@opencow-ai/opencow-agent-sdk 0.4.24 → 0.4.26
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/dist/capabilities/mcp/codexConfigFields.d.ts +20 -0
- package/dist/capabilities/mcp/envExpansion.d.ts +4 -1
- package/dist/capabilities/plugins/lspPluginIntegration.d.ts +1 -0
- package/dist/capabilities/plugins/mcpPluginIntegration.d.ts +1 -0
- package/dist/cli.mjs +63944 -76705
- package/dist/client.js +31389 -92985
- package/dist/constants/envVars.d.ts +5 -0
- package/dist/controller/loop.d.ts +5 -0
- package/dist/entrypoints/sdk/runtimeTypes.d.ts +16 -0
- package/dist/providers/shared/retry.d.ts +33 -1
- package/dist/sdk.js +31389 -92985
- package/dist/session/attachments.d.ts +9 -0
- package/dist/session/tokens.d.ts +2 -1
- package/dist/types/plugin.d.ts +5 -0
- package/dist/types/replayState.d.ts +13 -0
- package/package.json +1 -1
|
@@ -235,6 +235,11 @@ export declare const ENV_VARS: {
|
|
|
235
235
|
readonly DEBUG_INPUT: EnvVarSpec;
|
|
236
236
|
readonly DISABLE_EARLY_INPUT: EnvVarSpec;
|
|
237
237
|
readonly ENABLE_EXTENDED_KEYS: EnvVarSpec;
|
|
238
|
+
readonly ENABLE_STREAM_WATCHDOG: EnvVarSpec;
|
|
239
|
+
readonly SKILL_LISTING: EnvVarSpec;
|
|
240
|
+
readonly STREAM_IDLE_TIMEOUT_MS: EnvVarSpec;
|
|
241
|
+
readonly UNBOUNDED_CONNECTION_RETRY: EnvVarSpec;
|
|
242
|
+
readonly STREAM_REPLAY_RETRIES: EnvVarSpec;
|
|
238
243
|
readonly USE_READABLE_STDIN: EnvVarSpec;
|
|
239
244
|
};
|
|
240
245
|
export type EnvVarKey = keyof typeof ENV_VARS;
|
|
@@ -26,6 +26,11 @@ export declare function adjustParamsForNonStreaming<T extends {
|
|
|
26
26
|
* tool schemas, session identity, caching strategy, and host callbacks.
|
|
27
27
|
*/
|
|
28
28
|
export type Options = {
|
|
29
|
+
/**
|
|
30
|
+
* 内部:由 replayStreamOnTransportError 置位。为 true 时,读流阶段的可重放传输错误
|
|
31
|
+
* (且尚无完整消息送出)作为异常抛给调用方重放,而不是转成 assistant 错误消息。
|
|
32
|
+
*/
|
|
33
|
+
streamReplayEscape?: boolean;
|
|
29
34
|
getToolPermissionContext: () => Promise<ToolPermissionContext>;
|
|
30
35
|
model: string;
|
|
31
36
|
toolChoice?: BetaToolChoiceTool | BetaToolChoiceAuto | undefined;
|
|
@@ -149,6 +149,12 @@ export type SdkManagedPlugin = {
|
|
|
149
149
|
contentHash: string;
|
|
150
150
|
dataPath: string;
|
|
151
151
|
permissionGrant: SdkPluginPermissionGrant;
|
|
152
|
+
/**
|
|
153
|
+
* Host-supplied runtime environment values for this plugin's components
|
|
154
|
+
* (e.g. a third-party token the user entered in the host UI). Values take
|
|
155
|
+
* precedence over the ambient process env and stay scoped to this plugin.
|
|
156
|
+
*/
|
|
157
|
+
env?: Record<string, string>;
|
|
152
158
|
};
|
|
153
159
|
export type SdkPluginSnapshot = {
|
|
154
160
|
revision: string;
|
|
@@ -362,6 +368,16 @@ export type Options = {
|
|
|
362
368
|
* query startup never blocks on host skill resolution.
|
|
363
369
|
*/
|
|
364
370
|
skillCommandsProvider?: () => Promise<readonly unknown[]>;
|
|
371
|
+
/**
|
|
372
|
+
* 技能清单附件(`skill_listing`)总开关,默认 `true`(行为与未加开关前一致)。
|
|
373
|
+
*
|
|
374
|
+
* 置 `false` 后 SDK 不再把技能清单作为附件挂到用户消息上——用于 host 自己在
|
|
375
|
+
* 系统提示里维护技能目录、并自行通知技能增删变化的场景。技能正文仍走 Skill
|
|
376
|
+
* 工具按名加载,不受影响。
|
|
377
|
+
*
|
|
378
|
+
* 进程级等价物为 `OPENCOW_SKILL_LISTING=0`;per-query 的显式选项优先于进程环境。
|
|
379
|
+
*/
|
|
380
|
+
skillListing?: boolean;
|
|
365
381
|
/**
|
|
366
382
|
* Phase 1B.11d — host-provided agent definitions. Each entry is merged
|
|
367
383
|
* into the internal agent list used by the built-in AgentTool. Type is
|
|
@@ -1,16 +1,48 @@
|
|
|
1
1
|
import type Anthropic from '@anthropic-ai/sdk';
|
|
2
|
-
import { APIError } from '@anthropic-ai/sdk';
|
|
2
|
+
import { APIConnectionError, APIError } from '@anthropic-ai/sdk';
|
|
3
3
|
import type { QuerySource } from 'src/constants/querySource.js';
|
|
4
4
|
import type { SystemAPIErrorMessage } from 'src/types/message.js';
|
|
5
5
|
import type { ThinkingConfig } from '../../lib/thinking.js';
|
|
6
6
|
export declare const BASE_DELAY_MS = 500;
|
|
7
|
+
/**
|
|
8
|
+
* 200 头已到、读 body 时连接被切断,Anthropic SDK 抛的是原始 TypeError,
|
|
9
|
+
* 不经过它自己的连接错误包装;不补包装就会落入下方「非 APIError 不重试」。
|
|
10
|
+
* 只认传输特征(cause 带系统错误码或固定文案),普通 TypeError 仍按程序错误处理。
|
|
11
|
+
*/
|
|
12
|
+
export declare function wrapBodyTransportError(error: unknown): unknown;
|
|
13
|
+
/** 读流阶段的传输中断(对端关闭、socket 断开、空闲看门狗中止)可以整条请求重放;其余不行。 */
|
|
14
|
+
export declare function toReplayableStreamError(error: unknown): APIConnectionError | null;
|
|
15
|
+
/**
|
|
16
|
+
* 流式响应读到一半断开、且还没有任何完整消息送出时,整个流式请求重放。
|
|
17
|
+
* 只在宿主显式给出重放次数时启用(默认 0 = 关闭,行为不变)。
|
|
18
|
+
* `run(escapable)`:前 maxReplays 次尝试 escapable=true,允许 queryModel 把可重放的流错误
|
|
19
|
+
* 作为异常抛出(否则它会把错误转成一条 assistant 错误消息);最后一次 escapable=false,
|
|
20
|
+
* 错误照常转成消息,所以总尝试次数是 maxReplays + 1,最终报错文案与不开启时一致。
|
|
21
|
+
* 已有完整 assistant 消息送出(工具可能已在执行)则不重放,避免重复执行;
|
|
22
|
+
* 重放前送出的 stream_event 半截内容由新的 message_start 取代。
|
|
23
|
+
* 建立连接阶段的失败由 withRetry 处理,这里只管读流阶段。
|
|
24
|
+
*/
|
|
25
|
+
export declare function replayStreamOnTransportError<T extends {
|
|
26
|
+
type: string;
|
|
27
|
+
}>(run: (escapable: boolean) => AsyncGenerator<T, void>, options: {
|
|
28
|
+
maxReplays: number;
|
|
29
|
+
signal?: AbortSignal;
|
|
30
|
+
delayMs?: (replay: number) => number;
|
|
31
|
+
}): AsyncGenerator<T | SystemAPIErrorMessage, void>;
|
|
32
|
+
export declare function getConnectionWaitDelay(attempt: number, backoff?: ConnectionWaitBackoff, random?: () => number): number;
|
|
7
33
|
export interface RetryContext {
|
|
8
34
|
maxTokensOverride?: number;
|
|
9
35
|
model: string;
|
|
10
36
|
thinkingConfig: ThinkingConfig;
|
|
11
37
|
fastMode?: boolean;
|
|
12
38
|
}
|
|
39
|
+
export interface ConnectionWaitBackoff {
|
|
40
|
+
initialMs: number;
|
|
41
|
+
maxMs: number;
|
|
42
|
+
}
|
|
13
43
|
interface RetryOptions {
|
|
44
|
+
/** 连接错误等待的退避节奏,默认 5s 起翻倍、上限 60s;主要供测试缩短等待。 */
|
|
45
|
+
connectionWaitBackoff?: ConnectionWaitBackoff;
|
|
14
46
|
maxRetries?: number;
|
|
15
47
|
model: string;
|
|
16
48
|
fallbackModel?: string;
|