@sentry/junior 0.299.0 → 0.301.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-AgCNqqsG.js → adapter-CNjGEJO9.js} +5 -4
- package/dist/{admin-1VwEXztm.js → admin-CRJHvCGg.js} +2 -2
- package/dist/{agent-runner-Ciet8_nn.js → agent-runner-H4YhvNBj.js} +514 -270
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +6 -7
- package/dist/api.d.ts +1 -1
- package/dist/api.js +327 -61
- package/dist/{app--ky-Eu33.d.ts → app-HDZglaIu.d.ts} +14 -3
- package/dist/app.d.ts +1 -1
- package/dist/app.js +60 -220
- package/dist/{automation-M3RFJUBf.js → automation-Cva5ZOwW.js} +2 -2
- package/dist/{background-compaction-queue-CnimvRdk.js → background-compaction-queue-CNrZ3QcU.js} +8 -4
- package/dist/{briefs-CwzvgdCa.js → briefs-x6Mzwxmg.js} +3 -3
- package/dist/{catalog-runtime-DaBaHY7u.js → catalog-runtime-BEY6EGRi.js} +1 -1
- package/dist/cli/chat.js +16 -16
- package/dist/cli/check.js +3 -3
- package/dist/cli/main.js +3 -3
- package/dist/cli/plugins.js +5 -5
- package/dist/cli/snapshot-create.js +4 -4
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +4 -4
- package/dist/{config-CAXIpWQb.js → config-CmjhyqgB.js} +39 -8
- package/dist/{connections-Dy0hPdUq.js → connections-CfIRm0xv.js} +6 -6
- package/dist/{continue-in-slack-DIOjFj76.js → continue-in-slack-DPoABVkB.js} +6 -6
- package/dist/{conversation-fCWD9Az3.js → conversation-BNXfq6Lb.js} +30 -9
- package/dist/{conversation-feed-BPK8vkkZ.js → conversation-feed-CfpyFMHP.js} +23 -2
- package/dist/{conversation-privacy-DUgtRkf8.js → conversation-privacy-0CM0V2qK.js} +1 -1
- package/dist/{conversation-turn-DkJB6yMF.js → conversation-turn-C0sxyvS-.js} +17 -17
- package/dist/{credential-sync-RX24Y8aY.js → credential-sync-tEMKZ_8M.js} +15 -15
- package/dist/{db-B07FtU9g.d.ts → db-BdUHQhrC.d.ts} +1 -1
- package/dist/{db-COYOGzYS.js → db-Czra10QW.js} +13 -8
- package/dist/{executor-BWmAgSyi.js → executor-D_023K0H.js} +9 -4
- package/dist/instrumentation.js +14 -5
- package/dist/{lineage-D-5jm_oj.js → lineage-DmMIE0VL.js} +2 -2
- package/dist/{logging-DPLEa8Bn.js → logging-DcjLDDqi.js} +1 -1
- package/dist/{message-BIHR1yRk.js → message-C0JY9RJP.js} +8 -8
- package/dist/{model-input-BPZYH8Nd.js → model-input-CBp-p24N.js} +4 -4
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +4 -4
- package/dist/{oauth-callback-server-R7qvSzFG.js → oauth-callback-server-BRq9QNhU.js} +2 -2
- package/dist/{plugins-CBW2Prb_.js → plugins-BBX07Jzt.js} +1 -1
- package/dist/{projection-DEdP1q6f.js → projection-CQNDOi82.js} +911 -671
- package/dist/{prompt-4M98h_tC.js → prompt-DLUB5m72.js} +4 -4
- package/dist/{registry-BTKmKM-r.js → registry-Dj377ADs.js} +2 -2
- package/dist/{resolve-B8hXNVZ3.js → resolve-DJkh9Fky.js} +3 -3
- package/dist/{result-g-XAaOj6.js → result-C8iIpDl1.js} +9 -9
- package/dist/{runner-BlPSA5A8.js → runner-DZqrOy8C.js} +9 -9
- package/dist/{sandbox-egress-signals-Pai-MzEY.js → sandbox-egress-signals-CGwH86S9.js} +1 -1
- package/dist/{schema-DbuWR-DN.d.ts → schema-CdZFn7Qd.d.ts} +248 -6
- package/dist/{schema-BNnY_trV.js → schema-DyHXiQKI.js} +28 -16
- package/dist/{service-account-BYGZ08DQ.js → service-account-D6jGR4a1.js} +3 -3
- package/dist/{service-account-9OLNQMyz.js → service-account-suY004dx.js} +4 -4
- package/dist/{session-stop-2XJrcNCy.js → session-stop-BLmfFI3d.js} +121 -46
- package/dist/{skills-DpBQoeHV.js → skills-CmNG0dHb.js} +2 -2
- package/dist/{slack-conversation-unfurl-BcDIWo67.js → slack-conversation-unfurl-Bty-DlHe.js} +7 -7
- package/dist/{spawn-09GssFod.js → spawn-CNjkpXpk.js} +6 -6
- package/dist/{state-Cufq0_rH.js → state-CEbZuZD6.js} +2 -2
- package/dist/{statuses-B8mUfghF.js → statuses-Hn-HsOph.js} +86 -2
- package/dist/{stop-U7iUrR1g.js → stop-Bjy2-K4H.js} +967 -93
- package/dist/{store-BHiaHCQu.js → store-DmV4CoNr.js} +5 -5
- package/dist/{store-CSgUTMdv.js → store-Epv6t4vV.js} +9 -9
- package/dist/{task-queue-bMNq0clp.js → task-queue-AhG1tSXR.js} +3 -3
- package/dist/{task-runner-B__rxwxU.js → task-runner-BMxZI3o7.js} +8 -8
- package/dist/{thread-context-d0ceWbVT.js → thread-context-CXLnbg7g.js} +8 -8
- package/dist/{turn-session-routing-BVZHBFCF.js → turn-session-routing-BD3-jJl7.js} +5 -5
- package/dist/{turn-user-message-BEw7acTP.js → turn-user-message-DsUZi9gn.js} +3 -3
- package/dist/{users-BK3dbxZL.js → users-BxvYclQg.js} +3 -3
- package/dist/{validation-BDVJjO2E.js → validation-DOz8X9BU.js} +1 -1
- package/dist/{version-DQgZoQ3D.js → version-CGMRmMPK.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-CAWfFo29.js → viewer-H3EsMWtJ.js} +16 -114
- package/dist/{warmup-9ySPacF9.js → warmup-CdU5hR49.js} +51 -27
- package/dist/{worker-D8jJO-WO.js → worker-ClphajjD.js} +24 -20
- package/migrations/0107_attachment_deferred_download.sql +2 -0
- package/migrations/meta/0107_snapshot.json +4617 -0
- package/migrations/meta/_journal.json +7 -0
- package/package.json +10 -8
- package/dist/media-BAHvgkok.js +0 -85
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { At as getConversationWorkStates$1, Bt as recordConversationRetry$1, Dt as dropPendingMessages$1, Et as drainConversationMailbox$1, Ft as listActiveConversationIds$1, Gt as startConversationWork$1, Ht as releaseInboundMessage, It as markConversationWorkEnqueued$1, Jt as takeDeferredConversationMove, Kt as steerWebPendingMessages$1, Mt as hasRunnableConversationWork, Ot as getConversation$1, St as completeConversationWork$1, Ut as requestAnotherSlice$1, Vt as releaseConversationWork$1, Wt as requestConversationWork$1, _t as checkInConversationWork$1, bt as clearExpiredConversationLease$1, ft as ackMessages$1, gt as cancelHumanFacingPendingMessages$1, ht as beginConversationResume$1, kt as getConversationWorkState$1, mt as appendInboundMessage, pt as appendExclusiveInboundMessage, qt as stopConversationWork$1, vt as claimInboundMessage$1, wt as deadLetterAttempt$1, xt as completeConversationStop$1, yt as clearConsumedConversationWake$1, zt as recordAttemptFailure$1 } from "./projection-
|
|
2
|
-
import { p as logException } from "./logging-
|
|
3
|
-
import { a as getConversationStore } from "./db-
|
|
4
|
-
import "./background-compaction-queue-
|
|
1
|
+
import { At as getConversationWorkStates$1, Bt as recordConversationRetry$1, Dt as dropPendingMessages$1, Et as drainConversationMailbox$1, Ft as listActiveConversationIds$1, Gt as startConversationWork$1, Ht as releaseInboundMessage, It as markConversationWorkEnqueued$1, Jt as takeDeferredConversationMove, Kt as steerWebPendingMessages$1, Mt as hasRunnableConversationWork, Ot as getConversation$1, St as completeConversationWork$1, Ut as requestAnotherSlice$1, Vt as releaseConversationWork$1, Wt as requestConversationWork$1, _t as checkInConversationWork$1, bt as clearExpiredConversationLease$1, ft as ackMessages$1, gt as cancelHumanFacingPendingMessages$1, ht as beginConversationResume$1, kt as getConversationWorkState$1, mt as appendInboundMessage, pt as appendExclusiveInboundMessage, qt as stopConversationWork$1, vt as claimInboundMessage$1, wt as deadLetterAttempt$1, xt as completeConversationStop$1, yt as clearConsumedConversationWake$1, zt as recordAttemptFailure$1 } from "./projection-CQNDOi82.js";
|
|
2
|
+
import { p as logException } from "./logging-DcjLDDqi.js";
|
|
3
|
+
import { a as getConversationStore } from "./db-Czra10QW.js";
|
|
4
|
+
import "./background-compaction-queue-CNrZ3QcU.js";
|
|
5
5
|
// src/chat/task-execution/store.ts
|
|
6
6
|
function metadataStore(options) {
|
|
7
7
|
return options.conversationStore ?? getConversationStore();
|
|
@@ -304,7 +304,7 @@ async function runDeferredMove(args) {
|
|
|
304
304
|
const move = await takeDeferredConversationMove(args);
|
|
305
305
|
if (move === void 0) return;
|
|
306
306
|
try {
|
|
307
|
-
const { continueDeferredSlackClick } = await import("./slack-conversation-unfurl-
|
|
307
|
+
const { continueDeferredSlackClick } = await import("./slack-conversation-unfurl-Bty-DlHe.js").then((n) => n.r);
|
|
308
308
|
await continueDeferredSlackClick(move, args.getSlackAdapter);
|
|
309
309
|
} catch (error) {
|
|
310
310
|
logException(error, "slack.continue_here.deferred.failed", { "gen_ai.conversation.id": args.conversationId });
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as botConfig } from "./config-
|
|
3
|
-
import { _ as runBestEffort, h as logWarn } from "./logging-
|
|
4
|
-
import { X as agentTurnTotalTokens, Y as agentTurnCostUsd, o as getDb } from "./db-
|
|
5
|
-
import { d as juniorAutomationVersions, f as juniorAutomations, j as juniorConversations, u as juniorAutomationRuns } from "./executor-
|
|
6
|
-
import { r as getStateAdapter } from "./adapter-
|
|
7
|
-
import { h as credentialSubjectSchema } from "./registry-
|
|
8
|
-
import { u as automationEventCatalog, v as registeredEventTriggerProblems } from "./turn-session-routing-
|
|
9
|
-
import { B as automationTaskColumns, H as automationTaskSchema, M as scheduledAutomationSchema, S as automationVersionSchema, V as automationTaskDescription, k as eventAutomationSchema, z as automationSkillNameSchema } from "./automation-
|
|
1
|
+
import { Da as postSlackMessage, Fi as getDashboardTaskLink, Oi as JUNIOR_THREAD_STATE_TTL_MS, eo as ToolInputError, ma as formatSlackLink, pa as escapeSlackMrkdwnText, w as fallbackShortTitle, wa as openSlackDirectMessage } from "./projection-CQNDOi82.js";
|
|
2
|
+
import { n as botConfig } from "./config-CmjhyqgB.js";
|
|
3
|
+
import { _ as runBestEffort, h as logWarn } from "./logging-DcjLDDqi.js";
|
|
4
|
+
import { X as agentTurnTotalTokens, Y as agentTurnCostUsd, o as getDb } from "./db-Czra10QW.js";
|
|
5
|
+
import { d as juniorAutomationVersions, f as juniorAutomations, j as juniorConversations, u as juniorAutomationRuns } from "./executor-D_023K0H.js";
|
|
6
|
+
import { r as getStateAdapter } from "./adapter-CNjGEJO9.js";
|
|
7
|
+
import { h as credentialSubjectSchema } from "./registry-Dj377ADs.js";
|
|
8
|
+
import { u as automationEventCatalog, v as registeredEventTriggerProblems } from "./turn-session-routing-BD3-jJl7.js";
|
|
9
|
+
import { B as automationTaskColumns, H as automationTaskSchema, M as scheduledAutomationSchema, S as automationVersionSchema, V as automationTaskDescription, k as eventAutomationSchema, z as automationSkillNameSchema } from "./automation-Cva5ZOwW.js";
|
|
10
10
|
import * as z from "zod";
|
|
11
11
|
import { createHash } from "node:crypto";
|
|
12
12
|
import { and, asc, count, desc, eq, gte, inArray, isNotNull, isNull, lte, max, ne, or, sql } from "drizzle-orm";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { h as logWarn } from "./logging-
|
|
2
|
-
import { C as
|
|
1
|
+
import { h as logWarn } from "./logging-DcjLDDqi.js";
|
|
2
|
+
import { C as verifyQueueMessage, E as getQueueProvider, S as signQueueMessage, w as queueCallback, x as QUEUE_SIGNATURE_MAX_AGE_MS } from "./background-compaction-queue-CNrZ3QcU.js";
|
|
3
3
|
import * as z from "zod";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
5
5
|
// src/chat/plugins/task-queue.ts
|
|
@@ -60,7 +60,7 @@ function pluginTaskCallback() {
|
|
|
60
60
|
maxDeliveries: PLUGIN_TASK_MAX_DELIVERIES,
|
|
61
61
|
onRejected: logPluginTaskQueueMessageRejected,
|
|
62
62
|
run: async (message) => {
|
|
63
|
-
const { processPluginTask } = await import("./task-runner-
|
|
63
|
+
const { processPluginTask } = await import("./task-runner-BMxZI3o7.js").then((n) => n.r);
|
|
64
64
|
await processPluginTask(message);
|
|
65
65
|
},
|
|
66
66
|
topic: PLUGIN_TASK_QUEUE_TOPIC,
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { v as __exportAll } from "./sentry-BRTJqumy.js";
|
|
2
|
-
import {
|
|
3
|
-
import { E as withSpan } from "./logging-
|
|
2
|
+
import { Bi as createPluginState, Dn as instructionTextForProjection, In as stripRuntimeTurnContext, Mn as isToolResultMessage, Oo as createPluginConversationEvents, Pn as normalizeToolNameFromResult, Sn as getPiMessageRole, _o as createPluginLogger, fr as getPlugins, go as createPluginModelCostRecorder, hr as coreTaskRegistrations, io as createPluginModel, jn as isToolResultError, ro as createPluginEmbedder, st as getTurnRecord, v as hydrateConversationMessages, ys as createPluginCache } from "./projection-CQNDOi82.js";
|
|
3
|
+
import { E as withSpan } from "./logging-DcjLDDqi.js";
|
|
4
4
|
import { v as parseSlackMessageTs } from "./actor-D2iXzvlN.js";
|
|
5
|
-
import { a as getConversationStore, o as getDb } from "./db-
|
|
5
|
+
import { a as getConversationStore, o as getDb } from "./db-Czra10QW.js";
|
|
6
6
|
import { m as sameActorIdentity } from "./history-IjdmO_r6.js";
|
|
7
|
-
import { r as getStateAdapter } from "./adapter-
|
|
8
|
-
import { i as readActorIdentity } from "./viewer-
|
|
9
|
-
import { a as getPersistedThreadState, c as coerceThreadConversationState, t as resolveConversationRouting } from "./turn-session-routing-
|
|
10
|
-
import { c as getDispatchRecord } from "./store-
|
|
11
|
-
import { i as pluginTaskParamsSchema, r as pluginTaskId, s as sendVercelPluginTask } from "./task-queue-
|
|
7
|
+
import { r as getStateAdapter } from "./adapter-CNjGEJO9.js";
|
|
8
|
+
import { i as readActorIdentity } from "./viewer-H3EsMWtJ.js";
|
|
9
|
+
import { a as getPersistedThreadState, c as coerceThreadConversationState, t as resolveConversationRouting } from "./turn-session-routing-BD3-jJl7.js";
|
|
10
|
+
import { c as getDispatchRecord } from "./store-Epv6t4vV.js";
|
|
11
|
+
import { i as pluginTaskParamsSchema, r as pluginTaskId, s as sendVercelPluginTask } from "./task-queue-AhG1tSXR.js";
|
|
12
12
|
import { pluginRunContextSchema } from "@sentry/junior-plugin-api";
|
|
13
13
|
// src/chat/plugins/task-runner.ts
|
|
14
14
|
/**
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { E as buildConversationContext, X as clearPendingAuth,
|
|
2
|
-
import {
|
|
3
|
-
import { G as isRecord, b as setSpanAttributes, t as buildTurnFailureResponse } from "./logging-
|
|
4
|
-
import { o as getDb, r as getConversationEventStore } from "./db-
|
|
5
|
-
import { H as
|
|
6
|
-
import { S as listChildMessages, m as markTurnCompleted, n as getTurnUserMessageId, p as markTurnClosed, x as isAgentInvocationResult } from "./turn-user-message-
|
|
7
|
-
import { _ as getConversationWorkState } from "./store-
|
|
8
|
-
import { a as getPersistedThreadState, c as coerceThreadConversationState, s as persistThreadStateById } from "./turn-session-routing-
|
|
1
|
+
import { E as buildConversationContext, X as clearPendingAuth, ds as listConversationAnnotations, j as markConversationMessage, v as hydrateConversationMessages } from "./projection-CQNDOi82.js";
|
|
2
|
+
import { B as ProviderError, G as getProviderErrorUserMessage, U as findProviderError, W as getProviderErrorAttributes } from "./config-CmjhyqgB.js";
|
|
3
|
+
import { G as isRecord, b as setSpanAttributes, t as buildTurnFailureResponse } from "./logging-DcjLDDqi.js";
|
|
4
|
+
import { o as getDb, r as getConversationEventStore } from "./db-Czra10QW.js";
|
|
5
|
+
import { H as readMessageCardRefs, U as removedCardSchema, W as resolveMessageCards } from "./conversation-BNXfq6Lb.js";
|
|
6
|
+
import { S as listChildMessages, m as markTurnCompleted, n as getTurnUserMessageId, p as markTurnClosed, x as isAgentInvocationResult } from "./turn-user-message-DsUZi9gn.js";
|
|
7
|
+
import { _ as getConversationWorkState } from "./store-DmV4CoNr.js";
|
|
8
|
+
import { a as getPersistedThreadState, c as coerceThreadConversationState, s as persistThreadStateById } from "./turn-session-routing-BD3-jJl7.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,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { G as isRecord, K as toOptionalNumber, q as toOptionalString } from "./logging-
|
|
3
|
-
import { o as getDb } from "./db-
|
|
4
|
-
import { r as getStateAdapter } from "./adapter-
|
|
1
|
+
import { Oi as JUNIOR_THREAD_STATE_TTL_MS, b as persistConversationMessages, bs as createDurableLocationConfigurationService, eo as ToolInputError } from "./projection-CQNDOi82.js";
|
|
2
|
+
import { G as isRecord, K as toOptionalNumber, q as toOptionalString } from "./logging-DcjLDDqi.js";
|
|
3
|
+
import { o as getDb } from "./db-Czra10QW.js";
|
|
4
|
+
import { r as getStateAdapter } from "./adapter-CNjGEJO9.js";
|
|
5
5
|
import * as z from "zod";
|
|
6
6
|
import { agentEventMatchSchema, anyResourceMatchFields, describeEventTrigger, eventTriggerChoices, eventTriggerProblems, normalizeEventIdentifier, normalizeEventMatch } from "@sentry/junior-plugin-api";
|
|
7
7
|
// src/chat/events/catalog.ts
|
|
@@ -338,7 +338,7 @@ function slackSourceForDestination(args) {
|
|
|
338
338
|
* Reads parent Conversations when this Conversation has no Destination.
|
|
339
339
|
*/
|
|
340
340
|
async function resolveConversationRouting(args) {
|
|
341
|
-
const conversationStore = args.conversationStore ?? (await import("./db-
|
|
341
|
+
const conversationStore = args.conversationStore ?? (await import("./db-Czra10QW.js").then((n) => n.n)).getConversationStore();
|
|
342
342
|
const chain = await loadConversationChain(args.conversationId, conversationStore);
|
|
343
343
|
let destination;
|
|
344
344
|
let source;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Yt as readInboundMessageSender } from "./projection-
|
|
1
|
+
import { Yt as readInboundMessageSender } from "./projection-CQNDOi82.js";
|
|
2
2
|
import { v as parseSlackMessageTs } from "./actor-D2iXzvlN.js";
|
|
3
|
-
import { r as getConversationEventStore, s as getSqlExecutor } from "./db-
|
|
4
|
-
import { g as juniorAgentInvocations } from "./executor-
|
|
3
|
+
import { r as getConversationEventStore, s as getSqlExecutor } from "./db-Czra10QW.js";
|
|
4
|
+
import { g as juniorAgentInvocations } from "./executor-D_023K0H.js";
|
|
5
5
|
import { createHash } from "node:crypto";
|
|
6
6
|
import { inArray } from "drizzle-orm";
|
|
7
7
|
// src/chat/state/turn-id.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as getConversationStore } from "./db-
|
|
3
|
-
import { r as getStateAdapter } from "./adapter-
|
|
1
|
+
import { Ko as SlackActionError, Xo as getSlackClient, rs as withSlackRetries, ts as runWithSlackInstallationToken } from "./projection-CQNDOi82.js";
|
|
2
|
+
import { a as getConversationStore } from "./db-Czra10QW.js";
|
|
3
|
+
import { r as getStateAdapter } from "./adapter-CNjGEJO9.js";
|
|
4
4
|
import * as z from "zod";
|
|
5
5
|
// src/chat/slack/channel.ts
|
|
6
6
|
const replySubtypeSchema = z.object({ subtype: z.string().optional() });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { v as __exportAll } from "./sentry-BRTJqumy.js";
|
|
2
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime-
|
|
2
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-BEY6EGRi.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.301.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-CGMRmMPK.js";
|
|
@@ -1,27 +1,21 @@
|
|
|
1
|
-
import { H as GOOGLE_IDENTITY_PROVIDER, W as normalizeIdentityEmail
|
|
2
|
-
import { H as clearCachedUser, M as findActorIdentityId, U as readCachedUserByEmail,
|
|
3
|
-
import { M as juniorIdentities, N as juniorUsers } from "./executor-
|
|
4
|
-
import { r as detectImageMediaType } from "./media-BAHvgkok.js";
|
|
1
|
+
import { H as GOOGLE_IDENTITY_PROVIDER, W as normalizeIdentityEmail } from "./logging-DcjLDDqi.js";
|
|
2
|
+
import { H as clearCachedUser, M as findActorIdentityId, U as readCachedUserByEmail, o as getDb } from "./db-Czra10QW.js";
|
|
3
|
+
import { M as juniorIdentities, N as juniorUsers } from "./executor-D_023K0H.js";
|
|
5
4
|
import { createHash, randomUUID } from "node:crypto";
|
|
6
5
|
import { and, asc, eq, inArray, isNotNull } from "drizzle-orm";
|
|
7
6
|
import { identitySchema, userSchema } from "@sentry/junior-plugin-api";
|
|
8
7
|
// src/chat/identities/avatar.ts
|
|
9
8
|
/**
|
|
10
9
|
* Profile photos of people, saved on their native Slack and Google
|
|
11
|
-
* identities.
|
|
12
|
-
* load a photo from Slack or
|
|
10
|
+
* identities. `/api/people/avatars/:identityId` serves each photo through
|
|
11
|
+
* the shared image route code, so browsers never load a photo from Slack or
|
|
12
|
+
* Google.
|
|
13
13
|
*/
|
|
14
14
|
const AVATAR_HOSTS = {
|
|
15
15
|
slack: ["avatars.slack-edge.com"],
|
|
16
16
|
[GOOGLE_IDENTITY_PROVIDER]: ["googleusercontent.com"]
|
|
17
17
|
};
|
|
18
18
|
const AVATAR_PROVIDERS = Object.keys(AVATAR_HOSTS);
|
|
19
|
-
const AVATAR_CACHE_TTL_MS = 864e5;
|
|
20
|
-
const AVATAR_FAILURE_TTL_MS = 3e5;
|
|
21
|
-
const AVATAR_FETCH_TIMEOUT_MS = 5e3;
|
|
22
|
-
const MAX_AVATAR_BYTES = 1048576;
|
|
23
|
-
const AVATAR_EDGE_PX = 96;
|
|
24
|
-
const MAX_AVATAR_REDIRECTS = 3;
|
|
25
19
|
/**
|
|
26
20
|
* Return the URL when it is HTTPS on a photo host of the provider or a
|
|
27
21
|
* subdomain. Junior fetches only these URLs.
|
|
@@ -34,11 +28,8 @@ function parseAvatarUrl(value, provider) {
|
|
|
34
28
|
const host = url.hostname.toLowerCase();
|
|
35
29
|
return hosts.some((allowed) => host === allowed || host.endsWith(`.${allowed}`)) ? url.href : void 0;
|
|
36
30
|
}
|
|
37
|
-
function avatarUrlHash(url) {
|
|
38
|
-
return createHash("sha256").update(url).digest("hex");
|
|
39
|
-
}
|
|
40
31
|
function avatarVersion(url) {
|
|
41
|
-
return
|
|
32
|
+
return createHash("sha256").update(url).digest("hex").slice(0, 16);
|
|
42
33
|
}
|
|
43
34
|
function avatarPath(identityId, avatarUrl) {
|
|
44
35
|
return `/api/people/avatars/${encodeURIComponent(identityId)}?v=${avatarVersion(avatarUrl)}`;
|
|
@@ -76,110 +67,21 @@ function identityAvatarUrl(row, userAvatarUrls) {
|
|
|
76
67
|
if (row.userId) return userAvatarUrls.get(row.userId);
|
|
77
68
|
return row.avatarUrl ? avatarPath(row.identityId, row.avatarUrl) : void 0;
|
|
78
69
|
}
|
|
79
|
-
async function readBoundedBody(response, maxBytes) {
|
|
80
|
-
if (!response.body) return /* @__PURE__ */ new Uint8Array();
|
|
81
|
-
const reader = response.body.getReader();
|
|
82
|
-
const chunks = [];
|
|
83
|
-
let total = 0;
|
|
84
|
-
while (true) {
|
|
85
|
-
const { done, value } = await reader.read();
|
|
86
|
-
if (done) return Buffer.concat(chunks);
|
|
87
|
-
total += value.byteLength;
|
|
88
|
-
if (total > maxBytes) {
|
|
89
|
-
await reader.cancel();
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
chunks.push(value);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
function avatarFetchFailed(host, attributes) {
|
|
96
|
-
logWarn("avatar.fetch.failed", {
|
|
97
|
-
"server.address": host,
|
|
98
|
-
...attributes
|
|
99
|
-
});
|
|
100
|
-
return null;
|
|
101
|
-
}
|
|
102
|
-
async function fetchAvatarResponse(url, provider, signal) {
|
|
103
|
-
let current = url;
|
|
104
|
-
for (let redirects = 0;; redirects += 1) {
|
|
105
|
-
const response = await fetch(current, {
|
|
106
|
-
redirect: "manual",
|
|
107
|
-
signal
|
|
108
|
-
});
|
|
109
|
-
const location = response.headers.get("location");
|
|
110
|
-
if (response.status < 300 || response.status >= 400 || !location) return response;
|
|
111
|
-
await response.body?.cancel();
|
|
112
|
-
const next = URL.canParse(location, current) ? parseAvatarUrl(new URL(location, current).href, provider) : void 0;
|
|
113
|
-
if (!next) return "redirect_off_host";
|
|
114
|
-
if (redirects >= MAX_AVATAR_REDIRECTS) return "too_many_redirects";
|
|
115
|
-
current = next;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
async function fetchAvatarImage(url, provider) {
|
|
119
|
-
const host = new URL(url).hostname;
|
|
120
|
-
let data;
|
|
121
|
-
try {
|
|
122
|
-
const response = await fetchAvatarResponse(url, provider, AbortSignal.timeout(AVATAR_FETCH_TIMEOUT_MS));
|
|
123
|
-
if (typeof response === "string") return avatarFetchFailed(host, { "app.reason": response });
|
|
124
|
-
if (!response.ok) {
|
|
125
|
-
await response.body?.cancel();
|
|
126
|
-
return avatarFetchFailed(host, { "http.response.status_code": response.status });
|
|
127
|
-
}
|
|
128
|
-
data = await readBoundedBody(response, MAX_AVATAR_BYTES);
|
|
129
|
-
} catch (error) {
|
|
130
|
-
return avatarFetchFailed(host, { "exception.message": error instanceof Error ? error.message : String(error) });
|
|
131
|
-
}
|
|
132
|
-
if (!data) return avatarFetchFailed(host, { "app.reason": "too_large" });
|
|
133
|
-
const contentType = detectImageMediaType(data);
|
|
134
|
-
if (!contentType) return avatarFetchFailed(host, { "app.reason": "not_an_image" });
|
|
135
|
-
try {
|
|
136
|
-
return {
|
|
137
|
-
contentType: "image/webp",
|
|
138
|
-
data: await shrinkAvatar(data)
|
|
139
|
-
};
|
|
140
|
-
} catch (error) {
|
|
141
|
-
logWarn("avatar.resize.failed", {
|
|
142
|
-
"server.address": host,
|
|
143
|
-
"exception.message": error instanceof Error ? error.message : String(error)
|
|
144
|
-
});
|
|
145
|
-
return {
|
|
146
|
-
contentType,
|
|
147
|
-
data: Buffer.from(data).toString("base64")
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
async function shrinkAvatar(data) {
|
|
152
|
-
const { default: sharp } = await import("sharp");
|
|
153
|
-
return (await sharp(data).rotate().resize({
|
|
154
|
-
width: AVATAR_EDGE_PX,
|
|
155
|
-
height: AVATAR_EDGE_PX,
|
|
156
|
-
withoutEnlargement: true
|
|
157
|
-
}).webp({ quality: 80 }).toBuffer()).toString("base64");
|
|
158
|
-
}
|
|
159
70
|
/**
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
* not return one.
|
|
71
|
+
* Return how to fetch the photo of one user Identity, or nothing when it has
|
|
72
|
+
* no photo on a photo host of its provider. A redirect cannot leave the
|
|
73
|
+
* photo hosts of the provider.
|
|
164
74
|
*/
|
|
165
|
-
async function
|
|
75
|
+
async function readAvatarFetch(db, identityId) {
|
|
166
76
|
const [row] = await db.select({
|
|
167
77
|
avatarUrl: juniorIdentities.avatarUrl,
|
|
168
78
|
provider: juniorIdentities.provider
|
|
169
79
|
}).from(juniorIdentities).where(and(eq(juniorIdentities.id, identityId), eq(juniorIdentities.kind, "user"))).limit(1);
|
|
170
80
|
const url = row ? parseAvatarUrl(row.avatarUrl, row.provider) : void 0;
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
return {
|
|
176
|
-
value: loaded,
|
|
177
|
-
ttlMs: loaded ? AVATAR_CACHE_TTL_MS : AVATAR_FAILURE_TTL_MS
|
|
178
|
-
};
|
|
179
|
-
});
|
|
180
|
-
return image ? {
|
|
181
|
-
image,
|
|
182
|
-
version: avatarVersion(row.avatarUrl)
|
|
81
|
+
const hosts = row && AVATAR_HOSTS[row.provider];
|
|
82
|
+
return url && hosts ? {
|
|
83
|
+
hosts,
|
|
84
|
+
url
|
|
183
85
|
} : void 0;
|
|
184
86
|
}
|
|
185
87
|
// src/chat/plugins/viewer.ts
|
|
@@ -305,4 +207,4 @@ async function readIdentityByIdFromSql(db, identityId) {
|
|
|
305
207
|
async function readIdentityById(identityId) {
|
|
306
208
|
return await readIdentityByIdFromSql(getDb(), identityId);
|
|
307
209
|
}
|
|
308
|
-
export { readActorIdentityFromSql as a, readViewerAvatarUrl as c, updateViewerDisplayName as d, identityAvatarUrl as f, userAvatarUrlsFromIdentities as g, readUserAvatarUrls as h, readActorIdentity as i, resolveViewerUser as l,
|
|
210
|
+
export { readActorIdentityFromSql as a, readViewerAvatarUrl as c, updateViewerDisplayName as d, identityAvatarUrl as f, userAvatarUrlsFromIdentities as g, readUserAvatarUrls as h, readActorIdentity as i, resolveViewerUser as l, readAvatarFetch as m, findUserByEmailFromSql as n, readIdentityById as o, parseAvatarUrl as p, listAdminUsersFromSql as r, readIdentityByIdFromSql as s, findUserByEmail as t, setUserAdminFromSql as u };
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { n as captureMessage, u as sentry_exports, v as __exportAll } from "./sentry-BRTJqumy.js";
|
|
2
|
-
import { $ as loadTurnCheckpoint, Cn as getTerminalAssistantMessages, H as PluginCredentialFailureError,
|
|
3
|
-
import {
|
|
4
|
-
import { E as withSpan, h as logWarn, m as logInfo, x as setSpanStatus } from "./logging-
|
|
2
|
+
import { $ as loadTurnCheckpoint, Cn as getTerminalAssistantMessages, H as PluginCredentialFailureError, K as AuthorizationFlowDisabledError, Lo as FORK_INSTRUCTIONS, Ro as loadForkHistory, Un as escapeClosingTags, X as clearPendingAuth, _o as createPluginLogger, at as failTurnRecord, et as lostWorkerBeforeFirstSave, fn as NO_REPLY_TOOL_NAME, fr as getPlugins, in as REPLY_TOOL_NAME, j as markConversationMessage, nt as saveTurnCheckpoint, on as readTurnAnswer, qn as renderTag, rn as isTurnExecutionLimitExceededError, rt as abandonTurnRecord, s as openConversationProjection, st as getTurnRecord, tt as pauseLostWorkerTurn, un as getAssistantReplyText, v as hydrateConversationMessages, vn as REPORT_BLOCKED_TOOL_NAME, yi as listWatches, ys as createPluginCache } from "./projection-CQNDOi82.js";
|
|
3
|
+
import { D as resolveGatewayModel, _ as TURN_REASONING_LEVELS, i as getChatConfig, n as botConfig, q as isProviderRetryError } from "./config-CmjhyqgB.js";
|
|
4
|
+
import { E as withSpan, h as logWarn, m as logInfo, x as setSpanStatus } from "./logging-DcjLDDqi.js";
|
|
5
5
|
import { o as isUserActor } from "./actor-D2iXzvlN.js";
|
|
6
|
-
import { C as isPersonInput, D as conversationKindFromRow, E as turnBehavior, a as getConversationStore, et as rootConversationIsArchived, j as SYSTEM_IDENTITY_ID, o as getDb, r as getConversationEventStore, s as getSqlExecutor, w as isTopLevelKind, y as userMessageQueries } from "./db-
|
|
7
|
-
import { g as juniorAgentInvocations, h as juniorAgentBindings, j as juniorConversations, w as juniorConversationEvents } from "./executor-
|
|
6
|
+
import { C as isPersonInput, D as conversationKindFromRow, E as turnBehavior, a as getConversationStore, et as rootConversationIsArchived, j as SYSTEM_IDENTITY_ID, o as getDb, r as getConversationEventStore, s as getSqlExecutor, w as isTopLevelKind, y as userMessageQueries } from "./db-Czra10QW.js";
|
|
7
|
+
import { g as juniorAgentInvocations, h as juniorAgentBindings, j as juniorConversations, w as juniorConversationEvents } from "./executor-D_023K0H.js";
|
|
8
8
|
import { d as contextProvenance, m as sameActorIdentity, u as agentInstructionProvenance } from "./history-IjdmO_r6.js";
|
|
9
|
-
import { r as getStateAdapter } from "./adapter-
|
|
10
|
-
import { p as credentialContextSchema } from "./registry-
|
|
11
|
-
import { u as completeText } from "./prompt-
|
|
12
|
-
import { A as
|
|
13
|
-
import { C as getAuthPausedConversationTurnId, E as listActiveMailboxTurns, F as isEventMailboxMetadata, T as listActiveMailboxTurnSources, X as maybePostAutomatedTurnLimitNotice, at as
|
|
14
|
-
import {
|
|
15
|
-
import { A as getAgentInvocationResultMessageId, C as ownAgentInvocation, I as getUnnamedAgentConversationId, N as getChildAgentLockName, O as getAgentInvocationIdForResult, P as getNamedAgentConversationId, R as buildDeterministicTurnId, S as listChildMessages, T as getAgentInvocationId, _ as ConversationTurnLifecycleService, b as hasAgentInvocationReply, d as isTurnInputCommitLostError, j as getAgentInvocationTurnId, k as getAgentInvocationMessageId, l as getConversationTurnBoundaryError, p as markTurnClosed, s as TurnInputCommitLostError, t as getTurnUserMessage, w as readChildMessageSender } from "./turn-user-message-
|
|
16
|
-
import { D as stopConversationWork, _ as getConversationWorkState, h as ensureConversationWake, m as dropPendingMessages, r as appendAndEnqueueInboundMessage, v as getConversationWorkStates, w as requestConversationWork } from "./store-
|
|
17
|
-
import { a as getPersistedThreadState, c as coerceThreadConversationState, i as getPersistedSandboxState, n as resolveTurnSessionRouting, s as persistThreadStateById } from "./turn-session-routing-
|
|
18
|
-
import {
|
|
9
|
+
import { r as getStateAdapter } from "./adapter-CNjGEJO9.js";
|
|
10
|
+
import { p as credentialContextSchema } from "./registry-Dj377ADs.js";
|
|
11
|
+
import { u as completeText } from "./prompt-DLUB5m72.js";
|
|
12
|
+
import { A as agentTypeInstructions, j as agentTypeSchema } from "./conversation-BNXfq6Lb.js";
|
|
13
|
+
import { C as getAuthPausedConversationTurnId, E as listActiveMailboxTurns, F as isEventMailboxMetadata, T as listActiveMailboxTurnSources, X as maybePostAutomatedTurnLimitNotice, at as conversationSubtree, ct as systemPromptHash, f as buildSteeringPiMessage, g as withoutSavedSteeringMessages, i as resumeStoppedConversationTree, it as resetAutomatedTurnLimit, m as instructionForInputs, n as isSkippedAfterConversationStop, ot as conversationSubtreeColumns, r as markConversationsStopped, rt as recordFinishedTurnForAutomatedLimit, st as buildDeploymentSystemPrompt, t as getConversationStoppedAtMs } from "./session-stop-BLmfFI3d.js";
|
|
14
|
+
import { T as getTurnRequestDeadline, b as sendCacheWarmup, l as getVercelConversationWorkQueue } from "./background-compaction-queue-CNrZ3QcU.js";
|
|
15
|
+
import { A as getAgentInvocationResultMessageId, C as ownAgentInvocation, I as getUnnamedAgentConversationId, N as getChildAgentLockName, O as getAgentInvocationIdForResult, P as getNamedAgentConversationId, R as buildDeterministicTurnId, S as listChildMessages, T as getAgentInvocationId, _ as ConversationTurnLifecycleService, b as hasAgentInvocationReply, d as isTurnInputCommitLostError, j as getAgentInvocationTurnId, k as getAgentInvocationMessageId, l as getConversationTurnBoundaryError, p as markTurnClosed, s as TurnInputCommitLostError, t as getTurnUserMessage, w as readChildMessageSender } from "./turn-user-message-DsUZi9gn.js";
|
|
16
|
+
import { D as stopConversationWork, _ as getConversationWorkState, h as ensureConversationWake, m as dropPendingMessages, r as appendAndEnqueueInboundMessage, v as getConversationWorkStates, w as requestConversationWork } from "./store-DmV4CoNr.js";
|
|
17
|
+
import { a as getPersistedThreadState, c as coerceThreadConversationState, i as getPersistedSandboxState, n as resolveTurnSessionRouting, s as persistThreadStateById } from "./turn-session-routing-BD3-jJl7.js";
|
|
18
|
+
import { C as isAgentInvocationResultEventType, b as AGENT_PARENT_MESSAGE_EVENT_TYPE, n as AGENT_INVOCATION_PARENT_MAILBOX_STATUSES, t as AGENT_INVOCATION_MAILBOX_STATUSES, v as AGENT_INVOCATION_EVENT_NAMESPACE } from "./statuses-Hn-HsOph.js";
|
|
19
19
|
import * as z from "zod";
|
|
20
20
|
import { streamSimple } from "@earendil-works/pi-ai/compat";
|
|
21
21
|
import { isDeepStrictEqual, promisify } from "node:util";
|
|
@@ -322,7 +322,7 @@ const REFRESHED_READ_FRACTION = .9;
|
|
|
322
322
|
const BREAKER_OUTCOMES_MAX = 20;
|
|
323
323
|
const BREAKER_MAX_MISSES = 10;
|
|
324
324
|
const BREAKER_OUTCOMES_TTL_MS = 360 * MINUTE_MS;
|
|
325
|
-
const BREAKER_OPEN_TTL_MS =
|
|
325
|
+
const BREAKER_OPEN_TTL_MS = 30 * MINUTE_MS;
|
|
326
326
|
const breakerOutcomesKey = (provider) => `${KEY_PREFIX}:breaker:${provider}:outcomes`;
|
|
327
327
|
const breakerOpenKey = (provider) => `${KEY_PREFIX}:breaker:${provider}:open`;
|
|
328
328
|
const providerOf = (modelId) => modelId.split("/")[0] ?? "";
|
|
@@ -383,8 +383,27 @@ function warmupTooLate(cacheExpiresAtMs) {
|
|
|
383
383
|
async function breakerOpen(state, modelId) {
|
|
384
384
|
return await state.get(breakerOpenKey(providerOf(modelId))) === true;
|
|
385
385
|
}
|
|
386
|
+
/** Report whether each warmed provider's breaker is open. */
|
|
387
|
+
async function breakerStates(state) {
|
|
388
|
+
return Promise.all(Object.keys(CACHE_TTL_MS).map(async (provider) => ({
|
|
389
|
+
provider,
|
|
390
|
+
open: await state.get(breakerOpenKey(provider)) === true
|
|
391
|
+
})));
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Close a provider's breaker so warming starts again, and forget its recent
|
|
395
|
+
* outcomes so old misses cannot reopen it. Returns false for a provider that
|
|
396
|
+
* is not warmed.
|
|
397
|
+
*/
|
|
398
|
+
async function closeBreaker(state, provider) {
|
|
399
|
+
if (!Object.hasOwn(CACHE_TTL_MS, provider)) return false;
|
|
400
|
+
await state.delete(breakerOutcomesKey(provider));
|
|
401
|
+
await state.delete(breakerOpenKey(provider));
|
|
402
|
+
return true;
|
|
403
|
+
}
|
|
386
404
|
async function countOutcome(state, modelId, miss) {
|
|
387
405
|
const provider = providerOf(modelId);
|
|
406
|
+
if (await breakerOpen(state, modelId)) return;
|
|
388
407
|
await state.appendToList(breakerOutcomesKey(provider), miss ? 1 : 0, {
|
|
389
408
|
maxLength: BREAKER_OUTCOMES_MAX,
|
|
390
409
|
ttlMs: BREAKER_OUTCOMES_TTL_MS
|
|
@@ -392,15 +411,18 @@ async function countOutcome(state, modelId, miss) {
|
|
|
392
411
|
if (!miss) return;
|
|
393
412
|
const outcomes = await state.getList(breakerOutcomesKey(provider));
|
|
394
413
|
const misses = outcomes.filter((outcome) => outcome === 1).length;
|
|
395
|
-
if (misses >= BREAKER_MAX_MISSES && await state.setIfNotExists(breakerOpenKey(provider), true, BREAKER_OPEN_TTL_MS))
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
"
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
414
|
+
if (misses >= BREAKER_MAX_MISSES && await state.setIfNotExists(breakerOpenKey(provider), true, BREAKER_OPEN_TTL_MS)) {
|
|
415
|
+
await state.delete(breakerOutcomesKey(provider));
|
|
416
|
+
captureMessage("Cache warming stopped: too many warmups missed the cache", {
|
|
417
|
+
level: "error",
|
|
418
|
+
fingerprint: ["cache_warming.breaker.opened", provider],
|
|
419
|
+
tags: { "gen_ai.request.model": modelId },
|
|
420
|
+
extra: {
|
|
421
|
+
"app.cache_warming.misses": misses,
|
|
422
|
+
"app.cache_warming.outcomes": outcomes.length
|
|
423
|
+
}
|
|
424
|
+
});
|
|
425
|
+
}
|
|
404
426
|
}
|
|
405
427
|
/**
|
|
406
428
|
* Send one warmup: the same request with a one-token output limit. Count its
|
|
@@ -474,7 +496,9 @@ const IMAGE_REF_PREFIX = "sha256:";
|
|
|
474
496
|
const imageKey = (conversationId, sha256) => `${KEY_PREFIX}:image:${conversationId}:${sha256}`;
|
|
475
497
|
function imageParts(message) {
|
|
476
498
|
if (message.role === "assistant" || typeof message.content === "string") return [];
|
|
477
|
-
|
|
499
|
+
const images = [];
|
|
500
|
+
for (const part of message.content) if (part.type === "image") images.push(part);
|
|
501
|
+
return images;
|
|
478
502
|
}
|
|
479
503
|
function snapshotContext(context, toRef) {
|
|
480
504
|
return {
|
|
@@ -3688,4 +3712,4 @@ async function runCacheWarmup(message) {
|
|
|
3688
3712
|
}, startedAtMs, warm);
|
|
3689
3713
|
}, attributes);
|
|
3690
3714
|
}
|
|
3691
|
-
export { AgentDepthLimitError as $, readChildConversationSender as A,
|
|
3715
|
+
export { AgentDepthLimitError as $, readChildConversationSender as A, GAP_SEGMENTS as At, endActiveAgentInvocations as B, listPendingAgentInvocationMailboxAppends as C, deleteWebAuthorization as Ct, sendsResultToParent as D, breakerStates as Dt, reportReplacedWithoutOpenWork as E, executeTurn as Et, parentMessageText as F, gapHistogramReport as Ft, stopChildAgent as G, enqueueAgentInvocation as H, readLastParentMessageAtMs as I, gapSegment as It, cancelSignInWait as J, stopChildAgentsBelow as K, readParentMessage as L, childAgentTurnOptions as M, MINUTE_MS as Mt, isParentMessageMeta as N, MIN_WARMUP_PREFIX_TOKENS as Nt, childAgentInput as O, closeBreaker as Ot, logDroppedParentMessage as P, NO_REPLY_GAP_MS as Pt, createAgentInvocationFromLatest as Q, createAgentInvocationWorker as R, listOpenAgentInvocations as S, createWebAuthorization as St, markAgentInvocationParentMailboxAppended as T, AgentRunError as Tt, resolveAgentInvocationId as U, endAgentInvocationsOfStoppedWork as V, dropOwnUnreadLoopReplies as W, recordSubagentEnded as X, completeCancelledConversationTurn as Y, createAgentInvocationForMessage as Z, getAgentInvocation as _, getTurnAuthorization as _t, segmentGapsKey as a, findChildAgentConversationId as at, isTerminalAgentInvocation as b, isAttemptInterrupt as bt, listConversationWork as c, CHILD_AGENT_RESULTS as ct, listChildAgents as d, supersedeOpenMailboxTurns as dt, AgentInvocationLimitError as et, listDescendantAgents as f, supersedeTurnForInput as ft, getActiveAgentInvocationForConversation as g, wakePausedTurn as gt, TERMINAL_AGENT_INVOCATION_STATUSES as h, wakeAuthorizedTurn as ht, createCacheWarmingRecorder as i, AgentNameInUseError as it, routeChildInput as j, IDLE_HORIZON_MS as jt, getChildAgentInputSender as k, connectedState as kt, readLastUserMessageAtByConversation as l, PARENT_AGENT_TARGET as lt, NON_TERMINAL_AGENT_INVOCATION_STATUSES as m, getPausedTurnRequest as mt, GLOBAL_GAPS_MAX as n, AgentMessageQueueFullError as nt, warmup_exports as o, getAgentBinding as ot, listUnreportedSiblingAgents as p, createPausedTurns as pt, stopChildAgentsOf as q, GLOBAL_GAPS_TTL_MS as r, AgentMessageTargetError as rt, isConversationWorkDone as s, CHILD_AGENT_KINDS as st, CONVERSATION_STATE_TTL_MS as t, AgentMessagePausedError as tt, listAgentRelatives as u, agentNameSchema as ut, getChildAgentLabel as v, canJoinTurn as vt, listPendingAgentInvocationResults as w, getWebAuthorization as wt, listAgentInvocationsForConversation as x, selectAttemptMessages as xt, getLatestAgentInvocationForConversation as y, canShareTurn as yt, createAndEnqueueAgentInvocation as z };
|
|
@@ -1,30 +1,23 @@
|
|
|
1
1
|
import { v as __exportAll } from "./sentry-BRTJqumy.js";
|
|
2
|
-
import { Ct as countPendingConversationMessages, Nt as isFinalAttempt, Pt as isInvalidConversationRecordError, jt as hasConversationStop } from "./projection-
|
|
3
|
-
import {
|
|
4
|
-
import { T as withLogContext, b as setSpanAttributes, h as logWarn, m as logInfo, p as logException } from "./logging-
|
|
5
|
-
import { t as getConversationStoppedAtMs } from "./session-stop-
|
|
6
|
-
import { bt as isAttemptInterrupt, xt as selectAttemptMessages } from "./warmup-
|
|
7
|
-
import { f as ConversationQueueMessageRejectedError,
|
|
8
|
-
import { C as requestAnotherSlice, S as releaseConversationWork, T as startConversationWork, _ as getConversationWorkState, b as recordAttemptFailure, c as clearConsumedConversationWake, d as completeConversationWork, f as deadLetterAttempt, h as ensureConversationWake, i as beginConversationResume, o as checkInConversationWork, p as drainConversationMailbox, t as ackMessages, u as completeConversationStop, x as recordConversationRetry } from "./store-
|
|
9
|
-
// src/chat/task-execution/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const CONVERSATION_WORK_DEFER_DELAY_MS = 15e3;
|
|
15
|
-
const CONVERSATION_STOP_CHECK_INTERVAL_MS = 500;
|
|
16
|
-
function now(options) {
|
|
17
|
-
return options.nowMs?.() ?? Date.now();
|
|
18
|
-
}
|
|
19
|
-
function nudgeIdempotencyKey(reason, conversationId, nowMs) {
|
|
20
|
-
return `${reason}:${conversationId}:${nowMs}`;
|
|
21
|
-
}
|
|
2
|
+
import { Ct as countPendingConversationMessages, Nt as isFinalAttempt, Pt as isInvalidConversationRecordError, jt as hasConversationStop } from "./projection-CQNDOi82.js";
|
|
3
|
+
import { i as getChatConfig, q as isProviderRetryError } from "./config-CmjhyqgB.js";
|
|
4
|
+
import { T as withLogContext, b as setSpanAttributes, h as logWarn, m as logInfo, p as logException } from "./logging-DcjLDDqi.js";
|
|
5
|
+
import { t as getConversationStoppedAtMs } from "./session-stop-BLmfFI3d.js";
|
|
6
|
+
import { bt as isAttemptInterrupt, xt as selectAttemptMessages } from "./warmup-CdU5hR49.js";
|
|
7
|
+
import { T as getTurnRequestDeadline, f as ConversationQueueMessageRejectedError, h as nudgeIdempotencyKey } from "./background-compaction-queue-CNrZ3QcU.js";
|
|
8
|
+
import { C as requestAnotherSlice, S as releaseConversationWork, T as startConversationWork, _ as getConversationWorkState, b as recordAttemptFailure, c as clearConsumedConversationWake, d as completeConversationWork, f as deadLetterAttempt, h as ensureConversationWake, i as beginConversationResume, o as checkInConversationWork, p as drainConversationMailbox, t as ackMessages, u as completeConversationStop, x as recordConversationRetry } from "./store-DmV4CoNr.js";
|
|
9
|
+
// src/chat/task-execution/lost-lease.ts
|
|
10
|
+
/**
|
|
11
|
+
* Count a slice that lost its Conversation Lease as a failed attempt, then
|
|
12
|
+
* hand the work to a new slice, or stop it when retries are exhausted.
|
|
13
|
+
*/
|
|
22
14
|
async function requestLostLeaseRecovery(args) {
|
|
23
15
|
const before = await getConversationWorkState({
|
|
24
16
|
conversationId: args.conversationId,
|
|
25
17
|
state: args.options.state
|
|
26
18
|
});
|
|
27
19
|
const retry = await recordConversationRetry({
|
|
20
|
+
beforeWorkStops: args.options.beforeWorkStops,
|
|
28
21
|
conversationId: args.conversationId,
|
|
29
22
|
leaseToken: args.leaseToken,
|
|
30
23
|
conversationStore: args.options.conversationStore,
|
|
@@ -65,6 +58,16 @@ async function requestLostLeaseRecovery(args) {
|
|
|
65
58
|
state: args.options.state
|
|
66
59
|
});
|
|
67
60
|
}
|
|
61
|
+
// src/chat/task-execution/worker.ts
|
|
62
|
+
var worker_exports = /* @__PURE__ */ __exportAll({
|
|
63
|
+
CONVERSATION_WORK_DEFER_DELAY_MS: () => CONVERSATION_WORK_DEFER_DELAY_MS,
|
|
64
|
+
processConversationWork: () => processConversationWork
|
|
65
|
+
});
|
|
66
|
+
const CONVERSATION_WORK_DEFER_DELAY_MS = 15e3;
|
|
67
|
+
const CONVERSATION_STOP_CHECK_INTERVAL_MS = 500;
|
|
68
|
+
function now(options) {
|
|
69
|
+
return options.nowMs?.() ?? Date.now();
|
|
70
|
+
}
|
|
68
71
|
/**
|
|
69
72
|
* Record one failed delivery attempt and surface dead-lettered messages.
|
|
70
73
|
*
|
|
@@ -589,6 +592,7 @@ async function processConversationWorkInContext(message, options) {
|
|
|
589
592
|
});
|
|
590
593
|
} else {
|
|
591
594
|
if ((failure ? failure.status : await recordConversationRetry({
|
|
595
|
+
beforeWorkStops: options.beforeWorkStops,
|
|
592
596
|
conversationId,
|
|
593
597
|
leaseToken: lease.leaseToken,
|
|
594
598
|
conversationStore: options.conversationStore,
|