@zaip-ai/cli 6.3.0 → 7.6.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 +13 -11
- package/dist/commands/init.d.ts +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +18 -5
- 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/adapters.d.ts +3 -2
- package/dist/services/adapters.d.ts.map +1 -1
- package/dist/services/adapters.js +34 -143
- 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 +12 -0
- package/dist/services/codex-pre-tool-dependencies.test-support.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 +244 -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 +221 -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 +219 -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 +97 -192
- 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-target-windows.test.d.ts +2 -0
- package/dist/services/install-target-windows.test.d.ts.map +1 -0
- package/dist/services/install-target-windows.test.js +39 -0
- package/dist/services/install-target-windows.test.js.map +1 -0
- package/dist/services/install-target.d.ts +6 -0
- package/dist/services/install-target.d.ts.map +1 -0
- package/dist/services/install-target.js +89 -0
- package/dist/services/install-target.js.map +1 -0
- package/dist/services/install-target.test.d.ts +2 -0
- package/dist/services/install-target.test.d.ts.map +1 -0
- package/dist/services/install-target.test.js +47 -0
- package/dist/services/install-target.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 +37 -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 +3 -1
- package/templates/.agents/README.md +3 -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 +326 -146
- package/templates/.agents/dashboard/apps/frontend/dist/assets/CostCalculationGuidePage-DZ2mnR6k.js +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{DashboardHelpDialog-BQOQCvcJ.js → DashboardHelpDialog-DnxpHJSo.js} +20 -10
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{PricingSettingsDialog-CGET1J8Q.js → PricingSettingsDialog-DsFTUwhL.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-86kLUrXm.js +3 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{TraceabilityWorkspace-Bw6xnXUN.js → TraceabilityWorkspace-BZ1rH1vl.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-BZf8HWmm.js → dashboard-localization-BVBhiAAS.js} +3 -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-C4uiRYHu.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-DFY7ZDlu.css → traceability-s5SzQnzt.css} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/traceability-vQx9R6BQ.js +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/index.html +9 -8
- package/templates/.agents/dashboard/apps/frontend/e2e/release-delivery-fixture.mjs +117 -0
- package/templates/.agents/dashboard/apps/frontend/e2e/release-delivery-lab.mjs +246 -0
- package/templates/.agents/dashboard/apps/frontend/e2e/release-delivery-receipt.mjs +65 -0
- 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 +8 -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/release-delivery.test.tsx +78 -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 +108 -0
- package/templates/.agents/dashboard/apps/frontend/src/use-runtime-status.ts +18 -8
- 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/modules/traceability/src/contracts.ts +11 -0
- package/templates/.agents/dashboard/modules/traceability/src/react/ReleaseDeliveryPanel.tsx +60 -0
- package/templates/.agents/dashboard/modules/traceability/src/react/TaskTracePanel.tsx +9 -57
- package/templates/.agents/dashboard/modules/traceability/src/react/release-delivery-panel.css +26 -0
- package/templates/.agents/dashboard/modules/traceability/src/react/trace-date-format.ts +33 -0
- package/templates/.agents/dashboard/modules/traceability/src/react/trace-stage-labels.ts +28 -0
- 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 +310 -264
- 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 +310 -264
- 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-release-receipt.ts +71 -0
- 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-trace-release-delivery.ts +120 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-trace-routes.ts +5 -4
- 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/stack-dependencies.json +3 -3
- 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 +539 -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/historical-catalog-b6b6516200bdb412c92063e887ccef329d7c5193b5610cba5346e97c71301394.mjs +318 -0
- package/templates/.agents/runtime/bin/zaip.mjs +2262 -768
- package/templates/.agents/runtime/checksums.sha256 +7 -6
- package/templates/.agents/runtime/manifest.json +2 -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 +248 -281
- 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 +169 -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-next-release.mjs +57 -0
- 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 +306 -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 +79 -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-A35CQWF4.mjs +2 -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-CJ5ZQF6M.mjs +11 -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-EQTZ3Y7R.mjs +2 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/publication-proof-runtime/chunks/chunk-FMNUSV2P.mjs +139 -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-LWS3QVJO.mjs +24 -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-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/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 +566 -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 +19 -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/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 +8 -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 +3905 -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-1gE8RHel.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-DZhppOIk.css +0 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-DtLrd13g.js +0 -2
- package/templates/.agents/dashboard/apps/frontend/dist/assets/traceability-DFpwb0TN.js +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,139 @@
|
|
|
1
|
+
import {createRequire as __zaipCreateRequire} from "node:module";const require=__zaipCreateRequire(import.meta.url);
|
|
2
|
+
import{C as gt,D as pi,E as mi,F as Me,H as en,I as _i,J as fi,K as gi,M as he,b as oi,f as ft,j as ai,k as si,l as ci,m as li,n as ze,r as di,v as ui}from"./chunk-LWS3QVJO.mjs";import{A as ee,B as H,C as J,G as D,H as vi,g as ht,h as hi,k as yi,l as Fe,r as Le,w as U}from"./chunk-EQTZ3Y7R.mjs";import{a as Qt,b as T,c as dt,g as Xt,h as ut,j as pt,l as ti,m as ni,n as Ne,o as ge,p as V,q as $,r as j,s as mt,t as ii,u as Yt,v as ri,w as _t,x as De,y as le}from"./chunk-CJ5ZQF6M.mjs";import{Jd as r}from"./chunk-MSCWMPU5.mjs";import{AsyncLocalStorage as cl}from"node:async_hooks";import{createHash as ll}from"node:crypto";import{realpath as dl}from"node:fs/promises";import{lstat as Do,open as zo,realpath as tn,stat as Mo}from"node:fs/promises";import{isAbsolute as Fo,relative as Lo}from"node:path";var No=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"]),yt=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 i=Math.min(this.output.length-this.outputUsed,e.length-n);e.copy(this.output,this.outputUsed,n,n+i),this.outputUsed+=i,n+=i,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 i=0;i<e.length;i++){let o=e[i];if(!this.inString){if(o===34){if(this.emit(e.subarray(n,i)),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&&No.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=i+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 ye=class extends Error{constructor(n){super(`Isolated transcript ${n.path}, line ${n.line}: ${n.code}`);this.diagnostic=n}diagnostic};async function*vt(t,e,n={}){let i=n.maxLineBytes??16777216,o=n.chunkSize??Math.min(256*1024,i);if(![o,i].every(u=>Number.isSafeInteger(u)&&u>0)||o>i)throw new RangeError("Invalid transcript read bounds");let a=t.resolve(e);await t.exists(e);let s=await Do(a),c=await tn(a),l=Lo(await tn(t.root),c);if(!s.isFile()||s.isSymbolicLink()||l===".."||l.startsWith("..\\")||l.startsWith("../")||Fo(l))throw new Error("Unsafe transcript path");let d=await Mo(a,{bigint:!0}),p=await zo(a,"r");try{let u=await p.stat({bigint:!0});if(!(u.dev===d.dev||process.platform==="win32"&&d.dev===0n)||u.ino!==d.ino||u.birthtimeNs!==d.birthtimeNs||await tn(a)!==c)throw new Error("Transcript identity changed during open");let _={size:Number(u.size)};if(!Number.isSafeInteger(_.size))throw new RangeError("Transcript snapshot size is not safely addressable");let m=0,h=0,v=1,y=0,g=null,b=[],w=C=>{if(h+=C.length,h>i&&n.oversizedPolicy!=="project")throw new RangeError(`Transcript record exceeds bounded line size (${i} bytes): ${e}`);if(h>i&&g===null){g=new yt(i);for(let E of b)g.feed(E);b.length=0}g!==null?g.feed(C):C.length&&b.push(C)},x=()=>{if(g!==null){let E=g.finish(),A={path:e,line:v,byteOffset:y,bytes:h,code:g.error??"oversized_record_projected",omittedKeys:[...g.omittedKeys].sort()};if(n.onDiagnostic?.(A),E===null)throw new ye(A);return g=null,v++,y+=h+1,h=0,E}let C=Buffer.concat(b,h);return b.length=0,v++,y+=h+1,h=0,(C.at(-1)===13?C.subarray(0,-1):C).toString("utf8")};for(;m<_.size;){let C=Buffer.allocUnsafe(Math.min(o,_.size-m)),E=0;for(;E<C.length;){let I=await p.read(C,E,C.length-E,m+E);if(!I.bytesRead)throw new Error("Transcript snapshot was truncated during read");E+=I.bytesRead}m+=E;let A=0;for(let I=C.indexOf(10,A);I!==-1;I=C.indexOf(10,A))w(C.subarray(A,I)),yield x(),A=I+1;w(C.subarray(A))}h>0&&(yield x())}finally{await p.close()}}import{open as Ii}from"node:fs/promises";import{homedir as Pi}from"node:os";import{join as qi}from"node:path";function wi(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 z(t){return typeof t=="string"&&t.trim().length>0?t.trim():null}function je(t){let e=t?.payload;if(t?.type==="event_msg"&&e?.type==="user_message"){let s=z(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(c=>c==="user.text"))return null}let i=e.content;if(!Array.isArray(i)){let s=z(i);return s===null?null:{text:s,turnId:typeof n?.turn_id=="string"?n.turn_id:null}}let o=i.flatMap(s=>{let c=R(s);return c!==null&&(c.type==="input_text"||c.type==="text")&&typeof c.text=="string"?[c.text]:[]}).join(`
|
|
3
|
+
`),a=z(o);return a===null?null:{text:a,turnId:typeof n?.turn_id=="string"?n.turn_id:null}}function de(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 te=t=>typeof t=="string"&&t.length<=256?t:null,ve=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 i=R(n?.payload),o=R(i?.internal_chat_message_metadata_passthrough);if(o===null&&typeof i?.internal_chat_message_metadata_passthrough=="string"&&Buffer.byteLength(i.internal_chat_message_metadata_passthrough)<=65536)try{o=R(JSON.parse(i.internal_chat_message_metadata_passthrough))}catch{}let a=o?.content_item_kinds,s=o?.content_item_metadata,c=i?.content;this.messages.push({...e,provenance:{source_record_type:te(n?.type),source_payload_type:te(i?.type),role:te(i?.role),author_kind:te(i?.author_kind),content_item_kinds:Array.isArray(a)&&a.length<=64&&a.every(l=>te(l)!==null)?[...a]:null,metadata_turn_id:te(o?.turn_id),content_item_provenance:Array.isArray(s)&&s.length<=64?s.map(l=>te(R(R(l)?.provenance)?.type)):null,content_types:Array.isArray(c)&&c.length<=64?c.map(l=>te(R(l)?.type)):null}})}select(e){return this.messages.filter(n=>n.turnId===null||n.turnId===e).reverse()}ordered(){return[...this.messages].reverse()}};import{isAbsolute as jo,join as Wo,relative as Uo,resolve as bi,sep as Ho}from"node:path";function xi(t,e=new Date){let n=[];for(let i of[0,1,2]){let o=new Date(e);o.setDate(e.getDate()-i),n.push(Wo(t,"sessions",String(o.getFullYear()),String(o.getMonth()+1).padStart(2,"0"),String(o.getDate()).padStart(2,"0")))}return n}async function ki(t,e){let n=[];for(let i=0;i<t.length;i+=8){let o=await Promise.allSettled(t.slice(i,i+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 Si(t,e,n,i){if(i||!n.size||[...n].every(s=>e.some(c=>c.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(c=>s.includes(c)));if(a.length>128)throw new Error("Exact Codex thread has too many transcript candidates");return[...new Set([...e,...a])].sort()}function we(t,e){if(!e?.trim()||e.length>4096||!jo(e))return null;let n=Uo(bi(t),bi(e)).replace(/\\/g,"/");return n===""||n===".."||n.startsWith(`..${Ho}`)||n.startsWith("../")||!/^sessions\/\d{4}\/\d{2}\/\d{2}\/[A-Za-z0-9._-]+\.jsonl$/u.test(n)?null:n}import{execFile as Jo}from"node:child_process";import{promisify as Bo}from"node:util";var Ko=Bo(Jo);function wt(t){let e=t.replace(/\\/g,"/");return process.platform==="win32"?e.toLowerCase():e}async function Ei(t,e){let n=new Set([wt(t)]);if(e.size!==1)return n;try{let{stdout:i}=await Ko("git",["worktree","list","--porcelain","-z"],{cwd:t,encoding:"utf8",maxBuffer:262144,timeout:5e3,windowsHide:!0});for(let o of i.split("\0"))o.startsWith("worktree ")&&n.add(wt(o.slice(9)))}catch{}return n}async function*be(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 i=e,o=[];for(;i>0;){let a=Math.max(0,i-n),s=Buffer.allocUnsafe(i-a),c=0;for(;c<s.length;){let{bytesRead:d}=await t.read(s,c,s.length-c,a+c);if(d===0)throw new Error("JSONL snapshot was truncated during read");c+=d}let l=s.length;for(let d=s.lastIndexOf(10,l-1);d>=0;d=l===0?-1:s.lastIndexOf(10,l-1)){let p=s.subarray(d+1,l),u=o.length===0?p:Buffer.concat([p,...o.reverse()]);o.length=0,yield Ci(u),l=d}l>0&&o.push(s.subarray(0,l)),i=a}o.length>0?yield Ci(Buffer.concat(o.reverse())):e>0&&(yield"")}function Ci(t){return(t.at(-1)===13?t.subarray(0,-1):t).toString("utf8")}async function Ri(t,e,n,i){try{for await(let o of vt(t,e,{oversizedPolicy:"project",onDiagnostic:a=>{a.code!=="oversized_record_projected"&&(i?i(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 ye))throw o}return null}var Ti=new Map;function nn(t){return wt(t)}async function Go(t,e){let n=new V(t),i=(await Promise.all(xi(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:i}}async function Vi(t,e={}){let n=e.sessionsRoot??qi(Pi(),".codex"),i=new V(n),o=Ai(e.transcriptPath)?[]:(await Go(n,e.now)).files,a=Ai(e.transcriptPath),s=we(n,e.transcriptPath);if(e.sessionPaths!==void 0&&a)throw new Error("Codex transcript path cannot be combined with sessionPaths");let c=a?s===null?[]:[s]:e.sessionPaths??[];for(let h of c)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 l=a||c.length>0?[...new Set(c)].sort():o,d=new Set([e.threadId,...e.threadIds??[],...(e.invocations??[]).map(h=>h.threadId)].filter(h=>typeof h=="string"&&h.trim().length>0));l=[...await Si(i,l,d,a||c.length>0)];let p=await Ei(t,d),u=z(e.agentPath),f=z(e.parentThreadId),_=a||d.size===0||u!==null||f!==null?l:l.filter(h=>[...d].some(v=>h.includes(v)));if(_.length===0)return{filesystem:i,files:[],acceptedWorkspaces:p};let m=await ki(_,async h=>{let v=await Oi(i,h,e.onTranscriptDiagnostic);return v!==null&&p.has(nn(v.cwd))&&(u!==null?v.agentPath===u&&(f===null||v.parentThreadId===f):f!==null?v.parentThreadId===f:d.size===0||v.sessionId!==null&&d.has(v.sessionId))?h:null});return{filesystem:i,files:m.filter(h=>h!==null),acceptedWorkspaces:p}}function Ai(t){return typeof t=="string"&&t.trim().length>0}async function $i(t,e={}){let n=e.sessionsRoot??qi(Pi(),".codex"),{filesystem:i,files:o,acceptedWorkspaces:a}=await Vi(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)),c=o,l=[];for(let d of c){let p=await Zo(i,d,a,s,e);p!==null&&l.push(p)}return l.sort((d,p)=>(p.startedAt??"").localeCompare(d.startedAt??""))}async function ne(t,e={}){return(await $i(t,e))[0]??null}async function Zo(t,e,n,i,o={}){let a=await Oi(t,e);if(a===null||a.sessionId===null||!n.has(nn(a.cwd))||i.size>0&&!i.has(a.sessionId))return null;let s=await Ii(t.resolve(e),"r");try{let c=await s.stat(),l=null,d=null,p=null,u=null,f=null,_=null,m=null,h=null,v=new ve;for await(let g of be(s,c.size)){let b=de(g),w=b?.payload??null;u===null&&typeof b?.timestamp=="string"&&(u=b.timestamp),f===null&&b?.type==="turn_context"&&(typeof w?.model=="string"&&(l=w.model),typeof w?.effort=="string"&&(d=w.effort),typeof w?.service_tier=="string"&&(p=w.service_tier));let x=R(w?.thread_settings);f===null&&(b?.type==="thread_settings_applied"||w?.type==="thread_settings_applied")&&(typeof x?.model=="string"&&(l=x.model),typeof x?.reasoning_effort=="string"&&(d=x.reasoning_effort),typeof x?.service_tier=="string"&&(p=x.service_tier));let C=je(b);if(C!==null&&(o.includeHumanMessages&&v.push(C,b),f===null&&(h=C),f!==null&&m===null&&(C.turnId===null||C.turnId===f)&&(m=C.text)),w?.type==="task_complete"){if(f===null)return null;break}if(w?.type==="task_started"&&typeof w.turn_id=="string"){if(f!==null&&w.turn_id!==f)break;f=w.turn_id,_=typeof b?.timestamp=="string"?b.timestamp:_}}if(f===null)return null;let y=o.includeHumanMessages?v.select(f):[];return{sessionId:a.sessionId,...o.includeWorkspaceRoot?{workspaceRoot:a.cwd}:{},...o.includeHumanMessages?{humanMessages:y.map(g=>g.text),humanMessageProvenance:y.map(g=>g.provenance)}:{},turnId:f,sessionPath:e,startedAt:_,userMessage:m??(h?.turnId===null||h?.turnId===f?h?.text??null:null),model:l,reasoningEffort:d,serviceTier:p,observedAt:u}}finally{await s.close()}}async function Oi(t,e,n){if(!await t.exists(e))return null;let i=t.resolve(e),o=Ti.get(i);if(o!==void 0)return o;let a=await Ii(i,"r");try{let s=await a.stat(),c=Buffer.allocUnsafe(Math.min(s.size,64*1024));await a.read(c,0,c.length,0);let l=c.toString("utf8").split(/\r?\n/).map(de).find(_=>_?.type==="session_meta");!l&&s.size>c.length&&(l=await Ri(t,e,de,n)??void 0);let d=l?.payload??null,p=wi(d),u=p!==null&&typeof d?.id=="string"?d.id:typeof d?.session_id=="string"?d.session_id:typeof d?.id=="string"?d.id:null,f=typeof d?.cwd!="string"?null:{sessionId:u,cwd:d.cwd,agentPath:z(d.agent_path)??z(p?.agent_path),parentThreadId:z(d.parent_thread_id)??z(p?.parent_thread_id),agentRole:z(d.agent_role)??z(p?.agent_role),agentNickname:z(d.agent_nickname)??z(p?.agent_nickname)};return Ti.set(i,f),f}finally{await a.close()}}import{lstat as na,open as Fi,realpath as ia}from"node:fs/promises";import{homedir as ra}from"node:os";import{join as oa,resolve as zi}from"node:path";import{lstat as Qo,open as Xo,realpath as Yo}from"node:fs/promises";import{resolve as ea}from"node:path";async function We(t,e,n){let i=t.resolve(e);if(we(t.root,i)!==e)return null;let o=await Qo(i);if(!o.isFile()||o.isSymbolicLink()||(await Yo(i)).toLowerCase()!==ea(i).toLowerCase())return null;let a=await Xo(i,"r");try{let s=null;for await(let c of be(a,(await a.stat()).size)){let l=null;try{l=JSON.parse(c)}catch{continue}let d=l?.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 p=l?.type==="turn_context"?{model:d.model,effort:d.effort}:l?.type==="thread_settings_applied"||d.type==="thread_settings_applied"?{model:d.thread_settings?.model,effort:d.thread_settings?.reasoning_effort}:null;p&&(s={model:typeof p.model=="string"&&p.model.trim()?p.model:null,reasoningEffort:typeof p.effort=="string"?p.effort:null})}}}return null}finally{await a.close()}}var bt="request_user_input_async",Ni="Login conclu\xEDdo",rn=`<send_user_message_question_reply>
|
|
4
|
+
`,Di=`
|
|
5
|
+
</send_user_message_question_reply>`;function ta(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 xt(t){if(typeof t!="string"||t.length>16384)return null;try{return JSON.parse(t)}catch{return null}}var kt=class{candidates=new Map;observeReverse(e,n){if(e?.type!=="response_item")return;let i=e.payload;if(i?.type==="message"&&i.role==="user"&&n?.startsWith(rn)){let s=xt(n.slice(rn.length,-Di.length)),c=Array.isArray(s)&&s.length===1?R(s[0]):null,l=xt(c?.questionItemId);if(!Array.isArray(l)||l[0]!==bt||typeof l[1]!="string"||!/^call_[a-zA-Z0-9_-]{1,128}$/.test(l[1])||l[2]!==0||l.length!==3)return;this.candidates.set(l[1],{text:n,stage:this.candidates.has(l[1])?"invalid":"output"});return}let o=i?.call_id;if(typeof o!="string")return;let a=this.candidates.get(o);if(a){if(i?.type==="function_call_output"){let s=R(xt(i.output));a.stage=a.stage==="output"&&s?.accepted===!0&&Object.keys(s).length===1?"call":"invalid"}else if(i?.type==="function_call"){let s=R(xt(i.arguments)),c=Array.isArray(s?.questions)&&s.questions.length===1?R(s.questions[0]):null,l=rn+JSON.stringify([{questionItemId:JSON.stringify([bt,o,0]),question:c?.title,answer:Ni}])+Di;a.stage=a.stage==="call"&&(i.name===bt||i.name===`functions.${bt}`)&&(i.namespace===void 0||i.namespace==="functions")&&s!==null&&Object.keys(s).length===1&&c!==null&&Object.keys(c).length===2&&ta(c.title)&&Array.isArray(c.options)&&c.options.length===2&&c.options[0]===Ni&&c.options[1]==="Prefiro a corre\xE7\xE3o no c\xF3digo"&&a.text===l?"matched":"invalid"}}}matchedTexts(){return new Set([...this.candidates.values()].filter(e=>e.stage==="matched").map(e=>e.text))}};var on="<send_user_message_question_reply>",an="</send_user_message_question_reply>",sn="request_user_input_async";function St(t){if(typeof t!="string"||t.length>65536)return null;try{return JSON.parse(t)}catch{return null}}var Et=class{candidates=new Map;observeReverse(e,n){if(e?.type!=="response_item")return;let i=e.payload;if(i?.type==="message"&&i.role==="user"&&n?.startsWith(on)&&n.endsWith(an)){let s=St(n.slice(on.length,-an.length).trim()),c=Array.isArray(s)&&s.length===1?R(s[0]):null,l=St(c?.questionItemId);if(!Array.isArray(l)||l.length!==3||l[0]!==sn||typeof l[1]!="string"||!/^call_[a-zA-Z0-9_-]{1,128}$/.test(l[1])||!Number.isInteger(l[2])||l[2]<0||l[2]>2||typeof c?.question!="string"||typeof c.answer!="string"||typeof e.timestamp!="string"||!Number.isFinite(Date.parse(e.timestamp))||n!==`${on}
|
|
6
|
+
${JSON.stringify([{questionItemId:JSON.stringify(l),question:c.question,answer:c.answer}])}
|
|
7
|
+
${an}`)return;this.candidates.set(l[1],{text:n,question:c.question,answer:c.answer,observedAt:e.timestamp,index:l[2],stage:this.candidates.has(l[1])?"invalid":"output"});return}let o=i?.call_id;if(typeof o!="string")return;let a=this.candidates.get(o);if(a){if(i?.type==="function_call_output"){let s=R(St(i.output));a.stage=a.stage==="output"&&s?.accepted===!0&&i.output===JSON.stringify({accepted:!0})?"call":"invalid"}else if(i?.type==="function_call"){let s=R(St(i.arguments)),c=Array.isArray(s?.questions)?R(s.questions[a.index]):null;a.stage=a.stage==="call"&&(i.name===sn||i.name===`functions.${sn}`)&&(i.namespace===void 0||i.namespace==="functions")&&s!==null&&Object.keys(s).length===1&&Array.isArray(s.questions)&&s.questions.length>=1&&s.questions.length<=3&&s.questions.every(l=>{let d=R(l);return d!==null&&Object.keys(d).length===2&&typeof d.title=="string"&&Array.isArray(d.options)&&d.options.length>0&&d.options.every(p=>typeof p=="string")})&&i.arguments===JSON.stringify(s)&&c?.title===a.question&&Array.isArray(c.options)&&c.options.includes(a.answer)?"matched":"invalid"}}}matchedReplies(){return new Map([...this.candidates.values()].filter(e=>e.stage==="matched").map(e=>[e.text,{question:e.question,answer:e.answer,observedAt:e.observedAt}]))}};function cn(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 Li(t){let e=await na(t,{bigint:!0}),n=i=>process.platform==="win32"?zi(i).toLowerCase():zi(i);return e.isFile()&&!e.isSymbolicLink()&&n(await ia(t))===n(t)?e:null}async function Mi(t,e,n){let i=await Fi(t,"r");try{let o=await i.stat({bigint:!0}),a=await Li(t);return e.ino===n.ino&&cn(e,o)&&a!==null&&cn(n,a)}finally{await i.close()}}async function Ct(t,e){if(![e.threadId,e.sourceTurnId,e.currentTurnId,e.transcriptPath].every(d=>typeof d=="string"&&d.trim()))return null;let n=e.sessionsRoot??oa(ra(),".codex"),i=we(n,e.transcriptPath);if(!i)return null;let o=await ne(t,{sessionsRoot:n,threadId:e.threadId,transcriptPath:e.transcriptPath});if(!o||o.sessionId!==e.threadId||o.turnId!==e.currentTurnId||o.sessionPath!==i)return null;let a=new V(n),s=a.resolve(i),c=await Li(s);if(!c)return null;let l=await Fi(s,"r");try{let d=await l.stat({bigint:!0}),p=new ve,u=new kt,f=new Et;if(!Number.isSafeInteger(Number(d.size))||!await Mi(s,d,c))return null;let _=new Set,m=!1,h=0,v=e.currentTurnId;for await(let E of be(l,Number(d.size))){if(h+=Buffer.byteLength(E),h>64*1024*1024||_.size>128)throw new Error("Codex human-turn range exceeds bounded scan limit");let A=de(E),I=A?.payload;typeof I?.turn_id=="string"&&(A?.type==="turn_context"||["task_started","task_complete","turn_aborted"].includes(String(I.type)))&&(v=I.turn_id,_.add(v));let ce=je(A);if(u.observeReverse(A,ce?.text),f.observeReverse(A,ce?.text),ce&&p.push({text:ce.text,turnId:ce.turnId??v},A),I?.type==="task_started"&&I.turn_id===e.sourceTurnId){m=!0;break}}if(!m)return null;let y=await We(a,i,e.sourceTurnId);if(!y)return null;let g=await ne(t,{sessionsRoot:n,threadId:e.threadId,transcriptPath:e.transcriptPath});if(!g||g.sessionId!==o.sessionId||g.turnId!==o.turnId||g.model!==o.model||g.reasoningEffort!==o.reasoningEffort)return null;let b=await l.stat({bigint:!0});if(!cn(d,b)||!await Mi(s,d,c))throw new Error("Codex human-turn evidence changed during the exact range read");let w=p.ordered();if(w.some(E=>E.turnId===null))return null;let x=u.matchedTexts(),C=f.matchedReplies();return{messages:w.map(E=>({...E,turnId:E.turnId,...C.has(E.text)&&E.provenance.source_record_type==="response_item"?{nativeQuestionReply:C.get(E.text)}:{},...x.has(E.text)&&E.provenance.source_record_type==="response_item"?{nativeLoginReply:!0}:{}})),source:y,current:{model:o.model,reasoningEffort:o.reasoningEffort}}}finally{await l.close()}}var xe=r.number().finite().nonnegative().nullable(),ca=r.object({task_id:r.string().min(1),completed:r.boolean(),completed_at:r.string().min(1).nullable(),attempt:r.number().int().nonnegative().nullable(),attempt_id:r.string().min(1).nullable().optional(),equivalence_key:r.string().min(1).nullable().optional(),equivalence_evidence_id:r.string().min(1).nullable().optional(),baseline_equivalence_evidence_id:r.string().min(1).nullable().optional(),model:r.string().min(1).nullable(),reasoning_effort:r.enum(["low","medium","high","xhigh"]).nullable(),baseline_task_id:r.string().min(1).nullable(),baseline_attempt_id:r.string().min(1).nullable().optional(),baseline_equivalence_id:r.string().min(1).nullable(),observed_cost_usd:xe,baseline_observed_cost_usd:xe,quality_score:xe,quality_floor:xe,rework_count:r.number().int().nonnegative().nullable(),context_budget_tokens:r.number().int().nonnegative().nullable().optional(),cached_context_tokens:r.number().int().nonnegative().nullable().optional(),baseline_context_budget_tokens:r.number().int().nonnegative().nullable().optional(),baseline_cached_context_tokens:r.number().int().nonnegative().nullable().optional(),billed_amount:xe.optional(),billed_currency:r.string().min(1).nullable().optional(),billed_provenance:r.enum(["observed","inferred","unavailable"]).nullable().optional(),billed_source_id:r.string().min(1).nullable().optional(),billed_at:r.string().min(1).nullable().optional(),baseline_billed_amount:xe.optional(),baseline_billed_currency:r.string().min(1).nullable().optional(),baseline_billed_provenance:r.enum(["observed","inferred","unavailable"]).nullable().optional(),baseline_billed_source_id:r.string().min(1).nullable().optional(),baseline_billed_at:r.string().min(1).nullable().optional()}).strict(),Pd=r.object({timezone:r.string().min(1),interval:r.object({start:r.string().min(1),end:r.string().min(1)}).strict(),equivalence_key:r.string().min(1).nullable().optional(),tasks:r.array(ca)}).strict();var ie=r.string().datetime({offset:!0}).or(r.string().datetime()),da=r.object({id:r.string().min(1),provider:r.enum(["openai","anthropic"]),aliases:r.array(r.string().min(1)).default([]),input_per_million_usd:r.number().nonnegative(),cached_input_per_million_usd:r.number().nonnegative().nullable().default(null),cache_write_input_per_million_usd:r.number().nonnegative().nullable().optional(),output_per_million_usd:r.number().nonnegative(),reasoning_per_million_usd:r.number().nonnegative().nullable().default(null),priority_input_per_million_usd:r.number().nonnegative().nullable().optional(),priority_cached_input_per_million_usd:r.number().nonnegative().nullable().optional(),priority_cache_write_input_per_million_usd:r.number().nonnegative().nullable().optional(),priority_output_per_million_usd:r.number().nonnegative().nullable().optional(),priority_reasoning_per_million_usd:r.number().nonnegative().nullable().optional(),reasoning_billed_separately:r.boolean().default(!1),long_context_threshold_tokens:r.number().int().positive().nullable().default(null),long_context_input_multiplier:r.number().positive().default(1),long_context_output_multiplier:r.number().positive().default(1),priority_long_context_supported:r.boolean().default(!1),source_label:r.string().min(1),source_url:r.string().url(),notes:r.array(r.string()).default([])}).strict(),su=r.object({schema_version:r.literal(1),updated_at:ie,source:r.string().min(1),disclaimer:r.string().min(1),models:r.array(da)}).strict(),cu=r.object({schema_version:r.literal(1),base:r.literal("USD"),quote:r.literal("BRL"),rate:r.number().positive(),as_of:ie,source_label:r.string().min(1),source_url:r.string().url()}).strict(),ji=r.object({input:r.number().int().nonnegative().nullable(),cached_input:r.number().int().nonnegative().nullable().default(null),cache_write_input:r.number().int().nonnegative().nullable().optional(),output:r.number().int().nonnegative().nullable(),reasoning:r.number().int().nonnegative().nullable(),total:r.number().int().nonnegative().nullable().default(null),source:r.preprocess(t=>t==="client"?"provider_reported":t,r.enum(["provider_reported","estimated","unavailable"]))}).strict(),Wi=r.object({estimated_usd:r.number().nonnegative().nullable(),estimated_brl:r.number().nonnegative().nullable(),fx_rate:r.number().positive().nullable(),pricing_model:r.string().nullable(),pricing_source:r.string().nullable(),pricing_source_url:r.string().url().nullable().optional(),pricing_catalog_updated_at:ie.nullable().optional(),input_usd:r.number().nonnegative().nullable().default(null),cached_input_usd:r.number().nonnegative().nullable().default(null),cache_write_input_usd:r.number().nonnegative().nullable().optional(),output_usd:r.number().nonnegative().nullable().default(null),reasoning_usd:r.number().nonnegative().nullable().default(null)}).strict(),ua=r.object({cycle_count:r.number().int().nonnegative().nullable(),source:r.enum(["repository","local-codex","manual","unavailable"]),segment_key:r.string().nullable()}).strict(),aa=r.object({schema_version:r.literal(1),recorded_at:ie,run_id:r.string().startsWith("RUN-"),task_id:r.string().startsWith("TASK-"),spec_id:r.string().nullable(),change_id:r.string().nullable(),task_title:r.string().nullable(),task_status:r.string().nullable(),client:r.string().min(1),agent:r.string().min(1),provider:r.enum(["openai","anthropic"]).nullable(),model:r.string().min(1),status:r.enum(["running","completed","failed"]),started_at:ie,finished_at:ie.nullable(),duration_ms:r.number().int().nonnegative().nullable(),token_usage:ji,estimated_cost:Wi,telemetry:ua,source_segment_key:r.string().nullable()}).strict(),sa=r.object({schema_version:r.literal(1),recorded_at:ie,run_id:r.string().startsWith("RUN-"),task_id:r.string().startsWith("TASK-"),cycle_index:r.number().int().nonnegative(),provider:r.enum(["openai","anthropic"]).nullable(),model:r.string().min(1),timestamp:ie,source:r.enum(["local-codex","manual"]),source_segment_key:r.string().nullable(),token_usage:ji,estimated_cost:Wi}).strict();import{execFile as ba}from"node:child_process";import{constants as xa}from"node:fs";import{access as ka,lstat as Sa,realpath as Xi,stat as Ea}from"node:fs/promises";import{dirname as Ca,isAbsolute as pn,relative as Ra,resolve as mn}from"node:path";import{promisify as Ta}from"node:util";import{execFile as pa}from"node:child_process";import{randomUUID as ma}from"node:crypto";import{lstat as ln,mkdtemp as _a,readdir as fa,readFile as Ui,realpath as Hi,rm as Ji,unlink as dn,writeFile as ga}from"node:fs/promises";import{tmpdir as ha}from"node:os";import{basename as Bi,dirname as ya,join as Ki,resolve as ue}from"node:path";import{promisify as va}from"node:util";var wa=va(pa),un=new WeakMap;async function Gi(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 i=performance.now(),o=ue(t),a=await Hi(ha()),s=await _a(Ki(a,`zaip-candidate-${Bi(o)}-`)),c=`${s}.owner`,l=ma(),d=async(b=!1)=>{if(ya(ue(s))!==a||!Bi(s).startsWith("zaip-candidate-"))throw new Error("Candidate checkout path escaped its owner");let w=await ln(s).catch(x=>{if(x.code==="ENOENT")return null;throw x});if(b&&w===null)throw new Error("Owned candidate directory disappeared");if(w!==null&&(!w.isDirectory()||w.isSymbolicLink()||await Hi(s)!==s))throw new Error("Candidate checkout is no longer an owned directory")};try{await d(!0),await ga(c,l,{flag:"wx",mode:384})}catch(b){try{await d(!0);let w=await Ui(c,"utf8").catch(x=>{if(x.code==="ENOENT")return null;throw x});if(w!==null&&w!==l)throw new Error("Candidate ownership marker changed during setup");await Ji(s,{recursive:!0,force:!0}),w!==null&&await dn(c)}catch(w){throw new AggregateError([b,w],"Candidate setup and cleanup failed")}throw b}let p=async()=>{if(await Ui(c,"utf8")!==l)throw new Error("Candidate checkout ownership marker changed")},u=async()=>{await p(),await d()},f=Object.freeze({path:s,repository:o,commit:e}),_=!1,m,h=0,v=0,y,g;try{await Ue(o,["worktree","add","--detach",s,e]),_=!0,un.set(f,{running:!1}),h=Math.round(performance.now()-i),m=await n(f)}catch(b){y=b}finally{let b=performance.now();un.delete(f);try{await u(),await ln(s).catch(()=>null)&&await Zi(s);let w=!1,C=(_?null:await Ue(o,["worktree","list","--porcelain"]))?.stdout.split(/\r?\n/).some(E=>E.startsWith("worktree ")&&ue(E.slice(9))===ue(s))??!1;if(_||C)try{await Ue(o,["worktree","remove","--force","--force",s])}catch{w=!0}await u(),await ln(s).catch(()=>null)&&await Ji(s,{recursive:!0,force:!0,maxRetries:3,retryDelay:100}),w&&(await Ue(o,["worktree","list","--porcelain"])).stdout.split(/\r?\n/).some(I=>I.startsWith("worktree ")&&ue(I.slice(9))===ue(s))&&await Ue(o,["worktree","remove","--force","--force",s]),await p(),await dn(c),v=Math.round(performance.now()-b)}catch(w){g=w}}if(g!==void 0){let b=w=>w instanceof Error?w.message:String(w);throw new AggregateError(y===void 0?[g]:[y,g],`${y===void 0?"Candidate operation finished":b(y)}; cleanup incomplete at ${s}: ${b(g)}`)}if(y!==void 0)throw y;return{value:m,preparation_ms:h,cleanup_ms:v}}async function Zi(t){for(let e of await fa(t,{withFileTypes:!0})){let n=Ki(t,e.name);e.isSymbolicLink()?await dn(n):e.isDirectory()&&await Zi(n)}}function Qi(t,e,n){let i=un.get(t);if(!i||i.running||t.repository!==ue(e)||t.commit!==n)throw new Error("candidate workspace must be owned, sequential and bound to the same repository and SHA");return i.running=!0,()=>{i.running=!1}}function Ue(t,e){return wa("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 er=Ta(ba);async function _n(t,e){if(e===void 0){let i=await Gi(t.repository_path,t.commit_sha,o=>_n(t,o));return{...i.value,timings_ms:{...i.value.timings_ms,preparation:i.preparation_ms,cleanup:i.cleanup_ms}}}let n=Qi(e,t.repository_path,t.commit_sha);try{return await Aa(t,e.path)}finally{n()}}async function Aa(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(!pn(t.executable_path))throw new Error("candidate validation requires an absolute executable path");if(!Array.isArray(t.args)||t.args.some(m=>typeof m!="string"))throw new Error("candidate validation requires a JSON string array of arguments");let i=mn(t.executable_path),o=await Ea(i).catch(()=>null);if(o===null||!o.isFile())throw new Error("candidate validation executable path is not a file");await ka(i,xa.X_OK).catch(()=>{throw new Error("candidate validation executable path is not executable")});let a=mn(t.repository_path),s=Ra(a,i);if(s===""||!s.startsWith("..")&&!pn(s))throw new Error("candidate validation requires an external toolchain executable, not a shared-checkout executable");let c=[a.toLowerCase(),a.replaceAll("\\","/").toLowerCase()];if(t.args.some(m=>c.some(h=>m.toLowerCase().includes(h))))throw new Error("candidate validation arguments must use candidate-relative paths, not shared-checkout paths");if(await Xi(i)!==await Xi(process.execPath))throw new Error("candidate validation requires the current host Node runtime");let l=t.args[0];if(!l||l.startsWith("-")||pn(l)||l.includes("\\")||l.includes(":")||l.includes("\0")||l.split("/").some(m=>["",".",".."].includes(m))||!/\.(?:c|m)?js$/.test(l))throw new Error("candidate validation requires a committed relative Node harness; eval, loaders and inline code are not allowed");let d=await re(a,["rev-parse",`${t.commit_sha}^{commit}`]),u=(await re(a,["--literal-pathspecs","ls-tree",d,"--",l])).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 f=await re(a,["rev-parse",`${d}^{tree}`]),_=t.timeout_ms??12e4;if(!Number.isInteger(_)||_<1||_>36e5)throw new Error("candidate validation timeout must be between 1 and 3600000 milliseconds");{let m=await re(e,["rev-parse","HEAD"]),h=await re(e,["rev-parse","HEAD^{tree}"]);if(m!==d||h!==f)throw new Error("isolated worktree does not match requested candidate commit and tree");await Ia(e,"before execution");let v=mn(e,l);for(;v!==e;){if((await Sa(v)).isSymbolicLink())throw new Error("candidate harness cannot follow a symlink");v=Ca(v)}let y=new Date().toISOString(),g=performance.now()-n,b=performance.now(),w=await Pa(i,t.args,e,_),x=Math.round(performance.now()-b),C=new Date().toISOString(),E=performance.now(),A=await tr(e),I=await re(e,["rev-parse","HEAD"]),ce=await re(e,["rev-parse","HEAD^{tree}"]),ei=I!==d||ce!==f,Oo=ei?"candidate HEAD or tree changed during execution":A?w.diagnostic:"candidate has uncommitted changes after execution";return{status:w.exitCode===0&&A&&!ei?"passed":"failed",command:JSON.stringify([i,...t.args]),output:{stdout:Yi(w.stdout),stderr:Yi(w.stderr)},timings_ms:{process:x,verification:Math.round(g+performance.now()-E)},candidate_execution:{kind:"isolated_git_worktree",protocol:"committed_node_harness_v1",harness_path:l,harness_blob_sha:u[1],commit_sha:d,tree_sha:f,exit_code:w.exitCode,diagnostic:Oo,started_at:y,finished_at:C}}}}function Yi(t){let e=ri(t);try{return _t(e),e}catch{return"[REDACTED: command output contained sensitive values]"}}async function Ia(t,e){if(!await tr(t))throw new Error(`isolated worktree is dirty ${e}`)}async function tr(t){return await re(t,["status","--porcelain","--untracked-files=all"])===""}async function Pa(t,e,n,i){try{return{exitCode:0,diagnostic:null,...await er(t,[...e],{cwd:n,shell:!1,windowsHide:!0,env:nr(),timeout:i,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 $a(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 qa=["APPDATA","COMSPEC","HOME","LANG","LOCALAPPDATA","LC_ALL","PATH","PATHEXT","Path","ProgramFiles","ProgramData","PROGRAMDATA","SYSTEMROOT","SystemRoot","TEMP","TMP","USERPROFILE","WINDIR"];function nr(){return Object.fromEntries(qa.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 $a(t){return t!==null&&typeof t=="object"&&("killed"in t&&t.killed===!0||"signal"in t&&t.signal==="SIGTERM")}async function re(t,e){let{stdout:n}=await Oa(t,e);return n.trim()}function Oa(t,e){return er("git",[...e],{cwd:t,shell:!1,windowsHide:!0,encoding:"utf8",env:nr(),maxBuffer:10*1024*1024})}import{createHash as za}from"node:crypto";var Na=".agents/private/state/codex-telemetry-spool/v1/events";var Fu=64*1024*1024;var Da=r.object({path:r.string().startsWith(`${Na}/`).endsWith(".json"),stat:r.object({dev:r.string(),ino:r.string(),size:r.string(),mtime_ns:r.string(),ctime_ns:r.string()}).strict(),envelope:en}).strict(),Lu=r.object({schema_version:r.literal(2),prefix:r.string().regex(/^[a-f0-9]{2}$/),events:r.array(Da),checksum_sha256:r.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,i=t.entrypoint==="observation"?t.observed_agent_path??null:n,o=t.client_turn_id??null;return n===null&&o===null?null:Me.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?i:null,...e&&i===null&&t.observed_agent_id?{native_agent_id:t.observed_agent_id}:{}})}var ir=".agents/private/state/codex-telemetry-spool/v1",ap=`${ir}/events`,sp=64*1024,Ma=t=>za("sha256").update(t).digest("hex");async function He(t,e){let n=Me.parse(e),i=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=`${ir}/correlations/${Ma(i)}.json`;try{return await t.writeTextAtomicExclusive(o,`${JSON.stringify(n)}
|
|
8
|
+
`),n}catch(s){if(!Fa(s)||s.code!=="EEXIST")throw s}let a=Me.parse(JSON.parse(await t.readText(o)));if(fn(a,n))return await t.writeTextAtomic(o,`${JSON.stringify(n)}
|
|
9
|
+
`),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 fn(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 Fa(t){return t instanceof Error&&"code"in t}var La=r.object({run_id:r.string().startsWith("RUN-"),path:r.string().startsWith(".agents/records/runs/"),content_sha256:r.string().regex(/^[a-f0-9]{64}$/)}).strict(),ja=r.object({schema_version:r.literal(1),manifest_id:r.string().min(1),created_at:r.string().datetime({offset:!0}),kind:r.literal("historical_developer_attribution"),assignment:ft.extend({attribution_source:r.literal("human_assigned")}),source_streams:r.array(La).min(1)}).strict().superRefine((t,e)=>{let n=new Set,i=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"}),i.has(a.path)&&e.addIssue({code:"custom",path:["source_streams",o,"path"],message:"Duplicate historical Run path"}),n.add(a.run_id),i.add(a.path)}),pp=ja.extend({manifest_hash:r.string().regex(/^[a-f0-9]{64}$/)}).strict();var Wa=".agents/private/state/developer-identity.json",fp=1440*60*1e3,Rt=class extends Error{name="DeveloperIdentityBootstrapRequiredError"};async function Ua(t){try{return ft.parse(JSON.parse(await t.readText(Wa)))}catch(e){if(Ha(e))return null;throw new Rt("Developer identity cache is invalid; run `developer identity bootstrap`",{cause:e})}}async function rr(t){let e=await Ua(t);if(e===null)throw new Rt("Developer identity is not configured; run `developer identity bootstrap`");return e}function Ha(t){return typeof t=="object"&&t!==null&&"code"in t&&t.code==="ENOENT"}import{createHash as ls,randomUUID as ds}from"node:crypto";function or(t){return t instanceof Error&&"code"in t&&t.code==="EEXIST"}async function ar(t,e,n,i,o){let a=`${e}.lock`,s=()=>t.writeTextExclusive(a,`${JSON.stringify({run_id:n,pid:process.pid})}
|
|
10
|
+
`);try{await s()}catch(c){if(!or(c))throw c;if(!await i())throw new Error(`Run V2 is being updated concurrently: ${n}`);try{await s()}catch(l){throw or(l)?new Error(`Run V2 is being updated concurrently: ${n}`):l}}try{await o()}finally{await t.removeFile(a)}}async function sr(t,e,n){let i=t.sameTurnHandoff,o=i&&"kind"in i&&i.kind==="native_question_continuation";if(o&&(e===null||e.run.task_id!==t.taskId||e.run.execution_id!==t.executionId||i.target_task_id!==t.taskId||e.run.model!==t.model||e.run.reasoning_effort!==t.reasoningEffort||(await n()).some(s=>s.run.parent_run_id===e.run.run_id&&s.finished===null)))throw new Error("Native question continuation requires its exact blocked Task and terminal children");let a=t.sameTurnHandoff!==void 0&&"kind"in t.sameTurnHandoff&&t.sameTurnHandoff.kind==="conversation_promotion";if(a&&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(s=>s.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"||!a&&e.finalization_decision?.outcome!==(o?"blocked":"completed")||(!a&&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 cr(t){return B(t)&&t.code==="ENOENT"||t instanceof ge&&B(t.cause)&&t.cause.code==="ENOENT"}function Ja(t){return cr(t)||B(t)&&t.code==="EBADF"||t instanceof ge&&(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 Tt(t){await new Promise(e=>setTimeout(e,t))}function gn(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,i){let o=null,a=5;for(let c=0;c<a;c+=1)try{o=await t.readText(e);break}catch(l){if(!Ja(l)||c===a-1)throw l;await Tt(5*(c+1))}if(o===null)throw new Error(`Subagent invocation claim disappeared: ${i}`);let s=JSON.parse(o);if(s.identity!==n)throw new Error(`Subagent invocation claim is incompatible: ${i}`);return s}function At(t){let e=Date.parse(t.lease_expires_at);return!Number.isFinite(e)||e<=Date.now()}async function lr(t,e,n,i){let o=`${e}.recovery-${n}.json`;for(let a=0;a<8;a+=1){let s=gn(`recovery:${n}`,i);try{return await t.writeTextExclusive(o,`${JSON.stringify(s)}
|
|
11
|
+
`),o}catch(c){if(!B(c)||c.code!=="EEXIST")throw c;let l;try{l=JSON.parse(await t.readText(o))}catch(d){if(cr(d))continue;throw d}if(!At(l))return null;o=`${o}.${l.owner_nonce}.json`}}throw new Error("Subagent invocation recovery lease chain exceeded")}async function hn(t,e,n,i,o,a){let s=await Se(t,e,n,i);if(s.owner_nonce!==o){if(s.run_id===a)return;throw new Error(`Subagent invocation claim ownership changed: ${i}`)}await t.writeTextAtomic(e,`${JSON.stringify({...s,run_id:a,lease_expires_at:new Date().toISOString()})}
|
|
12
|
+
`)}function dr(t){try{return process.kill(t,0),!0}catch(e){return!(B(e)&&e.code==="ESRCH")}}async function ur(t,e,n,i,o){let a=await t.listFiles(e,".jsonl");if(o&&o.threadId!==null){let l=[];for(let _=0;_<a.length;_+=16)l.push(...await Promise.all(a.slice(_,_+16).map(async m=>{let h=await t.readFirstLine(m),v=h?.trim()?h:await t.readText(m),y=gt.parse(Je(v)[0]);if(!n(y.run_id).includes(m))throw new Error(`Run V2 id does not match storage path: ${m}`);return{path:m,run:y}})));let d=_=>_==="codex-desktop"?"codex":_,p=new Set(l.filter(({run:_})=>d(_.client)===d(o.client)&&_.client_thread_id===o.threadId).map(({run:_})=>_.run_id)),u=new Map;for(let{run:_}of l)_.parent_run_id!==null&&u.set(_.parent_run_id,[...u.get(_.parent_run_id)??[],_.run_id]);let f=[...p];for(let _=0;_<f.length;_++)for(let m of u.get(f[_])??[])p.has(m)||(p.add(m),f.push(m));a=l.filter(({run:_})=>p.has(_.run_id)).map(({path:_})=>_)}let s=await Promise.all(a.map(async l=>{let d=Ee(Je(await t.readText(l)));if(!n(d.run.run_id).includes(l))throw new Error(`Run V2 id does not match storage path: ${l}`);return{path:l,run:d}})),c=new Map;for(let l of s){let d=c.get(l.run.run.run_id);if(d!==void 0&&JSON.stringify(d.run.records)!==JSON.stringify(l.run.records))throw new Error(`Run V2 has divergent monthly and legacy streams: ${l.run.run.run_id}`);(d===void 0||l.path===i(l.run.run.run_id))&&c.set(l.run.run.run_id,l)}return[...c.values()].map(({run:l})=>l).sort((l,d)=>d.run.occurred_at.localeCompare(l.run.occurred_at)||d.run.run_id.localeCompare(l.run.run_id))}import{createHash as Ba,randomUUID as Ka}from"node:crypto";var pe="usage-attribution",Pt="usage-attribution-recovery",Ga=3e4,Za=3;async function _r(t,e,n){let i=Date.now()+12e4,o=Ka(),a=null;for(;;){if(a!==null&&Date.now()>=i)throw a;try{if(await t.writeTextAtomicExclusive(e,`${JSON.stringify(fr(o))}
|
|
13
|
+
`),Date.now()>=i)throw await mr(t,e,o),new Error("Usage attribution lock acquisition exceeded deadline");break}catch(s){if((!oe(s)||s.code!=="EEXIST")&&!ts(s))throw s;if(a=s,oe(s)&&s.code==="EEXIST"){let c=await Qa(t,e,i);if(c===null){await It(s,i);continue}if(c.purpose!==pe)throw new Error("Usage attribution lock has an incompatible purpose");if(!pr(c)){await It(s,i);continue}if(Date.now()>=i)throw s;let l=await es(t,e,c.owner_nonce,o);if(l!==null)try{if(Date.now()>=i)throw s;let d=await Be(t,e);if(d!==null&&d.owner_nonce===c.owner_nonce&&d.content===c.content&&pr(d)){if(Date.now()>=i)throw s;await t.removeFileIfContentMatches(e,d.content)}}finally{await hr(t,l,o)}}await It(s,i)}}try{return await n()}finally{await mr(t,e,o)}}function fr(t){let e=Date.now();return{schema_version:1,purpose:pe,pid:process.pid,owner_nonce:t,acquired_at:new Date(e).toISOString(),lease_expires_at:new Date(e+Ga).toISOString()}}async function Be(t,e){try{let n=await t.readText(e),i=JSON.parse(n);if(Ya(i))return{...i,content:n};if(Xa(i))return{schema_version:1,purpose:pe,pid:i.pid,owner_nonce:`legacy-${Ba("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(oe(n)&&n.code==="ENOENT")return null;throw n}}async function Qa(t,e,n){let i=0;for(;;)try{return await Be(t,e)}catch(o){if(!ns(o)||(i+=1,i>=Za||Date.now()>=n)||(await It(o,n),Date.now()>=n))throw o}}function Xa(t){return typeof t=="object"&&t!==null&&t.purpose===pe&&Number.isSafeInteger(t.pid)&&t.pid>0}function Ya(t){if(typeof t!="object"||t===null)return!1;let e=t;return e.schema_version===1&&(e.purpose===pe||e.purpose===Pt)&&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 pr(t){return t!==null&&t.purpose===pe&&(t.legacy===!0||Date.parse(t.lease_expires_at)<=Date.now())&&!gr(t.pid)}function gr(t){try{return process.kill(t,0),!0}catch(e){return!(oe(e)&&e.code==="ESRCH")}}async function es(t,e,n,i){let o=`${e}.recovery-${n}`;try{return await t.writeTextAtomicExclusive(o,`${JSON.stringify({...fr(i),purpose:Pt,target_nonce:n})}
|
|
14
|
+
`),o}catch(a){if(!oe(a)||a.code!=="EEXIST")throw a;let s=await Be(t,o);return s!==null&&s.purpose===Pt&&s.target_nonce===n&&Date.parse(s.lease_expires_at)<=Date.now()&&!gr(s.pid)&&await hr(t,o,s.owner_nonce),null}}async function mr(t,e,n){let i=await Be(t,e);i?.purpose===pe&&i.owner_nonce===n&&await t.removeFileIfContentMatches(e,i.content)}async function hr(t,e,n){let i=await Be(t,e);i?.purpose===Pt&&i.owner_nonce===n&&await t.removeFileIfContentMatches(e,i.content)}async function It(t,e){if(Date.now()>=e)throw t;await new Promise(n=>setTimeout(n,25))}function oe(t){return t instanceof Error&&"code"in t}function ts(t){return oe(t)&&(t.code==="ENOENT"||t.code==="EBADF")||t instanceof ge&&(oe(t.cause)&&(t.cause.code==="ENOENT"||t.cause.code==="EBADF")||t.message.startsWith("Physical path escapes workspace root:"))}function ns(t){let e=t instanceof ge?t.cause:t;return oe(e)&&(e.code==="EBADF"||process.platform==="win32"&&e.code==="EPERM")}var Q=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"&&us(n.localBasePath)}filesystem;storage;activeWriters=new Set;async start(e){let n=e.clock??new T,i=e.id??Ne("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 sr(e,a,()=>this.list());let s=a?.run.agent_invocation_id??`AINV-${i.slice(4)}`,c=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)}`,l=o===null?c??s:o.run.root_agent_invocation_id??c,d=c===null?0:(o?.run.delegation_depth??0)+1,p=o!==null?o.run.developer_identity:e.entrypoint==="observation"?null:e.developerIdentity??(this.storage.storageMode==="local_only"?null:await rr(this.filesystem)),u=gt.parse({schema_version:2,event_id:X(i,1),run_id:i,sequence:1,occurred_at:n.now().toISOString(),type:"run.started",attribution_status:"attributed",developer_identity:p,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:l,parent_agent_invocation_id:c,invocation_kind:c===null?"orchestrator":"delegated",delegation_depth:d,intake:e.intake??null}),f=this.path(i);if(this.activeWriters.has(i))throw new Error(`Run V2 already has a writer or persisted stream: ${i}`);try{await this.filesystem.writeTextExclusive(f,Ce(u))}catch(_){throw!B(_)||_.code!=="EEXIST"?_:new Error(`Run V2 already has a writer or persisted stream: ${i}`)}try{let _=ke(u);_!==null&&e.sameTurnHandoff===void 0&&await He(this.filesystem,_)}catch(_){throw await this.filesystem.removeFile(f),_}return this.activeWriters.add(i),new qt(this.filesystem,f,u,n,()=>{this.activeWriters.delete(i)})}async read(e){let n=await this.readPath(e);if(n===null)throw new Error(`Run V2 not found: ${e}`);return Ee(Je(await this.filesystem.readText(n)))}async list(e){return ur(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=>he.parse(s)),[i]=n;if(i===void 0)return;let o=i.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 ar(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 c=await this.read(o),l=c.records.length+1;for(let[d,p]of n.entries())if(p.sequence!==l+d)throw new Error(`Run V2 compare-and-append failed: expected sequence ${l+d}, received ${p.sequence}`);Ee([...c.records,...n]),await this.filesystem.appendText(a,n.map(Ce).join(""))})}async withUsageAttributionLock(e){return _r(this.filesystem,`${this.basePath()}/.usage-attribution.lock`,e)}async recoverOrphanedAppendLock(e,n){let i;try{i=await this.filesystem.readText(e)}catch{return!1}let o;try{o=JSON.parse(i)}catch{return!1}if(o.run_id!==n||typeof o.pid!="number"||!Number.isSafeInteger(o.pid)||o.pid<=0||dr(o.pid))return!1;try{return await this.filesystem.readText(e)!==i?!1:(await this.filesystem.removeFile(e),!0)}catch{return!1}}async withSubagentInvocationClaim(e,n,i,o){let a=ls("sha256").update(e).digest("hex"),s=this.subagentInvocationClaimPath(a);await this.migrateLegacySubagentInvocationClaim(s,a,e);let c=ds(),l=gn(e,c),d=!1;try{await this.filesystem.writeTextExclusive(s,`${JSON.stringify(l)}
|
|
15
|
+
`),d=!0}catch(u){if(!B(u)||u.code!=="EEXIST")throw u}let p=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(!At(u)){if(Date.now()>=p)throw new Error(`Subagent invocation claim remained pending: ${a}`);await Tt(25);continue}let f=await lr(this.filesystem,s,u.owner_nonce,c);if(f===null){if(Date.now()>=p)throw new Error(`Subagent invocation claim recovery timed out: ${a}`);await Tt(25);continue}try{let _=await Se(this.filesystem,s,e,a);if(typeof _.run_id=="string")return n(_.run_id);if(!At(_))continue;await this.filesystem.writeTextAtomic(s,`${JSON.stringify(l)}
|
|
16
|
+
`),d=!0}finally{await this.filesystem.removeFile(f)}}try{let u=await o?.();if(u!=null)return await hn(this.filesystem,s,e,a,c,u.runId),u.value;let f=await i();return await hn(this.filesystem,s,e,a,c,f.runId),f.value}catch(u){let f=await Se(this.filesystem,s,e,a);throw f.owner_nonce===c&&f.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:i}=Yt(e);return`${this.storage.localBasePath}/${n}/${i}/${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:i,day:o}=ii(e);return[this.path(e),`${this.storage.localBasePath}/${n}/${i}/${o}/${e}.jsonl`]}async readPath(e){if(this.storage.storageMode==="tracked_sanitized")return le(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"?mt("subagent-invocation",e):`${this.basePath()}/.claims/subagent-invocation/${e}.json`}async migrateLegacySubagentInvocationClaim(e,n,i){let o=`${this.basePath()}/.subagent-invocation-claims/${n}.json`;if(!await this.filesystem.exists(o))return;let a=await Se(this.filesystem,o,i,n);try{await this.filesystem.writeTextExclusive(e,`${JSON.stringify(a)}
|
|
17
|
+
`)}catch(s){if(!B(s)||s.code!=="EEXIST")throw s}}};function us(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 wr(t){let e=new Map,n=[];for(let i of t){if(i.source_segment_key===null){n.push(i);continue}let o=e.get(i.source_segment_key);if(o===void 0){e.set(i.source_segment_key,i),n.push(i);continue}if(!yn(i,o))throw new Error(`Divergent duplicate source segment: ${i.source_segment_key}`)}return n}function yn(t,e){return JSON.stringify(vr(t))===JSON.stringify(vr(e))}function vr(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 br(t,e){let n=[],i=null;for(let o of t.split(/\r?\n/).map(a=>a.trim()).filter(Boolean)){let a=JSON.parse(o),s=he.parse(Array.isArray(a)?e(a,i):a);i??=s.run_id,n.push(s)}return n}function Vt(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 i=e.find(o=>o.type==="model.selection.recorded");if(i!==void 0){if(JSON.stringify(i.requested)!==JSON.stringify(n.requested))throw new Error(`Agent Run calls must inherit one model configuration: ${t.run_id}`);if(JSON.stringify(i.selection)!==JSON.stringify(n.selection))throw new Error(`Agent Run calls must inherit one selection decision: ${t.run_id}`)}}function X(t,e){return`${t}:${String(e).padStart(6,"0")}`}function Ce(t){if(_t(t),t.type==="run.started")return`${JSON.stringify(t)}
|
|
18
|
+
`;if(t.type==="run.late_finalization.assessed")return`${JSON.stringify(t)}
|
|
19
|
+
`;if(t.type==="run.finished")return`${JSON.stringify([3,"f",t.event_id,t.sequence,t.occurred_at,t.phase,t.status])}
|
|
20
|
+
`;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])}
|
|
21
|
+
`;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])}
|
|
22
|
+
`;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]])}
|
|
23
|
+
`;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])}
|
|
24
|
+
`;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]])}
|
|
25
|
+
`;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])}
|
|
26
|
+
`}function xr(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],f=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:f[0],policy_version:f[1],reasons:f[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],f=t[9],_=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:f[0],brl:f[1],fx_rate:f[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]},..._===null||!Array.isArray(_)?{}:{runtime:{reasoning_effort:_[0],service_tier:_[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],i=t[9],o=t[15],a=t[16],s=t[17],c=t[18],l=t[19],d=t[20],p=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:i[0],brl:i[1],fx_rate:i[2]??null},provider:t[10],model:t[11],source_segment_key:t[12],...p==null?{}:{attributed_spec_id:p},...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},...c==null?{}:{source_finished_at:c},...l===!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 kr(t,e,n,i,o){let a=t.native_stop??t.native_terminal;if(!a||i!==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=he.parse(y),b=e.get(g.event_id);if(b!==void 0){if(JSON.stringify(b)!==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 i=n[0],o=i.phase,a=null,s=null,c=null,l=null,d=new Map,p=new Map,u=new Map,f=new Map,_=new Map;for(let[y,g]of n.entries()){if(g.run_id!==i.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 b=d.get(g.sequence);if(b!==void 0&&b!==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"&&!si(g,a,p))throw new Error("Run V2 contains a non-retrospective record after run.finished");if(g.type==="usage.recorded"){if(ze(o,g.phase),g.phase==="execution"&&i.execution_id===null&&i.attribution_status!=="legacy_unattributed")throw new Error("Execution phase requires execution_id");if(g.supersedes_event_id!==null&&!p.has(g.supersedes_event_id))throw new Error(`Superseded usage event must occur earlier: ${g.supersedes_event_id}`);p.set(g.event_id,g),o=g.phase}if(g.type==="run.attribution.recovered"){if(!oi(i,g))throw new Error("Run attribution recovery does not match its immutable start header");if(l!==null)throw new Error("Run V2 has multiple attribution recoveries");ze(o,g.phase),o=g.phase,l=g}if(g.type==="model.selection.recorded"){if(Vt(i,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(f.has(g.invocation_id))throw new Error(`Duplicate provider terminal for invocation: ${g.invocation_id}`);f.set(g.invocation_id,g)}if(g.type==="model.call.observed"){let w=_.get(g.call_id);if(w!==void 0&&JSON.stringify(w)!==JSON.stringify(g)&&!ai(w,g))throw new Error(`Divergent duplicate Model Call: ${g.call_id}`);_.set(g.call_id,g)}if(g.type==="run.finalization.decided"){if(s!==null||c!==null)throw new Error("Run V2 has multiple finalization decisions");s=g}if(g.type==="run.late_finalization.assessed"&&(kr(g,i,a,c,s),c=g),g.type==="run.finished"){if(g.phase!==o)throw new Error("run.finished phase must match the latest phase");a=g}}let m=n.filter(y=>y.type==="usage.recorded"),h=new Set(m.map(y=>y.supersedes_event_id).filter(y=>y!==null)),v=wr(m.filter(y=>!h.has(y.event_id)));return{run:l===null?i:{...i,phase:l.phase,execution_id:l.execution_id,task_id:l.task_id,change_id:l.change_id},status:a?.status??"running",finished:a,finalization_decision:s,late_finalization_assessment:c,attribution_recovery:l,records:n,usage_records:m,effective_usage_records:v,model_selection_records:[...u.values()],provider_invocation_records:[...f.values()],model_call_records:[..._.values()]}}var qt=class{constructor(e,n,i,o,a){this.filesystem=e;this.path=n;this.started=i;this.clock=o;this.release=a;this.records=[i],this.currentPhase=i.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(yn(a,o))return o;if(e.supersedesEventId!==o.event_id)throw new Error(`Divergent source segment requires supersession: ${e.sourceSegmentKey}`)}}if(ze(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 i=this.usageRecord(e,this.nextSequence,e.occurredAt);return await this.append(i),this.records.push(i),this.nextSequence+=1,this.currentPhase=i.phase,i}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(!ci(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}`);Vt(this.started,this.records,e);let i=_i.parse({schema_version:2,event_id:e.eventId??X(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(i),this.records.push(i),this.nextSequence+=1,i}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 i=this.modelCallRecord(e,this.nextSequence,e.occurredAt);return await this.append(i),this.records.push(i),this.nextSequence+=1,i}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 i=this.records.find(a=>a.type==="provider.invocation.finished"&&a.invocation_id===e.invocationId);if(i?.type==="provider.invocation.finished"){if(!li(i,e))throw new Error(`Divergent provider terminal for invocation: ${e.invocationId}`);return i}let o=fi.parse({schema_version:2,event_id:e.eventId??X(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 i=gi.parse({schema_version:2,event_id:X(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(i),this.records.push(i),this.finishedRecord=i,this.nextSequence+=1,this.release(),i}usageRecord(e,n,i){return pi.parse({schema_version:2,event_id:e.eventId??X(this.started.run_id,n),run_id:this.started.run_id,sequence:n,occurred_at:e.occurredAt??i??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,i){return mi.parse({schema_version:2,event_id:e.eventId??X(this.started.run_id,n),run_id:this.started.run_id,sequence:n,occurred_at:e.occurredAt??i??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 Je(t){return br(t,xr)}var $t=r.string().datetime({offset:!0}),ms=r.preprocess(t=>t==="client"?"provider_reported":t,r.enum(["provider_reported","estimated","unavailable"])),vm=r.object({id:r.string().regex(/^DEC-(?:HUMAN|AI)-/),title:r.string().min(1),origin:r.enum(["human","agent"]),category:r.enum(["architecture","contract","database","security","dependency","network","infrastructure","cost","implementation"]),status:r.enum(["active","superseded","rejected"]),task:r.string().startsWith("TASK-").nullable(),change:r.string().startsWith("CHG-").nullable(),context:r.string().min(1),decision:r.string().min(1),reason:r.string().min(1),alternatives:r.array(r.string()),consequences:r.array(r.string()),reversible:r.boolean(),rollback:r.string(),confidence:r.number().min(0).max(1).nullable(),created_at:$t,confirmed_at:$t.nullable()}).strict();var wm=r.object({id:r.string().startsWith("RUN-"),task:r.string().startsWith("TASK-"),status:r.enum(["running","completed","failed"]),client:r.string().min(1),agent:r.string().min(1),model:r.string().min(1),started_at:$t,finished_at:$t.nullable(),duration_ms:r.number().int().nonnegative().nullable(),provider:r.string().min(1).nullable().default(null),token_usage:r.object({input:r.number().int().nonnegative().nullable(),cached_input:r.number().int().nonnegative().nullable().default(null),output:r.number().int().nonnegative().nullable(),reasoning:r.number().int().nonnegative().nullable(),total:r.number().int().nonnegative().nullable().default(null),source:ms}),cost:r.object({estimated_usd:r.number().nonnegative().nullable(),estimated_brl:r.number().nonnegative().nullable(),fx_rate:r.number().positive().nullable(),pricing_model:r.string().nullable(),pricing_source:r.string().nullable(),input_usd:r.number().nonnegative().nullable().default(null),cached_input_usd:r.number().nonnegative().nullable().default(null),output_usd:r.number().nonnegative().nullable().default(null),reasoning_usd:r.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:r.object({cycle_count:r.number().int().nonnegative().nullable(),source:r.enum(["repository","local-codex","manual","unavailable"]),segment_key:r.string().nullable()}).default({cycle_count:null,source:"unavailable",segment_key:null}),commands:r.array(r.string()),gates:r.array(r.string()),decisions:r.array(r.string()),evidence:r.array(r.string())}).strict();var vn=["objective","requirement_ids","acceptance_ids","write_scopes"],Rm={simple:{level:"simple",requiredFields:[...vn,"verification"],optionalFields:["risk_notes","rollback"],maximumUnresolvedQuestions:0},standard:{level:"standard",requiredFields:[...vn,"included_scope","excluded_scope","design","risks","verification","rollback"],optionalFields:["rollout","open_questions"],maximumUnresolvedQuestions:2},complex:{level:"complex",requiredFields:[...vn,"problem","outcomes","included_scope","excluded_scope","architecture","security","dag","budgets","risks","rollout","rollback","verification","independent_reviewer"],optionalFields:["open_questions"],maximumUnresolvedQuestions:3}};var Ot=r.enum(["test","eval","check","review","spec_review","quality_review","mutation","integration","cross_spec_e2e"]),Sr=r.object({schema_version:r.literal(2),assurance_version:r.literal(1),profile:r.enum(["task-lite","task-standard-2","task-standard-3","task-critical"]),risk:r.enum(["lite","standard","critical"]),minimum_validation_artifacts:r.number().int().positive(),maximum_validation_artifacts:r.number().int().positive().nullable(),minimum_evidence_artifacts:r.number().int().positive(),maximum_evidence_artifacts:r.number().int().positive().nullable(),minimum_distinct_modalities:r.number().int().positive(),complete_acceptance_coverage:r.literal(!0),evidence_per_acceptance:r.boolean(),requires_independent_verifier:r.boolean(),requires_mutation_discrimination:r.boolean(),minimum_mutation_kill_ratio:r.number().min(0).max(1).nullable(),requires_rollback:r.boolean(),requires_final_commit_evidence:r.boolean(),requires_test:r.boolean(),required_modalities:r.array(Ot)}).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 Vm=r.object({schema_version:r.literal(2),assurance_version:r.literal(1),profile:r.enum(["spec-delivery","prd-delivery"]),origin:r.enum(["spec","prd"]),minimum_parent_validation_artifacts:r.number().int().positive(),minimum_parent_evidence_artifacts:r.number().int().positive(),minimum_distinct_modalities:r.number().int().positive(),complete_acceptance_coverage:r.literal(!0),requires_acceptance_matrix:r.literal(!0),requires_independent_verifier:r.literal(!0),integration_modality:r.enum(["integration","cross_spec_e2e"]),evidence_per_acceptance:r.boolean(),evidence_per_outcome:r.boolean(),requires_mutation_discrimination:r.boolean(),minimum_mutation_kill_ratio:r.number().min(0).max(1).nullable(),requires_rollback:r.boolean(),requires_final_commit_evidence:r.boolean(),required_modalities:r.array(Ot).min(3)}).strict();function W(t){return r.array(t).superRefine((e,n)=>{let i=new Set;for(let[o,a]of e.entries())i.has(a)&&n.addIssue({code:"custom",path:[o],message:`duplicate value: ${a}`}),i.add(a)})}var Er=r.string().datetime({offset:!0}),_s=W(r.string().startsWith("AC-")).min(1),fs=r.enum(["confirmed","limited","pending","failed","not_applicable"]),gs=r.enum(["visual","interaction","api","database_schema","persistence","logs","integration"]),hs=r.string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/),ys=r.object({schema_version:r.literal(1),id:r.string().regex(/^OBS-[A-Z0-9]+(?:-[A-Z0-9]+)*$/),task_id:r.string().startsWith("TASK-"),change_id:r.string().startsWith("CHG-"),execution_id:r.string().startsWith("EXEC-"),run_id:r.string().startsWith("RUN-"),acceptance_ids:_s,proof_kind:gs,state:fs,scenario:r.string().min(1).nullable(),expected:r.string().min(1).nullable(),observed:r.string().min(1).nullable(),observed_at:Er,examiner_id:r.string().min(1),commit_sha:hs.nullable(),candidate_version:r.string().min(1).nullable(),environment:r.object({class:r.string().min(1).nullable(),id:r.string().min(1).nullable(),version:r.string().min(1).nullable()}).strict(),visual:r.object({url:r.string().url(),viewport:r.string().regex(/^\d{2,5}x\d{2,5}$/),captured_at:Er,loaded_version:r.string().min(1),examination:r.string().min(1)}).strict().nullable(),correlation_ids:W(r.string().min(1)).default([]),locators:W(r.string().min(1)).default([]),limitations:r.string().min(1).nullable(),not_applicable_reason:r.string().min(1).nullable(),pending_reason:r.string().min(1).nullable(),dependency:r.string().min(1).nullable(),resume_plan:r.string().min(1).nullable(),attempts:r.array(r.object({kind:r.enum(["initial","retry","alternative"]),recovery_action:r.string().min(1).nullable(),alternative_available:r.boolean().nullable()}).strict()).max(3)}).strict().superRefine((t,e)=>{let n=t.attempts.map(i=>i.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(vs).join(",")&&e.addIssue({code:"custom",path:["attempts"],message:"observation attempts must be initial, retry, then alternative"});for(let[i,o]of t.attempts.entries())o.kind==="retry"&&(i===0||o.recovery_action===null)&&e.addIssue({code:"custom",path:["attempts",i],message:"retry observations require a preceding initial attempt and recovery_action"}),o.kind==="alternative"&&o.alternative_available!==!0&&e.addIssue({code:"custom",path:["attempts",i,"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 i;try{i=new URL(t.visual.url)}catch{e.addIssue({code:"custom",path:["visual","url"],message:"visual URL must be a sanitized http(s) URL"});return}(i.protocol!=="http:"&&i.protocol!=="https:"||i.username||i.password||i.search||i.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 vs(t,e){return{initial:0,retry:1,alternative:2}[t]-{initial:0,retry:1,alternative:2}[e]}var Nt=r.string().datetime({offset:!0}),Ke=r.string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/).nullable(),Cr=W(r.string().startsWith("AC-")).min(1),ws=r.object({kind:r.literal("isolated_git_worktree"),protocol:r.literal("committed_node_harness_v1").optional(),harness_path:r.string().min(1).optional(),harness_blob_sha:Ke.unwrap().optional(),commit_sha:Ke.unwrap(),tree_sha:Ke.unwrap(),exit_code:r.number().int().min(-1),diagnostic:r.string().nullable().optional(),started_at:Nt,finished_at:Nt}).strict(),wn={test:"TEST-",eval:"EVAL-",check:"CHECK-",review:"REVIEW-",spec_review:"REVIEW-SPEC-",quality_review:"REVIEW-QUALITY-",mutation:"MUT-",integration:"INT-",cross_spec_e2e:"E2E-"},bs=r.object({schema_version:r.literal(2),id:r.string().min(1),kind:Ot,task_id:r.string().startsWith("TASK-"),change_id:r.string().startsWith("CHG-"),execution_id:r.string().startsWith("EXEC-"),run_id:r.string().startsWith("RUN-"),acceptance_ids:Cr,executed_at:Nt,command:r.string().min(1).nullable(),status:r.enum(["passed","failed","not_applicable"]),asserted_outcomes:W(r.string().min(1)).min(1),locators:W(r.string().min(1)).min(1),author_id:r.string().min(1),commit_sha:Ke,candidate_execution:ws.nullable().optional(),not_applicable_reason:r.string().min(1).nullable()}).strict().superRefine((t,e)=>{t.id.startsWith(wn[t.kind])||e.addIssue({code:"custom",path:["id"],message:`${t.kind} validation id must start with ${wn[t.kind]}`}),!Rr(t.kind)&&t.command===null&&e.addIssue({code:"custom",path:["command"],message:`${t.kind} validation requires its executed command`}),Dt(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"}))}),xs=r.object({schema_version:r.literal(2),id:r.string().startsWith("EVD-"),task_id:r.string().startsWith("TASK-"),change_id:r.string().startsWith("CHG-"),execution_id:r.string().startsWith("EXEC-"),run_id:r.string().startsWith("RUN-"),acceptance_ids:Cr,outcome_ids:W(r.string().startsWith("OUT-")).default([]),validation_artifact_ids:W(r.string().min(1)).min(1),observed_at:Nt,status:r.enum(["passed","not_applicable"]),summary:r.string().min(1),locators:W(r.string().min(1)).min(1),commit_sha:Ke,not_applicable_reason:r.string().min(1).nullable()}).strict().superRefine((t,e)=>{Dt(t.status,t.not_applicable_reason,e)}),Wm=r.object({...bs.shape,schema_version:r.literal(3),scope:r.literal("spec_execution"),spec_id:r.string().startsWith("SPEC-"),task_id:r.never().optional(),change_id:r.never().optional()}).strict().superRefine((t,e)=>{t.id.startsWith(wn[t.kind])||e.addIssue({code:"custom",path:["id"],message:"invalid validation prefix"}),!Rr(t.kind)&&t.command===null&&e.addIssue({code:"custom",path:["command"],message:"validation requires command"}),Dt(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"}))}),Um=r.object({...xs.shape,schema_version:r.literal(3),scope:r.literal("spec_execution"),spec_id:r.string().startsWith("SPEC-"),task_id:r.never().optional(),change_id:r.never().optional()}).strict().superRefine((t,e)=>{Dt(t.status,t.not_applicable_reason,e)});function Dt(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 Rr(t){return t==="review"||t==="spec_review"||t==="quality_review"}var bn=r.string().regex(/^[a-f0-9]{64}$/),ks=r.object({acceptance_id:r.string().regex(/^AC-[A-Z0-9-]+$/),basis:r.enum(["behavior","normative"]),modalities:r.array(r.enum(["test","check","quality_review","mutation"])).min(1),reason:r.string().trim().min(20),observable_basis:r.string().trim().min(8)}).strict(),Zm=r.object({schema_version:r.literal(1),task_id:r.string().regex(/^TASK-[A-Z0-9-]+$/),change_id:r.string().regex(/^CHG-[A-Z0-9-]+$/),execution_id:r.string().regex(/^EXEC-[A-Z0-9-]+$/),attempt_count:r.number().int().positive(),plan_revision:r.number().int().positive(),plan_hash:bn,authorization:r.object({human_decision_id:r.string().regex(/^DEC-HUMAN-[A-Z0-9-]+$/),human_decision_sha256:bn,classification_decision_id:r.string().regex(/^DEC-AI-[A-Z0-9-]+$/),classification_decision_sha256:bn}).strict(),criteria:r.array(ks).min(1)}).strict();function Tr(t,e,n={decisions:[],evidence:[],evals:[],tests:[]},i={}){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=(p,u,f)=>p.replace(new RegExp(`(## ${u}\\n\\n)([\\s\\S]*?)(?=\\n\\n## |$)`),(_,m)=>`${m}${f}`),c=(p,u,f,_)=>p.replace(new RegExp(`(## ${u}\\n\\n)${Ss(f)}(?=\\n\\n## |$)`),(m,h)=>`${h}${_}`),l=(p,u,f,_)=>p.replace(new RegExp(`(## ${u}\\n\\n)([\\s\\S]*?)(?=\\n\\n## |$)`),(m,h,v)=>{let y="Refer\xEAncias registradas (status no artefato):",g=v.startsWith(`${y}
|
|
27
|
+
`)&&v.slice(y.length+1).split(`
|
|
28
|
+
`).every(b=>/^- `[^`]+`$/.test(b));return v!==f&&!g?m:`${h}${_.length===0?f:`${y}
|
|
29
|
+
${_.map(b=>`- \`${b}\``).join(`
|
|
30
|
+
`)}`}`}),d=e;["draft","planned"].includes(t.status)||(d=c(d,"Plano","Plano preparado e aguardando execu\xE7\xE3o.",`Plano materializado; estado atual: ${t.status}.`));for(let[p,u,f]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=l(d,p,u,f);if(i.preserveManual){let p=(u,f,_,m)=>u.replace(new RegExp(`(## ${f}\\n\\n)([\\s\\S]*?)(?=\\n\\n## |$)`),(h,v,y)=>m.test(y.trimEnd())?`${v}${_}${y.slice(y.trimEnd().length)}`:h);return d=p(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\.)$/),p(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 Ss(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function zt(t){return`# ${t}
|
|
31
|
+
|
|
32
|
+
## Plano
|
|
33
|
+
|
|
34
|
+
Plano preparado e aguardando execu\xE7\xE3o.
|
|
35
|
+
|
|
36
|
+
## Implementa\xE7\xE3o
|
|
37
|
+
|
|
38
|
+
Ainda n\xE3o executada.
|
|
39
|
+
|
|
40
|
+
## Decis\xF5es
|
|
41
|
+
|
|
42
|
+
Nenhuma decis\xE3o registrada.
|
|
43
|
+
|
|
44
|
+
## Evid\xEAncias
|
|
45
|
+
|
|
46
|
+
Nenhuma evid\xEAncia registrada.
|
|
47
|
+
|
|
48
|
+
## Evals
|
|
49
|
+
|
|
50
|
+
Ainda n\xE3o executados.
|
|
51
|
+
|
|
52
|
+
## Testes
|
|
53
|
+
|
|
54
|
+
Ainda n\xE3o executados.
|
|
55
|
+
|
|
56
|
+
## Resultado
|
|
57
|
+
|
|
58
|
+
Aguardando execu\xE7\xE3o.`}function Ar(t){return`# ${t.title}
|
|
59
|
+
|
|
60
|
+
## Problema
|
|
61
|
+
|
|
62
|
+
${t.problem}
|
|
63
|
+
|
|
64
|
+
## Outcomes
|
|
65
|
+
|
|
66
|
+
${Ge(t.outcomes)}
|
|
67
|
+
|
|
68
|
+
## Restri\xE7\xF5es
|
|
69
|
+
|
|
70
|
+
${Ge(t.constraints)}
|
|
71
|
+
|
|
72
|
+
## Fora de escopo
|
|
73
|
+
|
|
74
|
+
${Ge(t.non_goals)}`}function Ir(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}
|
|
75
|
+
|
|
76
|
+
${e.stack_description}
|
|
77
|
+
|
|
78
|
+
${e.stack_components.map(i=>`- ${i.kind}: ${i.name} ${i.version} (${i.version_source})`).join(`
|
|
79
|
+
`)}`;return`# ${t.title}
|
|
80
|
+
|
|
81
|
+
## Objetivo
|
|
82
|
+
|
|
83
|
+
${t.objective}
|
|
84
|
+
|
|
85
|
+
## Escopo
|
|
86
|
+
|
|
87
|
+
${Ge(t.included_scope)}
|
|
88
|
+
|
|
89
|
+
## Fora de escopo
|
|
90
|
+
|
|
91
|
+
${Ge(t.excluded_scope)}
|
|
92
|
+
|
|
93
|
+
## Stack de implementa\xE7\xE3o
|
|
94
|
+
|
|
95
|
+
${n}`}function Ge(t){return t.length===0?"Nenhum.":t.map(e=>`- ${e}`).join(`
|
|
96
|
+
`)}async function Pr(t,e,n,i,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`)]),c={decisions:s[0].map(l=>l.slice(a.length+1)),evidence:s[1].map(l=>l.slice(a.length+1)),evals:s[2].map(l=>l.slice(a.length+1)),tests:s[3].map(l=>l.slice(a.length+1))};return Tr(n,i,c,o)}function xn(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 qr(t,e){return t.status==="planned"&&xn(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 kn(t,e,n,i){let o=new Intl.DateTimeFormat("en-CA",{timeZone:i,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(n.now()),a=s=>{let c=o.find(l=>l.type===s)?.value;if(c===void 0)throw new Error(`Unable to format ID date part: ${s}`);return c};return[t,a("year"),a("month"),a("day"),a("hour"),a("minute"),ti(e),ni()].join("-")}async function Re(t,e,n,i){let o=await le(t,e,n,i);if(o===null)throw new Error(`${n} not found: ${i}`);return o}var Vr={draft:["ready","blocked","failed","cancelled"],ready:["active","blocked","failed","cancelled"],active:["delivered","blocked","failed","cancelled"],blocked:["active","failed","cancelled"],delivered:[],failed:[],cancelled:[]},$r={draft:["ready","blocked","failed","cancelled"],ready:["active","blocked","failed","cancelled"],active:["delivered","blocked","failed","cancelled"],blocked:["active","failed","cancelled"],delivered:[],failed:[],cancelled:[]},Or={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:[]},Sn={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 me(t,e,n,i){if(!t[e].includes(n))throw new Error(`Invalid ${i} transition: ${e} -> ${n}`)}import{createHash as Es}from"node:crypto";var S=class extends Error{name="ExecutionClientTurnConflictError"};function En(t){return D.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:Le.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 Cn(t){return D.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:Le.parse(t.policy),dag:{nodes:[],topological_order:[]},created_at:t.now,updated_at:t.now,started_at:null,finished_at:null,result:null})}function N(t){let e;try{e=JSON.parse(t)}catch{throw new S("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 S("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((i,o)=>{if(i===null||typeof i!="object")return!0;let a=i,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(i=>i.target_task_id)).size!==n.length||new Set(n.map(i=>i.successor_run_id)).size!==n.length)throw new S("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&&Nr(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&&Nr(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 S("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 Ze(t){return t instanceof Error&&"code"in t&&t.code==="EEXIST"}function Nr(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 Dr(t,e,n){let i=N(await t.readText(e)),o={schema_version:9,kind:"delivery",...n};if(i.schema_version===9){if(JSON.stringify(i)!==JSON.stringify(o))throw new S("Conversation handoff conflicts with target or authorization");return i}if(i.schema_version!==1||i.kind!=="interaction"||i.execution_id!==n.interaction_execution_id||i.client_turn_id!==n.client_turn_id||i.origin.type!=="interaction")throw new S("Conversation handoff requires its original interaction claim");return await t.writeTextAtomic(e,`${JSON.stringify(o)}
|
|
97
|
+
`),o}async function zr(t,e,n){if(!await t.exists(e))return null;let i=N(await t.readText(e));if(i.client_turn_id!==n)throw new S("Persisted client turn claim has another identity");return i.schema_version===9?i:null}async function Mr(t,e,n){let i;try{i=await t.readText(e)}catch(s){if(s instanceof Error&&"code"in s&&s.code==="ENOENT")return null;throw s}let o=N(i);if(o.client_turn_id!==n)throw new S("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 Fr(t,e,n,i){let o=null;try{o=N(await t.readText(e))}catch(u){if(!(u instanceof Error&&"code"in u&&u.code==="ENOENT"))throw u}let a=i.sameTurn?7:8,s={execution_id:i.executionId,origin:i.specId===null?{type:"task",task_id:i.targetTaskId}:{type:"spec",spec_id:i.specId},predecessor_run_id:i.predecessorRunId,successor_run_id:i.proposedSuccessorRunId,target_task_id:i.targetTaskId,authorization_sha256:i.authorizationSha256};if(o?.client_turn_id!==void 0&&o.client_turn_id!==i.clientTurnId)throw new S("Persisted client turn claim has another identity");if(o?.schema_version===1&&(!i.sameTurn||o.kind!=="delivery"||o.execution_id!==i.maintenanceExecutionId||o.origin.type!=="task"))throw new S("Sequence requires the maintenance delivery claim");if(o===null&&i.sameTurn)throw new S("Sequence requires the maintenance delivery claim");if(o!==null&&o.schema_version===2)throw new S("SPEC handoff cannot become a publication sequence");let c=await n(i.clientTurnId);if(c!==null&&(c.schema_version!==a||c.maintenance_run_id!==i.maintenanceRunId||c.maintenance_execution_id!==""&&c.maintenance_execution_id!==i.maintenanceExecutionId))throw new S("Sequence has another maintenance authority");let l=c?.steps.find(u=>u.target_task_id===s.target_task_id);if(l!==void 0){if(JSON.stringify({...l,successor_run_id:s.successor_run_id})!==JSON.stringify(s))throw new S("Sequence replay has another target or proof");return l.successor_run_id}if((c?.steps.at(-1)?.successor_run_id??i.maintenanceRunId)!==i.predecessorRunId)throw new S("Sequence predecessor is not the previous root");let p={schema_version:a,client_turn_id:i.clientTurnId,maintenance_run_id:i.maintenanceRunId,maintenance_execution_id:i.maintenanceExecutionId,kind:"delivery",steps:[...c?.steps??[],s]};return o===null?await t.writeTextExclusive(e,`${JSON.stringify(p)}
|
|
98
|
+
`):await t.writeTextAtomic(e,`${JSON.stringify(p)}
|
|
99
|
+
`),s.successor_run_id}var Mt=class{constructor(e,n){this.filesystem=e;this._layout=n}filesystem;_layout;async claimIdentity(e,n,i,o,a){let s=a.filter(u=>u.client_turn_id===e);if(s.length>1)throw new S(`Client turn resolves to multiple Executions: ${e}`);let c=s[0];c!==void 0&&this.assertExpectedExecution(c,i,o);let l={schema_version:1,client_turn_id:e,execution_id:c?.id??n,kind:i,origin:o},d=this.claimPath(e);try{return await this.filesystem.writeTextExclusive(d,`${JSON.stringify(l)}
|
|
100
|
+
`),l.execution_id}catch(u){if(!Ze(u))throw u}let p=N(await this.filesystem.readText(d));if(this.assertCompatibleClaim(p,e,i,o),!("execution_id"in p))throw new S("Sequence cannot be claimed as one Execution");return p.execution_id}async claimExplicitIdentity(e,n,i,o){let a={schema_version:1,client_turn_id:e,execution_id:n,kind:i,origin:o},s=this.claimPath(e);try{return await this.filesystem.writeTextExclusive(s,`${JSON.stringify(a)}
|
|
101
|
+
`),n}catch(l){if(!Ze(l))throw l}let c=N(await this.filesystem.readText(s));if(this.assertCompatibleClaim(c,e,i,o),!("execution_id"in c))throw new S("Sequence cannot be claimed as one Execution");return c.execution_id}async claimSpecHandoff(e){let n=this.claimPath(e.clientTurnId),i=N(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:i.schema_version===2?i.successor_run_id:e.proposedSuccessorRunId,authorization_sha256:e.authorizationSha256};if(i.schema_version===2){if(JSON.stringify(i)!==JSON.stringify(o))throw new S("Same-turn handoff conflicts with its claimed target or authorization");return i.successor_run_id}if(i.client_turn_id!==e.clientTurnId||i.kind!=="interaction"||i.execution_id!==e.interactionExecutionId||i.origin.type!=="interaction")throw new S("Same-turn handoff requires the original interaction claim");return await this.filesystem.writeTextAtomic(n,`${JSON.stringify(o)}
|
|
102
|
+
`),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 i=N(n);if(i.client_turn_id!==e)throw new S("Persisted client turn claim has another identity");return i.schema_version===2?i:null}async claimConversationHandoff(e){return Dr(this.filesystem,this.claimPath(e.client_turn_id),e)}async readConversationHandoff(e){return zr(this.filesystem,this.claimPath(e),e)}async claimPostPublicationHandoff(e){let n=this.claimPath(e.clientTurnId),i=N(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:i.schema_version===3||i.schema_version===5?i.successor_run_id:e.proposedSuccessorRunId,target_task_id:e.targetTaskId,authorization_sha256:e.authorizationSha256};if(i.schema_version===3||i.schema_version===5){if(JSON.stringify(i)!==JSON.stringify(o))throw new S("Post-publication handoff conflicts with its claim");return i.successor_run_id}if(i.schema_version!==1||i.client_turn_id!==e.clientTurnId||i.kind!=="delivery"||i.execution_id!==e.maintenanceExecutionId||i.origin.type!=="task")throw new S("Post-publication handoff requires the original maintenance delivery claim");return await this.filesystem.writeTextAtomic(n,`${JSON.stringify(o)}
|
|
103
|
+
`),o.successor_run_id}async readPostPublicationHandoff(e){try{let n=N(await this.filesystem.readText(this.claimPath(e)));if(n.client_turn_id!==e)throw new S("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),i={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(i)}
|
|
104
|
+
`),i.successor_run_id}catch(a){if(!Ze(a))throw a}let o=N(await this.filesystem.readText(n));if(o.schema_version!==4&&o.schema_version!==6||JSON.stringify(o)!==JSON.stringify({...i,successor_run_id:o.successor_run_id}))throw new S("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 i=N(n);if(i.client_turn_id!==e)throw new S("Persisted client turn claim has another identity");return i.schema_version===4||i.schema_version===6?i:null}async readPostPublicationSequence(e){return Mr(this.filesystem,this.claimPath(e),e)}async claimPostPublicationSequence(e){return Fr(this.filesystem,this.claimPath(e.clientTurnId),n=>this.readPostPublicationSequence(n),e)}async createExecution(e,n,i,o,a,s){try{return await this.filesystem.writeTextExclusive(o,a),e}catch(c){if(!Ze(c))throw c;return this.assertExpectedExecution(await s(),n,i)}}assertExpectedExecution(e,n,i){if(e.kind!==n||JSON.stringify(e.origin)!==JSON.stringify(i))throw new S(`Client turn ${e.client_turn_id??"unknown"} resolves to incompatible ${e.kind??"legacy-delivery"} Execution ${e.id}`);return e}claimPath(e){let n=Es("sha256").update(e).digest("hex");return mt("execution-client-turn",n)}assertCompatibleClaim(e,n,i,o){if(!("origin"in e))throw new S("Client turn is already a publication sequence");if(e.client_turn_id!==n||e.kind!==i||JSON.stringify(e.origin)!==JSON.stringify(o))throw new S(`Client turn ${n} is already claimed by incompatible Execution ${e.execution_id}`)}};var Y=class{constructor(e,n){this.filesystem=e;this.layout=n;Qe(n),this.clientTurnClaims=new Mt(e,n)}filesystem;layout;clientTurnClaims;async read(e){let n=await Re(this.filesystem,this.layout,"execution",e),i=$(await this.filesystem.readText(n),D);return{execution:i.metadata,body:i.body}}async list(){return Te(this.filesystem,this.layout.entityRoot("execution"),"execution.md",D)}async createInteraction(e){let n={type:"interaction",conversation_id:e.conversationId},i=await this.clientTurnClaims.claimIdentity(e.clientTurnId,e.id,"interaction",n,await this.list()),o=await this.read(i).catch(()=>null);if(o!==null)return this.clientTurnClaims.assertExpectedExecution(o.execution,"interaction",n);let s=(e.clock??new T).now().toISOString(),c=En({id:i,clientTurnId:e.clientTurnId,origin:n,policy:e.policy,now:s});return this.clientTurnClaims.createExecution(c,"interaction",n,this.path(c.id),this.serialize(c),async()=>(await this.read(c.id)).execution)}async createDeliveryIntake(e){let n=await this.clientTurnClaims.claimIdentity(e.clientTurnId,e.id,"delivery",e.origin,await this.list()),i=await this.read(n).catch(()=>null);if(i!==null)return this.clientTurnClaims.assertExpectedExecution(i.execution,"delivery",e.origin);let a=(e.clock??new T).now().toISOString(),s=Cn({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 i=await this.read(e);if(i.execution.plan_hash===n.plan_hash)return i.execution;if(Le.parse(n.policy),i.execution.kind!=="delivery"||i.execution.plan_hash!==null||i.execution.plan_revision!==null||JSON.stringify(i.execution.origin)!==JSON.stringify(n.origin))throw new TypeError(`Execution ${e} is not a matching delivery intake`);let o=D.parse({...n,kind:"delivery",client_turn_id:i.execution.client_turn_id,revision:i.execution.revision+1,created_at:i.execution.created_at});return await this.write(o),o}async claimClientTurn(e,n){let i=await this.read(e),o=i.execution.kind??"delivery",a=await this.clientTurnClaims.claimExplicitIdentity(n,e,o,i.execution.origin);if(a!==e){let c=await this.read(a);return this.clientTurnClaims.assertExpectedExecution(c.execution,o,i.execution.origin)}if(i.execution.kind==="interaction"){if(i.execution.client_turn_id!==n)throw new Error(`Interaction Execution ${e} belongs to another client turn`);return i.execution}if(i.execution.client_turn_id===n)return i.execution;if(i.execution.client_turn_id!=null)throw new Error(`Delivery Execution ${e} already belongs to another client turn`);let s=D.parse({...i.execution,revision:i.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[i,o]=await Promise.all([this.read(e),this.read(n)]);if(i.execution.origin.type!=="spec"||o.execution.origin.type!=="prd")throw new TypeError("Child Execution must originate from a SPEC under a PRD Execution");if(i.execution.parent_execution_id===n)return i.execution;if(i.execution.parent_execution_id!=null)throw new TypeError(`Execution ${e} is already linked to ${i.execution.parent_execution_id}`);if(["completed","failed","cancelled"].includes(o.execution.status))throw new TypeError(`Parent Execution ${n} is terminal`);let a=D.parse({...i.execution,parent_execution_id:n,revision:i.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,i=null,o=new T,a=null){let s=await this.read(e);me(Sn,s.execution.status,n,"Execution");let c=o.now().toISOString(),l=["completed","failed","cancelled"].includes(n),d=D.parse({...s.execution,revision:s.execution.revision+1,status:n,status_reason:["blocked","failed","cancelled"].includes(n)?a??i??`Execution moved to ${n}.`:null,updated_at:c,started_at:n==="running"&&s.execution.started_at===null?c:s.execution.started_at,finished_at:l?c:null,result:l?i: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 j({metadata:D.parse(e),body:n})}path(e){return this.layout.activePath("execution",e)}};var Ae=class{constructor(e,n){this.filesystem=e;this.layout=n;Qe(n)}filesystem;layout;async create(e){let n=e.clock??new T,i=n.now().toISOString(),o=e.id??kn("PRD",e.shortName,n,this.layout.project.timezone),a=[...e.outcomes??[]],s=ee.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??vi(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:i,updated_at:i});return await this.write(s,Ar(s),!0),s}async createReworkSuccessor(e,n){let{prd:i}=await this.read(e);if(i.status!=="cancelled")throw new TypeError(`PRD ${e} must be cancelled before rework`);return this.create({...n,targetRelease:n.targetRelease??i.target_release,reworkOfPrdId:i.id,tags:["rework"]})}async read(e){let n=await Re(this.filesystem,this.layout,"prd",e),i=$(await this.filesystem.readText(n),ee);return{prd:i.metadata,body:i.body}}async list(){return Te(this.filesystem,this.layout.entityRoot("prd"),".md",ee)}async setPreparedPlan(e,n){let i=U.parse(n),o=await this.read(e);if(i.source.type==="prd"&&i.acceptance_policy===void 0&&o.prd.prepared_plan?.hash!==i.hash&&o.prd.plan_ref?.hash!==i.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=hi(i,e);if(a.length===0)throw new TypeError(`PRD ${e} requires at least one SPEC`);let s=await Te(this.filesystem,this.layout.entityRoot("spec"),".md",H),c=new Map(s.map(d=>[d.id,d]));for(let d of a){let p=c.get(d);if(p===void 0)throw new TypeError(`PRD SPEC does not resolve: ${d}`);if(p.prd_id!==e)throw new TypeError(`SPEC ${d} does not belong to PRD ${e}`);if(["active","delivered","cancelled"].includes(p.status))throw new TypeError(`SPEC ${d} cannot be prepared from status ${p.status}`);await ht(p.implementation,this.filesystem,this.layout)}let l=ee.parse({...o.prd,revision:o.prd.revision+1,prepared_plan:i,plan_ref:null,updated_at:i.prepared_at});return await this.write(l,o.body),l}async transition(e,n,i=new T,o=null){let a=await this.read(e);me(Vr,a.prd.status,n,"PRD");let s=typeof i=="string"?new T:i,c=typeof i=="string"?i:o,l=ee.parse({...a.prd,revision:a.prd.revision+1,status:n,status_reason:["blocked","failed","cancelled"].includes(n)?c??`PRD moved to ${n}.`:null,updated_at:s.now().toISOString()});return await this.write(l,a.body),l}async normalizePreparedPlan(e,n){let i=await this.read(e);if(i.prd.plan_ref?.hash===n.hash)return i.prd;if(i.prd.prepared_plan?.hash!==n.hash)throw new Error(`PRD ${e} does not contain PreparedPlan ${n.hash}`);let o=ee.parse({...i.prd,revision:i.prd.revision+1,prepared_plan:null,plan_ref:Fe(n),updated_at:new Date().toISOString()});return await this.write(o,i.body),o}path(e){return this.layout.activePath("prd",e)}async write(e,n,i=!1){await this.filesystem[i?"writeTextAtomicExclusive":"writeTextAtomic"](this.path(e.id),j({metadata:ee.parse(e),body:n}))}},Ie=class{constructor(e,n){this.filesystem=e;this.layout=n;Qe(n)}filesystem;layout;async create(e){let n=e.clock??new T,i=n.now().toISOString(),o=H.parse({schema_version:2,id:e.id??kn("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:i,updated_at:i});return await this.write(o,Ir(o),!0),o}async read(e){let n=await Re(this.filesystem,this.layout,"spec",e),i=$(await this.filesystem.readText(n),H);return{spec:i.metadata,body:i.body}}async list(){return Te(this.filesystem,this.layout.entityRoot("spec"),".md",H)}async retargetPublishedRelease(e,n){let i=await this.read(e);if(i.spec.release_retarget!==null||i.spec.status!=="active"||i.spec.target_release!==n.from||i.spec.plan_ref===null)throw new TypeError(`SPEC ${e} cannot be retargeted from its current lifecycle state`);let o=new Date().toISOString(),a=H.parse({...i.spec,revision:i.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,i.body),a}async setPreparedPlan(e,n){let i=U.parse(n);if(i.source.type!=="spec"||i.source.spec_id!==e)throw new TypeError(`Prepared plan source must be spec ${e}`);let o=await this.read(e);if(i.acceptance_policy===void 0&&o.spec.prepared_plan?.hash!==i.hash&&o.spec.plan_ref?.hash!==i.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 ht(o.spec.implementation,this.filesystem,this.layout);let a=H.parse({...o.spec,revision:o.spec.revision+1,prepared_plan:i,plan_ref:null,updated_at:i.prepared_at});return await this.write(a,o.body),a}async transition(e,n,i=new T,o=null){let a=await this.read(e);me($r,a.spec.status,n,"DeliverySpec");let s=typeof i=="string"?new T:i,c=typeof i=="string"?i:o;["active","delivered"].includes(n)&&await ht(a.spec.implementation,this.filesystem,this.layout);let l=H.parse({...a.spec,revision:a.spec.revision+1,status:n,status_reason:["blocked","failed","cancelled"].includes(n)?c??`SPEC moved to ${n}.`:null,updated_at:s.now().toISOString()});return await this.write(l,a.body),l}async normalizePreparedPlan(e,n){let i=await this.read(e);if(i.spec.plan_ref?.hash===n.hash)return i.spec;if(i.spec.prepared_plan?.hash!==n.hash)throw new Error(`SPEC ${e} does not contain PreparedPlan ${n.hash}`);let o=H.parse({...i.spec,revision:i.spec.revision+1,prepared_plan:null,plan_ref:Fe(n),updated_at:new Date().toISOString()});return await this.write(o,i.body),o}path(e){return this.layout.activePath("spec",e)}async write(e,n,i=!1){await this.filesystem[i?"writeTextAtomicExclusive":"writeTextAtomic"](this.path(e.id),j({metadata:H.parse(e),body:n}))}},ae=class{constructor(e,n){this.filesystem=e;this.layout=n;Qe(n)}filesystem;layout;async read(e){let n=await Re(this.filesystem,this.layout,"change",e),i=$(await this.filesystem.readText(n),J);return{change:i.metadata,body:i.body}}async createDraft(e){let i=(e.clock??new T).now().toISOString(),o=J.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:i,updated_at:i,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 i=await this.read(e);if(i.change.status==="planned"&&qr(i.change,n))return i.change;if(i.change.status!=="draft"||!xn(i.change,n))throw new TypeError(`Change ${e} does not match its Task draft`);let o=J.parse({...n,revision:i.change.revision+1,created_at:i.change.created_at,updated_at:n.updated_at});return await this.write(o),o}async list(){return Te(this.filesystem,this.layout.entityRoot("change"),"change.md",J)}async transition(e,n,i=null,o=new T,a=null){let s=await this.read(e);me(Or,s.change.status,n,"Change");let c=o.now().toISOString(),l=["completed","failed","cancelled"].includes(n),d=J.parse({...s.change,revision:s.change.revision+1,status:n,status_reason:["blocked","failed","cancelled"].includes(n)?a??i??`Change moved to ${n}.`:null,updated_at:c,started_at:n==="executing"&&s.change.started_at===null?c:s.change.started_at,finished_at:l?c:null,result:l?i:null});return await this.write(d,await Pr(this.filesystem,this.path(e),d,s.body)),d}async write(e,n=zt(e.title)){await this.filesystem.writeTextAtomic(this.path(e.id),this.serialize(e,n))}serialize(e,n=zt(e.title)){return j({metadata:J.parse(e),body:n})}path(e){return this.layout.activePath("change",e)}};function Rn(t){return`# Execution ${t.id}
|
|
105
|
+
|
|
106
|
+
## Plano
|
|
107
|
+
|
|
108
|
+
DAG e pol\xEDtica est\xE3o persistidas no frontmatter.
|
|
109
|
+
|
|
110
|
+
## Progresso
|
|
111
|
+
|
|
112
|
+
Estado atual: ${t.status}.
|
|
113
|
+
|
|
114
|
+
## Resultado
|
|
115
|
+
|
|
116
|
+
${t.result??t.status_reason??"Ainda n\xE3o conclu\xEDda."}`}async function Te(t,e,n,i){let o=await t.listFiles(e,n);return Promise.all(o.map(async a=>$(await t.readText(a),i).metadata))}function Qe(t){if(t.version===1)throw new TypeError("V2 repositories require a modern WorkspaceLayout")}var Cs=["lite","standard","critical"],Ft=r.string().datetime({offset:!0}),sf=r.object({id:r.string().startsWith("SPEC-"),capability:r.string().min(1),title:r.string().min(1),status:r.enum(["active","deprecated"]).default("active"),version:r.number().int().positive().default(1),updated_at:Ft}).strict();var cf=r.object({id:r.string().startsWith("CHG-"),title:r.string().min(1),status:r.enum(["draft","planned","executing","verifying","completed","failed","blocked","cancelled"]),risk:r.enum(Cs),capabilities:r.array(r.string().startsWith("SPEC-")),requirements:r.array(r.string().startsWith("REQ-")),tasks:r.array(r.string().startsWith("TASK-")),human_decisions:r.array(r.string().startsWith("DEC-HUMAN-")),agent_decisions:r.array(r.string().startsWith("DEC-AI-")),created_at:Ft,updated_at:Ft,completed_at:Ft.nullable().default(null)}).strict();var _e=["validate","develop","review","fix","verify","close"];var mg=5*6e4;var tt=r.object({outcome:r.enum(["completed","blocked","failed","cancelled"]),summary:r.string().trim().min(1),evidence_ids:r.array(r.string().min(1)),changed_files:r.array(r.string().min(1))}).strict();var qn=r.string().datetime(),Vn=r.object({id:r.string().min(1),acceptance_ids:r.array(r.string().min(1))}).strict(),Fs=r.object({soft_cycles:r.number().int().positive(),max_attempts:r.number().int().positive().nullable()}).strict(),Ls=r.object({phase:r.enum(_e),event_id:r.string().min(1),state_hash:r.string().regex(/^[a-f0-9]{64}$/),cycles:r.number().int().nonnegative(),input_tokens:r.number().int().nonnegative().nullable(),measurement_source:r.enum(["provider-uncached-input","observable-context-fallback","unavailable"]),checkpoint_required:r.boolean()}).strict(),js=r.object({schema_version:r.literal(1),id:r.string().min(1),phase:r.enum(_e),status:r.enum(["running","blocked","completed"]),revision:r.number().int().positive(),acceptance_ids:r.array(r.string().min(1)).min(1),budgets:r.object(Object.fromEntries(_e.map(t=>[t,Fs]))),attempts:r.object(Object.fromEntries(_e.map(t=>[t,r.number().int().nonnegative()]))),checkpoints:r.array(Ls),evidence:r.array(Vn),processed_event_ids:r.array(r.string().min(1)),blocker:r.string().min(1).nullable()}).strict(),jt=r.enum(["execution_override","task_override","automatic_policy","project_defaults"]),Ws=r.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"]),Us=r.object({model:r.string().min(1),reasoning_effort:r.enum(["low","medium","high","xhigh"]),velocity:r.literal("standard"),origin:jt,sources:r.object({model:jt,reasoning_effort:jt,velocity:jt}).strict(),policy_version:r.string().min(1),reasons:r.array(Ws).min(1)}).strict(),Hs=r.object({invocation_id:r.string().regex(/^INV-[A-Z0-9-]+$/),run_id:r.string().min(1).nullable().default(null),phase:r.enum(_e),role:r.enum(["builder","verifier","finalizer"]),checkpoint_id:r.string().min(1).nullable(),checkpoint_hash:r.string().regex(/^[a-f0-9]{64}$/).nullable(),selection:Us.nullable().default(null)}).strict(),Js=r.object({astra_diagnostic:Xt.optional(),rework:r.enum(["localized","structural"]),rework_cost:r.enum(["medium","high"]),findings:r.array(r.string().min(1)).default([]),complexity:r.enum(["simple","standard","complex"]),transversality:r.enum(["local","multi_module","cross_system"]),ambiguity:r.enum(["low","medium","high"]),bounded:r.boolean(),high_volume:r.boolean(),xhigh_triggers:r.array(r.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(),Gr=r.object({task_id:r.string().min(1),status:r.enum(["available","unavailable","quality_below_floor"]),evidence_ids:r.array(r.string().min(1)),validation_ids:r.array(r.string().min(1)),rework_count:r.number().int().nonnegative().nullable(),quality_score:r.number().nonnegative().nullable(),quality_floor:r.number().nonnegative().nullable(),cost_delta_usd:r.number().nullable(),economy_status:r.enum(["available","unavailable"])}).strict(),Bs=r.object({baseline_task_id:r.string().min(1).nullable(),baseline_equivalence_id:r.string().min(1).nullable(),model:r.string().min(1).nullable(),reasoning_effort:r.enum(["low","medium","high","xhigh"]).nullable(),context_budget_tokens:r.number().int().nonnegative().nullable(),cached_context_tokens:r.number().int().nonnegative().nullable(),early_stop_reason:r.string().min(1).nullable(),retry_count:r.number().int().nonnegative().nullable(),rework_count:r.number().int().nonnegative().nullable(),observed_cost_usd:r.number().nonnegative().nullable(),baseline_observed_cost_usd:r.number().nonnegative().nullable(),quality_score:r.number().nonnegative().nullable(),quality_floor:r.number().nonnegative().nullable()}).strict(),Ks=r.object({provider:r.enum(["codex","claude"]),host_authentication_available:r.boolean(),requires_external_provider:r.boolean(),requires_remote_operation:r.boolean()}).strict(),Gs=r.object({identity:r.string().min(1),replay_key:r.string().regex(/^[a-f0-9]{64}$/),validation_ids:r.array(r.string().min(1)),evidence_ids:r.array(r.string().min(1))}).strict(),Zs=r.object({candidate_fingerprint:r.string().regex(/^[a-f0-9]{64}$/).nullable(),proof_fingerprint:r.string().regex(/^[a-f0-9]{64}$/),semantic_attempts:r.number().int().nonnegative(),classification:r.enum(["unknown","localized","structural"]),proof_delta:r.enum(["none","added","replaced"]),repeated_without_delta:r.boolean(),elapsed_reassessment:r.literal("unavailable"),decision:r.enum(["shadow_continue","shadow_rereview","shadow_block"])}).strict(),Qs=r.object({id:r.string().min(1),rule:r.string(),path:r.string(),line:r.number().int().positive(),severity:r.enum(["low","medium","high","critical"]),message:r.string(),status:r.enum(["open","resolved","waived"]),resolution_evidence_id:r.string().nullable()}).strict(),Xs=r.object({id:r.string().min(1),executor_id:r.string().min(1),reviewer_id:r.string().min(1),max_repair_cycles:r.number().int().nonnegative().nullable(),repair_cycles:r.number().int().nonnegative(),findings:r.array(Qs),reviewer_approved:r.boolean()}).strict(),Ys=r.object({autonomy:Qt.optional(),finalizer_decision:tt.optional(),recovery_invocation:r.object({id:r.string().min(1),run_id:r.string().nullable()}).strict().optional(),recovery_plan:r.object({hypothesis:r.string().min(1),test:r.string().min(1),executor_model:r.string().min(1)}).strict().optional(),id:r.string().min(1),change_id:r.string().min(1),title:r.string().min(1),objective:r.string().min(1),risk:r.enum(["lite","standard","critical"]),priority:r.number().int(),depends_on:r.array(r.string().min(1)),acceptance_ids:r.array(r.string().min(1)).min(1),write_scopes:r.array(r.string().min(1)),scope_receipt:r.object({receipt_id:r.string().min(1),current_scopes:r.array(r.string().min(1)),delta_scopes:r.array(r.string().min(1))}).optional(),child_execution_id:r.string().min(1).optional(),builder:r.object({id:r.string().min(1),model:r.string().min(1),reasoning_effort:r.enum(["low","medium","high","xhigh"]).optional(),tools:r.array(r.string()).optional(),execution_eligibility:r.array(r.enum(["interaction","delivery"])).optional()}).optional(),verifier:r.object({id:r.string().min(1),model:r.string().min(1),reasoning_effort:r.enum(["low","medium","high","xhigh"]).optional(),tools:r.array(r.string()).optional(),execution_eligibility:r.array(r.enum(["interaction","delivery"])).optional()}).optional(),commit:r.object({agent:r.enum(["CODEX","CLAUDE"]),execution_id:r.string().min(1),change_id:r.string().min(1),task_id:r.string().min(1),title:r.string().min(1),prd_id:r.string().min(1).nullable(),spec_id:r.string().min(1).nullable()}).strict().optional(),runtime:dt.optional(),model_profile:pt.optional(),assurance_contract:Sr.optional(),outcome_measurement:Bs.optional(),status:r.enum(["planned","running","completed","failed","blocked"]),worktree_path:r.string().min(1).nullable(),integration_commit:r.string().min(1).nullable(),changed_files:r.array(r.string().min(1)).default([]),task_run_id:r.string().min(1).nullable().default(null),finalizer_approved:r.boolean().default(!1),closure_pending:r.boolean().default(!1),finalization_pending:r.boolean().default(!1),lifecycle_cleanup:r.object({handoff_path:r.string().min(1),invocation_run_id:r.string().min(1).nullable(),task_run_id:r.string().min(1).nullable(),invocation_finished:r.boolean(),task_finished:r.boolean(),last_error:r.string().nullable()}).strict().optional(),active_invocation:Hs.nullable(),active_diagnostic:r.object({invocation_id:r.string().regex(/^INV-[A-Z0-9-]+$/),run_id:r.string().min(1).nullable(),status:r.enum(["requested","completed","blocked"]),cycle:r.union([r.literal(1),r.literal(2),r.literal(3)]),evidence_fingerprint:r.string().regex(/^[a-f0-9]{64}$/),executor_attempt_id:r.string().min(1).nullable(),handback:ut.nullable()}).strict().nullable().default(null),handback:ut.nullable().default(null),last_executor_invocation_id:r.string().min(1).nullable().default(null),rework_profile:Js.nullable().default(null),sdc:js,validation_ids:r.array(r.string().min(1)),evidence:r.array(Vn),outcome_projection:Gr.nullable().default(null),validation_attempts:r.array(Gs).default([]),convergence_observations:r.array(Zs).default([]),qa_session:Xs.nullable().default(null),qa_pending_resolutions:r.array(r.object({finding_id:r.string().min(1),evidence_id:r.string().min(1)}).strict()).default([]),qa_approval_observed:r.boolean().default(!1),qa_review_candidate_fingerprint:r.string().regex(/^[a-f0-9]{64}$/).nullable().default(null),last_error:r.string().min(1).nullable()}).strict(),uy=r.object({schema_version:r.literal(1),execution_id:r.string().min(1),lease_ms:r.number().int().min(5e3).max(Number.MAX_SAFE_INTEGER).nullable().default(null),source:r.enum(["task","spec","prd"]),operational_context:Ks.default({provider:"codex",host_authentication_available:!1,requires_external_provider:!1,requires_remote_operation:!1}),status:r.enum(["running","completed","failed","blocked"]),revision:r.number().int().nonnegative(),created_at:qn,updated_at:qn,execution_started_at:qn.nullable().default(null),invocation_count:r.number().int().nonnegative().default(0),stalled_cycles:r.number().int().nonnegative().default(0),handoff_worktree_path:r.string().min(1).nullable().default(null),handoff_branch:r.string().min(1).nullable().default(null),handoff_commit:r.string().min(1).nullable().default(null),parent_acceptance:r.object({run_id:r.string().min(1).nullable(),finalizer_run_id:r.string().min(1).nullable().default(null),invocation_id:r.string().regex(/^INV-[A-Z0-9-]+$/).nullable().default(null),checkpoint_id:r.string().min(1).nullable().default(null),checkpoint_hash:r.string().min(1).nullable().default(null),candidate:r.object({handoff_worktree_path:r.string().min(1),handoff_commit:r.string().min(1),validation_ids:r.array(r.string().min(1)),evidence:r.array(Vn),task_outcomes:r.array(r.object({task_id:r.string().min(1),integration_commit:r.string().min(1),changed_files:r.array(r.string().min(1)),outcome_projection:Gr.nullable()}).strict())}).strict().nullable().default(null),decision_observed:r.boolean().default(!1),decision:tt.optional(),status:r.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:r.array(Ys).min(1),last_error:r.string().min(1).nullable()}).strict();var Wt=r.object({editorial_delivery:r.boolean().optional(),production_impact:r.boolean().optional(),external_action:r.boolean().optional(),irreversible_change:r.boolean().optional(),security_or_critical_data:r.boolean().optional(),data_migration:r.boolean().optional(),broad_audit:r.boolean().optional(),rollback:r.enum(["trivial","planned","complex"]).optional(),verification_scope:r.enum(["scoped","package","cross_scope","full"]).optional()}).strict();function tc(t){return{verification_scope:t==="lite"?"scoped":t==="standard"?"package":"full"}}function Zr(t,e){let n=Wt.parse(e??tc(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 $n=r.preprocess(t=>typeof t=="string"?{summary:t,changed_files:[],evidence_ids:[],completed_run_id:null}:t,r.object({summary:r.string().min(1),changed_files:r.array(r.string().min(1)),evidence_ids:r.array(r.string().startsWith("EVD-")),completed_run_id:r.string().startsWith("RUN-").nullable()}).strict());function On(t){return typeof t=="object"&&t!==null&&"code"in t&&t.code==="EEXIST"}function Nn(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.",i=t.result?.evidence_ids.length?t.result.evidence_ids.map(o=>`- ${o}`).join(`
|
|
117
|
+
`):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}
|
|
118
|
+
|
|
119
|
+
## Objetivo
|
|
120
|
+
|
|
121
|
+
${t.objective}
|
|
122
|
+
|
|
123
|
+
## Plano
|
|
124
|
+
|
|
125
|
+
${e}
|
|
126
|
+
|
|
127
|
+
## Evid\xEAncias
|
|
128
|
+
|
|
129
|
+
${i}
|
|
130
|
+
|
|
131
|
+
## Resultado
|
|
132
|
+
|
|
133
|
+
${n}`}function nt(t,e){return JSON.stringify(t)===JSON.stringify(e)}function it(t,e,n){let i=new Set;for(let o of t)i.has(o)&&n.addIssue({code:"custom",path:[e],message:`Duplicate value: ${o}`}),i.add(o)}async function Qr(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 Dn(t,e,n,i,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:i,started_at:e==="executing"&&t.started_at===null?i:t.started_at,finished_at:s?i:null,result:s?n:null}}function Xr(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 nc(t){return t.plan_ref?.execution_id??t.prepared_plan?.execution_id??null}function Yr(t,e){if(t.status!=="blocked"||t.status_reason!==e.reason||nc(t)!==e.executionId||!Xr(e.reason,e.runId))throw new Error(`Task ${t.id} is not recoverable from its own completion gate`)}var eo={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 Ut=r.string().datetime({offset:!0}),ic=r.string().regex(/^[a-f0-9]{64}$/),to=r.string().startsWith("TASK-"),rc=r.string().startsWith("CHG-"),oc=r.string().startsWith("REQ-"),ac=r.string().startsWith("AC-"),K=r.object({schema_version:r.literal(2),id:to,revision:r.number().int().positive(),change_id:rc,title:r.string().min(1),short_name:r.string().min(1),objective:r.string().min(1),target_release:r.string().regex(/^[1-9]\d*\.(?:0|[1-9]\d*)$/).nullable().optional(),status:r.enum(["draft","planned","executing","verifying","completed","failed","blocked","cancelled"]),status_reason:r.string().min(1).nullable().optional(),attempt_count:r.number().int().nonnegative().optional(),risk:r.enum(["lite","standard","critical"]),priority:r.enum(["low","medium","high","urgent"]),owner:r.string().min(1).nullable(),requirement_ids:r.array(oc).min(1),acceptance_ids:r.array(ac).min(1),depends_on:r.array(to),write_scopes:r.array(r.string().min(1)),runtime:dt.optional(),model_profile:pt.optional(),assurance_risk_signals:Wt.optional(),assurance_risk_signals_source:r.enum(["explicit","risk_default"]).optional(),plan_revision:r.number().int().positive().nullable(),plan_hash:ic.nullable(),prepared_plan:U.optional(),plan_ref:yi.optional(),created_at:Ut,updated_at:Ut,started_at:Ut.nullable(),finished_at:Ut.nullable(),result:$n.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"}),it(t.requirement_ids,"requirement_ids",e),it(t.acceptance_ids,"acceptance_ids",e),it(t.depends_on,"depends_on",e),it(t.write_scopes,"write_scopes",e)}),fe=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 le(this.filesystem,this.layout,"task",e);if(n===null)throw new Error(`task not found: ${e}`);let i=$(await this.filesystem.readText(n),K);return{task:i.metadata,body:i.body}}async list(){let e=await this.filesystem.listFiles(this.layout.entityRoot("task"),".md");return Promise.all(e.map(async n=>$(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 i=(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:i,updated_at:i,started_at:null,finished_at:null,result:null,assurance_risk_signals:Zr(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 i=U.parse(n);if(i.source.type!=="task"||i.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===i.hash)return o.task;if(o.task.status!=="draft")throw new Error(`Task ${e} must be draft before prepare`);let a=i.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",nt(a.requirement_ids,o.task.requirement_ids)?null:"requirement_ids",nt(a.acceptance_ids,o.task.acceptance_ids)?null:"acceptance_ids",nt(a.write_scopes,o.task.write_scopes)?null:"write_scopes"].filter(d=>d!==null),c=i.dag.nodes.find(d=>d.task_id===e);if((c===void 0||!nt(c.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 l=K.parse({...o.task,revision:o.task.revision+1,status:"planned",plan_revision:i.revision,plan_hash:i.hash,prepared_plan:i,...a.model_profile===void 0?{}:{model_profile:a.model_profile},updated_at:i.prepared_at});return await this.write(l),l}async write(e,n=Nn(e)){await this.filesystem.writeTextAtomic(this.path(e.id),this.serialize(e,n))}async normalizePreparedPlan(e,n){let i=await this.read(e);if(i.task.plan_ref?.hash===n.hash)return i.task;if(i.task.prepared_plan?.hash!==n.hash)throw new Error(`Task ${e} does not contain PreparedPlan ${n.hash}`);let{prepared_plan:o,...a}=i.task,s=K.parse({...a,revision:i.task.revision+1,plan_ref:Fe(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=Nn(e)){return j({metadata:K.parse(e),body:n})}async transition(e,n,i=null,o=new T,a=null){let s=await this.read(e);if(!eo[s.task.status].includes(n))throw new Error(`Invalid Task transition: ${s.task.status} -> ${n}`);let c=K.parse(Dn(s.task,n,i,o.now().toISOString(),a));return await this.write(c),c}async recoverOwnCompletionGateBlock(e,n,i=new T){let o=await this.read(e);Yr(o.task,n);let a=K.parse(Dn(o.task,"executing",null,i.now().toISOString(),null,!0));return await this.write(a),a}path(e){return this.layout.activePath("task",e)}},qe=class extends Error{name="MaterializationCollisionError"},Ht=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 ae(e,n),this.tasks=new fe(e,n),this.executions=new Y(e,n)}filesystem;layout;static activeMaterializations=new Map;changes;tasks;executions;activeNormalizations=new Map;async execute(e){let n=`${this.filesystem.root}:${e.hash}`,i=t.activeMaterializations.get(n);if(i!==void 0)return i;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=U.parse(e),i=cc(n),o=[...i.changes.map(m=>({kind:"change",id:m.id,path:this.changes.path(m.id),content:this.changes.serialize(m)})),...i.tasks.map(m=>({kind:"task",id:m.id,path:this.tasks.path(m.id),content:this.tasks.serialize(m)})),{kind:"execution",id:i.execution.id,path:this.executions.path(i.execution.id),content:this.executions.serialize(i.execution)}],a=[],s=[],c=[],l=!1;for(let m of o){let h=await le(this.filesystem,this.layout,m.kind,m.id);if(h===null){a.push(m);continue}if(h!==m.path)throw new qe(`${m.kind} ${m.id} collides with inactive layout path ${h}`);let v=await this.filesystem.readText(h);if(v!==m.content){if(m.kind==="execution"){let y=$(v,D).metadata;if(y.kind==="delivery"&&y.plan_hash===null&&y.plan_revision===null&&JSON.stringify(y.origin)===JSON.stringify(i.execution.origin)){l=!0,s.push(m.path);continue}}if(m.kind==="change"){let y=i.changes.find(b=>b.id===m.id),g=y===void 0?null:sc(v,y);if(y!==void 0&&g!==null){g==="draft"&&c.push(y),s.push(m.path);continue}}if(m.kind==="task"&&n.source.type==="task"&&m.id===n.source.task_id&&no(v,n)){s.push(m.path);continue}throw new qe(`${m.kind} ${m.id} already exists with divergent content`)}s.push(m.path)}let d=[],p=[],u=!1;try{u=await this.persistPreparedPlan(n);for(let m of a)try{await this.filesystem.writeTextExclusive(m.path,m.content),d.push(m),p.push(m.path)}catch(h){if(!await lc(this.filesystem,m,h,n))throw h;s.push(m.path)}for(let m of c)await this.changes.promoteDraft(m.id,m);l&&await this.executions.promoteDeliveryIntake(i.execution.id,i.execution)}catch(m){throw await Qr(this.filesystem,d),u&&await this.removePreparedPlan(n),m}let f=(await this.executions.read(n.execution_id)).execution;try{await this.normalizeSource(n)}catch(m){throw u&&await this.removePreparedPlan(n),m}let _=await Promise.all(i.tasks.map(async m=>(await this.tasks.read(m.id)).task));return{execution:f,changes:await Promise.all(i.changes.map(async m=>(await this.changes.read(m.id)).change)),tasks:_,created_paths:p,reused_paths:s}}async readPreparedPlan(e){return U.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),i=`${JSON.stringify(e,null,2)}
|
|
134
|
+
`;try{return await this.filesystem.writeTextAtomicExclusive(n,i),!0}catch(o){if(!On(o))throw o;let a=U.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 i=U.parse(JSON.parse(await this.filesystem.readText(n)));JSON.stringify(i)===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 i=(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,i);try{await i}finally{this.activeNormalizations.delete(e.hash)}}};function no(t,e){try{let n=$(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 sc(t,e){try{let n=$(t,J).metadata,i=n.status==="draft"||n.status==="planned"?n.status:null;return i!==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))?i:null}catch{return null}}function cc(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])),i=t.blueprints.tasks.map(s=>{let c=e.get(s.id);if(c===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:c.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=>J.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:i.filter(c=>c.change_id===s.id).map(c=>c.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=D.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:i,execution:a}}async function lc(t,e,n,i){if(!On(n)||!await t.exists(e.path))return!1;let o=await t.readText(e.path);if(o===e.content||e.kind==="task"&&i.source.type==="task"&&e.id===i.source.task_id&&no(o,i))return!0;throw new qe(`${e.kind} ${e.id} was created concurrently with divergent content`)}var zn=r.string().datetime({offset:!0}),hw=r.object({id:r.string().startsWith("TASK-"),title:r.string().min(1),short_name:r.string().min(1),status:r.enum(["draft","planned","executing","verifying","completed","failed","blocked","cancelled"]),risk:r.enum(["lite","standard","critical"]),priority:r.enum(["low","medium","high","urgent"]),owner:r.string().min(1).nullable().default(null),progress:r.number().int().min(0).max(100),spec:r.string().startsWith("SPEC-"),change:r.string().startsWith("CHG-"),requirements:r.array(r.string().startsWith("REQ-")),depends_on:r.array(r.string().startsWith("TASK-")),human_decisions:r.array(r.string().startsWith("DEC-HUMAN-")),agent_decisions:r.array(r.string().startsWith("DEC-AI-")),created_at:zn,started_at:zn.nullable(),finished_at:zn.nullable()}).strict();function rt(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 ae(t,e),tasks:new fe(t,e),executions:new Y(t,e),materializer:new Ht(t,e),decisions:new di(t,e),runs:new Q(t,n==="local_only"?{storageMode:"local_only",localBasePath:".agents/private/state/runs"}:{storageMode:"tracked_sanitized",layout:e})}}var dc="native-question-continuation";function io(t){if(t.length<2)return null;let e=new Set(t.map(a=>a.run.run_id)),n=t.filter(a=>!e.has(a.run.continuation_of_run_id??""));if(n.length!==1)return null;let i=n[0],o=new Set([i.run.run_id]);for(;o.size<t.length;){let a=t.filter(l=>l.run.continuation_of_run_id===i.run.run_id);if(a.length!==1||!i.finished||i.finalization_decision?.outcome!=="blocked")return null;let s=a[0],c=s.run.same_turn_handoff;if(!c||!("kind"in c)||c.kind!=="native_question_continuation"||c.predecessor_run_id!==i.run.run_id||c.target_task_id!==s.run.task_id||!s.run.intake?.reason_codes.includes(`approval-${c.authorization_sha256.slice(0,48)}`)||o.has(s.run.run_id)||!s.run.intake?.reason_codes.includes(dc)||s.run.task_id!==i.run.task_id||s.run.execution_id!==i.run.execution_id||s.run.parent_run_id!==null||s.run.intake.intent!=="continue")return null;i=s,o.add(i.run.run_id)}return i}import{AsyncLocalStorage as gc}from"node:async_hooks";import{execFile as hc}from"node:child_process";import{realpath as yc}from"node:fs/promises";import{isAbsolute as vc,resolve as Fn}from"node:path";import{promisify as wc}from"node:util";var k=class extends Error{};import{execFile as uc}from"node:child_process";import{basename as pc,dirname as mc,resolve as Mn}from"node:path";import{promisify as _c}from"node:util";var fc=_c(uc);async function Jt(t){let e=async(a,s)=>(await fc("git",s,{cwd:a,windowsHide:!0,timeout:1e4,encoding:"utf8"})).stdout.trim(),n;try{n=Mn(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 Mn(t);throw a}if(pc(n).toLowerCase()!==".git")throw new k("Release cycle requires a verifiable primary Git checkout");let i=mc(n);if(Mn(await e(i,["rev-parse","--show-toplevel"])).toLowerCase()!==i.toLowerCase())throw new k("Release control root could not be verified");return i}var ro=new gc,bc=wc(hc),F=t=>process.platform==="win32"?Fn(t).toLowerCase():Fn(t),L=(t,e)=>F(t)===F(e);function oo(t){let e=ro.getStore();return e&&F(e.canonical)===F(t)?e.invocation:t}function Bt(){return ro.getStore()}async function G(t,e){if(!vc(t)||process.platform==="win32"&&/^[/\\]{2}/.test(t))throw new k("Lifecycle root must be an absolute local Git path");t=Fn(t);let n=await yc(t);if(F(n)!==F(t))throw new k("Lifecycle workspace must use its physical Git path");if(F(await Jt(t))!==F(e))throw new k("Native invocation and lifecycle workspace belong to different Git repositories");if(F(t)===F(e))return n;if(!(await bc("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=>F(o.slice(9))).includes(F(t)))throw new k("Lifecycle invocation requires a registered Git worktree");return n}import{execFileSync as kc}from"node:child_process";import{createHash as Sc,randomUUID as Ec}from"node:crypto";import{lstatSync as at,mkdirSync as Cc,readFileSync as mo,realpathSync as _o,unlinkSync as Rc}from"node:fs";import{link as Tc,open as Ac,unlink as Ic}from"node:fs/promises";import{dirname as so,join as fo,resolve as co}from"node:path";function Ln(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]??"",i=n.includes("@")?n.slice(0,n.lastIndexOf("@")):null;if(/[?#]/.test(t)||e.password||i!==null&&!(e.protocol==="ssh:"&&i==="git"))throw Error("Unsafe Git destination metadata")}return t}var se=r.string().regex(/^[a-f0-9]{64}$/),ao=r.string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/),xc=r.string().regex(/^RUN-[A-Z0-9-]+$/),jn=r.object({schema_version:r.literal(1),binding_id:r.string().regex(/^PBIND-[a-f0-9]{64}$/),created_at:r.string().datetime({offset:!0}),staging_id:r.string().uuid(),source_run_id:xc,source_thread_id:r.string().min(1).max(256),source_turn_id:r.string().min(1).max(256),task_id:r.string().regex(/^TASK-[A-Z0-9-]+$/).nullable(),change_id:r.string().regex(/^CHG-[A-Z0-9-]+$/).nullable(),execution_id:r.string().regex(/^EXEC-[A-Z0-9-]+$/),request_sha256:se,repository_sha256:se,records_workspace_sha256:se,native_workspace_sha256:se,candidate_sha:ao,candidate_tree_sha:ao,destination:r.object({remote:r.literal("origin"),url:r.string().min(1).max(4096),ref:r.string().regex(/^refs\/heads\/[A-Za-z0-9][A-Za-z0-9._/-]*$/).refine(t=>!t.includes("..")),scope:r.enum(["frontend","backend","framework"])}).strict(),mode:r.enum(["commits","release"]),condition:r.enum(["tests_passed"]).nullable(),contract_sha256:se,project_policy_sha256:se.nullable(),rule_sources:r.array(r.object({path:r.string().regex(/^\.agents\/rules\/(?:[A-Za-z0-9_-]+\/)*[A-Za-z0-9_-]+\.md$/),sha256:se}).strict()).max(32),content_sha256:se}).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 ot(t){let e=t.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/\s+/g," ").trim(),n="se (?:os )?testes (?:passarem|forem aprovados)",i=new RegExp(`^${n},?\\s+(.+)$`).exec(e),o=new RegExp(`^(.+?),?\\s+${n}[.!]?$`).exec(e),a=i?.[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),c=/^(?:revise|verifique|confira) se (?:o )?deploy foi feito no github e no npm, caso contrario (?:resolva as pendencias, )?(?:faca os ajustes necessarios e )?(?:faca (?:o )?deploy|garanta o deploy feito)[.!]?$/.test(e)||/^(?: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),l=/^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),p=i||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)&&!c&&!s&&!d&&!l?"unsupported":null,u=a.replace(/\b(?:nao\s+(?:publique|publicar)|sem\s+publicar)\s+(?:(?:um|uma|o|a|novo|nova)\s+)*release\b/g,""),f=/\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),_=/^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),m=t.includes("?")||/[`"'“”<>]/.test(t)||/\b(?:disse|citou|exemplo|quoted|said|talvez|maybe|hipoteticamente|hypothetically)\b/.test(e);return{action:a,condition:p,publicationDenied:f,directPublication:_,untrusted:m,...s?{incompleteReleaseVersion:s[1]}:{}}}var Un=t=>Sc("sha256").update(JSON.stringify(t)).digest("hex"),Ve=t=>process.platform==="win32"?co(t).toLowerCase():co(t);function q(t){throw Error(`publication_binding_${t}`)}var Hn=(t,e,n)=>`PBIND-${Un([t,e,n])}`;function Jn(t,e){return/^RUN-[A-Z0-9-]+$/.test(e)||q("invalid_source_run"),fo(t,".agents/private/state/codex-hook-publication/v1",`${e}.json`)}function st(t,e,n=!1,i=!1){for(let o=e;;o=so(o)){let a;try{a=at(o)}catch(s){if(n&&s.code==="ENOENT")return null;throw s}if((a.isSymbolicLink()||Ve(_o(o))!==Ve(o)||(o===e?!a.isFile()||a.nlink!==1&&!(i&&a.nlink===2)||a.size>65536:!a.isDirectory()))&&q("unsafe_physical_path"),Ve(o)===Ve(t))return at(e);so(o)===o&&q("root_escape")}}function Kt(t,e){let n=Jn(t,e),i=st(t,n,!0,!0);if(!i)return null;let o=mo(n,"utf8"),a=st(t,n,!1,!0);(!a||i.ino!==a.ino||i.dev!==a.dev||i.mtimeMs!==a.mtimeMs||i.size!==a.size)&&q("changed_during_read");let s;try{s=jn.parse(JSON.parse(o)),Ln(s.destination.url)}catch{return q("invalid_record")}let{content_sha256:c,...l}=s;return(s.source_run_id!==e||c!==Un(l)||s.binding_id!==Hn(e,s.request_sha256,s.repository_sha256)||o!==`${JSON.stringify(s,null,2)}
|
|
135
|
+
`)&&q("invalid_record"),a.nlink===2&&go(t,n,s,o),s}function go(t,e,n,i){let o=`${e}.${n.staging_id}.tmp`,a=st(t,e,!1,!0);if(a?.nlink===1)return null;let s;try{s=st(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||mo(o,"utf8")!==i)&&q("unexpected_alias"),o}function ho(t,e,n){let i=Kt(n.primaryRoot,t.source_run_id);i||q("missing_original_capture"),(i.binding_id!==t.binding_id||i.request_sha256!==t.source_sha256||i.source_thread_id!==t.client_thread_id||i.source_turn_id!==t.client_turn_id||i.task_id!==n.taskId||i.change_id!==n.changeId||i.execution_id!==n.executionId||i.records_workspace_sha256!==t.records_workspace_sha256||i.native_workspace_sha256!==t.native_workspace_sha256||i.repository_sha256!==t.repository_sha256||i.contract_sha256!==e.contract_sha256||i.candidate_sha!==e.candidate?.sha||i.destination.url!==e.destination?.url||i.destination.ref!==`refs/heads/${e.destination?.branch}`||i.destination.scope!==e.destination?.scope||i.mode!==e.mode||i.condition!==ot(n.request).condition||i.project_policy_sha256!==(e.project_restrictions?.policy_sha256??null)||JSON.stringify(i.rule_sources)!==JSON.stringify(e.project_restrictions?.rule_sources??[]))&&q("candidate_destination_or_contract_changed");let o=Date.parse(i.created_at);return(o<Date.parse(n.sourceStartedAt)||o>Date.now()||n.sourceFinishedAt!==null&&o>Date.parse(n.sourceFinishedAt))&&q("original_capture_time_mismatch"),i}function lb(t,e){let n=uo(t);return(e.mode!=="release"||e.phase!=="publish"||e.destination?.remote!=="origin"||e.destination.branch!=="main"||e.destination.scope!=="framework"||t.git_only)&&q("closure_original_release_required"),ho(t,e,n)}function lo(t,e){let n=Wn(t),i=ho(t,e,n),o=Jn(n.primaryRoot,t.source_run_id);if(at(o).nlink===2){let a=`${JSON.stringify(i,null,2)}
|
|
136
|
+
`,s=go(n.primaryRoot,o,i,a);if(s)try{Rc(s)}catch(c){c.code!=="ENOENT"&&q("own_staging_cleanup_failed")}st(n.primaryRoot,o)}return i}async function db(t,e){let n=Wn(t);if(!["commits","release"].includes(String(e.mode))||e.phase!=="publish")return;let i=await po(n.repository,n.request,n.currentRunId);if((i.binding_id!==t.binding_id||i.steering_sha256!==e.authorization?.steering_sha256)&&q("human_source_changed_before_capture"),Kt(n.primaryRoot,t.source_run_id))return lo(i,e);n.originalTurn||q("missing_original_capture_no_retroactive_binding");let o=(...f)=>kc("git",f,{cwd:n.repository,encoding:"utf8",windowsHide:!0}).trim();e.destination&&Ln(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=jn.parse({schema_version:1,binding_id:t.binding_id,created_at:new Date().toISOString(),staging_id:Ec(),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:ot(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,...c}=a;a.content_sha256=Un(c);let l=Jn(n.primaryRoot,t.source_run_id),d=`${l}.${a.staging_id}.tmp`,p=n.primaryRoot;for(let f of[".agents","private","state","codex-hook-publication","v1"]){p=fo(p,f);try{Cc(p)}catch(_){if(_.code!=="EEXIST")throw _}(!at(p).isDirectory()||at(p).isSymbolicLink()||Ve(_o(p))!==Ve(p))&&q("unsafe_directory")}let u=!1;try{let f=await Ac(d,"wx",384);u=!0;try{await f.writeFile(`${JSON.stringify(a,null,2)}
|
|
137
|
+
`,"utf8"),await f.sync()}finally{await f.close()}try{await Tc(d,l)}catch(_){if(_.code!=="EEXIST")throw _}}finally{u&&await Ic(d).catch(f=>{if(f.code!=="ENOENT")throw f})}return lo(i,e)}var P=t=>t.replace(/\r\n?/g,`
|
|
138
|
+
`).trim().normalize("NFC"),Pc=t=>P(t).normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase();function ct(t){throw Error(`publication_native_capability_missing:${t}`)}function yo(t,e,n,i){let o=[];for(let l of i){let d=l.provenance,p=P(l.text),u=!!d&&d.source_record_type==="response_item"&&d.source_payload_type==="message"&&d.role==="user"&&d.metadata_turn_id===l.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((h,v)=>h==="input_text"&&d.content_item_kinds?.[v]==="user.text"&&d.content_item_provenance?.[v]==="user"),f=o.at(-1),m=u&&(l.nativeQuestionReply?.answer==="N\xE3o possuo certificado de assinatura de c\xF3digo"&&l.nativeQuestionReply.question.includes("Voc\xEA j\xE1 possui um certificado ou servi\xE7o de assinatura de c\xF3digo")||l.nativeQuestionReply?.answer==="Autorizar publica\xE7\xE3o sem Authenticode"&&l.nativeQuestionReply.question.includes("publicar os execut\xE1veis sem Authenticode")&&l.nativeQuestionReply.question.includes("mantendo as verifica\xE7\xF5es de integridade e a assinatura do comprovante"))||u&&p.startsWith("<send_user_message_question_reply>")&&l.nativeLoginReply===!0&&d.content_types?.length===1;f?.turn===l.turnId&&f.text===p?(f.human||=u,f.loginReply||=m):o.push({turn:l.turnId,text:p,human:u,loginReply:m})}let a=o.findIndex(l=>l.turn===e&&l.human&&!/^[<[{]/.test(l.text)&&l.text===P(t));(a<0||o.slice(0,a).some(l=>l.human))&&ct("original_human_source_mismatch"),o.slice(a).some(l=>!l.human)&&ct("human_provenance_unavailable");let s={git_transport:"default",github_api:"default",release:"default",sql:"default"},c=[];for(let l of o.slice(a+1)){if(l.loginReply)continue;let d=l.text,p=Pc(d);if(ot(d).publicationDenied&&ct("human_revocation"),!/^(?:qual (?:e )?o status|status|alguma novidade|andamento|any update|what is the status)\??[.!]?$/.test(p)){if(/^(?:continue|retome|resume|prossiga|siga)(?:\s+TASK-[A-Z0-9-]+)?[.!]?$/i.test(d)){(d.match(/TASK-[A-Z0-9-]+/g)??[]).some(f=>f!==n)&&ct("foreign_continuation");continue}/^(?:somente|apenas|exclusivamente) (?:via |por )?ssh[.!]?$/.test(p)?s.git_transport="ssh-only":/^(?:sem|nao use a?) api (?:do )?github[.!]?$/.test(p)?s.github_api="forbidden":/^sem release[.!]?$/.test(p)?s.release="forbidden":/^(?:sem executar|nao execute) sql[.!]?$/.test(p)?s.sql="forbidden":ct("human_steering_changed"),c.push(d)}}return{constraints:s,steering:c}}import{createHash as Zc}from"node:crypto";import{createHash as Mc}from"node:crypto";import{lstat as Nc}from"node:fs/promises";import{lstat as qc,mkdir as fb,readFile as gb,realpath as Vc,writeFile as hb}from"node:fs/promises";import{dirname as vb,isAbsolute as $c,relative as Oc,resolve as Bn}from"node:path";async function $e(t,e,n=!1){let i=Bn(t,e),o=Oc(t,i);if(!o||o.startsWith("..")||$c(o))throw new k("Preservation path escaped its root");let a=o.split(/[\\/]/),s=Bn(t);for(let c=-1;c<a.length;c++){c>=0&&(s=Bn(s,a[c]));let l;try{l=await qc(s)}catch(u){if(n&&u.code==="ENOENT")return i;throw u}let d=await Vc(s),p=u=>process.platform==="win32"?u.toLowerCase():u;if(l.isSymbolicLink()||p(d)!==p(s)||(c<a.length-1?!l.isDirectory():!l.isFile()||l.nlink!==1))throw new k("Preservation refuses links, aliases or nonregular files")}return i}var Kn=".agents/private/state/task-workspaces/record-origin-admission.json";async function Dc(t){if(!await t.exists(Kn))return null;let e=await $e(t.root,Kn);if((await Nc(e)).size>16384)throw new k("Legacy origin admission exceeds bounded metadata size");let n=await t.readText(Kn),i=JSON.parse(n),o=i?.origin;if(i?.schema_version!==1||i?.kind!=="legacy_origin_admission"||o?.schema_version!==1||o?.kind!=="legacy_record_origin"||typeof o.canonical_workspace!="string"||!L(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 k("Unknown legacy origin admission must be preserved before reconciliation");return await G(o.records_workspace,t.root),{source:n,origin:o}}async function vo(t,e){let n=await Dc(t);if(n&&e.some(i=>[n.origin.task_id,n.origin.change_id,n.origin.execution_id,n.origin.run_id].includes(i)))throw new k("legacy_worktree_lifecycle_requires_recovery: origin admission is incomplete; retry its exact authenticated task workspace command before reading canonical copies")}function zc(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 k("Invalid legacy origin identity");return`.agents/private/state/task-workspaces/record-origins/${t}/${e}.json`}async function wo(t,e,n){let i=zc(e,n);if(!await t.exists(i))return null;await $e(t.root,i);let o=await t.readText(i);if(Buffer.byteLength(o)>16384)throw new k("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"||!L(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 k("Legacy record origin is incompatible; preserve it before reconciliation");return await G(a.records_workspace,t.root),a}function Gn(t,e){return new Q(t,e.projectConfig?.tracking.storage_mode==="local_only"?{storageMode:"local_only",localBasePath:".agents/private/state/runs"}:{storageMode:"tracked_sanitized",layout:e})}async function Gt(t,e,n){let i=await Jt(t);await G(t,i);let o=new V(i),a=await De(o);await vo(o,[n]);let s=await wo(o,e,n);if(!s)return{filesystem:o,layout:a,primaryRoot:i,legacy:!1};let c=new V(await G(s.records_workspace,i)),l=await De(c);if(l.version===1||a.version===1||l.version!==a.version||l.projectConfig?.zaip?.enabled!==!0||a.projectConfig?.zaip?.enabled!==!0||l.projectConfig.project.id!==a.projectConfig.project.id||!L(s.canonical_workspace,i))throw new k("Legacy record source requires matching enabled project identities and layouts");let d=new fe(c,l),p=new ae(c,l),u=new Y(c,l),f=[d.path(s.task_id),p.path(s.change_id),u.path(s.execution_id)];if(s.records_baseline.some(v=>!f.includes(v.path)))throw new k("Legacy record baseline contains a path outside its exact graph");for(let v of s.records_baseline){let y=await o.exists(v.path)?await o.readText(v.path):null;if((y===null?null:Mc("sha256").update(y).digest("hex"))!==v.sha256)throw new k("Legacy record source conflicts with its preserved canonical baseline")}let{task:_}=await d.read(s.task_id),{change:m}=await p.read(s.change_id),{execution:h}=await u.read(s.execution_id);if(_.id!==s.task_id||m.id!==s.change_id||h.id!==s.execution_id||_.change_id!==m.id||(_.plan_ref?.execution_id??_.prepared_plan?.execution_id)!==h.id||m.source.type!=="task"||m.source.task_id!==_.id||m.task_ids.length!==1||m.task_ids[0]!==_.id||h.kind!=="delivery"||h.origin.type!=="task"||h.origin.task_id!==_.id||h.dag.nodes.length!==1||h.dag.nodes[0]?.task_id!==_.id||h.dag.nodes[0]?.change_id!==m.id)throw new k("Legacy record source has an inconsistent Task/Change/Execution graph");if(e==="runs"){let v=Gn(c,l),y=await v.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(Gn(o,a).path(n)))throw new k("Legacy source Run conflicts with its exact graph binding or canonical copy")}return{filesystem:c,layout:l,primaryRoot:i,legacy:!0}}import{createHash as Uc}from"node:crypto";import{createHash as Fc}from"node:crypto";import{homedir as Lc}from"node:os";import{join as jc,relative as Wc}from"node:path";async function bo(t,e,n=jc(Lc(),".codex")){if(!e.transcriptPath||!e.clientThreadId||!e.clientTurnId)throw new k("Principal continuation requires its observed transcript");let i=Wc(n,e.transcriptPath).replaceAll("\\","/");if(!/^sessions\/\d{4}\/\d{2}\/\d{2}\/[A-Za-z0-9._-]+\.jsonl$/.test(i)||!i.includes(e.clientThreadId))throw new k("Principal continuation transcript identity differs");let o=await We(new V(n),i,e.clientTurnId);if(!o||o.model!==e.observedModel||o.reasoningEffort!==e.observedReasoningEffort)throw new k("Principal continuation native context is unavailable or changed");return Fc("sha256").update(JSON.stringify({session:e.clientThreadId,turn:e.clientTurnId,...o})).digest("hex")}var xo=t=>Uc("sha256").update(t).digest("hex"),Hc=(t,e,n)=>`.agents/private/state/codex-principal-continuations/v2/${xo(JSON.stringify([t,e,n]))}.json`;function Jc(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 Bc(t,e){if(!Jc(t))throw new k("Root Task continuation requires its active orchestrator owner");let n=t.run,{task:i}=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(i.status)||i.id!==n.task_id||i.change_id!==n.change_id||i.plan_ref?.execution_id!==a.id||i.plan_ref.hash!==a.plan_hash||!["executing","verifying"].includes(o.status)||o.id!==n.change_id||o.source.type!=="task"||o.source.task_id!==i.id||o.task_ids.length!==1||o.task_ids[0]!==i.id||a.id!==n.execution_id||a.kind!=="delivery"||!["running","verifying"].includes(a.status)||a.origin.type!=="task"||a.origin.task_id!==i.id||a.dag.nodes.length!==1||a.dag.nodes[0]?.task_id!==i.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===i.id||u.run.execution_id===a.id)))throw new k("Root Task continuation requires sole exact Task/Change/Execution ownership");let c=await Gt(e.filesystem.root,"runs",n.run_id);if(!L(c.filesystem.root,e.filesystem.root))throw new k("Root Task continuation must read its verified original record source");let l=new V(c.primaryRoot);await $e(l.root,".agents/private/state/task-workspaces/shared-writer.json");let d=await l.readText(".agents/private/state/task-workspaces/shared-writer.json"),p=JSON.parse(d);if(p.mode!=="shared"||p.status!=="ready"||p.branch!==null||p.run_id!==n.run_id||p.task_id!==i.id||p.execution_id!==a.id||typeof p.path!="string"||!L(p.path,c.primaryRoot)||typeof p.canonical_workspace!="string"||!L(p.canonical_workspace,c.primaryRoot)||(c.legacy?typeof p.records_workspace!="string"||!L(p.records_workspace,e.filesystem.root):p.records_workspace!==void 0)||!/^[a-f0-9]{40}$/.test(p.base_commit??""))throw new k("Root Task continuation writer claim differs");return{claim_sha256:xo(d),task:i,execution:a}}function Kc(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 Gc(t,e,n,i){if(!Kc(t,e))throw new k("Root Task continuation requires the same session/model/effort and a new observed turn");let o=await Bc(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 bo(n.filesystem,e,i)}}async function ko(t,e,n,i){try{let o=await Gc(t,e,n,i),a=await n.filesystem.readText(Hc(t.run.run_id,e.clientThreadId,e.clientTurnId));return Buffer.byteLength(a)<=8192&&a===`${JSON.stringify(o)}
|
|
139
|
+
`}catch{return!1}}function M(t){throw Error(`publication_native_capability_missing:${t}`)}async function Zn(t,e){let n=await Gt(t,"runs",e),i=new Q(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 i.read(e)}}function So(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)&&M("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,i=e.entrypoint==="task"&&e.execution_kind==="delivery"&&e.task_id!==null&&e.change_id!==null;return!n&&!i&&M("unsupported_source_run_kind"),{gitOnly:n,task:i}}async function Qc(t,e){let{run:n}=e.fold;(!n.task_id||!n.change_id||!n.execution_id||n.agent!=="agent-orchestrator")&&M("closure_requires_exact_task_root");let i=rt(e.source.filesystem,e.source.layout),[{task:o},{change:a},{execution:s}]=await Promise.all([i.tasks.read(n.task_id),i.changes.read(n.change_id),i.executions.read(n.execution_id)]),c=!!(e.fold.finished||e.fold.finalization_decision);if((o.id!==n.task_id||o.change_id!==n.change_id||o.plan_ref?.execution_id!==s.id||o.plan_ref.hash!==s.plan_hash||a.id!==n.change_id||a.source.type!=="task"||a.source.task_id!==o.id||a.task_ids.length!==1||a.task_ids[0]!==o.id||a.plan_hash!==s.plan_hash||s.id!==n.execution_id||s.kind!=="delivery"||s.origin.type!=="task"||s.origin.task_id!==o.id||s.dag.nodes.length!==1||s.dag.nodes[0]?.task_id!==o.id||s.dag.nodes[0]?.change_id!==a.id||!(c?o.status==="completed":["executing","verifying"].includes(o.status))||!(c?a.status==="completed":["executing","verifying"].includes(a.status))||!(c?s.status==="completed":["running","verifying"].includes(s.status)))&&M("closure_lifecycle_mismatch"),!c)return;let l=e.fold.finalization_decision;(e.fold.finished?.status!=="completed"||l?.outcome!=="completed"||o.result?.completed_run_id!==n.run_id||!l.evidence_ids.length||l.evidence_ids.some(p=>!o.result?.evidence_ids.includes(p)))&&M("closure_completed_finalization_required");let d=(await Zn(t,l.finalizer_run_id)).fold;(d.finished?.status!=="completed"||d.run.agent!=="agent-finalizer"||d.run.attribution_status!=="attributed"||ui(d.run)!=="finalization"||d.run.parent_run_id!==n.run_id||d.run.task_id!==n.task_id||d.run.change_id!==n.change_id||d.run.execution_id!==n.execution_id||d.run.execution_kind!=="delivery")&&M("closure_completed_finalizer_mismatch")}async function Eo(t,e,n,i,o,a){let s=await Zn(t,e),c=s.fold.run,l=So(s.fold);(a==="publication"&&(s.fold.finished||s.fold.finalization_decision)||c.client_thread_id!==n.clientThreadId||c.model!==n.observedModel||c.reasoning_effort!==n.observedReasoningEffort)&&M("source_run_mismatch_or_terminal"),a==="closure"&&(l.task||M("closure_requires_exact_task_root"),await Qc(t,s)),c.client_turn_id!==n.clientTurnId&&(!l.task||!await ko(s.fold,n,rt(s.source.filesystem,s.source.layout),o))&&M("authenticated_same_run_turn_continuation_required");let d=Zc("sha256").update(P(i)).digest("hex"),p=s,u=new Set,f=[];for(let _=0;_<16;_++){let m=p.fold.run;u.has(m.run_id)&&M("continuation_cycle"),u.add(m.run_id),f.push(p),So(p.fold);let h=Kt(p.source.primaryRoot,m.run_id);if(h&&h.request_sha256===d)return a==="closure"&&(h.mode!=="release"||h.destination.remote!=="origin"||h.destination.ref!=="refs/heads/main"||h.destination.scope!=="framework")&&M("closure_original_release_binding_required"),{current:s,origin:p,kind:l,binding:h,segments:f};if(a==="publication"&&(m.client_turn_id===n.clientTurnId&&(!l.task||P(m.direct_execution_authorization??"")===P(i))&&P(n.userMessage??"")===P(i)||!m.continuation_of_run_id&&l.task&&P(m.direct_execution_authorization??"")===P(i)))return{current:s,origin:p,kind:l,binding:null,segments:f};m.continuation_of_run_id||M("original_binding_or_canonical_successor_missing");let v=await Zn(t,m.continuation_of_run_id),y=v.fold.run;(!v.fold.finished||y.client_thread_id!==c.client_thread_id||y.task_id!==c.task_id||y.change_id!==c.change_id||y.execution_id!==c.execution_id||y.conversation_id!==c.conversation_id)&&M("continuation_graph_mismatch"),p=v}return M("continuation_chain_limit")}function Co(t,e,n,i,o){return Eo(t,e,n,i,o,"publication")}function Ro(t,e,n,i,o){return Eo(t,e,n,i,o,"closure")}import{AsyncLocalStorage as Xc}from"node:async_hooks";import{createHash as Yc,randomUUID as el}from"node:crypto";import{lstat as Qn,readFile as tl,realpath as To,rename as nl,unlink as il}from"node:fs/promises";import{homedir as rl}from"node:os";import{dirname as Ao,resolve as lt}from"node:path";var ol=new Xc;async function Io(t,e,n={}){let i=ol.getStore();if(i&&i.root===t.root&&i.client===e&&i.argv===JSON.stringify(n.argv??process.argv.slice(2))&&(n.threadId===void 0||Zt(n.threadId)===i.value.clientThreadId)&&(n.turnId===void 0||Zt(n.turnId)===i.value.clientTurnId))return i.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=oo(t.root),s=o.filter(b=>b.startsWith("--codex-hook-")),c=s.length>0,l=s.filter(b=>b.startsWith("--codex-hook-thread=")),d=l[0]?.slice(20),p=Zt(n.threadId??process.env.CODEX_THREAD_ID);if(c&&(s.length!==2||l.length!==1||!d||!/^[A-Za-z0-9_-]{1,256}$/.test(d)||p!==null&&p!==d))throw new Error("Codex hook identity is incomplete or conflicts with the active thread.");let u=p??d??null,f=Zt(n.turnId??process.env.CODEX_TURN_ID),_=c&&u!==null?await al(a,u,o,n.now??new Date):null,m=_?.turnId??null;if(c&&(m===null||f!==null&&f!==m))throw new Error("Codex hook turn receipt is missing, consumed, expired or conflicts with the active turn.");let h=c?m:f,v=sl(),y=await ne(a,{threadId:u,includeWorkspaceRoot:!0,...v===null?{}:{transcriptPath:v},...n.sessionsRoot===void 0?{}:{sessionsRoot:n.sessionsRoot},...n.now===void 0?{}:{now:n.now}}),g=h===null||y?.turnId===h?y:null;return{...Bt()&&g?.workspaceRoot?{nativeWorkspace:g.workspaceRoot}:{},..._?.nativePrincipal===void 0?{}:{nativePrincipal:_.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:v??(g?lt(n.sessionsRoot??lt(rl(),".codex"),g.sessionPath):null)}}async function al(t,e,n,i){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-")),c=Yc("sha256").update(JSON.stringify(s)).digest("hex"),l=lt(t,".agents/private/state/codex-hook-turn/v1",`${a}.json`);if(s[0]==="task"&&s[1]==="storage-handoff"){let u=lt(t,".local/codex-hook-turn/v1",`${a}.json`),f=async _=>Qn(_).then(()=>!0,m=>{if(m.code==="ENOENT")return!1;throw m});if(await f(u)){if(await f(l))return null;l=u}}let d=`${l}.${el()}.consumed`,p=!1;try{for(let h=l;;h=Ao(h)){let v=await Qn(h),y=await To(h),g=process.platform==="win32"?y.toLowerCase()===h.toLowerCase():y===h;if(v.isSymbolicLink()||!g||(h===l?!v.isFile()||v.nlink!==1:!v.isDirectory()))return null;if(h===lt(t))break;if(Ao(h)===h)return null}await nl(l,d),p=!0;let u=await Qn(d);if(!u.isFile()||u.isSymbolicLink()||u.nlink!==1||u.size>2048)return null;let f=await To(d);if(process.platform==="win32"?f.toLowerCase()!==d.toLowerCase():f!==d)return null;let _=JSON.parse(await tl(d,"utf8")),m=i.getTime()-Number(_.observed_at_ms);return _.schema_version!==1||_.thread_id!==e||typeof _.turn_id!="string"||!_.turn_id||_.turn_id.length>256||_.tool_use_sha256!==a||_.argv_sha256!==c||_.native_principal!==void 0&&typeof _.native_principal!="boolean"||!Number.isFinite(m)||m<-5e3||m>6e4?null:{turnId:_.turn_id,..._.native_principal===void 0?{}:{nativePrincipal:_.native_principal}}}catch{return null}finally{p&&await il(d).catch(()=>{})}}function sl(){let t=process.env.CODEX_TRANSCRIPT_PATH?.trim();return t===void 0||t.length===0||t.length>4096?null:t}function Zt(t){let e=t?.trim();return e===void 0||e.length===0?null:e}var qo=new WeakMap,Vo=new WeakMap,Xn=new WeakSet;function uo(t){let e=Vo.get(t);return(!e||!Xn.has(t))&&O("verified_native_closure_source_required"),e}function Wn(t){let e=qo.get(t);return(!e||!Yn.has(t))&&O("verified_native_source_required"),e}var Po=new Map,Oe=new cl;function Lx(t,e){return Oe.run({sessionsRoot:t.sessionsRoot},e)}var Yn=new WeakSet,Z=t=>ll("sha256").update(t).digest("hex");function O(t){throw new Error(`publication_native_capability_missing:${t}`)}async function ul(t,e){let n=[...t.segments].reverse(),i=t.origin,o=i.fold.run;for(let a of n.slice(1)){let s=i.fold.run,c=a.fold.run;if(c.client_turn_id!==o.client_turn_id)break;let l=c.same_turn_handoff;(!s.agent_invocation_id||c.agent_invocation_id!==s.agent_invocation_id||s.root_agent_invocation_id!==s.agent_invocation_id||c.root_agent_invocation_id!==s.root_agent_invocation_id||s.parent_agent_invocation_id!==null||c.parent_agent_invocation_id!==null||c.client_thread_id!==s.client_thread_id||c.model!==s.model||c.reasoning_effort!==s.reasoning_effort||c.task_id!==s.task_id||c.change_id!==s.change_id||c.execution_id!==s.execution_id||c.conversation_id!==s.conversation_id||c.continuation_of_run_id!==s.run_id||!i.fold.finished||i.fold.finalization_decision?.outcome!=="blocked"||!l||!("kind"in l)||l.kind!=="native_question_continuation"||l.predecessor_run_id!==s.run_id||l.target_task_id!==c.task_id||l.target_spec_id!==null||c.intake?.intent!=="continue"||!c.intake.reason_codes.includes("native-question-continuation")||!c.intake.reason_codes.includes(`approval-${l.authorization_sha256.slice(0,48)}`))&&O("same_invocation_capture_handoff_mismatch");let d=e.filter(h=>h.nativeQuestionReply&&Z(h.text)===l.authorization_sha256),p=d[0],u=p?.provenance,f=Date.parse(p?.nativeQuestionReply?.observedAt??""),_=Date.parse(i.fold.finished.occurred_at),m=Date.parse(c.occurred_at);(d.length!==1||!Number.isFinite(f)||!Number.isFinite(_)||!Number.isFinite(m)||f<=_||f>m||m>Date.now()||!c.direct_execution_authorization||p?.nativeQuestionReply?.answer.trim()!==c.direct_execution_authorization.trim()||p.turnId!==o.client_turn_id||u?.source_record_type!=="response_item"||u.source_payload_type!=="message"||u.role!=="user"||u.metadata_turn_id!==o.client_turn_id||u.content_types?.length!==1||u.content_types[0]!=="input_text"||u.content_item_kinds?.length!==1||u.content_item_kinds[0]!=="user.text"||u.content_item_provenance?.length!==1||u.content_item_provenance[0]!=="user")&&O("same_invocation_capture_native_receipt_required"),i=a}if(i!==t.origin){let s=(await rt(i.source.filesystem,i.source.layout).runs.list({client:o.client,threadId:o.client_thread_id??null})).filter(({run:c})=>c.parent_run_id===null&&c.client_turn_id===o.client_turn_id&&c.task_id===o.task_id&&c.execution_id===o.execution_id);io(s)?.run.run_id!==i.fold.run.run_id&&O("same_invocation_capture_ambiguous_owner")}return i}async function $o(t,e,n,i){let o=await dl(t),a=new V(o);/^RUN-[A-Z0-9-]+$/.test(n??"")||O("exact_source_run_required");let s=JSON.stringify([o,n,process.argv.slice(2),Oe.getStore()]),c=Po.get(s);if(!c){let x=await Io(a,"codex",Oe.getStore());if(!x.nativePrincipal||!x.clientThreadId||!x.clientTurnId||!x.observedModel||!x.observedReasoningEffort||!x.transcriptPath){let C=Object.entries({native_principal:!!x.nativePrincipal,client_thread:!!x.clientThreadId,client_turn:!!x.clientTurnId,observed_model:!!x.observedModel,observed_reasoning_effort:!!x.observedReasoningEffort,transcript_path:!!x.transcriptPath}).filter(([,E])=>!E).map(([E])=>E);O(`observed_principal_receipt_required:missing=${C.join(",")}`)}c={thread:x.clientThreadId,turn:x.clientTurnId,model:x.observedModel,effort:x.observedReasoningEffort,transcript:x.transcriptPath,principal:x.nativePrincipal},Po.set(s,c)}let l={...Oe.getStore(),threadId:c.thread,transcriptPath:c.transcript,includeHumanMessages:!0,includeWorkspaceRoot:!0},p=await ne(o,l);(!p||p.sessionId!==c.thread||p.turnId!==c.turn||p.model!==c.model||p.reasoningEffort!==c.effort||!p.workspaceRoot||!p.humanMessages?.length)&&O("fresh_transcript_context_required");let u=await(i==="closure"?Ro:Co)(o,n,{clientThreadId:c.thread,clientTurnId:c.turn,observedModel:c.model,observedReasoningEffort:c.effort,observedServiceTier:p.serviceTier??null,userMessage:p.userMessage,transcriptPath:c.transcript,nativePrincipal:c.principal},e,Oe.getStore()?.sessionsRoot),f=u.origin.source,_=u.origin.fold,m=_.run,h=await G(p.workspaceRoot,f.primaryRoot);m.client_turn_id||O("source_turn_missing");let v=await Ct(o,{...Oe.getStore(),threadId:c.thread,transcriptPath:c.transcript,sourceTurnId:m.client_turn_id,currentTurnId:c.turn});(!v||v.source.model!==m.model||v.source.reasoningEffort!==m.reasoning_effort||v.current.model!==c.model||v.current.reasoningEffort!==c.effort)&&O("complete_original_human_history_required"),u.kind.task&&P(m.direct_execution_authorization??"")!==P(e)&&O("original_human_source_mismatch");let y=await ul(u,v.messages),{constraints:g,steering:b}=yo(e,m.client_turn_id,m.task_id,v.messages),w=Object.freeze({binding_id:Hn(m.run_id,Z(P(e)),Z(o)),source_run_id:m.run_id,current_run_id:n,current_turn_id:c.turn,source_sha256:Z(P(e)),steering_sha256:Z(JSON.stringify(b)),repository_sha256:Z(o),records_workspace_sha256:Z(f.filesystem.root),native_workspace_sha256:Z(h),client_thread_id:c.thread,client_turn_id:m.client_turn_id,git_only:u.kind.gitOnly,constraints:Object.freeze(g)});return(i==="closure"?Xn:Yn).add(w),m.execution_id||O("source_execution_missing"),(i==="closure"?Vo:qo).set(w,Object.freeze({repository:o,primaryRoot:f.primaryRoot,originalTurn:i==="publication"&&y.fold.run.run_id===n&&m.client_turn_id===c.turn&&y.fold.finished===null&&y.fold.finalization_decision===null,currentRunId:n,taskId:m.task_id,changeId:m.change_id,executionId:m.execution_id,request:e,sourceStartedAt:m.occurred_at,sourceFinishedAt:y.fold.finished?.occurred_at??null})),w}function po(t,e,n){return $o(t,e,n,"publication")}function jx(t,e,n){return $o(t,e,n,"closure")}function Wx(t,e){(!t||!Xn.has(t)||t.source_sha256!==Z(P(e)))&&O("verified_native_closure_source_required")}async function Ux(t,e,n){for(let i of n)i.command!=="node"&&O("git_only_requires_committed_node_harness"),(await _n({repository_path:t,commit_sha:e,executable_path:process.execPath,args:[...i.args]})).status!=="passed"&&O("git_only_candidate_validation_failed")}function Hx(t,e){(!t||!Yn.has(t)||t.source_sha256!==Z(P(e)))&&O("verified_native_source_required")}export{Ee as a,Q as b,bs as c,K as d,Gt as e,uo as f,Wn as g,Lx as h,po as i,jx as j,Wx as k,Ux as l,Hx as m,lb as n,lo as o,db as p};
|