@opencode-ai/plugin 0.0.0-next-202606301613 → 0.0.0-next-15259
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/example.d.ts +1 -1
- package/dist/index.js +1 -0
- package/dist/shell.js +0 -1
- package/dist/tui.d.ts +15 -15
- package/dist/v2/effect/agent.d.ts +11 -8
- package/dist/v2/effect/agent.js +0 -1
- package/dist/v2/effect/aisdk.d.ts +8 -5
- package/dist/v2/effect/aisdk.js +0 -1
- package/dist/v2/effect/catalog.d.ts +11 -8
- package/dist/v2/effect/catalog.js +0 -1
- package/dist/v2/effect/command.d.ts +11 -8
- package/dist/v2/effect/command.js +0 -1
- package/dist/v2/effect/event.d.ts +2 -7
- package/dist/v2/effect/event.js +0 -1
- package/dist/v2/effect/filesystem.js +0 -1
- package/dist/v2/effect/index.d.ts +10 -3
- package/dist/v2/effect/index.js +10 -1
- package/dist/v2/effect/integration.d.ts +5 -4
- package/dist/v2/effect/integration.js +0 -1
- package/dist/v2/effect/location.js +0 -1
- package/dist/v2/effect/npm.js +0 -1
- package/dist/v2/effect/path.js +0 -1
- package/dist/v2/effect/plugin.d.ts +27 -6
- package/dist/v2/effect/reference.d.ts +7 -4
- package/dist/v2/effect/reference.js +0 -1
- package/dist/v2/effect/registration.d.ts +2 -6
- package/dist/v2/effect/registration.js +0 -1
- package/dist/v2/effect/session.d.ts +2 -0
- package/dist/v2/effect/session.js +0 -0
- package/dist/v2/effect/skill.d.ts +10 -7
- package/dist/v2/effect/skill.js +0 -1
- package/dist/v2/effect/tool.d.ts +148 -0
- package/dist/v2/effect/tool.js +114 -0
- package/dist/v2/options.js +0 -1
- package/dist/v2/promise/agent.d.ts +6 -4
- package/dist/v2/promise/agent.js +0 -1
- package/dist/v2/promise/aisdk.d.ts +8 -5
- package/dist/v2/promise/aisdk.js +0 -1
- package/dist/v2/promise/catalog.d.ts +6 -4
- package/dist/v2/promise/catalog.js +0 -1
- package/dist/v2/promise/command.d.ts +6 -4
- package/dist/v2/promise/command.js +0 -1
- package/dist/v2/promise/event.d.ts +3 -0
- package/dist/v2/promise/event.js +0 -0
- package/dist/v2/promise/index.d.ts +11 -11
- package/dist/v2/promise/index.js +11 -1
- package/dist/v2/promise/integration.d.ts +5 -4
- package/dist/v2/promise/integration.js +0 -1
- package/dist/v2/promise/plugin.d.ts +27 -6
- package/dist/v2/promise/reference.d.ts +6 -4
- package/dist/v2/promise/reference.js +0 -1
- package/dist/v2/promise/registration.d.ts +2 -6
- package/dist/v2/promise/registration.js +0 -1
- package/dist/v2/promise/session.d.ts +2 -0
- package/dist/v2/promise/session.js +0 -0
- package/dist/v2/promise/skill.d.ts +6 -4
- package/dist/v2/promise/skill.js +0 -1
- package/dist/v2/promise/tool.d.ts +75 -0
- package/dist/v2/promise/tool.js +17 -0
- package/package.json +21 -17
- package/dist/v2/effect/context.d.ts +0 -21
- package/dist/v2/effect/context.js +0 -1
- package/dist/v2/promise/context.d.ts +0 -21
- package/dist/v2/promise/context.js +0 -1
package/dist/example.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Plugin } from "./index.js";
|
|
1
|
+
import type { Plugin } from "./index.js";
|
|
2
2
|
export declare const ExamplePlugin: Plugin;
|
package/dist/index.js
CHANGED
package/dist/shell.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/tui.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OpencodeClient, LspStatus, McpStatus, Message, Part, Provider, PermissionRequest, QuestionRequest, Session, SessionStatus, Config as SdkConfig } from "@opencode-ai/sdk/v2";
|
|
2
|
+
import type { OpenCodeEvent } from "@opencode-ai/client/promise";
|
|
3
|
+
import type { PromptInput } from "@opencode-ai/schema";
|
|
4
|
+
import type { Types } from "effect";
|
|
2
5
|
import type { CliRenderer, KeyEvent, RGBA, Renderable, SlotMode } from "@opentui/core";
|
|
3
6
|
import type { Binding, Keymap } from "@opentui/keymap";
|
|
4
7
|
import { type BindingConfig, type CreateBindingLookupOptions, type KeySequenceFormatPart, type SequenceBindingLike } from "@opentui/keymap/extras";
|
|
@@ -125,18 +128,16 @@ export type TuiDialogSelectProps<Value = unknown> = {
|
|
|
125
128
|
skipFilter?: boolean;
|
|
126
129
|
current?: Value;
|
|
127
130
|
};
|
|
128
|
-
export type TuiPromptInfo = {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
end: number;
|
|
136
|
-
value: string;
|
|
137
|
-
};
|
|
131
|
+
export type TuiPromptInfo = Types.DeepMutable<PromptInput.Prompt> & {
|
|
132
|
+
pasted: {
|
|
133
|
+
text: string;
|
|
134
|
+
source: {
|
|
135
|
+
start: number;
|
|
136
|
+
end: number;
|
|
137
|
+
text: string;
|
|
138
138
|
};
|
|
139
|
-
}
|
|
139
|
+
}[];
|
|
140
|
+
mode?: "normal" | "shell";
|
|
140
141
|
};
|
|
141
142
|
export type TuiPromptRef = {
|
|
142
143
|
focused: boolean;
|
|
@@ -302,7 +303,6 @@ export type TuiState = {
|
|
|
302
303
|
count: () => number;
|
|
303
304
|
get: (sessionID: string) => Session | undefined;
|
|
304
305
|
diff: (sessionID: string) => ReadonlyArray<TuiSidebarFileItem>;
|
|
305
|
-
todo: (sessionID: string) => ReadonlyArray<TuiSidebarTodoItem>;
|
|
306
306
|
messages: (sessionID: string) => ReadonlyArray<Message>;
|
|
307
307
|
status: (sessionID: string) => SessionStatus | undefined;
|
|
308
308
|
permission: (sessionID: string) => ReadonlyArray<PermissionRequest>;
|
|
@@ -346,7 +346,6 @@ export type TuiSidebarMcpItem = {
|
|
|
346
346
|
error?: string;
|
|
347
347
|
};
|
|
348
348
|
export type TuiSidebarLspItem = Pick<LspStatus, "id" | "root" | "status">;
|
|
349
|
-
export type TuiSidebarTodoItem = Pick<Todo, "content" | "status">;
|
|
350
349
|
export type TuiSidebarFileItem = {
|
|
351
350
|
file: string;
|
|
352
351
|
additions: number;
|
|
@@ -382,6 +381,7 @@ export type TuiHostSlotMap = {
|
|
|
382
381
|
};
|
|
383
382
|
sidebar_footer: {
|
|
384
383
|
session_id: string;
|
|
384
|
+
directory: string;
|
|
385
385
|
};
|
|
386
386
|
};
|
|
387
387
|
export type TuiSlotMap<Slots extends Record<string, object> = {}> = TuiHostSlotMap & Slots;
|
|
@@ -405,7 +405,7 @@ export type TuiSlots = {
|
|
|
405
405
|
};
|
|
406
406
|
};
|
|
407
407
|
export type TuiEventBus = {
|
|
408
|
-
on: <Type extends
|
|
408
|
+
on: <Type extends OpenCodeEvent["type"]>(type: Type, handler: (event: Extract<OpenCodeEvent, {
|
|
409
409
|
type: Type;
|
|
410
410
|
}>) => void) => () => void;
|
|
411
411
|
};
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { AgentApi } from "@opencode-ai/client/effect/api";
|
|
2
|
+
import type { AgentInfo } from "@opencode-ai/sdk/v2/types";
|
|
3
|
+
import type { Effect } from "effect";
|
|
4
|
+
import type { Transform } from "./registration.js";
|
|
3
5
|
export interface AgentDraft {
|
|
4
|
-
list(): readonly
|
|
5
|
-
get(id: string):
|
|
6
|
+
list(): readonly AgentInfo[];
|
|
7
|
+
get(id: string): AgentInfo | undefined;
|
|
6
8
|
default(id: string | undefined): void;
|
|
7
|
-
update(id: string, update: (agent:
|
|
9
|
+
update(id: string, update: (agent: AgentInfo) => void): void;
|
|
8
10
|
remove(id: string): void;
|
|
9
11
|
}
|
|
10
|
-
export
|
|
11
|
-
transform: AgentDraft
|
|
12
|
-
|
|
12
|
+
export interface AgentDomain extends AgentApi<unknown> {
|
|
13
|
+
readonly transform: Transform<AgentDraft>;
|
|
14
|
+
readonly reload: () => Effect.Effect<void>;
|
|
15
|
+
}
|
package/dist/v2/effect/agent.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import type { LanguageModelV3 } from "@ai-sdk/provider";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Model } from "@opencode-ai/schema/model";
|
|
3
3
|
import type { Hooks } from "./registration.js";
|
|
4
|
-
export
|
|
4
|
+
export interface AISDKHooks {
|
|
5
5
|
sdk: {
|
|
6
|
-
readonly model:
|
|
6
|
+
readonly model: Model.Info;
|
|
7
7
|
readonly package: string;
|
|
8
8
|
readonly options: Record<string, any>;
|
|
9
9
|
sdk?: any;
|
|
10
10
|
};
|
|
11
11
|
language: {
|
|
12
|
-
readonly model:
|
|
12
|
+
readonly model: Model.Info;
|
|
13
13
|
readonly sdk: any;
|
|
14
14
|
readonly options: Record<string, any>;
|
|
15
15
|
language?: LanguageModelV3;
|
|
16
16
|
};
|
|
17
|
-
}
|
|
17
|
+
}
|
|
18
|
+
export interface AISDKDomain {
|
|
19
|
+
readonly hook: Hooks<AISDKHooks>;
|
|
20
|
+
}
|
package/dist/v2/effect/aisdk.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { ModelInfo, ProviderV2Info } from "@opencode-ai/sdk/v2/types";
|
|
2
|
+
import type { CatalogApi } from "@opencode-ai/client/effect/api";
|
|
3
|
+
import type { Effect } from "effect";
|
|
4
|
+
import type { Transform } from "./registration.js";
|
|
3
5
|
export interface CatalogProviderRecord {
|
|
4
6
|
readonly provider: ProviderV2Info;
|
|
5
|
-
readonly models: ReadonlyMap<string,
|
|
7
|
+
readonly models: ReadonlyMap<string, ModelInfo>;
|
|
6
8
|
}
|
|
7
9
|
export interface CatalogDraft {
|
|
8
10
|
readonly provider: {
|
|
@@ -12,8 +14,8 @@ export interface CatalogDraft {
|
|
|
12
14
|
remove(providerID: string): void;
|
|
13
15
|
};
|
|
14
16
|
readonly model: {
|
|
15
|
-
get(providerID: string, modelID: string):
|
|
16
|
-
update(providerID: string, modelID: string, update: (model:
|
|
17
|
+
get(providerID: string, modelID: string): ModelInfo | undefined;
|
|
18
|
+
update(providerID: string, modelID: string, update: (model: ModelInfo) => void): void;
|
|
17
19
|
remove(providerID: string, modelID: string): void;
|
|
18
20
|
readonly default: {
|
|
19
21
|
get(): {
|
|
@@ -24,6 +26,7 @@ export interface CatalogDraft {
|
|
|
24
26
|
};
|
|
25
27
|
};
|
|
26
28
|
}
|
|
27
|
-
export
|
|
28
|
-
transform: CatalogDraft
|
|
29
|
-
|
|
29
|
+
export interface CatalogDomain extends CatalogApi<unknown> {
|
|
30
|
+
readonly transform: Transform<CatalogDraft>;
|
|
31
|
+
readonly reload: () => Effect.Effect<void>;
|
|
32
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { CommandInfo } from "@opencode-ai/sdk/v2/types";
|
|
2
|
+
import type { CommandApi } from "@opencode-ai/client/effect/api";
|
|
3
|
+
import type { Effect } from "effect";
|
|
4
|
+
import type { Transform } from "./registration.js";
|
|
3
5
|
export interface CommandDraft {
|
|
4
|
-
list(): readonly
|
|
5
|
-
get(name: string):
|
|
6
|
-
update(name: string, update: (command:
|
|
6
|
+
list(): readonly CommandInfo[];
|
|
7
|
+
get(name: string): CommandInfo | undefined;
|
|
8
|
+
update(name: string, update: (command: CommandInfo) => void): void;
|
|
7
9
|
remove(name: string): void;
|
|
8
10
|
}
|
|
9
|
-
export
|
|
10
|
-
transform: CommandDraft
|
|
11
|
-
|
|
11
|
+
export interface CommandDomain extends CommandApi<unknown> {
|
|
12
|
+
readonly transform: Transform<CommandDraft>;
|
|
13
|
+
readonly reload: () => Effect.Effect<void>;
|
|
14
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export type EventMap = {
|
|
4
|
-
[Item in SDKEvent as Item["type"]]: Item;
|
|
5
|
-
};
|
|
6
|
-
export interface Event {
|
|
7
|
-
subscribe<Type extends keyof EventMap>(type: Type): Stream.Stream<EventMap[Type]>;
|
|
1
|
+
import type { EventApi } from "@opencode-ai/client/effect/api";
|
|
2
|
+
export interface EventDomain extends Pick<EventApi<unknown>, "subscribe"> {
|
|
8
3
|
}
|
package/dist/v2/effect/event.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
export
|
|
2
|
-
export {
|
|
3
|
-
export
|
|
1
|
+
export * as Plugin from "./plugin.js";
|
|
2
|
+
export { Agent } from "@opencode-ai/schema/agent";
|
|
3
|
+
export { Command } from "@opencode-ai/schema/command";
|
|
4
|
+
export { Connection } from "@opencode-ai/schema/connection";
|
|
5
|
+
export { Credential } from "@opencode-ai/schema/credential";
|
|
6
|
+
export { Integration } from "@opencode-ai/schema/integration";
|
|
7
|
+
export { Model } from "@opencode-ai/schema/model";
|
|
8
|
+
export { Provider } from "@opencode-ai/schema/provider";
|
|
9
|
+
export { Reference } from "@opencode-ai/schema/reference";
|
|
10
|
+
export { Skill } from "@opencode-ai/schema/skill";
|
package/dist/v2/effect/index.js
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * as Plugin from "./plugin.js";
|
|
2
|
+
export { Agent } from "@opencode-ai/schema/agent";
|
|
3
|
+
export { Command } from "@opencode-ai/schema/command";
|
|
4
|
+
export { Connection } from "@opencode-ai/schema/connection";
|
|
5
|
+
export { Credential } from "@opencode-ai/schema/credential";
|
|
6
|
+
export { Integration } from "@opencode-ai/schema/integration";
|
|
7
|
+
export { Model } from "@opencode-ai/schema/model";
|
|
8
|
+
export { Provider } from "@opencode-ai/schema/provider";
|
|
9
|
+
export { Reference } from "@opencode-ai/schema/reference";
|
|
10
|
+
export { Skill } from "@opencode-ai/schema/skill";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ConnectionInfo, CredentialOAuth, CredentialValue, IntegrationEnvMethod, IntegrationInputs, IntegrationKeyMethod, IntegrationMethod, IntegrationOAuthMethod, IntegrationRef } from "@opencode-ai/sdk/v2/types";
|
|
2
|
+
import type { IntegrationApi } from "@opencode-ai/client/effect/api";
|
|
2
3
|
import type { Effect, Scope } from "effect";
|
|
3
|
-
import type {
|
|
4
|
+
import type { Transform } from "./registration.js";
|
|
4
5
|
export type IntegrationOAuthAuthorization = {
|
|
5
6
|
readonly url: string;
|
|
6
7
|
readonly instructions: string;
|
|
@@ -36,9 +37,9 @@ export interface IntegrationDraft {
|
|
|
36
37
|
remove(integrationID: string, method: IntegrationMethod): void;
|
|
37
38
|
};
|
|
38
39
|
}
|
|
39
|
-
export interface
|
|
40
|
-
transform: IntegrationDraft
|
|
41
|
-
|
|
40
|
+
export interface IntegrationDomain extends IntegrationApi<unknown> {
|
|
41
|
+
readonly transform: Transform<IntegrationDraft>;
|
|
42
|
+
readonly reload: () => Effect.Effect<void>;
|
|
42
43
|
readonly connection: {
|
|
43
44
|
readonly active: (integrationID: string) => Effect.Effect<ConnectionInfo | undefined>;
|
|
44
45
|
readonly resolve: (connection: ConnectionInfo) => Effect.Effect<CredentialValue | undefined, unknown>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/v2/effect/npm.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/v2/effect/path.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,11 +1,32 @@
|
|
|
1
|
+
import type { PluginApi } from "@opencode-ai/client/effect/api";
|
|
1
2
|
import type { Effect, Scope } from "effect";
|
|
2
|
-
import type {
|
|
3
|
+
import type { PluginOptions } from "../options.js";
|
|
4
|
+
import type { AgentDomain } from "./agent.js";
|
|
5
|
+
import type { AISDKDomain } from "./aisdk.js";
|
|
6
|
+
import type { CatalogDomain } from "./catalog.js";
|
|
7
|
+
import type { CommandDomain } from "./command.js";
|
|
8
|
+
import type { EventDomain } from "./event.js";
|
|
9
|
+
import type { IntegrationDomain } from "./integration.js";
|
|
10
|
+
import type { ReferenceDomain } from "./reference.js";
|
|
11
|
+
import type { SessionDomain } from "./session.js";
|
|
12
|
+
import type { SkillDomain } from "./skill.js";
|
|
13
|
+
import type { ToolDomain } from "./tool.js";
|
|
14
|
+
export interface Context {
|
|
15
|
+
readonly options: PluginOptions;
|
|
16
|
+
readonly agent: AgentDomain;
|
|
17
|
+
readonly aisdk: AISDKDomain;
|
|
18
|
+
readonly catalog: CatalogDomain;
|
|
19
|
+
readonly command: CommandDomain;
|
|
20
|
+
readonly event: EventDomain;
|
|
21
|
+
readonly integration: IntegrationDomain;
|
|
22
|
+
readonly plugin: PluginApi<unknown>;
|
|
23
|
+
readonly reference: ReferenceDomain;
|
|
24
|
+
readonly session: SessionDomain;
|
|
25
|
+
readonly skill: SkillDomain;
|
|
26
|
+
readonly tool: ToolDomain;
|
|
27
|
+
}
|
|
3
28
|
export interface Plugin<R = Scope.Scope> {
|
|
4
29
|
readonly id: string;
|
|
5
|
-
readonly effect: (context:
|
|
30
|
+
readonly effect: (context: Context) => Effect.Effect<void, never, R>;
|
|
6
31
|
}
|
|
7
32
|
export declare function define<R = Scope.Scope>(plugin: Plugin<R>): Plugin<R>;
|
|
8
|
-
export interface PluginDomain {
|
|
9
|
-
readonly add: (plugin: Plugin) => Effect.Effect<void>;
|
|
10
|
-
readonly remove: (id: string) => Effect.Effect<void>;
|
|
11
|
-
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { ReferenceGitSource, ReferenceLocalSource } from "@opencode-ai/sdk/v2/types";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ReferenceApi } from "@opencode-ai/client/effect/api";
|
|
3
|
+
import type { Effect } from "effect";
|
|
4
|
+
import type { Transform } from "./registration.js";
|
|
3
5
|
export interface ReferenceDraft {
|
|
4
6
|
add(name: string, source: ReferenceLocalSource | ReferenceGitSource): void;
|
|
5
7
|
remove(name: string): void;
|
|
6
8
|
list(): readonly (readonly [string, ReferenceLocalSource | ReferenceGitSource])[];
|
|
7
9
|
}
|
|
8
|
-
export
|
|
9
|
-
transform: ReferenceDraft
|
|
10
|
-
|
|
10
|
+
export interface ReferenceDomain extends ReferenceApi<unknown> {
|
|
11
|
+
readonly transform: Transform<ReferenceDraft>;
|
|
12
|
+
readonly reload: () => Effect.Effect<void>;
|
|
13
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -2,9 +2,5 @@ import type { Effect, Scope } from "effect";
|
|
|
2
2
|
export interface Registration {
|
|
3
3
|
readonly dispose: Effect.Effect<void>;
|
|
4
4
|
}
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
export type Hooks<Spec> = {
|
|
9
|
-
readonly [Name in keyof Spec]: (callback: (input: Spec[Name]) => Effect.Effect<void> | void) => Effect.Effect<Registration, never, Scope.Scope>;
|
|
10
|
-
};
|
|
5
|
+
export type Hooks<Spec> = <Name extends keyof Spec>(name: Name, callback: (input: Spec[Name]) => Effect.Effect<void>) => Effect.Effect<Registration, never, Scope.Scope>;
|
|
6
|
+
export type Transform<Input> = (callback: (input: Input) => void) => Effect.Effect<Registration, never, Scope.Scope>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
File without changes
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { SkillSource } from "@opencode-ai/sdk/v2/types";
|
|
2
|
+
import type { SkillApi } from "@opencode-ai/client/effect/api";
|
|
3
|
+
import type { Effect } from "effect";
|
|
4
|
+
import type { Transform } from "./registration.js";
|
|
3
5
|
export interface SkillDraft {
|
|
4
|
-
source(source:
|
|
5
|
-
list(): readonly
|
|
6
|
+
source(source: SkillSource): void;
|
|
7
|
+
list(): readonly SkillSource[];
|
|
8
|
+
}
|
|
9
|
+
export interface SkillDomain extends SkillApi<unknown> {
|
|
10
|
+
readonly transform: Transform<SkillDraft>;
|
|
11
|
+
readonly reload: () => Effect.Effect<void>;
|
|
6
12
|
}
|
|
7
|
-
export type SkillHooks = Hooks<{
|
|
8
|
-
transform: SkillDraft;
|
|
9
|
-
}>;
|
package/dist/v2/effect/skill.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
export * as Tool from "./tool.js";
|
|
2
|
+
import { Agent } from "@opencode-ai/schema/agent";
|
|
3
|
+
import type { LLM } from "@opencode-ai/schema/llm";
|
|
4
|
+
import { Session } from "@opencode-ai/schema/session";
|
|
5
|
+
import { SessionMessage } from "@opencode-ai/schema/session-message";
|
|
6
|
+
import { Effect, JsonSchema, Schema } from "effect";
|
|
7
|
+
import type { Hooks, Transform } from "./registration.js";
|
|
8
|
+
export interface Context {
|
|
9
|
+
readonly sessionID: Session.ID;
|
|
10
|
+
readonly agent: Agent.ID;
|
|
11
|
+
readonly assistantMessageID: SessionMessage.ID;
|
|
12
|
+
readonly toolCallID: string;
|
|
13
|
+
}
|
|
14
|
+
export type SchemaType<A> = Schema.Codec<A, any>;
|
|
15
|
+
type ToolDefinition = {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly description: string;
|
|
18
|
+
readonly inputSchema: JsonSchema.JsonSchema;
|
|
19
|
+
readonly outputSchema?: JsonSchema.JsonSchema;
|
|
20
|
+
};
|
|
21
|
+
type ToolCall = {
|
|
22
|
+
readonly input: unknown;
|
|
23
|
+
readonly [key: string]: unknown;
|
|
24
|
+
};
|
|
25
|
+
type ToolResultValue = {
|
|
26
|
+
readonly type: "json";
|
|
27
|
+
readonly value: unknown;
|
|
28
|
+
} | {
|
|
29
|
+
readonly type: "text";
|
|
30
|
+
readonly value: unknown;
|
|
31
|
+
} | {
|
|
32
|
+
readonly type: "error";
|
|
33
|
+
readonly value: unknown;
|
|
34
|
+
} | {
|
|
35
|
+
readonly type: "content";
|
|
36
|
+
readonly value: ReadonlyArray<LLM.ToolContent>;
|
|
37
|
+
};
|
|
38
|
+
type ToolOutput = {
|
|
39
|
+
readonly structured: unknown;
|
|
40
|
+
readonly content: ReadonlyArray<LLM.ToolContent>;
|
|
41
|
+
};
|
|
42
|
+
declare const TypeId: unique symbol;
|
|
43
|
+
export interface Definition<Input extends SchemaType<any>, Output extends SchemaType<any>> {
|
|
44
|
+
readonly [TypeId]: {
|
|
45
|
+
readonly _Input: Input;
|
|
46
|
+
readonly _Output: Output;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export type AnyTool = Definition<any, any>;
|
|
50
|
+
declare const Failure_base: Schema.Class<Failure, Schema.TaggedStruct<"LLM.ToolFailure", {
|
|
51
|
+
readonly message: Schema.String;
|
|
52
|
+
readonly error: Schema.optional<Schema.Defect>;
|
|
53
|
+
readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
54
|
+
}>, import("effect/Cause").YieldableError>;
|
|
55
|
+
export declare class Failure extends Failure_base {
|
|
56
|
+
}
|
|
57
|
+
declare const RegistrationError_base: Schema.Class<RegistrationError, Schema.TaggedStruct<"Tool.RegistrationError", {
|
|
58
|
+
readonly name: Schema.String;
|
|
59
|
+
readonly message: Schema.String;
|
|
60
|
+
}>, import("effect/Cause").YieldableError>;
|
|
61
|
+
export declare class RegistrationError extends RegistrationError_base {
|
|
62
|
+
}
|
|
63
|
+
export type Content = {
|
|
64
|
+
readonly type: "text";
|
|
65
|
+
readonly text: string;
|
|
66
|
+
} | {
|
|
67
|
+
readonly type: "file";
|
|
68
|
+
readonly data: string;
|
|
69
|
+
readonly mime: string;
|
|
70
|
+
readonly name?: string;
|
|
71
|
+
};
|
|
72
|
+
type Config<Input extends SchemaType<any>, Output extends SchemaType<any>, Structured extends SchemaType<any> = Output> = {
|
|
73
|
+
readonly description: string;
|
|
74
|
+
readonly input: Input;
|
|
75
|
+
readonly output: Output;
|
|
76
|
+
readonly structured?: Structured;
|
|
77
|
+
readonly toStructuredOutput?: (input: {
|
|
78
|
+
readonly input: Schema.Schema.Type<Input>;
|
|
79
|
+
readonly output: Output["Encoded"];
|
|
80
|
+
}) => Schema.Schema.Type<Structured>;
|
|
81
|
+
readonly execute: (input: Schema.Schema.Type<Input>, context: Context) => Effect.Effect<Schema.Schema.Type<Output>, Failure>;
|
|
82
|
+
readonly toModelOutput?: (input: {
|
|
83
|
+
readonly input: Schema.Schema.Type<Input>;
|
|
84
|
+
readonly output: Output["Encoded"];
|
|
85
|
+
}) => ReadonlyArray<Content>;
|
|
86
|
+
};
|
|
87
|
+
export type DynamicOutput = {
|
|
88
|
+
readonly structured: unknown;
|
|
89
|
+
readonly content: ReadonlyArray<Content>;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Config for a tool whose input shape is a raw JSON Schema not known at compile
|
|
93
|
+
* time (MCP servers, plugin manifests). Input is passed through as `unknown`;
|
|
94
|
+
* `execute` returns the already-projected structured value and model content.
|
|
95
|
+
*/
|
|
96
|
+
type DynamicConfig = {
|
|
97
|
+
readonly description: string;
|
|
98
|
+
readonly jsonSchema: JsonSchema.JsonSchema;
|
|
99
|
+
readonly outputSchema?: JsonSchema.JsonSchema;
|
|
100
|
+
readonly execute: (input: unknown, context: Context) => Effect.Effect<DynamicOutput, Failure>;
|
|
101
|
+
};
|
|
102
|
+
export declare function make<Input extends SchemaType<any>, Output extends SchemaType<any>, Structured extends SchemaType<any> = Output>(config: Config<Input, Output, Structured>): Definition<Input, Structured>;
|
|
103
|
+
export declare function make(config: DynamicConfig): AnyTool;
|
|
104
|
+
export declare const validateName: (name: string) => Effect.Effect<void, never, never> | Effect.Effect<never, RegistrationError, never>;
|
|
105
|
+
export declare const registrationEntries: (tools: Readonly<Record<string, AnyTool>>, group?: string) => {
|
|
106
|
+
key: string;
|
|
107
|
+
name: string;
|
|
108
|
+
group: string | undefined;
|
|
109
|
+
tool: AnyTool;
|
|
110
|
+
}[];
|
|
111
|
+
export declare const withPermission: <Input extends SchemaType<any>, Output extends SchemaType<any>>(tool: Definition<Input, Output>, permission: string) => Definition<Input, Output>;
|
|
112
|
+
export declare const permission: (tool: AnyTool, name: string) => string;
|
|
113
|
+
export declare const definition: (name: string, tool: AnyTool) => ToolDefinition;
|
|
114
|
+
export declare const settle: (tool: AnyTool, call: ToolCall, context: Context) => Effect.Effect<ToolOutput, Failure, never>;
|
|
115
|
+
export interface ToolExecuteBeforeEvent {
|
|
116
|
+
readonly tool: string;
|
|
117
|
+
readonly sessionID: Session.ID;
|
|
118
|
+
readonly agent: Agent.ID;
|
|
119
|
+
readonly assistantMessageID: SessionMessage.ID;
|
|
120
|
+
readonly toolCallID: string;
|
|
121
|
+
input: unknown;
|
|
122
|
+
}
|
|
123
|
+
export interface ToolExecuteAfterEvent {
|
|
124
|
+
readonly tool: string;
|
|
125
|
+
readonly sessionID: Session.ID;
|
|
126
|
+
readonly agent: Agent.ID;
|
|
127
|
+
readonly assistantMessageID: SessionMessage.ID;
|
|
128
|
+
readonly toolCallID: string;
|
|
129
|
+
readonly input: unknown;
|
|
130
|
+
result: ToolResultValue;
|
|
131
|
+
output?: ToolOutput;
|
|
132
|
+
outputPaths?: ReadonlyArray<string>;
|
|
133
|
+
}
|
|
134
|
+
export interface RegisterOptions {
|
|
135
|
+
readonly group?: string;
|
|
136
|
+
readonly deferred?: boolean;
|
|
137
|
+
}
|
|
138
|
+
export interface ToolDraft {
|
|
139
|
+
add(name: string, tool: AnyTool, options?: RegisterOptions): void;
|
|
140
|
+
}
|
|
141
|
+
export interface ToolHooks {
|
|
142
|
+
readonly "execute.before": ToolExecuteBeforeEvent;
|
|
143
|
+
readonly "execute.after": ToolExecuteAfterEvent;
|
|
144
|
+
}
|
|
145
|
+
export interface ToolDomain {
|
|
146
|
+
readonly transform: Transform<ToolDraft>;
|
|
147
|
+
readonly hook: Hooks<ToolHooks>;
|
|
148
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
export * as Tool from "./tool.js";
|
|
2
|
+
import { Agent } from "@opencode-ai/schema/agent";
|
|
3
|
+
import { Session } from "@opencode-ai/schema/session";
|
|
4
|
+
import { SessionMessage } from "@opencode-ai/schema/session-message";
|
|
5
|
+
import { Effect, JsonSchema, Schema } from "effect";
|
|
6
|
+
export class Failure extends Schema.TaggedErrorClass()("LLM.ToolFailure", {
|
|
7
|
+
message: Schema.String,
|
|
8
|
+
error: Schema.optional(Schema.Defect()),
|
|
9
|
+
metadata: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
|
|
10
|
+
}) {
|
|
11
|
+
}
|
|
12
|
+
export class RegistrationError extends Schema.TaggedErrorClass()("Tool.RegistrationError", {
|
|
13
|
+
name: Schema.String,
|
|
14
|
+
message: Schema.String,
|
|
15
|
+
}) {
|
|
16
|
+
}
|
|
17
|
+
const runtimes = new WeakMap();
|
|
18
|
+
export function make(config) {
|
|
19
|
+
if ("jsonSchema" in config)
|
|
20
|
+
return makeDynamic(config);
|
|
21
|
+
return makeTyped(config);
|
|
22
|
+
}
|
|
23
|
+
function makeTyped(config) {
|
|
24
|
+
const tool = Object.freeze({});
|
|
25
|
+
const definitions = new Map();
|
|
26
|
+
runtimes.set(tool, {
|
|
27
|
+
definition: (name) => {
|
|
28
|
+
const cached = definitions.get(name);
|
|
29
|
+
if (cached)
|
|
30
|
+
return cached;
|
|
31
|
+
const definition = {
|
|
32
|
+
name,
|
|
33
|
+
description: config.description,
|
|
34
|
+
inputSchema: toJsonSchema(config.input),
|
|
35
|
+
outputSchema: toJsonSchema(config.structured ?? config.output),
|
|
36
|
+
};
|
|
37
|
+
definitions.set(name, definition);
|
|
38
|
+
return definition;
|
|
39
|
+
},
|
|
40
|
+
settle: (call, context) => Schema.decodeUnknownEffect(config.input)(call.input).pipe(Effect.mapError((error) => new Failure({ message: `Invalid tool input: ${error.message}` })), Effect.flatMap((input) => config.execute(input, context).pipe(Effect.flatMap((output) => Schema.encodeEffect(config.output)(output).pipe(Effect.flatMap((output) => {
|
|
41
|
+
if (!config.structured || !config.toStructuredOutput)
|
|
42
|
+
return Effect.succeed({ output, structured: output });
|
|
43
|
+
return Schema.encodeEffect(config.structured)(config.toStructuredOutput({ input, output })).pipe(Effect.map((structured) => ({ output, structured })));
|
|
44
|
+
}), Effect.mapError((error) => new Failure({
|
|
45
|
+
message: `Tool returned an invalid value for its output schema: ${error.message}`,
|
|
46
|
+
})))), Effect.map(({ output, structured }) => ({
|
|
47
|
+
structured,
|
|
48
|
+
content: config.toModelOutput?.({ input, output }).map(toModelContent) ??
|
|
49
|
+
(typeof output === "string" ? [{ type: "text", text: output }] : []),
|
|
50
|
+
}))))),
|
|
51
|
+
});
|
|
52
|
+
return tool;
|
|
53
|
+
}
|
|
54
|
+
function makeDynamic(config) {
|
|
55
|
+
const tool = Object.freeze({});
|
|
56
|
+
const definitions = new Map();
|
|
57
|
+
runtimes.set(tool, {
|
|
58
|
+
definition: (name) => {
|
|
59
|
+
const cached = definitions.get(name);
|
|
60
|
+
if (cached)
|
|
61
|
+
return cached;
|
|
62
|
+
const definition = {
|
|
63
|
+
name,
|
|
64
|
+
description: config.description,
|
|
65
|
+
inputSchema: config.jsonSchema,
|
|
66
|
+
outputSchema: config.outputSchema,
|
|
67
|
+
};
|
|
68
|
+
definitions.set(name, definition);
|
|
69
|
+
return definition;
|
|
70
|
+
},
|
|
71
|
+
settle: (call, context) => config
|
|
72
|
+
.execute(call.input, context)
|
|
73
|
+
.pipe(Effect.map((output) => ({ structured: output.structured, content: output.content.map(toModelContent) }))),
|
|
74
|
+
});
|
|
75
|
+
return tool;
|
|
76
|
+
}
|
|
77
|
+
function toModelContent(part) {
|
|
78
|
+
if (part.type === "text")
|
|
79
|
+
return { type: "text", text: part.text };
|
|
80
|
+
return { type: "file", uri: `data:${part.mime};base64,${part.data}`, mime: part.mime, name: part.name };
|
|
81
|
+
}
|
|
82
|
+
export const validateName = (name) => /^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(name)
|
|
83
|
+
? Effect.void
|
|
84
|
+
: Effect.fail(new RegistrationError({ name, message: `Invalid tool name: ${name}` }));
|
|
85
|
+
export const registrationEntries = (tools, group) => Object.entries(tools).map(([name, tool]) => {
|
|
86
|
+
const normalized = name.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
87
|
+
const parent = group?.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
88
|
+
return {
|
|
89
|
+
key: parent === undefined ? normalized : `${parent}_${normalized}`,
|
|
90
|
+
name: normalized,
|
|
91
|
+
group: parent,
|
|
92
|
+
tool,
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
export const withPermission = (tool, permission) => {
|
|
96
|
+
const decorated = Object.freeze({});
|
|
97
|
+
runtimes.set(decorated, { ...runtimeOf(tool), permission });
|
|
98
|
+
return decorated;
|
|
99
|
+
};
|
|
100
|
+
export const permission = (tool, name) => runtimeOf(tool).permission ?? name;
|
|
101
|
+
export const definition = (name, tool) => runtimeOf(tool).definition(name);
|
|
102
|
+
export const settle = (tool, call, context) => runtimeOf(tool).settle(call, context);
|
|
103
|
+
function runtimeOf(tool) {
|
|
104
|
+
const runtime = runtimes.get(tool);
|
|
105
|
+
if (!runtime)
|
|
106
|
+
throw new TypeError("Invalid Tool value");
|
|
107
|
+
return runtime;
|
|
108
|
+
}
|
|
109
|
+
function toJsonSchema(schema) {
|
|
110
|
+
const document = Schema.toJsonSchemaDocument(schema);
|
|
111
|
+
if (Object.keys(document.definitions).length === 0)
|
|
112
|
+
return document.schema;
|
|
113
|
+
return { ...document.schema, $defs: document.definitions };
|
|
114
|
+
}
|
package/dist/v2/options.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import type { AgentApi } from "@opencode-ai/client/promise/api";
|
|
1
2
|
import type { AgentDraft } from "../effect/agent.js";
|
|
2
|
-
import type {
|
|
3
|
+
import type { Transform } from "./registration.js";
|
|
3
4
|
export type { AgentDraft };
|
|
4
|
-
export
|
|
5
|
-
transform: AgentDraft
|
|
6
|
-
|
|
5
|
+
export interface AgentDomain extends AgentApi {
|
|
6
|
+
readonly transform: Transform<AgentDraft>;
|
|
7
|
+
readonly reload: () => Promise<void>;
|
|
8
|
+
}
|
package/dist/v2/promise/agent.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import type { LanguageModelV3 } from "@ai-sdk/provider";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Model } from "@opencode-ai/schema/model";
|
|
3
3
|
import type { Hooks } from "./registration.js";
|
|
4
|
-
export
|
|
4
|
+
export interface AISDKHooks {
|
|
5
5
|
sdk: {
|
|
6
|
-
readonly model:
|
|
6
|
+
readonly model: Model.Info;
|
|
7
7
|
readonly package: string;
|
|
8
8
|
readonly options: Record<string, any>;
|
|
9
9
|
sdk?: any;
|
|
10
10
|
};
|
|
11
11
|
language: {
|
|
12
|
-
readonly model:
|
|
12
|
+
readonly model: Model.Info;
|
|
13
13
|
readonly sdk: any;
|
|
14
14
|
readonly options: Record<string, any>;
|
|
15
15
|
language?: LanguageModelV3;
|
|
16
16
|
};
|
|
17
|
-
}
|
|
17
|
+
}
|
|
18
|
+
export interface AISDKDomain {
|
|
19
|
+
readonly hook: Hooks<AISDKHooks>;
|
|
20
|
+
}
|
package/dist/v2/promise/aisdk.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import type { CatalogApi } from "@opencode-ai/client/promise/api";
|
|
1
2
|
import type { CatalogDraft, CatalogProviderRecord } from "../effect/catalog.js";
|
|
2
|
-
import type {
|
|
3
|
+
import type { Transform } from "./registration.js";
|
|
3
4
|
export type { CatalogDraft, CatalogProviderRecord };
|
|
4
|
-
export
|
|
5
|
-
transform: CatalogDraft
|
|
6
|
-
|
|
5
|
+
export interface CatalogDomain extends CatalogApi {
|
|
6
|
+
readonly transform: Transform<CatalogDraft>;
|
|
7
|
+
readonly reload: () => Promise<void>;
|
|
8
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import type { CommandApi } from "@opencode-ai/client/promise/api";
|
|
1
2
|
import type { CommandDraft } from "../effect/command.js";
|
|
2
|
-
import type {
|
|
3
|
+
import type { Transform } from "./registration.js";
|
|
3
4
|
export type { CommandDraft };
|
|
4
|
-
export
|
|
5
|
-
transform: CommandDraft
|
|
6
|
-
|
|
5
|
+
export interface CommandDomain extends CommandApi {
|
|
6
|
+
readonly transform: Transform<CommandDraft>;
|
|
7
|
+
readonly reload: () => Promise<void>;
|
|
8
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
File without changes
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export type { PluginContext } from "./context.js";
|
|
2
1
|
export type { PluginOptions } from "../options.js";
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
2
|
+
export * as Plugin from "./plugin.js";
|
|
3
|
+
export { Tool } from "./tool.js";
|
|
4
|
+
export { Agent } from "@opencode-ai/schema/agent";
|
|
5
|
+
export { Command } from "@opencode-ai/schema/command";
|
|
6
|
+
export { Connection } from "@opencode-ai/schema/connection";
|
|
7
|
+
export { Credential } from "@opencode-ai/schema/credential";
|
|
8
|
+
export { Integration } from "@opencode-ai/schema/integration";
|
|
9
|
+
export { Model } from "@opencode-ai/schema/model";
|
|
10
|
+
export { Provider } from "@opencode-ai/schema/provider";
|
|
11
|
+
export { Reference } from "@opencode-ai/schema/reference";
|
|
12
|
+
export { Skill } from "@opencode-ai/schema/skill";
|
package/dist/v2/promise/index.js
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * as Plugin from "./plugin.js";
|
|
2
|
+
export { Tool } from "./tool.js";
|
|
3
|
+
export { Agent } from "@opencode-ai/schema/agent";
|
|
4
|
+
export { Command } from "@opencode-ai/schema/command";
|
|
5
|
+
export { Connection } from "@opencode-ai/schema/connection";
|
|
6
|
+
export { Credential } from "@opencode-ai/schema/credential";
|
|
7
|
+
export { Integration } from "@opencode-ai/schema/integration";
|
|
8
|
+
export { Model } from "@opencode-ai/schema/model";
|
|
9
|
+
export { Provider } from "@opencode-ai/schema/provider";
|
|
10
|
+
export { Reference } from "@opencode-ai/schema/reference";
|
|
11
|
+
export { Skill } from "@opencode-ai/schema/skill";
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import type { IntegrationApi } from "@opencode-ai/client/promise/api";
|
|
1
2
|
import type { IntegrationDraft, IntegrationMethodRegistration } from "../effect/integration.js";
|
|
2
3
|
import type { CredentialValue } from "@opencode-ai/sdk/v2/types";
|
|
3
|
-
import type {
|
|
4
|
+
import type { Transform } from "./registration.js";
|
|
4
5
|
export type { IntegrationDraft, IntegrationMethodRegistration };
|
|
5
|
-
export interface
|
|
6
|
-
transform: IntegrationDraft
|
|
7
|
-
|
|
6
|
+
export interface IntegrationDomain extends IntegrationApi {
|
|
7
|
+
readonly transform: Transform<IntegrationDraft>;
|
|
8
|
+
readonly reload: () => Promise<void>;
|
|
8
9
|
readonly connection: {
|
|
9
10
|
readonly active: (integrationID: string) => Promise<import("@opencode-ai/sdk/v2/types").ConnectionInfo | undefined>;
|
|
10
11
|
readonly resolve: (connection: import("@opencode-ai/sdk/v2/types").ConnectionInfo) => Promise<CredentialValue | undefined>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,10 +1,31 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PluginApi } from "@opencode-ai/client/promise/api";
|
|
2
|
+
import type { PluginOptions } from "../options.js";
|
|
3
|
+
import type { AgentDomain } from "./agent.js";
|
|
4
|
+
import type { AISDKDomain } from "./aisdk.js";
|
|
5
|
+
import type { CatalogDomain } from "./catalog.js";
|
|
6
|
+
import type { CommandDomain } from "./command.js";
|
|
7
|
+
import type { EventDomain } from "./event.js";
|
|
8
|
+
import type { IntegrationDomain } from "./integration.js";
|
|
9
|
+
import type { ReferenceDomain } from "./reference.js";
|
|
10
|
+
import type { SessionDomain } from "./session.js";
|
|
11
|
+
import type { SkillDomain } from "./skill.js";
|
|
12
|
+
import type { ToolDomain } from "./tool.js";
|
|
13
|
+
export interface Context {
|
|
14
|
+
readonly options: PluginOptions;
|
|
15
|
+
readonly agent: AgentDomain;
|
|
16
|
+
readonly aisdk: AISDKDomain;
|
|
17
|
+
readonly catalog: CatalogDomain;
|
|
18
|
+
readonly command: CommandDomain;
|
|
19
|
+
readonly event: EventDomain;
|
|
20
|
+
readonly integration: IntegrationDomain;
|
|
21
|
+
readonly plugin: PluginApi;
|
|
22
|
+
readonly reference: ReferenceDomain;
|
|
23
|
+
readonly session: SessionDomain;
|
|
24
|
+
readonly skill: SkillDomain;
|
|
25
|
+
readonly tool: ToolDomain;
|
|
26
|
+
}
|
|
2
27
|
export interface Plugin {
|
|
3
28
|
readonly id: string;
|
|
4
|
-
readonly setup: (context:
|
|
29
|
+
readonly setup: (context: Context) => Promise<void> | void;
|
|
5
30
|
}
|
|
6
31
|
export declare function define(plugin: Plugin): Plugin;
|
|
7
|
-
export interface PluginDomain {
|
|
8
|
-
readonly add: (plugin: Plugin) => Promise<void>;
|
|
9
|
-
readonly remove: (id: string) => Promise<void>;
|
|
10
|
-
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import type { ReferenceApi } from "@opencode-ai/client/promise/api";
|
|
1
2
|
import type { ReferenceDraft } from "../effect/reference.js";
|
|
2
|
-
import type {
|
|
3
|
+
import type { Transform } from "./registration.js";
|
|
3
4
|
export type { ReferenceDraft };
|
|
4
|
-
export
|
|
5
|
-
transform: ReferenceDraft
|
|
6
|
-
|
|
5
|
+
export interface ReferenceDomain extends ReferenceApi {
|
|
6
|
+
readonly transform: Transform<ReferenceDraft>;
|
|
7
|
+
readonly reload: () => Promise<void>;
|
|
8
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
export interface Registration {
|
|
2
2
|
readonly dispose: () => Promise<void>;
|
|
3
3
|
}
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
export type Hooks<Spec> = {
|
|
8
|
-
readonly [Name in keyof Spec]: (callback: (input: Spec[Name]) => Promise<void> | void) => Promise<Registration>;
|
|
9
|
-
};
|
|
4
|
+
export type Hooks<Spec> = <Name extends keyof Spec>(name: Name, callback: (input: Spec[Name]) => Promise<void> | void) => Promise<Registration>;
|
|
5
|
+
export type Transform<Input> = (callback: (input: Input) => void) => Promise<Registration>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
File without changes
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import type { SkillApi } from "@opencode-ai/client/promise/api";
|
|
1
2
|
import type { SkillDraft } from "../effect/skill.js";
|
|
2
|
-
import type {
|
|
3
|
+
import type { Transform } from "./registration.js";
|
|
3
4
|
export type { SkillDraft };
|
|
4
|
-
export
|
|
5
|
-
transform: SkillDraft
|
|
6
|
-
|
|
5
|
+
export interface SkillDomain extends SkillApi {
|
|
6
|
+
readonly transform: Transform<SkillDraft>;
|
|
7
|
+
readonly reload: () => Promise<void>;
|
|
8
|
+
}
|
package/dist/v2/promise/skill.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export * as Tool from "./tool.js";
|
|
2
|
+
import { Tool } from "../effect/tool.js";
|
|
3
|
+
import type { Agent } from "@opencode-ai/schema/agent";
|
|
4
|
+
import type { Session } from "@opencode-ai/schema/session";
|
|
5
|
+
import type { SessionMessage } from "@opencode-ai/schema/session-message";
|
|
6
|
+
import { type JsonSchema, type Schema } from "effect";
|
|
7
|
+
import type { Hooks, Transform } from "./registration.js";
|
|
8
|
+
export type Context = Tool.Context;
|
|
9
|
+
export type SchemaType<A> = Tool.SchemaType<A>;
|
|
10
|
+
export type Definition<Input extends SchemaType<any>, Output extends SchemaType<any>> = Tool.Definition<Input, Output>;
|
|
11
|
+
export type AnyTool = Tool.AnyTool;
|
|
12
|
+
export declare const Failure: typeof Tool.Failure;
|
|
13
|
+
export type Failure = Tool.Failure;
|
|
14
|
+
export declare const RegistrationError: typeof Tool.RegistrationError;
|
|
15
|
+
export type RegistrationError = Tool.RegistrationError;
|
|
16
|
+
export type Content = Tool.Content;
|
|
17
|
+
export type DynamicOutput = Tool.DynamicOutput;
|
|
18
|
+
type Config<Input extends SchemaType<any>, Output extends SchemaType<any>, Structured extends SchemaType<any> = Output> = {
|
|
19
|
+
readonly description: string;
|
|
20
|
+
readonly input: Input;
|
|
21
|
+
readonly output: Output;
|
|
22
|
+
readonly structured?: Structured;
|
|
23
|
+
readonly toStructuredOutput?: (input: {
|
|
24
|
+
readonly input: Schema.Schema.Type<Input>;
|
|
25
|
+
readonly output: Output["Encoded"];
|
|
26
|
+
}) => Schema.Schema.Type<Structured>;
|
|
27
|
+
readonly execute: (input: Schema.Schema.Type<Input>, context: Context) => Promise<Schema.Schema.Type<Output>>;
|
|
28
|
+
readonly toModelOutput?: (input: {
|
|
29
|
+
readonly input: Schema.Schema.Type<Input>;
|
|
30
|
+
readonly output: Output["Encoded"];
|
|
31
|
+
}) => ReadonlyArray<Content>;
|
|
32
|
+
};
|
|
33
|
+
type DynamicConfig = {
|
|
34
|
+
readonly description: string;
|
|
35
|
+
readonly jsonSchema: JsonSchema.JsonSchema;
|
|
36
|
+
readonly outputSchema?: JsonSchema.JsonSchema;
|
|
37
|
+
readonly execute: (input: unknown, context: Context) => Promise<DynamicOutput>;
|
|
38
|
+
};
|
|
39
|
+
export declare function make<Input extends SchemaType<any>, Output extends SchemaType<any>, Structured extends SchemaType<any> = Output>(config: Config<Input, Output, Structured>): Definition<Input, Structured>;
|
|
40
|
+
export declare function make(config: DynamicConfig): AnyTool;
|
|
41
|
+
export declare const withPermission: <Input extends Tool.SchemaType<any>, Output extends Tool.SchemaType<any>>(tool: Tool.Definition<Input, Output>, permission: string) => Tool.Definition<Input, Output>;
|
|
42
|
+
export interface ToolExecuteBeforeEvent {
|
|
43
|
+
readonly tool: string;
|
|
44
|
+
readonly sessionID: Session.ID;
|
|
45
|
+
readonly agent: Agent.ID;
|
|
46
|
+
readonly assistantMessageID: SessionMessage.ID;
|
|
47
|
+
readonly toolCallID: string;
|
|
48
|
+
input: unknown;
|
|
49
|
+
}
|
|
50
|
+
export interface ToolExecuteAfterEvent {
|
|
51
|
+
readonly tool: string;
|
|
52
|
+
readonly sessionID: Session.ID;
|
|
53
|
+
readonly agent: Agent.ID;
|
|
54
|
+
readonly assistantMessageID: SessionMessage.ID;
|
|
55
|
+
readonly toolCallID: string;
|
|
56
|
+
readonly input: unknown;
|
|
57
|
+
result: Tool.ToolExecuteAfterEvent["result"];
|
|
58
|
+
output?: Tool.ToolExecuteAfterEvent["output"];
|
|
59
|
+
outputPaths?: ReadonlyArray<string>;
|
|
60
|
+
}
|
|
61
|
+
export interface RegisterOptions {
|
|
62
|
+
readonly group?: string;
|
|
63
|
+
readonly deferred?: boolean;
|
|
64
|
+
}
|
|
65
|
+
export interface ToolDraft {
|
|
66
|
+
add(name: string, tool: AnyTool, options?: RegisterOptions): void;
|
|
67
|
+
}
|
|
68
|
+
export interface ToolHooks {
|
|
69
|
+
readonly "execute.before": ToolExecuteBeforeEvent;
|
|
70
|
+
readonly "execute.after": ToolExecuteAfterEvent;
|
|
71
|
+
}
|
|
72
|
+
export interface ToolDomain {
|
|
73
|
+
readonly transform: Transform<ToolDraft>;
|
|
74
|
+
readonly hook: Hooks<ToolHooks>;
|
|
75
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * as Tool from "./tool.js";
|
|
2
|
+
import { Tool } from "../effect/tool.js";
|
|
3
|
+
import { Effect } from "effect";
|
|
4
|
+
export const Failure = Tool.Failure;
|
|
5
|
+
export const RegistrationError = Tool.RegistrationError;
|
|
6
|
+
export function make(config) {
|
|
7
|
+
if ("jsonSchema" in config)
|
|
8
|
+
return Tool.make({
|
|
9
|
+
...config,
|
|
10
|
+
execute: (input, context) => Effect.promise(() => config.execute(input, context)),
|
|
11
|
+
});
|
|
12
|
+
return Tool.make({
|
|
13
|
+
...config,
|
|
14
|
+
execute: (input, context) => Effect.promise(() => config.execute(input, context)),
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export const withPermission = Tool.withPermission;
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@opencode-ai/plugin",
|
|
4
|
-
"version": "0.0.0-next-
|
|
4
|
+
"version": "0.0.0-next-15259",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {
|
|
8
|
+
"test": "bun test --timeout 5000",
|
|
8
9
|
"typecheck": "tsgo --noEmit",
|
|
9
|
-
"build": "tsc"
|
|
10
|
+
"build": "tsc -p tsconfig.build.json"
|
|
10
11
|
},
|
|
11
12
|
"exports": {
|
|
12
13
|
".": {
|
|
@@ -25,17 +26,17 @@
|
|
|
25
26
|
"import": "./dist/v2/effect/index.js",
|
|
26
27
|
"types": "./dist/v2/effect/index.d.ts"
|
|
27
28
|
},
|
|
28
|
-
"./v2/effect
|
|
29
|
-
"import": "./dist/v2/effect
|
|
30
|
-
"types": "./dist/v2/effect
|
|
29
|
+
"./v2/effect/*": {
|
|
30
|
+
"import": "./dist/v2/effect/*.js",
|
|
31
|
+
"types": "./dist/v2/effect/*.d.ts"
|
|
31
32
|
},
|
|
32
|
-
"./v2
|
|
33
|
-
"import": "./dist/v2/effect/plugin.js",
|
|
34
|
-
"types": "./dist/v2/effect/plugin.d.ts"
|
|
35
|
-
},
|
|
36
|
-
"./v2/promise": {
|
|
33
|
+
"./v2": {
|
|
37
34
|
"import": "./dist/v2/promise/index.js",
|
|
38
35
|
"types": "./dist/v2/promise/index.d.ts"
|
|
36
|
+
},
|
|
37
|
+
"./v2/*": {
|
|
38
|
+
"import": "./dist/v2/promise/*.js",
|
|
39
|
+
"types": "./dist/v2/promise/*.d.ts"
|
|
39
40
|
}
|
|
40
41
|
},
|
|
41
42
|
"files": [
|
|
@@ -43,14 +44,16 @@
|
|
|
43
44
|
],
|
|
44
45
|
"dependencies": {
|
|
45
46
|
"@ai-sdk/provider": "3.0.8",
|
|
46
|
-
"@opencode-ai/
|
|
47
|
+
"@opencode-ai/client": "0.0.0-next-15259",
|
|
48
|
+
"@opencode-ai/schema": "0.0.0-next-15259",
|
|
49
|
+
"@opencode-ai/sdk": "0.0.0-next-15259",
|
|
47
50
|
"effect": "4.0.0-beta.83",
|
|
48
51
|
"zod": "4.1.8"
|
|
49
52
|
},
|
|
50
53
|
"peerDependencies": {
|
|
51
|
-
"@opentui/core": ">=0.3
|
|
52
|
-
"@opentui/keymap": ">=0.3
|
|
53
|
-
"@opentui/solid": ">=0.3
|
|
54
|
+
"@opentui/core": ">=0.4.3",
|
|
55
|
+
"@opentui/keymap": ">=0.4.3",
|
|
56
|
+
"@opentui/solid": ">=0.4.3"
|
|
54
57
|
},
|
|
55
58
|
"peerDependenciesMeta": {
|
|
56
59
|
"@opentui/core": {
|
|
@@ -64,9 +67,10 @@
|
|
|
64
67
|
}
|
|
65
68
|
},
|
|
66
69
|
"devDependencies": {
|
|
67
|
-
"@opentui/core": "0.3
|
|
68
|
-
"@opentui/keymap": "0.3
|
|
69
|
-
"@opentui/solid": "0.3
|
|
70
|
+
"@opentui/core": "0.4.3",
|
|
71
|
+
"@opentui/keymap": "0.4.3",
|
|
72
|
+
"@opentui/solid": "0.4.3",
|
|
73
|
+
"@tsconfig/bun": "1.0.9",
|
|
70
74
|
"@tsconfig/node22": "22.0.2",
|
|
71
75
|
"@types/node": "24.12.2",
|
|
72
76
|
"typescript": "5.8.2",
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { PluginOptions } from "../options.js";
|
|
2
|
-
import type { AgentHooks } from "./agent.js";
|
|
3
|
-
import type { AISDKHooks } from "./aisdk.js";
|
|
4
|
-
import type { CatalogHooks } from "./catalog.js";
|
|
5
|
-
import type { CommandHooks } from "./command.js";
|
|
6
|
-
import type { IntegrationHooks } from "./integration.js";
|
|
7
|
-
import type { PluginDomain } from "./plugin.js";
|
|
8
|
-
import type { ReferenceHooks } from "./reference.js";
|
|
9
|
-
import type { SkillHooks } from "./skill.js";
|
|
10
|
-
import type { Reload } from "./registration.js";
|
|
11
|
-
export interface PluginContext {
|
|
12
|
-
readonly options: PluginOptions;
|
|
13
|
-
readonly agent: AgentHooks & Reload;
|
|
14
|
-
readonly aisdk: AISDKHooks;
|
|
15
|
-
readonly catalog: CatalogHooks & Reload;
|
|
16
|
-
readonly command: CommandHooks & Reload;
|
|
17
|
-
readonly integration: IntegrationHooks & Reload;
|
|
18
|
-
readonly plugin: PluginDomain;
|
|
19
|
-
readonly reference: ReferenceHooks & Reload;
|
|
20
|
-
readonly skill: SkillHooks & Reload;
|
|
21
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { PluginOptions } from "../options.js";
|
|
2
|
-
import type { AgentHooks } from "./agent.js";
|
|
3
|
-
import type { AISDKHooks } from "./aisdk.js";
|
|
4
|
-
import type { CatalogHooks } from "./catalog.js";
|
|
5
|
-
import type { CommandHooks } from "./command.js";
|
|
6
|
-
import type { IntegrationHooks } from "./integration.js";
|
|
7
|
-
import type { PluginDomain } from "./plugin.js";
|
|
8
|
-
import type { ReferenceHooks } from "./reference.js";
|
|
9
|
-
import type { SkillHooks } from "./skill.js";
|
|
10
|
-
import type { Reload } from "./registration.js";
|
|
11
|
-
export interface PluginContext {
|
|
12
|
-
readonly options: PluginOptions;
|
|
13
|
-
readonly agent: AgentHooks & Reload;
|
|
14
|
-
readonly aisdk: AISDKHooks;
|
|
15
|
-
readonly catalog: CatalogHooks & Reload;
|
|
16
|
-
readonly command: CommandHooks & Reload;
|
|
17
|
-
readonly integration: IntegrationHooks & Reload;
|
|
18
|
-
readonly plugin: PluginDomain;
|
|
19
|
-
readonly reference: ReferenceHooks & Reload;
|
|
20
|
-
readonly skill: SkillHooks & Reload;
|
|
21
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|