@sentry/junior 0.246.0 → 0.248.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-Bh-MYw-j.js → admin-BlHz8fGl.js} +1 -1
- package/dist/{agent-hooks-DpklSWZg.js → agent-hooks-DWCHBPYw.js} +25 -12
- package/dist/{agent-invocations-BO6ddZax.js → agent-invocations-D_YoNnAn.js} +8 -2
- package/dist/{agent-runner-DSKpHjHW.js → agent-runner-CnlFtbzb.js} +608 -2434
- package/dist/api/schema.d.ts +171 -3
- package/dist/api/schema.js +3 -3
- package/dist/api.js +219 -153
- package/dist/{app-BYB7szGb.d.ts → app-B0gT1Slp.d.ts} +11 -2
- package/dist/app.d.ts +1 -1
- package/dist/app.js +30 -27
- package/dist/assistant-reply-BxCi7V4v.js +45 -0
- package/dist/{briefs-cZ5vWqP_.js → briefs-CdkIl79U.js} +4 -4
- package/dist/{catalog-runtime-CTaQXYqS.js → catalog-runtime-CTBsdSam.js} +1 -1
- package/dist/cli/chat.js +22 -16
- 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--xtsAxKP.js → client-CWQtbizj.js} +2 -2
- package/dist/{config-BK53Ip5C.js → config-aitDvTQm.js} +16 -9
- package/dist/{conversation-CvBG57Io.js → conversation-Cjo9tHGm.js} +85 -1
- package/dist/{conversation-privacy-BDBFw6Ws.js → conversation-privacy-BsqXHVBz.js} +1 -1
- package/dist/{credential-sync-BiuhC9Ds.js → credential-sync-DqZF735a.js} +14 -14
- package/dist/{executor-bmmuRY-w.js → executor-oIZAkQZb.js} +3 -3
- package/dist/{images-DZliDtSH.js → images-Dzh3RBXY.js} +4 -21
- package/dist/instrumentation.js +2 -2
- package/dist/{job-queue-Cz3M7gg4.js → job-queue-DyA2AEnY.js} +1 -1
- package/dist/{logging-DVtMYOdD.js → logging-OpC2jwiV.js} +1 -1
- package/dist/message-EyMrVXEf.js +59 -0
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +3 -3
- package/dist/{oauth-authorization-By_MVRDC.js → oauth-authorization-BA4Dt6a7.js} +1 -45
- package/dist/{oauth-callback-server-BrUo6w1e.js → oauth-callback-server-ClDv9Z5Y.js} +2 -2
- package/dist/{pending-auth-BuQLZ6dK.js → pending-auth-D_nf121N.js} +2 -2
- package/dist/{profile-BevMNSlr.js → profile-Dfg76pvk.js} +4 -4
- package/dist/{prompt-C9Q9cjD3.js → prompt-C7bRJ2vg.js} +1 -1
- package/dist/{registry-C2rSEio1.js → registry-fpIZHoqE.js} +1 -1
- package/dist/{resolve-qPhrznTf.js → resolve-LMCZhQVg.js} +2 -2
- package/dist/result-C1ZCRPLx.js +463 -0
- package/dist/{runner-CNh5eMWx.js → runner-DNZMviFH.js} +11 -10
- package/dist/{sandbox-egress-signals-BnDEKu8d.js → sandbox-egress-signals-Dcc-mwkl.js} +1 -1
- package/dist/{schema-BWMRg8JS.js → schema-BRZsYL5-.js} +5 -4
- package/dist/session-stop-dyvsZDB0.js +782 -0
- package/dist/{skills-C6zJbudq.js → skills-BgGiQt5Y.js} +2 -2
- package/dist/{spawn-C3efZSx3.js → spawn-CpqxMPWE.js} +3 -2
- package/dist/store-OMQAFrJG.js +1417 -0
- package/dist/{task-queue-BX4vG6uA.js → task-queue-SWsXPSp-.js} +3 -3
- package/dist/{task-runner-T51kll0U.js → task-runner-BOxv7shv.js} +11 -11
- package/dist/{tasks-B9OIjl2K.js → tasks-DREdnhVP.js} +49 -16
- package/dist/{thread-state-AGZtVyXp.js → thread-state-BoNCtSwk.js} +7 -7
- package/dist/{turn-failure-response-DJ8KU2bo.js → turn-failure-response-C6jrCPjc.js} +9 -9
- package/dist/{turn-lifecycle-DZJkJ95q.js → turn-lifecycle-cQFsZFOU.js} +1 -1
- package/dist/{turn-session-routing-mRqLbMZW.js → turn-session-routing-Ba12fwXz.js} +1 -1
- package/dist/{validation-Dg0Ihxzo.js → validation-Dmfh2cTj.js} +1 -1
- package/dist/{version-Deub4try.js → version-ByV7nGOn.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-D5hbx6TE.js → viewer-CX41TWYr.js} +4 -4
- package/dist/{web-authorization-DCxixz5S.js → web-authorization-rDLlKIS0.js} +6 -6
- package/dist/{web-input-0sorYVLh.js → web-input-Bn9HHZEo.js} +43 -208
- package/dist/{work-rm2X7jj4.js → work-CvFoEpRT.js} +90 -14
- package/dist/{worker-bnGsAOP3.js → worker-CI5B63vk.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 +6 -5
- package/dist/message-BSN-Ma5f.js +0 -317
|
@@ -1,39 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { f as escapeXml, i as completeText, r as completeObject, v as isProviderRetryError } from "./client
|
|
3
|
-
import { C as withLogContext, I as isRecord, L as toOptionalNumber, R as toOptionalString, _ as setSentryUser, b as setTags, d as logException, f as logInfo, n as createChatSdkLogger, o as getActiveTraceId, p as logWarn, t as buildTurnFailureResponse, u as logError, v as setSpanAttributes, w as withSpan } from "./logging-
|
|
4
|
-
import { c as getSlackClientSecret, i as getChatConfig, l as getSlackSigningSecret, n as botConfig, o as getSlackBotToken, s as getSlackClientId, v as normalizeSlackEmojiName } from "./config-
|
|
1
|
+
import { A as resolveSlackChannelIdFromMessage, B as effectiveTaskOutcomes, C as renderBlockText, D as storeAttachment, Ft as createUserTokenStore, It as buildSteeringPiMessage, Lt as withoutSavedSteeringMessages, M as getConversationInfo, N as listThreadReplies, O as parseSlackThreadId, Rt as RetryableDeliveryError, S as renderAttachmentText, Ut as shouldEmitDevAgentTrace, Vt as AuthorizationFlowDisabledError, a as buildAuthPauseResponse, h as latestProgressStatus, j as resolveSlackChannelIdFromThreadId, k as readSlackRawMessageContext, m as PluginCredentialFailureError, n as executeAgentRun, r as createContextCompactor, t as createAgentRunner, z as eventAutomationTriggerAvailable } from "./agent-runner-CnlFtbzb.js";
|
|
2
|
+
import { f as escapeXml, i as completeText, r as completeObject, v as isProviderRetryError } from "./client-CWQtbizj.js";
|
|
3
|
+
import { C as withLogContext, I as isRecord, L as toOptionalNumber, R as toOptionalString, _ as setSentryUser, b as setTags, d as logException, f as logInfo, n as createChatSdkLogger, o as getActiveTraceId, p as logWarn, t as buildTurnFailureResponse, u as logError, v as setSpanAttributes, w as withSpan } from "./logging-OpC2jwiV.js";
|
|
4
|
+
import { c as getSlackClientSecret, i as getChatConfig, l as getSlackSigningSecret, n as botConfig, o as getSlackBotToken, s as getSlackClientId, v as normalizeSlackEmojiName } from "./config-aitDvTQm.js";
|
|
5
5
|
import { o as modelIdForProfile, r as defaultModelId } from "./model-profile-BwU8mqwD.js";
|
|
6
6
|
import { a as isUserActor, g as parseSlackMessageTs, i as isActorUserId, l as parseSlackChannelId, n as createSlackActor, o as parseActorUserId, r as createSlackResumeActor, t as createActor } from "./actor-BTtLaeWy.js";
|
|
7
|
-
import { M as createSlackDestination, P as requireSlackDestination, c as getConversationEventStore, d as getDb, f as getSqlExecutor, u as getConversationStore } from "./viewer-
|
|
8
|
-
import { c as juniorIdentities, d as juniorDestinations, l as juniorUsers } from "./agent-invocations-
|
|
9
|
-
import { c as juniorAutomationExecutions, o as juniorSchedulerTasks, u as juniorEventAutomations } from "./executor-
|
|
7
|
+
import { M as createSlackDestination, P as requireSlackDestination, c as getConversationEventStore, d as getDb, f as getSqlExecutor, u as getConversationStore } from "./viewer-CX41TWYr.js";
|
|
8
|
+
import { c as juniorIdentities, d as juniorDestinations, l as juniorUsers } from "./agent-invocations-D_YoNnAn.js";
|
|
9
|
+
import { c as juniorAutomationExecutions, o as juniorSchedulerTasks, u as juniorEventAutomations } from "./executor-oIZAkQZb.js";
|
|
10
10
|
import { f as instructionProvenanceFor } from "./history-Nte1oVed.js";
|
|
11
|
-
import { d as credentialContextForActor } from "./registry-
|
|
12
|
-
import { $ as listTurnSummaries, $t as
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { E as acquireActiveLock, O as withLock, T as MUTATION_LOCK_TTL_MS, w as getStateAdapter } from "./profile-
|
|
16
|
-
import { a as wasPendingAuthStopped, c as getThreadStopDecision, l as buildDeterministicAssistantMessageId, o as decideSubscribedThreadReply, r as clearPendingAuth, s as getSubscribedReplyPreflightDecision, u as buildDeterministicTurnId } from "./pending-auth-
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
11
|
+
import { d as credentialContextForActor } from "./registry-fpIZHoqE.js";
|
|
12
|
+
import { $ as listTurnSummaries, $t as appendThreadContextMessages, At as loadProjection, D as sameDefinitionValue, Et as commitMessages, Gt as hydrateConversationMessages, H as removeReactionFromMessage, I as truncateStatusText, J as saveTurnCheckpoint, Jt as persistConversationMessageSummaries, Kt as persistConversationMessages, L as addReactionToMessage, Lt as recordAuthorizationCompleted, M as formatSlackLink, N as normalizeSlackReplyMarkdown, Ot as loadConversationProjection, P as normalizeSlackStatusText, Q as getTurnRecord, St as trimTrailingAssistantMessages, T as listAutomationVersions, Tt as commitAcceptedReply, V as postSlackMessage, Vt as recordSubscribedReplyRoute, X as completeTurnRecord, Y as abandonTurnRecord, Yt as resolveConversationTitle, Z as failTurnRecord, Zt as fallbackShortTitle, _ as listDeletedEventAutomationsCreatedBy, a as readScheduledAutomation, an as markConversationMessage, cn as turnHasReply, en as buildConversationContext, et as recordTurnSummary, g as getEventAutomation, i as parseScheduledAutomationRow, in as isHumanConversationMessage, j as escapeSlackMrkdwnText, l as withScheduledAutomationLock, ln as upsertConversationMessage, m as eventAutomationBelongsToUser, nn as estimateConversationContextTokens, on as normalizeConversationText, ot as buildTurnErrorResponse, p as deleteEventAutomation, q as loadTurnCheckpoint, rn as getConversationMessageSlackTs, s as saveScheduledAutomationInLock, sn as recordDeliveredAssistantMessage, tn as createConversationMemoryService, tt as persistWithRetry, w as automationDefinition, y as parseEventAutomationRow } from "./tasks-DREdnhVP.js";
|
|
13
|
+
import { Bt as getHeaderString, Dt as readAttachmentVisionSummary, Gt as runWithSlackInstallationToken, It as lookupSlackUser, Lt as SlackActionError, Ot as recordSlackAttachment, Rt as downloadPrivateSlackFile, Tt as getSlackFileId, Ut as isDmChannel, V as cancelSubscriptions, Vt as getSlackClient, Wt as normalizeSlackConversationId, at as getDashboardObjectIconLink, it as getDashboardConversationLink, nt as verifyTimerWatchCredentialSubject, o as getPluginSlackConversationLink, rt as JUNIOR_THREAD_STATE_TTL_MS, wt as buildSentryConversationUrl } from "./agent-hooks-DWCHBPYw.js";
|
|
14
|
+
import { F as readMessageAttachments, R as isVisionImageMediaType } from "./conversation-Cjo9tHGm.js";
|
|
15
|
+
import { E as acquireActiveLock, O as withLock, T as MUTATION_LOCK_TTL_MS, w as getStateAdapter } from "./profile-Dfg76pvk.js";
|
|
16
|
+
import { a as wasPendingAuthStopped, c as getThreadStopDecision, l as buildDeterministicAssistantMessageId, o as decideSubscribedThreadReply, r as clearPendingAuth, s as getSubscribedReplyPreflightDecision, u as buildDeterministicTurnId } from "./pending-auth-D_nf121N.js";
|
|
17
|
+
import { a as TurnInputDeferredError, c as isTurnInputCommitLostError, d as markTurnCompleted, f as markTurnFailed, i as TurnInputCommitLostError, l as isTurnInputDeferredError, n as ConversationTurnBoundaryError, o as getConversationTurnBoundaryError, p as startActiveTurn, r as CooperativeTurnYieldError, s as isCooperativeTurnYieldError, u as markTurnClosed } from "./oauth-authorization-BA4Dt6a7.js";
|
|
18
|
+
import { n as getAssistantReplyText } from "./assistant-reply-BxCi7V4v.js";
|
|
19
|
+
import { A as recordFinishedTurnForAutomatedLimit, F as finishedRunReply, P as deliversFinalText, R as runDispatchOutcome, c as timerWatchCredentialSubject, i as skipInputBeforeConversationStop, k as maybePostAutomatedTurnLimitNotice, l as getEventCatalog, s as isEventMailboxMetadata, v as automationEventCatalog } from "./session-stop-dyvsZDB0.js";
|
|
20
|
+
import { a as EVENT_SYSTEM_ACTOR, o as isEventConversationMessage } from "./prompt-C7bRJ2vg.js";
|
|
21
|
+
import { a as getVercelConversationWorkQueue, f as getTurnRequestDeadline } from "./job-queue-DyA2AEnY.js";
|
|
22
|
+
import { E as stopConversationWork, g as getConversationWorkState, h as getConversation, m as ensureConversationWake, n as appendAndEnqueueExclusiveInboundMessage, r as appendAndEnqueueInboundMessage, w as requestConversationWork } from "./store-OMQAFrJG.js";
|
|
20
23
|
import { l as automationListQuerySchema } from "./automation-gznOMaQ2.js";
|
|
21
24
|
import { r as isExperimentalFeatureEnabled } from "./experimental-Qn9rKLgx.js";
|
|
22
25
|
import { c as sumUtcHoursIntoSixHours, m as healthReportSchema, t as webMessageId } from "./web-message-id-xPI_EFSC.js";
|
|
23
|
-
import { C as readAutomationExecutionHours, D as readAutomationExecutions, E as readAutomationExecutionSummaries, O as readAutomationRuns, S as readAutomationExecutionDays, T as readAutomationExecutionStatusHours, _ as markDispatchFailed, a as confirmDispatchMailboxAppend, b as emptyAutomationRunWindows, c as getDispatchInputMessageId, f as isTerminalDispatchStatus, g as markDispatchCompleted, h as markDispatchBlocked, i as claimDispatchMailboxAppend, l as getDispatchRecord, m as markDispatchAwaitingResume, n as scheduleSessionCompletedPluginTasks, s as getDispatchConversationId, t as processPluginTask, u as getDispatchTurnId, v as markDispatchRunning, w as readAutomationExecutionStatusDays, x as readAutomationExecutionByConversationId } from "./task-runner-
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import { a as
|
|
28
|
-
import { a as getPausedTurnRequest, c as getTurnAuthorization, i as createPausedTurns, n as deleteWebAuthorization, s as wakePausedTurn, t as createWebAuthorization } from "./web-authorization-
|
|
29
|
-
import { n as resolveTurnSessionRouting } from "./turn-session-routing-
|
|
30
|
-
import { t as
|
|
31
|
-
import {
|
|
32
|
-
import { r as
|
|
26
|
+
import { C as readAutomationExecutionHours, D as readAutomationExecutions, E as readAutomationExecutionSummaries, O as readAutomationRuns, S as readAutomationExecutionDays, T as readAutomationExecutionStatusHours, _ as markDispatchFailed, a as confirmDispatchMailboxAppend, b as emptyAutomationRunWindows, c as getDispatchInputMessageId, f as isTerminalDispatchStatus, g as markDispatchCompleted, h as markDispatchBlocked, i as claimDispatchMailboxAppend, l as getDispatchRecord, m as markDispatchAwaitingResume, n as scheduleSessionCompletedPluginTasks, s as getDispatchConversationId, t as processPluginTask, u as getDispatchTurnId, v as markDispatchRunning, w as readAutomationExecutionStatusDays, x as readAutomationExecutionByConversationId } from "./task-runner-BOxv7shv.js";
|
|
27
|
+
import { a as withAgentInvocationResultActors, c as resolveMailboxTurnWork, f as joinMailboxText, i as startAgentInvocationsForChildInput, l as sourceFromTurnInput, o as getAuthPausedConversationTurnId, s as getEventBatchDelayMs, t as enqueueAgentInvocationResult, u as turnInputFactsFromConversationMessage } from "./result-C1ZCRPLx.js";
|
|
28
|
+
import { n as getTurnLifecycle, t as ConversationTurnLifecycleService } from "./turn-lifecycle-cQFsZFOU.js";
|
|
29
|
+
import { i as resolveAgentInvocationId, o as AgentRunError, s as executeTurn, t as createAgentInvocationWorker } from "./work-CvFoEpRT.js";
|
|
30
|
+
import { a as persistThreadState, c as configValueSchema, i as persistThreadRuntimeState, n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState, s as coerceThreadConversationState, t as getLocationConfigurationService } from "./thread-state-BoNCtSwk.js";
|
|
31
|
+
import { a as getPausedTurnRequest, c as getTurnAuthorization, i as createPausedTurns, n as deleteWebAuthorization, s as wakePausedTurn, t as createWebAuthorization } from "./web-authorization-rDLlKIS0.js";
|
|
32
|
+
import { n as resolveTurnSessionRouting } from "./turn-session-routing-Ba12fwXz.js";
|
|
33
|
+
import { t as bindMessageAgent } from "./message-EyMrVXEf.js";
|
|
34
|
+
import { t as bindSpawnAgent } from "./spawn-CpqxMPWE.js";
|
|
35
|
+
import { a as persistAuthPauseTurnState, c as getTurnUserSlackMessageTs, d as loadPendingMessageCards, i as completeAuthPauseTurn, l as buildDeliveredTurnStatePatch, n as getAgentTurnDiagnosticsAttributes, o as getTurnUserMessage, r as requireTurnFailureEventId, s as getTurnUserReplyAttachmentContext, t as finalizeFailedTurnReplyWithEvent, u as getInterruptionMarker } from "./turn-failure-response-C6jrCPjc.js";
|
|
36
|
+
import { r as storeInputImages } from "./images-Dzh3RBXY.js";
|
|
33
37
|
import { z } from "zod";
|
|
34
38
|
import { createHash } from "node:crypto";
|
|
35
39
|
import { and, asc, count, desc, eq, exists, inArray, ne, or, sql } from "drizzle-orm";
|
|
36
|
-
import {
|
|
40
|
+
import { createSlackSource, createWebSource, localDestinationSchema, objectFactFields, objectPresentation, objectTypeSchema } from "@sentry/junior-plugin-api";
|
|
37
41
|
import { unionAll } from "drizzle-orm/pg-core";
|
|
38
42
|
import { del, get, put } from "@vercel/blob";
|
|
39
43
|
import { Message, ThreadImpl, stringifyMarkdown } from "chat";
|
|
@@ -1569,144 +1573,6 @@ function createSlackTurnRuntime(deps) {
|
|
|
1569
1573
|
};
|
|
1570
1574
|
}
|
|
1571
1575
|
//#endregion
|
|
1572
|
-
//#region src/chat/conversations/web-mailbox.ts
|
|
1573
|
-
/** Parse web mailbox metadata written before Source and Actor were complete. */
|
|
1574
|
-
const legacyWebMailboxMetadataSchema = z.object({
|
|
1575
|
-
authorEmail: z.string().email(),
|
|
1576
|
-
authorFullName: z.string().min(1).optional(),
|
|
1577
|
-
authorUserId: z.string().min(1),
|
|
1578
|
-
authorUserName: z.string().min(1).optional(),
|
|
1579
|
-
kind: z.literal("api_turn"),
|
|
1580
|
-
messageId: z.string().min(1)
|
|
1581
|
-
}).strict();
|
|
1582
|
-
//#endregion
|
|
1583
|
-
//#region src/chat/task-execution/mailbox-turn.ts
|
|
1584
|
-
/**
|
|
1585
|
-
* Restore Turn input facts, with saved Message fallback for legacy cursors.
|
|
1586
|
-
*
|
|
1587
|
-
* TODO(dcramer): Remove Actor and Source reconstruction from the saved Message
|
|
1588
|
-
* after no deployed Turn cursor can omit either field.
|
|
1589
|
-
*/
|
|
1590
|
-
function turnInputFactsFromConversationMessage(message, args) {
|
|
1591
|
-
if (isEventConversationMessage(message)) return {
|
|
1592
|
-
actor: args.savedActor ?? EVENT_SYSTEM_ACTOR,
|
|
1593
|
-
author: message.author ?? EVENT_MESSAGE_AUTHOR,
|
|
1594
|
-
source: args.savedSource ?? (args.location ? createWebSource(args.conversationId, args.visibility === "private" ? "private" : "public") : createLocalSource(args.conversationId))
|
|
1595
|
-
};
|
|
1596
|
-
const actor = args.savedActor ?? createActor(message.author, {
|
|
1597
|
-
platform: "web",
|
|
1598
|
-
userId: message.author?.userId
|
|
1599
|
-
});
|
|
1600
|
-
if (actor?.platform !== "web") return;
|
|
1601
|
-
return {
|
|
1602
|
-
actor,
|
|
1603
|
-
author: message.author ?? { userId: actor.userId },
|
|
1604
|
-
source: args.savedSource?.kind === "web" ? args.savedSource : createWebSource(args.conversationId, args.visibility === "private" ? "private" : "public")
|
|
1605
|
-
};
|
|
1606
|
-
}
|
|
1607
|
-
/** Normalize the selected mailbox Source with current Conversation visibility. */
|
|
1608
|
-
function sourceFromTurnInput(args) {
|
|
1609
|
-
if (args.source.kind === "web") return createWebSource(args.conversationId, args.visibility === "private" ? "private" : "public");
|
|
1610
|
-
return args.source;
|
|
1611
|
-
}
|
|
1612
|
-
function hasEventActor(actors) {
|
|
1613
|
-
return Boolean(actors?.some((actor) => actor.platform === "system" && actor.name === EVENT_SYSTEM_ACTOR.name));
|
|
1614
|
-
}
|
|
1615
|
-
/** Return the active web Turn for one Conversation, if it has one. */
|
|
1616
|
-
async function getActiveConversationTurnId(conversationId) {
|
|
1617
|
-
const active = (await listTurnSummaries(conversationId)).filter((summary) => summary.surface === "api" && !summary.dispatchId && (summary.state === "paused" || summary.state === "running"));
|
|
1618
|
-
if (active.length > 1) throw new Error(`Conversation ${conversationId} has multiple active web turns`);
|
|
1619
|
-
const turnId = active[0]?.turnId;
|
|
1620
|
-
if (!turnId) return void 0;
|
|
1621
|
-
const record = await getTurnRecord(conversationId, turnId);
|
|
1622
|
-
return record && (record.source?.kind === "web" || !record.source && record.surface === "api") && !record.dispatchId && (record.state === "paused" || record.state === "running") ? turnId : void 0;
|
|
1623
|
-
}
|
|
1624
|
-
/** Return the active web or event mailbox Turn. */
|
|
1625
|
-
async function getActiveMailboxTurnId(conversationId) {
|
|
1626
|
-
const summaries = await listTurnSummaries(conversationId);
|
|
1627
|
-
const active = (await Promise.all(summaries.filter((summary) => !summary.dispatchId && (summary.state === "paused" || summary.state === "running")).map((summary) => getTurnRecord(conversationId, summary.turnId)))).filter((record) => record && !record.dispatchId && (record.source?.kind === "web" || record.source?.kind === "event" || !record.source && (record.surface === "api" || hasEventActor(record.actors))) && (record.state === "paused" || record.state === "running"));
|
|
1628
|
-
if (active.length > 1) throw new Error(`Conversation ${conversationId} has multiple active mailbox Turns`);
|
|
1629
|
-
return active[0]?.turnId;
|
|
1630
|
-
}
|
|
1631
|
-
/** Return the idle auth-paused web Turn for one Conversation. */
|
|
1632
|
-
async function getAuthPausedConversationTurnId(conversationId) {
|
|
1633
|
-
const turnId = await getActiveConversationTurnId(conversationId);
|
|
1634
|
-
if (!turnId) return void 0;
|
|
1635
|
-
const record = await getTurnRecord(conversationId, turnId);
|
|
1636
|
-
return record?.state === "paused" && record.resumeReason === "auth" ? turnId : void 0;
|
|
1637
|
-
}
|
|
1638
|
-
function parseWebMessages(messages) {
|
|
1639
|
-
if (messages.length === 0) return [];
|
|
1640
|
-
const parsed = messages.map((message) => ({
|
|
1641
|
-
message,
|
|
1642
|
-
metadata: legacyWebMailboxMetadataSchema.safeParse(message.input.metadata)
|
|
1643
|
-
}));
|
|
1644
|
-
if (parsed.every((entry) => !entry.metadata.success)) return [];
|
|
1645
|
-
if (parsed.some((entry) => !entry.metadata.success)) throw new Error("A Turn cannot combine different kinds of input");
|
|
1646
|
-
return parsed.map((entry) => {
|
|
1647
|
-
if (!entry.metadata.success) throw new Error("User message has invalid metadata");
|
|
1648
|
-
const metadata = entry.metadata.data;
|
|
1649
|
-
const actor = {
|
|
1650
|
-
platform: "web",
|
|
1651
|
-
userId: metadata.authorUserId,
|
|
1652
|
-
email: metadata.authorEmail.trim().toLowerCase(),
|
|
1653
|
-
...metadata.authorFullName ? { fullName: metadata.authorFullName } : void 0,
|
|
1654
|
-
...metadata.authorUserName ? { userName: metadata.authorUserName } : void 0
|
|
1655
|
-
};
|
|
1656
|
-
return {
|
|
1657
|
-
actor,
|
|
1658
|
-
author: {
|
|
1659
|
-
email: actor.email,
|
|
1660
|
-
...actor.fullName ? { fullName: actor.fullName } : void 0,
|
|
1661
|
-
userId: actor.userId,
|
|
1662
|
-
...actor.userName ? { userName: actor.userName } : void 0
|
|
1663
|
-
},
|
|
1664
|
-
message: entry.message,
|
|
1665
|
-
source: createWebSource(entry.message.conversationId)
|
|
1666
|
-
};
|
|
1667
|
-
});
|
|
1668
|
-
}
|
|
1669
|
-
function parseEventMessages(messages) {
|
|
1670
|
-
if (messages.length === 0) return [];
|
|
1671
|
-
if (!messages.every((message) => message.source === "event" && isEventMailboxMetadata(message.input.metadata))) return [];
|
|
1672
|
-
return messages.map((message) => {
|
|
1673
|
-
if (!isEventMailboxMetadata(message.input.metadata)) throw new Error("Event has invalid metadata");
|
|
1674
|
-
return {
|
|
1675
|
-
actor: EVENT_SYSTEM_ACTOR,
|
|
1676
|
-
author: EVENT_MESSAGE_AUTHOR,
|
|
1677
|
-
message,
|
|
1678
|
-
source: createEventSource({
|
|
1679
|
-
eventKey: message.input.metadata.event.eventKey,
|
|
1680
|
-
eventType: message.input.metadata.event.eventType,
|
|
1681
|
-
identifier: message.input.metadata.event.identifier,
|
|
1682
|
-
namespace: message.input.metadata.event.namespace
|
|
1683
|
-
})
|
|
1684
|
-
};
|
|
1685
|
-
});
|
|
1686
|
-
}
|
|
1687
|
-
/**
|
|
1688
|
-
* Select web or event work from new mailbox input or a saved Turn.
|
|
1689
|
-
* Saved Actor data identifies a resumed event Turn.
|
|
1690
|
-
*/
|
|
1691
|
-
async function resolveMailboxTurnWork(context) {
|
|
1692
|
-
const batch = parseWebMessages(context.attempt.messages);
|
|
1693
|
-
if (batch.length > 0) return {
|
|
1694
|
-
kind: "mailbox",
|
|
1695
|
-
batch
|
|
1696
|
-
};
|
|
1697
|
-
const resourceBatch = parseEventMessages(context.attempt.messages);
|
|
1698
|
-
if (resourceBatch.length > 0) return {
|
|
1699
|
-
kind: "mailbox",
|
|
1700
|
-
batch: resourceBatch
|
|
1701
|
-
};
|
|
1702
|
-
if (context.attempt.messages.length > 0) return;
|
|
1703
|
-
const turnId = await getActiveMailboxTurnId(context.conversationId);
|
|
1704
|
-
return turnId ? {
|
|
1705
|
-
kind: "resume",
|
|
1706
|
-
turnId
|
|
1707
|
-
} : void 0;
|
|
1708
|
-
}
|
|
1709
|
-
//#endregion
|
|
1710
1576
|
//#region src/chat/conversations/stop.ts
|
|
1711
1577
|
/** Stop the current Conversation Turn and wake an idle resume when needed. */
|
|
1712
1578
|
async function stopConversationTurn(args) {
|
|
@@ -4257,17 +4123,6 @@ async function resolveDestinationVisibility(args) {
|
|
|
4257
4123
|
}
|
|
4258
4124
|
//#endregion
|
|
4259
4125
|
//#region src/chat/providers/slack/input.ts
|
|
4260
|
-
/**
|
|
4261
|
-
* Return a stable key for one steering message. Resolved attachments may change
|
|
4262
|
-
* when Junior retries a mailbox delivery, so only the message time and text
|
|
4263
|
-
* form the key.
|
|
4264
|
-
*/
|
|
4265
|
-
function steeringMessageKey(message) {
|
|
4266
|
-
if (message.role !== "user") return;
|
|
4267
|
-
const first = Array.isArray(message.content) ? message.content[0] : void 0;
|
|
4268
|
-
const text = first && typeof first === "object" && "text" in first ? String(first.text ?? "") : "";
|
|
4269
|
-
return `${message.timestamp}:${text}`;
|
|
4270
|
-
}
|
|
4271
4126
|
function renderRecentThreadMessageLines(conversationContext, messages) {
|
|
4272
4127
|
const messagesForContext = messages.filter((queued) => {
|
|
4273
4128
|
if (queued.explicitMention) return false;
|
|
@@ -4362,11 +4217,7 @@ async function saveSteeringMessages(args) {
|
|
|
4362
4217
|
if (!lock) return false;
|
|
4363
4218
|
try {
|
|
4364
4219
|
const projection = await loadConversationProjection({ conversationId: args.conversationId });
|
|
4365
|
-
const
|
|
4366
|
-
const missing = args.messages.filter((entry) => {
|
|
4367
|
-
const key = steeringMessageKey(entry.message);
|
|
4368
|
-
return key === void 0 || !savedKeys.has(key);
|
|
4369
|
-
});
|
|
4220
|
+
const missing = withoutSavedSteeringMessages(projection.messages, args.messages, (entry) => entry.message);
|
|
4370
4221
|
if (missing.length === 0) return true;
|
|
4371
4222
|
await commitMessages({
|
|
4372
4223
|
conversationId: args.conversationId,
|
|
@@ -4901,11 +4752,7 @@ function createSlackTurn(deps) {
|
|
|
4901
4752
|
throw new TurnInputDeferredError();
|
|
4902
4753
|
}
|
|
4903
4754
|
if (batchedSteeringMessages.length > 0) {
|
|
4904
|
-
const
|
|
4905
|
-
const newSteeringMessages = batchedSteeringMessages.map((entry) => entry.message).filter((batchedMessage) => {
|
|
4906
|
-
const key = steeringMessageKey(batchedMessage);
|
|
4907
|
-
return key === void 0 || !presentKeys.has(key);
|
|
4908
|
-
});
|
|
4755
|
+
const newSteeringMessages = withoutSavedSteeringMessages(piMessages ?? [], batchedSteeringMessages.map((entry) => entry.message), (message) => message);
|
|
4909
4756
|
if (newSteeringMessages.length > 0) piMessages = [...piMessages ?? [], ...newSteeringMessages];
|
|
4910
4757
|
}
|
|
4911
4758
|
status.update();
|
|
@@ -6710,12 +6557,6 @@ async function commitAssistantMessage(args) {
|
|
|
6710
6557
|
}
|
|
6711
6558
|
}
|
|
6712
6559
|
//#endregion
|
|
6713
|
-
//#region src/chat/task-execution/mailbox-input.ts
|
|
6714
|
-
/** Join non-empty mailbox Message text for one Turn. */
|
|
6715
|
-
function joinMailboxText(messages) {
|
|
6716
|
-
return messages.map((message) => message.input.text.trim()).filter(Boolean).join("\n\n");
|
|
6717
|
-
}
|
|
6718
|
-
//#endregion
|
|
6719
6560
|
//#region src/chat/conversations/destination.ts
|
|
6720
6561
|
function requireLocalDestination(conversationId) {
|
|
6721
6562
|
const parsed = localDestinationSchema.safeParse({
|
|
@@ -6738,10 +6579,6 @@ function resolveConversationDestination(args) {
|
|
|
6738
6579
|
//#endregion
|
|
6739
6580
|
//#region src/chat/task-execution/conversation-turn.ts
|
|
6740
6581
|
/** Run a mailbox Turn and store its assistant Messages. */
|
|
6741
|
-
/** Extra debounce time added per additional event already batched. */
|
|
6742
|
-
const EVENT_WAIT_PER_EXTRA_MESSAGE_MS = 5e3;
|
|
6743
|
-
/** Upper bound on the debounce window regardless of batch size. */
|
|
6744
|
-
const EVENT_MAX_WAIT_MS = 6e4;
|
|
6745
6582
|
function stableHex$1(...parts) {
|
|
6746
6583
|
return createHash("sha256").update(parts.join("\0")).digest("hex").slice(0, 24);
|
|
6747
6584
|
}
|
|
@@ -6805,15 +6642,11 @@ async function completeCancelledConversationTurn(args) {
|
|
|
6805
6642
|
function createConversationTurnWorker(agentRunner, deliverMessage) {
|
|
6806
6643
|
return async (context, resolved) => {
|
|
6807
6644
|
if (resolved.kind === "mailbox") {
|
|
6808
|
-
const
|
|
6809
|
-
if (
|
|
6810
|
-
|
|
6811
|
-
|
|
6812
|
-
|
|
6813
|
-
status: "deferred",
|
|
6814
|
-
delayMs
|
|
6815
|
-
};
|
|
6816
|
-
}
|
|
6645
|
+
const delayMs = getEventBatchDelayMs(resolved.batch.map((entry) => entry.message));
|
|
6646
|
+
if (delayMs > 0) return {
|
|
6647
|
+
status: "deferred",
|
|
6648
|
+
delayMs
|
|
6649
|
+
};
|
|
6817
6650
|
}
|
|
6818
6651
|
const lifecycle = new ConversationTurnLifecycleService(getConversationEventStore());
|
|
6819
6652
|
const isResume = resolved.kind === "resume";
|
|
@@ -7310,11 +7143,13 @@ function createConversationWork(options) {
|
|
|
7310
7143
|
throw new Error(`Conversation ${context.conversationId} has a ${destination.platform} destination but no matching conversation worker`);
|
|
7311
7144
|
};
|
|
7312
7145
|
const run = async (context) => {
|
|
7313
|
-
const
|
|
7146
|
+
const skipped = await skipInputBeforeConversationStop(context);
|
|
7147
|
+
if (skipped) return skipped;
|
|
7148
|
+
const childInput = await startAgentInvocationsForChildInput(context, {
|
|
7314
7149
|
queue: options.queue,
|
|
7315
7150
|
state: options.state
|
|
7316
7151
|
});
|
|
7317
|
-
if (
|
|
7152
|
+
if (childInput) return childInput;
|
|
7318
7153
|
const mailboxTurn = await resolveMailboxTurnWork(context);
|
|
7319
7154
|
if (mailboxTurn) return await conversationTurnWorker(context, await withAgentInvocationResultActors(mailboxTurn));
|
|
7320
7155
|
const invocationId = await resolveAgentInvocationId(context);
|
|
@@ -7549,4 +7384,4 @@ async function appendAndEnqueueWebMessage(input, options) {
|
|
|
7549
7384
|
};
|
|
7550
7385
|
}
|
|
7551
7386
|
//#endregion
|
|
7552
|
-
export { withNormalizedThreadId as A,
|
|
7387
|
+
export { withNormalizedThreadId as A, readHealthReport as B, buildSlackInboundMessage as C, isSlackMessageStopped as D, verifySlackSignature as E, renderSlackObjectCard as F, createVercelAttachmentStorage as I, AGENT_DISPATCH_MAX_AGE_MS as L, THREAD_OPTOUT_ACK as M, startProcessingReaction as N, stopSlackThread as O, parseContent as P, enqueueAgentDispatch as R, recordSkippedConversationMessage as S, runWithSlackInstallation as T, readViewerAutomationRuns as _, recordWebConversationActivity as a, readViewerAutomations as b, createProductionSlackWebhookServices as c, resolveSlackConversationContextFromThreadId as d, createSlackWebApiStatusSender as f, readViewerAutomationExecutions as g, readConversationSourceTask as h, createConversationId as i, stopConversationTurn as j, normalizeIncomingSlackThreadId as k, getProductionSlackAdapter as l, deleteViewerTask as m, conversationTurnIdForMessage as n, webActorFromEmail as o, ViewerTaskNotFoundError as p, createAndEnqueueConversation as r, createProductionConversationWorkOptions as s, appendAndEnqueueWebMessage as t, formatSlackConversationRedactedLabel as u, readViewerAutomationSummary as v, clearSlackPendingReactions as w, resolveViewerTaskCandidate as x, readViewerAutomationVersions as y, GET as z };
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
|
|
2
|
-
import {
|
|
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-CnlFtbzb.js";
|
|
3
|
+
import { n as botConfig } from "./config-aitDvTQm.js";
|
|
4
|
+
import { c as getConversationEventStore, u as getConversationStore } from "./viewer-CX41TWYr.js";
|
|
5
|
+
import { f as instructionProvenanceFor, p as sameActorIdentity } from "./history-Nte1oVed.js";
|
|
6
|
+
import { J as saveTurnCheckpoint, Nt as openConversationProjection, Q as getTurnRecord, Y as abandonTurnRecord, Z as failTurnRecord, ct as isTurnExecutionLimitExceededError, dt as getTerminalAssistantMessages } from "./tasks-DREdnhVP.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-BxCi7V4v.js";
|
|
9
|
+
import { A as recordFinishedTurnForAutomatedLimit, j as resetAutomatedTurnLimit, k as maybePostAutomatedTurnLimitNotice } from "./session-stop-dyvsZDB0.js";
|
|
10
|
+
import { r as appendAndEnqueueInboundMessage } from "./store-OMQAFrJG.js";
|
|
11
|
+
import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-cQFsZFOU.js";
|
|
12
|
+
import { n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState } from "./thread-state-BoNCtSwk.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());
|
|
@@ -207,6 +273,19 @@ async function saveAgentInvocationResult(args) {
|
|
|
207
273
|
source: args.invocation.source,
|
|
208
274
|
surface: "internal"
|
|
209
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
|
+
}
|
|
210
289
|
const terminal = await completeAgentInvocation({
|
|
211
290
|
invocationId: args.invocation.invocationId,
|
|
212
291
|
...failed ? {
|
|
@@ -270,7 +349,7 @@ function createAgentInvocationWorker(agentRunner, options = {}) {
|
|
|
270
349
|
};
|
|
271
350
|
const finish = async (terminal) => {
|
|
272
351
|
if (!terminal || !isTerminalAgentInvocation(terminal)) return;
|
|
273
|
-
await persistTerminalLifecycle(terminal);
|
|
352
|
+
if (terminal.parentMailboxStatus !== "steered") await persistTerminalLifecycle(terminal);
|
|
274
353
|
await report(terminal);
|
|
275
354
|
};
|
|
276
355
|
let acknowledged = context.attempt.messages.length === 0;
|
|
@@ -351,6 +430,7 @@ function createAgentInvocationWorker(agentRunner, options = {}) {
|
|
|
351
430
|
try {
|
|
352
431
|
outcome = await executeTurn(agentRunner, {
|
|
353
432
|
conversationId: invocation.childConversationId,
|
|
433
|
+
parentConversationId: invocation.parentConversationId,
|
|
354
434
|
turnId,
|
|
355
435
|
runId: invocation.invocationId,
|
|
356
436
|
instruction: { text: invocation.input },
|
|
@@ -362,14 +442,10 @@ function createAgentInvocationWorker(agentRunner, options = {}) {
|
|
|
362
442
|
...location ? { location } : void 0,
|
|
363
443
|
surface: "internal",
|
|
364
444
|
...stopSignal ? { signal: stopSignal } : void 0,
|
|
365
|
-
|
|
366
|
-
"handoff",
|
|
367
|
-
"interactive-auth",
|
|
368
|
-
"subagents"
|
|
369
|
-
],
|
|
370
|
-
reasoning: invocation.reasoningLevel,
|
|
445
|
+
...agentInvocationRunPolicy(invocation, canSpawn),
|
|
371
446
|
state: { sandboxRef },
|
|
372
447
|
durability: {
|
|
448
|
+
drainSteeringMessages: createAgentMessageSteeringDrain(context, invocation),
|
|
373
449
|
onInputCommitted: acknowledge,
|
|
374
450
|
shouldYield: context.shouldYield,
|
|
375
451
|
onSandboxRefChanged: async (nextSandboxRef) => {
|
|
@@ -398,7 +474,7 @@ function createAgentInvocationWorker(agentRunner, options = {}) {
|
|
|
398
474
|
await acknowledge();
|
|
399
475
|
return { status: "completed" };
|
|
400
476
|
}
|
|
401
|
-
if (!context.attempt.isFinalAttempt) throw runError;
|
|
477
|
+
if (!context.attempt.isFinalAttempt && !isTurnExecutionLimitExceededError(runError)) throw runError;
|
|
402
478
|
await finish(await completeAgentInvocation({
|
|
403
479
|
invocationId: invocation.invocationId,
|
|
404
480
|
errorMessage: runError instanceof Error ? runError.message : "Agent invocation failed",
|
|
@@ -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-CWQtbizj.js";
|
|
3
|
+
import { C as withLogContext, d as logException, f as logInfo, p as logWarn } from "./logging-OpC2jwiV.js";
|
|
4
|
+
import { i as getChatConfig } from "./config-aitDvTQm.js";
|
|
5
|
+
import { f as getTurnRequestDeadline, m as ConversationQueueMessageRejectedError } from "./job-queue-DyA2AEnY.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-OMQAFrJG.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;
|