@sentry/junior 0.184.0 → 0.185.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.
- package/dist/{agent-hooks-XTZVALGQ.js → agent-hooks-NGZQLL5O.js} +13 -11
- package/dist/api/acp/schema.d.ts +20 -2
- package/dist/api/code/overview.d.ts +39 -0
- package/dist/api/locations/detail.d.ts +1 -1
- package/dist/api/people/code.d.ts +22 -0
- package/dist/api/schema/code.d.ts +46 -0
- package/dist/api/schema/conversation.d.ts +100 -20
- package/dist/api/schema/location.d.ts +1 -1
- package/dist/api/schema/person.d.ts +1 -1
- package/dist/api/schema.d.ts +4 -4
- package/dist/api/schema.js +12 -1
- package/dist/api.js +358 -76
- package/dist/app.js +406 -377
- package/dist/{catalog-runtime-5357XR4F.js → catalog-runtime-AAEAO2RL.js} +4 -4
- package/dist/chat/api-turns/accepted-reply.d.ts +11 -0
- package/dist/chat/api-turns/cancellation.d.ts +3 -5
- package/dist/chat/api-turns/work.d.ts +4 -9
- package/dist/chat/app/conversation-work.d.ts +1 -1
- package/dist/chat/app/factory.d.ts +4 -0
- package/dist/chat/app/services.d.ts +4 -3
- package/dist/chat/conversations/history.d.ts +83 -9
- package/dist/chat/conversations/turn-lifecycle.d.ts +4 -3
- package/dist/chat/providers/slack/input.d.ts +32 -0
- package/dist/chat/{runtime → providers/slack}/processing-reaction.d.ts +6 -8
- package/dist/chat/{runtime/slack-resume.d.ts → providers/slack/resume.d.ts} +16 -19
- package/dist/chat/providers/slack/runtime.d.ts +1 -10
- package/dist/chat/providers/slack/turn.d.ts +11 -24
- package/dist/chat/resource-events/store.d.ts +1 -1
- package/dist/chat/resource-events/tool-support.d.ts +0 -5
- package/dist/chat/runtime/turn-execution.d.ts +7 -2
- package/dist/chat/sandbox/egress/credentials.d.ts +3 -3
- package/dist/chat/sandbox/egress/session.d.ts +5 -6
- package/dist/chat/scheduled-tasks/tool-support.d.ts +5 -5
- package/dist/chat/scheduled-tasks/tools/create.d.ts +2 -2
- package/dist/chat/scheduled-tasks/tools/delete.d.ts +2 -2
- package/dist/chat/scheduled-tasks/tools/list.d.ts +2 -2
- package/dist/chat/scheduled-tasks/tools/run-now.d.ts +2 -2
- package/dist/chat/scheduled-tasks/tools/update.d.ts +2 -2
- package/dist/chat/scheduled-tasks/types.d.ts +1 -1
- package/dist/chat/services/provider-retry.d.ts +2 -0
- package/dist/chat/services/turn-failure-response.d.ts +4 -0
- package/dist/chat/task-execution/paused-turn.d.ts +0 -2
- package/dist/chat/task-execution/state.d.ts +2 -2
- package/dist/chat/task-execution/store.d.ts +1 -1
- package/dist/chat/task-execution/turn-wake.d.ts +12 -0
- package/dist/chat/tool-support/action-review.d.ts +1 -1
- package/dist/chat/tools/resource-events.d.ts +1 -1
- package/dist/chat/tools/search-conversation-events.d.ts +1 -1
- package/dist/chat/tools/types.d.ts +1 -1
- package/dist/chat/tools/watch-resource-events.d.ts +2 -2
- package/dist/{chunk-FKEZZMXS.js → chunk-4HA36IWS.js} +9 -94
- package/dist/{chunk-WVIA7V3M.js → chunk-4K25ODAO.js} +27 -1
- package/dist/{chunk-UF6BUA5W.js → chunk-4S47VHJR.js} +3 -3
- package/dist/{chunk-JNO2GUDS.js → chunk-6DOAUXLD.js} +231 -198
- package/dist/{chunk-M3QYTBQ6.js → chunk-6Q7YZLCL.js} +2 -1
- package/dist/{chunk-6VOYP4M6.js → chunk-7GAP2XG4.js} +1 -1
- package/dist/{chunk-LHXIZLFF.js → chunk-7MHNIGHP.js} +1 -1
- package/dist/{chunk-IZDYYYGP.js → chunk-ABAX75GG.js} +10 -384
- package/dist/{chunk-WQFEWULF.js → chunk-ATUWN6Z3.js} +2 -2
- package/dist/{chunk-4RONS3WR.js → chunk-C6TS47CQ.js} +4 -4
- package/dist/chunk-D4YV5TDV.js +45 -0
- package/dist/{chunk-Z3QAXJR7.js → chunk-D63IUQQE.js} +4 -4
- package/dist/{chunk-M5YWNMTE.js → chunk-DAPC2HTM.js} +24 -6
- package/dist/{chunk-BHYRYYLY.js → chunk-EIJCPJOY.js} +1 -1
- package/dist/{chunk-SHJK75Z2.js → chunk-EJYP3NQ4.js} +4 -4
- package/dist/{chunk-K7VDC2QW.js → chunk-EWEH2PJW.js} +6 -6
- package/dist/{chunk-6WGC3SO4.js → chunk-FFHXG2FX.js} +13 -11
- package/dist/{chunk-MLSQX2EX.js → chunk-FTVMXDNN.js} +1 -1
- package/dist/chunk-GFBR4S3Q.js +406 -0
- package/dist/{chunk-PJPRXO2T.js → chunk-GJTIZQGJ.js} +1 -1
- package/dist/{chunk-BT53RIGJ.js → chunk-HJPC32TQ.js} +12 -50
- package/dist/{chunk-RF6J3DIO.js → chunk-INQHUE72.js} +84 -1
- package/dist/{chunk-6UDPINOX.js → chunk-LRI5IRGY.js} +19 -44
- package/dist/{chunk-BCHYQS4B.js → chunk-LVK4WJKM.js} +1 -1
- package/dist/{chunk-UBOIHNTH.js → chunk-MWOH6CIK.js} +178 -148
- package/dist/{chunk-3S7ULUWW.js → chunk-OMQ2J6F6.js} +1 -1
- package/dist/{chunk-DUKIDPF6.js → chunk-PNYJOEVV.js} +1 -1
- package/dist/{chunk-MAPJFUMV.js → chunk-QCT4226Q.js} +3 -3
- package/dist/{chunk-HIPUIPJM.js → chunk-QZKHHG3B.js} +34 -8
- package/dist/{chunk-QABCY33S.js → chunk-TVVAMOLS.js} +2 -2
- package/dist/{chunk-JA43DV4Y.js → chunk-U4CTAVWN.js} +1 -1
- package/dist/{chunk-LCP4EDKR.js → chunk-UUULGCKK.js} +1 -1
- package/dist/{chunk-4CNDGK25.js → chunk-VH4IU3UC.js} +928 -984
- package/dist/chunk-W7GCLNIV.js +58 -0
- package/dist/{chunk-2ZQPVX7C.js → chunk-WLKWN4CD.js} +22 -12
- package/dist/{chunk-ACPDVEJO.js → chunk-X2SS6BF7.js} +198 -209
- package/dist/{chunk-YKX6MTLU.js → chunk-X7NCJQAA.js} +1 -1
- package/dist/{chunk-E57WPXWY.js → chunk-Y5G23T2D.js} +5 -5
- package/dist/{chunk-HUXFMDBZ.js → chunk-ZIF2S464.js} +1 -1
- package/dist/{chunk-JM2COLGC.js → chunk-ZKKGFUWM.js} +6 -6
- package/dist/cli/chat.js +35 -33
- package/dist/cli/check.js +5 -5
- package/dist/cli/plugins.js +14 -12
- package/dist/cli/snapshot-create.js +10 -9
- package/dist/cli/upgrade.js +7 -6
- package/dist/{db-MA52H62H.js → db-TRJ77FAU.js} +8 -6
- package/dist/instrumentation.js +3 -3
- package/dist/nitro.js +7 -6
- package/dist/{oauth-callback-server-DXGHKN6S.js → oauth-callback-server-XD5SV3MS.js} +30 -27
- package/dist/{runner-4IXUAQNK.js → runner-KFX7NG6D.js} +24 -19
- package/dist/{skills-X3DY7AXO.js → skills-J2AH26CW.js} +5 -5
- package/dist/spawn-VU3CSRI6.js +41 -0
- package/dist/task-runner-5JG3VIIY.js +34 -0
- package/dist/{validation-Z6JXSTJS.js → validation-O5J4VOPF.js} +5 -5
- package/dist/version.js +1 -1
- package/dist/{work-OKWRFBDW.js → work-ECPQTG3U.js} +24 -19
- package/dist/worker-RS3DXUDO.js +24 -0
- package/package.json +4 -4
- package/dist/spawn-43WGS6CH.js +0 -37
- package/dist/task-runner-VDRKITPV.js +0 -32
- package/dist/worker-B236AE72.js +0 -22
|
@@ -1,36 +1,40 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createWebAuthorization,
|
|
3
3
|
deleteWebAuthorization
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-UUULGCKK.js";
|
|
5
|
+
import {
|
|
6
|
+
AgentRunError,
|
|
7
|
+
executeTurn
|
|
8
|
+
} from "./chunk-W7GCLNIV.js";
|
|
5
9
|
import {
|
|
6
10
|
buildDeliveredTurnStatePatch,
|
|
7
11
|
completeAuthPauseTurn,
|
|
8
12
|
finalizeFailedTurnReplyWithEvent,
|
|
9
13
|
getTurnUserMessage
|
|
10
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-DAPC2HTM.js";
|
|
11
15
|
import {
|
|
12
16
|
processPluginTask,
|
|
13
17
|
scheduleSessionCompletedPluginTasks
|
|
14
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-FFHXG2FX.js";
|
|
15
19
|
import {
|
|
16
20
|
ConversationTurnLifecycleService
|
|
17
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-6Q7YZLCL.js";
|
|
18
22
|
import {
|
|
19
23
|
coerceThreadConversationState,
|
|
20
24
|
getPersistedSandboxState,
|
|
21
25
|
getPersistedThreadState,
|
|
22
26
|
persistThreadStateById
|
|
23
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-Y5G23T2D.js";
|
|
24
28
|
import {
|
|
25
29
|
healthReportSchema
|
|
26
30
|
} from "./chunk-UTL3MHPC.js";
|
|
27
31
|
import {
|
|
28
32
|
parseSlackThreadId
|
|
29
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-X7NCJQAA.js";
|
|
30
34
|
import {
|
|
31
35
|
appendAndEnqueueExclusiveInboundMessage,
|
|
32
36
|
appendAndEnqueueInboundMessage
|
|
33
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-D63IUQQE.js";
|
|
34
38
|
import {
|
|
35
39
|
TurnInputCommitLostError,
|
|
36
40
|
buildDeterministicTurnId,
|
|
@@ -41,10 +45,11 @@ import {
|
|
|
41
45
|
markTurnClosed,
|
|
42
46
|
markTurnFailed,
|
|
43
47
|
startActiveTurn
|
|
44
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-U4CTAVWN.js";
|
|
45
49
|
import {
|
|
46
50
|
abandonTurnRecord,
|
|
47
51
|
buildConversationContext,
|
|
52
|
+
commitAcceptedReply,
|
|
48
53
|
getTurnRecord,
|
|
49
54
|
hydrateConversationMessages,
|
|
50
55
|
listTurnSummaries,
|
|
@@ -56,27 +61,27 @@ import {
|
|
|
56
61
|
recordDeliveredAssistantMessage,
|
|
57
62
|
saveTurnCheckpoint,
|
|
58
63
|
upsertConversationMessage
|
|
59
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-WLKWN4CD.js";
|
|
60
65
|
import {
|
|
61
66
|
normalizeSlackConversationId
|
|
62
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-VH4IU3UC.js";
|
|
63
68
|
import {
|
|
64
69
|
getConversationEventStore,
|
|
65
70
|
getConversationStore,
|
|
66
71
|
getDb
|
|
67
|
-
} from "./chunk-
|
|
72
|
+
} from "./chunk-ABAX75GG.js";
|
|
68
73
|
import {
|
|
69
74
|
juniorConversationParticipants,
|
|
70
75
|
juniorConversations,
|
|
71
76
|
juniorIdentities,
|
|
72
77
|
juniorUsers
|
|
73
|
-
} from "./chunk-
|
|
78
|
+
} from "./chunk-LVK4WJKM.js";
|
|
74
79
|
import {
|
|
75
80
|
juniorDestinations
|
|
76
81
|
} from "./chunk-VFUK3X5B.js";
|
|
77
82
|
import {
|
|
78
83
|
canExposeConversationPayload
|
|
79
|
-
} from "./chunk-
|
|
84
|
+
} from "./chunk-EIJCPJOY.js";
|
|
80
85
|
import {
|
|
81
86
|
credentialContextForActor
|
|
82
87
|
} from "./chunk-CEMMLV5L.js";
|
|
@@ -84,7 +89,7 @@ import {
|
|
|
84
89
|
logException,
|
|
85
90
|
setTags,
|
|
86
91
|
withLogContext
|
|
87
|
-
} from "./chunk-
|
|
92
|
+
} from "./chunk-OMQ2J6F6.js";
|
|
88
93
|
|
|
89
94
|
// src/handlers/health.ts
|
|
90
95
|
function readHealthReport() {
|
|
@@ -196,6 +201,35 @@ import {
|
|
|
196
201
|
localDestinationSchema
|
|
197
202
|
} from "@sentry/junior-plugin-api";
|
|
198
203
|
|
|
204
|
+
// src/chat/api-turns/accepted-reply.ts
|
|
205
|
+
async function commitWebAcceptedReply(args) {
|
|
206
|
+
const conversationMessageId = recordDeliveredAssistantMessage({
|
|
207
|
+
conversation: args.conversation,
|
|
208
|
+
sessionId: args.sessionId,
|
|
209
|
+
source: "web",
|
|
210
|
+
text: args.text,
|
|
211
|
+
userMessageId: args.userMessageId
|
|
212
|
+
});
|
|
213
|
+
try {
|
|
214
|
+
await persistWithRetry(
|
|
215
|
+
() => commitAcceptedReply({
|
|
216
|
+
...args.agentMessage ? { agentMessage: args.agentMessage } : void 0,
|
|
217
|
+
conversation: args.conversation,
|
|
218
|
+
conversationMessageId,
|
|
219
|
+
conversationId: args.conversationId
|
|
220
|
+
})
|
|
221
|
+
);
|
|
222
|
+
} catch (error) {
|
|
223
|
+
logException(
|
|
224
|
+
new Error("Accepted assistant message persistence failed"),
|
|
225
|
+
"api.assistant.message_post_delivery_persist.failed",
|
|
226
|
+
{
|
|
227
|
+
"error.type": error instanceof Error ? error.name : typeof error
|
|
228
|
+
}
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
199
233
|
// src/chat/api-turns/cancellation.ts
|
|
200
234
|
function createApiTurnCancellation() {
|
|
201
235
|
const active = /* @__PURE__ */ new Map();
|
|
@@ -217,7 +251,7 @@ function createApiTurnCancellation() {
|
|
|
217
251
|
if (!entry) {
|
|
218
252
|
return false;
|
|
219
253
|
}
|
|
220
|
-
entry.controller.abort(new
|
|
254
|
+
entry.controller.abort(new DOMException("Turn cancelled", "AbortError"));
|
|
221
255
|
return true;
|
|
222
256
|
},
|
|
223
257
|
disconnect(conversationId, signal) {
|
|
@@ -257,7 +291,7 @@ async function completeCancelledApiTurn(args) {
|
|
|
257
291
|
await abandonTurnRecord({
|
|
258
292
|
conversationId: args.conversationId,
|
|
259
293
|
turnId: args.turnId,
|
|
260
|
-
errorMessage: "
|
|
294
|
+
errorMessage: "Turn cancelled"
|
|
261
295
|
});
|
|
262
296
|
clearPendingAuth(args.conversation, args.turnId);
|
|
263
297
|
markConversationMessage(args.conversation, args.userMessageId, {
|
|
@@ -279,7 +313,9 @@ async function completeCancelledApiTurn(args) {
|
|
|
279
313
|
conversation: args.conversation,
|
|
280
314
|
sandboxRef: args.sandboxRef
|
|
281
315
|
});
|
|
282
|
-
await
|
|
316
|
+
await new ConversationTurnLifecycleService(
|
|
317
|
+
getConversationEventStore()
|
|
318
|
+
).complete({
|
|
283
319
|
conversationId: args.conversationId,
|
|
284
320
|
createdAtMs: Date.now(),
|
|
285
321
|
outcome: "cancelled",
|
|
@@ -504,20 +540,22 @@ function hasLostTurnInputCommit(error) {
|
|
|
504
540
|
const cause = getConversationTurnBoundaryError(error)?.cause ?? error;
|
|
505
541
|
return isTurnInputCommitLostError(error) || isTurnInputCommitLostError(cause);
|
|
506
542
|
}
|
|
507
|
-
function createApiTurnWorker(
|
|
543
|
+
function createApiTurnWorker(agentRunner, cancellation) {
|
|
508
544
|
return async (context) => {
|
|
509
545
|
const resolved = await resolveApiTurnWork(context);
|
|
510
546
|
if (!resolved) {
|
|
511
547
|
throw new Error(
|
|
512
|
-
`API
|
|
548
|
+
`Conversation API worker received other work for ${context.conversationId}`
|
|
513
549
|
);
|
|
514
550
|
}
|
|
515
551
|
if (context.publishExternally) {
|
|
516
552
|
throw new Error(
|
|
517
|
-
`API
|
|
553
|
+
`Conversation API work cannot publish to a provider for ${context.conversationId}`
|
|
518
554
|
);
|
|
519
555
|
}
|
|
520
|
-
const lifecycle =
|
|
556
|
+
const lifecycle = new ConversationTurnLifecycleService(
|
|
557
|
+
getConversationEventStore()
|
|
558
|
+
);
|
|
521
559
|
const isResume = resolved.kind === "resume";
|
|
522
560
|
let actor;
|
|
523
561
|
let text;
|
|
@@ -543,7 +581,7 @@ function createApiTurnWorker(options) {
|
|
|
543
581
|
);
|
|
544
582
|
if (!resumedActor) {
|
|
545
583
|
throw new Error(
|
|
546
|
-
`API
|
|
584
|
+
`Conversation API resume missing actor for ${context.conversationId}`
|
|
547
585
|
);
|
|
548
586
|
}
|
|
549
587
|
actor = resumedActor;
|
|
@@ -577,7 +615,7 @@ function createApiTurnWorker(options) {
|
|
|
577
615
|
await context.attempt.ack();
|
|
578
616
|
} catch {
|
|
579
617
|
throw new TurnInputCommitLostError(
|
|
580
|
-
`Conversation work lease lost before API
|
|
618
|
+
`Conversation work lease lost before Conversation API message acknowledgement for ${context.conversationId}`
|
|
581
619
|
);
|
|
582
620
|
}
|
|
583
621
|
acknowledged = true;
|
|
@@ -590,12 +628,12 @@ function createApiTurnWorker(options) {
|
|
|
590
628
|
});
|
|
591
629
|
let sandboxRef = getPersistedSandboxState(persisted);
|
|
592
630
|
const initialSandboxRef = sandboxRef;
|
|
593
|
-
const appSignal =
|
|
631
|
+
const appSignal = cancellation?.signal(context.conversationId);
|
|
594
632
|
const stopSignal = context.stopSignal?.();
|
|
595
633
|
const cancellationSignal = appSignal && stopSignal ? AbortSignal.any([appSignal, stopSignal]) : appSignal ?? stopSignal;
|
|
596
634
|
const finishCancellation = () => {
|
|
597
635
|
if (appSignal) {
|
|
598
|
-
|
|
636
|
+
cancellation?.finish(context.conversationId, appSignal);
|
|
599
637
|
}
|
|
600
638
|
};
|
|
601
639
|
const completeCancelledTurn = async () => {
|
|
@@ -603,10 +641,9 @@ function createApiTurnWorker(options) {
|
|
|
603
641
|
await completeCancelledApiTurn({
|
|
604
642
|
acknowledge,
|
|
605
643
|
actorId: actor.userId,
|
|
606
|
-
cancellation
|
|
644
|
+
cancellation,
|
|
607
645
|
conversation,
|
|
608
646
|
conversationId: context.conversationId,
|
|
609
|
-
lifecycle,
|
|
610
647
|
sandboxRef,
|
|
611
648
|
signal: appSignal,
|
|
612
649
|
turnId,
|
|
@@ -624,7 +661,7 @@ function createApiTurnWorker(options) {
|
|
|
624
661
|
const userMessage = getTurnUserMessage(conversation, turnId);
|
|
625
662
|
if (!userMessage) {
|
|
626
663
|
throw new Error(
|
|
627
|
-
`Unable to locate the persisted user message for
|
|
664
|
+
`Unable to locate the persisted user message for Turn "${turnId}"`
|
|
628
665
|
);
|
|
629
666
|
}
|
|
630
667
|
userMessageId = userMessage.id;
|
|
@@ -676,37 +713,23 @@ function createApiTurnWorker(options) {
|
|
|
676
713
|
let failureCode = "persistence_failed";
|
|
677
714
|
let modelFailureEventId;
|
|
678
715
|
let modelFailureCaptureAttempted = false;
|
|
679
|
-
let
|
|
716
|
+
let completedSuccessfully = false;
|
|
680
717
|
const deliverAssistantMessage = async (value) => {
|
|
718
|
+
const agentMessage = typeof value === "string" ? void 0 : value;
|
|
681
719
|
const replyText = typeof value === "string" ? value : getAssistantReplyText(value);
|
|
682
720
|
if (!replyText?.trim()) {
|
|
683
721
|
return;
|
|
684
722
|
}
|
|
685
723
|
failureCode = "delivery_failed";
|
|
686
724
|
assistantMessageDelivered = true;
|
|
687
|
-
|
|
725
|
+
await commitWebAcceptedReply({
|
|
726
|
+
...agentMessage ? { agentMessage } : void 0,
|
|
688
727
|
conversation,
|
|
728
|
+
conversationId: context.conversationId,
|
|
689
729
|
sessionId: turnId,
|
|
690
|
-
source: "web",
|
|
691
730
|
text: replyText,
|
|
692
731
|
userMessageId
|
|
693
732
|
});
|
|
694
|
-
try {
|
|
695
|
-
await persistWithRetry(
|
|
696
|
-
() => persistConversationMessages({
|
|
697
|
-
conversation,
|
|
698
|
-
conversationId: context.conversationId
|
|
699
|
-
})
|
|
700
|
-
);
|
|
701
|
-
} catch (error) {
|
|
702
|
-
logException(
|
|
703
|
-
new Error("Accepted assistant message persistence failed"),
|
|
704
|
-
"api.assistant.message_post_delivery_persist.failed",
|
|
705
|
-
{
|
|
706
|
-
"error.type": error instanceof Error ? error.name : typeof error
|
|
707
|
-
}
|
|
708
|
-
);
|
|
709
|
-
}
|
|
710
733
|
failureCode = "agent_run_failed";
|
|
711
734
|
};
|
|
712
735
|
try {
|
|
@@ -751,53 +774,112 @@ function createApiTurnWorker(options) {
|
|
|
751
774
|
failureCode = "agent_run_failed";
|
|
752
775
|
currentRunId = `api-run:${stableHex(turnId, String(startedAtMs))}`;
|
|
753
776
|
setTags({ runId: currentRunId });
|
|
754
|
-
const outcome = await
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
durability: {
|
|
782
|
-
onInputCommitted: acknowledge,
|
|
783
|
-
shouldYield: context.shouldYield,
|
|
784
|
-
onSandboxRefChanged: async (nextSandboxRef) => {
|
|
785
|
-
sandboxRef = nextSandboxRef;
|
|
786
|
-
await persistThreadStateById(context.conversationId, {
|
|
787
|
-
conversation,
|
|
788
|
-
sandboxRef
|
|
789
|
-
});
|
|
777
|
+
const outcome = await executeTurn(
|
|
778
|
+
agentRunner,
|
|
779
|
+
{
|
|
780
|
+
conversationId: context.conversationId,
|
|
781
|
+
turnId,
|
|
782
|
+
runId: currentRunId,
|
|
783
|
+
instruction: {
|
|
784
|
+
text,
|
|
785
|
+
context: buildConversationContext(conversation, {
|
|
786
|
+
excludeMessageId: userMessageId
|
|
787
|
+
})
|
|
788
|
+
},
|
|
789
|
+
history: piMessages,
|
|
790
|
+
actor,
|
|
791
|
+
credentialContext: credentialContextForActor(actor),
|
|
792
|
+
destination,
|
|
793
|
+
publishExternally: false,
|
|
794
|
+
source,
|
|
795
|
+
surface: "api",
|
|
796
|
+
...cancellationSignal ? { signal: cancellationSignal } : void 0,
|
|
797
|
+
authorization: createWebAuthorization({
|
|
798
|
+
actorId: actor.userId,
|
|
799
|
+
conversationId: context.conversationId
|
|
800
|
+
}),
|
|
801
|
+
state: {
|
|
802
|
+
pendingAuth: conversation.processing.pendingAuth,
|
|
803
|
+
sandboxRef
|
|
790
804
|
},
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
805
|
+
delivery: deliverAssistantMessage,
|
|
806
|
+
durability: {
|
|
807
|
+
onInputCommitted: acknowledge,
|
|
808
|
+
shouldYield: context.shouldYield,
|
|
809
|
+
onSandboxRefChanged: async (nextSandboxRef) => {
|
|
810
|
+
sandboxRef = nextSandboxRef;
|
|
811
|
+
await persistThreadStateById(context.conversationId, {
|
|
812
|
+
conversation,
|
|
813
|
+
sandboxRef
|
|
814
|
+
});
|
|
815
|
+
},
|
|
816
|
+
recordPendingAuth: async (pendingAuth) => {
|
|
817
|
+
conversation.processing.pendingAuth = pendingAuth;
|
|
818
|
+
await persistThreadStateById(context.conversationId, {
|
|
819
|
+
conversation,
|
|
820
|
+
sandboxRef
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
},
|
|
825
|
+
async (result) => {
|
|
826
|
+
if (cancellationSignal?.aborted) {
|
|
827
|
+
throw cancellationSignal.reason ?? new DOMException("Turn cancelled", "AbortError");
|
|
828
|
+
}
|
|
829
|
+
finishCancellation();
|
|
830
|
+
modelFailureCaptureAttempted = result.diagnostics.outcome !== "success";
|
|
831
|
+
const finalized = finalizeFailedTurnReplyWithEvent({
|
|
832
|
+
reply: result,
|
|
833
|
+
logException
|
|
834
|
+
});
|
|
835
|
+
const modelFailureReason = finalized.failureReason;
|
|
836
|
+
const reply = finalized.reply;
|
|
837
|
+
modelFailureEventId = finalized.eventId;
|
|
838
|
+
if (reply.diagnostics.outcome !== "success") {
|
|
839
|
+
await deliverAssistantMessage(reply.text);
|
|
840
|
+
}
|
|
841
|
+
const completedState = buildDeliveredTurnStatePatch({
|
|
842
|
+
conversation,
|
|
843
|
+
reply,
|
|
844
|
+
sessionId: turnId,
|
|
845
|
+
userMessageId
|
|
846
|
+
});
|
|
847
|
+
await persistThreadStateById(context.conversationId, {
|
|
848
|
+
conversation: completedState.conversation,
|
|
849
|
+
sandboxRef: reply.sandboxRef ?? sandboxRef
|
|
850
|
+
});
|
|
851
|
+
if (reply.piMessages?.length) {
|
|
852
|
+
const latest = await getTurnRecord(
|
|
853
|
+
context.conversationId,
|
|
854
|
+
turnId
|
|
855
|
+
);
|
|
856
|
+
await saveTurnCheckpoint({
|
|
857
|
+
mode: "completed",
|
|
858
|
+
conversationId: context.conversationId,
|
|
859
|
+
turnId,
|
|
860
|
+
sliceId: latest?.sliceId ?? 1,
|
|
861
|
+
messages: reply.piMessages,
|
|
862
|
+
durationMs: reply.diagnostics.durationMs,
|
|
863
|
+
usage: reply.diagnostics.usage,
|
|
864
|
+
destination,
|
|
865
|
+
publishExternally: false,
|
|
866
|
+
source,
|
|
867
|
+
actor,
|
|
868
|
+
surface: "api"
|
|
796
869
|
});
|
|
797
870
|
}
|
|
871
|
+
completedSuccessfully = reply.diagnostics.outcome === "success";
|
|
872
|
+
return completedSuccessfully ? {
|
|
873
|
+
outcome: assistantMessageDelivered ? "success" : "no_reply"
|
|
874
|
+
} : {
|
|
875
|
+
...modelFailureEventId ? { eventId: modelFailureEventId } : void 0,
|
|
876
|
+
failureCode: "model_execution_failed",
|
|
877
|
+
...modelFailureReason ? { failureReason: modelFailureReason } : void 0,
|
|
878
|
+
outcome: "failed"
|
|
879
|
+
};
|
|
798
880
|
}
|
|
799
|
-
|
|
800
|
-
if (cancellationSignal?.aborted) {
|
|
881
|
+
);
|
|
882
|
+
if (outcome.status !== "completed" && cancellationSignal?.aborted) {
|
|
801
883
|
return await completeCancelledTurn();
|
|
802
884
|
}
|
|
803
885
|
if (outcome.status === "suspended") {
|
|
@@ -813,57 +895,12 @@ function createApiTurnWorker(options) {
|
|
|
813
895
|
sandboxRef
|
|
814
896
|
});
|
|
815
897
|
if (appSignal) {
|
|
816
|
-
|
|
898
|
+
cancellation?.park(context.conversationId, appSignal);
|
|
817
899
|
}
|
|
818
900
|
await acknowledge();
|
|
819
901
|
return { status: "paused" };
|
|
820
902
|
}
|
|
821
|
-
|
|
822
|
-
reply = outcome.result;
|
|
823
|
-
modelFailureCaptureAttempted = reply.diagnostics.outcome !== "success";
|
|
824
|
-
const finalized = finalizeFailedTurnReplyWithEvent({
|
|
825
|
-
reply,
|
|
826
|
-
logException
|
|
827
|
-
});
|
|
828
|
-
reply = finalized.reply;
|
|
829
|
-
modelFailureEventId = finalized.eventId;
|
|
830
|
-
if (reply.diagnostics.outcome !== "success") {
|
|
831
|
-
await deliverAssistantMessage(reply.text);
|
|
832
|
-
}
|
|
833
|
-
const completedState = buildDeliveredTurnStatePatch({
|
|
834
|
-
conversation,
|
|
835
|
-
reply,
|
|
836
|
-
sessionId: turnId,
|
|
837
|
-
userMessageId
|
|
838
|
-
});
|
|
839
|
-
await persistThreadStateById(context.conversationId, {
|
|
840
|
-
conversation: completedState.conversation,
|
|
841
|
-
sandboxRef: reply.sandboxRef ?? sandboxRef
|
|
842
|
-
});
|
|
843
|
-
if (reply.piMessages?.length) {
|
|
844
|
-
const latest = await getTurnRecord(context.conversationId, turnId);
|
|
845
|
-
await saveTurnCheckpoint({
|
|
846
|
-
mode: "completed",
|
|
847
|
-
conversationId: context.conversationId,
|
|
848
|
-
turnId,
|
|
849
|
-
sliceId: latest?.sliceId ?? 1,
|
|
850
|
-
messages: reply.piMessages,
|
|
851
|
-
durationMs: reply.diagnostics.durationMs,
|
|
852
|
-
usage: reply.diagnostics.usage,
|
|
853
|
-
destination,
|
|
854
|
-
publishExternally: false,
|
|
855
|
-
source,
|
|
856
|
-
actor,
|
|
857
|
-
surface: "api"
|
|
858
|
-
});
|
|
859
|
-
}
|
|
860
|
-
if (reply.diagnostics.outcome === "success") {
|
|
861
|
-
await lifecycle.complete({
|
|
862
|
-
conversationId: context.conversationId,
|
|
863
|
-
createdAtMs: Date.now(),
|
|
864
|
-
outcome: assistantMessageDelivered ? "success" : "no_reply",
|
|
865
|
-
turnId
|
|
866
|
-
});
|
|
903
|
+
if (completedSuccessfully) {
|
|
867
904
|
try {
|
|
868
905
|
await scheduleSessionCompletedPluginTasks(
|
|
869
906
|
{
|
|
@@ -895,30 +932,23 @@ function createApiTurnWorker(options) {
|
|
|
895
932
|
turnId
|
|
896
933
|
});
|
|
897
934
|
}
|
|
898
|
-
} else {
|
|
899
|
-
await lifecycle.fail({
|
|
900
|
-
conversationId: context.conversationId,
|
|
901
|
-
createdAtMs: Date.now(),
|
|
902
|
-
...modelFailureEventId ? { eventId: modelFailureEventId } : void 0,
|
|
903
|
-
failureCode: "model_execution_failed",
|
|
904
|
-
turnId
|
|
905
|
-
});
|
|
906
935
|
}
|
|
907
936
|
await acknowledge();
|
|
908
937
|
return { status: "completed" };
|
|
909
938
|
} catch (error) {
|
|
910
|
-
|
|
939
|
+
const failure = error instanceof AgentRunError ? error.cause : error;
|
|
940
|
+
if (hasLostTurnInputCommit(failure)) {
|
|
911
941
|
return { status: "lost_lease" };
|
|
912
942
|
}
|
|
913
943
|
if (cancellationSignal?.aborted) {
|
|
914
944
|
return await completeCancelledTurn();
|
|
915
945
|
}
|
|
916
946
|
if (!context.attempt.isFinalAttempt) {
|
|
917
|
-
throw
|
|
947
|
+
throw failure;
|
|
918
948
|
}
|
|
919
949
|
const failureEventId = modelFailureCaptureAttempted && failureCode === "agent_run_failed" ? modelFailureEventId : captureApiBoundaryFailure({
|
|
920
950
|
conversationId: context.conversationId,
|
|
921
|
-
error,
|
|
951
|
+
error: failure,
|
|
922
952
|
failureCode,
|
|
923
953
|
runId: currentRunId,
|
|
924
954
|
turnId
|
|
@@ -6,14 +6,14 @@ import {
|
|
|
6
6
|
isStale,
|
|
7
7
|
runNonInteractiveCommand,
|
|
8
8
|
sleep
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-EJYP3NQ4.js";
|
|
10
10
|
import {
|
|
11
11
|
getStateAdapter
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-PNYJOEVV.js";
|
|
13
13
|
import {
|
|
14
14
|
setSpanAttributes,
|
|
15
15
|
withSpan
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-OMQ2J6F6.js";
|
|
17
17
|
|
|
18
18
|
// src/chat/sandbox/resources.ts
|
|
19
19
|
var configuredResources;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
-
ToolInputError
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
ToolInputError
|
|
3
|
+
} from "./chunk-WLKWN4CD.js";
|
|
4
|
+
import {
|
|
5
|
+
getPlugins,
|
|
6
|
+
getSlackClient
|
|
7
|
+
} from "./chunk-VH4IU3UC.js";
|
|
6
8
|
import {
|
|
7
9
|
getDb
|
|
8
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-ABAX75GG.js";
|
|
9
11
|
import {
|
|
10
12
|
juniorAttachments,
|
|
11
13
|
juniorConversations,
|
|
@@ -13,16 +15,38 @@ import {
|
|
|
13
15
|
juniorSchedulerRuns,
|
|
14
16
|
juniorSchedulerTasks,
|
|
15
17
|
juniorStats
|
|
16
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-LVK4WJKM.js";
|
|
17
19
|
import {
|
|
18
20
|
juniorDestinations
|
|
19
21
|
} from "./chunk-VFUK3X5B.js";
|
|
20
22
|
import {
|
|
21
23
|
getSlackBotToken
|
|
22
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-LRI5IRGY.js";
|
|
23
25
|
import {
|
|
24
26
|
logWarn
|
|
25
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-OMQ2J6F6.js";
|
|
28
|
+
|
|
29
|
+
// src/chat/resource-events/workspace.ts
|
|
30
|
+
function canRouteResourceEvents() {
|
|
31
|
+
return Boolean(getSlackBotToken());
|
|
32
|
+
}
|
|
33
|
+
function createResourceEventTeamIdResolver() {
|
|
34
|
+
let pending;
|
|
35
|
+
return async () => {
|
|
36
|
+
if (!canRouteResourceEvents()) return void 0;
|
|
37
|
+
pending ??= getSlackClient().auth.test().then((result) => {
|
|
38
|
+
const teamId = result.team_id?.trim();
|
|
39
|
+
if (!teamId) {
|
|
40
|
+
throw new Error("Slack auth.test did not return a workspace team id");
|
|
41
|
+
}
|
|
42
|
+
return teamId;
|
|
43
|
+
}).catch((error) => {
|
|
44
|
+
pending = void 0;
|
|
45
|
+
throw error;
|
|
46
|
+
});
|
|
47
|
+
return await pending;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
26
50
|
|
|
27
51
|
// src/chat/event-tasks/store.ts
|
|
28
52
|
import {
|
|
@@ -1250,6 +1274,8 @@ export {
|
|
|
1250
1274
|
registeredResourceEventMatchSchema,
|
|
1251
1275
|
requireSupportedResourceEventMatch,
|
|
1252
1276
|
normalizeEventIdentifier,
|
|
1277
|
+
canRouteResourceEvents,
|
|
1278
|
+
createResourceEventTeamIdResolver,
|
|
1253
1279
|
getResourceEventCatalog,
|
|
1254
1280
|
getEventTask,
|
|
1255
1281
|
createEventTask,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createAndEnqueueAgentInvocation
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-HJPC32TQ.js";
|
|
4
4
|
import {
|
|
5
5
|
actorFromRun,
|
|
6
6
|
toolInvocationDestination
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-INQHUE72.js";
|
|
8
8
|
|
|
9
9
|
// src/chat/agent-invocations/spawn.ts
|
|
10
10
|
function bindSpawnAgent(run, options) {
|