@opengeni/db 5.0.1 → 6.0.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/automations.d.ts +0 -2
- package/dist/canonical-human-identities.d.ts +4 -0
- package/dist/canonical-human-identities.js +3 -3
- package/dist/capability-components.d.ts +5 -13
- package/dist/capability-integrations.d.ts +23 -8
- package/dist/capability-reconciliation.d.ts +5 -0
- package/dist/capability-reconciliation.js +21 -0
- package/dist/capability-reconciliation.js.map +1 -0
- package/dist/{chunk-6T2GGYWE.js → chunk-4UJCXBR2.js} +4 -5800
- package/dist/chunk-4UJCXBR2.js.map +1 -0
- package/dist/{chunk-MWMXWHJD.js → chunk-7JCDSMX2.js} +2 -2
- package/dist/chunk-AJA2ZIUW.js +219 -0
- package/dist/chunk-AJA2ZIUW.js.map +1 -0
- package/dist/chunk-CDAT6EKW.js +247 -0
- package/dist/chunk-CDAT6EKW.js.map +1 -0
- package/dist/{chunk-DPONPYJD.js → chunk-CJI6G254.js} +70 -18
- package/dist/chunk-CJI6G254.js.map +1 -0
- package/dist/chunk-G32NVMRJ.js +276 -0
- package/dist/chunk-G32NVMRJ.js.map +1 -0
- package/dist/chunk-GABXCG3N.js +5811 -0
- package/dist/chunk-GABXCG3N.js.map +1 -0
- package/dist/{chunk-ERKVSPDX.js → chunk-LVY33EWL.js} +3 -3
- package/dist/{chunk-45CP2YKY.js → chunk-MAMBI2HR.js} +9 -3
- package/dist/{chunk-45CP2YKY.js.map → chunk-MAMBI2HR.js.map} +1 -1
- package/dist/{chunk-F73UKJY6.js → chunk-MN5PZMEK.js} +91 -108
- package/dist/chunk-MN5PZMEK.js.map +1 -0
- package/dist/chunk-PJI4MUZ7.js +131 -0
- package/dist/chunk-PJI4MUZ7.js.map +1 -0
- package/dist/{chunk-T6BWIGWJ.js → chunk-RIYHP2WU.js} +2 -2
- package/dist/{chunk-7HMK3B45.js → chunk-RL2MUXM3.js} +16 -7
- package/dist/chunk-RL2MUXM3.js.map +1 -0
- package/dist/{chunk-HQDVI2DB.js → chunk-SYKHLPTK.js} +4 -3
- package/dist/{chunk-HQDVI2DB.js.map → chunk-SYKHLPTK.js.map} +1 -1
- package/dist/{chunk-T6YLHJLS.js → chunk-XIXVVBW2.js} +198 -51
- package/dist/chunk-XIXVVBW2.js.map +1 -0
- package/dist/chunk-ZPJ6V2VG.js +156 -0
- package/dist/chunk-ZPJ6V2VG.js.map +1 -0
- package/dist/codex-capacity-recovery.d.ts +12 -0
- package/dist/codex-failure-eligibility.d.ts +9 -0
- package/dist/company-profile-schema.d.ts +4 -2
- package/dist/connect-attempts.d.ts +15 -0
- package/dist/connect-attempts.js +25 -0
- package/dist/connect-attempts.js.map +1 -0
- package/dist/connection-authority.d.ts +7 -63
- package/dist/connection-refresh-lock.d.ts +4 -0
- package/dist/connection-token-resolver.d.ts +8 -43
- package/dist/database-timing.d.ts +10 -0
- package/dist/database.d.ts +4 -0
- package/dist/editable-artifact-durable-export.js +2 -2
- package/dist/editable-artifacts.d.ts +9 -0
- package/dist/editable-artifacts.js +7 -5
- package/dist/index.d.ts +447 -78
- package/dist/index.js +12705 -12872
- package/dist/index.js.map +1 -1
- package/dist/insights-usage-bundle.d.ts +3 -0
- package/dist/integration-bindings.d.ts +1 -1
- package/dist/integration-facets.d.ts +18 -1
- package/dist/knowledge-entries-schema.d.ts +2 -0
- package/dist/knowledge-entries.d.ts +1 -0
- package/dist/knowledge-indexing.d.ts +1 -0
- package/dist/live-session-attempt.d.ts +35 -137
- package/dist/managed-auth-session-sets.js +3 -3
- package/dist/mcp-account-bindings.d.ts +4 -0
- package/dist/mcp-oauth.d.ts +11 -0
- package/dist/mcp-operations.js +2 -2
- package/dist/migrate.js +1 -1
- package/dist/organization-integration-policy.d.ts +51 -0
- package/dist/organization-integration-policy.js +18 -0
- package/dist/organization-integration-policy.js.map +1 -0
- package/dist/organization-usage.d.ts +20 -0
- package/dist/plugin-packages.d.ts +9 -12
- package/dist/pr-review.d.ts +0 -11
- package/dist/preference-registry-schema.d.ts +17 -0
- package/dist/provision-roles.js +1 -1
- package/dist/retained-provider-commands.d.ts +124 -6
- package/dist/retained-provider-commands.js +29 -97
- package/dist/retained-provider-commands.js.map +1 -1
- package/dist/retired-session-create-metadata.d.ts +4 -0
- package/dist/runtime-posture.d.ts +7 -5
- package/dist/schema.d.ts +876 -656
- package/dist/schema.js +5 -7
- package/dist/session-admission-block.d.ts +32 -0
- package/dist/session-attempt-writers.d.ts +4 -0
- package/dist/session-background-commands.js +5 -4
- package/dist/session-command-output.js +8 -126
- package/dist/session-command-output.js.map +1 -1
- package/dist/session-control.d.ts +5 -1
- package/dist/session-event-slices.d.ts +10 -0
- package/dist/session-event-slices.js +8 -222
- package/dist/session-event-slices.js.map +1 -1
- package/dist/session-file-attachments.d.ts +28 -0
- package/dist/session-goal-reports.d.ts +43 -0
- package/dist/session-mcp-approval.d.ts +4 -0
- package/dist/session-mcp-credential-rotation.js +5 -4
- package/dist/session-mcp-credential-rotation.js.map +1 -1
- package/dist/session-message-search.d.ts +22 -0
- package/dist/session-queue-commands.d.ts +2 -6
- package/dist/session-retry.d.ts +36 -0
- package/dist/session-tenancy.js +3 -3
- package/dist/skill-source-release-impact.d.ts +18 -0
- package/dist/skill-source-release.d.ts +9 -0
- package/dist/skills.d.ts +7 -1
- package/dist/user-resource-authority.d.ts +0 -8
- package/dist/video-generation.js +3 -3
- package/dist/workspace-tool-defaults.js +5 -4
- package/dist/workspace-tool-defaults.js.map +1 -1
- package/drizzle/0468_knowledge_relationship_projection.sql +30 -0
- package/drizzle/0469_knowledge_source_discovery.sql +85 -0
- package/drizzle/0470_organization_integration_policy.sql +151 -0
- package/drizzle/0471_usage_events_account_recent_index.sql +4 -0
- package/drizzle/0472_usage_events_workspace_recent_index.sql +4 -0
- package/drizzle/0473_organization_usage_analytical_capability.sql +237 -0
- package/drizzle/0474_goal_report_requirements.sql +156 -0
- package/drizzle/0475_session_event_history_statistics.sql +15 -0
- package/drizzle/0476_session_event_history_policy_planning.sql +29 -0
- package/drizzle/0477_managed_sign_in_methods.sql +303 -0
- package/drizzle/0478_sender_owned_connections.sql +2772 -0
- package/drizzle/0479_connection_create_idempotency.sql +16 -0
- package/drizzle/0480_private_session_organization_key_administration.sql +154 -0
- package/drizzle/0481_personal_connection_visibility_cleanup.sql +45 -0
- package/drizzle/0482_remove_packs.sql +417 -0
- package/drizzle/0483_preclaim_admission_block.sql +85 -0
- package/drizzle/0484_insights_usage_projection.sql +211 -0
- package/drizzle/0485_inherited_mcp_approval_policies.sql +6 -0
- package/drizzle/0486_reasoning_configuration_message_forks.sql +35 -0
- package/drizzle/0487_skill_catalog_message_forks.sql +26 -0
- package/drizzle/0488_permanent_skill_removal.sql +207 -0
- package/drizzle/0489_modal_command_byte_offsets.sql +17 -0
- package/drizzle/0490_periodic_capture_attempt_cadence.sql +6 -0
- package/drizzle/0491_warm_capture_holder_reclamation.sql +57 -0
- package/drizzle/0492_codex_accepted_source_authority.sql +249 -0
- package/drizzle/0493_stopping_command_error_containment.sql +58 -0
- package/drizzle/0494_mcp_account_bindings.sql +334 -0
- package/drizzle/0495_consented_sandbox_recovery.sql +220 -0
- package/drizzle/0496_supervised_command_settlement.sql +386 -0
- package/drizzle/0497_modal_inventory_owner_read_capability.sql +112 -0
- package/drizzle/0498_enrollment_membership_fence.sql +87 -0
- package/drizzle/0499_session_attachment_access.sql +224 -0
- package/drizzle/0500_session_execution_epoch.sql +37 -0
- package/drizzle/0501_session_sharing_execution.sql +591 -0
- package/drizzle/0502_active_message_boundary_forks.sql +30 -0
- package/package.json +17 -5
- package/src/automations.ts +17 -73
- package/src/canonical-human-identities.ts +17 -5
- package/src/capability-components.ts +7 -24
- package/src/capability-integrations.ts +301 -21
- package/src/capability-reconciliation.ts +19 -0
- package/src/codex-capacity-recovery.ts +47 -0
- package/src/codex-failure-eligibility.ts +93 -0
- package/src/connect-attempts.ts +49 -18
- package/src/connection-authority.ts +12 -158
- package/src/connection-refresh-lock.ts +22 -0
- package/src/connection-token-resolver.ts +58 -530
- package/src/database-timing.ts +43 -0
- package/src/database.ts +61 -26
- package/src/editable-artifacts.ts +1 -1
- package/src/index.ts +3578 -1273
- package/src/insights-model-bundle.ts +19 -7
- package/src/insights-usage-bundle.ts +16 -19
- package/src/integration-bindings.ts +2 -7
- package/src/integration-facets.ts +73 -6
- package/src/knowledge-entries.ts +8 -1
- package/src/live-session-attempt.ts +0 -22
- package/src/mcp-account-bindings.ts +12 -0
- package/src/mcp-oauth.ts +26 -0
- package/src/organization-integration-policy.ts +235 -0
- package/src/organization-usage.ts +83 -0
- package/src/plugin-packages.ts +226 -42
- package/src/pr-review.ts +7 -69
- package/src/preference-registry-schema.ts +1 -0
- package/src/provision-roles.ts +50 -37
- package/src/retained-provider-commands.ts +286 -9
- package/src/retired-session-create-metadata.ts +16 -0
- package/src/runtime-posture.ts +217 -13
- package/src/schema.ts +104 -120
- package/src/session-admission-block.ts +29 -0
- package/src/session-attempt-writers.ts +48 -0
- package/src/session-control.ts +21 -5
- package/src/session-event-slices.ts +76 -26
- package/src/session-file-attachments.ts +66 -0
- package/src/session-goal-reports.ts +255 -0
- package/src/session-mcp-approval.ts +30 -0
- package/src/session-message-search.ts +348 -0
- package/src/session-queue-commands.ts +60 -36
- package/src/session-retry.ts +319 -0
- package/src/skill-config-migration.ts +11 -2
- package/src/skill-source-release-impact.ts +33 -0
- package/src/skill-source-release.ts +67 -26
- package/src/skills.ts +44 -6
- package/src/user-resource-authority.ts +0 -56
- package/dist/chunk-6T2GGYWE.js.map +0 -1
- package/dist/chunk-7HMK3B45.js.map +0 -1
- package/dist/chunk-DPONPYJD.js.map +0 -1
- package/dist/chunk-F73UKJY6.js.map +0 -1
- package/dist/chunk-T6YLHJLS.js.map +0 -1
- package/dist/host-mcp-binding-match.d.ts +0 -5
- package/dist/host-mcp-bindings.d.ts +0 -79
- package/dist/host-mcp-resolvers.d.ts +0 -47
- package/dist/host-mcp-task-authority.d.ts +0 -43
- package/dist/host-selection-identity.d.ts +0 -6
- package/dist/pack-components.d.ts +0 -83
- package/dist/pack-installations.d.ts +0 -86
- package/src/host-mcp-binding-match.ts +0 -34
- package/src/host-mcp-bindings.ts +0 -777
- package/src/host-mcp-resolvers.ts +0 -266
- package/src/host-mcp-task-authority.ts +0 -384
- package/src/host-selection-identity.ts +0 -29
- package/src/pack-components.ts +0 -980
- package/src/pack-installations.ts +0 -950
- /package/dist/{chunk-MWMXWHJD.js.map → chunk-7JCDSMX2.js.map} +0 -0
- /package/dist/{chunk-ERKVSPDX.js.map → chunk-LVY33EWL.js.map} +0 -0
- /package/dist/{chunk-T6BWIGWJ.js.map → chunk-RIYHP2WU.js.map} +0 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
|
|
3
|
+
export type DatabaseTimingStage =
|
|
4
|
+
| "transaction_admission"
|
|
5
|
+
| "savepoint_admission"
|
|
6
|
+
| "rls_setup"
|
|
7
|
+
| "scoped_callback";
|
|
8
|
+
export type DatabaseTimingObservation = {
|
|
9
|
+
stage: DatabaseTimingStage;
|
|
10
|
+
outcome: "completed" | "failed";
|
|
11
|
+
durationMs: number;
|
|
12
|
+
};
|
|
13
|
+
export type DatabaseTimingObserver = (observation: DatabaseTimingObservation) => void;
|
|
14
|
+
|
|
15
|
+
const timingObserver = new AsyncLocalStorage<DatabaseTimingObserver>();
|
|
16
|
+
|
|
17
|
+
/** Opt-in, async-local diagnostics only; no identity or query payload is retained. */
|
|
18
|
+
export function withDatabaseTimingObserver<T>(
|
|
19
|
+
observer: DatabaseTimingObserver,
|
|
20
|
+
work: () => Promise<T>,
|
|
21
|
+
): Promise<T> {
|
|
22
|
+
return timingObserver.run(observer, work);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function startDatabaseTiming(
|
|
26
|
+
stage: DatabaseTimingStage,
|
|
27
|
+
): (outcome: DatabaseTimingObservation["outcome"]) => void {
|
|
28
|
+
const observer = timingObserver.getStore();
|
|
29
|
+
if (!observer) return () => undefined;
|
|
30
|
+
const started = performance.now();
|
|
31
|
+
let finished = false;
|
|
32
|
+
return (outcome) => {
|
|
33
|
+
if (finished) return;
|
|
34
|
+
finished = true;
|
|
35
|
+
try {
|
|
36
|
+
// Do not await observers or let rejected async observers escape either.
|
|
37
|
+
const result = observer({ stage, outcome, durationMs: performance.now() - started });
|
|
38
|
+
void Promise.resolve(result).catch(() => undefined);
|
|
39
|
+
} catch {
|
|
40
|
+
// Diagnostics must not replace database results or the original error.
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
package/src/database.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SessionAttachmentReadAccess } from "./session-file-attachments";
|
|
1
2
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
3
|
import { eq, sql, type SQL } from "drizzle-orm";
|
|
3
4
|
import type { PgDatabase, PgTransactionConfig } from "drizzle-orm/pg-core";
|
|
@@ -10,6 +11,7 @@ import {
|
|
|
10
11
|
} from "./persistence-errors";
|
|
11
12
|
import { LOSSLESS_CONTENT_WRITER_APPLICATION_NAME } from "./lossless-json";
|
|
12
13
|
import * as schema from "./schema";
|
|
14
|
+
import { startDatabaseTiming } from "./database-timing";
|
|
13
15
|
|
|
14
16
|
// §7.7 driver widening (Step I). `Database` is the structural, cross-driver
|
|
15
17
|
// query-layer port: every helper in this file accepts `db: Database` and uses
|
|
@@ -52,6 +54,8 @@ export type RlsContext = {
|
|
|
52
54
|
};
|
|
53
55
|
|
|
54
56
|
export type SessionRlsActorContext = {
|
|
57
|
+
/** Server-authorized session attachment scope; never taken from request JSON. */
|
|
58
|
+
sessionAttachmentReadAccess?: SessionAttachmentReadAccess;
|
|
55
59
|
subjectId: string;
|
|
56
60
|
/** Host-verified personal file ownership, never a request-supplied subject. */
|
|
57
61
|
privateFileOwnerSubjectId?: string | null;
|
|
@@ -59,6 +63,9 @@ export type SessionRlsActorContext = {
|
|
|
59
63
|
};
|
|
60
64
|
|
|
61
65
|
const sessionRlsActorContext = new AsyncLocalStorage<SessionRlsActorContext>();
|
|
66
|
+
export function currentSessionAttachmentReadAccess(): SessionAttachmentReadAccess | undefined {
|
|
67
|
+
return sessionRlsActorContext.getStore()?.sessionAttachmentReadAccess;
|
|
68
|
+
}
|
|
62
69
|
|
|
63
70
|
export async function withSessionRlsActorContext<T>(
|
|
64
71
|
actor: SessionRlsActorContext,
|
|
@@ -469,32 +476,60 @@ export async function withRlsContext<T>(
|
|
|
469
476
|
sessionTenancyFence: "shared" | "none" = "shared",
|
|
470
477
|
): Promise<T> {
|
|
471
478
|
const restoreParentScope = isTransactionHandle(db);
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
);
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
479
|
+
// Callback entry includes connection admission AND BEGIN/SAVEPOINT round-trip.
|
|
480
|
+
// This is deliberately not advertised as pure pool wait.
|
|
481
|
+
const admission = startDatabaseTiming(
|
|
482
|
+
restoreParentScope ? "savepoint_admission" : "transaction_admission",
|
|
483
|
+
);
|
|
484
|
+
try {
|
|
485
|
+
return await db.transaction(async (tx) => {
|
|
486
|
+
admission("completed");
|
|
487
|
+
const setup = startDatabaseTiming("rls_setup");
|
|
488
|
+
const scoped = tx as unknown as Database;
|
|
489
|
+
let parentScope: RlsContextSettings | null;
|
|
490
|
+
try {
|
|
491
|
+
parentScope = restoreParentScope ? await readRlsContextSettings(scoped) : null;
|
|
492
|
+
await setRlsContext(scoped, context);
|
|
493
|
+
if (context.workspaceId && sessionTenancyFence === "shared") {
|
|
494
|
+
await scoped.execute(
|
|
495
|
+
sql`select pg_advisory_xact_lock_shared(hashtextextended(${`session-tenancy:${context.workspaceId}`}, 0))`,
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
// Defense-in-depth: read the LOCAL GUC back on THIS backend BEFORE running
|
|
499
|
+
// the scoped query. The set_config and this read share one db.transaction,
|
|
500
|
+
// which a transaction pooler pins to a single backend — so a mismatch here
|
|
501
|
+
// means the context was genuinely lost (a torn transaction / pooler backend
|
|
502
|
+
// swap), not normal operation. Without this guard such an event runs the
|
|
503
|
+
// scoped read with an empty account_id and returns zero RLS-visible rows,
|
|
504
|
+
// manufacturing a phantom "no active subscription" from a credential that is
|
|
505
|
+
// in fact active. Convert that silent false into a loud, root-cause-bearing
|
|
506
|
+
// error so the caller can retry rather than permanently mis-decide.
|
|
507
|
+
await assertRlsContextApplied(scoped, context);
|
|
508
|
+
setup("completed");
|
|
509
|
+
} catch (error) {
|
|
510
|
+
setup("failed");
|
|
511
|
+
throw error;
|
|
512
|
+
}
|
|
513
|
+
const callback = startDatabaseTiming("scoped_callback");
|
|
514
|
+
let value: T;
|
|
515
|
+
try {
|
|
516
|
+
value = await fn(scoped);
|
|
517
|
+
callback("completed");
|
|
518
|
+
} catch (error) {
|
|
519
|
+
callback("failed");
|
|
520
|
+
throw error;
|
|
521
|
+
}
|
|
522
|
+
// A nested transaction is a savepoint, and SET LOCAL survives successful
|
|
523
|
+
// savepoint release. Restore only the tenant scope the nested helper owns;
|
|
524
|
+
// writer/protocol capabilities intentionally remain transaction-wide.
|
|
525
|
+
if (parentScope) await restoreRlsContextSettings(scoped, parentScope);
|
|
526
|
+
return value;
|
|
527
|
+
}, transactionConfig);
|
|
528
|
+
} catch (error) {
|
|
529
|
+
// No-op after callback entry; only admission failures are counted here.
|
|
530
|
+
admission("failed");
|
|
531
|
+
throw error;
|
|
532
|
+
}
|
|
498
533
|
}
|
|
499
534
|
|
|
500
535
|
/**
|
|
@@ -4760,7 +4760,7 @@ function persistedEditableArtifactActorKey(actor: PersistedEditableArtifactActor
|
|
|
4760
4760
|
}
|
|
4761
4761
|
}
|
|
4762
4762
|
|
|
4763
|
-
async function transactionallyAuthorizeEditableArtifactActor(
|
|
4763
|
+
export async function transactionallyAuthorizeEditableArtifactActor(
|
|
4764
4764
|
tx: Database,
|
|
4765
4765
|
input: Readonly<{
|
|
4766
4766
|
scope: PersistedEditableArtifactScope;
|