@opengeni/db 0.31.1 → 0.36.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.
- package/dist/browser-auth.d.ts +209 -1
- package/dist/browser-downloads.d.ts +51 -0
- package/dist/browser-identities.d.ts +11 -2
- package/dist/browser-sessions.d.ts +83 -1
- package/dist/browser-state-artifacts.d.ts +75 -1
- package/dist/canonical-human-identities.d.ts +48 -0
- package/dist/canonical-human-identities.js +28 -0
- package/dist/canonical-human-identities.js.map +1 -0
- package/dist/capability-integrations.d.ts +8 -6
- package/dist/{chunk-MWDVXQOL.js → chunk-5KTIEDX7.js} +5773 -4212
- package/dist/chunk-5KTIEDX7.js.map +1 -0
- package/dist/chunk-FPVAD4CO.js +117 -0
- package/dist/chunk-FPVAD4CO.js.map +1 -0
- package/dist/chunk-GYO7ED2Q.js +259 -0
- package/dist/chunk-GYO7ED2Q.js.map +1 -0
- package/dist/{chunk-F5FT7BEZ.js → chunk-HSOWSYOX.js} +2 -2
- package/dist/{chunk-YHZXQ7HP.js → chunk-VKLB2ZGI.js} +446 -19
- package/dist/chunk-VKLB2ZGI.js.map +1 -0
- package/dist/{chunk-NBE6CHRI.js → chunk-VTPRIXKG.js} +49 -9
- package/dist/chunk-VTPRIXKG.js.map +1 -0
- package/dist/{chunk-ISI2TIUG.js → chunk-Z7VYMNPZ.js} +76 -4
- package/dist/chunk-Z7VYMNPZ.js.map +1 -0
- package/dist/database.d.ts +5 -0
- package/dist/editable-artifact-durable-export.js +2 -2
- package/dist/editable-artifacts.js +3 -3
- package/dist/index.d.ts +467 -29
- package/dist/index.js +23247 -16232
- package/dist/index.js.map +1 -1
- package/dist/insights.d.ts +23 -7
- package/dist/integration-bindings.d.ts +24 -24
- package/dist/integration-facets.d.ts +99 -0
- package/dist/interaction-revisions.d.ts +11 -0
- package/dist/interaction-schema.d.ts +698 -34
- package/dist/persistence-errors.d.ts +8 -0
- package/dist/provision-roles.js +1 -1
- package/dist/runtime-posture.d.ts +8 -7
- package/dist/schema.d.ts +9464 -5412
- package/dist/schema.js +51 -9
- package/dist/session-control.d.ts +29 -3
- package/dist/session-tenancy.d.ts +44 -0
- package/dist/session-tenancy.js +16 -0
- package/dist/session-tenancy.js.map +1 -0
- package/dist/slack-task-policy-schema.d.ts +847 -0
- package/dist/slack-task-policy.d.ts +65 -0
- package/dist/task-notes-schema.d.ts +924 -0
- package/dist/task-notes.d.ts +85 -0
- package/dist/video-generation.d.ts +9 -0
- package/dist/video-generation.js +5 -3
- package/dist/xai-subscription.d.ts +326 -0
- package/drizzle/0212_browser_state_transfer_hardening.sql +560 -0
- package/drizzle/0213_browser_interaction_authority.sql +67 -0
- package/drizzle/0214_browser_download_saves.sql +34 -0
- package/drizzle/0215_browser_controller_host.sql +385 -0
- package/drizzle/0216_browser_auth_health_evidence.sql +137 -0
- package/drizzle/0217_external_browser_auth_operations.sql +22 -0
- package/drizzle/0218_organization_tenancy_foundation.sql +299 -0
- package/drizzle/0219_organization_tenancy_managed_human_provisioning.sql +317 -0
- package/drizzle/0219_site_auth_maintenance_sessions.sql +234 -0
- package/drizzle/0220_memory_slack_append_only_cascade.sql +38 -0
- package/drizzle/0220_session_channels.sql +54 -0
- package/drizzle/0221_sessions_channel_index.sql +5 -0
- package/drizzle/0222_session_visibility_authority_epochs.sql +158 -0
- package/drizzle/0222_sessions_channel_fk.sql +89 -0
- package/drizzle/0223_pending_tool_event_output.sql +55 -0
- package/drizzle/0223_sessions_channel_fk_validate.sql +118 -0
- package/drizzle/0224_slack_post_outcome_reconciliation.sql +123 -0
- package/drizzle/0225_session_visibility_fork_activation.sql +1363 -0
- package/drizzle/0226_personal_codex_authority_foundation.sql +365 -0
- package/drizzle/0227_slack_native_actions.sql +145 -0
- package/drizzle/0228_interaction_controller_data_plane.sql +14 -0
- package/drizzle/0228_slack_task_policy.sql +400 -0
- package/drizzle/0229_slack_inbox_file_fact.sql +10 -0
- package/drizzle/0230_user_scoped_variable_sets_rigs.sql +84 -0
- package/drizzle/0231_integration_definition_identity_cutover.sql +271 -0
- package/drizzle/0232_integration_facet_authority_cutover.sql +610 -0
- package/drizzle/0233_skill_and_integration_authority_cutover.sql +1162 -0
- package/drizzle/0234_xai_subscription_authority.sql +1139 -0
- package/drizzle/0235_canonical_human_login_bindings.sql +920 -0
- package/drizzle/0236_browser_identity_lifecycle.sql +39 -0
- package/drizzle/0236_session_visibility_slack_policy.sql +72 -0
- package/drizzle/0237_interaction_transition_reaper.sql +263 -0
- package/drizzle/0238_goal_persistence_policy.sql +471 -0
- package/drizzle/0238_recover_unclaimed_session_turns.sql +307 -0
- package/drizzle/0238_supergrok_realtime_model.sql +29 -0
- package/drizzle/0239_supergrok_video_funding.sql +50 -0
- package/drizzle/0239_task_tree_notes.sql +990 -0
- package/package.json +13 -5
- package/src/browser-auth.ts +2600 -123
- package/src/browser-downloads.ts +517 -0
- package/src/browser-identities.ts +220 -3
- package/src/browser-sessions.ts +334 -45
- package/src/browser-state-artifacts.ts +402 -12
- package/src/canonical-human-identities.ts +317 -0
- package/src/capability-integrations.ts +121 -213
- package/src/database.ts +41 -1
- package/src/index.ts +4625 -411
- package/src/insights.ts +109 -28
- package/src/integration-bindings.ts +101 -101
- package/src/{integration-features.ts → integration-facets.ts} +187 -184
- package/src/interaction-revisions.ts +33 -3
- package/src/interaction-schema.ts +311 -8
- package/src/pack-components.ts +43 -43
- package/src/pack-installations.ts +0 -43
- package/src/persistence-errors.ts +60 -1
- package/src/plugin-packages.ts +9 -9
- package/src/provision-roles.ts +232 -0
- package/src/runtime-posture.ts +227 -14
- package/src/schema.ts +1188 -75
- package/src/session-control.ts +122 -37
- package/src/session-queue-commands.ts +78 -1
- package/src/session-tenancy.ts +188 -0
- package/src/session-tool-call-settlement.ts +9 -3
- package/src/slack-task-policy-schema.ts +130 -0
- package/src/slack-task-policy.ts +341 -0
- package/src/task-notes-schema.ts +135 -0
- package/src/task-notes.ts +178 -0
- package/src/video-generation.ts +90 -12
- package/src/workspace-artifacts.ts +1 -1
- package/src/xai-subscription.ts +1887 -0
- package/dist/chunk-ISI2TIUG.js.map +0 -1
- package/dist/chunk-MWDVXQOL.js.map +0 -1
- package/dist/chunk-NBE6CHRI.js.map +0 -1
- package/dist/chunk-YHZXQ7HP.js.map +0 -1
- package/dist/integration-features.d.ts +0 -99
- /package/dist/{chunk-F5FT7BEZ.js.map → chunk-HSOWSYOX.js.map} +0 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { type TaskNoteKind as TaskNoteKindType } from "@opengeni/contracts";
|
|
2
|
+
import type { Database } from "./database.js";
|
|
3
|
+
export type TaskNoteAttemptClaims = {
|
|
4
|
+
accountId: string;
|
|
5
|
+
workspaceId: string;
|
|
6
|
+
sessionId: string;
|
|
7
|
+
turnId: string;
|
|
8
|
+
attemptId: string;
|
|
9
|
+
executionGeneration: number;
|
|
10
|
+
};
|
|
11
|
+
export type CreateTaskNoteInput = TaskNoteAttemptClaims & {
|
|
12
|
+
operationId: string;
|
|
13
|
+
kind: TaskNoteKindType;
|
|
14
|
+
text: string;
|
|
15
|
+
expiresInDays: number;
|
|
16
|
+
};
|
|
17
|
+
export type ArchiveTaskNoteInput = TaskNoteAttemptClaims & {
|
|
18
|
+
operationId: string;
|
|
19
|
+
noteId: string;
|
|
20
|
+
expectedVersion: number;
|
|
21
|
+
reason: string;
|
|
22
|
+
};
|
|
23
|
+
export type ListTaskNotesInput = TaskNoteAttemptClaims & {
|
|
24
|
+
includeArchived?: boolean;
|
|
25
|
+
limit?: number;
|
|
26
|
+
};
|
|
27
|
+
export declare function createTaskNote(db: Database, input: CreateTaskNoteInput): Promise<{
|
|
28
|
+
note: {
|
|
29
|
+
id: string;
|
|
30
|
+
rootSessionId: string;
|
|
31
|
+
kind: "artifact" | "blocker" | "decision" | "finding" | "handoff" | "ownership";
|
|
32
|
+
text: string;
|
|
33
|
+
status: "active" | "archived";
|
|
34
|
+
version: number;
|
|
35
|
+
expiresAt: string;
|
|
36
|
+
createdAt: string;
|
|
37
|
+
updatedAt: string;
|
|
38
|
+
archivedAt: string | null;
|
|
39
|
+
provenance: {
|
|
40
|
+
actorKind: "human" | "service";
|
|
41
|
+
sourceSessionId: string;
|
|
42
|
+
sourceTurnId: string;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
replayed: boolean;
|
|
46
|
+
}>;
|
|
47
|
+
export declare function archiveTaskNote(db: Database, input: ArchiveTaskNoteInput): Promise<{
|
|
48
|
+
note: {
|
|
49
|
+
id: string;
|
|
50
|
+
rootSessionId: string;
|
|
51
|
+
kind: "artifact" | "blocker" | "decision" | "finding" | "handoff" | "ownership";
|
|
52
|
+
text: string;
|
|
53
|
+
status: "active" | "archived";
|
|
54
|
+
version: number;
|
|
55
|
+
expiresAt: string;
|
|
56
|
+
createdAt: string;
|
|
57
|
+
updatedAt: string;
|
|
58
|
+
archivedAt: string | null;
|
|
59
|
+
provenance: {
|
|
60
|
+
actorKind: "human" | "service";
|
|
61
|
+
sourceSessionId: string;
|
|
62
|
+
sourceTurnId: string;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
replayed: boolean;
|
|
66
|
+
}>;
|
|
67
|
+
export declare function listTaskNotes(db: Database, input: ListTaskNotesInput): Promise<{
|
|
68
|
+
notes: {
|
|
69
|
+
id: string;
|
|
70
|
+
rootSessionId: string;
|
|
71
|
+
kind: "artifact" | "blocker" | "decision" | "finding" | "handoff" | "ownership";
|
|
72
|
+
text: string;
|
|
73
|
+
status: "active" | "archived";
|
|
74
|
+
version: number;
|
|
75
|
+
expiresAt: string;
|
|
76
|
+
createdAt: string;
|
|
77
|
+
updatedAt: string;
|
|
78
|
+
archivedAt: string | null;
|
|
79
|
+
provenance: {
|
|
80
|
+
actorKind: "human" | "service";
|
|
81
|
+
sourceSessionId: string;
|
|
82
|
+
sourceTurnId: string;
|
|
83
|
+
};
|
|
84
|
+
}[];
|
|
85
|
+
}>;
|
|
@@ -70,6 +70,15 @@ export declare function admitVideoGenerationOperation(db: Database, input: Admit
|
|
|
70
70
|
operation: VideoGenerationOperation;
|
|
71
71
|
created: boolean;
|
|
72
72
|
}>;
|
|
73
|
+
/** Persist a rotated provider token before it is used for another remote call. */
|
|
74
|
+
export declare function rotateVideoGenerationCredential(db: Database, input: {
|
|
75
|
+
accountId: string;
|
|
76
|
+
workspaceId: string;
|
|
77
|
+
operationId: string;
|
|
78
|
+
requestDigest: string;
|
|
79
|
+
expectedCredentialEncrypted: string;
|
|
80
|
+
credentialEncrypted: string;
|
|
81
|
+
}): Promise<VideoGenerationOperation>;
|
|
73
82
|
/**
|
|
74
83
|
* Seal a reference-bearing operation only after every immutable staging object
|
|
75
84
|
* has been uploaded and independently verified by the worker. The source
|
package/dist/video-generation.js
CHANGED
|
@@ -25,12 +25,13 @@ import {
|
|
|
25
25
|
mediaGenerationResultForOperation,
|
|
26
26
|
mediaGenerationResultForStoredOperation,
|
|
27
27
|
rescheduleVideoGenerationOperation,
|
|
28
|
+
rotateVideoGenerationCredential,
|
|
28
29
|
settleVideoGenerationFailure,
|
|
29
30
|
settleVideoGenerationReady,
|
|
30
31
|
updateWorkspaceVideoGenerationPolicy
|
|
31
|
-
} from "./chunk-
|
|
32
|
-
import "./chunk-
|
|
33
|
-
import "./chunk-
|
|
32
|
+
} from "./chunk-VTPRIXKG.js";
|
|
33
|
+
import "./chunk-Z7VYMNPZ.js";
|
|
34
|
+
import "./chunk-5KTIEDX7.js";
|
|
34
35
|
import "./chunk-PZ5AY32C.js";
|
|
35
36
|
export {
|
|
36
37
|
ACTIVE_VIDEO_GENERATION_STATUSES,
|
|
@@ -59,6 +60,7 @@ export {
|
|
|
59
60
|
mediaGenerationResultForOperation,
|
|
60
61
|
mediaGenerationResultForStoredOperation,
|
|
61
62
|
rescheduleVideoGenerationOperation,
|
|
63
|
+
rotateVideoGenerationCredential,
|
|
62
64
|
settleVideoGenerationFailure,
|
|
63
65
|
settleVideoGenerationReady,
|
|
64
66
|
updateWorkspaceVideoGenerationPolicy
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import { type XaiProviderAccountAuthoritySnapshotV1 as XaiAuthoritySnapshot } from "@opengeni/contracts";
|
|
2
|
+
import type { Database } from "./database.js";
|
|
3
|
+
import * as schema from "./schema.js";
|
|
4
|
+
export type XaiAccountAuthorityScope = "workspace" | "user";
|
|
5
|
+
export type XaiCredentialStatus = "active" | "needs_relogin" | "error" | "disabled";
|
|
6
|
+
export type XaiCredentialSecretV1 = {
|
|
7
|
+
version: 1;
|
|
8
|
+
accessToken?: string;
|
|
9
|
+
refreshToken?: string;
|
|
10
|
+
sessionToken?: string;
|
|
11
|
+
cookie?: string;
|
|
12
|
+
};
|
|
13
|
+
export type XaiSubscriptionAccountMetadata = {
|
|
14
|
+
id: string;
|
|
15
|
+
scope: XaiAccountAuthorityScope;
|
|
16
|
+
providerAccountId: string | null;
|
|
17
|
+
label: string | null;
|
|
18
|
+
accountEmail: string | null;
|
|
19
|
+
planType: string | null;
|
|
20
|
+
status: XaiCredentialStatus;
|
|
21
|
+
allocatorEnabled: boolean;
|
|
22
|
+
version: number;
|
|
23
|
+
allocatorVersion: number;
|
|
24
|
+
allocatorUpdatedAt: Date | null;
|
|
25
|
+
expiresAt: Date | null;
|
|
26
|
+
lastRefreshAt: Date | null;
|
|
27
|
+
lastError: string | null;
|
|
28
|
+
quotaUsedPercent: number | null;
|
|
29
|
+
quotaResetAt: Date | null;
|
|
30
|
+
quotaCheckedAt: Date | null;
|
|
31
|
+
exhaustedUntil: Date | null;
|
|
32
|
+
selectionCount: number;
|
|
33
|
+
lastSelectedAt: Date | null;
|
|
34
|
+
connectedBySubjectId: string | null;
|
|
35
|
+
};
|
|
36
|
+
export type XaiCredentialForRun = XaiSubscriptionAccountMetadata & {
|
|
37
|
+
secret: XaiCredentialSecretV1;
|
|
38
|
+
authoritySnapshot: XaiAuthoritySnapshot;
|
|
39
|
+
};
|
|
40
|
+
export type XaiCredentialLeaseResult = {
|
|
41
|
+
credentialId: string | null;
|
|
42
|
+
rotationEnabled: boolean;
|
|
43
|
+
reused: boolean;
|
|
44
|
+
holderId: string | null;
|
|
45
|
+
generation: number | null;
|
|
46
|
+
leasedUntil: Date | null;
|
|
47
|
+
accounts: XaiSubscriptionAccountMetadata[];
|
|
48
|
+
};
|
|
49
|
+
export declare const XAI_CREDENTIAL_LEASE_TTL_MS: number;
|
|
50
|
+
/** Stable session sharding, matching Codex's cache-affinity contract. */
|
|
51
|
+
export declare function xaiCredentialShardIndex(sessionId: string, candidateCount: number): number;
|
|
52
|
+
export declare function createXaiSubscriptionCredential(db: Database, input: {
|
|
53
|
+
accountId: string;
|
|
54
|
+
workspaceId: string;
|
|
55
|
+
subjectId: string;
|
|
56
|
+
scope?: XaiAccountAuthorityScope;
|
|
57
|
+
encryptionKey: Uint8Array;
|
|
58
|
+
secret: XaiCredentialSecretV1;
|
|
59
|
+
providerAccountId?: string | null;
|
|
60
|
+
label?: string | null;
|
|
61
|
+
accountEmail?: string | null;
|
|
62
|
+
planType?: string | null;
|
|
63
|
+
expiresAt?: Date | null;
|
|
64
|
+
}): Promise<{
|
|
65
|
+
account: XaiSubscriptionAccountMetadata;
|
|
66
|
+
authoritySnapshot: XaiAuthoritySnapshot;
|
|
67
|
+
}>;
|
|
68
|
+
export declare function upsertXaiSubscriptionCredential(db: Database, input: {
|
|
69
|
+
accountId: string;
|
|
70
|
+
workspaceId: string;
|
|
71
|
+
subjectId: string;
|
|
72
|
+
credentialId?: string | null;
|
|
73
|
+
authoritySnapshot?: XaiAuthoritySnapshot;
|
|
74
|
+
scope?: XaiAccountAuthorityScope;
|
|
75
|
+
encryptionKey: Uint8Array;
|
|
76
|
+
secret: XaiCredentialSecretV1;
|
|
77
|
+
providerAccountId?: string | null;
|
|
78
|
+
label?: string | null;
|
|
79
|
+
accountEmail?: string | null;
|
|
80
|
+
planType?: string | null;
|
|
81
|
+
expiresAt?: Date | null;
|
|
82
|
+
}): Promise<{
|
|
83
|
+
account: XaiSubscriptionAccountMetadata;
|
|
84
|
+
authoritySnapshot: XaiAuthoritySnapshot;
|
|
85
|
+
}>;
|
|
86
|
+
export declare function listXaiSubscriptionAccountsMetadata(db: Database, input: {
|
|
87
|
+
workspaceId: string;
|
|
88
|
+
subjectId: string;
|
|
89
|
+
}): Promise<XaiSubscriptionAccountMetadata[]>;
|
|
90
|
+
/**
|
|
91
|
+
* Metadata-only readiness check for the SuperGrok model catalog.
|
|
92
|
+
*
|
|
93
|
+
* Like Codex, allocator eligibility is runtime scheduling state, not connection
|
|
94
|
+
* readiness. With rotation enabled any healthy account makes the rail ready;
|
|
95
|
+
* with rotation disabled the explicit active account is authoritative.
|
|
96
|
+
*/
|
|
97
|
+
export declare function workspaceXaiSubscriptionActive(db: Database, settings: {
|
|
98
|
+
readonly supergrokSubscriptionEnabled: boolean;
|
|
99
|
+
}, workspaceId: string, subjectId: string): Promise<boolean>;
|
|
100
|
+
export declare function getXaiSubscriptionAccountMetadata(db: Database, input: {
|
|
101
|
+
workspaceId: string;
|
|
102
|
+
subjectId: string;
|
|
103
|
+
credentialId: string;
|
|
104
|
+
}): Promise<XaiSubscriptionAccountMetadata | null>;
|
|
105
|
+
export declare function getXaiSubscriptionAccountAuthoritySnapshot(db: Database, input: {
|
|
106
|
+
workspaceId: string;
|
|
107
|
+
subjectId: string;
|
|
108
|
+
credentialId: string;
|
|
109
|
+
}): Promise<XaiAuthoritySnapshot | null>;
|
|
110
|
+
/**
|
|
111
|
+
* Resolve the provider-account authority frozen on a newly accepted human turn.
|
|
112
|
+
* Workspace authority is the default. A caller's private pool becomes effective
|
|
113
|
+
* only after that exact pool has an active credential pointer, which is set by
|
|
114
|
+
* the caller's explicit private connection/activation action.
|
|
115
|
+
*/
|
|
116
|
+
export declare function resolveXaiProviderAccountAuthoritySnapshotForAcceptance(db: Database, input: {
|
|
117
|
+
workspaceId: string;
|
|
118
|
+
subjectId: string;
|
|
119
|
+
}): Promise<XaiAuthoritySnapshot>;
|
|
120
|
+
/** Transaction-local acceptance resolver. The caller must already have set the
|
|
121
|
+
* exact authenticated subject GUC on this same transaction. */
|
|
122
|
+
export declare function resolveXaiProviderAccountAuthoritySnapshotForAcceptanceInTransaction(db: Database, input: {
|
|
123
|
+
workspaceId: string;
|
|
124
|
+
}): Promise<XaiAuthoritySnapshot>;
|
|
125
|
+
export declare function updateXaiSubscriptionAccountSettings(db: Database, input: {
|
|
126
|
+
workspaceId: string;
|
|
127
|
+
subjectId: string;
|
|
128
|
+
credentialId: string;
|
|
129
|
+
expectedVersion: number;
|
|
130
|
+
label?: string | null;
|
|
131
|
+
allocatorEnabled?: boolean;
|
|
132
|
+
}): Promise<XaiSubscriptionAccountMetadata>;
|
|
133
|
+
export type XaiAllocatorUpdateResult = {
|
|
134
|
+
kind: "updated" | "unchanged" | "conflict";
|
|
135
|
+
allocatorEnabled: boolean;
|
|
136
|
+
allocatorVersion: number;
|
|
137
|
+
allocatorUpdatedAt: Date | null;
|
|
138
|
+
} | {
|
|
139
|
+
kind: "not_found";
|
|
140
|
+
};
|
|
141
|
+
export declare function updateXaiAllocatorEligibility(db: Database, input: {
|
|
142
|
+
workspaceId: string;
|
|
143
|
+
subjectId: string;
|
|
144
|
+
credentialId: string;
|
|
145
|
+
enabled: boolean;
|
|
146
|
+
expectedVersion: number;
|
|
147
|
+
}): Promise<XaiAllocatorUpdateResult>;
|
|
148
|
+
export declare function renameXaiSubscriptionAccount(db: Database, input: {
|
|
149
|
+
workspaceId: string;
|
|
150
|
+
subjectId: string;
|
|
151
|
+
credentialId: string;
|
|
152
|
+
label: string | null;
|
|
153
|
+
}): Promise<XaiSubscriptionAccountMetadata | null>;
|
|
154
|
+
export declare function disconnectXaiSubscriptionCredential(db: Database, input: {
|
|
155
|
+
accountId: string;
|
|
156
|
+
workspaceId: string;
|
|
157
|
+
subjectId: string;
|
|
158
|
+
credentialId: string;
|
|
159
|
+
authoritySnapshot: XaiAuthoritySnapshot;
|
|
160
|
+
}): Promise<boolean>;
|
|
161
|
+
export declare function materializeXaiCredentialForRun(db: Database, input: {
|
|
162
|
+
workspaceId: string;
|
|
163
|
+
subjectId: string;
|
|
164
|
+
credentialId: string;
|
|
165
|
+
authoritySnapshot: XaiAuthoritySnapshot;
|
|
166
|
+
encryptionKey: Uint8Array;
|
|
167
|
+
}): Promise<XaiCredentialForRun>;
|
|
168
|
+
export type XaiSerializedCredentialRefreshResult = {
|
|
169
|
+
credential: XaiCredentialForRun;
|
|
170
|
+
refreshed: boolean;
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Refresh one connected xAI account under a database row lock.
|
|
174
|
+
*
|
|
175
|
+
* OAuth refresh tokens may rotate. Multiple sessions are allowed to share the
|
|
176
|
+
* same account, so an unlocked read-refresh-write sequence can make one
|
|
177
|
+
* successful refresh invalidate every other in-flight refresh. This operation
|
|
178
|
+
* re-reads the secret after acquiring the lock and skips the provider call when
|
|
179
|
+
* another request already installed a newer token pair.
|
|
180
|
+
*/
|
|
181
|
+
export declare function refreshXaiSubscriptionCredentialSerialized(db: Database, input: {
|
|
182
|
+
accountId: string;
|
|
183
|
+
workspaceId: string;
|
|
184
|
+
subjectId: string;
|
|
185
|
+
credentialId: string;
|
|
186
|
+
authoritySnapshot: XaiAuthoritySnapshot;
|
|
187
|
+
encryptionKey: Uint8Array;
|
|
188
|
+
observedAccessToken: string | undefined;
|
|
189
|
+
observedRefreshToken: string | undefined;
|
|
190
|
+
refresh: (current: XaiCredentialForRun) => Promise<{
|
|
191
|
+
secret: XaiCredentialSecretV1;
|
|
192
|
+
expiresAt: Date | null;
|
|
193
|
+
}>;
|
|
194
|
+
}): Promise<XaiSerializedCredentialRefreshResult>;
|
|
195
|
+
export declare function acquireXaiCredentialLease(db: Database, input: {
|
|
196
|
+
accountId: string;
|
|
197
|
+
workspaceId: string;
|
|
198
|
+
subjectId: string;
|
|
199
|
+
sessionId: string;
|
|
200
|
+
turnId: string;
|
|
201
|
+
holderId: string;
|
|
202
|
+
authoritySnapshot: XaiAuthoritySnapshot;
|
|
203
|
+
pinnedCredentialId?: string | null;
|
|
204
|
+
pinSource?: "manual" | "policy" | null;
|
|
205
|
+
now?: Date;
|
|
206
|
+
leaseTtlMs?: number;
|
|
207
|
+
}): Promise<XaiCredentialLeaseResult>;
|
|
208
|
+
/**
|
|
209
|
+
* Select an authorized connected account for a non-turn operation (voice,
|
|
210
|
+
* transcription, media). Rotation uses the same stable session/request shard
|
|
211
|
+
* as turns, but does not create a capacity lease: one account may serve many
|
|
212
|
+
* concurrent upstream sessions just like Codex subscriptions.
|
|
213
|
+
*/
|
|
214
|
+
export declare function selectXaiCredentialForUse(db: Database, input: {
|
|
215
|
+
accountId: string;
|
|
216
|
+
workspaceId: string;
|
|
217
|
+
subjectId: string;
|
|
218
|
+
authoritySnapshot: XaiAuthoritySnapshot;
|
|
219
|
+
shardKey: string;
|
|
220
|
+
pinnedCredentialId?: string | null;
|
|
221
|
+
pinSource?: "manual" | "policy" | null;
|
|
222
|
+
now?: Date;
|
|
223
|
+
}): Promise<{
|
|
224
|
+
credentialId: string | null;
|
|
225
|
+
rotationEnabled: boolean;
|
|
226
|
+
accounts: XaiSubscriptionAccountMetadata[];
|
|
227
|
+
}>;
|
|
228
|
+
export declare function releaseXaiCredentialLease(db: Database, input: {
|
|
229
|
+
workspaceId: string;
|
|
230
|
+
subjectId: string;
|
|
231
|
+
turnId: string;
|
|
232
|
+
holderId: string;
|
|
233
|
+
generation: number;
|
|
234
|
+
}): Promise<boolean>;
|
|
235
|
+
export declare function heartbeatXaiCredentialLeaseUntil(db: Database, input: {
|
|
236
|
+
workspaceId: string;
|
|
237
|
+
subjectId: string;
|
|
238
|
+
turnId: string;
|
|
239
|
+
holderId: string;
|
|
240
|
+
generation: number;
|
|
241
|
+
leaseTtlMs?: number;
|
|
242
|
+
now?: Date;
|
|
243
|
+
}): Promise<Date | null>;
|
|
244
|
+
export declare function getXaiRotationSettings(db: Database, input: {
|
|
245
|
+
workspaceId: string;
|
|
246
|
+
subjectId: string;
|
|
247
|
+
authoritySnapshot: XaiAuthoritySnapshot;
|
|
248
|
+
}): Promise<typeof schema.xaiRotationSettings.$inferSelect | null>;
|
|
249
|
+
export declare function ensureXaiRotationSettings(db: Database, input: {
|
|
250
|
+
accountId: string;
|
|
251
|
+
workspaceId: string;
|
|
252
|
+
subjectId: string;
|
|
253
|
+
authoritySnapshot: XaiAuthoritySnapshot;
|
|
254
|
+
}): Promise<typeof schema.xaiRotationSettings.$inferSelect>;
|
|
255
|
+
export declare function setActiveXaiCredential(db: Database, input: {
|
|
256
|
+
accountId: string;
|
|
257
|
+
workspaceId: string;
|
|
258
|
+
subjectId: string;
|
|
259
|
+
authoritySnapshot: XaiAuthoritySnapshot;
|
|
260
|
+
credentialId: string;
|
|
261
|
+
}): Promise<boolean>;
|
|
262
|
+
export declare function setInitialActiveXaiCredential(db: Database, input: {
|
|
263
|
+
accountId: string;
|
|
264
|
+
workspaceId: string;
|
|
265
|
+
subjectId: string;
|
|
266
|
+
authoritySnapshot: XaiAuthoritySnapshot;
|
|
267
|
+
credentialId: string;
|
|
268
|
+
}): Promise<boolean>;
|
|
269
|
+
export declare function disconnectXaiSubscriptionCredentialAndRepick(db: Database, input: {
|
|
270
|
+
accountId: string;
|
|
271
|
+
workspaceId: string;
|
|
272
|
+
subjectId: string;
|
|
273
|
+
credentialId: string;
|
|
274
|
+
authoritySnapshot: XaiAuthoritySnapshot;
|
|
275
|
+
}): Promise<{
|
|
276
|
+
disconnected: boolean;
|
|
277
|
+
newActiveCredentialId: string | null;
|
|
278
|
+
}>;
|
|
279
|
+
export declare function updateXaiRotationSettings(db: Database, input: {
|
|
280
|
+
workspaceId: string;
|
|
281
|
+
subjectId: string;
|
|
282
|
+
authoritySnapshot: XaiAuthoritySnapshot;
|
|
283
|
+
expectedVersion: number;
|
|
284
|
+
rotationEnabled: boolean;
|
|
285
|
+
}): Promise<typeof schema.xaiRotationSettings.$inferSelect>;
|
|
286
|
+
export declare function setXaiSessionAccountPin(db: Database, input: {
|
|
287
|
+
accountId: string;
|
|
288
|
+
workspaceId: string;
|
|
289
|
+
subjectId: string;
|
|
290
|
+
sessionId: string;
|
|
291
|
+
authoritySnapshot: XaiAuthoritySnapshot;
|
|
292
|
+
credentialId: string | null;
|
|
293
|
+
pinSource: "manual" | "policy" | null;
|
|
294
|
+
/** undefined = unconditional human write; null = row must not exist. */
|
|
295
|
+
expectedVersion?: number | null;
|
|
296
|
+
}): Promise<typeof schema.xaiSessionAccountPins.$inferSelect>;
|
|
297
|
+
export declare function getXaiSessionAccountPin(db: Database, input: {
|
|
298
|
+
workspaceId: string;
|
|
299
|
+
subjectId: string;
|
|
300
|
+
sessionId: string;
|
|
301
|
+
authoritySnapshot: XaiAuthoritySnapshot;
|
|
302
|
+
}): Promise<typeof schema.xaiSessionAccountPins.$inferSelect | null>;
|
|
303
|
+
export declare function recordXaiSessionLastAccount(db: Database, input: {
|
|
304
|
+
accountId: string;
|
|
305
|
+
workspaceId: string;
|
|
306
|
+
subjectId: string;
|
|
307
|
+
sessionId: string;
|
|
308
|
+
authoritySnapshot: XaiAuthoritySnapshot;
|
|
309
|
+
credentialId: string;
|
|
310
|
+
}): Promise<typeof schema.xaiSessionAccountPins.$inferSelect>;
|
|
311
|
+
export declare function updateXaiQuotaMetadata(db: Database, input: {
|
|
312
|
+
workspaceId: string;
|
|
313
|
+
subjectId: string;
|
|
314
|
+
credentialId: string;
|
|
315
|
+
quotaUsedPercent: number | null;
|
|
316
|
+
quotaResetAt: Date | null;
|
|
317
|
+
quotaCheckedAt: Date;
|
|
318
|
+
exhaustedUntil: Date | null;
|
|
319
|
+
}): Promise<boolean>;
|
|
320
|
+
export declare function wakeXaiCapacityWaiters(db: Database, input: {
|
|
321
|
+
workspaceId: string;
|
|
322
|
+
subjectId: string;
|
|
323
|
+
authoritySnapshot: XaiAuthoritySnapshot;
|
|
324
|
+
reason: string;
|
|
325
|
+
now?: Date;
|
|
326
|
+
}): Promise<number>;
|