@osovv/vv-opencode 1.7.0 → 2.0.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 +25 -0
- package/README.md +22 -2
- package/dist/commands/preset.js +1 -1
- package/dist/commands/preset.js.map +1 -1
- package/dist/index.d.ts +7 -11
- package/dist/index.js +53 -20
- package/dist/index.js.map +1 -1
- package/dist/plugins/analytics/index.d.ts +2 -0
- package/dist/plugins/analytics/index.js +13 -2
- package/dist/plugins/analytics/index.js.map +1 -1
- package/dist/plugins/analytics/v2.d.ts +21 -0
- package/dist/plugins/analytics/v2.js +133 -0
- package/dist/plugins/analytics/v2.js.map +1 -0
- package/dist/plugins/guardian/index.d.ts +46 -0
- package/dist/plugins/guardian/index.js +21 -6
- package/dist/plugins/guardian/index.js.map +1 -1
- package/dist/plugins/guardian/v2.d.ts +13 -0
- package/dist/plugins/guardian/v2.js +161 -0
- package/dist/plugins/guardian/v2.js.map +1 -0
- package/dist/plugins/hashline-edit/index.d.ts +33 -1
- package/dist/plugins/hashline-edit/index.js +38 -14
- package/dist/plugins/hashline-edit/index.js.map +1 -1
- package/dist/plugins/hashline-edit/schemas.d.ts +7 -7
- package/dist/plugins/hashline-edit/v2.d.ts +12 -0
- package/dist/plugins/hashline-edit/v2.js +145 -0
- package/dist/plugins/hashline-edit/v2.js.map +1 -0
- package/dist/plugins/model-roles/index.d.ts +2 -0
- package/dist/plugins/model-roles/index.js +13 -2
- package/dist/plugins/model-roles/index.js.map +1 -1
- package/dist/plugins/model-roles/v2.d.ts +24 -0
- package/dist/plugins/model-roles/v2.js +274 -0
- package/dist/plugins/model-roles/v2.js.map +1 -0
- package/dist/plugins/peak-hours/index.d.ts +2 -0
- package/dist/plugins/peak-hours/index.js +13 -2
- package/dist/plugins/peak-hours/index.js.map +1 -1
- package/dist/plugins/peak-hours/v2.d.ts +12 -0
- package/dist/plugins/peak-hours/v2.js +95 -0
- package/dist/plugins/peak-hours/v2.js.map +1 -0
- package/dist/plugins/secrets-redaction/index.d.ts +7 -0
- package/dist/plugins/secrets-redaction/index.js +17 -4
- package/dist/plugins/secrets-redaction/index.js.map +1 -1
- package/dist/plugins/secrets-redaction/v2.d.ts +14 -0
- package/dist/plugins/secrets-redaction/v2.js +100 -0
- package/dist/plugins/secrets-redaction/v2.js.map +1 -0
- package/dist/plugins/spec-guard/index.d.ts +2 -0
- package/dist/plugins/spec-guard/index.js +13 -2
- package/dist/plugins/spec-guard/index.js.map +1 -1
- package/dist/plugins/spec-guard/v2.d.ts +12 -0
- package/dist/plugins/spec-guard/v2.js +139 -0
- package/dist/plugins/spec-guard/v2.js.map +1 -0
- package/dist/plugins/system-context-injection/agent-contexts.d.ts +5 -0
- package/dist/plugins/system-context-injection/agent-contexts.js +164 -0
- package/dist/plugins/system-context-injection/agent-contexts.js.map +1 -0
- package/dist/plugins/system-context-injection/index.d.ts +2 -0
- package/dist/plugins/system-context-injection/index.js +16 -146
- package/dist/plugins/system-context-injection/index.js.map +1 -1
- package/dist/plugins/system-context-injection/v2.d.ts +13 -0
- package/dist/plugins/system-context-injection/v2.js +60 -0
- package/dist/plugins/system-context-injection/v2.js.map +1 -0
- package/dist/plugins/tool-history-compaction/index.d.ts +2 -0
- package/dist/plugins/tool-history-compaction/index.js +13 -2
- package/dist/plugins/tool-history-compaction/index.js.map +1 -1
- package/dist/plugins/tool-history-compaction/v2.d.ts +11 -0
- package/dist/plugins/tool-history-compaction/v2.js +56 -0
- package/dist/plugins/tool-history-compaction/v2.js.map +1 -0
- package/dist/plugins/v2-runtime/config-watcher.d.ts +26 -0
- package/dist/plugins/v2-runtime/config-watcher.js +111 -0
- package/dist/plugins/v2-runtime/config-watcher.js.map +1 -0
- package/dist/plugins/v2-runtime/index.d.ts +50 -0
- package/dist/plugins/v2-runtime/index.js +114 -0
- package/dist/plugins/v2-runtime/index.js.map +1 -0
- package/dist/plugins/v2-runtime/location-config.d.ts +51 -0
- package/dist/plugins/v2-runtime/location-config.js +91 -0
- package/dist/plugins/v2-runtime/location-config.js.map +1 -0
- package/dist/plugins/v2-runtime/setup.d.ts +48 -0
- package/dist/plugins/v2-runtime/setup.js +174 -0
- package/dist/plugins/v2-runtime/setup.js.map +1 -0
- package/dist/plugins/web-tools/index.d.ts +2 -0
- package/dist/plugins/web-tools/index.js +13 -2
- package/dist/plugins/web-tools/index.js.map +1 -1
- package/dist/plugins/web-tools/v2.d.ts +11 -0
- package/dist/plugins/web-tools/v2.js +99 -0
- package/dist/plugins/web-tools/v2.js.map +1 -0
- package/dist/plugins/workflow/index.d.ts +2 -0
- package/dist/plugins/workflow/index.js +13 -2
- package/dist/plugins/workflow/index.js.map +1 -1
- package/dist/plugins/workflow/results.d.ts +16 -16
- package/dist/plugins/workflow/v2.d.ts +58 -0
- package/dist/plugins/workflow/v2.js +181 -0
- package/dist/plugins/workflow/v2.js.map +1 -0
- package/dist/tui.d.ts +1 -0
- package/dist/tui.js +41 -6
- package/dist/tui.js.map +1 -1
- package/package.json +13 -5
- package/schemas/vvoc/v3.json +1 -1
- package/server.js +7 -0
- package/templates/skills/vv-execute/references/tool-contracts.md +1 -1
- package/tui.js +7 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Plugin as V2Plugin } from "@opencode/plugin";
|
|
2
|
+
import type { Hooks, Plugin as V1Plugin, PluginInput, PluginOptions } from "@opencode-ai/plugin";
|
|
3
|
+
/**
|
|
4
|
+
* The v2 setup signature, including an optional cleanup return.
|
|
5
|
+
*/
|
|
6
|
+
export type V2Setup = (context: V2Plugin.Context) => Promise<V2Plugin.Cleanup | void> | V2Plugin.Cleanup | void;
|
|
7
|
+
/**
|
|
8
|
+
* A dual-runtime plugin entrypoint: the v2 Plugin shape (id + setup) plus the
|
|
9
|
+
* v1 object-entrypoint server() member. OpenCode v1 (>= 1.18.29) detects the
|
|
10
|
+
* default export through its id/server members and calls only server(); OpenCode
|
|
11
|
+
* v2 reads id and setup() and ignores server(). Neither runtime loads the other
|
|
12
|
+
* path, so a package exposing exactly this default export registers once.
|
|
13
|
+
*/
|
|
14
|
+
export type DualPlugin = V2Plugin.Plugin & {
|
|
15
|
+
server: V1Plugin;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Build the dual entrypoint for one plugin.
|
|
19
|
+
*
|
|
20
|
+
* The v1 factory keeps its original single-argument or two-argument signature
|
|
21
|
+
* and is wrapped verbatim as the server() member. The v2 setup receives the v2
|
|
22
|
+
* plugin context and may return nothing yet; later migration tasks attach the
|
|
23
|
+
* domain registrations.
|
|
24
|
+
*/
|
|
25
|
+
export declare function defineDualPlugin(definition: {
|
|
26
|
+
id: string;
|
|
27
|
+
v1: V1Plugin;
|
|
28
|
+
v2: V2Setup;
|
|
29
|
+
}): DualPlugin;
|
|
30
|
+
/**
|
|
31
|
+
* Merge multiple v1 hook objects into one hook object.
|
|
32
|
+
*
|
|
33
|
+
* The v1 runtime triggers each hook key across plugin entries sequentially in
|
|
34
|
+
* registration order, and calls dispose() on every entry in registration order
|
|
35
|
+
* at shutdown. Producing one merged object that chains every key sequentially
|
|
36
|
+
* and forwards dispose in registration order reproduces that behavior exactly
|
|
37
|
+
* while presenting the aggregator as a single plugin entry.
|
|
38
|
+
*
|
|
39
|
+
* Children that returned undefined or an object without the requested key are
|
|
40
|
+
* skipped for that key. An empty list produces an object with no hook members.
|
|
41
|
+
*/
|
|
42
|
+
export declare function mergeV1Hooks(entries: Array<Hooks | undefined>): Hooks;
|
|
43
|
+
/**
|
|
44
|
+
* Run v1 plugin factories sequentially and merge their hook objects.
|
|
45
|
+
*
|
|
46
|
+
* A factory that throws is logged and skipped so one failing plugin cannot take
|
|
47
|
+
* the remaining plugins offline, matching how the v1 runtime isolates plugin
|
|
48
|
+
* load failures across separate package entries.
|
|
49
|
+
*/
|
|
50
|
+
export declare function aggregateV1Plugins(factories: Array<V1Plugin>, input: PluginInput, options?: PluginOptions, onError?: (error: unknown, index: number) => void): Promise<Hooks>;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// FILE: src/plugins/v2-runtime/index.ts
|
|
2
|
+
// VERSION: 1.0.0
|
|
3
|
+
// START_MODULE_CONTRACT
|
|
4
|
+
// PURPOSE: Provide the dual-runtime plugin foundation that lets one package entrypoint serve OpenCode v1 (server() object entrypoints, >= 1.18.29) and OpenCode v2 (Plugin.define setup, >= 2.0.18) without double registration.
|
|
5
|
+
// SCOPE: Dual entrypoint construction with stable plugin ids, sequential v1 plugin aggregation with per-plugin error isolation, hook-object merging that preserves v1 trigger and dispose ordering, and the typed seams later tasks use to attach v2 domain registrations.
|
|
6
|
+
// DEPENDS: [@opencode/plugin, @opencode-ai/plugin]
|
|
7
|
+
// LINKS: [M-PLUGIN-V2-RUNTIME, V-M-PLUGIN-V2-RUNTIME, M-PLUGIN-GUARDIAN, M-PLUGIN-WORKFLOW]
|
|
8
|
+
// ROLE: RUNTIME
|
|
9
|
+
// MAP_MODE: EXPORTS
|
|
10
|
+
// END_MODULE_CONTRACT
|
|
11
|
+
//
|
|
12
|
+
// START_MODULE_MAP
|
|
13
|
+
// defineDualPlugin - Build a dual entrypoint whose default export serves v2 via setup(ctx) and v1 via server(input, options).
|
|
14
|
+
// mergeV1Hooks - Merge v1 hook objects into one object that runs each hook key sequentially in registration order and disposes in the same order.
|
|
15
|
+
// aggregateV1Plugins - Run v1 plugin factories sequentially with per-factory error isolation and merge their hook objects.
|
|
16
|
+
// DualPlugin - Type of the dual entrypoint: v2 Plugin shape plus the v1 server() member.
|
|
17
|
+
// V2Setup - Signature of a v2 setup function receiving the v2 plugin Context.
|
|
18
|
+
// END_MODULE_MAP
|
|
19
|
+
//
|
|
20
|
+
// START_CHANGE_SUMMARY
|
|
21
|
+
// LAST_CHANGE: [C-OPENCODE-V2-MIGRATION - Created the dual-runtime foundation so every package entrypoint loads under both OpenCode runtimes.]
|
|
22
|
+
// END_CHANGE_SUMMARY
|
|
23
|
+
import { Plugin as V2Plugin } from "@opencode/plugin";
|
|
24
|
+
// END_BLOCK_DUAL_PLUGIN_TYPE
|
|
25
|
+
// START_BLOCK_DEFINE_DUAL_PLUGIN
|
|
26
|
+
/**
|
|
27
|
+
* Build the dual entrypoint for one plugin.
|
|
28
|
+
*
|
|
29
|
+
* The v1 factory keeps its original single-argument or two-argument signature
|
|
30
|
+
* and is wrapped verbatim as the server() member. The v2 setup receives the v2
|
|
31
|
+
* plugin context and may return nothing yet; later migration tasks attach the
|
|
32
|
+
* domain registrations.
|
|
33
|
+
*/
|
|
34
|
+
export function defineDualPlugin(definition) {
|
|
35
|
+
return {
|
|
36
|
+
...V2Plugin.define({
|
|
37
|
+
id: definition.id,
|
|
38
|
+
setup: definition.v2,
|
|
39
|
+
}),
|
|
40
|
+
server: definition.v1,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
// END_BLOCK_DEFINE_DUAL_PLUGIN
|
|
44
|
+
// START_BLOCK_MERGE_V1_HOOKS
|
|
45
|
+
/**
|
|
46
|
+
* Merge multiple v1 hook objects into one hook object.
|
|
47
|
+
*
|
|
48
|
+
* The v1 runtime triggers each hook key across plugin entries sequentially in
|
|
49
|
+
* registration order, and calls dispose() on every entry in registration order
|
|
50
|
+
* at shutdown. Producing one merged object that chains every key sequentially
|
|
51
|
+
* and forwards dispose in registration order reproduces that behavior exactly
|
|
52
|
+
* while presenting the aggregator as a single plugin entry.
|
|
53
|
+
*
|
|
54
|
+
* Children that returned undefined or an object without the requested key are
|
|
55
|
+
* skipped for that key. An empty list produces an object with no hook members.
|
|
56
|
+
*/
|
|
57
|
+
export function mergeV1Hooks(entries) {
|
|
58
|
+
const present = entries.filter((entry) => Boolean(entry));
|
|
59
|
+
const keys = new Set();
|
|
60
|
+
for (const entry of present) {
|
|
61
|
+
for (const key of Object.keys(entry)) {
|
|
62
|
+
keys.add(key);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const merged = {};
|
|
66
|
+
for (const key of keys) {
|
|
67
|
+
if (key === "dispose")
|
|
68
|
+
continue;
|
|
69
|
+
const handlers = present
|
|
70
|
+
.map((entry) => entry[key])
|
|
71
|
+
.filter((handler) => typeof handler === "function");
|
|
72
|
+
if (handlers.length === 0)
|
|
73
|
+
continue;
|
|
74
|
+
merged[key] = async (input, output) => {
|
|
75
|
+
for (const handler of handlers) {
|
|
76
|
+
await handler(input, output);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
const disposers = present
|
|
81
|
+
.map((entry) => entry.dispose)
|
|
82
|
+
.filter((disposer) => typeof disposer === "function");
|
|
83
|
+
if (disposers.length > 0) {
|
|
84
|
+
merged.dispose = async () => {
|
|
85
|
+
for (const disposer of disposers) {
|
|
86
|
+
await disposer();
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return merged;
|
|
91
|
+
}
|
|
92
|
+
// END_BLOCK_MERGE_V1_HOOKS
|
|
93
|
+
// START_BLOCK_AGGREGATE_V1_PLUGINS
|
|
94
|
+
/**
|
|
95
|
+
* Run v1 plugin factories sequentially and merge their hook objects.
|
|
96
|
+
*
|
|
97
|
+
* A factory that throws is logged and skipped so one failing plugin cannot take
|
|
98
|
+
* the remaining plugins offline, matching how the v1 runtime isolates plugin
|
|
99
|
+
* load failures across separate package entries.
|
|
100
|
+
*/
|
|
101
|
+
export async function aggregateV1Plugins(factories, input, options, onError) {
|
|
102
|
+
const results = [];
|
|
103
|
+
for (const [index, factory] of factories.entries()) {
|
|
104
|
+
try {
|
|
105
|
+
results.push(await factory(input, options));
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
onError?.(error, index);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return mergeV1Hooks(results);
|
|
112
|
+
}
|
|
113
|
+
// END_BLOCK_AGGREGATE_V1_PLUGINS
|
|
114
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/v2-runtime/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AAC;QACnD,IAAI,CAAC;YACH,OAAO,CAAC,IAAI,CAAC,MAAM,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;QAC9C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IACD,OAAO,YAAY,CAAC,OAAO,CAAC,CAAC;AAC/B,CAAC;AACD,iCAAiC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ConfigSource } from "../../lib/config-layers.js";
|
|
2
|
+
import type { VvocConfig } from "../../lib/vvoc-config.js";
|
|
3
|
+
/**
|
|
4
|
+
* Effective vvoc config resolved for one session location directory.
|
|
5
|
+
*/
|
|
6
|
+
export interface LocationConfigSnapshot {
|
|
7
|
+
readonly directory: string;
|
|
8
|
+
readonly config: VvocConfig;
|
|
9
|
+
readonly source: ConfigSource;
|
|
10
|
+
readonly warnings: readonly string[];
|
|
11
|
+
readonly loadedAt: number;
|
|
12
|
+
}
|
|
13
|
+
export interface LocationResolverOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Injectable effective-config loader for one directory. Defaults to the
|
|
16
|
+
* layer engine with effective scope and default fallback, mirroring the v1
|
|
17
|
+
* startup snapshot semantics for that directory.
|
|
18
|
+
*/
|
|
19
|
+
loadForDirectory?: (directory: string) => Promise<Omit<LocationConfigSnapshot, "directory" | "loadedAt">>;
|
|
20
|
+
/** TTL in milliseconds for cached entries; defaults to 2000. */
|
|
21
|
+
ttlMs?: number;
|
|
22
|
+
/** Injectable logger receiving resolution failure warnings. */
|
|
23
|
+
warn?: (message: string) => void;
|
|
24
|
+
/** Injectable clock in milliseconds for deterministic tests. */
|
|
25
|
+
now?: () => number;
|
|
26
|
+
}
|
|
27
|
+
export interface LocationResolver {
|
|
28
|
+
/** Resolve the effective config for one directory, or undefined when it cannot be loaded (fail closed). */
|
|
29
|
+
forDirectory(directory: string): Promise<LocationConfigSnapshot | undefined>;
|
|
30
|
+
/** Resolve the effective config for a session through its persisted location directory. */
|
|
31
|
+
forSession(sessionID: string, sessionGet: (input: {
|
|
32
|
+
sessionID: string;
|
|
33
|
+
}) => Promise<{
|
|
34
|
+
location?: {
|
|
35
|
+
directory?: string;
|
|
36
|
+
};
|
|
37
|
+
} | undefined>): Promise<LocationConfigSnapshot | undefined>;
|
|
38
|
+
/** Drop the cached entry for one directory so the next read reloads from disk. */
|
|
39
|
+
invalidate(directory: string): void;
|
|
40
|
+
/** Number of directories currently cached; exposed for tests and diagnostics. */
|
|
41
|
+
readonly cachedDirectories: readonly string[];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Build the per-location resolver.
|
|
45
|
+
*
|
|
46
|
+
* A directory whose config fails to load resolves to undefined after a logged
|
|
47
|
+
* warning, and that failure is cached for the TTL so a broken project does not
|
|
48
|
+
* hammer the filesystem from every hook invocation. Plugins treat undefined as
|
|
49
|
+
* disabled for that location, preserving the v1 fail-closed posture.
|
|
50
|
+
*/
|
|
51
|
+
export declare function createLocationResolver(options?: LocationResolverOptions): LocationResolver;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// FILE: src/plugins/v2-runtime/location-config.ts
|
|
2
|
+
// VERSION: 1.0.0
|
|
3
|
+
// START_MODULE_CONTRACT
|
|
4
|
+
// PURPOSE: Resolve the effective vvoc configuration per session location for the OpenCode v2 runtime, replacing the v1 startup-snapshot model.
|
|
5
|
+
// SCOPE: Per-directory effective config resolution through the existing layer engine with TTL caching, session-to-directory mapping through the v2 session API, watcher-driven invalidation, and fail-closed behavior for unresolvable locations.
|
|
6
|
+
// DEPENDS: [src/lib/config-layers.ts]
|
|
7
|
+
// LINKS: [M-PLUGIN-V2-RUNTIME, V-M-PLUGIN-V2-RUNTIME, M-CONFIG-LAYERS]
|
|
8
|
+
// ROLE: RUNTIME
|
|
9
|
+
// MAP_MODE: EXPORTS
|
|
10
|
+
// END_MODULE_CONTRACT
|
|
11
|
+
//
|
|
12
|
+
// START_MODULE_MAP
|
|
13
|
+
// LocationConfigSnapshot - Effective config resolved for one directory plus source metadata and load time.
|
|
14
|
+
// LocationResolver - Resolver interface with forDirectory, forSession, invalidate, and cachedDirectories.
|
|
15
|
+
// LocationResolverOptions - Injectable loader, logger, TTL, and clock for deterministic tests.
|
|
16
|
+
// createLocationResolver - Build a per-directory caching resolver with session mapping and invalidation.
|
|
17
|
+
// END_MODULE_MAP
|
|
18
|
+
//
|
|
19
|
+
// START_CHANGE_SUMMARY
|
|
20
|
+
// LAST_CHANGE: [C-OPENCODE-V2-MIGRATION T-002 - Created the per-location config resolver for the v2 runtime.]
|
|
21
|
+
// END_CHANGE_SUMMARY
|
|
22
|
+
import { loadVvocConfigForRead } from "../../lib/config-layers.js";
|
|
23
|
+
/**
|
|
24
|
+
* Build the per-location resolver.
|
|
25
|
+
*
|
|
26
|
+
* A directory whose config fails to load resolves to undefined after a logged
|
|
27
|
+
* warning, and that failure is cached for the TTL so a broken project does not
|
|
28
|
+
* hammer the filesystem from every hook invocation. Plugins treat undefined as
|
|
29
|
+
* disabled for that location, preserving the v1 fail-closed posture.
|
|
30
|
+
*/
|
|
31
|
+
export function createLocationResolver(options = {}) {
|
|
32
|
+
const ttlMs = options.ttlMs ?? 2000;
|
|
33
|
+
const warn = options.warn ?? ((message) => console.warn(message));
|
|
34
|
+
const now = options.now ?? Date.now;
|
|
35
|
+
const load = options.loadForDirectory ??
|
|
36
|
+
(async (directory) => {
|
|
37
|
+
const read = await loadVvocConfigForRead({
|
|
38
|
+
cwd: directory,
|
|
39
|
+
scope: "effective",
|
|
40
|
+
allowDefault: true,
|
|
41
|
+
});
|
|
42
|
+
return { config: read.config, source: read.source, warnings: read.warnings };
|
|
43
|
+
});
|
|
44
|
+
const cache = new Map();
|
|
45
|
+
async function resolve(directory) {
|
|
46
|
+
const key = directory;
|
|
47
|
+
const cached = cache.get(key);
|
|
48
|
+
if (cached && cached.expiresAt > now()) {
|
|
49
|
+
return cached.value;
|
|
50
|
+
}
|
|
51
|
+
let value;
|
|
52
|
+
try {
|
|
53
|
+
value = { directory, ...(await load(directory)), loadedAt: now() };
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
warn(`[vvoc][v2-runtime] config resolution failed for ${directory}: ${String(error)}; plugins stay disabled for this location`);
|
|
57
|
+
value = undefined;
|
|
58
|
+
}
|
|
59
|
+
cache.set(key, { value, expiresAt: now() + ttlMs });
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
async forDirectory(directory) {
|
|
64
|
+
return resolve(directory);
|
|
65
|
+
},
|
|
66
|
+
async forSession(sessionID, sessionGet) {
|
|
67
|
+
let directory;
|
|
68
|
+
try {
|
|
69
|
+
const session = await sessionGet({ sessionID });
|
|
70
|
+
directory = session?.location?.directory;
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
warn(`[vvoc][v2-runtime] session lookup failed for ${sessionID}: ${String(error)}; plugins stay disabled for this session`);
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
if (!directory) {
|
|
77
|
+
warn(`[vvoc][v2-runtime] session ${sessionID} has no location directory; plugins stay disabled for this session`);
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
return resolve(directory);
|
|
81
|
+
},
|
|
82
|
+
invalidate(directory) {
|
|
83
|
+
cache.delete(directory);
|
|
84
|
+
},
|
|
85
|
+
get cachedDirectories() {
|
|
86
|
+
return [...cache.keys()];
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
// END_BLOCK_CREATE_LOCATION_RESOLVER
|
|
91
|
+
//# sourceMappingURL=location-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"location-config.js","sourceRoot":"","sources":["../../../src/plugins/v2-runtime/location-config.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,iBAAiB;AACjB,wBAAwB;AACxB,iJAAiJ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CAAC;QACD,UAAU,CAAC,SAAS;YAClB,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAC1B,CAAC;QACD,IAAI,iBAAiB;YACnB,OAAO,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QAC3B,CAAC;KACF,CAAC;AACJ,CAAC;AACD,qCAAqC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Plugin as V2Plugin } from "@opencode/plugin";
|
|
2
|
+
import { type LocationResolver } from "./location-config.js";
|
|
3
|
+
/**
|
|
4
|
+
* The context handed to every vvoc plugin v2 setup: the OpenCode v2 plugin
|
|
5
|
+
* context plus the shared location resolver and a multiplexed config watcher.
|
|
6
|
+
*/
|
|
7
|
+
export interface V2AdapterContext {
|
|
8
|
+
readonly ctx: V2Plugin.Context;
|
|
9
|
+
readonly resolver: LocationResolver;
|
|
10
|
+
/** Watch the project vvoc config effective for one directory; the returned stop function never throws. */
|
|
11
|
+
watchConfig(directory: string, onChange: () => void): Promise<() => void>;
|
|
12
|
+
}
|
|
13
|
+
type V2PluginSetup = (adapter: V2AdapterContext) => Promise<V2Plugin.Cleanup | void> | V2Plugin.Cleanup | void;
|
|
14
|
+
/**
|
|
15
|
+
* Per-plugin v2 setup functions in the canonical v1 plugin order. Migration
|
|
16
|
+
* tasks append entries as each plugin gains its v2 registration.
|
|
17
|
+
*/
|
|
18
|
+
export declare const V2_PLUGIN_SETUPS: Array<{
|
|
19
|
+
name: string;
|
|
20
|
+
setup: V2PluginSetup;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* OpenCode v1 (>= 1.18.29) also invokes setup() on dual entrypoints through
|
|
24
|
+
* its reduced v2 bridge host, whose context only carries the agent, aisdk,
|
|
25
|
+
* catalog, command, integration, plugin, reference, and skill domains. The
|
|
26
|
+
* full OpenCode v2 context additionally carries app, location, event, model,
|
|
27
|
+
* provider, session, storage, tool, and the remaining runtime domains. Probe
|
|
28
|
+
* verified against OpenCode 1.18.32: the v1 bridge lacks tool, session, event,
|
|
29
|
+
* storage, app, and location, so their presence distinguishes the runtimes.
|
|
30
|
+
*/
|
|
31
|
+
export declare function isFullV2Context(context: V2Plugin.Context): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Build the shared adapter for one plugin context: a per-location config
|
|
34
|
+
* resolver and a config watcher multiplexer that keeps one filesystem watch
|
|
35
|
+
* per directory regardless of how many plugins subscribe to that directory.
|
|
36
|
+
*/
|
|
37
|
+
export declare function createV2Adapter(context: V2Plugin.Context): V2AdapterContext;
|
|
38
|
+
/**
|
|
39
|
+
* Run every registered v2 plugin setup against the adapter, isolating failures
|
|
40
|
+
* per plugin, and return one cleanup that disposes the successful cleanups in
|
|
41
|
+
* reverse registration order.
|
|
42
|
+
*
|
|
43
|
+
* Under the v1 v2-bridge host this returns without registering anything: the
|
|
44
|
+
* same entrypoint's server() member already provides the v1 behavior, so the
|
|
45
|
+
* package never registers twice inside one OpenCode v1 process.
|
|
46
|
+
*/
|
|
47
|
+
export declare function setupV2Plugins(context: V2Plugin.Context): Promise<V2Plugin.Cleanup | void>;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
// FILE: src/plugins/v2-runtime/setup.ts
|
|
2
|
+
// VERSION: 1.1.0
|
|
3
|
+
// START_MODULE_CONTRACT
|
|
4
|
+
// PURPOSE: Dispatch the v2 setup(ctx) entry for the package root across the vvoc server plugins through a shared adapter carrying per-location config resolution and config watching.
|
|
5
|
+
// SCOPE: Central v2 registration seam: the adapter context (plugin context, location resolver, config watch helper), the ordered plugin setup registry, full-v2-context feature detection, per-plugin error isolation, and aggregated reverse-order cleanup disposal.
|
|
6
|
+
// DEPENDS: [@opencode/plugin, src/plugins/v2-runtime/location-config.ts, src/plugins/v2-runtime/config-watcher.ts]
|
|
7
|
+
// LINKS: [M-PLUGIN-V2-RUNTIME, V-M-PLUGIN-V2-RUNTIME]
|
|
8
|
+
// ROLE: RUNTIME
|
|
9
|
+
// MAP_MODE: EXPORTS
|
|
10
|
+
// END_MODULE_CONTRACT
|
|
11
|
+
//
|
|
12
|
+
// START_MODULE_MAP
|
|
13
|
+
// setupV2Plugins - Run the v2 registrations for every vvoc server plugin against one full OpenCode v2 plugin context and return one aggregated cleanup; no-ops under the v1 v2-bridge host where the v1 runtime already calls server().
|
|
14
|
+
// V2_PLUGIN_SETUPS - Ordered registry of per-plugin v2 setup functions extended by later migration tasks.
|
|
15
|
+
// V2AdapterContext - Plugin context plus the location resolver and multiplexed config watcher shared by all vvoc plugins.
|
|
16
|
+
// createV2Adapter - Build the shared adapter context with the location resolver and multiplexed config watcher.
|
|
17
|
+
// isFullV2Context - Feature-detect whether a setup context carries the full OpenCode v2 domain set.
|
|
18
|
+
// END_MODULE_MAP
|
|
19
|
+
//
|
|
20
|
+
// START_CHANGE_SUMMARY
|
|
21
|
+
// LAST_CHANGE: [C-OPENCODE-V2-MIGRATION T-002 - Plugin setups now receive the shared adapter context with per-location config resolution and config watching.]
|
|
22
|
+
// END_CHANGE_SUMMARY
|
|
23
|
+
import { createLocationResolver } from "./location-config.js";
|
|
24
|
+
import { watchProjectVvocConfig } from "./config-watcher.js";
|
|
25
|
+
import { setupAnalyticsV2 } from "../analytics/v2.js";
|
|
26
|
+
import { setupSystemContextInjectionV2 } from "../system-context-injection/v2.js";
|
|
27
|
+
import { setupModelRolesV2 } from "../model-roles/v2.js";
|
|
28
|
+
import { setupToolHistoryCompactionV2 } from "../tool-history-compaction/v2.js";
|
|
29
|
+
import { setupSpecGuardV2 } from "../spec-guard/v2.js";
|
|
30
|
+
import { setupSecretsRedactionV2 } from "../secrets-redaction/v2.js";
|
|
31
|
+
import { setupPeakHoursV2 } from "../peak-hours/v2.js";
|
|
32
|
+
import { setupWebToolsV2 } from "../web-tools/v2.js";
|
|
33
|
+
import { setupHashlineEditV2 } from "../hashline-edit/v2.js";
|
|
34
|
+
import { setupGuardianV2 } from "../guardian/v2.js";
|
|
35
|
+
import { setupWorkflowV2 } from "../workflow/v2.js";
|
|
36
|
+
// END_BLOCK_V2_ADAPTER_CONTEXT
|
|
37
|
+
// START_BLOCK_V2_PLUGIN_SETUPS
|
|
38
|
+
/**
|
|
39
|
+
* Per-plugin v2 setup functions in the canonical v1 plugin order. Migration
|
|
40
|
+
* tasks append entries as each plugin gains its v2 registration.
|
|
41
|
+
*/
|
|
42
|
+
export const V2_PLUGIN_SETUPS = [
|
|
43
|
+
{ name: "analytics", setup: (adapter) => setupAnalyticsV2(adapter) },
|
|
44
|
+
{ name: "system-context-injection", setup: (adapter) => setupSystemContextInjectionV2(adapter) },
|
|
45
|
+
{ name: "model-roles", setup: (adapter) => setupModelRolesV2(adapter) },
|
|
46
|
+
{ name: "tool-history-compaction", setup: (adapter) => setupToolHistoryCompactionV2(adapter) },
|
|
47
|
+
{ name: "spec-guard", setup: (adapter) => setupSpecGuardV2(adapter) },
|
|
48
|
+
{ name: "secrets-redaction", setup: (adapter) => setupSecretsRedactionV2(adapter) },
|
|
49
|
+
{ name: "peak-hours", setup: (adapter) => setupPeakHoursV2(adapter) },
|
|
50
|
+
{ name: "web-tools", setup: (adapter) => setupWebToolsV2(adapter) },
|
|
51
|
+
{ name: "hashline-edit", setup: (adapter) => setupHashlineEditV2(adapter) },
|
|
52
|
+
{ name: "guardian", setup: (adapter) => setupGuardianV2(adapter) },
|
|
53
|
+
{ name: "workflow", setup: (adapter) => setupWorkflowV2(adapter) },
|
|
54
|
+
];
|
|
55
|
+
// END_BLOCK_V2_PLUGIN_SETUPS
|
|
56
|
+
// START_BLOCK_IS_FULL_V2_CONTEXT
|
|
57
|
+
/**
|
|
58
|
+
* OpenCode v1 (>= 1.18.29) also invokes setup() on dual entrypoints through
|
|
59
|
+
* its reduced v2 bridge host, whose context only carries the agent, aisdk,
|
|
60
|
+
* catalog, command, integration, plugin, reference, and skill domains. The
|
|
61
|
+
* full OpenCode v2 context additionally carries app, location, event, model,
|
|
62
|
+
* provider, session, storage, tool, and the remaining runtime domains. Probe
|
|
63
|
+
* verified against OpenCode 1.18.32: the v1 bridge lacks tool, session, event,
|
|
64
|
+
* storage, app, and location, so their presence distinguishes the runtimes.
|
|
65
|
+
*/
|
|
66
|
+
export function isFullV2Context(context) {
|
|
67
|
+
const probe = context;
|
|
68
|
+
return ("tool" in probe &&
|
|
69
|
+
"session" in probe &&
|
|
70
|
+
"event" in probe &&
|
|
71
|
+
"storage" in probe &&
|
|
72
|
+
"app" in probe &&
|
|
73
|
+
"location" in probe);
|
|
74
|
+
}
|
|
75
|
+
// END_BLOCK_IS_FULL_V2_CONTEXT
|
|
76
|
+
// START_BLOCK_CREATE_ADAPTER
|
|
77
|
+
/**
|
|
78
|
+
* Build the shared adapter for one plugin context: a per-location config
|
|
79
|
+
* resolver and a config watcher multiplexer that keeps one filesystem watch
|
|
80
|
+
* per directory regardless of how many plugins subscribe to that directory.
|
|
81
|
+
*/
|
|
82
|
+
export function createV2Adapter(context) {
|
|
83
|
+
const resolver = createLocationResolver();
|
|
84
|
+
const subscriptions = new Map();
|
|
85
|
+
const activeWatches = new Map();
|
|
86
|
+
async function ensureWatched(directory) {
|
|
87
|
+
if (activeWatches.has(directory))
|
|
88
|
+
return;
|
|
89
|
+
const listeners = subscriptions.get(directory);
|
|
90
|
+
if (!listeners || listeners.size === 0)
|
|
91
|
+
return;
|
|
92
|
+
const stopWatch = await watchProjectVvocConfig(directory, () => {
|
|
93
|
+
resolver.invalidate(directory);
|
|
94
|
+
for (const listener of listeners.values()) {
|
|
95
|
+
try {
|
|
96
|
+
listener();
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
console.warn(`[vvoc][v2-runtime] config listener failed for ${directory}: ${String(error)}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
activeWatches.set(directory, stopWatch);
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
ctx: context,
|
|
107
|
+
resolver,
|
|
108
|
+
async watchConfig(directory, onChange) {
|
|
109
|
+
const key = Symbol("vvoc-config-listener");
|
|
110
|
+
let listeners = subscriptions.get(directory);
|
|
111
|
+
if (!listeners) {
|
|
112
|
+
listeners = new Map();
|
|
113
|
+
subscriptions.set(directory, listeners);
|
|
114
|
+
}
|
|
115
|
+
listeners.set(key, onChange);
|
|
116
|
+
await ensureWatched(directory);
|
|
117
|
+
let stopped = false;
|
|
118
|
+
return () => {
|
|
119
|
+
if (stopped)
|
|
120
|
+
return;
|
|
121
|
+
stopped = true;
|
|
122
|
+
const current = subscriptions.get(directory);
|
|
123
|
+
if (!current)
|
|
124
|
+
return;
|
|
125
|
+
current.delete(key);
|
|
126
|
+
if (current.size === 0) {
|
|
127
|
+
subscriptions.delete(directory);
|
|
128
|
+
const stopWatch = activeWatches.get(directory);
|
|
129
|
+
if (stopWatch) {
|
|
130
|
+
activeWatches.delete(directory);
|
|
131
|
+
stopWatch();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
// END_BLOCK_CREATE_ADAPTER
|
|
139
|
+
// START_BLOCK_SETUP_V2_PLUGINS
|
|
140
|
+
/**
|
|
141
|
+
* Run every registered v2 plugin setup against the adapter, isolating failures
|
|
142
|
+
* per plugin, and return one cleanup that disposes the successful cleanups in
|
|
143
|
+
* reverse registration order.
|
|
144
|
+
*
|
|
145
|
+
* Under the v1 v2-bridge host this returns without registering anything: the
|
|
146
|
+
* same entrypoint's server() member already provides the v1 behavior, so the
|
|
147
|
+
* package never registers twice inside one OpenCode v1 process.
|
|
148
|
+
*/
|
|
149
|
+
export async function setupV2Plugins(context) {
|
|
150
|
+
if (!isFullV2Context(context))
|
|
151
|
+
return undefined;
|
|
152
|
+
const adapter = createV2Adapter(context);
|
|
153
|
+
const cleanups = [];
|
|
154
|
+
for (const entry of V2_PLUGIN_SETUPS) {
|
|
155
|
+
try {
|
|
156
|
+
const cleanup = await entry.setup(adapter);
|
|
157
|
+
if (typeof cleanup === "function") {
|
|
158
|
+
cleanups.push(cleanup);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
console.error(`[vvoc][v2-runtime] plugin ${entry.name} failed to load: ${String(error)}`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (cleanups.length === 0)
|
|
166
|
+
return undefined;
|
|
167
|
+
return async () => {
|
|
168
|
+
for (const cleanup of cleanups.reverse()) {
|
|
169
|
+
await cleanup();
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
// END_BLOCK_SETUP_V2_PLUGINS
|
|
174
|
+
//# sourceMappingURL=setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../../src/plugins/v2-runtime/setup.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,iBAAiB;AACjB,wBAAwB;AACxB,wLAAwL;AACxL,wQAAwQ;AACxQ,qHAAqH;AACrH,wDAAwD;AACxD,kBAAkB;AAClB,sBAAsB;AACtB,sBAAsB;AACtB,EAAE;AACF,mBAAmB;AACnB,0OAA0O;AAC1O,4GAA4G;AAC5G,4HAA4H;AAC5H,kHAAkH;AAClH,sGAAsG;AACtG,iBAAiB;AACjB,EAAE;AACF,uBAAuB;AACvB,iKAAiK;AACjK,qBAAqB;AAGrB,OAAO,EAAE,sBAAsB,EAAyB,MAAM,sBAAsB,CAAC;AACrF,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,6BAA6B,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,E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 +3,7 @@
|
|
|
3
3
|
// START_MODULE_CONTRACT
|
|
4
4
|
// PURPOSE: Register the canonical web_search and web_fetch tools, publish their strict input contracts through the owned definition seam, validate owned raw arguments before execution, and suppress OpenCode built-ins at runtime while the web-tools plugin is enabled.
|
|
5
5
|
// SCOPE: Startup vvoc snapshot use, plugin toggle handling, runtime permission suppression, tool registration, owned contract publication and pre-execute validation for the two owned tool ids only, and credential-safe diagnostics. No interception of unrelated host or MCP tools.
|
|
6
|
-
// DEPENDS: [@opencode-ai/plugin, src/lib/agent-tool-contract.ts, src/lib/config-layers.ts, src/lib/plugin-toggle-config.ts, src/plugins/web-tools/config.ts, src/plugins/web-tools/schemas.ts, src/plugins/web-tools/search-service.ts, src/plugins/web-tools/fetch-service.ts]
|
|
6
|
+
// DEPENDS: [@opencode-ai/plugin, src/lib/agent-tool-contract.ts, src/lib/config-layers.ts, src/lib/plugin-toggle-config.ts, src/plugins/web-tools/config.ts, src/plugins/web-tools/schemas.ts, src/plugins/web-tools/search-service.ts, src/plugins/web-tools/fetch-service.ts, src/plugins/v2-runtime/index.ts]
|
|
7
7
|
// LINKS: M-PLUGIN-WEB-TOOLS, M-WEB-CONFIG, M-WEB-SEARCH-SERVICE, M-WEB-FETCH-SERVICE, M-AGENT-TOOL-CONTRACT, V-M-PLUGIN-WEB-TOOLS, DF-WEB-SEARCH, DF-WEB-FETCH
|
|
8
8
|
// ROLE: RUNTIME
|
|
9
9
|
// MAP_MODE: EXPORTS
|
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
// SUPPRESSED_BUILTIN_PERMISSIONS - Built-in permission ids hidden while the plugin is enabled.
|
|
14
14
|
// applyBuiltinSuppression - Add runtime-only deny rules unless the user configured a key explicitly.
|
|
15
15
|
// WebToolsPlugin - Public plugin entry registering web_search and web_fetch.
|
|
16
|
+
// default - Dual subpath entrypoint: v2 setup() seam plus v1 server() delegating to the named factory.
|
|
16
17
|
// END_MODULE_MAP
|
|
17
18
|
//
|
|
18
19
|
// START_CHANGE_SUMMARY
|
|
19
|
-
// LAST_CHANGE: [C-AGENT-TOOL-CONTRACTS T-006 - Published both web tool contracts through the owned definition adapter and added an owned-only pre-execute guard; preserved built-in suppression, explicit user overrides, and disabled-plugin behavior.]
|
|
20
|
+
// LAST_CHANGE: [C-OPENCODE-V2-MIGRATION T-001 - Added the dual subpath entrypoint so the plugin loads under OpenCode v1 via server() and v2 via setup(). Prior: C-AGENT-TOOL-CONTRACTS T-006 - Published both web tool contracts through the owned definition adapter and added an owned-only pre-execute guard; preserved built-in suppression, explicit user overrides, and disabled-plugin behavior.]
|
|
20
21
|
// END_CHANGE_SUMMARY
|
|
21
22
|
import { ContractInputError, createToolDefinitionAdapter } from "../../lib/agent-tool-contract.js";
|
|
22
23
|
import { loadVvocConfig } from "../../lib/config-layers.js";
|
|
@@ -107,4 +108,14 @@ export const WebToolsPlugin = async ({ client, directory }) => {
|
|
|
107
108
|
"tool.definition": toolDefinitionAdapter,
|
|
108
109
|
};
|
|
109
110
|
};
|
|
111
|
+
// START_BLOCK_DUAL_SUBPATH_ENTRY
|
|
112
|
+
import { defineDualPlugin } from "../v2-runtime/index.js";
|
|
113
|
+
import { createV2Adapter } from "../v2-runtime/setup.js";
|
|
114
|
+
import { setupWebToolsV2 } from "./v2.js";
|
|
115
|
+
export default defineDualPlugin({
|
|
116
|
+
id: "vvoc.web-tools",
|
|
117
|
+
v1: WebToolsPlugin,
|
|
118
|
+
v2: (ctx) => setupWebToolsV2(createV2Adapter(ctx)),
|
|
119
|
+
});
|
|
120
|
+
// END_BLOCK_DUAL_SUBPATH_ENTRY
|
|
110
121
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/web-tools/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,iBAAiB;AACjB,wBAAwB;AACxB,6QAA6Q;AAC7Q,yRAAyR;AACzR,
|
|
1
|
+
{"version":3,"file":"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,CAAC;QACH,CAAC;QACD,IAAI,EAAE;YACJ,UAAU,EAAE,mBAAmB,CAAC,QAAQ,CAAC,MAAM,CAAC;YAChD,SAAS,EAAE,kBAAkB,CAAC,QAAQ,CAAC,KAAK,CAAC;SAC9C;QACD,iBAAiB,EAAE,qBAAqB;KACzC,CAAC;AACJ,CAAC,CAAC;AAEF,iCAAiC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,eAAe,gBAAgB,CAAC;IAC9B,EAAE,EAAE,gBAAgB;IACpB,EAAE,EAAE,cAAc;IAClB,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,eAAe,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;CACnD,CAAC,CAAC;AACH,+BAA+B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Plugin as V2Plugin } from "@opencode/plugin";
|
|
2
|
+
import type { V2AdapterContext } from "../v2-runtime/setup.js";
|
|
3
|
+
/**
|
|
4
|
+
* Register the web tools on the v2 runtime.
|
|
5
|
+
*
|
|
6
|
+
* A later valid tool registration overrides the same effective name, so
|
|
7
|
+
* registering web_search and web_fetch replaces the OpenCode built-ins while
|
|
8
|
+
* the plugin is enabled and disposing the registration restores them, which
|
|
9
|
+
* replaces the v1 config-hook builtin suppression.
|
|
10
|
+
*/
|
|
11
|
+
export declare function setupWebToolsV2(adapter: V2AdapterContext): Promise<V2Plugin.Cleanup | void>;
|