@opengeni/db 0.36.1 → 1.0.1

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 (47) hide show
  1. package/dist/canonical-human-identities.js +3 -3
  2. package/dist/{chunk-HSOWSYOX.js → chunk-4SR4HKKA.js} +2 -2
  3. package/dist/{chunk-5KTIEDX7.js → chunk-6ZYKCRFO.js} +124 -16
  4. package/dist/chunk-6ZYKCRFO.js.map +1 -0
  5. package/dist/{chunk-VTPRIXKG.js → chunk-CUPM3FGB.js} +3 -3
  6. package/dist/{chunk-GYO7ED2Q.js → chunk-LTG3S6ZY.js} +2 -2
  7. package/dist/{chunk-VKLB2ZGI.js → chunk-NXAFLCQX.js} +81 -2
  8. package/dist/chunk-NXAFLCQX.js.map +1 -0
  9. package/dist/{chunk-FPVAD4CO.js → chunk-WD5ROSLL.js} +2 -2
  10. package/dist/{chunk-Z7VYMNPZ.js → chunk-ZWREYEWA.js} +2 -2
  11. package/dist/editable-artifact-durable-export.d.ts +10 -0
  12. package/dist/editable-artifact-durable-export.js +18 -3
  13. package/dist/editable-artifact-durable-export.js.map +1 -1
  14. package/dist/editable-artifacts.js +3 -3
  15. package/dist/index.d.ts +40 -8
  16. package/dist/index.js +509 -59
  17. package/dist/index.js.map +1 -1
  18. package/dist/knowledge-source-sync-schema.d.ts +730 -0
  19. package/dist/knowledge-source-sync.d.ts +60 -0
  20. package/dist/provision-roles.js +1 -1
  21. package/dist/runtime-posture.d.ts +3 -3
  22. package/dist/schema.d.ts +21 -4
  23. package/dist/schema.js +5 -1
  24. package/dist/session-queue-commands.d.ts +1 -1
  25. package/dist/session-realtime-ledger.d.ts +1 -0
  26. package/dist/session-tenancy.js +3 -3
  27. package/dist/video-generation.js +3 -3
  28. package/drizzle/0240_model_context_user_messages.sql +204 -0
  29. package/drizzle/0243_google_drive_object_acl_authority.sql +554 -0
  30. package/package.json +4 -4
  31. package/src/editable-artifact-durable-export.ts +27 -0
  32. package/src/index.ts +212 -13
  33. package/src/knowledge-source-sync-schema.ts +83 -0
  34. package/src/knowledge-source-sync.ts +530 -0
  35. package/src/provision-roles.ts +36 -0
  36. package/src/runtime-posture.ts +49 -1
  37. package/src/schema.ts +30 -7
  38. package/src/session-queue-commands.ts +13 -14
  39. package/src/session-realtime-context.ts +16 -0
  40. package/src/session-realtime-ledger.ts +53 -1
  41. package/dist/chunk-5KTIEDX7.js.map +0 -1
  42. package/dist/chunk-VKLB2ZGI.js.map +0 -1
  43. /package/dist/{chunk-HSOWSYOX.js.map → chunk-4SR4HKKA.js.map} +0 -0
  44. /package/dist/{chunk-VTPRIXKG.js.map → chunk-CUPM3FGB.js.map} +0 -0
  45. /package/dist/{chunk-GYO7ED2Q.js.map → chunk-LTG3S6ZY.js.map} +0 -0
  46. /package/dist/{chunk-FPVAD4CO.js.map → chunk-WD5ROSLL.js.map} +0 -0
  47. /package/dist/{chunk-Z7VYMNPZ.js.map → chunk-ZWREYEWA.js.map} +0 -0
@@ -9,9 +9,9 @@ import {
9
9
  getCanonicalHumanIdentityProjection,
10
10
  synchronizeCanonicalHumanLoginBindings,
11
11
  validateCanonicalHumanSession
12
- } from "./chunk-GYO7ED2Q.js";
13
- import "./chunk-Z7VYMNPZ.js";
14
- import "./chunk-5KTIEDX7.js";
12
+ } from "./chunk-LTG3S6ZY.js";
13
+ import "./chunk-ZWREYEWA.js";
14
+ import "./chunk-6ZYKCRFO.js";
15
15
  import "./chunk-PZ5AY32C.js";
16
16
  export {
17
17
  CanonicalHumanIdentityAuthorityError,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  rawRows,
3
3
  withRlsContext
4
- } from "./chunk-Z7VYMNPZ.js";
4
+ } from "./chunk-ZWREYEWA.js";
5
5
 
6
6
  // src/editable-artifacts.ts
7
7
  import { createHash } from "crypto";
@@ -3532,4 +3532,4 @@ export {
3532
3532
  PostgresEditableArtifactStore,
3533
3533
  PostgresEditableArtifactLiveReadStore
3534
3534
  };
3535
- //# sourceMappingURL=chunk-HSOWSYOX.js.map
3535
+ //# sourceMappingURL=chunk-4SR4HKKA.js.map
@@ -82,6 +82,8 @@ __export(schema_exports, {
82
82
  generatedVideoArtifacts: () => generatedVideoArtifacts,
83
83
  githubInstallationRepositories: () => githubInstallationRepositories,
84
84
  githubInstallations: () => githubInstallations,
85
+ googleDriveObjectAclEvidence: () => googleDriveObjectAclEvidence,
86
+ googleDriveObjectAclPrincipals: () => googleDriveObjectAclPrincipals,
85
87
  hostExportConfig: () => hostExportConfig,
86
88
  hostExportConsumers: () => hostExportConsumers,
87
89
  hostExportCursorState: () => hostExportCursorState,
@@ -275,7 +277,7 @@ import {
275
277
  jsonb as jsonb12,
276
278
  numeric,
277
279
  pgTable as pgTable13,
278
- primaryKey as primaryKey4,
280
+ primaryKey as primaryKey5,
279
281
  text as text13,
280
282
  timestamp as timestamp13,
281
283
  unique,
@@ -3046,6 +3048,7 @@ import {
3046
3048
  integer as integer10,
3047
3049
  jsonb as jsonb9,
3048
3050
  pgTable as pgTable10,
3051
+ primaryKey as primaryKey2,
3049
3052
  text as text10,
3050
3053
  timestamp as timestamp10,
3051
3054
  uniqueIndex as uniqueIndex10,
@@ -3207,6 +3210,7 @@ var knowledgeSourceSyncIndexObligations = pgTable10(
3207
3210
  objectLifecycleGeneration: bigint8("object_lifecycle_generation", { mode: "number" }).notNull(),
3208
3211
  objectVersionGeneration: bigint8("object_version_generation", { mode: "number" }).notNull(),
3209
3212
  citationLocator: jsonb9("citation_locator").$type().notNull(),
3213
+ googleDriveAclEvidenceId: uuid10("google_drive_acl_evidence_id"),
3210
3214
  aclEligibility: text10("acl_eligibility").notNull().default("pending"),
3211
3215
  status: text10("status").notNull().default("pending"),
3212
3216
  failureCode: text10("failure_code"),
@@ -3224,6 +3228,85 @@ var knowledgeSourceSyncIndexObligations = pgTable10(
3224
3228
  )
3225
3229
  })
3226
3230
  );
3231
+ var googleDriveObjectAclEvidence = pgTable10(
3232
+ "google_drive_object_acl_evidence",
3233
+ {
3234
+ id: uuid10("id").primaryKey().defaultRandom(),
3235
+ accountId: uuid10("account_id").notNull(),
3236
+ workspaceId: uuid10("workspace_id").notNull(),
3237
+ sourceId: uuid10("source_id").notNull(),
3238
+ knowledgeSourceObjectId: uuid10("knowledge_source_object_id").notNull(),
3239
+ knowledgeDocumentVersionId: uuid10("knowledge_document_version_id").notNull(),
3240
+ documentId: uuid10("document_id").notNull(),
3241
+ fileId: uuid10("file_id").notNull(),
3242
+ indexObligationId: uuid10("index_obligation_id").notNull(),
3243
+ connectionId: uuid10("connection_id").notNull(),
3244
+ connectionVersion: bigint8("connection_version", { mode: "number" }).notNull(),
3245
+ sourcePrincipalHash: text10("source_principal_hash").notNull(),
3246
+ sourceSyncGeneration: bigint8("source_sync_generation", { mode: "number" }).notNull(),
3247
+ sourceConfigGeneration: bigint8("source_config_generation", { mode: "number" }).notNull(),
3248
+ sourceLifecycleGeneration: bigint8("source_lifecycle_generation", { mode: "number" }).notNull(),
3249
+ objectLifecycleGeneration: bigint8("object_lifecycle_generation", {
3250
+ mode: "number"
3251
+ }).notNull(),
3252
+ objectVersionGeneration: bigint8("object_version_generation", { mode: "number" }).notNull(),
3253
+ providerRevision: text10("provider_revision"),
3254
+ driveId: text10("drive_id"),
3255
+ aclRevision: text10("acl_revision").notNull(),
3256
+ aclHash: text10("acl_hash").notNull(),
3257
+ eligibility: text10("eligibility").notNull(),
3258
+ observedAt: timestamp10("observed_at", { withTimezone: true }).notNull(),
3259
+ expiresAt: timestamp10("expires_at", { withTimezone: true }).notNull(),
3260
+ citationLocator: jsonb9("citation_locator").$type().notNull(),
3261
+ operationId: text10("operation_id").notNull(),
3262
+ inputHash: text10("input_hash").notNull(),
3263
+ createdAt: timestamp10("created_at", { withTimezone: true }).notNull().defaultNow()
3264
+ },
3265
+ (table) => ({
3266
+ obligationOperation: uniqueIndex10("google_drive_object_acl_evidence_obligation_uq").on(
3267
+ table.indexObligationId,
3268
+ table.operationId
3269
+ ),
3270
+ version: index10("google_drive_object_acl_evidence_version_idx").on(
3271
+ table.knowledgeDocumentVersionId,
3272
+ table.expiresAt,
3273
+ table.createdAt
3274
+ ),
3275
+ file: index10("google_drive_object_acl_evidence_file_idx").on(
3276
+ table.accountId,
3277
+ table.fileId,
3278
+ table.expiresAt
3279
+ )
3280
+ })
3281
+ );
3282
+ var googleDriveObjectAclPrincipals = pgTable10(
3283
+ "google_drive_object_acl_principals",
3284
+ {
3285
+ evidenceId: uuid10("evidence_id").notNull(),
3286
+ ordinal: integer10("ordinal").notNull(),
3287
+ accountId: uuid10("account_id").notNull(),
3288
+ workspaceId: uuid10("workspace_id").notNull(),
3289
+ principalType: text10("principal_type").notNull(),
3290
+ permissionIdHash: text10("permission_id_hash"),
3291
+ emailHash: text10("email_hash"),
3292
+ domainHash: text10("domain_hash"),
3293
+ role: text10("role").notNull(),
3294
+ inherited: boolean4("inherited").notNull().default(false),
3295
+ allowFileDiscovery: boolean4("allow_file_discovery"),
3296
+ expirationTime: timestamp10("expiration_time", { withTimezone: true }),
3297
+ createdAt: timestamp10("created_at", { withTimezone: true }).notNull().defaultNow()
3298
+ },
3299
+ (table) => ({
3300
+ identity: primaryKey2({ columns: [table.evidenceId, table.ordinal] }),
3301
+ match: index10("google_drive_object_acl_principals_match_idx").on(
3302
+ table.evidenceId,
3303
+ table.principalType,
3304
+ table.permissionIdHash,
3305
+ table.emailHash,
3306
+ table.domainHash
3307
+ )
3308
+ })
3309
+ );
3227
3310
 
3228
3311
  // src/transcription-recordings-schema.ts
3229
3312
  import { sql as sql10 } from "drizzle-orm";
@@ -3234,7 +3317,7 @@ import {
3234
3317
  integer as integer11,
3235
3318
  jsonb as jsonb10,
3236
3319
  pgTable as pgTable11,
3237
- primaryKey as primaryKey2,
3320
+ primaryKey as primaryKey3,
3238
3321
  text as text11,
3239
3322
  timestamp as timestamp11,
3240
3323
  uniqueIndex as uniqueIndex11,
@@ -3378,7 +3461,7 @@ var transcriptionRecordingChunks = pgTable11(
3378
3461
  completedAt: timestamp11("completed_at", { withTimezone: true })
3379
3462
  },
3380
3463
  (table) => ({
3381
- pk: primaryKey2({
3464
+ pk: primaryKey3({
3382
3465
  name: "transcription_recording_chunks_pk",
3383
3466
  columns: [table.recordingId, table.chunkNumber]
3384
3467
  }),
@@ -3431,7 +3514,7 @@ var transcriptionRecordingSegments = pgTable11(
3431
3514
  updatedAt: timestamp11("updated_at", { withTimezone: true }).notNull().defaultNow()
3432
3515
  },
3433
3516
  (table) => ({
3434
- pk: primaryKey2({
3517
+ pk: primaryKey3({
3435
3518
  name: "transcription_recording_segments_pk",
3436
3519
  columns: [table.recordingId, table.segmentNumber]
3437
3520
  }),
@@ -3472,7 +3555,7 @@ import {
3472
3555
  integer as integer12,
3473
3556
  jsonb as jsonb11,
3474
3557
  pgTable as pgTable12,
3475
- primaryKey as primaryKey3,
3558
+ primaryKey as primaryKey4,
3476
3559
  text as text12,
3477
3560
  timestamp as timestamp12,
3478
3561
  uniqueIndex as uniqueIndex12,
@@ -3906,7 +3989,7 @@ var attachedBrowserDevices = pgTable12(
3906
3989
  updatedAt: timestamp12("updated_at", { withTimezone: true }).notNull().defaultNow()
3907
3990
  },
3908
3991
  (table) => ({
3909
- identity: primaryKey3({
3992
+ identity: primaryKey4({
3910
3993
  name: "attached_browser_devices_workspace_id_pk",
3911
3994
  columns: [table.workspaceId, table.id]
3912
3995
  }),
@@ -3957,7 +4040,7 @@ var attachedBrowserInventories = pgTable12(
3957
4040
  updatedAt: timestamp12("updated_at", { withTimezone: true }).notNull().defaultNow()
3958
4041
  },
3959
4042
  (table) => ({
3960
- identity: primaryKey3({
4043
+ identity: primaryKey4({
3961
4044
  name: "attached_browser_inventories_workspace_enrollment_pk",
3962
4045
  columns: [table.workspaceId, table.enrollmentId]
3963
4046
  }),
@@ -7000,10 +7083,10 @@ var sessions = pgTable13(
7000
7083
  status: text13("status").notNull().default("queued"),
7001
7084
  initialMessage: losslessText("initial_message").notNull(),
7002
7085
  initialMessageCodecVersion: losslessCodecVersion("initial_message_codec_version"),
7003
- // Invisible host context frozen with the winning session create. The
7004
- // initial turn copies this value so an idempotent repair can never adopt a
7005
- // retrying caller's different instructions.
7006
- initialTurnInstructions: text13("initial_turn_instructions"),
7086
+ // Model-visible application context frozen with the winning create. The
7087
+ // initial turn copies it into the canonical user message so an idempotent
7088
+ // repair cannot adopt a retrying caller's different message context.
7089
+ initialModelContext: text13("initial_model_context"),
7007
7090
  title: text13("title"),
7008
7091
  titleSource: text13("title_source"),
7009
7092
  // Per-session agent persona/system instructions supplied at create (the
@@ -7284,6 +7367,11 @@ var sessions = pgTable13(
7284
7367
  table.workspaceId,
7285
7368
  table.rootSessionId,
7286
7369
  table.nestedAgentDepth
7370
+ ),
7371
+ initialModelContextValid: check10(
7372
+ "sessions_initial_model_context_check",
7373
+ sql12`${table.initialModelContext} is null
7374
+ or opengeni_private.model_context_value_valid(${table.initialModelContext})`
7287
7375
  )
7288
7376
  })
7289
7377
  );
@@ -7618,6 +7706,9 @@ var sessionRealtimeEntries = pgTable13(
7618
7706
  textCodecVersion: losslessCodecVersion("text_codec_version"),
7619
7707
  payload: losslessJsonb("payload").$type().notNull().default({}),
7620
7708
  payloadCodecVersion: losslessCodecVersion("payload_codec_version"),
7709
+ // Application context for an exact provider-in delegation or finalized
7710
+ // transcript. It is materialized as ordinary user-role message content.
7711
+ modelContext: text13("model_context"),
7621
7712
  clientAckedAt: timestamp13("client_acked_at", { withTimezone: true }),
7622
7713
  providerAckedAt: timestamp13("provider_acked_at", { withTimezone: true }),
7623
7714
  createdAt: timestamp13("created_at", { withTimezone: true }).notNull().defaultNow(),
@@ -7682,6 +7773,15 @@ var sessionRealtimeEntries = pgTable13(
7682
7773
  sql12`(${table.kind} = 'user_transcript' and ${table.role} = 'user' and ${table.text} is not null)
7683
7774
  or (${table.kind} = 'assistant_transcript' and ${table.role} = 'assistant' and ${table.text} is not null)
7684
7775
  or (${table.kind} not in ('user_transcript', 'assistant_transcript') and ${table.role} is null)`
7776
+ ),
7777
+ modelContextValid: check10(
7778
+ "session_realtime_entries_model_context_check",
7779
+ sql12`${table.modelContext} is null
7780
+ or (
7781
+ ${table.direction} = 'provider_in'
7782
+ and ${table.kind} in ('delegation_call', 'user_transcript', 'assistant_transcript')
7783
+ and opengeni_private.model_context_value_valid(${table.modelContext})
7784
+ )`
7685
7785
  )
7686
7786
  })
7687
7787
  );
@@ -8291,7 +8391,7 @@ var videoGenerationReferences = pgTable13(
8291
8391
  createdAt: timestamp13("created_at", { withTimezone: true }).notNull().defaultNow()
8292
8392
  },
8293
8393
  (table) => ({
8294
- pk: primaryKey4({
8394
+ pk: primaryKey5({
8295
8395
  name: "video_generation_references_pk",
8296
8396
  columns: [table.operationId, table.ordinal]
8297
8397
  }),
@@ -8798,9 +8898,10 @@ var sessionTurns = pgTable13(
8798
8898
  prompt: losslessText("prompt").notNull(),
8799
8899
  promptCodecVersion: losslessCodecVersion("prompt_codec_version"),
8800
8900
  annotations: jsonb12("annotations").$type().notNull().default([]),
8801
- // Host context for this exact turn. System-level at runtime and deliberately
8802
- // separate from the visible prompt/event payload.
8803
- turnInstructions: text13("turn_instructions"),
8901
+ // Application context for this exact user message. It is copied into the
8902
+ // canonical user-role history item at claim and omitted from public queue
8903
+ // projections; full event/audit data retains it.
8904
+ modelContext: text13("model_context"),
8804
8905
  resources: jsonb12("resources").$type().notNull().default([]),
8805
8906
  tools: jsonb12("tools").$type().notNull().default([]),
8806
8907
  // false = inherit the durable session policy; true = this turn explicitly
@@ -8868,6 +8969,11 @@ var sessionTurns = pgTable13(
8868
8969
  latencyModeValid: check10(
8869
8970
  "session_turns_latency_mode_check",
8870
8971
  sql12`${table.latencyMode} in ('standard', 'priority', 'fast')`
8972
+ ),
8973
+ modelContextValid: check10(
8974
+ "session_turns_model_context_check",
8975
+ sql12`${table.modelContext} is null
8976
+ or opengeni_private.model_context_value_valid(${table.modelContext})`
8871
8977
  )
8872
8978
  })
8873
8979
  );
@@ -13001,6 +13107,8 @@ export {
13001
13107
  knowledgeSourceSyncItemOutcomes,
13002
13108
  knowledgeSourceSyncWakes,
13003
13109
  knowledgeSourceSyncIndexObligations,
13110
+ googleDriveObjectAclEvidence,
13111
+ googleDriveObjectAclPrincipals,
13004
13112
  transcriptionRecordingStateValues,
13005
13113
  transcriptionRecordingChunkStateValues,
13006
13114
  transcriptionRecordingObjectKindValues,
@@ -13197,4 +13305,4 @@ export {
13197
13305
  rigChanges,
13198
13306
  schema_exports
13199
13307
  };
13200
- //# sourceMappingURL=chunk-5KTIEDX7.js.map
13308
+ //# sourceMappingURL=chunk-6ZYKCRFO.js.map