@sentry/junior 0.275.0 → 0.277.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/{adapter-dE2BiWP_.js → adapter-BtfBHVM5.js} +1 -1
- package/dist/{admin-CkPaAYuZ.js → admin-DzAKbZsm.js} +1 -1
- package/dist/{agent-invocations-C1RNOCs8.js → agent-invocations-Crs3XHhg.js} +6 -1
- package/dist/{agent-runner-bE7aH7ew.js → agent-runner-BsYAbniN.js} +394 -244
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +4 -4
- package/dist/api.d.ts +13 -2
- package/dist/api.js +186 -68
- package/dist/{app-CgkquhZ8.d.ts → app-BjEQwNVP.d.ts} +11 -3
- package/dist/app.d.ts +2 -2
- package/dist/app.js +227 -112
- package/dist/{assistant-reply-CjRU9Z59.js → assistant-reply-NebRGG4G.js} +1 -1
- package/dist/{automation-BGrd03QO.js → automation-Cql9h2vO.js} +42 -13
- package/dist/{background-compaction-queue-BYuOt3qK.js → background-compaction-queue-hh18yCeU.js} +2 -2
- package/dist/{briefs-6xUvmGos.js → briefs-BBo0Eimi.js} +4 -4
- package/dist/{catalog-runtime-DcJ5NHDW.js → catalog-runtime-DE-F4Awo.js} +1 -1
- package/dist/cli/chat.d.ts +1 -1
- package/dist/cli/chat.js +14 -14
- package/dist/cli/check.js +3 -3
- package/dist/cli/main.js +3 -3
- package/dist/cli/plugins.d.ts +1 -1
- package/dist/cli/plugins.js +4 -4
- package/dist/cli/snapshot-create.js +4 -4
- package/dist/cli/upgrade.d.ts +2 -2
- package/dist/cli/upgrade.js +3 -3
- package/dist/{client-gnKpkpqP.js → client-DZ8HTnYH.js} +2 -2
- package/dist/{config-D0GKc9sC.js → config-D5uUtrCP.js} +2 -2
- package/dist/{connections-DLqP5Bp1.js → connections-Do24CGP5.js} +14 -14
- package/dist/{conversation-BjTo9ZFL.js → conversation-SsASlWL7.js} +35 -12
- package/dist/{conversation-privacy-BCXFshP9.js → conversation-privacy-VuylvlKr.js} +1 -1
- package/dist/{credential-sync-BjihXFF2.js → credential-sync-BGQK3pOa.js} +13 -13
- package/dist/{db-BMZhoYKj.d.ts → db-DEiwO5Sh.d.ts} +1 -1
- package/dist/{executor-j8VMt-To.js → executor-hPfFTH0C.js} +13 -5
- package/dist/instrumentation.d.ts +14 -0
- package/dist/instrumentation.js +29 -6
- package/dist/{logging-CFHIO4Vs.js → logging-cI3T1dNc.js} +4 -2
- package/dist/{message-DH0cqFRS.js → message-DBwsAl7O.js} +9 -9
- package/dist/nitro.d.ts +2 -2
- package/dist/nitro.js +7 -3
- package/dist/{oauth-callback-server-BgU4EZsJ.js → oauth-callback-server-DXrnbplb.js} +2 -2
- package/dist/{plugins-B_0Cr0MO.d.ts → plugins-DtmjkTza.d.ts} +1 -0
- package/dist/{projection-CTvLSwcm.js → projection-7EFIqzuj.js} +4108 -3898
- package/dist/{prompt-JEWUUpLW.js → prompt-oRfGsxd3.js} +1 -1
- package/dist/{registry-OsyWR4GO.js → registry-Bzefs7kT.js} +24 -8
- package/dist/{resolve-DCrKjmVP.js → resolve-CuiEY_2u.js} +3 -3
- package/dist/{result-Btdt5bSl.js → result-DrcUtFaD.js} +9 -9
- package/dist/{runner-C1AwS93W.js → runner-CDE4CZ52.js} +12 -12
- package/dist/{sandbox-egress-signals-C-5i7Zxm.js → sandbox-egress-signals-0tcmGd13.js} +1 -1
- package/dist/{schema-DfdHlBnb.d.ts → schema-B6N2nc6v.d.ts} +108 -15
- package/dist/{schema-CX9XGKCm.js → schema-Dzi3lkdP.js} +25 -8
- package/dist/{service-account-DZX1KlQl.js → service-account-BOz9pqOE.js} +3 -3
- package/dist/{service-account-CQIW6At4.js → service-account-DIyz_9Uh.js} +3 -3
- package/dist/{session-stop-DjIyORJw.js → session-stop-0juF_BP0.js} +159 -55
- package/dist/{skills-BEfAAT6p.js → skills-CU5Is147.js} +2 -2
- package/dist/{spawn-Dgj4xxvO.js → spawn-6C9jHH4b.js} +2 -2
- package/dist/{stop-DomyNvuv.js → stop-6FVG1c-r.js} +487 -203
- package/dist/{store-Dp3RMEQd.js → store-DKs1WwdB.js} +3 -3
- package/dist/{store-B7Z6zIc7.js → store-DtHZviJ1.js} +11 -9
- package/dist/{task-queue-CVQ9cWnC.js → task-queue-CcvFQE_p.js} +3 -3
- package/dist/{task-runner-DHBG47gS.js → task-runner-DBkNejLl.js} +6 -6
- package/dist/{thread-state-BF8VwIxd.js → thread-state-4hjEIkIq.js} +4 -4
- package/dist/{turn-failure-response-Di7TbgsF.js → turn-failure-response-BZNLydC3.js} +7 -7
- package/dist/{turn-lifecycle-DzXwXmLg.js → turn-lifecycle-BhqYjaa4.js} +6 -1
- package/dist/{turn-session-routing-CIWhXKeT.js → turn-session-routing-jnLOfBHJ.js} +17 -16
- package/dist/{validation-BRmwRaXc.js → validation-BUFmsnKs.js} +1 -1
- package/dist/{version-DBVMsgvA.js → version-DJTk0ZCE.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-BFADRGP8.js → viewer-WY0RYE4E.js} +53 -15
- package/dist/{work-DDaoxZAw.js → work-C5AKvXJV.js} +30 -12
- package/dist/{worker-Bub0fDtW.js → worker-BcYVDVUy.js} +6 -6
- package/migrations/0073_conversation_quick_question.sql +1 -0
- package/migrations/0074_conversation_participant_pins.sql +1 -0
- package/migrations/0075_conversation_detail_version.sql +1 -0
- package/migrations/0076_conversation_auto_archive.sql +5 -0
- package/migrations/meta/0073_snapshot.json +4070 -0
- package/migrations/meta/0074_snapshot.json +4076 -0
- package/migrations/meta/0075_snapshot.json +4299 -0
- package/migrations/meta/0076_snapshot.json +4363 -0
- package/migrations/meta/_journal.json +29 -1
- package/package.json +5 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { At as recordConversationRetry$1, Dt as listActiveConversationIds$1, Ft as startConversationWork$1, It as steerWebPendingMessages$1, Lt as stopConversationWork$1, Mt as removeActiveConversation$1, Nt as requestAnotherSlice$1, Ot as markConversationWorkEnqueued$1, Pt as requestConversationWork$1, St as getConversationWorkState$1, _t as completeConversationStop$1, bt as drainConversationMailbox$1, dt as appendInboundMessage, ft as beginConversationResume$1, gt as clearExpiredConversationLease$1, ht as clearConsumedConversationWake$1, jt as releaseConversationWork$1, kt as recordAttemptFailure$1, lt as ackMessages$1, mt as checkInConversationWork$1, pt as cancelHumanFacingPendingMessages$1, ut as appendExclusiveInboundMessage, vt as completeConversationWork$1, xt as getConversation$1, yt as deadLetterAttempt$1 } from "./projection-
|
|
2
|
-
import { x as getConversationStore } from "./viewer-
|
|
3
|
-
import "./background-compaction-queue-
|
|
1
|
+
import { At as recordConversationRetry$1, Dt as listActiveConversationIds$1, Ft as startConversationWork$1, It as steerWebPendingMessages$1, Lt as stopConversationWork$1, Mt as removeActiveConversation$1, Nt as requestAnotherSlice$1, Ot as markConversationWorkEnqueued$1, Pt as requestConversationWork$1, St as getConversationWorkState$1, _t as completeConversationStop$1, bt as drainConversationMailbox$1, dt as appendInboundMessage, ft as beginConversationResume$1, gt as clearExpiredConversationLease$1, ht as clearConsumedConversationWake$1, jt as releaseConversationWork$1, kt as recordAttemptFailure$1, lt as ackMessages$1, mt as checkInConversationWork$1, pt as cancelHumanFacingPendingMessages$1, ut as appendExclusiveInboundMessage, vt as completeConversationWork$1, xt as getConversation$1, yt as deadLetterAttempt$1 } from "./projection-7EFIqzuj.js";
|
|
2
|
+
import { x as getConversationStore } from "./viewer-WY0RYE4E.js";
|
|
3
|
+
import "./background-compaction-queue-hh18yCeU.js";
|
|
4
4
|
// src/chat/task-execution/store.ts
|
|
5
5
|
function metadataStore(options) {
|
|
6
6
|
return options.conversationStore ?? getConversationStore();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { c as modelProfileSchema, u as TURN_REASONING_LEVELS } from "./model-profile-B998sjVd.js";
|
|
2
|
-
import { C as getSqlExecutor, x as getConversationStore } from "./viewer-
|
|
3
|
-
import { a as juniorAgentInvocations, i as juniorAgentBindings, n as AGENT_INVOCATION_PARENT_MAILBOX_STATUSES, t as AGENT_INVOCATION_MAILBOX_STATUSES } from "./agent-invocations-
|
|
4
|
-
import "./executor-
|
|
5
|
-
import { p as credentialContextSchema } from "./registry-
|
|
2
|
+
import { C as getSqlExecutor, x as getConversationStore } from "./viewer-WY0RYE4E.js";
|
|
3
|
+
import { a as juniorAgentInvocations, i as juniorAgentBindings, n as AGENT_INVOCATION_PARENT_MAILBOX_STATUSES, t as AGENT_INVOCATION_MAILBOX_STATUSES } from "./agent-invocations-Crs3XHhg.js";
|
|
4
|
+
import "./executor-hPfFTH0C.js";
|
|
5
|
+
import { p as credentialContextSchema } from "./registry-Bzefs7kT.js";
|
|
6
6
|
import { createHash } from "node:crypto";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
import { and, asc, count, countDistinct, desc, eq, inArray, lt, ne, or, sql } from "drizzle-orm";
|
|
@@ -304,6 +304,8 @@ const TERMINAL_AGENT_INVOCATION_STATUSES = [
|
|
|
304
304
|
"failed",
|
|
305
305
|
"stopped"
|
|
306
306
|
];
|
|
307
|
+
/** Statuses of an agent invocation that owns its child's Turn. */
|
|
308
|
+
const ACTIVE_AGENT_INVOCATION_STATUSES = ["running", "paused"];
|
|
307
309
|
/** Statuses of an agent invocation that has not finished. */
|
|
308
310
|
const NON_TERMINAL_AGENT_INVOCATION_STATUSES = [
|
|
309
311
|
"pending",
|
|
@@ -406,13 +408,13 @@ async function getAgentInvocation(invocationId) {
|
|
|
406
408
|
const rows = await getSqlExecutor().db().select().from(juniorAgentInvocations).where(eq(juniorAgentInvocations.invocationId, invocationId));
|
|
407
409
|
return rows[0] ? invocationFromRow(rows[0]) : void 0;
|
|
408
410
|
}
|
|
409
|
-
/** List the
|
|
410
|
-
async function
|
|
411
|
-
return (await getSqlExecutor().db().select().from(juniorAgentInvocations).where(and(eq(juniorAgentInvocations.childConversationId, childConversationId), inArray(juniorAgentInvocations.status, [
|
|
411
|
+
/** List the agent invocations of one child Conversation in the given statuses. */
|
|
412
|
+
async function listAgentInvocationsForConversation(childConversationId, statuses) {
|
|
413
|
+
return (await getSqlExecutor().db().select().from(juniorAgentInvocations).where(and(eq(juniorAgentInvocations.childConversationId, childConversationId), inArray(juniorAgentInvocations.status, [...statuses]))).orderBy(asc(juniorAgentInvocations.createdAt))).map(invocationFromRow);
|
|
412
414
|
}
|
|
413
415
|
/** Resolve the single invocation that may resume for one child conversation. */
|
|
414
416
|
async function getActiveAgentInvocationForConversation(childConversationId) {
|
|
415
|
-
const active = await
|
|
417
|
+
const active = await listAgentInvocationsForConversation(childConversationId, ACTIVE_AGENT_INVOCATION_STATUSES);
|
|
416
418
|
if (active.length > 1) throw new Error(`Child conversation ${childConversationId} has multiple active agent invocations`);
|
|
417
419
|
return active[0];
|
|
418
420
|
}
|
|
@@ -711,4 +713,4 @@ async function markAgentInvocationSteered(invocationId, nowMs = Date.now()) {
|
|
|
711
713
|
function isTerminalAgentInvocation(invocation) {
|
|
712
714
|
return TERMINAL_AGENT_INVOCATION_STATUSES.includes(invocation.status);
|
|
713
715
|
}
|
|
714
|
-
export {
|
|
716
|
+
export { markTurnFailed as $, AgentInvocationLimitError as A, agentTypeInstructions as B, markAgentInvocationMailboxAppended as C, markAgentInvocationSteered as D, markAgentInvocationRunning as E, findChildAgentConversationId as F, TurnInputCommitLostError as G, formatAgentTypes as H, CHILD_AGENT_RESULTS as I, isCooperativeTurnYieldError as J, TurnInputDeferredError as K, PARENT_AGENT_TARGET as L, AgentMessageQueueFullError as M, AgentMessageTargetError as N, parseAgentInvocationResultMessageId as O, AgentNameInUseError as P, markTurnCompleted as Q, agentNameSchema as R, listPendingAgentInvocationResults as S, markAgentInvocationPaused as T, ConversationTurnBoundaryError as U, agentTypeStartsWithParentHistory as V, CooperativeTurnYieldError as W, isTurnInputDeferredError as X, isTurnInputCommitLostError as Y, markTurnClosed as Z, getLatestAgentInvocationForConversation as _, createAgentInvocationForMessage as a, listAgentInvocationsForConversation as b, getAgentInvocation as c, getAgentInvocationIdForResult as d, startActiveTurn as et, getAgentInvocationMessageId as f, getChildAgentLockName as g, getChildAgentLabel as h, createAgentInvocation as i, AgentMessagePausedError as j, reportReplacedAgentInvocation as k, getAgentInvocationIdForEvents as l, getAgentInvocationTurnId as m, NON_TERMINAL_AGENT_INVOCATION_STATUSES as n, createAgentInvocationFromLatest as o, getAgentInvocationResultMessageId as p, getConversationTurnBoundaryError as q, completeAgentInvocation as r, getActiveAgentInvocationForConversation as s, ACTIVE_AGENT_INVOCATION_STATUSES as t, getAgentInvocationIdForMessage as u, invocationFromRow as v, markAgentInvocationParentMailboxAppended as w, listPendingAgentInvocationMailboxAppends as x, isTerminalAgentInvocation as y, AGENT_TYPES as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { h as logWarn } from "./logging-
|
|
2
|
-
import { _ as runWithTurnRequestDeadline, f as QUEUE_SIGNATURE_MAX_AGE_MS, h as getQueueProvider, m as verifyQueueMessage, p as signQueueMessage } from "./background-compaction-queue-
|
|
1
|
+
import { h as logWarn } from "./logging-cI3T1dNc.js";
|
|
2
|
+
import { _ as runWithTurnRequestDeadline, f as QUEUE_SIGNATURE_MAX_AGE_MS, h as getQueueProvider, m as verifyQueueMessage, p as signQueueMessage } from "./background-compaction-queue-hh18yCeU.js";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
// src/chat/queue/callback.ts
|
|
@@ -110,7 +110,7 @@ function pluginTaskCallback() {
|
|
|
110
110
|
maxDeliveries: PLUGIN_TASK_MAX_DELIVERIES,
|
|
111
111
|
onRejected: logPluginTaskQueueMessageRejected,
|
|
112
112
|
run: async (message) => {
|
|
113
|
-
const { processPluginTask } = await import("./task-runner-
|
|
113
|
+
const { processPluginTask } = await import("./task-runner-DBkNejLl.js").then((n) => n.r);
|
|
114
114
|
await processPluginTask(message);
|
|
115
115
|
},
|
|
116
116
|
topic: PLUGIN_TASK_QUEUE_TOPIC,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
|
|
2
|
-
import { $t as instructionTextForProjection, Bn as
|
|
2
|
+
import { $t as instructionTextForProjection, Bn as getPlugins, Jr as createPluginState, Jt as getPiMessageRole, Ma as createPluginLogger, Un as coreTaskRegistrations, Wa as createPluginConversationEvents, an as normalizeToolNameFromResult, co as createPluginCache, in as isToolResultMessage, it as getTurnRecord, rn as isToolResultError, sn as stripRuntimeTurnContext, va as createPluginEmbedder, x as hydrateConversationMessages, ya as createPluginModel } from "./projection-7EFIqzuj.js";
|
|
3
3
|
import { h as parseSlackMessageTs } from "./actor-B4DYygOB.js";
|
|
4
|
-
import { S as getDb, i as readActorIdentity, x as getConversationStore } from "./viewer-
|
|
4
|
+
import { S as getDb, i as readActorIdentity, x as getConversationStore } from "./viewer-WY0RYE4E.js";
|
|
5
5
|
import { _ as sameActorIdentity } from "./media-DstkkoNP.js";
|
|
6
|
-
import { r as getStateAdapter } from "./adapter-
|
|
7
|
-
import { t as resolveConversationRouting, u as getDispatchRecord } from "./turn-session-routing-
|
|
8
|
-
import { o as coerceThreadConversationState, r as getPersistedThreadState } from "./thread-state-
|
|
9
|
-
import { i as pluginTaskParamsSchema, r as pluginTaskId, s as sendVercelPluginTask } from "./task-queue-
|
|
6
|
+
import { r as getStateAdapter } from "./adapter-BtfBHVM5.js";
|
|
7
|
+
import { t as resolveConversationRouting, u as getDispatchRecord } from "./turn-session-routing-jnLOfBHJ.js";
|
|
8
|
+
import { o as coerceThreadConversationState, r as getPersistedThreadState } from "./thread-state-4hjEIkIq.js";
|
|
9
|
+
import { i as pluginTaskParamsSchema, r as pluginTaskId, s as sendVercelPluginTask } from "./task-queue-CcvFQE_p.js";
|
|
10
10
|
import { pluginRunContextSchema } from "@sentry/junior-plugin-api";
|
|
11
11
|
// src/chat/plugins/task-runner.ts
|
|
12
12
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { S as persistConversationMessages,
|
|
2
|
-
import {
|
|
3
|
-
import { S as getDb } from "./viewer-
|
|
4
|
-
import { r as getStateAdapter } from "./adapter-
|
|
1
|
+
import { S as persistConversationMessages, Vr as JUNIOR_THREAD_STATE_TTL_MS, lo as createDurableLocationConfigurationService } from "./projection-7EFIqzuj.js";
|
|
2
|
+
import { G as toOptionalNumber, K as toOptionalString, W as isRecord } from "./logging-cI3T1dNc.js";
|
|
3
|
+
import { S as getDb } from "./viewer-WY0RYE4E.js";
|
|
4
|
+
import { r as getStateAdapter } from "./adapter-BtfBHVM5.js";
|
|
5
5
|
// src/chat/state/conversation.ts
|
|
6
6
|
function defaultConversationState() {
|
|
7
7
|
return {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { F as markConversationMessage,
|
|
2
|
-
import { _ as findProviderError, h as ProviderError, v as getProviderErrorAttributes, y as getProviderErrorUserMessage } from "./client-
|
|
3
|
-
import {
|
|
1
|
+
import { F as markConversationMessage, Y as clearPendingAuth, pn as buildDeterministicTurnId, ro as listConversationAnnotations, x as hydrateConversationMessages } from "./projection-7EFIqzuj.js";
|
|
2
|
+
import { _ as findProviderError, h as ProviderError, v as getProviderErrorAttributes, y as getProviderErrorUserMessage } from "./client-DZ8HTnYH.js";
|
|
3
|
+
import { W as isRecord, t as buildTurnFailureResponse } from "./logging-cI3T1dNc.js";
|
|
4
4
|
import { h as parseSlackMessageTs } from "./actor-B4DYygOB.js";
|
|
5
|
-
import { S as getDb, y as getConversationEventStore } from "./viewer-
|
|
6
|
-
import { B as
|
|
7
|
-
import {
|
|
8
|
-
import { a as persistThreadStateById, o as coerceThreadConversationState, r as getPersistedThreadState } from "./thread-state-
|
|
5
|
+
import { S as getDb, y as getConversationEventStore } from "./viewer-WY0RYE4E.js";
|
|
6
|
+
import { B as removedCardSchema, V as resolveMessageCards, z as readMessageCardRefs } from "./conversation-SsASlWL7.js";
|
|
7
|
+
import { O as parseAgentInvocationResultMessageId, Q as markTurnCompleted, Z as markTurnClosed, c as getAgentInvocation, m as getAgentInvocationTurnId } from "./store-DtHZviJ1.js";
|
|
8
|
+
import { a as persistThreadStateById, o as coerceThreadConversationState, r as getPersistedThreadState } from "./thread-state-4hjEIkIq.js";
|
|
9
9
|
// src/chat/conversations/pending-cards.ts
|
|
10
10
|
/**
|
|
11
11
|
* Add the cards that tool results selected since the last visible assistant
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { y as getConversationEventStore } from "./viewer-
|
|
1
|
+
import { y as getConversationEventStore } from "./viewer-WY0RYE4E.js";
|
|
2
2
|
// src/chat/conversations/turn-lifecycle.ts
|
|
3
3
|
/** Persist correlated turn lifecycle facts with retry-safe terminal exclusion. */
|
|
4
4
|
var ConversationTurnLifecycleService = class {
|
|
@@ -19,6 +19,11 @@ var ConversationTurnLifecycleService = class {
|
|
|
19
19
|
}
|
|
20
20
|
}]);
|
|
21
21
|
}
|
|
22
|
+
/** Return the input message ids that started a Turn, when it started. */
|
|
23
|
+
async loadInputMessageIds(conversationId, turnId) {
|
|
24
|
+
const event = await this.events.loadByIdempotencyKey(conversationId, `turn:${turnId}:started`);
|
|
25
|
+
return event?.data.type === "turn_started" ? event.data.inputMessageIds : void 0;
|
|
26
|
+
}
|
|
22
27
|
/** Record a completion that is not a failure once. */
|
|
23
28
|
async complete(input) {
|
|
24
29
|
await this.events.append(input.conversationId, [{
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { D as fallbackShortTitle,
|
|
2
|
-
import { n as botConfig } from "./config-
|
|
3
|
-
import { _ as runBestEffort, h as logWarn } from "./logging-
|
|
4
|
-
import {
|
|
5
|
-
import { s as juniorConversations } from "./agent-invocations-
|
|
6
|
-
import { d as juniorAutomations, l as juniorAutomationRuns, u as juniorAutomationVersions } from "./executor-
|
|
7
|
-
import { h as credentialSubjectSchema } from "./registry-
|
|
8
|
-
import { r as getStateAdapter } from "./adapter-
|
|
9
|
-
import { O as eventAutomationSchema, S as automationVersionSchema, j as scheduledAutomationSchema } from "./automation-
|
|
1
|
+
import { D as fallbackShortTitle, Gr as getDashboardTaskLink, Mi as postSlackMessage, Vr as JUNIOR_THREAD_STATE_TTL_MS, bi as escapeSlackMrkdwnText, ki as openSlackDirectMessage, qr as ToolInputError, xi as formatSlackLink } from "./projection-7EFIqzuj.js";
|
|
2
|
+
import { n as botConfig } from "./config-D5uUtrCP.js";
|
|
3
|
+
import { _ as runBestEffort, h as logWarn } from "./logging-cI3T1dNc.js";
|
|
4
|
+
import { J as agentTurnCostUsd, S as getDb, Y as agentTurnTotalTokens } from "./viewer-WY0RYE4E.js";
|
|
5
|
+
import { s as juniorConversations } from "./agent-invocations-Crs3XHhg.js";
|
|
6
|
+
import { d as juniorAutomations, l as juniorAutomationRuns, u as juniorAutomationVersions } from "./executor-hPfFTH0C.js";
|
|
7
|
+
import { h as credentialSubjectSchema } from "./registry-Bzefs7kT.js";
|
|
8
|
+
import { r as getStateAdapter } from "./adapter-BtfBHVM5.js";
|
|
9
|
+
import { O as eventAutomationSchema, S as automationVersionSchema, j as scheduledAutomationSchema } from "./automation-Cql9h2vO.js";
|
|
10
10
|
import { createHash } from "node:crypto";
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
import { and, asc, count, desc, eq, gte, inArray, isNotNull, isNull, lte, max, ne, or, sql } from "drizzle-orm";
|
|
13
|
-
import { anyResourceMatchFields, describeEventTrigger, destinationSchema, destinationVisibilitySchema,
|
|
13
|
+
import { agentEventMatchSchema, anyResourceMatchFields, describeEventTrigger, destinationSchema, destinationVisibilitySchema, eventMatches, eventTriggerChoices, eventTriggerProblems, isSlackDestination, normalizeEventIdentifier, normalizeEventMatch, replyAttributionSchema, sourceSchema, taskOutcomeSchema } from "@sentry/junior-plugin-api";
|
|
14
14
|
// src/chat/events/catalog.ts
|
|
15
15
|
/** A source with nothing enabled, for a namespace that the catalog lacks. */
|
|
16
16
|
const NO_SOURCE = {
|
|
@@ -86,7 +86,7 @@ function eventGuidance(catalog, namespace, eventType) {
|
|
|
86
86
|
}
|
|
87
87
|
/** Build the match object the tools accept for one resource type. */
|
|
88
88
|
function registeredEventMatchSchema() {
|
|
89
|
-
return
|
|
89
|
+
return agentEventMatchSchema.optional().describe("Optional filters: exact values for the resource type match_fields, with snake_case keys. A single value must equal the event data. A list means the event value may be any one entry. For a field with list: true, the event value is a list, and it matches when it includes the value or any entry. A field with events is set only on those events, so every selected event must be in that list. Omit a key to ignore it. Unmatched events are dropped with no agent turn.");
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
92
|
* List why a selection cannot work with the enabled plugins. Use it for new
|
|
@@ -111,15 +111,16 @@ function uniqueMatchValues(match) {
|
|
|
111
111
|
* Reject an event automation trigger or a Watch that cannot work, with every
|
|
112
112
|
* problem in one message for the agent. Return its match as it is saved:
|
|
113
113
|
* each text value in the case that its plugin declares, with no repeated
|
|
114
|
-
* list values.
|
|
114
|
+
* list values. The dashboard clears `inputKeys` so messages name the filters
|
|
115
|
+
* as its plugin declares them.
|
|
115
116
|
*/
|
|
116
|
-
function requireValidEventTrigger(catalog, selection, target) {
|
|
117
|
+
function requireValidEventTrigger(catalog, selection, target, options = { inputKeys: true }) {
|
|
117
118
|
const fields = eventTriggerChoices(catalog[selection.namespace] ?? NO_SOURCE, selection)?.fields ?? {};
|
|
118
119
|
const normalized = {
|
|
119
120
|
...selection,
|
|
120
121
|
match: normalizeEventMatch(fields, selection.match)
|
|
121
122
|
};
|
|
122
|
-
const problems = registeredEventTriggerProblems(catalog, normalized,
|
|
123
|
+
const problems = registeredEventTriggerProblems(catalog, normalized, options);
|
|
123
124
|
if (problems.length > 0) {
|
|
124
125
|
const source = catalog[selection.namespace]?.displayName ?? selection.namespace;
|
|
125
126
|
const resource = selection.resourceType ? `${source} ${selection.resourceType.replaceAll("_", " ")}` : source;
|
|
@@ -141,7 +142,7 @@ function requireEventIdentifier(catalog, input) {
|
|
|
141
142
|
const resourceType = resourceTypes.find((candidate) => candidate.type === input.resourceType);
|
|
142
143
|
if (!resourceType?.identifier || fits(resourceType)) return identifier;
|
|
143
144
|
const fitting = resourceTypes.filter(fits).map((candidate) => candidate.type);
|
|
144
|
-
throw new ToolInputError([`Identifier "${identifier}" does not fit
|
|
145
|
+
throw new ToolInputError([`Identifier "${identifier}" does not fit resource_type "${input.resourceType}" in namespace "${input.namespace}". Expected format: "${resourceType.identifier.format}".`, ...fitting.length > 0 ? [`If the identifier is correct, use one of these resource_type values: ${fitting.map((type) => `"${type}"`).join(", ")}.`] : []].join(" "));
|
|
145
146
|
}
|
|
146
147
|
// src/chat/automations/revision.ts
|
|
147
148
|
/** Storage revisions prevent stale edits from replacing newer values. */
|
|
@@ -1583,7 +1584,7 @@ function slackSourceForDestination(args) {
|
|
|
1583
1584
|
* Reads parent Conversations when this Conversation has no Destination.
|
|
1584
1585
|
*/
|
|
1585
1586
|
async function resolveConversationRouting(args) {
|
|
1586
|
-
const conversationStore = args.conversationStore ?? (await import("./viewer-
|
|
1587
|
+
const conversationStore = args.conversationStore ?? (await import("./viewer-WY0RYE4E.js").then((n) => n.v)).getConversationStore();
|
|
1587
1588
|
const chain = await loadConversationChain(args.conversationId, conversationStore);
|
|
1588
1589
|
let destination;
|
|
1589
1590
|
let source;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
|
|
2
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime-
|
|
2
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-DE-F4Awo.js";
|
|
3
3
|
import { isDeepStrictEqual } from "node:util";
|
|
4
4
|
// src/chat/plugins/validation.ts
|
|
5
5
|
var validation_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// package.json
|
|
2
|
-
var version = "0.
|
|
2
|
+
var version = "0.277.0";
|
|
3
3
|
// src/version.ts
|
|
4
4
|
/** Installed Junior package version, or `unknown` when package metadata is unavailable. */
|
|
5
5
|
const JUNIOR_VERSION = typeof version === "string" && version.trim() ? version : "unknown";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as JUNIOR_VERSION } from "./version-
|
|
1
|
+
export { t as JUNIOR_VERSION } from "./version-DJTk0ZCE.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
|
|
2
|
-
import { i as getChatConfig } from "./config-
|
|
3
|
-
import {
|
|
2
|
+
import { i as getChatConfig } from "./config-D5uUtrCP.js";
|
|
3
|
+
import { U as normalizeIdentityEmail, V as GOOGLE_IDENTITY_PROVIDER, h as logWarn } from "./logging-cI3T1dNc.js";
|
|
4
4
|
import { a as isSlackUserId, d as parseSlackChannelReferenceId, f as parseSlackTeamId, s as parseActorUserId } from "./actor-B4DYygOB.js";
|
|
5
|
-
import { c as juniorIdentities, d as juniorDestinations, l as juniorUsers, o as conversationReadColumns, s as juniorConversations } from "./agent-invocations-
|
|
6
|
-
import { S as juniorConversationAnnotations, b as juniorConversationEvents, g as juniorConversationBindings, h as juniorConversationParticipants, t as createJuniorSqlExecutor, v as CONVERSATION_METRICS, y as juniorConversationMetrics } from "./executor-
|
|
5
|
+
import { c as juniorIdentities, d as juniorDestinations, l as juniorUsers, o as conversationReadColumns, s as juniorConversations } from "./agent-invocations-Crs3XHhg.js";
|
|
6
|
+
import { S as juniorConversationAnnotations, b as juniorConversationEvents, g as juniorConversationBindings, h as juniorConversationParticipants, t as createJuniorSqlExecutor, v as CONVERSATION_METRICS, y as juniorConversationMetrics } from "./executor-hPfFTH0C.js";
|
|
7
7
|
import { d as newConversationEventSchema, f as encodeHistoryPayload, l as decodeStoredConversationEvent, n as detectImageMediaType, o as conversationEventDataSchema, u as historyReplacementSchema, v as usageSchema } from "./media-DstkkoNP.js";
|
|
8
8
|
import { a as withLock } from "./locks-D-0h111u.js";
|
|
9
9
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -167,6 +167,32 @@ function addAgentTurnUsage(...usages) {
|
|
|
167
167
|
};
|
|
168
168
|
return hasAgentTurnUsage(result) ? result : void 0;
|
|
169
169
|
}
|
|
170
|
+
// src/chat/conversations/sql/detail-version.ts
|
|
171
|
+
/** SQL that advances `detail_version` inside a `juniorConversations` set. */
|
|
172
|
+
const nextDetailVersion = sql`${juniorConversations.detailVersion} + 1`;
|
|
173
|
+
function bumpDetailVersion(db, conversationIds) {
|
|
174
|
+
return db.update(juniorConversations).set({ detailVersion: nextDetailVersion }).where(inArray(juniorConversations.conversationId, [...conversationIds]));
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Return a CTE that marks the detail report of each Conversation as changed,
|
|
178
|
+
* in the same statement as the write that it covers:
|
|
179
|
+
* `db.with(conversationDetailTouch(db, ids)).insert(table)`.
|
|
180
|
+
* Postgres runs a data-modifying CTE even when the statement does not read it,
|
|
181
|
+
* and both changes commit together.
|
|
182
|
+
*/
|
|
183
|
+
function conversationDetailTouch(db, conversationIds) {
|
|
184
|
+
return db.$with("conversation_detail_touch").as(bumpDetailVersion(db, conversationIds).returning({ conversationId: juniorConversations.conversationId }));
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Mark the detail report of each Conversation as changed, for a write that
|
|
188
|
+
* cannot carry `conversationDetailTouch`. Call it after that write, in the same
|
|
189
|
+
* transaction when there is one. A bump before the write lets a detail read
|
|
190
|
+
* store old content under the new version.
|
|
191
|
+
*/
|
|
192
|
+
async function touchConversationDetail(db, conversationIds) {
|
|
193
|
+
if (conversationIds.length === 0) return;
|
|
194
|
+
await bumpDetailVersion(db, conversationIds);
|
|
195
|
+
}
|
|
170
196
|
// src/chat/conversations/metrics.ts
|
|
171
197
|
function finite(value) {
|
|
172
198
|
return value !== void 0 && Number.isFinite(value) && value >= 0 ? value : void 0;
|
|
@@ -279,7 +305,8 @@ async function replaceConversationMetrics(executor, args) {
|
|
|
279
305
|
'reasoningTokens', ${metric("reasoning_tokens")},
|
|
280
306
|
'cost', ${cost}
|
|
281
307
|
))
|
|
282
|
-
end
|
|
308
|
+
end`,
|
|
309
|
+
detailVersion: nextDetailVersion
|
|
283
310
|
}).where(eq(juniorConversations.conversationId, args.conversationId));
|
|
284
311
|
}
|
|
285
312
|
// src/chat/source.ts
|
|
@@ -711,7 +738,10 @@ function visibilityFromLocationRow(row) {
|
|
|
711
738
|
/** Store a channel-level Location's first bound post as its thread. */
|
|
712
739
|
async function startLocationThread(executor, binding) {
|
|
713
740
|
const location = juniorConversations.location;
|
|
714
|
-
await executor.db().update(juniorConversations).set({
|
|
741
|
+
await executor.db().update(juniorConversations).set({
|
|
742
|
+
location: sql`${location} || jsonb_build_object('threadTs', ${binding.providerConversationId}::text)`,
|
|
743
|
+
detailVersion: nextDetailVersion
|
|
744
|
+
}).where(and(eq(juniorConversations.conversationId, binding.conversationId), sql`${location}->>'provider' = ${binding.provider}`, sql`${location}->>'teamId' = ${binding.providerTenantId}`, sql`${location}->>'channelId' = ${binding.providerDestinationId}`, isNull(sql`${location}->>'threadTs'`)));
|
|
715
745
|
}
|
|
716
746
|
// src/chat/conversations/sql/store.ts
|
|
717
747
|
const CONVERSATION_MUTATION_LOCK_PREFIX = "junior_conversation";
|
|
@@ -974,7 +1004,8 @@ var SqlStore = class {
|
|
|
974
1004
|
if (incomingIsFresh) await this.executor.db().update(juniorConversations).set({
|
|
975
1005
|
metricRunId: args.execution.runId,
|
|
976
1006
|
executionDurationMs: args.metrics.durationMs,
|
|
977
|
-
executionUsage: args.metrics.usage ?? null
|
|
1007
|
+
executionUsage: args.metrics.usage ?? null,
|
|
1008
|
+
detailVersion: nextDetailVersion
|
|
978
1009
|
}).where(eq(juniorConversations.conversationId, args.conversationId));
|
|
979
1010
|
}
|
|
980
1011
|
});
|
|
@@ -1096,7 +1127,8 @@ var SqlStore = class {
|
|
|
1096
1127
|
runId: sql`case when ${incomingExecutionIsFresh} then excluded.run_id else ${juniorConversations.runId} end`,
|
|
1097
1128
|
lastCheckpointAt: sql`case when ${incomingExecutionIsFresh} then coalesce(excluded.last_checkpoint_at, ${juniorConversations.lastCheckpointAt}) else ${juniorConversations.lastCheckpointAt} end`,
|
|
1098
1129
|
lastEnqueuedAt: sql`case when ${incomingExecutionIsFresh} then coalesce(excluded.last_enqueued_at, ${juniorConversations.lastEnqueuedAt}) else ${juniorConversations.lastEnqueuedAt} end`,
|
|
1099
|
-
rootConversationId: sql`coalesce(${juniorConversations.rootConversationId}, excluded.root_conversation_id)
|
|
1130
|
+
rootConversationId: sql`coalesce(${juniorConversations.rootConversationId}, excluded.root_conversation_id)`,
|
|
1131
|
+
detailVersion: nextDetailVersion
|
|
1100
1132
|
}
|
|
1101
1133
|
}).returning({
|
|
1102
1134
|
actorIdentityId: juniorConversations.actorIdentityId,
|
|
@@ -1177,7 +1209,8 @@ async function ensureConversationRow(executor, conversationId, atMs, options = {
|
|
|
1177
1209
|
set: {
|
|
1178
1210
|
lastActivityAt: sql`greatest(${juniorConversations.lastActivityAt}, excluded.last_activity_at)`,
|
|
1179
1211
|
updatedAt: sql`greatest(${juniorConversations.updatedAt}, excluded.updated_at)`,
|
|
1180
|
-
transcriptPurgedAt: null
|
|
1212
|
+
transcriptPurgedAt: null,
|
|
1213
|
+
detailVersion: nextDetailVersion
|
|
1181
1214
|
}
|
|
1182
1215
|
});
|
|
1183
1216
|
}
|
|
@@ -1225,9 +1258,12 @@ async function findJuniorIdentityIdByEmail(executor, email) {
|
|
|
1225
1258
|
return (await executor.db().select({ id: juniorIdentities.id }).from(juniorIdentities).where(and(eq(juniorIdentities.provider, "junior"), eq(juniorIdentities.kind, "user"), or(eq(juniorIdentities.providerSubjectId, normalized), and(eq(juniorIdentities.emailNormalized, normalized), eq(juniorIdentities.emailVerified, true))))).limit(1))[0]?.id;
|
|
1226
1259
|
}
|
|
1227
1260
|
/**
|
|
1228
|
-
* Resolve a dashboard:<hash> author against junior identities keyed by
|
|
1229
|
-
* Web
|
|
1230
|
-
*
|
|
1261
|
+
* Resolve a legacy dashboard:<hash> author against junior identities keyed by
|
|
1262
|
+
* email. Web Actors stored dashboard:${sha256(email).slice(0,24)} before they
|
|
1263
|
+
* used the User id. This read-only fallback serves only those old events.
|
|
1264
|
+
*
|
|
1265
|
+
* TODO(dcramer): Delete with the guess in resolveEventActorIdentityId, after
|
|
1266
|
+
* every stored user Message event has its author Identity.
|
|
1231
1267
|
*/
|
|
1232
1268
|
async function findJuniorIdentityIdByDashboardAuthorId(executor, dashboardAuthorId) {
|
|
1233
1269
|
if (!dashboardAuthorId.startsWith("dashboard:")) return;
|
|
@@ -1410,7 +1446,8 @@ var SqlConversationEventStore = class {
|
|
|
1410
1446
|
});
|
|
1411
1447
|
rows.push(insertFromEvent(conversationId, seq++, historyVersion, event, actorIdentityId));
|
|
1412
1448
|
}
|
|
1413
|
-
|
|
1449
|
+
const db = this.executor.db();
|
|
1450
|
+
await db.with(conversationDetailTouch(db, [conversationId])).insert(juniorConversationEvents).values(rows);
|
|
1414
1451
|
for (const event of pending) if (event.data.type === "turn_started") await this.recordTurnInputParticipants(conversationId, event.data.inputMessageIds);
|
|
1415
1452
|
return rows.map((row) => ({
|
|
1416
1453
|
seq: row.seq,
|
|
@@ -1447,7 +1484,8 @@ var SqlConversationEventStore = class {
|
|
|
1447
1484
|
};
|
|
1448
1485
|
await ensureConversationRow(this.executor, conversationId, Date.now());
|
|
1449
1486
|
const historyVersion = currentHistoryVersion + 1;
|
|
1450
|
-
|
|
1487
|
+
const db = this.executor.db();
|
|
1488
|
+
await db.with(conversationDetailTouch(db, [conversationId])).insert(juniorConversationEvents).values(insertFromEvent(conversationId, cursor.nextSeq, historyVersion, parsed));
|
|
1451
1489
|
return {
|
|
1452
1490
|
status: "replaced",
|
|
1453
1491
|
historyVersion
|
|
@@ -1987,4 +2025,4 @@ async function readIdentityByIdFromSql(db, identityId) {
|
|
|
1987
2025
|
async function readIdentityById(identityId) {
|
|
1988
2026
|
return await readIdentityByIdFromSql(getDb(), identityId);
|
|
1989
2027
|
}
|
|
1990
|
-
export {
|
|
2028
|
+
export { createSlackDestination as $, locationFromRow as A, saveUserTimezone as B, getSqlExecutor as C, loadConversationSlackTenantIds as D, withConversationEventLock as E, deleteProviderIdentityForSlackUser as F, nextDetailVersion as G, bindProviderConversation as H, deleteProviderIdentityForUser as I, agentTurnCostUsd as J, touchConversationDetail as K, findUserByVerifiedEmails as L, SYSTEM_IDENTITY_ID as M, resolveActorIdentityId as N, createSqlStore as O, saveActorAvatar as P, resolveRootConversationId as Q, readUserTimezone as R, getDb as S, eventFromRow as T, parseSessionSource as U, upsertLinkedIdentity as V, conversationDetailTouch as W, agentTurnUsageSchema as X, agentTurnTotalTokens as Y, hasAgentTurnUsage as Z, closeDb as _, readActorIdentityFromSql as a, getConversationMessageSearchStore as b, readViewerAvatarUrl as c, updateViewerDisplayName as d, parseDestination as et, identityAvatarUrl as f, createCache as g, readUserAvatarUrls as h, readActorIdentity as i, startLocationThread as j, withConversationMutationLock as k, resolveViewerUser as l, readAvatarImage as m, findUserByEmailFromSql as n, sameDestination as nt, readIdentityById as o, parseAvatarUrl as p, addAgentTurnUsage as q, listAdminUsersFromSql as r, readIdentityByIdFromSql as s, findUserByEmail as t, requireSlackDestination as tt, setUserAdminFromSql as u, db_exports as v, createSqlConversationEventStore as w, getConversationStore as x, getConversationEventStore as y, recordGoogleSignIn as z };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { G as AuthorizationFlowDisabledError,
|
|
2
|
-
import { n as botConfig } from "./config-
|
|
3
|
-
import { M as SYSTEM_IDENTITY_ID, x as getConversationStore, y as getConversationEventStore } from "./viewer-
|
|
1
|
+
import { G as AuthorizationFlowDisabledError, Ja as loadForkHistory, V as PluginCredentialFailureError, Wt as isTurnExecutionLimitExceededError, Yt as getTerminalAssistantMessages, et as saveTurnCheckpoint, it as getTurnRecord, l as openConversationProjection, rt as failTurnRecord, tt as abandonTurnRecord } from "./projection-7EFIqzuj.js";
|
|
2
|
+
import { n as botConfig } from "./config-D5uUtrCP.js";
|
|
3
|
+
import { M as SYSTEM_IDENTITY_ID, x as getConversationStore, y as getConversationEventStore } from "./viewer-WY0RYE4E.js";
|
|
4
4
|
import { _ as sameActorIdentity, p as agentInstructionProvenance } from "./media-DstkkoNP.js";
|
|
5
|
-
import {
|
|
6
|
-
import { B as
|
|
7
|
-
import { n as getAssistantReplyText } from "./assistant-reply-
|
|
8
|
-
import {
|
|
9
|
-
import { r as appendAndEnqueueInboundMessage } from "./store-
|
|
10
|
-
import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-
|
|
11
|
-
import { a as persistThreadStateById, n as getPersistedSandboxState, r as getPersistedThreadState } from "./thread-state-
|
|
5
|
+
import { At as withoutSavedSteeringMessages, It as readBlockedReport, St as recordSubagentStarted, kt as buildSteeringPiMessage, xt as recordSubagentEnded, yt as stopChildAgentsOf } from "./agent-runner-BsYAbniN.js";
|
|
6
|
+
import { B as agentTypeInstructions, C as markAgentInvocationMailboxAppended, D as markAgentInvocationSteered, E as markAgentInvocationRunning, G as TurnInputCommitLostError, T as markAgentInvocationPaused, V as agentTypeStartsWithParentHistory, Y as isTurnInputCommitLostError, _ as getLatestAgentInvocationForConversation, b as listAgentInvocationsForConversation, c as getAgentInvocation, f as getAgentInvocationMessageId, i as createAgentInvocation, k as reportReplacedAgentInvocation, m as getAgentInvocationTurnId, n as NON_TERMINAL_AGENT_INVOCATION_STATUSES, q as getConversationTurnBoundaryError, r as completeAgentInvocation, s as getActiveAgentInvocationForConversation, t as ACTIVE_AGENT_INVOCATION_STATUSES, y as isTerminalAgentInvocation } from "./store-DtHZviJ1.js";
|
|
7
|
+
import { n as getAssistantReplyText } from "./assistant-reply-NebRGG4G.js";
|
|
8
|
+
import { E as maybePostAutomatedTurnLimitNotice, M as recordFinishedTurnForAutomatedLimit, N as resetAutomatedTurnLimit } from "./session-stop-0juF_BP0.js";
|
|
9
|
+
import { r as appendAndEnqueueInboundMessage } from "./store-DKs1WwdB.js";
|
|
10
|
+
import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-BhqYjaa4.js";
|
|
11
|
+
import { a as persistThreadStateById, n as getPersistedSandboxState, r as getPersistedThreadState } from "./thread-state-4hjEIkIq.js";
|
|
12
12
|
import { isDeepStrictEqual } from "node:util";
|
|
13
13
|
import { z } from "zod";
|
|
14
14
|
// src/chat/runtime/turn-execution.ts
|
|
@@ -281,6 +281,24 @@ async function endOtherActiveAgentInvocation(invocation) {
|
|
|
281
281
|
status: "failed"
|
|
282
282
|
});
|
|
283
283
|
}
|
|
284
|
+
/**
|
|
285
|
+
* End every agent invocation of a child whose last attempt lost its worker and
|
|
286
|
+
* whose input reached the child's mailbox. The worker ran no failure path, and
|
|
287
|
+
* the stop drops the mailbox, so none of them can run. The heartbeat sends
|
|
288
|
+
* each result.
|
|
289
|
+
*/
|
|
290
|
+
async function endAgentInvocationsOfStoppedWork(conversationId, inboundMessageIds) {
|
|
291
|
+
for (const invocation of await listAgentInvocationsForConversation(conversationId, NON_TERMINAL_AGENT_INVOCATION_STATUSES)) {
|
|
292
|
+
if (!inboundMessageIds.includes(getAgentInvocationMessageId(invocation.invocationId))) continue;
|
|
293
|
+
const terminal = await projectTerminalTurn(invocation, { reportNow: true }) ?? await completeAgentInvocation({
|
|
294
|
+
invocationId: invocation.invocationId,
|
|
295
|
+
errorMessage: "This task stopped because its worker failed repeatedly.",
|
|
296
|
+
reportNow: true,
|
|
297
|
+
status: "failed"
|
|
298
|
+
});
|
|
299
|
+
if (terminal && isTerminalAgentInvocation(terminal)) await persistTerminalLifecycle(terminal);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
284
302
|
/** Classify authorization failures that terminally block background work. */
|
|
285
303
|
function blockingInvocationError(error) {
|
|
286
304
|
const cause = getConversationTurnBoundaryError(error)?.cause ?? error;
|
|
@@ -415,7 +433,7 @@ function createAgentInvocationWorker(agentRunner, options = {}) {
|
|
|
415
433
|
await acknowledge();
|
|
416
434
|
return { status: "completed" };
|
|
417
435
|
}
|
|
418
|
-
for (const active of await
|
|
436
|
+
for (const active of await listAgentInvocationsForConversation(invocation.childConversationId, ACTIVE_AGENT_INVOCATION_STATUSES)) if (active.invocationId !== invocation.invocationId) await finish(await endOtherActiveAgentInvocation(active));
|
|
419
437
|
invocation = await markAgentInvocationRunning(invocation.invocationId) ?? invocation;
|
|
420
438
|
if (isTerminalAgentInvocation(invocation)) {
|
|
421
439
|
await finish(invocation);
|
|
@@ -529,4 +547,4 @@ function createAgentInvocationWorker(agentRunner, options = {}) {
|
|
|
529
547
|
return { status: "completed" };
|
|
530
548
|
};
|
|
531
549
|
}
|
|
532
|
-
export {
|
|
550
|
+
export { resolveAgentInvocationId as a, enqueueAgentInvocation as i, createAndEnqueueAgentInvocation as n, AgentRunError as o, endAgentInvocationsOfStoppedWork as r, executeTurn as s, createAgentInvocationWorker as t };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
|
|
2
|
-
import { Ct as hasConversationStop, Et as isInvalidConversationRecordError, Tt as isFinalAttempt } from "./projection-
|
|
3
|
-
import { b as isProviderRetryError } from "./client-
|
|
4
|
-
import { i as getChatConfig } from "./config-
|
|
5
|
-
import { T as withLogContext, b as setSpanAttributes, h as logWarn, m as logInfo, p as logException } from "./logging-
|
|
6
|
-
import { g as getTurnRequestDeadline, v as ConversationQueueMessageRejectedError } from "./background-compaction-queue-
|
|
7
|
-
import { C as requestAnotherSlice, T as startConversationWork, b as recordConversationRetry, d as countPendingConversationMessages, f as deadLetterAttempt, g as getConversationWorkState, i as beginConversationResume, 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-
|
|
2
|
+
import { Ct as hasConversationStop, Et as isInvalidConversationRecordError, Tt as isFinalAttempt } from "./projection-7EFIqzuj.js";
|
|
3
|
+
import { b as isProviderRetryError } from "./client-DZ8HTnYH.js";
|
|
4
|
+
import { i as getChatConfig } from "./config-D5uUtrCP.js";
|
|
5
|
+
import { T as withLogContext, b as setSpanAttributes, h as logWarn, m as logInfo, p as logException } from "./logging-cI3T1dNc.js";
|
|
6
|
+
import { g as getTurnRequestDeadline, v as ConversationQueueMessageRejectedError } from "./background-compaction-queue-hh18yCeU.js";
|
|
7
|
+
import { C as requestAnotherSlice, T as startConversationWork, b as recordConversationRetry, d as countPendingConversationMessages, f as deadLetterAttempt, g as getConversationWorkState, i as beginConversationResume, 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-DKs1WwdB.js";
|
|
8
8
|
// src/chat/task-execution/attempt-selection.ts
|
|
9
9
|
function selectContiguousTurnBatch(messages) {
|
|
10
10
|
const first = messages[0];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE "junior_conversations" ADD COLUMN "quick_question_at" timestamp with time zone;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE "junior_conversation_participants" ADD COLUMN "pinned_at" timestamp with time zone;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE "junior_conversations" ADD COLUMN "detail_version" integer DEFAULT 0 NOT NULL;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
ALTER TABLE "junior_conversation_participants" ADD COLUMN "auto_archive" boolean;--> statement-breakpoint
|
|
2
|
+
ALTER TABLE "junior_users" ADD COLUMN "auto_archive_default" boolean DEFAULT false NOT NULL;--> statement-breakpoint
|
|
3
|
+
ALTER TABLE "junior_users" ADD COLUMN "auto_archive_grace_hours" integer DEFAULT 24 NOT NULL;--> statement-breakpoint
|
|
4
|
+
CREATE INDEX "junior_conversation_participants_auto_archive_idx" ON "junior_conversation_participants" USING btree ("user_id") WHERE "junior_conversation_participants"."auto_archive" and "junior_conversation_participants"."archived_at" is null;--> statement-breakpoint
|
|
5
|
+
CREATE INDEX "junior_conversation_participants_unarchived_activity_idx" ON "junior_conversation_participants" USING btree ("user_id","last_message_at","root_conversation_id") WHERE "junior_conversation_participants"."archived_at" is null;
|