@hachej/boring-agent 0.1.108 → 0.1.110

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 (30) hide show
  1. package/dist/{errors-CEU4iujR.d.ts → admin-DORVQfLn.d.ts} +80 -3
  2. package/dist/{chunk-GS4ADE34.js → chunk-42D6KAQV.js} +36 -12
  3. package/dist/{chunk-6OANSUEI.js → chunk-72KT6VWV.js} +59 -2
  4. package/dist/{chunk-3JFPS2O6.js → chunk-KJIEMSQP.js} +10 -1
  5. package/dist/{chunk-MVKXLMH3.js → chunk-KN72XWP7.js} +1 -1
  6. package/dist/{chunk-KDXIXVF6.js → chunk-V3H5A3BR.js} +12410 -5047
  7. package/dist/core/index.d.ts +5 -5
  8. package/dist/core/index.js +2 -1
  9. package/dist/{createHarness-AHWSC36D.js → createHarness-DOLOHA62.js} +2 -2
  10. package/dist/file-search-BUgMSKZE.d.ts +289 -0
  11. package/dist/front/index.d.ts +89 -4
  12. package/dist/front/index.js +508 -47
  13. package/dist/front/styles.css +55 -55
  14. package/dist/{harness-Ct0e4RWc.d.ts → harness-qHlMJhZo.d.ts} +1 -1
  15. package/dist/{piChatEvent-BUWIzw5l.d.ts → piChatEvent-DpE0lIb9.d.ts} +49 -17
  16. package/dist/{piChatSessionService-nvroRAVk.d.ts → piChatSessionService-CBct-hmz.d.ts} +4 -1
  17. package/dist/server/agent-host/testing/gatewayConformance.d.ts +7 -6
  18. package/dist/server/agent-host/testing/gatewayConformance.js +14 -7
  19. package/dist/server/index.d.ts +890 -56
  20. package/dist/server/index.js +73 -7
  21. package/dist/server/worker/index.js +5 -5
  22. package/dist/{lease-nASWv2tU.d.ts → share-entry-CxS6UJ_L.d.ts} +77 -179
  23. package/dist/shared/index.d.ts +118 -222
  24. package/dist/shared/index.js +17 -5
  25. package/dist/{types-B7-PN5jV.d.ts → types-DcWoQMn8.d.ts} +346 -10
  26. package/docs/AGENT_GATEWAY_V0.md +22 -2
  27. package/docs/AGENT_PACKAGES.md +15 -5
  28. package/docs/ERROR_CODES.md +14 -0
  29. package/package.json +10 -18
  30. package/dist/file-search-BGUHnW9o.d.ts +0 -87
@@ -1,34 +1,292 @@
1
- import { P as ProvisionWorkspaceRuntimeOptions, W as WorkspaceProvisioningResult, a as PiPackageSource, R as RuntimeModeAdapter, b as RuntimeModeId, B as BuiltinRuntimeModeId, c as AgentRuntimeHostOperations, d as RuntimeBashStrategy, e as RuntimeFilesystemStrategy, M as ModeContext, f as WorkspaceProvisioningAdapter, g as AgentInstructionSource, C as ConfiguredAgentHostAgentSpec, h as AgentInstructionFileRef, i as AgentHostAgentSpec, j as RuntimeBundle, k as PiHarnessOptions, l as AgentMeteringSink, m as RuntimeFilesystemBinding, n as CreatedAgentHost, o as ResolvedPiHarnessOptions, p as ReadyStatusTracker, q as CreateAgentHostOptions, r as CompiledAgentHostAgentSpec, s as AgentRequestLedger, t as AgentEffectAdmission, u as AuthorizedEnvironmentIntent, v as AgentHostEnvironmentScope, w as ResolvedAgentRuntimeScope, x as AgentRequestKey, y as AgentRequestLedgerPrepareResult, z as AgentRequestFailure, D as AgentRequestLedgerRecord, E as AgentFleetCompiler, F as AgentRequestTarget, G as RuntimeFilesystemAccessDecision } from '../types-B7-PN5jV.js';
2
- export { A as AgentGatewayEffect, H as AgentHostDescription, I as AgentHostDirectProjectionOptions, J as AgentHostDispatcherRunInput, K as AgentHostEnvironmentLease, L as AgentHostHandle, N as DEFAULT_AGENT_TYPE_ID, O as MeteringErrorLogger, Q as MeteringReleaseInput, S as MeteringReleaseReason, T as MeteringReservationResult, U as MeteringReserveInput, V as MeteringRunKind, X as MeteringRunScope, Y as MeteringRunStatus, Z as MeteringSettleInput, _ as MeteringUsage, $ as MeteringUsageInput, a0 as PI_PACKAGE_RESOURCE_FILTERS, a1 as PiExtensionFactory, a2 as PluginSkillSource, a3 as ResolvedEnvironmentScope, a4 as RuntimeFilesystemBindingOperations, a5 as RuntimeNodePackageSpec, a6 as RuntimeProvisioningContribution, a7 as RuntimePythonSpec, a8 as RuntimeTemplateContribution, a9 as WorkspaceProvisioningExecResult, aa as compactPiPackages, ab as mergePiPackageSources, ac as normalizeMeteringUsage, ad as piPackageSourceKey } from '../types-B7-PN5jV.js';
1
+ import { P as ProvisionWorkspaceRuntimeOptions, W as WorkspaceProvisioningResult, a as PiPackageSource, C as CredentialVaultPersistenceV2, b as CredentialMaterialKindV1, c as WorkspaceCredentialLockOptionsV1, S as StoredCredentialRecordV1, d as StoredCredentialMetadataV1, R as RuntimeModeAdapter, e as RuntimeModeId, B as BuiltinRuntimeModeId, f as AgentRuntimeHostOperations, g as RuntimeBashStrategy, h as RuntimeFilesystemStrategy, M as ModeContext, i as WorkspaceProvisioningAdapter, j as AgentInstructionSource, k as ConfiguredAgentHostAgentSpec, l as AgentInstructionFileRef, m as AgentHostAgentSpec, n as RuntimeBundle, o as PiHarnessOptions, p as AgentMeteringSink, q as AgentHostCredentialOptionsV1, r as RuntimeFilesystemBinding, E as EventStreamStore, s as CreatedAgentHost, t as ResolvedPiHarnessOptions, u as ReadyStatusTracker, v as CreateAgentHostOptions, w as CompiledAgentHostAgentSpec, x as AgentRequestLedger, y as AgentEffectAdmission, z as AuthorizedEnvironmentIntent, D as AgentHostEnvironmentScope, F as ResolvedAgentRuntimeScope, G as AgentRequestKey, H as AcceptedWorkContext, I as AgentRequestLedgerPrepareResult, J as AgentRequestFailure, K as AgentRequestLedgerRecord, L as AgentFleetCompiler, N as AgentRequestTarget, O as RuntimeFilesystemAccessDecision } from '../types-DcWoQMn8.js';
2
+ export { A as AgentGatewayEffect, Q as AgentHostDescription, T as AgentHostDirectProjectionOptions, U as AgentHostDispatcherRunInput, V as AgentHostEnvironmentLease, X as AgentHostHandle, Y as CredentialVaultPersistenceV1, Z as DEFAULT_AGENT_TYPE_ID, _ as MeteringErrorLogger, $ as MeteringReleaseInput, a0 as MeteringReleaseReason, a1 as MeteringReservationResult, a2 as MeteringReserveInput, a3 as MeteringRunKind, a4 as MeteringRunScope, a5 as MeteringRunStatus, a6 as MeteringSettleInput, a7 as MeteringUsage, a8 as MeteringUsageInput, a9 as PI_PACKAGE_RESOURCE_FILTERS, aa as PiExtensionFactory, ab as PluginSkillSource, ac as ResolvedEnvironmentScope, ad as RuntimeFilesystemBindingOperations, ae as RuntimeNodePackageSpec, af as RuntimeProvisioningContribution, ag as RuntimePythonSpec, ah as RuntimeTemplateContribution, ai as WorkspaceCredentialLifecycleV1, aj as WorkspaceProvisioningExecResult, ak as compactPiPackages, al as mergePiPackageSources, am as normalizeMeteringUsage, an as piPackageSourceKey } from '../types-DcWoQMn8.js';
3
3
  import { d as ExecOptions, a as ExecResult, W as WorkspaceChangeEvent, b as Workspace, c as Sandbox } from '../sandbox-BMhut3kh.js';
4
4
  export { h as RuntimeFilesystemCapability } from '../sandbox-BMhut3kh.js';
5
5
  import { b as RemoteWorkerHealthResponse, R as RemoteWorkerWorkspaceOp, a as RemoteWorkerWorkspaceResult, c as RemoteWorkerExecRequest } from '../middleware-CaAEXpi5.js';
6
6
  export { d as REMOTE_WORKER_EXCLUSIVE_BINARY_CREATE_CAPABILITY, e as REMOTE_WORKER_PROVIDER, f as REMOTE_WORKER_RUNTIME_CWD, g as RemoteWorkerErrorPayload, h as RemoteWorkerExecResponse, i as RemoteWorkerFsEventEnvelope, W as WORKER_INTERNAL_TOKEN_HEADER, j as WORKER_REQUEST_ID_HEADER, k as WORKER_WORKSPACE_ID_HEADER, l as createAgentAuthMiddleware } from '../middleware-CaAEXpi5.js';
7
7
  import { SandboxProviderV1, WorkspaceSandboxPairV1 } from '@hachej/boring-sandbox/shared';
8
8
  import { BwrapSandboxProviderOptions } from '@hachej/boring-sandbox/providers/bwrap';
9
- import { F as SandboxHandleStore, k as CompiledAgentBundle, a as Sha256Digest, i as AgentDeployment, M as ShareEntryStore, y as ProviderId, c as CredentialFieldId, B as ResolvedCredentialMaterialV1, d as AuthorizedWorkspaceCredentialScopeV1, V as VerifiedWorkspaceCredentialAuthorityV1, X as WorkspaceCredentialAuthorityVerifierV1, n as CredentialConsumerBindingRegistryV1, z as ProviderRegistryV1, Y as WorkspaceCredentialResolverV1, P as ProviderCredentialRefV1, R as ResolvedCredentialLeaseV1 } from '../lease-nASWv2tU.js';
10
- import { z as ErrorCode, o as SessionCtx, a as SessionListOptions, b as SessionSummary, c as PiChatSnapshot, d as PiChatEvent, e as PromptReceipt, F as FollowUpPayload, f as FollowUpReceipt, Q as QueueClearPayload, g as QueueClearReceipt, I as InterruptPayload, h as CommandReceipt, i as StopPayload, j as StopReceipt, S as SessionStore } from '../piChatEvent-BUWIzw5l.js';
11
- import { B as JsonValue, A as AgentGateway, a as AuthorizedAgentScope, b as AgentSessionRef, c as AgentSessionActivity, V as VerifiedAgentScopeClaim, g as AgentAccessOperation, f as AgentAccessDecision, k as AgentGatewayErrorDTO, r as AgentSessionSummary, q as AgentSessionStateSnapshot, n as AgentSessionConnection } from '../errors-CEU4iujR.js';
12
- export { F as ResolveAgentAccess, G as ResolveAgentAccessInput } from '../errors-CEU4iujR.js';
13
- import { d as AgentActor, j as AgentEvent, w as TelemetrySink, s as AgentTool, D as AgentHarnessFactory, A as AgentHarness } from '../harness-Ct0e4RWc.js';
14
- export { u as AgentConfig, E as AgentHarnessFactoryInput } from '../harness-Ct0e4RWc.js';
9
+ import { r as ResolvedCredentialMaterialV1, k as CredentialConsumerBindingRegistryV1, W as WorkspaceCredentialResolverV1, t as SandboxHandleStore, C as CompiledAgentBundle, a as Sha256Digest, g as AgentDeployment, z as ShareEntryStore, P as ProviderCredentialRefV1, R as ResolvedCredentialLeaseV1 } from '../share-entry-CxS6UJ_L.js';
10
+ import { H as ErrorCode, k as SessionCtx, O as OriginChannel, a as SessionListOptions, b as SessionSummary, U as SessionCreateInit, c as PiChatSnapshot, d as PiChatEvent, e as PromptReceipt, F as FollowUpPayload, f as FollowUpReceipt, Q as QueueClearPayload, g as QueueClearReceipt, I as InterruptPayload, h as CommandReceipt, i as StopPayload, j as StopReceipt, S as SessionStore } from '../piChatEvent-DpE0lIb9.js';
11
+ import { B as CredentialLifecycleStateV1, P as JsonValue, A as AgentGateway, a as AuthorizedAgentScope, b as AgentSessionRef, c as AgentSessionActivity, V as VerifiedAgentScopeClaim, g as AgentAccessOperation, f as AgentAccessDecision, k as AgentGatewayErrorDTO, r as AgentSessionSummary, q as AgentSessionStateSnapshot, n as AgentSessionConnection } from '../admin-DORVQfLn.js';
12
+ export { T as ResolveAgentAccess, U as ResolveAgentAccessInput } from '../admin-DORVQfLn.js';
13
+ import { d as AgentActor, j as AgentEvent, w as TelemetrySink, s as AgentTool, D as AgentHarnessFactory, A as AgentHarness } from '../harness-qHlMJhZo.js';
14
+ export { u as AgentConfig, E as AgentHarnessFactoryInput } from '../harness-qHlMJhZo.js';
15
15
  import { IncomingMessage, ServerResponse } from 'node:http';
16
16
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
17
17
  import { FastifyRequest, FastifyInstance, FastifyPluginCallback } from 'fastify';
18
- import { i as PiSessionRequestContext, j as AgentPromptPayload, k as PiChatAttachmentResult } from '../piChatSessionService-nvroRAVk.js';
19
- import { c as WorkspaceAgentDirectRunInput, W as WorkspaceAgentDirectRunCallback, f as WorkspaceAgentDispatcherContext, e as WorkspaceAgentDispatcher, i as WorkspaceAgentGatewayBinding } from '../file-search-BGUHnW9o.js';
20
- export { L as LeaseBoundWorkspaceAgent } from '../file-search-BGUHnW9o.js';
21
- import { SettingsManager } from '@mariozechner/pi-coding-agent';
18
+ import { i as PiSessionRequestContext, j as AgentPromptPayload, k as PiChatAttachmentResult } from '../piChatSessionService-CBct-hmz.js';
19
+ import { P as ProviderId, I as WorkspaceKekProviderV1, a as CredentialFieldId, B as WorkspaceCredentialAuthorityVerifierV1, b as ProviderRegistryV1, t as WorkspaceAgentDirectRunInput, s as WorkspaceAgentDirectRunCallback, w as WorkspaceAgentDispatcherContext, v as WorkspaceAgentDispatcher, z as WorkspaceAgentGatewayBinding, C as CredentialConsumerBindingId, N as AgentInvocationFundingPolicyV1, A as AuthorizedWorkspaceCredentialScopeV1 } from '../file-search-BUgMSKZE.js';
20
+ export { L as LeaseBoundWorkspaceAgent } from '../file-search-BUgMSKZE.js';
21
+ import { CredentialStore, AuthPrompt } from '@earendil-works/pi-ai';
22
+ import { SettingsManager, ModelRuntime } from '@mariozechner/pi-coding-agent';
23
+ import postgres from 'postgres';
22
24
  import '@hachej/boring-bash/agent';
23
25
  import '@hachej/boring-sandbox/providers/node-workspace';
24
26
  import 'zod';
25
27
 
28
+ interface SqlResult {
29
+ toArray(): Array<Record<string, unknown>>;
30
+ }
31
+ interface SqlStorage {
32
+ exec(query: string, ...bindings: unknown[]): SqlResult;
33
+ }
34
+ /**
35
+ * `deferred` (SQLite's plain `BEGIN`) postpones acquiring any lock until the
36
+ * first read or write inside the transaction. That is fine for read-only
37
+ * transactions, but a transaction that reads THEN writes (e.g. a
38
+ * check-then-insert) starts under a read lock and must upgrade to a write
39
+ * lock mid-transaction — and SQLite refuses that upgrade with SQLITE_BUSY
40
+ * immediately if another connection holds the write lock, WITHOUT honoring
41
+ * `busy_timeout` (the busy handler only runs for the initial lock
42
+ * acquisition, not a lock *upgrade*). `immediate` (`BEGIN IMMEDIATE`)
43
+ * acquires the write lock up front, so `busy_timeout` applies normally and
44
+ * a concurrent writer simply waits instead of erroring. Use `immediate` for
45
+ * any transaction that writes — especially read-then-write — and reserve
46
+ * `deferred` for genuinely read-only transactions.
47
+ */
48
+ type SqlTransactionMode = 'deferred' | 'immediate';
49
+ type RunTransaction = <T>(fn: () => T, mode?: SqlTransactionMode) => T;
50
+
26
51
  declare function provisionWorkspaceRuntime(opts: ProvisionWorkspaceRuntimeOptions): Promise<WorkspaceProvisioningResult>;
27
52
 
28
53
  declare function createResourceSettingsManager(cwd: string, agentDir: string, piPackages: PiPackageSource[], options?: {
29
54
  includePackage?: (source: PiPackageSource) => boolean;
55
+ includeConfiguredPackages?: boolean;
30
56
  }): SettingsManager;
31
57
 
58
+ declare function createInMemoryCredentialVaultPersistenceV1(): CredentialVaultPersistenceV2;
59
+
60
+ interface PostgresCredentialVaultPersistenceOptionsV1 {
61
+ /** Independently pooled connection used only to evict an uncertain lock holder. */
62
+ readonly evictionSql: postgres.Sql;
63
+ /** Default bound for advisory-lock acquisition. */
64
+ readonly lockAcquireTimeoutMs?: number;
65
+ /** Delay between non-blocking advisory-lock attempts. */
66
+ readonly lockPollIntervalMs?: number;
67
+ /** Bound for confirming advisory unlock before evicting the connection. */
68
+ readonly lockReleaseTimeoutMs?: number;
69
+ }
70
+ type Sql = postgres.Sql | postgres.TransactionSql;
71
+ declare function createPostgresCredentialVaultPersistenceV1(sql: Sql, options: PostgresCredentialVaultPersistenceOptionsV1): CredentialVaultPersistenceV2;
72
+
73
+ /** Deployment-owned schema registration for durable credential vault storage. */
74
+ declare function runCredentialVaultPostgresMigrationsV1(sql: postgres.Sql): Promise<void>;
75
+
76
+ interface WorkspaceCredentialVersionStateV1 {
77
+ readonly counter: number;
78
+ /** Monotonic irreversible fence; any positive value means the workspace was shredded. */
79
+ readonly cryptoShredGeneration: number;
80
+ /** Monotonic workspace-wide fence for replayed wrapped DEKs and records. */
81
+ readonly dekGeneration: number;
82
+ /** Authenticated idempotency receipts for completed DEK rotations. */
83
+ readonly dekRotationReceipts: Readonly<Record<string, number>>;
84
+ readonly credentialVersions: Readonly<Record<string, number>>;
85
+ readonly credentialMaterialKinds: Readonly<Record<string, CredentialMaterialKindV1>>;
86
+ readonly credentialFieldIds: Readonly<Record<string, readonly string[]>>;
87
+ readonly credentialLifecycleStates: Readonly<Record<string, CredentialLifecycleStateV1>>;
88
+ readonly credentialTypes: Readonly<Record<string, string>>;
89
+ }
90
+ interface PendingCredentialVersionMutationV1 {
91
+ readonly operationId: string;
92
+ readonly providerId: ProviderId;
93
+ readonly expectedStateDigest: string;
94
+ readonly nextStateDigest: string;
95
+ readonly nextCredentialVersion: number;
96
+ readonly nextCredentialMaterialKind: CredentialMaterialKindV1;
97
+ readonly nextCredentialFieldIds: readonly string[];
98
+ readonly nextCredentialLifecycleState: CredentialLifecycleStateV1;
99
+ readonly nextCredentialType: string;
100
+ readonly nextDekGeneration: number;
101
+ }
102
+ interface CredentialVersionMutationStateV1 {
103
+ readonly nextCredentialVersion: number;
104
+ readonly nextCredentialMaterialKind: CredentialMaterialKindV1;
105
+ readonly nextCredentialFieldIds: readonly string[];
106
+ readonly nextCredentialLifecycleState: CredentialLifecycleStateV1;
107
+ readonly nextCredentialType: string;
108
+ readonly nextDekGeneration: number;
109
+ }
110
+ interface CredentialVersionMutationResultV1<T> {
111
+ readonly nextCredentialVersion: number;
112
+ readonly nextCredentialMaterialKind: CredentialMaterialKindV1;
113
+ readonly nextCredentialFieldIds: readonly string[];
114
+ readonly nextCredentialLifecycleState: CredentialLifecycleStateV1;
115
+ readonly nextCredentialType: string;
116
+ readonly nextDekGeneration: number;
117
+ readonly result: T;
118
+ }
119
+ /**
120
+ * V2 write-ahead mutation contract. The anchor seals both authenticated digests
121
+ * before invoking `commit`, then finalizes only after `commit` succeeds.
122
+ */
123
+ type CredentialVersionMutationResultV2<T> = CredentialVersionMutationStateV1 & {
124
+ readonly expectedStateDigest: string;
125
+ readonly nextStateDigest: string;
126
+ readonly commit: () => Promise<T>;
127
+ };
128
+ interface DekGenerationMutationResultV1<T> {
129
+ readonly nextDekGeneration: number;
130
+ readonly nextDekRotationOperationId: string;
131
+ readonly result: T;
132
+ }
133
+ interface CredentialLifecycleMutationResultV1<T> {
134
+ readonly nextCredentialLifecycleState: CredentialLifecycleStateV1;
135
+ readonly result: T;
136
+ }
137
+ interface CryptoShredMutationResultV1<T> {
138
+ readonly result: T;
139
+ }
140
+ interface CredentialVersionAnchorReadOptionsV1 {
141
+ /**
142
+ * A provider-list probe may treat a never-provisioned anchor file as empty
143
+ * only when persistence has no credential metadata. Existing malformed or
144
+ * unauthenticated anchor files still fail closed.
145
+ */
146
+ readonly allowUnprovisioned?: boolean;
147
+ }
148
+ type CredentialVersionAnchorReaderV1 = (options?: CredentialVersionAnchorReadOptionsV1) => Promise<WorkspaceCredentialVersionStateV1 | undefined>;
149
+ interface WorkspaceCredentialVersionAnchorV1 {
150
+ read(workspaceId: string, options?: CredentialVersionAnchorReadOptionsV1): Promise<WorkspaceCredentialVersionStateV1 | undefined>;
151
+ /** Serializes a persistence inspection with anchor mutations. */
152
+ withReadLock<T>(workspaceId: string, inspect: (readLocked: CredentialVersionAnchorReaderV1) => Promise<T>): Promise<T>;
153
+ /**
154
+ * Holds the external workspace mutation lock through the supplied DB CAS.
155
+ * If the DB commit succeeds but advancing this external anchor fails, the
156
+ * mismatch deliberately fail-stops; accepting DB-ahead state would turn an
157
+ * attacker replay into an automatic rollback. S1 prefers security over
158
+ * availability here and does not claim cross-store crash atomicity.
159
+ */
160
+ withMutation<T>(workspaceId: string, providerId: ProviderId, mutate: (current: WorkspaceCredentialVersionStateV1 | undefined) => Promise<CredentialVersionMutationResultV1<T>>): Promise<T>;
161
+ /** Authenticates a lifecycle-only state transition without minting a version. */
162
+ withLifecycleMutation<T>(workspaceId: string, providerId: ProviderId, mutate: (current: WorkspaceCredentialVersionStateV1 | undefined) => Promise<CredentialLifecycleMutationResultV1<T>>): Promise<T>;
163
+ /**
164
+ * Irreversibly advances the authenticated external shred fence before
165
+ * destructive persistence finalization. Repeated calls retain the fence and
166
+ * re-run finalization so cleanup is recoverable and idempotent.
167
+ */
168
+ withCryptoShredMutation<T>(workspaceId: string, mutate: (current: WorkspaceCredentialVersionStateV1) => Promise<CryptoShredMutationResultV1<T>>): Promise<T>;
169
+ /** Advances the authenticated workspace DEK fence exactly one generation. */
170
+ withDekGenerationMutation<T>(workspaceId: string, mutate: (current: WorkspaceCredentialVersionStateV1 | undefined) => Promise<DekGenerationMutationResultV1<T>>): Promise<T>;
171
+ }
172
+ /** Recovery-capable authority required by the durable vault backend. */
173
+ interface WorkspaceCredentialVersionAnchorV2 extends WorkspaceCredentialVersionAnchorV1 {
174
+ readonly contractVersion: 'boring.workspace-credential-version-anchor.v2';
175
+ readPendingMutation(workspaceId: string, options?: CredentialVersionAnchorReadOptionsV1): Promise<PendingCredentialVersionMutationV1 | undefined>;
176
+ recoverPendingMutation(workspaceId: string, durableStateDigest: string): Promise<void>;
177
+ /**
178
+ * Holds the external workspace mutation lock through a write-ahead,
179
+ * KEK-authenticated intent, the supplied DB CAS, and anchor finalization.
180
+ * This is recoverable deferred commit, not cross-store atomicity.
181
+ */
182
+ withRecoverableMutation<T>(workspaceId: string, providerId: ProviderId, mutate: (current: WorkspaceCredentialVersionStateV1 | undefined) => Promise<CredentialVersionMutationResultV2<T>>): Promise<T>;
183
+ }
184
+ /** Test/development anchor. Production local-KEK composition uses the sealed file adapter. */
185
+ declare function createInMemoryCredentialVersionAnchorV1(): WorkspaceCredentialVersionAnchorV2;
186
+ interface LocalCredentialVersionAnchorOptionsV1 {
187
+ readonly anchorFilePath: string;
188
+ readonly loadKek: () => Promise<Uint8Array>;
189
+ }
190
+ /** Explicit one-time provisioning; refuses to replace an existing anchor. */
191
+ declare function initializeLocalFileCredentialVersionAnchorV1(options: LocalCredentialVersionAnchorOptionsV1): Promise<void>;
192
+ /**
193
+ * Local-KEK rollback anchor. The pre-provisioned file lives on the
194
+ * operator-controlled durable mount beside the KEK, never in Postgres or a
195
+ * workspace. One counter advances per workspace; authenticated provider
196
+ * context is necessary because unchanged providers legitimately trail it.
197
+ *
198
+ * S1 rejects a replayed DB current-version pointer. It only narrows exposure:
199
+ * S2 makes exfiltrated old ciphertext cryptographically dead by destroying the
200
+ * superseded DEK generation.
201
+ */
202
+ declare function createLocalFileCredentialVersionAnchorV1(options: LocalCredentialVersionAnchorOptionsV1): WorkspaceCredentialVersionAnchorV2;
203
+
204
+ /**
205
+ * Convenience composition for self-host deployments. Returns `undefined` when
206
+ * the local-KEK backend was not explicitly selected; the caller must then fail
207
+ * closed rather than substitute a default.
208
+ */
209
+ declare function createLocalKekWorkspaceKekProviderFromEnvV1(env: Readonly<Record<string, string | undefined>>): WorkspaceKekProviderV1 | undefined;
210
+ declare function createLocalCredentialVersionAnchorFromEnvV1(env: Readonly<Record<string, string | undefined>>): WorkspaceCredentialVersionAnchorV2 | undefined;
211
+
212
+ interface CredentialStoreBackendV1 {
213
+ read(workspaceId: string, providerId: ProviderId, allowedFieldIds: readonly CredentialFieldId[]): Promise<ResolvedCredentialMaterialV1 & {
214
+ credentialVersion: number;
215
+ }>;
216
+ }
217
+ interface HostSideCredentialResolverOptionsV1 {
218
+ readonly authorityVerifier: WorkspaceCredentialAuthorityVerifierV1;
219
+ readonly bindingRegistry: CredentialConsumerBindingRegistryV1;
220
+ readonly providerRegistry: ProviderRegistryV1;
221
+ /**
222
+ * Storage boundary only. Vault/KmsBackend composition is deferred to bead
223
+ * 16f.2 and will implement this interface without changing the resolver.
224
+ */
225
+ readonly backend: CredentialStoreBackendV1;
226
+ }
227
+ interface InMemoryCredentialBackendEntryV1 {
228
+ readonly workspaceId: string;
229
+ readonly providerId: ProviderId;
230
+ readonly material: ResolvedCredentialMaterialV1;
231
+ readonly credentialVersion: number;
232
+ }
233
+ declare function createHostSideCredentialResolverV1(options: HostSideCredentialResolverOptionsV1): WorkspaceCredentialResolverV1;
234
+ declare function createInMemoryCredentialBackendV1(entries: readonly InMemoryCredentialBackendEntryV1[]): CredentialStoreBackendV1;
235
+
236
+ /**
237
+ * Composes a `WorkspaceKekProviderV1` (KmsBackend) with AAD-bound AES-256-GCM
238
+ * field crypto and an injectable persistence port into the
239
+ * `CredentialStoreBackendV1` that `createHostSideCredentialResolverV1` already
240
+ * consumes. The resolver contract is unchanged.
241
+ *
242
+ * Fail-closed rules: an unready backend, an unknown record, a wrong/absent
243
+ * KEK, or any tampered ciphertext/nonce/tag/AAD component throws a stable
244
+ * `CredentialResolutionError`. Nothing here ever returns "absent" in place of
245
+ * an authentication failure, and nothing ever falls back to another backend or
246
+ * to plaintext. Plaintext DEKs and field values are overwritten in `finally` on
247
+ * a best-effort basis (Node/V8 cannot guarantee erasure).
248
+ */
249
+ interface VaultCredentialStoreOptionsV1$1 {
250
+ readonly kmsBackend: WorkspaceKekProviderV1;
251
+ readonly persistence: CredentialVaultPersistenceV2;
252
+ readonly versionAnchor: WorkspaceCredentialVersionAnchorV2;
253
+ }
254
+ interface WriteCredentialFieldsInputV1 {
255
+ readonly workspaceId: string;
256
+ readonly providerId: ProviderId;
257
+ readonly credentialId?: string;
258
+ readonly fields: ReadonlyMap<CredentialFieldId, Uint8Array>;
259
+ readonly metadata?: Readonly<{
260
+ displayLabel?: string;
261
+ credentialType?: string;
262
+ maskedLastFourSuffix?: string;
263
+ }>;
264
+ }
265
+ interface VaultCredentialStoreBackendV1 extends CredentialStoreBackendV1 {
266
+ read(workspaceId: string, providerId: ProviderId, allowedFieldIds: readonly CredentialFieldId[], options?: WorkspaceCredentialLockOptionsV1): Promise<ResolvedCredentialMaterialV1 & {
267
+ credentialVersion: number;
268
+ }>;
269
+ /** Cross-process workspace serialization for Pi CredentialStore.modify(). */
270
+ withWorkspaceLock<T>(workspaceId: string, mutate: (locked: VaultCredentialStoreBackendV1) => Promise<T>, options?: WorkspaceCredentialLockOptionsV1): Promise<T>;
271
+ /**
272
+ * Writes (or rotates to) a new credential version for a workspace/provider.
273
+ * Every write mints a fresh credential version; nonces are never reused.
274
+ */
275
+ writeCredentialFields(input: WriteCredentialFieldsInputV1): Promise<StoredCredentialRecordV1>;
276
+ /** Marks a workspace/provider credential as deliberately field-less. */
277
+ writeAbsentCredential(workspaceId: string, providerId: ProviderId, options?: WorkspaceCredentialLockOptionsV1): Promise<StoredCredentialRecordV1>;
278
+ getCredentialMetadata(workspaceId: string, providerId: ProviderId): Promise<StoredCredentialMetadataV1 | undefined>;
279
+ listCredentialMetadata(workspaceId: string): Promise<readonly StoredCredentialMetadataV1[]>;
280
+ setCredentialLifecycleState(workspaceId: string, providerId: ProviderId, state: CredentialLifecycleStateV1): Promise<StoredCredentialMetadataV1>;
281
+ /** Rotates the KEK wrapping for one workspace DEK generation in place. */
282
+ rewrapWorkspaceDek(workspaceId: string, dekGeneration: number): Promise<void>;
283
+ /** Re-encrypts all live workspace credentials under a fresh DEK generation. */
284
+ rotateWorkspaceDek(workspaceId: string, operationId: string): Promise<number>;
285
+ /** Irreversibly destroys workspace credential key access and fails closed thereafter. */
286
+ cryptoShredWorkspace(workspaceId: string): Promise<void>;
287
+ }
288
+ declare function createVaultCredentialStoreBackendV1(options: VaultCredentialStoreOptionsV1$1): VaultCredentialStoreBackendV1;
289
+
32
290
  /**
33
291
  * uv setup for Python-family runtimes (e.g. Vercel `python3.13`), which already
34
292
  * ship `pip` and usually `uv`. Verify-or-install via the on-PATH `uv`.
@@ -408,10 +666,9 @@ declare class FleetConfigError extends Error {
408
666
  * descriptors, `.agents/factory/policy.yaml` `models.seats` tiers, and the
409
667
  * priority-ordered `models.tiers` candidates declared in fleet.yaml.
410
668
  *
411
- * Fails startup when any configured seat cannot materialize or verify. Only
412
- * genuinely unseated discovered packages remain nonfatal diagnostics. Whole-
413
- * fleet config errors (including unreadable/malformed fleet or policy YAML)
414
- * throw `FleetConfigError`.
669
+ * Excludes an individual package when a configured seat cannot materialize or
670
+ * verify, allowing valid sibling seats to boot. Whole-fleet config errors
671
+ * (including unreadable/malformed fleet or policy YAML) throw `FleetConfigError`.
415
672
  */
416
673
  declare function loadConfiguredAgentFleet(options: LoadConfiguredAgentFleetOptions): Promise<LoadConfiguredAgentFleetResult>;
417
674
 
@@ -467,9 +724,10 @@ interface ResolveDefaultAgentFleetOptions {
467
724
  * Resolves one deployment-static fleet for Core, Workspace, and CLI hosts.
468
725
  *
469
726
  * The built-in default is a regular configured Agent. When authored fleet
470
- * discovery is enabled it remains available alongside discovered seats so old
471
- * `default` session references stay routable. Invalid enabled fleet
472
- * composition fails boot; it never degrades to a pseudo-Agent.
727
+ * discovery is enabled it remains available alongside valid discovered seats
728
+ * so old `default` session references stay routable. Missing fleet config and
729
+ * individual package failures degrade to that valid subset; malformed whole-
730
+ * fleet configuration still rejects boot.
473
731
  */
474
732
  declare function resolveDefaultAgentFleet(options: ResolveDefaultAgentFleetOptions): Promise<readonly AgentHostAgentSpec[]>;
475
733
 
@@ -812,6 +1070,7 @@ interface CreateStandaloneAgentHostAppOptions {
812
1070
  sessionNamespace?: string;
813
1071
  telemetry?: TelemetrySink;
814
1072
  metering?: AgentMeteringSink;
1073
+ credentials?: AgentHostCredentialOptionsV1;
815
1074
  getFilesystemBindings?: (ctx: {
816
1075
  request?: FastifyRequest;
817
1076
  sessionId?: string;
@@ -875,6 +1134,441 @@ interface CreateStandaloneAgentHostAppOptions {
875
1134
  /** Thin standalone HTTP shell over one directly composed CreatedAgentHost. */
876
1135
  declare function createStandaloneAgentHostApp(options?: CreateStandaloneAgentHostAppOptions): Promise<FastifyInstance>;
877
1136
 
1137
+ type ChannelBindingStatus = 'active' | 'revoked';
1138
+ type ChannelInboundStatus = 'pending' | 'processing' | 'processed' | 'parked';
1139
+ type ChannelOutboundStatus = 'active' | 'parked';
1140
+ interface ChannelBinding {
1141
+ readonly channel: string;
1142
+ readonly conversationKey: string;
1143
+ readonly agentTypeId: string;
1144
+ readonly workspaceId: string;
1145
+ readonly authSubjectId: string;
1146
+ readonly bindingVersion: number;
1147
+ readonly status: ChannelBindingStatus;
1148
+ readonly sessionKey?: string;
1149
+ readonly lastInboundAt?: number;
1150
+ readonly outboundCursor: string;
1151
+ readonly outboundStatus: ChannelOutboundStatus;
1152
+ readonly sessionResetPending: boolean;
1153
+ readonly templateSentForInboundAt?: number;
1154
+ }
1155
+ interface ProvisionChannelBindingInput extends Omit<ChannelBinding, 'bindingVersion' | 'status' | 'lastInboundAt' | 'outboundCursor' | 'outboundStatus' | 'sessionResetPending' | 'templateSentForInboundAt'> {
1156
+ readonly status?: ChannelBindingStatus;
1157
+ /** Tail of an existing target stream; omitted only for a new/empty session. */
1158
+ readonly outboundCursor?: string;
1159
+ }
1160
+ interface InboundChannelMessage {
1161
+ readonly channel: string;
1162
+ readonly conversationKey: string;
1163
+ readonly providerMessageId: string;
1164
+ readonly text: string;
1165
+ readonly receivedAt: number;
1166
+ }
1167
+ interface QueuedChannelInbound extends InboundChannelMessage {
1168
+ readonly id: number;
1169
+ readonly agentTypeId: string;
1170
+ readonly workspaceId: string;
1171
+ readonly authSubjectId: string;
1172
+ readonly bindingVersion: number;
1173
+ readonly claimOwner: string;
1174
+ readonly attempts: number;
1175
+ readonly status: ChannelInboundStatus;
1176
+ readonly errorCode?: string;
1177
+ }
1178
+ type EnqueueInboundResult = {
1179
+ readonly disposition: 'enqueued';
1180
+ readonly binding: ChannelBinding;
1181
+ readonly queueId: number;
1182
+ } | {
1183
+ readonly disposition: 'duplicate';
1184
+ readonly binding?: ChannelBinding;
1185
+ } | {
1186
+ readonly disposition: 'unknown_binding';
1187
+ };
1188
+ interface ChannelIntentionRecord {
1189
+ readonly questionId: string;
1190
+ readonly sessionId: string;
1191
+ readonly channel: string;
1192
+ readonly conversationKey: string;
1193
+ readonly agentTypeId: string;
1194
+ readonly bindingVersion: number;
1195
+ readonly fieldName: string;
1196
+ readonly options: readonly {
1197
+ value: string;
1198
+ label: string;
1199
+ description?: string;
1200
+ }[];
1201
+ readonly title?: string;
1202
+ readonly context?: string;
1203
+ readonly status: 'pending' | 'projecting' | 'window-held' | 'projected' | 'answering' | 'answered' | 'closed';
1204
+ readonly answerValues?: Readonly<Record<string, unknown>>;
1205
+ readonly answerProviderMessageId?: string;
1206
+ }
1207
+ type ClaimIntentionReplyResult = {
1208
+ readonly disposition: 'claimed';
1209
+ readonly intention: ChannelIntentionRecord;
1210
+ } | {
1211
+ readonly disposition: 'duplicate';
1212
+ } | {
1213
+ readonly disposition: 'no_intention';
1214
+ };
1215
+ type ClaimInvalidIntentionReplyResult = {
1216
+ readonly disposition: 'claimed';
1217
+ } | {
1218
+ readonly disposition: 'duplicate';
1219
+ } | {
1220
+ readonly disposition: 'no_intention';
1221
+ };
1222
+ type NextInboundResult = {
1223
+ readonly disposition: 'claimed';
1224
+ readonly inbound: QueuedChannelInbound;
1225
+ } | {
1226
+ readonly disposition: 'blocked';
1227
+ readonly retryAt: number;
1228
+ } | {
1229
+ readonly disposition: 'empty';
1230
+ };
1231
+ interface EnsureSessionOptions {
1232
+ readonly reservationTtlMs?: number;
1233
+ readonly maxReservationCycles?: number;
1234
+ readonly initialBackoffMs?: number;
1235
+ readonly allocate: () => Promise<string>;
1236
+ readonly admit: (sessionKey: string) => Promise<void>;
1237
+ }
1238
+ declare class ChannelSessionCreateTimeoutError extends Error {
1239
+ readonly code: "SESSION_CREATE_TIMEOUT";
1240
+ constructor(channel: string, conversationKey: string, agentTypeId: string);
1241
+ }
1242
+ declare class ChannelBindingStore {
1243
+ private readonly sql;
1244
+ private readonly runTransaction;
1245
+ constructor(sql: SqlStorage, runTransaction: RunTransaction);
1246
+ private migrate;
1247
+ private ensureColumn;
1248
+ provision(input: ProvisionChannelBindingInput): ChannelBinding;
1249
+ getBinding(channel: string, conversationKey: string, agentTypeId: string): ChannelBinding | undefined;
1250
+ enqueueInbound(message: InboundChannelMessage, agentTypeId: string): EnqueueInboundResult;
1251
+ recordIntentionInboundActivity(binding: Pick<ChannelBinding, 'channel' | 'conversationKey' | 'agentTypeId' | 'bindingVersion'>, receivedAt: number): ChannelBinding | undefined;
1252
+ activeBindings(): ChannelBinding[];
1253
+ bindingForSession(sessionId: string, workspaceId: string): ChannelBinding | undefined;
1254
+ recordIntention(input: Omit<ChannelIntentionRecord, 'status'>): boolean;
1255
+ openIntentions(): ChannelIntentionRecord[];
1256
+ terminalIntention(channel: string, conversationKey: string, agentTypeId: string): ChannelIntentionRecord | undefined;
1257
+ activeIntention(channel: string, conversationKey: string, agentTypeId: string): ChannelIntentionRecord | undefined;
1258
+ claimIntentionProjection(questionId: string, owner: string, ttlMs?: number): ChannelIntentionRecord | undefined;
1259
+ holdIntentionForWindow(questionId: string, owner: string): boolean;
1260
+ releaseWindowHeldIntentions(binding: Pick<ChannelBinding, 'channel' | 'conversationKey' | 'agentTypeId' | 'bindingVersion'>): void;
1261
+ ownsIntentionClaim(questionId: string, owner: string): boolean;
1262
+ renewIntentionClaim(questionId: string, owner: string, ttlMs?: number): boolean;
1263
+ completeIntentionProjection(questionId: string, owner: string): boolean;
1264
+ claimIntentionReply(intention: ChannelIntentionRecord, providerMessageId: string, values: Readonly<Record<string, unknown>>, owner: string, ttlMs?: number): ClaimIntentionReplyResult;
1265
+ claimRecoverableIntentionAnswer(questionId: string, owner: string, ttlMs?: number): ChannelIntentionRecord | undefined;
1266
+ completeIntentionAnswer(questionId: string, owner: string): boolean;
1267
+ reconcileIntentionAnswered(questionId: string): void;
1268
+ reconcileIntentionClosed(questionId: string): void;
1269
+ claimInvalidIntentionReply(intention: ChannelIntentionRecord, providerMessageId: string, owner: string, ttlMs?: number): ClaimInvalidIntentionReplyResult;
1270
+ completeInvalidIntentionReply(channel: string, providerMessageId: string, owner: string): boolean;
1271
+ pendingInvalidIntentionReplies(): Array<{
1272
+ intention: ChannelIntentionRecord;
1273
+ providerMessageId: string;
1274
+ retryAt: number;
1275
+ }>;
1276
+ hasIntentionReply(channel: string, providerMessageId: string): boolean;
1277
+ claimOutbound(binding: ChannelBinding, owner: string, claimTtlMs?: number): boolean;
1278
+ outboundClaimRetryAt(binding: ChannelBinding): number | undefined;
1279
+ ownsOutboundClaim(owner: string): boolean;
1280
+ renewOutbound(owner: string, claimTtlMs?: number): boolean;
1281
+ releaseOutbound(owner: string): void;
1282
+ parkOutboundBinding(binding: ChannelBinding, claimOwner: string, errorCode: string): boolean;
1283
+ compareAndSetOutboundCursor(binding: ChannelBinding, claimOwner: string, nextCursor: string): boolean;
1284
+ markTemplateSent(binding: ChannelBinding, claimOwner: string): boolean;
1285
+ parkOutbound(binding: ChannelBinding, claimOwner: string, terminalOffset: string, errorCode: string): boolean;
1286
+ acknowledgeSessionReset(binding: ChannelBinding, claimOwner: string): boolean;
1287
+ markSessionGone(binding: ChannelBinding, claimOwner: string): boolean;
1288
+ pendingBindings(): ChannelBinding[];
1289
+ nextPending(channel: string, conversationKey: string, agentTypeId: string, claimOwner: string, claimTtlMs?: number): NextInboundResult;
1290
+ renewInbound(id: number, claimOwner: string, claimTtlMs?: number): boolean;
1291
+ completeInbound(id: number, claimOwner: string): boolean;
1292
+ retryInbound(id: number, claimOwner: string, errorCode: string): void;
1293
+ parkInbound(id: number, errorCode: string, claimOwner?: string): void;
1294
+ getInbound(id: number): QueuedChannelInbound | undefined;
1295
+ ensureSession(binding: ChannelBinding, options: EnsureSessionOptions): Promise<{
1296
+ sessionKey: string;
1297
+ created: boolean;
1298
+ }>;
1299
+ private readCreation;
1300
+ private claimCreation;
1301
+ private transitionCreation;
1302
+ private finishCreation;
1303
+ private recoverAdmitting;
1304
+ }
1305
+
1306
+ declare const CHANNEL_UNKNOWN_BINDING: "CHANNEL_UNKNOWN_BINDING";
1307
+ declare const CHANNEL_INBOUND_PARKED: "CHANNEL_INBOUND_PARKED";
1308
+ interface ChannelAdapter {
1309
+ readonly channelId: string;
1310
+ parseInbound(request: Request): Promise<readonly InboundChannelMessage[]>;
1311
+ renderOutbound(turn: unknown): readonly unknown[];
1312
+ send(message: unknown): Promise<void>;
1313
+ }
1314
+ /**
1315
+ * Trusted, host-injected seam. Implementations resolve workspace membership
1316
+ * from the binding and never receive the adapter-owned conversation key.
1317
+ */
1318
+ interface ChannelAgentInvoker {
1319
+ createSession(input: {
1320
+ readonly workspaceId: string;
1321
+ readonly authSubjectId: string;
1322
+ readonly agentTypeId: string;
1323
+ readonly originChannel: OriginChannel;
1324
+ /** Stable opaque id for replaying this binding generation's allocation. */
1325
+ readonly requestId: string;
1326
+ }): Promise<string>;
1327
+ isSessionBusy(input: {
1328
+ readonly workspaceId: string;
1329
+ readonly authSubjectId: string;
1330
+ readonly agentTypeId: string;
1331
+ readonly sessionKey: string;
1332
+ }): Promise<boolean>;
1333
+ /**
1334
+ * Implementations MUST durably deduplicate requestId and serialize
1335
+ * deliverySequence for a session before resolving. This is the downstream
1336
+ * fence that makes an expired queue lease safe to replay.
1337
+ */
1338
+ prompt(input: ChannelAgentInvocation): Promise<void>;
1339
+ /** Same durable idempotency and sequence contract as prompt. */
1340
+ followUp(input: ChannelAgentInvocation): Promise<void>;
1341
+ }
1342
+ interface ChannelAgentInvocation {
1343
+ readonly workspaceId: string;
1344
+ readonly authSubjectId: string;
1345
+ readonly agentTypeId: string;
1346
+ readonly sessionKey: string;
1347
+ readonly requestId: string;
1348
+ /** Monotonic durable queue id; stale/lower deliveries must be a no-op. */
1349
+ readonly deliverySequence: number;
1350
+ readonly text: string;
1351
+ }
1352
+ type ChannelInboundAck = {
1353
+ readonly accepted: true;
1354
+ readonly duplicate: boolean;
1355
+ readonly code: typeof ErrorCode.enum.CHANNEL_INBOUND_ACCEPTED;
1356
+ } | {
1357
+ readonly accepted: false;
1358
+ readonly duplicate: boolean;
1359
+ readonly code: typeof CHANNEL_UNKNOWN_BINDING;
1360
+ };
1361
+ declare class ChannelInboundService {
1362
+ private readonly store;
1363
+ private readonly invoker;
1364
+ private readonly options;
1365
+ private readonly drains;
1366
+ private readonly retryTimers;
1367
+ private readonly claimOwner;
1368
+ private disposed;
1369
+ constructor(store: ChannelBindingStore, invoker: ChannelAgentInvoker, options?: {
1370
+ readonly maxAttempts?: number;
1371
+ readonly inboundClaimTtlMs?: number;
1372
+ readonly drainRetryMs?: number;
1373
+ /** Called after durable completion, including work resumed at startup. */
1374
+ readonly onInboundDelivered?: (binding: ChannelBinding) => void;
1375
+ });
1376
+ /** Durable enqueue is the acknowledgement boundary; agent work stays async. */
1377
+ accept(message: InboundChannelMessage, agentTypeId: string): ChannelInboundAck;
1378
+ waitForIdle(): Promise<void>;
1379
+ dispose(): Promise<void>;
1380
+ resume(binding: ChannelBinding): void;
1381
+ private scheduleDrain;
1382
+ private drain;
1383
+ }
1384
+
1385
+ interface ChannelIntentionOption {
1386
+ readonly value: string;
1387
+ readonly label: string;
1388
+ readonly description?: string;
1389
+ }
1390
+ interface ChannelIntentionQuestion {
1391
+ readonly questionId: string;
1392
+ readonly sessionId: string;
1393
+ readonly ownerPrincipalId: string;
1394
+ readonly status: 'ready' | 'answered' | 'cancelled' | 'abandoned';
1395
+ readonly title?: string;
1396
+ readonly context?: string;
1397
+ readonly schema?: {
1398
+ readonly wireVersion: 1;
1399
+ readonly fields: readonly ChannelIntentionField[];
1400
+ };
1401
+ }
1402
+ type ChannelIntentionField = {
1403
+ readonly type: string;
1404
+ readonly name: string;
1405
+ readonly label: string;
1406
+ readonly options?: readonly ChannelIntentionOption[];
1407
+ };
1408
+ interface ChannelIntentionRuntime {
1409
+ /** Trusted workspace scope owning this ask_user store. */
1410
+ readonly workspaceId: string;
1411
+ listPending(): Promise<readonly ChannelIntentionQuestion[]>;
1412
+ getByQuestionId(questionId: string): Promise<ChannelIntentionQuestion | null>;
1413
+ submitAnswer(questionId: string, sessionId: string, values: Readonly<Record<string, string>>): Promise<unknown>;
1414
+ subscribe(listener: () => void): () => void;
1415
+ }
1416
+ interface ChannelIntentionSource {
1417
+ listPending(): Promise<readonly ChannelIntentionQuestion[]>;
1418
+ getByQuestionId(questionId: string): Promise<ChannelIntentionQuestion | null>;
1419
+ subscribe(listener: (...args: readonly unknown[]) => void): () => void;
1420
+ }
1421
+ /** Adapts the real ask_user store/runtime pair without introducing a package cycle. */
1422
+ declare function createChannelIntentionRuntime(workspaceId: string, source: ChannelIntentionSource, answers: Pick<ChannelIntentionRuntime, 'submitAnswer'>): ChannelIntentionRuntime;
1423
+ interface ChannelIntentionAdapter {
1424
+ readonly serviceWindowMs?: number;
1425
+ send(input: {
1426
+ readonly conversationKey: string;
1427
+ readonly text: string;
1428
+ }): Promise<void>;
1429
+ sendWindowTemplate?(input: {
1430
+ readonly conversationKey: string;
1431
+ }): Promise<void>;
1432
+ }
1433
+ type ChannelIntentionAck = {
1434
+ readonly handled: false;
1435
+ } | {
1436
+ readonly handled: true;
1437
+ readonly accepted: boolean;
1438
+ readonly duplicate: boolean;
1439
+ readonly questionId?: string;
1440
+ };
1441
+ type ChannelMessageAck = {
1442
+ readonly kind: 'intention';
1443
+ readonly ack: Exclude<ChannelIntentionAck, {
1444
+ handled: false;
1445
+ }>;
1446
+ } | {
1447
+ readonly kind: 'agent';
1448
+ readonly ack: ChannelInboundAck;
1449
+ };
1450
+ interface ChannelIntentionServiceOptions {
1451
+ readonly claimTtlMs?: number;
1452
+ readonly retryDelayMs?: number;
1453
+ }
1454
+ /**
1455
+ * Projects answerable ask_user questions to a bound channel and routes one
1456
+ * reply back into the same durable Human Intention. The runtime is an injected
1457
+ * seam so the channel core does not depend on the ask-user plugin package.
1458
+ */
1459
+ declare class ChannelIntentionService {
1460
+ private readonly store;
1461
+ private readonly runtime;
1462
+ private readonly adapters;
1463
+ private readonly options;
1464
+ private readonly owner;
1465
+ private scan?;
1466
+ private rescan;
1467
+ private timer?;
1468
+ private unsubscribe?;
1469
+ private disposed;
1470
+ constructor(store: ChannelBindingStore, runtime: ChannelIntentionRuntime, adapters: ReadonlyMap<string, ChannelIntentionAdapter>, options?: ChannelIntentionServiceOptions);
1471
+ start(): void;
1472
+ waitForIdle(): Promise<void>;
1473
+ dispose(): Promise<void>;
1474
+ notifyInbound(binding: {
1475
+ channel: string;
1476
+ conversationKey: string;
1477
+ agentTypeId: string;
1478
+ bindingVersion: number;
1479
+ }): void;
1480
+ accept(message: InboundChannelMessage, agentTypeId: string): Promise<ChannelIntentionAck>;
1481
+ private schedule;
1482
+ private scanOnce;
1483
+ private consumeAnswer;
1484
+ private armRetry;
1485
+ }
1486
+ /** Canonical ingress composition: approval replies never fall through to the agent prompt queue. */
1487
+ declare class ChannelMessageRouter {
1488
+ private readonly intentions;
1489
+ private readonly inbound;
1490
+ constructor(intentions: ChannelIntentionService, inbound: ChannelInboundService);
1491
+ accept(message: InboundChannelMessage, agentTypeId: string): Promise<ChannelMessageAck>;
1492
+ }
1493
+
1494
+ declare const CHANNEL_OUTBOUND_PARKED: "CHANNEL_OUTBOUND_PARKED";
1495
+ declare const CHANNEL_TURN_STALLED: "CHANNEL_TURN_STALLED";
1496
+ interface ChannelOutboundTurn {
1497
+ readonly turnId: string;
1498
+ readonly status: 'ok' | 'aborted' | 'error' | 'stalled';
1499
+ readonly text: string;
1500
+ }
1501
+ interface ChannelOutboundAdapter<Message = unknown> {
1502
+ /** Adapter-owned delivery constraint; omit for channels without a service window. */
1503
+ readonly serviceWindowMs?: number;
1504
+ renderOutbound(turn: ChannelOutboundTurn): readonly Message[];
1505
+ send(input: {
1506
+ readonly conversationKey: string;
1507
+ readonly message: Message;
1508
+ }): Promise<void>;
1509
+ sendWindowTemplate?(input: {
1510
+ readonly conversationKey: string;
1511
+ }): Promise<void>;
1512
+ }
1513
+ interface ChannelOutboundRuntime {
1514
+ /** Returns undefined only when the persisted session no longer exists. */
1515
+ resolveStreamPath(binding: ChannelBinding): Promise<string | undefined>;
1516
+ createSession(binding: ChannelBinding): Promise<string>;
1517
+ }
1518
+ interface ChannelOutboundServiceOptions {
1519
+ readonly maxSendAttempts?: number;
1520
+ readonly retryDelayMs?: number;
1521
+ readonly stallTimeoutMs?: number;
1522
+ readonly outboundClaimTtlMs?: number;
1523
+ readonly now?: () => number;
1524
+ }
1525
+ interface AssembledTurn {
1526
+ readonly turn: ChannelOutboundTurn;
1527
+ readonly terminalOffset: string;
1528
+ }
1529
+ declare class ChannelOutboundService<Message = unknown> {
1530
+ private readonly store;
1531
+ private readonly events;
1532
+ private readonly runtime;
1533
+ private readonly adapters;
1534
+ private readonly options;
1535
+ private readonly drains;
1536
+ private readonly pendingDrains;
1537
+ private readonly subscriptions;
1538
+ private readonly stallTimers;
1539
+ private readonly claimTimers;
1540
+ private disposed;
1541
+ constructor(store: ChannelBindingStore, events: EventStreamStore, runtime: ChannelOutboundRuntime, adapters: ReadonlyMap<string, ChannelOutboundAdapter<Message>>, options?: ChannelOutboundServiceOptions);
1542
+ start(): void;
1543
+ notifyInbound(binding: ChannelBinding): void;
1544
+ waitForIdle(): Promise<void>;
1545
+ dispose(): Promise<void>;
1546
+ private schedule;
1547
+ private drain;
1548
+ private readUnreadEvents;
1549
+ private scheduleClaimRetry;
1550
+ private ensureSubscription;
1551
+ private scheduleStall;
1552
+ private clearStall;
1553
+ private sendWindowTemplate;
1554
+ private sendWithRetry;
1555
+ private resolveStreamPath;
1556
+ private current;
1557
+ private isInsideServiceWindow;
1558
+ private stallTimeoutMs;
1559
+ private now;
1560
+ }
1561
+ declare function assembleNextTurn(entries: ReadonlyArray<{
1562
+ data: unknown;
1563
+ offset: string;
1564
+ }>, now?: number, stallTimeoutMs?: number): AssembledTurn | undefined;
1565
+ declare function shapeChannelText(text: string, dialect: string, maxLength?: number): string[];
1566
+
1567
+ declare const CHANNELS_ENV_FLAG = "BORING_AGENT_CHANNELS";
1568
+ declare const CHANNEL_DURABLE_STREAM_REQUIRED: "CHANNEL_DURABLE_STREAM_REQUIRED";
1569
+ declare function areChannelsEnabled(): boolean;
1570
+ declare function assertChannelDurability(durableStreamEnabled: boolean): void;
1571
+
878
1572
  interface AgentHostEnvironmentHttpProjectionOptions {
879
1573
  readonly created: CreatedAgentHost;
880
1574
  readonly authorizeAgentRequest: (request: FastifyRequest) => Promise<AuthorizedAgentScope>;
@@ -894,9 +1588,14 @@ interface EnvironmentProvisioningSnapshot {
894
1588
  readonly skillPaths: readonly string[];
895
1589
  }
896
1590
  interface EnvironmentLease {
1591
+ /** Opaque immutable identity for this exact provider/provisioning generation. */
1592
+ readonly generationId: string;
897
1593
  readonly bundle: RuntimeBundle;
898
1594
  /** One immutable Environment-owned snapshot shared by every compatible Agent binding. */
899
1595
  readonly provisioning?: EnvironmentProvisioningSnapshot;
1596
+ readonly signal: AbortSignal;
1597
+ /** Retains this exact generation; never resolves the workspace's current generation. */
1598
+ retain(): EnvironmentLease;
900
1599
  release(): void;
901
1600
  retire(): Promise<void>;
902
1601
  }
@@ -930,9 +1629,7 @@ type HarnessWatchResult = {
930
1629
  */
931
1630
  interface AgentHarnessBackend {
932
1631
  listSessions(scope: HarnessAgentScope, ctx: HarnessRequestContext, options?: SessionListOptions): Promise<SessionSummary[]>;
933
- createSession(scope: HarnessAgentScope, ctx: HarnessRequestContext, init?: {
934
- title?: string;
935
- }): Promise<SessionSummary>;
1632
+ createSession(scope: HarnessAgentScope, ctx: HarnessRequestContext, init?: SessionCreateInit): Promise<SessionSummary>;
936
1633
  readSnapshot(address: HarnessSessionAddress, ctx: HarnessRequestContext): Promise<PiChatSnapshot>;
937
1634
  watchEvents(address: HarnessSessionAddress, ctx: HarnessRequestContext, cursor: number, subscriber: (event: PiChatEvent) => void): Promise<HarnessWatchResult>;
938
1635
  submitPrompt(address: HarnessSessionAddress, ctx: HarnessRequestContext, payload: AgentPromptPayload): Promise<PromptReceipt>;
@@ -946,6 +1643,34 @@ interface AgentHarnessBackend {
946
1643
  close(): Promise<void>;
947
1644
  }
948
1645
 
1646
+ type PiLlmAuthKindV1 = 'api-key' | 'oauth';
1647
+ interface PiDerivedLlmProviderV1 {
1648
+ readonly providerId: ProviderId;
1649
+ readonly displayName: string;
1650
+ /** Auth kinds pi supports for this provider; metadata for later slices. */
1651
+ readonly authKinds: readonly PiLlmAuthKindV1[];
1652
+ readonly egressOrigins: readonly `https://${string}`[];
1653
+ readonly bindingId: CredentialConsumerBindingId;
1654
+ }
1655
+ /**
1656
+ * Narrowed per-binding surface. Runtime bindings only ever see registries and
1657
+ * the pre-bound resolver; the raw vault backend (plaintext write path) and
1658
+ * resolver minting stay host-scope-only on the full composition.
1659
+ */
1660
+ interface WorkspaceCredentialRuntimeViewV1 {
1661
+ readonly providerRegistry: ProviderRegistryV1;
1662
+ readonly bindingRegistry: CredentialConsumerBindingRegistryV1;
1663
+ readonly catalog: readonly PiDerivedLlmProviderV1[];
1664
+ readonly skippedProviderIds: readonly string[];
1665
+ /** Present when an authority verifier was supplied at composition time. */
1666
+ readonly resolver?: WorkspaceCredentialResolverV1;
1667
+ /** Actor-bound Pi credential store; workspace identity is fixed at construction. */
1668
+ createPiCredentialStore(workspaceId: string, userId: string | undefined, options: {
1669
+ readonly allowSubscriptionOAuth: boolean;
1670
+ readonly revokedOAuthReplacementVersion?: number;
1671
+ }): CredentialStore;
1672
+ }
1673
+
949
1674
  interface BuiltAgentComposition {
950
1675
  readonly harness: AgentHarness;
951
1676
  readonly sessionStore: SessionStore;
@@ -959,6 +1684,14 @@ interface BuiltAgentComposition {
959
1684
  userId?: string;
960
1685
  requestId?: string;
961
1686
  }) => Promise<readonly RuntimeFilesystemBinding[]>;
1687
+ /**
1688
+ * [1082 slice B] Narrowed per-binding credential view (registries + the
1689
+ * pre-bound resolver). Present only when `BORING_CREDENTIAL_KMS_BACKEND`
1690
+ * selected a backend at host startup. The raw vault backend and resolver
1691
+ * minting stay on the host-scope composition and are deliberately not
1692
+ * exposed here.
1693
+ */
1694
+ readonly credentials?: WorkspaceCredentialRuntimeViewV1;
962
1695
  dispose(): Promise<void>;
963
1696
  }
964
1697
 
@@ -982,6 +1715,8 @@ interface RuntimeBinding {
982
1715
  readonly key: string;
983
1716
  readonly agentTypeId: string;
984
1717
  readonly workspaceScopeId: string;
1718
+ readonly authSubjectId: string;
1719
+ readonly fundingPolicy: AgentInvocationFundingPolicyV1;
985
1720
  readonly generation: number;
986
1721
  readonly scope: ResolvedAgentRuntimeScope;
987
1722
  readonly environmentLease: EnvironmentLease;
@@ -1007,8 +1742,8 @@ interface AgentHostRuntime {
1007
1742
  acquireResolvedEnvironment(workspaceScopeId: string, environment: AgentHostEnvironmentScope): Promise<EnvironmentLease>;
1008
1743
  resolveSessionRuntime(agentTypeId: string, scope: AuthorizedAgentScope, claim: VerifiedAgentScopeClaim, sessionId: string): Promise<ResolvedAgentRuntimeScope | undefined>;
1009
1744
  resolveAgentRuntimeScope(agentTypeId: string, scope: AuthorizedAgentScope, claim: VerifiedAgentScopeClaim, operation: 'new-binding' | 'existing-session' | 'reload', requestId: string, sessionId?: string): Promise<ResolvedAgentRuntimeScope>;
1010
- resolveBinding(agentTypeId: string, scope: AuthorizedAgentScope, claim: VerifiedAgentScopeClaim, resolvedRuntimeScope?: ResolvedAgentRuntimeScope): Promise<RuntimeBinding>;
1011
- findPublishedCurrentBinding(agentTypeId: string, workspaceScopeId: string, physicalBindingIdentity: string, bindingIdentity?: string, provisioningFingerprint?: string): RuntimeBinding | undefined;
1745
+ resolveBinding(agentTypeId: string, scope: AuthorizedAgentScope, claim: VerifiedAgentScopeClaim, resolvedRuntimeScope?: ResolvedAgentRuntimeScope, fundingPolicy?: AgentInvocationFundingPolicyV1): Promise<RuntimeBinding>;
1746
+ findPublishedCurrentBinding(agentTypeId: string, workspaceScopeId: string, authSubjectId: string, physicalBindingIdentity: string, bindingIdentity?: string, provisioningFingerprint?: string, fundingPolicy?: AgentInvocationFundingPolicyV1): RuntimeBinding | undefined;
1012
1747
  startDrain(): void;
1013
1748
  drainRuntime(): Promise<void>;
1014
1749
  registerSubscription(close: () => void | Promise<void>): () => void;
@@ -1018,12 +1753,65 @@ interface AgentHostRuntime {
1018
1753
  }
1019
1754
  declare function createAgentHost(options: CreateAgentHostOptions): Promise<CreatedAgentHost>;
1020
1755
 
1756
+ declare const CHANNEL_RUNTIME_FILE_NAME = ".agent-channel-runtime.sqlite";
1757
+ interface AgentHostChannelStorage {
1758
+ readonly bindings: ChannelBindingStore;
1759
+ readonly events: EventStreamStore;
1760
+ close(): void;
1761
+ }
1762
+ /**
1763
+ * Opens the host-owned durable state shared by Agent Host event production and
1764
+ * channel delivery. App hosts pass `events` to their Agent Host composition and
1765
+ * the complete storage handle to {@link createAgentHostChannelRuntime}.
1766
+ */
1767
+ declare function createAgentHostChannelStorage(input: {
1768
+ readonly sessionRoot: string;
1769
+ readonly fileName?: string;
1770
+ }): AgentHostChannelStorage;
1771
+ interface CreateAgentHostChannelRuntimeOptions<Message> {
1772
+ readonly gateway: AgentGateway;
1773
+ readonly storage: AgentHostChannelStorage;
1774
+ /** Reissues an app-owned capability after validating the durable binding. */
1775
+ readonly resolveAuthorizedScope: (binding: Pick<ChannelBinding, 'workspaceId' | 'authSubjectId' | 'agentTypeId'>) => Promise<AuthorizedAgentScope>;
1776
+ readonly outboundAdapters: ReadonlyMap<string, ChannelOutboundAdapter<Message>>;
1777
+ /** Workspace-scoped ask_user source/answer seam; omit only when channels cannot ask owners. */
1778
+ readonly intentionRuntime?: ChannelIntentionRuntime;
1779
+ readonly outbound?: ChannelOutboundServiceOptions;
1780
+ }
1781
+ interface AgentHostChannelRuntime<Message> {
1782
+ readonly bindings: ChannelBindingStore;
1783
+ readonly events: EventStreamStore;
1784
+ readonly outboundAdapters: ReadonlyMap<string, ChannelOutboundAdapter<Message>>;
1785
+ provision(input: ProvisionChannelBindingInput): ChannelBinding;
1786
+ /** Durable enqueue is the acknowledgement boundary; delivery continues asynchronously. */
1787
+ acceptInbound(message: InboundChannelMessage, agentTypeId: string): ReturnType<ChannelInboundService['accept']> | ReturnType<ChannelMessageRouter['accept']>;
1788
+ waitForIdle(): Promise<void>;
1789
+ close(): Promise<void>;
1790
+ }
1791
+ /**
1792
+ * Concrete, provider-neutral app-host composition for channel state, session
1793
+ * invocation, durable event tails, outbound adapter lookup, restart recovery,
1794
+ * and lifecycle disposal. Provider packages only supply adapters and webhook
1795
+ * parsing; they never own workspace authority or durable state.
1796
+ */
1797
+ declare function createAgentHostChannelRuntime<Message>(options: CreateAgentHostChannelRuntimeOptions<Message>): AgentHostChannelRuntime<Message>;
1798
+
1799
+ declare const MIN_REQUEST_RETENTION_MS: number;
1800
+ interface SqliteAgentRequestLedgerOptions {
1801
+ /** Terminal payload retention. Values below 24 hours are raised to the minimum. */
1802
+ readonly retentionMs?: number;
1803
+ /** Injectable clock for deterministic storage tests. */
1804
+ readonly now?: () => number;
1805
+ }
1021
1806
  /** SQLite-backed atomic ownership/CAS ledger for direct and production projections. */
1022
1807
  declare class SqliteAgentRequestLedger implements AgentRequestLedger {
1023
1808
  readonly durability: "durable-transactional";
1024
1809
  private readonly database;
1025
- constructor(path: string);
1026
- prepare(key: AgentRequestKey, digest: string): Promise<AgentRequestLedgerPrepareResult>;
1810
+ private readonly now;
1811
+ private readonly retentionMs;
1812
+ constructor(path: string, options?: SqliteAgentRequestLedgerOptions);
1813
+ prepare(key: AgentRequestKey, digest: string, acceptedWork: AcceptedWorkContext): Promise<AgentRequestLedgerPrepareResult>;
1814
+ markAdmissionRetryable(key: AgentRequestKey): Promise<void>;
1027
1815
  acceptAdmission(key: AgentRequestKey, admissionReceipt: string): Promise<void>;
1028
1816
  beginEffect(key: AgentRequestKey): Promise<void>;
1029
1817
  reject(key: AgentRequestKey, failure: AgentRequestFailure): Promise<void>;
@@ -1031,7 +1819,12 @@ declare class SqliteAgentRequestLedger implements AgentRequestLedger {
1031
1819
  markOutcomeUnknown(key: AgentRequestKey, error: AgentGatewayErrorDTO): Promise<void>;
1032
1820
  read(key: AgentRequestKey): Promise<AgentRequestLedgerRecord | undefined>;
1033
1821
  close(): void;
1822
+ private migrateLegacyAcceptedWork;
1034
1823
  private readSync;
1824
+ private readActiveSync;
1825
+ private readTombstoneSync;
1826
+ private pruneExpiredTerminalRows;
1827
+ private immediateTransaction;
1035
1828
  private transition;
1036
1829
  }
1037
1830
 
@@ -1173,8 +1966,8 @@ declare class EmbeddedAgentGateway implements AgentGateway {
1173
1966
  readonly scope: AuthorizedAgentScope;
1174
1967
  }): Promise<{
1175
1968
  definition?: {
1969
+ digest?: string | undefined;
1176
1970
  version: string;
1177
- digest: string;
1178
1971
  } | undefined;
1179
1972
  pluginIds?: string[] | undefined;
1180
1973
  agentTypeId: string;
@@ -1214,7 +2007,8 @@ declare class EmbeddedAgentGateway implements AgentGateway {
1214
2007
  declare class InMemoryAgentRequestLedger implements AgentRequestLedger {
1215
2008
  readonly durability: "in-memory";
1216
2009
  private readonly records;
1217
- prepare(key: AgentRequestKey, digest: string): Promise<AgentRequestLedgerPrepareResult>;
2010
+ prepare(key: AgentRequestKey, digest: string, acceptedWork: AcceptedWorkContext): Promise<AgentRequestLedgerPrepareResult>;
2011
+ markAdmissionRetryable(key: AgentRequestKey): Promise<void>;
1218
2012
  acceptAdmission(key: AgentRequestKey, admissionReceipt: string): Promise<void>;
1219
2013
  beginEffect(key: AgentRequestKey): Promise<void>;
1220
2014
  reject(key: AgentRequestKey, failure: AgentRequestFailure): Promise<void>;
@@ -1224,6 +2018,9 @@ declare class InMemoryAgentRequestLedger implements AgentRequestLedger {
1224
2018
  private transition;
1225
2019
  }
1226
2020
 
2021
+ /** Canonical, collision-safe projection. The complete request key is the run identity. */
2022
+ declare function projectAgentRequestRunId(key: AgentRequestKey): string;
2023
+
1227
2024
  interface RuntimeScopeIdentityInput {
1228
2025
  readonly artifacts: readonly {
1229
2026
  readonly pluginId: string;
@@ -1410,35 +2207,72 @@ declare function resolveRuntimeReadonlyFilesystemAccess(policy: RuntimeReadonlyF
1410
2207
  /** Primary-user Operations adapter shared by HTTP and Pi filesystem tools. */
1411
2208
  declare function createUserFilesystemBinding(workspace: Workspace, policy: RuntimeReadonlyFilesystemPolicy, resolvePolicyPath: (path: string) => Promise<string>): RuntimeFilesystemBinding;
1412
2209
 
1413
- interface CredentialStoreBackendV1 {
1414
- read(workspaceId: string, providerId: ProviderId, allowedFieldIds: readonly CredentialFieldId[]): Promise<ResolvedCredentialMaterialV1 & {
1415
- credentialVersion: number;
1416
- }>;
1417
- }
1418
- interface HostSideCredentialResolverOptionsV1 {
1419
- readonly authorityVerifier: WorkspaceCredentialAuthorityVerifierV1;
1420
- readonly bindingRegistry: CredentialConsumerBindingRegistryV1;
1421
- readonly providerRegistry: ProviderRegistryV1;
1422
- /**
1423
- * Storage boundary only. Vault/KmsBackend composition is deferred to bead
1424
- * 16f.2 and will implement this interface without changing the resolver.
1425
- */
1426
- readonly backend: CredentialStoreBackendV1;
1427
- }
1428
- interface InMemoryCredentialBackendEntryV1 {
2210
+ declare function withResolvedCredential<T>(resolver: WorkspaceCredentialResolverV1, workspace: AuthorizedWorkspaceCredentialScopeV1, ref: ProviderCredentialRefV1, fn: (lease: ResolvedCredentialLeaseV1) => T | Promise<T>): Promise<T>;
2211
+
2212
+ /** Opaque, encrypted vault field containing Pi's canonical OAuth credential. */
2213
+ declare const PI_OAUTH_CREDENTIAL_FIELD_ID_V1: CredentialFieldId;
2214
+ interface VaultCredentialStoreOptionsV1 {
1429
2215
  readonly workspaceId: string;
1430
- readonly providerId: ProviderId;
1431
- readonly material: ResolvedCredentialMaterialV1;
1432
- readonly credentialVersion: number;
1433
- }
1434
- interface FakeAuthorityVerifierGrantV1 {
1435
- readonly scope: AuthorizedWorkspaceCredentialScopeV1;
1436
- readonly authority: VerifiedWorkspaceCredentialAuthorityV1;
2216
+ /** Verified actor identity. Required whenever subscription OAuth is enabled. */
2217
+ readonly userId?: string;
2218
+ readonly vaultBackend: VaultCredentialStoreBackendV1;
2219
+ /** Subscription OAuth is interactive-only; unattended seats set this false. */
2220
+ readonly allowSubscriptionOAuth: boolean;
2221
+ /** Login-only store's durable version fence for replacing a revoked OAuth tombstone. */
2222
+ readonly revokedOAuthReplacementVersion?: number;
2223
+ readonly allowedOAuthProviderIds?: readonly string[];
1437
2224
  }
1438
- declare function createHostSideCredentialResolverV1(options: HostSideCredentialResolverOptionsV1): WorkspaceCredentialResolverV1;
1439
- declare function createFakeAuthorityVerifierV1(grants: readonly FakeAuthorityVerifierGrantV1[]): WorkspaceCredentialAuthorityVerifierV1;
1440
- declare function createInMemoryCredentialBackendV1(entries: readonly InMemoryCredentialBackendEntryV1[]): CredentialStoreBackendV1;
2225
+ /**
2226
+ * Adapts Pi's async CredentialStore to one authorized workspace's encrypted
2227
+ * vault. The adapter is actor-bound at construction and never accepts a
2228
+ * workspace id from callers. Pi remains the sole owner of login and refresh.
2229
+ */
2230
+ declare function createVaultCredentialStoreV1(options: VaultCredentialStoreOptionsV1): CredentialStore;
1441
2231
 
1442
- declare function withResolvedCredential<T>(resolver: WorkspaceCredentialResolverV1, workspace: AuthorizedWorkspaceCredentialScopeV1, ref: ProviderCredentialRefV1, fn: (lease: ResolvedCredentialLeaseV1) => T | Promise<T>): Promise<T>;
2232
+ type SafeOAuthEventV1 = {
2233
+ readonly type: 'auth_url';
2234
+ readonly url: string;
2235
+ } | {
2236
+ readonly type: 'device_code';
2237
+ readonly userCode: string;
2238
+ readonly verificationUri: string;
2239
+ readonly expiresInSeconds?: number;
2240
+ } | {
2241
+ readonly type: 'progress';
2242
+ };
2243
+ interface SafeOAuthPromptV1 {
2244
+ readonly type: AuthPrompt['type'];
2245
+ readonly options?: readonly {
2246
+ readonly id: string;
2247
+ readonly label: string;
2248
+ }[];
2249
+ }
2250
+ interface OAuthFlowSnapshotV1 {
2251
+ readonly flowId: string;
2252
+ readonly providerId: 'openai-codex';
2253
+ readonly status: 'pending' | 'succeeded' | 'failed' | 'cancelled';
2254
+ readonly events: readonly SafeOAuthEventV1[];
2255
+ readonly prompt?: SafeOAuthPromptV1;
2256
+ readonly createdAt: string;
2257
+ readonly completedAt?: string;
2258
+ }
2259
+ interface CodexDisconnectResultV1 {
2260
+ /** Pi logout is local credential orchestration; it does not currently attest upstream revocation. */
2261
+ readonly logoutStatus: 'completed' | 'failed';
2262
+ readonly upstreamStatus: 'pending';
2263
+ }
2264
+ interface OpenAiCodexOAuthBrokerV1 {
2265
+ start(workspaceId: string, userId: string): Promise<OAuthFlowSnapshotV1>;
2266
+ get(workspaceId: string, userId: string, flowId: string): OAuthFlowSnapshotV1 | undefined;
2267
+ respond(workspaceId: string, userId: string, flowId: string, value: string): Promise<OAuthFlowSnapshotV1>;
2268
+ cancel(workspaceId: string, userId: string, flowId: string): Promise<void>;
2269
+ disconnect(workspaceId: string, userId: string): Promise<CodexDisconnectResultV1>;
2270
+ }
2271
+ interface OpenAiCodexOAuthBrokerOptionsV1 {
2272
+ readonly credentialStoreForActor: (workspaceId: string, userId: string) => CredentialStore | Promise<CredentialStore>;
2273
+ readonly createRuntime?: (credentials: CredentialStore) => Promise<Pick<ModelRuntime, 'login' | 'logout'>>;
2274
+ readonly now?: () => number;
2275
+ }
2276
+ declare function createOpenAiCodexOAuthBrokerV1(options: OpenAiCodexOAuthBrokerOptionsV1): OpenAiCodexOAuthBrokerV1;
1443
2277
 
1444
- export { AgentAccessDecision, AgentAccessOperation, AgentDirectoryCompilerError, type AgentDirectoryCompilerErrorCode, type AgentDirectoryCompilerPublicErrorCode, AgentEffectAdmission, AgentFleetCompilationError, AgentFleetCompilationErrorCode, AgentFleetCompiler, type AgentFleetPluginBindingContract, AgentHarnessFactory, AgentHostAgentSpec, type AgentHostEnvironmentHttpProjectionOptions, AgentHostEnvironmentScope, AgentInstructionFileRef, AgentInstructionSource, AgentMeteringSink, AgentRequestKey, AgentRequestLedger, AgentRequestLedgerPrepareResult, AgentRequestLedgerRecord, AgentRuntimeHostOperations, AuthoredAgentMaterializationError, type AuthoredAgentMaterializationErrorCode, type AuthoredAgentSourceV1, AuthorizedAgentScope, AuthorizedEnvironmentIntent, type AuthorizedSessionRunDetails, BuiltinRuntimeModeId, CompiledAgentHostAgentSpec, ConfiguredAgentHostAgentSpec, CreateAgentHostOptions, type CreateConfiguredAgentHostAgentSpecInput, type CreateStandaloneAgentHostAppOptions, type CreateValidatingAgentFleetCompilerOptions, CreatedAgentHost, type CredentialStoreBackendV1, DEFAULT_AGENT_FLEET, DEFAULT_PI_RESOURCE_DIGEST_LIMITS, DEFAULT_READONLY_WORKSPACE_PATHS, type DeploymentSnapshotProvider, type DeploymentSnapshotRecipe, type DeploymentSnapshotResult, type DeploymentSnapshotStatus, type DiscoveredAgentPackageDescriptor, EmbeddedAgentGateway, type FakeAuthorityVerifierGrantV1, FleetConfigError, type FleetConfigErrorCode, type FleetLoaderDiagnostic, type FleetLoaderDiagnosticCode, type FleetSeatBinding, type FleetSkillBinding, type HostSideCredentialResolverOptionsV1, InMemoryAgentRequestLedger, type InMemoryCredentialBackendEntryV1, type LegacyRequestLedgerLocation, type LoadConfiguredAgentFleetOptions, type LoadConfiguredAgentFleetResult, 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, ModeContext, type ModelTierCandidate, PiHarnessOptions, PiPackageSource, type PiResourceDigestInput, type PiResourceDigestLimits, type PiResourceSet, type ProvisionRuntimeWorkspaceOptions, ProvisionWorkspaceRuntimeOptions, type ProvisioningArtifactRequest, RUNTIME_FILESYSTEM_BINDING_DUPLICATE_CODE, RUNTIME_READONLY_FILESYSTEM_POLICY_INVALID_CODE, RemoteWorkerClient, RemoteWorkerClientError, type RemoteWorkerClientOptions, RemoteWorkerExecRequest, type RemoteWorkerModeAdapterOptions, RemoteWorkerWorkspaceOp, RemoteWorkerWorkspaceResult, type ResolveDefaultAgentFleetOptions, type ResolveRequestLedgerPathInput, type ResolvedAgent, type ResolvedAgentDigestInput, ResolvedAgentRuntimeScope, type ResolvedInstructionFileRefs, RuntimeBundle, type RuntimeEnvContribution, type RuntimeEnvContributionContext, RuntimeFilesystemAccessDecision, RuntimeFilesystemBinding, RuntimeFilesystemBindingConfigurationError, RuntimeModeAdapter, RuntimeModeId, type RuntimeReadonlyFilesystemPolicy, RuntimeReadonlyFilesystemPolicyError, type RuntimeWorkspaceProvisioningResult, type SandboxRuntimeModeOptions, type ShareEntryMcpResourceOptions, type SkillMetadataFrontmatter, SqliteAgentRequestLedger, TrustedAgentCompositionError, type TrustedAgentInstructionAppendix, type TrustedAuthoredAgentPolicy, UV_SETUP_COMMANDS, VerifiedAgentScopeClaim, type WithheldInstructionRef, type WorkspaceAgentDispatcherBinding, type WorkspaceAgentDispatcherResolveOptions, type WorkspaceAgentDispatcherResolver, WorkspaceProvisioningAdapter, WorkspaceProvisioningResult, applyCspHeaders, autoDetectMode, buildDeploymentSnapshotRecipe, compileAgentDirectory, compilePersonaPackageDirectory, constantTimeTokenEqual, createAgentHost, createBlaxelSandboxModeAdapter, createBoundWorkspaceAgentDispatcher, createConfiguredAgentHostAgentSpec, createDirectModeAdapter, createEnvironmentProvisioningFingerprint, createFakeAuthorityVerifierV1, createHostSideCredentialResolverV1, createInMemoryCredentialBackendV1, createLocalModeAdapter, createManagedAgentMcpDelegateController, createManagedAgentMcpHttpHandler, createManagedAgentMcpServer, createPiResourceDigestFence, createPiResourceDigestInput, createPluginDiagnosticsTool, createProviderRuntimeModeAdapter, createRemoteWorkerModeAdapter, createRemoteWorkerSandbox, createRemoteWorkerWorkspace, createResolvedAgentDigest, createResolvedRuntimeScopeIdentity, createResourceSettingsManager, createSandboxRuntimeModeAdapter, createStandaloneAgentHostApp, createUserFilesystemBinding, createValidatingAgentFleetCompiler, createVercelSandboxModeAdapter, decodeBytesFromWorker, deepLinkRoutes, digestPiResourceInputs, encodeBytesForWorker, hasBwrap, loadConfiguredAgentFleet, materializeAgentDirectory, mergeRuntimeFilesystemBindings, normalizeRuntimeReadonlyFilesystemPolicy, parseSkillMetadataFrontmatter, prepareDeploymentSnapshot, projectAuthorizedSessionRunDetails, provisionRuntimeWorkspace, provisionWorkspaceRuntime, registerAgentHostEnvironmentRoutes, registerShareEntryResources, resolveAgentDeployment, resolveAgentInstructionFileRefs, resolveBuiltinRuntimeLayoutRoot, resolveDefaultAgentFleet, resolveMode, resolveRequestLedgerPath, resolveRuntimeReadonlyFilesystemAccess, resolveWorkspaceRoot, sandboxRuntimeHostOperations, shareResourceUri, withResolvedCredential, withRuntimeEnvContributions };
2278
+ export { AgentAccessDecision, AgentAccessOperation, AgentDirectoryCompilerError, type AgentDirectoryCompilerErrorCode, type AgentDirectoryCompilerPublicErrorCode, AgentEffectAdmission, AgentFleetCompilationError, AgentFleetCompilationErrorCode, AgentFleetCompiler, type AgentFleetPluginBindingContract, AgentHarnessFactory, AgentHostAgentSpec, type AgentHostChannelRuntime, type AgentHostChannelStorage, AgentHostCredentialOptionsV1, type AgentHostEnvironmentHttpProjectionOptions, AgentHostEnvironmentScope, AgentInstructionFileRef, AgentInstructionSource, AgentMeteringSink, AgentRequestKey, AgentRequestLedger, AgentRequestLedgerPrepareResult, AgentRequestLedgerRecord, AgentRuntimeHostOperations, AuthoredAgentMaterializationError, type AuthoredAgentMaterializationErrorCode, type AuthoredAgentSourceV1, AuthorizedAgentScope, AuthorizedEnvironmentIntent, type AuthorizedSessionRunDetails, BuiltinRuntimeModeId, CHANNELS_ENV_FLAG, CHANNEL_DURABLE_STREAM_REQUIRED, CHANNEL_INBOUND_PARKED, CHANNEL_OUTBOUND_PARKED, CHANNEL_RUNTIME_FILE_NAME, CHANNEL_TURN_STALLED, CHANNEL_UNKNOWN_BINDING, type ChannelAdapter, type ChannelAgentInvocation, type ChannelAgentInvoker, type ChannelBinding, ChannelBindingStore, type ChannelInboundAck, ChannelInboundService, type ChannelIntentionAck, type ChannelIntentionAdapter, type ChannelIntentionField, type ChannelIntentionOption, type ChannelIntentionQuestion, type ChannelIntentionRecord, type ChannelIntentionRuntime, ChannelIntentionService, type ChannelIntentionServiceOptions, type ChannelIntentionSource, type ChannelMessageAck, ChannelMessageRouter, type ChannelOutboundAdapter, type ChannelOutboundRuntime, ChannelOutboundService, type ChannelOutboundServiceOptions, type ChannelOutboundTurn, ChannelSessionCreateTimeoutError, CompiledAgentHostAgentSpec, ConfiguredAgentHostAgentSpec, type CreateAgentHostChannelRuntimeOptions, CreateAgentHostOptions, type CreateConfiguredAgentHostAgentSpecInput, type CreateStandaloneAgentHostAppOptions, type CreateValidatingAgentFleetCompilerOptions, CreatedAgentHost, type CredentialStoreBackendV1, CredentialVaultPersistenceV2, DEFAULT_AGENT_FLEET, DEFAULT_PI_RESOURCE_DIGEST_LIMITS, DEFAULT_READONLY_WORKSPACE_PATHS, type DeploymentSnapshotProvider, type DeploymentSnapshotRecipe, type DeploymentSnapshotResult, type DeploymentSnapshotStatus, type DiscoveredAgentPackageDescriptor, EmbeddedAgentGateway, FleetConfigError, type FleetConfigErrorCode, type FleetLoaderDiagnostic, type FleetLoaderDiagnosticCode, type FleetSeatBinding, type FleetSkillBinding, type HostSideCredentialResolverOptionsV1, InMemoryAgentRequestLedger, type InMemoryCredentialBackendEntryV1, type InboundChannelMessage, type LegacyRequestLedgerLocation, type LoadConfiguredAgentFleetOptions, type LoadConfiguredAgentFleetResult, type LocalCredentialVersionAnchorOptionsV1, MANAGED_AGENT_MCP_DELIVERY_RULE, MANAGED_AGENT_MCP_ORIGIN_SURFACE, MIN_REQUEST_RETENTION_MS, 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, ModeContext, type ModelTierCandidate, type OpenAiCodexOAuthBrokerV1, PI_OAUTH_CREDENTIAL_FIELD_ID_V1, PiHarnessOptions, PiPackageSource, type PiResourceDigestInput, type PiResourceDigestLimits, type PiResourceSet, type ProvisionChannelBindingInput, type ProvisionRuntimeWorkspaceOptions, ProvisionWorkspaceRuntimeOptions, type ProvisioningArtifactRequest, type QueuedChannelInbound, RUNTIME_FILESYSTEM_BINDING_DUPLICATE_CODE, RUNTIME_READONLY_FILESYSTEM_POLICY_INVALID_CODE, RemoteWorkerClient, RemoteWorkerClientError, type RemoteWorkerClientOptions, RemoteWorkerExecRequest, type RemoteWorkerModeAdapterOptions, RemoteWorkerWorkspaceOp, RemoteWorkerWorkspaceResult, type ResolveDefaultAgentFleetOptions, type ResolveRequestLedgerPathInput, type ResolvedAgent, type ResolvedAgentDigestInput, ResolvedAgentRuntimeScope, type ResolvedInstructionFileRefs, RuntimeBundle, type RuntimeEnvContribution, type RuntimeEnvContributionContext, RuntimeFilesystemAccessDecision, RuntimeFilesystemBinding, RuntimeFilesystemBindingConfigurationError, RuntimeModeAdapter, RuntimeModeId, type RuntimeReadonlyFilesystemPolicy, RuntimeReadonlyFilesystemPolicyError, type RuntimeWorkspaceProvisioningResult, type SandboxRuntimeModeOptions, type ShareEntryMcpResourceOptions, type SkillMetadataFrontmatter, SqliteAgentRequestLedger, StoredCredentialRecordV1, TrustedAgentCompositionError, type TrustedAgentInstructionAppendix, type TrustedAuthoredAgentPolicy, UV_SETUP_COMMANDS, type VaultCredentialStoreBackendV1, type VaultCredentialStoreOptionsV1, VerifiedAgentScopeClaim, type WithheldInstructionRef, type WorkspaceAgentDispatcherBinding, type WorkspaceAgentDispatcherResolveOptions, type WorkspaceAgentDispatcherResolver, type WorkspaceCredentialVersionAnchorV1, type WorkspaceCredentialVersionAnchorV2, type WorkspaceCredentialVersionStateV1, WorkspaceProvisioningAdapter, WorkspaceProvisioningResult, applyCspHeaders, areChannelsEnabled, assembleNextTurn, assertChannelDurability, autoDetectMode, buildDeploymentSnapshotRecipe, compileAgentDirectory, compilePersonaPackageDirectory, constantTimeTokenEqual, createAgentHost, createAgentHostChannelRuntime, createAgentHostChannelStorage, createBlaxelSandboxModeAdapter, createBoundWorkspaceAgentDispatcher, createChannelIntentionRuntime, createConfiguredAgentHostAgentSpec, createDirectModeAdapter, createEnvironmentProvisioningFingerprint, createHostSideCredentialResolverV1, createInMemoryCredentialBackendV1, createInMemoryCredentialVaultPersistenceV1, createInMemoryCredentialVersionAnchorV1, createLocalCredentialVersionAnchorFromEnvV1, createLocalFileCredentialVersionAnchorV1, createLocalKekWorkspaceKekProviderFromEnvV1, createLocalModeAdapter, createManagedAgentMcpDelegateController, createManagedAgentMcpHttpHandler, createManagedAgentMcpServer, createOpenAiCodexOAuthBrokerV1, createPiResourceDigestFence, createPiResourceDigestInput, createPluginDiagnosticsTool, createPostgresCredentialVaultPersistenceV1, createProviderRuntimeModeAdapter, createRemoteWorkerModeAdapter, createRemoteWorkerSandbox, createRemoteWorkerWorkspace, createResolvedAgentDigest, createResolvedRuntimeScopeIdentity, createResourceSettingsManager, createSandboxRuntimeModeAdapter, createStandaloneAgentHostApp, createUserFilesystemBinding, createValidatingAgentFleetCompiler, createVaultCredentialStoreBackendV1, createVaultCredentialStoreV1, createVercelSandboxModeAdapter, decodeBytesFromWorker, deepLinkRoutes, digestPiResourceInputs, encodeBytesForWorker, hasBwrap, initializeLocalFileCredentialVersionAnchorV1, loadConfiguredAgentFleet, materializeAgentDirectory, mergeRuntimeFilesystemBindings, normalizeRuntimeReadonlyFilesystemPolicy, parseSkillMetadataFrontmatter, prepareDeploymentSnapshot, projectAgentRequestRunId, projectAuthorizedSessionRunDetails, provisionRuntimeWorkspace, provisionWorkspaceRuntime, registerAgentHostEnvironmentRoutes, registerShareEntryResources, resolveAgentDeployment, resolveAgentInstructionFileRefs, resolveBuiltinRuntimeLayoutRoot, resolveDefaultAgentFleet, resolveMode, resolveRequestLedgerPath, resolveRuntimeReadonlyFilesystemAccess, resolveWorkspaceRoot, runCredentialVaultPostgresMigrationsV1, sandboxRuntimeHostOperations, shapeChannelText, shareResourceUri, withResolvedCredential, withRuntimeEnvContributions };