@bastani/atomic-acp 0.0.13 → 0.0.14

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.
package/README.md CHANGED
@@ -73,6 +73,7 @@ Without a global install, use `"command": "npx", "args": ["-y", "@bastani/atomic
73
73
  - The model and thinking pickers list what your Atomic setup offers, and the context indicator shows how full the context is.
74
74
  - Prompt templates, skills (`/skill:name`) and extension commands such as `/workflow` appear in the slash menu.
75
75
  - When Atomic asks you to pick, confirm or type something, the editor shows a form.
76
+ - `ask_user_question` shows all of its questions in one form, multi-select included.
76
77
  - MCP servers the editor configures reach the thread's Atomic process, and their tools are callable as `mcp__<server>__<tool>`. Stdio and HTTP servers work, SSE servers are skipped. `atomic-acp` never writes to your Atomic MCP config, and a server you define there under the same name wins.
77
78
  - If Atomic exits during a message, the message fails with the reason, and the next message starts Atomic again on the same session.
78
79
 
@@ -132,7 +133,7 @@ With `ATOMIC_ACP_HEADLESS=1`, questions end at once instead of waiting. `ask_use
132
133
 
133
134
  ## Limitations
134
135
 
135
- - `ask_user_question` can't be answered over ACP, because Atomic's RPC mode can't carry its UI.
136
+ - `ask_user_question` needs Atomic 0.9.50 or newer and an editor that supports ACP forms (elicitation). Without them, the question can't be answered.
136
137
  - Atomic reads, writes and runs commands itself. The editor's file and terminal APIs aren't used.
137
138
  - Messages sent while Atomic is busy are queued and sent one at a time.
138
139
  - Zed is the tested client. Other ACP clients should work but may render some updates differently.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/index.ts
4
- import { AgentSideConnection, ndJsonStream } from "@agentclientprotocol/sdk";
4
+ import { ndJsonStream } from "@agentclientprotocol/sdk";
5
5
 
6
6
  // src/acp/workflow-history.ts
7
7
  function record(value) {
@@ -80,6 +80,8 @@ function bashTerminalExitMeta(id, exitCode) {
80
80
 
81
81
  // src/acp/agent.ts
82
82
  import {
83
+ agent,
84
+ methods as methods3,
83
85
  RequestError as RequestError4
84
86
  } from "@agentclientprotocol/sdk";
85
87
 
@@ -122,6 +124,9 @@ function terminalAuthLaunchSpec() {
122
124
  }
123
125
 
124
126
  // src/acp/elicitation/extension-dialog.ts
127
+ import {
128
+ methods
129
+ } from "@agentclientprotocol/sdk";
125
130
  var NO_CLIENT_ELICITATION_SUPPORT = {
126
131
  form: false,
127
132
  reason: "missing_client_capability"
@@ -154,6 +159,15 @@ async function requestDialog(conn, sessionId, ev, form, onClientCannotAnswer) {
154
159
  const id = String(ev.id);
155
160
  const cancelled = { type: "extension_ui_response", id, cancelled: true };
156
161
  const method = ev.method;
162
+ if (method === "questionnaire") {
163
+ if (!form) return cancelled;
164
+ try {
165
+ return await requestQuestionnaire(conn, sessionId, id, ev.questions);
166
+ } catch {
167
+ onClientCannotAnswer?.();
168
+ return cancelled;
169
+ }
170
+ }
157
171
  const options = Array.isArray(ev.options) ? ev.options.map(String) : [];
158
172
  if (method === "select" && !options.length) return cancelled;
159
173
  const title = typeof ev.title === "string" ? ev.title : `Atomic ${method}`;
@@ -169,7 +183,7 @@ async function requestDialog(conn, sessionId, ev, form, onClientCannotAnswer) {
169
183
  ...typeof ev.placeholder === "string" ? { description: ev.placeholder } : {},
170
184
  ...typeof ev.prefill === "string" ? { default: ev.prefill } : {}
171
185
  };
172
- const response2 = await conn.createElicitation({
186
+ const response2 = await conn.request(methods.client.elicitation.create, {
173
187
  sessionId,
174
188
  mode: "form",
175
189
  message: typeof ev.message === "string" ? `${title}
@@ -190,7 +204,7 @@ ${ev.message}` : title,
190
204
  for (const key of ["title", "message", "options", "placeholder", "prefill"]) {
191
205
  if (Object.hasOwn(ev, key)) rawInput[key] = ev[key];
192
206
  }
193
- const response = await conn.requestPermission({
207
+ const response = await conn.request(methods.client.session.requestPermission, {
194
208
  sessionId,
195
209
  toolCall: { toolCallId: `atomic-ui-${id}`, title, kind: "other", status: "pending", rawInput },
196
210
  options: method === "confirm" ? [
@@ -209,9 +223,64 @@ ${ev.message}` : title,
209
223
  return cancelled;
210
224
  }
211
225
  }
226
+ function readQuestions(value) {
227
+ if (!Array.isArray(value) || value.length === 0) return void 0;
228
+ const questions = [];
229
+ for (const item of value) {
230
+ const q = item;
231
+ if (!q || typeof q.question !== "string" || !Array.isArray(q.options) || q.options.length === 0) return void 0;
232
+ const options = q.options.filter(
233
+ (option) => typeof option?.label === "string" && option.label !== ""
234
+ );
235
+ if (options.length !== q.options.length) return void 0;
236
+ questions.push({
237
+ question: q.question,
238
+ ...typeof q.header === "string" ? { header: q.header } : {},
239
+ multiSelect: q.multiSelect === true,
240
+ options
241
+ });
242
+ }
243
+ return questions;
244
+ }
245
+ async function requestQuestionnaire(conn, sessionId, id, rawQuestions) {
246
+ const cancelled = { type: "extension_ui_response", id, cancelled: true };
247
+ const questions = readQuestions(rawQuestions);
248
+ if (!questions) return cancelled;
249
+ const properties = {};
250
+ questions.forEach((q, index) => {
251
+ const labels = q.options.map((option) => option.label);
252
+ const described = q.options.filter((option) => option.description);
253
+ const description = [q.question, ...described.map((option) => `${option.label}: ${option.description}`)].join("\n");
254
+ const title = q.header || q.question;
255
+ properties[`q${index}`] = q.multiSelect ? { type: "array", title, description, minItems: 1, items: { type: "string", enum: labels } } : { type: "string", title, description, enum: labels };
256
+ });
257
+ const response = await conn.request(methods.client.elicitation.create, {
258
+ sessionId,
259
+ mode: "form",
260
+ message: questions.length === 1 ? questions[0].question : "Atomic has some questions for you.",
261
+ requestedSchema: { type: "object", properties, required: Object.keys(properties) },
262
+ _meta: { atomicAcp: { kind: "extension_ui", method: "questionnaire", atomicRequestId: id } }
263
+ });
264
+ if (response.action !== "accept") return cancelled;
265
+ const content = response.content ?? {};
266
+ const answers = [];
267
+ for (const [index, q] of questions.entries()) {
268
+ const labels = q.options.map((option) => option.label);
269
+ const value = content[`q${index}`];
270
+ if (q.multiSelect) {
271
+ if (!Array.isArray(value) || value.length === 0 || !value.every((v) => typeof v === "string" && labels.includes(v)))
272
+ return cancelled;
273
+ answers.push({ questionIndex: index, question: q.question, kind: "multi", answer: null, selected: value });
274
+ } else {
275
+ if (typeof value !== "string" || !labels.includes(value)) return cancelled;
276
+ answers.push({ questionIndex: index, question: q.question, kind: "option", answer: value });
277
+ }
278
+ }
279
+ return { type: "extension_ui_response", id, answers };
280
+ }
212
281
 
213
282
  // src/acp/session.ts
214
- import { RequestError as RequestError3 } from "@agentclientprotocol/sdk";
283
+ import { RequestError as RequestError3, methods as methods2 } from "@agentclientprotocol/sdk";
215
284
 
216
285
  // src/acp/auth-required.ts
217
286
  import { RequestError } from "@agentclientprotocol/sdk";
@@ -561,6 +630,9 @@ var AtomicRpcProcess = class _AtomicRpcProcess {
561
630
  await proc.getState();
562
631
  } catch {
563
632
  }
633
+ if (params.answersQuestionnaires && !params.headless) {
634
+ await proc.request({ type: "set_extension_ui_capabilities", questionnaire: true }).catch(() => void 0);
635
+ }
564
636
  return proc;
565
637
  }
566
638
  /** Whether the Atomic process has exited. A session whose Atomic exited needs a new process. */
@@ -1181,8 +1253,9 @@ function toAtomicMcpServers(servers) {
1181
1253
  exposure: "direct"
1182
1254
  });
1183
1255
  } else {
1184
- const type = "type" in server ? String(server.type) : "unknown";
1185
- warnings.push(`MCP server "${server.name}" skipped: Atomic does not support the ${type} transport`);
1256
+ const other = server;
1257
+ const type = "type" in other ? String(other.type) : "unknown";
1258
+ warnings.push(`MCP server "${other.name}" skipped: Atomic does not support the ${type} transport`);
1186
1259
  }
1187
1260
  }
1188
1261
  return { servers: Object.fromEntries(out), warnings };
@@ -1340,7 +1413,8 @@ var SessionManager = class {
1340
1413
  cwd: params.cwd,
1341
1414
  atomicCommand: params.atomicCommand,
1342
1415
  mcpServers: atomicMcpServersForSpawn(params.mcpServers),
1343
- headless: params.headless
1416
+ headless: params.headless,
1417
+ answersQuestionnaires: params.clientElicitationSupport?.form === true
1344
1418
  });
1345
1419
  } catch (e) {
1346
1420
  if (e instanceof AtomicRpcSpawnError) {
@@ -1572,7 +1646,7 @@ var AtomicAcpSession = class {
1572
1646
  }
1573
1647
  emit(update) {
1574
1648
  this.lastEmit = this.lastEmit.then(
1575
- () => this.conn.sessionUpdate({
1649
+ () => this.conn.notify(methods2.client.session.update, {
1576
1650
  sessionId: this.sessionId,
1577
1651
  update
1578
1652
  })
@@ -1752,7 +1826,7 @@ var AtomicAcpSession = class {
1752
1826
  });
1753
1827
  return;
1754
1828
  }
1755
- if (!["select", "confirm", "input", "editor"].includes(String(method))) return;
1829
+ if (!["select", "confirm", "input", "editor", "questionnaire"].includes(String(method))) return;
1756
1830
  if (this.pendingExtensionDialogs.has(id)) return;
1757
1831
  const question = typeof ev.title === "string" && ev.title ? ev.title : `Atomic ${method}`;
1758
1832
  const noPersonAvailable = () => this.emitAgentText(`No person is available to answer "${question}", so Atomic was told it was cancelled.`);
@@ -2592,7 +2666,8 @@ var AtomicAcpAgent = class {
2592
2666
  sessionId,
2593
2667
  atomicCommand: process.env.ATOMIC_ACP_ATOMIC_COMMAND,
2594
2668
  mcpServers: atomicMcpServersForSpawn(mcpServers),
2595
- headless: isHeadlessFromEnv()
2669
+ headless: isHeadlessFromEnv(),
2670
+ answersQuestionnaires: this.clientElicitationSupport.form
2596
2671
  });
2597
2672
  } catch (error) {
2598
2673
  if (error instanceof AtomicRpcSpawnError) throw RequestError4.internalError({ code: error.code }, error.message);
@@ -2762,7 +2837,7 @@ var AtomicAcpAgent = class {
2762
2837
  enableSkillCommands,
2763
2838
  includeExtensionCommands: true
2764
2839
  });
2765
- await this.conn.sessionUpdate({
2840
+ await this.conn.notify(methods3.client.session.update, {
2766
2841
  sessionId: session.sessionId,
2767
2842
  update: {
2768
2843
  sessionUpdate: "available_commands_update",
@@ -2772,7 +2847,7 @@ var AtomicAcpAgent = class {
2772
2847
  return;
2773
2848
  } catch {
2774
2849
  }
2775
- await this.conn.sessionUpdate({
2850
+ await this.conn.notify(methods3.client.session.update, {
2776
2851
  sessionId: session.sessionId,
2777
2852
  update: {
2778
2853
  sessionUpdate: "available_commands_update",
@@ -2807,7 +2882,7 @@ var AtomicAcpAgent = class {
2807
2882
  text = `Could not read workflow history: ${error instanceof Error ? error.message : String(error)}`;
2808
2883
  }
2809
2884
  }
2810
- await this.conn.sessionUpdate({
2885
+ await this.conn.notify(methods3.client.session.update, {
2811
2886
  sessionId: session.sessionId,
2812
2887
  update: {
2813
2888
  sessionUpdate: "agent_message_chunk",
@@ -2829,7 +2904,7 @@ var AtomicAcpAgent = class {
2829
2904
  const text = headerLines.join("\n") + (summary ? `
2830
2905
 
2831
2906
  ${summary}` : "");
2832
- await this.conn.sessionUpdate({
2907
+ await this.conn.notify(methods3.client.session.update, {
2833
2908
  sessionId: session.sessionId,
2834
2909
  update: {
2835
2910
  sessionUpdate: "agent_message_chunk",
@@ -2857,7 +2932,7 @@ ${summary}` : "");
2857
2932
  }
2858
2933
  const text = lines.length ? lines.join("\n") : `Session stats:
2859
2934
  ${JSON.stringify(stats, null, 2)}`;
2860
- await this.conn.sessionUpdate({
2935
+ await this.conn.notify(methods3.client.session.update, {
2861
2936
  sessionId: session.sessionId,
2862
2937
  update: {
2863
2938
  sessionUpdate: "agent_message_chunk",
@@ -2869,7 +2944,7 @@ ${JSON.stringify(stats, null, 2)}`;
2869
2944
  if (cmd === "name") {
2870
2945
  const name = args.join(" ").trim();
2871
2946
  if (!name) {
2872
- await this.conn.sessionUpdate({
2947
+ await this.conn.notify(methods3.client.session.update, {
2873
2948
  sessionId: session.sessionId,
2874
2949
  update: {
2875
2950
  sessionUpdate: "agent_message_chunk",
@@ -2883,7 +2958,7 @@ ${JSON.stringify(stats, null, 2)}`;
2883
2958
  } catch (e) {
2884
2959
  const msg = String(e?.message ?? e);
2885
2960
  const hint = /set_session_name/i.test(msg) ? " This requires a newer Atomic version that supports `set_session_name` in RPC mode." : "";
2886
- await this.conn.sessionUpdate({
2961
+ await this.conn.notify(methods3.client.session.update, {
2887
2962
  sessionId: session.sessionId,
2888
2963
  update: {
2889
2964
  sessionUpdate: "agent_message_chunk",
@@ -2892,7 +2967,7 @@ ${JSON.stringify(stats, null, 2)}`;
2892
2967
  });
2893
2968
  return { stopReason: "end_turn" };
2894
2969
  }
2895
- await this.conn.sessionUpdate({
2970
+ await this.conn.notify(methods3.client.session.update, {
2896
2971
  sessionId: session.sessionId,
2897
2972
  update: {
2898
2973
  sessionUpdate: "agent_message_chunk",
@@ -2906,7 +2981,7 @@ ${JSON.stringify(stats, null, 2)}`;
2906
2981
  const state = await session.proc.getState();
2907
2982
  const current = String(state?.steeringMode ?? "");
2908
2983
  if (!modeRaw) {
2909
- await this.conn.sessionUpdate({
2984
+ await this.conn.notify(methods3.client.session.update, {
2910
2985
  sessionId: session.sessionId,
2911
2986
  update: {
2912
2987
  sessionUpdate: "agent_message_chunk",
@@ -2919,7 +2994,7 @@ ${JSON.stringify(stats, null, 2)}`;
2919
2994
  return { stopReason: "end_turn" };
2920
2995
  }
2921
2996
  if (modeRaw !== "all" && modeRaw !== "one-at-a-time") {
2922
- await this.conn.sessionUpdate({
2997
+ await this.conn.notify(methods3.client.session.update, {
2923
2998
  sessionId: session.sessionId,
2924
2999
  update: {
2925
3000
  sessionUpdate: "agent_message_chunk",
@@ -2932,7 +3007,7 @@ ${JSON.stringify(stats, null, 2)}`;
2932
3007
  return { stopReason: "end_turn" };
2933
3008
  }
2934
3009
  await session.proc.setSteeringMode(modeRaw);
2935
- await this.conn.sessionUpdate({
3010
+ await this.conn.notify(methods3.client.session.update, {
2936
3011
  sessionId: session.sessionId,
2937
3012
  update: {
2938
3013
  sessionUpdate: "agent_message_chunk",
@@ -2946,7 +3021,7 @@ ${JSON.stringify(stats, null, 2)}`;
2946
3021
  const state = await session.proc.getState();
2947
3022
  const current = String(state?.followUpMode ?? "");
2948
3023
  if (!modeRaw) {
2949
- await this.conn.sessionUpdate({
3024
+ await this.conn.notify(methods3.client.session.update, {
2950
3025
  sessionId: session.sessionId,
2951
3026
  update: {
2952
3027
  sessionUpdate: "agent_message_chunk",
@@ -2959,7 +3034,7 @@ ${JSON.stringify(stats, null, 2)}`;
2959
3034
  return { stopReason: "end_turn" };
2960
3035
  }
2961
3036
  if (modeRaw !== "all" && modeRaw !== "one-at-a-time") {
2962
- await this.conn.sessionUpdate({
3037
+ await this.conn.notify(methods3.client.session.update, {
2963
3038
  sessionId: session.sessionId,
2964
3039
  update: {
2965
3040
  sessionUpdate: "agent_message_chunk",
@@ -2972,7 +3047,7 @@ ${JSON.stringify(stats, null, 2)}`;
2972
3047
  return { stopReason: "end_turn" };
2973
3048
  }
2974
3049
  await session.proc.setFollowUpMode(modeRaw);
2975
- await this.conn.sessionUpdate({
3050
+ await this.conn.notify(methods3.client.session.update, {
2976
3051
  sessionId: session.sessionId,
2977
3052
  update: {
2978
3053
  sessionUpdate: "agent_message_chunk",
@@ -3006,7 +3081,7 @@ ${JSON.stringify(stats, null, 2)}`;
3006
3081
  };
3007
3082
  const changelogPath = findChangelog();
3008
3083
  if (!changelogPath) {
3009
- await this.conn.sessionUpdate({
3084
+ await this.conn.notify(methods3.client.session.update, {
3010
3085
  sessionId: session.sessionId,
3011
3086
  update: {
3012
3087
  sessionUpdate: "agent_message_chunk",
@@ -3019,7 +3094,7 @@ ${JSON.stringify(stats, null, 2)}`;
3019
3094
  try {
3020
3095
  text = readFileSync5(changelogPath, "utf-8");
3021
3096
  } catch (e) {
3022
- await this.conn.sessionUpdate({
3097
+ await this.conn.notify(methods3.client.session.update, {
3023
3098
  sessionId: session.sessionId,
3024
3099
  update: {
3025
3100
  sessionUpdate: "agent_message_chunk",
@@ -3030,7 +3105,7 @@ ${JSON.stringify(stats, null, 2)}`;
3030
3105
  }
3031
3106
  const maxChars = 2e4;
3032
3107
  if (text.length > maxChars) text = text.slice(0, maxChars) + "\n\n...(truncated)...";
3033
- await this.conn.sessionUpdate({
3108
+ await this.conn.notify(methods3.client.session.update, {
3034
3109
  sessionId: session.sessionId,
3035
3110
  update: {
3036
3111
  sessionUpdate: "agent_message_chunk",
@@ -3043,7 +3118,7 @@ ${JSON.stringify(stats, null, 2)}`;
3043
3118
  const state = await session.proc.getState();
3044
3119
  const messageCount = typeof state?.messageCount === "number" ? state.messageCount : 0;
3045
3120
  if (messageCount === 0) {
3046
- await this.conn.sessionUpdate({
3121
+ await this.conn.notify(methods3.client.session.update, {
3047
3122
  sessionId: session.sessionId,
3048
3123
  update: {
3049
3124
  sessionUpdate: "agent_message_chunk",
@@ -3059,7 +3134,7 @@ ${JSON.stringify(stats, null, 2)}`;
3059
3134
  const result = await session.proc.exportHtml(outputPath);
3060
3135
  resultPath = result.path;
3061
3136
  } catch (e) {
3062
- await this.conn.sessionUpdate({
3137
+ await this.conn.notify(methods3.client.session.update, {
3063
3138
  sessionId: session.sessionId,
3064
3139
  update: {
3065
3140
  sessionUpdate: "agent_message_chunk",
@@ -3072,7 +3147,7 @@ ${JSON.stringify(stats, null, 2)}`;
3072
3147
  return { stopReason: "end_turn" };
3073
3148
  }
3074
3149
  if (!resultPath) {
3075
- await this.conn.sessionUpdate({
3150
+ await this.conn.notify(methods3.client.session.update, {
3076
3151
  sessionId: session.sessionId,
3077
3152
  update: {
3078
3153
  sessionUpdate: "agent_message_chunk",
@@ -3085,7 +3160,7 @@ ${JSON.stringify(stats, null, 2)}`;
3085
3160
  return { stopReason: "end_turn" };
3086
3161
  }
3087
3162
  const uri = `file://${resultPath}`;
3088
- await this.conn.sessionUpdate({
3163
+ await this.conn.notify(methods3.client.session.update, {
3089
3164
  sessionId: session.sessionId,
3090
3165
  update: {
3091
3166
  sessionUpdate: "agent_message_chunk",
@@ -3095,7 +3170,7 @@ ${JSON.stringify(stats, null, 2)}`;
3095
3170
  }
3096
3171
  }
3097
3172
  });
3098
- await this.conn.sessionUpdate({
3173
+ await this.conn.notify(methods3.client.session.update, {
3099
3174
  sessionId: session.sessionId,
3100
3175
  update: {
3101
3176
  sessionUpdate: "agent_message_chunk",
@@ -3121,7 +3196,7 @@ ${JSON.stringify(stats, null, 2)}`;
3121
3196
  enabled = !current;
3122
3197
  }
3123
3198
  await session.proc.setAutoCompaction(enabled);
3124
- await this.conn.sessionUpdate({
3199
+ await this.conn.notify(methods3.client.session.update, {
3125
3200
  sessionId: session.sessionId,
3126
3201
  update: {
3127
3202
  sessionUpdate: "agent_message_chunk",
@@ -3207,7 +3282,7 @@ ${JSON.stringify(stats, null, 2)}`;
3207
3282
  if (role === "user") {
3208
3283
  const text = normalizeAtomicMessageText(m?.content);
3209
3284
  if (text) {
3210
- await this.conn.sessionUpdate({
3285
+ await this.conn.notify(methods3.client.session.update, {
3211
3286
  sessionId: session.sessionId,
3212
3287
  update: {
3213
3288
  sessionUpdate: "user_message_chunk",
@@ -3219,7 +3294,7 @@ ${JSON.stringify(stats, null, 2)}`;
3219
3294
  if (role === "assistant") {
3220
3295
  const text = normalizeAtomicAssistantText(m?.content);
3221
3296
  if (text) {
3222
- await this.conn.sessionUpdate({
3297
+ await this.conn.notify(methods3.client.session.update, {
3223
3298
  sessionId: session.sessionId,
3224
3299
  update: {
3225
3300
  sessionUpdate: "agent_message_chunk",
@@ -3234,7 +3309,7 @@ ${JSON.stringify(stats, null, 2)}`;
3234
3309
  const isError = Boolean(m?.isError);
3235
3310
  if (isBashTool(toolName)) {
3236
3311
  const text2 = bashResultText(m);
3237
- await this.conn.sessionUpdate({
3312
+ await this.conn.notify(methods3.client.session.update, {
3238
3313
  sessionId: session.sessionId,
3239
3314
  update: {
3240
3315
  sessionUpdate: "tool_call",
@@ -3246,7 +3321,7 @@ ${JSON.stringify(stats, null, 2)}`;
3246
3321
  _meta: bashTerminalInfoMeta(toolCallId, params.cwd)
3247
3322
  }
3248
3323
  });
3249
- await this.conn.sessionUpdate({
3324
+ await this.conn.notify(methods3.client.session.update, {
3250
3325
  sessionId: session.sessionId,
3251
3326
  update: {
3252
3327
  sessionUpdate: "tool_call_update",
@@ -3260,7 +3335,7 @@ ${JSON.stringify(stats, null, 2)}`;
3260
3335
  });
3261
3336
  continue;
3262
3337
  }
3263
- await this.conn.sessionUpdate({
3338
+ await this.conn.notify(methods3.client.session.update, {
3264
3339
  sessionId: session.sessionId,
3265
3340
  update: {
3266
3341
  sessionUpdate: "tool_call",
@@ -3273,7 +3348,7 @@ ${JSON.stringify(stats, null, 2)}`;
3273
3348
  }
3274
3349
  });
3275
3350
  const text = toolResultToText(m);
3276
- await this.conn.sessionUpdate({
3351
+ await this.conn.notify(methods3.client.session.update, {
3277
3352
  sessionId: session.sessionId,
3278
3353
  update: {
3279
3354
  sessionUpdate: "tool_call_update",
@@ -3304,7 +3379,7 @@ ${JSON.stringify(stats, null, 2)}`;
3304
3379
  enableSkillCommands,
3305
3380
  includeExtensionCommands: true
3306
3381
  });
3307
- await this.conn.sessionUpdate({
3382
+ await this.conn.notify(methods3.client.session.update, {
3308
3383
  sessionId: session.sessionId,
3309
3384
  update: {
3310
3385
  sessionUpdate: "available_commands_update",
@@ -3314,7 +3389,7 @@ ${JSON.stringify(stats, null, 2)}`;
3314
3389
  return;
3315
3390
  } catch {
3316
3391
  }
3317
- await this.conn.sessionUpdate({
3392
+ await this.conn.notify(methods3.client.session.update, {
3318
3393
  sessionId: session.sessionId,
3319
3394
  update: {
3320
3395
  sessionUpdate: "available_commands_update",
@@ -3364,6 +3439,13 @@ ${JSON.stringify(stats, null, 2)}`;
3364
3439
  return { configOptions };
3365
3440
  }
3366
3441
  };
3442
+ function atomicAcpApp(onAgent) {
3443
+ let atomicAgent2;
3444
+ return agent({ name: "atomic-acp" }).onConnect((connection) => {
3445
+ atomicAgent2 = new AtomicAcpAgent(connection.client);
3446
+ onAgent?.(atomicAgent2);
3447
+ }).onRequest(methods3.agent.initialize, ({ params }) => atomicAgent2.initialize(params)).onRequest(methods3.agent.authenticate, ({ params }) => atomicAgent2.authenticate(params)).onRequest(methods3.agent.session.new, ({ params }) => atomicAgent2.newSession(params)).onRequest(methods3.agent.session.load, ({ params }) => atomicAgent2.loadSession(params)).onRequest(methods3.agent.session.list, ({ params }) => atomicAgent2.listSessions(params)).onRequest(methods3.agent.session.delete, ({ params }) => atomicAgent2.deleteSession(params)).onRequest(methods3.agent.session.setMode, ({ params }) => atomicAgent2.setSessionMode(params)).onRequest(methods3.agent.session.setConfigOption, ({ params }) => atomicAgent2.setSessionConfigOption(params)).onRequest(methods3.agent.session.prompt, ({ params }) => atomicAgent2.prompt(params)).onNotification(methods3.agent.session.cancel, ({ params }) => atomicAgent2.cancel(params));
3448
+ }
3367
3449
  function startPendingRecovery(proc) {
3368
3450
  void proc.startPendingRecovery("resume").catch(() => {
3369
3451
  });
@@ -3421,11 +3503,14 @@ async function getSessionConfiguration(proc, pre) {
3421
3503
  }
3422
3504
  async function emitConfigOptionsUpdate(conn, sessionId, proc) {
3423
3505
  const { configOptions, modes } = await getSessionConfiguration(proc);
3424
- await conn.sessionUpdate({
3506
+ await conn.notify(methods3.client.session.update, {
3425
3507
  sessionId,
3426
3508
  update: { sessionUpdate: "current_mode_update", currentModeId: modes.currentModeId }
3427
3509
  });
3428
- await conn.sessionUpdate({ sessionId, update: { sessionUpdate: "config_option_update", configOptions } });
3510
+ await conn.notify(methods3.client.session.update, {
3511
+ sessionId,
3512
+ update: { sessionUpdate: "config_option_update", configOptions }
3513
+ });
3429
3514
  return configOptions;
3430
3515
  }
3431
3516
  async function setSessionModel(proc, requestedModelId) {
@@ -3756,11 +3841,11 @@ var output = new ReadableStream({
3756
3841
  }
3757
3842
  });
3758
3843
  var stream = ndJsonStream(input, output);
3759
- var agent = new AgentSideConnection((conn) => new AtomicAcpAgent(conn), stream);
3844
+ var atomicAgent;
3845
+ atomicAcpApp((created) => atomicAgent = created).connect(stream);
3760
3846
  function shutdown() {
3761
3847
  try {
3762
- ;
3763
- agent?.agent?.dispose?.();
3848
+ atomicAgent?.dispose();
3764
3849
  } catch {
3765
3850
  }
3766
3851
  try {