@kabmo-labs/kabmo 0.43.0 → 0.43.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 (163) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +609 -600
  3. package/dist/client/static/js/{CsvGrid-3fr85032.js → CsvGrid-g67pk2zy.js} +1 -1
  4. package/dist/client/static/js/{DocxView-pqbp2fpd.js → DocxView-pyh6p2kb.js} +1 -1
  5. package/dist/client/static/js/{DrawioView-m0vecq1m.js → DrawioView-g48r6y2m.js} +1 -1
  6. package/dist/client/static/js/{ImageView-rbejbjwg.js → ImageView-rnzf5tve.js} +1 -1
  7. package/dist/client/static/js/{LayoutWrapper-mxfsqh57.js → LayoutWrapper-rekrgth6.js} +1 -1
  8. package/dist/client/static/js/{Modal-vnwg4xn3.js → Modal-edw446r8.js} +1 -1
  9. package/dist/client/static/js/{PdfView-wmg0vk2p.js → PdfView-6z3cgj37.js} +1 -1
  10. package/dist/client/static/js/{SessionsView-90z2t4qe.js → SessionsView-e84tjbcr.js} +1 -1
  11. package/dist/client/static/js/{SheetView-rg5gkcd7.js → SheetView-64076z1j.js} +1 -1
  12. package/dist/client/static/js/{SvgPreview-wpb7b0ez.js → SvgPreview-dmpgavgd.js} +1 -1
  13. package/dist/client/static/js/{abnfDiagram-O67JEVCF-4pxqt66j.js → abnfDiagram-O67JEVCF-nfz5z1vw.js} +1 -1
  14. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-kwt1va5y.js → architectureDiagram-NJMV4G6O-jra2jyzw.js} +1 -1
  15. package/dist/client/static/js/{blockDiagram-BEXU5L5S-hbj5v7n7.js → blockDiagram-BEXU5L5S-3szktxam.js} +1 -1
  16. package/dist/client/static/js/{c4Diagram-YGBWAQC7-epfzh8dw.js → c4Diagram-YGBWAQC7-xe9vbppt.js} +1 -1
  17. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-kbks4qgz.js → classDiagram-v2-NBCMYWYE-egzhj1xn.js} +1 -1
  18. package/dist/client/static/js/{cose-bilkent-JH36ORCC-dvdmckrf.js → cose-bilkent-JH36ORCC-dfrk1wnr.js} +1 -1
  19. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-r084stj5.js → cynefinDiagram-VND7K2PF-xefpcmpg.js} +1 -1
  20. package/dist/client/static/js/{dagre-6A5THRUB-64qc51n1.js → dagre-6A5THRUB-vtzjnrt9.js} +1 -1
  21. package/dist/client/static/js/{diagram-22UHCM2B-70qtb1rm.js → diagram-22UHCM2B-4vvn790v.js} +1 -1
  22. package/dist/client/static/js/{diagram-3UASUU5V-dgkvnsme.js → diagram-3UASUU5V-tmht3bew.js} +1 -1
  23. package/dist/client/static/js/{diagram-ATOU4E4O-rnpsp26v.js → diagram-ATOU4E4O-p5wa5ztx.js} +1 -1
  24. package/dist/client/static/js/{diagram-CDSNMT55-26hthh60.js → diagram-CDSNMT55-8myesjfc.js} +1 -1
  25. package/dist/client/static/js/{diagram-MLGK6HIB-nc1s85r5.js → diagram-MLGK6HIB-9t3x2d5f.js} +1 -1
  26. package/dist/client/static/js/{diagram-MPIPVDR6-e4dckqhv.js → diagram-MPIPVDR6-8ahgnmhy.js} +1 -1
  27. package/dist/client/static/js/{dockerfile-rxtyyhr1.js → dockerfile-x8aa0543.js} +1 -1
  28. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-3w9h8qk7.js → ebnfDiagram-ZINNZB2B-5semw111.js} +1 -1
  29. package/dist/client/static/js/{elk-276RUBZZ-httpkyb1.js → elk-276RUBZZ-jmhs58ww.js} +1 -1
  30. package/dist/client/static/js/{erDiagram-OPXOYQCR-3qhvf7se.js → erDiagram-OPXOYQCR-31wvbpdr.js} +1 -1
  31. package/dist/client/static/js/flowDiagram-KWPJA3E3-36ygrbvm.js +1 -0
  32. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-t53m50e5.js → ganttDiagram-FUAMR5RP-c2dycjrf.js} +1 -1
  33. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-b5wn9eht.js → gitGraphDiagram-X574FWY7-y4k4pdd8.js} +1 -1
  34. package/dist/client/static/js/{index-kc3c2gzb.js → index-0q2qfcjn.js} +1 -1
  35. package/dist/client/static/js/{index-7zc1z9z9.js → index-2b46dzw8.js} +1 -1
  36. package/dist/client/static/js/{index-dg3b0mfk.js → index-2cbnjc32.js} +1 -1
  37. package/dist/client/static/js/{index-q1gwgmxt.js → index-3588r3wg.js} +1 -1
  38. package/dist/client/static/js/{index-8y51kgan.js → index-48gh56ka.js} +1 -1
  39. package/dist/client/static/js/{index-2q23dwrs.js → index-48pb18zj.js} +1 -1
  40. package/dist/client/static/js/{index-ksph3kpr.js → index-4rv388z7.js} +1 -1
  41. package/dist/client/static/js/{index-qzw4jnnv.js → index-52xmdeh2.js} +1 -1
  42. package/dist/client/static/js/{index-kccp6tgd.js → index-6fpd55cq.js} +1 -1
  43. package/dist/client/static/js/{index-d8r84zjd.js → index-8kqepehd.js} +2 -2
  44. package/dist/client/static/js/{index-fgyenbv8.js → index-aar68x31.js} +1 -1
  45. package/dist/client/static/js/{index-r11bbnek.js → index-cgzw43bc.js} +2 -2
  46. package/dist/client/static/js/{index-g3a9j9hf.js → index-cje5gg45.js} +1 -1
  47. package/dist/client/static/js/{index-rv4qs3wm.js → index-cjhvtzdd.js} +1 -1
  48. package/dist/client/static/js/{index-wmv3crye.js → index-dkwhs38j.js} +1 -1
  49. package/dist/client/static/js/{index-vmgzhp41.js → index-efra065v.js} +1 -1
  50. package/dist/client/static/js/{index-zqthmaxq.js → index-f77c3ag0.js} +147 -146
  51. package/dist/client/static/js/{index-7z9tz4ze.js → index-f7djda1g.js} +1 -1
  52. package/dist/client/static/js/{index-egd0vfey.js → index-fbcg8y95.js} +1 -1
  53. package/dist/client/static/js/{index-1dwdgp27.js → index-g3shdymf.js} +1 -1
  54. package/dist/client/static/js/{index-axszsg7a.js → index-h5n1btqy.js} +1 -1
  55. package/dist/client/static/js/{index-tzbzehqd.js → index-kc5znr75.js} +2 -2
  56. package/dist/client/static/js/{index-tnv3dryk.js → index-m1n4v0z7.js} +1 -1
  57. package/dist/client/static/js/{index-g4rsmakg.js → index-m94f4ngb.js} +1 -1
  58. package/dist/client/static/js/{index-4banz7gr.js → index-nt7nhchn.js} +1 -1
  59. package/dist/client/static/js/{index-f4fqvct6.js → index-pt8440xh.js} +1 -1
  60. package/dist/client/static/js/{index-jvs2fvqz.js → index-rn8w29pv.js} +1 -1
  61. package/dist/client/static/js/{index-kmzd0adv.js → index-s00j9042.js} +1 -1
  62. package/dist/client/static/js/{index-dkqgmacr.js → index-s7rfbydk.js} +1 -1
  63. package/dist/client/static/js/{index-j60gtvw8.js → index-sg6sz3g8.js} +1 -1
  64. package/dist/client/static/js/{index-k9ws464d.js → index-vyw4tbn8.js} +1 -1
  65. package/dist/client/static/js/{index-enb6chty.js → index-w5rw8f7w.js} +1 -1
  66. package/dist/client/static/js/{index-gwqb7m8g.js → index-x6v37h3j.js} +1 -1
  67. package/dist/client/static/js/{infoDiagram-VRGFBTTK-qv7438m3.js → infoDiagram-VRGFBTTK-z3pqx7w8.js} +1 -1
  68. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-p1w6zg5y.js → ishikawaDiagram-OU5B5YK6-f5v6z8yr.js} +1 -1
  69. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-ywk6xqxr.js → journeyDiagram-ZHPQQLJL-js1yxatk.js} +1 -1
  70. package/dist/client/static/js/{kanban-definition-PNTS6WVX-gtrmhggc.js → kanban-definition-PNTS6WVX-m0a6069c.js} +1 -1
  71. package/dist/client/static/js/{mermaid.core-5s24b4hh.js → mermaid.core-6xvbnm63.js} +2 -2
  72. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-3wx7abqn.js → mindmap-definition-NLK3R4M7-a9f9yzc0.js} +1 -1
  73. package/dist/client/static/js/one-dark-pro-hteqzfb0.js +1 -0
  74. package/dist/client/static/js/one-light-dapnh0rs.js +1 -0
  75. package/dist/client/static/js/{pegDiagram-GJSIUBJH-yvyqnjya.js → pegDiagram-GJSIUBJH-4v4pf1h1.js} +1 -1
  76. package/dist/client/static/js/{pieDiagram-5QR66LMP-26x6pj38.js → pieDiagram-5QR66LMP-a54yrmfm.js} +1 -1
  77. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-qhe8h0j9.js → quadrantDiagram-O4NWA36T-1twhvnp2.js} +1 -1
  78. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-dwy3k2jx.js → railroadDiagram-XR7U4H2S-83tqfdcy.js} +1 -1
  79. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-hcmgfesg.js → requirementDiagram-PLB6GJNP-73e3pzw6.js} +1 -1
  80. package/dist/client/static/js/{rust-bmb4ee5w.js → rust-jds4e4r7.js} +1 -1
  81. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-s6d3k4zs.js → sankeyDiagram-IPEJSGJF-1bzwj6sb.js} +1 -1
  82. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-0fcmzgdy.js → sequenceDiagram-PO4LG4MO-yh3h988k.js} +1 -1
  83. package/dist/client/static/js/{sizeCapture-INFHLROL-t8fcm7rq.js → sizeCapture-INFHLROL-1n121yp6.js} +1 -1
  84. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-jr80hfeg.js → stateDiagram-v2-GCMORJYK-0tdrzn06.js} +1 -1
  85. package/dist/client/static/js/{swimlanes-2SLR337P-x1ay6w39.js → swimlanes-2SLR337P-77n1ttdw.js} +1 -1
  86. package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-xj123xrp.js → swimlanesDiagram-TC7HE7FX-akjqm31r.js} +1 -1
  87. package/dist/client/static/js/{timeline-definition-EJHVYXUP-qz0g6msb.js → timeline-definition-EJHVYXUP-b6r0k3e8.js} +1 -1
  88. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-sxzrv8ht.js → usecaseDiagram-POWQR4AR-efq58m3m.js} +1 -1
  89. package/dist/client/static/js/{vennDiagram-UO4OBE2U-qsqgnjcv.js → vennDiagram-UO4OBE2U-ad4gvd5r.js} +1 -1
  90. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-rvwxn458.js → wardleyDiagram-VNRHLVJA-v89tys2p.js} +1 -1
  91. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-nb4w7rcg.js → xychartDiagram-PMCCYNJV-xtgzmknw.js} +1 -1
  92. package/package.json +1 -1
  93. package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/index.tsx +21 -9
  94. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/TaskResult.tsx +18 -4
  95. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/task-rows.ts +47 -0
  96. package/src/client/hooks/chat/omp/index.ts +2 -6
  97. package/src/server/lib/changes/capture-client-write.server.ts +45 -0
  98. package/src/server/lib/changes/capture.server.ts +20 -5
  99. package/src/server/lib/db/schema.ts +3 -0
  100. package/src/server/lib/harness/acp/auth.test.ts +69 -0
  101. package/src/server/lib/harness/acp/auth.ts +71 -0
  102. package/src/server/lib/harness/acp/background-replay.test.ts +139 -0
  103. package/src/server/lib/harness/acp/background-replay.ts +87 -0
  104. package/src/server/lib/harness/acp/background-work.ts +50 -33
  105. package/src/server/lib/harness/acp/calls.test.ts +68 -0
  106. package/src/server/lib/harness/acp/calls.ts +13 -0
  107. package/src/server/lib/harness/acp/client-capabilities.ts +5 -2
  108. package/src/server/lib/harness/acp/client-fs.test.ts +13 -0
  109. package/src/server/lib/harness/acp/client-fs.ts +16 -2
  110. package/src/server/lib/harness/acp/client.ts +22 -23
  111. package/src/server/lib/harness/acp/commands.test.ts +19 -0
  112. package/src/server/lib/harness/acp/commands.ts +26 -8
  113. package/src/server/lib/harness/acp/frames.ts +16 -1
  114. package/src/server/lib/harness/acp/grants.server.ts +75 -0
  115. package/src/server/lib/harness/acp/grants.test.ts +65 -0
  116. package/src/server/lib/harness/acp/grants.ts +79 -0
  117. package/src/server/lib/harness/acp/permissions.test.ts +9 -0
  118. package/src/server/lib/harness/acp/permissions.ts +56 -36
  119. package/src/server/lib/harness/acp/prompt-files.test.ts +69 -0
  120. package/src/server/lib/harness/acp/prompt-files.ts +58 -0
  121. package/src/server/lib/harness/acp/prompt.ts +50 -11
  122. package/src/server/lib/harness/acp/protocol.ts +20 -1
  123. package/src/server/lib/harness/acp/session-approvals.ts +45 -0
  124. package/src/server/lib/harness/acp/session-config-view.ts +81 -0
  125. package/src/server/lib/harness/acp/session-config.ts +48 -9
  126. package/src/server/lib/harness/acp/session-handshake.test.ts +71 -2
  127. package/src/server/lib/harness/acp/session-handshake.ts +128 -53
  128. package/src/server/lib/harness/acp/session-intake.test.ts +93 -0
  129. package/src/server/lib/harness/acp/session-intake.ts +75 -0
  130. package/src/server/lib/harness/acp/session-lifecycle.ts +50 -0
  131. package/src/server/lib/harness/acp/session-lost.test.ts +44 -0
  132. package/src/server/lib/harness/acp/session-lost.ts +34 -0
  133. package/src/server/lib/harness/acp/session-notify.ts +47 -0
  134. package/src/server/lib/harness/acp/session-observers.test.ts +4 -4
  135. package/src/server/lib/harness/acp/session-permissions.test.ts +64 -0
  136. package/src/server/lib/harness/acp/session-permissions.ts +9 -4
  137. package/src/server/lib/harness/acp/session-requests.ts +6 -0
  138. package/src/server/lib/harness/acp/session-roots.server.ts +47 -0
  139. package/src/server/lib/harness/acp/session-roots.test.ts +31 -0
  140. package/src/server/lib/harness/acp/session-start.ts +7 -0
  141. package/src/server/lib/harness/acp/session-turns.ts +11 -0
  142. package/src/server/lib/harness/acp/session-wiring.ts +100 -0
  143. package/src/server/lib/harness/acp/session.test-util.ts +34 -2
  144. package/src/server/lib/harness/acp/session.test.ts +10 -10
  145. package/src/server/lib/harness/acp/session.ts +146 -144
  146. package/src/server/lib/harness/acp/tool-calls.ts +27 -15
  147. package/src/server/lib/harness/acp/tool-identity.test.ts +136 -0
  148. package/src/server/lib/harness/acp/tool-identity.ts +121 -0
  149. package/src/server/lib/harness/acp/turn-cancel.test.ts +79 -0
  150. package/src/server/lib/harness/acp/turn-cancel.ts +61 -0
  151. package/src/server/lib/harness/acp/turn-dispatch.test.ts +103 -0
  152. package/src/server/lib/harness/acp/turn-dispatch.ts +61 -0
  153. package/src/server/lib/harness/acp/turn-queue.ts +43 -0
  154. package/src/server/lib/harness/acp/turn-verdict.ts +102 -0
  155. package/src/server/lib/harness/acp/turn.ts +86 -88
  156. package/src/server/lib/harness/acp/v2.test.ts +9 -0
  157. package/src/server/lib/harness/acp/v2.ts +13 -0
  158. package/src/server/lib/harness/acp/verbs.ts +35 -4
  159. package/src/server/lib/omp/session/delete.server.ts +3 -0
  160. package/src/shared/types/omp/agent.ts +14 -5
  161. package/dist/client/static/js/flowDiagram-KWPJA3E3-1jat076e.js +0 -1
  162. package/dist/client/static/js/one-dark-pro-3vya9z02.js +0 -1
  163. package/dist/client/static/js/one-light-1yrwn9my.js +0 -1
@@ -0,0 +1,75 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * What reaches an ACP agent as a PROMPT: a turn, a steer, or a held input.
8
+ *
9
+ * Split out of `session.ts` for the per-file ceiling, and because the rules here
10
+ * are one subject: a prompt is content blocks built from the composer's text,
11
+ * images and `@path` mentions, a turn is refused when the agent cannot accept
12
+ * the images, and an agent with no mid-turn channel gets the message queued
13
+ * instead of an error.
14
+ */
15
+
16
+ import { promptBlocks } from '@/server/lib/harness/acp/prompt';
17
+ import { promptFileLinks } from '@/server/lib/harness/acp/prompt-files';
18
+
19
+ /** The session slice a prompt needs. `AcpSession` satisfies it as-is. */
20
+ export interface AcpPromptHost {
21
+ readonly cwd: string;
22
+ readonly harness: string;
23
+ readonly acceptsImages: boolean;
24
+ promptCount: number;
25
+ background: { stop(): void };
26
+ usage: { beginTurn(): void };
27
+ /** Open the turn; `beginAcpTurn` owns the counts and the run marker. */
28
+ beginTurn(message: string, images: unknown): unknown;
29
+ emit(event: Record<string, unknown> & { type: string }): void;
30
+ /** The agent's own mid-turn verb, when it advertised `_meta.steering`. */
31
+ steer(blocks: unknown[], queue: 'steering' | 'followUp'): Promise<unknown>;
32
+ /** Hold the input for the next turn. */
33
+ queueTurnInput(message: string, images: unknown): void;
34
+ }
35
+
36
+ /** The blocks one prompt sends, so a steer carries the same file links. */
37
+ export function promptContent(host: { cwd: string }, message: string, images: unknown): Promise<unknown[]> {
38
+ return promptFileLinks(host.cwd, message).then((files) => promptBlocks(message, images, files));
39
+ }
40
+
41
+ /** Run one turn. Refuses images the agent never advertised. */
42
+ export function startAcpPrompt(host: AcpPromptHost, message: string, images: unknown): unknown {
43
+ // ACP's prompt capabilities are a MUST: an agent that did not advertise
44
+ // `image` has to be told, not sent blocks its dispatcher rejects.
45
+ if (!host.acceptsImages && Array.isArray(images) && images.length > 0) {
46
+ throw new Error(`This harness does not accept image attachments (${host.harness})`);
47
+ }
48
+ // A new prompt is the next request, so the agent flushes any held update
49
+ // itself; a probe would duplicate it.
50
+ host.background.stop();
51
+ host.promptCount += 1;
52
+ host.usage.beginTurn();
53
+ const ack = host.beginTurn(message, images);
54
+ // Only a delivered turn is recorded: a refusal must not leave a user row.
55
+ host.emit({ type: 'user_turn', message, images });
56
+ return ack;
57
+ }
58
+
59
+ /** One mid-turn message: steer when the agent can, queue when it cannot. */
60
+ export async function sendAcpMidTurn(
61
+ host: AcpPromptHost,
62
+ queue: 'steering' | 'followUp',
63
+ message: string,
64
+ images: unknown,
65
+ canSteer: boolean,
66
+ ): Promise<unknown> {
67
+ if (!canSteer) {
68
+ host.queueTurnInput(message, images);
69
+ host.emit({ type: 'user_turn', message, images });
70
+ return { queued: true };
71
+ }
72
+ const result = await host.steer(await promptContent(host, message, images), queue);
73
+ host.emit({ type: 'user_turn', message, images });
74
+ return result;
75
+ }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Ending an ACP session's life.
8
+ *
9
+ * Split out of `session.ts` for the file ceiling, and because one rule decides
10
+ * every branch here: a process Kabmo is shutting down must NOT be reported as a
11
+ * failure, while an agent that died mid-turn must say why. The exit report and
12
+ * the child-outcome row both read that distinction, so they belong together.
13
+ */
14
+
15
+ import type { AcpExitInfo } from '@/server/lib/harness/acp/session-exit';
16
+
17
+ /** What a teardown has to stop, clear and report. */
18
+ export interface AcpLifecycleHost {
19
+ destroyed: boolean;
20
+ /** True only when Kabmo itself is closing the session. */
21
+ closing: boolean;
22
+ readonly idle: { stop(): void };
23
+ readonly background: { stop(): void };
24
+ readonly permissions: { clear(): void; size(): number };
25
+ runDestroyHook(): void;
26
+ disposeProcess(): Promise<void>;
27
+ reportExit(info: AcpExitInfo): Promise<void>;
28
+ }
29
+
30
+ /** The agent process is gone. A teardown Kabmo started reports nothing. */
31
+ export function acpExited(host: AcpLifecycleHost, info: AcpExitInfo): Promise<void> {
32
+ const closing = host.closing;
33
+ host.destroyed = true;
34
+ host.background.stop();
35
+ host.idle.stop();
36
+ host.runDestroyHook();
37
+ return closing ? Promise.resolve() : host.reportExit(info);
38
+ }
39
+
40
+ /** Stop the agent and wait for it. */
41
+ export async function destroyAcp(host: AcpLifecycleHost): Promise<void> {
42
+ if (host.destroyed) return;
43
+ host.destroyed = true;
44
+ host.closing = true;
45
+ host.background.stop();
46
+ host.idle.stop();
47
+ host.permissions.clear();
48
+ host.runDestroyHook();
49
+ await host.disposeProcess().catch(() => {});
50
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The one failure that is recoverable but is not a retry.
8
+ *
9
+ * An agent that says "session not found" (or answers `-32002`) will say it for
10
+ * every later prompt in this process, so a turn that reports it must also drop
11
+ * the session: the route then respawns and resumes the agent's own history. The
12
+ * alternative — a chat that answers every send with the same refusal — is what
13
+ * this pins.
14
+ */
15
+
16
+ import { describe, expect, test } from 'bun:test';
17
+ import { isLostSession, LOST_SESSION_NOTICE } from '@/server/lib/harness/acp/session-lost';
18
+
19
+ describe('isLostSession', () => {
20
+ test('recognises the spellings adapters use', () => {
21
+ for (const message of [
22
+ 'session not found',
23
+ 'Session 01a1b4cc-… not found',
24
+ 'session lock unavailable',
25
+ 'no such session: abc',
26
+ ]) {
27
+ expect(isLostSession(message)).toBe(true);
28
+ }
29
+ });
30
+
31
+ test('recognises the spec code even when the wording differs', () => {
32
+ expect(isLostSession('Resource not found', -32002)).toBe(true);
33
+ });
34
+
35
+ test('a normal failure is not a lost session', () => {
36
+ expect(isLostSession('The model rejected the request')).toBe(false);
37
+ expect(isLostSession(null)).toBe(false);
38
+ expect(isLostSession('rate limited', -32003)).toBe(false);
39
+ });
40
+
41
+ test('the notice names the recovery', () => {
42
+ expect(LOST_SESSION_NOTICE).toContain('restores it');
43
+ });
44
+ });
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * "The agent no longer has this session."
8
+ *
9
+ * ACP defines no code for a lost session: an adapter answers `-32002`, or a
10
+ * message — `session not found`, `session lock unavailable`, `Session abc not
11
+ * found`. Whatever the spelling, the session object Kabmo holds is dead: every
12
+ * later prompt answers the same refusal, and a chat that keeps the same process
13
+ * can never recover.
14
+ *
15
+ * The recovery is the resume path that already exists — destroy this session so
16
+ * the next command respawns the agent and `session/resume|load`s the agent's own
17
+ * id. Recognising the failure is the whole job of this module.
18
+ */
19
+
20
+ const LOST_SESSION_PATTERN = /\bsession\b(?:\s+\S+)?\s+not\s+found|\bsession\s+lock\s+unavailable\b|\bno\s+such\s+session\b/i;
21
+
22
+ /** The spec's "resource not found", which adapters use for a dropped session. */
23
+ const NOT_FOUND_CODE = -32002;
24
+
25
+ /** Whether a failed turn means the session is gone. */
26
+ export function isLostSession(failure: string | null | undefined, code?: unknown): boolean {
27
+ if (code === NOT_FOUND_CODE) return true;
28
+ return typeof failure === 'string' && LOST_SESSION_PATTERN.test(failure);
29
+ }
30
+
31
+ /** The sentence a reattaching user reads once the session was dropped for a lost
32
+ * agent session; the next send restores it. */
33
+ export const LOST_SESSION_NOTICE =
34
+ 'The agent no longer has this session in its context. The next message restores it from the agent\'s own history.';
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The order one agent notification is routed in.
8
+ *
9
+ * The order IS the rule: the idle clock and the silence ceiling must see every
10
+ * frame (that is the only evidence a turn is alive), `$/cancel_request` must be
11
+ * answered before the frame is folded, a `session/load` replay belongs to the
12
+ * background probe, and the raw panel reads the ORIGINAL payload — so the frame
13
+ * log is fed before the mapper folds it and before the turn gate can drop one.
14
+ */
15
+
16
+ import { handleAcpCancelRequest } from '@/server/lib/harness/acp/session-requests';
17
+ import { handleSessionNotification, type AcpNotificationHost } from '@/server/lib/harness/acp/session-notifications';
18
+ import type { RawNotificationSink } from '@/server/lib/harness/acp/raw-listeners';
19
+
20
+ /** What one routed notification reads. */
21
+ export interface AcpNotifyHost extends AcpNotificationHost {
22
+ readonly rawSink: RawNotificationSink;
23
+ readonly background: { consume(method: string, params: Record<string, unknown>): boolean };
24
+ readonly turns: { noteActivity(): void };
25
+ readonly idle: { reset(): void };
26
+ /** The approval queue, for a withdrawn `$/cancel_request`. */
27
+ respond(id: string | number, result: unknown): void;
28
+ readonly permissions: import('@/server/lib/harness/acp/permissions').PendingPermissions;
29
+ }
30
+
31
+ export function handleAcpNotification(
32
+ host: AcpNotifyHost,
33
+ method: string,
34
+ params: Record<string, unknown>,
35
+ ): void {
36
+ // A long turn emits no commands but plenty of `session/update` frames.
37
+ host.idle.reset();
38
+ // The same frames are the only evidence a turn is still alive: ACP has no
39
+ // probe, so the silence ceiling is what bounds a wedged agent.
40
+ host.turns.noteActivity();
41
+ // The agent withdrawing a request it made; the approval it parks is answered.
42
+ if (handleAcpCancelRequest(host, method, params)) return;
43
+ // A `session/load` probe's replay repeats the whole chat; it is the probe's.
44
+ if (host.background.consume(method, params)) return;
45
+ if (method === 'session/update') host.rawSink.emit(method, params);
46
+ handleSessionNotification(host, method, params);
47
+ }
@@ -16,7 +16,7 @@
16
16
 
17
17
  import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
18
18
  import { isolateDb, releaseDb } from '@/test-support/isolated-db';
19
- import { mountSession, notify } from '@/server/lib/harness/acp/session.test-util';
19
+ import { flushTicks, mountSession, notify } from '@/server/lib/harness/acp/session.test-util';
20
20
  import { loadAcpSessions, saveHarnessSession } from '@/server/lib/harness/session-store.server';
21
21
  import { onRealtimeSignal } from '@/server/lib/realtime/signals.server';
22
22
 
@@ -43,7 +43,7 @@ describe('ACP silent turn', () => {
43
43
  await turn.started;
44
44
  if (say) notify(session, { sessionUpdate: 'agent_message_chunk', content: { type: 'text', text: say } });
45
45
  turn.finish({ stopReason: 'end_turn' });
46
- for (let i = 0; i < 5; i += 1) await Promise.resolve();
46
+ await flushTicks();
47
47
  return events;
48
48
  };
49
49
 
@@ -88,7 +88,7 @@ describe('ACP stream marker', () => {
88
88
  expect(streamMarks()).toEqual(['stream']);
89
89
 
90
90
  turn.finish({ stopReason: 'end_turn' });
91
- for (let i = 0; i < 4; i += 1) await Promise.resolve();
91
+ await flushTicks();
92
92
  expect(streamMarks()).toEqual(['stream', 'finish']);
93
93
  });
94
94
 
@@ -107,7 +107,7 @@ describe('ACP stream marker', () => {
107
107
  // No answer at all is the ACP silent-turn verdict, and the only reason the
108
108
  // notification has to show.
109
109
  turn.finish({ stopReason: 'end_turn' });
110
- for (let i = 0; i < 4; i += 1) await Promise.resolve();
110
+ await flushTicks();
111
111
  expect(streamMarks()).toEqual(['stream', 'finish']);
112
112
  expect(streamMarkFailures()).toEqual([null, 'The agent ended the turn without sending an answer']);
113
113
  });
@@ -104,6 +104,70 @@ describe('ACP permission gating', () => {
104
104
  });
105
105
  });
106
106
 
107
+ describe('ACP approval options', () => {
108
+ const withOptions = (session: AcpSession, id: number, options: Array<{ optionId: string; kind: string }>, action = 'execute') =>
109
+ (session as unknown as PermissionHost).onClientRequest(id, 'session/request_permission', {
110
+ sessionId: 'acp-1',
111
+ toolCall: { kind: action, title: 'Run the thing', rawInput: { command: 'rm -rf build' } },
112
+ options,
113
+ });
114
+
115
+ test('dismissing a dialog with only an allow option answers cancelled, never allow', async () => {
116
+ const { session, permissionAnswers } = mountSession();
117
+ await withOptions(session, 30, [{ optionId: 'allow', kind: 'allow_once' }]);
118
+ session.resolvePermission('30', false);
119
+ expect(permissionAnswers()).toEqual([
120
+ { id: 30, result: { outcome: { outcome: 'cancelled' } } },
121
+ ]);
122
+ });
123
+
124
+ test('Confirm picks the allow option even when the agent lists reject first', async () => {
125
+ const { session, permissionAnswers } = mountSession();
126
+ await withOptions(session, 31, [
127
+ { optionId: 'deny', kind: 'reject_once' },
128
+ { optionId: 'allow', kind: 'allow_once' },
129
+ ]);
130
+ session.resolvePermission('31', true);
131
+ expect(permissionAnswers()).toEqual([
132
+ { id: 31, result: { outcome: { outcome: 'selected', optionId: 'allow' } } },
133
+ ]);
134
+ });
135
+
136
+ test('an "always allow" choice answers that option and silences the next identical request', async () => {
137
+ const { session, events, permissionAnswers } = mountSession();
138
+ await withOptions(session, 32, [
139
+ { optionId: 'once', kind: 'allow_once' },
140
+ { optionId: 'always', kind: 'allow_always' },
141
+ { optionId: 'deny', kind: 'reject_once' },
142
+ ]);
143
+ session.resolvePermission('32', false, 'always');
144
+ expect(permissionAnswers()).toEqual([
145
+ { id: 32, result: { outcome: { outcome: 'selected', optionId: 'always' } } },
146
+ ]);
147
+ const before = dialogs(events);
148
+ expect(await withOptions(session, 33, [
149
+ { optionId: 'once', kind: 'allow_once' },
150
+ { optionId: 'always', kind: 'allow_always' },
151
+ ])).toEqual({
152
+ answered: true,
153
+ result: { outcome: { outcome: 'selected', optionId: 'always' } },
154
+ });
155
+ expect(dialogs(events)).toBe(before);
156
+ });
157
+
158
+ test('a choice id the dialog does not hold is never substituted', async () => {
159
+ const { session, permissionAnswers } = mountSession();
160
+ await withOptions(session, 34, [
161
+ { optionId: 'allow', kind: 'allow_once' },
162
+ { optionId: 'deny', kind: 'reject_once' },
163
+ ]);
164
+ session.resolvePermission('34', true, 'not-an-option');
165
+ expect(permissionAnswers()).toEqual([
166
+ { id: 34, result: { outcome: { outcome: 'selected', optionId: 'allow' } } },
167
+ ]);
168
+ });
169
+ });
170
+
107
171
  describe('ACP cancellation answers parked approvals', () => {
108
172
  test('Stop answers every parked request with the cancelled outcome', async () => {
109
173
  const { session, permissionAnswers } = mountSession();
@@ -19,11 +19,12 @@ import type { AcpId } from '@/server/lib/harness/acp/protocol';
19
19
  import type { PendingPermissions } from '@/server/lib/harness/acp/permissions';
20
20
  import type { ApprovalMode } from '@/shared/lib/omp/config/access-mode';
21
21
  import { allowOption, autoApproval, type PermissionOption } from '@/server/lib/harness/acp/permissions';
22
+ import { permissionGrantKey } from '@/server/lib/harness/acp/grants';
22
23
  import { noteAwaitingInput } from '@/server/lib/notifications/feed.server';
23
24
 
24
25
  /**
25
- * The option id to select when the tier already allows this call, or null to
26
- * park it as a dialog.
26
+ * The option id to select when the tier (or a standing grant) already allows
27
+ * this call, or null to park it as a dialog.
27
28
  *
28
29
  * Answered HERE, before a dialog exists: parking it would ask a question the
29
30
  * operator's own selection already answered, and `isBusy()` would report a
@@ -32,12 +33,16 @@ import { noteAwaitingInput } from '@/server/lib/notifications/feed.server';
32
33
  export function preApprovedOption(
33
34
  accessMode: ApprovalMode,
34
35
  params: Record<string, unknown>,
36
+ permissions?: PendingPermissions,
35
37
  ): string | null {
36
38
  const toolCall = params.toolCall && typeof params.toolCall === 'object'
37
39
  ? Object.fromEntries(Object.entries(params.toolCall))
38
40
  : undefined;
39
- if (!autoApproval(accessMode, toolCall)) return null;
40
41
  const options = Array.isArray(params.options) ? (params.options as PermissionOption[]) : [];
42
+ // A standing "always allow" is the operator's own answer to this exact call;
43
+ // it wins over the tier, including one that would otherwise ask.
44
+ if (permissions?.grants.has(permissionGrantKey(toolCall))) return allowOption(options, 'always');
45
+ if (!autoApproval(accessMode, toolCall)) return null;
41
46
  return allowOption(options);
42
47
  }
43
48
 
@@ -99,7 +104,7 @@ export function answerPermissionRequest(
99
104
  id: AcpId,
100
105
  params: Record<string, unknown>,
101
106
  ): Promise<PermissionRequestAnswer> {
102
- const optionId = preApprovedOption(host.accessMode, params);
107
+ const optionId = preApprovedOption(host.accessMode, params, host.permissions);
103
108
  if (optionId) {
104
109
  return Promise.resolve({ answered: true, result: { outcome: { outcome: 'selected', optionId } } });
105
110
  }
@@ -54,6 +54,12 @@ export function handleAcpClientRequest(
54
54
  // The file surface the client advertised at `initialize`. Routed before the
55
55
  // refusal so an agent that took the advertisement at its word gets an answer.
56
56
  if (isAcpFsMethod(method)) return handleAcpFsRequest(host, method, params);
57
+ // Cursor asks the CLIENT to run a nested task (`cursor/task`, measured on
58
+ // cursor-agent 2026.08.11). Answering `-32601` made its adapter fall back with
59
+ // an error in the middle of a delegation the tool card had already drawn; an
60
+ // empty result is what the adapter expects from a client that does not run
61
+ // the child itself.
62
+ if (method === 'cursor/task') return Promise.resolve({ answered: true, result: {} });
57
63
  // `-32601`, not "internal error": the agent decides from the code whether this
58
64
  // client simply lacks the method (Spec §Errors).
59
65
  return Promise.resolve({
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The directories one ACP chat may work in.
8
+ *
9
+ * ACP carries `additionalDirectories` on `session/new|load|resume|fork` when the
10
+ * agent advertises `sessionCapabilities.additionalDirectories`. Kabmo never sent
11
+ * it, so an agent driving a WORKTREE chat could only write inside the worktree
12
+ * — and its `fs/*` calls for the repository the worktree belongs to were refused
13
+ * as "outside this session's workspace".
14
+ *
15
+ * The roots are computed from what Kabmo already knows: the session's cwd, plus
16
+ * the primary repository root when the cwd IS a worktree (the worktree registry
17
+ * holds that pair). Nothing else is invented — a root the client will not serve
18
+ * must not be advertised to the agent either.
19
+ */
20
+
21
+ import { getDb } from '@/server/db.server';
22
+ import { worktreeRowFor } from '@/server/lib/db/worktree-registry.server';
23
+
24
+ /** The session's own root plus any registered parent repository root. */
25
+ export async function sessionRoots(cwd: string): Promise<string[]> {
26
+ const roots = [cwd];
27
+ try {
28
+ const db = await getDb();
29
+ const row = await worktreeRowFor(db, cwd);
30
+ if (row?.primary_root && row.primary_root !== cwd) roots.push(row.primary_root);
31
+ } catch {
32
+ // no-excuse-ok: catch — an unreadable worktree registry leaves one root,
33
+ // which is the same behaviour as before this module existed.
34
+ }
35
+ return roots;
36
+ }
37
+
38
+ /** The `additionalDirectories` list to send, or nothing when the capability is
39
+ * absent or there is only one root. */
40
+ export function additionalDirectoriesFor(
41
+ roots: readonly string[],
42
+ cwd: string,
43
+ advertised: boolean,
44
+ ): { additionalDirectories?: string[] } {
45
+ const extra = roots.filter((root) => root !== cwd);
46
+ return advertised && extra.length > 0 ? { additionalDirectories: extra } : {};
47
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * `additionalDirectories` is only sent when the agent advertised it.
8
+ *
9
+ * The gate is the point: the field is a v2 capability, and an agent that does
10
+ * not advertise it must not receive it — at best the key is ignored, at worst the
11
+ * whole setup request is refused and no chat starts at all.
12
+ */
13
+
14
+ import { describe, expect, test } from 'bun:test';
15
+ import { additionalDirectoriesFor } from '@/server/lib/harness/acp/session-roots.server';
16
+
17
+ describe('additionalDirectoriesFor', () => {
18
+ test('sends the extra roots when the agent advertised the capability', () => {
19
+ expect(additionalDirectoriesFor(['/work/repo', '/work/repo-a'], '/work/repo-a', true)).toEqual({
20
+ additionalDirectories: ['/work/repo'],
21
+ });
22
+ });
23
+
24
+ test('sends nothing when the capability is absent', () => {
25
+ expect(additionalDirectoriesFor(['/work/repo', '/work/repo-a'], '/work/repo-a', false)).toEqual({});
26
+ });
27
+
28
+ test('sends nothing when the session has only its own root', () => {
29
+ expect(additionalDirectoriesFor(['/work/repo'], '/work/repo', true)).toEqual({});
30
+ });
31
+ });
@@ -22,12 +22,16 @@ import type {
22
22
  AcpHandshakeTarget,
23
23
  } from '@/server/lib/harness/acp/session-handshake';
24
24
  import { handshakeAcpSession } from '@/server/lib/harness/acp/session-handshake';
25
+ import { loadAcpGrants } from '@/server/lib/harness/acp/grants.server';
25
26
  import type { IdleReaper } from '@/server/lib/omp/rpc/idle-reaper';
26
27
 
27
28
  /** The session slice a start drives: the handshake target, its clock and id. */
28
29
  export interface AcpStartTarget extends AcpHandshakeTarget {
29
30
  sessionId: string;
30
31
  idle: IdleReaper;
32
+ /** The approval queue, so the grants earned in an earlier process are
33
+ * hydrated before the first `session/request_permission` can arrive. */
34
+ permissions?: { grants: { hydrate(keys: readonly string[]): void } };
31
35
  }
32
36
 
33
37
  export async function startAcpSession(
@@ -56,6 +60,9 @@ export async function startAcpSession(
56
60
  );
57
61
  if (wantsReplay) await replay.run(mapper, handshake);
58
62
  else await handshake();
63
+ // "Always allow" is the operator's standing decision for this chat; a new
64
+ // child must not ask again. Read once, before the session can take a prompt.
65
+ target.permissions?.grants.hydrate(await loadAcpGrants(target.sessionId));
59
66
  // A slow handshake is not idleness: the window starts once it is usable.
60
67
  target.idle.reset(true);
61
68
  return { sessionId: target.sessionId };
@@ -46,6 +46,7 @@ import type { AcpTurns, AcpTurnEndInfo } from '@/server/lib/harness/acp/turn';
46
46
  import { driveAcpGoalAfterTurn } from '@/server/lib/harness/acp/acp-goal-driver.server';
47
47
  import type { AcpGoalHost } from '@/server/lib/harness/acp/acp-goal.server';
48
48
  import { assistantTextOf, spawnsBackgroundWork } from '@/server/lib/harness/acp/background-work';
49
+ import { isLostSession } from '@/server/lib/harness/acp/session-lost';
49
50
 
50
51
  /** What a turn reads and moves on the session. */
51
52
  export interface AcpTurnTarget {
@@ -62,6 +63,9 @@ export interface AcpTurnTarget {
62
63
  isAlive(): boolean;
63
64
  isBusy(): boolean;
64
65
  send(command: Record<string, unknown>): Promise<unknown>;
66
+ /** Drop this session when the agent says it no longer has it, so the next
67
+ * command respawns and resumes. */
68
+ dropLostSession?: () => void;
65
69
  }
66
70
 
67
71
  /** What the turn-end bookkeeping moves on the session. */
@@ -152,6 +156,13 @@ export async function settleAcpTurn(
152
156
  if (finalText && status === 'completed') {
153
157
  void saveSessionAnswer(target.sessionId, finalText).catch(() => {});
154
158
  }
159
+ // A lost agent session is not recoverable in THIS process: every later prompt
160
+ // answers the same refusal. Dropping the session lets the route respawn it and
161
+ // resume from the agent's own history — the alternative is a chat that can
162
+ // never send again.
163
+ if (isLostSession(info.failure) && target.dropLostSession) {
164
+ target.dropLostSession();
165
+ }
155
166
  const reported = noteChildOutcome({
156
167
  sessionId: target.sessionId,
157
168
  status,
@@ -0,0 +1,100 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The seams an ACP session binds at construction: the turn machine and the
8
+ * background probe.
9
+ *
10
+ * Both are pure wiring over the process and the mapper, and both are the place a
11
+ * reader gets lost inside `session.ts` — the turn machine's `prompt` seam builds
12
+ * the blocks a prompt sends, and the probe's `load` is a `session/load` on the
13
+ * session's OWN id. Naming them here keeps the session class to the state it
14
+ * owns.
15
+ */
16
+
17
+ import {
18
+ AcpBackgroundProbe,
19
+ BACKGROUND_LOAD_TIMEOUT_MS,
20
+ deliverBackgroundNotice,
21
+ type BackgroundNoticeHost,
22
+ } from '@/server/lib/harness/acp/background-work';
23
+ import type { AcpProcess } from '@/server/lib/harness/acp/client';
24
+ import type { AcpFrameMapper } from '@/server/lib/harness/acp/frames';
25
+ import { promptBlocks } from '@/server/lib/harness/acp/prompt';
26
+ import { promptFileLinks } from '@/server/lib/harness/acp/prompt-files';
27
+ import { AcpTurns, type AcpTurnEndInfo } from '@/server/lib/harness/acp/turn';
28
+ import { stampMessageModel } from '@/server/lib/harness/acp/session-config';
29
+ import type { AgentEvent } from '@/server/lib/omp/rpc/constants';
30
+ import type { IdleReaper } from '@/server/lib/omp/rpc/idle-reaper';
31
+
32
+ /** Everything the two seams read off the session. The counts are the background
33
+ * notice's alone: it emits one synthetic assistant row and has to move them. */
34
+ export interface AcpWiringHost extends BackgroundNoticeHost {
35
+ readonly cwd: string;
36
+ readonly proc: AcpProcess;
37
+ readonly mapper: AcpFrameMapper;
38
+ readonly idle: IdleReaper;
39
+ sessionId: string;
40
+ runModel: { provider: string; modelId: string } | null;
41
+ emit(event: AgentEvent): void;
42
+ onTurnEnded(info: AcpTurnEndInfo): void;
43
+ }
44
+
45
+ /** The wiring a session builds for itself: live getters, so the handshake's id
46
+ * and model reach the turn machine without a second assignment. */
47
+ export function acpWiringFor(session: {
48
+ cwd: string;
49
+ sessionId: string;
50
+ runModel: { provider: string; modelId: string } | null;
51
+ messageCount: number;
52
+ assistantCount: number;
53
+ emit(event: AgentEvent): void;
54
+ onTurnEnded(info: AcpTurnEndInfo): Promise<void>;
55
+ }, parts: { proc: AcpProcess; mapper: AcpFrameMapper; idle: IdleReaper }): AcpWiringHost {
56
+ return {
57
+ cwd: session.cwd,
58
+ proc: parts.proc,
59
+ mapper: parts.mapper,
60
+ idle: parts.idle,
61
+ get sessionId() { return session.sessionId; },
62
+ get runModel() { return session.runModel; },
63
+ get messageCount() { return session.messageCount; },
64
+ get assistantCount() { return session.assistantCount; },
65
+ emit: (event) => session.emit(event),
66
+ onTurnEnded: (info) => void session.onTurnEnded(info),
67
+ };
68
+ }
69
+
70
+ /** The background probe: ACP holds a subagent's completion until the next
71
+ * request, and `session/load` is the only request that surfaces it. */
72
+ export function acpBackgroundProbe(host: AcpWiringHost): AcpBackgroundProbe {
73
+ return new AcpBackgroundProbe({
74
+ load: () => host.proc.loadSession(host.sessionId, host.cwd, BACKGROUND_LOAD_TIMEOUT_MS),
75
+ resetIdle: () => host.idle.reset(),
76
+ emit: (text) => deliverBackgroundNotice(host, text),
77
+ });
78
+ }
79
+
80
+ /** The turn machine: one prompt, its frames, and how it ends. */
81
+ export function acpTurns(host: AcpWiringHost): AcpTurns {
82
+ return new AcpTurns({
83
+ emit: (event) => host.emit(event),
84
+ prompt: (message, images) =>
85
+ // `@path` mentions travel as `resource_link` blocks: no agent but omp
86
+ // expands them, and the file would otherwise reach the model as a path
87
+ // with no bytes behind it.
88
+ promptFileLinks(host.cwd, message).then(
89
+ (files) => host.proc.prompt(host.sessionId, promptBlocks(message, images, files), 0) as Promise<{ stopReason?: string } | undefined>,
90
+ ),
91
+ cancelAgent: () => host.proc.cancel(host.sessionId),
92
+ abandonPrompt: () => host.proc.abandonPrompt(host.sessionId),
93
+ resetMapper: () => host.mapper.reset(),
94
+ closeMessage: () => host.mapper.closeMessage().map((event) => stampMessageModel(event, host.runModel)),
95
+ openCalls: () => host.mapper.openCalls(),
96
+ // Armed from the turn's END, exactly as the omp wrapper arms it from its own
97
+ // terminal settle: without this a queued follow-up never left the table.
98
+ onTurnEnd: (info) => host.onTurnEnded(info),
99
+ });
100
+ }