@opengeni/db 0.14.3 → 0.17.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/{chunk-Y5WZZVQK.js → chunk-SK7YYHBI.js} +5 -2
- package/dist/chunk-SK7YYHBI.js.map +1 -0
- package/dist/{chunk-ELMUCYZF.js → chunk-T6RSJT6C.js} +202 -43
- package/dist/chunk-T6RSJT6C.js.map +1 -0
- package/dist/chunk-TLAC622R.js +4990 -0
- package/dist/chunk-TLAC622R.js.map +1 -0
- package/dist/codex-token-resolver.d.ts +64 -0
- package/dist/connection-token-resolver.d.ts +90 -0
- package/dist/environment-crypto.d.ts +11 -0
- package/dist/event-payload-sanitizer.d.ts +32 -0
- package/dist/index.d.ts +6374 -10
- package/dist/index.js +8075 -2776
- package/dist/index.js.map +1 -1
- package/dist/insights.d.ts +157 -0
- package/dist/memory-domain.d.ts +44 -0
- package/dist/migrate.d.ts +5 -7
- package/dist/migrate.js +1 -1
- package/dist/new-session-drafts.d.ts +49 -0
- package/dist/persistence-errors.d.ts +69 -0
- package/dist/preference-registry-schema.d.ts +1147 -0
- package/dist/preference-registry.d.ts +878 -0
- package/dist/provision-roles.d.ts +4 -6489
- package/dist/provision-roles.js +1 -1
- package/dist/role-relationships.d.ts +35 -0
- package/dist/runtime-posture-cli.d.ts +1 -0
- package/dist/runtime-posture.d.ts +103 -0
- package/dist/schema.d.ts +25330 -3
- package/dist/schema.js +31 -1
- package/dist/session-control.d.ts +331 -0
- package/dist/session-queue-commands.d.ts +186 -0
- package/dist/session-tool-call-settlement.d.ts +32 -0
- package/dist/turn-initiator.d.ts +28 -0
- package/dist/workspace-artifacts.d.ts +62 -0
- package/dist/workspace-instruction-policies-schema.d.ts +735 -0
- package/dist/workspace-instruction-policies.d.ts +64 -0
- package/drizzle/0136_unified_session_tool_policy.sql +1 -1
- package/drizzle/0137_preference_registry.sql +1347 -0
- package/drizzle/0138_sandbox_checkpoint_artifacts_and_deadlines.sql +1074 -0
- package/drizzle/0139_codex_provider_artifact_invalidations.sql +51 -0
- package/drizzle/0140_sandbox_restore_and_reaper_fences.sql +276 -0
- package/drizzle/0142_sandbox_archive_capture_gate.sql +80 -0
- package/drizzle/0143_session_codex_compaction_mode.sql +20 -0
- package/drizzle/0144_sandbox_viewer_force_drain_gate.sql +95 -0
- package/drizzle/0145_model_call_facts.sql +96 -0
- package/drizzle/0146_slack_bot_delete_idempotency.sql +105 -0
- package/drizzle/0147_draft_latency_mode.sql +12 -0
- package/drizzle/0148_session_turn_latency_mode.sql +12 -0
- package/drizzle/0149_workspace_artifacts.sql +348 -0
- package/drizzle/0150_slack_task_interactions.sql +344 -0
- package/package.json +6 -6
- package/src/index.ts +5766 -275
- package/src/insights.ts +837 -0
- package/src/migrate.ts +9 -1
- package/src/new-session-drafts.ts +4 -0
- package/src/preference-registry-schema.ts +170 -0
- package/src/preference-registry.ts +1220 -0
- package/src/provision-roles.ts +95 -22
- package/src/role-relationships.ts +132 -0
- package/src/runtime-posture.ts +47 -27
- package/src/schema.ts +875 -19
- package/src/session-queue-commands.ts +39 -6
- package/src/workspace-artifacts.ts +751 -0
- package/dist/chunk-DW24CKCT.js +0 -4046
- package/dist/chunk-DW24CKCT.js.map +0 -1
- package/dist/chunk-ELMUCYZF.js.map +0 -1
- package/dist/chunk-Y5WZZVQK.js.map +0 -1
- package/dist/schema-DhkRhcuQ.d.ts +0 -22666
package/dist/provision-roles.js
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type RoleRelationshipDirection = "inherits" | "member";
|
|
2
|
+
export type RoleRelationshipCatalogRow = {
|
|
3
|
+
relationship: string;
|
|
4
|
+
direction: RoleRelationshipDirection;
|
|
5
|
+
server_version_num: number;
|
|
6
|
+
admin_option: boolean | null;
|
|
7
|
+
inherit_option: boolean | null;
|
|
8
|
+
set_option: boolean | null;
|
|
9
|
+
member_is_superuser: boolean | null;
|
|
10
|
+
member_can_create_role: boolean | null;
|
|
11
|
+
grantor_role: string | null;
|
|
12
|
+
grantor_is_superuser: boolean | null;
|
|
13
|
+
};
|
|
14
|
+
export type ClassifiedRoleRelationships = {
|
|
15
|
+
relationships: string[];
|
|
16
|
+
managementOnlyRelationships: string[];
|
|
17
|
+
unsafeRelationships: string[];
|
|
18
|
+
};
|
|
19
|
+
type RoleTargetExpression = "current_user" | "$1";
|
|
20
|
+
/**
|
|
21
|
+
* One PostgreSQL 15-compatible catalog query for both provisioning and runtime
|
|
22
|
+
* posture. PostgreSQL 16 added per-membership INHERIT and SET columns; reading
|
|
23
|
+
* the catalog row through to_jsonb keeps this statement parseable on 15 while
|
|
24
|
+
* leaving the missing options null and therefore fail-closed.
|
|
25
|
+
*/
|
|
26
|
+
export declare function roleRelationshipsCatalogQuery(targetRole: RoleTargetExpression): string;
|
|
27
|
+
/**
|
|
28
|
+
* PostgreSQL 16+ automatically gives a non-superuser CREATEROLE principal an
|
|
29
|
+
* ADMIN-only grant on a role it creates. The exact edge below permits role
|
|
30
|
+
* management but cannot inherit the app role's privileges or SET ROLE into it.
|
|
31
|
+
*/
|
|
32
|
+
export declare function isManagementOnlyRoleRelationship(row: RoleRelationshipCatalogRow): boolean;
|
|
33
|
+
/** Classify exact management-only reverse grants while rejecting every other edge. */
|
|
34
|
+
export declare function classifyRoleRelationships(rows: readonly RoleRelationshipCatalogRow[]): ClassifiedRoleRelationships;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { Database, RlsStrategy } from "./index";
|
|
2
|
+
/**
|
|
3
|
+
* The complete standalone tenant-table contract. Adding or removing a
|
|
4
|
+
* FORCE-RLS table is an architectural change: update this list in the same
|
|
5
|
+
* commit as the migration so startup cannot silently accept an unreviewed gap.
|
|
6
|
+
*/
|
|
7
|
+
export declare const FORCE_RLS_TABLES: readonly ["agent_run_states", "api_keys", "audit_events", "billing_customers", "capability_catalog_items", "capability_installations", "codex_capacity_waiters", "codex_credential_leases", "codex_reset_redemption_attempts", "codex_rotation_settings", "codex_subscription_credentials", "composer_drafts", "connections", "credit_ledger_entries", "device_enrollment_requests", "document_bases", "document_chunks", "documents", "enrollments", "file_uploads", "files", "github_installation_repositories", "github_installations", "host_export_config", "host_export_consumers", "host_export_cursor_state", "host_export_dead_letters", "host_export_outbox", "import_batches", "integration_oauth_state_nonces", "knowledge_memories", "machine_metrics_latest", "machine_metrics_series", "model_call_facts", "new_session_drafts", "pack_installations", "preference_registry_events", "preference_registry_preferences", "preference_registry_revisions", "preference_registry_snapshots", "rig_changes", "rig_versions", "rigs", "sandbox_checkpoint_artifacts", "sandbox_lease_holders", "sandbox_leases", "sandbox_pty_sessions", "sandbox_retained_processes", "sandbox_session_envelopes", "sandbox_workspace_mutation_admissions", "sandboxes", "scheduled_task_runs", "scheduled_tasks", "session_attempt_interruptions", "session_command_receipts", "session_events", "session_goals", "session_history_items", "session_human_input_requests", "session_list_snapshots", "session_mcp_servers", "session_pending_tool_calls", "session_pins", "session_recordings", "session_spawn_denials", "session_stream_acknowledgments", "session_system_update_outbox", "session_system_updates", "session_turn_attempts", "session_turns", "session_workflow_wake_outbox", "sessions", "slack_bot_delete_operations", "slack_bot_post_operations", "slack_bot_user_links", "slack_interaction_inbox", "slack_interaction_progress_deliveries", "slack_interactions", "social_connections", "social_posts", "usage_events", "workspace_artifact_events", "workspace_artifact_versions", "workspace_artifacts", "workspace_captures", "workspace_control_events", "workspace_inference_controls", "workspace_instruction_policy_activation_events", "workspace_instruction_policy_heads", "workspace_instruction_policy_revisions", "workspace_model_policies", "workspace_packs", "workspace_session_activity_revisions", "workspace_variable_set_variables", "workspace_variable_sets"];
|
|
8
|
+
/**
|
|
9
|
+
* Deployment-global and authentication tables used by ordinary API/worker
|
|
10
|
+
* traffic. They intentionally do not carry workspace RLS: their access model
|
|
11
|
+
* is implemented by the authentication/access layer or by exact global keys.
|
|
12
|
+
*/
|
|
13
|
+
export declare const NON_RLS_RUNTIME_TABLES: readonly ["auth_identities", "auth_rate_limits", "auth_sessions", "auth_users", "auth_verifications", "integration_oauth_clients", "managed_accounts", "nested_agent_depth_configuration", "stripe_webhook_events", "workspace_memberships", "workspaces"];
|
|
14
|
+
/**
|
|
15
|
+
* Exact full-CRUD class for the standalone runtime role. This is deliberately
|
|
16
|
+
* explicit instead of being derived from FORCE_RLS_TABLES: adding a protected
|
|
17
|
+
* table must not silently grant it broader DML than its migration intended.
|
|
18
|
+
*/
|
|
19
|
+
export declare const RUNTIME_FULL_DML_TABLES: readonly ["agent_run_states", "api_keys", "audit_events", "auth_identities", "auth_rate_limits", "auth_sessions", "auth_users", "auth_verifications", "billing_customers", "capability_catalog_items", "capability_installations", "codex_capacity_waiters", "codex_credential_leases", "codex_reset_redemption_attempts", "codex_rotation_settings", "codex_subscription_credentials", "composer_drafts", "connections", "credit_ledger_entries", "device_enrollment_requests", "document_bases", "document_chunks", "documents", "enrollments", "file_uploads", "files", "github_installation_repositories", "github_installations", "import_batches", "integration_oauth_clients", "integration_oauth_state_nonces", "knowledge_memories", "machine_metrics_latest", "machine_metrics_series", "managed_accounts", "model_call_facts", "new_session_drafts", "pack_installations", "rig_changes", "rig_versions", "rigs", "sandbox_checkpoint_artifacts", "sandbox_lease_holders", "sandbox_leases", "sandbox_pty_sessions", "sandbox_retained_processes", "sandbox_session_envelopes", "sandbox_workspace_mutation_admissions", "sandboxes", "scheduled_task_runs", "scheduled_tasks", "session_attempt_interruptions", "session_command_receipts", "session_events", "session_goals", "session_history_items", "session_human_input_requests", "session_list_snapshots", "session_mcp_servers", "session_pending_tool_calls", "session_pins", "session_recordings", "session_stream_acknowledgments", "session_system_update_outbox", "session_system_updates", "session_turn_attempts", "session_turns", "session_workflow_wake_outbox", "sessions", "slack_bot_delete_operations", "slack_bot_post_operations", "slack_bot_user_links", "slack_interaction_inbox", "slack_interaction_progress_deliveries", "slack_interactions", "social_connections", "social_posts", "stripe_webhook_events", "usage_events", "workspace_artifacts", "workspace_captures", "workspace_control_events", "workspace_inference_controls", "workspace_instruction_policy_heads", "workspace_memberships", "workspace_model_policies", "workspace_packs", "workspace_session_activity_revisions", "workspace_variable_set_variables", "workspace_variable_sets", "workspaces"];
|
|
20
|
+
/** Configuration and lifecycle-owned audit rows are read-only at runtime. */
|
|
21
|
+
export declare const RUNTIME_READ_ONLY_TABLES: readonly ["nested_agent_depth_configuration", "preference_registry_events", "preference_registry_snapshots"];
|
|
22
|
+
/** Append-only evidence/revision tables are insertable and queryable, never mutable. */
|
|
23
|
+
export declare const RUNTIME_READ_INSERT_TABLES: readonly ["preference_registry_preferences", "preference_registry_revisions", "session_spawn_denials", "workspace_artifact_events", "workspace_artifact_versions", "workspace_instruction_policy_activation_events", "workspace_instruction_policy_revisions"];
|
|
24
|
+
/**
|
|
25
|
+
* These FORCE-RLS tables are owned by security-definer host-export routines.
|
|
26
|
+
* The ordinary application role must have no direct table privileges on them.
|
|
27
|
+
*/
|
|
28
|
+
export declare const PROTECTED_NO_DIRECT_DML_TABLES: readonly ["host_export_config", "host_export_consumers", "host_export_cursor_state", "host_export_dead_letters", "host_export_outbox"];
|
|
29
|
+
export type RuntimeTableDmlPrivilege = "SELECT" | "INSERT" | "UPDATE" | "DELETE";
|
|
30
|
+
export type RuntimeTablePrivilegeContract = Readonly<Record<string, readonly RuntimeTableDmlPrivilege[]>>;
|
|
31
|
+
/** Exact per-table DML contract. Absence means no direct table privileges. */
|
|
32
|
+
export declare const RUNTIME_TABLE_PRIVILEGES: RuntimeTablePrivilegeContract;
|
|
33
|
+
/** All tables with any direct runtime DML; retained as the aggregate public contract. */
|
|
34
|
+
export declare const RUNTIME_DML_TABLES: readonly string[];
|
|
35
|
+
export type RuntimeDatabasePostureOptions = {
|
|
36
|
+
rlsStrategy: RlsStrategy;
|
|
37
|
+
expectedRole?: string;
|
|
38
|
+
targetSchema?: string;
|
|
39
|
+
protectedTables?: readonly string[];
|
|
40
|
+
tablePrivileges?: RuntimeTablePrivilegeContract;
|
|
41
|
+
protectedNoDirectDmlTables?: readonly string[];
|
|
42
|
+
};
|
|
43
|
+
export type RuntimeDatabaseIdentity = {
|
|
44
|
+
currentUser: string;
|
|
45
|
+
sessionUser: string;
|
|
46
|
+
databaseOwner: string;
|
|
47
|
+
canConnectDatabase: boolean;
|
|
48
|
+
canCreateInDatabase: boolean;
|
|
49
|
+
rowSecurity: string;
|
|
50
|
+
canLogin: boolean;
|
|
51
|
+
superuser: boolean;
|
|
52
|
+
inherit: boolean;
|
|
53
|
+
createRole: boolean;
|
|
54
|
+
createDatabase: boolean;
|
|
55
|
+
replication: boolean;
|
|
56
|
+
bypassRls: boolean;
|
|
57
|
+
};
|
|
58
|
+
export type RuntimeSchemaPosture = {
|
|
59
|
+
name: string;
|
|
60
|
+
owner: string;
|
|
61
|
+
usage: boolean;
|
|
62
|
+
create: boolean;
|
|
63
|
+
};
|
|
64
|
+
export type RuntimeTablePosture = {
|
|
65
|
+
name: string;
|
|
66
|
+
owner: string;
|
|
67
|
+
rlsEnabled: boolean;
|
|
68
|
+
rlsForced: boolean;
|
|
69
|
+
rlsActive: boolean;
|
|
70
|
+
policyCount: number;
|
|
71
|
+
select: boolean;
|
|
72
|
+
insert: boolean;
|
|
73
|
+
update: boolean;
|
|
74
|
+
delete: boolean;
|
|
75
|
+
truncate: boolean;
|
|
76
|
+
references: boolean;
|
|
77
|
+
trigger: boolean;
|
|
78
|
+
};
|
|
79
|
+
export type RuntimeRoutinePosture = {
|
|
80
|
+
name: string;
|
|
81
|
+
owner: string;
|
|
82
|
+
execute: boolean;
|
|
83
|
+
};
|
|
84
|
+
export type RuntimeDatabasePosture = {
|
|
85
|
+
identity: RuntimeDatabaseIdentity;
|
|
86
|
+
/** Privilege-bearing role relationships; exact PG16+ management-only grants are excluded. */
|
|
87
|
+
memberships: string[];
|
|
88
|
+
schemas: RuntimeSchemaPosture[];
|
|
89
|
+
ownedSchemas: string[];
|
|
90
|
+
ownedRelations: string[];
|
|
91
|
+
tables: RuntimeTablePosture[];
|
|
92
|
+
privateRoutines: RuntimeRoutinePosture[];
|
|
93
|
+
};
|
|
94
|
+
export declare class RuntimeDatabasePostureError extends Error {
|
|
95
|
+
readonly violations: readonly string[];
|
|
96
|
+
constructor(violations: readonly string[]);
|
|
97
|
+
}
|
|
98
|
+
/** Inspect only PostgreSQL catalogs and privilege functions; no tenant rows. */
|
|
99
|
+
export declare function inspectRuntimeDatabasePosture(db: Database, options: RuntimeDatabasePostureOptions): Promise<RuntimeDatabasePosture>;
|
|
100
|
+
/** Pure deterministic evaluator used by startup/readiness and unit tests. */
|
|
101
|
+
export declare function evaluateRuntimeDatabasePosture(posture: RuntimeDatabasePosture, options: RuntimeDatabasePostureOptions): string[];
|
|
102
|
+
export declare function assertRuntimeDatabasePosture(db: Database, options: RuntimeDatabasePostureOptions): Promise<RuntimeDatabasePosture>;
|
|
103
|
+
export declare function runtimeDatabaseReadyCheck(db: Database, options: RuntimeDatabasePostureOptions): () => Promise<void>;
|