@opengeni/db 0.9.3 → 0.10.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-4LG5NBTC.js → chunk-P6PKXY5W.js} +93 -1
- package/dist/chunk-P6PKXY5W.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1332 -178
- package/dist/index.js.map +1 -1
- package/dist/provision-roles.d.ts +406 -32
- package/dist/{schema-CdPGTHlD.d.ts → schema-CqkzrBRS.d.ts} +513 -2
- package/dist/schema.d.ts +1 -1
- package/dist/schema.js +3 -1
- package/drizzle/0053_codex_credential_leases.sql +2 -2
- package/drizzle/0057_durable_queue_control.sql +1 -1
- package/drizzle/0061_session_workflow_wake_outbox.sql +1 -1
- package/drizzle/0062_session_list_snapshot_reaper.sql +1 -1
- package/drizzle/0063_session_control_mega_foundation.sql +1 -1
- package/drizzle/0064_rotation_strategy_sharded_backfill.sql +1 -1
- package/drizzle/0065_codex_subscription_overview.sql +168 -0
- package/drizzle/0065_session_tool_policy.sql +38 -0
- package/drizzle/0067_session_event_payload_bounds.sql +2 -2
- package/drizzle/0068_workspace_control_event_bounds.sql +2 -2
- package/drizzle/0069_session_event_history_backfill.sql +2 -2
- package/drizzle/0074_session_activity_revisions.sql +2 -2
- package/drizzle/0106_session_attempt_mcp_approval_policies.sql +29 -0
- package/drizzle/0107_host_export_lineage_contract.sql +381 -0
- package/drizzle/0108_fence_invalidated_warming_epochs.sql +76 -0
- package/package.json +5 -4
- package/src/codex-token-resolver.ts +175 -14
- package/src/connection-token-resolver.ts +143 -120
- package/src/event-payload-sanitizer.ts +32 -2
- package/src/index.ts +1888 -205
- package/src/schema.ts +107 -1
- package/src/session-control.ts +2 -0
- package/src/session-queue-commands.ts +94 -21
- package/dist/chunk-4LG5NBTC.js.map +0 -1
|
@@ -13,6 +13,7 @@ __export(schema_exports, {
|
|
|
13
13
|
capabilityInstallations: () => capabilityInstallations,
|
|
14
14
|
codexCapacityWaiters: () => codexCapacityWaiters,
|
|
15
15
|
codexCredentialLeases: () => codexCredentialLeases,
|
|
16
|
+
codexResetRedemptionAttempts: () => codexResetRedemptionAttempts,
|
|
16
17
|
codexRotationSettings: () => codexRotationSettings,
|
|
17
18
|
codexSubscriptionCredentials: () => codexSubscriptionCredentials,
|
|
18
19
|
composerDrafts: () => composerDrafts,
|
|
@@ -373,6 +374,19 @@ var codexSubscriptionCredentials = pgTable(
|
|
|
373
374
|
// refresh, encrypted material, and already-frozen/in-flight turns are
|
|
374
375
|
// intentionally independent. account eligibility policy owns toggle OCC/audit and product UI.
|
|
375
376
|
allocatorEnabled: boolean("allocator_enabled").notNull().default(true),
|
|
377
|
+
// Independent OCC/audit sequence for the allocator toggle. Token refresh
|
|
378
|
+
// continues to own `version`; quota/cache writes own neither counter.
|
|
379
|
+
allocatorVersion: integer("allocator_version").notNull().default(1),
|
|
380
|
+
allocatorUpdatedBySubjectId: text("allocator_updated_by_subject_id"),
|
|
381
|
+
allocatorUpdatedAt: timestamp("allocator_updated_at", { withTimezone: true }),
|
|
382
|
+
// Authoritative count-only summary cached from /wham/usage. Detailed rows
|
|
383
|
+
// are never persisted as redemption authority; every first POST preflights
|
|
384
|
+
// the provider's fresh detail endpoint.
|
|
385
|
+
resetCreditAvailableCount: integer("reset_credit_available_count"),
|
|
386
|
+
resetCreditsCheckedAt: timestamp("reset_credits_checked_at", { withTimezone: true }),
|
|
387
|
+
// Set only by a direct Better Auth cookie connection/reconnection. Legacy,
|
|
388
|
+
// configured, delegated, API-key, and agent-created rows remain view-only.
|
|
389
|
+
connectedBySubjectId: text("connected_by_subject_id"),
|
|
376
390
|
selectionCount: integer("selection_count").notNull().default(0),
|
|
377
391
|
lastSelectedAt: timestamp("last_selected_at", { withTimezone: true }),
|
|
378
392
|
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
@@ -393,6 +407,69 @@ var codexSubscriptionCredentials = pgTable(
|
|
|
393
407
|
)
|
|
394
408
|
})
|
|
395
409
|
);
|
|
410
|
+
var codexResetRedemptionAttempts = pgTable(
|
|
411
|
+
"codex_reset_redemption_attempts",
|
|
412
|
+
{
|
|
413
|
+
id: uuid("id").primaryKey(),
|
|
414
|
+
accountId: uuid("account_id").notNull().references(() => managedAccounts.id, { onDelete: "cascade" }),
|
|
415
|
+
workspaceId: uuid("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
|
|
416
|
+
credentialId: uuid("credential_id").notNull(),
|
|
417
|
+
subjectId: text("subject_id").notNull(),
|
|
418
|
+
browserSessionHash: text("browser_session_hash").notNull(),
|
|
419
|
+
creditId: text("credit_id").notNull(),
|
|
420
|
+
upstreamIdempotencyKey: uuid("upstream_idempotency_key").notNull().defaultRandom(),
|
|
421
|
+
status: text("status").notNull().default("processing"),
|
|
422
|
+
outcome: text("outcome"),
|
|
423
|
+
claimHolderId: uuid("claim_holder_id"),
|
|
424
|
+
claimExpiresAt: timestamp("claim_expires_at", { withTimezone: true }),
|
|
425
|
+
confirmationExpiresAt: timestamp("confirmation_expires_at", { withTimezone: true }).notNull(),
|
|
426
|
+
providerStartedAt: timestamp("provider_started_at", { withTimezone: true }),
|
|
427
|
+
completedAt: timestamp("completed_at", { withTimezone: true }),
|
|
428
|
+
lastFailureKind: text("last_failure_kind"),
|
|
429
|
+
retryCount: integer("retry_count").notNull().default(0),
|
|
430
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
431
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
432
|
+
},
|
|
433
|
+
(table) => ({
|
|
434
|
+
workspaceAccount: foreignKey({
|
|
435
|
+
name: "codex_reset_redemption_workspace_account_fk",
|
|
436
|
+
columns: [table.workspaceId, table.accountId],
|
|
437
|
+
foreignColumns: [workspaces.id, workspaces.accountId]
|
|
438
|
+
}).onDelete("cascade"),
|
|
439
|
+
upstreamKey: uniqueIndex("codex_reset_redemption_upstream_key_idx").on(
|
|
440
|
+
table.upstreamIdempotencyKey
|
|
441
|
+
),
|
|
442
|
+
credentialCredit: uniqueIndex("codex_reset_redemption_credential_credit_idx").on(table.workspaceId, table.credentialId, table.creditId).where(
|
|
443
|
+
sql`${table.status} <> 'completed' or ${table.outcome} in ('reset', 'alreadyRedeemed')`
|
|
444
|
+
),
|
|
445
|
+
workspaceCredential: index("codex_reset_redemption_workspace_credential_idx").on(
|
|
446
|
+
table.workspaceId,
|
|
447
|
+
table.credentialId,
|
|
448
|
+
table.createdAt
|
|
449
|
+
),
|
|
450
|
+
claimExpiry: index("codex_reset_redemption_claim_expiry_idx").on(table.claimExpiresAt).where(sql`${table.status} <> 'completed'`),
|
|
451
|
+
statusValid: check(
|
|
452
|
+
"codex_reset_redemption_status_check",
|
|
453
|
+
sql`${table.status} in ('processing', 'provider_started', 'completed')`
|
|
454
|
+
),
|
|
455
|
+
outcomeValid: check(
|
|
456
|
+
"codex_reset_redemption_outcome_check",
|
|
457
|
+
sql`${table.outcome} is null or ${table.outcome} in ('reset', 'nothingToReset', 'noCredit', 'alreadyRedeemed')`
|
|
458
|
+
),
|
|
459
|
+
completionConsistent: check(
|
|
460
|
+
"codex_reset_redemption_completed_check",
|
|
461
|
+
sql`(${table.status} = 'completed') = (${table.outcome} is not null and ${table.completedAt} is not null)`
|
|
462
|
+
),
|
|
463
|
+
retryCountValid: check(
|
|
464
|
+
"codex_reset_redemption_retry_count_check",
|
|
465
|
+
sql`${table.retryCount} >= 0`
|
|
466
|
+
),
|
|
467
|
+
humanSubjectValid: check(
|
|
468
|
+
"codex_reset_redemption_human_subject_check",
|
|
469
|
+
sql`${table.subjectId} like 'user:_%'`
|
|
470
|
+
)
|
|
471
|
+
})
|
|
472
|
+
);
|
|
396
473
|
var connections = pgTable(
|
|
397
474
|
"connections",
|
|
398
475
|
{
|
|
@@ -617,6 +694,10 @@ var sessions = pgTable(
|
|
|
617
694
|
// Non-default first-party MCP token permissions (manager-style sessions);
|
|
618
695
|
// null means the fixed worker default set in @opengeni/runtime.
|
|
619
696
|
firstPartyMcpPermissions: jsonb("first_party_mcp_permissions").$type(),
|
|
697
|
+
// Durable tool-policy origin. NULL is retained for pre-migration rows;
|
|
698
|
+
// mapSession exposes those rows as `legacy` instead of guessing omitted vs
|
|
699
|
+
// explicit [].
|
|
700
|
+
toolPolicy: jsonb("tool_policy").$type(),
|
|
620
701
|
// The manager session that spawned this one via session_create. Set only
|
|
621
702
|
// when the creating grant carried a worker-signed sessionId claim (a session
|
|
622
703
|
// spawning a worker); null for direct API creates and scheduled-task runs.
|
|
@@ -1051,6 +1132,9 @@ var sessionTurns = pgTable(
|
|
|
1051
1132
|
turnInstructions: text("turn_instructions"),
|
|
1052
1133
|
resources: jsonb("resources").$type().notNull().default([]),
|
|
1053
1134
|
tools: jsonb("tools").$type().notNull().default([]),
|
|
1135
|
+
// false = inherit the durable session policy; true = this turn explicitly
|
|
1136
|
+
// replaces it with `tools` after the core subset fence.
|
|
1137
|
+
toolsProvided: boolean("tools_provided").notNull().default(false),
|
|
1054
1138
|
model: text("model").notNull(),
|
|
1055
1139
|
reasoningEffort: text("reasoning_effort").notNull(),
|
|
1056
1140
|
sandboxBackend: text("sandbox_backend").notNull(),
|
|
@@ -1116,6 +1200,8 @@ var sessionTurnAttempts = pgTable(
|
|
|
1116
1200
|
verifiedControlRevision: bigint("verified_control_revision", {
|
|
1117
1201
|
mode: "number"
|
|
1118
1202
|
}).notNull(),
|
|
1203
|
+
// Immutable policy snapshot captured under the session lock at claim.
|
|
1204
|
+
mcpApprovalPolicies: jsonb("mcp_approval_policies").$type().notNull(),
|
|
1119
1205
|
startedAt: timestamp("started_at", { withTimezone: true }).notNull().defaultNow(),
|
|
1120
1206
|
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
1121
1207
|
closedAt: timestamp("closed_at", { withTimezone: true }),
|
|
@@ -1364,6 +1450,7 @@ var composerDrafts = pgTable(
|
|
|
1364
1450
|
text: text("text").notNull().default(""),
|
|
1365
1451
|
resources: jsonb("resources").$type().notNull().default([]),
|
|
1366
1452
|
tools: jsonb("tools").$type().notNull().default([]),
|
|
1453
|
+
toolsProvided: boolean("tools_provided").notNull().default(false),
|
|
1367
1454
|
model: text("model").notNull(),
|
|
1368
1455
|
reasoningEffort: text("reasoning_effort").notNull(),
|
|
1369
1456
|
sourceTurnId: uuid("source_turn_id"),
|
|
@@ -2535,6 +2622,10 @@ var hostExportOutbox = pgTable(
|
|
|
2535
2622
|
"host_export_outbox_kind_check",
|
|
2536
2623
|
sql`${table.exportKind} in ('session_event', 'usage_event')`
|
|
2537
2624
|
),
|
|
2625
|
+
rootSessionCaptured: check(
|
|
2626
|
+
"host_export_outbox_root_session_check",
|
|
2627
|
+
sql`${table.sessionId} is null or ${table.rootSessionId} is not null`
|
|
2628
|
+
),
|
|
2538
2629
|
sourceUnique: uniqueIndex("host_export_outbox_source_uq").on(table.exportKind, table.sourceId),
|
|
2539
2630
|
cursorUnique: uniqueIndex("host_export_outbox_cursor_uq").on(table.exportKind, table.exportCursor).where(sql`${table.exportCursor} is not null`),
|
|
2540
2631
|
unassigned: index("host_export_outbox_unassigned_idx").on(table.exportKind, table.enqueuedAt, table.id).where(sql`${table.exportCursor} is null`),
|
|
@@ -3033,6 +3124,7 @@ export {
|
|
|
3033
3124
|
workspaceVariableSets,
|
|
3034
3125
|
workspaceVariableSetVariables,
|
|
3035
3126
|
codexSubscriptionCredentials,
|
|
3127
|
+
codexResetRedemptionAttempts,
|
|
3036
3128
|
connections,
|
|
3037
3129
|
integrationOauthClients,
|
|
3038
3130
|
integrationOauthStateNonces,
|
|
@@ -3111,4 +3203,4 @@ export {
|
|
|
3111
3203
|
rigChanges,
|
|
3112
3204
|
schema_exports
|
|
3113
3205
|
};
|
|
3114
|
-
//# sourceMappingURL=chunk-
|
|
3206
|
+
//# sourceMappingURL=chunk-P6PKXY5W.js.map
|