@njuptlzf/agent-chat-server 0.2.0 → 0.3.0

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.
@@ -0,0 +1,126 @@
1
+ import type { Branding } from "@njuptlzf/agent-chat-protocol";
2
+
3
+ type BrandingUi = NonNullable<Branding["ui"]>;
4
+ type BrandingFollowUp = NonNullable<BrandingUi["followUp"]>;
5
+
6
+ /** 「下一步建议」的三态。全局(branding.ui.followUp.mode)与人格(PersonaUi.followUpMode)共用这一份。 */
7
+ export const FOLLOW_UP_MODES = ["off", "static", "llm"] as const;
8
+ export type FollowUpMode = (typeof FOLLOW_UP_MODES)[number];
9
+
10
+ /** 图标语义槽白名单:键是平台定义的槽名,不是组件名。新增视觉件时在这里登记。 */
11
+ export const ICON_SLOTS = ["attachment"] as const;
12
+
13
+ const FOLLOW_UP_KEYS: readonly string[] = ["mode", "count", "static", "systemPrompt", "maxMessages", "timeoutMs"];
14
+
15
+ const MAX_ICON_VALUE = 512;
16
+ const MAX_STATIC_ITEMS = 10;
17
+ const MAX_STATIC_CHARS = 200;
18
+ const MAX_PROMPT_CHARS = 2000;
19
+ const MAX_COUNT = 5;
20
+ const MAX_MESSAGES = 20;
21
+ const MAX_TIMEOUT_MS = 30_000;
22
+
23
+ function deny(file: string, msg: string): never {
24
+ throw new Error(`Invalid manifest ${file}: ${msg}`);
25
+ }
26
+
27
+ function isRecord(v: unknown): v is Record<string, unknown> {
28
+ return !!v && typeof v === "object" && !Array.isArray(v);
29
+ }
30
+
31
+ function isMode(v: unknown): v is FollowUpMode {
32
+ return typeof v === "string" && (FOLLOW_UP_MODES as readonly string[]).includes(v);
33
+ }
34
+
35
+ /**
36
+ * 校验并规范化 `branding.ui`(图标值 + 下一步建议配置)。
37
+ *
38
+ * 分级与人格 ui 同一套口径:未知键 / 形状错 = 启动期 fail-fast(manifest 是签入文件,
39
+ * 错别字必须响);单个图标值非法(如非 http(s) 的 url: 前缀)= 丢弃该键回落默认,不因
40
+ * 一个坏图标让服务起不来。返回 undefined 表示产品没配(或全被丢弃)。
41
+ */
42
+ export function parseBrandingUi(file: string, at: string, raw: unknown): BrandingUi | undefined {
43
+ if (raw === undefined) return undefined;
44
+ if (!isRecord(raw)) deny(file, `\`${at}\` must be a mapping`);
45
+ const src = raw as Record<string, unknown>;
46
+ for (const key of Object.keys(src)) {
47
+ if (key !== "icons" && key !== "followUp") {
48
+ deny(file, `\`${at}.${key}\` is not a branding ui field (allowed: icons, followUp)`);
49
+ }
50
+ }
51
+
52
+ let icons: Record<string, string> | undefined;
53
+ if (src.icons !== undefined) {
54
+ if (!isRecord(src.icons)) deny(file, `\`${at}.icons\` must be a mapping`);
55
+ const srcIcons = src.icons as Record<string, unknown>;
56
+ for (const [key, value] of Object.entries(srcIcons)) {
57
+ if (!(ICON_SLOTS as readonly string[]).includes(key)) {
58
+ deny(file, `\`${at}.icons.${key}\` is not a known icon slot (allowed: ${ICON_SLOTS.join(", ")})`);
59
+ }
60
+ if (typeof value !== "string" || value.trim() === "") {
61
+ deny(file, `\`${at}.icons.${key}\` must be a non-empty string`);
62
+ }
63
+ if (value.length > MAX_ICON_VALUE) {
64
+ deny(file, `\`${at}.icons.${key}\` must be at most ${MAX_ICON_VALUE} characters`);
65
+ }
66
+ // url: 前缀只放行 http(s);别的协议(如 javascript:)丢弃该键回落默认,不 fail。
67
+ if (value.startsWith("url:") && !/^url:https?:\/\/\S+$/i.test(value)) continue;
68
+ (icons ??= {})[key] = value;
69
+ }
70
+ if (icons && Object.keys(icons).length === 0) icons = undefined;
71
+ }
72
+
73
+ let followUp: BrandingFollowUp | undefined;
74
+ if (src.followUp !== undefined) {
75
+ if (!isRecord(src.followUp)) deny(file, `\`${at}.followUp\` must be a mapping`);
76
+ const fu = src.followUp as Record<string, unknown>;
77
+ for (const key of Object.keys(fu)) {
78
+ if (!FOLLOW_UP_KEYS.includes(key)) {
79
+ deny(file, `\`${at}.followUp.${key}\` is not a known field (allowed: ${FOLLOW_UP_KEYS.join(", ")})`);
80
+ }
81
+ }
82
+ followUp = {};
83
+ if (fu.mode !== undefined) {
84
+ if (!isMode(fu.mode)) deny(file, `\`${at}.followUp.mode\` must be one of ${FOLLOW_UP_MODES.join(" | ")}`);
85
+ followUp.mode = fu.mode;
86
+ }
87
+ if (fu.count !== undefined) {
88
+ const n = fu.count;
89
+ if (typeof n !== "number" || !Number.isInteger(n) || n < 1 || n > MAX_COUNT) {
90
+ deny(file, `\`${at}.followUp.count\` must be an integer between 1 and ${MAX_COUNT}`);
91
+ }
92
+ followUp.count = n;
93
+ }
94
+ if (fu.static !== undefined) {
95
+ const list = fu.static;
96
+ if (!Array.isArray(list) || list.length > MAX_STATIC_ITEMS || list.some((s) => typeof s !== "string" || !s.trim())) {
97
+ deny(file, `\`${at}.followUp.static\` must be a list of at most ${MAX_STATIC_ITEMS} non-empty strings`);
98
+ }
99
+ followUp.static = (list as string[]).map((s) => (s.length > MAX_STATIC_CHARS ? s.slice(0, MAX_STATIC_CHARS) : s));
100
+ }
101
+ if (fu.systemPrompt !== undefined) {
102
+ if (typeof fu.systemPrompt !== "string" || fu.systemPrompt.trim() === "") {
103
+ deny(file, `\`${at}.followUp.systemPrompt\` must be a non-empty string`);
104
+ }
105
+ followUp.systemPrompt = fu.systemPrompt.length > MAX_PROMPT_CHARS ? fu.systemPrompt.slice(0, MAX_PROMPT_CHARS) : fu.systemPrompt;
106
+ }
107
+ if (fu.maxMessages !== undefined) {
108
+ const n = fu.maxMessages;
109
+ if (typeof n !== "number" || !Number.isInteger(n) || n < 1 || n > MAX_MESSAGES) {
110
+ deny(file, `\`${at}.followUp.maxMessages\` must be an integer between 1 and ${MAX_MESSAGES}`);
111
+ }
112
+ followUp.maxMessages = n;
113
+ }
114
+ if (fu.timeoutMs !== undefined) {
115
+ const n = fu.timeoutMs;
116
+ if (typeof n !== "number" || !Number.isInteger(n) || n < 1 || n > MAX_TIMEOUT_MS) {
117
+ deny(file, `\`${at}.followUp.timeoutMs\` must be an integer between 1 and ${MAX_TIMEOUT_MS}`);
118
+ }
119
+ followUp.timeoutMs = n;
120
+ }
121
+ if (Object.keys(followUp).length === 0) followUp = undefined;
122
+ }
123
+
124
+ if (!icons && !followUp) return undefined;
125
+ return { ...(icons ? { icons } : {}), ...(followUp ? { followUp } : {}) };
126
+ }
package/src/events.ts CHANGED
@@ -1,206 +1,206 @@
1
- import type { AgentSessionEvent } from "@earendil-works/pi-coding-agent";
2
- import type { ChatEvent, TokenUsage, ToolResultView } from "@njuptlzf/agent-chat-protocol";
3
-
4
- type PiUsage = {
5
- input: number;
6
- output: number;
7
- cacheRead: number;
8
- cacheWrite: number;
9
- totalTokens: number;
10
- cost: { total: number };
11
- };
12
-
13
- export function emptyUsage(): TokenUsage {
14
- return { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0, costUsd: 0 };
15
- }
16
-
17
- function toTokenUsage(u: PiUsage): TokenUsage {
18
- return {
19
- input: u.input,
20
- output: u.output,
21
- cacheRead: u.cacheRead,
22
- cacheWrite: u.cacheWrite,
23
- total: u.totalTokens,
24
- costUsd: u.cost.total,
25
- };
26
- }
27
-
28
- function addUsage(a: TokenUsage, b: TokenUsage): TokenUsage {
29
- return {
30
- input: a.input + b.input,
31
- output: a.output + b.output,
32
- cacheRead: a.cacheRead + b.cacheRead,
33
- cacheWrite: a.cacheWrite + b.cacheWrite,
34
- total: a.total + b.total,
35
- costUsd: a.costUsd + b.costUsd,
36
- };
37
- }
38
-
39
- /**
40
- * 卡片数据:内联工具直接给 `details`;MCP 工具走 `structuredContent`
41
- * (pi 的 convertMcpResult 把它设成整个 CallToolResult,业务负载在内层
42
- * `structuredContent`,`details` 只剩 {server, tool})。前端只认负载,不认实现。
43
- */
44
- function cardOf(r: { details?: unknown; structuredContent?: unknown }): unknown {
45
- const sc = r.structuredContent;
46
- if (sc && typeof sc === "object") {
47
- const inner = (sc as { structuredContent?: unknown }).structuredContent;
48
- return inner && typeof inner === "object" ? inner : sc;
49
- }
50
- return r.details;
51
- }
52
-
53
- /** Flatten pi tool-result content into a text view the UI can show. */
54
- function toResultView(result: unknown): ToolResultView {
55
- const r = (result ?? {}) as {
56
- content?: Array<{ type: string; text?: string }>;
57
- details?: unknown;
58
- structuredContent?: unknown;
59
- };
60
- const text = (r.content ?? [])
61
- .filter((c) => c.type === "text" && typeof c.text === "string")
62
- .map((c) => c.text as string)
63
- .join("\n");
64
- return { text, details: cardOf(r) };
65
- }
66
-
67
- function assistantText(content: unknown): string {
68
- if (!Array.isArray(content)) return "";
69
- return content
70
- .filter((c: { type?: string }) => c?.type === "text")
71
- .map((c: { text?: string }) => c.text ?? "")
72
- .join("");
73
- }
74
-
75
- /**
76
- * 模型报错的用户文案(2026-11-04):pi 的 errorMessage 是原始串(如
77
- * `429: {"message":"inference exceeds tpm/rpm limit",...}`),直接下发会把
78
- * 上游 JSON 露进气泡。这里折叠成一句人话 + 保留状态码数字便于口头报障。
79
- * **failover 匹配不读这条文案**(见 server.ts 的 rawModelError)——它直接从
80
- * pi 原始事件取 errorMessage 做正则,用户文案怎么改都不影响切换逻辑。
81
- */
82
- export function friendlyModelError(raw: string | undefined): string {
83
- const msg = (raw ?? "").slice(0, 400);
84
- const status = /\b(4\d\d|5\d\d)\b/.exec(msg)?.[1];
85
- if (status === "429") return `模型限流中,请稍后再试,或在「管理 → 模型」调整档位(429)`;
86
- if (status === "401" || status === "403") return `模型服务鉴权失败,请检查模型配置或联系管理员(${status})`;
87
- if (status === "402") return "模型服务额度不足,请联系管理员(402)";
88
- if (status) return `模型服务暂时不可用,请稍后重试(${status})`;
89
- if (/timeout|timed out|ETIMEDOUT|ECONNRESET|ECONNREFUSED|socket hang up|fetch failed|network|ENOTFOUND|EAI_AGAIN/i.test(msg))
90
- return "连接模型服务的网络异常,请稍后重试";
91
- return "模型请求失败,请稍后重试";
92
- }
93
-
94
- export interface EventMapper {
95
- map(event: AgentSessionEvent): ChatEvent[];
96
- /** Usage accumulated across every assistant message seen so far. */
97
- totalUsage(): TokenUsage;
98
- }
99
-
100
- /**
101
- * Translate pi session events into the stable wire protocol.
102
- * Stateful (message ids, usage totals), so create one mapper per run.
103
- */
104
- export function createEventMapper(): EventMapper {
105
- let counter = 0;
106
- let currentMessageId = "";
107
- let total = emptyUsage();
108
-
109
- return {
110
- totalUsage: () => total,
111
- map(event) {
112
- switch (event.type) {
113
- case "message_start": {
114
- if ((event.message as { role?: string }).role === "assistant") {
115
- currentMessageId = `m${++counter}`;
116
- }
117
- return [];
118
- }
119
- case "message_update": {
120
- const ev = event.assistantMessageEvent;
121
- if (ev.type === "text_delta") {
122
- return [{ type: "text_delta", messageId: currentMessageId, delta: ev.delta }];
123
- }
124
- if (ev.type === "thinking_delta") {
125
- return [{ type: "thinking_delta", messageId: currentMessageId, delta: ev.delta }];
126
- }
127
- return [];
128
- }
129
- case "message_end": {
130
- const msg = event.message as {
131
- role?: string;
132
- content?: unknown;
133
- usage?: PiUsage;
134
- stopReason?: string;
135
- errorMessage?: string;
136
- };
137
- if (msg.role !== "assistant") return [];
138
- const out: ChatEvent[] = [];
139
- const usage = msg.usage ? toTokenUsage(msg.usage) : undefined;
140
- if (usage) total = addUsage(total, usage);
141
- out.push({
142
- type: "message_end",
143
- messageId: currentMessageId,
144
- text: assistantText(msg.content),
145
- usage,
146
- });
147
- if (msg.stopReason === "error") {
148
- out.push({
149
- type: "error",
150
- code: "model_error",
151
- message: friendlyModelError(msg.errorMessage),
152
- retryable: true,
153
- });
154
- }
155
- return out;
156
- }
157
- case "tool_execution_start":
158
- return [{ type: "tool_start", toolCallId: event.toolCallId, name: event.toolName, args: event.args }];
159
- case "tool_execution_update":
160
- return [{ type: "tool_update", toolCallId: event.toolCallId, partial: toResultView(event.partialResult) }];
161
- case "tool_execution_end":
162
- return [
163
- {
164
- type: "tool_end",
165
- toolCallId: event.toolCallId,
166
- name: event.toolName,
167
- ok: !event.isError,
168
- result: toResultView(event.result),
169
- durationMs: event.durationMs,
170
- },
171
- ];
172
- case "agent_settled":
173
- return [{ type: "done", aborted: event.aborted, usage: total }];
174
- default:
175
- return [];
176
- }
177
- },
178
- };
179
- }
180
-
181
- export interface RunAccounting {
182
- /** Feed each outgoing protocol event; counts completed tool rounds. */
183
- observe(ev: ChatEvent): void;
184
- toolRounds(): number;
185
- /** True once a completed tool round hit the configured cap. */
186
- limitHit(): boolean;
187
- }
188
-
189
- /**
190
- * Bounds one run's agentic loop: pi has no native turn cap, so the server
191
- * counts tool rounds on the wire and aborts when the cap is hit.
192
- */
193
- export function createRunAccounting(maxToolRounds: number | undefined): RunAccounting {
194
- let rounds = 0;
195
- let hit = false;
196
- return {
197
- observe(ev) {
198
- if (ev.type === "tool_end") {
199
- rounds++;
200
- if (maxToolRounds !== undefined && rounds >= maxToolRounds) hit = true;
201
- }
202
- },
203
- toolRounds: () => rounds,
204
- limitHit: () => hit,
205
- };
206
- }
1
+ import type { AgentSessionEvent } from "@earendil-works/pi-coding-agent";
2
+ import type { ChatEvent, TokenUsage, ToolResultView } from "@njuptlzf/agent-chat-protocol";
3
+
4
+ type PiUsage = {
5
+ input: number;
6
+ output: number;
7
+ cacheRead: number;
8
+ cacheWrite: number;
9
+ totalTokens: number;
10
+ cost: { total: number };
11
+ };
12
+
13
+ export function emptyUsage(): TokenUsage {
14
+ return { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0, costUsd: 0 };
15
+ }
16
+
17
+ function toTokenUsage(u: PiUsage): TokenUsage {
18
+ return {
19
+ input: u.input,
20
+ output: u.output,
21
+ cacheRead: u.cacheRead,
22
+ cacheWrite: u.cacheWrite,
23
+ total: u.totalTokens,
24
+ costUsd: u.cost.total,
25
+ };
26
+ }
27
+
28
+ function addUsage(a: TokenUsage, b: TokenUsage): TokenUsage {
29
+ return {
30
+ input: a.input + b.input,
31
+ output: a.output + b.output,
32
+ cacheRead: a.cacheRead + b.cacheRead,
33
+ cacheWrite: a.cacheWrite + b.cacheWrite,
34
+ total: a.total + b.total,
35
+ costUsd: a.costUsd + b.costUsd,
36
+ };
37
+ }
38
+
39
+ /**
40
+ * 卡片数据:内联工具直接给 `details`;MCP 工具走 `structuredContent`
41
+ * (pi 的 convertMcpResult 把它设成整个 CallToolResult,业务负载在内层
42
+ * `structuredContent`,`details` 只剩 {server, tool})。前端只认负载,不认实现。
43
+ */
44
+ function cardOf(r: { details?: unknown; structuredContent?: unknown }): unknown {
45
+ const sc = r.structuredContent;
46
+ if (sc && typeof sc === "object") {
47
+ const inner = (sc as { structuredContent?: unknown }).structuredContent;
48
+ return inner && typeof inner === "object" ? inner : sc;
49
+ }
50
+ return r.details;
51
+ }
52
+
53
+ /** Flatten pi tool-result content into a text view the UI can show. */
54
+ function toResultView(result: unknown): ToolResultView {
55
+ const r = (result ?? {}) as {
56
+ content?: Array<{ type: string; text?: string }>;
57
+ details?: unknown;
58
+ structuredContent?: unknown;
59
+ };
60
+ const text = (r.content ?? [])
61
+ .filter((c) => c.type === "text" && typeof c.text === "string")
62
+ .map((c) => c.text as string)
63
+ .join("\n");
64
+ return { text, details: cardOf(r) };
65
+ }
66
+
67
+ function assistantText(content: unknown): string {
68
+ if (!Array.isArray(content)) return "";
69
+ return content
70
+ .filter((c: { type?: string }) => c?.type === "text")
71
+ .map((c: { text?: string }) => c.text ?? "")
72
+ .join("");
73
+ }
74
+
75
+ /**
76
+ * 模型报错的用户文案(2026-11-04):pi 的 errorMessage 是原始串(如
77
+ * `429: {"message":"inference exceeds tpm/rpm limit",...}`),直接下发会把
78
+ * 上游 JSON 露进气泡。这里折叠成一句人话 + 保留状态码数字便于口头报障。
79
+ * **failover 匹配不读这条文案**(见 server.ts 的 rawModelError)——它直接从
80
+ * pi 原始事件取 errorMessage 做正则,用户文案怎么改都不影响切换逻辑。
81
+ */
82
+ export function friendlyModelError(raw: string | undefined): string {
83
+ const msg = (raw ?? "").slice(0, 400);
84
+ const status = /\b(4\d\d|5\d\d)\b/.exec(msg)?.[1];
85
+ if (status === "429") return `模型限流中,请稍后再试,或在「管理 → 模型」调整档位(429)`;
86
+ if (status === "401" || status === "403") return `模型服务鉴权失败,请检查模型配置或联系管理员(${status})`;
87
+ if (status === "402") return "模型服务额度不足,请联系管理员(402)";
88
+ if (status) return `模型服务暂时不可用,请稍后重试(${status})`;
89
+ if (/timeout|timed out|ETIMEDOUT|ECONNRESET|ECONNREFUSED|socket hang up|fetch failed|network|ENOTFOUND|EAI_AGAIN/i.test(msg))
90
+ return "连接模型服务的网络异常,请稍后重试";
91
+ return "模型请求失败,请稍后重试";
92
+ }
93
+
94
+ export interface EventMapper {
95
+ map(event: AgentSessionEvent): ChatEvent[];
96
+ /** Usage accumulated across every assistant message seen so far. */
97
+ totalUsage(): TokenUsage;
98
+ }
99
+
100
+ /**
101
+ * Translate pi session events into the stable wire protocol.
102
+ * Stateful (message ids, usage totals), so create one mapper per run.
103
+ */
104
+ export function createEventMapper(): EventMapper {
105
+ let counter = 0;
106
+ let currentMessageId = "";
107
+ let total = emptyUsage();
108
+
109
+ return {
110
+ totalUsage: () => total,
111
+ map(event) {
112
+ switch (event.type) {
113
+ case "message_start": {
114
+ if ((event.message as { role?: string }).role === "assistant") {
115
+ currentMessageId = `m${++counter}`;
116
+ }
117
+ return [];
118
+ }
119
+ case "message_update": {
120
+ const ev = event.assistantMessageEvent;
121
+ if (ev.type === "text_delta") {
122
+ return [{ type: "text_delta", messageId: currentMessageId, delta: ev.delta }];
123
+ }
124
+ if (ev.type === "thinking_delta") {
125
+ return [{ type: "thinking_delta", messageId: currentMessageId, delta: ev.delta }];
126
+ }
127
+ return [];
128
+ }
129
+ case "message_end": {
130
+ const msg = event.message as {
131
+ role?: string;
132
+ content?: unknown;
133
+ usage?: PiUsage;
134
+ stopReason?: string;
135
+ errorMessage?: string;
136
+ };
137
+ if (msg.role !== "assistant") return [];
138
+ const out: ChatEvent[] = [];
139
+ const usage = msg.usage ? toTokenUsage(msg.usage) : undefined;
140
+ if (usage) total = addUsage(total, usage);
141
+ out.push({
142
+ type: "message_end",
143
+ messageId: currentMessageId,
144
+ text: assistantText(msg.content),
145
+ usage,
146
+ });
147
+ if (msg.stopReason === "error") {
148
+ out.push({
149
+ type: "error",
150
+ code: "model_error",
151
+ message: friendlyModelError(msg.errorMessage),
152
+ retryable: true,
153
+ });
154
+ }
155
+ return out;
156
+ }
157
+ case "tool_execution_start":
158
+ return [{ type: "tool_start", toolCallId: event.toolCallId, name: event.toolName, args: event.args }];
159
+ case "tool_execution_update":
160
+ return [{ type: "tool_update", toolCallId: event.toolCallId, partial: toResultView(event.partialResult) }];
161
+ case "tool_execution_end":
162
+ return [
163
+ {
164
+ type: "tool_end",
165
+ toolCallId: event.toolCallId,
166
+ name: event.toolName,
167
+ ok: !event.isError,
168
+ result: toResultView(event.result),
169
+ durationMs: event.durationMs,
170
+ },
171
+ ];
172
+ case "agent_settled":
173
+ return [{ type: "done", aborted: event.aborted, usage: total }];
174
+ default:
175
+ return [];
176
+ }
177
+ },
178
+ };
179
+ }
180
+
181
+ export interface RunAccounting {
182
+ /** Feed each outgoing protocol event; counts completed tool rounds. */
183
+ observe(ev: ChatEvent): void;
184
+ toolRounds(): number;
185
+ /** True once a completed tool round hit the configured cap. */
186
+ limitHit(): boolean;
187
+ }
188
+
189
+ /**
190
+ * Bounds one run's agentic loop: pi has no native turn cap, so the server
191
+ * counts tool rounds on the wire and aborts when the cap is hit.
192
+ */
193
+ export function createRunAccounting(maxToolRounds: number | undefined): RunAccounting {
194
+ let rounds = 0;
195
+ let hit = false;
196
+ return {
197
+ observe(ev) {
198
+ if (ev.type === "tool_end") {
199
+ rounds++;
200
+ if (maxToolRounds !== undefined && rounds >= maxToolRounds) hit = true;
201
+ }
202
+ },
203
+ toolRounds: () => rounds,
204
+ limitHit: () => hit,
205
+ };
206
+ }
package/src/index.ts CHANGED
@@ -1,26 +1,26 @@
1
- /**
2
- * `@njuptlzf/agent-chat-server` 的公共入口。
3
- *
4
- * 只导出《[PUBLIC_API](../../../docs/design/PUBLIC_API.md)》登记的 18 项
5
- * 「被产品侧具名 import」的符号。产品仓通过 `@njuptlzf/agent-chat-server` 消费平台,
6
- * 不再走 `packages/server/src/*` 深路径;平台其余导出都是内部实现,随时可改。
7
- *
8
- * 增删导出必须同批改:PUBLIC_API.md、package.json 的 `exports`、
9
- * `packages/server/test/public-api.test.ts`(那条测试会数条数)。
10
- */
11
- export type { LoadedProduct, ToolContext } from "./manifest.ts";
12
- export { personaIdsOf } from "./manifest.ts";
13
- export type { ProductAdminRoute, ProductRoute, ServerDeps } from "./server.ts";
14
- export {
15
- auditDeny,
16
- auditedWrite,
17
- DRAFT_ID,
18
- deny401,
19
- MAX_ESSAY_CHARS,
20
- readJson,
21
- sendError,
22
- sendJson,
23
- SESSION_ID,
24
- } from "./server.ts";
25
- export { openDatabase, SqliteAccountState } from "./sqlite-stores.ts";
26
- export { localDay } from "./util.ts";
1
+ /**
2
+ * `@njuptlzf/agent-chat-server` 的公共入口。
3
+ *
4
+ * 只导出《[PUBLIC_API](../../../docs/design/PUBLIC_API.md)》登记的 18 项
5
+ * 「被产品侧具名 import」的符号。产品仓通过 `@njuptlzf/agent-chat-server` 消费平台,
6
+ * 不再走 `packages/server/src/*` 深路径;平台其余导出都是内部实现,随时可改。
7
+ *
8
+ * 增删导出必须同批改:PUBLIC_API.md、package.json 的 `exports`、
9
+ * `packages/server/test/public-api.test.ts`(那条测试会数条数)。
10
+ */
11
+ export type { LoadedProduct, ToolContext } from "./manifest.ts";
12
+ export { personaIdsOf } from "./manifest.ts";
13
+ export type { ProductAdminRoute, ProductRoute, ServerDeps } from "./server.ts";
14
+ export {
15
+ auditDeny,
16
+ auditedWrite,
17
+ DRAFT_ID,
18
+ deny401,
19
+ MAX_ESSAY_CHARS,
20
+ readJson,
21
+ sendError,
22
+ sendJson,
23
+ SESSION_ID,
24
+ } from "./server.ts";
25
+ export { openDatabase, SqliteAccountState } from "./sqlite-stores.ts";
26
+ export { localDay } from "./util.ts";