@zaip-ai/cli 6.2.0 → 7.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/dist/commands/init.d.ts +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +16 -3
- package/dist/commands/init.js.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/services/adapter-codex-config.d.ts +3 -0
- package/dist/services/adapter-codex-config.d.ts.map +1 -0
- package/dist/services/adapter-codex-config.js +119 -0
- package/dist/services/adapter-codex-config.js.map +1 -0
- package/dist/services/adapter-config-overlay.d.ts +8 -0
- package/dist/services/adapter-config-overlay.d.ts.map +1 -0
- package/dist/services/adapter-config-overlay.js +17 -0
- package/dist/services/adapter-config-overlay.js.map +1 -0
- package/dist/services/adapter-hook-sources.d.ts +4 -4
- package/dist/services/adapter-hook-sources.d.ts.map +1 -1
- package/dist/services/adapter-hook-sources.js +4 -4
- package/dist/services/adapter-hook-sources.js.map +1 -1
- package/dist/services/adapters.d.ts +3 -2
- package/dist/services/adapters.d.ts.map +1 -1
- package/dist/services/adapters.js +35 -144
- package/dist/services/adapters.js.map +1 -1
- package/dist/services/adapters.test.js +12 -0
- package/dist/services/adapters.test.js.map +1 -1
- package/dist/services/agent-adapters.d.ts +2 -98
- package/dist/services/agent-adapters.d.ts.map +1 -1
- package/dist/services/agent-adapters.js +30 -29
- package/dist/services/agent-adapters.js.map +1 -1
- package/dist/services/agent-adapters.test.js +4 -2
- package/dist/services/agent-adapters.test.js.map +1 -1
- package/dist/services/agent-guidance-types.d.ts +98 -0
- package/dist/services/agent-guidance-types.d.ts.map +1 -0
- package/dist/services/agent-guidance-types.js +4 -0
- package/dist/services/agent-guidance-types.js.map +1 -0
- package/dist/services/catalog-toml.d.ts +4 -0
- package/dist/services/catalog-toml.d.ts.map +1 -0
- package/dist/services/catalog-toml.js +10 -0
- package/dist/services/catalog-toml.js.map +1 -0
- package/dist/services/catalog-write-scope.d.ts +4 -0
- package/dist/services/catalog-write-scope.d.ts.map +1 -0
- package/dist/services/catalog-write-scope.js +18 -0
- package/dist/services/catalog-write-scope.js.map +1 -0
- package/dist/services/claude-settings-overlay.d.ts +4 -0
- package/dist/services/claude-settings-overlay.d.ts.map +1 -0
- package/dist/services/claude-settings-overlay.js +58 -0
- package/dist/services/claude-settings-overlay.js.map +1 -0
- package/dist/services/client-selection.d.ts +17 -0
- package/dist/services/client-selection.d.ts.map +1 -0
- package/dist/services/client-selection.js +67 -0
- package/dist/services/client-selection.js.map +1 -0
- package/dist/services/codex-conversation-lifecycle-hook.d.ts.map +1 -1
- package/dist/services/codex-conversation-lifecycle-hook.js +20 -9
- package/dist/services/codex-conversation-lifecycle-hook.js.map +1 -1
- package/dist/services/codex-git-publication-template.d.ts +2 -0
- package/dist/services/codex-git-publication-template.d.ts.map +1 -0
- package/dist/services/codex-git-publication-template.js +120 -0
- package/dist/services/codex-git-publication-template.js.map +1 -0
- package/dist/services/codex-github-setup-template.d.ts +3 -0
- package/dist/services/codex-github-setup-template.d.ts.map +1 -0
- package/dist/services/codex-github-setup-template.js +176 -0
- package/dist/services/codex-github-setup-template.js.map +1 -0
- package/dist/services/codex-hook-activation.d.ts +1 -1
- package/dist/services/codex-hook-activation.d.ts.map +1 -1
- package/dist/services/codex-hook-activation.js +55 -10
- package/dist/services/codex-hook-activation.js.map +1 -1
- package/dist/services/codex-host-diagnostic.d.ts +10 -0
- package/dist/services/codex-host-diagnostic.d.ts.map +1 -0
- package/dist/services/codex-host-diagnostic.js +5 -0
- package/dist/services/codex-host-diagnostic.js.map +1 -0
- package/dist/services/codex-host-diagnostic.test.d.ts +2 -0
- package/dist/services/codex-host-diagnostic.test.d.ts.map +1 -0
- package/dist/services/codex-host-diagnostic.test.js +24 -0
- package/dist/services/codex-host-diagnostic.test.js.map +1 -0
- package/dist/services/codex-literal-read-sequence-template.d.ts.map +1 -1
- package/dist/services/codex-literal-read-sequence-template.js +97 -6
- package/dist/services/codex-literal-read-sequence-template.js.map +1 -1
- package/dist/services/codex-native-authority-policy-template.d.ts +2 -0
- package/dist/services/codex-native-authority-policy-template.d.ts.map +1 -0
- package/dist/services/codex-native-authority-policy-template.js +132 -0
- package/dist/services/codex-native-authority-policy-template.js.map +1 -0
- package/dist/services/codex-native-tool-authority-template.d.ts.map +1 -1
- package/dist/services/codex-native-tool-authority-template.js +147 -145
- package/dist/services/codex-native-tool-authority-template.js.map +1 -1
- package/dist/services/codex-node-options-template.d.ts +3 -0
- package/dist/services/codex-node-options-template.d.ts.map +1 -0
- package/dist/services/codex-node-options-template.js +30 -0
- package/dist/services/codex-node-options-template.js.map +1 -0
- package/dist/services/codex-pre-tool-cli-capture-template.d.ts.map +1 -1
- package/dist/services/codex-pre-tool-cli-capture-template.js +214 -10
- package/dist/services/codex-pre-tool-cli-capture-template.js.map +1 -1
- package/dist/services/codex-pre-tool-cloud-template.d.ts.map +1 -1
- package/dist/services/codex-pre-tool-cloud-template.js +149 -12
- package/dist/services/codex-pre-tool-cloud-template.js.map +1 -1
- package/dist/services/codex-pre-tool-dependencies.test-support.d.ts.map +1 -1
- package/dist/services/codex-pre-tool-dependencies.test-support.js +13 -1
- package/dist/services/codex-pre-tool-dependencies.test-support.js.map +1 -1
- package/dist/services/codex-pre-tool-hook-template-bootstrap.test.js +2 -2
- package/dist/services/codex-pre-tool-hook-template-bootstrap.test.js.map +1 -1
- package/dist/services/codex-pre-tool-hook-template.d.ts.map +1 -1
- package/dist/services/codex-pre-tool-hook-template.js +53 -138
- package/dist/services/codex-pre-tool-hook-template.js.map +1 -1
- package/dist/services/codex-pre-tool-hook-template.test.js +13 -7
- package/dist/services/codex-pre-tool-hook-template.test.js.map +1 -1
- package/dist/services/codex-pre-tool-host-context-template.d.ts.map +1 -1
- package/dist/services/codex-pre-tool-host-context-template.js +23 -0
- package/dist/services/codex-pre-tool-host-context-template.js.map +1 -1
- package/dist/services/codex-pre-tool-policy-template.d.ts.map +1 -1
- package/dist/services/codex-pre-tool-policy-template.js +5 -3
- package/dist/services/codex-pre-tool-policy-template.js.map +1 -1
- package/dist/services/codex-pre-tool-release-review-template.d.ts.map +1 -1
- package/dist/services/codex-pre-tool-release-review-template.js +161 -2
- package/dist/services/codex-pre-tool-release-review-template.js.map +1 -1
- package/dist/services/codex-pre-tool-support-template.d.ts.map +1 -1
- package/dist/services/codex-pre-tool-support-template.js +88 -129
- package/dist/services/codex-pre-tool-support-template.js.map +1 -1
- package/dist/services/codex-release-publication-template.d.ts +2 -0
- package/dist/services/codex-release-publication-template.d.ts.map +1 -0
- package/dist/services/codex-release-publication-template.js +127 -0
- package/dist/services/codex-release-publication-template.js.map +1 -0
- package/dist/services/codex-repository-profile-template.d.ts +2 -0
- package/dist/services/codex-repository-profile-template.d.ts.map +1 -0
- package/dist/services/codex-repository-profile-template.js +84 -0
- package/dist/services/codex-repository-profile-template.js.map +1 -0
- package/dist/services/codex-rules.d.ts +1 -1
- package/dist/services/codex-rules.d.ts.map +1 -1
- package/dist/services/codex-rules.js +2 -2
- package/dist/services/codex-storage-handoff-template.d.ts +2 -0
- package/dist/services/codex-storage-handoff-template.d.ts.map +1 -0
- package/dist/services/codex-storage-handoff-template.js +18 -0
- package/dist/services/codex-storage-handoff-template.js.map +1 -0
- package/dist/services/codex-subagent-hook-template.d.ts +1 -1
- package/dist/services/codex-subagent-hook-template.d.ts.map +1 -1
- package/dist/services/codex-subagent-hook-template.js +7 -6
- package/dist/services/codex-subagent-hook-template.js.map +1 -1
- package/dist/services/codex-task-delivery-authority-template.d.ts +3 -0
- package/dist/services/codex-task-delivery-authority-template.d.ts.map +1 -0
- package/dist/services/codex-task-delivery-authority-template.js +206 -0
- package/dist/services/codex-task-delivery-authority-template.js.map +1 -0
- package/dist/services/codex-validation-runtime-template.js +1 -1
- package/dist/services/codex-windows-hook-command.js +2 -2
- package/dist/services/codex-windows-hook-command.js.map +1 -1
- package/dist/services/developer-identity-fixture.d.ts.map +1 -1
- package/dist/services/developer-identity-fixture.js +3 -2
- package/dist/services/developer-identity-fixture.js.map +1 -1
- package/dist/services/doctor.d.ts.map +1 -1
- package/dist/services/doctor.js +5 -1
- package/dist/services/doctor.js.map +1 -1
- package/dist/services/github-setup-status.d.ts +6 -3
- package/dist/services/github-setup-status.d.ts.map +1 -1
- package/dist/services/github-setup-status.js +9 -5
- package/dist/services/github-setup-status.js.map +1 -1
- package/dist/services/github-setup-status.test.js +69 -3
- package/dist/services/github-setup-status.test.js.map +1 -1
- package/dist/services/global-codex-config.d.ts.map +1 -1
- package/dist/services/global-codex-config.js +3 -0
- package/dist/services/global-codex-config.js.map +1 -1
- package/dist/services/global-codex-project-trust.d.ts +17 -0
- package/dist/services/global-codex-project-trust.d.ts.map +1 -0
- package/dist/services/global-codex-project-trust.js +186 -0
- package/dist/services/global-codex-project-trust.js.map +1 -0
- package/dist/services/global-codex-project-trust.test.d.ts +2 -0
- package/dist/services/global-codex-project-trust.test.d.ts.map +1 -0
- package/dist/services/global-codex-project-trust.test.js +188 -0
- package/dist/services/global-codex-project-trust.test.js.map +1 -0
- package/dist/services/install-agents-template.d.ts.map +1 -1
- package/dist/services/install-agents-template.js +95 -190
- package/dist/services/install-agents-template.js.map +1 -1
- package/dist/services/install-client-selection.d.ts +6 -0
- package/dist/services/install-client-selection.d.ts.map +1 -0
- package/dist/services/install-client-selection.js +24 -0
- package/dist/services/install-client-selection.js.map +1 -0
- package/dist/services/install-result.d.ts +6 -0
- package/dist/services/install-result.d.ts.map +1 -0
- package/dist/services/install-result.js +14 -0
- package/dist/services/install-result.js.map +1 -0
- package/dist/services/install-storage-boundary.d.ts +6 -0
- package/dist/services/install-storage-boundary.d.ts.map +1 -0
- package/dist/services/install-storage-boundary.js +173 -0
- package/dist/services/install-storage-boundary.js.map +1 -0
- package/dist/services/install-storage-boundary.test.d.ts +2 -0
- package/dist/services/install-storage-boundary.test.d.ts.map +1 -0
- package/dist/services/install-storage-boundary.test.js +110 -0
- package/dist/services/install-storage-boundary.test.js.map +1 -0
- package/dist/services/install-template-backup.d.ts +3 -0
- package/dist/services/install-template-backup.d.ts.map +1 -0
- package/dist/services/install-template-backup.js +46 -0
- package/dist/services/install-template-backup.js.map +1 -0
- package/dist/services/install-template-lock.d.ts +2 -0
- package/dist/services/install-template-lock.d.ts.map +1 -0
- package/dist/services/install-template-lock.js +32 -0
- package/dist/services/install-template-lock.js.map +1 -0
- package/dist/services/install-template-policy.d.ts +16 -0
- package/dist/services/install-template-policy.d.ts.map +1 -1
- package/dist/services/install-template-policy.js +73 -1
- package/dist/services/install-template-policy.js.map +1 -1
- package/dist/services/install-template-render.d.ts +11 -0
- package/dist/services/install-template-render.d.ts.map +1 -0
- package/dist/services/install-template-render.js +53 -0
- package/dist/services/install-template-render.js.map +1 -0
- package/dist/services/install-template-rule-files.d.ts +3 -0
- package/dist/services/install-template-rule-files.d.ts.map +1 -0
- package/dist/services/install-template-rule-files.js +24 -0
- package/dist/services/install-template-rule-files.js.map +1 -0
- package/dist/services/logger.d.ts.map +1 -1
- package/dist/services/logger.js +35 -10
- package/dist/services/logger.js.map +1 -1
- package/dist/services/logger.test.js +65 -16
- package/dist/services/logger.test.js.map +1 -1
- package/dist/services/project-config-upgrade.d.ts +3 -0
- package/dist/services/project-config-upgrade.d.ts.map +1 -0
- package/dist/services/project-config-upgrade.js +58 -0
- package/dist/services/project-config-upgrade.js.map +1 -0
- package/dist/services/runtime-template-deploy-policy.test.d.ts +2 -0
- package/dist/services/runtime-template-deploy-policy.test.d.ts.map +1 -0
- package/dist/services/runtime-template-deploy-policy.test.js +26 -0
- package/dist/services/runtime-template-deploy-policy.test.js.map +1 -0
- package/dist/services/runtime-template-test-support.d.ts +14 -0
- package/dist/services/runtime-template-test-support.d.ts.map +1 -1
- package/dist/services/runtime-template-test-support.js +18 -0
- package/dist/services/runtime-template-test-support.js.map +1 -1
- package/dist/services/runtime-template.test.js +14 -63
- package/dist/services/runtime-template.test.js.map +1 -1
- package/dist/services/sqlite-bootstrap.js +2 -2
- package/dist/services/sqlite-bootstrap.js.map +1 -1
- package/dist/services/stack-node.js +2 -2
- package/dist/services/stack-node.js.map +1 -1
- package/dist/services/stack-terraform.d.ts.map +1 -1
- package/dist/services/stack-terraform.js +5 -5
- package/dist/services/stack-terraform.js.map +1 -1
- package/dist/services/template-packed-path.test.d.ts +2 -0
- package/dist/services/template-packed-path.test.d.ts.map +1 -0
- package/dist/services/template-packed-path.test.js +30 -0
- package/dist/services/template-packed-path.test.js.map +1 -0
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -1
- package/templates/.agents/README-ENG.md +5 -1
- package/templates/.agents/README.md +5 -1
- package/templates/.agents/architecture/software-architecture.md +7 -1
- package/templates/.agents/config/agents/catalog.yaml +25 -12
- package/templates/.agents/config/agents/discovery.json +2 -2
- package/templates/.agents/config/autonomous-cloud-inputs.json +3 -3
- package/templates/.agents/config/clients/codex/agents/zaip-agent-analyst.toml +4 -2
- package/templates/.agents/config/clients/codex/agents/zaip-agent-auditor.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-backend.toml +6 -4
- package/templates/.agents/config/clients/codex/agents/zaip-agent-brand-strategist.toml +3 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-builder.toml +6 -4
- package/templates/.agents/config/clients/codex/agents/zaip-agent-cloud-engineer.toml +5 -3
- package/templates/.agents/config/clients/codex/agents/zaip-agent-data-analyst.toml +3 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-designer.toml +7 -4
- package/templates/.agents/config/clients/codex/agents/zaip-agent-finalizer.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-frontend.toml +9 -6
- package/templates/.agents/config/clients/codex/agents/zaip-agent-general-operations.toml +3 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-governance-compliance.toml +3 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-growth-strategist.toml +3 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-integrator.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-marketing-analyst.toml +5 -3
- package/templates/.agents/config/clients/codex/agents/zaip-agent-orchestrator.toml +4 -4
- package/templates/.agents/config/clients/codex/agents/zaip-agent-refactoring-specialist.toml +3 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-reviewer.toml +3 -3
- package/templates/.agents/config/clients/codex/agents/zaip-agent-sales-specialist.toml +3 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-security-auditor.toml +1 -1
- package/templates/.agents/config/clients/codex/agents/zaip-agent-task-executor.toml +6 -3
- package/templates/.agents/config/clients/codex/agents/zaip-agent-website-developer.toml +7 -4
- package/templates/.agents/config/clients/codex/agents/zaip-agent-writer.toml +3 -1
- package/templates/.agents/config/project.yaml +7 -2
- package/templates/.agents/dashboard/.zaip-managed.json +282 -142
- package/templates/.agents/dashboard/apps/frontend/dist/assets/CostCalculationGuidePage-DZ2mnR6k.js +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{DashboardHelpDialog-tg6j_0De.js → DashboardHelpDialog-DnxpHJSo.js} +45 -10
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{PricingSettingsDialog-DlkxF4w_.js → PricingSettingsDialog-DsFTUwhL.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-BCsdQtWG.js +3 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{TraceabilityWorkspace-B-5yP5Jx.js → TraceabilityWorkspace-BN8FwP5S.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{cost-monitor-C2AFYBu_.css → cost-monitor-BESDS3aE.css} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-YfoKMzCQ.js +59 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{dashboard-localization-CqicG5jJ.js → dashboard-localization-BVBhiAAS.js} +5 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{icons-vendor-CjGGux6h.js → icons-vendor-DSdQAua1.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-4cl5FQBn.css +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-uIVtG2ZR.js +2 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{react-vendor-B9jZSAKf.js → react-vendor-rGvJzdn5.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{traceability-DFpwb0TN.js → traceability-Boz50W9b.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/index.html +8 -7
- package/templates/.agents/dashboard/apps/frontend/index.html +1 -0
- package/templates/.agents/dashboard/apps/frontend/package.json +1 -1
- package/templates/.agents/dashboard/apps/frontend/playwright.dom.config.ts +2 -2
- package/templates/.agents/dashboard/apps/frontend/src/AppLoadingPanels.tsx +10 -7
- package/templates/.agents/dashboard/apps/frontend/src/AppOverlays.tsx +22 -19
- package/templates/.agents/dashboard/apps/frontend/src/CostCalculationGuidePage.tsx +16 -117
- package/templates/.agents/dashboard/apps/frontend/src/CostCharts.percentages.test.tsx +75 -0
- package/templates/.agents/dashboard/apps/frontend/src/CostTelemetryGuide.tsx +36 -0
- package/templates/.agents/dashboard/apps/frontend/src/DashboardToast.tsx +9 -0
- package/templates/.agents/dashboard/apps/frontend/src/ProjectSettingsPage.dom.test.ts +1 -1
- package/templates/.agents/dashboard/apps/frontend/src/ProjectStackEditor.tsx +1 -0
- package/templates/.agents/dashboard/apps/frontend/src/ReconciliationFeedback.dom.test.ts +1 -1
- package/templates/.agents/dashboard/apps/frontend/src/ReconciliationFeedback.tsx +22 -19
- package/templates/.agents/dashboard/apps/frontend/src/TraceabilityWorkspace.dom.e2e.ts +5 -2
- package/templates/.agents/dashboard/apps/frontend/src/WorkspaceStatus.dom.test.ts +86 -0
- package/templates/.agents/dashboard/apps/frontend/src/WorkspaceStatus.test.tsx +44 -0
- package/templates/.agents/dashboard/apps/frontend/src/WorkspaceStatus.tsx +37 -12
- package/templates/.agents/dashboard/apps/frontend/src/cost-guide-calculations.ts +118 -0
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-api-sqlite-view.ts +3 -0
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-api.ts +15 -31
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-http-transport.ts +30 -0
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-runtime-status.ts +4 -1
- package/templates/.agents/dashboard/apps/frontend/src/main.tsx +1 -0
- package/templates/.agents/dashboard/apps/frontend/src/project-settings-model.ts +2 -0
- package/templates/.agents/dashboard/apps/frontend/src/project-settings.test.ts +17 -0
- package/templates/.agents/dashboard/apps/frontend/src/snapshot-coherence.test.ts +0 -20
- package/templates/.agents/dashboard/apps/frontend/src/snapshot-observer.test.ts +112 -0
- package/templates/.agents/dashboard/apps/frontend/src/snapshot-observer.ts +147 -0
- package/templates/.agents/dashboard/apps/frontend/src/sqlite-compact-cost-adapter.ts +100 -0
- package/templates/.agents/dashboard/apps/frontend/src/sqlite-page-export.test.ts +20 -0
- package/templates/.agents/dashboard/apps/frontend/src/sqlite-page-export.ts +15 -0
- package/templates/.agents/dashboard/apps/frontend/src/styles-pricing.css +265 -0
- package/templates/.agents/dashboard/apps/frontend/src/styles.css +21 -265
- package/templates/.agents/dashboard/apps/frontend/src/use-app-cost-loaders.test.ts +35 -0
- package/templates/.agents/dashboard/apps/frontend/src/use-app-cost-loaders.ts +11 -87
- package/templates/.agents/dashboard/apps/frontend/src/use-app-effects.ts +26 -199
- package/templates/.agents/dashboard/apps/frontend/src/use-app-trace-documents.navigation.test.tsx +1 -1
- package/templates/.agents/dashboard/apps/frontend/src/use-app-work-board.test.ts +65 -0
- package/templates/.agents/dashboard/apps/frontend/src/use-app-work-board.ts +17 -1
- package/templates/.agents/dashboard/apps/frontend/src/use-dashboard-app-model.tsx +2 -2
- package/templates/.agents/dashboard/apps/frontend/src/use-operations-detail-export.ts +10 -0
- package/templates/.agents/dashboard/apps/frontend/src/use-runtime-status.dom.test.ts +86 -0
- package/templates/.agents/dashboard/apps/frontend/src/use-runtime-status.ts +4 -5
- package/templates/.agents/dashboard/apps/frontend/src/workspace-status.css +42 -0
- package/templates/.agents/dashboard/apps/frontend/vite.config.ts +1 -1
- package/templates/.agents/dashboard/modules/cost-monitor/package.json +1 -1
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CompactLifecycleCostTable.test.ts +11 -10
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CompactLifecycleCostTable.tsx +39 -15
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostCharts.test.ts +27 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostCharts.tsx +89 -83
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostGroupsTable.tsx +14 -24
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorPage.test.ts +1 -27
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorPage.tsx +12 -63
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTables.availability.test.ts +60 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTables.test.ts +1 -15
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/compact-cost-export-source.ts +85 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/compact-cost-page-range.test.ts +34 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-chart-presentation.ts +74 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-charts.css +117 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-group-table-totals.ts +29 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-export-sources.ts +19 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-page-state.ts +27 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor.css +6 -117
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/use-cost-group-page.ts +3 -1
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-summary-projection.ts +9 -32
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/cost-summary-metrics.ts +33 -0
- package/templates/.agents/dashboard/modules/operations/package.json +1 -1
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsLocaleMenu.tsx +58 -0
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverviewTopPanel.navigation.test.tsx +1 -1
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsPage.tsx +16 -47
- package/templates/.agents/dashboard/modules/operations/src/react/UnifiedWorkBoard.navigation.test.ts +1 -1
- package/templates/.agents/dashboard/modules/operations/src/react/export/ExcelExportAction.test.ts +4 -100
- package/templates/.agents/dashboard/modules/operations/src/react/export/ExcelExportAction.tsx +25 -89
- package/templates/.agents/dashboard/modules/operations/src/react/export/ExcelExportColumns.ts +1 -0
- package/templates/.agents/dashboard/modules/operations/src/react/export/ExcelExportDuration.test.ts +105 -0
- package/templates/.agents/dashboard/modules/operations/src/react/export/export-duration-rows.ts +91 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-page-contract.ts +4 -0
- package/templates/.agents/dashboard/modules/traceability/package.json +1 -1
- package/templates/.agents/dashboard/packages/branding/package.json +1 -1
- package/templates/.agents/dashboard/packages/contracts/package.json +2 -2
- package/templates/.agents/dashboard/packages/contracts/src/export.ts +2 -0
- package/templates/.agents/dashboard/packages/data-export/package.json +1 -1
- package/templates/.agents/dashboard/packages/data-export/src/index.test.ts +30 -0
- package/templates/.agents/dashboard/packages/data-export/src/index.ts +10 -0
- package/templates/.agents/dashboard/packages/data-export/src/ooxml-stream.ts +50 -3
- package/templates/.agents/dashboard/packages/local-runtime/DIAGNOSTICS.md +2 -1
- package/templates/.agents/dashboard/packages/local-runtime/dashboard-build-fingerprint.mjs +1 -1
- package/templates/.agents/dashboard/packages/local-runtime/dashboard-diagnostics.mjs +4 -2
- package/templates/.agents/dashboard/packages/local-runtime/dashboard-diagnostics.test.mjs +1 -1
- package/templates/.agents/dashboard/packages/local-runtime/dist/server.cjs +314 -269
- package/templates/.agents/dashboard/packages/local-runtime/dist/sqlite-read-model.cjs +266 -222
- package/templates/.agents/dashboard/packages/local-runtime/package.json +3 -3
- package/templates/.agents/dashboard/packages/local-runtime/scripts/verify-dashboard-executable-startup.mjs +4 -1
- package/templates/.agents/dashboard/packages/local-runtime/scripts/verify-dashboard-reconciliation-executable.mjs +4 -4
- package/templates/.agents/dashboard/packages/local-runtime/server.mjs +314 -269
- package/templates/.agents/dashboard/packages/local-runtime/src/active-codex-telemetry.test.ts +51 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/active-codex-telemetry.ts +15 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/dashboard-diagnostics.test.ts +1 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/project-settings.ts +3 -40
- package/templates/.agents/dashboard/packages/local-runtime/src/project-stack-labels.ts +40 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/retained-worktree-capture.ts +81 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-board.ts +11 -2
- package/templates/.agents/dashboard/packages/local-runtime/src/server-hono-security.test.ts +40 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-operations-routes.ts +33 -14
- package/templates/.agents/dashboard/packages/local-runtime/src/server-project-settings-routes.test.ts +83 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-project-settings-routes.ts +41 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-projections.ts +3 -19
- package/templates/.agents/dashboard/packages/local-runtime/src/server-reconciliation-diagnostics.test.ts +2 -2
- package/templates/.agents/dashboard/packages/local-runtime/src/server-reconciliation-refresh.test.ts +61 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-reconciliation-route.ts +2 -2
- package/templates/.agents/dashboard/packages/local-runtime/src/server-run-range.ts +18 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot-refresh.ts +3 -36
- package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot-worker-receipt.ts +38 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-work-priority-route.ts +18 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-workspace.ts +1 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server.ts +6 -32
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-summary-rollup.ts +47 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-financial-consistency.test.ts +133 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-financial-entity-page.ts +159 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-incremental-refresh.test.ts +12 -2
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-operations-work-list.ts +17 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-operation-pages.ts +71 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-summary.ts +5 -40
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-temporal-dimension.ts +29 -7
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-view-page.ts +7 -55
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-counts-every-root-execution-day-returns.test.ts +16 -24
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-counts-fixture.test-support.ts +27 -5
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-filesystem.ts +20 -37
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-keeps-orphan-telemetry-out-kanban-without.test.ts +9 -9
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-marks-token-cost-telemetry-unavailable-when.test.ts +3 -3
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-multi-provider.test.ts +14 -20
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-rebuilds-disposable-snapshot-serves-zaip-records.test.ts +11 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-schema.ts +1 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-work-financial-summary.ts +38 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/telemetry-reconciliation.integration.test.ts +223 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/work-priority-contract.test.ts +5 -5
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-launch-page.test.mjs +59 -3
- package/templates/.agents/dashboard/packages/ui/package.json +1 -1
- package/templates/.agents/dashboard/packages/windows-launcher/Program.cs +1 -1
- package/templates/.agents/dashboard/packages/windows-launcher/build-dashboard-launcher.ps1 +1 -1
- package/templates/.agents/dashboard/tests/e2e/package.json +1 -1
- package/templates/.agents/dashboard/tests/e2e/playwright.config.ts +1 -0
- package/templates/.agents/dashboard/tests/e2e/specs/dashboard.spec.ts +11 -15
- package/templates/.agents/dashboard/tests/e2e/specs/work-board-hydration.ts +40 -11
- package/templates/.agents/dashboard/zaip-dashboard-windows.exe +0 -0
- package/templates/.agents/design/.zaip-managed.json +498 -54
- package/templates/.agents/design/apps/catalog/dist/assets/index-BH6Fxbj0.css +1 -0
- package/templates/.agents/design/apps/catalog/dist/assets/index-BK0aBll9.css +1 -0
- package/templates/.agents/design/apps/catalog/dist/assets/index-Bzhb1wb_.js +76 -0
- package/templates/.agents/design/apps/catalog/dist/assets/index-CB-MTaWq.js +76 -0
- package/templates/.agents/design/apps/catalog/dist/assets/index-CIqfUcy8.js +76 -0
- package/templates/.agents/design/apps/catalog/dist/assets/index-Ccq-NOLA.js +76 -0
- package/templates/.agents/design/apps/catalog/dist/assets/index-Ch2eyD9C.js +76 -0
- package/templates/.agents/design/apps/catalog/dist/assets/index-Cy64ytQr.js +67 -0
- package/templates/.agents/design/apps/catalog/dist/assets/index-DfxEbFlq.js +76 -0
- package/templates/.agents/design/apps/catalog/dist/assets/index-Dqt6mTvD.js +76 -0
- package/templates/.agents/design/apps/catalog/dist/assets/index-rz8gOc0a.js +76 -0
- package/templates/.agents/design/apps/catalog/dist/index.html +2 -2
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{CatalogShell-BJ8b4xZr.js → CatalogShell-D2YyQQrT.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{Color-6AOWCN3U-CQLHzznn.js → Color-6AOWCN3U-BmCuNXMg.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/Components.stories-DF9KC_gA.js +158 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/DashboardFilters.stories-D17Q1egS.js +5 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/DashboardFiltersSpecimen-CEBrLT2k.js +1 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{DesignSystem.stories-ED52wFjY.js → DesignSystem.stories-BibuRt_c.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{DocsRenderer-JROSPFPF-BcLgM80v.js → DocsRenderer-JROSPFPF-GkfL8_gG.js} +4 -4
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/Maker.stories-Dv9Keun_.js +13 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/MakerSpecimen-DGwAKRi9.css +1 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/MakerSpecimen-mkkuFOp_.js +5 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{Primitives-DV6Bpudf.js → Primitives-n1UqmNvo.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/ReconciliationSpecimen-BJnfyyG3.js +1 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/ReconciliationSpecimen.stories-CH-GF9Rk.js +13 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{WithTooltip-7X4HQR7L-BKNiAz_E.js → WithTooltip-7X4HQR7L-BPXo6OoG.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{WorkspaceStatus.stories-BL19HGOo.js → WorkspaceStatus.stories-Cie1f_yU.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/WorkspaceStatusSpecimen-GcYWBBSp.js +1 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{chunk-DRQKCCAG-DZBcXL-p.js → chunk-DRQKCCAG-Cn4_bvJJ.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{chunk-W22LQPXL-CF3y2mfo.js → chunk-W22LQPXL-CQrULeB4.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{components-BVjxMRGq.js → components-uiaDZHE7.js} +5 -5
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/formatter-L2YTDE3Q-DfjRffT7.js +1 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{iframe-CTWGZcEe.js → iframe-BgEb-d5o.js} +4 -4
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/iframe-D1JaPXfV.css +1 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{react-18-B9_a4mHb.js → react-18-BZ-Ne01c.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/react-CwpjKEyW.js +1 -0
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{syntaxhighlighter-YFXUGROL-F_p8E2xc.js → syntaxhighlighter-YFXUGROL-BvuP8St2.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/{theming-fbSD9ZLF.js → theming-BGScn6Yf.js} +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/iframe.html +2 -2
- package/templates/.agents/design/apps/catalog/dist/storybook/index.json +1 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/sb-addons/a11y-2/manager-bundle.js +3 -3
- package/templates/.agents/design/apps/catalog/dist/storybook/sb-addons/docs-1/manager-bundle.js +4 -4
- package/templates/.agents/design/apps/catalog/dist/storybook/sb-addons/storybook-core-server-presets-0/common-manager-bundle.js +3 -3
- package/templates/.agents/design/apps/catalog/package.json +2 -2
- package/templates/.agents/design/apps/catalog/src/components/WorkspaceStatusSpecimen.tsx +32 -1
- package/templates/.agents/design/apps/catalog/src/pages/ComponentsPage.tsx +14 -3
- package/templates/.agents/design/apps/catalog/src/specimens/MAKER-HANDOFF.md +134 -0
- package/templates/.agents/design/apps/catalog/src/specimens/MakerSpecimen.test.tsx +143 -0
- package/templates/.agents/design/apps/catalog/src/specimens/MakerSpecimen.tsx +132 -0
- package/templates/.agents/design/apps/catalog/src/specimens/maker-fixtures.d.ts +15 -0
- package/templates/.agents/design/apps/catalog/src/specimens/maker-fixtures.js +86 -0
- package/templates/.agents/design/apps/catalog/src/specimens/maker-native.d.ts +1 -0
- package/templates/.agents/design/apps/catalog/src/specimens/maker-native.js +332 -0
- package/templates/.agents/design/apps/catalog/src/stories/Maker.stories.tsx +24 -0
- package/templates/.agents/design/apps/catalog/src/stories/WorkspaceStatus.stories.tsx +1 -0
- package/templates/.agents/design/apps/catalog/src/styles/maker-specimen.css +285 -0
- package/templates/.agents/design/design-system-maker/API.md +468 -0
- package/templates/.agents/design/design-system-maker/NOTICE.md +13 -0
- package/templates/.agents/design/design-system-maker/README.md +138 -0
- package/templates/.agents/design/design-system-maker/SOURCE-PROVENANCE.json +62 -0
- package/templates/.agents/design/design-system-maker/build.json +524 -0
- package/templates/.agents/design/design-system-maker/frontend/ADAPTATION.md +351 -0
- package/templates/.agents/design/design-system-maker/frontend/MAKER-REPAIR-HANDOFF.md +134 -0
- package/templates/.agents/design/design-system-maker/frontend/advanced/examples.js +30 -0
- package/templates/.agents/design/design-system-maker/frontend/advanced/index.html +75 -0
- package/templates/.agents/design/design-system-maker/frontend/advanced/index.js +30 -0
- package/templates/.agents/design/design-system-maker/frontend/catalog/filters.js +132 -0
- package/templates/.agents/design/design-system-maker/frontend/catalog/index.html +17 -0
- package/templates/.agents/design/design-system-maker/frontend/catalog/index.js +82 -0
- package/templates/.agents/design/design-system-maker/frontend/generate.html +74 -0
- package/templates/.agents/design/design-system-maker/frontend/generate.js +226 -0
- package/templates/.agents/design/design-system-maker/frontend/shared/api.js +112 -0
- package/templates/.agents/design/design-system-maker/frontend/shared/components.js +200 -0
- package/templates/.agents/design/design-system-maker/frontend/shared/diagnostic-view.js +218 -0
- package/templates/.agents/design/design-system-maker/frontend/shared/extraction-state.js +38 -0
- package/templates/.agents/design/design-system-maker/frontend/shared/failure-view.js +54 -0
- package/templates/.agents/design/design-system-maker/frontend/shared/frontend-scenarios-2.test.mjs +138 -0
- package/templates/.agents/design/design-system-maker/frontend/shared/frontend.test.mjs +357 -0
- package/templates/.agents/design/design-system-maker/frontend/shared/job-view.js +81 -0
- package/templates/.agents/design/design-system-maker/frontend/shared/model-hydration.js +26 -0
- package/templates/.agents/design/design-system-maker/frontend/shared/model.js +103 -0
- package/templates/.agents/design/design-system-maker/frontend/shared/palette-evidence.js +106 -0
- package/templates/.agents/design/design-system-maker/frontend/shared/palette-evidence.test.mjs +210 -0
- package/templates/.agents/design/design-system-maker/frontend/shared/palette-view.js +149 -0
- package/templates/.agents/design/design-system-maker/frontend/shared/preview.test.mjs +263 -0
- package/templates/.agents/design/design-system-maker/frontend/shared/report-view.js +267 -0
- package/templates/.agents/design/design-system-maker/frontend/shared/reprocess-dialog.js +192 -0
- package/templates/.agents/design/design-system-maker/frontend/shared/specimens.js +231 -0
- package/templates/.agents/design/design-system-maker/frontend/shared/viewer-actions.js +78 -0
- package/templates/.agents/design/design-system-maker/frontend/shared/viewer-detail.js +121 -0
- package/templates/.agents/design/design-system-maker/frontend/shared/viewer-summary.js +91 -0
- package/templates/.agents/design/design-system-maker/frontend/shared/visual-model.js +255 -0
- package/templates/.agents/design/design-system-maker/frontend/styles/advanced.css +128 -0
- package/templates/.agents/design/design-system-maker/frontend/styles/base.css +318 -0
- package/templates/.agents/design/design-system-maker/frontend/styles/catalog-filters.css +114 -0
- package/templates/.agents/design/design-system-maker/frontend/styles/diagnostic.css +298 -0
- package/templates/.agents/design/design-system-maker/frontend/styles/layout.css +320 -0
- package/templates/.agents/design/design-system-maker/frontend/styles/maker.css +7 -0
- package/templates/.agents/design/design-system-maker/frontend/styles/report.css +173 -0
- package/templates/.agents/design/design-system-maker/frontend/styles/reprocess-dialog.css +34 -0
- package/templates/.agents/design/design-system-maker/frontend/styles/specimen-foundations.css +363 -0
- package/templates/.agents/design/design-system-maker/frontend/styles/specimens.css +59 -0
- package/templates/.agents/design/design-system-maker/frontend/styles/viewer-summary.css +308 -0
- package/templates/.agents/design/design-system-maker/frontend/viewer/diagnostic.html +3 -0
- package/templates/.agents/design/design-system-maker/frontend/viewer/index.html +8 -0
- package/templates/.agents/design/design-system-maker/frontend/viewer/index.js +233 -0
- package/templates/.agents/design/design-system-maker/frontend/viewer/preview.html +3 -0
- package/templates/.agents/design/design-system-maker/frontend/viewer/specimen.js +88 -0
- package/templates/.agents/design/design-system-maker/launcher/Program.cs +117 -0
- package/templates/.agents/design/design-system-maker/runtime/chat-cli.mjs +27 -0
- package/templates/.agents/design/design-system-maker/runtime/chat-client.mjs +170 -0
- package/templates/.agents/design/design-system-maker/runtime/chat-contract.mjs +13 -0
- package/templates/.agents/design/design-system-maker/runtime/collection.mjs +269 -0
- package/templates/.agents/design/design-system-maker/runtime/contracts.mjs +383 -0
- package/templates/.agents/design/design-system-maker/runtime/design-codes.mjs +46 -0
- package/templates/.agents/design/design-system-maker/runtime/design-compose.mjs +118 -0
- package/templates/.agents/design/design-system-maker/runtime/design-markdown.mjs +154 -0
- package/templates/.agents/design/design-system-maker/runtime/import.mjs +137 -0
- package/templates/.agents/design/design-system-maker/runtime/io.mjs +121 -0
- package/templates/.agents/design/design-system-maker/runtime/job-progress.mjs +50 -0
- package/templates/.agents/design/design-system-maker/runtime/json-tokens.mjs +88 -0
- package/templates/.agents/design/design-system-maker/runtime/launch-identity.mjs +100 -0
- package/templates/.agents/design/design-system-maker/runtime/launch-protocol.mjs +88 -0
- package/templates/.agents/design/design-system-maker/runtime/launch-server.mjs +51 -0
- package/templates/.agents/design/design-system-maker/runtime/launch.mjs +107 -0
- package/templates/.agents/design/design-system-maker/runtime/local-actions.mjs +184 -0
- package/templates/.agents/design/design-system-maker/runtime/local-artifacts.mjs +228 -0
- package/templates/.agents/design/design-system-maker/runtime/local-request.mjs +100 -0
- package/templates/.agents/design/design-system-maker/runtime/lock.mjs +23 -0
- package/templates/.agents/design/design-system-maker/runtime/presentation.mjs +107 -0
- package/templates/.agents/design/design-system-maker/runtime/repository-source.mjs +200 -0
- package/templates/.agents/design/design-system-maker/runtime/reprocess-mode.mjs +17 -0
- package/templates/.agents/design/design-system-maker/runtime/request-contracts.mjs +121 -0
- package/templates/.agents/design/design-system-maker/runtime/serve.mjs +53 -0
- package/templates/.agents/design/design-system-maker/runtime/server.mjs +363 -0
- package/templates/.agents/design/design-system-maker/runtime/service-actions.mjs +59 -0
- package/templates/.agents/design/design-system-maker/runtime/service-host.mjs +32 -0
- package/templates/.agents/design/design-system-maker/runtime/service-projections.mjs +87 -0
- package/templates/.agents/design/design-system-maker/runtime/service.mjs +393 -0
- package/templates/.agents/design/design-system-maker/runtime/stop.mjs +38 -0
- package/templates/.agents/design/design-system-maker/runtime/trash.mjs +95 -0
- package/templates/.agents/design/design-system-maker/zaip-design-system-maker.exe +0 -0
- package/templates/.agents/design/packages/local-runtime/package.json +1 -1
- package/templates/.agents/requirements/autonomous-assurance.md +1 -1
- package/templates/.agents/requirements/cloud-hostinger-autonomy.md +9 -7
- package/templates/.agents/requirements/comparative-audit.md +1 -1
- package/templates/.agents/requirements/context-engine.md +1 -1
- package/templates/.agents/requirements/cost-observability.md +3 -3
- package/templates/.agents/requirements/dashboard-launch.md +1 -1
- package/templates/.agents/requirements/data-export.md +1 -1
- package/templates/.agents/requirements/design-system.md +1 -1
- package/templates/.agents/requirements/execution-engine.md +1 -1
- package/templates/.agents/requirements/kanban-dashboard.md +3 -3
- package/templates/.agents/requirements/landing-page-forms.md +39 -0
- package/templates/.agents/requirements/model-orchestration.md +1 -1
- package/templates/.agents/requirements/public-distribution.md +4 -4
- package/templates/.agents/requirements/site-performance.md +41 -0
- package/templates/.agents/requirements/software-architecture.md +1 -1
- package/templates/.agents/requirements/strategic-improvements.md +1 -1
- package/templates/.agents/requirements/work-lifecycle.md +1 -1
- package/templates/.agents/requirements/zaip-strategic-95.md +1 -1
- package/templates/.agents/rules/autonomy-decision.md +4 -1
- package/templates/.agents/rules/cloud-hostinger-autonomy.md +4 -1
- package/templates/.agents/rules/core.md +5 -2
- package/templates/.agents/rules/framework-maintenance.md +34 -0
- package/templates/.agents/rules/frontend-lite.md +2 -1
- package/templates/.agents/rules/github-deploy-auth.md +18 -0
- package/templates/.agents/rules/infisical-secrets.md +20 -0
- package/templates/.agents/rules/landing-page-forms.md +28 -0
- package/templates/.agents/rules/lead-measurement.md +20 -0
- package/templates/.agents/rules/local-sqlite-storage.md +2 -2
- package/templates/.agents/rules/local-state-storage.md +15 -0
- package/templates/.agents/rules/production-readiness.md +1 -1
- package/templates/.agents/rules/quality-assurance.md +36 -0
- package/templates/.agents/rules/repository-responsibility.md +38 -0
- package/templates/.agents/rules/security.md +1 -1
- package/templates/.agents/rules/site-performance.md +29 -0
- package/templates/.agents/rules/website-quality.md +31 -0
- package/templates/.agents/rules/workflow.md +1 -1
- package/templates/.agents/runtime/VERSION +1 -1
- package/templates/.agents/runtime/bin/zaip.mjs +2256 -802
- package/templates/.agents/runtime/checksums.sha256 +6 -6
- package/templates/.agents/runtime/manifest.json +1 -1
- package/templates/.agents/runtime/pnpm-lock.sha256 +1 -1
- package/templates/.agents/runtime/provenance.json +5 -5
- package/templates/.agents/runtime/sbom.cdx.json +7 -7
- package/templates/.agents/skills/criar-pasta-obsidian/SKILL.md +2 -2
- package/templates/.agents/skills/criar-pasta-obsidian/scripts/generate-obsidian-vault.mjs +7 -24
- package/templates/.agents/skills/criar-pasta-obsidian/scripts/generate-obsidian-vault.test.mjs +4 -2
- package/templates/.agents/skills/criar-pasta-obsidian/scripts/obsidian-format.mjs +20 -0
- package/templates/.agents/skills/zaip-skill-adapters/SKILL.md +6 -0
- package/templates/.agents/skills/zaip-skill-application-observability/references/lead-measurement.md +52 -0
- package/templates/.agents/skills/zaip-skill-architecture-design/SKILL.md +3 -1
- package/templates/.agents/skills/zaip-skill-auth-tenancy/references/lead-measurement.md +42 -0
- package/templates/.agents/skills/zaip-skill-author-skills/SKILL.md +1 -1
- package/templates/.agents/skills/zaip-skill-author-skills/references/engineering-skill-index.md +4 -0
- package/templates/.agents/skills/zaip-skill-author-skills/scripts/audit-skill-catalog.mjs +3 -0
- package/templates/.agents/skills/zaip-skill-author-skills/scripts/run-skill-tests.mjs +37 -7
- package/templates/.agents/skills/zaip-skill-author-skills/scripts/skill-test-plan.mjs +79 -0
- package/templates/.agents/skills/zaip-skill-author-skills/scripts/skill-test-plan.test.mjs +47 -0
- package/templates/.agents/skills/zaip-skill-backend/SKILL.md +2 -0
- package/templates/.agents/skills/zaip-skill-backend/references/deployment-environments.md +2 -2
- package/templates/.agents/skills/zaip-skill-change/references/observable-evidence.md +3 -3
- package/templates/.agents/skills/zaip-skill-cloud-engineering/SKILL.md +2 -0
- package/templates/.agents/skills/zaip-skill-cloudflare-access-setup/SKILL.md +16 -0
- package/templates/.agents/skills/zaip-skill-cloudflare-access-setup/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-cloudflare-access-setup/references/account-token.md +90 -0
- package/templates/.agents/skills/zaip-skill-cloudflare-access-setup/scripts/preview-access.mjs +91 -0
- package/templates/.agents/skills/zaip-skill-cloudflare-access-setup/scripts/preview-access.test.mjs +44 -0
- package/templates/.agents/skills/zaip-skill-cloudflare-github-deploy/SKILL.md +4 -2
- package/templates/.agents/skills/zaip-skill-cloudflare-github-deploy/references/workers-static-assets.md +1 -1
- package/templates/.agents/skills/zaip-skill-cloudflare-github-deploy/references/workflow-templates.md +5 -5
- package/templates/.agents/skills/zaip-skill-cloudflare-github-deploy/scripts/cloudflare-github-deploy-contract.test.mjs +24 -5
- package/templates/.agents/skills/zaip-skill-config/SKILL.md +33 -8
- package/templates/.agents/skills/zaip-skill-config/agents/openai.yaml +2 -2
- package/templates/.agents/skills/zaip-skill-config/references/repository-profiles.md +83 -0
- package/templates/.agents/skills/zaip-skill-dashboard-sqlite/SKILL.md +2 -2
- package/templates/.agents/skills/zaip-skill-data-modeling/references/lead-measurement.md +37 -0
- package/templates/.agents/skills/zaip-skill-database-migrations/references/lead-measurement.md +35 -0
- package/templates/.agents/skills/zaip-skill-decisions/SKILL.md +1 -0
- package/templates/.agents/skills/zaip-skill-deployment-pipeline/SKILL.md +11 -0
- package/templates/.agents/skills/zaip-skill-design-maker/SKILL.md +28 -0
- package/templates/.agents/skills/zaip-skill-design-maker/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-design-maker/references/chat-contract.md +46 -0
- package/templates/.agents/skills/zaip-skill-design-maker/references/compose.md +20 -0
- package/templates/.agents/skills/zaip-skill-design-maker/references/markdown.md +26 -0
- package/templates/.agents/skills/zaip-skill-design-maker/references/repository.md +24 -0
- package/templates/.agents/skills/zaip-skill-design-maker/references/url.md +24 -0
- package/templates/.agents/skills/zaip-skill-design-redesign/SKILL.md +41 -0
- package/templates/.agents/skills/zaip-skill-design-redesign/agents/openai.yaml +6 -0
- package/templates/.agents/skills/zaip-skill-design-reproduction/SKILL.md +47 -0
- package/templates/.agents/skills/zaip-skill-design-reproduction/agents/openai.yaml +6 -0
- package/templates/.agents/skills/zaip-skill-design-system/SKILL.md +6 -0
- package/templates/.agents/skills/zaip-skill-design-url-extraction/SKILL.md +50 -0
- package/templates/.agents/skills/zaip-skill-design-url-extraction/agents/openai.yaml +6 -0
- package/templates/.agents/skills/zaip-skill-design-url-extraction/references/capture-example.json +11 -0
- package/templates/.agents/skills/zaip-skill-design-url-extraction/references/runtime-workflow.md +127 -0
- package/templates/.agents/skills/zaip-skill-executar-fila-pronta/SKILL.md +3 -1
- package/templates/.agents/skills/zaip-skill-executar-fila-pronta/scripts/ready-queue-fence.mjs +2 -1
- package/templates/.agents/skills/zaip-skill-executar-fila-pronta/scripts/ready-queue-lease.mjs +3 -1
- package/templates/.agents/skills/zaip-skill-executar-fila-pronta/scripts/ready-queue-storage.mjs +40 -0
- package/templates/.agents/skills/zaip-skill-executar-fila-pronta/scripts/ready-queue-storage.test.mjs +87 -0
- package/templates/.agents/skills/zaip-skill-executar-fila-pronta/scripts/scheduled-ready-queue-contract.test.mjs +1 -1
- package/templates/.agents/skills/zaip-skill-execution/SKILL.md +11 -3
- package/templates/.agents/skills/zaip-skill-execution/references/autonomous-continuation.md +2 -0
- package/templates/.agents/skills/zaip-skill-execution/references/controlled-release-recovery.md +10 -4
- package/templates/.agents/skills/zaip-skill-execution/references/conversation-promotion.md +38 -0
- package/templates/.agents/skills/zaip-skill-execution/references/runtime-governance.md +3 -1
- package/templates/.agents/skills/zaip-skill-external-integrations/SKILL.md +2 -0
- package/templates/.agents/skills/zaip-skill-external-integrations/references/kommo.md +71 -0
- package/templates/.agents/skills/zaip-skill-figma-setup/SKILL.md +42 -0
- package/templates/.agents/skills/zaip-skill-figma-setup/agents/openai.yaml +6 -0
- package/templates/.agents/skills/zaip-skill-figma-setup/references/capability-contract.json +40 -0
- package/templates/.agents/skills/zaip-skill-figma-setup/references/figma-connection.md +60 -0
- package/templates/.agents/skills/zaip-skill-figma-setup/references/figma-handoff.md +71 -0
- package/templates/.agents/skills/zaip-skill-frontend/SKILL.md +30 -1
- package/templates/.agents/skills/zaip-skill-frontend-data-flows/SKILL.md +3 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/SKILL.md +38 -5
- package/templates/.agents/skills/zaip-skill-github-deploy/references/authentication.md +15 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/references/authorization.md +35 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/references/deployment-workflow.md +21 -3
- package/templates/.agents/skills/zaip-skill-github-deploy/references/literal-read-sequence.md +28 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/references/release-identity.md +4 -2
- package/templates/.agents/skills/zaip-skill-github-deploy/references/release-notes.md +4 -4
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/application-content.mjs +82 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/application-content.test.mjs +184 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/consumer-publication-authority.mjs +63 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/consumer-release-preparation.mjs +42 -36
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/consumer-release-preparation.test.mjs +4 -5
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/deploy-auth.mjs +400 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/deploy-auth.test.mjs +192 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/deploy-constraints.test.mjs +159 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/deploy-contract-cli.test.mjs +32 -24
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/deploy-contract-range.test-support.mjs +51 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/deploy-contract.mjs +213 -225
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/deploy-contract.test.mjs +63 -56
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/deploy-idempotent-intent.test.mjs +130 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/deploy-publication-intent.test.mjs +112 -5
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/deployment-request-conditions.test.mjs +117 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/deployment-request-continuation.test.mjs +44 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/deployment-request-preservation.test.mjs +58 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/deployment-request.mjs +291 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/git-command.mjs +11 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/git-config-paths.mjs +10 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/git-destination.mjs +21 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/git-push-target.mjs +62 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/git-push-target.test.mjs +78 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/github-deploy-contract.test.mjs +4 -2
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/guarded-commits.mjs +132 -42
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/preflight-options.mjs +50 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/preflight-worktree.test.mjs +52 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/preflight.mjs +70 -119
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/preflight.test.mjs +11 -1
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/project-restrictions.mjs +201 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/project-restrictions.test.mjs +154 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-authority-callbacks.test.mjs +46 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-conditions.mjs +193 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-intent.mjs +76 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-plan-binding.mjs +78 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-plan-refusal.mjs +30 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-project-policy.mjs +39 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-2457VC25.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-25VZXDBX.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-2JXOAZ2R.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-2OZK443Y.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-3BDTL55L.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-3MG57Y6I.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-3MQAJ6XX.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-3TUUBJPP.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-45Z34LBQ.mjs +140 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-4GJE2IXL.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-4HLOIRQU.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-55PSJJ75.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-5OTFTK2Y.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-7OFWNBZN.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-7R2IP55E.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-7SBOEN6U.mjs +24 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-A35CQWF4.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-A3ZCURGS.mjs +11 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-BC2LX3QU.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-C2Z26E6U.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-CHJGU2RU.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-D4LGE7UI.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-D5OUJS46.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-D6RZM5OT.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-DOK2R3GV.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-EAHVOUKK.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-FZUNFGZV.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-GGBPBQ6D.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-HFDX2GP6.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-HZ2NRMAG.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-IJKPDKXC.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-JEOOTEUX.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-JF3E72HZ.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-KRHOCS3C.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-LG5MJS2A.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-ML4PMB7C.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-MSCWMPU5.mjs +63 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-NJOFXS7P.mjs +137 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-NORNV3B2.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-PBU2HSKP.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-PG6LGVVW.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-PGYGDY3J.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-QFUQW6LE.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-QI32NI7M.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-R4HD7XOO.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-REHSM3G2.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-S22YDVTM.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-S5P4ZNUQ.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-SCK2RF6V.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-SWFLYM3O.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-TA7RY5MY.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-TM5WG7GR.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-TMVJHK37.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-TPDQAH7C.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-U2KO7ULM.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-U3ISMYJU.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-UKSDAS73.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-UNTPHSZO.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-V4MIRRUB.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-WNXOXX3Z.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-WQGTDRK7.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-WZJIRYT6.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-XED4KYQL.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-XEXCFKHI.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-XJJFARY4.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-XQOFL3K3.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-YAWUSDPM.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-YEUY7TMM.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-Z5X23XXT.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-Z7H2BHYQ.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-ZOGCYGYB.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/lifecycle-records.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-ar.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-az.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-be.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-bg.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-bn.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-ca.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-ckb.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-cs.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-da.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-de.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-el.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-en.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-eo.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-es.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-fa.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-fi.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-fr-CA.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-fr.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-gu.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-he.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-hi.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-hr.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-hu.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-hy.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-id.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-is.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-it.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-ja.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-ka.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-kh.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-km.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-kn.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-ko.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-lt.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-mk.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-ms.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-ne.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-nl.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-nn.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-no.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-ota.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-pl.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-ps.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-pt-BR.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-pt.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-ro.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-ru.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-sk.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-sl.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-sv.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-ta.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-tg.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-th.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-tk.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-tr.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-ua.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-uk.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-ur.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-uz.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-vi.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-yo.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-zh-CN.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/locale-zh-TW.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/manifest.json +565 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/native-authority.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/proof.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/run-records.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/yaml-runtime.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/zod-runtime.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-schema.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof.test.mjs +79 -0
- package/templates/.agents/skills/zaip-skill-github-setup/SKILL.md +14 -11
- package/templates/.agents/skills/zaip-skill-github-setup/references/bounded-setup.md +42 -0
- package/templates/.agents/skills/zaip-skill-github-setup/scripts/setup.mjs +365 -0
- package/templates/.agents/skills/zaip-skill-github-setup-ssh-folder/SKILL.md +13 -3
- package/templates/.agents/skills/zaip-skill-github-setup-ssh-folder/references/operational-procedure.md +4 -4
- package/templates/.agents/skills/zaip-skill-google-ads-conversions/SKILL.md +18 -0
- package/templates/.agents/skills/zaip-skill-google-ads-conversions/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-google-ads-conversions/references/implementation.md +61 -0
- package/templates/.agents/skills/zaip-skill-google-analytics/SKILL.md +24 -0
- package/templates/.agents/skills/zaip-skill-google-analytics/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-google-analytics/references/implementation.md +64 -0
- package/templates/.agents/skills/zaip-skill-google-tag-manager/SKILL.md +24 -0
- package/templates/.agents/skills/zaip-skill-google-tag-manager/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-google-tag-manager/references/implementation.md +71 -0
- package/templates/.agents/skills/zaip-skill-google-tag-manager/references/operator-checklist.md +51 -0
- package/templates/.agents/skills/zaip-skill-google-tag-manager/references/operator-fixtures.json +93 -0
- package/templates/.agents/skills/zaip-skill-google-tag-manager/scripts/check-runbook-links.mjs +103 -0
- package/templates/.agents/skills/zaip-skill-google-tag-manager/scripts/google-runbooks.test.mjs +247 -0
- package/templates/.agents/skills/zaip-skill-google-tag-manager/scripts/operator-model.mjs +221 -0
- package/templates/.agents/skills/zaip-skill-hostinger-cloudflare-terraform/SKILL.md +8 -2
- package/templates/.agents/skills/zaip-skill-hostinger-cloudflare-terraform/references/autonomous-cloud-inputs.example.json +3 -3
- package/templates/.agents/skills/zaip-skill-hostinger-cloudflare-terraform/references/autonomous-runner.md +4 -2
- package/templates/.agents/skills/zaip-skill-hostinger-cloudflare-terraform/references/cloudflare-agent-setup.md +23 -0
- package/templates/.agents/skills/zaip-skill-hostinger-cloudflare-terraform/references/cloudflare-dns.md +36 -0
- package/templates/.agents/skills/zaip-skill-hostinger-cloudflare-terraform/references/guia-iniciante-hostinger-vps.md +4 -4
- package/templates/.agents/skills/zaip-skill-hostinger-cloudflare-terraform/references/operational-contract.md +3 -3
- package/templates/.agents/skills/zaip-skill-hostinger-cloudflare-terraform/references/vps-onboarding.md +97 -0
- package/templates/.agents/skills/zaip-skill-image-optimization/SKILL.md +31 -0
- package/templates/.agents/skills/zaip-skill-image-optimization/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-image-optimization/references/adapters.md +36 -0
- package/templates/.agents/skills/zaip-skill-image-optimization/references/pipeline.md +35 -0
- package/templates/.agents/skills/zaip-skill-image-optimization/scripts/images.mjs +370 -0
- package/templates/.agents/skills/zaip-skill-image-optimization/scripts/images.test.mjs +385 -0
- package/templates/.agents/skills/zaip-skill-infisical/SKILL.md +20 -0
- package/templates/.agents/skills/zaip-skill-infisical/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-infisical/assets/compose.yaml +62 -0
- package/templates/.agents/skills/zaip-skill-infisical/assets/terraform/infisical.tf +57 -0
- package/templates/.agents/skills/zaip-skill-infisical/references/credential-workflow.md +88 -0
- package/templates/.agents/skills/zaip-skill-infisical/references/first-initialization.md +51 -0
- package/templates/.agents/skills/zaip-skill-infisical/references/security-and-edition.md +19 -0
- package/templates/.agents/skills/zaip-skill-infisical/references/self-hosting.md +71 -0
- package/templates/.agents/skills/zaip-skill-infisical/references/terraform.md +54 -0
- package/templates/.agents/skills/zaip-skill-infisical/scripts/prepare-self-host.mjs +92 -0
- package/templates/.agents/skills/zaip-skill-infisical/scripts/prepare-self-host.test.mjs +69 -0
- package/templates/.agents/skills/zaip-skill-infisical/scripts/preview-terraform.mjs +70 -0
- package/templates/.agents/skills/zaip-skill-infisical/scripts/preview-terraform.test.mjs +51 -0
- package/templates/.agents/skills/zaip-skill-infisical/scripts/terraform-plan-integration.test.mjs +83 -0
- package/templates/.agents/skills/zaip-skill-landing-page-forms/SKILL.md +37 -0
- package/templates/.agents/skills/zaip-skill-landing-page-forms/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-landing-page-forms/references/accessibility.md +29 -0
- package/templates/.agents/skills/zaip-skill-landing-page-forms/references/contact-then-qualification.example.json +83 -0
- package/templates/.agents/skills/zaip-skill-landing-page-forms/references/contracts.md +70 -0
- package/templates/.agents/skills/zaip-skill-landing-page-forms/references/examples.md +21 -0
- package/templates/.agents/skills/zaip-skill-landing-page-forms/references/journey.md +30 -0
- package/templates/.agents/skills/zaip-skill-landing-page-forms/references/multistep.example.json +84 -0
- package/templates/.agents/skills/zaip-skill-landing-page-forms/references/single-screen.example.json +76 -0
- package/templates/.agents/skills/zaip-skill-landing-page-forms/references/verification.md +24 -0
- package/templates/.agents/skills/zaip-skill-landing-page-forms/scripts/validate-plan.mjs +306 -0
- package/templates/.agents/skills/zaip-skill-landing-page-forms/scripts/validate-plan.test.mjs +183 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/SKILL.md +32 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/references/architecture.md +51 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/references/authority.md +49 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/references/bant-contract.md +36 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/references/consent-contract.md +48 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/references/delivery-contract.md +65 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/references/event-contract.md +47 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/references/examples/escola.json +180 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/references/examples/moradigna-regression.json +158 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/references/examples/solar.json +165 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/references/identity-contract.md +53 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/references/implementation-plan.md +60 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/references/kommo-contract.md +83 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/references/meta-mapping.md +28 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/references/migration.md +65 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/references/operations.md +125 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/references/persistence-reference.md +65 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/references/questionnaire-v2.schema.json +136 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/references/synthetic-config.json +24 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/references/synthetic-event.json +19 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/scripts/check-questionnaire.mjs +314 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/scripts/check-questionnaire.test.mjs +338 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/scripts/consent-cases-core.mjs +144 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/scripts/consent-cases-privacy.mjs +183 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/scripts/consent-fixtures.mjs +60 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/scripts/consent-rollback-support.mjs +114 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/scripts/consent.mjs +222 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/scripts/consent.test.mjs +294 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/scripts/delivery-ledger.mjs +179 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/scripts/delivery-v2-case-fixtures.mjs +118 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/scripts/delivery-v2-cases.mjs +6 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/scripts/delivery-v2-contract-cases.mjs +218 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/scripts/delivery-v2-contract.mjs +182 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/scripts/delivery-v2-proof-support.mjs +104 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/scripts/delivery-v2-proof.mjs +272 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/scripts/delivery-v2-state-cases.mjs +248 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/scripts/delivery-v2.mjs +234 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/scripts/lead-measurement.mjs +277 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/scripts/lead-measurement.test.mjs +288 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/scripts/questionnaire-ast-cases.mjs +127 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/scripts/questionnaire-test-support.mjs +25 -0
- package/templates/.agents/skills/zaip-skill-lead-measurement/scripts/questionnaire-validation.mjs +155 -0
- package/templates/.agents/skills/zaip-skill-lifecycle-closure/SKILL.md +30 -2
- package/templates/.agents/skills/zaip-skill-lifecycle-closure/references/empty-usage-lock.md +56 -0
- package/templates/.agents/skills/zaip-skill-lifecycle-closure/references/late-finalization.md +158 -0
- package/templates/.agents/skills/zaip-skill-lifecycle-closure/references/local-catalog-closure.md +37 -0
- package/templates/.agents/skills/zaip-skill-lifecycle-closure/references/post-publication-task-first.md +1 -1
- package/templates/.agents/skills/zaip-skill-lifecycle-closure/scripts/empty-lock-native.cs +113 -0
- package/templates/.agents/skills/zaip-skill-lifecycle-closure/scripts/empty-lock-native.ps1 +9 -0
- package/templates/.agents/skills/zaip-skill-lifecycle-closure/scripts/recover-empty-usage-lock.mjs +194 -0
- package/templates/.agents/skills/zaip-skill-local-credentials/SKILL.md +27 -0
- package/templates/.agents/skills/zaip-skill-maintenance-enter/SKILL.md +8 -6
- package/templates/.agents/skills/zaip-skill-maintenance-enter/scripts/maintenance.mjs +4 -4
- package/templates/.agents/skills/zaip-skill-maintenance-enter/scripts/maintenance.test.mjs +2 -2
- package/templates/.agents/skills/zaip-skill-maintenance-exit/SKILL.md +3 -3
- package/templates/.agents/skills/zaip-skill-marketing/SKILL.md +11 -0
- package/templates/.agents/skills/zaip-skill-marketing/references/search-content.md +17 -0
- package/templates/.agents/skills/zaip-skill-meta-conversions/SKILL.md +23 -0
- package/templates/.agents/skills/zaip-skill-meta-conversions/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-meta-conversions/references/implementation.md +88 -0
- package/templates/.agents/skills/zaip-skill-meta-conversions/references/synthetic-meta.json +27 -0
- package/templates/.agents/skills/zaip-skill-meta-conversions/scripts/check-meta-links.mjs +88 -0
- package/templates/.agents/skills/zaip-skill-meta-conversions/scripts/meta-model.mjs +369 -0
- package/templates/.agents/skills/zaip-skill-meta-conversions/scripts/meta-model.test.mjs +394 -0
- package/templates/.agents/skills/zaip-skill-performance-engineering/SKILL.md +26 -1
- package/templates/.agents/skills/zaip-skill-performance-engineering/references/astro-islands.md +41 -0
- package/templates/.agents/skills/zaip-skill-performance-engineering/references/controlled-runner.md +38 -0
- package/templates/.agents/skills/zaip-skill-performance-engineering/references/google-diagnostics.md +46 -0
- package/templates/.agents/skills/zaip-skill-performance-engineering/references/report-contract.md +99 -0
- package/templates/.agents/skills/zaip-skill-performance-engineering/references/site-budgets.json +25 -0
- package/templates/.agents/skills/zaip-skill-performance-engineering/references/site-performance.md +83 -0
- package/templates/.agents/skills/zaip-skill-performance-engineering/references/third-party-performance.md +57 -0
- package/templates/.agents/skills/zaip-skill-performance-engineering/scripts/assess-reports.mjs +42 -0
- package/templates/.agents/skills/zaip-skill-performance-engineering/scripts/capture-site.mjs +155 -0
- package/templates/.agents/skills/zaip-skill-performance-engineering/scripts/local-preview.mjs +84 -0
- package/templates/.agents/skills/zaip-skill-performance-engineering/scripts/performance-report.mjs +142 -0
- package/templates/.agents/skills/zaip-skill-performance-engineering/scripts/performance-report.test.mjs +122 -0
- package/templates/.agents/skills/zaip-skill-performance-engineering/scripts/report-fixtures.test-support.mjs +51 -0
- package/templates/.agents/skills/zaip-skill-performance-engineering/scripts/report-import.mjs +209 -0
- package/templates/.agents/skills/zaip-skill-performance-engineering/scripts/report-import.test.mjs +164 -0
- package/templates/.agents/skills/zaip-skill-performance-engineering/scripts/run-lighthouse.mjs +151 -0
- package/templates/.agents/skills/zaip-skill-performance-engineering/scripts/series-gate.mjs +225 -0
- package/templates/.agents/skills/zaip-skill-performance-engineering/scripts/series-gate.test.mjs +143 -0
- package/templates/.agents/skills/zaip-skill-qa/SKILL.md +54 -0
- package/templates/.agents/skills/zaip-skill-qa/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-qa/references/host-protocol.md +125 -0
- package/templates/.agents/skills/zaip-skill-qa/references/landing-page-forms.md +23 -0
- package/templates/.agents/skills/zaip-skill-qa/references/proof-adapters.md +92 -0
- package/templates/.agents/skills/zaip-skill-qa/references/scenarios.md +73 -0
- package/templates/.agents/skills/zaip-skill-qa/references/seo-geo.md +33 -0
- package/templates/.agents/skills/zaip-skill-qa/references/site-performance.md +20 -0
- package/templates/.agents/skills/zaip-skill-qa/scripts/observe-dashboard-ui.mjs +152 -0
- package/templates/.agents/skills/zaip-skill-qa/scripts/observe-dashboard-ui.test.mjs +65 -0
- package/templates/.agents/skills/zaip-skill-qa/scripts/qa-contract.test.mjs +203 -0
- package/templates/.agents/skills/zaip-skill-qa/scripts/run-behavior-tests.mjs +369 -0
- package/templates/.agents/skills/zaip-skill-qa/scripts/run-behavior-tests.test.mjs +168 -0
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/SKILL.md +33 -0
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-local-telemetry.mjs +42 -62
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-native-window.mjs +115 -0
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-native-window.test.mjs +123 -0
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-optional-timing.test.mjs +34 -0
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-reviewed-pairs-fixture.mjs +130 -0
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-deduplicate-apply.mjs +106 -0
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-lib.mjs +22 -45
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-lib.test.mjs +0 -24
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-remeasurement.mjs +73 -9
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-reviewed-order.mjs +48 -0
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-reviewed-pairs.mjs +255 -0
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-telemetry-reviewed-pairs.test.mjs +329 -0
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-token-snapshots.mjs +49 -0
- package/templates/.agents/skills/zaip-skill-reconcile-telemetry/scripts/reconcile-token-snapshots.test.mjs +33 -0
- package/templates/.agents/skills/zaip-skill-refactor-landing-page/SKILL.md +6 -0
- package/templates/.agents/skills/zaip-skill-release-qualification/SKILL.md +26 -1
- package/templates/.agents/skills/zaip-skill-release-qualification/references/frozen-task-recovery.md +47 -0
- package/templates/.agents/skills/zaip-skill-release-qualification/references/local-catalog.md +136 -0
- package/templates/.agents/skills/zaip-skill-release-qualification/references/local-preparation.md +7 -5
- package/templates/.agents/skills/zaip-skill-release-qualification/references/remote-validation.md +147 -0
- package/templates/.agents/skills/zaip-skill-sales-methodology/SKILL.md +1 -0
- package/templates/.agents/skills/zaip-skill-sales-methodology/references/bant-discovery.md +28 -0
- package/templates/.agents/skills/zaip-skill-screenshot-intake/SKILL.md +40 -0
- package/templates/.agents/skills/zaip-skill-screenshot-intake/agents/openai.yaml +6 -0
- package/templates/.agents/skills/zaip-skill-screenshot-intake/references/request-example.json +36 -0
- package/templates/.agents/skills/zaip-skill-screenshot-intake/references/runtime-workflow.md +110 -0
- package/templates/.agents/skills/zaip-skill-search-observability/SKILL.md +27 -0
- package/templates/.agents/skills/zaip-skill-search-observability/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-search-observability/references/report-template.md +32 -0
- package/templates/.agents/skills/zaip-skill-search-observability/references/workflow.md +56 -0
- package/templates/.agents/skills/zaip-skill-search-observability/scripts/search-report.mjs +139 -0
- package/templates/.agents/skills/zaip-skill-search-observability/scripts/search-report.test.mjs +72 -0
- package/templates/.agents/skills/zaip-skill-setup/SKILL.md +51 -44
- package/templates/.agents/skills/zaip-skill-setup/agents/openai.yaml +1 -1
- package/templates/.agents/skills/zaip-skill-setup/references/basic-onboarding.md +41 -0
- package/templates/.agents/skills/zaip-skill-setup/references/codex-activation.md +40 -0
- package/templates/.agents/skills/zaip-skill-setup/scripts/onboarding-contract.test.mjs +41 -0
- package/templates/.agents/skills/zaip-skill-spec/SKILL.md +1 -0
- package/templates/.agents/skills/zaip-skill-sqlite-read-model/SKILL.md +4 -3
- package/templates/.agents/skills/zaip-skill-task/SKILL.md +1 -0
- package/templates/.agents/skills/zaip-skill-task/references/commit-policy.md +1 -1
- package/templates/.agents/skills/zaip-skill-testing-strategy/SKILL.md +18 -0
- package/templates/.agents/skills/zaip-skill-testing-strategy/references/frontend-impact.md +81 -0
- package/templates/.agents/skills/zaip-skill-testing-strategy/references/verification-adoption.md +31 -0
- package/templates/.agents/skills/zaip-skill-testing-strategy/scripts/validation-plan.mjs +168 -0
- package/templates/.agents/skills/zaip-skill-testing-strategy/scripts/validation-plan.test.mjs +146 -0
- package/templates/.agents/skills/zaip-skill-tool-setup/scripts/tool-state.mjs +1 -1
- package/templates/.agents/skills/zaip-skill-use-connectors/SKILL.md +8 -0
- package/templates/.agents/skills/zaip-skill-use-connectors/scripts/select-connector.mjs +73 -0
- package/templates/.agents/skills/zaip-skill-use-connectors/scripts/select-connector.test.mjs +85 -0
- package/templates/.agents/skills/zaip-skill-visual-report/SKILL.md +41 -0
- package/templates/.agents/skills/zaip-skill-visual-report/agents/openai.yaml +6 -0
- package/templates/.agents/skills/zaip-skill-visual-report/references/fidelity-proof.md +56 -0
- package/templates/.agents/skills/zaip-skill-visual-report/references/intake-state.md +64 -0
- package/templates/.agents/skills/zaip-skill-visual-report/references/source-contract.md +79 -0
- package/templates/.agents/skills/zaip-skill-visual-report/references/synthesis-template.md +67 -0
- package/templates/.agents/skills/zaip-skill-visual-report/references/visual-contract.json +40 -0
- package/templates/.agents/skills/zaip-skill-website-readiness/SKILL.md +73 -17
- package/templates/.agents/skills/zaip-skill-website-readiness/agents/openai.yaml +2 -2
- package/templates/.agents/skills/zaip-skill-website-readiness/references/capability-checklist.md +8 -4
- package/templates/.agents/skills/zaip-skill-website-readiness/references/change-discovery.md +22 -0
- package/templates/.agents/skills/zaip-skill-website-readiness/references/content-and-agents.md +25 -0
- package/templates/.agents/skills/zaip-skill-website-readiness/references/crawler-policy.md +35 -0
- package/templates/.agents/skills/zaip-skill-website-readiness/references/schema-matrix.md +23 -0
- package/templates/.agents/skills/zaip-skill-website-readiness/references/search-evidence.md +36 -0
- package/templates/.agents/skills/zaip-skill-website-readiness/references/site-quality.example.json +14 -0
- package/templates/.agents/skills/zaip-skill-website-readiness/references/site-quality.md +109 -0
- package/templates/.agents/skills/zaip-skill-website-readiness/references/site-validation.md +60 -0
- package/templates/.agents/skills/zaip-skill-website-readiness/references/sources.md +37 -0
- package/templates/.agents/skills/zaip-skill-website-readiness/references/visual-preservation.md +84 -0
- package/templates/.agents/skills/zaip-skill-website-readiness/scripts/agent-content.mjs +116 -0
- package/templates/.agents/skills/zaip-skill-website-readiness/scripts/agent-content.test.mjs +83 -0
- package/templates/.agents/skills/zaip-skill-website-readiness/scripts/audit-site.mjs +136 -0
- package/templates/.agents/skills/zaip-skill-website-readiness/scripts/html-facts.mjs +56 -0
- package/templates/.agents/skills/zaip-skill-website-readiness/scripts/index-directives.mjs +29 -0
- package/templates/.agents/skills/zaip-skill-website-readiness/scripts/quality-plan.mjs +62 -0
- package/templates/.agents/skills/zaip-skill-website-readiness/scripts/robots-policy.mjs +63 -0
- package/templates/.agents/skills/zaip-skill-website-readiness/scripts/search-policy.test.mjs +183 -0
- package/templates/.agents/skills/zaip-skill-website-readiness/scripts/site-audit.mjs +243 -0
- package/templates/.agents/skills/zaip-skill-website-readiness/scripts/site-audit.test.mjs +287 -0
- package/templates/.agents/skills/zaip-skill-website-readiness/scripts/sitemap-policy.mjs +111 -0
- package/templates/.agents/skills/zaip-skill-website-readiness/scripts/verify-site-design.mjs +130 -0
- package/templates/.agents/skills/zaip-skill-website-readiness/scripts/visual-preservation.mjs +160 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/SKILL.md +70 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/references/complete-preservation.md +70 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/references/default-policy.md +53 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/references/lifecycle-roots.md +106 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/references/metadata-overlay.md +45 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/references/procedure.md +49 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/complete-preservation.mjs +252 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/durable-local-archive.mjs +162 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/durable-local-git.mjs +111 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/durable-state-acl.ps1 +37 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/durable-state-activate.ps1 +66 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/durable-state-alias.mjs +202 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/durable-state-batches.mjs +88 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/durable-state-copy-session.mjs +84 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/durable-state-cutover.mjs +350 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/durable-state-files.mjs +109 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/durable-state-generation-posix.mjs +194 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/durable-state-generation.mjs +173 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/durable-state-journal.mjs +88 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/durable-state-layout.mjs +102 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/durable-state-lock.mjs +106 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/durable-state-migration.mjs +234 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/durable-state-observation-tail.mjs +148 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/durable-state-permissions.mjs +52 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/durable-state-plan.mjs +143 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/durable-state-preparation.mjs +110 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/durable-state-process-start.ps1 +7 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/durable-state-quiescence.ps1 +11 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/durable-state-receipt-lease.mjs +67 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/durable-state-reuse.mjs +68 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/durable-state-telemetry-version.mjs +187 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/git-process.mjs +85 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/metadata-overlay.mjs +302 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/metadata-secrets.mjs +44 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/migrate-durable-state.mjs +49 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/recovery.mjs +247 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/retention-marker.mjs +44 -0
- package/templates/.agents/skills/zaip-skill-worktree-recovery/scripts/worktree-proof.mjs +148 -0
- package/templates/.agents/tools/api/kommo-crm/README.md +13 -9
- package/templates/.agents/tools/cloud-onboarding-architecture.mjs +273 -0
- package/templates/.agents/tools/cloud-onboarding-bootstrap.test.mjs +176 -0
- package/templates/.agents/tools/cloud-onboarding-configure.mjs +146 -0
- package/templates/.agents/tools/cloud-onboarding-credentials.mjs +279 -0
- package/templates/.agents/tools/cloud-onboarding-files.mjs +190 -0
- package/templates/.agents/tools/cloud-onboarding-files.test.mjs +72 -0
- package/templates/.agents/tools/cloud-onboarding-generation.mjs +161 -0
- package/templates/.agents/tools/cloud-onboarding-generation.test.mjs +129 -0
- package/templates/.agents/tools/cloud-onboarding-policy.mjs +196 -0
- package/templates/.agents/tools/cloud-onboarding-provider.mjs +228 -0
- package/templates/.agents/tools/cloud-onboarding-provider.test.mjs +144 -0
- package/templates/.agents/tools/cloud-onboarding-recovery.test.mjs +306 -0
- package/templates/.agents/tools/cloud-onboarding-ssh.mjs +223 -0
- package/templates/.agents/tools/cloud-onboarding-terraform.mjs +80 -0
- package/templates/.agents/tools/cloud-onboarding-test-fixture.mjs +184 -0
- package/templates/.agents/tools/cloud-onboarding-test-fixtures.mjs +117 -0
- package/templates/.agents/tools/cloud-onboarding.mjs +196 -0
- package/templates/.agents/tools/cloud-onboarding.ssh.integration.test.mjs +391 -0
- package/templates/.agents/tools/cloud-onboarding.test.mjs +237 -0
- package/templates/.agents/tools/cloud-runner-arguments.mjs +37 -0
- package/templates/.agents/tools/cloud-runner-dns.mjs +234 -11
- package/templates/.agents/tools/cloud-runner-dns.test.mjs +256 -0
- package/templates/.agents/tools/cloud-runner-process.mjs +61 -0
- package/templates/.agents/tools/cloud-runner-process.test.mjs +43 -0
- package/templates/.agents/tools/cloud-runner.integration.test.mjs +19 -3
- package/templates/.agents/tools/cloud-runner.mjs +49 -169
- package/templates/.agents/tools/cloud-runner.test.mjs +7 -42
- package/templates/.agents/tools/historical-local-archive.mjs +89 -0
- package/templates/.agents/tools/infisical-bootstrap-windows.test.mjs +12 -0
- package/templates/.agents/tools/infisical-bootstrap.mjs +240 -0
- package/templates/.agents/tools/infisical-bootstrap.test-support.mjs +39 -0
- package/templates/.agents/tools/infisical-bootstrap.test.mjs +193 -0
- package/templates/.agents/tools/infisical-policy.mjs +134 -0
- package/templates/.agents/tools/infisical-runner.mjs +349 -0
- package/templates/.agents/tools/infisical-runner.test.mjs +266 -0
- package/templates/.agents/tools/mcp/infra/cloudflare/README.md +3 -17
- package/templates/.agents/tools/mcp/infra/cloudflare/manifest.yaml +6 -10
- package/templates/.agents/tools/repository-cloud-boundary.test.mjs +41 -0
- package/templates/.agents/tools/repository-policy.mjs +257 -0
- package/templates/.agents/tools/repository-profile.mjs +116 -0
- package/templates/.agents/tools/repository-profile.test.mjs +67 -0
- package/templates/.agents/tools/secret-inventory.mjs +150 -0
- package/templates/.agents/tools/secret-inventory.test.mjs +60 -0
- package/templates/.agents/tools/visual-intake/cli.mjs +72 -0
- package/templates/.agents/tools/visual-intake/fs.mjs +137 -0
- package/templates/.agents/tools/visual-intake/lock.mjs +98 -0
- package/templates/.agents/tools/visual-intake/report.mjs +69 -0
- package/templates/.agents/tools/visual-intake/runtime.mjs +330 -0
- package/templates/.agents/tools/visual-intake/schema.mjs +235 -0
- package/templates/.agents/tools/visual-intake/transaction.mjs +206 -0
- package/templates/.agents/tools/visual-url/browser-cdp.mjs +167 -0
- package/templates/.agents/tools/visual-url/browser-page-evidence.mjs +111 -0
- package/templates/.agents/tools/visual-url/browser-proxy.mjs +194 -0
- package/templates/.agents/tools/visual-url/browser-rendered-sample.mjs +312 -0
- package/templates/.agents/tools/visual-url/browser-source.mjs +398 -0
- package/templates/.agents/tools/visual-url/capture.mjs +119 -0
- package/templates/.agents/tools/visual-url/captured-visual.mjs +301 -0
- package/templates/.agents/tools/visual-url/cli.mjs +29 -0
- package/templates/.agents/tools/visual-url/color-candidates.mjs +161 -0
- package/templates/.agents/tools/visual-url/colors.mjs +98 -0
- package/templates/.agents/tools/visual-url/contrast.mjs +40 -0
- package/templates/.agents/tools/visual-url/css-sample.mjs +109 -0
- package/templates/.agents/tools/visual-url/design-lint.mjs +83 -0
- package/templates/.agents/tools/visual-url/design-score.mjs +217 -0
- package/templates/.agents/tools/visual-url/failure.mjs +56 -0
- package/templates/.agents/tools/visual-url/files.mjs +176 -0
- package/templates/.agents/tools/visual-url/generated-tokens.mjs +369 -0
- package/templates/.agents/tools/visual-url/handoff.mjs +85 -0
- package/templates/.agents/tools/visual-url/icon.mjs +110 -0
- package/templates/.agents/tools/visual-url/local-source.mjs +63 -0
- package/templates/.agents/tools/visual-url/parser.mjs +288 -0
- package/templates/.agents/tools/visual-url/policy.mjs +201 -0
- package/templates/.agents/tools/visual-url/proposal-markdown.mjs +39 -0
- package/templates/.agents/tools/visual-url/proposal.mjs +388 -0
- package/templates/.agents/tools/visual-url/report.mjs +305 -0
- package/templates/.agents/tools/visual-url/runtime.mjs +218 -0
- package/templates/.agents/tools/visual-url/safe-visual-value.mjs +49 -0
- package/templates/.agents/tools/visual-url/transport.mjs +187 -0
- package/templates/.agents/tools/visual-url/visual-model.mjs +393 -0
- package/templates/.agents/zaip-aios/README.md +6 -0
- package/templates/.agents/zaip-aios/VERSION +1 -1
- package/templates/.agents/zaip-aios/guides/06-execucao.md +1 -1
- package/templates/.agents/zaip-aios/guides/16-lifecycle-e-reconciliacao.md +1 -1
- package/templates/.agents/zaip-aios/guides/19-assurance-e-autonomia.md +2 -2
- package/templates/.agents/zaip-aios/guides/20-instalacao-detalhada.md +60 -18
- package/templates/.agents/zaip-aios/guides/26-qualidade-e-release.md +31 -0
- package/templates/.agents/zaip-aios/guides/27-telemetria-git-native.md +2 -2
- package/templates/.agents/zaip-aios/guides/28-lifecycle-completo.md +2 -2
- package/templates/infra/terraform/README.md +2 -0
- package/templates/infra/terraform/infisical.tf +57 -0
- package/templates/infra/terraform/terraform.tfvars.example +5 -0
- package/templates/infra/terraform/variables.tf +1 -1
- package/templates/scripts/validate-cloud-hostinger-contract.mjs +4 -1
- package/templates/template-manifest.json +3856 -1127
- package/templates/.agents/architecture/hostinger-cloudflare-terraform.md +0 -90
- package/templates/.agents/dashboard/apps/frontend/dist/assets/CostCalculationGuidePage-uR-asJv_.js +0 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-Dr5Cw6py.js +0 -3
- package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-B0Jwz_rk.js +0 -68
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-CPcBwWeO.js +0 -2
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-DZhppOIk.css +0 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/Components.stories-kxWwSKin.js +0 -146
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/DashboardFilters.stories-Chm_dXV7.js +0 -9
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/DashboardFiltersSpecimen-9CaCbGIZ.js +0 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/WorkspaceStatusSpecimen-DQnSS6s9.js +0 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/formatter-L2YTDE3Q-Do9sjqiW.js +0 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/iframe-0W0Gj_Gs.css +0 -1
- package/templates/.agents/design/apps/catalog/dist/storybook/assets/react-NrUxok8K.js +0 -1
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import {createRequire as __zaipCreateRequire} from "node:module";const require=__zaipCreateRequire(import.meta.url);
|
|
2
|
+
import{C as _t,D as ni,E as ii,F as ze,H as Gt,I as ri,J as oi,K as ai,M as ge,b as Zn,f as mt,j as Qn,k as Xn,l as Yn,m as ei,n as De,r as ti}from"./chunk-7SBOEN6U.mjs";import{A as X,B as U,C as H,G as O,H as li,g as ft,h as si,k as ci,l as Me,r as Fe,w as W}from"./chunk-ZOGCYGYB.mjs";import{a as Jt,b as T,c as ct,g as Bt,h as lt,j as dt,l as Jn,m as Bn,n as Oe,o as fe,p as I,q as P,r as F,s as ut,t as Kn,u as Kt,v as Gn,w as pt,x as Ne,y as ce}from"./chunk-A3ZCURGS.mjs";import{Jd as i}from"./chunk-MSCWMPU5.mjs";import{AsyncLocalStorage as Jc}from"node:async_hooks";import{createHash as Bc}from"node:crypto";import{realpath as Kc}from"node:fs/promises";import{lstat as ko,open as So,realpath as Zt,stat as Eo}from"node:fs/promises";import{isAbsolute as Co,relative as To}from"node:path";var xo=new Set(["type","timestamp","id","session_id","cwd","source","subagent","thread_spawn","agent_path","parent_thread_id","turn_id","model","effort","reasoning_effort","service_tier","reason","info","total_token_usage","last_token_usage","payload","thread_settings","input_tokens","cached_input_tokens","cache_write_input_tokens","output_tokens","reasoning_output_tokens","total_tokens"]),gt=class{constructor(e){this.maxBytes=e;this.scalar=Buffer.allocUnsafe(Math.min(64*1024,e)),this.output=Buffer.allocUnsafe(Math.min(64*1024,e))}maxBytes;scalar;pieces=[];output;outputUsed=0;outputBytes=0;scalarBytes=0;inString=!1;escaped=!1;unicodeRemaining=0;pendingString=null;pendingElision=!1;lastKey=null;omittedKeys=new Set;error=null;emit(e){if(this.outputBytes+e.length>this.maxBytes){this.error="projection_exceeds_bound";return}this.outputBytes+=e.length;let n=0;for(;n<e.length;){let r=Math.min(this.output.length-this.outputUsed,e.length-n);e.copy(this.output,this.outputUsed,n,n+r),this.outputUsed+=r,n+=r,this.outputUsed===this.output.length&&(this.pieces.push(this.output),this.output=Buffer.allocUnsafe(Math.min(64*1024,this.maxBytes)),this.outputUsed=0)}}feed(e){if(this.error!==null)return;let n=0;for(let r=0;r<e.length;r++){let o=e[r];if(!this.inString){if(o===34){if(this.emit(e.subarray(n,r)),this.error!==null)return;this.inString=!0,this.scalarBytes=1,this.scalar[0]=o,this.pendingString=null,this.pendingElision=!1;continue}if(o!==32&&o!==9&&o!==13){if(o===58){if(this.pendingElision){this.error="essential_value_exceeds_bound";return}this.lastKey=this.pendingString}this.pendingString=null,this.pendingElision=!1}continue}if(this.scalarBytes<this.scalar.length&&(this.scalar[this.scalarBytes]=o),this.scalarBytes++,o<32){this.error="malformed_oversized_record";return}if(this.unicodeRemaining>0){if(!(o>=48&&o<=57||o>=65&&o<=70||o>=97&&o<=102)){this.error="malformed_oversized_record";return}this.unicodeRemaining--}else if(this.escaped){if(o===117)this.unicodeRemaining=4;else if(![34,92,47,98,102,110,114,116].includes(o)){this.error="malformed_oversized_record";return}this.escaped=!1}else if(o===92)this.escaped=!0;else if(o===34){if(this.inString=!1,this.scalarBytes>this.scalar.length){if(this.lastKey!==null&&xo.has(this.lastKey)){this.error="essential_value_exceeds_bound";return}this.omittedKeys.add(this.lastKey??"unknown"),this.emit(Buffer.from("null")),this.pendingElision=!0}else{let a=this.scalar.subarray(0,this.scalarBytes);this.emit(a);try{this.pendingString=JSON.parse(a.toString("utf8"))}catch{this.error="malformed_oversized_record";return}}if(this.error!==null)return;n=r+1}}this.inString||this.emit(e.subarray(n))}finish(){if((this.inString||this.escaped||this.unicodeRemaining>0)&&(this.error??="malformed_oversized_record"),this.error!==null)return null;this.pieces.push(this.output.subarray(0,this.outputUsed));let e=Buffer.concat(this.pieces,this.outputBytes).toString("utf8");try{JSON.parse(e)}catch{return this.error="malformed_oversized_record",null}return e}};var he=class extends Error{constructor(n){super(`Isolated transcript ${n.path}, line ${n.line}: ${n.code}`);this.diagnostic=n}diagnostic};async function*ht(t,e,n={}){let r=n.maxLineBytes??16777216,o=n.chunkSize??Math.min(256*1024,r);if(![o,r].every(u=>Number.isSafeInteger(u)&&u>0)||o>r)throw new RangeError("Invalid transcript read bounds");let a=t.resolve(e);await t.exists(e);let s=await ko(a),l=await Zt(a),c=To(await Zt(t.root),l);if(!s.isFile()||s.isSymbolicLink()||c===".."||c.startsWith("..\\")||c.startsWith("../")||Co(c))throw new Error("Unsafe transcript path");let d=await Eo(a,{bigint:!0}),m=await So(a,"r");try{let u=await m.stat({bigint:!0});if(!(u.dev===d.dev||process.platform==="win32"&&d.dev===0n)||u.ino!==d.ino||u.birthtimeNs!==d.birthtimeNs||await Zt(a)!==l)throw new Error("Transcript identity changed during open");let p={size:Number(u.size)};if(!Number.isSafeInteger(p.size))throw new RangeError("Transcript snapshot size is not safely addressable");let f=0,h=0,w=1,y=0,g=null,v=[],b=S=>{if(h+=S.length,h>r&&n.oversizedPolicy!=="project")throw new RangeError(`Transcript record exceeds bounded line size (${r} bytes): ${e}`);if(h>r&&g===null){g=new gt(r);for(let C of v)g.feed(C);v.length=0}g!==null?g.feed(S):S.length&&v.push(S)},E=()=>{if(g!==null){let C=g.finish(),A={path:e,line:w,byteOffset:y,bytes:h,code:g.error??"oversized_record_projected",omittedKeys:[...g.omittedKeys].sort()};if(n.onDiagnostic?.(A),C===null)throw new he(A);return g=null,w++,y+=h+1,h=0,C}let S=Buffer.concat(v,h);return v.length=0,w++,y+=h+1,h=0,(S.at(-1)===13?S.subarray(0,-1):S).toString("utf8")};for(;f<p.size;){let S=Buffer.allocUnsafe(Math.min(o,p.size-f)),C=0;for(;C<S.length;){let D=await m.read(S,C,S.length-C,f+C);if(!D.bytesRead)throw new Error("Transcript snapshot was truncated during read");C+=D.bytesRead}f+=C;let A=0;for(let D=S.indexOf(10,A);D!==-1;D=S.indexOf(10,A))b(S.subarray(A,D)),yield E(),A=D+1;b(S.subarray(A))}h>0&&(yield E())}finally{await m.close()}}import{open as wi}from"node:fs/promises";import{homedir as bi}from"node:os";import{join as xi}from"node:path";function di(t){let e=R(t?.source),n=R(e?.subagent);return R(n?.thread_spawn)}function R(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:null}function N(t){return typeof t=="string"&&t.trim().length>0?t.trim():null}function Le(t){let e=t?.payload;if(t?.type==="event_msg"&&e?.type==="user_message"){let s=N(e.message);return s===null?null:{text:s,turnId:typeof e.turn_id=="string"?e.turn_id:null}}if(t?.type!=="response_item"||e?.type!=="message"||e.role!=="user")return null;let n=R(e.internal_chat_message_metadata_passthrough);if(n!==null){let s=n.content_item_kinds;if(!Array.isArray(s)||s.length===0||!s.every(l=>l==="user.text"))return null}let r=e.content;if(!Array.isArray(r)){let s=N(r);return s===null?null:{text:s,turnId:typeof n?.turn_id=="string"?n.turn_id:null}}let o=r.flatMap(s=>{let l=R(s);return l!==null&&(l.type==="input_text"||l.type==="text")&&typeof l.text=="string"?[l.text]:[]}).join(`
|
|
3
|
+
`),a=N(o);return a===null?null:{text:a,turnId:typeof n?.turn_id=="string"?n.turn_id:null}}function le(t){if(t.length===0)return null;try{let e=JSON.parse(t);if(typeof e!="object"||e===null)return null;let n=e;return{type:n.type,timestamp:n.timestamp,payload:typeof n.payload=="object"&&n.payload!==null?n.payload:null}}catch{return null}}var Y=t=>typeof t=="string"&&t.length<=256?t:null,ye=class{messages=[];bytes=0;push(e,n){if(this.bytes+=Buffer.byteLength(e.text),this.messages.length>=256||this.bytes>2*1024*1024)throw new Error("Native human-message evidence exceeds the bounded active-turn limit");let r=R(n?.payload),o=R(r?.internal_chat_message_metadata_passthrough);if(o===null&&typeof r?.internal_chat_message_metadata_passthrough=="string"&&Buffer.byteLength(r.internal_chat_message_metadata_passthrough)<=65536)try{o=R(JSON.parse(r.internal_chat_message_metadata_passthrough))}catch{}let a=o?.content_item_kinds,s=o?.content_item_metadata,l=r?.content;this.messages.push({...e,provenance:{source_record_type:Y(n?.type),source_payload_type:Y(r?.type),role:Y(r?.role),author_kind:Y(r?.author_kind),content_item_kinds:Array.isArray(a)&&a.length<=64&&a.every(c=>Y(c)!==null)?[...a]:null,metadata_turn_id:Y(o?.turn_id),content_item_provenance:Array.isArray(s)&&s.length<=64?s.map(c=>Y(R(R(c)?.provenance)?.type)):null,content_types:Array.isArray(l)&&l.length<=64?l.map(c=>Y(R(c)?.type)):null}})}select(e){return this.messages.filter(n=>n.turnId===null||n.turnId===e).reverse()}ordered(){return[...this.messages].reverse()}};import{isAbsolute as Ro,join as Ao,relative as Io,resolve as ui,sep as Po}from"node:path";function pi(t,e=new Date){let n=[];for(let r of[0,1,2]){let o=new Date(e);o.setDate(e.getDate()-r),n.push(Ao(t,"sessions",String(o.getFullYear()),String(o.getMonth()+1).padStart(2,"0"),String(o.getDate()).padStart(2,"0")))}return n}async function mi(t,e){let n=[];for(let r=0;r<t.length;r+=8){let o=await Promise.allSettled(t.slice(r,r+8).map(e)),a=o.find(s=>s.status==="rejected");if(a?.status==="rejected")throw a.reason;for(let s of o)s.status==="fulfilled"&&n.push(s.value)}return n}async function _i(t,e,n,r){if(r||!n.size||[...n].every(s=>e.some(l=>l.includes(s))))return e;let a=(await t.listFiles("sessions",".jsonl")).filter(s=>/^sessions\/\d{4}\/\d{2}\/\d{2}\/[A-Za-z0-9._-]+\.jsonl$/u.test(s)&&[...n].some(l=>s.includes(l)));if(a.length>128)throw new Error("Exact Codex thread has too many transcript candidates");return[...new Set([...e,...a])].sort()}function ve(t,e){if(!e?.trim()||e.length>4096||!Ro(e))return null;let n=Io(ui(t),ui(e)).replace(/\\/g,"/");return n===""||n===".."||n.startsWith(`..${Po}`)||n.startsWith("../")||!/^sessions\/\d{4}\/\d{2}\/\d{2}\/[A-Za-z0-9._-]+\.jsonl$/u.test(n)?null:n}import{execFile as qo}from"node:child_process";import{promisify as $o}from"node:util";var Vo=$o(qo);function yt(t){let e=t.replace(/\\/g,"/");return process.platform==="win32"?e.toLowerCase():e}async function fi(t,e){let n=new Set([yt(t)]);if(e.size!==1)return n;try{let{stdout:r}=await Vo("git",["worktree","list","--porcelain","-z"],{cwd:t,encoding:"utf8",maxBuffer:262144,timeout:5e3,windowsHide:!0});for(let o of r.split("\0"))o.startsWith("worktree ")&&n.add(yt(o.slice(9)))}catch{}return n}async function*we(t,e,n=256*1024){if(!Number.isSafeInteger(e)||e<0||!Number.isSafeInteger(n)||n<1)throw new RangeError("Invalid JSONL snapshot size or chunk size");let r=e,o=[];for(;r>0;){let a=Math.max(0,r-n),s=Buffer.allocUnsafe(r-a),l=0;for(;l<s.length;){let{bytesRead:d}=await t.read(s,l,s.length-l,a+l);if(d===0)throw new Error("JSONL snapshot was truncated during read");l+=d}let c=s.length;for(let d=s.lastIndexOf(10,c-1);d>=0;d=c===0?-1:s.lastIndexOf(10,c-1)){let m=s.subarray(d+1,c),u=o.length===0?m:Buffer.concat([m,...o.reverse()]);o.length=0,yield gi(u),c=d}c>0&&o.push(s.subarray(0,c)),r=a}o.length>0?yield gi(Buffer.concat(o.reverse())):e>0&&(yield"")}function gi(t){return(t.at(-1)===13?t.subarray(0,-1):t).toString("utf8")}async function hi(t,e,n,r){try{for await(let o of ht(t,e,{oversizedPolicy:"project",onDiagnostic:a=>{a.code!=="oversized_record_projected"&&(r?r(a):process.emitWarning(`Isolated transcript ${a.path}, line ${a.line}: ${a.code}`,{code:"ZAIP_TRANSCRIPT_RECORD_ISOLATED"}))}})){let a=n(o);return a?.type==="session_meta"?a:null}}catch(o){if(!(o instanceof he))throw o}return null}var yi=new Map;function Qt(t){return yt(t)}async function Oo(t,e){let n=new I(t),r=(await Promise.all(pi(t,e??new Date).map(async o=>{let a=o.replace(`${n.root}\\`,"").replace(`${n.root}/`,"");try{return await n.listFiles(a,".jsonl")}catch{return[]}}))).flat().sort();return{filesystem:n,files:r}}async function ki(t,e={}){let n=e.sessionsRoot??xi(bi(),".codex"),r=new I(n),o=vi(e.transcriptPath)?[]:(await Oo(n,e.now)).files,a=vi(e.transcriptPath),s=ve(n,e.transcriptPath);if(e.sessionPaths!==void 0&&a)throw new Error("Codex transcript path cannot be combined with sessionPaths");let l=a?s===null?[]:[s]:e.sessionPaths??[];for(let h of l)if(!/^sessions\/\d{4}\/\d{2}\/\d{2}\/[A-Za-z0-9._-]+\.jsonl$/u.test(h))throw new Error(`Invalid explicit Codex session path: ${h}`);let c=a||l.length>0?[...new Set(l)].sort():o,d=new Set([e.threadId,...e.threadIds??[],...(e.invocations??[]).map(h=>h.threadId)].filter(h=>typeof h=="string"&&h.trim().length>0));c=[...await _i(r,c,d,a||l.length>0)];let m=await fi(t,d),u=N(e.agentPath),_=N(e.parentThreadId),p=a||d.size===0||u!==null||_!==null?c:c.filter(h=>[...d].some(w=>h.includes(w)));if(p.length===0)return{filesystem:r,files:[],acceptedWorkspaces:m};let f=await mi(p,async h=>{let w=await Ei(r,h,e.onTranscriptDiagnostic);return w!==null&&m.has(Qt(w.cwd))&&(u!==null?w.agentPath===u&&(_===null||w.parentThreadId===_):_!==null?w.parentThreadId===_:d.size===0||w.sessionId!==null&&d.has(w.sessionId))?h:null});return{filesystem:r,files:f.filter(h=>h!==null),acceptedWorkspaces:m}}function vi(t){return typeof t=="string"&&t.trim().length>0}async function Si(t,e={}){let n=e.sessionsRoot??xi(bi(),".codex"),{filesystem:r,files:o,acceptedWorkspaces:a}=await ki(t,{...e,sessionsRoot:n}),s=new Set([e.threadId,...e.threadIds??[],...(e.invocations??[]).map(d=>d.threadId)].filter(d=>typeof d=="string"&&d.length>0)),l=o,c=[];for(let d of l){let m=await No(r,d,a,s,e);m!==null&&c.push(m)}return c.sort((d,m)=>(m.startedAt??"").localeCompare(d.startedAt??""))}async function ee(t,e={}){return(await Si(t,e))[0]??null}async function No(t,e,n,r,o={}){let a=await Ei(t,e);if(a===null||a.sessionId===null||!n.has(Qt(a.cwd))||r.size>0&&!r.has(a.sessionId))return null;let s=await wi(t.resolve(e),"r");try{let l=await s.stat(),c=null,d=null,m=null,u=null,_=null,p=null,f=null,h=null,w=new ye;for await(let g of we(s,l.size)){let v=le(g),b=v?.payload??null;u===null&&typeof v?.timestamp=="string"&&(u=v.timestamp),_===null&&v?.type==="turn_context"&&(typeof b?.model=="string"&&(c=b.model),typeof b?.effort=="string"&&(d=b.effort),typeof b?.service_tier=="string"&&(m=b.service_tier));let E=R(b?.thread_settings);_===null&&(v?.type==="thread_settings_applied"||b?.type==="thread_settings_applied")&&(typeof E?.model=="string"&&(c=E.model),typeof E?.reasoning_effort=="string"&&(d=E.reasoning_effort),typeof E?.service_tier=="string"&&(m=E.service_tier));let S=Le(v);if(S!==null&&(o.includeHumanMessages&&w.push(S,v),_===null&&(h=S),_!==null&&f===null&&(S.turnId===null||S.turnId===_)&&(f=S.text)),b?.type==="task_complete"){if(_===null)return null;break}if(b?.type==="task_started"&&typeof b.turn_id=="string"){if(_!==null&&b.turn_id!==_)break;_=b.turn_id,p=typeof v?.timestamp=="string"?v.timestamp:p}}if(_===null)return null;let y=o.includeHumanMessages?w.select(_):[];return{sessionId:a.sessionId,...o.includeWorkspaceRoot?{workspaceRoot:a.cwd}:{},...o.includeHumanMessages?{humanMessages:y.map(g=>g.text),humanMessageProvenance:y.map(g=>g.provenance)}:{},turnId:_,sessionPath:e,startedAt:p,userMessage:f??(h?.turnId===null||h?.turnId===_?h?.text??null:null),model:c,reasoningEffort:d,serviceTier:m,observedAt:u}}finally{await s.close()}}async function Ei(t,e,n){if(!await t.exists(e))return null;let r=t.resolve(e),o=yi.get(r);if(o!==void 0)return o;let a=await wi(r,"r");try{let s=await a.stat(),l=Buffer.allocUnsafe(Math.min(s.size,64*1024));await a.read(l,0,l.length,0);let c=l.toString("utf8").split(/\r?\n/).map(le).find(p=>p?.type==="session_meta");!c&&s.size>l.length&&(c=await hi(t,e,le,n)??void 0);let d=c?.payload??null,m=di(d),u=m!==null&&typeof d?.id=="string"?d.id:typeof d?.session_id=="string"?d.session_id:typeof d?.id=="string"?d.id:null,_=typeof d?.cwd!="string"?null:{sessionId:u,cwd:d.cwd,agentPath:N(d.agent_path)??N(m?.agent_path),parentThreadId:N(d.parent_thread_id)??N(m?.parent_thread_id),agentRole:N(d.agent_role)??N(m?.agent_role),agentNickname:N(d.agent_nickname)??N(m?.agent_nickname)};return yi.set(r,_),_}finally{await a.close()}}import{lstat as jo,open as Ii,realpath as Wo}from"node:fs/promises";import{homedir as Uo}from"node:os";import{join as Ho,resolve as Ri}from"node:path";import{lstat as Do,open as zo,realpath as Mo}from"node:fs/promises";import{resolve as Fo}from"node:path";async function je(t,e,n){let r=t.resolve(e);if(ve(t.root,r)!==e)return null;let o=await Do(r);if(!o.isFile()||o.isSymbolicLink()||(await Mo(r)).toLowerCase()!==Fo(r).toLowerCase())return null;let a=await zo(r,"r");try{let s=null;for await(let l of we(a,(await a.stat()).size)){let c=null;try{c=JSON.parse(l)}catch{continue}let d=c?.payload;if(d){if(d.type==="task_started"){if(d.turn_id===n)return s;s=null}else if(d.type==="task_complete"||d.type==="turn_aborted")s=null;else if(s===null&&(d.turn_id===void 0||d.turn_id===n)){let m=c?.type==="turn_context"?{model:d.model,effort:d.effort}:c?.type==="thread_settings_applied"||d.type==="thread_settings_applied"?{model:d.thread_settings?.model,effort:d.thread_settings?.reasoning_effort}:null;m&&(s={model:typeof m.model=="string"&&m.model.trim()?m.model:null,reasoningEffort:typeof m.effort=="string"?m.effort:null})}}}return null}finally{await a.close()}}var vt="request_user_input_async",Ci="Login conclu\xEDdo",Xt=`<send_user_message_question_reply>
|
|
4
|
+
`,Ti=`
|
|
5
|
+
</send_user_message_question_reply>`;function Lo(t){if(t==="Voc\xEA concluiu o login no npm?")return!0;if(typeof t!="string")return!1;let e=/^O npm confirmou a conta (`[a-z0-9][a-z0-9._-]{0,213}`)/.exec(t)?.[1];return e!==void 0&&t===[`O npm confirmou a conta ${e} com a credencial da \`.env\`.`,"A verifica\xE7\xE3o de tags do publicador assinado usa a sess\xE3o do npm no Windows, que respondeu `401`.","O hook do ZAIP bloqueou minha tentativa de iniciar `npm login`.",`Para publicar este mesmo pacote j\xE1 assinado, execute \`npm login --registry=https://registry.npmjs.org/\` no PowerShell com a conta ${e}.`,"N\xE3o envie o token. Voc\xEA consegue concluir esse login?"].join(" ")}function wt(t){if(typeof t!="string"||t.length>16384)return null;try{return JSON.parse(t)}catch{return null}}var bt=class{candidates=new Map;observeReverse(e,n){if(e?.type!=="response_item")return;let r=e.payload;if(r?.type==="message"&&r.role==="user"&&n?.startsWith(Xt)){let s=wt(n.slice(Xt.length,-Ti.length)),l=Array.isArray(s)&&s.length===1?R(s[0]):null,c=wt(l?.questionItemId);if(!Array.isArray(c)||c[0]!==vt||typeof c[1]!="string"||!/^call_[a-zA-Z0-9_-]{1,128}$/.test(c[1])||c[2]!==0||c.length!==3)return;this.candidates.set(c[1],{text:n,stage:this.candidates.has(c[1])?"invalid":"output"});return}let o=r?.call_id;if(typeof o!="string")return;let a=this.candidates.get(o);if(a){if(r?.type==="function_call_output"){let s=R(wt(r.output));a.stage=a.stage==="output"&&s?.accepted===!0&&Object.keys(s).length===1?"call":"invalid"}else if(r?.type==="function_call"){let s=R(wt(r.arguments)),l=Array.isArray(s?.questions)&&s.questions.length===1?R(s.questions[0]):null,c=Xt+JSON.stringify([{questionItemId:JSON.stringify([vt,o,0]),question:l?.title,answer:Ci}])+Ti;a.stage=a.stage==="call"&&(r.name===vt||r.name===`functions.${vt}`)&&(r.namespace===void 0||r.namespace==="functions")&&s!==null&&Object.keys(s).length===1&&l!==null&&Object.keys(l).length===2&&Lo(l.title)&&Array.isArray(l.options)&&l.options.length===2&&l.options[0]===Ci&&l.options[1]==="Prefiro a corre\xE7\xE3o no c\xF3digo"&&a.text===c?"matched":"invalid"}}}matchedTexts(){return new Set([...this.candidates.values()].filter(e=>e.stage==="matched").map(e=>e.text))}};function Yt(t,e){return t.isFile()&&e.isFile()&&!t.isSymbolicLink()&&!e.isSymbolicLink()&&t.dev===e.dev&&t.ino===e.ino&&t.size===e.size&&t.mtimeNs===e.mtimeNs&&t.ctimeNs===e.ctimeNs}async function Pi(t){let e=await jo(t,{bigint:!0}),n=r=>process.platform==="win32"?Ri(r).toLowerCase():Ri(r);return e.isFile()&&!e.isSymbolicLink()&&n(await Wo(t))===n(t)?e:null}async function Ai(t,e,n){let r=await Ii(t,"r");try{let o=await r.stat({bigint:!0}),a=await Pi(t);return e.ino===n.ino&&Yt(e,o)&&a!==null&&Yt(n,a)}finally{await r.close()}}async function en(t,e){if(![e.threadId,e.sourceTurnId,e.currentTurnId,e.transcriptPath].every(d=>typeof d=="string"&&d.trim()))return null;let n=e.sessionsRoot??Ho(Uo(),".codex"),r=ve(n,e.transcriptPath);if(!r)return null;let o=await ee(t,{sessionsRoot:n,threadId:e.threadId,transcriptPath:e.transcriptPath});if(!o||o.sessionId!==e.threadId||o.turnId!==e.currentTurnId||o.sessionPath!==r)return null;let a=new I(n),s=a.resolve(r),l=await Pi(s);if(!l)return null;let c=await Ii(s,"r");try{let d=await c.stat({bigint:!0}),m=new ye,u=new bt;if(!Number.isSafeInteger(Number(d.size))||!await Ai(s,d,l))return null;let _=new Set,p=!1,f=0,h=e.currentTurnId;for await(let E of we(c,Number(d.size))){if(f+=Buffer.byteLength(E),f>64*1024*1024||_.size>128)throw new Error("Codex human-turn range exceeds bounded scan limit");let S=le(E),C=S?.payload;typeof C?.turn_id=="string"&&(S?.type==="turn_context"||["task_started","task_complete","turn_aborted"].includes(String(C.type)))&&(h=C.turn_id,_.add(h));let A=Le(S);if(u.observeReverse(S,A?.text),A&&m.push({text:A.text,turnId:A.turnId??h},S),C?.type==="task_started"&&C.turn_id===e.sourceTurnId){p=!0;break}}if(!p)return null;let w=await je(a,r,e.sourceTurnId);if(!w)return null;let y=await ee(t,{sessionsRoot:n,threadId:e.threadId,transcriptPath:e.transcriptPath});if(!y||y.sessionId!==o.sessionId||y.turnId!==o.turnId||y.model!==o.model||y.reasoningEffort!==o.reasoningEffort)return null;let g=await c.stat({bigint:!0});if(!Yt(d,g)||!await Ai(s,d,l))throw new Error("Codex human-turn evidence changed during the exact range read");let v=m.ordered();if(v.some(E=>E.turnId===null))return null;let b=u.matchedTexts();return{messages:v.map(E=>({...E,turnId:E.turnId,...b.has(E.text)&&E.provenance.source_record_type==="response_item"?{nativeLoginReply:!0}:{}})),source:w,current:{model:o.model,reasoningEffort:o.reasoningEffort}}}finally{await c.close()}}var be=i.number().finite().nonnegative().nullable(),Ko=i.object({task_id:i.string().min(1),completed:i.boolean(),completed_at:i.string().min(1).nullable(),attempt:i.number().int().nonnegative().nullable(),attempt_id:i.string().min(1).nullable().optional(),equivalence_key:i.string().min(1).nullable().optional(),equivalence_evidence_id:i.string().min(1).nullable().optional(),baseline_equivalence_evidence_id:i.string().min(1).nullable().optional(),model:i.string().min(1).nullable(),reasoning_effort:i.enum(["low","medium","high","xhigh"]).nullable(),baseline_task_id:i.string().min(1).nullable(),baseline_attempt_id:i.string().min(1).nullable().optional(),baseline_equivalence_id:i.string().min(1).nullable(),observed_cost_usd:be,baseline_observed_cost_usd:be,quality_score:be,quality_floor:be,rework_count:i.number().int().nonnegative().nullable(),context_budget_tokens:i.number().int().nonnegative().nullable().optional(),cached_context_tokens:i.number().int().nonnegative().nullable().optional(),baseline_context_budget_tokens:i.number().int().nonnegative().nullable().optional(),baseline_cached_context_tokens:i.number().int().nonnegative().nullable().optional(),billed_amount:be.optional(),billed_currency:i.string().min(1).nullable().optional(),billed_provenance:i.enum(["observed","inferred","unavailable"]).nullable().optional(),billed_source_id:i.string().min(1).nullable().optional(),billed_at:i.string().min(1).nullable().optional(),baseline_billed_amount:be.optional(),baseline_billed_currency:i.string().min(1).nullable().optional(),baseline_billed_provenance:i.enum(["observed","inferred","unavailable"]).nullable().optional(),baseline_billed_source_id:i.string().min(1).nullable().optional(),baseline_billed_at:i.string().min(1).nullable().optional()}).strict(),ud=i.object({timezone:i.string().min(1),interval:i.object({start:i.string().min(1),end:i.string().min(1)}).strict(),equivalence_key:i.string().min(1).nullable().optional(),tasks:i.array(Ko)}).strict();var te=i.string().datetime({offset:!0}).or(i.string().datetime()),Zo=i.object({id:i.string().min(1),provider:i.enum(["openai","anthropic"]),aliases:i.array(i.string().min(1)).default([]),input_per_million_usd:i.number().nonnegative(),cached_input_per_million_usd:i.number().nonnegative().nullable().default(null),cache_write_input_per_million_usd:i.number().nonnegative().nullable().optional(),output_per_million_usd:i.number().nonnegative(),reasoning_per_million_usd:i.number().nonnegative().nullable().default(null),priority_input_per_million_usd:i.number().nonnegative().nullable().optional(),priority_cached_input_per_million_usd:i.number().nonnegative().nullable().optional(),priority_cache_write_input_per_million_usd:i.number().nonnegative().nullable().optional(),priority_output_per_million_usd:i.number().nonnegative().nullable().optional(),priority_reasoning_per_million_usd:i.number().nonnegative().nullable().optional(),reasoning_billed_separately:i.boolean().default(!1),long_context_threshold_tokens:i.number().int().positive().nullable().default(null),long_context_input_multiplier:i.number().positive().default(1),long_context_output_multiplier:i.number().positive().default(1),priority_long_context_supported:i.boolean().default(!1),source_label:i.string().min(1),source_url:i.string().url(),notes:i.array(i.string()).default([])}).strict(),Ld=i.object({schema_version:i.literal(1),updated_at:te,source:i.string().min(1),disclaimer:i.string().min(1),models:i.array(Zo)}).strict(),jd=i.object({schema_version:i.literal(1),base:i.literal("USD"),quote:i.literal("BRL"),rate:i.number().positive(),as_of:te,source_label:i.string().min(1),source_url:i.string().url()}).strict(),qi=i.object({input:i.number().int().nonnegative().nullable(),cached_input:i.number().int().nonnegative().nullable().default(null),cache_write_input:i.number().int().nonnegative().nullable().optional(),output:i.number().int().nonnegative().nullable(),reasoning:i.number().int().nonnegative().nullable(),total:i.number().int().nonnegative().nullable().default(null),source:i.preprocess(t=>t==="client"?"provider_reported":t,i.enum(["provider_reported","estimated","unavailable"]))}).strict(),$i=i.object({estimated_usd:i.number().nonnegative().nullable(),estimated_brl:i.number().nonnegative().nullable(),fx_rate:i.number().positive().nullable(),pricing_model:i.string().nullable(),pricing_source:i.string().nullable(),pricing_source_url:i.string().url().nullable().optional(),pricing_catalog_updated_at:te.nullable().optional(),input_usd:i.number().nonnegative().nullable().default(null),cached_input_usd:i.number().nonnegative().nullable().default(null),cache_write_input_usd:i.number().nonnegative().nullable().optional(),output_usd:i.number().nonnegative().nullable().default(null),reasoning_usd:i.number().nonnegative().nullable().default(null)}).strict(),Qo=i.object({cycle_count:i.number().int().nonnegative().nullable(),source:i.enum(["repository","local-codex","manual","unavailable"]),segment_key:i.string().nullable()}).strict(),Jo=i.object({schema_version:i.literal(1),recorded_at:te,run_id:i.string().startsWith("RUN-"),task_id:i.string().startsWith("TASK-"),spec_id:i.string().nullable(),change_id:i.string().nullable(),task_title:i.string().nullable(),task_status:i.string().nullable(),client:i.string().min(1),agent:i.string().min(1),provider:i.enum(["openai","anthropic"]).nullable(),model:i.string().min(1),status:i.enum(["running","completed","failed"]),started_at:te,finished_at:te.nullable(),duration_ms:i.number().int().nonnegative().nullable(),token_usage:qi,estimated_cost:$i,telemetry:Qo,source_segment_key:i.string().nullable()}).strict(),Bo=i.object({schema_version:i.literal(1),recorded_at:te,run_id:i.string().startsWith("RUN-"),task_id:i.string().startsWith("TASK-"),cycle_index:i.number().int().nonnegative(),provider:i.enum(["openai","anthropic"]).nullable(),model:i.string().min(1),timestamp:te,source:i.enum(["local-codex","manual"]),source_segment_key:i.string().nullable(),token_usage:qi,estimated_cost:$i}).strict();import{execFile as sa}from"node:child_process";import{constants as ca}from"node:fs";import{access as la,lstat as da,realpath as ji,stat as ua}from"node:fs/promises";import{dirname as pa,isAbsolute as on,relative as ma,resolve as an}from"node:path";import{promisify as _a}from"node:util";import{execFile as Xo}from"node:child_process";import{randomUUID as Yo}from"node:crypto";import{lstat as tn,mkdtemp as ea,readdir as ta,readFile as Vi,realpath as Oi,rm as Ni,unlink as nn,writeFile as na}from"node:fs/promises";import{tmpdir as ia}from"node:os";import{basename as Di,dirname as ra,join as zi,resolve as de}from"node:path";import{promisify as oa}from"node:util";var aa=oa(Xo),rn=new WeakMap;async function Mi(t,e,n){if(!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(e))throw new Error("candidate validation requires a full commit SHA");let r=performance.now(),o=de(t),a=await Oi(ia()),s=await ea(zi(a,`zaip-candidate-${Di(o)}-`)),l=`${s}.owner`,c=Yo(),d=async(v=!1)=>{if(ra(de(s))!==a||!Di(s).startsWith("zaip-candidate-"))throw new Error("Candidate checkout path escaped its owner");let b=await tn(s).catch(E=>{if(E.code==="ENOENT")return null;throw E});if(v&&b===null)throw new Error("Owned candidate directory disappeared");if(b!==null&&(!b.isDirectory()||b.isSymbolicLink()||await Oi(s)!==s))throw new Error("Candidate checkout is no longer an owned directory")};try{await d(!0),await na(l,c,{flag:"wx",mode:384})}catch(v){try{await d(!0);let b=await Vi(l,"utf8").catch(E=>{if(E.code==="ENOENT")return null;throw E});if(b!==null&&b!==c)throw new Error("Candidate ownership marker changed during setup");await Ni(s,{recursive:!0,force:!0}),b!==null&&await nn(l)}catch(b){throw new AggregateError([v,b],"Candidate setup and cleanup failed")}throw v}let m=async()=>{if(await Vi(l,"utf8")!==c)throw new Error("Candidate checkout ownership marker changed")},u=async()=>{await m(),await d()},_=Object.freeze({path:s,repository:o,commit:e}),p=!1,f,h=0,w=0,y,g;try{await We(o,["worktree","add","--detach",s,e]),p=!0,rn.set(_,{running:!1}),h=Math.round(performance.now()-r),f=await n(_)}catch(v){y=v}finally{let v=performance.now();rn.delete(_);try{await u(),await tn(s).catch(()=>null)&&await Fi(s);let b=!1,S=(p?null:await We(o,["worktree","list","--porcelain"]))?.stdout.split(/\r?\n/).some(C=>C.startsWith("worktree ")&&de(C.slice(9))===de(s))??!1;if(p||S)try{await We(o,["worktree","remove","--force","--force",s])}catch{b=!0}await u(),await tn(s).catch(()=>null)&&await Ni(s,{recursive:!0,force:!0,maxRetries:3,retryDelay:100}),b&&(await We(o,["worktree","list","--porcelain"])).stdout.split(/\r?\n/).some(D=>D.startsWith("worktree ")&&de(D.slice(9))===de(s))&&await We(o,["worktree","remove","--force","--force",s]),await m(),await nn(l),w=Math.round(performance.now()-v)}catch(b){g=b}}if(g!==void 0){let v=b=>b instanceof Error?b.message:String(b);throw new AggregateError(y===void 0?[g]:[y,g],`${y===void 0?"Candidate operation finished":v(y)}; cleanup incomplete at ${s}: ${v(g)}`)}if(y!==void 0)throw y;return{value:f,preparation_ms:h,cleanup_ms:w}}async function Fi(t){for(let e of await ta(t,{withFileTypes:!0})){let n=zi(t,e.name);e.isSymbolicLink()?await nn(n):e.isDirectory()&&await Fi(n)}}function Li(t,e,n){let r=rn.get(t);if(!r||r.running||t.repository!==de(e)||t.commit!==n)throw new Error("candidate workspace must be owned, sequential and bound to the same repository and SHA");return r.running=!0,()=>{r.running=!1}}function We(t,e){return aa("git",e,{cwd:t,shell:!1,windowsHide:!0,encoding:"utf8",timeout:3e5,env:Object.fromEntries(Object.entries(process.env).filter(([n])=>!/^(GIT_|NODE_OPTIONS$)/i.test(n)))})}var Ui=_a(sa);async function sn(t,e){if(e===void 0){let r=await Mi(t.repository_path,t.commit_sha,o=>sn(t,o));return{...r.value,timings_ms:{...r.value.timings_ms,preparation:r.preparation_ms,cleanup:r.cleanup_ms}}}let n=Li(e,t.repository_path,t.commit_sha);try{return await fa(t,e.path)}finally{n()}}async function fa(t,e){let n=performance.now();if(!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(t.commit_sha))throw new Error("candidate validation requires a full commit SHA");if(!on(t.executable_path))throw new Error("candidate validation requires an absolute executable path");if(!Array.isArray(t.args)||t.args.some(f=>typeof f!="string"))throw new Error("candidate validation requires a JSON string array of arguments");let r=an(t.executable_path),o=await ua(r).catch(()=>null);if(o===null||!o.isFile())throw new Error("candidate validation executable path is not a file");await la(r,ca.X_OK).catch(()=>{throw new Error("candidate validation executable path is not executable")});let a=an(t.repository_path),s=ma(a,r);if(s===""||!s.startsWith("..")&&!on(s))throw new Error("candidate validation requires an external toolchain executable, not a shared-checkout executable");let l=[a.toLowerCase(),a.replaceAll("\\","/").toLowerCase()];if(t.args.some(f=>l.some(h=>f.toLowerCase().includes(h))))throw new Error("candidate validation arguments must use candidate-relative paths, not shared-checkout paths");if(await ji(r)!==await ji(process.execPath))throw new Error("candidate validation requires the current host Node runtime");let c=t.args[0];if(!c||c.startsWith("-")||on(c)||c.includes("\\")||c.includes(":")||c.includes("\0")||c.split("/").some(f=>["",".",".."].includes(f))||!/\.(?:c|m)?js$/.test(c))throw new Error("candidate validation requires a committed relative Node harness; eval, loaders and inline code are not allowed");let d=await ne(a,["rev-parse",`${t.commit_sha}^{commit}`]),u=(await ne(a,["--literal-pathspecs","ls-tree",d,"--",c])).match(/^100(?:644|755) blob ([a-f0-9]{40,64})\t/);if(!u?.[1])throw new Error("candidate harness must be a committed regular file");let _=await ne(a,["rev-parse",`${d}^{tree}`]),p=t.timeout_ms??12e4;if(!Number.isInteger(p)||p<1||p>36e5)throw new Error("candidate validation timeout must be between 1 and 3600000 milliseconds");{let f=await ne(e,["rev-parse","HEAD"]),h=await ne(e,["rev-parse","HEAD^{tree}"]);if(f!==d||h!==_)throw new Error("isolated worktree does not match requested candidate commit and tree");await ga(e,"before execution");let w=an(e,c);for(;w!==e;){if((await da(w)).isSymbolicLink())throw new Error("candidate harness cannot follow a symlink");w=pa(w)}let y=new Date().toISOString(),g=performance.now()-n,v=performance.now(),b=await ha(r,t.args,e,p),E=Math.round(performance.now()-v),S=new Date().toISOString(),C=performance.now(),A=await Hi(e),D=await ne(e,["rev-parse","HEAD"]),wo=await ne(e,["rev-parse","HEAD^{tree}"]),Hn=D!==d||wo!==_,bo=Hn?"candidate HEAD or tree changed during execution":A?b.diagnostic:"candidate has uncommitted changes after execution";return{status:b.exitCode===0&&A&&!Hn?"passed":"failed",command:JSON.stringify([r,...t.args]),output:{stdout:Wi(b.stdout),stderr:Wi(b.stderr)},timings_ms:{process:E,verification:Math.round(g+performance.now()-C)},candidate_execution:{kind:"isolated_git_worktree",protocol:"committed_node_harness_v1",harness_path:c,harness_blob_sha:u[1],commit_sha:d,tree_sha:_,exit_code:b.exitCode,diagnostic:bo,started_at:y,finished_at:S}}}}function Wi(t){let e=Gn(t);try{return pt(e),e}catch{return"[REDACTED: command output contained sensitive values]"}}async function ga(t,e){if(!await Hi(t))throw new Error(`isolated worktree is dirty ${e}`)}async function Hi(t){return await ne(t,["status","--porcelain","--untracked-files=all"])===""}async function ha(t,e,n,r){try{return{exitCode:0,diagnostic:null,...await Ui(t,[...e],{cwd:n,shell:!1,windowsHide:!0,env:Ji(),timeout:r,maxBuffer:1048576,encoding:"utf8"})}}catch(o){let a={stdout:o!==null&&typeof o=="object"&&"stdout"in o?String(o.stdout??"").slice(0,1048576):"",stderr:o!==null&&typeof o=="object"&&"stderr"in o?String(o.stderr??"").slice(0,1048576):""};return wa(o)?{exitCode:-1,diagnostic:"command timed out",...a}:va(o)?{exitCode:o.code,diagnostic:`command exited with code ${o.code}`,...a}:{exitCode:-1,diagnostic:"command could not start",...a}}}var ya=["APPDATA","COMSPEC","HOME","LANG","LOCALAPPDATA","LC_ALL","PATH","PATHEXT","Path","ProgramFiles","ProgramData","PROGRAMDATA","SYSTEMROOT","SystemRoot","TEMP","TMP","USERPROFILE","WINDIR"];function Ji(){return Object.fromEntries(ya.flatMap(t=>{let e=process.env[t];return e===void 0?[]:[[t,e]]}))}function va(t){return t!==null&&typeof t=="object"&&"code"in t&&typeof t.code=="number"}function wa(t){return t!==null&&typeof t=="object"&&("killed"in t&&t.killed===!0||"signal"in t&&t.signal==="SIGTERM")}async function ne(t,e){let{stdout:n}=await ba(t,e);return n.trim()}function ba(t,e){return Ui("git",[...e],{cwd:t,shell:!1,windowsHide:!0,encoding:"utf8",env:Ji(),maxBuffer:10*1024*1024})}import{AsyncLocalStorage as Ta}from"node:async_hooks";import{execFile as Ra}from"node:child_process";import{realpath as Aa}from"node:fs/promises";import{isAbsolute as Ia,resolve as ln}from"node:path";import{promisify as Pa}from"node:util";var x=class extends Error{};import{execFile as xa}from"node:child_process";import{basename as ka,dirname as Sa,resolve as cn}from"node:path";import{promisify as Ea}from"node:util";var Ca=Ea(xa);async function xt(t){let e=async(a,s)=>(await Ca("git",s,{cwd:a,windowsHide:!0,timeout:1e4,encoding:"utf8"})).stdout.trim(),n;try{n=cn(await e(t,["rev-parse","--path-format=absolute","--git-common-dir"]))}catch(a){if(a instanceof Error&&"stderr"in a&&/not a git repository/i.test(String(a.stderr)))return cn(t);throw a}if(ka(n).toLowerCase()!==".git")throw new x("Release cycle requires a verifiable primary Git checkout");let r=Sa(n);if(cn(await e(r,["rev-parse","--show-toplevel"])).toLowerCase()!==r.toLowerCase())throw new x("Release control root could not be verified");return r}var Bi=new Ta,qa=Pa(Ra),z=t=>process.platform==="win32"?ln(t).toLowerCase():ln(t),M=(t,e)=>z(t)===z(e);function Ki(t){let e=Bi.getStore();return e&&z(e.canonical)===z(t)?e.invocation:t}function kt(){return Bi.getStore()}async function J(t,e){if(!Ia(t)||process.platform==="win32"&&/^[/\\]{2}/.test(t))throw new x("Lifecycle root must be an absolute local Git path");t=ln(t);let n=await Aa(t);if(z(n)!==z(t))throw new x("Lifecycle workspace must use its physical Git path");if(z(await xt(t))!==z(e))throw new x("Native invocation and lifecycle workspace belong to different Git repositories");if(z(t)===z(e))return n;if(!(await qa("git",["worktree","list","--porcelain","-z"],{cwd:e,windowsHide:!0,shell:!1,encoding:"utf8",timeout:1e4,env:Object.fromEntries(Object.entries(process.env).filter(([o])=>!/^(GIT_|NODE_OPTIONS$)/i.test(o)))})).stdout.split("\0").filter(o=>o.startsWith("worktree ")).map(o=>z(o.slice(9))).includes(z(t)))throw new x("Lifecycle invocation requires a registered Git worktree");return n}import{execFileSync as Va}from"node:child_process";import{createHash as Oa,randomUUID as Na}from"node:crypto";import{lstatSync as He,mkdirSync as Da,readFileSync as er,realpathSync as tr,unlinkSync as za}from"node:fs";import{link as Ma,open as Fa,unlink as La}from"node:fs/promises";import{dirname as Zi,join as nr,resolve as Qi}from"node:path";function dn(t){if(typeof t!="string"||!t||t.length>4096||[...t].some(e=>e.charCodeAt(0)<32))throw Error("Unsafe Git destination metadata");if(/^[A-Za-z][A-Za-z0-9+.-]*:\/\//.test(t)){let e;try{e=new URL(t)}catch{throw Error("Unsafe Git destination metadata")}let n=t.slice(t.indexOf("://")+3).split(/[/?#]/)[0]??"",r=n.includes("@")?n.slice(0,n.lastIndexOf("@")):null;if(/[?#]/.test(t)||e.password||r!==null&&!(e.protocol==="ssh:"&&r==="git"))throw Error("Unsafe Git destination metadata")}return t}var ie=i.string().regex(/^[a-f0-9]{64}$/),Gi=i.string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/),$a=i.string().regex(/^RUN-[A-Z0-9-]+$/),un=i.object({schema_version:i.literal(1),binding_id:i.string().regex(/^PBIND-[a-f0-9]{64}$/),created_at:i.string().datetime({offset:!0}),staging_id:i.string().uuid(),source_run_id:$a,source_thread_id:i.string().min(1).max(256),source_turn_id:i.string().min(1).max(256),task_id:i.string().regex(/^TASK-[A-Z0-9-]+$/).nullable(),change_id:i.string().regex(/^CHG-[A-Z0-9-]+$/).nullable(),execution_id:i.string().regex(/^EXEC-[A-Z0-9-]+$/),request_sha256:ie,repository_sha256:ie,records_workspace_sha256:ie,native_workspace_sha256:ie,candidate_sha:Gi,candidate_tree_sha:Gi,destination:i.object({remote:i.literal("origin"),url:i.string().min(1).max(4096),ref:i.string().regex(/^refs\/heads\/[A-Za-z0-9][A-Za-z0-9._/-]*$/).refine(t=>!t.includes("..")),scope:i.enum(["frontend","backend","framework"])}).strict(),mode:i.enum(["commits","release"]),condition:i.enum(["tests_passed"]).nullable(),contract_sha256:ie,project_policy_sha256:ie.nullable(),rule_sources:i.array(i.object({path:i.string().regex(/^\.agents\/rules\/(?:[A-Za-z0-9_-]+\/)*[A-Za-z0-9_-]+\.md$/),sha256:ie}).strict()).max(32),content_sha256:ie}).strict().superRefine((t,e)=>{t.task_id===null!=(t.change_id===null)&&e.addIssue({code:"custom",path:["task_id"],message:"Publication Task and Change must belong to the same source graph"})});function Ue(t){let e=t.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/\s+/g," ").trim(),n="se (?:os )?testes (?:passarem|forem aprovados)",r=new RegExp(`^${n},?\\s+(.+)$`).exec(e),o=new RegExp(`^(.+?),?\\s+${n}[.!]?$`).exec(e),a=r?.[1]??o?.[1]??e,s=/^se a v((?:0|[1-9]\d*)\.(?:0|[1-9]\d*)) ainda nao foi publicada no github ou no npm,\s*(?:(?:faca os ajustes necessarios|remova os bloqueios|mude o que for necessario para corrigir problemas de deploy)(?:,\s*| e ))*(?:faca (?:o )?deploy|garanta que seja finalizado o deploy) da v\1[.!]?$/.exec(e),l=/^(?:revise|verifique|confira) se (?:ja )?foi feito (?:o )?deploy, caso contrario faca deploy(?: (?:da|de) v?(?:0|[1-9]\d*)\.(?:0|[1-9]\d*))?[.!]?$/.test(e)||/^(?:revise|verifique|confira) se (?:ja )?foi feito (?:o )?deploy (?:da|de) v?(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)[.!] se ainda nao, faca os ajustes necessarios para realizar o deploy corretamente[.!] garanta que o deploy seja feito[.!]?$/.test(e),c=/^faca deploy e explique quando devo pedir release[.!]?$/.test(e),d=/^revise se todos os ajustes foram realizados corretamente, faca os ajustes finais e publique na versao (?:0|[1-9]\d*)\.(?:0|[1-9]\d*)[.!]?$/.test(e),m=r||o?"tests_passed":/\b(?:se|if|quando|caso|desde que|a menos que|unless|after|when|once|provided|assuming|apos|depois|condicionado)\b/.test(e)&&!l&&!s&&!d&&!c?"unsupported":null,u=a.replace(/\b(?:nao\s+(?:publique|publicar)|sem\s+publicar)\s+(?:(?:um|uma|o|a|novo|nova)\s+)*release\b/g,""),_=/\b(?:nao|nunca|jamais|never|do not|dont|don't)\s+(?:(?:faca|fazer|faz|realize|execute|efetue|de|do|perform)\s+)?(?:o\s+)?(?:deploy|push|commit|publique|publicar|publish|publication|envie|suba)\b|\bsem\s+(?:fazer\s+)?(?:o\s+)?(?:deploy|push|commit|publicar|publicacao)\b/.test(u),p=/^resolva\s+tudo\s+(?:o\s+)?que\s+e\s+(?:preciso|necessario)\s+ate\s+fazer\s+(?:o\s+)?deploy\s+(?:da|de)\s+v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)[.!]?$/.test(a)||/^(?:(?:por favor|please),?\s+)?(?:(?:pode|favor)\s+)?(?:(?:faca|fazer|faz|realize|execute|do)\s+)?(?:o\s+)?(?:deploy|push|commit|publique|publicar|publish|envie|release)\b/.test(a),f=t.includes("?")||/[`"'“”<>]/.test(t)||/\b(?:disse|citou|exemplo|quoted|said|talvez|maybe|hipoteticamente|hypothetically)\b/.test(e);return{action:a,condition:m,publicationDenied:_,directPublication:p,untrusted:f,...s?{incompleteReleaseVersion:s[1]}:{}}}var mn=t=>Oa("sha256").update(JSON.stringify(t)).digest("hex"),xe=t=>process.platform==="win32"?Qi(t).toLowerCase():Qi(t);function q(t){throw Error(`publication_binding_${t}`)}var _n=(t,e,n)=>`PBIND-${mn([t,e,n])}`;function fn(t,e){return/^RUN-[A-Z0-9-]+$/.test(e)||q("invalid_source_run"),nr(t,".agents/private/state/codex-hook-publication/v1",`${e}.json`)}function Je(t,e,n=!1,r=!1){for(let o=e;;o=Zi(o)){let a;try{a=He(o)}catch(s){if(n&&s.code==="ENOENT")return null;throw s}if((a.isSymbolicLink()||xe(tr(o))!==xe(o)||(o===e?!a.isFile()||a.nlink!==1&&!(r&&a.nlink===2)||a.size>65536:!a.isDirectory()))&&q("unsafe_physical_path"),xe(o)===xe(t))return He(e);Zi(o)===o&&q("root_escape")}}function St(t,e){let n=fn(t,e),r=Je(t,n,!0,!0);if(!r)return null;let o=er(n,"utf8"),a=Je(t,n,!1,!0);(!a||r.ino!==a.ino||r.dev!==a.dev||r.mtimeMs!==a.mtimeMs||r.size!==a.size)&&q("changed_during_read");let s;try{s=un.parse(JSON.parse(o)),dn(s.destination.url)}catch{return q("invalid_record")}let{content_sha256:l,...c}=s;return(s.source_run_id!==e||l!==mn(c)||s.binding_id!==_n(e,s.request_sha256,s.repository_sha256)||o!==`${JSON.stringify(s,null,2)}
|
|
6
|
+
`)&&q("invalid_record"),a.nlink===2&&ir(t,n,s,o),s}function ir(t,e,n,r){let o=`${e}.${n.staging_id}.tmp`,a=Je(t,e,!1,!0);if(a?.nlink===1)return null;let s;try{s=Je(t,o,!1,!0)}catch{return q("unexpected_alias")}return(!a||!s||a.nlink!==2||s.nlink!==2||a.ino!==s.ino||a.dev!==s.dev||er(o,"utf8")!==r)&&q("unexpected_alias"),o}function Xi(t,e){let n=pn(t),r=St(n.primaryRoot,t.source_run_id);r||q("missing_original_capture"),(r.binding_id!==t.binding_id||r.request_sha256!==t.source_sha256||r.source_thread_id!==t.client_thread_id||r.source_turn_id!==t.client_turn_id||r.task_id!==n.taskId||r.change_id!==n.changeId||r.execution_id!==n.executionId||r.records_workspace_sha256!==t.records_workspace_sha256||r.native_workspace_sha256!==t.native_workspace_sha256||r.repository_sha256!==t.repository_sha256||r.contract_sha256!==e.contract_sha256||r.candidate_sha!==e.candidate?.sha||r.destination.url!==e.destination?.url||r.destination.ref!==`refs/heads/${e.destination?.branch}`||r.destination.scope!==e.destination?.scope||r.mode!==e.mode||r.condition!==Ue(n.request).condition||r.project_policy_sha256!==(e.project_restrictions?.policy_sha256??null)||JSON.stringify(r.rule_sources)!==JSON.stringify(e.project_restrictions?.rule_sources??[]))&&q("candidate_destination_or_contract_changed");let o=Date.parse(r.created_at);(o<Date.parse(n.sourceStartedAt)||o>Date.now()||n.sourceFinishedAt!==null&&o>Date.parse(n.sourceFinishedAt))&&q("original_capture_time_mismatch");let a=fn(n.primaryRoot,t.source_run_id);if(He(a).nlink===2){let s=`${JSON.stringify(r,null,2)}
|
|
7
|
+
`,l=ir(n.primaryRoot,a,r,s);if(l)try{za(l)}catch(c){c.code!=="ENOENT"&&q("own_staging_cleanup_failed")}Je(n.primaryRoot,a)}return r}async function Bu(t,e){let n=pn(t);if(!["commits","release"].includes(String(e.mode))||e.phase!=="publish")return;let r=await Yi(n.repository,n.request,n.currentRunId);if((r.binding_id!==t.binding_id||r.steering_sha256!==e.authorization?.steering_sha256)&&q("human_source_changed_before_capture"),St(n.primaryRoot,t.source_run_id))return Xi(r,e);n.originalTurn||q("missing_original_capture_no_retroactive_binding");let o=(..._)=>Va("git",_,{cwd:n.repository,encoding:"utf8",windowsHide:!0}).trim();e.destination&&dn(e.destination.url),(!e.candidate||!e.destination||o("rev-parse","HEAD")!==e.candidate.sha||o("remote","get-url","--push","--all","origin")!==e.destination.url||e.destination?.remote!=="origin"||e.authorization?.binding_id!==t.binding_id)&&q("candidate_changed_before_capture");let a=un.parse({schema_version:1,binding_id:t.binding_id,created_at:new Date().toISOString(),staging_id:Na(),source_run_id:t.source_run_id,source_thread_id:t.client_thread_id,source_turn_id:t.client_turn_id,task_id:n.taskId,change_id:n.changeId,execution_id:n.executionId,request_sha256:t.source_sha256,repository_sha256:t.repository_sha256,records_workspace_sha256:t.records_workspace_sha256,native_workspace_sha256:t.native_workspace_sha256,candidate_sha:e.candidate.sha,candidate_tree_sha:o("rev-parse","HEAD^{tree}"),destination:{remote:"origin",url:e.destination.url,ref:`refs/heads/${e.destination.branch}`,scope:e.destination.scope},mode:e.mode,condition:Ue(n.request).condition,contract_sha256:e.contract_sha256,project_policy_sha256:e.project_restrictions?.policy_sha256??null,rule_sources:e.project_restrictions?.rule_sources??[],content_sha256:"0".repeat(64)}),{content_sha256:s,...l}=a;a.content_sha256=mn(l);let c=fn(n.primaryRoot,t.source_run_id),d=`${c}.${a.staging_id}.tmp`,m=n.primaryRoot;for(let _ of[".agents","private","state","codex-hook-publication","v1"]){m=nr(m,_);try{Da(m)}catch(p){if(p.code!=="EEXIST")throw p}(!He(m).isDirectory()||He(m).isSymbolicLink()||xe(tr(m))!==xe(m))&&q("unsafe_directory")}let u=!1;try{let _=await Fa(d,"wx",384);u=!0;try{await _.writeFile(`${JSON.stringify(a,null,2)}
|
|
8
|
+
`,"utf8"),await _.sync()}finally{await _.close()}try{await Ma(d,c)}catch(p){if(p.code!=="EEXIST")throw p}}finally{u&&await La(d).catch(_=>{if(_.code!=="ENOENT")throw _})}return Xi(r,e)}var $=t=>t.replace(/\r\n?/g,`
|
|
9
|
+
`).trim().normalize("NFC"),ja=t=>$(t).normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase();function Be(t){throw Error(`publication_native_capability_missing:${t}`)}function rr(t,e,n,r){let o=[];for(let c of r){let d=c.provenance,m=$(c.text),u=!!d&&d.source_record_type==="response_item"&&d.source_payload_type==="message"&&d.role==="user"&&d.metadata_turn_id===c.turnId&&!!d.content_types?.length&&d.content_types.length===d.content_item_kinds?.length&&d.content_types.length===d.content_item_provenance?.length&&d.content_types.every((f,h)=>f==="input_text"&&d.content_item_kinds?.[h]==="user.text"&&d.content_item_provenance?.[h]==="user"),_=o.at(-1),p=u&&m.startsWith("<send_user_message_question_reply>")&&c.nativeLoginReply===!0&&d.content_types?.length===1;_?.turn===c.turnId&&_.text===m?(_.human||=u,_.loginReply||=p):o.push({turn:c.turnId,text:m,human:u,loginReply:p})}let a=o.findIndex(c=>c.turn===e&&c.human&&!/^[<[{]/.test(c.text)&&c.text===$(t));(a<0||o.slice(0,a).some(c=>c.human))&&Be("original_human_source_mismatch"),o.slice(a).some(c=>!c.human)&&Be("human_provenance_unavailable");let s={git_transport:"default",github_api:"default",release:"default",sql:"default"},l=[];for(let c of o.slice(a+1)){if(c.loginReply)continue;let d=c.text,m=ja(d);if(Ue(d).publicationDenied&&Be("human_revocation"),!/^(?:qual (?:e )?o status|status|alguma novidade|andamento|any update|what is the status)\??[.!]?$/.test(m)){if(/^(?:continue|retome|resume|prossiga|siga)(?:\s+TASK-[A-Z0-9-]+)?[.!]?$/i.test(d)){(d.match(/TASK-[A-Z0-9-]+/g)??[]).some(_=>_!==n)&&Be("foreign_continuation");continue}/^(?:somente|apenas|exclusivamente) (?:via |por )?ssh[.!]?$/.test(m)?s.git_transport="ssh-only":/^(?:sem|nao use a?) api (?:do )?github[.!]?$/.test(m)?s.github_api="forbidden":/^sem release[.!]?$/.test(m)?s.release="forbidden":/^(?:sem executar|nao execute) sql[.!]?$/.test(m)?s.sql="forbidden":Be("human_steering_changed"),l.push(d)}}return{constraints:s,steering:l}}import{createHash as Oc}from"node:crypto";import{createHash as Ha}from"node:crypto";var Wa=".agents/private/state/codex-telemetry-spool/v1/events";var Yu=64*1024*1024;var Ua=i.object({path:i.string().startsWith(`${Wa}/`).endsWith(".json"),stat:i.object({dev:i.string(),ino:i.string(),size:i.string(),mtime_ns:i.string(),ctime_ns:i.string()}).strict(),envelope:Gt}).strict(),ep=i.object({schema_version:i.literal(2),prefix:i.string().regex(/^[a-f0-9]{2}$/),events:i.array(Ua),checksum_sha256:i.string().regex(/^[a-f0-9]{64}$/)}).strict();function ke(t){if(t.same_turn_handoff!==void 0||!["codex","codex-desktop","codex-subagent"].includes(t.client)||t.agent_invocation_id===void 0||t.root_agent_invocation_id===void 0||t.parent_agent_invocation_id===void 0||t.invocation_kind===void 0||t.delegation_depth===void 0)return null;let e=t.client==="codex-subagent",n=t.client_thread_id??null,r=t.entrypoint==="observation"?t.observed_agent_path??null:n,o=t.client_turn_id??null;return n===null&&o===null?null:ze.parse({schema_version:1,run_id:t.run_id,execution_id:t.execution_id,task_id:t.task_id,spec_id:t.spec_id,prd_id:t.prd_id,change_id:t.change_id,developer_identity:t.developer_identity??null,zaip_agent:t.agent,phase:t.phase,purpose:t.run_purpose??null,agent_invocation_id:t.agent_invocation_id,root_agent_invocation_id:t.root_agent_invocation_id,parent_agent_invocation_id:t.parent_agent_invocation_id,invocation_kind:t.invocation_kind,delegation_depth:t.delegation_depth,client:t.client,thread_id:e?null:n,turn_id:o,agent_path:e?r:null,...e&&r===null&&t.observed_agent_id?{native_agent_id:t.observed_agent_id}:{}})}var or=".agents/private/state/codex-telemetry-spool/v1",vp=`${or}/events`,wp=64*1024,Ja=t=>Ha("sha256").update(t).digest("hex");async function Ke(t,e){let n=ze.parse(e),r=JSON.stringify([n.client==="codex-desktop"?"codex":n.client,n.thread_id,n.turn_id,n.agent_path,n.turn_id===null?n.run_id:null,...n.client==="codex-subagent"&&n.agent_path===null&&n.native_agent_id?[n.native_agent_id]:[],...n.purpose==="observation"?["observation"]:[]]),o=`${or}/correlations/${Ja(r)}.json`;try{return await t.writeTextAtomicExclusive(o,`${JSON.stringify(n)}
|
|
10
|
+
`),n}catch(s){if(!Ba(s)||s.code!=="EEXIST")throw s}let a=ze.parse(JSON.parse(await t.readText(o)));if(gn(a,n))return await t.writeTextAtomic(o,`${JSON.stringify(n)}
|
|
11
|
+
`),n;if(JSON.stringify(a)!==JSON.stringify(n))throw new Error(`Codex telemetry correlation is already owned by ${a.agent_invocation_id}`);return a}function gn(t,e){return["run_id","agent_invocation_id","root_agent_invocation_id","parent_agent_invocation_id","invocation_kind","delegation_depth","client","thread_id","turn_id","agent_path","native_agent_id"].some(o=>t[o]!==e[o])?!1:["execution_id","task_id","spec_id","prd_id","change_id","zaip_agent","phase","purpose"].every(o=>t[o]===null||t[o]===e[o])}function Ba(t){return t instanceof Error&&"code"in t}var Ka=i.object({run_id:i.string().startsWith("RUN-"),path:i.string().startsWith(".agents/records/runs/"),content_sha256:i.string().regex(/^[a-f0-9]{64}$/)}).strict(),Ga=i.object({schema_version:i.literal(1),manifest_id:i.string().min(1),created_at:i.string().datetime({offset:!0}),kind:i.literal("historical_developer_attribution"),assignment:mt.extend({attribution_source:i.literal("human_assigned")}),source_streams:i.array(Ka).min(1)}).strict().superRefine((t,e)=>{let n=new Set,r=new Set;for(let[o,a]of t.source_streams.entries())n.has(a.run_id)&&e.addIssue({code:"custom",path:["source_streams",o,"run_id"],message:"Duplicate historical Run"}),r.has(a.path)&&e.addIssue({code:"custom",path:["source_streams",o,"path"],message:"Duplicate historical Run path"}),n.add(a.run_id),r.add(a.path)}),Ep=Ga.extend({manifest_hash:i.string().regex(/^[a-f0-9]{64}$/)}).strict();var Za=".agents/private/state/developer-identity.json",Rp=1440*60*1e3,Et=class extends Error{name="DeveloperIdentityBootstrapRequiredError"};async function Qa(t){try{return mt.parse(JSON.parse(await t.readText(Za)))}catch(e){if(Xa(e))return null;throw new Et("Developer identity cache is invalid; run `developer identity bootstrap`",{cause:e})}}async function ar(t){let e=await Qa(t);if(e===null)throw new Et("Developer identity is not configured; run `developer identity bootstrap`");return e}function Xa(t){return typeof t=="object"&&t!==null&&"code"in t&&t.code==="ENOENT"}import{createHash as gs,randomUUID as hs}from"node:crypto";function sr(t){return t instanceof Error&&"code"in t&&t.code==="EEXIST"}async function cr(t,e,n,r,o){let a=`${e}.lock`,s=()=>t.writeTextExclusive(a,`${JSON.stringify({run_id:n,pid:process.pid})}
|
|
12
|
+
`);try{await s()}catch(l){if(!sr(l))throw l;if(!await r())throw new Error(`Run V2 is being updated concurrently: ${n}`);try{await s()}catch(c){throw sr(c)?new Error(`Run V2 is being updated concurrently: ${n}`):c}}try{await o()}finally{await t.removeFile(a)}}async function lr(t,e,n){let r=t.sameTurnHandoff!==void 0&&"kind"in t.sameTurnHandoff&&t.sameTurnHandoff.kind==="conversation_promotion";if(r&&e!==null&&(e.run.execution_kind!=="interaction"||e.run.entrypoint!=="conversation"||e.run.intake?.intent!=="conversation"||e.run.requires_finalizer!==!1||e.run.task_id!==null||e.run.change_id!==null||e.run.spec_id!==null||e.run.prd_id!==null||e.run.model!==t.model||e.run.reasoning_effort!==t.reasoningEffort||(await n()).some(o=>o.run.parent_run_id===e.run.run_id)))throw new Error("Conversation handoff predecessor must be a childless targetless interaction");if(e!==null&&(e.finished?.status!=="completed"||!r&&e.finalization_decision?.outcome!=="completed"||(!r&&t.sameTurnHandoff!==void 0&&"kind"in t.sameTurnHandoff?e.run.execution_kind!=="delivery"||e.run.entrypoint!=="task"||e.run.task_id===null:e.run.execution_kind!=="interaction")||e.run.client_thread_id!==t.clientThreadId||e.run.client_turn_id!==t.clientTurnId||e.run.conversation_id!==t.conversationId||e.run.parent_run_id!==null||t.continuationOfRunId!==e.run.run_id))throw new Error("Same-turn handoff predecessor is not an eligible completed root")}function dr(t){return B(t)&&t.code==="ENOENT"||t instanceof fe&&B(t.cause)&&t.cause.code==="ENOENT"}function Ya(t){return dr(t)||B(t)&&t.code==="EBADF"||t instanceof fe&&(B(t.cause)&&t.cause.code==="EBADF"||t.message.startsWith("Physical path escapes workspace root:"))}function B(t){return t instanceof Error&&"code"in t}async function Ct(t){await new Promise(e=>setTimeout(e,t))}function hn(t,e){let n=Date.now();return{schema_version:2,identity:t,run_id:null,owner_pid:process.pid,owner_nonce:e,claimed_at:new Date(n).toISOString(),lease_expires_at:new Date(n+3e4).toISOString()}}async function Se(t,e,n,r){let o=null,a=5;for(let l=0;l<a;l+=1)try{o=await t.readText(e);break}catch(c){if(!Ya(c)||l===a-1)throw c;await Ct(5*(l+1))}if(o===null)throw new Error(`Subagent invocation claim disappeared: ${r}`);let s=JSON.parse(o);if(s.identity!==n)throw new Error(`Subagent invocation claim is incompatible: ${r}`);return s}function Tt(t){let e=Date.parse(t.lease_expires_at);return!Number.isFinite(e)||e<=Date.now()}async function ur(t,e,n,r){let o=`${e}.recovery-${n}.json`;for(let a=0;a<8;a+=1){let s=hn(`recovery:${n}`,r);try{return await t.writeTextExclusive(o,`${JSON.stringify(s)}
|
|
13
|
+
`),o}catch(l){if(!B(l)||l.code!=="EEXIST")throw l;let c;try{c=JSON.parse(await t.readText(o))}catch(d){if(dr(d))continue;throw d}if(!Tt(c))return null;o=`${o}.${c.owner_nonce}.json`}}throw new Error("Subagent invocation recovery lease chain exceeded")}async function yn(t,e,n,r,o,a){let s=await Se(t,e,n,r);if(s.owner_nonce!==o){if(s.run_id===a)return;throw new Error(`Subagent invocation claim ownership changed: ${r}`)}await t.writeTextAtomic(e,`${JSON.stringify({...s,run_id:a,lease_expires_at:new Date().toISOString()})}
|
|
14
|
+
`)}function pr(t){try{return process.kill(t,0),!0}catch(e){return!(B(e)&&e.code==="ESRCH")}}async function mr(t,e,n,r,o){let a=await t.listFiles(e,".jsonl");if(o&&o.threadId!==null){let c=[];for(let p=0;p<a.length;p+=16)c.push(...await Promise.all(a.slice(p,p+16).map(async f=>{let h=await t.readFirstLine(f),w=h?.trim()?h:await t.readText(f),y=_t.parse(Ge(w)[0]);if(!n(y.run_id).includes(f))throw new Error(`Run V2 id does not match storage path: ${f}`);return{path:f,run:y}})));let d=p=>p==="codex-desktop"?"codex":p,m=new Set(c.filter(({run:p})=>d(p.client)===d(o.client)&&p.client_thread_id===o.threadId).map(({run:p})=>p.run_id)),u=new Map;for(let{run:p}of c)p.parent_run_id!==null&&u.set(p.parent_run_id,[...u.get(p.parent_run_id)??[],p.run_id]);let _=[...m];for(let p=0;p<_.length;p++)for(let f of u.get(_[p])??[])m.has(f)||(m.add(f),_.push(f));a=c.filter(({run:p})=>m.has(p.run_id)).map(({path:p})=>p)}let s=await Promise.all(a.map(async c=>{let d=Ee(Ge(await t.readText(c)));if(!n(d.run.run_id).includes(c))throw new Error(`Run V2 id does not match storage path: ${c}`);return{path:c,run:d}})),l=new Map;for(let c of s){let d=l.get(c.run.run.run_id);if(d!==void 0&&JSON.stringify(d.run.records)!==JSON.stringify(c.run.records))throw new Error(`Run V2 has divergent monthly and legacy streams: ${c.run.run.run_id}`);(d===void 0||c.path===r(c.run.run.run_id))&&l.set(c.run.run.run_id,c)}return[...l.values()].map(({run:c})=>c).sort((c,d)=>d.run.occurred_at.localeCompare(c.run.occurred_at)||d.run.run_id.localeCompare(c.run.run_id))}import{createHash as es,randomUUID as ts}from"node:crypto";var ue="usage-attribution",At="usage-attribution-recovery",ns=3e4,is=3;async function gr(t,e,n){let r=Date.now()+12e4,o=ts(),a=null;for(;;){if(a!==null&&Date.now()>=r)throw a;try{if(await t.writeTextAtomicExclusive(e,`${JSON.stringify(hr(o))}
|
|
15
|
+
`),Date.now()>=r)throw await fr(t,e,o),new Error("Usage attribution lock acquisition exceeded deadline");break}catch(s){if((!re(s)||s.code!=="EEXIST")&&!cs(s))throw s;if(a=s,re(s)&&s.code==="EEXIST"){let l=await rs(t,e,r);if(l===null){await Rt(s,r);continue}if(l.purpose!==ue)throw new Error("Usage attribution lock has an incompatible purpose");if(!_r(l)){await Rt(s,r);continue}if(Date.now()>=r)throw s;let c=await ss(t,e,l.owner_nonce,o);if(c!==null)try{if(Date.now()>=r)throw s;let d=await Ze(t,e);if(d!==null&&d.owner_nonce===l.owner_nonce&&d.content===l.content&&_r(d)){if(Date.now()>=r)throw s;await t.removeFileIfContentMatches(e,d.content)}}finally{await vr(t,c,o)}}await Rt(s,r)}}try{return await n()}finally{await fr(t,e,o)}}function hr(t){let e=Date.now();return{schema_version:1,purpose:ue,pid:process.pid,owner_nonce:t,acquired_at:new Date(e).toISOString(),lease_expires_at:new Date(e+ns).toISOString()}}async function Ze(t,e){try{let n=await t.readText(e),r=JSON.parse(n);if(as(r))return{...r,content:n};if(os(r))return{schema_version:1,purpose:ue,pid:r.pid,owner_nonce:`legacy-${es("sha256").update(n).digest("hex")}`,acquired_at:new Date(0).toISOString(),lease_expires_at:new Date(0).toISOString(),legacy:!0,content:n};throw new Error(`Usage attribution lock is malformed: ${e}`)}catch(n){if(re(n)&&n.code==="ENOENT")return null;throw n}}async function rs(t,e,n){let r=0;for(;;)try{return await Ze(t,e)}catch(o){if(!ls(o)||(r+=1,r>=is||Date.now()>=n)||(await Rt(o,n),Date.now()>=n))throw o}}function os(t){return typeof t=="object"&&t!==null&&t.purpose===ue&&Number.isSafeInteger(t.pid)&&t.pid>0}function as(t){if(typeof t!="object"||t===null)return!1;let e=t;return e.schema_version===1&&(e.purpose===ue||e.purpose===At)&&Number.isSafeInteger(e.pid)&&(e.pid??0)>0&&typeof e.owner_nonce=="string"&&e.owner_nonce.length>=16&&typeof e.acquired_at=="string"&&Number.isFinite(Date.parse(e.acquired_at))&&typeof e.lease_expires_at=="string"&&Number.isFinite(Date.parse(e.lease_expires_at))&&(e.target_nonce===void 0||typeof e.target_nonce=="string")}function _r(t){return t!==null&&t.purpose===ue&&(t.legacy===!0||Date.parse(t.lease_expires_at)<=Date.now())&&!yr(t.pid)}function yr(t){try{return process.kill(t,0),!0}catch(e){return!(re(e)&&e.code==="ESRCH")}}async function ss(t,e,n,r){let o=`${e}.recovery-${n}`;try{return await t.writeTextAtomicExclusive(o,`${JSON.stringify({...hr(r),purpose:At,target_nonce:n})}
|
|
16
|
+
`),o}catch(a){if(!re(a)||a.code!=="EEXIST")throw a;let s=await Ze(t,o);return s!==null&&s.purpose===At&&s.target_nonce===n&&Date.parse(s.lease_expires_at)<=Date.now()&&!yr(s.pid)&&await vr(t,o,s.owner_nonce),null}}async function fr(t,e,n){let r=await Ze(t,e);r?.purpose===ue&&r.owner_nonce===n&&await t.removeFileIfContentMatches(e,r.content)}async function vr(t,e,n){let r=await Ze(t,e);r?.purpose===At&&r.owner_nonce===n&&await t.removeFileIfContentMatches(e,r.content)}async function Rt(t,e){if(Date.now()>=e)throw t;await new Promise(n=>setTimeout(n,25))}function re(t){return t instanceof Error&&"code"in t}function cs(t){return re(t)&&(t.code==="ENOENT"||t.code==="EBADF")||t instanceof fe&&(re(t.cause)&&(t.cause.code==="ENOENT"||t.cause.code==="EBADF")||t.message.startsWith("Physical path escapes workspace root:"))}function ls(t){let e=t instanceof fe?t.cause:t;return re(e)&&(e.code==="EBADF"||process.platform==="win32"&&e.code==="EPERM")}var G=class{constructor(e,n){this.filesystem=e;this.storage=n;if(n.storageMode==="tracked_sanitized"&&n.layout.version===1)throw new Error("tracked_sanitized Run V2 storage requires a modern WorkspaceLayout");n.storageMode==="local_only"&&ys(n.localBasePath)}filesystem;storage;activeWriters=new Set;async start(e){let n=e.clock??new T,r=e.id??Oe("RUN",e.shortName,{clock:n,...e.collisionCode===void 0?{}:{collisionCode:e.collisionCode},...e.timeZone===void 0?{}:{timeZone:e.timeZone}}),o=e.parentRunId===void 0||e.parentRunId===null?null:await this.read(e.parentRunId).catch(()=>null),a=e.sameTurnHandoff===void 0?null:await this.read(e.sameTurnHandoff.predecessor_run_id);await lr(e,a,()=>this.list());let s=a?.run.agent_invocation_id??`AINV-${r.slice(4)}`,l=o===null?e.parentRunId===void 0||e.parentRunId===null?null:`AINV-${e.parentRunId.slice(4)}`:o.run.agent_invocation_id??`AINV-${o.run.run_id.slice(4)}`,c=o===null?l??s:o.run.root_agent_invocation_id??l,d=l===null?0:(o?.run.delegation_depth??0)+1,m=o!==null?o.run.developer_identity:e.entrypoint==="observation"?null:e.developerIdentity??(this.storage.storageMode==="local_only"?null:await ar(this.filesystem)),u=_t.parse({schema_version:2,event_id:Z(r,1),run_id:r,sequence:1,occurred_at:n.now().toISOString(),type:"run.started",attribution_status:"attributed",developer_identity:m,phase:e.phase,run_role:e.runRole??(e.phase!=="execution"?"intake":e.parentRunId!==void 0&&e.parentRunId!==null?"subagent":"orchestrator"),run_purpose:e.runPurpose??(e.phase!=="execution"?"intake":e.agent==="agent-finalizer"?"finalization":e.agent==="agent-reviewer"?"review":e.agent==="agent-auditor"?"audit":e.parentRunId===void 0||e.parentRunId===null?"orchestration":"execution"),requires_finalizer:e.requiresFinalizer??(e.phase==="execution"&&(e.parentRunId===void 0||e.parentRunId===null)&&e.executionId!==void 0&&e.executionId!==null),execution_kind:e.executionKind,execution_eligibility:[...e.executionEligibility??[]],...e.directExecutionAuthorization===void 0?{}:{direct_execution_authorization:e.directExecutionAuthorization},entrypoint:e.entrypoint,work_type:e.workType,storage_mode:this.storage.storageMode,client:e.client,agent:e.agent,agent_name:e.agentName??null,...e.agentIdentityWarning===void 0?{}:{agent_identity_warning:e.agentIdentityWarning},provider:e.provider,model:e.model,reasoning_effort:e.reasoningEffort??null,client_thread_id:e.clientThreadId??null,client_turn_id:e.clientTurnId??null,...e.entrypoint==="observation"?{observed_agent_id:e.observedAgentId??null,observed_agent_path:e.observedAgentPath??null,observed_parent_agent_id:e.observedParentAgentId??null}:{},conversation_id:e.conversationId,execution_id:e.executionId??null,task_id:e.taskId??null,spec_id:e.specId??null,prd_id:e.prdId??null,change_id:e.changeId??null,parent_run_id:e.parentRunId??null,...e.agentInvocationId===void 0?{}:{agent_invocation_id:e.agentInvocationId,root_agent_invocation_id:e.rootAgentInvocationId,parent_agent_invocation_id:e.parentAgentInvocationId,invocation_kind:e.invocationKind,delegation_depth:e.delegationDepth},continuation_of_run_id:e.continuationOfRunId??null,...e.sameTurnHandoff===void 0?{}:{same_turn_handoff:e.sameTurnHandoff},retry_of_run_id:e.retryOfRunId??null,agent_invocation_id:s,root_agent_invocation_id:c,parent_agent_invocation_id:l,invocation_kind:l===null?"orchestrator":"delegated",delegation_depth:d,intake:e.intake??null}),_=this.path(r);if(this.activeWriters.has(r))throw new Error(`Run V2 already has a writer or persisted stream: ${r}`);try{await this.filesystem.writeTextExclusive(_,Ce(u))}catch(p){throw!B(p)||p.code!=="EEXIST"?p:new Error(`Run V2 already has a writer or persisted stream: ${r}`)}try{let p=ke(u);p!==null&&e.sameTurnHandoff===void 0&&await Ke(this.filesystem,p)}catch(p){throw await this.filesystem.removeFile(_),p}return this.activeWriters.add(r),new It(this.filesystem,_,u,n,()=>{this.activeWriters.delete(r)})}async read(e){let n=await this.readPath(e);if(n===null)throw new Error(`Run V2 not found: ${e}`);return Ee(Ge(await this.filesystem.readText(n)))}async list(e){return mr(this.filesystem,this.basePath(),n=>this.candidatePaths(n),n=>this.path(n),e)}async appendRecord(e){await this.appendRecords([e])}async appendRecords(e){let n=e.map(s=>ge.parse(s)),[r]=n;if(r===void 0)return;let o=r.run_id;if(n.some(s=>s.run_id!==o))throw new Error("Run V2 batch must contain one Run id");let a=this.path(o);await cr(this.filesystem,a,o,()=>this.recoverOrphanedAppendLock(`${a}.lock`,o),async()=>{if(await this.readPath(o)!==a)throw new Error(`Run V2 ${o} is stored in a legacy daily path; migrate it before append`);let l=await this.read(o),c=l.records.length+1;for(let[d,m]of n.entries())if(m.sequence!==c+d)throw new Error(`Run V2 compare-and-append failed: expected sequence ${c+d}, received ${m.sequence}`);Ee([...l.records,...n]),await this.filesystem.appendText(a,n.map(Ce).join(""))})}async withUsageAttributionLock(e){return gr(this.filesystem,`${this.basePath()}/.usage-attribution.lock`,e)}async recoverOrphanedAppendLock(e,n){let r;try{r=await this.filesystem.readText(e)}catch{return!1}let o;try{o=JSON.parse(r)}catch{return!1}if(o.run_id!==n||typeof o.pid!="number"||!Number.isSafeInteger(o.pid)||o.pid<=0||pr(o.pid))return!1;try{return await this.filesystem.readText(e)!==r?!1:(await this.filesystem.removeFile(e),!0)}catch{return!1}}async withSubagentInvocationClaim(e,n,r,o){let a=gs("sha256").update(e).digest("hex"),s=this.subagentInvocationClaimPath(a);await this.migrateLegacySubagentInvocationClaim(s,a,e);let l=hs(),c=hn(e,l),d=!1;try{await this.filesystem.writeTextExclusive(s,`${JSON.stringify(c)}
|
|
17
|
+
`),d=!0}catch(u){if(!B(u)||u.code!=="EEXIST")throw u}let m=Date.now()+5e3;for(;!d;){let u=await Se(this.filesystem,s,e,a);if(typeof u.run_id=="string")return n(u.run_id);if(!Tt(u)){if(Date.now()>=m)throw new Error(`Subagent invocation claim remained pending: ${a}`);await Ct(25);continue}let _=await ur(this.filesystem,s,u.owner_nonce,l);if(_===null){if(Date.now()>=m)throw new Error(`Subagent invocation claim recovery timed out: ${a}`);await Ct(25);continue}try{let p=await Se(this.filesystem,s,e,a);if(typeof p.run_id=="string")return n(p.run_id);if(!Tt(p))continue;await this.filesystem.writeTextAtomic(s,`${JSON.stringify(c)}
|
|
18
|
+
`),d=!0}finally{await this.filesystem.removeFile(_)}}try{let u=await o?.();if(u!=null)return await yn(this.filesystem,s,e,a,l,u.runId),u.value;let _=await r();return await yn(this.filesystem,s,e,a,l,_.runId),_.value}catch(u){let _=await Se(this.filesystem,s,e,a);throw _.owner_nonce===l&&_.run_id===null&&await this.filesystem.removeFile(s),u}}path(e){if(this.storage.storageMode==="tracked_sanitized")return this.storage.layout.activePath("run",e);let{year:n,month:r}=Kt(e);return`${this.storage.localBasePath}/${n}/${r}/${e}.jsonl`}candidatePaths(e){if(this.storage.storageMode==="tracked_sanitized")return[this.path(e),...this.storage.layout.legacyReadCandidates("run",e).map(a=>a.path)];let{year:n,month:r,day:o}=Kn(e);return[this.path(e),`${this.storage.localBasePath}/${n}/${r}/${o}/${e}.jsonl`]}async readPath(e){if(this.storage.storageMode==="tracked_sanitized")return ce(this.filesystem,this.storage.layout,"run",e);for(let n of this.candidatePaths(e))if(await this.filesystem.exists(n))return n;return null}basePath(){return this.storage.storageMode==="tracked_sanitized"?this.storage.layout.entityRoot("run"):this.storage.localBasePath}subagentInvocationClaimPath(e){return this.storage.storageMode==="tracked_sanitized"?ut("subagent-invocation",e):`${this.basePath()}/.claims/subagent-invocation/${e}.json`}async migrateLegacySubagentInvocationClaim(e,n,r){let o=`${this.basePath()}/.subagent-invocation-claims/${n}.json`;if(!await this.filesystem.exists(o))return;let a=await Se(this.filesystem,o,r,n);try{await this.filesystem.writeTextExclusive(e,`${JSON.stringify(a)}
|
|
19
|
+
`)}catch(s){if(!B(s)||s.code!=="EEXIST")throw s}}};function ys(t){if(t.length===0||t.includes("\\")||t.includes("\0")||t.startsWith("/")||t.startsWith("./")||t.endsWith("/")||/^[A-Za-z]:/.test(t)||t.split("/").some(e=>e.length===0||e==="."||e===".."))throw new Error(`local_only Run basePath must be canonical and explicit: ${t}`)}function xr(t){let e=new Map,n=[];for(let r of t){if(r.source_segment_key===null){n.push(r);continue}let o=e.get(r.source_segment_key);if(o===void 0){e.set(r.source_segment_key,r),n.push(r);continue}if(!vn(r,o))throw new Error(`Divergent duplicate source segment: ${r.source_segment_key}`)}return n}function vn(t,e){return JSON.stringify(br(t))===JSON.stringify(br(e))}function br(t){return{phase:t.phase,activity_kind:t.activity_kind,classification_source:t.classification_source,tokens:t.tokens,cost:t.cost,provider:t.provider,model:t.model,source_segment_key:t.source_segment_key,model_call_id:t.model_call_id??null}}function kr(t,e){let n=[],r=null;for(let o of t.split(/\r?\n/).map(a=>a.trim()).filter(Boolean)){let a=JSON.parse(o),s=ge.parse(Array.isArray(a)?e(a,r):a);r??=s.run_id,n.push(s)}return n}function Pt(t,e,n){if(t.model!=="unknown"&&n.requested.model!==t.model)throw new Error(`Agent Run model is immutable: expected ${t.model}, received ${n.requested.model}`);if(t.reasoning_effort!=null&&n.requested.reasoning_effort!==t.reasoning_effort)throw new Error(`Agent Run reasoning effort is immutable: expected ${t.reasoning_effort}, received ${n.requested.reasoning_effort}`);let r=e.find(o=>o.type==="model.selection.recorded");if(r!==void 0){if(JSON.stringify(r.requested)!==JSON.stringify(n.requested))throw new Error(`Agent Run calls must inherit one model configuration: ${t.run_id}`);if(JSON.stringify(r.selection)!==JSON.stringify(n.selection))throw new Error(`Agent Run calls must inherit one selection decision: ${t.run_id}`)}}function Z(t,e){return`${t}:${String(e).padStart(6,"0")}`}function Ce(t){if(pt(t),t.type==="run.started")return`${JSON.stringify(t)}
|
|
20
|
+
`;if(t.type==="run.late_finalization.assessed")return`${JSON.stringify(t)}
|
|
21
|
+
`;if(t.type==="run.finished")return`${JSON.stringify([3,"f",t.event_id,t.sequence,t.occurred_at,t.phase,t.status])}
|
|
22
|
+
`;if(t.type==="run.finalization.decided")return`${JSON.stringify([3,"d",t.event_id,t.sequence,t.occurred_at,t.finalizer_run_id,t.outcome,t.summary,t.evidence_ids,t.changed_files])}
|
|
23
|
+
`;if(t.type==="run.attribution.recovered")return`${JSON.stringify([3,"a",t.event_id,t.sequence,t.occurred_at,t.phase,t.execution_id,t.task_id,t.change_id])}
|
|
24
|
+
`;if(t.type==="model.selection.recorded")return`${JSON.stringify([3,"m",t.event_id,t.sequence,t.occurred_at,t.invocation_id,[t.requested.model,t.requested.reasoning_effort,t.requested.velocity],[t.selection.source,t.selection.policy_version,t.selection.reasons]])}
|
|
25
|
+
`;if(t.type==="provider.invocation.finished")return`${JSON.stringify([3,"p",t.event_id,t.sequence,t.occurred_at,t.invocation_id,t.status,[t.effective.provider,t.effective.model,t.effective.reasoning_effort,t.effective.service_tier],t.latency_ms])}
|
|
26
|
+
`;if(t.type==="model.call.observed")return`${JSON.stringify([3,"c",t.event_id,t.sequence,t.occurred_at,t.call_id,t.agent_invocation_id,t.coverage,[t.tokens.input,t.tokens.cached_input,t.tokens.output,t.tokens.reasoning,t.tokens.total,t.tokens.source,t.tokens.cache_write_input??null],[t.cost.usd,t.cost.brl,t.cost.fx_rate??null],t.provider,t.model,t.source_call_key,t.source_occurred_at??null,t.source_started_at??null,t.source_finished_at??null,t.runtime===void 0?null:[t.runtime.reasoning_effort,t.runtime.service_tier]])}
|
|
27
|
+
`;let e=t.context_stats;return`${JSON.stringify([3,"u",t.event_id,t.sequence,t.occurred_at,t.phase,t.activity_kind,t.classification_source,[t.tokens.input,t.tokens.cached_input,t.tokens.output,t.tokens.reasoning,t.tokens.total,t.tokens.source,t.tokens.cache_write_input??null],[t.cost.usd,t.cost.brl,t.cost.fx_rate??null],t.provider,t.model,t.source_segment_key,t.supersedes_event_id,t.source_occurred_at??null,e===void 0?null:[e.initial_pack_tokens,e.tool_output_tokens,e.files_opened,e.snippets_opened],t.runtime===void 0?null:[t.runtime.reasoning_effort,t.runtime.service_tier],t.source_started_at??null,t.source_finished_at??null,t.retrospective_correction??null,t.model_call_id??null,t.attributed_spec_id??null])}
|
|
28
|
+
`}function Sr(t,e){if(t[0]!==3||e===null)throw new Error("Run delta requires transport version 3 and a preceding run.started header");if(t[1]==="f")return{schema_version:2,type:"run.finished",run_id:e,event_id:t[2],sequence:t[3],occurred_at:t[4],phase:t[5],status:t[6]};if(t[1]==="a")return{schema_version:2,type:"run.attribution.recovered",run_id:e,event_id:t[2],sequence:t[3],occurred_at:t[4],phase:t[5],execution_id:t[6],task_id:t[7],change_id:t[8]};if(t[1]==="d"&&Array.isArray(t[8]))return{schema_version:2,type:"run.finalization.decided",run_id:e,event_id:t[2],sequence:t[3],occurred_at:t[4],finalizer_run_id:t[5],outcome:t[6],summary:t[7],evidence_ids:t[8],changed_files:Array.isArray(t[9])?t[9]:[]};if(t[1]==="m"&&Array.isArray(t[6])&&Array.isArray(t[7])){let u=t[6],_=t[7];return{schema_version:2,type:"model.selection.recorded",run_id:e,event_id:t[2],sequence:t[3],occurred_at:t[4],invocation_id:t[5],requested:{model:u[0],reasoning_effort:u[1],velocity:u[2]},selection:{source:_[0],policy_version:_[1],reasons:_[2]}}}if(t[1]==="p"&&Array.isArray(t[7])){let u=t[7];return{schema_version:2,type:"provider.invocation.finished",run_id:e,event_id:t[2],sequence:t[3],occurred_at:t[4],invocation_id:t[5],status:t[6],effective:{provider:u[0],model:u[1],reasoning_effort:u[2],service_tier:u[3]},latency_ms:t[8]}}if(t[1]==="c"&&Array.isArray(t[8])&&Array.isArray(t[9])){let u=t[8],_=t[9],p=t[16];return{schema_version:2,type:"model.call.observed",run_id:e,event_id:t[2],sequence:t[3],occurred_at:t[4],call_id:t[5],agent_invocation_id:t[6],coverage:t[7],tokens:{input:u[0],cached_input:u[1],output:u[2],reasoning:u[3],total:u[4],source:u[5],...u[6]===void 0?{}:{cache_write_input:u[6]}},cost:{usd:_[0],brl:_[1],fx_rate:_[2]??null},provider:t[10],model:t[11],source_call_key:t[12],...t[13]===null?{}:{source_occurred_at:t[13]},...t[14]===null||t[14]===void 0?{}:{source_started_at:t[14]},...t[15]===null||t[15]===void 0?{}:{source_finished_at:t[15]},...p===null||!Array.isArray(p)?{}:{runtime:{reasoning_effort:p[0],service_tier:p[1]}}}}if(t[1]!=="u"||!Array.isArray(t[8])||!Array.isArray(t[9]))throw new Error("Invalid Run transport v3 delta");let n=t[8],r=t[9],o=t[15],a=t[16],s=t[17],l=t[18],c=t[19],d=t[20],m=typeof t[21]=="string"?t[21]:null;return{schema_version:2,type:"usage.recorded",run_id:e,event_id:t[2],sequence:t[3],occurred_at:t[4],phase:t[5],activity_kind:t[6],classification_source:t[7],tokens:{input:n[0],cached_input:n[1],output:n[2],reasoning:n[3],total:n[4],source:n[5],...n[6]===void 0?{}:{cache_write_input:n[6]}},cost:{usd:r[0],brl:r[1],fx_rate:r[2]??null},provider:t[10],model:t[11],source_segment_key:t[12],...m==null?{}:{attributed_spec_id:m},...d==null?{}:{model_call_id:d},supersedes_event_id:t[13],...t[14]===null?{}:{source_occurred_at:t[14]},...s==null?{}:{source_started_at:s},...l==null?{}:{source_finished_at:l},...c===!0?{retrospective_correction:!0}:{},...o===null||!Array.isArray(o)?{}:{context_stats:{initial_pack_tokens:o[0],tool_output_tokens:o[1],files_opened:o[2],snippets_opened:o[3]}},...a===null||!Array.isArray(a)?{}:{runtime:{reasoning_effort:a[0],service_tier:a[1]}}}}function Er(t,e,n,r,o){let a=t.native_stop??t.native_terminal;if(!a||r!==null||o!==null||n?.status!=="completed"||t.finished_event_id!==n.event_id||e.parent_run_id!==null||e.agent!=="agent-orchestrator"||e.execution_kind!=="delivery"||t.task_id!==e.task_id||t.change_id!==e.change_id||t.execution_id!==e.execution_id||t.principal.thread_id!==e.client_thread_id||t.principal.turn_id===e.client_turn_id||a.session_id!==e.client_thread_id||a.turn_id!==e.client_turn_id||t.assessor.parent_thread_id!==t.principal.thread_id||Date.parse(t.principal.started_at)<Date.parse(a.finished_at)||t.native_terminal!==void 0&&(t.native_terminal.finished_event_id!==n.event_id||t.authority?.predecessor_run_id!==e.continuation_of_run_id)||Date.parse(t.assessor.started_at)<Date.parse(n.occurred_at)||Date.parse(t.assessor.finished_at)<Date.parse(t.assessor.started_at)||Date.parse(t.occurred_at)<Date.parse(t.assessor.finished_at))throw new Error("Late finalization assessment does not match its stopped root")}function Ee(t){let e=new Map;for(let y of t){let g=ge.parse(y),v=e.get(g.event_id);if(v!==void 0){if(JSON.stringify(v)!==JSON.stringify(g))throw new Error(`Divergent duplicate Run V2 event: ${g.event_id}`);continue}e.set(g.event_id,g)}let n=[...e.values()].sort((y,g)=>y.sequence-g.sequence);if(n.length===0||n[0]?.type!=="run.started")throw new Error("Run V2 stream must start with run.started");let r=n[0],o=r.phase,a=null,s=null,l=null,c=null,d=new Map,m=new Map,u=new Map,_=new Map,p=new Map;for(let[y,g]of n.entries()){if(g.run_id!==r.run_id)throw new Error("Run V2 stream mixes run ids");if(g.sequence!==y+1)throw new Error("Run V2 sequence must be contiguous");let v=d.get(g.sequence);if(v!==void 0&&v!==g.event_id)throw new Error(`Run V2 sequence is duplicated: ${g.sequence}`);if(d.set(g.sequence,g.event_id),y>0&&g.type==="run.started")throw new Error("Run V2 has multiple starts");if(a!==null&&g.type!=="run.finalization.decided"&&g.type!=="run.late_finalization.assessed"&&!Xn(g,a,m))throw new Error("Run V2 contains a non-retrospective record after run.finished");if(g.type==="usage.recorded"){if(De(o,g.phase),g.phase==="execution"&&r.execution_id===null&&r.attribution_status!=="legacy_unattributed")throw new Error("Execution phase requires execution_id");if(g.supersedes_event_id!==null&&!m.has(g.supersedes_event_id))throw new Error(`Superseded usage event must occur earlier: ${g.supersedes_event_id}`);m.set(g.event_id,g),o=g.phase}if(g.type==="run.attribution.recovered"){if(!Zn(r,g))throw new Error("Run attribution recovery does not match its immutable start header");if(c!==null)throw new Error("Run V2 has multiple attribution recoveries");De(o,g.phase),o=g.phase,c=g}if(g.type==="model.selection.recorded"){if(Pt(r,n.slice(0,y),{invocationId:g.invocation_id,requested:g.requested,selection:g.selection}),u.has(g.invocation_id))throw new Error(`Duplicate model selection for invocation: ${g.invocation_id}`);u.set(g.invocation_id,g)}if(g.type==="provider.invocation.finished"){if(!u.has(g.invocation_id))throw new Error(`Provider invocation requires earlier model selection: ${g.invocation_id}`);if(_.has(g.invocation_id))throw new Error(`Duplicate provider terminal for invocation: ${g.invocation_id}`);_.set(g.invocation_id,g)}if(g.type==="model.call.observed"){let b=p.get(g.call_id);if(b!==void 0&&JSON.stringify(b)!==JSON.stringify(g)&&!Qn(b,g))throw new Error(`Divergent duplicate Model Call: ${g.call_id}`);p.set(g.call_id,g)}if(g.type==="run.finalization.decided"){if(s!==null||l!==null)throw new Error("Run V2 has multiple finalization decisions");s=g}if(g.type==="run.late_finalization.assessed"&&(Er(g,r,a,l,s),l=g),g.type==="run.finished"){if(g.phase!==o)throw new Error("run.finished phase must match the latest phase");a=g}}let f=n.filter(y=>y.type==="usage.recorded"),h=new Set(f.map(y=>y.supersedes_event_id).filter(y=>y!==null)),w=xr(f.filter(y=>!h.has(y.event_id)));return{run:c===null?r:{...r,phase:c.phase,execution_id:c.execution_id,task_id:c.task_id,change_id:c.change_id},status:a?.status??"running",finished:a,finalization_decision:s,late_finalization_assessment:l,attribution_recovery:c,records:n,usage_records:f,effective_usage_records:w,model_selection_records:[...u.values()],provider_invocation_records:[..._.values()],model_call_records:[...p.values()]}}var It=class{constructor(e,n,r,o,a){this.filesystem=e;this.path=n;this.started=r;this.clock=o;this.release=a;this.records=[r],this.currentPhase=r.phase}filesystem;path;started;clock;release;records;nextSequence=2;currentPhase;finishedRecord=null;async recordUsage(e){if(this.finishedRecord!==null&&e.retrospectiveCorrection!==!0)throw new Error(`Run is already finished: ${this.started.run_id}`);if(e.retrospectiveCorrection===!0&&(this.finishedRecord===null||e.activityKind!=="retrospective_local_remeasurement"||e.supersedesEventId===void 0||e.supersedesEventId===null||e.phase!==this.finishedRecord.phase))throw new Error("Invalid retrospective usage correction");let n=e.eventId;if(n!==void 0){let o=this.records.find(a=>a.event_id===n);if(o!==void 0){if(o.type!=="usage.recorded")throw new Error(`Event id already belongs to ${o.type}: ${n}`);let a=this.usageRecord(e,o.sequence,o.occurred_at);if(JSON.stringify(a)!==JSON.stringify(o))throw new Error(`Divergent duplicate Run V2 event: ${n}`);return o}}if(e.sourceSegmentKey!==void 0&&e.sourceSegmentKey!==null){let o=this.records.find(a=>a.type==="usage.recorded"&&a.source_segment_key===e.sourceSegmentKey&&a.supersedes_event_id===null);if(o?.type==="usage.recorded"){let a=this.usageRecord(e,o.sequence,o.occurred_at);if(vn(a,o))return o;if(e.supersedesEventId!==o.event_id)throw new Error(`Divergent source segment requires supersession: ${e.sourceSegmentKey}`)}}if(De(this.currentPhase,e.phase),e.phase==="execution"&&this.started.execution_id===null&&this.started.attribution_status!=="legacy_unattributed")throw new Error("Execution phase requires execution_id");if(e.supersedesEventId!==void 0&&e.supersedesEventId!==null&&this.records.find(a=>a.event_id===e.supersedesEventId&&a.type==="usage.recorded")===void 0)throw new Error(`Superseded usage event does not exist: ${e.supersedesEventId}`);let r=this.usageRecord(e,this.nextSequence,e.occurredAt);return await this.append(r),this.records.push(r),this.nextSequence+=1,this.currentPhase=r.phase,r}async recordModelSelection(e){if(this.finishedRecord!==null)throw new Error(`Run is already finished: ${this.started.run_id}`);let n=this.records.find(o=>o.type==="model.selection.recorded"&&o.invocation_id===e.invocationId);if(n?.type==="model.selection.recorded"){if(!Yn(n,e))throw new Error(`Divergent model selection for invocation: ${e.invocationId}`);return n}if(this.records.some(o=>o.type==="provider.invocation.finished"&&o.invocation_id===e.invocationId))throw new Error(`Provider invocation finished before model selection: ${e.invocationId}`);Pt(this.started,this.records,e);let r=ri.parse({schema_version:2,event_id:e.eventId??Z(this.started.run_id,this.nextSequence),run_id:this.started.run_id,sequence:this.nextSequence,occurred_at:e.occurredAt??this.clock.now().toISOString(),type:"model.selection.recorded",invocation_id:e.invocationId,requested:e.requested,selection:e.selection});return await this.append(r),this.records.push(r),this.nextSequence+=1,r}async recordModelCall(e){if(this.finishedRecord!==null)throw new Error(`Run is already finished: ${this.started.run_id}`);let n=this.records.find(o=>o.type==="model.call.observed"&&o.call_id===e.callId);if(n?.type==="model.call.observed"){let o=this.modelCallRecord(e,n.sequence,n.occurred_at);if(JSON.stringify(o)!==JSON.stringify(n))throw new Error(`Divergent duplicate Model Call: ${e.callId}`);return n}let r=this.modelCallRecord(e,this.nextSequence,e.occurredAt);return await this.append(r),this.records.push(r),this.nextSequence+=1,r}async finishProviderInvocation(e){if(this.finishedRecord!==null)throw new Error(`Run is already finished: ${this.started.run_id}`);if(this.records.find(a=>a.type==="model.selection.recorded"&&a.invocation_id===e.invocationId)===void 0)throw new Error(`Provider invocation requires model selection: ${e.invocationId}`);let r=this.records.find(a=>a.type==="provider.invocation.finished"&&a.invocation_id===e.invocationId);if(r?.type==="provider.invocation.finished"){if(!ei(r,e))throw new Error(`Divergent provider terminal for invocation: ${e.invocationId}`);return r}let o=oi.parse({schema_version:2,event_id:e.eventId??Z(this.started.run_id,this.nextSequence),run_id:this.started.run_id,sequence:this.nextSequence,occurred_at:e.occurredAt??this.clock.now().toISOString(),type:"provider.invocation.finished",invocation_id:e.invocationId,status:e.status,effective:e.effective,latency_ms:e.latencyMs});return await this.append(o),this.records.push(o),this.nextSequence+=1,o}async finish(e,n=this.clock.now().toISOString()){if(this.finishedRecord!==null){if(this.finishedRecord.status!==e)throw new Error(`Run already finished as ${this.finishedRecord.status}`);return this.finishedRecord}let r=ai.parse({schema_version:2,event_id:Z(this.started.run_id,this.nextSequence),run_id:this.started.run_id,sequence:this.nextSequence,occurred_at:n,type:"run.finished",phase:this.currentPhase,status:e,duration_ms:null,duration_provenance:null});return await this.append(r),this.records.push(r),this.finishedRecord=r,this.nextSequence+=1,this.release(),r}usageRecord(e,n,r){return ni.parse({schema_version:2,event_id:e.eventId??Z(this.started.run_id,n),run_id:this.started.run_id,sequence:n,occurred_at:e.occurredAt??r??this.clock.now().toISOString(),type:"usage.recorded",phase:e.phase,activity_kind:e.activityKind,classification_source:e.classificationSource,tokens:e.tokens,cost:e.cost,provider:e.provider,model:e.model,source_segment_key:e.sourceSegmentKey??null,...e.attributedSpecId===void 0?{}:{attributed_spec_id:e.attributedSpecId},...e.modelCallId===void 0?{}:{model_call_id:e.modelCallId},supersedes_event_id:e.supersedesEventId??null,...e.retrospectiveCorrection===!0?{retrospective_correction:!0}:{},...e.sourceOccurredAt===void 0?{}:{source_occurred_at:e.sourceOccurredAt},...e.sourceStartedAt===void 0?{}:{source_started_at:e.sourceStartedAt},...e.sourceFinishedAt===void 0?{}:{source_finished_at:e.sourceFinishedAt},...e.contextStats===void 0?{}:{context_stats:e.contextStats},...e.runtime===void 0?{}:{runtime:e.runtime}})}modelCallRecord(e,n,r){return ii.parse({schema_version:2,event_id:e.eventId??Z(this.started.run_id,n),run_id:this.started.run_id,sequence:n,occurred_at:e.occurredAt??r??this.clock.now().toISOString(),type:"model.call.observed",call_id:e.callId,agent_invocation_id:e.agentInvocationId,coverage:e.coverage,tokens:e.tokens,cost:e.cost,provider:e.provider,model:e.model,source_call_key:e.sourceCallKey??null,...e.sourceOccurredAt===void 0?{}:{source_occurred_at:e.sourceOccurredAt},...e.sourceStartedAt===void 0?{}:{source_started_at:e.sourceStartedAt},...e.sourceFinishedAt===void 0?{}:{source_finished_at:e.sourceFinishedAt},...e.runtime===void 0?{}:{runtime:e.runtime}})}async append(e){await this.filesystem.appendText(this.path,Ce(e))}};function Ge(t){return kr(t,Sr)}var qt=i.string().datetime({offset:!0}),ws=i.preprocess(t=>t==="client"?"provider_reported":t,i.enum(["provider_reported","estimated","unavailable"])),qm=i.object({id:i.string().regex(/^DEC-(?:HUMAN|AI)-/),title:i.string().min(1),origin:i.enum(["human","agent"]),category:i.enum(["architecture","contract","database","security","dependency","network","infrastructure","cost","implementation"]),status:i.enum(["active","superseded","rejected"]),task:i.string().startsWith("TASK-").nullable(),change:i.string().startsWith("CHG-").nullable(),context:i.string().min(1),decision:i.string().min(1),reason:i.string().min(1),alternatives:i.array(i.string()),consequences:i.array(i.string()),reversible:i.boolean(),rollback:i.string(),confidence:i.number().min(0).max(1).nullable(),created_at:qt,confirmed_at:qt.nullable()}).strict();var $m=i.object({id:i.string().startsWith("RUN-"),task:i.string().startsWith("TASK-"),status:i.enum(["running","completed","failed"]),client:i.string().min(1),agent:i.string().min(1),model:i.string().min(1),started_at:qt,finished_at:qt.nullable(),duration_ms:i.number().int().nonnegative().nullable(),provider:i.string().min(1).nullable().default(null),token_usage:i.object({input:i.number().int().nonnegative().nullable(),cached_input:i.number().int().nonnegative().nullable().default(null),output:i.number().int().nonnegative().nullable(),reasoning:i.number().int().nonnegative().nullable(),total:i.number().int().nonnegative().nullable().default(null),source:ws}),cost:i.object({estimated_usd:i.number().nonnegative().nullable(),estimated_brl:i.number().nonnegative().nullable(),fx_rate:i.number().positive().nullable(),pricing_model:i.string().nullable(),pricing_source:i.string().nullable(),input_usd:i.number().nonnegative().nullable().default(null),cached_input_usd:i.number().nonnegative().nullable().default(null),output_usd:i.number().nonnegative().nullable().default(null),reasoning_usd:i.number().nonnegative().nullable().default(null)}).default({estimated_usd:null,estimated_brl:null,fx_rate:null,pricing_model:null,pricing_source:null,input_usd:null,cached_input_usd:null,output_usd:null,reasoning_usd:null}),telemetry:i.object({cycle_count:i.number().int().nonnegative().nullable(),source:i.enum(["repository","local-codex","manual","unavailable"]),segment_key:i.string().nullable()}).default({cycle_count:null,source:"unavailable",segment_key:null}),commands:i.array(i.string()),gates:i.array(i.string()),decisions:i.array(i.string()),evidence:i.array(i.string())}).strict();var wn=["objective","requirement_ids","acceptance_ids","write_scopes"],Fm={simple:{level:"simple",requiredFields:[...wn,"verification"],optionalFields:["risk_notes","rollback"],maximumUnresolvedQuestions:0},standard:{level:"standard",requiredFields:[...wn,"included_scope","excluded_scope","design","risks","verification","rollback"],optionalFields:["rollout","open_questions"],maximumUnresolvedQuestions:2},complex:{level:"complex",requiredFields:[...wn,"problem","outcomes","included_scope","excluded_scope","architecture","security","dag","budgets","risks","rollout","rollback","verification","independent_reviewer"],optionalFields:["open_questions"],maximumUnresolvedQuestions:3}};var $t=i.enum(["test","eval","check","review","spec_review","quality_review","mutation","integration","cross_spec_e2e"]),Cr=i.object({schema_version:i.literal(2),assurance_version:i.literal(1),profile:i.enum(["task-lite","task-standard-2","task-standard-3","task-critical"]),risk:i.enum(["lite","standard","critical"]),minimum_validation_artifacts:i.number().int().positive(),maximum_validation_artifacts:i.number().int().positive().nullable(),minimum_evidence_artifacts:i.number().int().positive(),maximum_evidence_artifacts:i.number().int().positive().nullable(),minimum_distinct_modalities:i.number().int().positive(),complete_acceptance_coverage:i.literal(!0),evidence_per_acceptance:i.boolean(),requires_independent_verifier:i.boolean(),requires_mutation_discrimination:i.boolean(),minimum_mutation_kill_ratio:i.number().min(0).max(1).nullable(),requires_rollback:i.boolean(),requires_final_commit_evidence:i.boolean(),requires_test:i.boolean(),required_modalities:i.array($t)}).strict().superRefine((t,e)=>{t.maximum_validation_artifacts!==null&&t.maximum_validation_artifacts<t.minimum_validation_artifacts&&e.addIssue({code:"custom",path:["maximum_validation_artifacts"],message:"maximum validation artifacts cannot be lower than the minimum"}),t.maximum_evidence_artifacts!==null&&t.maximum_evidence_artifacts<t.minimum_evidence_artifacts&&e.addIssue({code:"custom",path:["maximum_evidence_artifacts"],message:"maximum Evidence artifacts cannot be lower than the minimum"})});var Jm=i.object({schema_version:i.literal(2),assurance_version:i.literal(1),profile:i.enum(["spec-delivery","prd-delivery"]),origin:i.enum(["spec","prd"]),minimum_parent_validation_artifacts:i.number().int().positive(),minimum_parent_evidence_artifacts:i.number().int().positive(),minimum_distinct_modalities:i.number().int().positive(),complete_acceptance_coverage:i.literal(!0),requires_acceptance_matrix:i.literal(!0),requires_independent_verifier:i.literal(!0),integration_modality:i.enum(["integration","cross_spec_e2e"]),evidence_per_acceptance:i.boolean(),evidence_per_outcome:i.boolean(),requires_mutation_discrimination:i.boolean(),minimum_mutation_kill_ratio:i.number().min(0).max(1).nullable(),requires_rollback:i.boolean(),requires_final_commit_evidence:i.boolean(),required_modalities:i.array($t).min(3)}).strict();function L(t){return i.array(t).superRefine((e,n)=>{let r=new Set;for(let[o,a]of e.entries())r.has(a)&&n.addIssue({code:"custom",path:[o],message:`duplicate value: ${a}`}),r.add(a)})}var Tr=i.string().datetime({offset:!0}),bs=L(i.string().startsWith("AC-")).min(1),xs=i.enum(["confirmed","limited","pending","failed","not_applicable"]),ks=i.enum(["visual","interaction","api","database_schema","persistence","logs","integration"]),Ss=i.string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/),Es=i.object({schema_version:i.literal(1),id:i.string().regex(/^OBS-[A-Z0-9]+(?:-[A-Z0-9]+)*$/),task_id:i.string().startsWith("TASK-"),change_id:i.string().startsWith("CHG-"),execution_id:i.string().startsWith("EXEC-"),run_id:i.string().startsWith("RUN-"),acceptance_ids:bs,proof_kind:ks,state:xs,scenario:i.string().min(1).nullable(),expected:i.string().min(1).nullable(),observed:i.string().min(1).nullable(),observed_at:Tr,examiner_id:i.string().min(1),commit_sha:Ss.nullable(),candidate_version:i.string().min(1).nullable(),environment:i.object({class:i.string().min(1).nullable(),id:i.string().min(1).nullable(),version:i.string().min(1).nullable()}).strict(),visual:i.object({url:i.string().url(),viewport:i.string().regex(/^\d{2,5}x\d{2,5}$/),captured_at:Tr,loaded_version:i.string().min(1),examination:i.string().min(1)}).strict().nullable(),correlation_ids:L(i.string().min(1)).default([]),locators:L(i.string().min(1)).default([]),limitations:i.string().min(1).nullable(),not_applicable_reason:i.string().min(1).nullable(),pending_reason:i.string().min(1).nullable(),dependency:i.string().min(1).nullable(),resume_plan:i.string().min(1).nullable(),attempts:i.array(i.object({kind:i.enum(["initial","retry","alternative"]),recovery_action:i.string().min(1).nullable(),alternative_available:i.boolean().nullable()}).strict()).max(3)}).strict().superRefine((t,e)=>{let n=t.attempts.map(r=>r.kind);new Set(n).size!==n.length&&e.addIssue({code:"custom",path:["attempts"],message:"observations allow each attempt kind at most once"}),t.state!=="pending"&&t.state!=="not_applicable"&&n[0]!=="initial"&&e.addIssue({code:"custom",path:["attempts"],message:"settled observations require an initial attempt"}),n.join(",")!==[...n].sort(Cs).join(",")&&e.addIssue({code:"custom",path:["attempts"],message:"observation attempts must be initial, retry, then alternative"});for(let[r,o]of t.attempts.entries())o.kind==="retry"&&(r===0||o.recovery_action===null)&&e.addIssue({code:"custom",path:["attempts",r],message:"retry observations require a preceding initial attempt and recovery_action"}),o.kind==="alternative"&&o.alternative_available!==!0&&e.addIssue({code:"custom",path:["attempts",r,"alternative_available"],message:"alternative observations require an available permitted mechanism"});if(t.state==="not_applicable"&&t.not_applicable_reason===null&&e.addIssue({code:"custom",path:["not_applicable_reason"],message:"not_applicable observations require a reason"}),t.state!=="not_applicable"&&t.not_applicable_reason!==null&&e.addIssue({code:"custom",path:["not_applicable_reason"],message:"applicable observations cannot retain a not-applicable reason"}),t.proof_kind!=="visual"&&t.visual!==null&&e.addIssue({code:"custom",path:["visual"],message:"only visual observations may include visual metadata"}),t.proof_kind==="visual"&&t.state==="confirmed"&&t.visual===null&&e.addIssue({code:"custom",path:["visual"],message:"confirmed visual observations require visual examination metadata"}),t.visual!==null){let r;try{r=new URL(t.visual.url)}catch{e.addIssue({code:"custom",path:["visual","url"],message:"visual URL must be a sanitized http(s) URL"});return}(r.protocol!=="http:"&&r.protocol!=="https:"||r.username||r.password||r.search||r.hash)&&e.addIssue({code:"custom",path:["visual","url"],message:"visual URL must be http(s) without credentials or query"})}t.state==="confirmed"&&t.locators.length===0&&e.addIssue({code:"custom",path:["locators"],message:"confirmed observations require locators"}),t.state==="confirmed"&&(t.candidate_version===null||t.environment.version===null)&&e.addIssue({code:"custom",path:["candidate_version"],message:"confirmed observations require observed candidate and environment versions"}),t.state==="confirmed"&&t.proof_kind==="integration"&&t.correlation_ids.length===0&&e.addIssue({code:"custom",path:["correlation_ids"],message:"confirmed integration observations require scenario correlation"}),t.state==="limited"&&t.limitations===null&&e.addIssue({code:"custom",path:["limitations"],message:"limited observations require a limitation"}),t.state==="pending"&&(t.pending_reason===null||t.dependency===null||t.resume_plan===null)&&e.addIssue({code:"custom",path:["pending_reason"],message:"pending observations require reason, dependency, and resume plan"}),t.state!=="pending"&&t.commit_sha===null&&e.addIssue({code:"custom",path:["commit_sha"],message:"settled observations require candidate commit"}),t.state!=="pending"&&(t.environment.class===null||t.environment.id===null)&&e.addIssue({code:"custom",path:["environment"],message:"settled observations require an identified environment"}),t.state!=="pending"&&(t.scenario===null||t.expected===null||t.observed===null)&&e.addIssue({code:"custom",message:"settled observations require scenario, expected, and observed"}),t.proof_kind==="visual"&&t.state==="confirmed"&&(t.candidate_version===null||t.visual===null||t.visual.loaded_version!==t.candidate_version)&&e.addIssue({code:"custom",path:["candidate_version"],message:"confirmed visual observations require candidate and loaded versions to agree"})});function Cs(t,e){return{initial:0,retry:1,alternative:2}[t]-{initial:0,retry:1,alternative:2}[e]}var Vt=i.string().datetime({offset:!0}),Qe=i.string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/).nullable(),Rr=L(i.string().startsWith("AC-")).min(1),Ts=i.object({kind:i.literal("isolated_git_worktree"),protocol:i.literal("committed_node_harness_v1").optional(),harness_path:i.string().min(1).optional(),harness_blob_sha:Qe.unwrap().optional(),commit_sha:Qe.unwrap(),tree_sha:Qe.unwrap(),exit_code:i.number().int().min(-1),diagnostic:i.string().nullable().optional(),started_at:Vt,finished_at:Vt}).strict(),bn={test:"TEST-",eval:"EVAL-",check:"CHECK-",review:"REVIEW-",spec_review:"REVIEW-SPEC-",quality_review:"REVIEW-QUALITY-",mutation:"MUT-",integration:"INT-",cross_spec_e2e:"E2E-"},Rs=i.object({schema_version:i.literal(2),id:i.string().min(1),kind:$t,task_id:i.string().startsWith("TASK-"),change_id:i.string().startsWith("CHG-"),execution_id:i.string().startsWith("EXEC-"),run_id:i.string().startsWith("RUN-"),acceptance_ids:Rr,executed_at:Vt,command:i.string().min(1).nullable(),status:i.enum(["passed","failed","not_applicable"]),asserted_outcomes:L(i.string().min(1)).min(1),locators:L(i.string().min(1)).min(1),author_id:i.string().min(1),commit_sha:Qe,candidate_execution:Ts.nullable().optional(),not_applicable_reason:i.string().min(1).nullable()}).strict().superRefine((t,e)=>{t.id.startsWith(bn[t.kind])||e.addIssue({code:"custom",path:["id"],message:`${t.kind} validation id must start with ${bn[t.kind]}`}),!Ar(t.kind)&&t.command===null&&e.addIssue({code:"custom",path:["command"],message:`${t.kind} validation requires its executed command`}),Ot(t.status,t.not_applicable_reason,e),t.candidate_execution!==null&&t.candidate_execution!==void 0&&(Date.parse(t.candidate_execution.finished_at)<Date.parse(t.candidate_execution.started_at)&&e.addIssue({code:"custom",path:["candidate_execution","finished_at"],message:"isolated validation cannot finish before it starts"}),t.commit_sha!==t.candidate_execution.commit_sha&&e.addIssue({code:"custom",path:["candidate_execution","commit_sha"],message:"isolated candidate execution must match validation commit"}),t.status==="passed"&&t.candidate_execution.exit_code!==0&&e.addIssue({code:"custom",path:["status"],message:"a non-zero isolated candidate exit code cannot pass validation"}))}),As=i.object({schema_version:i.literal(2),id:i.string().startsWith("EVD-"),task_id:i.string().startsWith("TASK-"),change_id:i.string().startsWith("CHG-"),execution_id:i.string().startsWith("EXEC-"),run_id:i.string().startsWith("RUN-"),acceptance_ids:Rr,outcome_ids:L(i.string().startsWith("OUT-")).default([]),validation_artifact_ids:L(i.string().min(1)).min(1),observed_at:Vt,status:i.enum(["passed","not_applicable"]),summary:i.string().min(1),locators:L(i.string().min(1)).min(1),commit_sha:Qe,not_applicable_reason:i.string().min(1).nullable()}).strict().superRefine((t,e)=>{Ot(t.status,t.not_applicable_reason,e)}),n_=i.object({...Rs.shape,schema_version:i.literal(3),scope:i.literal("spec_execution"),spec_id:i.string().startsWith("SPEC-"),task_id:i.never().optional(),change_id:i.never().optional()}).strict().superRefine((t,e)=>{t.id.startsWith(bn[t.kind])||e.addIssue({code:"custom",path:["id"],message:"invalid validation prefix"}),!Ar(t.kind)&&t.command===null&&e.addIssue({code:"custom",path:["command"],message:"validation requires command"}),Ot(t.status,t.not_applicable_reason,e),t.candidate_execution!==null&&t.candidate_execution!==void 0&&(t.candidate_execution.protocol!=="committed_node_harness_v1"&&e.addIssue({code:"custom",path:["candidate_execution","protocol"],message:"parental candidate requires committed Node harness protocol"}),t.candidate_execution.commit_sha!==t.commit_sha&&e.addIssue({code:"custom",path:["candidate_execution","commit_sha"],message:"candidate execution SHA must match parental Validation"}),Date.parse(t.candidate_execution.finished_at)<Date.parse(t.candidate_execution.started_at)&&e.addIssue({code:"custom",path:["candidate_execution","finished_at"],message:"candidate execution cannot finish before start"}),t.status==="passed"&&t.candidate_execution.exit_code!==0&&e.addIssue({code:"custom",path:["status"],message:"nonzero candidate exit cannot pass"}))}),i_=i.object({...As.shape,schema_version:i.literal(3),scope:i.literal("spec_execution"),spec_id:i.string().startsWith("SPEC-"),task_id:i.never().optional(),change_id:i.never().optional()}).strict().superRefine((t,e)=>{Ot(t.status,t.not_applicable_reason,e)});function Ot(t,e,n){t==="not_applicable"&&e===null&&n.addIssue({code:"custom",path:["not_applicable_reason"],message:"not-applicable artifacts require a reason"}),t!=="not_applicable"&&e!==null&&n.addIssue({code:"custom",path:["not_applicable_reason"],message:"applicable artifacts cannot retain a not-applicable reason"})}function Ar(t){return t==="review"||t==="spec_review"||t==="quality_review"}var xn=i.string().regex(/^[a-f0-9]{64}$/),Is=i.object({acceptance_id:i.string().regex(/^AC-[A-Z0-9-]+$/),basis:i.enum(["behavior","normative"]),modalities:i.array(i.enum(["test","check","quality_review","mutation"])).min(1),reason:i.string().trim().min(20),observable_basis:i.string().trim().min(8)}).strict(),l_=i.object({schema_version:i.literal(1),task_id:i.string().regex(/^TASK-[A-Z0-9-]+$/),change_id:i.string().regex(/^CHG-[A-Z0-9-]+$/),execution_id:i.string().regex(/^EXEC-[A-Z0-9-]+$/),attempt_count:i.number().int().positive(),plan_revision:i.number().int().positive(),plan_hash:xn,authorization:i.object({human_decision_id:i.string().regex(/^DEC-HUMAN-[A-Z0-9-]+$/),human_decision_sha256:xn,classification_decision_id:i.string().regex(/^DEC-AI-[A-Z0-9-]+$/),classification_decision_sha256:xn}).strict(),criteria:i.array(Is).min(1)}).strict();function Ir(t,e,n={decisions:[],evidence:[],evals:[],tests:[]},r={}){let o={draft:"Ainda n\xE3o iniciada.",planned:"Aguardando execu\xE7\xE3o.",executing:"Em execu\xE7\xE3o.",verifying:"Em verifica\xE7\xE3o.",completed:"Conclu\xEDda.",failed:"Falhou.",blocked:"Bloqueada.",cancelled:"Cancelada."}[t.status],a=t.result??t.status_reason??`Status can\xF4nico: ${t.status}.`,s=(m,u,_)=>m.replace(new RegExp(`(## ${u}\\n\\n)([\\s\\S]*?)(?=\\n\\n## |$)`),(p,f)=>`${f}${_}`),l=(m,u,_,p)=>m.replace(new RegExp(`(## ${u}\\n\\n)${Ps(_)}(?=\\n\\n## |$)`),(f,h)=>`${h}${p}`),c=(m,u,_,p)=>m.replace(new RegExp(`(## ${u}\\n\\n)([\\s\\S]*?)(?=\\n\\n## |$)`),(f,h,w)=>{let y="Refer\xEAncias registradas (status no artefato):",g=w.startsWith(`${y}
|
|
29
|
+
`)&&w.slice(y.length+1).split(`
|
|
30
|
+
`).every(v=>/^- `[^`]+`$/.test(v));return w!==_&&!g?f:`${h}${p.length===0?_:`${y}
|
|
31
|
+
${p.map(v=>`- \`${v}\``).join(`
|
|
32
|
+
`)}`}`}),d=e;["draft","planned"].includes(t.status)||(d=l(d,"Plano","Plano preparado e aguardando execu\xE7\xE3o.",`Plano materializado; estado atual: ${t.status}.`));for(let[m,u,_]of[["Decis\xF5es","Nenhuma decis\xE3o registrada.",n.decisions],["Evid\xEAncias","Nenhuma evid\xEAncia registrada.",n.evidence],["Evals","Ainda n\xE3o executados.",n.evals],["Testes","Ainda n\xE3o executados.",n.tests]])d=c(d,m,u,_);if(r.preserveManual){let m=(u,_,p,f)=>u.replace(new RegExp(`(## ${_}\\n\\n)([\\s\\S]*?)(?=\\n\\n## |$)`),(h,w,y)=>f.test(y.trimEnd())?`${w}${p}${y.slice(y.trimEnd().length)}`:h);return d=m(d,"Implementa\xE7\xE3o",o,/^(?:Ainda não iniciada\.|Ainda não executada\.|Aguardando execução\.|Em execução\.|Em verificação\.|Concluída\.|Falhou\.|Bloqueada\.|Cancelada\.)$/),m(d,"Resultado",a,/^(?:Aguardando execução\.|Ainda não concluída\.|Status canônico: [a-z_]+\.)$/)}return s(s(d,"Implementa\xE7\xE3o",o),"Resultado",a)}function Ps(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Nt(t){return`# ${t}
|
|
33
|
+
|
|
34
|
+
## Plano
|
|
35
|
+
|
|
36
|
+
Plano preparado e aguardando execu\xE7\xE3o.
|
|
37
|
+
|
|
38
|
+
## Implementa\xE7\xE3o
|
|
39
|
+
|
|
40
|
+
Ainda n\xE3o executada.
|
|
41
|
+
|
|
42
|
+
## Decis\xF5es
|
|
43
|
+
|
|
44
|
+
Nenhuma decis\xE3o registrada.
|
|
45
|
+
|
|
46
|
+
## Evid\xEAncias
|
|
47
|
+
|
|
48
|
+
Nenhuma evid\xEAncia registrada.
|
|
49
|
+
|
|
50
|
+
## Evals
|
|
51
|
+
|
|
52
|
+
Ainda n\xE3o executados.
|
|
53
|
+
|
|
54
|
+
## Testes
|
|
55
|
+
|
|
56
|
+
Ainda n\xE3o executados.
|
|
57
|
+
|
|
58
|
+
## Resultado
|
|
59
|
+
|
|
60
|
+
Aguardando execu\xE7\xE3o.`}function Pr(t){return`# ${t.title}
|
|
61
|
+
|
|
62
|
+
## Problema
|
|
63
|
+
|
|
64
|
+
${t.problem}
|
|
65
|
+
|
|
66
|
+
## Outcomes
|
|
67
|
+
|
|
68
|
+
${Xe(t.outcomes)}
|
|
69
|
+
|
|
70
|
+
## Restri\xE7\xF5es
|
|
71
|
+
|
|
72
|
+
${Xe(t.constraints)}
|
|
73
|
+
|
|
74
|
+
## Fora de escopo
|
|
75
|
+
|
|
76
|
+
${Xe(t.non_goals)}`}function qr(t){let e=t.implementation,n=e===null?"N\xE3o resolvida. Consulte `stack` e `stack.overrides` em `.agents/config/project.yaml` antes de preparar esta SPEC.":`Profile: ${e.stack_profile}
|
|
77
|
+
|
|
78
|
+
${e.stack_description}
|
|
79
|
+
|
|
80
|
+
${e.stack_components.map(r=>`- ${r.kind}: ${r.name} ${r.version} (${r.version_source})`).join(`
|
|
81
|
+
`)}`;return`# ${t.title}
|
|
82
|
+
|
|
83
|
+
## Objetivo
|
|
84
|
+
|
|
85
|
+
${t.objective}
|
|
86
|
+
|
|
87
|
+
## Escopo
|
|
88
|
+
|
|
89
|
+
${Xe(t.included_scope)}
|
|
90
|
+
|
|
91
|
+
## Fora de escopo
|
|
92
|
+
|
|
93
|
+
${Xe(t.excluded_scope)}
|
|
94
|
+
|
|
95
|
+
## Stack de implementa\xE7\xE3o
|
|
96
|
+
|
|
97
|
+
${n}`}function Xe(t){return t.length===0?"Nenhum.":t.map(e=>`- ${e}`).join(`
|
|
98
|
+
`)}async function $r(t,e,n,r,o={}){let a=e.slice(0,e.lastIndexOf("/")),s=await Promise.all([t.listFiles(`${a}/decisions`,".md"),t.listFiles(`${a}/artifacts/evidence`,".md"),t.listFiles(`${a}/artifacts/evals`),t.listFiles(`${a}/artifacts/tests`)]),l={decisions:s[0].map(c=>c.slice(a.length+1)),evidence:s[1].map(c=>c.slice(a.length+1)),evals:s[2].map(c=>c.slice(a.length+1)),tests:s[3].map(c=>c.slice(a.length+1))};return Ir(n,r,l,o)}function kn(t,e){return t.id===e.id&&t.title===e.title&&t.risk===e.risk&&JSON.stringify(t.source)===JSON.stringify(e.source)&&t.requirement_ids.every(n=>e.requirement_ids.includes(n))&&t.acceptance_ids.every(n=>e.acceptance_ids.includes(n))&&t.task_ids.every(n=>e.task_ids.includes(n))}function Vr(t,e){return t.status==="planned"&&kn(t,e)&&t.plan_revision===e.plan_revision&&t.plan_hash===e.plan_hash&&JSON.stringify(t.requirement_impact)===JSON.stringify(e.requirement_impact)}function Sn(t,e,n,r){let o=new Intl.DateTimeFormat("en-CA",{timeZone:r,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(n.now()),a=s=>{let l=o.find(c=>c.type===s)?.value;if(l===void 0)throw new Error(`Unable to format ID date part: ${s}`);return l};return[t,a("year"),a("month"),a("day"),a("hour"),a("minute"),Jn(e),Bn()].join("-")}async function Te(t,e,n,r){let o=await ce(t,e,n,r);if(o===null)throw new Error(`${n} not found: ${r}`);return o}var Or={draft:["ready","blocked","failed","cancelled"],ready:["active","blocked","failed","cancelled"],active:["delivered","blocked","failed","cancelled"],blocked:["active","failed","cancelled"],delivered:[],failed:[],cancelled:[]},Nr={draft:["ready","blocked","failed","cancelled"],ready:["active","blocked","failed","cancelled"],active:["delivered","blocked","failed","cancelled"],blocked:["active","failed","cancelled"],delivered:[],failed:[],cancelled:[]},Dr={draft:["planned","blocked","cancelled"],planned:["executing","blocked","failed","cancelled"],executing:["verifying","failed","blocked","cancelled"],verifying:["completed","failed","blocked","cancelled"],blocked:["executing","cancelled"],completed:[],failed:["executing"],cancelled:[]},En={planned:["running","blocked","failed","cancelled"],running:["paused","verifying","failed","blocked","cancelled"],paused:["running","cancelled"],verifying:["completed","failed","blocked","cancelled"],blocked:["running","cancelled"],completed:[],failed:["running"],cancelled:[]};function pe(t,e,n,r){if(!t[e].includes(n))throw new Error(`Invalid ${r} transition: ${e} -> ${n}`)}import{createHash as qs}from"node:crypto";var k=class extends Error{name="ExecutionClientTurnConflictError"};function Cn(t){return O.parse({schema_version:2,id:t.id,revision:1,kind:"interaction",client_turn_id:t.clientTurnId,origin:t.origin,status:"running",status_reason:null,plan_revision:null,plan_hash:null,policy:Fe.parse(t.policy),dag:{nodes:[],topological_order:[]},created_at:t.now,updated_at:t.now,started_at:t.now,finished_at:null,result:null})}function Tn(t){return O.parse({schema_version:2,id:t.id,revision:1,kind:"delivery",client_turn_id:t.clientTurnId,origin:t.origin,status:"planned",status_reason:null,plan_revision:null,plan_hash:null,policy:Fe.parse(t.policy),dag:{nodes:[],topological_order:[]},created_at:t.now,updated_at:t.now,started_at:null,finished_at:null,result:null})}function V(t){let e;try{e=JSON.parse(t)}catch{throw new k("Invalid persisted client turn claim")}if(e.schema_version===9){let n=e.origin;if(typeof e.client_turn_id!="string"||typeof e.interaction_execution_id!="string"||typeof e.execution_id!="string"||e.kind!=="delivery"||!n||n.type!=="task"||typeof n.task_id!="string"||!n.task_id.startsWith("TASK-")||typeof e.predecessor_run_id!="string"||typeof e.successor_run_id!="string"||!/^[a-f0-9]{64}$/.test(String(e.authorization_sha256??"")))throw new k("Invalid persisted conversation handoff");return e}if(e.schema_version===7||e.schema_version===8){let n=e.steps;if(typeof e.client_turn_id!="string"||typeof e.maintenance_run_id!="string"||typeof e.maintenance_execution_id!="string"||e.kind!=="delivery"||!Array.isArray(n)||n.length===0||n.some((r,o)=>{if(r===null||typeof r!="object")return!0;let a=r,s=a.origin;return typeof a.execution_id!="string"||typeof a.predecessor_run_id!="string"||typeof a.successor_run_id!="string"||typeof a.target_task_id!="string"||!/^[a-f0-9]{64}$/.test(String(a.authorization_sha256??""))||s===null||typeof s!="object"||!(s.type==="task"&&s.task_id===a.target_task_id||s.type==="spec"&&typeof s.spec_id=="string")||(o===0?a.predecessor_run_id!==e.maintenance_run_id:a.predecessor_run_id!==n[o-1].successor_run_id)})||new Set(n.map(r=>r.target_task_id)).size!==n.length||new Set(n.map(r=>r.successor_run_id)).size!==n.length)throw new k("Invalid persisted post-publication sequence");return e}if((e.schema_version===4||e.schema_version===6)&&typeof e.client_turn_id=="string"&&typeof e.execution_id=="string"&&e.kind==="delivery"&&typeof e.origin=="object"&&e.origin!==null&&zr(e,4)&&typeof e.predecessor_run_id=="string"&&typeof e.successor_run_id=="string"&&typeof e.target_task_id=="string"&&typeof e.authorization_sha256=="string"&&/^[a-f0-9]{64}$/.test(e.authorization_sha256)||(e.schema_version===3||e.schema_version===5)&&typeof e.client_turn_id=="string"&&typeof e.maintenance_execution_id=="string"&&typeof e.execution_id=="string"&&e.kind==="delivery"&&typeof e.origin=="object"&&e.origin!==null&&zr(e,3)&&typeof e.predecessor_run_id=="string"&&typeof e.successor_run_id=="string"&&typeof e.target_task_id=="string"&&typeof e.authorization_sha256=="string"&&/^[a-f0-9]{64}$/.test(e.authorization_sha256)||e.schema_version===2&&typeof e.client_turn_id=="string"&&typeof e.interaction_execution_id=="string"&&typeof e.execution_id=="string"&&e.kind==="delivery"&&typeof e.origin=="object"&&e.origin!==null&&e.origin.type==="spec"&&typeof e.origin.spec_id=="string"&&typeof e.predecessor_run_id=="string"&&typeof e.successor_run_id=="string"&&typeof e.authorization_sha256=="string"&&/^[a-f0-9]{64}$/.test(e.authorization_sha256))return e;if(e.schema_version!==1||typeof e.client_turn_id!="string"||typeof e.execution_id!="string"||e.kind!=="interaction"&&e.kind!=="delivery"||typeof e.origin!="object"||e.origin===null)throw new k("Invalid persisted client turn claim");return{schema_version:1,client_turn_id:e.client_turn_id,execution_id:e.execution_id,kind:e.kind,origin:e.origin}}function Ye(t){return t instanceof Error&&"code"in t&&t.code==="EEXIST"}function zr(t,e){let n=t.origin;return t.schema_version===e?n.type==="spec"&&typeof n.spec_id=="string":n.type==="task"&&typeof n.task_id=="string"&&n.task_id.startsWith("TASK-")&&n.task_id===t.target_task_id}async function Mr(t,e,n){let r=V(await t.readText(e)),o={schema_version:9,kind:"delivery",...n};if(r.schema_version===9){if(JSON.stringify(r)!==JSON.stringify(o))throw new k("Conversation handoff conflicts with target or authorization");return r}if(r.schema_version!==1||r.kind!=="interaction"||r.execution_id!==n.interaction_execution_id||r.client_turn_id!==n.client_turn_id||r.origin.type!=="interaction")throw new k("Conversation handoff requires its original interaction claim");return await t.writeTextAtomic(e,`${JSON.stringify(o)}
|
|
99
|
+
`),o}async function Fr(t,e,n){if(!await t.exists(e))return null;let r=V(await t.readText(e));if(r.client_turn_id!==n)throw new k("Persisted client turn claim has another identity");return r.schema_version===9?r:null}async function Lr(t,e,n){let r;try{r=await t.readText(e)}catch(s){if(s instanceof Error&&"code"in s&&s.code==="ENOENT")return null;throw s}let o=V(r);if(o.client_turn_id!==n)throw new k("Persisted client turn claim has another identity");if(o.schema_version===7||o.schema_version===8)return o;if(![3,4,5,6].includes(o.schema_version))return null;let a=o;return{schema_version:a.schema_version===3||a.schema_version===5?7:8,client_turn_id:a.client_turn_id,maintenance_run_id:a.predecessor_run_id,maintenance_execution_id:"maintenance_execution_id"in a?a.maintenance_execution_id:"",kind:"delivery",steps:[{execution_id:a.execution_id,origin:a.origin,predecessor_run_id:a.predecessor_run_id,successor_run_id:a.successor_run_id,target_task_id:a.target_task_id,authorization_sha256:a.authorization_sha256}]}}async function jr(t,e,n,r){let o=null;try{o=V(await t.readText(e))}catch(u){if(!(u instanceof Error&&"code"in u&&u.code==="ENOENT"))throw u}let a=r.sameTurn?7:8,s={execution_id:r.executionId,origin:r.specId===null?{type:"task",task_id:r.targetTaskId}:{type:"spec",spec_id:r.specId},predecessor_run_id:r.predecessorRunId,successor_run_id:r.proposedSuccessorRunId,target_task_id:r.targetTaskId,authorization_sha256:r.authorizationSha256};if(o?.client_turn_id!==void 0&&o.client_turn_id!==r.clientTurnId)throw new k("Persisted client turn claim has another identity");if(o?.schema_version===1&&(!r.sameTurn||o.kind!=="delivery"||o.execution_id!==r.maintenanceExecutionId||o.origin.type!=="task"))throw new k("Sequence requires the maintenance delivery claim");if(o===null&&r.sameTurn)throw new k("Sequence requires the maintenance delivery claim");if(o!==null&&o.schema_version===2)throw new k("SPEC handoff cannot become a publication sequence");let l=await n(r.clientTurnId);if(l!==null&&(l.schema_version!==a||l.maintenance_run_id!==r.maintenanceRunId||l.maintenance_execution_id!==""&&l.maintenance_execution_id!==r.maintenanceExecutionId))throw new k("Sequence has another maintenance authority");let c=l?.steps.find(u=>u.target_task_id===s.target_task_id);if(c!==void 0){if(JSON.stringify({...c,successor_run_id:s.successor_run_id})!==JSON.stringify(s))throw new k("Sequence replay has another target or proof");return c.successor_run_id}if((l?.steps.at(-1)?.successor_run_id??r.maintenanceRunId)!==r.predecessorRunId)throw new k("Sequence predecessor is not the previous root");let m={schema_version:a,client_turn_id:r.clientTurnId,maintenance_run_id:r.maintenanceRunId,maintenance_execution_id:r.maintenanceExecutionId,kind:"delivery",steps:[...l?.steps??[],s]};return o===null?await t.writeTextExclusive(e,`${JSON.stringify(m)}
|
|
100
|
+
`):await t.writeTextAtomic(e,`${JSON.stringify(m)}
|
|
101
|
+
`),s.successor_run_id}var Dt=class{constructor(e,n){this.filesystem=e;this._layout=n}filesystem;_layout;async claimIdentity(e,n,r,o,a){let s=a.filter(u=>u.client_turn_id===e);if(s.length>1)throw new k(`Client turn resolves to multiple Executions: ${e}`);let l=s[0];l!==void 0&&this.assertExpectedExecution(l,r,o);let c={schema_version:1,client_turn_id:e,execution_id:l?.id??n,kind:r,origin:o},d=this.claimPath(e);try{return await this.filesystem.writeTextExclusive(d,`${JSON.stringify(c)}
|
|
102
|
+
`),c.execution_id}catch(u){if(!Ye(u))throw u}let m=V(await this.filesystem.readText(d));if(this.assertCompatibleClaim(m,e,r,o),!("execution_id"in m))throw new k("Sequence cannot be claimed as one Execution");return m.execution_id}async claimExplicitIdentity(e,n,r,o){let a={schema_version:1,client_turn_id:e,execution_id:n,kind:r,origin:o},s=this.claimPath(e);try{return await this.filesystem.writeTextExclusive(s,`${JSON.stringify(a)}
|
|
103
|
+
`),n}catch(c){if(!Ye(c))throw c}let l=V(await this.filesystem.readText(s));if(this.assertCompatibleClaim(l,e,r,o),!("execution_id"in l))throw new k("Sequence cannot be claimed as one Execution");return l.execution_id}async claimSpecHandoff(e){let n=this.claimPath(e.clientTurnId),r=V(await this.filesystem.readText(n)),o={schema_version:2,client_turn_id:e.clientTurnId,interaction_execution_id:e.interactionExecutionId,execution_id:e.executionId,kind:"delivery",origin:{type:"spec",spec_id:e.specId},predecessor_run_id:e.predecessorRunId,successor_run_id:r.schema_version===2?r.successor_run_id:e.proposedSuccessorRunId,authorization_sha256:e.authorizationSha256};if(r.schema_version===2){if(JSON.stringify(r)!==JSON.stringify(o))throw new k("Same-turn handoff conflicts with its claimed target or authorization");return r.successor_run_id}if(r.client_turn_id!==e.clientTurnId||r.kind!=="interaction"||r.execution_id!==e.interactionExecutionId||r.origin.type!=="interaction")throw new k("Same-turn handoff requires the original interaction claim");return await this.filesystem.writeTextAtomic(n,`${JSON.stringify(o)}
|
|
104
|
+
`),o.successor_run_id}async readSpecHandoff(e){let n;try{n=await this.filesystem.readText(this.claimPath(e))}catch(o){if(o instanceof Error&&"code"in o&&o.code==="ENOENT")return null;throw o}let r=V(n);if(r.client_turn_id!==e)throw new k("Persisted client turn claim has another identity");return r.schema_version===2?r:null}async claimConversationHandoff(e){return Mr(this.filesystem,this.claimPath(e.client_turn_id),e)}async readConversationHandoff(e){return Fr(this.filesystem,this.claimPath(e),e)}async claimPostPublicationHandoff(e){let n=this.claimPath(e.clientTurnId),r=V(await this.filesystem.readText(n)),o={schema_version:e.specId===null?5:3,client_turn_id:e.clientTurnId,maintenance_execution_id:e.maintenanceExecutionId,execution_id:e.executionId,kind:"delivery",origin:e.specId===null?{type:"task",task_id:e.targetTaskId}:{type:"spec",spec_id:e.specId},predecessor_run_id:e.predecessorRunId,successor_run_id:r.schema_version===3||r.schema_version===5?r.successor_run_id:e.proposedSuccessorRunId,target_task_id:e.targetTaskId,authorization_sha256:e.authorizationSha256};if(r.schema_version===3||r.schema_version===5){if(JSON.stringify(r)!==JSON.stringify(o))throw new k("Post-publication handoff conflicts with its claim");return r.successor_run_id}if(r.schema_version!==1||r.client_turn_id!==e.clientTurnId||r.kind!=="delivery"||r.execution_id!==e.maintenanceExecutionId||r.origin.type!=="task")throw new k("Post-publication handoff requires the original maintenance delivery claim");return await this.filesystem.writeTextAtomic(n,`${JSON.stringify(o)}
|
|
105
|
+
`),o.successor_run_id}async readPostPublicationHandoff(e){try{let n=V(await this.filesystem.readText(this.claimPath(e)));if(n.client_turn_id!==e)throw new k("Persisted client turn claim has another identity");return n.schema_version===3||n.schema_version===5?n:null}catch(n){if(n instanceof Error&&"code"in n&&n.code==="ENOENT")return null;throw n}}async claimPostPublicationNewTurn(e){let n=this.claimPath(e.clientTurnId),r={schema_version:e.specId===null?6:4,client_turn_id:e.clientTurnId,execution_id:e.executionId,kind:"delivery",origin:e.specId===null?{type:"task",task_id:e.targetTaskId}:{type:"spec",spec_id:e.specId},predecessor_run_id:e.predecessorRunId,successor_run_id:e.proposedSuccessorRunId,target_task_id:e.targetTaskId,authorization_sha256:e.authorizationSha256};try{return await this.filesystem.writeTextExclusive(n,`${JSON.stringify(r)}
|
|
106
|
+
`),r.successor_run_id}catch(a){if(!Ye(a))throw a}let o=V(await this.filesystem.readText(n));if(o.schema_version!==4&&o.schema_version!==6||JSON.stringify(o)!==JSON.stringify({...r,successor_run_id:o.successor_run_id}))throw new k("Post-publication new turn has another claim");return o.successor_run_id}async readPostPublicationNewTurn(e){let n;try{n=await this.filesystem.readText(this.claimPath(e))}catch(o){if(o instanceof Error&&"code"in o&&o.code==="ENOENT")return null;throw o}let r=V(n);if(r.client_turn_id!==e)throw new k("Persisted client turn claim has another identity");return r.schema_version===4||r.schema_version===6?r:null}async readPostPublicationSequence(e){return Lr(this.filesystem,this.claimPath(e),e)}async claimPostPublicationSequence(e){return jr(this.filesystem,this.claimPath(e.clientTurnId),n=>this.readPostPublicationSequence(n),e)}async createExecution(e,n,r,o,a,s){try{return await this.filesystem.writeTextExclusive(o,a),e}catch(l){if(!Ye(l))throw l;return this.assertExpectedExecution(await s(),n,r)}}assertExpectedExecution(e,n,r){if(e.kind!==n||JSON.stringify(e.origin)!==JSON.stringify(r))throw new k(`Client turn ${e.client_turn_id??"unknown"} resolves to incompatible ${e.kind??"legacy-delivery"} Execution ${e.id}`);return e}claimPath(e){let n=qs("sha256").update(e).digest("hex");return ut("execution-client-turn",n)}assertCompatibleClaim(e,n,r,o){if(!("origin"in e))throw new k("Client turn is already a publication sequence");if(e.client_turn_id!==n||e.kind!==r||JSON.stringify(e.origin)!==JSON.stringify(o))throw new k(`Client turn ${n} is already claimed by incompatible Execution ${e.execution_id}`)}};var Q=class{constructor(e,n){this.filesystem=e;this.layout=n;et(n),this.clientTurnClaims=new Dt(e,n)}filesystem;layout;clientTurnClaims;async read(e){let n=await Te(this.filesystem,this.layout,"execution",e),r=P(await this.filesystem.readText(n),O);return{execution:r.metadata,body:r.body}}async list(){return Re(this.filesystem,this.layout.entityRoot("execution"),"execution.md",O)}async createInteraction(e){let n={type:"interaction",conversation_id:e.conversationId},r=await this.clientTurnClaims.claimIdentity(e.clientTurnId,e.id,"interaction",n,await this.list()),o=await this.read(r).catch(()=>null);if(o!==null)return this.clientTurnClaims.assertExpectedExecution(o.execution,"interaction",n);let s=(e.clock??new T).now().toISOString(),l=Cn({id:r,clientTurnId:e.clientTurnId,origin:n,policy:e.policy,now:s});return this.clientTurnClaims.createExecution(l,"interaction",n,this.path(l.id),this.serialize(l),async()=>(await this.read(l.id)).execution)}async createDeliveryIntake(e){let n=await this.clientTurnClaims.claimIdentity(e.clientTurnId,e.id,"delivery",e.origin,await this.list()),r=await this.read(n).catch(()=>null);if(r!==null)return this.clientTurnClaims.assertExpectedExecution(r.execution,"delivery",e.origin);let a=(e.clock??new T).now().toISOString(),s=Tn({id:n,clientTurnId:e.clientTurnId,origin:e.origin,policy:e.policy,now:a});return this.clientTurnClaims.createExecution(s,"delivery",e.origin,this.path(s.id),this.serialize(s),async()=>(await this.read(s.id)).execution)}async promoteDeliveryIntake(e,n){let r=await this.read(e);if(r.execution.plan_hash===n.plan_hash)return r.execution;if(Fe.parse(n.policy),r.execution.kind!=="delivery"||r.execution.plan_hash!==null||r.execution.plan_revision!==null||JSON.stringify(r.execution.origin)!==JSON.stringify(n.origin))throw new TypeError(`Execution ${e} is not a matching delivery intake`);let o=O.parse({...n,kind:"delivery",client_turn_id:r.execution.client_turn_id,revision:r.execution.revision+1,created_at:r.execution.created_at});return await this.write(o),o}async claimClientTurn(e,n){let r=await this.read(e),o=r.execution.kind??"delivery",a=await this.clientTurnClaims.claimExplicitIdentity(n,e,o,r.execution.origin);if(a!==e){let l=await this.read(a);return this.clientTurnClaims.assertExpectedExecution(l.execution,o,r.execution.origin)}if(r.execution.kind==="interaction"){if(r.execution.client_turn_id!==n)throw new Error(`Interaction Execution ${e} belongs to another client turn`);return r.execution}if(r.execution.client_turn_id===n)return r.execution;if(r.execution.client_turn_id!=null)throw new Error(`Delivery Execution ${e} already belongs to another client turn`);let s=O.parse({...r.execution,revision:r.execution.revision+1,kind:"delivery",client_turn_id:n,updated_at:new Date().toISOString()});return await this.write(s),s}async claimSpecHandoff(e){let n=(await this.read(e.executionId)).execution;if(n.origin.type!=="spec"||n.origin.spec_id!==e.specId)throw new Error("Same-turn handoff Execution does not belong to the target SPEC");return this.clientTurnClaims.claimSpecHandoff(e)}async readSpecHandoff(e){return this.clientTurnClaims.readSpecHandoff(e)}async claimConversationHandoff(e){let n=(await this.read(e.execution_id)).execution;if(n.kind!=="delivery"||n.origin.type!=="task"||n.origin.task_id!==e.origin.task_id)throw new Error("Conversation handoff requires the exact Task-first Execution");return this.clientTurnClaims.claimConversationHandoff(e)}async readConversationHandoff(e){return this.clientTurnClaims.readConversationHandoff(e)}async claimPostPublicationHandoff(e){return this.clientTurnClaims.claimPostPublicationHandoff(e)}async readPostPublicationHandoff(e){return this.clientTurnClaims.readPostPublicationHandoff(e)}async claimPostPublicationNewTurn(e){return this.clientTurnClaims.claimPostPublicationNewTurn(e)}async readPostPublicationNewTurn(e){return this.clientTurnClaims.readPostPublicationNewTurn(e)}async readPostPublicationSequence(e){return this.clientTurnClaims.readPostPublicationSequence(e)}async claimPostPublicationSequence(e){let n=(await this.read(e.executionId)).execution;if(e.specId===null&&(n.origin.type!=="task"||n.origin.task_id!==e.targetTaskId)||e.specId!==null&&(n.origin.type!=="spec"||n.origin.spec_id!==e.specId))throw new Error("Post-publication sequence Execution has another target origin");return this.clientTurnClaims.claimPostPublicationSequence(e)}async linkChildExecution(e,n){if(e===n)throw new TypeError("Execution cannot be its own parent");let[r,o]=await Promise.all([this.read(e),this.read(n)]);if(r.execution.origin.type!=="spec"||o.execution.origin.type!=="prd")throw new TypeError("Child Execution must originate from a SPEC under a PRD Execution");if(r.execution.parent_execution_id===n)return r.execution;if(r.execution.parent_execution_id!=null)throw new TypeError(`Execution ${e} is already linked to ${r.execution.parent_execution_id}`);if(["completed","failed","cancelled"].includes(o.execution.status))throw new TypeError(`Parent Execution ${n} is terminal`);let a=O.parse({...r.execution,parent_execution_id:n,revision:r.execution.revision+1,updated_at:new Date().toISOString()});return await this.write(a),a}async normalizeBody(e){let n=await this.read(e);return await this.write(n.execution),n.execution}async transition(e,n,r=null,o=new T,a=null){let s=await this.read(e);pe(En,s.execution.status,n,"Execution");let l=o.now().toISOString(),c=["completed","failed","cancelled"].includes(n),d=O.parse({...s.execution,revision:s.execution.revision+1,status:n,status_reason:["blocked","failed","cancelled"].includes(n)?a??r??`Execution moved to ${n}.`:null,updated_at:l,started_at:n==="running"&&s.execution.started_at===null?l:s.execution.started_at,finished_at:c?l:null,result:c?r:null});return await this.write(d),d}async write(e,n=Rn(e)){await this.filesystem.writeTextAtomic(this.path(e.id),this.serialize(e,n))}serialize(e,n=Rn(e)){return F({metadata:O.parse(e),body:n})}path(e){return this.layout.activePath("execution",e)}};var Ae=class{constructor(e,n){this.filesystem=e;this.layout=n;et(n)}filesystem;layout;async create(e){let n=e.clock??new T,r=n.now().toISOString(),o=e.id??Sn("PRD",e.shortName,n,this.layout.project.timezone),a=[...e.outcomes??[]],s=X.parse({schema_version:2,id:o,revision:1,title:e.title,target_release:e.targetRelease??null,status:"draft",status_reason:null,outcome_status:"unmeasured",problem:e.problem,audiences:[...e.audiences??[]],outcomes:a,outcome_ids:e.outcomeIds??li(o,a),constraints:[...e.constraints??[]],non_goals:[...e.nonGoals??[]],prepared_plan:null,plan_ref:null,creation_run_id:e.creationRunId??null,rework_of_prd_id:e.reworkOfPrdId??null,tags:[...e.tags??[]],created_at:r,updated_at:r});return await this.write(s,Pr(s),!0),s}async createReworkSuccessor(e,n){let{prd:r}=await this.read(e);if(r.status!=="cancelled")throw new TypeError(`PRD ${e} must be cancelled before rework`);return this.create({...n,targetRelease:n.targetRelease??r.target_release,reworkOfPrdId:r.id,tags:["rework"]})}async read(e){let n=await Te(this.filesystem,this.layout,"prd",e),r=P(await this.filesystem.readText(n),X);return{prd:r.metadata,body:r.body}}async list(){return Re(this.filesystem,this.layout.entityRoot("prd"),".md",X)}async setPreparedPlan(e,n){let r=W.parse(n),o=await this.read(e);if(r.source.type==="prd"&&r.acceptance_policy===void 0&&o.prd.prepared_plan?.hash!==r.hash&&o.prd.plan_ref?.hash!==r.hash)throw new TypeError("New PRD preparation requires proportional-acceptance-v1 adoption");if(!new Set(["draft","ready"]).has(o.prd.status))throw new TypeError(`PRD ${e} cannot be prepared from status ${o.prd.status}`);let a=si(r,e);if(a.length===0)throw new TypeError(`PRD ${e} requires at least one SPEC`);let s=await Re(this.filesystem,this.layout.entityRoot("spec"),".md",U),l=new Map(s.map(d=>[d.id,d]));for(let d of a){let m=l.get(d);if(m===void 0)throw new TypeError(`PRD SPEC does not resolve: ${d}`);if(m.prd_id!==e)throw new TypeError(`SPEC ${d} does not belong to PRD ${e}`);if(["active","delivered","cancelled"].includes(m.status))throw new TypeError(`SPEC ${d} cannot be prepared from status ${m.status}`);await ft(m.implementation,this.filesystem,this.layout)}let c=X.parse({...o.prd,revision:o.prd.revision+1,prepared_plan:r,plan_ref:null,updated_at:r.prepared_at});return await this.write(c,o.body),c}async transition(e,n,r=new T,o=null){let a=await this.read(e);pe(Or,a.prd.status,n,"PRD");let s=typeof r=="string"?new T:r,l=typeof r=="string"?r:o,c=X.parse({...a.prd,revision:a.prd.revision+1,status:n,status_reason:["blocked","failed","cancelled"].includes(n)?l??`PRD moved to ${n}.`:null,updated_at:s.now().toISOString()});return await this.write(c,a.body),c}async normalizePreparedPlan(e,n){let r=await this.read(e);if(r.prd.plan_ref?.hash===n.hash)return r.prd;if(r.prd.prepared_plan?.hash!==n.hash)throw new Error(`PRD ${e} does not contain PreparedPlan ${n.hash}`);let o=X.parse({...r.prd,revision:r.prd.revision+1,prepared_plan:null,plan_ref:Me(n),updated_at:new Date().toISOString()});return await this.write(o,r.body),o}path(e){return this.layout.activePath("prd",e)}async write(e,n,r=!1){await this.filesystem[r?"writeTextAtomicExclusive":"writeTextAtomic"](this.path(e.id),F({metadata:X.parse(e),body:n}))}},Ie=class{constructor(e,n){this.filesystem=e;this.layout=n;et(n)}filesystem;layout;async create(e){let n=e.clock??new T,r=n.now().toISOString(),o=U.parse({schema_version:2,id:e.id??Sn("SPEC",e.shortName,n,this.layout.project.timezone),prd_id:e.prdId??null,revision:1,title:e.title,target_release:e.targetRelease??null,status:"draft",status_reason:null,objective:e.objective,included_scope:[...e.includedScope??[]],excluded_scope:[...e.excludedScope??[]],requirement_ids:[...e.requirementIds??[]],acceptance_ids:[...e.acceptanceIds??[]],implementation:e.implementation??null,prepared_plan:null,plan_ref:null,creation_run_id:e.creationRunId??null,created_at:r,updated_at:r});return await this.write(o,qr(o),!0),o}async read(e){let n=await Te(this.filesystem,this.layout,"spec",e),r=P(await this.filesystem.readText(n),U);return{spec:r.metadata,body:r.body}}async list(){return Re(this.filesystem,this.layout.entityRoot("spec"),".md",U)}async retargetPublishedRelease(e,n){let r=await this.read(e);if(r.spec.release_retarget!==null||r.spec.status!=="active"||r.spec.target_release!==n.from||r.spec.plan_ref===null)throw new TypeError(`SPEC ${e} cannot be retargeted from its current lifecycle state`);let o=new Date().toISOString(),a=U.parse({...r.spec,revision:r.spec.revision+1,target_release:n.to,release_retarget:{from:n.from,to:n.to,adoption_main_sha:n.adoptionMainSha,actor_run_id:n.actorRunId,adopted_at:n.adoptedAt,retargeted_at:o},updated_at:o});return await this.write(a,r.body),a}async setPreparedPlan(e,n){let r=W.parse(n);if(r.source.type!=="spec"||r.source.spec_id!==e)throw new TypeError(`Prepared plan source must be spec ${e}`);let o=await this.read(e);if(r.acceptance_policy===void 0&&o.spec.prepared_plan?.hash!==r.hash&&o.spec.plan_ref?.hash!==r.hash)throw new TypeError("New SPEC preparation requires proportional-acceptance-v1 adoption");if(!new Set(["draft","ready"]).has(o.spec.status))throw new TypeError(`SPEC ${e} cannot be prepared from status ${o.spec.status}`);await ft(o.spec.implementation,this.filesystem,this.layout);let a=U.parse({...o.spec,revision:o.spec.revision+1,prepared_plan:r,plan_ref:null,updated_at:r.prepared_at});return await this.write(a,o.body),a}async transition(e,n,r=new T,o=null){let a=await this.read(e);pe(Nr,a.spec.status,n,"DeliverySpec");let s=typeof r=="string"?new T:r,l=typeof r=="string"?r:o;["active","delivered"].includes(n)&&await ft(a.spec.implementation,this.filesystem,this.layout);let c=U.parse({...a.spec,revision:a.spec.revision+1,status:n,status_reason:["blocked","failed","cancelled"].includes(n)?l??`SPEC moved to ${n}.`:null,updated_at:s.now().toISOString()});return await this.write(c,a.body),c}async normalizePreparedPlan(e,n){let r=await this.read(e);if(r.spec.plan_ref?.hash===n.hash)return r.spec;if(r.spec.prepared_plan?.hash!==n.hash)throw new Error(`SPEC ${e} does not contain PreparedPlan ${n.hash}`);let o=U.parse({...r.spec,revision:r.spec.revision+1,prepared_plan:null,plan_ref:Me(n),updated_at:new Date().toISOString()});return await this.write(o,r.body),o}path(e){return this.layout.activePath("spec",e)}async write(e,n,r=!1){await this.filesystem[r?"writeTextAtomicExclusive":"writeTextAtomic"](this.path(e.id),F({metadata:U.parse(e),body:n}))}},oe=class{constructor(e,n){this.filesystem=e;this.layout=n;et(n)}filesystem;layout;async read(e){let n=await Te(this.filesystem,this.layout,"change",e),r=P(await this.filesystem.readText(n),H);return{change:r.metadata,body:r.body}}async createDraft(e){let r=(e.clock??new T).now().toISOString(),o=H.parse({schema_version:2,id:e.id,revision:1,title:e.title,status:"draft",risk:e.risk,source:{type:"task",task_id:e.taskId},requirement_ids:[...e.requirementIds],acceptance_ids:[...e.acceptanceIds],requirement_impact:{type:"none",reason:"Awaiting prepared plan."},task_ids:[e.taskId],plan_revision:null,plan_hash:null,created_at:r,updated_at:r,started_at:null,finished_at:null,result:null});return await this.filesystem.writeTextExclusive(this.path(o.id),this.serialize(o)),o}async promoteDraft(e,n){let r=await this.read(e);if(r.change.status==="planned"&&Vr(r.change,n))return r.change;if(r.change.status!=="draft"||!kn(r.change,n))throw new TypeError(`Change ${e} does not match its Task draft`);let o=H.parse({...n,revision:r.change.revision+1,created_at:r.change.created_at,updated_at:n.updated_at});return await this.write(o),o}async list(){return Re(this.filesystem,this.layout.entityRoot("change"),"change.md",H)}async transition(e,n,r=null,o=new T,a=null){let s=await this.read(e);pe(Dr,s.change.status,n,"Change");let l=o.now().toISOString(),c=["completed","failed","cancelled"].includes(n),d=H.parse({...s.change,revision:s.change.revision+1,status:n,status_reason:["blocked","failed","cancelled"].includes(n)?a??r??`Change moved to ${n}.`:null,updated_at:l,started_at:n==="executing"&&s.change.started_at===null?l:s.change.started_at,finished_at:c?l:null,result:c?r:null});return await this.write(d,await $r(this.filesystem,this.path(e),d,s.body)),d}async write(e,n=Nt(e.title)){await this.filesystem.writeTextAtomic(this.path(e.id),this.serialize(e,n))}serialize(e,n=Nt(e.title)){return F({metadata:H.parse(e),body:n})}path(e){return this.layout.activePath("change",e)}};function Rn(t){return`# Execution ${t.id}
|
|
107
|
+
|
|
108
|
+
## Plano
|
|
109
|
+
|
|
110
|
+
DAG e pol\xEDtica est\xE3o persistidas no frontmatter.
|
|
111
|
+
|
|
112
|
+
## Progresso
|
|
113
|
+
|
|
114
|
+
Estado atual: ${t.status}.
|
|
115
|
+
|
|
116
|
+
## Resultado
|
|
117
|
+
|
|
118
|
+
${t.result??t.status_reason??"Ainda n\xE3o conclu\xEDda."}`}async function Re(t,e,n,r){let o=await t.listFiles(e,n);return Promise.all(o.map(async a=>P(await t.readText(a),r).metadata))}function et(t){if(t.version===1)throw new TypeError("V2 repositories require a modern WorkspaceLayout")}var $s=["lite","standard","critical"],zt=i.string().datetime({offset:!0}),wf=i.object({id:i.string().startsWith("SPEC-"),capability:i.string().min(1),title:i.string().min(1),status:i.enum(["active","deprecated"]).default("active"),version:i.number().int().positive().default(1),updated_at:zt}).strict();var bf=i.object({id:i.string().startsWith("CHG-"),title:i.string().min(1),status:i.enum(["draft","planned","executing","verifying","completed","failed","blocked","cancelled"]),risk:i.enum($s),capabilities:i.array(i.string().startsWith("SPEC-")),requirements:i.array(i.string().startsWith("REQ-")),tasks:i.array(i.string().startsWith("TASK-")),human_decisions:i.array(i.string().startsWith("DEC-HUMAN-")),agent_decisions:i.array(i.string().startsWith("DEC-AI-")),created_at:zt,updated_at:zt,completed_at:zt.nullable().default(null)}).strict();var me=["validate","develop","review","fix","verify","close"];var Cg=5*6e4;var rt=i.object({outcome:i.enum(["completed","blocked","failed","cancelled"]),summary:i.string().trim().min(1),evidence_ids:i.array(i.string().min(1)),changed_files:i.array(i.string().min(1))}).strict();var $n=i.string().datetime(),Vn=i.object({id:i.string().min(1),acceptance_ids:i.array(i.string().min(1))}).strict(),Bs=i.object({soft_cycles:i.number().int().positive(),max_attempts:i.number().int().positive().nullable()}).strict(),Ks=i.object({phase:i.enum(me),event_id:i.string().min(1),state_hash:i.string().regex(/^[a-f0-9]{64}$/),cycles:i.number().int().nonnegative(),input_tokens:i.number().int().nonnegative().nullable(),measurement_source:i.enum(["provider-uncached-input","observable-context-fallback","unavailable"]),checkpoint_required:i.boolean()}).strict(),Gs=i.object({schema_version:i.literal(1),id:i.string().min(1),phase:i.enum(me),status:i.enum(["running","blocked","completed"]),revision:i.number().int().positive(),acceptance_ids:i.array(i.string().min(1)).min(1),budgets:i.object(Object.fromEntries(me.map(t=>[t,Bs]))),attempts:i.object(Object.fromEntries(me.map(t=>[t,i.number().int().nonnegative()]))),checkpoints:i.array(Ks),evidence:i.array(Vn),processed_event_ids:i.array(i.string().min(1)),blocker:i.string().min(1).nullable()}).strict(),Ft=i.enum(["execution_override","task_override","automatic_policy","project_defaults"]),Zs=i.enum(["EXECUTION_OVERRIDE","TASK_OVERRIDE","XHIGH_ELIGIBLE","SIMPLE_BOUNDED_WORK","SOL_PLANNING_OR_REVIEW","SOL_AMBIGUOUS_OR_TRANSVERSAL","SOL_STRUCTURAL_REWORK","ASTRA_DIAGNOSTIC","ASTRA_HANDBACK","SOL_IMPLEMENTATION_BASELINE","TERRA_IMPLEMENTATION_BASELINE","PROJECT_DEFAULTS","RISK_ASSURANCE_ONLY"]),Qs=i.object({model:i.string().min(1),reasoning_effort:i.enum(["low","medium","high","xhigh"]),velocity:i.literal("standard"),origin:Ft,sources:i.object({model:Ft,reasoning_effort:Ft,velocity:Ft}).strict(),policy_version:i.string().min(1),reasons:i.array(Zs).min(1)}).strict(),Xs=i.object({invocation_id:i.string().regex(/^INV-[A-Z0-9-]+$/),run_id:i.string().min(1).nullable().default(null),phase:i.enum(me),role:i.enum(["builder","verifier","finalizer"]),checkpoint_id:i.string().min(1).nullable(),checkpoint_hash:i.string().regex(/^[a-f0-9]{64}$/).nullable(),selection:Qs.nullable().default(null)}).strict(),Ys=i.object({astra_diagnostic:Bt.optional(),rework:i.enum(["localized","structural"]),rework_cost:i.enum(["medium","high"]),findings:i.array(i.string().min(1)).default([]),complexity:i.enum(["simple","standard","complex"]),transversality:i.enum(["local","multi_module","cross_system"]),ambiguity:i.enum(["low","medium","high"]),bounded:i.boolean(),high_volume:i.boolean(),xhigh_triggers:i.array(i.enum(["full_stack_boundary","shared_contracts_3_plus","critical_data_or_security","rollout_and_rollback","repeated_structural_repair","architectural_review_finding","prepared_plan_invalidated","material_architectural_tradeoffs"]))}).strict(),Qr=i.object({task_id:i.string().min(1),status:i.enum(["available","unavailable","quality_below_floor"]),evidence_ids:i.array(i.string().min(1)),validation_ids:i.array(i.string().min(1)),rework_count:i.number().int().nonnegative().nullable(),quality_score:i.number().nonnegative().nullable(),quality_floor:i.number().nonnegative().nullable(),cost_delta_usd:i.number().nullable(),economy_status:i.enum(["available","unavailable"])}).strict(),ec=i.object({baseline_task_id:i.string().min(1).nullable(),baseline_equivalence_id:i.string().min(1).nullable(),model:i.string().min(1).nullable(),reasoning_effort:i.enum(["low","medium","high","xhigh"]).nullable(),context_budget_tokens:i.number().int().nonnegative().nullable(),cached_context_tokens:i.number().int().nonnegative().nullable(),early_stop_reason:i.string().min(1).nullable(),retry_count:i.number().int().nonnegative().nullable(),rework_count:i.number().int().nonnegative().nullable(),observed_cost_usd:i.number().nonnegative().nullable(),baseline_observed_cost_usd:i.number().nonnegative().nullable(),quality_score:i.number().nonnegative().nullable(),quality_floor:i.number().nonnegative().nullable()}).strict(),tc=i.object({provider:i.enum(["codex","claude"]),host_authentication_available:i.boolean(),requires_external_provider:i.boolean(),requires_remote_operation:i.boolean()}).strict(),nc=i.object({identity:i.string().min(1),replay_key:i.string().regex(/^[a-f0-9]{64}$/),validation_ids:i.array(i.string().min(1)),evidence_ids:i.array(i.string().min(1))}).strict(),ic=i.object({candidate_fingerprint:i.string().regex(/^[a-f0-9]{64}$/).nullable(),proof_fingerprint:i.string().regex(/^[a-f0-9]{64}$/),semantic_attempts:i.number().int().nonnegative(),classification:i.enum(["unknown","localized","structural"]),proof_delta:i.enum(["none","added","replaced"]),repeated_without_delta:i.boolean(),elapsed_reassessment:i.literal("unavailable"),decision:i.enum(["shadow_continue","shadow_rereview","shadow_block"])}).strict(),rc=i.object({id:i.string().min(1),rule:i.string(),path:i.string(),line:i.number().int().positive(),severity:i.enum(["low","medium","high","critical"]),message:i.string(),status:i.enum(["open","resolved","waived"]),resolution_evidence_id:i.string().nullable()}).strict(),oc=i.object({id:i.string().min(1),executor_id:i.string().min(1),reviewer_id:i.string().min(1),max_repair_cycles:i.number().int().nonnegative().nullable(),repair_cycles:i.number().int().nonnegative(),findings:i.array(rc),reviewer_approved:i.boolean()}).strict(),ac=i.object({autonomy:Jt.optional(),finalizer_decision:rt.optional(),recovery_invocation:i.object({id:i.string().min(1),run_id:i.string().nullable()}).strict().optional(),recovery_plan:i.object({hypothesis:i.string().min(1),test:i.string().min(1),executor_model:i.string().min(1)}).strict().optional(),id:i.string().min(1),change_id:i.string().min(1),title:i.string().min(1),objective:i.string().min(1),risk:i.enum(["lite","standard","critical"]),priority:i.number().int(),depends_on:i.array(i.string().min(1)),acceptance_ids:i.array(i.string().min(1)).min(1),write_scopes:i.array(i.string().min(1)),scope_receipt:i.object({receipt_id:i.string().min(1),current_scopes:i.array(i.string().min(1)),delta_scopes:i.array(i.string().min(1))}).optional(),child_execution_id:i.string().min(1).optional(),builder:i.object({id:i.string().min(1),model:i.string().min(1),reasoning_effort:i.enum(["low","medium","high","xhigh"]).optional(),tools:i.array(i.string()).optional(),execution_eligibility:i.array(i.enum(["interaction","delivery"])).optional()}).optional(),verifier:i.object({id:i.string().min(1),model:i.string().min(1),reasoning_effort:i.enum(["low","medium","high","xhigh"]).optional(),tools:i.array(i.string()).optional(),execution_eligibility:i.array(i.enum(["interaction","delivery"])).optional()}).optional(),commit:i.object({agent:i.enum(["CODEX","CLAUDE"]),execution_id:i.string().min(1),change_id:i.string().min(1),task_id:i.string().min(1),title:i.string().min(1),prd_id:i.string().min(1).nullable(),spec_id:i.string().min(1).nullable()}).strict().optional(),runtime:ct.optional(),model_profile:dt.optional(),assurance_contract:Cr.optional(),outcome_measurement:ec.optional(),status:i.enum(["planned","running","completed","failed","blocked"]),worktree_path:i.string().min(1).nullable(),integration_commit:i.string().min(1).nullable(),changed_files:i.array(i.string().min(1)).default([]),task_run_id:i.string().min(1).nullable().default(null),finalizer_approved:i.boolean().default(!1),closure_pending:i.boolean().default(!1),finalization_pending:i.boolean().default(!1),lifecycle_cleanup:i.object({handoff_path:i.string().min(1),invocation_run_id:i.string().min(1).nullable(),task_run_id:i.string().min(1).nullable(),invocation_finished:i.boolean(),task_finished:i.boolean(),last_error:i.string().nullable()}).strict().optional(),active_invocation:Xs.nullable(),active_diagnostic:i.object({invocation_id:i.string().regex(/^INV-[A-Z0-9-]+$/),run_id:i.string().min(1).nullable(),status:i.enum(["requested","completed","blocked"]),cycle:i.union([i.literal(1),i.literal(2),i.literal(3)]),evidence_fingerprint:i.string().regex(/^[a-f0-9]{64}$/),executor_attempt_id:i.string().min(1).nullable(),handback:lt.nullable()}).strict().nullable().default(null),handback:lt.nullable().default(null),last_executor_invocation_id:i.string().min(1).nullable().default(null),rework_profile:Ys.nullable().default(null),sdc:Gs,validation_ids:i.array(i.string().min(1)),evidence:i.array(Vn),outcome_projection:Qr.nullable().default(null),validation_attempts:i.array(nc).default([]),convergence_observations:i.array(ic).default([]),qa_session:oc.nullable().default(null),qa_pending_resolutions:i.array(i.object({finding_id:i.string().min(1),evidence_id:i.string().min(1)}).strict()).default([]),qa_approval_observed:i.boolean().default(!1),qa_review_candidate_fingerprint:i.string().regex(/^[a-f0-9]{64}$/).nullable().default(null),last_error:i.string().min(1).nullable()}).strict(),Sy=i.object({schema_version:i.literal(1),execution_id:i.string().min(1),lease_ms:i.number().int().min(5e3).max(Number.MAX_SAFE_INTEGER).nullable().default(null),source:i.enum(["task","spec","prd"]),operational_context:tc.default({provider:"codex",host_authentication_available:!1,requires_external_provider:!1,requires_remote_operation:!1}),status:i.enum(["running","completed","failed","blocked"]),revision:i.number().int().nonnegative(),created_at:$n,updated_at:$n,execution_started_at:$n.nullable().default(null),invocation_count:i.number().int().nonnegative().default(0),stalled_cycles:i.number().int().nonnegative().default(0),handoff_worktree_path:i.string().min(1).nullable().default(null),handoff_branch:i.string().min(1).nullable().default(null),handoff_commit:i.string().min(1).nullable().default(null),parent_acceptance:i.object({run_id:i.string().min(1).nullable(),finalizer_run_id:i.string().min(1).nullable().default(null),invocation_id:i.string().regex(/^INV-[A-Z0-9-]+$/).nullable().default(null),checkpoint_id:i.string().min(1).nullable().default(null),checkpoint_hash:i.string().min(1).nullable().default(null),candidate:i.object({handoff_worktree_path:i.string().min(1),handoff_commit:i.string().min(1),validation_ids:i.array(i.string().min(1)),evidence:i.array(Vn),task_outcomes:i.array(i.object({task_id:i.string().min(1),integration_commit:i.string().min(1),changed_files:i.array(i.string().min(1)),outcome_projection:Qr.nullable()}).strict())}).strict().nullable().default(null),decision_observed:i.boolean().default(!1),decision:rt.optional(),status:i.enum(["pending","approved","blocked"])}).default({run_id:null,finalizer_run_id:null,invocation_id:null,checkpoint_id:null,checkpoint_hash:null,candidate:null,decision_observed:!1,status:"pending"}),tasks:i.array(ac).min(1),last_error:i.string().min(1).nullable()}).strict();var Lt=i.object({editorial_delivery:i.boolean().optional(),production_impact:i.boolean().optional(),external_action:i.boolean().optional(),irreversible_change:i.boolean().optional(),security_or_critical_data:i.boolean().optional(),data_migration:i.boolean().optional(),broad_audit:i.boolean().optional(),rollback:i.enum(["trivial","planned","complex"]).optional(),verification_scope:i.enum(["scoped","package","cross_scope","full"]).optional()}).strict();function cc(t){return{verification_scope:t==="lite"?"scoped":t==="standard"?"package":"full"}}function Xr(t,e){let n=Lt.parse(e??cc(t));if(t!=="critical"&&(n.security_or_critical_data||n.data_migration||n.irreversible_change))throw new Error("Security, migration or irreversible risk signals require a critical Task");if(n.editorial_delivery===!0){if(t!=="lite")throw new Error("Editorial delivery risk signal requires a lite Task");if(n.production_impact===!0||n.external_action===!0||n.irreversible_change===!0||n.security_or_critical_data===!0||n.data_migration===!0||n.broad_audit===!0||n.rollback!==void 0&&n.rollback!=="trivial")throw new Error("Editorial delivery risk signal cannot include sensitive or critical controls");if(n.verification_scope!==void 0&&n.verification_scope!=="scoped")throw new Error("Editorial delivery risk signal requires scoped verification")}return n}var On=i.preprocess(t=>typeof t=="string"?{summary:t,changed_files:[],evidence_ids:[],completed_run_id:null}:t,i.object({summary:i.string().min(1),changed_files:i.array(i.string().min(1)),evidence_ids:i.array(i.string().startsWith("EVD-")),completed_run_id:i.string().startsWith("RUN-").nullable()}).strict());function Nn(t){return typeof t=="object"&&t!==null&&"code"in t&&t.code==="EEXIST"}function Dn(t){let e=t.status==="draft"?"Rascunho aguardando classifica\xE7\xE3o; pode possuir Run de conversa, mas nenhum Change ou Execution foi criado.":t.plan_hash===null?`Captura encerrada como ${t.status} sem materializar Change ou Execution.`:`Plano ${t.plan_revision??"-"} materializado em ${t.change_id}; estado atual: ${t.status}.`,n=t.result?.summary??t.status_reason??"Ainda n\xE3o conclu\xEDda.",r=t.result?.evidence_ids.length?t.result.evidence_ids.map(o=>`- ${o}`).join(`
|
|
119
|
+
`):t.plan_hash!==null?`O resultado final ainda n\xE3o possui uma lista consolidada de evid\xEAncias. Consulte os registros de evid\xEAncia do Change ${t.change_id}; evid\xEAncias parciais podem existir mesmo com a Task ${t.status}.`:"Nenhuma evid\xEAncia vinculada ao resultado desta captura.";return`# ${t.title}
|
|
120
|
+
|
|
121
|
+
## Objetivo
|
|
122
|
+
|
|
123
|
+
${t.objective}
|
|
124
|
+
|
|
125
|
+
## Plano
|
|
126
|
+
|
|
127
|
+
${e}
|
|
128
|
+
|
|
129
|
+
## Evid\xEAncias
|
|
130
|
+
|
|
131
|
+
${r}
|
|
132
|
+
|
|
133
|
+
## Resultado
|
|
134
|
+
|
|
135
|
+
${n}`}function ot(t,e){return JSON.stringify(t)===JSON.stringify(e)}function at(t,e,n){let r=new Set;for(let o of t)r.has(o)&&n.addIssue({code:"custom",path:[e],message:`Duplicate value: ${o}`}),r.add(o)}async function Yr(t,e){for(let n of[...e].reverse()){if(!await t.exists(n.path))continue;await t.readText(n.path)===n.content&&await t.removeFile(n.path)}}function zn(t,e,n,r,o,a=!1){let s=["completed","failed","cancelled"].includes(e);return{...t,revision:t.revision+1,status:e,attempt_count:e==="executing"&&t.status!=="verifying"&&!a?(t.attempt_count??0)+1:t.attempt_count,status_reason:["blocked","failed","cancelled"].includes(e)?o??n?.summary??`Task moved to ${e}.`:null,updated_at:r,started_at:e==="executing"&&t.started_at===null?r:t.started_at,finished_at:s?r:null,result:s?n:null}}function eo(t,e){return t===`Orchestrator stopped without a persisted Gui finalization decision; lifecycle was fail-closed as blocked. (Run ${e}).`||t===`Finalization barrier missing; resume after a completed zaip-agent-finalizer Sub-Run with authoritative metadata (Run ${e}).`||t===`Finalization barrier evidence_missing; resume after passed typed Evidence linked to the same Task, Change, Execution, and Run (Run ${e}).`||t.startsWith(`Completion gates did not close Run ${e}:`)}function lc(t){return t.plan_ref?.execution_id??t.prepared_plan?.execution_id??null}function to(t,e){if(t.status!=="blocked"||t.status_reason!==e.reason||lc(t)!==e.executionId||!eo(e.reason,e.runId))throw new Error(`Task ${t.id} is not recoverable from its own completion gate`)}var no={draft:["planned","blocked","failed","cancelled"],planned:["executing","blocked","failed","cancelled"],executing:["verifying","failed","blocked","cancelled"],verifying:["executing","completed","failed","blocked","cancelled"],blocked:["executing","cancelled"],completed:[],failed:["executing"],cancelled:[]};var jt=i.string().datetime({offset:!0}),dc=i.string().regex(/^[a-f0-9]{64}$/),io=i.string().startsWith("TASK-"),uc=i.string().startsWith("CHG-"),pc=i.string().startsWith("REQ-"),mc=i.string().startsWith("AC-"),K=i.object({schema_version:i.literal(2),id:io,revision:i.number().int().positive(),change_id:uc,title:i.string().min(1),short_name:i.string().min(1),objective:i.string().min(1),target_release:i.string().regex(/^[1-9]\d*\.(?:0|[1-9]\d*)$/).nullable().optional(),status:i.enum(["draft","planned","executing","verifying","completed","failed","blocked","cancelled"]),status_reason:i.string().min(1).nullable().optional(),attempt_count:i.number().int().nonnegative().optional(),risk:i.enum(["lite","standard","critical"]),priority:i.enum(["low","medium","high","urgent"]),owner:i.string().min(1).nullable(),requirement_ids:i.array(pc).min(1),acceptance_ids:i.array(mc).min(1),depends_on:i.array(io),write_scopes:i.array(i.string().min(1)),runtime:ct.optional(),model_profile:dt.optional(),assurance_risk_signals:Lt.optional(),assurance_risk_signals_source:i.enum(["explicit","risk_default"]).optional(),plan_revision:i.number().int().positive().nullable(),plan_hash:dc.nullable(),prepared_plan:W.optional(),plan_ref:ci.optional(),created_at:jt,updated_at:jt,started_at:jt.nullable(),finished_at:jt.nullable(),result:On.nullable()}).strict().superRefine((t,e)=>{let n=t.plan_revision===null&&t.plan_hash===null;t.status==="draft"||n&&["blocked","failed","cancelled"].includes(t.status)?(!n||t.prepared_plan!==void 0||t.plan_ref!==void 0)&&e.addIssue({code:"custom",message:`${t.status} Task without materialization cannot contain a prepared plan`}):(t.plan_revision===null||t.plan_hash===null)&&e.addIssue({code:"custom",message:`${t.status} Task requires plan_revision and plan_hash`}),t.prepared_plan!==void 0&&t.plan_ref!==void 0&&e.addIssue({code:"custom",message:"Task cannot contain prepared_plan and plan_ref"}),t.plan_ref!==void 0&&t.plan_ref.hash!==t.plan_hash&&e.addIssue({code:"custom",path:["plan_ref"],message:"plan_ref must match plan_hash"}),t.prepared_plan!==void 0&&(t.prepared_plan.source.type!=="task"||t.prepared_plan.source.task_id!==t.id||t.prepared_plan.hash!==t.plan_hash)&&e.addIssue({code:"custom",path:["prepared_plan"],message:"prepared_plan must belong to the Task and match plan_hash"}),["completed","failed","cancelled"].includes(t.status)&&(t.finished_at===null||t.result===null)&&e.addIssue({code:"custom",message:"terminal Task requires finished_at and result"}),["executing","verifying","completed"].includes(t.status)&&t.started_at===null&&e.addIssue({code:"custom",message:`${t.status} Task requires started_at`}),t.status==="completed"&&(t.result?.completed_run_id===null||t.result?.evidence_ids.length===0)&&e.addIssue({code:"custom",path:["result"],message:"completed Task requires completed_run_id and at least one Evidence"}),at(t.requirement_ids,"requirement_ids",e),at(t.acceptance_ids,"acceptance_ids",e),at(t.depends_on,"depends_on",e),at(t.write_scopes,"write_scopes",e)}),_e=class{constructor(e,n){this.filesystem=e;this.layout=n;if(n.version===1)throw new TypeError("TaskV2Repository requires a modern WorkspaceLayout")}filesystem;layout;async read(e){let n=await ce(this.filesystem,this.layout,"task",e);if(n===null)throw new Error(`task not found: ${e}`);let r=P(await this.filesystem.readText(n),K);return{task:r.metadata,body:r.body}}async list(){let e=await this.filesystem.listFiles(this.layout.entityRoot("task"),".md");return Promise.all(e.map(async n=>P(await this.filesystem.readText(n),K).metadata))}async createDraft(e){if(e.modelProfile&&e.modelProfile.risk!==e.risk)throw new Error("Task model profile risk differs from Task risk");let r=(e.clock??new T).now().toISOString(),o=K.parse({schema_version:2,id:e.id,revision:1,change_id:e.changeId,title:e.title,short_name:e.shortName,objective:e.objective,target_release:e.targetRelease??null,status:"draft",attempt_count:0,risk:e.risk,...e.modelProfile===void 0?{}:{model_profile:e.modelProfile},priority:e.priority,owner:e.owner??null,requirement_ids:[...e.requirementIds],acceptance_ids:[...e.acceptanceIds],depends_on:[...e.dependsOn??[]],write_scopes:[...e.writeScopes??[]],plan_revision:null,plan_hash:null,created_at:r,updated_at:r,started_at:null,finished_at:null,result:null,assurance_risk_signals:Xr(e.risk,e.assuranceRiskSignals),assurance_risk_signals_source:e.assuranceRiskSignals===void 0?"risk_default":"explicit"});return await this.filesystem.writeTextExclusive(this.path(o.id),this.serialize(o)),o}async setPreparedPlan(e,n){let r=W.parse(n);if(r.source.type!=="task"||r.source.task_id!==e)throw new TypeError(`Prepared plan source must be task ${e}`);let o=await this.read(e);if(o.task.status==="planned"&&o.task.prepared_plan?.hash===r.hash)return o.task;if(o.task.status!=="draft")throw new Error(`Task ${e} must be draft before prepare`);let a=r.blueprints.tasks.find(d=>d.id===e);if(a===void 0)throw new Error(`Prepared plan does not contain Task ${e}`);let s=[a.change_id===o.task.change_id?null:"change_id",a.title===o.task.title?null:"title",a.short_name===o.task.short_name?null:"short_name",a.objective===o.task.objective?null:"objective",a.risk===o.task.risk?null:"risk",a.priority===o.task.priority?null:"priority",a.owner===o.task.owner?null:"owner",ot(a.requirement_ids,o.task.requirement_ids)?null:"requirement_ids",ot(a.acceptance_ids,o.task.acceptance_ids)?null:"acceptance_ids",ot(a.write_scopes,o.task.write_scopes)?null:"write_scopes"].filter(d=>d!==null),l=r.dag.nodes.find(d=>d.task_id===e);if((l===void 0||!ot(l.depends_on,o.task.depends_on))&&s.push("depends_on"),s.length>0)throw new Error(`Prepared plan diverges from Task draft: ${s.join(", ")}`);let c=K.parse({...o.task,revision:o.task.revision+1,status:"planned",plan_revision:r.revision,plan_hash:r.hash,prepared_plan:r,...a.model_profile===void 0?{}:{model_profile:a.model_profile},updated_at:r.prepared_at});return await this.write(c),c}async write(e,n=Dn(e)){await this.filesystem.writeTextAtomic(this.path(e.id),this.serialize(e,n))}async normalizePreparedPlan(e,n){let r=await this.read(e);if(r.task.plan_ref?.hash===n.hash)return r.task;if(r.task.prepared_plan?.hash!==n.hash)throw new Error(`Task ${e} does not contain PreparedPlan ${n.hash}`);let{prepared_plan:o,...a}=r.task,s=K.parse({...a,revision:r.task.revision+1,plan_ref:Me(n),updated_at:new Date().toISOString()});return await this.write(s),s}async normalizeBody(e){let n=await this.read(e);return await this.write(n.task),n.task}serialize(e,n=Dn(e)){return F({metadata:K.parse(e),body:n})}async transition(e,n,r=null,o=new T,a=null){let s=await this.read(e);if(!no[s.task.status].includes(n))throw new Error(`Invalid Task transition: ${s.task.status} -> ${n}`);let l=K.parse(zn(s.task,n,r,o.now().toISOString(),a));return await this.write(l),l}async recoverOwnCompletionGateBlock(e,n,r=new T){let o=await this.read(e);to(o.task,n);let a=K.parse(zn(o.task,"executing",null,r.now().toISOString(),null,!0));return await this.write(a),a}path(e){return this.layout.activePath("task",e)}},qe=class extends Error{name="MaterializationCollisionError"},Wt=class t{constructor(e,n){this.filesystem=e;this.layout=n;if(n.version===1)throw new TypeError("PreparedPlanV2Materializer requires a modern WorkspaceLayout");this.changes=new oe(e,n),this.tasks=new _e(e,n),this.executions=new Q(e,n)}filesystem;layout;static activeMaterializations=new Map;changes;tasks;executions;activeNormalizations=new Map;async execute(e){let n=`${this.filesystem.root}:${e.hash}`,r=t.activeMaterializations.get(n);if(r!==void 0)return r;let o=this.executeInternal(e);t.activeMaterializations.set(n,o);try{return await o}finally{t.activeMaterializations.get(n)===o&&t.activeMaterializations.delete(n)}}async executeInternal(e){let n=W.parse(e),r=fc(n),o=[...r.changes.map(f=>({kind:"change",id:f.id,path:this.changes.path(f.id),content:this.changes.serialize(f)})),...r.tasks.map(f=>({kind:"task",id:f.id,path:this.tasks.path(f.id),content:this.tasks.serialize(f)})),{kind:"execution",id:r.execution.id,path:this.executions.path(r.execution.id),content:this.executions.serialize(r.execution)}],a=[],s=[],l=[],c=!1;for(let f of o){let h=await ce(this.filesystem,this.layout,f.kind,f.id);if(h===null){a.push(f);continue}if(h!==f.path)throw new qe(`${f.kind} ${f.id} collides with inactive layout path ${h}`);let w=await this.filesystem.readText(h);if(w!==f.content){if(f.kind==="execution"){let y=P(w,O).metadata;if(y.kind==="delivery"&&y.plan_hash===null&&y.plan_revision===null&&JSON.stringify(y.origin)===JSON.stringify(r.execution.origin)){c=!0,s.push(f.path);continue}}if(f.kind==="change"){let y=r.changes.find(v=>v.id===f.id),g=y===void 0?null:_c(w,y);if(y!==void 0&&g!==null){g==="draft"&&l.push(y),s.push(f.path);continue}}if(f.kind==="task"&&n.source.type==="task"&&f.id===n.source.task_id&&ro(w,n)){s.push(f.path);continue}throw new qe(`${f.kind} ${f.id} already exists with divergent content`)}s.push(f.path)}let d=[],m=[],u=!1;try{u=await this.persistPreparedPlan(n);for(let f of a)try{await this.filesystem.writeTextExclusive(f.path,f.content),d.push(f),m.push(f.path)}catch(h){if(!await gc(this.filesystem,f,h,n))throw h;s.push(f.path)}for(let f of l)await this.changes.promoteDraft(f.id,f);c&&await this.executions.promoteDeliveryIntake(r.execution.id,r.execution)}catch(f){throw await Yr(this.filesystem,d),u&&await this.removePreparedPlan(n),f}let _=(await this.executions.read(n.execution_id)).execution;try{await this.normalizeSource(n)}catch(f){throw u&&await this.removePreparedPlan(n),f}let p=await Promise.all(r.tasks.map(async f=>(await this.tasks.read(f.id)).task));return{execution:_,changes:await Promise.all(r.changes.map(async f=>(await this.changes.read(f.id)).change)),tasks:p,created_paths:m,reused_paths:s}}async readPreparedPlan(e){return W.parse(JSON.parse(await this.filesystem.readText(this.preparedPlanPath(e))))}preparedPlanPath(e){let n=this.executions.path(e);if(!n.endsWith("/execution.md"))throw new TypeError(`Execution path is not canonical: ${n}`);return`${n.slice(0,-12)}prepared-plan.json`}async persistPreparedPlan(e){let n=this.preparedPlanPath(e.execution_id),r=`${JSON.stringify(e,null,2)}
|
|
136
|
+
`;try{return await this.filesystem.writeTextAtomicExclusive(n,r),!0}catch(o){if(!Nn(o))throw o;let a=W.parse(JSON.parse(await this.filesystem.readText(n)));if(JSON.stringify(a)!==JSON.stringify(e))throw new qe(`PreparedPlan ${e.hash} collides with divergent execution payload ${e.execution_id}`);return!1}}async removePreparedPlan(e){let n=this.preparedPlanPath(e.execution_id);if(!await this.filesystem.exists(n))return;let r=W.parse(JSON.parse(await this.filesystem.readText(n)));JSON.stringify(r)===JSON.stringify(e)&&await this.filesystem.removeFile(n)}async normalizeSource(e){let n=this.activeNormalizations.get(e.hash);if(n!==void 0)return n;let r=(async()=>{e.source.type==="task"?await this.tasks.normalizePreparedPlan(e.source.task_id,e):e.source.type==="spec"?await new Ie(this.filesystem,this.layout).normalizePreparedPlan(e.source.spec_id,e):await new Ae(this.filesystem,this.layout).normalizePreparedPlan(e.source.prd_id,e)})();this.activeNormalizations.set(e.hash,r);try{await r}finally{this.activeNormalizations.delete(e.hash)}}};function ro(t,e){try{let n=P(t,K).metadata;return n.status==="planned"&&(n.prepared_plan?.hash===e.hash||n.plan_ref?.hash===e.hash)&&n.plan_hash===e.hash&&n.id===(e.source.type==="task"?e.source.task_id:"")}catch{return!1}}function _c(t,e){try{let n=P(t,H).metadata,r=n.status==="draft"||n.status==="planned"?n.status:null;return r!==null&&n.id===e.id&&n.title===e.title&&n.risk===e.risk&&JSON.stringify(n.source)===JSON.stringify(e.source)&&n.requirement_ids.every(a=>e.requirement_ids.includes(a))&&n.acceptance_ids.every(a=>e.acceptance_ids.includes(a))&&n.task_ids.every(a=>e.task_ids.includes(a))?r:null}catch{return null}}function fc(t){let e=new Map(t.dag.nodes.map(s=>[s.task_id,s])),n=new Map(t.blueprints.tasks.map(s=>[s.id,s])),r=t.blueprints.tasks.map(s=>{let l=e.get(s.id);if(l===void 0)throw new Error(`Prepared DAG does not contain ${s.id}`);return K.parse({schema_version:2,id:s.id,revision:1,change_id:s.change_id,title:s.title,short_name:s.short_name,objective:s.objective,status:"planned",risk:s.risk,priority:s.priority,owner:s.owner,requirement_ids:s.requirement_ids,acceptance_ids:s.acceptance_ids,depends_on:l.depends_on,write_scopes:s.write_scopes,...s.runtime===void 0?{}:{runtime:s.runtime},...s.model_profile===void 0?{}:{model_profile:s.model_profile},plan_revision:t.revision,plan_hash:t.hash,...t.source.type==="task"&&t.source.task_id===s.id?{prepared_plan:t}:{},created_at:t.prepared_at,updated_at:t.prepared_at,started_at:null,finished_at:null,result:null})}),o=t.blueprints.changes.map(s=>H.parse({schema_version:2,id:s.id,revision:1,title:s.title,status:"planned",risk:s.risk,source:s.source,requirement_ids:s.requirement_ids,acceptance_ids:s.acceptance_ids,requirement_impact:s.requirement_impact,task_ids:r.filter(l=>l.change_id===s.id).map(l=>l.id),plan_revision:t.revision,plan_hash:t.hash,created_at:t.prepared_at,updated_at:t.prepared_at,started_at:null,finished_at:null,result:null})),a=O.parse({schema_version:2,id:t.execution_id,revision:1,kind:"delivery",client_turn_id:null,origin:t.source,status:"planned",plan_revision:t.revision,plan_hash:t.hash,policy:t.policy,dag:{nodes:t.dag.nodes.map(s=>({task_id:s.task_id,change_id:n.get(s.task_id)?.change_id,depends_on:s.depends_on})),topological_order:t.dag.topological_order},created_at:t.prepared_at,updated_at:t.prepared_at,started_at:null,finished_at:null,result:null});return{changes:o,tasks:r,execution:a}}async function gc(t,e,n,r){if(!Nn(n)||!await t.exists(e.path))return!1;let o=await t.readText(e.path);if(o===e.content||e.kind==="task"&&r.source.type==="task"&&e.id===r.source.task_id&&ro(o,r))return!0;throw new qe(`${e.kind} ${e.id} was created concurrently with divergent content`)}var Mn=i.string().datetime({offset:!0}),Iw=i.object({id:i.string().startsWith("TASK-"),title:i.string().min(1),short_name:i.string().min(1),status:i.enum(["draft","planned","executing","verifying","completed","failed","blocked","cancelled"]),risk:i.enum(["lite","standard","critical"]),priority:i.enum(["low","medium","high","urgent"]),owner:i.string().min(1).nullable().default(null),progress:i.number().int().min(0).max(100),spec:i.string().startsWith("SPEC-"),change:i.string().startsWith("CHG-"),requirements:i.array(i.string().startsWith("REQ-")),depends_on:i.array(i.string().startsWith("TASK-")),human_decisions:i.array(i.string().startsWith("DEC-HUMAN-")),agent_decisions:i.array(i.string().startsWith("DEC-AI-")),created_at:Mn,started_at:Mn.nullable(),finished_at:Mn.nullable()}).strict();function oo(t,e){let n=e.projectConfig?.tracking.storage_mode??"tracked_sanitized";return{filesystem:t,layout:e,prds:new Ae(t,e),specs:new Ie(t,e),changes:new oe(t,e),tasks:new _e(t,e),executions:new Q(t,e),materializer:new Wt(t,e),decisions:new ti(t,e),runs:new G(t,n==="local_only"?{storageMode:"local_only",localBasePath:".agents/private/state/runs"}:{storageMode:"tracked_sanitized",layout:e})}}import{createHash as Sc}from"node:crypto";import{lstat as bc}from"node:fs/promises";import{lstat as hc,mkdir as Jw,readFile as Bw,realpath as yc,writeFile as Kw}from"node:fs/promises";import{dirname as Zw,isAbsolute as vc,relative as wc,resolve as Fn}from"node:path";async function $e(t,e,n=!1){let r=Fn(t,e),o=wc(t,r);if(!o||o.startsWith("..")||vc(o))throw new x("Preservation path escaped its root");let a=o.split(/[\\/]/),s=Fn(t);for(let l=-1;l<a.length;l++){l>=0&&(s=Fn(s,a[l]));let c;try{c=await hc(s)}catch(u){if(n&&u.code==="ENOENT")return r;throw u}let d=await yc(s),m=u=>process.platform==="win32"?u.toLowerCase():u;if(c.isSymbolicLink()||m(d)!==m(s)||(l<a.length-1?!c.isDirectory():!c.isFile()||c.nlink!==1))throw new x("Preservation refuses links, aliases or nonregular files")}return r}var Ln=".agents/private/state/task-workspaces/record-origin-admission.json";async function xc(t){if(!await t.exists(Ln))return null;let e=await $e(t.root,Ln);if((await bc(e)).size>16384)throw new x("Legacy origin admission exceeds bounded metadata size");let n=await t.readText(Ln),r=JSON.parse(n),o=r?.origin;if(r?.schema_version!==1||r?.kind!=="legacy_origin_admission"||o?.schema_version!==1||o?.kind!=="legacy_record_origin"||typeof o.canonical_workspace!="string"||!M(o.canonical_workspace,t.root)||!/^TASK-[A-Z0-9-]+$/.test(o.task_id)||!/^CHG-[A-Z0-9-]+$/.test(o.change_id)||!/^EXEC-[A-Z0-9-]+$/.test(o.execution_id)||!/^RUN-[A-Z0-9-]+$/.test(o.run_id))throw new x("Unknown legacy origin admission must be preserved before reconciliation");return await J(o.records_workspace,t.root),{source:n,origin:o}}async function ao(t,e){let n=await xc(t);if(n&&e.some(r=>[n.origin.task_id,n.origin.change_id,n.origin.execution_id,n.origin.run_id].includes(r)))throw new x("legacy_worktree_lifecycle_requires_recovery: origin admission is incomplete; retry its exact authenticated task workspace command before reading canonical copies")}function kc(t,e){if(!(t==="tasks"?/^TASK-[A-Z0-9-]+$/:t==="runs"?/^RUN-[A-Z0-9-]+$/:t==="changes"?/^CHG-[A-Z0-9-]+$/:/^EXEC-[A-Z0-9-]+$/).test(e))throw new x("Invalid legacy origin identity");return`.agents/private/state/task-workspaces/record-origins/${t}/${e}.json`}async function so(t,e,n){let r=kc(e,n);if(!await t.exists(r))return null;await $e(t.root,r);let o=await t.readText(r);if(Buffer.byteLength(o)>16384)throw new x("Legacy record origin exceeds bounded metadata size");let a=JSON.parse(o);if(a.schema_version!==1||a.kind!=="legacy_record_origin"||typeof a.canonical_workspace!="string"||!M(a.canonical_workspace,t.root)||!/^TASK-[A-Z0-9-]+$/.test(a.task_id)||!/^EXEC-[A-Z0-9-]+$/.test(a.execution_id)||!/^CHG-[A-Z0-9-]+$/.test(a.change_id)||!/^RUN-[A-Z0-9-]+$/.test(a.run_id)||(e==="tasks"?a.task_id!==n:e==="runs"?a.run_id!==n:e==="changes"?a.change_id!==n:a.execution_id!==n)||!Array.isArray(a.records_baseline)||a.records_baseline.length!==3||new Set(a.records_baseline.map(s=>s.path)).size!==3||a.records_baseline.some(s=>typeof s.path!="string"||!s.path||/(?:^|\/)\.\.(?:\/|$)|[:\\\0]/.test(s.path)||s.path.startsWith("/")||s.sha256!==null&&!/^[a-f0-9]{64}$/.test(s.sha256)))throw new x("Legacy record origin is incompatible; preserve it before reconciliation");return await J(a.records_workspace,t.root),a}function jn(t,e){return new G(t,e.projectConfig?.tracking.storage_mode==="local_only"?{storageMode:"local_only",localBasePath:".agents/private/state/runs"}:{storageMode:"tracked_sanitized",layout:e})}async function Ut(t,e,n){let r=await xt(t);await J(t,r);let o=new I(r),a=await Ne(o);await ao(o,[n]);let s=await so(o,e,n);if(!s)return{filesystem:o,layout:a,primaryRoot:r,legacy:!1};let l=new I(await J(s.records_workspace,r)),c=await Ne(l);if(c.version===1||a.version===1||c.version!==a.version||c.projectConfig?.zaip?.enabled!==!0||a.projectConfig?.zaip?.enabled!==!0||c.projectConfig.project.id!==a.projectConfig.project.id||!M(s.canonical_workspace,r))throw new x("Legacy record source requires matching enabled project identities and layouts");let d=new _e(l,c),m=new oe(l,c),u=new Q(l,c),_=[d.path(s.task_id),m.path(s.change_id),u.path(s.execution_id)];if(s.records_baseline.some(w=>!_.includes(w.path)))throw new x("Legacy record baseline contains a path outside its exact graph");for(let w of s.records_baseline){let y=await o.exists(w.path)?await o.readText(w.path):null;if((y===null?null:Sc("sha256").update(y).digest("hex"))!==w.sha256)throw new x("Legacy record source conflicts with its preserved canonical baseline")}let{task:p}=await d.read(s.task_id),{change:f}=await m.read(s.change_id),{execution:h}=await u.read(s.execution_id);if(p.id!==s.task_id||f.id!==s.change_id||h.id!==s.execution_id||p.change_id!==f.id||(p.plan_ref?.execution_id??p.prepared_plan?.execution_id)!==h.id||f.source.type!=="task"||f.source.task_id!==p.id||f.task_ids.length!==1||f.task_ids[0]!==p.id||h.kind!=="delivery"||h.origin.type!=="task"||h.origin.task_id!==p.id||h.dag.nodes.length!==1||h.dag.nodes[0]?.task_id!==p.id||h.dag.nodes[0]?.change_id!==f.id)throw new x("Legacy record source has an inconsistent Task/Change/Execution graph");if(e==="runs"){let w=jn(l,c),y=await w.read(n);if(y.run.task_id!==s.task_id||y.run.execution_id!==s.execution_id||y.run.change_id!==s.change_id||await o.exists(jn(o,a).path(n)))throw new x("Legacy source Run conflicts with its exact graph binding or canonical copy")}return{filesystem:l,layout:c,primaryRoot:r,legacy:!0}}import{createHash as Ac}from"node:crypto";import{createHash as Ec}from"node:crypto";import{homedir as Cc}from"node:os";import{join as Tc,relative as Rc}from"node:path";async function co(t,e,n=Tc(Cc(),".codex")){if(!e.transcriptPath||!e.clientThreadId||!e.clientTurnId)throw new x("Principal continuation requires its observed transcript");let r=Rc(n,e.transcriptPath).replaceAll("\\","/");if(!/^sessions\/\d{4}\/\d{2}\/\d{2}\/[A-Za-z0-9._-]+\.jsonl$/.test(r)||!r.includes(e.clientThreadId))throw new x("Principal continuation transcript identity differs");let o=await je(new I(n),r,e.clientTurnId);if(!o||o.model!==e.observedModel||o.reasoningEffort!==e.observedReasoningEffort)throw new x("Principal continuation native context is unavailable or changed");return Ec("sha256").update(JSON.stringify({session:e.clientThreadId,turn:e.clientTurnId,...o})).digest("hex")}var lo=t=>Ac("sha256").update(t).digest("hex"),Ic=(t,e,n)=>`.agents/private/state/codex-principal-continuations/v2/${lo(JSON.stringify([t,e,n]))}.json`;function Pc(t){let e=t.run;return t.status==="running"&&t.finished===null&&t.finalization_decision==null&&e.parent_run_id===null&&e.agent==="agent-orchestrator"&&e.run_role==="orchestrator"&&e.entrypoint==="task"&&e.execution_kind==="delivery"&&["codex","codex-desktop"].includes(e.client)&&!!e.task_id&&!!e.change_id&&!!e.execution_id&&e.spec_id===null&&e.prd_id===null}async function qc(t,e){if(!Pc(t))throw new x("Root Task continuation requires its active orchestrator owner");let n=t.run,{task:r}=await e.tasks.read(n.task_id),{change:o}=await e.changes.read(n.change_id),{execution:a}=await e.executions.read(n.execution_id),s=await e.runs.list();if(!["executing","verifying"].includes(r.status)||r.id!==n.task_id||r.change_id!==n.change_id||r.plan_ref?.execution_id!==a.id||r.plan_ref.hash!==a.plan_hash||!["executing","verifying"].includes(o.status)||o.id!==n.change_id||o.source.type!=="task"||o.source.task_id!==r.id||o.task_ids.length!==1||o.task_ids[0]!==r.id||a.id!==n.execution_id||a.kind!=="delivery"||!["running","verifying"].includes(a.status)||a.origin.type!=="task"||a.origin.task_id!==r.id||a.dag.nodes.length!==1||a.dag.nodes[0]?.task_id!==r.id||a.dag.nodes[0]?.change_id!==o.id||s.some(u=>u.run.run_id!==n.run_id&&u.finished===null&&u.run.agent==="agent-orchestrator"&&(u.run.task_id===r.id||u.run.execution_id===a.id)))throw new x("Root Task continuation requires sole exact Task/Change/Execution ownership");let l=await Ut(e.filesystem.root,"runs",n.run_id);if(!M(l.filesystem.root,e.filesystem.root))throw new x("Root Task continuation must read its verified original record source");let c=new I(l.primaryRoot);await $e(c.root,".agents/private/state/task-workspaces/shared-writer.json");let d=await c.readText(".agents/private/state/task-workspaces/shared-writer.json"),m=JSON.parse(d);if(m.mode!=="shared"||m.status!=="ready"||m.branch!==null||m.run_id!==n.run_id||m.task_id!==r.id||m.execution_id!==a.id||typeof m.path!="string"||!M(m.path,l.primaryRoot)||typeof m.canonical_workspace!="string"||!M(m.canonical_workspace,l.primaryRoot)||(l.legacy?typeof m.records_workspace!="string"||!M(m.records_workspace,e.filesystem.root):m.records_workspace!==void 0)||!/^[a-f0-9]{40}$/.test(m.base_commit??""))throw new x("Root Task continuation writer claim differs");return{claim_sha256:lo(d),task:r,execution:a}}function $c(t,e){return!!e.clientThreadId&&!!e.clientTurnId&&e.clientThreadId===t.run.client_thread_id&&e.clientTurnId!==t.run.client_turn_id&&!!e.observedModel&&e.observedModel===t.run.model&&!!e.observedReasoningEffort&&e.observedReasoningEffort===t.run.reasoning_effort}async function Vc(t,e,n,r){if(!$c(t,e))throw new x("Root Task continuation requires the same session/model/effort and a new observed turn");let o=await qc(t,n);return{schema_version:2,kind:"root_task",principal_run_id:t.run.run_id,task_owner_run_id:t.run.run_id,task_id:t.run.task_id,change_id:t.run.change_id,execution_id:t.run.execution_id,spec_id:null,prd_id:null,session_id:e.clientThreadId,original_turn_id:t.run.client_turn_id,previous_turn_id:t.run.client_turn_id,turn_id:e.clientTurnId,model:e.observedModel,reasoning_effort:e.observedReasoningEffort,claim_sha256:o.claim_sha256,context_sha256:await co(n.filesystem,e,r)}}async function uo(t,e,n,r){try{let o=await Vc(t,e,n,r),a=await n.filesystem.readText(Ic(t.run.run_id,e.clientThreadId,e.clientTurnId));return Buffer.byteLength(a)<=8192&&a===`${JSON.stringify(o)}
|
|
137
|
+
`}catch{return!1}}function ae(t){throw Error(`publication_native_capability_missing:${t}`)}async function po(t,e){let n=await Ut(t,"runs",e),r=new G(n.filesystem,n.layout.projectConfig?.tracking.storage_mode==="local_only"?{storageMode:"local_only",localBasePath:".agents/private/state/runs"}:{storageMode:"tracked_sanitized",layout:n.layout});return{source:n,fold:await r.read(e)}}function mo(t){let e=t.run;(e.parent_run_id!==null||e.run_role!=="orchestrator"||!["codex","codex-desktop"].includes(e.client)||e.attribution_status!=="attributed"||e.spec_id!==null||e.prd_id!==null)&&ae("unsupported_source_graph_use_exact_standalone_or_git_only_adapter");let n=e.entrypoint==="conversation"&&e.execution_kind==="interaction"&&e.task_id===null&&e.change_id===null,r=e.entrypoint==="task"&&e.execution_kind==="delivery"&&e.task_id!==null&&e.change_id!==null;return!n&&!r&&ae("unsupported_source_run_kind"),{gitOnly:n,task:r}}async function _o(t,e,n,r,o){let a=await po(t,e),s=a.fold.run,l=mo(a.fold);(a.fold.finished||a.fold.finalization_decision||s.client_thread_id!==n.clientThreadId||s.model!==n.observedModel||s.reasoning_effort!==n.observedReasoningEffort)&&ae("source_run_mismatch_or_terminal"),s.client_turn_id!==n.clientTurnId&&(!l.task||!await uo(a.fold,n,oo(a.source.filesystem,a.source.layout),o))&&ae("authenticated_same_run_turn_continuation_required");let c=Oc("sha256").update($(r)).digest("hex"),d=a,m=new Set;for(let u=0;u<16;u++){let _=d.fold.run;m.has(_.run_id)&&ae("continuation_cycle"),m.add(_.run_id),mo(d.fold);let p=St(d.source.primaryRoot,_.run_id);if(p&&p.request_sha256===c)return{current:a,origin:d,kind:l,binding:p};if(_.client_turn_id===n.clientTurnId&&$(n.userMessage??"")===$(r)||!_.continuation_of_run_id&&l.task&&$(_.direct_execution_authorization??"")===$(r))return{current:a,origin:d,kind:l,binding:null};_.continuation_of_run_id||ae("original_binding_or_canonical_successor_missing");let f=await po(t,_.continuation_of_run_id),h=f.fold.run;(!f.fold.finished||h.client_thread_id!==s.client_thread_id||h.task_id!==s.task_id||h.change_id!==s.change_id||h.execution_id!==s.execution_id||h.conversation_id!==s.conversation_id)&&ae("continuation_graph_mismatch"),d=f}return ae("continuation_chain_limit")}import{AsyncLocalStorage as Nc}from"node:async_hooks";import{createHash as Dc,randomUUID as zc}from"node:crypto";import{lstat as Wn,readFile as Mc,realpath as fo,rename as Fc,unlink as Lc}from"node:fs/promises";import{homedir as jc}from"node:os";import{dirname as go,resolve as st}from"node:path";var Wc=new Nc;async function ho(t,e,n={}){let r=Wc.getStore();if(r&&r.root===t.root&&r.client===e&&r.argv===JSON.stringify(n.argv??process.argv.slice(2))&&(n.threadId===void 0||Ht(n.threadId)===r.value.clientThreadId)&&(n.turnId===void 0||Ht(n.turnId)===r.value.clientTurnId))return r.value;if(!new Set(["codex","codex-desktop"]).has(e))return{clientThreadId:null,clientTurnId:null,userMessage:null,observedModel:null,observedReasoningEffort:null,observedServiceTier:null};let o=n.argv??process.argv.slice(2),a=Ki(t.root),s=o.filter(v=>v.startsWith("--codex-hook-")),l=s.length>0,c=s.filter(v=>v.startsWith("--codex-hook-thread=")),d=c[0]?.slice(20),m=Ht(n.threadId??process.env.CODEX_THREAD_ID);if(l&&(s.length!==2||c.length!==1||!d||!/^[A-Za-z0-9_-]{1,256}$/.test(d)||m!==null&&m!==d))throw new Error("Codex hook identity is incomplete or conflicts with the active thread.");let u=m??d??null,_=Ht(n.turnId??process.env.CODEX_TURN_ID),p=l&&u!==null?await Uc(a,u,o,n.now??new Date):null,f=p?.turnId??null;if(l&&(f===null||_!==null&&_!==f))throw new Error("Codex hook turn receipt is missing, consumed, expired or conflicts with the active turn.");let h=l?f:_,w=Hc(),y=await ee(a,{threadId:u,includeWorkspaceRoot:!0,...w===null?{}:{transcriptPath:w},...n.sessionsRoot===void 0?{}:{sessionsRoot:n.sessionsRoot},...n.now===void 0?{}:{now:n.now}}),g=h===null||y?.turnId===h?y:null;return{...kt()&&g?.workspaceRoot?{nativeWorkspace:g.workspaceRoot}:{},...p?.nativePrincipal===void 0?{}:{nativePrincipal:p.nativePrincipal},clientThreadId:u??g?.sessionId??null,clientTurnId:h??y?.turnId??null,userMessage:g?.userMessage??null,observedModel:g?.model??null,observedReasoningEffort:g?.reasoningEffort??null,observedServiceTier:g?.serviceTier??null,transcriptPath:w??(g?st(n.sessionsRoot??st(jc(),".codex"),g.sessionPath):null)}}async function Uc(t,e,n,r){let o=n.filter(u=>u.startsWith("--codex-hook-id="));if(o.length!==1)return null;let a=o[0]?.slice(16);if(!a||!/^[a-f0-9]{64}$/.test(a))return null;let s=n.filter(u=>!u.startsWith("--codex-hook-")),l=Dc("sha256").update(JSON.stringify(s)).digest("hex"),c=st(t,".agents/private/state/codex-hook-turn/v1",`${a}.json`);if(s[0]==="task"&&s[1]==="storage-handoff"){let u=st(t,".local/codex-hook-turn/v1",`${a}.json`),_=async p=>Wn(p).then(()=>!0,f=>{if(f.code==="ENOENT")return!1;throw f});if(await _(u)){if(await _(c))return null;c=u}}let d=`${c}.${zc()}.consumed`,m=!1;try{for(let h=c;;h=go(h)){let w=await Wn(h),y=await fo(h),g=process.platform==="win32"?y.toLowerCase()===h.toLowerCase():y===h;if(w.isSymbolicLink()||!g||(h===c?!w.isFile()||w.nlink!==1:!w.isDirectory()))return null;if(h===st(t))break;if(go(h)===h)return null}await Fc(c,d),m=!0;let u=await Wn(d);if(!u.isFile()||u.isSymbolicLink()||u.nlink!==1||u.size>2048)return null;let _=await fo(d);if(process.platform==="win32"?_.toLowerCase()!==d.toLowerCase():_!==d)return null;let p=JSON.parse(await Mc(d,"utf8")),f=r.getTime()-Number(p.observed_at_ms);return p.schema_version!==1||p.thread_id!==e||typeof p.turn_id!="string"||!p.turn_id||p.turn_id.length>256||p.tool_use_sha256!==a||p.argv_sha256!==l||p.native_principal!==void 0&&typeof p.native_principal!="boolean"||!Number.isFinite(f)||f<-5e3||f>6e4?null:{turnId:p.turn_id,...p.native_principal===void 0?{}:{nativePrincipal:p.native_principal}}}catch{return null}finally{m&&await Lc(d).catch(()=>{})}}function Hc(){let t=process.env.CODEX_TRANSCRIPT_PATH?.trim();return t===void 0||t.length===0||t.length>4096?null:t}function Ht(t){let e=t?.trim();return e===void 0||e.length===0?null:e}var vo=new WeakMap;function pn(t){let e=vo.get(t);return(!e||!Un.has(t))&&j("verified_native_source_required"),e}var yo=new Map,Ve=new Jc;function gx(t,e){return Ve.run({sessionsRoot:t.sessionsRoot},e)}var Un=new WeakSet,se=t=>Bc("sha256").update(t).digest("hex");function j(t){throw new Error(`publication_native_capability_missing:${t}`)}async function Yi(t,e,n){let r=await Kc(t),o=new I(r);/^RUN-[A-Z0-9-]+$/.test(n??"")||j("exact_source_run_required");let a=JSON.stringify([r,n,process.argv.slice(2),Ve.getStore()]),s=yo.get(a);if(!s){let v=await ho(o,"codex",Ve.getStore());if(!v.nativePrincipal||!v.clientThreadId||!v.clientTurnId||!v.observedModel||!v.observedReasoningEffort||!v.transcriptPath){let b=Object.entries({native_principal:!!v.nativePrincipal,client_thread:!!v.clientThreadId,client_turn:!!v.clientTurnId,observed_model:!!v.observedModel,observed_reasoning_effort:!!v.observedReasoningEffort,transcript_path:!!v.transcriptPath}).filter(([,E])=>!E).map(([E])=>E);j(`observed_principal_receipt_required:missing=${b.join(",")}`)}s={thread:v.clientThreadId,turn:v.clientTurnId,model:v.observedModel,effort:v.observedReasoningEffort,transcript:v.transcriptPath,principal:v.nativePrincipal},yo.set(a,s)}let l={...Ve.getStore(),threadId:s.thread,transcriptPath:s.transcript,includeHumanMessages:!0,includeWorkspaceRoot:!0},d=await ee(r,l);(!d||d.sessionId!==s.thread||d.turnId!==s.turn||d.model!==s.model||d.reasoningEffort!==s.effort||!d.workspaceRoot||!d.humanMessages?.length)&&j("fresh_transcript_context_required");let m=await _o(r,n,{clientThreadId:s.thread,clientTurnId:s.turn,observedModel:s.model,observedReasoningEffort:s.effort,observedServiceTier:d.serviceTier??null,userMessage:d.userMessage,transcriptPath:s.transcript,nativePrincipal:s.principal},e,Ve.getStore()?.sessionsRoot),u=m.origin.source,_=m.origin.fold,p=_.run,f=await J(d.workspaceRoot,u.primaryRoot);p.client_turn_id||j("source_turn_missing");let h=await en(r,{...Ve.getStore(),threadId:s.thread,transcriptPath:s.transcript,sourceTurnId:p.client_turn_id,currentTurnId:s.turn});(!h||h.source.model!==p.model||h.source.reasoningEffort!==p.reasoning_effort||h.current.model!==s.model||h.current.reasoningEffort!==s.effort)&&j("complete_original_human_history_required"),m.kind.task&&$(p.direct_execution_authorization??"")!==$(e)&&j("original_human_source_mismatch");let{constraints:w,steering:y}=rr(e,p.client_turn_id,p.task_id,h.messages),g=Object.freeze({binding_id:_n(p.run_id,se($(e)),se(r)),source_run_id:p.run_id,current_run_id:n,current_turn_id:s.turn,source_sha256:se($(e)),steering_sha256:se(JSON.stringify(y)),repository_sha256:se(r),records_workspace_sha256:se(u.filesystem.root),native_workspace_sha256:se(f),client_thread_id:s.thread,client_turn_id:p.client_turn_id,git_only:m.kind.gitOnly,constraints:Object.freeze(w)});return Un.add(g),p.execution_id||j("source_execution_missing"),vo.set(g,Object.freeze({repository:r,primaryRoot:u.primaryRoot,originalTurn:p.run_id===n&&p.client_turn_id===s.turn,currentRunId:n,taskId:p.task_id,changeId:p.change_id,executionId:p.execution_id,request:e,sourceStartedAt:p.occurred_at,sourceFinishedAt:_.finished?.occurred_at??null})),g}async function hx(t,e,n){for(let r of n)r.command!=="node"&&j("git_only_requires_committed_node_harness"),(await sn({repository_path:t,commit_sha:e,executable_path:process.execPath,args:[...r.args]})).status!=="passed"&&j("git_only_candidate_validation_failed")}function yx(t,e){(!t||!Un.has(t)||t.source_sha256!==se($(e)))&&j("verified_native_source_required")}export{Ee as a,G as b,Rs as c,K as d,Ut as e,pn as f,gx as g,Yi as h,hx as i,yx as j,Xi as k,Bu as l};
|