@iowarp/clio-coder 0.3.2 → 0.3.4

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 (259) hide show
  1. package/CHANGELOG.md +269 -458
  2. package/CONTRIBUTING.md +1 -1
  3. package/README.md +3 -3
  4. package/dist/{acp-BIYHVZIM.js → acp-S5R4RR5B.js} +7 -6
  5. package/dist/{agents-YT6SSRIT.js → agents-P6DMMVZY.js} +24 -21
  6. package/dist/assets/codewiki.json +1 -1
  7. package/dist/{auth-5TWEIYDN.js → auth-2XCZLPKS.js} +12 -8
  8. package/dist/{chunk-GGXXDWE4.js → chunk-22NAGB7X.js} +2 -2
  9. package/dist/{chunk-WMSVI4G2.js → chunk-2LZI5CAG.js} +133 -13
  10. package/dist/{chunk-OAO4GE4M.js → chunk-2TZWSW76.js} +2 -2
  11. package/dist/{chunk-OOJYHWRB.js → chunk-34475P3I.js} +2 -2
  12. package/dist/{chunk-WVO7V2QY.js → chunk-35MKKU5R.js} +4 -4
  13. package/dist/{chunk-LBNRH5WM.js → chunk-3HZ5RWN2.js} +5 -5
  14. package/dist/{chunk-AGYYIBLL.js → chunk-3JLKSKD7.js} +2 -2
  15. package/dist/{chunk-MBS4V7ZP.js → chunk-4JUF2NNX.js} +7 -7
  16. package/dist/{chunk-ZDOOVTXZ.js → chunk-4OC57DA6.js} +27 -4
  17. package/dist/chunk-5M54SPOL.js +926 -0
  18. package/dist/{chunk-STBPMHSX.js → chunk-7RXG6QRZ.js} +51 -11
  19. package/dist/{chunk-77VKQEHF.js → chunk-A2GZF7DC.js} +5 -5
  20. package/dist/{chunk-A3CYT5EX.js → chunk-AD2SYQYC.js} +55 -2
  21. package/dist/chunk-AOCYTWAV.js +449 -0
  22. package/dist/chunk-BEY543CS.js +258 -0
  23. package/dist/{chunk-6N5PTWMY.js → chunk-BP4OYD6A.js} +32 -13
  24. package/dist/chunk-BPGS2WCQ.js +612 -0
  25. package/dist/{chunk-J5HN4RYU.js → chunk-BRXQQJFP.js} +8 -8
  26. package/dist/chunk-CFGTUFWB.js +67 -0
  27. package/dist/{chunk-CBCAPZAA.js → chunk-E25LMLRW.js} +2 -2
  28. package/dist/{chunk-G2DE3C7R.js → chunk-EDRHSCIE.js} +4 -4
  29. package/dist/{chunk-4KLWL3UC.js → chunk-EFADSJET.js} +2 -2
  30. package/dist/{chunk-M6SHUN7Q.js → chunk-FO5ZOVUY.js} +2 -2
  31. package/dist/chunk-FYYLNIL5.js +313 -0
  32. package/dist/{chunk-EPVUXGXG.js → chunk-HV5X7OR2.js} +14 -12
  33. package/dist/{chunk-TZTZS7QK.js → chunk-HXG4IURW.js} +5 -3
  34. package/dist/{chunk-IGLFWIYI.js → chunk-K6WL7QZT.js} +3 -3
  35. package/dist/chunk-K7VKOLQQ.js +15 -0
  36. package/dist/{chunk-BMEMKKIT.js → chunk-KOHPCX4K.js} +2 -2
  37. package/dist/{chunk-V4RXGQ5Q.js → chunk-KRPY7NTG.js} +10 -7
  38. package/dist/chunk-LL4KHSZI.js +22 -0
  39. package/dist/{chunk-KJ5LWLOE.js → chunk-MEQ45TQ4.js} +15 -9
  40. package/dist/{chunk-5UUP6MWO.js → chunk-MV3K5QF2.js} +5 -436
  41. package/dist/{chunk-AO4RKG4M.js → chunk-N4CZJQRK.js} +5 -5
  42. package/dist/{chunk-ARBGF5F7.js → chunk-NILBFAPG.js} +14 -8
  43. package/dist/chunk-OZNBF4L3.js +23 -0
  44. package/dist/{verify-G6V4D2G7.js → chunk-PCZJO5TI.js} +127 -42
  45. package/dist/chunk-QQK64KLB.js +1360 -0
  46. package/dist/{chunk-6EJV5X2W.js → chunk-QQL5RT5M.js} +979 -1619
  47. package/dist/{chunk-LZSJBIVT.js → chunk-QWU7ZBO7.js} +70 -720
  48. package/dist/{chunk-2EHAIA3X.js → chunk-RD5U66HV.js} +3 -3
  49. package/dist/{chunk-OKGUZO2U.js → chunk-SPULKLCF.js} +4 -3
  50. package/dist/{chunk-OQ33BKR3.js → chunk-TTNYS3EA.js} +3 -60
  51. package/dist/chunk-TW3WDMVS.js +677 -0
  52. package/dist/chunk-TZSKNMZG.js +434 -0
  53. package/dist/{chunk-7MNJORFF.js → chunk-UL3WSD3F.js} +6 -1
  54. package/dist/{chunk-7EYHLWU7.js → chunk-UZHIZC5S.js} +7 -7
  55. package/dist/{chunk-QTYWRVRA.js → chunk-VAWWTKDP.js} +8 -8
  56. package/dist/{chunk-X75S7HFS.js → chunk-VEZEGCGW.js} +214 -20
  57. package/dist/{chunk-OHHN2SO4.js → chunk-VMNQ6OZA.js} +98 -202
  58. package/dist/chunk-VSNATDE6.js +122 -0
  59. package/dist/chunk-W6GROXXM.js +69 -0
  60. package/dist/chunk-WPQLXFOZ.js +375 -0
  61. package/dist/{chunk-ORBHGJC5.js → chunk-WR67VIZY.js} +3 -3
  62. package/dist/{chunk-3ZXDFGR5.js → chunk-X6COSD2O.js} +5 -5
  63. package/dist/chunk-ZGVHUX3M.js +66 -0
  64. package/dist/{chunk-MAW544W2.js → chunk-ZWMF7253.js} +4 -4
  65. package/dist/{chunk-MQSRRFWA.js → chunk-ZYKPLLNQ.js} +563 -546
  66. package/dist/cli/index.js +27 -23
  67. package/dist/{clio-4LY5K2AC.js → clio-J5JIOIDS.js} +7 -6
  68. package/dist/{code-nav-7AX6FYE6.js → code-nav-AXCXSBHX.js} +5 -3
  69. package/dist/{config-GTLUW2PR.js → config-OEBMIN2U.js} +37 -27
  70. package/dist/{configure-R6A64DHX.js → configure-PUQOSIXQ.js} +16 -13
  71. package/dist/{context-5VKGUVJJ.js → context-EKDCKUUZ.js} +82 -7
  72. package/dist/{context-RW5HC47S.js → context-MGSE4Z2T.js} +33 -23
  73. package/dist/{context-JFZEJ7W5.js → context-URSXPBCK.js} +17 -9
  74. package/dist/{context-clear-6ZHBAZZT.js → context-clear-KDAJRNUK.js} +33 -23
  75. package/dist/context-working-set-SBKMPPI2.js +1552 -0
  76. package/dist/{dispatch-runner-VKBRCWQC.js → dispatch-runner-MSWN72NK.js} +43 -29
  77. package/dist/{doctor-KI767GSN.js → doctor-7BSE27PJ.js} +10 -10
  78. package/dist/{eval-XSSNATB4.js → eval-IZGDOO4H.js} +9 -8
  79. package/dist/{evidence-UA6AWDQQ.js → evidence-SR7WXB5B.js} +51 -23
  80. package/dist/{evolve-QNTFGV6Z.js → evolve-K7VE2CBX.js} +30 -20
  81. package/dist/{fleet-Q7UOMUSG.js → fleet-7XMJNQNF.js} +48 -38
  82. package/dist/{fleet-preflight-DDN536IT.js → fleet-preflight-AQNAH644.js} +3 -3
  83. package/dist/{init-WBB65ZHQ.js → init-JGNPAYXT.js} +41 -31
  84. package/dist/{memory-MD3O64RI.js → memory-4ALKDJ4Q.js} +32 -22
  85. package/dist/{models-BZU34YWD.js → models-ZMMLFJNN.js} +22 -19
  86. package/dist/{monitor-MEQA5C3I.js → monitor-2F3T5KHP.js} +55 -43
  87. package/dist/{orchestrator-CGFKEP27.js → orchestrator-ORHT43JB.js} +2507 -1896
  88. package/dist/{reset-L2FQEE3E.js → reset-NXGTYNUO.js} +4 -3
  89. package/dist/{run-IV4Q6RLN.js → run-RF4WJGMT.js} +51 -41
  90. package/dist/{share-S5BZQC5I.js → share-UT3W6E4M.js} +5 -4
  91. package/dist/{skills-LQEKRDTN.js → skills-PSACKC5Q.js} +2 -2
  92. package/dist/{skills-eval-3DC4HEWS.js → skills-eval-WJSI55RZ.js} +34 -24
  93. package/dist/{targets-C4SSGQOB.js → targets-PIIRAOYS.js} +23 -20
  94. package/dist/{terminal-lease-IT5JW2NR.js → terminal-lease-ULWXWNVY.js} +5 -4
  95. package/dist/{upgrade-7TT7SQ3G.js → upgrade-346TZ6AV.js} +18 -17
  96. package/dist/{usage-GV4PKT3M.js → usage-6KKXR32N.js} +34 -24
  97. package/dist/verifiers-4UUM6TEE.js +1214 -0
  98. package/dist/verify-X5HDROLA.js +25 -0
  99. package/dist/{wiki-generate-DQF6Z66B.js → wiki-generate-7STOCIFZ.js} +42 -31
  100. package/dist/worker/entry.js +33 -24
  101. package/docs/README.md +8 -7
  102. package/docs/acp.md +1 -1
  103. package/docs/alcf-provider.md +1 -1
  104. package/docs/architecture.md +2 -2
  105. package/docs/artifact-versions.md +1 -1
  106. package/docs/built-in-agents.md +1 -1
  107. package/docs/capacity-and-scheduling.md +1 -1
  108. package/docs/commands-and-modes.md +53 -21
  109. package/docs/config-knobs-audit.md +1 -2
  110. package/docs/configuration-and-targets.md +15 -1
  111. package/docs/context-engine.md +64 -12
  112. package/docs/context-working-set.md +194 -0
  113. package/docs/development-pipeline.md +1 -1
  114. package/docs/documentation-coverage.md +5 -5
  115. package/docs/documentation-guide.md +6 -5
  116. package/docs/environment-variables.md +2 -1
  117. package/docs/eval-runner.md +1 -1
  118. package/docs/evals-internal.md +14 -1
  119. package/docs/evidence-and-memory.md +74 -2
  120. package/docs/evolution.md +1 -1
  121. package/docs/exit-codes-and-output.md +1 -1
  122. package/docs/extensions-and-sharing.md +2 -2
  123. package/docs/fleet-dispatch.md +22 -7
  124. package/docs/glossary.md +21 -1
  125. package/docs/installation-and-lifecycle.md +6 -6
  126. package/docs/middleware-and-components.md +1 -1
  127. package/docs/model-catalog.md +7 -9
  128. package/docs/observability.md +4 -4
  129. package/docs/performance-methodology.md +2 -2
  130. package/docs/proactive-memory.md +1 -1
  131. package/docs/prompt-envelope-and-tools.md +4 -4
  132. package/docs/provider-adapter-cookbook.md +1 -1
  133. package/docs/release-cut-checklist.md +35 -35
  134. package/docs/safety-model.md +23 -4
  135. package/docs/scientific-validation.md +21 -3
  136. package/docs/session-lifecycle.md +3 -3
  137. package/docs/skills-marketplace.md +1 -1
  138. package/docs/tool-usage.md +79 -12
  139. package/docs/trace-store.md +1 -1
  140. package/docs/troubleshooting.md +1 -1
  141. package/docs/tui-design.md +2 -2
  142. package/docs/worker-dispatch-mechanics.md +11 -1
  143. package/package.json +8 -11
  144. package/skills/meta/clio-test/SKILL.md +20 -17
  145. package/skills/meta/clio-test/evals.md +3 -3
  146. package/skills/meta/clio-test/references/harness.md +35 -6
  147. package/skills/meta/clio-test/references/test-map.md +20 -10
  148. package/skills/registry.yaml +2 -2
  149. package/skills/skill-marketplace.json +1 -1
  150. package/src/cli/context-working-set.ts +513 -0
  151. package/src/cli/context.ts +8 -0
  152. package/src/cli/evidence.ts +20 -2
  153. package/src/cli/index.ts +4 -0
  154. package/src/cli/verifiers.ts +325 -0
  155. package/src/core/bash-exec.ts +39 -14
  156. package/src/core/bus-events.ts +19 -4
  157. package/src/core/config.ts +54 -0
  158. package/src/core/defaults.ts +50 -3
  159. package/src/core/git-commit-attribution.ts +46 -21
  160. package/src/core/verification-scripts.ts +6 -0
  161. package/src/domains/agents/builtins/verifier.md +3 -0
  162. package/src/domains/config/classify.ts +1 -0
  163. package/src/domains/config/keybindings.ts +3 -3
  164. package/src/domains/context/working-set/contract.ts +161 -0
  165. package/src/domains/context/working-set/defaults.ts +28 -0
  166. package/src/domains/context/working-set/engine.ts +203 -0
  167. package/src/domains/context/working-set/fold.ts +62 -0
  168. package/src/domains/context/working-set/horizon.ts +38 -0
  169. package/src/domains/context/working-set/marker.ts +103 -0
  170. package/src/domains/context/working-set/path-index.ts +436 -0
  171. package/src/domains/context/working-set/payload.ts +152 -0
  172. package/src/domains/context/working-set/policies/age-horizon.ts +55 -0
  173. package/src/domains/context/working-set/policies/index.ts +21 -0
  174. package/src/domains/context/working-set/policies/structural.ts +160 -0
  175. package/src/domains/context/working-set/project.ts +132 -0
  176. package/src/domains/context/working-set/protect.ts +109 -0
  177. package/src/domains/context/working-set/recall.ts +177 -0
  178. package/src/domains/context/working-set/replay/controls.ts +112 -0
  179. package/src/domains/context/working-set/replay/load-clio.ts +199 -0
  180. package/src/domains/context/working-set/replay/metrics.ts +185 -0
  181. package/src/domains/context/working-set/replay/reference-graph.ts +79 -0
  182. package/src/domains/context/working-set/replay/report.ts +139 -0
  183. package/src/domains/context/working-set/replay/runner.ts +325 -0
  184. package/src/domains/context/working-set/replay/synthetic.ts +422 -0
  185. package/src/domains/context/working-set/replay/trace.ts +21 -0
  186. package/src/domains/context/working-set/visible.ts +54 -0
  187. package/src/domains/evidence/build.ts +112 -45
  188. package/src/domains/evidence/eval.ts +24 -7
  189. package/src/domains/evidence/index.ts +53 -0
  190. package/src/domains/evidence/ordering.ts +12 -0
  191. package/src/domains/evidence/run-trust.ts +221 -0
  192. package/src/domains/evidence/store.ts +46 -6
  193. package/src/domains/evidence/trust-status.ts +854 -0
  194. package/src/domains/evidence/types.ts +26 -0
  195. package/src/domains/middleware/memory-intervention.ts +3 -0
  196. package/src/domains/middleware/stalled-turn.ts +165 -4
  197. package/src/domains/safety/autonomy.ts +1 -1
  198. package/src/domains/safety/default-path-policy.ts +8 -0
  199. package/src/domains/safety/finish-contract.ts +4 -3
  200. package/src/domains/safety/policy-engine.ts +48 -6
  201. package/src/domains/session/compaction/compact.ts +23 -1
  202. package/src/domains/session/compaction/cut-point.ts +2 -0
  203. package/src/domains/session/compaction/tokens.ts +16 -1
  204. package/src/domains/session/context-ledger.ts +2 -0
  205. package/src/domains/session/entries.ts +107 -1
  206. package/src/domains/session/manager.ts +9 -2
  207. package/src/domains/session/migrations/index.ts +22 -3
  208. package/src/engine/acp/server.ts +3 -0
  209. package/src/engine/agent.ts +18 -1
  210. package/src/engine/session.ts +9 -3
  211. package/src/entry/orchestrator.ts +16 -4
  212. package/src/interactive/chat-loop-messages.ts +18 -6
  213. package/src/interactive/chat-panel.ts +571 -244
  214. package/src/interactive/chat-renderer.ts +79 -39
  215. package/src/interactive/context-meter.ts +10 -0
  216. package/src/interactive/context-overlay.ts +81 -6
  217. package/src/interactive/context-recall-command.ts +110 -0
  218. package/src/interactive/editor-submit.ts +26 -1
  219. package/src/interactive/footer/widgets.ts +22 -20
  220. package/src/interactive/footer-panel.ts +6 -1
  221. package/src/interactive/interactive-application.ts +2 -0
  222. package/src/interactive/interactive-event-projection.ts +12 -0
  223. package/src/interactive/interactive-slash-runtime.ts +49 -8
  224. package/src/interactive/model-session-replay.ts +21 -0
  225. package/src/interactive/overlay-general-openers.ts +6 -0
  226. package/src/interactive/overlay-session-lifecycle.ts +8 -4
  227. package/src/interactive/overlays/ask-user.ts +146 -24
  228. package/src/interactive/renderers/tool-execution.ts +167 -56
  229. package/src/interactive/session-transcript.ts +2 -2
  230. package/src/interactive/slash-commands.ts +29 -2
  231. package/src/interactive/status/index.ts +12 -1
  232. package/src/interactive/status/reasoning.ts +87 -0
  233. package/src/interactive/status/summary.ts +13 -2
  234. package/src/interactive/transcript-detail.ts +120 -0
  235. package/src/interactive/turn-context.ts +238 -88
  236. package/src/interactive/turn-middleware.ts +6 -6
  237. package/src/tools/agent-tools.ts +11 -4
  238. package/src/tools/bash.ts +144 -82
  239. package/src/tools/builtin-tool-catalog.ts +18 -6
  240. package/src/tools/context/index.ts +105 -3
  241. package/src/tools/context/surface.ts +3 -2
  242. package/src/tools/core-bootstrap.ts +21 -0
  243. package/src/tools/dispatch-runner.ts +9 -7
  244. package/src/tools/monitor.ts +28 -20
  245. package/src/tools/presentation.ts +107 -0
  246. package/src/tools/registry.ts +65 -7
  247. package/src/tools/result-disposition.ts +550 -0
  248. package/src/tools/result-shaping.ts +262 -19
  249. package/src/tools/safe-exec.ts +2 -0
  250. package/src/tools/verify/authoring.ts +1119 -0
  251. package/src/tools/verify/catalog.ts +346 -0
  252. package/src/tools/verify/index.ts +13 -3
  253. package/src/tools/verify/scripts.ts +135 -37
  254. package/src/tools/verify/surface.ts +9 -5
  255. package/src/tools/worker-evidence.ts +35 -12
  256. package/dist/chunk-MNA4JGU4.js +0 -255
  257. package/dist/chunk-SRF2PJNW.js +0 -184
  258. package/dist/chunk-T6YILFSB.js +0 -80
  259. package/dist/chunk-VAKQQHWR.js +0 -434
@@ -1,6 +1,7 @@
1
1
  import { mentionsWorkerToolCallCap } from "../core/guardrails.js";
2
2
  import type { ReceiptIntegrityResult } from "../domains/dispatch/receipt-integrity.js";
3
3
  import type { RunReceipt, RunReceiptVerification } from "../domains/dispatch/types.js";
4
+ import { adaptRunReceiptTrustStatus, type CanonicalTrustStatus } from "../domains/evidence/trust-status.js";
4
5
 
5
6
  /** Matches a source citation the parent can independently spot-check. */
6
7
  const SOURCE_CITATION_PATTERN = /([\w./~-]+):(\d+)/g;
@@ -39,10 +40,10 @@ export const SPOT_CHECK_GUIDANCE =
39
40
  * keeps its own role, so this is deliberately narrow; the activity and
40
41
  * first-pass labels below carry the honest signal for every other class.
41
42
  */
42
- function isMutationClassRun(receipt: RunReceipt, verification: RunReceiptVerification): boolean {
43
+ function isMutationClassRun(receipt: RunReceipt, status: CanonicalTrustStatus): boolean {
43
44
  // A read-only agent seals `not_applicable`; recon that changes nothing is
44
45
  // the expected outcome there, not a missing effect.
45
- if (verification.state === "not_applicable") return false;
46
+ if (status.validationGrounding.state === "not_applicable") return false;
46
47
  if (receipt.executionRole === "builder" || receipt.executionRole === "recovery") return true;
47
48
  return receipt.quality?.resultContract?.sourceId?.startsWith("agent-result-contract:mutation-report") === true;
48
49
  }
@@ -87,7 +88,7 @@ function receiptAdmissionLabels(receipt: RunReceipt): string[] {
87
88
  * fixed the file. These labels are the receipt's own counters, so the parent
88
89
  * sees the shape of the run before it reads the worker's account of it.
89
90
  */
90
- function receiptActivityLabels(receipt: RunReceipt, verification: RunReceiptVerification): string[] {
91
+ function receiptActivityLabels(receipt: RunReceipt, status: CanonicalTrustStatus): string[] {
91
92
  const labels: string[] = [];
92
93
  const activity = receipt.toolActivity;
93
94
  if (activity !== undefined) {
@@ -98,7 +99,7 @@ function receiptActivityLabels(receipt: RunReceipt, verification: RunReceiptVeri
98
99
  );
99
100
  // The case this whole label set exists for: the task was to change
100
101
  // something and nothing changed, under an exit code that says success.
101
- if (!activity.mutatingSucceeded && isMutationClassRun(receipt, verification)) labels.push("mutation_effect=none");
102
+ if (!activity.mutatingSucceeded && isMutationClassRun(receipt, status)) labels.push("mutation_effect=none");
102
103
  }
103
104
  const findings = receipt.findingsSummary;
104
105
  if (findings !== undefined) {
@@ -119,7 +120,11 @@ export function receiptEvidenceLabels(
119
120
  verification: RunReceiptVerification,
120
121
  integrity: ReceiptIntegrityResult,
121
122
  ): string[] {
122
- if (!integrity.ok) return [`receipt_integrity=FAILED reason=${JSON.stringify(integrity.reason)}`];
123
+ const status = adaptRunReceiptTrustStatus({ ...receipt, verification }, { integrity });
124
+ const canonical = canonicalTrustLabel(status);
125
+ if (!integrity.ok) {
126
+ return [canonical, `receipt_integrity=FAILED reason=${JSON.stringify(integrity.reason)}`];
127
+ }
123
128
  const briefing =
124
129
  receipt.briefing === undefined
125
130
  ? "briefing=none"
@@ -132,23 +137,36 @@ export function receiptEvidenceLabels(
132
137
  }${receipt.projectContext.contentHash !== undefined ? ` sha256:${receipt.projectContext.contentHash}` : ""}`;
133
138
  }
134
139
  return [
140
+ canonical,
135
141
  `receipt_integrity=verified/v${receipt.integrity.version}/${receipt.integrity.algorithm}`,
136
142
  `evidence_verification=${verification.state}/${verification.basis}`,
137
143
  ...receiptAdmissionLabels(receipt),
138
- ...receiptActivityLabels(receipt, verification),
144
+ ...receiptActivityLabels(receipt, status),
139
145
  briefing,
140
146
  projectContext,
141
147
  ];
142
148
  }
143
149
 
150
+ function canonicalTrustLabel(status: CanonicalTrustStatus): string {
151
+ return [
152
+ `trust_status=v${status.version}`,
153
+ `artifactIntegrity:${status.artifactIntegrity.state}`,
154
+ `validationGrounding:${status.validationGrounding.state}`,
155
+ `independentReview:${status.independentReview.state}`,
156
+ `contextProvenance:${status.contextProvenance.state}`,
157
+ `autonomyEnforcement:${status.autonomyEnforcement.state}`,
158
+ `completionEvidence:${status.completionEvidence.state}`,
159
+ ].join(" ");
160
+ }
161
+
144
162
  /**
145
163
  * Header for delegated worker text, keyed only on integrity-checked receipt
146
164
  * verification. The string is shared by dispatch and monitor so detached
147
165
  * collection cannot silently assign a different evidence meaning.
148
166
  */
149
- export function workerTextLabel(verification: RunReceiptVerification): string {
150
- switch (verification.state) {
151
- case "verified":
167
+ export function workerTextLabel(status: CanonicalTrustStatus): string {
168
+ switch (status.validationGrounding.state) {
169
+ case "validated":
152
170
  return "worker output (tool-verified):";
153
171
  case "not_applicable":
154
172
  return "reconnaissance output (advisory leads, not validation evidence):";
@@ -166,7 +184,7 @@ export function workerTextLabel(verification: RunReceiptVerification): string {
166
184
  */
167
185
  export function workerTextNonEvidenceNotices(
168
186
  receipt: RunReceipt,
169
- verification: RunReceiptVerification,
187
+ status: CanonicalTrustStatus,
170
188
  answerText: string,
171
189
  ): string[] {
172
190
  const notices: string[] = [];
@@ -184,7 +202,7 @@ export function workerTextNonEvidenceNotices(
184
202
  }
185
203
  if (receipt.toolActivity !== undefined && receipt.toolActivity.succeeded === 0) {
186
204
  notices.push("non-evidence: no tool call succeeded in this run; the text above was written without observed work.");
187
- } else if (receipt.toolActivity?.mutatingSucceeded === false && isMutationClassRun(receipt, verification)) {
205
+ } else if (receipt.toolActivity?.mutatingSucceeded === false && isMutationClassRun(receipt, status)) {
188
206
  // A live verifier run returned {"verdict":"pass"} for a check it never
189
207
  // ran, on a script that does not exist, at exit 0. The parent recovered
190
208
  // only because it independently diffed the tree; say so on the line.
@@ -206,7 +224,12 @@ export function workerTextNonEvidenceNotices(
206
224
  `non-evidence: '${receipt.capabilityMismatch.agentId}' is a ${receipt.capabilityMismatch.capabilityClass} recipe and cannot write to the workspace, but this task classified as ${receipt.capabilityMismatch.taskType}. Nothing it reports as changed can have been changed by it.`,
207
225
  );
208
226
  }
209
- if (!failedRun && verification.state === "not_applicable" && answerText.length > 0 && !hasSourceCitation(answerText)) {
227
+ if (
228
+ !failedRun &&
229
+ status.validationGrounding.state === "not_applicable" &&
230
+ answerText.length > 0 &&
231
+ !hasSourceCitation(answerText)
232
+ ) {
210
233
  notices.push(
211
234
  "non-evidence: this reconnaissance answer cites no file:line locations; treat its leads as unconfirmed.",
212
235
  );
@@ -1,255 +0,0 @@
1
- import { createRequire as __clioCreateRequire } from "node:module"; const require = __clioCreateRequire(import.meta.url);
2
- import {
3
- gitCommitAttributionEnabled,
4
- reportCommitAttributionDiagnostic,
5
- withManagedGitCommitAttributionEnvironment
6
- } from "./chunk-X75S7HFS.js";
7
- import {
8
- clampTimerDelayMs
9
- } from "./chunk-FQ4SKYE4.js";
10
- import {
11
- AI_AGENT_NAME
12
- } from "./chunk-6EJMN2Y3.js";
13
- import {
14
- init_esm_shims
15
- } from "./chunk-3R73A4XB.js";
16
-
17
- // src/core/headless-permission.ts
18
- init_esm_shims();
19
- var HEADLESS_PERMISSION_DENIED_REASON = "clio-coder run cannot confirm permission requests; rerun interactively to approve this action.";
20
- var HEADLESS_PERMISSION_DENIED_MARKER = "clio-coder run cannot confirm permission requests";
21
-
22
- // src/core/bash-exec.ts
23
- init_esm_shims();
24
- import { spawn } from "node:child_process";
25
- var BASH_HARD_CAP_BYTES = 16 * 1024 * 1024;
26
- var CLIO_CONTROL_ENV_KEYS = ["CLIO_CODER_INTERACTIVE", "CLIO_CODER_RESUME_SESSION_ID"];
27
- var BASH_UPDATE_THROTTLE_MS = 100;
28
- function buildToolEnv() {
29
- const env = { ...process.env };
30
- env.AI_AGENT = AI_AGENT_NAME;
31
- for (const key of CLIO_CONTROL_ENV_KEYS) {
32
- Reflect.deleteProperty(env, key);
33
- }
34
- return env;
35
- }
36
- var LOGIN_ENV_CAPTURE_TIMEOUT_MS = 1e4;
37
- var loginEnvCapture = null;
38
- function parseNullDelimitedEnv(raw) {
39
- const env = {};
40
- for (const entry of raw.split("\0")) {
41
- if (entry.length === 0) continue;
42
- const eq = entry.indexOf("=");
43
- if (eq <= 0) continue;
44
- env[entry.slice(0, eq)] = entry.slice(eq + 1);
45
- }
46
- return typeof env.PATH === "string" && env.PATH.length > 0 ? env : null;
47
- }
48
- function captureLoginEnv() {
49
- return new Promise((resolve) => {
50
- let stdout = "";
51
- let settled = false;
52
- const finish = (value) => {
53
- if (settled) return;
54
- settled = true;
55
- clearTimeout(timer);
56
- resolve(value);
57
- };
58
- const child = spawn("/bin/bash", ["-lc", "env -0"], {
59
- env: buildToolEnv(),
60
- stdio: ["ignore", "pipe", "ignore"]
61
- });
62
- const timer = setTimeout(() => {
63
- child.kill("SIGKILL");
64
- finish(null);
65
- }, LOGIN_ENV_CAPTURE_TIMEOUT_MS);
66
- child.stdout?.on("data", (chunk) => {
67
- stdout += chunk.toString("utf8");
68
- });
69
- child.on("error", () => finish(null));
70
- child.on("close", (code) => finish(code === 0 ? parseNullDelimitedEnv(stdout) : null));
71
- });
72
- }
73
- async function bashSpawnPlan() {
74
- loginEnvCapture ??= captureLoginEnv();
75
- const captured = await loginEnvCapture;
76
- if (captured === null) return { mode: "-lc", env: buildToolEnv() };
77
- const env = { ...process.env, ...captured };
78
- env.AI_AGENT = AI_AGENT_NAME;
79
- for (const key of CLIO_CONTROL_ENV_KEYS) {
80
- Reflect.deleteProperty(env, key);
81
- }
82
- return { mode: "-c", env };
83
- }
84
- function combineBashOutput(result) {
85
- const { stdout, stderr } = result;
86
- return stderr.length > 0 ? `${stdout}${stdout.endsWith("\n") || stdout.length === 0 ? "" : "\n"}${stderr}` : stdout;
87
- }
88
- async function runBashCommand(command, options = {}) {
89
- const plan = await bashSpawnPlan();
90
- const attribution = withManagedGitCommitAttributionEnvironment(plan.env, {
91
- cwd: options.cwd ?? process.cwd(),
92
- enabled: gitCommitAttributionEnabled(process.env)
93
- });
94
- reportCommitAttributionDiagnostic(attribution.diagnostic);
95
- return new Promise((resolve) => {
96
- const timeout = clampTimerDelayMs(options.timeoutMs ?? 3e5);
97
- let aborted = false;
98
- let timedOut = false;
99
- let settled = false;
100
- let timeoutId = null;
101
- let killGraceTimer = null;
102
- let killSent = false;
103
- let stdout = "";
104
- let stderr = "";
105
- let outputBytes = 0;
106
- let outputCapped = false;
107
- let updateTimer = null;
108
- let updateDirty = false;
109
- let lastUpdateAt = 0;
110
- const child = spawn("/bin/bash", [plan.mode, command], {
111
- ...options.cwd === void 0 ? {} : { cwd: options.cwd },
112
- env: attribution.env,
113
- detached: process.platform !== "win32",
114
- stdio: ["ignore", "pipe", "pipe"]
115
- });
116
- const emitUpdate = () => {
117
- if (options.onUpdate === void 0 || !updateDirty) return;
118
- updateDirty = false;
119
- lastUpdateAt = Date.now();
120
- try {
121
- options.onUpdate({ stdout, stderr, outputBytes: Math.min(outputBytes, BASH_HARD_CAP_BYTES) });
122
- } catch {
123
- }
124
- };
125
- const clearUpdateTimer = () => {
126
- if (updateTimer === null) return;
127
- clearTimeout(updateTimer);
128
- updateTimer = null;
129
- };
130
- const scheduleUpdate = () => {
131
- if (options.onUpdate === void 0) return;
132
- updateDirty = true;
133
- const delay = BASH_UPDATE_THROTTLE_MS - (Date.now() - lastUpdateAt);
134
- if (delay <= 0) {
135
- clearUpdateTimer();
136
- emitUpdate();
137
- return;
138
- }
139
- updateTimer ??= setTimeout(() => {
140
- updateTimer = null;
141
- emitUpdate();
142
- }, delay);
143
- };
144
- const finishUpdates = () => {
145
- clearUpdateTimer();
146
- emitUpdate();
147
- };
148
- if (options.onUpdate !== void 0) {
149
- updateDirty = true;
150
- emitUpdate();
151
- }
152
- const clearKillGraceTimer = () => {
153
- if (!killGraceTimer) return;
154
- clearTimeout(killGraceTimer);
155
- killGraceTimer = null;
156
- };
157
- const sendSignal = (signalName) => {
158
- const pid = child.pid;
159
- if (pid && process.platform !== "win32") {
160
- try {
161
- process.kill(-pid, signalName);
162
- return;
163
- } catch {
164
- }
165
- }
166
- child.kill(signalName);
167
- };
168
- const killChild = () => {
169
- if (killSent) return;
170
- killSent = true;
171
- sendSignal("SIGTERM");
172
- killGraceTimer = setTimeout(() => {
173
- sendSignal("SIGKILL");
174
- }, 5e3);
175
- };
176
- function onAbort() {
177
- aborted = true;
178
- killChild();
179
- }
180
- if (timeout > 0) {
181
- timeoutId = setTimeout(() => {
182
- timedOut = true;
183
- killChild();
184
- }, timeout);
185
- }
186
- if (options.signal?.aborted) {
187
- onAbort();
188
- } else {
189
- options.signal?.addEventListener("abort", onAbort, { once: true });
190
- }
191
- const appendChunk = (target, chunk) => {
192
- if (outputCapped) return;
193
- outputBytes += chunk.byteLength;
194
- if (outputBytes > BASH_HARD_CAP_BYTES) {
195
- const remaining = BASH_HARD_CAP_BYTES - (outputBytes - chunk.byteLength);
196
- if (remaining > 0) {
197
- const slice = chunk.subarray(0, remaining).toString("utf8");
198
- if (target === "stdout") stdout += slice;
199
- else stderr += slice;
200
- }
201
- outputCapped = true;
202
- scheduleUpdate();
203
- killChild();
204
- return;
205
- }
206
- if (target === "stdout") stdout += chunk.toString("utf8");
207
- else stderr += chunk.toString("utf8");
208
- scheduleUpdate();
209
- };
210
- child.stdout?.on("data", (chunk) => appendChunk("stdout", chunk));
211
- child.stderr?.on("data", (chunk) => appendChunk("stderr", chunk));
212
- child.on("error", (error) => {
213
- if (settled) return;
214
- settled = true;
215
- if (timeoutId) clearTimeout(timeoutId);
216
- clearKillGraceTimer();
217
- finishUpdates();
218
- options.signal?.removeEventListener("abort", onAbort);
219
- resolve({
220
- error,
221
- stdout,
222
- stderr,
223
- exitCode: null,
224
- signal: null,
225
- aborted,
226
- timedOut,
227
- outputCapped
228
- });
229
- });
230
- child.on("close", (code, signalName) => {
231
- if (settled) return;
232
- settled = true;
233
- if (timeoutId) clearTimeout(timeoutId);
234
- clearKillGraceTimer();
235
- finishUpdates();
236
- options.signal?.removeEventListener("abort", onAbort);
237
- const error = code === 0 && signalName === null ? null : {
238
- name: "Error",
239
- message: signalName ? `command terminated by ${signalName}` : `command exited with code ${code ?? "?"}`,
240
- code: code ?? void 0,
241
- signal: signalName ?? void 0
242
- };
243
- resolve({ error, stdout, stderr, exitCode: code, signal: signalName, aborted, timedOut, outputCapped });
244
- });
245
- });
246
- }
247
-
248
- export {
249
- HEADLESS_PERMISSION_DENIED_REASON,
250
- HEADLESS_PERMISSION_DENIED_MARKER,
251
- BASH_HARD_CAP_BYTES,
252
- combineBashOutput,
253
- runBashCommand
254
- };
255
- //# sourceMappingURL=chunk-MNA4JGU4.js.map
@@ -1,184 +0,0 @@
1
- import { createRequire as __clioCreateRequire } from "node:module"; const require = __clioCreateRequire(import.meta.url);
2
- import {
3
- gitCommitAttributionEnabled,
4
- reportCommitAttributionDiagnostic,
5
- withManagedGitCommitAttributionEnvironment
6
- } from "./chunk-X75S7HFS.js";
7
- import {
8
- clampTimerDelayMs
9
- } from "./chunk-FQ4SKYE4.js";
10
- import {
11
- AI_AGENT_NAME
12
- } from "./chunk-6EJMN2Y3.js";
13
- import {
14
- init_esm_shims
15
- } from "./chunk-3R73A4XB.js";
16
-
17
- // src/core/safe-exec.ts
18
- init_esm_shims();
19
- import { spawn } from "node:child_process";
20
- import path from "node:path";
21
- import { performance } from "node:perf_hooks";
22
- var SAFE_EXEC_DEFAULT_TIMEOUT_MS = 12e4;
23
- var SAFE_EXEC_DEFAULT_MAX_OUTPUT_BYTES = 6e5;
24
- var ENV_ALLOWLIST = [
25
- "PATH",
26
- "HOME",
27
- "USER",
28
- "LOGNAME",
29
- "LANG",
30
- "LC_ALL",
31
- "TMPDIR",
32
- "TEMP",
33
- "TMP",
34
- "CI",
35
- "NO_COLOR"
36
- ];
37
- function buildSafeToolEnv(extra = {}) {
38
- const env = {};
39
- for (const key of ENV_ALLOWLIST) {
40
- const value = process.env[key];
41
- if (value !== void 0) env[key] = value;
42
- }
43
- for (const [key, value] of Object.entries(extra)) {
44
- if (!/^[A-Z_][A-Z0-9_]*$/i.test(key)) continue;
45
- env[key] = value;
46
- }
47
- env.AI_AGENT = AI_AGENT_NAME;
48
- return env;
49
- }
50
- function resolveSafeCwd(cwd, workspaceRoot = process.cwd()) {
51
- const root = path.resolve(workspaceRoot);
52
- const resolved = cwd === void 0 ? root : path.isAbsolute(cwd) ? path.resolve(cwd) : path.resolve(root, cwd);
53
- const rel = path.relative(root, resolved);
54
- if (rel === "" || !rel.startsWith("..") && !path.isAbsolute(rel)) return resolved;
55
- throw new Error(`cwd escapes workspace root: ${resolved}`);
56
- }
57
- function runCommandVector(file, args, options = {}) {
58
- return new Promise((resolve) => {
59
- const startedAt = performance.now();
60
- const cwd = resolveSafeCwd(options.cwd, options.workspaceRoot);
61
- const timeoutMs = clampTimerDelayMs(options.timeoutMs ?? SAFE_EXEC_DEFAULT_TIMEOUT_MS);
62
- const maxOutputBytes = options.maxOutputBytes ?? SAFE_EXEC_DEFAULT_MAX_OUTPUT_BYTES;
63
- const attribution = withManagedGitCommitAttributionEnvironment(buildSafeToolEnv(options.env), {
64
- cwd,
65
- enabled: gitCommitAttributionEnabled(process.env)
66
- });
67
- reportCommitAttributionDiagnostic(attribution.diagnostic);
68
- let aborted = false;
69
- let timedOut = false;
70
- let outputCapped = false;
71
- let outputBytes = 0;
72
- let stdout = "";
73
- let stderr = "";
74
- let settled = false;
75
- let killSent = false;
76
- let timeoutId = null;
77
- let killGraceTimer = null;
78
- const child = spawn(file, [...args], {
79
- cwd,
80
- env: attribution.env,
81
- detached: process.platform !== "win32",
82
- stdio: ["ignore", "pipe", "pipe"]
83
- });
84
- const clearKillGraceTimer = () => {
85
- if (killGraceTimer) clearTimeout(killGraceTimer);
86
- killGraceTimer = null;
87
- };
88
- const sendSignal = (signalName) => {
89
- const pid = child.pid;
90
- if (pid && process.platform !== "win32") {
91
- try {
92
- process.kill(-pid, signalName);
93
- return;
94
- } catch {
95
- }
96
- }
97
- child.kill(signalName);
98
- };
99
- const killChild = () => {
100
- if (killSent) return;
101
- killSent = true;
102
- sendSignal("SIGTERM");
103
- killGraceTimer = setTimeout(() => sendSignal("SIGKILL"), 3e3);
104
- };
105
- const onAbort = () => {
106
- aborted = true;
107
- killChild();
108
- };
109
- if (timeoutMs > 0) {
110
- timeoutId = setTimeout(() => {
111
- timedOut = true;
112
- killChild();
113
- }, timeoutMs);
114
- }
115
- if (options.signal?.aborted) onAbort();
116
- else options.signal?.addEventListener("abort", onAbort, { once: true });
117
- const appendChunk = (target, chunk) => {
118
- outputBytes += chunk.byteLength;
119
- if (outputBytes > maxOutputBytes) {
120
- outputCapped = true;
121
- killChild();
122
- return;
123
- }
124
- if (target === "stdout") stdout += chunk.toString("utf8");
125
- else stderr += chunk.toString("utf8");
126
- };
127
- child.stdout?.on("data", (chunk) => appendChunk("stdout", chunk));
128
- child.stderr?.on("data", (chunk) => appendChunk("stderr", chunk));
129
- child.on("error", (error) => {
130
- if (settled) return;
131
- settled = true;
132
- if (timeoutId) clearTimeout(timeoutId);
133
- clearKillGraceTimer();
134
- options.signal?.removeEventListener("abort", onAbort);
135
- resolve({
136
- file,
137
- args: [...args],
138
- cwd,
139
- stdout,
140
- stderr: stderr.length > 0 ? stderr : error.message,
141
- exitCode: null,
142
- signal: null,
143
- aborted,
144
- timedOut,
145
- outputCapped,
146
- durationMs: Math.round(performance.now() - startedAt)
147
- });
148
- });
149
- child.on("close", (code, signalName) => {
150
- if (settled) return;
151
- settled = true;
152
- if (timeoutId) clearTimeout(timeoutId);
153
- clearKillGraceTimer();
154
- options.signal?.removeEventListener("abort", onAbort);
155
- resolve({
156
- file,
157
- args: [...args],
158
- cwd,
159
- stdout,
160
- stderr,
161
- exitCode: code,
162
- signal: signalName,
163
- aborted,
164
- timedOut,
165
- outputCapped,
166
- durationMs: Math.round(performance.now() - startedAt)
167
- });
168
- });
169
- });
170
- }
171
- function combineSafeOutput(result) {
172
- const { stdout, stderr } = result;
173
- return stderr.length > 0 ? `${stdout}${stdout.endsWith("\n") || stdout.length === 0 ? "" : "\n"}${stderr}` : stdout;
174
- }
175
-
176
- export {
177
- SAFE_EXEC_DEFAULT_TIMEOUT_MS,
178
- SAFE_EXEC_DEFAULT_MAX_OUTPUT_BYTES,
179
- buildSafeToolEnv,
180
- resolveSafeCwd,
181
- runCommandVector,
182
- combineSafeOutput
183
- };
184
- //# sourceMappingURL=chunk-SRF2PJNW.js.map
@@ -1,80 +0,0 @@
1
- import { createRequire as __clioCreateRequire } from "node:module"; const require = __clioCreateRequire(import.meta.url);
2
- import {
3
- init_esm_shims
4
- } from "./chunk-3R73A4XB.js";
5
-
6
- // src/core/skill-activation.ts
7
- init_esm_shims();
8
- var SKILL_SUGGESTION_ANCHOR = "Suggested skill: /skill <name>";
9
- var SKILL_SUGGESTION_PREFIX = SKILL_SUGGESTION_ANCHOR.slice(0, SKILL_SUGGESTION_ANCHOR.indexOf("<name>"));
10
- var SKILL_SURFACE_EXEMPT_TOOLS = /* @__PURE__ */ new Set(["context", "ask_user"]);
11
- function evaluateSkillToolSurface(policy, tool) {
12
- if (!policy || policy.loadedSkillPolicies.size === 0) return null;
13
- if (SKILL_SURFACE_EXEMPT_TOOLS.has(tool)) return null;
14
- const entries = [...policy.loadedSkillPolicies.entries()];
15
- const skills = entries.map(([name]) => name);
16
- const disallowedBy = entries.filter(([, declared]) => declared.disallowedTools?.includes(tool) === true).map(([name]) => name);
17
- if (disallowedBy.length > 0) return { skills, mergedAllowedTools: null, disallowedBy };
18
- const allowLists = entries.map(([, declared]) => declared.allowedTools);
19
- if (allowLists.some((list) => list === void 0 || list.length === 0)) return null;
20
- const merged = [...new Set(allowLists.flatMap((list) => [...list ?? []]))];
21
- if (merged.includes(tool)) return null;
22
- return { skills, mergedAllowedTools: merged, disallowedBy: [] };
23
- }
24
- function agentSkillToolPolicy(skillNames) {
25
- const allowedSkillNames = [...new Set(skillNames.map((name) => name.trim()).filter((name) => name.length > 0))];
26
- if (allowedSkillNames.length === 0) return void 0;
27
- return {
28
- allowedSkillNames,
29
- requests: allowedSkillNames.map((name) => ({ name, args: "", source: "recipe", installed: true })),
30
- loadedSkillNames: /* @__PURE__ */ new Set(),
31
- loadedSkillPolicies: /* @__PURE__ */ new Map()
32
- };
33
- }
34
- function trimmedString(value) {
35
- return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
36
- }
37
- function skillActivationFromSource(source, triggeredBy, turnId) {
38
- const sourceOrigin = trimmedString(source.sourceOrigin) ?? trimmedString(source.sourceInfo?.source);
39
- return {
40
- name: source.name,
41
- filePath: source.filePath,
42
- hash: source.hash,
43
- source: source.source,
44
- ...sourceOrigin ? { sourceOrigin } : {},
45
- triggeredBy,
46
- ...turnId ? { turnId } : {}
47
- };
48
- }
49
- function skillActivationFromToolDetails(details, turnId) {
50
- if (!details || typeof details !== "object" || Array.isArray(details)) return null;
51
- const record = details;
52
- const name = trimmedString(record.name);
53
- const filePath = trimmedString(record.filePath) ?? trimmedString(record.path);
54
- const hash = trimmedString(record.hash);
55
- const source = trimmedString(record.source);
56
- const sourceOrigin = trimmedString(record.sourceOrigin) ?? trimmedString(record.origin);
57
- if (!name || !filePath || !hash || !source) return null;
58
- const activation = skillActivationFromSource(
59
- { name, filePath, hash, source, ...sourceOrigin ? { sourceOrigin } : {} },
60
- "tool",
61
- turnId
62
- );
63
- if (record.drift === "match" || record.drift === "mismatch") activation.drift = record.drift;
64
- return activation;
65
- }
66
- function isSkillActivation(value) {
67
- if (!value || typeof value !== "object" || Array.isArray(value)) return false;
68
- const record = value;
69
- return typeof record.name === "string" && typeof record.filePath === "string" && typeof record.hash === "string" && typeof record.source === "string" && (record.sourceOrigin === void 0 || typeof record.sourceOrigin === "string") && (record.triggeredBy === "slash-command" || record.triggeredBy === "tool") && (record.turnId === void 0 || typeof record.turnId === "string") && (record.runId === void 0 || typeof record.runId === "string");
70
- }
71
-
72
- export {
73
- SKILL_SUGGESTION_ANCHOR,
74
- SKILL_SUGGESTION_PREFIX,
75
- evaluateSkillToolSurface,
76
- agentSkillToolPolicy,
77
- skillActivationFromToolDetails,
78
- isSkillActivation
79
- };
80
- //# sourceMappingURL=chunk-T6YILFSB.js.map