@opengeni/db 0.14.0 → 0.16.2

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.
Files changed (63) hide show
  1. package/dist/{chunk-ELMUCYZF.js → chunk-4RUK5CON.js} +183 -42
  2. package/dist/chunk-4RUK5CON.js.map +1 -0
  3. package/dist/chunk-HZD7KVAR.js +4648 -0
  4. package/dist/chunk-HZD7KVAR.js.map +1 -0
  5. package/dist/{chunk-Y5WZZVQK.js → chunk-SK7YYHBI.js} +5 -2
  6. package/dist/chunk-SK7YYHBI.js.map +1 -0
  7. package/dist/codex-token-resolver.d.ts +64 -0
  8. package/dist/connection-token-resolver.d.ts +90 -0
  9. package/dist/environment-crypto.d.ts +11 -0
  10. package/dist/event-payload-sanitizer.d.ts +32 -0
  11. package/dist/index.d.ts +6217 -10
  12. package/dist/index.js +6992 -2728
  13. package/dist/index.js.map +1 -1
  14. package/dist/insights.d.ts +157 -0
  15. package/dist/memory-domain.d.ts +44 -0
  16. package/dist/migrate.d.ts +5 -7
  17. package/dist/migrate.js +1 -1
  18. package/dist/new-session-drafts.d.ts +49 -0
  19. package/dist/persistence-errors.d.ts +69 -0
  20. package/dist/preference-registry-schema.d.ts +1147 -0
  21. package/dist/preference-registry.d.ts +878 -0
  22. package/dist/provision-roles.d.ts +4 -6478
  23. package/dist/provision-roles.js +1 -1
  24. package/dist/role-relationships.d.ts +35 -0
  25. package/dist/runtime-posture-cli.d.ts +1 -0
  26. package/dist/runtime-posture.d.ts +103 -0
  27. package/dist/schema.d.ts +23533 -3
  28. package/dist/schema.js +17 -1
  29. package/dist/session-control.d.ts +331 -0
  30. package/dist/session-queue-commands.d.ts +186 -0
  31. package/dist/session-tool-call-settlement.d.ts +32 -0
  32. package/dist/turn-initiator.d.ts +28 -0
  33. package/dist/workspace-instruction-policies-schema.d.ts +735 -0
  34. package/dist/workspace-instruction-policies.d.ts +64 -0
  35. package/drizzle/0136_unified_session_tool_policy.sql +109 -0
  36. package/drizzle/0137_preference_registry.sql +1347 -0
  37. package/drizzle/0138_sandbox_checkpoint_artifacts_and_deadlines.sql +1074 -0
  38. package/drizzle/0139_codex_provider_artifact_invalidations.sql +51 -0
  39. package/drizzle/0140_sandbox_restore_and_reaper_fences.sql +276 -0
  40. package/drizzle/0142_sandbox_archive_capture_gate.sql +80 -0
  41. package/drizzle/0143_session_codex_compaction_mode.sql +20 -0
  42. package/drizzle/0144_sandbox_viewer_force_drain_gate.sql +95 -0
  43. package/drizzle/0145_model_call_facts.sql +96 -0
  44. package/drizzle/0146_slack_bot_delete_idempotency.sql +105 -0
  45. package/drizzle/0147_draft_latency_mode.sql +12 -0
  46. package/drizzle/0148_session_turn_latency_mode.sql +12 -0
  47. package/package.json +6 -6
  48. package/src/index.ts +5095 -430
  49. package/src/insights.ts +837 -0
  50. package/src/migrate.ts +9 -1
  51. package/src/new-session-drafts.ts +4 -0
  52. package/src/preference-registry-schema.ts +170 -0
  53. package/src/preference-registry.ts +1220 -0
  54. package/src/provision-roles.ts +95 -22
  55. package/src/role-relationships.ts +132 -0
  56. package/src/runtime-posture.ts +28 -26
  57. package/src/schema.ts +484 -12
  58. package/src/session-queue-commands.ts +47 -46
  59. package/dist/chunk-ELMUCYZF.js.map +0 -1
  60. package/dist/chunk-PQKVUWQW.js +0 -4047
  61. package/dist/chunk-PQKVUWQW.js.map +0 -1
  62. package/dist/chunk-Y5WZZVQK.js.map +0 -1
  63. package/dist/schema-FoPub9yt.d.ts +0 -22666
@@ -0,0 +1,105 @@
1
+ -- deployment-mode: rolling
2
+ -- Slack chat.delete has no provider idempotency key. Persist the exact tenant,
3
+ -- principal, connection, tool, target, and protected request digest before the
4
+ -- mutation; an abandoned provider_started claim becomes outcome_unknown and is
5
+ -- reconciled before another delete is admitted.
6
+ --
7
+ -- This migration originally landed as 0141 after 0142 was already deployed.
8
+ -- Never rewrite that production history. A staging database may have applied
9
+ -- the withdrawn 0141 name before the ordering defect was caught; only that
10
+ -- exact committed legacy receipt may make an existing table idempotent here.
11
+
12
+ DO $migration$
13
+ BEGIN
14
+ IF to_regclass('slack_bot_delete_operations') IS NOT NULL
15
+ AND NOT EXISTS (
16
+ SELECT 1
17
+ FROM "schema_migrations"
18
+ WHERE "name" = '0141_slack_bot_delete_idempotency.sql'
19
+ )
20
+ THEN
21
+ RAISE EXCEPTION
22
+ 'slack_bot_delete_operations exists without the exact withdrawn 0141 migration receipt';
23
+ END IF;
24
+ END
25
+ $migration$;
26
+
27
+ CREATE TABLE IF NOT EXISTS "slack_bot_delete_operations" (
28
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
29
+ "account_id" uuid NOT NULL REFERENCES "managed_accounts"("id") ON DELETE CASCADE,
30
+ "workspace_id" uuid NOT NULL REFERENCES "workspaces"("id") ON DELETE CASCADE,
31
+ "connection_id" uuid NOT NULL REFERENCES "connections"("id") ON DELETE CASCADE,
32
+ "operation_id" uuid NOT NULL,
33
+ "principal_type" text NOT NULL,
34
+ "principal_id" text NOT NULL,
35
+ "tool_name" text NOT NULL,
36
+ "channel_id" text NOT NULL,
37
+ "message_timestamp" text NOT NULL,
38
+ "request_digest" text NOT NULL,
39
+ "status" text NOT NULL,
40
+ "claim_holder_id" uuid,
41
+ "claim_expires_at" timestamptz,
42
+ "attempt_count" integer NOT NULL DEFAULT 0,
43
+ "last_failure_code" text,
44
+ "slack_channel_id" text,
45
+ "slack_message_timestamp" text,
46
+ "completed_at" timestamptz,
47
+ "created_at" timestamptz NOT NULL DEFAULT now(),
48
+ "updated_at" timestamptz NOT NULL DEFAULT now(),
49
+ CONSTRAINT "slack_bot_delete_operations_workspace_operation_uq"
50
+ UNIQUE ("workspace_id", "operation_id"),
51
+ CONSTRAINT "slack_bot_delete_operations_principal_check"
52
+ CHECK (
53
+ "principal_type" IN ('subject', 'service')
54
+ AND length("principal_id") BETWEEN 1 AND 512
55
+ ),
56
+ CONSTRAINT "slack_bot_delete_operations_identity_check"
57
+ CHECK (
58
+ "tool_name" = 'slack_bot_delete_message'
59
+ AND length("channel_id") BETWEEN 1 AND 64
60
+ AND length("message_timestamp") BETWEEN 1 AND 64
61
+ AND "request_digest" ~ '^[0-9a-f]{64}$'
62
+ AND "attempt_count" > 0
63
+ AND (("claim_holder_id" IS NULL) = ("claim_expires_at" IS NULL))
64
+ ),
65
+ CONSTRAINT "slack_bot_delete_operations_status_check"
66
+ CHECK ("status" IN ('pending', 'provider_started', 'outcome_unknown', 'completed')),
67
+ CONSTRAINT "slack_bot_delete_operations_completion_check"
68
+ CHECK (
69
+ (
70
+ "status" <> 'completed'
71
+ AND "slack_channel_id" IS NULL
72
+ AND "slack_message_timestamp" IS NULL
73
+ AND "completed_at" IS NULL
74
+ )
75
+ OR (
76
+ "status" = 'completed'
77
+ AND "claim_holder_id" IS NULL
78
+ AND "claim_expires_at" IS NULL
79
+ AND "slack_channel_id" IS NOT NULL
80
+ AND "slack_message_timestamp" IS NOT NULL
81
+ AND "completed_at" IS NOT NULL
82
+ )
83
+ )
84
+ );
85
+
86
+ CREATE INDEX IF NOT EXISTS "slack_bot_delete_operations_workspace_status_idx"
87
+ ON "slack_bot_delete_operations" ("workspace_id", "status", "updated_at");
88
+
89
+ ALTER TABLE "slack_bot_delete_operations" ENABLE ROW LEVEL SECURITY;
90
+ ALTER TABLE "slack_bot_delete_operations" FORCE ROW LEVEL SECURITY;
91
+ DO $migration$
92
+ BEGIN
93
+ IF NOT EXISTS (
94
+ SELECT 1
95
+ FROM pg_policy
96
+ WHERE polrelid = 'slack_bot_delete_operations'::regclass
97
+ AND polname = 'workspace_isolation'
98
+ )
99
+ THEN
100
+ CREATE POLICY workspace_isolation ON "slack_bot_delete_operations"
101
+ USING (opengeni_private.workspace_rls_visible("account_id", "workspace_id"))
102
+ WITH CHECK (opengeni_private.workspace_rls_visible("account_id", "workspace_id"));
103
+ END IF;
104
+ END
105
+ $migration$;
@@ -0,0 +1,12 @@
1
+ -- deployment-mode: rolling
2
+ -- Draft latency selection is additive; existing rows remain Standard.
3
+
4
+ ALTER TABLE composer_drafts
5
+ ADD COLUMN latency_mode text NOT NULL DEFAULT 'standard',
6
+ ADD CONSTRAINT composer_drafts_latency_mode_check
7
+ CHECK (latency_mode IN ('standard', 'priority', 'fast'));
8
+
9
+ ALTER TABLE new_session_drafts
10
+ ADD COLUMN latency_mode text NOT NULL DEFAULT 'standard',
11
+ ADD CONSTRAINT new_session_drafts_latency_mode_check
12
+ CHECK (latency_mode IN ('standard', 'priority', 'fast'));
@@ -0,0 +1,12 @@
1
+ -- deployment-mode: rolling
2
+ -- Per-turn latency mode is the durable peer of model + reasoning_effort.
3
+ -- Existing rows default to Standard; backfill from frozen turn execution policy.
4
+
5
+ ALTER TABLE session_turns
6
+ ADD COLUMN latency_mode text NOT NULL DEFAULT 'standard',
7
+ ADD CONSTRAINT session_turns_latency_mode_check
8
+ CHECK (latency_mode IN ('standard', 'priority', 'fast'));
9
+
10
+ UPDATE session_turns
11
+ SET latency_mode = metadata->'turnExecutionPolicyV1'->>'latencyMode'
12
+ WHERE metadata->'turnExecutionPolicyV1'->>'latencyMode' IN ('standard', 'priority', 'fast');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeni/db",
3
- "version": "0.14.0",
3
+ "version": "0.16.2",
4
4
  "description": "OpenGeni persistence: Drizzle schema, RLS-scoped query layer, the SQL migration runner, and role provisioning.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -45,14 +45,14 @@
45
45
  "migrate": "bun src/migrate.ts",
46
46
  "provision-roles": "bun src/provision-roles.ts",
47
47
  "assert-runtime-posture": "bun src/runtime-posture-cli.ts",
48
- "typecheck": "tsgo --noEmit",
49
- "build": "tsup",
48
+ "typecheck": "tsc --noEmit",
49
+ "build": "bun ../../scripts/build-typescript-package.ts",
50
50
  "prepublishOnly": "bash ../../scripts/prepublish-guard"
51
51
  },
52
52
  "dependencies": {
53
- "@opengeni/codex": "^0.2.7",
54
- "@opengeni/config": "^0.7.11",
55
- "@opengeni/contracts": "^0.22.0",
53
+ "@opengeni/codex": "^0.2.9",
54
+ "@opengeni/config": "^0.7.22",
55
+ "@opengeni/contracts": "^0.26.1",
56
56
  "@opengeni/network": "^0.1.1",
57
57
  "drizzle-orm": "^0.45.2",
58
58
  "postgres": "^3.4.7"