@opencode-ai/plugin 0.0.0-fix-build-202511160139 → 0.0.0-next-202606261956
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-workspace.d.ts +3 -0
- package/dist/example-workspace.js +30 -0
- package/dist/example.d.ts +1 -1
- package/dist/example.js +2 -2
- package/dist/index.d.ts +259 -92
- package/dist/index.js +1 -1
- package/dist/shell.js +1 -0
- package/dist/tool.d.ts +42 -2
- package/dist/tui.d.ts +510 -0
- package/dist/tui.js +7 -0
- package/dist/v2/effect/agent.d.ts +12 -0
- package/dist/v2/effect/agent.js +1 -0
- package/dist/v2/effect/aisdk.d.ts +17 -0
- package/dist/v2/effect/aisdk.js +1 -0
- package/dist/v2/effect/catalog.d.ts +29 -0
- package/dist/v2/effect/catalog.js +1 -0
- package/dist/v2/effect/command.d.ts +11 -0
- package/dist/v2/effect/command.js +1 -0
- package/dist/v2/effect/context.d.ts +21 -0
- package/dist/v2/effect/context.js +1 -0
- package/dist/v2/effect/event.d.ts +8 -0
- package/dist/v2/effect/event.js +1 -0
- package/dist/v2/effect/filesystem.d.ts +23 -0
- package/dist/v2/effect/filesystem.js +1 -0
- package/dist/v2/effect/index.d.ts +3 -0
- package/dist/v2/effect/index.js +1 -0
- package/dist/v2/effect/integration.d.ts +46 -0
- package/dist/v2/effect/integration.js +1 -0
- package/dist/v2/effect/location.d.ts +6 -0
- package/dist/v2/effect/location.js +1 -0
- package/dist/v2/effect/npm.d.ts +7 -0
- package/dist/v2/effect/npm.js +1 -0
- package/dist/v2/effect/path.d.ts +8 -0
- package/dist/v2/effect/path.js +1 -0
- package/dist/v2/effect/plugin.d.ts +11 -0
- package/dist/v2/effect/plugin.js +3 -0
- package/dist/v2/effect/reference.d.ts +10 -0
- package/dist/v2/effect/reference.js +1 -0
- package/dist/v2/effect/registration.d.ts +10 -0
- package/dist/v2/effect/registration.js +1 -0
- package/dist/v2/effect/skill.d.ts +9 -0
- package/dist/v2/effect/skill.js +1 -0
- package/dist/v2/options.d.ts +1 -0
- package/dist/v2/options.js +1 -0
- package/dist/v2/promise/agent.d.ts +6 -0
- package/dist/v2/promise/agent.js +1 -0
- package/dist/v2/promise/aisdk.d.ts +17 -0
- package/dist/v2/promise/aisdk.js +1 -0
- package/dist/v2/promise/catalog.d.ts +6 -0
- package/dist/v2/promise/catalog.js +1 -0
- package/dist/v2/promise/command.d.ts +6 -0
- package/dist/v2/promise/command.js +1 -0
- package/dist/v2/promise/context.d.ts +21 -0
- package/dist/v2/promise/context.js +1 -0
- package/dist/v2/promise/index.d.ts +12 -0
- package/dist/v2/promise/index.js +1 -0
- package/dist/v2/promise/integration.d.ts +12 -0
- package/dist/v2/promise/integration.js +1 -0
- package/dist/v2/promise/plugin.d.ts +10 -0
- package/dist/v2/promise/plugin.js +3 -0
- package/dist/v2/promise/reference.d.ts +6 -0
- package/dist/v2/promise/reference.js +1 -0
- package/dist/v2/promise/registration.d.ts +9 -0
- package/dist/v2/promise/registration.js +1 -0
- package/dist/v2/promise/skill.d.ts +6 -0
- package/dist/v2/promise/skill.js +1 -0
- package/package.json +46 -4
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { mkdir, rm } from "node:fs/promises";
|
|
2
|
+
export const FolderWorkspacePlugin = async ({ experimental_workspace }) => {
|
|
3
|
+
experimental_workspace.register("folder", {
|
|
4
|
+
name: "Folder",
|
|
5
|
+
description: "Create a blank folder",
|
|
6
|
+
configure(config) {
|
|
7
|
+
const rand = "" + Math.random();
|
|
8
|
+
return {
|
|
9
|
+
...config,
|
|
10
|
+
directory: `/tmp/folder/folder-${rand}`,
|
|
11
|
+
};
|
|
12
|
+
},
|
|
13
|
+
async create(config) {
|
|
14
|
+
if (!config.directory)
|
|
15
|
+
return;
|
|
16
|
+
await mkdir(config.directory, { recursive: true });
|
|
17
|
+
},
|
|
18
|
+
async remove(config) {
|
|
19
|
+
await rm(config.directory, { recursive: true, force: true });
|
|
20
|
+
},
|
|
21
|
+
target(config) {
|
|
22
|
+
return {
|
|
23
|
+
type: "local",
|
|
24
|
+
directory: config.directory,
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
return {};
|
|
29
|
+
};
|
|
30
|
+
export default FolderWorkspacePlugin;
|
package/dist/example.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Plugin } from "./index";
|
|
1
|
+
import { Plugin } from "./index.js";
|
|
2
2
|
export declare const ExamplePlugin: Plugin;
|
package/dist/example.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,177 @@
|
|
|
1
|
-
import type { Event, createOpencodeClient, Project, Model, Provider, Permission, UserMessage,
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import type { Event, createOpencodeClient, Project, Model, Provider, Permission, UserMessage, Message, Part, Config as SDKConfig } from "@opencode-ai/sdk";
|
|
2
|
+
import type { Provider as ProviderV2, Model as ModelV2, Auth } from "@opencode-ai/sdk/v2";
|
|
3
|
+
import type { BunShell } from "./shell.js";
|
|
4
|
+
import { type ToolDefinition } from "./tool.js";
|
|
5
|
+
export * from "./tool.js";
|
|
6
|
+
export type ProviderContext = {
|
|
7
|
+
source: "env" | "config" | "custom" | "api";
|
|
8
|
+
info: Provider;
|
|
9
|
+
options: Record<string, any>;
|
|
10
|
+
};
|
|
11
|
+
export type WorkspaceInfo = {
|
|
12
|
+
id: string;
|
|
13
|
+
type: string;
|
|
14
|
+
name: string;
|
|
15
|
+
branch: string | null;
|
|
16
|
+
directory: string | null;
|
|
17
|
+
extra: unknown | null;
|
|
18
|
+
projectID: string;
|
|
19
|
+
};
|
|
20
|
+
export type WorkspaceTarget = {
|
|
21
|
+
type: "local";
|
|
22
|
+
directory: string;
|
|
23
|
+
} | {
|
|
24
|
+
type: "remote";
|
|
25
|
+
url: string | URL;
|
|
26
|
+
headers?: HeadersInit;
|
|
27
|
+
};
|
|
28
|
+
export type WorkspaceAdapter = {
|
|
29
|
+
name: string;
|
|
30
|
+
description: string;
|
|
31
|
+
configure(config: WorkspaceInfo): WorkspaceInfo | Promise<WorkspaceInfo>;
|
|
32
|
+
create(config: WorkspaceInfo, env: Record<string, string | undefined>, from?: WorkspaceInfo): Promise<void>;
|
|
33
|
+
remove(config: WorkspaceInfo): Promise<void>;
|
|
34
|
+
target(config: WorkspaceInfo): WorkspaceTarget | Promise<WorkspaceTarget>;
|
|
35
|
+
};
|
|
5
36
|
export type PluginInput = {
|
|
6
37
|
client: ReturnType<typeof createOpencodeClient>;
|
|
7
38
|
project: Project;
|
|
8
39
|
directory: string;
|
|
9
40
|
worktree: string;
|
|
41
|
+
experimental_workspace: {
|
|
42
|
+
register(type: string, adapter: WorkspaceAdapter): void;
|
|
43
|
+
};
|
|
44
|
+
serverUrl: URL;
|
|
10
45
|
$: BunShell;
|
|
11
46
|
};
|
|
12
|
-
export type
|
|
47
|
+
export type PluginOptions = Record<string, unknown>;
|
|
48
|
+
export type Config = Omit<SDKConfig, "plugin"> & {
|
|
49
|
+
plugin?: Array<string | [string, PluginOptions]>;
|
|
50
|
+
};
|
|
51
|
+
export type Plugin = (input: PluginInput, options?: PluginOptions) => Promise<Hooks>;
|
|
52
|
+
export type PluginModule = {
|
|
53
|
+
id?: string;
|
|
54
|
+
server: Plugin;
|
|
55
|
+
tui?: never;
|
|
56
|
+
};
|
|
57
|
+
type Rule = {
|
|
58
|
+
key: string;
|
|
59
|
+
op: "eq" | "neq";
|
|
60
|
+
value: string;
|
|
61
|
+
};
|
|
62
|
+
export type AuthHook = {
|
|
63
|
+
provider: string;
|
|
64
|
+
loader?: (auth: () => Promise<Auth>, provider: Provider) => Promise<Record<string, any>>;
|
|
65
|
+
methods: ({
|
|
66
|
+
type: "oauth";
|
|
67
|
+
label: string;
|
|
68
|
+
prompts?: Array<{
|
|
69
|
+
type: "text";
|
|
70
|
+
key: string;
|
|
71
|
+
message: string;
|
|
72
|
+
placeholder?: string;
|
|
73
|
+
validate?: (value: string) => string | undefined;
|
|
74
|
+
/** @deprecated Use `when` instead */
|
|
75
|
+
condition?: (inputs: Record<string, string>) => boolean;
|
|
76
|
+
when?: Rule;
|
|
77
|
+
} | {
|
|
78
|
+
type: "select";
|
|
79
|
+
key: string;
|
|
80
|
+
message: string;
|
|
81
|
+
options: Array<{
|
|
82
|
+
label: string;
|
|
83
|
+
value: string;
|
|
84
|
+
hint?: string;
|
|
85
|
+
}>;
|
|
86
|
+
/** @deprecated Use `when` instead */
|
|
87
|
+
condition?: (inputs: Record<string, string>) => boolean;
|
|
88
|
+
when?: Rule;
|
|
89
|
+
}>;
|
|
90
|
+
authorize(inputs?: Record<string, string>): Promise<AuthOAuthResult>;
|
|
91
|
+
} | {
|
|
92
|
+
type: "api";
|
|
93
|
+
label: string;
|
|
94
|
+
prompts?: Array<{
|
|
95
|
+
type: "text";
|
|
96
|
+
key: string;
|
|
97
|
+
message: string;
|
|
98
|
+
placeholder?: string;
|
|
99
|
+
validate?: (value: string) => string | undefined;
|
|
100
|
+
/** @deprecated Use `when` instead */
|
|
101
|
+
condition?: (inputs: Record<string, string>) => boolean;
|
|
102
|
+
when?: Rule;
|
|
103
|
+
} | {
|
|
104
|
+
type: "select";
|
|
105
|
+
key: string;
|
|
106
|
+
message: string;
|
|
107
|
+
options: Array<{
|
|
108
|
+
label: string;
|
|
109
|
+
value: string;
|
|
110
|
+
hint?: string;
|
|
111
|
+
}>;
|
|
112
|
+
/** @deprecated Use `when` instead */
|
|
113
|
+
condition?: (inputs: Record<string, string>) => boolean;
|
|
114
|
+
when?: Rule;
|
|
115
|
+
}>;
|
|
116
|
+
authorize?(inputs?: Record<string, string>): Promise<{
|
|
117
|
+
type: "success";
|
|
118
|
+
key: string;
|
|
119
|
+
provider?: string;
|
|
120
|
+
metadata?: Record<string, string>;
|
|
121
|
+
} | {
|
|
122
|
+
type: "failed";
|
|
123
|
+
}>;
|
|
124
|
+
})[];
|
|
125
|
+
};
|
|
126
|
+
export type AuthOAuthResult = {
|
|
127
|
+
url: string;
|
|
128
|
+
instructions: string;
|
|
129
|
+
} & ({
|
|
130
|
+
method: "auto";
|
|
131
|
+
callback(): Promise<({
|
|
132
|
+
type: "success";
|
|
133
|
+
provider?: string;
|
|
134
|
+
} & ({
|
|
135
|
+
refresh: string;
|
|
136
|
+
access: string;
|
|
137
|
+
expires: number;
|
|
138
|
+
accountId?: string;
|
|
139
|
+
enterpriseUrl?: string;
|
|
140
|
+
} | {
|
|
141
|
+
key: string;
|
|
142
|
+
metadata?: Record<string, string>;
|
|
143
|
+
})) | {
|
|
144
|
+
type: "failed";
|
|
145
|
+
}>;
|
|
146
|
+
} | {
|
|
147
|
+
method: "code";
|
|
148
|
+
callback(code: string): Promise<({
|
|
149
|
+
type: "success";
|
|
150
|
+
provider?: string;
|
|
151
|
+
} & ({
|
|
152
|
+
refresh: string;
|
|
153
|
+
access: string;
|
|
154
|
+
expires: number;
|
|
155
|
+
accountId?: string;
|
|
156
|
+
enterpriseUrl?: string;
|
|
157
|
+
} | {
|
|
158
|
+
key: string;
|
|
159
|
+
metadata?: Record<string, string>;
|
|
160
|
+
})) | {
|
|
161
|
+
type: "failed";
|
|
162
|
+
}>;
|
|
163
|
+
});
|
|
164
|
+
export type ProviderHookContext = {
|
|
165
|
+
auth?: Auth;
|
|
166
|
+
};
|
|
167
|
+
export type ProviderHook = {
|
|
168
|
+
id: string;
|
|
169
|
+
models?: (provider: ProviderV2, ctx: ProviderHookContext) => Promise<Record<string, ModelV2>>;
|
|
170
|
+
};
|
|
171
|
+
/** @deprecated Use AuthOAuthResult instead. */
|
|
172
|
+
export type AuthOuathResult = AuthOAuthResult;
|
|
13
173
|
export interface Hooks {
|
|
174
|
+
dispose?: () => Promise<void>;
|
|
14
175
|
event?: (input: {
|
|
15
176
|
event: Event;
|
|
16
177
|
}) => Promise<void>;
|
|
@@ -18,92 +179,8 @@ export interface Hooks {
|
|
|
18
179
|
tool?: {
|
|
19
180
|
[key: string]: ToolDefinition;
|
|
20
181
|
};
|
|
21
|
-
auth?:
|
|
22
|
-
|
|
23
|
-
loader?: (auth: () => Promise<Auth>, provider: Provider) => Promise<Record<string, any>>;
|
|
24
|
-
methods: ({
|
|
25
|
-
type: "oauth";
|
|
26
|
-
label: string;
|
|
27
|
-
prompts?: Array<{
|
|
28
|
-
type: "text";
|
|
29
|
-
key: string;
|
|
30
|
-
message: string;
|
|
31
|
-
placeholder?: string;
|
|
32
|
-
validate?: (value: string) => string | undefined;
|
|
33
|
-
condition?: (inputs: Record<string, string>) => boolean;
|
|
34
|
-
} | {
|
|
35
|
-
type: "select";
|
|
36
|
-
key: string;
|
|
37
|
-
message: string;
|
|
38
|
-
options: Array<{
|
|
39
|
-
label: string;
|
|
40
|
-
value: string;
|
|
41
|
-
hint?: string;
|
|
42
|
-
}>;
|
|
43
|
-
condition?: (inputs: Record<string, string>) => boolean;
|
|
44
|
-
}>;
|
|
45
|
-
authorize(inputs?: Record<string, string>): Promise<{
|
|
46
|
-
url: string;
|
|
47
|
-
instructions: string;
|
|
48
|
-
} & ({
|
|
49
|
-
method: "auto";
|
|
50
|
-
callback(): Promise<({
|
|
51
|
-
type: "success";
|
|
52
|
-
provider?: string;
|
|
53
|
-
} & ({
|
|
54
|
-
refresh: string;
|
|
55
|
-
access: string;
|
|
56
|
-
expires: number;
|
|
57
|
-
} | {
|
|
58
|
-
key: string;
|
|
59
|
-
})) | {
|
|
60
|
-
type: "failed";
|
|
61
|
-
}>;
|
|
62
|
-
} | {
|
|
63
|
-
method: "code";
|
|
64
|
-
callback(code: string): Promise<({
|
|
65
|
-
type: "success";
|
|
66
|
-
provider?: string;
|
|
67
|
-
} & ({
|
|
68
|
-
refresh: string;
|
|
69
|
-
access: string;
|
|
70
|
-
expires: number;
|
|
71
|
-
} | {
|
|
72
|
-
key: string;
|
|
73
|
-
})) | {
|
|
74
|
-
type: "failed";
|
|
75
|
-
}>;
|
|
76
|
-
})>;
|
|
77
|
-
} | {
|
|
78
|
-
type: "api";
|
|
79
|
-
label: string;
|
|
80
|
-
prompts?: Array<{
|
|
81
|
-
type: "text";
|
|
82
|
-
key: string;
|
|
83
|
-
message: string;
|
|
84
|
-
placeholder?: string;
|
|
85
|
-
validate?: (value: string) => string | undefined;
|
|
86
|
-
condition?: (inputs: Record<string, string>) => boolean;
|
|
87
|
-
} | {
|
|
88
|
-
type: "select";
|
|
89
|
-
key: string;
|
|
90
|
-
message: string;
|
|
91
|
-
options: Array<{
|
|
92
|
-
label: string;
|
|
93
|
-
value: string;
|
|
94
|
-
hint?: string;
|
|
95
|
-
}>;
|
|
96
|
-
condition?: (inputs: Record<string, string>) => boolean;
|
|
97
|
-
}>;
|
|
98
|
-
authorize?(inputs?: Record<string, string>): Promise<{
|
|
99
|
-
type: "success";
|
|
100
|
-
key: string;
|
|
101
|
-
provider?: string;
|
|
102
|
-
} | {
|
|
103
|
-
type: "failed";
|
|
104
|
-
}>;
|
|
105
|
-
})[];
|
|
106
|
-
};
|
|
182
|
+
auth?: AuthHook;
|
|
183
|
+
provider?: ProviderHook;
|
|
107
184
|
/**
|
|
108
185
|
* Called when a new message is received
|
|
109
186
|
*/
|
|
@@ -115,6 +192,7 @@ export interface Hooks {
|
|
|
115
192
|
modelID: string;
|
|
116
193
|
};
|
|
117
194
|
messageID?: string;
|
|
195
|
+
variant?: string;
|
|
118
196
|
}, output: {
|
|
119
197
|
message: UserMessage;
|
|
120
198
|
parts: Part[];
|
|
@@ -126,16 +204,34 @@ export interface Hooks {
|
|
|
126
204
|
sessionID: string;
|
|
127
205
|
agent: string;
|
|
128
206
|
model: Model;
|
|
129
|
-
provider:
|
|
207
|
+
provider: ProviderContext;
|
|
130
208
|
message: UserMessage;
|
|
131
209
|
}, output: {
|
|
132
210
|
temperature: number;
|
|
133
211
|
topP: number;
|
|
212
|
+
topK: number;
|
|
213
|
+
maxOutputTokens: number | undefined;
|
|
134
214
|
options: Record<string, any>;
|
|
135
215
|
}) => Promise<void>;
|
|
216
|
+
"chat.headers"?: (input: {
|
|
217
|
+
sessionID: string;
|
|
218
|
+
agent: string;
|
|
219
|
+
model: Model;
|
|
220
|
+
provider: ProviderContext;
|
|
221
|
+
message: UserMessage;
|
|
222
|
+
}, output: {
|
|
223
|
+
headers: Record<string, string>;
|
|
224
|
+
}) => Promise<void>;
|
|
136
225
|
"permission.ask"?: (input: Permission, output: {
|
|
137
226
|
status: "ask" | "deny" | "allow";
|
|
138
227
|
}) => Promise<void>;
|
|
228
|
+
"command.execute.before"?: (input: {
|
|
229
|
+
command: string;
|
|
230
|
+
sessionID: string;
|
|
231
|
+
arguments: string;
|
|
232
|
+
}, output: {
|
|
233
|
+
parts: Part[];
|
|
234
|
+
}) => Promise<void>;
|
|
139
235
|
"tool.execute.before"?: (input: {
|
|
140
236
|
tool: string;
|
|
141
237
|
sessionID: string;
|
|
@@ -143,13 +239,84 @@ export interface Hooks {
|
|
|
143
239
|
}, output: {
|
|
144
240
|
args: any;
|
|
145
241
|
}) => Promise<void>;
|
|
242
|
+
"shell.env"?: (input: {
|
|
243
|
+
cwd: string;
|
|
244
|
+
sessionID?: string;
|
|
245
|
+
callID?: string;
|
|
246
|
+
}, output: {
|
|
247
|
+
env: Record<string, string>;
|
|
248
|
+
}) => Promise<void>;
|
|
146
249
|
"tool.execute.after"?: (input: {
|
|
147
250
|
tool: string;
|
|
148
251
|
sessionID: string;
|
|
149
252
|
callID: string;
|
|
253
|
+
args: any;
|
|
150
254
|
}, output: {
|
|
151
255
|
title: string;
|
|
152
256
|
output: string;
|
|
153
257
|
metadata: any;
|
|
154
258
|
}) => Promise<void>;
|
|
259
|
+
"experimental.chat.messages.transform"?: (input: {}, output: {
|
|
260
|
+
messages: {
|
|
261
|
+
info: Message;
|
|
262
|
+
parts: Part[];
|
|
263
|
+
}[];
|
|
264
|
+
}) => Promise<void>;
|
|
265
|
+
"experimental.chat.system.transform"?: (input: {
|
|
266
|
+
sessionID?: string;
|
|
267
|
+
model: Model;
|
|
268
|
+
}, output: {
|
|
269
|
+
system: string[];
|
|
270
|
+
}) => Promise<void>;
|
|
271
|
+
"experimental.provider.small_model"?: (input: {
|
|
272
|
+
provider: ProviderV2;
|
|
273
|
+
}, output: {
|
|
274
|
+
model?: ModelV2;
|
|
275
|
+
}) => Promise<void>;
|
|
276
|
+
/**
|
|
277
|
+
* Called before session compaction starts. Allows plugins to customize
|
|
278
|
+
* the compaction prompt.
|
|
279
|
+
*
|
|
280
|
+
* - `context`: Additional context strings appended to the default prompt
|
|
281
|
+
* - `prompt`: If set, replaces the default compaction prompt entirely
|
|
282
|
+
*/
|
|
283
|
+
"experimental.session.compacting"?: (input: {
|
|
284
|
+
sessionID: string;
|
|
285
|
+
}, output: {
|
|
286
|
+
context: string[];
|
|
287
|
+
prompt?: string;
|
|
288
|
+
}) => Promise<void>;
|
|
289
|
+
/**
|
|
290
|
+
* Called after compaction succeeds and before a synthetic user
|
|
291
|
+
* auto-continue message is added.
|
|
292
|
+
*
|
|
293
|
+
* - `enabled`: Defaults to `true`. Set to `false` to skip the synthetic
|
|
294
|
+
* user "continue" turn.
|
|
295
|
+
*/
|
|
296
|
+
"experimental.compaction.autocontinue"?: (input: {
|
|
297
|
+
sessionID: string;
|
|
298
|
+
agent: string;
|
|
299
|
+
model: Model;
|
|
300
|
+
provider: ProviderContext;
|
|
301
|
+
message: UserMessage;
|
|
302
|
+
overflow: boolean;
|
|
303
|
+
}, output: {
|
|
304
|
+
enabled: boolean;
|
|
305
|
+
}) => Promise<void>;
|
|
306
|
+
"experimental.text.complete"?: (input: {
|
|
307
|
+
sessionID: string;
|
|
308
|
+
messageID: string;
|
|
309
|
+
partID: string;
|
|
310
|
+
}, output: {
|
|
311
|
+
text: string;
|
|
312
|
+
}) => Promise<void>;
|
|
313
|
+
/**
|
|
314
|
+
* Modify tool definitions (description and parameters) sent to LLM
|
|
315
|
+
*/
|
|
316
|
+
"tool.definition"?: (input: {
|
|
317
|
+
toolID: string;
|
|
318
|
+
}, output: {
|
|
319
|
+
description: string;
|
|
320
|
+
parameters: any;
|
|
321
|
+
}) => Promise<void>;
|
|
155
322
|
}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./tool";
|
|
1
|
+
export * from "./tool.js";
|
package/dist/shell.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/tool.d.ts
CHANGED
|
@@ -3,18 +3,58 @@ export type ToolContext = {
|
|
|
3
3
|
sessionID: string;
|
|
4
4
|
messageID: string;
|
|
5
5
|
agent: string;
|
|
6
|
+
/**
|
|
7
|
+
* Current project directory for this session.
|
|
8
|
+
* Prefer this over process.cwd() when resolving relative paths.
|
|
9
|
+
*/
|
|
10
|
+
directory: string;
|
|
11
|
+
/**
|
|
12
|
+
* Project worktree root for this session.
|
|
13
|
+
* Useful for generating stable relative paths (e.g. path.relative(worktree, absPath)).
|
|
14
|
+
*/
|
|
15
|
+
worktree: string;
|
|
6
16
|
abort: AbortSignal;
|
|
17
|
+
metadata(input: {
|
|
18
|
+
title?: string;
|
|
19
|
+
metadata?: {
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
};
|
|
22
|
+
}): void;
|
|
23
|
+
ask(input: AskInput): Promise<void>;
|
|
24
|
+
};
|
|
25
|
+
type AskInput = {
|
|
26
|
+
permission: string;
|
|
27
|
+
patterns: string[];
|
|
28
|
+
always: string[];
|
|
29
|
+
metadata: {
|
|
30
|
+
[key: string]: any;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export type ToolAttachment = {
|
|
34
|
+
type: "file";
|
|
35
|
+
mime: string;
|
|
36
|
+
url: string;
|
|
37
|
+
filename?: string;
|
|
38
|
+
};
|
|
39
|
+
export type ToolResult = string | {
|
|
40
|
+
title?: string;
|
|
41
|
+
output: string;
|
|
42
|
+
metadata?: {
|
|
43
|
+
[key: string]: any;
|
|
44
|
+
};
|
|
45
|
+
attachments?: ToolAttachment[];
|
|
7
46
|
};
|
|
8
47
|
export declare function tool<Args extends z.ZodRawShape>(input: {
|
|
9
48
|
description: string;
|
|
10
49
|
args: Args;
|
|
11
|
-
execute(args: z.infer<z.ZodObject<Args>>, context: ToolContext): Promise<
|
|
50
|
+
execute(args: z.infer<z.ZodObject<Args>>, context: ToolContext): Promise<ToolResult>;
|
|
12
51
|
}): {
|
|
13
52
|
description: string;
|
|
14
53
|
args: Args;
|
|
15
|
-
execute(args: z.infer<z.ZodObject<Args>>, context: ToolContext): Promise<
|
|
54
|
+
execute(args: z.infer<z.ZodObject<Args>>, context: ToolContext): Promise<ToolResult>;
|
|
16
55
|
};
|
|
17
56
|
export declare namespace tool {
|
|
18
57
|
var schema: typeof z;
|
|
19
58
|
}
|
|
20
59
|
export type ToolDefinition = ReturnType<typeof tool>;
|
|
60
|
+
export {};
|