@dailephd/my-centcom 0.1.0 → 0.3.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.
Files changed (175) hide show
  1. package/README.md +10 -5
  2. package/apps/daemon/dist/artifacts/returnSnapshots.d.ts +12 -0
  3. package/apps/daemon/dist/artifacts/returnSnapshots.js +41 -0
  4. package/apps/daemon/dist/bootstrap/app.d.ts +21 -0
  5. package/apps/daemon/dist/bootstrap/app.js +27 -0
  6. package/apps/daemon/dist/bootstrap/installLayout.d.ts +81 -0
  7. package/apps/daemon/dist/bootstrap/installLayout.js +164 -0
  8. package/apps/daemon/dist/bootstrap/main.d.ts +14 -0
  9. package/apps/daemon/dist/bootstrap/main.js +141 -0
  10. package/apps/daemon/dist/bootstrap/operatorConsole.d.ts +75 -0
  11. package/apps/daemon/dist/bootstrap/operatorConsole.js +293 -0
  12. package/apps/daemon/dist/bootstrap/privateDataRoot.d.ts +38 -0
  13. package/apps/daemon/dist/bootstrap/privateDataRoot.js +204 -0
  14. package/apps/daemon/dist/bootstrap/secureMain.d.ts +118 -0
  15. package/apps/daemon/dist/bootstrap/secureMain.js +403 -0
  16. package/apps/daemon/dist/bootstrap/setup.d.ts +93 -0
  17. package/apps/daemon/dist/bootstrap/setup.js +738 -0
  18. package/apps/daemon/dist/context/changeProposal.d.ts +97 -0
  19. package/apps/daemon/dist/context/changeProposal.js +259 -0
  20. package/apps/daemon/dist/context/gitEvidence.d.ts +88 -0
  21. package/apps/daemon/dist/context/gitEvidence.js +332 -0
  22. package/apps/daemon/dist/context/gitObservation.d.ts +30 -0
  23. package/apps/daemon/dist/context/gitObservation.js +113 -0
  24. package/apps/daemon/dist/context/projectReadIssuer.d.ts +68 -0
  25. package/apps/daemon/dist/context/projectReadIssuer.js +158 -0
  26. package/apps/daemon/dist/context/projectReadService.d.ts +153 -0
  27. package/apps/daemon/dist/context/projectReadService.js +652 -0
  28. package/apps/daemon/dist/context/projectViewService.d.ts +85 -0
  29. package/apps/daemon/dist/context/projectViewService.js +332 -0
  30. package/apps/daemon/dist/context/proposalRecorder.d.ts +11 -0
  31. package/apps/daemon/dist/context/proposalRecorder.js +19 -0
  32. package/apps/daemon/dist/plugins/drivers/codexMcpConfig.d.ts +40 -0
  33. package/apps/daemon/dist/plugins/drivers/codexMcpConfig.js +73 -0
  34. package/apps/daemon/dist/plugins/drivers/codexModelCompatibility.d.ts +49 -0
  35. package/apps/daemon/dist/plugins/drivers/codexModelCompatibility.js +70 -0
  36. package/apps/daemon/dist/plugins/drivers/fakePluginDriver.d.ts +16 -0
  37. package/apps/daemon/dist/plugins/drivers/fakePluginDriver.js +115 -0
  38. package/apps/daemon/dist/plugins/drivers/finiteCliDriver.d.ts +153 -0
  39. package/apps/daemon/dist/plugins/drivers/finiteCliDriver.js +505 -0
  40. package/apps/daemon/dist/plugins/registry/operationCatalog.d.ts +23 -0
  41. package/apps/daemon/dist/plugins/registry/operationCatalog.js +41 -0
  42. package/apps/daemon/dist/plugins/registry/registryOperationCatalog.d.ts +14 -0
  43. package/apps/daemon/dist/plugins/registry/registryOperationCatalog.js +29 -0
  44. package/apps/daemon/dist/plugins/registry/verifiedCapabilityRegistry.d.ts +151 -0
  45. package/apps/daemon/dist/plugins/registry/verifiedCapabilityRegistry.js +579 -0
  46. package/apps/daemon/dist/projects/codingAuthority.d.ts +102 -0
  47. package/apps/daemon/dist/projects/codingAuthority.js +244 -0
  48. package/apps/daemon/dist/projects/fixtureAuthorization.d.ts +54 -0
  49. package/apps/daemon/dist/projects/fixtureAuthorization.js +172 -0
  50. package/apps/daemon/dist/projects/pairedAuthority.d.ts +158 -0
  51. package/apps/daemon/dist/projects/pairedAuthority.js +273 -0
  52. package/apps/daemon/dist/projects/trustedCliConsent.d.ts +47 -0
  53. package/apps/daemon/dist/projects/trustedCliConsent.js +84 -0
  54. package/apps/daemon/dist/runs/changeApplier.d.ts +59 -0
  55. package/apps/daemon/dist/runs/changeApplier.js +319 -0
  56. package/apps/daemon/dist/runs/codingWorkflowService.d.ts +283 -0
  57. package/apps/daemon/dist/runs/codingWorkflowService.js +785 -0
  58. package/apps/daemon/dist/runs/durableIntentCoordinator.d.ts +72 -0
  59. package/apps/daemon/dist/runs/durableIntentCoordinator.js +160 -0
  60. package/apps/daemon/dist/runs/inMemoryCoordinator.d.ts +55 -0
  61. package/apps/daemon/dist/runs/inMemoryCoordinator.js +375 -0
  62. package/apps/daemon/dist/runs/runExecutor.d.ts +154 -0
  63. package/apps/daemon/dist/runs/runExecutor.js +295 -0
  64. package/apps/daemon/dist/runs/workflowService.d.ts +185 -0
  65. package/apps/daemon/dist/runs/workflowService.js +300 -0
  66. package/apps/daemon/dist/runtime/boundedProcessHost.d.ts +111 -0
  67. package/apps/daemon/dist/runtime/boundedProcessHost.js +752 -0
  68. package/apps/daemon/dist/runtime/evidenceRedaction.d.ts +30 -0
  69. package/apps/daemon/dist/runtime/evidenceRedaction.js +79 -0
  70. package/apps/daemon/dist/runtime/executionDiagnostics.d.ts +134 -0
  71. package/apps/daemon/dist/runtime/executionDiagnostics.js +213 -0
  72. package/apps/daemon/dist/runtime/modelExecutionPolicy.d.ts +22 -0
  73. package/apps/daemon/dist/runtime/modelExecutionPolicy.js +19 -0
  74. package/apps/daemon/dist/runtime/mxcExecution.d.ts +12 -0
  75. package/apps/daemon/dist/runtime/mxcExecution.js +163 -0
  76. package/apps/daemon/dist/runtime/mxcIntegrity.d.ts +24 -0
  77. package/apps/daemon/dist/runtime/mxcIntegrity.js +81 -0
  78. package/apps/daemon/dist/runtime/mxcWorker.d.ts +2 -0
  79. package/apps/daemon/dist/runtime/mxcWorker.js +45 -0
  80. package/apps/daemon/dist/runtime/provisionedExecution.d.ts +150 -0
  81. package/apps/daemon/dist/runtime/provisionedExecution.js +653 -0
  82. package/apps/daemon/dist/runtime/testExecution.d.ts +76 -0
  83. package/apps/daemon/dist/runtime/testExecution.js +106 -0
  84. package/apps/daemon/dist/runtime/testProfiles.d.ts +10 -0
  85. package/apps/daemon/dist/runtime/testProfiles.js +4 -0
  86. package/apps/daemon/dist/runtime/trustedAgentStaging.d.ts +89 -0
  87. package/apps/daemon/dist/runtime/trustedAgentStaging.js +262 -0
  88. package/apps/daemon/dist/runtime/trustedCaBundle.d.ts +77 -0
  89. package/apps/daemon/dist/runtime/trustedCaBundle.js +125 -0
  90. package/apps/daemon/dist/runtime/windows/windowsJobSupervisor.d.ts +166 -0
  91. package/apps/daemon/dist/runtime/windows/windowsJobSupervisor.js +521 -0
  92. package/apps/daemon/dist/storage/diagnosticLog.d.ts +63 -0
  93. package/apps/daemon/dist/storage/diagnosticLog.js +136 -0
  94. package/apps/daemon/dist/storage/executionTelemetry.d.ts +63 -0
  95. package/apps/daemon/dist/storage/executionTelemetry.js +247 -0
  96. package/apps/daemon/dist/storage/protectedSecrets.d.ts +39 -0
  97. package/apps/daemon/dist/storage/protectedSecrets.js +106 -0
  98. package/apps/daemon/dist/storage/sqliteLedger.d.ts +786 -0
  99. package/apps/daemon/dist/storage/sqliteLedger.js +1303 -0
  100. package/apps/daemon/dist/transports/http/dispatch.d.ts +43 -0
  101. package/apps/daemon/dist/transports/http/dispatch.js +405 -0
  102. package/apps/daemon/dist/transports/http/secureRoutes.d.ts +40 -0
  103. package/apps/daemon/dist/transports/http/secureRoutes.js +332 -0
  104. package/apps/daemon/dist/transports/http/workflowRoutes.d.ts +41 -0
  105. package/apps/daemon/dist/transports/http/workflowRoutes.js +473 -0
  106. package/apps/daemon/dist/transports/mcp/localProjectReadServer.d.ts +182 -0
  107. package/apps/daemon/dist/transports/mcp/localProjectReadServer.js +221 -0
  108. package/apps/daemon/dist/transports/native/nativeHost.d.ts +24 -0
  109. package/apps/daemon/dist/transports/native/nativeHost.js +344 -0
  110. package/apps/daemon/package.json +24 -0
  111. package/apps/daemon/src/runtime/benign/referenceEcho.mjs +27 -0
  112. package/apps/daemon/src/runtime/windows/buildSupervisor.mjs +87 -0
  113. package/apps/daemon/src/runtime/windows/supervisorMain.cs +676 -0
  114. package/apps/extension/manifest.secure.json +25 -0
  115. package/apps/extension/scripts/build.mjs +173 -0
  116. package/apps/extension/src/background/secureWorker.ts +1595 -0
  117. package/apps/extension/src/background/serviceWorker.ts +892 -0
  118. package/apps/extension/src/content/captureSelection.ts +64 -0
  119. package/apps/extension/src/content/secureInsert.ts +207 -0
  120. package/apps/extension/src/probe/index.html +41 -0
  121. package/apps/extension/src/probe/main.ts +201 -0
  122. package/apps/extension/src/sidepanel/index.html +203 -0
  123. package/apps/extension/src/sidepanel/main.ts +903 -0
  124. package/package.json +19 -3
  125. package/packages/contracts/dist/artifacts.d.ts +66 -0
  126. package/packages/contracts/dist/artifacts.js +64 -0
  127. package/packages/contracts/dist/automation.d.ts +540 -0
  128. package/packages/contracts/dist/automation.js +191 -0
  129. package/packages/contracts/dist/browser.d.ts +251 -0
  130. package/packages/contracts/dist/browser.js +131 -0
  131. package/packages/contracts/dist/context.d.ts +71 -0
  132. package/packages/contracts/dist/context.js +73 -0
  133. package/packages/contracts/dist/diagnostics.d.ts +99 -0
  134. package/packages/contracts/dist/diagnostics.js +284 -0
  135. package/packages/contracts/dist/effects.d.ts +42 -0
  136. package/packages/contracts/dist/effects.js +42 -0
  137. package/packages/contracts/dist/errors.d.ts +75 -0
  138. package/packages/contracts/dist/errors.js +70 -0
  139. package/packages/contracts/dist/events.d.ts +50 -0
  140. package/packages/contracts/dist/events.js +34 -0
  141. package/packages/contracts/dist/executionDiagnostics.d.ts +212 -0
  142. package/packages/contracts/dist/executionDiagnostics.js +101 -0
  143. package/packages/contracts/dist/identity.d.ts +54 -0
  144. package/packages/contracts/dist/identity.js +40 -0
  145. package/packages/contracts/dist/index.d.ts +20 -0
  146. package/packages/contracts/dist/index.js +20 -0
  147. package/packages/contracts/dist/invocation.d.ts +90 -0
  148. package/packages/contracts/dist/invocation.js +77 -0
  149. package/packages/contracts/dist/lifecycle.d.ts +130 -0
  150. package/packages/contracts/dist/lifecycle.js +135 -0
  151. package/packages/contracts/dist/plugin.d.ts +214 -0
  152. package/packages/contracts/dist/plugin.js +117 -0
  153. package/packages/contracts/dist/projectRead.d.ts +205 -0
  154. package/packages/contracts/dist/projectRead.js +162 -0
  155. package/packages/contracts/dist/secure.d.ts +128 -0
  156. package/packages/contracts/dist/secure.js +99 -0
  157. package/packages/contracts/package.json +32 -0
  158. package/packages/contracts/src/artifacts.ts +83 -0
  159. package/packages/contracts/src/automation.ts +238 -0
  160. package/packages/contracts/src/browser.ts +164 -0
  161. package/packages/contracts/src/context.ts +91 -0
  162. package/packages/contracts/src/diagnostics.ts +318 -0
  163. package/packages/contracts/src/effects.ts +49 -0
  164. package/packages/contracts/src/errors.ts +83 -0
  165. package/packages/contracts/src/events.ts +46 -0
  166. package/packages/contracts/src/executionDiagnostics.ts +116 -0
  167. package/packages/contracts/src/identity.ts +68 -0
  168. package/packages/contracts/src/index.ts +20 -0
  169. package/packages/contracts/src/invocation.ts +96 -0
  170. package/packages/contracts/src/lifecycle.ts +169 -0
  171. package/packages/contracts/src/plugin.ts +174 -0
  172. package/packages/contracts/src/projectRead.ts +179 -0
  173. package/packages/contracts/src/secure.ts +136 -0
  174. package/provenance.json +179 -9
  175. package/source.zip +0 -0
@@ -0,0 +1,76 @@
1
+ import { type ProcessObserver } from './boundedProcessHost.js';
2
+ import type { WindowsJobSupervisor } from './windows/windowsJobSupervisor.js';
3
+ export { TEST_PROFILES, type TestProfile } from './testProfiles.js';
4
+ /**
5
+ * C06 CONTROLLED TEST EXECUTION (SW-080). A model, a proposal or a project file can REQUEST a reviewed test profile by id; none of them can create executable authority.
6
+ *
7
+ * - Profiles are CODE (testProfiles.ts). A profile fixes the executable name, the complete argument template and the timeout. There is no argument, flag, script path, working-directory
8
+ * or environment value that any caller can supply. Adding a profile is a code review.
9
+ * - The executable is the trusted composition's pinned interpreter; its SHA-256 is verified by the bounded process host before every launch (tampering => EXECUTABLE_DIGEST_MISMATCH).
10
+ * - The process is created by the restricted-identity supervisor (Low integrity, restricted token, Job-supervised tree). The workspace is granted READ-only to that identity by the
11
+ * trusted caller; only the task-owned TEMP directory is writable. Working-directory choice is NOT presented as confinement: the grant is.
12
+ * - A test process EXITING 0 is not a pass. The pass verdict is derived from the runner's own TAP summary: tests >= the independently required minimum, pass == tests, and
13
+ * zero fail / cancelled / skipped / todo. Every dimension is returned so that a caller can see exactly why a run did not pass.
14
+ */
15
+ export interface TestSummary {
16
+ tests: number;
17
+ pass: number;
18
+ fail: number;
19
+ cancelled: number;
20
+ skipped: number;
21
+ todo: number;
22
+ }
23
+ export interface TestRunResult {
24
+ readonly passed: boolean;
25
+ readonly reasons: readonly string[];
26
+ readonly outcome: string;
27
+ readonly exitCode: number | null;
28
+ readonly summary: TestSummary | null;
29
+ readonly stdoutSha256: string;
30
+ readonly durationMs: number;
31
+ readonly profileId: string;
32
+ readonly identity: string | null;
33
+ readonly treeTerminated: boolean | null;
34
+ }
35
+ /** Parses the TAP summary lines Node prints at the end of a run. null = no summary at all (a run that never reported cannot be a pass). */
36
+ export declare function parseTapSummary(stdout: string): TestSummary | null;
37
+ /** Decides pass/fail from the process facts AND the runner's own summary. Pure; exported so the rule itself can be attacked in tests. */
38
+ export declare function judgeTestRun(i: {
39
+ outcome: string;
40
+ exitCode: number | null;
41
+ summary: TestSummary | null;
42
+ expectedMinTests: number;
43
+ }): {
44
+ passed: boolean;
45
+ reasons: string[];
46
+ };
47
+ export interface TestExecutor {
48
+ readonly executionIdentity?: string;
49
+ cancel?(runId: string): Promise<boolean>;
50
+ /** SHA-256 of the pinned interpreter (verified again by the process host before every launch). */
51
+ executableSha256(): Promise<string>;
52
+ run(i: {
53
+ runId: string;
54
+ profileId: string;
55
+ workspaceRoot: string;
56
+ tempDir: string;
57
+ expectedMinTests: number;
58
+ observer?: ProcessObserver;
59
+ }): Promise<TestRunResult | {
60
+ readonly refused: string;
61
+ }>;
62
+ close(): Promise<void>;
63
+ }
64
+ export declare function createTestExecutor(cfg: {
65
+ nodeExecutablePath: string;
66
+ supervisor: WindowsJobSupervisor;
67
+ }): TestExecutor;
68
+ /**
69
+ * Trusted preparation of the restricted execution identity's access (Windows): READ + EXECUTE on the workspace (it can read the code under test and can change nothing there) and
70
+ * MODIFY (with a Low integrity label) on the single task-owned TEMP directory. This grant is the confinement; the working directory is not. Throws if the grant cannot be applied.
71
+ */
72
+ export declare function prepareRestrictedAccess(i: {
73
+ workspaceRoot: string;
74
+ tempDir: string;
75
+ }): void;
76
+ //# sourceMappingURL=testExecution.d.ts.map
@@ -0,0 +1,106 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { lstatSync, readFileSync, realpathSync } from 'node:fs';
3
+ import { basename, isAbsolute, join } from 'node:path';
4
+ import { execFileSync } from 'node:child_process';
5
+ import { createBoundedProcessHost } from './boundedProcessHost.js';
6
+ import { TEST_PROFILES } from './testProfiles.js';
7
+ export { TEST_PROFILES } from './testProfiles.js';
8
+ /** Parses the TAP summary lines Node prints at the end of a run. null = no summary at all (a run that never reported cannot be a pass). */
9
+ export function parseTapSummary(stdout) {
10
+ const pick = (k) => { const m = new RegExp('^# ' + k + ' (\\d+)\\s*$', 'm').exec(stdout); return m ? Number(m[1]) : undefined; };
11
+ const tests = pick('tests');
12
+ const pass = pick('pass');
13
+ const fail = pick('fail');
14
+ if (tests === undefined || pass === undefined || fail === undefined)
15
+ return null;
16
+ return { tests, pass, fail, cancelled: pick('cancelled') ?? 0, skipped: pick('skipped') ?? 0, todo: pick('todo') ?? 0 };
17
+ }
18
+ /** Decides pass/fail from the process facts AND the runner's own summary. Pure; exported so the rule itself can be attacked in tests. */
19
+ export function judgeTestRun(i) {
20
+ const reasons = [];
21
+ if (i.outcome !== 'EXITED')
22
+ reasons.push('PROCESS_' + i.outcome);
23
+ if (i.exitCode !== 0)
24
+ reasons.push('EXIT_CODE_NONZERO');
25
+ const s = i.summary;
26
+ if (!s)
27
+ reasons.push('NO_TEST_SUMMARY');
28
+ else {
29
+ if (s.tests < Math.max(1, i.expectedMinTests))
30
+ reasons.push('TOO_FEW_TESTS');
31
+ if (s.fail !== 0)
32
+ reasons.push('ASSERTIONS_FAILED');
33
+ if (s.cancelled !== 0)
34
+ reasons.push('TESTS_CANCELLED');
35
+ if (s.skipped !== 0)
36
+ reasons.push('TESTS_SKIPPED');
37
+ if (s.todo !== 0)
38
+ reasons.push('TESTS_TODO');
39
+ if (s.pass !== s.tests)
40
+ reasons.push('NOT_ALL_PASSED');
41
+ }
42
+ return { passed: reasons.length === 0, reasons };
43
+ }
44
+ const sha = (b) => createHash('sha256').update(b).digest('hex');
45
+ const fileShaSync = (p) => createHash('sha256').update(readFileSync(p)).digest('hex');
46
+ export function createTestExecutor(cfg) {
47
+ if (!isAbsolute(cfg.nodeExecutablePath))
48
+ throw new Error('TEST_EXECUTOR_CONFIG_INVALID');
49
+ const exe = realpathSync.native(cfg.nodeExecutablePath);
50
+ if (!lstatSync(exe).isFile())
51
+ throw new Error('TEST_EXECUTOR_CONFIG_INVALID');
52
+ const pinned = Promise.resolve(fileShaSync(exe)); // the trusted digest of the pinned interpreter, taken SYNCHRONOUSLY once at composition (an async read could observe a later tamper)
53
+ const hosts = [];
54
+ return Object.freeze({
55
+ executableSha256: () => pinned,
56
+ async run(i) {
57
+ const profile = TEST_PROFILES[i.profileId]; // an unknown id has no meaning; nothing is derived from it
58
+ if (!profile)
59
+ return { refused: 'PROFILE_UNKNOWN' };
60
+ if (basename(exe).toLowerCase() !== profile.executableName)
61
+ return { refused: 'EXECUTABLE_NOT_THE_PROFILES' };
62
+ const digest = await pinned;
63
+ const host = createBoundedProcessHost({
64
+ approvedProjectRoot: i.workspaceRoot, approvedExecutablePath: exe, approvedExecutableSha256: digest, supervisor: cfg.supervisor,
65
+ limits: { timeoutMs: profile.timeoutMs, maxStdoutBytes: 1_048_576, maxStderrBytes: 262_144, maxArgvBytes: 4096, maxArguments: 16 },
66
+ ...(i.observer ? { observer: i.observer } : {}),
67
+ });
68
+ hosts.push(host);
69
+ const env = { SystemRoot: process.env.SystemRoot ?? 'C:\\Windows', TEMP: i.tempDir, TMP: i.tempDir };
70
+ try {
71
+ const r = await host.run({ runId: i.runId, executablePath: exe, args: [...profile.args], cwd: i.workspaceRoot, environment: env });
72
+ const summary = parseTapSummary(r.stdoutUtf8);
73
+ const j = judgeTestRun({ outcome: r.outcome, exitCode: r.exitCode, summary, expectedMinTests: i.expectedMinTests });
74
+ return { passed: j.passed, reasons: j.reasons, outcome: r.outcome, exitCode: r.exitCode, summary, stdoutSha256: sha(r.stdoutUtf8), durationMs: r.durationMs, profileId: profile.id,
75
+ identity: r.supervision?.executionIdentity ?? null, treeTerminated: r.processTreeTerminated };
76
+ }
77
+ catch (e) {
78
+ return { refused: String(e.code ?? 'TEST_LAUNCH_REFUSED') };
79
+ }
80
+ finally {
81
+ try {
82
+ await host.close();
83
+ }
84
+ catch { /* closed */ }
85
+ }
86
+ },
87
+ async close() { for (const h of hosts.splice(0)) {
88
+ try {
89
+ await h.close();
90
+ }
91
+ catch { /* closed */ }
92
+ } },
93
+ });
94
+ }
95
+ /**
96
+ * Trusted preparation of the restricted execution identity's access (Windows): READ + EXECUTE on the workspace (it can read the code under test and can change nothing there) and
97
+ * MODIFY (with a Low integrity label) on the single task-owned TEMP directory. This grant is the confinement; the working directory is not. Throws if the grant cannot be applied.
98
+ */
99
+ export function prepareRestrictedAccess(i) {
100
+ const icacls = join(process.env.SystemRoot ?? 'C:\\Windows', 'System32', 'icacls.exe');
101
+ const run = (...a) => { execFileSync(icacls, a, { windowsHide: true, shell: false, stdio: 'ignore' }); };
102
+ run(i.workspaceRoot, '/grant', '*S-1-5-12:(OI)(CI)(RX)', '/T', '/C', '/Q');
103
+ run(i.tempDir, '/grant', '*S-1-5-12:(OI)(CI)(M)', '/Q');
104
+ run(i.tempDir, '/setintegritylevel', '(OI)(CI)L', '/Q');
105
+ }
106
+ //# sourceMappingURL=testExecution.js.map
@@ -0,0 +1,10 @@
1
+ /** C06's single fixed test-profile authority, shared by the host and trusted MXC broker. */
2
+ export interface TestProfile {
3
+ readonly id: string;
4
+ readonly description: string;
5
+ readonly executableName: string;
6
+ readonly args: readonly string[];
7
+ readonly timeoutMs: number;
8
+ }
9
+ export declare const TEST_PROFILES: Readonly<Record<string, TestProfile>>;
10
+ //# sourceMappingURL=testProfiles.d.ts.map
@@ -0,0 +1,4 @@
1
+ export const TEST_PROFILES = Object.freeze({
2
+ 'node-test-v1': Object.freeze({ id: 'node-test-v1', description: 'Node.js built-in test runner over the workspace, TAP summary', executableName: 'node.exe', args: Object.freeze(['--preserve-symlinks', '--preserve-symlinks-main', '--test', '--test-isolation=none', '--test-reporter=tap']), timeoutMs: 60_000 }),
3
+ });
4
+ //# sourceMappingURL=testProfiles.js.map
@@ -0,0 +1,89 @@
1
+ /**
2
+ * C06 trusted agent staging (SW-067). A vendor CLI that is installed under the user's profile cannot be read by the RESTRICTED_LOW_INTEGRITY identity, and a bare
3
+ * `codex.exe` is not the whole program: it starts sibling executables (a command runner, a sandbox helper, a code-mode host, ripgrep). This module therefore pins
4
+ * the WHOLE reviewed file set, not one file:
5
+ *
6
+ * - REVIEWED_AGENT_BUILDS lists every file (relative path, size, SHA-256) of one exact vendor build. The list was taken from the official npm package
7
+ * `@openai/codex@0.167.0-win32-x64` (registry integrity recorded below) and matches the installed copy byte for byte. Adding or changing a build is a code review.
8
+ * - stageAgentBuild() copies a SOURCE tree only if every reviewed file matches; it never overwrites an existing staged directory (a differing one is refused as
9
+ * tampered, not repaired), copies to a partial directory first and renames, marks the files read-only and grants the restricted identity READ+EXECUTE only.
10
+ * - verifyStagedTree() re-checks the exact file set (no missing, changed, extra or linked file). It is called at provisioning, at every daemon start and again
11
+ * right before every launch (without re-hashing the executable the registry already re-hashes), so a silently updated or modified tree can never run.
12
+ * A newer installed version simply does not match a reviewed build and is refused (STAGE_SOURCE_NOT_REVIEWED): updates are never silently equivalent to the pin.
13
+ */
14
+ export interface ReviewedFile {
15
+ readonly rel: string;
16
+ readonly bytes: number;
17
+ readonly sha256: string;
18
+ }
19
+ export interface ReviewedAgentBuild {
20
+ readonly id: string;
21
+ readonly version: string;
22
+ /** The registry-published integrity of the official package this list was taken from (provenance record; not re-checked offline). */
23
+ readonly npmPackage: string;
24
+ readonly npmIntegrity: string;
25
+ /** The entrypoint inside the staged directory (forward slashes). */
26
+ readonly entrypoint: string;
27
+ readonly files: readonly ReviewedFile[];
28
+ }
29
+ export declare const REVIEWED_AGENT_BUILDS: Readonly<Record<string, ReviewedAgentBuild>>;
30
+ export type StagingCode = 'BUILD_UNKNOWN' | 'STAGE_SOURCE_NOT_REVIEWED' | 'STAGED_TREE_MODIFIED' | 'STAGE_IO_FAILED' | 'STAGED_TREE_MISSING';
31
+ export declare class StagingError extends Error {
32
+ readonly code: StagingCode;
33
+ readonly detail?: string | undefined;
34
+ constructor(code: StagingCode, detail?: string | undefined);
35
+ }
36
+ export declare function sha256FileSync(path: string): string;
37
+ /** Checks one directory against a reviewed build. Returns the first problem (a fixed code plus the relative path), never file content. */
38
+ export declare function verifyTree(dir: string, build: ReviewedAgentBuild, o?: {
39
+ hashEntrypoint?: boolean;
40
+ exact?: boolean;
41
+ }): {
42
+ ok: true;
43
+ } | {
44
+ ok: false;
45
+ code: StagingCode;
46
+ detail: string;
47
+ };
48
+ /** The reviewed staging directory of one build under a staging root, and its entrypoint. Pure path arithmetic. */
49
+ export declare const stagedDirOf: (stagingRoot: string, buildId: string) => string;
50
+ export declare const stagedEntrypointOf: (stagingRoot: string, build: ReviewedAgentBuild) => string;
51
+ export declare function grantRestrictedReadExecute(dir: string): void;
52
+ /**
53
+ * Stages one reviewed build from `sourceDir` (the vendor directory that contains bin/, codex-path/, codex-resources/ ...) into `<stagingRoot>/<build.id>`.
54
+ * Returns the staged entrypoint. Idempotent: an existing directory is only ever verified, never changed.
55
+ */
56
+ export declare function stageAgentBuild(o: {
57
+ sourceDir: string;
58
+ stagingRoot: string;
59
+ buildId: string;
60
+ }): {
61
+ entrypoint: string;
62
+ dir: string;
63
+ reused: boolean;
64
+ };
65
+ export interface StagedProjectReadAdapter {
66
+ readonly dir: string;
67
+ readonly serverScript: string;
68
+ readonly files: ReadonlyArray<{
69
+ readonly path: string;
70
+ readonly sha256: string;
71
+ }>;
72
+ }
73
+ export declare function stageProjectReadAdapter(projectRoot: string): StagedProjectReadAdapter;
74
+ /** Grants the restricted identity READ+EXECUTE only on a daemon-owned directory (used for the capability descriptors directory). */
75
+ export declare function grantRestrictedReadOnly(dir: string): void;
76
+ export interface McpOnlyCatalogReview {
77
+ readonly slug: string; /** SHA-256 of the exact derived catalogue text */
78
+ readonly sha256: string; /** the ONLY fields changed from the vendor entry */
79
+ readonly overrides: Readonly<Record<string, unknown>>;
80
+ }
81
+ export declare const MCP_ONLY_CATALOGS: Readonly<Record<string, McpOnlyCatalogReview>>;
82
+ export interface StagedModelCatalog {
83
+ readonly path: string;
84
+ readonly sha256: string;
85
+ }
86
+ /** Pure: the reviewed catalogue text for a `codex debug models` output and a REVIEWED slug. Throws CATALOG_UNREVIEWED if the slug has no review, the entry is missing or the result is not the pinned digest. */
87
+ export declare function deriveMcpOnlyCatalog(debugModelsJson: string, slug: string): string;
88
+ export declare function stageMcpOnlyModelCatalog(projectRoot: string, codexExecutable: string, slug: string): StagedModelCatalog;
89
+ //# sourceMappingURL=trustedAgentStaging.d.ts.map
@@ -0,0 +1,262 @@
1
+ import { execFileSync } from 'node:child_process';
2
+ import { createHash } from 'node:crypto';
3
+ import { chmodSync, closeSync, copyFileSync, existsSync, lstatSync, mkdirSync, openSync, readdirSync, readFileSync, readSync, realpathSync, renameSync, rmSync, writeFileSync } from 'node:fs';
4
+ import { dirname, join, relative, sep } from 'node:path';
5
+ export const REVIEWED_AGENT_BUILDS = Object.freeze({
6
+ 'codex-0.167.0-win32-x64': Object.freeze({
7
+ id: 'codex-0.167.0-win32-x64',
8
+ version: '0.167.0',
9
+ npmPackage: '@openai/codex@0.167.0-win32-x64',
10
+ npmIntegrity: 'sha512-duPCBwflc8qhQdLekbL8fDYF646tW4gj0/l9BDnsVhEzoqm6OwxMAJXDFwSOLUUJPCmjBeM+eHYAx4fP/hwfjg==',
11
+ entrypoint: 'bin/codex.exe',
12
+ // The voice runtime of the package (codex-resources/voice) is deliberately NOT staged: the reviewed operation never uses it.
13
+ files: Object.freeze([
14
+ { rel: 'codex-package.json', bytes: 206, sha256: '1052a791252f14520d3b218c0d0b7a2555c24b4f7b8d60c5b4694c9b4c6787f1' },
15
+ { rel: 'bin/codex.exe', bytes: 369062704, sha256: 'edfdd48f8b458af0906e507b4cb05217b326c3d6e515e9f024e05e3b8d650f70' },
16
+ { rel: 'bin/codex-code-mode-host.exe', bytes: 80328496, sha256: '5acd42f62966dd4a498ebfe04c5cae4c4a644a342a65a21bb53f8f36235c3d35' },
17
+ { rel: 'codex-path/rg.exe', bytes: 4218880, sha256: '14231169855ec5205cf5a1b6f1db358ff4aed4247c86b69ce8aae647c77f6680' },
18
+ { rel: 'codex-resources/codex-command-runner.exe', bytes: 8946992, sha256: '798919649d3069dd6c16292d73f3a5e5239a69843bf4b7ca6e77f412ce6e0d82' },
19
+ { rel: 'codex-resources/codex-windows-sandbox-setup.exe', bytes: 19564848, sha256: '6c55bfe87b35de7842c8025c6a9c041f682fcc5a80d26095579b50b4fa4ba57e' },
20
+ ]),
21
+ }),
22
+ });
23
+ export class StagingError extends Error {
24
+ code;
25
+ detail;
26
+ constructor(code, detail) {
27
+ super(detail ? `${code}:${detail}` : code);
28
+ this.code = code;
29
+ this.detail = detail;
30
+ this.name = 'StagingError';
31
+ }
32
+ }
33
+ export function sha256FileSync(path) {
34
+ const h = createHash('sha256');
35
+ const fd = openSync(path, 'r');
36
+ try {
37
+ const buf = Buffer.allocUnsafe(4 * 1024 * 1024);
38
+ for (;;) {
39
+ const n = readSync(fd, buf, 0, buf.length, null);
40
+ if (n === 0)
41
+ break;
42
+ h.update(buf.subarray(0, n));
43
+ }
44
+ }
45
+ finally {
46
+ closeSync(fd);
47
+ }
48
+ return h.digest('hex');
49
+ }
50
+ function listFiles(dir) {
51
+ const out = [];
52
+ const walk = (d) => {
53
+ for (const e of readdirSync(d, { withFileTypes: true })) {
54
+ const p = join(d, e.name);
55
+ if (e.isDirectory())
56
+ walk(p);
57
+ else
58
+ out.push(relative(dir, p).split(sep).join('/'));
59
+ }
60
+ };
61
+ walk(dir);
62
+ return out.sort();
63
+ }
64
+ /** Checks one directory against a reviewed build. Returns the first problem (a fixed code plus the relative path), never file content. */
65
+ export function verifyTree(dir, build, o = {}) {
66
+ if (!existsSync(dir))
67
+ return { ok: false, code: 'STAGED_TREE_MISSING', detail: '.' };
68
+ const hashEntry = o.hashEntrypoint !== false;
69
+ if (o.exact !== false) {
70
+ let present;
71
+ try {
72
+ present = listFiles(dir);
73
+ }
74
+ catch {
75
+ return { ok: false, code: 'STAGE_IO_FAILED', detail: '.' };
76
+ }
77
+ const want = build.files.map((f) => f.rel).sort();
78
+ const extra = present.find((p) => !want.includes(p));
79
+ if (extra !== undefined)
80
+ return { ok: false, code: 'STAGED_TREE_MODIFIED', detail: `extra:${extra}` };
81
+ }
82
+ for (const f of build.files) {
83
+ const p = join(dir, ...f.rel.split('/'));
84
+ try {
85
+ const st = lstatSync(p);
86
+ if (!st.isFile() || st.isSymbolicLink() || st.size !== f.bytes)
87
+ return { ok: false, code: 'STAGED_TREE_MODIFIED', detail: f.rel };
88
+ if ((f.rel !== build.entrypoint || hashEntry) && sha256FileSync(p) !== f.sha256)
89
+ return { ok: false, code: 'STAGED_TREE_MODIFIED', detail: f.rel };
90
+ }
91
+ catch {
92
+ return { ok: false, code: 'STAGED_TREE_MODIFIED', detail: f.rel };
93
+ }
94
+ }
95
+ return { ok: true };
96
+ }
97
+ /** The reviewed staging directory of one build under a staging root, and its entrypoint. Pure path arithmetic. */
98
+ export const stagedDirOf = (stagingRoot, buildId) => join(stagingRoot, buildId);
99
+ export const stagedEntrypointOf = (stagingRoot, build) => join(stagedDirOf(stagingRoot, build.id), ...build.entrypoint.split('/'));
100
+ export function grantRestrictedReadExecute(dir) {
101
+ const sysRoot = process.env.SystemRoot;
102
+ if (typeof sysRoot !== 'string')
103
+ throw new StagingError('STAGE_IO_FAILED', 'SystemRoot');
104
+ // S-1-5-12 = RESTRICTED. READ + EXECUTE only: the restricted identity can run the tree and can never modify it.
105
+ execFileSync(join(sysRoot, 'System32', 'icacls.exe'), [dir, '/grant', '*S-1-5-12:(OI)(CI)(RX)'], { windowsHide: true, shell: false, stdio: 'ignore', timeout: 60_000 });
106
+ }
107
+ /**
108
+ * Stages one reviewed build from `sourceDir` (the vendor directory that contains bin/, codex-path/, codex-resources/ ...) into `<stagingRoot>/<build.id>`.
109
+ * Returns the staged entrypoint. Idempotent: an existing directory is only ever verified, never changed.
110
+ */
111
+ export function stageAgentBuild(o) {
112
+ const build = Object.prototype.hasOwnProperty.call(REVIEWED_AGENT_BUILDS, o.buildId) ? REVIEWED_AGENT_BUILDS[o.buildId] : undefined;
113
+ if (!build)
114
+ throw new StagingError('BUILD_UNKNOWN');
115
+ const dest = stagedDirOf(o.stagingRoot, build.id);
116
+ if (existsSync(dest)) {
117
+ const v = verifyTree(dest, build);
118
+ if (!v.ok)
119
+ throw new StagingError('STAGED_TREE_MODIFIED', v.detail);
120
+ return { entrypoint: stagedEntrypointOf(o.stagingRoot, build), dir: dest, reused: true };
121
+ }
122
+ const src = verifyTree(o.sourceDir, build, { exact: false });
123
+ if (!src.ok)
124
+ throw new StagingError('STAGE_SOURCE_NOT_REVIEWED', src.detail);
125
+ const partial = `${dest}.partial-${process.pid}`;
126
+ try {
127
+ rmSync(partial, { recursive: true, force: true });
128
+ for (const f of build.files) {
129
+ const to = join(partial, ...f.rel.split('/'));
130
+ mkdirSync(dirname(to), { recursive: true });
131
+ copyFileSync(join(o.sourceDir, ...f.rel.split('/')), to);
132
+ }
133
+ const copied = verifyTree(partial, build);
134
+ if (!copied.ok)
135
+ throw new StagingError('STAGED_TREE_MODIFIED', copied.detail);
136
+ for (const f of build.files)
137
+ chmodSync(join(partial, ...f.rel.split('/')), 0o444);
138
+ renameSync(partial, dest);
139
+ grantRestrictedReadExecute(dest);
140
+ }
141
+ catch (e) {
142
+ try {
143
+ rmSync(partial, { recursive: true, force: true });
144
+ }
145
+ catch { /* best effort; the partial name is task-owned */ }
146
+ if (e instanceof StagingError)
147
+ throw e;
148
+ throw new StagingError('STAGE_IO_FAILED');
149
+ }
150
+ return { entrypoint: realpathSync.native(stagedEntrypointOf(o.stagingRoot, build)), dir: realpathSync.native(dest), reused: false };
151
+ }
152
+ const SERVER_IMPORT = "from '../../context/projectReadService.js'";
153
+ export function stageProjectReadAdapter(projectRoot) {
154
+ const dist = join(projectRoot, 'apps', 'daemon', 'dist');
155
+ const server = readFileSync(join(dist, 'transports', 'mcp', 'localProjectReadServer.js'), 'utf8');
156
+ const service = readFileSync(join(dist, 'context', 'projectReadService.js'), 'utf8');
157
+ if (server.split(SERVER_IMPORT).length !== 2)
158
+ throw new Error('ADAPTER_IMPORT_UNEXPECTED');
159
+ const serverMjs = server.replace(SERVER_IMPORT, "from './projectReadService.mjs'")
160
+ .replace("from '../../context/changeProposal.js'", "from './changeProposal.mjs'")
161
+ .replace("from '../../context/proposalRecorder.js'", "from './proposalRecorder.mjs'");
162
+ const proposal = readFileSync(join(dist, 'context', 'changeProposal.js'), 'utf8').replace("from './projectReadService.js'", "from './projectReadService.mjs'");
163
+ const recorder = readFileSync(join(dist, 'context', 'proposalRecorder.js'), 'utf8');
164
+ if (/\bimport\b[^;]*from\s+['"](?!node:|\.\/(?:projectReadService|changeProposal|proposalRecorder)\.mjs)/.test(serverMjs) || /\bimport\b[^;]*from\s+['"](?!node:)/.test(service) || /\bimport\b[^;]*from\s+['"](?!node:|\.\/projectReadService\.mjs)/.test(proposal) || /\bimport\b[^;]*from\s+['"](?!node:)/.test(recorder))
165
+ throw new Error('ADAPTER_IMPORT_UNEXPECTED');
166
+ const sha = (t) => createHash('sha256').update(t, 'utf8').digest('hex');
167
+ const id = sha([serverMjs, service, proposal, recorder].map(sha).join('\0')).slice(0, 16);
168
+ const dir = join(projectRoot, '.switchyard-data', 'mcp-adapter', id);
169
+ const existed = existsSync(dir);
170
+ mkdirSync(dir, { recursive: true });
171
+ if (lstatSync(dir).isSymbolicLink())
172
+ throw new Error('ADAPTER_STAGE_LINK');
173
+ const real = realpathSync.native(dir);
174
+ const want = [['localProjectReadServer.mjs', serverMjs], ['projectReadService.mjs', service], ['changeProposal.mjs', proposal], ['proposalRecorder.mjs', recorder]];
175
+ if (existed && readdirSync(real).sort().join('|') !== want.map(([n]) => n).sort().join('|'))
176
+ throw new Error('ADAPTER_STAGE_TAMPERED');
177
+ for (const [name, text] of want) {
178
+ const f = join(real, name);
179
+ if (existsSync(f)) {
180
+ // never repair a differing staged file: a digest-named directory whose content differs was tampered with
181
+ if (lstatSync(f).isSymbolicLink() || sha(readFileSync(f, 'utf8')) !== sha(text))
182
+ throw new Error('ADAPTER_STAGE_TAMPERED');
183
+ }
184
+ else
185
+ writeFileSync(f, text, { encoding: 'utf8', flag: 'wx' });
186
+ }
187
+ if (readdirSync(real).sort().join('|') !== want.map(([n]) => n).sort().join('|'))
188
+ throw new Error('ADAPTER_STAGE_TAMPERED');
189
+ const sysRoot = process.env.SystemRoot ?? 'C:\Windows';
190
+ execFileSync(join(sysRoot, 'System32', 'icacls.exe'), [real, '/grant', '*S-1-5-12:(OI)(CI)(RX)'], { windowsHide: true, shell: false, stdio: 'ignore', timeout: 30_000 });
191
+ return { dir: real, serverScript: join(real, 'localProjectReadServer.mjs'), files: want.map(([n, t]) => ({ path: join(real, n), sha256: sha(t) })) };
192
+ }
193
+ /** Grants the restricted identity READ+EXECUTE only on a daemon-owned directory (used for the capability descriptors directory). */
194
+ export function grantRestrictedReadOnly(dir) {
195
+ const sysRoot = process.env.SystemRoot ?? 'C:\Windows';
196
+ execFileSync(join(sysRoot, 'System32', 'icacls.exe'), [dir, '/grant', '*S-1-5-12:(OI)(CI)(RX)'], { windowsHide: true, shell: false, stdio: 'ignore', timeout: 30_000 });
197
+ }
198
+ export const MCP_ONLY_CATALOGS = Object.freeze({
199
+ // SW-077: gpt-6.1-sol is a code-mode model: its vendor entry exposes a JavaScript exec tool and six collaboration/sub-agent tools that no feature flag removes. The reviewed derivation changes
200
+ // exactly five fields (asserted field by field against the vendor entry): tool_mode, multi_agent_version, apply_patch_tool_type, experimental_supported_tools, supports_search_tool.
201
+ 'gpt-6.1-sol': Object.freeze({
202
+ slug: 'gpt-6.1-sol', sha256: '945e04c6870dc51d89be0823cea417b091ed1c913e63dd095018230023ba1638',
203
+ overrides: Object.freeze({ apply_patch_tool_type: null, tool_mode: null, multi_agent_version: null, experimental_supported_tools: Object.freeze([]),
204
+ // SW-078 (measured with the real model): with supports_search_tool=true the MCP tools are DEFERRED behind tool_search. The real gpt-6.1-sol called tool_search in the Responses-lite wire format and Codex 0.167.0 answered
205
+ // "unsupported call: tool_searchtool_search_tool" (the lite call shape is not routed to the tool_search handler), so no MCP tool was ever reachable. With search disabled the three MCP tools are offered DIRECTLY and tool_search is not offered at all.
206
+ supports_search_tool: false }),
207
+ }),
208
+ });
209
+ const catalogCache = new Map();
210
+ /** Pure: the reviewed catalogue text for a `codex debug models` output and a REVIEWED slug. Throws CATALOG_UNREVIEWED if the slug has no review, the entry is missing or the result is not the pinned digest. */
211
+ export function deriveMcpOnlyCatalog(debugModelsJson, slug) {
212
+ const review = Object.prototype.hasOwnProperty.call(MCP_ONLY_CATALOGS, slug) ? MCP_ONLY_CATALOGS[slug] : undefined;
213
+ if (!review)
214
+ throw new Error('CATALOG_UNREVIEWED');
215
+ let entry;
216
+ try {
217
+ entry = (JSON.parse(debugModelsJson).models ?? []).find((m) => m.slug === slug);
218
+ }
219
+ catch {
220
+ entry = undefined;
221
+ }
222
+ if (!entry)
223
+ throw new Error('CATALOG_UNREVIEWED');
224
+ const text = JSON.stringify({ models: [{ ...entry, ...review.overrides }] });
225
+ if (createHash('sha256').update(text, 'utf8').digest('hex') !== review.sha256)
226
+ throw new Error('CATALOG_UNREVIEWED');
227
+ return text;
228
+ }
229
+ export function stageMcpOnlyModelCatalog(projectRoot, codexExecutable, slug) {
230
+ const review = Object.prototype.hasOwnProperty.call(MCP_ONLY_CATALOGS, slug) ? MCP_ONLY_CATALOGS[slug] : undefined;
231
+ if (!review)
232
+ throw new Error('CATALOG_UNREVIEWED');
233
+ const key = `${projectRoot}\0${codexExecutable}\0${slug}`.toLowerCase();
234
+ const cached = catalogCache.get(key);
235
+ if (cached && existsSync(cached.path))
236
+ return cached;
237
+ const base = join(projectRoot, '.switchyard-data', 'mcp-adapter');
238
+ const home = join(base, '.catalog-home');
239
+ mkdirSync(home, { recursive: true });
240
+ const sysRoot = process.env.SystemRoot ?? 'C:\Windows';
241
+ const out = execFileSync(codexExecutable, ['debug', 'models'], { env: { SystemRoot: sysRoot, CODEX_HOME: home }, windowsHide: true, shell: false, timeout: 30_000, maxBuffer: 16 * 1024 * 1024, stdio: ['ignore', 'pipe', 'ignore'] }).toString('utf8');
242
+ const text = deriveMcpOnlyCatalog(out, slug);
243
+ const dir = join(base, `catalog-${review.sha256.slice(0, 16)}`);
244
+ mkdirSync(dir, { recursive: true });
245
+ if (lstatSync(dir).isSymbolicLink())
246
+ throw new Error('CATALOG_STAGE_LINK');
247
+ const real = realpathSync.native(dir);
248
+ const f = join(real, 'models.json');
249
+ if (existsSync(f)) {
250
+ if (lstatSync(f).isSymbolicLink() || readFileSync(f, 'utf8') !== text)
251
+ throw new Error('CATALOG_STAGE_TAMPERED');
252
+ }
253
+ else
254
+ writeFileSync(f, text, { encoding: 'utf8', flag: 'wx' });
255
+ if (readdirSync(real).join('|') !== 'models.json')
256
+ throw new Error('CATALOG_STAGE_TAMPERED');
257
+ execFileSync(join(sysRoot, 'System32', 'icacls.exe'), [real, '/grant', '*S-1-5-12:(OI)(CI)(RX)'], { windowsHide: true, shell: false, stdio: 'ignore', timeout: 30_000 });
258
+ const staged = { path: f, sha256: review.sha256 };
259
+ catalogCache.set(key, staged);
260
+ return staged;
261
+ }
262
+ //# sourceMappingURL=trustedAgentStaging.js.map
@@ -0,0 +1,77 @@
1
+ /**
2
+ * C06 trusted CA bundle (SW-069). The restricted Windows identity cannot use the Windows certificate verifier that Codex normally relies on (measured in SW-068: Codex's own
3
+ * `doctor` fails TLS validation as the restricted identity and passes for the normal user). The Planner-selected trust source is the Mozilla root store that is BUNDLED INSIDE a
4
+ * verified Node.js release (`tls.rootCertificates`): it is written once to an immutable PEM file, pinned by SHA-256, and handed to the Codex adapter as CODEX_CA_CERTIFICATE.
5
+ *
6
+ * What this is and is not (measured, see the SW-069 report):
7
+ * - Codex ADDS these roots to the trust it already has; a bundle containing only a private test CA still validated public hosts for the normal user. It is therefore NOT an
8
+ * exclusive trust set and NOT an endpoint restriction: it widens trust by exactly the pinned roots, which is why the file is pinned and never regenerated silently.
9
+ * - It does not disable verification: untrusted CAs, expired leaves, wrong host names and incomplete chains still fail with the bundle configured.
10
+ * - Never regenerated silently: staging recomputes the PEM from the RUNNING Node and refuses unless Node's version, executable digest AND the PEM digest equal the reviewed entry.
11
+ * A Node update therefore needs a reviewed new entry (code change), exactly like a Codex update.
12
+ * - Updating: add a REVIEWED_CA_BUNDLES entry for the new Node release (verify the release against nodejs.org SHASUMS256 and its Authenticode signature), then
13
+ * \`npm run centcom -- stage-ca\`. The old staged directory is left in place (immutable); the profile names the entry it requires.
14
+ * - Expiry: roots are reported, not enforced: the bundle's earliest NotAfter is recorded in launch evidence; an expired root is inert (it can never validate a chain).
15
+ */
16
+ export interface ReviewedCaBundle {
17
+ readonly id: string;
18
+ readonly origin: string;
19
+ readonly generation: string;
20
+ readonly nodeVersion: string;
21
+ /** SHA-256 of the official node.exe of that release (identical to the node.exe inside node-v24.20.0-win-x64.zip, whose zip digest equals nodejs.org SHASUMS256.txt). */
22
+ readonly nodeExeSha256: string;
23
+ readonly certCount: number;
24
+ readonly pemBytes: number;
25
+ readonly pemSha256: string;
26
+ readonly earliestNotAfter: string;
27
+ }
28
+ export declare const REVIEWED_CA_BUNDLES: Readonly<Record<string, ReviewedCaBundle>>;
29
+ export type CaBundleCode = 'CA_BUNDLE_UNKNOWN' | 'CA_BUNDLE_MISSING' | 'CA_BUNDLE_UNREADABLE' | 'CA_BUNDLE_MODIFIED' | 'CA_BUNDLE_MALFORMED' | 'CA_SOURCE_NOT_REVIEWED' | 'CA_STAGE_IO_FAILED';
30
+ export declare class CaBundleError extends Error {
31
+ readonly code: CaBundleCode;
32
+ readonly detail?: string | undefined;
33
+ constructor(code: CaBundleCode, detail?: string | undefined);
34
+ }
35
+ export interface PemInspection {
36
+ count: number;
37
+ unparseable: number;
38
+ expired: number;
39
+ notYetValid: number;
40
+ earliestNotAfter: string | null;
41
+ }
42
+ /** Parses every certificate block of a PEM text with the platform X.509 parser. Pure. */
43
+ export declare function inspectPem(pem: string, nowMs?: number): PemInspection;
44
+ /** The PEM the RUNNING Node would produce, with the identity of that Node. */
45
+ export declare function generateMozillaPemFromRunningNode(): {
46
+ pem: string;
47
+ nodeVersion: string;
48
+ nodeExeSha256: string;
49
+ certCount: number;
50
+ };
51
+ export type CaVerification = {
52
+ ok: true;
53
+ certCount: number;
54
+ expiredCount: number;
55
+ earliestNotAfter: string | null;
56
+ } | {
57
+ ok: false;
58
+ code: CaBundleCode;
59
+ detail: string;
60
+ };
61
+ /** Fail-closed verification of one PEM file against a reviewed entry: present, regular, not linked, readable, exact digest and size, every block a parseable certificate. */
62
+ export declare function verifyCaBundleFile(path: string, entry: ReviewedCaBundle, nowMs?: number): CaVerification;
63
+ export declare const stagedCaDirOf: (stagingRoot: string, entry: ReviewedCaBundle) => string;
64
+ export declare const stagedCaFileOf: (stagingRoot: string, entry: ReviewedCaBundle) => string;
65
+ /**
66
+ * Stages the reviewed bundle from the RUNNING Node. Refuses (writes nothing) unless the running Node is exactly the reviewed release and its PEM is exactly the reviewed digest.
67
+ * Idempotent: an existing staged file is only verified, never rewritten; a differing one is refused as tampered.
68
+ */
69
+ export declare function stageCaBundle(o: {
70
+ stagingRoot: string;
71
+ id: string;
72
+ }): {
73
+ path: string;
74
+ reused: boolean;
75
+ certCount: number;
76
+ };
77
+ //# sourceMappingURL=trustedCaBundle.d.ts.map