@opengeni/db 3.7.4 → 3.8.2-canary.0

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 (77) hide show
  1. package/dist/automations.d.ts +4 -0
  2. package/dist/canonical-human-identities.js +3 -3
  3. package/dist/{chunk-O56DM5GZ.js → chunk-53A2PEHT.js} +328 -31
  4. package/dist/chunk-53A2PEHT.js.map +1 -0
  5. package/dist/{chunk-SZAWDXQC.js → chunk-5S4BQAHX.js} +3 -3
  6. package/dist/{chunk-S3TDDCS2.js → chunk-CITYUGMW.js} +3 -3
  7. package/dist/{chunk-4NAR7FBA.js → chunk-F5YOZEYQ.js} +49 -1
  8. package/dist/chunk-F5YOZEYQ.js.map +1 -0
  9. package/dist/{chunk-F6PBS6WE.js → chunk-HZV7O6JR.js} +2 -2
  10. package/dist/{chunk-5NNCGFQY.js → chunk-RLQVPOVR.js} +2 -2
  11. package/dist/{chunk-DZCYW2WT.js → chunk-UKOGHUGC.js} +2 -2
  12. package/dist/{chunk-US4IS6IV.js → chunk-X6TO5HII.js} +2 -2
  13. package/dist/{chunk-U4WPPEBH.js → chunk-Y53WEFYB.js} +2 -2
  14. package/dist/connection-token-resolver.d.ts +4 -0
  15. package/dist/editable-artifact-durable-export.js +2 -2
  16. package/dist/editable-artifacts.js +3 -3
  17. package/dist/index.d.ts +164 -14
  18. package/dist/index.js +7327 -5442
  19. package/dist/index.js.map +1 -1
  20. package/dist/insights.d.ts +9 -0
  21. package/dist/managed-auth-session-sets.js +3 -3
  22. package/dist/model-catalog.d.ts +153 -0
  23. package/dist/new-session-drafts.d.ts +12 -0
  24. package/dist/organization-membership-lifecycle.d.ts +8 -1
  25. package/dist/organization-model-providers.d.ts +101 -0
  26. package/dist/pack-components.d.ts +1 -0
  27. package/dist/pr-review.d.ts +9 -0
  28. package/dist/provision-roles.js +1 -1
  29. package/dist/runtime-posture.d.ts +7 -7
  30. package/dist/schema.d.ts +989 -2
  31. package/dist/schema.js +11 -1
  32. package/dist/session-background-commands.js +3 -3
  33. package/dist/session-control.d.ts +35 -0
  34. package/dist/session-queue-commands.d.ts +17 -0
  35. package/dist/session-tenancy.js +3 -3
  36. package/dist/video-generation.js +3 -3
  37. package/dist/xai-subscription.d.ts +8 -0
  38. package/drizzle/0387_bound_host_export_session_payloads.sql +165 -0
  39. package/drizzle/0388_sandbox_provider_deadline_interactions.sql +491 -0
  40. package/drizzle/0389_model_catalog_and_gateway_custom_models.sql +241 -0
  41. package/drizzle/0390_organization_model_provider_connections.sql +197 -0
  42. package/drizzle/0391_sandbox_provider_deadline_interaction_followup.sql +295 -0
  43. package/drizzle/0392_context_compaction_pending_observability.sql +198 -0
  44. package/drizzle/0393_workspace_memory_and_learning_defaults.sql +102 -0
  45. package/drizzle/0394_session_selected_skill_activation.sql +20 -0
  46. package/drizzle/0395_scheduled_task_unclaimed_occurrence_invalidation.sql +154 -0
  47. package/drizzle/0396_model_call_equivalent_credit_cost.sql +28 -0
  48. package/drizzle/0397_sandbox_deadline_rotation_preemption.sql +113 -0
  49. package/drizzle/0398_organization_workspace_management_entry.sql +206 -0
  50. package/drizzle/0399_additional_managed_organization_creation.sql +691 -0
  51. package/package.json +6 -6
  52. package/src/automations.ts +9 -1
  53. package/src/connection-token-resolver.ts +12 -0
  54. package/src/index.ts +1551 -272
  55. package/src/insights-model-bundle.ts +54 -5
  56. package/src/insights.ts +53 -7
  57. package/src/model-catalog.ts +682 -0
  58. package/src/new-session-drafts.ts +66 -21
  59. package/src/organization-membership-lifecycle.ts +47 -5
  60. package/src/organization-model-providers.ts +614 -0
  61. package/src/pack-components.ts +15 -2
  62. package/src/pr-review.ts +19 -0
  63. package/src/provision-roles.ts +2 -0
  64. package/src/runtime-posture.ts +48 -0
  65. package/src/schema.ts +348 -32
  66. package/src/session-control.ts +170 -0
  67. package/src/session-queue-commands.ts +157 -82
  68. package/src/xai-subscription.ts +66 -14
  69. package/dist/chunk-4NAR7FBA.js.map +0 -1
  70. package/dist/chunk-O56DM5GZ.js.map +0 -1
  71. /package/dist/{chunk-SZAWDXQC.js.map → chunk-5S4BQAHX.js.map} +0 -0
  72. /package/dist/{chunk-S3TDDCS2.js.map → chunk-CITYUGMW.js.map} +0 -0
  73. /package/dist/{chunk-F6PBS6WE.js.map → chunk-HZV7O6JR.js.map} +0 -0
  74. /package/dist/{chunk-5NNCGFQY.js.map → chunk-RLQVPOVR.js.map} +0 -0
  75. /package/dist/{chunk-DZCYW2WT.js.map → chunk-UKOGHUGC.js.map} +0 -0
  76. /package/dist/{chunk-US4IS6IV.js.map → chunk-X6TO5HII.js.map} +0 -0
  77. /package/dist/{chunk-U4WPPEBH.js.map → chunk-Y53WEFYB.js.map} +0 -0
@@ -4,7 +4,7 @@ import {
4
4
  sessions,
5
5
  workspaceSessionActivityRevisions,
6
6
  workspaces
7
- } from "./chunk-O56DM5GZ.js";
7
+ } from "./chunk-53A2PEHT.js";
8
8
 
9
9
  // src/persistence-errors.ts
10
10
  var SQLSTATE_KEYS = ["sqlState", "sqlstate", "code"];
@@ -755,4 +755,4 @@ export {
755
755
  withAccountRls,
756
756
  dbBindingFor
757
757
  };
758
- //# sourceMappingURL=chunk-F6PBS6WE.js.map
758
+ //# sourceMappingURL=chunk-HZV7O6JR.js.map
@@ -5,7 +5,7 @@ import {
5
5
  withWorkspaceRls,
6
6
  withWorkspaceSubjectRls,
7
7
  withWorkspaceSubjectSessionActivityRls
8
- } from "./chunk-F6PBS6WE.js";
8
+ } from "./chunk-HZV7O6JR.js";
9
9
 
10
10
  // src/session-tenancy.ts
11
11
  import { createHash } from "crypto";
@@ -481,4 +481,4 @@ export {
481
481
  forkSessionContent,
482
482
  replayAppliedSessionFork
483
483
  };
484
- //# sourceMappingURL=chunk-5NNCGFQY.js.map
484
+ //# sourceMappingURL=chunk-RLQVPOVR.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  nestedPostgresSqlState,
3
3
  rawRows
4
- } from "./chunk-F6PBS6WE.js";
4
+ } from "./chunk-HZV7O6JR.js";
5
5
 
6
6
  // src/managed-auth-session-sets.ts
7
7
  import {
@@ -296,4 +296,4 @@ export {
296
296
  reapManagedAuthIsolatedSessions,
297
297
  reapExpiredManagedAuthSessionSets
298
298
  };
299
- //# sourceMappingURL=chunk-DZCYW2WT.js.map
299
+ //# sourceMappingURL=chunk-UKOGHUGC.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  rawRows,
3
3
  withRlsContext
4
- } from "./chunk-F6PBS6WE.js";
4
+ } from "./chunk-HZV7O6JR.js";
5
5
 
6
6
  // src/editable-artifacts.ts
7
7
  import { createHash } from "crypto";
@@ -3540,4 +3540,4 @@ export {
3540
3540
  PostgresEditableArtifactStore,
3541
3541
  PostgresEditableArtifactLiveReadStore
3542
3542
  };
3543
- //# sourceMappingURL=chunk-US4IS6IV.js.map
3543
+ //# sourceMappingURL=chunk-X6TO5HII.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  nestedPostgresSqlState,
3
3
  rawRows
4
- } from "./chunk-F6PBS6WE.js";
4
+ } from "./chunk-HZV7O6JR.js";
5
5
 
6
6
  // src/canonical-human-identities.ts
7
7
  import { createHash } from "crypto";
@@ -309,4 +309,4 @@ export {
309
309
  getCanonicalHumanIdentityProjection,
310
310
  applyCanonicalHumanIdentityOperation
311
311
  };
312
- //# sourceMappingURL=chunk-U4WPPEBH.js.map
312
+ //# sourceMappingURL=chunk-Y53WEFYB.js.map
@@ -51,6 +51,8 @@ export type ConnectionStatusGuard = {
51
51
  export type ResolveConnectionCredentialResult = {
52
52
  status: "ok";
53
53
  headers: Record<string, string>;
54
+ /** Credential authority is owned by the embedding host, not the native connection store. */
55
+ authoritySource?: "host";
54
56
  /** Present when the credential bundle or embedding host supplied explicit placements. */
55
57
  placements?: ConnectionCredentialPlacement[];
56
58
  connectionId: string;
@@ -69,6 +71,8 @@ export type ResolveConnectionCredentialResult = {
69
71
  status: "auth_needed";
70
72
  reason: McpCredentialAuthNeededReason;
71
73
  providerDomain: string;
74
+ /** Credential authority is owned by the embedding host, not the native connection store. */
75
+ authoritySource?: "host";
72
76
  provider?: string;
73
77
  connectionId?: string;
74
78
  scopes?: string[];
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  rawRows,
3
3
  withRlsContext
4
- } from "./chunk-F6PBS6WE.js";
5
- import "./chunk-O56DM5GZ.js";
4
+ } from "./chunk-HZV7O6JR.js";
5
+ import "./chunk-53A2PEHT.js";
6
6
  import "./chunk-PZ5AY32C.js";
7
7
 
8
8
  // src/editable-artifact-durable-export.ts
@@ -8,9 +8,9 @@ import {
8
8
  PostgresEditableArtifactStore,
9
9
  listEditableArtifactIdsForSession,
10
10
  touchEditableArtifactSessionLink
11
- } from "./chunk-US4IS6IV.js";
12
- import "./chunk-F6PBS6WE.js";
13
- import "./chunk-O56DM5GZ.js";
11
+ } from "./chunk-X6TO5HII.js";
12
+ import "./chunk-HZV7O6JR.js";
13
+ import "./chunk-53A2PEHT.js";
14
14
  import "./chunk-PZ5AY32C.js";
15
15
  export {
16
16
  EDITABLE_ARTIFACT_INTENT_MAX_BYTES,
package/dist/index.d.ts CHANGED
@@ -68,6 +68,7 @@ export { memoryTextForStorage } from "./memory-domain.js";
68
68
  export { migrate, runMigrations } from "./migrate.js";
69
69
  export { provisionRoles, type ProvisionResult, type ProvisionRolesOptions, } from "./provision-roles.js";
70
70
  export * from "./memory-domain.js";
71
+ export * from "./model-catalog.js";
71
72
  import { type Database, type SessionActivityDatabase } from "./database.js";
72
73
  export { createDb, registerDbBinding, retrySessionActivityRls, rlsContextForWorkspace, rlsStrategyFor, setRlsContext, setSubjectRlsContext, withAccountRls, withDatabaseStatementTimeout, withRlsContext, withSessionActivityRlsContext, withSessionActivitySavepoint, withWorkspaceRls, withWorkspaceSessionActivityRls, withWorkspaceSubjectRls, withWorkspaceSubjectSessionActivityRls, withWorkspaceUsageLock, withSandboxProviderReadLock, SandboxProviderReadLockUnavailableError, type CreateDbOptions, type Database, type DbClient, type SessionActivityDatabase, type RlsContext, type SessionRlsActorContext, type RlsStrategy, type SandboxProviderReadLockIdentity, type ManagedUserProfile, type UserLookup, type UserProfileLookup, } from "./database.js";
73
74
  export { withSessionRlsActorContext } from "./database.js";
@@ -536,6 +537,7 @@ export declare function deleteWorkspaceIfQuiescent(db: Database, input: {
536
537
  accountId: string;
537
538
  workspaceId: string;
538
539
  observer?: WorkspaceDeleteObserver;
540
+ organizationAdministratorSubjectId?: string;
539
541
  }): Promise<DeleteWorkspaceIfQuiescentResult>;
540
542
  /** Claim a bounded cross-workspace batch after abandoned claims expire. */
541
543
  export declare function claimTemporalScheduleCleanups(db: Database, input: {
@@ -718,6 +720,7 @@ export type ModelCallFact = {
718
720
  totalTokens: number | null;
719
721
  pricedCostMicros: number;
720
722
  estimatedProviderCostMicros: number | null;
723
+ equivalentCreditCostMicros: number | null;
721
724
  pricingSource: "configured_list_price" | "gateway_reported" | null;
722
725
  contextContributions: readonly ModelContextContributionSummary[] | null;
723
726
  occurredAt: Date;
@@ -740,6 +743,7 @@ export declare function recordModelCallFact(db: Database, input: {
740
743
  billingPath: ModelCallBillingPath;
741
744
  pricedCostMicros: number;
742
745
  estimatedProviderCostMicros?: number | null;
746
+ equivalentCreditCostMicros?: number | null;
743
747
  pricingSource?: "configured_list_price" | "gateway_reported" | null;
744
748
  contextContributions?: readonly ModelContextContributionSummary[] | null;
745
749
  inputTokens?: number | null;
@@ -849,6 +853,8 @@ export type CreateScheduledTaskInput = {
849
853
  variableSetId?: string | null;
850
854
  rigId?: string | null;
851
855
  metadata: Record<string, unknown>;
856
+ /** Trusted database-only admission seam. Throwing rolls the task creation back. */
857
+ beforeCreateCommit?: (tx: Database) => Promise<void>;
852
858
  };
853
859
  export type UpdateScheduledTaskInput = Partial<{
854
860
  name: string;
@@ -870,6 +876,8 @@ export type UpdateScheduledTaskInput = Partial<{
870
876
  authorityUpdatedBy: TurnInitiator;
871
877
  authorityUpdatedByContext: TurnInitiatorContext;
872
878
  authorityUpdatedByActor: AgentSessionCreationActor | null;
879
+ /** Trusted database-only admission seam. Throwing rolls the task update back. */
880
+ beforeUpdateCommit: (tx: Database) => Promise<void>;
873
881
  }>;
874
882
  export type CreatePackInstallationInput = {
875
883
  accountId: string;
@@ -992,6 +1000,43 @@ export type CreateConnectionInput = {
992
1000
  createdBySubjectId?: string | null;
993
1001
  updatedBySubjectId?: string | null;
994
1002
  };
1003
+ type UpsertWorkspaceProviderApiKeyConnectionInput = {
1004
+ accountId: string;
1005
+ workspaceId: string;
1006
+ operationId: string;
1007
+ requestDigest: string;
1008
+ credentialEncrypted: string;
1009
+ grantedScopes?: string[];
1010
+ expiresAt?: Date | null;
1011
+ metadata?: Record<string, unknown>;
1012
+ updatedBySubjectId: string;
1013
+ };
1014
+ type RotateWorkspaceProviderApiKeyConnectionInput = {
1015
+ accountId: string;
1016
+ workspaceId: string;
1017
+ connectionId: string;
1018
+ expectedVersion: number;
1019
+ operationId: string;
1020
+ requestDigest: string;
1021
+ credentialEncrypted: string;
1022
+ grantedScopes?: string[];
1023
+ expiresAt?: Date | null;
1024
+ metadata?: Record<string, unknown>;
1025
+ updatedBySubjectId: string;
1026
+ };
1027
+ type RevokeWorkspaceProviderApiKeyConnectionsInput = {
1028
+ accountId: string;
1029
+ workspaceId: string;
1030
+ connectionId: string;
1031
+ expectedVersion: number;
1032
+ updatedBySubjectId: string;
1033
+ };
1034
+ export type UpsertWorkspaceVercelAiGatewayConnectionInput = UpsertWorkspaceProviderApiKeyConnectionInput;
1035
+ export type RotateWorkspaceVercelAiGatewayConnectionInput = RotateWorkspaceProviderApiKeyConnectionInput;
1036
+ export type RevokeWorkspaceVercelAiGatewayConnectionsInput = RevokeWorkspaceProviderApiKeyConnectionsInput;
1037
+ export type UpsertWorkspaceOpenRouterConnectionInput = UpsertWorkspaceProviderApiKeyConnectionInput;
1038
+ export type RotateWorkspaceOpenRouterConnectionInput = RotateWorkspaceProviderApiKeyConnectionInput;
1039
+ export type RevokeWorkspaceOpenRouterConnectionsInput = RevokeWorkspaceProviderApiKeyConnectionsInput;
995
1040
  export type UpdateConnectionInput = {
996
1041
  workspaceId: string;
997
1042
  connectionId: string;
@@ -1335,6 +1380,7 @@ export type InstallPortableSkillInput = {
1335
1380
  sourcePath: string;
1336
1381
  name: string;
1337
1382
  description: string;
1383
+ activationMode?: "workspace_managed" | "session_selected";
1338
1384
  category?: string;
1339
1385
  tags?: string[];
1340
1386
  provenance?: "platform" | "deployment" | "registry" | "workspace";
@@ -1373,6 +1419,7 @@ export type PortableSkillRuntime = {
1373
1419
  version: string;
1374
1420
  name: string;
1375
1421
  description: string;
1422
+ activationMode: "workspace_managed" | "session_selected";
1376
1423
  sourceUrl: string;
1377
1424
  sourceCommit: string;
1378
1425
  sourcePath: string;
@@ -1848,8 +1895,14 @@ export declare function getCapabilityCatalogItem(db: Database, workspaceId: stri
1848
1895
  * immutable history.
1849
1896
  */
1850
1897
  export declare function installPortableSkill(db: Database, input: InstallPortableSkillInput): Promise<InstalledPortableSkill>;
1851
- /** Return exact text artifacts for active authoritative Skill installations. */
1852
- export declare function listInstalledPortableSkills(db: Database, workspaceId: string): Promise<PortableSkillRuntime[]>;
1898
+ /**
1899
+ * Return exact text artifacts for active authoritative Skill installations.
1900
+ * Session-selected Skills are excluded from ambient runtime resolution unless
1901
+ * the caller is explicitly materializing one during session admission.
1902
+ */
1903
+ export declare function listInstalledPortableSkills(db: Database, workspaceId: string, options?: {
1904
+ includeSessionSelected?: boolean;
1905
+ }): Promise<PortableSkillRuntime[]>;
1853
1906
  /** Return secret-free lifecycle summaries from the authoritative Skill ledger. */
1854
1907
  export declare function listInstalledSkills(db: Database, workspaceId: string): Promise<InstalledSkillSummary[]>;
1855
1908
  export declare function getPortableSkillUninstallPreview(db: Database, workspaceId: string, capabilityId: string): Promise<PortableSkillUninstallPreview>;
@@ -1886,6 +1939,15 @@ export declare function decryptedCapabilityHeaders(server: EnabledMcpCapabilityS
1886
1939
  export declare function getStoredCapabilityHeaderCiphertext(db: Database, workspaceId: string, capabilityId: string): Promise<Record<string, string> | null>;
1887
1940
  export declare function mcpServerIdForCapability(capabilityId: string, metadata?: Record<string, unknown>): string;
1888
1941
  export declare function createConnection(db: Database, input: CreateConnectionInput): Promise<ConnectionMetadataWithVerification>;
1942
+ /** Compatibility wrapper for the existing Vercel AI Gateway create/replay contract. */
1943
+ export declare function upsertWorkspaceVercelAiGatewayConnection(db: Database, input: UpsertWorkspaceVercelAiGatewayConnectionInput): Promise<ConnectionMetadataWithVerification | null>;
1944
+ export declare function upsertWorkspaceOpenRouterConnection(db: Database, input: UpsertWorkspaceOpenRouterConnectionInput): Promise<ConnectionMetadataWithVerification | null>;
1945
+ /** Compatibility wrapper for the existing Vercel AI Gateway rotation contract. */
1946
+ export declare function rotateWorkspaceVercelAiGatewayConnection(db: Database, input: RotateWorkspaceVercelAiGatewayConnectionInput): Promise<ConnectionMetadataWithVerification | null>;
1947
+ export declare function rotateWorkspaceOpenRouterConnection(db: Database, input: RotateWorkspaceOpenRouterConnectionInput): Promise<ConnectionMetadataWithVerification | null>;
1948
+ /** Compatibility wrapper for the existing Vercel AI Gateway revoke contract. */
1949
+ export declare function revokeWorkspaceVercelAiGatewayConnections(db: Database, input: RevokeWorkspaceVercelAiGatewayConnectionsInput): Promise<ConnectionMetadataWithVerification | null>;
1950
+ export declare function revokeWorkspaceOpenRouterConnections(db: Database, input: RevokeWorkspaceOpenRouterConnectionsInput): Promise<ConnectionMetadataWithVerification | null>;
1889
1951
  /**
1890
1952
  * Serialize one provider-principal/owner connection generation. Distinct OAuth
1891
1953
  * starts for the same principal converge on one row, while an explicit
@@ -2517,14 +2579,21 @@ export declare function loadConnectionCredentialForBroker(db: Database, settings
2517
2579
  allowSubjectOwned?: boolean;
2518
2580
  expectedAuthorityGeneration?: number;
2519
2581
  }): Promise<ConnectionCredentialForBroker | null>;
2520
- export declare function workspaceVercelAiGatewayConnectionActive(db: Database, workspaceId: string): Promise<boolean>;
2521
2582
  /** Metadata-only capability revision input; never selects/decrypts the API key. */
2522
2583
  export declare function getWorkspaceVercelAiGatewayConnectionMetadata(db: Database, workspaceId: string): Promise<{
2523
2584
  connectionId: string;
2524
2585
  version: number;
2525
2586
  } | null>;
2587
+ export declare function getWorkspaceOpenRouterConnectionMetadata(db: Database, workspaceId: string): Promise<{
2588
+ connectionId: string;
2589
+ version: number;
2590
+ } | null>;
2591
+ export declare function workspaceVercelAiGatewayConnectionActive(db: Database, workspaceId: string): Promise<boolean>;
2592
+ export declare function workspaceOpenRouterConnectionActive(db: Database, workspaceId: string): Promise<boolean>;
2526
2593
  /** Resolve only the reviewed workspace-shared AI Gateway credential shape. */
2527
2594
  export declare function loadWorkspaceVercelAiGatewayApiKey(db: Database, settings: Settings, workspaceId: string): Promise<string | null>;
2595
+ /** Resolve only the reviewed workspace-shared OpenRouter credential shape. */
2596
+ export declare function loadWorkspaceOpenRouterApiKey(db: Database, settings: Settings, workspaceId: string): Promise<string | null>;
2528
2597
  /**
2529
2598
  * Worker-only immutable credential lease for an asynchronous video operation.
2530
2599
  * The operation copies the already-encrypted credential envelope before its
@@ -2753,6 +2822,11 @@ export declare function createScheduledTaskRun(db: Database, input: {
2753
2822
  scheduledAt?: Date | null;
2754
2823
  firedAt?: Date;
2755
2824
  acceptedExecutionSnapshot?: ScheduledTaskRunAcceptedExecutionType | null;
2825
+ /**
2826
+ * Trusted database-only admission seam for a fresh agent occurrence.
2827
+ * Throwing rolls back the run insert; exact producer replay skips it.
2828
+ */
2829
+ beforeFreshAgentRunCommit?: (tx: Database) => Promise<void>;
2756
2830
  }): Promise<ScheduledTaskRun>;
2757
2831
  export declare function getScheduledTaskRunAcceptedExecution(db: Database, input: {
2758
2832
  workspaceId: string;
@@ -3614,6 +3688,8 @@ export declare function setWorkspaceCodexSubscriptionModeInTransaction(scopedDb:
3614
3688
  workspaceId: string;
3615
3689
  subjectId: string | null;
3616
3690
  mode: WorkspaceCodexSubscriptionMode;
3691
+ /** Effective source captured under the source lock before caller-owned credential writes. */
3692
+ effectiveSourceBeforeMutation?: EffectiveCodexSubscriptionSource;
3617
3693
  }): Promise<WorkspaceCodexSubscriptionSource>;
3618
3694
  export declare function setWorkspaceCodexSubscriptionMode(db: Database, input: {
3619
3695
  accountId: string;
@@ -4839,6 +4915,8 @@ export type SessionCreateInput = {
4839
4915
  policyRole?: string | null;
4840
4916
  parentSessionId?: string | null;
4841
4917
  createIdempotencyKey?: string | null;
4918
+ /** Exact explicit installed-Skill selection used for keyed-create replay. */
4919
+ selectedInstalledSkillIds?: string[];
4842
4920
  sandboxGroupId?: string | null;
4843
4921
  sandboxOs?: SandboxOs;
4844
4922
  /** Exact accepted generated-session compaction policy; internal lifecycle callers only. */
@@ -4858,7 +4936,9 @@ export type SessionCreateInput = {
4858
4936
  /** Trusted, transaction-local linkage run after the exact session row and
4859
4937
  * MCP metadata exist but before either can commit. It must perform database
4860
4938
  * work only; throwing rolls the complete create/replay transaction back. */
4861
- beforeCreateCommit?: (tx: Database, sessionId: string) => Promise<void>;
4939
+ beforeCreateCommit?: (tx: Database, sessionId: string, context?: {
4940
+ created: boolean;
4941
+ }) => Promise<void>;
4862
4942
  };
4863
4943
  export declare function createSession(db: Database, input: SessionCreateInput): Promise<DbSession>;
4864
4944
  /**
@@ -4883,6 +4963,43 @@ export declare function createSessionWithIdempotencyKey(db: Database, input: Ses
4883
4963
  createIdempotencyKey: string;
4884
4964
  }): Promise<SessionCreateSuccessResult>;
4885
4965
  export declare function getSessionByCreateIdempotencyKey(db: Database, workspaceId: string, createIdempotencyKey: string): Promise<Session | null>;
4966
+ /**
4967
+ * Recover a keyed create before mutable create dependencies (notably the
4968
+ * current model catalog) are consulted. A fully initialized queued turn gets a
4969
+ * fresh durable wake revision from persisted state only; an uninitialized shell
4970
+ * returns its persisted model so the caller can reopen it strictly as retained
4971
+ * while the canonical keyed transaction repairs initialization. The same
4972
+ * request-identity checks as transactional create replay run before any session
4973
+ * or committed denial is returned.
4974
+ */
4975
+ export type InitializedSessionCreateReplay = {
4976
+ outcome: "session";
4977
+ session: Session & {
4978
+ initialTurnId: string | null;
4979
+ };
4980
+ temporalWorkflowId: string;
4981
+ workflowWakeRevision: number | null;
4982
+ changed: boolean;
4983
+ } | {
4984
+ outcome: "pending";
4985
+ session: Session;
4986
+ } | {
4987
+ outcome: "denied";
4988
+ denial: SessionSpawnDenial;
4989
+ };
4990
+ export declare function getInitializedSessionCreateReplay(db: Database, input: {
4991
+ accountId: string;
4992
+ workspaceId: string;
4993
+ subjectId: string;
4994
+ activeManagedHumanSubjectId?: string;
4995
+ createIdempotencyKey: string;
4996
+ requestedSessionId?: string;
4997
+ visibility?: "user_private" | "workspace_shared";
4998
+ variableSetIds: string[];
4999
+ selectedInstalledSkillIds: string[];
5000
+ initialPersonalResourceAttachmentIntent?: PersonalResourceAttachmentIntent | null;
5001
+ deferInitialTurn?: boolean;
5002
+ }): Promise<InitializedSessionCreateReplay | null>;
4886
5003
  export declare function getSession(db: Database, workspaceId: string, sessionId: string): Promise<Session | null>;
4887
5004
  export type DeleteSessionTreeIfQuiescentResult = {
4888
5005
  status: "deleted";
@@ -5324,6 +5441,8 @@ export type SessionEventPage = {
5324
5441
  events: SessionEvent[];
5325
5442
  hasMore: boolean;
5326
5443
  bytes: number;
5444
+ /** True only when every full-mode event is the exact retained database row. */
5445
+ fullPayloadsExact: boolean;
5327
5446
  direction: SessionEventReadDirection;
5328
5447
  coveredSequence: {
5329
5448
  first: number;
@@ -5336,10 +5455,12 @@ export type SessionEventPage = {
5336
5455
  export declare const SESSION_EVENT_DB_PAGE_MAX_BYTES: number;
5337
5456
  /**
5338
5457
  * Read one direction-aware session-event page. Full mode selects the canonical
5339
- * row exactly; summary/none modes derive bounded monitoring projections in SQL
5340
- * without rewriting the retained source. `bytes` is the exact UTF-8 size of
5341
- * `JSON.stringify(events)`; `hasMore` is true whenever count or byte selection
5342
- * stopped before the durable range ended.
5458
+ * row exactly when it fits the page; an oversized historical row that predates
5459
+ * the durable write guard is projected at the bounded database-read boundary
5460
+ * when it would otherwise strand its cursor forever. Summary/none modes derive
5461
+ * bounded monitoring projections in SQL without rewriting the retained source.
5462
+ * `bytes` is the exact UTF-8 size of `JSON.stringify(events)`; `hasMore` is true
5463
+ * whenever count or byte selection stopped before the durable range ended.
5343
5464
  */
5344
5465
  export declare function listSessionEventPage(db: Database, workspaceId: string, sessionId: string, options?: ListSessionEventPageOptions): Promise<SessionEventPage>;
5345
5466
  export declare function listSessionEvents(db: Database, workspaceId: string, sessionId: string): Promise<SessionEvent[]>;
@@ -6208,6 +6329,9 @@ export type AcquireLeaseResult = {
6208
6329
  role: "fenced";
6209
6330
  reason: "superseded" | "capture_in_progress" | "rotation_in_progress" | "provider_recovery_in_progress";
6210
6331
  lease: LeaseSnapshot;
6332
+ /** Remaining durable capture budget from PostgreSQL's clock. Present only
6333
+ * for an exact active capture; callers cap it at the lifecycle ceiling. */
6334
+ captureRemainingMs?: number;
6211
6335
  };
6212
6336
  export type SandboxSharedPreparationSnapshot = {
6213
6337
  status: "running" | "completed" | "failed";
@@ -6965,6 +7089,16 @@ export declare function listSandboxViewerForceDrainWorkspaceIds(db: Database): P
6965
7089
  export declare function countQueuedTurns(db: Database): Promise<number>;
6966
7090
  export type SessionRecoveryBacklogState = "quiescence_missing" | "projection_stale";
6967
7091
  export declare function countSessionRecoveryBacklog(db: Database): Promise<Record<SessionRecoveryBacklogState, number>>;
7092
+ export type ContextCompactionPendingSummary = {
7093
+ pendingCount: number;
7094
+ oldestStartedAt: Date | null;
7095
+ };
7096
+ /**
7097
+ * Content-free cross-workspace projection of exact active attempts whose latest
7098
+ * automatic compaction landmark is still `started`. The trigger-maintained
7099
+ * private ledger survives turn-worker loss without exposing tenant identities.
7100
+ */
7101
+ export declare function getContextCompactionPendingSummary(db: Database): Promise<ContextCompactionPendingSummary>;
6968
7102
  export declare function countSandboxLeasesByLiveness(db: Database): Promise<Record<SandboxLeaseLiveness, number>>;
6969
7103
  export type CreditBalanceByAccount = {
6970
7104
  accountId: string;
@@ -6997,8 +7131,14 @@ export declare function confirmDrainCold(db: Database, input: {
6997
7131
  }>;
6998
7132
  export declare class SandboxWorkspaceMutationFencedError extends Error {
6999
7133
  readonly code: "attempt_fenced" | "holder_fenced" | "lease_fenced" | "rotation_in_progress" | "route_fenced" | "process_fenced" | "capture_in_progress" | "admission_fenced" | "operation_invalid" | "generation_exhausted" | "authority_unattributed" | "authority_revoked";
7134
+ /** Remaining exact archive-capture budget projected by PostgreSQL. This is
7135
+ * observational wait input only; it never licenses capture takeover. */
7136
+ readonly captureRemainingMs: number | null;
7000
7137
  readonly name: string;
7001
- constructor(code: "attempt_fenced" | "holder_fenced" | "lease_fenced" | "rotation_in_progress" | "route_fenced" | "process_fenced" | "capture_in_progress" | "admission_fenced" | "operation_invalid" | "generation_exhausted" | "authority_unattributed" | "authority_revoked", message: string);
7138
+ constructor(code: "attempt_fenced" | "holder_fenced" | "lease_fenced" | "rotation_in_progress" | "route_fenced" | "process_fenced" | "capture_in_progress" | "admission_fenced" | "operation_invalid" | "generation_exhausted" | "authority_unattributed" | "authority_revoked", message: string,
7139
+ /** Remaining exact archive-capture budget projected by PostgreSQL. This is
7140
+ * observational wait input only; it never licenses capture takeover. */
7141
+ captureRemainingMs?: number | null);
7002
7142
  }
7003
7143
  /** An operation named a durable retained process that has already reached a
7004
7144
  * terminal state. This remains a fence—the provider must not be called again
@@ -7586,6 +7726,7 @@ export type SandboxRotationBacklog = {
7586
7726
  turnBlocked: number;
7587
7727
  directBlocked: number;
7588
7728
  processBlocked: number;
7729
+ interactionBlocked: number;
7589
7730
  };
7590
7731
  export declare function readSandboxRotationBacklog(db: Database): Promise<SandboxRotationBacklog>;
7591
7732
  export type LegacyModalCheckpointSlot = {
@@ -8944,6 +9085,7 @@ export declare function materializeGoalContinuation(db: Database, input: {
8944
9085
  model: string;
8945
9086
  reasoningEffort: ReasoningEffort;
8946
9087
  latencyMode: LatencyMode;
9088
+ turnExecutionPolicy?: TurnExecutionPolicyV1;
8947
9089
  tools: ToolRef[];
8948
9090
  sandboxBackend: SandboxBackend;
8949
9091
  };
@@ -9654,10 +9796,13 @@ export type AddSessionSystemUpdateInput = {
9654
9796
  xaiProviderAccountAuthoritySnapshot?: XaiProviderAccountAuthoritySnapshotV1;
9655
9797
  scheduledTaskRunId?: string | null;
9656
9798
  } & SessionSystemUpdateInputVariant;
9657
- export type AddSessionSystemUpdateResult = {
9799
+ export type AddSessionSystemUpdateResult<RequireIdleSession extends boolean = boolean> = {
9658
9800
  added: false;
9659
9801
  reason: "session_cancelled";
9660
- } | {
9802
+ } | (RequireIdleSession extends true ? {
9803
+ added: false;
9804
+ reason: "session_not_idle";
9805
+ } : never) | {
9661
9806
  added: boolean;
9662
9807
  reason: "added" | "duplicate";
9663
9808
  update: SessionSystemUpdate;
@@ -9670,16 +9815,20 @@ export type AddSessionSystemUpdateResult = {
9670
9815
  export type PrepareSessionSystemUpdateSourceResult = {
9671
9816
  /** Private, bounded, content-free source authority appended before insert. */
9672
9817
  lineage?: Record<string, unknown>;
9818
+ /** Source-owned events appended before the pending-update event. */
9819
+ events?: SessionEvent[];
9673
9820
  };
9674
- export declare function addSessionSystemUpdate(db: Database, input: AddSessionSystemUpdateInput): Promise<AddSessionSystemUpdateResult>;
9821
+ export declare function addSessionSystemUpdate(db: Database, input: AddSessionSystemUpdateInput): Promise<AddSessionSystemUpdateResult<false>>;
9675
9822
  /**
9676
9823
  * Persist one internal update without fabricating a user prompt or queue row.
9677
9824
  * Dedupe and any producer/outbox mutation commit in the same transaction.
9678
9825
  */
9679
- export declare function addSessionSystemUpdateWithSourceMutation(db: Database, input: AddSessionSystemUpdateInput, mutateSource: (tx: Database, wakeEventId: string | null, updateId: string | null) => Promise<void>, options?: {
9826
+ export declare function addSessionSystemUpdateWithSourceMutation<RequireIdleSession extends boolean = false>(db: Database, input: AddSessionSystemUpdateInput, mutateSource: (tx: Database, wakeEventId: string | null, updateId: string | null, rejectionReason: "session_cancelled" | "session_not_idle" | null) => Promise<void>, options?: {
9827
+ /** Admit only when the already-locked session is at its idle boundary. */
9828
+ requireIdleSession?: RequireIdleSession;
9680
9829
  /** Runs under the locked session/source transaction before any update/event insert. */
9681
9830
  prepareSource?: (tx: Database, sessionId: string) => Promise<PrepareSessionSystemUpdateSourceResult | void>;
9682
- }): Promise<AddSessionSystemUpdateResult>;
9831
+ }): Promise<AddSessionSystemUpdateResult<RequireIdleSession>>;
9683
9832
  /**
9684
9833
  * One durable machine input by id, under the ordinary workspace RLS scope.
9685
9834
  * The row outlives delivery, so a late bounded projection of an already
@@ -9899,3 +10048,4 @@ export * from "./organization-recovery.js";
9899
10048
  export * from "./session-tenancy.js";
9900
10049
  export * from "./governed-learning-activation.js";
9901
10050
  export * from "./automations.js";
10051
+ export * from "./organization-model-providers.js";