@sentry/junior 0.223.0 → 0.225.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-DZU5nsd1.js → agent-hooks-CRuRcOg9.js} +9 -9
- package/dist/{agent-Bzbf92vv.js → agent-runner-Cad1RtWn.js} +1016 -144
- package/dist/api/schema.js +2 -2
- package/dist/api.js +16 -16
- package/dist/app.js +1538 -71
- package/dist/{briefs-BJPfCrlT.js → briefs-BtnkPWT5.js} +5 -5
- package/dist/{catalog-runtime-BthunUDD.js → catalog-runtime-pv4grNNb.js} +1 -1
- package/dist/{checkpoint-Deu-OVb3.js → checkpoint-6fkAdB3g.js} +8 -8
- package/dist/cli/chat.js +14 -15
- package/dist/cli/check.js +3 -3
- package/dist/cli/main.js +1 -1
- package/dist/cli/plugins.js +3 -3
- package/dist/cli/snapshot-create.js +3 -3
- package/dist/cli/upgrade.js +3 -3
- package/dist/{client-DjC6-6iU.js → client-ihmkx60d.js} +2 -2
- package/dist/{config-CtoUVs72.js → config-DMg679BW.js} +11 -13
- package/dist/{conversation-1HUoZr2l.js → conversation-Bygi39Xj.js} +1 -1
- package/dist/{conversation-privacy-xS1t92xa.js → conversation-privacy-ZYy05Y3q.js} +1 -1
- package/dist/credential-sync-DCB2SwnQ.js +940 -0
- package/dist/{execution-stats-CrXs9vSH.js → execution-stats-CR9CYpyj.js} +3 -3
- package/dist/{executor-AOhG9X1t.js → executor-B9R4cHte.js} +1 -1
- package/dist/instrumentation.js +2 -2
- package/dist/{job-queue-CNd9cpIy.js → job-queue-D2SiTrnt.js} +1 -1
- package/dist/{logging-DiN3o3nB.js → logging-CcTvYQ8A.js} +2 -2
- package/dist/{model-profile-CZmVoGdX.js → model-profile-BwU8mqwD.js} +14 -1
- package/dist/nitro.js +3 -3
- package/dist/{pending-auth-D7vmttn_.js → oauth-authorization-BS4vPJmu.js} +6 -48
- package/dist/{oauth-callback-server-Ca0VLUEw.js → oauth-callback-server-DnlQsGBJ.js} +4 -4
- package/dist/{profile-BsNrw8lj.js → profile-CV97YuiL.js} +5 -9
- package/dist/{prompt-90miy8VV.js → prompt-CL8zxsmm.js} +1 -1
- package/dist/{registry-Dankt-Pl.js → registry-C8I4IejN.js} +3 -3
- package/dist/{resolve-B38CpJe2.js → resolve-DXVAzYa3.js} +2 -2
- package/dist/{runner-Ck5rEjCm.js → runner-Die1RJ_z.js} +9 -10
- package/dist/{sandbox-egress-signals-BOfFkvly.js → sandbox-egress-signals-BZepyVh1.js} +1 -1
- package/dist/{schema-RpbW5Od2.js → schema-BE4uso4i.js} +1 -1
- package/dist/{short-title-BHd_jUFX.js → short-title-3wYH3ipl.js} +11 -5
- package/dist/{skills-DbP4TDft.js → skills-DUcDEgDI.js} +2 -2
- package/dist/{spawn-DzXc_PKO.js → spawn-o15i3tJu.js} +2 -2
- package/dist/{stats-pNGp3G5q.js → stats-DawHjcTw.js} +6 -6
- package/dist/{task-queue-Cy9y1foT.js → task-queue-D3PLY59C.js} +3 -3
- package/dist/{task-runner-DI1FBJFJ.js → task-runner-BMl2aM2v.js} +9 -84
- package/dist/{thread-state-DXgxOYpZ.js → thread-state-CAR6gdAm.js} +5 -5
- package/dist/{auth-pause-state-Bn2vX4PA.js → turn-failure-response-CZyoUMkD.js} +74 -73
- package/dist/{turn-lifecycle-Bjf6y2GO.js → turn-lifecycle-DPDHKi2U.js} +1 -1
- package/dist/turn-session-routing-Jkmmxpp-.js +77 -0
- package/dist/{validation-D5CIslEu.js → validation-BcGGxOa6.js} +1 -1
- package/dist/{version-_ZQFlslB.js → version-DYcuOFQb.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{web-authorization-6mmfS_o-.js → web-authorization-B09B8A8R.js} +1 -1
- package/dist/{web-input-BJpWm6go.js → web-input-CGE58TpK.js} +7 -7
- package/dist/{work-DvIlJR3C.js → work-Bm90pR9P.js} +52 -10
- package/dist/{worker-D1qidg-Y.js → worker-BvHr6JhE.js} +5 -5
- package/package.json +4 -4
- package/dist/agent-runner-2VQ9WhkG.js +0 -679
- package/dist/credential-sync-CKdXEUDO.js +0 -2811
- package/dist/experimental-CIXf7Uye.js +0 -46
- package/dist/turn-execution-BNOXrZ-M.js +0 -47
|
@@ -1,12 +1,52 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { y as clearPendingAuth } from "./agent-runner-Cad1RtWn.js";
|
|
2
|
+
import { _ as findProviderError, h as ProviderError, v as getProviderErrorAttributes, y as getProviderErrorUserMessage } from "./client-ihmkx60d.js";
|
|
3
|
+
import { I as isRecord, t as buildTurnFailureResponse } from "./logging-CcTvYQ8A.js";
|
|
3
4
|
import { _ as parseSlackMessageTs } from "./context-Bplcgypl.js";
|
|
4
|
-
import { Wt as getConversationEventStore } from "./agent-hooks-
|
|
5
|
-
import { A as messageCardKey, N as readMessageCards, j as messageCardRefSchema } from "./conversation-
|
|
6
|
-
import {
|
|
7
|
-
import { qt as buildDeterministicTurnId } from "./stats-
|
|
8
|
-
import {
|
|
9
|
-
import { o as persistThreadStateById, r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-
|
|
5
|
+
import { Wt as getConversationEventStore } from "./agent-hooks-CRuRcOg9.js";
|
|
6
|
+
import { A as messageCardKey, N as readMessageCards, j as messageCardRefSchema } from "./conversation-Bygi39Xj.js";
|
|
7
|
+
import { J as hydrateConversationMessages, at as markConversationMessage } from "./checkpoint-6fkAdB3g.js";
|
|
8
|
+
import { qt as buildDeterministicTurnId } from "./stats-DawHjcTw.js";
|
|
9
|
+
import { g as markTurnCompleted, h as markTurnClosed } from "./oauth-authorization-BS4vPJmu.js";
|
|
10
|
+
import { o as persistThreadStateById, r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-CAR6gdAm.js";
|
|
11
|
+
//#region src/chat/conversations/pending-cards.ts
|
|
12
|
+
/** Read undelivered card snapshots across resume and history replacement. */
|
|
13
|
+
async function loadPendingMessageCards(conversationId) {
|
|
14
|
+
const cards = /* @__PURE__ */ new Map();
|
|
15
|
+
const deleted = /* @__PURE__ */ new Set();
|
|
16
|
+
let beforeSeq;
|
|
17
|
+
while (true) {
|
|
18
|
+
const page = await getConversationEventStore().query(conversationId, {
|
|
19
|
+
beforeSeq,
|
|
20
|
+
limit: 100,
|
|
21
|
+
types: [
|
|
22
|
+
"tool_result",
|
|
23
|
+
"message",
|
|
24
|
+
"turn_started"
|
|
25
|
+
]
|
|
26
|
+
});
|
|
27
|
+
for (const event of [...page.events].reverse()) {
|
|
28
|
+
const data = event.data;
|
|
29
|
+
if (data.type === "turn_started" || data.type === "message" && data.role === "assistant") return [...cards.values()].reverse();
|
|
30
|
+
if (data.type !== "tool_result" || data.isError || typeof data.toolName !== "string" || !isRecord(data.details)) continue;
|
|
31
|
+
if (data.details.timed_out === true) continue;
|
|
32
|
+
if (Array.isArray(data.details.removedCards)) for (const ref of messageCardRefSchema.array().parse(data.details.removedCards)) deleted.add(JSON.stringify([ref.plugin, ref.key]));
|
|
33
|
+
for (const card of readMessageCards(data.details)) {
|
|
34
|
+
const key = messageCardKey(card);
|
|
35
|
+
if (!deleted.has(key) && !cards.has(key)) cards.set(key, card);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (!page.hasOlder || page.events.length === 0) return [...cards.values()].reverse();
|
|
39
|
+
beforeSeq = page.events[0].seq;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/chat/interruption-marker.ts
|
|
44
|
+
const INTERRUPTED_MARKER = "\n\n[Response interrupted before completion]";
|
|
45
|
+
/** Return the marker added when a visible reply ended mid-execution. */
|
|
46
|
+
function getInterruptionMarker() {
|
|
47
|
+
return INTERRUPTED_MARKER;
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
10
50
|
//#region src/chat/runtime/delivered-turn-state.ts
|
|
11
51
|
/** Build state after destination delivery or intentional no-reply completion. */
|
|
12
52
|
function buildDeliveredTurnStatePatch(args) {
|
|
@@ -55,43 +95,32 @@ function getTurnUserReplyAttachmentContext(message) {
|
|
|
55
95
|
};
|
|
56
96
|
}
|
|
57
97
|
//#endregion
|
|
58
|
-
//#region src/chat/
|
|
59
|
-
/**
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"message",
|
|
71
|
-
"turn_started"
|
|
72
|
-
]
|
|
73
|
-
});
|
|
74
|
-
for (const event of [...page.events].reverse()) {
|
|
75
|
-
const data = event.data;
|
|
76
|
-
if (data.type === "turn_started" || data.type === "message" && data.role === "assistant") return [...cards.values()].reverse();
|
|
77
|
-
if (data.type !== "tool_result" || data.isError || typeof data.toolName !== "string" || !isRecord(data.details)) continue;
|
|
78
|
-
if (data.details.timed_out === true) continue;
|
|
79
|
-
if (Array.isArray(data.details.removedCards)) for (const ref of messageCardRefSchema.array().parse(data.details.removedCards)) deleted.add(JSON.stringify([ref.plugin, ref.key]));
|
|
80
|
-
for (const card of readMessageCards(data.details)) {
|
|
81
|
-
const key = messageCardKey(card);
|
|
82
|
-
if (!deleted.has(key) && !cards.has(key)) cards.set(key, card);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
if (!page.hasOlder || page.events.length === 0) return [...cards.values()].reverse();
|
|
86
|
-
beforeSeq = page.events[0].seq;
|
|
87
|
-
}
|
|
98
|
+
//#region src/chat/runtime/auth-pause-state.ts
|
|
99
|
+
/** Mark an auth-paused turn complete after private authorization link delivery. */
|
|
100
|
+
function completeAuthPauseTurn(args) {
|
|
101
|
+
markConversationMessage(args.conversation, getTurnUserMessageId(args.conversation, args.sessionId), {
|
|
102
|
+
replied: true,
|
|
103
|
+
skippedReason: void 0
|
|
104
|
+
});
|
|
105
|
+
markTurnClosed({
|
|
106
|
+
conversation: args.conversation,
|
|
107
|
+
nowMs: Date.now(),
|
|
108
|
+
sessionId: args.sessionId
|
|
109
|
+
});
|
|
88
110
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
111
|
+
/** Reload thread state, mark the auth pause as parked, and persist it. */
|
|
112
|
+
async function persistAuthPauseTurnState(args) {
|
|
113
|
+
const currentState = await getPersistedThreadState(args.threadStateId);
|
|
114
|
+
const conversation = coerceThreadConversationState(currentState);
|
|
115
|
+
await hydrateConversationMessages({
|
|
116
|
+
conversation,
|
|
117
|
+
conversationId: args.threadStateId
|
|
118
|
+
});
|
|
119
|
+
completeAuthPauseTurn({
|
|
120
|
+
conversation,
|
|
121
|
+
sessionId: args.sessionId
|
|
122
|
+
});
|
|
123
|
+
await persistThreadStateById(args.threadStateId, { conversation });
|
|
95
124
|
}
|
|
96
125
|
//#endregion
|
|
97
126
|
//#region src/chat/services/turn-failure-response.ts
|
|
@@ -171,32 +200,4 @@ function finalizeFailedTurnReplyWithEvent(args) {
|
|
|
171
200
|
};
|
|
172
201
|
}
|
|
173
202
|
//#endregion
|
|
174
|
-
|
|
175
|
-
/** Mark an auth-paused turn complete after private authorization link delivery. */
|
|
176
|
-
function completeAuthPauseTurn(args) {
|
|
177
|
-
markConversationMessage(args.conversation, getTurnUserMessageId(args.conversation, args.sessionId), {
|
|
178
|
-
replied: true,
|
|
179
|
-
skippedReason: void 0
|
|
180
|
-
});
|
|
181
|
-
markTurnClosed({
|
|
182
|
-
conversation: args.conversation,
|
|
183
|
-
nowMs: Date.now(),
|
|
184
|
-
sessionId: args.sessionId
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
/** Reload thread state, mark the auth pause as parked, and persist it. */
|
|
188
|
-
async function persistAuthPauseTurnState(args) {
|
|
189
|
-
const currentState = await getPersistedThreadState(args.threadStateId);
|
|
190
|
-
const conversation = coerceThreadConversationState(currentState);
|
|
191
|
-
await hydrateConversationMessages({
|
|
192
|
-
conversation,
|
|
193
|
-
conversationId: args.threadStateId
|
|
194
|
-
});
|
|
195
|
-
completeAuthPauseTurn({
|
|
196
|
-
conversation,
|
|
197
|
-
sessionId: args.sessionId
|
|
198
|
-
});
|
|
199
|
-
await persistThreadStateById(args.threadStateId, { conversation });
|
|
200
|
-
}
|
|
201
|
-
//#endregion
|
|
202
|
-
export { requireTurnFailureEventId as a, getTurnUserMessage as c, getTurnUserSlackMessageTs as d, buildDeliveredTurnStatePatch as f, getAgentTurnDiagnosticsAttributes as i, getTurnUserMessageId as l, persistAuthPauseTurnState as n, getInterruptionMarker as o, finalizeFailedTurnReplyWithEvent as r, loadPendingMessageCards as s, completeAuthPauseTurn as t, getTurnUserReplyAttachmentContext as u };
|
|
203
|
+
export { persistAuthPauseTurnState as a, getTurnUserSlackMessageTs as c, loadPendingMessageCards as d, completeAuthPauseTurn as i, buildDeliveredTurnStatePatch as l, getAgentTurnDiagnosticsAttributes as n, getTurnUserMessage as o, requireTurnFailureEventId as r, getTurnUserReplyAttachmentContext as s, finalizeFailedTurnReplyWithEvent as t, getInterruptionMarker as u };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Wt as getConversationEventStore } from "./agent-hooks-
|
|
1
|
+
import { Wt as getConversationEventStore } from "./agent-hooks-CRuRcOg9.js";
|
|
2
2
|
//#region src/chat/conversations/turn-lifecycle.ts
|
|
3
3
|
/** Persist correlated turn lifecycle facts with retry-safe terminal exclusion. */
|
|
4
4
|
var ConversationTurnLifecycleService = class {
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
//#region src/chat/services/turn-session-routing.ts
|
|
2
|
+
async function loadConversationChain(conversationId, conversationStore) {
|
|
3
|
+
const chain = [];
|
|
4
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5
|
+
let cursor = conversationId;
|
|
6
|
+
while (cursor && !seen.has(cursor)) {
|
|
7
|
+
seen.add(cursor);
|
|
8
|
+
const conversation = await conversationStore.get({ conversationId: cursor });
|
|
9
|
+
if (!conversation) break;
|
|
10
|
+
chain.push(conversation);
|
|
11
|
+
cursor = conversation.parentConversationId;
|
|
12
|
+
}
|
|
13
|
+
return chain;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Normalize a stored Slack session source against the conversation destination.
|
|
17
|
+
*
|
|
18
|
+
* Does not create channel or thread values from the conversation id.
|
|
19
|
+
*/
|
|
20
|
+
function slackSourceForDestination(args) {
|
|
21
|
+
if (args.source?.kind !== "slack" || args.source.channelId !== args.destination.channelId) return;
|
|
22
|
+
const threadTs = args.source.threadTs?.trim();
|
|
23
|
+
return {
|
|
24
|
+
kind: "slack",
|
|
25
|
+
visibility: args.source.visibility ?? "public",
|
|
26
|
+
teamId: args.source.teamId?.trim() || args.destination.teamId,
|
|
27
|
+
channelId: args.source.channelId,
|
|
28
|
+
...threadTs ? { threadTs } : void 0
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Resolve the Conversation Location, Destination, and session Source.
|
|
33
|
+
*
|
|
34
|
+
* Reads parent Conversations when this Conversation has no Destination.
|
|
35
|
+
*/
|
|
36
|
+
async function resolveConversationRouting(args) {
|
|
37
|
+
const conversationStore = args.conversationStore ?? (await import("./agent-hooks-CRuRcOg9.js").then((n) => n.Ut)).getConversationStore();
|
|
38
|
+
const chain = await loadConversationChain(args.conversationId, conversationStore);
|
|
39
|
+
let destination;
|
|
40
|
+
let source;
|
|
41
|
+
let location;
|
|
42
|
+
for (const conversation of chain) {
|
|
43
|
+
destination ??= conversation.destination;
|
|
44
|
+
source ??= conversation.sessionSource;
|
|
45
|
+
location ??= conversation.location;
|
|
46
|
+
if (destination && source) break;
|
|
47
|
+
}
|
|
48
|
+
if (!destination) return;
|
|
49
|
+
if (destination.platform === "slack") {
|
|
50
|
+
const slackSource = slackSourceForDestination({
|
|
51
|
+
destination,
|
|
52
|
+
source
|
|
53
|
+
});
|
|
54
|
+
return {
|
|
55
|
+
destination,
|
|
56
|
+
...location ? { location } : void 0,
|
|
57
|
+
...slackSource ? { source: slackSource } : void 0
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
destination,
|
|
62
|
+
...location ? { location } : void 0,
|
|
63
|
+
...source ? { source } : void 0
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/** Require the Conversation Destination and Source from SQL. */
|
|
67
|
+
async function resolveTurnSessionRouting(args) {
|
|
68
|
+
const routing = await resolveConversationRouting(args);
|
|
69
|
+
if (!routing?.destination || !routing.source) throw new Error(`Conversation ${args.conversationId} is missing durable routing metadata`);
|
|
70
|
+
return {
|
|
71
|
+
destination: routing.destination,
|
|
72
|
+
...routing.location ? { location: routing.location } : void 0,
|
|
73
|
+
source: routing.source
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
export { resolveTurnSessionRouting as n, resolveConversationRouting as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
|
|
2
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime-
|
|
2
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-pv4grNNb.js";
|
|
3
3
|
import { isDeepStrictEqual } from "node:util";
|
|
4
4
|
//#region src/chat/plugins/validation.ts
|
|
5
5
|
var validation_exports = /* @__PURE__ */ __exportAll({
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as JUNIOR_VERSION } from "./version-
|
|
1
|
+
import { t as JUNIOR_VERSION } from "./version-DYcuOFQb.js";
|
|
2
2
|
export { JUNIOR_VERSION };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { w as getStateAdapter } from "./profile-
|
|
1
|
+
import { w as getStateAdapter } from "./profile-CV97YuiL.js";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
//#region src/chat/conversations/web-authorization.ts
|
|
4
4
|
const WEB_AUTHORIZATION_PREFIX = "junior:web_authorization:v1";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { s as getSlackBotToken } from "./config-
|
|
1
|
+
import { p as logWarn } from "./logging-CcTvYQ8A.js";
|
|
2
|
+
import { s as getSlackBotToken } from "./config-DMg679BW.js";
|
|
3
3
|
import "./context-Bplcgypl.js";
|
|
4
|
-
import { K as normalizeSlackConversationId, Kt as getConversationStore, qt as getDb } from "./agent-hooks-
|
|
4
|
+
import { K as normalizeSlackConversationId, Kt as getConversationStore, qt as getDb } from "./agent-hooks-CRuRcOg9.js";
|
|
5
5
|
import { n as juniorDestinations } from "./destinations-BeBiJeEM.js";
|
|
6
|
-
import { D as juniorIdentities, O as juniorUsers, o as juniorSchedulerTasks } from "./executor-
|
|
7
|
-
import { t as fallbackShortTitle } from "./short-title-
|
|
8
|
-
import { A as eventAutomationTriggerAvailable, F as effectiveTaskOutcomes, G as listDeletedEventAutomationsCreatedBy, H as eventAutomationBelongsToUser, J as listPublicEventAutomationsForTeams, K as listEventAutomationsCreatedBy, V as deleteEventAutomation, W as getEventAutomation, X as getEventCatalog, _ as parseScheduledAutomationRow, c as parseSlackThreadId, ft as appendAndEnqueueExclusiveInboundMessage, m as listPublicScheduledAutomationsForTeams, p as isListedScheduledAutomation, pt as appendAndEnqueueInboundMessage, qt as buildDeterministicTurnId, v as readScheduledAutomation, y as saveScheduledAutomation } from "./stats-
|
|
6
|
+
import { D as juniorIdentities, O as juniorUsers, o as juniorSchedulerTasks } from "./executor-B9R4cHte.js";
|
|
7
|
+
import { t as fallbackShortTitle } from "./short-title-3wYH3ipl.js";
|
|
8
|
+
import { A as eventAutomationTriggerAvailable, F as effectiveTaskOutcomes, G as listDeletedEventAutomationsCreatedBy, H as eventAutomationBelongsToUser, J as listPublicEventAutomationsForTeams, K as listEventAutomationsCreatedBy, V as deleteEventAutomation, W as getEventAutomation, X as getEventCatalog, _ as parseScheduledAutomationRow, c as parseSlackThreadId, ft as appendAndEnqueueExclusiveInboundMessage, m as listPublicScheduledAutomationsForTeams, p as isListedScheduledAutomation, pt as appendAndEnqueueInboundMessage, qt as buildDeterministicTurnId, v as readScheduledAutomation, y as saveScheduledAutomation } from "./stats-DawHjcTw.js";
|
|
9
9
|
import { p as healthReportSchema, s as sumUtcHoursIntoSixHours } from "./reporting-window-DbUqng0P.js";
|
|
10
|
-
import { a as readAutomationExecutionStatusDays, c as readAutomationExecutions, i as readAutomationExecutionHours, l as readAutomationRuns, n as readAutomationExecutionByConversationId, o as readAutomationExecutionStatusHours, r as readAutomationExecutionDays, s as readAutomationExecutionSummaries, t as emptyAutomationRunWindows } from "./execution-stats-
|
|
10
|
+
import { a as readAutomationExecutionStatusDays, c as readAutomationExecutions, i as readAutomationExecutionHours, l as readAutomationRuns, n as readAutomationExecutionByConversationId, o as readAutomationExecutionStatusHours, r as readAutomationExecutionDays, s as readAutomationExecutionSummaries, t as emptyAutomationRunWindows } from "./execution-stats-CR9CYpyj.js";
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
import { createHash } from "node:crypto";
|
|
13
13
|
import { and, desc, eq, inArray, lt, notInArray, or, sql } from "drizzle-orm";
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
|
|
2
|
-
import {
|
|
3
|
-
import { Jt as getSqlExecutor, Kt as getConversationStore, Wt as getConversationEventStore } from "./agent-hooks-
|
|
4
|
-
import { f as juniorAgentBindings, p as juniorAgentInvocations } from "./executor-
|
|
5
|
-
import {
|
|
6
|
-
import { pt as appendAndEnqueueInboundMessage } from "./stats-
|
|
7
|
-
import {
|
|
8
|
-
import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-
|
|
9
|
-
import { n as
|
|
10
|
-
import { n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState } from "./thread-state-DXgxOYpZ.js";
|
|
2
|
+
import { B as AgentInvocationLimitError, I as agentBindingSchema, L as agentInvocationSchema, R as createAgentInvocationSchema, n as runAgentWithTimeout, v as PluginCredentialFailureError, wt as AuthorizationFlowDisabledError, z as AgentInvocationBusyError } from "./agent-runner-Cad1RtWn.js";
|
|
3
|
+
import { Jt as getSqlExecutor, Kt as getConversationStore, Wt as getConversationEventStore } from "./agent-hooks-CRuRcOg9.js";
|
|
4
|
+
import { f as juniorAgentBindings, p as juniorAgentInvocations } from "./executor-B9R4cHte.js";
|
|
5
|
+
import { I as openConversationProjection, _ as getTerminalAssistantMessages, o as failTurnRecord, r as saveTurnCheckpoint, s as getTurnRecord } from "./checkpoint-6fkAdB3g.js";
|
|
6
|
+
import { pt as appendAndEnqueueInboundMessage } from "./stats-DawHjcTw.js";
|
|
7
|
+
import { d as getConversationTurnBoundaryError, l as TurnInputCommitLostError, p as isTurnInputCommitLostError, r as getAssistantReplyText } from "./oauth-authorization-BS4vPJmu.js";
|
|
8
|
+
import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-DPDHKi2U.js";
|
|
9
|
+
import { n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState } from "./thread-state-CAR6gdAm.js";
|
|
11
10
|
import { z } from "zod";
|
|
12
11
|
import { createHash } from "node:crypto";
|
|
13
12
|
import { and, asc, count, eq, inArray } from "drizzle-orm";
|
|
@@ -201,6 +200,49 @@ function isTerminalAgentInvocation(invocation) {
|
|
|
201
200
|
return TERMINAL_AGENT_INVOCATION_STATUSES.includes(invocation.status);
|
|
202
201
|
}
|
|
203
202
|
//#endregion
|
|
203
|
+
//#region src/chat/runtime/turn-execution.ts
|
|
204
|
+
/** An error thrown while the agent advances a Run. */
|
|
205
|
+
var AgentRunError = class extends Error {
|
|
206
|
+
constructor(cause) {
|
|
207
|
+
super(cause instanceof Error ? cause.message : "Agent Run failed", { cause });
|
|
208
|
+
this.name = "AgentRunError";
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
/**
|
|
212
|
+
* Run the agent and finish the Turn after the caller saves its result.
|
|
213
|
+
*
|
|
214
|
+
* A paused Run, or a Run waiting for authorization, leaves the Turn open. A
|
|
215
|
+
* save error also leaves the Turn open so the worker can retry or recover it.
|
|
216
|
+
* A timeout aborts the Run before this function reports the failure.
|
|
217
|
+
*/
|
|
218
|
+
async function executeTurn(agentRunner, run, saveResult, timeoutMs) {
|
|
219
|
+
let outcome;
|
|
220
|
+
try {
|
|
221
|
+
outcome = await runAgentWithTimeout(agentRunner, run, timeoutMs);
|
|
222
|
+
} catch (error) {
|
|
223
|
+
throw new AgentRunError(error);
|
|
224
|
+
}
|
|
225
|
+
if (outcome.status !== "completed") return outcome;
|
|
226
|
+
const saved = await saveResult(outcome.result);
|
|
227
|
+
const lifecycle = new ConversationTurnLifecycleService(getConversationEventStore());
|
|
228
|
+
const common = {
|
|
229
|
+
conversationId: run.conversationId,
|
|
230
|
+
createdAtMs: saved.finishedAtMs ?? Date.now(),
|
|
231
|
+
turnId: run.turnId
|
|
232
|
+
};
|
|
233
|
+
if (saved.outcome === "failed") await lifecycle.fail({
|
|
234
|
+
...common,
|
|
235
|
+
...saved.eventId ? { eventId: saved.eventId } : void 0,
|
|
236
|
+
failureCode: saved.failureCode,
|
|
237
|
+
...saved.failureReason ? { failureReason: saved.failureReason } : void 0
|
|
238
|
+
});
|
|
239
|
+
else await lifecycle.complete({
|
|
240
|
+
...common,
|
|
241
|
+
outcome: saved.outcome
|
|
242
|
+
});
|
|
243
|
+
return { status: "completed" };
|
|
244
|
+
}
|
|
245
|
+
//#endregion
|
|
204
246
|
//#region src/chat/agent-invocations/work.ts
|
|
205
247
|
var work_exports = /* @__PURE__ */ __exportAll({
|
|
206
248
|
buildAgentInvocationInboundMessage: () => buildAgentInvocationInboundMessage,
|
|
@@ -506,4 +548,4 @@ function routeAgentInvocationWork(options) {
|
|
|
506
548
|
};
|
|
507
549
|
}
|
|
508
550
|
//#endregion
|
|
509
|
-
export { work_exports as a, resolveAgentInvocationId as i, createAndEnqueueAgentInvocation as n,
|
|
551
|
+
export { work_exports as a, listPendingAgentInvocationMailboxAppends as c, resolveAgentInvocationId as i, createAndEnqueueAgentInvocation as n, AgentRunError as o, enqueueAgentInvocation as r, executeTurn as s, createAgentInvocationWorker as t };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
|
|
2
|
-
import { b as isProviderRetryError } from "./client-
|
|
3
|
-
import {
|
|
4
|
-
import { a as getChatConfig } from "./config-
|
|
5
|
-
import { At as recordConversationRetry, Ct as drainConversationMailbox, Et as getConversationWorkState, Ft as startConversationWork, Ht as isInvalidConversationRecordError, Nt as requestAnotherSlice, St as deadLetterAttempt, Vt as isFinalAttempt, _t as clearConsumedConversationWake, bt as completeConversationWork, dt as ackMessages, gt as checkInConversationWork, jt as releaseConversationWork, kt as recordAttemptFailure, mt as beginConversationResume, wt as ensureConversationWake, xt as countPendingConversationMessages, yt as completeConversationStop, zt as hasConversationStop } from "./stats-
|
|
2
|
+
import { b as isProviderRetryError } from "./client-ihmkx60d.js";
|
|
3
|
+
import { C as withLogContext, d as logException, f as logInfo, p as logWarn } from "./logging-CcTvYQ8A.js";
|
|
4
|
+
import { a as getChatConfig } from "./config-DMg679BW.js";
|
|
5
|
+
import { At as recordConversationRetry, Ct as drainConversationMailbox, Et as getConversationWorkState, Ft as startConversationWork, Ht as isInvalidConversationRecordError, Nt as requestAnotherSlice, St as deadLetterAttempt, Vt as isFinalAttempt, _t as clearConsumedConversationWake, bt as completeConversationWork, dt as ackMessages, gt as checkInConversationWork, jt as releaseConversationWork, kt as recordAttemptFailure, mt as beginConversationResume, wt as ensureConversationWake, xt as countPendingConversationMessages, yt as completeConversationStop, zt as hasConversationStop } from "./stats-DawHjcTw.js";
|
|
6
6
|
import { c as ConversationQueueMessageRejectedError } from "./vercel-queue-DIkVcfK4.js";
|
|
7
|
-
import { a as getTurnRequestDeadline } from "./job-queue-
|
|
7
|
+
import { a as getTurnRequestDeadline } from "./job-queue-D2SiTrnt.js";
|
|
8
8
|
//#region src/chat/task-execution/worker.ts
|
|
9
9
|
var worker_exports = /* @__PURE__ */ __exportAll({
|
|
10
10
|
CONVERSATION_WORK_DEFER_DELAY_MS: () => CONVERSATION_WORK_DEFER_DELAY_MS,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.225.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"pg": "^8.16.3",
|
|
86
86
|
"yaml": "^2.9.0",
|
|
87
87
|
"zod": "^4.5.4",
|
|
88
|
-
"@sentry/junior-plugin-api": "0.
|
|
88
|
+
"@sentry/junior-plugin-api": "0.225.0"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
91
|
"@emnapi/core": "^1.10.0",
|
|
@@ -104,9 +104,9 @@
|
|
|
104
104
|
"typescript": "^6.0.3",
|
|
105
105
|
"vercel": "^54.4.0",
|
|
106
106
|
"vitest": "^4.1.7",
|
|
107
|
-
"@sentry/junior-
|
|
107
|
+
"@sentry/junior-github": "0.225.0",
|
|
108
108
|
"@sentry/junior-testing": "0.0.0",
|
|
109
|
-
"@sentry/junior-
|
|
109
|
+
"@sentry/junior-memory": "0.225.0"
|
|
110
110
|
},
|
|
111
111
|
"scripts": {
|
|
112
112
|
"build": "tsdown",
|