@opengeni/db 1.0.1 → 3.1.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.
- package/dist/attached-browser-devices.d.ts +7 -0
- package/dist/automations.d.ts +154 -0
- package/dist/canonical-human-identities.js +3 -3
- package/dist/capability-integrations.d.ts +13 -0
- package/dist/child-lifecycle-notices.d.ts +68 -0
- package/dist/{chunk-LTG3S6ZY.js → chunk-EULAN2NP.js} +2 -2
- package/dist/{chunk-CUPM3FGB.js → chunk-NJVZPWXY.js} +3 -3
- package/dist/{chunk-4SR4HKKA.js → chunk-NMUBV7Z5.js} +19 -11
- package/dist/chunk-NMUBV7Z5.js.map +1 -0
- package/dist/chunk-OF5OBB76.js +4457 -0
- package/dist/chunk-OF5OBB76.js.map +1 -0
- package/dist/{chunk-6ZYKCRFO.js → chunk-PR2WMLOQ.js} +7580 -4417
- package/dist/chunk-PR2WMLOQ.js.map +1 -0
- package/dist/{chunk-ZWREYEWA.js → chunk-SCPUJS53.js} +41 -4
- package/dist/chunk-SCPUJS53.js.map +1 -0
- package/dist/{chunk-SK7YYHBI.js → chunk-SIBYBA2D.js} +46 -1
- package/dist/chunk-SIBYBA2D.js.map +1 -0
- package/dist/chunk-TIKF3KTI.js +383 -0
- package/dist/chunk-TIKF3KTI.js.map +1 -0
- package/dist/chunk-ZZ5LJEFX.js +516 -0
- package/dist/chunk-ZZ5LJEFX.js.map +1 -0
- package/dist/codemode-operations.d.ts +1 -6
- package/dist/company-brain-context-selection-schema.d.ts +705 -0
- package/dist/company-brain-context-selection.d.ts +94 -0
- package/dist/company-brain-governed-writes.d.ts +24 -0
- package/dist/company-brain.d.ts +55 -0
- package/dist/company-profile-agent-admin.d.ts +15 -0
- package/dist/company-profile-schema.d.ts +619 -2
- package/dist/company-profile.d.ts +9 -4
- package/dist/connection-authority.d.ts +95 -0
- package/dist/connection-scopes.d.ts +8 -0
- package/dist/connection-tenancy-backfill.d.ts +41 -0
- package/dist/connection-token-resolver.d.ts +30 -1
- package/dist/database.d.ts +19 -0
- package/dist/editable-artifact-durable-export.js +2 -2
- package/dist/editable-artifacts.d.ts +2 -2
- package/dist/editable-artifacts.js +3 -3
- package/dist/governed-learning-activation-schema.d.ts +984 -0
- package/dist/governed-learning-activation.d.ts +98 -0
- package/dist/governed-learning-evaluator-schema.d.ts +633 -0
- package/dist/governed-learning-evaluator.d.ts +28 -0
- package/dist/index.d.ts +1595 -81
- package/dist/index.js +21571 -8126
- package/dist/index.js.map +1 -1
- package/dist/insights.d.ts +18 -0
- package/dist/integration-bindings.d.ts +1 -0
- package/dist/integration-facets.d.ts +30 -0
- package/dist/interaction-placement-loss.d.ts +22 -0
- package/dist/managed-human-provisioning.d.ts +25 -0
- package/dist/memory-domain.d.ts +3 -3
- package/dist/migrate.d.ts +11 -1
- package/dist/migrate.js +1 -1
- package/dist/new-session-drafts.d.ts +43 -5
- package/dist/organization-membership-backfill.d.ts +174 -0
- package/dist/organization-membership-lifecycle.d.ts +162 -0
- package/dist/pr-review.d.ts +107 -0
- package/dist/preference-registry-schema.d.ts +2 -0
- package/dist/preference-registry.d.ts +2 -0
- package/dist/provision-roles.js +1 -1
- package/dist/runtime-posture.d.ts +22 -8
- package/dist/schema.d.ts +24914 -13703
- package/dist/schema.js +99 -1
- package/dist/scoped-knowledge-schema.d.ts +52 -1
- package/dist/session-background-commands.d.ts +125 -0
- package/dist/session-background-commands.js +34 -0
- package/dist/session-background-commands.js.map +1 -0
- package/dist/session-control.d.ts +156 -3
- package/dist/session-goal-pacing.d.ts +68 -0
- package/dist/session-queue-commands.d.ts +41 -4
- package/dist/session-realtime-ledger.d.ts +2 -0
- package/dist/session-tenancy.d.ts +71 -1
- package/dist/session-tenancy.js +25 -3
- package/dist/session-tool-call-settlement.d.ts +9 -4
- package/dist/slack-routing-personal-workspace.d.ts +23 -0
- package/dist/slack-routing.d.ts +153 -0
- package/dist/slack-task-policy-schema.d.ts +34 -0
- package/dist/slack-task-policy.d.ts +8 -0
- package/dist/slack-user-link-access.d.ts +1 -0
- package/dist/task-notes-schema.d.ts +594 -0
- package/dist/task-notes.d.ts +39 -0
- package/dist/turn-initiator.d.ts +2 -0
- package/dist/user-resource-authority.d.ts +109 -0
- package/dist/video-generation.js +3 -3
- package/dist/workspace-authority.d.ts +81 -0
- package/dist/workspace-instruction-policies-schema.d.ts +279 -0
- package/dist/workspace-instruction-policies.d.ts +62 -0
- package/dist/workspace-learning-policy.d.ts +1 -0
- package/dist/workspace-membership-permissions.d.ts +2 -0
- package/drizzle/0240_enrollment_connection_authority.sql +39 -0
- package/drizzle/0241_atomic_personal_resource_delegation.sql +1000 -0
- package/drizzle/0241_enrollment_agent_runtime.sql +70 -0
- package/drizzle/0244_slack_app_home_refresh_queue.sql +120 -0
- package/drizzle/0245_model_context_contribution_facts.sql +88 -0
- package/drizzle/0246_integration_personal_instance_authority.sql +70 -0
- package/drizzle/0247_terraform_stacks_provenance_repair.sql +428 -0
- package/drizzle/0248_terraform_stacks_component_resolution_fence.sql +83 -0
- package/drizzle/0249_personal_resource_delegation_authority_correction.sql +662 -0
- package/drizzle/0250_direct_retained_process_owner_liveness.sql +199 -0
- package/drizzle/0251_connected_machine_operation_policy.sql +45 -0
- package/drizzle/0252_scheduled_personal_resource_delegation.sql +1867 -0
- package/drizzle/0253_common_user_resource_authority_lifecycle.sql +1555 -0
- package/drizzle/0254_scoped_variable_set_authority.sql +1255 -0
- package/drizzle/0255_company_brain_governed_write_proposals.sql +524 -0
- package/drizzle/0256_connection_authority_delegation.sql +703 -0
- package/drizzle/0257_goal_revision_decisions_and_root_constraints.sql +436 -0
- package/drizzle/0258_three_scope_document_knowledge_authority.sql +1273 -0
- package/drizzle/0259_company_brain_context_selection_receipts.sql +869 -0
- package/drizzle/0260_task_note_knowledge_promotion.sql +820 -0
- package/drizzle/0261_preference_knowledge_proposal_actor_binding.sql +471 -0
- package/drizzle/0262_scoped_connected_machines_and_rigs.sql +1700 -0
- package/drizzle/0263_organization_membership_lifecycle.sql +3284 -0
- package/drizzle/0264_connection_authority_runtime_activation.sql +1084 -0
- package/drizzle/0266_company_brain_context_receipt_inspection.sql +156 -0
- package/drizzle/0268_governed_learning_decision_receipts.sql +825 -0
- package/drizzle/0269_governed_learning_activation_controller.sql +1874 -0
- package/drizzle/0270_governed_learning_history_inspection.sql +170 -0
- package/drizzle/0271_company_brain_retrieval_only_default.sql +524 -0
- package/drizzle/0272_human_confirmed_learning_activation.sql +591 -0
- package/drizzle/0273_scheduled_variable_set_materialization.sql +268 -0
- package/drizzle/0274_human_confirmed_knowledge_review.sql +310 -0
- package/drizzle/0275_scheduled_connection_authority.sql +5527 -0
- package/drizzle/0276_onboarding_proposal_initiating_human_guc.sql +198 -0
- package/drizzle/0277_workspace_writer_authority_attribution.sql +393 -0
- package/drizzle/0278_workspace_membership_removal_fencing.sql +1174 -0
- package/drizzle/0279_workspace_connection_use_lane.sql +343 -0
- package/drizzle/0280_connection_and_variable_set_audit_attribution.sql +773 -0
- package/drizzle/0281_viewer_holder_authority_claims.sql +52 -0
- package/drizzle/0282_variable_set_session_attach_attribution.sql +178 -0
- package/drizzle/0283_editable_spreadsheet_authored_state.sql +82 -0
- package/drizzle/0284_truthful_human_confirmed_review_reason.sql +930 -0
- package/drizzle/0285_organization_tenancy_inventory.sql +329 -0
- package/drizzle/0286_widen_task_note_expiry_ceiling.sql +391 -0
- package/drizzle/0287_open_suffix_pending_tool_calls.sql +18 -0
- package/drizzle/0288_attached_browser_reenrollment.sql +64 -0
- package/drizzle/0289_session_composer_policy_authority.sql +597 -0
- package/drizzle/0290_organization_membership_backfill.sql +268 -0
- package/drizzle/0291_resource_authority_classification_assertion.sql +371 -0
- package/drizzle/0292_truthful_tenancy_inventory_counters.sql +291 -0
- package/drizzle/0293_confirm_time_rule_rebaseline.sql +615 -0
- package/drizzle/0294_preference_activation_authority.sql +237 -0
- package/drizzle/0295_retire_legacy_standing_memory_mode.sql +476 -0
- package/drizzle/0296_force_rls_backfill_noop_repair.sql +215 -0
- package/drizzle/0297_session_ownership_classification_and_backfill.sql +752 -0
- package/drizzle/0298_organization_tenancy_parity.sql +609 -0
- package/drizzle/0299_organization_membership_lock_order.sql +291 -0
- package/drizzle/0300_tenancy_backfill_ledger.sql +459 -0
- package/drizzle/0301_session_snapshot_and_pin_visibility.sql +181 -0
- package/drizzle/0302_personal_workspace_session_ownership.sql +303 -0
- package/drizzle/0303_session_tenancy_product_activation.sql +919 -0
- package/drizzle/0304_personal_workspace_private_session_reads.sql +97 -0
- package/drizzle/0305_personal_resource_grant_management.sql +584 -0
- package/drizzle/0306_atomic_personal_resource_attachments.sql +1374 -0
- package/drizzle/0307_session_attention_state.sql +51 -0
- package/drizzle/0308_session_archives.sql +35 -0
- package/drizzle/0309_channel_project_pins.sql +6 -0
- package/drizzle/0310_channel_project_order.sql +27 -0
- package/drizzle/0311_company_scope_and_private_session_create.sql +656 -0
- package/drizzle/0312_quiescent_session_tree_deletion.sql +39 -0
- package/drizzle/0313_private_child_session_authority.sql +365 -0
- package/drizzle/0314_unregistered_organization_invitations.sql +606 -0
- package/drizzle/0315_personal_github_repository_selection.sql +624 -0
- package/drizzle/0316_human_confirmed_activation_resumed_generation.sql +869 -0
- package/drizzle/0317_session_goal_continuation_hold.sql +64 -0
- package/drizzle/0318_session_turn_startup_milestones.sql +115 -0
- package/drizzle/0319_event_triggered_automations.sql +254 -0
- package/drizzle/0320_pr_review_pack.sql +113 -0
- package/drizzle/0321_slack_bot_environment_display_name.sql +15 -0
- package/drizzle/0322_session_turns_unclaimed_prompt_trigger_index.sql +5 -0
- package/drizzle/0323_organization_private_session_enablement.sql +489 -0
- package/drizzle/0324_human_confirmed_company_profile_agent_admin.sql +856 -0
- package/drizzle/0325_child_lifecycle_notices.sql +44 -0
- package/drizzle/0326_interaction_operation_error_codes.sql +62 -0
- package/drizzle/0327_slack_first_task_hint.sql +29 -0
- package/drizzle/0328_session_background_commands.sql +590 -0
- package/drizzle/0329_slack_orchestration_delivery_events.sql +91 -0
- package/drizzle/0330_api_key_descriptions.sql +20 -0
- package/drizzle/0331_managed_organization_creation.sql +163 -0
- package/drizzle/0332_organization_shared_workspace_control_plane.sql +539 -0
- package/drizzle/0333_session_turn_prompt_routing.sql +45 -0
- package/drizzle/0334_connected_machine_workspace_root.sql +99 -0
- package/drizzle/0335_slack_workspace_routing.sql +460 -0
- package/drizzle/0336_atomic_session_fork_visibility.sql +667 -0
- package/drizzle/0337_slack_routed_action_handles.sql +189 -0
- package/drizzle/0338_atomic_connected_machine_attachments.sql +410 -0
- package/drizzle/0339_document_authority_reclassification.sql +1153 -0
- package/drizzle/0340_tenancy_backfill_activation_evidence.sql +1347 -0
- package/drizzle/0341_slack_routing_probe_organization_fence.sql +109 -0
- package/package.json +10 -6
- package/src/attached-browser-devices.ts +233 -5
- package/src/automations.ts +911 -0
- package/src/browser-sessions.ts +10 -0
- package/src/capability-integrations.ts +175 -1
- package/src/child-lifecycle-notices.ts +241 -0
- package/src/codemode-operations.ts +1 -35
- package/src/company-brain-context-selection-schema.ts +100 -0
- package/src/company-brain-context-selection.ts +359 -0
- package/src/company-brain-governed-writes.ts +1170 -0
- package/src/company-brain.ts +309 -0
- package/src/company-profile-agent-admin.ts +225 -0
- package/src/company-profile-schema.ts +121 -1
- package/src/company-profile.ts +21 -0
- package/src/computer-sessions.ts +10 -1
- package/src/connection-authority.ts +290 -0
- package/src/connection-scopes.ts +20 -0
- package/src/connection-tenancy-backfill.ts +81 -0
- package/src/connection-token-resolver.ts +263 -31
- package/src/database.ts +75 -2
- package/src/editable-artifacts-schema.ts +10 -5
- package/src/editable-artifacts.ts +21 -11
- package/src/governed-learning-activation-schema.ts +121 -0
- package/src/governed-learning-activation.ts +588 -0
- package/src/governed-learning-evaluator-schema.ts +72 -0
- package/src/governed-learning-evaluator.ts +217 -0
- package/src/index.ts +11651 -1548
- package/src/insights.ts +107 -0
- package/src/integration-bindings.ts +88 -6
- package/src/integration-facets.ts +287 -84
- package/src/interaction-placement-loss.ts +234 -0
- package/src/managed-human-provisioning.ts +116 -0
- package/src/memory-domain.ts +27 -32
- package/src/migrate.ts +77 -1
- package/src/new-session-drafts.ts +229 -35
- package/src/organization-membership-backfill.ts +735 -0
- package/src/organization-membership-lifecycle.ts +985 -0
- package/src/pr-review.ts +890 -0
- package/src/preference-registry.ts +31 -1
- package/src/provision-roles.ts +877 -6
- package/src/runtime-posture-cli.ts +2 -0
- package/src/runtime-posture.ts +1291 -76
- package/src/schema.ts +3303 -428
- package/src/scoped-knowledge-schema.ts +16 -8
- package/src/scoped-knowledge.ts +1 -1
- package/src/session-background-commands.ts +759 -0
- package/src/session-control.ts +640 -74
- package/src/session-goal-pacing.ts +126 -0
- package/src/session-queue-commands.ts +437 -84
- package/src/session-realtime-context.ts +3 -3
- package/src/session-realtime-ledger.ts +22 -11
- package/src/session-realtime-mirror.ts +1 -1
- package/src/session-tenancy.ts +403 -49
- package/src/session-tool-call-settlement.ts +38 -29
- package/src/slack-routing-personal-workspace.ts +67 -0
- package/src/slack-routing.ts +469 -0
- package/src/slack-task-policy-schema.ts +5 -0
- package/src/slack-task-policy.ts +18 -0
- package/src/slack-user-link-access.ts +17 -1
- package/src/task-notes-schema.ts +74 -0
- package/src/task-notes.ts +124 -2
- package/src/turn-initiator.ts +8 -0
- package/src/user-resource-authority.ts +377 -0
- package/src/workspace-authority.ts +160 -0
- package/src/workspace-instruction-policies-schema.ts +53 -1
- package/src/workspace-instruction-policies.ts +528 -77
- package/src/workspace-learning-policy.ts +21 -5
- package/src/workspace-membership-permissions.ts +9 -0
- package/dist/chunk-4SR4HKKA.js.map +0 -1
- package/dist/chunk-6ZYKCRFO.js.map +0 -1
- package/dist/chunk-NXAFLCQX.js +0 -2468
- package/dist/chunk-NXAFLCQX.js.map +0 -1
- package/dist/chunk-SK7YYHBI.js.map +0 -1
- package/dist/chunk-WD5ROSLL.js +0 -117
- package/dist/chunk-WD5ROSLL.js.map +0 -1
- package/dist/chunk-ZWREYEWA.js.map +0 -1
- /package/dist/{chunk-LTG3S6ZY.js.map → chunk-EULAN2NP.js.map} +0 -0
- /package/dist/{chunk-CUPM3FGB.js.map → chunk-NJVZPWXY.js.map} +0 -0
|
@@ -55,6 +55,10 @@ export type EffectiveSessionControl = {
|
|
|
55
55
|
interruptionPendingCount: number;
|
|
56
56
|
quiescencePendingCount: number;
|
|
57
57
|
} | null;
|
|
58
|
+
backgroundCommandSettlement: {
|
|
59
|
+
state: "stopping";
|
|
60
|
+
commandCount: number;
|
|
61
|
+
} | null;
|
|
58
62
|
};
|
|
59
63
|
export declare const SESSION_DISCOVERY_CONTROL_TITLE_MAX_CHARS = 200;
|
|
60
64
|
export declare const SESSION_DISCOVERY_CONTROL_TARGET_LIMIT = 100;
|
|
@@ -90,6 +94,10 @@ export declare function serializeEffectiveSessionControl(control: EffectiveSessi
|
|
|
90
94
|
interruptionPendingCount: number;
|
|
91
95
|
quiescencePendingCount: number;
|
|
92
96
|
} | null;
|
|
97
|
+
backgroundCommandSettlement: {
|
|
98
|
+
state: "stopping";
|
|
99
|
+
commandCount: number;
|
|
100
|
+
} | null;
|
|
93
101
|
primaryBlocker: (Omit<EffectiveControlBlocker, "changedAt"> & {
|
|
94
102
|
changedAt: string | null;
|
|
95
103
|
}) | null;
|
|
@@ -142,7 +150,118 @@ export declare function assertAgentCommandAuthorityInTransaction(db: Database, i
|
|
|
142
150
|
action: "pause" | "resume" | "steer" | "message" | "goal";
|
|
143
151
|
}): Promise<void>;
|
|
144
152
|
export declare function canonicalSessionCommandHash(value: unknown): string;
|
|
145
|
-
|
|
153
|
+
/**
|
|
154
|
+
* Default bounded control-prefix wait for request-scoped API mutations (Send,
|
|
155
|
+
* Steer, queued Steer, Pause/Resume/Cancel, workspace Pause/Resume, realtime
|
|
156
|
+
* sync). The bound is one budget across every lock step of the admission
|
|
157
|
+
* (advisory lock, row lock, and the savepoint escalation of a paused branch),
|
|
158
|
+
* not a per-statement timeout. A request that cannot enter the workspace
|
|
159
|
+
* control prefix within the budget fails with the typed, retryable
|
|
160
|
+
* `WorkspaceControlBusyError` before any write instead of holding a pooled
|
|
161
|
+
* connection and a snapshot for as long as the HTTP client (or ingress) keeps
|
|
162
|
+
* the socket open. Worker settlement, claims, and event appends never pass a
|
|
163
|
+
* bound: a legitimate wait there must not become a failed settlement.
|
|
164
|
+
* The deployment value is `OPENGENI_WORKSPACE_CONTROL_LOCK_TIMEOUT_MS`, parsed
|
|
165
|
+
* and validated once at boot by `@opengeni/config`
|
|
166
|
+
* (`settings.workspaceControlLockTimeoutMs`) and handed to this module through
|
|
167
|
+
* `configureWorkspaceControlRequestLockTimeoutMs` when the API app is built.
|
|
168
|
+
* This module never reads `process.env` per request.
|
|
169
|
+
*/
|
|
170
|
+
export declare const WORKSPACE_CONTROL_REQUEST_LOCK_TIMEOUT_MS = 20000;
|
|
171
|
+
/**
|
|
172
|
+
* Install the validated request-scoped budget for this process. The value is
|
|
173
|
+
* process-global and last-writer-wins: the API calls this exactly once from
|
|
174
|
+
* its settings at app composition (`createApp`), and every later
|
|
175
|
+
* `workspaceControlRequestLockTimeoutMs()` read observes that value. Workers
|
|
176
|
+
* never call it because they never pass a bound. A non-positive or
|
|
177
|
+
* non-integer value is a programming error here (the config layer already
|
|
178
|
+
* rejected it at boot).
|
|
179
|
+
*/
|
|
180
|
+
export declare function configureWorkspaceControlRequestLockTimeoutMs(lockTimeoutMs: number): void;
|
|
181
|
+
/** The request-scoped budget in milliseconds currently configured for this process. */
|
|
182
|
+
export declare function workspaceControlRequestLockTimeoutMs(): number;
|
|
183
|
+
export declare class WorkspaceControlBusyError extends Error {
|
|
184
|
+
readonly workspaceId: string;
|
|
185
|
+
readonly lockTimeoutMs: number;
|
|
186
|
+
readonly code = "WORKSPACE_CONTROL_BUSY";
|
|
187
|
+
constructor(workspaceId: string, lockTimeoutMs: number);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* One wall-clock budget shared by every lock step of one control-prefix
|
|
191
|
+
* acquisition. Each step sets `lock_timeout` to the remaining budget, so the
|
|
192
|
+
* total wait never exceeds the requested bound even when the advisory lock,
|
|
193
|
+
* the row lock, and a savepoint escalation each wait in turn.
|
|
194
|
+
*/
|
|
195
|
+
export type WorkspaceControlLockBudget = {
|
|
196
|
+
readonly totalMs: number;
|
|
197
|
+
readonly deadlineAt: number;
|
|
198
|
+
};
|
|
199
|
+
export declare function workspaceControlLockBudget(lockTimeoutMs: number): WorkspaceControlLockBudget;
|
|
200
|
+
export type WorkspaceControlLockOptions = {
|
|
201
|
+
/**
|
|
202
|
+
* Bound the whole prefix acquisition in milliseconds. Omit for
|
|
203
|
+
* worker/lifecycle writers. The previous `lock_timeout` is restored once the
|
|
204
|
+
* prefix is held.
|
|
205
|
+
*/
|
|
206
|
+
lockTimeoutMs?: number;
|
|
207
|
+
/** Share an already running budget (used by the admission helper). */
|
|
208
|
+
budget?: WorkspaceControlLockBudget;
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* Lock the mandatory workspace inference-control row.
|
|
212
|
+
*
|
|
213
|
+
* `share` and `update` first take a transaction-scoped advisory lock on
|
|
214
|
+
* `hashtextextended('workspace-control:<workspace id>', 0)` in the matching
|
|
215
|
+
* mode and only then the row lock. The advisory lock is what makes the prefix
|
|
216
|
+
* fair: PostgreSQL row locks let a new FOR SHARE requester join a share-locked
|
|
217
|
+
* tuple without queueing behind an already waiting FOR UPDATE, so under
|
|
218
|
+
* continuous share traffic (claims, settlement, appends across many sessions)
|
|
219
|
+
* a genuine control mutation can starve indefinitely. Heavyweight locks have a
|
|
220
|
+
* FIFO wait queue: a shared request conflicts with a waiting exclusive request
|
|
221
|
+
* and queues behind it, so a mutator waits only for the holders that preceded
|
|
222
|
+
* it, and sharers keep flowing between mutations. The row lock is retained
|
|
223
|
+
* unchanged for FK/consistency semantics and for SQL-function writers that
|
|
224
|
+
* lock the row directly (session-create triggers and capability functions).
|
|
225
|
+
*
|
|
226
|
+
* Invariant: a transaction that locks this row through any other path (a
|
|
227
|
+
* SECURITY DEFINER function, a trigger, raw SQL) must already hold the prefix
|
|
228
|
+
* through this helper or must never call this helper afterwards for the same
|
|
229
|
+
* workspace. Requesting the advisory lock after holding the row lock can
|
|
230
|
+
* deadlock against a mutator that holds the advisory lock and waits for the
|
|
231
|
+
* row. Every current SQL-function locker either runs in its own transaction or
|
|
232
|
+
* runs after this helper in the same transaction.
|
|
233
|
+
*/
|
|
234
|
+
export declare function lockWorkspaceInferenceControl(db: Database, workspaceId: string, mode: WorkspaceControlLockMode, options?: WorkspaceControlLockOptions): Promise<WorkspaceControlRow>;
|
|
235
|
+
export type WorkspaceControlAdmissionLock = {
|
|
236
|
+
control: WorkspaceControlRow;
|
|
237
|
+
mode: "share" | "update";
|
|
238
|
+
};
|
|
239
|
+
/**
|
|
240
|
+
* Lock the workspace control prefix for an admission. Callers that may resume
|
|
241
|
+
* a paused branch request escalation; inert queue admission stays shared.
|
|
242
|
+
*
|
|
243
|
+
* The common case (the target branch is active) holds only `FOR SHARE`. That
|
|
244
|
+
* still excludes every control mutation (Pause/Resume/Cancel, workspace
|
|
245
|
+
* control, auto-resume all take `FOR UPDATE`), so the effective state observed
|
|
246
|
+
* here cannot change for the rest of the transaction, while other Sends,
|
|
247
|
+
* Steers, claims, and event appends on the workspace proceed concurrently.
|
|
248
|
+
*
|
|
249
|
+
* When the branch is paused the admission must advance the workspace control
|
|
250
|
+
* revision, so it needs `FOR UPDATE`. Upgrading in place would deadlock as soon
|
|
251
|
+
* as two sharers decide to upgrade together (each waits for the other's share
|
|
252
|
+
* lock), so the shared prefix is taken inside a savepoint and rolled back
|
|
253
|
+
* before the exclusive prefix is requested: PostgreSQL releases row locks and
|
|
254
|
+
* transaction-level advisory locks acquired inside a rolled-back savepoint, so
|
|
255
|
+
* the exclusive request queues normally behind other holders.
|
|
256
|
+
*
|
|
257
|
+
* Callers that already hold the prefix exclusively (for example a realtime
|
|
258
|
+
* sync that admitted a delegation) simply observe their own stronger lock.
|
|
259
|
+
*/
|
|
260
|
+
export declare function lockWorkspaceInferenceControlForAdmission(db: Database, input: {
|
|
261
|
+
workspaceId: string;
|
|
262
|
+
sessionId: string;
|
|
263
|
+
resumePausedBranch: boolean;
|
|
264
|
+
} & WorkspaceControlLockOptions): Promise<WorkspaceControlAdmissionLock>;
|
|
146
265
|
export type SessionEventWriteLockInput = {
|
|
147
266
|
workspaceId: string;
|
|
148
267
|
/**
|
|
@@ -167,12 +286,19 @@ export type SessionEventWriteLocks = {
|
|
|
167
286
|
/**
|
|
168
287
|
* Establish the one canonical lock prefix for every `session_events` writer:
|
|
169
288
|
*
|
|
170
|
-
* workspace_inference_controls
|
|
289
|
+
* workspace-control advisory lock + workspace_inference_controls row
|
|
290
|
+
* (when control-aware; see `lockWorkspaceInferenceControl`)
|
|
171
291
|
* -> actual workspaces row FOR KEY SHARE
|
|
172
292
|
* -> session rows FOR NO KEY UPDATE, UUID ordered
|
|
173
293
|
* -> exact turn rows FOR UPDATE, UUID ordered
|
|
174
294
|
* -> exact attempt rows FOR UPDATE, UUID ordered
|
|
175
295
|
*
|
|
296
|
+
* Control-aware writers that do not mutate the control row take it `share`;
|
|
297
|
+
* only genuine control mutations (Pause/Resume/Cancel, workspace control,
|
|
298
|
+
* auto-resume, settings narrowing, quiescent tree deletion) take `update`.
|
|
299
|
+
* Prompt admission declares whether it may resume a paused branch through
|
|
300
|
+
* `lockWorkspaceInferenceControlForAdmission`.
|
|
301
|
+
*
|
|
176
302
|
* `FOR KEY SHARE` is deliberate. Event inserts need the workspace key to remain
|
|
177
303
|
* stable for their FK, but they do not mutate the workspace. The old generic
|
|
178
304
|
* `FOR UPDATE` lock serialized unrelated sessions and inverted the activity
|
|
@@ -187,6 +313,11 @@ export type SessionEventWriteLocks = {
|
|
|
187
313
|
* this helper and may discover exact turn IDs only after locking the session.
|
|
188
314
|
* They use the explicit `already_locked` stages, while retaining the same
|
|
189
315
|
* monotonic table order. New event writers should prefer one complete call.
|
|
316
|
+
*
|
|
317
|
+
* Retained-screenshot prepare is not an event writer, but its INSERT still
|
|
318
|
+
* KEY SHAREs the turn and attempt through FKs. It must take this same prefix
|
|
319
|
+
* first: PostgreSQL fires those FK checks in catalog name/OID order, which can
|
|
320
|
+
* be attempt-then-turn and otherwise deadlocks against this helper.
|
|
190
321
|
*/
|
|
191
322
|
export declare function lockSessionEventWriteRows(db: Database, input: SessionEventWriteLockInput): Promise<SessionEventWriteLocks>;
|
|
192
323
|
export declare function registerSessionTurnAttemptClaim(db: Database, input: {
|
|
@@ -203,6 +334,7 @@ export declare function registerSessionTurnAttemptClaim(db: Database, input: {
|
|
|
203
334
|
authorityEpoch: number;
|
|
204
335
|
authorityVisibility: "user_private" | "workspace_shared";
|
|
205
336
|
authorityOwnerOrganizationMembershipId: string | null;
|
|
337
|
+
personalResourceProtocolVersion: number;
|
|
206
338
|
mcpApprovalPolicies: Record<string, SessionMcpApprovalPolicy>;
|
|
207
339
|
connectorActionPolicies: schema.ConnectorActionPolicySnapshotEntry[];
|
|
208
340
|
}): Promise<typeof schema.sessionTurnAttempts.$inferSelect>;
|
|
@@ -314,6 +446,7 @@ export type SessionControlMutationResult = {
|
|
|
314
446
|
sessionControlEventId: string;
|
|
315
447
|
workspaceControlEventId: string;
|
|
316
448
|
interruptionCount: number;
|
|
449
|
+
backgroundCommandCount: number;
|
|
317
450
|
wakeCount: number;
|
|
318
451
|
cancelledSessionCount: number;
|
|
319
452
|
cancelledTurnCount: number;
|
|
@@ -321,8 +454,16 @@ export type SessionControlMutationResult = {
|
|
|
321
454
|
sessionId: string;
|
|
322
455
|
eventIds: string[];
|
|
323
456
|
}>;
|
|
457
|
+
workflowWake: SessionControlWorkflowWake | null;
|
|
324
458
|
replay: boolean;
|
|
325
459
|
};
|
|
460
|
+
export type SessionControlWorkflowWake = {
|
|
461
|
+
accountId: string;
|
|
462
|
+
workspaceId: string;
|
|
463
|
+
sessionId: string;
|
|
464
|
+
temporalWorkflowId: string;
|
|
465
|
+
wakeRevision: number;
|
|
466
|
+
};
|
|
326
467
|
export declare function mutateSessionControlInTransaction(db: SessionActivityDatabase, input: {
|
|
327
468
|
accountId: string;
|
|
328
469
|
workspaceId: string;
|
|
@@ -332,13 +473,22 @@ export declare function mutateSessionControlInTransaction(db: SessionActivityDat
|
|
|
332
473
|
action: "pause" | "resume" | "cancel";
|
|
333
474
|
reason?: string | null;
|
|
334
475
|
expectedControlEtag?: string | null;
|
|
476
|
+
/** Request-scoped callers bound the control prefix wait; lifecycle callers omit it. */
|
|
477
|
+
controlLockTimeoutMs?: number;
|
|
335
478
|
}): Promise<SessionControlMutationResult>;
|
|
336
479
|
export declare function autoResumeSessionBranchInTransaction(db: SessionActivityDatabase, input: {
|
|
337
480
|
workspaceId: string;
|
|
338
481
|
sessionId: string;
|
|
339
482
|
actor: string;
|
|
340
|
-
reason: "
|
|
483
|
+
reason: "human_steer" | "service_steer" | "agent_steer";
|
|
341
484
|
observedControlEtag?: string | null;
|
|
485
|
+
/**
|
|
486
|
+
* The admission prefix the caller already holds. A `share` admission
|
|
487
|
+
* proves the branch was active under a lock that excludes every control
|
|
488
|
+
* mutation, so it never needs to resume; only an `update` admission may
|
|
489
|
+
* advance the workspace revision here.
|
|
490
|
+
*/
|
|
491
|
+
admission?: WorkspaceControlAdmissionLock;
|
|
342
492
|
}): Promise<{
|
|
343
493
|
revision: number;
|
|
344
494
|
control: EffectiveSessionControl;
|
|
@@ -351,6 +501,7 @@ export type WorkspaceControlMutationResult = {
|
|
|
351
501
|
workspaceControlEventId: string;
|
|
352
502
|
workspaceState: EffectiveControlState;
|
|
353
503
|
interruptionCount: number;
|
|
504
|
+
backgroundCommandCount: number;
|
|
354
505
|
wakeCount: number;
|
|
355
506
|
replay: boolean;
|
|
356
507
|
};
|
|
@@ -362,4 +513,6 @@ export declare function mutateWorkspaceControlInTransaction(db: Database, input:
|
|
|
362
513
|
action: "pause" | "resume";
|
|
363
514
|
reason?: string | null;
|
|
364
515
|
expectedRevision?: number | null;
|
|
516
|
+
/** Request-scoped callers bound the control prefix wait; lifecycle callers omit it. */
|
|
517
|
+
controlLockTimeoutMs?: number;
|
|
365
518
|
}): Promise<WorkspaceControlMutationResult>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Database } from "./database.js";
|
|
2
|
+
import * as schema from "./schema.js";
|
|
3
|
+
/** Column reset shared by every goal head mutation that retires a `goal_wait` hold. */
|
|
4
|
+
export declare const SESSION_GOAL_HOLD_CLEARED: {
|
|
5
|
+
readonly continuationHoldTurnId: null;
|
|
6
|
+
readonly continuationHoldUntil: null;
|
|
7
|
+
readonly continuationHoldReason: null;
|
|
8
|
+
readonly continuationHoldSetAt: null;
|
|
9
|
+
};
|
|
10
|
+
/** The pause reason written when a per-goal or deployment continuation ceiling is reached. */
|
|
11
|
+
export declare const SESSION_GOAL_CAP_PAUSED_REASON = "max_auto_continuations";
|
|
12
|
+
/**
|
|
13
|
+
* Column reset applied when a goal re-arms: a fresh continuation epoch starts
|
|
14
|
+
* with zero consecutive no-input continuations and no pointer to a
|
|
15
|
+
* pre-pause continuation turn.
|
|
16
|
+
*/
|
|
17
|
+
export declare const SESSION_GOAL_CONTINUATION_EPOCH_RESET: {
|
|
18
|
+
readonly autoContinuations: 0;
|
|
19
|
+
readonly noProgressStreak: 0;
|
|
20
|
+
readonly lastContinuationTurnId: null;
|
|
21
|
+
readonly versionAtLastContinuation: null;
|
|
22
|
+
};
|
|
23
|
+
export type SessionGoalAutoResumeCause = {
|
|
24
|
+
/** The system-update kind that arrived, or `human_prompt` for a Send/Steer. */
|
|
25
|
+
kind: string;
|
|
26
|
+
updateId?: string;
|
|
27
|
+
turnId?: string;
|
|
28
|
+
};
|
|
29
|
+
export type SessionGoalAutoResumedByExternalInput = {
|
|
30
|
+
goal: typeof schema.sessionGoals.$inferSelect;
|
|
31
|
+
/** `goal.resumed` payload the caller appends at its next session sequence. */
|
|
32
|
+
payload: {
|
|
33
|
+
goalId: string;
|
|
34
|
+
text: string;
|
|
35
|
+
successCriteria?: string;
|
|
36
|
+
version: number;
|
|
37
|
+
objectiveRevision: number;
|
|
38
|
+
mutationPolicy: string;
|
|
39
|
+
actor: "system";
|
|
40
|
+
reason: "external_input";
|
|
41
|
+
cause: SessionGoalAutoResumeCause;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Resume a goal that the continuation ceiling paused, because new external
|
|
46
|
+
* input arrived. The ceiling (`max_auto_continuations`) is pacing for
|
|
47
|
+
* consecutive no-input continuations, never user intent: a `user_pause`,
|
|
48
|
+
* `api`, `agent`, or `limits` pause is deliberately left alone and is never
|
|
49
|
+
* resumed here. Every producer of external input calls this: child results,
|
|
50
|
+
* scheduled occurrences, and media results (`addSessionSystemUpdate*`), Agent
|
|
51
|
+
* messages (`sendAgentMessageInTransaction`), Agent Steer
|
|
52
|
+
* (`steerAgentSessionInTransaction`), and human/API Send/Steer
|
|
53
|
+
* (`submitHumanPromptInTransaction`).
|
|
54
|
+
*
|
|
55
|
+
* Lock contract: the caller already holds the canonical event-write prefix
|
|
56
|
+
* and the session row (`FOR NO KEY UPDATE`); this helper then takes the goal
|
|
57
|
+
* row `FOR UPDATE`, the same order every goal tool uses. It mutates only the
|
|
58
|
+
* goal head and returns the `goal.resumed` payload; the caller must append
|
|
59
|
+
* that event at its next session sequence inside the SAME transaction so the
|
|
60
|
+
* goal mutation and its timeline fact remain one session-sequenced commit.
|
|
61
|
+
* Returns null when the session has no goal or its pause is not the ceiling.
|
|
62
|
+
*/
|
|
63
|
+
export declare function autoResumeGoalPausedByCapInTransaction(tx: Database, input: {
|
|
64
|
+
workspaceId: string;
|
|
65
|
+
sessionId: string;
|
|
66
|
+
cause: SessionGoalAutoResumeCause;
|
|
67
|
+
now: Date;
|
|
68
|
+
}): Promise<SessionGoalAutoResumedByExternalInput | null>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ResourceRef, type McpPersonalConnectionDelegation, type DraftTimelineAnnotation, type LatencyMode, type ReasoningEffort, type SessionEvent, type SessionTurn, type TurnExecutionPolicyV1, type TimelineAnnotation } from "@opengeni/contracts";
|
|
2
|
-
import type
|
|
1
|
+
import { ResourceRef, type McpPersonalConnectionDelegation, type DraftTimelineAnnotation, type LatencyMode, type ReasoningEffort, type SessionEvent, type SessionPromptRouting, type SessionTurn, type TurnExecutionPolicyV1, type TimelineAnnotation, type PersonalResourceAttachmentIntent } from "@opengeni/contracts";
|
|
2
|
+
import { type Database, type SessionActivityDatabase } from "./database.js";
|
|
3
3
|
import { type SessionCommandActor, type SessionCommandReceiptRow } from "./session-control.js";
|
|
4
4
|
import * as schema from "./schema.js";
|
|
5
|
-
export type QueueCommandConflictCode = "QUEUE_VERSION_CHANGED" | "QUEUE_PROMPT_STARTED" | "QUEUE_ANCHOR_CHANGED" | "PROMPT_CHANGED" | "DRAFT_CHANGED" | "DRAFT_NOT_EMPTY" | "EDIT_SOURCE_CHANGED";
|
|
5
|
+
export type QueueCommandConflictCode = "QUEUE_VERSION_CHANGED" | "QUEUE_PROMPT_STARTED" | "QUEUE_ANCHOR_CHANGED" | "PROMPT_CHANGED" | "DRAFT_CHANGED" | "DRAFT_NOT_EMPTY" | "EDIT_SOURCE_CHANGED" | "ONCE_ATTACHMENT_IMMUTABLE";
|
|
6
6
|
export declare class QueueCommandConflictError extends Error {
|
|
7
7
|
readonly code: QueueCommandConflictCode;
|
|
8
8
|
readonly current: {
|
|
@@ -32,13 +32,18 @@ export type EditQueueCommandResult = QueueCommandResult & {
|
|
|
32
32
|
export type SteerQueueCommandResult = QueueCommandResult & {
|
|
33
33
|
interruptionCount: number;
|
|
34
34
|
workspaceControlEventId: string | null;
|
|
35
|
+
workflowId: string;
|
|
36
|
+
wakeRevision: number;
|
|
35
37
|
};
|
|
36
38
|
export type SubmitHumanPromptResult = {
|
|
37
39
|
receipt: SessionCommandReceiptRow;
|
|
40
|
+
routing: SessionPromptRouting;
|
|
38
41
|
queueVersion: number;
|
|
39
42
|
accepted: SessionEvent;
|
|
40
43
|
events: SessionEvent[];
|
|
41
44
|
turn: SessionTurn;
|
|
45
|
+
/** Current actor/session composer after an exact draft-bound submission. */
|
|
46
|
+
draft: ComposerDraftRow | null;
|
|
42
47
|
/** Backward-compatible row identities for lower-level callers. */
|
|
43
48
|
acceptedEventId: string;
|
|
44
49
|
eventIds: string[];
|
|
@@ -98,7 +103,12 @@ export declare function saveComposerDraftInTransaction(db: Database, input: {
|
|
|
98
103
|
resources: ResourceRef[];
|
|
99
104
|
model: string;
|
|
100
105
|
reasoningEffort: ReasoningEffort;
|
|
101
|
-
latencyMode
|
|
106
|
+
latencyMode: LatencyMode;
|
|
107
|
+
/**
|
|
108
|
+
* Bound the workspace control prefix wait (request-scoped API callers pass
|
|
109
|
+
* `workspaceControlRequestLockTimeoutMs()`); omit for lifecycle callers.
|
|
110
|
+
*/
|
|
111
|
+
controlLockTimeoutMs?: number;
|
|
102
112
|
}): Promise<ComposerDraftRow>;
|
|
103
113
|
export declare function moveQueuedTurnInTransaction(db: SessionActivityDatabase, input: {
|
|
104
114
|
accountId: string;
|
|
@@ -109,6 +119,11 @@ export declare function moveQueuedTurnInTransaction(db: SessionActivityDatabase,
|
|
|
109
119
|
expectedQueueVersion: number;
|
|
110
120
|
actor: SessionCommandActor;
|
|
111
121
|
operationKey: string;
|
|
122
|
+
/**
|
|
123
|
+
* Bound the workspace control prefix wait (request-scoped API callers pass
|
|
124
|
+
* `workspaceControlRequestLockTimeoutMs()`); omit for lifecycle callers.
|
|
125
|
+
*/
|
|
126
|
+
controlLockTimeoutMs?: number;
|
|
112
127
|
}): Promise<QueueCommandResult>;
|
|
113
128
|
export declare function deleteSessionQueueItemInTransaction(db: SessionActivityDatabase, input: {
|
|
114
129
|
accountId: string;
|
|
@@ -119,6 +134,11 @@ export declare function deleteSessionQueueItemInTransaction(db: SessionActivityD
|
|
|
119
134
|
actor: SessionCommandActor;
|
|
120
135
|
operationKey: string;
|
|
121
136
|
reason?: string | null;
|
|
137
|
+
/**
|
|
138
|
+
* Bound the workspace control prefix wait (request-scoped API callers pass
|
|
139
|
+
* `workspaceControlRequestLockTimeoutMs()`); omit for lifecycle callers.
|
|
140
|
+
*/
|
|
141
|
+
controlLockTimeoutMs?: number;
|
|
122
142
|
}): Promise<QueueCommandResult>;
|
|
123
143
|
export declare function editQueuedTurnInTransaction(db: SessionActivityDatabase, input: {
|
|
124
144
|
accountId: string;
|
|
@@ -131,6 +151,11 @@ export declare function editQueuedTurnInTransaction(db: SessionActivityDatabase,
|
|
|
131
151
|
replaceDraft: boolean;
|
|
132
152
|
actor: SessionCommandActor;
|
|
133
153
|
operationKey: string;
|
|
154
|
+
/**
|
|
155
|
+
* Bound the workspace control prefix wait (request-scoped API callers pass
|
|
156
|
+
* `workspaceControlRequestLockTimeoutMs()`); omit for lifecycle callers.
|
|
157
|
+
*/
|
|
158
|
+
controlLockTimeoutMs?: number;
|
|
134
159
|
}): Promise<EditQueueCommandResult>;
|
|
135
160
|
export declare function steerQueuedTurnInTransaction(db: SessionActivityDatabase, input: {
|
|
136
161
|
accountId: string;
|
|
@@ -141,6 +166,8 @@ export declare function steerQueuedTurnInTransaction(db: SessionActivityDatabase
|
|
|
141
166
|
controlEtag?: string | null;
|
|
142
167
|
actor: SessionCommandActor;
|
|
143
168
|
operationKey: string;
|
|
169
|
+
/** Request-scoped callers bound the control prefix wait; lifecycle callers omit it. */
|
|
170
|
+
controlLockTimeoutMs?: number;
|
|
144
171
|
}): Promise<SteerQueueCommandResult>;
|
|
145
172
|
export declare function submitHumanPromptInTransaction(db: SessionActivityDatabase, input: {
|
|
146
173
|
accountId: string;
|
|
@@ -175,10 +202,13 @@ export declare function submitHumanPromptInTransaction(db: SessionActivityDataba
|
|
|
175
202
|
/** Record the admitted run's durable usage fact in this transaction. */
|
|
176
203
|
recordAgentRunUsage?: boolean;
|
|
177
204
|
personalConnectionDelegations?: McpPersonalConnectionDelegation[];
|
|
205
|
+
personalResourceAttachment?: PersonalResourceAttachmentIntent;
|
|
178
206
|
mcpCredentialUpdates?: Array<{
|
|
179
207
|
id: string;
|
|
180
208
|
headersEncrypted: Record<string, string>;
|
|
181
209
|
}>;
|
|
210
|
+
/** Request-scoped callers bound the control prefix wait; lifecycle callers omit it. */
|
|
211
|
+
controlLockTimeoutMs?: number;
|
|
182
212
|
}): Promise<SubmitHumanPromptResult>;
|
|
183
213
|
export declare function sendAgentMessageInTransaction(db: SessionActivityDatabase, input: {
|
|
184
214
|
accountId: string;
|
|
@@ -189,6 +219,11 @@ export declare function sendAgentMessageInTransaction(db: SessionActivityDatabas
|
|
|
189
219
|
}>;
|
|
190
220
|
operationKey: string;
|
|
191
221
|
text: string;
|
|
222
|
+
/**
|
|
223
|
+
* Bound the workspace control prefix wait (request-scoped API callers pass
|
|
224
|
+
* `workspaceControlRequestLockTimeoutMs()`); omit for lifecycle callers.
|
|
225
|
+
*/
|
|
226
|
+
controlLockTimeoutMs?: number;
|
|
192
227
|
}): Promise<AgentInternalUpdateCommandResult>;
|
|
193
228
|
export declare function steerAgentSessionInTransaction(db: SessionActivityDatabase, input: {
|
|
194
229
|
accountId: string;
|
|
@@ -199,5 +234,7 @@ export declare function steerAgentSessionInTransaction(db: SessionActivityDataba
|
|
|
199
234
|
}>;
|
|
200
235
|
operationKey: string;
|
|
201
236
|
instruction: string;
|
|
237
|
+
/** Request-scoped callers bound the control prefix wait; lifecycle callers omit it. */
|
|
238
|
+
controlLockTimeoutMs?: number;
|
|
202
239
|
}): Promise<AgentInternalUpdateCommandResult>;
|
|
203
240
|
export {};
|
|
@@ -105,6 +105,8 @@ export type SessionRealtimeInboundEntryInput = {
|
|
|
105
105
|
modelContext?: string | undefined;
|
|
106
106
|
};
|
|
107
107
|
export type SyncSessionRealtimeLedgerInput = AssertSessionRealtimeOwnerInput & {
|
|
108
|
+
/** Request-scoped callers bound the control prefix wait; lifecycle callers omit it. */
|
|
109
|
+
controlLockTimeoutMs?: number;
|
|
108
110
|
connectionId: string;
|
|
109
111
|
connectionEpoch: number;
|
|
110
112
|
entries?: SessionRealtimeInboundEntryInput[] | undefined;
|
|
@@ -1,5 +1,31 @@
|
|
|
1
|
+
import { type SessionTenancyBlocker } from "@opengeni/contracts";
|
|
1
2
|
import { type Database } from "./database.js";
|
|
3
|
+
export declare class SessionTenancyConflictError extends Error {
|
|
4
|
+
readonly reason: "not_quiescent" | "authority_epoch" | "operation_reuse";
|
|
5
|
+
readonly blocker: SessionTenancyBlocker | null;
|
|
6
|
+
readonly name = "SessionTenancyConflictError";
|
|
7
|
+
constructor(reason: "not_quiescent" | "authority_epoch" | "operation_reuse", blocker?: SessionTenancyBlocker | null, options?: ErrorOptions);
|
|
8
|
+
}
|
|
9
|
+
export declare class SessionTenancyNotActivatedError extends Error {
|
|
10
|
+
readonly name = "SessionTenancyNotActivatedError";
|
|
11
|
+
constructor(options?: ErrorOptions);
|
|
12
|
+
}
|
|
13
|
+
export declare class SessionTenancyAccessError extends Error {
|
|
14
|
+
readonly name = "SessionTenancyAccessError";
|
|
15
|
+
constructor(options?: ErrorOptions);
|
|
16
|
+
}
|
|
17
|
+
export declare class SessionTenancyInvalidRequestError extends Error {
|
|
18
|
+
readonly name = "SessionTenancyInvalidRequestError";
|
|
19
|
+
constructor(options?: ErrorOptions);
|
|
20
|
+
}
|
|
21
|
+
/** Extract only the fixed quiescence DETAIL vocabulary, never arbitrary driver detail. */
|
|
22
|
+
export declare function nestedSessionTenancyBlocker(error: unknown): SessionTenancyBlocker | null;
|
|
2
23
|
export type SessionTenancyVisibility = "user_private" | "workspace_shared";
|
|
24
|
+
export type PrivateSessionCreatePolicy = {
|
|
25
|
+
personalWorkspace: boolean;
|
|
26
|
+
platformAvailable: boolean;
|
|
27
|
+
organizationEnabled: boolean;
|
|
28
|
+
};
|
|
3
29
|
export type TransitionSessionVisibilityInput = {
|
|
4
30
|
workspaceId: string;
|
|
5
31
|
sessionId: string;
|
|
@@ -10,6 +36,8 @@ export type TransitionSessionVisibilityInput = {
|
|
|
10
36
|
};
|
|
11
37
|
export type TransitionSessionVisibilityResult = {
|
|
12
38
|
operationId: string;
|
|
39
|
+
eventId: string | null;
|
|
40
|
+
eventSequence: number | null;
|
|
13
41
|
visibility: SessionTenancyVisibility;
|
|
14
42
|
authorityEpoch: number;
|
|
15
43
|
ownerOrganizationMembershipId: string | null;
|
|
@@ -27,10 +55,13 @@ export type ForkSessionContentInput = {
|
|
|
27
55
|
actorSubjectId: string;
|
|
28
56
|
destinationWorkspaceId: string;
|
|
29
57
|
destinationVisibility: SessionTenancyVisibility;
|
|
58
|
+
workspaceSharedAcknowledged: boolean;
|
|
30
59
|
operationKey: string;
|
|
31
60
|
};
|
|
32
61
|
export type ForkSessionContentResult = {
|
|
33
62
|
operationId: string;
|
|
63
|
+
eventId: string;
|
|
64
|
+
eventSequence: number;
|
|
34
65
|
sessionId: string;
|
|
35
66
|
workspaceId: string;
|
|
36
67
|
visibility: SessionTenancyVisibility;
|
|
@@ -38,7 +69,46 @@ export type ForkSessionContentResult = {
|
|
|
38
69
|
copiedHistoryItemCount: number;
|
|
39
70
|
replay: boolean;
|
|
40
71
|
};
|
|
72
|
+
export declare function sessionTenancyProductActivated(db: Database, workspaceId: string): Promise<boolean>;
|
|
73
|
+
export declare function getPrivateSessionCreatePolicy(db: Database, input: {
|
|
74
|
+
workspaceId: string;
|
|
75
|
+
actorSubjectId: string;
|
|
76
|
+
}): Promise<PrivateSessionCreatePolicy>;
|
|
77
|
+
/** Open the exact transaction-local trigger capability used by atomic private create. */
|
|
78
|
+
export declare function openPrivateSessionCreateCapability(db: Database, input: {
|
|
79
|
+
accountId: string;
|
|
80
|
+
workspaceId: string;
|
|
81
|
+
sessionId: string;
|
|
82
|
+
actorSubjectId: string;
|
|
83
|
+
}): Promise<{
|
|
84
|
+
capabilityId: string;
|
|
85
|
+
ownerMembershipId: string;
|
|
86
|
+
}>;
|
|
87
|
+
/** Open the exact transaction-local capability for one private child insert. */
|
|
88
|
+
export declare function openPrivateChildSessionCreateCapability(db: Database, input: {
|
|
89
|
+
accountId: string;
|
|
90
|
+
workspaceId: string;
|
|
91
|
+
sessionId: string;
|
|
92
|
+
parentSessionId: string;
|
|
93
|
+
actorTurnId: string;
|
|
94
|
+
actorAttemptId: string;
|
|
95
|
+
actorExecutionGeneration: number;
|
|
96
|
+
}): Promise<{
|
|
97
|
+
capabilityId: string;
|
|
98
|
+
ownerMembershipId: string;
|
|
99
|
+
ownerSubjectId: string;
|
|
100
|
+
}>;
|
|
101
|
+
export declare function closePrivateSessionCreateCapability(db: Database, capabilityId: string): Promise<void>;
|
|
41
102
|
export declare function canonicalSessionVisibilityTransitionHash(input: Pick<TransitionSessionVisibilityInput, "sessionId" | "targetVisibility" | "expectedAuthorityEpoch">): string;
|
|
42
|
-
export declare function canonicalSessionForkHash(input: Pick<ForkSessionContentInput, "sourceSessionId" | "destinationWorkspaceId" | "destinationVisibility">): string;
|
|
103
|
+
export declare function canonicalSessionForkHash(input: Pick<ForkSessionContentInput, "sourceSessionId" | "destinationWorkspaceId" | "destinationVisibility" | "workspaceSharedAcknowledged">): string;
|
|
43
104
|
export declare function transitionSessionVisibility(db: Database, input: TransitionSessionVisibilityInput): Promise<TransitionSessionVisibilityResult>;
|
|
44
105
|
export declare function forkSessionContent(db: Database, input: ForkSessionContentInput): Promise<ForkSessionContentResult>;
|
|
106
|
+
/**
|
|
107
|
+
* Recover one exact committed fork before mutable source-session authorization.
|
|
108
|
+
*
|
|
109
|
+
* The database capability requires the authenticated actor's active workspace
|
|
110
|
+
* authority and matches the complete actor/workspace/source/key/request-hash
|
|
111
|
+
* tuple. A fresh key returns null; changed intent raises the ordinary tenancy
|
|
112
|
+
* idempotency conflict. This is receipt recovery, not session discovery.
|
|
113
|
+
*/
|
|
114
|
+
export declare function replayAppliedSessionFork(db: Database, input: ForkSessionContentInput): Promise<ForkSessionContentResult | null>;
|
package/dist/session-tenancy.js
CHANGED
|
@@ -1,16 +1,38 @@
|
|
|
1
1
|
import {
|
|
2
|
+
SessionTenancyAccessError,
|
|
3
|
+
SessionTenancyConflictError,
|
|
4
|
+
SessionTenancyInvalidRequestError,
|
|
5
|
+
SessionTenancyNotActivatedError,
|
|
2
6
|
canonicalSessionForkHash,
|
|
3
7
|
canonicalSessionVisibilityTransitionHash,
|
|
8
|
+
closePrivateSessionCreateCapability,
|
|
4
9
|
forkSessionContent,
|
|
10
|
+
getPrivateSessionCreatePolicy,
|
|
11
|
+
nestedSessionTenancyBlocker,
|
|
12
|
+
openPrivateChildSessionCreateCapability,
|
|
13
|
+
openPrivateSessionCreateCapability,
|
|
14
|
+
replayAppliedSessionFork,
|
|
15
|
+
sessionTenancyProductActivated,
|
|
5
16
|
transitionSessionVisibility
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-TIKF3KTI.js";
|
|
18
|
+
import "./chunk-SCPUJS53.js";
|
|
19
|
+
import "./chunk-PR2WMLOQ.js";
|
|
9
20
|
import "./chunk-PZ5AY32C.js";
|
|
10
21
|
export {
|
|
22
|
+
SessionTenancyAccessError,
|
|
23
|
+
SessionTenancyConflictError,
|
|
24
|
+
SessionTenancyInvalidRequestError,
|
|
25
|
+
SessionTenancyNotActivatedError,
|
|
11
26
|
canonicalSessionForkHash,
|
|
12
27
|
canonicalSessionVisibilityTransitionHash,
|
|
28
|
+
closePrivateSessionCreateCapability,
|
|
13
29
|
forkSessionContent,
|
|
30
|
+
getPrivateSessionCreatePolicy,
|
|
31
|
+
nestedSessionTenancyBlocker,
|
|
32
|
+
openPrivateChildSessionCreateCapability,
|
|
33
|
+
openPrivateSessionCreateCapability,
|
|
34
|
+
replayAppliedSessionFork,
|
|
35
|
+
sessionTenancyProductActivated,
|
|
14
36
|
transitionSessionVisibility
|
|
15
37
|
};
|
|
16
38
|
//# sourceMappingURL=session-tenancy.js.map
|
|
@@ -18,12 +18,17 @@ export type ClosePendingSessionToolCallsInput = {
|
|
|
18
18
|
reason: string;
|
|
19
19
|
sequence: number;
|
|
20
20
|
now: Date;
|
|
21
|
+
turnAssociation?: "current" | null;
|
|
22
|
+
preserveInterruptionRows?: boolean;
|
|
21
23
|
};
|
|
22
24
|
/**
|
|
23
|
-
* Close
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
25
|
+
* Close raw tool calls for a logical turn while its owning session/turn locks
|
|
26
|
+
* are held. Recoverable transitions preserve interruption rows because those
|
|
27
|
+
* rows are the exact open-suffix resume authority for a replacement attempt;
|
|
28
|
+
* ordinary in-flight rows still receive durable outcome-unknown settlement.
|
|
29
|
+
* Terminal and superseding transitions close every row. Durable results win;
|
|
30
|
+
* repeated settlement is an exact no-op after the selected ledger rows are
|
|
31
|
+
* deleted.
|
|
27
32
|
*/
|
|
28
33
|
export declare function closePendingSessionToolCallsInTransaction(tx: Database, input: ClosePendingSessionToolCallsInput): Promise<{
|
|
29
34
|
sequence: number;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Database } from "./database.js";
|
|
2
|
+
/**
|
|
3
|
+
* The subject's own personal workspace in one organization, or null.
|
|
4
|
+
*
|
|
5
|
+
* Only an `active` membership counts, and only that membership's own
|
|
6
|
+
* `personalWorkspaceId` pointer is read - never a default workspace, a
|
|
7
|
+
* `created_by`, or current access.
|
|
8
|
+
*
|
|
9
|
+
* Non-`user:` subjects (API keys, delegated service principals, configured and
|
|
10
|
+
* local principals) can never own an organization membership, so they
|
|
11
|
+
* short-circuit rather than tripping `list_self_organization_memberships`'
|
|
12
|
+
* `42501` guard.
|
|
13
|
+
*
|
|
14
|
+
* ORACLE, NOT AN AUTHORIZATION. This answers "which workspace is this named
|
|
15
|
+
* subject's own" for whatever subject it is handed; it does not establish that
|
|
16
|
+
* the caller IS that subject. Pass only a subject authenticated out of band -
|
|
17
|
+
* for Slack, one named by a durable `slack_bot_user_links` row. Never pass a
|
|
18
|
+
* subject taken from a request payload.
|
|
19
|
+
*/
|
|
20
|
+
export declare function namedSubjectPersonalWorkspaceId(db: Database, input: {
|
|
21
|
+
accountId: string;
|
|
22
|
+
subjectId: string;
|
|
23
|
+
}): Promise<string | null>;
|