page-agent-sdk 4.0.0 → 4.2.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 +4 -5
- package/README.zh-CN.md +5 -6
- package/dist/page-agent-sdk.headless.js +2802 -2978
- package/dist/page-agent-sdk.iife.js +158 -159
- package/dist/page-agent-sdk.js +4802 -5029
- package/dist/page-agent-sdk.legacy.js +15424 -15673
- package/dist/page-agent-sdk.umd.cjs +111 -112
- package/dist/style.css +1 -1
- package/package.json +1 -2
- package/style.css +1 -1
- package/types/headless.d.ts +25 -60
- package/types/index.d.ts +25 -141
package/types/index.d.ts
CHANGED
|
@@ -158,7 +158,6 @@ export type SdkEvent =
|
|
|
158
158
|
| { type: 'session_restored'; sessionId: string; rounds: number }
|
|
159
159
|
| { type: 'usage'; round: number; usage: TokenUsage; cumulative: TokenUsage }
|
|
160
160
|
| { type: 'error'; message: string; severity?: 'recoverable' | 'fatal' | 'observable'; code?: string; context?: unknown }
|
|
161
|
-
| { type: 'trace'; spans: TraceSpan[]; metrics: TraceMetrics }
|
|
162
161
|
| { type: 'context_trimmed'; dropped: { round: number; user: unknown; assistant: unknown[]; steps: unknown[] }[]; vfsResults: Record<string, string>; summary: string; reason: string }
|
|
163
162
|
| { type: 'focus_chip_click'; path: string; label?: string }
|
|
164
163
|
| { type: 'focus_change'; focuses: Focus[] };
|
|
@@ -405,11 +404,6 @@ export interface DialogMessages {
|
|
|
405
404
|
debugStepsBtn: string
|
|
406
405
|
debugStepsCountSuffix: string // 步 / steps(n 在前)
|
|
407
406
|
debugTraceEmpty: string
|
|
408
|
-
debugMetricRounds: string
|
|
409
|
-
debugMetricTotal: string
|
|
410
|
-
debugMetricAvg: string
|
|
411
|
-
debugMetricTools: string
|
|
412
|
-
debugMetricCompressions: string
|
|
413
407
|
debugCtxEmpty: string
|
|
414
408
|
debugCtxOccupancy: string // 占用 / Occupancy(title)
|
|
415
409
|
debugCtxThreshold: string // 压缩阈值 / compress threshold
|
|
@@ -451,13 +445,6 @@ export interface DialogMessages {
|
|
|
451
445
|
debugSameAsMain: string // (同主) / (same as main)
|
|
452
446
|
debugTodosTitle: string
|
|
453
447
|
debugMemoryTitle: string
|
|
454
|
-
debugPrefsTitle: string // 用户偏好 / User preferences(preferences opt-in 小节标题)
|
|
455
|
-
debugPrefTopicColor: string // 偏好 topic 标签:颜色 / color
|
|
456
|
-
debugPrefTopicCopy: string // 文案 / copy
|
|
457
|
-
debugPrefTopicLayout: string // 排版 / layout
|
|
458
|
-
debugPrefTopicInteraction: string // 交互 / interaction
|
|
459
|
-
debugPrefTopicTech: string // 技术 / tech
|
|
460
|
-
debugPrefTopicOther: string // 其他 / other
|
|
461
448
|
debugLastCompTitle: string
|
|
462
449
|
debugTriggered: string
|
|
463
450
|
debugNotTriggered: string // ✗(未达阈值) / ✗ (below threshold)
|
|
@@ -602,6 +589,8 @@ export interface SubagentInfo {
|
|
|
602
589
|
enabled: boolean;
|
|
603
590
|
maxDepth: number;
|
|
604
591
|
maxParallel: number;
|
|
592
|
+
/** 单次委派总时长毫秒(flow-robustness P1#4 反射:undefined → 默认 600000;0 = 关) */
|
|
593
|
+
timeoutMs: number;
|
|
605
594
|
allowedTools: string[];
|
|
606
595
|
/** 预声明子 agent 列表(动态:反映 setSubagents/addSubagent/removeSubagent 后的最新) */
|
|
607
596
|
subagents?: { id: string; description: string }[];
|
|
@@ -662,8 +651,6 @@ export interface AgentInfo {
|
|
|
662
651
|
mission?: Mission;
|
|
663
652
|
/** 方案确认留痕(save-and-plan-gates 3c:RHC 带 options 的方案被点选;undefined=本会话无已确认方案) */
|
|
664
653
|
planConfirmation?: PlanConfirmationRecord;
|
|
665
|
-
/** 跨会话用户偏好(preferences 中间件;updatedAt 新在前;capabilities.preferences:false → undefined) */
|
|
666
|
-
preferences?: PersistedPreference[];
|
|
667
654
|
/** 宿主动作元信息(actions 注册;集成方 save_draft/publish 等) */
|
|
668
655
|
actions?: Record<string, { description: string; hasParams: boolean }>;
|
|
669
656
|
/** 跨压缩工作记忆(workingMemory 中间件;pin 最近 read/query/search 定位 path + read hash,≤10 LRU) */
|
|
@@ -685,8 +672,6 @@ export interface AgentInfo {
|
|
|
685
672
|
};
|
|
686
673
|
/** 会话级 checkpoint 装载状态(未开启 → undefined) */
|
|
687
674
|
checkpoints?: { enabled: boolean; auto: boolean; list: CheckpointMeta[] };
|
|
688
|
-
/** 结构化追踪(revive-observability-tracing;capabilities.tracing 开时填充,否则 undefined) */
|
|
689
|
-
trace?: { spans: TraceSpan[]; metrics: TraceMetrics };
|
|
690
675
|
/** 上下文构成快照(context-inspector;每轮 wrapModelCall 覆盖;capabilities.contextInspector:false → undefined) */
|
|
691
676
|
context?: ContextSnapshot;
|
|
692
677
|
}
|
|
@@ -870,6 +855,10 @@ export interface DataOpsOptions {
|
|
|
870
855
|
onConflict?: (conflict: ConflictInfo) => Promise<ConflictResolution>;
|
|
871
856
|
/** 冲突监听字段白名单(任意深度字段名):声明后仅这些字段的值变动触发自动冲突检测(位置不敏感);未声明 = 不开自动检测(仅显式 expectedHash 校验);['*'] = 全字段检测(旧 autoLock 行为) */
|
|
872
857
|
conflictWatchFields?: string[];
|
|
858
|
+
/**
|
|
859
|
+
* 同轮工具并发上限(createAgent 透传):>1 且 conflictWatchFields 武装时启用 dataOps 闭包级并发写互锁(async mutex,单锁 bind 域)—— 同轮并发双写不再「双双过旧基线、后者静默覆盖前者」;串行/未武装直通 no-op 零行为变化
|
|
860
|
+
*/
|
|
861
|
+
maxParallelTools?: number;
|
|
873
862
|
}
|
|
874
863
|
|
|
875
864
|
/** 数据操作控制器(运行时替换配置;createDataOps 返回的工具数组上以不可枚举属性 `controller` 挂载) */
|
|
@@ -935,11 +924,11 @@ export interface SkillRefSpec {
|
|
|
935
924
|
doc?: string;
|
|
936
925
|
getContent?: () => string | Promise<string>;
|
|
937
926
|
}
|
|
938
|
-
/** skill 执行钩子:code(内联 JS)/url(远程,仅 sandbox)二选一;context 默认 sandbox
|
|
927
|
+
/** skill 执行钩子:code(内联 JS)/url(远程,仅 sandbox)二选一;context 默认 sandbox(host 已随 4.1.0 移除,残值落 sandbox 执行) */
|
|
939
928
|
export interface SkillExecSpec {
|
|
940
929
|
code?: string;
|
|
941
930
|
url?: string;
|
|
942
|
-
context?: 'sandbox'
|
|
931
|
+
context?: 'sandbox';
|
|
943
932
|
inject?: 'append' | 'prepend';
|
|
944
933
|
}
|
|
945
934
|
/** skill 附带工具工厂(返回单个/数组工具,可异步;ctx.signal 运行时中止信号) */
|
|
@@ -986,8 +975,10 @@ export interface ApprovalOptions {
|
|
|
986
975
|
tools?: string[];
|
|
987
976
|
/** 自定义判定(优先于 tools);返回 true 需确认 */
|
|
988
977
|
confirm?: (name: string, args: any) => boolean;
|
|
989
|
-
/** 超时毫秒(
|
|
978
|
+
/** 超时毫秒(无响应自动拒绝);SDK 装配层默认 30000(响应方调事件的 hold() 接管后不限时);显式 Infinity/负数 = 不超时 */
|
|
990
979
|
timeoutMs?: number;
|
|
980
|
+
/** 超时自动拒的留痕回调(abort/用户先收口不触发) */
|
|
981
|
+
onAutoReject?: (info: { toolName: string; waitedMs: number }) => void;
|
|
991
982
|
/** 是否装载 request_human_confirmation 主动确认工具(传 approval 时默认 true;false 关闭) */
|
|
992
983
|
humanConfirmTool?: boolean;
|
|
993
984
|
}
|
|
@@ -1000,14 +991,14 @@ export interface PlanConfirmationRecord {
|
|
|
1000
991
|
choice: string;
|
|
1001
992
|
viaOptions: true;
|
|
1002
993
|
}
|
|
1003
|
-
|
|
1004
|
-
export
|
|
1005
|
-
/** 大批量变更门禁(bulk-change-guard):量纲 = 现有组件节点数;默认关,须配 approval 才装配 */
|
|
1006
|
-
export interface BulkGuardOptions {
|
|
1007
|
-
threshold?: number;
|
|
994
|
+
/** humanConfirm 中间件可选项:timeoutMs 无响应自动拒(超时视同拒绝);onAutoReject 超时留痕回调 */
|
|
995
|
+
export interface HumanConfirmOptions {
|
|
1008
996
|
timeoutMs?: number;
|
|
1009
|
-
|
|
997
|
+
onAutoReject?: (info: { toolName: string; waitedMs: number }) => void;
|
|
1010
998
|
}
|
|
999
|
+
export declare function createHumanConfirmMiddleware(onResolved?: (record: PlanConfirmationRecord) => void, opts?: HumanConfirmOptions): any;
|
|
1000
|
+
export declare const HUMAN_CONFIRM_TOOL_NAME: string;
|
|
1001
|
+
/** 写触达量纲结果(原 bulk-change-guard 量纲;bulkGuard 已于 4.1.0 移除,函数为 delegateNudge 依赖保留) */
|
|
1011
1002
|
export interface WriteScaleResult {
|
|
1012
1003
|
count: number;
|
|
1013
1004
|
scopes: string[];
|
|
@@ -1015,19 +1006,6 @@ export interface WriteScaleResult {
|
|
|
1015
1006
|
}
|
|
1016
1007
|
/** 度量单次写调用触达的现有组件节点数(纯函数:同组件多 patch=1;新增路径不计) */
|
|
1017
1008
|
export declare function measureWriteScale(args: unknown, getBind: () => unknown): WriteScaleResult;
|
|
1018
|
-
/** 中间件工厂参数(getBind/tools/getPlanConfirmation/onEvent;挂起经 ctx.emit approval_request) */
|
|
1019
|
-
export interface BulkGuardMiddlewareOptions extends BulkGuardOptions {
|
|
1020
|
-
getBind: () => unknown;
|
|
1021
|
-
tools?: unknown[];
|
|
1022
|
-
getPlanConfirmation?: () => { at: number; summary: string } | undefined;
|
|
1023
|
-
onEvent?: (info: { stage: 'bulk_guard'; decision: 'confirm' | 'observe' | 'exempt-plan' | 'exempt-once' | 'pass' | 'timeout' | 'rejected'; kind: string; count: number }) => void;
|
|
1024
|
-
}
|
|
1025
|
-
/** 会话级豁免态(每形态确认过一次本会话放行;reset 钩子接 switch/resetSession) */
|
|
1026
|
-
export interface BulkGuardState {
|
|
1027
|
-
confirmedKinds: Set<string>;
|
|
1028
|
-
reset(): void;
|
|
1029
|
-
}
|
|
1030
|
-
export declare function createBulkGuardMiddleware(opts: BulkGuardMiddlewareOptions): any;
|
|
1031
1009
|
export interface CheckpointMeta {
|
|
1032
1010
|
id: number;
|
|
1033
1011
|
label?: string;
|
|
@@ -1063,6 +1041,8 @@ export interface StorageConfig {
|
|
|
1063
1041
|
maxBytesPerSession?: number;
|
|
1064
1042
|
evictionWatermark?: number;
|
|
1065
1043
|
debounceMs?: number;
|
|
1044
|
+
/** flush 单项落盘超时 ms(默认 5000):IDB 事务卡死不拖死 flush 调用方,超时项留待后续 flush/pagehide 重试 */
|
|
1045
|
+
flushTimeoutMs?: number;
|
|
1066
1046
|
}
|
|
1067
1047
|
/** Skill 独立持久化存储配置(与 storage 选项分离) */
|
|
1068
1048
|
export interface SkillStoreConfig {
|
|
@@ -1073,29 +1053,6 @@ export interface SkillStoreConfig {
|
|
|
1073
1053
|
/** DB 命名空间,默认 'chat-sdk'(与 SessionStore 同库,不同 key 前缀) */
|
|
1074
1054
|
dbName?: string;
|
|
1075
1055
|
}
|
|
1076
|
-
/** 偏好主题枚举(合并键):同 topic 后说覆盖前说 */
|
|
1077
|
-
export type PreferenceTopic = 'color' | 'copy' | 'layout' | 'interaction' | 'tech' | 'other';
|
|
1078
|
-
/** 持久化的单条用户偏好(captured/提炼后的一句话中性陈述) */
|
|
1079
|
-
export interface PersistedPreference {
|
|
1080
|
-
id: string;
|
|
1081
|
-
content: string;
|
|
1082
|
-
topic: PreferenceTopic;
|
|
1083
|
-
sourceSessionId: string;
|
|
1084
|
-
sourceRound: number;
|
|
1085
|
-
createdAt: number;
|
|
1086
|
-
updatedAt: number;
|
|
1087
|
-
}
|
|
1088
|
-
/** 用户偏好跨会话记忆的独立持久化存储配置(preference-persistence;需 capabilities.preferences:true) */
|
|
1089
|
-
export interface PreferenceStoreConfig {
|
|
1090
|
-
/** 存储 id(命名空间);同 id 跨页面/跨 agent 共享,不传按 agentId 隔离 */
|
|
1091
|
-
id?: string;
|
|
1092
|
-
/** 后端类型,默认 'indexed';'local' / 'session' / 'memory' */
|
|
1093
|
-
backend?: StorageBackendType;
|
|
1094
|
-
/** DB 命名空间,默认 'chat-sdk' */
|
|
1095
|
-
dbName?: string;
|
|
1096
|
-
/** FIFO 条目上限(默认 20;超限按 updatedAt 删最旧) */
|
|
1097
|
-
maxEntries?: number;
|
|
1098
|
-
}
|
|
1099
1056
|
export interface SessionMeta {
|
|
1100
1057
|
agentId: string;
|
|
1101
1058
|
sessionId: string;
|
|
@@ -1204,8 +1161,6 @@ export interface ChatSdkOptions {
|
|
|
1204
1161
|
skills?: SkillSpec[];
|
|
1205
1162
|
/** 用户创建 skill 的独立持久化存储(与 storage 选项分离)。默认 `{ backend: 'indexed' }`(即使 storage:false 也持久化);`false` 关闭;`id` 手动指定同一 id 可跨页面/跨 agent 复用 */
|
|
1206
1163
|
skillStorage?: SkillStoreConfig | false;
|
|
1207
|
-
/** 用户偏好跨会话记忆的独立持久化存储(需 `capabilities.preferences:true`);默认 indexedDB;maxEntries FIFO 上限(默认 20);false 不持久化(仅页面生命周期内有效) */
|
|
1208
|
-
preferenceStorage?: PreferenceStoreConfig | false;
|
|
1209
1164
|
/** AGENTS.md 风格持久指令。支持 string 与同步/异步函数(异步函数适合加载 RAG 文档) */
|
|
1210
1165
|
memory?: string | (() => string | Promise<string>);
|
|
1211
1166
|
data?: DataConfig;
|
|
@@ -1236,6 +1191,10 @@ export interface ChatSdkOptions {
|
|
|
1236
1191
|
streamStallMs?: number;
|
|
1237
1192
|
/** 单次模型调用流总时长上限:防空转帧黑洞(keepalive 空转不断喂饱间隔看门狗,超限 → StreamMaxDurationError,重委派/重发即自愈)。默认 600s;0 = 关闭 */
|
|
1238
1193
|
streamMaxDurationMs?: number;
|
|
1194
|
+
/**
|
|
1195
|
+
* per-tool 看门狗:单工具执行超此 ms → 放弃等待,recoverable 错误结果回灌自纠(防集成方工具永不 settle 拖死整轮:loading 永转 + stop 无效)。只对集成方注入工具生效(defineTool / actions / skill 工具工厂 / rag retriever);内置/MCP/委派与 conflict ask 挂起是设计内等待,豁免。默认 120s;0 = 关闭
|
|
1196
|
+
*/
|
|
1197
|
+
toolTimeoutMs?: number;
|
|
1239
1198
|
/** token 预算上限(累计 total_tokens 超过 → 停止 agent + emit BUDGET_EXCEEDED;需 capabilities.automation:true) */
|
|
1240
1199
|
tokenBudget?: number;
|
|
1241
1200
|
/** 单次 invoke 的 token 预算上限(opt-in,默认关):本次 agent 调用累计 total_tokens 超限 → 中断收口(observable emit + 友好文本,已完成部分保留);与 automation 全局 tokenBudget 正交 */
|
|
@@ -1255,16 +1214,14 @@ export interface ChatSdkOptions {
|
|
|
1255
1214
|
/** 图片输入配置组(image-input-vision):images.upload 上传换 URL(集成方 OSS)/ images.describe 绑定识图转述(集成方识图子 agent / 自有 vision API,非多模态主模型时转述注入) */
|
|
1256
1215
|
images?: ImagesConfig;
|
|
1257
1216
|
/** 子 agent 委派(默认开启;{ enabled: false } 关闭) */
|
|
1258
|
-
capabilities?: { dataOps?: boolean; fetch?: boolean; planning?: boolean; missionAnchor?: boolean; skills?: boolean; vfs?: boolean; summarization?: boolean; memory?: boolean; subagent?: boolean; verify?: boolean; domInspect?: boolean; inspectEnv?: boolean; draftWrite?: boolean;
|
|
1259
|
-
subagent?: { enabled?: boolean; allowedTools?: string[]; systemPrompt?: string; temperature?: number; maxTokens?: number; skills?: SkillSpec[]; llm?: LLMConfig | ChatModelLike; maxDepth?: number; maxParallel?: number; timeoutMs?: number; thinkingMode?: 'simple' | 'deep' };
|
|
1217
|
+
capabilities?: { dataOps?: boolean; fetch?: boolean; planning?: boolean; missionAnchor?: boolean; skills?: boolean; vfs?: boolean; summarization?: boolean; memory?: boolean; subagent?: boolean; verify?: boolean; domInspect?: boolean; inspectEnv?: boolean; draftWrite?: boolean; automation?: boolean; workingMemory?: boolean; focus?: boolean; contextInspector?: boolean; agentCompression?: boolean };/** tracing/skillHostScript/preferences/bulkGuard 已于 4.1.0 移除;残键静默忽略 */
|
|
1218
|
+
subagent?: { enabled?: boolean; allowedTools?: string[]; systemPrompt?: string; temperature?: number; maxTokens?: number; skills?: SkillSpec[]; llm?: LLMConfig | ChatModelLike; maxDepth?: number; maxParallel?: number; /** 单次委派总时长毫秒(默认 600000=10min;超时 abort 子流 + recoverable 回灌;0 = 不限制) */ timeoutMs?: number; thinkingMode?: 'simple' | 'deep' };
|
|
1260
1219
|
/** 预声明子 agent 列表:每个用同主配置方式声明,自动生成 use_<id> 委派工具(与 spawn_agent 共存) */
|
|
1261
1220
|
subagents?: SubagentConfig[];
|
|
1262
1221
|
/** 自检:agent 返回前跑 check,不通过则 feedback 回灌自纠(默认关闭)。传 check/maxAttempts/adversarial 任一即自动开启(无需再配 capabilities.verify:true;显式 false 或 enabled:false 可关)。check 省略时默认 createWriteBackCheck 写后读回验证 */
|
|
1263
1222
|
verify?: { enabled?: boolean; check?: VerifyCheck; maxAttempts?: number; adversarial?: boolean };
|
|
1264
1223
|
/** 人工确认:工具调用前弹确认框,用户「允许/拒绝」后才执行(默认关闭,不传 = 不装) */
|
|
1265
1224
|
approval?: ApprovalOptions;
|
|
1266
|
-
/** 大批量变更门禁(默认关;capabilities.bulkGuard:true 开启,须同时配置 approval 否则 no-op)。量纲 = 现有组件节点数(同组件多 patch 不拦,新增内容不计);超阈挂 approval(自带 timeoutMs 超时自动拒);mode:'observe' 无人值守只留痕 */
|
|
1267
|
-
bulkGuard?: { threshold?: number; timeoutMs?: number; mode?: 'confirm' | 'observe' };
|
|
1268
1225
|
/** 主动征询(默认开启):装载 request_human_confirmation 工具,LLM 在不确定/多方案/高风险时主动征询;false 关闭(types-alignment 补漏) */
|
|
1269
1226
|
humanConfirm?: boolean;
|
|
1270
1227
|
/** 会话级 checkpoint 回滚(回到上次正常时)。默认关闭;传 true 或 { maxCheckpoints?, auto? } 开启 */
|
|
@@ -1413,12 +1370,6 @@ export interface ChatSdk {
|
|
|
1413
1370
|
getMission(): Mission | undefined;
|
|
1414
1371
|
/** 显式设置/覆盖 mission(传 {goal} 重设;传 {goal,criteria} 整体替换;传 {} 清空);capabilities 关时 warn 不抛 */
|
|
1415
1372
|
setMission(mission: Partial<Mission>): void;
|
|
1416
|
-
/** 读取跨会话用户偏好快照(updatedAt 新在前;capabilities.preferences:false → 恒 []) */
|
|
1417
|
-
getPreferences(): PersistedPreference[];
|
|
1418
|
-
/** 删除单条跨会话偏好(by id;学错可删);capabilities 关 → false */
|
|
1419
|
-
removePreference(id: string): Promise<boolean>;
|
|
1420
|
-
/** 清空全部跨会话偏好(存储 + 注入段同清);capabilities 关 → no-op */
|
|
1421
|
-
clearPreferences(): Promise<void>;
|
|
1422
1373
|
/** 读取当前聚焦焦点(兼容:返回首个;未聚焦 / capabilities.focus:false → undefined) */
|
|
1423
1374
|
getFocus(): Focus | undefined;
|
|
1424
1375
|
/** 读取全部聚焦焦点(multi-focus;空数组=未聚焦;capabilities.focus:false → []) */
|
|
@@ -1594,34 +1545,6 @@ export declare function validateRootValueLocally(args: { schema: any; allowKeys:
|
|
|
1594
1545
|
export declare function validateWriteLocally(args: { schema: any; bindRef: unknown; clone: unknown; patches: { op?: string; jsonPath?: string; value?: unknown }[]; schemaErrorMode?: 'zod' | 'schema_invalid'; appendCaptures: { jp: string; elems: unknown[] }[]; moveCaptures: { jp: string; toPath: string; elem: unknown }[]; valueAt?: (jp: string) => unknown }): LocalValidationPlan;
|
|
1595
1546
|
/** 增量 patch 写入纯函数(clone + 局部校验 + 快照 + 外科手术式写回);write(edit) / eval 共用 */
|
|
1596
1547
|
export declare function applyPatchesToBind(args: { bindRef: unknown; patches: { op?: string; jsonPath?: string; value?: unknown }[]; schema: any; allowKeys: string[] | null; snapshots: any[]; maxSnapshots: number; markDataDirty?: () => void; schemaErrorMode?: 'zod' | 'schema_invalid'; snapshotLabel?: string; dryRun?: boolean; internalAfterWrite?: (bind: any, before: any) => void; protectedCtx?: unknown }): { ok: true; applied: { op: string; jp: string; value: unknown }[]; clone: unknown; notices: string[] } | { ok: false; error: string };
|
|
1597
|
-
/** 结构化追踪 span(revive-observability-tracing Phase 3) */
|
|
1598
|
-
export type SpanType = 'round' | 'model' | 'tool' | 'compression';
|
|
1599
|
-
export type SpanStatus = 'ok' | 'error' | 'timeout';
|
|
1600
|
-
export interface TraceSpan {
|
|
1601
|
-
id: string;
|
|
1602
|
-
parentId?: string;
|
|
1603
|
-
name: string;
|
|
1604
|
-
type: SpanType;
|
|
1605
|
-
startTs: number;
|
|
1606
|
-
endTs?: number;
|
|
1607
|
-
durationMs?: number;
|
|
1608
|
-
status: SpanStatus;
|
|
1609
|
-
attributes: Record<string, unknown>;
|
|
1610
|
-
}
|
|
1611
|
-
export interface TraceMetrics {
|
|
1612
|
-
rounds: number;
|
|
1613
|
-
totalDurationMs: number;
|
|
1614
|
-
avgRoundMs: number;
|
|
1615
|
-
toolCalls: number;
|
|
1616
|
-
toolFailures: number;
|
|
1617
|
-
toolSuccessRate: number;
|
|
1618
|
-
modelCalls: number;
|
|
1619
|
-
retries: number;
|
|
1620
|
-
compressions: number;
|
|
1621
|
-
totalTokens?: { prompt: number; completion: number; total: number };
|
|
1622
|
-
}
|
|
1623
|
-
/** 从 TraceSpan[] 聚合 metrics(纯函数:轮次/延迟/工具成功率/重试/压缩/token) */
|
|
1624
|
-
export declare function getTraceMetrics(spans: TraceSpan[]): TraceMetrics;
|
|
1625
1548
|
// ============ 通用 JSON 操作纯函数(jsonUtils,refactor-module-extraction 从 dataOps 抽离;零依赖,经 ./query subpath 按需引入)============
|
|
1626
1549
|
export type EditOp = 'set' | 'remove' | 'merge' | 'append' | 'move';
|
|
1627
1550
|
export declare const UNSAFE_KEYS: Set<string>;
|
|
@@ -1766,7 +1689,6 @@ export type CapabilityFlags = Partial<Record<string, boolean>>;
|
|
|
1766
1689
|
export type ResolvedCapabilities = Record<string, boolean>;
|
|
1767
1690
|
export declare const CAPABILITIES: readonly Capability[];
|
|
1768
1691
|
/** 已列入移除计划的配置键(config-surface-pruning;维护者确认外部零使用,warn 一版后移除)。键 = capabilities 键名,值 = 迁移指引 */
|
|
1769
|
-
export declare const DEPRECATED_CAPABILITIES: Readonly<Record<string, string>>;
|
|
1770
1692
|
/** 单一解析:集成方原始 caps(Partial)→ 全量 boolean(opt-out 默认开 !==false / opt-in 默认关 ===true;requires 依赖未满足强制关)。参数宽松 Record<string,unknown>(兼容含 subagents 等非 boolean 字段的 caps 对象;只读已知 capability 的 boolean) */
|
|
1771
1693
|
export declare function resolveCapabilities(caps?: Record<string, unknown>): ResolvedCapabilities;
|
|
1772
1694
|
export declare function resolveStorage(storage: any): any | null;
|
|
@@ -1879,41 +1801,6 @@ export declare function createWebStorageBackend(storage: Storage): StorageBacken
|
|
|
1879
1801
|
export declare function isQuotaError(err: unknown): boolean;
|
|
1880
1802
|
/** 创建 Skill 独立持久化存储(与 storage 选项分离;默认 indexedDB,可手动指定 id 跨页复用) */
|
|
1881
1803
|
export declare function createSkillStore(config?: SkillStoreConfig): SkillStore;
|
|
1882
|
-
// ============ 用户偏好跨会话记忆(preference-persistence;capabilities.preferences opt-in)============
|
|
1883
|
-
/** FIFO 条目上限默认值(20) */
|
|
1884
|
-
export declare const DEFAULT_MAX_PREFERENCES: number;
|
|
1885
|
-
/** 创建偏好独立存储(与 storage/skillStorage 同构;同 topic 后说覆盖,FIFO 超限删最旧) */
|
|
1886
|
-
export declare function createPreferenceStore(config?: PreferenceStoreConfig): PreferenceStore;
|
|
1887
|
-
export interface PreferenceStore {
|
|
1888
|
-
ready: Promise<boolean>;
|
|
1889
|
-
list(): Promise<PersistedPreference[]>;
|
|
1890
|
-
put(pref: Omit<PersistedPreference, 'id' | 'createdAt' | 'updatedAt'> & { id?: string }): Promise<PersistedPreference>;
|
|
1891
|
-
remove(id: string): Promise<boolean>;
|
|
1892
|
-
clear(): Promise<void>;
|
|
1893
|
-
dispose(): void;
|
|
1894
|
-
}
|
|
1895
|
-
/** 偏好捕获中间件选项 */
|
|
1896
|
-
export interface PreferencesMiddlewareOptions {
|
|
1897
|
-
store: PreferenceStore;
|
|
1898
|
-
/** 小 LLM 通道(如 summaryLlmInvoke);缺省 → 只强信号生效(降级) */
|
|
1899
|
-
llmInvoke?: (prompt: string) => Promise<string>;
|
|
1900
|
-
/** 当前会话 id getter(记入条目溯源) */
|
|
1901
|
-
getSessionId: () => string;
|
|
1902
|
-
/** debug 留痕回调 */
|
|
1903
|
-
onDebug?: (data: Record<string, unknown>) => void;
|
|
1904
|
-
}
|
|
1905
|
-
/** 偏好捕获中间件(afterAgent 收口捕获 + augmentPrompt pin 段注入) */
|
|
1906
|
-
export declare function createPreferencesMiddleware(opts: PreferencesMiddlewareOptions): any;
|
|
1907
|
-
/** 强信号提取:显式命令句式(「记住:」等)命中 → {content, topic};未命中 → undefined(零 LLM) */
|
|
1908
|
-
export declare function extractExplicitPreference(text: string): { content: string; topic: PreferenceTopic } | undefined;
|
|
1909
|
-
/** 中信号初筛:模式词命中(松筛,真伪由 LLM 提炼判定) */
|
|
1910
|
-
export declare function looksLikePreferenceSignal(text: string): boolean;
|
|
1911
|
-
/** 解析提炼 LLM 输出(容错剥围栏;captured 非 true / 非法 → undefined,宁漏勿误) */
|
|
1912
|
-
export declare function parsePreferenceJson(raw: string): { content: string; topic: PreferenceTopic } | undefined;
|
|
1913
|
-
/** 提炼 prompt(中信号;输出 JSON) */
|
|
1914
|
-
export declare function buildExtractPrompt(text: string): string;
|
|
1915
|
-
/** 注入 pin 段(cache 快照 → markdown;空 → undefined) */
|
|
1916
|
-
export declare function buildPreferencePrompt(prefs: PersistedPreference[]): string | undefined;
|
|
1917
1804
|
export interface SkillStore {
|
|
1918
1805
|
ready: Promise<boolean>;
|
|
1919
1806
|
list(): Promise<PersistedSkill[]>;
|
|
@@ -1929,7 +1816,6 @@ export interface PersistedSkill {
|
|
|
1929
1816
|
description: string;
|
|
1930
1817
|
content: string;
|
|
1931
1818
|
}
|
|
1932
|
-
|
|
1933
1819
|
// ============ 大 JSON 查询/搜索/沙箱脚本(dataSlotQuery)============
|
|
1934
1820
|
export interface JpNode {
|
|
1935
1821
|
/** 相对属性根的点号路径(数组索引用数字,如 components.0.text) */
|
|
@@ -1975,8 +1861,6 @@ export interface SandboxResult {
|
|
|
1975
1861
|
* 无 input 传 undefined(skill exec);有 input 作 data 入参(eval_script)。
|
|
1976
1862
|
*/
|
|
1977
1863
|
export declare function createSandboxRunner(script: string, timeoutMs?: number): (input?: unknown) => Promise<SandboxResult>;
|
|
1978
|
-
/** 宿主脚本执行(skill exec context:'host';AsyncFunction 主线程全权,不经静态扫描,需 capabilities.skillHostScript:true) */
|
|
1979
|
-
export declare function runHostScript(code: string, timeoutMs?: number): Promise<SandboxResult>;
|
|
1980
1864
|
|
|
1981
1865
|
// ============ 工具报错(结构化 ERROR:{json},供 LLM 排查)============
|
|
1982
1866
|
export interface ToolErrorInput {
|