@webskill/sdk 0.17.0 → 0.18.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 +1 -1
- package/dist/agent.js +13 -6
- package/dist/{approval-CBPnGPIm.js → approval-B7GW86u2.js} +1 -1
- package/dist/browser.d.ts +9 -1
- package/dist/browser.js +136 -4
- package/dist/governance.js +1 -1
- package/dist/{index-1sQZ4VBN.d.ts → index-DQ3-6GFu.d.ts} +27 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/{llm-B7lLH0ZI.js → llm-eIQNO9tr.js} +67 -12
- package/dist/node.js +1 -1
- package/dist/testing.js +1 -1
- package/dist/{types-BuacBov_.js → types-DOJI5YC3.js} +4 -3
- package/dist/{webSkillApi-Ce2OO5S5.js → webSkillApi-DMENIqW0.js} +1 -1
- package/package.json +1 -1
package/dist/agent.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { E as DEFAULT_MAX_DATA_SOURCE_BYTES } from "./index-BDyXe-a5.js";
|
|
2
|
-
import { $ as NestedFrameRef, $t as TAB_WORKSET_MIN_MAX, A as DelegationRequest, An as withDelegationOrigin, At as PerceptionAuditSink, B as DownloadedFileReader, Bt as SkillGenerationMessages, C as DataSourcePolicyOptions, Cn as createSkillGenerationToolSource, Ct as PagePerceptionPolicy, D as DelegationBudget, Dn as frameSteps, Dt as ParentBudget, E as DataSourceTransport, En as frameLabel, Et as PagePerceptionToolSourceOptions, F as DownloadedFileEntry, Ft as PerceptionScope, G as FrameScope, Gt as SkillGeneratorOptions, H as DownloadedFileToolSourceOptions, Ht as SkillGenerationPolicy, I as DownloadedFileListing, It as PerceptionScopeInput, J as HttpDataSourceOptions, Jt as SubAgentRunInput, K as GENERATE_SKILL_TOOL, Kt as SkillTraceEvidence, L as DownloadedFilePolicy, Lt as READ_DOWNLOADED_FILE_TOOL, M as DelegationToolSourceOptions, Mt as PerceptionPagingBudget, N as DownloadedFileAction, Nt as PerceptionRecord, O as DelegationOrchestrator, On as toActionFrameScopes, Ot as PerceivedImage, P as DownloadedFileConsent, Pt as PerceptionResult, Q as MANAGE_TODO_TOOL, Qt as TAB_WORKSET_MAX_MAX, R as DownloadedFilePolicyOptions, Rt as SKILL_GENERATION_SYSTEM_PROMPT, S as DataSourcePolicy, Sn as createPagePerceptionToolSource, St as PageAuditSink, T as DataSourceRecord, Tn as createTodoToolSource, Tt as PagePerceptionReader, U as FOCUS_PAGE_TAB_TOOL, Ut as SkillGenerationToolSourceOptions, V as DownloadedFileRecord, Vt as SkillGenerationOutcome, W as FrameNote, Wt as SkillGenerator, X as LIST_DOWNLOADED_FILES_TOOL, Xt as SubtreeRejection, Y as ImageCaptureBudget, Yt as SubAgentRunner, Z as LIST_PAGE_TABS_TOOL, Zt as TAB_WORKSET_DEFAULT_MAX, _ as DataSourceCandidatePolicyOptions, _n as clampWorksetMax, _t as PageActionScope, a as ActionTabWindow, an as TabWorksetPort, at as PAGE_DOCUMENT_REF, b as DataSourceDef, bn as createHttpDataSourceTransport, bt as PageActionToolSourceOptions, c as DELEGATE_TASK_TOOL, cn as TodoItem, ct as PERCEPTION_SYSTEM_PROMPT, d as DOWNLOAD_WAIT_MAX_MS, dn as TodoStatus, dt as PageActionKind, en as TAB_WORKSET_SYSTEM_PROMPT, et as OpenedPageInfo, f as DOWNLOAD_WAIT_MIN_MS, fn as TodoStore, ft as PageActionOutcome, g as DataSourceCandidatePolicy, gn as clampDownloadWaitMs, gt as PageActionRequest, h as DataSourceCandidateAuditSink, hn as WorksetTabView, ht as PageActionRecord, i as ActionTabWatcher, in as TabWorksetPolicyOptions, it as PAGE_ACTION_TOOL, j as DelegationResult, jt as PerceptionCaptureOptions, k as DelegationOrchestratorOptions, kn as toFrameScopes, kt as PerceivedNode, l as DELEGATION_SYSTEM_PROMPT, ln as TodoList, lt as PageActionConsent, m as DataSourceCandidate, mn as WorksetTab, mt as PageActionPolicyOptions, n as ActionDownloadWindow, nn as TabAdmission, nt as PAGE_ACTION_KINDS, o as CLOSE_PAGE_TAB_TOOL, on as TabWorksetToolSourceOptions, ot as PERCEIVE_PAGE_TOOL, p as DataSourceAuditSink, pn as TodoToolSourceOptions, pt as PageActionPolicy, q as GeneratedSkillDraft, qt as SkillTraceEvidenceStep, r as ActionFrameScope, rn as TabWorksetPolicy, rt as PAGE_ACTION_SYSTEM_PROMPT, s as ConsentUi, sn as TodoEvent, st as PERCEPTION_PAGING_DEFAULTS, t as ActionDownloadWatcher, tn as TODO_SYSTEM_PROMPT, tt as OpenedTabSignal, u as DOWNLOAD_WAIT_DEFAULT_MS, un as TodoListener, ut as PageActionExecutor, v as DataSourceCandidateRecord, vn as createDelegationToolSource, vt as PageActionScopeInput, w as DataSourceProvenance, wn as createTabWorksetToolSource, wt as PagePerceptionPolicyOptions, x as DataSourceKind, xn as createPageActionToolSource, xt as PageActionUi, y as DataSourceCandidateStore, yn as createDownloadedFileToolSource, yt as PageActionTarget, z as DownloadedFileReadResult, zt as SkillCandidateSink } from "./index-
|
|
2
|
+
import { $ as NestedFrameRef, $t as TAB_WORKSET_MIN_MAX, A as DelegationRequest, An as withDelegationOrigin, At as PerceptionAuditSink, B as DownloadedFileReader, Bt as SkillGenerationMessages, C as DataSourcePolicyOptions, Cn as createSkillGenerationToolSource, Ct as PagePerceptionPolicy, D as DelegationBudget, Dn as frameSteps, Dt as ParentBudget, E as DataSourceTransport, En as frameLabel, Et as PagePerceptionToolSourceOptions, F as DownloadedFileEntry, Ft as PerceptionScope, G as FrameScope, Gt as SkillGeneratorOptions, H as DownloadedFileToolSourceOptions, Ht as SkillGenerationPolicy, I as DownloadedFileListing, It as PerceptionScopeInput, J as HttpDataSourceOptions, Jt as SubAgentRunInput, K as GENERATE_SKILL_TOOL, Kt as SkillTraceEvidence, L as DownloadedFilePolicy, Lt as READ_DOWNLOADED_FILE_TOOL, M as DelegationToolSourceOptions, Mt as PerceptionPagingBudget, N as DownloadedFileAction, Nt as PerceptionRecord, O as DelegationOrchestrator, On as toActionFrameScopes, Ot as PerceivedImage, P as DownloadedFileConsent, Pt as PerceptionResult, Q as MANAGE_TODO_TOOL, Qt as TAB_WORKSET_MAX_MAX, R as DownloadedFilePolicyOptions, Rt as SKILL_GENERATION_SYSTEM_PROMPT, S as DataSourcePolicy, Sn as createPagePerceptionToolSource, St as PageAuditSink, T as DataSourceRecord, Tn as createTodoToolSource, Tt as PagePerceptionReader, U as FOCUS_PAGE_TAB_TOOL, Ut as SkillGenerationToolSourceOptions, V as DownloadedFileRecord, Vt as SkillGenerationOutcome, W as FrameNote, Wt as SkillGenerator, X as LIST_DOWNLOADED_FILES_TOOL, Xt as SubtreeRejection, Y as ImageCaptureBudget, Yt as SubAgentRunner, Z as LIST_PAGE_TABS_TOOL, Zt as TAB_WORKSET_DEFAULT_MAX, _ as DataSourceCandidatePolicyOptions, _n as clampWorksetMax, _t as PageActionScope, a as ActionTabWindow, an as TabWorksetPort, at as PAGE_DOCUMENT_REF, b as DataSourceDef, bn as createHttpDataSourceTransport, bt as PageActionToolSourceOptions, c as DELEGATE_TASK_TOOL, cn as TodoItem, ct as PERCEPTION_SYSTEM_PROMPT, d as DOWNLOAD_WAIT_MAX_MS, dn as TodoStatus, dt as PageActionKind, en as TAB_WORKSET_SYSTEM_PROMPT, et as OpenedPageInfo, f as DOWNLOAD_WAIT_MIN_MS, fn as TodoStore, ft as PageActionOutcome, g as DataSourceCandidatePolicy, gn as clampDownloadWaitMs, gt as PageActionRequest, h as DataSourceCandidateAuditSink, hn as WorksetTabView, ht as PageActionRecord, i as ActionTabWatcher, in as TabWorksetPolicyOptions, it as PAGE_ACTION_TOOL, j as DelegationResult, jt as PerceptionCaptureOptions, k as DelegationOrchestratorOptions, kn as toFrameScopes, kt as PerceivedNode, l as DELEGATION_SYSTEM_PROMPT, ln as TodoList, lt as PageActionConsent, m as DataSourceCandidate, mn as WorksetTab, mt as PageActionPolicyOptions, n as ActionDownloadWindow, nn as TabAdmission, nt as PAGE_ACTION_KINDS, o as CLOSE_PAGE_TAB_TOOL, on as TabWorksetToolSourceOptions, ot as PERCEIVE_PAGE_TOOL, p as DataSourceAuditSink, pn as TodoToolSourceOptions, pt as PageActionPolicy, q as GeneratedSkillDraft, qt as SkillTraceEvidenceStep, r as ActionFrameScope, rn as TabWorksetPolicy, rt as PAGE_ACTION_SYSTEM_PROMPT, s as ConsentUi, sn as TodoEvent, st as PERCEPTION_PAGING_DEFAULTS, t as ActionDownloadWatcher, tn as TODO_SYSTEM_PROMPT, tt as OpenedTabSignal, u as DOWNLOAD_WAIT_DEFAULT_MS, un as TodoListener, ut as PageActionExecutor, v as DataSourceCandidateRecord, vn as createDelegationToolSource, vt as PageActionScopeInput, w as DataSourceProvenance, wn as createTabWorksetToolSource, wt as PagePerceptionPolicyOptions, x as DataSourceKind, xn as createPageActionToolSource, xt as PageActionUi, y as DataSourceCandidateStore, yn as createDownloadedFileToolSource, yt as PageActionTarget, z as DownloadedFileReadResult, zt as SkillCandidateSink } from "./index-DQ3-6GFu.js";
|
|
3
3
|
export { type ActionDownloadWatcher, type ActionDownloadWindow, type ActionFrameScope, type ActionTabWatcher, type ActionTabWindow, CLOSE_PAGE_TAB_TOOL, type ConsentUi, DEFAULT_MAX_DATA_SOURCE_BYTES, DELEGATE_TASK_TOOL, DELEGATION_SYSTEM_PROMPT, DOWNLOAD_WAIT_DEFAULT_MS, DOWNLOAD_WAIT_MAX_MS, DOWNLOAD_WAIT_MIN_MS, type DataSourceAuditSink, type DataSourceCandidate, type DataSourceCandidateAuditSink, DataSourceCandidatePolicy, type DataSourceCandidatePolicyOptions, type DataSourceCandidateRecord, type DataSourceCandidateStore, type DataSourceDef, type DataSourceKind, DataSourcePolicy, type DataSourcePolicyOptions, type DataSourceProvenance, type DataSourceRecord, type DataSourceTransport, type DelegationBudget, DelegationOrchestrator, type DelegationOrchestratorOptions, type DelegationRequest, type DelegationResult, type DelegationToolSourceOptions, type DownloadedFileAction, type DownloadedFileConsent, type DownloadedFileEntry, type DownloadedFileListing, DownloadedFilePolicy, type DownloadedFilePolicyOptions, type DownloadedFileReadResult, type DownloadedFileReader, type DownloadedFileRecord, type DownloadedFileToolSourceOptions, FOCUS_PAGE_TAB_TOOL, type FrameNote, type FrameScope, GENERATE_SKILL_TOOL, type GeneratedSkillDraft, type HttpDataSourceOptions, type ImageCaptureBudget, LIST_DOWNLOADED_FILES_TOOL, LIST_PAGE_TABS_TOOL, MANAGE_TODO_TOOL, type NestedFrameRef, type OpenedPageInfo, type OpenedTabSignal, PAGE_ACTION_KINDS, PAGE_ACTION_SYSTEM_PROMPT, PAGE_ACTION_TOOL, PAGE_DOCUMENT_REF, PERCEIVE_PAGE_TOOL, PERCEPTION_PAGING_DEFAULTS, PERCEPTION_SYSTEM_PROMPT, type PageActionConsent, type PageActionExecutor, type PageActionKind, type PageActionOutcome, PageActionPolicy, type PageActionPolicyOptions, type PageActionRecord, type PageActionRequest, type PageActionScope, type PageActionScopeInput, type PageActionTarget, type PageActionToolSourceOptions, type PageActionUi, type PageAuditSink, PagePerceptionPolicy, type PagePerceptionPolicyOptions, type PagePerceptionReader, type PagePerceptionToolSourceOptions, type ParentBudget, type PerceivedImage, type PerceivedNode, type PerceptionAuditSink, type PerceptionCaptureOptions, type PerceptionPagingBudget, type PerceptionRecord, type PerceptionResult, type PerceptionScope, type PerceptionScopeInput, READ_DOWNLOADED_FILE_TOOL, SKILL_GENERATION_SYSTEM_PROMPT, type SkillCandidateSink, type SkillGenerationMessages, type SkillGenerationOutcome, type SkillGenerationPolicy, type SkillGenerationToolSourceOptions, SkillGenerator, type SkillGeneratorOptions, type SkillTraceEvidence, type SkillTraceEvidenceStep, type SubAgentRunInput, type SubAgentRunner, type SubtreeRejection, TAB_WORKSET_DEFAULT_MAX, TAB_WORKSET_MAX_MAX, TAB_WORKSET_MIN_MAX, TAB_WORKSET_SYSTEM_PROMPT, TODO_SYSTEM_PROMPT, type TabAdmission, TabWorksetPolicy, type TabWorksetPolicyOptions, type TabWorksetPort, type TabWorksetToolSourceOptions, type TodoEvent, type TodoItem, type TodoList, type TodoListener, type TodoStatus, TodoStore, type TodoToolSourceOptions, type WorksetTab, type WorksetTabView, clampDownloadWaitMs, clampWorksetMax, createDelegationToolSource, createDownloadedFileToolSource, createHttpDataSourceTransport, createPageActionToolSource, createPagePerceptionToolSource, createSkillGenerationToolSource, createTabWorksetToolSource, createTodoToolSource, frameLabel, frameSteps, toActionFrameScopes, toFrameScopes, withDelegationOrigin };
|
package/dist/agent.js
CHANGED
|
@@ -3,7 +3,7 @@ import { b as parseSkillMarkdown, y as isValidSkillName } from "./skill-CAJMsLod
|
|
|
3
3
|
import { t as assertRemoteUrlAllowed } from "./urlSafety-CiSuCJvX.js";
|
|
4
4
|
import { c as formatAttachmentText, l as UNTRUSTED_LINE_LIMIT, o as XLSX_MIME, s as classifyAttachment, u as sanitizeUntrustedLine } from "./kind-DxgS8LM-.js";
|
|
5
5
|
import { o as toBase64, s as DEFAULT_MAX_DATA_SOURCE_BYTES } from "./linkedDocument-xNXF-z8n.js";
|
|
6
|
-
import { a as frameLabel, i as toFrameScopes, n as PAGE_DOCUMENT_REF, o as frameSteps, r as toActionFrameScopes, t as PAGE_ACTION_KINDS } from "./types-
|
|
6
|
+
import { a as frameLabel, i as toFrameScopes, n as PAGE_DOCUMENT_REF, o as frameSteps, r as toActionFrameScopes, t as PAGE_ACTION_KINDS } from "./types-DOJI5YC3.js";
|
|
7
7
|
|
|
8
8
|
//#region ../agent/src/todo/store.ts
|
|
9
9
|
const STATUSES = [
|
|
@@ -1274,7 +1274,7 @@ const PERCEPTION_SYSTEM_PROMPT = [
|
|
|
1274
1274
|
//#endregion
|
|
1275
1275
|
//#region ../agent/src/perception/toolSource.ts
|
|
1276
1276
|
const PERCEIVE_PAGE_TOOL = "perceive_page";
|
|
1277
|
-
const DESCRIPTION$1 = "Read the parts of the current page the host made readable, as a structured accessibility outline. Read-only: it cannot click, type, submit
|
|
1277
|
+
const DESCRIPTION$1 = "Read the parts of the current page the host made readable, as a structured accessibility outline. Read-only: it cannot click, type, submit or navigate.";
|
|
1278
1278
|
/**
|
|
1279
1279
|
* 两个参数,且它们都扩不出一寸新范围(AC-10.8 的判据由 0.14.0 分册 22 §3 修订)。
|
|
1280
1280
|
*
|
|
@@ -2000,7 +2000,7 @@ var PageActionPolicy = class {
|
|
|
2000
2000
|
const where = target.frame === void 0 ? "on the page" : `in the embedded frame "${target.frame}"`;
|
|
2001
2001
|
const scopeNote = target.elevated === true ? " This dialog is outside the usual allowlist; it was opened by this task." : "";
|
|
2002
2002
|
const scopeLabel = rememberable ? this.#options.consent?.describeScope?.(target, request.action) : void 0;
|
|
2003
|
-
const message = request.action === "back" ? `Allow the assistant to go back to the previous page${target.name === void 0 ? "" : ` on "${target.name}"`}?${scopeNote}` : `Allow the assistant to ${request.action} "${target.name ?? target.role}" ${where}?${scopeNote}`;
|
|
2003
|
+
const message = request.action === "back" ? `Allow the assistant to go back to the previous page${target.name === void 0 ? "" : ` on "${target.name}"`}?${scopeNote}` : request.action === "scroll" ? `Allow the assistant to scroll ${request.value === "up" ? "up" : "down"} the area around "${target.name ?? target.role}" ${where}?${scopeNote}` : `Allow the assistant to ${request.action} "${target.name ?? target.role}" ${where}?${scopeNote}`;
|
|
2004
2004
|
const response = await this.#options.ui.request({
|
|
2005
2005
|
type: "authorize",
|
|
2006
2006
|
id: `page-action-${this.#seq}`,
|
|
@@ -2016,7 +2016,8 @@ var PageActionPolicy = class {
|
|
|
2016
2016
|
},
|
|
2017
2017
|
...rememberable ? { rememberable: true } : {},
|
|
2018
2018
|
...scopeLabel !== void 0 ? { rememberLabel: scopeLabel } : {},
|
|
2019
|
-
...request.action === "fill" && request.value !== void 0 ? { value: target.secret === true ? "••••••" : request.value } : {}
|
|
2019
|
+
...request.action === "fill" && request.value !== void 0 ? { value: target.secret === true ? "••••••" : request.value } : {},
|
|
2020
|
+
...request.action === "scroll" ? { direction: request.value === "up" ? "up" : "down" } : {}
|
|
2020
2021
|
}
|
|
2021
2022
|
});
|
|
2022
2023
|
if (response.cancelled === true || response.value === false) return false;
|
|
@@ -2046,6 +2047,10 @@ var PageActionPolicy = class {
|
|
|
2046
2047
|
approved,
|
|
2047
2048
|
ok: outcome.ok,
|
|
2048
2049
|
...request.action === "fill" && request.value !== void 0 && !secret ? { value: request.value } : {},
|
|
2050
|
+
...request.action === "scroll" && outcome.scrolled !== void 0 ? { scrolled: {
|
|
2051
|
+
direction: request.value === "up" ? "up" : "down",
|
|
2052
|
+
...outcome.scrolled
|
|
2053
|
+
} } : {},
|
|
2049
2054
|
...outcome.reason !== void 0 ? { reason: outcome.reason } : {}
|
|
2050
2055
|
};
|
|
2051
2056
|
this.#records = [record, ...this.#records].slice(0, 50);
|
|
@@ -2093,7 +2098,8 @@ const PAGE_ACTION_SYSTEM_PROMPT = [
|
|
|
2093
2098
|
"Every action asks the user to confirm it first, so do not chain actions speculatively: act only when the user asked for something that requires it.",
|
|
2094
2099
|
"A reference expires as soon as the page is perceived again; perceive first, then act.",
|
|
2095
2100
|
"After an action, the result tells you where it led. \"openedTab\" means a new page opened — switch to it with focus_page_tab to read it. \"navigated\" means this page itself moved to a new address. \"elevatedModal\" means a dialog opened on this page. If none of the three appear, the page did not change.",
|
|
2096
|
-
"Use the \"back\" action to return to the previous page in this page's history. It takes no \"ref\" and no \"value\", and it only affects the page you are currently on. After going back, always perceive_page again: every reference from before the action is dead."
|
|
2101
|
+
"Use the \"back\" action to return to the previous page in this page's history. It takes no \"ref\" and no \"value\", and it only affects the page you are currently on. After going back, always perceive_page again: every reference from before the action is dead.",
|
|
2102
|
+
"Use the \"scroll\" action only when the page itself says there is more than you can see (for example a list that says it has 20 rows but shows 13). Pass the \"ref\" of any element inside the region you want to scroll and a \"value\" of \"down\" or \"up\"; the region is found for you, so do not look for a reference to the scrollbar or the container. The result carries \"scrolled\": when \"atEnd\" is true there is nothing further in that direction — stop scrolling and answer with what you have. Perceive the page again after each scroll: rows that left the screen no longer exist and their references are dead."
|
|
2097
2103
|
].join("\n");
|
|
2098
2104
|
|
|
2099
2105
|
//#endregion
|
|
@@ -2118,7 +2124,7 @@ const INPUT_SCHEMA = {
|
|
|
2118
2124
|
},
|
|
2119
2125
|
value: {
|
|
2120
2126
|
type: "string",
|
|
2121
|
-
description: "Text for \"fill\", the option name for \"select\",
|
|
2127
|
+
description: "Text for \"fill\", the option name for \"select\", \"true\"/\"false\" for \"set\", or \"down\"/\"up\" for \"scroll\""
|
|
2122
2128
|
}
|
|
2123
2129
|
},
|
|
2124
2130
|
required: ["action"],
|
|
@@ -2209,6 +2215,7 @@ function createPageActionToolSource(options) {
|
|
|
2209
2215
|
"select",
|
|
2210
2216
|
"set"
|
|
2211
2217
|
].includes(action) && typeof value !== "string") return toolError$2("VALIDATION_FAILED", `act_on_page needs a "value" string when the action is "${action}".`);
|
|
2218
|
+
if (action === "scroll" && value !== "down" && value !== "up") return toolError$2("VALIDATION_FAILED", "act_on_page with \"scroll\" needs a \"value\" of \"down\" or \"up\".");
|
|
2212
2219
|
return await run({
|
|
2213
2220
|
ref,
|
|
2214
2221
|
action,
|
|
@@ -2,7 +2,7 @@ import { n as messageOf, t as WebSkillError } from "./errors-BDZNpC13.js";
|
|
|
2
2
|
import { b as parseSkillMarkdown, i as buildCatalog, n as SkillDiscovery, r as SkillReader } from "./skill-CAJMsLod.js";
|
|
3
3
|
import { a as atomicWriteText, r as resolveInsideRoot, t as assertSafePathSegment } from "./pathSecurity-B1owvJAF.js";
|
|
4
4
|
import { t as assertRemoteUrlAllowed } from "./urlSafety-CiSuCJvX.js";
|
|
5
|
-
import { c as findUnpairedToolCalls, d as partsToText, f as promptText, l as interruptedToolResult, p as textParts, u as sealToolCallPairs } from "./llm-
|
|
5
|
+
import { c as findUnpairedToolCalls, d as partsToText, f as promptText, l as interruptedToolResult, p as textParts, u as sealToolCallPairs } from "./llm-eIQNO9tr.js";
|
|
6
6
|
import { a as fromBase64, c as DEFAULT_MAX_DOCUMENT_BYTES, d as TEXT_BUDGETED_CONTENT_TYPES, i as UNSUPPORTED_DOCUMENT_MESSAGE, l as DEFAULT_MAX_DOCUMENT_TEXT_BYTES, n as READ_LINKED_DOCUMENT_TOOL_NAME, o as toBase64, r as SUPPORTED_DOCUMENT_MIME, t as READ_LINKED_DOCUMENT_TOOL } from "./linkedDocument-xNXF-z8n.js";
|
|
7
7
|
import { t as mergeCatalogEntries } from "./external-_ZRQe-V9.js";
|
|
8
8
|
import { i as isArtifactCardHidden, n as extractChartSpec, r as admitArtifactMetadata, t as buildRenderResult } from "./renderResult-D9Q-Vu2x.js";
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Ct as SkillsLockfile, Et as TrustedKeyStore, H as FileStat, Mt as WebSkillError, N as ArchiveLimits, S as UiBridge, U as FileSystemProvider, _t as SkillManifest, b as RenderResultRequest, c as InteractionResponse, jt as VerifyResult, kt as UnsignedPolicy, l as LlmClient, m as LlmStreamEvent, o as InteractionPolicy, p as LlmResponse, pt as SkillInstallSource, s as InteractionRequest, u as LlmCompleteInput, v as MemoryStore } from "./types-Btpdd1y--BcxQ10Fa.js";
|
|
2
2
|
import { Kt as ScriptExecutionContext, M as DocumentSurfaceHost, R as ExternalSkillProvider, S as BridgeResponse, Un as WebSkillApi, Yn as bridgeError, ct as NetworkPolicy, gn as ToolDefinition, m as ApprovalScope, ot as LinkedDocumentReader, qt as ScriptExecutor, x as BridgeRequest, y as BridgeCapabilities, yn as ToolResult, yr as parseBridgeRequest, z as ExternalToolSource } from "./index-BDyXe-a5.js";
|
|
3
|
-
import { $ as NestedFrameRef, Ct as PagePerceptionPolicy, It as PerceptionScopeInput, Pt as PerceptionResult, Tt as PagePerceptionReader, Xt as SubtreeRejection, ft as PageActionOutcome, gt as PageActionRequest, jt as PerceptionCaptureOptions, kt as PerceivedNode, ut as PageActionExecutor, vt as PageActionScopeInput, yt as PageActionTarget } from "./index-
|
|
3
|
+
import { $ as NestedFrameRef, Ct as PagePerceptionPolicy, It as PerceptionScopeInput, Pt as PerceptionResult, Tt as PagePerceptionReader, Xt as SubtreeRejection, ft as PageActionOutcome, gt as PageActionRequest, jt as PerceptionCaptureOptions, kt as PerceivedNode, ut as PageActionExecutor, vt as PageActionScopeInput, yt as PageActionTarget } from "./index-DQ3-6GFu.js";
|
|
4
4
|
//#region ../browser/dist/index.d.ts
|
|
5
5
|
//#region src/fs/featureDetection.d.ts
|
|
6
6
|
/** 检测当前环境是否可用 OPFS(navigator.storage.getDirectory) */
|
|
@@ -583,6 +583,14 @@ interface DomPageActionOptions {
|
|
|
583
583
|
* 其余动作不用它——它们的文档从元素自带的 `ownerDocument` 取,跨帧时才不会拿错。
|
|
584
584
|
*/
|
|
585
585
|
document?: Document;
|
|
586
|
+
/**
|
|
587
|
+
* 滚动后等待页面稳定的上限(毫秒,0.18.0 FR-10.6)。
|
|
588
|
+
* SDK 夹在 `SCROLL_SETTLE_BOUNDS` 之间;不注入即用缺省值。
|
|
589
|
+
*
|
|
590
|
+
* **模型无法影响它**:这是装配期参数,工具入参里没有任何相关字段。
|
|
591
|
+
* 重 ERP 的首屏渲染可能超过缺省上限,宿主据此上调。
|
|
592
|
+
*/
|
|
593
|
+
scrollSettleMs?: () => number | undefined;
|
|
586
594
|
}
|
|
587
595
|
/**
|
|
588
596
|
* @experimental
|
package/dist/browser.js
CHANGED
|
@@ -2,11 +2,11 @@ import { n as messageOf, t as WebSkillError } from "./errors-BDZNpC13.js";
|
|
|
2
2
|
import { A as SKILL_MANIFEST_FILE, D as verifySkillSignature, M as buildManifest, O as MANIFEST_EXCLUDED_FILES, P as verifyManifest, b as parseSkillMarkdown, c as unzipWithLimits, f as SKILL_PACK_FILE, i as buildCatalog, k as SKILLS_LOCKFILE, m as parseSkillPackManifest, n as SkillDiscovery, o as readResponseWithLimit, p as exportSkills, t as validateSkills, u as detectSkillArchiveShapeFromFs, w as readSkillSignature, y as isValidSkillName } from "./skill-CAJMsLod.js";
|
|
3
3
|
import { a as atomicWriteText, o as isAtomicTempPath, r as resolveInsideRoot } from "./pathSecurity-B1owvJAF.js";
|
|
4
4
|
import { t as assertRemoteUrlAllowed } from "./urlSafety-CiSuCJvX.js";
|
|
5
|
-
import { a as networkPolicyLibSource, c as bridgeError, d as FsMemoryStore, g as FsRunSnapshotStore, l as parseBridgeRequest, nt as ProgressiveRouter, p as AgentLoop, r as normalizeToolError, s as UPLOAD_FILES_UNAVAILABLE, t as CapabilityApproval, u as FsArtifactStore } from "./approval-
|
|
6
|
-
import { a as GoogleGenAiClient, o as AnthropicClient, s as OpenAiCompatibleClient, t as MockLlmClient } from "./llm-
|
|
5
|
+
import { a as networkPolicyLibSource, c as bridgeError, d as FsMemoryStore, g as FsRunSnapshotStore, l as parseBridgeRequest, nt as ProgressiveRouter, p as AgentLoop, r as normalizeToolError, s as UPLOAD_FILES_UNAVAILABLE, t as CapabilityApproval, u as FsArtifactStore } from "./approval-B7GW86u2.js";
|
|
6
|
+
import { a as GoogleGenAiClient, o as AnthropicClient, s as OpenAiCompatibleClient, t as MockLlmClient } from "./llm-eIQNO9tr.js";
|
|
7
7
|
import { n as normalizeToolContent, t as mergeCatalogEntries } from "./external-_ZRQe-V9.js";
|
|
8
|
-
import { t as createWebSkillApi } from "./webSkillApi-
|
|
9
|
-
import { a as frameLabel, i as toFrameScopes, o as frameSteps, r as toActionFrameScopes } from "./types-
|
|
8
|
+
import { t as createWebSkillApi } from "./webSkillApi-DMENIqW0.js";
|
|
9
|
+
import { a as frameLabel, i as toFrameScopes, o as frameSteps, r as toActionFrameScopes } from "./types-DOJI5YC3.js";
|
|
10
10
|
|
|
11
11
|
//#region ../browser/src/fs/featureDetection.ts
|
|
12
12
|
/** 检测当前环境是否可用 OPFS(navigator.storage.getDirectory) */
|
|
@@ -3198,6 +3198,31 @@ function documentKey(view) {
|
|
|
3198
3198
|
//#endregion
|
|
3199
3199
|
//#region ../browser/src/dom/pageAction.ts
|
|
3200
3200
|
const FILLABLE_TAGS = /* @__PURE__ */ new Set(["INPUT", "TEXTAREA"]);
|
|
3201
|
+
/**
|
|
3202
|
+
* 滚动稳定化的等待边界(毫秒);宿主注入值被夹在这之间。
|
|
3203
|
+
* 刻意**不导出**:本册只登记了一处新增公开契约(`scrollSettleMs`),
|
|
3204
|
+
* 多导出一个常量就是多一处要维护的公开面,而宿主注入超界值本来就会被夹住。
|
|
3205
|
+
*/
|
|
3206
|
+
const SCROLL_SETTLE_BOUNDS = {
|
|
3207
|
+
min: 300,
|
|
3208
|
+
max: 5e3,
|
|
3209
|
+
default: 800
|
|
3210
|
+
};
|
|
3211
|
+
/**
|
|
3212
|
+
* 滚动后等待渲染的两个时长。
|
|
3213
|
+
*
|
|
3214
|
+
* 只有「静默窗口」是不够的,而且这里的顺序容易搞反:虚拟列表在 `scroll` 事件后要经过
|
|
3215
|
+
* 一次 rAF、甚至一段节流才**开始**重渲染,那之前观察器一直是静默的。
|
|
3216
|
+
* 若把「一直没动静」直接判成「渲染完了」,就会在渲染开始之前返回,读到滚动前的旧行——
|
|
3217
|
+
* 而且页面越慢越容易中招,正好是最需要滚动的那类页面。
|
|
3218
|
+
*
|
|
3219
|
+
* 所以两段分开:**还没见过任何变更**时按「等首次变更」的宽限期算,
|
|
3220
|
+
* 见过之后才按静默窗口算。宽限期取 250ms 是为了盖住常见的 100ms 节流加一帧渲染。
|
|
3221
|
+
*/
|
|
3222
|
+
const SCROLL_SETTLE_FIRST_CHANGE_MS = 250;
|
|
3223
|
+
const SCROLL_SETTLE_QUIET_MS = 80;
|
|
3224
|
+
/** 两屏之间的重叠身位(像素)。必须大于 0,否则横跨视口边界的那一行会在两次感知之间消失 */
|
|
3225
|
+
const SCROLL_OVERLAP_PX = 64;
|
|
3201
3226
|
/** 只看显式声明,不看尺寸:jsdom 有 getComputedStyle 但没有布局 */
|
|
3202
3227
|
function hidden(element) {
|
|
3203
3228
|
if (element.hasAttribute("hidden")) return true;
|
|
@@ -3445,6 +3470,75 @@ function attachFiles(input, files) {
|
|
|
3445
3470
|
input.dispatchEvent(new Event("input", { bubbles: true }));
|
|
3446
3471
|
input.dispatchEvent(new Event("change", { bubbles: true }));
|
|
3447
3472
|
}
|
|
3473
|
+
const scrolls = (overflow) => overflow === "auto" || overflow === "scroll" || overflow === "overlay";
|
|
3474
|
+
/**
|
|
3475
|
+
* 滚动落点(FR-10.3):从被指认元素**自身**起沿祖先链上溯,取第一个真正能滚的容器。
|
|
3476
|
+
*
|
|
3477
|
+
* 判据是两个条件的**合取**,第二个不能省:现代布局里 `overflow-y: auto` 的祖先
|
|
3478
|
+
* 常有好几层(卡片、面板、栅格),其中绝大多数内容并没有溢出。只看 overflow 会命中
|
|
3479
|
+
* 最近的那个 `auto`,往它的 `scrollTop` 写值没有任何效果——表现是操作报成功、
|
|
3480
|
+
* 页面没动、也没有新行,即向模型报了一次假成功。
|
|
3481
|
+
*
|
|
3482
|
+
* 判据里不含任何组件库特征(class 名、data 属性、组件实例):这是「通用」二字的判据。
|
|
3483
|
+
*
|
|
3484
|
+
* 根滚动容器单独兜底而不是靠链上命中:`documentElement` 的 `overflow-y` 计算值
|
|
3485
|
+
* 通常是 `visible`(滚动被传播到视口),不会被上面的判据命中,但文档确实可滚。
|
|
3486
|
+
* 顺序必须是先链后兜底——嵌套场景下先命中的必须是内层列表。
|
|
3487
|
+
*/
|
|
3488
|
+
function scrollTargetOf(element) {
|
|
3489
|
+
const doc = element.ownerDocument;
|
|
3490
|
+
const view = doc.defaultView;
|
|
3491
|
+
if (view === null) return void 0;
|
|
3492
|
+
for (let node = element; node !== null; node = node.parentElement) {
|
|
3493
|
+
const style = view.getComputedStyle(node);
|
|
3494
|
+
if (scrolls(style.overflowY) && node.scrollHeight > node.clientHeight) return {
|
|
3495
|
+
container: node,
|
|
3496
|
+
isRoot: false
|
|
3497
|
+
};
|
|
3498
|
+
}
|
|
3499
|
+
const root = doc.scrollingElement ?? doc.documentElement;
|
|
3500
|
+
if (root !== null && root.scrollHeight > root.clientHeight) return {
|
|
3501
|
+
container: root,
|
|
3502
|
+
isRoot: true
|
|
3503
|
+
};
|
|
3504
|
+
}
|
|
3505
|
+
function clampScrollSettleMs(value) {
|
|
3506
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return SCROLL_SETTLE_BOUNDS.default;
|
|
3507
|
+
return Math.min(Math.max(Math.round(value), SCROLL_SETTLE_BOUNDS.min), SCROLL_SETTLE_BOUNDS.max);
|
|
3508
|
+
}
|
|
3509
|
+
/**
|
|
3510
|
+
* 等落点容器的子树安静下来(FR-10.6)。
|
|
3511
|
+
*
|
|
3512
|
+
* 观察器必须在**写 `scrollTop` 之前**挂上:写值到第一次变更之间不能有空档,
|
|
3513
|
+
* 否则渲染快的页面会在挂上观察器之前就完成变更,然后被静默窗口判成「没动静」。
|
|
3514
|
+
*
|
|
3515
|
+
* 只观察落点子树,不观察整个文档:ERP 页面上到处是无关的轮询与徽标刷新,
|
|
3516
|
+
* 观察全文档等于永远等不到静默。
|
|
3517
|
+
*/
|
|
3518
|
+
function watchQuiescence(container) {
|
|
3519
|
+
const Observer = container.ownerDocument.defaultView?.MutationObserver;
|
|
3520
|
+
let lastChange;
|
|
3521
|
+
const observer = Observer === void 0 ? void 0 : new Observer(() => lastChange = Date.now());
|
|
3522
|
+
observer?.observe(container, {
|
|
3523
|
+
childList: true,
|
|
3524
|
+
subtree: true
|
|
3525
|
+
});
|
|
3526
|
+
return { settle: async (budgetMs) => {
|
|
3527
|
+
const started = Date.now();
|
|
3528
|
+
try {
|
|
3529
|
+
for (;;) {
|
|
3530
|
+
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
3531
|
+
const now = Date.now();
|
|
3532
|
+
if (now - started >= budgetMs) return;
|
|
3533
|
+
if (lastChange === void 0) {
|
|
3534
|
+
if (now - started >= SCROLL_SETTLE_FIRST_CHANGE_MS) return;
|
|
3535
|
+
} else if (now - lastChange >= SCROLL_SETTLE_QUIET_MS) return;
|
|
3536
|
+
}
|
|
3537
|
+
} finally {
|
|
3538
|
+
observer?.disconnect();
|
|
3539
|
+
}
|
|
3540
|
+
} };
|
|
3541
|
+
}
|
|
3448
3542
|
/** @experimental */
|
|
3449
3543
|
function createDomPageActionExecutor(options) {
|
|
3450
3544
|
const { reader } = options;
|
|
@@ -3501,6 +3595,40 @@ function createDomPageActionExecutor(options) {
|
|
|
3501
3595
|
documentUrl: view.location.href
|
|
3502
3596
|
};
|
|
3503
3597
|
};
|
|
3598
|
+
/**
|
|
3599
|
+
* 滚动一屏(0.18.0 分册 10)。
|
|
3600
|
+
*
|
|
3601
|
+
* 不走 `done()`:滚动不会导航、也不会打开模态,套那段等待只是白等一个预算。
|
|
3602
|
+
* 稳定化是滚动自己的收尾,见 `watchQuiescence`。
|
|
3603
|
+
*/
|
|
3604
|
+
const scrollRegion = async (element, target, direction) => {
|
|
3605
|
+
const found = scrollTargetOf(element);
|
|
3606
|
+
if (found === void 0) return {
|
|
3607
|
+
ok: false,
|
|
3608
|
+
target,
|
|
3609
|
+
reason: "This area cannot be scrolled: nothing around this element has a scrollable region."
|
|
3610
|
+
};
|
|
3611
|
+
const { container, isRoot } = found;
|
|
3612
|
+
if (!isRoot && !reader.inActionScope(container)) return {
|
|
3613
|
+
ok: false,
|
|
3614
|
+
target,
|
|
3615
|
+
reason: "The scrollable region around this element is outside the actionable scope."
|
|
3616
|
+
};
|
|
3617
|
+
const step = Math.max(container.clientHeight - SCROLL_OVERLAP_PX, Math.round(container.clientHeight / 2), 1);
|
|
3618
|
+
const before = container.scrollTop;
|
|
3619
|
+
const watch = watchQuiescence(container);
|
|
3620
|
+
container.scrollTop = direction === "down" ? before + step : before - step;
|
|
3621
|
+
await watch.settle(clampScrollSettleMs(options.scrollSettleMs?.()));
|
|
3622
|
+
const after = container.scrollTop;
|
|
3623
|
+
return {
|
|
3624
|
+
ok: true,
|
|
3625
|
+
target,
|
|
3626
|
+
scrolled: {
|
|
3627
|
+
atEnd: direction === "down" ? after >= container.scrollHeight - container.clientHeight - 1 : after <= 0,
|
|
3628
|
+
movedBy: Math.abs(after - before)
|
|
3629
|
+
}
|
|
3630
|
+
};
|
|
3631
|
+
};
|
|
3504
3632
|
const execute = async (request) => {
|
|
3505
3633
|
if (request.action === "back") return await goBack();
|
|
3506
3634
|
const element = reader.resolve(request.ref);
|
|
@@ -3571,6 +3699,10 @@ function createDomPageActionExecutor(options) {
|
|
|
3571
3699
|
};
|
|
3572
3700
|
}
|
|
3573
3701
|
if (request.action === "set") return await done(setToggle(element, request.value ?? "", target));
|
|
3702
|
+
if (request.action === "scroll") {
|
|
3703
|
+
if (request.value !== "down" && request.value !== "up") return fail("Use \"down\" or \"up\".");
|
|
3704
|
+
return await scrollRegion(element, target, request.value);
|
|
3705
|
+
}
|
|
3574
3706
|
if (request.action === "attach") {
|
|
3575
3707
|
const files = await options.pickFiles?.();
|
|
3576
3708
|
if (files === void 0 || files.length === 0) return {
|
package/dist/governance.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as messageOf, t as WebSkillError } from "./errors-BDZNpC13.js";
|
|
2
2
|
import { y as isValidSkillName } from "./skill-CAJMsLod.js";
|
|
3
3
|
import { a as atomicWriteText, t as assertSafePathSegment } from "./pathSecurity-B1owvJAF.js";
|
|
4
|
-
import { d as partsToText, p as textParts } from "./llm-
|
|
4
|
+
import { d as partsToText, p as textParts } from "./llm-eIQNO9tr.js";
|
|
5
5
|
import { n as AUDIT_EVENT_TYPE_LIST, t as AUDIT_EVENT_TYPES } from "./eventTypes-CwciaqCU.js";
|
|
6
6
|
|
|
7
7
|
//#region ../governance/src/candidate/candidateNormalizer.ts
|
|
@@ -1119,15 +1119,15 @@ type PageActionScopeInput = PageActionScope | {
|
|
|
1119
1119
|
*/
|
|
1120
1120
|
declare function toActionFrameScopes(scope: PageActionScopeInput): readonly ActionFrameScope[];
|
|
1121
1121
|
/**
|
|
1122
|
-
* 本版的操作集(FR-25.1 / 0.16.0 FR-13.6
|
|
1122
|
+
* 本版的操作集(FR-25.1 / 0.16.0 FR-13.6 / 0.18.0 FR-10.1)。拖拽仍不在内(D64);
|
|
1123
1123
|
* 导航只有 `back` 一个,且它**不接受地址**——可达面被浏览器历史封死(SC-1)。
|
|
1124
1124
|
*
|
|
1125
|
-
* `select`/`set`/`attach`
|
|
1125
|
+
* `select`/`set`/`attach`/`scroll` 与既有几个走**同一条** policy 路径,
|
|
1126
1126
|
* 范围白名单、逐次确认、审计三条硬约束因此天然覆盖到它们——
|
|
1127
|
-
* 前提是新动作不绕过 policy
|
|
1127
|
+
* 前提是新动作不绕过 policy 直调执行器(AC-25.4 守这一点)。
|
|
1128
1128
|
* @experimental
|
|
1129
1129
|
*/
|
|
1130
|
-
declare const PAGE_ACTION_KINDS: readonly ["click", "fill", "submit", "select", "set", "attach", "back"];
|
|
1130
|
+
declare const PAGE_ACTION_KINDS: readonly ["click", "fill", "submit", "select", "set", "attach", "scroll", "back"];
|
|
1131
1131
|
type PageActionKind = (typeof PAGE_ACTION_KINDS)[number];
|
|
1132
1132
|
/**
|
|
1133
1133
|
* `back` 的目标占位(0.16.0 分册 13 §4.1)。
|
|
@@ -1145,8 +1145,8 @@ interface PageActionRequest {
|
|
|
1145
1145
|
action: PageActionKind;
|
|
1146
1146
|
/**
|
|
1147
1147
|
* `fill` 填入的文本;`select` 要选中的选项可访问名;
|
|
1148
|
-
* `set` 的目标态(`'true'` | `'false'
|
|
1149
|
-
*
|
|
1148
|
+
* `set` 的目标态(`'true'` | `'false'`);`scroll` 的方向(`'down'` | `'up'`)。
|
|
1149
|
+
* `attach` 不用它——文件**始终由用户在确认卡里选**,Agent 传不进本地路径(FR-25.5)。
|
|
1150
1150
|
*/
|
|
1151
1151
|
value?: string;
|
|
1152
1152
|
}
|
|
@@ -1197,6 +1197,17 @@ interface PageActionOutcome {
|
|
|
1197
1197
|
* 带 `admitted: false` 即开出来了但没接进来(例如工作集触顶)。
|
|
1198
1198
|
*/
|
|
1199
1199
|
openedTab?: OpenedTabSignal;
|
|
1200
|
+
/**
|
|
1201
|
+
* 本次滚动的位移与边界状态(0.18.0 分册 10 · FR-10.7)。
|
|
1202
|
+
* 非 `scroll` 动作**不带**该字段,与 `navigated` 同口径。
|
|
1203
|
+
*
|
|
1204
|
+
* 两个值都在**稳定化之后**回读:虚拟列表加载新行会改变 `scrollHeight`,
|
|
1205
|
+
* 用滚动前的值算 `atEnd` 会提前报到底,模型于是停在半路。
|
|
1206
|
+
*/
|
|
1207
|
+
scrolled?: {
|
|
1208
|
+
atEnd: boolean;
|
|
1209
|
+
movedBy: number;
|
|
1210
|
+
};
|
|
1200
1211
|
/** 失败原因(英文) */
|
|
1201
1212
|
reason?: string;
|
|
1202
1213
|
}
|
|
@@ -1247,6 +1258,16 @@ interface PageActionRecord {
|
|
|
1247
1258
|
noop?: boolean;
|
|
1248
1259
|
/** 非密码类控件填入的值;密码类控件**整个字段不存在** */
|
|
1249
1260
|
value?: string;
|
|
1261
|
+
/**
|
|
1262
|
+
* 本次滚动的方向与实际位移(0.18.0 FR-10.8);非 `scroll` 动作不带。
|
|
1263
|
+
* 位移要进留痕:只记「滚了」而不记「滚了多少」,事后分不出
|
|
1264
|
+
* 「滚到底了」与「根本没滚动」。
|
|
1265
|
+
*/
|
|
1266
|
+
scrolled?: {
|
|
1267
|
+
direction: 'down' | 'up';
|
|
1268
|
+
movedBy: number;
|
|
1269
|
+
atEnd: boolean;
|
|
1270
|
+
};
|
|
1250
1271
|
reason?: string;
|
|
1251
1272
|
}
|
|
1252
1273
|
//#endregion
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,6 @@ import { $ as IntegrityVerdict, $n as diffUserProfile, $t as SessionMeta, A as D
|
|
|
6
6
|
* Version of the published `@webskill/sdk` package, injected at build time.
|
|
7
7
|
* @stable
|
|
8
8
|
*/
|
|
9
|
-
declare const SDK_VERSION = "0.
|
|
9
|
+
declare const SDK_VERSION = "0.18.0";
|
|
10
10
|
//#endregion
|
|
11
11
|
export { ALLOWED_TOOLS_EXCLUSION_REASON, ASK_USER_FIELD_TYPES, ASK_USER_INPUT_SCHEMA, ASK_USER_MAX_FIELDS, ASK_USER_TOOL, ASK_USER_TOOL_NAME, ATOMIC_TMP_SUFFIX_PATTERN, ATTACHMENT_TEXT_LIMIT, type ActivateLifecycleData, AgentLoop, type AgentLoopConfig, type AgentLoopDeps, AnthropicClient, type AnthropicClientConfig, type ApprovalDecision, type ApprovalScope, type ArchiveLimits, type Artifact, type ArtifactStore, type AttachmentTextInput, BEHAVIOR_RECORDS_KEY, type BehaviorRecord, type BehaviorRecordKind, type BehaviorScene, type BridgeCapabilities, type BridgeCapability, type BridgeRequest, type BridgeResponse, CapabilityApproval, type CapabilityMode, type CatalogRenderer, type ChartSpec, type ChatAttachmentKind, type CryptoKeyLike, DEFAULT_ARCHIVE_LIMITS, DEFAULT_LOOP_LIMITS, DEFAULT_MAX_DATA_SOURCE_BYTES, DEFAULT_MAX_DOCUMENT_BYTES, DEFAULT_MAX_DOCUMENT_TEXT_BYTES, DEFAULT_MAX_UPLOAD_FILE_BYTES, DEFAULT_USER_PROFILE_LIMITS, DOCX_MIME, type DataSourceInfo, type DiscoveryResult, type DocumentSurfaceHost, type DocumentSurfacePort, type DocxTextExtractor, EMPTY_USER_PROFILE, EventBus, type ExecuteLifecycleData, type ExternalSkillProvider, type ExternalToolSource, FILE_MIME_TYPES, FS_SESSION_PAGE_SIZE, type FileStat, type FileSystemProvider, type FormField, FsArtifactStore, FsMemoryStore, FsRunSnapshotStore, FsRunTraceStore, FsSessionStore, FsToolStepStore, FsTrustedKeyStore, FullDisclosureRouter, GoogleGenAiClient, type GoogleGenAiClientConfig, HookRunner, type HookRunnerOptions, IMAGE_MIME_TYPES, type InstalledSkillManifest, type IntegrityVerdict, type InteractLifecycleData, type InteractionOrigin, type InteractionPolicy, type InteractionRequest, type InteractionResponse, type JsonSchema, type LifecycleEvent, type LifecycleEventInit, type LifecycleHook, type LifecycleHookContext, type LifecycleListener, type LinkedDocumentReader, type LlmClient, type LlmCompleteInput, type LlmContentPart, type LlmMessage, type LlmResponse, type LlmStreamEvent, type LlmTokenUsage, type LlmToolCall, type LlmToolSpec, MANIFEST_EXCLUDED_FILES, MAX_TOOL_STEP_ARG_BYTES, MemoryFS, type MemoryStore, type NetworkPolicy, OpenAiCompatibleClient, type OpenAiCompatibleClientConfig, type Page, type PageQuery, type PdfTextExtractor, ProgressiveRouter, READ_LINKED_DOCUMENT_TOOL, READ_LINKED_DOCUMENT_TOOL_NAME, READ_SKILL_FILE_INPUT_SCHEMA, READ_SKILL_FILE_TOOL, READ_SKILL_FILE_TOOL_NAME, RUN_SNAPSHOT_SCHEMA_VERSION, RUN_TRACE_SCHEMA_VERSION, type RedactedArgs, type RefineUserProfileInput, type RemoteUrlPolicy, type RenderBlock, type RenderResultRequest, type RouteLifecycleData, type RouteResult, type RunLimitErrorDetails, type RunResult, type RunSnapshot, type RunSnapshotListEntry, type RunSnapshotStore, type RunTerminationReason, type RunToolCall, type RunTraceFile, type RunTraceFilter, type RunTraceMetrics, type RunTraceStore, type RunTraceSummary, type RunUploadFiles, type RunUsageSummary, type RuntimePhase, type RuntimeRun, type RuntimeSession, type RuntimeSessionHandle, SDK_VERSION, SENSITIVE_ANNOTATION, SESSION_SCHEMA_VERSION, SIGNATURE_SCHEMA_VERSION, SKILLS_LOCKFILE, SKILL_MANIFEST_FILE, SKILL_NAME_MAX_LENGTH, SKILL_NAME_PATTERN, SKILL_PACK_FILE, SKILL_SIGNATURE_FILE, SUPPORTED_DOCUMENT_MIME, type SchemaInferer, type ScriptExecutionContext, type ScriptExecutor, type SealOptions, type SealRecord, type SealResult, SerializingMemoryStore, type SessionListPage, type SessionMeta, type SessionRecord, type SessionStore, type SignatureAuditSink, type SignatureVerdict, type SkillArchiveDetection, type SkillArchiveShape, type SkillCandidateMarker, type SkillCatalog, type SkillCatalogEntry, SkillDiscovery, type SkillDocument, type SkillFailureReport, type SkillInstallSource, type SkillIntegrityGuard, type SkillIssue, type SkillLocation, type SkillManagerPort, type SkillManifest, type SkillMetadata, type SkillOutcomeReporter, type SkillPackManifest, SkillReader, type SkillRouter, type SkillScriptDescriptor, type SkillScriptSchemaSource, type SkillSignature, type SkillSource, type SkillStateGuard, type SkillSuccessReport, type SkillsLockfile, TEXT_BUDGETED_CONTENT_TYPES, TEXT_EXTENSIONS, type TerminalLifecycleData, type TextualToolContent, type TodoTraceEvent, type ToolCallContext, type ToolContent, type ToolDefinition, type ToolDisclosure, type ToolResolution, type ToolResult, type ToolStepReader, type ToolStepRecord, type ToolStepStore, type ToolStepTrust, type TraceClock, type TraceEvent, type TraceEventType, TraceRecorder, type TrustedKey, type TrustedKeyStore, UNSUPPORTED_DOCUMENT_MESSAGE, UNTRUSTED_LINE_LIMIT, UPLOAD_FILES_UNAVAILABLE, USER_PROFILE_EXPORT_VERSION, USER_PROFILE_KEY, USER_PROFILE_NO_INVENTION_RULE, USER_PROFILE_PROMPT_HEADER, USER_PROFILE_REFINE_PROMPT, type UiBridge, type UiSpecActionCapability, type UiSpecDrafts, type UiSpecEvent, type UiSpecNode, type UiSpecPatch, type UiSpecSnapshot, type UiSurfaceActionRequest, type UiSurfaceActionResponse, type UnsignedPolicy, type UnsupportedRunSnapshot, type UploadFileInfo, type UserProfile, type UserProfileEntry, type UserProfileExport, type UserProfileImportDiff, type UserProfileLimits, type ValidationReport, type VercelToolSpec, type VerifyResult, type WebSkillApi, WebSkillError, type WebSkillErrorCode, WebSkillRuntime, type WebSkillRuntimeDeps, XLSX_MIME, type XlsxTextExtractor, appendBehaviorRecords, applyUserProfileImport, assertRemoteUrlAllowed, assertSafePathSegment, atomicWriteText, bridgeError, buildCatalog, buildManifest, buildRenderResult, checkDependencyCycles, checkSkillRules, classifyAttachment, computeDigest, createScriptContext, createWebSkillApi, detectSkillArchiveShape, detectSkillArchiveShapeFromFs, diffUserProfile, escapeXml, exportSkills, exportUserProfile, extractChartSpec, extractSkillCandidate, extractTodoTraceEvents, extractUiSpecEvents, findUnpairedToolCalls, formatAttachmentText, formatSkillScriptManifest, fromVercelResult, fromVercelStreamPart, interruptedToolResult, isAtomicTempPath, isNetworkAllowed, isUnsupportedRunSnapshot, isValidSkillName, jsonRenderer, keyIdOf, listSkillScripts, mergeCatalogEntries, mergeProfileEntries, messageOf, networkPolicyLibSource, networkUrlHost, normalizeErrorCode, normalizePath, normalizeToolContent, normalizeToolError, parseBridgeRequest, parseSkillMarkdown, parseSkillPackManifest, parseUserProfileExport, partsToText, readBehaviorRecords, readProfileEntries, readResponseWithLimit, readSkillSignature, readUserProfile, redactToolStepArgs, refineUserProfile, renderAvailableSkillsXml, renderCatalogJson, renderUserProfileContext, resolveArchiveLimits, resolveInsideRoot, resolveToolName, sampleBehaviorRecords, sanitizeUntrustedLine, schemaSourceLabel, schemaToForm, scriptToolName, sealToolCallPairs, signSkill, signaturePayloadBytes, stripArchiveRoot, summarizeRunUsage, summarizeToolCalls, textParts, toBase64, toLlmToolSpec, toRecordDigests, toVercelToolSpecs, unzipWithLimits, validateSkills, validateUiSpecEvent, validateUiSpecNode, verifyManifest, verifySkillSignature, xmlRenderer };
|
package/dist/index.js
CHANGED
|
@@ -3,13 +3,13 @@ import { A as SKILL_MANIFEST_FILE, C as keyIdOf, D as verifySkillSignature, E as
|
|
|
3
3
|
import { a as atomicWriteText, i as ATOMIC_TMP_SUFFIX_PATTERN, n as normalizePath, o as isAtomicTempPath, r as resolveInsideRoot, t as assertSafePathSegment } from "./pathSecurity-B1owvJAF.js";
|
|
4
4
|
import { t as assertRemoteUrlAllowed } from "./urlSafety-CiSuCJvX.js";
|
|
5
5
|
import { a as TEXT_EXTENSIONS, c as formatAttachmentText, i as IMAGE_MIME_TYPES, l as UNTRUSTED_LINE_LIMIT, n as DOCX_MIME, o as XLSX_MIME, r as FILE_MIME_TYPES, s as classifyAttachment, t as ATTACHMENT_TEXT_LIMIT, u as sanitizeUntrustedLine } from "./kind-DxgS8LM-.js";
|
|
6
|
-
import { $ as scriptToolName, A as readUserProfile, B as createScriptContext, C as TraceRecorder, D as mergeProfileEntries, E as appendBehaviorRecords, F as DEFAULT_USER_PROFILE_LIMITS, G as ASK_USER_TOOL_NAME, H as ASK_USER_INPUT_SCHEMA, I as EMPTY_USER_PROFILE, J as READ_SKILL_FILE_TOOL_NAME, K as READ_SKILL_FILE_INPUT_SCHEMA, L as SerializingMemoryStore, M as USER_PROFILE_NO_INVENTION_RULE, N as USER_PROFILE_PROMPT_HEADER, O as readBehaviorRecords, P as renderUserProfileContext, Q as schemaSourceLabel, R as EventBus, S as extractTodoTraceEvents, T as USER_PROFILE_KEY, U as ASK_USER_MAX_FIELDS, V as ASK_USER_FIELD_TYPES, W as ASK_USER_TOOL, X as formatSkillScriptManifest, Y as ALLOWED_TOOLS_EXCLUSION_REASON, Z as listSkillScripts, _ as RUN_SNAPSHOT_SCHEMA_VERSION, a as networkPolicyLibSource, at as xmlRenderer, b as MAX_TOOL_STEP_ARG_BYTES, c as bridgeError, d as FsMemoryStore, et as resolveToolName, f as WebSkillRuntime, g as FsRunSnapshotStore, h as redactToolStepArgs, i as isNetworkAllowed, it as renderAvailableSkillsXml, j as sampleBehaviorRecords, k as readProfileEntries, l as parseBridgeRequest, m as SENSITIVE_ANNOTATION, n as normalizeErrorCode, nt as ProgressiveRouter, o as networkUrlHost, p as AgentLoop, q as READ_SKILL_FILE_TOOL, r as normalizeToolError, rt as escapeXml, s as UPLOAD_FILES_UNAVAILABLE, t as CapabilityApproval, tt as toLlmToolSpec, u as FsArtifactStore, v as isUnsupportedRunSnapshot, w as BEHAVIOR_RECORDS_KEY, x as extractSkillCandidate, y as DEFAULT_LOOP_LIMITS, z as schemaToForm } from "./approval-
|
|
7
|
-
import { a as GoogleGenAiClient, c as findUnpairedToolCalls, d as partsToText, f as promptText, i as toVercelToolSpecs, l as interruptedToolResult, n as fromVercelResult, o as AnthropicClient, p as textParts, r as fromVercelStreamPart, s as OpenAiCompatibleClient, u as sealToolCallPairs } from "./llm-
|
|
6
|
+
import { $ as scriptToolName, A as readUserProfile, B as createScriptContext, C as TraceRecorder, D as mergeProfileEntries, E as appendBehaviorRecords, F as DEFAULT_USER_PROFILE_LIMITS, G as ASK_USER_TOOL_NAME, H as ASK_USER_INPUT_SCHEMA, I as EMPTY_USER_PROFILE, J as READ_SKILL_FILE_TOOL_NAME, K as READ_SKILL_FILE_INPUT_SCHEMA, L as SerializingMemoryStore, M as USER_PROFILE_NO_INVENTION_RULE, N as USER_PROFILE_PROMPT_HEADER, O as readBehaviorRecords, P as renderUserProfileContext, Q as schemaSourceLabel, R as EventBus, S as extractTodoTraceEvents, T as USER_PROFILE_KEY, U as ASK_USER_MAX_FIELDS, V as ASK_USER_FIELD_TYPES, W as ASK_USER_TOOL, X as formatSkillScriptManifest, Y as ALLOWED_TOOLS_EXCLUSION_REASON, Z as listSkillScripts, _ as RUN_SNAPSHOT_SCHEMA_VERSION, a as networkPolicyLibSource, at as xmlRenderer, b as MAX_TOOL_STEP_ARG_BYTES, c as bridgeError, d as FsMemoryStore, et as resolveToolName, f as WebSkillRuntime, g as FsRunSnapshotStore, h as redactToolStepArgs, i as isNetworkAllowed, it as renderAvailableSkillsXml, j as sampleBehaviorRecords, k as readProfileEntries, l as parseBridgeRequest, m as SENSITIVE_ANNOTATION, n as normalizeErrorCode, nt as ProgressiveRouter, o as networkUrlHost, p as AgentLoop, q as READ_SKILL_FILE_TOOL, r as normalizeToolError, rt as escapeXml, s as UPLOAD_FILES_UNAVAILABLE, t as CapabilityApproval, tt as toLlmToolSpec, u as FsArtifactStore, v as isUnsupportedRunSnapshot, w as BEHAVIOR_RECORDS_KEY, x as extractSkillCandidate, y as DEFAULT_LOOP_LIMITS, z as schemaToForm } from "./approval-B7GW86u2.js";
|
|
7
|
+
import { a as GoogleGenAiClient, c as findUnpairedToolCalls, d as partsToText, f as promptText, i as toVercelToolSpecs, l as interruptedToolResult, n as fromVercelResult, o as AnthropicClient, p as textParts, r as fromVercelStreamPart, s as OpenAiCompatibleClient, u as sealToolCallPairs } from "./llm-eIQNO9tr.js";
|
|
8
8
|
import { c as DEFAULT_MAX_DOCUMENT_BYTES, d as TEXT_BUDGETED_CONTENT_TYPES, i as UNSUPPORTED_DOCUMENT_MESSAGE, l as DEFAULT_MAX_DOCUMENT_TEXT_BYTES, n as READ_LINKED_DOCUMENT_TOOL_NAME, o as toBase64, r as SUPPORTED_DOCUMENT_MIME, s as DEFAULT_MAX_DATA_SOURCE_BYTES, t as READ_LINKED_DOCUMENT_TOOL, u as DEFAULT_MAX_UPLOAD_FILE_BYTES } from "./linkedDocument-xNXF-z8n.js";
|
|
9
9
|
import { n as normalizeToolContent, t as mergeCatalogEntries } from "./external-_ZRQe-V9.js";
|
|
10
10
|
import { n as extractChartSpec, t as buildRenderResult } from "./renderResult-D9Q-Vu2x.js";
|
|
11
11
|
import { n as validateUiSpecEvent, r as validateUiSpecNode, t as extractUiSpecEvents } from "./surface-DVGiCmwq.js";
|
|
12
|
-
import { t as createWebSkillApi } from "./webSkillApi-
|
|
12
|
+
import { t as createWebSkillApi } from "./webSkillApi-DMENIqW0.js";
|
|
13
13
|
|
|
14
14
|
//#region ../core/src/fs/memoryFs.ts
|
|
15
15
|
const ROOT = "/";
|
|
@@ -1004,7 +1004,7 @@ var FsToolStepStore = class {
|
|
|
1004
1004
|
* Version of the published `@webskill/sdk` package, injected at build time.
|
|
1005
1005
|
* @stable
|
|
1006
1006
|
*/
|
|
1007
|
-
const SDK_VERSION = "0.
|
|
1007
|
+
const SDK_VERSION = "0.18.0";
|
|
1008
1008
|
|
|
1009
1009
|
//#endregion
|
|
1010
1010
|
export { ALLOWED_TOOLS_EXCLUSION_REASON, ASK_USER_FIELD_TYPES, ASK_USER_INPUT_SCHEMA, ASK_USER_MAX_FIELDS, ASK_USER_TOOL, ASK_USER_TOOL_NAME, ATOMIC_TMP_SUFFIX_PATTERN, ATTACHMENT_TEXT_LIMIT, AgentLoop, AnthropicClient, BEHAVIOR_RECORDS_KEY, CapabilityApproval, DEFAULT_ARCHIVE_LIMITS, DEFAULT_LOOP_LIMITS, DEFAULT_MAX_DATA_SOURCE_BYTES, DEFAULT_MAX_DOCUMENT_BYTES, DEFAULT_MAX_DOCUMENT_TEXT_BYTES, DEFAULT_MAX_UPLOAD_FILE_BYTES, DEFAULT_USER_PROFILE_LIMITS, DOCX_MIME, EMPTY_USER_PROFILE, EventBus, FILE_MIME_TYPES, FS_SESSION_PAGE_SIZE, FsArtifactStore, FsMemoryStore, FsRunSnapshotStore, FsRunTraceStore, FsSessionStore, FsToolStepStore, FsTrustedKeyStore, FullDisclosureRouter, GoogleGenAiClient, HookRunner, IMAGE_MIME_TYPES, MANIFEST_EXCLUDED_FILES, MAX_TOOL_STEP_ARG_BYTES, MemoryFS, OpenAiCompatibleClient, ProgressiveRouter, READ_LINKED_DOCUMENT_TOOL, READ_LINKED_DOCUMENT_TOOL_NAME, READ_SKILL_FILE_INPUT_SCHEMA, READ_SKILL_FILE_TOOL, READ_SKILL_FILE_TOOL_NAME, RUN_SNAPSHOT_SCHEMA_VERSION, RUN_TRACE_SCHEMA_VERSION, SDK_VERSION, SENSITIVE_ANNOTATION, SESSION_SCHEMA_VERSION, SIGNATURE_SCHEMA_VERSION, SKILLS_LOCKFILE, SKILL_MANIFEST_FILE, SKILL_NAME_MAX_LENGTH, SKILL_NAME_PATTERN, SKILL_PACK_FILE, SKILL_SIGNATURE_FILE, SUPPORTED_DOCUMENT_MIME, SerializingMemoryStore, SkillDiscovery, SkillReader, TEXT_BUDGETED_CONTENT_TYPES, TEXT_EXTENSIONS, TraceRecorder, UNSUPPORTED_DOCUMENT_MESSAGE, UNTRUSTED_LINE_LIMIT, UPLOAD_FILES_UNAVAILABLE, USER_PROFILE_EXPORT_VERSION, USER_PROFILE_KEY, USER_PROFILE_NO_INVENTION_RULE, USER_PROFILE_PROMPT_HEADER, USER_PROFILE_REFINE_PROMPT, WebSkillError, WebSkillRuntime, XLSX_MIME, appendBehaviorRecords, applyUserProfileImport, assertRemoteUrlAllowed, assertSafePathSegment, atomicWriteText, bridgeError, buildCatalog, buildManifest, buildRenderResult, checkDependencyCycles, checkSkillRules, classifyAttachment, computeDigest, createScriptContext, createWebSkillApi, detectSkillArchiveShape, detectSkillArchiveShapeFromFs, diffUserProfile, escapeXml, exportSkills, exportUserProfile, extractChartSpec, extractSkillCandidate, extractTodoTraceEvents, extractUiSpecEvents, findUnpairedToolCalls, formatAttachmentText, formatSkillScriptManifest, fromVercelResult, fromVercelStreamPart, interruptedToolResult, isAtomicTempPath, isNetworkAllowed, isUnsupportedRunSnapshot, isValidSkillName, jsonRenderer, keyIdOf, listSkillScripts, mergeCatalogEntries, mergeProfileEntries, messageOf, networkPolicyLibSource, networkUrlHost, normalizeErrorCode, normalizePath, normalizeToolContent, normalizeToolError, parseBridgeRequest, parseSkillMarkdown, parseSkillPackManifest, parseUserProfileExport, partsToText, readBehaviorRecords, readProfileEntries, readResponseWithLimit, readSkillSignature, readUserProfile, redactToolStepArgs, refineUserProfile, renderAvailableSkillsXml, renderCatalogJson, renderUserProfileContext, resolveArchiveLimits, resolveInsideRoot, resolveToolName, sampleBehaviorRecords, sanitizeUntrustedLine, schemaSourceLabel, schemaToForm, scriptToolName, sealToolCallPairs, signSkill, signaturePayloadBytes, stripArchiveRoot, summarizeRunUsage, summarizeToolCalls, textParts, toBase64, toLlmToolSpec, toRecordDigests, toVercelToolSpecs, unzipWithLimits, validateSkills, validateUiSpecEvent, validateUiSpecNode, verifyManifest, verifySkillSignature, xmlRenderer };
|
|
@@ -809,6 +809,44 @@ const toOpenAiTools = (tools) => tools.map((tool) => ({
|
|
|
809
809
|
}
|
|
810
810
|
}));
|
|
811
811
|
const errorMessage$2 = (e) => e instanceof Error ? e.message : String(e);
|
|
812
|
+
/** 错误正文只给能定位问题的开头一段,整份上游响应仍在 cause 里 */
|
|
813
|
+
const DETAIL_LIMIT = 500;
|
|
814
|
+
/**
|
|
815
|
+
* 2xx 响应体里的业务错误文本。兼容端点在「HTTP 成功但业务失败」时的三种常见形态:
|
|
816
|
+
* OpenAI `{error:{message}}`、Ollama `{error:"..."}`、vLLM `{object:"error",message:"..."}`。
|
|
817
|
+
*/
|
|
818
|
+
const upstreamErrorText = (data) => {
|
|
819
|
+
if (typeof data !== "object" || data === null) return void 0;
|
|
820
|
+
const record = data;
|
|
821
|
+
const error = record["error"];
|
|
822
|
+
if (typeof error === "string" && error !== "") return error;
|
|
823
|
+
if (typeof error === "object" && error !== null) {
|
|
824
|
+
const message = error["message"];
|
|
825
|
+
if (typeof message === "string" && message !== "") return message;
|
|
826
|
+
}
|
|
827
|
+
const top = record["message"];
|
|
828
|
+
if (record["object"] === "error" && typeof top === "string" && top !== "") return top;
|
|
829
|
+
};
|
|
830
|
+
const parseJsonOrUndefined = (text) => {
|
|
831
|
+
try {
|
|
832
|
+
return JSON.parse(text);
|
|
833
|
+
} catch {
|
|
834
|
+
return;
|
|
835
|
+
}
|
|
836
|
+
};
|
|
837
|
+
/**
|
|
838
|
+
* 错误正文会进 trace 与控制台,而网关形态的 baseUrl 里常带凭据
|
|
839
|
+
* (`https://user:pass@host`、`?api-key=...`)。报 URL 只为了让宿主认出自己指错了地方,
|
|
840
|
+
* origin + pathname 已经够;解不出来的就原样给回(那就不是一个能藏凭据的 URL)。
|
|
841
|
+
*/
|
|
842
|
+
const redactUrl = (url) => {
|
|
843
|
+
try {
|
|
844
|
+
const parsed = new URL(url);
|
|
845
|
+
return `${parsed.origin}${parsed.pathname}`;
|
|
846
|
+
} catch {
|
|
847
|
+
return url;
|
|
848
|
+
}
|
|
849
|
+
};
|
|
812
850
|
/** OpenAI chat completions 协议客户端(兼容端点通用) */
|
|
813
851
|
var OpenAiCompatibleClient = class {
|
|
814
852
|
#config;
|
|
@@ -827,19 +865,19 @@ var OpenAiCompatibleClient = class {
|
|
|
827
865
|
};
|
|
828
866
|
}
|
|
829
867
|
async complete(input) {
|
|
830
|
-
const res = await this.#postChat(input, false);
|
|
868
|
+
const { res, endpoint } = await this.#postChat(input, false);
|
|
831
869
|
let data;
|
|
832
870
|
try {
|
|
833
871
|
data = await res.json();
|
|
834
872
|
} catch (e) {
|
|
835
|
-
throw new WebSkillError("LLM_REQUEST_FAILED", `Failed to parse LLM response: ${errorMessage$2(e)}`, e);
|
|
873
|
+
throw new WebSkillError("LLM_REQUEST_FAILED", `Failed to parse the LLM response from ${endpoint}: ${errorMessage$2(e)}`, e);
|
|
836
874
|
}
|
|
837
|
-
return this.#parseResponse(data);
|
|
875
|
+
return this.#parseResponse(data, endpoint);
|
|
838
876
|
}
|
|
839
877
|
/** SSE 流式:fetch + ReadableStream 按行解析 data: 帧(Node/浏览器通用) */
|
|
840
878
|
async *stream(input) {
|
|
841
|
-
const res = await this.#postChat(input, true);
|
|
842
|
-
if (!res.body) throw new WebSkillError("LLM_REQUEST_FAILED",
|
|
879
|
+
const { res, endpoint } = await this.#postChat(input, true);
|
|
880
|
+
if (!res.body) throw new WebSkillError("LLM_REQUEST_FAILED", `The LLM streaming response from ${endpoint} has no body`);
|
|
843
881
|
const toolCallsByIndex = /* @__PURE__ */ new Map();
|
|
844
882
|
const decoder = new TextDecoder();
|
|
845
883
|
const reader = res.body.getReader();
|
|
@@ -847,6 +885,8 @@ var OpenAiCompatibleClient = class {
|
|
|
847
885
|
const think = createThinkTagSplitter();
|
|
848
886
|
let done = false;
|
|
849
887
|
let usage;
|
|
888
|
+
let sawFrame = false;
|
|
889
|
+
let head = "";
|
|
850
890
|
const handleFrame = function* (data) {
|
|
851
891
|
if (data === "[DONE]") {
|
|
852
892
|
done = true;
|
|
@@ -897,7 +937,10 @@ var OpenAiCompatibleClient = class {
|
|
|
897
937
|
try {
|
|
898
938
|
for (;;) {
|
|
899
939
|
const { value, done: readerDone } = await reader.read();
|
|
900
|
-
const
|
|
940
|
+
const text = readerDone ? "" : decoder.decode(value, { stream: true });
|
|
941
|
+
const payloads = readerDone ? frames.flush() : frames.push(text);
|
|
942
|
+
if (payloads.length > 0) sawFrame = true;
|
|
943
|
+
else if (!sawFrame && head.length < DETAIL_LIMIT) head += text;
|
|
901
944
|
for (const payload of payloads) {
|
|
902
945
|
yield* handleFrame(payload);
|
|
903
946
|
if (done) break;
|
|
@@ -907,6 +950,10 @@ var OpenAiCompatibleClient = class {
|
|
|
907
950
|
} finally {
|
|
908
951
|
reader.releaseLock();
|
|
909
952
|
}
|
|
953
|
+
if (!sawFrame) {
|
|
954
|
+
const upstream = upstreamErrorText(parseJsonOrUndefined(head));
|
|
955
|
+
throw new WebSkillError("LLM_REQUEST_FAILED", upstream === void 0 ? `The LLM stream from ${endpoint} carried no data frames; the endpoint answered HTTP 200 but not an event stream${head === "" ? "" : `: ${head.slice(0, DETAIL_LIMIT)}`}` : `The endpoint ${endpoint} answered HTTP 200 with an error instead of a stream: ${upstream.slice(0, DETAIL_LIMIT)}`, head);
|
|
956
|
+
}
|
|
910
957
|
const tail = think.flush();
|
|
911
958
|
if (tail.thinking !== "") yield {
|
|
912
959
|
type: "thinking-delta",
|
|
@@ -955,9 +1002,11 @@ var OpenAiCompatibleClient = class {
|
|
|
955
1002
|
body["stream"] = true;
|
|
956
1003
|
body["stream_options"] = { include_usage: true };
|
|
957
1004
|
}
|
|
1005
|
+
const endpoint = `${baseUrl}/chat/completions`;
|
|
1006
|
+
const shown = redactUrl(endpoint);
|
|
958
1007
|
let res;
|
|
959
1008
|
try {
|
|
960
|
-
res = await this.#fetch(
|
|
1009
|
+
res = await this.#fetch(endpoint, {
|
|
961
1010
|
method: "POST",
|
|
962
1011
|
headers: {
|
|
963
1012
|
"content-type": "application/json",
|
|
@@ -967,13 +1016,16 @@ var OpenAiCompatibleClient = class {
|
|
|
967
1016
|
signal: input.signal ?? (this.#config.requestTimeoutMs ? AbortSignal.timeout(this.#config.requestTimeoutMs) : null)
|
|
968
1017
|
});
|
|
969
1018
|
} catch (e) {
|
|
970
|
-
throw new WebSkillError("LLM_REQUEST_FAILED", `LLM request failed: ${errorMessage$2(e)}`, e);
|
|
1019
|
+
throw new WebSkillError("LLM_REQUEST_FAILED", `The LLM request to ${shown} failed: ${errorMessage$2(e)}`, e);
|
|
971
1020
|
}
|
|
972
1021
|
if (!res.ok) {
|
|
973
1022
|
const detail = await res.text().catch(() => "");
|
|
974
|
-
throw new WebSkillError("LLM_REQUEST_FAILED", `LLM request failed with HTTP ${res.status}${detail ? `: ${detail.slice(0,
|
|
1023
|
+
throw new WebSkillError("LLM_REQUEST_FAILED", `The LLM request to ${shown} failed with HTTP ${res.status}${detail ? `: ${detail.slice(0, DETAIL_LIMIT)}` : ""}`, { status: res.status });
|
|
975
1024
|
}
|
|
976
|
-
return
|
|
1025
|
+
return {
|
|
1026
|
+
res,
|
|
1027
|
+
endpoint: shown
|
|
1028
|
+
};
|
|
977
1029
|
}
|
|
978
1030
|
/** 轻量探测(GET /models),集成测试据此决定 skip */
|
|
979
1031
|
async checkAvailability() {
|
|
@@ -984,10 +1036,13 @@ var OpenAiCompatibleClient = class {
|
|
|
984
1036
|
return false;
|
|
985
1037
|
}
|
|
986
1038
|
}
|
|
987
|
-
#parseResponse(data) {
|
|
1039
|
+
#parseResponse(data, endpoint) {
|
|
988
1040
|
try {
|
|
989
1041
|
const choice = data.choices?.[0]?.message;
|
|
990
|
-
if (!choice)
|
|
1042
|
+
if (!choice) {
|
|
1043
|
+
const upstream = upstreamErrorText(data);
|
|
1044
|
+
throw new Error(upstream === void 0 ? `the response from ${endpoint} has no choices[0].message` : `the endpoint ${endpoint} answered HTTP 200 with an error instead of a completion: ${upstream.slice(0, DETAIL_LIMIT)}`);
|
|
1045
|
+
}
|
|
991
1046
|
const toolCalls = choice["tool_calls"]?.map((tc) => {
|
|
992
1047
|
let args = {};
|
|
993
1048
|
let parseError;
|
package/dist/node.js
CHANGED
|
@@ -2,7 +2,7 @@ import { n as messageOf, t as WebSkillError } from "./errors-BDZNpC13.js";
|
|
|
2
2
|
import { A as SKILL_MANIFEST_FILE, D as verifySkillSignature, M as buildManifest, O as MANIFEST_EXCLUDED_FILES, P as verifyManifest, b as parseSkillMarkdown, c as unzipWithLimits, f as SKILL_PACK_FILE, k as SKILLS_LOCKFILE, m as parseSkillPackManifest, o as readResponseWithLimit, p as exportSkills, s as resolveArchiveLimits, t as validateSkills, w as readSkillSignature, y as isValidSkillName } from "./skill-CAJMsLod.js";
|
|
3
3
|
import { a as atomicWriteText, o as isAtomicTempPath, r as resolveInsideRoot, t as assertSafePathSegment } from "./pathSecurity-B1owvJAF.js";
|
|
4
4
|
import { t as assertRemoteUrlAllowed } from "./urlSafety-CiSuCJvX.js";
|
|
5
|
-
import { B as createScriptContext, a as networkPolicyLibSource, c as bridgeError, d as FsMemoryStore, f as WebSkillRuntime, l as parseBridgeRequest, r as normalizeToolError, s as UPLOAD_FILES_UNAVAILABLE, t as CapabilityApproval, u as FsArtifactStore } from "./approval-
|
|
5
|
+
import { B as createScriptContext, a as networkPolicyLibSource, c as bridgeError, d as FsMemoryStore, f as WebSkillRuntime, l as parseBridgeRequest, r as normalizeToolError, s as UPLOAD_FILES_UNAVAILABLE, t as CapabilityApproval, u as FsArtifactStore } from "./approval-B7GW86u2.js";
|
|
6
6
|
import { n as normalizeToolContent } from "./external-_ZRQe-V9.js";
|
|
7
7
|
import { i as probeLlmCapabilities } from "./env-Bj1MI2Ww.js";
|
|
8
8
|
import { t as AUDIT_EVENT_TYPES } from "./eventTypes-CwciaqCU.js";
|
package/dist/testing.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as MockLlmClient } from "./llm-
|
|
1
|
+
import { t as MockLlmClient } from "./llm-eIQNO9tr.js";
|
|
2
2
|
import { t as MemoryArtifactStore } from "./memoryArtifactStore-D6dLeY55.js";
|
|
3
3
|
import { n as loadGoogleConfigFromEnv, r as loadLlmConfigFromEnv, t as loadAnthropicConfigFromEnv } from "./env-Bj1MI2Ww.js";
|
|
4
4
|
|
|
@@ -58,12 +58,12 @@ function toActionFrameScopes(scope) {
|
|
|
58
58
|
}];
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
|
-
* 本版的操作集(FR-25.1 / 0.16.0 FR-13.6
|
|
61
|
+
* 本版的操作集(FR-25.1 / 0.16.0 FR-13.6 / 0.18.0 FR-10.1)。拖拽仍不在内(D64);
|
|
62
62
|
* 导航只有 `back` 一个,且它**不接受地址**——可达面被浏览器历史封死(SC-1)。
|
|
63
63
|
*
|
|
64
|
-
* `select`/`set`/`attach`
|
|
64
|
+
* `select`/`set`/`attach`/`scroll` 与既有几个走**同一条** policy 路径,
|
|
65
65
|
* 范围白名单、逐次确认、审计三条硬约束因此天然覆盖到它们——
|
|
66
|
-
* 前提是新动作不绕过 policy
|
|
66
|
+
* 前提是新动作不绕过 policy 直调执行器(AC-25.4 守这一点)。
|
|
67
67
|
* @experimental
|
|
68
68
|
*/
|
|
69
69
|
const PAGE_ACTION_KINDS = [
|
|
@@ -73,6 +73,7 @@ const PAGE_ACTION_KINDS = [
|
|
|
73
73
|
"select",
|
|
74
74
|
"set",
|
|
75
75
|
"attach",
|
|
76
|
+
"scroll",
|
|
76
77
|
"back"
|
|
77
78
|
];
|
|
78
79
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as WebSkillError } from "./errors-BDZNpC13.js";
|
|
2
2
|
import { b as parseSkillMarkdown, i as buildCatalog, n as SkillDiscovery, t as validateSkills } from "./skill-CAJMsLod.js";
|
|
3
|
-
import { f as WebSkillRuntime } from "./approval-
|
|
3
|
+
import { f as WebSkillRuntime } from "./approval-B7GW86u2.js";
|
|
4
4
|
|
|
5
5
|
//#region ../runtime/src/facade/webSkillApi.ts
|
|
6
6
|
/**
|