@sentry/junior 0.179.0 → 0.180.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 (126) hide show
  1. package/dist/{agent-hooks-32IDCLMW.js → agent-hooks-DKDDRKZA.js} +16 -18
  2. package/dist/api/schema.js +0 -1
  3. package/dist/api.js +199 -197
  4. package/dist/app.d.ts +4 -0
  5. package/dist/app.js +300 -1259
  6. package/dist/catalog-runtime-WXKGUF3W.js +14 -0
  7. package/dist/chat/agent/sandbox.d.ts +0 -2
  8. package/dist/chat/api-turns/routing.d.ts +4 -0
  9. package/dist/chat/api-turns/work.d.ts +5 -0
  10. package/dist/chat/config.d.ts +5 -2
  11. package/dist/chat/configuration/defaults.d.ts +1 -1
  12. package/dist/chat/conversations/projection.d.ts +6 -4
  13. package/dist/chat/ingress/message-router.d.ts +3 -0
  14. package/dist/chat/model-profile.d.ts +8 -10
  15. package/dist/chat/pi/conversation-events.d.ts +3 -2
  16. package/dist/chat/plugins/task-queue.d.ts +40 -3
  17. package/dist/chat/plugins/task-runner.d.ts +1 -1
  18. package/dist/chat/queue/callback.d.ts +26 -0
  19. package/dist/chat/queue/sign.d.ts +30 -0
  20. package/dist/chat/sandbox/sandbox.d.ts +0 -2
  21. package/dist/chat/sandbox/session.d.ts +0 -2
  22. package/dist/chat/sandbox/skill-sync.d.ts +1 -1
  23. package/dist/chat/sandbox/snapshot/events.d.ts +23 -0
  24. package/dist/chat/sandbox/snapshot/job-callback.d.ts +5 -0
  25. package/dist/chat/sandbox/snapshot/job-queue.d.ts +26 -0
  26. package/dist/chat/sandbox/snapshot/job-runner.d.ts +11 -0
  27. package/dist/chat/sandbox/snapshot/not-ready-error.d.ts +6 -0
  28. package/dist/chat/sandbox/snapshot/workspace.d.ts +9 -3
  29. package/dist/chat/services/turn-router.d.ts +4 -3
  30. package/dist/chat/task-execution/queue-signing.d.ts +10 -21
  31. package/dist/chat/task-execution/state.d.ts +48 -0
  32. package/dist/chat/task-execution/store.d.ts +28 -2
  33. package/dist/chat/task-execution/worker.d.ts +4 -1
  34. package/dist/chat/tools/handoff/tool.d.ts +1 -1
  35. package/dist/{chunk-B6ECUSVX.js → chunk-2AYEVN7K.js} +8 -8
  36. package/dist/{chunk-SLGGOASN.js → chunk-2YIRH4E3.js} +46 -46
  37. package/dist/{chunk-KJLHIHFF.js → chunk-3ILJBWP7.js} +35 -227
  38. package/dist/{chunk-RZRYOLCE.js → chunk-5PUMIMNQ.js} +2292 -1147
  39. package/dist/{chunk-CJLBLELR.js → chunk-5TUR4M3M.js} +8 -61
  40. package/dist/{chunk-6ZWRNC4D.js → chunk-6Y5B5PEX.js} +1 -1
  41. package/dist/{chunk-XSPSCWLH.js → chunk-6YCEWOLO.js} +4 -4
  42. package/dist/chunk-7H2VZTWN.js +103 -0
  43. package/dist/{chunk-FAS6AIMF.js → chunk-CCDXTDSY.js} +8 -8
  44. package/dist/{chunk-CGA4ERJ5.js → chunk-CEMMLV5L.js} +1 -1
  45. package/dist/{chunk-XZY6G5YZ.js → chunk-CK6EINVZ.js} +180 -87
  46. package/dist/{chunk-FIANEE7Z.js → chunk-CM5HNV2W.js} +6 -6
  47. package/dist/{chunk-JT4WMD3C.js → chunk-CP73FKME.js} +144 -218
  48. package/dist/{chunk-3I7XE3PA.js → chunk-DHLOGWYH.js} +36 -36
  49. package/dist/chunk-DKIJ2RP5.js +68 -0
  50. package/dist/{chunk-YFNAMRGE.js → chunk-DRHEGXTZ.js} +1 -1
  51. package/dist/{chunk-OOUNJNMR.js → chunk-DWPN6SCH.js} +1 -1
  52. package/dist/chunk-EWHP2IRG.js +209 -0
  53. package/dist/{chunk-R6U7N4FS.js → chunk-FGC3PHNH.js} +3 -3
  54. package/dist/{chunk-3TM3FYLQ.js → chunk-GA5NS74S.js} +1 -1
  55. package/dist/{chunk-FIDMHAO6.js → chunk-GPXAHUQH.js} +84 -274
  56. package/dist/chunk-GUKXEPMX.js +218 -0
  57. package/dist/{chunk-GENV6KF2.js → chunk-I6IFTAPF.js} +108 -76
  58. package/dist/{chunk-R5NWWYIS.js → chunk-IANUX7HX.js} +5 -5
  59. package/dist/{chunk-G2CAC4CV.js → chunk-KCL6AWYW.js} +74 -68
  60. package/dist/{chunk-5IRROPA5.js → chunk-L7LTGN4Z.js} +129 -31
  61. package/dist/{chunk-Q5B3WTGG.js → chunk-LGVQLNLS.js} +42 -41
  62. package/dist/chunk-M3QYTBQ6.js +55 -0
  63. package/dist/{chunk-FTGD2FBP.js → chunk-MXEUIGHO.js} +2 -2
  64. package/dist/{chunk-M63DETLL.js → chunk-N7TMSOZH.js} +6 -6
  65. package/dist/{chunk-2HIPYNQI.js → chunk-O4QYZTDK.js} +33 -32
  66. package/dist/chunk-PEQXYSSE.js +45 -0
  67. package/dist/{chunk-RTRBYSF3.js → chunk-QSO7B5JO.js} +1 -1
  68. package/dist/{chunk-HQNE5APD.js → chunk-RAZG3YHC.js} +100 -79
  69. package/dist/{chunk-VP4OVRDD.js → chunk-S7YRTOSQ.js} +69 -73
  70. package/dist/{chunk-U4TKB6F6.js → chunk-SDBKZ5LV.js} +108 -5
  71. package/dist/{chunk-GPLAT6H7.js → chunk-TC5DE5KJ.js} +22 -18
  72. package/dist/{chunk-H4HBKISO.js → chunk-TXKUKMVO.js} +1 -1
  73. package/dist/chunk-U5EUCUBH.js +164 -0
  74. package/dist/{chunk-3AFVR5UC.js → chunk-VG722ONZ.js} +18 -16
  75. package/dist/{chunk-ZQMG3CL5.js → chunk-VGPPWWHF.js} +16 -16
  76. package/dist/{chunk-JMJNFEDC.js → chunk-WVAMRKYG.js} +9 -54
  77. package/dist/chunk-X6GDDWQH.js +60 -0
  78. package/dist/{chunk-4GWXAILB.js → chunk-ZE2KOV3G.js} +1 -1
  79. package/dist/{chunk-TIEKUH4Q.js → chunk-ZM7ZURJS.js} +4 -3
  80. package/dist/cli/chat.js +47 -43
  81. package/dist/cli/check.js +13 -15
  82. package/dist/cli/env.js +0 -1
  83. package/dist/cli/init.js +0 -1
  84. package/dist/cli/main.js +2 -3
  85. package/dist/cli/plugins.js +18 -20
  86. package/dist/cli/run.js +0 -1
  87. package/dist/cli/snapshot-create.js +14 -16
  88. package/dist/cli/upgrade.js +16 -18
  89. package/dist/{conversation-work-KATFHLG3.js → conversation-work-VIOQ5ZF3.js} +0 -2
  90. package/dist/{db-EJAV7JL6.js → db-6SBHIAJK.js} +8 -10
  91. package/dist/deployment.d.ts +1 -0
  92. package/dist/{discovery-GUFTFBTL.js → discovery-DWVDM7UK.js} +1 -2
  93. package/dist/{experimental-XVDOSRBS.js → experimental-SIJSRDJD.js} +0 -1
  94. package/dist/instrumentation.js +7 -9
  95. package/dist/nitro.js +39 -13
  96. package/dist/{oauth-callback-server-GAVSUBTQ.js → oauth-callback-server-WSDQPZZS.js} +34 -32
  97. package/dist/{oauth-relay-3ZU72UGL.js → oauth-relay-5XPVRPYB.js} +0 -1
  98. package/dist/{plugins-HW4VWW6G.js → plugins-YTYJMMJF.js} +1 -2
  99. package/dist/{runner-34JL64JF.js → runner-GWTSWESR.js} +39 -33
  100. package/dist/{sandbox-egress-signals-DXOOBSBI.js → sandbox-egress-signals-FIL7EGPR.js} +5 -6
  101. package/dist/{sentry-JMWTS32N.js → sentry-MB3NL3IR.js} +1 -2
  102. package/dist/skills-F32BPFYW.js +27 -0
  103. package/dist/spawn-X5BPP5OE.js +37 -0
  104. package/dist/task-runner-2FPBV5PP.js +32 -0
  105. package/dist/validation-62WO524A.js +17 -0
  106. package/dist/vercel.js +0 -1
  107. package/dist/version.js +1 -2
  108. package/dist/work-3C3CMZ24.js +45 -0
  109. package/dist/worker-MFAI6ZEK.js +22 -0
  110. package/package.json +8 -7
  111. package/dist/catalog-runtime-FBVA6WAQ.js +0 -16
  112. package/dist/chat/plugins/task-callback.d.ts +0 -5
  113. package/dist/chat/plugins/task-message.d.ts +0 -23
  114. package/dist/chat/plugins/task-signing.d.ts +0 -31
  115. package/dist/chat/sandbox/snapshot/waiting-error.d.ts +0 -15
  116. package/dist/chat/services/workspace-snapshot-wait.d.ts +0 -27
  117. package/dist/chunk-5I6ORJUY.js +0 -127
  118. package/dist/chunk-6GWA276C.js +0 -72
  119. package/dist/chunk-MLKGABMK.js +0 -9
  120. package/dist/chunk-UT6X7XN7.js +0 -51
  121. package/dist/chunk-WR76IVA5.js +0 -130
  122. package/dist/skills-U545HALM.js +0 -29
  123. package/dist/spawn-I2S4IDUQ.js +0 -37
  124. package/dist/validation-EVXVGA44.js +0 -19
  125. package/dist/work-QOAUPDBU.js +0 -45
  126. package/dist/worker-5GX2IKLZ.js +0 -24
@@ -0,0 +1,218 @@
1
+ import {
2
+ abandonTurnRecord,
3
+ extractAssistantText
4
+ } from "./chunk-GPXAHUQH.js";
5
+
6
+ // src/chat/state/turn-id.ts
7
+ function buildDeterministicTurnId(messageId) {
8
+ const sanitized = messageId.replace(/[^a-zA-Z0-9_-]/g, "_");
9
+ return `turn_${sanitized}`;
10
+ }
11
+ function buildDeterministicAssistantMessageId(turnId) {
12
+ return `${turnId}:assistant:1`;
13
+ }
14
+
15
+ // src/chat/runtime/turn.ts
16
+ var ConversationTurnBoundaryError = class extends Error {
17
+ eventId;
18
+ failureCode;
19
+ constructor(args) {
20
+ super(
21
+ args.cause instanceof Error ? args.cause.message : String(args.cause),
22
+ {
23
+ cause: args.cause
24
+ }
25
+ );
26
+ this.name = "ConversationTurnBoundaryError";
27
+ this.eventId = args.eventId;
28
+ this.failureCode = args.failureCode;
29
+ }
30
+ };
31
+ function getConversationTurnBoundaryError(error) {
32
+ return error instanceof ConversationTurnBoundaryError ? error : void 0;
33
+ }
34
+ var CooperativeTurnYieldError = class extends Error {
35
+ code = "cooperative_turn_yield";
36
+ constructor(message = "Agent turn yielded at a safe boundary") {
37
+ super(message);
38
+ this.name = "CooperativeTurnYieldError";
39
+ }
40
+ };
41
+ function isCooperativeTurnYieldError(error) {
42
+ return error instanceof CooperativeTurnYieldError;
43
+ }
44
+ var TurnInputCommitLostError = class extends Error {
45
+ code = "turn_input_commit_lost";
46
+ constructor(message = "Turn input commit lost its durable owner") {
47
+ super(message);
48
+ this.name = "TurnInputCommitLostError";
49
+ }
50
+ };
51
+ function isTurnInputCommitLostError(error) {
52
+ return error instanceof TurnInputCommitLostError;
53
+ }
54
+ var TurnInputDeferredError = class extends Error {
55
+ code = "turn_input_deferred";
56
+ constructor(message = "Turn input is deferred until the active resume ends") {
57
+ super(message);
58
+ this.name = "TurnInputDeferredError";
59
+ }
60
+ };
61
+ function isTurnInputDeferredError(error) {
62
+ return error instanceof TurnInputDeferredError;
63
+ }
64
+ function startActiveTurn(args) {
65
+ args.conversation.processing.activeTurnId = args.nextTurnId;
66
+ }
67
+ function clearActiveTurn(conversation, sessionId) {
68
+ if (!sessionId || conversation.processing.activeTurnId === sessionId) {
69
+ conversation.processing.activeTurnId = void 0;
70
+ }
71
+ }
72
+ function markTurnClosed(args) {
73
+ clearActiveTurn(args.conversation, args.sessionId);
74
+ args.conversation.processing.lastCompletedAtMs = args.nowMs;
75
+ }
76
+ function markTurnCompleted(args) {
77
+ clearActiveTurn(args.conversation, args.sessionId);
78
+ args.conversation.processing.lastCompletedAtMs = args.nowMs;
79
+ }
80
+ function markTurnFailed(args) {
81
+ clearActiveTurn(args.conversation, args.sessionId);
82
+ args.conversation.processing.lastCompletedAtMs = args.nowMs;
83
+ args.markConversationMessage(args.conversation, args.userMessageId, {
84
+ replied: false,
85
+ skippedReason: "reply failed"
86
+ });
87
+ }
88
+
89
+ // src/chat/no-reply.ts
90
+ var NO_REPLY_MARKER = "[[NO_REPLY]]";
91
+ function isNoReplyMarker(text) {
92
+ return text.trim() === NO_REPLY_MARKER;
93
+ }
94
+ function containsNoReplyMarker(text) {
95
+ return text.includes(NO_REPLY_MARKER);
96
+ }
97
+
98
+ // src/chat/services/assistant-reply.ts
99
+ var THINKING_XML_BLOCK_PATTERN = /[ \t]*<thinking\b[^>]*>[\s\S]*?<\/thinking>[ \t]*(?:\r?\n)?/gi;
100
+ var FENCED_CODE_BLOCK_PATTERN = /```[\s\S]*?```/g;
101
+ function sanitizeAssistantText(text) {
102
+ let result = "";
103
+ let cursor = 0;
104
+ for (const match of text.matchAll(FENCED_CODE_BLOCK_PATTERN)) {
105
+ const start = match.index;
106
+ if (start === void 0) continue;
107
+ result += text.slice(cursor, start).replace(THINKING_XML_BLOCK_PATTERN, "");
108
+ result += match[0];
109
+ cursor = start + match[0].length;
110
+ }
111
+ return (result + text.slice(cursor).replace(THINKING_XML_BLOCK_PATTERN, "")).trim();
112
+ }
113
+ function decideReply(message) {
114
+ if (message.content.some((part) => part.type === "toolCall")) {
115
+ return { kind: "suppress" };
116
+ }
117
+ const text = sanitizeAssistantText(extractAssistantText(message));
118
+ if (!text) return { kind: "empty" };
119
+ if (isNoReplyMarker(text) || containsNoReplyMarker(text)) {
120
+ return { kind: "suppress" };
121
+ }
122
+ return { kind: "deliver", text };
123
+ }
124
+ function getAssistantReplyText(message) {
125
+ const decision = decideReply(message);
126
+ return decision.kind === "deliver" ? decision.text : void 0;
127
+ }
128
+
129
+ // src/chat/services/pending-auth.ts
130
+ var AUTH_LINK_REUSE_WINDOW_MS = 10 * 60 * 1e3;
131
+ var NON_REQUEST_SKIPPED_REASON_PREFIXES = [
132
+ "directed_to_other_party:",
133
+ "side_conversation:"
134
+ ];
135
+ function isSkippedNonRequest(reason) {
136
+ return NON_REQUEST_SKIPPED_REASON_PREFIXES.some(
137
+ (prefix) => reason?.startsWith(prefix)
138
+ );
139
+ }
140
+ function canReusePendingAuthLink(args) {
141
+ const { pendingAuth } = args;
142
+ if (!pendingAuth) {
143
+ return false;
144
+ }
145
+ return pendingAuth.kind === args.kind && pendingAuth.provider === args.provider && pendingAuth.actorId === args.actorId && pendingAuth.scope === args.scope && pendingAuth.sessionId === args.sessionId && pendingAuth.linkSentAtMs + AUTH_LINK_REUSE_WINDOW_MS > (args.nowMs ?? Date.now());
146
+ }
147
+ function getConversationPendingAuth(args) {
148
+ const pendingAuth = args.conversation.processing.pendingAuth;
149
+ if (!pendingAuth) {
150
+ return void 0;
151
+ }
152
+ if (pendingAuth.kind !== args.kind || pendingAuth.provider !== args.provider || pendingAuth.actorId !== args.actorId || pendingAuth.scope !== args.scope) {
153
+ return void 0;
154
+ }
155
+ return pendingAuth;
156
+ }
157
+ function clearPendingAuth(conversation, sessionId) {
158
+ if (!conversation.processing.pendingAuth) {
159
+ return;
160
+ }
161
+ if (sessionId && conversation.processing.pendingAuth.sessionId !== sessionId) {
162
+ return;
163
+ }
164
+ conversation.processing.pendingAuth = void 0;
165
+ }
166
+ async function abandonReplacedPendingAuth(args) {
167
+ if (args.previousPendingAuth && args.previousPendingAuth.sessionId !== args.nextPendingAuth.sessionId && args.conversationId) {
168
+ await abandonTurnRecord({
169
+ conversationId: args.conversationId,
170
+ turnId: args.previousPendingAuth.sessionId,
171
+ errorMessage: "Abandoned by a newer auth-blocked request in the same conversation."
172
+ });
173
+ }
174
+ }
175
+ function isPendingAuthLatestRequest(conversation, pendingAuth) {
176
+ for (let index = conversation.messages.length - 1; index >= 0; index -= 1) {
177
+ const message = conversation.messages[index];
178
+ if (message?.role !== "user") {
179
+ continue;
180
+ }
181
+ if (message.author?.isBot) {
182
+ continue;
183
+ }
184
+ if (isSkippedNonRequest(message.meta?.skippedReason)) {
185
+ continue;
186
+ }
187
+ return buildDeterministicTurnId(message.id) === pendingAuth.sessionId;
188
+ }
189
+ return false;
190
+ }
191
+
192
+ export {
193
+ buildDeterministicTurnId,
194
+ buildDeterministicAssistantMessageId,
195
+ ConversationTurnBoundaryError,
196
+ getConversationTurnBoundaryError,
197
+ CooperativeTurnYieldError,
198
+ isCooperativeTurnYieldError,
199
+ TurnInputCommitLostError,
200
+ isTurnInputCommitLostError,
201
+ TurnInputDeferredError,
202
+ isTurnInputDeferredError,
203
+ startActiveTurn,
204
+ markTurnClosed,
205
+ markTurnCompleted,
206
+ markTurnFailed,
207
+ NO_REPLY_MARKER,
208
+ isNoReplyMarker,
209
+ containsNoReplyMarker,
210
+ sanitizeAssistantText,
211
+ decideReply,
212
+ getAssistantReplyText,
213
+ canReusePendingAuthLink,
214
+ getConversationPendingAuth,
215
+ clearPendingAuth,
216
+ abandonReplacedPendingAuth,
217
+ isPendingAuthLatestRequest
218
+ };
@@ -3,7 +3,7 @@ import {
3
3
  toCanonicalInputMessage,
4
4
  toCanonicalOutputMessage,
5
5
  toGenAiMessagesTraceAttributes
6
- } from "./chunk-XSPSCWLH.js";
6
+ } from "./chunk-6YCEWOLO.js";
7
7
  import {
8
8
  extractGenAiUsageAttributes,
9
9
  logException,
@@ -11,7 +11,7 @@ import {
11
11
  normalizeGenAiFinishReason,
12
12
  serializeGenAiAttribute,
13
13
  withSpan
14
- } from "./chunk-HQNE5APD.js";
14
+ } from "./chunk-RAZG3YHC.js";
15
15
 
16
16
  // src/chat/services/provider-error.ts
17
17
  var ProviderError = class extends Error {
@@ -74,17 +74,17 @@ function providerMessage(error) {
74
74
  }
75
75
  function extractTransportKind(error, depth = 0) {
76
76
  if (!(error instanceof Error) || depth > 4) return void 0;
77
- const shaped = error;
78
- const code = typeof shaped.code === "string" ? shaped.code.toUpperCase() : void 0;
77
+ const providerError = error;
78
+ const code = typeof providerError.code === "string" ? providerError.code.toUpperCase() : void 0;
79
79
  if (code && TIMEOUT_ERROR_CODES.has(code)) return "timeout";
80
80
  if (code && NETWORK_ERROR_CODES.has(code)) return "network";
81
- return extractTransportKind(shaped.cause, depth + 1);
81
+ return extractTransportKind(providerError.cause, depth + 1);
82
82
  }
83
83
  function extractStatus(error, message) {
84
84
  if (error instanceof Error) {
85
- const shaped = error;
86
- if (typeof shaped.status === "number") return shaped.status;
87
- if (typeof shaped.statusCode === "number") return shaped.statusCode;
85
+ const providerError = error;
86
+ if (typeof providerError.status === "number") return providerError.status;
87
+ if (typeof providerError.statusCode === "number") return providerError.statusCode;
88
88
  }
89
89
  const match = message.match(
90
90
  /^(?:Error:\s*)?([45]\d\d)\b|\bstatus(?:Code)?["'=:\s]+([45]\d\d)\b/i
@@ -189,9 +189,9 @@ function getProviderErrorAttributes(error) {
189
189
  return {
190
190
  "app.ai.provider_error.kind": error.kind,
191
191
  "app.ai.provider_error.retryable": error.retryable,
192
- ...error.status !== void 0 ? { "app.ai.provider_error.status": error.status } : {},
193
- ...error.retryAfterMs !== void 0 ? { "app.ai.provider_error.retry_after_ms": error.retryAfterMs } : {},
194
- ...error.modelId ? { "gen_ai.request.model": error.modelId } : {}
192
+ ...error.status !== void 0 ? { "app.ai.provider_error.status": error.status } : void 0,
193
+ ...error.retryAfterMs !== void 0 ? { "app.ai.provider_error.retry_after_ms": error.retryAfterMs } : void 0,
194
+ ...error.modelId ? { "gen_ai.request.model": error.modelId } : void 0
195
195
  };
196
196
  }
197
197
 
@@ -385,21 +385,21 @@ async function completeText(params) {
385
385
  "gen_ai.operation.name": GEN_AI_OPERATION_CHAT,
386
386
  "gen_ai.request.model": params.modelId,
387
387
  "gen_ai.output.type": "text",
388
- ...params.promptName ? { "gen_ai.prompt.name": params.promptName } : {},
388
+ ...params.promptName ? { "gen_ai.prompt.name": params.promptName } : void 0,
389
389
  "server.address": GEN_AI_SERVER_ADDRESS,
390
390
  "server.port": GEN_AI_SERVER_PORT,
391
- ...hasCompactedConversationContext(params.messages) ? { "gen_ai.conversation.compacted": true } : {},
391
+ ...hasCompactedConversationContext(params.messages) ? { "gen_ai.conversation.compacted": true } : void 0,
392
392
  "app.conversation.privacy": effectivePrivacy,
393
- ...params.thinkingLevel ? { "gen_ai.request.reasoning.level": params.thinkingLevel } : {},
394
- ...params.temperature !== void 0 ? { "gen_ai.request.temperature": params.temperature } : {},
395
- ...params.maxTokens !== void 0 ? { "gen_ai.request.max_tokens": params.maxTokens } : {}
393
+ ...params.thinkingLevel ? { "gen_ai.request.reasoning.level": params.thinkingLevel } : void 0,
394
+ ...params.temperature !== void 0 ? { "gen_ai.request.temperature": params.temperature } : void 0,
395
+ ...params.maxTokens !== void 0 ? { "gen_ai.request.max_tokens": params.maxTokens } : void 0
396
396
  };
397
397
  const startAttributes = {
398
398
  ...baseAttributes,
399
399
  ...toGenAiMessagesTraceAttributes("gen_ai.input", params.messages),
400
- ...params.system ? { "gen_ai.system_instructions.content_chars": params.system.length } : {},
401
- ...systemInstructionsAttribute ? { "gen_ai.system_instructions": systemInstructionsAttribute } : {},
402
- ...requestMessagesAttribute ? { "gen_ai.input.messages": requestMessagesAttribute } : {},
400
+ ...params.system ? { "gen_ai.system_instructions.content_chars": params.system.length } : void 0,
401
+ ...systemInstructionsAttribute ? { "gen_ai.system_instructions": systemInstructionsAttribute } : void 0,
402
+ ...requestMessagesAttribute ? { "gen_ai.input.messages": requestMessagesAttribute } : void 0,
403
403
  "gen_ai.provider.auth_mode": authMode
404
404
  };
405
405
  return withSpan(
@@ -416,7 +416,7 @@ async function completeText(params) {
416
416
  messages: params.messages
417
417
  },
418
418
  {
419
- ...apiKey ? { apiKey } : {},
419
+ ...apiKey ? { apiKey } : void 0,
420
420
  temperature: params.temperature,
421
421
  maxTokens: params.maxTokens,
422
422
  reasoning: params.thinkingLevel,
@@ -440,14 +440,14 @@ async function completeText(params) {
440
440
  content: outputText ? [{ type: "text", text: outputText }] : []
441
441
  }
442
442
  ]),
443
- ...outputMessagesAttribute ? { "gen_ai.output.messages": outputMessagesAttribute } : {},
443
+ ...outputMessagesAttribute ? { "gen_ai.output.messages": outputMessagesAttribute } : void 0,
444
444
  ...usageAttributes,
445
445
  ...message.stopReason ? {
446
446
  "gen_ai.response.finish_reasons": [
447
447
  normalizeGenAiFinishReason(message.stopReason)
448
448
  ]
449
- } : {},
450
- ...message.model ? { "gen_ai.response.model": message.model } : {}
449
+ } : void 0,
450
+ ...message.model ? { "gen_ai.response.model": message.model } : void 0
451
451
  };
452
452
  setSpanAttributes(endAttributes);
453
453
  if (message.stopReason === "error") {
@@ -473,10 +473,10 @@ function logContextFromMetadata(modelId, metadata) {
473
473
  const runId = typeof metadata?.runId === "string" ? metadata.runId : void 0;
474
474
  return {
475
475
  modelId,
476
- ...conversationId ? { conversationId } : {},
477
- ...messageConversationId ? { messageConversationId } : {},
478
- ...destinationName ? { destinationName } : {},
479
- ...runId ? { runId } : {}
476
+ ...conversationId ? { conversationId } : void 0,
477
+ ...messageConversationId ? { messageConversationId } : void 0,
478
+ ...destinationName ? { destinationName } : void 0,
479
+ ...runId ? { runId } : void 0
480
480
  };
481
481
  }
482
482
  function objectCompletionCost(modelId, usage) {
@@ -491,7 +491,7 @@ function objectCompletionCost(modelId, usage) {
491
491
  output: usage.outputTokens ?? 0,
492
492
  cacheRead: cacheRead ?? 0,
493
493
  cacheWrite: cacheWrite ?? 0,
494
- ...usage.outputTokenDetails.reasoningTokens !== void 0 ? { reasoning: usage.outputTokenDetails.reasoningTokens } : {},
494
+ ...usage.outputTokenDetails.reasoningTokens !== void 0 ? { reasoning: usage.outputTokenDetails.reasoningTokens } : void 0,
495
495
  totalTokens: usage.totalTokens ?? (input ?? 0) + (usage.outputTokens ?? 0) + (cacheRead ?? 0) + (cacheWrite ?? 0),
496
496
  cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 }
497
497
  }).total;
@@ -523,17 +523,17 @@ async function completeObject(params) {
523
523
  model: provider.chat(params.modelId),
524
524
  schema: params.schema,
525
525
  prompt: params.prompt,
526
- ...params.system !== void 0 ? { system: params.system } : {},
527
- ...params.temperature !== void 0 ? { temperature: params.temperature } : {},
528
- ...params.maxTokens !== void 0 ? { maxOutputTokens: params.maxTokens } : {},
526
+ ...params.system !== void 0 ? { system: params.system } : void 0,
527
+ ...params.temperature !== void 0 ? { temperature: params.temperature } : void 0,
528
+ ...params.maxTokens !== void 0 ? { maxOutputTokens: params.maxTokens } : void 0,
529
529
  ...params.recordTelemetryPayloads === false ? {
530
530
  experimental_telemetry: {
531
531
  isEnabled: true,
532
532
  recordInputs: false,
533
533
  recordOutputs: false
534
534
  }
535
- } : {},
536
- ...params.signal !== void 0 ? { abortSignal: params.signal } : {}
535
+ } : void 0,
536
+ ...params.signal !== void 0 ? { abortSignal: params.signal } : void 0
537
537
  });
538
538
  setSpanAttributes({
539
539
  "gen_ai.response.finish_reasons": [result2.finishReason],
@@ -546,18 +546,18 @@ async function completeObject(params) {
546
546
  "gen_ai.operation.name": GEN_AI_OPERATION_CHAT,
547
547
  "gen_ai.request.model": params.modelId,
548
548
  "gen_ai.output.type": "json",
549
- ...params.promptName ? { "gen_ai.prompt.name": params.promptName } : {},
549
+ ...params.promptName ? { "gen_ai.prompt.name": params.promptName } : void 0,
550
550
  "server.address": GEN_AI_SERVER_ADDRESS,
551
551
  "server.port": GEN_AI_SERVER_PORT,
552
552
  "gen_ai.provider.auth_mode": credential?.mode ?? "api_key",
553
- ...params.thinkingLevel ? { "gen_ai.request.reasoning.level": params.thinkingLevel } : {},
554
- ...params.temperature !== void 0 ? { "gen_ai.request.temperature": params.temperature } : {},
555
- ...params.maxTokens !== void 0 ? { "gen_ai.request.max_tokens": params.maxTokens } : {}
553
+ ...params.thinkingLevel ? { "gen_ai.request.reasoning.level": params.thinkingLevel } : void 0,
554
+ ...params.temperature !== void 0 ? { "gen_ai.request.temperature": params.temperature } : void 0,
555
+ ...params.maxTokens !== void 0 ? { "gen_ai.request.max_tokens": params.maxTokens } : void 0
556
556
  }
557
557
  );
558
558
  } catch (error) {
559
559
  const providerError = createProviderError(error, {
560
- ...NoObjectGeneratedError.isInstance(error) ? { kind: "invalid_response" } : {},
560
+ ...NoObjectGeneratedError.isInstance(error) ? { kind: "invalid_response" } : void 0,
561
561
  modelId: params.modelId
562
562
  });
563
563
  throw providerError;
@@ -565,7 +565,7 @@ async function completeObject(params) {
565
565
  const costUsd = bestEffortObjectCompletionCost(params.modelId, result.usage);
566
566
  return {
567
567
  object: result.object,
568
- ...costUsd !== void 0 ? { costUsd } : {}
568
+ ...costUsd !== void 0 ? { costUsd } : void 0
569
569
  };
570
570
  }
571
571
  async function embedTexts(params) {
@@ -586,7 +586,7 @@ async function embedTexts(params) {
586
586
  const result2 = await embedMany({
587
587
  model: provider.embeddingModel(params.modelId),
588
588
  values: texts,
589
- ...params.signal !== void 0 ? { abortSignal: params.signal } : {}
589
+ ...params.signal !== void 0 ? { abortSignal: params.signal } : void 0
590
590
  });
591
591
  const dimensions = result2.embeddings[0]?.length;
592
592
  if (result2.embeddings.length !== texts.length || !dimensions || !result2.embeddings.every(
@@ -605,7 +605,7 @@ async function embedTexts(params) {
605
605
  "gen_ai.embeddings.dimension.count": dimensions,
606
606
  ...extractGenAiUsageAttributes({
607
607
  inputTokens: result2.usage.tokens,
608
- ...costUsd !== void 0 ? { cost: { input: costUsd, total: costUsd } } : {}
608
+ ...costUsd !== void 0 ? { cost: { input: costUsd, total: costUsd } } : void 0
609
609
  })
610
610
  });
611
611
  return { costUsd, dimensions, result: result2 };
@@ -620,7 +620,7 @@ async function embedTexts(params) {
620
620
  }
621
621
  );
622
622
  return {
623
- ...result.costUsd !== void 0 ? { costUsd: result.costUsd } : {},
623
+ ...result.costUsd !== void 0 ? { costUsd: result.costUsd } : void 0,
624
624
  dimensions: result.dimensions,
625
625
  model: params.modelId,
626
626
  provider: GEN_AI_PROVIDER_NAME,
@@ -668,8 +668,6 @@ function parseTurnReasoningLevel(value) {
668
668
 
669
669
  // src/chat/model-profile.ts
670
670
  import { z as z2 } from "zod";
671
- var STANDARD_MODEL_PROFILE = "standard";
672
- var DEFAULT_HANDOFF_MODEL_PROFILE = "handoff";
673
671
  var modelProfileSchema = z2.string().regex(/^[a-z][a-z0-9_-]*$/);
674
672
  var ModelProfileNotConfiguredError = class extends Error {
675
673
  constructor(profile) {
@@ -680,8 +678,8 @@ var ModelProfileNotConfiguredError = class extends Error {
680
678
  function modelIdForProfile(config, profile) {
681
679
  return profileConfig(config, profile).modelId;
682
680
  }
683
- function standardModelId(config) {
684
- return modelIdForProfile(config, STANDARD_MODEL_PROFILE);
681
+ function defaultModelId(config) {
682
+ return modelIdForProfile(config, config.defaultProfile);
685
683
  }
686
684
  function profileConfig(config, profile) {
687
685
  const profileConfig2 = Object.hasOwn(config.profiles, profile) ? config.profiles[profile] : void 0;
@@ -826,47 +824,49 @@ function validateGatewayModelId(raw) {
826
824
  function validateEmbeddingModelId(raw) {
827
825
  return toOptionalTrimmed(raw);
828
826
  }
829
- function parseProfiles(rawValue, standardModelId2, handoffModelId) {
830
- const profiles = {
831
- [STANDARD_MODEL_PROFILE]: { modelId: standardModelId2 },
832
- [DEFAULT_HANDOFF_MODEL_PROFILE]: {
833
- modelId: handoffModelId,
834
- reasoningLevel: "high"
835
- }
836
- };
837
- const trimmed = toOptionalTrimmed(rawValue);
838
- if (trimmed === void 0) {
839
- return profiles;
840
- }
841
- let parsed;
842
- try {
843
- parsed = JSON.parse(trimmed);
844
- } catch {
845
- throw new Error("AI_MODEL_PROFILES must be a JSON object");
827
+ function parseProfileMap(rawProfiles, configName) {
828
+ if (!rawProfiles || typeof rawProfiles !== "object" || Array.isArray(rawProfiles)) {
829
+ const objectType = configName === "AI_MODEL_PROFILES" ? "a JSON object" : "an object";
830
+ throw new Error(`${configName} must be ${objectType}`);
846
831
  }
847
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
848
- throw new Error("AI_MODEL_PROFILES must be a JSON object");
849
- }
850
- for (const [profile, rawModelId] of Object.entries(parsed)) {
832
+ const profiles = {};
833
+ for (const [profile, rawModelId] of Object.entries(rawProfiles)) {
851
834
  if (!modelProfileSchema.safeParse(profile).success) {
852
835
  throw new Error(
853
- `AI_MODEL_PROFILES profile "${profile}" must match ^[a-z][a-z0-9_-]*$`
836
+ `${configName} profile "${profile}" must match ^[a-z][a-z0-9_-]*$`
854
837
  );
855
838
  }
856
- if (profile === STANDARD_MODEL_PROFILE || profile === DEFAULT_HANDOFF_MODEL_PROFILE) {
857
- throw new Error(`AI_MODEL_PROFILES profile "${profile}" is reserved`);
858
- }
859
839
  if (typeof rawModelId !== "string") {
860
- throw new Error(`AI_MODEL_PROFILES.${profile} must be a model id string`);
840
+ throw new Error(`${configName}.${profile} must be a model id string`);
861
841
  }
862
842
  const modelId = validateGatewayModelId(rawModelId);
863
843
  if (!modelId) {
864
- throw new Error(`AI_MODEL_PROFILES.${profile} must not be empty`);
844
+ throw new Error(`${configName}.${profile} must not be empty`);
865
845
  }
866
846
  profiles[profile] = { modelId };
867
847
  }
868
848
  return profiles;
869
849
  }
850
+ function parseProfiles(rawValue, standardModelId, handoffModelId) {
851
+ const profiles = {
852
+ standard: { modelId: standardModelId },
853
+ handoff: { modelId: handoffModelId, reasoningLevel: "high" }
854
+ };
855
+ const trimmed = toOptionalTrimmed(rawValue);
856
+ if (trimmed === void 0) {
857
+ return profiles;
858
+ }
859
+ let parsed;
860
+ try {
861
+ parsed = JSON.parse(trimmed);
862
+ } catch {
863
+ throw new Error("AI_MODEL_PROFILES must be a JSON object");
864
+ }
865
+ return {
866
+ ...profiles,
867
+ ...parseProfileMap(parsed, "AI_MODEL_PROFILES")
868
+ };
869
+ }
870
870
  function parseReactionEmoji(envName, rawValue, defaultEmoji) {
871
871
  const trimmed = toOptionalTrimmed(rawValue);
872
872
  if (trimmed === void 0) {
@@ -880,7 +880,22 @@ function parseReactionEmoji(envName, rawValue, defaultEmoji) {
880
880
  }
881
881
  return normalized;
882
882
  }
883
+ function warnDeprecatedProfileEnv(env) {
884
+ for (const envName of [
885
+ "AI_MODEL",
886
+ "AI_HANDOFF_MODEL",
887
+ "AI_MODEL_PROFILES"
888
+ ]) {
889
+ if (toOptionalTrimmed(env[envName]) !== void 0) {
890
+ logWarn("config.profile_env.deprecated", {
891
+ "app.config.env_name": envName,
892
+ "app.config.replacement": "createApp({ defaultProfile, profiles })"
893
+ });
894
+ }
895
+ }
896
+ }
883
897
  function readBotConfig(env, functionMaxDurationSeconds) {
898
+ warnDeprecatedProfileEnv(env);
884
899
  const maxTurnTimeoutMs = resolveMaxTurnTimeoutMs(functionMaxDurationSeconds);
885
900
  const modelId = validateGatewayModelId(env.AI_MODEL) ?? DEFAULT_MODEL_ID;
886
901
  const reasoningLevel = toOptionalTrimmed(env.AI_REASONING_LEVEL);
@@ -889,6 +904,7 @@ function readBotConfig(env, functionMaxDurationSeconds) {
889
904
  const handoffModelId = validateGatewayModelId(env.AI_HANDOFF_MODEL) ?? DEFAULT_HANDOFF_MODEL_ID;
890
905
  return {
891
906
  userName: toOptionalTrimmed(env.JUNIOR_BOT_NAME) ?? "junior",
907
+ defaultProfile: "standard",
892
908
  crossActorMidRunMode: parseCrossActorMidRunMode(
893
909
  env.JUNIOR_CROSS_ACTOR_MID_RUN_MODE
894
910
  ),
@@ -1021,6 +1037,23 @@ function getRuntimeMetadata() {
1021
1037
  version: toOptionalTrimmed(process.env.VERCEL_GIT_COMMIT_SHA)
1022
1038
  };
1023
1039
  }
1040
+ function setProfiles(profiles, defaultProfile) {
1041
+ if (!profiles || !defaultProfile) {
1042
+ throw new Error("profiles and defaultProfile must be configured together");
1043
+ }
1044
+ const configuredProfiles = parseProfileMap(profiles, "profiles");
1045
+ const selectedDefault = defaultProfile;
1046
+ if (!modelProfileSchema.safeParse(selectedDefault).success) {
1047
+ throw new Error(
1048
+ `defaultProfile "${selectedDefault}" must match ^[a-z][a-z0-9_-]*$`
1049
+ );
1050
+ }
1051
+ if (!Object.hasOwn(configuredProfiles, selectedDefault)) {
1052
+ throw new Error(`defaultProfile "${selectedDefault}" is not configured`);
1053
+ }
1054
+ botConfig.profiles = configuredProfiles;
1055
+ botConfig.defaultProfile = selectedDefault;
1056
+ }
1024
1057
  function getSlackReactionConfig() {
1025
1058
  return {
1026
1059
  completedReactionEmoji: chatConfig.slack.completedReactionEmoji,
@@ -1072,12 +1105,10 @@ export {
1072
1105
  embedTexts,
1073
1106
  normalizeSlackEmojiName,
1074
1107
  TURN_REASONING_LEVELS,
1075
- STANDARD_MODEL_PROFILE,
1076
- DEFAULT_HANDOFF_MODEL_PROFILE,
1077
1108
  modelProfileSchema,
1078
1109
  ModelProfileNotConfiguredError,
1079
1110
  modelIdForProfile,
1080
- standardModelId,
1111
+ defaultModelId,
1081
1112
  profileConfig,
1082
1113
  DEFAULT_SQL_STATEMENT_TIMEOUT_MS,
1083
1114
  FUNCTION_TIMEOUT_BUFFER_SECONDS,
@@ -1089,6 +1120,7 @@ export {
1089
1120
  getSlackClientId,
1090
1121
  getSlackClientSecret,
1091
1122
  getRuntimeMetadata,
1123
+ setProfiles,
1092
1124
  getSlackReactionConfig,
1093
1125
  setSlackReactionConfig
1094
1126
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createAndEnqueueAgentInvocation
3
- } from "./chunk-GPLAT6H7.js";
3
+ } from "./chunk-TC5DE5KJ.js";
4
4
  import {
5
5
  actorFromRun,
6
6
  toolInvocationDestination
@@ -18,16 +18,16 @@ function bindSpawnAgent(run, options) {
18
18
  const invocation = await createAndEnqueueAgentInvocation(
19
19
  {
20
20
  actor,
21
- ...input.name ? { agentName: input.name } : {},
22
- ...run.credentialContext ? { credentialContext: run.credentialContext } : {},
21
+ ...input.name ? { agentName: input.name } : void 0,
22
+ ...run.credentialContext ? { credentialContext: run.credentialContext } : void 0,
23
23
  destination: toolInvocationDestination(run),
24
24
  ...run.destinationVisibility ? {
25
25
  destinationVisibility: run.destinationVisibility
26
- } : {},
26
+ } : void 0,
27
27
  idempotencyKey: `${run.turnId}:${call.toolCallId}`,
28
28
  input: input.task,
29
29
  parentConversationId: run.conversationId,
30
- ...input.reasoningLevel ? { reasoningLevel: input.reasoningLevel } : {},
30
+ ...input.reasoningLevel ? { reasoningLevel: input.reasoningLevel } : void 0,
31
31
  source: run.source
32
32
  },
33
33
  { ...options, queue }