@hachej/boring-agent 0.1.89 → 0.1.91

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 (39) hide show
  1. package/dist/{chunk-GOM3VJOJ.js → chunk-2GBHYJVC.js} +31 -1
  2. package/dist/{chunk-I7UEASPG.js → chunk-BHH5NH7P.js} +5534 -8253
  3. package/dist/{chunk-M32FXCIN.js → chunk-CJ2BW2W2.js} +23 -8
  4. package/dist/{chunk-WZCTVT57.js → chunk-IWBC6SF7.js} +94 -112
  5. package/dist/chunk-NITBKFG6.js +1246 -0
  6. package/dist/{chunk-BDYXKHWY.js → chunk-PZC76CIA.js} +7 -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-PMYRKDE4.js} +2 -2
  10. package/dist/errors-BEmw9HMp.d.ts +200 -0
  11. package/dist/front/index.d.ts +30 -5
  12. package/dist/front/index.js +230 -44
  13. package/dist/{harness-VvP0l5Mj.d.ts → harness-Bt_GMNYR.d.ts} +2 -2
  14. package/dist/{workspaceAgentDispatcher-CKEeNPjW.d.ts → lease-2aXepSBL.d.ts} +254 -59
  15. package/dist/{protocol-B_OQKfbI.d.ts → middleware-CzW8n7B7.d.ts} +20 -18
  16. package/dist/piChatEvent-DBO3M5lu.d.ts +367 -0
  17. package/dist/{piChatSessionService-DPjJ0g71.d.ts → piChatSessionService-BaaVWke7.d.ts} +5 -1
  18. package/dist/{sandbox-DthfJaOB.d.ts → sandbox-DAD8cWQR.d.ts} +14 -1
  19. package/dist/server/agent-host/testing/gatewayConformance.d.ts +41 -0
  20. package/dist/server/agent-host/testing/gatewayConformance.js +465 -0
  21. package/dist/server/index.d.ts +507 -708
  22. package/dist/server/index.js +53 -50
  23. package/dist/server/worker/index.d.ts +9 -7
  24. package/dist/server/worker/index.js +19 -28
  25. package/dist/shared/index.d.ts +119 -27
  26. package/dist/shared/index.js +65 -282
  27. package/dist/types-jcMapYr9.d.ts +759 -0
  28. package/docs/ACCESSIBILITY.md +4 -5
  29. package/docs/API.md +3 -0
  30. package/docs/AUTHORING.md +68 -0
  31. package/docs/ERROR_CODES.md +29 -0
  32. package/docs/README.md +1 -0
  33. package/docs/RISKS-MULTI-TAB.md +1 -1
  34. package/docs/runtime-provisioning.md +1 -1
  35. package/docs/runtime.md +9 -6
  36. package/package.json +18 -9
  37. package/dist/chunk-DGRKMMXO.js +0 -8
  38. package/dist/chunk-XPQEF32D.js +0 -385
  39. package/dist/piChatEvent-nmOBSNU9.d.ts +0 -367
@@ -1,139 +1,24 @@
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 { P as ProvisionWorkspaceRuntimeOptions, W as WorkspaceProvisioningResult, R as RuntimeModeAdapter, a as RuntimeModeId, B as BuiltinRuntimeModeId, b as AgentRuntimeHostOperations, c as RuntimeBashStrategy, d as RuntimeFilesystemStrategy, M as ModeContext, e as WorkspaceProvisioningAdapter, f as RuntimeBundle, g as PiHarnessOptions, h as AgentMeteringSink, i as RuntimeFilesystemBinding, j as MeteringErrorLogger, k as ReadyStatusTracker, l as ResolvedAgentRuntimeScope, C as CreateAgentHostOptions, m as CompiledAgentHostAgentSpec, n as AgentRequestLedger, o as AgentEffectAdmission, p as AgentRequestKey, q as CreatedAgentHost, r as AgentFleetCompiler, A as AgentGatewayEffect, s as AgentRequestTarget, t as AgentRequestLedgerRecord, u as AgentRequestFailure, v as AgentHostLegacyRoutePolicy } from '../types-jcMapYr9.js';
2
+ export { w as AgentHostAddressedHttpProjectionOptions, x as AgentHostAgentSpec, y as AgentHostDescription, z as AgentHostHandle, D as AgentHostHttpProjectionOptions, E as AgentHostLegacyHttpProjectionOptions, F as AgentHostLegacyProjectionComposition, G as AgentHostLegacyProjectionLifecycle, H as AgentHostLegacyProjectionRuntime, I as AgentHostLegacyRoutePolicyMountInput, J as ConfiguredAgentHostAgentSpec, L as LegacyDefaultAgentHostSpec, K as MeteringReleaseInput, N as MeteringReleaseReason, O as MeteringReservationResult, Q as MeteringReserveInput, S as MeteringRunKind, T as MeteringRunScope, U as MeteringRunStatus, V as MeteringSettleInput, X as MeteringUsage, Y as MeteringUsageInput, Z as PI_PACKAGE_RESOURCE_FILTERS, _ as PiExtensionFactory, $ as PiPackageSource, a0 as PluginSkillSource, a1 as ResolvedEnvironmentScope, a2 as RuntimeFilesystemBindingOperations, a3 as RuntimeNodePackageSpec, a4 as RuntimeProvisioningContribution, a5 as RuntimePythonSpec, a6 as RuntimeTemplateContribution, a7 as WorkspaceProvisioningExecResult, a8 as compactPiPackages, a9 as createResourceSettingsManager, aa as mergePiPackageSources, ab as normalizeMeteringUsage, ac as piPackageSourceKey } from '../types-jcMapYr9.js';
3
+ import { E as ExecOptions, a as ExecResult, W as WorkspaceChangeEvent, b as Workspace, S as Sandbox } from '../sandbox-DAD8cWQR.js';
4
+ import { R as RemoteWorkerWorkspaceOp, a as RemoteWorkerWorkspaceResult, b as RemoteWorkerExecRequest } from '../middleware-CzW8n7B7.js';
5
+ 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, j as createAgentAuthMiddleware } from '../middleware-CzW8n7B7.js';
6
+ import { SandboxProviderV1, WorkspaceSandboxPairV1 } from '@hachej/boring-sandbox/shared';
7
+ import { S as SandboxHandleStore, C as CompiledAgentBundle, a as Sha256Digest, A as AgentDeployment, b as ShareEntryStore, P as PluginRestartWarning, W as WorkspaceAgentDispatcherContext, c as WorkspaceAgentDispatcher, d as ProviderId, e as CredentialFieldId, R as ResolvedCredentialMaterialV1, f as AuthorizedWorkspaceCredentialScopeV1, V as VerifiedWorkspaceCredentialAuthorityV1, g as WorkspaceCredentialAuthorityVerifierV1, h as CredentialConsumerBindingRegistryV1, i as ProviderRegistryV1, j as WorkspaceCredentialResolverV1, k as ProviderCredentialRefV1, l as ResolvedCredentialLeaseV1 } from '../lease-2aXepSBL.js';
8
+ import { s as AgentConfig, b as Agent, d as AgentActor, j as AgentEvent, t as AgentTool, u as AgentHarnessFactory, T as TelemetrySink, A as AgentHarness } from '../harness-Bt_GMNYR.js';
9
+ export { v as AgentHarnessFactoryInput } from '../harness-Bt_GMNYR.js';
10
+ import { b as PiChatEvent, E as ErrorCode, l as SessionCtx, S as SessionStore, m as SessionListOptions, k as SessionSummary, n as PiChatSnapshot, c as PromptPayload, d as PromptReceipt, F as FollowUpPayload, e as FollowUpReceipt, f as QueueClearPayload, g as QueueClearReceipt, I as InterruptPayload, i as StopPayload, j as StopReceipt } from '../piChatEvent-DBO3M5lu.js';
11
+ import { A as AgentGateway, a as AuthorizedAgentScope, b as AgentSessionRef, c as AgentSessionActivity, V as VerifiedAgentScopeClaim, d as AgentSessionSummary, e as AgentSessionStateSnapshot, f as AgentSessionConnection, J as JsonValue, g as AgentGatewayErrorDTO } from '../errors-BEmw9HMp.js';
10
12
  import { IncomingMessage, ServerResponse } from 'node:http';
11
13
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
12
- import { PackageSource, ExtensionFactory, SettingsManager } from '@mariozechner/pi-coding-agent';
13
- import { a as AgentEffectAdmission } from '../piChatSessionService-DPjJ0g71.js';
14
+ import { FastifyRequest, FastifyInstance, FastifyPluginAsync } from 'fastify';
15
+ import { i as PiSessionRequestContext, g as PiChatSessionService, h as PiSessionCreateInit, e as PiChatEventSubscriber, P as PiChatEventStreamResult, a as AgentEffectAdmission$1 } from '../piChatSessionService-BaaVWke7.js';
16
+ import { BoringAgentRuntimePaths } from '@hachej/boring-sandbox/providers/node-workspace';
17
+ import '@hachej/boring-bash/agent';
18
+ import '@mariozechner/pi-coding-agent';
14
19
  import 'zod';
15
20
 
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>;
21
+ declare function provisionWorkspaceRuntime(opts: ProvisionWorkspaceRuntimeOptions): Promise<WorkspaceProvisioningResult>;
137
22
 
138
23
  /**
139
24
  * uv setup for Python-family runtimes (e.g. Vercel `python3.13`), which already
@@ -168,392 +53,8 @@ interface BuildDeploymentSnapshotRecipeOptions extends DeploymentSnapshotRecipe
168
53
  declare function buildDeploymentSnapshotRecipe(opts?: BuildDeploymentSnapshotRecipeOptions): DeploymentSnapshotRecipe;
169
54
  declare function prepareDeploymentSnapshot(provider: DeploymentSnapshotProvider, recipe: DeploymentSnapshotRecipe): Promise<DeploymentSnapshotResult>;
170
55
 
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>;
188
-
189
- interface CreateNodeWorkspaceOptions {
190
- runtimeContext?: WorkspaceRuntimeContext;
191
- }
192
- declare function createNodeWorkspace(root: string, opts?: CreateNodeWorkspaceOptions): Workspace;
193
-
194
- /**
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.
200
- */
201
- declare function assertRealPathWithinWorkspace(workspaceRoot: string, absPath: string): Promise<void>;
202
-
203
56
  declare function resolveWorkspaceRoot(defaultRoot?: string): string;
204
57
 
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>;
228
-
229
- interface ProvisioningLogger {
230
- info?(message: string, fields?: Record<string, unknown>): void;
231
- warn?(message: string, fields?: Record<string, unknown>): void;
232
- error?(message: string, fields?: Record<string, unknown>): void;
233
- }
234
-
235
- interface PluginSkillSource {
236
- name: string;
237
- source: string | URL;
238
- }
239
- interface RuntimeTemplateContribution$1 {
240
- id: string;
241
- path: string | URL;
242
- target?: string;
243
- }
244
- interface RuntimePythonSpec$1 {
245
- id: string;
246
- projectFile: string | URL;
247
- packageName?: string;
248
- packageRoot?: string | URL;
249
- version?: string;
250
- extraLibs?: string[];
251
- env?: Record<string, string | URL>;
252
- expectedBins?: string[];
253
- }
254
- interface RuntimeNodePackageSpec$1 {
255
- id: string;
256
- packageName: string;
257
- packageRoot?: string | URL;
258
- version?: string;
259
- expectedBins?: string[];
260
- }
261
- interface RuntimeProvisioningContribution$1 {
262
- templateDirs?: RuntimeTemplateContribution$1[];
263
- python?: RuntimePythonSpec$1[];
264
- nodePackages?: RuntimeNodePackageSpec$1[];
265
- }
266
- interface WorkspaceProvisioningResult {
267
- changed: boolean;
268
- env: Record<string, string>;
269
- pathEntries: string[];
270
- skillPaths: string[];
271
- }
272
- interface WorkspaceProvisioningExecResult {
273
- stdout?: string;
274
- stderr?: string;
275
- }
276
- interface ResolveInstallSourceOpts {
277
- kind: 'node' | 'python';
278
- id: string;
279
- fingerprint: string;
280
- }
281
- interface WorkspaceProvisioningAdapter {
282
- mode: 'direct' | 'local' | 'vercel-sandbox';
283
- exec(command: string, args: string[], opts?: {
284
- cwd?: string;
285
- env?: Record<string, string>;
286
- timeoutMs?: number;
287
- }): Promise<WorkspaceProvisioningExecResult | void>;
288
- resolveInstallSource(source: string | URL, opts: ResolveInstallSourceOpts): Promise<string>;
289
- workspaceFs: {
290
- exists(workspaceRelativePath: string): Promise<boolean>;
291
- /** Remove a workspace-relative generated path. Missing path is success. */
292
- rm(workspaceRelativePath: string): Promise<void>;
293
- /** Create a workspace-relative directory recursively. */
294
- mkdir(workspaceRelativePath: string): Promise<void>;
295
- writeText(workspaceRelativePath: string, content: string): Promise<void>;
296
- readText(workspaceRelativePath: string): Promise<string | null>;
297
- /** Copy a host file or directory into the workspace; directory copies are recursive. */
298
- copyFromHost(hostSourcePath: string | URL, workspaceRelativeTarget: string): Promise<void>;
299
- };
300
- getRuntimeCacheRoot(): string;
301
- }
302
- interface ProvisioningTelemetryContext {
303
- workspaceId?: string;
304
- sessionId?: string;
305
- requestId?: string;
306
- runtimeMode?: string;
307
- }
308
- interface ProvisionWorkspaceRuntimeOptions {
309
- plugins: Array<{
310
- id: string;
311
- skills?: PluginSkillSource[];
312
- provisioning?: RuntimeProvisioningContribution$1;
313
- }>;
314
- adapter: WorkspaceProvisioningAdapter;
315
- runtimeLayout: BoringAgentRuntimePaths;
316
- logger?: ProvisioningLogger;
317
- telemetry?: TelemetrySink;
318
- telemetryContext?: ProvisioningTelemetryContext;
319
- }
320
-
321
- declare function provisionWorkspaceRuntime(opts: ProvisionWorkspaceRuntimeOptions): Promise<WorkspaceProvisioningResult>;
322
-
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
- type BuiltinRuntimeModeId = 'direct' | 'local' | 'vercel-sandbox';
382
- type RuntimeModeId = BuiltinRuntimeModeId | (string & {});
383
- interface RuntimeModeReadinessHooks {
384
- initialSandboxReady?: boolean;
385
- initialWorkspaceReadiness?: CapabilityReadinessDetail;
386
- onTrackerCreated?: (tracker: ReadyStatusTracker) => void;
387
- }
388
- type RuntimeCachedBindingHealthCheckResult = {
389
- state: 'ok';
390
- } | {
391
- state: 'recreate';
392
- message?: string;
393
- error?: unknown;
394
- };
395
- interface RuntimeCachedBindingHealthCheck {
396
- intervalMs?: number;
397
- check(ctx: {
398
- runtimeBundle: RuntimeBundle;
399
- workspaceId: string;
400
- }): Promise<RuntimeCachedBindingHealthCheckResult>;
401
- }
402
- type RuntimeBashStrategy = {
403
- kind: 'host';
404
- preserveHostHome?: boolean;
405
- } | {
406
- kind: 'local-sandbox';
407
- sandboxRoot: string;
408
- } | {
409
- kind: 'remote';
410
- defaultPath?: string;
411
- };
412
- interface RuntimeRemoteWorkspacePathOptions {
413
- rootAliases?: string[];
414
- toRemotePath?: (value: string) => string;
415
- toRuntimePath?: (value: string) => string;
416
- sanitizeErrorText?: (value: string) => string;
417
- }
418
- type RuntimeFilesystemStrategy = {
419
- kind: 'host';
420
- } | {
421
- kind: 'remote-workspace';
422
- pathOptions?: RuntimeRemoteWorkspacePathOptions;
423
- };
424
- interface RuntimeModeAdapter {
425
- readonly id: RuntimeModeId;
426
- /**
427
- * Declares whether the workspace files are strongly available on the host
428
- * path before create() runs. Composition layers use this to decide whether
429
- * host-side fs checks/prompts are safe without hard-coding sandbox IDs.
430
- */
431
- readonly workspaceFsCapability?: Workspace['fsCapability'];
432
- readonly readiness?: RuntimeModeReadinessHooks;
433
- readonly cachedBindingHealthCheck?: RuntimeCachedBindingHealthCheck;
434
- create(ctx: ModeContext): Promise<RuntimeBundle>;
435
- createProvisioningAdapter?(runtimeLayout: BoringAgentRuntimePaths, ctx?: ModeContext): WorkspaceProvisioningAdapter;
436
- getRuntimeLayoutRoot?(ctx: ModeContext): string;
437
- evictCachedRuntime?(ctx: {
438
- workspaceId: string;
439
- }): void;
440
- dispose?(): Promise<void>;
441
- }
442
- interface ModeContext {
443
- workspaceRoot: string;
444
- sessionId: string;
445
- workspaceId?: string;
446
- templatePath?: string;
447
- requestId?: string;
448
- telemetry?: TelemetrySink;
449
- }
450
- interface RuntimeFilesystemBindingOperations {
451
- read(descriptor: {
452
- filesystem: string;
453
- path: string;
454
- }): Promise<{
455
- content: string;
456
- mtimeMs?: number;
457
- metadata?: unknown;
458
- }>;
459
- list(descriptor: {
460
- filesystem: string;
461
- path: string;
462
- }): Promise<{
463
- entries: string[];
464
- metadata?: unknown;
465
- }>;
466
- find(descriptor: {
467
- filesystem: string;
468
- path: string;
469
- }, pattern: string, options?: {
470
- limit?: number;
471
- offset?: number;
472
- }): Promise<{
473
- paths: string[];
474
- metadata?: unknown;
475
- }>;
476
- grep(descriptor: {
477
- filesystem: string;
478
- path: string;
479
- }, pattern: string, options?: {
480
- limit?: number;
481
- offset?: number;
482
- }): Promise<{
483
- matches: Array<{
484
- path: string;
485
- line: number;
486
- text: string;
487
- }>;
488
- metadata?: unknown;
489
- }>;
490
- stat(descriptor: {
491
- filesystem: string;
492
- path: string;
493
- }): Promise<{
494
- isDirectory: boolean;
495
- metadata?: unknown;
496
- }>;
497
- write?(descriptor: {
498
- filesystem: string;
499
- path: string;
500
- content: string;
501
- expectedMtimeMs?: number;
502
- }): Promise<{
503
- mtimeMs?: number;
504
- metadata?: unknown;
505
- }>;
506
- delete?(descriptor: {
507
- filesystem: string;
508
- path: string;
509
- }): Promise<{
510
- metadata?: unknown;
511
- }>;
512
- move?(descriptor: {
513
- filesystem: string;
514
- from: string;
515
- to: string;
516
- }): Promise<{
517
- metadata?: unknown;
518
- }>;
519
- mkdir?(descriptor: {
520
- filesystem: string;
521
- path: string;
522
- recursive?: boolean;
523
- }): Promise<{
524
- metadata?: unknown;
525
- }>;
526
- rejectMutation(operation: string, descriptor: {
527
- filesystem: string;
528
- path: string;
529
- }): never;
530
- }
531
- interface RuntimeFilesystemBinding {
532
- readonly filesystem: string;
533
- readonly access: 'readonly' | 'readwrite';
534
- readonly operations: RuntimeFilesystemBindingOperations;
535
- }
536
- interface RuntimeBundle {
537
- runtimeContext?: WorkspaceRuntimeContext;
538
- /**
539
- * Server-private host/storage root for host-side filesystem work. Do not use
540
- * this as the agent-visible cwd; Workspace.root remains the public runtime
541
- * namespace shown to tools/model.
542
- */
543
- storageRoot?: string;
544
- workspace: Workspace;
545
- sandbox: Sandbox;
546
- fileSearch: FileSearch;
547
- /** Optional per-execution runtime env provider for local/direct operations that do not call Sandbox.exec. */
548
- getRuntimeEnv?: () => Promise<Record<string, string>>;
549
- /** Runtime-owned bash execution strategy, consumed by the agent bash tool builder. */
550
- bash?: RuntimeBashStrategy;
551
- /** Runtime-owned filesystem strategy, consumed by the agent filesystem tool builder. */
552
- filesystem?: RuntimeFilesystemStrategy;
553
- /** Optional filesystem bindings prepared for this runtime/session. */
554
- filesystemBindings?: RuntimeFilesystemBinding[];
555
- }
556
-
557
58
  interface RemoteWorkerClientOptions {
558
59
  baseUrl: string;
559
60
  token: string;
@@ -611,13 +112,6 @@ declare function createRemoteWorkerWorkspace(client: RemoteWorkerClient): Worksp
611
112
 
612
113
  declare function createRemoteWorkerSandbox(client: RemoteWorkerClient): Sandbox;
613
114
 
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
115
  interface RuntimeTemplateContribution {
622
116
  id: string;
623
117
  path: string | URL;
@@ -660,15 +154,6 @@ interface RuntimeWorkspaceProvisioningResult {
660
154
  }
661
155
  declare function provisionRuntimeWorkspace({ workspaceRoot, contributions, force, }: ProvisionRuntimeWorkspaceOptions): Promise<RuntimeWorkspaceProvisioningResult>;
662
156
 
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
157
  type ProvisioningArtifactKind = 'node' | 'python';
673
158
  /** What a per-mode packer receives to produce one artifact. `id`/`fingerprint`
674
159
  * are passed through (not used by the default packer, but part of the public
@@ -681,27 +166,84 @@ interface ProvisioningArtifactRequest {
681
166
  outputPath: string;
682
167
  }
683
168
 
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
169
  declare function hasBwrap(): boolean;
699
170
  declare function autoDetectMode(): RuntimeModeId;
700
171
  interface ResolveModeOptions {
701
- sandboxHandleStore?: SandboxHandleStore;
172
+ adapters?: Readonly<Record<BuiltinRuntimeModeId, RuntimeModeAdapter>>;
702
173
  }
703
174
  declare function resolveMode(mode?: RuntimeModeId, opts?: ResolveModeOptions): RuntimeModeAdapter;
704
175
 
176
+ declare function createDirectModeAdapter(options: {
177
+ provider: SandboxProviderV1;
178
+ runtimeHost: AgentRuntimeHostOperations;
179
+ }): RuntimeModeAdapter;
180
+
181
+ declare function createLocalModeAdapter(options: {
182
+ provider: SandboxProviderV1;
183
+ runtimeHost: AgentRuntimeHostOperations;
184
+ }): RuntimeModeAdapter;
185
+
186
+ declare function createVercelSandboxModeAdapter(options: {
187
+ provider: SandboxProviderV1;
188
+ runtimeHost: AgentRuntimeHostOperations;
189
+ remoteRoot: string;
190
+ workspaceRoot: string;
191
+ }): RuntimeModeAdapter;
192
+
193
+ interface ProviderRuntimeModeAdapterOptions {
194
+ id: 'direct' | 'local' | 'vercel-sandbox';
195
+ provider: SandboxProviderV1;
196
+ runtimeHost: AgentRuntimeHostOperations;
197
+ workspaceFsCapability: 'strong' | 'best-effort';
198
+ bash: RuntimeBashStrategy;
199
+ filesystem: RuntimeFilesystemStrategy;
200
+ storageRoot?: (context: ModeContext) => string | undefined;
201
+ preflight?: (context: ModeContext) => void | Promise<void>;
202
+ prepare?: (context: ModeContext) => Promise<void>;
203
+ provisioningAdapter?: (context: ModeContext, pair: WorkspaceSandboxPairV1) => WorkspaceProvisioningAdapter | undefined;
204
+ healthCheckIntervalMs?: number;
205
+ readiness?: RuntimeModeAdapter['readiness'];
206
+ }
207
+ declare function createProviderRuntimeModeAdapter(options: ProviderRuntimeModeAdapterOptions): RuntimeModeAdapter;
208
+
209
+ declare const sandboxRuntimeHostOperations: AgentRuntimeHostOperations;
210
+ interface SandboxRuntimeModeOptions {
211
+ readonly sandboxHandleStore?: SandboxHandleStore;
212
+ }
213
+ /** Built-in runtime layout root without exposing provider package constants to consumers. */
214
+ declare function resolveBuiltinRuntimeLayoutRoot(mode: BuiltinRuntimeModeId, workspaceRoot: string): string;
215
+ declare function createSandboxRuntimeModeAdapter(mode: BuiltinRuntimeModeId, options?: SandboxRuntimeModeOptions): RuntimeModeAdapter;
216
+
217
+ interface EventStreamReadResult {
218
+ events: Array<{
219
+ data: unknown;
220
+ offset: string;
221
+ }>;
222
+ nextOffset: string;
223
+ upToDate: boolean;
224
+ closed: boolean;
225
+ }
226
+ interface EventStreamMeta {
227
+ nextOffset: string;
228
+ closed: boolean;
229
+ }
230
+ interface EventStreamStore {
231
+ createStream(path: string): Promise<void>;
232
+ appendEvent(path: string, event: unknown): Promise<string>;
233
+ appendEventOnce(path: string, key: string, event: unknown): Promise<string>;
234
+ appendAgentEvent(sessionId: string, chunk: PiChatEvent, opts?: {
235
+ idempotencyKey?: string;
236
+ streamPath?: string;
237
+ }): Promise<string>;
238
+ readEvents(path: string, opts?: {
239
+ offset?: string;
240
+ limit?: number;
241
+ }): Promise<EventStreamReadResult>;
242
+ closeStream(path: string): Promise<void>;
243
+ getStreamMeta(path: string): Promise<EventStreamMeta | null>;
244
+ subscribe(path: string, listener: () => void): () => void;
245
+ }
246
+
705
247
  declare function createAgent(config: AgentConfig): Agent;
706
248
 
707
249
  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 +262,34 @@ declare class AgentDirectoryCompilerError extends Error {
720
262
  }
721
263
  declare function compileAgentDirectory(directory: string): Promise<CompiledAgentBundle>;
722
264
 
265
+ type AuthoredAgentMaterializationErrorCode = Extract<ErrorCode, 'AUTHORED_AGENT_ID_INVALID' | 'AUTHORED_AGENT_TYPE_MISMATCH' | 'AUTHORED_AGENT_REFERENCE_UNSUPPORTED'>;
266
+ type AuthoredAgentSourceV1 = Readonly<{
267
+ schemaVersion: 1;
268
+ agentTypeId: string;
269
+ version: string;
270
+ label?: string;
271
+ description?: string;
272
+ instructions: string;
273
+ }>;
274
+ interface MaterializeAgentDirectoryInput {
275
+ directory: string;
276
+ expectedAgentTypeId?: string;
277
+ }
278
+ declare class AuthoredAgentMaterializationError extends Error {
279
+ readonly code: AuthoredAgentMaterializationErrorCode;
280
+ readonly field?: string;
281
+ constructor(input: {
282
+ code: AuthoredAgentMaterializationErrorCode;
283
+ field?: string;
284
+ message: string;
285
+ });
286
+ }
287
+ /**
288
+ * Loads declarative authored identity, safe metadata, and instructions.
289
+ * Executable behavior is selected only by trusted host/plugin policy.
290
+ */
291
+ declare function materializeAgentDirectory(input: MaterializeAgentDirectoryInput): Promise<AuthoredAgentSourceV1>;
292
+
723
293
  interface ResolvedAgentDigestInput {
724
294
  readonly workspaceId: string;
725
295
  readonly defaultDeploymentId: string;
@@ -841,7 +411,13 @@ interface ManagedAgentCollectArtifactsInput {
841
411
  events: readonly AgentEvent[];
842
412
  }
843
413
  interface ManagedAgentMcpDelegateOptions {
844
- agent?: Agent;
414
+ gateway?: AgentGateway;
415
+ agentTypeId?: string;
416
+ resolveGatewayScope?(input: {
417
+ brief: string;
418
+ ctx: SessionCtx;
419
+ request: ManagedAgentDelegateRequestContext;
420
+ }): AuthorizedAgentScope | Promise<AuthorizedAgentScope>;
845
421
  resolveSessionCtx(input: {
846
422
  brief: string;
847
423
  request: ManagedAgentDelegateRequestContext;
@@ -890,7 +466,7 @@ declare class ManagedAgentMcpDelegateController {
890
466
  private resolveSessionCtx;
891
467
  private resolveWorkspace;
892
468
  private resolveRunnerWorkspace;
893
- private createAgentDelegateRunner;
469
+ private createGatewayDelegateRunner;
894
470
  private assertNotAborted;
895
471
  private stopDelegatedSession;
896
472
  private resolveActor;
@@ -979,150 +555,6 @@ interface RuntimeEnvContribution {
979
555
  getEnv(ctx: RuntimeEnvContributionContext): Record<string, string> | Promise<Record<string, string>>;
980
556
  }
981
557
 
982
- type PiPackageSource = PackageSource;
983
- declare const PI_PACKAGE_RESOURCE_FILTERS: readonly ["extensions", "skills", "prompts", "themes"];
984
- declare function piPackageSourceKey(source: PiPackageSource): string;
985
- declare function compactPiPackages(sources: Array<PiPackageSource | undefined>): PiPackageSource[];
986
- declare function mergePiPackageSources(base?: PiPackageSource[], additional?: PiPackageSource[]): PiPackageSource[];
987
-
988
- interface PiHarnessOptions {
989
- noContextFiles?: boolean;
990
- noSkills?: boolean;
991
- additionalSkillPaths?: string[];
992
- /**
993
- * Additional native Pi package sources to enable for this agent runtime.
994
- * These are applied as in-memory SettingsManager overrides, so host/plugin
995
- * declarations do not mutate .pi/settings.json.
996
- */
997
- packages?: PiPackageSource[];
998
- /**
999
- * Additional native pi extension entrypoints. Pi loads these through jiti and
1000
- * re-imports them on ctx.reload(), which is required for hot-reloadable
1001
- * boring agent plugins.
1002
- */
1003
- extensionPaths?: string[];
1004
- /** In-process host extensions. Use only for trusted built-ins; hot plugin code should use paths. */
1005
- extensionFactories?: ExtensionFactory[];
1006
- /**
1007
- * Optional source of hot-reloadable Pi resources. Pi calls it on every
1008
- * reloadSession() (and once at session build) and merges the result with
1009
- * the static fields above. Lets the workspace plugin layer refresh
1010
- * package.json-discovered skills/packages/extensions without mutating
1011
- * arrays that the harness already captured.
1012
- */
1013
- getHotReloadableResources?: () => HotReloadablePiResources;
1014
- /** Reject an explicit unavailable/unknown model instead of silently falling back. */
1015
- strictModelResolution?: boolean;
1016
- }
1017
- interface HotReloadablePiResources {
1018
- additionalSkillPaths?: string[];
1019
- packages?: PiPackageSource[];
1020
- extensionPaths?: string[];
1021
- }
1022
- type PiExtensionFactory = ExtensionFactory;
1023
- declare function createResourceSettingsManager(cwd: string, agentDir: string, piPackages: PiPackageSource[]): SettingsManager;
1024
-
1025
- /**
1026
- * Generic metering seam for hosts that bill native Pi usage.
1027
- *
1028
- * The agent package owns lifecycle correctness (when to reserve, record,
1029
- * settle, release based on native Pi events); the host-provided sink owns
1030
- * persistence and product policy (credits, pricing, currencies, hard stops).
1031
- *
1032
- * Lifecycle per accepted prompt/follow-up ("run", identified by `runId`):
1033
- *
1034
- * reserveRun before execution starts; throwing rejects the request
1035
- * (fail closed) so hosts can enforce hard stops.
1036
- * recordUsage once per native assistant message carrying usage.
1037
- * `usageId` is a stable idempotency key.
1038
- * settleRun when the run reaches a native terminal state and usage
1039
- * was recorded (or it finished ok).
1040
- * releaseRun when the run never produced billable usage: rejected
1041
- * execution, cleared queue, cancel/abort, or error before
1042
- * any usage arrived.
1043
- *
1044
- * Every run terminates with exactly one settle or release from the
1045
- * coordinator; sinks should still treat all four methods as idempotent
1046
- * because process restarts and client retries can replay transitions.
1047
- */
1048
- interface AgentMeteringSink {
1049
- /** False means the sink is installed but policy is disabled/no-op. Omitted means active for fail-closed callers. */
1050
- isEnabled?: () => boolean;
1051
- reserveRun(input: MeteringReserveInput): Promise<MeteringReservationResult>;
1052
- /** Records the usage and returns the credit micros it was actually billed. The
1053
- * coordinator counts a usage as billable from this charged amount (not raw provider
1054
- * fields), so a row that prices to 0 (e.g. cost-only usage when provider cost isn't
1055
- * trusted) doesn't make a free run settle. */
1056
- recordUsage(input: MeteringUsageInput): Promise<MeteringUsageResult>;
1057
- settleRun(input: MeteringSettleInput): Promise<void>;
1058
- releaseRun(input: MeteringReleaseInput): Promise<void>;
1059
- }
1060
- interface MeteringUsageResult {
1061
- /** Credit micros this usage row was billed (0 = no real debit). */
1062
- billedMicros: number;
1063
- }
1064
- interface MeteringRunScope {
1065
- workspaceId?: string;
1066
- userId?: string;
1067
- userEmail?: string;
1068
- userEmailVerified?: boolean;
1069
- sessionId: string;
1070
- /** Stable id for one accepted prompt/follow-up run. */
1071
- runId: string;
1072
- source: 'pi-chat';
1073
- }
1074
- type MeteringRunKind = 'prompt' | 'followup';
1075
- interface MeteringReserveInput extends MeteringRunScope {
1076
- kind: MeteringRunKind;
1077
- message: string;
1078
- model?: ChatModelSelection;
1079
- }
1080
- /** Sinks without reservation rows can return an empty object. */
1081
- interface MeteringReservationResult {
1082
- reservationId?: string;
1083
- }
1084
- interface MeteringUsage {
1085
- input: number;
1086
- output: number;
1087
- cacheRead: number;
1088
- cacheWrite: number;
1089
- cost: {
1090
- input: number;
1091
- output: number;
1092
- cacheRead: number;
1093
- cacheWrite: number;
1094
- total: number;
1095
- };
1096
- }
1097
- interface MeteringUsageInput extends MeteringRunScope {
1098
- reservationId?: string;
1099
- /** Stable idempotency key for this usage row. */
1100
- usageId: string;
1101
- messageId?: string;
1102
- model?: {
1103
- provider?: string;
1104
- id?: string;
1105
- };
1106
- usage: MeteringUsage;
1107
- stopReason?: string;
1108
- metadata?: Record<string, unknown>;
1109
- }
1110
- type MeteringRunStatus = 'ok' | 'error' | 'aborted';
1111
- interface MeteringSettleInput extends MeteringRunScope {
1112
- reservationId?: string;
1113
- status: MeteringRunStatus;
1114
- }
1115
- type MeteringReleaseReason = 'run-rejected' | 'queue-cleared' | 'cancelled' | 'error-before-usage' | 'usage-write-failed' | 'fallback-hold-charge';
1116
- interface MeteringReleaseInput extends MeteringRunScope {
1117
- reservationId?: string;
1118
- reason: MeteringReleaseReason;
1119
- }
1120
- type MeteringErrorLogger = (message: string, error: unknown) => void;
1121
- /** Native Pi usage objects always carry token + cost breakdowns; normalize
1122
- * defensively (zero-filling gaps and clamping negatives) so a partial object
1123
- * from an unexpected provider still meters as zeros instead of NaN. */
1124
- declare function normalizeMeteringUsage(value: unknown): MeteringUsage | undefined;
1125
-
1126
558
  interface WorkspaceAgentDispatcherResolveOptions {
1127
559
  request?: FastifyRequest;
1128
560
  }
@@ -1142,6 +574,8 @@ interface CreateAgentAppOptions {
1142
574
  mode?: RuntimeModeId;
1143
575
  /** Supply a custom runtime adapter to plug in non-built-in sandbox/workspace modes. */
1144
576
  runtimeModeAdapter?: RuntimeModeAdapter;
577
+ /** Provider/runtime values supplied by the embedding host. */
578
+ runtimeHost?: AgentRuntimeHostOperations;
1145
579
  authToken?: string;
1146
580
  version?: string;
1147
581
  logger?: boolean;
@@ -1180,6 +614,11 @@ interface CreateAgentAppOptions {
1180
614
  userEmailVerified?: boolean;
1181
615
  requestId?: string;
1182
616
  }) => RuntimeFilesystemBinding[] | undefined | Promise<RuntimeFilesystemBinding[] | undefined>;
617
+ /**
618
+ * Trusted host seam for resolving Pi HTTP session scope. The default keeps
619
+ * unauthenticated requests workspace-only and authenticated requests user-scoped.
620
+ */
621
+ resolvePiSessionRequestContext?: (request: FastifyRequest, defaultContext: PiSessionRequestContext) => PiSessionRequestContext | Promise<PiSessionRequestContext>;
1183
622
  /** Generic runtime env contributors. Agent stays workspace-neutral; hosts decide env names/values. */
1184
623
  runtimeEnvContributions?: RuntimeEnvContribution[];
1185
624
  /** Runtime-aware provisioning hook. Runs after Workspace/Sandbox creation and before tools/harness. */
@@ -1232,6 +671,302 @@ interface CreateAgentAppOptions {
1232
671
  }
1233
672
  declare function createAgentApp(opts?: CreateAgentAppOptions): Promise<FastifyInstance>;
1234
673
 
674
+ interface HarnessPiChatServiceOptions {
675
+ harness: AgentHarness;
676
+ sessionStore: SessionStore;
677
+ workdir: string;
678
+ workspace?: Workspace;
679
+ eventStore?: EventStreamStore;
680
+ /**
681
+ * Optional host billing sink. When set, accepted prompts/follow-ups reserve
682
+ * before execution (a rejecting sink blocks the request), native assistant
683
+ * usage is recorded per message, and every run settles or releases from
684
+ * native terminal lifecycle.
685
+ */
686
+ metering?: AgentMeteringSink;
687
+ /** Host-owned process-lifetime projection of live session activity. */
688
+ onEvent?: (sessionId: string, event: PiChatEvent) => void;
689
+ /** Receives non-fatal metering pipeline failures (default: console.warn). */
690
+ meteringLogger?: MeteringErrorLogger;
691
+ }
692
+ declare class HarnessPiChatService implements PiChatSessionService {
693
+ private readonly harness;
694
+ private readonly sessionStore;
695
+ private readonly workdir;
696
+ private readonly workspace?;
697
+ private readonly eventStore?;
698
+ private readonly onEvent?;
699
+ private readonly channels;
700
+ private readonly channelCreations;
701
+ private readonly messageMetadata;
702
+ private readonly activePromptRuns;
703
+ private readonly syntheticPromptFailures;
704
+ private readonly activeSyntheticPromptErrors;
705
+ private readonly lifecycle;
706
+ private readonly metering?;
707
+ private disposePromise?;
708
+ constructor(options: HarnessPiChatServiceOptions);
709
+ /** Test/diagnostic hook: resolves once queued metering sink calls settle. */
710
+ flushMetering(): Promise<void>;
711
+ dispose(): Promise<void>;
712
+ private disposeService;
713
+ listSessions(ctx: PiSessionRequestContext, options?: SessionListOptions): Promise<SessionSummary[]>;
714
+ createSession(ctx: PiSessionRequestContext, init?: PiSessionCreateInit): Promise<SessionSummary>;
715
+ deleteSession(ctx: PiSessionRequestContext, sessionId: string): Promise<void>;
716
+ private deleteSessionBeforeDispose;
717
+ readAttachment(ctx: PiSessionRequestContext, sessionId: string, messageId: string, index: number): Promise<{
718
+ data: Uint8Array;
719
+ mediaType: string;
720
+ filename?: string;
721
+ }>;
722
+ readState(ctx: PiSessionRequestContext, sessionId: string): Promise<PiChatSnapshot>;
723
+ private readStateBeforeDispose;
724
+ private harnessMayHaveLiveSession;
725
+ private readPersistedState;
726
+ subscribe(ctx: PiSessionRequestContext, sessionId: string, cursor: number, subscriber: PiChatEventSubscriber): Promise<PiChatEventStreamResult>;
727
+ private subscribeBeforeDispose;
728
+ prompt(ctx: PiSessionRequestContext, sessionId: string, payload: PromptPayload): Promise<PromptReceipt>;
729
+ private promptBeforeDispose;
730
+ followUp(ctx: PiSessionRequestContext, sessionId: string, payload: FollowUpPayload): Promise<FollowUpReceipt>;
731
+ private followUpBeforeDispose;
732
+ clearQueue(ctx: PiSessionRequestContext, sessionId: string, payload: QueueClearPayload): Promise<QueueClearReceipt>;
733
+ private clearQueueBeforeDispose;
734
+ interrupt(ctx: PiSessionRequestContext, sessionId: string, _payload: InterruptPayload): Promise<{
735
+ accepted: true;
736
+ cursor: number;
737
+ }>;
738
+ private interruptBeforeDispose;
739
+ stop(ctx: PiSessionRequestContext, sessionId: string, _payload: StopPayload): Promise<StopReceipt>;
740
+ private stopBeforeDispose;
741
+ private clearAllFollowUps;
742
+ private nextFollowUpForInterrupt;
743
+ private autoPostInterruptedFollowUp;
744
+ private runPrompt;
745
+ private trackActiveRun;
746
+ private clearAutoPostedFollowUpForFallback;
747
+ private canClearAutoPostedFollowUpForFallback;
748
+ private enrichSyntheticPromptFailures;
749
+ private publishAutoPostedFollowUpRunError;
750
+ private publishChannelEvents;
751
+ private publishChannelEventSync;
752
+ private publishPromptRunError;
753
+ private runAndDrainPublishQueue;
754
+ private drainPublishQueue;
755
+ private getAdapter;
756
+ private getChannel;
757
+ private ensureChannel;
758
+ /** Coalesce concurrent cold callers so only one adapter subscription wins. */
759
+ private createChannelOnce;
760
+ private buildChannel;
761
+ private readDurableLatestPiChatSeq;
762
+ private assertCanAccessSession;
763
+ private sessionKey;
764
+ }
765
+
766
+ interface EnvironmentProvisioningSnapshot {
767
+ readonly changed: boolean;
768
+ readonly env: Readonly<Record<string, string>>;
769
+ readonly pathEntries: readonly string[];
770
+ readonly skillPaths: readonly string[];
771
+ }
772
+ interface EnvironmentLease {
773
+ readonly bundle: RuntimeBundle;
774
+ /** One immutable Environment-owned snapshot shared by every compatible Agent binding. */
775
+ readonly provisioning?: EnvironmentProvisioningSnapshot;
776
+ release(): void;
777
+ retire(): Promise<void>;
778
+ }
779
+
780
+ interface BuiltAgentComposition {
781
+ readonly agent: Agent;
782
+ readonly harness: AgentHarness;
783
+ readonly sessionStore: SessionStore;
784
+ readonly service: HarnessPiChatService;
785
+ readonly tools: readonly AgentTool[];
786
+ readonly runtimeBundle: RuntimeBundle;
787
+ readonly readyTracker: ReadyStatusTracker;
788
+ readonly runtimeScopeIdentity: string;
789
+ dispose(): Promise<void>;
790
+ }
791
+
792
+ interface AgentSessionRuntimeAuthority {
793
+ readonly runtimeScope: ResolvedAgentRuntimeScope;
794
+ /** Absent only for a pre-AH0 transcript created before runtime pins existed. */
795
+ readonly runtimeScopeIdentity?: string;
796
+ }
797
+ /** Process-lifetime live-turn projection. Reads never create activity rows. */
798
+ declare class AgentSessionActivityIndex {
799
+ private readonly activity;
800
+ get(workspaceScopeId: string, ref: AgentSessionRef): AgentSessionActivity;
801
+ set(workspaceScopeId: string, ref: AgentSessionRef, activity: AgentSessionActivity): void;
802
+ delete(workspaceScopeId: string, ref: AgentSessionRef): void;
803
+ observe(workspaceScopeId: string, ref: AgentSessionRef, event: PiChatEvent): void;
804
+ }
805
+
806
+ interface RuntimeBinding {
807
+ readonly key: string;
808
+ readonly scope: ResolvedAgentRuntimeScope;
809
+ readonly environmentLease: EnvironmentLease;
810
+ readonly composition: BuiltAgentComposition;
811
+ }
812
+ interface AgentHostRuntime {
813
+ readonly options: CreateAgentHostOptions;
814
+ readonly compiledAgents: readonly CompiledAgentHostAgentSpec[];
815
+ readonly compiledById: ReadonlyMap<string, CompiledAgentHostAgentSpec>;
816
+ readonly ledger: AgentRequestLedger;
817
+ readonly effectAdmission: AgentEffectAdmission;
818
+ readonly activity: AgentSessionActivityIndex;
819
+ listSessionSummaries(agentTypeId: string, scope: AuthorizedAgentScope, claim: VerifiedAgentScopeClaim): Promise<readonly SessionSummary[]>;
820
+ isDraining(): boolean;
821
+ assertOpen(): void;
822
+ verify(scope: AuthorizedAgentScope): Promise<VerifiedAgentScopeClaim>;
823
+ resolveSessionRuntime(agentTypeId: string, scope: AuthorizedAgentScope, claim: VerifiedAgentScopeClaim, sessionId: string): Promise<AgentSessionRuntimeAuthority | undefined>;
824
+ resolveBinding(agentTypeId: string, scope: AuthorizedAgentScope, claim: VerifiedAgentScopeClaim, resolvedRuntimeScope?: ResolvedAgentRuntimeScope): Promise<RuntimeBinding>;
825
+ startDrain(): void;
826
+ drainRuntime(): Promise<void>;
827
+ registerSubscription(close: () => void | Promise<void>): () => void;
828
+ trackEffect<T>(effect: Promise<T>, key: AgentRequestKey): Promise<T>;
829
+ retireCompatibilityComposition(composition: BuiltAgentComposition): Promise<void>;
830
+ closeRuntime(): Promise<void>;
831
+ }
832
+ declare function createAgentHost(options: CreateAgentHostOptions): Promise<CreatedAgentHost>;
833
+
834
+ declare const AgentFleetCompilationErrorCode: {
835
+ readonly AGENT_FLEET_PLUGIN_UNKNOWN: "AGENT_FLEET_PLUGIN_UNKNOWN";
836
+ readonly AGENT_FLEET_CONFIG_BINDING_UNKNOWN: "AGENT_FLEET_CONFIG_BINDING_UNKNOWN";
837
+ readonly AGENT_FLEET_MODEL_POLICY_UNCOMPILED: "AGENT_FLEET_MODEL_POLICY_UNCOMPILED";
838
+ };
839
+ type AgentFleetCompilationErrorCode = (typeof AgentFleetCompilationErrorCode)[keyof typeof AgentFleetCompilationErrorCode];
840
+ declare class AgentFleetCompilationError extends Error {
841
+ readonly code: AgentFleetCompilationErrorCode;
842
+ readonly details: Readonly<Record<string, string>>;
843
+ constructor(code: AgentFleetCompilationErrorCode, message: string, details: Readonly<Record<string, string>>);
844
+ }
845
+ interface AgentFleetPluginBindingContract {
846
+ readonly id: string;
847
+ readonly configKeys?: readonly string[];
848
+ }
849
+ interface CreateValidatingAgentFleetCompilerOptions {
850
+ readonly plugins: readonly AgentFleetPluginBindingContract[];
851
+ readonly compiler?: AgentFleetCompiler;
852
+ /**
853
+ * Keeps Core's existing fail-closed policy when it has no app compiler.
854
+ * This is not model allowlist validation.
855
+ */
856
+ readonly requireCompilerForModelPolicy?: boolean;
857
+ }
858
+ /**
859
+ * The one reusable fleet binding-validation funnel. Apps supply only their
860
+ * already-resolved plugin contracts and optional stricter policy compiler.
861
+ */
862
+ declare function createValidatingAgentFleetCompiler(options: CreateValidatingAgentFleetCompilerOptions): AgentFleetCompiler;
863
+
864
+ declare class EmbeddedAgentGateway implements AgentGateway {
865
+ private readonly runtime;
866
+ private readonly cursorSecret;
867
+ private readonly connections;
868
+ private readonly effects;
869
+ private readonly pins;
870
+ private readonly writerTails;
871
+ private sessionRuntimeResolutionObserver?;
872
+ private closed;
873
+ constructor(runtime: AgentHostRuntime);
874
+ /** Server-only test observer for distinguishing runtime pin resolution paths. */
875
+ setSessionRuntimeResolutionObserverForTesting(observer: (input: {
876
+ readonly source: 'pre-ah0-compatibility-fallback' | 'persisted-runtime-pin';
877
+ readonly runtimeScopeIdentity: string;
878
+ }) => void): void;
879
+ /** Test-only activity seam used by the shared implementation conformance. */
880
+ setActivityForTesting(workspaceScopeId: string, ref: AgentSessionRef, activity: AgentSessionActivity): void;
881
+ private assertOpen;
882
+ private verify;
883
+ listAgents(input: {
884
+ readonly scope: AuthorizedAgentScope;
885
+ }): Promise<{
886
+ definition?: {
887
+ version: string;
888
+ digest: string;
889
+ } | undefined;
890
+ agentTypeId: string;
891
+ label: string;
892
+ }[]>;
893
+ listSessions(input: Parameters<AgentGateway['listSessions']>[0]): Promise<{
894
+ nextCursor?: string | undefined;
895
+ sessions: AgentSessionSummary[];
896
+ }>;
897
+ createSession(input: Parameters<AgentGateway['createSession']>[0]): Promise<AgentSessionRef>;
898
+ readSessionState(input: Parameters<AgentGateway['readSessionState']>[0]): Promise<AgentSessionStateSnapshot>;
899
+ connectSession(input: Parameters<AgentGateway['connectSession']>[0]): Promise<AgentSessionConnection>;
900
+ private send;
901
+ renameSession(input: Parameters<AgentGateway['renameSession']>[0]): Promise<AgentSessionSummary>;
902
+ deleteSession(input: Parameters<AgentGateway['deleteSession']>[0]): Promise<void>;
903
+ close(): Promise<void>;
904
+ private bindingForSession;
905
+ private loadSummary;
906
+ private sessionEffect;
907
+ /** Internal legacy-alias seam; never exposed through the public Gateway contract. */
908
+ runLegacyCompatibilityEffect(input: {
909
+ readonly scope: AuthorizedAgentScope;
910
+ readonly operation: AgentGatewayEffect;
911
+ readonly target: AgentRequestTarget;
912
+ readonly requestId: string;
913
+ readonly payload: JsonValue;
914
+ readonly action: () => Promise<unknown>;
915
+ }): Promise<unknown>;
916
+ private effect;
917
+ private replayReceipt;
918
+ private failure;
919
+ private withWriter;
920
+ private encodeCursor;
921
+ private decodeCursor;
922
+ }
923
+
924
+ /** Process-lifetime Level-B ledger with the exact published state machine. */
925
+ declare class InMemoryAgentRequestLedger implements AgentRequestLedger {
926
+ private readonly records;
927
+ prepare(key: AgentRequestKey, digest: string): Promise<AgentRequestLedgerRecord>;
928
+ acceptAdmission(key: AgentRequestKey, admissionReceipt: string): Promise<void>;
929
+ beginEffect(key: AgentRequestKey): Promise<void>;
930
+ reject(key: AgentRequestKey, failure: AgentRequestFailure): Promise<void>;
931
+ complete(key: AgentRequestKey, receipt: JsonValue): Promise<void>;
932
+ markOutcomeUnknown(key: AgentRequestKey, error: AgentGatewayErrorDTO): Promise<void>;
933
+ read(key: AgentRequestKey): Promise<AgentRequestLedgerRecord | undefined>;
934
+ private transition;
935
+ }
936
+
937
+ interface RuntimeScopeIdentityInput {
938
+ readonly artifacts: readonly {
939
+ readonly pluginId: string;
940
+ readonly digest: string;
941
+ }[];
942
+ readonly validatedConfig: JsonValue;
943
+ readonly grants: readonly string[];
944
+ readonly placementIdentity: string;
945
+ readonly isolationMode: string;
946
+ readonly toolContractDigests: readonly string[];
947
+ readonly provisioningGeneration: string;
948
+ readonly bindingInputs?: JsonValue;
949
+ }
950
+ interface EnvironmentProvisioningIdentityInput {
951
+ readonly placementIdentity: string;
952
+ readonly providerDigest: string;
953
+ readonly provisioningArtifactDigests: readonly string[];
954
+ readonly provisioningGeneration: string;
955
+ readonly templateDigest?: string;
956
+ }
957
+ /**
958
+ * Produces the complete Agent-binding identity. Grants intentionally
959
+ * participate here even though they do not participate in Environment
960
+ * provisioning identity.
961
+ */
962
+ declare function createResolvedRuntimeScopeIdentity(input: RuntimeScopeIdentityInput): string;
963
+ /**
964
+ * Produces only the Environment-mutating identity. Contribution grants and
965
+ * tool contracts are deliberately absent, so grant-only changes share the
966
+ * same canonical Environment lease.
967
+ */
968
+ declare function createEnvironmentProvisioningFingerprint(input: EnvironmentProvisioningIdentityInput): string;
969
+
1235
970
  interface HeaderLike {
1236
971
  setHeader(name: string, value: string): void;
1237
972
  }
@@ -1283,7 +1018,29 @@ interface ModelsRoutesOptions {
1283
1018
  filterModels?: (ctx: ModelFilterContext, models: readonly ModelSummary[], defaultModel: AgentModelSelection | undefined) => ModelFilterResult | Promise<ModelFilterResult>;
1284
1019
  }
1285
1020
 
1021
+ type PiSessionRequestContextResolver = (request: FastifyRequest, defaultContext: PiSessionRequestContext) => PiSessionRequestContext | Promise<PiSessionRequestContext>;
1022
+
1023
+ interface PrebuiltAgentHostRoutePolicy {
1024
+ /** The sole Host instance constructed by the embedding composition root. */
1025
+ readonly created: CreatedAgentHost;
1026
+ /** Default Agent used by the legacy unaddressed route family. */
1027
+ readonly defaultAgentTypeId: string;
1028
+ /**
1029
+ * App-owned capability issuer. The app may replace workspaceScopeId with its
1030
+ * canonical workspace/storage partition while retaining the normalized
1031
+ * runtime scope as private issuer context.
1032
+ */
1033
+ issueScope(input: {
1034
+ readonly claim: VerifiedAgentScopeClaim;
1035
+ readonly runtimeScope: ResolvedAgentRuntimeScope;
1036
+ }): AuthorizedAgentScope;
1037
+ }
1286
1038
  interface RegisterAgentRoutesOptions {
1039
+ /**
1040
+ * Reuse a Host created by the embedding composition root. Omission preserves
1041
+ * the historical wrapper behavior and constructs one legacy default Host.
1042
+ */
1043
+ agentHost?: PrebuiltAgentHostRoutePolicy;
1287
1044
  workspaceRoot?: string;
1288
1045
  sessionId?: string;
1289
1046
  templatePath?: string;
@@ -1295,8 +1052,12 @@ interface RegisterAgentRoutesOptions {
1295
1052
  mode?: RuntimeModeId;
1296
1053
  /** Supply a custom runtime adapter to plug in non-built-in sandbox/workspace modes. */
1297
1054
  runtimeModeAdapter?: RuntimeModeAdapter;
1055
+ /** Provider/runtime values supplied by the embedding host. */
1056
+ runtimeHost?: AgentRuntimeHostOperations;
1298
1057
  version?: string;
1299
1058
  extraTools?: AgentTool[];
1059
+ /** When true, omit the six filesystem tools (read/write/edit/find/grep/ls). */
1060
+ disableDefaultFileTools?: boolean;
1300
1061
  getExtraTools?: (ctx: {
1301
1062
  workspaceId: string;
1302
1063
  workspaceRoot: string;
@@ -1335,10 +1096,12 @@ interface RegisterAgentRoutesOptions {
1335
1096
  sessionNamespace?: string;
1336
1097
  /** Optional explicit root for file-backed Pi chat transcript storage. */
1337
1098
  sessionRoot?: string;
1099
+ /** Trusted host seam for resolving Pi HTTP session scope. */
1100
+ resolvePiSessionRequestContext?: PiSessionRequestContextResolver;
1338
1101
  /** Optional best-effort telemetry sink supplied by an embedding host. */
1339
1102
  telemetry?: TelemetrySink;
1340
1103
  /** Optional host admission called immediately before each agent effect. */
1341
- admitEffect?: AgentEffectAdmission;
1104
+ admitEffect?: AgentEffectAdmission$1;
1342
1105
  /** Generic request-aware model filtering seam. Hosts may filter per user/workspace. */
1343
1106
  filterModels?: ModelsRoutesOptions['filterModels'];
1344
1107
  /** Generic per-request/per-run filesystem binding seam. Hosts may return user/session-filtered bindings. */
@@ -1373,7 +1136,6 @@ interface RegisterAgentRoutesOptions {
1373
1136
  userId?: string;
1374
1137
  }) => string | undefined | Promise<string | undefined>;
1375
1138
  registerHealthRoute?: boolean;
1376
- sandboxHandleStore?: SandboxHandleStore;
1377
1139
  /**
1378
1140
  * Optional Lane W share-entry store (AR1-002/AR1-003, same-workspace
1379
1141
  * shareable links, `docs/issues/391/runtime-refactor/work/
@@ -1398,6 +1160,8 @@ interface RegisterAgentRoutesOptions {
1398
1160
  runtimeMode: RuntimeModeId;
1399
1161
  runtimeLayout: BoringAgentRuntimePaths;
1400
1162
  provisioningAdapter?: WorkspaceProvisioningAdapter;
1163
+ /** Already-created paired Workspace/Sandbox runtime for this binding. */
1164
+ runtimeBundle: RuntimeBundle;
1401
1165
  request?: FastifyRequest;
1402
1166
  /** Aborted when this binding retires; retirement still drains the task before provider disposal. */
1403
1167
  signal: AbortSignal;
@@ -1428,24 +1192,59 @@ interface RegisterAgentRoutesOptions {
1428
1192
  */
1429
1193
  onWorkspaceAgentDispatcher?: (resolver: WorkspaceAgentDispatcherResolver) => void;
1430
1194
  }
1195
+ interface AgentHostLegacyRouteScopePolicy {
1196
+ /** App-owned capability issuer for the already-created Host. */
1197
+ issueScope(input: {
1198
+ readonly claim: VerifiedAgentScopeClaim;
1199
+ readonly runtimeScope: ResolvedAgentRuntimeScope;
1200
+ }): AuthorizedAgentScope;
1201
+ /** True only for the legacy wrapper whose Host admission calls admitEffect. */
1202
+ readonly gatewayUsesLegacyAdmission?: boolean;
1203
+ }
1204
+ type AgentHostLegacyRoutePolicyOptions = Omit<RegisterAgentRoutesOptions, 'agentHost' | 'runtimeModeAdapter'> & {
1205
+ readonly runtimeModeAdapter: RuntimeModeAdapter;
1206
+ };
1207
+
1208
+ /** Normalize legacy options into the nested Host projection seam. */
1209
+ declare function createAgentHostLegacyRoutePolicy(options: AgentHostLegacyRoutePolicyOptions, scopePolicy: AgentHostLegacyRouteScopePolicy): AgentHostLegacyRoutePolicy;
1210
+
1431
1211
  /**
1432
- * Fastify plugin that mounts agent routes onto a host app (typically core-built).
1212
+ * Compatibility wrapper for legacy embedding callers.
1433
1213
  *
1434
- * Shape B counterpart to createAgentApp (Shape A). The host provides its own
1435
- * Fastify instance, auth, and stores; this plugin only adds routes + runtime.
1436
- * No auth middleware is registered — the host's authHook handles authentication.
1214
+ * It normalizes legacy construction inputs, creates or reuses exactly one Host,
1215
+ * and delegates the complete route profile through CreatedAgentHost.registerRoutes().
1437
1216
  */
1438
1217
  declare const registerAgentRoutes: FastifyPluginAsync<RegisterAgentRoutesOptions>;
1439
1218
 
1440
- interface LogFields {
1441
- [key: string]: unknown;
1219
+ interface CredentialStoreBackendV1 {
1220
+ read(workspaceId: string, providerId: ProviderId, allowedFieldIds: readonly CredentialFieldId[]): Promise<ResolvedCredentialMaterialV1 & {
1221
+ credentialVersion: number;
1222
+ }>;
1442
1223
  }
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;
1224
+ interface HostSideCredentialResolverOptionsV1 {
1225
+ readonly authorityVerifier: WorkspaceCredentialAuthorityVerifierV1;
1226
+ readonly bindingRegistry: CredentialConsumerBindingRegistryV1;
1227
+ readonly providerRegistry: ProviderRegistryV1;
1228
+ /**
1229
+ * Storage boundary only. Vault/KmsBackend composition is deferred to bead
1230
+ * 16f.2 and will implement this interface without changing the resolver.
1231
+ */
1232
+ readonly backend: CredentialStoreBackendV1;
1448
1233
  }
1449
- declare function createLogger(prefix: string): Logger;
1234
+ interface InMemoryCredentialBackendEntryV1 {
1235
+ readonly workspaceId: string;
1236
+ readonly providerId: ProviderId;
1237
+ readonly material: ResolvedCredentialMaterialV1;
1238
+ readonly credentialVersion: number;
1239
+ }
1240
+ interface FakeAuthorityVerifierGrantV1 {
1241
+ readonly scope: AuthorizedWorkspaceCredentialScopeV1;
1242
+ readonly authority: VerifiedWorkspaceCredentialAuthorityV1;
1243
+ }
1244
+ declare function createHostSideCredentialResolverV1(options: HostSideCredentialResolverOptionsV1): WorkspaceCredentialResolverV1;
1245
+ declare function createFakeAuthorityVerifierV1(grants: readonly FakeAuthorityVerifierGrantV1[]): WorkspaceCredentialAuthorityVerifierV1;
1246
+ declare function createInMemoryCredentialBackendV1(entries: readonly InMemoryCredentialBackendEntryV1[]): CredentialStoreBackendV1;
1247
+
1248
+ declare function withResolvedCredential<T>(resolver: WorkspaceCredentialResolverV1, workspace: AuthorizedWorkspaceCredentialScopeV1, ref: ProviderCredentialRefV1, fn: (lease: ResolvedCredentialLeaseV1) => T | Promise<T>): Promise<T>;
1450
1249
 
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 };
1250
+ export { AgentConfig, AgentDirectoryCompilerError, type AgentDirectoryCompilerErrorCode, type AgentDirectoryCompilerPublicErrorCode, AgentEffectAdmission, AgentFleetCompilationError, AgentFleetCompilationErrorCode, AgentFleetCompiler, type AgentFleetPluginBindingContract, AgentGatewayEffect, AgentHarnessFactory, AgentHostLegacyRoutePolicy, type AgentHostLegacyRoutePolicyOptions, type AgentHostLegacyRouteScopePolicy, AgentMeteringSink, AgentRequestKey, AgentRequestLedger, AgentRequestLedgerRecord, AgentRuntimeHostOperations, AuthoredAgentMaterializationError, type AuthoredAgentMaterializationErrorCode, type AuthoredAgentSourceV1, AuthorizedAgentScope, BuiltinRuntimeModeId, CompiledAgentHostAgentSpec, type CreateAgentAppOptions, CreateAgentHostOptions, type CreateValidatingAgentFleetCompilerOptions, CreatedAgentHost, type CredentialStoreBackendV1, type DeploymentSnapshotProvider, type DeploymentSnapshotRecipe, type DeploymentSnapshotResult, type DeploymentSnapshotStatus, EmbeddedAgentGateway, type FakeAuthorityVerifierGrantV1, type HostSideCredentialResolverOptionsV1, InMemoryAgentRequestLedger, type InMemoryCredentialBackendEntryV1, 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, MeteringErrorLogger, ModeContext, PiHarnessOptions, type PrebuiltAgentHostRoutePolicy, type ProvisionRuntimeWorkspaceOptions, ProvisionWorkspaceRuntimeOptions, type ProvisioningArtifactRequest, type RegisterAgentRoutesOptions, RemoteWorkerClient, RemoteWorkerClientError, type RemoteWorkerClientOptions, RemoteWorkerExecRequest, type RemoteWorkerModeAdapterOptions, RemoteWorkerWorkspaceOp, RemoteWorkerWorkspaceResult, type ResolvedAgent, type ResolvedAgentDigestInput, ResolvedAgentRuntimeScope, RuntimeBundle, type RuntimeEnvContribution, type RuntimeEnvContributionContext, RuntimeFilesystemBinding, RuntimeModeAdapter, RuntimeModeId, type RuntimeWorkspaceProvisioningResult, type SandboxRuntimeModeOptions, type ShareEntryMcpResourceOptions, UV_SETUP_COMMANDS, VerifiedAgentScopeClaim, type WorkspaceAgentDispatcherBinding, type WorkspaceAgentDispatcherResolveOptions, type WorkspaceAgentDispatcherResolver, WorkspaceProvisioningAdapter, WorkspaceProvisioningResult, applyCspHeaders, autoDetectMode, buildDeploymentSnapshotRecipe, compileAgentDirectory, constantTimeTokenEqual, createAgent, createAgentApp, createAgentHost, createAgentHostLegacyRoutePolicy, createDirectModeAdapter, createEnvironmentProvisioningFingerprint, createFakeAuthorityVerifierV1, createHostSideCredentialResolverV1, createInMemoryCredentialBackendV1, createLocalModeAdapter, createManagedAgentMcpDelegateController, createManagedAgentMcpHttpHandler, createManagedAgentMcpServer, createProviderRuntimeModeAdapter, createRemoteWorkerModeAdapter, createRemoteWorkerSandbox, createRemoteWorkerWorkspace, createResolvedAgentDigest, createResolvedRuntimeScopeIdentity, createSandboxRuntimeModeAdapter, createValidatingAgentFleetCompiler, createVercelSandboxModeAdapter, decodeBytesFromWorker, encodeBytesForWorker, hasBwrap, materializeAgentDirectory, prepareDeploymentSnapshot, provisionRuntimeWorkspace, provisionWorkspaceRuntime, registerAgentRoutes, registerShareEntryResources, resolveAgentDeployment, resolveBuiltinRuntimeLayoutRoot, resolveMode, resolveWorkspaceRoot, sandboxRuntimeHostOperations, shareResourceUri, withResolvedCredential };