@yitom/acp-client 0.1.2 → 0.1.3

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
@@ -99,6 +99,20 @@ await client.disconnect()
99
99
 
100
100
  ---
101
101
 
102
+ ## ⌨️ 斜杠命令(available_commands_update)
103
+
104
+ Agent 推送的 `available_commands_update` 会原样经 `onSessionUpdate` 透传,同时按会话缓存最新列表(含 `name` / `description` / `input.hint`),
105
+ 即使宿主还没拿到 sessionId 也不会丢:
106
+
107
+ ```ts
108
+ const handle = (await client.createSession()).value
109
+ const cmds = handle.availableCommands ?? (await client.waitForAvailableCommands(handle.sessionId, 500))
110
+ // 调用命令 = 普通文本 prompt(ACP 规范)
111
+ await handle.prompt(formatCommandPrompt('review', 'main')) // "/review main"
112
+ ```
113
+
114
+ Sidecar:`session/open` 结果带 `availableCommands`(若已收到),并新增 `session/commands` 查询方法。
115
+
102
116
  ## 📦 打包构建
103
117
 
104
118
  在本包根目录一键构建生成 `dist`(ESM / CJS / `.d.ts`):
@@ -1,3 +1,4 @@
1
+ import { type AcpAvailableCommand } from '../session/available-commands';
1
2
  import { type InitializeResponse } from '@agentclientprotocol/sdk';
2
3
  import type { AcpConnectionStatus, AcpPermissionOutcome, AcpProxySettings, AcpRuntimeInfo, AcpSessionRestoreMethod, AppError, InkdownVirtualResource } from "../contracts";
3
4
  import { type Result } from "../contracts";
@@ -56,6 +57,8 @@ export declare class AcpSessionHandle {
56
57
  data: string;
57
58
  }>;
58
59
  }): Promise<Result<unknown, AppError>>;
60
+ /** Agent 通过 available_commands_update 提供的斜杠命令(调用 = prompt 发送 `/name args` 文本) */
61
+ get availableCommands(): AcpAvailableCommand[] | undefined;
59
62
  /** 修改会话配置项(如模型 ID、模式等) */
60
63
  setConfigOption(configId: string, value: string | boolean): Promise<Result<unknown, AppError>>;
61
64
  }
@@ -68,6 +71,7 @@ export declare class AcpSessionHandle {
68
71
  */
69
72
  export declare class AcpClient {
70
73
  private status;
74
+ private readonly commandsCache;
71
75
  private runtimeInfo;
72
76
  private adapter;
73
77
  private readonly workspaceRoot;
@@ -99,6 +103,10 @@ export declare class AcpClient {
99
103
  status: AcpConnectionStatus;
100
104
  init: InitializeResponse;
101
105
  }, AppError>>;
106
+ /** 最近一次 available_commands_update 的命令列表(未收到过则为 undefined) */
107
+ getAvailableCommands(sessionId: string): AcpAvailableCommand[] | undefined;
108
+ /** 等待某会话的命令列表(已缓存则立即返回;超时返回 undefined) */
109
+ waitForAvailableCommands(sessionId: string, timeoutMs?: number): Promise<AcpAvailableCommand[] | undefined>;
102
110
  /** 创建或恢复会话 */
103
111
  createSession(options?: {
104
112
  resumeSessionId?: string | null;
package/dist/index.cjs CHANGED
@@ -46,6 +46,7 @@ __export(exports_src, {
46
46
  AcpClient: () => AcpClient,
47
47
  AcpSessionHandle: () => AcpSessionHandle,
48
48
  AcpTerminalManager: () => AcpTerminalManager,
49
+ AvailableCommandsCache: () => AvailableCommandsCache,
49
50
  BUILTIN_ACP_RUNTIMES: () => BUILTIN_ACP_RUNTIMES,
50
51
  CLAUDE_ACP_NPM_PACKAGE: () => CLAUDE_ACP_NPM_PACKAGE,
51
52
  CODEX_ACP_NPM_PACKAGE: () => CODEX_ACP_NPM_PACKAGE,
@@ -85,8 +86,10 @@ __export(exports_src, {
85
86
  disposeAllAcpProcesses: () => disposeAllAcpProcesses,
86
87
  emptyAcpAuthPreflight: () => emptyAcpAuthPreflight,
87
88
  err: () => err,
89
+ extractAvailableCommands: () => extractAvailableCommands,
88
90
  findBuiltinAcpRuntime: () => findBuiltinAcpRuntime,
89
91
  findModelConfigOption: () => findModelConfigOption,
92
+ formatCommandPrompt: () => formatCommandPrompt,
90
93
  geminiAdapter: () => geminiAdapter,
91
94
  getAcpEarlyExitStderrDetail: () => getAcpEarlyExitStderrDetail,
92
95
  getAcpProviderCodexHome: () => getAcpProviderCodexHome,
@@ -313,6 +316,94 @@ var BUILTIN_ACP_RUNTIMES = [
313
316
  function findBuiltinAcpRuntime(id) {
314
317
  return BUILTIN_ACP_RUNTIMES.find((item) => item.id === id);
315
318
  }
319
+ // src/session/available-commands.ts
320
+ function normalizeCommand(raw) {
321
+ if (!raw || typeof raw !== "object")
322
+ return null;
323
+ const r = raw;
324
+ if (typeof r.name !== "string" || !r.name.trim())
325
+ return null;
326
+ const out = {
327
+ name: r.name.trim(),
328
+ description: typeof r.description === "string" ? r.description : ""
329
+ };
330
+ const input = r.input;
331
+ if (input && typeof input === "object" && typeof input.hint === "string") {
332
+ out.input = { hint: input.hint };
333
+ }
334
+ if (r._meta && typeof r._meta === "object")
335
+ out._meta = r._meta;
336
+ return out;
337
+ }
338
+ function extractAvailableCommands(params) {
339
+ if (!params || typeof params !== "object")
340
+ return null;
341
+ const p = params;
342
+ if (typeof p.sessionId !== "string" || !p.update)
343
+ return null;
344
+ if (p.update.sessionUpdate !== "available_commands_update")
345
+ return null;
346
+ const list = Array.isArray(p.update.availableCommands) ? p.update.availableCommands : [];
347
+ const commands = list.map(normalizeCommand).filter((c) => c !== null);
348
+ return { sessionId: p.sessionId, commands };
349
+ }
350
+ function formatCommandPrompt(name, args) {
351
+ const n = name.replace(/^\//, "");
352
+ const a = (args ?? "").trim();
353
+ return a ? `/${n} ${a}` : `/${n}`;
354
+ }
355
+
356
+ class AvailableCommandsCache {
357
+ bySession = new Map;
358
+ waiters = new Map;
359
+ observe(params) {
360
+ const hit = extractAvailableCommands(params);
361
+ if (!hit)
362
+ return false;
363
+ this.bySession.set(hit.sessionId, hit.commands);
364
+ const ws = this.waiters.get(hit.sessionId);
365
+ if (ws) {
366
+ this.waiters.delete(hit.sessionId);
367
+ for (const w of ws)
368
+ w(hit.commands);
369
+ }
370
+ return true;
371
+ }
372
+ get(sessionId) {
373
+ return this.bySession.get(sessionId);
374
+ }
375
+ wait(sessionId, timeoutMs = 150) {
376
+ const cur = this.bySession.get(sessionId);
377
+ if (cur || timeoutMs <= 0)
378
+ return Promise.resolve(cur);
379
+ return new Promise((resolve) => {
380
+ const done = (c) => {
381
+ clearTimeout(timer);
382
+ const list = this.waiters.get(sessionId);
383
+ if (list) {
384
+ const i = list.indexOf(fn);
385
+ if (i >= 0)
386
+ list.splice(i, 1);
387
+ if (list.length === 0)
388
+ this.waiters.delete(sessionId);
389
+ }
390
+ resolve(c);
391
+ };
392
+ const fn = (c) => done(c);
393
+ const timer = setTimeout(() => done(undefined), timeoutMs);
394
+ const list = this.waiters.get(sessionId) ?? [];
395
+ list.push(fn);
396
+ this.waiters.set(sessionId, list);
397
+ });
398
+ }
399
+ delete(sessionId) {
400
+ this.bySession.delete(sessionId);
401
+ }
402
+ clear() {
403
+ this.bySession.clear();
404
+ }
405
+ }
406
+
316
407
  // src/client/acp-client.ts
317
408
  var import_sdk4 = require("@agentclientprotocol/sdk");
318
409
 
@@ -2144,6 +2235,9 @@ class AcpSessionHandle {
2144
2235
  async prompt(promptText, options) {
2145
2236
  return this.client.promptSession(this.sessionId, promptText, options);
2146
2237
  }
2238
+ get availableCommands() {
2239
+ return this.client.getAvailableCommands(this.sessionId);
2240
+ }
2147
2241
  async setConfigOption(configId, value) {
2148
2242
  return this.client.setSessionConfigOption(this.sessionId, configId, value);
2149
2243
  }
@@ -2151,6 +2245,7 @@ class AcpSessionHandle {
2151
2245
 
2152
2246
  class AcpClient {
2153
2247
  status = "disconnected";
2248
+ commandsCache = new AvailableCommandsCache;
2154
2249
  runtimeInfo;
2155
2250
  adapter;
2156
2251
  workspaceRoot;
@@ -2260,6 +2355,7 @@ class AcpClient {
2260
2355
  return { outcome: "cancelled" };
2261
2356
  },
2262
2357
  onSessionUpdate: (params) => {
2358
+ this.commandsCache.observe(params);
2263
2359
  this.callbacks.onSessionUpdate?.(params);
2264
2360
  }
2265
2361
  };
@@ -2290,6 +2386,12 @@ class AcpClient {
2290
2386
  return err({ code: "ACP_PROTOCOL_ERROR", message });
2291
2387
  }
2292
2388
  }
2389
+ getAvailableCommands(sessionId) {
2390
+ return this.commandsCache.get(sessionId);
2391
+ }
2392
+ waitForAvailableCommands(sessionId, timeoutMs = 150) {
2393
+ return this.commandsCache.wait(sessionId, timeoutMs);
2394
+ }
2293
2395
  async createSession(options) {
2294
2396
  if (!this.sdkConnection?.agent) {
2295
2397
  return err({ code: "ACP_NOT_CONNECTED", message: "尚未连接到 Agent 服务端" });
package/dist/index.d.ts CHANGED
@@ -28,6 +28,7 @@ export * from "./auth/connect-auth-gate";
28
28
  export * from "./session/agent-registry";
29
29
  export * from "./session/config-options";
30
30
  export * from "./session/session-capabilities";
31
+ export * from "./session/available-commands";
31
32
  export * from "./mcp/inkdown-mcp-tools";
32
33
  export * from "./mcp/inkdown-mcp-toc-tools";
33
34
  export * from "./mcp/inkdown-mcp-rpc";
package/dist/index.js CHANGED
@@ -148,6 +148,94 @@ var BUILTIN_ACP_RUNTIMES = [
148
148
  function findBuiltinAcpRuntime(id) {
149
149
  return BUILTIN_ACP_RUNTIMES.find((item) => item.id === id);
150
150
  }
151
+ // src/session/available-commands.ts
152
+ function normalizeCommand(raw) {
153
+ if (!raw || typeof raw !== "object")
154
+ return null;
155
+ const r = raw;
156
+ if (typeof r.name !== "string" || !r.name.trim())
157
+ return null;
158
+ const out = {
159
+ name: r.name.trim(),
160
+ description: typeof r.description === "string" ? r.description : ""
161
+ };
162
+ const input = r.input;
163
+ if (input && typeof input === "object" && typeof input.hint === "string") {
164
+ out.input = { hint: input.hint };
165
+ }
166
+ if (r._meta && typeof r._meta === "object")
167
+ out._meta = r._meta;
168
+ return out;
169
+ }
170
+ function extractAvailableCommands(params) {
171
+ if (!params || typeof params !== "object")
172
+ return null;
173
+ const p = params;
174
+ if (typeof p.sessionId !== "string" || !p.update)
175
+ return null;
176
+ if (p.update.sessionUpdate !== "available_commands_update")
177
+ return null;
178
+ const list = Array.isArray(p.update.availableCommands) ? p.update.availableCommands : [];
179
+ const commands = list.map(normalizeCommand).filter((c) => c !== null);
180
+ return { sessionId: p.sessionId, commands };
181
+ }
182
+ function formatCommandPrompt(name, args) {
183
+ const n = name.replace(/^\//, "");
184
+ const a = (args ?? "").trim();
185
+ return a ? `/${n} ${a}` : `/${n}`;
186
+ }
187
+
188
+ class AvailableCommandsCache {
189
+ bySession = new Map;
190
+ waiters = new Map;
191
+ observe(params) {
192
+ const hit = extractAvailableCommands(params);
193
+ if (!hit)
194
+ return false;
195
+ this.bySession.set(hit.sessionId, hit.commands);
196
+ const ws = this.waiters.get(hit.sessionId);
197
+ if (ws) {
198
+ this.waiters.delete(hit.sessionId);
199
+ for (const w of ws)
200
+ w(hit.commands);
201
+ }
202
+ return true;
203
+ }
204
+ get(sessionId) {
205
+ return this.bySession.get(sessionId);
206
+ }
207
+ wait(sessionId, timeoutMs = 150) {
208
+ const cur = this.bySession.get(sessionId);
209
+ if (cur || timeoutMs <= 0)
210
+ return Promise.resolve(cur);
211
+ return new Promise((resolve) => {
212
+ const done = (c) => {
213
+ clearTimeout(timer);
214
+ const list = this.waiters.get(sessionId);
215
+ if (list) {
216
+ const i = list.indexOf(fn);
217
+ if (i >= 0)
218
+ list.splice(i, 1);
219
+ if (list.length === 0)
220
+ this.waiters.delete(sessionId);
221
+ }
222
+ resolve(c);
223
+ };
224
+ const fn = (c) => done(c);
225
+ const timer = setTimeout(() => done(undefined), timeoutMs);
226
+ const list = this.waiters.get(sessionId) ?? [];
227
+ list.push(fn);
228
+ this.waiters.set(sessionId, list);
229
+ });
230
+ }
231
+ delete(sessionId) {
232
+ this.bySession.delete(sessionId);
233
+ }
234
+ clear() {
235
+ this.bySession.clear();
236
+ }
237
+ }
238
+
151
239
  // src/client/acp-client.ts
152
240
  import {
153
241
  methods as methods2
@@ -1984,6 +2072,9 @@ class AcpSessionHandle {
1984
2072
  async prompt(promptText, options) {
1985
2073
  return this.client.promptSession(this.sessionId, promptText, options);
1986
2074
  }
2075
+ get availableCommands() {
2076
+ return this.client.getAvailableCommands(this.sessionId);
2077
+ }
1987
2078
  async setConfigOption(configId, value) {
1988
2079
  return this.client.setSessionConfigOption(this.sessionId, configId, value);
1989
2080
  }
@@ -1991,6 +2082,7 @@ class AcpSessionHandle {
1991
2082
 
1992
2083
  class AcpClient {
1993
2084
  status = "disconnected";
2085
+ commandsCache = new AvailableCommandsCache;
1994
2086
  runtimeInfo;
1995
2087
  adapter;
1996
2088
  workspaceRoot;
@@ -2100,6 +2192,7 @@ class AcpClient {
2100
2192
  return { outcome: "cancelled" };
2101
2193
  },
2102
2194
  onSessionUpdate: (params) => {
2195
+ this.commandsCache.observe(params);
2103
2196
  this.callbacks.onSessionUpdate?.(params);
2104
2197
  }
2105
2198
  };
@@ -2130,6 +2223,12 @@ class AcpClient {
2130
2223
  return err({ code: "ACP_PROTOCOL_ERROR", message });
2131
2224
  }
2132
2225
  }
2226
+ getAvailableCommands(sessionId) {
2227
+ return this.commandsCache.get(sessionId);
2228
+ }
2229
+ waitForAvailableCommands(sessionId, timeoutMs = 150) {
2230
+ return this.commandsCache.wait(sessionId, timeoutMs);
2231
+ }
2133
2232
  async createSession(options) {
2134
2233
  if (!this.sdkConnection?.agent) {
2135
2234
  return err({ code: "ACP_NOT_CONNECTED", message: "尚未连接到 Agent 服务端" });
@@ -3140,6 +3239,7 @@ export {
3140
3239
  AcpClient,
3141
3240
  AcpSessionHandle,
3142
3241
  AcpTerminalManager,
3242
+ AvailableCommandsCache,
3143
3243
  BUILTIN_ACP_RUNTIMES,
3144
3244
  CLAUDE_ACP_NPM_PACKAGE,
3145
3245
  CODEX_ACP_NPM_PACKAGE,
@@ -3179,8 +3279,10 @@ export {
3179
3279
  disposeAllAcpProcesses,
3180
3280
  emptyAcpAuthPreflight,
3181
3281
  err,
3282
+ extractAvailableCommands,
3182
3283
  findBuiltinAcpRuntime,
3183
3284
  findModelConfigOption,
3285
+ formatCommandPrompt,
3184
3286
  geminiAdapter,
3185
3287
  getAcpEarlyExitStderrDetail,
3186
3288
  getAcpProviderCodexHome,
@@ -0,0 +1,43 @@
1
+ /**
2
+ * ACP `available_commands_update` handling.
3
+ *
4
+ * Agents typically push their slash commands right after session/new|load|resume
5
+ * returns — i.e. before a host has learned the sessionId or wired a listener.
6
+ * Raw notifications are still forwarded untouched via `onSessionUpdate`; this
7
+ * cache additionally keeps the latest list per session so hosts can read it
8
+ * at any time (`AcpClient.getAvailableCommands`, `AcpSessionHandle.availableCommands`,
9
+ * sidecar `session/open` result + `session/commands`).
10
+ *
11
+ * Invoking a command is plain prompt text (`/name args`) per the ACP spec.
12
+ */
13
+ export interface AcpAvailableCommandInput {
14
+ /** Placeholder shown while the user types the argument. */
15
+ hint: string;
16
+ }
17
+ export interface AcpAvailableCommand {
18
+ name: string;
19
+ description: string;
20
+ input?: AcpAvailableCommandInput | null;
21
+ _meta?: Record<string, unknown>;
22
+ }
23
+ /**
24
+ * Extract `{ sessionId, commands }` from a session/update params object
25
+ * (`{ sessionId, update: { sessionUpdate: 'available_commands_update', availableCommands } }`).
26
+ */
27
+ export declare function extractAvailableCommands(params: unknown): {
28
+ sessionId: string;
29
+ commands: AcpAvailableCommand[];
30
+ } | null;
31
+ /** Build the prompt text for a command invocation (ACP: plain text `/name args`). */
32
+ export declare function formatCommandPrompt(name: string, args?: string): string;
33
+ export declare class AvailableCommandsCache {
34
+ private bySession;
35
+ private waiters;
36
+ /** Feed every session/update params object; returns true if it was a commands update. */
37
+ observe(params: unknown): boolean;
38
+ get(sessionId: string): AcpAvailableCommand[] | undefined;
39
+ /** Resolve with the cached list, or wait up to `timeoutMs` for one (undefined on timeout). */
40
+ wait(sessionId: string, timeoutMs?: number): Promise<AcpAvailableCommand[] | undefined>;
41
+ delete(sessionId: string): void;
42
+ clear(): void;
43
+ }
package/dist/sidecar.cjs CHANGED
@@ -163,6 +163,88 @@ var BUILTIN_ACP_RUNTIMES = [
163
163
  function findBuiltinAcpRuntime(id) {
164
164
  return BUILTIN_ACP_RUNTIMES.find((item) => item.id === id);
165
165
  }
166
+ // src/session/available-commands.ts
167
+ function normalizeCommand(raw) {
168
+ if (!raw || typeof raw !== "object")
169
+ return null;
170
+ const r = raw;
171
+ if (typeof r.name !== "string" || !r.name.trim())
172
+ return null;
173
+ const out = {
174
+ name: r.name.trim(),
175
+ description: typeof r.description === "string" ? r.description : ""
176
+ };
177
+ const input = r.input;
178
+ if (input && typeof input === "object" && typeof input.hint === "string") {
179
+ out.input = { hint: input.hint };
180
+ }
181
+ if (r._meta && typeof r._meta === "object")
182
+ out._meta = r._meta;
183
+ return out;
184
+ }
185
+ function extractAvailableCommands(params) {
186
+ if (!params || typeof params !== "object")
187
+ return null;
188
+ const p = params;
189
+ if (typeof p.sessionId !== "string" || !p.update)
190
+ return null;
191
+ if (p.update.sessionUpdate !== "available_commands_update")
192
+ return null;
193
+ const list = Array.isArray(p.update.availableCommands) ? p.update.availableCommands : [];
194
+ const commands = list.map(normalizeCommand).filter((c) => c !== null);
195
+ return { sessionId: p.sessionId, commands };
196
+ }
197
+ class AvailableCommandsCache {
198
+ bySession = new Map;
199
+ waiters = new Map;
200
+ observe(params) {
201
+ const hit = extractAvailableCommands(params);
202
+ if (!hit)
203
+ return false;
204
+ this.bySession.set(hit.sessionId, hit.commands);
205
+ const ws = this.waiters.get(hit.sessionId);
206
+ if (ws) {
207
+ this.waiters.delete(hit.sessionId);
208
+ for (const w of ws)
209
+ w(hit.commands);
210
+ }
211
+ return true;
212
+ }
213
+ get(sessionId) {
214
+ return this.bySession.get(sessionId);
215
+ }
216
+ wait(sessionId, timeoutMs = 150) {
217
+ const cur = this.bySession.get(sessionId);
218
+ if (cur || timeoutMs <= 0)
219
+ return Promise.resolve(cur);
220
+ return new Promise((resolve) => {
221
+ const done = (c) => {
222
+ clearTimeout(timer);
223
+ const list = this.waiters.get(sessionId);
224
+ if (list) {
225
+ const i = list.indexOf(fn);
226
+ if (i >= 0)
227
+ list.splice(i, 1);
228
+ if (list.length === 0)
229
+ this.waiters.delete(sessionId);
230
+ }
231
+ resolve(c);
232
+ };
233
+ const fn = (c) => done(c);
234
+ const timer = setTimeout(() => done(undefined), timeoutMs);
235
+ const list = this.waiters.get(sessionId) ?? [];
236
+ list.push(fn);
237
+ this.waiters.set(sessionId, list);
238
+ });
239
+ }
240
+ delete(sessionId) {
241
+ this.bySession.delete(sessionId);
242
+ }
243
+ clear() {
244
+ this.bySession.clear();
245
+ }
246
+ }
247
+
166
248
  // node_modules/@agentclientprotocol/sdk/dist/schema/index.js
167
249
  var AGENT_METHODS = {
168
250
  initialize: "initialize",
@@ -11615,6 +11697,9 @@ class AcpSessionHandle {
11615
11697
  async prompt(promptText, options) {
11616
11698
  return this.client.promptSession(this.sessionId, promptText, options);
11617
11699
  }
11700
+ get availableCommands() {
11701
+ return this.client.getAvailableCommands(this.sessionId);
11702
+ }
11618
11703
  async setConfigOption(configId, value) {
11619
11704
  return this.client.setSessionConfigOption(this.sessionId, configId, value);
11620
11705
  }
@@ -11622,6 +11707,7 @@ class AcpSessionHandle {
11622
11707
 
11623
11708
  class AcpClient {
11624
11709
  status = "disconnected";
11710
+ commandsCache = new AvailableCommandsCache;
11625
11711
  runtimeInfo;
11626
11712
  adapter;
11627
11713
  workspaceRoot;
@@ -11731,6 +11817,7 @@ class AcpClient {
11731
11817
  return { outcome: "cancelled" };
11732
11818
  },
11733
11819
  onSessionUpdate: (params) => {
11820
+ this.commandsCache.observe(params);
11734
11821
  this.callbacks.onSessionUpdate?.(params);
11735
11822
  }
11736
11823
  };
@@ -11761,6 +11848,12 @@ class AcpClient {
11761
11848
  return err({ code: "ACP_PROTOCOL_ERROR", message });
11762
11849
  }
11763
11850
  }
11851
+ getAvailableCommands(sessionId) {
11852
+ return this.commandsCache.get(sessionId);
11853
+ }
11854
+ waitForAvailableCommands(sessionId, timeoutMs = 150) {
11855
+ return this.commandsCache.wait(sessionId, timeoutMs);
11856
+ }
11764
11857
  async createSession(options) {
11765
11858
  if (!this.sdkConnection?.agent) {
11766
11859
  return err({ code: "ACP_NOT_CONNECTED", message: "尚未连接到 Agent 服务端" });
@@ -12462,9 +12555,11 @@ async function handleRpcRequest(id, method, params) {
12462
12555
  }
12463
12556
  const handle = sessionResult.value;
12464
12557
  activeSessions.set(handle.sessionId, handle);
12558
+ const availableCommands = await client2.waitForAvailableCommands(handle.sessionId, 150);
12465
12559
  sendResponse(id, {
12466
12560
  sessionId: handle.sessionId,
12467
12561
  restoreMethod: handle.restoreMethod,
12562
+ ...availableCommands ? { availableCommands } : {},
12468
12563
  configOptions: handle.configOptions,
12469
12564
  modelOptions: extractModelOptions(handle.configOptions)
12470
12565
  });
@@ -12580,6 +12675,15 @@ async function handleRpcRequest(id, method, params) {
12580
12675
  }
12581
12676
  break;
12582
12677
  }
12678
+ case "session/commands": {
12679
+ const { sessionId } = params ?? {};
12680
+ if (!client2) {
12681
+ sendError(id, -32002, "Client not connected");
12682
+ return;
12683
+ }
12684
+ sendResponse(id, { sessionId, availableCommands: client2.getAvailableCommands(String(sessionId ?? "")) ?? null });
12685
+ break;
12686
+ }
12583
12687
  case "session/cancel": {
12584
12688
  try {
12585
12689
  const { sessionId } = params ?? {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yitom/acp-client",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Headless ACP (Agent Client Protocol) SDK for connecting to Codex, Claude, Cursor, DeepSeek and more",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",