@yitom/acp-client 0.1.7 → 0.1.8
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 +14 -0
- package/dist/app-skills-mcp-serve.cjs +291 -0
- package/dist/client/acp-client.d.ts +52 -1
- package/dist/client/session-open.d.ts +5 -0
- package/dist/index.cjs +1098 -189
- package/dist/index.d.ts +5 -0
- package/dist/index.js +1080 -171
- package/dist/mcp/app-skills-mcp-serve.d.ts +1 -0
- package/dist/mcp/app-skills-mcp.d.ts +48 -0
- package/dist/process/process-manager.d.ts +51 -5
- package/dist/resources/app-resources.d.ts +91 -0
- package/dist/resources/config-text.d.ts +36 -0
- package/dist/resources/eligibility.d.ts +19 -0
- package/dist/resources/index.d.ts +5 -0
- package/dist/resources/runtime-bindings.d.ts +59 -0
- package/dist/resources/session-config.d.ts +9 -0
- package/dist/runtimes/index.d.ts +17 -0
- package/dist/session/compat-guide.d.ts +33 -0
- package/dist/sidecar.cjs +1050 -170
- package/dist/version.d.ts +1 -1
- package/docs/api-reference.md +108 -0
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK 管理的通用只读技能 MCP 服务(纯文档技能):
|
|
3
|
+
* - `app_list_skills`:技能目录(名称+描述),供模型发现;
|
|
4
|
+
* - `app_read_skill`:指定技能正文按需读取(含版本摘要)。
|
|
5
|
+
* 只读:无写入、无执行;目录穿越/越界引用一律拒绝并报可诊断错误码。
|
|
6
|
+
* 不包含任何宿主业务内容;工具描述只讲发现与加载方法。
|
|
7
|
+
*/
|
|
8
|
+
export declare const APP_SKILLS_MCP_SERVER_NAME = "app-skills";
|
|
9
|
+
export interface AppSkillsToolDefinition {
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
inputSchema: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
export declare const APP_SKILLS_TOOLS: AppSkillsToolDefinition[];
|
|
15
|
+
export type AppSkillsCallResult = {
|
|
16
|
+
content: Array<{
|
|
17
|
+
type: 'text';
|
|
18
|
+
text: string;
|
|
19
|
+
}>;
|
|
20
|
+
isError?: boolean;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* 分发技能工具调用(纯函数式逻辑,可单测;stdio Runner 与单测共用)。
|
|
24
|
+
* 返回文本均为磁盘实时读取;修改文件后新版本即时可见。
|
|
25
|
+
*/
|
|
26
|
+
export declare function callAppSkillsTool(directory: string, name: string, args?: Record<string, unknown>): Promise<AppSkillsCallResult>;
|
|
27
|
+
export interface AppSkillsMcpServerDescriptor {
|
|
28
|
+
name: string;
|
|
29
|
+
command: string;
|
|
30
|
+
args: string[];
|
|
31
|
+
env: Array<{
|
|
32
|
+
name: string;
|
|
33
|
+
value: string;
|
|
34
|
+
}>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* 技能 MCP 服务描述符(供宿主并入 createSession 的 mcpServers):
|
|
38
|
+
* command/args 指向随包构建产物,无源码路径、无私有缓存引用。
|
|
39
|
+
*/
|
|
40
|
+
export declare function buildAppSkillsMcpServer(directory: string, opts?: {
|
|
41
|
+
name?: string;
|
|
42
|
+
runnerPath?: string;
|
|
43
|
+
}): AppSkillsMcpServerDescriptor;
|
|
44
|
+
/**
|
|
45
|
+
* Runner 入口解析:优先构建产物(发版/消费路径),回落源码(开发期)。
|
|
46
|
+
* 两者皆无时抛错(调用方明确降级,不静默挂一个坏服务)。
|
|
47
|
+
*/
|
|
48
|
+
export declare function resolveAppSkillsRunnerPath(fromFile?: string): string;
|
|
@@ -2,6 +2,14 @@ import { type ChildProcessWithoutNullStreams } from 'node:child_process';
|
|
|
2
2
|
import type { AcpRuntimeInfo } from "../contracts";
|
|
3
3
|
export interface SpawnedAcpProcess {
|
|
4
4
|
runtimeId: string;
|
|
5
|
+
/** 宿主作用域键(如窗口/租户隔离;缺席=单宿主默认) */
|
|
6
|
+
scopeKey?: string;
|
|
7
|
+
/** 执行环境标记(如 native / wsl:<distro>;宿主计算后传入) */
|
|
8
|
+
executionContext?: string;
|
|
9
|
+
/** 应用资源绑定标签(内容摘要+运行时;缺席=未绑定,按旧语义复用) */
|
|
10
|
+
profileTag?: string | null;
|
|
11
|
+
/** 握手后记录的桥版本(同进程内不变) */
|
|
12
|
+
bridgeVersion?: string;
|
|
5
13
|
child: ChildProcessWithoutNullStreams;
|
|
6
14
|
kill: () => void;
|
|
7
15
|
/** spawn 时间戳(保留供诊断/排序,stderr 归因已去窗口化,不再参与判定) */
|
|
@@ -22,6 +30,12 @@ export interface SpawnAcpOptions {
|
|
|
22
30
|
env?: NodeJS.ProcessEnv;
|
|
23
31
|
/** 需要从继承环境里剔除的变量名(如关闭代理时清理 HTTP(S)_PROXY) */
|
|
24
32
|
envRemove?: string[];
|
|
33
|
+
/** 宿主作用域键(窗口/租户隔离;缺席=单宿主默认,与旧键完全一致) */
|
|
34
|
+
scopeKey?: string;
|
|
35
|
+
/** 执行环境标记(宿主计算后传入;复用时必须一致) */
|
|
36
|
+
executionContext?: string;
|
|
37
|
+
/** 应用资源绑定标签(要求时不一致即视为无温进程) */
|
|
38
|
+
profileTag?: string | null;
|
|
25
39
|
onStderrLine?: (line: string) => void;
|
|
26
40
|
onExit?: (code: number | null, signal: NodeJS.Signals | null) => void;
|
|
27
41
|
}
|
|
@@ -31,8 +45,9 @@ export interface SpawnAcpOptions {
|
|
|
31
45
|
*/
|
|
32
46
|
export declare function isSpawnedAcpProcessAlive(handle: SpawnedAcpProcess): boolean;
|
|
33
47
|
/**
|
|
34
|
-
* 多运行时温进程隔离:`active`
|
|
35
|
-
*
|
|
48
|
+
* 多运行时温进程隔离:`active` 按作用域+runtime.id 分键,绝不跨作用域或
|
|
49
|
+
* runtime 串用(无作用域时键即 runtime.id,与旧行为一致)。
|
|
50
|
+
* connect 前经 `getLiveAcpProcess` / `tryReuseLiveAcpProcess` 取温进程;
|
|
36
51
|
* 不同 runtime 即使 command 相同也各持独立句柄。
|
|
37
52
|
*/
|
|
38
53
|
export declare function spawnAcpProcess(options: SpawnAcpOptions): SpawnedAcpProcess;
|
|
@@ -49,11 +64,42 @@ export declare function getAcpEarlyExitStderrDetail(handle: Pick<SpawnedAcpProce
|
|
|
49
64
|
/** 失败尾部拼进连接失败错误(已含尾部时不重复拼)。函数名保留早退字样仅防旧引用。 */
|
|
50
65
|
export declare function withAcpEarlyExitDetail(message: string, detail: string | null): string;
|
|
51
66
|
export declare function disposeAllAcpProcesses(): void;
|
|
52
|
-
export declare function getActiveAcpProcess(runtimeId: string): SpawnedAcpProcess | undefined;
|
|
67
|
+
export declare function getActiveAcpProcess(runtimeId: string, scopeKey?: string): SpawnedAcpProcess | undefined;
|
|
53
68
|
/** 当前仍存活的温进程 runtime 清单(调试/测试用,不暴露 child 句柄细节)。 */
|
|
54
69
|
export declare function listLiveAcpRuntimeIds(): string[];
|
|
70
|
+
export interface LiveAcpProcessQuery {
|
|
71
|
+
/** 宿主作用域键(与 spawn 时一致;缺席=单宿主默认) */
|
|
72
|
+
scopeKey?: string;
|
|
73
|
+
/** 执行环境标记(宿主计算后传入;不一致不复用) */
|
|
74
|
+
executionContext?: string;
|
|
75
|
+
/** 应用资源绑定标签(要求时不一致即视为无温进程) */
|
|
76
|
+
expectedTag?: string | null;
|
|
77
|
+
}
|
|
55
78
|
/**
|
|
56
|
-
*
|
|
79
|
+
* 取仍存活的常驻进程(复用时用)。已退出或被外部杀掉的返回 undefined,
|
|
57
80
|
* 调用方应走冷启动并顺手清扫其残留临时目录。
|
|
81
|
+
* 作用域/执行环境/绑定标签任一不匹配即视为无温进程;不要求标签时沿旧语义
|
|
82
|
+
* 复用(含无标签的老进程)。
|
|
83
|
+
*/
|
|
84
|
+
export declare function getLiveAcpProcess(runtimeId: string, query?: LiveAcpProcessQuery): SpawnedAcpProcess | undefined;
|
|
85
|
+
export type ReuseAcpProcessResult = {
|
|
86
|
+
status: 'hit';
|
|
87
|
+
handle: SpawnedAcpProcess;
|
|
88
|
+
} | {
|
|
89
|
+
status: 'miss';
|
|
90
|
+
} | {
|
|
91
|
+
status: 'busy';
|
|
92
|
+
handle: SpawnedAcpProcess;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* 标签感知复用裁决(连接层调用,替代裸 get + 自行 kill):
|
|
96
|
+
* - 无存活进程 → miss(调用方冷启动);
|
|
97
|
+
* - 标签一致 → hit(直接复用,不杀);
|
|
98
|
+
* - 标签不一致但旧进程正忙(isBusy 为真)→ busy(沿用旧进程,不杀不断,
|
|
99
|
+
* 调用方降级兼容,新标签下次冷启动生效);
|
|
100
|
+
* - 标签不一致且空闲 → 杀旧进程后 miss(调用方冷启动)。
|
|
101
|
+
* 不要求标签时等价于旧 getLive 语义。
|
|
58
102
|
*/
|
|
59
|
-
export declare function
|
|
103
|
+
export declare function tryReuseLiveAcpProcess(runtimeId: string, query?: LiveAcpProcessQuery & {
|
|
104
|
+
isBusy?: (handle: SpawnedAcpProcess) => boolean;
|
|
105
|
+
}): ReuseAcpProcessResult;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 应用资源目录契约(单目录接口的宿主侧输入):
|
|
3
|
+
*
|
|
4
|
+
* <directory>/
|
|
5
|
+
* AGENTS.md 宿主常驻规则(主动读取,不等待模型找文件)
|
|
6
|
+
* skills/<name>/SKILL.md 按需加载的技能(发现与正文分别记录)
|
|
7
|
+
*
|
|
8
|
+
* 本模块只做读取、校验与摘要,不解释业务语义,不依赖 Electron,
|
|
9
|
+
* 不包含任何宿主品牌、工具名称或 UI 逻辑。
|
|
10
|
+
*/
|
|
11
|
+
export declare const APP_RULES_FILE = "AGENTS.md";
|
|
12
|
+
export declare const APP_SKILLS_DIR = "skills";
|
|
13
|
+
export declare const APP_SKILL_FILE = "SKILL.md";
|
|
14
|
+
export interface AppDiscoveredSkill {
|
|
15
|
+
/** 技能名(frontmatter 无 name 时取目录名) */
|
|
16
|
+
name: string;
|
|
17
|
+
/** frontmatter description(缺席为空字符串,非正文) */
|
|
18
|
+
description: string;
|
|
19
|
+
/** 相对目录的 SKILL.md 路径(`skills/<name>/SKILL.md`) */
|
|
20
|
+
path: string;
|
|
21
|
+
/** 正文字符数(脱敏统计用,不含正文) */
|
|
22
|
+
chars: number;
|
|
23
|
+
/** 正文 sha256(变更检测用;含名称与描述,任一变化即变) */
|
|
24
|
+
digest: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 最小 frontmatter 解析(无依赖):首行 `---` 起至下一个 `---` 行,
|
|
28
|
+
* `key: value` 按首个冒号切分,仅取 name/description,值去首尾引号。
|
|
29
|
+
* 形状非法一律回退空对象,不抛错。
|
|
30
|
+
*/
|
|
31
|
+
export declare function parseSkillFrontmatter(text: string): {
|
|
32
|
+
name?: string;
|
|
33
|
+
description?: string;
|
|
34
|
+
};
|
|
35
|
+
export interface AppResourceLoad {
|
|
36
|
+
/** 目录本身可读 */
|
|
37
|
+
directoryReadable: boolean;
|
|
38
|
+
/** 常驻规则:缺席为 null(调用方明确回退,不静默) */
|
|
39
|
+
rules: {
|
|
40
|
+
chars: number;
|
|
41
|
+
digest: string;
|
|
42
|
+
} | null;
|
|
43
|
+
/** 发现到的技能(仅目录 + SKILL.md both present 才算发现) */
|
|
44
|
+
skills: AppDiscoveredSkill[];
|
|
45
|
+
/** 非致命问题(缺文件、不可读项),供诊断记录 */
|
|
46
|
+
warnings: string[];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* 读取并校验应用资源目录。纯同步 fs,只抛错于调用方无法处理的场景之外——
|
|
50
|
+
* 本函数不抛错:目录不可读/文件缺席一律体现在返回值中,由调用方裁决回退。
|
|
51
|
+
*/
|
|
52
|
+
export declare function readAppResourcesDir(directory: string): AppResourceLoad;
|
|
53
|
+
/** 资源内容摘要(规则 + 有序技能):温复用与变更检测只比摘要,不比目录名。 */
|
|
54
|
+
export declare function digestAppResources(load: AppResourceLoad): string | null;
|
|
55
|
+
/** 读取常驻规则正文(适配器合并配置用;正文不出本作用域,只传摘要与长度)。 */
|
|
56
|
+
export declare function readAppRulesText(directory: string): string | null;
|
|
57
|
+
export interface AppResourceReport {
|
|
58
|
+
/** Child-only isolated config roots; existence is not proof the runtime loaded rules. */
|
|
59
|
+
configurationScope?: 'session';
|
|
60
|
+
configurationDirectory?: string;
|
|
61
|
+
configurationRulesFile?: string;
|
|
62
|
+
/** 规则是否已进入本次连接的原生通道(目录存在≠已应用) */
|
|
63
|
+
rulesApplied: boolean;
|
|
64
|
+
/** 仅表示已准备原生环境,不等同于会话已应用。 */
|
|
65
|
+
rulesPrepared?: boolean;
|
|
66
|
+
/** 原生技能入口未实现时为 false;skillsFound 只是 SDK 文件扫描结果。 */
|
|
67
|
+
skillsApplied?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* 技能向 Agent 的暴露方式(会话级):
|
|
70
|
+
* mcp-exposed = 已随会话 MCP 列表挂载通用只读技能服务;
|
|
71
|
+
* none = 未挂载(无 resources / 显式关闭 / 构建失败)。
|
|
72
|
+
* 原生运行时扫描生效时才可能为其他值,当前不虚构。
|
|
73
|
+
*/
|
|
74
|
+
skillsExposed?: 'mcp-exposed' | 'none';
|
|
75
|
+
rulesChars: number;
|
|
76
|
+
profileDigest: string | null;
|
|
77
|
+
/** SDK 已发现并读取正文的技能名(运行时是否加载另行确认,不冒充) */
|
|
78
|
+
skillsFound: string[];
|
|
79
|
+
/** 未应用/降级原因(脱敏短码) */
|
|
80
|
+
reason?: string;
|
|
81
|
+
/** 握手后记录的桥版本(同进程内不变) */
|
|
82
|
+
bridgeVersion?: string;
|
|
83
|
+
/** 桥版本是否在白名单内(未知/越界即 false) */
|
|
84
|
+
bridgeSupported?: boolean;
|
|
85
|
+
}
|
|
86
|
+
export interface AppResourcePrep {
|
|
87
|
+
/** 待并入 spawn 环境的变量(缺席=不注入) */
|
|
88
|
+
env?: NodeJS.ProcessEnv;
|
|
89
|
+
report: AppResourceReport;
|
|
90
|
+
}
|
|
91
|
+
export declare function isAbsolutePathLike(path: string): boolean;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 宿主配置文本合并(通用算法,不含宿主品牌与业务内容):
|
|
3
|
+
* - CODEX_CONFIG JSON 合并:保留全部已有键,已有 developer_instructions
|
|
4
|
+
* (字符串)予以保留并接在宿主规则块之后;无效 JSON / 冲突类型明确失败,
|
|
5
|
+
* 不静默覆盖。
|
|
6
|
+
* - config.toml 手术合并(无 TOML 解析依赖):保留调用方未知内容,
|
|
7
|
+
* 只替换指定的顶层键与整节表。
|
|
8
|
+
*/
|
|
9
|
+
export type ConfigMergeFailure = 'invalid-json' | 'conflicting-value' | 'empty-block';
|
|
10
|
+
export type ConfigMergeResult = {
|
|
11
|
+
ok: true;
|
|
12
|
+
json: string;
|
|
13
|
+
preservedUserInstructions: boolean;
|
|
14
|
+
} | {
|
|
15
|
+
ok: false;
|
|
16
|
+
reason: ConfigMergeFailure;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* 合并 CODEX_CONFIG:宿主规则块在前、用户已有 developer_instructions 在后
|
|
20
|
+
* (与既往每轮前缀在用户消息之前的生效顺序一致)。
|
|
21
|
+
*/
|
|
22
|
+
export declare function mergeCodexConfigJson(input: {
|
|
23
|
+
existingRaw?: string;
|
|
24
|
+
hostBlock: string;
|
|
25
|
+
}): ConfigMergeResult;
|
|
26
|
+
/**
|
|
27
|
+
* config.toml 手术合并:保留未知文本(注释、空行、其他表),只替换
|
|
28
|
+
* managedTopKeys 指定的顶层键与 managedTables 指定的整节。
|
|
29
|
+
* 行级状态机,无需 TOML 解析器;未知形状宁可保留原文,不猜测改写。
|
|
30
|
+
*/
|
|
31
|
+
export declare function mergeConfigTomlPreserving(input: {
|
|
32
|
+
existingText: string | null;
|
|
33
|
+
managedTopKeys: string[];
|
|
34
|
+
managedTables: string[];
|
|
35
|
+
replacementBlock: string;
|
|
36
|
+
}): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 运行时原生资格与桥版本门(通用策略,封装在 SDK 内):
|
|
3
|
+
* 仅验证过的运行时可候选原生加载;未知版本、版本越界一律回退,
|
|
4
|
+
* 不靠 model 名称或 runtime.id 单独判定成功。
|
|
5
|
+
*
|
|
6
|
+
* 注意:白名单记录的是已验证的桥精确版本,不是“永远兼容”承诺;
|
|
7
|
+
* 新精确版本出现时先回退,验证后随 SDK 更新放行。
|
|
8
|
+
*/
|
|
9
|
+
/** 已核对原生配置接口的运行时与桥版本;模型遵从需要单独实测 */
|
|
10
|
+
export declare const NATIVE_ELIGIBLE_BRIDGE_VERSIONS: Record<string, string[]>;
|
|
11
|
+
export type NativeCompatReason = 'runtime-not-verified' | 'unknown-bridge-version' | 'unsupported-bridge-version';
|
|
12
|
+
export interface NativeEligibility {
|
|
13
|
+
eligible: boolean;
|
|
14
|
+
reason?: NativeCompatReason;
|
|
15
|
+
}
|
|
16
|
+
/** 运行时原生资格:仅白名单内可候选,其余(含将来新增)全部兼容回退。 */
|
|
17
|
+
export declare function resolveRuntimeEligibility(runtimeId: string): NativeEligibility;
|
|
18
|
+
/** 桥版本门:空/不可解析 → 未知回退;精确版本命中白名单才放行。 */
|
|
19
|
+
export declare function isSupportedBridgeVersion(runtimeId: string, version?: string): NativeEligibility;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type AppResourcePrep } from './app-resources';
|
|
2
|
+
/** Configuration-home discovery is NOT an ACP guarantee. Keep authentication homes intact. */
|
|
3
|
+
export declare const APP_RESOURCE_CAPABILITIES: {
|
|
4
|
+
readonly 'codex-acp': {
|
|
5
|
+
readonly entry: 'CODEX_CONFIG';
|
|
6
|
+
readonly strategy: 'native-overlay';
|
|
7
|
+
readonly configHome: 'CODEX_HOME';
|
|
8
|
+
};
|
|
9
|
+
readonly opencode: {
|
|
10
|
+
readonly entry: 'OPENCODE_CONFIG_CONTENT';
|
|
11
|
+
readonly strategy: 'native-overlay';
|
|
12
|
+
readonly configHome: 'OPENCODE_CONFIG_DIR';
|
|
13
|
+
};
|
|
14
|
+
readonly 'opencode-v2': {
|
|
15
|
+
readonly entry: null;
|
|
16
|
+
readonly strategy: 'compatibility';
|
|
17
|
+
readonly configHome: null;
|
|
18
|
+
};
|
|
19
|
+
readonly claude: {
|
|
20
|
+
readonly entry: '_meta.systemPrompt + _meta.claudeCode.options.plugins';
|
|
21
|
+
readonly strategy: 'native-session';
|
|
22
|
+
readonly configHome: 'CLAUDE_CONFIG_DIR';
|
|
23
|
+
};
|
|
24
|
+
readonly gemini: {
|
|
25
|
+
readonly entry: null;
|
|
26
|
+
readonly strategy: 'compatibility';
|
|
27
|
+
readonly configHome: 'GEMINI_CLI_HOME';
|
|
28
|
+
};
|
|
29
|
+
readonly copilot: {
|
|
30
|
+
readonly entry: null;
|
|
31
|
+
readonly strategy: 'compatibility';
|
|
32
|
+
readonly configHome: 'COPILOT_HOME';
|
|
33
|
+
readonly candidateEntry: 'COPILOT_CUSTOM_INSTRUCTIONS_DIRS';
|
|
34
|
+
};
|
|
35
|
+
readonly 'cursor-cli': {
|
|
36
|
+
readonly entry: null;
|
|
37
|
+
readonly strategy: 'compatibility';
|
|
38
|
+
readonly configHome: 'CURSOR_CONFIG_DIR';
|
|
39
|
+
};
|
|
40
|
+
readonly agy: {
|
|
41
|
+
readonly entry: '_meta.appResources.directory';
|
|
42
|
+
readonly strategy: 'native-session';
|
|
43
|
+
readonly configHome: null;
|
|
44
|
+
};
|
|
45
|
+
readonly deepseek: {
|
|
46
|
+
readonly entry: null;
|
|
47
|
+
readonly strategy: 'compatibility';
|
|
48
|
+
readonly configHome: null;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export declare function prepareCompatibilityResources(directory: string, reason: string): AppResourcePrep;
|
|
52
|
+
export declare function mergeOpenCodeAppConfig(raw: string | undefined, directory: string): string;
|
|
53
|
+
export declare function prepareOpenCodeResources(input: {
|
|
54
|
+
directory: string;
|
|
55
|
+
env?: NodeJS.ProcessEnv;
|
|
56
|
+
command?: string;
|
|
57
|
+
}): Promise<AppResourcePrep>;
|
|
58
|
+
export declare function prepareClaudeResources(directory: string): AppResourcePrep;
|
|
59
|
+
export declare function claudeResourceSessionMeta(directory: string): Record<string, unknown> | undefined;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface SessionConfigHome {
|
|
2
|
+
directory: string;
|
|
3
|
+
env: NodeJS.ProcessEnv;
|
|
4
|
+
rulesFile: string;
|
|
5
|
+
nativeRules: boolean;
|
|
6
|
+
dispose(): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
/** Child-process configuration roots, NOT a replacement of process.env/HOME/cwd. */
|
|
9
|
+
export declare function createSessionConfigHome(runtime: string, resources: string): Promise<SessionConfigHome>;
|
package/dist/runtimes/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AcpAuthMethod, AcpProxySettings, CodexAuthPreflight, AcpAgentQuota } from "../contracts";
|
|
2
|
+
import type { AppResourcePrep } from "../resources/app-resources";
|
|
2
3
|
import { codexAdapter } from './codex';
|
|
3
4
|
export * from './codex';
|
|
4
5
|
export * from './claude';
|
|
@@ -43,6 +44,22 @@ export interface GenericRuntimeAdapter {
|
|
|
43
44
|
env: NodeJS.ProcessEnv;
|
|
44
45
|
envRemove: string[];
|
|
45
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* 应用资源预准备(冷启动 spawn 前调用一次):
|
|
49
|
+
* 读取宿主传入的资源目录,返回待注入的环境变量与加载报告。
|
|
50
|
+
* 缺省(undefined)= 该运行时无原生资源入口,调用方按兼容处理。
|
|
51
|
+
* 报告区分“SDK 已读取”与“运行时已加载”,不冒充后者。
|
|
52
|
+
*/
|
|
53
|
+
prepareAppResources?: (input: {
|
|
54
|
+
directory: string;
|
|
55
|
+
workspaceRoot: string;
|
|
56
|
+
command?: string;
|
|
57
|
+
/** 最终子进程有效环境;不要改读全局 process.env。 */
|
|
58
|
+
env?: NodeJS.ProcessEnv;
|
|
59
|
+
}) => Promise<AppResourcePrep>;
|
|
60
|
+
appResourceSessionMeta?: (directory: string) => Record<string, unknown> | undefined;
|
|
61
|
+
/** 已核对的桥精确版本白名单(缺席=未声明,调用方按未知版本回退) */
|
|
62
|
+
supportedBridgeVersions?: string[];
|
|
46
63
|
orderAuthMethods?: (methods: AcpAuthMethod[]) => AcpAuthMethod[];
|
|
47
64
|
canSkipInteractiveAuth?: (methodId: string, force?: boolean) => boolean;
|
|
48
65
|
/**
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK 自动兼容引导(compat/user-context 通道):
|
|
3
|
+
* 无安全原生入口时,SDK 在必要会话首轮自动附带本块,不逐轮重复。
|
|
4
|
+
*
|
|
5
|
+
* - 内容与宿主资源同源(规则正文 + 技能目录),SDK 不编写业务提示词;
|
|
6
|
+
* - 明确记为 compatibility/user-context,不宣称 system/developer 优先级;
|
|
7
|
+
* - 稳定标记供宿主回放清洗与诊断;SDK 转发通知原文,不改写不剥离。
|
|
8
|
+
*/
|
|
9
|
+
export declare const COMPAT_CONTEXT_TAG = "acp-compat-context";
|
|
10
|
+
export interface CompatSkillEntry {
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
}
|
|
14
|
+
export interface CompatGuideInput {
|
|
15
|
+
/** 同源规则正文(缺席则只带技能指引) */
|
|
16
|
+
rulesText: string | null;
|
|
17
|
+
/** 同源技能目录(名称+描述,不含正文) */
|
|
18
|
+
skills: CompatSkillEntry[];
|
|
19
|
+
/** 技能正文是否可经 MCP 读取(决定指引写法,不虚构可用性) */
|
|
20
|
+
skillsViaMcp: boolean;
|
|
21
|
+
/** 本次交付快照摘要(短哈希) */
|
|
22
|
+
digest: string | null;
|
|
23
|
+
sessionId: string;
|
|
24
|
+
/** 连接代次(重连/恢复后重新附带一次的诊断依据) */
|
|
25
|
+
generation: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 构建兼容引导块。纯函数;调用方保证同一次交付使用同一快照
|
|
29
|
+
* (正文与摘要同读,不混用两次读取期间变化的内容)。
|
|
30
|
+
*/
|
|
31
|
+
export declare function buildCompatGuideText(input: CompatGuideInput): string | null;
|
|
32
|
+
/** 附带记账键:会话 + 连接代次 + 资源摘要;三者任一变化即新交付(有界)。 */
|
|
33
|
+
export declare function compatDeliveryKey(sessionId: string, generation: number, digest: string | null): string;
|