@langchain/quickjs 0.4.0 → 0.5.1
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/index.cjs +595 -429
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +68 -115
- package/dist/index.d.ts +68 -115
- package/dist/index.js +594 -424
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import * as _$langchain from "langchain";
|
|
2
1
|
import { AgentMiddleware } from "langchain";
|
|
3
2
|
import { z } from "zod/v4";
|
|
4
3
|
import { StructuredToolInterface } from "@langchain/core/tools";
|
|
5
|
-
import { AnyBackendProtocol, BackendFactory, SkillMetadata } from "deepagents";
|
|
6
4
|
|
|
7
5
|
//#region src/types.d.ts
|
|
8
6
|
/**
|
|
@@ -39,11 +37,6 @@ interface CodeInterpreterMiddlewareOptions {
|
|
|
39
37
|
* @default null (uses built-in prompt)
|
|
40
38
|
*/
|
|
41
39
|
systemPrompt?: string | null;
|
|
42
|
-
/**
|
|
43
|
-
* Backend the REPL reads skill module sources from. When provided alongside
|
|
44
|
-
* `SkillsMiddleware`, skills with a `module:` key become dynamic-importable.
|
|
45
|
-
*/
|
|
46
|
-
skillsBackend?: AnyBackendProtocol | BackendFactory;
|
|
47
40
|
/**
|
|
48
41
|
* Maximum number of `tools.*` bridge calls allowed per `eval()` invocation.
|
|
49
42
|
*
|
|
@@ -78,6 +71,43 @@ interface CodeInterpreterMiddlewareOptions {
|
|
|
78
71
|
* @default true
|
|
79
72
|
*/
|
|
80
73
|
captureConsole?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Expose the built-in `task()` global for subagent orchestration.
|
|
76
|
+
*
|
|
77
|
+
* When `true` (default) and subagent specs are available, a `task()`
|
|
78
|
+
* global is installed in the REPL that dispatches subagents
|
|
79
|
+
* programmatically with a fixed concurrency cap of 32.
|
|
80
|
+
* Set to `false` to require subagent dispatch through the normal
|
|
81
|
+
* `task` tool path.
|
|
82
|
+
*
|
|
83
|
+
* @default true
|
|
84
|
+
*/
|
|
85
|
+
subagents?: boolean;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Configuration for the built-in subagent primitive.
|
|
89
|
+
*
|
|
90
|
+
* When provided to a ReplSession, a frozen `subagent()` global is
|
|
91
|
+
* installed in the QuickJS context. Calls are gated by a concurrency
|
|
92
|
+
* queue and forwarded to the dispatch callback.
|
|
93
|
+
*/
|
|
94
|
+
interface SubagentBridgeOptions {
|
|
95
|
+
/**
|
|
96
|
+
* Callback that invokes a subagent. Receives validated input from
|
|
97
|
+
* the QuickJS guest and returns the subagent's output — a string
|
|
98
|
+
* for text responses or an object for structured (responseSchema)
|
|
99
|
+
* responses.
|
|
100
|
+
*/
|
|
101
|
+
dispatch: (input: {
|
|
102
|
+
description: string;
|
|
103
|
+
subagentType: string;
|
|
104
|
+
responseSchema?: Record<string, unknown>;
|
|
105
|
+
}) => Promise<unknown>;
|
|
106
|
+
/**
|
|
107
|
+
* Maximum number of concurrent subagent calls within a single eval.
|
|
108
|
+
* Excess calls queue and resolve as permits free up.
|
|
109
|
+
*/
|
|
110
|
+
maxConcurrency: number;
|
|
81
111
|
}
|
|
82
112
|
/**
|
|
83
113
|
* Options for creating a ReplSession.
|
|
@@ -86,10 +116,11 @@ interface ReplSessionOptions {
|
|
|
86
116
|
memoryLimitBytes?: number;
|
|
87
117
|
maxStackSizeBytes?: number;
|
|
88
118
|
tools?: StructuredToolInterface[];
|
|
89
|
-
skillsEnabled?: boolean;
|
|
90
119
|
maxPtcCalls?: number | null;
|
|
91
120
|
maxResultChars?: number;
|
|
92
121
|
captureConsole?: boolean;
|
|
122
|
+
sessionId?: string;
|
|
123
|
+
subagentBridge?: SubagentBridgeOptions;
|
|
93
124
|
}
|
|
94
125
|
/**
|
|
95
126
|
* Result of a single REPL evaluation.
|
|
@@ -105,31 +136,18 @@ interface ReplResult {
|
|
|
105
136
|
logs: string[];
|
|
106
137
|
logsDroppedChars: number;
|
|
107
138
|
}
|
|
108
|
-
/**
|
|
109
|
-
* Metadata + backend pair the session needs to resolve skill imports.
|
|
110
|
-
*/
|
|
111
|
-
interface SkillsContext {
|
|
112
|
-
/**
|
|
113
|
-
* Per-eval snapshot of `state.skillsMetadata`.
|
|
114
|
-
*/
|
|
115
|
-
metadata: SkillMetadata[];
|
|
116
|
-
/**
|
|
117
|
-
* Backend the session fetches skill source files from.
|
|
118
|
-
*/
|
|
119
|
-
backend: AnyBackendProtocol;
|
|
120
|
-
}
|
|
121
139
|
//#endregion
|
|
122
140
|
//#region src/middleware.d.ts
|
|
123
141
|
/**
|
|
124
142
|
* Create the Code Interpreter middleware.
|
|
125
143
|
*/
|
|
126
|
-
declare function createCodeInterpreterMiddleware(options?: CodeInterpreterMiddlewareOptions): AgentMiddleware<undefined, undefined, unknown, readonly [
|
|
144
|
+
declare function createCodeInterpreterMiddleware(options?: CodeInterpreterMiddlewareOptions): AgentMiddleware<undefined, undefined, unknown, readonly [import("langchain").DynamicStructuredTool<z.ZodObject<{
|
|
127
145
|
code: z.ZodString;
|
|
128
146
|
}, z.core.$strip>, {
|
|
129
147
|
code: string;
|
|
130
148
|
}, {
|
|
131
149
|
code: string;
|
|
132
|
-
}, string, unknown, string>]>;
|
|
150
|
+
}, string, unknown, string>], readonly []>;
|
|
133
151
|
//#endregion
|
|
134
152
|
//#region src/errors.d.ts
|
|
135
153
|
/**
|
|
@@ -179,11 +197,12 @@ declare class ReplSession {
|
|
|
179
197
|
private context;
|
|
180
198
|
private consoleBuffer;
|
|
181
199
|
private options;
|
|
182
|
-
private skillsContext;
|
|
183
|
-
private skillsLoaded;
|
|
184
|
-
private skillsFailed;
|
|
185
200
|
private readonly maxPtcCalls;
|
|
186
201
|
private ptcCallsRemaining;
|
|
202
|
+
private subagentQueue;
|
|
203
|
+
private bridgeDispatchRef;
|
|
204
|
+
/** Allowed keys in the subagent input object. */
|
|
205
|
+
private static readonly SUBAGENT_ALLOWED_KEYS;
|
|
187
206
|
/**
|
|
188
207
|
* Reset the shared WASM module. Forces the next session to instantiate
|
|
189
208
|
* a fresh module. Only needed in tests where module state must be
|
|
@@ -194,42 +213,6 @@ declare class ReplSession {
|
|
|
194
213
|
static resetSharedModule(): void;
|
|
195
214
|
constructor(id: string, options?: ReplSessionOptions);
|
|
196
215
|
private ensureStarted;
|
|
197
|
-
/**
|
|
198
|
-
* Load the skill into cache on first access and replay cached errors.
|
|
199
|
-
*/
|
|
200
|
-
private ensureSkillLoaded;
|
|
201
|
-
/**
|
|
202
|
-
* Pre-load all skills referenced in source code into the in-memory
|
|
203
|
-
* cache. Must be called before `evalCodeAsync` so the module loader
|
|
204
|
-
* can resolve synchronously. An async loader would cause asyncify
|
|
205
|
-
* suspensions on each import, which is incompatible with the shared
|
|
206
|
-
* WASM module used by all sessions.
|
|
207
|
-
*/
|
|
208
|
-
preloadReferencedSkills(code: string): Promise<void>;
|
|
209
|
-
/**
|
|
210
|
-
* Resolve a module specifier to source code. Strictly synchronous —
|
|
211
|
-
* only reads from the in-memory skill cache populated by
|
|
212
|
-
* `preloadReferencedSkills`. Returns error source (not a thrown
|
|
213
|
-
* exception) for missing or failed skills so QuickJS reports the
|
|
214
|
-
* error inside the VM.
|
|
215
|
-
*/
|
|
216
|
-
private resolveSpecifier;
|
|
217
|
-
/**
|
|
218
|
-
* Canonicalize an `import` specifier. Bare specifiers pass through;
|
|
219
|
-
* relative specifiers are resolved against the importing module's path.
|
|
220
|
-
* Traversal out of a skill's `@/skills/<name>/` namespace is rejected.
|
|
221
|
-
*/
|
|
222
|
-
private normalizeSpecifier;
|
|
223
|
-
/**
|
|
224
|
-
* Wire the QuickJS module loader and normalizer on this session's runtime.
|
|
225
|
-
*
|
|
226
|
-
* The loader is strictly synchronous — it reads from the in-memory skill
|
|
227
|
-
* cache populated by `preloadReferencedSkills`. This is critical: an async
|
|
228
|
-
* module loader causes asyncify suspensions on each import, and disposing
|
|
229
|
-
* a runtime after multi-file imports corrupts the shared module's asyncify
|
|
230
|
-
* state, silently breaking the loader for all subsequent sessions.
|
|
231
|
-
*/
|
|
232
|
-
private installModuleLoader;
|
|
233
216
|
/**
|
|
234
217
|
* Initialise the per-eval PTC counter. Called at the top of every `eval()`.
|
|
235
218
|
*/
|
|
@@ -261,12 +244,6 @@ declare class ReplSession {
|
|
|
261
244
|
* Dispose and remove the session with the given key, if it exists.
|
|
262
245
|
*/
|
|
263
246
|
static deleteSession(key: string): void;
|
|
264
|
-
/**
|
|
265
|
-
* Push the current skills metadata + backend into the session.
|
|
266
|
-
* Called by the middleware once per `eval` invocation, before eval runs.
|
|
267
|
-
* Pass `undefined` to clear the context (no skill imports will resolve).
|
|
268
|
-
*/
|
|
269
|
-
setSkillsContext(ctx?: SkillsContext): void;
|
|
270
247
|
/**
|
|
271
248
|
* Evaluate code in this session.
|
|
272
249
|
*
|
|
@@ -291,6 +268,23 @@ declare class ReplSession {
|
|
|
291
268
|
static clearCache(): void;
|
|
292
269
|
private setupConsole;
|
|
293
270
|
private injectTools;
|
|
271
|
+
/**
|
|
272
|
+
* Install the `task` global on the QuickJS context.
|
|
273
|
+
*
|
|
274
|
+
* Registers the host function directly as `globalThis.task`,
|
|
275
|
+
* then freezes it via `evalCode`. Structured results (when
|
|
276
|
+
* responseSchema is provided) are marshaled into native QuickJS
|
|
277
|
+
* objects on the host side — no JS wrapper needed.
|
|
278
|
+
*/
|
|
279
|
+
/**
|
|
280
|
+
* Replace the active bridge dispatch with a fresh one.
|
|
281
|
+
*
|
|
282
|
+
* Call this before each eval so the dispatch closure carries
|
|
283
|
+
* the current invocation's config (tracing callbacks, run ID, etc.)
|
|
284
|
+
* rather than the stale config from session creation.
|
|
285
|
+
*/
|
|
286
|
+
updateBridgeDispatch(dispatch: SubagentBridgeOptions["dispatch"]): void;
|
|
287
|
+
private injectSubagentBridge;
|
|
294
288
|
}
|
|
295
289
|
//#endregion
|
|
296
290
|
//#region src/utils.d.ts
|
|
@@ -302,10 +296,6 @@ declare function toCamelCase(name: string): string;
|
|
|
302
296
|
* Format the result of a REPL evaluation for the agent.
|
|
303
297
|
*/
|
|
304
298
|
declare function formatReplResult(result: ReplResult): string;
|
|
305
|
-
/**
|
|
306
|
-
* Render a pre-eval error when referenced skills are not available on the agent.
|
|
307
|
-
*/
|
|
308
|
-
declare function formatSkillNotAvailable(missing: readonly string[]): string;
|
|
309
299
|
//#endregion
|
|
310
300
|
//#region src/transform.d.ts
|
|
311
301
|
/**
|
|
@@ -339,51 +329,14 @@ declare function transformForEval(code: string): string;
|
|
|
339
329
|
*/
|
|
340
330
|
declare function stripTypeSyntax(code: string): string;
|
|
341
331
|
//#endregion
|
|
342
|
-
//#region src/
|
|
343
|
-
/**
|
|
344
|
-
* File extensions the loader will enumerate from a skill directory.
|
|
345
|
-
*/
|
|
346
|
-
declare const SKILL_MODULE_EXTENSIONS: string[];
|
|
347
|
-
/**
|
|
348
|
-
* Hard cap on total bytes pulled for one skill's bundle (1 MiB).
|
|
349
|
-
*/
|
|
350
|
-
declare const MAX_SKILL_BUNDLE_BYTES: number;
|
|
351
|
-
/**
|
|
352
|
-
* Install-ready state for a single skill, produced by `loadSkill`.
|
|
353
|
-
*/
|
|
354
|
-
interface LoadedSkill {
|
|
355
|
-
/**
|
|
356
|
-
* Spec-validated kebab-case skill name.
|
|
357
|
-
*/
|
|
358
|
-
name: string;
|
|
359
|
-
/**
|
|
360
|
-
* Bare specifier the skill installs under: `"@/skills/<name>"`.
|
|
361
|
-
*/
|
|
362
|
-
specifier: string;
|
|
363
|
-
/**
|
|
364
|
-
* Relative POSIX path of the entrypoint file (e.g. `"index.ts"`).
|
|
365
|
-
*/
|
|
366
|
-
entryRel: string;
|
|
367
|
-
/**
|
|
368
|
-
* File contents keyed by relative POSIX path, with TS syntax stripped.
|
|
369
|
-
*/
|
|
370
|
-
files: Map<string, string>;
|
|
371
|
-
}
|
|
372
|
-
/**
|
|
373
|
-
* Build a `LoadedSkill` from a skill's metadata and a backend handle.
|
|
374
|
-
*
|
|
375
|
-
* Enumerates code files under the skill directory, downloads them,
|
|
376
|
-
* strips TypeScript syntax, and validates the entrypoint is present.
|
|
377
|
-
*/
|
|
378
|
-
declare function loadSkill(metadata: SkillMetadata, backend: AnyBackendProtocol): Promise<LoadedSkill>;
|
|
332
|
+
//#region src/subagent-dispatch.d.ts
|
|
379
333
|
/**
|
|
380
|
-
*
|
|
334
|
+
* Validate that a response schema does not exceed size, depth, or
|
|
335
|
+
* property-count limits.
|
|
381
336
|
*
|
|
382
|
-
*
|
|
383
|
-
* before evaluation starts. Dynamic imports with computed specifiers are
|
|
384
|
-
* not detected.
|
|
337
|
+
* @throws Error if any limit is exceeded.
|
|
385
338
|
*/
|
|
386
|
-
declare function
|
|
339
|
+
declare function validateResponseSchema(schema: Record<string, unknown>): void;
|
|
387
340
|
//#endregion
|
|
388
|
-
export { type CodeInterpreterMiddlewareOptions, DEFAULT_EXECUTION_TIMEOUT, DEFAULT_MAX_PTC_CALLS, DEFAULT_MAX_STACK_SIZE, DEFAULT_MEMORY_LIMIT,
|
|
341
|
+
export { type CodeInterpreterMiddlewareOptions, DEFAULT_EXECUTION_TIMEOUT, DEFAULT_MAX_PTC_CALLS, DEFAULT_MAX_STACK_SIZE, DEFAULT_MEMORY_LIMIT, PTCCallBudgetExceededError, type ReplResult, ReplSession, type ReplSessionOptions, type SubagentBridgeOptions, createCodeInterpreterMiddleware, formatReplResult, stripTypeSyntax, toCamelCase, transformForEval, validateResponseSchema };
|
|
389
342
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import * as _$langchain from "langchain";
|
|
2
1
|
import { AgentMiddleware } from "langchain";
|
|
3
2
|
import { z } from "zod/v4";
|
|
4
|
-
import { AnyBackendProtocol, BackendFactory, SkillMetadata } from "deepagents";
|
|
5
3
|
import { StructuredToolInterface } from "@langchain/core/tools";
|
|
6
4
|
|
|
7
5
|
//#region src/types.d.ts
|
|
@@ -39,11 +37,6 @@ interface CodeInterpreterMiddlewareOptions {
|
|
|
39
37
|
* @default null (uses built-in prompt)
|
|
40
38
|
*/
|
|
41
39
|
systemPrompt?: string | null;
|
|
42
|
-
/**
|
|
43
|
-
* Backend the REPL reads skill module sources from. When provided alongside
|
|
44
|
-
* `SkillsMiddleware`, skills with a `module:` key become dynamic-importable.
|
|
45
|
-
*/
|
|
46
|
-
skillsBackend?: AnyBackendProtocol | BackendFactory;
|
|
47
40
|
/**
|
|
48
41
|
* Maximum number of `tools.*` bridge calls allowed per `eval()` invocation.
|
|
49
42
|
*
|
|
@@ -78,6 +71,43 @@ interface CodeInterpreterMiddlewareOptions {
|
|
|
78
71
|
* @default true
|
|
79
72
|
*/
|
|
80
73
|
captureConsole?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Expose the built-in `task()` global for subagent orchestration.
|
|
76
|
+
*
|
|
77
|
+
* When `true` (default) and subagent specs are available, a `task()`
|
|
78
|
+
* global is installed in the REPL that dispatches subagents
|
|
79
|
+
* programmatically with a fixed concurrency cap of 32.
|
|
80
|
+
* Set to `false` to require subagent dispatch through the normal
|
|
81
|
+
* `task` tool path.
|
|
82
|
+
*
|
|
83
|
+
* @default true
|
|
84
|
+
*/
|
|
85
|
+
subagents?: boolean;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Configuration for the built-in subagent primitive.
|
|
89
|
+
*
|
|
90
|
+
* When provided to a ReplSession, a frozen `subagent()` global is
|
|
91
|
+
* installed in the QuickJS context. Calls are gated by a concurrency
|
|
92
|
+
* queue and forwarded to the dispatch callback.
|
|
93
|
+
*/
|
|
94
|
+
interface SubagentBridgeOptions {
|
|
95
|
+
/**
|
|
96
|
+
* Callback that invokes a subagent. Receives validated input from
|
|
97
|
+
* the QuickJS guest and returns the subagent's output — a string
|
|
98
|
+
* for text responses or an object for structured (responseSchema)
|
|
99
|
+
* responses.
|
|
100
|
+
*/
|
|
101
|
+
dispatch: (input: {
|
|
102
|
+
description: string;
|
|
103
|
+
subagentType: string;
|
|
104
|
+
responseSchema?: Record<string, unknown>;
|
|
105
|
+
}) => Promise<unknown>;
|
|
106
|
+
/**
|
|
107
|
+
* Maximum number of concurrent subagent calls within a single eval.
|
|
108
|
+
* Excess calls queue and resolve as permits free up.
|
|
109
|
+
*/
|
|
110
|
+
maxConcurrency: number;
|
|
81
111
|
}
|
|
82
112
|
/**
|
|
83
113
|
* Options for creating a ReplSession.
|
|
@@ -86,10 +116,11 @@ interface ReplSessionOptions {
|
|
|
86
116
|
memoryLimitBytes?: number;
|
|
87
117
|
maxStackSizeBytes?: number;
|
|
88
118
|
tools?: StructuredToolInterface[];
|
|
89
|
-
skillsEnabled?: boolean;
|
|
90
119
|
maxPtcCalls?: number | null;
|
|
91
120
|
maxResultChars?: number;
|
|
92
121
|
captureConsole?: boolean;
|
|
122
|
+
sessionId?: string;
|
|
123
|
+
subagentBridge?: SubagentBridgeOptions;
|
|
93
124
|
}
|
|
94
125
|
/**
|
|
95
126
|
* Result of a single REPL evaluation.
|
|
@@ -105,31 +136,18 @@ interface ReplResult {
|
|
|
105
136
|
logs: string[];
|
|
106
137
|
logsDroppedChars: number;
|
|
107
138
|
}
|
|
108
|
-
/**
|
|
109
|
-
* Metadata + backend pair the session needs to resolve skill imports.
|
|
110
|
-
*/
|
|
111
|
-
interface SkillsContext {
|
|
112
|
-
/**
|
|
113
|
-
* Per-eval snapshot of `state.skillsMetadata`.
|
|
114
|
-
*/
|
|
115
|
-
metadata: SkillMetadata[];
|
|
116
|
-
/**
|
|
117
|
-
* Backend the session fetches skill source files from.
|
|
118
|
-
*/
|
|
119
|
-
backend: AnyBackendProtocol;
|
|
120
|
-
}
|
|
121
139
|
//#endregion
|
|
122
140
|
//#region src/middleware.d.ts
|
|
123
141
|
/**
|
|
124
142
|
* Create the Code Interpreter middleware.
|
|
125
143
|
*/
|
|
126
|
-
declare function createCodeInterpreterMiddleware(options?: CodeInterpreterMiddlewareOptions): AgentMiddleware<undefined, undefined, unknown, readonly [
|
|
144
|
+
declare function createCodeInterpreterMiddleware(options?: CodeInterpreterMiddlewareOptions): AgentMiddleware<undefined, undefined, unknown, readonly [import("langchain").DynamicStructuredTool<z.ZodObject<{
|
|
127
145
|
code: z.ZodString;
|
|
128
146
|
}, z.core.$strip>, {
|
|
129
147
|
code: string;
|
|
130
148
|
}, {
|
|
131
149
|
code: string;
|
|
132
|
-
}, string, unknown, string>]>;
|
|
150
|
+
}, string, unknown, string>], readonly []>;
|
|
133
151
|
//#endregion
|
|
134
152
|
//#region src/errors.d.ts
|
|
135
153
|
/**
|
|
@@ -179,11 +197,12 @@ declare class ReplSession {
|
|
|
179
197
|
private context;
|
|
180
198
|
private consoleBuffer;
|
|
181
199
|
private options;
|
|
182
|
-
private skillsContext;
|
|
183
|
-
private skillsLoaded;
|
|
184
|
-
private skillsFailed;
|
|
185
200
|
private readonly maxPtcCalls;
|
|
186
201
|
private ptcCallsRemaining;
|
|
202
|
+
private subagentQueue;
|
|
203
|
+
private bridgeDispatchRef;
|
|
204
|
+
/** Allowed keys in the subagent input object. */
|
|
205
|
+
private static readonly SUBAGENT_ALLOWED_KEYS;
|
|
187
206
|
/**
|
|
188
207
|
* Reset the shared WASM module. Forces the next session to instantiate
|
|
189
208
|
* a fresh module. Only needed in tests where module state must be
|
|
@@ -194,42 +213,6 @@ declare class ReplSession {
|
|
|
194
213
|
static resetSharedModule(): void;
|
|
195
214
|
constructor(id: string, options?: ReplSessionOptions);
|
|
196
215
|
private ensureStarted;
|
|
197
|
-
/**
|
|
198
|
-
* Load the skill into cache on first access and replay cached errors.
|
|
199
|
-
*/
|
|
200
|
-
private ensureSkillLoaded;
|
|
201
|
-
/**
|
|
202
|
-
* Pre-load all skills referenced in source code into the in-memory
|
|
203
|
-
* cache. Must be called before `evalCodeAsync` so the module loader
|
|
204
|
-
* can resolve synchronously. An async loader would cause asyncify
|
|
205
|
-
* suspensions on each import, which is incompatible with the shared
|
|
206
|
-
* WASM module used by all sessions.
|
|
207
|
-
*/
|
|
208
|
-
preloadReferencedSkills(code: string): Promise<void>;
|
|
209
|
-
/**
|
|
210
|
-
* Resolve a module specifier to source code. Strictly synchronous —
|
|
211
|
-
* only reads from the in-memory skill cache populated by
|
|
212
|
-
* `preloadReferencedSkills`. Returns error source (not a thrown
|
|
213
|
-
* exception) for missing or failed skills so QuickJS reports the
|
|
214
|
-
* error inside the VM.
|
|
215
|
-
*/
|
|
216
|
-
private resolveSpecifier;
|
|
217
|
-
/**
|
|
218
|
-
* Canonicalize an `import` specifier. Bare specifiers pass through;
|
|
219
|
-
* relative specifiers are resolved against the importing module's path.
|
|
220
|
-
* Traversal out of a skill's `@/skills/<name>/` namespace is rejected.
|
|
221
|
-
*/
|
|
222
|
-
private normalizeSpecifier;
|
|
223
|
-
/**
|
|
224
|
-
* Wire the QuickJS module loader and normalizer on this session's runtime.
|
|
225
|
-
*
|
|
226
|
-
* The loader is strictly synchronous — it reads from the in-memory skill
|
|
227
|
-
* cache populated by `preloadReferencedSkills`. This is critical: an async
|
|
228
|
-
* module loader causes asyncify suspensions on each import, and disposing
|
|
229
|
-
* a runtime after multi-file imports corrupts the shared module's asyncify
|
|
230
|
-
* state, silently breaking the loader for all subsequent sessions.
|
|
231
|
-
*/
|
|
232
|
-
private installModuleLoader;
|
|
233
216
|
/**
|
|
234
217
|
* Initialise the per-eval PTC counter. Called at the top of every `eval()`.
|
|
235
218
|
*/
|
|
@@ -261,12 +244,6 @@ declare class ReplSession {
|
|
|
261
244
|
* Dispose and remove the session with the given key, if it exists.
|
|
262
245
|
*/
|
|
263
246
|
static deleteSession(key: string): void;
|
|
264
|
-
/**
|
|
265
|
-
* Push the current skills metadata + backend into the session.
|
|
266
|
-
* Called by the middleware once per `eval` invocation, before eval runs.
|
|
267
|
-
* Pass `undefined` to clear the context (no skill imports will resolve).
|
|
268
|
-
*/
|
|
269
|
-
setSkillsContext(ctx?: SkillsContext): void;
|
|
270
247
|
/**
|
|
271
248
|
* Evaluate code in this session.
|
|
272
249
|
*
|
|
@@ -291,6 +268,23 @@ declare class ReplSession {
|
|
|
291
268
|
static clearCache(): void;
|
|
292
269
|
private setupConsole;
|
|
293
270
|
private injectTools;
|
|
271
|
+
/**
|
|
272
|
+
* Install the `task` global on the QuickJS context.
|
|
273
|
+
*
|
|
274
|
+
* Registers the host function directly as `globalThis.task`,
|
|
275
|
+
* then freezes it via `evalCode`. Structured results (when
|
|
276
|
+
* responseSchema is provided) are marshaled into native QuickJS
|
|
277
|
+
* objects on the host side — no JS wrapper needed.
|
|
278
|
+
*/
|
|
279
|
+
/**
|
|
280
|
+
* Replace the active bridge dispatch with a fresh one.
|
|
281
|
+
*
|
|
282
|
+
* Call this before each eval so the dispatch closure carries
|
|
283
|
+
* the current invocation's config (tracing callbacks, run ID, etc.)
|
|
284
|
+
* rather than the stale config from session creation.
|
|
285
|
+
*/
|
|
286
|
+
updateBridgeDispatch(dispatch: SubagentBridgeOptions["dispatch"]): void;
|
|
287
|
+
private injectSubagentBridge;
|
|
294
288
|
}
|
|
295
289
|
//#endregion
|
|
296
290
|
//#region src/utils.d.ts
|
|
@@ -302,10 +296,6 @@ declare function toCamelCase(name: string): string;
|
|
|
302
296
|
* Format the result of a REPL evaluation for the agent.
|
|
303
297
|
*/
|
|
304
298
|
declare function formatReplResult(result: ReplResult): string;
|
|
305
|
-
/**
|
|
306
|
-
* Render a pre-eval error when referenced skills are not available on the agent.
|
|
307
|
-
*/
|
|
308
|
-
declare function formatSkillNotAvailable(missing: readonly string[]): string;
|
|
309
299
|
//#endregion
|
|
310
300
|
//#region src/transform.d.ts
|
|
311
301
|
/**
|
|
@@ -339,51 +329,14 @@ declare function transformForEval(code: string): string;
|
|
|
339
329
|
*/
|
|
340
330
|
declare function stripTypeSyntax(code: string): string;
|
|
341
331
|
//#endregion
|
|
342
|
-
//#region src/
|
|
343
|
-
/**
|
|
344
|
-
* File extensions the loader will enumerate from a skill directory.
|
|
345
|
-
*/
|
|
346
|
-
declare const SKILL_MODULE_EXTENSIONS: string[];
|
|
347
|
-
/**
|
|
348
|
-
* Hard cap on total bytes pulled for one skill's bundle (1 MiB).
|
|
349
|
-
*/
|
|
350
|
-
declare const MAX_SKILL_BUNDLE_BYTES: number;
|
|
351
|
-
/**
|
|
352
|
-
* Install-ready state for a single skill, produced by `loadSkill`.
|
|
353
|
-
*/
|
|
354
|
-
interface LoadedSkill {
|
|
355
|
-
/**
|
|
356
|
-
* Spec-validated kebab-case skill name.
|
|
357
|
-
*/
|
|
358
|
-
name: string;
|
|
359
|
-
/**
|
|
360
|
-
* Bare specifier the skill installs under: `"@/skills/<name>"`.
|
|
361
|
-
*/
|
|
362
|
-
specifier: string;
|
|
363
|
-
/**
|
|
364
|
-
* Relative POSIX path of the entrypoint file (e.g. `"index.ts"`).
|
|
365
|
-
*/
|
|
366
|
-
entryRel: string;
|
|
367
|
-
/**
|
|
368
|
-
* File contents keyed by relative POSIX path, with TS syntax stripped.
|
|
369
|
-
*/
|
|
370
|
-
files: Map<string, string>;
|
|
371
|
-
}
|
|
372
|
-
/**
|
|
373
|
-
* Build a `LoadedSkill` from a skill's metadata and a backend handle.
|
|
374
|
-
*
|
|
375
|
-
* Enumerates code files under the skill directory, downloads them,
|
|
376
|
-
* strips TypeScript syntax, and validates the entrypoint is present.
|
|
377
|
-
*/
|
|
378
|
-
declare function loadSkill(metadata: SkillMetadata, backend: AnyBackendProtocol): Promise<LoadedSkill>;
|
|
332
|
+
//#region src/subagent-dispatch.d.ts
|
|
379
333
|
/**
|
|
380
|
-
*
|
|
334
|
+
* Validate that a response schema does not exceed size, depth, or
|
|
335
|
+
* property-count limits.
|
|
381
336
|
*
|
|
382
|
-
*
|
|
383
|
-
* before evaluation starts. Dynamic imports with computed specifiers are
|
|
384
|
-
* not detected.
|
|
337
|
+
* @throws Error if any limit is exceeded.
|
|
385
338
|
*/
|
|
386
|
-
declare function
|
|
339
|
+
declare function validateResponseSchema(schema: Record<string, unknown>): void;
|
|
387
340
|
//#endregion
|
|
388
|
-
export { type CodeInterpreterMiddlewareOptions, DEFAULT_EXECUTION_TIMEOUT, DEFAULT_MAX_PTC_CALLS, DEFAULT_MAX_STACK_SIZE, DEFAULT_MEMORY_LIMIT,
|
|
341
|
+
export { type CodeInterpreterMiddlewareOptions, DEFAULT_EXECUTION_TIMEOUT, DEFAULT_MAX_PTC_CALLS, DEFAULT_MAX_STACK_SIZE, DEFAULT_MEMORY_LIMIT, PTCCallBudgetExceededError, type ReplResult, ReplSession, type ReplSessionOptions, type SubagentBridgeOptions, createCodeInterpreterMiddleware, formatReplResult, stripTypeSyntax, toCamelCase, transformForEval, validateResponseSchema };
|
|
389
342
|
//# sourceMappingURL=index.d.ts.map
|