ycodium-acp-executor 0.2.5004 → 0.2.5100

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 (60) hide show
  1. package/README.md +7 -2
  2. package/dist/_private/ycodium-executor-common/catalogModel.d.ts +9 -0
  3. package/dist/_private/ycodium-executor-common/catalogModel.js +39 -0
  4. package/dist/_private/ycodium-executor-common/eventTypes.d.ts +7 -0
  5. package/dist/_private/ycodium-executor-common/eventTypes.js +1 -0
  6. package/dist/_private/ycodium-executor-common/modelSelection.d.ts +7 -0
  7. package/dist/_private/ycodium-executor-common/modelSelection.js +24 -0
  8. package/dist/_private/ycodium-executor-common/nodeStreams.d.ts +44 -0
  9. package/dist/_private/ycodium-executor-common/nodeStreams.js +158 -0
  10. package/dist/_private/ycodium-executor-common/raceAbort.d.ts +8 -0
  11. package/dist/_private/ycodium-executor-common/raceAbort.js +25 -0
  12. package/dist/{reasoning-level-fallback.d.ts → _private/ycodium-executor-common/reasoningLevelFallback.d.ts} +0 -1
  13. package/dist/{reasoning-level-fallback.js → _private/ycodium-executor-common/reasoningLevelFallback.js} +2 -1
  14. package/dist/_private/ycodium-executor-common/stderrTail.d.ts +9 -0
  15. package/dist/_private/ycodium-executor-common/stderrTail.js +29 -0
  16. package/dist/_private/ycodium-executor-common/toolPresentation.d.ts +19 -0
  17. package/dist/_private/ycodium-executor-common/toolPresentation.js +222 -0
  18. package/dist/errors.d.ts.map +1 -1
  19. package/dist/errors.js +2 -26
  20. package/dist/errors.js.map +1 -1
  21. package/dist/executor/prompt.js +1 -1
  22. package/dist/executor/prompt.js.map +1 -1
  23. package/dist/index.d.ts +7 -0
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +4 -0
  26. package/dist/index.js.map +1 -1
  27. package/dist/instance-kit.d.ts +353 -0
  28. package/dist/instance-kit.d.ts.map +1 -0
  29. package/dist/instance-kit.js +259 -0
  30. package/dist/instance-kit.js.map +1 -0
  31. package/dist/probe-process.d.ts +34 -0
  32. package/dist/probe-process.d.ts.map +1 -0
  33. package/dist/probe-process.js +51 -0
  34. package/dist/probe-process.js.map +1 -0
  35. package/dist/probe-session.d.ts +39 -0
  36. package/dist/probe-session.d.ts.map +1 -0
  37. package/dist/probe-session.js +71 -0
  38. package/dist/probe-session.js.map +1 -0
  39. package/dist/runtime-model.d.ts +2 -9
  40. package/dist/runtime-model.d.ts.map +1 -1
  41. package/dist/runtime-model.js +2 -38
  42. package/dist/runtime-model.js.map +1 -1
  43. package/dist/thread-operations.d.ts +72 -0
  44. package/dist/thread-operations.d.ts.map +1 -0
  45. package/dist/thread-operations.js +85 -0
  46. package/dist/thread-operations.js.map +1 -0
  47. package/dist/tool-call-state.d.ts.map +1 -1
  48. package/dist/tool-call-state.js +2 -1
  49. package/dist/tool-call-state.js.map +1 -1
  50. package/dist/tool-presentation.d.ts +0 -15
  51. package/dist/tool-presentation.d.ts.map +1 -1
  52. package/dist/tool-presentation.js +0 -208
  53. package/dist/tool-presentation.js.map +1 -1
  54. package/dist/types.d.ts +4 -4
  55. package/dist/types.d.ts.map +1 -1
  56. package/dist/types.js +0 -4
  57. package/dist/types.js.map +1 -1
  58. package/package.json +4 -3
  59. package/dist/reasoning-level-fallback.d.ts.map +0 -1
  60. package/dist/reasoning-level-fallback.js.map +0 -1
package/README.md CHANGED
@@ -77,8 +77,10 @@ await executor.dispose();
77
77
  ```
78
78
 
79
79
  `executor.events` yields `ExecutorEvent` values with the same shape as the type of that name in
80
- `@ycodium-ai/plugin-api/executor`. This package does not import plugin-api, so the two types are
81
- structurally compatible rather than shared.
80
+ `@ycodium-ai/plugin-api/executor`. This package does not runtime-import plugin-api. The event type
81
+ set, `raceAbort`, `nodeStreamsFromHandle`, `modelSelectionStringOption`, and
82
+ `reasoningLevelFallbackWarning` are defined once in the private package `ycodium-executor-common`
83
+ and shipped inside this package's own build (plugin-api re-exports the same function signatures).
82
84
 
83
85
  What the executor handles for you:
84
86
 
@@ -154,6 +156,9 @@ version and its models:
154
156
  - `probeCliVersion`, `parseCliVersion` and `collectProbeProcess` run a CLI and read its output.
155
157
  - `openAcpProbeHandshake` opens a throwaway connection over the CLI's stdio, runs `initialize`, and
156
158
  lets you send further requests (`session/new`, `session/list`) with one timeout.
159
+ - `withAcpProbeProcess` makes the temp directory, runs the spawn function you pass, opens that
160
+ handshake, and kills the process afterwards. Map `mkdir-failed`, `not-started`, and `threw`
161
+ yourself; auth-required and version stay at the call site.
157
162
  - `acpModelChoicesFromConfigOptions`, `acpModelChoicesFromSessionModels`, `findAcpEffortConfig`,
158
163
  `acpAvailableModes` and `acpAgentVersion` read models, effort levels, modes and the agent
159
164
  version out of those answers.
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 宿主要的型号在手的型号目录里对应哪一个取值:`@ycodium-ai/plugin-api` 与 `ycodium-acp-executor` 共用这一份。本包不发布,
3
+ * 两个发布包构建时由 scripts/lib/inline-private-packages.mjs 把它内联进各自的 dist。
4
+ */
5
+ /**
6
+ * 先精确匹配,再按最后一段唯一匹配;两个取值最后一段相同就不猜(不同 provider 的地址与凭据不同)。
7
+ * 对不上返回 `undefined`,调用方不设型号。完整理由见 `@ycodium-ai/plugin-api/executor` 的同名函数。
8
+ */
9
+ export declare function matchCatalogModel(requested: string | undefined, catalog: ReadonlyArray<string>): string | undefined;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * 宿主要的型号在手的型号目录里对应哪一个取值:`@ycodium-ai/plugin-api` 与 `ycodium-acp-executor` 共用这一份。本包不发布,
3
+ * 两个发布包构建时由 scripts/lib/inline-private-packages.mjs 把它内联进各自的 dist。
4
+ */
5
+ /**
6
+ * 目录里一个取值的「最后一段」:dsh 的 JSON 元组 `["deepseek-official","deepseek-flash"]`
7
+ * 取最后一个元素(至少两段),opencode 的 `provider/model` 取第一个斜杠之后(模型名里
8
+ * 可以再带斜杠,opencode 自己也只在第一个斜杠处切)。别的形状没有最后一段。
9
+ */
10
+ function catalogModelLastSegment(value) {
11
+ if (value.startsWith("[")) {
12
+ let parsed;
13
+ try {
14
+ parsed = JSON.parse(value);
15
+ }
16
+ catch {
17
+ return undefined;
18
+ }
19
+ if (!Array.isArray(parsed) || parsed.length < 2)
20
+ return undefined;
21
+ const last = parsed[parsed.length - 1];
22
+ return typeof last === "string" ? last : undefined;
23
+ }
24
+ const separator = value.indexOf("/");
25
+ return separator > 0 && separator < value.length - 1 ? value.slice(separator + 1) : undefined;
26
+ }
27
+ /**
28
+ * 先精确匹配,再按最后一段唯一匹配;两个取值最后一段相同就不猜(不同 provider 的地址与凭据不同)。
29
+ * 对不上返回 `undefined`,调用方不设型号。完整理由见 `@ycodium-ai/plugin-api/executor` 的同名函数。
30
+ */
31
+ export function matchCatalogModel(requested, catalog) {
32
+ const wanted = requested?.trim();
33
+ if (!wanted)
34
+ return undefined;
35
+ if (catalog.includes(wanted))
36
+ return wanted;
37
+ const byLastSegment = catalog.filter((value) => catalogModelLastSegment(value) === wanted);
38
+ return byLastSegment.length === 1 ? byLastSegment[0] : undefined;
39
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 执行器事件的 `type` 闭集:`@ycodium-ai/plugin-api` 与 `ycodium-acp-executor` 共用这一份。本包不发布,
3
+ * 两个发布包构建时由 scripts/lib/inline-private-packages.mjs 把它内联进各自的 dist;
4
+ * `ycodium-acp-executor` 因此仍不在运行时依赖 plugin-api,plugin-api 也仍没有运行时依赖。
5
+ */
6
+ /** `type` 闭集与 contracts 的 `ProviderRuntimeEventType` 相同(含 `tool.denied`),不另造事件词汇。 */
7
+ export type ExecutorEventType = "session.started" | "session.configured" | "session.state.changed" | "session.exited" | "thread.started" | "thread.state.changed" | "thread.metadata.updated" | "thread.token-usage.updated" | "thread.realtime.started" | "thread.realtime.item-added" | "thread.realtime.audio.delta" | "thread.realtime.error" | "thread.realtime.closed" | "turn.started" | "turn.completed" | "turn.aborted" | "turn.plan.updated" | "turn.proposed.delta" | "turn.proposed.completed" | "turn.diff.updated" | "item.started" | "item.updated" | "item.completed" | "content.delta" | "request.opened" | "request.resolved" | "user-input.requested" | "user-input.resolved" | "task.started" | "task.progress" | "task.updated" | "task.completed" | "hook.started" | "hook.progress" | "hook.completed" | "tool.progress" | "tool.summary" | "tool.denied" | "auth.status" | "account.updated" | "account.rate-limits.updated" | "mcp.status.updated" | "mcp.oauth.completed" | "model.rerouted" | "config.warning" | "deprecation.notice" | "files.persisted" | "assistant.attachment.produced" | "assistant.artifact.produced" | "runtime.warning" | "runtime.error";
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 从 `ModelSelection` 形状里读出某个字符串选项的值。
3
+ * 空串按缺席处理:界面清掉一个选项时留的是空串,发一个空值出去等于让 CLI 用空档。
4
+ * `@ycodium-ai/plugin-api` 与 `ycodium-acp-executor` 共用这一份。本包不发布,
5
+ * 两个发布包构建时由 scripts/lib/inline-private-packages.mjs 把它内联进各自的 dist。
6
+ */
7
+ export declare function modelSelectionStringOption(selection: unknown, optionId: string): string | undefined;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * 从 `ModelSelection` 形状里读出某个字符串选项的值。
3
+ * 空串按缺席处理:界面清掉一个选项时留的是空串,发一个空值出去等于让 CLI 用空档。
4
+ * `@ycodium-ai/plugin-api` 与 `ycodium-acp-executor` 共用这一份。本包不发布,
5
+ * 两个发布包构建时由 scripts/lib/inline-private-packages.mjs 把它内联进各自的 dist。
6
+ */
7
+ export function modelSelectionStringOption(selection, optionId) {
8
+ if (typeof selection !== "object" || selection === null || Array.isArray(selection)) {
9
+ return undefined;
10
+ }
11
+ const options = selection["options"];
12
+ if (!Array.isArray(options))
13
+ return undefined;
14
+ for (const entry of options) {
15
+ if (typeof entry !== "object" || entry === null || Array.isArray(entry))
16
+ continue;
17
+ const record = entry;
18
+ if (record["id"] !== optionId)
19
+ continue;
20
+ const value = record["value"];
21
+ return typeof value === "string" ? value.trim() || undefined : undefined;
22
+ }
23
+ return undefined;
24
+ }
@@ -0,0 +1,44 @@
1
+ import * as NodeStream from "node:stream";
2
+ /** 判「这次失败是不是因为对端没了」。真异常返回 false,交给调用方照旧处理。 */
3
+ export declare function isPeerClosedStdinError(error: unknown): boolean;
4
+ /** 对端没了导致这次写没送到。`code` 保留原始那一个,诊断不丢。 */
5
+ export declare class PeerClosedStdinError extends Error {
6
+ readonly name = "PeerClosedStdinError";
7
+ readonly code: string;
8
+ constructor(operation: "write" | "close", cause?: unknown);
9
+ }
10
+ /** 调用方要认的「对端没了」错误。不传就用本模块这份,形状与 plugin-api 的公开类相同。 */
11
+ export type StdinPeerErrors = {
12
+ readonly isPeerClosed: (error: unknown) => boolean;
13
+ readonly peerClosed: (operation: "write" | "close", cause?: unknown) => Error;
14
+ };
15
+ /** 宿主 `process.spawn` 句柄里与流有关的那几位;`kill` / `exited` 由调用方自己拿。 */
16
+ export type SpawnHandle = {
17
+ readonly stdout: AsyncIterable<Uint8Array>;
18
+ readonly stderr: AsyncIterable<Uint8Array>;
19
+ readonly writeStdin: (chunk: Uint8Array | string) => Promise<void>;
20
+ readonly closeStdin: () => Promise<void>;
21
+ };
22
+ /** 写失败同时投给回调与流;调用方必须接住 `'error'`,真异常不能吞掉。 */
23
+ export declare function nodeWritableFromHandle(handle: Pick<SpawnHandle, "writeStdin" | "closeStdin">, errors?: StdinPeerErrors): NodeStream.Writable;
24
+ /**
25
+ * stderr 尾巴要进给用户看的错误,先脱敏:家目录换成 `~`,配对链接、Bearer、Basic、
26
+ * x-api-key 与常见密钥前缀一律遮掉。
27
+ */
28
+ export declare function redactStderrExcerpt(text: string, environment?: Readonly<Record<string, string | undefined>>): string;
29
+ /** 已脱敏的 stderr 只留最后不超过 `maxChars` 字。调用方先 trim 的那一步在 `lastStderrTail`。 */
30
+ export declare function lastStderrLines(redacted: string, maxChars: number): string;
31
+ /**
32
+ * 从启动起抽干 stderr:宿主那条队列有界,不抽会把子进程写堵死。抽的同时按 UTF-8 流式解码、留最后几 KiB;
33
+ * 返回的函数等它读完(最多半秒)后交出脱敏的那一段,给「启动期就退出」的错误点名原因。
34
+ */
35
+ export declare function drainStderrTail(stderr: AsyncIterable<Uint8Array>): () => Promise<string>;
36
+ /**
37
+ * 把 `host.process.spawn` 的句柄折成协议库要的 Node 流。
38
+ * stderr 由 `drainStderrTail` 抽干,`stderrTail()` 交出脱敏的末尾一段。
39
+ */
40
+ export declare function nodeStreamsFromHandle(handle: SpawnHandle, errors?: StdinPeerErrors): {
41
+ readonly readable: NodeStream.Readable;
42
+ readonly writable: NodeStream.Writable;
43
+ readonly stderrTail: () => Promise<string>;
44
+ };
@@ -0,0 +1,158 @@
1
+ // @effect-diagnostics globalTimers:off - 等 stderr 读完的上限只能用 setTimeout。
2
+ /**
3
+ * 把 `host.process.spawn` 的句柄折成 Node 流,并抽干 stderr 尾巴。
4
+ * `@ycodium-ai/plugin-api` 与 `ycodium-acp-executor` 共用这一份。本包不发布,
5
+ * 两个发布包构建时由 scripts/lib/inline-private-packages.mjs 把它内联进各自的 dist。
6
+ * plugin-api 仍导出自己的 `PeerClosedStdinError`(`instanceof` 认那一份),调用时传进来。
7
+ */
8
+ import { lastStderrTail } from "./stderrTail.js";
9
+ import * as NodeOS from "node:os";
10
+ import * as NodeStream from "node:stream";
11
+ /** 对端已关:Node 与 libuv 在这几个 code 上说的是同一件事。 */
12
+ const PEER_CLOSED_STDIN_CODES = new Set([
13
+ "EPIPE",
14
+ "ECONNRESET",
15
+ "EOF",
16
+ "ERR_STREAM_DESTROYED",
17
+ "ERR_STREAM_WRITE_AFTER_END",
18
+ "ERR_STREAM_ALREADY_FINISHED",
19
+ ]);
20
+ function errorCode(value) {
21
+ if (typeof value !== "object" || value === null)
22
+ return undefined;
23
+ const code = value.code;
24
+ return typeof code === "string" ? code : undefined;
25
+ }
26
+ function asError(value) {
27
+ return value instanceof Error ? value : new Error(String(value));
28
+ }
29
+ /** 判「这次失败是不是因为对端没了」。真异常返回 false,交给调用方照旧处理。 */
30
+ export function isPeerClosedStdinError(error) {
31
+ const code = errorCode(error);
32
+ return code !== undefined && PEER_CLOSED_STDIN_CODES.has(code);
33
+ }
34
+ /** 对端没了导致这次写没送到。`code` 保留原始那一个,诊断不丢。 */
35
+ export class PeerClosedStdinError extends Error {
36
+ name = "PeerClosedStdinError";
37
+ code;
38
+ constructor(operation, cause) {
39
+ super(`Child process stdin is closed; the ${operation} did not reach the peer.`, cause === undefined ? undefined : { cause });
40
+ this.code = errorCode(cause) ?? "ERR_STREAM_DESTROYED";
41
+ }
42
+ }
43
+ const ownErrors = {
44
+ isPeerClosed: isPeerClosedStdinError,
45
+ peerClosed: (operation, cause) => new PeerClosedStdinError(operation, cause),
46
+ };
47
+ function toStreamError(errors, operation, error) {
48
+ if (errors.isPeerClosed(error))
49
+ return errors.peerClosed(operation, error);
50
+ return asError(error);
51
+ }
52
+ /** 写失败同时投给回调与流;调用方必须接住 `'error'`,真异常不能吞掉。 */
53
+ export function nodeWritableFromHandle(handle, errors = ownErrors) {
54
+ return new NodeStream.Writable({
55
+ write(chunk, _encoding, callback) {
56
+ const bytes = typeof chunk === "string" ? new TextEncoder().encode(chunk) : chunk;
57
+ handle.writeStdin(bytes).then(() => callback(), (error) => callback(toStreamError(errors, "write", error)));
58
+ },
59
+ final(callback) {
60
+ handle.closeStdin().then(() => callback(),
61
+ // 关一条对端已经没了的流是正常收尾,不是失败;真异常照旧交出去。
62
+ (error) => callback(errors.isPeerClosed(error) ? undefined : toStreamError(errors, "close", error)));
63
+ },
64
+ });
65
+ }
66
+ /** 留给启动失败诊断的 stderr 尾巴上限(字符)。 */
67
+ const STDERR_TAIL_MAX_CHARS = 4_096;
68
+ /** 取尾巴时最多等 stderr 读完这么久。 */
69
+ const STDERR_SETTLE_MS = 500;
70
+ const PAIRING_URL_PATTERN = /https?:\/\/[^\s]*\/pair#[^\s]*/gi;
71
+ const BEARER_TOKEN_PATTERN = /\bBearer\s+[A-Za-z0-9._\-+=/]+/gi;
72
+ const BASIC_AUTH_PATTERN = /\bAuthorization:\s*Basic\s+\S+/gi;
73
+ const API_KEY_HEADER_PATTERN = /\bx-api-key:\s*\S+/gi;
74
+ const SECRET_TOKEN_PATTERN = /\b(?:sk-[A-Za-z0-9][A-Za-z0-9-]{7,}|ghp_[A-Za-z0-9]+|xox[a-zA-Z]-[A-Za-z0-9-]+)\b/g;
75
+ /**
76
+ * stderr 尾巴要进给用户看的错误,先脱敏:家目录换成 `~`,配对链接、Bearer、Basic、
77
+ * x-api-key 与常见密钥前缀一律遮掉。
78
+ */
79
+ export function redactStderrExcerpt(text, environment = process.env) {
80
+ let result = text.replaceAll("\0", "");
81
+ const homes = [environment["HOME"], environment["USERPROFILE"], NodeOS.homedir()].filter((value) => typeof value === "string" && value.length > 1);
82
+ for (const home of new Set(homes)) {
83
+ result = result.split(home).join("~");
84
+ }
85
+ return result
86
+ .replace(PAIRING_URL_PATTERN, "[pairing-url]")
87
+ .replace(BEARER_TOKEN_PATTERN, "Bearer [redacted]")
88
+ .replace(BASIC_AUTH_PATTERN, "Authorization: Basic [redacted]")
89
+ .replace(API_KEY_HEADER_PATTERN, "x-api-key: [redacted]")
90
+ .replace(SECRET_TOKEN_PATTERN, "[redacted]")
91
+ .trim();
92
+ }
93
+ /** 已脱敏的 stderr 只留最后不超过 `maxChars` 字。调用方先 trim 的那一步在 `lastStderrTail`。 */
94
+ export function lastStderrLines(redacted, maxChars) {
95
+ return lastStderrTail(redacted.trim(), maxChars);
96
+ }
97
+ /**
98
+ * 从启动起抽干 stderr:宿主那条队列有界,不抽会把子进程写堵死。抽的同时按 UTF-8 流式解码、留最后几 KiB;
99
+ * 返回的函数等它读完(最多半秒)后交出脱敏的那一段,给「启动期就退出」的错误点名原因。
100
+ */
101
+ export function drainStderrTail(stderr) {
102
+ let tail = "";
103
+ const decoder = new TextDecoder();
104
+ const drained = (async () => {
105
+ for await (const chunk of stderr) {
106
+ const next = tail + decoder.decode(chunk, { stream: true });
107
+ tail = next.length <= STDERR_TAIL_MAX_CHARS ? next : next.slice(-STDERR_TAIL_MAX_CHARS);
108
+ }
109
+ })().catch(() => undefined);
110
+ // 进程的别的出口到头时 stderr 未必已读完(各走各的管道):等它读完再取,但不无限等——
111
+ // 子进程关了别的管道却还活着时,stderr 不会到头。
112
+ return async () => {
113
+ let timer;
114
+ await Promise.race([
115
+ drained,
116
+ new Promise((resolve) => {
117
+ timer = setTimeout(resolve, STDERR_SETTLE_MS);
118
+ }),
119
+ ]);
120
+ clearTimeout(timer);
121
+ return redactStderrExcerpt(tail);
122
+ };
123
+ }
124
+ /**
125
+ * 把 `host.process.spawn` 的句柄折成协议库要的 Node 流。
126
+ * stderr 由 `drainStderrTail` 抽干,`stderrTail()` 交出脱敏的末尾一段。
127
+ */
128
+ export function nodeStreamsFromHandle(handle, errors = ownErrors) {
129
+ const readable = new NodeStream.PassThrough();
130
+ void (async () => {
131
+ try {
132
+ for await (const chunk of handle.stdout) {
133
+ if (!readable.writable)
134
+ return;
135
+ if (!readable.write(chunk)) {
136
+ await new Promise((resolve) => {
137
+ const onDone = () => {
138
+ readable.off("drain", onDone);
139
+ readable.off("close", onDone);
140
+ resolve();
141
+ };
142
+ readable.once("drain", onDone);
143
+ readable.once("close", onDone);
144
+ });
145
+ }
146
+ }
147
+ }
148
+ catch (error) {
149
+ readable.destroy(asError(error));
150
+ return;
151
+ }
152
+ if (readable.writable)
153
+ readable.end();
154
+ })();
155
+ const settledStderrTail = drainStderrTail(handle.stderr);
156
+ const writable = nodeWritableFromHandle(handle, errors);
157
+ return { readable, writable, stderrTail: settledStderrTail };
158
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 等到 `pending` 结束;`signal` 已中止就抛 `Error("aborted")`,不再等下去。
3
+ * 先接住 `pending` 自己的拒绝:中止赢了这场等待之后,那支再拒绝就没人处理。
4
+ * 不传 `signal` 就只等 `pending`。这支不杀进程,杀进程只在宿主的 spawn。
5
+ * `@ycodium-ai/plugin-api` 与 `ycodium-acp-executor` 共用这一份。本包不发布,
6
+ * 两个发布包构建时由 scripts/lib/inline-private-packages.mjs 把它内联进各自的 dist。
7
+ */
8
+ export declare function raceAbort<T>(pending: Promise<T>, signal?: AbortSignal | undefined): Promise<T>;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * 等到 `pending` 结束;`signal` 已中止就抛 `Error("aborted")`,不再等下去。
3
+ * 先接住 `pending` 自己的拒绝:中止赢了这场等待之后,那支再拒绝就没人处理。
4
+ * 不传 `signal` 就只等 `pending`。这支不杀进程,杀进程只在宿主的 spawn。
5
+ * `@ycodium-ai/plugin-api` 与 `ycodium-acp-executor` 共用这一份。本包不发布,
6
+ * 两个发布包构建时由 scripts/lib/inline-private-packages.mjs 把它内联进各自的 dist。
7
+ */
8
+ export async function raceAbort(pending, signal) {
9
+ if (signal === undefined)
10
+ return pending;
11
+ void pending.catch(() => undefined);
12
+ if (signal.aborted)
13
+ throw new Error("aborted");
14
+ let onAbort;
15
+ const aborted = new Promise((_resolve, reject) => {
16
+ onAbort = () => reject(new Error("aborted"));
17
+ signal.addEventListener("abort", onAbort, { once: true });
18
+ });
19
+ try {
20
+ return await Promise.race([pending, aborted]);
21
+ }
22
+ finally {
23
+ signal.removeEventListener("abort", onAbort);
24
+ }
25
+ }
@@ -11,4 +11,3 @@ export declare function reasoningLevelFallbackWarning(input: {
11
11
  code: string;
12
12
  };
13
13
  };
14
- //# sourceMappingURL=reasoning-level-fallback.d.ts.map
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * 存的推理强度当前型号不认、这一轮没用上它时发的 `runtime.warning` 载荷。客户端按 `detail.code` 用本地化文案重画;
3
3
  * `message` 是英文兜底,只给不认这个 code 的表面。`appliedEffort` 缺席表示实际档位由 agent 定,不能说成默认档。
4
+ * `@ycodium-ai/plugin-api` 与 `ycodium-acp-executor` 共用这一份。本包不发布,
5
+ * 两个发布包构建时由 scripts/lib/inline-private-packages.mjs 把它内联进各自的 dist。
4
6
  */
5
7
  const REASONING_LEVEL_FALLBACK_CODE = "reasoning-level-fallback";
6
8
  export function reasoningLevelFallbackWarning(input) {
@@ -18,4 +20,3 @@ export function reasoningLevelFallbackWarning(input) {
18
20
  },
19
21
  };
20
22
  }
21
- //# sourceMappingURL=reasoning-level-fallback.js.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 已脱敏 stderr 的末尾一段:`@ycodium-ai/plugin-api` 与 `ycodium-acp-executor` 共用这一份。本包不发布,
3
+ * 两个发布包构建时由 scripts/lib/inline-private-packages.mjs 把它内联进各自的 dist。
4
+ */
5
+ /**
6
+ * 末尾不超过 `maxChars` 字。能从整行开始就从整行开始;只有一行时照字数截,但不劈开代理对,
7
+ * 截点落在脱敏标记里就从标记之后开始。调用方先 trim。
8
+ */
9
+ export declare function lastStderrTail(text: string, maxChars: number): string;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * 已脱敏 stderr 的末尾一段:`@ycodium-ai/plugin-api` 与 `ycodium-acp-executor` 共用这一份。本包不发布,
3
+ * 两个发布包构建时由 scripts/lib/inline-private-packages.mjs 把它内联进各自的 dist。
4
+ */
5
+ /** `redactStderrExcerpt` 换进去的标记:截尾时不能只留半个。 */
6
+ const REDACTION_MARKERS = ["[redacted]", "[pairing-url]"];
7
+ /**
8
+ * 末尾不超过 `maxChars` 字。能从整行开始就从整行开始;只有一行时照字数截,但不劈开代理对,
9
+ * 截点落在脱敏标记里就从标记之后开始。调用方先 trim。
10
+ */
11
+ export function lastStderrTail(text, maxChars) {
12
+ if (text.length <= maxChars)
13
+ return text;
14
+ let start = text.length - maxChars;
15
+ if (text[start - 1] !== "\n") {
16
+ const lineEnd = text.indexOf("\n", start);
17
+ if (lineEnd !== -1 && lineEnd < text.length - 1)
18
+ return text.slice(lineEnd + 1);
19
+ const code = text.charCodeAt(start);
20
+ if (code >= 0xdc00 && code <= 0xdfff)
21
+ start += 1;
22
+ for (const marker of REDACTION_MARKERS) {
23
+ const at = text.lastIndexOf(marker, start);
24
+ if (at !== -1 && at < start && start < at + marker.length)
25
+ start = at + marker.length;
26
+ }
27
+ }
28
+ return text.slice(start);
29
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * 工具活动摘要行的唯一规则:ACP 执行器与 `@ycodium/shared/toolActivity`(服务器、客户端)共用。
3
+ * 本包不发布;`ycodium-acp-executor` 构建时把它内联进 dist,shared 直接引源码。只依赖本模块自己。
4
+ */
5
+ export declare function normalizeCommandValue(value: unknown): string | undefined;
6
+ export declare function extractToolCommand(data: Record<string, unknown> | undefined, title: string | undefined): string | undefined;
7
+ export type ToolActivityPresentation = {
8
+ readonly summary: string;
9
+ readonly detail?: string;
10
+ };
11
+ /** `itemType` 收宿主 `ToolLifecycleItemType` 的全集;规则只认其中三种。 */
12
+ export interface ToolActivityPresentationInput {
13
+ readonly itemType?: string | null | undefined;
14
+ readonly title?: string | null | undefined;
15
+ readonly detail?: string | null | undefined;
16
+ readonly data?: unknown;
17
+ readonly fallbackSummary?: string | null | undefined;
18
+ }
19
+ export declare function deriveToolActivityPresentation(input: ToolActivityPresentationInput): ToolActivityPresentation;