@yitom/acp-client 0.1.12 → 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 +19 -20
- 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/index.cjs +1476 -775
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3706 -3006
- 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 -0
- package/dist/runtimes/deepseek/index.d.ts +10 -6
- package/dist/runtimes/deepseek/quota.d.ts +42 -0
- package/dist/session/code-mode.d.ts +30 -0
- package/dist/sidecar.cjs +3929 -3148
- package/dist/version.d.ts +1 -1
- package/docs/adding-an-agent.md +14 -0
- package/docs/api-reference.md +61 -0
- package/package.json +7 -5
|
@@ -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>;
|
|
@@ -3,22 +3,26 @@ import type { GenericRuntimeAdapter } from '../index';
|
|
|
3
3
|
/**
|
|
4
4
|
* DeepSeek 运行时适配器(`bunx @deepseek-ai/dsh --profile acp`)。
|
|
5
5
|
*
|
|
6
|
-
* 凭证复用:harness 自身凭证(`DEEPSEEK_API_KEY`
|
|
7
|
-
*
|
|
6
|
+
* 凭证复用:harness 自身凭证(`DEEPSEEK_API_KEY` 或 `$DSH_HOME/.credentials.yaml`,
|
|
7
|
+
* 全部留在官方位置,我方不存、不读内容)。harness 的 ACP `authMethods` 为空,
|
|
8
8
|
* 连接门闩天然走 `skip_auth`;此处探测仅供诊断展示。
|
|
9
9
|
* 模型经 session 到达(顶层 `models` 方言由 session-open 合成 model 选项),无需额外动作。
|
|
10
10
|
*
|
|
11
11
|
* 缺 key 预检(仿 cursor `resolveSpawnCommand` 为 null 即拦的 precedent):
|
|
12
|
-
*
|
|
13
|
-
* closed),故经 `resolveSpawnBlocker` 在 spawn 前判停,回带中文动作指引。
|
|
14
|
-
* 同族 `DSH_*`
|
|
15
|
-
*
|
|
12
|
+
* 本机既无 env key 也无 DSH 本地登录时 harness 极可能直接退出(stdio 关闭→传输层报
|
|
13
|
+
* connection closed),故经 `resolveSpawnBlocker` 在 spawn 前判停,回带中文动作指引。
|
|
14
|
+
* 同族 `DSH_*` 仅认文档明确的变量——`DSH_HOME`(本地登录位置)、`DEEPSEEK_API_KEY`
|
|
15
|
+
* (预检)与 `DSH_PACKAGE`(包定位符覆盖,见 `resolveDeepseekSpawnCommand`)。
|
|
16
16
|
*
|
|
17
17
|
* 上游坏包逃生(实锤:dsh 0.1.5-rc.2 内依赖 `…-documentpreview@^0.1.5-rc.3`,
|
|
18
18
|
* 而该包最高仅 0.1.6-alpha.1,上游缺 rc.3,自解析依赖失败退出):
|
|
19
19
|
* 设 `DSH_PACKAGE` pin 旧版(如 `@deepseek-ai/dsh@0.1.4`)即可绕过。
|
|
20
20
|
*/
|
|
21
21
|
export declare function buildDeepseekMissingKeyMessage(): string;
|
|
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;
|
|
22
26
|
export declare function resolveDeepseekSpawnBlocker(env?: NodeJS.ProcessEnv): string | null;
|
|
23
27
|
/**
|
|
24
28
|
* 包定位符覆盖(`DSH_PACKAGE`,缺省 `@deepseek-ai/dsh`,沿 contracts 常量口径):
|
|
@@ -0,0 +1,42 @@
|
|
|
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;
|
|
9
|
+
/**
|
|
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)。
|
|
20
|
+
*
|
|
21
|
+
* 文件由 harness 生成,结构固定:`records: → <name>: → kind/payload → token/issuer`。
|
|
22
|
+
* 这里只做单遍扫描,不引入 YAML 依赖;任何异常都退化为空列表。
|
|
23
|
+
*/
|
|
24
|
+
export declare function parseDshCredentialGrants(text: string): PlatformGrant[];
|
|
25
|
+
export interface DeepseekQuotaProbeOptions {
|
|
26
|
+
/** 覆盖进程环境,便于测试与宿主注入。 */
|
|
27
|
+
env?: NodeJS.ProcessEnv;
|
|
28
|
+
fetchImpl?: FetchLike;
|
|
29
|
+
now?: () => number;
|
|
30
|
+
/** 覆盖 DSH 凭据文件(测试用);缺省 `$DSH_HOME/.credentials.yaml`。 */
|
|
31
|
+
credentialsFile?: string;
|
|
32
|
+
/** 覆盖平台 origin(测试/私有部署用)。 */
|
|
33
|
+
platformOrigin?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 查询 DeepSeek 账户额度。
|
|
37
|
+
*
|
|
38
|
+
* 优先平台账户(余额 + 邮箱/昵称),其次 API Key(公开余额接口)。
|
|
39
|
+
* 两者都没有时返回 null —— 界面继续显示“无额度数据”,而不是编造状态。
|
|
40
|
+
*/
|
|
41
|
+
export declare function probeDeepseekQuota(options?: DeepseekQuotaProbeOptions): Promise<AcpAgentQuota | null>;
|
|
42
|
+
export {};
|
|
@@ -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;
|