// tools/deploy/configure-target.ts — SPEC-478
import { saveDeployConfig } from '../../storage/deploy-config-store.js';
import { trackCost } from '../../engine/cost-tracking/operation-tracker.js';
export async function handleConfigureDeployTarget(input) {
    return trackCost(input.projectPath, 'configure_deploy_target', async () => {
        try {
            await saveDeployConfig(input.projectPath, {
                provider: input.provider,
                token: input.token,
                projectId: input.projectId,
                team: input.team,
                defaultEnvironment: 'preview',
            });
            return {
                content: [
                    {
                        type: 'text',
                        text: `Deploy target configured: ${input.provider}${input.projectId ? ` (project: ${input.projectId})` : ''}. Use deploy_spec to trigger a deployment.`,
                    },
                ],
                structuredContent: { provider: input.provider, ok: true },
            };
        }
        catch (err) {
            return {
                content: [
                    {
                        type: 'text',
                        text: `Failed to save deploy config: ${err instanceof Error ? err.message : String(err)}`,
                    },
                ],
                isError: true,
            };
        }
    }); // end trackCost
}
//# sourceMappingURL=configure-target.js.map