@opengeni/db 0.7.3 → 0.10.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-YFQ7SGE4.js → chunk-BMFDXFPA.js} +23 -1
- package/dist/chunk-BMFDXFPA.js.map +1 -0
- package/dist/chunk-KW526IJA.js +127 -0
- package/dist/chunk-KW526IJA.js.map +1 -0
- package/dist/{chunk-B22X3IEZ.js → chunk-P6PKXY5W.js} +604 -32
- package/dist/chunk-P6PKXY5W.js.map +1 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +7408 -2276
- package/dist/index.js.map +1 -1
- package/dist/migrate.d.ts +29 -4
- package/dist/migrate.js +3 -1
- package/dist/provision-roles.d.ts +1122 -73
- package/dist/provision-roles.js +1 -1
- package/dist/{schema-BN5mB9xZ.d.ts → schema-CqkzrBRS.d.ts} +6967 -4457
- package/dist/schema.d.ts +1 -1
- package/dist/schema.js +19 -1
- package/drizzle/0053_codex_credential_leases.sql +2 -2
- package/drizzle/0057_durable_queue_control.sql +1 -1
- package/drizzle/0061_session_workflow_wake_outbox.sql +1 -1
- package/drizzle/0062_session_list_snapshot_reaper.sql +1 -1
- package/drizzle/0063_session_control_mega_foundation.sql +1 -1
- package/drizzle/0064_rotation_strategy_sharded_backfill.sql +15 -0
- package/drizzle/0065_codex_subscription_overview.sql +168 -0
- package/drizzle/0065_session_attempt_quiescence.sql +26 -0
- package/drizzle/0065_session_tool_policy.sql +38 -0
- package/drizzle/0066_session_interruption_attempt_lookup.sql +4 -0
- package/drizzle/0067_session_event_payload_bounds.sql +209 -0
- package/drizzle/0068_workspace_control_event_bounds.sql +134 -0
- package/drizzle/0069_session_event_history_backfill.sql +32 -0
- package/drizzle/0070_session_event_type_sequence_lookup.sql +4 -0
- package/drizzle/0071_session_event_monitoring_tail.sql +10 -0
- package/drizzle/0072_sessions_workspace_created_id_idx.sql +4 -0
- package/drizzle/0073_sessions_workspace_updated_id_idx.sql +4 -0
- package/drizzle/0074_session_activity_revisions.sql +72 -0
- package/drizzle/0075_sessions_workspace_activity_revision_idx.sql +4 -0
- package/drizzle/0076_session_workflow_wake_acl.sql +13 -0
- package/drizzle/0077_session_attempt_latest_lookup.sql +4 -0
- package/drizzle/0094_quarantine_credential_bearing_catalog_urls.sql +51 -0
- package/drizzle/0095_github_existing_installations.sql +84 -0
- package/drizzle/0096_session_turn_initiators.sql +97 -0
- package/drizzle/0097_host_export_outbox.sql +1220 -0
- package/drizzle/0098_usage_events_workspace_session_idx.sql +4 -0
- package/drizzle/0099_session_human_input_attempt_owner_index.sql +6 -0
- package/drizzle/0100_session_human_input_requests.sql +89 -0
- package/drizzle/0101_session_mcp_connection_refs.sql +30 -0
- package/drizzle/0102_session_command_receipt_service_actor.sql +16 -0
- package/drizzle/0103_host_export_root_session.sql +166 -0
- package/drizzle/0104_host_export_root_session_backfill.sql +27 -0
- package/drizzle/0105_session_turn_instructions.sql +9 -0
- package/drizzle/0106_session_attempt_mcp_approval_policies.sql +29 -0
- package/drizzle/0107_host_export_lineage_contract.sql +381 -0
- package/drizzle/0108_fence_invalidated_warming_epochs.sql +76 -0
- package/package.json +5 -4
- package/src/codex-token-resolver.ts +175 -14
- package/src/connection-token-resolver.ts +428 -119
- package/src/event-payload-sanitizer.ts +88 -20
- package/src/index.ts +7208 -1273
- package/src/memory-domain.ts +1 -1
- package/src/migrate.ts +86 -23
- package/src/persistence-errors.ts +252 -0
- package/src/provision-roles.ts +42 -0
- package/src/schema.ts +658 -34
- package/src/session-control.ts +520 -38
- package/src/session-queue-commands.ts +385 -61
- package/src/session-tool-call-settlement.ts +58 -7
- package/src/turn-initiator.ts +155 -0
- package/dist/chunk-7LDU7F5P.js +0 -80
- package/dist/chunk-7LDU7F5P.js.map +0 -1
- package/dist/chunk-B22X3IEZ.js.map +0 -1
- package/dist/chunk-YFQ7SGE4.js.map +0 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { ResourceRef, ToolRef, ReasoningEffort, KnowledgeMemoryKind, SessionEvent, SessionStatus, SystemUpdateClassification, SessionSystemUpdateKind, SessionSystemUpdatePayload, SessionSystemUpdate, SessionEventType, SessionTurnStatus, Permission, SessionTurn, ConnectionKind, ConnectionStatus, KnowledgeMemory, CapabilityKind, CapabilitySource, KnowledgeMemoryStatus, KnowledgeSourceRef, ScheduledTaskStatus, ScheduledTaskScheduleSpec, ScheduledTaskRunMode, ScheduledTaskOverlapPolicy, ScheduledTaskAgentConfig, SessionGoalCreatedBy,
|
|
1
|
+
import { TurnInitiatorContext, SessionMcpApprovalPolicy, TurnInitiator, ResourceRef, ToolRef, ReasoningEffort, TurnExecutionPolicyV1, KnowledgeMemoryKind, McpCredentialsRequest, McpCredentialAuthNeededReason, McpConnectionResourceScope, ConnectionCredentialsPort, SessionEvent, SessionStatus, SessionHumanInputRequest, SystemUpdateClassification, SessionSystemUpdateKind, SessionSystemUpdatePayload, SessionSystemUpdate, SessionEventType, SessionTurnStatus, HumanInputQuestion, Permission, SessionTurn, ConnectionKind, ConnectionStatus, KnowledgeMemory, CapabilityKind, CapabilitySource, KnowledgeMemoryStatus, KnowledgeSourceRef, ScheduledTaskStatus, ScheduledTaskScheduleSpec, ScheduledTaskRunMode, ScheduledTaskOverlapPolicy, ScheduledTaskAgentConfig, SessionGoalCreatedBy, McpServerConnectionRef as McpServerConnectionRef$1, SocialProvider, SocialConnectionStatus, SessionTurnSource, SandboxBackend, SandboxOs, FileAsset, FileUploadStatus, GitHubRepositoryScope, SessionGoal, SessionEventReadDirection, SessionEventSemanticClass, SessionEventPayloadMode, SessionAuthorizationListScope, CapabilityPack, RigChangeKind, RigChangeStatus, RigCheck, SessionGoalStatus, Session, LineageNode, SessionMcpServerMetadata, RigVersion, BillingBalance, RigChange, AccessContext, HostEventExportBatch, HostUsageExportBatch, ApiKey, ConnectionMetadata, Rig, ScheduledTask, ScheduledTaskTriggerType, ScheduledTaskRun, SessionToolPolicy, SocialConnection, SocialPost, VariableSet, Workspace, CapabilityInstallation, PackInstallation, CapabilityCatalogItem, HumanInputResponse, ManagedAccount, SessionQueueSnapshot, WorkspaceControlEvent, AccessGrant, WorkspaceRegisteredPack, SessionListResponse, UsageEvent, WorkspaceMember, VariableSetVariableMetadata, PackInstallationStatus, ScheduledTaskRunStatus } from '@opengeni/contracts';
|
|
2
2
|
import { environmentsEncryptionKeyBytes, Settings, McpServerConnectionRef } from '@opengeni/config';
|
|
3
|
-
import { refreshCodexToken, CodexTokenSnapshot, CodexUsagePayload } from '@opengeni/codex';
|
|
3
|
+
import { refreshCodexToken, CodexRateLimitResetCreditsDetails, ResetCreditFetchFailureReason, CodexTokenSnapshot, CodexFetch, CodexUsagePayload } from '@opengeni/codex';
|
|
4
|
+
import { SQL } from 'drizzle-orm';
|
|
4
5
|
import { PgDatabase, PgTransactionConfig } from 'drizzle-orm/pg-core';
|
|
5
|
-
import { s as sessionCommandReceipts,
|
|
6
|
-
import 'drizzle-orm';
|
|
6
|
+
import { s as sessionCommandReceipts, w as workspaces, a as sessions, b as sessionTurns, c as sessionTurnAttempts, d as composerDrafts, e as schema, f as enrollmentOsValues, g as enrollmentExposureValues, h as deviceEnrollmentStatusValues, i as enrollmentStatusValues, j as sandboxKindValues, k as sessionRecordingCodecValues, l as sessionRecordingModeValues, m as sessionRecordingStateValues } from './schema-CqkzrBRS.js';
|
|
7
7
|
import './migrate.js';
|
|
8
|
+
import { FetchLike, DnsLookup } from '@opengeni/network';
|
|
8
9
|
|
|
9
10
|
declare const SESSION_ANCESTRY_LIMIT = 10000;
|
|
10
11
|
type WorkspaceControlLockMode = "share" | "update";
|
|
@@ -12,6 +13,11 @@ type EffectiveControlState = "active" | "paused";
|
|
|
12
13
|
type SessionCommandActor = {
|
|
13
14
|
type: "human" | "operator";
|
|
14
15
|
subjectId: string;
|
|
16
|
+
} | {
|
|
17
|
+
type: "service";
|
|
18
|
+
subjectId: string;
|
|
19
|
+
subjectLabel?: string;
|
|
20
|
+
context?: TurnInitiatorContext;
|
|
15
21
|
} | {
|
|
16
22
|
type: "agent_attempt";
|
|
17
23
|
attemptId: string;
|
|
@@ -52,8 +58,28 @@ type EffectiveSessionControl = {
|
|
|
52
58
|
settlement: {
|
|
53
59
|
state: "stopping";
|
|
54
60
|
attemptCount: number;
|
|
61
|
+
interruptionPendingCount: number;
|
|
62
|
+
quiescencePendingCount: number;
|
|
55
63
|
} | null;
|
|
56
64
|
};
|
|
65
|
+
declare const SESSION_DISCOVERY_CONTROL_TITLE_MAX_CHARS = 200;
|
|
66
|
+
declare const SESSION_DISCOVERY_CONTROL_TARGET_LIMIT = 100;
|
|
67
|
+
/**
|
|
68
|
+
* Purpose-built control projection for session discovery. Full blocker evidence,
|
|
69
|
+
* actors/reasons, resume options, etags, and settlement state remain available
|
|
70
|
+
* from the ordinary session detail APIs; this shape is intentionally only what
|
|
71
|
+
* `sessions_list` renders.
|
|
72
|
+
*/
|
|
73
|
+
type SessionDiscoveryControl = {
|
|
74
|
+
state: EffectiveControlState;
|
|
75
|
+
primaryBlocker: {
|
|
76
|
+
kind: "session" | "workspace";
|
|
77
|
+
sessionId?: string;
|
|
78
|
+
displayName: string;
|
|
79
|
+
displayNameOriginalChars: number;
|
|
80
|
+
} | null;
|
|
81
|
+
additionalBlockerCount: number;
|
|
82
|
+
};
|
|
57
83
|
declare function serializeEffectiveSessionControl(control: EffectiveSessionControl): {
|
|
58
84
|
primaryBlocker: (Omit<EffectiveControlBlocker, "changedAt"> & {
|
|
59
85
|
changedAt: string | null;
|
|
@@ -82,6 +108,8 @@ declare function serializeEffectiveSessionControl(control: EffectiveSessionContr
|
|
|
82
108
|
settlement: {
|
|
83
109
|
state: "stopping";
|
|
84
110
|
attemptCount: number;
|
|
111
|
+
interruptionPendingCount: number;
|
|
112
|
+
quiescencePendingCount: number;
|
|
85
113
|
} | null;
|
|
86
114
|
};
|
|
87
115
|
type WorkspaceControlRow = {
|
|
@@ -121,6 +149,47 @@ declare function assertAgentCommandAuthorityInTransaction(db: Database, input: {
|
|
|
121
149
|
}): Promise<void>;
|
|
122
150
|
declare function canonicalSessionCommandHash(value: unknown): string;
|
|
123
151
|
declare function lockWorkspaceInferenceControl(db: Database, workspaceId: string, mode: WorkspaceControlLockMode): Promise<WorkspaceControlRow>;
|
|
152
|
+
type SessionEventWriteLockInput = {
|
|
153
|
+
workspaceId: string;
|
|
154
|
+
/**
|
|
155
|
+
* Control-aware writes take this lock first. Callers that already hold the
|
|
156
|
+
* workspace control row (for example a Pause mutation under FOR UPDATE) say
|
|
157
|
+
* `already_locked`; ordinary audit/title appends explicitly use `none`.
|
|
158
|
+
*/
|
|
159
|
+
controlLock: WorkspaceControlLockMode | "already_locked" | "none";
|
|
160
|
+
/** Used only when a staged caller already established the workspace prefix. */
|
|
161
|
+
workspaceLock?: "key_share" | "already_locked";
|
|
162
|
+
sessionIds?: string[];
|
|
163
|
+
turnIds?: string[];
|
|
164
|
+
attemptIds?: string[];
|
|
165
|
+
};
|
|
166
|
+
type SessionEventWriteLocks = {
|
|
167
|
+
control: WorkspaceControlRow | null;
|
|
168
|
+
workspace: typeof workspaces.$inferSelect | null;
|
|
169
|
+
sessions: Array<typeof sessions.$inferSelect>;
|
|
170
|
+
turns: Array<typeof sessionTurns.$inferSelect>;
|
|
171
|
+
attempts: Array<typeof sessionTurnAttempts.$inferSelect>;
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* Establish the one canonical lock prefix for every `session_events` writer:
|
|
175
|
+
*
|
|
176
|
+
* workspace_inference_controls (when control-aware)
|
|
177
|
+
* -> actual workspaces row FOR KEY SHARE
|
|
178
|
+
* -> session rows FOR UPDATE, UUID ordered
|
|
179
|
+
* -> exact turn rows FOR UPDATE, UUID ordered
|
|
180
|
+
* -> exact attempt rows FOR UPDATE, UUID ordered
|
|
181
|
+
*
|
|
182
|
+
* `FOR KEY SHARE` is deliberate. Event inserts need the workspace key to remain
|
|
183
|
+
* stable for their FK, but they do not mutate the workspace. The old generic
|
|
184
|
+
* `FOR UPDATE` lock serialized unrelated sessions and inverted the activity
|
|
185
|
+
* path's session -> implicit workspace-FK edge.
|
|
186
|
+
*
|
|
187
|
+
* Complex lifecycle transactions may acquire allocator/control locks before
|
|
188
|
+
* this helper and may discover exact turn IDs only after locking the session.
|
|
189
|
+
* They use the explicit `already_locked` stages, while retaining the same
|
|
190
|
+
* monotonic table order. New event writers should prefer one complete call.
|
|
191
|
+
*/
|
|
192
|
+
declare function lockSessionEventWriteRows(db: Database, input: SessionEventWriteLockInput): Promise<SessionEventWriteLocks>;
|
|
124
193
|
declare function registerSessionTurnAttemptClaim(db: Database, input: {
|
|
125
194
|
id: string;
|
|
126
195
|
accountId: string;
|
|
@@ -132,6 +201,7 @@ declare function registerSessionTurnAttemptClaim(db: Database, input: {
|
|
|
132
201
|
temporalWorkflowRunId: string;
|
|
133
202
|
temporalActivityId: string;
|
|
134
203
|
verifiedControlRevision: number;
|
|
204
|
+
mcpApprovalPolicies: Record<string, SessionMcpApprovalPolicy>;
|
|
135
205
|
}): Promise<typeof sessionTurnAttempts.$inferSelect>;
|
|
136
206
|
/**
|
|
137
207
|
* Close the exact first-class owner while the caller still holds the owning
|
|
@@ -153,9 +223,23 @@ declare function closeSessionTurnAttemptInTransaction(db: Database, input: {
|
|
|
153
223
|
}>;
|
|
154
224
|
declare function evaluateSessionControls(db: Database, workspaceId: string, sessionIds: string[], options?: {
|
|
155
225
|
lock?: WorkspaceControlLockMode;
|
|
226
|
+
/** Reuse a control row already locked before workspace/session/turn rows. */
|
|
227
|
+
workspaceControl?: WorkspaceControlRow | undefined;
|
|
156
228
|
}): Promise<Map<string, EffectiveSessionControl>>;
|
|
229
|
+
/**
|
|
230
|
+
* Return one compact aggregate row per target for `sessions_list`.
|
|
231
|
+
*
|
|
232
|
+
* Unlike `evaluateSessionControls`, the database boundary never returns a row
|
|
233
|
+
* per blocker/ancestor, nor does application code construct blocker or resume
|
|
234
|
+
* option arrays. The recursive walk carries no growing visited-path array: a
|
|
235
|
+
* missing ancestor stops below the limit, while a cycle cannot reach a root and
|
|
236
|
+
* therefore runs into the hard `SESSION_ANCESTRY_LIMIT`. The externally
|
|
237
|
+
* supplied target set is capped by `SESSION_DISCOVERY_CONTROL_TARGET_LIMIT`.
|
|
238
|
+
*/
|
|
239
|
+
declare function evaluateSessionDiscoveryControls(db: Database, workspaceId: string, sessionIds: string[]): Promise<Map<string, SessionDiscoveryControl>>;
|
|
157
240
|
declare function evaluateSessionControl(db: Database, workspaceId: string, sessionId: string, options?: {
|
|
158
241
|
lock?: WorkspaceControlLockMode;
|
|
242
|
+
workspaceControl?: WorkspaceControlRow | undefined;
|
|
159
243
|
}): Promise<EffectiveSessionControl>;
|
|
160
244
|
declare function reserveSessionCommandReceipt(db: Database, input: {
|
|
161
245
|
accountId: string;
|
|
@@ -224,7 +308,7 @@ declare function autoResumeSessionBranchInTransaction(db: Database, input: {
|
|
|
224
308
|
workspaceId: string;
|
|
225
309
|
sessionId: string;
|
|
226
310
|
actor: string;
|
|
227
|
-
reason: "human_send" | "human_steer" | "agent_steer";
|
|
311
|
+
reason: "human_send" | "human_steer" | "service_send" | "service_steer" | "agent_steer";
|
|
228
312
|
observedControlEtag?: string | null;
|
|
229
313
|
}): Promise<{
|
|
230
314
|
revision: number;
|
|
@@ -251,7 +335,13 @@ declare function mutateWorkspaceControlInTransaction(db: Database, input: {
|
|
|
251
335
|
expectedRevision?: number | null;
|
|
252
336
|
}): Promise<WorkspaceControlMutationResult>;
|
|
253
337
|
|
|
254
|
-
type
|
|
338
|
+
type FrozenTurnInitiator = {
|
|
339
|
+
initiator: TurnInitiator;
|
|
340
|
+
context: TurnInitiatorContext;
|
|
341
|
+
};
|
|
342
|
+
declare function frozenInitiatorForCommandActor(db: Database, workspaceId: string, actor: SessionCommandActor, subjectLabel?: string): Promise<FrozenTurnInitiator>;
|
|
343
|
+
|
|
344
|
+
type QueueCommandConflictCode = "QUEUE_VERSION_CHANGED" | "QUEUE_PROMPT_STARTED" | "QUEUE_ANCHOR_CHANGED" | "PROMPT_CHANGED" | "DRAFT_CHANGED" | "DRAFT_NOT_EMPTY" | "EDIT_SOURCE_CHANGED";
|
|
255
345
|
declare class QueueCommandConflictError extends Error {
|
|
256
346
|
readonly code: QueueCommandConflictCode;
|
|
257
347
|
readonly current: {
|
|
@@ -341,6 +431,7 @@ declare function saveComposerDraftInTransaction(db: Database, input: {
|
|
|
341
431
|
text: string;
|
|
342
432
|
resources: ResourceRef[];
|
|
343
433
|
tools: ToolRef[];
|
|
434
|
+
toolsProvided: boolean;
|
|
344
435
|
model: string;
|
|
345
436
|
reasoningEffort: ReasoningEffort;
|
|
346
437
|
}): Promise<ComposerDraftRow>;
|
|
@@ -391,17 +482,22 @@ declare function submitHumanPromptInTransaction(db: Database, input: {
|
|
|
391
482
|
workspaceId: string;
|
|
392
483
|
sessionId: string;
|
|
393
484
|
subjectId: string;
|
|
485
|
+
subjectLabel?: string;
|
|
394
486
|
actor: SessionCommandActor;
|
|
395
487
|
operationKey: string;
|
|
396
488
|
delivery: "send" | "steer";
|
|
397
489
|
controlEtag?: string | null;
|
|
398
490
|
expectedDraftRevision?: number | null;
|
|
399
491
|
text: string;
|
|
492
|
+
turnInstructions?: string | null;
|
|
400
493
|
resources: ResourceRef[];
|
|
401
494
|
tools: ToolRef[];
|
|
495
|
+
toolsProvided?: boolean;
|
|
402
496
|
model?: string | null;
|
|
403
497
|
reasoningEffort?: ReasoningEffort | null;
|
|
404
498
|
reasoningEffortFallback: ReasoningEffort;
|
|
499
|
+
/** Trusted API/core admission snapshot. Omitted only by legacy low-level callers. */
|
|
500
|
+
turnExecutionPolicy?: TurnExecutionPolicyV1;
|
|
405
501
|
source: "user" | "api";
|
|
406
502
|
mcpCredentialUpdates?: Array<{
|
|
407
503
|
id: string;
|
|
@@ -449,23 +545,6 @@ declare function encryptEnvironmentValue(key: Uint8Array, plaintext: string): st
|
|
|
449
545
|
*/
|
|
450
546
|
declare function decryptEnvironmentValue(key: Uint8Array, stored: string): string;
|
|
451
547
|
|
|
452
|
-
/**
|
|
453
|
-
* Last line of defense against a session event crashing a whole turn.
|
|
454
|
-
*
|
|
455
|
-
* Postgres `text`/`jsonb` cannot store a NUL byte (U+0000) nor lone UTF-16
|
|
456
|
-
* surrogates. Raw exec output routinely carries both -- chrome/crashpad logs,
|
|
457
|
-
* `cat` of a binary, random bytes -- and the worker persists that output verbatim
|
|
458
|
-
* inside `agent.toolCall.output` / `sandbox.command.output` event payloads. When
|
|
459
|
-
* such a payload reaches `INSERT INTO session_events`, the driver rejects it
|
|
460
|
-
* ("Failed query: insert into session_events") and the turn dies.
|
|
461
|
-
*
|
|
462
|
-
* `sanitizeEventPayload` deep-walks any payload value (objects, arrays, nested)
|
|
463
|
-
* and, for every string, strips NUL and rewrites invalid/lone UTF-16 surrogates
|
|
464
|
-
* to the Unicode replacement char (U+FFFD), so the result is always valid UTF-8
|
|
465
|
-
* that jsonb can store. It is cheap and total: only strings are touched, and only
|
|
466
|
-
* the two disallowed classes of code unit -- no meaningful text is lost, no
|
|
467
|
-
* truncation (truncation is handled elsewhere).
|
|
468
|
-
*/
|
|
469
548
|
/**
|
|
470
549
|
* Strip NUL and repair invalid/lone UTF-16 surrogates in a single string.
|
|
471
550
|
* Returns the input unchanged (same reference) when it is already clean, so the
|
|
@@ -478,7 +557,14 @@ declare function sanitizeEventString(value: string): string;
|
|
|
478
557
|
* combinations are traversed; non-string leaves pass through untouched. Object
|
|
479
558
|
* keys are sanitized too -- they are jsonb-constrained the same as values.
|
|
480
559
|
*/
|
|
481
|
-
|
|
560
|
+
type SanitizeEventPayloadOptions = {
|
|
561
|
+
/**
|
|
562
|
+
* Separately trusted, server-created retained-output evidence. Never populate
|
|
563
|
+
* this from a producer-controlled payload field.
|
|
564
|
+
*/
|
|
565
|
+
fullEvidence?: unknown;
|
|
566
|
+
};
|
|
567
|
+
declare function sanitizeEventPayload<T>(payload: T, options?: SanitizeEventPayloadOptions): T;
|
|
482
568
|
/**
|
|
483
569
|
* Make model-facing conversation data safe for Postgres without redacting it.
|
|
484
570
|
*
|
|
@@ -490,6 +576,76 @@ declare function sanitizeEventPayload<T>(payload: T): T;
|
|
|
490
576
|
*/
|
|
491
577
|
declare function sanitizeModelPayload<T>(payload: T): T;
|
|
492
578
|
|
|
579
|
+
type DatabaseFailureCode = "db_deadlock" | "db_serialization_failure" | "db_failure";
|
|
580
|
+
type PersistenceRetryOutcome = "not_retryable" | "exhausted";
|
|
581
|
+
type SafeDatabaseErrorFacts = {
|
|
582
|
+
severity?: string;
|
|
583
|
+
schema?: string;
|
|
584
|
+
table?: string;
|
|
585
|
+
column?: string;
|
|
586
|
+
dataType?: string;
|
|
587
|
+
constraint?: string;
|
|
588
|
+
routine?: string;
|
|
589
|
+
};
|
|
590
|
+
type PersistenceFailureDetails = {
|
|
591
|
+
code: DatabaseFailureCode;
|
|
592
|
+
sqlState: string | null;
|
|
593
|
+
stage: string;
|
|
594
|
+
eventTypes: string[];
|
|
595
|
+
correlationId: string;
|
|
596
|
+
attempts: number;
|
|
597
|
+
retryOutcome: PersistenceRetryOutcome;
|
|
598
|
+
database: SafeDatabaseErrorFacts;
|
|
599
|
+
};
|
|
600
|
+
/** Find the driver SQLSTATE even when Drizzle wrapped it under nested causes. */
|
|
601
|
+
declare function nestedPostgresSqlState(error: unknown): string | null;
|
|
602
|
+
declare function databaseFailureCode(sqlState: string | null): DatabaseFailureCode;
|
|
603
|
+
declare function isRetryablePersistenceSqlState(sqlState: string | null): boolean;
|
|
604
|
+
/**
|
|
605
|
+
* Distinguish database/ORM failures from expected domain exceptions when a
|
|
606
|
+
* driver omitted SQLSTATE. This checks shape only and never retains query text,
|
|
607
|
+
* bound parameters, or a raw driver cause.
|
|
608
|
+
*/
|
|
609
|
+
declare function isDatabasePersistenceFailure(error: unknown): boolean;
|
|
610
|
+
/** Extract only PostgreSQL diagnostic identifiers; never query text/parameters. */
|
|
611
|
+
declare function safeDatabaseErrorFacts(error: unknown): SafeDatabaseErrorFacts;
|
|
612
|
+
/** Public-safe cause that preserves database classification without driver data. */
|
|
613
|
+
declare class SanitizedDatabasePersistenceCause extends Error {
|
|
614
|
+
readonly sqlState: string | null;
|
|
615
|
+
readonly database: SafeDatabaseErrorFacts;
|
|
616
|
+
readonly name = "SanitizedDatabasePersistenceCause";
|
|
617
|
+
constructor(sqlState: string | null, database: SafeDatabaseErrorFacts);
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* Public-safe replacement for a raw Drizzle/postgres-js failure. Its `cause`
|
|
621
|
+
* is a newly constructed sanitized projection; the original driver cause can
|
|
622
|
+
* contain full SQL and bound parameters and is never retained.
|
|
623
|
+
*/
|
|
624
|
+
declare class SessionEventPersistenceError extends Error {
|
|
625
|
+
readonly details: PersistenceFailureDetails;
|
|
626
|
+
readonly name = "SessionEventPersistenceError";
|
|
627
|
+
readonly cause: SanitizedDatabasePersistenceCause;
|
|
628
|
+
constructor(details: PersistenceFailureDetails);
|
|
629
|
+
get code(): DatabaseFailureCode;
|
|
630
|
+
}
|
|
631
|
+
declare function isSessionEventPersistenceError(error: unknown): error is SessionEventPersistenceError;
|
|
632
|
+
type IdempotentPersistenceTransactionOptions = {
|
|
633
|
+
stage: string;
|
|
634
|
+
eventTypes?: string[];
|
|
635
|
+
maxAttempts?: number;
|
|
636
|
+
correlationId?: string;
|
|
637
|
+
onRetry?: (input: {
|
|
638
|
+
attempt: number;
|
|
639
|
+
sqlState: "40P01" | "40001";
|
|
640
|
+
}) => void | Promise<void>;
|
|
641
|
+
};
|
|
642
|
+
/**
|
|
643
|
+
* Retry only the supplied idempotent database transaction/savepoint. Provider
|
|
644
|
+
* inference, tools, NATS, and all other external effects must remain outside
|
|
645
|
+
* this function. A single correlation ID follows every persistence attempt.
|
|
646
|
+
*/
|
|
647
|
+
declare function runIdempotentPersistenceTransaction<T>(options: IdempotentPersistenceTransactionOptions, transaction: (attempt: number) => Promise<T>): Promise<T>;
|
|
648
|
+
|
|
493
649
|
/** Reject writes whose sanitized text exceeds this many characters. */
|
|
494
650
|
declare const MEMORY_TEXT_MAX_CHARS = 4000;
|
|
495
651
|
/** Per-workspace cap on agent-visible memory records (active ∪ approved). */
|
|
@@ -536,6 +692,7 @@ declare function renderWorkspaceMemoryBlock(records: readonly MemoryBlockRecord[
|
|
|
536
692
|
|
|
537
693
|
type ProvisionResult = {
|
|
538
694
|
appRole: string | null;
|
|
695
|
+
hostExportRole: string | null;
|
|
539
696
|
temporalRole: string | null;
|
|
540
697
|
temporalDatabases: string[];
|
|
541
698
|
schema: string;
|
|
@@ -559,6 +716,16 @@ type ProvisionRolesOptions = {
|
|
|
559
716
|
rlsStrategy?: RlsStrategy;
|
|
560
717
|
appRole?: string;
|
|
561
718
|
appPassword?: string;
|
|
719
|
+
/**
|
|
720
|
+
* Optional cross-workspace projection role. It receives schema USAGE and
|
|
721
|
+
* EXECUTE only on the host-export API; it receives no table privileges.
|
|
722
|
+
* Provision it after the first migration run so the schema exists. The
|
|
723
|
+
* provisioner also registers same-owner default privileges for future
|
|
724
|
+
* host-export functions; shipped migrations preserve existing exporter ACLs
|
|
725
|
+
* when a migration-only upgrade adds a function.
|
|
726
|
+
*/
|
|
727
|
+
hostExportRole?: string;
|
|
728
|
+
hostExportPassword?: string;
|
|
562
729
|
temporalRole?: string;
|
|
563
730
|
temporalPassword?: string;
|
|
564
731
|
temporalDatabases?: string[];
|
|
@@ -580,6 +747,22 @@ type ProvisionRolesOptions = {
|
|
|
580
747
|
*/
|
|
581
748
|
declare function provisionRoles(adminConnection: string, options?: ProvisionRolesOptions): Promise<ProvisionResult>;
|
|
582
749
|
|
|
750
|
+
type CodexTokenDeadlineClock = {
|
|
751
|
+
setTimeout: (callback: () => void, delayMs: number) => ReturnType<typeof globalThis.setTimeout>;
|
|
752
|
+
clearTimeout: (handle: ReturnType<typeof globalThis.setTimeout>) => void;
|
|
753
|
+
};
|
|
754
|
+
type CodexTokenDeadlineOptions = {
|
|
755
|
+
timeoutMs?: number | undefined;
|
|
756
|
+
signal?: AbortSignal | undefined;
|
|
757
|
+
clock?: CodexTokenDeadlineClock | undefined;
|
|
758
|
+
};
|
|
759
|
+
/**
|
|
760
|
+
* Bound a refresh promise without abandoning its rejection handler when the
|
|
761
|
+
* deadline or cancellation wins. The provider promise is observed exactly
|
|
762
|
+
* once, while the observer itself always fulfills, so a late provider failure
|
|
763
|
+
* cannot become an unhandled rejection or replace the authoritative outcome.
|
|
764
|
+
*/
|
|
765
|
+
declare function withCodexTokenDeadline<T>(operation: Promise<T>, options?: CodexTokenDeadlineOptions): Promise<T>;
|
|
583
766
|
type CodexAuthDeps = {
|
|
584
767
|
loadCredential: typeof loadCodexCredentialForRun;
|
|
585
768
|
recordRefresh: typeof recordCodexTokenRefresh;
|
|
@@ -607,7 +790,23 @@ declare function buildCodexTokenResolver(db: Database, settings: Settings, works
|
|
|
607
790
|
* A refresh that stamps needs_relogin returns { status:"error", reason } and never
|
|
608
791
|
* hits the provider; a transient refresh error returns a plain error payload.
|
|
609
792
|
*/
|
|
610
|
-
declare function fetchCodexUsageForAccount(db: Database, settings: Settings, workspaceId: string, credentialId: string): Promise<CodexUsagePayload>;
|
|
793
|
+
declare function fetchCodexUsageForAccount(db: Database, settings: Settings, workspaceId: string, credentialId: string, fetchImpl?: CodexFetch): Promise<CodexUsagePayload>;
|
|
794
|
+
type CodexRateLimitResetCreditsAccountResult = {
|
|
795
|
+
ok: true;
|
|
796
|
+
status: number;
|
|
797
|
+
details: CodexRateLimitResetCreditsDetails;
|
|
798
|
+
} | {
|
|
799
|
+
ok: false;
|
|
800
|
+
status: number;
|
|
801
|
+
reason: ResetCreditFetchFailureReason | "needs_relogin";
|
|
802
|
+
};
|
|
803
|
+
/**
|
|
804
|
+
* Fresh detailed reset-credit inventory for one exact workspace credential.
|
|
805
|
+
* The token is refreshed through the same resolver as usage and never escapes
|
|
806
|
+
* this server-side function. Detailed rows are returned to the route only and
|
|
807
|
+
* are never persisted as redemption authority.
|
|
808
|
+
*/
|
|
809
|
+
declare function fetchCodexRateLimitResetCreditsForAccount(db: Database, settings: Settings, workspaceId: string, credentialId: string, fetchImpl?: CodexFetch): Promise<CodexRateLimitResetCreditsAccountResult>;
|
|
611
810
|
|
|
612
811
|
type ResolveConnectionCredentialResult = {
|
|
613
812
|
status: "ok";
|
|
@@ -616,21 +815,52 @@ type ResolveConnectionCredentialResult = {
|
|
|
616
815
|
expiresAt?: Date | null;
|
|
617
816
|
} | {
|
|
618
817
|
status: "auth_needed";
|
|
619
|
-
reason:
|
|
818
|
+
reason: McpCredentialAuthNeededReason;
|
|
620
819
|
providerDomain: string;
|
|
820
|
+
provider?: string;
|
|
621
821
|
connectionId?: string;
|
|
622
822
|
scopes?: string[];
|
|
623
823
|
resource?: string;
|
|
824
|
+
selectedResources?: McpConnectionResourceScope[];
|
|
624
825
|
authorizationUrl?: string;
|
|
625
826
|
};
|
|
626
827
|
type ResolveConnectionCredentialInput = {
|
|
627
828
|
workspaceId: string;
|
|
628
829
|
subjectId?: string;
|
|
629
830
|
serverId: string;
|
|
831
|
+
toolName?: string;
|
|
832
|
+
/** @deprecated Use toolName. Retained for the API's pre-existing broker call shape. */
|
|
630
833
|
toolId?: string;
|
|
631
834
|
connectionRef: McpServerConnectionRef;
|
|
835
|
+
/** Exact MCP destination whose request would receive the resolved headers. */
|
|
836
|
+
destinationUrl: string;
|
|
632
837
|
forceRefresh?: boolean;
|
|
633
838
|
};
|
|
839
|
+
type HostMcpCredentialResolverContext = {
|
|
840
|
+
accountId: string;
|
|
841
|
+
workspaceId: string;
|
|
842
|
+
sessionId: string;
|
|
843
|
+
rootSessionId: string;
|
|
844
|
+
turnId: string;
|
|
845
|
+
attemptId: string | null;
|
|
846
|
+
executionGeneration: number;
|
|
847
|
+
initiator: TurnInitiator;
|
|
848
|
+
initiatorContext: TurnInitiatorContext;
|
|
849
|
+
surface: McpCredentialsRequest["surface"];
|
|
850
|
+
};
|
|
851
|
+
declare class HostMcpCredentialScopeError extends Error {
|
|
852
|
+
constructor(field: "accountId" | "workspaceId" | "sessionId");
|
|
853
|
+
}
|
|
854
|
+
declare class HostMcpCredentialBindingError extends Error {
|
|
855
|
+
constructor(field: "provider" | "providerDomain" | "connectionId" | "scopes" | "resource" | "selectedResources" | "destinationUrl");
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* Adapts the public embedding credential port to the runtime's connection
|
|
859
|
+
* resolver contract. Scope echoes are checked before credential headers can
|
|
860
|
+
* reach a request; the returned object is a fresh copy so a host cannot mutate
|
|
861
|
+
* headers after resolution.
|
|
862
|
+
*/
|
|
863
|
+
declare function buildHostConnectionTokenResolver(resolve: NonNullable<ConnectionCredentialsPort["mcpCredentials"]>, context: HostMcpCredentialResolverContext): (input: ResolveConnectionCredentialInput) => Promise<ResolveConnectionCredentialResult>;
|
|
634
864
|
type ConnectionBrokerDeps = {
|
|
635
865
|
loadCredential: typeof loadConnectionCredentialForBroker;
|
|
636
866
|
recordRefresh: typeof recordConnectionTokenRefresh;
|
|
@@ -641,6 +871,10 @@ type ConnectionBrokerDeps = {
|
|
|
641
871
|
keyBytes: typeof environmentsEncryptionKeyBytes;
|
|
642
872
|
now: () => Date;
|
|
643
873
|
};
|
|
874
|
+
type RefreshTransportOptions = {
|
|
875
|
+
fetchImpl?: FetchLike;
|
|
876
|
+
dnsLookup?: DnsLookup;
|
|
877
|
+
};
|
|
644
878
|
declare function buildConnectionTokenResolver(db: Database, settings: Settings, deps?: ConnectionBrokerDeps): (input: ResolveConnectionCredentialInput) => Promise<ResolveConnectionCredentialResult>;
|
|
645
879
|
declare class ConnectionRefreshHttpError extends Error {
|
|
646
880
|
readonly httpStatus: number;
|
|
@@ -653,12 +887,11 @@ declare class ConnectionRefreshHttpError extends Error {
|
|
|
653
887
|
* the canonical `Bearer`. A non-bearer scheme is passed through unchanged.
|
|
654
888
|
*/
|
|
655
889
|
declare function normalizeBearerScheme(tokenType: string | null | undefined): string;
|
|
656
|
-
declare function refreshOAuthConnectionCredential(cred: ConnectionCredentialForBroker, ref: McpServerConnectionRef, settings?:
|
|
890
|
+
declare function refreshOAuthConnectionCredential(cred: ConnectionCredentialForBroker, ref: McpServerConnectionRef, settings: Settings, transportOptions?: RefreshTransportOptions): Promise<{
|
|
657
891
|
credential: Record<string, unknown>;
|
|
658
892
|
expiresAt: Date | null;
|
|
659
893
|
grantedScopes?: string[];
|
|
660
894
|
}>;
|
|
661
|
-
declare function isPrivateAddress(address: string): boolean;
|
|
662
895
|
|
|
663
896
|
type Database = PgDatabase<any, typeof schema>;
|
|
664
897
|
type DbClient = {
|
|
@@ -710,7 +943,7 @@ type CreateDbOptions = {
|
|
|
710
943
|
* it as a per-session startup parameter (the supported, query-param-free way;
|
|
711
944
|
* URL `?search_path=` is IGNORED by postgres-js). Keep `public` LAST so the
|
|
712
945
|
* `vector` type and `gen_random_uuid()` (which live in `public` on the
|
|
713
|
-
* pgvector image) still resolve — the
|
|
946
|
+
* pgvector image) still resolve — the schema-isolation contract live footgun.
|
|
714
947
|
*/
|
|
715
948
|
searchPath?: string;
|
|
716
949
|
/** RLS posture; defaults to `"force"` (today's standalone). */
|
|
@@ -733,6 +966,115 @@ declare function registerDbBinding(db: Database, binding: {
|
|
|
733
966
|
rlsStrategy?: RlsStrategy;
|
|
734
967
|
userLookup?: UserLookup;
|
|
735
968
|
}): void;
|
|
969
|
+
type HostExportKind = "session_event" | "usage_event";
|
|
970
|
+
/**
|
|
971
|
+
* A leased row did not satisfy this consumer build's export contract. Only
|
|
972
|
+
* bounded schema diagnostics are retained here; the source payload is never
|
|
973
|
+
* copied into the error. The lease can therefore be failed visibly, or an
|
|
974
|
+
* operator can re-claim it with a known token and explicitly dead-letter the
|
|
975
|
+
* reported head cursor.
|
|
976
|
+
*/
|
|
977
|
+
declare class HostExportPayloadError extends Error {
|
|
978
|
+
readonly kind: HostExportKind;
|
|
979
|
+
readonly consumerId: string;
|
|
980
|
+
readonly leaseToken: string;
|
|
981
|
+
readonly cursor: string;
|
|
982
|
+
readonly schemaIssues: string[];
|
|
983
|
+
readonly name = "HostExportPayloadError";
|
|
984
|
+
constructor(kind: HostExportKind, consumerId: string, leaseToken: string, cursor: string, schemaIssues: string[]);
|
|
985
|
+
}
|
|
986
|
+
type HostExportConsumerStatus = {
|
|
987
|
+
exportKind: HostExportKind;
|
|
988
|
+
consumerId: string;
|
|
989
|
+
checkpoint: string;
|
|
990
|
+
enabled: boolean;
|
|
991
|
+
consecutiveFailures: number;
|
|
992
|
+
nextAttemptAt: string;
|
|
993
|
+
lastError: string | null;
|
|
994
|
+
lastErrorAt: string | null;
|
|
995
|
+
blockedAt: string | null;
|
|
996
|
+
leaseExpiresAt: string | null;
|
|
997
|
+
maxCursor: string;
|
|
998
|
+
pendingCount: string;
|
|
999
|
+
unassignedCount: string;
|
|
1000
|
+
prunedThrough: string;
|
|
1001
|
+
};
|
|
1002
|
+
/**
|
|
1003
|
+
* Enable a named consumer. This call deliberately requires a database handle
|
|
1004
|
+
* authenticated as the separately provisioned host-export role; the ordinary
|
|
1005
|
+
* tenant-scoped app role cannot execute this cross-workspace API.
|
|
1006
|
+
*/
|
|
1007
|
+
declare function registerHostExportConsumer(db: Database, input: {
|
|
1008
|
+
kind: HostExportKind;
|
|
1009
|
+
consumerId: string;
|
|
1010
|
+
}): Promise<void>;
|
|
1011
|
+
declare function disableHostExportConsumer(db: Database, input: {
|
|
1012
|
+
kind: HostExportKind;
|
|
1013
|
+
consumerId: string;
|
|
1014
|
+
}): Promise<void>;
|
|
1015
|
+
/**
|
|
1016
|
+
* Permanently remove a quiesced consumer and release its retention floor.
|
|
1017
|
+
* Unlike disable, re-registering this name later starts at the retained floor.
|
|
1018
|
+
*/
|
|
1019
|
+
declare function retireHostExportConsumer(db: Database, input: {
|
|
1020
|
+
kind: HostExportKind;
|
|
1021
|
+
consumerId: string;
|
|
1022
|
+
}): Promise<void>;
|
|
1023
|
+
declare function claimHostExportBatch(db: Database, input: {
|
|
1024
|
+
kind: "session_event";
|
|
1025
|
+
consumerId: string;
|
|
1026
|
+
leaseToken: string;
|
|
1027
|
+
leaseHolderId: string;
|
|
1028
|
+
leaseSeconds?: number;
|
|
1029
|
+
limit?: number;
|
|
1030
|
+
maxBytes?: number;
|
|
1031
|
+
}): Promise<HostEventExportBatch | null>;
|
|
1032
|
+
declare function claimHostExportBatch(db: Database, input: {
|
|
1033
|
+
kind: "usage_event";
|
|
1034
|
+
consumerId: string;
|
|
1035
|
+
leaseToken: string;
|
|
1036
|
+
leaseHolderId: string;
|
|
1037
|
+
leaseSeconds?: number;
|
|
1038
|
+
limit?: number;
|
|
1039
|
+
maxBytes?: number;
|
|
1040
|
+
}): Promise<HostUsageExportBatch | null>;
|
|
1041
|
+
declare function acknowledgeHostExportBatch(db: Database, input: {
|
|
1042
|
+
kind: HostExportKind;
|
|
1043
|
+
consumerId: string;
|
|
1044
|
+
leaseToken: string;
|
|
1045
|
+
}): Promise<string>;
|
|
1046
|
+
declare function failHostExportBatch(db: Database, input: {
|
|
1047
|
+
kind: HostExportKind;
|
|
1048
|
+
consumerId: string;
|
|
1049
|
+
leaseToken: string;
|
|
1050
|
+
error: string;
|
|
1051
|
+
maxFailures?: number;
|
|
1052
|
+
}): Promise<number>;
|
|
1053
|
+
declare function deadLetterHostExportHead(db: Database, input: {
|
|
1054
|
+
kind: HostExportKind;
|
|
1055
|
+
consumerId: string;
|
|
1056
|
+
leaseToken: string;
|
|
1057
|
+
cursor: string;
|
|
1058
|
+
reason: string;
|
|
1059
|
+
}): Promise<string>;
|
|
1060
|
+
declare function resumeHostExportConsumer(db: Database, input: {
|
|
1061
|
+
kind: HostExportKind;
|
|
1062
|
+
consumerId: string;
|
|
1063
|
+
}): Promise<void>;
|
|
1064
|
+
declare function rewindHostExportConsumer(db: Database, input: {
|
|
1065
|
+
kind: HostExportKind;
|
|
1066
|
+
consumerId: string;
|
|
1067
|
+
checkpoint: string;
|
|
1068
|
+
}): Promise<void>;
|
|
1069
|
+
declare function pruneHostExportOutbox(db: Database, input: {
|
|
1070
|
+
kind: HostExportKind;
|
|
1071
|
+
graceSeconds?: number;
|
|
1072
|
+
limit?: number;
|
|
1073
|
+
}): Promise<number>;
|
|
1074
|
+
declare function getHostExportConsumerStatus(db: Database, input: {
|
|
1075
|
+
kind: HostExportKind;
|
|
1076
|
+
consumerId: string;
|
|
1077
|
+
}): Promise<HostExportConsumerStatus | null>;
|
|
736
1078
|
declare function setRlsContext(db: Database, context: RlsContext): Promise<void>;
|
|
737
1079
|
declare function withRlsContext<T>(db: Database, context: RlsContext, fn: (db: Database) => Promise<T>, transactionConfig?: PgTransactionConfig): Promise<T>;
|
|
738
1080
|
declare function rlsContextForWorkspace(db: Database, workspaceId: string): Promise<RlsContext>;
|
|
@@ -835,18 +1177,40 @@ type GitHubInstallation = {
|
|
|
835
1177
|
installationId: number;
|
|
836
1178
|
accountLogin: string | null;
|
|
837
1179
|
accountType: string | null;
|
|
1180
|
+
repositoryScope: GitHubRepositoryScope;
|
|
1181
|
+
linkedBySubjectId: string | null;
|
|
838
1182
|
createdAt: string;
|
|
839
1183
|
updatedAt: string;
|
|
840
1184
|
};
|
|
1185
|
+
type GitHubInstallationAccess = GitHubInstallation & {
|
|
1186
|
+
repositoryIds: number[];
|
|
1187
|
+
};
|
|
841
1188
|
declare function upsertGitHubInstallation(db: Database, input: {
|
|
842
1189
|
accountId: string;
|
|
843
1190
|
workspaceId: string;
|
|
844
1191
|
installationId: number;
|
|
845
1192
|
accountLogin?: string | null;
|
|
846
1193
|
accountType?: string | null;
|
|
1194
|
+
linkedBySubjectId?: string | null;
|
|
847
1195
|
}): Promise<GitHubInstallation>;
|
|
1196
|
+
declare function bindGitHubInstallationRepositories(db: Database, input: {
|
|
1197
|
+
accountId: string;
|
|
1198
|
+
workspaceId: string;
|
|
1199
|
+
installationId: number;
|
|
1200
|
+
accountLogin?: string | null;
|
|
1201
|
+
accountType?: string | null;
|
|
1202
|
+
linkedBySubjectId: string;
|
|
1203
|
+
repositoryIds: number[];
|
|
1204
|
+
}): Promise<GitHubInstallationAccess>;
|
|
848
1205
|
declare function listGitHubInstallationsForWorkspace(db: Database, workspaceId: string): Promise<GitHubInstallation[]>;
|
|
849
1206
|
declare function listGitHubInstallationIdsForWorkspace(db: Database, workspaceId: string): Promise<number[]>;
|
|
1207
|
+
declare function listGitHubInstallationAccessForWorkspace(db: Database, workspaceId: string): Promise<GitHubInstallationAccess[]>;
|
|
1208
|
+
declare function areGitHubRepositoriesAllowedForWorkspace(db: Database, workspaceId: string, installationId: number, repositoryIds: number[]): Promise<boolean>;
|
|
1209
|
+
declare function deleteGitHubInstallationBinding(db: Database, input: {
|
|
1210
|
+
accountId: string;
|
|
1211
|
+
workspaceId: string;
|
|
1212
|
+
installationId: number;
|
|
1213
|
+
}): Promise<boolean>;
|
|
850
1214
|
declare function recordUsageEvent(db: Database, input: {
|
|
851
1215
|
accountId: string;
|
|
852
1216
|
workspaceId: string;
|
|
@@ -856,6 +1220,12 @@ declare function recordUsageEvent(db: Database, input: {
|
|
|
856
1220
|
unit: string;
|
|
857
1221
|
sourceResourceType?: string | null;
|
|
858
1222
|
sourceResourceId?: string | null;
|
|
1223
|
+
sessionId?: string | null;
|
|
1224
|
+
turnId?: string | null;
|
|
1225
|
+
turnAttemptId?: string | null;
|
|
1226
|
+
initiator?: TurnInitiator | null;
|
|
1227
|
+
initiatorContext?: TurnInitiatorContext;
|
|
1228
|
+
origin?: SessionTurnSource | null;
|
|
859
1229
|
idempotencyKey: string;
|
|
860
1230
|
occurredAt?: Date;
|
|
861
1231
|
}): Promise<UsageEvent>;
|
|
@@ -921,6 +1291,11 @@ declare function countScheduledTasksForWorkspace(db: Database, workspaceId: stri
|
|
|
921
1291
|
type AppendEventInput = {
|
|
922
1292
|
type: SessionEventType;
|
|
923
1293
|
payload?: unknown;
|
|
1294
|
+
/**
|
|
1295
|
+
* Server-created retained-output evidence for canonical audit truncation.
|
|
1296
|
+
* Producer payload fields are never trusted as evidence.
|
|
1297
|
+
*/
|
|
1298
|
+
retainedOutputEvidence?: unknown;
|
|
924
1299
|
clientEventId?: string;
|
|
925
1300
|
turnId?: string | null;
|
|
926
1301
|
turnGeneration?: number | null;
|
|
@@ -1214,7 +1589,8 @@ type CreateSessionMcpServerInput = {
|
|
|
1214
1589
|
allowedTools?: string[] | null;
|
|
1215
1590
|
timeoutMs?: number | null;
|
|
1216
1591
|
cacheToolsList?: boolean | null;
|
|
1217
|
-
requireApproval?:
|
|
1592
|
+
requireApproval?: SessionMcpApprovalPolicy | null;
|
|
1593
|
+
connectionRef?: McpServerConnectionRef$1 | null;
|
|
1218
1594
|
headersEncrypted?: Record<string, string>;
|
|
1219
1595
|
};
|
|
1220
1596
|
type UpdateSessionMcpServerCredentialsInput = {
|
|
@@ -1225,11 +1601,15 @@ type UpdateSessionMcpServerCredentialsResult = {
|
|
|
1225
1601
|
servers: SessionMcpServerMetadata[];
|
|
1226
1602
|
missingIds: string[];
|
|
1227
1603
|
};
|
|
1604
|
+
type UpdateSessionMcpApprovalPolicyResult = {
|
|
1605
|
+
server: SessionMcpServerMetadata | null;
|
|
1606
|
+
changed: boolean;
|
|
1607
|
+
};
|
|
1228
1608
|
type SessionMcpServerForRun = SessionMcpServerMetadata & {
|
|
1229
1609
|
allowedTools?: string[];
|
|
1230
1610
|
timeoutMs?: number;
|
|
1231
1611
|
cacheToolsList?: boolean;
|
|
1232
|
-
requireApproval
|
|
1612
|
+
requireApproval: SessionMcpApprovalPolicy;
|
|
1233
1613
|
headers: Record<string, string>;
|
|
1234
1614
|
};
|
|
1235
1615
|
type EnqueueSessionTurnInput = {
|
|
@@ -1240,17 +1620,28 @@ type EnqueueSessionTurnInput = {
|
|
|
1240
1620
|
temporalWorkflowId: string;
|
|
1241
1621
|
source: SessionTurnSource;
|
|
1242
1622
|
prompt: string;
|
|
1623
|
+
turnInstructions?: string | null;
|
|
1243
1624
|
resources: ResourceRef[];
|
|
1244
1625
|
tools: ToolRef[];
|
|
1626
|
+
toolsProvided?: boolean;
|
|
1245
1627
|
model: string;
|
|
1246
1628
|
reasoningEffort: ReasoningEffort;
|
|
1247
1629
|
sandboxBackend: SandboxBackend;
|
|
1248
1630
|
sandboxOs?: SandboxOs | null;
|
|
1249
1631
|
metadata: Record<string, unknown>;
|
|
1250
1632
|
lineage?: Record<string, unknown>;
|
|
1633
|
+
initiator: TurnInitiator;
|
|
1634
|
+
initiatorContext?: TurnInitiatorContext;
|
|
1251
1635
|
/** Steer inserts before all waiting prompts; Send appends after them. */
|
|
1252
1636
|
placement?: "head" | "tail";
|
|
1253
1637
|
};
|
|
1638
|
+
/**
|
|
1639
|
+
* Worker-only turn projection. Host instructions are durable execution input,
|
|
1640
|
+
* never part of the public SessionTurn/queue/HTTP contract.
|
|
1641
|
+
*/
|
|
1642
|
+
type SessionTurnForExecution = SessionTurn & {
|
|
1643
|
+
turnInstructions: string | null;
|
|
1644
|
+
};
|
|
1254
1645
|
declare function createFileUpload(db: Database, input: {
|
|
1255
1646
|
accountId: string;
|
|
1256
1647
|
workspaceId: string;
|
|
@@ -1270,6 +1661,17 @@ declare function createFileUpload(db: Database, input: {
|
|
|
1270
1661
|
}>;
|
|
1271
1662
|
declare function getFile(db: Database, workspaceId: string, fileId: string): Promise<FileAsset | null>;
|
|
1272
1663
|
declare function requireFile(db: Database, workspaceId: string, fileId: string): Promise<FileAsset>;
|
|
1664
|
+
type RetainedFileArtifact = {
|
|
1665
|
+
file: FileAsset;
|
|
1666
|
+
uploadStatus: FileUploadStatus | null;
|
|
1667
|
+
uploadExpiresAt: Date | null;
|
|
1668
|
+
};
|
|
1669
|
+
/**
|
|
1670
|
+
* RLS-scoped file lookup with just enough upload lifecycle truth to distinguish
|
|
1671
|
+
* pending, failed, and expired artifact references. The bytes and provider
|
|
1672
|
+
* location remain in the existing FileAsset/object-storage seam.
|
|
1673
|
+
*/
|
|
1674
|
+
declare function getRetainedFileArtifact(db: Database, workspaceId: string, fileId: string): Promise<RetainedFileArtifact | null>;
|
|
1273
1675
|
declare function getFileUpload(db: Database, workspaceId: string, uploadId: string): Promise<{
|
|
1274
1676
|
id: string;
|
|
1275
1677
|
status: FileUploadStatus;
|
|
@@ -1595,6 +1997,28 @@ declare function createRigVersionForChangePromotion(db: Database, workspaceId: s
|
|
|
1595
1997
|
change: RigChange;
|
|
1596
1998
|
}>;
|
|
1597
1999
|
declare function listRigVersions(db: Database, workspaceId: string, rigId: string): Promise<RigVersion[]>;
|
|
2000
|
+
type RigVersionMonitoringSummary = {
|
|
2001
|
+
id: string;
|
|
2002
|
+
rigId: string;
|
|
2003
|
+
version: number;
|
|
2004
|
+
active: boolean;
|
|
2005
|
+
image: string | null;
|
|
2006
|
+
imageOriginalChars: number | null;
|
|
2007
|
+
setupScriptBytes: number;
|
|
2008
|
+
checkCount: number;
|
|
2009
|
+
credentialHookCount: number;
|
|
2010
|
+
defaultVariableSetCount: number;
|
|
2011
|
+
changelog: string | null;
|
|
2012
|
+
changelogOriginalChars: number | null;
|
|
2013
|
+
createdBy: string | null;
|
|
2014
|
+
createdAt: string;
|
|
2015
|
+
};
|
|
2016
|
+
/** Compact-by-query historical rig versions for the model-facing MCP surface. */
|
|
2017
|
+
declare function listRigVersionMonitoringSummaries(db: Database, workspaceId: string, rigId: string, limit?: number): Promise<{
|
|
2018
|
+
versions: RigVersionMonitoringSummary[];
|
|
2019
|
+
hasMore: boolean;
|
|
2020
|
+
total: number;
|
|
2021
|
+
}>;
|
|
1598
2022
|
declare function getRigVersion(db: Database, workspaceId: string, rigId: string, versionId: string): Promise<RigVersion | null>;
|
|
1599
2023
|
declare function getRigVersionById(db: Database, workspaceId: string, versionId: string): Promise<RigVersion | null>;
|
|
1600
2024
|
declare function getRigName(db: Database, workspaceId: string, rigId: string): Promise<string | null>;
|
|
@@ -1609,6 +2033,31 @@ declare function createRigChange(db: Database, input: {
|
|
|
1609
2033
|
proposedBy?: string | null;
|
|
1610
2034
|
}): Promise<RigChange>;
|
|
1611
2035
|
declare function listRigChanges(db: Database, workspaceId: string, rigId: string, limit?: number): Promise<RigChange[]>;
|
|
2036
|
+
type RigChangeMonitoringSummary = {
|
|
2037
|
+
id: string;
|
|
2038
|
+
rigId: string;
|
|
2039
|
+
baseVersionId: string | null;
|
|
2040
|
+
kind: RigChangeKind;
|
|
2041
|
+
status: RigChangeStatus;
|
|
2042
|
+
proposedBy: string | null;
|
|
2043
|
+
resultVersionId: string | null;
|
|
2044
|
+
commandPreview: string | null;
|
|
2045
|
+
commandOriginalChars: number | null;
|
|
2046
|
+
payloadBytes: number;
|
|
2047
|
+
verificationBytes: number;
|
|
2048
|
+
verificationLogBytes: number;
|
|
2049
|
+
verificationStartedAt: string | null;
|
|
2050
|
+
verificationFinishedAt: string | null;
|
|
2051
|
+
verificationPassed: boolean | null;
|
|
2052
|
+
createdAt: string;
|
|
2053
|
+
updatedAt: string;
|
|
2054
|
+
};
|
|
2055
|
+
/** Compact-by-query recent rig changes for the model-facing MCP surface. */
|
|
2056
|
+
declare function listRigChangeMonitoringSummaries(db: Database, workspaceId: string, rigId: string, limit?: number): Promise<{
|
|
2057
|
+
changes: RigChangeMonitoringSummary[];
|
|
2058
|
+
hasMore: boolean;
|
|
2059
|
+
total: number;
|
|
2060
|
+
}>;
|
|
1612
2061
|
declare function getRigChange(db: Database, workspaceId: string, changeId: string): Promise<RigChange | null>;
|
|
1613
2062
|
declare function updateRigChangeStatus(db: Database, workspaceId: string, changeId: string, input: {
|
|
1614
2063
|
status: RigChangeStatus;
|
|
@@ -1709,6 +2158,15 @@ type CodexCredentialForRun = {
|
|
|
1709
2158
|
* accessor — auto-activates a brand-new first account and ensures the
|
|
1710
2159
|
* rotation-settings row exists.
|
|
1711
2160
|
*/
|
|
2161
|
+
type UpsertCodexSubscriptionCredentialResult = {
|
|
2162
|
+
kind: "upserted";
|
|
2163
|
+
id: string;
|
|
2164
|
+
isNew: boolean;
|
|
2165
|
+
} | {
|
|
2166
|
+
kind: "unresolved_redemption";
|
|
2167
|
+
id: string;
|
|
2168
|
+
isNew: false;
|
|
2169
|
+
};
|
|
1712
2170
|
declare function upsertCodexSubscriptionCredential(db: Database, input: {
|
|
1713
2171
|
accountId: string;
|
|
1714
2172
|
workspaceId: string;
|
|
@@ -1721,10 +2179,9 @@ declare function upsertCodexSubscriptionCredential(db: Database, input: {
|
|
|
1721
2179
|
lastRefreshAt: Date | null;
|
|
1722
2180
|
accountEmail?: string | null;
|
|
1723
2181
|
label?: string | null;
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
}>;
|
|
2182
|
+
/** Direct managed-cookie human who most recently connected this row. */
|
|
2183
|
+
connectedBySubjectId?: string | null;
|
|
2184
|
+
}): Promise<UpsertCodexSubscriptionCredentialResult>;
|
|
1728
2185
|
/**
|
|
1729
2186
|
* The ONLY decrypt-read accessor. Fails closed. Never call from an API route that
|
|
1730
2187
|
* returns the result.
|
|
@@ -1853,6 +2310,12 @@ type CodexAccountStatus = {
|
|
|
1853
2310
|
status: string;
|
|
1854
2311
|
/** New automatic allocations only; health/refresh and existing turns remain independent. */
|
|
1855
2312
|
allocatorEnabled: boolean;
|
|
2313
|
+
allocatorVersion: number;
|
|
2314
|
+
allocatorUpdatedBySubjectId: string | null;
|
|
2315
|
+
allocatorUpdatedAt: Date | null;
|
|
2316
|
+
resetCreditAvailableCount: number | null;
|
|
2317
|
+
resetCreditsCheckedAt: Date | null;
|
|
2318
|
+
connectedBySubjectId: string | null;
|
|
1856
2319
|
isActive: boolean;
|
|
1857
2320
|
expiresAt: Date | null;
|
|
1858
2321
|
lastRefreshAt: Date | null;
|
|
@@ -1872,7 +2335,7 @@ type CodexAccountStatus = {
|
|
|
1872
2335
|
* the selection cursor gives deterministic fairness after those holders drain.
|
|
1873
2336
|
* None of these fields contains credential material.
|
|
1874
2337
|
*/
|
|
1875
|
-
type CodexLeaseAccountStatus = CodexAccountStatus & {
|
|
2338
|
+
type CodexLeaseAccountStatus = Omit<CodexAccountStatus, "allocatorVersion" | "allocatorUpdatedBySubjectId" | "allocatorUpdatedAt" | "resetCreditAvailableCount" | "resetCreditsCheckedAt" | "connectedBySubjectId"> & {
|
|
1876
2339
|
activeLeaseCount: number;
|
|
1877
2340
|
selectionCount: number;
|
|
1878
2341
|
lastSelectedAt: Date | null;
|
|
@@ -1880,8 +2343,8 @@ type CodexLeaseAccountStatus = CodexAccountStatus & {
|
|
|
1880
2343
|
/**
|
|
1881
2344
|
* Opaque accepted-turn policy scope resolved while the durable turn is locked.
|
|
1882
2345
|
*
|
|
1883
|
-
*
|
|
1884
|
-
* allocator policy
|
|
2346
|
+
* This API deliberately does not know the shape of named pools. A downstream
|
|
2347
|
+
* allocator policy owns its private scope type and supplies a pure
|
|
1885
2348
|
* metadata resolver. The resolved value is handed to the selector in the same
|
|
1886
2349
|
* workspace rotation-row transaction as lease acquisition, so future pool
|
|
1887
2350
|
* membership filtering cannot race the accepted turn's frozen policy.
|
|
@@ -1966,7 +2429,7 @@ declare function acquireCodexCredentialLease<T, TPolicyScope = never, TUnavailab
|
|
|
1966
2429
|
/**
|
|
1967
2430
|
* Optional downstream parser for private accepted-turn policy metadata.
|
|
1968
2431
|
* It is pure, runs under the turn/rotation transaction, and must not query
|
|
1969
|
-
* pool membership itself.
|
|
2432
|
+
* pool membership itself. This module stores or interprets no pool identifiers.
|
|
1970
2433
|
*/
|
|
1971
2434
|
resolvePolicyScope?: CodexCredentialLeasePolicyScopeResolver<TPolicyScope>;
|
|
1972
2435
|
/**
|
|
@@ -2070,11 +2533,13 @@ declare const CODEX_CAPACITY_REFRESH_MAX_MS: number;
|
|
|
2070
2533
|
declare function codexCapacityRefreshBackoffMs(attempt: number): number;
|
|
2071
2534
|
/**
|
|
2072
2535
|
* Atomically settle one all-unavailable turn and arm exactly one durable wait.
|
|
2073
|
-
* Lock order is allocator rotation row ->
|
|
2074
|
-
*
|
|
2075
|
-
*
|
|
2076
|
-
*
|
|
2077
|
-
*
|
|
2536
|
+
* Lock order is allocator rotation row -> workspace control -> actual workspace
|
|
2537
|
+
* -> session -> exact turn -> exact attempt -> goal -> live lease (when a
|
|
2538
|
+
* reactive failure owns one) -> waiter. The control share lock and effective
|
|
2539
|
+
* control recheck prevent a capacity boundary from closing an attempt after a
|
|
2540
|
+
* committed Pause. The failed turn, idle/capacity-paused session, durable
|
|
2541
|
+
* events, lease release, and waiter generation commit together; a crash cannot
|
|
2542
|
+
* leave only half of the boundary visible.
|
|
2078
2543
|
*/
|
|
2079
2544
|
declare function armCodexCapacityWait(db: Database, input: {
|
|
2080
2545
|
accountId: string;
|
|
@@ -2100,8 +2565,8 @@ declare function armCodexCapacityWait(db: Database, input: {
|
|
|
2100
2565
|
}): Promise<ArmCodexCapacityWaitResult>;
|
|
2101
2566
|
declare function getCodexCapacityWaitForSession(db: Database, workspaceId: string, sessionId: string): Promise<CodexCapacityWait | null>;
|
|
2102
2567
|
/**
|
|
2103
|
-
* Same-transaction capacity-mutation/outbox seam for
|
|
2104
|
-
*
|
|
2568
|
+
* Same-transaction capacity-mutation/outbox seam for account eligibility and
|
|
2569
|
+
* policy-scope membership/default changes. The allocator rotation row is always the
|
|
2105
2570
|
* first lock. Mutations report whether capacity truth changed; only then are
|
|
2106
2571
|
* matching waiter wake revisions advanced and returned for best-effort signal.
|
|
2107
2572
|
*/
|
|
@@ -2172,13 +2637,198 @@ declare function quarantineCodexCredentialForLease(db: Database, input: {
|
|
|
2172
2637
|
* the workspace active pointer. Ordered by created_at ASC (stable list order).
|
|
2173
2638
|
*/
|
|
2174
2639
|
declare function listCodexAccountStatuses(db: Database, workspaceId: string): Promise<CodexAccountStatus[]>;
|
|
2640
|
+
type CodexAllocatorUpdateResult = {
|
|
2641
|
+
kind: "updated" | "unchanged";
|
|
2642
|
+
allocatorEnabled: boolean;
|
|
2643
|
+
allocatorVersion: number;
|
|
2644
|
+
allocatorUpdatedBySubjectId: string | null;
|
|
2645
|
+
allocatorUpdatedAt: Date | null;
|
|
2646
|
+
} | {
|
|
2647
|
+
kind: "conflict";
|
|
2648
|
+
allocatorEnabled: boolean;
|
|
2649
|
+
allocatorVersion: number;
|
|
2650
|
+
allocatorUpdatedBySubjectId: string | null;
|
|
2651
|
+
allocatorUpdatedAt: Date | null;
|
|
2652
|
+
} | {
|
|
2653
|
+
kind: "not_found";
|
|
2654
|
+
};
|
|
2655
|
+
/**
|
|
2656
|
+
* Toggle only NEW allocator eligibility under credential-row OCC.
|
|
2657
|
+
*
|
|
2658
|
+
* Same-state writes are idempotent even when `expectedVersion` is stale. A real
|
|
2659
|
+
* state transition requires the exact current version, increments only the
|
|
2660
|
+
* allocator version, and writes one audit row in the same transaction. It never
|
|
2661
|
+
* touches credential `version`, health, encrypted material, cooldown, or quota.
|
|
2662
|
+
*/
|
|
2663
|
+
declare function updateCodexAllocatorEligibility(db: Database, input: {
|
|
2664
|
+
accountId: string;
|
|
2665
|
+
workspaceId: string;
|
|
2666
|
+
credentialId: string;
|
|
2667
|
+
subjectId: string;
|
|
2668
|
+
enabled: boolean;
|
|
2669
|
+
expectedVersion: number;
|
|
2670
|
+
}): Promise<CodexCapacityMutationResult<CodexAllocatorUpdateResult>>;
|
|
2671
|
+
declare const CODEX_RESET_REDEMPTION_OUTCOMES: readonly ["reset", "nothingToReset", "noCredit", "alreadyRedeemed"];
|
|
2672
|
+
type CodexResetRedemptionOutcome = (typeof CODEX_RESET_REDEMPTION_OUTCOMES)[number];
|
|
2673
|
+
type CodexResetRedemptionStatus = "processing" | "provider_started" | "completed";
|
|
2674
|
+
type CodexResetRedemptionAttempt = {
|
|
2675
|
+
id: string;
|
|
2676
|
+
accountId: string;
|
|
2677
|
+
workspaceId: string;
|
|
2678
|
+
credentialId: string;
|
|
2679
|
+
subjectId: string;
|
|
2680
|
+
browserSessionHash: string;
|
|
2681
|
+
creditId: string;
|
|
2682
|
+
upstreamIdempotencyKey: string;
|
|
2683
|
+
status: CodexResetRedemptionStatus;
|
|
2684
|
+
outcome: CodexResetRedemptionOutcome | null;
|
|
2685
|
+
claimHolderId: string | null;
|
|
2686
|
+
claimExpiresAt: Date | null;
|
|
2687
|
+
confirmationExpiresAt: Date;
|
|
2688
|
+
providerStartedAt: Date | null;
|
|
2689
|
+
completedAt: Date | null;
|
|
2690
|
+
lastFailureKind: string | null;
|
|
2691
|
+
retryCount: number;
|
|
2692
|
+
createdAt: Date;
|
|
2693
|
+
updatedAt: Date;
|
|
2694
|
+
};
|
|
2695
|
+
/** Metadata-only attempt read used to resume a browser-session-bound ambiguity. */
|
|
2696
|
+
declare function getCodexResetRedemptionAttempt(db: Database, workspaceId: string, attemptId: string): Promise<CodexResetRedemptionAttempt | null>;
|
|
2697
|
+
type CodexResetRedemptionRecovery = {
|
|
2698
|
+
attemptId: string;
|
|
2699
|
+
credentialId: string;
|
|
2700
|
+
creditId: string;
|
|
2701
|
+
status: "provider_started" | "completed";
|
|
2702
|
+
outcome: CodexResetRedemptionOutcome | null;
|
|
2703
|
+
providerStartedAt: Date | null;
|
|
2704
|
+
completedAt: Date | null;
|
|
2705
|
+
createdAt: Date;
|
|
2706
|
+
updatedAt: Date;
|
|
2707
|
+
};
|
|
2708
|
+
/**
|
|
2709
|
+
* Cookie-owner discovery source for durable ambiguous/completed attempts.
|
|
2710
|
+
* Browser storage is never required to recover these non-secret identifiers.
|
|
2711
|
+
*/
|
|
2712
|
+
declare function listCodexResetRedemptionRecoveries(db: Database, input: {
|
|
2713
|
+
accountId: string;
|
|
2714
|
+
workspaceId: string;
|
|
2715
|
+
subjectId: string;
|
|
2716
|
+
}): Promise<CodexResetRedemptionRecovery[]>;
|
|
2717
|
+
type AdoptCodexResetRedemptionResult = {
|
|
2718
|
+
kind: "current" | "adopted";
|
|
2719
|
+
attempt: CodexResetRedemptionAttempt;
|
|
2720
|
+
} | {
|
|
2721
|
+
kind: "in_progress";
|
|
2722
|
+
} | {
|
|
2723
|
+
kind: "not_found";
|
|
2724
|
+
} | {
|
|
2725
|
+
kind: "forbidden";
|
|
2726
|
+
} | {
|
|
2727
|
+
kind: "conflict";
|
|
2728
|
+
};
|
|
2729
|
+
/** Adopt a released durable ambiguity/completion into the owner's current browser session. */
|
|
2730
|
+
declare function adoptCodexResetRedemptionAttempt(db: Database, input: {
|
|
2731
|
+
accountId: string;
|
|
2732
|
+
workspaceId: string;
|
|
2733
|
+
attemptId: string;
|
|
2734
|
+
credentialId: string;
|
|
2735
|
+
creditId: string;
|
|
2736
|
+
subjectId: string;
|
|
2737
|
+
browserSessionHash: string;
|
|
2738
|
+
}): Promise<AdoptCodexResetRedemptionResult>;
|
|
2739
|
+
type ClaimCodexResetRedemptionResult = {
|
|
2740
|
+
kind: "claimed";
|
|
2741
|
+
attempt: CodexResetRedemptionAttempt;
|
|
2742
|
+
} | {
|
|
2743
|
+
kind: "in_progress";
|
|
2744
|
+
attempt: CodexResetRedemptionAttempt;
|
|
2745
|
+
} | {
|
|
2746
|
+
kind: "completed";
|
|
2747
|
+
attempt: CodexResetRedemptionAttempt;
|
|
2748
|
+
} | {
|
|
2749
|
+
kind: "not_found";
|
|
2750
|
+
} | {
|
|
2751
|
+
kind: "forbidden";
|
|
2752
|
+
} | {
|
|
2753
|
+
kind: "conflict";
|
|
2754
|
+
};
|
|
2755
|
+
/**
|
|
2756
|
+
* Claim or reclaim one logical redemption across API replicas/crashes.
|
|
2757
|
+
*
|
|
2758
|
+
* A transaction advisory lock closes the initial INSERT race. A live claim
|
|
2759
|
+
* yields `in_progress`; an expired/released claim is reclaimed without changing
|
|
2760
|
+
* the status or upstream key. Existing attempt identity is immutable.
|
|
2761
|
+
*/
|
|
2762
|
+
declare function claimCodexResetRedemption(db: Database, input: {
|
|
2763
|
+
id: string;
|
|
2764
|
+
accountId: string;
|
|
2765
|
+
workspaceId: string;
|
|
2766
|
+
credentialId: string;
|
|
2767
|
+
subjectId: string;
|
|
2768
|
+
browserSessionHash: string;
|
|
2769
|
+
creditId: string;
|
|
2770
|
+
confirmationExpiresAt: Date;
|
|
2771
|
+
claimHolderId: string;
|
|
2772
|
+
claimTtlMs?: number;
|
|
2773
|
+
}): Promise<ClaimCodexResetRedemptionResult>;
|
|
2774
|
+
type CodexResetRedemptionSendNotReadyReason = "not_found" | "identity_mismatch" | "claim_expired" | "confirmation_expired" | "credential_unavailable" | "already_completed";
|
|
2775
|
+
type FenceCodexResetRedemptionSendResult = {
|
|
2776
|
+
kind: "ready";
|
|
2777
|
+
attempt: CodexResetRedemptionAttempt;
|
|
2778
|
+
} | {
|
|
2779
|
+
kind: "not_ready";
|
|
2780
|
+
reason: CodexResetRedemptionSendNotReadyReason;
|
|
2781
|
+
};
|
|
2782
|
+
/**
|
|
2783
|
+
* Final DB-time irreversible-send fence, called only after preflight and token
|
|
2784
|
+
* resolution and immediately before every provider POST (including ambiguity
|
|
2785
|
+
* retries). The credential SHARE lock serializes against disconnect and
|
|
2786
|
+
* ownership-changing reconnect. The claim is extended beyond the bounded
|
|
2787
|
+
* consume operation in the same transaction that persists provider_started.
|
|
2788
|
+
*/
|
|
2789
|
+
declare function fenceCodexResetRedemptionSend(db: Database, input: {
|
|
2790
|
+
accountId: string;
|
|
2791
|
+
workspaceId: string;
|
|
2792
|
+
attemptId: string;
|
|
2793
|
+
claimHolderId: string;
|
|
2794
|
+
credentialId: string;
|
|
2795
|
+
subjectId: string;
|
|
2796
|
+
browserSessionHash: string;
|
|
2797
|
+
sendLeaseMs?: number;
|
|
2798
|
+
}): Promise<FenceCodexResetRedemptionSendResult>;
|
|
2799
|
+
/** Delete only definite pre-provider work still owned by this request. */
|
|
2800
|
+
declare function abandonCodexResetRedemptionBeforeProvider(db: Database, input: {
|
|
2801
|
+
accountId: string;
|
|
2802
|
+
workspaceId: string;
|
|
2803
|
+
attemptId: string;
|
|
2804
|
+
claimHolderId: string;
|
|
2805
|
+
}): Promise<boolean>;
|
|
2806
|
+
/** Release a failed claim while preserving processing/provider_started truth. */
|
|
2807
|
+
declare function releaseCodexResetRedemptionClaim(db: Database, input: {
|
|
2808
|
+
accountId: string;
|
|
2809
|
+
workspaceId: string;
|
|
2810
|
+
attemptId: string;
|
|
2811
|
+
claimHolderId: string;
|
|
2812
|
+
failureKind: string;
|
|
2813
|
+
}): Promise<boolean>;
|
|
2814
|
+
/** Persist the exact provider outcome, cooldown repair, and audit atomically. */
|
|
2815
|
+
declare function completeCodexResetRedemption(db: Database, input: {
|
|
2816
|
+
accountId: string;
|
|
2817
|
+
workspaceId: string;
|
|
2818
|
+
attemptId: string;
|
|
2819
|
+
claimHolderId: string;
|
|
2820
|
+
outcome: CodexResetRedemptionOutcome;
|
|
2821
|
+
}): Promise<CodexCapacityMutationResult<CodexResetRedemptionAttempt | null>>;
|
|
2175
2822
|
/** The P2 usage-cache snapshot written by the refreshing usage wrapper. */
|
|
2176
2823
|
type CodexAccountUsageSnapshot = {
|
|
2177
|
-
primaryUsedPercent
|
|
2178
|
-
primaryResetAt
|
|
2179
|
-
secondaryUsedPercent
|
|
2180
|
-
secondaryResetAt
|
|
2181
|
-
|
|
2824
|
+
primaryUsedPercent?: number | null;
|
|
2825
|
+
primaryResetAt?: Date | null;
|
|
2826
|
+
secondaryUsedPercent?: number | null;
|
|
2827
|
+
secondaryResetAt?: Date | null;
|
|
2828
|
+
/** Present only when the quota body parsed successfully. */
|
|
2829
|
+
checkedAt?: Date;
|
|
2830
|
+
resetCreditAvailableCount?: number | null;
|
|
2831
|
+
resetCreditsCheckedAt?: Date | null;
|
|
2182
2832
|
};
|
|
2183
2833
|
/**
|
|
2184
2834
|
* Cache-write for P2 quota bars: persist the five plaintext usage columns on a
|
|
@@ -2324,9 +2974,13 @@ declare function recordSessionActiveCodexCredential(db: Database, workspaceId: s
|
|
|
2324
2974
|
declare function disconnectCodexAccount(db: Database, workspaceId: string, credentialId: string): Promise<{
|
|
2325
2975
|
removed: boolean;
|
|
2326
2976
|
newActiveCredentialId: string | null;
|
|
2977
|
+
blockedByUnresolvedRedemption: boolean;
|
|
2978
|
+
}>;
|
|
2979
|
+
/** Legacy "disconnect all"; atomically rejects when any provider work is unresolved. */
|
|
2980
|
+
declare function disconnectAllCodexAccounts(db: Database, workspaceId: string): Promise<{
|
|
2981
|
+
removed: number;
|
|
2982
|
+
blockedCredentialIds: string[];
|
|
2327
2983
|
}>;
|
|
2328
|
-
/** Legacy "disconnect all" (old workspace-wide behavior). Returns rows removed. */
|
|
2329
|
-
declare function disconnectAllCodexAccounts(db: Database, workspaceId: string): Promise<number>;
|
|
2330
2984
|
declare function recordAuditEvent(db: Database, input: {
|
|
2331
2985
|
accountId: string;
|
|
2332
2986
|
workspaceId?: string | null;
|
|
@@ -2343,19 +2997,55 @@ declare function createSessionMcpServers(db: Database, input: {
|
|
|
2343
2997
|
servers: CreateSessionMcpServerInput[];
|
|
2344
2998
|
}): Promise<SessionMcpServerMetadata[]>;
|
|
2345
2999
|
declare function listSessionMcpServerMetadata(db: Database, workspaceId: string, sessionId: string): Promise<SessionMcpServerMetadata[]>;
|
|
3000
|
+
/**
|
|
3001
|
+
* Returns the complete stored server configuration needed to snapshot an
|
|
3002
|
+
* immediate parent's MCP context onto a child session. Credential values stay
|
|
3003
|
+
* encrypted throughout this path: the core can copy the ciphertext into the
|
|
3004
|
+
* child's rows, but it never receives plaintext headers.
|
|
3005
|
+
*
|
|
3006
|
+
* This is intentionally distinct from `listSessionMcpServersForRun`, whose
|
|
3007
|
+
* worker-only responsibility is decrypting credentials at the execution
|
|
3008
|
+
* boundary.
|
|
3009
|
+
*/
|
|
3010
|
+
declare function listSessionMcpServersForChildInheritance(db: Database, workspaceId: string, sessionId: string): Promise<CreateSessionMcpServerInput[]>;
|
|
2346
3011
|
declare function updateSessionMcpServerCredentials(db: Database, input: {
|
|
2347
3012
|
workspaceId: string;
|
|
2348
3013
|
sessionId: string;
|
|
2349
3014
|
updates: UpdateSessionMcpServerCredentialsInput[];
|
|
2350
3015
|
}): Promise<UpdateSessionMcpServerCredentialsResult>;
|
|
2351
|
-
declare function
|
|
3016
|
+
declare function updateSessionMcpApprovalPolicy(db: Database, input: {
|
|
3017
|
+
workspaceId: string;
|
|
3018
|
+
sessionId: string;
|
|
3019
|
+
serverId: string;
|
|
3020
|
+
requireApproval: SessionMcpApprovalPolicy;
|
|
3021
|
+
}): Promise<UpdateSessionMcpApprovalPolicyResult>;
|
|
3022
|
+
declare function listSessionMcpServersForRun(db: Database, workspaceId: string, sessionId: string, attemptId: string, encryptionKey: Uint8Array | null): Promise<SessionMcpServerForRun[]>;
|
|
3023
|
+
type AgentSessionCreationActor = Extract<SessionCommandActor, {
|
|
3024
|
+
type: "agent_attempt";
|
|
3025
|
+
}>;
|
|
3026
|
+
/** A caller-preallocated session UUID is already owned by another session. */
|
|
3027
|
+
declare class SessionIdConflictError extends Error {
|
|
3028
|
+
readonly sessionId: string;
|
|
3029
|
+
constructor(sessionId: string);
|
|
3030
|
+
}
|
|
2352
3031
|
declare function createSession(db: Database, input: {
|
|
3032
|
+
requestedSessionId?: string;
|
|
2353
3033
|
accountId: string;
|
|
2354
3034
|
workspaceId: string;
|
|
2355
3035
|
initialMessage: string;
|
|
3036
|
+
initialTurnInstructions?: string | null;
|
|
2356
3037
|
resources: ResourceRef[];
|
|
2357
3038
|
tools?: ToolRef[];
|
|
3039
|
+
toolPolicy?: SessionToolPolicy | null;
|
|
2358
3040
|
metadata: Record<string, unknown>;
|
|
3041
|
+
/**
|
|
3042
|
+
* Frozen creator authority. Legacy/test-only callers may omit this and get
|
|
3043
|
+
* an explicit unattributed service sentinel; production producers must pass
|
|
3044
|
+
* an authenticated subject or named service.
|
|
3045
|
+
*/
|
|
3046
|
+
createdBy?: TurnInitiator;
|
|
3047
|
+
createdByContext?: TurnInitiatorContext;
|
|
3048
|
+
createdByActor?: AgentSessionCreationActor | null;
|
|
2359
3049
|
model: string;
|
|
2360
3050
|
sandboxBackend: SandboxBackend;
|
|
2361
3051
|
variableSetId?: string | null;
|
|
@@ -2380,12 +3070,18 @@ declare function createSession(db: Database, input: {
|
|
|
2380
3070
|
* the row already existed and must be returned as-is).
|
|
2381
3071
|
*/
|
|
2382
3072
|
declare function createSessionWithIdempotencyKey(db: Database, input: {
|
|
3073
|
+
requestedSessionId?: string;
|
|
2383
3074
|
accountId: string;
|
|
2384
3075
|
workspaceId: string;
|
|
2385
3076
|
initialMessage: string;
|
|
3077
|
+
initialTurnInstructions?: string | null;
|
|
2386
3078
|
resources: ResourceRef[];
|
|
2387
3079
|
tools?: ToolRef[];
|
|
3080
|
+
toolPolicy?: SessionToolPolicy | null;
|
|
2388
3081
|
metadata: Record<string, unknown>;
|
|
3082
|
+
createdBy?: TurnInitiator;
|
|
3083
|
+
createdByContext?: TurnInitiatorContext;
|
|
3084
|
+
createdByActor?: AgentSessionCreationActor | null;
|
|
2389
3085
|
model: string;
|
|
2390
3086
|
sandboxBackend: SandboxBackend;
|
|
2391
3087
|
variableSetId?: string | null;
|
|
@@ -2441,6 +3137,7 @@ type ListSessionsForSubjectOptions = ListSessionsOptions & {
|
|
|
2441
3137
|
subjectId: string;
|
|
2442
3138
|
cursor?: SessionListCursor | undefined;
|
|
2443
3139
|
search?: string | undefined;
|
|
3140
|
+
authorizationScope?: SessionAuthorizationListScope | undefined;
|
|
2444
3141
|
};
|
|
2445
3142
|
declare class SessionPinVersionConflictError extends Error {
|
|
2446
3143
|
readonly current: Pick<Session, "pinned" | "pinnedAt" | "pinVersion">;
|
|
@@ -2455,6 +3152,32 @@ declare class SessionListAccessError extends Error {
|
|
|
2455
3152
|
declare class SessionPinAccessError extends Error {
|
|
2456
3153
|
constructor(message?: string);
|
|
2457
3154
|
}
|
|
3155
|
+
type SessionTreeStats = NonNullable<Session["treeStats"]>;
|
|
3156
|
+
/**
|
|
3157
|
+
* Remove control metadata derived from sessions other than the exact target.
|
|
3158
|
+
* Effective state and the opaque OCC etag remain usable without exposing
|
|
3159
|
+
* ancestor ids/titles/actors/reasons or descendant settlement facts.
|
|
3160
|
+
*/
|
|
3161
|
+
declare function projectEffectiveControlForRelatedAccess(control: Session["effectiveControl"], sessionId: string, access: "target" | "root"): Session["effectiveControl"];
|
|
3162
|
+
/**
|
|
3163
|
+
* Remove metadata derived from sessions other than the exact authorized
|
|
3164
|
+
* target, including parent identity and descendant counts.
|
|
3165
|
+
*/
|
|
3166
|
+
declare function projectSessionForRelatedAccess(session: Session, access: "target" | "root"): Session;
|
|
3167
|
+
/**
|
|
3168
|
+
* Return bounded descendant aggregates for the bounded set of rows being
|
|
3169
|
+
* painted in the session rail. Each selected root receives an independent
|
|
3170
|
+
* fixed node/depth budget. `truncated=true` makes every count an explicit lower
|
|
3171
|
+
* bound when a deep, wide, overlapping, or cyclic graph reaches that budget.
|
|
3172
|
+
*/
|
|
3173
|
+
declare function sessionTreeStatsForSessions(db: Database, workspaceId: string, rootIds: string[]): Promise<Map<string, SessionTreeStats>>;
|
|
3174
|
+
/**
|
|
3175
|
+
* Convert the embedding host's complete list scope into a workspace-bound SQL
|
|
3176
|
+
* predicate. Root scopes include every descendant through the durable parent
|
|
3177
|
+
* graph; exact ids never imply access to related sessions. `UNION` (rather than
|
|
3178
|
+
* `UNION ALL`) makes legacy cycles terminate without a caller-sized path array.
|
|
3179
|
+
*/
|
|
3180
|
+
declare function sessionAuthorizationScopeFilter(scope: SessionAuthorizationListScope): SQL;
|
|
2458
3181
|
/** Opaque, URL-safe cursor encoding for a server-owned activity snapshot. */
|
|
2459
3182
|
declare function encodeSessionListCursor(cursor: SessionListCursor): string;
|
|
2460
3183
|
/** Decode and validate a cursor before it reaches any SQL predicate. */
|
|
@@ -2471,7 +3194,7 @@ declare function reapExpiredSessionListSnapshots(db: Database, limit?: number):
|
|
|
2471
3194
|
*/
|
|
2472
3195
|
declare function listSessionsForSubject(db: Database, workspaceId: string, options: ListSessionsForSubjectOptions): Promise<SessionListResponse>;
|
|
2473
3196
|
/** Read a session with the caller subject's personal pin projection. */
|
|
2474
|
-
declare function getSessionForSubject(db: Database, workspaceId: string, sessionId: string, subjectId: string): Promise<Session | null>;
|
|
3197
|
+
declare function getSessionForSubject(db: Database, workspaceId: string, sessionId: string, subjectId: string, relatedSessionAccess?: "target" | "root"): Promise<Session | null>;
|
|
2475
3198
|
/**
|
|
2476
3199
|
* Idempotently set a member's pin without mutating the session's lifecycle or
|
|
2477
3200
|
* activity timestamps. A transaction advisory lock serializes same-subject,
|
|
@@ -2486,11 +3209,83 @@ declare function setSessionPin(db: Database, input: {
|
|
|
2486
3209
|
}): Promise<Session | null>;
|
|
2487
3210
|
declare function listSessions(db: Database, workspaceId: string, limit?: number): Promise<Session[]>;
|
|
2488
3211
|
declare function listSessions(db: Database, workspaceId: string, options?: ListSessionsOptions): Promise<Session[]>;
|
|
3212
|
+
type SessionDiscoveryOrderBy = "createdAt" | "updatedAt";
|
|
3213
|
+
type SessionDiscoveryCursor = {
|
|
3214
|
+
orderBy: SessionDiscoveryOrderBy;
|
|
3215
|
+
/** Decimal database activity revision; zero is the legacy/created-order bucket. */
|
|
3216
|
+
sortRevision: string;
|
|
3217
|
+
/** Exact PostgreSQL timestamp text (including microseconds), not a JS Date. */
|
|
3218
|
+
sortAt: string;
|
|
3219
|
+
id: string;
|
|
3220
|
+
/** Created-order timestamp ceiling; retained as diagnostic context for updated order. */
|
|
3221
|
+
snapshotAt: string;
|
|
3222
|
+
/** First-page revision fence: later activity belongs to the next incremental scan. */
|
|
3223
|
+
snapshotRevision: string;
|
|
3224
|
+
/** Incremental revision scope is cursor-bound and cannot change on continuation. */
|
|
3225
|
+
updatedAfter: string | null;
|
|
3226
|
+
};
|
|
3227
|
+
declare const SESSION_DISCOVERY_GOAL_MAX_CHARS = 600;
|
|
3228
|
+
declare const SESSION_DISCOVERY_MESSAGE_MAX_CHARS = 600;
|
|
3229
|
+
type SessionDiscoverySummary = {
|
|
3230
|
+
id: string;
|
|
3231
|
+
title: string | null;
|
|
3232
|
+
titleOriginalChars: number | null;
|
|
3233
|
+
parentSessionId: string | null;
|
|
3234
|
+
status: SessionStatus;
|
|
3235
|
+
effectiveControl: SessionDiscoveryControl;
|
|
3236
|
+
goal: {
|
|
3237
|
+
status: SessionGoalStatus;
|
|
3238
|
+
text: string;
|
|
3239
|
+
textOriginalChars: number;
|
|
3240
|
+
} | null;
|
|
3241
|
+
queuedPromptCount: number;
|
|
3242
|
+
treeStats: NonNullable<Session["treeStats"]>;
|
|
3243
|
+
latestMessage: {
|
|
3244
|
+
type: SessionEventType;
|
|
3245
|
+
preview: string | null;
|
|
3246
|
+
previewOriginalChars: number | null;
|
|
3247
|
+
} | null;
|
|
3248
|
+
createdAt: string;
|
|
3249
|
+
updatedAt: string;
|
|
3250
|
+
/** Internal exact revision key; omitted from the MCP row projection. */
|
|
3251
|
+
sortRevision: string;
|
|
3252
|
+
/** Internal exact keyset timestamp; omitted from the MCP row projection. */
|
|
3253
|
+
sortAt: string;
|
|
3254
|
+
};
|
|
3255
|
+
/**
|
|
3256
|
+
* Compact-by-construction discovery projection for the first-party
|
|
3257
|
+
* `sessions_list` MCP tool. It never selects instructions, resources, tools,
|
|
3258
|
+
* MCP metadata, repositories, settings, or full event/history bodies.
|
|
3259
|
+
*/
|
|
3260
|
+
declare function listSessionDiscoverySummaries(db: Database, workspaceId: string, options: {
|
|
3261
|
+
limit: number;
|
|
3262
|
+
cursor?: SessionDiscoveryCursor;
|
|
3263
|
+
includeLastMessage?: boolean;
|
|
3264
|
+
orderBy?: SessionDiscoveryOrderBy;
|
|
3265
|
+
updatedAfter?: string;
|
|
3266
|
+
authorizationScope?: SessionAuthorizationListScope;
|
|
3267
|
+
}): Promise<{
|
|
3268
|
+
sessions: SessionDiscoverySummary[];
|
|
3269
|
+
hasMore: boolean;
|
|
3270
|
+
nextCursor: SessionDiscoveryCursor | null;
|
|
3271
|
+
total: number;
|
|
3272
|
+
orderBy: SessionDiscoveryOrderBy;
|
|
3273
|
+
snapshotAt: string;
|
|
3274
|
+
snapshotRevision: string;
|
|
3275
|
+
updatedThrough: string | null;
|
|
3276
|
+
updatedAfter: string | null;
|
|
3277
|
+
}>;
|
|
2489
3278
|
type SessionLineage = {
|
|
2490
3279
|
ancestors: Session[];
|
|
2491
3280
|
children: LineageNode[];
|
|
2492
3281
|
truncated: boolean;
|
|
2493
3282
|
};
|
|
3283
|
+
/**
|
|
3284
|
+
* Resolve a session tree to its root without materializing the full lineage.
|
|
3285
|
+
* Every recursive hop stays workspace-scoped and invalid/cyclic/deep chains
|
|
3286
|
+
* fail closed instead of returning an ambiguous credential authority.
|
|
3287
|
+
*/
|
|
3288
|
+
declare function getSessionRootId(db: Database, workspaceId: string, sessionId: string): Promise<string | null>;
|
|
2494
3289
|
/**
|
|
2495
3290
|
* Read the full lineage slice around a session. Every recursive step carries
|
|
2496
3291
|
* workspace_id as a hard predicate; a foreign parent/child id is invisible even
|
|
@@ -2511,16 +3306,80 @@ type ListSessionEventsOptions = {
|
|
|
2511
3306
|
after?: number;
|
|
2512
3307
|
before?: number;
|
|
2513
3308
|
limit?: number;
|
|
3309
|
+
direction?: SessionEventReadDirection;
|
|
3310
|
+
includeTypes?: readonly SessionEventType[];
|
|
3311
|
+
excludeTypes?: readonly SessionEventType[];
|
|
3312
|
+
includeClasses?: readonly SessionEventSemanticClass[];
|
|
3313
|
+
excludeClasses?: readonly SessionEventSemanticClass[];
|
|
3314
|
+
defaultExcludeTypes?: readonly SessionEventType[];
|
|
3315
|
+
payloadMode?: SessionEventPayloadMode;
|
|
3316
|
+
/**
|
|
3317
|
+
* Internal exclusive-latest selector. Eligible legacy rows with a null
|
|
3318
|
+
* association remain visible, while late-rejected and duplicate callbacks do
|
|
3319
|
+
* not compete with current truth. Durable session sequence is authoritative
|
|
3320
|
+
* across distinct turns; turn generation is metadata only here. Callers must
|
|
3321
|
+
* pair this with a single semantic class and limit 1.
|
|
3322
|
+
*/
|
|
3323
|
+
authoritativeLatest?: boolean;
|
|
3324
|
+
};
|
|
3325
|
+
type ListSessionEventPageOptions = ListSessionEventsOptions & {
|
|
3326
|
+
/** Exact UTF-8 JSON-array envelope budget for rows materialized by the app. */
|
|
3327
|
+
maxBytes?: number;
|
|
3328
|
+
/** Internal SQL fetch size. Batches never escape the surrounding RLS transaction. */
|
|
3329
|
+
batchSize?: number;
|
|
2514
3330
|
};
|
|
3331
|
+
type SessionEventPage = {
|
|
3332
|
+
events: SessionEvent[];
|
|
3333
|
+
hasMore: boolean;
|
|
3334
|
+
bytes: number;
|
|
3335
|
+
direction: SessionEventReadDirection;
|
|
3336
|
+
coveredSequence: {
|
|
3337
|
+
first: number;
|
|
3338
|
+
last: number;
|
|
3339
|
+
} | null;
|
|
3340
|
+
nextAfter: number | null;
|
|
3341
|
+
nextBefore: number | null;
|
|
3342
|
+
truncatedBy: "count" | "bytes" | null;
|
|
3343
|
+
};
|
|
3344
|
+
declare const SESSION_EVENT_DB_PAGE_MAX_BYTES: number;
|
|
3345
|
+
/**
|
|
3346
|
+
* Read one direction-aware session-event page without transferring legacy raw
|
|
3347
|
+
* payloads or malformed free-form envelope strings out of PostgreSQL.
|
|
3348
|
+
*
|
|
3349
|
+
* Migration 0067 deliberately leaves historical rows untouched. This query
|
|
3350
|
+
* invokes its immutable payload projector in SQL and mirrors the rolling
|
|
3351
|
+
* envelope guard in SQL, then accumulates small batches under one RLS
|
|
3352
|
+
* transaction. `bytes` is the exact UTF-8 size of `JSON.stringify(events)`;
|
|
3353
|
+
* `hasMore` is true whenever count or byte selection stopped before the durable
|
|
3354
|
+
* range ended. A nonempty durable range can therefore never become an empty,
|
|
3355
|
+
* non-advancing HTTP page.
|
|
3356
|
+
*/
|
|
3357
|
+
declare function listSessionEventPage(db: Database, workspaceId: string, sessionId: string, options?: ListSessionEventPageOptions): Promise<SessionEventPage>;
|
|
2515
3358
|
declare function listSessionEvents(db: Database, workspaceId: string, sessionId: string): Promise<SessionEvent[]>;
|
|
2516
3359
|
declare function listSessionEvents(db: Database, workspaceId: string, sessionId: string, after: number, limit?: number): Promise<SessionEvent[]>;
|
|
2517
3360
|
declare function listSessionEvents(db: Database, workspaceId: string, sessionId: string, options: ListSessionEventsOptions): Promise<SessionEvent[]>;
|
|
2518
3361
|
type ToolspaceCallReservation = {
|
|
2519
3362
|
reserved: true;
|
|
2520
3363
|
count: number;
|
|
3364
|
+
turn: SessionTurnForExecution;
|
|
2521
3365
|
} | {
|
|
2522
3366
|
reserved: false;
|
|
3367
|
+
reason: TurnAttemptFenceRejectReason | "budget_exhausted";
|
|
2523
3368
|
};
|
|
3369
|
+
type ToolspaceTurnAttemptClaims = {
|
|
3370
|
+
sessionId: string;
|
|
3371
|
+
turnId: string;
|
|
3372
|
+
attemptId: string;
|
|
3373
|
+
executionGeneration: number;
|
|
3374
|
+
};
|
|
3375
|
+
/**
|
|
3376
|
+
* Admit one exact Toolspace bearer before any session credential is decrypted or
|
|
3377
|
+
* any upstream schema is enumerated. This intentionally reuses the canonical
|
|
3378
|
+
* activity write fence so Pause/Steer, attempt replacement, generation changes,
|
|
3379
|
+
* and terminal settlement revoke a copied token at the same linearization point
|
|
3380
|
+
* as other attempt-owned writes.
|
|
3381
|
+
*/
|
|
3382
|
+
declare function admitToolspaceTurnAttempt(db: Database, workspaceId: string, claims: ToolspaceTurnAttemptClaims): Promise<boolean>;
|
|
2524
3383
|
/**
|
|
2525
3384
|
* Atomically reserve one toolspace call against a turn's per-turn budget.
|
|
2526
3385
|
*
|
|
@@ -2528,10 +3387,20 @@ type ToolspaceCallReservation = {
|
|
|
2528
3387
|
* below `limit` and returns the post-increment value. Concurrent reservations
|
|
2529
3388
|
* for the same turn serialize on the row lock, so exactly `limit` of N
|
|
2530
3389
|
* simultaneous callers observe `reserved: true` — closing the read-then-append
|
|
2531
|
-
* TOCTOU the event-count approach had.
|
|
2532
|
-
*
|
|
3390
|
+
* TOCTOU the event-count approach had. The returned attempt id is captured by
|
|
3391
|
+
* that same UPDATE, so callers cannot accidentally execute under a successor
|
|
3392
|
+
* attempt. `reserved: false` means the turn is not executable, at/over budget,
|
|
3393
|
+
* or no longer exists.
|
|
2533
3394
|
*/
|
|
2534
|
-
declare function
|
|
3395
|
+
declare function reserveToolspaceCallForAttempt(db: Database, input: {
|
|
3396
|
+
accountId: string;
|
|
3397
|
+
workspaceId: string;
|
|
3398
|
+
sessionId: string;
|
|
3399
|
+
turnId: string;
|
|
3400
|
+
executionGeneration: number;
|
|
3401
|
+
attemptId: string;
|
|
3402
|
+
limit: number;
|
|
3403
|
+
}): Promise<ToolspaceCallReservation>;
|
|
2535
3404
|
declare function getSessionEvent(db: Database, workspaceId: string, eventId: string): Promise<SessionEvent | null>;
|
|
2536
3405
|
declare function listWorkspaceControlEvents(db: Database, workspaceId: string, after?: number, limit?: number): Promise<WorkspaceControlEvent[]>;
|
|
2537
3406
|
declare function getWorkspaceControlEvent(db: Database, workspaceId: string, eventId: string): Promise<WorkspaceControlEvent | null>;
|
|
@@ -2548,7 +3417,82 @@ declare function getLatestRunState(db: Database, workspaceId: string, sessionId:
|
|
|
2548
3417
|
pendingApprovals: unknown[];
|
|
2549
3418
|
frozenCodexCredentialId: string | null;
|
|
2550
3419
|
} | null>;
|
|
3420
|
+
declare class HumanInputResponseValidationError extends Error {
|
|
3421
|
+
readonly code: "INVALID_RESPONSE" | "SKIP_NOT_ALLOWED";
|
|
3422
|
+
readonly name = "HumanInputResponseValidationError";
|
|
3423
|
+
constructor(code: "INVALID_RESPONSE" | "SKIP_NOT_ALLOWED", message: string);
|
|
3424
|
+
}
|
|
3425
|
+
declare function getSessionHumanInputRequest(db: Database, workspaceId: string, sessionId: string, requestId: string): Promise<SessionHumanInputRequest | null>;
|
|
3426
|
+
declare function listSessionHumanInputRequests(db: Database, workspaceId: string, sessionId: string, options?: {
|
|
3427
|
+
status?: SessionHumanInputRequest["status"];
|
|
3428
|
+
limit?: number;
|
|
3429
|
+
}): Promise<SessionHumanInputRequest[]>;
|
|
3430
|
+
declare function validateHumanInputResponse(request: Pick<SessionHumanInputRequest, "questions" | "allowSkip">, rawResponse: unknown): HumanInputResponse;
|
|
3431
|
+
type AcceptSessionHumanInputResponseResult = {
|
|
3432
|
+
action: "accepted";
|
|
3433
|
+
request: SessionHumanInputRequest;
|
|
3434
|
+
event: SessionEvent;
|
|
3435
|
+
events: SessionEvent[];
|
|
3436
|
+
workflowWakeRevision: number;
|
|
3437
|
+
} | {
|
|
3438
|
+
action: "conflict";
|
|
3439
|
+
request: SessionHumanInputRequest;
|
|
3440
|
+
events: SessionEvent[];
|
|
3441
|
+
workflowWakeRevision: number | null;
|
|
3442
|
+
} | {
|
|
3443
|
+
action: "not_found";
|
|
3444
|
+
};
|
|
3445
|
+
/**
|
|
3446
|
+
* First-writer-wins settlement for one pending structured input boundary.
|
|
3447
|
+
* Session + logical turn + current freeze generation are locked with the row;
|
|
3448
|
+
* the creation attempt is provenance and is intentionally not the resume owner.
|
|
3449
|
+
*/
|
|
3450
|
+
declare function acceptSessionHumanInputResponse(db: Database, input: {
|
|
3451
|
+
accountId: string;
|
|
3452
|
+
workspaceId: string;
|
|
3453
|
+
sessionId: string;
|
|
3454
|
+
requestId: string;
|
|
3455
|
+
response: unknown;
|
|
3456
|
+
respondedBy: string;
|
|
3457
|
+
clientEventId?: string | null;
|
|
3458
|
+
expireOnly?: boolean;
|
|
3459
|
+
}): Promise<AcceptSessionHumanInputResponseResult>;
|
|
3460
|
+
declare function expireSessionHumanInputRequest(db: Database, input: {
|
|
3461
|
+
accountId: string;
|
|
3462
|
+
workspaceId: string;
|
|
3463
|
+
sessionId: string;
|
|
3464
|
+
requestId: string;
|
|
3465
|
+
}): Promise<AcceptSessionHumanInputResponseResult>;
|
|
3466
|
+
declare function getHumanInputResumeForEvent(db: Database, workspaceId: string, sessionId: string, event: Pick<SessionEvent, "type" | "payload">): Promise<{
|
|
3467
|
+
requestId: string;
|
|
3468
|
+
toolCallId: string;
|
|
3469
|
+
response: HumanInputResponse;
|
|
3470
|
+
} | null>;
|
|
2551
3471
|
type TurnAttemptFenceRejectReason = "workspace_paused" | "session_paused" | "pending_control" | "active_turn_changed" | "generation_changed" | "attempt_changed" | "turn_terminal" | "not_found";
|
|
3472
|
+
type InstallOrReadTurnExecutionPolicyForAttemptResult = {
|
|
3473
|
+
accepted: true;
|
|
3474
|
+
installed: boolean;
|
|
3475
|
+
policy: TurnExecutionPolicyV1;
|
|
3476
|
+
turn: SessionTurn;
|
|
3477
|
+
} | {
|
|
3478
|
+
accepted: false;
|
|
3479
|
+
reason: TurnAttemptFenceRejectReason;
|
|
3480
|
+
};
|
|
3481
|
+
/**
|
|
3482
|
+
* Freeze a legacy turn's execution identity at its first admitted attempt, or
|
|
3483
|
+
* return the policy already accepted for this logical turn. The exact active
|
|
3484
|
+
* attempt owns this mutation; malformed present metadata fails closed and a
|
|
3485
|
+
* replay never replaces an existing valid policy.
|
|
3486
|
+
*/
|
|
3487
|
+
declare function installOrReadTurnExecutionPolicyForAttempt(db: Database, input: {
|
|
3488
|
+
accountId: string;
|
|
3489
|
+
workspaceId: string;
|
|
3490
|
+
sessionId: string;
|
|
3491
|
+
turnId: string;
|
|
3492
|
+
executionGeneration: number;
|
|
3493
|
+
attemptId: string;
|
|
3494
|
+
policyForAbsent: TurnExecutionPolicyV1;
|
|
3495
|
+
}): Promise<InstallOrReadTurnExecutionPolicyForAttemptResult>;
|
|
2552
3496
|
/**
|
|
2553
3497
|
* Append conversation items (verbatim SDK AgentInputItems) to the session's
|
|
2554
3498
|
* history. Idempotent on (workspace, session, position): concurrent or
|
|
@@ -2563,6 +3507,7 @@ declare function appendSessionHistoryItems(db: Database, input: {
|
|
|
2563
3507
|
expectedExecutionGeneration: number;
|
|
2564
3508
|
expectedAttemptId: string;
|
|
2565
3509
|
producerCodexCredentialId?: string | null;
|
|
3510
|
+
modelToolOutputTruncationTokens?: number;
|
|
2566
3511
|
items: Array<{
|
|
2567
3512
|
position: number;
|
|
2568
3513
|
item: Record<string, unknown>;
|
|
@@ -2590,20 +3535,31 @@ declare function registerPendingSessionToolCall(db: Database, input: PendingSess
|
|
|
2590
3535
|
accepted: boolean;
|
|
2591
3536
|
registered: boolean;
|
|
2592
3537
|
}>;
|
|
3538
|
+
/**
|
|
3539
|
+
* Clear one completed Toolspace receipt after its attempt-fenced output event is
|
|
3540
|
+
* durable. If control already replaced the attempt, its settlement transaction
|
|
3541
|
+
* owns the receipt and will retain an explicit outcome-unknown or the durable
|
|
3542
|
+
* output event instead.
|
|
3543
|
+
*/
|
|
3544
|
+
declare function clearPendingSessionToolspaceCall(db: Database, input: Omit<PendingSessionToolCallInput, "callType" | "callItem">): Promise<{
|
|
3545
|
+
accepted: boolean;
|
|
3546
|
+
cleared: boolean;
|
|
3547
|
+
}>;
|
|
2593
3548
|
/** Record the raw SDK result without dropping the call receipt. */
|
|
2594
3549
|
declare function recordPendingSessionToolCallResult(db: Database, input: Omit<PendingSessionToolCallInput, "callType" | "callItem"> & {
|
|
2595
3550
|
resultItem: Record<string, unknown>;
|
|
2596
3551
|
}): Promise<{
|
|
2597
3552
|
accepted: boolean;
|
|
2598
3553
|
recorded: boolean;
|
|
2599
|
-
allResultsRecorded: boolean;
|
|
2600
3554
|
}>;
|
|
2601
3555
|
/**
|
|
2602
3556
|
* Remove completed receipts only after the full SDK call/result batch is
|
|
2603
3557
|
* durable. Until then every raw result remains available to an attempt-ending
|
|
2604
3558
|
* transaction, including reverse-completing parallel calls.
|
|
2605
3559
|
*/
|
|
2606
|
-
declare function clearDurablePendingSessionToolCalls(db: Database, input: Omit<PendingSessionToolCallInput, "callId" | "callType" | "callItem">
|
|
3560
|
+
declare function clearDurablePendingSessionToolCalls(db: Database, input: Omit<PendingSessionToolCallInput, "callId" | "callType" | "callItem"> & {
|
|
3561
|
+
callIds: string[];
|
|
3562
|
+
}): Promise<{
|
|
2607
3563
|
accepted: boolean;
|
|
2608
3564
|
cleared: number;
|
|
2609
3565
|
}>;
|
|
@@ -2705,7 +3661,7 @@ declare function recordSkippedContextCompaction(db: Database, input: {
|
|
|
2705
3661
|
turnId: string;
|
|
2706
3662
|
expectedExecutionGeneration: number;
|
|
2707
3663
|
expectedAttemptId: string;
|
|
2708
|
-
reason: "no_history" | "replacement_not_smaller";
|
|
3664
|
+
reason: "no_history" | "replacement_not_smaller" | "replacement_unchanged" | "summarization_failed";
|
|
2709
3665
|
}): Promise<{
|
|
2710
3666
|
recorded: true;
|
|
2711
3667
|
events: SessionEvent[];
|
|
@@ -3183,6 +4139,9 @@ declare function persistDrainSnapshot(db: Database, input: {
|
|
|
3183
4139
|
declare function persistWarmSnapshot(db: Database, input: {
|
|
3184
4140
|
accountId: string;
|
|
3185
4141
|
workspaceId: string;
|
|
4142
|
+
sessionId: string;
|
|
4143
|
+
turnId: string;
|
|
4144
|
+
attemptId: string;
|
|
3186
4145
|
sandboxGroupId: string;
|
|
3187
4146
|
expectedEpoch: number;
|
|
3188
4147
|
/** base64 of the provider snapshot-ref / tar archive from persistWorkspace(). */
|
|
@@ -3242,15 +4201,17 @@ type WorkspaceCaptureCommitResult = {
|
|
|
3242
4201
|
* — can embed the same number). Writes ONLY when a warm lease with the expected
|
|
3243
4202
|
* epoch still exists for the sandbox group (the same supersession guard
|
|
3244
4203
|
* persistWarmSnapshot uses, expressed as an EXISTS on sandbox_leases). Returns
|
|
3245
|
-
* the assigned revision, or null when the fence rejected the write (
|
|
3246
|
-
* released lease). Captures for
|
|
3247
|
-
*
|
|
4204
|
+
* the assigned revision, or null when the fence rejected the write (interrupted
|
|
4205
|
+
* attempt, cancelled/superseded turn, or released/superseded lease). Captures for
|
|
4206
|
+
* one session are serialized (one turn at a time), so the explicit revision never
|
|
4207
|
+
* races the unique (session_id, revision) index.
|
|
3248
4208
|
*/
|
|
3249
4209
|
declare function insertWorkspaceCapture(db: Database, input: {
|
|
3250
4210
|
accountId: string;
|
|
3251
4211
|
workspaceId: string;
|
|
3252
4212
|
sessionId: string;
|
|
3253
|
-
turnId: string
|
|
4213
|
+
turnId: string;
|
|
4214
|
+
attemptId: string;
|
|
3254
4215
|
sandboxGroupId: string;
|
|
3255
4216
|
expectedEpoch: number;
|
|
3256
4217
|
revision: number;
|
|
@@ -3274,7 +4235,8 @@ declare function insertFailedWorkspaceCapture(db: Database, input: {
|
|
|
3274
4235
|
accountId: string;
|
|
3275
4236
|
workspaceId: string;
|
|
3276
4237
|
sessionId: string;
|
|
3277
|
-
turnId: string
|
|
4238
|
+
turnId: string;
|
|
4239
|
+
attemptId: string;
|
|
3278
4240
|
sandboxGroupId: string;
|
|
3279
4241
|
expectedEpoch: number;
|
|
3280
4242
|
revision: number;
|
|
@@ -3836,6 +4798,8 @@ type InitializeSessionStartInput = {
|
|
|
3836
4798
|
sessionId: string;
|
|
3837
4799
|
clientEventId?: string;
|
|
3838
4800
|
reasoningEffortFallback: ReasoningEffort;
|
|
4801
|
+
/** Trusted create-session policy. Omitted only by legacy low-level callers. */
|
|
4802
|
+
turnExecutionPolicy?: TurnExecutionPolicyV1;
|
|
3839
4803
|
createdEventPayload: Record<string, unknown>;
|
|
3840
4804
|
goal?: {
|
|
3841
4805
|
text: string;
|
|
@@ -3877,7 +4841,7 @@ type ClaimSessionWorkForAttemptInput = {
|
|
|
3877
4841
|
};
|
|
3878
4842
|
type ClaimSessionWorkForAttemptResult = {
|
|
3879
4843
|
action: "claimed";
|
|
3880
|
-
turn:
|
|
4844
|
+
turn: SessionTurnForExecution;
|
|
3881
4845
|
} | {
|
|
3882
4846
|
action: "unclaimed";
|
|
3883
4847
|
reason: "gate-closed" | "no-work" | "stale-approval" | "control-pending";
|
|
@@ -3896,6 +4860,33 @@ type SessionAttemptInterruptionSettlement = {
|
|
|
3896
4860
|
turnId: string | null;
|
|
3897
4861
|
outcome: SessionTurnAttemptOutcome | null;
|
|
3898
4862
|
};
|
|
4863
|
+
/**
|
|
4864
|
+
* Acknowledge that the exact cancelled attempt reached its final quiescence
|
|
4865
|
+
* boundary: after this transaction it has no inference, user-visible output,
|
|
4866
|
+
* or workspace-persistence authority. Fenced/idempotent cleanup and telemetry
|
|
4867
|
+
* may still finish. This may race the workflow's logical settlement transaction
|
|
4868
|
+
* in either order; both use the canonical control -> workspace -> session ->
|
|
4869
|
+
* exact turn -> exact attempt lock order and require the durable interruption.
|
|
4870
|
+
* Temporal activity cancellation/terminalization is transport state only. The
|
|
4871
|
+
* workflow admits a replacement from this durable receipt, never from the
|
|
4872
|
+
* activity promise.
|
|
4873
|
+
*/
|
|
4874
|
+
declare function markSessionAttemptQuiesced(db: Database, input: {
|
|
4875
|
+
accountId?: string;
|
|
4876
|
+
workspaceId: string;
|
|
4877
|
+
sessionId: string;
|
|
4878
|
+
attemptId: string;
|
|
4879
|
+
temporalWorkflowId: string;
|
|
4880
|
+
/** When supplied, both values bind an activity-owned recovery proof to the
|
|
4881
|
+
* exact persisted Temporal dispatch. Legacy v1 replay callers omit them. */
|
|
4882
|
+
temporalWorkflowRunId?: string;
|
|
4883
|
+
temporalActivityId?: string;
|
|
4884
|
+
/** The dying activity also reaches this boundary for non-control ownership
|
|
4885
|
+
* fences. It may no-op when no Pause/Steer interruption exists; replacement
|
|
4886
|
+
* admission remains strict because only a durable interruption needs this
|
|
4887
|
+
* receipt. */
|
|
4888
|
+
allowUninterrupted?: boolean;
|
|
4889
|
+
}): Promise<SessionEvent[]>;
|
|
3899
4890
|
/**
|
|
3900
4891
|
* Settle every durable interruption cause for one exact first-class attempt.
|
|
3901
4892
|
* Steer wins the logical-turn fate when causes coexist; effective control after
|
|
@@ -3910,6 +4901,8 @@ type SessionWorkPeek = {
|
|
|
3910
4901
|
triggerEventId: string;
|
|
3911
4902
|
} | {
|
|
3912
4903
|
kind: "approval-wait";
|
|
4904
|
+
humanInputRequestId?: string;
|
|
4905
|
+
expiresAt?: string;
|
|
3913
4906
|
} | {
|
|
3914
4907
|
kind: "capacity-wait";
|
|
3915
4908
|
ref: {
|
|
@@ -3921,6 +4914,9 @@ type SessionWorkPeek = {
|
|
|
3921
4914
|
} | {
|
|
3922
4915
|
kind: "interruption-pending";
|
|
3923
4916
|
attemptId: string;
|
|
4917
|
+
} | {
|
|
4918
|
+
kind: "cancellation-wait";
|
|
4919
|
+
attemptId: string;
|
|
3924
4920
|
} | {
|
|
3925
4921
|
kind: "idle";
|
|
3926
4922
|
};
|
|
@@ -3972,7 +4968,38 @@ type ApplySessionTurnSettlementInput = {
|
|
|
3972
4968
|
sessionStatus: SessionStatus;
|
|
3973
4969
|
activeTurnId: string | null;
|
|
3974
4970
|
events: AppendEventInput[];
|
|
4971
|
+
/**
|
|
4972
|
+
* A mid-turn SDK freeze installed atomically with requires_action. Human
|
|
4973
|
+
* input requests are public protocol rows; ordinary approvals remain only in
|
|
4974
|
+
* pendingApprovals. No request can become visible without the exact frozen
|
|
4975
|
+
* RunState needed to resume it, and no frozen request can miss its status
|
|
4976
|
+
* transition/events because all writes share this transaction.
|
|
4977
|
+
*/
|
|
4978
|
+
runState?: {
|
|
4979
|
+
serializedRunState: string;
|
|
4980
|
+
pendingApprovals: unknown[];
|
|
4981
|
+
frozenCodexCredentialId?: string | null;
|
|
4982
|
+
humanInputRequests?: Array<{
|
|
4983
|
+
id: string;
|
|
4984
|
+
toolCallId: string;
|
|
4985
|
+
questions: HumanInputQuestion[];
|
|
4986
|
+
allowSkip: boolean;
|
|
4987
|
+
expiresAt?: Date | null;
|
|
4988
|
+
}>;
|
|
4989
|
+
};
|
|
3975
4990
|
recording?: SessionTurnRecordingSettlement;
|
|
4991
|
+
/**
|
|
4992
|
+
* Atomically consume an operator /compact request and record why it could
|
|
4993
|
+
* not install a replacement. This lives on the terminal turn settlement so
|
|
4994
|
+
* a worker crash can never clear the request without also publishing the
|
|
4995
|
+
* attempt-owned failure truth.
|
|
4996
|
+
*/
|
|
4997
|
+
compactionRequestFailure?: {
|
|
4998
|
+
reason: "summarization_failed";
|
|
4999
|
+
producerId?: string | null;
|
|
5000
|
+
producerSeq?: number | null;
|
|
5001
|
+
occurredAt?: Date;
|
|
5002
|
+
};
|
|
3976
5003
|
};
|
|
3977
5004
|
type ApplySessionTurnSettlementResult = {
|
|
3978
5005
|
action: "settled";
|
|
@@ -4109,7 +5136,13 @@ type RecoverSessionDispatchResult = {
|
|
|
4109
5136
|
*/
|
|
4110
5137
|
declare function recoverSessionDispatch(db: Database, workspaceId: string, input: RecoverSessionDispatchInput): Promise<RecoverSessionDispatchResult>;
|
|
4111
5138
|
declare function getSessionTurn(db: Database, workspaceId: string, turnId: string): Promise<SessionTurn | null>;
|
|
4112
|
-
|
|
5139
|
+
/**
|
|
5140
|
+
* Resolve the exact currently executable turn/attempt from authoritative
|
|
5141
|
+
* pointers in one query. This avoids treating a stale session preview as proof
|
|
5142
|
+
* that no attempt exists during an atomic claim transition.
|
|
5143
|
+
*/
|
|
5144
|
+
declare function getActiveSessionTurnForExecution(db: Database, workspaceId: string, sessionId: string): Promise<SessionTurnForExecution | null>;
|
|
5145
|
+
declare function getSessionTurnForAttempt(db: Database, workspaceId: string, sessionId: string, attemptId: string): Promise<SessionTurnForExecution | null>;
|
|
4113
5146
|
/**
|
|
4114
5147
|
* Return the newest turn that reached agent execution for a session. A claimed
|
|
4115
5148
|
* turn's `started_at` is set before worker admission, so it is not sufficient
|
|
@@ -4201,11 +5234,26 @@ declare function enqueueSessionWorkflowWakeIfRunnable(db: Database, input: {
|
|
|
4201
5234
|
/** Claim only explicit, undelivered wake revisions; never infer work by scan. */
|
|
4202
5235
|
declare function claimPendingSessionWorkflowWakes(db: Database, limit?: number): Promise<SessionWorkflowWake[]>;
|
|
4203
5236
|
/**
|
|
4204
|
-
* Acknowledge an immediate post-commit signal
|
|
4205
|
-
*
|
|
4206
|
-
*
|
|
5237
|
+
* Acknowledge an immediate post-commit signal only after it cannot strand an
|
|
5238
|
+
* accepted Agent Steer. Temporal accepting a signal is transport evidence, not
|
|
5239
|
+
* proof that a closing workflow observed Postgres or admitted its pending
|
|
5240
|
+
* direction. While active control still has an actionable Agent Steer, retain
|
|
5241
|
+
* the revision so the bounded outbox dispatcher retries signalWithStart. The
|
|
5242
|
+
* attempt-fenced claim consumes the update once; a real Pause is the typed
|
|
5243
|
+
* blocker and may acknowledge this revision because Resume commits a new one.
|
|
5244
|
+
*
|
|
5245
|
+
* An older sender may advance only its own revision; it cannot clear a claim or
|
|
5246
|
+
* failure state belonging to a newer revision. The control -> workspace ->
|
|
5247
|
+
* session lock prefix serializes this decision with Steer, Pause/Resume, and
|
|
5248
|
+
* claim without weakening physical-quiescence admission.
|
|
4207
5249
|
*/
|
|
4208
|
-
|
|
5250
|
+
type SessionWorkflowWakeDeliveryResult = {
|
|
5251
|
+
action: "acknowledged";
|
|
5252
|
+
} | {
|
|
5253
|
+
action: "pending_admission";
|
|
5254
|
+
blocker: "pending_agent_steer";
|
|
5255
|
+
};
|
|
5256
|
+
declare function markSessionWorkflowWakeDelivered(db: Database, input: Omit<SessionWorkflowWake, "interruptionRequested">): Promise<SessionWorkflowWakeDeliveryResult>;
|
|
4209
5257
|
/** Record delivery failure; the claim already scheduled the bounded retry. */
|
|
4210
5258
|
declare function markSessionWorkflowWakeFailed(db: Database, input: SessionWorkflowWake, error: string): Promise<boolean>;
|
|
4211
5259
|
declare function getOrCreateSessionSystemUpdateOutbox(db: Database, input: Omit<SessionSystemUpdateOutboxDelivery, "id" | "status">): Promise<SessionSystemUpdateOutboxDelivery>;
|
|
@@ -4295,6 +5343,7 @@ declare function appendSessionEventsAndUpdateSession(db: Database, workspaceId:
|
|
|
4295
5343
|
}): Promise<SessionEvent[]>;
|
|
4296
5344
|
type LockedSessionUpdateContext = {
|
|
4297
5345
|
updateSessionMcpServerCredentials: (updates: UpdateSessionMcpServerCredentialsInput[]) => Promise<UpdateSessionMcpServerCredentialsResult>;
|
|
5346
|
+
updateSessionMcpApprovalPolicy: (serverId: string, requireApproval: SessionMcpApprovalPolicy) => Promise<UpdateSessionMcpApprovalPolicyResult>;
|
|
4298
5347
|
listPendingSessionTurns: () => Promise<SessionTurn[]>;
|
|
4299
5348
|
};
|
|
4300
5349
|
type LockedSessionUpdateResult = {
|
|
@@ -4311,4 +5360,4 @@ type LockedSessionUpdateResult = {
|
|
|
4311
5360
|
declare function appendSessionEventsWithLockedSessionUpdate(db: Database, workspaceId: string, sessionId: string, build: (session: Session, context: LockedSessionUpdateContext) => LockedSessionUpdateResult | Promise<LockedSessionUpdateResult>): Promise<SessionEvent[]>;
|
|
4312
5361
|
declare function sessionSubject(workspaceId: string, sessionId: string): string;
|
|
4313
5362
|
|
|
4314
|
-
export { type CorrectWorkspaceMemoryResult as $, AGENT_VISIBLE_MEMORY_STATUSES as A, type BootstrapWorkspaceInput as B, CODEX_CAPACITY_REFRESH_MAX_MS as C, type CodexCapacitySelectionContext as D, type CodexCapacityWait as E, type CodexCapacityWaitStatus as F, type CodexCapacityWakeTarget as G, type CodexCredentialForRun as H, type CodexCredentialLeaseCandidateFilter as I, type CodexCredentialLeaseCandidateFilterResult as J, type CodexCredentialLeasePolicyScopeResolver as K, type CodexCredentialLeaseQuarantine as L, type CodexCredentialLeaseResult as M, type CodexCredentialLeaseSelection as N, type CodexCredentialLeaseSelectionContext as O, type CodexCredentialStatus as P, type ProvisionResult, type ProvisionRolesOptions, type CodexCredentialTokens as Q, type CodexLeaseAccountStatus as R, type CodexPinSource as S, type CodexRotationSettings as T, type CodexRotationStrategy as U, type ComposerDraftRow as V, type ConnectionBrokerDeps as W, type ConnectionCredentialForBroker as X, ConnectionRefreshHttpError as Y, type ConsumeOAuthStateNonceInput as Z, type CorrectWorkspaceMemoryInput as _, type AcceptSessionApprovalDecisionResult as a, type MarkWarmLeaseInstanceLostResult as a$, type CreateCapabilityCatalogItemInput as a0, type CreateConnectionInput as a1, type CreateDbOptions as a2, type CreateImportBatchInput as a3, type CreateKnowledgeMemoryInput as a4, type CreatePackInstallationInput as a5, type CreateScheduledTaskInput as a6, type CreateSessionGoalInput as a7, type CreateSessionMcpServerInput as a8, type CreateSocialConnectionInput as a9, type IntegrationOAuthClientForUse as aA, type LeaseHolderKind as aB, type LeaseSnapshot as aC, type ListKnowledgeMemoryOptions as aD, type ListSessionEventsOptions as aE, type ListSessionsForSubjectOptions as aF, type ListSessionsOptions as aG, type LiveModalSandboxLeaseAttribution as aH, MACHINE_METRICS_SERIES_INTERVAL_MS as aI, MAX_INTERNAL_UPDATE_BATCH_BYTES as aJ, MAX_INTERNAL_UPDATE_BATCH_MEMBERS as aK, MAX_INTERNAL_UPDATE_BYTES as aL, MEMORY_ACTIVE_RECORD_CAP as aM, MEMORY_BLOCK_KIND_ORDER as aN, MEMORY_BLOCK_RECORD_LIMIT as aO, MEMORY_CORRECT_TOOL_DESCRIPTION as aP, MEMORY_KIND_SECTION_TITLES as aQ, MEMORY_NEAR_DUP_COSINE_THRESHOLD as aR, MEMORY_NEAR_DUP_NEIGHBORS as aS, MEMORY_SAVE_TOOL_DESCRIPTION as aT, MEMORY_SEARCH_DEFAULT_LIMIT as aU, MEMORY_SEARCH_MAX_LIMIT as aV, MEMORY_SEARCH_TOOL_DESCRIPTION as aW, MEMORY_TEXT_MAX_CHARS as aX, MEMORY_VISIBLE_RECORD_CAP as aY, type MachineMetricsRow as aZ, type MachineMetricsSample as a_, type CreateSocialPostInput as aa, type CreditBalanceByAccount as ab, type Database as ac, type DbClient as ad, type DeviceEnrollmentRequestRecord as ae, type DeviceEnrollmentStatus as af, type EditQueueCommandResult as ag, type EffectiveControlBlocker as ah, type EffectiveControlResumeOption as ai, type EffectiveControlState as aj, type EffectiveSessionControl as ak, type EnableCapabilityInstallationInput as al, type EnabledMcpCapabilityServer as am, type EnqueueSessionTurnInput as an, type EnrollmentExposure as ao, type EnrollmentOs as ap, type EnrollmentRecord as aq, type EnrollmentStatus as ar, type ExpiredFileUploadCleanupClaim as as, type FileUploadCleanupClaimResult as at, type ForceDrainResult as au, type GitHubInstallation as av, type GoalContinuationDecision as aw, type ImportBatch as ax, type InitializeSessionStartInput as ay, type InitializeSessionStartResult as az, type AccrueWarmSecondsResult as b, type SetSessionCodexPinOptions as b$, type MemoryBlockRecord as b0, type MemoryEmbedder as b1, type MemorySanitizeResult as b2, type MeterableWarmLease as b3, type PendingSessionToolCallInput as b4, type QueueCommandConflictCode as b5, QueueCommandConflictError as b6, type QueueCommandResult as b7, type QueuedTurnRow as b8, type ReapDrainable as b9, type SaveWorkspaceMemoryResult as bA, type SessionAttemptInterruptionSettlement as bB, type SessionCodexState as bC, type SessionCommandActor as bD, SessionCommandIdempotencyError as bE, type SessionCommandReceiptRow as bF, SessionContextBusyError as bG, SessionControlConflictError as bH, SessionControlInvariantError as bI, type SessionControlMutationResult as bJ, type SessionLineage as bK, SessionListAccessError as bL, type SessionListCursor as bM, SessionListCursorError as bN, type SessionMcpServerForRun as bO, SessionPinAccessError as bP, SessionPinVersionConflictError as bQ, type SessionRecordingCodec as bR, type SessionRecordingMode as bS, type SessionRecordingRow as bT, type SessionRecordingState as bU, type SessionSystemUpdateOutboxDelivery as bV, type SessionTurnAttemptOutcome as bW, type SessionTurnRecordingSettlement as bX, type SessionWorkPeek as bY, type SessionWorkTrigger as bZ, type SessionWorkflowWake as b_, type ReconcileCodexCapacityWaitResult as ba, type RecoverSessionDispatchInput as bb, type RecoverSessionDispatchResult as bc, type RegisterWorkspacePackInput as bd, type RegistryCapabilityCatalogItemInput as be, type RegistryCatalogSurfaceKey as bf, type ReplaceIntegrationOAuthClientInput as bg, type RequestSessionTurnRecoveryInput as bh, type RequestSessionTurnRecoveryResult as bi, type ResolveConnectionCredentialInput as bj, type ResolveConnectionCredentialResult as bk, RigActiveVersionChangedError as bl, RigChangeAlreadyVerifyingError as bm, RigChangeTransitionError as bn, type RigVersionContentInput as bo, type RlsContext as bp, type RlsStrategy as bq, SESSION_ANCESTRY_LIMIT as br, SandboxImageConflictError as bs, type SandboxKind as bt, type SandboxLeaseLiveness as bu, SandboxLeaseSupersededError as bv, type SandboxPtySessionRow as bw, type SandboxRecord as bx, SandboxRigConflictError as by, type SaveWorkspaceMemoryInput as bz, type AcquireLeaseInput as c, claimFileUploadCleanup as c$, type SettleCodexCredentialFailoverResult as c0, type SettleCodexCredentialLeaseLossResult as c1, type SteerQueueCommandResult as c2, type StoreIntegrationOAuthClientInput as c3, type StoredIntegrationOAuthClient as c4, type StreamAcknowledgment as c5, type SubmitHumanPromptResult as c6, type ToolspaceCallReservation as c7, type TurnAttemptFenceRejectReason as c8, type UpdateConnectionInput as c9, acquireLease as cA, activateRigVersion as cB, addSessionSystemUpdate as cC, addSessionSystemUpdateWithSourceMutation as cD, allAccountPermissions as cE, allWorkspacePermissions as cF, appendSessionEventToSandboxGroup as cG, appendSessionEvents as cH, appendSessionEventsAndUpdateSession as cI, appendSessionEventsForTurnAttempt as cJ, appendSessionEventsWithLockedSessionUpdate as cK, appendSessionHistoryItems as cL, applyContextCompaction as cM, applyCreditDebitUpToBalance as cN, applyCreditLedgerEntry as cO, applySessionTurnSettlement as cP, approveDeviceEnrollmentRequest as cQ, armCodexCapacityWait as cR, assertAgentCommandAuthorityInTransaction as cS, autoResumeSessionBranchInTransaction as cT, beginRigChangeVerificationAttempt as cU, bootstrapWorkspace as cV, buildChildCompletionDigest as cW, buildCodexTokenResolver as cX, buildConnectionTokenResolver as cY, canonicalSessionCommandHash as cZ, claimExpiredFileUploadCleanup as c_, type UpdateImportBatchCountsInput as ca, type UpdateKnowledgeMemoryInput as cb, type UpdateScheduledTaskInput as cc, type UpdateSessionMcpServerCredentialsInput as cd, type UpdateSessionMcpServerCredentialsResult as ce, type UserLookup as cf, type VariableSetForRun as cg, WORKSPACE_MEMORY_BLOCK_EMPTY as ch, WORKSPACE_MEMORY_BLOCK_HEADER_POPULATED as ci, WORKSPACE_MEMORY_BLOCK_TOKEN_BUDGET as cj, type WorkspaceCaptureCommitResult as ck, type WorkspaceCaptureGcPlan as cl, type WorkspaceCaptureGcRow as cm, type WorkspaceCaptureRow as cn, type WorkspaceControlLockMode as co, type WorkspaceControlMutationResult as cp, type WorkspaceEnvironmentForRun as cq, type WorkspaceMemoryOrigin as cr, type WorkspaceMemorySearchInput as cs, type WorkspaceMemorySearchMode as ct, type WorkspaceMemorySearchResult as cu, type WorkspaceModelPolicy as cv, abandonRecordingForTurnAttempt as cw, acceptSessionApprovalDecision as cx, accrueWarmSeconds as cy, acquireCodexCredentialLease as cz, type AcquireLeaseResult as d, decryptEnvironmentValue as d$, claimPendingSessionSystemUpdateOutbox as d0, claimPendingSessionWorkflowWakes as d1, claimSessionWorkForAttempt as d2, clearDurablePendingSessionToolCalls as d3, clearEnrollmentWentOffline as d4, clearSessionContext as d5, clearSessionGoal as d6, clearedContextMarkerItem as d7, closePtySession as d8, closeSessionTurnAttemptInTransaction as d9, countWorkspaceEnvironments as dA, countWorkspacesForAccount as dB, createApiKey as dC, createConnection as dD, createDb as dE, createDeviceEnrollmentRequest as dF, createEnrollment as dG, createFileUpload as dH, createImportBatch as dI, createKnowledgeMemory as dJ, createRig as dK, createRigChange as dL, createRigVersion as dM, createRigVersionForChangePromotion as dN, createSandbox as dO, createScheduledTask as dP, createScheduledTaskRun as dQ, createSession as dR, createSessionGoal as dS, createSessionMcpServers as dT, createSessionWithIdempotencyKey as dU, createSocialConnection as dV, createSocialPost as dW, createVariableSet as dX, createWorkspace as dY, createWorkspaceEnvironment as dZ, decodeSessionListCursor as d_, codexCapacityRefreshBackoffMs as da, commitWarmingToWarm as db, completeExpiredFileUploadCleanup as dc, completeFileUpload as dd, completeFileUploadCleanup as de, computeWorkspaceCaptureGcPlan as df, confirmDrainCold as dg, consumeDeviceEnrollmentRequest as dh, consumeIntegrationOAuthStateNonce as di, correctWorkspaceMemory as dj, countActiveApiKeysForWorkspace as dk, countActiveSessionHistoryItems as dl, countActiveSessionsForWorkspace as dm, countActiveSessionsUsingEnvironment as dn, countActiveSessionsUsingVariableSet as dp, countConsecutiveReactiveRotations as dq, countQueuedTurns as dr, countRigs as ds, countSandboxLeasesByLiveness as dt, countScheduledTasksForWorkspace as du, countScheduledTasksUsingEnvironment as dv, countScheduledTasksUsingVariableSet as dw, countSessionHistoryItems as dx, countSessionsUsingRig as dy, countVariableSets as dz, type ActiveSandboxPointer as e, getRecording as e$, decryptedCapabilityHeaders as e0, deleteRecording as e1, deleteRig as e2, deleteRigIfNoActiveSessions as e3, deleteScheduledTask as e4, deleteSessionQueueItemInTransaction as e5, deleteVariableSet as e6, deleteVariableSetVariable as e7, deleteWorkspace as e8, deleteWorkspaceCaptureRows as e9, forceDrainOverLimitViewerOnlyBoxes as eA, getActiveSessionHistoryItems as eB, getAnySessionInGroup as eC, getBillingBalance as eD, getBillingCustomer as eE, getCapabilityCatalogItem as eF, getCapabilityInstallation as eG, getCodexCapacityWaitForSession as eH, getCodexCredentialStatus as eI, getCodexRotationSettings as eJ, getComposerDraftInTransaction as eK, getConnectionMetadata as eL, getDeviceEnrollmentRequestByDeviceCode as eM, getEnrollment as eN, getFile as eO, getFileUpload as eP, getKnowledgeMemory as eQ, getLatestRunState as eR, getLatestStartedSessionTurn as eS, getManagedAccount as eT, getManagedUserByEmail as eU, getMaterializedSandboxFileResources as eV, getOpenPtySession as eW, getOrCreateSessionSystemUpdateOutbox as eX, getPackInstallation as eY, getPendingDeviceEnrollmentRequestByUserCode as eZ, getPendingDeviceEnrollmentRequestByUserCodeGlobal as e_, deleteWorkspaceEnvironment as ea, deleteWorkspaceEnvironmentVariable as eb, deleteWorkspacePack as ec, denyDeviceEnrollmentRequest as ed, disableCapabilityInstallation as ee, disconnectAllCodexAccounts as ef, disconnectCodexAccount as eg, editQueuedTurnInTransaction as eh, enableCapabilityInstallation as ei, enablePackInstallation as ej, encodeSessionListCursor as ek, encryptEnvironmentValue as el, enqueueSessionTurn as em, enqueueSessionWorkflowWake as en, enqueueSessionWorkflowWakeIfRunnable as eo, enqueueSessionWorkflowWakeInTransaction as ep, ensureCodexRotationSettings as eq, ensureManagedAccessForUser as er, estimateMemoryTokens as es, evaluateGoalContinuation as et, evaluateSessionControl as eu, evaluateSessionControls as ev, failWarmingToCold as ew, fetchCodexUsageForAccount as ex, finalizeEnrollmentByToken as ey, findActiveApiKeyByHash as ez, type AddSessionSystemUpdateInput as f, listDistinctRigVersionIdsInGroup as f$, getRig as f0, getRigByName as f1, getRigChange as f2, getRigName as f3, getRigVersion as f4, getRigVersionById as f5, getSandbox as f6, getSandboxSessionEnvelope as f7, getScheduledTask as f8, getSession as f9, getWorkspacePack as fA, grantWorkspaceAccess as fB, hasCreditLedgerEntry as fC, hashMemoryText as fD, heartbeatCodexCredentialLease as fE, heartbeatCodexCredentialLeaseUntil as fF, heartbeatLeaseHolder as fG, ingestMachineMetricsSample as fH, initializeSessionStartAtomically as fI, insertFailedWorkspaceCapture as fJ, insertMachineMetricsSeries as fK, insertPtySession as fL, insertRecording as fM, insertWorkspaceCapture as fN, interruptedToolCallResult as fO, isCodexBilledTurn as fP, isMemoryTextTooLong as fQ, isPrivateAddress as fR, isSessionCompactionRequested as fS, isStripeWebhookProcessed as fT, latestWorkspaceCapture as fU, listApiKeys as fV, listCapabilityCatalogItems as fW, listCapabilityInstallations as fX, listCodexAccountStatuses as fY, listConnectionsMetadata as fZ, listCreditBalancesByAccount as f_, getSessionByCreateIdempotencyKey as fa, getSessionCodexState as fb, getSessionEvent as fc, getSessionEventByClientEventId as fd, getSessionForSubject as fe, getSessionGoal as ff, getSessionHistoryItems as fg, getSessionLineage as fh, getSessionQueueSnapshot as fi, getSessionSystemUpdateOutboxByDedupeKey as fj, getSessionTurn as fk, getSessionTurnForAttempt as fl, getSocialConnection as fm, getStoredCapabilityHeaderCiphertext as fn, getStreamAcknowledgment as fo, getVariableSet as fp, getVariableSetByName as fq, getVariableSetValuesForRun as fr, getWorkspace as fs, getWorkspaceControlEvent as ft, getWorkspaceDefaultRigId as fu, getWorkspaceEnvironment as fv, getWorkspaceEnvironmentByName as fw, getWorkspaceEnvironmentValuesForRun as fx, getWorkspaceGrant as fy, getWorkspaceModelPolicy as fz, type AddSessionSystemUpdateResult as g, persistDrainSnapshot as g$, listDistinctVariableSetIdsInGroup as g0, listEnabledMcpCapabilityServers as g1, listEnrollments as g2, listGitHubInstallationIdsForWorkspace as g3, listGitHubInstallationsForWorkspace as g4, listKnowledgeMemories as g5, listLiveModalSandboxLeaseAttributions as g6, listMeterableWarmLeases as g7, listOpenPtySessions as g8, listOutstandingSessionSystemUpdates as g9, listWorkspacePacks as gA, listWorkspacesForSubject as gB, loadCodexCredentialForRun as gC, loadConnectionCredentialForBroker as gD, loadIntegrationOAuthClient as gE, loadVariableSetForRun as gF, loadWorkspaceEnvironmentForRun as gG, lockWorkspaceInferenceControl as gH, markFileUploadFailed as gI, markSandboxFileResourcesMaterialized as gJ, markScheduledTaskRunFailedIfQueued as gK, markSessionSystemUpdateOutboxDeliveredInTransaction as gL, markSessionSystemUpdateOutboxFailed as gM, markSessionWorkflowWakeDelivered as gN, markSessionWorkflowWakeFailed as gO, markStaleRegistryCatalogItems as gP, markStripeWebhookProcessed as gQ, markWarmLeaseInstanceLost as gR, mcpServerIdForCapability as gS, moveQueuedTurnInTransaction as gT, mutateSessionControlInTransaction as gU, mutateWorkspaceControlInTransaction as gV, nextSessionHistoryPosition as gW, normalizeBearerScheme as gX, normalizeMemoryText as gY, orphanedResultRowIndicesForRepair as gZ, peekSessionWork as g_, listPackInstallations as ga, listPendingCodexCapacityWakeTargets as gb, listPendingSessionTurns as gc, listRecordings as gd, listRegistryCatalogSurfaceKeys as ge, listRigChanges as gf, listRigVersions as gg, listRigs as gh, listSandboxes as gi, listScheduledTaskRuns as gj, listScheduledTasks as gk, listSessionEvents as gl, listSessionIdsInGroup as gm, listSessionMcpServerMetadata as gn, listSessionMcpServersForRun as go, listSessionSystemUpdatesForTurn as gp, listSessionTurns as gq, listSessions as gr, listSessionsForSubject as gs, listSocialConnections as gt, listSocialPosts as gu, listUsageEvents as gv, listVariableSets as gw, listWorkspaceControlEvents as gx, listWorkspaceEnvironments as gy, listWorkspaceMembers as gz, AgentCommandAuthorityError as h, saveComposerDraftInTransaction as h$, persistWarmSnapshot as h0, planWorkspaceCaptureGc as h1, quarantineCodexCredentialForLease as h2, reArmDrainingLease as h3, readActiveSandbox as h4, readLease as h5, readMachineMetricsLatest as h6, readMachineMetricsLatestForWorkspace as h7, readMachineMetricsSeries as h8, reapExpiredSessionListSnapshots as h9, registerWorkspacePack as hA, releaseCodexCredentialLease as hB, releaseLeaseHolder as hC, removeWorkspaceMember as hD, renameCodexAccount as hE, renderWorkspaceMemoryBlock as hF, replaceIntegrationOAuthClient as hG, requestSessionCompaction as hH, requestSessionTurnRecovery as hI, requireFile as hJ, requireScheduledTask as hK, requireSession as hL, requireSocialConnection as hM, requireWorkspace as hN, reserveSessionCommandReceipt as hO, reserveToolspaceCallForTurn as hP, resolveWorkspaceMemoryBlock as hQ, revokeApiKey as hR, revokeConnection as hS, revokeEnrollment as hT, revokeViewer as hU, rlsContextForWorkspace as hV, rlsStrategyFor as hW, sanitizeEventPayload as hX, sanitizeEventString as hY, sanitizeMemoryText as hZ, sanitizeModelPayload as h_, reapStaleLeaseHolders as ha, reapStaleLeaseHoldersGlobal as hb, reconcileCodexCapacityWait as hc, recordAuditEvent as hd, recordCodexAccountConnectors as he, recordCodexAccountUsage as hf, recordCodexAccountUsageWithWakeTargets as hg, recordCodexTokenRefresh as hh, recordConnectionTokenRefresh as hi, recordConnectionUsed as hj, recordLeaseDataPlaneUrl as hk, recordLeaseTerminalDataPlaneUrl as hl, recordPendingSessionToolCallResult as hm, recordSessionActiveCodexCredential as hn, recordSkippedContextCompaction as ho, recordStreamAcknowledgment as hp, recordStripeWebhookEvent as hq, recordUsageEvent as hr, recordWarmingSandboxCreated as hs, recoverSessionDispatch as ht, refreshOAuthConnectionCredential as hu, registerDbBinding as hv, registerInternalUpdateWakeInTransaction as hw, registerPendingSessionToolCall as hx, registerSessionTurnAttemptClaim as hy, registerSessionWorkflowWakeInTransaction as hz, type AgentInternalUpdateCommandResult as i, upsertBillingCustomer as i$, saveRunState as i0, saveWorkspaceMemory as i1, searchWorkspaceMemories as i2, sendAgentMessageInTransaction as i3, serializeEffectiveSessionControl as i4, sessionSubject as i5, sessionsWithActiveOpOnEnrollment as i6, setActiveCodexCredential as i7, setActiveSandbox as i8, setCodexCredentialExhausted as i9, steerAgentSessionInTransaction as iA, steerQueuedTurnInTransaction as iB, storeIntegrationOAuthClient as iC, submitHumanPromptInTransaction as iD, sumUsageQuantity as iE, supersedeSessionCurrentDirectionInTransaction as iF, touchEnrollmentLastSeen as iG, touchLeaseHolder as iH, updateCodexRotationSettings as iI, updateConnection as iJ, updateImportBatchCounts as iK, updateKnowledgeMemory as iL, updatePackInstallationStatus as iM, updatePtySessionActivity as iN, updateRecording as iO, updateRig as iP, updateRigChangeStatus as iQ, updateScheduledTask as iR, updateScheduledTaskRun as iS, updateSessionCommandReceiptResult as iT, updateSessionGoal as iU, updateSessionMcpServerCredentials as iV, updateSessionTitle as iW, updateVariableSet as iX, updateWorkspace as iY, updateWorkspaceEnvironment as iZ, updateWorkspaceSettings as i_, setCodexCredentialExhaustedWithWakeTargets as ia, setCodexCredentialStatus as ib, setCodexCredentialStatusById as ic, setConnectionStatus as id, setEnrollmentDisplayState as ie, setEnrollmentOpStreamState as ig, setEnrollmentWentOffline as ih, setInitialActiveCodexCredential as ii, setRlsContext as ij, setSessionCodexPin as ik, setSessionGoalLastContinuationTurn as il, setSessionGoalStatus as im, setSessionLastInputTokensForTurnAttempt as io, setSessionPin as ip, setTemporalWorkflowId as iq, setVariableSetVariable as ir, setWorkspaceDefaultRig as is, setWorkspaceEnvironmentVariable as it, settleCodexCredentialFailover as iu, settleCodexCredentialLeaseLoss as iv, settleScheduledTaskRunInTransaction as iw, settleSessionAttemptInterruptions as ix, settleSessionIdleWithParentOutbox as iy, shortMemoryId as iz, type AppendEventInput as j, upsertCapabilityCatalogItem as j0, upsertCodexSubscriptionCredential as j1, upsertGitHubInstallation as j2, upsertMachineMetricsLatest as j3, upsertRegistryCapabilityCatalogItem as j4, upsertSandboxSessionEnvelope as j5, upsertSessionGoal as j6, upsertWorkspaceModelPolicy as j7, withAccountRls as j8, withCodexCapacityMutation as j9, withCodexCredentialRefreshLock as ja, withRlsContext as jb, withWorkspaceRls as jc, withWorkspaceSubjectRls as jd, withWorkspaceUsageLock as je, workspaceCaptureAtRevision as jf, workspaceCodexSubscriptionActive as jg, type ApplyContextCompactionResult as k, type ApplySessionTurnSettlementInput as l, type ApplySessionTurnSettlementResult as m, type ArmCodexCapacityWaitResult as n, CODEX_CAPACITY_REFRESH_MIN_MS as o, CODEX_CREDENTIAL_LEASE_TTL_MS as p, provisionRoles, CODEX_ROTATION_STRATEGIES as q, type ClaimSessionWorkForAttemptInput as r, type ClaimSessionWorkForAttemptResult as s, type ClearSessionContextResult as t, type CodexAccountStatus as u, type CodexAccountUsageSnapshot as v, type CodexAuthDeps as w, type CodexCapacityAvailabilityDecision as x, type CodexCapacityMutationResult as y, type CodexCapacityResetKind as z };
|
|
5363
|
+
export { type CodexResetRedemptionRecovery as $, AGENT_VISIBLE_MEMORY_STATUSES as A, type BootstrapWorkspaceInput as B, CODEX_CAPACITY_REFRESH_MAX_MS as C, type CodexAllocatorUpdateResult as D, type CodexAuthDeps as E, type CodexCapacityAvailabilityDecision as F, type CodexCapacityMutationResult as G, type CodexCapacityResetKind as H, type CodexCapacitySelectionContext as I, type CodexCapacityWait as J, type CodexCapacityWaitStatus as K, type CodexCapacityWakeTarget as L, type CodexCredentialForRun as M, type CodexCredentialLeaseCandidateFilter as N, type CodexCredentialLeaseCandidateFilterResult as O, type CodexCredentialLeasePolicyScopeResolver as P, type ProvisionResult, type ProvisionRolesOptions, type CodexCredentialLeaseQuarantine as Q, type CodexCredentialLeaseResult as R, type CodexCredentialLeaseSelection as S, type CodexCredentialLeaseSelectionContext as T, type CodexCredentialStatus as U, type CodexCredentialTokens as V, type CodexLeaseAccountStatus as W, type CodexPinSource as X, type CodexRateLimitResetCreditsAccountResult as Y, type CodexResetRedemptionAttempt as Z, type CodexResetRedemptionOutcome as _, type AcceptSessionApprovalDecisionResult as a, type LeaseHolderKind as a$, type CodexResetRedemptionSendNotReadyReason as a0, type CodexResetRedemptionStatus as a1, type CodexRotationSettings as a2, type CodexRotationStrategy as a3, type CodexTokenDeadlineClock as a4, type CodexTokenDeadlineOptions as a5, type ComposerDraftRow as a6, type ConnectionBrokerDeps as a7, type ConnectionCredentialForBroker as a8, ConnectionRefreshHttpError as a9, type EnabledMcpCapabilityServer as aA, type EnqueueSessionTurnInput as aB, type EnrollmentExposure as aC, type EnrollmentOs as aD, type EnrollmentRecord as aE, type EnrollmentStatus as aF, type ExpiredFileUploadCleanupClaim as aG, type FenceCodexResetRedemptionSendResult as aH, type FileUploadCleanupClaimResult as aI, type ForceDrainResult as aJ, type FrozenTurnInitiator as aK, type GitHubInstallation as aL, type GitHubInstallationAccess as aM, type GoalContinuationDecision as aN, type HostExportConsumerStatus as aO, type HostExportKind as aP, HostExportPayloadError as aQ, HostMcpCredentialBindingError as aR, type HostMcpCredentialResolverContext as aS, HostMcpCredentialScopeError as aT, HumanInputResponseValidationError as aU, type IdempotentPersistenceTransactionOptions as aV, type ImportBatch as aW, type InitializeSessionStartInput as aX, type InitializeSessionStartResult as aY, type InstallOrReadTurnExecutionPolicyForAttemptResult as aZ, type IntegrationOAuthClientForUse as a_, type ConsumeOAuthStateNonceInput as aa, type CorrectWorkspaceMemoryInput as ab, type CorrectWorkspaceMemoryResult as ac, type CreateCapabilityCatalogItemInput as ad, type CreateConnectionInput as ae, type CreateDbOptions as af, type CreateImportBatchInput as ag, type CreateKnowledgeMemoryInput as ah, type CreatePackInstallationInput as ai, type CreateScheduledTaskInput as aj, type CreateSessionGoalInput as ak, type CreateSessionMcpServerInput as al, type CreateSocialConnectionInput as am, type CreateSocialPostInput as an, type CreditBalanceByAccount as ao, type Database as ap, type DatabaseFailureCode as aq, type DbClient as ar, type DeviceEnrollmentRequestRecord as as, type DeviceEnrollmentStatus as at, type EditQueueCommandResult as au, type EffectiveControlBlocker as av, type EffectiveControlResumeOption as aw, type EffectiveControlState as ax, type EffectiveSessionControl as ay, type EnableCapabilityInstallationInput as az, type AcceptSessionHumanInputResponseResult as b, SESSION_DISCOVERY_GOAL_MAX_CHARS as b$, type LeaseSnapshot as b0, type ListKnowledgeMemoryOptions as b1, type ListSessionEventPageOptions as b2, type ListSessionEventsOptions as b3, type ListSessionsForSubjectOptions as b4, type ListSessionsOptions as b5, type LiveModalSandboxLeaseAttribution as b6, MACHINE_METRICS_SERIES_INTERVAL_MS as b7, MAX_INTERNAL_UPDATE_BATCH_BYTES as b8, MAX_INTERNAL_UPDATE_BATCH_MEMBERS as b9, type QueueCommandResult as bA, type QueuedTurnRow as bB, type ReapDrainable as bC, type ReconcileCodexCapacityWaitResult as bD, type RecoverSessionDispatchInput as bE, type RecoverSessionDispatchResult as bF, type RefreshTransportOptions as bG, type RegisterWorkspacePackInput as bH, type RegistryCapabilityCatalogItemInput as bI, type RegistryCatalogSurfaceKey as bJ, type ReplaceIntegrationOAuthClientInput as bK, type RequestSessionTurnRecoveryInput as bL, type RequestSessionTurnRecoveryResult as bM, type ResolveConnectionCredentialInput as bN, type ResolveConnectionCredentialResult as bO, type RetainedFileArtifact as bP, RigActiveVersionChangedError as bQ, RigChangeAlreadyVerifyingError as bR, type RigChangeMonitoringSummary as bS, RigChangeTransitionError as bT, type RigVersionContentInput as bU, type RigVersionMonitoringSummary as bV, type RlsContext as bW, type RlsStrategy as bX, SESSION_ANCESTRY_LIMIT as bY, SESSION_DISCOVERY_CONTROL_TARGET_LIMIT as bZ, SESSION_DISCOVERY_CONTROL_TITLE_MAX_CHARS as b_, MAX_INTERNAL_UPDATE_BYTES as ba, MEMORY_ACTIVE_RECORD_CAP as bb, MEMORY_BLOCK_KIND_ORDER as bc, MEMORY_BLOCK_RECORD_LIMIT as bd, MEMORY_CORRECT_TOOL_DESCRIPTION as be, MEMORY_KIND_SECTION_TITLES as bf, MEMORY_NEAR_DUP_COSINE_THRESHOLD as bg, MEMORY_NEAR_DUP_NEIGHBORS as bh, MEMORY_SAVE_TOOL_DESCRIPTION as bi, MEMORY_SEARCH_DEFAULT_LIMIT as bj, MEMORY_SEARCH_MAX_LIMIT as bk, MEMORY_SEARCH_TOOL_DESCRIPTION as bl, MEMORY_TEXT_MAX_CHARS as bm, MEMORY_VISIBLE_RECORD_CAP as bn, type MachineMetricsRow as bo, type MachineMetricsSample as bp, type MarkWarmLeaseInstanceLostResult as bq, type MemoryBlockRecord as br, type MemoryEmbedder as bs, type MemorySanitizeResult as bt, type MeterableWarmLease as bu, type PendingSessionToolCallInput as bv, type PersistenceFailureDetails as bw, type PersistenceRetryOutcome as bx, type QueueCommandConflictCode as by, QueueCommandConflictError as bz, type AccrueWarmSecondsResult as c, type UpdateKnowledgeMemoryInput as c$, SESSION_DISCOVERY_MESSAGE_MAX_CHARS as c0, SESSION_EVENT_DB_PAGE_MAX_BYTES as c1, type SafeDatabaseErrorFacts as c2, SandboxImageConflictError as c3, type SandboxKind as c4, type SandboxLeaseLiveness as c5, SandboxLeaseSupersededError as c6, type SandboxPtySessionRow as c7, type SandboxRecord as c8, SandboxRigConflictError as c9, SessionPinAccessError as cA, SessionPinVersionConflictError as cB, type SessionRecordingCodec as cC, type SessionRecordingMode as cD, type SessionRecordingRow as cE, type SessionRecordingState as cF, type SessionSystemUpdateOutboxDelivery as cG, type SessionTurnAttemptOutcome as cH, type SessionTurnForExecution as cI, type SessionTurnRecordingSettlement as cJ, type SessionWorkPeek as cK, type SessionWorkTrigger as cL, type SessionWorkflowWake as cM, type SessionWorkflowWakeDeliveryResult as cN, type SetSessionCodexPinOptions as cO, type SettleCodexCredentialFailoverResult as cP, type SettleCodexCredentialLeaseLossResult as cQ, type SteerQueueCommandResult as cR, type StoreIntegrationOAuthClientInput as cS, type StoredIntegrationOAuthClient as cT, type StreamAcknowledgment as cU, type SubmitHumanPromptResult as cV, type ToolspaceCallReservation as cW, type ToolspaceTurnAttemptClaims as cX, type TurnAttemptFenceRejectReason as cY, type UpdateConnectionInput as cZ, type UpdateImportBatchCountsInput as c_, SanitizedDatabasePersistenceCause as ca, type SaveWorkspaceMemoryInput as cb, type SaveWorkspaceMemoryResult as cc, type SessionAttemptInterruptionSettlement as cd, type SessionCodexState as ce, type SessionCommandActor as cf, SessionCommandIdempotencyError as cg, type SessionCommandReceiptRow as ch, SessionContextBusyError as ci, SessionControlConflictError as cj, SessionControlInvariantError as ck, type SessionControlMutationResult as cl, type SessionDiscoveryControl as cm, type SessionDiscoveryCursor as cn, type SessionDiscoveryOrderBy as co, type SessionDiscoverySummary as cp, type SessionEventPage as cq, SessionEventPersistenceError as cr, type SessionEventWriteLockInput as cs, type SessionEventWriteLocks as ct, SessionIdConflictError as cu, type SessionLineage as cv, SessionListAccessError as cw, type SessionListCursor as cx, SessionListCursorError as cy, type SessionMcpServerForRun as cz, type AcquireLeaseInput as d, claimExpiredFileUploadCleanup as d$, type UpdateScheduledTaskInput as d0, type UpdateSessionMcpApprovalPolicyResult as d1, type UpdateSessionMcpServerCredentialsInput as d2, type UpdateSessionMcpServerCredentialsResult as d3, type UpsertCodexSubscriptionCredentialResult as d4, type UserLookup as d5, type VariableSetForRun as d6, WORKSPACE_MEMORY_BLOCK_EMPTY as d7, WORKSPACE_MEMORY_BLOCK_HEADER_POPULATED as d8, WORKSPACE_MEMORY_BLOCK_TOKEN_BUDGET as d9, adoptCodexResetRedemptionAttempt as dA, allAccountPermissions as dB, allWorkspacePermissions as dC, appendSessionEventToSandboxGroup as dD, appendSessionEvents as dE, appendSessionEventsAndUpdateSession as dF, appendSessionEventsForTurnAttempt as dG, appendSessionEventsWithLockedSessionUpdate as dH, appendSessionHistoryItems as dI, applyContextCompaction as dJ, applyCreditDebitUpToBalance as dK, applyCreditLedgerEntry as dL, applySessionTurnSettlement as dM, approveDeviceEnrollmentRequest as dN, areGitHubRepositoriesAllowedForWorkspace as dO, armCodexCapacityWait as dP, assertAgentCommandAuthorityInTransaction as dQ, autoResumeSessionBranchInTransaction as dR, beginRigChangeVerificationAttempt as dS, bindGitHubInstallationRepositories as dT, bootstrapWorkspace as dU, buildChildCompletionDigest as dV, buildCodexTokenResolver as dW, buildConnectionTokenResolver as dX, buildHostConnectionTokenResolver as dY, canonicalSessionCommandHash as dZ, claimCodexResetRedemption as d_, type WorkspaceCaptureCommitResult as da, type WorkspaceCaptureGcPlan as db, type WorkspaceCaptureGcRow as dc, type WorkspaceCaptureRow as dd, type WorkspaceControlLockMode as de, type WorkspaceControlMutationResult as df, type WorkspaceControlRow as dg, type WorkspaceEnvironmentForRun as dh, type WorkspaceMemoryOrigin as di, type WorkspaceMemorySearchInput as dj, type WorkspaceMemorySearchMode as dk, type WorkspaceMemorySearchResult as dl, type WorkspaceModelPolicy as dm, abandonCodexResetRedemptionBeforeProvider as dn, abandonRecordingForTurnAttempt as dp, acceptSessionApprovalDecision as dq, acceptSessionHumanInputResponse as dr, accrueWarmSeconds as ds, acknowledgeHostExportBatch as dt, acquireCodexCredentialLease as du, acquireLease as dv, activateRigVersion as dw, addSessionSystemUpdate as dx, addSessionSystemUpdateWithSourceMutation as dy, admitToolspaceTurnAttempt as dz, type AcquireLeaseResult as e, createWorkspace as e$, claimFileUploadCleanup as e0, claimHostExportBatch as e1, claimPendingSessionSystemUpdateOutbox as e2, claimPendingSessionWorkflowWakes as e3, claimSessionWorkForAttempt as e4, clearDurablePendingSessionToolCalls as e5, clearEnrollmentWentOffline as e6, clearPendingSessionToolspaceCall as e7, clearSessionContext as e8, clearSessionGoal as e9, countSessionHistoryItems as eA, countSessionsUsingRig as eB, countVariableSets as eC, countWorkspaceEnvironments as eD, countWorkspacesForAccount as eE, createApiKey as eF, createConnection as eG, createDb as eH, createDeviceEnrollmentRequest as eI, createEnrollment as eJ, createFileUpload as eK, createImportBatch as eL, createKnowledgeMemory as eM, createRig as eN, createRigChange as eO, createRigVersion as eP, createRigVersionForChangePromotion as eQ, createSandbox as eR, createScheduledTask as eS, createScheduledTaskRun as eT, createSession as eU, createSessionGoal as eV, createSessionMcpServers as eW, createSessionWithIdempotencyKey as eX, createSocialConnection as eY, createSocialPost as eZ, createVariableSet as e_, clearedContextMarkerItem as ea, closePtySession as eb, closeSessionTurnAttemptInTransaction as ec, codexCapacityRefreshBackoffMs as ed, commitWarmingToWarm as ee, completeCodexResetRedemption as ef, completeExpiredFileUploadCleanup as eg, completeFileUpload as eh, completeFileUploadCleanup as ei, computeWorkspaceCaptureGcPlan as ej, confirmDrainCold as ek, consumeDeviceEnrollmentRequest as el, consumeIntegrationOAuthStateNonce as em, correctWorkspaceMemory as en, countActiveApiKeysForWorkspace as eo, countActiveSessionHistoryItems as ep, countActiveSessionsForWorkspace as eq, countActiveSessionsUsingEnvironment as er, countActiveSessionsUsingVariableSet as es, countConsecutiveReactiveRotations as et, countQueuedTurns as eu, countRigs as ev, countSandboxLeasesByLiveness as ew, countScheduledTasksForWorkspace as ex, countScheduledTasksUsingEnvironment as ey, countScheduledTasksUsingVariableSet as ez, type ActiveSandboxPointer as f, getDeviceEnrollmentRequestByDeviceCode as f$, createWorkspaceEnvironment as f0, databaseFailureCode as f1, deadLetterHostExportHead as f2, decodeSessionListCursor as f3, decryptEnvironmentValue as f4, decryptedCapabilityHeaders as f5, deleteGitHubInstallationBinding as f6, deleteRecording as f7, deleteRig as f8, deleteRigIfNoActiveSessions as f9, evaluateGoalContinuation as fA, evaluateSessionControl as fB, evaluateSessionControls as fC, evaluateSessionDiscoveryControls as fD, expireSessionHumanInputRequest as fE, failHostExportBatch as fF, failWarmingToCold as fG, fenceCodexResetRedemptionSend as fH, fetchCodexRateLimitResetCreditsForAccount as fI, fetchCodexUsageForAccount as fJ, finalizeEnrollmentByToken as fK, findActiveApiKeyByHash as fL, forceDrainOverLimitViewerOnlyBoxes as fM, frozenInitiatorForCommandActor as fN, getActiveSessionHistoryItems as fO, getActiveSessionTurnForExecution as fP, getAnySessionInGroup as fQ, getBillingBalance as fR, getBillingCustomer as fS, getCapabilityCatalogItem as fT, getCapabilityInstallation as fU, getCodexCapacityWaitForSession as fV, getCodexCredentialStatus as fW, getCodexResetRedemptionAttempt as fX, getCodexRotationSettings as fY, getComposerDraftInTransaction as fZ, getConnectionMetadata as f_, deleteScheduledTask as fa, deleteSessionQueueItemInTransaction as fb, deleteVariableSet as fc, deleteVariableSetVariable as fd, deleteWorkspace as fe, deleteWorkspaceCaptureRows as ff, deleteWorkspaceEnvironment as fg, deleteWorkspaceEnvironmentVariable as fh, deleteWorkspacePack as fi, denyDeviceEnrollmentRequest as fj, disableCapabilityInstallation as fk, disableHostExportConsumer as fl, disconnectAllCodexAccounts as fm, disconnectCodexAccount as fn, editQueuedTurnInTransaction as fo, enableCapabilityInstallation as fp, enablePackInstallation as fq, encodeSessionListCursor as fr, encryptEnvironmentValue as fs, enqueueSessionTurn as ft, enqueueSessionWorkflowWake as fu, enqueueSessionWorkflowWakeIfRunnable as fv, enqueueSessionWorkflowWakeInTransaction as fw, ensureCodexRotationSettings as fx, ensureManagedAccessForUser as fy, estimateMemoryTokens as fz, type AddSessionSystemUpdateInput as g, ingestMachineMetricsSample as g$, getEnrollment as g0, getFile as g1, getFileUpload as g2, getHostExportConsumerStatus as g3, getHumanInputResumeForEvent as g4, getKnowledgeMemory as g5, getLatestRunState as g6, getLatestStartedSessionTurn as g7, getManagedAccount as g8, getManagedUserByEmail as g9, getSessionLineage as gA, getSessionQueueSnapshot as gB, getSessionRootId as gC, getSessionSystemUpdateOutboxByDedupeKey as gD, getSessionTurn as gE, getSessionTurnForAttempt as gF, getSocialConnection as gG, getStoredCapabilityHeaderCiphertext as gH, getStreamAcknowledgment as gI, getVariableSet as gJ, getVariableSetByName as gK, getVariableSetValuesForRun as gL, getWorkspace as gM, getWorkspaceControlEvent as gN, getWorkspaceDefaultRigId as gO, getWorkspaceEnvironment as gP, getWorkspaceEnvironmentByName as gQ, getWorkspaceEnvironmentValuesForRun as gR, getWorkspaceGrant as gS, getWorkspaceModelPolicy as gT, getWorkspacePack as gU, grantWorkspaceAccess as gV, hasCreditLedgerEntry as gW, hashMemoryText as gX, heartbeatCodexCredentialLease as gY, heartbeatCodexCredentialLeaseUntil as gZ, heartbeatLeaseHolder as g_, getMaterializedSandboxFileResources as ga, getOpenPtySession as gb, getOrCreateSessionSystemUpdateOutbox as gc, getPackInstallation as gd, getPendingDeviceEnrollmentRequestByUserCode as ge, getPendingDeviceEnrollmentRequestByUserCodeGlobal as gf, getRecording as gg, getRetainedFileArtifact as gh, getRig as gi, getRigByName as gj, getRigChange as gk, getRigName as gl, getRigVersion as gm, getRigVersionById as gn, getSandbox as go, getSandboxSessionEnvelope as gp, getScheduledTask as gq, getSession as gr, getSessionByCreateIdempotencyKey as gs, getSessionCodexState as gt, getSessionEvent as gu, getSessionEventByClientEventId as gv, getSessionForSubject as gw, getSessionGoal as gx, getSessionHistoryItems as gy, getSessionHumanInputRequest as gz, type AddSessionSystemUpdateResult as h, listVariableSets as h$, initializeSessionStartAtomically as h0, insertFailedWorkspaceCapture as h1, insertMachineMetricsSeries as h2, insertPtySession as h3, insertRecording as h4, insertWorkspaceCapture as h5, installOrReadTurnExecutionPolicyForAttempt as h6, interruptedToolCallResult as h7, isCodexBilledTurn as h8, isDatabasePersistenceFailure as h9, listPendingCodexCapacityWakeTargets as hA, listPendingSessionTurns as hB, listRecordings as hC, listRegistryCatalogSurfaceKeys as hD, listRigChangeMonitoringSummaries as hE, listRigChanges as hF, listRigVersionMonitoringSummaries as hG, listRigVersions as hH, listRigs as hI, listSandboxes as hJ, listScheduledTaskRuns as hK, listScheduledTasks as hL, listSessionDiscoverySummaries as hM, listSessionEventPage as hN, listSessionEvents as hO, listSessionHumanInputRequests as hP, listSessionIdsInGroup as hQ, listSessionMcpServerMetadata as hR, listSessionMcpServersForChildInheritance as hS, listSessionMcpServersForRun as hT, listSessionSystemUpdatesForTurn as hU, listSessionTurns as hV, listSessions as hW, listSessionsForSubject as hX, listSocialConnections as hY, listSocialPosts as hZ, listUsageEvents as h_, isMemoryTextTooLong as ha, isRetryablePersistenceSqlState as hb, isSessionCompactionRequested as hc, isSessionEventPersistenceError as hd, isStripeWebhookProcessed as he, latestWorkspaceCapture as hf, listApiKeys as hg, listCapabilityCatalogItems as hh, listCapabilityInstallations as hi, listCodexAccountStatuses as hj, listCodexResetRedemptionRecoveries as hk, listConnectionsMetadata as hl, listCreditBalancesByAccount as hm, listDistinctRigVersionIdsInGroup as hn, listDistinctVariableSetIdsInGroup as ho, listEnabledMcpCapabilityServers as hp, listEnrollments as hq, listGitHubInstallationAccessForWorkspace as hr, listGitHubInstallationIdsForWorkspace as hs, listGitHubInstallationsForWorkspace as ht, listKnowledgeMemories as hu, listLiveModalSandboxLeaseAttributions as hv, listMeterableWarmLeases as hw, listOpenPtySessions as hx, listOutstandingSessionSystemUpdates as hy, listPackInstallations as hz, type AdoptCodexResetRedemptionResult as i, recordSkippedContextCompaction as i$, listWorkspaceControlEvents as i0, listWorkspaceEnvironments as i1, listWorkspaceMembers as i2, listWorkspacePacks as i3, listWorkspacesForSubject as i4, loadCodexCredentialForRun as i5, loadConnectionCredentialForBroker as i6, loadIntegrationOAuthClient as i7, loadVariableSetForRun as i8, loadWorkspaceEnvironmentForRun as i9, persistWarmSnapshot as iA, planWorkspaceCaptureGc as iB, projectEffectiveControlForRelatedAccess as iC, projectSessionForRelatedAccess as iD, pruneHostExportOutbox as iE, quarantineCodexCredentialForLease as iF, reArmDrainingLease as iG, readActiveSandbox as iH, readLease as iI, readMachineMetricsLatest as iJ, readMachineMetricsLatestForWorkspace as iK, readMachineMetricsSeries as iL, reapExpiredSessionListSnapshots as iM, reapStaleLeaseHolders as iN, reapStaleLeaseHoldersGlobal as iO, reconcileCodexCapacityWait as iP, recordAuditEvent as iQ, recordCodexAccountConnectors as iR, recordCodexAccountUsage as iS, recordCodexAccountUsageWithWakeTargets as iT, recordCodexTokenRefresh as iU, recordConnectionTokenRefresh as iV, recordConnectionUsed as iW, recordLeaseDataPlaneUrl as iX, recordLeaseTerminalDataPlaneUrl as iY, recordPendingSessionToolCallResult as iZ, recordSessionActiveCodexCredential as i_, lockSessionEventWriteRows as ia, lockWorkspaceInferenceControl as ib, markFileUploadFailed as ic, markSandboxFileResourcesMaterialized as id, markScheduledTaskRunFailedIfQueued as ie, markSessionAttemptQuiesced as ig, markSessionSystemUpdateOutboxDeliveredInTransaction as ih, markSessionSystemUpdateOutboxFailed as ii, markSessionWorkflowWakeDelivered as ij, markSessionWorkflowWakeFailed as ik, markStaleRegistryCatalogItems as il, markStripeWebhookProcessed as im, markWarmLeaseInstanceLost as io, mcpServerIdForCapability as ip, moveQueuedTurnInTransaction as iq, mutateSessionControlInTransaction as ir, mutateWorkspaceControlInTransaction as is, nestedPostgresSqlState as it, nextSessionHistoryPosition as iu, normalizeBearerScheme as iv, normalizeMemoryText as iw, orphanedResultRowIndicesForRepair as ix, peekSessionWork as iy, persistDrainSnapshot as iz, AgentCommandAuthorityError as j, setEnrollmentOpStreamState as j$, recordStreamAcknowledgment as j0, recordStripeWebhookEvent as j1, recordUsageEvent as j2, recordWarmingSandboxCreated as j3, recoverSessionDispatch as j4, refreshOAuthConnectionCredential as j5, registerDbBinding as j6, registerHostExportConsumer as j7, registerInternalUpdateWakeInTransaction as j8, registerPendingSessionToolCall as j9, rewindHostExportConsumer as jA, rlsContextForWorkspace as jB, rlsStrategyFor as jC, runIdempotentPersistenceTransaction as jD, safeDatabaseErrorFacts as jE, sanitizeEventPayload as jF, sanitizeEventString as jG, sanitizeMemoryText as jH, sanitizeModelPayload as jI, saveComposerDraftInTransaction as jJ, saveRunState as jK, saveWorkspaceMemory as jL, searchWorkspaceMemories as jM, sendAgentMessageInTransaction as jN, serializeEffectiveSessionControl as jO, sessionAuthorizationScopeFilter as jP, sessionSubject as jQ, sessionTreeStatsForSessions as jR, sessionsWithActiveOpOnEnrollment as jS, setActiveCodexCredential as jT, setActiveSandbox as jU, setCodexCredentialExhausted as jV, setCodexCredentialExhaustedWithWakeTargets as jW, setCodexCredentialStatus as jX, setCodexCredentialStatusById as jY, setConnectionStatus as jZ, setEnrollmentDisplayState as j_, registerSessionTurnAttemptClaim as ja, registerSessionWorkflowWakeInTransaction as jb, registerWorkspacePack as jc, releaseCodexCredentialLease as jd, releaseCodexResetRedemptionClaim as je, releaseLeaseHolder as jf, removeWorkspaceMember as jg, renameCodexAccount as jh, renderWorkspaceMemoryBlock as ji, replaceIntegrationOAuthClient as jj, requestSessionCompaction as jk, requestSessionTurnRecovery as jl, requireFile as jm, requireScheduledTask as jn, requireSession as jo, requireSocialConnection as jp, requireWorkspace as jq, reserveSessionCommandReceipt as jr, reserveToolspaceCallForAttempt as js, resolveWorkspaceMemoryBlock as jt, resumeHostExportConsumer as ju, retireHostExportConsumer as jv, revokeApiKey as jw, revokeConnection as jx, revokeEnrollment as jy, revokeViewer as jz, type AgentInternalUpdateCommandResult as k, withWorkspaceSubjectRls as k$, setEnrollmentWentOffline as k0, setInitialActiveCodexCredential as k1, setRlsContext as k2, setSessionCodexPin as k3, setSessionGoalLastContinuationTurn as k4, setSessionGoalStatus as k5, setSessionLastInputTokensForTurnAttempt as k6, setSessionPin as k7, setTemporalWorkflowId as k8, setVariableSetVariable as k9, updateScheduledTask as kA, updateScheduledTaskRun as kB, updateSessionCommandReceiptResult as kC, updateSessionGoal as kD, updateSessionMcpApprovalPolicy as kE, updateSessionMcpServerCredentials as kF, updateSessionTitle as kG, updateVariableSet as kH, updateWorkspace as kI, updateWorkspaceEnvironment as kJ, updateWorkspaceSettings as kK, upsertBillingCustomer as kL, upsertCapabilityCatalogItem as kM, upsertCodexSubscriptionCredential as kN, upsertGitHubInstallation as kO, upsertMachineMetricsLatest as kP, upsertRegistryCapabilityCatalogItem as kQ, upsertSandboxSessionEnvelope as kR, upsertSessionGoal as kS, upsertWorkspaceModelPolicy as kT, validateHumanInputResponse as kU, withAccountRls as kV, withCodexCapacityMutation as kW, withCodexCredentialRefreshLock as kX, withCodexTokenDeadline as kY, withRlsContext as kZ, withWorkspaceRls as k_, setWorkspaceDefaultRig as ka, setWorkspaceEnvironmentVariable as kb, settleCodexCredentialFailover as kc, settleCodexCredentialLeaseLoss as kd, settleScheduledTaskRunInTransaction as ke, settleSessionAttemptInterruptions as kf, settleSessionIdleWithParentOutbox as kg, shortMemoryId as kh, steerAgentSessionInTransaction as ki, steerQueuedTurnInTransaction as kj, storeIntegrationOAuthClient as kk, submitHumanPromptInTransaction as kl, sumUsageQuantity as km, supersedeSessionCurrentDirectionInTransaction as kn, touchEnrollmentLastSeen as ko, touchLeaseHolder as kp, updateCodexAllocatorEligibility as kq, updateCodexRotationSettings as kr, updateConnection as ks, updateImportBatchCounts as kt, updateKnowledgeMemory as ku, updatePackInstallationStatus as kv, updatePtySessionActivity as kw, updateRecording as kx, updateRig as ky, updateRigChangeStatus as kz, type AppendEventInput as l, withWorkspaceUsageLock as l0, workspaceCaptureAtRevision as l1, workspaceCodexSubscriptionActive as l2, type ApplyContextCompactionResult as m, type ApplySessionTurnSettlementInput as n, type ApplySessionTurnSettlementResult as o, type ArmCodexCapacityWaitResult as p, provisionRoles, CODEX_CAPACITY_REFRESH_MIN_MS as q, CODEX_CREDENTIAL_LEASE_TTL_MS as r, CODEX_RESET_REDEMPTION_OUTCOMES as s, CODEX_ROTATION_STRATEGIES as t, type ClaimCodexResetRedemptionResult as u, type ClaimSessionWorkForAttemptInput as v, type ClaimSessionWorkForAttemptResult as w, type ClearSessionContextResult as x, type CodexAccountStatus as y, type CodexAccountUsageSnapshot as z };
|