@qoder-ai/qoder-agent-sdk 1.0.55 → 1.0.57

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.
@@ -7,12 +7,15 @@ import type { DiagnosticsSink } from "../core/sdk-diagnostics.js";
7
7
  export declare const SESSION_STORE_FILE_CHECKPOINTING_CAPABILITY = "session_store_file_checkpointing_v1";
8
8
  export declare const SESSION_STORE_FORK_BARRIER_CAPABILITY = "session_store_fork_barrier_v1";
9
9
  /**
10
- * 心跳判死阈值:30s 无任何入站帧即判 daemon 失活。与 CLI 仓
11
- * DAEMON_KEEP_ALIVE_INTERVAL_MS(5s 发送周期,本值 = 6 周期)镜像;能力常量
10
+ * 心跳判死阈值:120s 无任何入站字节即判 daemon 失活。与 CLI 仓
11
+ * DAEMON_KEEP_ALIVE_INTERVAL_MS(5s 发送周期,本值 = 24 周期)镜像;能力常量
12
12
  * DAEMON_KEEP_ALIVE_CAPABILITY 同为两仓镜像,靠握手协商门控——组合不匹配时
13
13
  * 最多不武装看门狗,不会误判。
14
+ *
15
+ * 阈值取 120s 而不是 30s:daemon 是共享进程,AI 代码统计等可选后台工作可能在
16
+ * 主线程上产生数十秒的计算停顿;30s 会把「忙」误判成「死」,连带终止全部会话。
14
17
  */
15
- export declare const DAEMON_HEARTBEAT_TIMEOUT_MS = 30000;
18
+ export declare const DAEMON_HEARTBEAT_TIMEOUT_MS = 120000;
16
19
  export declare const DAEMON_KEEP_ALIVE_CAPABILITY = "daemon_keep_alive_v1";
17
20
  /**
18
21
  * daemon 会话 close 改成「关信道即回包、后台排干 teardown」的能力位(CLI 仓镜像)。
@@ -63,6 +66,12 @@ export interface DaemonInitializeOptions {
63
66
  * An empty string clears a previously configured proxy.
64
67
  */
65
68
  proxy?: string;
69
+ /**
70
+ * Proxy bypass list applied during the handshake (`daemon_proxy_bypass_v1`).
71
+ * Replaces `NO_PROXY` / `no_proxy` in the daemon process; an empty string
72
+ * clears both.
73
+ */
74
+ noProxy?: string;
66
75
  }
67
76
  export type DaemonRequestHandler = (request: DaemonControlRequestFrame) => Promise<JsonValue>;
68
77
  export declare class DaemonRpcError extends Error {
@@ -111,7 +120,12 @@ export interface DaemonSessionIdClaim {
111
120
  export declare class DaemonHeartbeatTimeoutError extends Error {
112
121
  readonly code = "DAEMON_HEARTBEAT_TIMEOUT";
113
122
  readonly elapsedMs: number;
114
- constructor(elapsedMs: number);
123
+ /**
124
+ * 判死时是否正处在一条未收完的帧中间:区分「daemon 完全静默」与「大帧传到一半
125
+ * 停住」。两者都是连接级失败;该字段只用于现场归因,不改变判定与传播路径。
126
+ */
127
+ readonly partialFrame: boolean;
128
+ constructor(elapsedMs: number, partialFrame?: boolean);
115
129
  }
116
130
  export declare class DaemonConnection {
117
131
  private readonly input;
@@ -156,11 +170,20 @@ export declare class DaemonConnection {
156
170
  private readonly describeUnexpectedClose;
157
171
  private readonly diagnostics;
158
172
  /**
159
- * 心跳看门狗:最近一次入站帧的单调钟时刻(任意入站帧都刷新——有正常会话流量
160
- * 时天然免检,keep_alive 只是空闲期保底节拍)。单调钟使机器睡眠/唤醒后差值仍小,
161
- * 不误杀。看门狗定时器与阈值见 armHeartbeatWatchdog。
173
+ * 心跳看门狗:最近一次**入站字节**的单调钟时刻(每个 chunk 都刷新——有正常会话
174
+ * 流量时天然免检,keep_alive 只是空闲期保底节拍)。
175
+ *
176
+ * 不能等整行收完再刷新:一条大帧(单个 tool 结果可达数 MiB)在慢速管道上可能连续
177
+ * 传输超过阈值,期间字节一直在到达、事件循环也正常,只是换行符还没出现。以行为
178
+ * 单位会把它误判成「daemon 失活」,进而 fail() 整条连接、连带杀掉全部会话。
179
+ * 单调钟使机器睡眠/唤醒后差值仍小,不误杀。看门狗定时器与阈值见 armHeartbeatWatchdog。
162
180
  */
163
181
  private lastInboundAt;
182
+ /**
183
+ * 是否正处在一条尚未收完的 NDJSON 帧中间。只用于判死时的诊断:区分「daemon 完全
184
+ * 静默」与「大帧传到一半停住」,不参与是否判死的判定(后者只看字节进展)。
185
+ */
186
+ private inboundFrameInProgress;
164
187
  private heartbeatWatchdog;
165
188
  private readonly heartbeatTimeoutMs;
166
189
  constructor(options: DaemonConnectionOptions);
@@ -170,8 +193,21 @@ export declare class DaemonConnection {
170
193
  /**
171
194
  * Switches the daemon-level (process-wide) proxy, or clears it with
172
195
  * `undefined` / `null` / an empty string. Returns the normalized value.
196
+ *
197
+ * `noProxy` omitted leaves the current bypass list unchanged; `null`
198
+ * restores the value inherited at daemon startup; a string replaces both
199
+ * `NO_PROXY` and `no_proxy`.
200
+ */
201
+ setProxy(proxy?: string | null, noProxy?: string | null): Promise<string | null>;
202
+ /**
203
+ * Same as `setProxy`, but also returns the effective bypass list. Gated on
204
+ * `daemon_proxy_bypass_v1` when `noProxy` is supplied so an older CLI cannot
205
+ * silently ignore the field.
173
206
  */
174
- setProxy(proxy?: string | null): Promise<string | null>;
207
+ setProxySettings(proxy?: string | null, noProxy?: string | null): Promise<{
208
+ proxy: string | null;
209
+ noProxy: string | null;
210
+ }>;
175
211
  /**
176
212
  * 同步占用一个声明 id。opening/open 直接抛冲突;closing 则排队,ready 在
177
213
  * 前一次 close 出清后兑现。未声明 id(daemon 现 mint)不会撞,调用方不占用。
@@ -8,6 +8,8 @@ export interface InitDaemonOptions {
8
8
  /** 语义同 `StartDaemonOptions.executableArgs`。 */
9
9
  executableArgs?: string[];
10
10
  proxy?: string;
11
+ /** 语义同 `StartDaemonOptions.noProxy`。 */
12
+ noProxy?: string;
11
13
  /** 语义同 `StartDaemonOptions.vpcEndpoint`。 */
12
14
  vpcEndpoint?: string;
13
15
  env?: Record<string, string | undefined>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * JSON.stringify leaves U+2028/U+2029 raw inside strings. They are valid JSON,
3
+ * but Node's readline treats them as line breaks, which splits one NDJSON frame
4
+ * into several. Escape them so every reader that only honours "\n" stays compatible.
5
+ */
6
+ export declare function escapeJsonLineSeparators(line: string): string;
7
+ /**
8
+ * Split an NDJSON stream on "\n" only. CRLF is accepted by stripping the
9
+ * trailing "\r"; U+2028/U+2029 remain content and are never treated as
10
+ * terminators.
11
+ */
12
+ export declare function readNdjsonLines(input: AsyncIterable<Buffer | string>): AsyncGenerator<string>;
@@ -28,6 +28,13 @@ export declare const DAEMON_VALIDATE_PLUGINS_CAPABILITY = "daemon_validate_plugi
28
28
  * and switch it later via `daemon.setproxy`.
29
29
  */
30
30
  export declare const DAEMON_PROXY_CAPABILITY = "daemon_proxy_v1";
31
+ /**
32
+ * The daemon accepts a `no_proxy` bypass list alongside the process-wide proxy
33
+ * (`initialize` and `daemon.setproxy`), and applies it to its own environment.
34
+ * Older CLIs ignore the field, so callers must gate on this capability instead
35
+ * of assuming the bypass list was applied.
36
+ */
37
+ export declare const DAEMON_PROXY_BYPASS_CAPABILITY = "daemon_proxy_bypass_v1";
31
38
  export type JsonPrimitive = string | number | boolean | null;
32
39
  export type JsonValue = JsonPrimitive | JsonValue[] | {
33
40
  [key: string]: JsonValue;
@@ -78,12 +85,26 @@ export interface DaemonSessionUpdatedStatusEventFrame {
78
85
  export interface KeepAliveFrame {
79
86
  type: "keep_alive";
80
87
  }
88
+ /**
89
+ * Connection-level fatal signal emitted by the CLI when its NDJSON reader
90
+ * cannot recover the frame boundary (for example one user message split into
91
+ * multiple lines). It carries metadata only, never frame content.
92
+ */
93
+ export interface DaemonProtocolErrorFrame {
94
+ type: "protocol_error";
95
+ code: string;
96
+ message?: string;
97
+ malformed_lines?: number;
98
+ malformed_bytes?: number;
99
+ last_frame_type?: string;
100
+ last_frame_session_id?: string;
101
+ }
81
102
  /** A raw Query message carrying a daemon-local Session route. */
82
103
  export type DaemonWireSessionMessage = JsonObject & {
83
104
  type: string;
84
105
  session_id?: string;
85
106
  };
86
- export type DaemonProtocolFrame = DaemonControlRequestFrame | DaemonControlResponseFrame | DaemonSessionUpdatedStatusEventFrame | KeepAliveFrame | DaemonWireSessionMessage;
107
+ export type DaemonProtocolFrame = DaemonControlRequestFrame | DaemonControlResponseFrame | DaemonSessionUpdatedStatusEventFrame | KeepAliveFrame | DaemonProtocolErrorFrame | DaemonWireSessionMessage;
87
108
  export type InitializeDaemonParams = {
88
109
  daemon_protocol_version: typeof DAEMON_PROTOCOL_VERSION;
89
110
  sdk_version: string;
@@ -102,6 +123,12 @@ export type InitializeDaemonParams = {
102
123
  * empty string clears a previously configured proxy.
103
124
  */
104
125
  proxy?: string;
126
+ /**
127
+ * Proxy bypass list applied during the handshake (`daemon_proxy_bypass_v1`).
128
+ * Replaces `NO_PROXY` / `no_proxy` in the daemon process; an empty string
129
+ * clears both.
130
+ */
131
+ no_proxy?: string;
105
132
  };
106
133
  export type InitializeDaemonResult = {
107
134
  daemon_protocol_version: typeof DAEMON_PROTOCOL_VERSION;
@@ -260,9 +287,17 @@ export type DaemonValidatePluginsResult = {
260
287
  export type DaemonSetProxyParams = {
261
288
  /** `null` clears the daemon-level proxy. */
262
289
  proxy: string | null;
290
+ /**
291
+ * Replaces the daemon's `NO_PROXY` / `no_proxy`. `null` restores the value
292
+ * inherited at daemon startup; an empty string clears both. Omitted leaves
293
+ * the current bypass list unchanged.
294
+ */
295
+ no_proxy?: string | null;
263
296
  };
264
297
  export type DaemonSetProxyResult = {
265
298
  proxy: string | null;
299
+ /** Present only when the request carried `no_proxy`. */
300
+ no_proxy?: string | null;
266
301
  };
267
302
  export type DaemonGetUsageInfoParams = Record<string, never>;
268
303
  export type DaemonGetUsageInfoResult = {
@@ -39,6 +39,12 @@ export interface StartDaemonOptions {
39
39
  * at any later point, whenever something first triggers the landing.
40
40
  */
41
41
  initializeTimeoutMs?: number;
42
+ /**
43
+ * 心跳看门狗阈值(ms):超过这段时间没有任何入站字节即判 daemon 失活。
44
+ * 缺省 120s;0 关闭看门狗(逃生口)。只在 CLI 协商出 `daemon_keep_alive_v1` 后生效。
45
+ * 宿主一般不需要调整;测试与受限环境用它缩短判定窗口。
46
+ */
47
+ heartbeatTimeoutMs?: number;
42
48
  pathToQoderCLIExecutable?: string;
43
49
  /**
44
50
  * 运行 CLI 脚本入口的解释器(node/bun/deno 等),语义与 `query()` 的
@@ -55,6 +61,12 @@ export interface StartDaemonOptions {
55
61
  * 账号面与所有会话(`daemon_proxy_v1`)。运行期可用 `daemon.setProxy()` 切换。
56
62
  */
57
63
  proxy?: string;
64
+ /**
65
+ * daemon 进程级代理绕过名单:握手时随 `daemon.initialize` 写入
66
+ * `NO_PROXY` / `no_proxy`(`daemon_proxy_bypass_v1`)。空串表示清空;
67
+ * 运行期可用 `daemon.setProxy(proxy, { noProxy })` 切换或恢复。
68
+ */
69
+ noProxy?: string;
58
70
  /**
59
71
  * VPC private-deployment endpoint for the daemon process (CN deployments only).
60
72
  * Written to `QODERCN_VPC_ENDPOINT` / `QODER_VPC_ENDPOINT` before spawn; the CLI
@@ -105,13 +117,26 @@ export interface Daemon {
105
117
  * Set or clear the daemon-level (process-wide) proxy for every Session.
106
118
  * `undefined` / `null` / an empty string clears it. Requires
107
119
  * `daemon_proxy_v1`; resolves with the normalized proxy (or null).
120
+ *
121
+ * `options.noProxy` replaces the daemon's bypass list (`null` restores the
122
+ * value inherited at startup, an empty string clears it). Supplying it
123
+ * requires `daemon_proxy_bypass_v1`; omitting it leaves the current list
124
+ * unchanged.
108
125
  */
109
- setProxy(proxy?: string | null): Promise<string | null>;
126
+ setProxy(proxy?: string | null, options?: {
127
+ noProxy?: string | null;
128
+ }): Promise<string | null>;
110
129
  /**
111
130
  * The daemon-level proxy currently in effect (`null` when unset/cleared, or
112
131
  * when the CLI does not support `daemon_proxy_v1`).
113
132
  */
114
133
  getProxy(): string | null;
134
+ /**
135
+ * The daemon-level proxy bypass list currently tracked by the SDK (`null`
136
+ * when unset/cleared or when the CLI does not support
137
+ * `daemon_proxy_bypass_v1`).
138
+ */
139
+ getNoProxy(): string | null;
115
140
  /**
116
141
  * Explicitly lands credentials and reports whether the daemon is authenticated.
117
142
  *
@@ -182,6 +207,12 @@ interface InternalDaemonRuntime {
182
207
  /** Local CLI launch context for feedback that bypasses the daemon. */
183
208
  readonly hostActionLaunch: {
184
209
  proxy?: string;
210
+ /**
211
+ * `undefined` uses the env as-is; `null` also uses the env (the CLI
212
+ * restored its startup value); a string overrides `NO_PROXY` / `no_proxy`
213
+ * for the one-shot CLI launch.
214
+ */
215
+ noProxy?: string | null;
185
216
  cliPath?: string;
186
217
  env?: Record<string, string | undefined>;
187
218
  };
@@ -198,6 +229,11 @@ interface InternalDaemonRuntime {
198
229
  * when the CLI ignored the handshake proxy). Updated by `setProxy`.
199
230
  */
200
231
  proxy: string | null;
232
+ /**
233
+ * The daemon-level proxy bypass list currently applied by the CLI (`null`
234
+ * when unset, or when the CLI does not support bypass updates).
235
+ */
236
+ noProxy: string | null;
201
237
  readonly transportProvider: QueryTransportProvider<ProcessTransportOptions>;
202
238
  }
203
239
  export declare function getDaemonRuntime(daemon: Daemon): InternalDaemonRuntime | undefined;
package/dist/index.d.ts CHANGED
@@ -60,7 +60,7 @@ export type { DaemonFallbackReason, DaemonInitResult, InitDaemonOptions, } from
60
60
  export { startDaemon } from './daemon/start-daemon.js';
61
61
  export type { Daemon, DaemonState, DaemonSessionInfo, SessionRuntimeState, StartDaemonOptions, } from './daemon/start-daemon.js';
62
62
  export type { DaemonGetModelsParams, DaemonValidateByokModelParams, DaemonValidatePluginsParams, DaemonSetProxyParams, } from './daemon/protocol.js';
63
- export { DAEMON_PROXY_CAPABILITY, DAEMON_VALIDATE_PLUGINS_CAPABILITY, } from './daemon/protocol.js';
63
+ export { DAEMON_PROXY_BYPASS_CAPABILITY, DAEMON_PROXY_CAPABILITY, DAEMON_VALIDATE_PLUGINS_CAPABILITY, } from './daemon/protocol.js';
64
64
  export { DEFAULT_RUNTIME_TRANSPORT, } from './core/default-runtime.js';
65
65
  export { ProcessTransport, QoderCliProcessError, } from './core/process-transport.js';
66
66
  export { hasResolvableQoderWorkerRuntime, QoderWorkerRuntimeError, WorkerTransport, resolveQoderWorkerRuntimePath, } from './core/worker-transport.js';
@@ -96,7 +96,7 @@ export type { AccessTokenInput, AuthOptions, FetchServiceAccountToken, ServiceAc
96
96
  */
97
97
  export type { FetchJobToken, JobTokenAuthOptions, JobTokenRequest, JobTokenResult, } from './types/auth.js';
98
98
  export type { Base64ImageSource, UrlImageSource, URLImageSource, ImageSource, ImageContentBlock, ImageBlockParam, ContentBlock, MessageParam, AccountInfo, UsageAddOnQuotaBucket, UsageInfo, UsageOrgResourcePackage, UsageQuotaBucket, SessionCreditsUsage, ApiKeySource, ExitReason, FastModeState, ConfigScope, SettingSource, SDKAssistantMessageError, SDKStatus, EffortLevel, ThinkingAdaptive, ThinkingEnabled, ThinkingDisabled, ThinkingConfig, ModelInfo, ModelSource, ServerModelJson, ServerModelJsonValue, ModelStrategy, ModelPromotion, LocalizedModelText, ModelContextConfig, ModelContextWindowEntry, ModelEffortEntry, ModelThinkingConfig, ModelThinkingDisabled, ModelThinkingEnabled, ModelUsage, NonNullableUsage, SlashCommand, ToolConfig, SdkPluginConfig, } from './types/common.js';
99
- export type { SDKMessage, SDKAssistantMessage, SDKToolNonExecutionKind, SDKToolResultMeta, SDKMessageOrigin, SDKSelectedSkill, SDKArtifactInfo, SDKArtifactUpdateMessage, SDKAvailableModelsUpdateMessage, SDKCommandsChangedMessage, SDKUserMessage, SDKUserMessageReplay, SDKResultMessage, SDKResultSuccess, SDKResultError, SDKSystemMessage, SDKSystemInitMessage, SDKSystemMessageSubtype, SDKSystemMessageBySubtype, SDKPartialAssistantMessage, SDKCompactBoundaryMessage, SDKStatusMessage, SDKAPIRetryMessage, SDKModelQueueStatusMessage, SDKControlRequestProgressMessage, SDKCommandLifecycleMessage, SDKHookStartedMessage, SDKHookProgressMessage, SDKHookResponseMessage, SDKPermissionDeniedMessage, SDKMirrorErrorMessage, SDKTaskNotificationMessage, SDKTaskStartedMessage, SDKTaskProgressMessage, SDKTaskUpdatedMessage, SDKBackgroundTasksChangedMessage, SDKSessionStateChangedMessage, SDKPlanModeChangedMessage, SDKSessionTitleChangedMessage, SDKFilesPersistedEvent, SDKElicitationCompleteMessage, SDKPromptSuggestionMessage, SDKCloudAgentEventMessage, SDKMemoryGenerationMessage, SDKMemoryConsumptionMessage, SDKSkillEvolutionMessage, SDKAgentsMdSizeWarningMessage, SDKPermissionDenial, } from './types/messages.js';
99
+ export type { SDKMessage, SDKAssistantMessage, SDKToolNonExecutionKind, SDKToolResultMeta, SDKMessageOrigin, SDKSelectedSkill, SDKArtifactInfo, SDKArtifactUpdateMessage, SDKAvailableModelsUpdateMessage, SDKCommandsChangedMessage, SDKUserMessage, SDKUserMessageReplay, SDKResultMessage, SDKResultSuccess, SDKResultError, SDKSystemMessage, SDKSystemInitMessage, SDKSystemMessageSubtype, SDKSystemMessageBySubtype, SDKPartialAssistantMessage, SDKCompactBoundaryMessage, SDKStatusMessage, SDKAPIRetryMessage, SDKModelQueueStatusMessage, SDKControlRequestProgressMessage, SDKCommandLifecycleMessage, SDKToolProgressMessage, SDKHookDiagnosticsMessage, SDKHookStartedMessage, SDKHookProgressMessage, SDKHookResponseMessage, SDKPermissionDeniedMessage, SDKMirrorErrorMessage, SDKTaskNotificationMessage, SDKTaskStartedMessage, SDKTaskProgressMessage, SDKTaskUpdatedMessage, SDKBackgroundTasksChangedMessage, SDKSessionStateChangedMessage, SDKPlanModeChangedMessage, SDKSessionTitleChangedMessage, SDKFilesPersistedEvent, SDKElicitationCompleteMessage, SDKPromptSuggestionMessage, SDKCloudAgentEventMessage, SDKMemoryGenerationMessage, SDKMemoryConsumptionMessage, SDKSkillEvolutionMessage, SDKAgentsMdSizeWarningMessage, SDKPermissionDenial, } from './types/messages.js';
100
100
  export type { DefaultRuntimeTransport, } from './core/default-runtime.js';
101
101
  export type { QueryTransportCreateOptions, QueryTransportProviderOption, } from './core/query-transport.js';
102
102
  export type { ProcessTransportOptions } from './core/process-transport.js';