@sentry/junior 0.188.0 → 0.190.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 (115) hide show
  1. package/dist/{agent-hooks-5RQEVLQD.js → agent-hooks-3IG2FQW2.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 +44 -55
  6. package/dist/app.d.ts +1 -1
  7. package/dist/app.js +1025 -349
  8. package/dist/{catalog-runtime-L4A6BJ3U.js → catalog-runtime-2OT7S3ZC.js} +4 -4
  9. package/dist/chat/actor.d.ts +7 -2
  10. package/dist/chat/agent/resume.d.ts +0 -2
  11. package/dist/chat/agent/types.d.ts +8 -9
  12. package/dist/chat/agent-dispatch/work.d.ts +1 -10
  13. package/dist/chat/agent-invocations/spawn.d.ts +1 -1
  14. package/dist/chat/agent-invocations/types.d.ts +44 -108
  15. package/dist/chat/app/conversation-work.d.ts +16 -8
  16. package/dist/chat/conversation-privacy.d.ts +7 -7
  17. package/dist/chat/conversations/destination.d.ts +12 -0
  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 +4 -4
  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/event-tasks/tool-support.d.ts +1 -7
  27. package/dist/chat/providers/slack/runtime.d.ts +1 -0
  28. package/dist/chat/providers/slack/system-turn.d.ts +8 -0
  29. package/dist/chat/resource-events/actor.d.ts +13 -12
  30. package/dist/chat/resource-events/notification.d.ts +1 -1
  31. package/dist/chat/services/guardian-action-policy.d.ts +1 -1
  32. package/dist/chat/services/turn-session-routing.d.ts +2 -2
  33. package/dist/chat/source.d.ts +3 -3
  34. package/dist/chat/task-execution/assistant-message.d.ts +32 -0
  35. package/dist/chat/task-execution/conversation-turn.d.ts +8 -0
  36. package/dist/chat/{api-turns → task-execution}/mailbox-input.d.ts +1 -2
  37. package/dist/chat/task-execution/mailbox-turn.d.ts +52 -0
  38. package/dist/chat/task-execution/paused-turn.d.ts +1 -1
  39. package/dist/chat/task-execution/slack-work.d.ts +0 -2
  40. package/dist/chat/task-execution/state.d.ts +2 -2
  41. package/dist/chat/task-execution/store.d.ts +1 -1
  42. package/dist/chat/task-execution/turn-cursor.d.ts +10 -1
  43. package/dist/chat/tools/types.d.ts +9 -2
  44. package/dist/{chunk-XJIPMHKI.js → chunk-2MKHYSYL.js} +3 -3
  45. package/dist/{chunk-QCGNHSMA.js → chunk-2MRF22J4.js} +25 -10
  46. package/dist/{chunk-HCIVBCP5.js → chunk-3J3BCB4J.js} +1 -1
  47. package/dist/chunk-4BLFIYVK.js +703 -0
  48. package/dist/{chunk-NZLZ4KYZ.js → chunk-4PKEJK5B.js} +1 -1
  49. package/dist/{chunk-VFZAUQ5V.js → chunk-62DRKZQU.js} +5 -183
  50. package/dist/{chunk-QIOUTXTZ.js → chunk-663DQH5W.js} +1 -1
  51. package/dist/{chunk-Z5SKZE5B.js → chunk-67MMSYSE.js} +4 -12
  52. package/dist/{chunk-ZX7RSBQ6.js → chunk-6BXUSF7J.js} +1 -1
  53. package/dist/{chunk-W42ENMJW.js → chunk-6H7YU6XH.js} +1 -1
  54. package/dist/{chunk-WGZJ5SU4.js → chunk-7UJ6IJCK.js} +1 -1
  55. package/dist/{chunk-QDHJTKPE.js → chunk-7Y7XMI6P.js} +8 -6
  56. package/dist/{chunk-6YGFBU3A.js → chunk-BGOLRC36.js} +62 -336
  57. package/dist/{chunk-CVBDVIF4.js → chunk-BUJU6C2J.js} +1 -1
  58. package/dist/{chunk-XI4PVY2T.js → chunk-CZXZKTAI.js} +5 -5
  59. package/dist/chunk-DA2KGZZI.js +13 -0
  60. package/dist/{chunk-RMB7CERI.js → chunk-DJZGQ7OL.js} +311 -137
  61. package/dist/{chunk-FIUCHYT6.js → chunk-DVX6U6GI.js} +1 -1
  62. package/dist/{chunk-AW77HH54.js → chunk-ECOR3OXY.js} +19 -299
  63. package/dist/{chunk-WW2Y7JIA.js → chunk-F3K2267N.js} +51 -50
  64. package/dist/{chunk-W2DDJCPS.js → chunk-FVFJ57RK.js} +8 -8
  65. package/dist/{chunk-UVUXFRYN.js → chunk-GWCFXTB6.js} +211 -7
  66. package/dist/{chunk-X55FOVZO.js → chunk-HI5KXE3C.js} +3 -3
  67. package/dist/{chunk-ERZMACYA.js → chunk-IRQ3RSX3.js} +3 -3
  68. package/dist/{chunk-32XSSFZV.js → chunk-JV7U4665.js} +1 -1
  69. package/dist/chunk-MNHJ4WLE.js +285 -0
  70. package/dist/{chunk-SC67CH3C.js → chunk-OJFX2FP7.js} +14 -17
  71. package/dist/{chunk-IUUQWIG2.js → chunk-OKAHLUSU.js} +70 -19
  72. package/dist/{chunk-PSHMPRIU.js → chunk-OON4IQHH.js} +2 -2
  73. package/dist/{chunk-6JZGXLL2.js → chunk-OYCOLHCR.js} +5 -7
  74. package/dist/{chunk-3HEZWDS5.js → chunk-REVH4BZU.js} +2 -2
  75. package/dist/{chunk-CDSLOYOR.js → chunk-RLYJYEIY.js} +6 -6
  76. package/dist/{chunk-CZRWU4ZM.js → chunk-T66GV7A3.js} +2 -5
  77. package/dist/{chunk-Q7O74WOO.js → chunk-VWNIDTFR.js} +2 -2
  78. package/dist/{chunk-CIG6WI7Q.js → chunk-W2C4TPLB.js} +5 -5
  79. package/dist/{chunk-QIMN3FXL.js → chunk-Y4WL4OYD.js} +1 -1
  80. package/dist/{chunk-MQDIIFZM.js → chunk-YFU4DGZY.js} +12 -5
  81. package/dist/chunk-YKIAUKYH.js +311 -0
  82. package/dist/{chunk-QVH6FW3T.js → chunk-ZFCO2TMB.js} +7 -3
  83. package/dist/cli/chat.js +34 -33
  84. package/dist/cli/check.js +5 -5
  85. package/dist/cli/plugins.js +12 -12
  86. package/dist/cli/snapshot-create.js +9 -9
  87. package/dist/cli/upgrade.js +6 -6
  88. package/dist/db/schema/agent-invocations.d.ts +18 -42
  89. package/dist/db/schema/conversations.d.ts +62 -0
  90. package/dist/db/schema.d.ts +49 -42
  91. package/dist/{db-YPRZAA2T.js → db-2IFDMDDY.js} +6 -6
  92. package/dist/instrumentation.js +3 -3
  93. package/dist/nitro.js +6 -6
  94. package/dist/{oauth-callback-server-DBBIR3XG.js → oauth-callback-server-SZSS2KH6.js} +30 -28
  95. package/dist/{runner-FKVFFPLO.js → runner-2N4QU77X.js} +25 -21
  96. package/dist/{skills-4RBAZEMV.js → skills-VU2LZAKX.js} +5 -5
  97. package/dist/spawn-3K7RV4T5.js +42 -0
  98. package/dist/task-runner-52DYFHW3.js +36 -0
  99. package/dist/{validation-E6Z5LHZM.js → validation-IJGHK7NI.js} +5 -5
  100. package/dist/version.js +1 -1
  101. package/dist/{work-OFTXWOK4.js → work-DI45MLRL.js} +22 -21
  102. package/dist/{worker-OMWNOKTJ.js → worker-FY7KWG2M.js} +10 -10
  103. package/migrations/0037_conversation_location.sql +23 -0
  104. package/migrations/meta/0037_snapshot.json +3192 -0
  105. package/migrations/meta/_journal.json +7 -0
  106. package/package.json +4 -4
  107. package/dist/chat/api-turns/assistant-message.d.ts +0 -12
  108. package/dist/chat/api-turns/cancellation.d.ts +0 -24
  109. package/dist/chat/api-turns/routing.d.ts +0 -51
  110. package/dist/chat/api-turns/work.d.ts +0 -99
  111. package/dist/chat/task-execution/slack-resource-event.d.ts +0 -55
  112. package/dist/chunk-6FGN7ZEG.js +0 -221
  113. package/dist/chunk-LODJKINF.js +0 -1502
  114. package/dist/spawn-CO7QFCNJ.js +0 -41
  115. package/dist/task-runner-DUGZGI7V.js +0 -34
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  createAndEnqueueAgentInvocation
3
- } from "./chunk-SC67CH3C.js";
3
+ } from "./chunk-OJFX2FP7.js";
4
4
  import {
5
5
  actorFromRun,
6
6
  toolInvocationDestination
7
- } from "./chunk-6FGN7ZEG.js";
7
+ } from "./chunk-GWCFXTB6.js";
8
8
 
9
9
  // src/chat/agent-invocations/spawn.ts
10
10
  function bindSpawnAgent(run, options) {
@@ -21,9 +21,6 @@ function bindSpawnAgent(run, options) {
21
21
  ...input.name ? { agentName: input.name } : void 0,
22
22
  ...run.credentialContext ? { credentialContext: run.credentialContext } : void 0,
23
23
  destination: toolInvocationDestination(run),
24
- ...run.destinationVisibility ? {
25
- destinationVisibility: run.destinationVisibility
26
- } : void 0,
27
24
  idempotencyKey: `${run.turnId}:${call.toolCallId}`,
28
25
  input: input.task,
29
26
  parentConversationId: run.conversationId,
@@ -7,7 +7,7 @@ import {
7
7
  toCanonicalInputMessage,
8
8
  toCanonicalOutputMessage,
9
9
  toGenAiMessagesTraceAttributes
10
- } from "./chunk-FIUCHYT6.js";
10
+ } from "./chunk-DVX6U6GI.js";
11
11
  import {
12
12
  extractGenAiUsageAttributes,
13
13
  logException,
@@ -15,7 +15,7 @@ import {
15
15
  normalizeGenAiFinishReason,
16
16
  serializeGenAiAttribute,
17
17
  withSpan
18
- } from "./chunk-QIMN3FXL.js";
18
+ } from "./chunk-Y4WL4OYD.js";
19
19
 
20
20
  // src/chat/services/provider-error.ts
21
21
  var ProviderError = class extends Error {
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  persistConversationMessages
3
- } from "./chunk-6YGFBU3A.js";
3
+ } from "./chunk-BGOLRC36.js";
4
4
  import {
5
5
  JUNIOR_THREAD_STATE_TTL_MS
6
6
  } from "./chunk-3Y47VMHV.js";
7
7
  import {
8
8
  getDb
9
- } from "./chunk-IUUQWIG2.js";
9
+ } from "./chunk-OKAHLUSU.js";
10
10
  import {
11
11
  juniorLocationConfigurations
12
- } from "./chunk-QVH6FW3T.js";
12
+ } from "./chunk-ZFCO2TMB.js";
13
13
  import {
14
14
  getStateAdapter
15
- } from "./chunk-ZX7RSBQ6.js";
15
+ } from "./chunk-6BXUSF7J.js";
16
16
  import {
17
17
  juniorDestinations
18
18
  } from "./chunk-VFUK3X5B.js";
@@ -20,7 +20,7 @@ import {
20
20
  isRecord,
21
21
  toOptionalNumber,
22
22
  toOptionalString
23
- } from "./chunk-QIMN3FXL.js";
23
+ } from "./chunk-Y4WL4OYD.js";
24
24
 
25
25
  // src/chat/state/conversation.ts
26
26
  function defaultConversationState() {
@@ -12,7 +12,7 @@ import {
12
12
  } from "./chunk-PEQXYSSE.js";
13
13
  import {
14
14
  JUNIOR_VERSION
15
- } from "./chunk-32XSSFZV.js";
15
+ } from "./chunk-JV7U4665.js";
16
16
 
17
17
  // src/deployment.ts
18
18
  var JUNIOR_HEARTBEAT_ROUTE = "/api/internal/heartbeat";
@@ -8,14 +8,14 @@ import {
8
8
  getConversationStore,
9
9
  parseDestination,
10
10
  sameDestination
11
- } from "./chunk-IUUQWIG2.js";
11
+ } from "./chunk-OKAHLUSU.js";
12
12
  import {
13
13
  getDefaultRedisStateAdapterFor,
14
14
  getStateAdapter
15
- } from "./chunk-ZX7RSBQ6.js";
15
+ } from "./chunk-6BXUSF7J.js";
16
16
  import {
17
17
  getChatConfig
18
- } from "./chunk-Q7O74WOO.js";
18
+ } from "./chunk-VWNIDTFR.js";
19
19
  import {
20
20
  parseStoredSlackActor
21
21
  } from "./chunk-N7TMSOZH.js";
@@ -23,7 +23,7 @@ import {
23
23
  isRecord,
24
24
  toOptionalNumber,
25
25
  toOptionalString
26
- } from "./chunk-QIMN3FXL.js";
26
+ } from "./chunk-Y4WL4OYD.js";
27
27
 
28
28
  // src/chat/task-execution/state.ts
29
29
  import { randomUUID } from "crypto";
@@ -730,7 +730,14 @@ async function appendInboundMessageWithAdmission(args) {
730
730
  if (args.exclusive && hasRunnableWork(current)) {
731
731
  return { status: "active" };
732
732
  }
733
- const status = current.execution.lease && current.execution.status === "running" ? "running" : current.execution.lease ? "paused" : "pending";
733
+ let status;
734
+ if (current.execution.lease) {
735
+ status = current.execution.status === "running" ? "running" : "paused";
736
+ } else if (current.execution.status === "paused" && args.message.delivery === "defer") {
737
+ status = "paused";
738
+ } else {
739
+ status = "pending";
740
+ }
734
741
  const next = {
735
742
  ...current,
736
743
  destination: current.destination ?? args.message.destination,
@@ -0,0 +1,311 @@
1
+ import {
2
+ usageSchema
3
+ } from "./chunk-PDO5BLNM.js";
4
+ import {
5
+ botConfig
6
+ } from "./chunk-VWNIDTFR.js";
7
+ import {
8
+ logWarn
9
+ } from "./chunk-Y4WL4OYD.js";
10
+
11
+ // src/chat/conversations/structured-events.ts
12
+ import {
13
+ conversationEventPresentationSchema,
14
+ defineConversationEvent
15
+ } from "@sentry/junior-plugin-api";
16
+ import { z } from "zod";
17
+ var JUNIOR_NATIVE_EVENT_NAMESPACE = "junior";
18
+ var authenticationEventContentSchema = z.object({
19
+ accountLabel: z.string().trim().min(1).max(120).optional(),
20
+ actorId: z.string().min(1),
21
+ authorizationId: z.string().min(1).optional(),
22
+ provider: z.string().regex(/^[a-z][a-z0-9-]*$/),
23
+ providerLabel: z.string().trim().min(1).max(80).optional()
24
+ }).strict();
25
+ var agentsInstructionsUpdatedContentSchema = z.object({
26
+ action: z.enum(["loaded", "replaced", "cleared"]),
27
+ directory: z.string().trim().min(1).max(500).optional(),
28
+ fingerprint: z.string().trim().min(1).max(128),
29
+ sources: z.array(
30
+ z.object({
31
+ content: z.string().min(1).max(32 * 1024),
32
+ path: z.string().trim().min(1).max(500)
33
+ }).strict()
34
+ ).max(32),
35
+ textBytes: z.number().int().nonnegative().optional()
36
+ }).strict();
37
+ function providerTitle(content) {
38
+ return content.providerLabel?.trim() || content.provider;
39
+ }
40
+ function agentsInstructionsTitle(action) {
41
+ if (action === "loaded") return "Loaded AGENTS.md";
42
+ if (action === "replaced") return "Updated AGENTS.md";
43
+ return "Cleared AGENTS.md";
44
+ }
45
+ function sourceFilename(sourcePath) {
46
+ return sourcePath.split("/").at(-1) || sourcePath;
47
+ }
48
+ function formatBytes(bytes) {
49
+ if (bytes < 1024) return `${bytes} bytes`;
50
+ const kilobytes = bytes / 1024;
51
+ return `${Number.isInteger(kilobytes) ? kilobytes : kilobytes.toFixed(1)} KB`;
52
+ }
53
+ function agentsInstructionsPreview(content) {
54
+ const source = content.sources[0];
55
+ if (!source) return void 0;
56
+ const filename = sourceFilename(source.path);
57
+ const label = content.sources.length === 1 ? filename : `${content.sources.length} AGENTS.md files`;
58
+ return typeof content.textBytes === "number" ? `${label} \xB7 ${formatBytes(content.textBytes)}` : label;
59
+ }
60
+ var authenticationLinkedEvent = defineConversationEvent({
61
+ name: "authentication_linked",
62
+ version: 1,
63
+ schema: authenticationEventContentSchema,
64
+ renderEvent(event) {
65
+ const provider = providerTitle(event);
66
+ return {
67
+ icon: "link",
68
+ title: `${provider} connected`,
69
+ ...event.accountLabel ? { preview: `Connected as \`${event.accountLabel}\`` } : void 0,
70
+ details: [
71
+ {
72
+ title: `${provider} connected`,
73
+ ...event.accountLabel ? { description: `Connected as \`${event.accountLabel}\`` } : void 0,
74
+ metadata: [event.provider]
75
+ }
76
+ ]
77
+ };
78
+ }
79
+ });
80
+ var authenticationUnlinkedEvent = defineConversationEvent({
81
+ name: "authentication_unlinked",
82
+ version: 1,
83
+ schema: authenticationEventContentSchema,
84
+ renderEvent(event) {
85
+ const provider = providerTitle(event);
86
+ return {
87
+ icon: "key",
88
+ title: `${provider} disconnected`,
89
+ details: [
90
+ {
91
+ title: `${provider} disconnected`,
92
+ metadata: [event.provider]
93
+ }
94
+ ]
95
+ };
96
+ }
97
+ });
98
+ var agentsInstructionsUpdatedEvent = defineConversationEvent({
99
+ name: "agents_instructions_updated",
100
+ version: 1,
101
+ schema: agentsInstructionsUpdatedContentSchema,
102
+ renderEvent(event) {
103
+ const title = agentsInstructionsTitle(event.action);
104
+ const preview = agentsInstructionsPreview(event);
105
+ return {
106
+ icon: "brain",
107
+ title,
108
+ ...preview ? { preview } : void 0,
109
+ ...event.sources.length > 0 ? {
110
+ details: event.sources.map((source) => ({
111
+ title: sourceFilename(source.path),
112
+ content: source.content
113
+ }))
114
+ } : void 0
115
+ };
116
+ }
117
+ });
118
+ var NATIVE_EVENT_DEFINITIONS = [
119
+ authenticationLinkedEvent,
120
+ authenticationUnlinkedEvent,
121
+ agentsInstructionsUpdatedEvent
122
+ ];
123
+ function getJuniorNativeEventDefinition(args) {
124
+ return NATIVE_EVENT_DEFINITIONS.find(
125
+ (definition) => definition.eventName === args.name && definition.version === args.version
126
+ );
127
+ }
128
+ function renderJuniorNativeConversationEvent(args) {
129
+ if (args.namespace !== JUNIOR_NATIVE_EVENT_NAMESPACE) return void 0;
130
+ const definition = getJuniorNativeEventDefinition(args);
131
+ if (!definition) return void 0;
132
+ const presentation = definition.renderEvent(definition.parse(args.content));
133
+ return presentation === void 0 ? void 0 : conversationEventPresentationSchema.parse(presentation);
134
+ }
135
+
136
+ // src/chat/usage.ts
137
+ var agentTurnUsageSchema = usageSchema;
138
+ var COMPONENT_USAGE_FIELDS = [
139
+ "inputTokens",
140
+ "outputTokens",
141
+ "cachedInputTokens",
142
+ "cacheCreationTokens"
143
+ ];
144
+ var COST_COMPONENT_FIELDS = [
145
+ "input",
146
+ "output",
147
+ "cacheRead",
148
+ "cacheWrite"
149
+ ];
150
+ function hasAgentTurnUsage(usage) {
151
+ return Boolean(
152
+ usage && (Object.entries(usage).some(
153
+ ([field, value]) => field !== "cost" && typeof value === "number" && Number.isFinite(value)
154
+ ) || Object.values(usage.cost ?? {}).some(
155
+ (value) => typeof value === "number" && Number.isFinite(value)
156
+ ))
157
+ );
158
+ }
159
+ function getFiniteCount(value) {
160
+ return typeof value === "number" && Number.isFinite(value) ? Math.max(0, Math.floor(value)) : void 0;
161
+ }
162
+ function getFiniteCost(value) {
163
+ return typeof value === "number" && Number.isFinite(value) ? Math.max(0, value) : void 0;
164
+ }
165
+ function addCost(left, right) {
166
+ return Math.round(((left ?? 0) + right) * 1e12) / 1e12;
167
+ }
168
+ function getComponentTotal(usage) {
169
+ let total;
170
+ for (const field of COMPONENT_USAGE_FIELDS) {
171
+ const value = getFiniteCount(usage[field]);
172
+ if (value === void 0) continue;
173
+ total = (total ?? 0) + value;
174
+ }
175
+ return total;
176
+ }
177
+ function addAgentTurnUsage(...usages) {
178
+ const components = {};
179
+ let componentTotal;
180
+ let totalOnlyTokens;
181
+ let reasoningTokens;
182
+ const cost = {};
183
+ for (const usage of usages) {
184
+ if (!usage) continue;
185
+ const reasoning = getFiniteCount(usage.reasoningTokens);
186
+ if (reasoning !== void 0) {
187
+ reasoningTokens = (reasoningTokens ?? 0) + reasoning;
188
+ }
189
+ if (usage.cost) {
190
+ for (const field of [...COST_COMPONENT_FIELDS, "total"]) {
191
+ const value = getFiniteCost(usage.cost[field]);
192
+ if (value === void 0) continue;
193
+ cost[field] = addCost(cost[field], value);
194
+ }
195
+ }
196
+ const usageComponentTotal = getComponentTotal(usage);
197
+ if (usageComponentTotal !== void 0) {
198
+ componentTotal = (componentTotal ?? 0) + usageComponentTotal;
199
+ for (const field of COMPONENT_USAGE_FIELDS) {
200
+ const value = getFiniteCount(usage[field]);
201
+ if (value === void 0) continue;
202
+ components[field] = (components[field] ?? 0) + value;
203
+ }
204
+ continue;
205
+ }
206
+ const totalTokens = getFiniteCount(usage.totalTokens);
207
+ if (totalTokens !== void 0) {
208
+ totalOnlyTokens = (totalOnlyTokens ?? 0) + totalTokens;
209
+ }
210
+ }
211
+ if (totalOnlyTokens !== void 0) {
212
+ return {
213
+ totalTokens: totalOnlyTokens + (componentTotal ?? 0),
214
+ ...reasoningTokens !== void 0 ? { reasoningTokens } : void 0,
215
+ ...Object.keys(cost).length > 0 ? { cost } : void 0
216
+ };
217
+ }
218
+ const result = {
219
+ ...components,
220
+ ...reasoningTokens !== void 0 ? { reasoningTokens } : void 0,
221
+ ...Object.keys(cost).length > 0 ? { cost } : void 0
222
+ };
223
+ return hasAgentTurnUsage(result) ? result : void 0;
224
+ }
225
+
226
+ // src/chat/services/short-title.ts
227
+ var SHORT_TITLE_MAX_LENGTH = 60;
228
+ var TITLE_PROMPTS = {
229
+ conversation: [
230
+ "Generate a concise 5-8 word conversation title from the first user message below.",
231
+ "Capture the user's main request.",
232
+ "Reply with ONLY the title, with no quotes or trailing punctuation."
233
+ ],
234
+ task: [
235
+ "Generate a concise 5-8 word task title from the task instruction below.",
236
+ "Capture the task's main purpose.",
237
+ "Reply with ONLY the title, with no quotes or trailing punctuation."
238
+ ]
239
+ };
240
+ function normalizeShortTitle(value) {
241
+ return value.replace(/\s+/g, " ").trim().slice(0, SHORT_TITLE_MAX_LENGTH);
242
+ }
243
+ function fallbackShortTitle(sourceText, fallback = "Untitled") {
244
+ const firstLine = sourceText.split(/\r?\n/).map((line) => line.trim()).find((line) => line.length > 0) ?? "";
245
+ return normalizeShortTitle(firstLine) || fallback;
246
+ }
247
+ async function generateShortTitle(args) {
248
+ const sourceText = args.sourceText.trim();
249
+ if (!sourceText) return void 0;
250
+ try {
251
+ const result = await args.completeText({
252
+ modelId: botConfig.fastModelId,
253
+ temperature: 0,
254
+ promptName: `junior.${args.kind}_title`,
255
+ messages: [
256
+ {
257
+ role: "user",
258
+ content: [
259
+ ...TITLE_PROMPTS[args.kind],
260
+ "",
261
+ args.kind === "conversation" ? `First user message: ${sourceText.slice(0, 500)}` : `Task instruction: ${sourceText.slice(0, 500)}`
262
+ ].join("\n"),
263
+ timestamp: Date.now()
264
+ }
265
+ ],
266
+ metadata: {
267
+ modelId: botConfig.fastModelId
268
+ }
269
+ });
270
+ const title = normalizeShortTitle(result.text);
271
+ return title || void 0;
272
+ } catch (error) {
273
+ logWarn(`${args.kind}.title.generation.failed`, {
274
+ "exception.message": error instanceof Error ? error.message : String(error)
275
+ });
276
+ return void 0;
277
+ }
278
+ }
279
+ async function resolveTaskTitle(args) {
280
+ const explicit = normalizeShortTitle(args.title ?? "");
281
+ if (explicit) return explicit;
282
+ return generateShortTitle({
283
+ completeText: args.completeText,
284
+ kind: "task",
285
+ sourceText: args.instruction
286
+ });
287
+ }
288
+
289
+ // src/chat/tools/execution/tool-input-error.ts
290
+ var ToolInputError = class extends Error {
291
+ constructor(message, options) {
292
+ super(message, options);
293
+ this.name = "ToolInputError";
294
+ }
295
+ };
296
+
297
+ export {
298
+ JUNIOR_NATIVE_EVENT_NAMESPACE,
299
+ authenticationLinkedEvent,
300
+ authenticationUnlinkedEvent,
301
+ agentsInstructionsUpdatedEvent,
302
+ renderJuniorNativeConversationEvent,
303
+ SHORT_TITLE_MAX_LENGTH,
304
+ fallbackShortTitle,
305
+ generateShortTitle,
306
+ resolveTaskTitle,
307
+ ToolInputError,
308
+ agentTurnUsageSchema,
309
+ hasAgentTurnUsage,
310
+ addAgentTurnUsage
311
+ };
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-VFUK3X5B.js";
5
5
  import {
6
6
  DEFAULT_SQL_STATEMENT_TIMEOUT_MS
7
- } from "./chunk-Q7O74WOO.js";
7
+ } from "./chunk-VWNIDTFR.js";
8
8
 
9
9
  // src/db/neon.ts
10
10
  import { AsyncLocalStorage } from "async_hooks";
@@ -137,12 +137,14 @@ var juniorConversations = pgTable4(
137
137
  schemaVersion: integer2("schema_version").notNull().default(1),
138
138
  source: text4("source").$type(),
139
139
  /** Structured session Source locator; set-once on the conversation root. */
140
- // TODO(dcramer): Remove source_json after every stored Conversation has a
141
- // complete Location and all readers use it for provider context.
140
+ // TODO(dcramer): Remove source_json after resume reads the saved Turn Source
141
+ // and all provider context readers use Conversation Location.
142
142
  sessionSource: jsonb2("source_json").$type(),
143
143
  originType: text4("origin_type"),
144
144
  originId: text4("origin_id"),
145
145
  originRunId: text4("origin_run_id"),
146
+ /** Complete Location associated with this Conversation. */
147
+ location: jsonb2("location_json").$type(),
146
148
  // TODO(dcramer): Rename destination_id to location_id after all deployed
147
149
  // readers and writers use the singular Conversation Location contract.
148
150
  destinationId: text4("destination_id").references(
@@ -518,6 +520,8 @@ var juniorAgentInvocations = pgTable12(
518
520
  ).$type(),
519
521
  source: jsonb5("source_json").$type().notNull(),
520
522
  destination: jsonb5("destination_json").$type().notNull(),
523
+ // TODO(dcramer): Remove destinationVisibility after all deployed Agent
524
+ // invocation readers ignore the destination_visibility SQL column.
521
525
  destinationVisibility: text12(
522
526
  "destination_visibility"
523
527
  ).$type(),
package/dist/cli/chat.js CHANGED
@@ -1,52 +1,53 @@
1
1
  import {
2
2
  executeAgentRun
3
- } from "../chunk-RMB7CERI.js";
4
- import "../chunk-6JZGXLL2.js";
3
+ } from "../chunk-DJZGQ7OL.js";
4
+ import "../chunk-OYCOLHCR.js";
5
5
  import "../chunk-6Y5B5PEX.js";
6
6
  import "../chunk-DIB4GX3G.js";
7
- import "../chunk-W2DDJCPS.js";
8
- import "../chunk-UVUXFRYN.js";
9
- import "../chunk-VFZAUQ5V.js";
10
- import "../chunk-CVBDVIF4.js";
7
+ import "../chunk-FVFJ57RK.js";
11
8
  import {
12
9
  createAgentRunner
13
- } from "../chunk-6FGN7ZEG.js";
14
- import "../chunk-MQDIIFZM.js";
15
- import "../chunk-Z5SKZE5B.js";
16
- import "../chunk-6YGFBU3A.js";
10
+ } from "../chunk-GWCFXTB6.js";
11
+ import "../chunk-67MMSYSE.js";
12
+ import "../chunk-BGOLRC36.js";
17
13
  import "../chunk-2LYHWMR4.js";
18
- import "../chunk-XJIPMHKI.js";
14
+ import "../chunk-62DRKZQU.js";
15
+ import "../chunk-BUJU6C2J.js";
16
+ import "../chunk-YFU4DGZY.js";
17
+ import "../chunk-DA2KGZZI.js";
18
+ import "../chunk-YKIAUKYH.js";
19
+ import "../chunk-2MKHYSYL.js";
19
20
  import "../chunk-PDO5BLNM.js";
20
21
  import "../chunk-UIE3R5XU.js";
21
22
  import "../chunk-X6GDDWQH.js";
23
+ import "../chunk-7UJ6IJCK.js";
22
24
  import "../chunk-DKIJ2RP5.js";
23
25
  import "../chunk-JAL3CH4G.js";
24
26
  import "../chunk-7H2VZTWN.js";
25
- import "../chunk-WGZJ5SU4.js";
26
27
  import {
27
28
  loadAppPluginSet
28
29
  } from "../chunk-Y2CM7HXH.js";
29
- import "../chunk-QCGNHSMA.js";
30
+ import "../chunk-2MRF22J4.js";
30
31
  import "../chunk-3Y47VMHV.js";
31
- import "../chunk-IUUQWIG2.js";
32
- import "../chunk-QVH6FW3T.js";
33
- import "../chunk-X55FOVZO.js";
34
- import "../chunk-ZX7RSBQ6.js";
32
+ import "../chunk-OKAHLUSU.js";
33
+ import "../chunk-ZFCO2TMB.js";
34
+ import "../chunk-HI5KXE3C.js";
35
+ import "../chunk-6BXUSF7J.js";
35
36
  import "../chunk-GFBR4S3Q.js";
36
37
  import "../chunk-VFUK3X5B.js";
37
- import "../chunk-Q7O74WOO.js";
38
+ import "../chunk-VWNIDTFR.js";
38
39
  import "../chunk-D4YV5TDV.js";
39
- import "../chunk-FIUCHYT6.js";
40
- import "../chunk-3HEZWDS5.js";
41
- import "../chunk-NZLZ4KYZ.js";
42
- import "../chunk-QIOUTXTZ.js";
40
+ import "../chunk-DVX6U6GI.js";
41
+ import "../chunk-REVH4BZU.js";
42
+ import "../chunk-4PKEJK5B.js";
43
+ import "../chunk-663DQH5W.js";
43
44
  import "../chunk-CEMMLV5L.js";
44
45
  import "../chunk-N7TMSOZH.js";
45
46
  import "../chunk-DWPN6SCH.js";
46
47
  import "../chunk-TXKUKMVO.js";
47
- import "../chunk-QIMN3FXL.js";
48
+ import "../chunk-Y4WL4OYD.js";
48
49
  import "../chunk-PEQXYSSE.js";
49
- import "../chunk-32XSSFZV.js";
50
+ import "../chunk-JV7U4665.js";
50
51
 
51
52
  // src/cli/chat.ts
52
53
  import {
@@ -168,10 +169,10 @@ async function configureLocalChatPlugins(pluginSet) {
168
169
  databaseModule
169
170
  ] = await Promise.all([
170
171
  import("../plugins-YTYJMMJF.js"),
171
- import("../agent-hooks-5RQEVLQD.js"),
172
- import("../catalog-runtime-L4A6BJ3U.js"),
173
- import("../validation-E6Z5LHZM.js"),
174
- import("../db-YPRZAA2T.js")
172
+ import("../agent-hooks-3IG2FQW2.js"),
173
+ import("../catalog-runtime-2OT7S3ZC.js"),
174
+ import("../validation-IJGHK7NI.js"),
175
+ import("../db-2IFDMDDY.js")
175
176
  ]);
176
177
  const resolvedPluginSet = pluginSet === void 0 ? await loadLocalPluginSet() : pluginSet ?? void 0;
177
178
  const plugins = pluginsModule.pluginRuntimeRegistrationsFromPluginSet(resolvedPluginSet);
@@ -237,14 +238,14 @@ async function prepareLocalChatRun(io, pluginSet) {
237
238
  await configureLocalChatPlugins(pluginSet);
238
239
  const { setExperimentalFeatures } = await import("../experimental-P5FZM4CU.js");
239
240
  setExperimentalFeatures({ subagents: true });
240
- const { runLocalAgentTurn } = await import("../runner-FKVFFPLO.js");
241
- const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-DBBIR3XG.js");
241
+ const { runLocalAgentTurn } = await import("../runner-2N4QU77X.js");
242
+ const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-SZSS2KH6.js");
242
243
  const { createLocalOAuthState } = await import("../oauth-relay-5XPVRPYB.js");
243
244
  const { createLocalSandboxEgressSignalTransport } = await import("../sandbox-egress-signals-FIL7EGPR.js");
244
- const { bindSpawnAgent } = await import("../spawn-CO7QFCNJ.js");
245
- const { createAgentInvocationWorker, routeAgentInvocationWork } = await import("../work-OFTXWOK4.js");
245
+ const { bindSpawnAgent } = await import("../spawn-3K7RV4T5.js");
246
+ const { createAgentInvocationWorker, routeAgentInvocationWork } = await import("../work-DI45MLRL.js");
246
247
  const { createLocalConversationWork } = await import("../conversation-work-VIOQ5ZF3.js");
247
- const { processConversationWork } = await import("../worker-OMWNOKTJ.js");
248
+ const { processConversationWork } = await import("../worker-FY7KWG2M.js");
248
249
  let agentRunner;
249
250
  const localConversationWork = createLocalConversationWork(async (message) => {
250
251
  if (!agentRunner) {
package/dist/cli/check.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  parseSkillFile
3
- } from "../chunk-3HEZWDS5.js";
4
- import "../chunk-NZLZ4KYZ.js";
3
+ } from "../chunk-REVH4BZU.js";
4
+ import "../chunk-4PKEJK5B.js";
5
5
  import {
6
6
  parseInlinePluginManifest,
7
7
  parsePluginManifest
8
- } from "../chunk-QIOUTXTZ.js";
8
+ } from "../chunk-663DQH5W.js";
9
9
  import "../chunk-CEMMLV5L.js";
10
10
  import "../chunk-N7TMSOZH.js";
11
11
  import "../chunk-DWPN6SCH.js";
@@ -14,9 +14,9 @@ import {
14
14
  JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE,
15
15
  JUNIOR_HEARTBEAT_ROUTE,
16
16
  LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION
17
- } from "../chunk-QIMN3FXL.js";
17
+ } from "../chunk-Y4WL4OYD.js";
18
18
  import "../chunk-PEQXYSSE.js";
19
- import "../chunk-32XSSFZV.js";
19
+ import "../chunk-JV7U4665.js";
20
20
 
21
21
  // src/cli/check.ts
22
22
  import fs from "fs/promises";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  validatePluginEgressCredentialHooks,
3
3
  validatePluginRegistrations
4
- } from "../chunk-HCIVBCP5.js";
4
+ } from "../chunk-3J3BCB4J.js";
5
5
  import {
6
6
  pluginCatalogConfigFromPluginSet,
7
7
  pluginCliRegistrationsFromPluginSet,
@@ -14,30 +14,30 @@ import {
14
14
  createPluginLogger,
15
15
  setPlugins,
16
16
  validatePlugins
17
- } from "../chunk-QCGNHSMA.js";
17
+ } from "../chunk-2MRF22J4.js";
18
18
  import "../chunk-3Y47VMHV.js";
19
19
  import {
20
20
  getDb
21
- } from "../chunk-IUUQWIG2.js";
22
- import "../chunk-QVH6FW3T.js";
23
- import "../chunk-X55FOVZO.js";
24
- import "../chunk-ZX7RSBQ6.js";
21
+ } from "../chunk-OKAHLUSU.js";
22
+ import "../chunk-ZFCO2TMB.js";
23
+ import "../chunk-HI5KXE3C.js";
24
+ import "../chunk-6BXUSF7J.js";
25
25
  import "../chunk-GFBR4S3Q.js";
26
26
  import "../chunk-VFUK3X5B.js";
27
- import "../chunk-Q7O74WOO.js";
27
+ import "../chunk-VWNIDTFR.js";
28
28
  import "../chunk-D4YV5TDV.js";
29
- import "../chunk-FIUCHYT6.js";
29
+ import "../chunk-DVX6U6GI.js";
30
30
  import {
31
31
  pluginCatalogRuntime
32
- } from "../chunk-NZLZ4KYZ.js";
33
- import "../chunk-QIOUTXTZ.js";
32
+ } from "../chunk-4PKEJK5B.js";
33
+ import "../chunk-663DQH5W.js";
34
34
  import "../chunk-CEMMLV5L.js";
35
35
  import "../chunk-N7TMSOZH.js";
36
36
  import "../chunk-DWPN6SCH.js";
37
37
  import "../chunk-TXKUKMVO.js";
38
- import "../chunk-QIMN3FXL.js";
38
+ import "../chunk-Y4WL4OYD.js";
39
39
  import "../chunk-PEQXYSSE.js";
40
- import "../chunk-32XSSFZV.js";
40
+ import "../chunk-JV7U4665.js";
41
41
 
42
42
  // src/cli/plugins.ts
43
43
  import { stderr as defaultStderr, stdout as defaultStdout } from "process";