@zaip-ai/cli 4.9.0 → 5.1.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/dist/services/adapter-hook-sources.d.ts +3 -0
- package/dist/services/adapter-hook-sources.d.ts.map +1 -1
- package/dist/services/adapter-hook-sources.js +3 -0
- package/dist/services/adapter-hook-sources.js.map +1 -1
- package/dist/services/adapters.d.ts +1 -1
- package/dist/services/adapters.d.ts.map +1 -1
- package/dist/services/adapters.js +5 -2
- package/dist/services/adapters.js.map +1 -1
- package/dist/services/adapters.test.js +1 -1
- package/dist/services/adapters.test.js.map +1 -1
- package/dist/services/codex-conversation-lifecycle-hook.d.ts.map +1 -1
- package/dist/services/codex-conversation-lifecycle-hook.js +16 -6
- package/dist/services/codex-conversation-lifecycle-hook.js.map +1 -1
- 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 +116 -10
- package/dist/services/codex-hook-activation.js.map +1 -1
- package/dist/services/codex-pre-tool-cli-capture-template.d.ts +2 -0
- package/dist/services/codex-pre-tool-cli-capture-template.d.ts.map +1 -0
- package/dist/services/codex-pre-tool-cli-capture-template.js +104 -0
- package/dist/services/codex-pre-tool-cli-capture-template.js.map +1 -0
- package/dist/services/codex-pre-tool-cloud-template.d.ts +2 -0
- package/dist/services/codex-pre-tool-cloud-template.d.ts.map +1 -0
- package/dist/services/codex-pre-tool-cloud-template.js +190 -0
- package/dist/services/codex-pre-tool-cloud-template.js.map +1 -0
- package/dist/services/codex-pre-tool-dependencies.test-support.d.ts +2 -0
- package/dist/services/codex-pre-tool-dependencies.test-support.d.ts.map +1 -0
- package/dist/services/codex-pre-tool-dependencies.test-support.js +9 -0
- package/dist/services/codex-pre-tool-dependencies.test-support.js.map +1 -0
- package/dist/services/codex-pre-tool-hook-fixture.test-support.d.ts +5 -0
- package/dist/services/codex-pre-tool-hook-fixture.test-support.d.ts.map +1 -0
- package/dist/services/codex-pre-tool-hook-fixture.test-support.js +19 -0
- package/dist/services/codex-pre-tool-hook-fixture.test-support.js.map +1 -0
- package/dist/services/codex-pre-tool-hook-template-bootstrap.test.d.ts +2 -0
- package/dist/services/codex-pre-tool-hook-template-bootstrap.test.d.ts.map +1 -0
- package/dist/services/codex-pre-tool-hook-template-bootstrap.test.js +107 -0
- package/dist/services/codex-pre-tool-hook-template-bootstrap.test.js.map +1 -0
- package/dist/services/codex-pre-tool-hook-template.d.ts.map +1 -1
- package/dist/services/codex-pre-tool-hook-template.js +96 -210
- package/dist/services/codex-pre-tool-hook-template.js.map +1 -1
- package/dist/services/codex-pre-tool-hook-template.test.js +32 -80
- package/dist/services/codex-pre-tool-hook-template.test.js.map +1 -1
- package/dist/services/codex-pre-tool-host-context-template.d.ts +2 -0
- package/dist/services/codex-pre-tool-host-context-template.d.ts.map +1 -0
- package/dist/services/codex-pre-tool-host-context-template.js +139 -0
- package/dist/services/codex-pre-tool-host-context-template.js.map +1 -0
- package/dist/services/codex-pre-tool-support-template.d.ts.map +1 -1
- package/dist/services/codex-pre-tool-support-template.js +61 -101
- package/dist/services/codex-pre-tool-support-template.js.map +1 -1
- 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 +13 -2
- package/dist/services/codex-subagent-hook-template.js.map +1 -1
- package/dist/services/codex-validation-runtime-template.d.ts.map +1 -1
- package/dist/services/codex-validation-runtime-template.js +10 -4
- package/dist/services/codex-validation-runtime-template.js.map +1 -1
- package/dist/services/runtime-template-test-support.d.ts +1 -0
- package/dist/services/runtime-template-test-support.d.ts.map +1 -1
- package/dist/services/runtime-template-test-support.js +23 -2
- package/dist/services/runtime-template-test-support.js.map +1 -1
- package/dist/services/runtime-template.test.js +4 -23
- package/dist/services/runtime-template.test.js.map +1 -1
- package/package.json +1 -1
- package/templates/.agents/README-ENG.md +58 -7
- package/templates/.agents/README.md +46 -10
- package/templates/.agents/config/agents/discovery.json +1 -1
- package/templates/.agents/dashboard/.zaip-managed.json +174 -86
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{CostCalculationGuidePage-BW7Vy1cp.js → CostCalculationGuidePage-uR-asJv_.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{DashboardHelpDialog-Cp_hEVd8.js → DashboardHelpDialog-CngnpoLL.js} +87 -13
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{PricingSettingsDialog-Prcs-ydy.js → PricingSettingsDialog-Bszw3ekd.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{ProjectSettingsPage-Cu40wAFF.js → ProjectSettingsPage-IJ1znG4w.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{TraceabilityWorkspace-Bh3YBd3C.js → TraceabilityWorkspace-CsBpHqq_.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-B0Jwz_rk.js +68 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{dashboard-localization-CF7B1Hjn.js → dashboard-localization-D41g5rdo.js} +58 -7
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{icons-vendor-DOhy6D2-.js → icons-vendor-CjGGux6h.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-Bedlm0f7.js +2 -0
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{react-vendor-CkPC-yMz.js → react-vendor-B9jZSAKf.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/assets/{traceability-BEdGoIDm.js → traceability-DFpwb0TN.js} +1 -1
- package/templates/.agents/dashboard/apps/frontend/dist/index.html +5 -5
- package/templates/.agents/dashboard/apps/frontend/package.json +2 -2
- package/templates/.agents/dashboard/apps/frontend/src/AppDashboardContent.tsx +3 -0
- package/templates/.agents/dashboard/apps/frontend/src/AppOverlays.tsx +16 -7
- package/templates/.agents/dashboard/apps/frontend/src/__tests__/app-composition-support.ts +1 -0
- package/templates/.agents/dashboard/apps/frontend/src/cost-period-refresh.test.ts +1 -1
- package/templates/.agents/dashboard/apps/frontend/src/operations-period-render.test.ts +2 -0
- package/templates/.agents/dashboard/apps/frontend/src/use-app-trace-documents.navigation.test.tsx +125 -0
- package/templates/.agents/dashboard/apps/frontend/src/use-app-trace-documents.ts +67 -9
- package/templates/.agents/dashboard/apps/frontend/src/use-dashboard-app-model.tsx +15 -15
- package/templates/.agents/dashboard/apps/frontend/src/use-dashboard-locale.ts +18 -0
- package/templates/.agents/dashboard/modules/cost-monitor/package.json +1 -1
- package/templates/.agents/dashboard/modules/cost-monitor/src/contracts.ts +10 -3
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostFilters.run-page.test.ts +5 -1
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostGroupsTable.period-values.test.tsx +2 -2
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTables-keeps-legacy-codex-identity-fields-blank.test.ts +5 -5
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTables.test.ts +36 -43
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-loaders.ts +1 -0
- package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-table-formatters.ts +6 -4
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/aggregate.ts +2 -2
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-monitor-projection.ts +1 -1
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-summary-projection.ts +11 -25
- package/templates/.agents/dashboard/modules/cost-monitor/src/server/cost-summary-defaults.ts +26 -0
- package/templates/.agents/dashboard/modules/operations/package.json +1 -1
- package/templates/.agents/dashboard/modules/operations/src/contracts.ts +11 -16
- package/templates/.agents/dashboard/modules/operations/src/planning-contracts.ts +14 -0
- package/templates/.agents/dashboard/modules/operations/src/react/DecisionTable.tsx +65 -0
- package/templates/.agents/dashboard/modules/operations/src/react/EntityTables.tsx +5 -71
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverview.tsx +4 -39
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverviewTopPanel.navigation.test.tsx +150 -0
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsOverviewTopPanel.tsx +7 -3
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsPage.tsx +14 -43
- package/templates/.agents/dashboard/modules/operations/src/react/OperationsPageOverview.tsx +3 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-overview-contract.ts +51 -0
- package/templates/.agents/dashboard/modules/operations/src/react/operations-overview-period-filter.test.ts +12 -3
- package/templates/.agents/dashboard/modules/operations/src/react/operations-page-contract.ts +1 -0
- package/templates/.agents/dashboard/modules/operations/src/react/use-operations-default-range.ts +16 -0
- package/templates/.agents/dashboard/modules/operations/src/react/use-operations-filter-sync.ts +66 -0
- package/templates/.agents/dashboard/modules/traceability/package.json +1 -1
- package/templates/.agents/dashboard/packages/branding/package.json +1 -1
- package/templates/.agents/dashboard/packages/contracts/package.json +1 -1
- package/templates/.agents/dashboard/packages/data-export/package.json +1 -1
- package/templates/.agents/dashboard/packages/local-runtime/dashboard-build-fingerprint.mjs +87 -0
- package/templates/.agents/dashboard/packages/local-runtime/dashboard-build-fingerprint.test.mjs +48 -0
- package/templates/.agents/dashboard/packages/local-runtime/dist/server.cjs +193 -191
- package/templates/.agents/dashboard/packages/local-runtime/dist/sqlite-read-model.cjs +169 -169
- package/templates/.agents/dashboard/packages/local-runtime/package.json +1 -1
- package/templates/.agents/dashboard/packages/local-runtime/scripts/build-frontend.mjs +29 -0
- package/templates/.agents/dashboard/packages/local-runtime/scripts/build-sqlite-runtime.mjs +5 -0
- package/templates/.agents/dashboard/packages/local-runtime/server.mjs +193 -191
- package/templates/.agents/dashboard/packages/local-runtime/src/active-capture-failure.test.ts +38 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/active-capture-failure.ts +35 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/active-codex-telemetry.test.ts +53 -2
- package/templates/.agents/dashboard/packages/local-runtime/src/active-codex-telemetry.ts +18 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/manifest-runs.ts +8 -2
- package/templates/.agents/dashboard/packages/local-runtime/src/server-capture-projection-order.test.ts +118 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-cost-run-search.test.ts +90 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-cost-run-search.ts +86 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-operations-routes.ts +8 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/server-projection-loaders.ts +13 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-projections.ts +30 -74
- package/templates/.agents/dashboard/packages/local-runtime/src/server-route-handlers.ts +42 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-routes.test.ts +60 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server-run-projections.test.ts +12 -2
- package/templates/.agents/dashboard/packages/local-runtime/src/server-telemetry-command.test.ts +29 -4
- package/templates/.agents/dashboard/packages/local-runtime/src/server-telemetry-refresh.ts +7 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/server.test.ts +51 -54
- package/templates/.agents/dashboard/packages/local-runtime/src/server.ts +28 -45
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-filter-matrix.test.ts +5 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-invocation-page.test.ts +49 -0
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-invocation-page.ts +44 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-cached-cost-page.ts +11 -10
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-summary.ts +1 -1
- package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-work-item-index.test.ts +18 -1
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-build.mjs +12 -5
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-paths.mjs +8 -0
- package/templates/.agents/dashboard/packages/local-runtime/start-dashboard.test.mjs +1 -0
- package/templates/.agents/dashboard/packages/ui/package.json +1 -1
- package/templates/.agents/dashboard/tests/e2e/package.json +1 -1
- package/templates/.agents/dashboard/tests/e2e/qualify-top-five-trace.mjs +53 -0
- package/templates/.agents/dashboard/tests/e2e/verify-top-five-served.mjs +78 -0
- package/templates/.agents/design/.zaip-managed.json +14 -6
- package/templates/.agents/design/apps/catalog/dist/assets/index-BGxXxXTo.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/components/TopEntitiesSpecimen.tsx +45 -0
- package/templates/.agents/design/apps/catalog/src/pages/ComponentsPage.tsx +3 -1
- package/templates/.agents/design/apps/catalog/src/stories/Components.stories.tsx +2 -0
- package/templates/.agents/design/packages/local-runtime/package.json +1 -1
- package/templates/.agents/requirements/autonomous-assurance.md +11 -2
- 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 +1 -1
- package/templates/.agents/requirements/public-distribution.md +1 -1
- 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 +2 -1
- package/templates/.agents/requirements/zaip-strategic-95.md +1 -1
- package/templates/.agents/rules/run-lifecycle-closure.md +2 -1
- package/templates/.agents/rules/workflow.md +1 -0
- package/templates/.agents/runtime/VERSION +1 -1
- package/templates/.agents/runtime/bin/zaip.mjs +1178 -764
- package/templates/.agents/runtime/checksums.sha256 +6 -6
- package/templates/.agents/runtime/manifest.json +1 -1
- package/templates/.agents/runtime/pnpm-lock.sha256 +1 -1
- package/templates/.agents/runtime/provenance.json +5 -5
- package/templates/.agents/runtime/sbom.cdx.json +59 -59
- package/templates/.agents/skills/zaip-skill-execution/SKILL.md +1 -1
- package/templates/.agents/skills/zaip-skill-execution/references/controlled-release-recovery.md +14 -0
- package/templates/.agents/skills/zaip-skill-execution/references/runtime-governance.md +1 -1
- package/templates/.agents/skills/zaip-skill-github-deploy/SKILL.md +5 -1
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/deploy-contract-cli.test.mjs +53 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/deploy-contract.mjs +12 -0
- package/templates/.agents/skills/zaip-skill-github-deploy/scripts/deploy-contract.test.mjs +26 -32
- package/templates/.agents/skills/zaip-skill-maintenance-enter/SKILL.md +23 -0
- package/templates/.agents/skills/zaip-skill-maintenance-enter/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-maintenance-enter/scripts/maintenance.mjs +213 -0
- package/templates/.agents/skills/zaip-skill-maintenance-enter/scripts/maintenance.test.mjs +207 -0
- package/templates/.agents/skills/zaip-skill-maintenance-exit/SKILL.md +21 -0
- package/templates/.agents/skills/zaip-skill-maintenance-exit/agents/openai.yaml +4 -0
- package/templates/.agents/skills/zaip-skill-release-qualification/SKILL.md +2 -0
- package/templates/.agents/skills/zaip-skill-release-qualification/references/local-preparation.md +37 -8
- package/templates/.agents/zaip-aios/VERSION +1 -1
- package/templates/.agents/zaip-aios/guides/10-seguranca.md +2 -2
- package/templates/.agents/zaip-aios/guides/26-qualidade-e-release.md +38 -0
- package/templates/template-manifest.json +259 -135
- package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-Co2Jiuzh.js +0 -68
- package/templates/.agents/dashboard/apps/frontend/dist/assets/index-qVSJnJ0_.js +0 -2
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
export const CODEX_PRE_TOOL_CLOUD_HOOK = String.raw `import { readFile } from "node:fs/promises";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
|
|
4
|
+
export function createCloudValidators({ tokenizeLiteralCommand, deny, repositoryRoot, isWithinRepository, cloudRunnerScript, cloudContractPath, cloudOperationProviders }) {
|
|
5
|
+
function optionMap(tokens) {
|
|
6
|
+
if (tokens.length % 2 !== 0) return null;
|
|
7
|
+
const values = new Map();
|
|
8
|
+
for (let index = 0; index < tokens.length; index += 2) {
|
|
9
|
+
const key = tokens[index];
|
|
10
|
+
const value = tokens[index + 1];
|
|
11
|
+
if (!key.startsWith("--") || value.startsWith("--") || values.has(key)) return null;
|
|
12
|
+
values.set(key, value);
|
|
13
|
+
}
|
|
14
|
+
return values;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function requireExactOptions(options, allowed, required) {
|
|
18
|
+
if ([...options.keys()].some((key) => !allowed.has(key))) return false;
|
|
19
|
+
return [...required].every((key) => typeof options.get(key) === "string" && options.get(key).length > 0);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function isStringArray(value) {
|
|
23
|
+
return Array.isArray(value) && value.every((item) => typeof item === "string" && item.length > 0);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async function readCloudContract(options) {
|
|
27
|
+
if (options.get("--contract") !== cloudContractPath) {
|
|
28
|
+
deny("Cloud runner must use the canonical autonomous-cloud contract path.");
|
|
29
|
+
}
|
|
30
|
+
const absolute = resolve(repositoryRoot, cloudContractPath);
|
|
31
|
+
if (!isWithinRepository(absolute)) deny("Cloud runner contract escapes the repository boundary.");
|
|
32
|
+
let contract;
|
|
33
|
+
try {
|
|
34
|
+
contract = JSON.parse(await readFile(absolute, "utf8"));
|
|
35
|
+
} catch {
|
|
36
|
+
deny("Cloud runner contract is absent or malformed.");
|
|
37
|
+
}
|
|
38
|
+
if (
|
|
39
|
+
contract === null ||
|
|
40
|
+
typeof contract !== "object" ||
|
|
41
|
+
contract.version !== 1 ||
|
|
42
|
+
contract.profile !== "autonomous-cloud" ||
|
|
43
|
+
contract.cloudflare === null ||
|
|
44
|
+
typeof contract.cloudflare !== "object" ||
|
|
45
|
+
contract.hostinger === null ||
|
|
46
|
+
typeof contract.hostinger !== "object"
|
|
47
|
+
) {
|
|
48
|
+
deny("Cloud runner contract has no valid autonomous-cloud profile.");
|
|
49
|
+
}
|
|
50
|
+
return contract;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function cloudflareTargetMatches(contract, options, operation) {
|
|
54
|
+
const cloudflare = contract.cloudflare;
|
|
55
|
+
const record = options.get("--dns-record");
|
|
56
|
+
const managed = isStringArray(cloudflare.dns_records) && cloudflare.dns_records.includes(record);
|
|
57
|
+
const direct = cloudflare.direct_dns_records !== null && typeof cloudflare.direct_dns_records === "object" && Object.hasOwn(cloudflare.direct_dns_records, record);
|
|
58
|
+
return (
|
|
59
|
+
typeof cloudflare.account_id === "string" &&
|
|
60
|
+
typeof cloudflare.zone_id === "string" &&
|
|
61
|
+
isStringArray(cloudflare.allowed_operations) &&
|
|
62
|
+
cloudflare.account_id === options.get("--account-id") &&
|
|
63
|
+
cloudflare.zone_id === options.get("--zone-id") &&
|
|
64
|
+
cloudflare.allowed_operations.includes(operation) &&
|
|
65
|
+
(operation === "cloudflare:dns:read" ? managed || direct : direct && !managed)
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function hostingerTargetMatches(contract, options, operation) {
|
|
70
|
+
const hostinger = contract.hostinger;
|
|
71
|
+
const role = options.get("--vps-role");
|
|
72
|
+
if (
|
|
73
|
+
typeof hostinger.account_id !== "string" ||
|
|
74
|
+
!isStringArray(hostinger.allowed_operations) ||
|
|
75
|
+
hostinger.account_id !== options.get("--account-id") ||
|
|
76
|
+
!hostinger.allowed_operations.includes(operation) ||
|
|
77
|
+
(role !== "edge" && role !== "application") ||
|
|
78
|
+
hostinger.vps === null ||
|
|
79
|
+
typeof hostinger.vps !== "object"
|
|
80
|
+
) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
const target = hostinger.vps[role];
|
|
84
|
+
if (target === null || typeof target !== "object") return false;
|
|
85
|
+
|
|
86
|
+
if (typeof target.id !== "string" || target.id !== options.get("--vps-id")) return false;
|
|
87
|
+
if (operation.startsWith("hostinger:ssh:")) {
|
|
88
|
+
return typeof target.host_key_sha256 === "string" && target.host_key_sha256 === options.get("--host-key-sha256");
|
|
89
|
+
}
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function terraformTargetMatches(contract, options, operation) {
|
|
94
|
+
const terraform = contract.terraform;
|
|
95
|
+
if (
|
|
96
|
+
terraform === null ||
|
|
97
|
+
typeof terraform !== "object" ||
|
|
98
|
+
!isStringArray(terraform.allowed_operations) ||
|
|
99
|
+
!terraform.allowed_operations.includes(operation)
|
|
100
|
+
) return false;
|
|
101
|
+
if (operation === "terraform:plan") return terraform.working_directory === options.get("--terraform-directory");
|
|
102
|
+
if (operation === "terraform:apply") {
|
|
103
|
+
const plan = terraform.plan;
|
|
104
|
+
return plan !== null && typeof plan === "object" && typeof plan.path === "string" && typeof plan.sha256 === "string" && typeof plan.policy_result_sha256 === "string" && plan.path === options.get("--plan-path") && plan.sha256 === options.get("--plan-sha256") && plan.policy_result_sha256 === options.get("--policy-result-sha256");
|
|
105
|
+
}
|
|
106
|
+
return terraform.import_targets !== null && typeof terraform.import_targets === "object" && terraform.import_targets[options.get("--resource-address")] === options.get("--resource-id");
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function validateDirectCloudProviderMutation(command) {
|
|
110
|
+
const tokens = tokenizeLiteralCommand(command);
|
|
111
|
+
if (/^(?:node|node\.exe)$/i.test(tokens?.[0] ?? "") && tokens?.[1] === cloudRunnerScript) return;
|
|
112
|
+
if (/\bterraform(?:\.exe)?\s+(?:apply|destroy|import)\b/i.test(command)) deny("Direct Terraform mutation is blocked; use the contract-bound cloud runner.");
|
|
113
|
+
const provider = /^(?:wrangler|cloudflare|hostinger)(?:\.exe|\.cmd|\.js|\.mjs)?$/i;
|
|
114
|
+
const wrapperProvider = /^(?:wrangler|cloudflare|hostinger)(?:\.exe|\.cmd|\.js|\.mjs|@[A-Za-z0-9][A-Za-z0-9._-]*)?$/i;
|
|
115
|
+
const base = (token) => token?.split(/[\\/]/).at(-1) ?? "";
|
|
116
|
+
if (tokens === null) {
|
|
117
|
+
// Complex shell syntax stays fail-closed; literal arguments are inspected as tokens below.
|
|
118
|
+
if (/\b(?:wrangler|cloudflare|hostinger)(?:\.exe)?\b/i.test(command)) deny("Direct Cloudflare or Hostinger commands are blocked; use the contract-bound cloud runner.");
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
let index = 0;
|
|
122
|
+
const launcher = base(tokens[0]);
|
|
123
|
+
if (/^(?:npx|pnpm|npm|yarn|bunx)(?:\.cmd|\.exe)?$/i.test(launcher)) {
|
|
124
|
+
// Package-manager options can move the executable. Inspect exact provider
|
|
125
|
+
// tokens across this recognized wrapper; paths and document names remain inert.
|
|
126
|
+
if (tokens.slice(1).some((token) => wrapperProvider.test(token))) deny("Direct Cloudflare or Hostinger commands are blocked; use the contract-bound cloud runner.");
|
|
127
|
+
index = 1;
|
|
128
|
+
if (/^npx(?:\.cmd|\.exe)?$/i.test(launcher) && /^(?:--yes|-y)$/.test(tokens[index] ?? "")) index += 1;
|
|
129
|
+
if (/^pnpm(?:\.cmd|\.exe)?$/i.test(launcher) && /^(?:--filter|--dir)$/.test(tokens[index] ?? "") && tokens[index + 1]) index += 2;
|
|
130
|
+
if (/^(?:exec|dlx)$/.test(tokens[index] ?? "")) index += 1;
|
|
131
|
+
if (tokens[index] === "--") index += 1;
|
|
132
|
+
if (/^(?:exec|dlx)$/.test(tokens[index] ?? "")) index += 1;
|
|
133
|
+
} else if (/^(?:node|node\.exe)$/i.test(launcher)) index = 1;
|
|
134
|
+
else if (/^(?:powershell|pwsh|cmd|bash|sh)(?:\.exe)?$/i.test(launcher)) {
|
|
135
|
+
if (/\b(?:wrangler|cloudflare|hostinger)(?:\.exe)?\b/i.test(command)) deny("Direct Cloudflare or Hostinger commands are blocked; use the contract-bound cloud runner.");
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (provider.test(base(tokens[index]))) deny("Direct Cloudflare or Hostinger commands are blocked; use the contract-bound cloud runner.");
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
async function validateCloudRunner(command) {
|
|
142
|
+
const tokens = tokenizeLiteralCommand(command);
|
|
143
|
+
if (tokens === null || tokens.length < 2 || !/^(?:node|node\.exe)$/i.test(tokens[0]) || tokens[1] !== cloudRunnerScript) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
const options = optionMap(tokens.slice(2));
|
|
147
|
+
if (options === null) deny("Cloud runner requires literal, named arguments.");
|
|
148
|
+
const operation = options.get("--operation");
|
|
149
|
+
if (operation === "contract:derive") {
|
|
150
|
+
if (!requireExactOptions(options, new Set(["--operation", "--credentials-source"]), new Set(["--operation", "--credentials-source"]))) {
|
|
151
|
+
deny("Cloud contract derivation has unrecognized arguments.");
|
|
152
|
+
}
|
|
153
|
+
if (options.get("--credentials-source") !== "root") {
|
|
154
|
+
deny("Cloud contract derivation requires the selected root credential source.");
|
|
155
|
+
}
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
const provider = cloudOperationProviders.get(operation);
|
|
159
|
+
if (provider === undefined) deny("Cloud runner operation is unrecognized or destructive.");
|
|
160
|
+
const common = new Set(["--contract", "--operation", "--provider", "--account-id", "--credentials-source", "--zone-id", "--dns-record", "--vps-role", "--vps-id", "--host-key-sha256", "--terraform-directory", "--plan-path", "--plan-sha256", "--policy-result-sha256", "--resource-address", "--resource-id"]);
|
|
161
|
+
const baseRequired = provider === "terraform"
|
|
162
|
+
? new Set(["--contract", "--operation", "--credentials-source"])
|
|
163
|
+
: new Set(["--contract", "--operation", "--provider", "--account-id", "--credentials-source"]);
|
|
164
|
+
if (!requireExactOptions(options, common, baseRequired)) {
|
|
165
|
+
deny("Cloud runner invocation has unrecognized arguments.");
|
|
166
|
+
}
|
|
167
|
+
if ((provider !== "terraform" && options.get("--provider") !== provider) || !["root", "agents"].includes(options.get("--credentials-source"))) {
|
|
168
|
+
deny("Cloud runner provider or credential source is outside the approved contract.");
|
|
169
|
+
}
|
|
170
|
+
const contract = await readCloudContract(options);
|
|
171
|
+
const valid = provider === "cloudflare"
|
|
172
|
+
? requireExactOptions(options, common, new Set(["--contract", "--operation", "--provider", "--account-id", "--credentials-source", "--zone-id", "--dns-record"])) && cloudflareTargetMatches(contract, options, operation)
|
|
173
|
+
: provider === "hostinger"
|
|
174
|
+
? requireExactOptions(options, common, new Set(["--contract", "--operation", "--provider", "--account-id", "--credentials-source", "--vps-role"])) && hostingerTargetMatches(contract, options, operation)
|
|
175
|
+
: requireExactOptions(
|
|
176
|
+
options,
|
|
177
|
+
common,
|
|
178
|
+
operation === "terraform:plan"
|
|
179
|
+
? new Set(["--contract", "--operation", "--credentials-source", "--terraform-directory"])
|
|
180
|
+
: operation === "terraform:apply"
|
|
181
|
+
? new Set(["--contract", "--operation", "--credentials-source", "--plan-path", "--plan-sha256", "--policy-result-sha256"])
|
|
182
|
+
: new Set(["--contract", "--operation", "--credentials-source", "--resource-address", "--resource-id"]),
|
|
183
|
+
) && terraformTargetMatches(contract, options, operation);
|
|
184
|
+
if (!valid) deny("Cloud runner target, operation, or host identity is outside the approved contract.");
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
return { validateCloudRunner, validateDirectCloudProviderMutation };
|
|
188
|
+
}
|
|
189
|
+
`;
|
|
190
|
+
//# sourceMappingURL=codex-pre-tool-cloud-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-pre-tool-cloud-template.js","sourceRoot":"","sources":["../../src/services/codex-pre-tool-cloud-template.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4LlD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-pre-tool-dependencies.test-support.d.ts","sourceRoot":"","sources":["../../src/services/codex-pre-tool-dependencies.test-support.ts"],"names":[],"mappings":"AAIA,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GACtD,OAAO,CAAC,IAAI,CAAC,CAIf"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CODEX_PRE_TOOL_CLOUD_HOOK } from "./codex-pre-tool-cloud-template.js";
|
|
2
|
+
import { CODEX_PRE_TOOL_HOST_CONTEXT_HOOK } from "./codex-pre-tool-host-context-template.js";
|
|
3
|
+
import { CODEX_PRE_TOOL_CLI_CAPTURE_HOOK } from "./codex-pre-tool-cli-capture-template.js";
|
|
4
|
+
export async function writePreToolDependencies(write) {
|
|
5
|
+
await write("zaip-pre-tool-cloud.mjs", CODEX_PRE_TOOL_CLOUD_HOOK);
|
|
6
|
+
await write("zaip-pre-tool-host-context.mjs", CODEX_PRE_TOOL_HOST_CONTEXT_HOOK);
|
|
7
|
+
await write("zaip-pre-tool-cli-capture.mjs", CODEX_PRE_TOOL_CLI_CAPTURE_HOOK);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=codex-pre-tool-dependencies.test-support.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-pre-tool-dependencies.test-support.js","sourceRoot":"","sources":["../../src/services/codex-pre-tool-dependencies.test-support.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,gCAAgC,EAAE,MAAM,2CAA2C,CAAC;AAC7F,OAAO,EAAE,+BAA+B,EAAE,MAAM,0CAA0C,CAAC;AAE3F,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,KAAuD;IAEvD,MAAM,KAAK,CAAC,yBAAyB,EAAE,yBAAyB,CAAC,CAAC;IAClE,MAAM,KAAK,CAAC,gCAAgC,EAAE,gCAAgC,CAAC,CAAC;IAChF,MAAM,KAAK,CAAC,+BAA+B,EAAE,+BAA+B,CAAC,CAAC;AAChF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-pre-tool-hook-fixture.test-support.d.ts","sourceRoot":"","sources":["../../src/services/codex-pre-tool-hook-fixture.test-support.ts"],"names":[],"mappings":"AAQA,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,MAAM;;;GAUpD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { CODEX_HOOK_ACTIVATION } from "./codex-hook-activation.js";
|
|
4
|
+
import { CODEX_NATIVE_TOOL_AUTHORITY_HOOK } from "./codex-native-tool-authority-template.js";
|
|
5
|
+
import { writePreToolDependencies } from "./codex-pre-tool-dependencies.test-support.js";
|
|
6
|
+
import { CODEX_PRE_TOOL_HOOK } from "./codex-pre-tool-hook-template.js";
|
|
7
|
+
import { CODEX_PRE_TOOL_SUPPORT_HOOK } from "./codex-pre-tool-support-template.js";
|
|
8
|
+
export async function installPreToolHook(root) {
|
|
9
|
+
const hooks = join(root, ".codex", "hooks");
|
|
10
|
+
await mkdir(hooks, { recursive: true });
|
|
11
|
+
const hookPath = join(hooks, "zaip-pre-tool-use.mjs");
|
|
12
|
+
await writeFile(hookPath, CODEX_PRE_TOOL_HOOK);
|
|
13
|
+
await writeFile(join(hooks, "zaip-hook-activation.mjs"), CODEX_HOOK_ACTIVATION);
|
|
14
|
+
await writeFile(join(hooks, "zaip-pre-tool-support.mjs"), CODEX_PRE_TOOL_SUPPORT_HOOK);
|
|
15
|
+
await writePreToolDependencies((file, content) => writeFile(join(hooks, file), content));
|
|
16
|
+
await writeFile(join(hooks, "zaip-native-tool-authority.mjs"), CODEX_NATIVE_TOOL_AUTHORITY_HOOK);
|
|
17
|
+
return { hooks, hookPath };
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=codex-pre-tool-hook-fixture.test-support.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-pre-tool-hook-fixture.test-support.js","sourceRoot":"","sources":["../../src/services/codex-pre-tool-hook-fixture.test-support.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,gCAAgC,EAAE,MAAM,2CAA2C,CAAC;AAC7F,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AAEnF,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAAY;IACnD,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC5C,MAAM,KAAK,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,EAAE,uBAAuB,CAAC,CAAC;IACtD,MAAM,SAAS,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC;IAC/C,MAAM,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,0BAA0B,CAAC,EAAE,qBAAqB,CAAC,CAAC;IAChF,MAAM,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,2BAA2B,CAAC,EAAE,2BAA2B,CAAC,CAAC;IACvF,MAAM,wBAAwB,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;IACzF,MAAM,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,gCAAgC,CAAC,EAAE,gCAAgC,CAAC,CAAC;IACjG,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-pre-tool-hook-template-bootstrap.test.d.ts","sourceRoot":"","sources":["../../src/services/codex-pre-tool-hook-template-bootstrap.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import { homedir, tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { afterEach, expect, it } from "vitest";
|
|
6
|
+
import { CODEX_HOOK_ACTIVATION } from "./codex-hook-activation.js";
|
|
7
|
+
import { CODEX_NATIVE_TOOL_AUTHORITY_HOOK } from "./codex-native-tool-authority-template.js";
|
|
8
|
+
import { CODEX_PRE_TOOL_HOOK } from "./codex-pre-tool-hook-template.js";
|
|
9
|
+
import { CODEX_PRE_TOOL_SUPPORT_HOOK } from "./codex-pre-tool-support-template.js";
|
|
10
|
+
import { writePreToolDependencies } from "./codex-pre-tool-dependencies.test-support.js";
|
|
11
|
+
const roots = [];
|
|
12
|
+
afterEach(async () => {
|
|
13
|
+
await Promise.all(roots.splice(0).map((root) => rm(root, { recursive: true, force: true })));
|
|
14
|
+
});
|
|
15
|
+
it("allows explicit acceptance arguments before Task capture without allowing writes", async () => {
|
|
16
|
+
const root = await mkdtemp(join(tmpdir(), "zaip-cli-bootstrap-hook-"));
|
|
17
|
+
roots.push(root);
|
|
18
|
+
await mkdir(join(root, ".agents", "config"), { recursive: true });
|
|
19
|
+
await writeFile(join(root, ".agents", "config", "project.yaml"), "zaip:\n enabled: true\ntracking:\n enabled: false\n");
|
|
20
|
+
const hooks = join(root, ".codex", "hooks");
|
|
21
|
+
await mkdir(hooks, { recursive: true });
|
|
22
|
+
await writeFile(join(hooks, "zaip-pre-tool-use.mjs"), CODEX_PRE_TOOL_HOOK);
|
|
23
|
+
await writeFile(join(hooks, "zaip-hook-activation.mjs"), CODEX_HOOK_ACTIVATION);
|
|
24
|
+
await writeFile(join(hooks, "zaip-pre-tool-support.mjs"), CODEX_PRE_TOOL_SUPPORT_HOOK);
|
|
25
|
+
await writePreToolDependencies((file, content) => writeFile(join(hooks, file), content));
|
|
26
|
+
await writeFile(join(hooks, "zaip-native-tool-authority.mjs"), CODEX_NATIVE_TOOL_AUTHORITY_HOOK);
|
|
27
|
+
const invoke = (cmd) => spawnSync(process.execPath, [join(hooks, "zaip-pre-tool-use.mjs")], {
|
|
28
|
+
cwd: root,
|
|
29
|
+
encoding: "utf8",
|
|
30
|
+
windowsHide: true,
|
|
31
|
+
env: { ...process.env, CODEX_THREAD_ID: "bootstrap-thread", CODEX_TURN_ID: "bootstrap-turn" },
|
|
32
|
+
input: JSON.stringify({
|
|
33
|
+
cwd: root,
|
|
34
|
+
session_id: "bootstrap-thread",
|
|
35
|
+
turn_id: "bootstrap-turn",
|
|
36
|
+
tool_use_id: "bootstrap-tool",
|
|
37
|
+
tool_name: "exec_command",
|
|
38
|
+
tool_input: { cmd },
|
|
39
|
+
}),
|
|
40
|
+
});
|
|
41
|
+
const result = invoke("node .agents/runtime/bin/zaip.mjs conversation start --intent new-work --acceptance AC-WORK-001-09 --json");
|
|
42
|
+
expect(result.status, result.stderr).toBe(0);
|
|
43
|
+
const output = JSON.parse(result.stdout).hookSpecificOutput;
|
|
44
|
+
expect(output.permissionDecision, result.stdout).toBe("allow");
|
|
45
|
+
expect(output.updatedInput.cmd).toContain("--codex-hook-id=");
|
|
46
|
+
for (const cmd of [
|
|
47
|
+
"ac src/a.ts payload",
|
|
48
|
+
"AC src/a.ts payload",
|
|
49
|
+
"(Set-Content -LiteralPath src/a.ts -Value code)",
|
|
50
|
+
"Write-Output (Set-Content -LiteralPath src/a.ts -Value code)",
|
|
51
|
+
"env cp src/a.ts src/b.ts",
|
|
52
|
+
"exec cp src/a.ts src/b.ts",
|
|
53
|
+
"FOO=1 cp src/a.ts src/b.ts",
|
|
54
|
+
"unknown-wrapper ac src/a.ts payload",
|
|
55
|
+
".\\echo.cmd ac src/a.ts payload",
|
|
56
|
+
".\\node.cmd .agents/runtime/bin/zaip.mjs conversation start --acceptance AC-WORK-001-09",
|
|
57
|
+
"echo.cmd ac src/a.ts payload",
|
|
58
|
+
"node.cmd .agents/runtime/bin/zaip.mjs conversation start --acceptance AC-WORK-001-09",
|
|
59
|
+
"node scripts/unknown.mjs --acceptance AC-WORK-001-09",
|
|
60
|
+
"command ac src/a.ts payload",
|
|
61
|
+
".\\sed.exe -i s/a/b/ src/a.ts",
|
|
62
|
+
".\\sed.exe -f script.sed src/input.ts",
|
|
63
|
+
"git apply patch.diff",
|
|
64
|
+
"node scripts/read.mjs --acceptance AC-WORK-001-09; ac src/a.ts payload",
|
|
65
|
+
"node scripts/read.mjs > src/a.ts",
|
|
66
|
+
]) {
|
|
67
|
+
const blocked = invoke(cmd);
|
|
68
|
+
expect(blocked.status, blocked.stderr).toBe(0);
|
|
69
|
+
expect(JSON.parse(blocked.stdout).hookSpecificOutput.permissionDecision).toBe("deny");
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
it("denies a configured project when the activation module is missing", async () => {
|
|
73
|
+
const root = await mkdtemp(join(tmpdir(), "zaip-cli-missing-activation-"));
|
|
74
|
+
roots.push(root);
|
|
75
|
+
await mkdir(join(root, ".agents", "config"), { recursive: true });
|
|
76
|
+
await writeFile(join(root, ".agents", "config", "project.yaml"), "zaip:\n enabled: true\n");
|
|
77
|
+
const hooks = join(root, ".codex", "hooks");
|
|
78
|
+
await mkdir(hooks, { recursive: true });
|
|
79
|
+
await writeFile(join(hooks, "zaip-pre-tool-use.mjs"), CODEX_PRE_TOOL_HOOK);
|
|
80
|
+
await writeFile(join(hooks, "zaip-pre-tool-support.mjs"), CODEX_PRE_TOOL_SUPPORT_HOOK);
|
|
81
|
+
await writePreToolDependencies((file, content) => writeFile(join(hooks, file), content));
|
|
82
|
+
await writeFile(join(hooks, "zaip-native-tool-authority.mjs"), CODEX_NATIVE_TOOL_AUTHORITY_HOOK);
|
|
83
|
+
const invoke = () => spawnSync(process.execPath, [join(hooks, "zaip-pre-tool-use.mjs")], {
|
|
84
|
+
cwd: root,
|
|
85
|
+
encoding: "utf8",
|
|
86
|
+
windowsHide: true,
|
|
87
|
+
input: JSON.stringify({
|
|
88
|
+
cwd: root,
|
|
89
|
+
tool_name: "apply_patch",
|
|
90
|
+
tool_input: { command: "*** Begin Patch\n*** Add File: src/code.ts\n+ok\n*** End Patch" },
|
|
91
|
+
}),
|
|
92
|
+
});
|
|
93
|
+
const result = invoke();
|
|
94
|
+
expect(result.status, result.stderr).toBe(0);
|
|
95
|
+
expect(JSON.parse(result.stdout).hookSpecificOutput).toMatchObject({
|
|
96
|
+
permissionDecision: "deny",
|
|
97
|
+
permissionDecisionReason: expect.stringContaining("activation module is unavailable"),
|
|
98
|
+
});
|
|
99
|
+
const config = join(root, ".agents", "config", "project.yaml");
|
|
100
|
+
await writeFile(config, "zaip:\n enabled: false\n");
|
|
101
|
+
expect(invoke().stdout).toBe("{}\n");
|
|
102
|
+
await writeFile(config, 'zaip:\n enabled: "false"\n');
|
|
103
|
+
expect(JSON.parse(invoke().stdout).hookSpecificOutput.permissionDecision).toBe("deny");
|
|
104
|
+
await rm(config);
|
|
105
|
+
expect(invoke().stdout).toBe("{}\n");
|
|
106
|
+
});
|
|
107
|
+
//# sourceMappingURL=codex-pre-tool-hook-template-bootstrap.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-pre-tool-hook-template-bootstrap.test.js","sourceRoot":"","sources":["../../src/services/codex-pre-tool-hook-template-bootstrap.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,gCAAgC,EAAE,MAAM,2CAA2C,CAAC;AAC7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AAEzF,MAAM,KAAK,GAAa,EAAE,CAAC;AAC3B,SAAS,CAAC,KAAK,IAAI,EAAE;IACnB,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAC/F,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,kFAAkF,EAAE,KAA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AC,MAAM,CAAC,CAAC;IACjB,MAAM,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACvC,CAAC,CAAC,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":"AAEA,eAAO,MAAM,mBAAmB,
|
|
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,QA+mB/B,CAAC"}
|