page-agent-sdk 2.23.0 → 2.24.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.
- package/README.md +3 -3
- package/README.zh-CN.md +3 -3
- package/dist/page-agent-sdk.css +1 -1
- package/dist/page-agent-sdk.iife.js +129 -127
- package/dist/page-agent-sdk.js +3469 -3267
- package/dist/page-agent-sdk.umd.cjs +75 -73
- package/package.json +1 -1
- package/types/index.d.ts +25 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "page-agent-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.24.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "AI agent SDK for web pages — embed a chat assistant that edits page data via schema-validated tools. A lighter, framework-agnostic alternative to CopilotKit/LangChain for in-page JSON-editing agents. Vue-bundled; works with DeepSeek, OpenAI, MCP.",
|
|
6
6
|
"main": "./dist/page-agent-sdk.umd.cjs",
|
package/types/index.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export interface ToolStep {
|
|
|
21
21
|
args?: any;
|
|
22
22
|
result?: string;
|
|
23
23
|
status: 'running' | 'done' | 'error';
|
|
24
|
+
/** 工具执行耗时(毫秒,tool_result 时回填) */
|
|
25
|
+
durationMs?: number;
|
|
24
26
|
/** 子 agent 工具步骤(spawn 委派时展示子进度) */
|
|
25
27
|
children?: ToolStep[];
|
|
26
28
|
}
|
|
@@ -152,6 +154,8 @@ export interface SubagentConfig {
|
|
|
152
154
|
}
|
|
153
155
|
export interface AgentInfo {
|
|
154
156
|
id: string;
|
|
157
|
+
/** 当前会话 id(switchSession/onClear 后实时反映) */
|
|
158
|
+
sessionId: string;
|
|
155
159
|
model?: string;
|
|
156
160
|
/** 当前生效的 systemPrompt(默认或用户传入;仅 base 段,不含中间件 augmentPrompt,便于调试/验证默认提示词) */
|
|
157
161
|
systemPrompt: string;
|
|
@@ -412,6 +416,8 @@ export interface SessionStore {
|
|
|
412
416
|
listSessions(agentId: string): Promise<SessionMeta[]>;
|
|
413
417
|
load(agentId: string, sessionId: string): Promise<SessionSnapshot | undefined>;
|
|
414
418
|
save(agentId: string, sessionId: string, snap: Partial<SessionSnapshot>): Promise<void>;
|
|
419
|
+
/** 更新会话标题(自动从首条 user 消息生成,供历史列表显示) */
|
|
420
|
+
updateTitle(agentId: string, sessionId: string, title: string): Promise<void>;
|
|
415
421
|
flush(): Promise<void>;
|
|
416
422
|
deleteSession(agentId: string, sessionId: string): Promise<void>;
|
|
417
423
|
createSession(agentId: string, title?: string, sessionId?: string): Promise<string>;
|
|
@@ -540,6 +546,10 @@ export interface ChatSdkOptions {
|
|
|
540
546
|
contextPreset?: 'auto' | 'conservative' | 'aggressive' | 'complex';
|
|
541
547
|
/** 摘要压缩专用 LLM(BaseChatModel 实例或 LLMConfig);不传则默认用主 agent 模型(llm) */
|
|
542
548
|
summaryLlm?: any;
|
|
549
|
+
/** 标题生成 LLM(BaseChatModel 实例或 LLMConfig);不传则用 summaryLlm → 主 llm。首轮后自动生成会话标题(主旨) */
|
|
550
|
+
titleLlm?: any;
|
|
551
|
+
/** 自动生成会话标题(默认 true:首轮后调 LLM 生成主旨标题;false 关闭,用规则 deriveTitle 截取) */
|
|
552
|
+
autoTitle?: boolean;
|
|
543
553
|
/** 摘要 LLM 温度(默认 0.3) */
|
|
544
554
|
summaryTemperature?: number;
|
|
545
555
|
/** 摘要 LLM 输出上限(默认 1024) */
|
|
@@ -602,6 +612,14 @@ export interface ChatSdk {
|
|
|
602
612
|
show(): void;
|
|
603
613
|
send(message: string, options?: { mission?: Partial<Mission> }): Promise<string>;
|
|
604
614
|
switchSession(sessionId?: string): Promise<string>;
|
|
615
|
+
/** 列出当前 agent 的所有历史会话(供「历史列表」UI;storage 未开启 → []) */
|
|
616
|
+
listSessions(): Promise<SessionMeta[]>;
|
|
617
|
+
/** 历史会话列表(响应式;switchSession/deleteSession/onClear/init 后自动 refresh;直接消费无需手动 listSessions/refresh/hook) */
|
|
618
|
+
readonly sessions: import('vue').Ref<SessionMeta[]>;
|
|
619
|
+
/** 删除指定历史会话;不可删除当前会话(删当前请先 switchSession 切走);storage 未开启 → no-op + warn */
|
|
620
|
+
deleteSession(sessionId: string): Promise<void>;
|
|
621
|
+
/** 当前会话 id(switchSession/onClear 后实时反映;供历史列表高亮当前项) */
|
|
622
|
+
readonly sessionId: string;
|
|
605
623
|
stream: (messages: AgentMessage[], onEvent: StreamHandler, signal?: AbortSignal) => Promise<string>;
|
|
606
624
|
/** 检视 agent 详细信息(tools/skills/data/middleware/todos) */
|
|
607
625
|
inspect(): AgentInfo;
|
|
@@ -818,6 +836,7 @@ export declare function recallRounds(older: any[], query: string, topK: number):
|
|
|
818
836
|
// ============ LLM 解析(llmResolver,refactor-module-extraction 期二 从 createChatSdk 抽离)============
|
|
819
837
|
export declare function isChatModel(v: unknown): boolean;
|
|
820
838
|
export declare function resolveLlm(options: any): { modelCaps: any; summaryLlmInvoke: ((prompt: string) => Promise<string>) | undefined };
|
|
839
|
+
export declare function deriveTitle(msgs: AgentMessage[]): string | undefined;
|
|
821
840
|
// ============ 乐观锁冲突管理器(conflictManager,refactor-module-extraction 期二 从 createChatSdk 抽离)============
|
|
822
841
|
export interface ConflictManager {
|
|
823
842
|
pendingConflict: import('vue').Ref<any | null>;
|
|
@@ -1038,3 +1057,9 @@ export interface ModelCaps { [k: string]: any }
|
|
|
1038
1057
|
|
|
1039
1058
|
// 剪贴板复制(clipboard API + execCommand 降级,兼容非 secure context / 旧浏览器)
|
|
1040
1059
|
export declare function copyText(text: string): Promise<boolean>;
|
|
1060
|
+
/**
|
|
1061
|
+
* 串行化运行器(P1-2,arch-review):把并发异步操作排成串行链,一个跑完下一个才开始。
|
|
1062
|
+
* createChatSdk 的 send/switchSession/batch 经此串行化,防并发共享 state 竞态。
|
|
1063
|
+
* 返回的 runSerial(fn):fn 排队执行(前一个无论成败都继续),返回 fn 的 Promise(透传结果/错误)。
|
|
1064
|
+
*/
|
|
1065
|
+
export declare function createSerialRunner(): <T>(fn: () => Promise<T>) => Promise<T>;
|