@yitom/acp-client 0.1.13 → 0.1.14
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 +16 -41
- package/dist/client/acp-client.d.ts +17 -2
- package/dist/client/client-handlers.d.ts +3 -3
- package/dist/client/mcp-session-recovery.d.ts +47 -0
- package/dist/client/sdk-client.d.ts +2 -6
- package/dist/client/session-open.d.ts +14 -7
- package/dist/contracts/index.d.ts +0 -27
- package/dist/index.cjs +3658 -3474
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3676 -3493
- package/dist/mcp/connection-health.d.ts +21 -0
- package/dist/resources/app-resources.d.ts +0 -7
- package/dist/resources/runtime-bindings.d.ts +1 -6
- package/dist/runtimes/codex/codex-auth-preflight.d.ts +1 -1
- package/dist/runtimes/codex/codex-code-mode-home.d.ts +54 -0
- package/dist/runtimes/codex/index.d.ts +1 -2
- package/dist/runtimes/deepseek/index.d.ts +16 -51
- package/dist/runtimes/deepseek/quota.d.ts +37 -19
- package/dist/runtimes/index.d.ts +2 -22
- package/dist/session/code-mode.d.ts +30 -0
- package/dist/session/quota.d.ts +0 -9
- package/dist/sidecar.cjs +3914 -3566
- package/dist/version.d.ts +1 -1
- package/docs/adding-an-agent.md +14 -0
- package/docs/api-reference.md +48 -124
- package/package.json +7 -6
- package/dist/runtimes/deepseek/deepseek-provider.d.ts +0 -50
- package/dist/runtimes/deepseek/dsh-acp-bootstrap.d.ts +0 -65
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** A host observation of MCP discovery/transport, independent of ACP and any UI. */
|
|
2
|
+
export interface AcpMcpHealthMonitor {
|
|
3
|
+
readonly discoveries: number;
|
|
4
|
+
readonly disconnects: number;
|
|
5
|
+
readonly hasDiscoveredClient: boolean;
|
|
6
|
+
waitForDiscovery(after: number, signal: AbortSignal, timeoutMs?: number): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
/** Call discovered after tools/list succeeds, and closed when its transport closes. */
|
|
9
|
+
export declare class McpConnectionHealth implements AcpMcpHealthMonitor {
|
|
10
|
+
private clients;
|
|
11
|
+
private listeners;
|
|
12
|
+
private discoveryCount;
|
|
13
|
+
private disconnectCount;
|
|
14
|
+
get discoveries(): number;
|
|
15
|
+
get disconnects(): number;
|
|
16
|
+
get hasDiscoveredClient(): boolean;
|
|
17
|
+
discovered(client: object): void;
|
|
18
|
+
closed(client: object): void;
|
|
19
|
+
needsRecovery(since: number): boolean;
|
|
20
|
+
waitForDiscovery(after: number, signal: AbortSignal, timeoutMs?: number): Promise<void>;
|
|
21
|
+
}
|
|
@@ -55,13 +55,6 @@ export declare function digestAppResources(load: AppResourceLoad): string | null
|
|
|
55
55
|
/** 读取常驻规则正文(适配器合并配置用;正文不出本作用域,只传摘要与长度)。 */
|
|
56
56
|
export declare function readAppRulesText(directory: string): string | null;
|
|
57
57
|
export interface AppResourceReport {
|
|
58
|
-
/** Prepared process overlay, not proof of runtime loading or UI MCP availability. */
|
|
59
|
-
openCodeQuestions?: {
|
|
60
|
-
version?: string;
|
|
61
|
-
mode: 'fallback' | 'unverified';
|
|
62
|
-
configuration: 'prepared' | 'unchanged';
|
|
63
|
-
reason: string;
|
|
64
|
-
};
|
|
65
58
|
/** Child-only isolated config roots; existence is not proof the runtime loaded rules. */
|
|
66
59
|
configurationScope?: 'session';
|
|
67
60
|
configurationDirectory?: string;
|
|
@@ -12,7 +12,7 @@ export declare const APP_RESOURCE_CAPABILITIES: {
|
|
|
12
12
|
readonly configHome: 'OPENCODE_CONFIG_DIR';
|
|
13
13
|
};
|
|
14
14
|
readonly 'opencode-v2': {
|
|
15
|
-
readonly entry:
|
|
15
|
+
readonly entry: null;
|
|
16
16
|
readonly strategy: 'compatibility';
|
|
17
17
|
readonly configHome: null;
|
|
18
18
|
};
|
|
@@ -50,11 +50,6 @@ export declare const APP_RESOURCE_CAPABILITIES: {
|
|
|
50
50
|
};
|
|
51
51
|
export declare function prepareCompatibilityResources(directory: string, reason: string): AppResourcePrep;
|
|
52
52
|
export declare function mergeOpenCodeAppConfig(raw: string | undefined, directory: string): string;
|
|
53
|
-
/** Verified: 1.18.35 acp/event.ts omits questions; the 2.0.6 Windows ACP
|
|
54
|
-
* dispatcher cancels form.created. Neither implies native resource loading. */
|
|
55
|
-
export declare function resolveOpenCodeQuestionMode(version: string): 'fallback' | 'unverified';
|
|
56
|
-
/** Child-only overlay; preserve unrelated permissions, providers and authentication. */
|
|
57
|
-
export declare function mergeOpenCodeQuestionConfig(raw: string | undefined): string;
|
|
58
53
|
export declare function prepareOpenCodeResources(input: {
|
|
59
54
|
directory: string;
|
|
60
55
|
env?: NodeJS.ProcessEnv;
|
|
@@ -2,7 +2,7 @@ import type { CodexAuthPreflight } from "../../contracts";
|
|
|
2
2
|
export type { CodexAuthPreflight };
|
|
3
3
|
export declare function emptyAcpAuthPreflight(): CodexAuthPreflight;
|
|
4
4
|
export declare function isCodexPreflightRuntime(runtimeId?: string): boolean;
|
|
5
|
-
export declare function resolveCodexHome(): string;
|
|
5
|
+
export declare function resolveCodexHome(env?: NodeJS.ProcessEnv): string;
|
|
6
6
|
/**
|
|
7
7
|
* 仅做布尔级探测,对齐 VS Code/Zed「复用本机 Codex 登录」:
|
|
8
8
|
* 不把 auth.json / token 读进渲染进程。
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Isolated CODEX_HOME for code mode.
|
|
3
|
+
*
|
|
4
|
+
* Codex resolves its whole configuration and login from `CODEX_HOME` (default
|
|
5
|
+
* `~/.codex`). Pointing a spawned `codex-acp` at an app-owned directory lets a
|
|
6
|
+
* host enable `features.code_mode` without touching the user's global config.
|
|
7
|
+
*
|
|
8
|
+
* The app directory is seeded from the user's home first (the preferred path):
|
|
9
|
+
* `auth.json` and `config.toml` are copied once, then `code_mode = true` is
|
|
10
|
+
* merged into `[features]`. Later runs keep the app copy; the user's home is
|
|
11
|
+
* never written.
|
|
12
|
+
*/
|
|
13
|
+
export interface CodexCodeModeHomeOptions {
|
|
14
|
+
/** App-owned directory; defaults to `~/.acp-client/codex-home`. */
|
|
15
|
+
home?: string;
|
|
16
|
+
/** Source to seed from; defaults to `CODEX_HOME` or `~/.codex`. */
|
|
17
|
+
sourceHome?: string;
|
|
18
|
+
/** Re-copy auth.json/config.toml even when the app copy already exists. */
|
|
19
|
+
force?: boolean;
|
|
20
|
+
/** Environment used for the default resolution (tests). */
|
|
21
|
+
env?: NodeJS.ProcessEnv;
|
|
22
|
+
}
|
|
23
|
+
export interface CodexCodeModeHomeResult {
|
|
24
|
+
home: string;
|
|
25
|
+
sourceHome: string;
|
|
26
|
+
authCopied: boolean;
|
|
27
|
+
configCopied: boolean;
|
|
28
|
+
codeModeEnabled: boolean;
|
|
29
|
+
warnings: string[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The app-owned Codex home.
|
|
33
|
+
*
|
|
34
|
+
* Resolution order (no machine-specific path is hardcoded):
|
|
35
|
+
* 1. `ACP_CODEX_HOME` — a full target directory;
|
|
36
|
+
* 2. `<base>/codex-home`, where base is the argument or `ACP_STUDIO_HOME`;
|
|
37
|
+
* 3. `<user home>/.acp-client/codex-home`.
|
|
38
|
+
*/
|
|
39
|
+
export declare function resolveAppCodexHome(baseDir?: string, env?: NodeJS.ProcessEnv): string;
|
|
40
|
+
/**
|
|
41
|
+
* Merge `code_mode = true` into the `[features]` table of a TOML document.
|
|
42
|
+
*
|
|
43
|
+
* Text-level on purpose: the user's config may carry comments, ordering and
|
|
44
|
+
* provider tables a TOML round-trip would rewrite. Existing keys are preserved;
|
|
45
|
+
* only the one line is replaced (or inserted) and a missing table is appended.
|
|
46
|
+
*/
|
|
47
|
+
export declare function withCodeModeEnabled(toml: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* Seed an isolated Codex home from the user's home and enable code mode.
|
|
50
|
+
*
|
|
51
|
+
* @param options - target directory, source home and force-copy flag.
|
|
52
|
+
* @returns what was copied and any non-fatal warning worth logging.
|
|
53
|
+
*/
|
|
54
|
+
export declare function provisionCodexCodeModeHome(options?: CodexCodeModeHomeOptions): Promise<CodexCodeModeHomeResult>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './quota';
|
|
2
|
+
export * from './codex-code-mode-home';
|
|
2
3
|
import type { CodexAuthPreflight, AcpAgentQuota } from "../../contracts";
|
|
3
4
|
import type { GenericRuntimeAdapter } from '../index';
|
|
4
5
|
import { type StoredAcpProvider } from './codex-provider';
|
|
@@ -9,8 +10,6 @@ export declare function provisionCustomProviderCodexHome(provider: StoredAcpProv
|
|
|
9
10
|
export interface CodexRuntimeAdapter extends GenericRuntimeAdapter {
|
|
10
11
|
probeQuota?: (options?: {
|
|
11
12
|
sessionId?: string;
|
|
12
|
-
dataDir?: string;
|
|
13
|
-
env?: NodeJS.ProcessEnv;
|
|
14
13
|
}) => Promise<AcpAgentQuota | null>;
|
|
15
14
|
id: 'codex-acp';
|
|
16
15
|
probeAuth: () => CodexAuthPreflight;
|
|
@@ -1,73 +1,38 @@
|
|
|
1
1
|
import type { CodexAuthPreflight } from "../../contracts";
|
|
2
2
|
import type { GenericRuntimeAdapter } from '../index';
|
|
3
|
-
export * from './dsh-acp-bootstrap';
|
|
4
|
-
export * from './deepseek-provider';
|
|
5
|
-
export * from './quota';
|
|
6
3
|
/**
|
|
7
|
-
* DeepSeek 运行时适配器(`dsh --profile acp`)。
|
|
4
|
+
* DeepSeek 运行时适配器(`bunx @deepseek-ai/dsh --profile acp`)。
|
|
8
5
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* 3. `DSH_PACKAGE`:npm 包定位符覆盖(如 pin `@deepseek-ai/dsh@0.2.1-rc.2`);
|
|
14
|
-
* 4. 缺省 `bunx -y @deepseek-ai/dsh@latest --profile acp`。
|
|
6
|
+
* 凭证复用:harness 自身凭证(`DEEPSEEK_API_KEY` 或 `$DSH_HOME/.credentials.yaml`,
|
|
7
|
+
* 全部留在官方位置,我方不存、不读内容)。harness 的 ACP `authMethods` 为空,
|
|
8
|
+
* 连接门闩天然走 `skip_auth`;此处探测仅供诊断展示。
|
|
9
|
+
* 模型经 session 到达(顶层 `models` 方言由 session-open 合成 model 选项),无需额外动作。
|
|
15
10
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* 用稳定安装的原因:bunx 把包装进临时目录,harness 的
|
|
23
|
-
* `$DSH_HOME/profiles/node_modules` 会把这些包软链到该临时目录;临时目录被系统
|
|
24
|
-
* 清理后 profile 立刻断链(实测 `bunx-<id>@deepseek-ai/dsh@latest` 已消失)。
|
|
25
|
-
*
|
|
26
|
-
* 凭证:harness 自身凭证(`DEEPSEEK_API_KEY` 或 `$DSH_HOME/.credentials.yaml`
|
|
27
|
-
* 里的登录记录,全部留在官方位置,我方不存)。harness 的 ACP `authMethods`
|
|
28
|
-
* 为空,连接门闩天然走 `skip_auth`;此处探测仅供诊断与预检。
|
|
29
|
-
*
|
|
30
|
-
* 缺凭证预检(仿 cursor `resolveSpawnCommand` 为 null 即拦的 precedent):
|
|
31
|
-
* 本机既无 key 也无 harness 登录记录时 harness 极可能直接退出(stdio 关闭→
|
|
32
|
-
* 传输层报 connection closed),故经 `resolveSpawnBlocker` 在 spawn 前判停,
|
|
33
|
-
* 回带中文动作指引。只认文档明确的变量:`DEEPSEEK_API_KEY`(预检)、
|
|
34
|
-
* `DSH_HOME`(凭证库位置)、`DSH_PACKAGE` / `DSH_BIN` / `DSH_RUNTIME_DIR`
|
|
35
|
-
* (启动目标覆盖)。
|
|
11
|
+
* 缺 key 预检(仿 cursor `resolveSpawnCommand` 为 null 即拦的 precedent):
|
|
12
|
+
* 本机既无 env key 也无 DSH 本地登录时 harness 极可能直接退出(stdio 关闭→传输层报
|
|
13
|
+
* connection closed),故经 `resolveSpawnBlocker` 在 spawn 前判停,回带中文动作指引。
|
|
14
|
+
* 同族 `DSH_*` 仅认文档明确的变量——`DSH_HOME`(本地登录位置)、`DEEPSEEK_API_KEY`
|
|
15
|
+
* (预检)与 `DSH_PACKAGE`(包定位符覆盖,见 `resolveDeepseekSpawnCommand`)。
|
|
36
16
|
*
|
|
37
17
|
* 上游坏包逃生(实锤:dsh 0.1.5-rc.2 内依赖 `…-documentpreview@^0.1.5-rc.3`,
|
|
38
18
|
* 而该包最高仅 0.1.6-alpha.1,上游缺 rc.3,自解析依赖失败退出):
|
|
39
19
|
* 设 `DSH_PACKAGE` pin 旧版(如 `@deepseek-ai/dsh@0.1.4`)即可绕过。
|
|
40
|
-
*
|
|
41
|
-
* 模型口径:ACP `session/new` 的 model 选项值是 `["provider","model"]` 的 JSON
|
|
42
|
-
* 串;官方 catalog 里 V4.1-Flash 的 id 是 `deepseek-flash`(桌面端 1017 徽标
|
|
43
|
-
* 只是 UI 标签,不是模型版本)。ACP 应用自带的补丁把默认模型写成了
|
|
44
|
-
* `deepseek-v4-flash`,需要 profile 层覆盖,见 docs/api-reference.md。
|
|
45
20
|
*/
|
|
46
21
|
export declare function buildDeepseekMissingKeyMessage(): string;
|
|
47
|
-
/** harness
|
|
48
|
-
export
|
|
49
|
-
/**
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
* 遇到下一个顶层键立即停止,避免把别的顶层字段误判成凭证。
|
|
53
|
-
*/
|
|
54
|
-
export declare function hasDshCredentials(env?: NodeJS.ProcessEnv): boolean;
|
|
55
|
-
/**
|
|
56
|
-
* 预检判停:显式 env 有 key、宿主表单已落库、或 harness 自己已登录,三者其一即放行。
|
|
57
|
-
* `dataDir` 用于读 URL+Token 表单落库;不传则只看 env 与 harness 凭证库。
|
|
58
|
-
*/
|
|
59
|
-
export declare function resolveDeepseekSpawnBlocker(env?: NodeJS.ProcessEnv, dataDir?: string): string | null;
|
|
22
|
+
/** DSH 的 home;沿用 harness 自己的 DSH_HOME 约定,缺省 ~/.dsh。 */
|
|
23
|
+
export declare function resolveDeepseekHarnessHome(env?: NodeJS.ProcessEnv): string;
|
|
24
|
+
/** 只检查 DSH 本地凭据文件是否存在且非空,绝不读取/记录其中内容。 */
|
|
25
|
+
export declare function hasDeepseekHarnessCredentials(env?: NodeJS.ProcessEnv): boolean;
|
|
26
|
+
export declare function resolveDeepseekSpawnBlocker(env?: NodeJS.ProcessEnv): string | null;
|
|
60
27
|
/**
|
|
61
28
|
* 包定位符覆盖(`DSH_PACKAGE`,缺省 `@deepseek-ai/dsh`,沿 contracts 常量口径):
|
|
62
29
|
* 最小校验——非空、无空白、无 shell 元字符(`;&|$()` 等),非法回落缺省并 dev warn。
|
|
63
30
|
* 经 `resolveSpawnCommand` 风格返回 spawn 目标覆盖(precedent 照抄 cursor)。
|
|
64
31
|
*/
|
|
65
32
|
export declare function resolveDeepseekPackage(env?: NodeJS.ProcessEnv): string;
|
|
66
|
-
/** 稳定安装的 dsh 入口覆盖(`DSH_BIN`);非法值回落 null 走包解析。 */
|
|
67
|
-
export declare function resolveDeepseekBin(env?: NodeJS.ProcessEnv): string | null;
|
|
68
33
|
export declare function resolveDeepseekSpawnCommand(env?: NodeJS.ProcessEnv): {
|
|
69
34
|
command: string;
|
|
70
35
|
args: string[];
|
|
71
36
|
};
|
|
72
|
-
export declare function probeDeepseekAuth(
|
|
37
|
+
export declare function probeDeepseekAuth(): CodexAuthPreflight;
|
|
73
38
|
export declare const deepseekAdapter: GenericRuntimeAdapter;
|
|
@@ -1,24 +1,42 @@
|
|
|
1
|
-
import type { AcpAgentQuota } from '../../contracts/quota';
|
|
1
|
+
import type { AcpAccountInfo, AcpAgentQuota, AcpQuotaCredits } from '../../contracts/quota';
|
|
2
|
+
type FetchLike = typeof fetch;
|
|
3
|
+
interface PlatformGrant {
|
|
4
|
+
token: string;
|
|
5
|
+
issuer?: string;
|
|
6
|
+
}
|
|
7
|
+
/** 测试与手动刷新用:丢弃 30s 缓存。 */
|
|
8
|
+
export declare function resetDeepseekQuotaCache(): void;
|
|
2
9
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
* 官方 `/user/balance` 响应 → `AcpAgentQuota`(API Key 计费口径)。
|
|
11
|
+
* 多币种时优先 CNY;不伪造速率窗口。
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseDeepseekBalance(payload: unknown, runtimeId?: string): AcpAgentQuota | null;
|
|
14
|
+
/** 钱包摘要 → credits(优先 CNY,其余币种不折叠)。 */
|
|
15
|
+
export declare function parsePlatformWallet(value: unknown): AcpQuotaCredits | undefined;
|
|
16
|
+
/** 平台用户资料 → 账户信息(邮箱/昵称)。 */
|
|
17
|
+
export declare function parsePlatformAccount(value: unknown): AcpAccountInfo | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* 解析 DSH 的 `.credentials.yaml`(仅取 account grant)。
|
|
9
20
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
21
|
+
* 文件由 harness 生成,结构固定:`records: → <name>: → kind/payload → token/issuer`。
|
|
22
|
+
* 这里只做单遍扫描,不引入 YAML 依赖;任何异常都退化为空列表。
|
|
12
23
|
*/
|
|
13
|
-
export
|
|
14
|
-
|
|
24
|
+
export declare function parseDshCredentialGrants(text: string): PlatformGrant[];
|
|
25
|
+
export interface DeepseekQuotaProbeOptions {
|
|
26
|
+
/** 覆盖进程环境,便于测试与宿主注入。 */
|
|
15
27
|
env?: NodeJS.ProcessEnv;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
28
|
+
fetchImpl?: FetchLike;
|
|
29
|
+
now?: () => number;
|
|
30
|
+
/** 覆盖 DSH 凭据文件(测试用);缺省 `$DSH_HOME/.credentials.yaml`。 */
|
|
31
|
+
credentialsFile?: string;
|
|
32
|
+
/** 覆盖平台 origin(测试/私有部署用)。 */
|
|
33
|
+
platformOrigin?: string;
|
|
19
34
|
}
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
35
|
+
/**
|
|
36
|
+
* 查询 DeepSeek 账户额度。
|
|
37
|
+
*
|
|
38
|
+
* 优先平台账户(余额 + 邮箱/昵称),其次 API Key(公开余额接口)。
|
|
39
|
+
* 两者都没有时返回 null —— 界面继续显示“无额度数据”,而不是编造状态。
|
|
40
|
+
*/
|
|
41
|
+
export declare function probeDeepseekQuota(options?: DeepseekQuotaProbeOptions): Promise<AcpAgentQuota | null>;
|
|
42
|
+
export {};
|
package/dist/runtimes/index.d.ts
CHANGED
|
@@ -15,15 +15,10 @@ export interface GenericRuntimeAdapter {
|
|
|
15
15
|
beforeSpawn?: () => Promise<void>;
|
|
16
16
|
/** 仅冷启动(无温进程可用、即将 spawn)时调用一次;各 runtime 自理副作用 */
|
|
17
17
|
onColdStart?: () => Promise<void>;
|
|
18
|
-
probeAuth: (
|
|
19
|
-
env?: NodeJS.ProcessEnv;
|
|
20
|
-
dataDir?: string;
|
|
21
|
-
}) => CodexAuthPreflight;
|
|
18
|
+
probeAuth: () => CodexAuthPreflight;
|
|
22
19
|
/** 运行时配额探针(5h 限制、周额度、余额),与会话生命周期解耦 */
|
|
23
20
|
probeQuota?: (options?: {
|
|
24
21
|
sessionId?: string;
|
|
25
|
-
dataDir?: string;
|
|
26
|
-
env?: NodeJS.ProcessEnv;
|
|
27
22
|
}) => Promise<AcpAgentQuota | null>;
|
|
28
23
|
/**
|
|
29
24
|
* 预 spawn 接线点(冷启动 spawn 前调用一次):
|
|
@@ -42,24 +37,9 @@ export interface GenericRuntimeAdapter {
|
|
|
42
37
|
* 返回非空字符串表示直接判停,`acp-connection.ts` 以该文案回带
|
|
43
38
|
* `ACP_SPAWN_ERROR`,不触达 spawn(如 deepseek 缺 DEEPSEEK_API_KEY 时
|
|
44
39
|
* harness 秒退,stdio 关闭即裸 `ACP connection closed`)。
|
|
45
|
-
* 上下文带宿主显式 env 与 dataDir:运行时可有自己的凭证落库(如 DeepSeek
|
|
46
|
-
* 的 URL+Token 表单),预检必须与 spawn 用同一份事实,否则会出现
|
|
47
|
-
* “表单填了却仍被判停”。
|
|
48
40
|
* 缺省(undefined)/返回空表示放行;抛错时按放行处理(防御性回落),不断连接。
|
|
49
41
|
*/
|
|
50
|
-
resolveSpawnBlocker?: (
|
|
51
|
-
env?: NodeJS.ProcessEnv;
|
|
52
|
-
dataDir?: string;
|
|
53
|
-
}) => string | null | undefined;
|
|
54
|
-
/**
|
|
55
|
-
* 运行时自有凭证落库 → 追加 spawn 环境(缺省不注入)。
|
|
56
|
-
* 在代理/调用方 env 合成之后合并;`currentEnv` 已含的键由实现方决定是否覆盖
|
|
57
|
-
* (DeepSeek 的做法是显式 env 优先,落库只补空缺)。
|
|
58
|
-
*/
|
|
59
|
-
getProviderEnv?: (context: {
|
|
60
|
-
dataDir: string;
|
|
61
|
-
env: NodeJS.ProcessEnv;
|
|
62
|
-
}) => NodeJS.ProcessEnv | undefined;
|
|
42
|
+
resolveSpawnBlocker?: () => string | null | undefined;
|
|
63
43
|
getSpawnEnv?: (proxySettings?: Partial<AcpProxySettings>) => {
|
|
64
44
|
env: NodeJS.ProcessEnv;
|
|
65
45
|
envRemove: string[];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session-level "code mode" (PTC) request.
|
|
3
|
+
*
|
|
4
|
+
* ACP has no standard field for how tools are presented to the model. An agent
|
|
5
|
+
* that supports it advertises the offered presentations in `initialize`:
|
|
6
|
+
*
|
|
7
|
+
* agentCapabilities._meta.toolsMode.values = ['native', 'ptc']
|
|
8
|
+
*
|
|
9
|
+
* and a client selects one per session through `_meta.toolsMode` on
|
|
10
|
+
* session/new and session/resume. Under `ptc` the agent asks the model to write
|
|
11
|
+
* code and exposes every visible tool — including MCP tools mounted for the
|
|
12
|
+
* session — as `tools.<name>(...)`.
|
|
13
|
+
*
|
|
14
|
+
* Support is read from that declaration and nothing else: an agent that does
|
|
15
|
+
* not declare it has no code mode, so the client must not invent one from a
|
|
16
|
+
* runtime id (that would show a switch that silently does nothing).
|
|
17
|
+
*/
|
|
18
|
+
export type AcpCodeMode = 'on' | 'off';
|
|
19
|
+
/** The presentations an agent declares, or null when it declares nothing. */
|
|
20
|
+
export declare function parseCodeModeModes(caps: Record<string, unknown> | null | undefined): string[] | null;
|
|
21
|
+
/** Whether this agent declares a code-mode presentation. */
|
|
22
|
+
export declare function supportsCodeMode(caps: Record<string, unknown> | null | undefined): boolean;
|
|
23
|
+
/** The `_meta` extension for one session, or undefined when nothing is requested. */
|
|
24
|
+
export declare function codeModeSessionMeta(mode: AcpCodeMode | undefined, caps: Record<string, unknown> | null | undefined): Record<string, unknown> | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Merge the app-resource extension with the code-mode request. The code-mode
|
|
27
|
+
* key wins over an accidental same-named app-resource key; everything else is
|
|
28
|
+
* preserved so a runtime that rejects unknown meta still keeps its resources.
|
|
29
|
+
*/
|
|
30
|
+
export declare function mergeSessionMeta(appMeta: Record<string, unknown> | undefined, mode: AcpCodeMode | undefined, caps: Record<string, unknown> | null | undefined): Record<string, unknown> | undefined;
|
package/dist/session/quota.d.ts
CHANGED
|
@@ -9,17 +9,8 @@ export declare function parseRateLimitsFromStatusText(text: string, runtimeId?:
|
|
|
9
9
|
export declare class QuotaCache {
|
|
10
10
|
private bySession;
|
|
11
11
|
private byRuntime;
|
|
12
|
-
/** ACP `usage_update` 的上下文占用(token 用量),与余额探针分账存放 */
|
|
13
|
-
private usageBySession;
|
|
14
|
-
private usageByRuntime;
|
|
15
12
|
observe(params: unknown, defaultRuntimeId?: string): AcpAgentQuota | null;
|
|
16
13
|
set(quota: AcpAgentQuota, sessionId?: string): void;
|
|
17
14
|
get(sessionId?: string, runtimeId?: string): AcpAgentQuota | undefined;
|
|
18
|
-
/**
|
|
19
|
-
* 把 `usage_update` 的上下文占用并入配额对象(读取时合并,不覆盖余额):
|
|
20
|
-
* 有余额时作为 `extraWindows` 的 `Context` 窗口;没有余额但有用量时,
|
|
21
|
-
* 单独给出一个以 Context 为主窗口的配额,避免 UI 一片空白。
|
|
22
|
-
*/
|
|
23
|
-
applyContextUsage(quota: AcpAgentQuota | null | undefined, sessionId?: string, runtimeId?: string): AcpAgentQuota | null;
|
|
24
15
|
clear(): void;
|
|
25
16
|
}
|