@stigmer/sdk 3.0.9-dev.20260616060535 → 3.1.1

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 (240) hide show
  1. package/activity.js +1 -1
  2. package/activity.js.map +1 -1
  3. package/authorization-config.js +1 -1
  4. package/authorization-config.js.map +1 -1
  5. package/billing.js +1 -1
  6. package/billing.js.map +1 -1
  7. package/errors.d.ts +1 -1
  8. package/errors.d.ts.map +1 -1
  9. package/errors.js +2 -2
  10. package/errors.js.map +1 -1
  11. package/execution/__tests__/approval-provenance.test.d.ts +2 -0
  12. package/execution/__tests__/approval-provenance.test.d.ts.map +1 -0
  13. package/execution/__tests__/approval-provenance.test.js +42 -0
  14. package/execution/__tests__/approval-provenance.test.js.map +1 -0
  15. package/execution/__tests__/file-review-fold.corpus.test.d.ts +2 -0
  16. package/execution/__tests__/file-review-fold.corpus.test.d.ts.map +1 -0
  17. package/execution/__tests__/file-review-fold.corpus.test.js +82 -0
  18. package/execution/__tests__/file-review-fold.corpus.test.js.map +1 -0
  19. package/execution/__tests__/file-review-fold.test.d.ts +2 -0
  20. package/execution/__tests__/file-review-fold.test.d.ts.map +1 -0
  21. package/execution/__tests__/file-review-fold.test.js +184 -0
  22. package/execution/__tests__/file-review-fold.test.js.map +1 -0
  23. package/execution/__tests__/to-display-file-change.test.d.ts +2 -0
  24. package/execution/__tests__/to-display-file-change.test.d.ts.map +1 -0
  25. package/execution/__tests__/to-display-file-change.test.js +69 -0
  26. package/execution/__tests__/to-display-file-change.test.js.map +1 -0
  27. package/execution/__tests__/tool-view.file-changes.test.d.ts +2 -0
  28. package/execution/__tests__/tool-view.file-changes.test.d.ts.map +1 -0
  29. package/execution/__tests__/tool-view.file-changes.test.js +86 -0
  30. package/execution/__tests__/tool-view.file-changes.test.js.map +1 -0
  31. package/execution/__tests__/tool-view.fixtures.test.js +3 -0
  32. package/execution/__tests__/tool-view.fixtures.test.js.map +1 -1
  33. package/execution/__tests__/tool-view.output-ref.test.d.ts +2 -0
  34. package/execution/__tests__/tool-view.output-ref.test.d.ts.map +1 -0
  35. package/execution/__tests__/tool-view.output-ref.test.js +64 -0
  36. package/execution/__tests__/tool-view.output-ref.test.js.map +1 -0
  37. package/execution/__tests__/tool-view.search.test.d.ts +2 -0
  38. package/execution/__tests__/tool-view.search.test.d.ts.map +1 -0
  39. package/execution/__tests__/tool-view.search.test.js +200 -0
  40. package/execution/__tests__/tool-view.search.test.js.map +1 -0
  41. package/execution/__tests__/tool-view.shell.test.d.ts +2 -0
  42. package/execution/__tests__/tool-view.shell.test.d.ts.map +1 -0
  43. package/execution/__tests__/tool-view.shell.test.js +104 -0
  44. package/execution/__tests__/tool-view.shell.test.js.map +1 -0
  45. package/execution/approval-provenance.d.ts +30 -0
  46. package/execution/approval-provenance.d.ts.map +1 -0
  47. package/execution/approval-provenance.js +73 -0
  48. package/execution/approval-provenance.js.map +1 -0
  49. package/execution/execution-phases.d.ts +7 -0
  50. package/execution/execution-phases.d.ts.map +1 -0
  51. package/execution/execution-phases.js +21 -0
  52. package/execution/execution-phases.js.map +1 -0
  53. package/execution/file-review-fold.d.ts +44 -0
  54. package/execution/file-review-fold.d.ts.map +1 -0
  55. package/execution/file-review-fold.js +182 -0
  56. package/execution/file-review-fold.js.map +1 -0
  57. package/execution/to-display-file-change.d.ts +14 -0
  58. package/execution/to-display-file-change.d.ts.map +1 -0
  59. package/execution/to-display-file-change.js +57 -0
  60. package/execution/to-display-file-change.js.map +1 -0
  61. package/execution/tool-view.d.ts +8 -2
  62. package/execution/tool-view.d.ts.map +1 -1
  63. package/execution/tool-view.js +205 -21
  64. package/execution/tool-view.js.map +1 -1
  65. package/gen/agent.d.ts +1 -1
  66. package/gen/agent.d.ts.map +1 -1
  67. package/gen/agent.js +2 -2
  68. package/gen/agent.js.map +1 -1
  69. package/gen/agentexecution.d.ts +3 -2
  70. package/gen/agentexecution.d.ts.map +1 -1
  71. package/gen/agentexecution.js +10 -2
  72. package/gen/agentexecution.js.map +1 -1
  73. package/gen/agentinstance.d.ts +1 -1
  74. package/gen/agentinstance.d.ts.map +1 -1
  75. package/gen/agentinstance.js +2 -2
  76. package/gen/agentinstance.js.map +1 -1
  77. package/gen/apikey.js +2 -2
  78. package/gen/apikey.js.map +1 -1
  79. package/gen/artifact.js +2 -2
  80. package/gen/artifact.js.map +1 -1
  81. package/gen/client.d.ts +65 -65
  82. package/gen/client.d.ts.map +1 -1
  83. package/gen/client.js +43 -43
  84. package/gen/client.js.map +1 -1
  85. package/gen/environment.d.ts +1 -1
  86. package/gen/environment.d.ts.map +1 -1
  87. package/gen/environment.js +2 -2
  88. package/gen/environment.js.map +1 -1
  89. package/gen/executioncontext.d.ts +1 -1
  90. package/gen/executioncontext.d.ts.map +1 -1
  91. package/gen/executioncontext.js +2 -2
  92. package/gen/executioncontext.js.map +1 -1
  93. package/gen/iampolicy.js +2 -2
  94. package/gen/iampolicy.js.map +1 -1
  95. package/gen/identityaccount.d.ts +1 -1
  96. package/gen/identityaccount.d.ts.map +1 -1
  97. package/gen/identityaccount.js +2 -2
  98. package/gen/identityaccount.js.map +1 -1
  99. package/gen/identityprovider.d.ts +1 -1
  100. package/gen/identityprovider.d.ts.map +1 -1
  101. package/gen/identityprovider.js +2 -2
  102. package/gen/identityprovider.js.map +1 -1
  103. package/gen/invitation.js +2 -2
  104. package/gen/invitation.js.map +1 -1
  105. package/gen/mcpserver.d.ts +2 -1
  106. package/gen/mcpserver.d.ts.map +1 -1
  107. package/gen/mcpserver.js +3 -2
  108. package/gen/mcpserver.js.map +1 -1
  109. package/gen/oauthapp.d.ts +1 -1
  110. package/gen/oauthapp.d.ts.map +1 -1
  111. package/gen/oauthapp.js +2 -2
  112. package/gen/oauthapp.js.map +1 -1
  113. package/gen/organization.d.ts +1 -1
  114. package/gen/organization.d.ts.map +1 -1
  115. package/gen/organization.js +2 -2
  116. package/gen/organization.js.map +1 -1
  117. package/gen/platformclient.d.ts +1 -1
  118. package/gen/platformclient.d.ts.map +1 -1
  119. package/gen/platformclient.js +2 -2
  120. package/gen/platformclient.js.map +1 -1
  121. package/gen/project.d.ts +1 -1
  122. package/gen/project.d.ts.map +1 -1
  123. package/gen/project.js +2 -2
  124. package/gen/project.js.map +1 -1
  125. package/gen/session.d.ts +1 -1
  126. package/gen/session.d.ts.map +1 -1
  127. package/gen/session.js +2 -2
  128. package/gen/session.js.map +1 -1
  129. package/gen/skill.d.ts +1 -1
  130. package/gen/skill.d.ts.map +1 -1
  131. package/gen/skill.js +2 -2
  132. package/gen/skill.js.map +1 -1
  133. package/gen/workflow.d.ts +1 -1
  134. package/gen/workflow.d.ts.map +1 -1
  135. package/gen/workflow.js +2 -2
  136. package/gen/workflow.js.map +1 -1
  137. package/gen/workflowexecution.d.ts +3 -2
  138. package/gen/workflowexecution.d.ts.map +1 -1
  139. package/gen/workflowexecution.js +10 -2
  140. package/gen/workflowexecution.js.map +1 -1
  141. package/gen/workflowinstance.d.ts +1 -1
  142. package/gen/workflowinstance.d.ts.map +1 -1
  143. package/gen/workflowinstance.js +2 -2
  144. package/gen/workflowinstance.js.map +1 -1
  145. package/github.js +1 -1
  146. package/github.js.map +1 -1
  147. package/index.d.ts +40 -36
  148. package/index.d.ts.map +1 -1
  149. package/index.js +37 -33
  150. package/index.js.map +1 -1
  151. package/internal/interceptors.d.ts +1 -1
  152. package/internal/interceptors.d.ts.map +1 -1
  153. package/internal/interceptors.js +1 -1
  154. package/internal/interceptors.js.map +1 -1
  155. package/node.d.ts +2 -2
  156. package/node.d.ts.map +1 -1
  157. package/node.js +3 -3
  158. package/node.js.map +1 -1
  159. package/package.json +2 -2
  160. package/platform-client-auth.js +2 -2
  161. package/platform-client-auth.js.map +1 -1
  162. package/platform.d.ts +1 -1
  163. package/platform.d.ts.map +1 -1
  164. package/platform.js +1 -1
  165. package/platform.js.map +1 -1
  166. package/resource-availability.js +1 -1
  167. package/resource-availability.js.map +1 -1
  168. package/search.js +1 -1
  169. package/search.js.map +1 -1
  170. package/src/activity.ts +1 -1
  171. package/src/authorization-config.ts +1 -1
  172. package/src/billing.ts +1 -1
  173. package/src/errors.ts +2 -2
  174. package/src/execution/__tests__/approval-provenance.test.ts +60 -0
  175. package/src/execution/__tests__/file-review-fold.corpus.test.ts +127 -0
  176. package/src/execution/__tests__/file-review-fold.test.ts +281 -0
  177. package/src/execution/__tests__/to-display-file-change.test.ts +91 -0
  178. package/src/execution/__tests__/tool-view.file-changes.test.ts +100 -0
  179. package/src/execution/__tests__/tool-view.fixtures.test.ts +4 -0
  180. package/src/execution/__tests__/tool-view.output-ref.test.ts +76 -0
  181. package/src/execution/__tests__/tool-view.search.test.ts +264 -0
  182. package/src/execution/__tests__/tool-view.shell.test.ts +127 -0
  183. package/src/execution/approval-provenance.ts +80 -0
  184. package/src/execution/execution-phases.ts +23 -0
  185. package/src/execution/file-review-fold.ts +210 -0
  186. package/src/execution/to-display-file-change.ts +66 -0
  187. package/src/execution/tool-view.ts +261 -30
  188. package/src/gen/agent.ts +3 -3
  189. package/src/gen/agentexecution.ts +10 -4
  190. package/src/gen/agentinstance.ts +3 -3
  191. package/src/gen/apikey.ts +2 -2
  192. package/src/gen/artifact.ts +2 -2
  193. package/src/gen/client.ts +65 -65
  194. package/src/gen/environment.ts +3 -3
  195. package/src/gen/executioncontext.ts +3 -3
  196. package/src/gen/iampolicy.ts +2 -2
  197. package/src/gen/identityaccount.ts +3 -3
  198. package/src/gen/identityprovider.ts +3 -3
  199. package/src/gen/invitation.ts +2 -2
  200. package/src/gen/mcpserver.ts +5 -3
  201. package/src/gen/oauthapp.ts +3 -3
  202. package/src/gen/organization.ts +3 -3
  203. package/src/gen/platformclient.ts +3 -3
  204. package/src/gen/project.ts +3 -3
  205. package/src/gen/session.ts +3 -3
  206. package/src/gen/skill.ts +3 -3
  207. package/src/gen/workflow.ts +3 -3
  208. package/src/gen/workflowexecution.ts +10 -4
  209. package/src/gen/workflowinstance.ts +3 -3
  210. package/src/github.ts +1 -1
  211. package/src/index.ts +48 -36
  212. package/src/internal/interceptors.ts +2 -2
  213. package/src/node.ts +3 -3
  214. package/src/platform-client-auth.ts +2 -2
  215. package/src/platform.ts +2 -2
  216. package/src/resource-availability.ts +1 -1
  217. package/src/search.ts +1 -1
  218. package/src/stigmer.ts +8 -8
  219. package/src/synth/context.ts +3 -3
  220. package/src/synth/index.ts +6 -6
  221. package/src/synth/writer.ts +4 -4
  222. package/src/transport.ts +2 -2
  223. package/stigmer.d.ts +7 -7
  224. package/stigmer.d.ts.map +1 -1
  225. package/stigmer.js +8 -8
  226. package/stigmer.js.map +1 -1
  227. package/synth/context.d.ts +3 -3
  228. package/synth/context.d.ts.map +1 -1
  229. package/synth/index.d.ts +5 -5
  230. package/synth/index.d.ts.map +1 -1
  231. package/synth/index.js +3 -3
  232. package/synth/index.js.map +1 -1
  233. package/synth/writer.d.ts +1 -1
  234. package/synth/writer.d.ts.map +1 -1
  235. package/synth/writer.js +3 -3
  236. package/synth/writer.js.map +1 -1
  237. package/transport.d.ts +1 -1
  238. package/transport.d.ts.map +1 -1
  239. package/transport.js +1 -1
  240. package/transport.js.map +1 -1
@@ -0,0 +1,73 @@
1
+ // Framework-agnostic authorization-provenance labels for every Stigmer surface.
2
+ //
3
+ // describeApprovalPolicySource maps the wire ApprovalPolicySource — *which policy
4
+ // layer decided a tool call's approval requirement* — to a short human phrase.
5
+ // It is shared by @stigmer/react (the ApprovalCard "why-gated" line and the
6
+ // tool-call detail view) and @stigmer/ink (the terminal approval prompt); the Go
7
+ // CLI mirrors it. The phrasing is intrinsic to the source's semantics so the
8
+ // same label reads correctly whether the call is still waiting (a gating source
9
+ // → "required by …") or already cleared (a bypass source → "auto-approved …").
10
+ import { ApprovalPolicySource } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
11
+ export { ApprovalPolicySource };
12
+ /**
13
+ * Returns a short human phrase describing a tool call's authorization
14
+ * provenance, or `null` for {@link ApprovalPolicySource.UNSPECIFIED} — an
15
+ * execution that predates this field, or a tool the gate never evaluated (e.g. a
16
+ * read-only built-in) — so callers render nothing rather than a misleading
17
+ * default.
18
+ */
19
+ export function describeApprovalPolicySource(source) {
20
+ switch (source) {
21
+ case ApprovalPolicySource.CLASSIFIER_DEFAULT:
22
+ return "required by the tool's default policy";
23
+ case ApprovalPolicySource.PINNED_OVERRIDE:
24
+ return "required by a pinned override";
25
+ case ApprovalPolicySource.AGENT_OVERRIDE:
26
+ return "required by agent override";
27
+ case ApprovalPolicySource.BUILTIN_CATEGORY:
28
+ return "required by built-in tool policy";
29
+ case ApprovalPolicySource.ANNOTATION_DESTRUCTIVE_TIGHTEN:
30
+ return "required: marked destructive by the server";
31
+ case ApprovalPolicySource.AUTO_APPROVE_ALL:
32
+ return "auto-approved by a run-wide bypass";
33
+ case ApprovalPolicySource.APPROVAL_LEASE:
34
+ return "auto-approved by a run lease";
35
+ case ApprovalPolicySource.UNSPECIFIED:
36
+ default:
37
+ return null;
38
+ }
39
+ }
40
+ /**
41
+ * Returns whether a policy source carries information worth surfacing inline at
42
+ * the approval gate, versus the everyday default ("this tool category just
43
+ * requires approval") that is noise next to the action it is already gating.
44
+ *
45
+ * The default gating reasons — {@link ApprovalPolicySource.CLASSIFIER_DEFAULT}
46
+ * and {@link ApprovalPolicySource.BUILTIN_CATEGORY} — explain nothing the user
47
+ * does not already infer from the tool itself, so they are suppressed from the
48
+ * card (the full phrase stays available on hover where a surface chooses to show
49
+ * a chip). The remaining sources each change the user's understanding of *why*
50
+ * this particular call is held — an explicit override, a server tightening a
51
+ * destructive tool, or (post-execution) a bypass/lease that cleared it — and so
52
+ * are worth showing. {@link ApprovalPolicySource.UNSPECIFIED} is never
53
+ * informative (legacy / ungated).
54
+ *
55
+ * This is the headless policy behind the gate's "smart-suppress" provenance
56
+ * chip; rendering lives in the consuming surface.
57
+ */
58
+ export function isInformativePolicySource(source) {
59
+ switch (source) {
60
+ case ApprovalPolicySource.PINNED_OVERRIDE:
61
+ case ApprovalPolicySource.AGENT_OVERRIDE:
62
+ case ApprovalPolicySource.ANNOTATION_DESTRUCTIVE_TIGHTEN:
63
+ case ApprovalPolicySource.AUTO_APPROVE_ALL:
64
+ case ApprovalPolicySource.APPROVAL_LEASE:
65
+ return true;
66
+ case ApprovalPolicySource.CLASSIFIER_DEFAULT:
67
+ case ApprovalPolicySource.BUILTIN_CATEGORY:
68
+ case ApprovalPolicySource.UNSPECIFIED:
69
+ default:
70
+ return false;
71
+ }
72
+ }
73
+ //# sourceMappingURL=approval-provenance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval-provenance.js","sourceRoot":"","sources":["../../src/execution/approval-provenance.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,EAAE;AACF,kFAAkF;AAClF,+EAA+E;AAC/E,4EAA4E;AAC5E,iFAAiF;AACjF,6EAA6E;AAC7E,gFAAgF;AAChF,+EAA+E;AAE/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,8DAA8D,CAAC;AAEpG,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAEhC;;;;;;GAMG;AACH,MAAM,UAAU,4BAA4B,CAC1C,MAA4B;IAE5B,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,oBAAoB,CAAC,kBAAkB;YAC1C,OAAO,uCAAuC,CAAC;QACjD,KAAK,oBAAoB,CAAC,eAAe;YACvC,OAAO,+BAA+B,CAAC;QACzC,KAAK,oBAAoB,CAAC,cAAc;YACtC,OAAO,4BAA4B,CAAC;QACtC,KAAK,oBAAoB,CAAC,gBAAgB;YACxC,OAAO,kCAAkC,CAAC;QAC5C,KAAK,oBAAoB,CAAC,8BAA8B;YACtD,OAAO,4CAA4C,CAAC;QACtD,KAAK,oBAAoB,CAAC,gBAAgB;YACxC,OAAO,oCAAoC,CAAC;QAC9C,KAAK,oBAAoB,CAAC,cAAc;YACtC,OAAO,8BAA8B,CAAC;QACxC,KAAK,oBAAoB,CAAC,WAAW,CAAC;QACtC;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,yBAAyB,CACvC,MAA4B;IAE5B,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,oBAAoB,CAAC,eAAe,CAAC;QAC1C,KAAK,oBAAoB,CAAC,cAAc,CAAC;QACzC,KAAK,oBAAoB,CAAC,8BAA8B,CAAC;QACzD,KAAK,oBAAoB,CAAC,gBAAgB,CAAC;QAC3C,KAAK,oBAAoB,CAAC,cAAc;YACtC,OAAO,IAAI,CAAC;QACd,KAAK,oBAAoB,CAAC,kBAAkB,CAAC;QAC7C,KAAK,oBAAoB,CAAC,gBAAgB,CAAC;QAC3C,KAAK,oBAAoB,CAAC,WAAW,CAAC;QACtC;YACE,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { ExecutionPhase } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
2
+ /**
3
+ * Returns `true` when the given phase represents a final, immutable
4
+ * execution state — no further updates will arrive from the server.
5
+ */
6
+ export declare function isTerminalPhase(phase: ExecutionPhase): boolean;
7
+ //# sourceMappingURL=execution-phases.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-phases.d.ts","sourceRoot":"","sources":["../../src/execution/execution-phases.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,cAAc,EAAE,MAAM,8DAA8D,CAAC;AAS9F;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAE9D"}
@@ -0,0 +1,21 @@
1
+ // Framework-agnostic execution-phase predicates.
2
+ //
3
+ // Lives in @stigmer/sdk (the pure layer) so it is shared by @stigmer/react and
4
+ // @stigmer/ink and usable by pure logic here (e.g. the file-review fold's corpus
5
+ // parity test reproduces the server's terminal-phase gate). @stigmer/react
6
+ // re-exports it so its public API is unchanged.
7
+ import { ExecutionPhase } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
8
+ const TERMINAL_PHASES = new Set([
9
+ ExecutionPhase.EXECUTION_COMPLETED,
10
+ ExecutionPhase.EXECUTION_FAILED,
11
+ ExecutionPhase.EXECUTION_CANCELLED,
12
+ ExecutionPhase.EXECUTION_TERMINATED,
13
+ ]);
14
+ /**
15
+ * Returns `true` when the given phase represents a final, immutable
16
+ * execution state — no further updates will arrive from the server.
17
+ */
18
+ export function isTerminalPhase(phase) {
19
+ return TERMINAL_PHASES.has(phase);
20
+ }
21
+ //# sourceMappingURL=execution-phases.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-phases.js","sourceRoot":"","sources":["../../src/execution/execution-phases.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,EAAE;AACF,+EAA+E;AAC/E,iFAAiF;AACjF,2EAA2E;AAC3E,gDAAgD;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,8DAA8D,CAAC;AAE9F,MAAM,eAAe,GAAgC,IAAI,GAAG,CAAC;IAC3D,cAAc,CAAC,mBAAmB;IAClC,cAAc,CAAC,gBAAgB;IAC/B,cAAc,CAAC,mBAAmB;IAClC,cAAc,CAAC,oBAAoB;CACpC,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,KAAqB;IACnD,OAAO,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC"}
@@ -0,0 +1,44 @@
1
+ import type { AgentExecutionStatus } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/api_pb";
2
+ import type { FileChangeSet, FileReviewEventStream } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/filereview_pb";
3
+ /**
4
+ * Folds a file-review event ledger into its list of {@link FileChangeSet}s,
5
+ * grouped by `change_set_id` in first-seen order.
6
+ *
7
+ * This is the display fold: unlike the server projection it does NOT collapse to
8
+ * an empty list for a terminal execution, so a completed/failed/cancelled
9
+ * execution still yields its settled sets for read-only display. For the LIVE
10
+ * (actionable) view, prefer the server-computed `status.file_change_sets`
11
+ * projection (it is structurally shared across stream frames); this fold is the
12
+ * settled/terminal complement — see {@link displayFileChangeSets}.
13
+ *
14
+ * The fold is a faithful port of the Go/Java projector: scalar and snapshot
15
+ * fields are last-writer-wins, `decisions` accumulate, `changes` are replaced
16
+ * wholesale by the latest `CANDIDATE_CAPTURED`, and terminal `RECONCILED` /
17
+ * `FAILED` statuses are sticky (a later non-terminal event never downgrades
18
+ * them).
19
+ *
20
+ * @param stream - The execution's `file_review_event_stream`, or `undefined`.
21
+ * @returns One {@link FileChangeSet} per `change_set_id`, in first-seen order.
22
+ */
23
+ export declare function foldFileReviewEventStream(stream: FileReviewEventStream | undefined): FileChangeSet[];
24
+ /**
25
+ * The single read seam for displaying an execution's file change sets.
26
+ *
27
+ * Returns the server-computed `status.file_change_sets` projection when it is
28
+ * present (a LIVE execution — the projection is structurally shared across
29
+ * stream frames, so consumers keep stable references and streaming re-renders
30
+ * stay scoped to the actively-changing card), and otherwise folds the ledger
31
+ * (a TERMINAL execution — the server projects nil there, but the ledger is
32
+ * preserved). The fold therefore never runs on the streaming hot path; it only
33
+ * reconstructs the settled sets a dead execution would otherwise not display.
34
+ *
35
+ * The two branches are equivalent by construction for a non-terminal execution
36
+ * (the fold minus its terminal gate IS the server projection — locked by the
37
+ * corpus parity test), so this accessor is a single consistent source whichever
38
+ * branch it takes.
39
+ *
40
+ * @param status - The execution status, or `undefined`.
41
+ * @returns The change sets to display, or an empty array when there are none.
42
+ */
43
+ export declare function displayFileChangeSets(status: AgentExecutionStatus | undefined): FileChangeSet[];
44
+ //# sourceMappingURL=file-review-fold.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-review-fold.d.ts","sourceRoot":"","sources":["../../src/execution/file-review-fold.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6DAA6D,CAAC;AACxG,OAAO,KAAK,EACV,aAAa,EAEb,qBAAqB,EACtB,MAAM,oEAAoE,CAAC;AAQ5E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,qBAAqB,GAAG,SAAS,GACxC,aAAa,EAAE,CAsBjB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,oBAAoB,GAAG,SAAS,GACvC,aAAa,EAAE,CAIjB"}
@@ -0,0 +1,182 @@
1
+ // Framework-agnostic fold of the file-review event ledger into FileChangeSets.
2
+ //
3
+ // The server persists an append-only `file_review_event_stream` ledger on the
4
+ // execution status and computes `file_change_sets` as its projection. That
5
+ // server projection is phase-aware: it is nil for a TERMINAL execution (a dead
6
+ // execution has no *actionable* review). Settled/historical display therefore
7
+ // cannot read the projection — it must fold the always-preserved ledger itself.
8
+ //
9
+ // `foldFileReviewEventStream` is the TypeScript port of the Go projector
10
+ // `ProjectFileChangeSets` (backend/services/stigmer-server/pkg/domain/
11
+ // agentexecution/filereview/project.go), and its Java mirror
12
+ // `FileChangeSetProjector`. It is byte-for-byte identical to them EXCEPT it does
13
+ // not apply the terminal-phase gate — that is the whole point of the client-side
14
+ // fold (it must render settled sets for a terminal execution). Every other rule
15
+ // (first-seen change-set ordering, last-writer-wins scalars, decision
16
+ // accumulation, wholesale change replacement, sticky terminal status) matches
17
+ // the server exactly, so live and settled views agree.
18
+ //
19
+ // Parity is not maintained by discipline: the shared cross-edition corpus at
20
+ // apis/testdata/hitl/file-review/*.json — already replayed by the Go and Java
21
+ // projector suites — is replayed against this fold too (see the corpus parity
22
+ // test), so a drift between TS and the backends fails a test rather than
23
+ // shipping.
24
+ //
25
+ // This module has no React/framework dependency (mirrors tool-view.ts) so it is
26
+ // shared by @stigmer/react and @stigmer/ink and mirror-able by the Go CLI.
27
+ import { create } from "@bufbuild/protobuf";
28
+ import { FileChangeSetSchema } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/filereview_pb";
29
+ import { FileChangeSetStatus, FileDecisionScope, FileReviewEventType, } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
30
+ /**
31
+ * Folds a file-review event ledger into its list of {@link FileChangeSet}s,
32
+ * grouped by `change_set_id` in first-seen order.
33
+ *
34
+ * This is the display fold: unlike the server projection it does NOT collapse to
35
+ * an empty list for a terminal execution, so a completed/failed/cancelled
36
+ * execution still yields its settled sets for read-only display. For the LIVE
37
+ * (actionable) view, prefer the server-computed `status.file_change_sets`
38
+ * projection (it is structurally shared across stream frames); this fold is the
39
+ * settled/terminal complement — see {@link displayFileChangeSets}.
40
+ *
41
+ * The fold is a faithful port of the Go/Java projector: scalar and snapshot
42
+ * fields are last-writer-wins, `decisions` accumulate, `changes` are replaced
43
+ * wholesale by the latest `CANDIDATE_CAPTURED`, and terminal `RECONCILED` /
44
+ * `FAILED` statuses are sticky (a later non-terminal event never downgrades
45
+ * them).
46
+ *
47
+ * @param stream - The execution's `file_review_event_stream`, or `undefined`.
48
+ * @returns One {@link FileChangeSet} per `change_set_id`, in first-seen order.
49
+ */
50
+ export function foldFileReviewEventStream(stream) {
51
+ if (!stream || stream.events.length === 0)
52
+ return [];
53
+ const order = [];
54
+ const byId = new Map();
55
+ for (const ev of stream.events) {
56
+ const changeSetId = ev.changeSetId;
57
+ // An event with no correlation id cannot be attributed to a set; the server
58
+ // skips it, so we do too.
59
+ if (!changeSetId)
60
+ continue;
61
+ let set = byId.get(changeSetId);
62
+ if (!set) {
63
+ set = create(FileChangeSetSchema, { id: changeSetId });
64
+ byId.set(changeSetId, set);
65
+ order.push(changeSetId);
66
+ }
67
+ applyEvent(set, ev);
68
+ }
69
+ return order.map((id) => byId.get(id));
70
+ }
71
+ /**
72
+ * The single read seam for displaying an execution's file change sets.
73
+ *
74
+ * Returns the server-computed `status.file_change_sets` projection when it is
75
+ * present (a LIVE execution — the projection is structurally shared across
76
+ * stream frames, so consumers keep stable references and streaming re-renders
77
+ * stay scoped to the actively-changing card), and otherwise folds the ledger
78
+ * (a TERMINAL execution — the server projects nil there, but the ledger is
79
+ * preserved). The fold therefore never runs on the streaming hot path; it only
80
+ * reconstructs the settled sets a dead execution would otherwise not display.
81
+ *
82
+ * The two branches are equivalent by construction for a non-terminal execution
83
+ * (the fold minus its terminal gate IS the server projection — locked by the
84
+ * corpus parity test), so this accessor is a single consistent source whichever
85
+ * branch it takes.
86
+ *
87
+ * @param status - The execution status, or `undefined`.
88
+ * @returns The change sets to display, or an empty array when there are none.
89
+ */
90
+ export function displayFileChangeSets(status) {
91
+ const projected = status?.fileChangeSets;
92
+ if (projected && projected.length > 0)
93
+ return projected;
94
+ return foldFileReviewEventStream(status?.fileReviewEventStream);
95
+ }
96
+ /**
97
+ * Applies one ledger event to its change-set accumulator, mirroring the Go
98
+ * projector's `applyEvent`. The switch is keyed on `event_type` (the coarse
99
+ * bucket the server keys on); the typed payload is read defensively so a
100
+ * malformed event degrades to zero values exactly as the Go nil-getters do,
101
+ * rather than throwing.
102
+ */
103
+ function applyEvent(set, ev) {
104
+ switch (ev.eventType) {
105
+ case FileReviewEventType.BASELINE_CAPTURED: {
106
+ const b = ev.payload.case === "baselineCaptured" ? ev.payload.value : undefined;
107
+ set.turnId = b?.turnId ?? "";
108
+ set.harnessId = b?.harnessId ?? "";
109
+ set.baselineSnapshot = b?.baselineSnapshot;
110
+ set.status = FileChangeSetStatus.CAPTURING;
111
+ break;
112
+ }
113
+ case FileReviewEventType.CANDIDATE_CAPTURED: {
114
+ const c = ev.payload.case === "candidateCaptured" ? ev.payload.value : undefined;
115
+ set.candidateSnapshot = c?.candidateSnapshot;
116
+ set.changes = c?.changes ?? [];
117
+ set.aggregateDigest = c?.aggregateDigest ?? "";
118
+ set.diffCompleteness = c?.diffCompleteness ?? set.diffCompleteness;
119
+ set.status = deriveStatusAfterCandidate(set);
120
+ break;
121
+ }
122
+ case FileReviewEventType.FILE_DECIDED: {
123
+ if (ev.payload.case === "fileDecided") {
124
+ set.decisions.push(ev.payload.value);
125
+ }
126
+ set.status = deriveStatusAfterCandidate(set);
127
+ break;
128
+ }
129
+ case FileReviewEventType.RECONCILED: {
130
+ const r = ev.payload.case === "reconciled" ? ev.payload.value : undefined;
131
+ set.approvedSnapshot = r?.approvedSnapshot;
132
+ set.status = FileChangeSetStatus.RECONCILED;
133
+ break;
134
+ }
135
+ case FileReviewEventType.FAILED: {
136
+ set.status = FileChangeSetStatus.FAILED;
137
+ break;
138
+ }
139
+ // UNSPECIFIED / any future type: ignored, matching the Go projector.
140
+ default:
141
+ break;
142
+ }
143
+ }
144
+ /**
145
+ * Derives a change set's status after a candidate or decision event, mirroring
146
+ * the Go projector's `deriveStatusAfterCandidate`. Terminal statuses are sticky:
147
+ * a `FILE_DECIDED` arriving after `RECONCILED`/`FAILED` never reverts the set to
148
+ * an actionable state.
149
+ */
150
+ function deriveStatusAfterCandidate(set) {
151
+ if (set.status === FileChangeSetStatus.RECONCILED ||
152
+ set.status === FileChangeSetStatus.FAILED) {
153
+ return set.status;
154
+ }
155
+ return isFullyDecided(set)
156
+ ? FileChangeSetStatus.DECIDED
157
+ : FileChangeSetStatus.AWAITING_REVIEW;
158
+ }
159
+ /**
160
+ * Whether every captured change in the set has a verdict, mirroring the Go
161
+ * projector's `isFullyDecided`: a set with no captured changes is never fully
162
+ * decided; any CHANGE_SET-scoped decision covers all files; otherwise every
163
+ * change id must appear among the FILE-scoped decisions.
164
+ */
165
+ function isFullyDecided(set) {
166
+ if (set.changes.length === 0)
167
+ return false;
168
+ const decidedFileIds = new Set();
169
+ for (const decision of set.decisions) {
170
+ if (decision.scope === FileDecisionScope.CHANGE_SET)
171
+ return true;
172
+ if (decision.scope === FileDecisionScope.FILE) {
173
+ decidedFileIds.add(decision.fileChangeId);
174
+ }
175
+ }
176
+ for (const change of set.changes) {
177
+ if (!decidedFileIds.has(change.id))
178
+ return false;
179
+ }
180
+ return true;
181
+ }
182
+ //# sourceMappingURL=file-review-fold.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-review-fold.js","sourceRoot":"","sources":["../../src/execution/file-review-fold.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ACrE;YACE,MAAM;IACV,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAS,0BAA0B,CAAC,GAAkB;IACpD,IACE,GAAG,CAAC,MAAM,KAAK,mBAAmB,CAAC,UAAU;QAC7C,GAAG,CAAC,MAAM,KAAK,mBAAmB,CAAC,MAAM,EACzC,CAAC;QACD,OAAO,GAAG,CAAC,MAAM,CAAC;IACpB,CAAC;IACD,OAAO,cAAc,CAAC,GAAG,CAAC;QACxB,CAAC,CAAC,mBAAmB,CAAC,OAAO;QAC7B,CAAC,CAAC,mBAAmB,CAAC,eAAe,CAAC;AAC1C,CAAC;AAED;;;;;GAKG;AACH,SAAS,cAAc,CAAC,GAAkB;IACxC,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAE3C,MAAM,cAAc,GAAG,IAAI,GAAG,EAAU,CAAC;IACzC,KAAK,MAAM,QAAQ,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;QACrC,IAAI,QAAQ,CAAC,KAAK,KAAK,iBAAiB,CAAC,UAAU;YAAE,OAAO,IAAI,CAAC;QACjE,IAAI,QAAQ,CAAC,KAAK,KAAK,iBAAiB,CAAC,IAAI,EAAE,CAAC;YAC9C,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IAED,KAAK,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;QACjC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YAAE,OAAO,KAAK,CAAC;IACnD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { CapturedFileChange } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/filereview_pb";
2
+ import type { FileChange } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/message_pb";
3
+ /**
4
+ * Adapts a {@link CapturedFileChange} to the {@link FileChange} the diff
5
+ * renderers consume. The two reuse the same `FileContent` for before/after, so
6
+ * the bodies map directly; a capture is always WHOLE_FILE (the candidate carries
7
+ * the byte-exact sides), so the resulting `FileChange` renders as a true
8
+ * before/after diff.
9
+ *
10
+ * @param captured - A captured file change from a `FileChangeSet`.
11
+ * @returns The equivalent display-side {@link FileChange}.
12
+ */
13
+ export declare function toDisplayFileChange(captured: CapturedFileChange): FileChange;
14
+ //# sourceMappingURL=to-display-file-change.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-display-file-change.d.ts","sourceRoot":"","sources":["../../src/execution/to-display-file-change.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oEAAoE,CAAC;AAC7G,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iEAAiE,CAAC;AAQlG;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,UAAU,CAU5E"}
@@ -0,0 +1,57 @@
1
+ // Projects a CapturedFileChange (the file-review ledger/domain type) onto the
2
+ // FileChange display view-model that every diff renderer speaks.
3
+ //
4
+ // The two representations coexist by design (see the CapturedFileChange proto
5
+ // comment): CapturedFileChange is the apply-then-review domain type (always
6
+ // whole-file, byte-exact before/after, carries digests / capture_class /
7
+ // blocked_reason for enforcement), while FileChange is the *display superset* —
8
+ // it additionally models captureLevel and inline HUNK_ONLY diffs, which the
9
+ // still-live deny-gate approval produces directly. Because FileChange is the
10
+ // superset, this projection is lossless; the reverse would not be (a whole-file
11
+ // CapturedFileChange has no inline hunk to lose, but a HUNK_ONLY FileChange has
12
+ // no whole-file bytes). That asymmetry is exactly why display renders through
13
+ // FileChange and this adapter only ever runs one way.
14
+ //
15
+ // This is a pure derive-on-read projection from the single source (the ledger),
16
+ // not a stored second copy: it is called at render time by both FileReviewCard
17
+ // and useSessionFileChanges, never persisted.
18
+ //
19
+ // Framework-agnostic (no React) so it is shared across @stigmer/react,
20
+ // @stigmer/ink, and mirror-able by the Go CLI, alongside tool-view.ts.
21
+ import { create } from "@bufbuild/protobuf";
22
+ import { FileChangeSchema } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/message_pb";
23
+ import { FileChangeCaptureLevel, FileChangeKind, FileChangeType, } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
24
+ /**
25
+ * Adapts a {@link CapturedFileChange} to the {@link FileChange} the diff
26
+ * renderers consume. The two reuse the same `FileContent` for before/after, so
27
+ * the bodies map directly; a capture is always WHOLE_FILE (the candidate carries
28
+ * the byte-exact sides), so the resulting `FileChange` renders as a true
29
+ * before/after diff.
30
+ *
31
+ * @param captured - A captured file change from a `FileChangeSet`.
32
+ * @returns The equivalent display-side {@link FileChange}.
33
+ */
34
+ export function toDisplayFileChange(captured) {
35
+ return create(FileChangeSchema, {
36
+ path: captured.pathAfter || captured.pathBefore,
37
+ changeType: toFileChangeType(captured.kind),
38
+ captureLevel: FileChangeCaptureLevel.WHOLE_FILE,
39
+ before: captured.before,
40
+ after: captured.after,
41
+ renameFrom: captured.kind === FileChangeKind.RENAME ? captured.pathBefore : "",
42
+ });
43
+ }
44
+ /** Maps the ledger's {@link FileChangeKind} to the display {@link FileChangeType}. */
45
+ function toFileChangeType(kind) {
46
+ switch (kind) {
47
+ case FileChangeKind.ADD:
48
+ return FileChangeType.CREATE;
49
+ case FileChangeKind.DELETE:
50
+ return FileChangeType.DELETE;
51
+ case FileChangeKind.RENAME:
52
+ return FileChangeType.RENAME;
53
+ default:
54
+ return FileChangeType.MODIFY;
55
+ }
56
+ }
57
+ //# sourceMappingURL=to-display-file-change.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-display-file-change.js","sourceRoot":"","sources":["../../src/execution/to-display-file-change.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,iEAAiE;AACjE,EAAE;AACF,8EAA8E;AAC9E,4EAA4E;AAC5E,yEAAyE;AACzE,gFAAgF;AA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} from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
2
+ import { FileChangeCaptureLevel } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
2
3
  import type { ToolCall } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/message_pb";
3
- export { ToolKind };
4
+ export { ToolKind, FileChangeCaptureLevel };
4
5
  /** A single match in a search/grep result. */
5
6
  export interface ToolSearchMatch {
6
7
  /** File path the match was found in, when the result format provides it. */
@@ -33,6 +34,7 @@ export type ToolResultView = {
33
34
  readonly linesAdded?: number;
34
35
  readonly linesRemoved?: number;
35
36
  readonly unifiedDiff?: string;
37
+ readonly captureLevel?: FileChangeCaptureLevel;
36
38
  } | {
37
39
  readonly type: "file";
38
40
  readonly path: string;
@@ -41,6 +43,7 @@ export type ToolResultView = {
41
43
  readonly truncated: boolean;
42
44
  } | {
43
45
  readonly type: "terminal";
46
+ readonly command?: string;
44
47
  readonly stdout: string;
45
48
  readonly stderr: string;
46
49
  readonly exitCode?: number;
@@ -48,6 +51,8 @@ export type ToolResultView = {
48
51
  readonly type: "search";
49
52
  readonly matches: readonly ToolSearchMatch[];
50
53
  readonly count: number;
54
+ readonly kind?: "files" | "content";
55
+ readonly truncated?: boolean;
51
56
  } | {
52
57
  readonly type: "list";
53
58
  readonly entries: readonly string[];
@@ -67,7 +72,8 @@ export type ToolResultView = {
67
72
  readonly message: string;
68
73
  } | {
69
74
  readonly type: "outputRef";
70
- readonly downloadUrl: string;
75
+ readonly storageKey: string;
76
+ readonly contentHash: string;
71
77
  readonly isImage: boolean;
72
78
  readonly mimeType: string;
73
79
  readonly sizeBytes: number;
@@ -1 +1 @@
1
- {"version":3,"file":"tool-view.d.ts","sourceRoot":"","sources":["../../src/execution/tool-view.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,QAAQ,EAAE,MAAM,8DAA8D,CAAC;AAExF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iEAAiE,CAAC;AAEhG,OAA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