@sentry/junior 0.245.0 → 0.247.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/{admin-BEbNsG87.js → admin-BGwaqDMs.js} +1 -1
- package/dist/{agent-hooks-Caa0Qh_Q.js → agent-hooks-C72ByH0C.js} +11 -11
- package/dist/{agent-invocations-BO6ddZax.js → agent-invocations-D_YoNnAn.js} +8 -2
- package/dist/{agent-runner-BEuPFbbv.js → agent-runner-DsAFAKKs.js} +822 -2524
- package/dist/api/schema.d.ts +23 -1
- package/dist/api/schema.js +3 -3
- package/dist/api.js +82 -21
- package/dist/{app-BYB7szGb.d.ts → app-4t4mPTdS.d.ts} +8 -1
- package/dist/app.d.ts +1 -1
- package/dist/app.js +37 -68
- package/dist/assistant-reply-ChOzcTBS.js +45 -0
- package/dist/{briefs-DFAh_jTW.js → briefs-Dc7qZrhc.js} +4 -4
- package/dist/{catalog-runtime-wmq_fqff.js → catalog-runtime-DS1k7fUG.js} +1 -1
- package/dist/cli/chat.js +25 -15
- package/dist/cli/check.js +3 -3
- package/dist/cli/main.js +2 -2
- package/dist/cli/plugins.js +4 -4
- package/dist/cli/snapshot-create.js +3 -3
- package/dist/cli/upgrade.js +3 -3
- package/dist/{client-Bn9SRFCi.js → client-BVnfNd3D.js} +2 -2
- package/dist/{config-_XAINZMN.js → config-CgWvImQL.js} +2 -2
- package/dist/{conversation-CvBG57Io.js → conversation-CYsbVFLx.js} +71 -1
- package/dist/{conversation-privacy-BN5SGxsF.js → conversation-privacy-D3TdVM9H.js} +1 -1
- package/dist/{credential-sync-BvaUm6HQ.js → credential-sync-DLw3jkv-.js} +14 -14
- package/dist/{executor-CFIqoCNJ.js → executor-DQazjeGA.js} +3 -3
- package/dist/{images-Ci43I3ek.js → images-C3e5E-p_.js} +4 -21
- package/dist/instrumentation.js +2 -2
- package/dist/{job-queue-CGicV7x6.js → job-queue-BEUqRhjC.js} +1 -1
- package/dist/{logging-Bs3dV81s.js → logging-CZEc8_v4.js} +1 -1
- package/dist/message-BIJa7lKh.js +59 -0
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +3 -3
- package/dist/{oauth-authorization-COzWmMjO.js → oauth-authorization-BA4Dt6a7.js} +1 -45
- package/dist/{oauth-callback-server-17c9_39v.js → oauth-callback-server-R9OSdLP1.js} +2 -2
- package/dist/{pending-auth-Bnhg7Q9k.js → pending-auth-Oo5AQhaf.js} +2 -2
- package/dist/{profile-BA471c-l.js → profile-aVLDAirh.js} +4 -4
- package/dist/{prompt-C9Q9cjD3.js → prompt-ZG1UCxjF.js} +1 -1
- package/dist/{registry-BYNOFO6e.js → registry-CtaDOOM5.js} +1 -1
- package/dist/{resolve-rpz8No2i.js → resolve-Bdw4hu7s.js} +2 -2
- package/dist/result-DNgmkASh.js +463 -0
- package/dist/{runner-C8DRk9X6.js → runner-BUSScEu5.js} +11 -10
- package/dist/{sandbox-egress-signals-B8hurjFt.js → sandbox-egress-signals-E9r8bf9G.js} +1 -1
- package/dist/{schema-WRgR9EL6.js → schema-tyd6hALh.js} +23 -3
- package/dist/session-stop-CAhBfBUT.js +782 -0
- package/dist/{skills-C4yrD2NR.js → skills-DQy-mmBC.js} +2 -2
- package/dist/{spawn-CdAaTXrY.js → spawn-DQ_MVWZ6.js} +3 -2
- package/dist/store-DjLA8GKs.js +1417 -0
- package/dist/{task-queue-BBxHzlIB.js → task-queue-BT2h_t8I.js} +3 -3
- package/dist/{task-runner-BqFapTjs.js → task-runner-CiPepjIB.js} +11 -11
- package/dist/{tasks-Ddd7OAkp.js → tasks-DMmRrIVl.js} +9 -9
- package/dist/{thread-state-DqErwbA8.js → thread-state-ehZYGpX9.js} +7 -7
- package/dist/{turn-failure-response-DtL1-fOl.js → turn-failure-response-D7J10z7l.js} +9 -9
- package/dist/{turn-lifecycle-B5pzyD6W.js → turn-lifecycle-Buswqs90.js} +1 -1
- package/dist/{turn-session-routing-D6pTU5uF.js → turn-session-routing-Bw-yiSb4.js} +1 -1
- package/dist/{validation-BAzlyNIc.js → validation-DTguegIe.js} +1 -1
- package/dist/{version-CiXDH3oe.js → version-BrZSE5du.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-wCn8xneI.js → viewer-BlAozHer.js} +4 -4
- package/dist/{web-authorization-d5MtGpfG.js → web-authorization-DwyTlkAg.js} +6 -6
- package/dist/{web-input-BZTiCtvP.js → web-input-DSYxI7Wi.js} +77 -378
- package/dist/{work-4QPqTd5_.js → work-CRBXkJoU.js} +96 -13
- package/dist/{worker-mc62tybz.js → worker-BVJKM9Ja.js} +7 -7
- package/migrations/0053_conversation_stopped_at.sql +1 -0
- package/migrations/0054_flowery_rage.sql +1 -0
- package/migrations/meta/0053_snapshot.json +3771 -0
- package/migrations/meta/0054_snapshot.json +3777 -0
- package/migrations/meta/_journal.json +14 -0
- package/package.json +5 -4
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
|
|
2
|
-
import { G as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
2
|
+
import { $ as getAgentInvocation, G as recordSubagentStarted, H as stopChildAgentsOf, Ht as readBlockedReport, It as buildSteeringPiMessage, J as createAgentInvocation, Lt as withoutSavedSteeringMessages, Q as getActiveAgentInvocationForConversation, Vt as AuthorizationFlowDisabledError, W as recordSubagentEnded, at as getAgentInvocationTurnId, ct as isTerminalAgentInvocation, dt as markAgentInvocationMailboxAppended, gt as reportReplacedAgentInvocation, ht as markAgentInvocationSteered, m as PluginCredentialFailureError, mt as markAgentInvocationRunning, pt as markAgentInvocationPaused, q as completeAgentInvocation, rt as getAgentInvocationMessageId, st as getLatestAgentInvocationForConversation } from "./agent-runner-DsAFAKKs.js";
|
|
3
|
+
import { n as botConfig } from "./config-CgWvImQL.js";
|
|
4
|
+
import { c as getConversationEventStore, u as getConversationStore } from "./viewer-BlAozHer.js";
|
|
5
|
+
import { f as instructionProvenanceFor, p as sameActorIdentity } from "./history-Nte1oVed.js";
|
|
6
|
+
import { At as openConversationProjection, J as saveTurnCheckpoint, Q as getTurnRecord, Y as abandonTurnRecord, Z as failTurnRecord, ct as getTerminalAssistantMessages } from "./tasks-DMmRrIVl.js";
|
|
7
|
+
import { c as isTurnInputCommitLostError, i as TurnInputCommitLostError, o as getConversationTurnBoundaryError } from "./oauth-authorization-BA4Dt6a7.js";
|
|
8
|
+
import { n as getAssistantReplyText } from "./assistant-reply-ChOzcTBS.js";
|
|
9
|
+
import { A as recordFinishedTurnForAutomatedLimit, j as resetAutomatedTurnLimit, k as maybePostAutomatedTurnLimitNotice } from "./session-stop-CAhBfBUT.js";
|
|
10
|
+
import { r as appendAndEnqueueInboundMessage } from "./store-DjLA8GKs.js";
|
|
11
|
+
import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-Buswqs90.js";
|
|
12
|
+
import { n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState } from "./thread-state-ehZYGpX9.js";
|
|
13
|
+
import { isDeepStrictEqual } from "node:util";
|
|
8
14
|
import { z } from "zod";
|
|
9
15
|
//#region src/chat/runtime/turn-execution.ts
|
|
10
16
|
/** An error thrown while the agent advances a Run. */
|
|
@@ -50,6 +56,7 @@ async function executeTurn(agentRunner, run, saveResult) {
|
|
|
50
56
|
//#endregion
|
|
51
57
|
//#region src/chat/agent-invocations/work.ts
|
|
52
58
|
var work_exports = /* @__PURE__ */ __exportAll({
|
|
59
|
+
agentInvocationRunPolicy: () => agentInvocationRunPolicy,
|
|
53
60
|
buildAgentInvocationInboundMessage: () => buildAgentInvocationInboundMessage,
|
|
54
61
|
createAgentInvocationWorker: () => createAgentInvocationWorker,
|
|
55
62
|
createAndEnqueueAgentInvocation: () => createAndEnqueueAgentInvocation,
|
|
@@ -61,6 +68,18 @@ const agentInvocationMailboxMetadataSchema = z.object({
|
|
|
61
68
|
agentInvocationId: z.string().min(1),
|
|
62
69
|
kind: z.literal("agent_invocation")
|
|
63
70
|
}).strict();
|
|
71
|
+
/** Map a durable invocation's model settings and depth to the child Run policy. */
|
|
72
|
+
function agentInvocationRunPolicy(invocation, canSpawn) {
|
|
73
|
+
return {
|
|
74
|
+
disabledFeatures: canSpawn ? ["handoff", "interactive-auth"] : [
|
|
75
|
+
"handoff",
|
|
76
|
+
"interactive-auth",
|
|
77
|
+
"subagents"
|
|
78
|
+
],
|
|
79
|
+
...invocation.modelProfile ? { modelProfile: invocation.modelProfile } : void 0,
|
|
80
|
+
...invocation.reasoningLevel ? { reasoning: invocation.reasoningLevel } : void 0
|
|
81
|
+
};
|
|
82
|
+
}
|
|
64
83
|
/** Build destinationless mailbox work that references one durable invocation. */
|
|
65
84
|
function buildAgentInvocationInboundMessage(invocation, nowMs = Date.now()) {
|
|
66
85
|
return {
|
|
@@ -123,6 +142,53 @@ async function resolveAgentInvocationId(context) {
|
|
|
123
142
|
const latest = await getLatestAgentInvocationForConversation(context.conversationId);
|
|
124
143
|
return latest?.status === "stopped" ? latest.invocationId : void 0;
|
|
125
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Give queued parent messages to the running agent invocation of a child as
|
|
147
|
+
* steering messages. A message joins only with the Actor and credentials of
|
|
148
|
+
* the running Turn. The first message that does not match stops the scan, so
|
|
149
|
+
* it and every later message wait for the current work. Each message that
|
|
150
|
+
* joins ends as `steered`, and the running agent invocation reports for it.
|
|
151
|
+
*/
|
|
152
|
+
function createAgentMessageSteeringDrain(context, running) {
|
|
153
|
+
const turnId = getAgentInvocationTurnId(running.invocationId);
|
|
154
|
+
return async (accept) => {
|
|
155
|
+
const accepted = [];
|
|
156
|
+
await context.attempt.drain(async (pending) => {
|
|
157
|
+
const readIds = [];
|
|
158
|
+
const joining = [];
|
|
159
|
+
for (const message of pending) {
|
|
160
|
+
const metadata = agentInvocationMailboxMetadataSchema.safeParse(message.input.metadata);
|
|
161
|
+
if (!metadata.success) continue;
|
|
162
|
+
const candidate = await getAgentInvocation(metadata.data.agentInvocationId);
|
|
163
|
+
if (!candidate?.parentToolCallId || candidate.invocationId === running.invocationId) continue;
|
|
164
|
+
if (isTerminalAgentInvocation(candidate)) {
|
|
165
|
+
if (candidate.parentMailboxStatus === "steered") readIds.push(message.inboundMessageId);
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
if (!sameActorIdentity(candidate.actor, running.actor) || !isDeepStrictEqual(candidate.credentialContext, running.credentialContext)) break;
|
|
169
|
+
joining.push(candidate);
|
|
170
|
+
readIds.push(message.inboundMessageId);
|
|
171
|
+
}
|
|
172
|
+
if (joining.length === 0) return readIds;
|
|
173
|
+
const saved = (await getTurnRecord(running.childConversationId, turnId))?.piMessages ?? [];
|
|
174
|
+
const messages = withoutSavedSteeringMessages(saved, joining.map((candidate) => ({
|
|
175
|
+
provenance: instructionProvenanceFor(candidate.actor),
|
|
176
|
+
text: candidate.input,
|
|
177
|
+
timestampMs: candidate.createdAtMs
|
|
178
|
+
})), buildSteeringPiMessage);
|
|
179
|
+
if (messages.length > 0) {
|
|
180
|
+
await accept(messages);
|
|
181
|
+
accepted.push(...messages);
|
|
182
|
+
}
|
|
183
|
+
for (const candidate of joining) {
|
|
184
|
+
const terminal = await markAgentInvocationSteered(candidate.invocationId);
|
|
185
|
+
if (terminal && isTerminalAgentInvocation(terminal)) await recordSubagentEnded(terminal);
|
|
186
|
+
}
|
|
187
|
+
return readIds;
|
|
188
|
+
}, { deferred: true });
|
|
189
|
+
return accepted;
|
|
190
|
+
};
|
|
191
|
+
}
|
|
126
192
|
/** Project the terminal invocation into the idempotent turn lifecycle. */
|
|
127
193
|
async function persistTerminalLifecycle(invocation) {
|
|
128
194
|
const lifecycle = new ConversationTurnLifecycleService(getConversationEventStore());
|
|
@@ -166,11 +232,15 @@ async function projectTerminalTurn(invocation) {
|
|
|
166
232
|
if (turn.state === "paused") return;
|
|
167
233
|
const result = getTerminalAssistantMessages(turn.piMessages).map(getAssistantReplyText).filter((text) => text !== void 0).join("\n\n");
|
|
168
234
|
const failed = turn.state !== "completed" || Boolean(turn.errorMessage);
|
|
235
|
+
const blocked = turn.turnStartMessageIndex === void 0 ? void 0 : readBlockedReport(turn.piMessages.slice(turn.turnStartMessageIndex));
|
|
169
236
|
return await completeAgentInvocation({
|
|
170
237
|
invocationId: invocation.invocationId,
|
|
171
238
|
...failed ? {
|
|
172
239
|
errorMessage: turn.errorMessage ?? "Agent invocation failed",
|
|
173
240
|
status: "failed"
|
|
241
|
+
} : blocked ? {
|
|
242
|
+
errorMessage: blocked.missing,
|
|
243
|
+
status: "blocked"
|
|
174
244
|
} : {
|
|
175
245
|
result,
|
|
176
246
|
status: "completed"
|
|
@@ -203,11 +273,27 @@ async function saveAgentInvocationResult(args) {
|
|
|
203
273
|
source: args.invocation.source,
|
|
204
274
|
surface: "internal"
|
|
205
275
|
});
|
|
276
|
+
if (args.invocation.parentToolCallId) await resetAutomatedTurnLimit({ conversationId: args.invocation.childConversationId });
|
|
277
|
+
else if (args.invocation.source.kind !== "agent_invocation") {
|
|
278
|
+
const maxTurns = botConfig.maxConsecutiveAutomatedTurns;
|
|
279
|
+
await maybePostAutomatedTurnLimitNotice({
|
|
280
|
+
conversationId: args.invocation.childConversationId,
|
|
281
|
+
maxTurns,
|
|
282
|
+
update: await recordFinishedTurnForAutomatedLimit({
|
|
283
|
+
conversationId: args.invocation.childConversationId,
|
|
284
|
+
maxTurns,
|
|
285
|
+
source: args.invocation.source
|
|
286
|
+
})
|
|
287
|
+
});
|
|
288
|
+
}
|
|
206
289
|
const terminal = await completeAgentInvocation({
|
|
207
290
|
invocationId: args.invocation.invocationId,
|
|
208
291
|
...failed ? {
|
|
209
292
|
errorMessage: args.result.diagnostics.errorMessage ?? "Agent invocation failed",
|
|
210
293
|
status: "failed"
|
|
294
|
+
} : args.result.blocked ? {
|
|
295
|
+
errorMessage: args.result.blocked.missing,
|
|
296
|
+
status: "blocked"
|
|
211
297
|
} : {
|
|
212
298
|
result: args.result.text,
|
|
213
299
|
status: "completed"
|
|
@@ -263,7 +349,7 @@ function createAgentInvocationWorker(agentRunner, options = {}) {
|
|
|
263
349
|
};
|
|
264
350
|
const finish = async (terminal) => {
|
|
265
351
|
if (!terminal || !isTerminalAgentInvocation(terminal)) return;
|
|
266
|
-
await persistTerminalLifecycle(terminal);
|
|
352
|
+
if (terminal.parentMailboxStatus !== "steered") await persistTerminalLifecycle(terminal);
|
|
267
353
|
await report(terminal);
|
|
268
354
|
};
|
|
269
355
|
let acknowledged = context.attempt.messages.length === 0;
|
|
@@ -344,6 +430,7 @@ function createAgentInvocationWorker(agentRunner, options = {}) {
|
|
|
344
430
|
try {
|
|
345
431
|
outcome = await executeTurn(agentRunner, {
|
|
346
432
|
conversationId: invocation.childConversationId,
|
|
433
|
+
parentConversationId: invocation.parentConversationId,
|
|
347
434
|
turnId,
|
|
348
435
|
runId: invocation.invocationId,
|
|
349
436
|
instruction: { text: invocation.input },
|
|
@@ -355,14 +442,10 @@ function createAgentInvocationWorker(agentRunner, options = {}) {
|
|
|
355
442
|
...location ? { location } : void 0,
|
|
356
443
|
surface: "internal",
|
|
357
444
|
...stopSignal ? { signal: stopSignal } : void 0,
|
|
358
|
-
|
|
359
|
-
"handoff",
|
|
360
|
-
"interactive-auth",
|
|
361
|
-
"subagents"
|
|
362
|
-
],
|
|
363
|
-
reasoning: invocation.reasoningLevel,
|
|
445
|
+
...agentInvocationRunPolicy(invocation, canSpawn),
|
|
364
446
|
state: { sandboxRef },
|
|
365
447
|
durability: {
|
|
448
|
+
drainSteeringMessages: createAgentMessageSteeringDrain(context, invocation),
|
|
366
449
|
onInputCommitted: acknowledge,
|
|
367
450
|
shouldYield: context.shouldYield,
|
|
368
451
|
onSandboxRefChanged: async (nextSandboxRef) => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { f as
|
|
2
|
+
import { v as isProviderRetryError } from "./client-BVnfNd3D.js";
|
|
3
|
+
import { C as withLogContext, d as logException, f as logInfo, p as logWarn } from "./logging-CZEc8_v4.js";
|
|
4
|
+
import { i as getChatConfig } from "./config-CgWvImQL.js";
|
|
5
|
+
import { f as getTurnRequestDeadline, m as ConversationQueueMessageRejectedError } from "./job-queue-BEUqRhjC.js";
|
|
6
|
+
import { C as requestAnotherSlice, M as isInvalidConversationRecordError, T as startConversationWork, b as recordConversationRetry, d as countPendingConversationMessages, f as deadLetterAttempt, g as getConversationWorkState, i as beginConversationResume, j as isFinalAttempt, k as hasConversationStop, l as completeConversationStop, m as ensureConversationWake, o as checkInConversationWork, p as drainConversationMailbox, s as clearConsumedConversationWake, t as ackMessages, u as completeConversationWork, x as releaseConversationWork, y as recordAttemptFailure } from "./store-DjLA8GKs.js";
|
|
7
7
|
//#region src/chat/task-execution/worker.ts
|
|
8
8
|
var worker_exports = /* @__PURE__ */ __exportAll({
|
|
9
9
|
CONVERSATION_WORK_DEFER_DELAY_MS: () => CONVERSATION_WORK_DEFER_DELAY_MS,
|
|
@@ -262,12 +262,12 @@ async function processConversationWorkInContext(message, options) {
|
|
|
262
262
|
"app.lease.expires_at_ms": lease.leaseExpiresAtMs,
|
|
263
263
|
"app.worker.soft_yield_deadline_ms": softYieldDeadlineMs
|
|
264
264
|
});
|
|
265
|
-
const drain = (handle) => drainConversationMailbox({
|
|
265
|
+
const drain = (handle, drainOptions) => drainConversationMailbox({
|
|
266
266
|
conversationId,
|
|
267
267
|
leaseToken: lease.leaseToken,
|
|
268
268
|
conversationStore: options.conversationStore,
|
|
269
269
|
handle: async (messages) => {
|
|
270
|
-
const candidates = messages.filter((message) => message.delivery === "interrupt" && (attemptSelectedMessageIds.has(message.inboundMessageId) || !attemptStartMessageIds.has(message.inboundMessageId)));
|
|
270
|
+
const candidates = drainOptions?.deferred ? messages : messages.filter((message) => message.delivery === "interrupt" && (attemptSelectedMessageIds.has(message.inboundMessageId) || !attemptStartMessageIds.has(message.inboundMessageId)));
|
|
271
271
|
if (candidates.length === 0) return [];
|
|
272
272
|
return await handle(candidates) ?? candidates.map((message) => message.inboundMessageId);
|
|
273
273
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE "junior_conversations" ADD COLUMN "stopped_at" timestamp with time zone;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE "junior_agent_invocations" ADD COLUMN "model_profile" text;
|