@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,473 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { BootstrapSessionRequestV1Schema, BootstrapSessionResponseV1Schema, CaptureRunRequestV1Schema, CaptureRunResponseV1Schema, CaptureStoreRequestV1Schema, CaptureStoreResponseV1Schema, ReturnRebindRequestV1Schema, ReturnReceiptRequestV1Schema, RunStatusResponseV1Schema, RunWaitRequestV1Schema, SCHEMA_VERSION_V1, WorkflowCurrentResponseV1Schema, WorkflowDismissRequestV1Schema, WorkflowPreferenceRequestV1Schema, WorkflowReadRequestV1Schema, CodingReadRequestV1Schema, CodingActionRequestV1Schema, CodingCaptureRunRequestV1Schema, TrustedCliConsentRequestSchema, ReviewedPatchRequestV1Schema, ReviewedCommitRequestSchema, ActivityRequestSchema, ActivityResponseSchema, } from '../../../../../packages/contracts/dist/index.js';
3
+ import { z } from 'zod';
4
+ import { WorkflowRefusal } from '../../runs/workflowService.js';
5
+ import { CodingAuthority } from '../../projects/codingAuthority.js';
6
+ import { isTrustedProposalRun } from '../../projects/trustedCliConsent.js';
7
+ export const WORKFLOW_BROWSER_PATHS = [
8
+ '/v1/runs/:runId/activity',
9
+ '/v1/coding/:runId/status', '/v1/coding/:runId/proposal', '/v1/coding/:runId/action', '/v1/coding/:runId/reviewed-patch', '/v1/coding/:runId/commit-review', '/v1/coding/:runId/reviewed-commit',
10
+ '/v1/coding/trusted-consent',
11
+ '/v1/captures/:captureId/coding',
12
+ '/v1/captures', '/v1/captures/:captureId/run', '/v1/workflow/current', '/v1/workflow/preference', '/v1/workflow/dismiss', '/v1/runs/:runId/wait',
13
+ '/v1/returns/:returnId/receipt', '/v1/returns/:returnId/rebind',
14
+ ];
15
+ const REFUSAL_STATUS = {
16
+ CAPTURE_NOT_FOUND: 404, NOT_FOUND: 404, CAPTURE_EXPIRED: 409, CAPTURE_CONFLICT: 409, CAPTURE_INVALID: 400, GRANT_DENIED: 403, RETURN_NOT_AVAILABLE: 409,
17
+ RETURN_CHANGED: 409, ALREADY_INSERTED: 409, STATE_CONFLICT: 409, SEAL_FAILED: 500, RUN_NOT_RUNNABLE: 409,
18
+ };
19
+ const AdminRequestSchema = z.strictObject({ schemaVersion: z.literal(1), installationId: z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/), secret: z.string().regex(/^[A-Za-z0-9_-]{32,128}$/), runId: z.string().regex(/^run\.[a-f0-9]{32}$/).optional() });
20
+ /** A native host is a plain local process: a browser always adds Origin and/or Sec-Fetch-* to a POST, a web page cannot remove them. */
21
+ const isNonBrowserRequest = (req) => req.headers.origin === undefined && req.headers['sec-fetch-mode'] === undefined && req.headers['sec-fetch-site'] === undefined && req.headers['sec-fetch-dest'] === undefined;
22
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
23
+ export function registerWorkflowRoutes(app, deps) {
24
+ const { authority, coordinator, workflow, launcher, h } = deps;
25
+ if (deps.codingWorkflow) {
26
+ for (const action of ['commit-review', 'reviewed-commit'])
27
+ app.post(`/v1/coding/:runId/${action}`, async (req, reply) => {
28
+ const p = h.authenticate(req, reply);
29
+ if (!p)
30
+ return reply;
31
+ const body = ReviewedCommitRequestSchema.safeParse(req.body);
32
+ if (!body.success)
33
+ return h.validationFail(reply, body.error);
34
+ const row = deps.ledger.getCodingProposal(body.data.proposalId);
35
+ if (!row || row.runId !== req.params.runId || row.principalId !== p.principalId)
36
+ return h.fail(reply, 404, 'NOT_FOUND');
37
+ const service = await deps.codingWorkflow();
38
+ try {
39
+ const identity = { ...body.data, principalId: p.principalId, origin: p.origin };
40
+ const result = action === 'commit-review' ? service.commitReview(p.principalId, p.origin, row.proposalId, body.data.message) : service.reviewedCommit(identity);
41
+ return reply.header('cache-control', 'no-store').send({ schemaVersion: 1, result });
42
+ }
43
+ catch {
44
+ return h.fail(reply, 409, 'STATE_CONFLICT');
45
+ }
46
+ });
47
+ app.post('/v1/coding/trusted-consent', async (req, reply) => {
48
+ const p = h.authenticate(req, reply);
49
+ if (!p)
50
+ return reply;
51
+ const body = TrustedCliConsentRequestSchema.safeParse(req.body);
52
+ if (!body.success)
53
+ return h.validationFail(reply, body.error);
54
+ const i = body.data;
55
+ if (!authority.authorize(p.principalId, i.projectId, i.pluginId, i.operationId))
56
+ return h.fail(reply, 403, 'GRANT_DENIED');
57
+ const consent = (await deps.codingWorkflow()).trustedCliConsent;
58
+ if (!consent)
59
+ return h.fail(reply, 403, 'TRUSTED_CLI_UNAVAILABLE');
60
+ try {
61
+ const target = { principalId: p.principalId, origin: p.origin, projectId: i.projectId, pluginId: i.pluginId, operationId: i.operationId };
62
+ const state = i.action === 'status' ? consent.status(target) : consent.decide(target, i.action, i.challenge, i.warningVersion);
63
+ return reply.header('cache-control', 'no-store').send({ schemaVersion: 1, ...state });
64
+ }
65
+ catch {
66
+ return h.fail(reply, 403, 'TRUSTED_CLI_CONSENT_MISMATCH');
67
+ }
68
+ });
69
+ const request = CodingReadRequestV1Schema;
70
+ for (const action of ['status', 'proposal'])
71
+ app.post(`/v1/coding/:runId/${action}`, async (req, reply) => {
72
+ const p = h.authenticate(req, reply);
73
+ if (!p)
74
+ return reply;
75
+ const body = request.safeParse(req.body);
76
+ if (!body.success)
77
+ return h.validationFail(reply, body.error);
78
+ const { runId } = req.params;
79
+ const run = coordinator.getStatus(p.principalId, runId);
80
+ if (!run)
81
+ return h.fail(reply, 404, 'NOT_FOUND');
82
+ const service = await deps.codingWorkflow();
83
+ const detail = deps.ledger.getRunDetailForPrincipal(p.principalId, runId);
84
+ const coding = deps.ledger.findCodingGrants(p.principalId, detail.projectId, runId, 'PROPOSE').length > 0;
85
+ const proposals = deps.ledger.findCodingProposalsByRun(runId).map((row) => ({ ...service.describeForApproval(p.principalId, row.proposalId), reviewedPatch: service.reviewedPatchView(p.principalId, p.origin, row.proposalId), actions: deps.ledger.readCodingActions(row.proposalId), result: service.copyCommittedResult(p.principalId, row.proposalId) ?? service.copyAppliedResult(p.principalId, row.proposalId) ?? service.copyResult(p.principalId, row.proposalId) ?? null, proposalResult: service.copyProposal(p.principalId, row.proposalId) ?? null }));
86
+ return reply.header('cache-control', 'no-store').send({ schemaVersion: 1, runId, lifecycleState: run.lifecycleState, coding, proposals });
87
+ });
88
+ const effectRequest = CodingActionRequestV1Schema;
89
+ app.post('/v1/coding/:runId/reviewed-patch', async (req, reply) => {
90
+ const p = h.authenticate(req, reply);
91
+ if (!p)
92
+ return reply;
93
+ const body = ReviewedPatchRequestV1Schema.safeParse(req.body);
94
+ if (!body.success)
95
+ return h.validationFail(reply, body.error);
96
+ const { runId } = req.params;
97
+ if (!coordinator.getStatus(p.principalId, runId))
98
+ return h.fail(reply, 404, 'NOT_FOUND');
99
+ const row = deps.ledger.getCodingProposal(body.data.proposalId);
100
+ if (!row || row.runId !== runId || row.principalId !== p.principalId)
101
+ return h.fail(reply, 404, 'NOT_FOUND');
102
+ const service = await deps.codingWorkflow();
103
+ try {
104
+ const result = service.reviewedApply({ ...body.data, principalId: p.principalId, origin: p.origin });
105
+ return reply.header('cache-control', 'no-store').send({ schemaVersion: 1, result });
106
+ }
107
+ catch {
108
+ h.note(req, 'ERROR', 'RUN', 'coding.reviewed-patch', 'CODING_ACTION_UNCERTAIN', 'FAILED', { runId });
109
+ return h.fail(reply, 409, 'STATE_CONFLICT');
110
+ }
111
+ });
112
+ app.post('/v1/coding/:runId/action', async (req, reply) => {
113
+ const p = h.authenticate(req, reply);
114
+ if (!p)
115
+ return reply;
116
+ const body = effectRequest.safeParse(req.body);
117
+ if (!body.success)
118
+ return h.validationFail(reply, body.error);
119
+ const { runId } = req.params;
120
+ const i = body.data;
121
+ if (!coordinator.getStatus(p.principalId, runId))
122
+ return h.fail(reply, 404, 'NOT_FOUND');
123
+ const service = await deps.codingWorkflow();
124
+ const view = service.describeForApproval(p.principalId, i.proposalId);
125
+ if (!view || view.runId !== runId)
126
+ return h.fail(reply, 404, 'NOT_FOUND');
127
+ const run = deps.ledger.getRunDetailForPrincipal(p.principalId, runId);
128
+ if (isTrustedProposalRun(deps.ledger, runId) && !['proposal', 'reject'].includes(i.action))
129
+ return h.fail(reply, 403, 'PROPOSAL_ONLY_MODE');
130
+ if (!authority.authorize(p.principalId, run.projectId, run.pluginId, run.operationId))
131
+ return h.fail(reply, 403, 'GRANT_DENIED');
132
+ if (view.digest !== i.digest)
133
+ return h.fail(reply, 409, 'STATE_CONFLICT');
134
+ const oldAction = deps.ledger.readCodingActions(i.proposalId).find((a) => a.action === i.action);
135
+ if (!oldAction && !service.actionReady(p.principalId, i.proposalId, i.action))
136
+ return h.fail(reply, 409, 'STATE_CONFLICT');
137
+ const reservation = deps.ledger.reserveCodingAction(i.proposalId, i.action, i.digest, new Date().toISOString());
138
+ if (reservation !== 'NEW') {
139
+ const previous = deps.ledger.readCodingActions(i.proposalId).find((a) => a.action === i.action);
140
+ if (reservation === 'CONFLICT' || previous?.result == null)
141
+ return h.fail(reply, 409, 'STATE_CONFLICT');
142
+ return reply.header('cache-control', 'no-store').send({ schemaVersion: 1, duplicate: true, result: previous.result });
143
+ }
144
+ const identity = { principalId: p.principalId, proposalId: i.proposalId };
145
+ let result;
146
+ try {
147
+ if (i.action === 'apply') {
148
+ const a = service.approve({ ...identity, shownDigest: i.digest });
149
+ result = a.ok ? service.apply(identity) : a;
150
+ }
151
+ else if (i.action === 'reject')
152
+ result = service.reject(p.principalId, i.proposalId);
153
+ else if (i.action === 'proposal')
154
+ result = service.finalizeProposal({ ...identity, shownDigest: i.digest });
155
+ else if (i.action === 'test') {
156
+ const a = service.authorizeTest({ ...identity, profileId: 'node-test-v1' });
157
+ result = a.ok ? await service.test({ ...identity, profileId: 'node-test-v1', expectedMinTests: 1 }) : a;
158
+ }
159
+ else if (i.action === 'git') {
160
+ const a = service.authorizeGitRead(identity);
161
+ result = a.ok ? service.verify(identity) : a;
162
+ }
163
+ else if (i.action === 'commit') {
164
+ const a = service.authorizeCommit(identity);
165
+ result = a.ok ? service.commit(identity) : a;
166
+ }
167
+ else
168
+ result = service.finalize(identity);
169
+ deps.ledger.finishCodingAction(i.proposalId, i.action, result);
170
+ }
171
+ catch {
172
+ h.note(req, 'ERROR', 'RUN', 'coding.' + i.action, 'CODING_ACTION_UNCERTAIN', 'FAILED', { runId });
173
+ return h.fail(reply, 409, 'STATE_CONFLICT');
174
+ }
175
+ return reply.header('cache-control', 'no-store').send({ schemaVersion: 1, duplicate: false, result });
176
+ });
177
+ }
178
+ const noStore = (reply) => reply.header('cache-control', 'no-store');
179
+ const refusal = (reply, req, e, op) => {
180
+ if (e instanceof WorkflowRefusal) {
181
+ h.note(req, e.code === 'GRANT_DENIED' ? 'WARN' : 'INFO', e.code === 'GRANT_DENIED' ? 'AUTH' : 'SNAPSHOT', op, e.code, e.code === 'GRANT_DENIED' ? 'DENIED' : 'REFUSED');
182
+ return h.fail(reply, REFUSAL_STATUS[e.code] ?? 409, e.code === 'RUN_NOT_RUNNABLE' ? 'STATE_CONFLICT' : e.code);
183
+ }
184
+ throw e;
185
+ };
186
+ const launchOnce = (req, principalId, runId) => {
187
+ if (!launcher)
188
+ return;
189
+ try {
190
+ launcher.launch(principalId, runId);
191
+ h.note(req, 'INFO', 'RUN', 'run.launch', 'RUN_LAUNCH_REQUESTED', 'OK', { runId });
192
+ }
193
+ catch {
194
+ h.note(req, 'ERROR', 'RUN', 'run.launch', 'RUN_LAUNCH_FAILED', 'FAILED', { runId });
195
+ }
196
+ };
197
+ // ---------------------------------------------------------------------------------------------------- native bootstrap (no browser can call these)
198
+ app.post('/v1/bootstrap/session', async (req, reply) => {
199
+ if (!isNonBrowserRequest(req))
200
+ return h.fail(reply, 403, 'ORIGIN_DENIED');
201
+ const body = BootstrapSessionRequestV1Schema.safeParse(req.body);
202
+ if (!body.success)
203
+ return h.validationFail(reply, body.error);
204
+ const r = authority.issueInstallationSession(body.data.installationId, body.data.secret, body.data.extensionOrigin);
205
+ if (!r.ok) {
206
+ h.note(req, 'WARN', 'AUTH', 'bootstrap.session', 'SESSION_REFUSED', 'DENIED', { internalReason: r.reason, installationId: body.data.installationId });
207
+ return h.fail(reply, 403, 'SESSION_REFUSED', { detail: { internalReason: r.reason } });
208
+ }
209
+ h.note(req, 'INFO', 'AUTH', 'bootstrap.session', 'SESSION_ISSUED', 'OK', { installationId: body.data.installationId, principalId: r.principalId, expiresAt: r.expiresAt });
210
+ return noStore(reply).code(200).send(BootstrapSessionResponseV1Schema.parse({ schemaVersion: SCHEMA_VERSION_V1, installationId: body.data.installationId, bearerToken: r.bearerToken, expiresAt: r.expiresAt }));
211
+ });
212
+ const adminPrincipal = (req, reply) => {
213
+ if (!isNonBrowserRequest(req)) {
214
+ h.fail(reply, 403, 'ORIGIN_DENIED');
215
+ return undefined;
216
+ }
217
+ const body = AdminRequestSchema.safeParse(req.body);
218
+ if (!body.success) {
219
+ h.validationFail(reply, body.error);
220
+ return undefined;
221
+ }
222
+ const p = authority.verifyInstallationSecret(body.data.installationId, body.data.secret);
223
+ if (!p) {
224
+ h.note(req, 'WARN', 'AUTH', 'bootstrap.admin', 'ADMIN_DENIED', 'DENIED');
225
+ h.fail(reply, 403, 'SESSION_REFUSED');
226
+ return undefined;
227
+ }
228
+ return { principalId: p, ...(body.data.runId ? { runId: body.data.runId } : {}) };
229
+ };
230
+ app.post('/v1/bootstrap/pending', async (req, reply) => {
231
+ const a = adminPrincipal(req, reply);
232
+ if (!a)
233
+ return reply;
234
+ if (!workflow)
235
+ return h.fail(reply, 404, 'NOT_FOUND');
236
+ return noStore(reply).code(200).send({ schemaVersion: SCHEMA_VERSION_V1, pending: workflow.pendingConfirmations(a.principalId) });
237
+ });
238
+ app.post('/v1/bootstrap/confirm', async (req, reply) => {
239
+ const a = adminPrincipal(req, reply);
240
+ if (!a)
241
+ return reply;
242
+ if (!workflow || !a.runId)
243
+ return h.fail(reply, 404, 'NOT_FOUND');
244
+ try {
245
+ const r = workflow.confirmLocally(a.principalId, a.runId);
246
+ h.note(req, 'INFO', 'RUN', 'run.confirm', 'RUN_CONFIRMED_LOCALLY', 'OK', { runId: a.runId });
247
+ if (r.launch)
248
+ launchOnce(req, a.principalId, a.runId);
249
+ return noStore(reply).code(200).send({ schemaVersion: SCHEMA_VERSION_V1, runId: a.runId, lifecycleState: r.lifecycleState });
250
+ }
251
+ catch (e) {
252
+ return refusal(reply, req, e, 'run.confirm');
253
+ }
254
+ });
255
+ if (!workflow)
256
+ return;
257
+ app.post('/v1/captures/:captureId/coding', async (req, reply) => {
258
+ const p = h.authenticate(req, reply);
259
+ if (!p)
260
+ return reply;
261
+ if (!deps.codingWorkflow)
262
+ return h.fail(reply, 404, 'NOT_FOUND');
263
+ const body = CodingCaptureRunRequestV1Schema.safeParse(req.body);
264
+ if (!body.success)
265
+ return h.validationFail(reply, body.error);
266
+ const { captureId } = req.params;
267
+ if (!/^cap\.[a-f0-9]{32}$/.test(captureId))
268
+ return h.fail(reply, 404, 'CAPTURE_NOT_FOUND');
269
+ const service = await deps.codingWorkflow();
270
+ const target = { principalId: p.principalId, origin: p.origin, projectId: body.data.projectId, pluginId: body.data.pluginId, operationId: body.data.operationId };
271
+ const mode = body.data.executionMode ?? 'STRICT_ISOLATED';
272
+ if (mode === 'TRUSTED_LOCAL_CLI_PROPOSAL_ONLY') {
273
+ try {
274
+ if (!service.trustedCliConsent?.status(target).enabled)
275
+ return h.fail(reply, 403, 'TRUSTED_CLI_CONSENT_REQUIRED');
276
+ }
277
+ catch {
278
+ return h.fail(reply, 403, 'TRUSTED_CLI_CONSENT_REQUIRED');
279
+ }
280
+ }
281
+ try {
282
+ const out = workflow.runCapture(p.principalId, captureId, body.data);
283
+ if (mode === 'STRICT_ISOLATED' && isTrustedProposalRun(deps.ledger, out.runId))
284
+ return h.fail(reply, 409, 'STATE_CONFLICT');
285
+ if (out.launch && !out.duplicate) {
286
+ if (mode === 'TRUSTED_LOCAL_CLI_PROPOSAL_ONLY')
287
+ service.trustedCliConsent.bind(target, out.runId);
288
+ const codingAuthority = new CodingAuthority({ ledger: deps.ledger });
289
+ const grants = ['INSPECT', 'PROPOSE'].map((operation) => codingAuthority.grant({ principalId: p.principalId, projectId: body.data.projectId, runId: out.runId, operation, lifetimeMs: 15 * 60_000 }));
290
+ if (grants.some((g) => !g.ok)) {
291
+ codingAuthority.revokeRun(out.runId);
292
+ return h.fail(reply, 403, 'GRANT_DENIED');
293
+ }
294
+ launchOnce(req, p.principalId, out.runId);
295
+ }
296
+ return noStore(reply).code(out.duplicate ? 200 : 202).send(CaptureRunResponseV1Schema.parse({ schemaVersion: 1, runId: out.runId, lifecycleState: out.lifecycleState, duplicate: out.duplicate, consent: out.consent, effectClass: out.effectClass }));
297
+ }
298
+ catch (e) {
299
+ return refusal(reply, req, e, 'coding.start');
300
+ }
301
+ });
302
+ // ---------------------------------------------------------------------------------------------------- browser-facing workflow
303
+ app.post('/v1/captures', async (req, reply) => {
304
+ const p = h.authenticate(req, reply);
305
+ if (!p)
306
+ return reply;
307
+ const body = CaptureStoreRequestV1Schema.safeParse(req.body);
308
+ if (!body.success)
309
+ return h.validationFail(reply, body.error);
310
+ try {
311
+ const out = workflow.storeCapture(p.principalId, body.data);
312
+ h.note(req, 'INFO', 'SNAPSHOT', 'capture.store', out.duplicate ? 'CAPTURE_REUSED' : 'CAPTURE_STORED', 'OK', { captureId: out.captureId, bytes: out.bytes, sha256: out.sha256, fidelity: body.data.fidelity, lineEndingsNormalized: body.data.lineEndingsNormalized ?? 0 });
313
+ return noStore(reply).code(out.duplicate ? 200 : 201).send(CaptureStoreResponseV1Schema.parse({ schemaVersion: SCHEMA_VERSION_V1, ...out }));
314
+ }
315
+ catch (e) {
316
+ return refusal(reply, req, e, 'capture.store');
317
+ }
318
+ });
319
+ app.post('/v1/captures/:captureId/run', async (req, reply) => {
320
+ const p = h.authenticate(req, reply);
321
+ if (!p)
322
+ return reply;
323
+ const body = CaptureRunRequestV1Schema.safeParse(req.body);
324
+ if (!body.success)
325
+ return h.validationFail(reply, body.error);
326
+ const { captureId } = req.params;
327
+ if (!/^cap\.[a-f0-9]{32}$/.test(captureId))
328
+ return h.fail(reply, 404, 'CAPTURE_NOT_FOUND');
329
+ try {
330
+ const out = workflow.runCapture(p.principalId, captureId, body.data);
331
+ h.note(req, 'INFO', 'RUN', 'capture.run', out.duplicate ? 'RUN_PREPARE_DUPLICATE' : 'RUN_PREPARED', 'OK', { runId: out.runId, consent: out.consent, state: out.lifecycleState });
332
+ if (out.launch)
333
+ launchOnce(req, p.principalId, out.runId);
334
+ return noStore(reply).code(out.duplicate ? 200 : 202).send(CaptureRunResponseV1Schema.parse({
335
+ schemaVersion: SCHEMA_VERSION_V1, runId: out.runId, lifecycleState: out.lifecycleState, duplicate: out.duplicate, consent: out.consent, effectClass: out.effectClass,
336
+ }));
337
+ }
338
+ catch (e) {
339
+ return refusal(reply, req, e, 'capture.run');
340
+ }
341
+ });
342
+ app.post('/v1/workflow/current', async (req, reply) => {
343
+ const p = h.authenticate(req, reply);
344
+ if (!p)
345
+ return reply;
346
+ const body = WorkflowReadRequestV1Schema.safeParse(req.body);
347
+ if (!body.success)
348
+ return h.validationFail(reply, body.error);
349
+ if (body.data.watchOnly) {
350
+ const deadline = Date.now() + (body.data.timeoutMs ?? 0);
351
+ for (;;) {
352
+ if (!h.authenticate(req, reply))
353
+ return reply;
354
+ const revision = workflow.revision(p.principalId);
355
+ if (revision !== body.data.sinceRevision || Date.now() >= deadline || reply.raw.destroyed) {
356
+ return noStore(reply).send({ schemaVersion: 1, revision, changed: revision !== body.data.sinceRevision, observedAt: new Date().toISOString(), daemonVersion: '0.3.0' });
357
+ }
358
+ await sleep(120);
359
+ }
360
+ }
361
+ const current = workflow.current(p.principalId);
362
+ return noStore(reply).code(200).send(WorkflowCurrentResponseV1Schema.parse({ ...current, revision: workflow.revision(p.principalId, current), observedAt: new Date().toISOString(), daemonVersion: '0.3.0' }));
363
+ });
364
+ app.post('/v1/workflow/preference', async (req, reply) => {
365
+ const p = h.authenticate(req, reply);
366
+ if (!p)
367
+ return reply;
368
+ const body = WorkflowPreferenceRequestV1Schema.safeParse(req.body);
369
+ if (!body.success)
370
+ return h.validationFail(reply, body.error);
371
+ if (!workflow.setPreference(p.principalId, body.data))
372
+ return h.fail(reply, 403, 'GRANT_DENIED');
373
+ return noStore(reply).code(200).send({ schemaVersion: SCHEMA_VERSION_V1, ok: true });
374
+ });
375
+ app.post('/v1/workflow/dismiss', async (req, reply) => {
376
+ const p = h.authenticate(req, reply);
377
+ if (!p)
378
+ return reply;
379
+ const body = WorkflowDismissRequestV1Schema.safeParse(req.body);
380
+ if (!body.success)
381
+ return h.validationFail(reply, body.error);
382
+ return noStore(reply).code(200).send({ schemaVersion: SCHEMA_VERSION_V1, dismissed: workflow.dismiss(p.principalId, body.data.captureId) });
383
+ });
384
+ // SW-097: existing authenticated bounded long-poll transport; durable source cursors survive
385
+ // daemon/worker restart. Never reads another principal's run. No generic log endpoint.
386
+ app.post('/v1/runs/:runId/activity', async (req, reply) => {
387
+ const p = h.authenticate(req, reply);
388
+ if (!p)
389
+ return reply;
390
+ const body = ActivityRequestSchema.safeParse(req.body);
391
+ if (!body.success)
392
+ return h.validationFail(reply, body.error);
393
+ const { runId } = req.params;
394
+ const deadline = Date.now() + body.data.timeoutMs;
395
+ const daemonEvents = (deps.diag?.lifecycleHistory() ?? []).map(e => ({ id: `D:${createHash('sha256').update(`${e.ts}:${e.event}`).digest('hex').slice(0, 16)}`, ts: e.ts, component: 'C02', severity: 'INFO', status: 'OBSERVED', kind: e.event, summary: e.event, runId }));
396
+ try {
397
+ for (;;) {
398
+ // Re-authenticate while waiting so revocation/expiry also stops an outstanding subscription.
399
+ if (!h.authenticate(req, reply))
400
+ return reply;
401
+ const out = workflow.activity(p.principalId, runId, body.data.cursor);
402
+ if (out.cursor !== body.data.cursor || Date.now() >= deadline || reply.raw.destroyed) {
403
+ const response = { ...out, events: [...daemonEvents, ...out.events].sort((a, b) => a.ts.localeCompare(b.ts)).slice(-80) };
404
+ // UTF-8, rather than character count: multibyte process text must also fit the worker's transport ceiling.
405
+ while (Buffer.byteLength(JSON.stringify(response), 'utf8') > 48000 && response.events.length) {
406
+ response.events.shift();
407
+ response.truncated = true;
408
+ }
409
+ return noStore(reply).send(ActivityResponseSchema.parse(response));
410
+ }
411
+ await sleep(120);
412
+ }
413
+ }
414
+ catch (e) {
415
+ return refusal(reply, req, e, 'run.activity');
416
+ }
417
+ });
418
+ // Bounded long-poll: answers as soon as the run's updatedAt differs from the caller's, the run is terminal, or the timeout passes. Read-only.
419
+ app.post('/v1/runs/:runId/wait', async (req, reply) => {
420
+ const p = h.authenticate(req, reply);
421
+ if (!p)
422
+ return reply;
423
+ const body = RunWaitRequestV1Schema.safeParse(req.body);
424
+ if (!body.success)
425
+ return h.validationFail(reply, body.error);
426
+ const { runId } = req.params;
427
+ const deadline = Date.now() + body.data.timeoutMs;
428
+ for (;;) {
429
+ const run = coordinator.getStatus(p.principalId, runId);
430
+ if (!run)
431
+ return h.fail(reply, 404, 'NOT_FOUND');
432
+ if (run.updatedAt !== body.data.sinceUpdatedAt || workflow.isTerminal(run.lifecycleState) || Date.now() >= deadline || reply.raw.destroyed) {
433
+ return noStore(reply).code(200).send(RunStatusResponseV1Schema.parse({ schemaVersion: SCHEMA_VERSION_V1, runId: run.runId, lifecycleState: run.lifecycleState, createdAt: run.createdAt, updatedAt: run.updatedAt }));
434
+ }
435
+ await sleep(120);
436
+ }
437
+ });
438
+ app.post('/v1/returns/:returnId/receipt', async (req, reply) => {
439
+ const p = h.authenticate(req, reply);
440
+ if (!p)
441
+ return reply;
442
+ const body = ReturnReceiptRequestV1Schema.safeParse(req.body);
443
+ if (!body.success)
444
+ return h.validationFail(reply, body.error);
445
+ const { returnId } = req.params;
446
+ try {
447
+ const state = workflow.recordReceipt(p.principalId, returnId, body.data);
448
+ h.note(req, 'INFO', 'SNAPSHOT', 'return.receipt', `RETURN_${state}`, 'OK', { returnId, ...(body.data.code ? { failure: body.data.code } : {}) });
449
+ return noStore(reply).code(200).send({ schemaVersion: SCHEMA_VERSION_V1, returnId, state });
450
+ }
451
+ catch (e) {
452
+ return refusal(reply, req, e, 'return.receipt');
453
+ }
454
+ });
455
+ app.post('/v1/returns/:returnId/rebind', async (req, reply) => {
456
+ const p = h.authenticate(req, reply);
457
+ if (!p)
458
+ return reply;
459
+ const body = ReturnRebindRequestV1Schema.safeParse(req.body);
460
+ if (!body.success)
461
+ return h.validationFail(reply, body.error);
462
+ const { returnId } = req.params;
463
+ try {
464
+ const seq = workflow.rebind(p.principalId, returnId, body.data.sha256, body.data.binding);
465
+ h.note(req, 'INFO', 'SNAPSHOT', 'return.rebind', 'RETURN_REBOUND', 'OK', { returnId, target: seq });
466
+ return noStore(reply).code(200).send({ schemaVersion: SCHEMA_VERSION_V1, returnId, state: 'RETURN_READY', target: seq });
467
+ }
468
+ catch (e) {
469
+ return refusal(reply, req, e, 'return.rebind');
470
+ }
471
+ });
472
+ }
473
+ //# sourceMappingURL=workflowRoutes.js.map
@@ -0,0 +1,182 @@
1
+ import { type PrService } from '../../context/projectReadService.js';
2
+ /**
3
+ * SW-074 LOCAL PROJECT-READ MCP ADAPTER (stdio). This is NOT the optional ChatGPT-facing gateway (C10/M12): it opens no port, serves no remote client and is started only as a
4
+ * child of a coding-agent CLI by trusted configuration. It is an ADAPTER: every tools/call is passed to the C07 read service, which independently authorizes it against the
5
+ * run-scoped capability. A valid connection, an "auto-approved" tool annotation or a well-formed request confers nothing by itself.
6
+ *
7
+ * Transport: newline-delimited JSON-RPC 2.0 on stdin/stdout (MCP stdio). Bounded: one line is at most PR_LIMITS-derived 64 KiB; batches, binary framing and unknown methods are
8
+ * refused; stdout carries protocol messages only. Exposed surface: initialize, notifications/initialized, ping, tools/list, tools/call for exactly three read-only tools.
9
+ * No resources, prompts, sampling, logging, roots, completion, command execution, write or network tool exists in this process.
10
+ */
11
+ export declare const MCP_SERVER_NAME = "centcom-project-read";
12
+ export declare const MCP_SERVER_VERSION = "1.0.0";
13
+ export declare const MCP_SUPPORTED_VERSIONS: readonly ["2025-06-18", "2025-03-26", "2024-11-05"];
14
+ export declare const MCP_MAX_LINE_BYTES = 65536;
15
+ export declare const MCP_TOOL_DEFINITIONS: readonly ({
16
+ name: string;
17
+ title: string;
18
+ description: string;
19
+ inputSchema: {
20
+ type: string;
21
+ additionalProperties: boolean;
22
+ properties: {
23
+ path: {
24
+ description: string;
25
+ type: string;
26
+ minLength: number;
27
+ maxLength: 260;
28
+ };
29
+ limit: {
30
+ type: string;
31
+ minimum: number;
32
+ maximum: 200;
33
+ };
34
+ offset?: undefined;
35
+ max_bytes?: undefined;
36
+ };
37
+ required?: undefined;
38
+ };
39
+ annotations: {
40
+ readOnlyHint: boolean;
41
+ destructiveHint: boolean;
42
+ idempotentHint: boolean;
43
+ openWorldHint: boolean;
44
+ title: string;
45
+ };
46
+ } | {
47
+ name: string;
48
+ title: string;
49
+ description: string;
50
+ inputSchema: {
51
+ type: string;
52
+ additionalProperties: boolean;
53
+ required: string[];
54
+ properties: {
55
+ path: {
56
+ type: string;
57
+ minLength: number;
58
+ maxLength: 260;
59
+ description: string;
60
+ };
61
+ offset: {
62
+ type: string;
63
+ minimum: number;
64
+ maximum: 1048576;
65
+ description: string;
66
+ };
67
+ max_bytes: {
68
+ type: string;
69
+ minimum: number;
70
+ maximum: 32768;
71
+ };
72
+ limit?: undefined;
73
+ };
74
+ };
75
+ annotations: {
76
+ readOnlyHint: boolean;
77
+ destructiveHint: boolean;
78
+ idempotentHint: boolean;
79
+ openWorldHint: boolean;
80
+ title: string;
81
+ };
82
+ } | {
83
+ name: string;
84
+ title: string;
85
+ description: string;
86
+ inputSchema: {
87
+ type: string;
88
+ additionalProperties: boolean;
89
+ required: string[];
90
+ properties: {
91
+ path: {
92
+ type: string;
93
+ minLength: number;
94
+ maxLength: 260;
95
+ description: string;
96
+ };
97
+ limit?: undefined;
98
+ offset?: undefined;
99
+ max_bytes?: undefined;
100
+ };
101
+ };
102
+ annotations: {
103
+ readOnlyHint: boolean;
104
+ destructiveHint: boolean;
105
+ idempotentHint: boolean;
106
+ openWorldHint: boolean;
107
+ title: string;
108
+ };
109
+ })[];
110
+ /** SW-080: listed ONLY when the run's capability carries it (a PROPOSE grant authorized it). It records data; it can neither modify the project nor run anything. */
111
+ export declare const MCP_PROPOSE_TOOL_DEFINITION: Readonly<{
112
+ name: "propose_change";
113
+ title: "Propose a change";
114
+ description: "Submit ONE proposed code change for human review. The project is NOT modified. Each operation names a project-relative path; modify, delete and rename must carry the SHA-256 of the file as you last read it (get_project_file_metadata). Operations: create (path, content), modify (path, preimageSha256, content = the complete new file text), delete (path, preimageSha256), rename (path, to, preimageSha256). Files under tests/ and executable configuration such as package.json cannot be proposed.";
115
+ inputSchema: {
116
+ type: string;
117
+ additionalProperties: boolean;
118
+ required: string[];
119
+ properties: {
120
+ summary: {
121
+ type: string;
122
+ minLength: number;
123
+ maxLength: 500;
124
+ };
125
+ operations: {
126
+ type: string;
127
+ minItems: number;
128
+ maxItems: 20;
129
+ items: {
130
+ type: string;
131
+ required: string[];
132
+ properties: {
133
+ op: {
134
+ enum: string[];
135
+ };
136
+ path: {
137
+ type: string;
138
+ minLength: number;
139
+ maxLength: 260;
140
+ description: string;
141
+ };
142
+ to: {
143
+ type: string;
144
+ minLength: number;
145
+ maxLength: 260;
146
+ description: string;
147
+ };
148
+ preimageSha256: {
149
+ type: string;
150
+ pattern: string;
151
+ };
152
+ content: {
153
+ type: string;
154
+ maxLength: 65536;
155
+ };
156
+ };
157
+ };
158
+ };
159
+ };
160
+ };
161
+ annotations: {
162
+ title: string;
163
+ readOnlyHint: boolean;
164
+ destructiveHint: boolean;
165
+ idempotentHint: boolean;
166
+ openWorldHint: boolean;
167
+ };
168
+ }>;
169
+ type Out = (msg: unknown) => void;
170
+ export interface McpAdapter {
171
+ handleLine(line: string): void;
172
+ close(): void;
173
+ }
174
+ /** Pure protocol adapter over an injected read service and an injected output sink (the entry point wires stdin/stdout). */
175
+ export declare function createMcpAdapter(service: PrService, out: Out): McpAdapter;
176
+ /** Bounded newline framing: a line over the cap is discarded WITHOUT being buffered and reported once. */
177
+ export declare function createLineSplitter(max: number, onLine: (line: string) => void, onOversize: () => void): {
178
+ push(chunk: Buffer): void;
179
+ end(): void;
180
+ };
181
+ export {};
182
+ //# sourceMappingURL=localProjectReadServer.d.ts.map