@sentry/junior 0.203.0 → 0.205.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 (174) hide show
  1. package/dist/agent-D4nu8MQV.js +17521 -0
  2. package/dist/agent-hooks-DXHpTJ4m.js +4042 -0
  3. package/dist/agent-runner-C04colea.js +678 -0
  4. package/dist/api/schema.d.ts +2736 -2639
  5. package/dist/api/schema.js +4 -169
  6. package/dist/api.d.ts +23 -17
  7. package/dist/api.js +3881 -5326
  8. package/dist/app-Cb776lL8.d.ts +247 -0
  9. package/dist/app.d.ts +4 -520
  10. package/dist/app.js +9524 -11875
  11. package/dist/auth-pause-state-C2P3guS1.js +168 -0
  12. package/dist/catalog-runtime-CXw3asJD.js +7 -0
  13. package/dist/checkpoint-CrViJ8Ps.js +2450 -0
  14. package/dist/cli/chat.d.ts +20 -0
  15. package/dist/cli/chat.js +229 -336
  16. package/dist/cli/check.d.ts +8 -0
  17. package/dist/cli/check.js +513 -806
  18. package/dist/cli/env.d.ts +13 -0
  19. package/dist/cli/env.js +63 -12
  20. package/dist/cli/init.d.ts +3 -0
  21. package/dist/cli/init.js +90 -159
  22. package/dist/cli/main.d.ts +6 -0
  23. package/dist/cli/main.js +43 -64
  24. package/dist/cli/plugins.d.ts +13 -0
  25. package/dist/cli/plugins.js +148 -227
  26. package/dist/cli/run.d.ts +16 -0
  27. package/dist/cli/run.js +52 -8
  28. package/dist/cli/snapshot-create.d.ts +4 -0
  29. package/dist/cli/snapshot-create.js +71 -125
  30. package/dist/cli/upgrade.d.ts +15 -0
  31. package/dist/cli/upgrade.js +232 -335
  32. package/dist/config-BOtJQ7Pc.js +941 -0
  33. package/dist/context-B45_WqVX.js +298 -0
  34. package/dist/conversation-privacy-BZRA6Pes.js +182 -0
  35. package/dist/conversation-work-C6y3T5Hx.js +51 -0
  36. package/dist/credential-sync-Bep34IB_.js +2661 -0
  37. package/dist/db-BeyXKJOI.d.ts +5 -0
  38. package/dist/destinations-BeBiJeEM.js +29 -0
  39. package/dist/execution-stats-B6lgWxCK.js +373 -0
  40. package/dist/executor-BlUhFL7_.js +721 -0
  41. package/dist/experimental-CIXf7Uye.js +46 -0
  42. package/dist/history-ClE4toxe.d.ts +32 -0
  43. package/dist/history-CqTuSAdI.js +441 -0
  44. package/dist/instrumentation.d.ts +3 -3
  45. package/dist/instrumentation.js +130 -176
  46. package/dist/job-queue-DLMqIK74.js +63 -0
  47. package/dist/logging-BMJzdDlP.js +1210 -0
  48. package/dist/model-profile-CZmVoGdX.js +49 -0
  49. package/dist/nitro.d.ts +31 -36
  50. package/dist/nitro.js +275 -456
  51. package/dist/oauth-callback-server-WwG5_Zgm.js +130 -0
  52. package/dist/oauth-relay-CdCnu80W.js +62 -0
  53. package/dist/package-discovery-7a9YqLhE.js +455 -0
  54. package/dist/pending-auth-CUbXq06G.js +185 -0
  55. package/dist/plugin-module-BKGOXca2.js +81 -0
  56. package/dist/plugins-BI9A1vKA.d.ts +95 -0
  57. package/dist/plugins-egKWjgue.js +99 -0
  58. package/dist/private-trace-result-BLvBjy_e.js +16 -0
  59. package/dist/profile-T0tXE4zu.js +861 -0
  60. package/dist/registry-BA0__8ai.js +1419 -0
  61. package/dist/reporting-schema-DosTN__Q.js +105 -0
  62. package/dist/resolve-bvD1ORdv.js +546 -0
  63. package/dist/rolldown-runtime-B4FMCO8f.js +28 -0
  64. package/dist/runner-BXYxfIUL.js +392 -0
  65. package/dist/sandbox-egress-signals-ngEPjSEW.js +46 -0
  66. package/dist/schema-Rn8-XEaN.js +1140 -0
  67. package/dist/sentry-CD3SdJl-.js +26 -0
  68. package/dist/skills-DJOlYdBs.js +316 -0
  69. package/dist/spawn-h0R1bTEo.js +29 -0
  70. package/dist/stats-3YZn-Swi.js +2648 -0
  71. package/dist/store-C5qxF2ac.d.ts +208 -0
  72. package/dist/task-queue-CoXwd2eq.js +136 -0
  73. package/dist/task-runner-B2_mJZj0.js +639 -0
  74. package/dist/thread-state-CqZ1m-es.js +431 -0
  75. package/dist/turn-execution-fI6PZ0iI.js +47 -0
  76. package/dist/turn-lifecycle-CcnwrOcp.js +54 -0
  77. package/dist/usage-B5SfMb3H.js +296 -0
  78. package/dist/usage-schema-CKaDkH_j.js +20 -0
  79. package/dist/validation-DfWcvhuS.js +40 -0
  80. package/dist/vercel-queue-DIkVcfK4.js +167 -0
  81. package/dist/vercel.d.ts +6 -6
  82. package/dist/vercel.js +14 -6
  83. package/dist/version-CnXZ614E.d.ts +5 -0
  84. package/dist/version-oD-oPrbO.js +8 -0
  85. package/dist/version.d.ts +2 -4
  86. package/dist/version.js +2 -6
  87. package/dist/web-authorization-Crbzlmzo.js +76 -0
  88. package/dist/web-input-BOuq3oKK.js +494 -0
  89. package/dist/work-B91LQKHr.js +509 -0
  90. package/dist/worker-BcRRTe6k.js +625 -0
  91. package/package.json +9 -9
  92. package/dist/agent-hooks-GB2VPTNA.js +0 -51
  93. package/dist/catalog-runtime-UBLIWD3O.js +0 -14
  94. package/dist/chunk-2LYHWMR4.js +0 -46
  95. package/dist/chunk-352OWAZH.js +0 -320
  96. package/dist/chunk-3Y47VMHV.js +0 -6
  97. package/dist/chunk-3YJSKOWF.js +0 -164
  98. package/dist/chunk-4KSSKTQ5.js +0 -229
  99. package/dist/chunk-4UO6FK4G.js +0 -64
  100. package/dist/chunk-5AHX53NQ.js +0 -717
  101. package/dist/chunk-5J3E5FWA.js +0 -700
  102. package/dist/chunk-5PDAG6O3.js +0 -206
  103. package/dist/chunk-6Y5B5PEX.js +0 -80
  104. package/dist/chunk-7GWQ5S5R.js +0 -2086
  105. package/dist/chunk-7H2VZTWN.js +0 -103
  106. package/dist/chunk-7NL7T6VU.js +0 -406
  107. package/dist/chunk-A5L27LE4.js +0 -387
  108. package/dist/chunk-ADIAWL34.js +0 -81
  109. package/dist/chunk-ASTEMBKJ.js +0 -519
  110. package/dist/chunk-CEMMLV5L.js +0 -98
  111. package/dist/chunk-CM5HNV2W.js +0 -131
  112. package/dist/chunk-CRTRBBRI.js +0 -105
  113. package/dist/chunk-DA2KGZZI.js +0 -13
  114. package/dist/chunk-DIB4GX3G.js +0 -8
  115. package/dist/chunk-DKIJ2RP5.js +0 -68
  116. package/dist/chunk-DWPN6SCH.js +0 -172
  117. package/dist/chunk-EDKUFGPL.js +0 -64
  118. package/dist/chunk-ENY6SKIU.js +0 -1228
  119. package/dist/chunk-F4MGCZOX.js +0 -2943
  120. package/dist/chunk-FA6POGLH.js +0 -70
  121. package/dist/chunk-FSUR7GTG.js +0 -20475
  122. package/dist/chunk-GKEOHJL5.js +0 -1856
  123. package/dist/chunk-GMCB6W5Y.js +0 -333
  124. package/dist/chunk-IE2VPG7O.js +0 -1135
  125. package/dist/chunk-IZ5B5IHQ.js +0 -3656
  126. package/dist/chunk-JAL3CH4G.js +0 -27
  127. package/dist/chunk-KIIEUXD3.js +0 -1764
  128. package/dist/chunk-KXU4NIL7.js +0 -692
  129. package/dist/chunk-MTM5IFCY.js +0 -1190
  130. package/dist/chunk-N7TMSOZH.js +0 -235
  131. package/dist/chunk-NCEBK6PH.js +0 -36
  132. package/dist/chunk-NHJU2ZAL.js +0 -56
  133. package/dist/chunk-P6KTRNVC.js +0 -321
  134. package/dist/chunk-PDO5BLNM.js +0 -22
  135. package/dist/chunk-PDRNLLFT.js +0 -3295
  136. package/dist/chunk-PEQXYSSE.js +0 -45
  137. package/dist/chunk-PKEX2AQX.js +0 -198
  138. package/dist/chunk-PSJCGIGO.js +0 -1163
  139. package/dist/chunk-PZUSUL55.js +0 -506
  140. package/dist/chunk-R45M4TUS.js +0 -37
  141. package/dist/chunk-RC745GGZ.js +0 -122
  142. package/dist/chunk-SP3QKZXJ.js +0 -820
  143. package/dist/chunk-TXKUKMVO.js +0 -417
  144. package/dist/chunk-UE4GPWSD.js +0 -931
  145. package/dist/chunk-UIE3R5XU.js +0 -17
  146. package/dist/chunk-UXPG6ZIN.js +0 -84
  147. package/dist/chunk-VFUK3X5B.js +0 -50
  148. package/dist/chunk-VNMJWREK.js +0 -787
  149. package/dist/chunk-VZ7CSOX2.js +0 -706
  150. package/dist/chunk-WCNQJKFT.js +0 -10
  151. package/dist/chunk-WDZR3QQM.js +0 -135
  152. package/dist/chunk-WLYVJCHV.js +0 -1433
  153. package/dist/chunk-WS7NAFTM.js +0 -1520
  154. package/dist/chunk-X6GDDWQH.js +0 -60
  155. package/dist/chunk-XPDEYNQI.js +0 -102
  156. package/dist/chunk-XRW44VGM.js +0 -58
  157. package/dist/chunk-Y2CM7HXH.js +0 -111
  158. package/dist/chunk-Y7X25LFY.js +0 -15
  159. package/dist/conversation-work-VIOQ5ZF3.js +0 -54
  160. package/dist/db-NGDJV7YH.js +0 -26
  161. package/dist/discovery-DWVDM7UK.js +0 -44
  162. package/dist/experimental-P5FZM4CU.js +0 -12
  163. package/dist/oauth-callback-server-YFY7YEGK.js +0 -243
  164. package/dist/oauth-relay-5XPVRPYB.js +0 -8
  165. package/dist/plugins-YTYJMMJF.js +0 -14
  166. package/dist/runner-ORTNSB2Q.js +0 -522
  167. package/dist/sandbox-egress-signals-FIL7EGPR.js +0 -73
  168. package/dist/sentry-MB3NL3IR.js +0 -42
  169. package/dist/skills-H376WQOH.js +0 -27
  170. package/dist/spawn-T43WHLOS.js +0 -42
  171. package/dist/task-runner-LBZWF32V.js +0 -36
  172. package/dist/validation-REJLRKI6.js +0 -17
  173. package/dist/work-3KJ3RE76.js +0 -51
  174. package/dist/worker-QFEBU72E.js +0 -24
@@ -1,522 +0,0 @@
1
- import {
2
- buildDeliveredTurnStatePatch,
3
- completeAuthPauseTurn,
4
- finalizeFailedTurnReplyWithEvent
5
- } from "./chunk-4KSSKTQ5.js";
6
- import {
7
- processPluginTask,
8
- scheduleSessionCompletedPluginTasks
9
- } from "./chunk-SP3QKZXJ.js";
10
- import {
11
- ConversationTurnLifecycleService
12
- } from "./chunk-EDKUFGPL.js";
13
- import {
14
- coerceThreadConversationState,
15
- getPersistedSandboxState,
16
- getPersistedThreadState,
17
- persistThreadStateById
18
- } from "./chunk-ASTEMBKJ.js";
19
- import "./chunk-PZUSUL55.js";
20
- import "./chunk-3YJSKOWF.js";
21
- import {
22
- authorizationId
23
- } from "./chunk-DIB4GX3G.js";
24
- import {
25
- getAssistantReplyText,
26
- markTurnFailed,
27
- startActiveTurn
28
- } from "./chunk-5PDAG6O3.js";
29
- import {
30
- buildConversationContext,
31
- commitAcceptedReply,
32
- hydrateConversationMessages,
33
- loadProjection,
34
- markConversationMessage,
35
- normalizeConversationText,
36
- persistConversationMessages,
37
- persistWithRetry,
38
- recordAuthorizationCompleted,
39
- recordDeliveredAssistantMessage,
40
- saveTurnCheckpoint,
41
- stripRuntimeTurnContext,
42
- upsertConversationMessage
43
- } from "./chunk-F4MGCZOX.js";
44
- import "./chunk-DA2KGZZI.js";
45
- import "./chunk-GMCB6W5Y.js";
46
- import "./chunk-PDO5BLNM.js";
47
- import "./chunk-NCEBK6PH.js";
48
- import "./chunk-7H2VZTWN.js";
49
- import "./chunk-IZ5B5IHQ.js";
50
- import "./chunk-3Y47VMHV.js";
51
- import {
52
- getConversationEventStore,
53
- getConversationStore
54
- } from "./chunk-GKEOHJL5.js";
55
- import "./chunk-IE2VPG7O.js";
56
- import "./chunk-5AHX53NQ.js";
57
- import "./chunk-P6KTRNVC.js";
58
- import "./chunk-7NL7T6VU.js";
59
- import "./chunk-VFUK3X5B.js";
60
- import "./chunk-ENY6SKIU.js";
61
- import "./chunk-NHJU2ZAL.js";
62
- import "./chunk-PKEX2AQX.js";
63
- import "./chunk-WCNQJKFT.js";
64
- import "./chunk-7GWQ5S5R.js";
65
- import {
66
- credentialContextForActor
67
- } from "./chunk-CEMMLV5L.js";
68
- import "./chunk-N7TMSOZH.js";
69
- import "./chunk-DWPN6SCH.js";
70
- import "./chunk-TXKUKMVO.js";
71
- import {
72
- logException,
73
- setTags,
74
- withLogContext
75
- } from "./chunk-WS7NAFTM.js";
76
- import "./chunk-PEQXYSSE.js";
77
- import "./chunk-WDZR3QQM.js";
78
-
79
- // src/chat/local/runner.ts
80
- import { randomUUID } from "crypto";
81
- import {
82
- createLocalSource,
83
- localDestinationSchema
84
- } from "@sentry/junior-plugin-api";
85
- var SENTRY_EVENT_ID_PATTERN = /^[a-f0-9]{32}$/i;
86
- var LOCAL_FAILURE_EVENT_NAMES = {
87
- agent_run_failed: "local.agent_run.failed",
88
- delivery_failed: "local.reply.delivery.failed",
89
- model_execution_failed: "local.model.execution.failed",
90
- persistence_failed: "local.turn.persistence.failed"
91
- };
92
- function localDestination(conversationId) {
93
- const parsed = localDestinationSchema.safeParse({
94
- platform: "local",
95
- conversationId
96
- });
97
- if (!parsed.success) {
98
- throw new Error("Invalid local conversation id");
99
- }
100
- return parsed.data;
101
- }
102
- function localTurnId() {
103
- return `local-turn-${randomUUID()}`;
104
- }
105
- function localRunId() {
106
- return `local-run-${randomUUID()}`;
107
- }
108
- function captureLocalBoundaryFailure(args) {
109
- setTags({
110
- conversationId: args.conversationId,
111
- ...args.runId ? { runId: args.runId } : void 0
112
- });
113
- const eventId = args.capture(
114
- args.error,
115
- LOCAL_FAILURE_EVENT_NAMES[args.failureCode],
116
- { "app.ai.failure_code": args.failureCode }
117
- );
118
- return eventId && SENTRY_EVENT_ID_PATTERN.test(eventId) ? eventId : void 0;
119
- }
120
- async function loadLocalPiMessages(args) {
121
- const projection = await loadProjection({
122
- conversationId: args.conversationId
123
- });
124
- if (projection.length === 0) {
125
- return void 0;
126
- }
127
- return stripRuntimeTurnContext(projection);
128
- }
129
- async function runLocalAgentTurn(input, deps) {
130
- return withLogContext(
131
- {
132
- conversationId: input.conversationId,
133
- destinationName: input.conversationId,
134
- messageConversationId: input.conversationId,
135
- platform: "local",
136
- userId: "local-cli",
137
- userName: "local"
138
- },
139
- () => runLocalAgentTurnInContext(input, deps)
140
- );
141
- }
142
- async function runLocalAgentTurnInContext(input, deps) {
143
- const text = input.message.trim();
144
- if (!text) {
145
- throw new Error("Local agent message must not be empty");
146
- }
147
- const destination = localDestination(input.conversationId);
148
- const source = createLocalSource(destination.conversationId);
149
- const lifecycle = new ConversationTurnLifecycleService(
150
- getConversationEventStore()
151
- );
152
- await getConversationStore().recordActivity({
153
- conversationId: input.conversationId,
154
- destination,
155
- nowMs: Date.now(),
156
- source: "local",
157
- visibility: "private"
158
- });
159
- const persisted = await getPersistedThreadState(input.conversationId);
160
- const conversation = coerceThreadConversationState(persisted);
161
- await hydrateConversationMessages({
162
- conversation,
163
- conversationId: input.conversationId
164
- });
165
- let sandboxRef = getPersistedSandboxState(persisted);
166
- const initialSandboxRef = sandboxRef;
167
- const turnId = localTurnId();
168
- const userMessageId = `${turnId}:user`;
169
- const startedAtMs = Date.now();
170
- upsertConversationMessage(conversation, {
171
- id: userMessageId,
172
- role: "user",
173
- text: normalizeConversationText(text),
174
- createdAtMs: startedAtMs,
175
- author: {
176
- fullName: "Local CLI",
177
- userId: "local-cli",
178
- userName: "local"
179
- },
180
- meta: {
181
- explicitMention: true,
182
- replied: false
183
- }
184
- });
185
- await persistConversationMessages({
186
- conversation,
187
- conversationId: input.conversationId
188
- });
189
- await lifecycle.start({
190
- conversationId: input.conversationId,
191
- createdAtMs: Date.now(),
192
- inputMessageIds: [userMessageId],
193
- surface: "internal",
194
- turnId
195
- });
196
- startActiveTurn({
197
- conversation,
198
- nextTurnId: turnId
199
- });
200
- let reply;
201
- let completedState;
202
- let failureCode = "persistence_failed";
203
- let modelFailureEventId;
204
- let modelFailureReason;
205
- let modelFailureCaptureAttempted = false;
206
- let currentRunId;
207
- let completionSliceId = 1;
208
- const localActor = {
209
- fullName: "Local CLI",
210
- platform: "local",
211
- userId: "local-cli",
212
- userName: "local"
213
- };
214
- let assistantMessageDelivered = false;
215
- const deliverAssistantMessage = async (reply2) => {
216
- const message = typeof reply2 === "string" ? void 0 : reply2;
217
- const text2 = typeof reply2 === "string" ? reply2 : getAssistantReplyText(reply2);
218
- if (!text2?.trim()) {
219
- return;
220
- }
221
- failureCode = "delivery_failed";
222
- await deps.deliverReply({ text: text2 });
223
- assistantMessageDelivered = true;
224
- const recordedMessageId = recordDeliveredAssistantMessage({
225
- conversation,
226
- sessionId: turnId,
227
- text: text2,
228
- userMessageId
229
- });
230
- try {
231
- await persistWithRetry(
232
- () => message ? commitAcceptedReply({
233
- agentMessage: message,
234
- conversation,
235
- conversationMessageId: recordedMessageId,
236
- conversationId: input.conversationId
237
- }) : persistConversationMessages({
238
- conversation,
239
- conversationId: input.conversationId
240
- })
241
- );
242
- } catch (error) {
243
- logException(
244
- new Error("Accepted assistant message persistence failed"),
245
- "local.assistant.message_post_delivery_persist.failed",
246
- { "error.type": error instanceof Error ? error.name : typeof error }
247
- );
248
- }
249
- failureCode = "agent_run_failed";
250
- };
251
- try {
252
- await persistThreadStateById(input.conversationId, { conversation });
253
- const piMessages = await loadLocalPiMessages({
254
- conversationId: input.conversationId
255
- });
256
- failureCode = "agent_run_failed";
257
- const runAgent = async (messages) => {
258
- currentRunId = localRunId();
259
- setTags({ runId: currentRunId });
260
- const authorization = deps.authorization ? {
261
- createState: deps.authorization.createState,
262
- deliver: deps.authorization.deliver
263
- } : void 0;
264
- return await deps.agentRunner.run({
265
- conversationId: input.conversationId,
266
- turnId,
267
- runId: currentRunId,
268
- instruction: {
269
- text,
270
- context: buildConversationContext(conversation, {
271
- excludeMessageId: userMessageId
272
- })
273
- },
274
- history: messages,
275
- actor: localActor,
276
- credentialContext: credentialContextForActor(localActor),
277
- destination,
278
- source,
279
- surface: "internal",
280
- authorization,
281
- ...deps.authorization ? void 0 : { disabledFeatures: ["interactive-auth"] },
282
- environment: {
283
- sandboxEgressSignals: deps.sandboxEgressSignals
284
- },
285
- state: {
286
- pendingAuth: conversation.processing.pendingAuth,
287
- sandboxRef
288
- },
289
- onEvent: async (event) => {
290
- if (event.type === "status") {
291
- await deps.onStatus?.(event.text);
292
- return;
293
- }
294
- if (event.type === "tool_started") {
295
- await deps.onToolInvocation?.({
296
- params: event.params,
297
- toolName: event.toolName
298
- });
299
- return;
300
- }
301
- if (event.type === "tool_finished") {
302
- await deps.onToolResult?.(event.report);
303
- }
304
- },
305
- delivery: deliverAssistantMessage,
306
- durability: {
307
- onSandboxRefChanged: async (nextSandboxRef) => {
308
- sandboxRef = nextSandboxRef;
309
- await persistThreadStateById(input.conversationId, {
310
- conversation,
311
- sandboxRef
312
- });
313
- },
314
- recordPendingAuth: async (pendingAuth) => {
315
- conversation.processing.pendingAuth = pendingAuth;
316
- await persistThreadStateById(input.conversationId, {
317
- conversation,
318
- sandboxRef
319
- });
320
- }
321
- }
322
- });
323
- };
324
- let outcome = await runAgent(piMessages);
325
- while (outcome.status === "awaiting_auth") {
326
- const pendingAuth = conversation.processing.pendingAuth;
327
- if (!pendingAuth || !deps.authorization) {
328
- throw new Error(
329
- "Local OAuth requires an active callback server and authorization delivery."
330
- );
331
- }
332
- completeAuthPauseTurn({ conversation, sessionId: turnId });
333
- await persistThreadStateById(input.conversationId, {
334
- conversation,
335
- sandboxRef
336
- });
337
- await deps.authorization.wait();
338
- await recordAuthorizationCompleted({
339
- conversationId: input.conversationId,
340
- kind: pendingAuth.kind,
341
- provider: pendingAuth.provider,
342
- actorId: pendingAuth.actorId,
343
- authorizationId: authorizationId({
344
- sessionId: turnId,
345
- kind: pendingAuth.kind,
346
- provider: pendingAuth.provider
347
- })
348
- });
349
- completionSliceId += 1;
350
- outcome = await runAgent(
351
- await loadLocalPiMessages({
352
- conversationId: input.conversationId
353
- })
354
- );
355
- }
356
- if (outcome.status !== "completed") {
357
- throw new Error(`Local agent run ended with ${outcome.status}`);
358
- }
359
- reply = outcome.result;
360
- modelFailureCaptureAttempted = reply.diagnostics.outcome !== "success";
361
- const finalized = finalizeFailedTurnReplyWithEvent({
362
- reply,
363
- logException
364
- });
365
- reply = finalized.reply;
366
- modelFailureEventId = finalized.eventId;
367
- modelFailureReason = finalized.failureReason;
368
- if (reply.diagnostics.outcome !== "success") {
369
- await deliverAssistantMessage(reply.text);
370
- }
371
- completedState = buildDeliveredTurnStatePatch({
372
- conversation,
373
- reply,
374
- sessionId: turnId,
375
- userMessageId
376
- });
377
- } catch (error) {
378
- deps.authorization?.cancel();
379
- const failureEventId = modelFailureCaptureAttempted && failureCode === "agent_run_failed" ? modelFailureEventId : captureLocalBoundaryFailure({
380
- capture: logException,
381
- conversationId: input.conversationId,
382
- error,
383
- failureCode,
384
- runId: currentRunId
385
- });
386
- try {
387
- markTurnFailed({
388
- conversation,
389
- nowMs: Date.now(),
390
- sessionId: turnId,
391
- userMessageId,
392
- markConversationMessage
393
- });
394
- await persistThreadStateById(input.conversationId, {
395
- conversation,
396
- sandboxRef: initialSandboxRef ?? null
397
- });
398
- } catch (persistenceError) {
399
- const persistenceEventId = captureLocalBoundaryFailure({
400
- capture: logException,
401
- conversationId: input.conversationId,
402
- error: persistenceError,
403
- failureCode: "persistence_failed",
404
- runId: currentRunId
405
- });
406
- await lifecycle.fail({
407
- conversationId: input.conversationId,
408
- createdAtMs: Date.now(),
409
- ...persistenceEventId ? { eventId: persistenceEventId } : void 0,
410
- failureCode: "persistence_failed",
411
- turnId
412
- });
413
- throw new AggregateError(
414
- [error, persistenceError],
415
- "Local turn failure state could not be persisted"
416
- );
417
- }
418
- await lifecycle.fail({
419
- conversationId: input.conversationId,
420
- createdAtMs: Date.now(),
421
- ...failureEventId ? { eventId: failureEventId } : void 0,
422
- failureCode,
423
- turnId
424
- });
425
- throw error;
426
- }
427
- deps.authorization?.cancel();
428
- try {
429
- await persistThreadStateById(input.conversationId, {
430
- conversation: completedState.conversation,
431
- sandboxRef: reply.sandboxRef ?? sandboxRef
432
- });
433
- if (reply.piMessages?.length) {
434
- await saveTurnCheckpoint({
435
- mode: "completed",
436
- conversationId: input.conversationId,
437
- turnId,
438
- sliceId: completionSliceId,
439
- messages: reply.piMessages,
440
- durationMs: reply.diagnostics.durationMs,
441
- usage: reply.diagnostics.usage,
442
- destination,
443
- source,
444
- actor: localActor,
445
- surface: "internal"
446
- });
447
- }
448
- } catch (error) {
449
- const persistenceEventId = captureLocalBoundaryFailure({
450
- capture: logException,
451
- conversationId: input.conversationId,
452
- error,
453
- failureCode: "persistence_failed",
454
- runId: currentRunId
455
- });
456
- await lifecycle.fail({
457
- conversationId: input.conversationId,
458
- createdAtMs: Date.now(),
459
- ...persistenceEventId ? { eventId: persistenceEventId } : void 0,
460
- failureCode: "persistence_failed",
461
- turnId
462
- });
463
- throw error;
464
- }
465
- if (reply.diagnostics.outcome === "success") {
466
- await lifecycle.complete({
467
- conversationId: input.conversationId,
468
- createdAtMs: Date.now(),
469
- outcome: assistantMessageDelivered ? "success" : "no_reply",
470
- turnId
471
- });
472
- } else {
473
- await lifecycle.fail({
474
- conversationId: input.conversationId,
475
- createdAtMs: Date.now(),
476
- ...modelFailureEventId ? { eventId: modelFailureEventId } : void 0,
477
- failureCode: "model_execution_failed",
478
- ...modelFailureReason ? { failureReason: modelFailureReason } : void 0,
479
- turnId
480
- });
481
- }
482
- if (reply.diagnostics.outcome === "success") {
483
- try {
484
- await scheduleSessionCompletedPluginTasks(
485
- {
486
- conversationId: input.conversationId,
487
- sessionId: turnId
488
- },
489
- {
490
- send: async (message) => {
491
- try {
492
- await processPluginTask(message);
493
- } catch (error) {
494
- logException(
495
- error,
496
- "local.plugin.session_completion_task.failed",
497
- {
498
- conversationId: input.conversationId,
499
- pluginName: message.plugin,
500
- taskName: message.name,
501
- turnId
502
- }
503
- );
504
- }
505
- }
506
- }
507
- );
508
- } catch (error) {
509
- logException(error, "local.plugin.session_completion_task.failed", {
510
- conversationId: input.conversationId,
511
- turnId
512
- });
513
- }
514
- }
515
- return {
516
- conversationId: input.conversationId,
517
- outcome: reply.diagnostics.outcome
518
- };
519
- }
520
- export {
521
- runLocalAgentTurn
522
- };
@@ -1,73 +0,0 @@
1
- import {
2
- sandboxEgressSignalsResponseSchema
3
- } from "./chunk-6Y5B5PEX.js";
4
- import "./chunk-CEMMLV5L.js";
5
- import "./chunk-N7TMSOZH.js";
6
-
7
- // src/chat/local/sandbox-egress-signals.ts
8
- var SANDBOX_EGRESS_SIGNALS_PATH = "/api/internal/sandbox-egress/signals";
9
- var LOCAL_DEV_SERVER_TIMEOUT_MS = 1e3;
10
- function signalRequest(baseUrl, credentialToken) {
11
- return {
12
- headers: {
13
- "x-junior-sandbox-egress-token": credentialToken
14
- },
15
- url: `${baseUrl}${SANDBOX_EGRESS_SIGNALS_PATH}`
16
- };
17
- }
18
- async function requestLocalDevServer(request, init) {
19
- try {
20
- return await fetch(request.url, {
21
- ...init,
22
- headers: request.headers,
23
- signal: AbortSignal.timeout(LOCAL_DEV_SERVER_TIMEOUT_MS)
24
- });
25
- } catch {
26
- return void 0;
27
- }
28
- }
29
- function createLocalSandboxEgressSignalTransport(baseUrl) {
30
- return {
31
- clear: async (credentialToken) => {
32
- const request = signalRequest(baseUrl, credentialToken);
33
- const response = await requestLocalDevServer(request, {
34
- method: "DELETE"
35
- });
36
- if (!response) {
37
- return;
38
- }
39
- if (!response.ok) {
40
- throw new Error(
41
- `Could not clear dev-server sandbox egress signals: HTTP ${response.status}`
42
- );
43
- }
44
- },
45
- consume: async (credentialToken) => {
46
- const request = signalRequest(baseUrl, credentialToken);
47
- const response = await requestLocalDevServer(request);
48
- if (!response) {
49
- return {};
50
- }
51
- if (!response.ok) {
52
- throw new Error(
53
- `Could not consume dev-server sandbox egress signals: HTTP ${response.status}`
54
- );
55
- }
56
- const value = sandboxEgressSignalsResponseSchema.safeParse(
57
- await response.json()
58
- );
59
- if (!value.success) {
60
- throw new Error("Dev-server sandbox egress signals were invalid");
61
- }
62
- const authRequired = value.data.auth_required;
63
- const permissionDenied = value.data.permission_denied;
64
- return {
65
- ...authRequired ? { authRequired } : void 0,
66
- ...permissionDenied ? { permissionDenied } : void 0
67
- };
68
- }
69
- };
70
- }
71
- export {
72
- createLocalSandboxEgressSignalTransport
73
- };
@@ -1,42 +0,0 @@
1
- import {
2
- captureException,
3
- captureMessage,
4
- continueTrace,
5
- flush,
6
- getActiveSpan,
7
- getClient,
8
- getGlobalScope,
9
- getTraceData,
10
- init,
11
- logger,
12
- setTag,
13
- setUser,
14
- spanToJSON,
15
- startInactiveSpan,
16
- startSpan,
17
- vercelAIIntegration,
18
- withActiveSpan,
19
- withScope,
20
- withStreamedSpan
21
- } from "./chunk-PEQXYSSE.js";
22
- export {
23
- captureException,
24
- captureMessage,
25
- continueTrace,
26
- flush,
27
- getActiveSpan,
28
- getClient,
29
- getGlobalScope,
30
- getTraceData,
31
- init,
32
- logger,
33
- setTag,
34
- setUser,
35
- spanToJSON,
36
- startInactiveSpan,
37
- startSpan,
38
- vercelAIIntegration,
39
- withActiveSpan,
40
- withScope,
41
- withStreamedSpan
42
- };
@@ -1,27 +0,0 @@
1
- import {
2
- discoverSkills,
3
- findSkillByName,
4
- loadSkillsByName,
5
- parseSkillFile,
6
- parseSkillInvocation,
7
- resetSkillDiscoveryCache,
8
- stripFrontmatter
9
- } from "./chunk-A5L27LE4.js";
10
- import "./chunk-WCNQJKFT.js";
11
- import "./chunk-7GWQ5S5R.js";
12
- import "./chunk-CEMMLV5L.js";
13
- import "./chunk-N7TMSOZH.js";
14
- import "./chunk-DWPN6SCH.js";
15
- import "./chunk-TXKUKMVO.js";
16
- import "./chunk-WS7NAFTM.js";
17
- import "./chunk-PEQXYSSE.js";
18
- import "./chunk-WDZR3QQM.js";
19
- export {
20
- discoverSkills,
21
- findSkillByName,
22
- loadSkillsByName,
23
- parseSkillFile,
24
- parseSkillInvocation,
25
- resetSkillDiscoveryCache,
26
- stripFrontmatter
27
- };
@@ -1,42 +0,0 @@
1
- import {
2
- bindSpawnAgent
3
- } from "./chunk-R45M4TUS.js";
4
- import "./chunk-KXU4NIL7.js";
5
- import "./chunk-XRW44VGM.js";
6
- import "./chunk-EDKUFGPL.js";
7
- import "./chunk-ASTEMBKJ.js";
8
- import "./chunk-352OWAZH.js";
9
- import "./chunk-6Y5B5PEX.js";
10
- import "./chunk-DIB4GX3G.js";
11
- import "./chunk-UE4GPWSD.js";
12
- import "./chunk-5PDAG6O3.js";
13
- import "./chunk-F4MGCZOX.js";
14
- import "./chunk-2LYHWMR4.js";
15
- import "./chunk-KIIEUXD3.js";
16
- import "./chunk-DA2KGZZI.js";
17
- import "./chunk-GMCB6W5Y.js";
18
- import "./chunk-PDO5BLNM.js";
19
- import "./chunk-JAL3CH4G.js";
20
- import "./chunk-IZ5B5IHQ.js";
21
- import "./chunk-3Y47VMHV.js";
22
- import "./chunk-GKEOHJL5.js";
23
- import "./chunk-IE2VPG7O.js";
24
- import "./chunk-5AHX53NQ.js";
25
- import "./chunk-P6KTRNVC.js";
26
- import "./chunk-7NL7T6VU.js";
27
- import "./chunk-VFUK3X5B.js";
28
- import "./chunk-ENY6SKIU.js";
29
- import "./chunk-NHJU2ZAL.js";
30
- import "./chunk-PKEX2AQX.js";
31
- import "./chunk-WCNQJKFT.js";
32
- import "./chunk-7GWQ5S5R.js";
33
- import "./chunk-CEMMLV5L.js";
34
- import "./chunk-N7TMSOZH.js";
35
- import "./chunk-DWPN6SCH.js";
36
- import "./chunk-TXKUKMVO.js";
37
- import "./chunk-WS7NAFTM.js";
38
- import "./chunk-PEQXYSSE.js";
39
- import "./chunk-WDZR3QQM.js";
40
- export {
41
- bindSpawnAgent
42
- };