@ai-zen/agents-host 0.1.0-alpha.3 → 0.1.0-alpha.4
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/CHANGELOG.md +39 -0
- package/dist/app.d.ts +0 -5
- package/dist/app.js +3 -9
- package/dist/handlers/configHandlers.d.ts +1 -3
- package/dist/handlers/conversationHandlers.d.ts +0 -2
- package/dist/handlers/conversationHandlers.js +2 -16
- package/dist/handlers/hostHandlers.d.ts +4 -5
- package/dist/handlers/hostHandlers.js +3 -21
- package/dist/handlers/index.d.ts +2 -4
- package/dist/handlers/index.js +0 -1
- package/dist/handlers/noticeHandlers.d.ts +0 -8
- package/dist/handlers/noticeHandlers.js +0 -10
- package/dist/i18n/en.d.ts +0 -168
- package/dist/i18n/en.js +0 -171
- package/dist/i18n/zh.d.ts +0 -168
- package/dist/i18n/zh.js +0 -169
- package/dist/index.d.ts +1 -0
- package/dist/net/WsHub.d.ts +1 -2
- package/dist/net/WsHub.js +0 -2
- package/dist/services/AutoNaming.d.ts +0 -5
- package/dist/services/AutoNaming.js +0 -18
- package/dist/services/ConfigService.d.ts +2 -2
- package/dist/services/ConfigService.js +11 -20
- package/dist/services/ModelService.d.ts +1 -3
- package/dist/services/ModelService.js +0 -4
- package/dist/services/QuestionService.d.ts +0 -7
- package/dist/services/QuestionService.js +0 -15
- package/dist/storage/ConversationRepository.d.ts +0 -3
- package/dist/storage/ConversationRepository.js +0 -12
- package/dist/storage/QuestionRepository.d.ts +0 -1
- package/dist/storage/QuestionRepository.js +0 -4
- package/dist/storage/types.d.ts +0 -2
- package/dist/wire/methods.d.ts +4 -52
- package/dist/wire/methods.js +0 -5
- package/dist/wire/states.d.ts +5 -12
- package/package.json +3 -2
- package/dist/handlers/capabilities.d.ts +0 -26
- package/dist/handlers/capabilities.js +0 -138
package/dist/wire/states.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ import type { MessageKey } from "../i18n/index.js";
|
|
|
29
29
|
* 「界面显示」「客户端重排」「换个语言连回来重渲染」三种需要。
|
|
30
30
|
*/
|
|
31
31
|
export interface LocalizedText {
|
|
32
|
-
/** 稳定码(如 `notice.
|
|
32
|
+
/** 稳定码(如 `notice.settingsApplied`、`tool.failed`),与文案键分开,便于客户端分支 */
|
|
33
33
|
code: string;
|
|
34
34
|
/** 文案键(`i18n` 的键空间) */
|
|
35
35
|
messageKey: MessageKey;
|
|
@@ -347,8 +347,6 @@ export interface LocalSectionExtensions {
|
|
|
347
347
|
* ```
|
|
348
348
|
*/
|
|
349
349
|
export type LocalMessageContentSection = AgentNS.MessageContentSection & LocalSectionExtensions;
|
|
350
|
-
/** 带本地扩展的正文:字符串原样,数组里的每一段可能带 `__` 字段 */
|
|
351
|
-
export type LocalMessageContent = string | LocalMessageContentSection[];
|
|
352
350
|
/**
|
|
353
351
|
* 一个内容段里的素材 id(没有这个扩展字段时为空)。
|
|
354
352
|
*
|
|
@@ -410,14 +408,16 @@ export interface AttachmentOutcome {
|
|
|
410
408
|
problem: ProblemFact | null;
|
|
411
409
|
}
|
|
412
410
|
/**
|
|
413
|
-
*
|
|
411
|
+
* 状态栏每一块的事实。块 id 固定,块内结构按 id 不同而不同(判别式联合)。
|
|
414
412
|
*
|
|
415
413
|
* 这样的好处是:宿主给的是可排版的块,客户端决定摆哪几块、摆在哪(PRD F-I6 /
|
|
416
414
|
* 「宿主给能力、客户端给交互」),双方都不需要解析一整行字符串。
|
|
415
|
+
*
|
|
416
|
+
* **块名(助手 / 模型 / 上下文 …)不在这里**:那是界面的词汇,归客户端 —— 同一块在
|
|
417
|
+
* 不同界面上叫法可能不同,也可能干脆不显示名字。宿主只给 id 与 facts。
|
|
417
418
|
*/
|
|
418
419
|
export type StatusBlock = {
|
|
419
420
|
id: "agent";
|
|
420
|
-
label: LocalizedText;
|
|
421
421
|
/**
|
|
422
422
|
* 助手块的三个事实。
|
|
423
423
|
*
|
|
@@ -432,33 +432,26 @@ export type StatusBlock = {
|
|
|
432
432
|
};
|
|
433
433
|
} | {
|
|
434
434
|
id: "model";
|
|
435
|
-
label: LocalizedText;
|
|
436
435
|
facts: ModelState;
|
|
437
436
|
} | {
|
|
438
437
|
id: "thinking";
|
|
439
|
-
label: LocalizedText;
|
|
440
438
|
facts: ThinkingState;
|
|
441
439
|
} | {
|
|
442
440
|
id: "context";
|
|
443
|
-
label: LocalizedText;
|
|
444
441
|
facts: ContextState;
|
|
445
442
|
} | {
|
|
446
443
|
id: "usage";
|
|
447
|
-
label: LocalizedText;
|
|
448
444
|
facts: UsageSnapshot;
|
|
449
445
|
} | {
|
|
450
446
|
id: "cwd";
|
|
451
|
-
label: LocalizedText;
|
|
452
447
|
facts: FolderFact;
|
|
453
448
|
} | {
|
|
454
449
|
id: "tools";
|
|
455
|
-
label: LocalizedText;
|
|
456
450
|
facts: {
|
|
457
451
|
running: RunningTool[];
|
|
458
452
|
};
|
|
459
453
|
} | {
|
|
460
454
|
id: "subagents";
|
|
461
|
-
label: LocalizedText;
|
|
462
455
|
facts: {
|
|
463
456
|
items: SubAgentSnapshot[];
|
|
464
457
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-zen/agents-host",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.4",
|
|
4
4
|
"description": "AI-Zen Agents Host — session/workspace service shared by CLI and Desktop",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
"build": "tsc",
|
|
62
62
|
"pretest": "tsc --noEmit -p tsconfig.test.json",
|
|
63
63
|
"test": "vitest run",
|
|
64
|
-
"test:all": "npm run pretest && vitest run && npm run build"
|
|
64
|
+
"test:all": "npm run pretest && vitest run && npm run build && vitest run --config vitest.e2e.config.ts",
|
|
65
|
+
"test:e2e": "npm run pretest && vitest run --config vitest.e2e.config.ts"
|
|
65
66
|
}
|
|
66
67
|
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 能力清单(PRD F-E5 / F-E6 / F-F9,裁定 R6)。
|
|
3
|
-
*
|
|
4
|
-
* 清单是「帮助页与指令菜单渲染用的那一份真相」,所以它必须与契约同步:每一项对应
|
|
5
|
-
* `MethodMap` 里的一个方法名,编号取 PRD §4 那一行的能力号(`wire/methods.ts` 里每个方法
|
|
6
|
-
* 的注释就写着自己的编号)。没有编号的方法用契约注释里记的那条决定编号(`workspace.*` 是
|
|
7
|
-
* `D9`/`D10`/`D11`:PRD §4 当初没给项目单列能力行),不另编一个。
|
|
8
|
-
*
|
|
9
|
-
* 三件事刻意分开:
|
|
10
|
-
* - **标题与说明**:`LocalizedText`,按连接语言渲染(D8),文案键在 `i18n/`;
|
|
11
|
-
* - **`blocking`**:执行期间会不会占住这段对话(F-E6 让界面显示「正在执行什么」);
|
|
12
|
-
* - **`destructive`**:有不可撤销的后果(F-F9 的二次确认)。
|
|
13
|
-
*
|
|
14
|
-
* 编号撞车的场合(几个方法服务同一条能力,例如 `config.saveEndpoint` / `config.deleteEndpoint`
|
|
15
|
-
* 都属于 F-F2)用 `<编号>#<动作>` 做 id:编号仍是 PRD 的那个,id 保持唯一,客户端可以按 id 存
|
|
16
|
-
* 展开状态。顺序与 `METHOD_NAMES` 一致,帮助页读起来就是「按域分组的办法清单」。
|
|
17
|
-
*/
|
|
18
|
-
import type { Language } from "../i18n/index.js";
|
|
19
|
-
import type { CapabilityView } from "../wire/index.js";
|
|
20
|
-
/**
|
|
21
|
-
* 造能力清单。
|
|
22
|
-
*
|
|
23
|
-
* 默认语言渲染一份:`host.hello` 与 `host.capabilities` 的出参都要能在不知道收件人语言时
|
|
24
|
-
* 先给出形状,客户端按自己的语言用 `messageKey` + `params` 重渲染(D8 的同一套口径)。
|
|
25
|
-
*/
|
|
26
|
-
export declare function createCapabilities(language?: Language): CapabilityView[];
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 能力清单(PRD F-E5 / F-E6 / F-F9,裁定 R6)。
|
|
3
|
-
*
|
|
4
|
-
* 清单是「帮助页与指令菜单渲染用的那一份真相」,所以它必须与契约同步:每一项对应
|
|
5
|
-
* `MethodMap` 里的一个方法名,编号取 PRD §4 那一行的能力号(`wire/methods.ts` 里每个方法
|
|
6
|
-
* 的注释就写着自己的编号)。没有编号的方法用契约注释里记的那条决定编号(`workspace.*` 是
|
|
7
|
-
* `D9`/`D10`/`D11`:PRD §4 当初没给项目单列能力行),不另编一个。
|
|
8
|
-
*
|
|
9
|
-
* 三件事刻意分开:
|
|
10
|
-
* - **标题与说明**:`LocalizedText`,按连接语言渲染(D8),文案键在 `i18n/`;
|
|
11
|
-
* - **`blocking`**:执行期间会不会占住这段对话(F-E6 让界面显示「正在执行什么」);
|
|
12
|
-
* - **`destructive`**:有不可撤销的后果(F-F9 的二次确认)。
|
|
13
|
-
*
|
|
14
|
-
* 编号撞车的场合(几个方法服务同一条能力,例如 `config.saveEndpoint` / `config.deleteEndpoint`
|
|
15
|
-
* 都属于 F-F2)用 `<编号>#<动作>` 做 id:编号仍是 PRD 的那个,id 保持唯一,客户端可以按 id 存
|
|
16
|
-
* 展开状态。顺序与 `METHOD_NAMES` 一致,帮助页读起来就是「按域分组的办法清单」。
|
|
17
|
-
*/
|
|
18
|
-
import { DEFAULT_LANGUAGE, render } from "../i18n/index.js";
|
|
19
|
-
import { methodDomain } from "../wire/index.js";
|
|
20
|
-
/**
|
|
21
|
-
* 清单本体:**每个方法一条**,且与 `METHOD_NAMES` 一一对应(用例会钉住这条)。
|
|
22
|
-
*
|
|
23
|
-
* `blocking` 只标「跑起来时这段对话不能发下一条」的那几个:一轮对话、交接回合、
|
|
24
|
-
* 临时对话(它借的 Scope 与项目共用,跑的时候同样不能被打断)。
|
|
25
|
-
* `destructive` 只标「做下去就回不来」的那几个:删项目 / 删对话 / 撤回 / 删端点 /
|
|
26
|
-
* 删助手 / 删模型(含图片模型)/ 删 MCP 条目 / 恢复出厂。清通知不算:它清的是
|
|
27
|
-
* 界面上的一条提示,为它弹二次确认反而是打扰。
|
|
28
|
-
*
|
|
29
|
-
* 两样东西刻意不在这份清单里(裁定 2026-11-13):
|
|
30
|
-
* - `host.usage`:「按项目 / 整机」的用量聚合没有任何客户端消费,F-I5 的落点在
|
|
31
|
-
* `conversation.state` 的 `usage`;
|
|
32
|
-
* - `credential.*`:凭据由宿主自己管理(`agents-host token create|list|revoke`),
|
|
33
|
-
* 客户端只有「连接管理 + 记住密码」,那里没有可渲染的能力。
|
|
34
|
-
*/
|
|
35
|
-
const FACTS = [
|
|
36
|
-
{ method: "host.hello", prd: "F-A1", blocking: false, destructive: false },
|
|
37
|
-
{ method: "host.version", prd: "F-E3", blocking: false, destructive: false },
|
|
38
|
-
{ method: "host.upgrade", prd: "F-E3", blocking: false, destructive: false },
|
|
39
|
-
{ method: "host.shutdown", prd: "F-E1", blocking: false, destructive: false },
|
|
40
|
-
{ method: "host.capabilities", prd: "F-E5", blocking: false, destructive: false },
|
|
41
|
-
{ method: "host.reload", prd: "F-E1", blocking: false, destructive: false },
|
|
42
|
-
{ method: "host.setLanguage", prd: "F-E4", blocking: false, destructive: false },
|
|
43
|
-
{ method: "workspace.list", prd: "D9", blocking: false, destructive: false },
|
|
44
|
-
{ method: "workspace.create", prd: "D10", blocking: false, destructive: false },
|
|
45
|
-
{ method: "workspace.get", prd: "D9", blocking: false, destructive: false },
|
|
46
|
-
{ method: "workspace.rename", prd: "D9", blocking: false, destructive: false },
|
|
47
|
-
{ method: "workspace.remove", prd: "D11", blocking: false, destructive: true },
|
|
48
|
-
{ method: "conversation.list", prd: "F-C5", blocking: false, destructive: false },
|
|
49
|
-
{ method: "conversation.create", prd: "F-C7", blocking: false, destructive: false },
|
|
50
|
-
{ method: "conversation.get", prd: "F-A6", blocking: false, destructive: false },
|
|
51
|
-
{ method: "conversation.state", prd: "F-I3", blocking: false, destructive: false },
|
|
52
|
-
{ method: "conversation.rename", prd: "F-C3", blocking: false, destructive: false },
|
|
53
|
-
{ method: "conversation.pin", prd: "F-C5", blocking: false, destructive: false },
|
|
54
|
-
{ method: "conversation.delete", prd: "F-C10", blocking: false, destructive: true },
|
|
55
|
-
{ method: "conversation.send", prd: "F-C2", blocking: true, destructive: false },
|
|
56
|
-
{ method: "conversation.abort", prd: "F-E1", blocking: false, destructive: false },
|
|
57
|
-
{ method: "conversation.revert", prd: "F-C8", blocking: false, destructive: true },
|
|
58
|
-
{ method: "conversation.setModel", prd: "F-B4", blocking: false, destructive: false },
|
|
59
|
-
{ method: "conversation.setThinking", prd: "F-B6", blocking: false, destructive: false },
|
|
60
|
-
{ method: "conversation.transient", prd: "F-A2", blocking: true, destructive: false },
|
|
61
|
-
{ method: "message.list", prd: "F-I7", blocking: false, destructive: false },
|
|
62
|
-
{ method: "question.list", prd: "F-I9", blocking: false, destructive: false },
|
|
63
|
-
{ method: "question.answer", prd: "F-I9", blocking: false, destructive: false },
|
|
64
|
-
{ method: "notice.list", prd: "F-I8", blocking: false, destructive: false },
|
|
65
|
-
{ method: "notice.dismiss", prd: "F-I8", blocking: false, destructive: false },
|
|
66
|
-
{ method: "notice.clear", prd: "F-I8", blocking: false, destructive: false },
|
|
67
|
-
{ method: "config.get", prd: "F-F1", blocking: false, destructive: false },
|
|
68
|
-
{ method: "config.patch", prd: "F-F1", blocking: false, destructive: false },
|
|
69
|
-
{ method: "config.setDefaults", prd: "F-F7", blocking: false, destructive: false },
|
|
70
|
-
{ method: "config.getDiscovery", prd: "F-G1", blocking: false, destructive: false },
|
|
71
|
-
{ method: "config.saveMcp", prd: "F-F6", blocking: false, destructive: false },
|
|
72
|
-
{ method: "config.deleteMcp", prd: "F-G1", blocking: false, destructive: true },
|
|
73
|
-
{ method: "config.saveEndpoint", prd: "F-F2", blocking: false, destructive: false },
|
|
74
|
-
{ method: "config.deleteEndpoint", prd: "F-F2", blocking: false, destructive: true },
|
|
75
|
-
{ method: "agent.list", prd: "F-B2", blocking: false, destructive: false },
|
|
76
|
-
{ method: "agent.get", prd: "F-B2", blocking: false, destructive: false },
|
|
77
|
-
{ method: "agent.create", prd: "F-B2", blocking: false, destructive: false },
|
|
78
|
-
{ method: "agent.update", prd: "F-B2", blocking: false, destructive: false },
|
|
79
|
-
{ method: "agent.delete", prd: "F-F5", blocking: false, destructive: true },
|
|
80
|
-
{ method: "agent.setModel", prd: "F-B4", blocking: false, destructive: false },
|
|
81
|
-
{ method: "agent.setThinking", prd: "F-B6", blocking: false, destructive: false },
|
|
82
|
-
{ method: "agent.restoreFactory", prd: "F-F5", blocking: false, destructive: true },
|
|
83
|
-
{ method: "model.list", prd: "F-F3", blocking: false, destructive: false },
|
|
84
|
-
{ method: "model.listImages", prd: "F-F4", blocking: false, destructive: false },
|
|
85
|
-
{ method: "model.create", prd: "F-F3", blocking: false, destructive: false },
|
|
86
|
-
{ method: "model.update", prd: "F-F3", blocking: false, destructive: false },
|
|
87
|
-
{ method: "model.delete", prd: "F-F3", blocking: false, destructive: true },
|
|
88
|
-
{ method: "model.restoreFactory", prd: "F-F3", blocking: false, destructive: true },
|
|
89
|
-
{ method: "model.saveImage", prd: "F-F4", blocking: false, destructive: false },
|
|
90
|
-
{ method: "model.deleteImage", prd: "F-F4", blocking: false, destructive: true },
|
|
91
|
-
{ method: "asset.begin", prd: "F-H8", blocking: false, destructive: false },
|
|
92
|
-
{ method: "asset.end", prd: "F-H8", blocking: false, destructive: false },
|
|
93
|
-
{ method: "asset.get", prd: "F-H7", blocking: false, destructive: false },
|
|
94
|
-
{ method: "completion.files", prd: "F-H5", blocking: false, destructive: false },
|
|
95
|
-
{ method: "handoff.start", prd: "F-D5", blocking: true, destructive: false },
|
|
96
|
-
{ method: "handoff.listDocuments", prd: "F-D6", blocking: false, destructive: false },
|
|
97
|
-
{ method: "search.conversations", prd: "F-C6", blocking: false, destructive: false },
|
|
98
|
-
{ method: "search.messages", prd: "F-C6", blocking: false, destructive: false },
|
|
99
|
-
];
|
|
100
|
-
/** 标题的文案键(`capability.<方法名>`) */
|
|
101
|
-
function titleKey(method) {
|
|
102
|
-
return `capability.${method}`;
|
|
103
|
-
}
|
|
104
|
-
/** 说明的文案键(`capability.<方法名>.detail`) */
|
|
105
|
-
function detailKey(method) {
|
|
106
|
-
return `capability.${method}.detail`;
|
|
107
|
-
}
|
|
108
|
-
/** 一句话:码 + 参数 + 按给定语言渲染的句子(存码不存句子,D8) */
|
|
109
|
-
function text(key, language) {
|
|
110
|
-
return { code: key, messageKey: key, params: {}, message: render(language, key) };
|
|
111
|
-
}
|
|
112
|
-
/** 动作名(`conversation.send` → `send`),编号撞车时用来给 id 去重 */
|
|
113
|
-
function actionOf(method) {
|
|
114
|
-
return method.slice(method.indexOf(".") + 1);
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* 造能力清单。
|
|
118
|
-
*
|
|
119
|
-
* 默认语言渲染一份:`host.hello` 与 `host.capabilities` 的出参都要能在不知道收件人语言时
|
|
120
|
-
* 先给出形状,客户端按自己的语言用 `messageKey` + `params` 重渲染(D8 的同一套口径)。
|
|
121
|
-
*/
|
|
122
|
-
export function createCapabilities(language = DEFAULT_LANGUAGE) {
|
|
123
|
-
const used = new Set();
|
|
124
|
-
return FACTS.map((fact) => {
|
|
125
|
-
// 同一个编号下的第二个及以后的方法:`<编号>#<动作>`
|
|
126
|
-
const id = used.has(fact.prd) ? `${fact.prd}#${actionOf(fact.method)}` : fact.prd;
|
|
127
|
-
used.add(fact.prd);
|
|
128
|
-
return {
|
|
129
|
-
id,
|
|
130
|
-
domain: methodDomain(fact.method),
|
|
131
|
-
title: text(titleKey(fact.method), language),
|
|
132
|
-
description: text(detailKey(fact.method), language),
|
|
133
|
-
method: fact.method,
|
|
134
|
-
blocking: fact.blocking,
|
|
135
|
-
destructive: fact.destructive,
|
|
136
|
-
};
|
|
137
|
-
});
|
|
138
|
-
}
|