@sentry/junior 0.153.0 → 0.155.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 (83) hide show
  1. package/dist/{agent-hooks-7BWOB7SN.js → agent-hooks-AWVTLAV2.js} +11 -12
  2. package/dist/api/conversations/list.d.ts +5 -3
  3. package/dist/api/conversations/membership.d.ts +16 -0
  4. package/dist/api/locations/detail.d.ts +1 -0
  5. package/dist/api/schema/conversation.d.ts +3 -0
  6. package/dist/api/schema/location.d.ts +1 -0
  7. package/dist/api/schema/person.d.ts +1 -0
  8. package/dist/api/schema.js +1 -1
  9. package/dist/api.js +318 -187
  10. package/dist/app.js +39 -39
  11. package/dist/catalog-runtime-V6YD6KH5.js +16 -0
  12. package/dist/chat/conversations/sql/event-actor.d.ts +14 -0
  13. package/dist/chat/conversations/sql/event-lock.d.ts +1 -1
  14. package/dist/chat/conversations/sql/participants.d.ts +17 -0
  15. package/dist/chat/plugins/unfinished-work.d.ts +2 -0
  16. package/dist/chat/runtime/agent-runner.d.ts +2 -0
  17. package/dist/chat/runtime/slack-resume.d.ts +1 -1
  18. package/dist/chat/state/conversation.d.ts +1 -0
  19. package/dist/{chunk-O2YXWWPM.js → chunk-2AHVM3HK.js} +92 -9
  20. package/dist/{chunk-VXWTGOLW.js → chunk-2WLJDM23.js} +1 -1
  21. package/dist/{chunk-4TWLKHOM.js → chunk-37G5HJ2X.js} +4 -4
  22. package/dist/{chunk-ISEROVYZ.js → chunk-4K5N6HTX.js} +5 -5
  23. package/dist/{chunk-ET54Q4TD.js → chunk-773XC7P4.js} +116 -82
  24. package/dist/{chunk-HUO3UTAQ.js → chunk-7MA4HV4W.js} +1 -1
  25. package/dist/{chunk-HMU2QP5M.js → chunk-7NYEB2TM.js} +1 -1
  26. package/dist/{chunk-URFV5RWN.js → chunk-AENPRXCG.js} +23 -56
  27. package/dist/{chunk-TIV3PX5H.js → chunk-APHDJYN7.js} +2 -2
  28. package/dist/{chunk-RUIXF3YQ.js → chunk-BDUENQD3.js} +1 -1
  29. package/dist/{chunk-5TXDKTET.js → chunk-CPQBTTI6.js} +7 -7
  30. package/dist/{chunk-A5SROS6H.js → chunk-ELOTIL5F.js} +5 -5
  31. package/dist/{chunk-JJAMURMR.js → chunk-EORR34UB.js} +1 -1
  32. package/dist/{chunk-5QBK3QHJ.js → chunk-J2SYI36O.js} +6 -8
  33. package/dist/{chunk-K4LK6KYO.js → chunk-J7MWZFFP.js} +4 -4
  34. package/dist/{chunk-COC65LIW.js → chunk-JFZBGFNX.js} +3 -1
  35. package/dist/{chunk-YECBSG77.js → chunk-JIC33O5L.js} +2 -2
  36. package/dist/{chunk-XAYXN4EG.js → chunk-JJX77MB7.js} +366 -138
  37. package/dist/{chunk-FLEY546A.js → chunk-KBT2I5ER.js} +7 -7
  38. package/dist/{chunk-37LMRT7G.js → chunk-KTVHAHUV.js} +1 -1
  39. package/dist/{chunk-PMJAY6JS.js → chunk-LQT3SWFA.js} +5 -5
  40. package/dist/{chunk-HYEAR6HL.js → chunk-MLBH7J7J.js} +1 -1
  41. package/dist/{chunk-5DMPHA4V.js → chunk-NKFRRZIT.js} +27 -37
  42. package/dist/{chunk-HOK7MEWG.js → chunk-NWSKFYOH.js} +1 -1
  43. package/dist/{chunk-JY2HJYJT.js → chunk-RN3AWYEP.js} +2 -2
  44. package/dist/{chunk-RKW5QGGN.js → chunk-RQ62VKM7.js} +1 -1
  45. package/dist/{chunk-XQPKMLRI.js → chunk-SDRJ2LE3.js} +1 -1
  46. package/dist/{chunk-JAJVUQV7.js → chunk-TKJ7277U.js} +3 -3
  47. package/dist/{chunk-EPOA52SD.js → chunk-TVXAN43I.js} +1 -1
  48. package/dist/{chunk-2NS3ACHB.js → chunk-UWTXAYBP.js} +11 -11
  49. package/dist/{chunk-2J4VCHRX.js → chunk-V57LZDHN.js} +8 -10
  50. package/dist/{chunk-HZF5P5UN.js → chunk-V7YE4WCP.js} +58 -7
  51. package/dist/{chunk-PGJBNO3I.js → chunk-XFZLQANQ.js} +2 -2
  52. package/dist/{chunk-5XBRH3N7.js → chunk-Y6MVGU7L.js} +12 -11
  53. package/dist/{chunk-WTKAALLV.js → chunk-Y7ZUBP2K.js} +6 -6
  54. package/dist/{chunk-UG5UCHHJ.js → chunk-ZLSFOSDK.js} +2 -1
  55. package/dist/cli/chat.js +36 -36
  56. package/dist/cli/check.js +8 -9
  57. package/dist/cli/init.js +41 -7
  58. package/dist/cli/plugins.js +15 -16
  59. package/dist/cli/snapshot-create.js +11 -12
  60. package/dist/cli/upgrade.js +9 -10
  61. package/dist/db/schema/conversation-events.d.ts +20 -0
  62. package/dist/db/schema/conversation-participants.d.ts +63 -0
  63. package/dist/db/schema.d.ts +77 -1
  64. package/dist/{db-QNQM5YRR.js → db-WT7P56AH.js} +8 -8
  65. package/dist/instrumentation.js +4 -4
  66. package/dist/nitro.js +2 -2
  67. package/dist/{oauth-callback-server-ERQPIR27.js → oauth-callback-server-R2PK2MCA.js} +26 -26
  68. package/dist/{runner-BX46SQIE.js → runner-O7YYUIHT.js} +15 -16
  69. package/dist/{sandbox-egress-signals-EKPAVWQL.js → sandbox-egress-signals-U3ZX7C5W.js} +3 -4
  70. package/dist/{skills-JL44EIRX.js → skills-S6HLQRH7.js} +8 -9
  71. package/dist/spawn-B4SBFFA2.js +37 -0
  72. package/dist/{validation-UU2AIJIY.js → validation-46WD2OAR.js} +8 -9
  73. package/dist/version.js +1 -1
  74. package/dist/{work-SS7RU5CH.js → work-YT5QUBS3.js} +20 -21
  75. package/dist/worker-4C5BEDWN.js +24 -0
  76. package/migrations/0026_conversation_event_actor_and_participants.sql +140 -0
  77. package/migrations/meta/0026_snapshot.json +2424 -0
  78. package/migrations/meta/_journal.json +7 -0
  79. package/package.json +8 -6
  80. package/dist/catalog-runtime-CGUDNL3D.js +0 -17
  81. package/dist/chunk-F3B2YJ76.js +0 -57
  82. package/dist/spawn-W6FO32T4.js +0 -38
  83. package/dist/worker-5P2E7LVI.js +0 -25
package/dist/app.js CHANGED
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  processConversationWork
3
- } from "./chunk-K4LK6KYO.js";
3
+ } from "./chunk-J7MWZFFP.js";
4
4
  import {
5
5
  bindSpawnAgent
6
- } from "./chunk-RKW5QGGN.js";
6
+ } from "./chunk-RQ62VKM7.js";
7
7
  import {
8
8
  createAgentInvocationWorker,
9
9
  enqueueAgentInvocation,
10
10
  listPendingAgentInvocationMailboxAppends,
11
11
  routeAgentInvocationWork
12
- } from "./chunk-WTKAALLV.js";
12
+ } from "./chunk-Y7ZUBP2K.js";
13
13
  import {
14
14
  GET as GET2,
15
15
  GET2 as GET3,
@@ -36,12 +36,12 @@ import {
36
36
  startSlackProcessingReaction,
37
37
  stripLeadingBotMention,
38
38
  wakePausedTurn
39
- } from "./chunk-5DMPHA4V.js";
39
+ } from "./chunk-NKFRRZIT.js";
40
40
  import "./chunk-FA6POGLH.js";
41
41
  import {
42
42
  getTurnRequestDeadline,
43
43
  runWithTurnRequestDeadline
44
- } from "./chunk-HOK7MEWG.js";
44
+ } from "./chunk-NWSKFYOH.js";
45
45
  import {
46
46
  GET,
47
47
  conversationVisibilityFromSlackChannelType,
@@ -50,8 +50,8 @@ import {
50
50
  resolveSlackChannelTypeFromMessage,
51
51
  resolveSlackConversationContext,
52
52
  routeApiTurnWork
53
- } from "./chunk-5XBRH3N7.js";
54
- import "./chunk-37LMRT7G.js";
53
+ } from "./chunk-Y6MVGU7L.js";
54
+ import "./chunk-KTVHAHUV.js";
55
55
  import {
56
56
  CONVERSATION_WORK_STALE_ENQUEUE_MS,
57
57
  appendAndEnqueueInboundMessage,
@@ -62,7 +62,7 @@ import {
62
62
  isInvalidConversationRecordError,
63
63
  listActiveConversationIds,
64
64
  removeActiveConversation
65
- } from "./chunk-A5SROS6H.js";
65
+ } from "./chunk-ELOTIL5F.js";
66
66
  import {
67
67
  buildDeliveredTurnStatePatch,
68
68
  claimDispatchMailboxAppend,
@@ -93,7 +93,7 @@ import {
93
93
  requireTurnFailureEventId,
94
94
  resolveTurnSessionRouting,
95
95
  scheduleSessionCompletedPluginTasks
96
- } from "./chunk-2NS3ACHB.js";
96
+ } from "./chunk-UWTXAYBP.js";
97
97
  import {
98
98
  ConversationTurnLifecycleService,
99
99
  coerceThreadConversationState,
@@ -103,7 +103,7 @@ import {
103
103
  persistThreadRuntimeState,
104
104
  persistThreadState,
105
105
  persistThreadStateById
106
- } from "./chunk-ISEROVYZ.js";
106
+ } from "./chunk-4K5N6HTX.js";
107
107
  import "./chunk-UTL3MHPC.js";
108
108
  import {
109
109
  getVercelConversationWorkQueue,
@@ -122,7 +122,7 @@ import {
122
122
  import {
123
123
  validatePluginEgressCredentialHooks,
124
124
  validatePluginRegistrations
125
- } from "./chunk-HYEAR6HL.js";
125
+ } from "./chunk-MLBH7J7J.js";
126
126
  import {
127
127
  defineJuniorPlugins,
128
128
  pluginCatalogConfigFromEnv,
@@ -136,7 +136,6 @@ import {
136
136
  clearSandboxEgressSignals,
137
137
  consumeSandboxEgressAuthRequiredSignal,
138
138
  consumeSandboxEgressPermissionDeniedSignal,
139
- createAgentRunner,
140
139
  createContextCompactor,
141
140
  deliverResourceEventSubscription,
142
141
  executeAgentRun,
@@ -155,18 +154,19 @@ import {
155
154
  setConfigDefaults,
156
155
  shouldEmitDevAgentTrace,
157
156
  shouldPropagateSandboxEgressTrace
158
- } from "./chunk-URFV5RWN.js";
157
+ } from "./chunk-AENPRXCG.js";
159
158
  import {
160
159
  AuthorizationFlowDisabledError,
161
160
  PluginCredentialFailureError
162
- } from "./chunk-5TXDKTET.js";
161
+ } from "./chunk-CPQBTTI6.js";
163
162
  import "./chunk-DIB4GX3G.js";
164
163
  import {
164
+ createAgentRunner,
165
165
  createUserTokenStore,
166
166
  deleteMcpAuthSessionsForUserProvider,
167
167
  deleteMcpServerSessionId,
168
168
  deleteMcpStoredOAuthCredentials
169
- } from "./chunk-O2YXWWPM.js";
169
+ } from "./chunk-2AHVM3HK.js";
170
170
  import {
171
171
  RetryableDeliveryError
172
172
  } from "./chunk-RF6J3DIO.js";
@@ -174,8 +174,8 @@ import {
174
174
  formatProviderLabel,
175
175
  postSlackMessage,
176
176
  startOAuthFlow
177
- } from "./chunk-FLEY546A.js";
178
- import "./chunk-HUO3UTAQ.js";
177
+ } from "./chunk-KBT2I5ER.js";
178
+ import "./chunk-7MA4HV4W.js";
179
179
  import {
180
180
  getExperimentalFeatures,
181
181
  setExperimentalFeatures
@@ -183,16 +183,16 @@ import {
183
183
  import {
184
184
  getSandboxResourceConfig,
185
185
  setSandboxResourceConfig
186
- } from "./chunk-4TWLKHOM.js";
186
+ } from "./chunk-37G5HJ2X.js";
187
187
  import {
188
188
  createSchedulerSqlStore,
189
189
  findMatchingEventTasks,
190
190
  logScheduledTaskRunSkipped,
191
191
  scheduledTaskRunAttributes
192
- } from "./chunk-PMJAY6JS.js";
192
+ } from "./chunk-LQT3SWFA.js";
193
193
  import {
194
194
  parseSlackThreadId
195
- } from "./chunk-TIV3PX5H.js";
195
+ } from "./chunk-APHDJYN7.js";
196
196
  import {
197
197
  ConversationTurnBoundaryError,
198
198
  CooperativeTurnYieldError,
@@ -242,7 +242,7 @@ import {
242
242
  trimTrailingAssistantMessages,
243
243
  turnHasReply,
244
244
  upsertConversationMessage
245
- } from "./chunk-5QBK3QHJ.js";
245
+ } from "./chunk-J2SYI36O.js";
246
246
  import "./chunk-3Y47VMHV.js";
247
247
  import "./chunk-PDO5BLNM.js";
248
248
  import "./chunk-UIE3R5XU.js";
@@ -262,7 +262,7 @@ import {
262
262
  verifyEventTaskCredentialSubject,
263
263
  verifyScheduledTaskCredentialSubject,
264
264
  verifySlackDirectCredentialSubject
265
- } from "./chunk-2J4VCHRX.js";
265
+ } from "./chunk-V57LZDHN.js";
266
266
  import {
267
267
  SlackActionError,
268
268
  downloadPrivateSlackFile,
@@ -272,7 +272,7 @@ import {
272
272
  normalizeSlackConversationId,
273
273
  runWithSlackInstallationToken,
274
274
  runWithWorkspaceTeamId
275
- } from "./chunk-JAJVUQV7.js";
275
+ } from "./chunk-TKJ7277U.js";
276
276
  import {
277
277
  contextProvenance,
278
278
  createSlackDestination,
@@ -285,19 +285,19 @@ import {
285
285
  requireSlackDestination,
286
286
  withConversationEventLock,
287
287
  withConversationMutationLock
288
- } from "./chunk-XAYXN4EG.js";
288
+ } from "./chunk-JJX77MB7.js";
289
289
  import {
290
290
  juniorAgentBindings,
291
291
  juniorAgentInvocations,
292
292
  juniorConversationEvents,
293
293
  juniorConversations
294
- } from "./chunk-ET54Q4TD.js";
294
+ } from "./chunk-773XC7P4.js";
295
295
  import "./chunk-EM225ITJ.js";
296
296
  import {
297
297
  acquireActiveLock,
298
298
  getStateAdapter,
299
299
  withActiveLock
300
- } from "./chunk-XQPKMLRI.js";
300
+ } from "./chunk-SDRJ2LE3.js";
301
301
  import {
302
302
  STANDARD_MODEL_PROFILE,
303
303
  botConfig,
@@ -315,30 +315,28 @@ import {
315
315
  modelIdForProfile,
316
316
  setSlackReactionConfig,
317
317
  standardModelId
318
- } from "./chunk-PGJBNO3I.js";
318
+ } from "./chunk-XFZLQANQ.js";
319
319
  import {
320
320
  juniorDestinations
321
321
  } from "./chunk-VFUK3X5B.js";
322
- import "./chunk-VXWTGOLW.js";
323
- import "./chunk-YECBSG77.js";
322
+ import "./chunk-2WLJDM23.js";
323
+ import "./chunk-JIC33O5L.js";
324
324
  import {
325
325
  pluginCatalogRuntime
326
- } from "./chunk-EPOA52SD.js";
327
- import "./chunk-JY2HJYJT.js";
326
+ } from "./chunk-TVXAN43I.js";
327
+ import "./chunk-RN3AWYEP.js";
328
328
  import {
329
329
  credentialContextForActor
330
- } from "./chunk-RUIXF3YQ.js";
330
+ } from "./chunk-BDUENQD3.js";
331
331
  import {
332
332
  createActor,
333
333
  createSlackActor,
334
334
  createSlackResumeActor,
335
335
  isActorUserId,
336
- parseActorUserId
337
- } from "./chunk-HZF5P5UN.js";
338
- import {
336
+ parseActorUserId,
339
337
  parseSlackChannelId,
340
338
  parseSlackMessageTs
341
- } from "./chunk-F3B2YJ76.js";
339
+ } from "./chunk-V7YE4WCP.js";
342
340
  import {
343
341
  buildTurnFailureResponse,
344
342
  createChatSdkLogger,
@@ -358,7 +356,7 @@ import {
358
356
  withContext,
359
357
  withLogContext,
360
358
  withSpan
361
- } from "./chunk-HMU2QP5M.js";
359
+ } from "./chunk-7NYEB2TM.js";
362
360
  import {
363
361
  continueTrace
364
362
  } from "./chunk-6GWA276C.js";
@@ -366,10 +364,10 @@ import "./chunk-OOUNJNMR.js";
366
364
  import "./chunk-H4HBKISO.js";
367
365
  import {
368
366
  JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE
369
- } from "./chunk-JJAMURMR.js";
367
+ } from "./chunk-EORR34UB.js";
370
368
  import {
371
369
  JUNIOR_VERSION
372
- } from "./chunk-COC65LIW.js";
370
+ } from "./chunk-JFZBGFNX.js";
373
371
  import "./chunk-MLKGABMK.js";
374
372
 
375
373
  // src/app.ts
@@ -8849,6 +8847,8 @@ function dashboardHostRoutePaths(dashboard) {
8849
8847
  "/favicon.ico",
8850
8848
  "/_junior/dashboard/avatar.png",
8851
8849
  "/_junior/dashboard/client.js",
8850
+ "/_junior/dashboard/icon-512.png",
8851
+ "/_junior/dashboard/manifest.webmanifest",
8852
8852
  loginPath,
8853
8853
  "/api/health",
8854
8854
  "/api/runtime",
@@ -0,0 +1,16 @@
1
+ import {
2
+ pluginCatalogRuntime
3
+ } from "./chunk-TVXAN43I.js";
4
+ import "./chunk-RN3AWYEP.js";
5
+ import "./chunk-BDUENQD3.js";
6
+ import "./chunk-V7YE4WCP.js";
7
+ import "./chunk-7NYEB2TM.js";
8
+ import "./chunk-6GWA276C.js";
9
+ import "./chunk-OOUNJNMR.js";
10
+ import "./chunk-H4HBKISO.js";
11
+ import "./chunk-EORR34UB.js";
12
+ import "./chunk-JFZBGFNX.js";
13
+ import "./chunk-MLKGABMK.js";
14
+ export {
15
+ pluginCatalogRuntime
16
+ };
@@ -0,0 +1,14 @@
1
+ import type { JuniorSqlDatabase } from "@/db/db";
2
+ import type { ConversationEventData } from "../history";
3
+ /**
4
+ * Resolve the durable actor identity for one event payload.
5
+ * Human user messages get an identity when author data is enough; other events
6
+ * keep a null actor.
7
+ */
8
+ export declare function resolveEventActorIdentityId(executor: JuniorSqlDatabase, args: {
9
+ conversationId: string;
10
+ data: ConversationEventData;
11
+ nowMs: number;
12
+ }): Promise<string | undefined>;
13
+ /** Drop payload-only authorIdentityId after lifting it onto the event column. */
14
+ export declare function stripPayloadAuthorIdentityId(data: ConversationEventData): ConversationEventData;
@@ -1,3 +1,3 @@
1
1
  import type { JuniorSqlDatabase } from "@/db/db";
2
- /** Serialize all event sequence allocation and visible projection writes. */
2
+ /** Serialize event sequence allocation with other conversation writes. */
3
3
  export declare function withConversationEventLock<T>(executor: JuniorSqlDatabase, conversationId: string, callback: () => Promise<T>): Promise<T>;
@@ -0,0 +1,17 @@
1
+ import type { JuniorSqlDatabase } from "@/db/db";
2
+ /** Resolve the root conversation id that owns personal-feed membership. */
3
+ export declare function resolveRootConversationId(executor: JuniorSqlDatabase, conversationId: string): Promise<string>;
4
+ /**
5
+ * Upsert one linked user as a participant on a root conversation.
6
+ * No-ops when the identity is missing, unlinked, or not a user.
7
+ */
8
+ export declare function recordConversationParticipant(executor: JuniorSqlDatabase, args: {
9
+ actorIdentityId: string;
10
+ conversationId: string;
11
+ atMs: number;
12
+ }): Promise<void>;
13
+ /** Find which of the supplied root conversations include the linked user. */
14
+ export declare function rootConversationIdsForParticipant(executor: JuniorSqlDatabase, args: {
15
+ rootConversationIds: readonly string[];
16
+ userId: string;
17
+ }): Promise<Set<string>>;
@@ -0,0 +1,2 @@
1
+ /** Return candidate conversations that have unfinished plugin work. */
2
+ export declare function listUnfinishedWork(conversationIds: string[]): Promise<string[]>;
@@ -12,3 +12,5 @@ export declare function createAgentRunner(execute: (run: AgentRun, streamFn?: St
12
12
  streamFn?: StreamFn;
13
13
  tracePropagation?: SandboxEgressTracePropagationConfig;
14
14
  }): AgentRunner;
15
+ /** Abort a timed-out agent run and wait briefly for its work to settle. */
16
+ export declare function runAgentWithTimeout(agentRunner: AgentRunner, run: AgentRun, timeoutMs: number | undefined): Promise<AgentRunOutcome>;
@@ -1,6 +1,6 @@
1
1
  import { type AgentRun } from "@/chat/agent/types";
2
2
  import type { AgentRunResult } from "@/chat/services/turn-result";
3
- import type { AgentRunner } from "@/chat/runtime/agent-runner";
3
+ import { type AgentRunner } from "@/chat/runtime/agent-runner";
4
4
  import { type ConversationTurnLifecycle } from "@/chat/conversations/turn-lifecycle";
5
5
  import { type AssistantStatusSpec } from "@/chat/slack/assistant-thread/status";
6
6
  import type { SlackMessageTs } from "@/chat/slack/timestamp";
@@ -1,5 +1,6 @@
1
1
  type ConversationRole = "assistant" | "system" | "user";
2
2
  export interface ConversationAuthor {
3
+ email?: string;
3
4
  fullName?: string;
4
5
  isBot?: boolean;
5
6
  userId?: string;
@@ -1,34 +1,40 @@
1
+ import {
2
+ isAgentRunFeatureDisabled
3
+ } from "./chunk-RF6J3DIO.js";
1
4
  import {
2
5
  resolveBaseUrl
3
- } from "./chunk-FLEY546A.js";
6
+ } from "./chunk-KBT2I5ER.js";
7
+ import {
8
+ isExperimentalFeatureEnabled
9
+ } from "./chunk-5IDFPCON.js";
4
10
  import {
5
11
  createPluginLogger,
6
12
  getPlugins
7
- } from "./chunk-2J4VCHRX.js";
13
+ } from "./chunk-V57LZDHN.js";
8
14
  import {
9
15
  getSlackClient,
10
16
  withSlackRetries
11
- } from "./chunk-JAJVUQV7.js";
17
+ } from "./chunk-TKJ7277U.js";
12
18
  import {
13
19
  getDb,
14
20
  parseDestination
15
- } from "./chunk-XAYXN4EG.js";
21
+ } from "./chunk-JJX77MB7.js";
16
22
  import {
17
23
  sleep
18
24
  } from "./chunk-EM225ITJ.js";
19
25
  import {
20
26
  acquireActiveLock,
21
27
  getStateAdapter
22
- } from "./chunk-XQPKMLRI.js";
28
+ } from "./chunk-SDRJ2LE3.js";
23
29
  import {
24
30
  pluginCatalogRuntime
25
- } from "./chunk-EPOA52SD.js";
31
+ } from "./chunk-TVXAN43I.js";
26
32
  import {
27
33
  fetchWithBoundedOAuthErrorBodies
28
- } from "./chunk-JY2HJYJT.js";
34
+ } from "./chunk-RN3AWYEP.js";
29
35
  import {
30
36
  isRecord
31
- } from "./chunk-HMU2QP5M.js";
37
+ } from "./chunk-7NYEB2TM.js";
32
38
 
33
39
  // src/chat/capabilities/router.ts
34
40
  var ProviderCredentialRouter = class {
@@ -140,6 +146,81 @@ async function issueProviderCredentialLease(input) {
140
146
  return await getSandboxEgressRouter().issue(input);
141
147
  }
142
148
 
149
+ // src/chat/runtime/agent-runner.ts
150
+ var AGENT_ABORT_SETTLE_GRACE_MS = 5e3;
151
+ function createAgentRunner(execute, options) {
152
+ const streamFn = options?.streamFn;
153
+ const tracePropagation = options?.tracePropagation;
154
+ const bindSpawnAgent = options?.bindSpawnAgent;
155
+ const canBindSpawn = Boolean(bindSpawnAgent) && isExperimentalFeatureEnabled("subagents");
156
+ return {
157
+ run: async (run) => {
158
+ const spawnAgent = bindSpawnAgent && canBindSpawn && !isAgentRunFeatureDisabled(run.disabledFeatures, "subagents") ? bindSpawnAgent(run) : void 0;
159
+ const nextRun = {
160
+ ...run,
161
+ environment: {
162
+ ...run.environment,
163
+ sandboxTracePropagation: run.environment?.sandboxTracePropagation ?? tracePropagation
164
+ },
165
+ ...spawnAgent ? {
166
+ durability: {
167
+ ...run.durability,
168
+ spawnAgent
169
+ }
170
+ } : {}
171
+ };
172
+ return await execute(nextRun, streamFn);
173
+ }
174
+ };
175
+ }
176
+ async function waitForAgentSettlement(runPromise) {
177
+ let timeoutId;
178
+ const settleGrace = new Promise((resolve) => {
179
+ timeoutId = setTimeout(resolve, AGENT_ABORT_SETTLE_GRACE_MS);
180
+ timeoutId.unref?.();
181
+ });
182
+ await Promise.race([
183
+ runPromise.then(
184
+ () => void 0,
185
+ () => void 0
186
+ ),
187
+ settleGrace
188
+ ]);
189
+ if (timeoutId) {
190
+ clearTimeout(timeoutId);
191
+ }
192
+ }
193
+ async function runAgentWithTimeout(agentRunner, run, timeoutMs) {
194
+ if (typeof timeoutMs !== "number") {
195
+ return await agentRunner.run(run);
196
+ }
197
+ const timeoutError = new Error(
198
+ `executeAgentRun timed out after ${timeoutMs}ms`
199
+ );
200
+ const abortController = new AbortController();
201
+ const signal = run.signal ? AbortSignal.any([run.signal, abortController.signal]) : abortController.signal;
202
+ const runPromise = agentRunner.run({ ...run, signal });
203
+ let timeoutId;
204
+ const timeoutPromise = new Promise((_, reject) => {
205
+ timeoutId = setTimeout(() => {
206
+ abortController.abort(timeoutError);
207
+ reject(timeoutError);
208
+ }, timeoutMs);
209
+ });
210
+ try {
211
+ return await Promise.race([runPromise, timeoutPromise]);
212
+ } catch (error) {
213
+ if (abortController.signal.aborted) {
214
+ await waitForAgentSettlement(runPromise);
215
+ }
216
+ throw error;
217
+ } finally {
218
+ if (timeoutId) {
219
+ clearTimeout(timeoutId);
220
+ }
221
+ }
222
+ }
223
+
143
224
  // src/chat/mcp/errors.ts
144
225
  var McpProviderError = class extends Error {
145
226
  phase;
@@ -1159,5 +1240,7 @@ export {
1159
1240
  deleteMcpStoredOAuthCredentials,
1160
1241
  deleteMcpServerSessionId,
1161
1242
  createMcpOAuthClientProvider,
1162
- finalizeMcpAuthorization
1243
+ finalizeMcpAuthorization,
1244
+ createAgentRunner,
1245
+ runAgentWithTimeout
1163
1246
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  logWarn
3
- } from "./chunk-HMU2QP5M.js";
3
+ } from "./chunk-7NYEB2TM.js";
4
4
 
5
5
  // src/chat/conversation-privacy.ts
6
6
  import { AsyncLocalStorage } from "async_hooks";
@@ -4,18 +4,18 @@ import {
4
4
  } from "./chunk-EM225ITJ.js";
5
5
  import {
6
6
  getStateAdapter
7
- } from "./chunk-XQPKMLRI.js";
7
+ } from "./chunk-SDRJ2LE3.js";
8
8
  import {
9
9
  toOptionalTrimmed
10
- } from "./chunk-PGJBNO3I.js";
10
+ } from "./chunk-XFZLQANQ.js";
11
11
  import {
12
12
  pluginCatalogRuntime
13
- } from "./chunk-EPOA52SD.js";
13
+ } from "./chunk-TVXAN43I.js";
14
14
  import {
15
15
  setSpanAttributes,
16
16
  setSpanStatus,
17
17
  withSpan
18
- } from "./chunk-HMU2QP5M.js";
18
+ } from "./chunk-7NYEB2TM.js";
19
19
 
20
20
  // src/chat/sandbox/resources.ts
21
21
  var configuredResources;
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  persistConversationMessages
3
- } from "./chunk-5QBK3QHJ.js";
3
+ } from "./chunk-J2SYI36O.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-XAYXN4EG.js";
9
+ } from "./chunk-JJX77MB7.js";
10
10
  import {
11
11
  juniorLocationConfigurations
12
- } from "./chunk-ET54Q4TD.js";
12
+ } from "./chunk-773XC7P4.js";
13
13
  import {
14
14
  getStateAdapter
15
- } from "./chunk-XQPKMLRI.js";
15
+ } from "./chunk-SDRJ2LE3.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-HMU2QP5M.js";
23
+ } from "./chunk-7NYEB2TM.js";
24
24
 
25
25
  // src/chat/conversations/turn-lifecycle.ts
26
26
  var ConversationTurnLifecycleService = class {