@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.
- package/dist/{agent-hooks-32IDCLMW.js → agent-hooks-DKDDRKZA.js} +16 -18
- package/dist/api/schema.js +0 -1
- package/dist/api.js +199 -197
- package/dist/app.d.ts +4 -0
- package/dist/app.js +300 -1259
- package/dist/catalog-runtime-WXKGUF3W.js +14 -0
- package/dist/chat/agent/sandbox.d.ts +0 -2
- package/dist/chat/api-turns/routing.d.ts +4 -0
- package/dist/chat/api-turns/work.d.ts +5 -0
- package/dist/chat/config.d.ts +5 -2
- package/dist/chat/configuration/defaults.d.ts +1 -1
- package/dist/chat/conversations/projection.d.ts +6 -4
- package/dist/chat/ingress/message-router.d.ts +3 -0
- package/dist/chat/model-profile.d.ts +8 -10
- package/dist/chat/pi/conversation-events.d.ts +3 -2
- package/dist/chat/plugins/task-queue.d.ts +40 -3
- package/dist/chat/plugins/task-runner.d.ts +1 -1
- package/dist/chat/queue/callback.d.ts +26 -0
- package/dist/chat/queue/sign.d.ts +30 -0
- package/dist/chat/sandbox/sandbox.d.ts +0 -2
- package/dist/chat/sandbox/session.d.ts +0 -2
- package/dist/chat/sandbox/skill-sync.d.ts +1 -1
- package/dist/chat/sandbox/snapshot/events.d.ts +23 -0
- package/dist/chat/sandbox/snapshot/job-callback.d.ts +5 -0
- package/dist/chat/sandbox/snapshot/job-queue.d.ts +26 -0
- package/dist/chat/sandbox/snapshot/job-runner.d.ts +11 -0
- package/dist/chat/sandbox/snapshot/not-ready-error.d.ts +6 -0
- package/dist/chat/sandbox/snapshot/workspace.d.ts +9 -3
- package/dist/chat/services/turn-router.d.ts +4 -3
- package/dist/chat/task-execution/queue-signing.d.ts +10 -21
- package/dist/chat/task-execution/state.d.ts +48 -0
- package/dist/chat/task-execution/store.d.ts +28 -2
- package/dist/chat/task-execution/worker.d.ts +4 -1
- package/dist/chat/tools/handoff/tool.d.ts +1 -1
- package/dist/{chunk-B6ECUSVX.js → chunk-2AYEVN7K.js} +8 -8
- package/dist/{chunk-SLGGOASN.js → chunk-2YIRH4E3.js} +46 -46
- package/dist/{chunk-KJLHIHFF.js → chunk-3ILJBWP7.js} +35 -227
- package/dist/{chunk-RZRYOLCE.js → chunk-5PUMIMNQ.js} +2292 -1147
- package/dist/{chunk-CJLBLELR.js → chunk-5TUR4M3M.js} +8 -61
- package/dist/{chunk-6ZWRNC4D.js → chunk-6Y5B5PEX.js} +1 -1
- package/dist/{chunk-XSPSCWLH.js → chunk-6YCEWOLO.js} +4 -4
- package/dist/chunk-7H2VZTWN.js +103 -0
- package/dist/{chunk-FAS6AIMF.js → chunk-CCDXTDSY.js} +8 -8
- package/dist/{chunk-CGA4ERJ5.js → chunk-CEMMLV5L.js} +1 -1
- package/dist/{chunk-XZY6G5YZ.js → chunk-CK6EINVZ.js} +180 -87
- package/dist/{chunk-FIANEE7Z.js → chunk-CM5HNV2W.js} +6 -6
- package/dist/{chunk-JT4WMD3C.js → chunk-CP73FKME.js} +144 -218
- package/dist/{chunk-3I7XE3PA.js → chunk-DHLOGWYH.js} +36 -36
- package/dist/chunk-DKIJ2RP5.js +68 -0
- package/dist/{chunk-YFNAMRGE.js → chunk-DRHEGXTZ.js} +1 -1
- package/dist/{chunk-OOUNJNMR.js → chunk-DWPN6SCH.js} +1 -1
- package/dist/chunk-EWHP2IRG.js +209 -0
- package/dist/{chunk-R6U7N4FS.js → chunk-FGC3PHNH.js} +3 -3
- package/dist/{chunk-3TM3FYLQ.js → chunk-GA5NS74S.js} +1 -1
- package/dist/{chunk-FIDMHAO6.js → chunk-GPXAHUQH.js} +84 -274
- package/dist/chunk-GUKXEPMX.js +218 -0
- package/dist/{chunk-GENV6KF2.js → chunk-I6IFTAPF.js} +108 -76
- package/dist/{chunk-R5NWWYIS.js → chunk-IANUX7HX.js} +5 -5
- package/dist/{chunk-G2CAC4CV.js → chunk-KCL6AWYW.js} +74 -68
- package/dist/{chunk-5IRROPA5.js → chunk-L7LTGN4Z.js} +129 -31
- package/dist/{chunk-Q5B3WTGG.js → chunk-LGVQLNLS.js} +42 -41
- package/dist/chunk-M3QYTBQ6.js +55 -0
- package/dist/{chunk-FTGD2FBP.js → chunk-MXEUIGHO.js} +2 -2
- package/dist/{chunk-M63DETLL.js → chunk-N7TMSOZH.js} +6 -6
- package/dist/{chunk-2HIPYNQI.js → chunk-O4QYZTDK.js} +33 -32
- package/dist/chunk-PEQXYSSE.js +45 -0
- package/dist/{chunk-RTRBYSF3.js → chunk-QSO7B5JO.js} +1 -1
- package/dist/{chunk-HQNE5APD.js → chunk-RAZG3YHC.js} +100 -79
- package/dist/{chunk-VP4OVRDD.js → chunk-S7YRTOSQ.js} +69 -73
- package/dist/{chunk-U4TKB6F6.js → chunk-SDBKZ5LV.js} +108 -5
- package/dist/{chunk-GPLAT6H7.js → chunk-TC5DE5KJ.js} +22 -18
- package/dist/{chunk-H4HBKISO.js → chunk-TXKUKMVO.js} +1 -1
- package/dist/chunk-U5EUCUBH.js +164 -0
- package/dist/{chunk-3AFVR5UC.js → chunk-VG722ONZ.js} +18 -16
- package/dist/{chunk-ZQMG3CL5.js → chunk-VGPPWWHF.js} +16 -16
- package/dist/{chunk-JMJNFEDC.js → chunk-WVAMRKYG.js} +9 -54
- package/dist/chunk-X6GDDWQH.js +60 -0
- package/dist/{chunk-4GWXAILB.js → chunk-ZE2KOV3G.js} +1 -1
- package/dist/{chunk-TIEKUH4Q.js → chunk-ZM7ZURJS.js} +4 -3
- package/dist/cli/chat.js +47 -43
- package/dist/cli/check.js +13 -15
- package/dist/cli/env.js +0 -1
- package/dist/cli/init.js +0 -1
- package/dist/cli/main.js +2 -3
- package/dist/cli/plugins.js +18 -20
- package/dist/cli/run.js +0 -1
- package/dist/cli/snapshot-create.js +14 -16
- package/dist/cli/upgrade.js +16 -18
- package/dist/{conversation-work-KATFHLG3.js → conversation-work-VIOQ5ZF3.js} +0 -2
- package/dist/{db-EJAV7JL6.js → db-6SBHIAJK.js} +8 -10
- package/dist/deployment.d.ts +1 -0
- package/dist/{discovery-GUFTFBTL.js → discovery-DWVDM7UK.js} +1 -2
- package/dist/{experimental-XVDOSRBS.js → experimental-SIJSRDJD.js} +0 -1
- package/dist/instrumentation.js +7 -9
- package/dist/nitro.js +39 -13
- package/dist/{oauth-callback-server-GAVSUBTQ.js → oauth-callback-server-WSDQPZZS.js} +34 -32
- package/dist/{oauth-relay-3ZU72UGL.js → oauth-relay-5XPVRPYB.js} +0 -1
- package/dist/{plugins-HW4VWW6G.js → plugins-YTYJMMJF.js} +1 -2
- package/dist/{runner-34JL64JF.js → runner-GWTSWESR.js} +39 -33
- package/dist/{sandbox-egress-signals-DXOOBSBI.js → sandbox-egress-signals-FIL7EGPR.js} +5 -6
- package/dist/{sentry-JMWTS32N.js → sentry-MB3NL3IR.js} +1 -2
- package/dist/skills-F32BPFYW.js +27 -0
- package/dist/spawn-X5BPP5OE.js +37 -0
- package/dist/task-runner-2FPBV5PP.js +32 -0
- package/dist/validation-62WO524A.js +17 -0
- package/dist/vercel.js +0 -1
- package/dist/version.js +1 -2
- package/dist/work-3C3CMZ24.js +45 -0
- package/dist/worker-MFAI6ZEK.js +22 -0
- package/package.json +8 -7
- package/dist/catalog-runtime-FBVA6WAQ.js +0 -16
- package/dist/chat/plugins/task-callback.d.ts +0 -5
- package/dist/chat/plugins/task-message.d.ts +0 -23
- package/dist/chat/plugins/task-signing.d.ts +0 -31
- package/dist/chat/sandbox/snapshot/waiting-error.d.ts +0 -15
- package/dist/chat/services/workspace-snapshot-wait.d.ts +0 -27
- package/dist/chunk-5I6ORJUY.js +0 -127
- package/dist/chunk-6GWA276C.js +0 -72
- package/dist/chunk-MLKGABMK.js +0 -9
- package/dist/chunk-UT6X7XN7.js +0 -51
- package/dist/chunk-WR76IVA5.js +0 -130
- package/dist/skills-U545HALM.js +0 -29
- package/dist/spawn-I2S4IDUQ.js +0 -37
- package/dist/validation-EVXVGA44.js +0 -19
- package/dist/work-QOAUPDBU.js +0 -45
- package/dist/worker-5GX2IKLZ.js +0 -24
|
@@ -1,28 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
coerceThreadConversationState,
|
|
3
|
-
getPersistedThreadState
|
|
4
|
-
|
|
5
|
-
} from "./chunk-CJLBLELR.js";
|
|
3
|
+
getPersistedThreadState
|
|
4
|
+
} from "./chunk-5TUR4M3M.js";
|
|
6
5
|
import {
|
|
7
6
|
pluginTaskId,
|
|
8
7
|
pluginTaskParamsSchema,
|
|
9
8
|
sendVercelPluginTask
|
|
10
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-U5EUCUBH.js";
|
|
11
10
|
import {
|
|
12
|
-
buildDeterministicTurnId,
|
|
13
|
-
clearPendingAuth,
|
|
14
11
|
getPiMessageRole,
|
|
15
12
|
getTurnRecord,
|
|
16
13
|
hydrateConversationMessages,
|
|
17
14
|
instructionTextForProjection,
|
|
18
15
|
isToolResultError,
|
|
19
16
|
isToolResultMessage,
|
|
20
|
-
markConversationMessage,
|
|
21
|
-
markTurnClosed,
|
|
22
|
-
markTurnCompleted,
|
|
23
17
|
normalizeToolNameFromResult,
|
|
24
18
|
stripRuntimeTurnContext
|
|
25
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-GPXAHUQH.js";
|
|
26
20
|
import {
|
|
27
21
|
createPluginConversationEvents,
|
|
28
22
|
createPluginEmbedder,
|
|
@@ -30,7 +24,7 @@ import {
|
|
|
30
24
|
createPluginModel,
|
|
31
25
|
createPluginState,
|
|
32
26
|
getPlugins
|
|
33
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-DHLOGWYH.js";
|
|
34
28
|
import {
|
|
35
29
|
JUNIOR_THREAD_STATE_TTL_MS
|
|
36
30
|
} from "./chunk-3Y47VMHV.js";
|
|
@@ -38,56 +32,30 @@ import {
|
|
|
38
32
|
getConversationStore,
|
|
39
33
|
getDb,
|
|
40
34
|
sameActorIdentity
|
|
41
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-S7YRTOSQ.js";
|
|
42
36
|
import {
|
|
43
37
|
juniorConversations,
|
|
44
38
|
juniorTaskExecutions
|
|
45
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-FGC3PHNH.js";
|
|
46
40
|
import {
|
|
47
41
|
getStateAdapter
|
|
48
|
-
} from "./chunk-
|
|
49
|
-
import {
|
|
50
|
-
ProviderError,
|
|
51
|
-
findProviderError,
|
|
52
|
-
getProviderErrorAttributes,
|
|
53
|
-
getProviderErrorUserMessage
|
|
54
|
-
} from "./chunk-GENV6KF2.js";
|
|
42
|
+
} from "./chunk-GA5NS74S.js";
|
|
55
43
|
import {
|
|
56
44
|
credentialSubjectSchema
|
|
57
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-CEMMLV5L.js";
|
|
58
46
|
import {
|
|
59
47
|
parseSlackMessageTs
|
|
60
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-N7TMSOZH.js";
|
|
61
49
|
import {
|
|
62
|
-
buildTurnFailureResponse,
|
|
63
50
|
logWarn
|
|
64
|
-
} from "./chunk-
|
|
65
|
-
|
|
66
|
-
// src/chat/runtime/delivered-turn-state.ts
|
|
67
|
-
function buildDeliveredTurnStatePatch(args) {
|
|
68
|
-
const conversation = structuredClone(args.conversation);
|
|
69
|
-
clearPendingAuth(conversation, args.sessionId);
|
|
70
|
-
markConversationMessage(conversation, args.userMessageId, {
|
|
71
|
-
replied: true,
|
|
72
|
-
skippedReason: void 0
|
|
73
|
-
});
|
|
74
|
-
markTurnCompleted({
|
|
75
|
-
conversation,
|
|
76
|
-
nowMs: Date.now(),
|
|
77
|
-
sessionId: args.sessionId
|
|
78
|
-
});
|
|
79
|
-
return {
|
|
80
|
-
conversation,
|
|
81
|
-
sandboxRef: args.reply.sandboxRef
|
|
82
|
-
};
|
|
83
|
-
}
|
|
51
|
+
} from "./chunk-RAZG3YHC.js";
|
|
84
52
|
|
|
85
53
|
// src/chat/plugins/task-runner.ts
|
|
86
54
|
import { pluginRunContextSchema } from "@sentry/junior-plugin-api";
|
|
87
55
|
|
|
88
56
|
// src/chat/services/turn-session-routing.ts
|
|
89
57
|
async function resolveTurnSessionRouting(args) {
|
|
90
|
-
const conversationStore = args.conversationStore ?? (await import("./db-
|
|
58
|
+
const conversationStore = args.conversationStore ?? (await import("./db-6SBHIAJK.js")).getConversationStore();
|
|
91
59
|
const conversation = await conversationStore.get({
|
|
92
60
|
conversationId: args.conversationId
|
|
93
61
|
});
|
|
@@ -148,7 +116,7 @@ async function recordTaskExecution(type, taskId, options) {
|
|
|
148
116
|
const status = options.status ?? "completed";
|
|
149
117
|
try {
|
|
150
118
|
await getDb().insert(juniorTaskExecutions).values({
|
|
151
|
-
...options.conversationId ? { conversationId: options.conversationId } :
|
|
119
|
+
...options.conversationId ? { conversationId: options.conversationId } : void 0,
|
|
152
120
|
executedAtMs: nowMs,
|
|
153
121
|
executionId: options.executionId,
|
|
154
122
|
kind: type,
|
|
@@ -205,8 +173,8 @@ async function readTaskExecutionSummaries(type, namespace, options = {}) {
|
|
|
205
173
|
rows.map((row) => [
|
|
206
174
|
row.taskId,
|
|
207
175
|
{
|
|
208
|
-
...row.lastConversationId ? { lastConversationId: row.lastConversationId } :
|
|
209
|
-
...row.lastExecutedAtMs !== null ? { lastExecutedAtMs: row.lastExecutedAtMs } :
|
|
176
|
+
...row.lastConversationId ? { lastConversationId: row.lastConversationId } : void 0,
|
|
177
|
+
...row.lastExecutedAtMs !== null ? { lastExecutedAtMs: row.lastExecutedAtMs } : void 0,
|
|
210
178
|
runsLast7Days: row.runsLast7Days,
|
|
211
179
|
totalRuns: row.totalRuns
|
|
212
180
|
}
|
|
@@ -290,11 +258,11 @@ async function readTaskExecutions(args) {
|
|
|
290
258
|
return rows.map((row) => {
|
|
291
259
|
const title = row.title?.trim();
|
|
292
260
|
return {
|
|
293
|
-
...row.conversationId ? { conversationId: row.conversationId } :
|
|
261
|
+
...row.conversationId ? { conversationId: row.conversationId } : void 0,
|
|
294
262
|
executedAt: new Date(row.executedAtMs).toISOString(),
|
|
295
263
|
executionId: row.executionId,
|
|
296
264
|
status: row.status,
|
|
297
|
-
...title ? { title } :
|
|
265
|
+
...title ? { title } : void 0
|
|
298
266
|
};
|
|
299
267
|
});
|
|
300
268
|
}
|
|
@@ -330,13 +298,13 @@ async function readTaskRuns(args) {
|
|
|
330
298
|
const title = row.title?.trim();
|
|
331
299
|
return [
|
|
332
300
|
{
|
|
333
|
-
...row.conversationId ? { conversationId: row.conversationId } :
|
|
301
|
+
...row.conversationId ? { conversationId: row.conversationId } : void 0,
|
|
334
302
|
executedAt: new Date(row.executedAtMs).toISOString(),
|
|
335
303
|
executionId: row.executionId,
|
|
336
304
|
kind: row.kind,
|
|
337
305
|
status: row.status,
|
|
338
306
|
taskId: row.taskId,
|
|
339
|
-
...title ? { title } :
|
|
307
|
+
...title ? { title } : void 0
|
|
340
308
|
}
|
|
341
309
|
];
|
|
342
310
|
});
|
|
@@ -499,8 +467,8 @@ function toDispatchProjection(record) {
|
|
|
499
467
|
return {
|
|
500
468
|
id: record.id,
|
|
501
469
|
status: record.status,
|
|
502
|
-
...record.resultMessageTs ? { resultMessageTs: record.resultMessageTs } :
|
|
503
|
-
...record.errorMessage ? { errorMessage: record.errorMessage } :
|
|
470
|
+
...record.resultMessageTs ? { resultMessageTs: record.resultMessageTs } : void 0,
|
|
471
|
+
...record.errorMessage ? { errorMessage: record.errorMessage } : void 0
|
|
504
472
|
};
|
|
505
473
|
}
|
|
506
474
|
function isTerminalDispatchStatus(status) {
|
|
@@ -580,15 +548,15 @@ async function createOrGetDispatch(args) {
|
|
|
580
548
|
const record = {
|
|
581
549
|
actor: { platform: "system", name: args.plugin },
|
|
582
550
|
createdAtMs: args.nowMs,
|
|
583
|
-
...args.options.credentialSubject ? { credentialSubject: args.options.credentialSubject } :
|
|
551
|
+
...args.options.credentialSubject ? { credentialSubject: args.options.credentialSubject } : void 0,
|
|
584
552
|
destination: args.options.destination,
|
|
585
553
|
destinationVisibility: args.options.destinationVisibility,
|
|
586
554
|
id,
|
|
587
555
|
idempotencyKey: args.options.idempotencyKey,
|
|
588
556
|
input: args.options.input,
|
|
589
|
-
...metadata ? { metadata } :
|
|
557
|
+
...metadata ? { metadata } : void 0,
|
|
590
558
|
plugin: args.plugin,
|
|
591
|
-
...args.options.replyAttribution ? { replyAttribution: args.options.replyAttribution } :
|
|
559
|
+
...args.options.replyAttribution ? { replyAttribution: args.options.replyAttribution } : void 0,
|
|
592
560
|
status: "pending",
|
|
593
561
|
source: args.options.source,
|
|
594
562
|
updatedAtMs: args.nowMs
|
|
@@ -644,7 +612,7 @@ async function recordEventTaskExecution(previous, next, status) {
|
|
|
644
612
|
const conversationId = getDispatchConversationId(next);
|
|
645
613
|
const conversation = await getConversationStore().get({ conversationId });
|
|
646
614
|
await recordTaskExecution("event", eventTaskId, {
|
|
647
|
-
...conversation ? { conversationId } :
|
|
615
|
+
...conversation ? { conversationId } : void 0,
|
|
648
616
|
executionId: next.id,
|
|
649
617
|
nowMs: next.updatedAtMs,
|
|
650
618
|
status
|
|
@@ -657,7 +625,7 @@ async function markDispatchBlocked(id, errorMessage, resultMessageTs) {
|
|
|
657
625
|
(record) => isTerminalDispatchStatus(record.status) ? record : {
|
|
658
626
|
...record,
|
|
659
627
|
errorMessage,
|
|
660
|
-
...resultMessageTs ? { resultMessageTs } :
|
|
628
|
+
...resultMessageTs ? { resultMessageTs } : void 0,
|
|
661
629
|
status: "blocked"
|
|
662
630
|
}
|
|
663
631
|
);
|
|
@@ -671,7 +639,7 @@ async function markDispatchCompleted(id, resultMessageTs) {
|
|
|
671
639
|
(record) => isTerminalDispatchStatus(record.status) ? record : {
|
|
672
640
|
...record,
|
|
673
641
|
errorMessage: void 0,
|
|
674
|
-
...resultMessageTs ? { resultMessageTs } :
|
|
642
|
+
...resultMessageTs ? { resultMessageTs } : void 0,
|
|
675
643
|
status: "completed"
|
|
676
644
|
}
|
|
677
645
|
);
|
|
@@ -685,7 +653,7 @@ async function markDispatchFailed(id, errorMessage, resultMessageTs) {
|
|
|
685
653
|
(record) => isTerminalDispatchStatus(record.status) ? record : {
|
|
686
654
|
...record,
|
|
687
655
|
errorMessage,
|
|
688
|
-
...resultMessageTs ? { resultMessageTs } :
|
|
656
|
+
...resultMessageTs ? { resultMessageTs } : void 0,
|
|
689
657
|
status: "failed"
|
|
690
658
|
}
|
|
691
659
|
);
|
|
@@ -766,7 +734,7 @@ function sanitizeText(text) {
|
|
|
766
734
|
function messageProvenance(provenance) {
|
|
767
735
|
return {
|
|
768
736
|
authority: provenance.authority,
|
|
769
|
-
...provenance.actor ? { actor: provenance.actor } :
|
|
737
|
+
...provenance.actor ? { actor: provenance.actor } : void 0
|
|
770
738
|
};
|
|
771
739
|
}
|
|
772
740
|
function runTranscriptEntry(message, provenance, runActor) {
|
|
@@ -799,7 +767,7 @@ function runTranscriptEntry(message, provenance, runActor) {
|
|
|
799
767
|
type: "toolResult",
|
|
800
768
|
toolName,
|
|
801
769
|
isError: isToolResultError(message),
|
|
802
|
-
...text ? { text } :
|
|
770
|
+
...text ? { text } : void 0
|
|
803
771
|
};
|
|
804
772
|
}
|
|
805
773
|
function turnMessagesWithProvenance(record) {
|
|
@@ -826,8 +794,8 @@ function slackContextAuthor(source, message) {
|
|
|
826
794
|
platform: "slack",
|
|
827
795
|
teamId: source.teamId,
|
|
828
796
|
userId,
|
|
829
|
-
...message.author?.userName ? { userName: message.author.userName } :
|
|
830
|
-
...message.author?.fullName ? { fullName: message.author.fullName } :
|
|
797
|
+
...message.author?.userName ? { userName: message.author.userName } : void 0,
|
|
798
|
+
...message.author?.fullName ? { fullName: message.author.fullName } : void 0
|
|
831
799
|
};
|
|
832
800
|
}
|
|
833
801
|
function slackTimestampMs(value) {
|
|
@@ -884,7 +852,7 @@ async function loadConversationContextTranscriptEntries(record, source, runActor
|
|
|
884
852
|
text,
|
|
885
853
|
provenance: {
|
|
886
854
|
authority: "context",
|
|
887
|
-
...author ? { actor: author } :
|
|
855
|
+
...author ? { actor: author } : void 0
|
|
888
856
|
},
|
|
889
857
|
isRunActor: sameActorIdentity(author, runActor)
|
|
890
858
|
});
|
|
@@ -939,7 +907,7 @@ async function loadPluginRun(params) {
|
|
|
939
907
|
// Derived from the full run provenance on the record, not the sliced or
|
|
940
908
|
// stripped transcript, so it reflects every committed instruction actor.
|
|
941
909
|
actors: record.actors,
|
|
942
|
-
...runActor ? { actor: runActor } :
|
|
910
|
+
...runActor ? { actor: runActor } : void 0,
|
|
943
911
|
runId: record.turnId,
|
|
944
912
|
source: routing.source,
|
|
945
913
|
transcript: [...contextEntries, ...runEntries]
|
|
@@ -1025,155 +993,6 @@ async function processPluginTask(message, options = {}) {
|
|
|
1025
993
|
});
|
|
1026
994
|
}
|
|
1027
995
|
|
|
1028
|
-
// src/chat/interruption-marker.ts
|
|
1029
|
-
var INTERRUPTED_MARKER = "\n\n[Response interrupted before completion]";
|
|
1030
|
-
function getInterruptionMarker() {
|
|
1031
|
-
return INTERRUPTED_MARKER;
|
|
1032
|
-
}
|
|
1033
|
-
|
|
1034
|
-
// src/chat/services/turn-failure-response.ts
|
|
1035
|
-
function requireTurnFailureEventId(eventId, eventName) {
|
|
1036
|
-
if (!eventId) {
|
|
1037
|
-
throw new Error(`Sentry did not return an event ID for ${eventName}`);
|
|
1038
|
-
}
|
|
1039
|
-
return eventId;
|
|
1040
|
-
}
|
|
1041
|
-
function getExecutionFailureReason(reply) {
|
|
1042
|
-
const errorMessage = reply.diagnostics.errorMessage?.trim();
|
|
1043
|
-
if (errorMessage) {
|
|
1044
|
-
return errorMessage;
|
|
1045
|
-
}
|
|
1046
|
-
if (reply.diagnostics.toolErrorCount > 0) {
|
|
1047
|
-
return `${reply.diagnostics.toolErrorCount} tool result error(s)`;
|
|
1048
|
-
}
|
|
1049
|
-
if (reply.diagnostics.assistantMessageCount > 0) {
|
|
1050
|
-
return "assistant returned no text";
|
|
1051
|
-
}
|
|
1052
|
-
return "empty assistant turn";
|
|
1053
|
-
}
|
|
1054
|
-
function getFailureCapture(reply) {
|
|
1055
|
-
if (reply.diagnostics.outcome === "provider_error") {
|
|
1056
|
-
const providerError = findProviderError(reply.diagnostics.providerError);
|
|
1057
|
-
return {
|
|
1058
|
-
eventName: "agent.turn.provider_error",
|
|
1059
|
-
error: reply.diagnostics.providerError ?? new Error(
|
|
1060
|
-
reply.diagnostics.errorMessage ?? "Provider error without explicit message"
|
|
1061
|
-
),
|
|
1062
|
-
attributes: providerError ? getProviderErrorAttributes(providerError) : {},
|
|
1063
|
-
body: "Agent turn failed with provider error"
|
|
1064
|
-
};
|
|
1065
|
-
}
|
|
1066
|
-
const failureReason = getExecutionFailureReason(reply);
|
|
1067
|
-
return {
|
|
1068
|
-
eventName: "agent.turn.execution.failed",
|
|
1069
|
-
error: new Error(`Agent turn execution failure: ${failureReason}`),
|
|
1070
|
-
attributes: {
|
|
1071
|
-
"app.ai.execution_failure_reason": failureReason
|
|
1072
|
-
},
|
|
1073
|
-
body: "Agent turn completed with execution failure"
|
|
1074
|
-
};
|
|
1075
|
-
}
|
|
1076
|
-
function getAgentTurnDiagnosticsAttributes(reply) {
|
|
1077
|
-
return {
|
|
1078
|
-
"app.ai.outcome": reply.diagnostics.outcome,
|
|
1079
|
-
"app.ai.assistant_messages": reply.diagnostics.assistantMessageCount,
|
|
1080
|
-
"app.ai.tool_results": reply.diagnostics.toolResultCount,
|
|
1081
|
-
"app.ai.tool_error_results": reply.diagnostics.toolErrorCount,
|
|
1082
|
-
"app.ai.tool_call_count": reply.diagnostics.toolCalls.length,
|
|
1083
|
-
"app.ai.used_primary_text": reply.diagnostics.usedPrimaryText,
|
|
1084
|
-
...reply.diagnostics.reasoningLevel ? {
|
|
1085
|
-
"gen_ai.request.reasoning.level": reply.diagnostics.reasoningLevel
|
|
1086
|
-
} : {},
|
|
1087
|
-
...reply.diagnostics.stopReason ? {
|
|
1088
|
-
"gen_ai.response.finish_reasons": [reply.diagnostics.stopReason]
|
|
1089
|
-
} : {},
|
|
1090
|
-
...reply.diagnostics.errorMessage && reply.diagnostics.outcome !== "provider_error" ? { "exception.message": reply.diagnostics.errorMessage } : {}
|
|
1091
|
-
};
|
|
1092
|
-
}
|
|
1093
|
-
function finalizeFailedTurnReplyWithEvent(args) {
|
|
1094
|
-
if (args.reply.diagnostics.outcome === "success") {
|
|
1095
|
-
return { reply: args.reply };
|
|
1096
|
-
}
|
|
1097
|
-
const capture = getFailureCapture(args.reply);
|
|
1098
|
-
const eventId = requireTurnFailureEventId(
|
|
1099
|
-
args.logException(capture.error, capture.eventName, {
|
|
1100
|
-
...getAgentTurnDiagnosticsAttributes(args.reply),
|
|
1101
|
-
...args.attributes,
|
|
1102
|
-
...capture.attributes
|
|
1103
|
-
}),
|
|
1104
|
-
capture.eventName
|
|
1105
|
-
);
|
|
1106
|
-
const providerPartialText = args.reply.diagnostics.outcome === "provider_error" && args.reply.diagnostics.assistantMessageCount > 0 ? args.reply.text.trim() : "";
|
|
1107
|
-
const providerUserMessage = args.reply.diagnostics.providerError instanceof ProviderError ? getProviderErrorUserMessage(args.reply.diagnostics.providerError) : "";
|
|
1108
|
-
const failureText = providerUserMessage ? `${providerUserMessage} Reference: \`event_id=${eventId}\`.` : buildTurnFailureResponse(eventId);
|
|
1109
|
-
return {
|
|
1110
|
-
eventId,
|
|
1111
|
-
reply: {
|
|
1112
|
-
...args.reply,
|
|
1113
|
-
text: providerPartialText ? `${providerPartialText}${getInterruptionMarker()}` : failureText
|
|
1114
|
-
}
|
|
1115
|
-
};
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
|
-
// src/chat/runtime/turn-user-message.ts
|
|
1119
|
-
function getTurnUserMessage(conversation, sessionId) {
|
|
1120
|
-
for (let index = conversation.messages.length - 1; index >= 0; index -= 1) {
|
|
1121
|
-
const message = conversation.messages[index];
|
|
1122
|
-
if (message?.role !== "user") {
|
|
1123
|
-
continue;
|
|
1124
|
-
}
|
|
1125
|
-
if (buildDeterministicTurnId(message.id) === sessionId) {
|
|
1126
|
-
return message;
|
|
1127
|
-
}
|
|
1128
|
-
}
|
|
1129
|
-
return void 0;
|
|
1130
|
-
}
|
|
1131
|
-
function getTurnUserMessageId(conversation, sessionId) {
|
|
1132
|
-
return getTurnUserMessage(conversation, sessionId)?.id;
|
|
1133
|
-
}
|
|
1134
|
-
function getTurnUserSlackMessageTs(message) {
|
|
1135
|
-
return parseSlackMessageTs(message?.meta?.slackTs);
|
|
1136
|
-
}
|
|
1137
|
-
function getTurnUserReplyAttachmentContext(message) {
|
|
1138
|
-
const inboundAttachmentCount = message?.meta?.attachmentCount ?? 0;
|
|
1139
|
-
const imageAttachmentCount = message?.meta?.imageAttachmentCount ?? 0;
|
|
1140
|
-
const imagesHydrated = message?.meta?.imagesHydrated === true;
|
|
1141
|
-
return {
|
|
1142
|
-
...inboundAttachmentCount > 0 ? { inboundAttachmentCount } : {},
|
|
1143
|
-
...!imagesHydrated && imageAttachmentCount > 0 ? { omittedImageAttachmentCount: imageAttachmentCount } : {}
|
|
1144
|
-
};
|
|
1145
|
-
}
|
|
1146
|
-
|
|
1147
|
-
// src/chat/runtime/auth-pause-state.ts
|
|
1148
|
-
function completeAuthPauseTurn(args) {
|
|
1149
|
-
markConversationMessage(
|
|
1150
|
-
args.conversation,
|
|
1151
|
-
getTurnUserMessageId(args.conversation, args.sessionId),
|
|
1152
|
-
{
|
|
1153
|
-
replied: true,
|
|
1154
|
-
skippedReason: void 0
|
|
1155
|
-
}
|
|
1156
|
-
);
|
|
1157
|
-
markTurnClosed({
|
|
1158
|
-
conversation: args.conversation,
|
|
1159
|
-
nowMs: Date.now(),
|
|
1160
|
-
sessionId: args.sessionId
|
|
1161
|
-
});
|
|
1162
|
-
}
|
|
1163
|
-
async function persistAuthPauseTurnState(args) {
|
|
1164
|
-
const currentState = await getPersistedThreadState(args.threadStateId);
|
|
1165
|
-
const conversation = coerceThreadConversationState(currentState);
|
|
1166
|
-
await hydrateConversationMessages({
|
|
1167
|
-
conversation,
|
|
1168
|
-
conversationId: args.threadStateId
|
|
1169
|
-
});
|
|
1170
|
-
completeAuthPauseTurn({
|
|
1171
|
-
conversation,
|
|
1172
|
-
sessionId: args.sessionId
|
|
1173
|
-
});
|
|
1174
|
-
await persistThreadStateById(args.threadStateId, { conversation });
|
|
1175
|
-
}
|
|
1176
|
-
|
|
1177
996
|
export {
|
|
1178
997
|
recordTaskExecution,
|
|
1179
998
|
readTaskExecutionSummaries,
|
|
@@ -1197,18 +1016,7 @@ export {
|
|
|
1197
1016
|
listPendingDispatchMailboxAppends,
|
|
1198
1017
|
claimDispatchMailboxAppend,
|
|
1199
1018
|
getPluginDispatchProjection,
|
|
1200
|
-
buildDeliveredTurnStatePatch,
|
|
1201
|
-
getTurnUserMessage,
|
|
1202
|
-
getTurnUserMessageId,
|
|
1203
|
-
getTurnUserSlackMessageTs,
|
|
1204
|
-
getTurnUserReplyAttachmentContext,
|
|
1205
1019
|
resolveTurnSessionRouting,
|
|
1206
1020
|
scheduleSessionCompletedPluginTasks,
|
|
1207
|
-
processPluginTask
|
|
1208
|
-
getInterruptionMarker,
|
|
1209
|
-
requireTurnFailureEventId,
|
|
1210
|
-
getAgentTurnDiagnosticsAttributes,
|
|
1211
|
-
finalizeFailedTurnReplyWithEvent,
|
|
1212
|
-
completeAuthPauseTurn,
|
|
1213
|
-
persistAuthPauseTurnState
|
|
1021
|
+
processPluginTask
|
|
1214
1022
|
};
|