@bastani/atomic-acp 0.0.13 → 0.0.15

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";
@@ -313,6 +382,23 @@ function parseAtomicExtraArgs(argv, env) {
313
382
  const fromArgv = separator < 0 ? [] : argv.slice(separator + 1).map((arg) => validateAtomicArg(arg, "arguments after --"));
314
383
  return [...fromEnv, ...fromArgv];
315
384
  }
385
+ var EXCLUDE_TOOLS_FLAGS = /* @__PURE__ */ new Set(["--exclude-tools", "-xt"]);
386
+ function withExcludedTool(extraArgs, tool) {
387
+ const args = [...extraArgs];
388
+ const joined = (list) => list.split(",").includes(tool) ? list : list ? `${list},${tool}` : tool;
389
+ for (let index = args.length - 1; index >= 0; index--) {
390
+ const arg = args[index];
391
+ if (arg.startsWith("--exclude-tools=")) {
392
+ args[index] = `--exclude-tools=${joined(arg.slice("--exclude-tools=".length))}`;
393
+ return args;
394
+ }
395
+ if (EXCLUDE_TOOLS_FLAGS.has(arg) && index + 1 < args.length) {
396
+ args[index + 1] = joined(args[index + 1]);
397
+ return args;
398
+ }
399
+ }
400
+ return [...args, "--exclude-tools", tool];
401
+ }
316
402
 
317
403
  // src/atomic-rpc/adapter-extension.ts
318
404
  import { randomBytes } from "crypto";
@@ -506,7 +592,7 @@ var AtomicRpcProcess = class _AtomicRpcProcess {
506
592
  ...params.headless ? { askUserQuestionUnavailable: NO_PERSON_FOR_ASK_USER_QUESTION } : {}
507
593
  });
508
594
  if (adapterExtension) args.push("-e", adapterExtension.path);
509
- args.push(...extraArgs);
595
+ args.push(...params.headless ? withExcludedTool(extraArgs, "ask_user_question") : extraArgs);
510
596
  const start = shouldUseShellForAtomicCommand(cmd) ? crossSpawn : spawn;
511
597
  let child;
512
598
  try {
@@ -561,6 +647,9 @@ var AtomicRpcProcess = class _AtomicRpcProcess {
561
647
  await proc.getState();
562
648
  } catch {
563
649
  }
650
+ if (params.answersQuestionnaires && !params.headless) {
651
+ await proc.request({ type: "set_extension_ui_capabilities", questionnaire: true }).catch(() => void 0);
652
+ }
564
653
  return proc;
565
654
  }
566
655
  /** Whether the Atomic process has exited. A session whose Atomic exited needs a new process. */
@@ -1181,8 +1270,9 @@ function toAtomicMcpServers(servers) {
1181
1270
  exposure: "direct"
1182
1271
  });
1183
1272
  } 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`);
1273
+ const other = server;
1274
+ const type = "type" in other ? String(other.type) : "unknown";
1275
+ warnings.push(`MCP server "${other.name}" skipped: Atomic does not support the ${type} transport`);
1186
1276
  }
1187
1277
  }
1188
1278
  return { servers: Object.fromEntries(out), warnings };
@@ -1340,7 +1430,8 @@ var SessionManager = class {
1340
1430
  cwd: params.cwd,
1341
1431
  atomicCommand: params.atomicCommand,
1342
1432
  mcpServers: atomicMcpServersForSpawn(params.mcpServers),
1343
- headless: params.headless
1433
+ headless: params.headless,
1434
+ answersQuestionnaires: params.clientElicitationSupport?.form === true
1344
1435
  });
1345
1436
  } catch (e) {
1346
1437
  if (e instanceof AtomicRpcSpawnError) {
@@ -1572,7 +1663,7 @@ var AtomicAcpSession = class {
1572
1663
  }
1573
1664
  emit(update) {
1574
1665
  this.lastEmit = this.lastEmit.then(
1575
- () => this.conn.sessionUpdate({
1666
+ () => this.conn.notify(methods2.client.session.update, {
1576
1667
  sessionId: this.sessionId,
1577
1668
  update
1578
1669
  })
@@ -1752,7 +1843,7 @@ var AtomicAcpSession = class {
1752
1843
  });
1753
1844
  return;
1754
1845
  }
1755
- if (!["select", "confirm", "input", "editor"].includes(String(method))) return;
1846
+ if (!["select", "confirm", "input", "editor", "questionnaire"].includes(String(method))) return;
1756
1847
  if (this.pendingExtensionDialogs.has(id)) return;
1757
1848
  const question = typeof ev.title === "string" && ev.title ? ev.title : `Atomic ${method}`;
1758
1849
  const noPersonAvailable = () => this.emitAgentText(`No person is available to answer "${question}", so Atomic was told it was cancelled.`);
@@ -2592,7 +2683,8 @@ var AtomicAcpAgent = class {
2592
2683
  sessionId,
2593
2684
  atomicCommand: process.env.ATOMIC_ACP_ATOMIC_COMMAND,
2594
2685
  mcpServers: atomicMcpServersForSpawn(mcpServers),
2595
- headless: isHeadlessFromEnv()
2686
+ headless: isHeadlessFromEnv(),
2687
+ answersQuestionnaires: this.clientElicitationSupport.form
2596
2688
  });
2597
2689
  } catch (error) {
2598
2690
  if (error instanceof AtomicRpcSpawnError) throw RequestError4.internalError({ code: error.code }, error.message);
@@ -2762,7 +2854,7 @@ var AtomicAcpAgent = class {
2762
2854
  enableSkillCommands,
2763
2855
  includeExtensionCommands: true
2764
2856
  });
2765
- await this.conn.sessionUpdate({
2857
+ await this.conn.notify(methods3.client.session.update, {
2766
2858
  sessionId: session.sessionId,
2767
2859
  update: {
2768
2860
  sessionUpdate: "available_commands_update",
@@ -2772,7 +2864,7 @@ var AtomicAcpAgent = class {
2772
2864
  return;
2773
2865
  } catch {
2774
2866
  }
2775
- await this.conn.sessionUpdate({
2867
+ await this.conn.notify(methods3.client.session.update, {
2776
2868
  sessionId: session.sessionId,
2777
2869
  update: {
2778
2870
  sessionUpdate: "available_commands_update",
@@ -2807,7 +2899,7 @@ var AtomicAcpAgent = class {
2807
2899
  text = `Could not read workflow history: ${error instanceof Error ? error.message : String(error)}`;
2808
2900
  }
2809
2901
  }
2810
- await this.conn.sessionUpdate({
2902
+ await this.conn.notify(methods3.client.session.update, {
2811
2903
  sessionId: session.sessionId,
2812
2904
  update: {
2813
2905
  sessionUpdate: "agent_message_chunk",
@@ -2829,7 +2921,7 @@ var AtomicAcpAgent = class {
2829
2921
  const text = headerLines.join("\n") + (summary ? `
2830
2922
 
2831
2923
  ${summary}` : "");
2832
- await this.conn.sessionUpdate({
2924
+ await this.conn.notify(methods3.client.session.update, {
2833
2925
  sessionId: session.sessionId,
2834
2926
  update: {
2835
2927
  sessionUpdate: "agent_message_chunk",
@@ -2857,7 +2949,7 @@ ${summary}` : "");
2857
2949
  }
2858
2950
  const text = lines.length ? lines.join("\n") : `Session stats:
2859
2951
  ${JSON.stringify(stats, null, 2)}`;
2860
- await this.conn.sessionUpdate({
2952
+ await this.conn.notify(methods3.client.session.update, {
2861
2953
  sessionId: session.sessionId,
2862
2954
  update: {
2863
2955
  sessionUpdate: "agent_message_chunk",
@@ -2869,7 +2961,7 @@ ${JSON.stringify(stats, null, 2)}`;
2869
2961
  if (cmd === "name") {
2870
2962
  const name = args.join(" ").trim();
2871
2963
  if (!name) {
2872
- await this.conn.sessionUpdate({
2964
+ await this.conn.notify(methods3.client.session.update, {
2873
2965
  sessionId: session.sessionId,
2874
2966
  update: {
2875
2967
  sessionUpdate: "agent_message_chunk",
@@ -2883,7 +2975,7 @@ ${JSON.stringify(stats, null, 2)}`;
2883
2975
  } catch (e) {
2884
2976
  const msg = String(e?.message ?? e);
2885
2977
  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({
2978
+ await this.conn.notify(methods3.client.session.update, {
2887
2979
  sessionId: session.sessionId,
2888
2980
  update: {
2889
2981
  sessionUpdate: "agent_message_chunk",
@@ -2892,7 +2984,7 @@ ${JSON.stringify(stats, null, 2)}`;
2892
2984
  });
2893
2985
  return { stopReason: "end_turn" };
2894
2986
  }
2895
- await this.conn.sessionUpdate({
2987
+ await this.conn.notify(methods3.client.session.update, {
2896
2988
  sessionId: session.sessionId,
2897
2989
  update: {
2898
2990
  sessionUpdate: "agent_message_chunk",
@@ -2906,7 +2998,7 @@ ${JSON.stringify(stats, null, 2)}`;
2906
2998
  const state = await session.proc.getState();
2907
2999
  const current = String(state?.steeringMode ?? "");
2908
3000
  if (!modeRaw) {
2909
- await this.conn.sessionUpdate({
3001
+ await this.conn.notify(methods3.client.session.update, {
2910
3002
  sessionId: session.sessionId,
2911
3003
  update: {
2912
3004
  sessionUpdate: "agent_message_chunk",
@@ -2919,7 +3011,7 @@ ${JSON.stringify(stats, null, 2)}`;
2919
3011
  return { stopReason: "end_turn" };
2920
3012
  }
2921
3013
  if (modeRaw !== "all" && modeRaw !== "one-at-a-time") {
2922
- await this.conn.sessionUpdate({
3014
+ await this.conn.notify(methods3.client.session.update, {
2923
3015
  sessionId: session.sessionId,
2924
3016
  update: {
2925
3017
  sessionUpdate: "agent_message_chunk",
@@ -2932,7 +3024,7 @@ ${JSON.stringify(stats, null, 2)}`;
2932
3024
  return { stopReason: "end_turn" };
2933
3025
  }
2934
3026
  await session.proc.setSteeringMode(modeRaw);
2935
- await this.conn.sessionUpdate({
3027
+ await this.conn.notify(methods3.client.session.update, {
2936
3028
  sessionId: session.sessionId,
2937
3029
  update: {
2938
3030
  sessionUpdate: "agent_message_chunk",
@@ -2946,7 +3038,7 @@ ${JSON.stringify(stats, null, 2)}`;
2946
3038
  const state = await session.proc.getState();
2947
3039
  const current = String(state?.followUpMode ?? "");
2948
3040
  if (!modeRaw) {
2949
- await this.conn.sessionUpdate({
3041
+ await this.conn.notify(methods3.client.session.update, {
2950
3042
  sessionId: session.sessionId,
2951
3043
  update: {
2952
3044
  sessionUpdate: "agent_message_chunk",
@@ -2959,7 +3051,7 @@ ${JSON.stringify(stats, null, 2)}`;
2959
3051
  return { stopReason: "end_turn" };
2960
3052
  }
2961
3053
  if (modeRaw !== "all" && modeRaw !== "one-at-a-time") {
2962
- await this.conn.sessionUpdate({
3054
+ await this.conn.notify(methods3.client.session.update, {
2963
3055
  sessionId: session.sessionId,
2964
3056
  update: {
2965
3057
  sessionUpdate: "agent_message_chunk",
@@ -2972,7 +3064,7 @@ ${JSON.stringify(stats, null, 2)}`;
2972
3064
  return { stopReason: "end_turn" };
2973
3065
  }
2974
3066
  await session.proc.setFollowUpMode(modeRaw);
2975
- await this.conn.sessionUpdate({
3067
+ await this.conn.notify(methods3.client.session.update, {
2976
3068
  sessionId: session.sessionId,
2977
3069
  update: {
2978
3070
  sessionUpdate: "agent_message_chunk",
@@ -3006,7 +3098,7 @@ ${JSON.stringify(stats, null, 2)}`;
3006
3098
  };
3007
3099
  const changelogPath = findChangelog();
3008
3100
  if (!changelogPath) {
3009
- await this.conn.sessionUpdate({
3101
+ await this.conn.notify(methods3.client.session.update, {
3010
3102
  sessionId: session.sessionId,
3011
3103
  update: {
3012
3104
  sessionUpdate: "agent_message_chunk",
@@ -3019,7 +3111,7 @@ ${JSON.stringify(stats, null, 2)}`;
3019
3111
  try {
3020
3112
  text = readFileSync5(changelogPath, "utf-8");
3021
3113
  } catch (e) {
3022
- await this.conn.sessionUpdate({
3114
+ await this.conn.notify(methods3.client.session.update, {
3023
3115
  sessionId: session.sessionId,
3024
3116
  update: {
3025
3117
  sessionUpdate: "agent_message_chunk",
@@ -3030,7 +3122,7 @@ ${JSON.stringify(stats, null, 2)}`;
3030
3122
  }
3031
3123
  const maxChars = 2e4;
3032
3124
  if (text.length > maxChars) text = text.slice(0, maxChars) + "\n\n...(truncated)...";
3033
- await this.conn.sessionUpdate({
3125
+ await this.conn.notify(methods3.client.session.update, {
3034
3126
  sessionId: session.sessionId,
3035
3127
  update: {
3036
3128
  sessionUpdate: "agent_message_chunk",
@@ -3043,7 +3135,7 @@ ${JSON.stringify(stats, null, 2)}`;
3043
3135
  const state = await session.proc.getState();
3044
3136
  const messageCount = typeof state?.messageCount === "number" ? state.messageCount : 0;
3045
3137
  if (messageCount === 0) {
3046
- await this.conn.sessionUpdate({
3138
+ await this.conn.notify(methods3.client.session.update, {
3047
3139
  sessionId: session.sessionId,
3048
3140
  update: {
3049
3141
  sessionUpdate: "agent_message_chunk",
@@ -3059,7 +3151,7 @@ ${JSON.stringify(stats, null, 2)}`;
3059
3151
  const result = await session.proc.exportHtml(outputPath);
3060
3152
  resultPath = result.path;
3061
3153
  } catch (e) {
3062
- await this.conn.sessionUpdate({
3154
+ await this.conn.notify(methods3.client.session.update, {
3063
3155
  sessionId: session.sessionId,
3064
3156
  update: {
3065
3157
  sessionUpdate: "agent_message_chunk",
@@ -3072,7 +3164,7 @@ ${JSON.stringify(stats, null, 2)}`;
3072
3164
  return { stopReason: "end_turn" };
3073
3165
  }
3074
3166
  if (!resultPath) {
3075
- await this.conn.sessionUpdate({
3167
+ await this.conn.notify(methods3.client.session.update, {
3076
3168
  sessionId: session.sessionId,
3077
3169
  update: {
3078
3170
  sessionUpdate: "agent_message_chunk",
@@ -3085,7 +3177,7 @@ ${JSON.stringify(stats, null, 2)}`;
3085
3177
  return { stopReason: "end_turn" };
3086
3178
  }
3087
3179
  const uri = `file://${resultPath}`;
3088
- await this.conn.sessionUpdate({
3180
+ await this.conn.notify(methods3.client.session.update, {
3089
3181
  sessionId: session.sessionId,
3090
3182
  update: {
3091
3183
  sessionUpdate: "agent_message_chunk",
@@ -3095,7 +3187,7 @@ ${JSON.stringify(stats, null, 2)}`;
3095
3187
  }
3096
3188
  }
3097
3189
  });
3098
- await this.conn.sessionUpdate({
3190
+ await this.conn.notify(methods3.client.session.update, {
3099
3191
  sessionId: session.sessionId,
3100
3192
  update: {
3101
3193
  sessionUpdate: "agent_message_chunk",
@@ -3121,7 +3213,7 @@ ${JSON.stringify(stats, null, 2)}`;
3121
3213
  enabled = !current;
3122
3214
  }
3123
3215
  await session.proc.setAutoCompaction(enabled);
3124
- await this.conn.sessionUpdate({
3216
+ await this.conn.notify(methods3.client.session.update, {
3125
3217
  sessionId: session.sessionId,
3126
3218
  update: {
3127
3219
  sessionUpdate: "agent_message_chunk",
@@ -3207,7 +3299,7 @@ ${JSON.stringify(stats, null, 2)}`;
3207
3299
  if (role === "user") {
3208
3300
  const text = normalizeAtomicMessageText(m?.content);
3209
3301
  if (text) {
3210
- await this.conn.sessionUpdate({
3302
+ await this.conn.notify(methods3.client.session.update, {
3211
3303
  sessionId: session.sessionId,
3212
3304
  update: {
3213
3305
  sessionUpdate: "user_message_chunk",
@@ -3219,7 +3311,7 @@ ${JSON.stringify(stats, null, 2)}`;
3219
3311
  if (role === "assistant") {
3220
3312
  const text = normalizeAtomicAssistantText(m?.content);
3221
3313
  if (text) {
3222
- await this.conn.sessionUpdate({
3314
+ await this.conn.notify(methods3.client.session.update, {
3223
3315
  sessionId: session.sessionId,
3224
3316
  update: {
3225
3317
  sessionUpdate: "agent_message_chunk",
@@ -3234,7 +3326,7 @@ ${JSON.stringify(stats, null, 2)}`;
3234
3326
  const isError = Boolean(m?.isError);
3235
3327
  if (isBashTool(toolName)) {
3236
3328
  const text2 = bashResultText(m);
3237
- await this.conn.sessionUpdate({
3329
+ await this.conn.notify(methods3.client.session.update, {
3238
3330
  sessionId: session.sessionId,
3239
3331
  update: {
3240
3332
  sessionUpdate: "tool_call",
@@ -3246,7 +3338,7 @@ ${JSON.stringify(stats, null, 2)}`;
3246
3338
  _meta: bashTerminalInfoMeta(toolCallId, params.cwd)
3247
3339
  }
3248
3340
  });
3249
- await this.conn.sessionUpdate({
3341
+ await this.conn.notify(methods3.client.session.update, {
3250
3342
  sessionId: session.sessionId,
3251
3343
  update: {
3252
3344
  sessionUpdate: "tool_call_update",
@@ -3260,7 +3352,7 @@ ${JSON.stringify(stats, null, 2)}`;
3260
3352
  });
3261
3353
  continue;
3262
3354
  }
3263
- await this.conn.sessionUpdate({
3355
+ await this.conn.notify(methods3.client.session.update, {
3264
3356
  sessionId: session.sessionId,
3265
3357
  update: {
3266
3358
  sessionUpdate: "tool_call",
@@ -3273,7 +3365,7 @@ ${JSON.stringify(stats, null, 2)}`;
3273
3365
  }
3274
3366
  });
3275
3367
  const text = toolResultToText(m);
3276
- await this.conn.sessionUpdate({
3368
+ await this.conn.notify(methods3.client.session.update, {
3277
3369
  sessionId: session.sessionId,
3278
3370
  update: {
3279
3371
  sessionUpdate: "tool_call_update",
@@ -3304,7 +3396,7 @@ ${JSON.stringify(stats, null, 2)}`;
3304
3396
  enableSkillCommands,
3305
3397
  includeExtensionCommands: true
3306
3398
  });
3307
- await this.conn.sessionUpdate({
3399
+ await this.conn.notify(methods3.client.session.update, {
3308
3400
  sessionId: session.sessionId,
3309
3401
  update: {
3310
3402
  sessionUpdate: "available_commands_update",
@@ -3314,7 +3406,7 @@ ${JSON.stringify(stats, null, 2)}`;
3314
3406
  return;
3315
3407
  } catch {
3316
3408
  }
3317
- await this.conn.sessionUpdate({
3409
+ await this.conn.notify(methods3.client.session.update, {
3318
3410
  sessionId: session.sessionId,
3319
3411
  update: {
3320
3412
  sessionUpdate: "available_commands_update",
@@ -3364,6 +3456,13 @@ ${JSON.stringify(stats, null, 2)}`;
3364
3456
  return { configOptions };
3365
3457
  }
3366
3458
  };
3459
+ function atomicAcpApp(onAgent) {
3460
+ let atomicAgent2;
3461
+ return agent({ name: "atomic-acp" }).onConnect((connection) => {
3462
+ atomicAgent2 = new AtomicAcpAgent(connection.client);
3463
+ onAgent?.(atomicAgent2);
3464
+ }).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));
3465
+ }
3367
3466
  function startPendingRecovery(proc) {
3368
3467
  void proc.startPendingRecovery("resume").catch(() => {
3369
3468
  });
@@ -3421,11 +3520,14 @@ async function getSessionConfiguration(proc, pre) {
3421
3520
  }
3422
3521
  async function emitConfigOptionsUpdate(conn, sessionId, proc) {
3423
3522
  const { configOptions, modes } = await getSessionConfiguration(proc);
3424
- await conn.sessionUpdate({
3523
+ await conn.notify(methods3.client.session.update, {
3425
3524
  sessionId,
3426
3525
  update: { sessionUpdate: "current_mode_update", currentModeId: modes.currentModeId }
3427
3526
  });
3428
- await conn.sessionUpdate({ sessionId, update: { sessionUpdate: "config_option_update", configOptions } });
3527
+ await conn.notify(methods3.client.session.update, {
3528
+ sessionId,
3529
+ update: { sessionUpdate: "config_option_update", configOptions }
3530
+ });
3429
3531
  return configOptions;
3430
3532
  }
3431
3533
  async function setSessionModel(proc, requestedModelId) {
@@ -3756,11 +3858,11 @@ var output = new ReadableStream({
3756
3858
  }
3757
3859
  });
3758
3860
  var stream = ndJsonStream(input, output);
3759
- var agent = new AgentSideConnection((conn) => new AtomicAcpAgent(conn), stream);
3861
+ var atomicAgent;
3862
+ atomicAcpApp((created) => atomicAgent = created).connect(stream);
3760
3863
  function shutdown() {
3761
3864
  try {
3762
- ;
3763
- agent?.agent?.dispose?.();
3865
+ atomicAgent?.dispose();
3764
3866
  } catch {
3765
3867
  }
3766
3868
  try {