@dailephd/my-centcom 0.2.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,125 @@
1
+ import { X509Certificate, createHash } from 'node:crypto';
2
+ import { chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, writeFileSync } from 'node:fs';
3
+ import { rootCertificates } from 'node:tls';
4
+ import { join } from 'node:path';
5
+ import { grantRestrictedReadExecute, sha256FileSync } from './trustedAgentStaging.js';
6
+ export const REVIEWED_CA_BUNDLES = Object.freeze({
7
+ 'mozilla-node-v24.20.0-win-x64': Object.freeze({
8
+ id: 'mozilla-node-v24.20.0-win-x64',
9
+ origin: 'Mozilla NSS root store as bundled in Node.js v24.20.0 (OpenJS Foundation Authenticode-signed node.exe; release verified against nodejs.org SHASUMS256.txt)',
10
+ generation: 'tls.rootCertificates of the running node.exe; PEM blocks joined with LF plus one trailing LF (deterministic)',
11
+ nodeVersion: 'v24.20.0',
12
+ nodeExeSha256: '5c976096e04e5c2c1f091938926234cc9fbebfe9787ddd149351b3b0ecc707b5',
13
+ certCount: 118,
14
+ pemBytes: 176827,
15
+ pemSha256: '7473d063957ee812a4dd1a56183728b86cb99d6c218274606ad9d18897adf6ab',
16
+ earliestNotAfter: '2028-12-06T15:08:21.000Z',
17
+ }),
18
+ });
19
+ export class CaBundleError extends Error {
20
+ code;
21
+ detail;
22
+ constructor(code, detail) {
23
+ super(detail ? `${code}:${detail}` : code);
24
+ this.code = code;
25
+ this.detail = detail;
26
+ this.name = 'CaBundleError';
27
+ }
28
+ }
29
+ /** Parses every certificate block of a PEM text with the platform X.509 parser. Pure. */
30
+ export function inspectPem(pem, nowMs = Date.now()) {
31
+ const blocks = pem.match(/-----BEGIN CERTIFICATE-----[\s\S]*?-----END CERTIFICATE-----/g) ?? [];
32
+ let unparseable = 0;
33
+ let expired = 0;
34
+ let notYetValid = 0;
35
+ let earliest = Number.POSITIVE_INFINITY;
36
+ for (const b of blocks) {
37
+ try {
38
+ const x = new X509Certificate(b);
39
+ const na = Date.parse(x.validTo);
40
+ const nb = Date.parse(x.validFrom);
41
+ if (na < nowMs)
42
+ expired += 1;
43
+ if (nb > nowMs)
44
+ notYetValid += 1;
45
+ if (na < earliest)
46
+ earliest = na;
47
+ }
48
+ catch {
49
+ unparseable += 1;
50
+ }
51
+ }
52
+ return { count: blocks.length, unparseable, expired, notYetValid, earliestNotAfter: Number.isFinite(earliest) ? new Date(earliest).toISOString() : null };
53
+ }
54
+ /** The PEM the RUNNING Node would produce, with the identity of that Node. */
55
+ export function generateMozillaPemFromRunningNode() {
56
+ return { pem: rootCertificates.join('\n') + '\n', nodeVersion: process.version, nodeExeSha256: sha256FileSync(process.execPath), certCount: rootCertificates.length };
57
+ }
58
+ /** 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. */
59
+ export function verifyCaBundleFile(path, entry, nowMs = Date.now()) {
60
+ if (!existsSync(path))
61
+ return { ok: false, code: 'CA_BUNDLE_MISSING', detail: 'absent' };
62
+ let bytes;
63
+ try {
64
+ const st = lstatSync(path);
65
+ if (!st.isFile() || st.isSymbolicLink())
66
+ return { ok: false, code: 'CA_BUNDLE_MODIFIED', detail: 'not-a-regular-file' };
67
+ bytes = readFileSync(path);
68
+ }
69
+ catch {
70
+ return { ok: false, code: 'CA_BUNDLE_UNREADABLE', detail: 'read-failed' };
71
+ }
72
+ if (bytes.length !== entry.pemBytes || createHash('sha256').update(bytes).digest('hex') !== entry.pemSha256)
73
+ return { ok: false, code: 'CA_BUNDLE_MODIFIED', detail: `bytes=${bytes.length}` };
74
+ const insp = inspectPem(bytes.toString('utf8'), nowMs);
75
+ if (insp.count !== entry.certCount || insp.unparseable > 0)
76
+ return { ok: false, code: 'CA_BUNDLE_MALFORMED', detail: `certs=${insp.count} unparseable=${insp.unparseable}` };
77
+ return { ok: true, certCount: insp.count, expiredCount: insp.expired + insp.notYetValid, earliestNotAfter: insp.earliestNotAfter };
78
+ }
79
+ export const stagedCaDirOf = (stagingRoot, entry) => join(stagingRoot, `ca-${entry.id}`);
80
+ export const stagedCaFileOf = (stagingRoot, entry) => join(stagedCaDirOf(stagingRoot, entry), 'ca-bundle.pem');
81
+ /**
82
+ * 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.
83
+ * Idempotent: an existing staged file is only verified, never rewritten; a differing one is refused as tampered.
84
+ */
85
+ export function stageCaBundle(o) {
86
+ const entry = Object.prototype.hasOwnProperty.call(REVIEWED_CA_BUNDLES, o.id) ? REVIEWED_CA_BUNDLES[o.id] : undefined;
87
+ if (!entry)
88
+ throw new CaBundleError('CA_BUNDLE_UNKNOWN');
89
+ const dest = stagedCaFileOf(o.stagingRoot, entry);
90
+ if (existsSync(dest)) {
91
+ const v = verifyCaBundleFile(dest, entry);
92
+ if (!v.ok)
93
+ throw new CaBundleError(v.code, v.detail);
94
+ return { path: realpathSync.native(dest), reused: true, certCount: v.certCount };
95
+ }
96
+ const gen = generateMozillaPemFromRunningNode();
97
+ const pemSha = createHash('sha256').update(gen.pem, 'utf8').digest('hex');
98
+ if (gen.nodeVersion !== entry.nodeVersion || gen.nodeExeSha256 !== entry.nodeExeSha256 || pemSha !== entry.pemSha256) {
99
+ throw new CaBundleError('CA_SOURCE_NOT_REVIEWED', `node=${gen.nodeVersion} exe=${gen.nodeExeSha256.slice(0, 12)} pem=${pemSha.slice(0, 12)}`);
100
+ }
101
+ const dir = stagedCaDirOf(o.stagingRoot, entry);
102
+ const partial = `${dir}.partial-${process.pid}`;
103
+ try {
104
+ rmSync(partial, { recursive: true, force: true });
105
+ mkdirSync(partial, { recursive: true });
106
+ writeFileSync(join(partial, 'ca-bundle.pem'), gen.pem, { encoding: 'utf8', flag: 'wx' });
107
+ const v = verifyCaBundleFile(join(partial, 'ca-bundle.pem'), entry);
108
+ if (!v.ok)
109
+ throw new CaBundleError(v.code, v.detail);
110
+ chmodSync(join(partial, 'ca-bundle.pem'), 0o444);
111
+ renameSync(partial, dir);
112
+ grantRestrictedReadExecute(dir); // READ + EXECUTE only: the restricted identity can read the bundle and can never replace or modify it
113
+ }
114
+ catch (e) {
115
+ try {
116
+ rmSync(partial, { recursive: true, force: true });
117
+ }
118
+ catch { /* task-owned name */ }
119
+ if (e instanceof CaBundleError)
120
+ throw e;
121
+ throw new CaBundleError('CA_STAGE_IO_FAILED');
122
+ }
123
+ return { path: realpathSync.native(dest), reused: false, certCount: gen.certCount };
124
+ }
125
+ //# sourceMappingURL=trustedCaBundle.js.map
@@ -0,0 +1,166 @@
1
+ import { EventEmitter } from 'node:events';
2
+ import { PassThrough } from 'node:stream';
3
+ /**
4
+ * C06 Windows Job-supervised launch adapter (SW-046, B03-F). It is an IMPLEMENTATION of process supervision for the
5
+ * single existing boundedProcessHost; it is not a second public runner and nothing but trusted in-process
6
+ * construction can select it (no request field, environment variable or daemon wiring).
7
+ *
8
+ * One helper process (supervisorMain.cs, built from tracked text into an ignored directory) is started per launch. It
9
+ * owns one unnamed Job Object (KILL_ON_JOB_CLOSE, no breakaway), creates the pinned target SUSPENDED, assigns it to the
10
+ * Job BEFORE it can execute, and relays bounded stdout/stderr frames. The versioned frame protocol is validated
11
+ * strictly here: unknown types or fields, bad lengths, bad UTF-8, frames out of order, duplicate terminal frames and
12
+ * truncation all produce a truthful FAILED supervision record, never a success. Nothing the helper reports is used as
13
+ * an OS handle, a filename or an authorization fact.
14
+ *
15
+ * What this does NOT establish (reported as NOT_VERIFIED in every result): atomic image identity (this adapter reaches
16
+ * the helper by PATH, so a residual race remains between the helper digest check and the helper's start), operating
17
+ * system filesystem confinement, and private-database isolation. A Job Object restricts none of those.
18
+ * Execution identity (SW-050): the trusted owner may construct the supervisor with the fixed identity RESTRICTED_LOW_INTEGRITY. The
19
+ * helper then creates the target with a restricted PRIMARY token derived from the caller's own token (privileges removed, fixed
20
+ * restricting-SID set, Low integrity), verifies that token and the child's actual token before the child can run, and reports it in
21
+ * an 'I' frame that this decoder requires before 'S'. There is no fallback to the caller token and no request field can select an
22
+ * identity. The identity is NOT general filesystem isolation (broad-ACL-independent Low-integrity writable locations, world-readable
23
+ * files, same-user IPC and the network stay exposed) and the security tier is never claimed as enforced.
24
+ */
25
+ export type StdinStatus = 'NOT_REQUESTED' | 'NOT_ATTEMPTED' | 'DELIVERED_EOF' | 'EARLY_EXIT' | 'ERROR';
26
+ export type SupervisorErrorCode = 'UNSUPPORTED_PLATFORM' | 'HELPER_CONFIG_INVALID' | 'HELPER_UNVERIFIED';
27
+ /** Sanitized: only a fixed code. */
28
+ export declare class SupervisorError extends Error {
29
+ readonly code: SupervisorErrorCode;
30
+ constructor(code: SupervisorErrorCode);
31
+ }
32
+ /** The only identities. CALLER_TOKEN is the SW-046 behavior (the helper's own token). Selected ONLY at trusted construction. */
33
+ export type ExecutionIdentity = 'CALLER_TOKEN' | 'RESTRICTED_LOW_INTEGRITY';
34
+ export declare const MAX_REQUEST_BYTES = 65536;
35
+ export declare const MAX_FRAME_BYTES = 65536;
36
+ export declare const MAX_CONTROL_FRAMES = 1024;
37
+ /** Observed dimensions, kept separate on purpose. A successful exit or an API return never implies tree termination. */
38
+ export type SupervisionEvidence = Readonly<{
39
+ processLaunched: boolean;
40
+ rootExited: boolean;
41
+ /** True only when the helper confirmed IsProcessInJob and a resume previous-suspend-count of exactly 1. */
42
+ jobAssignedBeforeResume: boolean;
43
+ /** True only when every tracked Job member (PID + creation time) was observed gone and the Job's active count was 0. */
44
+ knownTreeTerminatedAndChecked: boolean;
45
+ executableDigestPrechecked: boolean;
46
+ trackedJobMembersAtTermination: number | null;
47
+ totalProcessesEverInJob: number | null;
48
+ terminationWaitMs: number | null;
49
+ terminationReason: string | null;
50
+ cancelRequestedWhileRunning: boolean;
51
+ ownerLossObserved: boolean;
52
+ helperFailureCode: string | null;
53
+ protocol: 'OK' | 'VIOLATION' | 'TRUNCATED' | 'NO_TERMINAL_FRAME';
54
+ /**
55
+ * SW-052 stdin delivery. NOT_REQUESTED: no stdin was asked for. NOT_ATTEMPTED: asked for, but the target never ran (or the report never came).
56
+ * DELIVERED_EOF: every byte was accepted by the private pipe and the write end was closed (EOF); this is NOT proof the target consumed it
57
+ * (it does prove the target read all but the pipe's small buffer). EARLY_EXIT: the target stopped reading first; bytesWritten < expected.
58
+ */
59
+ stdinStatus: StdinStatus;
60
+ stdinBytesExpected: number | null;
61
+ stdinBytesWritten: number | null;
62
+ stdinEofClosed: boolean;
63
+ /** The identity the trusted owner asked for. */
64
+ executionIdentity: ExecutionIdentity;
65
+ /** True only when the helper verified the created token AND the child's own primary token (restricted mode); always false for CALLER_TOKEN. */
66
+ childTokenVerified: boolean;
67
+ atomicImageIdentity: 'NOT_VERIFIED';
68
+ osFilesystemConfinement: 'NOT_VERIFIED';
69
+ privateDatabaseIsolation: 'NOT_VERIFIED';
70
+ }>;
71
+ export interface SupervisedLaunchSpec {
72
+ exe: string;
73
+ sha256: string;
74
+ cwd: string;
75
+ args: readonly string[];
76
+ /** Already validated, allowlisted environment (non-empty strings). */
77
+ env: Readonly<Record<string, string>>;
78
+ /** SW-052: already validated approved UTF-8 input bytes (1..STDIN_MAX), delivered once on a private pipe. Absent = stdin ignored. */
79
+ stdin?: Uint8Array;
80
+ }
81
+ /** The subset of ChildProcess that boundedProcessHost uses, plus the evidence accessor. */
82
+ export interface SupervisedChild extends EventEmitter {
83
+ stdout: PassThrough;
84
+ stderr: PassThrough;
85
+ kill(signal?: NodeJS.Signals): boolean;
86
+ evidence(): SupervisionEvidence;
87
+ /** The helper process id (not the target's). Diagnostic only. */
88
+ readonly helperPid: number | undefined;
89
+ }
90
+ export interface WindowsJobSupervisor {
91
+ readonly kind: 'WINDOWS_JOB_SUPERVISOR';
92
+ readonly executionIdentity: ExecutionIdentity;
93
+ /** Re-hashes the helper executable; rejects with SupervisorError unless it equals the trusted digest. */
94
+ verifyHelper(): Promise<void>;
95
+ /** SW-052: throws SupervisorError('HELPER_CONFIG_INVALID') if this exact launch (including the identity and stdin this supervisor adds) cannot be encoded. Starts nothing. */
96
+ checkLaunchRequest(spec: SupervisedLaunchSpec): void;
97
+ spawn(spec: SupervisedLaunchSpec): SupervisedChild;
98
+ }
99
+ export declare const isWindowsJobSupervisor: (v: unknown) => v is WindowsJobSupervisor;
100
+ export declare function encodeFrame(type: string, payload: Buffer): Buffer;
101
+ /** Hard ceiling mirrored from the helper and the shared contract (STDIN_MAX_BYTES_V1). */
102
+ export declare const STDIN_MAX_BYTES = 32768;
103
+ export declare function encodeLaunchRequest(spec: SupervisedLaunchSpec, identity?: ExecutionIdentity): Buffer;
104
+ export interface DecoderSink {
105
+ data(kind: 'O' | 'E', payload: Buffer): boolean;
106
+ started(): void;
107
+ /** The single valid terminal frame arrived. `launched` is false when it followed a launch failure. */
108
+ terminal(launched: boolean): void;
109
+ /** A violation was detected; the owner must stop trusting the stream and close the helper. */
110
+ violation(kind: 'VIOLATION' | 'TRUNCATED'): void;
111
+ }
112
+ /**
113
+ * Pure, I/O-free decoder for the helper's output stream. Everything the helper says is untrusted until it passes this
114
+ * state machine: header magic/version, length <= MAX_FRAME_BYTES, known frame type, strict UTF-8 key=value schemas with
115
+ * exactly the allowed keys, frame order, at most MAX_CONTROL_FRAMES control frames and exactly one terminal frame.
116
+ */
117
+ export declare class HelperProtocolDecoder {
118
+ private readonly sink;
119
+ private readonly expectedIdentity;
120
+ private readonly expectedStdinBytes;
121
+ readonly ev: {
122
+ processLaunched: boolean;
123
+ rootExited: boolean;
124
+ jobAssignedBeforeResume: boolean;
125
+ knownTreeTerminatedAndChecked: boolean;
126
+ executableDigestPrechecked: boolean;
127
+ trackedJobMembersAtTermination: number | null;
128
+ totalProcessesEverInJob: number | null;
129
+ terminationWaitMs: number | null;
130
+ terminationReason: string | null;
131
+ cancelRequestedWhileRunning: boolean;
132
+ ownerLossObserved: boolean;
133
+ helperFailureCode: string | null;
134
+ protocol: SupervisionEvidence["protocol"];
135
+ executionIdentity: ExecutionIdentity;
136
+ childTokenVerified: boolean;
137
+ stdinStatus: StdinStatus;
138
+ stdinBytesExpected: number | null;
139
+ stdinBytesWritten: number | null;
140
+ stdinEofClosed: boolean;
141
+ };
142
+ sawN: boolean;
143
+ sawI: boolean;
144
+ sawS: boolean;
145
+ sawX: boolean;
146
+ sawT: boolean;
147
+ sawZ: boolean;
148
+ sawF: boolean;
149
+ sawH: boolean;
150
+ exitCode: number | null;
151
+ cancelled: boolean;
152
+ private controlFrames;
153
+ private pending;
154
+ constructor(sink: DecoderSink, expectedIdentity?: ExecutionIdentity, expectedStdinBytes?: number | null);
155
+ get pendingBytes(): number;
156
+ feed(chunk: Buffer): void;
157
+ /** The helper's stdout ended. Truthfully classify a stream that stopped without a terminal frame. */
158
+ endOfStream(): void;
159
+ private frame;
160
+ }
161
+ export declare function createWindowsJobSupervisor(config: {
162
+ helperPath: string;
163
+ helperSha256: string;
164
+ executionIdentity?: ExecutionIdentity;
165
+ }): WindowsJobSupervisor;
166
+ //# sourceMappingURL=windowsJobSupervisor.d.ts.map