@webskill/sdk 0.8.0 → 0.10.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/dist/agent.d.ts +2 -2
- package/dist/agent.js +6 -2
- package/dist/browser.d.ts +5 -3
- package/dist/browser.js +35 -13
- package/dist/{catalogComponents-DfxxfUvn-D55Gbb2l.js → catalogComponents-DTcYfpLQ-CcoOaz-Z.js} +1946 -976
- package/dist/{dist-CJqQsIm9.js → dist-1OFC-zax.js} +7 -5
- package/dist/{dist-DmI5SBBF.js → dist-BViUeszk.js} +393 -44
- package/dist/{dist-59XlqDuv.js → dist-Bev6i6Ip.js} +10 -2
- package/dist/{eventTypes-g1BXL6x5-CibcOftR.js → eventTypes-s2uwAcLG-Go3l_dUe.js} +13 -2
- package/dist/governance.d.ts +37 -6
- package/dist/governance.js +53 -15
- package/dist/{index-P9J2LTfU.d.ts → index-B0QPLWPZ.d.ts} +6 -2
- package/dist/{index-fLskQfAS.d.ts → index-BF4E1a9j.d.ts} +10 -3
- package/dist/{index-K-eewlGL.d.ts → index-DtFdMKBX.d.ts} +69 -7
- package/dist/index.d.ts +11 -3
- package/dist/index.js +13 -4
- package/dist/mcp.d.ts +23 -3
- package/dist/mcp.js +70 -25
- package/dist/{memoryArtifactStore-52Zn9npI-upv5OWYf.js → memoryArtifactStore-52Zn9npI-LbCQaqyx.js} +1 -1
- package/dist/node.d.ts +3 -3
- package/dist/node.js +6 -6
- package/dist/{openUiLibrary-DURlAxjk-CU6AzfSW.js → openUiLibrary-CIrV--Ad-B8zG_91e.js} +3 -3
- package/dist/{skillVersionStore-Bl-ElD45-gRfSaAby.d.ts → skillVersionStore-D-qHk9ZE-DBsYYCWn.d.ts} +13 -5
- package/dist/{testing-BCUO5gZR.js → testing-WPTyXQYt.js} +28 -5
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +2 -2
- package/dist/{types-B3n0cMZu-BdcqQ35O.d.ts → types-CrRcT-LM-DZAp8sWv.d.ts} +44 -3
- package/dist/ui-react.d.ts +17 -2
- package/dist/ui-react.js +123 -39
- package/dist/ui-vue.d.ts +1 -1
- package/dist/ui-vue.js +1 -1
- package/dist/ui.d.ts +3 -3
- package/dist/ui.js +2 -2
- package/dist/{webskillLitCatalog-DwTwSBFt-DiXXpNZA.js → webskillLitCatalog-BJrphK0y-SGmRXaaO.js} +2 -2
- package/package.json +1 -1
|
@@ -76,6 +76,14 @@ function verifyManifest(manifest, actualHashes, actualFiles = [...actualHashes.k
|
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
|
+
* 原子写的临时文件名后缀模式;列举/打包侧据此排除中断残留(0.9.0 分册 11)。
|
|
80
|
+
* 单一来源:不要在别处手写正则(AC-G10),复制正则必然漂移。
|
|
81
|
+
* @stable
|
|
82
|
+
*/
|
|
83
|
+
const ATOMIC_TMP_SUFFIX_PATTERN = /\.tmp-\d+-[a-z0-9]+$/;
|
|
84
|
+
/** 该路径是否是 atomicWriteText 留下的临时文件 */
|
|
85
|
+
const isAtomicTempPath = (path) => ATOMIC_TMP_SUFFIX_PATTERN.test(path);
|
|
86
|
+
/**
|
|
79
87
|
* 原子写文本:先写临时文件再 rename(进程崩溃不留下半写文件;lockfile 等账本场景)。
|
|
80
88
|
* 原子性强弱取决于 provider 的 rename 实现:NodeFS/MemoryFS 为真 rename;
|
|
81
89
|
* OPFS 无原生 move,rename 是 copy+delete(非原子,崩溃可能残留双份),
|
|
@@ -656,7 +664,7 @@ async function listFilesRecursive(fs, root, prefix = "") {
|
|
|
656
664
|
for (const entry of await fs.list(root)) {
|
|
657
665
|
const rel = prefix === "" ? baseName$1(entry.path) : `${prefix}/${baseName$1(entry.path)}`;
|
|
658
666
|
if (entry.type === "directory") out.push(...await listFilesRecursive(fs, entry.path, rel));
|
|
659
|
-
else out.push(rel);
|
|
667
|
+
else if (!isAtomicTempPath(baseName$1(entry.path))) out.push(rel);
|
|
660
668
|
}
|
|
661
669
|
return out;
|
|
662
670
|
}
|
|
@@ -1122,4 +1130,4 @@ const xmlRenderer = {
|
|
|
1122
1130
|
};
|
|
1123
1131
|
|
|
1124
1132
|
//#endregion
|
|
1125
|
-
export {
|
|
1133
|
+
export { jsonRenderer as A, resolveArchiveLimits as B, computeDigest as C, exportSkills as D, escapeXml as E, parseSkillPackManifest as F, unzipWithLimits as G, signSkill as H, readResponseWithLimit as I, verifySkillSignature as J, validateSkills as K, readSkillSignature as L, messageOf as M, normalizePath as N, isAtomicTempPath as O, parseSkillMarkdown as P, renderAvailableSkillsXml as R, checkSkillRules as S, detectSkillArchiveShapeFromFs as T, signaturePayloadBytes as U, resolveInsideRoot as V, stripArchiveRoot as W, xmlRenderer as Y, assertSafePathSegment as _, MemoryFS as a, buildManifest as b, SKILL_MANIFEST_FILE as c, SKILL_PACK_FILE as d, SKILL_SIGNATURE_FILE as f, assertRemoteUrlAllowed as g, WebSkillError as h, MANIFEST_EXCLUDED_FILES as i, keyIdOf as j, isValidSkillName as k, SKILL_NAME_MAX_LENGTH as l, SkillReader as m, DEFAULT_ARCHIVE_LIMITS as n, SIGNATURE_SCHEMA_VERSION as o, SkillDiscovery as p, verifyManifest as q, FsTrustedKeyStore as r, SKILLS_LOCKFILE as s, ATOMIC_TMP_SUFFIX_PATTERN as t, SKILL_NAME_PATTERN as u, atomicWriteText as v, detectSkillArchiveShape as w, checkDependencyCycles as x, buildCatalog as y, renderCatalogJson as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region ../governance/dist/eventTypes-
|
|
1
|
+
//#region ../governance/dist/eventTypes-s2uwAcLG.js
|
|
2
2
|
/**
|
|
3
3
|
* 审计事件类型常量(FR-13.4)。
|
|
4
4
|
*
|
|
@@ -15,8 +15,12 @@ const AUDIT_EVENT_TYPES = {
|
|
|
15
15
|
skillRepairApplied: "skill.repair_applied",
|
|
16
16
|
skillQuarantined: "skill.quarantined",
|
|
17
17
|
skillPolicyDenied: "skill.policy_denied",
|
|
18
|
+
skillUserCaused: "skill.user_caused",
|
|
18
19
|
skillUninstalled: "skill.uninstalled",
|
|
19
20
|
skillInstalled: "skill.installed",
|
|
21
|
+
skillExported: "skill.exported",
|
|
22
|
+
skillRenamed: "skill.renamed",
|
|
23
|
+
skillVersioned: "skill.versioned",
|
|
20
24
|
trustKeyAdded: "trust.key_added",
|
|
21
25
|
trustKeyRemoved: "trust.key_removed",
|
|
22
26
|
policyNetworkChanged: "policy.network_changed",
|
|
@@ -27,8 +31,15 @@ const AUDIT_EVENT_TYPES = {
|
|
|
27
31
|
profileChanged: "profile.changed",
|
|
28
32
|
mcpEndpointChanged: "mcp.endpoint_changed",
|
|
29
33
|
mcpPolicyRelaxed: "mcp.policy_relaxed",
|
|
34
|
+
webmcpEnabled: "webmcp.enabled",
|
|
30
35
|
providerChanged: "provider.changed",
|
|
31
|
-
|
|
36
|
+
candidateCreated: "candidate.created",
|
|
37
|
+
candidateGenerated: "candidate.generated",
|
|
38
|
+
candidateSubmitted: "candidate.submitted",
|
|
39
|
+
candidateApproved: "candidate.approved",
|
|
40
|
+
candidateRejected: "candidate.rejected",
|
|
41
|
+
pagePerceived: "page.perceived",
|
|
42
|
+
pageAction: "page.action"
|
|
32
43
|
};
|
|
33
44
|
/** 稳定展示序:筛选下拉与文档表格都从这里取,不各自维护一份顺序 */
|
|
34
45
|
const AUDIT_EVENT_TYPE_LIST = Object.values(AUDIT_EVENT_TYPES);
|
package/dist/governance.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { H as IntegrityVerdict,
|
|
3
|
-
import { _ as
|
|
1
|
+
import { R as FileSystemProvider, S as UiBridge, U as Page, W as PageQuery, f as LlmMessage, it as SkillCatalogEntry, l as LlmClient, ot as SkillDocument, ut as SkillManagerPort } from "./types-CrRcT-LM-DZAp8sWv.js";
|
|
2
|
+
import { H as IntegrityVerdict, Ht as SkillStateGuard, Lt as SkillIntegrityGuard, Rt as SkillOutcomeReporter, mn as WebSkillRuntime, xt as RuntimeRun } from "./index-DtFdMKBX.js";
|
|
3
|
+
import { _ as SkillState, a as AuditLog, b as SkillVersionStore, c as CandidateFile, d as CandidateSkill, f as CandidateSource, g as SKILL_VERSION_PAGE_SIZE, h as CompositeApprovalPolicy, i as AuditEvent, l as CandidatePage, m as CandidateStore, n as ApprovalDecision, o as AuditQueryFilter, p as CandidateStatus, r as ApprovalPolicy, s as CANDIDATE_PAGE_SIZE, t as AlwaysHumanApprovalPolicy, u as CandidateRisk, v as SkillVersion, x as candidateToCatalogEntry, y as SkillVersionPage } from "./skillVersionStore-D-qHk9ZE-DBsYYCWn.js";
|
|
4
4
|
//#region ../governance/dist/index.d.ts
|
|
5
5
|
//#region src/candidate/candidateNormalizer.d.ts
|
|
6
6
|
/** 剥 markdown fence 与 <think> 块、截取首尾 {};非对象 → CANDIDATE_INVALID */
|
|
@@ -108,6 +108,8 @@ interface AuditChainVerification {
|
|
|
108
108
|
}
|
|
109
109
|
/** 带断链报告的分页结果(`tolerateBrokenChain` 打开时才可能带上后两个字段) */
|
|
110
110
|
interface AuditPage extends Page<AuditEvent> {
|
|
111
|
+
/** 筛选后的匹配总数(不分页截断):页码分页需要它算总页数 */
|
|
112
|
+
total: number;
|
|
111
113
|
chainBrokenAt?: number;
|
|
112
114
|
chainReason?: string;
|
|
113
115
|
/**
|
|
@@ -150,6 +152,13 @@ declare class FsAuditLog implements AuditLog {
|
|
|
150
152
|
* 本页范围内的 hash 链必须自洽:逐条重算 hash 并核对与前一行的 `prevHash` 链接,
|
|
151
153
|
* 任一处对不上以 `GOVERNANCE_FAILED` 报错。范围之外的断链不在本方法职责内——
|
|
152
154
|
* 那是 `verifyChain()` 的事(全量 O(N) 校验不该压在每次翻页上)。
|
|
155
|
+
*
|
|
156
|
+
* 边界语义(0.10.0 复核后固化):
|
|
157
|
+
* - `cursor` 是「匹配序列的结束下标」而非稳定指针:翻页间隔内有新事件追加时,
|
|
158
|
+
* 页间可能漂移一条,属追加型数据的固有边界,调用方不要按「稳定快照」实现导出;
|
|
159
|
+
* - `tolerateBrokenChain` 打开且本页检测到断链时,`total` 收缩到断点前
|
|
160
|
+
* (断点及其之后的记录不再可翻出,页码不会指向空页);断点在更后面的页时
|
|
161
|
+
* 本页的 `total` 仍按全量匹配数返回。
|
|
153
162
|
*/
|
|
154
163
|
query(filter?: AuditQueryFilter & PageQuery): Promise<AuditPage>;
|
|
155
164
|
/** hash 链完整性校验:逐行重算 hash 并核对 prevHash 链接。**只读**,绝不改写历史 */
|
|
@@ -173,8 +182,12 @@ declare const AUDIT_EVENT_TYPES: {
|
|
|
173
182
|
readonly skillRepairApplied: "skill.repair_applied";
|
|
174
183
|
readonly skillQuarantined: "skill.quarantined";
|
|
175
184
|
readonly skillPolicyDenied: "skill.policy_denied";
|
|
185
|
+
readonly skillUserCaused: "skill.user_caused";
|
|
176
186
|
readonly skillUninstalled: "skill.uninstalled";
|
|
177
187
|
readonly skillInstalled: "skill.installed";
|
|
188
|
+
readonly skillExported: "skill.exported";
|
|
189
|
+
readonly skillRenamed: "skill.renamed";
|
|
190
|
+
readonly skillVersioned: "skill.versioned";
|
|
178
191
|
readonly trustKeyAdded: "trust.key_added";
|
|
179
192
|
readonly trustKeyRemoved: "trust.key_removed";
|
|
180
193
|
readonly policyNetworkChanged: "policy.network_changed";
|
|
@@ -185,8 +198,15 @@ declare const AUDIT_EVENT_TYPES: {
|
|
|
185
198
|
readonly profileChanged: "profile.changed";
|
|
186
199
|
readonly mcpEndpointChanged: "mcp.endpoint_changed";
|
|
187
200
|
readonly mcpPolicyRelaxed: "mcp.policy_relaxed";
|
|
201
|
+
readonly webmcpEnabled: "webmcp.enabled";
|
|
188
202
|
readonly providerChanged: "provider.changed";
|
|
203
|
+
readonly candidateCreated: "candidate.created";
|
|
189
204
|
readonly candidateGenerated: "candidate.generated";
|
|
205
|
+
readonly candidateSubmitted: "candidate.submitted";
|
|
206
|
+
readonly candidateApproved: "candidate.approved";
|
|
207
|
+
readonly candidateRejected: "candidate.rejected";
|
|
208
|
+
readonly pagePerceived: "page.perceived";
|
|
209
|
+
readonly pageAction: "page.action";
|
|
190
210
|
};
|
|
191
211
|
type AuditEventType = (typeof AUDIT_EVENT_TYPES)[keyof typeof AUDIT_EVENT_TYPES];
|
|
192
212
|
/** 稳定展示序:筛选下拉与文档表格都从这里取,不各自维护一份顺序 */
|
|
@@ -237,9 +257,19 @@ declare class RepairPlanner {
|
|
|
237
257
|
/**
|
|
238
258
|
* 用户策略主动拒绝的错误码(FR-12.4):这是配置生效的证据,不是技能有问题,不计入隔离阈值。
|
|
239
259
|
*
|
|
240
|
-
*
|
|
260
|
+
* 集中在这一份常量里而不散在条件判断里,是为了让「哪些策略拒绝码不计数」只有一个事实源。
|
|
261
|
+
* (用户自身原因的豁免码见 `USER_CAUSED_CODES`,两类语义不同,不并在一起。)
|
|
241
262
|
*/
|
|
242
263
|
declare const POLICY_DENIAL_CODES: ReadonlySet<string>;
|
|
264
|
+
/**
|
|
265
|
+
* 用户自身原因的错误码(0.10.0 UI-UX5 #49-2):交互等待超时(用户没处理)与
|
|
266
|
+
* 用户自行取消(ask_user / 交互卡取消)都不是技能的错,不计入隔离阈值。
|
|
267
|
+
*
|
|
268
|
+
* loop 里这两类结局走 RunTerminated 旁路、本来到不了上报口;这里再挡一道,
|
|
269
|
+
* 是因为宿主执行器也可能把「等用户时被取消/超时」包成 ok:false 的失败结果交回来——
|
|
270
|
+
* 「算不算技能的错」的判定口径必须在上报侧只有这一处。
|
|
271
|
+
*/
|
|
272
|
+
declare const USER_CAUSED_CODES: ReadonlySet<string>;
|
|
243
273
|
/** 自动隔离的原因判别式(FR-12.6);人工隔离仍写自由文本 */
|
|
244
274
|
declare const QUARANTINE_REASONS: {
|
|
245
275
|
readonly integrity: "integrity";
|
|
@@ -266,7 +296,7 @@ declare class SkillStatePolicy {
|
|
|
266
296
|
detail?: string;
|
|
267
297
|
}): Promise<void>;
|
|
268
298
|
/**
|
|
269
|
-
* 失败计数;达阈值(默认
|
|
299
|
+
* 失败计数;达阈值(默认 5)→ quarantined + 审计。
|
|
270
300
|
*
|
|
271
301
|
* 计数是**连续**而非累计(0.7.0 FR-12.5):一次成功执行经 `clearFailures` 归零,
|
|
272
302
|
* `setState(name, 'active')` 同样清零。
|
|
@@ -312,6 +342,7 @@ declare class SkillStatePolicy {
|
|
|
312
342
|
toSkillOutcomeReporter(input?: {
|
|
313
343
|
actor?: string;
|
|
314
344
|
policyDenialCodes?: ReadonlySet<string>;
|
|
345
|
+
userCausedCodes?: ReadonlySet<string>;
|
|
315
346
|
}): SkillOutcomeReporter;
|
|
316
347
|
/** disabled → SKILL_DISABLED;quarantined → SKILL_QUARANTINED */
|
|
317
348
|
assertExecutable(skillName: string): Promise<void>;
|
|
@@ -485,4 +516,4 @@ declare function createMissHook(deps: {
|
|
|
485
516
|
*/
|
|
486
517
|
declare function completeText(llm: LlmClient, messages: LlmMessage[]): Promise<string>;
|
|
487
518
|
//#endregion
|
|
488
|
-
export { AUDIT_EVENT_TYPES, AUDIT_EVENT_TYPE_LIST, AUDIT_PAGE_SIZE, AlwaysHumanApprovalPolicy, type ApprovalDecision, type ApprovalPolicy, type AuditChainVerification, type AuditEvent, type AuditEventType, type AuditLog, type AuditPage, type AuditQueryFilter, CANDIDATE_PAGE_SIZE, type CandidateFile, type CandidateRisk, type CandidateSink, type CandidateSinkOptions, type CandidateSkill, type CandidateSource, type CandidateStatus, CandidateStore, CompositeApprovalPolicy, DependencyGraph, DocumentSkillExtractor, type EvaluationReport, type EvaluationResult, EvaluationRunner, type EvaluationTask, FailureAnalyzer, type FailureDiagnosis, FsAuditLog, type GeneratedSkillSubmission, LlmCandidateGenerator, POLICY_DENIAL_CODES, QUARANTINE_REASONS, type RepairOption, RepairPlanner, SCORING_WEIGHTS, SKILL_VERSION_PAGE_SIZE, type ScoreInput, SimilarityDetector, SkillScorer, type SkillState, SkillStatePolicy, type SkillVersion, SkillVersionStore, type SourceDocument, candidateToCatalogEntry, completeText, createCandidateSink, createMissHook, jaccardSimilarity, normalizeCandidate, normalizeCandidateFiles, normalizeRisk, parseJsonObject, readDocument, sanitizeCandidateName, suggestFromFailedRun, validateCandidate };
|
|
519
|
+
export { AUDIT_EVENT_TYPES, AUDIT_EVENT_TYPE_LIST, AUDIT_PAGE_SIZE, AlwaysHumanApprovalPolicy, type ApprovalDecision, type ApprovalPolicy, type AuditChainVerification, type AuditEvent, type AuditEventType, type AuditLog, type AuditPage, type AuditQueryFilter, CANDIDATE_PAGE_SIZE, type CandidateFile, type CandidatePage, type CandidateRisk, type CandidateSink, type CandidateSinkOptions, type CandidateSkill, type CandidateSource, type CandidateStatus, CandidateStore, CompositeApprovalPolicy, DependencyGraph, DocumentSkillExtractor, type EvaluationReport, type EvaluationResult, EvaluationRunner, type EvaluationTask, FailureAnalyzer, type FailureDiagnosis, FsAuditLog, type GeneratedSkillSubmission, LlmCandidateGenerator, POLICY_DENIAL_CODES, QUARANTINE_REASONS, type RepairOption, RepairPlanner, SCORING_WEIGHTS, SKILL_VERSION_PAGE_SIZE, type ScoreInput, SimilarityDetector, SkillScorer, type SkillState, SkillStatePolicy, type SkillVersion, type SkillVersionPage, SkillVersionStore, type SourceDocument, USER_CAUSED_CODES, candidateToCatalogEntry, completeText, createCandidateSink, createMissHook, jaccardSimilarity, normalizeCandidate, normalizeCandidateFiles, normalizeRisk, parseJsonObject, readDocument, sanitizeCandidateName, suggestFromFailedRun, validateCandidate };
|
package/dist/governance.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as textParts, n as partsToText } from "./memoryArtifactStore-52Zn9npI-
|
|
3
|
-
import { n as AUDIT_EVENT_TYPE_LIST, t as AUDIT_EVENT_TYPES } from "./eventTypes-
|
|
1
|
+
import { M as messageOf, _ as assertSafePathSegment, h as WebSkillError, k as isValidSkillName, v as atomicWriteText } from "./dist-Bev6i6Ip.js";
|
|
2
|
+
import { a as textParts, n as partsToText } from "./memoryArtifactStore-52Zn9npI-LbCQaqyx.js";
|
|
3
|
+
import { n as AUDIT_EVENT_TYPE_LIST, t as AUDIT_EVENT_TYPES } from "./eventTypes-s2uwAcLG-Go3l_dUe.js";
|
|
4
4
|
|
|
5
5
|
//#region ../governance/dist/index.js
|
|
6
6
|
const invalid = (message, details) => {
|
|
@@ -105,6 +105,9 @@ function validateCandidate(candidate) {
|
|
|
105
105
|
* 治理侧各列表共用的游标切片,形状与会话消息(C1)完全一致:
|
|
106
106
|
* 无游标给**最新**一页,`nextCursor` 指向更早的历史,页内按时间升序。
|
|
107
107
|
*
|
|
108
|
+
* 返回值附带筛选后匹配总数 `total`(0.10.0 UI-UX5 #40.12):页码分页的总页数依据,
|
|
109
|
+
* 与 `AuditPage.total` 同一语义(`all` 是已过滤集合,length 即匹配总数)。
|
|
110
|
+
*
|
|
108
111
|
* 缺省页长由各 store 传入——缺省属于实现,不属于调用方。
|
|
109
112
|
*/
|
|
110
113
|
function takeTailPage(all, options, defaultLimit, what) {
|
|
@@ -118,6 +121,7 @@ function takeTailPage(all, options, defaultLimit, what) {
|
|
|
118
121
|
const start = Math.max(0, end - limit);
|
|
119
122
|
return {
|
|
120
123
|
items: all.slice(start, end),
|
|
124
|
+
total: all.length,
|
|
121
125
|
...start > 0 ? { nextCursor: String(start) } : {}
|
|
122
126
|
};
|
|
123
127
|
}
|
|
@@ -135,7 +139,7 @@ var CandidateStore = class {
|
|
|
135
139
|
async save(candidate) {
|
|
136
140
|
validateCandidate(candidate);
|
|
137
141
|
assertSafePathSegment(candidate.id, "candidate id");
|
|
138
|
-
await this.#fs
|
|
142
|
+
await atomicWriteText(this.#fs, `${dirOf$1(this.#root)}/${candidate.id}.json`, JSON.stringify(candidate, null, 2));
|
|
139
143
|
}
|
|
140
144
|
async get(id) {
|
|
141
145
|
assertSafePathSegment(id, "candidate id");
|
|
@@ -150,7 +154,10 @@ var CandidateStore = class {
|
|
|
150
154
|
*/
|
|
151
155
|
async list(options = {}) {
|
|
152
156
|
const dir = dirOf$1(this.#root);
|
|
153
|
-
if (!await this.#fs.exists(dir)) return {
|
|
157
|
+
if (!await this.#fs.exists(dir)) return {
|
|
158
|
+
items: [],
|
|
159
|
+
total: 0
|
|
160
|
+
};
|
|
154
161
|
const out = [];
|
|
155
162
|
for (const entry of await this.#fs.list(dir)) {
|
|
156
163
|
if (entry.type !== "file" || !entry.path.endsWith(".json")) continue;
|
|
@@ -211,7 +218,7 @@ function createCandidateSink(options) {
|
|
|
211
218
|
};
|
|
212
219
|
await options.store.save(candidate);
|
|
213
220
|
await options.audit?.append({
|
|
214
|
-
type:
|
|
221
|
+
type: AUDIT_EVENT_TYPES.candidateCreated,
|
|
215
222
|
target: candidate.id,
|
|
216
223
|
data: {
|
|
217
224
|
name: candidate.name,
|
|
@@ -275,7 +282,7 @@ var LlmCandidateGenerator = class {
|
|
|
275
282
|
...this.#createId ? { createId: this.#createId } : {}
|
|
276
283
|
});
|
|
277
284
|
await this.#audit?.append({
|
|
278
|
-
type:
|
|
285
|
+
type: AUDIT_EVENT_TYPES.candidateCreated,
|
|
279
286
|
target: candidate.id,
|
|
280
287
|
data: {
|
|
281
288
|
name: candidate.name,
|
|
@@ -435,10 +442,20 @@ var FsAuditLog = class {
|
|
|
435
442
|
* 本页范围内的 hash 链必须自洽:逐条重算 hash 并核对与前一行的 `prevHash` 链接,
|
|
436
443
|
* 任一处对不上以 `GOVERNANCE_FAILED` 报错。范围之外的断链不在本方法职责内——
|
|
437
444
|
* 那是 `verifyChain()` 的事(全量 O(N) 校验不该压在每次翻页上)。
|
|
445
|
+
*
|
|
446
|
+
* 边界语义(0.10.0 复核后固化):
|
|
447
|
+
* - `cursor` 是「匹配序列的结束下标」而非稳定指针:翻页间隔内有新事件追加时,
|
|
448
|
+
* 页间可能漂移一条,属追加型数据的固有边界,调用方不要按「稳定快照」实现导出;
|
|
449
|
+
* - `tolerateBrokenChain` 打开且本页检测到断链时,`total` 收缩到断点前
|
|
450
|
+
* (断点及其之后的记录不再可翻出,页码不会指向空页);断点在更后面的页时
|
|
451
|
+
* 本页的 `total` 仍按全量匹配数返回。
|
|
438
452
|
*/
|
|
439
453
|
async query(filter = {}) {
|
|
440
454
|
const path = fileOf$1(this.#root);
|
|
441
|
-
if (!await this.#fs.exists(path)) return {
|
|
455
|
+
if (!await this.#fs.exists(path)) return {
|
|
456
|
+
items: [],
|
|
457
|
+
total: 0
|
|
458
|
+
};
|
|
442
459
|
const raw = await this.#fs.readText(path);
|
|
443
460
|
/** 按文件行序保留(含解析失败的洞):链校验必须在文件行序上做,不能在筛选结果上做 */
|
|
444
461
|
const records = [];
|
|
@@ -495,6 +512,7 @@ var FsAuditLog = class {
|
|
|
495
512
|
}
|
|
496
513
|
return {
|
|
497
514
|
items,
|
|
515
|
+
total: broken !== void 0 ? start + items.length : matched.length,
|
|
498
516
|
...start > 0 ? { nextCursor: String(start) } : {},
|
|
499
517
|
...broken !== void 0 ? {
|
|
500
518
|
chainBrokenAt: broken.at,
|
|
@@ -592,7 +610,7 @@ var SkillVersionStore = class {
|
|
|
592
610
|
await this.#fs.writeBinary(archivePath, input.archive);
|
|
593
611
|
version.archivePath = archivePath;
|
|
594
612
|
}
|
|
595
|
-
await this.#fs
|
|
613
|
+
await atomicWriteText(this.#fs, `${dirOf(this.#root, skillName)}/${version.versionId}.json`, JSON.stringify(version, null, 2));
|
|
596
614
|
await this.#prune(skillName);
|
|
597
615
|
return version;
|
|
598
616
|
}
|
|
@@ -734,13 +752,23 @@ const fileOf = (root) => `${root}/.webskill/states.json`;
|
|
|
734
752
|
/**
|
|
735
753
|
* 用户策略主动拒绝的错误码(FR-12.4):这是配置生效的证据,不是技能有问题,不计入隔离阈值。
|
|
736
754
|
*
|
|
737
|
-
*
|
|
755
|
+
* 集中在这一份常量里而不散在条件判断里,是为了让「哪些策略拒绝码不计数」只有一个事实源。
|
|
756
|
+
* (用户自身原因的豁免码见 `USER_CAUSED_CODES`,两类语义不同,不并在一起。)
|
|
738
757
|
*/
|
|
739
758
|
const POLICY_DENIAL_CODES = /* @__PURE__ */ new Set([
|
|
740
759
|
"NETWORK_BLOCKED",
|
|
741
760
|
"TOOL_NOT_ALLOWED",
|
|
742
761
|
"FS_PERMISSION_DENIED"
|
|
743
762
|
]);
|
|
763
|
+
/**
|
|
764
|
+
* 用户自身原因的错误码(0.10.0 UI-UX5 #49-2):交互等待超时(用户没处理)与
|
|
765
|
+
* 用户自行取消(ask_user / 交互卡取消)都不是技能的错,不计入隔离阈值。
|
|
766
|
+
*
|
|
767
|
+
* loop 里这两类结局走 RunTerminated 旁路、本来到不了上报口;这里再挡一道,
|
|
768
|
+
* 是因为宿主执行器也可能把「等用户时被取消/超时」包成 ok:false 的失败结果交回来——
|
|
769
|
+
* 「算不算技能的错」的判定口径必须在上报侧只有这一处。
|
|
770
|
+
*/
|
|
771
|
+
const USER_CAUSED_CODES = /* @__PURE__ */ new Set(["RUN_INTERACTION_TIMEOUT", "RUN_CANCELLED"]);
|
|
744
772
|
/** 自动隔离的原因判别式(FR-12.6);人工隔离仍写自由文本 */
|
|
745
773
|
const QUARANTINE_REASONS = {
|
|
746
774
|
integrity: "integrity",
|
|
@@ -763,7 +791,7 @@ var SkillStatePolicy = class {
|
|
|
763
791
|
this.#root = deps.root.replace(/\/+$/, "");
|
|
764
792
|
this.#fs = deps.fs;
|
|
765
793
|
this.#audit = deps.audit;
|
|
766
|
-
this.#failureThreshold = deps.failureThreshold ??
|
|
794
|
+
this.#failureThreshold = deps.failureThreshold ?? 5;
|
|
767
795
|
}
|
|
768
796
|
async #load() {
|
|
769
797
|
const path = fileOf(this.#root);
|
|
@@ -787,7 +815,7 @@ var SkillStatePolicy = class {
|
|
|
787
815
|
async #persist() {
|
|
788
816
|
const data = await this.#load();
|
|
789
817
|
const path = fileOf(this.#root);
|
|
790
|
-
await this.#fs
|
|
818
|
+
await atomicWriteText(this.#fs, path, JSON.stringify(data, null, 2));
|
|
791
819
|
try {
|
|
792
820
|
this.#loadedMtimeMs = (await this.#fs.stat(path)).mtimeMs;
|
|
793
821
|
} catch {
|
|
@@ -819,7 +847,7 @@ var SkillStatePolicy = class {
|
|
|
819
847
|
});
|
|
820
848
|
}
|
|
821
849
|
/**
|
|
822
|
-
* 失败计数;达阈值(默认
|
|
850
|
+
* 失败计数;达阈值(默认 5)→ quarantined + 审计。
|
|
823
851
|
*
|
|
824
852
|
* 计数是**连续**而非累计(0.7.0 FR-12.5):一次成功执行经 `clearFailures` 归零,
|
|
825
853
|
* `setState(name, 'active')` 同样清零。
|
|
@@ -921,9 +949,19 @@ var SkillStatePolicy = class {
|
|
|
921
949
|
*/
|
|
922
950
|
toSkillOutcomeReporter(input = {}) {
|
|
923
951
|
const denied = input.policyDenialCodes ?? POLICY_DENIAL_CODES;
|
|
952
|
+
const userCaused = input.userCausedCodes ?? USER_CAUSED_CODES;
|
|
924
953
|
const actor = input.actor !== void 0 ? { actor: input.actor } : {};
|
|
925
954
|
return {
|
|
926
955
|
onSkillFailed: async (report) => {
|
|
956
|
+
if (userCaused.has(report.code)) {
|
|
957
|
+
await this.#audit?.append({
|
|
958
|
+
type: AUDIT_EVENT_TYPES.skillUserCaused,
|
|
959
|
+
target: report.skillName,
|
|
960
|
+
...actor,
|
|
961
|
+
data: { code: report.code }
|
|
962
|
+
});
|
|
963
|
+
return;
|
|
964
|
+
}
|
|
927
965
|
if (denied.has(report.code)) {
|
|
928
966
|
await this.#audit?.append({
|
|
929
967
|
type: AUDIT_EVENT_TYPES.skillPolicyDenied,
|
|
@@ -1178,7 +1216,7 @@ var DocumentSkillExtractor = class {
|
|
|
1178
1216
|
documentHash: input.document.hash
|
|
1179
1217
|
};
|
|
1180
1218
|
await this.#audit?.append({
|
|
1181
|
-
type:
|
|
1219
|
+
type: AUDIT_EVENT_TYPES.candidateCreated,
|
|
1182
1220
|
target: candidate.id,
|
|
1183
1221
|
data: {
|
|
1184
1222
|
name: candidate.name,
|
|
@@ -1231,4 +1269,4 @@ function createMissHook(deps) {
|
|
|
1231
1269
|
}
|
|
1232
1270
|
|
|
1233
1271
|
//#endregion
|
|
1234
|
-
export { AUDIT_EVENT_TYPES, AUDIT_EVENT_TYPE_LIST, AUDIT_PAGE_SIZE, AlwaysHumanApprovalPolicy, CANDIDATE_PAGE_SIZE, CandidateStore, CompositeApprovalPolicy, DependencyGraph, DocumentSkillExtractor, EvaluationRunner, FailureAnalyzer, FsAuditLog, LlmCandidateGenerator, POLICY_DENIAL_CODES, QUARANTINE_REASONS, RepairPlanner, SCORING_WEIGHTS, SKILL_VERSION_PAGE_SIZE, SimilarityDetector, SkillScorer, SkillStatePolicy, SkillVersionStore, candidateToCatalogEntry, completeText, createCandidateSink, createMissHook, jaccardSimilarity, normalizeCandidate, normalizeCandidateFiles, normalizeRisk, parseJsonObject, readDocument, sanitizeCandidateName, suggestFromFailedRun, validateCandidate };
|
|
1272
|
+
export { AUDIT_EVENT_TYPES, AUDIT_EVENT_TYPE_LIST, AUDIT_PAGE_SIZE, AlwaysHumanApprovalPolicy, CANDIDATE_PAGE_SIZE, CandidateStore, CompositeApprovalPolicy, DependencyGraph, DocumentSkillExtractor, EvaluationRunner, FailureAnalyzer, FsAuditLog, LlmCandidateGenerator, POLICY_DENIAL_CODES, QUARANTINE_REASONS, RepairPlanner, SCORING_WEIGHTS, SKILL_VERSION_PAGE_SIZE, SimilarityDetector, SkillScorer, SkillStatePolicy, SkillVersionStore, USER_CAUSED_CODES, candidateToCatalogEntry, completeText, createCandidateSink, createMissHook, jaccardSimilarity, normalizeCandidate, normalizeCandidateFiles, normalizeRisk, parseJsonObject, readDocument, sanitizeCandidateName, suggestFromFailedRun, validateCandidate };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { k as ExternalToolSource } from "./index-
|
|
1
|
+
import { B as JsonSchema, C as UiSpecActionCapability, D as UiSpecSnapshot, S as UiBridge, b as RenderResultRequest, bt as UiSpecNode, c as InteractionResponse, r as ChartSpec, s as InteractionRequest, y as RenderBlock } from "./types-CrRcT-LM-DZAp8sWv.js";
|
|
2
|
+
import { k as ExternalToolSource } from "./index-DtFdMKBX.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { ComponentType, ReactNode } from "react";
|
|
5
5
|
//#region ../ui/dist/index.d.ts
|
|
@@ -76,6 +76,10 @@ interface SurfaceFormTexts {
|
|
|
76
76
|
arrayFirstItemOnly: string;
|
|
77
77
|
/** 历史快照(宿主未接 action)的一次性只读说明 */
|
|
78
78
|
readOnlySnapshot: string;
|
|
79
|
+
/** 建议值的前缀(0.10.0 #48.14:画像建议标签此前只有英文硬编码) */
|
|
80
|
+
suggested: string;
|
|
81
|
+
/** 采纳建议值的按钮 */
|
|
82
|
+
useSuggestion: string;
|
|
79
83
|
}
|
|
80
84
|
/** 可复用的部分取自 DEFAULT_INTERACTION_TEXTS,不另抄一份(AC-G10) */
|
|
81
85
|
declare const DEFAULT_SURFACE_FORM_TEXTS: SurfaceFormTexts;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as InteractionOrigin, c as InteractionResponse, s as InteractionRequest
|
|
2
|
-
import { k as ExternalToolSource } from "./index-
|
|
1
|
+
import { S as UiBridge, a as InteractionOrigin, c as InteractionResponse, s as InteractionRequest } from "./types-CrRcT-LM-DZAp8sWv.js";
|
|
2
|
+
import { k as ExternalToolSource } from "./index-DtFdMKBX.js";
|
|
3
3
|
//#region ../agent/dist/index.d.ts
|
|
4
4
|
//#region src/todo/types.d.ts
|
|
5
5
|
/** 待办条目状态:未开始 / 进行中 / 已完成(FR-3.1) */
|
|
@@ -134,6 +134,13 @@ interface SkillGeneratorOptions {
|
|
|
134
134
|
/** 生成所属会话,写入审计与候选 metadata */
|
|
135
135
|
sessionId?: () => string | undefined;
|
|
136
136
|
now?: () => Date;
|
|
137
|
+
/** 界面文案注入口:生成器与语言无关,字典在宿主手里(UI-UX5 #9) */
|
|
138
|
+
messages?: SkillGenerationMessages;
|
|
139
|
+
}
|
|
140
|
+
/** 生成器面向用户的文案;缺省全部为英文模板 */
|
|
141
|
+
interface SkillGenerationMessages {
|
|
142
|
+
/** 授权确认卡的正文(含技能名与描述插值由实现方完成) */
|
|
143
|
+
confirmSkill?(draft: GeneratedSkillDraft): string;
|
|
137
144
|
}
|
|
138
145
|
/**
|
|
139
146
|
* 技能自动生成策略。生成动作是策略而不是内核:它不进入 `AgentLoop`,
|
|
@@ -622,4 +629,4 @@ declare function createPageActionToolSource(options: PageActionToolSourceOptions
|
|
|
622
629
|
*/
|
|
623
630
|
declare const PAGE_ACTION_SYSTEM_PROMPT: string;
|
|
624
631
|
//#endregion
|
|
625
|
-
export {
|
|
632
|
+
export { TodoList as $, PagePerceptionReader as A, SKILL_GENERATION_SYSTEM_PROMPT as B, PageActionRequest as C, PageAuditSink as D, PageActionUi as E, PerceptionAuditSink as F, SkillGenerationToolSourceOptions as G, SkillGenerationMessages as H, PerceptionCaptureOptions as I, SubAgentRunInput as J, SkillGenerator as K, PerceptionRecord as L, ParentBudget as M, PerceivedImage as N, PagePerceptionPolicy as O, PerceivedNode as P, TodoItem as Q, PerceptionResult as R, PageActionRecord as S, PageActionToolSourceOptions as T, SkillGenerationOutcome as U, SkillCandidateSink as V, SkillGenerationPolicy as W, TODO_SYSTEM_PROMPT as X, SubAgentRunner as Y, TodoEvent as Z, PageActionExecutor as _, DelegationOrchestratorOptions as a, createPageActionToolSource as at, PageActionPolicy as b, DelegationToolSourceOptions as c, createTodoToolSource as ct, ImageCaptureBudget as d, TodoListener as et, MANAGE_TODO_TOOL as f, PERCEPTION_SYSTEM_PROMPT as g, PERCEIVE_PAGE_TOOL as h, DelegationOrchestrator as i, createDelegationToolSource as it, PagePerceptionToolSourceOptions as j, PagePerceptionPolicyOptions as k, GENERATE_SKILL_TOOL as l, withDelegationOrigin as lt, PAGE_ACTION_TOOL as m, DELEGATION_SYSTEM_PROMPT as n, TodoStore as nt, DelegationRequest as o, createPagePerceptionToolSource as ot, PAGE_ACTION_SYSTEM_PROMPT as p, SkillGeneratorOptions as q, DelegationBudget as r, TodoToolSourceOptions as rt, DelegationResult as s, createSkillGenerationToolSource as st, DELEGATE_TASK_TOOL as t, TodoStatus as tt, GeneratedSkillDraft as u, PageActionKind as v, PageActionScope as w, PageActionPolicyOptions as x, PageActionOutcome as y, PerceptionScope as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as JsonSchema, I as DiscoveryResult, O as UiSurfaceActionRequest, R as FileSystemProvider, S as UiBridge, St as ValidationReport, T as UiSpecEvent, Tt as WebSkillErrorCode, U as Page, W as PageQuery, _ as LlmToolSpec, at as SkillDiscovery, b as RenderResultRequest, bt as UiSpecNode, d as LlmContentPart, dt as SkillManifest, f as LlmMessage, g as LlmToolCall, h as LlmTokenUsage, i as FormField, it as SkillCatalogEntry, l as LlmClient, m as LlmStreamEvent, n as ArtifactStore, o as InteractionPolicy, ot as SkillDocument, p as LlmResponse, r as ChartSpec, rt as SkillCatalog, s as InteractionRequest, st as SkillInstallSource, t as Artifact, u as LlmCompleteInput, v as MemoryStore, w as UiSpecDrafts, y as RenderBlock } from "./types-CrRcT-LM-DZAp8sWv.js";
|
|
2
2
|
//#region ../runtime/dist/index.d.ts
|
|
3
3
|
//#region src/llm/parts.d.ts
|
|
4
4
|
/** 纯文本消息内容的构造快捷方式(引擎内部绝大多数消息仍是纯文本) */
|
|
@@ -148,6 +148,19 @@ interface AnthropicClientConfig {
|
|
|
148
148
|
requestTimeoutMs?: number;
|
|
149
149
|
/** max_tokens(Messages API 必填),默认 4096 */
|
|
150
150
|
maxTokens?: number;
|
|
151
|
+
/**
|
|
152
|
+
* Extended thinking 开关(预算 token 数)。语义(0.10.0 复核后固化的分层口径):
|
|
153
|
+
* - 不设置 ⇒ 完全不请求思考能力(**直连客户端的缺省**);
|
|
154
|
+
* - `> 0` 的正整数 ⇒ 启用并透传 `budget_tokens`;
|
|
155
|
+
* - `<= 0` / 非整数 / 非有限数 ⇒ 一律视为关闭(不发出 thinking 参数,避免供应商 400)。
|
|
156
|
+
* 经 `createLlmClient` 装配时由工厂层按 `?? 10_000` 默认开启(0.10.0 #40.4),
|
|
157
|
+
* 与直连客户端的「默认关闭」是同一字段的两层缺省,不互相冲突。
|
|
158
|
+
* 开启后响应里的 thinking block 解析进 `LlmResponse.thinking`,
|
|
159
|
+
* 流式路径的 thinking_delta 映射为 `thinking-delta` 事件。
|
|
160
|
+
* 注意:Anthropic 要求 thinking 开启时不传 temperature(只允许默认值 1),
|
|
161
|
+
* 本客户端在开启时自动省略 temperature。
|
|
162
|
+
*/
|
|
163
|
+
thinkingBudgetTokens?: number;
|
|
151
164
|
/**
|
|
152
165
|
* 浏览器直调 opt-in:true 时发送 anthropic-dangerous-direct-browser-access 头
|
|
153
166
|
* (默认 false 不发——仅在明确运行于浏览器且无服务端代理时开启)
|
|
@@ -161,7 +174,12 @@ declare class AnthropicClient implements LlmClient {
|
|
|
161
174
|
complete(input: LlmCompleteInput): Promise<LlmResponse>;
|
|
162
175
|
/** SSE 流式:text_delta → text-delta;input_json_delta 按 block index 聚合 → tool-calls */
|
|
163
176
|
stream(input: LlmCompleteInput): AsyncIterable<LlmStreamEvent>;
|
|
164
|
-
/**
|
|
177
|
+
/**
|
|
178
|
+
* 真实调用路径探测(FR-27.1):`POST /v1/messages` 最小请求(max_tokens=1),200 即可达。
|
|
179
|
+
* Anthropic 兼容端点(如 LM Studio 的 /anthropic 层)不实现 `GET /v1/models`,
|
|
180
|
+
* 用 /models 探测会把「能对话」误判为「不可达」——checkAvailability 的语义从
|
|
181
|
+
* 「/models 可达」改为「能完成一次真实调用」。
|
|
182
|
+
*/
|
|
165
183
|
checkAvailability(): Promise<boolean>;
|
|
166
184
|
}
|
|
167
185
|
//#endregion
|
|
@@ -370,6 +388,11 @@ type ExecuteLifecycleData = {
|
|
|
370
388
|
} | {
|
|
371
389
|
kind: 'llm-delta';
|
|
372
390
|
delta: string;
|
|
391
|
+
} |
|
|
392
|
+
/** 思考增量(0.10.0 UI-UX5 #32):流式思考逐段透出;非流式路径一次性补发整段 */
|
|
393
|
+
{
|
|
394
|
+
kind: 'thinking-delta';
|
|
395
|
+
delta: string;
|
|
373
396
|
} | {
|
|
374
397
|
kind: 'interaction-resumed';
|
|
375
398
|
interactionId: string;
|
|
@@ -439,7 +462,11 @@ type LifecycleHook = (ctx: LifecycleHookContext) => Promise<void | {
|
|
|
439
462
|
}>;
|
|
440
463
|
//#endregion
|
|
441
464
|
//#region src/trace/types.d.ts
|
|
442
|
-
type TraceEventType = 'skill.routed' | 'skill.activated' | 'skill.integrity-failed' | 'llm.request' | 'llm.response' |
|
|
465
|
+
type TraceEventType = 'skill.routed' | 'skill.activated' | 'skill.integrity-failed' | 'llm.request' | 'llm.response' |
|
|
466
|
+
/** 一轮模型调用产出的一段思考正文(data.text;每轮至多一条,UI-UX5 #32) */
|
|
467
|
+
'llm.thinking' |
|
|
468
|
+
/** 一轮模型调用的 token 用量(data.inputTokens/outputTokens;上游不回报则无此事件,UI-UX5 #47) */
|
|
469
|
+
'llm.usage' | 'tool.started' | 'tool.completed' | 'tool.failed' | 'tool.denied' | 'artifact.created' | 'ui.requested' | 'ui.resumed' | 'ui.surface-action.requested' | 'ui.surface-action.resolved' | 'ui.rendered' | 'ui.degraded' | 'todo.created' | 'todo.updated' | 'todo.cleared' | 'run.warning' | 'run.completed' | 'run.cancelled' | 'run.failed' | 'run.resumed';
|
|
443
470
|
interface TraceEvent {
|
|
444
471
|
id: string;
|
|
445
472
|
runId: string;
|
|
@@ -460,7 +487,7 @@ interface AgentLoopConfig {
|
|
|
460
487
|
temperature?: number;
|
|
461
488
|
/** 设为 'off' 时完成 run 不调用 uiBridge.renderResult */
|
|
462
489
|
renderResult?: 'off';
|
|
463
|
-
/** 工具结果回喂上限(字节,默认
|
|
490
|
+
/** 工具结果回喂上限(字节,默认 256_000;超长头尾保留 + 完整内容落 artifact) */
|
|
464
491
|
toolResultMaxBytes?: number;
|
|
465
492
|
/** session paramHistory 保留条数上限(默认 50,超出裁最旧) */
|
|
466
493
|
paramHistoryLimit?: number;
|
|
@@ -1331,8 +1358,8 @@ declare class AgentLoop {
|
|
|
1331
1358
|
*/
|
|
1332
1359
|
declare const DEFAULT_LOOP_LIMITS: {
|
|
1333
1360
|
readonly maxTurns: 10;
|
|
1334
|
-
readonly totalTimeoutMs:
|
|
1335
|
-
readonly toolTimeoutMs:
|
|
1361
|
+
readonly totalTimeoutMs: 3600000;
|
|
1362
|
+
readonly toolTimeoutMs: 600000;
|
|
1336
1363
|
};
|
|
1337
1364
|
/**
|
|
1338
1365
|
* 触顶类失败(`RUN_TIMEOUT` / `RUN_MAX_TURNS_EXCEEDED`)记进 `run.failed`
|
|
@@ -1488,6 +1515,12 @@ interface RunTraceSummary {
|
|
|
1488
1515
|
turnCount: number;
|
|
1489
1516
|
/** endedAt - startedAt,无 endedAt 或时间戳不可解析时缺省 */
|
|
1490
1517
|
durationMs?: number;
|
|
1518
|
+
/**
|
|
1519
|
+
* 本 run 各轮 `llm.usage` 事件的 token 聚合(0.10.0 UI-UX5 #47)。
|
|
1520
|
+
* 全 run 无 usage 上报(旧 trace、不支持统计的上游)时缺省——
|
|
1521
|
+
* 消费方据「有没有」决定要不要展示,不显示假数据。
|
|
1522
|
+
*/
|
|
1523
|
+
usage?: LlmTokenUsage;
|
|
1491
1524
|
}
|
|
1492
1525
|
/** @stable */
|
|
1493
1526
|
interface RunTraceFilter {
|
|
@@ -1561,6 +1594,11 @@ interface RunToolCall {
|
|
|
1561
1594
|
args?: string;
|
|
1562
1595
|
/** 执行耗时 ms */
|
|
1563
1596
|
durationMs?: number;
|
|
1597
|
+
/**
|
|
1598
|
+
* 开始时刻(trace `tool.started` 的 ts,ISO)。思考卡片与工具卡片按时间
|
|
1599
|
+
* 穿插(UI-UX5 #32)需要一个共同时钟;旧 trace 没有 started 事件时缺省。
|
|
1600
|
+
*/
|
|
1601
|
+
startedAt?: string;
|
|
1564
1602
|
/**
|
|
1565
1603
|
* failed 时的结构化错误码(如 `TOOL_NOT_ALLOWED`)。
|
|
1566
1604
|
* 消费方据此区分「被策略拒绝」与「执行出错」,不必解析 message 文案。
|
|
@@ -1580,6 +1618,30 @@ interface RunToolCall {
|
|
|
1580
1618
|
*/
|
|
1581
1619
|
declare function summarizeToolCalls(run: RuntimeRun): RunToolCall[];
|
|
1582
1620
|
//#endregion
|
|
1621
|
+
//#region src/engine/usage.d.ts
|
|
1622
|
+
/**
|
|
1623
|
+
* 一次 run 的大模型用量聚合(0.10.0 UI-UX5 #47)。
|
|
1624
|
+
* 从 trace 事件推导,不落第二份数据:llm.request 计请求次数,llm.usage 计 token。
|
|
1625
|
+
* @stable
|
|
1626
|
+
*/
|
|
1627
|
+
interface RunUsageSummary {
|
|
1628
|
+
/** llm.request 事件数:本 run 向大模型发送请求的次数(与 RunTraceSummary.turnCount 同源) */
|
|
1629
|
+
llmCalls: number;
|
|
1630
|
+
/**
|
|
1631
|
+
* 各轮 llm.usage 的输入 token 合计。全 run 没有任何 usage 上报时缺省——
|
|
1632
|
+
* 「上游不支持统计」与「恰好为零」必须可区分,消费方缺省时不显示假数据。
|
|
1633
|
+
*/
|
|
1634
|
+
inputTokens?: number;
|
|
1635
|
+
/** 各轮 llm.usage 的输出 token 合计;缺省语义同 inputTokens */
|
|
1636
|
+
outputTokens?: number;
|
|
1637
|
+
}
|
|
1638
|
+
/**
|
|
1639
|
+
* 从 run 的 trace 聚合大模型用量(请求次数 + 输入/输出 token)。
|
|
1640
|
+
* 与 `summarizeToolCalls` 同型:消费方不再各自遍历 trace。
|
|
1641
|
+
* @stable
|
|
1642
|
+
*/
|
|
1643
|
+
declare function summarizeRunUsage(trace: readonly TraceEvent[]): RunUsageSummary;
|
|
1644
|
+
//#endregion
|
|
1583
1645
|
//#region src/engine/session.d.ts
|
|
1584
1646
|
declare const SESSION_SCHEMA_VERSION = 1;
|
|
1585
1647
|
/** `FsSessionStore` 的缺省页长。缺省值属于实现,不属于调用方——否则「下推」只推了一半 */
|
|
@@ -1692,4 +1754,4 @@ declare class FsSessionStore<TMessage = unknown> implements SessionStore<TMessag
|
|
|
1692
1754
|
delete(id: string): Promise<void>;
|
|
1693
1755
|
}
|
|
1694
1756
|
//#endregion
|
|
1695
|
-
export { READ_SKILL_FILE_INPUT_SCHEMA as $,
|
|
1757
|
+
export { READ_SKILL_FILE_INPUT_SCHEMA as $, schemaToForm as $n, TraceEventType as $t, FS_SESSION_PAGE_SIZE as A, fromVercelStreamPart as An, SealResult as At, HookRunnerOptions as B, normalizeToolContent as Bn, SkillScriptDescriptor as Bt, DEFAULT_LOOP_LIMITS as C, exportUserProfile as Cn, RuntimeSessionHandle as Ct, ExecuteLifecycleData as D, findUnpairedToolCalls as Dn, ScriptExecutor as Dt, EventBus as E, extractUiSpecEvents as En, ScriptExecutionContext as Et, FsSessionStore as F, mergeCatalogEntries as Fn, SessionStore as Ft, LifecycleEventInit as G, readBehaviorRecords as Gn, TextualToolContent as Gt, IntegrityVerdict as H, parseBridgeRequest as Hn, SkillStateGuard as Ht, FullDisclosureRouter as I, mergeProfileEntries as In, SkillFailureReport as It, LifecycleListener as J, refineUserProfile as Jn, ToolDefinition as Jt, LifecycleHook as K, readProfileEntries as Kn, TodoTraceEvent as Kt, GoogleGenAiClient as L, networkPolicyLibSource as Ln, SkillIntegrityGuard as Lt, FsMemoryStore as M, isNetworkAllowed as Mn, SessionListPage as Mt, FsRunSnapshotStore as N, isUnsupportedRunSnapshot as Nn, SessionMeta as Nt, ExternalSkillProvider as O, formatSkillScriptManifest as On, SealOptions as Ot, FsRunTraceStore as P, listSkillScripts as Pn, SessionRecord as Pt, ProgressiveRouter as Q, schemaSourceLabel as Qn, TraceEvent as Qt, GoogleGenAiClientConfig as R, networkUrlHost as Rn, SkillOutcomeReporter as Rt, CapabilityMode as S, diffUserProfile as Sn, RuntimeSession as St, EMPTY_USER_PROFILE as T, extractTodoTraceEvents as Tn, SchemaInferer as Tt, InteractLifecycleData as U, parseUserProfileExport as Un, SkillSuccessReport as Ut, InstalledSkillManifest as V, normalizeToolError as Vn, SkillScriptSchemaSource as Vt, LifecycleEvent as W, partsToText as Wn, TerminalLifecycleData as Wt, OpenAiCompatibleClient as X, resolveToolName as Xn, ToolResult as Xt, NetworkPolicy as Y, renderUserProfileContext as Yn, ToolResolution as Yt, OpenAiCompatibleClientConfig as Z, sampleBehaviorRecords as Zn, TraceClock as Zt, BridgeCapabilities as _, applyUserProfileImport as _n, RunTraceStore as _t, ActivateLifecycleData as a, USER_PROFILE_REFINE_PROMPT as an, toLlmToolSpec as ar, RouteLifecycleData as at, BridgeResponse as b, createScriptContext as bn, RuntimePhase as bt, AgentLoopDeps as c, UserProfileEntry as cn, validateUiSpecEvent as cr, RunResult as ct, ApprovalDecision as d, UserProfileLimits as dn, RunSnapshotStore as dt, TraceRecorder as en, scriptToolName as er, READ_SKILL_FILE_TOOL as et, ApprovalScope as f, VercelToolSpec as fn, RunTerminationReason as ft, BehaviorScene as g, appendBehaviorRecords as gn, RunTraceMetrics as gt, BehaviorRecordKind as h, WebSkillRuntimeDeps as hn, RunTraceFilter as ht, ASK_USER_TOOL_NAME as i, USER_PROFILE_PROMPT_HEADER as in, textParts as ir, RefineUserProfileInput as it, FsArtifactStore as j, interruptedToolResult as jn, SerializingMemoryStore as jt, ExternalToolSource as k, fromVercelResult as kn, SealRecord as kt, AnthropicClient as l, UserProfileExport as ln, validateUiSpecNode as lr, RunSnapshot as lt, BehaviorRecord as m, WebSkillRuntime as mn, RunTraceFile as mt, ASK_USER_INPUT_SCHEMA as n, USER_PROFILE_KEY as nn, summarizeRunUsage as nr, RUN_SNAPSHOT_SCHEMA_VERSION as nt, AgentLoop as o, UnsupportedRunSnapshot as on, toRecordDigests as or, RouteResult as ot, BEHAVIOR_RECORDS_KEY as p, WebSkillApi as pn, RunToolCall as pt, LifecycleHookContext as q, readUserProfile as qn, ToolContent as qt, ASK_USER_TOOL as r, USER_PROFILE_NO_INVENTION_RULE as rn, summarizeToolCalls as rr, RUN_TRACE_SCHEMA_VERSION as rt, AgentLoopConfig as s, UserProfile as sn, toVercelToolSpecs as sr, RunLimitErrorDetails as st, ALLOWED_TOOLS_EXCLUSION_REASON as t, USER_PROFILE_EXPORT_VERSION as tn, sealToolCallPairs as tr, READ_SKILL_FILE_TOOL_NAME as tt, AnthropicClientConfig as u, UserProfileImportDiff as un, RunSnapshotListEntry as ut, BridgeCapability as v, bridgeError as vn, RunTraceSummary as vt, DEFAULT_USER_PROFILE_LIMITS as w, extractChartSpec as wn, SESSION_SCHEMA_VERSION as wt, CapabilityApproval as x, createWebSkillApi as xn, RuntimeRun as xt, BridgeRequest as y, buildRenderResult as yn, RunUsageSummary as yt, HookRunner as z, normalizeErrorCode as zn, SkillRouter as zt };
|