@osovv/vv-opencode 1.4.5 → 1.6.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 +23 -0
- package/README.md +47 -16
- package/dist/commands/patch-provider.d.ts +5 -5
- package/dist/commands/patch-provider.js +10 -6
- package/dist/commands/patch-provider.js.map +1 -1
- 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/opencode/agent-registrations.d.ts +33 -0
- package/dist/lib/opencode/agent-registrations.js +469 -0
- package/dist/lib/opencode/agent-registrations.js.map +1 -0
- package/dist/lib/opencode/inspection.d.ts +84 -0
- package/dist/lib/opencode/inspection.js +367 -0
- package/dist/lib/opencode/inspection.js.map +1 -0
- package/dist/lib/opencode/model-overrides.d.ts +19 -0
- package/dist/lib/opencode/model-overrides.js +221 -0
- package/dist/lib/opencode/model-overrides.js.map +1 -0
- package/dist/lib/opencode/paths.d.ts +21 -0
- package/dist/lib/opencode/paths.js +62 -0
- package/dist/lib/opencode/paths.js.map +1 -0
- package/dist/lib/opencode/plugin-registration.d.ts +17 -0
- package/dist/lib/opencode/plugin-registration.js +210 -0
- package/dist/lib/opencode/plugin-registration.js.map +1 -0
- package/dist/lib/opencode/shared-utils.d.ts +30 -0
- package/dist/lib/opencode/shared-utils.js +183 -0
- package/dist/lib/opencode/shared-utils.js.map +1 -0
- package/dist/lib/opencode/vvoc-config-io.d.ts +9 -0
- package/dist/lib/opencode/vvoc-config-io.js +58 -0
- package/dist/lib/opencode/vvoc-config-io.js.map +1 -0
- package/dist/lib/opencode.d.ts +15 -174
- package/dist/lib/opencode.js +19 -1387
- package/dist/lib/opencode.js.map +1 -1
- package/dist/lib/spec-lint/cross-file-rules.d.ts +2 -0
- package/dist/lib/spec-lint/cross-file-rules.js +33 -0
- package/dist/lib/spec-lint/cross-file-rules.js.map +1 -0
- package/dist/lib/spec-lint/delegated-extraction.d.ts +8 -0
- package/dist/lib/spec-lint/delegated-extraction.js +112 -0
- package/dist/lib/spec-lint/delegated-extraction.js.map +1 -0
- package/dist/lib/spec-lint/lint.d.ts +7 -0
- package/dist/lib/spec-lint/lint.js +92 -0
- package/dist/lib/spec-lint/lint.js.map +1 -0
- package/dist/lib/spec-lint/parser.d.ts +101 -0
- package/dist/lib/spec-lint/parser.js +482 -0
- package/dist/lib/spec-lint/parser.js.map +1 -0
- package/dist/lib/spec-lint/plan-rules.d.ts +38 -0
- package/dist/lib/spec-lint/plan-rules.js +745 -0
- package/dist/lib/spec-lint/plan-rules.js.map +1 -0
- package/dist/lib/spec-lint/spec-rules.d.ts +8 -0
- package/dist/lib/spec-lint/spec-rules.js +188 -0
- package/dist/lib/spec-lint/spec-rules.js.map +1 -0
- package/dist/lib/spec-lint.d.ts +4 -63
- package/dist/lib/spec-lint.js +13 -1505
- package/dist/lib/spec-lint.js.map +1 -1
- package/dist/lib/vvoc-preset-registry.d.ts +7 -7
- package/dist/lib/vvoc-preset-registry.js +8 -8
- package/dist/lib/vvoc-preset-registry.js.map +1 -1
- 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/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.d.ts +30 -0
- package/dist/plugins/workflow/authorization.js +147 -0
- package/dist/plugins/workflow/authorization.js.map +1 -0
- 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 +197 -435
- 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 +18 -0
- package/dist/plugins/workflow/recovery.js +217 -0
- package/dist/plugins/workflow/recovery.js.map +1 -0
- 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 +398 -0
- package/dist/plugins/workflow/schemas.js +399 -0
- package/dist/plugins/workflow/schemas.js.map +1 -0
- 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 +11 -82
- package/dist/plugins/workflow/tooling.js +478 -461
- 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-implementer.md +16 -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,407 @@
|
|
|
1
|
+
// FILE: src/lib/agent-tool-contract.ts
|
|
2
|
+
// VERSION: 1.1.0
|
|
3
|
+
// START_MODULE_CONTRACT
|
|
4
|
+
// PURPOSE: Provide reusable cross-plugin agent-tool contract primitives: registered raw argument maps, strict full-object runtime schemas with output inference, bounded diagnostics, fail-closed definition/pre-execute/direct-execute guards, SDK-compatible result-envelope helpers, and loaded contract identity.
|
|
5
|
+
// SCOPE: Generic owned-tool contract descriptors and host-boundary adapters only. No catalog aggregation, no workflow/plugin runtime imports, no permission or state-eligibility decisions. Uses the pinned SDK tool.schema Zod instance; zod imports are type-only. Result-envelope validation is producer/test-only and never wraps post-side-effect execution.
|
|
6
|
+
// DEPENDS: [@opencode-ai/plugin, zod (types), src/lib/package.ts]
|
|
7
|
+
// LINKS: [M-AGENT-TOOL-CONTRACT]
|
|
8
|
+
// ROLE: RUNTIME
|
|
9
|
+
// MAP_MODE: EXPORTS
|
|
10
|
+
// END_MODULE_CONTRACT
|
|
11
|
+
//
|
|
12
|
+
// START_MODULE_MAP
|
|
13
|
+
// AGENT_TOOL_CONTRACT_REVISION - Public tool-contract revision string for loaded identity.
|
|
14
|
+
// PACKAGE_NAME - Re-exported canonical package name from package.ts.
|
|
15
|
+
// PACKAGE_VERSION - Re-exported cached package version from package.ts.
|
|
16
|
+
// resolveToolContractReferencePath - Package-relative path to the tool-contracts reference document.
|
|
17
|
+
// MAX_CONTRACT_ISSUES - Maximum structural issues retained per diagnostic.
|
|
18
|
+
// MAX_ISSUE_PATH_CHARS - Maximum rendered issue path length.
|
|
19
|
+
// MAX_ISSUE_MESSAGE_CHARS - Maximum rendered issue message length.
|
|
20
|
+
// MAX_ISSUE_VALUE_CHARS - Maximum safe scalar preview length.
|
|
21
|
+
// ContractIssueCode - Stable machine-readable structural issue codes.
|
|
22
|
+
// ContractIssue - Bounded, tokenized structural issue with safe value/type summary.
|
|
23
|
+
// escapePathSegment - Escape one issue path segment for safe tokenized rendering.
|
|
24
|
+
// formatIssuePath - Render a Zod path tuple as a bounded, control-safe token path.
|
|
25
|
+
// summarizeReceivedValue - Safe bounded scalar/container value summary.
|
|
26
|
+
// toContractIssues - Convert a ZodError into bounded tokenized contract issues (preserves union branch paths).
|
|
27
|
+
// formatContractIssues - Render issues as a bounded single-line explanation.
|
|
28
|
+
// ContractInputError - Pre-execution structural rejection with code, category, and issues.
|
|
29
|
+
// ContractHostCompatibilityError - Fail-closed host-context rejection for unsupported definition publication.
|
|
30
|
+
// OperationExample - Named accept/reject operation example metadata for a contract.
|
|
31
|
+
// OwnedToolResult - Object branch of the pinned SDK ToolResult (assignable through tool execute).
|
|
32
|
+
// OwnedToolAttachment - Pinned SDK ToolAttachment shape.
|
|
33
|
+
// ownedToolResult - Build an SDK-compatible structured tool result envelope.
|
|
34
|
+
// ownedToolAttachmentSchema - Strict attachment envelope schema for producer/test validation.
|
|
35
|
+
// ownedToolResultSchema - Strict result envelope schema; metadata/document content remain opaque.
|
|
36
|
+
// validateOwnedToolResult - Producer/test-only result envelope validation (no post-side-effect wrapper).
|
|
37
|
+
// strictObject - Build a closed object schema on the SDK tool.schema instance.
|
|
38
|
+
// contractInputJsonSchema - Input-mode JSON Schema projection for a contract schema.
|
|
39
|
+
// OwnedToolArgs - Schema-inferred argument type for an owned-tool registered map.
|
|
40
|
+
// OwnedToolContract - Registered raw map plus strict runtime schema and typed parse helpers.
|
|
41
|
+
// defineOwnedToolContract - Define a closed owned-tool contract from a raw argument map.
|
|
42
|
+
// parseOwnedToolArgs - Direct-execute parse returning schema-inferred output (defaults applied).
|
|
43
|
+
// ToolDefinitionHookOutput - Narrow structural view of the SDK tool.definition hook output.
|
|
44
|
+
// createToolDefinitionAdapter - Owned-only fail-closed tool.definition adapter publishing strict jsonSchema while preserving parameters identity.
|
|
45
|
+
// createPreExecuteGuard - Owned-only tool.execute.before structural guard that never mutates raw args.
|
|
46
|
+
// END_MODULE_MAP
|
|
47
|
+
//
|
|
48
|
+
// START_CHANGE_SUMMARY
|
|
49
|
+
// LAST_CHANGE: [C-AGENT-TOOL-CONTRACTS - Correction cycle: fail-closed definition publication, Zod output inference end-to-end, SDK-compatible result envelope + producer validation schema, escaped diagnostic paths, and preserved nested union issue paths.]
|
|
50
|
+
// END_CHANGE_SUMMARY
|
|
51
|
+
import { tool } from "@opencode-ai/plugin";
|
|
52
|
+
import { join } from "node:path";
|
|
53
|
+
import { fileURLToPath } from "node:url";
|
|
54
|
+
import { PACKAGE_NAME, PACKAGE_VERSION } from "./package.js";
|
|
55
|
+
export { PACKAGE_NAME, PACKAGE_VERSION };
|
|
56
|
+
// START_BLOCK_CONTRACT_IDENTITY
|
|
57
|
+
/** Public tool-contract revision; independent of persistence and workflow contract versions. */
|
|
58
|
+
export const AGENT_TOOL_CONTRACT_REVISION = "1";
|
|
59
|
+
const TOOL_CONTRACT_REFERENCE_PACKAGE_PATH = "templates/skills/vv-execute/references/tool-contracts.md";
|
|
60
|
+
/**
|
|
61
|
+
* Resolve the package-relative path to the shipped tool-contracts reference document.
|
|
62
|
+
* Uses the loaded module location, not global installs or user config.
|
|
63
|
+
*/
|
|
64
|
+
export function resolveToolContractReferencePath() {
|
|
65
|
+
const packageRoot = fileURLToPath(new URL("../../", import.meta.url));
|
|
66
|
+
return join(packageRoot, TOOL_CONTRACT_REFERENCE_PACKAGE_PATH);
|
|
67
|
+
}
|
|
68
|
+
// END_BLOCK_CONTRACT_IDENTITY
|
|
69
|
+
// START_BLOCK_ISSUES
|
|
70
|
+
/** Maximum number of structural issues retained in one diagnostic. */
|
|
71
|
+
export const MAX_CONTRACT_ISSUES = 8;
|
|
72
|
+
/** Maximum rendered path length in characters. */
|
|
73
|
+
export const MAX_ISSUE_PATH_CHARS = 120;
|
|
74
|
+
/** Maximum rendered message length in characters. */
|
|
75
|
+
export const MAX_ISSUE_MESSAGE_CHARS = 200;
|
|
76
|
+
/** Maximum safe scalar preview length in characters. */
|
|
77
|
+
export const MAX_ISSUE_VALUE_CHARS = 48;
|
|
78
|
+
function truncateChars(value, max) {
|
|
79
|
+
if (value.length <= max)
|
|
80
|
+
return value;
|
|
81
|
+
return `${value.slice(0, Math.max(0, max - 1))}…`;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Escape one path segment so user-controlled keys cannot inject control characters
|
|
85
|
+
* or forge ambiguous dotted/bracketed paths.
|
|
86
|
+
*/
|
|
87
|
+
export function escapePathSegment(segment) {
|
|
88
|
+
let escaped = "";
|
|
89
|
+
for (const character of segment) {
|
|
90
|
+
const code = character.codePointAt(0) ?? 0;
|
|
91
|
+
if (code < 0x20 || code === 0x7f) {
|
|
92
|
+
escaped += `\\u${code.toString(16).padStart(4, "0")}`;
|
|
93
|
+
}
|
|
94
|
+
else if (character === "\\" || character === "." || character === "[" || character === "]") {
|
|
95
|
+
escaped += `\\${character}`;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
escaped += character;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return escaped;
|
|
102
|
+
}
|
|
103
|
+
/** Render a Zod path tuple as a bounded dotted/bracketed token path with escaped segments. */
|
|
104
|
+
export function formatIssuePath(path) {
|
|
105
|
+
let rendered = "";
|
|
106
|
+
for (const segment of path) {
|
|
107
|
+
if (typeof segment === "number") {
|
|
108
|
+
rendered += `[${segment}]`;
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
const token = escapePathSegment(typeof segment === "symbol" ? segment.toString() : segment);
|
|
112
|
+
rendered = rendered ? `${rendered}.${token}` : token;
|
|
113
|
+
}
|
|
114
|
+
if (rendered.length >= MAX_ISSUE_PATH_CHARS) {
|
|
115
|
+
return truncateChars(rendered, MAX_ISSUE_PATH_CHARS);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return rendered || "(root)";
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Build a safe, bounded received-value summary.
|
|
122
|
+
* Scalars get a short preview; containers get a type name only — never a payload echo.
|
|
123
|
+
*/
|
|
124
|
+
export function summarizeReceivedValue(value) {
|
|
125
|
+
if (value === null)
|
|
126
|
+
return "null";
|
|
127
|
+
if (value === undefined)
|
|
128
|
+
return "undefined";
|
|
129
|
+
if (typeof value === "string") {
|
|
130
|
+
return truncateChars(JSON.stringify(value), MAX_ISSUE_VALUE_CHARS);
|
|
131
|
+
}
|
|
132
|
+
if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
|
|
133
|
+
return truncateChars(String(value), MAX_ISSUE_VALUE_CHARS);
|
|
134
|
+
}
|
|
135
|
+
if (Array.isArray(value))
|
|
136
|
+
return "array";
|
|
137
|
+
if (typeof value === "object")
|
|
138
|
+
return "object";
|
|
139
|
+
return truncateChars(String(value), MAX_ISSUE_VALUE_CHARS);
|
|
140
|
+
}
|
|
141
|
+
function issueCodeOf(code) {
|
|
142
|
+
switch (code) {
|
|
143
|
+
case "unrecognized_keys":
|
|
144
|
+
case "invalid_value":
|
|
145
|
+
case "invalid_type":
|
|
146
|
+
case "invalid_format":
|
|
147
|
+
case "too_small":
|
|
148
|
+
case "too_big":
|
|
149
|
+
case "missing_value":
|
|
150
|
+
case "invalid_union":
|
|
151
|
+
case "custom":
|
|
152
|
+
return code;
|
|
153
|
+
default:
|
|
154
|
+
return "custom";
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function pushConcreteIssue(issues, raw, basePath) {
|
|
158
|
+
if (issues.length >= MAX_CONTRACT_ISSUES)
|
|
159
|
+
return;
|
|
160
|
+
const code = issueCodeOf(raw.code);
|
|
161
|
+
if (raw.code === "unrecognized_keys" && Array.isArray(raw.keys)) {
|
|
162
|
+
for (const key of raw.keys) {
|
|
163
|
+
if (issues.length >= MAX_CONTRACT_ISSUES)
|
|
164
|
+
break;
|
|
165
|
+
issues.push({
|
|
166
|
+
code: "unrecognized_keys",
|
|
167
|
+
path: formatIssuePath([...basePath, String(key)]),
|
|
168
|
+
message: truncateChars(`unrecognized key ${JSON.stringify(truncateChars(String(key), MAX_ISSUE_VALUE_CHARS))}`, MAX_ISSUE_MESSAGE_CHARS),
|
|
169
|
+
expected: "a known property of this request object",
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const expected = Array.isArray(raw.values) && raw.values.length > 0
|
|
175
|
+
? truncateChars(raw.values.map((value) => summarizeReceivedValue(value)).join(" | "), MAX_ISSUE_MESSAGE_CHARS)
|
|
176
|
+
: raw.code === "invalid_type" && raw.expected !== undefined
|
|
177
|
+
? truncateChars(String(raw.expected), MAX_ISSUE_MESSAGE_CHARS)
|
|
178
|
+
: undefined;
|
|
179
|
+
const received = raw.code === "invalid_type" && raw.received !== undefined
|
|
180
|
+
? truncateChars(String(raw.received), MAX_ISSUE_VALUE_CHARS)
|
|
181
|
+
: undefined;
|
|
182
|
+
issues.push({
|
|
183
|
+
code,
|
|
184
|
+
path: formatIssuePath(basePath),
|
|
185
|
+
message: truncateChars(raw.message ?? "invalid value", MAX_ISSUE_MESSAGE_CHARS),
|
|
186
|
+
...(expected !== undefined ? { expected } : {}),
|
|
187
|
+
...(received !== undefined ? { received } : {}),
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
function pushIssueTree(issues, rawList, prefix) {
|
|
191
|
+
for (const raw of rawList) {
|
|
192
|
+
if (issues.length >= MAX_CONTRACT_ISSUES)
|
|
193
|
+
return;
|
|
194
|
+
const basePath = [...prefix, ...(raw.path ?? [])];
|
|
195
|
+
if (raw.code === "invalid_union" && Array.isArray(raw.errors) && raw.errors.length > 0) {
|
|
196
|
+
// Preserve nested union/discriminator branch paths (e.g. source.reference, source.kind).
|
|
197
|
+
for (const branch of raw.errors) {
|
|
198
|
+
pushIssueTree(issues, branch, basePath);
|
|
199
|
+
if (issues.length >= MAX_CONTRACT_ISSUES)
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
pushConcreteIssue(issues, raw, basePath);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Convert a ZodError into bounded tokenized contract issues.
|
|
209
|
+
* Unknown keys become precise leaf paths; union branch paths are preserved;
|
|
210
|
+
* values are summarized, not echoed wholesale.
|
|
211
|
+
*/
|
|
212
|
+
export function toContractIssues(error) {
|
|
213
|
+
const issues = [];
|
|
214
|
+
pushIssueTree(issues, error.issues, []);
|
|
215
|
+
return issues;
|
|
216
|
+
}
|
|
217
|
+
/** Render issues as one bounded single-line explanation suitable for host tool errors. */
|
|
218
|
+
export function formatContractIssues(issues) {
|
|
219
|
+
if (issues.length === 0)
|
|
220
|
+
return "INVALID_INPUT: structural validation failed";
|
|
221
|
+
const parts = issues.map((issue) => {
|
|
222
|
+
const path = issue.path || "(root)";
|
|
223
|
+
const expected = issue.expected ? `; expected ${issue.expected}` : "";
|
|
224
|
+
const received = issue.received ? `; received ${issue.received}` : "";
|
|
225
|
+
return truncateChars(`${path}: ${issue.message}${expected}${received}`, MAX_ISSUE_MESSAGE_CHARS);
|
|
226
|
+
});
|
|
227
|
+
return truncateChars(`INVALID_INPUT: ${parts.join(" | ")}`, MAX_ISSUE_MESSAGE_CHARS * (MAX_CONTRACT_ISSUES + 1));
|
|
228
|
+
}
|
|
229
|
+
/** Pre-execution structural rejection for owned tools. Not a permission or state decision. */
|
|
230
|
+
export class ContractInputError extends Error {
|
|
231
|
+
code = "INVALID_INPUT";
|
|
232
|
+
category = "input";
|
|
233
|
+
toolId;
|
|
234
|
+
issues;
|
|
235
|
+
constructor(toolId, issues) {
|
|
236
|
+
super(formatContractIssues(issues));
|
|
237
|
+
this.name = "ContractInputError";
|
|
238
|
+
this.toolId = toolId;
|
|
239
|
+
this.issues = issues;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Fail-closed host-context rejection when an owned tool cannot publish its contract
|
|
244
|
+
* through the host tool.definition seam. Never mutates the hook output before throwing.
|
|
245
|
+
*/
|
|
246
|
+
export class ContractHostCompatibilityError extends Error {
|
|
247
|
+
code = "HOST_CONTRACT_UNSUPPORTED";
|
|
248
|
+
category = "host_context";
|
|
249
|
+
toolId;
|
|
250
|
+
reason;
|
|
251
|
+
constructor(toolId, reason) {
|
|
252
|
+
super(truncateChars(`HOST_CONTRACT_UNSUPPORTED: tool=${escapePathSegment(toolId)}; ${reason}`, MAX_ISSUE_MESSAGE_CHARS));
|
|
253
|
+
this.name = "ContractHostCompatibilityError";
|
|
254
|
+
this.toolId = toolId;
|
|
255
|
+
this.reason = truncateChars(reason, MAX_ISSUE_MESSAGE_CHARS);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Build a structured tool result envelope compatible with the pinned SDK ToolResult.
|
|
260
|
+
* Empty output and empty metadata remain valid for consumers that need them.
|
|
261
|
+
*/
|
|
262
|
+
export function ownedToolResult(output, init) {
|
|
263
|
+
return {
|
|
264
|
+
...(init?.title !== undefined ? { title: init.title } : {}),
|
|
265
|
+
output,
|
|
266
|
+
...(init?.metadata !== undefined ? { metadata: init.metadata } : {}),
|
|
267
|
+
...(init?.attachments !== undefined ? { attachments: init.attachments } : {}),
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
/** Closed object schema on the SDK tool.schema instance (rejects unknown keys). */
|
|
271
|
+
export function strictObject(shape) {
|
|
272
|
+
return tool.schema.strictObject(shape);
|
|
273
|
+
}
|
|
274
|
+
/** Attachment envelope schema for producer/test validation of owned tool results. */
|
|
275
|
+
export const ownedToolAttachmentSchema = strictObject({
|
|
276
|
+
type: tool.schema.literal("file"),
|
|
277
|
+
mime: tool.schema.string(),
|
|
278
|
+
url: tool.schema.string(),
|
|
279
|
+
filename: tool.schema.string().optional(),
|
|
280
|
+
});
|
|
281
|
+
/**
|
|
282
|
+
* Strict result-envelope schema for producer/test checks.
|
|
283
|
+
* `metadata` and nested document/binary content are declared opaque extension regions
|
|
284
|
+
* (record/unknown or declared opaque fields), not re-validated payload shapes.
|
|
285
|
+
* This is never applied as a throw-after-side-effect execute wrapper.
|
|
286
|
+
*/
|
|
287
|
+
export const ownedToolResultSchema = strictObject({
|
|
288
|
+
title: tool.schema.string().optional(),
|
|
289
|
+
output: tool.schema.string(),
|
|
290
|
+
metadata: tool.schema.record(tool.schema.string(), tool.schema.unknown()).optional(),
|
|
291
|
+
attachments: tool.schema.array(ownedToolAttachmentSchema).optional(),
|
|
292
|
+
});
|
|
293
|
+
/**
|
|
294
|
+
* Producer/test-only validation of a structured result envelope.
|
|
295
|
+
* Returns typed output on success; structural issues on failure.
|
|
296
|
+
* Do not call this after irreversible side effects as a gate that invites replay.
|
|
297
|
+
*/
|
|
298
|
+
export function validateOwnedToolResult(value) {
|
|
299
|
+
const result = ownedToolResultSchema.safeParse(value);
|
|
300
|
+
if (result.success) {
|
|
301
|
+
return { success: true, data: result.data };
|
|
302
|
+
}
|
|
303
|
+
return { success: false, issues: toContractIssues(result.error) };
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Project a contract schema to its input-mode JSON Schema.
|
|
307
|
+
* Consistent with the host registry projection (io: "input", $defs → definitions).
|
|
308
|
+
*/
|
|
309
|
+
export function contractInputJsonSchema(schema) {
|
|
310
|
+
const projected = tool.schema.toJSONSchema(schema, { io: "input" });
|
|
311
|
+
if (typeof projected !== "object" || projected === null || Array.isArray(projected)) {
|
|
312
|
+
throw new Error("contract schema produced a non-object JSON Schema");
|
|
313
|
+
}
|
|
314
|
+
const record = projected;
|
|
315
|
+
const { $defs, ...rest } = record;
|
|
316
|
+
if (typeof $defs === "object" && $defs !== null && !Array.isArray($defs)) {
|
|
317
|
+
return { ...rest, definitions: $defs };
|
|
318
|
+
}
|
|
319
|
+
return rest;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Define an owned-tool contract from the same raw argument map used for SDK registration.
|
|
323
|
+
* The runtime schema is a strict full-object validator over that map; nested closedness
|
|
324
|
+
* comes from composing nested shapes with strictObject. Unknown keys are never coerced or filtered.
|
|
325
|
+
*/
|
|
326
|
+
export function defineOwnedToolContract(init) {
|
|
327
|
+
const runtimeSchema = strictObject(init.registeredArgs);
|
|
328
|
+
const inputJsonSchema = contractInputJsonSchema(runtimeSchema);
|
|
329
|
+
const examples = init.examples ?? [];
|
|
330
|
+
return {
|
|
331
|
+
toolId: init.toolId,
|
|
332
|
+
description: init.description,
|
|
333
|
+
registeredArgs: init.registeredArgs,
|
|
334
|
+
runtimeSchema,
|
|
335
|
+
inputJsonSchema,
|
|
336
|
+
examples,
|
|
337
|
+
safeParse(raw) {
|
|
338
|
+
const result = runtimeSchema.safeParse(raw);
|
|
339
|
+
if (result.success) {
|
|
340
|
+
return { success: true, data: result.data };
|
|
341
|
+
}
|
|
342
|
+
return { success: false, issues: toContractIssues(result.error) };
|
|
343
|
+
},
|
|
344
|
+
parse(raw) {
|
|
345
|
+
const result = runtimeSchema.safeParse(raw);
|
|
346
|
+
if (result.success)
|
|
347
|
+
return result.data;
|
|
348
|
+
throw new ContractInputError(init.toolId, toContractIssues(result.error));
|
|
349
|
+
},
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Direct-execute validation: parse raw (host-forwarded) args through the contract schema,
|
|
354
|
+
* applying schema defaults/canonicalization for execute to consume.
|
|
355
|
+
* Returns the schema-inferred output type (defaults and enum literals preserved).
|
|
356
|
+
*/
|
|
357
|
+
export function parseOwnedToolArgs(contract, rawArgs) {
|
|
358
|
+
return contract.parse(rawArgs);
|
|
359
|
+
}
|
|
360
|
+
function isDefinitionHookOutput(value) {
|
|
361
|
+
return (typeof value === "object" && value !== null && "parameters" in value && "description" in value);
|
|
362
|
+
}
|
|
363
|
+
function hasJsonSchemaMember(value) {
|
|
364
|
+
return "jsonSchema" in value;
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Owned-only tool.definition adapter (fail-closed).
|
|
368
|
+
* Publishes the strict input-mode jsonSchema through the host's observable jsonSchema member
|
|
369
|
+
* while preserving parameters identity (the host decoder is never replaced).
|
|
370
|
+
* For owned tool IDs, an unsupported host shape (malformed output or missing jsonSchema member)
|
|
371
|
+
* throws ContractHostCompatibilityError without mutating the output.
|
|
372
|
+
* Unowned tool IDs are left untouched.
|
|
373
|
+
*/
|
|
374
|
+
export function createToolDefinitionAdapter(contracts) {
|
|
375
|
+
const byId = new Map(contracts.map((contract) => [contract.toolId, contract]));
|
|
376
|
+
return async function toolDefinitionAdapter(input, output) {
|
|
377
|
+
const contract = byId.get(input.toolID);
|
|
378
|
+
if (!contract)
|
|
379
|
+
return;
|
|
380
|
+
if (!isDefinitionHookOutput(output)) {
|
|
381
|
+
throw new ContractHostCompatibilityError(contract.toolId, "malformed tool.definition output: missing required description/parameters members");
|
|
382
|
+
}
|
|
383
|
+
if (!hasJsonSchemaMember(output)) {
|
|
384
|
+
throw new ContractHostCompatibilityError(contract.toolId, "unsupported host tool.definition shape: missing jsonSchema member required for strict publication");
|
|
385
|
+
}
|
|
386
|
+
output.jsonSchema = contract.inputJsonSchema;
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Owned-only pre-execute structural guard for tool.execute.before.
|
|
391
|
+
* Inspects raw args and throws ContractInputError on structural failure.
|
|
392
|
+
* Never mutates output.args and never confers state/permission eligibility.
|
|
393
|
+
*/
|
|
394
|
+
export function createPreExecuteGuard(contracts) {
|
|
395
|
+
const byId = new Map(contracts.map((contract) => [contract.toolId, contract]));
|
|
396
|
+
return async function preExecuteGuard(input, output) {
|
|
397
|
+
const contract = byId.get(input.tool);
|
|
398
|
+
if (!contract)
|
|
399
|
+
return;
|
|
400
|
+
const result = contract.runtimeSchema.safeParse(output.args);
|
|
401
|
+
if (!result.success) {
|
|
402
|
+
throw new ContractInputError(contract.toolId, toContractIssues(result.error));
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
// END_BLOCK_HOST_ADAPTERS
|
|
407
|
+
//# sourceMappingURL=agent-tool-contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-tool-contract.js","sourceRoot":"","sources":["../../src/lib/agent-tool-contract.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,iBAAiB;AACjB,wBAAwB;AACxB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H,MAAM,UAAU,qBAAqB,CACnC,SAAoD;IAEpD,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC/E,OAAO,KAAK,UAAU,eAAe,CAAC,KAAK,EAAE,MAAM;QACjD,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,QAAQ;YAAE,OAAO;QACtB,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC7D,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,MAAM,IAAI,kBAAkB,CAAC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAChF,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AACD,0BAA0B"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type ManagedOpenCodeAgentName } from "../managed-agents.js";
|
|
2
|
+
import { type JsonObject, type WriteResult } from "./shared-utils.js";
|
|
3
|
+
import type { ResolvedPaths } from "./paths.js";
|
|
4
|
+
export type ManagedAgentModelMap = Record<ManagedOpenCodeAgentName, string | undefined>;
|
|
5
|
+
export type ManagedAgentOverrideMap = Record<ManagedOpenCodeAgentName, {
|
|
6
|
+
model?: string;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function ensureManagedAgentRegistrationsConfigText(text: string | undefined, paths: Pick<ResolvedPaths, "managedAgentsDirPath" | "managedSkillsDirPath" | "opencodeConfigPath">): string;
|
|
9
|
+
export declare function syncManagedAgentRegistrations(paths: ResolvedPaths): Promise<{
|
|
10
|
+
path: string;
|
|
11
|
+
changed: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
export declare function installManagedAgentPrompts(paths: ResolvedPaths, options: {
|
|
14
|
+
force: boolean;
|
|
15
|
+
}): Promise<WriteResult[]>;
|
|
16
|
+
export declare function syncManagedAgentPrompts(paths: ResolvedPaths, options: {
|
|
17
|
+
force: boolean;
|
|
18
|
+
}): Promise<WriteResult[]>;
|
|
19
|
+
export declare function installManagedSkillFiles(paths: ResolvedPaths, options: {
|
|
20
|
+
force: boolean;
|
|
21
|
+
}): Promise<WriteResult[]>;
|
|
22
|
+
export declare function syncManagedSkillFiles(paths: ResolvedPaths, options: {
|
|
23
|
+
force: boolean;
|
|
24
|
+
}): Promise<WriteResult[]>;
|
|
25
|
+
export declare function ensureManagedSkillSymlink(configDir?: string): Promise<WriteResult>;
|
|
26
|
+
export declare function readManagedAgentModels(paths: Pick<ResolvedPaths, "opencodeConfigPath">): Promise<ManagedAgentModelMap>;
|
|
27
|
+
export declare function readManagedAgentOverrides(paths: Pick<ResolvedPaths, "opencodeConfigPath">): Promise<ManagedAgentOverrideMap>;
|
|
28
|
+
export declare function writeManagedAgentModel(paths: Pick<ResolvedPaths, "managedAgentsDirPath" | "managedSkillsDirPath" | "opencodeConfigPath">, agentName: ManagedOpenCodeAgentName, options: {
|
|
29
|
+
model?: string;
|
|
30
|
+
ensureEntry: boolean;
|
|
31
|
+
}): Promise<WriteResult>;
|
|
32
|
+
export declare function readAgentMap(document: JsonObject, label: string): Record<string, JsonObject>;
|
|
33
|
+
export declare function ensureAgentConfigText(text: string | undefined): string;
|