ycodium-acp-executor 0.2.5877 → 0.2.5921

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 (49) hide show
  1. package/dist/adapter-support.d.ts.map +1 -1
  2. package/dist/adapter-support.js +12 -3
  3. package/dist/adapter-support.js.map +1 -1
  4. package/dist/approvals.d.ts +1 -0
  5. package/dist/approvals.d.ts.map +1 -1
  6. package/dist/approvals.js.map +1 -1
  7. package/dist/events.d.ts +18 -0
  8. package/dist/events.d.ts.map +1 -1
  9. package/dist/events.js +226 -40
  10. package/dist/events.js.map +1 -1
  11. package/dist/executor/requests.d.ts +12 -1
  12. package/dist/executor/requests.d.ts.map +1 -1
  13. package/dist/executor/requests.js +341 -45
  14. package/dist/executor/requests.js.map +1 -1
  15. package/dist/executor/updates.d.ts +14 -2
  16. package/dist/executor/updates.d.ts.map +1 -1
  17. package/dist/executor/updates.js +65 -10
  18. package/dist/executor/updates.js.map +1 -1
  19. package/dist/executor.d.ts.map +1 -1
  20. package/dist/executor.js +16 -13
  21. package/dist/executor.js.map +1 -1
  22. package/dist/index.d.ts +3 -2
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +2 -2
  25. package/dist/index.js.map +1 -1
  26. package/dist/runtime-model.d.ts.map +1 -1
  27. package/dist/runtime-model.js +54 -10
  28. package/dist/runtime-model.js.map +1 -1
  29. package/dist/source/adapter-support.ts +15 -3
  30. package/dist/source/approvals.ts +1 -0
  31. package/dist/source/events.ts +277 -41
  32. package/dist/source/executor/requests.ts +372 -45
  33. package/dist/source/executor/updates.ts +98 -12
  34. package/dist/source/executor.ts +25 -20
  35. package/dist/source/index.ts +4 -1
  36. package/dist/source/runtime-model.ts +75 -10
  37. package/dist/source/tool-call-state.ts +171 -4
  38. package/dist/source/types.ts +6 -1
  39. package/dist/source/vendor-hooks.ts +19 -0
  40. package/dist/tool-call-state.d.ts +27 -0
  41. package/dist/tool-call-state.d.ts.map +1 -1
  42. package/dist/tool-call-state.js +113 -4
  43. package/dist/tool-call-state.js.map +1 -1
  44. package/dist/types.d.ts +6 -1
  45. package/dist/types.d.ts.map +1 -1
  46. package/dist/vendor-hooks.d.ts +18 -0
  47. package/dist/vendor-hooks.d.ts.map +1 -1
  48. package/dist/vendor-hooks.js.map +1 -1
  49. package/package.json +4 -4
@@ -274,6 +274,27 @@ export function createAcpExecutor(options: AcpExecutorOptions): AcpExecutor {
274
274
  promptMutex,
275
275
  shared,
276
276
  });
277
+ const {
278
+ settleAllApprovals,
279
+ settleAllUserInputs,
280
+ makeExtensionContext,
281
+ handlePermissionRequest,
282
+ respondToRequest,
283
+ respondToUserInput,
284
+ supersedePermissionTrackedState,
285
+ runWithCommittedPermissionBaseline,
286
+ } = createExecutorRequests({
287
+ emit,
288
+ stamp,
289
+ options,
290
+ approvals,
291
+ pendingUserInputs,
292
+ failIfDisposed,
293
+ randomId,
294
+ hooks,
295
+ shared,
296
+ toolCalls,
297
+ });
277
298
  const {
278
299
  emitCompactionState,
279
300
  receiveSessionUpdate,
@@ -294,25 +315,8 @@ export function createAcpExecutor(options: AcpExecutorOptions): AcpExecutor {
294
315
  closeActiveAssistantSegment,
295
316
  ensureActiveAssistantSegment,
296
317
  shared,
297
- });
298
- const {
299
- settleAllApprovals,
300
- settleAllUserInputs,
301
- makeExtensionContext,
302
- handlePermissionRequest,
303
- respondToRequest,
304
- respondToUserInput,
305
- } = createExecutorRequests({
306
- emit,
307
- stamp,
308
- options,
309
- approvals,
310
- pendingUserInputs,
311
- failIfDisposed,
312
- randomId,
313
- hooks,
314
- shared,
315
- toolCalls,
318
+ supersedePermissionTrackedState,
319
+ runWithCommittedPermissionBaseline,
316
320
  });
317
321
  const { rememberSettledPromptKey, abortPendingSettlement, settleFromNotification } =
318
322
  createExecutorSettlement({ hooks, shared });
@@ -351,10 +355,11 @@ export function createAcpExecutor(options: AcpExecutorOptions): AcpExecutor {
351
355
  onNotification: (notification: AcpIncomingNotification) => {
352
356
  if (notification.method === "session/update") {
353
357
  const params = notification.params as SessionNotification;
358
+ const rawUpdate = (params as { readonly update?: unknown }).update;
354
359
  const transformed = hooks.transformSessionUpdate
355
360
  ? hooks.transformSessionUpdate(params)
356
361
  : params;
357
- if (transformed !== undefined) receiveSessionUpdate(transformed);
362
+ if (transformed !== undefined) receiveSessionUpdate(transformed, rawUpdate);
358
363
  return;
359
364
  }
360
365
  if (settleFromNotification(notification.method, notification.params)) return;
@@ -97,7 +97,10 @@ export {
97
97
  makeAcpRequestOpenedEvent,
98
98
  makeAcpRequestResolvedEvent,
99
99
  makeAcpToolCallEvent,
100
+ markAcpDiffTooLarge,
101
+ readAcpDiffTooLarge,
100
102
  } from "./events.ts";
103
+ export type { AcpClippedDiffStats } from "./events.ts";
101
104
  export {
102
105
  acpCommandsToSlashCommands,
103
106
  decideToolCallUpdateEmission,
@@ -159,7 +162,7 @@ export type {
159
162
  ExecutorEvent,
160
163
  ExecutorEventType,
161
164
  } from "./types.ts";
162
- export { boundTailText } from "./tool-call-state.ts";
165
+ export { boundTailText, readToolCallIdentityFields } from "./tool-call-state.ts";
163
166
  export { createToolSubagentTracker } from "./tool-subagents.ts";
164
167
  export type {
165
168
  AcpToolSubagentFacts,
@@ -5,7 +5,12 @@ import type { SessionNotification } from "./protocol.ts";
5
5
 
6
6
  import { findConfigOptionEntry } from "./config-options.ts";
7
7
  import { isRecord, readAcpText } from "./util.ts";
8
- import { makeToolCallState, type AcpToolCallState } from "./tool-call-state.ts";
8
+ import {
9
+ makeToolCallState,
10
+ readToolCallIdentityFields,
11
+ toolCallIdentityChanged,
12
+ type AcpToolCallState,
13
+ } from "./tool-call-state.ts";
9
14
 
10
15
  export { decideToolCallUpdateEmission, mergeToolCallState } from "./tool-call-state.ts";
11
16
  export type { AcpToolCallEmitDecision, AcpToolCallState } from "./tool-call-state.ts";
@@ -330,20 +335,76 @@ export function parsePermissionRequest(
330
335
  known?: { readonly state: AcpToolCallState; readonly rawTitle: string | undefined },
331
336
  ): AcpPermissionRequest {
332
337
  const request = params.toolCall;
338
+ const requestFields = request as {
339
+ readonly name?: unknown;
340
+ readonly mcpServer?: unknown;
341
+ readonly mcpTool?: unknown;
342
+ };
333
343
  const earlier = known?.state.data;
344
+ const identityChanged =
345
+ known !== undefined &&
346
+ toolCallIdentityChanged(
347
+ {
348
+ name: earlier?.["name"],
349
+ kind: known.state.kind,
350
+ mcpServer: earlier?.["mcpServer"],
351
+ mcpTool: earlier?.["mcpTool"],
352
+ },
353
+ {
354
+ name: requestFields.name,
355
+ kind: request.kind,
356
+ mcpServer: requestFields.mcpServer,
357
+ mcpTool: requestFields.mcpTool,
358
+ },
359
+ );
360
+ const prior = identityChanged ? undefined : known;
361
+ const priorData = identityChanged ? undefined : earlier;
362
+ const priorNegativeMcp =
363
+ prior !== undefined ? readToolCallIdentityFields(prior.state).negativeMcp : false;
364
+ const reqMeta = (request as { readonly _meta?: unknown })._meta;
365
+ const parentMeta = (params as { readonly _meta?: unknown })._meta;
366
+ const requestNegativeMcp =
367
+ requestFields.mcpServer === null ||
368
+ requestFields.mcpTool === null ||
369
+ (isRecord(reqMeta) && reqMeta["is_mcp_tool_call"] === false) ||
370
+ (isRecord(parentMeta) && parentMeta["is_mcp_tool_call"] === false);
371
+ const allowPriorMcpFields =
372
+ !priorNegativeMcp && !requestNegativeMcp && requestFields.name === undefined;
373
+ const inheritedRawTitle =
374
+ prior?.rawTitle !== undefined &&
375
+ !(
376
+ (priorNegativeMcp || requestNegativeMcp) &&
377
+ /^(?:(?:Running|Run)\s+)?mcp_/u.test(prior.rawTitle.trim())
378
+ )
379
+ ? prior.rawTitle
380
+ : undefined;
334
381
  const toolCall = makeToolCallState(
335
382
  {
336
383
  toolCallId: request.toolCallId,
337
- name: earlier?.["name"],
338
- title: request.title ?? known?.rawTitle,
339
- kind: request.kind ?? earlier?.["kind"],
384
+ name: requestFields.name !== undefined ? requestFields.name : priorData?.["name"],
385
+ mcpServer:
386
+ requestFields.mcpServer !== undefined
387
+ ? requestFields.mcpServer
388
+ : allowPriorMcpFields
389
+ ? priorData?.["mcpServer"]
390
+ : undefined,
391
+ mcpTool:
392
+ requestFields.mcpTool !== undefined
393
+ ? requestFields.mcpTool
394
+ : allowPriorMcpFields
395
+ ? priorData?.["mcpTool"]
396
+ : undefined,
397
+ title: request.title ?? inheritedRawTitle,
398
+ kind: request.kind ?? priorData?.["kind"],
340
399
  status: request.status ?? known?.state.status,
341
- rawInput: request.rawInput !== undefined ? request.rawInput : earlier?.["rawInput"],
342
- rawOutput: request.rawOutput !== undefined ? request.rawOutput : earlier?.["rawOutput"],
343
- content: request.content !== undefined ? request.content : earlier?.["content"],
344
- locations: request.locations !== undefined ? request.locations : earlier?.["locations"],
400
+ rawInput: request.rawInput !== undefined ? request.rawInput : priorData?.["rawInput"],
401
+ rawOutput: request.rawOutput !== undefined ? request.rawOutput : priorData?.["rawOutput"],
402
+ content: request.content !== undefined ? request.content : priorData?.["content"],
403
+ locations: request.locations !== undefined ? request.locations : priorData?.["locations"],
404
+ _meta: reqMeta,
405
+ parentMeta,
345
406
  },
346
- { fallbackStatus: "pending" },
407
+ { fallbackStatus: "pending", ...(priorNegativeMcp ? { inheritedNegativeMcp: true } : {}) },
347
408
  );
348
409
  const kind = toolCall?.kind ?? "unknown";
349
410
  const content = toolCall?.data["content"];
@@ -357,7 +418,7 @@ export function parsePermissionRequest(
357
418
  : [];
358
419
  })[0]
359
420
  : undefined;
360
- const originalTitle = (request.title ?? known?.rawTitle)?.trim() || undefined;
421
+ const originalTitle = (request.title ?? inheritedRawTitle)?.trim() || undefined;
361
422
  const detail = toolCall?.command ?? firstText ?? originalTitle;
362
423
  return {
363
424
  kind,
@@ -479,6 +540,8 @@ export function parseSessionUpdateEvent(params: SessionNotification): {
479
540
  {
480
541
  toolCallId: upd["toolCallId"],
481
542
  name: upd["name"],
543
+ mcpServer: upd["mcpServer"],
544
+ mcpTool: upd["mcpTool"],
482
545
  title: typeof upd["title"] === "string" ? upd["title"] : undefined,
483
546
  kind: upd["kind"],
484
547
  status: upd["status"],
@@ -486,6 +549,8 @@ export function parseSessionUpdateEvent(params: SessionNotification): {
486
549
  rawOutput: upd["rawOutput"],
487
550
  content: upd["content"],
488
551
  locations: upd["locations"],
552
+ _meta: upd["_meta"],
553
+ parentMeta: (params as { readonly _meta?: unknown })._meta,
489
554
  },
490
555
  kind === "tool_call" ? { fallbackStatus: "pending" } : undefined,
491
556
  );
@@ -18,6 +18,37 @@ export interface AcpToolCallState {
18
18
  readonly data: Record<string, unknown>;
19
19
  }
20
20
 
21
+ interface ClearedToolCallIdentityFields {
22
+ readonly name?: null;
23
+ readonly mcpServer?: null;
24
+ readonly mcpTool?: null;
25
+ readonly negativeMcp?: true;
26
+ readonly positiveMcp?: true;
27
+ }
28
+
29
+ const clearedIdentityFields = new WeakMap<AcpToolCallState, ClearedToolCallIdentityFields>();
30
+
31
+ /** 读取用于判定身份变化的字段,保留规范化层用 `null` 显式抹掉的身份/MCP 清除信号与负向 MCP 标记。 */
32
+ export function readToolCallIdentityFields(
33
+ state: AcpToolCallState,
34
+ options?: { readonly kindFromData?: boolean },
35
+ ): {
36
+ readonly name: unknown;
37
+ readonly kind: unknown;
38
+ readonly mcpServer: unknown;
39
+ readonly mcpTool: unknown;
40
+ readonly negativeMcp: boolean;
41
+ } {
42
+ const cleared = clearedIdentityFields.get(state);
43
+ return {
44
+ name: cleared?.name === null ? null : state.data["name"],
45
+ kind: options?.kindFromData ? state.data["kind"] : state.kind,
46
+ mcpServer: cleared?.mcpServer === null ? null : state.data["mcpServer"],
47
+ mcpTool: cleared?.mcpTool === null ? null : state.data["mcpTool"],
48
+ negativeMcp: cleared?.negativeMcp === true,
49
+ };
50
+ }
51
+
21
52
  function normalizeToolCallStatus(
22
53
  raw: unknown,
23
54
  fallback?: "pending" | "inProgress" | "completed" | "failed",
@@ -176,6 +207,9 @@ export function makeToolCallState(
176
207
  readonly toolCallId: unknown;
177
208
  /** ACP 扩展字段,常只有首条 tool_call 带;落进 `data` 由 `mergeToolCallState` 沿用,后到的覆盖旧的。 */
178
209
  readonly name?: unknown;
210
+ /** 由 adapter 在归一化前缀前确立的 MCP server 与工具名,防下游按较小配置表重新拆错。 */
211
+ readonly mcpServer?: unknown;
212
+ readonly mcpTool?: unknown;
179
213
  readonly title?: string | null | undefined;
180
214
  readonly kind?: unknown;
181
215
  readonly status?: unknown;
@@ -183,15 +217,42 @@ export function makeToolCallState(
183
217
  readonly rawOutput?: unknown;
184
218
  readonly content?: unknown;
185
219
  readonly locations?: unknown;
220
+ readonly _meta?: unknown;
221
+ readonly parentMeta?: unknown;
186
222
  },
187
223
  options?: {
188
224
  readonly fallbackStatus?: "pending" | "inProgress" | "completed" | "failed";
225
+ readonly inheritedNegativeMcp?: boolean;
189
226
  },
190
227
  ): AcpToolCallState | undefined {
191
228
  const toolCallId = typeof input.toolCallId === "string" ? input.toolCallId.trim() : "";
192
229
  if (!toolCallId) {
193
230
  return undefined;
194
231
  }
232
+ const explicitNullMcp = input.mcpServer === null || input.mcpTool === null;
233
+ const reqMetaFlag =
234
+ isRecord(input._meta) && typeof input._meta["is_mcp_tool_call"] === "boolean"
235
+ ? input._meta["is_mcp_tool_call"]
236
+ : undefined;
237
+ const parentMetaFlag =
238
+ isRecord(input.parentMeta) && typeof input.parentMeta["is_mcp_tool_call"] === "boolean"
239
+ ? input.parentMeta["is_mcp_tool_call"]
240
+ : undefined;
241
+ const metaFlag =
242
+ reqMetaFlag === false || parentMetaFlag === false
243
+ ? false
244
+ : reqMetaFlag === true || parentMetaFlag === true
245
+ ? true
246
+ : undefined;
247
+ const explicitPositiveMcp =
248
+ !explicitNullMcp &&
249
+ metaFlag !== false &&
250
+ (metaFlag === true ||
251
+ (readAcpText(input, "mcpServer") !== undefined &&
252
+ readAcpText(input, "mcpTool") !== undefined));
253
+ const explicitNegativeMcp = explicitNullMcp || metaFlag === false;
254
+ const negativeMcp =
255
+ explicitNegativeMcp || (!explicitPositiveMcp && options?.inheritedNegativeMcp === true);
195
256
  const title = typeof input.title === "string" ? input.title.trim() || undefined : undefined;
196
257
  const command = extractToolCallCommand(input.rawInput, title);
197
258
  const extractedContent = extractTextContentFromToolCallContent(input.content);
@@ -208,6 +269,12 @@ export function makeToolCallState(
208
269
  const name = readAcpText(input, "name");
209
270
  if (name) {
210
271
  data["name"] = name;
272
+ const mcpServer = readAcpText(input, "mcpServer");
273
+ const mcpTool = readAcpText(input, "mcpTool");
274
+ if (!negativeMcp && mcpServer !== undefined && mcpTool !== undefined) {
275
+ data["mcpServer"] = mcpServer;
276
+ data["mcpTool"] = mcpTool;
277
+ }
211
278
  }
212
279
  if (command) {
213
280
  data["command"] = command;
@@ -241,7 +308,7 @@ export function makeToolCallState(
241
308
  })
242
309
  : undefined;
243
310
  const status = normalizeToolCallStatus(input.status, options?.fallbackStatus);
244
- return {
311
+ const state: AcpToolCallState = {
245
312
  toolCallId,
246
313
  ...(kind ? { kind } : {}),
247
314
  ...(presentation?.summary ? { title: presentation.summary } : {}),
@@ -251,12 +318,85 @@ export function makeToolCallState(
251
318
  ...(textContent ? { contentText: textContent } : {}),
252
319
  data,
253
320
  };
321
+ if (
322
+ input.name === null ||
323
+ input.mcpServer === null ||
324
+ input.mcpTool === null ||
325
+ negativeMcp ||
326
+ explicitPositiveMcp
327
+ ) {
328
+ clearedIdentityFields.set(state, {
329
+ ...(input.name === null ? { name: null } : {}),
330
+ ...(input.mcpServer === null ? { mcpServer: null } : {}),
331
+ ...(input.mcpTool === null ? { mcpTool: null } : {}),
332
+ ...(negativeMcp ? { negativeMcp: true } : {}),
333
+ ...(explicitPositiveMcp ? { positiveMcp: true } : {}),
334
+ });
335
+ }
336
+ return state;
337
+ }
338
+
339
+ export function toolCallIdentityChanged(
340
+ previous: {
341
+ readonly name?: unknown;
342
+ readonly kind?: unknown;
343
+ readonly mcpServer?: unknown;
344
+ readonly mcpTool?: unknown;
345
+ },
346
+ next: {
347
+ readonly name?: unknown;
348
+ readonly kind?: unknown;
349
+ readonly mcpServer?: unknown;
350
+ readonly mcpTool?: unknown;
351
+ },
352
+ ): boolean {
353
+ const prevName = readAcpText(previous, "name");
354
+ const nextName = readAcpText(next, "name");
355
+ const prevKind = normalizeToolKind(previous.kind);
356
+ const nextKind = normalizeToolKind(next.kind);
357
+ const prevServer = readAcpText(previous, "mcpServer");
358
+ const nextServer = readAcpText(next, "mcpServer");
359
+ const prevTool = readAcpText(previous, "mcpTool");
360
+ const nextTool = readAcpText(next, "mcpTool");
361
+ const clearedName = prevName !== undefined && next.name === null;
362
+ const clearedServer = prevServer !== undefined && next.mcpServer === null;
363
+ const clearedTool = prevTool !== undefined && next.mcpTool === null;
364
+ return (
365
+ clearedName ||
366
+ clearedServer ||
367
+ clearedTool ||
368
+ (prevName !== undefined && nextName !== undefined && prevName !== nextName) ||
369
+ (prevKind !== undefined && nextKind !== undefined && prevKind !== nextKind) ||
370
+ (prevServer !== undefined && nextServer !== undefined && prevServer !== nextServer) ||
371
+ (prevTool !== undefined && nextTool !== undefined && prevTool !== nextTool)
372
+ );
254
373
  }
255
374
 
256
375
  export function mergeToolCallState(
257
376
  previous: AcpToolCallState | undefined,
258
377
  next: AcpToolCallState,
259
378
  ): AcpToolCallState {
379
+ if (
380
+ previous !== undefined &&
381
+ toolCallIdentityChanged(
382
+ {
383
+ name: previous.data["name"],
384
+ kind: previous.kind,
385
+ mcpServer: previous.data["mcpServer"],
386
+ mcpTool: previous.data["mcpTool"],
387
+ },
388
+ readToolCallIdentityFields(next, { kindFromData: true }),
389
+ )
390
+ ) {
391
+ const status = next.status ?? previous.status;
392
+ if (status === undefined || status === next.status) {
393
+ return next;
394
+ }
395
+ const replaced: AcpToolCallState = { ...next, status };
396
+ const nextCleared = clearedIdentityFields.get(next);
397
+ if (nextCleared !== undefined) clearedIdentityFields.set(replaced, nextCleared);
398
+ return replaced;
399
+ }
260
400
  const nextKind = typeof next.data["kind"] === "string" ? next.data["kind"] : undefined;
261
401
  const kind = nextKind ?? previous?.kind;
262
402
  const title = next.title ?? previous?.title;
@@ -265,7 +405,28 @@ export function mergeToolCallState(
265
405
  const detail = next.detail ?? previous?.detail;
266
406
  // 这一帧带了 content(哪怕是空的)就以它为准;没带才沿用上一帧的文本。
267
407
  const contentText = "content" in next.data ? next.contentText : previous?.contentText;
268
- return {
408
+ const prevCleared = previous === undefined ? undefined : clearedIdentityFields.get(previous);
409
+ const nextCleared = clearedIdentityFields.get(next);
410
+ const nextPositiveMcp =
411
+ (typeof next.data["mcpServer"] === "string" && typeof next.data["mcpTool"] === "string") ||
412
+ nextCleared?.positiveMcp === true;
413
+ const mergedNegativeMcp =
414
+ nextCleared?.negativeMcp === true || (!nextPositiveMcp && prevCleared?.negativeMcp === true);
415
+ const clearPreviousMcp =
416
+ previous !== undefined &&
417
+ (mergedNegativeMcp ||
418
+ (next.data["name"] !== undefined && next.data["mcpServer"] === undefined));
419
+ const previousData = clearPreviousMcp
420
+ ? Object.fromEntries(
421
+ Object.entries(previous.data).filter(([key]) => key !== "mcpServer" && key !== "mcpTool"),
422
+ )
423
+ : previous?.data;
424
+ const nextData = mergedNegativeMcp
425
+ ? Object.fromEntries(
426
+ Object.entries(next.data).filter(([key]) => key !== "mcpServer" && key !== "mcpTool"),
427
+ )
428
+ : next.data;
429
+ const merged: AcpToolCallState = {
269
430
  toolCallId: next.toolCallId,
270
431
  ...(kind ? { kind } : {}),
271
432
  ...(title ? { title } : {}),
@@ -274,10 +435,16 @@ export function mergeToolCallState(
274
435
  ...(detail ? { detail } : {}),
275
436
  ...(contentText ? { contentText } : {}),
276
437
  data: {
277
- ...previous?.data,
278
- ...next.data,
438
+ ...previousData,
439
+ ...nextData,
279
440
  },
280
441
  };
442
+ if (mergedNegativeMcp) {
443
+ clearedIdentityFields.set(merged, { negativeMcp: true });
444
+ } else if (nextPositiveMcp || prevCleared?.positiveMcp === true) {
445
+ clearedIdentityFields.set(merged, { positiveMcp: true });
446
+ }
447
+ return merged;
281
448
  }
282
449
 
283
450
  const TOOL_CALL_UPDATE_MIN_DETAIL_GROWTH_CHARS = 256;
@@ -40,6 +40,8 @@ export type AcpFileChange =
40
40
  | {
41
41
  readonly path: string;
42
42
  readonly changeKind: "add" | "modify";
43
+ readonly additions?: number;
44
+ readonly deletions?: number;
43
45
  readonly content: {
44
46
  readonly kind: "replace";
45
47
  readonly oldText?: string;
@@ -48,7 +50,10 @@ export type AcpFileChange =
48
50
  }
49
51
  | {
50
52
  readonly path: string;
51
- readonly omitted: "unavailable";
53
+ readonly changeKind?: "add" | "modify";
54
+ readonly additions?: number;
55
+ readonly deletions?: number;
56
+ readonly omitted: "unavailable" | "too-large";
52
57
  };
53
58
 
54
59
  export type AcpUsageSnapshot = {
@@ -122,6 +122,25 @@ export type AcpVendorHooks = {
122
122
  readonly transformSessionUpdate?: (
123
123
  notification: SessionNotification,
124
124
  ) => SessionNotification | undefined;
125
+ /**
126
+ * 每条 `session/request_permission` 进通用机之前先过这里。
127
+ * 用于按当前会话的 `mcpServers` 把厂商自定义工具名规范成 `mcp__<server>__<tool>`,
128
+ * 避免单下划线前缀在审批与 UI 中撞上内置 `ycodium` 服务器。
129
+ */
130
+ readonly transformPermissionRequest?: (
131
+ params: unknown,
132
+ context?: { readonly requestId?: string },
133
+ ) => unknown;
134
+ /**
135
+ * 当某条权限请求以非批准方式收口(decline / cancel / dispose 清场)时触发,
136
+ * 供厂商规范化器撤销仅由该未过审请求写入的会话记忆。
137
+ */
138
+ readonly onPermissionRequestSettled?: (input: {
139
+ readonly sessionId: string;
140
+ readonly toolCallId: string;
141
+ readonly accepted: boolean;
142
+ readonly requestId?: string;
143
+ }) => void;
125
144
  /** 这一轮可能被 RPC 应答之外的信号收口(Grok)。留空 = 只等应答。 */
126
145
  readonly promptSettlement?: AcpPromptSettlementHooks;
127
146
  readonly resolveRequestedModelId?: (model: string | null | undefined) => string | undefined;
@@ -9,12 +9,25 @@ export interface AcpToolCallState {
9
9
  readonly contentText?: string;
10
10
  readonly data: Record<string, unknown>;
11
11
  }
12
+ /** 读取用于判定身份变化的字段,保留规范化层用 `null` 显式抹掉的身份/MCP 清除信号与负向 MCP 标记。 */
13
+ export declare function readToolCallIdentityFields(state: AcpToolCallState, options?: {
14
+ readonly kindFromData?: boolean;
15
+ }): {
16
+ readonly name: unknown;
17
+ readonly kind: unknown;
18
+ readonly mcpServer: unknown;
19
+ readonly mcpTool: unknown;
20
+ readonly negativeMcp: boolean;
21
+ };
12
22
  /** 超长文本只留末尾 `limit` 个字符并在前面标出被截断。 */
13
23
  export declare function boundTailText(text: string, limit?: number): string;
14
24
  export declare function makeToolCallState(input: {
15
25
  readonly toolCallId: unknown;
16
26
  /** ACP 扩展字段,常只有首条 tool_call 带;落进 `data` 由 `mergeToolCallState` 沿用,后到的覆盖旧的。 */
17
27
  readonly name?: unknown;
28
+ /** 由 adapter 在归一化前缀前确立的 MCP server 与工具名,防下游按较小配置表重新拆错。 */
29
+ readonly mcpServer?: unknown;
30
+ readonly mcpTool?: unknown;
18
31
  readonly title?: string | null | undefined;
19
32
  readonly kind?: unknown;
20
33
  readonly status?: unknown;
@@ -22,9 +35,23 @@ export declare function makeToolCallState(input: {
22
35
  readonly rawOutput?: unknown;
23
36
  readonly content?: unknown;
24
37
  readonly locations?: unknown;
38
+ readonly _meta?: unknown;
39
+ readonly parentMeta?: unknown;
25
40
  }, options?: {
26
41
  readonly fallbackStatus?: "pending" | "inProgress" | "completed" | "failed";
42
+ readonly inheritedNegativeMcp?: boolean;
27
43
  }): AcpToolCallState | undefined;
44
+ export declare function toolCallIdentityChanged(previous: {
45
+ readonly name?: unknown;
46
+ readonly kind?: unknown;
47
+ readonly mcpServer?: unknown;
48
+ readonly mcpTool?: unknown;
49
+ }, next: {
50
+ readonly name?: unknown;
51
+ readonly kind?: unknown;
52
+ readonly mcpServer?: unknown;
53
+ readonly mcpTool?: unknown;
54
+ }): boolean;
28
55
  export declare function mergeToolCallState(previous: AcpToolCallState | undefined, next: AcpToolCallState): AcpToolCallState;
29
56
  export interface AcpToolCallEmitDecisionInput {
30
57
  readonly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