@hachej/boring-agent 0.1.89 → 0.1.90

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.
Files changed (28) hide show
  1. package/dist/{chunk-GOM3VJOJ.js → chunk-4PKGVPJA.js} +8 -0
  2. package/dist/{chunk-I7UEASPG.js → chunk-5CYVBVP3.js} +4315 -9647
  3. package/dist/{chunk-M32FXCIN.js → chunk-BEFJNMKQ.js} +1 -1
  4. package/dist/{chunk-XPQEF32D.js → chunk-CFQQXJKK.js} +1 -1
  5. package/dist/{chunk-WZCTVT57.js → chunk-F7ZS27HE.js} +2 -94
  6. package/dist/{chunk-BDYXKHWY.js → chunk-JEDRQAR5.js} +1 -1
  7. package/dist/core/index.d.ts +5 -5
  8. package/dist/core/index.js +2 -2
  9. package/dist/{createHarness-CCQLHKUF.js → createHarness-UCCGMVQJ.js} +2 -2
  10. package/dist/front/index.d.ts +12 -3
  11. package/dist/front/index.js +62 -4
  12. package/dist/{harness-VvP0l5Mj.d.ts → harness-Rbkdpvse.d.ts} +2 -2
  13. package/dist/{piChatEvent-nmOBSNU9.d.ts → piChatEvent-CHgln6yx.d.ts} +13 -13
  14. package/dist/{piChatSessionService-DPjJ0g71.d.ts → piChatSessionService-DDKPOj4x.d.ts} +1 -1
  15. package/dist/{protocol-B_OQKfbI.d.ts → protocol-CDA4bcP9.d.ts} +2 -18
  16. package/dist/{sandbox-DthfJaOB.d.ts → sandbox-OEG_l9GE.d.ts} +1 -1
  17. package/dist/server/index.d.ts +164 -288
  18. package/dist/server/index.js +20 -51
  19. package/dist/server/worker/index.d.ts +9 -7
  20. package/dist/server/worker/index.js +18 -27
  21. package/dist/shared/index.d.ts +51 -27
  22. package/dist/shared/index.js +3 -3
  23. package/dist/{workspaceAgentDispatcher-CKEeNPjW.d.ts → workspaceAgentDispatcher-50Uzuxhs.d.ts} +4 -18
  24. package/docs/ERROR_CODES.md +8 -0
  25. package/docs/RISKS-MULTI-TAB.md +1 -1
  26. package/docs/runtime-provisioning.md +1 -1
  27. package/docs/runtime.md +9 -6
  28. package/package.json +5 -5
@@ -1,140 +1,20 @@
1
- import { W as WorkspaceRuntimeContext, S as Sandbox, a as Workspace, E as ExecOptions, b as ExecResult, c as WorkspaceChangeEvent } from '../sandbox-DthfJaOB.js';
2
- import { R as RemoteWorkerWorkspaceOp, a as RemoteWorkerWorkspaceResult, b as RemoteWorkerExecRequest } from '../protocol-B_OQKfbI.js';
3
- export { B as BwrapResourceLimits, C as CreateBwrapSandboxOptions, c as REMOTE_WORKER_PROVIDER, d as REMOTE_WORKER_RUNTIME_CWD, e as RemoteWorkerErrorPayload, f as RemoteWorkerExecResponse, g as RemoteWorkerFsEventEnvelope, W as WORKER_INTERNAL_TOKEN_HEADER, h as WORKER_REQUEST_ID_HEADER, i as WORKER_WORKSPACE_ID_HEADER, j as createBwrapSandbox } from '../protocol-B_OQKfbI.js';
4
- import { S as SandboxHandleStore, a as SandboxHandleRecord, F as FileSearch, C as CompiledAgentBundle, b as Sha256Digest, A as AgentDeployment, c as ShareEntryStore, P as PluginRestartWarning, W as WorkspaceAgentDispatcherContext, d as WorkspaceAgentDispatcher } from '../workspaceAgentDispatcher-CKEeNPjW.js';
5
- import { Sandbox as Sandbox$1 } from '@vercel/sandbox';
6
- import { T as TelemetrySink, s as ToolReadinessRequirement, t as AgentConfig, b as Agent, d as AgentActor, j as AgentEvent, u as AgentTool, v as AgentHarnessFactory } from '../harness-VvP0l5Mj.js';
7
- export { w as AgentHarnessFactoryInput } from '../harness-VvP0l5Mj.js';
8
- import { FastifyInstance, FastifyRequest, FastifyPluginAsync } from 'fastify';
9
- import { E as ErrorCode, l as SessionCtx, m as ChatModelSelection } from '../piChatEvent-nmOBSNU9.js';
1
+ import { F as FileSearch, C as CompiledAgentBundle, S as Sha256Digest, A as AgentDeployment, a as ShareEntryStore, P as PluginRestartWarning, W as WorkspaceAgentDispatcherContext, b as WorkspaceAgentDispatcher } from '../workspaceAgentDispatcher-50Uzuxhs.js';
2
+ import { W as Workspace, a as WorkspaceRuntimeContext, S as Sandbox, E as ExecOptions, b as ExecResult, c as WorkspaceChangeEvent } from '../sandbox-OEG_l9GE.js';
3
+ import { T as ToolReadinessRequirement, s as TelemetrySink, t as AgentConfig, b as Agent, u as AgentTool, d as AgentActor, j as AgentEvent, v as AgentHarnessFactory } from '../harness-Rbkdpvse.js';
4
+ export { w as AgentHarnessFactoryInput } from '../harness-Rbkdpvse.js';
5
+ import { RuntimeHostOperations } from '@hachej/boring-bash/agent';
6
+ import { CreateNodeWorkspaceOptions, BoringAgentRuntimePaths } from '@hachej/boring-sandbox/providers/node-workspace';
7
+ import { R as RemoteWorkerWorkspaceOp, a as RemoteWorkerWorkspaceResult, b as RemoteWorkerExecRequest } from '../protocol-CDA4bcP9.js';
8
+ export { c as REMOTE_WORKER_PROVIDER, d as REMOTE_WORKER_RUNTIME_CWD, e as RemoteWorkerErrorPayload, f as RemoteWorkerExecResponse, g as RemoteWorkerFsEventEnvelope, W as WORKER_INTERNAL_TOKEN_HEADER, h as WORKER_REQUEST_ID_HEADER, i as WORKER_WORKSPACE_ID_HEADER } from '../protocol-CDA4bcP9.js';
9
+ import { SandboxProviderV1, WorkspaceSandboxPairV1 } from '@hachej/boring-sandbox/shared';
10
+ import { E as ErrorCode, l as SessionCtx, m as ChatModelSelection } from '../piChatEvent-CHgln6yx.js';
10
11
  import { IncomingMessage, ServerResponse } from 'node:http';
11
12
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
13
+ import { FastifyRequest, FastifyInstance, FastifyPluginAsync } from 'fastify';
12
14
  import { PackageSource, ExtensionFactory, SettingsManager } from '@mariozechner/pi-coding-agent';
13
- import { a as AgentEffectAdmission } from '../piChatSessionService-DPjJ0g71.js';
15
+ import { a as AgentEffectAdmission } from '../piChatSessionService-DDKPOj4x.js';
14
16
  import 'zod';
15
17
 
16
- interface CreateDirectSandboxOptions {
17
- runtimeContext?: WorkspaceRuntimeContext;
18
- }
19
- declare function createDirectSandbox(opts?: CreateDirectSandboxOptions): Sandbox;
20
-
21
- interface FileHandleStoreOptions {
22
- storePath?: string;
23
- }
24
- declare class FileHandleStore implements SandboxHandleStore {
25
- private readonly storePath;
26
- constructor(opts?: FileHandleStoreOptions);
27
- get(workspaceId: string): Promise<SandboxHandleRecord | null>;
28
- put(record: SandboxHandleRecord): Promise<void>;
29
- delete(workspaceId: string): Promise<void>;
30
- list(): Promise<SandboxHandleRecord[]>;
31
- private readStore;
32
- private writeStore;
33
- }
34
-
35
- interface ResolveSandboxCreateParams {
36
- name?: string;
37
- persistent?: boolean;
38
- snapshotExpiration?: number;
39
- source?: {
40
- type: 'snapshot';
41
- snapshotId: string;
42
- } | {
43
- type: 'tarball';
44
- url: string;
45
- };
46
- }
47
- type VercelSandboxHandle = Sandbox$1 & {
48
- sandboxId?: string;
49
- name?: string;
50
- currentSnapshotId?: string;
51
- sourceSnapshotId?: string;
52
- };
53
- interface VercelSandboxClient {
54
- create(params?: ResolveSandboxCreateParams): Promise<VercelSandboxHandle>;
55
- get(params: {
56
- sandboxId?: string;
57
- name?: string;
58
- resume?: boolean;
59
- }): Promise<VercelSandboxHandle>;
60
- }
61
- interface SandboxLifecycleLogger {
62
- info?(message: string, metadata: Record<string, unknown>): void;
63
- warn?(message: string, metadata: Record<string, unknown>): void;
64
- }
65
- type ExpiredSandboxPolicy = 'recreate' | 'error';
66
- interface ResolveSandboxHandleOptions {
67
- tarballUrl?: string;
68
- maxIdleMs?: number;
69
- now?: () => number;
70
- logger?: SandboxLifecycleLogger;
71
- expiredSandboxPolicy?: ExpiredSandboxPolicy;
72
- }
73
- declare function resolveSandboxHandle(workspaceId: string, store: SandboxHandleStore, vercel: VercelSandboxClient, opts?: ResolveSandboxHandleOptions): Promise<VercelSandboxHandle>;
74
-
75
- interface VercelCommandResult {
76
- exitCode: number;
77
- stdout(opts?: {
78
- signal?: AbortSignal;
79
- }): Promise<string>;
80
- stderr(opts?: {
81
- signal?: AbortSignal;
82
- }): Promise<string>;
83
- }
84
- interface VercelBakeSandbox {
85
- runCommand(command: string, args?: string[], opts?: {
86
- signal?: AbortSignal;
87
- }): Promise<VercelCommandResult>;
88
- snapshot(opts?: {
89
- signal?: AbortSignal;
90
- }): Promise<{
91
- snapshotId: string;
92
- }>;
93
- stop?(opts?: {
94
- signal?: AbortSignal;
95
- }): Promise<void>;
96
- }
97
- interface VercelBakeClient {
98
- create(params?: {
99
- runtime?: string;
100
- }): Promise<VercelBakeSandbox>;
101
- }
102
- interface BakeLogger {
103
- info?: (...args: unknown[]) => void;
104
- warn?: (...args: unknown[]) => void;
105
- }
106
- type SnapshotBakeStatus = 'skipped' | 'cache-hit' | 'baked' | 'failed';
107
- type SnapshotBakeReason = 'snapshot-id-configured' | 'no-packages' | 'cache-hit' | 'baked' | 'bake-failed';
108
- interface SnapshotBakeResult {
109
- status: SnapshotBakeStatus;
110
- reason: SnapshotBakeReason;
111
- hash?: string;
112
- snapshotId?: string;
113
- error?: unknown;
114
- }
115
- interface SnapshotBakeOptions {
116
- client: VercelBakeClient;
117
- pythonPackages?: readonly string[];
118
- systemPackages?: readonly string[];
119
- setupCommands?: readonly string[];
120
- snapshotId?: string;
121
- runtime?: string;
122
- cachePath?: string;
123
- logger?: BakeLogger;
124
- now?: () => Date;
125
- }
126
- declare function buildPackageHash(input: {
127
- pythonPackages?: readonly string[];
128
- systemPackages?: readonly string[];
129
- }): string;
130
- declare function buildSnapshotRecipeHash(input: {
131
- runtime?: string;
132
- pythonPackages?: readonly string[];
133
- systemPackages?: readonly string[];
134
- setupCommands?: readonly string[];
135
- }): string;
136
- declare function bakeSnapshotIfNeeded(opts: SnapshotBakeOptions): Promise<SnapshotBakeResult>;
137
-
138
18
  /**
139
19
  * uv setup for Python-family runtimes (e.g. Vercel `python3.13`), which already
140
20
  * ship `pip` and usually `uv`. Verify-or-install via the on-PATH `uv`.
@@ -168,63 +48,88 @@ interface BuildDeploymentSnapshotRecipeOptions extends DeploymentSnapshotRecipe
168
48
  declare function buildDeploymentSnapshotRecipe(opts?: BuildDeploymentSnapshotRecipeOptions): DeploymentSnapshotRecipe;
169
49
  declare function prepareDeploymentSnapshot(provider: DeploymentSnapshotProvider, recipe: DeploymentSnapshotRecipe): Promise<DeploymentSnapshotResult>;
170
50
 
171
- interface VercelDeploymentSnapshotOptions {
172
- client: VercelBakeClient;
173
- snapshotId?: string;
174
- runtime?: string;
175
- cachePath?: string;
176
- logger?: BakeLogger;
177
- now?: () => Date;
178
- /**
179
- * Extra deploy-time setup commands baked into the reusable snapshot.
180
- * Use for runtime primitives such as uv or OS tools, not workspace content.
181
- */
182
- setupCommands?: readonly string[];
183
- pythonPackages?: readonly string[];
184
- systemPackages?: readonly string[];
185
- }
186
- declare function createVercelDeploymentSnapshotProvider(opts: Omit<VercelDeploymentSnapshotOptions, 'runtime' | 'setupCommands' | 'pythonPackages' | 'systemPackages'>): DeploymentSnapshotProvider;
187
- declare function prepareVercelDeploymentSnapshot(opts: VercelDeploymentSnapshotOptions): Promise<SnapshotBakeResult>;
51
+ declare function resolveWorkspaceRoot(defaultRoot?: string): string;
188
52
 
189
- interface CreateNodeWorkspaceOptions {
190
- runtimeContext?: WorkspaceRuntimeContext;
53
+ type ReadyState = 'provisioning' | 'ready' | 'degraded';
54
+ type CapabilityState = 'not-started' | 'preparing' | 'ready' | 'failed';
55
+ interface CapabilityReadinessDetail {
56
+ state: CapabilityState;
57
+ requirement?: ToolReadinessRequirement;
58
+ startedAt?: string;
59
+ completedAt?: string;
60
+ errorCode?: string;
61
+ causeCode?: string;
62
+ retryable?: boolean;
63
+ message?: string;
64
+ }
65
+ interface AgentCapabilityReadiness {
66
+ chat: CapabilityReadinessDetail;
67
+ workspace: CapabilityReadinessDetail;
68
+ runtimeDependencies: CapabilityReadinessDetail;
69
+ }
70
+ interface ReadyStatusEvent {
71
+ state: ReadyState;
72
+ sandboxReady: boolean;
73
+ harnessReady: boolean;
74
+ capabilities: AgentCapabilityReadiness;
75
+ message?: string;
76
+ timestamp: string;
77
+ }
78
+ interface ReadinessSnapshot {
79
+ sandboxReady: boolean;
80
+ harnessReady: boolean;
81
+ capabilities: AgentCapabilityReadiness;
82
+ degradedReason?: string;
83
+ }
84
+ type StatusHandler = (event: ReadyStatusEvent) => void;
85
+ declare class ReadyStatusTracker {
86
+ private _sandboxReady;
87
+ private _harnessReady;
88
+ private _degradedReason?;
89
+ private _capabilities;
90
+ private subscribers;
91
+ constructor(opts?: {
92
+ sandboxReady?: boolean;
93
+ harnessReady?: boolean;
94
+ capabilities?: Partial<AgentCapabilityReadiness>;
95
+ });
96
+ get state(): ReadyState;
97
+ isReady(): boolean;
98
+ getReadiness(): ReadinessSnapshot;
99
+ getCapabilities(): AgentCapabilityReadiness;
100
+ updateCapability(name: keyof AgentCapabilityReadiness, detail: CapabilityReadinessDetail): void;
101
+ updateRuntimeDependencies(detail: CapabilityReadinessDetail): void;
102
+ markSandboxReady(): void;
103
+ markHarnessReady(): void;
104
+ markDegraded(reason: string): void;
105
+ clearDegraded(): void;
106
+ subscribe(handler: StatusHandler): () => void;
107
+ private emit;
108
+ private snapshot;
191
109
  }
192
- declare function createNodeWorkspace(root: string, opts?: CreateNodeWorkspaceOptions): Workspace;
193
110
 
194
111
  /**
195
- * Validate and resolve a user-provided relative path under workspaceRoot.
196
- */
197
- declare function validatePath(workspaceRoot: string, relPath: string): string;
198
- /**
199
- * Resolve symlinks and ensure candidate path remains under workspaceRoot.
112
+ * Host-owned values used by Agent's provider-neutral runtime composition.
113
+ *
114
+ * The concrete implementation lives outside packages/agent/src so Agent can
115
+ * consume an injected Workspace + Sandbox pair without importing provider
116
+ * runtime values.
200
117
  */
201
- declare function assertRealPathWithinWorkspace(workspaceRoot: string, absPath: string): Promise<void>;
202
-
203
- declare function resolveWorkspaceRoot(defaultRoot?: string): string;
204
-
205
- interface BoringAgentRuntimePaths {
206
- /** Runtime-visible workspace root. This is BORING_AGENT_WORKSPACE_ROOT. */
207
- workspaceRoot: string;
208
- agentDir: string;
209
- node: string;
210
- nodeModules: string;
211
- nodeBin: string;
212
- venv: string;
213
- venvBin: string;
214
- venvPython: string;
215
- sdk: string;
216
- uvHome: string;
217
- uvBin: string;
218
- skills: string;
219
- cache: string;
220
- nodeCache: string;
221
- uvCache: string;
222
- pipCache: string;
223
- tmp: string;
224
- }
225
- declare function getBoringAgentRuntimePaths(runtimeWorkspaceRoot: string): BoringAgentRuntimePaths;
226
- declare function getBoringAgentPathEntries(paths: BoringAgentRuntimePaths): string[];
227
- declare function getBoringAgentRuntimeEnv(paths: BoringAgentRuntimePaths, adapterCacheRoot?: string): Record<string, string>;
118
+ interface AgentRuntimeHostOperations extends RuntimeHostOperations {
119
+ createNodeWorkspace(root: string, options?: CreateNodeWorkspaceOptions): Workspace;
120
+ getNodeWorkspaceHostRoot(workspace: Workspace): string | undefined;
121
+ getBoringAgentRuntimePaths(workspaceRoot: string): BoringAgentRuntimePaths;
122
+ getBoringAgentRuntimeEnv(paths: BoringAgentRuntimePaths, cacheRoot?: string): Record<string, string>;
123
+ getBoringAgentPathEntries(paths: BoringAgentRuntimePaths): string[];
124
+ readonly runtimeLayout: Readonly<{
125
+ agentDir: string;
126
+ runtimeDirNames: readonly string[];
127
+ gitignoreContent: string;
128
+ }>;
129
+ validatePath(root: string, requestedPath: string): string;
130
+ assertRealPathWithinWorkspace(root: string, targetPath: string): Promise<void>;
131
+ isIgnoredDirName(name: string): boolean;
132
+ }
228
133
 
229
134
  interface ProvisioningLogger {
230
135
  info?(message: string, fields?: Record<string, unknown>): void;
@@ -313,6 +218,7 @@ interface ProvisionWorkspaceRuntimeOptions {
313
218
  }>;
314
219
  adapter: WorkspaceProvisioningAdapter;
315
220
  runtimeLayout: BoringAgentRuntimePaths;
221
+ runtimeHost: AgentRuntimeHostOperations;
316
222
  logger?: ProvisioningLogger;
317
223
  telemetry?: TelemetrySink;
318
224
  telemetryContext?: ProvisioningTelemetryContext;
@@ -320,64 +226,6 @@ interface ProvisionWorkspaceRuntimeOptions {
320
226
 
321
227
  declare function provisionWorkspaceRuntime(opts: ProvisionWorkspaceRuntimeOptions): Promise<WorkspaceProvisioningResult>;
322
228
 
323
- type ReadyState = 'provisioning' | 'ready' | 'degraded';
324
- type CapabilityState = 'not-started' | 'preparing' | 'ready' | 'failed';
325
- interface CapabilityReadinessDetail {
326
- state: CapabilityState;
327
- requirement?: ToolReadinessRequirement;
328
- startedAt?: string;
329
- completedAt?: string;
330
- errorCode?: string;
331
- causeCode?: string;
332
- retryable?: boolean;
333
- message?: string;
334
- }
335
- interface AgentCapabilityReadiness {
336
- chat: CapabilityReadinessDetail;
337
- workspace: CapabilityReadinessDetail;
338
- runtimeDependencies: CapabilityReadinessDetail;
339
- }
340
- interface ReadyStatusEvent {
341
- state: ReadyState;
342
- sandboxReady: boolean;
343
- harnessReady: boolean;
344
- capabilities: AgentCapabilityReadiness;
345
- message?: string;
346
- timestamp: string;
347
- }
348
- interface ReadinessSnapshot {
349
- sandboxReady: boolean;
350
- harnessReady: boolean;
351
- capabilities: AgentCapabilityReadiness;
352
- degradedReason?: string;
353
- }
354
- type StatusHandler = (event: ReadyStatusEvent) => void;
355
- declare class ReadyStatusTracker {
356
- private _sandboxReady;
357
- private _harnessReady;
358
- private _degradedReason?;
359
- private _capabilities;
360
- private subscribers;
361
- constructor(opts?: {
362
- sandboxReady?: boolean;
363
- harnessReady?: boolean;
364
- capabilities?: Partial<AgentCapabilityReadiness>;
365
- });
366
- get state(): ReadyState;
367
- isReady(): boolean;
368
- getReadiness(): ReadinessSnapshot;
369
- getCapabilities(): AgentCapabilityReadiness;
370
- updateCapability(name: keyof AgentCapabilityReadiness, detail: CapabilityReadinessDetail): void;
371
- updateRuntimeDependencies(detail: CapabilityReadinessDetail): void;
372
- markSandboxReady(): void;
373
- markHarnessReady(): void;
374
- markDegraded(reason: string): void;
375
- clearDegraded(): void;
376
- subscribe(handler: StatusHandler): () => void;
377
- private emit;
378
- private snapshot;
379
- }
380
-
381
229
  type BuiltinRuntimeModeId = 'direct' | 'local' | 'vercel-sandbox';
382
230
  type RuntimeModeId = BuiltinRuntimeModeId | (string & {});
383
231
  interface RuntimeModeReadinessHooks {
@@ -423,6 +271,7 @@ type RuntimeFilesystemStrategy = {
423
271
  };
424
272
  interface RuntimeModeAdapter {
425
273
  readonly id: RuntimeModeId;
274
+ readonly runtimeHost?: AgentRuntimeHostOperations;
426
275
  /**
427
276
  * Declares whether the workspace files are strongly available on the host
428
277
  * path before create() runs. Composition layers use this to decide whether
@@ -432,11 +281,10 @@ interface RuntimeModeAdapter {
432
281
  readonly readiness?: RuntimeModeReadinessHooks;
433
282
  readonly cachedBindingHealthCheck?: RuntimeCachedBindingHealthCheck;
434
283
  create(ctx: ModeContext): Promise<RuntimeBundle>;
435
- createProvisioningAdapter?(runtimeLayout: BoringAgentRuntimePaths, ctx?: ModeContext): WorkspaceProvisioningAdapter;
436
284
  getRuntimeLayoutRoot?(ctx: ModeContext): string;
437
285
  evictCachedRuntime?(ctx: {
438
286
  workspaceId: string;
439
- }): void;
287
+ }): void | Promise<void>;
440
288
  dispose?(): Promise<void>;
441
289
  }
442
290
  interface ModeContext {
@@ -544,6 +392,8 @@ interface RuntimeBundle {
544
392
  workspace: Workspace;
545
393
  sandbox: Sandbox;
546
394
  fileSearch: FileSearch;
395
+ /** Host-owned provider utilities injected at the application boundary. */
396
+ runtimeHost?: AgentRuntimeHostOperations;
547
397
  /** Optional per-execution runtime env provider for local/direct operations that do not call Sandbox.exec. */
548
398
  getRuntimeEnv?: () => Promise<Record<string, string>>;
549
399
  /** Runtime-owned bash execution strategy, consumed by the agent bash tool builder. */
@@ -552,6 +402,10 @@ interface RuntimeBundle {
552
402
  filesystem?: RuntimeFilesystemStrategy;
553
403
  /** Optional filesystem bindings prepared for this runtime/session. */
554
404
  filesystemBindings?: RuntimeFilesystemBinding[];
405
+ /** Provisioning operations derived from this bundle's acquired Workspace + Sandbox pair. */
406
+ provisioningAdapter?: WorkspaceProvisioningAdapter;
407
+ /** Idempotently releases the acquired Workspace + Sandbox pair. */
408
+ disposeRuntime?: () => Promise<void>;
555
409
  }
556
410
 
557
411
  interface RemoteWorkerClientOptions {
@@ -611,13 +465,6 @@ declare function createRemoteWorkerWorkspace(client: RemoteWorkerClient): Worksp
611
465
 
612
466
  declare function createRemoteWorkerSandbox(client: RemoteWorkerClient): Sandbox;
613
467
 
614
- declare function fileRoutes(app: FastifyInstance, opts: {
615
- workspace?: Workspace;
616
- getWorkspace?: (request: FastifyRequest) => Workspace | Promise<Workspace>;
617
- filesystemBindings?: RuntimeFilesystemBinding[];
618
- getFilesystemBindings?: (request: FastifyRequest) => RuntimeFilesystemBinding[] | undefined | Promise<RuntimeFilesystemBinding[] | undefined>;
619
- }, done: (err?: Error) => void): void;
620
-
621
468
  interface RuntimeTemplateContribution {
622
469
  id: string;
623
470
  path: string | URL;
@@ -660,15 +507,6 @@ interface RuntimeWorkspaceProvisioningResult {
660
507
  }
661
508
  declare function provisionRuntimeWorkspace({ workspaceRoot, contributions, force, }: ProvisionRuntimeWorkspaceOptions): Promise<RuntimeWorkspaceProvisioningResult>;
662
509
 
663
- declare const VERCEL_SANDBOX_WORKSPACE_ROOT = "/workspace";
664
- interface VercelSandboxWorkspace extends Workspace {
665
- invalidateMetadataCache(): void;
666
- }
667
- interface VercelSandboxWorkspaceOptions {
668
- onMutation?: () => void;
669
- }
670
- declare function createVercelSandboxWorkspace(sandbox: Sandbox$1, workspaceOpts?: VercelSandboxWorkspaceOptions): VercelSandboxWorkspace;
671
-
672
510
  type ProvisioningArtifactKind = 'node' | 'python';
673
511
  /** What a per-mode packer receives to produce one artifact. `id`/`fingerprint`
674
512
  * are passed through (not used by the default packer, but part of the public
@@ -681,27 +519,46 @@ interface ProvisioningArtifactRequest {
681
519
  outputPath: string;
682
520
  }
683
521
 
684
- declare const VERCEL_PROVISIONING_CACHE_ROOT = "/tmp/boring-agent-cache";
685
- interface CreateVercelProvisioningAdapterOptions {
686
- runtimeLayout: BoringAgentRuntimePaths;
687
- workspaceFs: WorkspaceProvisioningAdapter['workspaceFs'];
688
- exec(command: string, args: string[], opts?: {
689
- cwd?: string;
690
- env?: Record<string, string>;
691
- timeoutMs?: number;
692
- }): Promise<WorkspaceProvisioningExecResult | void>;
693
- prepareArtifact(request: ProvisioningArtifactRequest): Promise<void>;
694
- cacheRoot?: string;
695
- }
696
- declare function createVercelProvisioningAdapter(options: CreateVercelProvisioningAdapterOptions): WorkspaceProvisioningAdapter;
697
-
698
522
  declare function hasBwrap(): boolean;
699
523
  declare function autoDetectMode(): RuntimeModeId;
700
524
  interface ResolveModeOptions {
701
- sandboxHandleStore?: SandboxHandleStore;
525
+ adapters?: Readonly<Record<BuiltinRuntimeModeId, RuntimeModeAdapter>>;
702
526
  }
703
527
  declare function resolveMode(mode?: RuntimeModeId, opts?: ResolveModeOptions): RuntimeModeAdapter;
704
528
 
529
+ declare function createDirectModeAdapter(options: {
530
+ provider: SandboxProviderV1;
531
+ runtimeHost: AgentRuntimeHostOperations;
532
+ }): RuntimeModeAdapter;
533
+
534
+ declare function createLocalModeAdapter(options: {
535
+ provider: SandboxProviderV1;
536
+ runtimeHost: AgentRuntimeHostOperations;
537
+ }): RuntimeModeAdapter;
538
+
539
+ declare function createVercelSandboxModeAdapter(options: {
540
+ provider: SandboxProviderV1;
541
+ runtimeHost: AgentRuntimeHostOperations;
542
+ remoteRoot: string;
543
+ workspaceRoot: string;
544
+ }): RuntimeModeAdapter;
545
+
546
+ interface ProviderRuntimeModeAdapterOptions {
547
+ id: 'direct' | 'local' | 'vercel-sandbox';
548
+ provider: SandboxProviderV1;
549
+ runtimeHost: AgentRuntimeHostOperations;
550
+ workspaceFsCapability: 'strong' | 'best-effort';
551
+ bash: RuntimeBashStrategy;
552
+ filesystem: RuntimeFilesystemStrategy;
553
+ storageRoot?: (context: ModeContext) => string | undefined;
554
+ preflight?: (context: ModeContext) => void | Promise<void>;
555
+ prepare?: (context: ModeContext) => Promise<void>;
556
+ provisioningAdapter?: (context: ModeContext, pair: WorkspaceSandboxPairV1) => WorkspaceProvisioningAdapter | undefined;
557
+ healthCheckIntervalMs?: number;
558
+ readiness?: RuntimeModeAdapter['readiness'];
559
+ }
560
+ declare function createProviderRuntimeModeAdapter(options: ProviderRuntimeModeAdapterOptions): RuntimeModeAdapter;
561
+
705
562
  declare function createAgent(config: AgentConfig): Agent;
706
563
 
707
564
  type AgentDirectoryCompilerErrorCode = 'AGENT_DIRECTORY_NOT_FOUND' | 'AGENT_DIRECTORY_NOT_DIRECTORY' | 'AGENT_MANIFEST_NOT_FOUND' | 'AGENT_MANIFEST_NOT_FILE' | 'AGENT_MANIFEST_INVALID_UTF8' | 'AGENT_MANIFEST_INVALID_JSON' | 'AGENT_ASSET_NOT_FOUND' | 'AGENT_ASSET_NOT_FILE' | 'AGENT_ASSET_INVALID_UTF8' | 'AGENT_PATH_SYMLINK_ESCAPE' | 'AGENT_PATH_CHANGED_DURING_READ' | 'AGENT_DIRECTORY_IO_FAILED';
@@ -720,6 +577,33 @@ declare class AgentDirectoryCompilerError extends Error {
720
577
  }
721
578
  declare function compileAgentDirectory(directory: string): Promise<CompiledAgentBundle>;
722
579
 
580
+ type AuthoredAgentMaterializationErrorCode = Extract<ErrorCode, 'AUTHORED_AGENT_ID_INVALID' | 'AUTHORED_AGENT_TYPE_MISMATCH' | 'AUTHORED_AGENT_CATALOG_REQUIRED' | 'AUTHORED_AGENT_CATALOG_INVALID' | 'AUTHORED_AGENT_REFERENCE_UNKNOWN' | 'AUTHORED_AGENT_REFERENCE_UNSUPPORTED' | 'AUTHORED_AGENT_TOOL_INVALID' | 'AUTHORED_AGENT_TOOL_COLLISION'>;
581
+ type MaterializedAgentSourceV1 = Readonly<{
582
+ schemaVersion: 1;
583
+ agentTypeId: string;
584
+ version: string;
585
+ label?: string;
586
+ instructions: string;
587
+ tools: readonly AgentTool[];
588
+ declaredToolRefs: readonly string[];
589
+ }>;
590
+ type AuthoredAgentToolCatalog = ReadonlyMap<string, AgentTool>;
591
+ interface MaterializeAgentDirectoryInput {
592
+ directory: string;
593
+ expectedAgentTypeId?: string;
594
+ toolCatalog?: AuthoredAgentToolCatalog;
595
+ }
596
+ declare class AuthoredAgentMaterializationError extends Error {
597
+ readonly code: AuthoredAgentMaterializationErrorCode;
598
+ readonly field?: string;
599
+ constructor(input: {
600
+ code: AuthoredAgentMaterializationErrorCode;
601
+ field?: string;
602
+ message: string;
603
+ });
604
+ }
605
+ declare function materializeAgentDirectory(input: MaterializeAgentDirectoryInput): Promise<MaterializedAgentSourceV1>;
606
+
723
607
  interface ResolvedAgentDigestInput {
724
608
  readonly workspaceId: string;
725
609
  readonly defaultDeploymentId: string;
@@ -1142,6 +1026,8 @@ interface CreateAgentAppOptions {
1142
1026
  mode?: RuntimeModeId;
1143
1027
  /** Supply a custom runtime adapter to plug in non-built-in sandbox/workspace modes. */
1144
1028
  runtimeModeAdapter?: RuntimeModeAdapter;
1029
+ /** Provider/runtime values supplied by the embedding host. */
1030
+ runtimeHost?: AgentRuntimeHostOperations;
1145
1031
  authToken?: string;
1146
1032
  version?: string;
1147
1033
  logger?: boolean;
@@ -1295,6 +1181,8 @@ interface RegisterAgentRoutesOptions {
1295
1181
  mode?: RuntimeModeId;
1296
1182
  /** Supply a custom runtime adapter to plug in non-built-in sandbox/workspace modes. */
1297
1183
  runtimeModeAdapter?: RuntimeModeAdapter;
1184
+ /** Provider/runtime values supplied by the embedding host. */
1185
+ runtimeHost?: AgentRuntimeHostOperations;
1298
1186
  version?: string;
1299
1187
  extraTools?: AgentTool[];
1300
1188
  getExtraTools?: (ctx: {
@@ -1373,7 +1261,6 @@ interface RegisterAgentRoutesOptions {
1373
1261
  userId?: string;
1374
1262
  }) => string | undefined | Promise<string | undefined>;
1375
1263
  registerHealthRoute?: boolean;
1376
- sandboxHandleStore?: SandboxHandleStore;
1377
1264
  /**
1378
1265
  * Optional Lane W share-entry store (AR1-002/AR1-003, same-workspace
1379
1266
  * shareable links, `docs/issues/391/runtime-refactor/work/
@@ -1437,15 +1324,4 @@ interface RegisterAgentRoutesOptions {
1437
1324
  */
1438
1325
  declare const registerAgentRoutes: FastifyPluginAsync<RegisterAgentRoutesOptions>;
1439
1326
 
1440
- interface LogFields {
1441
- [key: string]: unknown;
1442
- }
1443
- interface Logger {
1444
- debug(msg: string, fields?: LogFields): void;
1445
- info(msg: string, fields?: LogFields): void;
1446
- warn(msg: string, fields?: LogFields): void;
1447
- error(msg: string, fields?: LogFields): void;
1448
- }
1449
- declare function createLogger(prefix: string): Logger;
1450
-
1451
- export { AgentConfig, AgentDirectoryCompilerError, type AgentDirectoryCompilerErrorCode, type AgentDirectoryCompilerPublicErrorCode, AgentHarnessFactory, type AgentMeteringSink, type BoringAgentRuntimePaths, type BuiltinRuntimeModeId, type CreateAgentAppOptions, type CreateVercelProvisioningAdapterOptions, type DeploymentSnapshotProvider, type DeploymentSnapshotRecipe, type DeploymentSnapshotResult, type DeploymentSnapshotStatus, FileHandleStore, type LogFields, type Logger, MANAGED_AGENT_MCP_DELIVERY_RULE, MANAGED_AGENT_MCP_ORIGIN_SURFACE, type ManagedAgentArtifact, type ManagedAgentArtifactCandidate, type ManagedAgentArtifactRef, type ManagedAgentBoundRunnerWorkspace, type ManagedAgentCollectArtifactsInput, type ManagedAgentDelegateInput, type ManagedAgentDelegateProgress, type ManagedAgentDelegateRequestContext, type ManagedAgentDelegateResult, type ManagedAgentDelegateRunInput, type ManagedAgentDelegateRunner, type ManagedAgentDelegateStatus, type ManagedAgentDelegateStatusResult, ManagedAgentMcpDelegateController, type ManagedAgentMcpDelegateOptions, ManagedAgentMcpError, type ManagedAgentMcpHttpHandlerOptions, type ManagedAgentMcpServerOptions, type ManagedAgentSafeError, type ManagedAgentWorkspaceResolutionInput, type MeteringErrorLogger, type MeteringReleaseInput, type MeteringReleaseReason, type MeteringReservationResult, type MeteringReserveInput, type MeteringRunKind, type MeteringRunScope, type MeteringRunStatus, type MeteringSettleInput, type MeteringUsage, type MeteringUsageInput, type ModeContext, PI_PACKAGE_RESOURCE_FILTERS, type PiExtensionFactory, type PiHarnessOptions, type PiPackageSource, type PluginSkillSource, type ProvisionRuntimeWorkspaceOptions, type ProvisionWorkspaceRuntimeOptions, type ProvisioningArtifactRequest, type RegisterAgentRoutesOptions, RemoteWorkerClient, RemoteWorkerClientError, type RemoteWorkerClientOptions, RemoteWorkerExecRequest, type RemoteWorkerModeAdapterOptions, RemoteWorkerWorkspaceOp, RemoteWorkerWorkspaceResult, type ResolvedAgent, type ResolvedAgentDigestInput, type RuntimeBundle, type RuntimeEnvContribution, type RuntimeEnvContributionContext, type RuntimeFilesystemBinding, type RuntimeFilesystemBindingOperations, type RuntimeModeAdapter, type RuntimeModeId, type RuntimeNodePackageSpec$1 as RuntimeNodePackageSpec, type RuntimeProvisioningContribution$1 as RuntimeProvisioningContribution, type RuntimePythonSpec$1 as RuntimePythonSpec, type RuntimeTemplateContribution$1 as RuntimeTemplateContribution, type RuntimeWorkspaceProvisioningResult, type ShareEntryMcpResourceOptions, type SnapshotBakeOptions, type SnapshotBakeResult, UV_SETUP_COMMANDS, VERCEL_PROVISIONING_CACHE_ROOT, VERCEL_SANDBOX_WORKSPACE_ROOT, UV_SETUP_COMMANDS as VERCEL_UV_SETUP_COMMANDS, type VercelBakeClient, type VercelBakeSandbox, type VercelDeploymentSnapshotOptions, type WorkspaceAgentDispatcherBinding, type WorkspaceAgentDispatcherResolveOptions, type WorkspaceAgentDispatcherResolver, type WorkspaceProvisioningAdapter, type WorkspaceProvisioningExecResult, type WorkspaceProvisioningResult, applyCspHeaders, assertRealPathWithinWorkspace, autoDetectMode, bakeSnapshotIfNeeded, buildDeploymentSnapshotRecipe, buildPackageHash, buildSnapshotRecipeHash, compactPiPackages, compileAgentDirectory, constantTimeTokenEqual, createAgent, createAgentApp, createDirectSandbox, createLogger, createManagedAgentMcpDelegateController, createManagedAgentMcpHttpHandler, createManagedAgentMcpServer, createNodeWorkspace, createRemoteWorkerModeAdapter, createRemoteWorkerSandbox, createRemoteWorkerWorkspace, createResolvedAgentDigest, createResourceSettingsManager, createVercelDeploymentSnapshotProvider, createVercelProvisioningAdapter, createVercelSandboxWorkspace, decodeBytesFromWorker, encodeBytesForWorker, fileRoutes, getBoringAgentPathEntries, getBoringAgentRuntimeEnv, getBoringAgentRuntimePaths, hasBwrap, mergePiPackageSources, normalizeMeteringUsage, piPackageSourceKey, prepareDeploymentSnapshot, prepareVercelDeploymentSnapshot, provisionRuntimeWorkspace, provisionWorkspaceRuntime, registerAgentRoutes, registerShareEntryResources, resolveAgentDeployment, resolveMode, resolveSandboxHandle, resolveWorkspaceRoot, shareResourceUri, validatePath };
1327
+ export { AgentConfig, AgentDirectoryCompilerError, type AgentDirectoryCompilerErrorCode, type AgentDirectoryCompilerPublicErrorCode, AgentHarnessFactory, type AgentMeteringSink, type AgentRuntimeHostOperations, AuthoredAgentMaterializationError, type AuthoredAgentMaterializationErrorCode, type AuthoredAgentToolCatalog, type BuiltinRuntimeModeId, type CreateAgentAppOptions, type DeploymentSnapshotProvider, type DeploymentSnapshotRecipe, type DeploymentSnapshotResult, type DeploymentSnapshotStatus, MANAGED_AGENT_MCP_DELIVERY_RULE, MANAGED_AGENT_MCP_ORIGIN_SURFACE, type ManagedAgentArtifact, type ManagedAgentArtifactCandidate, type ManagedAgentArtifactRef, type ManagedAgentBoundRunnerWorkspace, type ManagedAgentCollectArtifactsInput, type ManagedAgentDelegateInput, type ManagedAgentDelegateProgress, type ManagedAgentDelegateRequestContext, type ManagedAgentDelegateResult, type ManagedAgentDelegateRunInput, type ManagedAgentDelegateRunner, type ManagedAgentDelegateStatus, type ManagedAgentDelegateStatusResult, ManagedAgentMcpDelegateController, type ManagedAgentMcpDelegateOptions, ManagedAgentMcpError, type ManagedAgentMcpHttpHandlerOptions, type ManagedAgentMcpServerOptions, type ManagedAgentSafeError, type ManagedAgentWorkspaceResolutionInput, type MaterializeAgentDirectoryInput, type MaterializedAgentSourceV1, type MeteringErrorLogger, type MeteringReleaseInput, type MeteringReleaseReason, type MeteringReservationResult, type MeteringReserveInput, type MeteringRunKind, type MeteringRunScope, type MeteringRunStatus, type MeteringSettleInput, type MeteringUsage, type MeteringUsageInput, type ModeContext, PI_PACKAGE_RESOURCE_FILTERS, type PiExtensionFactory, type PiHarnessOptions, type PiPackageSource, type PluginSkillSource, type ProvisionRuntimeWorkspaceOptions, type ProvisionWorkspaceRuntimeOptions, type ProvisioningArtifactRequest, type RegisterAgentRoutesOptions, RemoteWorkerClient, RemoteWorkerClientError, type RemoteWorkerClientOptions, RemoteWorkerExecRequest, type RemoteWorkerModeAdapterOptions, RemoteWorkerWorkspaceOp, RemoteWorkerWorkspaceResult, type ResolvedAgent, type ResolvedAgentDigestInput, type RuntimeBundle, type RuntimeEnvContribution, type RuntimeEnvContributionContext, type RuntimeFilesystemBinding, type RuntimeFilesystemBindingOperations, type RuntimeModeAdapter, type RuntimeModeId, type RuntimeNodePackageSpec$1 as RuntimeNodePackageSpec, type RuntimeProvisioningContribution$1 as RuntimeProvisioningContribution, type RuntimePythonSpec$1 as RuntimePythonSpec, type RuntimeTemplateContribution$1 as RuntimeTemplateContribution, type RuntimeWorkspaceProvisioningResult, type ShareEntryMcpResourceOptions, UV_SETUP_COMMANDS, type WorkspaceAgentDispatcherBinding, type WorkspaceAgentDispatcherResolveOptions, type WorkspaceAgentDispatcherResolver, type WorkspaceProvisioningAdapter, type WorkspaceProvisioningExecResult, type WorkspaceProvisioningResult, applyCspHeaders, autoDetectMode, buildDeploymentSnapshotRecipe, compactPiPackages, compileAgentDirectory, constantTimeTokenEqual, createAgent, createAgentApp, createDirectModeAdapter, createLocalModeAdapter, createManagedAgentMcpDelegateController, createManagedAgentMcpHttpHandler, createManagedAgentMcpServer, createProviderRuntimeModeAdapter, createRemoteWorkerModeAdapter, createRemoteWorkerSandbox, createRemoteWorkerWorkspace, createResolvedAgentDigest, createResourceSettingsManager, createVercelSandboxModeAdapter, decodeBytesFromWorker, encodeBytesForWorker, hasBwrap, materializeAgentDirectory, mergePiPackageSources, normalizeMeteringUsage, piPackageSourceKey, prepareDeploymentSnapshot, provisionRuntimeWorkspace, provisionWorkspaceRuntime, registerAgentRoutes, registerShareEntryResources, resolveAgentDeployment, resolveMode, resolveWorkspaceRoot, shareResourceUri };