@sentry/junior 0.187.0 → 0.189.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 (108) hide show
  1. package/dist/{agent-hooks-XVAE2554.js → agent-hooks-6QRYH6PX.js} +11 -11
  2. package/dist/api/acp/conversations.d.ts +2 -2
  3. package/dist/api/conversations/list.d.ts +7 -0
  4. package/dist/api/people/shared.d.ts +54 -0
  5. package/dist/api.js +41 -52
  6. package/dist/app.d.ts +1 -1
  7. package/dist/app.js +1001 -338
  8. package/dist/{catalog-runtime-DWFAC562.js → catalog-runtime-IETJLJFG.js} +4 -4
  9. package/dist/chat/agent/resume.d.ts +0 -2
  10. package/dist/chat/agent/types.d.ts +9 -14
  11. package/dist/chat/agent-dispatch/work.d.ts +1 -10
  12. package/dist/chat/agent-invocations/spawn.d.ts +1 -1
  13. package/dist/chat/agent-invocations/types.d.ts +296 -24
  14. package/dist/chat/app/conversation-work.d.ts +16 -8
  15. package/dist/chat/conversation-privacy.d.ts +7 -7
  16. package/dist/chat/conversations/destination.d.ts +12 -0
  17. package/dist/chat/conversations/location.d.ts +3 -8
  18. package/dist/chat/conversations/projection.d.ts +2 -2
  19. package/dist/chat/conversations/sql/location.d.ts +13 -4
  20. package/dist/chat/{api-turns → conversations}/stop.d.ts +2 -2
  21. package/dist/chat/conversations/store.d.ts +8 -11
  22. package/dist/chat/conversations/structured-events.d.ts +1 -1
  23. package/dist/chat/{api-turns/authorization.d.ts → conversations/web-authorization.d.ts} +1 -0
  24. package/dist/chat/conversations/web-input.d.ts +98 -0
  25. package/dist/chat/conversations/web-mailbox.d.ts +12 -0
  26. package/dist/chat/providers/slack/runtime.d.ts +1 -0
  27. package/dist/chat/providers/slack/system-turn.d.ts +8 -0
  28. package/dist/chat/resource-events/actor.d.ts +13 -12
  29. package/dist/chat/resource-events/notification.d.ts +1 -1
  30. package/dist/chat/services/guardian-action-policy.d.ts +1 -1
  31. package/dist/chat/services/turn-session-routing.d.ts +5 -5
  32. package/dist/chat/task-execution/assistant-message.d.ts +32 -0
  33. package/dist/chat/task-execution/conversation-turn.d.ts +8 -0
  34. package/dist/chat/{api-turns → task-execution}/mailbox-input.d.ts +1 -2
  35. package/dist/chat/task-execution/mailbox-turn.d.ts +42 -0
  36. package/dist/chat/task-execution/paused-turn.d.ts +1 -1
  37. package/dist/chat/task-execution/slack-work.d.ts +0 -2
  38. package/dist/{chunk-WL3R2KTS.js → chunk-4RHJ3CXR.js} +90 -289
  39. package/dist/{chunk-U6ZQHRIP.js → chunk-5CXCGDIL.js} +1 -1
  40. package/dist/{chunk-HXR3FHTE.js → chunk-5VWAY27R.js} +7 -3
  41. package/dist/{chunk-D3GDGREI.js → chunk-6AUR6PWR.js} +3 -3
  42. package/dist/{chunk-EIWYZXSM.js → chunk-7R5JRPCY.js} +8 -6
  43. package/dist/{chunk-WRDW3A3D.js → chunk-AC7MDOJW.js} +5 -7
  44. package/dist/{chunk-URZ7UD4P.js → chunk-BYBSI5TI.js} +2 -2
  45. package/dist/{chunk-MUPPP7A7.js → chunk-CMWIMFM6.js} +4 -182
  46. package/dist/{chunk-WKIS4VRK.js → chunk-CUYFCI4G.js} +70 -39
  47. package/dist/chunk-DA2KGZZI.js +13 -0
  48. package/dist/{chunk-Q6OCUQ7W.js → chunk-DYXVAO2E.js} +1 -1
  49. package/dist/{chunk-QH3I7ZOK.js → chunk-E3PDZPGV.js} +1 -1
  50. package/dist/{chunk-NU775DLU.js → chunk-GP32KD2J.js} +4 -12
  51. package/dist/{chunk-STF4GSK4.js → chunk-KN32OWL2.js} +5 -5
  52. package/dist/chunk-LHKZKAZ4.js +285 -0
  53. package/dist/{chunk-D5BWM37G.js → chunk-MFSET7Q7.js} +51 -341
  54. package/dist/{chunk-DUE4EUNL.js → chunk-MI6ZBDTS.js} +6 -6
  55. package/dist/{chunk-27T5HZHO.js → chunk-MRXMFB4L.js} +6 -87
  56. package/dist/{chunk-4A2R3AQB.js → chunk-MVPLEPSI.js} +1 -1
  57. package/dist/{chunk-7LRRVMPH.js → chunk-NY2F7BZA.js} +1 -1
  58. package/dist/chunk-O35GZCKL.js +311 -0
  59. package/dist/{chunk-U3KMII5Y.js → chunk-OEIITG5F.js} +1 -1
  60. package/dist/{chunk-6FKNNUSN.js → chunk-PCPSX4ES.js} +209 -7
  61. package/dist/{chunk-6YCIYOVA.js → chunk-PY3EIEAF.js} +1 -1
  62. package/dist/{chunk-U5POFCKM.js → chunk-QNIOBNOY.js} +284 -123
  63. package/dist/{chunk-JCRXXEMC.js → chunk-S3SGZUOI.js} +1 -1
  64. package/dist/chunk-SR6OMO5C.js +703 -0
  65. package/dist/{chunk-TQHCZXN7.js → chunk-UCWO5MKP.js} +7 -7
  66. package/dist/{chunk-ITLYUKGZ.js → chunk-VKQWU4PO.js} +2 -2
  67. package/dist/{chunk-JZPDYKRG.js → chunk-WDHPN2GH.js} +3 -3
  68. package/dist/{chunk-P2VU5JNH.js → chunk-WMUAKAIF.js} +42 -42
  69. package/dist/{chunk-NIKLTFBP.js → chunk-WN6VLHOU.js} +12 -5
  70. package/dist/{chunk-VC343WHM.js → chunk-WWYUYKKV.js} +1 -1
  71. package/dist/{chunk-OM4SFFJK.js → chunk-WYDF6PGK.js} +3 -3
  72. package/dist/{chunk-KRYJ5VOD.js → chunk-YNZPOFF3.js} +16 -21
  73. package/dist/{chunk-Z6OHCDXP.js → chunk-YYSEH2WC.js} +2 -2
  74. package/dist/{chunk-BITZUBPJ.js → chunk-YYZNESC3.js} +8 -8
  75. package/dist/{chunk-2VUDJGB6.js → chunk-ZUPDSJUE.js} +2 -5
  76. package/dist/{chunk-X5SXFVZT.js → chunk-ZV6PFUA4.js} +1 -1
  77. package/dist/cli/chat.js +34 -33
  78. package/dist/cli/check.js +5 -5
  79. package/dist/cli/plugins.js +12 -12
  80. package/dist/cli/snapshot-create.js +9 -9
  81. package/dist/cli/upgrade.js +6 -6
  82. package/dist/db/schema/conversations.d.ts +62 -0
  83. package/dist/db/schema.d.ts +31 -0
  84. package/dist/{db-FBHAWVXU.js → db-LPJKR2EO.js} +6 -6
  85. package/dist/instrumentation.js +3 -3
  86. package/dist/nitro.js +6 -6
  87. package/dist/{oauth-callback-server-5HS5ULC6.js → oauth-callback-server-DMXF4TTQ.js} +30 -28
  88. package/dist/{runner-46W6NV6B.js → runner-L5DPVYCN.js} +24 -20
  89. package/dist/{skills-TG3QC4B6.js → skills-NXG3LBCK.js} +5 -5
  90. package/dist/spawn-VRUIGKWW.js +42 -0
  91. package/dist/task-runner-7YTBSPXW.js +36 -0
  92. package/dist/{validation-GMRIDBC5.js → validation-CH36LTOS.js} +5 -5
  93. package/dist/version.js +1 -1
  94. package/dist/{work-W4ULBJTU.js → work-HBC5Y5VZ.js} +22 -21
  95. package/dist/{worker-M6NVACS2.js → worker-5RDZHLXH.js} +10 -10
  96. package/migrations/0037_conversation_location.sql +23 -0
  97. package/migrations/meta/0037_snapshot.json +3192 -0
  98. package/migrations/meta/_journal.json +7 -0
  99. package/package.json +4 -4
  100. package/dist/chat/api-turns/assistant-message.d.ts +0 -12
  101. package/dist/chat/api-turns/cancellation.d.ts +0 -24
  102. package/dist/chat/api-turns/routing.d.ts +0 -51
  103. package/dist/chat/api-turns/work.d.ts +0 -99
  104. package/dist/chat/task-execution/slack-resource-event.d.ts +0 -47
  105. package/dist/chunk-4YD3DET6.js +0 -1503
  106. package/dist/chunk-6FGN7ZEG.js +0 -221
  107. package/dist/spawn-Y6YWBIJS.js +0 -41
  108. package/dist/task-runner-YSGBPN4U.js +0 -34
@@ -1,6 +1,13 @@
1
1
  import {
2
- usageSchema
3
- } from "./chunk-PDO5BLNM.js";
2
+ JUNIOR_NATIVE_EVENT_NAMESPACE,
3
+ ToolInputError,
4
+ addAgentTurnUsage,
5
+ agentsInstructionsUpdatedEvent,
6
+ authenticationLinkedEvent,
7
+ authenticationUnlinkedEvent,
8
+ fallbackShortTitle,
9
+ generateShortTitle
10
+ } from "./chunk-O35GZCKL.js";
4
11
  import {
5
12
  bindProviderConversation,
6
13
  createSqlConversationEventStore,
@@ -9,18 +16,18 @@ import {
9
16
  getSqlExecutor,
10
17
  sanitizePostgresJson,
11
18
  withConversationEventLock
12
- } from "./chunk-WKIS4VRK.js";
19
+ } from "./chunk-CUYFCI4G.js";
13
20
  import {
14
21
  SANDBOX_REPOS_ROOT,
15
22
  SANDBOX_WORKSPACE_ROOT,
16
23
  sleep
17
- } from "./chunk-JZPDYKRG.js";
24
+ } from "./chunk-WDHPN2GH.js";
18
25
  import {
19
26
  MUTATION_LOCK_TTL_MS,
20
27
  fenceLock,
21
28
  getStateAdapter,
22
29
  withLock
23
- } from "./chunk-U6ZQHRIP.js";
30
+ } from "./chunk-5CXCGDIL.js";
24
31
  import {
25
32
  agentHistoryItemSchema,
26
33
  contextProvenance,
@@ -33,7 +40,7 @@ import {
33
40
  escapeXml,
34
41
  resolveGatewayModel,
35
42
  unwrapCurrentInstruction
36
- } from "./chunk-URZ7UD4P.js";
43
+ } from "./chunk-BYBSI5TI.js";
37
44
  import {
38
45
  parseSlackMessageTs,
39
46
  toStoredSlackActor
@@ -43,7 +50,7 @@ import {
43
50
  logException,
44
51
  logWarn,
45
52
  setSpanAttributes
46
- } from "./chunk-6YCIYOVA.js";
53
+ } from "./chunk-PY3EIEAF.js";
47
54
 
48
55
  // src/chat/turn-context-tag.ts
49
56
  var TURN_CONTEXT_TAG = "runtime-turn-context";
@@ -567,69 +574,6 @@ function getConversationMessageSlackTs(message) {
567
574
  import { createHash } from "crypto";
568
575
  import { isDeepStrictEqual as isDeepStrictEqual2 } from "util";
569
576
 
570
- // src/chat/services/short-title.ts
571
- var SHORT_TITLE_MAX_LENGTH = 60;
572
- var TITLE_PROMPTS = {
573
- conversation: [
574
- "Generate a concise 5-8 word conversation title from the first user message below.",
575
- "Capture the user's main request.",
576
- "Reply with ONLY the title, with no quotes or trailing punctuation."
577
- ],
578
- task: [
579
- "Generate a concise 5-8 word task title from the task instruction below.",
580
- "Capture the task's main purpose.",
581
- "Reply with ONLY the title, with no quotes or trailing punctuation."
582
- ]
583
- };
584
- function normalizeShortTitle(value) {
585
- return value.replace(/\s+/g, " ").trim().slice(0, SHORT_TITLE_MAX_LENGTH);
586
- }
587
- function fallbackShortTitle(sourceText, fallback = "Untitled") {
588
- const firstLine = sourceText.split(/\r?\n/).map((line) => line.trim()).find((line) => line.length > 0) ?? "";
589
- return normalizeShortTitle(firstLine) || fallback;
590
- }
591
- async function generateShortTitle(args) {
592
- const sourceText = args.sourceText.trim();
593
- if (!sourceText) return void 0;
594
- try {
595
- const result = await args.completeText({
596
- modelId: botConfig.fastModelId,
597
- temperature: 0,
598
- promptName: `junior.${args.kind}_title`,
599
- messages: [
600
- {
601
- role: "user",
602
- content: [
603
- ...TITLE_PROMPTS[args.kind],
604
- "",
605
- args.kind === "conversation" ? `First user message: ${sourceText.slice(0, 500)}` : `Task instruction: ${sourceText.slice(0, 500)}`
606
- ].join("\n"),
607
- timestamp: Date.now()
608
- }
609
- ],
610
- metadata: {
611
- modelId: botConfig.fastModelId
612
- }
613
- });
614
- const title = normalizeShortTitle(result.text);
615
- return title || void 0;
616
- } catch (error) {
617
- logWarn(`${args.kind}.title.generation.failed`, {
618
- "exception.message": error instanceof Error ? error.message : String(error)
619
- });
620
- return void 0;
621
- }
622
- }
623
- async function resolveTaskTitle(args) {
624
- const explicit = normalizeShortTitle(args.title ?? "");
625
- if (explicit) return explicit;
626
- return generateShortTitle({
627
- completeText: args.completeText,
628
- kind: "task",
629
- sourceText: args.instruction
630
- });
631
- }
632
-
633
577
  // src/chat/services/conversation-title.ts
634
578
  var inFlightTitles = /* @__PURE__ */ new Map();
635
579
  async function ensureConversationTitle(args) {
@@ -653,7 +597,7 @@ async function ensureConversationTitleOnce(args) {
653
597
  if (stored?.title?.trim()) {
654
598
  return void 0;
655
599
  }
656
- if (stored?.lineage) {
600
+ if (stored?.parentConversationId) {
657
601
  return void 0;
658
602
  }
659
603
  const titleSourceMessage = getThreadTitleSourceMessage(args.conversation);
@@ -941,131 +885,6 @@ var piContentMessageSchema = z.object({
941
885
  role: z.string().min(1)
942
886
  }).passthrough().transform((value) => value);
943
887
 
944
- // src/chat/conversations/structured-events.ts
945
- import {
946
- conversationEventPresentationSchema,
947
- defineConversationEvent
948
- } from "@sentry/junior-plugin-api";
949
- import { z as z2 } from "zod";
950
- var JUNIOR_NATIVE_EVENT_NAMESPACE = "junior";
951
- var authenticationEventContentSchema = z2.object({
952
- accountLabel: z2.string().trim().min(1).max(120).optional(),
953
- actorId: z2.string().min(1),
954
- authorizationId: z2.string().min(1).optional(),
955
- provider: z2.string().regex(/^[a-z][a-z0-9-]*$/),
956
- providerLabel: z2.string().trim().min(1).max(80).optional()
957
- }).strict();
958
- var agentsInstructionsUpdatedContentSchema = z2.object({
959
- action: z2.enum(["loaded", "replaced", "cleared"]),
960
- directory: z2.string().trim().min(1).max(500).optional(),
961
- fingerprint: z2.string().trim().min(1).max(128),
962
- sources: z2.array(
963
- z2.object({
964
- content: z2.string().min(1).max(32 * 1024),
965
- path: z2.string().trim().min(1).max(500)
966
- }).strict()
967
- ).max(32),
968
- textBytes: z2.number().int().nonnegative().optional()
969
- }).strict();
970
- function providerTitle(content) {
971
- return content.providerLabel?.trim() || content.provider;
972
- }
973
- function agentsInstructionsTitle(action) {
974
- if (action === "loaded") return "Loaded AGENTS.md";
975
- if (action === "replaced") return "Updated AGENTS.md";
976
- return "Cleared AGENTS.md";
977
- }
978
- function sourceFilename(sourcePath) {
979
- return sourcePath.split("/").at(-1) || sourcePath;
980
- }
981
- function formatBytes(bytes) {
982
- if (bytes < 1024) return `${bytes} bytes`;
983
- const kilobytes = bytes / 1024;
984
- return `${Number.isInteger(kilobytes) ? kilobytes : kilobytes.toFixed(1)} KB`;
985
- }
986
- function agentsInstructionsPreview(content) {
987
- const source = content.sources[0];
988
- if (!source) return void 0;
989
- const filename = sourceFilename(source.path);
990
- const label = content.sources.length === 1 ? filename : `${content.sources.length} AGENTS.md files`;
991
- return typeof content.textBytes === "number" ? `${label} \xB7 ${formatBytes(content.textBytes)}` : label;
992
- }
993
- var authenticationLinkedEvent = defineConversationEvent({
994
- name: "authentication_linked",
995
- version: 1,
996
- schema: authenticationEventContentSchema,
997
- renderEvent(event) {
998
- const provider = providerTitle(event);
999
- return {
1000
- icon: "link",
1001
- title: `${provider} connected`,
1002
- ...event.accountLabel ? { preview: `Connected as \`${event.accountLabel}\`` } : void 0,
1003
- details: [
1004
- {
1005
- title: `${provider} connected`,
1006
- ...event.accountLabel ? { description: `Connected as \`${event.accountLabel}\`` } : void 0,
1007
- metadata: [event.provider]
1008
- }
1009
- ]
1010
- };
1011
- }
1012
- });
1013
- var authenticationUnlinkedEvent = defineConversationEvent({
1014
- name: "authentication_unlinked",
1015
- version: 1,
1016
- schema: authenticationEventContentSchema,
1017
- renderEvent(event) {
1018
- const provider = providerTitle(event);
1019
- return {
1020
- icon: "key",
1021
- title: `${provider} disconnected`,
1022
- details: [
1023
- {
1024
- title: `${provider} disconnected`,
1025
- metadata: [event.provider]
1026
- }
1027
- ]
1028
- };
1029
- }
1030
- });
1031
- var agentsInstructionsUpdatedEvent = defineConversationEvent({
1032
- name: "agents_instructions_updated",
1033
- version: 1,
1034
- schema: agentsInstructionsUpdatedContentSchema,
1035
- renderEvent(event) {
1036
- const title = agentsInstructionsTitle(event.action);
1037
- const preview = agentsInstructionsPreview(event);
1038
- return {
1039
- icon: "brain",
1040
- title,
1041
- ...preview ? { preview } : void 0,
1042
- ...event.sources.length > 0 ? {
1043
- details: event.sources.map((source) => ({
1044
- title: sourceFilename(source.path),
1045
- content: source.content
1046
- }))
1047
- } : void 0
1048
- };
1049
- }
1050
- });
1051
- var NATIVE_EVENT_DEFINITIONS = [
1052
- authenticationLinkedEvent,
1053
- authenticationUnlinkedEvent,
1054
- agentsInstructionsUpdatedEvent
1055
- ];
1056
- function getJuniorNativeEventDefinition(args) {
1057
- return NATIVE_EVENT_DEFINITIONS.find(
1058
- (definition) => definition.eventName === args.name && definition.version === args.version
1059
- );
1060
- }
1061
- function renderJuniorNativeConversationEvent(args) {
1062
- if (args.namespace !== JUNIOR_NATIVE_EVENT_NAMESPACE) return void 0;
1063
- const definition = getJuniorNativeEventDefinition(args);
1064
- if (!definition) return void 0;
1065
- const presentation = definition.renderEvent(definition.parse(args.content));
1066
- return presentation === void 0 ? void 0 : conversationEventPresentationSchema.parse(presentation);
1067
- }
1068
-
1069
888
  // src/chat/pi/conversation-events.ts
1070
889
  function authorizationObservationMessage(data, createdAtMs) {
1071
890
  const label = data.kind === "mcp" ? "MCP authorization" : "Authorization";
@@ -1737,7 +1556,7 @@ async function persistWithRetry(persist) {
1737
1556
  }
1738
1557
 
1739
1558
  // src/chat/task-execution/turn-cursor.ts
1740
- import { z as z3 } from "zod";
1559
+ import { z as z2 } from "zod";
1741
1560
 
1742
1561
  // src/chat/repository-instructions.ts
1743
1562
  import { createHash as createHash2 } from "crypto";
@@ -1745,16 +1564,6 @@ import path2 from "path";
1745
1564
 
1746
1565
  // src/chat/tools/sandbox/file-utils.ts
1747
1566
  import path from "path";
1748
-
1749
- // src/chat/tools/execution/tool-input-error.ts
1750
- var ToolInputError = class extends Error {
1751
- constructor(message, options) {
1752
- super(message, options);
1753
- this.name = "ToolInputError";
1754
- }
1755
- };
1756
-
1757
- // src/chat/tools/sandbox/file-utils.ts
1758
1567
  var MAX_TEXT_CHARS = 6e4;
1759
1568
  var RIPGREP_EXCLUDED_GLOBS = [
1760
1569
  "!**/.git/**",
@@ -2202,64 +2011,64 @@ function definedProps(values) {
2202
2011
  Object.entries(values).filter(([, value]) => value !== void 0)
2203
2012
  );
2204
2013
  }
2205
- var turnStatusSchema = z3.enum([
2014
+ var turnStatusSchema = z2.enum([
2206
2015
  "running",
2207
2016
  "paused",
2208
2017
  "completed",
2209
2018
  "failed",
2210
2019
  "abandoned"
2211
2020
  ]);
2212
- var turnSurfaceSchema = z3.enum([
2021
+ var turnSurfaceSchema = z2.enum([
2213
2022
  "slack",
2214
2023
  "api",
2215
2024
  "scheduler",
2216
2025
  "internal"
2217
2026
  ]);
2218
- var turnPauseReasonSchema = z3.enum([
2027
+ var turnPauseReasonSchema = z2.enum([
2219
2028
  "timeout",
2220
2029
  "auth",
2221
2030
  "yield",
2222
2031
  "retry"
2223
2032
  ]);
2224
- var nonNegativeNumberSchema = z3.number().finite().nonnegative();
2225
- var seqCursorSchema = z3.number().int().min(-1);
2226
- var storedTurnSummarySchema = z3.object({
2227
- schemaVersion: z3.literal(TURN_CURSOR_SCHEMA_VERSION),
2228
- version: z3.number().int().nonnegative(),
2229
- conversationId: z3.string().min(1),
2230
- dispatchId: z3.string().min(1).optional(),
2231
- dispatchOutcome: z3.enum(["blocked", "completed", "failed"]).optional(),
2232
- resultMessageId: z3.string().min(1).optional(),
2033
+ var nonNegativeNumberSchema = z2.number().finite().nonnegative();
2034
+ var seqCursorSchema = z2.number().int().min(-1);
2035
+ var storedTurnSummarySchema = z2.object({
2036
+ schemaVersion: z2.literal(TURN_CURSOR_SCHEMA_VERSION),
2037
+ version: z2.number().int().nonnegative(),
2038
+ conversationId: z2.string().min(1),
2039
+ dispatchId: z2.string().min(1).optional(),
2040
+ dispatchOutcome: z2.enum(["blocked", "completed", "failed"]).optional(),
2041
+ resultMessageId: z2.string().min(1).optional(),
2233
2042
  resumeReason: turnPauseReasonSchema.optional(),
2234
- turnId: z3.string().min(1),
2235
- sliceId: z3.number().int().nonnegative(),
2043
+ turnId: z2.string().min(1),
2044
+ sliceId: z2.number().int().nonnegative(),
2236
2045
  state: turnStatusSchema,
2237
2046
  surface: turnSurfaceSchema.optional(),
2238
2047
  updatedAtMs: nonNegativeNumberSchema
2239
2048
  }).strip();
2240
- var storedTurnRecordSchema = z3.object({
2241
- schemaVersion: z3.literal(TURN_CURSOR_SCHEMA_VERSION),
2242
- version: z3.number().int().nonnegative(),
2243
- conversationId: z3.string().min(1),
2244
- dispatchId: z3.string().min(1).optional(),
2245
- dispatchOutcome: z3.enum(["blocked", "completed", "failed"]).optional(),
2246
- resultMessageId: z3.string().min(1).optional(),
2049
+ var storedTurnRecordSchema = z2.object({
2050
+ schemaVersion: z2.literal(TURN_CURSOR_SCHEMA_VERSION),
2051
+ version: z2.number().int().nonnegative(),
2052
+ conversationId: z2.string().min(1),
2053
+ dispatchId: z2.string().min(1).optional(),
2054
+ dispatchOutcome: z2.enum(["blocked", "completed", "failed"]).optional(),
2055
+ resultMessageId: z2.string().min(1).optional(),
2247
2056
  lastProgressAtMs: nonNegativeNumberSchema,
2248
2057
  resumeReason: turnPauseReasonSchema.optional(),
2249
- publishExternally: z3.boolean().optional(),
2250
- resumedFromSliceId: z3.number().int().nonnegative().optional(),
2251
- turnId: z3.string().min(1),
2252
- sliceId: z3.number().int().nonnegative(),
2058
+ publishExternally: z2.boolean().optional(),
2059
+ resumedFromSliceId: z2.number().int().nonnegative().optional(),
2060
+ turnId: z2.string().min(1),
2061
+ sliceId: z2.number().int().nonnegative(),
2253
2062
  startedAtMs: nonNegativeNumberSchema,
2254
2063
  state: turnStatusSchema,
2255
2064
  surface: turnSurfaceSchema.optional(),
2256
- traceId: z3.string().optional(),
2065
+ traceId: z2.string().optional(),
2257
2066
  updatedAtMs: nonNegativeNumberSchema,
2258
2067
  committedSeq: seqCursorSchema,
2259
- historyVersion: z3.number().int().nonnegative().optional(),
2260
- errorMessage: z3.string().optional(),
2068
+ historyVersion: z2.number().int().nonnegative().optional(),
2069
+ errorMessage: z2.string().optional(),
2261
2070
  turnStartSeq: seqCursorSchema.optional(),
2262
- runtimeContext: z3.array(piMessageSchema).optional()
2071
+ runtimeContext: z2.array(piMessageSchema).optional()
2263
2072
  }).strip();
2264
2073
  function conversationExecutionFromSummary(summary) {
2265
2074
  const status = summary.state === "completed" || summary.state === "abandoned" ? "idle" : summary.state;
@@ -2306,12 +2115,12 @@ async function recordConversationActivityMetadata(args) {
2306
2115
  const conversation = await conversationStore.get({
2307
2116
  conversationId: args.summary.conversationId
2308
2117
  });
2309
- const isChild = Boolean(conversation?.lineage);
2310
- const destination = isChild ? void 0 : args.destination;
2311
- if (!isChild && !destination && !conversation) {
2118
+ const hasParent = Boolean(conversation?.parentConversationId);
2119
+ const destination = hasParent ? void 0 : args.destination;
2120
+ if (!hasParent && !destination && !conversation) {
2312
2121
  return;
2313
2122
  }
2314
- const activitySource = isChild ? "internal" : args.source?.platform === "web" ? "web" : destination?.platform === "local" ? "local" : destination ? args.summary.surface : void 0;
2123
+ const activitySource = hasParent ? "internal" : args.source?.platform === "web" ? "web" : destination?.platform === "local" ? "local" : destination ? args.summary.surface : void 0;
2315
2124
  await conversationStore.recordActivity({
2316
2125
  activityAtMs: args.summary.updatedAtMs,
2317
2126
  channelName: args.summary.channelName,
@@ -2321,7 +2130,7 @@ async function recordConversationActivityMetadata(args) {
2321
2130
  actor: sessionLogActor(args.actor),
2322
2131
  ...definedProps({ source: activitySource }),
2323
2132
  ...args.source ? { sessionSource: args.source } : void 0,
2324
- visibility: isChild ? void 0 : args.destinationVisibility
2133
+ visibility: hasParent ? void 0 : args.destinationVisibility
2325
2134
  });
2326
2135
  await conversationStore.recordExecution({
2327
2136
  channelName: args.summary.channelName,
@@ -2337,7 +2146,7 @@ async function recordConversationActivityMetadata(args) {
2337
2146
  actor: sessionLogActor(args.actor),
2338
2147
  ...definedProps({ source: activitySource }),
2339
2148
  updatedAtMs: args.nowMs,
2340
- visibility: isChild ? void 0 : args.destinationVisibility
2149
+ visibility: hasParent ? void 0 : args.destinationVisibility
2341
2150
  });
2342
2151
  }
2343
2152
  function materializeTurnRecord(stored, piProjection, turnStartMessageIndex, restoreVolatileContext = true, runtimeMetrics) {
@@ -2808,96 +2617,6 @@ async function failTurnRecord(args) {
2808
2617
  );
2809
2618
  }
2810
2619
 
2811
- // src/chat/usage.ts
2812
- var agentTurnUsageSchema = usageSchema;
2813
- var COMPONENT_USAGE_FIELDS = [
2814
- "inputTokens",
2815
- "outputTokens",
2816
- "cachedInputTokens",
2817
- "cacheCreationTokens"
2818
- ];
2819
- var COST_COMPONENT_FIELDS = [
2820
- "input",
2821
- "output",
2822
- "cacheRead",
2823
- "cacheWrite"
2824
- ];
2825
- function hasAgentTurnUsage(usage) {
2826
- return Boolean(
2827
- usage && (Object.entries(usage).some(
2828
- ([field, value]) => field !== "cost" && typeof value === "number" && Number.isFinite(value)
2829
- ) || Object.values(usage.cost ?? {}).some(
2830
- (value) => typeof value === "number" && Number.isFinite(value)
2831
- ))
2832
- );
2833
- }
2834
- function getFiniteCount(value) {
2835
- return typeof value === "number" && Number.isFinite(value) ? Math.max(0, Math.floor(value)) : void 0;
2836
- }
2837
- function getFiniteCost(value) {
2838
- return typeof value === "number" && Number.isFinite(value) ? Math.max(0, value) : void 0;
2839
- }
2840
- function addCost(left, right) {
2841
- return Math.round(((left ?? 0) + right) * 1e12) / 1e12;
2842
- }
2843
- function getComponentTotal(usage) {
2844
- let total;
2845
- for (const field of COMPONENT_USAGE_FIELDS) {
2846
- const value = getFiniteCount(usage[field]);
2847
- if (value === void 0) continue;
2848
- total = (total ?? 0) + value;
2849
- }
2850
- return total;
2851
- }
2852
- function addAgentTurnUsage(...usages) {
2853
- const components = {};
2854
- let componentTotal;
2855
- let totalOnlyTokens;
2856
- let reasoningTokens;
2857
- const cost = {};
2858
- for (const usage of usages) {
2859
- if (!usage) continue;
2860
- const reasoning = getFiniteCount(usage.reasoningTokens);
2861
- if (reasoning !== void 0) {
2862
- reasoningTokens = (reasoningTokens ?? 0) + reasoning;
2863
- }
2864
- if (usage.cost) {
2865
- for (const field of [...COST_COMPONENT_FIELDS, "total"]) {
2866
- const value = getFiniteCost(usage.cost[field]);
2867
- if (value === void 0) continue;
2868
- cost[field] = addCost(cost[field], value);
2869
- }
2870
- }
2871
- const usageComponentTotal = getComponentTotal(usage);
2872
- if (usageComponentTotal !== void 0) {
2873
- componentTotal = (componentTotal ?? 0) + usageComponentTotal;
2874
- for (const field of COMPONENT_USAGE_FIELDS) {
2875
- const value = getFiniteCount(usage[field]);
2876
- if (value === void 0) continue;
2877
- components[field] = (components[field] ?? 0) + value;
2878
- }
2879
- continue;
2880
- }
2881
- const totalTokens = getFiniteCount(usage.totalTokens);
2882
- if (totalTokens !== void 0) {
2883
- totalOnlyTokens = (totalOnlyTokens ?? 0) + totalTokens;
2884
- }
2885
- }
2886
- if (totalOnlyTokens !== void 0) {
2887
- return {
2888
- totalTokens: totalOnlyTokens + (componentTotal ?? 0),
2889
- ...reasoningTokens !== void 0 ? { reasoningTokens } : void 0,
2890
- ...Object.keys(cost).length > 0 ? { cost } : void 0
2891
- };
2892
- }
2893
- const result = {
2894
- ...components,
2895
- ...reasoningTokens !== void 0 ? { reasoningTokens } : void 0,
2896
- ...Object.keys(cost).length > 0 ? { cost } : void 0
2897
- };
2898
- return hasAgentTurnUsage(result) ? result : void 0;
2899
- }
2900
-
2901
2620
  // src/chat/services/turn-limit.ts
2902
2621
  var TurnSliceLimitExceededError = class extends Error {
2903
2622
  constructor(maxSlices) {
@@ -3087,7 +2806,6 @@ async function saveDone(args) {
3087
2806
  }
3088
2807
 
3089
2808
  export {
3090
- renderJuniorNativeConversationEvent,
3091
2809
  TURN_CONTEXT_TAG,
3092
2810
  isAssistantMessage,
3093
2811
  isToolResultMessage,
@@ -3119,10 +2837,6 @@ export {
3119
2837
  createConversationMemoryService,
3120
2838
  isHumanConversationMessage,
3121
2839
  getConversationMessageSlackTs,
3122
- SHORT_TITLE_MAX_LENGTH,
3123
- fallbackShortTitle,
3124
- generateShortTitle,
3125
- resolveTaskTitle,
3126
2840
  resolveConversationTitle,
3127
2841
  persistConversationMessageSummaries,
3128
2842
  projectConversationMessages,
@@ -3145,7 +2859,6 @@ export {
3145
2859
  recordToolExecutionStarted,
3146
2860
  recordAttachmentsDelivered,
3147
2861
  recordGuardianActionReviewed,
3148
- ToolInputError,
3149
2862
  MAX_TEXT_CHARS,
3150
2863
  RIPGREP_EXCLUDED_GLOBS,
3151
2864
  DEFAULT_SEARCH_COMMAND_TIMEOUT_MS,
@@ -3164,9 +2877,6 @@ export {
3164
2877
  renderAgentsInstructions,
3165
2878
  buildAgentsInstructionsMessage,
3166
2879
  findVisibleAgentsInstructions,
3167
- agentTurnUsageSchema,
3168
- hasAgentTurnUsage,
3169
- addAgentTurnUsage,
3170
2880
  TurnSliceLimitExceededError,
3171
2881
  buildTurnLimitResponse,
3172
2882
  persistWithRetry,
@@ -5,7 +5,7 @@ import {
5
5
  getConversationEventStore,
6
6
  getDb,
7
7
  getSqlExecutor
8
- } from "./chunk-WKIS4VRK.js";
8
+ } from "./chunk-CUYFCI4G.js";
9
9
  import {
10
10
  juniorCodeChanges,
11
11
  juniorCodeRepositories,
@@ -16,7 +16,7 @@ import {
16
16
  juniorUsers,
17
17
  juniorWorkspaceRepos,
18
18
  juniorWorkspaces
19
- } from "./chunk-HXR3FHTE.js";
19
+ } from "./chunk-5VWAY27R.js";
20
20
  import {
21
21
  SANDBOX_WORKSPACE_ROOT,
22
22
  getVercelSandboxCredentials,
@@ -24,16 +24,16 @@ import {
24
24
  isSandboxMissingError,
25
25
  runNonInteractiveCommand,
26
26
  sleep
27
- } from "./chunk-JZPDYKRG.js";
27
+ } from "./chunk-WDHPN2GH.js";
28
28
  import {
29
29
  getStateAdapter
30
- } from "./chunk-U6ZQHRIP.js";
30
+ } from "./chunk-5CXCGDIL.js";
31
31
  import {
32
32
  botConfig,
33
33
  completeObject,
34
34
  embedTexts,
35
35
  getSlackBotToken
36
- } from "./chunk-URZ7UD4P.js";
36
+ } from "./chunk-BYBSI5TI.js";
37
37
  import {
38
38
  defaultModelId
39
39
  } from "./chunk-D4YV5TDV.js";
@@ -52,7 +52,7 @@ import {
52
52
  setSpanAttributes,
53
53
  setSpanStatus,
54
54
  withSpan
55
- } from "./chunk-6YCIYOVA.js";
55
+ } from "./chunk-PY3EIEAF.js";
56
56
 
57
57
  // src/chat/plugins/agent-hooks.ts
58
58
  import {