@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,163 @@
1
+ import { lstatSync, readFileSync, readdirSync } from 'node:fs';
2
+ import { dirname, join } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { StringDecoder } from 'node:string_decoder';
5
+ import { createBoundedProcessHost } from './boundedProcessHost.js';
6
+ import { canonical, hash, inside, verifyMxcRuntime, MXC_PINS } from './mxcIntegrity.js';
7
+ import { judgeTestRun, parseTapSummary, TEST_PROFILES } from './testExecution.js';
8
+ /** C06 adapter; production readiness is deliberately absent. A caller cannot
9
+ * choose an executable/argv/network rule. The existing host/supervisor owns the
10
+ * broker tree; MXC owns the inner PSEC. No restricted-token fallback. */
11
+ export function createMxcTestExecutor(cfg) {
12
+ const broker = join(dirname(fileURLToPath(import.meta.url)), 'mxcWorker.js');
13
+ const closure = ['mxcWorker.js', 'mxcIntegrity.js', 'testProfiles.js'].map(n => ({ path: join(dirname(broker), n), sha: hash(readFileSync(join(dirname(broker), n))) }));
14
+ const hosts = new Map();
15
+ const seen = new Set();
16
+ let closed = false;
17
+ // CALLER_TOKEN applies to this trusted broker, NEVER to project code.
18
+ if (cfg.supervisor.executionIdentity !== 'CALLER_TOKEN')
19
+ throw new Error('MXC_SUPERVISOR_INVALID');
20
+ const checkSource = (dir) => {
21
+ let files = 0, bytes = 0;
22
+ const walk = (current, depth) => {
23
+ if (depth > 32)
24
+ throw new Error('MXC_SOURCE_LIMIT');
25
+ for (const n of readdirSync(current)) {
26
+ if (n === '.git')
27
+ continue;
28
+ if (++files > 4096)
29
+ throw new Error('MXC_SOURCE_LIMIT');
30
+ const p = join(current, n), s = lstatSync(p);
31
+ if (s.isSymbolicLink() || (!s.isDirectory() && s.nlink !== 1))
32
+ throw new Error('MXC_PATH_UNREVIEWED');
33
+ if (s.isDirectory())
34
+ walk(p, depth + 1);
35
+ else if ((bytes += s.size) > 128 * 1024 * 1024)
36
+ throw new Error('MXC_SOURCE_LIMIT');
37
+ }
38
+ };
39
+ walk(dir, 0);
40
+ };
41
+ return {
42
+ executionIdentity: 'MXC_PROCESS_CONTAINER_SYNTHETIC',
43
+ executableSha256: async () => MXC_PINS.nodeSha256,
44
+ async run(i) {
45
+ if (!cfg.syntheticWorkspaceBoundary)
46
+ return { refused: 'TEST_BOUNDARY_UNVERIFIED' };
47
+ if (closed)
48
+ return { refused: 'HOST_CLOSED' };
49
+ if (!i.observer)
50
+ return { refused: 'TELEMETRY_UNAVAILABLE' };
51
+ if (Object.keys(i).some(k => !['runId', 'profileId', 'workspaceRoot', 'tempDir', 'expectedMinTests', 'observer'].includes(k)))
52
+ return { refused: 'MXC_REQUEST_INVALID' };
53
+ if (!Number.isSafeInteger(i.expectedMinTests) || i.expectedMinTests < 1)
54
+ return { refused: 'MXC_REQUEST_INVALID' };
55
+ const profile = TEST_PROFILES[i.profileId];
56
+ if (!profile)
57
+ return { refused: 'PROFILE_UNKNOWN' };
58
+ if (seen.has(i.runId))
59
+ return { refused: 'DUPLICATE_RUN_ID' };
60
+ seen.add(i.runId);
61
+ try {
62
+ if (!inside(cfg.syntheticWorkspaceBoundary, i.workspaceRoot) || !inside(cfg.tempBoundary, i.tempDir))
63
+ throw new Error('MXC_PATH_UNREVIEWED');
64
+ checkSource(i.workspaceRoot);
65
+ const runtime = verifyMxcRuntime(cfg.projectRoot);
66
+ for (const f of closure)
67
+ if (hash(readFileSync(canonical(f.path))) !== f.sha)
68
+ throw new Error('MXC_BROKER_INTEGRITY');
69
+ let buffer = '', stdout = '', stderr = '', attested = false, started = false, terminal, error = '', protocol = false;
70
+ let outputLimited = false;
71
+ const byteCounts = { stdout: 0, stderr: 0 };
72
+ const decoders = { stdout: new StringDecoder('utf8'), stderr: new StringDecoder('utf8') };
73
+ const observer = {
74
+ lifecycle: (s, d) => i.observer.lifecycle(s, d),
75
+ chunk: (stream, bytes) => {
76
+ if (stream === 'stderr') {
77
+ stderr += Buffer.from(bytes).toString('utf8');
78
+ i.observer.chunk(stream, bytes);
79
+ return;
80
+ }
81
+ buffer += Buffer.from(bytes).toString('utf8');
82
+ let nl;
83
+ while ((nl = buffer.indexOf('\n')) >= 0) {
84
+ const line = buffer.slice(0, nl);
85
+ buffer = buffer.slice(nl + 1);
86
+ try {
87
+ const f = JSON.parse(line);
88
+ if (terminal || error)
89
+ throw new Error('order');
90
+ if (f.kind === 'attestation' && !attested && f.value.tier === 'base-container' && f.value.runtime === runtime.fingerprint && f.value.profile === profile.id && f.value.mode === 'OFFLINE_SYNTHETIC_ONLY') {
91
+ attested = true;
92
+ i.observer.lifecycle('MXC_POLICY_ATTESTED', { tier: f.value.tier, policy: f.value.policy, synthetic: true });
93
+ }
94
+ else if (f.kind === 'started' && attested && !started && Number.isInteger(f.value.pid)) {
95
+ started = true;
96
+ i.observer.lifecycle('MXC_CHILD_STARTED', { pid: f.value.pid });
97
+ }
98
+ else if ((f.kind === 'stdout' || f.kind === 'stderr') && started && typeof f.value === 'string') {
99
+ const b = Buffer.from(f.value, 'base64');
100
+ byteCounts[f.kind] += b.length;
101
+ if (byteCounts[f.kind] > (f.kind === 'stdout' ? 1_048_576 : 262144)) {
102
+ outputLimited = true;
103
+ i.observer.lifecycle('FAILED_MXC_OUTPUT_LIMIT', { stream: f.kind });
104
+ void hosts.get(i.runId)?.cancel(i.runId);
105
+ continue;
106
+ }
107
+ if (f.kind === 'stdout')
108
+ stdout += decoders.stdout.write(b);
109
+ else
110
+ stderr += decoders.stderr.write(b);
111
+ i.observer.chunk(f.kind, b);
112
+ }
113
+ else if (f.kind === 'exit' && started && Number.isInteger(f.value.exitCode) && typeof f.value.timedOut === 'boolean') {
114
+ stdout += decoders.stdout.end();
115
+ stderr += decoders.stderr.end();
116
+ terminal = f.value;
117
+ }
118
+ else if (f.kind === 'error' && typeof f.value.code === 'string')
119
+ error = f.value.code;
120
+ else
121
+ throw new Error('frame');
122
+ }
123
+ catch {
124
+ protocol = true;
125
+ }
126
+ }
127
+ },
128
+ };
129
+ // The privileged broker never starts in project-controlled storage
130
+ // (including Windows DLL-search cwd). Only the inner PSEC child uses it.
131
+ const brokerRoot = canonical(cfg.projectRoot); // trusted application checkout, with the host's required Git root marker
132
+ const host = createBoundedProcessHost({ approvedProjectRoot: brokerRoot, approvedExecutablePath: runtime.node, approvedExecutableSha256: MXC_PINS.nodeSha256, supervisor: cfg.supervisor, stdin: { maxBytes: 16000 }, observer,
133
+ limits: { timeoutMs: profile.timeoutMs, maxStdoutBytes: 1_048_576, maxStderrBytes: 262144, maxArguments: 8, maxArgvBytes: 4096 } });
134
+ hosts.set(i.runId, host);
135
+ const result = await host.run({ runId: i.runId, executablePath: runtime.node, args: [broker], cwd: brokerRoot, environment: { SystemRoot: process.env.SystemRoot, TEMP: i.tempDir, TMP: i.tempDir },
136
+ stdinUtf8: JSON.stringify({ projectRoot: canonical(cfg.projectRoot), workspaceRoot: canonical(i.workspaceRoot), tempDir: canonical(i.tempDir), workspaceBoundary: canonical(cfg.syntheticWorkspaceBoundary), tempBoundary: canonical(cfg.tempBoundary), profileId: profile.id }) });
137
+ if (error)
138
+ return { refused: error };
139
+ const outcome = outputLimited ? 'OUTPUT_LIMIT_EXCEEDED' : result.outcome === 'EXITED' && terminal?.timedOut ? 'TIMEOUT' : result.outcome;
140
+ const summary = parseTapSummary(stdout), judged = judgeTestRun({ outcome, exitCode: terminal?.exitCode ?? result.exitCode, summary, expectedMinTests: i.expectedMinTests });
141
+ const reasons = [...judged.reasons];
142
+ if (!attested || !started || !terminal || protocol || buffer.length || result.exitCode !== 0)
143
+ reasons.push('MXC_PROTOCOL_INCOMPLETE');
144
+ if (result.processTreeTerminated !== true)
145
+ reasons.push('TREE_UNCONFIRMED');
146
+ return { passed: reasons.length === 0, reasons, outcome, exitCode: terminal?.exitCode ?? result.exitCode, summary, stdoutSha256: hash(stdout), durationMs: result.durationMs, profileId: profile.id, identity: attested ? 'MXC_PROCESS_CONTAINER_SYNTHETIC' : null, treeTerminated: result.processTreeTerminated };
147
+ }
148
+ catch (e) {
149
+ return { refused: e instanceof Error ? ('code' in e ? e.code : e.message) : 'MXC_LAUNCH_REFUSED' };
150
+ }
151
+ finally {
152
+ const host = hosts.get(i.runId);
153
+ if (host) {
154
+ await host.close();
155
+ hosts.delete(i.runId);
156
+ }
157
+ }
158
+ },
159
+ cancel: async (runId) => await hosts.get(runId)?.cancel(runId) ?? false,
160
+ async close() { closed = true; await Promise.all([...hosts.values()].map(h => h.close())); hosts.clear(); },
161
+ };
162
+ }
163
+ //# sourceMappingURL=mxcExecution.js.map
@@ -0,0 +1,24 @@
1
+ export declare const MXC_PINS: Readonly<{
2
+ sdk: "1.0.1";
3
+ node: "24.21.0";
4
+ tree: "d27480614e123ad475b8259b378233d6b75bd6200f3252d61c30d9fd8be61213";
5
+ nodeSha256: "ba4e6d110e8c1592a1ecd390f6b05f3da124b13871a5be62b341a07a853c6c32";
6
+ nativeSha256: "bd45522f06dc9cc8001dcd5d7320bc2bf303fb08a39bf10f3404bd9a8001812c";
7
+ }>;
8
+ export declare const hash: (b: string | Uint8Array) => string;
9
+ export declare function canonical(p: string): string;
10
+ export declare function inside(base: string, p: string): boolean;
11
+ export declare function tree(dir: string): {
12
+ path: string;
13
+ bytes: number;
14
+ sha256: string;
15
+ }[];
16
+ export declare function verifyMxcRuntime(projectRoot: string): {
17
+ node: string;
18
+ sdk: string;
19
+ fingerprint: string;
20
+ };
21
+ /** Explicit immutable source binding for trusted offline fixture composition.
22
+ * Git internals are never exported to the MXC test policy. */
23
+ export declare function syntheticSourceFingerprint(dir: string): string;
24
+ //# sourceMappingURL=mxcIntegrity.d.ts.map
@@ -0,0 +1,81 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { lstatSync, readdirSync, readFileSync, realpathSync } from 'node:fs';
3
+ import { isAbsolute, join, normalize, relative, sep } from 'node:path';
4
+ // Reviewed SW-087 official archives, registry signatures, Node release signature
5
+ // and Microsoft native signatures. Never derive a trusted digest from a request.
6
+ export const MXC_PINS = Object.freeze({ sdk: '1.0.1', node: '24.21.0',
7
+ tree: 'd27480614e123ad475b8259b378233d6b75bd6200f3252d61c30d9fd8be61213',
8
+ nodeSha256: 'ba4e6d110e8c1592a1ecd390f6b05f3da124b13871a5be62b341a07a853c6c32',
9
+ nativeSha256: 'bd45522f06dc9cc8001dcd5d7320bc2bf303fb08a39bf10f3404bd9a8001812c',
10
+ });
11
+ export const hash = (b) => createHash('sha256').update(b).digest('hex');
12
+ export function canonical(p) {
13
+ if (!isAbsolute(p) || /[\u0000-\u001f"\r\n]/.test(p) || p.split(/[\\/]/).some(s => s === '..' || s === '.'))
14
+ throw new Error('MXC_PATH_UNREVIEWED');
15
+ const s = lstatSync(p), r = realpathSync.native(p);
16
+ if (s.isSymbolicLink() || r.toLowerCase() !== normalize(p).toLowerCase())
17
+ throw new Error('MXC_PATH_UNREVIEWED');
18
+ return r;
19
+ }
20
+ export function inside(base, p) {
21
+ const r = relative(canonical(base), canonical(p));
22
+ return r !== '' && r !== '..' && !r.startsWith('..' + sep) && !isAbsolute(r);
23
+ }
24
+ export function tree(dir) {
25
+ const entries = [];
26
+ const walk = (p) => {
27
+ for (const n of readdirSync(p).sort()) {
28
+ const f = join(p, n), s = lstatSync(f);
29
+ if (s.isSymbolicLink() || (!s.isDirectory() && s.nlink !== 1))
30
+ throw new Error('MXC_PATH_UNREVIEWED');
31
+ if (s.isDirectory())
32
+ walk(f);
33
+ else if (s.isFile())
34
+ entries.push({ path: relative(dir, f).replaceAll('\\', '/'), bytes: s.size, sha256: hash(readFileSync(f)) });
35
+ }
36
+ };
37
+ walk(dir);
38
+ return entries;
39
+ }
40
+ export function verifyMxcRuntime(projectRoot) {
41
+ try {
42
+ const root = canonical(projectRoot), tools = join(root, '.switchyard-dev', 'tools', 'sw087');
43
+ canonical(tools);
44
+ const node = canonical(join(tools, 'node-v24.21.0-win-x64', 'node.exe'));
45
+ if (hash(readFileSync(node)) !== MXC_PINS.nodeSha256)
46
+ throw new Error('MXC_RUNTIME_INTEGRITY');
47
+ const native = canonical(join(tools, 'sdk', 'package', 'bin', 'x64', 'mxc_ffi.dll'));
48
+ if (hash(readFileSync(native)) !== MXC_PINS.nativeSha256)
49
+ throw new Error('MXC_PAYLOAD_INTEGRITY');
50
+ const sdk = canonical(join(tools, 'sdk', 'package', 'dist', 'v1', 'index.js'));
51
+ if (hash(JSON.stringify(tree(tools))) !== MXC_PINS.tree)
52
+ throw new Error('MXC_PAYLOAD_INTEGRITY');
53
+ return { node, sdk, fingerprint: hash(JSON.stringify(MXC_PINS)) };
54
+ }
55
+ catch (e) {
56
+ if (e && typeof e === 'object' && 'code' in e && ['ENOENT', 'ENOTDIR'].includes(String(e.code)))
57
+ throw new Error('MXC_DEPENDENCY_MISSING');
58
+ throw e;
59
+ }
60
+ }
61
+ /** Explicit immutable source binding for trusted offline fixture composition.
62
+ * Git internals are never exported to the MXC test policy. */
63
+ export function syntheticSourceFingerprint(dir) {
64
+ const entries = [];
65
+ const walk = (p) => {
66
+ for (const n of readdirSync(p).sort()) {
67
+ if (n === '.git')
68
+ continue;
69
+ const f = join(p, n), s = lstatSync(f);
70
+ if (s.isSymbolicLink() || (!s.isDirectory() && s.nlink !== 1))
71
+ throw new Error('MXC_PATH_UNREVIEWED');
72
+ if (s.isDirectory())
73
+ walk(f);
74
+ else
75
+ entries.push({ path: relative(dir, f).replaceAll('\\', '/'), sha256: hash(readFileSync(f)) });
76
+ }
77
+ };
78
+ walk(canonical(dir));
79
+ return hash(JSON.stringify(entries));
80
+ }
81
+ //# sourceMappingURL=mxcIntegrity.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=mxcWorker.d.ts.map
@@ -0,0 +1,45 @@
1
+ // Trusted fixed-profile broker, launched ONLY by C06's existing pinned Windows
2
+ // Job supervisor. Its child is untrusted; its stdout cannot write broker frames.
3
+ import { readFileSync } from 'node:fs';
4
+ import { join } from 'node:path';
5
+ import { pathToFileURL } from 'node:url';
6
+ import { canonical, hash, inside, verifyMxcRuntime, MXC_PINS } from './mxcIntegrity.js';
7
+ import { TEST_PROFILES } from './testProfiles.js';
8
+ const emit = (kind, value) => { process.stdout.write(JSON.stringify({ kind, value }) + '\n'); };
9
+ async function main() {
10
+ const input = readFileSync(0, 'utf8');
11
+ if (Buffer.byteLength(input) > 16000)
12
+ throw new Error('MXC_REQUEST_INVALID');
13
+ const i = JSON.parse(input);
14
+ const keys = ['projectRoot', 'workspaceRoot', 'tempDir', 'workspaceBoundary', 'tempBoundary', 'profileId'];
15
+ if (Object.keys(i).length !== keys.length || keys.some(k => typeof i[k] !== 'string'))
16
+ throw new Error('MXC_REQUEST_INVALID');
17
+ const profile = TEST_PROFILES[i.profileId];
18
+ if (!profile)
19
+ throw new Error('PROFILE_UNKNOWN');
20
+ if (!inside(i.workspaceBoundary, i.workspaceRoot) || !inside(i.tempBoundary, i.tempDir))
21
+ throw new Error('MXC_PATH_UNREVIEWED');
22
+ const runtime = verifyMxcRuntime(i.projectRoot);
23
+ if (process.execPath.toLowerCase() !== runtime.node.toLowerCase() || process.versions.node !== MXC_PINS.node)
24
+ throw new Error('MXC_RUNTIME_INTEGRITY');
25
+ const sdk = await import(pathToFileURL(runtime.sdk).href);
26
+ const request = {
27
+ command: `"${runtime.node}" ${profile.args.join(' ')}`, containment: { type: 'processcontainer', config: { capabilities: [] } },
28
+ filesystem: { readonlyPaths: [runtime.node, canonical(i.workspaceRoot)], readwritePaths: [canonical(i.tempDir)], deniedPaths: [join(i.workspaceRoot, '.git')], clearPolicyOnExit: true },
29
+ network: { egress: { default: 'deny' }, ingress: { default: 'deny', hostLoopback: 'deny' } },
30
+ ui: { disable: false, clipboard: 'none', allowInputInjection: false }, workingDirectory: i.workspaceRoot, timeoutMs: profile.timeoutMs,
31
+ environment: { SystemRoot: process.env.SystemRoot, LOCALAPPDATA: i.tempDir, TEMP: i.tempDir, TMP: i.tempDir, CENTCOM_TEST_OUTPUT: i.tempDir }, inheritDefaultEnvironment: false,
32
+ };
33
+ const probe = sdk.probe(request);
34
+ if (probe.error || probe.tier !== 'base-container' || probe.needsDaclAugmentation || probe.warnings.length)
35
+ throw new Error('MXC_POLICY_UNSUPPORTED');
36
+ emit('attestation', { mode: 'OFFLINE_SYNTHETIC_ONLY', tier: probe.tier, runtime: runtime.fingerprint, policy: hash(JSON.stringify(request)), profile: profile.id, network: 'DENY_INGRESS_EGRESS_LOOPBACK' });
37
+ const child = await sdk.spawn(request, { telemetry: { enabled: false } });
38
+ emit('started', { pid: child.id });
39
+ for (const [name, stream] of [['stdout', child.standardOutput], ['stderr', child.standardError]])
40
+ stream?.on('data', (b) => emit(name, b.toString('base64')));
41
+ const wait = await child.wait();
42
+ emit('exit', wait);
43
+ }
44
+ void main().catch((e) => { emit('error', { code: e instanceof Error && /^[A-Z_]{3,64}$/.test(e.message) ? e.message : 'MXC_STARTUP_FAILED' }); process.exitCode = 70; });
45
+ //# sourceMappingURL=mxcWorker.js.map
@@ -0,0 +1,150 @@
1
+ import { type OperationCatalog } from '../plugins/registry/operationCatalog.js';
2
+ import type { PairedAuthority } from '../projects/pairedAuthority.js';
3
+ import type { DurableIntentCoordinator } from '../runs/durableIntentCoordinator.js';
4
+ import type { SqliteLedger } from '../storage/sqliteLedger.js';
5
+ import type { QueuedRunLauncher } from '../transports/http/secureRoutes.js';
6
+ import { type ProjectReadIssuer } from '../context/projectReadIssuer.js';
7
+ import { type CodexProjectReadMcp } from '../plugins/drivers/codexMcpConfig.js';
8
+ import { ExecutionTelemetry } from '../storage/executionTelemetry.js';
9
+ import { CodingWorkflowService } from '../runs/codingWorkflowService.js';
10
+ /**
11
+ * C06 PRODUCTION COMPOSITION OF OPERATOR-PROVISIONED EXECUTION (SW-060).
12
+ *
13
+ * This is the one place where persisted operator configuration becomes a runnable capability. It is reachable ONLY from trusted startup (the
14
+ * attended operator console and the ledger rows it wrote). There is no HTTP, message, page, environment or command-line path into it.
15
+ *
16
+ * What an operator can provision is deliberately NOT a command line. The operator names (plugin id, operation id, one REVIEWED PROFILE, an absolute
17
+ * executable and at most one pinned code input). The argument template, stdin transport, timeout, output bounds, effect class (always 'read') and
18
+ * restricted-identity supervision come from the reviewed profile in this file. A profile never contains a prompt placeholder: the approved prompt travels
19
+ * on stdin only. Nothing is templated through a shell; there is no environment injection.
20
+ *
21
+ * Trust model: a persisted row is DATA. At every start the executable and code inputs are re-read and re-hashed through the C04 registry and compared with the
22
+ * digest the operator saw; any difference disables the row permanently (never re-enabled automatically) and nothing is launched for it. Every launch re-checks
23
+ * again (registry revalidation inside the driver), then runs under the SW-050 RESTRICTED_LOW_INTEGRITY Job supervisor. This is path-ACL confinement with known
24
+ * limits; nothing here claims OS-enforced isolation or filesystem write confinement.
25
+ */
26
+ /** Trusted composition values a profile may need at argument-build time. Never request, environment or command-line input. */
27
+ export interface ProfileContext {
28
+ readonly mcp?: CodexProjectReadMcp;
29
+ /** DEV harness only (profiles offered solely with devSmokeProfiles): the loopback port of the scripted non-model endpoint, injected by the test composition. */
30
+ readonly devMockResponsesPort?: number;
31
+ }
32
+ export interface ReviewedProfile {
33
+ readonly scriptedModelOnly?: boolean;
34
+ readonly id: string;
35
+ readonly description: string;
36
+ /** Required executable file name (case-insensitive). */
37
+ readonly executableName: string;
38
+ /** Exactly this many pinned code inputs (interpreter scripts). */
39
+ readonly codeInputs: 0 | 1;
40
+ readonly buildArgs: (codeInputs: readonly string[], ctx?: ProfileContext) => readonly string[];
41
+ readonly timeoutMs: number;
42
+ /**
43
+ * SW-061: the CLI keeps per-user state (configuration, sign-in). It must NEVER see the real user profile, so it is given a disposable, task-owned,
44
+ * Low-integrity HOME-like set of directories under the daemon's child scratch area instead. The state starts EMPTY (no sign-in); how it would be
45
+ * signed in is a separate user decision. Names are fixed here, never operator input.
46
+ */
47
+ readonly agentHome?: Readonly<Record<string, string>>;
48
+ /**
49
+ * SW-067: the id of a REVIEWED_AGENT_BUILDS entry. When set, the operator's executable must be the entrypoint of that build staged under
50
+ * <project>/.switchyard-data/agents/<id>/ and the WHOLE staged tree must match the reviewed file list at provisioning, at every start and right before every launch.
51
+ */
52
+ readonly stagedBuild?: string;
53
+ /**
54
+ * SW-069: the id of a REVIEWED_CA_BUNDLES entry. The staged, digest-pinned PEM is handed to the CLI as CODEX_CA_CERTIFICATE through the host's trusted environment (a fixed, reviewed
55
+ * value; never operator input, never inherited from the user's environment). Verified at provisioning, at start and before every launch; the host re-hashes it before every run.
56
+ * Requires agentHome (the trusted environment).
57
+ */
58
+ readonly caBundle?: string;
59
+ /**
60
+ * SW-074: the profile registers the read-only project MCP server (provider-specific Codex configuration in codexMcpConfig.ts). A capability is issued per run from the
61
+ * AUTHORIZED invocation, handed to the child only through the host's trusted per-run environment, and revoked when the run settles. Requires agentHome and the staged adapter.
62
+ */
63
+ readonly projectReadMcp?: boolean;
64
+ }
65
+ /**
66
+ * PRODUCTION profiles. Adding one is a code review, never a configuration value. Only these are offered by a normal start.
67
+ */
68
+ export declare const PRODUCTION_PROFILES: Readonly<Record<string, ReviewedProfile>>;
69
+ /**
70
+ * DEV SMOKE profiles (SW-061): benign, non-network reference implementations (node.exe running ONE pinned script that speaks the JSONL frame shapes). They exist so the
71
+ * whole pipeline can be exercised without any agent or model. They are NOT offered by a normal start; they are available only when trusted startup is told so
72
+ * explicitly (devSmokeProfiles), and every start with that mode on announces it. A row that uses one is invalidated at the next start without the mode.
73
+ */
74
+ export declare const DEV_SMOKE_PROFILES: Readonly<Record<string, ReviewedProfile>>;
75
+ /** Every reviewed profile (the union). Use profilesFor() to know which are ACTIVE for a given start. */
76
+ export declare const REVIEWED_PROFILES: Readonly<Record<string, ReviewedProfile>>;
77
+ export declare const profilesFor: (devSmokeProfiles: boolean) => Readonly<Record<string, ReviewedProfile>>;
78
+ export type ProvisionErrorCode = 'PROFILE_UNKNOWN' | 'ARGUMENT_INVALID' | 'ALREADY_PROVISIONED' | 'EXECUTABLE_REFUSED' | 'HELPER_UNAVAILABLE' | 'GIT_UNAVAILABLE' | 'TELEMETRY_UNAVAILABLE' | 'MCP_SERVER_UNAVAILABLE' | 'CA_BUNDLE_INVALID' | 'CHILD_TEMP_UNAVAILABLE' | 'REGISTRATION_REFUSED' | 'PERSIST_FAILED' | 'NOT_FOUND';
79
+ export declare class ProvisionError extends Error {
80
+ readonly code: ProvisionErrorCode;
81
+ constructor(code: ProvisionErrorCode);
82
+ }
83
+ export interface ProvisionActions {
84
+ provisionOperation(a: {
85
+ pluginId: string;
86
+ operationId: string;
87
+ profileId: string;
88
+ executablePath: string;
89
+ codeInputPath?: string;
90
+ }): Promise<{
91
+ executableSha256: string;
92
+ manifestFingerprint: string;
93
+ }>;
94
+ listProvisioned(): ReadonlyArray<{
95
+ pluginId: string;
96
+ operationId: string;
97
+ profileId: string;
98
+ enabled: boolean;
99
+ executableSha256: string;
100
+ disabledReason: string | null;
101
+ }>;
102
+ disableProvisioned(pluginId: string, operationId: string): boolean;
103
+ }
104
+ export interface ProvisionedExecution extends ProvisionActions {
105
+ close?(): Promise<void>;
106
+ codingWorkflow(): Promise<CodingWorkflowService>;
107
+ /** Resolves operations that are provisioned, verified and enabled RIGHT NOW. Plugged into C03 next to the static catalog. */
108
+ readonly resolve: OperationCatalog['resolve'];
109
+ readonly launcher: QueuedRunLauncher;
110
+ promptCapBytes(pluginId: string, operationId: string): number;
111
+ /** Rows that failed re-verification at startup (already disabled in the ledger). */
112
+ readonly invalidatedAtStartup: readonly string[];
113
+ readonly enabledAtStartup: number;
114
+ }
115
+ /** Presentation of reviewed capabilities only; a label never authorizes execution. */
116
+ export declare function reviewedTaskPresentation(profileId: string): {
117
+ agentLabel: string;
118
+ coding: boolean;
119
+ strictReady?: boolean;
120
+ } | undefined;
121
+ /**
122
+ * Git for the C07 observation is found ONLY at the standard install locations under Program Files; PATH is never searched (so a hostile PATH entry cannot
123
+ * substitute the binary). Absent Git is a clear provisioning error, not a fallback.
124
+ */
125
+ export declare function findGit(): string;
126
+ export declare function createProvisionedExecution(owners: {
127
+ ledger: SqliteLedger;
128
+ authority: PairedAuthority;
129
+ coordinator: DurableIntentCoordinator;
130
+ now: () => number;
131
+ projectRoot: string;
132
+ /** SW-061: offer the benign DEV_SMOKE_PROFILES. Default false. */
133
+ devSmokeProfiles?: boolean;
134
+ /** SW-068: the execution evidence recorder shared with the rest of the daemon. Created here when absent. */
135
+ telemetry?: ExecutionTelemetry;
136
+ /** SW-074: the run-scoped project-read capability issuer; created from the ledger and authority when absent. */
137
+ projectRead?: ProjectReadIssuer;
138
+ /** Daemon-instance runtime namespace; trusted bootstrap derives it from its private data root. */
139
+ runtimeRoot?: string;
140
+ codingJournalRoot?: string;
141
+ /** SW-074 DEV harness only (honored solely together with devSmokeProfiles): the loopback port of the scripted non-model endpoint for the mock-provider profile. */
142
+ devMockResponsesPort?: number;
143
+ /** Trusted offline test composition only: exact disposable source manifest.
144
+ * Dev flags alone never enable TEST. Not accepted from HTTP or environment. */
145
+ syntheticTestAcceptance?: {
146
+ sourceRoot: string;
147
+ sourceSha256: string;
148
+ };
149
+ }): Promise<ProvisionedExecution>;
150
+ //# sourceMappingURL=provisionedExecution.d.ts.map