@calliopelabs/cli 3.5.4 → 3.6.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 (291) hide show
  1. package/README.md +8 -0
  2. package/dist/acp.d.ts +10 -3
  3. package/dist/acp.d.ts.map +1 -1
  4. package/dist/acp.js +27 -7
  5. package/dist/acp.js.map +1 -1
  6. package/dist/bin.d.ts.map +1 -1
  7. package/dist/bin.js +28 -8
  8. package/dist/bin.js.map +1 -1
  9. package/dist/execution/authority.d.ts +4 -1
  10. package/dist/execution/authority.d.ts.map +1 -1
  11. package/dist/execution/authority.js +23 -7
  12. package/dist/execution/authority.js.map +1 -1
  13. package/dist/execution/child-grants.d.ts +2 -0
  14. package/dist/execution/child-grants.d.ts.map +1 -1
  15. package/dist/execution/child-grants.js +19 -4
  16. package/dist/execution/child-grants.js.map +1 -1
  17. package/dist/execution/delegated.d.ts +14 -0
  18. package/dist/execution/delegated.d.ts.map +1 -0
  19. package/dist/execution/delegated.js +66 -0
  20. package/dist/execution/delegated.js.map +1 -0
  21. package/dist/execution/files.js +6 -6
  22. package/dist/execution/files.js.map +1 -1
  23. package/dist/execution/guard.d.ts +5 -0
  24. package/dist/execution/guard.d.ts.map +1 -1
  25. package/dist/execution/guard.js +31 -16
  26. package/dist/execution/guard.js.map +1 -1
  27. package/dist/execution/index.d.ts +4 -0
  28. package/dist/execution/index.d.ts.map +1 -1
  29. package/dist/execution/index.js +4 -0
  30. package/dist/execution/index.js.map +1 -1
  31. package/dist/execution/ledger-cli.d.ts +2 -1
  32. package/dist/execution/ledger-cli.d.ts.map +1 -1
  33. package/dist/execution/ledger-cli.js +51 -14
  34. package/dist/execution/ledger-cli.js.map +1 -1
  35. package/dist/execution/ledger-protocol.d.ts +6 -2
  36. package/dist/execution/ledger-protocol.d.ts.map +1 -1
  37. package/dist/execution/ledger-protocol.js +110 -24
  38. package/dist/execution/ledger-protocol.js.map +1 -1
  39. package/dist/execution/ledger-server.d.ts +13 -0
  40. package/dist/execution/ledger-server.d.ts.map +1 -1
  41. package/dist/execution/ledger-server.js +57 -13
  42. package/dist/execution/ledger-server.js.map +1 -1
  43. package/dist/execution/ledger-tunnel.d.ts +50 -0
  44. package/dist/execution/ledger-tunnel.d.ts.map +1 -0
  45. package/dist/execution/ledger-tunnel.js +307 -0
  46. package/dist/execution/ledger-tunnel.js.map +1 -0
  47. package/dist/execution/ledger.d.ts +4 -0
  48. package/dist/execution/ledger.d.ts.map +1 -1
  49. package/dist/execution/ledger.js +30 -4
  50. package/dist/execution/ledger.js.map +1 -1
  51. package/dist/execution/parent-accounting.d.ts +41 -0
  52. package/dist/execution/parent-accounting.d.ts.map +1 -0
  53. package/dist/execution/parent-accounting.js +52 -0
  54. package/dist/execution/parent-accounting.js.map +1 -0
  55. package/dist/execution/parent-budget.d.ts +25 -0
  56. package/dist/execution/parent-budget.d.ts.map +1 -0
  57. package/dist/execution/parent-budget.js +102 -0
  58. package/dist/execution/parent-budget.js.map +1 -0
  59. package/dist/execution/project-spend.d.ts.map +1 -1
  60. package/dist/execution/project-spend.js +35 -5
  61. package/dist/execution/project-spend.js.map +1 -1
  62. package/dist/execution/remote-checkpoint.d.ts +15 -0
  63. package/dist/execution/remote-checkpoint.d.ts.map +1 -0
  64. package/dist/execution/remote-checkpoint.js +165 -0
  65. package/dist/execution/remote-checkpoint.js.map +1 -0
  66. package/dist/execution/remote-ledger.d.ts +12 -2
  67. package/dist/execution/remote-ledger.d.ts.map +1 -1
  68. package/dist/execution/remote-ledger.js +53 -21
  69. package/dist/execution/remote-ledger.js.map +1 -1
  70. package/dist/execution/types.d.ts +23 -5
  71. package/dist/execution/types.d.ts.map +1 -1
  72. package/dist/execution/types.js.map +1 -1
  73. package/dist/goals/supervised.js +2 -2
  74. package/dist/goals/supervised.js.map +1 -1
  75. package/dist/headless.d.ts +2 -6
  76. package/dist/headless.d.ts.map +1 -1
  77. package/dist/headless.js +17 -21
  78. package/dist/headless.js.map +1 -1
  79. package/dist/improvement/actions.d.ts +3 -4
  80. package/dist/improvement/actions.d.ts.map +1 -1
  81. package/dist/improvement/actions.js +10 -7
  82. package/dist/improvement/actions.js.map +1 -1
  83. package/dist/improvement/capabilities.d.ts +54 -0
  84. package/dist/improvement/capabilities.d.ts.map +1 -0
  85. package/dist/improvement/capabilities.js +44 -0
  86. package/dist/improvement/capabilities.js.map +1 -0
  87. package/dist/improvement/cli.d.ts +1 -1
  88. package/dist/improvement/cli.d.ts.map +1 -1
  89. package/dist/improvement/cli.js +14 -2
  90. package/dist/improvement/cli.js.map +1 -1
  91. package/dist/improvement/index.d.ts +5 -0
  92. package/dist/improvement/index.d.ts.map +1 -1
  93. package/dist/improvement/index.js +5 -0
  94. package/dist/improvement/index.js.map +1 -1
  95. package/dist/improvement/proposal-hash.d.ts +3 -0
  96. package/dist/improvement/proposal-hash.d.ts.map +1 -0
  97. package/dist/improvement/proposal-hash.js +5 -0
  98. package/dist/improvement/proposal-hash.js.map +1 -0
  99. package/dist/improvement/review-contract.d.ts +32 -0
  100. package/dist/improvement/review-contract.d.ts.map +1 -0
  101. package/dist/improvement/review-contract.js +62 -0
  102. package/dist/improvement/review-contract.js.map +1 -0
  103. package/dist/improvement/review-requests.d.ts +72 -0
  104. package/dist/improvement/review-requests.d.ts.map +1 -0
  105. package/dist/improvement/review-requests.js +63 -0
  106. package/dist/improvement/review-requests.js.map +1 -0
  107. package/dist/improvement/source-changes.d.ts +78 -0
  108. package/dist/improvement/source-changes.d.ts.map +1 -0
  109. package/dist/improvement/source-changes.js +91 -0
  110. package/dist/improvement/source-changes.js.map +1 -0
  111. package/dist/improvement/task-outcomes.d.ts +82 -0
  112. package/dist/improvement/task-outcomes.d.ts.map +1 -0
  113. package/dist/improvement/task-outcomes.js +72 -0
  114. package/dist/improvement/task-outcomes.js.map +1 -0
  115. package/dist/index.d.ts +10 -0
  116. package/dist/index.d.ts.map +1 -1
  117. package/dist/index.js +6 -0
  118. package/dist/index.js.map +1 -1
  119. package/dist/isolation/contracts.d.ts +13 -0
  120. package/dist/isolation/contracts.d.ts.map +1 -1
  121. package/dist/isolation/contracts.js +9 -1
  122. package/dist/isolation/contracts.js.map +1 -1
  123. package/dist/isolation/coordinator.d.ts.map +1 -1
  124. package/dist/isolation/coordinator.js +4 -0
  125. package/dist/isolation/coordinator.js.map +1 -1
  126. package/dist/isolation/process.d.ts.map +1 -1
  127. package/dist/isolation/process.js +3 -1
  128. package/dist/isolation/process.js.map +1 -1
  129. package/dist/isolation/worktree.d.ts +9 -1
  130. package/dist/isolation/worktree.d.ts.map +1 -1
  131. package/dist/isolation/worktree.js +8 -3
  132. package/dist/isolation/worktree.js.map +1 -1
  133. package/dist/memory.d.ts +5 -3
  134. package/dist/memory.d.ts.map +1 -1
  135. package/dist/memory.js +8 -6
  136. package/dist/memory.js.map +1 -1
  137. package/dist/migration/assessment-contract.d.ts +60 -0
  138. package/dist/migration/assessment-contract.d.ts.map +1 -0
  139. package/dist/migration/assessment-contract.js +132 -0
  140. package/dist/migration/assessment-contract.js.map +1 -0
  141. package/dist/migration/assessment-schema.d.ts +19 -0
  142. package/dist/migration/assessment-schema.d.ts.map +1 -0
  143. package/dist/migration/assessment-schema.js +43 -0
  144. package/dist/migration/assessment-schema.js.map +1 -0
  145. package/dist/migration/assessment.d.ts +159 -0
  146. package/dist/migration/assessment.d.ts.map +1 -0
  147. package/dist/migration/assessment.js +219 -0
  148. package/dist/migration/assessment.js.map +1 -0
  149. package/dist/migration/cli.d.ts +6 -0
  150. package/dist/migration/cli.d.ts.map +1 -0
  151. package/dist/migration/cli.js +101 -0
  152. package/dist/migration/cli.js.map +1 -0
  153. package/dist/migration/evidence.d.ts +27 -0
  154. package/dist/migration/evidence.d.ts.map +1 -0
  155. package/dist/migration/evidence.js +124 -0
  156. package/dist/migration/evidence.js.map +1 -0
  157. package/dist/migration/example.d.ts +33 -0
  158. package/dist/migration/example.d.ts.map +1 -0
  159. package/dist/migration/example.js +28 -0
  160. package/dist/migration/example.js.map +1 -0
  161. package/dist/migration/index.d.ts +21 -0
  162. package/dist/migration/index.d.ts.map +1 -0
  163. package/dist/migration/index.js +15 -0
  164. package/dist/migration/index.js.map +1 -0
  165. package/dist/migration/inventory.d.ts +70 -0
  166. package/dist/migration/inventory.d.ts.map +1 -0
  167. package/dist/migration/inventory.js +233 -0
  168. package/dist/migration/inventory.js.map +1 -0
  169. package/dist/migration/schema.d.ts +61 -0
  170. package/dist/migration/schema.d.ts.map +1 -0
  171. package/dist/migration/schema.js +76 -0
  172. package/dist/migration/schema.js.map +1 -0
  173. package/dist/migration/verification.d.ts +146 -0
  174. package/dist/migration/verification.d.ts.map +1 -0
  175. package/dist/migration/verification.js +260 -0
  176. package/dist/migration/verification.js.map +1 -0
  177. package/dist/orchestration/actions.d.ts +2 -0
  178. package/dist/orchestration/actions.d.ts.map +1 -1
  179. package/dist/orchestration/actions.js.map +1 -1
  180. package/dist/orchestration/artifact-host.d.ts +46 -0
  181. package/dist/orchestration/artifact-host.d.ts.map +1 -0
  182. package/dist/orchestration/artifact-host.js +64 -0
  183. package/dist/orchestration/artifact-host.js.map +1 -0
  184. package/dist/orchestration/coordinator-actions.d.ts +1 -1
  185. package/dist/orchestration/coordinator-actions.d.ts.map +1 -1
  186. package/dist/orchestration/coordinator-actions.js +5 -3
  187. package/dist/orchestration/coordinator-actions.js.map +1 -1
  188. package/dist/orchestration/coordinator-types.d.ts +23 -2
  189. package/dist/orchestration/coordinator-types.d.ts.map +1 -1
  190. package/dist/orchestration/coordinator.d.ts +5 -0
  191. package/dist/orchestration/coordinator.d.ts.map +1 -1
  192. package/dist/orchestration/coordinator.js +30 -13
  193. package/dist/orchestration/coordinator.js.map +1 -1
  194. package/dist/orchestration/execution-cli.d.ts +1 -1
  195. package/dist/orchestration/execution-cli.d.ts.map +1 -1
  196. package/dist/orchestration/execution-cli.js +29 -6
  197. package/dist/orchestration/execution-cli.js.map +1 -1
  198. package/dist/orchestration/execution-journal.d.ts.map +1 -1
  199. package/dist/orchestration/execution-journal.js +79 -6
  200. package/dist/orchestration/execution-journal.js.map +1 -1
  201. package/dist/orchestration/execution-store.d.ts +5 -1
  202. package/dist/orchestration/execution-store.d.ts.map +1 -1
  203. package/dist/orchestration/execution-store.js +66 -5
  204. package/dist/orchestration/execution-store.js.map +1 -1
  205. package/dist/orchestration/execution.d.ts.map +1 -1
  206. package/dist/orchestration/execution.js +37 -10
  207. package/dist/orchestration/execution.js.map +1 -1
  208. package/dist/orchestration/index.d.ts +6 -0
  209. package/dist/orchestration/index.d.ts.map +1 -1
  210. package/dist/orchestration/index.js +6 -0
  211. package/dist/orchestration/index.js.map +1 -1
  212. package/dist/orchestration/interruption.d.ts +10 -0
  213. package/dist/orchestration/interruption.d.ts.map +1 -0
  214. package/dist/orchestration/interruption.js +38 -0
  215. package/dist/orchestration/interruption.js.map +1 -0
  216. package/dist/orchestration/question-contract.d.ts +19 -0
  217. package/dist/orchestration/question-contract.d.ts.map +1 -0
  218. package/dist/orchestration/question-contract.js +21 -0
  219. package/dist/orchestration/question-contract.js.map +1 -0
  220. package/dist/orchestration/questions.d.ts +9 -0
  221. package/dist/orchestration/questions.d.ts.map +1 -0
  222. package/dist/orchestration/questions.js +75 -0
  223. package/dist/orchestration/questions.js.map +1 -0
  224. package/dist/orchestration/reviewed-ledger.d.ts +23 -0
  225. package/dist/orchestration/reviewed-ledger.d.ts.map +1 -0
  226. package/dist/orchestration/reviewed-ledger.js +49 -0
  227. package/dist/orchestration/reviewed-ledger.js.map +1 -0
  228. package/dist/orchestration/source-candidates.d.ts +64 -0
  229. package/dist/orchestration/source-candidates.d.ts.map +1 -0
  230. package/dist/orchestration/source-candidates.js +95 -0
  231. package/dist/orchestration/source-candidates.js.map +1 -0
  232. package/dist/orchestration/validation.js +1 -1
  233. package/dist/orchestration/validation.js.map +1 -1
  234. package/dist/runlog.js +2 -2
  235. package/dist/runlog.js.map +1 -1
  236. package/dist/runtime/permissions.d.ts.map +1 -1
  237. package/dist/runtime/permissions.js +3 -2
  238. package/dist/runtime/permissions.js.map +1 -1
  239. package/dist/runtime/turn.d.ts +2 -0
  240. package/dist/runtime/turn.d.ts.map +1 -1
  241. package/dist/runtime/turn.js +21 -7
  242. package/dist/runtime/turn.js.map +1 -1
  243. package/dist/session-management/actions.js +1 -1
  244. package/dist/session-management/actions.js.map +1 -1
  245. package/dist/sessions/execution-binding.d.ts +8 -0
  246. package/dist/sessions/execution-binding.d.ts.map +1 -0
  247. package/dist/sessions/execution-binding.js +9 -0
  248. package/dist/sessions/execution-binding.js.map +1 -0
  249. package/dist/sessions/index.d.ts +1 -0
  250. package/dist/sessions/index.d.ts.map +1 -1
  251. package/dist/sessions/index.js +1 -0
  252. package/dist/sessions/index.js.map +1 -1
  253. package/dist/source-changes/writer.d.ts +77 -0
  254. package/dist/source-changes/writer.d.ts.map +1 -0
  255. package/dist/source-changes/writer.js +189 -0
  256. package/dist/source-changes/writer.js.map +1 -0
  257. package/dist/spawning/actions.d.ts +10 -1
  258. package/dist/spawning/actions.d.ts.map +1 -1
  259. package/dist/spawning/actions.js +26 -7
  260. package/dist/spawning/actions.js.map +1 -1
  261. package/dist/spawning/cli.js +1 -1
  262. package/dist/spawning/cli.js.map +1 -1
  263. package/dist/spawning/execution.d.ts.map +1 -1
  264. package/dist/spawning/execution.js +2 -0
  265. package/dist/spawning/execution.js.map +1 -1
  266. package/dist/spawning/types.d.ts +19 -6
  267. package/dist/spawning/types.d.ts.map +1 -1
  268. package/dist/spawning/validation.d.ts +16 -0
  269. package/dist/spawning/validation.d.ts.map +1 -1
  270. package/dist/spawning/validation.js +44 -8
  271. package/dist/spawning/validation.js.map +1 -1
  272. package/dist/storage.d.ts +3 -0
  273. package/dist/storage.d.ts.map +1 -1
  274. package/dist/storage.js +6 -1
  275. package/dist/storage.js.map +1 -1
  276. package/dist/supervision/contracts.js +4 -1
  277. package/dist/supervision/contracts.js.map +1 -1
  278. package/dist/tools.d.ts +1 -0
  279. package/dist/tools.d.ts.map +1 -1
  280. package/dist/tools.js +5 -0
  281. package/dist/tools.js.map +1 -1
  282. package/docs/README.md +66 -0
  283. package/docs/delegation-ledger.md +329 -0
  284. package/docs/migration-assessment.md +113 -0
  285. package/docs/migration-example-plan.json +88 -0
  286. package/docs/migration-example-report.json +511 -0
  287. package/docs/migration-inventory.md +63 -0
  288. package/docs/migration-playbook.md +152 -0
  289. package/docs/migration-verification.md +177 -0
  290. package/docs/releases/3.6.0.md +43 -0
  291. package/package.json +7 -2
@@ -0,0 +1,38 @@
1
+ import { authorizeSessionAction } from '../session-management/index.js';
2
+ import { inspectExecution } from './coordinator-actions.js';
3
+ import { RunStore } from './store.js';
4
+ import { OrchestrationError } from './types.js';
5
+ export function interruptionRecoveryCapabilities() {
6
+ return { version: 1, owner: 'calliope-cli', eventVersion: 10, semantics: 'record-interruption-without-execution' };
7
+ }
8
+ /** Record a confirmed dead coordinator without retrying work or settling charges. */
9
+ export async function recoverInterruptedExecution(cwd, runId, revision, options = {}) {
10
+ const initial = await inspectExecution(cwd, runId, options), { store, execution, owner } = initial;
11
+ if (typeof revision !== 'string' || !/^[a-f0-9]{64}$/.test(revision))
12
+ throw new OrchestrationError('invalid', 'Recovery requires the observed execution revision.');
13
+ if (!execution || execution.state.status !== 'running' || !execution.state.ownerId || !owner || owner.alive || owner.id !== execution.state.ownerId)
14
+ throw new OrchestrationError('conflict', 'Recovery requires a confirmed dead matching coordinator.');
15
+ store.assertRevision(revision);
16
+ store.assertApproval(execution.header);
17
+ const authority = initial.view.manifest.version === 2 ? (await import('../goals/index.js')).goalRunAuthority(initial.view.manifest, (options.store ?? new RunStore()).root) : undefined;
18
+ authority?.assertActive();
19
+ await authorizeSessionAction(cwd, 'orchestration_recover', { path: cwd, runId, revision, ownerId: owner.id,
20
+ planHash: execution.state.graph?.hash ?? initial.view.manifest.planHash, operation: 'Record interrupted work without execution, retry or budget settlement.' }, options);
21
+ const currentOwner = store.owner();
22
+ if (!currentOwner || currentOwner.alive || currentOwner.id !== owner.id || currentOwner.pid !== owner.pid)
23
+ throw new OrchestrationError('conflict', 'Coordinator ownership changed during recovery review.');
24
+ const lease = store.acquire();
25
+ try {
26
+ await store.append({ type: 'interruption_recovered', ownerId: owner.id, source: options.source === 'repl' ? 'repl' : 'cli' }, options.signal, undefined, () => {
27
+ lease.check();
28
+ store.assertRevision(revision);
29
+ store.assertApproval(execution.header);
30
+ authority?.assertActive();
31
+ });
32
+ return store.read();
33
+ }
34
+ finally {
35
+ lease.release();
36
+ }
37
+ }
38
+ //# sourceMappingURL=interruption.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interruption.js","sourceRoot":"","sources":["../../src/orchestration/interruption.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sBAAsB,EAAC,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,kBAAkB,EAAC,MAAM,YAAY,CAAC;AAG9C,MAAM,UAAU,gCAAgC;IAC9C,OAAO,EAAC,OAAO,EAAC,CAAC,EAAC,KAAK,EAAC,cAAc,EAAC,YAAY,EAAC,EAAE,EAAC,SAAS,EAAC,uCAAuC,EAAU,CAAC;AACrH,CAAC;AAED,qFAAqF;AACrF,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,GAAU,EAAC,KAAY,EAAC,QAAe,EAAC,OAAO,GAAkB,EAAE;IACnH,MAAM,OAAO,GAAC,MAAM,gBAAgB,CAAC,GAAG,EAAC,KAAK,EAAC,OAAO,CAAC,EAAC,EAAC,KAAK,EAAC,SAAS,EAAC,KAAK,EAAC,GAAC,OAAO,CAAC;IACxF,IAAG,OAAO,QAAQ,KAAG,QAAQ,IAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC;QAAC,MAAM,IAAI,kBAAkB,CAAC,SAAS,EAAC,oDAAoD,CAAC,CAAC;IAC7J,IAAG,CAAC,SAAS,IAAE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AkB,CAAC,UAAU,EAAC,uDAAuD,CAAC,CAAC;IACnG,MAAM,KAAK,GAAC,KAAK,CAAC,OAAO,EAAE,CAAC;IAC5B,IAAI,CAAC;QACH,MAAM,KAAK,CAAC,MAAM,CAAC,EAAC,IAAI,EAAC,wBAAwB,EAAC,OAAO,EAAC,KAAK,CAAC,EAAE,EAAC,MAAM,EAAC,OAAO,CAAC,MAAM,KAAG,MAAM,CAAA,CAAC,CAAA,MAAM,CAAA,CAAC,CAAA,KAAK,EAAC,EAAC,OAAO,CAAC,MAAM,EAAC,SAAS,EAAC,GAAE,EAAE;YAC3I,KAAK,CAAC,KAAK,EAAE,CAAC;YAAA,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;YAAA,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YAAA,SAAS,EAAE,YAAY,EAAE,CAAC;QAChH,CAAC,CAAC,CAAC;QACH,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC;YAAO,CAAC;QAAA,KAAK,CAAC,OAAO,EAAE,CAAC;IAAA,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,19 @@
1
+ /** A question is input to one tool call, never an expansion of its authority. */
2
+ export interface ExecutionQuestionRequest {
3
+ id: string;
4
+ ownerId: string;
5
+ attempt: number;
6
+ sessionId: string;
7
+ callId: string;
8
+ text: string;
9
+ options: string[];
10
+ context: string | null;
11
+ }
12
+ export interface ExecutionQuestion extends ExecutionQuestionRequest {
13
+ taskId: string;
14
+ status: 'pending' | 'answered' | 'closed';
15
+ answer: string | null;
16
+ }
17
+ export declare function validateQuestionRequest(value: unknown): asserts value is ExecutionQuestionRequest;
18
+ export declare function validateQuestionAnswer(value: unknown): asserts value is string;
19
+ //# sourceMappingURL=question-contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"question-contract.d.ts","sourceRoot":"","sources":["../../src/orchestration/question-contract.ts"],"names":[],"mappings":"AAEA,iFAAiF;AACjF,MAAM,WAAW,wBAAwB;IACvC,EAAE,EAAC,MAAM,CAAC;IAAA,OAAO,EAAC,MAAM,CAAC;IAAA,OAAO,EAAC,MAAM,CAAC;IAAA,SAAS,EAAC,MAAM,CAAC;IAAA,MAAM,EAAC,MAAM,CAAC;IACvE,IAAI,EAAC,MAAM,CAAC;IAAA,OAAO,EAAC,MAAM,EAAE,CAAC;IAAA,OAAO,EAAC,MAAM,GAAC,IAAI,CAAC;CAClD;AACD,MAAM,WAAW,iBAAkB,SAAQ,wBAAwB;IACjE,MAAM,EAAC,MAAM,CAAC;IAAA,MAAM,EAAC,SAAS,GAAC,UAAU,GAAC,QAAQ,CAAC;IAAA,MAAM,EAAC,MAAM,GAAC,IAAI,CAAC;CACvE;AACD,wBAAgB,uBAAuB,CAAC,KAAK,EAAC,OAAO,GAAE,OAAO,CAAC,KAAK,IAAI,wBAAwB,CAQ/F;AACD,wBAAgB,sBAAsB,CAAC,KAAK,EAAC,OAAO,GAAE,OAAO,CAAC,KAAK,IAAI,MAAM,CAAoB"}
@@ -0,0 +1,21 @@
1
+ import { array, fail, integer, shape, text, uuid } from './validation.js';
2
+ export function validateQuestionRequest(value) {
3
+ shape(value, ['id', 'ownerId', 'attempt', 'sessionId', 'callId', 'text', 'options', 'context']);
4
+ if (!uuid(value.id) || !uuid(value.ownerId))
5
+ fail('Invalid question request identity.');
6
+ integer(value.attempt, 1, 4);
7
+ text(value.sessionId, 128);
8
+ text(value.callId, 256);
9
+ if (!/^[a-zA-Z0-9_-]+$/.test(value.sessionId))
10
+ fail('Invalid question session.');
11
+ text(value.text, 8192);
12
+ array(value.options, 8);
13
+ for (const option of value.options)
14
+ text(option, 256);
15
+ if (new Set(value.options).size !== value.options.length)
16
+ fail('Question options must be distinct.');
17
+ if (value.context !== null)
18
+ text(value.context, 8192);
19
+ }
20
+ export function validateQuestionAnswer(value) { text(value, 8192); }
21
+ //# sourceMappingURL=question-contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"question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EAAC,IAAI,CAAC,CAAC;AACnD,CAAC;AACD,MAAM,UAAU,sBAAsB,CAAC,KAAa,IAA2B,IAAI,CAAC,KAAK,EAAC,IAAI,CAAC,CAAC,CAAA,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { ToolCall } from '../types.js';
2
+ import type { RunActionOptions } from './actions.js';
3
+ import type { ExecutionInspection } from './coordinator-types.js';
4
+ import type { ExecutionStore } from './execution-store.js';
5
+ /** The coordinator retains its lease and active task slot throughout this wait. */
6
+ export declare function waitForExecutionAnswer(store: ExecutionStore, taskId: string, call: ToolCall, signal: AbortSignal | undefined, assertAuthority: () => void): Promise<string>;
7
+ /** Answer one inspected request under current policy and the journal writer lock. */
8
+ export declare function answerExecutionQuestion(cwd: string, runId: string, questionId: string, revision: string, answer: string, options?: RunActionOptions): Promise<ExecutionInspection>;
9
+ //# sourceMappingURL=questions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"questions.d.ts","sourceRoot":"","sources":["../../src/orchestration/questions.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,wBAAwB,CAAC;AAGhE,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAczD,mFAAmF;AACnF,wBAAsB,sBAAsB,CAAC,KAAK,EAAC,cAAc,EAAC,MAAM,EAAC,MAAM,EAAC,IAAI,EAAC,QAAQ,EAAC,MAAM,EAAC,WAAW,GAAC,SAAS,EAAC,eAAe,EAAC,MAAI,IAAI,GAAE,OAAO,CAAC,MAAM,CAAC,CAiBnK;AAED,qFAAqF;AACrF,wBAAsB,uBAAuB,CAAC,GAAG,EAAC,MAAM,EAAC,KAAK,EAAC,MAAM,EAAC,UAAU,EAAC,MAAM,EAAC,QAAQ,EAAC,MAAM,EAAC,MAAM,EAAC,MAAM,EAAC,OAAO,GAAC,gBAAmB,gCAqBhJ"}
@@ -0,0 +1,75 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { dirname } from 'node:path';
3
+ import { canonicalJson, describeApproval, digest } from '../approvals/index.js';
4
+ import { cancellableDelay, throwIfCancelled } from '../cancellation.js';
5
+ import { authorizeSessionAction } from '../session-management/index.js';
6
+ import { withScope } from '../scope.js';
7
+ import { inspectExecution } from './coordinator-actions.js';
8
+ import { agentStopped } from './execution-journal.js';
9
+ import { validateQuestionRequest, validateQuestionAnswer } from './question-contract.js';
10
+ import { OrchestrationError } from './types.js';
11
+ import { hex, shape, uuid } from './validation.js';
12
+ function pendingQuestion(store, execution, id) {
13
+ const q = execution.state.questions?.[id], owner = store.owner();
14
+ if (!q || q.status !== 'pending' || !owner?.alive || owner.id !== q.ownerId || execution.state.ownerId !== q.ownerId)
15
+ throw new OrchestrationError('conflict', 'Question has no live waiting coordinator; inspect its task before recovery.');
16
+ const task = execution.state.tasks[q.taskId], context = store.context(execution), agent = context.plan.agents.find(a => a.id === task.agentId);
17
+ if (task.status !== 'running' || task.sessionId !== q.sessionId || task.attempts !== q.attempt || agentStopped(execution.state, context, agent.id) || Date.now() >= Math.min(execution.header.deadline, Date.parse(execution.header.createdAt) + agent.timeBudgetMs))
18
+ throw new OrchestrationError('conflict', 'Question task stopped or its original deadline expired.');
19
+ store.assertApproval(execution.header);
20
+ return q;
21
+ }
22
+ /** The coordinator retains its lease and active task slot throughout this wait. */
23
+ export async function waitForExecutionAnswer(store, taskId, call, signal, assertAuthority) {
24
+ throwIfCancelled(signal);
25
+ assertAuthority();
26
+ if (call.name !== 'ask_question')
27
+ throw new OrchestrationError('invalid', 'Only ask_question can wait for a question answer.');
28
+ shape(call.arguments, ['question'], ['options', 'context']);
29
+ const state = store.read().state, task = state.tasks[taskId];
30
+ if (!task?.sessionId || !state.ownerId)
31
+ throw new OrchestrationError('conflict', 'Question has no active task session.');
32
+ const request = { id: randomUUID(), ownerId: state.ownerId, attempt: task.attempts, sessionId: task.sessionId, callId: call.id,
33
+ text: call.arguments.question, options: (call.arguments.options ?? []), context: (call.arguments.context ?? null) };
34
+ validateQuestionRequest(request);
35
+ await store.append({ type: 'question_asked', taskId, request }, signal, undefined, assertAuthority);
36
+ for (;;) {
37
+ throwIfCancelled(signal);
38
+ assertAuthority();
39
+ const execution = store.read(), q = execution.state.questions?.[request.id];
40
+ if (q?.status === 'answered' && q.answer !== null)
41
+ return q.answer;
42
+ pendingQuestion(store, execution, request.id);
43
+ await cancellableDelay(100, signal);
44
+ }
45
+ }
46
+ /** Answer one inspected request under current policy and the journal writer lock. */
47
+ export async function answerExecutionQuestion(cwd, runId, questionId, revision, answer, options = {}) {
48
+ if (!uuid(questionId) || !hex(revision))
49
+ throw new OrchestrationError('invalid', 'Answer requires the exact question ID and inspected execution revision.');
50
+ validateQuestionAnswer(answer);
51
+ const initial = await inspectExecution(cwd, runId, options), { store, view } = initial;
52
+ if (!initial.execution)
53
+ throw new OrchestrationError('unavailable', 'Run has no execution history.');
54
+ if (initial.execution.state.revision !== revision)
55
+ throw new OrchestrationError('conflict', 'Execution changed; inspect the pending question again.');
56
+ const q = pendingQuestion(store, initial.execution, questionId);
57
+ const goalAuthority = view.manifest.version === 2 ? (await import('../goals/index.js')).goalRunAuthority(view.manifest, dirname(dirname(store.root))) : undefined;
58
+ const permissionCall = { id: questionId, name: 'orchestration_answer', arguments: { path: cwd, runId, questionId, revision, taskId: q.taskId, sessionId: q.sessionId, attempt: q.attempt, callId: q.callId, ownerId: q.ownerId,
59
+ planHash: initial.execution.state.graph?.hash ?? view.manifest.planHash, questionHash: digest(canonicalJson(q)), answerHash: digest(answer) } };
60
+ const permissionKey = () => withScope(cwd, () => describeApproval(permissionCall, cwd).key), approvedKey = permissionKey();
61
+ const assertAuthority = () => {
62
+ throwIfCancelled(options.signal);
63
+ goalAuthority?.assertActive();
64
+ const current = store.read();
65
+ if (current.state.revision !== revision)
66
+ throw new OrchestrationError('conflict', 'Execution changed during the answer decision.');
67
+ pendingQuestion(store, current, questionId);
68
+ if (permissionKey() !== approvedKey)
69
+ throw new OrchestrationError('policy-denied', 'Question answer scope or policy changed before commit.');
70
+ };
71
+ await authorizeSessionAction(cwd, permissionCall.name, permissionCall.arguments, { ...options, confirmation: options.confirmation ?? 'mutating' });
72
+ await store.append({ type: 'question_answered', taskId: q.taskId, questionId, answer }, options.signal, undefined, assertAuthority);
73
+ return store.read();
74
+ }
75
+ //# sourceMappingURL=questions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"questions.js","sourceRoot":"","sources":["../../src/orchestration/questions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AACvC,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,aAAa,EAAC,gBAAgB,EAAC,MAAM,EAAC,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAC,gBAAgB,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAC,sBAAsB,EAAC,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAItC,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAC,uBAAuB,EAAC,sBAAsB,EAA+B,MAAM,wBAAwB,CAAC;AACpH,OAAO,EAAC,kBAAkB,EAAC,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAC,GAAG,EAAC,KAAK,EAAC,IAAI,EAAC,MAAM,iBAAiB,CAAC;AAE/C,SAAS,eAAe,CAAC,KAAoB,EAAC,SAA6B,EAAC,EAAS;IACnF,MAAM,CAAC,GAAC,SAAS,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC,EAAC,KAAK,GAAC,KAAK,CAAC,KAAK,EAAE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AA+C,CAAC,CAAC;QAC9H,eAAe,CAAC,KAAK,EAAC,OAAO,EAAC,UAAU,CAAC,CAAC;QAC1C,IAAG,aAAa,EAAE,KAAG,WAAW;YAAC,MAAM,IAAI,kBAAkB,CAAC,eAAe,EAAC,wDAAwD,CAAC,CAAC;IAC1I,CAAC,CAAC;IACF,MAAM,sBAAsB,CAAC,GAAG,EAAC,cAAc,CAAC,IAAI,EAAC,cAAc,CAAC,SAAS,EAAC,EAAC,GAAG,OAAO,EAAC,YAAY,EAAC,OAAO,CAAC,YAAY,IAAE,UAAU,EAAC,CAAC,CAAC;IAC1I,MAAM,KAAK,CAAC,MAAM,CAAC,EAAC,IAAI,EAAC,mBAAmB,EAAC,MAAM,EAAC,CAAC,CAAC,MAAM,EAAC,UAAU,EAAC,MAAM,EAAC,EAAC,OAAO,CAAC,MAAM,EAAC,SAAS,EAAC,eAAe,CAAC,CAAC;IAC1H,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC;AACtB,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { RunActionOptions } from './actions.js';
2
+ export declare const REVIEWED_LEDGER_CAPABILITY: {
3
+ readonly version: 1;
4
+ readonly ownerScope: 1;
5
+ readonly tokenVersion: 2;
6
+ readonly reviewedAuthority: 1;
7
+ readonly grants: 'native-admissions-only';
8
+ };
9
+ /** Returns an unbound server and a private owner token. Only the trusted host listens or delivers credentials. */
10
+ export declare function prepareReviewedLedger(cwd: string, runId: string, agentId: string, maxOutputTokens: number, options?: RunActionOptions): Promise<{
11
+ server: import("node:http").Server<typeof import("node:http").IncomingMessage, typeof import("node:http").ServerResponse>;
12
+ ownerToken: string;
13
+ execution: import("../execution/guard.js").AgentExecution;
14
+ deadline: number;
15
+ capability: {
16
+ readonly version: 1;
17
+ readonly ownerScope: 1;
18
+ readonly tokenVersion: 2;
19
+ readonly reviewedAuthority: 1;
20
+ readonly grants: 'native-admissions-only';
21
+ };
22
+ }>;
23
+ //# sourceMappingURL=reviewed-ledger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reviewed-ledger.d.ts","sourceRoot":"","sources":["../../src/orchestration/reviewed-ledger.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAEnD,eAAO,MAAM,0BAA0B;aAAE,OAAO,EAAC,CAAC;aAAC,UAAU,EAAC,CAAC;aAAC,YAAY,EAAC,CAAC;aAAC,iBAAiB,EAAC,CAAC;aAAC,MAAM,EAAC,wBAAwB;CAAU,CAAC;AAE7I,kHAAkH;AAClH,wBAAsB,qBAAqB,CAAC,GAAG,EAAC,MAAM,EAAC,KAAK,EAAC,MAAM,EAAC,OAAO,EAAC,MAAM,EAAC,eAAe,EAAC,MAAM,EAAC,OAAO,GAAC,gBAAmB;;;;;;0BAHpF,CAAC;6BAAY,CAAC;+BAAc,CAAC;oCAAmB,CAAC;yBAAQ,wBAAwB;;GA6BjI"}
@@ -0,0 +1,49 @@
1
+ /** Host an existing reviewed allowance; native graph admission remains the only writer of children. */
2
+ import { dirname, join } from 'node:path';
3
+ import { canonicalJson, digest } from '../approvals/index.js';
4
+ import { throwIfCancelled } from '../cancellation.js';
5
+ import { accountLineage } from '../execution/authority.js';
6
+ import { effectiveExecutionManifest } from '../execution/child-grants.js';
7
+ import { createLedgerServer } from '../execution/ledger-server.js';
8
+ import { LedgerServerState, mintLedgerToken } from '../execution/ledger-protocol.js';
9
+ import { ExecutionLimitError } from '../execution/types.js';
10
+ import { inspectSpawnAuthority } from '../spawning/authority.js';
11
+ import { RunStore } from './store.js';
12
+ import { ExecutionStore } from './execution-store.js';
13
+ import { agentStopped } from './execution-journal.js';
14
+ import { prepareAgentExecution } from './execution.js';
15
+ export const REVIEWED_LEDGER_CAPABILITY = { version: 1, ownerScope: 1, tokenVersion: 2, reviewedAuthority: 1, grants: 'native-admissions-only' };
16
+ /** Returns an unbound server and a private owner token. Only the trusted host listens or delivers credentials. */
17
+ export async function prepareReviewedLedger(cwd, runId, agentId, maxOutputTokens, options = {}) {
18
+ const runs = options.store ?? new RunStore(), execution = await prepareAgentExecution(cwd, runId, agentId, maxOutputTokens, { ...options, store: runs });
19
+ const ledger = execution.ledger, view = await runs.read(runId, cwd, options.signal), history = new ExecutionStore(join(runs.root, runId), view.manifest);
20
+ const assertOwner = () => { throwIfCancelled(options.signal); execution.assertAuthority(); };
21
+ const assertAccount = (id) => {
22
+ assertOwner();
23
+ const current = history.exists() ? inspectSpawnAuthority(history, ledger) : undefined, context = current?.context ?? view.manifest;
24
+ if (!context.plan.agents.some(agent => agent.id === id) || current && agentStopped(current.view.state, context, id))
25
+ throw new ExecutionLimitError('authority', 'Account is not active in the reviewed native graph.');
26
+ };
27
+ const assertGrant = (grant) => {
28
+ assertOwner();
29
+ const admitted = history.exists() ? inspectSpawnAuthority(history, ledger).view.state.graph?.admissions.find(entry => entry.grant.grant.id === grant.id) : undefined;
30
+ if (!admitted || canonicalJson(admitted.grant.grant) !== canonicalJson(grant))
31
+ throw new ExecutionLimitError('authority', 'Child grant requires its existing native reviewed admission.');
32
+ for (const account of grant.accounts)
33
+ assertAccount(account.id);
34
+ };
35
+ assertAccount(agentId);
36
+ const saved = ledger.read(cwd), effective = effectiveExecutionManifest(saved.manifest, saved.projection), deadline = Math.min(...accountLineage(effective, agentId).map(account => account.deadline));
37
+ if (Date.now() >= deadline)
38
+ throw new ExecutionLimitError('deadline', 'Original owner allowance expired.');
39
+ history.create({ version: 1, runId, manifestHash: view.manifest.hash, approvalRevision: view.run.revision, createdAt: new Date(saved.manifest.createdAt).toISOString(), deadline: saved.manifest.deadline });
40
+ assertAccount(agentId);
41
+ const authority = digest(canonicalJson({ version: 1, runId, manifestHash: view.manifest.hash, approvalRevision: view.run.revision }));
42
+ const state = new LedgerServerState(join(dirname(ledger.root), `${runId}.ledger-server`));
43
+ const server = createLedgerServer({ ledger, cwd, state, ownerAgentId: agentId, authority, assertAuthority: assertOwner, assertAccountAuthority: assertAccount, assertGrantAuthority: assertGrant,
44
+ assertReservationAuthority: reservation => { if (reservation.outputTokens > maxOutputTokens)
45
+ throw new ExecutionLimitError('budget', 'Request exceeds the reviewed host output limit.'); } });
46
+ const ownerToken = mintLedgerToken(state.secret(), { v: 2, authority, run: runId, role: 'parent', owner: agentId, exp: deadline });
47
+ return { server, ownerToken, execution, deadline, capability: REVIEWED_LEDGER_CAPABILITY };
48
+ }
49
+ //# sourceMappingURL=reviewed-ledger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reviewed-ledger.js","sourceRoot":"","sources":["../../src/orchestration/reviewed-ledger.ts"],"names":[],"mappings":"AAAA,uGAAuG;AACvG,OAAO,EAAC,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AACvC,OAAO,EAAC,aAAa,EAAC,MAAM,EAAC,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAC,cAAc,EAAC,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAC,0BAA0B,EAAC,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAC,kBAAkB,EAAC,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAC,iBAAiB,EAAC,eAAe,EAAC,MAAM,iCAAiC,CAAC;AAClF,OAAO,EAAC,mBAAmB,EAAiB,MAAM,uBAAuB,CAAC;AAE1E,OAAO,EAAC,qBAAqB,EAAC,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAC,qBAAqB,EAAC,MAAM,gBAAgB,CAAC;AAGrD,MAAM,CAAC,MAAM,0BAA0B,GAAC,EAAC,OAAO,EAAC,CAAC,EAAC,UAAU,EAAC,CAAC,EAAC,YAAY,EAAC,CAAC,EAAC,iBAAiB,EAAC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EAAC,QAAQ,EAAC,KAAK,EAAC,OAAO,EAAC,GAAG,EAAC,QAAQ,EAAC,CAAC,CAAC;IACpH,OAAO,EAAC,MAAM,EAAC,UAAU,EAAC,SAAS,EAAC,QAAQ,EAAC,UAAU,EAAC,0BAA0B,EAAC,CAAC;AACtF,CAAC"}
@@ -0,0 +1,64 @@
1
+ import { type WriterReview } from '../source-changes/writer.js';
2
+ import type { RunActionOptions } from './actions.js';
3
+ export interface SourceCandidateSelection {
4
+ runId: string;
5
+ executionRevision: string;
6
+ taskId: string;
7
+ attempt: number;
8
+ artifactId: string;
9
+ artifactHash: string;
10
+ }
11
+ export interface SourceCandidateReview extends WriterReview<SourceCandidateSelection> {
12
+ kind: 'source-candidate-review';
13
+ verification: 'required';
14
+ }
15
+ export declare function sourceCandidateCapabilities(): {
16
+ readonly version: 1;
17
+ readonly owner: 'calliope-cli';
18
+ readonly writer: 'git';
19
+ readonly operations: readonly ['preview', 'create', 'inspect', 'list'];
20
+ readonly semantics: 'generated-task-patch-to-unverified-local-candidate';
21
+ readonly verification: 'required';
22
+ readonly installation: false;
23
+ readonly merge: false;
24
+ readonly push: false;
25
+ readonly mayCallModel: false;
26
+ };
27
+ /** Preview creates no Git object/ref and does not turn task checks into migration acceptance. */
28
+ export declare function previewSourceCandidate(cwd: string, source: SourceCandidateSelection, options?: RunActionOptions): Promise<{
29
+ review: SourceCandidateReview;
30
+ hash: string;
31
+ branch: string;
32
+ patch: string;
33
+ }>;
34
+ export declare const createSourceCandidate: (cwd: string, source: SourceCandidateSelection, reviewedHash: string, options?: RunActionOptions) => Promise<{
35
+ version: 1;
36
+ status: "candidate" | "prepared";
37
+ hash: string;
38
+ branch: string;
39
+ review: SourceCandidateReview;
40
+ createdAt: string;
41
+ commit: string | null;
42
+ tree: string | null;
43
+ }>;
44
+ export declare const inspectSourceCandidate: (cwd: string, runId: string, hash: string, options?: RunActionOptions) => Promise<{
45
+ version: 1;
46
+ status: "candidate" | "prepared";
47
+ hash: string;
48
+ branch: string;
49
+ review: SourceCandidateReview;
50
+ createdAt: string;
51
+ commit: string | null;
52
+ tree: string | null;
53
+ }>;
54
+ export declare const listSourceCandidates: (cwd: string, runId: string, options?: RunActionOptions) => Promise<{
55
+ version: 1;
56
+ status: "candidate" | "prepared";
57
+ hash: string;
58
+ branch: string;
59
+ review: SourceCandidateReview;
60
+ createdAt: string;
61
+ commit: string | null;
62
+ tree: string | null;
63
+ }[]>;
64
+ //# sourceMappingURL=source-candidates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-candidates.d.ts","sourceRoot":"","sources":["../../src/orchestration/source-candidates.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,KAAK,YAAY,EAAC,MAAM,6BAA6B,CAAC;AAM3E,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAEnD,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAC,MAAM,CAAC;IAAA,iBAAiB,EAAC,MAAM,CAAC;IAAA,MAAM,EAAC,MAAM,CAAC;IAAA,OAAO,EAAC,MAAM,CAAC;IAAA,UAAU,EAAC,MAAM,CAAC;IAAA,YAAY,EAAC,MAAM,CAAC;CAC1G;AACD,MAAM,WAAW,qBAAsB,SAAQ,YAAY,CAAC,wBAAwB,CAAC;IACnF,IAAI,EAAC,yBAAyB,CAAC;IAAA,YAAY,EAAC,UAAU,CAAC;CACxD;AASD,wBAAgB,2BAA2B;aAAW,OAAO,EAAC,CAAC;aAAC,KAAK,EAAC,cAAc;aAAC,MAAM,EAAC,KAAK;aAC/F,UAAU,YAAE,SAAS,EAAC,QAAQ,EAAC,SAAS,EAAC,MAAM;aAAE,SAAS,EAAC,oDAAoD;aAC/G,YAAY,EAAC,UAAU;aAAC,YAAY;aAAO,KAAK;aAAO,IAAI;aAAO,YAAY;EAAkB;AAUlG,iGAAiG;AACjG,wBAAsB,sBAAsB,CAAC,GAAG,EAAC,MAAM,EAAC,MAAM,EAAC,wBAAwB,EAAC,OAAO,GAAC,gBAAmB;;;;;GAElH;AAgDD,eAAO,MAAM,qBAAqB;;;;;;;;;EAAa,CAAC;AAChD,eAAO,MAAM,sBAAsB;;;;;;;;;EAAe,CAAC;AACnD,eAAO,MAAM,oBAAoB;;;;;;;;;IAAY,CAAC"}
@@ -0,0 +1,95 @@
1
+ /** Generated task patches become immutable candidates, never verified proposals. */
2
+ import { canonicalJson, digest } from '../approvals/index.js';
3
+ import { sourceWriter } from '../source-changes/writer.js';
4
+ import { readPinnedWorktreeBase, worktreeGit } from '../isolation/worktree.js';
5
+ import { inspectExecution } from './coordinator-actions.js';
6
+ import { readCollectedArtifact } from './verification.js';
7
+ import { OrchestrationError } from './types.js';
8
+ import { id, pathName, shape } from './validation.js';
9
+ function conflict(message) { throw new OrchestrationError('conflict', message); }
10
+ const hash = (v) => typeof v === 'string' && /^[a-f0-9]{64}$/.test(v);
11
+ const uuid = (v) => typeof v === 'string' && /^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/.test(v);
12
+ const git = (project, args, options, input) => worktreeGit(project, ['--no-replace-objects', '--literal-pathspecs', ...args], options.signal, [0], input);
13
+ const branchFor = (source, review) => `refs/calliope-candidates/${source.runId}/${review}`;
14
+ const commitMessage = (source, review) => `Stage unverified candidate for ${source.taskId}\n\nCalliope-Source-Candidate: ${review}\nRun: ${source.runId}\nAttempt: ${source.attempt}\nArtifact-SHA256: ${source.artifactHash}\nVerification: required\n`;
15
+ export function sourceCandidateCapabilities() {
16
+ return { version: 1, owner: 'calliope-cli', writer: 'git',
17
+ operations: ['preview', 'create', 'inspect', 'list'], semantics: 'generated-task-patch-to-unverified-local-candidate',
18
+ verification: 'required', installation: false, merge: false, push: false, mayCallModel: false };
19
+ }
20
+ function selection(source) {
21
+ shape(source, ['runId', 'executionRevision', 'taskId', 'attempt', 'artifactId', 'artifactHash']);
22
+ if (!uuid(source.runId) || !hash(source.executionRevision) || !hash(source.artifactHash) ||
23
+ !Number.isSafeInteger(source.attempt) || source.attempt < 1)
24
+ throw new OrchestrationError('invalid', 'Select the exact native task attempt and patch.');
25
+ id(source.taskId);
26
+ id(source.artifactId);
27
+ }
28
+ /** Preview creates no Git object/ref and does not turn task checks into migration acceptance. */
29
+ export async function previewSourceCandidate(cwd, source, options = {}) {
30
+ return preview(cwd, source, options);
31
+ }
32
+ async function preview(cwd, source, options, leaseId) {
33
+ selection(source);
34
+ const current = await inspectExecution(cwd, source.runId, options), { view, store } = current, state = current.execution?.state;
35
+ if (!state || state.revision !== source.executionRevision || state.ownerId || current.owner?.alive && current.owner.id !== leaseId)
36
+ conflict('The source execution changed or is still owned. Inspect its current task evidence.');
37
+ store.assertApproval(current.execution.header);
38
+ const context = store.context(), task = context.plan.tasks.find(t => t.id === source.taskId), attempt = state.tasks[source.taskId], output = attempt?.output;
39
+ if (!task?.isolation || task.isolation.mode === 'read-only-v1' || task.isolation.patchArtifactId !== source.artifactId ||
40
+ !attempt || attempt.attempts !== source.attempt || attempt.status !== 'completed' || !output ||
41
+ !output.checks.length || output.checks.some(check => !check.passed))
42
+ conflict('Select a completed isolated task attempt and its executor-collected patch. Independent verification is still required.');
43
+ const artifact = output.artifacts.find(a => a.id === source.artifactId);
44
+ if (!artifact || artifact.sha256 !== source.artifactHash || artifact.kind !== 'patch' || artifact.location !== 'run' ||
45
+ artifact.bytes < 1 || artifact.bytes > 1024 * 1024)
46
+ conflict('Select the collected nonempty patch, up to 1 MiB.');
47
+ const bytes = await readCollectedArtifact(store, artifact, options);
48
+ let patch;
49
+ try {
50
+ patch = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
51
+ }
52
+ catch {
53
+ conflict('Native patches must use UTF-8.');
54
+ }
55
+ const project = view.manifest.project, baseCommit = readPinnedWorktreeBase(store.root, project.root, view.manifest.planHash);
56
+ if ((await git(project.root, ['rev-parse', '--verify', 'HEAD^{commit}'], options)).trim() !== baseCommit)
57
+ conflict('The owning source advanced beyond the task base. Replan the affected unit before creating a candidate.');
58
+ const author = { name: (await git(project.root, ['config', '--local', '--get', 'user.name'], options)).trim(),
59
+ email: (await git(project.root, ['config', '--local', '--get', 'user.email'], options)).trim() };
60
+ if (Object.values(author).some(v => !v || v.length > 256 || /[\r\n<>\x00]/.test(v)))
61
+ conflict('Configure a valid repository-local Git author before reviewing a candidate.');
62
+ const stats = await git(project.root, ['apply', '--numstat', '-z', '--'], options, { text: patch });
63
+ const paths = stats.split('\0').filter(Boolean).map(line => {
64
+ const match = /^(?:\d+|-)\t(?:\d+|-)\t(.+)$/s.exec(line);
65
+ if (!match)
66
+ conflict('Native patch path inventory is unavailable.');
67
+ const value = match[1];
68
+ pathName(value);
69
+ if (value.split('/').some(p => p.toLowerCase() === '.git'))
70
+ conflict('Git metadata cannot be staged.');
71
+ return value;
72
+ });
73
+ const grants = context.plan.agents.find(a => a.id === task.agentId).allowedPaths.filter(g => g.access === 'write');
74
+ if (!paths.length || paths.length > 1000 || paths.some(p => !grants.some(g => g.path === '.' || p === g.path || p.startsWith(g.path + '/'))))
75
+ conflict('The patch exceeds the selected worker’s original write scope or path bound.');
76
+ // Do not silently hide an overlapping user edit, including an ignored/untracked target.
77
+ if (await git(project.root, ['status', '--porcelain=v1', '-z', '--untracked-files=all', '--ignored=matching', '--', ...paths], options))
78
+ conflict('Candidate paths conflict with local staged, unstaged, untracked or ignored changes. Preserve them and replan.');
79
+ const review = { version: 1, kind: 'source-candidate-review', writer: 'git', verification: 'required',
80
+ project: { root: project.root, key: project.key }, source, manifestHash: view.manifest.hash,
81
+ sourceHash: digest(canonicalJson({ task, attempt, artifact })), baseCommit, author, paths, patchBytes: bytes.length };
82
+ const reviewHash = digest(canonicalJson(review));
83
+ store.assertRevision(source.executionRevision);
84
+ store.assertApproval(current.execution.header);
85
+ return { review, hash: reviewHash, branch: branchFor(source, reviewHash), patch };
86
+ }
87
+ const writer = sourceWriter({
88
+ directory: 'source-candidates', kind: 'source-candidate-review', status: 'candidate', tool: 'orchestration_source_candidate',
89
+ operation: 'Create one unverified local candidate for independent verification; do not mark verified, merge, install, push or run work.',
90
+ selection, branchFor, commitMessage, preview,
91
+ });
92
+ export const createSourceCandidate = writer.write;
93
+ export const inspectSourceCandidate = writer.inspect;
94
+ export const listSourceCandidates = writer.list;
95
+ //# sourceMappingURL=source-candidates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-candidates.js","sourceRoot":"","sources":["../../src/orchestration/source-candidates.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,OAAO,EAAC,aAAa,EAAC,MAAM,EAAC,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAC,YAAY,EAAmB,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EAAC,sBAAsB,EAAC,WAAW,EAAC,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAC,qBAAqB,EAAC,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAC,kBAAkB,EAAC,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAC,EAAE,EAAC,QAAQ,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAC;AASlD,SAAS,QAAQ,CAAC,OAAc,IAAQ,MAAM,IAAI,kBAAkB,CAAC,UAAU,EAAC,OAAO,CAAC,CAAC,CAAA,CAAC;AAC1F,MAAM,IAAI,GAAC,CAAC,CAAS,EAAC,EAAE,CAAA,OAAO,CAAC,KAAG,QAAQ,IAAE,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACtE,MAAM,IAAI,GAAC,CAAC,CAAS,EAAC,EAAE,CAAA,OAAO,CAAC,KAAG,QAAQ,IAAE,+CAA+C,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACrG,MAAM,GAAG,GAAC,CAAC,OAAc,EAAC,IAAa,EAAC,OAAwB,EAAC,KAAwC,EAAC,EAAE,CAC1G,WAAW,CAAC,OAAO,EAAC,CAAC,sBAAsB,EAAC,qBAAqB,EAAC,GAAG,IAAI,C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,CAAC"}
@@ -254,7 +254,7 @@ export function analyzePlan(value) {
254
254
  fail('Task input exceeds its agent scope.');
255
255
  if ((v.version === 3 || v.version === 4)) {
256
256
  validateTaskIsolation(item.isolation, item, plan);
257
- if (!owner.allowedTools.includes('write_file') && !owner.allowedTools.includes('edit_file'))
257
+ if (item.isolation.mode !== 'read-only-v1' && !owner.allowedTools.includes('write_file') && !owner.allowedTools.includes('edit_file'))
258
258
  fail('Isolated mutation tasks require write_file or edit_file authority.');
259
259
  }
260
260
  if (v.version !== 1) {