@osovv/vv-opencode 1.5.0 → 1.7.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/CHANGELOG.md +18 -0
- package/README.md +41 -10
- package/dist/lib/agent-tool-catalog.d.ts +144 -0
- package/dist/lib/agent-tool-catalog.js +2551 -0
- package/dist/lib/agent-tool-catalog.js.map +1 -0
- package/dist/lib/agent-tool-contract.d.ts +200 -0
- package/dist/lib/agent-tool-contract.js +407 -0
- package/dist/lib/agent-tool-contract.js.map +1 -0
- package/dist/lib/workflow-contract.d.ts +12 -0
- package/dist/lib/workflow-contract.js +71 -18
- package/dist/lib/workflow-contract.js.map +1 -1
- package/dist/plugins/hashline-edit/index.js +102 -97
- package/dist/plugins/hashline-edit/index.js.map +1 -1
- package/dist/plugins/hashline-edit/normalize-edits.d.ts +2 -8
- package/dist/plugins/hashline-edit/normalize-edits.js +32 -17
- package/dist/plugins/hashline-edit/normalize-edits.js.map +1 -1
- package/dist/plugins/hashline-edit/schemas.d.ts +246 -0
- package/dist/plugins/hashline-edit/schemas.js +659 -0
- package/dist/plugins/hashline-edit/schemas.js.map +1 -0
- package/dist/plugins/hashline-edit/str-replace-editor.d.ts +6 -17
- package/dist/plugins/hashline-edit/str-replace-editor.js +19 -21
- package/dist/plugins/hashline-edit/str-replace-editor.js.map +1 -1
- package/dist/plugins/hashline-edit/tool-description.d.ts +1 -0
- package/dist/plugins/hashline-edit/tool-description.js +20 -4
- package/dist/plugins/hashline-edit/tool-description.js.map +1 -1
- package/dist/plugins/system-context-injection/index.js +9 -4
- package/dist/plugins/system-context-injection/index.js.map +1 -1
- package/dist/plugins/web-tools/fetch-service.d.ts +8 -5
- package/dist/plugins/web-tools/fetch-service.js +30 -45
- package/dist/plugins/web-tools/fetch-service.js.map +1 -1
- package/dist/plugins/web-tools/index.js +23 -5
- package/dist/plugins/web-tools/index.js.map +1 -1
- package/dist/plugins/web-tools/schemas.d.ts +469 -0
- package/dist/plugins/web-tools/schemas.js +523 -0
- package/dist/plugins/web-tools/schemas.js.map +1 -0
- package/dist/plugins/web-tools/search-service.d.ts +6 -3
- package/dist/plugins/web-tools/search-service.js +24 -29
- package/dist/plugins/web-tools/search-service.js.map +1 -1
- package/dist/plugins/workflow/authority.d.ts +6 -0
- package/dist/plugins/workflow/authority.js +45 -10
- package/dist/plugins/workflow/authority.js.map +1 -1
- package/dist/plugins/workflow/authorization.js +16 -8
- package/dist/plugins/workflow/authorization.js.map +1 -1
- package/dist/plugins/workflow/checkpoints.d.ts +41 -2
- package/dist/plugins/workflow/checkpoints.js +176 -47
- package/dist/plugins/workflow/checkpoints.js.map +1 -1
- package/dist/plugins/workflow/delegated.d.ts +15 -1
- package/dist/plugins/workflow/delegated.js +65 -35
- package/dist/plugins/workflow/delegated.js.map +1 -1
- package/dist/plugins/workflow/execution.d.ts +15 -30
- package/dist/plugins/workflow/execution.js +133 -33
- package/dist/plugins/workflow/execution.js.map +1 -1
- package/dist/plugins/workflow/index.js +177 -112
- package/dist/plugins/workflow/index.js.map +1 -1
- package/dist/plugins/workflow/input-validation.d.ts +48 -0
- package/dist/plugins/workflow/input-validation.js +536 -0
- package/dist/plugins/workflow/input-validation.js.map +1 -0
- package/dist/plugins/workflow/inspection.d.ts +60 -0
- package/dist/plugins/workflow/inspection.js +316 -0
- package/dist/plugins/workflow/inspection.js.map +1 -0
- package/dist/plugins/workflow/protocol.d.ts +2 -0
- package/dist/plugins/workflow/protocol.js +26 -4
- package/dist/plugins/workflow/protocol.js.map +1 -1
- package/dist/plugins/workflow/recovery.d.ts +2 -1
- package/dist/plugins/workflow/recovery.js +79 -12
- package/dist/plugins/workflow/recovery.js.map +1 -1
- package/dist/plugins/workflow/repair.d.ts +1 -1
- package/dist/plugins/workflow/repair.js +9 -10
- package/dist/plugins/workflow/repair.js.map +1 -1
- package/dist/plugins/workflow/results.d.ts +2566 -0
- package/dist/plugins/workflow/results.js +1111 -0
- package/dist/plugins/workflow/results.js.map +1 -0
- package/dist/plugins/workflow/schemas.d.ts +214 -24
- package/dist/plugins/workflow/schemas.js +350 -89
- package/dist/plugins/workflow/schemas.js.map +1 -1
- package/dist/plugins/workflow/state.d.ts +3 -2
- package/dist/plugins/workflow/state.js +15 -8
- package/dist/plugins/workflow/state.js.map +1 -1
- package/dist/plugins/workflow/system-instruction.md +17 -1
- package/dist/plugins/workflow/tooling.d.ts +2 -18
- package/dist/plugins/workflow/tooling.js +477 -460
- package/dist/plugins/workflow/tooling.js.map +1 -1
- package/dist/plugins/workflow/transactions.d.ts +13 -0
- package/dist/plugins/workflow/transactions.js +13 -3
- package/dist/plugins/workflow/transactions.js.map +1 -1
- package/package.json +6 -3
- package/schemas/vvoc/v3.json +1 -1
- package/templates/agents/vv-code-reviewer.md +13 -4
- package/templates/agents/vv-controller.md +17 -0
- package/templates/agents/vv-implementer.md +20 -9
- package/templates/agents/vv-spec-reviewer.md +13 -4
- package/templates/skills/vv-execute/SKILL.md +3 -3
- package/templates/skills/vv-execute/references/tool-contracts.md +1750 -0
- package/templates/skills/vv-review/SKILL.md +1 -1
|
@@ -0,0 +1,523 @@
|
|
|
1
|
+
// FILE: src/plugins/web-tools/schemas.ts
|
|
2
|
+
// VERSION: 1.0.0
|
|
3
|
+
// START_MODULE_CONTRACT
|
|
4
|
+
// PURPOSE: Single source of the two vvoc-owned web tool contracts: registered raw argument maps, strict runtime schemas with explicit execute-time defaults, args-only URL/shape validation, model-facing descriptions, operation examples, concrete search/fetch result metadata/attachment producer schemas, and the owned contracts consumed by the definition and pre-execute publication seam.
|
|
5
|
+
// SCOPE: Pure contract declarations and args-only validation for web_search and web_fetch: unknown-key rejection, provided-value typing/enum/bounds checks, representable URL scheme/shape checks, and closed result-envelope schemas for the actual provider delivery variants. No network I/O, permission request, credential resolution, provider selection, dispatch, or content rewriting; the services keep transport and credential redaction authority.
|
|
6
|
+
// DEPENDS: [@opencode-ai/plugin, zod (types), src/lib/agent-tool-contract.ts]
|
|
7
|
+
// LINKS: [M-PLUGIN-WEB-TOOLS, M-WEB-SEARCH-SERVICE, M-WEB-FETCH-SERVICE, M-AGENT-TOOL-CONTRACT]
|
|
8
|
+
// ROLE: RUNTIME
|
|
9
|
+
// MAP_MODE: EXPORTS
|
|
10
|
+
// END_MODULE_CONTRACT
|
|
11
|
+
//
|
|
12
|
+
// START_MODULE_MAP
|
|
13
|
+
// WEB_SEARCH_TOOL_ID - Registered tool id for provider-neutral web search.
|
|
14
|
+
// WEB_FETCH_TOOL_ID - Registered tool id for provider-neutral web fetch.
|
|
15
|
+
// WEB_SEARCH_PROVIDERS - Canonical search provider vocabulary.
|
|
16
|
+
// WEB_FETCH_PROVIDERS - Canonical fetch provider vocabulary.
|
|
17
|
+
// WEB_CREDENTIAL_SOURCES - Credential provenance vocabulary reported in metadata.
|
|
18
|
+
// WEB_REGIONS - Canonical Z.AI region vocabulary.
|
|
19
|
+
// WebRegion - Union of supported Z.AI region identifiers.
|
|
20
|
+
// SEARCH_FRESHNESS_WINDOWS - Canonical freshness window vocabulary.
|
|
21
|
+
// WebSearchFreshness - Union of supported freshness window identifiers.
|
|
22
|
+
// FETCH_FORMATS - Canonical textual output format vocabulary.
|
|
23
|
+
// WebFetchFormat - Union of supported textual output format identifiers.
|
|
24
|
+
// WEB_SEARCH_DEFAULT_COUNT - Default result count.
|
|
25
|
+
// WEB_SEARCH_MIN_COUNT - Minimum result count.
|
|
26
|
+
// WEB_SEARCH_MAX_COUNT - Maximum result count.
|
|
27
|
+
// WEB_FETCH_DEFAULT_TIMEOUT_SECONDS - Default per-call timeout in seconds.
|
|
28
|
+
// WEB_FETCH_MAX_TIMEOUT_SECONDS - Maximum model-configurable timeout in seconds.
|
|
29
|
+
// webSearchArgs - Registered raw argument map for web_search.
|
|
30
|
+
// webFetchArgs - Registered raw argument map for web_fetch.
|
|
31
|
+
// WebSearchToolArgs - Schema-derived web_search argument shape with defaults applied.
|
|
32
|
+
// WebFetchToolArgs - Schema-derived web_fetch argument shape with defaults applied.
|
|
33
|
+
// webSearchContract - Owned contract for web_search.
|
|
34
|
+
// webFetchContract - Owned contract for web_fetch.
|
|
35
|
+
// webToolContracts - Owned contracts for both web tools (definition adapter input).
|
|
36
|
+
// WebSearchValidation - Successful parsed search args or bounded issues.
|
|
37
|
+
// WebFetchValidation - Successful parsed fetch args or bounded issues.
|
|
38
|
+
// validateWebSearchToolInput - Structural validation for web_search.
|
|
39
|
+
// validateWebFetchToolInput - Structural plus URL scheme/shape validation for web_fetch.
|
|
40
|
+
// webSearchMetadataSchema - Closed search metadata schema per provider variant.
|
|
41
|
+
// webSearchResultSchema - Closed search result envelope producer schema.
|
|
42
|
+
// webFetchMetadataSchema - Closed fetch metadata schema per provider/delivery variant.
|
|
43
|
+
// webFetchTextResultSchema - Closed textual fetch result envelope producer schema.
|
|
44
|
+
// webFetchMediaResultSchema - Closed media/attachment fetch result envelope producer schema.
|
|
45
|
+
// webFetchResultSchema - Closed fetch result envelope union.
|
|
46
|
+
// WebSearchResultEnvelope - Schema-derived search result envelope.
|
|
47
|
+
// WebFetchResultEnvelope - Schema-derived fetch result envelope.
|
|
48
|
+
// WebSearchMetadata - Schema-derived search metadata union.
|
|
49
|
+
// WebFetchMetadata - Schema-derived fetch metadata union.
|
|
50
|
+
// END_MODULE_MAP
|
|
51
|
+
//
|
|
52
|
+
// START_CHANGE_SUMMARY
|
|
53
|
+
// LAST_CHANGE: [C-AGENT-TOOL-CONTRACTS T-006 - Initial single-source web input/result contracts with explicit execute-time defaults, URL scheme/shape validation before dispatch, closed provider-variant metadata schemas, and operation examples.]
|
|
54
|
+
// END_CHANGE_SUMMARY
|
|
55
|
+
import { tool } from "@opencode-ai/plugin";
|
|
56
|
+
import { MAX_CONTRACT_ISSUES, MAX_ISSUE_MESSAGE_CHARS, MAX_ISSUE_PATH_CHARS, MAX_ISSUE_VALUE_CHARS, defineOwnedToolContract, ownedToolAttachmentSchema, strictObject, } from "../../lib/agent-tool-contract.js";
|
|
57
|
+
const schema = tool.schema;
|
|
58
|
+
// START_BLOCK_TOOL_IDS
|
|
59
|
+
/** Registered tool id for provider-neutral web search. */
|
|
60
|
+
export const WEB_SEARCH_TOOL_ID = "web_search";
|
|
61
|
+
/** Registered tool id for provider-neutral web fetch. */
|
|
62
|
+
export const WEB_FETCH_TOOL_ID = "web_fetch";
|
|
63
|
+
/** Canonical search provider vocabulary. */
|
|
64
|
+
export const WEB_SEARCH_PROVIDERS = ["exa", "brave", "zai"];
|
|
65
|
+
/** Canonical fetch provider vocabulary. */
|
|
66
|
+
export const WEB_FETCH_PROVIDERS = ["native", "spider", "zai"];
|
|
67
|
+
/** Credential provenance vocabulary reported in result metadata. */
|
|
68
|
+
export const WEB_CREDENTIAL_SOURCES = ["env", "config"];
|
|
69
|
+
/** Canonical Z.AI region vocabulary (matches the canonical vvoc web region enum). */
|
|
70
|
+
export const WEB_REGIONS = ["international", "china"];
|
|
71
|
+
/** Canonical freshness window vocabulary. */
|
|
72
|
+
export const SEARCH_FRESHNESS_WINDOWS = ["day", "week", "month", "year"];
|
|
73
|
+
/** Canonical textual output format vocabulary. */
|
|
74
|
+
export const FETCH_FORMATS = ["markdown", "text", "html"];
|
|
75
|
+
/** Default result count. */
|
|
76
|
+
export const WEB_SEARCH_DEFAULT_COUNT = 8;
|
|
77
|
+
/** Minimum result count. */
|
|
78
|
+
export const WEB_SEARCH_MIN_COUNT = 1;
|
|
79
|
+
/** Maximum result count. */
|
|
80
|
+
export const WEB_SEARCH_MAX_COUNT = 20;
|
|
81
|
+
/** Default per-call timeout in seconds. */
|
|
82
|
+
export const WEB_FETCH_DEFAULT_TIMEOUT_SECONDS = 30;
|
|
83
|
+
/** Maximum model-configurable timeout in seconds. */
|
|
84
|
+
export const WEB_FETCH_MAX_TIMEOUT_SECONDS = 120;
|
|
85
|
+
// END_BLOCK_TOOL_IDS
|
|
86
|
+
// START_BLOCK_ARG_MAPS
|
|
87
|
+
/**
|
|
88
|
+
* Registered raw argument map for web_search (single source of the tool surface).
|
|
89
|
+
* Provider-neutral: no credential, provider, or region arguments are accepted.
|
|
90
|
+
* count carries a representable 1..20 integer bound and the documented default;
|
|
91
|
+
* the execute boundary re-applies the default because the host forwards raw args.
|
|
92
|
+
*/
|
|
93
|
+
export const webSearchArgs = {
|
|
94
|
+
query: schema.string().min(1).describe("The search query; the text is sent unchanged."),
|
|
95
|
+
count: schema
|
|
96
|
+
.number()
|
|
97
|
+
.int()
|
|
98
|
+
.min(WEB_SEARCH_MIN_COUNT)
|
|
99
|
+
.max(WEB_SEARCH_MAX_COUNT)
|
|
100
|
+
.default(WEB_SEARCH_DEFAULT_COUNT)
|
|
101
|
+
.describe(`Number of results, integer ${WEB_SEARCH_MIN_COUNT} through ${WEB_SEARCH_MAX_COUNT}, default ${WEB_SEARCH_DEFAULT_COUNT}.`),
|
|
102
|
+
freshness: schema
|
|
103
|
+
.enum(SEARCH_FRESHNESS_WINDOWS)
|
|
104
|
+
.optional()
|
|
105
|
+
.describe("Optional time window restricting results: day, week, month, or year."),
|
|
106
|
+
};
|
|
107
|
+
const webSearchArgsObject = strictObject(webSearchArgs);
|
|
108
|
+
/**
|
|
109
|
+
* Registered raw argument map for web_fetch (single source of the tool surface).
|
|
110
|
+
* Provider-neutral: no credential or provider arguments are accepted.
|
|
111
|
+
* format and timeout carry the documented defaults; the execute boundary re-applies
|
|
112
|
+
* them because the host forwards raw args. A provider may drop the numeric bound
|
|
113
|
+
* during schema lowering, so the positive/maximum rule stays runtime-enforced.
|
|
114
|
+
*/
|
|
115
|
+
export const webFetchArgs = {
|
|
116
|
+
url: schema
|
|
117
|
+
.string()
|
|
118
|
+
.min(1)
|
|
119
|
+
.describe("The HTTP or HTTPS URL to retrieve; the URL is requested unchanged."),
|
|
120
|
+
format: schema
|
|
121
|
+
.enum(FETCH_FORMATS)
|
|
122
|
+
.default("markdown")
|
|
123
|
+
.describe("Output format for textual resources: markdown, text, or html. Default markdown."),
|
|
124
|
+
timeout: schema
|
|
125
|
+
.number()
|
|
126
|
+
.positive()
|
|
127
|
+
.max(WEB_FETCH_MAX_TIMEOUT_SECONDS)
|
|
128
|
+
.default(WEB_FETCH_DEFAULT_TIMEOUT_SECONDS)
|
|
129
|
+
.describe(`Timeout in seconds: greater than 0 and at most ${WEB_FETCH_MAX_TIMEOUT_SECONDS}; fractional values are allowed. Default ${WEB_FETCH_DEFAULT_TIMEOUT_SECONDS}.`),
|
|
130
|
+
};
|
|
131
|
+
const webFetchArgsObject = strictObject(webFetchArgs);
|
|
132
|
+
// END_BLOCK_ARG_MAPS
|
|
133
|
+
// START_BLOCK_OPERATION_EXAMPLES
|
|
134
|
+
const webSearchExamples = [
|
|
135
|
+
{
|
|
136
|
+
operation: "search",
|
|
137
|
+
label: "query only applies count 8",
|
|
138
|
+
expect: "accept",
|
|
139
|
+
input: { query: "vvoc" },
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
operation: "search",
|
|
143
|
+
label: "explicit integer count at the maximum",
|
|
144
|
+
expect: "accept",
|
|
145
|
+
input: { query: "vvoc", count: WEB_SEARCH_MAX_COUNT },
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
operation: "search",
|
|
149
|
+
label: "freshness window filters results",
|
|
150
|
+
expect: "accept",
|
|
151
|
+
input: { query: "vvoc", freshness: "week" },
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
operation: "search",
|
|
155
|
+
label: "count below the minimum",
|
|
156
|
+
expect: "reject",
|
|
157
|
+
input: { query: "vvoc", count: 0 },
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
operation: "search",
|
|
161
|
+
label: "count above the maximum",
|
|
162
|
+
expect: "reject",
|
|
163
|
+
input: { query: "vvoc", count: WEB_SEARCH_MAX_COUNT + 1 },
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
operation: "search",
|
|
167
|
+
label: "fractional count is not an integer",
|
|
168
|
+
expect: "reject",
|
|
169
|
+
input: { query: "vvoc", count: 1.5 },
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
operation: "search",
|
|
173
|
+
label: "string count is not coerced",
|
|
174
|
+
expect: "reject",
|
|
175
|
+
input: { query: "vvoc", count: "8" },
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
operation: "search",
|
|
179
|
+
label: "null count is not a default",
|
|
180
|
+
expect: "reject",
|
|
181
|
+
input: { query: "vvoc", count: null },
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
operation: "search",
|
|
185
|
+
label: "unknown freshness window",
|
|
186
|
+
expect: "reject",
|
|
187
|
+
input: { query: "vvoc", freshness: "hour" },
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
operation: "search",
|
|
191
|
+
label: "credential or provider selection is not a caller argument",
|
|
192
|
+
expect: "reject",
|
|
193
|
+
input: { query: "vvoc", credential: "secret", provider: "brave" },
|
|
194
|
+
},
|
|
195
|
+
];
|
|
196
|
+
const webFetchExamples = [
|
|
197
|
+
{
|
|
198
|
+
operation: "fetch",
|
|
199
|
+
label: "url only applies markdown and 30 seconds",
|
|
200
|
+
expect: "accept",
|
|
201
|
+
input: { url: "https://example.test/page" },
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
operation: "fetch",
|
|
205
|
+
label: "text format with a fractional positive timeout",
|
|
206
|
+
expect: "accept",
|
|
207
|
+
input: { url: "https://example.test/page", format: "text", timeout: 0.5 },
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
operation: "fetch",
|
|
211
|
+
label: "html format at the timeout maximum",
|
|
212
|
+
expect: "accept",
|
|
213
|
+
input: {
|
|
214
|
+
url: "https://example.test/page",
|
|
215
|
+
format: "html",
|
|
216
|
+
timeout: WEB_FETCH_MAX_TIMEOUT_SECONDS,
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
operation: "fetch",
|
|
221
|
+
label: "relative url has no absolute scheme",
|
|
222
|
+
expect: "reject",
|
|
223
|
+
input: { url: "/page" },
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
operation: "fetch",
|
|
227
|
+
label: "file scheme is unsupported",
|
|
228
|
+
expect: "reject",
|
|
229
|
+
input: { url: "file:///tmp/secret" },
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
operation: "fetch",
|
|
233
|
+
label: "data scheme is unsupported",
|
|
234
|
+
expect: "reject",
|
|
235
|
+
input: { url: "data:text/plain,hello" },
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
operation: "fetch",
|
|
239
|
+
label: "ftp scheme is unsupported",
|
|
240
|
+
expect: "reject",
|
|
241
|
+
input: { url: "ftp://example.test/file" },
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
operation: "fetch",
|
|
245
|
+
label: "malformed host is unparseable",
|
|
246
|
+
expect: "reject",
|
|
247
|
+
input: { url: "https://exa mple.test" },
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
operation: "fetch",
|
|
251
|
+
label: "unsupported format",
|
|
252
|
+
expect: "reject",
|
|
253
|
+
input: { url: "https://example.test/page", format: "pdf" },
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
operation: "fetch",
|
|
257
|
+
label: "timeout of zero is not positive",
|
|
258
|
+
expect: "reject",
|
|
259
|
+
input: { url: "https://example.test/page", timeout: 0 },
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
operation: "fetch",
|
|
263
|
+
label: "timeout above the maximum",
|
|
264
|
+
expect: "reject",
|
|
265
|
+
input: { url: "https://example.test/page", timeout: WEB_FETCH_MAX_TIMEOUT_SECONDS + 1 },
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
operation: "fetch",
|
|
269
|
+
label: "string timeout is not coerced",
|
|
270
|
+
expect: "reject",
|
|
271
|
+
input: { url: "https://example.test/page", timeout: "30" },
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
operation: "fetch",
|
|
275
|
+
label: "null timeout is not a default",
|
|
276
|
+
expect: "reject",
|
|
277
|
+
input: { url: "https://example.test/page", timeout: null },
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
operation: "fetch",
|
|
281
|
+
label: "credential or provider selection is not a caller argument",
|
|
282
|
+
expect: "reject",
|
|
283
|
+
input: { url: "https://example.test/page", apiKey: "secret", provider: "spider" },
|
|
284
|
+
},
|
|
285
|
+
];
|
|
286
|
+
// END_BLOCK_OPERATION_EXAMPLES
|
|
287
|
+
// START_BLOCK_CONTRACTS
|
|
288
|
+
/** Owned contract for web_search. */
|
|
289
|
+
export const webSearchContract = defineOwnedToolContract({
|
|
290
|
+
toolId: WEB_SEARCH_TOOL_ID,
|
|
291
|
+
description: "Search the web using the configured provider and return ranked results as Markdown. Use for discovering information; returns titles, URLs, snippets, and dates.",
|
|
292
|
+
registeredArgs: webSearchArgs,
|
|
293
|
+
examples: webSearchExamples,
|
|
294
|
+
});
|
|
295
|
+
/** Owned contract for web_fetch. */
|
|
296
|
+
export const webFetchContract = defineOwnedToolContract({
|
|
297
|
+
toolId: WEB_FETCH_TOOL_ID,
|
|
298
|
+
description: "Fetch a known HTTP or HTTPS URL using the configured provider. Returns Markdown, text, raw HTML, or an image/PDF attachment.",
|
|
299
|
+
registeredArgs: webFetchArgs,
|
|
300
|
+
examples: webFetchExamples,
|
|
301
|
+
});
|
|
302
|
+
/** Owned contracts for both web tools (input to the owned definition/pre-execute adapters). */
|
|
303
|
+
export const webToolContracts = [
|
|
304
|
+
webSearchContract,
|
|
305
|
+
webFetchContract,
|
|
306
|
+
];
|
|
307
|
+
// END_BLOCK_CONTRACTS
|
|
308
|
+
// START_BLOCK_ISSUE_HELPERS
|
|
309
|
+
function truncateChars(value, max) {
|
|
310
|
+
if (value.length <= max)
|
|
311
|
+
return value;
|
|
312
|
+
return `${value.slice(0, Math.max(0, max - 1))}…`;
|
|
313
|
+
}
|
|
314
|
+
function boundedIssue(issue) {
|
|
315
|
+
return {
|
|
316
|
+
code: issue.code,
|
|
317
|
+
path: truncateChars(issue.path, MAX_ISSUE_PATH_CHARS),
|
|
318
|
+
message: truncateChars(issue.message, MAX_ISSUE_MESSAGE_CHARS),
|
|
319
|
+
...(issue.expected !== undefined
|
|
320
|
+
? { expected: truncateChars(issue.expected, MAX_ISSUE_MESSAGE_CHARS) }
|
|
321
|
+
: {}),
|
|
322
|
+
...(issue.received !== undefined
|
|
323
|
+
? { received: truncateChars(issue.received, MAX_ISSUE_VALUE_CHARS) }
|
|
324
|
+
: {}),
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
function pushIssue(issues, issue) {
|
|
328
|
+
if (issues.length >= MAX_CONTRACT_ISSUES)
|
|
329
|
+
return;
|
|
330
|
+
issues.push(boundedIssue(issue));
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Strict structural validation for web_search.
|
|
334
|
+
* Unknown root keys, malformed provided values, unsupported freshness windows, and
|
|
335
|
+
* out-of-bounds counts reject; the documented count default is applied for execute.
|
|
336
|
+
* The query text is preserved verbatim.
|
|
337
|
+
*/
|
|
338
|
+
export function validateWebSearchToolInput(raw) {
|
|
339
|
+
const parsed = webSearchContract.safeParse(raw);
|
|
340
|
+
if (!parsed.success) {
|
|
341
|
+
return { ok: false, issues: parsed.issues };
|
|
342
|
+
}
|
|
343
|
+
return { ok: true, data: parsed.data };
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Strict structural plus URL scheme/shape validation for web_fetch.
|
|
347
|
+
* Structural failures reject first; then the URL must parse as an absolute HTTP or
|
|
348
|
+
* HTTPS URL. Diagnostics identify the offending `url` field with a bounded message
|
|
349
|
+
* that never echoes the raw URL (which may carry credentials) or an error payload.
|
|
350
|
+
* The format and timeout defaults are applied for execute.
|
|
351
|
+
*/
|
|
352
|
+
export function validateWebFetchToolInput(raw) {
|
|
353
|
+
const parsed = webFetchContract.safeParse(raw);
|
|
354
|
+
if (!parsed.success) {
|
|
355
|
+
return { ok: false, issues: parsed.issues };
|
|
356
|
+
}
|
|
357
|
+
const issues = [];
|
|
358
|
+
let parsedUrl;
|
|
359
|
+
try {
|
|
360
|
+
parsedUrl = new URL(parsed.data.url);
|
|
361
|
+
}
|
|
362
|
+
catch {
|
|
363
|
+
pushIssue(issues, {
|
|
364
|
+
code: "invalid_format",
|
|
365
|
+
path: "url",
|
|
366
|
+
message: "url must be an absolute HTTP or HTTPS URL",
|
|
367
|
+
expected: "an absolute http(s) URL",
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
if (parsedUrl && parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") {
|
|
371
|
+
const scheme = truncateChars(parsedUrl.protocol.replace(/:$/, ""), MAX_ISSUE_VALUE_CHARS);
|
|
372
|
+
pushIssue(issues, {
|
|
373
|
+
code: "invalid_value",
|
|
374
|
+
path: "url",
|
|
375
|
+
message: `unsupported URL scheme "${scheme}"; only http and https are supported`,
|
|
376
|
+
expected: "http or https",
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
if (issues.length > 0) {
|
|
380
|
+
return { ok: false, issues };
|
|
381
|
+
}
|
|
382
|
+
return { ok: true, data: parsed.data };
|
|
383
|
+
}
|
|
384
|
+
// END_BLOCK_VALIDATION
|
|
385
|
+
// START_BLOCK_RESULT_SCHEMAS
|
|
386
|
+
const credentialSourceSchema = schema.enum(WEB_CREDENTIAL_SOURCES);
|
|
387
|
+
const formatSchema = schema.enum(FETCH_FORMATS);
|
|
388
|
+
const regionSchema = schema.enum(WEB_REGIONS);
|
|
389
|
+
const [EXA, BRAVE, ZAI_SEARCH] = WEB_SEARCH_PROVIDERS;
|
|
390
|
+
const [NATIVE, SPIDER, ZAI_FETCH] = WEB_FETCH_PROVIDERS;
|
|
391
|
+
/**
|
|
392
|
+
* Closed search metadata schemas for the actual delivery variants.
|
|
393
|
+
* `region` is present only for the direct Z.AI provider; unknown fields and
|
|
394
|
+
* missing known fields reject.
|
|
395
|
+
*/
|
|
396
|
+
export const webSearchMetadataSchema = schema.union([
|
|
397
|
+
strictObject({
|
|
398
|
+
provider: schema.literal(EXA),
|
|
399
|
+
resultCount: schema.number().int().min(0),
|
|
400
|
+
credentialSource: credentialSourceSchema,
|
|
401
|
+
}),
|
|
402
|
+
strictObject({
|
|
403
|
+
provider: schema.literal(BRAVE),
|
|
404
|
+
resultCount: schema.number().int().min(0),
|
|
405
|
+
credentialSource: credentialSourceSchema,
|
|
406
|
+
}),
|
|
407
|
+
strictObject({
|
|
408
|
+
provider: schema.literal(ZAI_SEARCH),
|
|
409
|
+
region: regionSchema,
|
|
410
|
+
resultCount: schema.number().int().min(0),
|
|
411
|
+
credentialSource: credentialSourceSchema,
|
|
412
|
+
}),
|
|
413
|
+
]);
|
|
414
|
+
/**
|
|
415
|
+
* Closed result envelope for web_search producer/test checks.
|
|
416
|
+
* `output` is the rendered Markdown document and stays a declared opaque string.
|
|
417
|
+
* This is never applied as a throw-after-side-effect execute wrapper.
|
|
418
|
+
*/
|
|
419
|
+
export const webSearchResultSchema = strictObject({
|
|
420
|
+
title: schema.string(),
|
|
421
|
+
output: schema.string(),
|
|
422
|
+
metadata: webSearchMetadataSchema,
|
|
423
|
+
});
|
|
424
|
+
/**
|
|
425
|
+
* Closed fetch metadata schemas for the actual provider/delivery variants.
|
|
426
|
+
* Native reports its status; Spider may add status/duration; Z.AI reader text
|
|
427
|
+
* carries its regional request metadata while direct Z.AI media reports only the
|
|
428
|
+
* region/format/credential provenance. Region is required for every Z.AI variant.
|
|
429
|
+
*/
|
|
430
|
+
export const webFetchMetadataSchema = schema.union([
|
|
431
|
+
strictObject({
|
|
432
|
+
provider: schema.literal(NATIVE),
|
|
433
|
+
format: formatSchema,
|
|
434
|
+
status: schema.number().int(),
|
|
435
|
+
}),
|
|
436
|
+
strictObject({
|
|
437
|
+
provider: schema.literal(SPIDER),
|
|
438
|
+
format: formatSchema,
|
|
439
|
+
credentialSource: credentialSourceSchema,
|
|
440
|
+
status: schema.number().int().optional(),
|
|
441
|
+
durationMs: schema.number().optional(),
|
|
442
|
+
}),
|
|
443
|
+
strictObject({
|
|
444
|
+
provider: schema.literal(ZAI_FETCH),
|
|
445
|
+
region: regionSchema,
|
|
446
|
+
format: formatSchema,
|
|
447
|
+
credentialSource: credentialSourceSchema,
|
|
448
|
+
status: schema.number().int(),
|
|
449
|
+
requestId: schema.string().optional(),
|
|
450
|
+
model: schema.string().optional(),
|
|
451
|
+
created: schema.number().optional(),
|
|
452
|
+
title: schema.string().optional(),
|
|
453
|
+
}),
|
|
454
|
+
strictObject({
|
|
455
|
+
provider: schema.literal(ZAI_FETCH),
|
|
456
|
+
region: regionSchema,
|
|
457
|
+
format: formatSchema,
|
|
458
|
+
credentialSource: credentialSourceSchema,
|
|
459
|
+
}),
|
|
460
|
+
]);
|
|
461
|
+
/** Closed textual fetch result envelope producer schema (no attachments region). */
|
|
462
|
+
export const webFetchTextResultSchema = strictObject({
|
|
463
|
+
title: schema.string(),
|
|
464
|
+
output: schema.string(),
|
|
465
|
+
metadata: schema.union([
|
|
466
|
+
strictObject({
|
|
467
|
+
provider: schema.literal(NATIVE),
|
|
468
|
+
format: formatSchema,
|
|
469
|
+
status: schema.number().int(),
|
|
470
|
+
}),
|
|
471
|
+
strictObject({
|
|
472
|
+
provider: schema.literal(SPIDER),
|
|
473
|
+
format: formatSchema,
|
|
474
|
+
credentialSource: credentialSourceSchema,
|
|
475
|
+
status: schema.number().int().optional(),
|
|
476
|
+
durationMs: schema.number().optional(),
|
|
477
|
+
}),
|
|
478
|
+
strictObject({
|
|
479
|
+
provider: schema.literal(ZAI_FETCH),
|
|
480
|
+
region: regionSchema,
|
|
481
|
+
format: formatSchema,
|
|
482
|
+
credentialSource: credentialSourceSchema,
|
|
483
|
+
status: schema.number().int(),
|
|
484
|
+
requestId: schema.string().optional(),
|
|
485
|
+
model: schema.string().optional(),
|
|
486
|
+
created: schema.number().optional(),
|
|
487
|
+
title: schema.string().optional(),
|
|
488
|
+
}),
|
|
489
|
+
]),
|
|
490
|
+
});
|
|
491
|
+
/** Closed media fetch result envelope producer schema requiring a real attachment. */
|
|
492
|
+
export const webFetchMediaResultSchema = strictObject({
|
|
493
|
+
title: schema.string(),
|
|
494
|
+
output: schema.string(),
|
|
495
|
+
metadata: schema.union([
|
|
496
|
+
strictObject({
|
|
497
|
+
provider: schema.literal(NATIVE),
|
|
498
|
+
format: formatSchema,
|
|
499
|
+
status: schema.number().int(),
|
|
500
|
+
}),
|
|
501
|
+
strictObject({
|
|
502
|
+
provider: schema.literal(SPIDER),
|
|
503
|
+
format: formatSchema,
|
|
504
|
+
credentialSource: credentialSourceSchema,
|
|
505
|
+
status: schema.number().int().optional(),
|
|
506
|
+
durationMs: schema.number().optional(),
|
|
507
|
+
}),
|
|
508
|
+
strictObject({
|
|
509
|
+
provider: schema.literal(ZAI_FETCH),
|
|
510
|
+
region: regionSchema,
|
|
511
|
+
format: formatSchema,
|
|
512
|
+
credentialSource: credentialSourceSchema,
|
|
513
|
+
}),
|
|
514
|
+
]),
|
|
515
|
+
attachments: schema.array(ownedToolAttachmentSchema).min(1),
|
|
516
|
+
});
|
|
517
|
+
/** Closed fetch result envelope union for producer/test checks. */
|
|
518
|
+
export const webFetchResultSchema = schema.union([
|
|
519
|
+
webFetchTextResultSchema,
|
|
520
|
+
webFetchMediaResultSchema,
|
|
521
|
+
]);
|
|
522
|
+
// END_BLOCK_RESULT_SCHEMAS
|
|
523
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../src/plugins/web-tools/schemas.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,iBAAiB;AACjB,wBAAwB;AACxB,sYAAsY;AACtY,kcAAkc;AAClc,gFAAgF;AAChF,kGAAkG;AAClG,kBAAkB;AAClB,sBAAsB;AACtB,sBAAsB;AACtB,EAAE;AACF,mBAAmB;AACnB,6EAA6E;AAC7E,2EAA2E;AAC3E,iEAAiE;AACjE,+DAA+D;AAC/D,oFAAoF;AACpF,oDAAoD;AACpD,4DA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derSearchMarkdown(results: WebSearchResult[]): string;
|
|
10
10
|
/**
|
|
11
11
|
* Create the web_search tool bound to the resolved search configuration.
|
|
12
|
-
* execute
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* execute validates raw host-forwarded arguments through the shared strict contract first,
|
|
13
|
+
* so unknown keys, invalid provided values, and out-of-range counts reject with a bounded
|
|
14
|
+
* diagnostic before any permission request, credential lookup, or provider dispatch.
|
|
15
|
+
* The documented count default is re-applied here because the host forwards unparsed raw
|
|
16
|
+
* arguments. Permission uses key web_search with patterns [query], and the result reports
|
|
17
|
+
* metadata { provider, region?, resultCount, credentialSource }.
|
|
15
18
|
* Missing credentials raise an actionable error naming the environment variable
|
|
16
19
|
* and the web.search.apiKey config field without printing any value.
|
|
17
20
|
*/
|