@opengeni/db 0.27.3 → 0.27.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-EX7CDSGH.js → chunk-M6EOXYHK.js} +6 -1
- package/dist/chunk-M6EOXYHK.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +151 -36
- package/dist/index.js.map +1 -1
- package/dist/schema.d.ts +17 -0
- package/dist/schema.js +1 -1
- package/dist/session-control.d.ts +1 -0
- package/dist/session-realtime-context.d.ts +1 -1
- package/drizzle/0170_session_control_wake_revision.sql +133 -0
- package/package.json +4 -4
- package/src/index.ts +214 -37
- package/src/schema.ts +5 -0
- package/src/session-control.ts +11 -4
- package/src/session-queue-commands.ts +3 -0
- package/src/session-realtime-context.ts +1 -1
- package/dist/chunk-EX7CDSGH.js.map +0 -1
package/src/session-control.ts
CHANGED
|
@@ -1494,12 +1494,13 @@ async function registerContinuableWakes(
|
|
|
1494
1494
|
)
|
|
1495
1495
|
), upserted as (
|
|
1496
1496
|
insert into ${schema.sessionWorkflowWakeOutbox} (
|
|
1497
|
-
session_id, account_id, workspace_id, temporal_workflow_id, reason
|
|
1497
|
+
session_id, account_id, workspace_id, temporal_workflow_id, reason, control_revision
|
|
1498
1498
|
)
|
|
1499
|
-
select session_id, account_id, workspace_id, temporal_workflow_id, ${input.reason}
|
|
1499
|
+
select session_id, account_id, workspace_id, temporal_workflow_id, ${input.reason}, 1
|
|
1500
1500
|
from eligible
|
|
1501
1501
|
on conflict (session_id) do update set
|
|
1502
1502
|
wake_revision = ${schema.sessionWorkflowWakeOutbox}.wake_revision + 1,
|
|
1503
|
+
control_revision = ${schema.sessionWorkflowWakeOutbox}.wake_revision + 1,
|
|
1503
1504
|
temporal_workflow_id = excluded.temporal_workflow_id,
|
|
1504
1505
|
reason = excluded.reason,
|
|
1505
1506
|
attempts = 0,
|
|
@@ -1611,12 +1612,13 @@ async function registerCancellationWakes(
|
|
|
1611
1612
|
and session.id in (${sessionIds})
|
|
1612
1613
|
), upserted as (
|
|
1613
1614
|
insert into ${schema.sessionWorkflowWakeOutbox} (
|
|
1614
|
-
session_id, account_id, workspace_id, temporal_workflow_id, reason
|
|
1615
|
+
session_id, account_id, workspace_id, temporal_workflow_id, reason, control_revision
|
|
1615
1616
|
)
|
|
1616
|
-
select session_id, account_id, workspace_id, temporal_workflow_id, 'session_cancelled'
|
|
1617
|
+
select session_id, account_id, workspace_id, temporal_workflow_id, 'session_cancelled', 1
|
|
1617
1618
|
from eligible
|
|
1618
1619
|
on conflict (session_id) do update set
|
|
1619
1620
|
wake_revision = ${schema.sessionWorkflowWakeOutbox}.wake_revision + 1,
|
|
1621
|
+
control_revision = ${schema.sessionWorkflowWakeOutbox}.wake_revision + 1,
|
|
1620
1622
|
temporal_workflow_id = excluded.temporal_workflow_id,
|
|
1621
1623
|
reason = excluded.reason,
|
|
1622
1624
|
attempts = 0,
|
|
@@ -1641,6 +1643,7 @@ export async function registerSessionWorkflowWakeInTransaction(
|
|
|
1641
1643
|
sessionId: string;
|
|
1642
1644
|
temporalWorkflowId: string;
|
|
1643
1645
|
reason: string;
|
|
1646
|
+
controlRequested?: boolean;
|
|
1644
1647
|
},
|
|
1645
1648
|
): Promise<number> {
|
|
1646
1649
|
const [row] = await db
|
|
@@ -1650,6 +1653,7 @@ export async function registerSessionWorkflowWakeInTransaction(
|
|
|
1650
1653
|
workspaceId: input.workspaceId,
|
|
1651
1654
|
sessionId: input.sessionId,
|
|
1652
1655
|
temporalWorkflowId: input.temporalWorkflowId,
|
|
1656
|
+
controlRevision: input.controlRequested ? 1 : 0,
|
|
1653
1657
|
reason: input.reason,
|
|
1654
1658
|
})
|
|
1655
1659
|
.onConflictDoUpdate({
|
|
@@ -1657,6 +1661,9 @@ export async function registerSessionWorkflowWakeInTransaction(
|
|
|
1657
1661
|
set: {
|
|
1658
1662
|
temporalWorkflowId: input.temporalWorkflowId,
|
|
1659
1663
|
wakeRevision: sql`${schema.sessionWorkflowWakeOutbox.wakeRevision} + 1`,
|
|
1664
|
+
controlRevision: input.controlRequested
|
|
1665
|
+
? sql`${schema.sessionWorkflowWakeOutbox.wakeRevision} + 1`
|
|
1666
|
+
: sql`${schema.sessionWorkflowWakeOutbox.controlRevision}`,
|
|
1660
1667
|
reason: input.reason,
|
|
1661
1668
|
attempts: 0,
|
|
1662
1669
|
nextAttemptAt: new Date(),
|
|
@@ -1180,6 +1180,7 @@ export async function steerQueuedTurnInTransaction(
|
|
|
1180
1180
|
sessionId: input.sessionId,
|
|
1181
1181
|
temporalWorkflowId: session.temporalWorkflowId ?? `session-${input.sessionId}`,
|
|
1182
1182
|
reason: "queue_steer",
|
|
1183
|
+
controlRequested: true,
|
|
1183
1184
|
});
|
|
1184
1185
|
const receipt = await updateSessionCommandReceiptResult(db, reserved.receipt.id, {
|
|
1185
1186
|
controlRevision: resumed.revision,
|
|
@@ -1739,6 +1740,7 @@ export async function submitHumanPromptInTransaction(
|
|
|
1739
1740
|
sessionId: input.sessionId,
|
|
1740
1741
|
temporalWorkflowId: workflowId,
|
|
1741
1742
|
reason: input.delivery === "steer" ? "prompt_steer" : "prompt_send",
|
|
1743
|
+
controlRequested: input.delivery === "steer",
|
|
1742
1744
|
});
|
|
1743
1745
|
await db.insert(schema.auditEvents).values({
|
|
1744
1746
|
accountId: input.accountId,
|
|
@@ -2183,6 +2185,7 @@ export async function steerAgentSessionInTransaction(
|
|
|
2183
2185
|
sessionId: input.targetSessionId,
|
|
2184
2186
|
temporalWorkflowId: workflowId,
|
|
2185
2187
|
reason: "agent_steer",
|
|
2188
|
+
controlRequested: true,
|
|
2186
2189
|
});
|
|
2187
2190
|
await db
|
|
2188
2191
|
.update(schema.sessions)
|
|
@@ -10,7 +10,7 @@ import { submitHumanPromptInTransaction } from "./session-queue-commands";
|
|
|
10
10
|
export const SESSION_REALTIME_CONTEXT_MAX_BYTES = 65_536;
|
|
11
11
|
export const SESSION_REALTIME_TAIL_SOURCE = "transcript_tail_flush";
|
|
12
12
|
export const SESSION_REALTIME_TAIL_INSTRUCTION =
|
|
13
|
-
"The user just ended
|
|
13
|
+
"The user just ended the realtime voice session but remains reachable by text. Ending voice changes only the communication mode; it does not stop, pause, or complete existing work. Treat the remaining transcript tail as additional context. If work was already underway, continue it from the current state. Change or stop that work only if the user explicitly requested it. If nothing was underway and the transcript contains no unhandled request, acknowledge briefly; otherwise handle any unhandled request.";
|
|
14
14
|
|
|
15
15
|
export type SessionRealtimeContextProjection = {
|
|
16
16
|
id: string;
|