@dudko.dev/agent-web 0.0.36 → 0.0.38
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/README.md +156 -4
- package/dist/agent-web.js +270 -110
- package/dist/agent-web.js.map +1 -1
- package/dist/chunk-AY2BZYZY.js +573 -0
- package/dist/chunk-AY2BZYZY.js.map +1 -0
- package/dist/chunk-CTXDKSDD.js +39 -0
- package/dist/chunk-CTXDKSDD.js.map +1 -0
- package/dist/{chunk-CPSDKXO6.js → chunk-T6LZW7ML.js} +27 -35
- package/dist/chunk-T6LZW7ML.js.map +1 -0
- package/dist/chunk-V3JOK7EW.js +929 -0
- package/dist/chunk-V3JOK7EW.js.map +1 -0
- package/dist/index.cjs +5980 -3627
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +363 -3
- package/dist/index.d.ts +363 -3
- package/dist/index.js +1183 -583
- package/dist/index.js.map +1 -1
- package/dist/mcp.cjs +879 -13
- package/dist/mcp.cjs.map +1 -1
- package/dist/mcp.d.cts +372 -13
- package/dist/mcp.d.ts +372 -13
- package/dist/mcp.js +857 -15
- package/dist/mcp.js.map +1 -1
- package/dist/sandbox-AMO2SA4X.js +269 -0
- package/dist/sandbox-AMO2SA4X.js.map +1 -0
- package/dist/sandbox-worker.cjs +745 -0
- package/dist/sandbox-worker.cjs.map +1 -0
- package/dist/sandbox-worker.d.cts +37 -0
- package/dist/sandbox-worker.d.ts +37 -0
- package/dist/sandbox-worker.js +27 -0
- package/dist/sandbox-worker.js.map +1 -0
- package/package.json +30 -11
- package/dist/chunk-CPSDKXO6.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -517,6 +517,8 @@ interface PlannerPromptContext {
|
|
|
517
517
|
skills?: string;
|
|
518
518
|
/** The catalogue is condensed and the executor can search the rest (large catalogues). */
|
|
519
519
|
searchMode?: boolean;
|
|
520
|
+
/** Set when `config.sandbox` is on: when to plan a `run_js` step. */
|
|
521
|
+
sandbox?: string;
|
|
520
522
|
}
|
|
521
523
|
interface ExecutorPromptContext {
|
|
522
524
|
goal: string;
|
|
@@ -540,6 +542,8 @@ interface ExecutorPromptContext {
|
|
|
540
542
|
learning?: {
|
|
541
543
|
fetch: boolean;
|
|
542
544
|
};
|
|
545
|
+
/** Set when `config.sandbox` is on: what `run_js` is, and never to report code as run without it. */
|
|
546
|
+
sandbox?: string;
|
|
543
547
|
}
|
|
544
548
|
interface ReplannerPromptContext {
|
|
545
549
|
goal: string;
|
|
@@ -562,6 +566,8 @@ interface SynthesizerPromptContext {
|
|
|
562
566
|
activeSkills?: string;
|
|
563
567
|
/** What the user said while the run was going, oldest first. */
|
|
564
568
|
updates?: string[];
|
|
569
|
+
/** Set when `config.sandbox` is on: the output of code is reported only when `run_js` returned it. */
|
|
570
|
+
sandbox?: string;
|
|
565
571
|
}
|
|
566
572
|
interface Prompts {
|
|
567
573
|
planner(ctx: PlannerPromptContext): PromptParts;
|
|
@@ -807,6 +813,66 @@ interface SaveSkillInput {
|
|
|
807
813
|
*/
|
|
808
814
|
declare const createLearning: (cfg: LearningConfig, skills: Skill[], warn: (message: string) => void) => Promise<Learning>;
|
|
809
815
|
|
|
816
|
+
interface ISandboxConfig {
|
|
817
|
+
timeoutMs?: number;
|
|
818
|
+
memoryLimitBytes?: number;
|
|
819
|
+
maxOutputChars?: number;
|
|
820
|
+
maxCodeChars?: number;
|
|
821
|
+
files?: boolean;
|
|
822
|
+
}
|
|
823
|
+
interface ISandboxLimits {
|
|
824
|
+
timeoutMs: number;
|
|
825
|
+
memoryLimitBytes: number;
|
|
826
|
+
maxOutputChars: number;
|
|
827
|
+
maxCodeChars: number;
|
|
828
|
+
}
|
|
829
|
+
interface ISandboxError {
|
|
830
|
+
name: string;
|
|
831
|
+
message: string;
|
|
832
|
+
stack?: string;
|
|
833
|
+
}
|
|
834
|
+
interface ISandboxResult {
|
|
835
|
+
ok: boolean;
|
|
836
|
+
stdout: string;
|
|
837
|
+
result?: unknown;
|
|
838
|
+
error?: ISandboxError;
|
|
839
|
+
truncated: boolean;
|
|
840
|
+
durationMs: number;
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
/**
|
|
844
|
+
* `config.sandbox`: the `run_js` tool - the model's code runs in QuickJS compiled to
|
|
845
|
+
* WebAssembly (the optional peer `quickjs-emscripten`), never in the page's own JavaScript
|
|
846
|
+
* engine. This module is loaded only when the sandbox is switched on.
|
|
847
|
+
*
|
|
848
|
+
* Where the guest runs:
|
|
849
|
+
* - `worker` given: in a Web Worker that is terminated when the run is over or over time (the
|
|
850
|
+
* hard stop). One worker per run. The worker module is `@dudko.dev/agent-web/sandbox-worker`.
|
|
851
|
+
* - no `worker`: on the page's thread, stopped by the engine's interrupt handler only. A single
|
|
852
|
+
* long native call in the guest then blocks the page until it returns - prefer a worker.
|
|
853
|
+
*/
|
|
854
|
+
/** A worker as the sandbox uses it: a real `Worker`, or a `MessagePort` in tests. */
|
|
855
|
+
interface SandboxWorkerLike {
|
|
856
|
+
postMessage(message: unknown): void;
|
|
857
|
+
addEventListener(type: string, listener: (ev: any) => void): void;
|
|
858
|
+
terminate?(): void;
|
|
859
|
+
}
|
|
860
|
+
interface SandboxConfig extends ISandboxConfig {
|
|
861
|
+
/**
|
|
862
|
+
* Builds a fresh Worker for one run, e.g.
|
|
863
|
+
* `() => new Worker(new URL('@dudko.dev/agent-web/sandbox-worker', import.meta.url), { type: 'module' })`
|
|
864
|
+
* (Vite: `import SandboxWorker from '@dudko.dev/agent-web/sandbox-worker?worker'`). Without it
|
|
865
|
+
* the guest runs on the page's thread - isolated all the same, but only softly interruptible.
|
|
866
|
+
*/
|
|
867
|
+
worker?: () => SandboxWorkerLike;
|
|
868
|
+
/**
|
|
869
|
+
* Loads the engine for the page-thread fallback, e.g. `() => import('quickjs-emscripten')`, so
|
|
870
|
+
* that your bundler resolves it. Default: a runtime `import('quickjs-emscripten')` (Node, or a
|
|
871
|
+
* page with an import map). Not used when `worker` is given.
|
|
872
|
+
*/
|
|
873
|
+
engine?: () => Promise<unknown>;
|
|
874
|
+
}
|
|
875
|
+
|
|
810
876
|
type EgressErrorCode = 'disabled' | 'bad-url' | 'bad-protocol' | 'bad-port' | 'bad-method' | 'credentials-in-url' | 'denied-host' | 'not-allowed-host' | 'denied-address' | 'bad-redirect' | 'network' | 'too-large' | 'timeout';
|
|
811
877
|
declare class EgressError extends Error {
|
|
812
878
|
readonly code: EgressErrorCode;
|
|
@@ -987,6 +1053,17 @@ interface BrowserAgentConfig {
|
|
|
987
1053
|
* or tools you pass yourself - those are your configuration, not the model's.
|
|
988
1054
|
*/
|
|
989
1055
|
egress?: boolean | IEgressPolicy;
|
|
1056
|
+
/**
|
|
1057
|
+
* Let the agent RUN JavaScript it wrote (the `run_js` tool) and read the output. Off unless
|
|
1058
|
+
* set: with it off the tool does not exist and the engine is never loaded. `true` = the
|
|
1059
|
+
* defaults, on the page's thread; an object sets the limits and - recommended - a `worker`
|
|
1060
|
+
* factory, so the guest runs in a Web Worker that is terminated at the deadline. The guest
|
|
1061
|
+
* runs in QuickJS compiled to WebAssembly (the optional peer `quickjs-emscripten`): no network,
|
|
1062
|
+
* no DOM, no page globals. When the agent has file tools (`createFileTools`) the guest can
|
|
1063
|
+
* import / require workspace files and use `fs` through the same file system and the same
|
|
1064
|
+
* consent rules (`files: false` switches that off). A run is a write for tool approval.
|
|
1065
|
+
*/
|
|
1066
|
+
sandbox?: boolean | SandboxConfig;
|
|
990
1067
|
/** Host tools the executor may call (an AI SDK ToolSet; use defineTool). */
|
|
991
1068
|
tools?: AgentToolSet;
|
|
992
1069
|
/** Whitelist: only these tool names from `tools` are mounted (default: all). */
|
|
@@ -1114,6 +1191,201 @@ interface ResolvedConfig {
|
|
|
1114
1191
|
declare const resolveBudgets: (c: BrowserAgentConfig, contextWindowTokens: number) => ResolvedConfig["budgets"];
|
|
1115
1192
|
declare const resolveConfig: (c: BrowserAgentConfig) => ResolvedConfig;
|
|
1116
1193
|
|
|
1194
|
+
interface PipelineDefinition {
|
|
1195
|
+
version: 1;
|
|
1196
|
+
name?: string;
|
|
1197
|
+
entry: string;
|
|
1198
|
+
nodes: PipelineNode[];
|
|
1199
|
+
edges: PipelineEdge[];
|
|
1200
|
+
limits?: {
|
|
1201
|
+
maxNodeVisits?: number;
|
|
1202
|
+
maxRuns?: number;
|
|
1203
|
+
};
|
|
1204
|
+
}
|
|
1205
|
+
interface PipelineNode {
|
|
1206
|
+
id: string;
|
|
1207
|
+
name?: string;
|
|
1208
|
+
instructions?: string;
|
|
1209
|
+
model?: string;
|
|
1210
|
+
skills?: string[];
|
|
1211
|
+
tools?: string[];
|
|
1212
|
+
mcpServers?: string[];
|
|
1213
|
+
routes?: PipelineRoute[];
|
|
1214
|
+
join?: 'all' | 'any';
|
|
1215
|
+
settings?: Record<string, unknown>;
|
|
1216
|
+
position?: {
|
|
1217
|
+
x: number;
|
|
1218
|
+
y: number;
|
|
1219
|
+
};
|
|
1220
|
+
}
|
|
1221
|
+
interface PipelineRoute {
|
|
1222
|
+
label: string;
|
|
1223
|
+
description?: string;
|
|
1224
|
+
}
|
|
1225
|
+
type PipelineCondition = {
|
|
1226
|
+
kind: 'always';
|
|
1227
|
+
} | {
|
|
1228
|
+
kind: 'contains';
|
|
1229
|
+
text: string;
|
|
1230
|
+
caseSensitive?: boolean;
|
|
1231
|
+
} | {
|
|
1232
|
+
kind: 'matches';
|
|
1233
|
+
pattern: string;
|
|
1234
|
+
flags?: string;
|
|
1235
|
+
} | {
|
|
1236
|
+
kind: 'route';
|
|
1237
|
+
label: string;
|
|
1238
|
+
} | {
|
|
1239
|
+
kind: 'otherwise';
|
|
1240
|
+
};
|
|
1241
|
+
interface PipelineEdge {
|
|
1242
|
+
id?: string;
|
|
1243
|
+
from: string;
|
|
1244
|
+
to: string;
|
|
1245
|
+
when?: PipelineCondition;
|
|
1246
|
+
}
|
|
1247
|
+
declare const PIPELINE_LIMITS: {
|
|
1248
|
+
readonly maxNodeVisits: 3;
|
|
1249
|
+
readonly maxRuns: 25;
|
|
1250
|
+
readonly maxNodeVisitsCeiling: 100;
|
|
1251
|
+
readonly maxRunsCeiling: 1000;
|
|
1252
|
+
readonly maxNodes: 200;
|
|
1253
|
+
readonly maxEdges: 1000;
|
|
1254
|
+
readonly maxRoutes: 20;
|
|
1255
|
+
readonly maxPatternLength: 500;
|
|
1256
|
+
readonly maxPatternProgram: 1000;
|
|
1257
|
+
readonly conditionInputChars: 50000;
|
|
1258
|
+
};
|
|
1259
|
+
interface PipelineUsage {
|
|
1260
|
+
inputTokens: number;
|
|
1261
|
+
outputTokens: number;
|
|
1262
|
+
totalTokens: number;
|
|
1263
|
+
reasoningTokens?: number;
|
|
1264
|
+
cachedInputTokens?: number;
|
|
1265
|
+
cacheWriteTokens?: number;
|
|
1266
|
+
}
|
|
1267
|
+
interface PipelineNodeSource {
|
|
1268
|
+
nodeId: string;
|
|
1269
|
+
name?: string;
|
|
1270
|
+
text: string;
|
|
1271
|
+
}
|
|
1272
|
+
interface PipelineNodeInput {
|
|
1273
|
+
request: string;
|
|
1274
|
+
from: PipelineNodeSource[];
|
|
1275
|
+
visit: number;
|
|
1276
|
+
}
|
|
1277
|
+
interface PipelineNodeOutput {
|
|
1278
|
+
text: string;
|
|
1279
|
+
usage?: PipelineUsage;
|
|
1280
|
+
route?: string;
|
|
1281
|
+
}
|
|
1282
|
+
interface PipelineNodeContext<E = never> {
|
|
1283
|
+
signal: AbortSignal;
|
|
1284
|
+
pipeline: PipelineDefinition;
|
|
1285
|
+
emit: (event: E) => void;
|
|
1286
|
+
}
|
|
1287
|
+
type PipelineNodeRunner<E = never> = (node: PipelineNode, input: PipelineNodeInput, ctx: PipelineNodeContext<E>) => Promise<PipelineNodeOutput>;
|
|
1288
|
+
type PipelineStop = 'maxRuns' | 'maxNodeVisits' | 'aborted';
|
|
1289
|
+
type PipelineEvent = {
|
|
1290
|
+
type: 'pipeline.started';
|
|
1291
|
+
pipeline?: string;
|
|
1292
|
+
} | {
|
|
1293
|
+
type: 'pipeline.node.started';
|
|
1294
|
+
nodeId: string;
|
|
1295
|
+
visit: number;
|
|
1296
|
+
from: string[];
|
|
1297
|
+
} | {
|
|
1298
|
+
type: 'pipeline.node.finished';
|
|
1299
|
+
nodeId: string;
|
|
1300
|
+
visit: number;
|
|
1301
|
+
text: string;
|
|
1302
|
+
route?: string;
|
|
1303
|
+
usage?: PipelineUsage;
|
|
1304
|
+
} | {
|
|
1305
|
+
type: 'pipeline.node.failed';
|
|
1306
|
+
nodeId: string;
|
|
1307
|
+
visit: number;
|
|
1308
|
+
error: string;
|
|
1309
|
+
} | {
|
|
1310
|
+
type: 'pipeline.node.skipped';
|
|
1311
|
+
nodeId: string;
|
|
1312
|
+
from: string[];
|
|
1313
|
+
reason: 'maxRuns' | 'maxNodeVisits';
|
|
1314
|
+
} | {
|
|
1315
|
+
type: 'pipeline.edge';
|
|
1316
|
+
from: string;
|
|
1317
|
+
to: string;
|
|
1318
|
+
edgeId: string;
|
|
1319
|
+
visit: number;
|
|
1320
|
+
fired: boolean;
|
|
1321
|
+
} | {
|
|
1322
|
+
type: 'pipeline.finished';
|
|
1323
|
+
stoppedBy?: PipelineStop;
|
|
1324
|
+
runs: number;
|
|
1325
|
+
};
|
|
1326
|
+
type PipelineTraceEntry = {
|
|
1327
|
+
type: 'node';
|
|
1328
|
+
nodeId: string;
|
|
1329
|
+
visit: number;
|
|
1330
|
+
wave: number;
|
|
1331
|
+
from: string[];
|
|
1332
|
+
text: string;
|
|
1333
|
+
route?: string;
|
|
1334
|
+
usage?: PipelineUsage;
|
|
1335
|
+
} | {
|
|
1336
|
+
type: 'edge';
|
|
1337
|
+
from: string;
|
|
1338
|
+
to: string;
|
|
1339
|
+
edgeId: string;
|
|
1340
|
+
visit: number;
|
|
1341
|
+
fired: boolean;
|
|
1342
|
+
} | {
|
|
1343
|
+
type: 'dropped';
|
|
1344
|
+
nodeId: string;
|
|
1345
|
+
from: string[];
|
|
1346
|
+
reason: 'maxRuns' | 'maxNodeVisits';
|
|
1347
|
+
};
|
|
1348
|
+
interface PipelineResult {
|
|
1349
|
+
text: string;
|
|
1350
|
+
outputs: Record<string, {
|
|
1351
|
+
visit: number;
|
|
1352
|
+
text: string;
|
|
1353
|
+
route?: string;
|
|
1354
|
+
}[]>;
|
|
1355
|
+
trace: PipelineTraceEntry[];
|
|
1356
|
+
usage: PipelineUsage;
|
|
1357
|
+
stoppedBy?: PipelineStop;
|
|
1358
|
+
runs: number;
|
|
1359
|
+
}
|
|
1360
|
+
interface PipelineIssue {
|
|
1361
|
+
code: string;
|
|
1362
|
+
message: string;
|
|
1363
|
+
nodeId?: string;
|
|
1364
|
+
edgeId?: string;
|
|
1365
|
+
edgeIndex?: number;
|
|
1366
|
+
}
|
|
1367
|
+
interface PipelineValidation {
|
|
1368
|
+
ok: boolean;
|
|
1369
|
+
errors: PipelineIssue[];
|
|
1370
|
+
warnings: PipelineIssue[];
|
|
1371
|
+
}
|
|
1372
|
+
declare class PipelineValidationError extends Error {
|
|
1373
|
+
errors: PipelineIssue[];
|
|
1374
|
+
constructor(errors: PipelineIssue[]);
|
|
1375
|
+
}
|
|
1376
|
+
declare class PipelineNodeError extends Error {
|
|
1377
|
+
nodeId: string;
|
|
1378
|
+
visit: number;
|
|
1379
|
+
constructor(nodeId: string, visit: number, cause: unknown);
|
|
1380
|
+
}
|
|
1381
|
+
declare const testPipelineCondition: (when: PipelineCondition | undefined, output: {
|
|
1382
|
+
text: string;
|
|
1383
|
+
route?: string;
|
|
1384
|
+
}, matcher?: (text: string) => boolean) => boolean;
|
|
1385
|
+
declare const normalizePipeline: (definition: PipelineDefinition) => PipelineDefinition;
|
|
1386
|
+
declare const validatePipeline: (definition: PipelineDefinition) => PipelineValidation;
|
|
1387
|
+
declare const renderPipelineNodeInput: (input: PipelineNodeInput) => string;
|
|
1388
|
+
|
|
1117
1389
|
type ReplanMode = 'continue' | 'revise' | 'finish';
|
|
1118
1390
|
type Phase = 'plan' | 'execute' | 'replan' | 'synthesize';
|
|
1119
1391
|
/** Phases a `usage` event can be charged to: the four stages plus compaction and subagents. */
|
|
@@ -1125,7 +1397,7 @@ type UsagePhase = Phase | 'compact' | 'subagent';
|
|
|
1125
1397
|
* event taxonomy (no persistence/otel events), plus `model.load` for WebLLM
|
|
1126
1398
|
* weight-download progress.
|
|
1127
1399
|
*/
|
|
1128
|
-
type
|
|
1400
|
+
type AgentEventBody =
|
|
1129
1401
|
/**
|
|
1130
1402
|
* `runId` names the run for `persistence` / `resumeFromRunId`. `resumed` is set when it
|
|
1131
1403
|
* continues a checkpointed run: the steps already done and the ones still to come.
|
|
@@ -1339,6 +1611,16 @@ type AgentEvent =
|
|
|
1339
1611
|
type: 'error';
|
|
1340
1612
|
phase: Phase | 'run';
|
|
1341
1613
|
error: string;
|
|
1614
|
+
}
|
|
1615
|
+
/** A pipeline's own events (`createPipeline`): the run, each node visit, each edge decision. */
|
|
1616
|
+
| PipelineEvent;
|
|
1617
|
+
/**
|
|
1618
|
+
* `nodeId` / `visit` are set on the events a pipeline forwards from a node's agent (and on the
|
|
1619
|
+
* `pipeline.node.*` events themselves).
|
|
1620
|
+
*/
|
|
1621
|
+
type AgentEvent = AgentEventBody & {
|
|
1622
|
+
nodeId?: string;
|
|
1623
|
+
visit?: number;
|
|
1342
1624
|
};
|
|
1343
1625
|
type AgentEventHandler = (event: AgentEvent) => void;
|
|
1344
1626
|
|
|
@@ -1544,6 +1826,15 @@ interface AgentContext {
|
|
|
1544
1826
|
nudge: boolean;
|
|
1545
1827
|
tools: string[];
|
|
1546
1828
|
};
|
|
1829
|
+
/**
|
|
1830
|
+
* Set when `config.sandbox` is on and `run_js` is mounted: the sentences the stage prompts
|
|
1831
|
+
* carry (what the tool is, and that code is never reported as run without it).
|
|
1832
|
+
*/
|
|
1833
|
+
sandbox?: {
|
|
1834
|
+
planner: string;
|
|
1835
|
+
executor: string;
|
|
1836
|
+
synthesizer: string;
|
|
1837
|
+
};
|
|
1547
1838
|
/** Tools find_tools activated during this run (search mode). */
|
|
1548
1839
|
discovered?: () => string[];
|
|
1549
1840
|
/** Built-in tool names (find_tools, skill tools) — always callable. */
|
|
@@ -1855,6 +2146,68 @@ findings?: string[]) => Promise<{
|
|
|
1855
2146
|
usage: IUsage;
|
|
1856
2147
|
}>;
|
|
1857
2148
|
|
|
2149
|
+
/**
|
|
2150
|
+
* A pipeline: a graph of agents with conditions and loops, described in plain JSON. The graph
|
|
2151
|
+
* engine (validation, conditions, scheduling) is `engine.ts`, the same file as the Node
|
|
2152
|
+
* sibling's; this file is the adapter that runs a node with this package's createAgent.
|
|
2153
|
+
*/
|
|
2154
|
+
interface PipelineOptions {
|
|
2155
|
+
/** The seam: run a node yourself. When given, the pipeline knows nothing about agents. */
|
|
2156
|
+
runNode?: PipelineNodeRunner<AgentEvent>;
|
|
2157
|
+
/**
|
|
2158
|
+
* Otherwise: the agent config of a node. One agent is created per node, on its first visit,
|
|
2159
|
+
* and kept until `pipeline.close()`.
|
|
2160
|
+
*/
|
|
2161
|
+
resolveNode?: (node: PipelineNode) => BrowserAgentConfig | Promise<BrowserAgentConfig>;
|
|
2162
|
+
}
|
|
2163
|
+
interface PipelineRunOptions {
|
|
2164
|
+
input: string;
|
|
2165
|
+
signal?: AbortSignal;
|
|
2166
|
+
/** The pipeline.* events, and every node agent's own events with `nodeId` and `visit` added. */
|
|
2167
|
+
onEvent?: AgentEventHandler;
|
|
2168
|
+
}
|
|
2169
|
+
interface Pipeline {
|
|
2170
|
+
/** A copy of the validated definition. */
|
|
2171
|
+
definition: PipelineDefinition;
|
|
2172
|
+
/**
|
|
2173
|
+
* Rejects with PipelineNodeError when a node fails. An aborted `signal` resolves with what the
|
|
2174
|
+
* run has and `stoppedBy: 'aborted'` (as agent.run resolves with `stopped`).
|
|
2175
|
+
*/
|
|
2176
|
+
run: (options: PipelineRunOptions) => Promise<PipelineResult>;
|
|
2177
|
+
/** Drop the node agents. The pipeline can run again: agents are created anew. */
|
|
2178
|
+
close: () => Promise<void>;
|
|
2179
|
+
}
|
|
2180
|
+
declare const createPipeline: (definition: PipelineDefinition, options: PipelineOptions) => Pipeline;
|
|
2181
|
+
interface NodeResolverOptions {
|
|
2182
|
+
/**
|
|
2183
|
+
* The config every node starts from. With `memory`, each node gets a session of its own,
|
|
2184
|
+
* `<base sessionId>:<node id>`, unless `configure` sets another.
|
|
2185
|
+
*/
|
|
2186
|
+
base: BrowserAgentConfig;
|
|
2187
|
+
/**
|
|
2188
|
+
* What the names in a node may refer to. A name that is not registered fails the node: a
|
|
2189
|
+
* definition cannot reach anything the host did not put here.
|
|
2190
|
+
*/
|
|
2191
|
+
models?: Record<string, ModelInput>;
|
|
2192
|
+
skills?: Record<string, Skill>;
|
|
2193
|
+
/** Named groups of tools. */
|
|
2194
|
+
tools?: Record<string, AgentToolSet>;
|
|
2195
|
+
/** Connected MCP servers (`connectMcpHttp` from `./mcp`), or any object with their `tools`. */
|
|
2196
|
+
mcpServers?: Record<string, {
|
|
2197
|
+
tools: AgentToolSet;
|
|
2198
|
+
}>;
|
|
2199
|
+
/**
|
|
2200
|
+
* The last word on a node's config - the place to read `node.settings`, which is never
|
|
2201
|
+
* applied by itself (it comes from the definition, and a definition is not trusted).
|
|
2202
|
+
*/
|
|
2203
|
+
configure?: (config: BrowserAgentConfig, node: PipelineNode) => BrowserAgentConfig | Promise<BrowserAgentConfig>;
|
|
2204
|
+
}
|
|
2205
|
+
/**
|
|
2206
|
+
* Build a `resolveNode` from registries: a node's `model`, `skills`, `tools` and `mcpServers`
|
|
2207
|
+
* names are looked up and added to `base`.
|
|
2208
|
+
*/
|
|
2209
|
+
declare const nodeResolver: (options: NodeResolverOptions) => NonNullable<PipelineOptions["resolveNode"]>;
|
|
2210
|
+
|
|
1858
2211
|
/**
|
|
1859
2212
|
* The wire protocol between a parent agent and a subagent running in a Web
|
|
1860
2213
|
* Worker. Every message is structured-cloneable; anything that is not (an
|
|
@@ -2038,6 +2391,13 @@ interface FileToolsOptions {
|
|
|
2038
2391
|
/** Cap on the text fs_read returns (default 50 000 chars; the rest is cut with a marker). */
|
|
2039
2392
|
maxReadChars?: number;
|
|
2040
2393
|
}
|
|
2394
|
+
/** What one of these tools does, and on which file system (read by `config.sandbox`). */
|
|
2395
|
+
interface FileToolBinding {
|
|
2396
|
+
vfs: VirtualFileSystem;
|
|
2397
|
+
op: 'list' | 'read' | 'write' | 'delete';
|
|
2398
|
+
}
|
|
2399
|
+
/** The file-system binding of a tool made by `createFileTools` (undefined for any other tool). */
|
|
2400
|
+
declare const fileToolBindingOf: (t: unknown) => FileToolBinding | undefined;
|
|
2041
2401
|
/**
|
|
2042
2402
|
* Tools that give the agent the virtual file system: list, read, write and
|
|
2043
2403
|
* delete. Listing and reading are marked read-only, so the `ask-writes`
|
|
@@ -2609,5 +2969,5 @@ declare class IndexedDBRunStore implements RunPersistence {
|
|
|
2609
2969
|
clear(): Promise<void>;
|
|
2610
2970
|
}
|
|
2611
2971
|
|
|
2612
|
-
export { AgentTool, AgentToolSet, AttachmentsNotSupportedError, ContextWindowExceededError, DEFAULT_COMPACTION_THRESHOLD_RATIO, EgressError, FILES_STORE, FIND_TOOLS_NAME, FORGET_SKILL_TOOL, ImagesNotSupportedError, IndexedDBRunStore, IndexedDBStore, KEYS_STORE, MemoryCredentialStore, MemoryRunStore, MemorySkillStore, MemoryStore, PlanSchema, PlanStepSchema, RUNS_STORE, ReplanSchema, SAVE_SKILL_TOOL, SECRETS_STORE, SESSIONS_STORE, SKILL_TOOL_NAMES, TOOL_APPROVAL_MODES, TOOL_SEARCH_WINDOW_SHARE, ToolBudgetError, ToolDeniedError, VaultCredentialStore, VaultOptions, VfsSkillStore, VirtualFileSystem, WEBLLM_DEFAULT_CONTEXT_WINDOW, WEB_FETCH_TOOL, attachmentKind, buildModelFromStage, bytesToBase64, checkEgressUrl, checkLimits, classifyAddress, compactHistory, compactSteps, compressHistory, contextOverflowOf, contextWindowOf, createAgent, createEgressTools, createFileTools, createFindToolsTool, createGuardedFetch, createLearning, createLogger, createPlan, createRunControl, createSkillTools, createSubagentTool, createToolResultClearer, createWebFetchTool, createWebLLMModel, decideReplan, decideToolPermission, decryptJSON, defaultPrompts, defineSkill, defineTool, directBrowserOk, dispatch, encryptJSON, messageTokens as estimateMessagesTokens, estimateTokens, executeStep, findSecret, fitCompactionToWindow, generate, generateStructured, getOrCreateVaultKey, hostMatches, htmlToText, isAttachmentRefusal, isDirectModel, isImageRefusal, isProviderSpec, isReadOnlyTool, isTextMime, isWebGPUAvailable, learnedPreamble, limitModelOutput, loadSkillFromUrl, looksLikeJson, markReadOnly, matchRule, mediaTypeOf, mergeProviderOptions, mimeFromPath, normalizePath, normalizeSkillName, normalizeSteps, normalizeUsage, openAgentWebDB, parseExecutorResponse, parsePlainText, parsePlannerResponse, parseReplannerResponse, parseSkillMarkdown, preloadWebLLMModel, renderActiveSkills, renderCatalog, renderSearchCatalog, renderSkillIndex, replanWanted, resolveBudgets, resolveCaching, resolveCompaction, resolveConfig, resolveEgressPolicy, resolveModel, resolveResume, resolveStage, resolveThinking, runToolLoop, schemaHintOf, searchTools, selectToolMode, serveSubagentWorker, shouldReplan, splitBlocker, stream, supportsImages, supportsNativeTools, supportsPdf, supportsStructuredOutput, synthesizeAnswer, thinkingFor, toFilePart, toImagePart, tokenize, toolCatalogOf, toolDefinitionTokens, toolRunContextOf, unloadWebLLMModel, webLLMContextWindow, withRollingBreakpoint, withSystem, withWebLLMContextWindow };
|
|
2613
|
-
export type { Agent, AgentContext, AgentEvent, AgentEventHandler, AgentLogger, AgentLoggerSink, AgentWebDBOptions, AttachmentKind, BrowserAgentConfig, ClearedInfo, CompactOptions, CompactResult, CompactionConfig, CompressOptions, ContextStore, CredentialStore, EffectiveToolStrategy, EgressErrorCode, EncryptedBlob, ExecutorPromptContext, ExecutorResult, FileToolsOptions, GenerateOptions, GuardedFetch, IEgressPolicy, IPlan, IPlanStep, IResolvedEgressPolicy, IStepResult, IToolCall, IUsage, IWebFetchOptions, IndexedDBRunStoreOptions, IndexedDBStoreOptions, Learning, LearningConfig, LimitBreach, LimitKind, LoadSkillOptions, LogLevel, MessageEndpoint, ModelInput, ParentToWorker, Phase, PhaseBudgets, PlanShape, PlannerPromptContext, PlannerResult, PromptCachingSetting, PromptParts, Prompts, ProviderModelSpec, ProviderOptionsMap, ProviderType, ProxiedToolSpec, RawAction, ReplanDecision, ReplanMode, ReplanShape, ReplanTrigger, ReplannerPromptContext, ReplannerResult, ResolvedCaching, ResolvedCompaction, ResolvedConfig, ResolvedStage, ResolvedThinking, RunControl, RunFile, RunImage, RunOptions, RunPersistence, RunResult, RunSnapshot, RunStatus, RunStoreOptions, SaveSkillInput, SearchToolsOptions, ServeSubagentOptions, Skill, SkillOrigin, SkillStore, StageInput, StageOverride, StoredMessage, SubagentInfo, SubagentProfile, SubagentToolOptions, SubagentWorkerConfig, SynthesizerPromptContext, ThinkingConfig, ThinkingLevel, ThinkingSetting, ThinkingStage, TokenLimits, ToolApprovalConfig, ToolApprovalDecision, ToolApprovalMode, ToolApprovalRequest, ToolCallMode, ToolCatalogEntry, ToolLoopCallbacks, ToolLoopOptions, ToolLoopResult, ToolMode, ToolPermission, ToolResultClearing, ToolRunContext, ToolSelectionStrategy, UsagePhase, VfsListener, VirtualFile, VirtualFileInfo, VirtualFileSystemOptions, WebLLMAppConfigLike, WebLLMModelOptions, WorkerLike, WorkerToParent };
|
|
2972
|
+
export { AgentTool, AgentToolSet, AttachmentsNotSupportedError, ContextWindowExceededError, DEFAULT_COMPACTION_THRESHOLD_RATIO, EgressError, FILES_STORE, FIND_TOOLS_NAME, FORGET_SKILL_TOOL, ImagesNotSupportedError, IndexedDBRunStore, IndexedDBStore, KEYS_STORE, MemoryCredentialStore, MemoryRunStore, MemorySkillStore, MemoryStore, PIPELINE_LIMITS, PipelineNodeError, PipelineValidationError, PlanSchema, PlanStepSchema, RUNS_STORE, ReplanSchema, SAVE_SKILL_TOOL, SECRETS_STORE, SESSIONS_STORE, SKILL_TOOL_NAMES, TOOL_APPROVAL_MODES, TOOL_SEARCH_WINDOW_SHARE, ToolBudgetError, ToolDeniedError, VaultCredentialStore, VaultOptions, VfsSkillStore, VirtualFileSystem, WEBLLM_DEFAULT_CONTEXT_WINDOW, WEB_FETCH_TOOL, attachmentKind, buildModelFromStage, bytesToBase64, checkEgressUrl, checkLimits, classifyAddress, compactHistory, compactSteps, compressHistory, contextOverflowOf, contextWindowOf, createAgent, createEgressTools, createFileTools, createFindToolsTool, createGuardedFetch, createLearning, createLogger, createPipeline, createPlan, createRunControl, createSkillTools, createSubagentTool, createToolResultClearer, createWebFetchTool, createWebLLMModel, decideReplan, decideToolPermission, decryptJSON, defaultPrompts, defineSkill, defineTool, directBrowserOk, dispatch, encryptJSON, messageTokens as estimateMessagesTokens, estimateTokens, executeStep, fileToolBindingOf, findSecret, fitCompactionToWindow, generate, generateStructured, getOrCreateVaultKey, hostMatches, htmlToText, isAttachmentRefusal, isDirectModel, isImageRefusal, isProviderSpec, isReadOnlyTool, isTextMime, isWebGPUAvailable, learnedPreamble, limitModelOutput, loadSkillFromUrl, looksLikeJson, markReadOnly, matchRule, mediaTypeOf, mergeProviderOptions, mimeFromPath, nodeResolver, normalizePath, normalizePipeline, normalizeSkillName, normalizeSteps, normalizeUsage, openAgentWebDB, parseExecutorResponse, parsePlainText, parsePlannerResponse, parseReplannerResponse, parseSkillMarkdown, preloadWebLLMModel, renderActiveSkills, renderCatalog, renderPipelineNodeInput, renderSearchCatalog, renderSkillIndex, replanWanted, resolveBudgets, resolveCaching, resolveCompaction, resolveConfig, resolveEgressPolicy, resolveModel, resolveResume, resolveStage, resolveThinking, runToolLoop, schemaHintOf, searchTools, selectToolMode, serveSubagentWorker, shouldReplan, splitBlocker, stream, supportsImages, supportsNativeTools, supportsPdf, supportsStructuredOutput, synthesizeAnswer, testPipelineCondition, thinkingFor, toFilePart, toImagePart, tokenize, toolCatalogOf, toolDefinitionTokens, toolRunContextOf, unloadWebLLMModel, validatePipeline, webLLMContextWindow, withRollingBreakpoint, withSystem, withWebLLMContextWindow };
|
|
2973
|
+
export type { Agent, AgentContext, AgentEvent, AgentEventHandler, AgentLogger, AgentLoggerSink, AgentWebDBOptions, AttachmentKind, BrowserAgentConfig, ClearedInfo, CompactOptions, CompactResult, CompactionConfig, CompressOptions, ContextStore, CredentialStore, EffectiveToolStrategy, EgressErrorCode, EncryptedBlob, ExecutorPromptContext, ExecutorResult, FileToolBinding, FileToolsOptions, GenerateOptions, GuardedFetch, IEgressPolicy, IPlan, IPlanStep, IResolvedEgressPolicy, ISandboxConfig, ISandboxError, ISandboxLimits, ISandboxResult, IStepResult, IToolCall, IUsage, IWebFetchOptions, IndexedDBRunStoreOptions, IndexedDBStoreOptions, Learning, LearningConfig, LimitBreach, LimitKind, LoadSkillOptions, LogLevel, MessageEndpoint, ModelInput, NodeResolverOptions, ParentToWorker, Phase, PhaseBudgets, Pipeline, PipelineCondition, PipelineDefinition, PipelineEdge, PipelineEvent, PipelineIssue, PipelineNode, PipelineNodeContext, PipelineNodeInput, PipelineNodeOutput, PipelineNodeRunner, PipelineNodeSource, PipelineOptions, PipelineResult, PipelineRoute, PipelineRunOptions, PipelineStop, PipelineTraceEntry, PipelineUsage, PipelineValidation, PlanShape, PlannerPromptContext, PlannerResult, PromptCachingSetting, PromptParts, Prompts, ProviderModelSpec, ProviderOptionsMap, ProviderType, ProxiedToolSpec, RawAction, ReplanDecision, ReplanMode, ReplanShape, ReplanTrigger, ReplannerPromptContext, ReplannerResult, ResolvedCaching, ResolvedCompaction, ResolvedConfig, ResolvedStage, ResolvedThinking, RunControl, RunFile, RunImage, RunOptions, RunPersistence, RunResult, RunSnapshot, RunStatus, RunStoreOptions, SandboxConfig, SandboxWorkerLike, SaveSkillInput, SearchToolsOptions, ServeSubagentOptions, Skill, SkillOrigin, SkillStore, StageInput, StageOverride, StoredMessage, SubagentInfo, SubagentProfile, SubagentToolOptions, SubagentWorkerConfig, SynthesizerPromptContext, ThinkingConfig, ThinkingLevel, ThinkingSetting, ThinkingStage, TokenLimits, ToolApprovalConfig, ToolApprovalDecision, ToolApprovalMode, ToolApprovalRequest, ToolCallMode, ToolCatalogEntry, ToolLoopCallbacks, ToolLoopOptions, ToolLoopResult, ToolMode, ToolPermission, ToolResultClearing, ToolRunContext, ToolSelectionStrategy, UsagePhase, VfsListener, VirtualFile, VirtualFileInfo, VirtualFileSystemOptions, WebLLMAppConfigLike, WebLLMModelOptions, WorkerLike, WorkerToParent };
|