@opengeni/db 0.14.0 → 0.14.3

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.
@@ -1,12 +1,9 @@
1
1
  import {
2
2
  metadataWithTurnExecutionPolicyV1,
3
3
  mergeResourceRefs,
4
- mergeToolRefs,
5
4
  turnExecutionPolicyAuditMetadata,
6
5
  type ReasoningEffort,
7
6
  type ResourceRef,
8
- type SessionToolPolicy,
9
- type ToolRef,
10
7
  type TurnExecutionPolicyV1,
11
8
  } from "@opengeni/contracts";
12
9
  import { and, asc, eq, inArray, sql } from "drizzle-orm";
@@ -367,13 +364,7 @@ async function normalizeQueuePositions(
367
364
  }
368
365
 
369
366
  function draftIsNonEmpty(draft: ComposerDraftRow): boolean {
370
- return (
371
- draft.text.length > 0 ||
372
- draft.resources.length > 0 ||
373
- draft.tools.length > 0 ||
374
- draft.toolsProvided ||
375
- draft.sourceTurnId !== null
376
- );
367
+ return draft.text.length > 0 || draft.resources.length > 0 || draft.sourceTurnId !== null;
377
368
  }
378
369
 
379
370
  export async function getComposerDraftInTransaction(
@@ -410,8 +401,6 @@ export async function saveComposerDraftInTransaction(
410
401
  expectedRevision: number;
411
402
  text: string;
412
403
  resources: ResourceRef[];
413
- tools: ToolRef[];
414
- toolsProvided: boolean;
415
404
  model: string;
416
405
  reasoningEffort: ReasoningEffort;
417
406
  },
@@ -442,8 +431,8 @@ export async function saveComposerDraftInTransaction(
442
431
  revision,
443
432
  text: input.text,
444
433
  resources: input.resources,
445
- tools: input.tools,
446
- toolsProvided: input.toolsProvided,
434
+ tools: [],
435
+ toolsProvided: false,
447
436
  model: input.model,
448
437
  reasoningEffort: input.reasoningEffort,
449
438
  // A queue edit is still the same accepted work item. Preserve its frozen
@@ -814,8 +803,8 @@ export async function editQueuedTurnInTransaction(
814
803
  revision: nextDraftRevision,
815
804
  text: turn.prompt,
816
805
  resources: turn.resources,
817
- tools: turn.tools,
818
- toolsProvided: turn.toolsProvided,
806
+ tools: [],
807
+ toolsProvided: false,
819
808
  model: turn.model,
820
809
  reasoningEffort: turn.reasoningEffort,
821
810
  sourceTurnId: turn.id,
@@ -1131,8 +1120,6 @@ export async function submitHumanPromptInTransaction(
1131
1120
  text: string;
1132
1121
  turnInstructions?: string | null;
1133
1122
  resources: ResourceRef[];
1134
- tools: ToolRef[];
1135
- toolsProvided?: boolean;
1136
1123
  model?: string | null;
1137
1124
  reasoningEffort?: ReasoningEffort | null;
1138
1125
  reasoningEffortFallback: ReasoningEffort;
@@ -1163,8 +1150,6 @@ export async function submitHumanPromptInTransaction(
1163
1150
  text: input.text,
1164
1151
  turnInstructions: input.turnInstructions ?? null,
1165
1152
  resources: input.resources,
1166
- tools: input.tools,
1167
- toolsProvided: input.toolsProvided === true,
1168
1153
  model: input.model ?? null,
1169
1154
  reasoningEffort: input.reasoningEffort ?? null,
1170
1155
  source: input.source,
@@ -1272,16 +1257,12 @@ export async function submitHumanPromptInTransaction(
1272
1257
  canonicalSessionCommandHash({
1273
1258
  text: draft.text,
1274
1259
  resources: draft.resources,
1275
- tools: draft.tools,
1276
- toolsProvided: draft.toolsProvided,
1277
1260
  model: draft.model,
1278
1261
  reasoningEffort: draft.reasoningEffort,
1279
1262
  }) !==
1280
1263
  canonicalSessionCommandHash({
1281
1264
  text: input.text,
1282
1265
  resources: input.resources,
1283
- tools: input.tools,
1284
- toolsProvided: input.toolsProvided === true,
1285
1266
  model: input.model ?? session.model,
1286
1267
  reasoningEffort: input.reasoningEffort ?? input.reasoningEffortFallback,
1287
1268
  })
@@ -1401,11 +1382,6 @@ export async function submitHumanPromptInTransaction(
1401
1382
  payload: sanitizeEventPayload({
1402
1383
  text: input.text,
1403
1384
  ...(input.resources.length ? { resources: input.resources } : {}),
1404
- ...(input.toolsProvided === true
1405
- ? { tools: input.tools }
1406
- : input.tools.length
1407
- ? { tools: input.tools }
1408
- : {}),
1409
1385
  ...(input.model ? { model: input.model } : {}),
1410
1386
  ...(input.reasoningEffort ? { reasoningEffort: input.reasoningEffort } : {}),
1411
1387
  delivery: input.delivery,
@@ -1433,8 +1409,8 @@ export async function submitHumanPromptInTransaction(
1433
1409
  ? editedSourceTurnInstructions
1434
1410
  : (input.turnInstructions ?? null),
1435
1411
  resources: input.resources,
1436
- tools: input.tools,
1437
- toolsProvided: input.toolsProvided === true,
1412
+ tools: [],
1413
+ toolsProvided: false,
1438
1414
  model: input.model ?? session.model,
1439
1415
  reasoningEffort: input.reasoningEffort ?? input.reasoningEffortFallback,
1440
1416
  sandboxBackend: session.sandboxBackend,
@@ -1578,9 +1554,7 @@ export async function submitHumanPromptInTransaction(
1578
1554
  .update(schema.sessions)
1579
1555
  .set({
1580
1556
  resources: mergeResourceRefs(session.resources as ResourceRef[], input.resources),
1581
- tools: sessionToolPolicyIsFixed(session.toolPolicy)
1582
- ? session.tools
1583
- : mergeToolRefs(session.tools as ToolRef[], input.tools),
1557
+ tools: session.tools,
1584
1558
  activeTurnId: input.delivery === "steer" ? liveCurrentTurnId : session.activeTurnId,
1585
1559
  status: nextStatus,
1586
1560
  queueVersion,
@@ -1653,12 +1627,6 @@ export async function submitHumanPromptInTransaction(
1653
1627
  };
1654
1628
  }
1655
1629
 
1656
- function sessionToolPolicyIsFixed(value: unknown): boolean {
1657
- if (!value || typeof value !== "object" || Array.isArray(value)) return false;
1658
- const mode = (value as Partial<SessionToolPolicy>).mode;
1659
- return mode === "workspace_default" || mode === "explicit" || mode === "inherited";
1660
- }
1661
-
1662
1630
  export async function sendAgentMessageInTransaction(
1663
1631
  db: Database,
1664
1632
  input: {