@opengeni/db 1.0.1 → 3.2.0-canary.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.
Files changed (271) hide show
  1. package/dist/attached-browser-devices.d.ts +7 -0
  2. package/dist/automations.d.ts +154 -0
  3. package/dist/canonical-human-identities.js +3 -3
  4. package/dist/capability-integrations.d.ts +13 -0
  5. package/dist/child-lifecycle-notices.d.ts +68 -0
  6. package/dist/{chunk-4SR4HKKA.js → chunk-2EH4WRHL.js} +19 -11
  7. package/dist/chunk-2EH4WRHL.js.map +1 -0
  8. package/dist/{chunk-CUPM3FGB.js → chunk-2PRS4J5Q.js} +3 -3
  9. package/dist/chunk-6HMM2R5T.js +390 -0
  10. package/dist/chunk-6HMM2R5T.js.map +1 -0
  11. package/dist/{chunk-ZWREYEWA.js → chunk-AZHW7R5V.js} +56 -11
  12. package/dist/chunk-AZHW7R5V.js.map +1 -0
  13. package/dist/{chunk-LTG3S6ZY.js → chunk-E6CLMKEE.js} +2 -2
  14. package/dist/{chunk-6ZYKCRFO.js → chunk-KRLPEMLH.js} +7591 -4417
  15. package/dist/chunk-KRLPEMLH.js.map +1 -0
  16. package/dist/chunk-NAB6FKFN.js +516 -0
  17. package/dist/chunk-NAB6FKFN.js.map +1 -0
  18. package/dist/{chunk-SK7YYHBI.js → chunk-SIBYBA2D.js} +46 -1
  19. package/dist/chunk-SIBYBA2D.js.map +1 -0
  20. package/dist/chunk-UZNXG44K.js +4508 -0
  21. package/dist/chunk-UZNXG44K.js.map +1 -0
  22. package/dist/codemode-operations.d.ts +1 -6
  23. package/dist/company-brain-context-selection-schema.d.ts +705 -0
  24. package/dist/company-brain-context-selection.d.ts +94 -0
  25. package/dist/company-brain-governed-writes.d.ts +24 -0
  26. package/dist/company-brain.d.ts +55 -0
  27. package/dist/company-profile-agent-admin.d.ts +15 -0
  28. package/dist/company-profile-schema.d.ts +619 -2
  29. package/dist/company-profile.d.ts +9 -4
  30. package/dist/connection-authority.d.ts +95 -0
  31. package/dist/connection-scopes.d.ts +8 -0
  32. package/dist/connection-tenancy-backfill.d.ts +85 -0
  33. package/dist/connection-token-resolver.d.ts +30 -1
  34. package/dist/database.d.ts +23 -4
  35. package/dist/editable-artifact-durable-export.js +2 -2
  36. package/dist/editable-artifacts.d.ts +2 -2
  37. package/dist/editable-artifacts.js +3 -3
  38. package/dist/governed-learning-activation-schema.d.ts +984 -0
  39. package/dist/governed-learning-activation.d.ts +98 -0
  40. package/dist/governed-learning-evaluator-schema.d.ts +633 -0
  41. package/dist/governed-learning-evaluator.d.ts +28 -0
  42. package/dist/index.d.ts +1606 -81
  43. package/dist/index.js +21898 -8147
  44. package/dist/index.js.map +1 -1
  45. package/dist/insights.d.ts +18 -0
  46. package/dist/integration-bindings.d.ts +1 -0
  47. package/dist/integration-facets.d.ts +30 -0
  48. package/dist/interaction-placement-loss.d.ts +22 -0
  49. package/dist/managed-human-provisioning.d.ts +25 -0
  50. package/dist/memory-domain.d.ts +3 -3
  51. package/dist/migrate.d.ts +11 -1
  52. package/dist/migrate.js +1 -1
  53. package/dist/new-session-drafts.d.ts +43 -5
  54. package/dist/organization-membership-backfill.d.ts +174 -0
  55. package/dist/organization-membership-lifecycle.d.ts +162 -0
  56. package/dist/pr-review.d.ts +107 -0
  57. package/dist/preference-registry-schema.d.ts +2 -0
  58. package/dist/preference-registry.d.ts +2 -0
  59. package/dist/provision-roles.js +1 -1
  60. package/dist/runtime-posture.d.ts +29 -8
  61. package/dist/schema.d.ts +24914 -13703
  62. package/dist/schema.js +99 -1
  63. package/dist/scoped-knowledge-schema.d.ts +52 -1
  64. package/dist/session-background-commands.d.ts +125 -0
  65. package/dist/session-background-commands.js +34 -0
  66. package/dist/session-background-commands.js.map +1 -0
  67. package/dist/session-control.d.ts +156 -3
  68. package/dist/session-goal-pacing.d.ts +68 -0
  69. package/dist/session-queue-commands.d.ts +43 -4
  70. package/dist/session-realtime-ledger.d.ts +2 -0
  71. package/dist/session-tenancy.d.ts +71 -1
  72. package/dist/session-tenancy.js +25 -3
  73. package/dist/session-tool-call-settlement.d.ts +9 -4
  74. package/dist/slack-routing-personal-workspace.d.ts +23 -0
  75. package/dist/slack-routing.d.ts +268 -0
  76. package/dist/slack-task-policy-schema.d.ts +34 -0
  77. package/dist/slack-task-policy.d.ts +8 -0
  78. package/dist/slack-user-link-access.d.ts +28 -0
  79. package/dist/task-notes-schema.d.ts +594 -0
  80. package/dist/task-notes.d.ts +39 -0
  81. package/dist/turn-initiator.d.ts +2 -0
  82. package/dist/user-resource-authority.d.ts +109 -0
  83. package/dist/video-generation.js +3 -3
  84. package/dist/workspace-authority.d.ts +81 -0
  85. package/dist/workspace-instruction-policies-schema.d.ts +279 -0
  86. package/dist/workspace-instruction-policies.d.ts +62 -0
  87. package/dist/workspace-learning-policy.d.ts +1 -0
  88. package/dist/workspace-membership-permissions.d.ts +2 -0
  89. package/drizzle/0240_enrollment_connection_authority.sql +39 -0
  90. package/drizzle/0241_atomic_personal_resource_delegation.sql +1000 -0
  91. package/drizzle/0241_enrollment_agent_runtime.sql +70 -0
  92. package/drizzle/0244_slack_app_home_refresh_queue.sql +120 -0
  93. package/drizzle/0245_model_context_contribution_facts.sql +88 -0
  94. package/drizzle/0246_integration_personal_instance_authority.sql +70 -0
  95. package/drizzle/0247_terraform_stacks_provenance_repair.sql +428 -0
  96. package/drizzle/0248_terraform_stacks_component_resolution_fence.sql +83 -0
  97. package/drizzle/0249_personal_resource_delegation_authority_correction.sql +662 -0
  98. package/drizzle/0250_direct_retained_process_owner_liveness.sql +199 -0
  99. package/drizzle/0251_connected_machine_operation_policy.sql +45 -0
  100. package/drizzle/0252_scheduled_personal_resource_delegation.sql +1867 -0
  101. package/drizzle/0253_common_user_resource_authority_lifecycle.sql +1555 -0
  102. package/drizzle/0254_scoped_variable_set_authority.sql +1255 -0
  103. package/drizzle/0255_company_brain_governed_write_proposals.sql +524 -0
  104. package/drizzle/0256_connection_authority_delegation.sql +703 -0
  105. package/drizzle/0257_goal_revision_decisions_and_root_constraints.sql +436 -0
  106. package/drizzle/0258_three_scope_document_knowledge_authority.sql +1273 -0
  107. package/drizzle/0259_company_brain_context_selection_receipts.sql +869 -0
  108. package/drizzle/0260_task_note_knowledge_promotion.sql +820 -0
  109. package/drizzle/0261_preference_knowledge_proposal_actor_binding.sql +471 -0
  110. package/drizzle/0262_scoped_connected_machines_and_rigs.sql +1700 -0
  111. package/drizzle/0263_organization_membership_lifecycle.sql +3284 -0
  112. package/drizzle/0264_connection_authority_runtime_activation.sql +1084 -0
  113. package/drizzle/0266_company_brain_context_receipt_inspection.sql +156 -0
  114. package/drizzle/0268_governed_learning_decision_receipts.sql +825 -0
  115. package/drizzle/0269_governed_learning_activation_controller.sql +1874 -0
  116. package/drizzle/0270_governed_learning_history_inspection.sql +170 -0
  117. package/drizzle/0271_company_brain_retrieval_only_default.sql +524 -0
  118. package/drizzle/0272_human_confirmed_learning_activation.sql +591 -0
  119. package/drizzle/0273_scheduled_variable_set_materialization.sql +268 -0
  120. package/drizzle/0274_human_confirmed_knowledge_review.sql +310 -0
  121. package/drizzle/0275_scheduled_connection_authority.sql +5527 -0
  122. package/drizzle/0276_onboarding_proposal_initiating_human_guc.sql +198 -0
  123. package/drizzle/0277_workspace_writer_authority_attribution.sql +393 -0
  124. package/drizzle/0278_workspace_membership_removal_fencing.sql +1174 -0
  125. package/drizzle/0279_workspace_connection_use_lane.sql +343 -0
  126. package/drizzle/0280_connection_and_variable_set_audit_attribution.sql +773 -0
  127. package/drizzle/0281_viewer_holder_authority_claims.sql +52 -0
  128. package/drizzle/0282_variable_set_session_attach_attribution.sql +178 -0
  129. package/drizzle/0283_editable_spreadsheet_authored_state.sql +82 -0
  130. package/drizzle/0284_truthful_human_confirmed_review_reason.sql +930 -0
  131. package/drizzle/0285_organization_tenancy_inventory.sql +329 -0
  132. package/drizzle/0286_widen_task_note_expiry_ceiling.sql +391 -0
  133. package/drizzle/0287_open_suffix_pending_tool_calls.sql +18 -0
  134. package/drizzle/0288_attached_browser_reenrollment.sql +64 -0
  135. package/drizzle/0289_session_composer_policy_authority.sql +597 -0
  136. package/drizzle/0290_organization_membership_backfill.sql +268 -0
  137. package/drizzle/0291_resource_authority_classification_assertion.sql +371 -0
  138. package/drizzle/0292_truthful_tenancy_inventory_counters.sql +291 -0
  139. package/drizzle/0293_confirm_time_rule_rebaseline.sql +615 -0
  140. package/drizzle/0294_preference_activation_authority.sql +237 -0
  141. package/drizzle/0295_retire_legacy_standing_memory_mode.sql +476 -0
  142. package/drizzle/0296_force_rls_backfill_noop_repair.sql +215 -0
  143. package/drizzle/0297_session_ownership_classification_and_backfill.sql +752 -0
  144. package/drizzle/0298_organization_tenancy_parity.sql +609 -0
  145. package/drizzle/0299_organization_membership_lock_order.sql +291 -0
  146. package/drizzle/0300_tenancy_backfill_ledger.sql +459 -0
  147. package/drizzle/0301_session_snapshot_and_pin_visibility.sql +181 -0
  148. package/drizzle/0302_personal_workspace_session_ownership.sql +303 -0
  149. package/drizzle/0303_session_tenancy_product_activation.sql +919 -0
  150. package/drizzle/0304_personal_workspace_private_session_reads.sql +97 -0
  151. package/drizzle/0305_personal_resource_grant_management.sql +584 -0
  152. package/drizzle/0306_atomic_personal_resource_attachments.sql +1374 -0
  153. package/drizzle/0307_session_attention_state.sql +51 -0
  154. package/drizzle/0308_session_archives.sql +35 -0
  155. package/drizzle/0309_channel_project_pins.sql +6 -0
  156. package/drizzle/0310_channel_project_order.sql +27 -0
  157. package/drizzle/0311_company_scope_and_private_session_create.sql +656 -0
  158. package/drizzle/0312_quiescent_session_tree_deletion.sql +39 -0
  159. package/drizzle/0313_private_child_session_authority.sql +365 -0
  160. package/drizzle/0314_unregistered_organization_invitations.sql +606 -0
  161. package/drizzle/0315_personal_github_repository_selection.sql +624 -0
  162. package/drizzle/0316_human_confirmed_activation_resumed_generation.sql +869 -0
  163. package/drizzle/0317_session_goal_continuation_hold.sql +64 -0
  164. package/drizzle/0318_session_turn_startup_milestones.sql +115 -0
  165. package/drizzle/0319_event_triggered_automations.sql +254 -0
  166. package/drizzle/0320_pr_review_pack.sql +113 -0
  167. package/drizzle/0321_slack_bot_environment_display_name.sql +15 -0
  168. package/drizzle/0322_session_turns_unclaimed_prompt_trigger_index.sql +5 -0
  169. package/drizzle/0323_organization_private_session_enablement.sql +489 -0
  170. package/drizzle/0324_human_confirmed_company_profile_agent_admin.sql +856 -0
  171. package/drizzle/0325_child_lifecycle_notices.sql +44 -0
  172. package/drizzle/0326_interaction_operation_error_codes.sql +62 -0
  173. package/drizzle/0327_slack_first_task_hint.sql +29 -0
  174. package/drizzle/0328_session_background_commands.sql +590 -0
  175. package/drizzle/0329_slack_orchestration_delivery_events.sql +91 -0
  176. package/drizzle/0330_api_key_descriptions.sql +20 -0
  177. package/drizzle/0331_managed_organization_creation.sql +163 -0
  178. package/drizzle/0332_organization_shared_workspace_control_plane.sql +539 -0
  179. package/drizzle/0333_session_turn_prompt_routing.sql +45 -0
  180. package/drizzle/0334_connected_machine_workspace_root.sql +99 -0
  181. package/drizzle/0335_slack_workspace_routing.sql +460 -0
  182. package/drizzle/0336_atomic_session_fork_visibility.sql +667 -0
  183. package/drizzle/0337_slack_routed_action_handles.sql +189 -0
  184. package/drizzle/0338_atomic_connected_machine_attachments.sql +410 -0
  185. package/drizzle/0339_document_authority_reclassification.sql +1153 -0
  186. package/drizzle/0340_tenancy_backfill_activation_evidence.sql +1347 -0
  187. package/drizzle/0341_slack_routing_probe_organization_fence.sql +109 -0
  188. package/drizzle/0342_slack_route_prompt_single_pending.sql +32 -0
  189. package/drizzle/0343_personal_document_force_rls_lock_repair.sql +146 -0
  190. package/drizzle/0344_private_session_visibility_transition_gate.sql +85 -0
  191. package/drizzle/0345_tenant_scoped_session_tenancy_fence.sql +2839 -0
  192. package/drizzle/0346_document_migration_audit_surface.sql +454 -0
  193. package/drizzle/0347_connection_authority_convergence_evidence.sql +396 -0
  194. package/package.json +10 -6
  195. package/src/attached-browser-devices.ts +233 -5
  196. package/src/automations.ts +911 -0
  197. package/src/browser-sessions.ts +10 -0
  198. package/src/capability-integrations.ts +175 -1
  199. package/src/child-lifecycle-notices.ts +241 -0
  200. package/src/codemode-operations.ts +1 -35
  201. package/src/company-brain-context-selection-schema.ts +100 -0
  202. package/src/company-brain-context-selection.ts +359 -0
  203. package/src/company-brain-governed-writes.ts +1170 -0
  204. package/src/company-brain.ts +309 -0
  205. package/src/company-profile-agent-admin.ts +225 -0
  206. package/src/company-profile-schema.ts +121 -1
  207. package/src/company-profile.ts +21 -0
  208. package/src/computer-sessions.ts +10 -1
  209. package/src/connection-authority.ts +290 -0
  210. package/src/connection-scopes.ts +20 -0
  211. package/src/connection-tenancy-backfill.ts +167 -0
  212. package/src/connection-token-resolver.ts +263 -31
  213. package/src/database.ts +87 -2
  214. package/src/editable-artifacts-schema.ts +10 -5
  215. package/src/editable-artifacts.ts +21 -11
  216. package/src/governed-learning-activation-schema.ts +121 -0
  217. package/src/governed-learning-activation.ts +588 -0
  218. package/src/governed-learning-evaluator-schema.ts +72 -0
  219. package/src/governed-learning-evaluator.ts +217 -0
  220. package/src/index.ts +11676 -1550
  221. package/src/insights.ts +107 -0
  222. package/src/integration-bindings.ts +88 -6
  223. package/src/integration-facets.ts +287 -84
  224. package/src/interaction-placement-loss.ts +234 -0
  225. package/src/managed-human-provisioning.ts +116 -0
  226. package/src/memory-domain.ts +27 -32
  227. package/src/migrate.ts +77 -1
  228. package/src/new-session-drafts.ts +229 -35
  229. package/src/organization-membership-backfill.ts +735 -0
  230. package/src/organization-membership-lifecycle.ts +995 -0
  231. package/src/pr-review.ts +890 -0
  232. package/src/preference-registry.ts +31 -1
  233. package/src/provision-roles.ts +905 -6
  234. package/src/runtime-posture-cli.ts +2 -0
  235. package/src/runtime-posture.ts +1317 -72
  236. package/src/schema.ts +3316 -428
  237. package/src/scoped-knowledge-schema.ts +16 -8
  238. package/src/scoped-knowledge.ts +1 -1
  239. package/src/session-background-commands.ts +759 -0
  240. package/src/session-control.ts +640 -74
  241. package/src/session-goal-pacing.ts +126 -0
  242. package/src/session-queue-commands.ts +441 -85
  243. package/src/session-realtime-context.ts +4 -6
  244. package/src/session-realtime-ledger.ts +28 -14
  245. package/src/session-realtime-mirror.ts +1 -1
  246. package/src/session-tenancy.ts +410 -49
  247. package/src/session-tool-call-settlement.ts +38 -29
  248. package/src/slack-routing-personal-workspace.ts +67 -0
  249. package/src/slack-routing.ts +867 -0
  250. package/src/slack-task-policy-schema.ts +5 -0
  251. package/src/slack-task-policy.ts +18 -0
  252. package/src/slack-user-link-access.ts +138 -11
  253. package/src/task-notes-schema.ts +74 -0
  254. package/src/task-notes.ts +124 -2
  255. package/src/turn-initiator.ts +8 -0
  256. package/src/user-resource-authority.ts +377 -0
  257. package/src/workspace-authority.ts +160 -0
  258. package/src/workspace-instruction-policies-schema.ts +53 -1
  259. package/src/workspace-instruction-policies.ts +528 -77
  260. package/src/workspace-learning-policy.ts +21 -5
  261. package/src/workspace-membership-permissions.ts +9 -0
  262. package/dist/chunk-4SR4HKKA.js.map +0 -1
  263. package/dist/chunk-6ZYKCRFO.js.map +0 -1
  264. package/dist/chunk-NXAFLCQX.js +0 -2468
  265. package/dist/chunk-NXAFLCQX.js.map +0 -1
  266. package/dist/chunk-SK7YYHBI.js.map +0 -1
  267. package/dist/chunk-WD5ROSLL.js +0 -117
  268. package/dist/chunk-WD5ROSLL.js.map +0 -1
  269. package/dist/chunk-ZWREYEWA.js.map +0 -1
  270. /package/dist/{chunk-CUPM3FGB.js.map → chunk-2PRS4J5Q.js.map} +0 -0
  271. /package/dist/{chunk-LTG3S6ZY.js.map → chunk-E6CLMKEE.js.map} +0 -0
@@ -0,0 +1,268 @@
1
+ import { type Database } from "./database.js";
2
+ import * as schema from "./schema.js";
3
+ /** The installation binding's own tenancy: credential, identity, and inbox. */
4
+ export type SlackRouteHome = {
5
+ accountId: string;
6
+ workspaceId: string;
7
+ };
8
+ /** How a stored route was decided. `picker` is a human answering the Slack card. */
9
+ export type SlackRouteSource = "picker" | "admin";
10
+ export type SlackChannelRoute = {
11
+ id: string;
12
+ accountId: string;
13
+ workspaceId: string;
14
+ connectionId: string;
15
+ slackTeamId: string;
16
+ slackChannelId: string;
17
+ targetAccountId: string;
18
+ targetWorkspaceId: string;
19
+ decidedBySubjectId: string;
20
+ decidedBySlackUserId: string;
21
+ source: SlackRouteSource;
22
+ version: number;
23
+ createdAt: Date;
24
+ updatedAt: Date;
25
+ };
26
+ export type SlackUserDmRoute = Omit<SlackChannelRoute, "slackChannelId"> & {
27
+ slackUserId: string;
28
+ };
29
+ export type UpsertSlackChannelRouteInput = {
30
+ connectionId: string;
31
+ slackTeamId: string;
32
+ slackChannelId: string;
33
+ targetAccountId: string;
34
+ targetWorkspaceId: string;
35
+ decidedBySubjectId: string;
36
+ decidedBySlackUserId: string;
37
+ source: SlackRouteSource;
38
+ };
39
+ export type UpsertSlackUserDmRouteInput = Omit<UpsertSlackChannelRouteInput, "slackChannelId"> & {
40
+ slackUserId: string;
41
+ };
42
+ /** Ids only. Never content, never a subject. */
43
+ export type SlackInteractionTenancy = {
44
+ accountId: string;
45
+ workspaceId: string;
46
+ interactionId: string;
47
+ };
48
+ /** One workspace a Slack-linked subject may start work in. */
49
+ export type SlackRoutableWorkspace = {
50
+ accountId: string;
51
+ workspaceId: string;
52
+ label: string;
53
+ /** True for the subject's own personal workspace, which has no membership row. */
54
+ personal: boolean;
55
+ };
56
+ /**
57
+ * Resolve which tenancy owns the `slack_interactions` row for one exact
58
+ * connection-scoped route key, through the content-free SECURITY DEFINER probe.
59
+ *
60
+ * Thread continuation must cross workspaces: `slack_interactions_route_uq` is
61
+ * `(connection_id, route_key)` and therefore connection-global, while every
62
+ * ordinary interaction read is workspace-fenced and would miss a thread whose
63
+ * interaction lives in a routed workspace.
64
+ *
65
+ * This returns IDS ONLY. It cannot widen visibility, because the caller must
66
+ * re-read the full row under the returned tenancy's own RLS - which is what
67
+ * `getSlackInteractionById` already does.
68
+ */
69
+ export declare function probeSlackInteractionTenancy(db: Database, input: {
70
+ accountId: string;
71
+ connectionId: string;
72
+ routeKey: string;
73
+ }): Promise<SlackInteractionTenancy | null>;
74
+ /**
75
+ * Which workspace owns one Slack action handle.
76
+ *
77
+ * A button click arrives on an inbox row that carries the installation's
78
+ * tenancy and names the handle only by id, while the handle lives in the
79
+ * workspace that owns its session. Content-free, ids only: the caller must
80
+ * re-read the full handle under the returned tenancy's own RLS, where every
81
+ * existing authorization check already lives.
82
+ */
83
+ export declare function probeSlackActionHandleTenancy(db: Database, input: {
84
+ accountId: string;
85
+ connectionId: string;
86
+ handleId: string;
87
+ }): Promise<SlackRouteHome | null>;
88
+ /** Every channel route this installation has, for the admin surface. */
89
+ export declare function listSlackChannelRoutes(db: Database, home: SlackRouteHome, input: {
90
+ connectionId: string;
91
+ }): Promise<SlackChannelRoute[]>;
92
+ export declare function getSlackChannelRoute(db: Database, home: SlackRouteHome, input: {
93
+ connectionId: string;
94
+ slackChannelId: string;
95
+ }): Promise<SlackChannelRoute | null>;
96
+ export declare function getSlackUserDmRoute(db: Database, home: SlackRouteHome, input: {
97
+ connectionId: string;
98
+ slackUserId: string;
99
+ }): Promise<SlackUserDmRoute | null>;
100
+ /**
101
+ * The ask-once memory for a channel. A repeat write for the same
102
+ * `(connectionId, slackChannelId)` re-points the channel and bumps `version`;
103
+ * it never creates a second row, so a channel always has exactly one answer.
104
+ *
105
+ * The caller is responsible for having authorized `target*` for the deciding
106
+ * subject through `resolveSlackTargetAuthority` first - a stored route is
107
+ * memory, never authority, and every later use re-authorizes it live.
108
+ */
109
+ export declare function upsertSlackChannelRoute(db: Database, home: SlackRouteHome, input: UpsertSlackChannelRouteInput): Promise<SlackChannelRoute>;
110
+ /** The ask-once memory for one Slack human's direct messages. */
111
+ export declare function upsertSlackUserDmRoute(db: Database, home: SlackRouteHome, input: UpsertSlackUserDmRouteInput): Promise<SlackUserDmRoute>;
112
+ /** Clear a channel's stored answer; the next message asks again. */
113
+ export declare function deleteSlackChannelRoute(db: Database, home: SlackRouteHome, input: {
114
+ connectionId: string;
115
+ slackChannelId: string;
116
+ }): Promise<boolean>;
117
+ /** Clear one Slack human's stored DM answer; DMs fall back to the derived personal workspace. */
118
+ export declare function deleteSlackUserDmRoute(db: Database, home: SlackRouteHome, input: {
119
+ connectionId: string;
120
+ slackUserId: string;
121
+ }): Promise<boolean>;
122
+ /**
123
+ * THE workspaces one subject may start Slack work in, within one organization.
124
+ *
125
+ * This is deliberately one function so the "workspaces this subject may create
126
+ * sessions in" question has a single implementation that a future shared
127
+ * candidate-set contract can replace wholesale, rather than several call sites
128
+ * each re-deriving it slightly differently.
129
+ *
130
+ * Two independent sources, unioned:
131
+ *
132
+ * 1. `workspace_memberships` joined to `workspaces` in this account, filtered
133
+ * to memberships that actually permit starting work (`sessions:create`, or
134
+ * `workspace:admin` which implies it).
135
+ * 2. The subject's OWN personal workspace, from the active organization
136
+ * membership's `personalWorkspaceId` pointer.
137
+ *
138
+ * `listWorkspacesForSubject` is NOT usable here: it is a bare membership join
139
+ * with no permission filter, and it cannot see personal workspaces at all,
140
+ * because a managed human's personal workspace deliberately has no
141
+ * `workspace_memberships` row.
142
+ *
143
+ * The personal-workspace id is DERIVED from the membership pointer. It is never
144
+ * accepted from a Slack payload, a route row, or a caller argument.
145
+ *
146
+ * Ordered stably by label then workspace id, with plain code-unit comparison so
147
+ * two hosts with different ICU data cannot render a picker differently.
148
+ *
149
+ * ORACLE, NOT AN AUTHORIZATION. This answers "what could this named subject use"
150
+ * for whatever subject it is handed; it does not establish that the caller IS
151
+ * that subject. Pass only a subject authenticated out of band - for Slack, one
152
+ * named by a durable `slack_bot_user_links` row. Never pass a subject taken
153
+ * from a request payload.
154
+ */
155
+ export declare function listNamedSubjectSlackRoutableWorkspaces(db: Database, input: {
156
+ accountId: string;
157
+ subjectId: string;
158
+ }): Promise<SlackRoutableWorkspace[]>;
159
+ /** The trigger kinds a picker can be opened from, mirroring the table's CHECK. */
160
+ export type SlackRoutePromptTriggerKind = (typeof schema.slackRoutePrompts.$inferSelect)["triggerKind"];
161
+ /** A pending first-use picker plus the workspaces it offered. */
162
+ export type SlackRoutePrompt = {
163
+ id: string;
164
+ accountId: string;
165
+ workspaceId: string;
166
+ connectionId: string;
167
+ inboxId: string;
168
+ slackTeamId: string;
169
+ slackUserId: string;
170
+ slackChannelId: string;
171
+ slackMessageTs: string;
172
+ providerEventId: string;
173
+ triggerKind: SlackRoutePromptTriggerKind;
174
+ requestText: string;
175
+ hasFiles: boolean;
176
+ slackThreadTs: string | null;
177
+ messageOperationId: string;
178
+ status: "pending" | "answered" | "expired" | "cancelled";
179
+ expiresAt: Date;
180
+ options: readonly SlackRoutePromptOption[];
181
+ };
182
+ export type SlackRoutePromptOption = {
183
+ id: string;
184
+ candidateAccountId: string;
185
+ candidateWorkspaceId: string;
186
+ candidateLabel: string;
187
+ position: number;
188
+ };
189
+ /**
190
+ * Open one first-use picker for a conversation, or return the one already open.
191
+ *
192
+ * Three separate uniques make this idempotent from three directions: Slack's
193
+ * retries of one event collide on `(connection_id, provider_event_id)`, a
194
+ * replayed inbox row collides on `(connection_id, inbox_id)`, and a genuinely
195
+ * different message in the same conversation collides on the partial pending
196
+ * index. The last one is why a second message never posts a second card: the
197
+ * person is already being asked the same question.
198
+ */
199
+ export declare function openSlackRoutePrompt(db: Database, home: SlackRouteHome, input: {
200
+ connectionId: string;
201
+ inboxId: string;
202
+ slackTeamId: string;
203
+ slackUserId: string;
204
+ slackChannelId: string;
205
+ slackMessageTs: string;
206
+ providerEventId: string;
207
+ triggerKind: SlackRoutePromptTriggerKind;
208
+ requestText: string;
209
+ hasFiles: boolean;
210
+ slackThreadTs: string | null;
211
+ messageOperationId: string;
212
+ expiresAt: Date;
213
+ candidates: readonly SlackRoutableWorkspace[];
214
+ now?: Date;
215
+ }): Promise<{
216
+ opened: boolean;
217
+ prompt: SlackRoutePrompt;
218
+ } | null>;
219
+ /**
220
+ * The prompt one offered button belongs to.
221
+ *
222
+ * The button's `value` is the option row id, which is a UUID precisely because
223
+ * the block-action normalizer already requires that shape. The option rows are a
224
+ * prompt-time SNAPSHOT and are never authority: the caller must re-authorize the
225
+ * chosen workspace live.
226
+ */
227
+ export declare function getSlackRoutePromptByOption(db: Database, home: SlackRouteHome, optionId: string): Promise<{
228
+ prompt: SlackRoutePrompt;
229
+ chosen: SlackRoutePromptOption;
230
+ } | null>;
231
+ /**
232
+ * Settle a prompt without answering it: the person pressed the cancel action, or
233
+ * it aged out. Only a still-pending row moves, so this cannot overwrite an
234
+ * answer that landed first.
235
+ */
236
+ export declare function settleSlackRoutePrompt(db: Database, home: SlackRouteHome, input: {
237
+ promptId: string;
238
+ status: "expired" | "cancelled";
239
+ }): Promise<boolean>;
240
+ /**
241
+ * Answer a picker: freeze the choice, remember it, and re-queue the request.
242
+ *
243
+ * All three commit together. The route row is the ask-once memory, so a later
244
+ * message in that conversation never asks again, and the re-queued inbox row is
245
+ * what actually starts the work the person asked for before they were
246
+ * interrupted by the question.
247
+ *
248
+ * The re-queued row carries a DERIVED provider event id, not the original one.
249
+ * The original inbox row still exists and is settled, so re-using its id would
250
+ * collide with the inbox's own `(connection_id, provider_event_id)` dedupe and
251
+ * silently queue nothing at all. Deriving it from the prompt keeps the insert
252
+ * idempotent for exactly this answer, so a double-click cannot create two
253
+ * sessions.
254
+ *
255
+ * Only a still-pending prompt answers. A second click, an expiry sweep, or a
256
+ * cancel that landed first all leave `answered: false` and change nothing.
257
+ */
258
+ export declare function answerSlackRoutePrompt(db: Database, home: SlackRouteHome, input: {
259
+ promptId: string;
260
+ targetAccountId: string;
261
+ targetWorkspaceId: string;
262
+ answeredBySubjectId: string;
263
+ decidedBySlackUserId: string;
264
+ now?: Date;
265
+ }): Promise<{
266
+ answered: boolean;
267
+ queuedProviderEventId: string | null;
268
+ }>;
@@ -772,6 +772,40 @@ export declare const slackSharedTaskOrigins: import("drizzle-orm/pg-core").PgTab
772
772
  identity: undefined;
773
773
  generated: undefined;
774
774
  }, {}, {}>;
775
+ policyAccountId: import("drizzle-orm/pg-core").PgColumn<{
776
+ name: "policy_account_id";
777
+ tableName: "slack_shared_task_origins";
778
+ dataType: "string";
779
+ columnType: "PgUUID";
780
+ data: string;
781
+ driverParam: string;
782
+ notNull: false;
783
+ hasDefault: false;
784
+ isPrimaryKey: false;
785
+ isAutoincrement: false;
786
+ hasRuntimeDefault: false;
787
+ enumValues: undefined;
788
+ baseColumn: never;
789
+ identity: undefined;
790
+ generated: undefined;
791
+ }, {}, {}>;
792
+ policyWorkspaceId: import("drizzle-orm/pg-core").PgColumn<{
793
+ name: "policy_workspace_id";
794
+ tableName: "slack_shared_task_origins";
795
+ dataType: "string";
796
+ columnType: "PgUUID";
797
+ data: string;
798
+ driverParam: string;
799
+ notNull: false;
800
+ hasDefault: false;
801
+ isPrimaryKey: false;
802
+ isAutoincrement: false;
803
+ hasRuntimeDefault: false;
804
+ enumValues: undefined;
805
+ baseColumn: never;
806
+ identity: undefined;
807
+ generated: undefined;
808
+ }, {}, {}>;
775
809
  policyHash: import("drizzle-orm/pg-core").PgColumn<{
776
810
  name: "policy_hash";
777
811
  tableName: "slack_shared_task_origins";
@@ -11,6 +11,14 @@ export type SlackSharedTaskOrigin = {
11
11
  sourceThreadTs: string;
12
12
  initiatingSlackUserId: string;
13
13
  policyRevisionId: string;
14
+ /**
15
+ * Home tenancy of the frozen policy revision. The row's own
16
+ * `accountId`/`workspaceId` are the routed task's, which is a different
17
+ * workspace once Slack workspace routing is on. Null on rows written before
18
+ * routing existed, where the two were always equal.
19
+ */
20
+ policyAccountId: string | null;
21
+ policyWorkspaceId: string | null;
14
22
  policyHash: string;
15
23
  policyActivationVersion: number;
16
24
  publicationMode: "never" | "approval_required" | "allow";
@@ -22,9 +22,32 @@ export type SlackUserLinkAccessMutationInput = {
22
22
  expectedVersion: number;
23
23
  idempotencyKey: string;
24
24
  };
25
+ /**
26
+ * The Slack team one access request was raised from.
27
+ *
28
+ * The public request shape deliberately omits it, but an approver has to
29
+ * resolve the installation binding to know where the identity link belongs, and
30
+ * for a routed request that is not the workspace being granted.
31
+ */
32
+ export declare function slackUserLinkAccessRequestTeam(db: Database, input: {
33
+ workspaceId: string;
34
+ requestId: string;
35
+ }): Promise<{
36
+ slackTeamId: string;
37
+ connectionId: string;
38
+ } | null>;
39
+ /**
40
+ * The tenancy an identity link belongs to. See `withSlackIdentityHomeScope`.
41
+ */
42
+ export type SlackIdentityHome = {
43
+ accountId: string;
44
+ workspaceId: string;
45
+ };
25
46
  export type ApproveSlackUserLinkAccessInput = SlackUserLinkAccessMutationInput & {
26
47
  role?: string;
27
48
  permissions: Permission[];
49
+ /** The installation's tenancy, when it differs from the routed request's. */
50
+ identityHome?: SlackIdentityHome;
28
51
  };
29
52
  /**
30
53
  * Persist one verified Slack bearer as token-free, subject-bound state. A
@@ -36,6 +59,8 @@ export declare function getSlackUserLinkAccessRequestForSubject(db: Database, in
36
59
  workspaceId: string;
37
60
  requestId: string;
38
61
  subjectId: string;
62
+ /** The installation's tenancy, when it differs from the routed request's. */
63
+ identityHome?: SlackIdentityHome;
39
64
  }, now?: Date): Promise<SlackUserLinkAccessRequest | null>;
40
65
  export declare function requestSlackUserLinkWorkspaceAccess(db: Database, input: SlackUserLinkAccessMutationInput, now?: Date): Promise<SlackUserLinkAccessRequest>;
41
66
  export declare function cancelSlackUserLinkAccessRequest(db: Database, input: SlackUserLinkAccessMutationInput, now?: Date): Promise<SlackUserLinkAccessRequest>;
@@ -50,5 +75,8 @@ export declare function completeSlackUserLinkAccessIfGranted(db: Database, input
50
75
  workspaceId: string;
51
76
  requestId: string;
52
77
  subjectId: string;
78
+ /** The installation's tenancy, when it differs from the routed request's. */
79
+ identityHome?: SlackIdentityHome;
53
80
  }, now?: Date): Promise<SlackUserLinkAccessRequest | null>;
54
81
  export declare function listPendingSlackUserLinkAccessRequests(db: Database, workspaceId: string, now?: Date): Promise<SlackUserLinkAccessRequest[]>;
82
+ export declare function workspaceMembershipPermissionsAllowSlackLink(value: unknown): boolean;