@zaip-ai/cli 4.5.0 → 4.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 +2 -0
- package/dist/services/adapters.d.ts +1 -1
- package/dist/services/adapters.js +4 -4
- package/dist/services/adapters.js.map +1 -1
- package/dist/services/codex-native-tool-authority-template.d.ts.map +1 -1
- package/dist/services/codex-native-tool-authority-template.js +188 -9
- package/dist/services/codex-native-tool-authority-template.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 +50 -128
- package/dist/services/codex-pre-tool-hook-template.js.map +1 -1
- package/dist/services/codex-pre-tool-hook-template.test.js +4 -0
- package/dist/services/codex-pre-tool-hook-template.test.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 +1 -4
- package/dist/services/codex-pre-tool-support-template.js.map +1 -1
- package/dist/services/codex-stale-git-lock-template.d.ts +2 -0
- package/dist/services/codex-stale-git-lock-template.d.ts.map +1 -0
- package/dist/services/codex-stale-git-lock-template.js +64 -0
- package/dist/services/codex-stale-git-lock-template.js.map +1 -0
- package/dist/services/global-codex-config-migration.test.js +1 -4
- package/dist/services/global-codex-config-migration.test.js.map +1 -1
- package/dist/services/install-template-policy.d.ts.map +1 -1
- package/dist/services/install-template-policy.js +2 -0
- package/dist/services/install-template-policy.js.map +1 -1
- package/dist/services/logger.js +2 -1
- package/dist/services/logger.js.map +1 -1
- package/dist/services/logger.test.js +71 -0
- package/dist/services/logger.test.js.map +1 -1
- package/dist/services/runtime-template-test-support.d.ts +3 -0
- package/dist/services/runtime-template-test-support.d.ts.map +1 -0
- package/dist/services/runtime-template-test-support.js +32 -0
- package/dist/services/runtime-template-test-support.js.map +1 -0
- package/dist/services/runtime-template.test.js +23 -31
- package/dist/services/runtime-template.test.js.map +1 -1
- package/package.json +1 -1
- package/templates/.agents/README.md +8 -0
- package/templates/.agents/config/agents/discovery.json +1 -1
- package/templates/.agents/config/deploy-policy.json +5 -0
- package/templates/.agents/dashboard/.zaip-managed.json +211 -75
- package/templates/.agents/dashboard/README.md +2 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{CostCalculationGuidePage-f4ZGJRg3.js → CostCalculationGuidePage-BRtiPijr.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{DashboardHelpDialog-CkQ_y8kg.js → DashboardHelpDialog-BR4ZeYpE.js} +99 -10
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{PricingSettingsDialog-v9zGRTlk.js → PricingSettingsDialog-Dr4QDFmn.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{ProjectSettingsPage-doIMhei7.js → ProjectSettingsPage-BG0N5dw_.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{TraceabilityWorkspace-C_4ftjyB.js → TraceabilityWorkspace-BvoM-YQ0.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-fTQhSL85.js +68 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{icons-vendor-Cv3WBFIF.js → icons-vendor-Bc6vux5t.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-BMfzKaAR.js +2 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-DZhppOIk.css +1 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{react-vendor-mHgsmxb6.js → react-vendor-DNJQFov3.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{traceability-B0CPyEVq.js → traceability-B7tjIB7W.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/index.html +6 -6
- package/templates/.agents/dashboard/apps/frontend/package.json +1 -1
- package/templates/.agents/dashboard/apps/frontend/src/AppOverlays.tsx +6 -34
- package/templates/.agents/dashboard/apps/frontend/src/ReconciliationFeedback.dom.test.ts +130 -0
- package/templates/.agents/dashboard/apps/frontend/src/ReconciliationFeedback.tsx +226 -0
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-api-sqlite-view.ts +45 -0
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-api.test.ts +15 -0
- package/templates/.agents/dashboard/apps/frontend/src/dashboard-api.ts +17 -46
- package/templates/.agents/dashboard/apps/frontend/src/reconciliation-feedback-fixtures.ts +23 -0
- package/templates/.agents/dashboard/apps/frontend/src/reconciliation-feedback-model.test.ts +69 -0
- package/templates/.agents/dashboard/apps/frontend/src/reconciliation-feedback-model.ts +59 -0
- package/templates/.agents/dashboard/apps/frontend/src/reconciliation-feedback.css +131 -0
- package/templates/.agents/dashboard/apps/frontend/src/styles.css +0 -32
- package/templates/.agents/dashboard/apps/frontend/src/use-dashboard-app-model.tsx +2 -2
- package/templates/.agents/dashboard/modules/cost-monitor/package.json +1 -1
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorPage.test.ts +2 -2
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorPage.tsx +1 -1
- package/templates/.agents/dashboard/modules/operations/package.json +1 -1
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsPage.tsx +1 -4
- package/templates/.agents/dashboard/modules/operations/src/react/UnifiedWorkBoard.navigation.test.ts +236 -0
- package/templates/.agents/dashboard/modules/operations/src/react/UnifiedWorkBoard.tsx +1 -24
- package/templates/.agents/dashboard/modules/operations/src/react/operations-overview-period-filter.test.ts +3 -2
- package/templates/.agents/dashboard/modules/traceability/package.json +1 -1
- package/templates/.agents/dashboard/packages/branding/package.json +1 -1
- package/templates/.agents/dashboard/packages/contracts/package.json +1 -1
- package/templates/.agents/dashboard/packages/data-export/package.json +1 -1
- package/templates/.agents/dashboard/packages/local-runtime/DIAGNOSTICS.md +42 -0
- package/templates/.agents/dashboard/packages/local-runtime/dashboard-diagnostics.d.mts +10 -0
- package/templates/.agents/dashboard/packages/local-runtime/dashboard-diagnostics.mjs +101 -0
- package/templates/.agents/dashboard/packages/local-runtime/dashboard-diagnostics.test.mjs +58 -0
- package/templates/.agents/dashboard/packages/local-runtime/dist/server.cjs +232 -217
- package/templates/.agents/dashboard/packages/local-runtime/dist/sqlite-read-model.cjs +201 -188
- package/templates/.agents/dashboard/packages/local-runtime/package.json +1 -1
- package/templates/.agents/dashboard/packages/local-runtime/scripts/test-sqlite-dashboard-startup.mjs +233 -0
- package/templates/.agents/dashboard/packages/local-runtime/scripts/validate-provider-nonzero.mjs +45 -0
- package/templates/.agents/dashboard/packages/local-runtime/scripts/verify-dashboard-executable-startup.mjs +107 -0
- package/templates/.agents/dashboard/packages/local-runtime/scripts/verify-dashboard-reconciliation-executable.mjs +271 -0
- package/templates/.agents/dashboard/packages/local-runtime/server.mjs +232 -217
- package/templates/.agents/dashboard/packages/local-runtime/src/active-codex-telemetry.test.ts +78 -12
- package/templates/.agents/dashboard/packages/local-runtime/src/active-codex-telemetry.ts +36 -56
- package/templates/.agents/dashboard/packages/local-runtime/src/canonical-source-revision-cache.test.ts +125 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/canonical-source-revision-cache.ts +168 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/dashboard-diagnostics.test.ts +57 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-agent-catalog-routes.ts +76 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-dual-reads-manifest-summaries-without-losing.test.ts +5 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-reconciliation-diagnostics.test.ts +118 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-reconciliation-result.test.ts +35 -6
- package/templates/.agents/dashboard/packages/local-runtime/src/server-reconciliation-route.ts +105 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot-synchronization.test.ts +64 -9
- package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot-synchronization.ts +19 -27
- package/templates/.agents/dashboard/packages/local-runtime/src/server-telemetry-command.test.ts +111 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-telemetry-refresh.test.ts +59 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-telemetry-refresh.ts +44 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-work-reconciliation.test.ts +20 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-work-reconciliation.ts +12 -7
- package/templates/.agents/dashboard/packages/local-runtime/src/server-workspace.ts +48 -6
- package/templates/.agents/dashboard/packages/local-runtime/src/server.test.ts +2 -2
- package/templates/.agents/dashboard/packages/local-runtime/src/server.ts +126 -134
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-agent-page.ts +14 -2
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-dashboard-startup.test.ts +163 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-dashboard-startup.ts +78 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-header-timestamp.test.ts +31 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-provider-nonzero.test.ts +271 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-provider-visibility.ts +32 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-operations-duration.ts +58 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-provider-dimension.ts +12 -3
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-view-page.ts +9 -58
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-rebuild.ts +9 -35
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-schema.ts +10 -8
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-source-fingerprint.ts +43 -45
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model.test.ts +5 -9
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model.ts +5 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-startup-seed.test.ts +87 -0
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-logging.mjs +6 -2
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-server.mjs +7 -1
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard.mjs +4 -5
- package/templates/.agents/dashboard/packages/ui/package.json +1 -1
- package/templates/.agents/dashboard/packages/ui/src/DashboardHeader.test.mjs +33 -4
- package/templates/.agents/dashboard/packages/ui/src/DashboardHeader.tsx +8 -7
- package/templates/.agents/dashboard/packages/windows-launcher/Program.cs +46 -3
- package/templates/.agents/dashboard/tests/e2e/package.json +1 -1
- package/templates/.agents/dashboard/tests/e2e/qualify-kanban-popup.mjs +56 -0
- package/templates/.agents/dashboard/tests/e2e/specs/dashboard-update-label.spec.ts +49 -0
- package/templates/.agents/design/.zaip-managed.json +17 -5
- package/templates/.agents/design/apps/catalog/dist/assets/index-D3uhpycC.js +72 -0
- package/templates/.agents/design/apps/catalog/dist/index.html +1 -1
- package/templates/.agents/design/apps/catalog/package.json +1 -1
- package/templates/.agents/design/apps/catalog/src/pages/ComponentsPage.tsx +13 -1
- package/templates/.agents/design/apps/catalog/src/specimens/ReconciliationSpecimen.stories.tsx +6 -0
- package/templates/.agents/design/apps/catalog/src/specimens/ReconciliationSpecimen.tsx +101 -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 +1 -1
- 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 +1 -1
- 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 +1 -1
- package/templates/.agents/requirements/model-orchestration.md +21 -6
- package/templates/.agents/requirements/public-distribution.md +4 -4
- 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/core.md +3 -1
- package/templates/.agents/rules/workflow.md +3 -2
- package/templates/.agents/runtime/VERSION +1 -1
- package/templates/.agents/runtime/bin/zaip.mjs +366 -196
- package/templates/.agents/runtime/checksums.sha256 +5 -5
- package/templates/.agents/runtime/manifest.json +1 -1
- package/templates/.agents/runtime/provenance.json +4 -4
- package/templates/.agents/runtime/sbom.cdx.json +1 -1
- package/templates/.agents/skills/zaip-skill-config/SKILL.md +25 -3
- package/templates/.agents/skills/zaip-skill-execution/SKILL.md +4 -0
- package/templates/.agents/skills/zaip-skill-execution/references/autonomous-continuation.md +4 -0
- package/templates/.agents/skills/zaip-skill-execution/references/candidate-workflow.md +1 -1
- package/templates/.agents/skills/zaip-skill-execution/references/runtime-governance.md +2 -2
- package/templates/.agents/skills/zaip-skill-general-operations/SKILL.md +1 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/SKILL.md +36 -48
- package/templates/.agents/skills/zaip-skill-github-deploy/agents/openai.yaml +2 -2
- package/templates/.agents/skills/zaip-skill-github-deploy/references/deployment-workflow.md +67 -99
- package/templates/.agents/skills/zaip-skill-github-deploy/references/release-identity.md +33 -30
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/deploy-contract.mjs +303 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/deploy-contract.test.mjs +334 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/github-deploy-contract.test.mjs +41 -28
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/guarded-commits.mjs +212 -0
- package/templates/.agents/skills/zaip-skill-lifecycle-closure/SKILL.md +4 -0
- package/templates/.agents/skills/zaip-skill-prd/SKILL.md +4 -0
- package/templates/.agents/skills/zaip-skill-release-qualification/SKILL.md +44 -68
- package/templates/.agents/skills/zaip-skill-release-qualification/references/local-preparation.md +91 -44
- package/templates/.agents/skills/zaip-skill-send-email/SKILL.md +15 -0
- package/templates/.agents/skills/zaip-skill-send-email/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-setup/SKILL.md +5 -2
- package/templates/.agents/skills/zaip-skill-spec/SKILL.md +4 -0
- package/templates/.agents/skills/zaip-skill-task/SKILL.md +4 -0
- package/templates/.agents/skills/zaip-skill-testing-strategy/SKILL.md +19 -0
- package/templates/.agents/skills/zaip-skill-tool-setup/SKILL.md +2 -0
- package/templates/.agents/skills/zaip-skill-use-connectors/SKILL.md +15 -0
- package/templates/.agents/skills/zaip-skill-use-connectors/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-use-connectors/scripts/connector-guidance.test.mjs +29 -0
- package/templates/.agents/skills/zaip-skill-use-connectors/scripts/verify-connector-lock.mjs +30 -0
- package/templates/.agents/tools/cloud-runner.integration.test.mjs +3 -0
- package/templates/.agents/zaip-aios/VERSION +1 -1
- package/templates/.agents/zaip-aios/guides/03-tasks.md +6 -0
- package/templates/.agents/zaip-aios/guides/04-specs.md +6 -0
- package/templates/.agents/zaip-aios/guides/05-prds.md +4 -0
- package/templates/.agents/zaip-aios/guides/06-execucao.md +6 -0
- package/templates/.agents/zaip-aios/guides/16-lifecycle-e-reconciliacao.md +6 -0
- package/templates/.agents/zaip-aios/guides/19-assurance-e-autonomia.md +4 -0
- package/templates/.agents/zaip-aios/guides/22-fluxos-e-roteamento.md +6 -0
- package/templates/.agents/zaip-aios/guides/23-orquestracao-de-modelos.md +36 -4
- package/templates/.agents/zaip-aios/guides/26-qualidade-e-release.md +15 -4
- package/templates/.agents/zaip-aios/guides/28-lifecycle-completo.md +8 -0
- package/templates/template-manifest.json +330 -142
- package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-D7PrDZy9.js +0 -68
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-OBJXZOwe.css +0 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-Rbmpz4UO.js +0 -2
package/README.md
CHANGED
|
@@ -226,3 +226,5 @@ Run `corepack pnpm verify` from `public-cli` before submitting a change. The pac
|
|
|
226
226
|
uses `SEE LICENSE IN LICENSE`; the bundled [LICENSE](LICENSE) carries the proprietary
|
|
227
227
|
ZAIP-AIOS Commercial License notice. Consult that file for the applicable terms, npm for
|
|
228
228
|
the published version, and the release evidence for the qualification status.
|
|
229
|
+
|
|
230
|
+
Repository source v4.5 defines a shared writer claim for serial Tasks, limited parallel worktrees, recoverable isolated checkout closure, a current-release manifest and exact-SHA pre-main CI for critical/builder release delivery. The packaged CLI must pass template/runtime parity and installation qualification before those source rules are treated as an installed version.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type PublicAgentCatalog } from "./agent-adapters.js";
|
|
2
2
|
export { isManagedAdapter } from "./managed-adapter.js";
|
|
3
|
-
export declare const ADAPTERS_VERSION = "4.
|
|
3
|
+
export declare const ADAPTERS_VERSION = "4.6.0";
|
|
4
4
|
export interface AdapterFile {
|
|
5
5
|
path: string;
|
|
6
6
|
content: string;
|
|
@@ -11,7 +11,7 @@ export { isManagedAdapter } from "./managed-adapter.js";
|
|
|
11
11
|
import { CODEX_GITHUB_DEPLOY_RULES, CODEX_SECURITY_RULES } from "./codex-rules.js";
|
|
12
12
|
import { codexWindowsHookCommand } from "./codex-windows-hook-command.js";
|
|
13
13
|
import { applyTransactionalChanges, assertSafeDestination } from "./transactional-files.js";
|
|
14
|
-
export const ADAPTERS_VERSION = "4.
|
|
14
|
+
export const ADAPTERS_VERSION = "4.6.0";
|
|
15
15
|
const ROOT_GUIDANCE = `# ZAIP-AIOS
|
|
16
16
|
|
|
17
17
|
Read \`.agents/config/project.yaml\` first. Apply ZAIP only for literal boolean \`zaip.enabled: true\`, except framework maintenance or \`zaip enable\`. \`AGENTS.md\` is a bootstrap; canonical guidance lives in \`.agents/\`.
|
|
@@ -185,9 +185,9 @@ const CLAUDE_SETTINGS = `{
|
|
|
185
185
|
`;
|
|
186
186
|
export function adapterFiles(workspaceRoot, catalog) {
|
|
187
187
|
const codexConfig = CODEX_CONFIG.replaceAll(CODEX_WORKSPACE_ROOT_PLACEHOLDER, JSON.stringify(resolve(workspaceRoot)))
|
|
188
|
-
.replaceAll("__ZAIP_WINDOWS_PRE_TOOL_HOOK__", codexWindowsHookCommand("zaip-pre-tool-use.mjs"
|
|
189
|
-
.replaceAll("__ZAIP_WINDOWS_CONVERSATION_HOOK__", codexWindowsHookCommand("zaip-conversation-lifecycle.mjs"
|
|
190
|
-
.replaceAll("__ZAIP_WINDOWS_SUBAGENT_HOOK__", codexWindowsHookCommand("zaip-subagent-lifecycle.mjs"
|
|
188
|
+
.replaceAll("__ZAIP_WINDOWS_PRE_TOOL_HOOK__", codexWindowsHookCommand("zaip-pre-tool-use.mjs"))
|
|
189
|
+
.replaceAll("__ZAIP_WINDOWS_CONVERSATION_HOOK__", codexWindowsHookCommand("zaip-conversation-lifecycle.mjs"))
|
|
190
|
+
.replaceAll("__ZAIP_WINDOWS_SUBAGENT_HOOK__", codexWindowsHookCommand("zaip-subagent-lifecycle.mjs"));
|
|
191
191
|
return [
|
|
192
192
|
...(catalog === undefined
|
|
193
193
|
? []
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapters.js","sourceRoot":"","sources":["../../src/services/adapters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,iCAAiC,EACjC,mBAAmB,EACnB,2BAA2B,EAC3B,6BAA6B,GAC9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,gBAAgB,EAEhB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,gCAAgC,EAAE,MAAM,2CAA2C,CAAC;AAC7F,OAAO,EAAE,qBAAqB,EAAE,M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AI,EAAE,eAAe,EAAE,OAAO,EAAE,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IACD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC;IACjF,MAAM,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACvD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;AAC1C,CAAC;AAED,KAAK,UAAU,oBAAoB,CAAC,IAAY;IAC9C,MAAM,OAAO,GAAG,uBAAuB,CACrC,MAAM,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,oCAAoC,CAAC,EAAE,MAAM,CAAC,CAC5E,CAAC;IACF,OAAO,CAAC,GAAG,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAC,CAAC;AAC/E,CAAC;AAED,SAAS,OAAO,CAAC,IAAY,EAAE,IAAY,EAAE,MAAc;IACzD,OAAO,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex-native-tool-authority-template.d.ts","sourceRoot":"","sources":["../../src/services/codex-native-tool-authority-template.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,gCAAgC,
|
|
1
|
+
{"version":3,"file":"codex-native-tool-authority-template.d.ts","sourceRoot":"","sources":["../../src/services/codex-native-tool-authority-template.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,gCAAgC,QA0QT,CAAC"}
|
|
@@ -1,7 +1,92 @@
|
|
|
1
1
|
import { CODEX_VALIDATION_RUNTIME_SUPPORT } from "./codex-validation-runtime-template.js";
|
|
2
|
-
export const CODEX_NATIVE_TOOL_AUTHORITY_HOOK = String.raw `import {
|
|
3
|
-
import {
|
|
2
|
+
export const CODEX_NATIVE_TOOL_AUTHORITY_HOOK = String.raw `import { execFileSync } from "node:child_process";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
import { lstat, readFile, realpath } from "node:fs/promises";
|
|
4
5
|
import { dirname, isAbsolute, relative, resolve } from "node:path";
|
|
6
|
+
import { pathToFileURL } from "node:url";
|
|
7
|
+
// Run starts remain JSON objects; subsequent canonical v3 events are compact arrays.
|
|
8
|
+
// Decode only identity/terminal fields needed for authority, never infer a Run.
|
|
9
|
+
export function readAuthorityRunRecords(text, id) {
|
|
10
|
+
if (typeof text !== "string" || !text.endsWith("\n")) throw new Error("incomplete_run");
|
|
11
|
+
const types = { f: "run.finished", d: "run.finalization.decided", a: "run.attribution.recovered", m: "model.selection.recorded", p: "provider.invocation.finished", c: "model.call.observed", u: "usage.recorded" };
|
|
12
|
+
const records = text.split(/\r?\n/).filter(Boolean).map((line, index) => {
|
|
13
|
+
const value = JSON.parse(line);
|
|
14
|
+
const record = Array.isArray(value)
|
|
15
|
+
? value[0] === 3 && Object.hasOwn(types, value[1]) && value.length >= 7
|
|
16
|
+
? { schema_version: 2, type: types[value[1]], event_id: value[2], sequence: value[3], run_id: id }
|
|
17
|
+
: null
|
|
18
|
+
: value;
|
|
19
|
+
if (!record || record.schema_version !== 2 || record.run_id !== id || record.sequence !== index + 1 ||
|
|
20
|
+
((Array.isArray(value) || record.event_id !== undefined) && record.event_id !== id + ":" + String(index + 1).padStart(6, "0")) ||
|
|
21
|
+
typeof record.type !== "string" || (index === 0 ? record.type !== "run.started" : record.type === "run.started"))
|
|
22
|
+
throw new Error("invalid_run_identity");
|
|
23
|
+
return record;
|
|
24
|
+
});
|
|
25
|
+
if (!records.length) throw new Error("empty_run");
|
|
26
|
+
return records;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function checkDestructivePatterns(command, patterns, deny) {
|
|
30
|
+
if (/^(?:Write-Output|echo|printf)\s+'(?:[^']|'')*'\s*$/i.test(command)) return;
|
|
31
|
+
for (const entry of patterns) if (entry.pattern.test(command)) deny(entry.reason);
|
|
32
|
+
}
|
|
33
|
+
export async function configuredDeploymentBranches(repositoryRoot, deny) {
|
|
34
|
+
const defaults = { applicationBranches: ["beta"], scopeBranches: { frontend: "beta", backend: "beta" }, productionBranch: "main" };
|
|
35
|
+
let source;
|
|
36
|
+
try {
|
|
37
|
+
source = await readFile(resolve(repositoryRoot, ".agents/config/project.yaml"), "utf8");
|
|
38
|
+
} catch (error) {
|
|
39
|
+
if (error?.code === "ENOENT") return defaults;
|
|
40
|
+
deny("Could not read project.yaml deploy policy.");
|
|
41
|
+
}
|
|
42
|
+
let document;
|
|
43
|
+
try {
|
|
44
|
+
const parser = await import(
|
|
45
|
+
pathToFileURL(
|
|
46
|
+
resolve(repositoryRoot, ".agents/skills/zaip-skill-github-deploy/scripts/yaml-parser.mjs"),
|
|
47
|
+
).href,
|
|
48
|
+
);
|
|
49
|
+
document = parser.parseDocument(source, { strict: true, uniqueKeys: true });
|
|
50
|
+
} catch {
|
|
51
|
+
deny("Canonical deploy YAML parser is unavailable.");
|
|
52
|
+
}
|
|
53
|
+
if (document.errors.length > 0) deny("project.yaml deploy policy is malformed.");
|
|
54
|
+
const config = document.toJS();
|
|
55
|
+
if (config === null || typeof config !== "object" || Array.isArray(config)) {
|
|
56
|
+
deny("project.yaml must contain a mapping.");
|
|
57
|
+
}
|
|
58
|
+
const deploy = config.deploy;
|
|
59
|
+
if (deploy === undefined) return defaults;
|
|
60
|
+
if (deploy === null || typeof deploy !== "object" || Array.isArray(deploy)) {
|
|
61
|
+
deny("project.yaml deploy must be a mapping.");
|
|
62
|
+
}
|
|
63
|
+
if (!Object.keys(deploy).every((key) => ["branch", "production_branch", "allow_production", "frontend", "backend", "database"].includes(key))) {
|
|
64
|
+
deny("project.yaml deploy has unsupported keys.");
|
|
65
|
+
}
|
|
66
|
+
for (const key of ["frontend", "backend", "database"]) {
|
|
67
|
+
if (deploy[key] !== undefined && (deploy[key] === null || typeof deploy[key] !== "object" || Array.isArray(deploy[key]) || !Object.keys(deploy[key]).every((nested) => nested === "branch"))) deny("project.yaml deploy scope is invalid.");
|
|
68
|
+
}
|
|
69
|
+
const productionBranch = Object.hasOwn(deploy, "production_branch")
|
|
70
|
+
? deploy.production_branch
|
|
71
|
+
: defaults.productionBranch;
|
|
72
|
+
const frontend = deploy.frontend !== undefined && Object.hasOwn(deploy.frontend, "branch") ? deploy.frontend.branch : "beta";
|
|
73
|
+
const backend = deploy.backend !== undefined && Object.hasOwn(deploy.backend, "branch") ? deploy.backend.branch : "beta";
|
|
74
|
+
const database = deploy.database !== undefined && Object.hasOwn(deploy.database, "branch") ? deploy.database.branch : "beta";
|
|
75
|
+
if (database !== "beta") deny("project.yaml deploy.database.branch must be beta.");
|
|
76
|
+
if (
|
|
77
|
+
!isSafeBranchName(frontend) ||
|
|
78
|
+
!isSafeBranchName(backend) ||
|
|
79
|
+
!isSafeBranchName(productionBranch) ||
|
|
80
|
+
(frontend !== "main" && frontend === productionBranch) ||
|
|
81
|
+
(backend !== "main" && backend === productionBranch)
|
|
82
|
+
) {
|
|
83
|
+
deny("project.yaml application deploy policy is invalid.");
|
|
84
|
+
}
|
|
85
|
+
return { applicationBranches: [...new Set([frontend, backend])], scopeBranches: { frontend, backend }, productionBranch };
|
|
86
|
+
}
|
|
87
|
+
function isSafeBranchName(branch) {
|
|
88
|
+
return typeof branch === "string" && branch.length <= 255 && /^[A-Za-z0-9][A-Za-z0-9._/-]*$/.test(branch) && !branch.includes("..") && !branch.includes("//") && !branch.includes("@{") && !branch.endsWith(".") && !branch.endsWith("/") && !branch.split("/").some((segment) => segment.startsWith(".") || segment.endsWith(".lock"));
|
|
89
|
+
}
|
|
5
90
|
const inside = (path, root) => { const scoped = relative(root, resolve(path)); return scoped === "" || (!scoped.startsWith("..") && !isAbsolute(scoped)); };
|
|
6
91
|
const authorityPath = path => /^(?:\.agents\/(?:records|data\/runs)\/|\.local\/(?:codex-hook-|codex-telemetry-spool\/|runs\/))/i.test(path.replaceAll("\\", "/"));
|
|
7
92
|
/** Inspect existing ancestors too: a missing destination can still traverse a junction. */
|
|
@@ -34,13 +119,14 @@ async function canonicalScopes(id, root, boundedRead) {
|
|
|
34
119
|
});
|
|
35
120
|
}
|
|
36
121
|
/** Validate only this native child's patch scope and its still-active canonical ancestry. */
|
|
37
|
-
export async function hasNativeDelegatedPatch(event, repositoryRoot, boundedRead) {
|
|
122
|
+
export async function hasNativeDelegatedPatch(event, repositoryRoot, boundedRead, authorityRoot = repositoryRoot) {
|
|
38
123
|
if (event.tool_name !== "apply_patch" || typeof event.session_id !== "string" || typeof event.turn_id !== "string") return false;
|
|
39
124
|
try {
|
|
40
125
|
const key = createHash("sha256").update(JSON.stringify([event.session_id, event.turn_id])).digest("hex");
|
|
41
|
-
const binding = JSON.parse(await boundedRead(resolve(
|
|
126
|
+
const binding = JSON.parse(await boundedRead(resolve(authorityRoot, ".local/codex-hook-native/v2", key + ".json"), 65536));
|
|
42
127
|
if (binding.schema_version !== 2 || binding.session_id !== event.session_id || binding.turn_id !== event.turn_id ||
|
|
43
|
-
typeof binding.native_session_id !== "string" ||
|
|
128
|
+
typeof binding.native_session_id !== "string" ||
|
|
129
|
+
![binding.native_session_id, binding.parent_session_id, binding.host_session_id].includes(event.session_id) ||
|
|
44
130
|
!Array.isArray(binding.write_scopes) || !binding.write_scopes.length) return false;
|
|
45
131
|
const readRun = async id => {
|
|
46
132
|
const match = typeof id === "string" && /^RUN-(\d{4})-(\d{2})-(\d{2})-[A-Z0-9-]+-[A-Z0-9]{2,16}$/.exec(id);
|
|
@@ -48,30 +134,42 @@ export async function hasNativeDelegatedPatch(event, repositoryRoot, boundedRead
|
|
|
48
134
|
let text;
|
|
49
135
|
for (const directory of [match[1] + "/" + match[2], match[1] + "/" + match[2] + "/" + match[3]]) {
|
|
50
136
|
try {
|
|
51
|
-
const value = await boundedRead(resolve(
|
|
137
|
+
const value = await boundedRead(resolve(authorityRoot, ".agents/records/runs", directory, id + ".jsonl"), 8388608);
|
|
52
138
|
if (text !== undefined) throw new Error("ambiguous_run");
|
|
53
139
|
text = value;
|
|
54
140
|
} catch (error) { if (error.code !== "ENOENT") throw error; }
|
|
55
141
|
}
|
|
56
142
|
if (!text?.endsWith("\n")) throw new Error("incomplete_run");
|
|
57
|
-
const records = text
|
|
143
|
+
const records = readAuthorityRunRecords(text, id);
|
|
58
144
|
if (records.some((row, i) => row.schema_version !== 2 || row.sequence !== i + 1 || row.run_id !== id ||
|
|
59
145
|
row.type === "run.finished" || row.type === "run.finalization.decided")) throw new Error("inactive_run");
|
|
60
146
|
if (records[0]?.type !== "run.started") throw new Error("invalid_run");
|
|
61
147
|
return records[0];
|
|
62
148
|
};
|
|
63
149
|
const child = await readRun(binding.run_id), parent = await readRun(binding.parent_run_id);
|
|
150
|
+
const macro = parent.parent_run_id === null ? null : await readRun(parent.parent_run_id);
|
|
151
|
+
const ownTaskRoot = parent.parent_run_id === null && parent.run_role === "orchestrator";
|
|
152
|
+
const delegatedTaskOrchestrator = macro !== null &&
|
|
153
|
+
parent.run_role === "subagent" && parent.run_purpose === "orchestration" &&
|
|
154
|
+
parent.entrypoint === "task" && typeof parent.spec_id === "string" &&
|
|
155
|
+
macro.agent === "agent-orchestrator" && macro.run_role === "orchestrator" &&
|
|
156
|
+
macro.parent_run_id === null && macro.entrypoint === "spec" &&
|
|
157
|
+
macro.task_id === null && macro.spec_id === parent.spec_id &&
|
|
158
|
+
macro.execution_id === parent.execution_id &&
|
|
159
|
+
child.spec_id === parent.spec_id && child.change_id === parent.change_id;
|
|
160
|
+
if (binding.host_session_id !== undefined &&
|
|
161
|
+
binding.host_session_id !== (macro === null ? parent.client_thread_id : macro.client_thread_id)) return false;
|
|
64
162
|
if (child.client !== "codex-subagent" || child.run_role !== "subagent" || child.run_purpose !== "execution" ||
|
|
65
163
|
!child.execution_eligibility?.includes("delivery") || child.parent_run_id !== parent.run_id ||
|
|
66
164
|
child.client_thread_id !== binding.agent_id || child.client_turn_id !== event.turn_id ||
|
|
67
|
-
parent.agent !== "agent-orchestrator" ||
|
|
165
|
+
parent.agent !== "agent-orchestrator" || !(ownTaskRoot || delegatedTaskOrchestrator) ||
|
|
68
166
|
parent.client_thread_id !== binding.parent_session_id ||
|
|
69
167
|
parent.entrypoint !== "task" || !binding.task_id || !binding.execution_id ||
|
|
70
168
|
child.task_id !== binding.task_id || parent.task_id !== binding.task_id ||
|
|
71
169
|
child.execution_id !== binding.execution_id || parent.execution_id !== binding.execution_id) return false;
|
|
72
170
|
const command = event.tool_input?.command;
|
|
73
171
|
if (typeof command !== "string") return false;
|
|
74
|
-
const scopes = await canonicalScopes(binding.task_id,
|
|
172
|
+
const scopes = await canonicalScopes(binding.task_id, authorityRoot, boundedRead);
|
|
75
173
|
if (JSON.stringify(scopes) !== JSON.stringify(binding.write_scopes)) return false;
|
|
76
174
|
const paths = [...command.matchAll(/^\*\*\* (?:Add File|Update File|Delete File|Move to): (.+)$/gm)].map(match => match[1].trim());
|
|
77
175
|
for (const path of paths) if (!await isSafePatchPath(resolve(repositoryRoot, path), repositoryRoot)) return false;
|
|
@@ -85,5 +183,86 @@ export async function hasNativeDelegatedPatch(event, repositoryRoot, boundedRead
|
|
|
85
183
|
});
|
|
86
184
|
} catch { return false; }
|
|
87
185
|
}
|
|
186
|
+
export async function hasCurrentTaskOrchestratorRun(event, installedRoot, boundedRead) {
|
|
187
|
+
const threadId = event.session_id, turnId = event.turn_id;
|
|
188
|
+
if (typeof threadId !== "string" || typeof turnId !== "string" || !threadId || !turnId) return false;
|
|
189
|
+
if ((process.env.CODEX_THREAD_ID && threadId !== process.env.CODEX_THREAD_ID) ||
|
|
190
|
+
(process.env.CODEX_TURN_ID && turnId !== process.env.CODEX_TURN_ID)) return false;
|
|
191
|
+
try {
|
|
192
|
+
const digest = createHash("sha256").update(JSON.stringify(["codex", threadId, turnId, null, null])).digest("hex");
|
|
193
|
+
const correlation = JSON.parse(await boundedRead(resolve(installedRoot, ".local/codex-telemetry-spool/v1/correlations", digest + ".json"), 65536, installedRoot));
|
|
194
|
+
const id = correlation.run_id;
|
|
195
|
+
const dated = typeof id === "string" ? /^RUN-(\d{4})-(\d{2})-(\d{2})-[A-Z0-9-]+-[A-Z0-9]{2,16}$/.exec(id) : null;
|
|
196
|
+
if (!dated || correlation.schema_version !== 1 || correlation.thread_id !== threadId || correlation.turn_id !== turnId || correlation.agent_path !== null) return false;
|
|
197
|
+
const candidates = [
|
|
198
|
+
".agents/records/runs/" + dated[1] + "/" + dated[2] + "/" + id + ".jsonl",
|
|
199
|
+
".agents/records/runs/" + dated[1] + "/" + dated[2] + "/" + dated[3] + "/" + id + ".jsonl",
|
|
200
|
+
".agents/data/runs/" + dated[1] + "/" + dated[2] + "/" + dated[3] + "/" + id + ".jsonl",
|
|
201
|
+
".local/runs/" + dated[1] + "/" + dated[2] + "/" + id + ".jsonl",
|
|
202
|
+
];
|
|
203
|
+
let selected = null;
|
|
204
|
+
for (const candidate of candidates) {
|
|
205
|
+
try {
|
|
206
|
+
const source = await boundedRead(resolve(installedRoot, candidate), 8388608, installedRoot);
|
|
207
|
+
if (selected !== null) return false;
|
|
208
|
+
selected = source;
|
|
209
|
+
} catch (error) { if (error.code !== "ENOENT") return false; }
|
|
210
|
+
}
|
|
211
|
+
if (selected === null || !selected.endsWith("\n")) return false;
|
|
212
|
+
const records = readAuthorityRunRecords(selected, id), started = records[0];
|
|
213
|
+
if (records.some((record, i) => record.run_id !== id || record.sequence !== i + 1 || record.schema_version !== 2)) return false;
|
|
214
|
+
const valid = started?.type === "run.started" && started.client_thread_id === threadId && started.client_turn_id === turnId &&
|
|
215
|
+
["codex", "codex-desktop"].includes(started.client) && started.phase === "execution" &&
|
|
216
|
+
typeof started.task_id === "string" && started.task_id.startsWith("TASK-") &&
|
|
217
|
+
typeof started.execution_id === "string" && started.execution_id.startsWith("EXEC-") &&
|
|
218
|
+
started.agent === "agent-orchestrator" && started.run_role === "orchestrator" && started.parent_run_id === null && started.entrypoint === "task" &&
|
|
219
|
+
correlation.task_id === started.task_id && correlation.execution_id === started.execution_id &&
|
|
220
|
+
!records.some(record => record.type === "run.finished" || record.type === "run.finalization.decided");
|
|
221
|
+
return valid ? started : false;
|
|
222
|
+
} catch { return false; }
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** A Task's product writer is claimed centrally before any edit. */
|
|
226
|
+
function isolatedGitMatchesClaim(repositoryRoot, authorityRoot, claim) {
|
|
227
|
+
const git = (root, args) => execFileSync("git", ["-C", root, ...args], {
|
|
228
|
+
encoding: "utf8", windowsHide: true, timeout: 15000,
|
|
229
|
+
env: Object.fromEntries(Object.entries(process.env).filter(([key]) => !/^(GIT_|NODE_OPTIONS$)/i.test(key))),
|
|
230
|
+
}).trim();
|
|
231
|
+
if (resolve(git(repositoryRoot, ["rev-parse", "--show-toplevel"])) !== resolve(repositoryRoot) ||
|
|
232
|
+
git(repositoryRoot, ["branch", "--show-current"]) !== claim.branch) return false;
|
|
233
|
+
const head = git(repositoryRoot, ["rev-parse", "HEAD"]);
|
|
234
|
+
if (head !== git(authorityRoot, ["rev-parse", claim.branch])) return false;
|
|
235
|
+
return git(authorityRoot, ["worktree", "list", "--porcelain"]).split(/\r?\n\r?\n/).some(block => {
|
|
236
|
+
const lines = block.split(/\r?\n/);
|
|
237
|
+
return lines.some(line => line.startsWith("worktree ") && resolve(line.slice(9)) === resolve(repositoryRoot)) &&
|
|
238
|
+
lines.includes("HEAD " + head) && lines.includes("branch refs/heads/" + claim.branch);
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
export async function hasClaimedTaskWriter(event, repositoryRoot, boundedRead, directRun = null, authorityRoot = repositoryRoot) {
|
|
242
|
+
try {
|
|
243
|
+
let runId = directRun?.run_id, taskId = directRun?.task_id, executionId = directRun?.execution_id;
|
|
244
|
+
if (!runId) {
|
|
245
|
+
const key = createHash("sha256").update(JSON.stringify([event.session_id, event.turn_id])).digest("hex");
|
|
246
|
+
const binding = JSON.parse(await boundedRead(resolve(authorityRoot, ".local/codex-hook-native/v2", key + ".json"), 65536));
|
|
247
|
+
if (binding.session_id !== event.session_id || binding.turn_id !== event.turn_id) return false;
|
|
248
|
+
runId = binding.parent_run_id; taskId = binding.task_id; executionId = binding.execution_id;
|
|
249
|
+
}
|
|
250
|
+
if (!/^RUN-[A-Z0-9-]+$/.test(runId ?? "") || !/^TASK-[A-Z0-9-]+$/.test(taskId ?? "") ||
|
|
251
|
+
!/^EXEC-[A-Z0-9-]+$/.test(executionId ?? "")) return false;
|
|
252
|
+
const source = await boundedRead(resolve(authorityRoot, ".local/task-workspaces/shared-writer.json"), 65536).catch(() => null);
|
|
253
|
+
const claim = source === null ? null : JSON.parse(source);
|
|
254
|
+
if (claim?.mode === "shared" && claim.status === "ready" && claim.branch === null &&
|
|
255
|
+
claim.run_id === runId && claim.task_id === taskId && claim.execution_id === executionId &&
|
|
256
|
+
resolve(claim.path) === resolve(authorityRoot) && resolve(repositoryRoot) === resolve(authorityRoot) &&
|
|
257
|
+
resolve(claim.canonical_workspace) === resolve(authorityRoot)) return true;
|
|
258
|
+
const isolated = JSON.parse(await boundedRead(resolve(authorityRoot, ".local/task-workspaces/claims", taskId + ".json"), 65536));
|
|
259
|
+
return isolated.status === "ready" && isolated.mode !== "shared" &&
|
|
260
|
+
isolated.run_id === runId && isolated.task_id === taskId && isolated.execution_id === executionId &&
|
|
261
|
+
typeof isolated.branch === "string" && isolated.branch.startsWith("codex/") &&
|
|
262
|
+
resolve(isolated.path) === resolve(repositoryRoot) &&
|
|
263
|
+
resolve(isolated.canonical_workspace) === resolve(authorityRoot) &&
|
|
264
|
+
isolatedGitMatchesClaim(repositoryRoot, authorityRoot, isolated);
|
|
265
|
+
} catch { return false; }
|
|
266
|
+
}
|
|
88
267
|
` + CODEX_VALIDATION_RUNTIME_SUPPORT;
|
|
89
268
|
//# sourceMappingURL=codex-native-tool-authority-template.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex-native-tool-authority-template.js","sourceRoot":"","sources":["../../src/services/codex-native-tool-authority-template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,wCAAwC,CAAC;AAC1F,MAAM,CAAC,MAAM,gCAAgC,
|
|
1
|
+
{"version":3,"file":"codex-native-tool-authority-template.js","sourceRoot":"","sources":["../../src/services/codex-native-tool-authority-template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,wCAAwC,CAAC;AAC1F,MAAM,CAAC,MAAM,gCAAgC,GAC3C,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyQX,GAAG,gCAAgC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex-pre-tool-hook-template.d.ts","sourceRoot":"","sources":["../../src/services/codex-pre-tool-hook-template.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"codex-pre-tool-hook-template.d.ts","sourceRoot":"","sources":["../../src/services/codex-pre-tool-hook-template.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,QAqpB/B,CAAC"}
|