@opengeni/db 3.7.4-canary.0 → 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 (62) hide show
  1. package/dist/canonical-human-identities.js +3 -3
  2. package/dist/{chunk-DXJ2WY6W.js → chunk-53A2PEHT.js} +241 -31
  3. package/dist/chunk-53A2PEHT.js.map +1 -0
  4. package/dist/{chunk-JS3AWDKZ.js → chunk-5S4BQAHX.js} +3 -3
  5. package/dist/{chunk-JP6IYGYI.js → chunk-CITYUGMW.js} +3 -3
  6. package/dist/{chunk-6FIVOJ3V.js → chunk-F5YOZEYQ.js} +45 -1
  7. package/dist/chunk-F5YOZEYQ.js.map +1 -0
  8. package/dist/{chunk-ZTSJPFDH.js → chunk-HZV7O6JR.js} +2 -2
  9. package/dist/{chunk-VDXHLVDE.js → chunk-RLQVPOVR.js} +2 -2
  10. package/dist/{chunk-LHKB62GC.js → chunk-UKOGHUGC.js} +2 -2
  11. package/dist/{chunk-QL4AHBYD.js → chunk-X6TO5HII.js} +2 -2
  12. package/dist/{chunk-3ZMN4EXC.js → chunk-Y53WEFYB.js} +2 -2
  13. package/dist/connection-token-resolver.d.ts +4 -0
  14. package/dist/editable-artifact-durable-export.js +2 -2
  15. package/dist/editable-artifacts.js +3 -3
  16. package/dist/index.d.ts +59 -12
  17. package/dist/index.js +5259 -4374
  18. package/dist/index.js.map +1 -1
  19. package/dist/insights.d.ts +9 -0
  20. package/dist/managed-auth-session-sets.js +3 -3
  21. package/dist/new-session-drafts.d.ts +12 -0
  22. package/dist/organization-membership-lifecycle.d.ts +8 -1
  23. package/dist/organization-model-providers.d.ts +101 -0
  24. package/dist/pack-components.d.ts +1 -0
  25. package/dist/provision-roles.js +1 -1
  26. package/dist/runtime-posture.d.ts +5 -5
  27. package/dist/schema.d.ts +645 -0
  28. package/dist/schema.js +7 -1
  29. package/dist/session-background-commands.js +3 -3
  30. package/dist/session-tenancy.js +3 -3
  31. package/dist/video-generation.js +3 -3
  32. package/drizzle/0390_organization_model_provider_connections.sql +197 -0
  33. package/drizzle/0391_sandbox_provider_deadline_interaction_followup.sql +295 -0
  34. package/drizzle/0392_context_compaction_pending_observability.sql +198 -0
  35. package/drizzle/0393_workspace_memory_and_learning_defaults.sql +102 -0
  36. package/drizzle/0394_session_selected_skill_activation.sql +20 -0
  37. package/drizzle/0395_scheduled_task_unclaimed_occurrence_invalidation.sql +154 -0
  38. package/drizzle/0396_model_call_equivalent_credit_cost.sql +28 -0
  39. package/drizzle/0397_sandbox_deadline_rotation_preemption.sql +113 -0
  40. package/drizzle/0398_organization_workspace_management_entry.sql +206 -0
  41. package/drizzle/0399_additional_managed_organization_creation.sql +691 -0
  42. package/package.json +6 -6
  43. package/src/connection-token-resolver.ts +12 -0
  44. package/src/index.ts +701 -155
  45. package/src/insights-model-bundle.ts +54 -5
  46. package/src/insights.ts +32 -0
  47. package/src/new-session-drafts.ts +66 -21
  48. package/src/organization-membership-lifecycle.ts +47 -5
  49. package/src/organization-model-providers.ts +614 -0
  50. package/src/pack-components.ts +15 -2
  51. package/src/provision-roles.ts +2 -0
  52. package/src/runtime-posture.ts +44 -0
  53. package/src/schema.ts +250 -30
  54. package/dist/chunk-6FIVOJ3V.js.map +0 -1
  55. package/dist/chunk-DXJ2WY6W.js.map +0 -1
  56. /package/dist/{chunk-JS3AWDKZ.js.map → chunk-5S4BQAHX.js.map} +0 -0
  57. /package/dist/{chunk-JP6IYGYI.js.map → chunk-CITYUGMW.js.map} +0 -0
  58. /package/dist/{chunk-ZTSJPFDH.js.map → chunk-HZV7O6JR.js.map} +0 -0
  59. /package/dist/{chunk-VDXHLVDE.js.map → chunk-RLQVPOVR.js.map} +0 -0
  60. /package/dist/{chunk-LHKB62GC.js.map → chunk-UKOGHUGC.js.map} +0 -0
  61. /package/dist/{chunk-QL4AHBYD.js.map → chunk-X6TO5HII.js.map} +0 -0
  62. /package/dist/{chunk-3ZMN4EXC.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-DXJ2WY6W.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-ZTSJPFDH.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-ZTSJPFDH.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-VDXHLVDE.js.map
484
+ //# sourceMappingURL=chunk-RLQVPOVR.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  nestedPostgresSqlState,
3
3
  rawRows
4
- } from "./chunk-ZTSJPFDH.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-LHKB62GC.js.map
299
+ //# sourceMappingURL=chunk-UKOGHUGC.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  rawRows,
3
3
  withRlsContext
4
- } from "./chunk-ZTSJPFDH.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-QL4AHBYD.js.map
3543
+ //# sourceMappingURL=chunk-X6TO5HII.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  nestedPostgresSqlState,
3
3
  rawRows
4
- } from "./chunk-ZTSJPFDH.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-3ZMN4EXC.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-ZTSJPFDH.js";
5
- import "./chunk-DXJ2WY6W.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-QL4AHBYD.js";
12
- import "./chunk-ZTSJPFDH.js";
13
- import "./chunk-DXJ2WY6W.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
@@ -537,6 +537,7 @@ export declare function deleteWorkspaceIfQuiescent(db: Database, input: {
537
537
  accountId: string;
538
538
  workspaceId: string;
539
539
  observer?: WorkspaceDeleteObserver;
540
+ organizationAdministratorSubjectId?: string;
540
541
  }): Promise<DeleteWorkspaceIfQuiescentResult>;
541
542
  /** Claim a bounded cross-workspace batch after abandoned claims expire. */
542
543
  export declare function claimTemporalScheduleCleanups(db: Database, input: {
@@ -719,6 +720,7 @@ export type ModelCallFact = {
719
720
  totalTokens: number | null;
720
721
  pricedCostMicros: number;
721
722
  estimatedProviderCostMicros: number | null;
723
+ equivalentCreditCostMicros: number | null;
722
724
  pricingSource: "configured_list_price" | "gateway_reported" | null;
723
725
  contextContributions: readonly ModelContextContributionSummary[] | null;
724
726
  occurredAt: Date;
@@ -741,6 +743,7 @@ export declare function recordModelCallFact(db: Database, input: {
741
743
  billingPath: ModelCallBillingPath;
742
744
  pricedCostMicros: number;
743
745
  estimatedProviderCostMicros?: number | null;
746
+ equivalentCreditCostMicros?: number | null;
744
747
  pricingSource?: "configured_list_price" | "gateway_reported" | null;
745
748
  contextContributions?: readonly ModelContextContributionSummary[] | null;
746
749
  inputTokens?: number | null;
@@ -1377,6 +1380,7 @@ export type InstallPortableSkillInput = {
1377
1380
  sourcePath: string;
1378
1381
  name: string;
1379
1382
  description: string;
1383
+ activationMode?: "workspace_managed" | "session_selected";
1380
1384
  category?: string;
1381
1385
  tags?: string[];
1382
1386
  provenance?: "platform" | "deployment" | "registry" | "workspace";
@@ -1415,6 +1419,7 @@ export type PortableSkillRuntime = {
1415
1419
  version: string;
1416
1420
  name: string;
1417
1421
  description: string;
1422
+ activationMode: "workspace_managed" | "session_selected";
1418
1423
  sourceUrl: string;
1419
1424
  sourceCommit: string;
1420
1425
  sourcePath: string;
@@ -1890,8 +1895,14 @@ export declare function getCapabilityCatalogItem(db: Database, workspaceId: stri
1890
1895
  * immutable history.
1891
1896
  */
1892
1897
  export declare function installPortableSkill(db: Database, input: InstallPortableSkillInput): Promise<InstalledPortableSkill>;
1893
- /** Return exact text artifacts for active authoritative Skill installations. */
1894
- 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[]>;
1895
1906
  /** Return secret-free lifecycle summaries from the authoritative Skill ledger. */
1896
1907
  export declare function listInstalledSkills(db: Database, workspaceId: string): Promise<InstalledSkillSummary[]>;
1897
1908
  export declare function getPortableSkillUninstallPreview(db: Database, workspaceId: string, capabilityId: string): Promise<PortableSkillUninstallPreview>;
@@ -3677,6 +3688,8 @@ export declare function setWorkspaceCodexSubscriptionModeInTransaction(scopedDb:
3677
3688
  workspaceId: string;
3678
3689
  subjectId: string | null;
3679
3690
  mode: WorkspaceCodexSubscriptionMode;
3691
+ /** Effective source captured under the source lock before caller-owned credential writes. */
3692
+ effectiveSourceBeforeMutation?: EffectiveCodexSubscriptionSource;
3680
3693
  }): Promise<WorkspaceCodexSubscriptionSource>;
3681
3694
  export declare function setWorkspaceCodexSubscriptionMode(db: Database, input: {
3682
3695
  accountId: string;
@@ -4902,6 +4915,8 @@ export type SessionCreateInput = {
4902
4915
  policyRole?: string | null;
4903
4916
  parentSessionId?: string | null;
4904
4917
  createIdempotencyKey?: string | null;
4918
+ /** Exact explicit installed-Skill selection used for keyed-create replay. */
4919
+ selectedInstalledSkillIds?: string[];
4905
4920
  sandboxGroupId?: string | null;
4906
4921
  sandboxOs?: SandboxOs;
4907
4922
  /** Exact accepted generated-session compaction policy; internal lifecycle callers only. */
@@ -4981,6 +4996,7 @@ export declare function getInitializedSessionCreateReplay(db: Database, input: {
4981
4996
  requestedSessionId?: string;
4982
4997
  visibility?: "user_private" | "workspace_shared";
4983
4998
  variableSetIds: string[];
4999
+ selectedInstalledSkillIds: string[];
4984
5000
  initialPersonalResourceAttachmentIntent?: PersonalResourceAttachmentIntent | null;
4985
5001
  deferInitialTurn?: boolean;
4986
5002
  }): Promise<InitializedSessionCreateReplay | null>;
@@ -5425,6 +5441,8 @@ export type SessionEventPage = {
5425
5441
  events: SessionEvent[];
5426
5442
  hasMore: boolean;
5427
5443
  bytes: number;
5444
+ /** True only when every full-mode event is the exact retained database row. */
5445
+ fullPayloadsExact: boolean;
5428
5446
  direction: SessionEventReadDirection;
5429
5447
  coveredSequence: {
5430
5448
  first: number;
@@ -5437,10 +5455,12 @@ export type SessionEventPage = {
5437
5455
  export declare const SESSION_EVENT_DB_PAGE_MAX_BYTES: number;
5438
5456
  /**
5439
5457
  * Read one direction-aware session-event page. Full mode selects the canonical
5440
- * row exactly; summary/none modes derive bounded monitoring projections in SQL
5441
- * without rewriting the retained source. `bytes` is the exact UTF-8 size of
5442
- * `JSON.stringify(events)`; `hasMore` is true whenever count or byte selection
5443
- * 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.
5444
5464
  */
5445
5465
  export declare function listSessionEventPage(db: Database, workspaceId: string, sessionId: string, options?: ListSessionEventPageOptions): Promise<SessionEventPage>;
5446
5466
  export declare function listSessionEvents(db: Database, workspaceId: string, sessionId: string): Promise<SessionEvent[]>;
@@ -6309,6 +6329,9 @@ export type AcquireLeaseResult = {
6309
6329
  role: "fenced";
6310
6330
  reason: "superseded" | "capture_in_progress" | "rotation_in_progress" | "provider_recovery_in_progress";
6311
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;
6312
6335
  };
6313
6336
  export type SandboxSharedPreparationSnapshot = {
6314
6337
  status: "running" | "completed" | "failed";
@@ -7066,6 +7089,16 @@ export declare function listSandboxViewerForceDrainWorkspaceIds(db: Database): P
7066
7089
  export declare function countQueuedTurns(db: Database): Promise<number>;
7067
7090
  export type SessionRecoveryBacklogState = "quiescence_missing" | "projection_stale";
7068
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>;
7069
7102
  export declare function countSandboxLeasesByLiveness(db: Database): Promise<Record<SandboxLeaseLiveness, number>>;
7070
7103
  export type CreditBalanceByAccount = {
7071
7104
  accountId: string;
@@ -7098,8 +7131,14 @@ export declare function confirmDrainCold(db: Database, input: {
7098
7131
  }>;
7099
7132
  export declare class SandboxWorkspaceMutationFencedError extends Error {
7100
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;
7101
7137
  readonly name: string;
7102
- 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);
7103
7142
  }
7104
7143
  /** An operation named a durable retained process that has already reached a
7105
7144
  * terminal state. This remains a fence—the provider must not be called again
@@ -9757,10 +9796,13 @@ export type AddSessionSystemUpdateInput = {
9757
9796
  xaiProviderAccountAuthoritySnapshot?: XaiProviderAccountAuthoritySnapshotV1;
9758
9797
  scheduledTaskRunId?: string | null;
9759
9798
  } & SessionSystemUpdateInputVariant;
9760
- export type AddSessionSystemUpdateResult = {
9799
+ export type AddSessionSystemUpdateResult<RequireIdleSession extends boolean = boolean> = {
9761
9800
  added: false;
9762
9801
  reason: "session_cancelled";
9763
- } | {
9802
+ } | (RequireIdleSession extends true ? {
9803
+ added: false;
9804
+ reason: "session_not_idle";
9805
+ } : never) | {
9764
9806
  added: boolean;
9765
9807
  reason: "added" | "duplicate";
9766
9808
  update: SessionSystemUpdate;
@@ -9773,16 +9815,20 @@ export type AddSessionSystemUpdateResult = {
9773
9815
  export type PrepareSessionSystemUpdateSourceResult = {
9774
9816
  /** Private, bounded, content-free source authority appended before insert. */
9775
9817
  lineage?: Record<string, unknown>;
9818
+ /** Source-owned events appended before the pending-update event. */
9819
+ events?: SessionEvent[];
9776
9820
  };
9777
- export declare function addSessionSystemUpdate(db: Database, input: AddSessionSystemUpdateInput): Promise<AddSessionSystemUpdateResult>;
9821
+ export declare function addSessionSystemUpdate(db: Database, input: AddSessionSystemUpdateInput): Promise<AddSessionSystemUpdateResult<false>>;
9778
9822
  /**
9779
9823
  * Persist one internal update without fabricating a user prompt or queue row.
9780
9824
  * Dedupe and any producer/outbox mutation commit in the same transaction.
9781
9825
  */
9782
- 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;
9783
9829
  /** Runs under the locked session/source transaction before any update/event insert. */
9784
9830
  prepareSource?: (tx: Database, sessionId: string) => Promise<PrepareSessionSystemUpdateSourceResult | void>;
9785
- }): Promise<AddSessionSystemUpdateResult>;
9831
+ }): Promise<AddSessionSystemUpdateResult<RequireIdleSession>>;
9786
9832
  /**
9787
9833
  * One durable machine input by id, under the ordinary workspace RLS scope.
9788
9834
  * The row outlives delivery, so a late bounded projection of an already
@@ -10002,3 +10048,4 @@ export * from "./organization-recovery.js";
10002
10048
  export * from "./session-tenancy.js";
10003
10049
  export * from "./governed-learning-activation.js";
10004
10050
  export * from "./automations.js";
10051
+ export * from "./organization-model-providers.js";