@opencode-ai/plugin
Advanced tools
@@ -112,8 +112,9 @@ export * as Tool from "./tool.js"; | ||
| export declare const validateName: (name: string) => Effect.Effect<void, never, never> | Effect.Effect<never, RegistrationError, never>; | ||
| export declare const registrationEntries: (tools: Readonly<Record<string, AnyTool>>, group?: string) => { | ||
| export declare const registrationEntries: (tools: Readonly<Record<string, AnyTool>>, namespace?: string) => { | ||
| key: string; | ||
| name: string; | ||
| group: string | undefined; | ||
| namespace: string | undefined; | ||
| tool: AnyTool; | ||
| }[]; | ||
| export declare const validateNamespace: (namespace: string) => Effect.Effect<void, never, never> | Effect.Effect<never, RegistrationError, never>; | ||
| export declare const withPermission: <T extends AnyTool>(tool: T, permission: string) => Omit<T, "permission"> & { | ||
@@ -145,3 +146,3 @@ readonly permission: string; | ||
| export interface RegisterOptions { | ||
| readonly group?: string; | ||
| readonly namespace?: string; | ||
| /** Defaults to true. False exposes the tool directly to the provider. */ | ||
@@ -148,0 +149,0 @@ readonly codemode?: boolean; |
@@ -28,12 +28,14 @@ export * as Tool from "./tool.js"; | ||
| : Effect.fail(new RegistrationError({ name, message: `Invalid tool name: ${name}` })); | ||
| export const registrationEntries = (tools, group) => Object.entries(tools).map(([name, tool]) => { | ||
| export const registrationEntries = (tools, namespace) => Object.entries(tools).map(([name, tool]) => { | ||
| const normalized = name.replace(/[^a-zA-Z0-9_-]/g, "_"); | ||
| const parent = group?.replace(/[^a-zA-Z0-9_-]/g, "_"); | ||
| return { | ||
| key: parent === undefined ? normalized : `${parent}_${normalized}`, | ||
| key: namespace === undefined ? normalized : `${namespace.replaceAll(".", "_")}_${normalized}`, | ||
| name: normalized, | ||
| group: parent, | ||
| namespace, | ||
| tool, | ||
| }; | ||
| }); | ||
| export const validateNamespace = (namespace) => namespace.split(".").every((segment) => /^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(segment)) | ||
| ? Effect.void | ||
| : Effect.fail(new RegistrationError({ name: namespace, message: `Invalid tool namespace: ${JSON.stringify(namespace)}` })); | ||
| export const withPermission = (tool, permission) => ({ ...tool, permission }); | ||
@@ -40,0 +42,0 @@ export const permission = (tool, name) => tool.permission ?? name; |
+5
-5
| { | ||
| "$schema": "https://json.schemastore.org/package.json", | ||
| "name": "@opencode-ai/plugin", | ||
| "version": "0.0.0-next-15760", | ||
| "version": "0.0.0-next-15769", | ||
| "type": "module", | ||
@@ -55,6 +55,6 @@ "license": "MIT", | ||
| "@ai-sdk/provider": "3.0.8", | ||
| "@opencode-ai/ai": "0.0.0-next-15760", | ||
| "@opencode-ai/client": "0.0.0-next-15760", | ||
| "@opencode-ai/schema": "0.0.0-next-15760", | ||
| "@opencode-ai/sdk": "0.0.0-next-15760", | ||
| "@opencode-ai/ai": "0.0.0-next-15769", | ||
| "@opencode-ai/client": "0.0.0-next-15769", | ||
| "@opencode-ai/schema": "0.0.0-next-15769", | ||
| "@opencode-ai/sdk": "0.0.0-next-15769", | ||
| "@standard-schema/spec": "^1.1.0", | ||
@@ -61,0 +61,0 @@ "effect": "4.0.0-beta.98", |
78608
0.52%2075
0.14%+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed