@opengeni/db 0.28.1 → 0.31.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/attached-browser-devices.d.ts +42 -0
- package/dist/attempt-tool-catalogs.d.ts +16 -0
- package/dist/browser-auth.d.ts +91 -0
- package/dist/browser-identities.d.ts +128 -0
- package/dist/browser-sessions.d.ts +272 -0
- package/dist/browser-state-artifacts.d.ts +17 -0
- package/dist/capability-components.d.ts +37 -0
- package/dist/capability-integrations.d.ts +192 -0
- package/dist/chunk-F5FT7BEZ.js +3535 -0
- package/dist/chunk-F5FT7BEZ.js.map +1 -0
- package/dist/chunk-ISI2TIUG.js +639 -0
- package/dist/chunk-ISI2TIUG.js.map +1 -0
- package/dist/chunk-MWDVXQOL.js +11639 -0
- package/dist/chunk-MWDVXQOL.js.map +1 -0
- package/dist/chunk-NBE6CHRI.js +955 -0
- package/dist/chunk-NBE6CHRI.js.map +1 -0
- package/dist/{chunk-DBS5HPEW.js → chunk-YHZXQ7HP.js} +760 -11
- package/dist/chunk-YHZXQ7HP.js.map +1 -0
- package/dist/codemode-operations.d.ts +117 -0
- package/dist/codex-token-resolver.d.ts +2 -2
- package/dist/company-profile-schema.d.ts +798 -0
- package/dist/company-profile.d.ts +268 -0
- package/dist/computer-sessions.d.ts +109 -0
- package/dist/connection-token-resolver.d.ts +9 -4
- package/dist/database.d.ts +52 -3
- package/dist/editable-artifact-durable-export.d.ts +153 -0
- package/dist/editable-artifact-durable-export.js +788 -0
- package/dist/editable-artifact-durable-export.js.map +1 -0
- package/dist/editable-artifact-materialization.d.ts +123 -0
- package/dist/editable-artifacts-schema.d.ts +4152 -0
- package/dist/editable-artifacts.d.ts +610 -0
- package/dist/editable-artifacts.js +26 -0
- package/dist/editable-artifacts.js.map +1 -0
- package/dist/environment-crypto.d.ts +8 -4
- package/dist/generated-images.d.ts +139 -0
- package/dist/index.d.ts +958 -126
- package/dist/index.js +31204 -12172
- package/dist/index.js.map +1 -1
- package/dist/insights.d.ts +51 -4
- package/dist/integration-bindings.d.ts +70 -0
- package/dist/integration-features.d.ts +99 -0
- package/dist/interaction-revisions.d.ts +3 -0
- package/dist/interaction-schema.d.ts +5372 -0
- package/dist/knowledge-source-sync-schema.d.ts +1679 -0
- package/dist/knowledge-source-sync.d.ts +274 -0
- package/dist/lossless-columns.d.ts +58 -0
- package/dist/lossless-json.d.ts +39 -0
- package/dist/memory-domain.d.ts +3 -6
- package/dist/memory-governance.d.ts +2 -2
- package/dist/memory-slack-delivery.d.ts +101 -0
- package/dist/new-session-drafts.d.ts +2 -2
- package/dist/pack-components.d.ts +76 -0
- package/dist/pack-installations.d.ts +86 -0
- package/dist/persistence-errors.d.ts +7 -14
- package/dist/plugin-packages.d.ts +126 -0
- package/dist/preference-registry.d.ts +1 -1
- package/dist/provision-roles.d.ts +9 -1
- package/dist/provision-roles.js +1 -1
- package/dist/runtime-posture.d.ts +18 -6
- package/dist/schema.d.ts +19122 -8731
- package/dist/schema.js +173 -1
- package/dist/scoped-knowledge.d.ts +97 -1
- package/dist/session-control.d.ts +4 -4
- package/dist/session-queue-commands.d.ts +19 -11
- package/dist/session-realtime-context.d.ts +2 -2
- package/dist/session-realtime-ledger.d.ts +4 -4
- package/dist/session-realtime-mirror.d.ts +2 -2
- package/dist/session-realtime-state.d.ts +1 -1
- package/dist/session-realtime-terminal.d.ts +8 -1
- package/dist/session-realtime.d.ts +7 -7
- package/dist/session-tool-call-settlement.d.ts +1 -1
- package/dist/slack-user-link-access.d.ts +54 -0
- package/dist/transcription-recordings-schema.d.ts +44 -6
- package/dist/transcription-recordings.d.ts +3 -3
- package/dist/turn-initiator.d.ts +2 -2
- package/dist/video-generation.d.ts +216 -0
- package/dist/video-generation.js +66 -0
- package/dist/video-generation.js.map +1 -0
- package/dist/workspace-artifacts.d.ts +1 -1
- package/dist/workspace-instruction-policies.d.ts +1 -1
- package/dist/workspace-learning-policy-schema.d.ts +932 -0
- package/dist/workspace-learning-policy.d.ts +161 -0
- package/drizzle/0065_enrollment_credential_generation.sql +10 -0
- package/drizzle/0140_retained_screenshot_artifacts.sql +192 -0
- package/drizzle/0176_lossless_canonical_json.sql +975 -0
- package/drizzle/0177_session_events_workspace_turn_type_index.sql +5 -0
- package/drizzle/0178_permissioned_secret_reads.sql +14 -0
- package/drizzle/0179_slack_private_shortcut_delivery_gate.sql +85 -0
- package/drizzle/0180_retained_screenshot_lifecycle_fences.sql +273 -0
- package/drizzle/0181_connected_machine_removal.sql +52 -0
- package/drizzle/0182_connected_machine_remove_session_default.sql +77 -0
- package/drizzle/0183_model_call_provider_cost_estimates.sql +39 -0
- package/drizzle/0184_sandbox_drain_teardown_fence.sql +682 -0
- package/drizzle/0185_temporal_schedule_cleanup_outbox.sql +168 -0
- package/drizzle/0186_sandbox_capture_provider_contract.sql +400 -0
- package/drizzle/0187_generated_image_artifacts.sql +173 -0
- package/drizzle/0188_image_generation_retention_failure.sql +25 -0
- package/drizzle/0189_retained_session_image_formats.sql +13 -0
- package/drizzle/0190_timeline_annotations.sql +31 -0
- package/drizzle/0191_editable_artifact_engine.sql +3853 -0
- package/drizzle/0192_editable_artifact_live_tickets.sql +338 -0
- package/drizzle/0193_editable_artifact_authorization.sql +190 -0
- package/drizzle/0194_editable_artifact_durable_exports.sql +160 -0
- package/drizzle/0195_editable_artifact_import_authorization.sql +203 -0
- package/drizzle/0196_rig_provider_images.sql +152 -0
- package/drizzle/0197_knowledge_source_sync_schedules.sql +523 -0
- package/drizzle/0198_memory_slack_publication_delivery.sql +393 -0
- package/drizzle/0199_workspace_learning_policy.sql +980 -0
- package/drizzle/0201_company_profile_authority.sql +849 -0
- package/drizzle/0202_document_index_checkpoints.sql +85 -0
- package/drizzle/0203_durable_video_generation.sql +353 -0
- package/drizzle/0204_video_generation_funding.sql +44 -0
- package/drizzle/0205_attempt_tool_catalogs.sql +230 -0
- package/drizzle/0206_browser_sessions.sql +646 -0
- package/drizzle/0207_browser_identities.sql +379 -0
- package/drizzle/0208_attached_browser_devices.sql +165 -0
- package/drizzle/0209_computer_sessions.sql +575 -0
- package/drizzle/0210_browser_auth_network_interventions.sql +441 -0
- package/drizzle/0211_editable_artifact_session_links.sql +58 -0
- package/drizzle/0212_slack_installation_bindings.sql +348 -0
- package/drizzle/0213_slack_user_link_access_requests.sql +177 -0
- package/drizzle/0214_session_activity_commit_gate.sql +262 -0
- package/drizzle/0215_capabilities_platform.sql +980 -0
- package/drizzle/0216_pack_component_ownership.sql +235 -0
- package/drizzle/0217_capability_definition_delete_authority.sql +32 -0
- package/package.json +18 -5
- package/src/attached-browser-devices.ts +371 -0
- package/src/attempt-tool-catalogs.ts +131 -0
- package/src/browser-auth.ts +1896 -0
- package/src/browser-identities.ts +1168 -0
- package/src/browser-sessions.ts +2005 -0
- package/src/browser-state-artifacts.ts +59 -0
- package/src/capability-components.ts +166 -0
- package/src/capability-integrations.ts +1663 -0
- package/src/codemode-operations.ts +674 -0
- package/src/company-profile-schema.ts +143 -0
- package/src/company-profile.ts +968 -0
- package/src/computer-sessions.ts +1130 -0
- package/src/connection-token-resolver.ts +270 -25
- package/src/database.ts +434 -24
- package/src/editable-artifact-durable-export.ts +1201 -0
- package/src/editable-artifact-materialization.ts +893 -0
- package/src/editable-artifacts-schema.ts +879 -0
- package/src/editable-artifacts.ts +5404 -0
- package/src/environment-crypto.ts +22 -9
- package/src/generated-images.ts +740 -0
- package/src/index.ts +10117 -2730
- package/src/insights.ts +160 -13
- package/src/integration-bindings.ts +455 -0
- package/src/integration-features.ts +859 -0
- package/src/interaction-revisions.ts +40 -0
- package/src/interaction-schema.ts +1303 -0
- package/src/knowledge-source-sync-schema.ts +192 -0
- package/src/knowledge-source-sync.ts +1922 -0
- package/src/lossless-columns.ts +35 -0
- package/src/lossless-json.ts +322 -0
- package/src/memory-domain.ts +5 -44
- package/src/memory-slack-delivery.ts +801 -0
- package/src/pack-components.ts +954 -0
- package/src/pack-installations.ts +929 -0
- package/src/persistence-errors.ts +26 -34
- package/src/plugin-packages.ts +1186 -0
- package/src/provision-roles.ts +302 -1
- package/src/runtime-posture-cli.ts +9 -0
- package/src/runtime-posture.ts +514 -5
- package/src/schema.ts +5177 -2957
- package/src/scoped-knowledge-schema.ts +1 -1
- package/src/scoped-knowledge.ts +655 -3
- package/src/session-control.ts +133 -81
- package/src/session-queue-commands.ts +511 -247
- package/src/session-realtime-context.ts +20 -7
- package/src/session-realtime-ledger.ts +32 -10
- package/src/session-realtime-mirror.ts +4 -2
- package/src/session-realtime-terminal.ts +89 -21
- package/src/session-realtime.ts +10 -9
- package/src/session-tool-call-settlement.ts +38 -15
- package/src/slack-user-link-access.ts +702 -0
- package/src/transcription-recordings-schema.ts +5 -2
- package/src/transcription-recordings.ts +70 -40
- package/src/video-generation.ts +1452 -0
- package/src/workspace-learning-policy-schema.ts +139 -0
- package/src/workspace-learning-policy.ts +595 -0
- package/dist/chunk-DBS5HPEW.js.map +0 -1
- package/dist/chunk-HT5T62CC.js +0 -6803
- package/dist/chunk-HT5T62CC.js.map +0 -1
- package/dist/event-payload-sanitizer.d.ts +0 -32
- package/src/event-payload-sanitizer.ts +0 -377
package/src/session-control.ts
CHANGED
|
@@ -7,7 +7,8 @@ import {
|
|
|
7
7
|
type TurnInitiatorContext,
|
|
8
8
|
} from "@opengeni/contracts";
|
|
9
9
|
import { and, eq, inArray, sql } from "drizzle-orm";
|
|
10
|
-
import type { Database } from "./database";
|
|
10
|
+
import type { Database, SessionActivityDatabase } from "./database";
|
|
11
|
+
import { withLosslessContentWriteVersion } from "./lossless-json";
|
|
11
12
|
import * as schema from "./schema";
|
|
12
13
|
import { closePendingSessionToolCallsInTransaction } from "./session-tool-call-settlement";
|
|
13
14
|
import {
|
|
@@ -15,6 +16,10 @@ import {
|
|
|
15
16
|
renderRealtimeHumanInputResponseContext,
|
|
16
17
|
} from "./session-realtime-mirror";
|
|
17
18
|
|
|
19
|
+
type SessionEventInsertWithPayload = typeof schema.sessionEvents.$inferInsert & {
|
|
20
|
+
payload: unknown;
|
|
21
|
+
};
|
|
22
|
+
|
|
18
23
|
export const SESSION_ANCESTRY_LIMIT = 10_000;
|
|
19
24
|
|
|
20
25
|
export type WorkspaceControlLockMode = "none" | "share" | "update";
|
|
@@ -1158,7 +1163,10 @@ export async function evaluateSessionDiscoveryControls(
|
|
|
1158
1163
|
);
|
|
1159
1164
|
}
|
|
1160
1165
|
|
|
1161
|
-
|
|
1166
|
+
// Discovery owns one read-only repeatable-read snapshot, so this projection
|
|
1167
|
+
// must not join the writer lock graph merely to keep workspace/session facts
|
|
1168
|
+
// coherent. The snapshot is the consistency boundary.
|
|
1169
|
+
const workspace = await lockWorkspaceInferenceControl(db, workspaceId, "none");
|
|
1162
1170
|
const workspacePauseRevision = asSafeRevision(
|
|
1163
1171
|
workspace.workspacePauseRevision,
|
|
1164
1172
|
"workspace pause revision",
|
|
@@ -1940,7 +1948,9 @@ async function enqueueCancelledChildOutboxInTransaction(
|
|
|
1940
1948
|
[];
|
|
1941
1949
|
if (input.rootSession.parentTurnId) {
|
|
1942
1950
|
const [parentTurn] = await db
|
|
1943
|
-
.select({
|
|
1951
|
+
.select({
|
|
1952
|
+
delegations: schema.sessionTurns.personalConnectionDelegations,
|
|
1953
|
+
})
|
|
1944
1954
|
.from(schema.sessionTurns)
|
|
1945
1955
|
.where(
|
|
1946
1956
|
and(
|
|
@@ -1957,33 +1967,47 @@ async function enqueueCancelledChildOutboxInTransaction(
|
|
|
1957
1967
|
`Invalid personal MCP delegation snapshot at session_turns:${input.workspaceId}:${parentSessionId}:${input.rootSession.parentTurnId}`,
|
|
1958
1968
|
);
|
|
1959
1969
|
}
|
|
1960
|
-
personalConnectionDelegations = parsed.data.map((delegation) => ({
|
|
1970
|
+
personalConnectionDelegations = parsed.data.map((delegation) => ({
|
|
1971
|
+
...delegation,
|
|
1972
|
+
}));
|
|
1961
1973
|
}
|
|
1962
1974
|
}
|
|
1963
1975
|
await db
|
|
1964
1976
|
.insert(schema.sessionSystemUpdateOutbox)
|
|
1965
|
-
.values(
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1977
|
+
.values(
|
|
1978
|
+
withLosslessContentWriteVersion(
|
|
1979
|
+
withLosslessContentWriteVersion(
|
|
1980
|
+
{
|
|
1981
|
+
accountId: input.rootSession.accountId,
|
|
1982
|
+
workspaceId: input.workspaceId,
|
|
1983
|
+
sourceSessionId: input.rootSession.id,
|
|
1984
|
+
targetSessionId: parentSessionId,
|
|
1985
|
+
dedupeKey: `child-completion:${input.rootSession.id}:cancelled`,
|
|
1986
|
+
kind: "child_terminal_result",
|
|
1987
|
+
classification: "info",
|
|
1988
|
+
sourceId: input.rootSession.id,
|
|
1989
|
+
summary: "Child session was terminally cancelled.",
|
|
1990
|
+
payload: {
|
|
1991
|
+
type: "child_terminal_result",
|
|
1992
|
+
childSessionId: input.rootSession.id,
|
|
1993
|
+
status: "cancelled",
|
|
1994
|
+
},
|
|
1995
|
+
lineage: {
|
|
1996
|
+
childSessionId: input.rootSession.id,
|
|
1997
|
+
parentSessionId,
|
|
1998
|
+
...(input.rootSession.parentTurnId
|
|
1999
|
+
? { parentTurnId: input.rootSession.parentTurnId }
|
|
2000
|
+
: {}),
|
|
2001
|
+
},
|
|
2002
|
+
personalConnectionDelegations,
|
|
2003
|
+
},
|
|
2004
|
+
"summary",
|
|
2005
|
+
"summaryCodecVersion",
|
|
2006
|
+
),
|
|
2007
|
+
"payload",
|
|
2008
|
+
"payloadCodecVersion",
|
|
2009
|
+
),
|
|
2010
|
+
)
|
|
1987
2011
|
.onConflictDoNothing({
|
|
1988
2012
|
target: [
|
|
1989
2013
|
schema.sessionSystemUpdateOutbox.workspaceId,
|
|
@@ -2029,7 +2053,7 @@ async function assertSessionBranchIsNotCancelled(
|
|
|
2029
2053
|
}
|
|
2030
2054
|
|
|
2031
2055
|
async function cancelSessionSubtreeInTransaction(
|
|
2032
|
-
db:
|
|
2056
|
+
db: SessionActivityDatabase,
|
|
2033
2057
|
input: {
|
|
2034
2058
|
accountId: string;
|
|
2035
2059
|
workspaceId: string;
|
|
@@ -2142,7 +2166,11 @@ async function cancelSessionSubtreeInTransaction(
|
|
|
2142
2166
|
});
|
|
2143
2167
|
await db
|
|
2144
2168
|
.update(schema.codexCapacityWaiters)
|
|
2145
|
-
.set({
|
|
2169
|
+
.set({
|
|
2170
|
+
status: "superseded",
|
|
2171
|
+
lastWakeReason: "session_cancelled",
|
|
2172
|
+
updatedAt: now,
|
|
2173
|
+
})
|
|
2146
2174
|
.where(
|
|
2147
2175
|
and(
|
|
2148
2176
|
eq(schema.codexCapacityWaiters.workspaceId, input.workspaceId),
|
|
@@ -2178,13 +2206,16 @@ async function cancelSessionSubtreeInTransaction(
|
|
|
2178
2206
|
else systemUpdatesBySession.set(update.sessionId, [update]);
|
|
2179
2207
|
}
|
|
2180
2208
|
|
|
2181
|
-
const affectedSessionEvents: Array<{
|
|
2209
|
+
const affectedSessionEvents: Array<{
|
|
2210
|
+
sessionId: string;
|
|
2211
|
+
eventIds: string[];
|
|
2212
|
+
}> = [];
|
|
2182
2213
|
for (const session of input.lockedSessions) {
|
|
2183
2214
|
if (!sessionIdSet.has(session.id)) continue;
|
|
2184
2215
|
let sequence = session.lastSequence + (session.id === input.rootSessionId ? 1 : 0);
|
|
2185
2216
|
const cancelledTurns = cancelledTurnsBySession.get(session.id) ?? [];
|
|
2186
2217
|
const preinsertedEvents: Array<{ id: string; sequence: number }> = [];
|
|
2187
|
-
const eventValues:
|
|
2218
|
+
const eventValues: SessionEventInsertWithPayload[] = [];
|
|
2188
2219
|
for (const update of (systemUpdatesBySession.get(session.id) ?? []).sort((left, right) =>
|
|
2189
2220
|
left.id.localeCompare(right.id),
|
|
2190
2221
|
)) {
|
|
@@ -2210,7 +2241,10 @@ async function cancelSessionSubtreeInTransaction(
|
|
|
2210
2241
|
});
|
|
2211
2242
|
sequence = closedTools.sequence;
|
|
2212
2243
|
preinsertedEvents.push(
|
|
2213
|
-
...closedTools.events.map((event) => ({
|
|
2244
|
+
...closedTools.events.map((event) => ({
|
|
2245
|
+
id: event.id,
|
|
2246
|
+
sequence: event.sequence,
|
|
2247
|
+
})),
|
|
2214
2248
|
);
|
|
2215
2249
|
for (const humanInput of (humanInputsByTurn.get(turn.id) ?? []).sort((left, right) =>
|
|
2216
2250
|
left.id.localeCompare(right.id),
|
|
@@ -2224,7 +2258,10 @@ async function cancelSessionSubtreeInTransaction(
|
|
|
2224
2258
|
turnId: turn.id,
|
|
2225
2259
|
turnGeneration: turn.executionGeneration,
|
|
2226
2260
|
...(turn.id === session.activeTurnId ? { turnAssociation: "current" as const } : {}),
|
|
2227
|
-
payload: {
|
|
2261
|
+
payload: {
|
|
2262
|
+
requestId: humanInput.id,
|
|
2263
|
+
response: { outcome: "cancelled" },
|
|
2264
|
+
},
|
|
2228
2265
|
occurredAt: now,
|
|
2229
2266
|
});
|
|
2230
2267
|
}
|
|
@@ -2261,13 +2298,16 @@ async function cancelSessionSubtreeInTransaction(
|
|
|
2261
2298
|
}
|
|
2262
2299
|
const inserted =
|
|
2263
2300
|
eventValues.length > 0
|
|
2264
|
-
? await db
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2301
|
+
? await db
|
|
2302
|
+
.insert(schema.sessionEvents)
|
|
2303
|
+
.values(withLosslessContentWriteVersion(eventValues, "payload", "payloadCodecVersion"))
|
|
2304
|
+
.returning({
|
|
2305
|
+
id: schema.sessionEvents.id,
|
|
2306
|
+
sequence: schema.sessionEvents.sequence,
|
|
2307
|
+
type: schema.sessionEvents.type,
|
|
2308
|
+
turnId: schema.sessionEvents.turnId,
|
|
2309
|
+
payload: schema.sessionEvents.payload,
|
|
2310
|
+
})
|
|
2271
2311
|
: [];
|
|
2272
2312
|
const cancelledHumanInputsById = new Map(
|
|
2273
2313
|
cancelledHumanInputs
|
|
@@ -2338,7 +2378,7 @@ async function cancelSessionSubtreeInTransaction(
|
|
|
2338
2378
|
}
|
|
2339
2379
|
|
|
2340
2380
|
export async function mutateSessionControlInTransaction(
|
|
2341
|
-
db:
|
|
2381
|
+
db: SessionActivityDatabase,
|
|
2342
2382
|
input: {
|
|
2343
2383
|
accountId: string;
|
|
2344
2384
|
workspaceId: string;
|
|
@@ -2548,25 +2588,31 @@ export async function mutateSessionControlInTransaction(
|
|
|
2548
2588
|
});
|
|
2549
2589
|
const [controlEvent] = await db
|
|
2550
2590
|
.insert(schema.sessionEvents)
|
|
2551
|
-
.values(
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2591
|
+
.values(
|
|
2592
|
+
withLosslessContentWriteVersion(
|
|
2593
|
+
{
|
|
2594
|
+
accountId: input.accountId,
|
|
2595
|
+
workspaceId: input.workspaceId,
|
|
2596
|
+
sessionId: input.sessionId,
|
|
2597
|
+
sequence: updated.lastSequence + 1,
|
|
2598
|
+
type:
|
|
2599
|
+
input.action === "pause" || input.action === "cancel"
|
|
2600
|
+
? "session.control.paused"
|
|
2601
|
+
: "session.control.resumed",
|
|
2602
|
+
payload: {
|
|
2603
|
+
operationId: reserved.receipt.id,
|
|
2604
|
+
revision,
|
|
2605
|
+
actor,
|
|
2606
|
+
...(input.reason ? { reason: input.reason } : {}),
|
|
2607
|
+
...(input.action === "cancel" ? { terminal: true } : {}),
|
|
2608
|
+
interruptionCount,
|
|
2609
|
+
},
|
|
2610
|
+
occurredAt: new Date(),
|
|
2611
|
+
},
|
|
2612
|
+
"payload",
|
|
2613
|
+
"payloadCodecVersion",
|
|
2614
|
+
),
|
|
2615
|
+
)
|
|
2570
2616
|
.returning({ id: schema.sessionEvents.id });
|
|
2571
2617
|
if (!controlEvent)
|
|
2572
2618
|
throw new SessionControlInvariantError("Session control event was not inserted");
|
|
@@ -2574,27 +2620,33 @@ export async function mutateSessionControlInTransaction(
|
|
|
2574
2620
|
.update(schema.sessions)
|
|
2575
2621
|
.set({ lastSequence: updated.lastSequence + 1, updatedAt: new Date() })
|
|
2576
2622
|
.where(eq(schema.sessions.id, input.sessionId));
|
|
2577
|
-
await db.insert(schema.auditEvents).values(
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2623
|
+
await db.insert(schema.auditEvents).values(
|
|
2624
|
+
withLosslessContentWriteVersion(
|
|
2625
|
+
{
|
|
2626
|
+
accountId: input.accountId,
|
|
2627
|
+
workspaceId: input.workspaceId,
|
|
2628
|
+
subjectId: actor,
|
|
2629
|
+
action: `session.control.${input.action}`,
|
|
2630
|
+
targetType: "session",
|
|
2631
|
+
targetId: input.sessionId,
|
|
2632
|
+
metadata: {
|
|
2633
|
+
operationId: reserved.receipt.id,
|
|
2634
|
+
revision,
|
|
2635
|
+
interruptionCount,
|
|
2636
|
+
...(input.actor.type === "agent_attempt"
|
|
2637
|
+
? {
|
|
2638
|
+
callerSessionId: input.actor.sessionId,
|
|
2639
|
+
callerTurnId: input.actor.turnId,
|
|
2640
|
+
callerAttemptId: input.actor.attemptId,
|
|
2641
|
+
callerExecutionGeneration: input.actor.executionGeneration,
|
|
2642
|
+
}
|
|
2643
|
+
: {}),
|
|
2644
|
+
},
|
|
2645
|
+
},
|
|
2646
|
+
"metadata",
|
|
2647
|
+
"metadataCodecVersion",
|
|
2648
|
+
),
|
|
2649
|
+
);
|
|
2598
2650
|
const cancellation =
|
|
2599
2651
|
input.action === "cancel"
|
|
2600
2652
|
? await cancelSessionSubtreeInTransaction(db, {
|
|
@@ -2645,7 +2697,7 @@ export async function mutateSessionControlInTransaction(
|
|
|
2645
2697
|
}
|
|
2646
2698
|
|
|
2647
2699
|
export async function autoResumeSessionBranchInTransaction(
|
|
2648
|
-
db:
|
|
2700
|
+
db: SessionActivityDatabase,
|
|
2649
2701
|
input: {
|
|
2650
2702
|
workspaceId: string;
|
|
2651
2703
|
sessionId: string;
|