agents 0.31.0 → 0.32.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/dist/{agent-routing-wS1TimZ_.d.ts → agent-routing-vVMA7m8Y.d.ts} +6 -6
- package/dist/agent-routing.d.ts +1 -1
- package/dist/agent-tool-types.d.ts +1 -1
- package/dist/{agent-tools-Bamxxb6Y.d.ts → agent-tools-gGXXkf1z.d.ts} +2 -2
- package/dist/agent-tools.d.ts +1 -1
- package/dist/agent-tools.js +0 -1
- package/dist/agent-tools.js.map +1 -1
- package/dist/browser/ai.js +1 -1
- package/dist/browser/tools/ai-sdk.d.ts +66 -1
- package/dist/browser/tools/ai-sdk.js +2 -2
- package/dist/browser/tools/pi.js +2 -2
- package/dist/browser/tools/tanstack-ai.d.ts +2 -2
- package/dist/browser/tools/tanstack-ai.js +2 -2
- package/dist/browser/tools/tanstack-ai.js.map +1 -1
- package/dist/{browser-tool-lGnvEBLJ.js → browser-tool-DRan7Lk6.js} +2 -2
- package/dist/{browser-tool-lGnvEBLJ.js.map → browser-tool-DRan7Lk6.js.map} +1 -1
- package/dist/catalog-BpOejOsE.js +239 -0
- package/dist/catalog-BpOejOsE.js.map +1 -0
- package/dist/catalog-BpiVV1OF.d.ts +173 -0
- package/dist/chat/index.d.ts +2 -2
- package/dist/chat-sdk/index.d.ts +1 -1
- package/dist/chat-sdk/index.js +1 -1
- package/dist/{client-wn4-yqGz.d.ts → client-eSfgYvd3.d.ts} +2 -2
- package/dist/client.d.ts +1 -1
- package/dist/{cloudflare-Dzvc7V2N.js → cloudflare-CUUm_9q9.js} +26 -4
- package/dist/cloudflare-CUUm_9q9.js.map +1 -0
- package/dist/{do-oauth-client-provider-DfsUcpc3.d.ts → do-oauth-client-provider-DtNqv7oj.d.ts} +26 -2
- package/dist/{index-YSKgfgg9.d.ts → emitter-BJZtCVjQ.d.ts} +6 -140
- package/dist/emitter-DPOVcCln.js +15 -0
- package/dist/emitter-DPOVcCln.js.map +1 -0
- package/dist/experimental/channels/web/index.js +1 -1
- package/dist/harness/container/index.js +0 -1
- package/dist/harness/container/index.js.map +1 -1
- package/dist/harness/container/runtime/index.js +2 -2
- package/dist/harness/opencode/index.js +0 -1
- package/dist/harness/opencode/index.js.map +1 -1
- package/dist/harness/pi/index.d.ts +11 -4
- package/dist/harness/pi/index.js +43 -141
- package/dist/harness/pi/index.js.map +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.js +2 -2
- package/dist/markdown-BZ-VLtA1.js +86 -0
- package/dist/markdown-BZ-VLtA1.js.map +1 -0
- package/dist/mcp/client/do-oauth-client-provider.d.ts +4 -2
- package/dist/mcp/client/do-oauth-client-provider.js +15 -1
- package/dist/mcp/client/do-oauth-client-provider.js.map +1 -1
- package/dist/mcp/client/index.d.ts +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/models/pi-ai/index.js +129 -2
- package/dist/models/pi-ai/index.js.map +1 -1
- package/dist/observability/ai/index.js +1 -2
- package/dist/observability/ai/index.js.map +1 -1
- package/dist/observability/index.d.ts +170 -9
- package/dist/observability/index.js +386 -11
- package/dist/observability/index.js.map +1 -1
- package/dist/react.d.ts +2 -2
- package/dist/resource-B59OV2a2.js +325 -0
- package/dist/resource-B59OV2a2.js.map +1 -0
- package/dist/routing/index.d.ts +1 -1
- package/dist/script-CFDLTk5b.d.ts +91 -0
- package/dist/script-workspace-BpdAYq1R.d.ts +41 -0
- package/dist/serializable.d.ts +1 -1
- package/dist/skill-DRBcIBjC.d.ts +221 -0
- package/dist/skills/index.d.ts +275 -36
- package/dist/skills/index.js +265 -1534
- package/dist/skills/index.js.map +1 -1
- package/dist/skills/runner.d.ts +37 -0
- package/dist/skills/runner.js +912 -0
- package/dist/skills/runner.js.map +1 -0
- package/dist/skills/tools/ai-sdk.d.ts +36 -0
- package/dist/skills/tools/ai-sdk.js +94 -0
- package/dist/skills/tools/ai-sdk.js.map +1 -0
- package/dist/source-9RQzlEhM.d.ts +112 -0
- package/dist/{src-BGolXG_H.js → src-DoGNJ4Ud.js} +4 -5
- package/dist/src-DoGNJ4Ud.js.map +1 -0
- package/dist/sub-routing.d.ts +1 -1
- package/dist/tool-CxKsvxjm.js.map +1 -1
- package/dist/tool-DkT_DJBm.js.map +1 -1
- package/dist/{tool-helpers-BodWi4gd.js → tool-helpers-BI7ifO2S.js} +1 -2
- package/dist/{tool-helpers-BodWi4gd.js.map → tool-helpers-BI7ifO2S.js.map} +1 -1
- package/dist/vite.d.ts +2 -2
- package/dist/vite.js +10 -258
- package/dist/vite.js.map +1 -1
- package/dist/voice/index.d.ts +1 -1
- package/dist/websockets/index.js +1 -1
- package/dist/{websockets-CyoeosdO.js → websockets-C6SJtWCJ.js} +1 -2
- package/dist/{websockets-CyoeosdO.js.map → websockets-C6SJtWCJ.js.map} +1 -1
- package/dist/workflow-types.d.ts +1 -1
- package/dist/workflows.d.ts +1 -1
- package/dist/workflows.js +0 -1
- package/dist/workflows.js.map +1 -1
- package/docs/harnesses/pi.md +9 -3
- package/docs/mcp-client.md +23 -1
- package/docs/mcp-servers.md +2 -2
- package/docs/observability.md +5 -3
- package/package.json +24 -15
- package/dist/ai-sdk-hW3vntnk.d.ts +0 -72
- package/dist/cloudflare-Dzvc7V2N.js.map +0 -1
- package/dist/index-iv9FTXX9.d.ts +0 -311
- package/dist/skills/compile.d.ts +0 -40
- package/dist/skills/compile.js +0 -65
- package/dist/skills/compile.js.map +0 -1
- package/dist/src-BGolXG_H.js.map +0 -1
- package/skills-module.d.ts +0 -22
package/dist/index-iv9FTXX9.d.ts
DELETED
|
@@ -1,311 +0,0 @@
|
|
|
1
|
-
import { ToolSet } from "ai";
|
|
2
|
-
|
|
3
|
-
//#region src/skills/frontmatter.d.ts
|
|
4
|
-
interface ParsedSkillMarkdown {
|
|
5
|
-
data: Record<string, unknown>;
|
|
6
|
-
body: string;
|
|
7
|
-
}
|
|
8
|
-
declare function parseSkillFrontmatter(raw: string): ParsedSkillMarkdown;
|
|
9
|
-
declare function parseSkillMarkdown(raw: string): {
|
|
10
|
-
name: string;
|
|
11
|
-
description: string;
|
|
12
|
-
body: string;
|
|
13
|
-
compatibility?: string;
|
|
14
|
-
license?: string;
|
|
15
|
-
allowedTools?: string;
|
|
16
|
-
metadata?: Record<string, unknown>;
|
|
17
|
-
} | null;
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/skills/types.d.ts
|
|
20
|
-
interface SkillDescriptor {
|
|
21
|
-
name: string;
|
|
22
|
-
description: string;
|
|
23
|
-
compatibility?: string;
|
|
24
|
-
license?: string;
|
|
25
|
-
allowedTools?: string;
|
|
26
|
-
metadata?: Record<string, unknown>;
|
|
27
|
-
sourceId?: string;
|
|
28
|
-
version?: string;
|
|
29
|
-
}
|
|
30
|
-
interface SkillContent extends SkillDescriptor {
|
|
31
|
-
body: string;
|
|
32
|
-
rawContent?: string;
|
|
33
|
-
resources?: SkillResourceDescriptor[];
|
|
34
|
-
}
|
|
35
|
-
interface SkillResourceDescriptor {
|
|
36
|
-
path: string;
|
|
37
|
-
kind: "reference" | "script" | "asset" | "file";
|
|
38
|
-
size?: number;
|
|
39
|
-
encoding?: "text" | "base64";
|
|
40
|
-
mimeType?: string;
|
|
41
|
-
/**
|
|
42
|
-
* Set when a script resource was compiled to a self-contained JavaScript
|
|
43
|
-
* module ahead of time — by the Agents Vite plugin for bundled skills, or via
|
|
44
|
-
* `compileSkillScript` from `agents/skills/compile` for R2/dynamic skills. The
|
|
45
|
-
* runtime runs precompiled scripts directly; the runtime ships no in-Worker
|
|
46
|
-
* bundler, so non-precompiled TypeScript or multi-file scripts cannot run.
|
|
47
|
-
*/
|
|
48
|
-
precompiled?: boolean;
|
|
49
|
-
}
|
|
50
|
-
interface SkillResource extends SkillResourceDescriptor {
|
|
51
|
-
content: string;
|
|
52
|
-
}
|
|
53
|
-
interface SkillScriptContext {
|
|
54
|
-
skill: SkillDescriptor;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* The `ctx` object passed as the second argument to function-style JS/TS
|
|
58
|
-
* skill scripts (`export default async function run(input, ctx)`).
|
|
59
|
-
*
|
|
60
|
-
* Capabilities are gated by the runner: `workspace` throws unless workspace
|
|
61
|
-
* access is enabled, and `tools` only resolves tools the runner was given.
|
|
62
|
-
*/
|
|
63
|
-
interface SkillRunContext {
|
|
64
|
-
/** Metadata for the skill that owns this script. */
|
|
65
|
-
skill: SkillDescriptor;
|
|
66
|
-
/** Text bundled resources by relative path (e.g. `references/style-guide.md`). */
|
|
67
|
-
files: Record<string, string>;
|
|
68
|
-
/** Workspace access, gated by the runner's `workspace` permission. */
|
|
69
|
-
workspace: {
|
|
70
|
-
readFile(path: string): Promise<string | null>;
|
|
71
|
-
listFiles(path?: string): Promise<unknown>;
|
|
72
|
-
glob(pattern: string): Promise<unknown>;
|
|
73
|
-
stat(path: string): Promise<{
|
|
74
|
-
type: string;
|
|
75
|
-
size: number;
|
|
76
|
-
} | null>;
|
|
77
|
-
writeFile(path: string, content: string): Promise<void>;
|
|
78
|
-
};
|
|
79
|
-
/** Explicitly granted tools: `tools.call(name, input)` or `tools.<name>(input)`. */
|
|
80
|
-
tools: {
|
|
81
|
-
call(name: string, input?: unknown): Promise<unknown>;
|
|
82
|
-
} & Record<string, (input?: unknown) => Promise<unknown>>;
|
|
83
|
-
/** Scratch artifacts returned to the model as `outputFiles`. */
|
|
84
|
-
output: {
|
|
85
|
-
writeFile(name: string, content: string): Promise<void>;
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
interface SkillScriptRequest {
|
|
89
|
-
skill: SkillContent;
|
|
90
|
-
path: string;
|
|
91
|
-
source: string;
|
|
92
|
-
input: unknown;
|
|
93
|
-
resources?: SkillResource[];
|
|
94
|
-
}
|
|
95
|
-
interface SkillScriptRunner {
|
|
96
|
-
run(request: SkillScriptRequest): Promise<unknown>;
|
|
97
|
-
}
|
|
98
|
-
interface SkillSource {
|
|
99
|
-
id: string;
|
|
100
|
-
fingerprint: string;
|
|
101
|
-
list(): Promise<SkillDescriptor[]>;
|
|
102
|
-
load(name: string): Promise<SkillContent | null>;
|
|
103
|
-
readResource?(name: string, path: string): Promise<SkillResource | null>;
|
|
104
|
-
refresh?(): Promise<void>;
|
|
105
|
-
}
|
|
106
|
-
interface SkillManifestResource extends SkillResourceDescriptor {
|
|
107
|
-
content: string;
|
|
108
|
-
}
|
|
109
|
-
interface SkillManifestEntry {
|
|
110
|
-
name: string;
|
|
111
|
-
description: string;
|
|
112
|
-
body: string;
|
|
113
|
-
rawContent?: string;
|
|
114
|
-
compatibility?: string;
|
|
115
|
-
license?: string;
|
|
116
|
-
allowedTools?: string;
|
|
117
|
-
metadata?: Record<string, unknown>;
|
|
118
|
-
version?: string;
|
|
119
|
-
resources?: SkillManifestResource[];
|
|
120
|
-
}
|
|
121
|
-
interface SkillManifest {
|
|
122
|
-
id: string;
|
|
123
|
-
fingerprint: string;
|
|
124
|
-
skills: SkillManifestEntry[];
|
|
125
|
-
}
|
|
126
|
-
interface SkillRegistrySnapshot {
|
|
127
|
-
fingerprint: string;
|
|
128
|
-
catalogPrompt: string | null;
|
|
129
|
-
}
|
|
130
|
-
//#endregion
|
|
131
|
-
//#region src/skills/manifest.d.ts
|
|
132
|
-
declare function fromManifest(manifest: SkillManifest): SkillSource;
|
|
133
|
-
//#endregion
|
|
134
|
-
//#region src/skills/r2.d.ts
|
|
135
|
-
interface R2SkillSourceOptions {
|
|
136
|
-
prefix?: string;
|
|
137
|
-
skills?: string[];
|
|
138
|
-
id?: string;
|
|
139
|
-
fingerprint?: "metadata" | "content";
|
|
140
|
-
refreshIntervalMs?: number;
|
|
141
|
-
}
|
|
142
|
-
declare function r2(
|
|
143
|
-
bucket: R2Bucket,
|
|
144
|
-
options?: R2SkillSourceOptions
|
|
145
|
-
): SkillSource;
|
|
146
|
-
//#endregion
|
|
147
|
-
//#region src/skills/workspace.d.ts
|
|
148
|
-
/**
|
|
149
|
-
* The Workspace Agent Skills read and write: a `Workspace` from
|
|
150
|
-
* `@cloudflare/computer`, or anything with the same `fs` methods.
|
|
151
|
-
*/
|
|
152
|
-
interface SkillWorkspace {
|
|
153
|
-
readonly fs: {
|
|
154
|
-
stat(path: string): Promise<{
|
|
155
|
-
size: number;
|
|
156
|
-
isDirectory: boolean;
|
|
157
|
-
}>;
|
|
158
|
-
readFile(path: string): Promise<ReadableStream<Uint8Array>>;
|
|
159
|
-
writeFile(path: string, content: Uint8Array): Promise<void>;
|
|
160
|
-
mkdir(
|
|
161
|
-
path: string,
|
|
162
|
-
options?: {
|
|
163
|
-
recursive?: boolean;
|
|
164
|
-
}
|
|
165
|
-
): Promise<void>;
|
|
166
|
-
readdir(path: string): Promise<
|
|
167
|
-
Array<{
|
|
168
|
-
name: string;
|
|
169
|
-
size: number;
|
|
170
|
-
isDirectory: boolean;
|
|
171
|
-
}>
|
|
172
|
-
>;
|
|
173
|
-
find(
|
|
174
|
-
directory: string,
|
|
175
|
-
pattern?: string
|
|
176
|
-
): Promise<
|
|
177
|
-
Array<{
|
|
178
|
-
path: string;
|
|
179
|
-
type: "file" | "dir";
|
|
180
|
-
}>
|
|
181
|
-
>;
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
/** Options for projecting Agent Skills into a Workspace. */
|
|
185
|
-
interface SkillWorkspaceSeedOptions {
|
|
186
|
-
/** Destination directory. Defaults to `/workspace/.agents/skills`. */
|
|
187
|
-
readonly root?: string;
|
|
188
|
-
/** Existing-file policy. Default `"preserve"` keeps Workspace edits. */
|
|
189
|
-
readonly onConflict?: "preserve" | "replace";
|
|
190
|
-
}
|
|
191
|
-
/** Summary returned after projecting Agent Skills into a Workspace. */
|
|
192
|
-
interface SkillWorkspaceSeedResult {
|
|
193
|
-
/** Files written from source content. */
|
|
194
|
-
readonly written: number;
|
|
195
|
-
/** Existing files preserved without a write. */
|
|
196
|
-
readonly preserved: number;
|
|
197
|
-
/** Files skipped because their source content could not be read or written. */
|
|
198
|
-
readonly skipped: number;
|
|
199
|
-
/** Non-fatal per-file diagnostics. */
|
|
200
|
-
readonly warnings: readonly string[];
|
|
201
|
-
/** Absolute Workspace directory containing the projected skills. */
|
|
202
|
-
readonly root: string;
|
|
203
|
-
}
|
|
204
|
-
//#endregion
|
|
205
|
-
//#region src/skills/runner.d.ts
|
|
206
|
-
/**
|
|
207
|
-
* Options for {@link runner}.
|
|
208
|
-
*
|
|
209
|
-
* @experimental Skill script execution is experimental and the option shape
|
|
210
|
-
* may change before stabilizing.
|
|
211
|
-
*/
|
|
212
|
-
interface WorkerSkillScriptRunnerOptions {
|
|
213
|
-
loader: WorkerLoader;
|
|
214
|
-
timeout?: number;
|
|
215
|
-
network?: boolean;
|
|
216
|
-
workspace?: "none" | "read" | "read-write";
|
|
217
|
-
workspaceInstance?: SkillWorkspace;
|
|
218
|
-
tools?: ToolSet | (() => ToolSet | Promise<ToolSet>);
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Create a skill script runner backed by a Worker Loader.
|
|
222
|
-
*
|
|
223
|
-
* Capabilities are opt-in and enforced by a single host bridge: no network and
|
|
224
|
-
* no tools by default, read-only workspace access when `workspaceInstance` is
|
|
225
|
-
* provided. JS/TS scripts are function-style (`export default run(input, ctx)`)
|
|
226
|
-
* and receive `ctx = { skill, files, workspace, tools, output }`. Python and
|
|
227
|
-
* Bash use the path-based `/skill`, `/input.json`, `/output` contract.
|
|
228
|
-
*
|
|
229
|
-
* @experimental Skill script execution is experimental and may change before
|
|
230
|
-
* stabilizing.
|
|
231
|
-
*/
|
|
232
|
-
declare function runner(
|
|
233
|
-
options: WorkerSkillScriptRunnerOptions
|
|
234
|
-
): SkillScriptRunner;
|
|
235
|
-
//#endregion
|
|
236
|
-
//#region src/skills/registry.d.ts
|
|
237
|
-
declare class SkillRegistry {
|
|
238
|
-
readonly contextLabel = "think_skills";
|
|
239
|
-
/**
|
|
240
|
-
* Non-fatal diagnostics collected during the most recent {@link load} or
|
|
241
|
-
* {@link refresh} (duplicate skill names, sources that failed to list).
|
|
242
|
-
* Reset on every load so it never grows unbounded across refreshes.
|
|
243
|
-
*/
|
|
244
|
-
readonly warnings: string[];
|
|
245
|
-
private sources;
|
|
246
|
-
private scriptRunner;
|
|
247
|
-
private descriptors;
|
|
248
|
-
private sourceBySkill;
|
|
249
|
-
private loaded;
|
|
250
|
-
private workspaceFiles;
|
|
251
|
-
private workspaceSkillNames;
|
|
252
|
-
private workspaceResources;
|
|
253
|
-
constructor(sources: SkillSource[], scriptRunner?: SkillScriptRunner | null);
|
|
254
|
-
get fingerprint(): string;
|
|
255
|
-
load(): Promise<void>;
|
|
256
|
-
refresh(): Promise<void>;
|
|
257
|
-
/**
|
|
258
|
-
* Seed resolved Agent Skills into a Workspace.
|
|
259
|
-
* Existing files are preserved by default, and become authoritative for
|
|
260
|
-
* activation, resource reads, and script execution.
|
|
261
|
-
*/
|
|
262
|
-
seedWorkspace(
|
|
263
|
-
workspace: SkillWorkspace,
|
|
264
|
-
options?: SkillWorkspaceSeedOptions
|
|
265
|
-
): Promise<SkillWorkspaceSeedResult>;
|
|
266
|
-
/**
|
|
267
|
-
* Route skill reads through an already-seeded Workspace without probing or
|
|
268
|
-
* rewriting its files. Hosts use this when the durable source fingerprint
|
|
269
|
-
* matches the recorded projection fingerprint.
|
|
270
|
-
*/
|
|
271
|
-
useWorkspace(
|
|
272
|
-
workspace: SkillWorkspace,
|
|
273
|
-
options?: SkillWorkspaceSeedOptions
|
|
274
|
-
): Promise<void>;
|
|
275
|
-
private writeSeedFile;
|
|
276
|
-
snapshot(): Promise<SkillRegistrySnapshot>;
|
|
277
|
-
systemPrompt(): Promise<string | null>;
|
|
278
|
-
loadSkill(name: string): Promise<SkillContent | null>;
|
|
279
|
-
private resolveResourceTarget;
|
|
280
|
-
private readResource;
|
|
281
|
-
private readSkillResources;
|
|
282
|
-
tools(): ToolSet;
|
|
283
|
-
}
|
|
284
|
-
//#endregion
|
|
285
|
-
export {
|
|
286
|
-
parseSkillFrontmatter as C,
|
|
287
|
-
SkillSource as S,
|
|
288
|
-
SkillResourceDescriptor as _,
|
|
289
|
-
SkillWorkspaceSeedOptions as a,
|
|
290
|
-
SkillScriptRequest as b,
|
|
291
|
-
r2 as c,
|
|
292
|
-
SkillDescriptor as d,
|
|
293
|
-
SkillManifest as f,
|
|
294
|
-
SkillResource as g,
|
|
295
|
-
SkillRegistrySnapshot as h,
|
|
296
|
-
SkillWorkspace as i,
|
|
297
|
-
fromManifest as l,
|
|
298
|
-
SkillManifestResource as m,
|
|
299
|
-
WorkerSkillScriptRunnerOptions as n,
|
|
300
|
-
SkillWorkspaceSeedResult as o,
|
|
301
|
-
SkillManifestEntry as p,
|
|
302
|
-
runner as r,
|
|
303
|
-
R2SkillSourceOptions as s,
|
|
304
|
-
SkillRegistry as t,
|
|
305
|
-
SkillContent as u,
|
|
306
|
-
SkillRunContext as v,
|
|
307
|
-
parseSkillMarkdown as w,
|
|
308
|
-
SkillScriptRunner as x,
|
|
309
|
-
SkillScriptContext as y
|
|
310
|
-
};
|
|
311
|
-
//# sourceMappingURL=index-iv9FTXX9.d.ts.map
|
package/dist/skills/compile.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
//#region src/skills/compile.d.ts
|
|
2
|
-
interface CompiledSkillScript {
|
|
3
|
-
/** Self-contained ESM source, ready to embed and run without a bundler. */
|
|
4
|
-
content: string;
|
|
5
|
-
/** Always `true`; mirrors the `precompiled` flag on skill resources. */
|
|
6
|
-
precompiled: true;
|
|
7
|
-
}
|
|
8
|
-
interface CompileSkillScriptOptions {
|
|
9
|
-
/**
|
|
10
|
-
* JavaScript target for the emitted bundle. Defaults to `es2022`, which the
|
|
11
|
-
* Workers runtime supports.
|
|
12
|
-
*/
|
|
13
|
-
target?: string;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Whether a resource path is a skill script that should be compiled ahead of
|
|
17
|
-
* time (i.e. has a `.js`, `.mjs`, `.ts`, or `.tsx` extension).
|
|
18
|
-
*/
|
|
19
|
-
declare function isCompilableSkillScript(path: string): boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Compile a skill script file into a single self-contained ESM module.
|
|
22
|
-
*
|
|
23
|
-
* Resolves and inlines sibling imports relative to `entryPath`, strips
|
|
24
|
-
* TypeScript types, and emits ESM so the script can run in the Worker sandbox
|
|
25
|
-
* without an in-Worker bundler.
|
|
26
|
-
*
|
|
27
|
-
* @param entryPath Absolute path to the skill script file on disk.
|
|
28
|
-
*/
|
|
29
|
-
declare function compileSkillScript(
|
|
30
|
-
entryPath: string,
|
|
31
|
-
options?: CompileSkillScriptOptions
|
|
32
|
-
): Promise<CompiledSkillScript>;
|
|
33
|
-
//#endregion
|
|
34
|
-
export {
|
|
35
|
-
CompileSkillScriptOptions,
|
|
36
|
-
CompiledSkillScript,
|
|
37
|
-
compileSkillScript,
|
|
38
|
-
isCompilableSkillScript
|
|
39
|
-
};
|
|
40
|
-
//# sourceMappingURL=compile.d.ts.map
|
package/dist/skills/compile.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { build } from "esbuild";
|
|
2
|
-
//#region src/skills/compile.ts
|
|
3
|
-
/**
|
|
4
|
-
* Build-time skill-script compiler.
|
|
5
|
-
*
|
|
6
|
-
* Skill scripts must be self-contained JavaScript modules before they can run:
|
|
7
|
-
* the Worker runtime executes them directly through the sandbox and does **not**
|
|
8
|
-
* ship an in-Worker bundler. This module compiles a skill script (TypeScript or
|
|
9
|
-
* multi-file JavaScript) into a single self-contained ESM bundle using esbuild.
|
|
10
|
-
*
|
|
11
|
-
* It runs in Node (build time) only — the Agents Vite plugin uses it to compile
|
|
12
|
-
* bundled skills, and skills served from R2 or other dynamic sources should be
|
|
13
|
-
* compiled with {@link compileSkillScript} before upload.
|
|
14
|
-
*
|
|
15
|
-
* @module
|
|
16
|
-
*/
|
|
17
|
-
/** Skill-script extensions that can (and must) be compiled ahead of time. */
|
|
18
|
-
const COMPILABLE_SCRIPT_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
19
|
-
".js",
|
|
20
|
-
".mjs",
|
|
21
|
-
".ts",
|
|
22
|
-
".tsx"
|
|
23
|
-
]);
|
|
24
|
-
function extensionOf(path) {
|
|
25
|
-
const file = path.split("/").at(-1) ?? path;
|
|
26
|
-
const index = file.lastIndexOf(".");
|
|
27
|
-
return index === -1 ? "" : file.slice(index).toLowerCase();
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Whether a resource path is a skill script that should be compiled ahead of
|
|
31
|
-
* time (i.e. has a `.js`, `.mjs`, `.ts`, or `.tsx` extension).
|
|
32
|
-
*/
|
|
33
|
-
function isCompilableSkillScript(path) {
|
|
34
|
-
return COMPILABLE_SCRIPT_EXTENSIONS.has(extensionOf(path));
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Compile a skill script file into a single self-contained ESM module.
|
|
38
|
-
*
|
|
39
|
-
* Resolves and inlines sibling imports relative to `entryPath`, strips
|
|
40
|
-
* TypeScript types, and emits ESM so the script can run in the Worker sandbox
|
|
41
|
-
* without an in-Worker bundler.
|
|
42
|
-
*
|
|
43
|
-
* @param entryPath Absolute path to the skill script file on disk.
|
|
44
|
-
*/
|
|
45
|
-
async function compileSkillScript(entryPath, options = {}) {
|
|
46
|
-
const output = (await build({
|
|
47
|
-
entryPoints: [entryPath],
|
|
48
|
-
bundle: true,
|
|
49
|
-
write: false,
|
|
50
|
-
format: "esm",
|
|
51
|
-
platform: "browser",
|
|
52
|
-
target: options.target ?? "es2022",
|
|
53
|
-
logLevel: "silent",
|
|
54
|
-
legalComments: "none"
|
|
55
|
-
})).outputFiles?.[0];
|
|
56
|
-
if (!output) throw new Error(`esbuild produced no output when compiling skill script "${entryPath}".`);
|
|
57
|
-
return {
|
|
58
|
-
content: output.text,
|
|
59
|
-
precompiled: true
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
//#endregion
|
|
63
|
-
export { compileSkillScript, isCompilableSkillScript };
|
|
64
|
-
|
|
65
|
-
//# sourceMappingURL=compile.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compile.js","names":[],"sources":["../../src/skills/compile.ts"],"sourcesContent":["import { build } from \"esbuild\";\n\n/**\n * Build-time skill-script compiler.\n *\n * Skill scripts must be self-contained JavaScript modules before they can run:\n * the Worker runtime executes them directly through the sandbox and does **not**\n * ship an in-Worker bundler. This module compiles a skill script (TypeScript or\n * multi-file JavaScript) into a single self-contained ESM bundle using esbuild.\n *\n * It runs in Node (build time) only — the Agents Vite plugin uses it to compile\n * bundled skills, and skills served from R2 or other dynamic sources should be\n * compiled with {@link compileSkillScript} before upload.\n *\n * @module\n */\n\n/** Skill-script extensions that can (and must) be compiled ahead of time. */\nconst COMPILABLE_SCRIPT_EXTENSIONS = new Set([\".js\", \".mjs\", \".ts\", \".tsx\"]);\n\nexport interface CompiledSkillScript {\n /** Self-contained ESM source, ready to embed and run without a bundler. */\n content: string;\n /** Always `true`; mirrors the `precompiled` flag on skill resources. */\n precompiled: true;\n}\n\nexport interface CompileSkillScriptOptions {\n /**\n * JavaScript target for the emitted bundle. Defaults to `es2022`, which the\n * Workers runtime supports.\n */\n target?: string;\n}\n\nfunction extensionOf(path: string): string {\n const file = path.split(\"/\").at(-1) ?? path;\n const index = file.lastIndexOf(\".\");\n return index === -1 ? \"\" : file.slice(index).toLowerCase();\n}\n\n/**\n * Whether a resource path is a skill script that should be compiled ahead of\n * time (i.e. has a `.js`, `.mjs`, `.ts`, or `.tsx` extension).\n */\nexport function isCompilableSkillScript(path: string): boolean {\n return COMPILABLE_SCRIPT_EXTENSIONS.has(extensionOf(path));\n}\n\n/**\n * Compile a skill script file into a single self-contained ESM module.\n *\n * Resolves and inlines sibling imports relative to `entryPath`, strips\n * TypeScript types, and emits ESM so the script can run in the Worker sandbox\n * without an in-Worker bundler.\n *\n * @param entryPath Absolute path to the skill script file on disk.\n */\nexport async function compileSkillScript(\n entryPath: string,\n options: CompileSkillScriptOptions = {}\n): Promise<CompiledSkillScript> {\n const result = await build({\n entryPoints: [entryPath],\n bundle: true,\n write: false,\n format: \"esm\",\n platform: \"browser\",\n target: options.target ?? \"es2022\",\n logLevel: \"silent\",\n legalComments: \"none\"\n });\n\n const output = result.outputFiles?.[0];\n if (!output) {\n throw new Error(\n `esbuild produced no output when compiling skill script \"${entryPath}\".`\n );\n }\n\n return { content: output.text, precompiled: true };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkBA,MAAM,+CAA+B,IAAI,IAAI;CAAC;CAAO;CAAQ;CAAO;AAAM,CAAC;AAiB3E,SAAS,YAAY,MAAsB;CACzC,MAAM,OAAO,KAAK,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK;CACvC,MAAM,QAAQ,KAAK,YAAY,GAAG;CAClC,OAAO,UAAU,KAAK,KAAK,KAAK,MAAM,KAAK,CAAC,CAAC,YAAY;AAC3D;;;;;AAMA,SAAgB,wBAAwB,MAAuB;CAC7D,OAAO,6BAA6B,IAAI,YAAY,IAAI,CAAC;AAC3D;;;;;;;;;;AAWA,eAAsB,mBACpB,WACA,UAAqC,CAAC,GACR;CAY9B,MAAM,UAAS,MAXM,MAAM;EACzB,aAAa,CAAC,SAAS;EACvB,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,UAAU;EACV,QAAQ,QAAQ,UAAU;EAC1B,UAAU;EACV,eAAe;CACjB,CAAC,EAAA,CAEqB,cAAc;CACpC,IAAI,CAAC,QACH,MAAM,IAAI,MACR,2DAA2D,UAAU,GACvE;CAGF,OAAO;EAAE,SAAS,OAAO;EAAM,aAAa;CAAK;AACnD"}
|