@opengeni/db 0.28.1 → 0.28.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/{chunk-HT5T62CC.js → chunk-P6CUHXQZ.js} +651 -206
  2. package/dist/chunk-P6CUHXQZ.js.map +1 -0
  3. package/dist/{chunk-DBS5HPEW.js → chunk-VHBFHMPC.js} +7 -1
  4. package/dist/chunk-VHBFHMPC.js.map +1 -0
  5. package/dist/environment-crypto.d.ts +8 -4
  6. package/dist/index.d.ts +265 -20
  7. package/dist/index.js +3966 -2185
  8. package/dist/index.js.map +1 -1
  9. package/dist/lossless-columns.d.ts +58 -0
  10. package/dist/lossless-json.d.ts +39 -0
  11. package/dist/memory-domain.d.ts +3 -6
  12. package/dist/persistence-errors.d.ts +7 -14
  13. package/dist/provision-roles.js +1 -1
  14. package/dist/runtime-posture.d.ts +2 -2
  15. package/dist/schema.d.ts +1419 -271
  16. package/dist/schema.js +9 -1
  17. package/dist/session-realtime-terminal.d.ts +7 -0
  18. package/dist/transcription-recordings-schema.d.ts +44 -6
  19. package/dist/transcription-recordings.d.ts +1 -1
  20. package/drizzle/0065_enrollment_credential_generation.sql +10 -0
  21. package/drizzle/0140_retained_screenshot_artifacts.sql +192 -0
  22. package/drizzle/0176_lossless_canonical_json.sql +975 -0
  23. package/drizzle/0177_session_events_workspace_turn_type_index.sql +5 -0
  24. package/drizzle/0178_permissioned_secret_reads.sql +14 -0
  25. package/drizzle/0179_slack_private_shortcut_delivery_gate.sql +85 -0
  26. package/drizzle/0180_retained_screenshot_lifecycle_fences.sql +273 -0
  27. package/drizzle/0181_connected_machine_removal.sql +52 -0
  28. package/drizzle/0182_connected_machine_remove_session_default.sql +77 -0
  29. package/package.json +4 -4
  30. package/src/database.ts +7 -1
  31. package/src/environment-crypto.ts +22 -9
  32. package/src/index.ts +4253 -1601
  33. package/src/lossless-columns.ts +35 -0
  34. package/src/lossless-json.ts +322 -0
  35. package/src/memory-domain.ts +5 -44
  36. package/src/persistence-errors.ts +29 -34
  37. package/src/runtime-posture.ts +6 -0
  38. package/src/schema.ts +260 -38
  39. package/src/session-control.ts +125 -76
  40. package/src/session-queue-commands.ts +325 -234
  41. package/src/session-realtime-context.ts +18 -5
  42. package/src/session-realtime-ledger.ts +29 -7
  43. package/src/session-realtime-mirror.ts +4 -2
  44. package/src/session-realtime-terminal.ts +89 -21
  45. package/src/session-realtime.ts +3 -2
  46. package/src/session-tool-call-settlement.ts +29 -15
  47. package/src/transcription-recordings-schema.ts +5 -2
  48. package/src/transcription-recordings.ts +70 -40
  49. package/dist/chunk-DBS5HPEW.js.map +0 -1
  50. package/dist/chunk-HT5T62CC.js.map +0 -1
  51. package/dist/event-payload-sanitizer.d.ts +0 -32
  52. package/src/event-payload-sanitizer.ts +0 -377
package/dist/index.d.ts CHANGED
@@ -1,10 +1,11 @@
1
- import type { AccessContext, AccessGrant, AccessPrincipalKind, ApiKey, BillingBalance, CapabilityCatalogItem, CapabilityInstallation, CapabilityKind, CapabilityPack, CapabilitySource, ConnectionKind, ConnectionMetadata, ConnectionStatus, DocumentAuthorityKind, McpServerConnectionRef, FileAsset, FileUploadStatus, FirstPartyMcpToolName, HumanInputQuestion, HumanInputResponse, KnowledgeMemory, KnowledgeMemoryKind, KnowledgeMemoryStatus, KnowledgeSourceRef, GitHubInstallationAuthorityKind, GitHubRepositoryScope, HostEventExportBatch, HostUsageExportBatch, ManagedAccount, McpPersonalConnectionDelegation, Permission, PackInstallation, PackInstallationStatus, ResourceRef, SandboxBackend, SandboxOs, ScheduledTask, ScheduledTaskAgentConfig, ScheduledTaskOverlapPolicy, ScheduledTaskRun, ScheduledTaskRunMode, ScheduledTaskRunStatus, ScheduledTaskScheduleSpec, ScheduledTaskStatus, ScheduledTaskTriggerType, Session, SessionAuthorizationListScope, SessionListResponse, SessionEvent, SessionEventPayloadMode, SessionEventReadDirection, SessionEventSemanticClass, SessionEventType, SessionGoal, SessionGoalCreatedBy, SessionGoalStatus, SessionHumanInputRequest, LineageNode, SessionMcpApprovalPolicy, SessionSkill, SessionMcpServerMetadata, SessionStatus, SessionToolPolicy, SessionTurn, SessionQueueSnapshot, SessionSystemUpdate, SessionSystemUpdateKind, SystemUpdateClassification, SessionTurnSource, SessionTurnStatus, TurnInitiator, TurnInitiatorContext, SocialConnection, SocialConnectionStatus, SocialPost, SocialProvider, ToolRef, ReasoningEffort, UsageEvent, Workspace, WorkspaceControlEvent, VariableSet, VariableSetVariableMetadata, WorkspaceMember, WorkspaceRegisteredPack, Rig, RigVersion, RigChange, RigChangeKind, RigChangeStatus, RigCheck, NativeSnapshotDescriptor, TarWorkspaceArchiveDescriptor, WorkspaceArchiveDescriptor, ModalCheckpointProviderBinding } from "@opengeni/contracts";
1
+ import type { AccessContext, AccessGrant, AccessPrincipalKind, ApiKey, BillingBalance, CapabilityCatalogItem, CapabilityInstallation, CapabilityKind, CapabilityPack, CapabilitySource, ConnectionKind, ConnectionMetadata, ConnectionStatus, DocumentAuthorityKind, McpServerConnectionRef, FileAsset, FileUploadStatus, FirstPartyMcpToolName, HumanInputQuestion, HumanInputResponse, KnowledgeMemory, KnowledgeMemoryKind, KnowledgeMemoryStatus, KnowledgeSourceRef, GitHubInstallationAuthorityKind, GitHubRepositoryScope, HostEventExportBatch, HostUsageExportBatch, ManagedAccount, McpPersonalConnectionDelegation, Permission, PackInstallation, PackInstallationStatus, ResourceRef, SandboxBackend, SandboxOs, ScheduledTask, ScheduledTaskAgentConfig, ScheduledTaskOverlapPolicy, ScheduledTaskRun, ScheduledTaskRunMode, ScheduledTaskRunStatus, ScheduledTaskScheduleSpec, ScheduledTaskStatus, ScheduledTaskTriggerType, Session, SessionAuthorizationListScope, SessionListResponse, SessionEvent, SessionEventPayloadMode, SessionEventReadDirection, SessionEventSemanticClass, SessionEventType, SessionGoal, SessionGoalCreatedBy, SessionGoalStatus, SessionHumanInputRequest, LineageNode, SessionMcpApprovalPolicy, SessionSkill, SessionMcpServerMetadata, SessionStatus, SessionToolPolicy, SessionTurn, SessionQueueSnapshot, SessionSystemUpdate, SessionSystemUpdateKind, SystemUpdateClassification, SessionTurnSource, SessionTurnStatus, TurnInitiator, TurnInitiatorContext, SocialConnection, SocialConnectionStatus, SocialPost, SocialProvider, ToolRef, ReasoningEffort, UsageEvent, Workspace, WorkspaceControlEvent, VariableSet, VariableSetSecret, VariableSetVariableMetadata, WorkspaceMember, WorkspaceRegisteredPack, Rig, RigVersion, RigChange, RigChangeKind, RigChangeStatus, RigCheck, NativeSnapshotDescriptor, TarWorkspaceArchiveDescriptor, WorkspaceArchiveDescriptor, ModalCheckpointProviderBinding } from "@opengeni/contracts";
2
2
  import { type LatencyMode, SessionSystemUpdatePayload, TurnExecutionPolicyV1 } from "@opengeni/contracts";
3
3
  import { type Settings } from "@opengeni/config";
4
4
  import { type CodexFetch } from "@opengeni/codex";
5
5
  export { isCodexBilledModel } from "@opengeni/codex";
6
6
  import { type SQL } from "drizzle-orm";
7
7
  export { frozenInitiatorForCommandActor, type FrozenTurnInitiator } from "./turn-initiator";
8
+ export { LOSSLESS_TEXT_PREFIX } from "./lossless-json";
8
9
  import { type SessionDiscoveryControl, type SessionCommandActor, type SessionTurnAttemptOutcome } from "./session-control";
9
10
  import { type SessionRealtimeContinuityEntry } from "./session-realtime-context";
10
11
  import * as schema from "./schema";
@@ -22,11 +23,10 @@ export * from "./scoped-knowledge";
22
23
  export { interruptedToolCallResult } from "./session-tool-call-settlement";
23
24
  export { decryptEnvironmentValue, encryptEnvironmentValue } from "./environment-crypto";
24
25
  export { decryptEnvironmentValue as decryptVariableSetValue, encryptEnvironmentValue as encryptVariableSetValue, } from "./environment-crypto";
25
- export { sanitizeEventPayload, sanitizeEventString, sanitizeModelPayload, } from "./event-payload-sanitizer";
26
26
  export * from "./persistence-errors";
27
27
  export * from "./runtime-posture";
28
28
  export * from "./insights";
29
- export { sanitizeMemoryText } from "./memory-domain";
29
+ export { memoryTextForStorage } from "./memory-domain";
30
30
  export { migrate, runMigrations } from "./migrate";
31
31
  export { provisionRoles, type ProvisionResult, type ProvisionRolesOptions, } from "./provision-roles";
32
32
  export * from "./memory-domain";
@@ -539,6 +539,7 @@ export type CreateScheduledTaskInput = {
539
539
  createdByContext?: TurnInitiatorContext;
540
540
  createdByActor?: AgentSessionCreationActor | null;
541
541
  personalConnectionDelegations?: McpPersonalConnectionDelegation[];
542
+ targetSessionId?: string | null;
542
543
  variableSetId?: string | null;
543
544
  rigId?: string | null;
544
545
  metadata: Record<string, unknown>;
@@ -552,6 +553,7 @@ export type UpdateScheduledTaskInput = Partial<{
552
553
  agentConfig: ScheduledTaskAgentConfig;
553
554
  personalConnectionDelegations: McpPersonalConnectionDelegation[];
554
555
  reusableSessionId: string | null;
556
+ targetSessionId: string | null;
555
557
  variableSetId: string | null;
556
558
  rigId: string | null;
557
559
  metadata: Record<string, unknown>;
@@ -689,6 +691,15 @@ export type UpdateConnectionInput = {
689
691
  metadata?: Record<string, unknown>;
690
692
  updatedBySubjectId?: string | null;
691
693
  };
694
+ export type UpdateSlackBotDocumentDestinationInput = {
695
+ accountId: string;
696
+ workspaceId: string;
697
+ connectionId: string;
698
+ visibleToSubjectId: string;
699
+ expectedVersion: number;
700
+ metadata: Record<string, unknown>;
701
+ updatedBySubjectId: string;
702
+ };
692
703
  export type TransitionConnectionStateInput = {
693
704
  workspaceId: string;
694
705
  connectionId: string;
@@ -1006,6 +1017,138 @@ export type RetainedFileArtifact = {
1006
1017
  * location remain in the existing FileAsset/object-storage seam.
1007
1018
  */
1008
1019
  export declare function getRetainedFileArtifact(db: Database, workspaceId: string, fileId: string): Promise<RetainedFileArtifact | null>;
1020
+ export type RetainedScreenshotArtifactStatus = "pending" | "reconciling" | "ready" | "cleanup_queued" | "cleanup_pending" | "failed" | "expired" | "deleted";
1021
+ export type RetainedScreenshotQuotaState = "reserved" | "ready" | "released";
1022
+ export type RetainedScreenshotArtifact = {
1023
+ artifactId: string;
1024
+ accountId: string;
1025
+ workspaceId: string;
1026
+ sessionId: string | null;
1027
+ turnId: string | null;
1028
+ attemptId: string | null;
1029
+ settlementKey: string;
1030
+ toolCallId: string;
1031
+ toolOutputId: string;
1032
+ status: RetainedScreenshotArtifactStatus;
1033
+ quotaState: RetainedScreenshotQuotaState;
1034
+ mediaType: string;
1035
+ sizeBytes: number;
1036
+ sha256: string;
1037
+ width: number;
1038
+ height: number;
1039
+ retentionExpiresAt: Date;
1040
+ readyAt: Date | null;
1041
+ cleanupReason: string | null;
1042
+ lastError: string | null;
1043
+ maintenanceClaimId: string | null;
1044
+ maintenanceClaimedAt: Date | null;
1045
+ createdAt: Date;
1046
+ updatedAt: Date;
1047
+ file: FileAsset;
1048
+ };
1049
+ export declare class RetainedScreenshotQuotaExceededError extends Error {
1050
+ readonly quotaBytes: number;
1051
+ readonly usedBytes: number;
1052
+ readonly requestedBytes: number;
1053
+ readonly code = "retained_screenshot_workspace_quota_exceeded";
1054
+ constructor(quotaBytes: number, usedBytes: number, requestedBytes: number);
1055
+ }
1056
+ export type PrepareRetainedScreenshotArtifactInput = {
1057
+ artifactId: string;
1058
+ accountId: string;
1059
+ workspaceId: string;
1060
+ sessionId: string;
1061
+ turnId: string;
1062
+ attemptId: string;
1063
+ settlementKey: string;
1064
+ toolCallId: string;
1065
+ toolOutputId: string;
1066
+ mediaType: "image/png";
1067
+ sizeBytes: number;
1068
+ sha256: string;
1069
+ width: number;
1070
+ height: number;
1071
+ retentionExpiresAt: Date;
1072
+ bucket: string;
1073
+ objectKey: string;
1074
+ workspaceQuotaBytes: number;
1075
+ };
1076
+ /**
1077
+ * Reserve quota and create one deterministic pending file/artifact pair.
1078
+ * Replays return the original row only when every immutable identity and byte
1079
+ * fact matches; a UUID/settlement collision fails closed.
1080
+ */
1081
+ export declare function prepareRetainedScreenshotArtifact(db: Database, input: PrepareRetainedScreenshotArtifactInput): Promise<{
1082
+ artifact: RetainedScreenshotArtifact;
1083
+ created: boolean;
1084
+ }>;
1085
+ /** Settle one exact pending/reconciling artifact ready and move its quota once. */
1086
+ export declare function settleRetainedScreenshotArtifactReady(db: Database, input: {
1087
+ accountId: string;
1088
+ workspaceId: string;
1089
+ artifactId: string;
1090
+ settlementKey: string;
1091
+ maintenanceClaimId?: string;
1092
+ }): Promise<RetainedScreenshotArtifact>;
1093
+ /** Record a bounded diagnostic while preserving retryable pending truth. */
1094
+ export declare function recordRetainedScreenshotArtifactError(db: Database, input: {
1095
+ accountId: string;
1096
+ workspaceId: string;
1097
+ artifactId: string;
1098
+ settlementKey: string;
1099
+ error: string;
1100
+ }): Promise<void>;
1101
+ /** Session-qualified lookup: a screenshot from another session is indistinguishable from absent. */
1102
+ export declare function getRetainedScreenshotArtifact(db: Database, workspaceId: string, sessionId: string, artifactId: string): Promise<RetainedScreenshotArtifact | null>;
1103
+ export type RetainedScreenshotMaintenanceClaim = {
1104
+ action: "reconcile" | "delete";
1105
+ claimId: string;
1106
+ artifactId: string;
1107
+ accountId: string;
1108
+ workspaceId: string;
1109
+ sessionId: string | null;
1110
+ objectKey: string;
1111
+ mediaType: string;
1112
+ sizeBytes: number;
1113
+ sha256: string;
1114
+ width: number;
1115
+ height: number;
1116
+ retentionExpiresAt: Date;
1117
+ cleanupReason: string | null;
1118
+ };
1119
+ /** Bounded global claim through the migration's sole FORCE-RLS bypass. */
1120
+ export declare function claimRetainedScreenshotMaintenance(db: Database, input: {
1121
+ pendingGraceMs: number;
1122
+ claimTimeoutMs: number;
1123
+ limit: number;
1124
+ }): Promise<RetainedScreenshotMaintenanceClaim[]>;
1125
+ /**
1126
+ * Atomically transfer one exact reconcile claim into cleanup ownership before
1127
+ * any provider delete. A concurrent ready settlement clears/replaces the claim
1128
+ * and makes this a stale no-op.
1129
+ */
1130
+ export declare function promoteRetainedScreenshotMaintenanceCleanup(db: Database, input: {
1131
+ accountId: string;
1132
+ workspaceId: string;
1133
+ artifactId: string;
1134
+ claimId: string;
1135
+ cleanupReason: string;
1136
+ }): Promise<boolean>;
1137
+ /**
1138
+ * Complete a claimed reconcile/delete operation and release exactly one quota
1139
+ * bucket. A lost response is idempotent on the requested terminal state.
1140
+ */
1141
+ export declare function completeRetainedScreenshotMaintenance(db: Database, input: {
1142
+ accountId: string;
1143
+ workspaceId: string;
1144
+ artifactId: string;
1145
+ claimId: string;
1146
+ outcome: "ready" | "failed" | "expired" | "deleted";
1147
+ }): Promise<boolean>;
1148
+ export declare function getWorkspaceScreenshotQuota(db: Database, workspaceId: string): Promise<{
1149
+ reservedBytes: number;
1150
+ readyBytes: number;
1151
+ } | null>;
1009
1152
  export declare function getFileUpload(db: Database, workspaceId: string, uploadId: string): Promise<{
1010
1153
  id: string;
1011
1154
  status: FileUploadStatus;
@@ -1110,7 +1253,7 @@ export declare function decryptedCapabilityHeaders(server: EnabledMcpCapabilityS
1110
1253
  * Returns the encrypted credential-header map stored on a capability
1111
1254
  * installation, or null when none is stored. This is the only read path for
1112
1255
  * the ciphertext besides listEnabledMcpCapabilityServers; the generic
1113
- * installation mapping redacts it to header names.
1256
+ * installation mapping projects it to header names.
1114
1257
  */
1115
1258
  export declare function getStoredCapabilityHeaderCiphertext(db: Database, workspaceId: string, capabilityId: string): Promise<Record<string, string> | null>;
1116
1259
  export declare function mcpServerIdForCapability(capabilityId: string, metadata?: Record<string, unknown>): string;
@@ -1118,6 +1261,12 @@ export declare function createConnection(db: Database, input: CreateConnectionIn
1118
1261
  export declare function listConnectionsMetadata(db: Database, workspaceId: string, subjectId?: string | null): Promise<ConnectionMetadataWithVerification[]>;
1119
1262
  export declare function getConnectionMetadata(db: Database, workspaceId: string, connectionId: string, subjectId?: string | null): Promise<ConnectionMetadataWithVerification | null>;
1120
1263
  export declare function updateConnection(db: Database, input: UpdateConnectionInput): Promise<ConnectionMetadataWithVerification | null>;
1264
+ /**
1265
+ * Updates only pre-validated workspace Slack-bot destination metadata while
1266
+ * atomically advancing its install proof to the new connection generation.
1267
+ * A stale version or already-invalid proof returns null without writing.
1268
+ */
1269
+ export declare function updateSlackBotDocumentDestination(db: Database, input: UpdateSlackBotDocumentDestinationInput): Promise<ConnectionMetadataWithVerification | null>;
1121
1270
  /**
1122
1271
  * Applies a metadata/status lifecycle transition behind the connection's
1123
1272
  * existing `(id, version)` fence. Unlike ordinary metadata edits, every
@@ -1297,8 +1446,10 @@ export declare function claimSlackInteractionProgressDelivery(db: Database, inpu
1297
1446
  }): Promise<SlackInteractionProgressClaim>;
1298
1447
  export declare function rekeySlackInteractionRoute(db: Database, input: Pick<SlackInteraction, "id" | "accountId" | "workspaceId"> & {
1299
1448
  routeKey: string;
1449
+ slackChannelId?: string;
1300
1450
  slackThreadTs: string;
1301
1451
  ackSlackMessageTs: string;
1452
+ repairUnacknowledgedPrivateShortcutDelivery?: boolean;
1302
1453
  }): Promise<SlackInteraction | null>;
1303
1454
  export declare function claimSlackInteractionDelivery(db: Database, claimHolderId: string, claimLeaseMs: number): Promise<SlackInteraction | null>;
1304
1455
  export declare function reopenSlackInteractionDelivery(db: Database, input: Pick<SlackInteraction, "id" | "accountId" | "workspaceId">): Promise<boolean>;
@@ -1525,7 +1676,6 @@ export type SaveWorkspaceMemoryResult = {
1525
1676
  superseded: KnowledgeMemory | null;
1526
1677
  supersededId: string | null;
1527
1678
  updated: boolean;
1528
- redactionCount: number;
1529
1679
  embedded: boolean;
1530
1680
  };
1531
1681
  export type CorrectWorkspaceMemoryInput = {
@@ -1615,7 +1765,21 @@ export declare function updateScheduledTask(db: Database, workspaceId: string, t
1615
1765
  export declare function getScheduledTask(db: Database, workspaceId: string, taskId: string): Promise<ScheduledTask | null>;
1616
1766
  export declare function getScheduledTaskPersonalConnectionDelegations(db: Database, workspaceId: string, taskId: string): Promise<McpPersonalConnectionDelegation[]>;
1617
1767
  export declare function requireScheduledTask(db: Database, workspaceId: string, taskId: string): Promise<ScheduledTask>;
1618
- export declare function listScheduledTasks(db: Database, workspaceId: string, limit?: number): Promise<ScheduledTask[]>;
1768
+ export declare class ScheduledTaskTargetConflictError extends Error {
1769
+ constructor();
1770
+ }
1771
+ /**
1772
+ * DB-only delivery fence used inside the system-update source transaction.
1773
+ * The task row is locked after the target session row, so a concurrent retarget
1774
+ * linearizes before or after the complete scheduled occurrence instead of
1775
+ * delivering one fire to a stale session snapshot.
1776
+ */
1777
+ export declare function requireScheduledTaskTargetInTransaction(tx: Database, input: {
1778
+ workspaceId: string;
1779
+ taskId: string;
1780
+ targetSessionId: string;
1781
+ }): Promise<void>;
1782
+ export declare function listScheduledTasks(db: Database, workspaceId: string, limit?: number, offset?: number): Promise<ScheduledTask[]>;
1619
1783
  export declare function deleteScheduledTask(db: Database, workspaceId: string, taskId: string): Promise<void>;
1620
1784
  export declare function createScheduledTaskRun(db: Database, input: {
1621
1785
  workspaceId: string;
@@ -1656,6 +1820,37 @@ export declare function createVariableSet(db: Database, input: {
1656
1820
  export declare function listVariableSets(db: Database, workspaceId: string): Promise<VariableSet[]>;
1657
1821
  export declare function getVariableSet(db: Database, workspaceId: string, variableSetId: string): Promise<VariableSet | null>;
1658
1822
  export declare function getVariableSetByName(db: Database, workspaceId: string, name: string): Promise<VariableSet | null>;
1823
+ export type VariableSetSecretAuditActor = {
1824
+ kind: "subject";
1825
+ } | {
1826
+ kind: "agent_attempt";
1827
+ sessionId: string;
1828
+ turnId: string;
1829
+ attemptId: string;
1830
+ executionGeneration: number;
1831
+ };
1832
+ export declare class VariableSetSecretReadAuthorityError extends Error {
1833
+ readonly code = "VARIABLE_SET_SECRET_READ_AUTHORITY_STALE";
1834
+ constructor();
1835
+ }
1836
+ /**
1837
+ * Read one encrypted value, decrypt it, and commit its metadata-only audit in
1838
+ * one RLS transaction. Agent reads lock and recheck the canonical attempt/control
1839
+ * fence in that same transaction, so cancellation or replacement linearizes
1840
+ * either before the read (denied) or after its committed audit. The plaintext is
1841
+ * returned only after the audit insert commits; an audit failure rolls back and
1842
+ * rejects the whole operation.
1843
+ */
1844
+ export declare function readVariableSetSecretAtomically(db: Database, input: {
1845
+ accountId: string;
1846
+ workspaceId: string;
1847
+ subjectId: string;
1848
+ variableSetId?: string;
1849
+ variableSetName?: string;
1850
+ name: string;
1851
+ actor: VariableSetSecretAuditActor;
1852
+ decrypt: (valueEncrypted: string) => string;
1853
+ }): Promise<VariableSetSecret | null>;
1659
1854
  export declare function updateVariableSet(db: Database, workspaceId: string, variableSetId: string, input: {
1660
1855
  name?: string;
1661
1856
  description?: string | null;
@@ -2119,7 +2314,7 @@ export type CodexCredentialLeasePolicyScopeResolver<TPolicyScope> = (turnMetadat
2119
2314
  export type CodexCredentialLeaseCandidateFilterResult<TUnavailableDiagnostic = never> = {
2120
2315
  /** Candidates from exactly one selected policy scope; never a union-ranked pool list. */
2121
2316
  accounts: readonly CodexLeaseAccountStatus[];
2122
- /** Downstream-owned, secret-safe diagnostics for rejected primary/fallback scopes. */
2317
+ /** Downstream-owned, value-free metadata diagnostics for rejected primary/fallback scopes. */
2123
2318
  unavailableDiagnostics?: readonly TUnavailableDiagnostic[];
2124
2319
  };
2125
2320
  export type CodexCredentialLeaseCandidateFilter<TPolicyScope, TUnavailableDiagnostic = never> = (input: {
@@ -3189,16 +3384,11 @@ export type SessionEventPage = {
3189
3384
  };
3190
3385
  export declare const SESSION_EVENT_DB_PAGE_MAX_BYTES: number;
3191
3386
  /**
3192
- * Read one direction-aware session-event page without transferring legacy raw
3193
- * payloads or malformed free-form envelope strings out of PostgreSQL.
3194
- *
3195
- * Migration 0067 deliberately leaves historical rows untouched. This query
3196
- * invokes its immutable payload projector in SQL and mirrors the rolling
3197
- * envelope guard in SQL, then accumulates small batches under one RLS
3198
- * transaction. `bytes` is the exact UTF-8 size of `JSON.stringify(events)`;
3199
- * `hasMore` is true whenever count or byte selection stopped before the durable
3200
- * range ended. A nonempty durable range can therefore never become an empty,
3201
- * non-advancing HTTP page.
3387
+ * Read one direction-aware session-event page. Full mode selects the canonical
3388
+ * row exactly; summary/none modes derive bounded monitoring projections in SQL
3389
+ * without rewriting the retained source. `bytes` is the exact UTF-8 size of
3390
+ * `JSON.stringify(events)`; `hasMore` is true whenever count or byte selection
3391
+ * stopped before the durable range ended.
3202
3392
  */
3203
3393
  export declare function listSessionEventPage(db: Database, workspaceId: string, sessionId: string, options?: ListSessionEventPageOptions): Promise<SessionEventPage>;
3204
3394
  export declare function listSessionEvents(db: Database, workspaceId: string, sessionId: string): Promise<SessionEvent[]>;
@@ -3372,8 +3562,8 @@ export type PendingSessionToolCallInput = {
3372
3562
  };
3373
3563
  /**
3374
3564
  * Durably capture the raw SDK call item at the exact attempt boundary. This is
3375
- * model-facing truth, deliberately separate from the redacted session-event
3376
- * projection. The receipt belongs to the logical turn so an approval resume can
3565
+ * model-facing truth, deliberately separate from the session-event timeline.
3566
+ * The receipt belongs to the logical turn so an approval resume can
3377
3567
  * settle it from a newer attempt. Duplicate SDK delivery converges on the
3378
3568
  * unique (turn, call) identity.
3379
3569
  */
@@ -5323,6 +5513,7 @@ export type EnrollmentRecord = {
5323
5513
  desktopUnavailableReason: string | null;
5324
5514
  allowScreenControl: boolean;
5325
5515
  status: EnrollmentStatus;
5516
+ credentialGeneration: number;
5326
5517
  os: EnrollmentOs;
5327
5518
  arch: string;
5328
5519
  lastSeenAt: string | null;
@@ -5360,6 +5551,47 @@ export declare function getEnrollment(db: Database, workspaceId: string, enrollm
5360
5551
  export declare function listEnrollments(db: Database, workspaceId: string, options?: {
5361
5552
  status?: EnrollmentStatus;
5362
5553
  }): Promise<EnrollmentRecord[]>;
5554
+ export type MachineRemovalOutcome = (typeof schema.machineRemovalOperationOutcomeValues)[number];
5555
+ export type MachineRemovalBlockCode = "active_route" | "active_commands" | "active_lease" | "recovery_pending" | "not_selfhosted";
5556
+ export type MachineRemovalResult = {
5557
+ enrollmentId: string;
5558
+ outcome: MachineRemovalOutcome;
5559
+ removed: boolean;
5560
+ machineName: string | null;
5561
+ lastSeenAt: string | null;
5562
+ revokedAt: string | null;
5563
+ code: MachineRemovalBlockCode | null;
5564
+ message: string;
5565
+ action: string;
5566
+ };
5567
+ export declare class MachineRemovalIdempotencyError extends Error {
5568
+ readonly name = "MachineRemovalIdempotencyError";
5569
+ }
5570
+ export declare class MachineRemovalRevisionConflictError extends Error {
5571
+ readonly currentUpdatedAt: string;
5572
+ readonly name = "MachineRemovalRevisionConflictError";
5573
+ constructor(message: string, currentUpdatedAt: string);
5574
+ }
5575
+ /**
5576
+ * Remove one connected-machine enrollment without touching the durable identity
5577
+ * or any session/route/archive evidence. The enrollment row is the lifecycle
5578
+ * truth: status -> revoked rejects future auth-callout/heartbeat/reconnect
5579
+ * attempts, while a fresh device-flow re-enrollment can reactivate the same
5580
+ * public-key identity with a new credential family.
5581
+ *
5582
+ * The operation key is scoped to the workspace and is receipt-backed. A retry
5583
+ * with the same key and request fingerprint replays the exact committed result;
5584
+ * a different fingerprint is rejected rather than risking an accidental replay
5585
+ * against a changed control-plane revision.
5586
+ */
5587
+ export declare function removeEnrollment(db: Database, input: {
5588
+ accountId: string;
5589
+ workspaceId: string;
5590
+ enrollmentId: string;
5591
+ operationKey: string;
5592
+ expectedUpdatedAt?: string;
5593
+ subjectId?: string | null;
5594
+ }): Promise<MachineRemovalResult | null>;
5363
5595
  export declare function revokeEnrollment(db: Database, input: {
5364
5596
  accountId: string;
5365
5597
  workspaceId: string;
@@ -5367,6 +5599,14 @@ export declare function revokeEnrollment(db: Database, input: {
5367
5599
  }): Promise<{
5368
5600
  revoked: boolean;
5369
5601
  }>;
5602
+ export declare function revokeEnrollmentByGeneration(db: Database, input: {
5603
+ workspaceId: string;
5604
+ enrollmentId: string;
5605
+ credentialGeneration: number;
5606
+ }): Promise<{
5607
+ matched: boolean;
5608
+ revoked: boolean;
5609
+ }>;
5370
5610
  export declare function touchEnrollmentLastSeen(db: Database, input: {
5371
5611
  accountId: string;
5372
5612
  workspaceId: string;
@@ -5941,6 +6181,8 @@ export type InitializeSessionStartResult = {
5941
6181
  turn: SessionTurn | null;
5942
6182
  temporalWorkflowId: string;
5943
6183
  workflowWakeRevision: number | null;
6184
+ /** True when this call installed/repaired start state or committed a new wake revision. */
6185
+ changed: boolean;
5944
6186
  };
5945
6187
  /**
5946
6188
  * Install a newly created session's complete first runnable unit atomically.
@@ -5998,7 +6240,10 @@ export type SessionAttemptInterruptionSettlement = {
5998
6240
  * exact turn -> exact attempt lock order and require the durable interruption.
5999
6241
  * Temporal activity cancellation/terminalization is transport state only. The
6000
6242
  * workflow admits a replacement from this durable receipt, never from the
6001
- * activity promise.
6243
+ * activity promise. The same boundary also applies when the activity itself
6244
+ * durably requested same-turn recovery (for example during a worker rollout):
6245
+ * that recovery event is the logical settlement cause in place of a
6246
+ * Pause/Steer interruption row.
6002
6247
  */
6003
6248
  export declare function markSessionAttemptQuiesced(db: Database, input: {
6004
6249
  accountId?: string;