@celljs/ta 4.9.0 → 4.9.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 (144) hide show
  1. package/dist/gateway.mjs +26 -8
  2. package/dist/pi/CHANGELOG.md +4 -0
  3. package/dist/pi/package.json +1 -1
  4. package/dist/pi/packages/ta-agents/README.en.md +2 -2
  5. package/dist/pi/packages/ta-agents/README.md +2 -2
  6. package/dist/pi/packages/ta-agents/extension/index.mjs +50 -12
  7. package/dist/pi/packages/ta-agents/lib/agent-bindings.d.ts +17 -4
  8. package/dist/pi/packages/ta-agents/lib/agent-bindings.js +39 -9
  9. package/dist/pi/packages/ta-agents/lib/agent-catalog.d.ts +2 -0
  10. package/dist/pi/packages/ta-agents/lib/agent-catalog.js +3 -0
  11. package/dist/pi/packages/ta-agents/lib/extension.d.ts +2 -1
  12. package/dist/pi/packages/ta-agents/lib/extension.js +11 -3
  13. package/dist/pi/packages/ta-agents/lib/json-rpc.js +7 -1
  14. package/dist/pi/packages/ta-agents/package.json +1 -1
  15. package/dist/pi/packages/ta-bots/package.json +1 -1
  16. package/dist/pi/packages/ta-changes/package.json +1 -1
  17. package/dist/pi/packages/ta-channels/lib/i18n.d.ts +2 -1
  18. package/dist/pi/packages/ta-channels/lib/i18n.js +4 -2
  19. package/dist/pi/packages/ta-channels/lib/sidebar.js +63 -11
  20. package/dist/pi/packages/ta-channels/lib/tasks.d.ts +2 -0
  21. package/dist/pi/packages/ta-channels/lib/tasks.js +21 -10
  22. package/dist/pi/packages/ta-channels/package.json +1 -1
  23. package/dist/pi/packages/ta-channels/web/index.js +95 -27
  24. package/dist/pi/packages/ta-computer-use/package.json +1 -1
  25. package/dist/pi/packages/ta-cron/package.json +1 -1
  26. package/dist/pi/packages/ta-extensions/package.json +1 -1
  27. package/dist/pi/packages/ta-launcher/package.json +1 -1
  28. package/dist/pi/packages/ta-workspace/lib/index.js +2 -1
  29. package/dist/pi/packages/ta-workspace/lib/terminal-sessions.d.ts +51 -0
  30. package/dist/pi/packages/ta-workspace/lib/terminal-sessions.js +226 -0
  31. package/dist/pi/packages/ta-workspace/lib/terminal.d.ts +0 -39
  32. package/dist/pi/packages/ta-workspace/lib/terminal.js +28 -240
  33. package/dist/pi/packages/ta-workspace/package.json +1 -1
  34. package/dist/pi/packages/ta-workspace/web/index.js +3 -1
  35. package/dist/public/assets/{abnfDiagram-S7VZAUFO-C1tb6dM5.js → abnfDiagram-S7VZAUFO-EVMX_yOb.js} +1 -1
  36. package/dist/public/assets/{architecture-WOLXFQ4H-DN1Va8BF.js → architecture-WOLXFQ4H-CDgbgZ_o.js} +1 -1
  37. package/dist/public/assets/{architectureDiagram-YGSQEFNW-BmK2SYtQ.js → architectureDiagram-YGSQEFNW-dHreaCWz.js} +1 -1
  38. package/dist/public/assets/{blockDiagram-APKKGZFW-DvLrLzTm.js → blockDiagram-APKKGZFW-D6FhzBDq.js} +1 -1
  39. package/dist/public/assets/{browser-DAv3ly6M.js → browser-y6EDNUmc.js} +1 -1
  40. package/dist/public/assets/{c4Diagram-KJ2TOQU5-CrQlWwrG.js → c4Diagram-KJ2TOQU5-BFpcr8Cs.js} +1 -1
  41. package/dist/public/assets/{chunk-6MUBBAK2-CHKMsuY_.js → chunk-6MUBBAK2-BczXkMV-.js} +1 -1
  42. package/dist/public/assets/{chunk-AXFCVDMN-CWJ7Np6s.js → chunk-AXFCVDMN-CjJsv3jB.js} +1 -1
  43. package/dist/public/assets/{chunk-BG4553SI-3v5XbQGM.js → chunk-BG4553SI-FBaleaLz.js} +1 -1
  44. package/dist/public/assets/{chunk-DQASFODM-2CC-yiCz.js → chunk-DQASFODM-BFdXY5sX.js} +1 -1
  45. package/dist/public/assets/{chunk-HFQBQIA3-D2hzQPAy.js → chunk-HFQBQIA3-C5cwK-Fg.js} +1 -1
  46. package/dist/public/assets/{chunk-KQLB2F66-SifAZs2r.js → chunk-KQLB2F66-BUek3IRk.js} +1 -1
  47. package/dist/public/assets/{chunk-KS47KZWR-BP0C0VCC.js → chunk-KS47KZWR-BxsYBzt6.js} +1 -1
  48. package/dist/public/assets/{chunk-LEVMRMFU-B1f5vw5b.js → chunk-LEVMRMFU-Bdcwz9fS.js} +1 -1
  49. package/dist/public/assets/{chunk-M57EVK23-B2MCJt7Y.js → chunk-M57EVK23-kkpP5oug.js} +1 -1
  50. package/dist/public/assets/{chunk-OY52VR5R-cDpZJMk4.js → chunk-OY52VR5R-CFhQgxmD.js} +1 -1
  51. package/dist/public/assets/{chunk-QB3YPZ4I-BE0we2xc.js → chunk-QB3YPZ4I-BVXqu0eC.js} +1 -1
  52. package/dist/public/assets/{chunk-R3KSYZAL-D9wOfqqH.js → chunk-R3KSYZAL-B7SUqqLI.js} +1 -1
  53. package/dist/public/assets/{chunk-STOXU5M4-BIaVsc0K.js → chunk-STOXU5M4-B3abfbnH.js} +1 -1
  54. package/dist/public/assets/{chunk-TU62E6Q5-BZc0OZEM.js → chunk-TU62E6Q5-C9NqnUav.js} +1 -1
  55. package/dist/public/assets/{chunk-X4PVCEUW-Bngfwwzm.js → chunk-X4PVCEUW-BeLfETDx.js} +1 -1
  56. package/dist/public/assets/{chunk-XXDRQBXY-C5FQ6XHK.js → chunk-XXDRQBXY-DXai1i8p.js} +1 -1
  57. package/dist/public/assets/{classDiagram-v2-L25IHNXF-_om54nmt.js → classDiagram-v2-L25IHNXF-Zj6ne_tC.js} +1 -1
  58. package/dist/public/assets/{cose-bilkent-JH36ORCC-Dwpeee_6.js → cose-bilkent-JH36ORCC-C0-TjqfJ.js} +1 -1
  59. package/dist/public/assets/cynefin-EF2NZ3EQ-CoY4CrZu.js +1 -0
  60. package/dist/public/assets/{cynefinDiagram-L36ESFBY-DP5_y9Dq.js → cynefinDiagram-L36ESFBY-BnqxfzPa.js} +1 -1
  61. package/dist/public/assets/{d3-selection-DFiMlEmn.js → d3-selection-DfFLTR9d.js} +1 -1
  62. package/dist/public/assets/{dagre-SPEB5RXH-DYwsk6gk.js → dagre-SPEB5RXH-kI17e5cH.js} +1 -1
  63. package/dist/public/assets/{diagram-3B7GL73J-Dq_nT3AZ.js → diagram-3B7GL73J-DgPjeLA5.js} +1 -1
  64. package/dist/public/assets/{diagram-DNEMPZML-ChURW6y9.js → diagram-DNEMPZML-CRhPfa0I.js} +1 -1
  65. package/dist/public/assets/{diagram-L3MUGCDN-CgVp4Rto.js → diagram-L3MUGCDN-ExuTg12b.js} +1 -1
  66. package/dist/public/assets/{diagram-LA4NIPWU-vrqLMDby.js → diagram-LA4NIPWU-Dgx5xNiY.js} +1 -1
  67. package/dist/public/assets/{diagram-MHCOC4E2-lvfOr5ij.js → diagram-MHCOC4E2-BuifkUTl.js} +1 -1
  68. package/dist/public/assets/{diagram-XPFHEONP-oQ18TeVp.js → diagram-XPFHEONP-CFEaBo7z.js} +1 -1
  69. package/dist/public/assets/{dist-BOxxmveI.js → dist-C-iJHcSK.js} +1 -1
  70. package/dist/public/assets/{ebnfDiagram-UZSYDL2S-C7_tlZCS.js → ebnfDiagram-UZSYDL2S-D-hp5yNt.js} +1 -1
  71. package/dist/public/assets/{editor.api-CoZ8MEuz.js → editor.api-BopUWpqY.js} +1 -1
  72. package/dist/public/assets/{elk-XV6XMXQE-Dkt5-ikg.js → elk-XV6XMXQE-CBbk_IpU.js} +1 -1
  73. package/dist/public/assets/{erDiagram-EYBAPDEH-27kh3zlx.js → erDiagram-EYBAPDEH-B02R_WWE.js} +1 -1
  74. package/dist/public/assets/{eventmodeling-K75KTNOO-CxVEejjN.js → eventmodeling-K75KTNOO-aCZfYnCI.js} +1 -1
  75. package/dist/public/assets/flowDiagram-MALGAFMO-CATkJShO.js +1 -0
  76. package/dist/public/assets/{freemarker2-D6CwPIXh.js → freemarker2-DMN60LeK.js} +1 -1
  77. package/dist/public/assets/{ganttDiagram-23REXITY-C-amlwpX.js → ganttDiagram-23REXITY-DioU8TlD.js} +1 -1
  78. package/dist/public/assets/gitGraph-VSP46ZUC-g4yHXXxx.js +1 -0
  79. package/dist/public/assets/{gitGraphDiagram-STJD7YCW-DKhzI0Xz.js → gitGraphDiagram-STJD7YCW--q3ctg6y.js} +1 -1
  80. package/dist/public/assets/{handlebars-mxNr68Gm.js → handlebars-B_-qdvpB.js} +1 -1
  81. package/dist/public/assets/{html-Bze6s9R9.js → html-BN8Ah3Js.js} +1 -1
  82. package/dist/public/assets/{index-BhQUc9PU.js → index-B3A--ac8.js} +2 -2
  83. package/dist/public/assets/info-OHQRW6UA-CKADJjz4.js +1 -0
  84. package/dist/public/assets/{infoDiagram-KBXO4MBG-WHuWjEDO.js → infoDiagram-KBXO4MBG-CGXteYo9.js} +1 -1
  85. package/dist/public/assets/{ishikawaDiagram-M35NCXHK-DFHUwD0J.js → ishikawaDiagram-M35NCXHK-DM2LmOAc.js} +1 -1
  86. package/dist/public/assets/{javascript-4NMPu7y1.js → javascript-BlizGb0q.js} +1 -1
  87. package/dist/public/assets/{journeyDiagram-OPLOXDXO-C7gV6zEr.js → journeyDiagram-OPLOXDXO-CNITRtGl.js} +1 -1
  88. package/dist/public/assets/{jsonMode-B1JEHPMp.js → jsonMode-CEUmT5sN.js} +1 -1
  89. package/dist/public/assets/{kanban-definition-BZKZHSQY-DlRu_d2Q.js → kanban-definition-BZKZHSQY-BPUuS9um.js} +1 -1
  90. package/dist/public/assets/{liquid-B7sIf4NX.js → liquid-BbyLjUbE.js} +1 -1
  91. package/dist/public/assets/{mdx-CAN0qez6.js → mdx-DiQz7Q35.js} +1 -1
  92. package/dist/public/assets/{mermaid-parser.core-BGmotBhf.js → mermaid-parser.core-Dum100hC.js} +3 -3
  93. package/dist/public/assets/{mermaid.core-Cl6SS3cM.js → mermaid.core-BWmWf6XO.js} +4 -4
  94. package/dist/public/assets/{mindmap-definition-I2QAS2VK-DiQ8Feqr.js → mindmap-definition-I2QAS2VK-L8HyYUDY.js} +1 -1
  95. package/dist/public/assets/module-CH7IXa5L.js +1781 -0
  96. package/dist/public/assets/module-DNAasuMC.js +1 -0
  97. package/dist/public/assets/{monaco-CwCjTWAO.js → monaco-zOOyBmxy.js} +3 -3
  98. package/dist/public/assets/packet-JDAUHWVQ-CpKMhX4K.js +1 -0
  99. package/dist/public/assets/{pegDiagram-FD4XPPHP-XhCpv6BX.js → pegDiagram-FD4XPPHP-CTZKPo0Z.js} +1 -1
  100. package/dist/public/assets/pie-XZMESJXO-CW-zGDRd.js +1 -0
  101. package/dist/public/assets/{pieDiagram-J4AKIIQI-DUVzuXUd.js → pieDiagram-J4AKIIQI-DAeT3dFi.js} +1 -1
  102. package/dist/public/assets/{python-DsoF66Sp.js → python-C984gt98.js} +1 -1
  103. package/dist/public/assets/{quadrantDiagram-XTYBLID2-Ddobf0z0.js → quadrantDiagram-XTYBLID2--PXxwV1Z.js} +1 -1
  104. package/dist/public/assets/radar-ABXABTNO-Cg8W433p.js +1 -0
  105. package/dist/public/assets/railroad-I3PHUGI6-DriMt2PQ.js +1 -0
  106. package/dist/public/assets/{railroad-abnf-LNEFI6M7-DkrNo-Gf.js → railroad-abnf-LNEFI6M7-BYcFfrCa.js} +1 -1
  107. package/dist/public/assets/{railroad-ebnf-DWYD2UWJ-DaB7gY8P.js → railroad-ebnf-DWYD2UWJ-Cd33qxAm.js} +1 -1
  108. package/dist/public/assets/{railroad-peg-JR7BVNR7-D_QG87QV.js → railroad-peg-JR7BVNR7-C5TpzaU8.js} +1 -1
  109. package/dist/public/assets/{railroadDiagram-MRQ6NCDL-x-nUoBjv.js → railroadDiagram-MRQ6NCDL-DlWwjbhH.js} +1 -1
  110. package/dist/public/assets/{razor-DSrcJyQe.js → razor-BBqMR1Qn.js} +1 -1
  111. package/dist/public/assets/{requirementDiagram-Y7LWUY3S-kNNcbsty.js → requirementDiagram-Y7LWUY3S-CsYBy9HS.js} +1 -1
  112. package/dist/public/assets/{sankeyDiagram-WGJFYUXA-ClC12Odk.js → sankeyDiagram-WGJFYUXA-Baxyb5p9.js} +1 -1
  113. package/dist/public/assets/{sequenceDiagram-5NDRBG5M-DDQITP2g.js → sequenceDiagram-5NDRBG5M-Cq6VeBT_.js} +1 -1
  114. package/dist/public/assets/{stateDiagram-v2-FJ4FJNEA-N1t_36oh.js → stateDiagram-v2-FJ4FJNEA-O60WKaE7.js} +1 -1
  115. package/dist/public/assets/{swimlanes-UMQ2AFYF-DSt9fFYE.js → swimlanes-UMQ2AFYF-C2nf1-Cc.js} +1 -1
  116. package/dist/public/assets/swimlanesDiagram-OMPLPG4O-B46JxqS8.js +8 -0
  117. package/dist/public/assets/{timeline-definition-SEUHKTQE-CfymOw_s.js → timeline-definition-SEUHKTQE-DEfUG6YH.js} +1 -1
  118. package/dist/public/assets/treeView-D4JQ5SDB-1LhEWwC9.js +1 -0
  119. package/dist/public/assets/treemap-SAJKECNS-D3t3N7nS.js +1 -0
  120. package/dist/public/assets/{typescript-J7rF-zX8.js → typescript-Gtq7f0aU.js} +1 -1
  121. package/dist/public/assets/{usecaseDiagram-AFA6YXN4-CK_mRc2_.js → usecaseDiagram-AFA6YXN4-Gw9DyJcx.js} +1 -1
  122. package/dist/public/assets/{vennDiagram-NNMJR3RB-DW8xR6IJ.js → vennDiagram-NNMJR3RB-Clb3MLWF.js} +1 -1
  123. package/dist/public/assets/wardley-7MLQ67FV-D3sAsd8p.js +1 -0
  124. package/dist/public/assets/{wardleyDiagram-S7YFUSEH-Css55Zq5.js → wardleyDiagram-S7YFUSEH-BrTRpwu2.js} +1 -1
  125. package/dist/public/assets/{xml-CJeviG_a.js → xml-Bx3nk7iG.js} +1 -1
  126. package/dist/public/assets/{xychartDiagram-GGNKY7IX-BnhK9cFS.js → xychartDiagram-GGNKY7IX-BfjTcIsb.js} +1 -1
  127. package/dist/public/assets/{yaml-Gw3uo6rF.js → yaml-dFLE_rSl.js} +1 -1
  128. package/dist/public/index.html +1 -1
  129. package/dist/serve/index.mjs +13 -5
  130. package/package.json +24 -24
  131. package/dist/public/assets/cynefin-EF2NZ3EQ-CW_93VVD.js +0 -1
  132. package/dist/public/assets/flowDiagram-MALGAFMO-BRowRdve.js +0 -1
  133. package/dist/public/assets/gitGraph-VSP46ZUC-BGmojXlx.js +0 -1
  134. package/dist/public/assets/info-OHQRW6UA-CRRVgGj2.js +0 -1
  135. package/dist/public/assets/module-1nDbf1AK.js +0 -1761
  136. package/dist/public/assets/module-BkKfSTDV.js +0 -1
  137. package/dist/public/assets/packet-JDAUHWVQ-DUlqTCWQ.js +0 -1
  138. package/dist/public/assets/pie-XZMESJXO-2RgP4ScO.js +0 -1
  139. package/dist/public/assets/radar-ABXABTNO-Dap8k-yH.js +0 -1
  140. package/dist/public/assets/railroad-I3PHUGI6-Ds10NBze.js +0 -1
  141. package/dist/public/assets/swimlanesDiagram-OMPLPG4O-BHAN4SQO.js +0 -8
  142. package/dist/public/assets/treeView-D4JQ5SDB-f1hLUBjI.js +0 -1
  143. package/dist/public/assets/treemap-SAJKECNS-_NPRpuUC.js +0 -1
  144. package/dist/public/assets/wardley-7MLQ67FV-CLBqtefx.js +0 -1
package/dist/gateway.mjs CHANGED
@@ -8,6 +8,7 @@ import { createReadStream, existsSync as existsSync2, mkdirSync as mkdirSync4, s
8
8
  import { createServer as createServer2, request as httpRequest } from "node:http";
9
9
  import { request as httpsRequest } from "node:https";
10
10
  import { extname, join as join5, normalize, sep } from "node:path";
11
+ import { pipeline } from "node:stream";
11
12
 
12
13
  // ../../packages/rpc/esm/node/websocket/websocket-connection.js
13
14
  import { createHash } from "node:crypto";
@@ -1263,7 +1264,11 @@ var SignInPageUtil;
1263
1264
  for (const part of (header !== null && header !== undefined ? header : "").split(";")) {
1264
1265
  const [key, ...value] = part.trim().split("=");
1265
1266
  if (key === name) {
1266
- return decodeURIComponent(value.join("="));
1267
+ try {
1268
+ return decodeURIComponent(value.join("="));
1269
+ } catch (_a) {
1270
+ return;
1271
+ }
1267
1272
  }
1268
1273
  }
1269
1274
  return;
@@ -1979,7 +1984,7 @@ class Environments {
1979
1984
  });
1980
1985
  const next = this.tenants.update(tenant.id, { environment: choice });
1981
1986
  this.provider(next);
1982
- this.running.delete(tenant.id);
1987
+ Object.assign(this.state(tenant.id), { status: "stopped", endpoint: undefined, error: undefined });
1983
1988
  return next;
1984
1989
  }
1985
1990
  async dispose() {
@@ -2016,6 +2021,10 @@ var GatewayServiceUtil;
2016
2021
  return typeof method === "string" && GatewayServiceUtil2.SERVICES.includes(method.split("/")[0]);
2017
2022
  }
2018
2023
  GatewayServiceUtil2.owns = owns;
2024
+ function mayOwn(text) {
2025
+ return GatewayServiceUtil2.SERVICES.some((service) => text.includes(`"${service}/`));
2026
+ }
2027
+ GatewayServiceUtil2.mayOwn = mayOwn;
2019
2028
  function error(id, message, code, hint) {
2020
2029
  return JSON.stringify({ jsonrpc: "2.0", id, error: { code: TA_RPC_ERROR_CODE, message, data: { kind: "application", data: { code, hint } } } });
2021
2030
  }
@@ -2231,11 +2240,14 @@ class GatewaySocket {
2231
2240
  };
2232
2241
  }
2233
2242
  fromBrowser(text) {
2234
- var _a;
2243
+ if (this.failure === undefined && !GatewayServiceUtil.mayOwn(text)) {
2244
+ this.forward(text);
2245
+ return;
2246
+ }
2235
2247
  let message;
2236
2248
  try {
2237
2249
  message = JSON.parse(text);
2238
- } catch (_b) {
2250
+ } catch (_a) {
2239
2251
  this.close(1007, "Not JSON.");
2240
2252
  return;
2241
2253
  }
@@ -2249,6 +2261,10 @@ class GatewaySocket {
2249
2261
  }
2250
2262
  return;
2251
2263
  }
2264
+ this.forward(text);
2265
+ }
2266
+ forward(text) {
2267
+ var _a;
2252
2268
  if (((_a = this.inner) === null || _a === undefined ? undefined : _a.readyState) === WebSocket.OPEN) {
2253
2269
  this.inner.send(text);
2254
2270
  } else if (this.queued.length < MAX_QUEUED) {
@@ -2662,11 +2678,10 @@ class GatewayServer {
2662
2678
  const outgoing = send(target, { method: request2.method, headers }, (incoming) => {
2663
2679
  var _a2;
2664
2680
  response.writeHead((_a2 = incoming.statusCode) !== null && _a2 !== undefined ? _a2 : 502, incoming.headers);
2665
- incoming.pipe(response);
2666
- incoming.on("end", () => resolve());
2667
- incoming.on("error", reject);
2681
+ pipeline(incoming, response, () => resolve());
2668
2682
  });
2669
2683
  outgoing.on("error", reject);
2684
+ response.once("close", () => outgoing.destroy());
2670
2685
  outgoing.end();
2671
2686
  });
2672
2687
  }
@@ -2686,7 +2701,10 @@ class GatewayServer {
2686
2701
  response.end();
2687
2702
  return;
2688
2703
  }
2689
- createReadStream(file).pipe(response);
2704
+ const stream = createReadStream(file);
2705
+ stream.once("error", () => response.headersSent ? response.destroy() : SignInPageUtil.end(response, 404));
2706
+ response.once("close", () => stream.destroy());
2707
+ stream.pipe(response);
2690
2708
  }
2691
2709
  upgrade(request2, socket, head) {
2692
2710
  var _a, _b;
@@ -1,5 +1,9 @@
1
1
  # @celljs/ta
2
2
 
3
+ ## 4.9.1
4
+
5
+ No changes in this release.
6
+
3
7
  ## 4.9.0
4
8
 
5
9
  ### Minor Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta",
3
- "version": "4.9.0",
3
+ "version": "4.9.1",
4
4
  "type": "module",
5
5
  "piConfig": {
6
6
  "name": "ta",
@@ -32,7 +32,7 @@ Pick one in the model list of the + on the left of the input box, an agent's mod
32
32
  }
33
33
  ```
34
34
 
35
- Fields: `name`, `command`, `args`, `env`, `login` (the sign-in command to tell the user), `permissions`, `options` (the agent's settings of a new session, by the id or category of the option, such as `{ "mode": "default" }`), `clientMeta` (`_meta` of the client's capabilities in `initialize`). `env` and `options` of a built-in agent merge with those of the settings. `false` turns a built-in agent off. A built-in agent named in the settings is offered even when its program is not found, so it can run another one: the adapters read `CLAUDE_CODE_EXECUTABLE` (Claude Code's executable) and `CODEX_PATH` (the `codex` command), for example for wrappers built on the same code:
35
+ Fields: `name`, `command`, `args`, `env`, `login` (the sign-in command to tell the user), `permissions`, `options` (the agent's settings of a new session, by the id or category of the option, such as `{ "mode": "default" }`), `clientMeta` (`_meta` of the client's capabilities in `initialize`), `processPerSession` (a process for each pi session, for an agent whose process serves one session). `env` and `options` of a built-in agent merge with those of the settings. `false` turns a built-in agent off. A built-in agent named in the settings is offered even when its program is not found, so it can run another one: the adapters read `CLAUDE_CODE_EXECUTABLE` (Claude Code's executable) and `CODEX_PATH` (the `codex` command), for example for wrappers built on the same code:
36
36
 
37
37
  ```json
38
38
  {
@@ -48,7 +48,7 @@ Fields: `name`, `command`, `args`, `env`, `login` (the sign-in command to tell t
48
48
  - **A turn**: each time pi asks the model, only what the user said since the agent last answered goes to the agent (`session/prompt`), since the agent keeps its own history. The agent's text and thinking stream as pi's message.
49
49
  - **Tool calls**: the agent uses its own tools; each call is recorded in pi as a call of `agent_tool` (its arguments are a title, a kind and a target, such as `{ kind: "execute", target: "npm test" }`), so Ta shows it as a line like its own tools, with the agent's output as the result. As soon as a call of kind edit, delete or move names the file it changes (`locations`, or `file_path` and the like in its arguments), or brings an ACP diff, the extension emits `ta:file-write` on `pi.events` (`{ path, before? }`, `TA_FILE_WRITE_EVENT` of ta-protocol), so that ta-changes keeps the file as it was before the agent writes it. When the agent starts a call, the assistant message ends (`toolUse`); pi "running" `agent_tool` only waits for the agent to finish the call, and pi's next request goes on with the same turn. some agents (CodeBuddy Code) stream the arguments first, so a call shows once the agent says they are complete (`toolArgumentsComplete` in `_meta`, or announcing the call again as `pending` with them); without such a sign, 1.5 seconds without news of the call, or the agent saying something else, will do; calls started together go in one message and show in parallel. `agent_tool` is active only while the model is an agent.
50
50
  - **Sessions**: a pi session uses one session of each agent; its id is kept in the pi session (the custom entry `ta-agents.session`), and reopening the conversation loads it again (`session/load`). A fork, or going back to an earlier message in pi (`/tree`), starts a new session of the agent on the next turn and hands it the conversation so far as text; so does switching to an agent in the middle of a conversation (30,000 characters at most).
51
- - **Processes**: the sessions of one agent in one directory share a process (one of CodeBuddy Code takes about 650 MB); by directory, because CodeBuddy Code runs commands where it was started rather than in the directory of the session. A process stops after 10 minutes without a turn, and starts again, loading its sessions, when it is needed. It keeps pi's process alive only while a request waits for its answer, so `pi -p` exits once it answered.
51
+ - **Processes**: the sessions of one agent in one directory share a process; by directory, because CodeBuddy Code runs commands where it was started rather than in the directory of the session. CodeBuddy Code itself runs a process for each conversation (about 650 MB), stopped when the conversation closes: a process of it answers only the session it opened or loaded last, and a prompt of another one waits forever, or ends at once with nothing while that one works. A process stops after 10 minutes without a turn, and starts again, loading its sessions, when it is needed. It keeps pi's process alive only while a request waits for its answer, so `pi -p` exits once it answered.
52
52
  - **When the agent goes on by itself**: after a background task, an agent may start a turn on its own (CodeBuddy Code starts it with `unsolicitedTurn` in a `session_info_update` and ends it with `session_end`; other agents give no end, and the turn ends after 3 quiet seconds). The extension sends pi a message that is not shown, which starts a pi turn that shows it.
53
53
  - **When the user talks while the agent works**: ACP has no way to steer a turn, so it is kept and sent as the next turn as soon as this one ends. Stopping sends `session/cancel`; the next turn waits for the agent to end the cancelled one (5 seconds at most).
54
54
  - **Permissions**: as in pi, nothing is held back: a permission request of the agent is answered "allow once". With `permissions: "ask"` the user picks in the UI. The agent's own permission mode (CodeBuddy Code's settings, for example) still applies.
@@ -32,7 +32,7 @@ CodeBuddy Code 和在它自己的终端里一样:用 PTC(代码模式,工
32
32
  }
33
33
  ```
34
34
 
35
- 字段:`name`、`command`、`args`、`env`、`login`(提示用户执行的登录命令)、`permissions`、`options`(新会话的 Agent 设置,按选项的 id 或类别,如 `{ "mode": "default" }`)、`clientMeta`(`initialize` 里客户端能力的 `_meta`)。内置 Agent 的 `env`、`options` 与设置里的合并。`false` 关掉一个内置 Agent。设置里写了某个内置 Agent,即使没找到它的程序也会提供,适合改用别的程序:适配器认环境变量 `CLAUDE_CODE_EXECUTABLE`(Claude Code 的可执行文件)和 `CODEX_PATH`(`codex` 命令),比如用同源的包装版:
35
+ 字段:`name`、`command`、`args`、`env`、`login`(提示用户执行的登录命令)、`permissions`、`options`(新会话的 Agent 设置,按选项的 id 或类别,如 `{ "mode": "default" }`)、`clientMeta`(`initialize` 里客户端能力的 `_meta`)、`processPerSession`(每个 pi 会话单独一个进程,用于一个进程只服务一个会话的 Agent)。内置 Agent 的 `env`、`options` 与设置里的合并。`false` 关掉一个内置 Agent。设置里写了某个内置 Agent,即使没找到它的程序也会提供,适合改用别的程序:适配器认环境变量 `CLAUDE_CODE_EXECUTABLE`(Claude Code 的可执行文件)和 `CODEX_PATH`(`codex` 命令),比如用同源的包装版:
36
36
 
37
37
  ```json
38
38
  {
@@ -48,7 +48,7 @@ CodeBuddy Code 和在它自己的终端里一样:用 PTC(代码模式,工
48
48
  - **一轮怎么走**:pi 每次请求模型时,只把用户自上次回答以来说的话发给 Agent(`session/prompt`),因为 Agent 自己保存历史。Agent 的文字和思考按流式转成 pi 的消息。
49
49
  - **工具调用**:Agent 用自己的工具,每次调用在 pi 里记成一次 `agent_tool` 工具调用(参数是标题、种类和对象,例如 `{ kind: "execute", target: "npm test" }`),所以 Ta 显示成和自己的工具一样的一行,结果就是 Agent 工具的输出。种类是 edit、delete、move 的调用一说出要改的文件(`locations` 或参数里的 `file_path` 等),或者带来 ACP diff,扩展就经 `pi.events` 发 `ta:file-write`(`{ path, before? }`,见 ta-protocol 的 `TA_FILE_WRITE_EVENT`),让 ta-changes 在 Agent 动手前留下文件原样。具体做法:Agent 开始一次调用时,结束当前这条 assistant 消息(`toolUse`);pi “执行”`agent_tool` 时只是等 Agent 把这次调用做完;pi 下一次请求时接着流同一轮。有的 Agent(CodeBuddy Code)先流式发参数,等它说参数齐了(`_meta` 的 `toolArgumentsComplete`,或带着参数以 `pending` 再报一次这次调用)才显示;没有这类信号时,1.5 秒没有新消息或 Agent 开始说别的,也算齐了;同时开始的几次调用放进同一条消息,并行显示。`agent_tool` 只在当前模型是 Agent 时启用。
50
50
  - **会话**:一个 pi 会话对一个 Agent 用一个 Agent 会话,它的 id 记在 pi 会话里(自定义条目 `ta-agents.session`),重新打开对话时用 `session/load` 接上。分叉,或在 pi 里回退到之前的消息(`/tree`),都会让下一轮新开一个 Agent 会话,并把到此为止的对话作为文字交给它;中途换到 Agent 时也一样(最多 3 万字)。
51
- - **进程**:同一个 Agent 在同一个目录下的所有会话共用一个进程(CodeBuddy Code 一个进程约 650 MB);按目录分开,是因为 CodeBuddy Code 在启动目录里执行命令,不看会话的目录。10 分钟没有任何一轮就停掉进程,下次用时再启动并加载会话。只在有请求等待回复时保持 pi 进程不退出,所以 `pi -p` 回答完就退出。
51
+ - **进程**:同一个 Agent 在同一个目录下的所有会话共用一个进程;按目录分开,是因为 CodeBuddy Code 在启动目录里执行命令,不看会话的目录。CodeBuddy Code 例外,每个对话单独一个进程(约 650 MB),对话关闭时停掉:它的一个进程只回答最后新建或加载的会话,其他会话发消息会一直等不到回复,或在那个会话忙时立刻空着结束。10 分钟没有任何一轮就停掉进程,下次用时再启动并加载会话。只在有请求等待回复时保持 pi 进程不退出,所以 `pi -p` 回答完就退出。
52
52
  - **Agent 自己继续时**:后台任务结束后,Agent 可能自己开始一轮(CodeBuddy Code 用 `session_info_update` 的 `unsolicitedTurn` 开始、`session_end` 收尾;其他 Agent 没有明确的结束标志,就在 3 秒没有消息后收尾)。扩展发一条不显示的消息让 pi 开一轮,把这一轮显示出来。
53
53
  - **用户在 Agent 干活时说话**:ACP 没有“插话”,所以先存下,这一轮结束后马上作为下一轮发出。停止(中止)会发 `session/cancel`,下一轮会等 Agent 把被取消的这轮收尾(最多 5 秒)。
54
54
  - **权限**:和 pi 一样默认不拦:Agent 请求权限时选“允许一次”。设置 `permissions: "ask"` 后,改为在界面上让用户选。Agent 自己的权限模式(例如 CodeBuddy Code 的配置)照常生效。
@@ -657,7 +657,11 @@ class JsonRpcConnection {
657
657
  }
658
658
  }
659
659
  } else if (message.id === undefined || message.id === null) {
660
- this.onNotification(message.method, message.params);
660
+ try {
661
+ this.onNotification(message.method, message.params);
662
+ } catch (error) {
663
+ console.error(error);
664
+ }
661
665
  } else {
662
666
  this.answer(message.id, message.method, message.params);
663
667
  }
@@ -905,11 +909,9 @@ var BINDING_ENTRY = "ta-agents.session";
905
909
  var POOL = Symbol.for("ta-agents.pool");
906
910
  var AgentPool;
907
911
  ((AgentPool) => {
908
- function of(config, cwd) {
909
- const global = globalThis;
910
- const pool = global[POOL] ?? create();
911
- global[POOL] = pool;
912
- const key = JSON.stringify([config.command, config.args, config.env ?? {}, config.clientMeta ?? {}, cwd]);
912
+ function of(config, cwd, owner) {
913
+ const pool = all();
914
+ const key = keyOf(config, cwd, owner);
913
915
  let agent = pool.get(key);
914
916
  if (!agent) {
915
917
  agent = new AcpAgent(config.name, { command: config.command, args: config.args, env: config.env, clientMeta: config.clientMeta, cwd });
@@ -918,6 +920,25 @@ var AgentPool;
918
920
  return agent;
919
921
  }
920
922
  AgentPool.of = of;
923
+ function release(config, cwd, owner) {
924
+ if (!config.processPerSession) {
925
+ return;
926
+ }
927
+ const pool = all();
928
+ const key = keyOf(config, cwd, owner);
929
+ pool.get(key)?.stop();
930
+ pool.delete(key);
931
+ }
932
+ AgentPool.release = release;
933
+ function keyOf(config, cwd, owner) {
934
+ return JSON.stringify([config.command, config.args, config.env ?? {}, config.clientMeta ?? {}, cwd, config.processPerSession ? owner ?? "" : ""]);
935
+ }
936
+ function all() {
937
+ const global = globalThis;
938
+ const pool = global[POOL] ?? create();
939
+ global[POOL] = pool;
940
+ return pool;
941
+ }
921
942
  function create() {
922
943
  const pool = new Map;
923
944
  process.once("exit", () => {
@@ -933,13 +954,17 @@ class AgentBindings {
933
954
  save;
934
955
  prepare;
935
956
  agentOf;
957
+ release;
936
958
  cwd = process.cwd();
959
+ owner;
937
960
  ids = new Map;
938
961
  opened = new Map;
939
- constructor(save, prepare, agentOf = AgentPool.of) {
962
+ used = new Map;
963
+ constructor(save, prepare, agentOf = AgentPool.of, release = AgentPool.release) {
940
964
  this.save = save;
941
965
  this.prepare = prepare;
942
966
  this.agentOf = agentOf;
967
+ this.release = release;
943
968
  }
944
969
  restore(entries, fork) {
945
970
  this.ids.clear();
@@ -962,7 +987,8 @@ class AgentBindings {
962
987
  return this.ids.get(agent);
963
988
  }
964
989
  open(config, signal) {
965
- const agent = this.agentOf(config, this.cwd);
990
+ this.used.set(JSON.stringify([config.id, this.cwd, this.owner]), { config, cwd: this.cwd, owner: this.owner });
991
+ const agent = this.agentOf(config, this.cwd, this.owner);
966
992
  let opened = this.opened.get(config.id);
967
993
  if (opened) {
968
994
  opened = opened.then((value) => agent.running && agent.sessions.get(value.session.id) === value.session ? { ...value, fresh: false } : this.connect(config, agent, signal));
@@ -975,6 +1001,10 @@ class AgentBindings {
975
1001
  }
976
1002
  close() {
977
1003
  this.opened.clear();
1004
+ for (const { config, cwd, owner } of this.used.values()) {
1005
+ this.release(config, cwd, owner);
1006
+ }
1007
+ this.used.clear();
978
1008
  }
979
1009
  async connect(config, agent, signal) {
980
1010
  if (AgentBindings.isRemote(this.cwd)) {
@@ -1024,7 +1054,8 @@ var PRESETS = [
1024
1054
  login: "cbc",
1025
1055
  env: { CODEBUDDY_CODE_MODE_ENABLED: "1" },
1026
1056
  clientMeta: { "codebuddy.ai": { mainAgentSupport: true, toolModeSupport: true } },
1027
- options: { mode: "fullAccess" }
1057
+ options: { mode: "fullAccess" },
1058
+ processPerSession: true
1028
1059
  },
1029
1060
  {
1030
1061
  id: "claude-code",
@@ -1666,22 +1697,25 @@ function activate(pi, options = {}) {
1666
1697
  return option ? { outcome: "selected", optionId: option.optionId } : { outcome: "cancelled" };
1667
1698
  },
1668
1699
  title: (title) => {
1669
- if (!pi.getSessionName()) {
1700
+ if (context && !pi.getSessionName()) {
1670
1701
  pi.setSessionName(title);
1671
1702
  }
1672
1703
  },
1673
1704
  activity: () => {
1674
- if (context?.model?.provider === config.id) {
1705
+ if (context && context.model?.provider === config.id) {
1675
1706
  pi.sendMessage({ customType: ACTIVITY_ENTRY, content: ACTIVITY_TEXT, display: false }, { triggerTurn: true });
1676
1707
  }
1677
1708
  },
1678
1709
  write: (path, before) => {
1710
+ if (!context) {
1711
+ return;
1712
+ }
1679
1713
  const file = { path: resolve(context?.cwd ?? bindings.cwd, path), ...before !== undefined ? { before } : {} };
1680
1714
  pi.events.emit(TA_FILE_WRITE_EVENT, file);
1681
1715
  }
1682
1716
  };
1683
1717
  learn(config, session);
1684
- }, options.agentOf);
1718
+ }, options.agentOf, options.release);
1685
1719
  const streamer = new AgentStreamer({
1686
1720
  open: (config, signal) => bindings.open(config, signal),
1687
1721
  calls,
@@ -1706,6 +1740,10 @@ function activate(pi, options = {}) {
1706
1740
  }
1707
1741
  sessionId = ctx.sessionManager.getSessionId();
1708
1742
  Sessions.set(sessionId, self);
1743
+ if (bindings.owner !== sessionId) {
1744
+ bindings.close();
1745
+ bindings.owner = sessionId;
1746
+ }
1709
1747
  bindings.cwd = ctx.cwd;
1710
1748
  bindings.restore(ctx.sessionManager.getBranch(), event.reason === "fork");
1711
1749
  const settings = pi.getSettings().agents;
@@ -10,10 +10,13 @@ export interface Binding {
10
10
  }
11
11
  /**
12
12
  * The agents' processes of this process, shared by its pi sessions, which load this package each: one
13
- * per agent and directory, since some agents run commands where they were started.
13
+ * per agent and directory, since some agents run commands where they were started, and one per pi
14
+ * session too for an agent that serves one session per process (`processPerSession`).
14
15
  */
15
16
  export declare namespace AgentPool {
16
- function of(config: AgentConfig, cwd: string): AcpAgent;
17
+ function of(config: AgentConfig, cwd: string, owner?: string): AcpAgent;
18
+ /** Stops the process of `owner`'s own, if it has one: its pi session closed. */
19
+ function release(config: AgentConfig, cwd: string, owner?: string): void;
17
20
  }
18
21
  /**
19
22
  * The sessions of agents one pi session talks to, one per agent. Which session that is stays in the
@@ -23,11 +26,20 @@ export declare namespace AgentPool {
23
26
  export declare class AgentBindings {
24
27
  protected readonly save: (binding: Binding) => void;
25
28
  protected readonly prepare: (config: AgentConfig, session: AgentSession) => void;
26
- protected readonly agentOf: (config: AgentConfig, cwd: string) => AcpAgent;
29
+ protected readonly agentOf: (config: AgentConfig, cwd: string, owner?: string) => AcpAgent;
30
+ protected readonly release: (config: AgentConfig, cwd: string, owner?: string) => void;
27
31
  cwd: string;
32
+ /** The pi session: an agent that serves one session per process runs a process for it alone. */
33
+ owner?: string;
28
34
  protected readonly ids: Map<string, string>;
29
35
  protected readonly opened: Map<string, Promise<OpenedSession>>;
30
- constructor(save: (binding: Binding) => void, prepare: (config: AgentConfig, session: AgentSession) => void, agentOf?: (config: AgentConfig, cwd: string) => AcpAgent);
36
+ /** The agents opened, with where, to let their own processes go on close. */
37
+ protected readonly used: Map<string, {
38
+ config: AgentConfig;
39
+ cwd: string;
40
+ owner?: string;
41
+ }>;
42
+ constructor(save: (binding: Binding) => void, prepare: (config: AgentConfig, session: AgentSession) => void, agentOf?: (config: AgentConfig, cwd: string, owner?: string) => AcpAgent, release?: (config: AgentConfig, cwd: string, owner?: string) => void);
31
43
  restore(entries: readonly unknown[], fork: boolean): void;
32
44
  /**
33
45
  * The conversation went back (pi's tree): the agents' sessions remember what came after, so the next
@@ -36,6 +48,7 @@ export declare class AgentBindings {
36
48
  forget(): void;
37
49
  sessionId(agent: string): string | undefined;
38
50
  open(config: AgentConfig, signal?: AbortSignal): Promise<OpenedSession>;
51
+ /** The pi session closed: the processes it had of its own stop; shared ones stay for the others. */
39
52
  close(): void;
40
53
  protected connect(config: AgentConfig, agent: AcpAgent, signal?: AbortSignal): Promise<OpenedSession>;
41
54
  static dirs(cwd: string): string[];
@@ -11,16 +11,14 @@ exports.BINDING_ENTRY = 'ta-agents.session';
11
11
  const POOL = Symbol.for('ta-agents.pool');
12
12
  /**
13
13
  * The agents' processes of this process, shared by its pi sessions, which load this package each: one
14
- * per agent and directory, since some agents run commands where they were started.
14
+ * per agent and directory, since some agents run commands where they were started, and one per pi
15
+ * session too for an agent that serves one session per process (`processPerSession`).
15
16
  */
16
17
  var AgentPool;
17
18
  (function (AgentPool) {
18
- function of(config, cwd) {
19
- var _a, _b, _c;
20
- const global = globalThis;
21
- const pool = (_a = global[POOL]) !== null && _a !== void 0 ? _a : create();
22
- global[POOL] = pool;
23
- const key = JSON.stringify([config.command, config.args, (_b = config.env) !== null && _b !== void 0 ? _b : {}, (_c = config.clientMeta) !== null && _c !== void 0 ? _c : {}, cwd]);
19
+ function of(config, cwd, owner) {
20
+ const pool = all();
21
+ const key = keyOf(config, cwd, owner);
24
22
  let agent = pool.get(key);
25
23
  if (!agent) {
26
24
  agent = new acp_agent_1.AcpAgent(config.name, { command: config.command, args: config.args, env: config.env, clientMeta: config.clientMeta, cwd });
@@ -29,6 +27,29 @@ var AgentPool;
29
27
  return agent;
30
28
  }
31
29
  AgentPool.of = of;
30
+ /** Stops the process of `owner`'s own, if it has one: its pi session closed. */
31
+ function release(config, cwd, owner) {
32
+ var _a;
33
+ if (!config.processPerSession) {
34
+ return;
35
+ }
36
+ const pool = all();
37
+ const key = keyOf(config, cwd, owner);
38
+ (_a = pool.get(key)) === null || _a === void 0 ? void 0 : _a.stop();
39
+ pool.delete(key);
40
+ }
41
+ AgentPool.release = release;
42
+ function keyOf(config, cwd, owner) {
43
+ var _a, _b;
44
+ return JSON.stringify([config.command, config.args, (_a = config.env) !== null && _a !== void 0 ? _a : {}, (_b = config.clientMeta) !== null && _b !== void 0 ? _b : {}, cwd, config.processPerSession ? (owner !== null && owner !== void 0 ? owner : '') : '']);
45
+ }
46
+ function all() {
47
+ var _a;
48
+ const global = globalThis;
49
+ const pool = (_a = global[POOL]) !== null && _a !== void 0 ? _a : create();
50
+ global[POOL] = pool;
51
+ return pool;
52
+ }
32
53
  function create() {
33
54
  const pool = new Map();
34
55
  process.once('exit', () => {
@@ -45,13 +66,16 @@ var AgentPool;
45
66
  * session again; a fork, or going back in the conversation, starts a new one.
46
67
  */
47
68
  class AgentBindings {
48
- constructor(save, prepare, agentOf = AgentPool.of) {
69
+ constructor(save, prepare, agentOf = AgentPool.of, release = AgentPool.release) {
49
70
  this.save = save;
50
71
  this.prepare = prepare;
51
72
  this.agentOf = agentOf;
73
+ this.release = release;
52
74
  this.cwd = process.cwd();
53
75
  this.ids = new Map();
54
76
  this.opened = new Map();
77
+ /** The agents opened, with where, to let their own processes go on close. */
78
+ this.used = new Map();
55
79
  }
56
80
  restore(entries, fork) {
57
81
  this.ids.clear();
@@ -78,7 +102,8 @@ class AgentBindings {
78
102
  return this.ids.get(agent);
79
103
  }
80
104
  open(config, signal) {
81
- const agent = this.agentOf(config, this.cwd);
105
+ this.used.set(JSON.stringify([config.id, this.cwd, this.owner]), { config, cwd: this.cwd, owner: this.owner });
106
+ const agent = this.agentOf(config, this.cwd, this.owner);
82
107
  let opened = this.opened.get(config.id);
83
108
  if (opened) {
84
109
  // The program may have stopped since, idle, and its sessions with it.
@@ -92,8 +117,13 @@ class AgentBindings {
92
117
  this.opened.set(config.id, opened);
93
118
  return opened;
94
119
  }
120
+ /** The pi session closed: the processes it had of its own stop; shared ones stay for the others. */
95
121
  close() {
96
122
  this.opened.clear();
123
+ for (const { config, cwd, owner } of this.used.values()) {
124
+ this.release(config, cwd, owner);
125
+ }
126
+ this.used.clear();
97
127
  }
98
128
  async connect(config, agent, signal) {
99
129
  var _a, _b, _c;
@@ -13,6 +13,8 @@ export interface AgentConfig {
13
13
  clientMeta?: Record<string, unknown>;
14
14
  /** Settings of a new session, by the id or category of the agent's option (`mode`, `model`...). */
15
15
  options?: Record<string, string>;
16
+ /** A process of its own for each pi session, for an agent that serves one session per process. */
17
+ processPerSession?: boolean;
16
18
  }
17
19
  /** An agent of `agents` in pi's settings.json; `false` turns a built-in one off. */
18
20
  export type AgentSetting = false | Partial<AgentConfig>;
@@ -22,6 +22,9 @@ const PRESETS = [
22
22
  env: { CODEBUDDY_CODE_MODE_ENABLED: '1' },
23
23
  clientMeta: { 'codebuddy.ai': { mainAgentSupport: true, toolModeSupport: true } },
24
24
  options: { mode: 'fullAccess' },
25
+ // It answers only the session it opened or loaded last: a prompt of another one waits forever, or
26
+ // ends at once with nothing while that one works.
27
+ processPerSession: true,
25
28
  },
26
29
  {
27
30
  id: 'claude-code',
@@ -5,7 +5,8 @@ import type { ExtensionAPI } from './pi-types';
5
5
  export interface AgentsOptions {
6
6
  find?: (program: string) => string | undefined;
7
7
  cache?: ModelCache;
8
- agentOf?: (config: AgentConfig, cwd: string) => AcpAgent;
8
+ agentOf?: (config: AgentConfig, cwd: string, owner?: string) => AcpAgent;
9
+ release?: (config: AgentConfig, cwd: string, owner?: string) => void;
9
10
  /** `agents` of the user's settings.json, read when the extension loads, before pi's settings are there. */
10
11
  userAgents?: () => Record<string, AgentSetting> | undefined;
11
12
  }
@@ -144,26 +144,30 @@ function activate(pi, options = {}) {
144
144
  const option = request.options.find(candidate => candidate.name === chosen);
145
145
  return option ? { outcome: 'selected', optionId: option.optionId } : { outcome: 'cancelled' };
146
146
  },
147
+ // The agent may still speak after the pi session closed, when pi's API is no longer usable.
147
148
  title: title => {
148
- if (!pi.getSessionName()) {
149
+ if (context && !pi.getSessionName()) {
149
150
  pi.setSessionName(title);
150
151
  }
151
152
  },
152
153
  activity: () => {
153
154
  var _a;
154
- if (((_a = context === null || context === void 0 ? void 0 : context.model) === null || _a === void 0 ? void 0 : _a.provider) === config.id) {
155
+ if (context && ((_a = context.model) === null || _a === void 0 ? void 0 : _a.provider) === config.id) {
155
156
  pi.sendMessage({ customType: ACTIVITY_ENTRY, content: agent_prompt_1.ACTIVITY_TEXT, display: false }, { triggerTurn: true });
156
157
  }
157
158
  },
158
159
  // Other extensions (the list of changed files) hear of the files the agent writes with its own tools.
159
160
  write: (path, before) => {
160
161
  var _a;
162
+ if (!context) {
163
+ return;
164
+ }
161
165
  const file = { path: (0, node_path_1.resolve)((_a = context === null || context === void 0 ? void 0 : context.cwd) !== null && _a !== void 0 ? _a : bindings.cwd, path), ...(before !== undefined ? { before } : {}) };
162
166
  pi.events.emit(TA_FILE_WRITE_EVENT, file);
163
167
  },
164
168
  };
165
169
  learn(config, session);
166
- }, options.agentOf);
170
+ }, options.agentOf, options.release);
167
171
  const streamer = new agent_streamer_1.AgentStreamer({
168
172
  open: (config, signal) => bindings.open(config, signal),
169
173
  calls,
@@ -190,6 +194,10 @@ function activate(pi, options = {}) {
190
194
  }
191
195
  sessionId = ctx.sessionManager.getSessionId();
192
196
  Sessions.set(sessionId, self);
197
+ if (bindings.owner !== sessionId) {
198
+ bindings.close();
199
+ bindings.owner = sessionId;
200
+ }
193
201
  bindings.cwd = ctx.cwd;
194
202
  bindings.restore(ctx.sessionManager.getBranch(), event.reason === 'fork');
195
203
  const settings = pi.getSettings().agents;
@@ -124,7 +124,13 @@ class JsonRpcConnection {
124
124
  }
125
125
  }
126
126
  else if (message.id === undefined || message.id === null) {
127
- this.onNotification(message.method, message.params);
127
+ try {
128
+ this.onNotification(message.method, message.params);
129
+ }
130
+ catch (error) {
131
+ // One update that fails to apply leaves the rest of the stream, and the process of pi, as they are.
132
+ console.error(error);
133
+ }
128
134
  }
129
135
  else {
130
136
  void this.answer(message.id, message.method, message.params);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-agents",
3
- "version": "4.9.0",
3
+ "version": "4.9.1",
4
4
  "description": "A pi package for Ta: other coding agents (CodeBuddy Code, Claude Code, Codex and any agent that speaks ACP) as models to pick, each running a conversation on its own harness",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-bots",
3
- "version": "4.9.0",
3
+ "version": "4.9.1",
4
4
  "description": "A pi package for Ta: bots of WeChat (ClawBot) and WeCom connected to the double, an agent or a conversation, messages and files both ways",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-changes",
3
- "version": "4.9.0",
3
+ "version": "4.9.1",
4
4
  "description": "A pi package for Ta: the files each reply changed, with their diffs, and a button that takes the changes of a reply back",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -131,7 +131,8 @@ declare const EN: {
131
131
  readonly noTasksHere: 'What the double hands out, tasks and teams, is listed here';
132
132
  readonly tellDouble: 'Talk to the double';
133
133
  readonly deleteTask: 'Delete the team';
134
- readonly confirmDeleteTask: 'Delete #{channel} and its messages? Its agents stay, among your members.';
134
+ readonly deleteTaskHint: 'The messages of #{channel} go with it. Its agents stay, among your members.';
135
+ readonly selectTasks: 'Select';
135
136
  };
136
137
  export type Words = {
137
138
  readonly [K in keyof typeof EN]: string;
@@ -134,7 +134,8 @@ const EN = {
134
134
  noTasksHere: 'What the double hands out, tasks and teams, is listed here',
135
135
  tellDouble: 'Talk to the double',
136
136
  deleteTask: 'Delete the team',
137
- confirmDeleteTask: 'Delete #{channel} and its messages? Its agents stay, among your members.',
137
+ deleteTaskHint: 'The messages of #{channel} go with it. Its agents stay, among your members.',
138
+ selectTasks: 'Select',
138
139
  };
139
140
  const ZH = {
140
141
  title: '分身',
@@ -269,7 +270,8 @@ const ZH = {
269
270
  noTasksHere: '分身交出去的任务和团队会列在这里',
270
271
  tellDouble: '和分身说',
271
272
  deleteTask: '删除这个团队',
272
- confirmDeleteTask: '删除 #{channel} 及其消息?团队成员会留在你的成员里。',
273
+ deleteTaskHint: '#{channel} 的消息会一起删除,团队成员会留在你的成员里。',
274
+ selectTasks: '多选',
273
275
  };
274
276
  var ChannelWords;
275
277
  (function (ChannelWords) {