@opengeni/db 0.22.2 → 0.26.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.
- package/dist/{chunk-CYGFLLMN.js → chunk-7WTDI7Y3.js} +764 -283
- package/dist/chunk-7WTDI7Y3.js.map +1 -0
- package/dist/{chunk-BNGEN5QZ.js → chunk-KW6U54V2.js} +26 -2
- package/dist/chunk-KW6U54V2.js.map +1 -0
- package/dist/connection-token-resolver.d.ts +24 -2
- package/dist/index.d.ts +107 -5
- package/dist/index.js +7857 -3898
- package/dist/index.js.map +1 -1
- package/dist/preference-registry.d.ts +14 -0
- package/dist/provision-roles.js +1 -1
- package/dist/runtime-posture.d.ts +3 -3
- package/dist/schema.d.ts +1659 -77
- package/dist/schema.js +13 -1
- package/dist/session-control.d.ts +7 -1
- package/dist/session-queue-commands.d.ts +8 -0
- package/dist/session-realtime-context.d.ts +56 -0
- package/dist/session-realtime-ledger.d.ts +188 -0
- package/dist/session-realtime-mirror.d.ts +51 -0
- package/dist/session-realtime-state.d.ts +2 -0
- package/dist/session-realtime-terminal.d.ts +40 -0
- package/dist/session-realtime.d.ts +59 -0
- package/dist/workspace-instruction-policies-schema.d.ts +307 -0
- package/dist/workspace-instruction-policies.d.ts +97 -7
- package/drizzle/0156_slack_reaction_trigger.sql +49 -0
- package/drizzle/0157_session_policy_role_snapshots.sql +1146 -0
- package/drizzle/0158_session_realtime_mode.sql +88 -0
- package/drizzle/0159_session_realtime_ledger.sql +198 -0
- package/drizzle/0160_session_realtime_delegation_terminal.sql +38 -0
- package/drizzle/0161_session_realtime_context_projection.sql +82 -0
- package/drizzle/0162_session_realtime_connection_promotion.sql +53 -0
- package/drizzle/0163_session_realtime_delegation_progress.sql +35 -0
- package/drizzle/0164_session_realtime_models.sql +28 -0
- package/drizzle/0165_document_authority_foundation.sql +259 -0
- package/drizzle/0166_connection_disconnect_idempotency.sql +49 -0
- package/drizzle/0167_document_index_replay_authority.sql +61 -0
- package/drizzle/0168_workspace_instruction_policy_operation_receipts.sql +44 -0
- package/package.json +4 -4
- package/src/connection-token-resolver.ts +79 -16
- package/src/index.ts +1033 -101
- package/src/preference-registry.ts +114 -6
- package/src/provision-roles.ts +12 -0
- package/src/runtime-posture.ts +12 -0
- package/src/schema.ts +486 -43
- package/src/session-control.ts +643 -21
- package/src/session-queue-commands.ts +121 -18
- package/src/session-realtime-context.ts +393 -0
- package/src/session-realtime-ledger.ts +1790 -0
- package/src/session-realtime-mirror.ts +276 -0
- package/src/session-realtime-state.ts +25 -0
- package/src/session-realtime-terminal.ts +306 -0
- package/src/session-realtime.ts +659 -0
- package/src/workspace-instruction-policies-schema.ts +71 -0
- package/src/workspace-instruction-policies.ts +568 -25
- package/dist/chunk-BNGEN5QZ.js.map +0 -1
- package/dist/chunk-CYGFLLMN.js.map +0 -1
|
@@ -558,6 +558,109 @@ export async function listPreferenceRegistry(
|
|
|
558
558
|
});
|
|
559
559
|
}
|
|
560
560
|
|
|
561
|
+
export type PreferenceRegistryGovernanceIdentity = Pick<
|
|
562
|
+
PreferenceRegistryDescriptor,
|
|
563
|
+
"id" | "revisionId" | "contentHash" | "activeVersion" | "scope"
|
|
564
|
+
>;
|
|
565
|
+
|
|
566
|
+
export type CurrentPreferenceRegistryGovernanceMetadata = {
|
|
567
|
+
descriptors: PreferenceRegistryGovernanceIdentity[];
|
|
568
|
+
truncated: boolean;
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* Read the current active descriptor identities for one exact authenticated
|
|
573
|
+
* subject. Full preference values and even descriptor display text stay inside
|
|
574
|
+
* this DB boundary; Workspace State receives only stable revision metadata.
|
|
575
|
+
*/
|
|
576
|
+
export async function getCurrentPreferenceRegistryGovernanceMetadata(
|
|
577
|
+
db: Database,
|
|
578
|
+
input: { workspaceId: string; subjectId: string },
|
|
579
|
+
): Promise<CurrentPreferenceRegistryGovernanceMetadata> {
|
|
580
|
+
return await withWorkspaceSubjectRls(db, input.workspaceId, input.subjectId, async (scopedDb) => {
|
|
581
|
+
const rows = await scopedDb
|
|
582
|
+
.select({
|
|
583
|
+
preference: schema.preferenceRegistryPreferences,
|
|
584
|
+
revision: schema.preferenceRegistryRevisions,
|
|
585
|
+
})
|
|
586
|
+
.from(schema.preferenceRegistryPreferences)
|
|
587
|
+
.innerJoin(
|
|
588
|
+
schema.preferenceRegistryRevisions,
|
|
589
|
+
and(
|
|
590
|
+
eq(
|
|
591
|
+
schema.preferenceRegistryRevisions.id,
|
|
592
|
+
schema.preferenceRegistryPreferences.activeRevisionId,
|
|
593
|
+
),
|
|
594
|
+
eq(
|
|
595
|
+
schema.preferenceRegistryRevisions.accountId,
|
|
596
|
+
schema.preferenceRegistryPreferences.accountId,
|
|
597
|
+
),
|
|
598
|
+
),
|
|
599
|
+
)
|
|
600
|
+
.where(
|
|
601
|
+
and(
|
|
602
|
+
eq(schema.preferenceRegistryPreferences.status, "active"),
|
|
603
|
+
or(
|
|
604
|
+
isNull(schema.preferenceRegistryRevisions.expiresAt),
|
|
605
|
+
gt(schema.preferenceRegistryRevisions.expiresAt, sql`transaction_timestamp()`),
|
|
606
|
+
),
|
|
607
|
+
),
|
|
608
|
+
)
|
|
609
|
+
.orderBy(
|
|
610
|
+
sql`case ${schema.preferenceRegistryPreferences.scope}
|
|
611
|
+
when 'organization' then 0
|
|
612
|
+
when 'workspace' then 1
|
|
613
|
+
when 'user' then 2
|
|
614
|
+
else 3
|
|
615
|
+
end`,
|
|
616
|
+
desc(schema.preferenceRegistryRevisions.precedenceRank),
|
|
617
|
+
asc(schema.preferenceRegistryPreferences.stableKey),
|
|
618
|
+
asc(schema.preferenceRegistryPreferences.id),
|
|
619
|
+
)
|
|
620
|
+
.limit(PREFERENCE_REGISTRY_DESCRIPTOR_MAX_COUNT + 1);
|
|
621
|
+
|
|
622
|
+
const bounded = boundPreferenceRegistryDescriptors(
|
|
623
|
+
rows.map(({ preference, revision }) =>
|
|
624
|
+
PreferenceRegistryDescriptor.parse({
|
|
625
|
+
id: preference.id,
|
|
626
|
+
stableKey: preference.stableKey,
|
|
627
|
+
title: revision.title,
|
|
628
|
+
description: revision.description,
|
|
629
|
+
scope: preference.scope,
|
|
630
|
+
activeVersion: preference.activationVersion,
|
|
631
|
+
revisionId: revision.id,
|
|
632
|
+
contentHash: revision.contentHash,
|
|
633
|
+
precedence: {
|
|
634
|
+
tier: preference.scope,
|
|
635
|
+
rank: revision.precedenceRank,
|
|
636
|
+
conflictStrategy: revision.conflictStrategy,
|
|
637
|
+
conflictsWith: revision.conflictsWith,
|
|
638
|
+
},
|
|
639
|
+
provenance: {
|
|
640
|
+
source: revision.provenanceSource,
|
|
641
|
+
sourceIdHash: revision.provenanceSourceId
|
|
642
|
+
? contentHash(revision.provenanceSourceId)
|
|
643
|
+
: null,
|
|
644
|
+
trust: revision.trust,
|
|
645
|
+
},
|
|
646
|
+
expiresAt: revision.expiresAt ? iso(revision.expiresAt) : null,
|
|
647
|
+
retrievalHandle: `preference://${preference.id}/revisions/${revision.id}?sha256=${revision.contentHash}`,
|
|
648
|
+
}),
|
|
649
|
+
),
|
|
650
|
+
);
|
|
651
|
+
return {
|
|
652
|
+
descriptors: bounded.descriptors.map((descriptor) => ({
|
|
653
|
+
id: descriptor.id,
|
|
654
|
+
revisionId: descriptor.revisionId,
|
|
655
|
+
contentHash: descriptor.contentHash,
|
|
656
|
+
activeVersion: descriptor.activeVersion,
|
|
657
|
+
scope: descriptor.scope,
|
|
658
|
+
})),
|
|
659
|
+
truncated: bounded.truncated,
|
|
660
|
+
};
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
|
|
561
664
|
export async function listPreferenceRegistryForAttempt(
|
|
562
665
|
db: Database,
|
|
563
666
|
input: PreferenceRegistryAttemptClaims & PreferenceRegistryListInput,
|
|
@@ -998,7 +1101,10 @@ async function withPreferenceRegistryAttemptAuthority<T>(
|
|
|
998
1101
|
), locked_turn AS MATERIALIZED (
|
|
999
1102
|
SELECT turn.id, turn.account_id, turn.workspace_id, turn.session_id,
|
|
1000
1103
|
turn.active_attempt_id, turn.execution_generation,
|
|
1001
|
-
|
|
1104
|
+
coalesce(
|
|
1105
|
+
turn.initiating_human_subject_id,
|
|
1106
|
+
case when turn.initiator_kind = 'subject' then turn.initiator_subject_id end
|
|
1107
|
+
) as initiating_human_subject_id
|
|
1002
1108
|
FROM session_turns turn
|
|
1003
1109
|
JOIN locked_session session
|
|
1004
1110
|
ON session.id = turn.session_id
|
|
@@ -1008,8 +1114,10 @@ async function withPreferenceRegistryAttemptAuthority<T>(
|
|
|
1008
1114
|
AND turn.active_attempt_id = ${input.attemptId}::uuid
|
|
1009
1115
|
AND turn.execution_generation = ${input.executionGeneration}
|
|
1010
1116
|
AND turn.status IN ('running', 'requires_action', 'recovering', 'waiting_capacity')
|
|
1011
|
-
AND
|
|
1012
|
-
|
|
1117
|
+
AND length(btrim(coalesce(
|
|
1118
|
+
turn.initiating_human_subject_id,
|
|
1119
|
+
case when turn.initiator_kind = 'subject' then turn.initiator_subject_id end
|
|
1120
|
+
))) BETWEEN 1 AND 1024
|
|
1013
1121
|
FOR SHARE OF turn
|
|
1014
1122
|
), locked_attempt AS MATERIALIZED (
|
|
1015
1123
|
SELECT attempt.id, attempt.account_id, attempt.workspace_id,
|
|
@@ -1032,7 +1140,7 @@ async function withPreferenceRegistryAttemptAuthority<T>(
|
|
|
1032
1140
|
)
|
|
1033
1141
|
FOR SHARE OF attempt
|
|
1034
1142
|
)
|
|
1035
|
-
SELECT turn.
|
|
1143
|
+
SELECT turn.initiating_human_subject_id
|
|
1036
1144
|
FROM locked_workspace workspace
|
|
1037
1145
|
JOIN locked_session session ON true
|
|
1038
1146
|
JOIN locked_turn turn ON true
|
|
@@ -1041,8 +1149,8 @@ async function withPreferenceRegistryAttemptAuthority<T>(
|
|
|
1041
1149
|
AND workspace.id = attempt.workspace_id
|
|
1042
1150
|
AND session.id = attempt.session_id
|
|
1043
1151
|
AND turn.id = attempt.turn_id
|
|
1044
|
-
`)) as unknown as Array<{
|
|
1045
|
-
const initiatingHumanSubjectId = rows[0]?.
|
|
1152
|
+
`)) as unknown as Array<{ initiating_human_subject_id: string }>;
|
|
1153
|
+
const initiatingHumanSubjectId = rows[0]?.initiating_human_subject_id;
|
|
1046
1154
|
if (!initiatingHumanSubjectId) {
|
|
1047
1155
|
throw new PreferenceRegistryInitiatorError(
|
|
1048
1156
|
"Preference retrieval requires the exact current attempt, generation, and immutable human initiator",
|
package/src/provision-roles.ts
CHANGED
|
@@ -469,6 +469,18 @@ BEGIN
|
|
|
469
469
|
${literal(role)}
|
|
470
470
|
);
|
|
471
471
|
END IF;
|
|
472
|
+
IF to_regprocedure(
|
|
473
|
+
format(
|
|
474
|
+
'%I.workspace_instruction_policy_get_or_create_snapshot(uuid,uuid,uuid,uuid,uuid,integer)',
|
|
475
|
+
${literal(schema)}
|
|
476
|
+
)
|
|
477
|
+
) IS NOT NULL THEN
|
|
478
|
+
EXECUTE format(
|
|
479
|
+
'GRANT EXECUTE ON FUNCTION %I.workspace_instruction_policy_get_or_create_snapshot(uuid, uuid, uuid, uuid, uuid, integer) TO %I',
|
|
480
|
+
${literal(schema)},
|
|
481
|
+
${literal(role)}
|
|
482
|
+
);
|
|
483
|
+
END IF;
|
|
472
484
|
IF to_regprocedure(
|
|
473
485
|
format(
|
|
474
486
|
'%I.scoped_knowledge_apply_lifecycle(uuid,text,uuid,text,bigint,text,text,text,text,text,text)',
|
package/src/runtime-posture.ts
CHANGED
|
@@ -24,6 +24,7 @@ export const FORCE_RLS_TABLES = [
|
|
|
24
24
|
"codex_rotation_settings",
|
|
25
25
|
"codex_subscription_credentials",
|
|
26
26
|
"composer_drafts",
|
|
27
|
+
"connection_disconnect_operations",
|
|
27
28
|
"connections",
|
|
28
29
|
"connector_action_policies",
|
|
29
30
|
"connector_action_requests",
|
|
@@ -95,6 +96,10 @@ export const FORCE_RLS_TABLES = [
|
|
|
95
96
|
"session_mcp_servers",
|
|
96
97
|
"session_pending_tool_calls",
|
|
97
98
|
"session_pins",
|
|
99
|
+
"session_realtime_connections",
|
|
100
|
+
"session_realtime_context_projections",
|
|
101
|
+
"session_realtime_entries",
|
|
102
|
+
"session_realtime_modes",
|
|
98
103
|
"session_recordings",
|
|
99
104
|
"session_spawn_denials",
|
|
100
105
|
"session_stream_acknowledgments",
|
|
@@ -122,6 +127,7 @@ export const FORCE_RLS_TABLES = [
|
|
|
122
127
|
"workspace_instruction_policy_activation_events",
|
|
123
128
|
"workspace_instruction_policy_heads",
|
|
124
129
|
"workspace_instruction_policy_revisions",
|
|
130
|
+
"workspace_instruction_policy_snapshots",
|
|
125
131
|
"workspace_model_policies",
|
|
126
132
|
"workspace_packs",
|
|
127
133
|
"workspace_session_activity_revisions",
|
|
@@ -171,6 +177,7 @@ export const RUNTIME_FULL_DML_TABLES = [
|
|
|
171
177
|
"codex_rotation_settings",
|
|
172
178
|
"codex_subscription_credentials",
|
|
173
179
|
"composer_drafts",
|
|
180
|
+
"connection_disconnect_operations",
|
|
174
181
|
"connections",
|
|
175
182
|
"connector_action_policies",
|
|
176
183
|
"connector_action_requests",
|
|
@@ -217,6 +224,10 @@ export const RUNTIME_FULL_DML_TABLES = [
|
|
|
217
224
|
"session_mcp_servers",
|
|
218
225
|
"session_pending_tool_calls",
|
|
219
226
|
"session_pins",
|
|
227
|
+
"session_realtime_connections",
|
|
228
|
+
"session_realtime_context_projections",
|
|
229
|
+
"session_realtime_entries",
|
|
230
|
+
"session_realtime_modes",
|
|
220
231
|
"session_recordings",
|
|
221
232
|
"session_stream_acknowledgments",
|
|
222
233
|
"session_system_update_outbox",
|
|
@@ -257,6 +268,7 @@ export const RUNTIME_READ_ONLY_TABLES = [
|
|
|
257
268
|
"nested_agent_depth_configuration",
|
|
258
269
|
"preference_registry_events",
|
|
259
270
|
"preference_registry_snapshots",
|
|
271
|
+
"workspace_instruction_policy_snapshots",
|
|
260
272
|
] as const;
|
|
261
273
|
|
|
262
274
|
/** Append-only evidence/revision tables are insertable and queryable, never mutable. */
|