@sentry/junior 0.261.0 → 0.263.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-Bx_1B2De.js → adapter-BIacI0Bt.js} +2 -2
- package/dist/{admin-BAbbVgVc.js → admin-C7vUk7s9.js} +1 -1
- package/dist/{agent-hooks-ghyZZQqB.js → agent-hooks-CqnZfuCt.js} +126 -36
- package/dist/{agent-invocations-Qfz7dWgU.js → agent-invocations-CxKldAeB.js} +1 -0
- package/dist/{agent-runner-g110-xgg.js → agent-runner-BUBas7Yy.js} +150 -683
- package/dist/api/schema.d.ts +4 -0
- package/dist/api/schema.js +3 -3
- package/dist/api.js +34 -30
- package/dist/{app-VCiPQ65Q.d.ts → app-Bo0kB987.d.ts} +1 -1
- package/dist/app.d.ts +1 -1
- package/dist/app.js +55 -61
- package/dist/{assistant-reply-CQcMaWNL.js → assistant-reply-BFmjgJjD.js} +1 -1
- package/dist/{automation-DrpcA-SX.js → automation-CWX0qL8U.js} +1 -1
- package/dist/{briefs-CKcfrIQL.js → briefs-h55v5lX9.js} +4 -4
- package/dist/{catalog-runtime-cd60vzAB.js → catalog-runtime-Suf-aLlh.js} +1 -1
- package/dist/cli/chat.js +15 -17
- package/dist/cli/check.js +3 -3
- package/dist/cli/main.js +3 -3
- package/dist/cli/plugins.js +4 -4
- package/dist/cli/snapshot-create.js +4 -4
- package/dist/cli/upgrade.js +3 -3
- package/dist/{client-2i0JJpoC.js → client-DZBCBj1M.js} +2 -2
- package/dist/{config-C9qM41O0.js → config-Dnv8KmNs.js} +2 -2
- package/dist/{connections-DrtTrwkp.js → connections-Br0_xv27.js} +10 -10
- package/dist/{conversation-CvuKJ3tA.js → conversation-B0baEwoA.js} +2 -0
- package/dist/{conversation-privacy-1iTiFX1O.js → conversation-privacy-FY8yc2q3.js} +1 -1
- package/dist/{credential-sync-wKNQ1dYc.js → credential-sync-BvkiyWF5.js} +14 -14
- package/dist/{executor-Rimyj8HZ.js → executor-J9k2sp9m.js} +4 -3
- package/dist/{images-D1JggcVY.js → images-DV2FlEGL.js} +3 -3
- package/dist/instrumentation.js +2 -2
- package/dist/{job-queue-BjQdSqA3.js → job-queue-B4yTgklN.js} +1 -1
- package/dist/{logging-BLTa7R7f.js → logging-Dk_FpF36.js} +1 -1
- package/dist/{message-DAeP5WWW.js → message-BzseAFH1.js} +4 -3
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +3 -3
- package/dist/{oauth-callback-server-BAy1hhF1.js → oauth-callback-server-bTspTMCC.js} +2 -2
- package/dist/{profile-CthM2qFM.js → profile-Dq5I7TV1.js} +13 -6
- package/dist/{prompt-DeVax2qO.js → prompt-CxatQVaj.js} +1 -1
- package/dist/{registry-BnSaArNb.js → registry-BFzQFV_y.js} +1 -1
- package/dist/{resolve-B5eLRl0v.js → resolve-CnRHib0U.js} +4 -4
- package/dist/{result-Cvm0GZCv.js → result-DczfmNBa.js} +18 -12
- package/dist/{runner-D-pUzHbU.js → runner-CJd9Wec-.js} +11 -11
- package/dist/{sandbox-egress-signals-mvwGV7rl.js → sandbox-egress-signals-DUmVkOx4.js} +1 -1
- package/dist/{schema-OzL8Zw4H.js → schema-QidbykYl.js} +3 -3
- package/dist/{service-account-DWxvpSfd.js → service-account-BI2kQDrb.js} +3 -3
- package/dist/{service-account-Ch1uIpnR.js → service-account-x2QZXm4X.js} +3 -3
- package/dist/{session-stop-Boj_zpTa.js → session-stop-CtyJsnEj.js} +12 -12
- package/dist/{skills-BpdYCfFt.js → skills-Dbzx9-rS.js} +2 -2
- package/dist/{spawn-h1DJMQTf.js → spawn-D8WU99UV.js} +3 -2
- package/dist/store-TKg1HVKx.js +697 -0
- package/dist/{store-B6KqcdCQ.js → store-UlOrW6JC.js} +6 -6
- package/dist/{task-queue-BaDwKSYv.js → task-queue-BRB49H-J.js} +3 -3
- package/dist/{task-runner-BAX5li9a.js → task-runner-C575f2Dd.js} +19 -11
- package/dist/{tasks-uCfmlWga.js → tasks-LOItiYgL.js} +46 -66
- package/dist/{thread-state-BJHVIz8G.js → thread-state-IDHdZA7R.js} +5 -5
- package/dist/{turn-failure-response-CCC76P6-.js → turn-failure-response-h_LSXJ-M.js} +46 -20
- package/dist/{turn-lifecycle-pHSESVR9.js → turn-lifecycle-Cvi6Sb8Y.js} +1 -1
- package/dist/{turn-session-routing-BIKJZaiw.js → turn-session-routing-5Nyv4fso.js} +1 -1
- package/dist/{validation-B9KL_5Wc.js → validation-BeTriWC2.js} +1 -1
- package/dist/{version-CN9BXMW_.js → version-BQX_hLDC.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-C5xFaYVi.js → viewer-DmNRM88V.js} +4 -4
- package/dist/{web-input-D6eqfXYd.js → web-input-BHcGXSox.js} +97 -36
- package/dist/{work-C-ecZAme.js → work-DLJMV02b.js} +41 -10
- package/dist/{worker-BpYDqiOf.js → worker-vfG2ESg1.js} +5 -5
- package/migrations/0062_plugin_report_index.sql +20 -0
- package/migrations/0063_agent_invocation_type.sql +1 -0
- package/migrations/meta/0062_snapshot.json +3499 -0
- package/migrations/meta/0063_snapshot.json +3505 -0
- package/migrations/meta/_journal.json +14 -0
- package/package.json +4 -4
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { B as toOptionalNumber, V as toOptionalString, z as isRecord } from "./logging-
|
|
2
|
-
import { i as getChatConfig } from "./config-
|
|
1
|
+
import { B as toOptionalNumber, V as toOptionalString, z as isRecord } from "./logging-Dk_FpF36.js";
|
|
2
|
+
import { i as getChatConfig } from "./config-Dnv8KmNs.js";
|
|
3
3
|
import { s as parseStoredSlackActor } from "./actor-tlxzqaRe.js";
|
|
4
|
-
import { B as sameDestination, R as parseDestination, u as getConversationStore } from "./viewer-
|
|
5
|
-
import { gt as JUNIOR_THREAD_STATE_TTL_MS } from "./agent-hooks-
|
|
6
|
-
import { n as getDefaultRedisStateAdapterFor, r as getStateAdapter } from "./adapter-
|
|
7
|
-
import "./job-queue-
|
|
4
|
+
import { B as sameDestination, R as parseDestination, u as getConversationStore } from "./viewer-DmNRM88V.js";
|
|
5
|
+
import { gt as JUNIOR_THREAD_STATE_TTL_MS } from "./agent-hooks-CqnZfuCt.js";
|
|
6
|
+
import { n as getDefaultRedisStateAdapterFor, r as getStateAdapter } from "./adapter-BIacI0Bt.js";
|
|
7
|
+
import "./job-queue-B4yTgklN.js";
|
|
8
8
|
import { z } from "zod";
|
|
9
9
|
import { randomUUID } from "node:crypto";
|
|
10
10
|
import { destinationSchema } from "@sentry/junior-plugin-api";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { m as logWarn } from "./logging-
|
|
2
|
-
import { c as QUEUE_SIGNATURE_MAX_AGE_MS, d as createVercelQueueClient, l as signQueueMessage, p as runWithTurnRequestDeadline, u as verifyQueueMessage } from "./job-queue-
|
|
1
|
+
import { m as logWarn } from "./logging-Dk_FpF36.js";
|
|
2
|
+
import { c as QUEUE_SIGNATURE_MAX_AGE_MS, d as createVercelQueueClient, l as signQueueMessage, p as runWithTurnRequestDeadline, u as verifyQueueMessage } from "./job-queue-B4yTgklN.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
5
5
|
import { handleCallback, registerDevConsumer } from "@vercel/queue";
|
|
@@ -114,7 +114,7 @@ function pluginTaskCallback() {
|
|
|
114
114
|
maxDeliveries: PLUGIN_TASK_MAX_DELIVERIES,
|
|
115
115
|
onRejected: logPluginTaskQueueMessageRejected,
|
|
116
116
|
run: async (message) => {
|
|
117
|
-
const { processPluginTask } = await import("./task-runner-
|
|
117
|
+
const { processPluginTask } = await import("./task-runner-C575f2Dd.js").then((n) => n.r);
|
|
118
118
|
await processPluginTask(message);
|
|
119
119
|
},
|
|
120
120
|
topic: PLUGIN_TASK_QUEUE_TOPIC,
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
|
|
2
|
-
import { $t as
|
|
3
|
-
import { g as runBestEffort, m as logWarn } from "./logging-
|
|
2
|
+
import { $t as isToolResultMessage, Gt as getPiMessageRole, Kn as openSlackDirectMessage, Nt as getTurnRecord, Qt as isToolResultError, Rn as escapeSlackMrkdwnText, X as hydrateConversationMessages, Yt as instructionTextForProjection, en as normalizeToolNameFromResult, i as readScheduledAutomation, l as blockEventAutomation, m as getEventAutomation, nn as stripRuntimeTurnContext, nt as fallbackShortTitle, qn as postSlackMessage, zn as formatSlackLink } from "./tasks-LOItiYgL.js";
|
|
3
|
+
import { g as runBestEffort, m as logWarn } from "./logging-Dk_FpF36.js";
|
|
4
4
|
import { g as parseSlackMessageTs } from "./actor-tlxzqaRe.js";
|
|
5
|
-
import { T as agentTurnTotalTokens, d as getDb, r as readActorIdentity, u as getConversationStore, w as agentTurnCostUsd } from "./viewer-
|
|
6
|
-
import { s as juniorConversations } from "./agent-invocations-
|
|
7
|
-
import { a as juniorAutomationRuns, s as juniorAutomations } from "./executor-
|
|
5
|
+
import { T as agentTurnTotalTokens, d as getDb, r as readActorIdentity, u as getConversationStore, w as agentTurnCostUsd } from "./viewer-DmNRM88V.js";
|
|
6
|
+
import { s as juniorConversations } from "./agent-invocations-CxKldAeB.js";
|
|
7
|
+
import { a as juniorAutomationRuns, s as juniorAutomations } from "./executor-J9k2sp9m.js";
|
|
8
8
|
import { m as sameActorIdentity } from "./history-AY8rs-FR.js";
|
|
9
|
-
import { h as credentialSubjectSchema } from "./registry-
|
|
10
|
-
import { Ct as
|
|
11
|
-
import { r as getStateAdapter } from "./adapter-
|
|
12
|
-
import { r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-
|
|
13
|
-
import { t as resolveConversationRouting } from "./turn-session-routing-
|
|
14
|
-
import { i as pluginTaskParamsSchema, o as sendVercelPluginTask, r as pluginTaskId } from "./task-queue-
|
|
9
|
+
import { h as credentialSubjectSchema } from "./registry-BFzQFV_y.js";
|
|
10
|
+
import { Ct as createPluginState, Et as createPluginLogger, It as createPluginConversationEvents, Qt as createPluginCache, Tt as createPluginModel, gt as JUNIOR_THREAD_STATE_TTL_MS, p as coreTaskRegistrations, u as getPlugins, wt as createPluginEmbedder, yt as getDashboardTaskLink } from "./agent-hooks-CqnZfuCt.js";
|
|
11
|
+
import { r as getStateAdapter } from "./adapter-BIacI0Bt.js";
|
|
12
|
+
import { r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-IDHdZA7R.js";
|
|
13
|
+
import { t as resolveConversationRouting } from "./turn-session-routing-5Nyv4fso.js";
|
|
14
|
+
import { i as pluginTaskParamsSchema, o as sendVercelPluginTask, r as pluginTaskId } from "./task-queue-BRB49H-J.js";
|
|
15
15
|
import { z } from "zod";
|
|
16
16
|
import { createHash } from "node:crypto";
|
|
17
17
|
import { and, asc, count, desc, eq, gte, inArray, isNotNull, lte, max, sql } from "drizzle-orm";
|
|
@@ -784,6 +784,13 @@ async function getPluginDispatchProjection(args) {
|
|
|
784
784
|
return toDispatchProjection(record);
|
|
785
785
|
}
|
|
786
786
|
// src/chat/plugins/task-runner.ts
|
|
787
|
+
/**
|
|
788
|
+
* Plugin background-task orchestration.
|
|
789
|
+
*
|
|
790
|
+
* Core schedules tasks from completed sessions and exposes plugins only a
|
|
791
|
+
* bounded run projection rather than live runtime internals or queue
|
|
792
|
+
* payloads.
|
|
793
|
+
*/
|
|
787
794
|
var task_runner_exports = /* @__PURE__ */ __exportAll({
|
|
788
795
|
processPluginTask: () => processPluginTask,
|
|
789
796
|
scheduleSessionCompletedPluginTasks: () => scheduleSessionCompletedPluginTasks
|
|
@@ -991,6 +998,7 @@ function taskPluginContext(plugin, message, options = {}) {
|
|
|
991
998
|
model: createPluginModel(pluginName, plugin.model, { signal: options.signal }),
|
|
992
999
|
name: message.name,
|
|
993
1000
|
plugin: { name: pluginName },
|
|
1001
|
+
cache: createPluginCache(pluginName),
|
|
994
1002
|
run: { async load() {
|
|
995
1003
|
return await loadPluginRun(sessionParams);
|
|
996
1004
|
} },
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { V as toOptionalString, f as logException, m as logWarn, o as getActiveTraceId, p as logInfo, s as getLogContextAttributes, t as buildTurnFailureResponse, u as logAudit, y as setSpanAttributes, z as isRecord } from "./logging-BLTa7R7f.js";
|
|
1
|
+
import { a as completeText, f as unwrapCurrentInstruction, p as escapeXml, s as resolveGatewayModel, y as isProviderRetryError } from "./client-DZBCBj1M.js";
|
|
2
|
+
import { V as toOptionalString, f as logException, m as logWarn, o as getActiveTraceId, p as logInfo, s as getLogContextAttributes, t as buildTurnFailureResponse, u as logAudit, y as setSpanAttributes, z as isRecord } from "./logging-Dk_FpF36.js";
|
|
4
3
|
import { n as captureMessage } from "./sentry-BBUlHih9.js";
|
|
5
|
-
import { n as botConfig, v as normalizeSlackEmojiName } from "./config-
|
|
4
|
+
import { n as botConfig, v as normalizeSlackEmojiName } from "./config-Dnv8KmNs.js";
|
|
6
5
|
import { c as toStoredSlackActor, f as parseSlackUserId, g as parseSlackMessageTs } from "./actor-tlxzqaRe.js";
|
|
7
|
-
import { C as addAgentTurnUsage, R as parseDestination, c as getConversationEventStore, d as getDb, f as getSqlExecutor, m as withConversationEventLock, p as createSqlConversationEventStore, u as getConversationStore, x as bindProviderConversation, y as startLocationThread } from "./viewer-
|
|
8
|
-
import { d as juniorDestinations } from "./agent-invocations-
|
|
9
|
-
import { a as juniorAutomationRuns, l as juniorLocationConfigurations, o as juniorAutomationVersions, s as juniorAutomations } from "./executor-
|
|
6
|
+
import { C as addAgentTurnUsage, R as parseDestination, c as getConversationEventStore, d as getDb, f as getSqlExecutor, m as withConversationEventLock, p as createSqlConversationEventStore, u as getConversationStore, x as bindProviderConversation, y as startLocationThread } from "./viewer-DmNRM88V.js";
|
|
7
|
+
import { d as juniorDestinations } from "./agent-invocations-CxKldAeB.js";
|
|
8
|
+
import { a as juniorAutomationRuns, l as juniorLocationConfigurations, o as juniorAutomationVersions, s as juniorAutomations } from "./executor-J9k2sp9m.js";
|
|
10
9
|
import { d as contextProvenance, f as instructionActors, n as agentHistoryItemSchema, p as instructionProvenanceFor } from "./history-AY8rs-FR.js";
|
|
11
|
-
import { _ as CredentialUnavailableError, a as resolveAuthTokenPlaceholder, f as credentialContextForActor, h as credentialSubjectSchema, o as resolvePluginCommandEnv, p as credentialContextSchema } from "./registry-
|
|
12
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime-
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { y as sleep } from "./profile-
|
|
17
|
-
import { A as eventAutomationSchema, E as scheduledAutomationSchema, S as automationVersionSchema } from "./automation-
|
|
10
|
+
import { _ as CredentialUnavailableError, a as resolveAuthTokenPlaceholder, f as credentialContextForActor, h as credentialSubjectSchema, o as resolvePluginCommandEnv, p as credentialContextSchema } from "./registry-BFzQFV_y.js";
|
|
11
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-Suf-aLlh.js";
|
|
12
|
+
import { Et as createPluginLogger, Qt as createPluginCache, ct as getSlackClient, dt as normalizeSlackConversationId, en as JUNIOR_NATIVE_EVENT_NAMESPACE, it as SlackActionError, n as applyPluginFormatMarkdown, nn as authenticationLinkedEvent, pt as withSlackRetries, rn as authenticationUnlinkedEvent, tn as agentsInstructionsUpdatedEvent, u as getPlugins, ut as isDmChannel, xt as ToolInputError } from "./agent-hooks-CqnZfuCt.js";
|
|
13
|
+
import { a as acquireActiveLock, i as MUTATION_LOCK_TTL_MS, o as fenceLock, r as getStateAdapter, s as withLock } from "./adapter-BIacI0Bt.js";
|
|
14
|
+
import { N as messageCardRef } from "./conversation-B0baEwoA.js";
|
|
15
|
+
import { y as sleep } from "./profile-Dq5I7TV1.js";
|
|
16
|
+
import { A as eventAutomationSchema, E as scheduledAutomationSchema, S as automationVersionSchema } from "./automation-CWX0qL8U.js";
|
|
18
17
|
import { isDeepStrictEqual } from "node:util";
|
|
19
18
|
import { z } from "zod";
|
|
20
19
|
import { createHash, createHmac, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
|
|
@@ -420,6 +419,7 @@ function basePluginContext(plugin) {
|
|
|
420
419
|
const pluginName = plugin.manifest.name;
|
|
421
420
|
return {
|
|
422
421
|
plugin: { name: pluginName },
|
|
422
|
+
cache: createPluginCache(pluginName),
|
|
423
423
|
log: createPluginLogger(pluginName),
|
|
424
424
|
db: getDb()
|
|
425
425
|
};
|
|
@@ -1336,12 +1336,10 @@ const sandboxEgressAuthRequiredSignalSchema = z.object({
|
|
|
1336
1336
|
});
|
|
1337
1337
|
const sandboxEgressPermissionDeniedSignalSchema = z.object({
|
|
1338
1338
|
account: pluginProviderAccountSchema.optional(),
|
|
1339
|
-
acceptedPermissions: z.string().optional(),
|
|
1340
1339
|
grant: sandboxEgressGrantSchema,
|
|
1341
1340
|
message: z.string().min(1),
|
|
1342
1341
|
provider: providerNameSchema,
|
|
1343
1342
|
source: z.literal("upstream"),
|
|
1344
|
-
sso: z.string().optional(),
|
|
1345
1343
|
status: httpStatusSchema,
|
|
1346
1344
|
upstreamHost: z.string().min(1),
|
|
1347
1345
|
upstreamPath: z.string().min(1),
|
|
@@ -2007,21 +2005,6 @@ function displayedUpstreamPath(upstreamUrl) {
|
|
|
2007
2005
|
if (upstreamUrl.hostname.toLowerCase() === "github.com" && (gitService === "git-upload-pack" || gitService === "git-receive-pack")) return `${upstreamUrl.pathname}?service=${gitService}`;
|
|
2008
2006
|
return upstreamUrl.pathname;
|
|
2009
2007
|
}
|
|
2010
|
-
function upstreamPermissionAttributes(provider, upstream) {
|
|
2011
|
-
if (provider !== "github") return {};
|
|
2012
|
-
return {
|
|
2013
|
-
"app.github.accepted_permissions": upstream.headers.get("x-accepted-github-permissions") ?? void 0,
|
|
2014
|
-
"app.github.sso": upstream.headers.get("x-github-sso") ?? void 0
|
|
2015
|
-
};
|
|
2016
|
-
}
|
|
2017
|
-
function githubPermissionHeaders(upstream) {
|
|
2018
|
-
const acceptedPermissions = upstream.headers.get("x-accepted-github-permissions");
|
|
2019
|
-
const sso = upstream.headers.get("x-github-sso");
|
|
2020
|
-
return {
|
|
2021
|
-
...acceptedPermissions ? { acceptedPermissions } : void 0,
|
|
2022
|
-
...sso ? { sso } : void 0
|
|
2023
|
-
};
|
|
2024
|
-
}
|
|
2025
2008
|
function permissionDeniedMessage(provider, grant) {
|
|
2026
2009
|
return `${provider} returned HTTP 403 after the runtime injected the ${grant.name} grant. The request was forwarded; this is not a local runtime block.`;
|
|
2027
2010
|
}
|
|
@@ -2193,8 +2176,7 @@ function leaseLogAttributes(input) {
|
|
|
2193
2176
|
provider: input.provider,
|
|
2194
2177
|
status: input.status
|
|
2195
2178
|
}),
|
|
2196
|
-
...routingAttributes(input.request, input.upstreamUrl)
|
|
2197
|
-
...input.upstream ? upstreamPermissionAttributes(input.provider, input.upstream) : void 0
|
|
2179
|
+
...routingAttributes(input.request, input.upstreamUrl)
|
|
2198
2180
|
};
|
|
2199
2181
|
}
|
|
2200
2182
|
async function recordSandboxAuthRequired(input) {
|
|
@@ -2215,8 +2197,7 @@ async function recordSandboxPermissionDenied(input) {
|
|
|
2215
2197
|
source: "upstream",
|
|
2216
2198
|
status: input.upstream.status,
|
|
2217
2199
|
upstreamHost: input.upstreamUrl.hostname,
|
|
2218
|
-
upstreamPath: displayedUpstreamPath(input.upstreamUrl)
|
|
2219
|
-
...input.provider === "github" ? githubPermissionHeaders(input.upstream) : void 0
|
|
2200
|
+
upstreamPath: displayedUpstreamPath(input.upstreamUrl)
|
|
2220
2201
|
});
|
|
2221
2202
|
}
|
|
2222
2203
|
/**
|
|
@@ -2326,13 +2307,12 @@ async function executeCredentialedEgressRequest(input) {
|
|
|
2326
2307
|
let leaseOrResponse = await resolveLease();
|
|
2327
2308
|
if (leaseOrResponse instanceof Response) return leaseOrResponse;
|
|
2328
2309
|
let lease = leaseOrResponse;
|
|
2329
|
-
const attributes = (activeLease, status
|
|
2310
|
+
const attributes = (activeLease, status) => leaseLogAttributes({
|
|
2330
2311
|
egressId: activeEgressId,
|
|
2331
2312
|
lease: activeLease,
|
|
2332
2313
|
provider,
|
|
2333
2314
|
request,
|
|
2334
2315
|
status,
|
|
2335
|
-
...upstream ? { upstream } : void 0,
|
|
2336
2316
|
upstreamUrl
|
|
2337
2317
|
});
|
|
2338
2318
|
if (!hasSandboxEgressLeaseTransformForHost(lease, upstreamUrl.hostname)) {
|
|
@@ -2387,7 +2367,7 @@ async function executeCredentialedEgressRequest(input) {
|
|
|
2387
2367
|
authorization: error.authorization ?? lease.authorization,
|
|
2388
2368
|
message: error.message
|
|
2389
2369
|
});
|
|
2390
|
-
logWarn("sandbox.egress.upstream_auth_requirement.classified", { ...attributes(lease, upstream.status
|
|
2370
|
+
logWarn("sandbox.egress.upstream_auth_requirement.classified", { ...attributes(lease, upstream.status) });
|
|
2391
2371
|
await upstream.body?.cancel().catch(() => void 0);
|
|
2392
2372
|
return authRequiredResponse({
|
|
2393
2373
|
provider,
|
|
@@ -2406,12 +2386,12 @@ async function executeCredentialedEgressRequest(input) {
|
|
|
2406
2386
|
upstreamUrl
|
|
2407
2387
|
});
|
|
2408
2388
|
if (upstream.status >= 400) logWarn("sandbox.egress.upstream_response.failed", {
|
|
2409
|
-
...attributes(lease, upstream.status
|
|
2389
|
+
...attributes(lease, upstream.status),
|
|
2410
2390
|
"error.type": `http_${upstream.status}`
|
|
2411
2391
|
});
|
|
2412
2392
|
if (upstream.status === UPSTREAM_TOKEN_REJECTION_STATUS) {
|
|
2413
2393
|
logWarn("sandbox.egress.upstream_auth.rejected", {
|
|
2414
|
-
...attributes(lease, upstream.status
|
|
2394
|
+
...attributes(lease, upstream.status),
|
|
2415
2395
|
"app.sandbox.egress.www_authenticate": upstream.headers.get("www-authenticate") ?? void 0
|
|
2416
2396
|
});
|
|
2417
2397
|
await clearCredentialLease(provider, lease.grant, credentialContext);
|
|
@@ -2430,10 +2410,10 @@ async function executeCredentialedEgressRequest(input) {
|
|
|
2430
2410
|
});
|
|
2431
2411
|
}
|
|
2432
2412
|
if (upstream.status === UPSTREAM_PERMISSION_REJECTION_STATUS && !retriedAfter403) {
|
|
2433
|
-
logWarn("sandbox.egress.upstream_auth.rejected", { ...attributes(lease, upstream.status
|
|
2413
|
+
logWarn("sandbox.egress.upstream_auth.rejected", { ...attributes(lease, upstream.status) });
|
|
2434
2414
|
await clearCredentialLease(provider, lease.grant, credentialContext);
|
|
2435
2415
|
await upstream.body?.cancel().catch(() => void 0);
|
|
2436
|
-
logWarn("sandbox.egress.upstream_auth.retrying", { ...attributes(lease, upstream.status
|
|
2416
|
+
logWarn("sandbox.egress.upstream_auth.retrying", { ...attributes(lease, upstream.status) });
|
|
2437
2417
|
leaseOrResponse = await resolveLease();
|
|
2438
2418
|
if (leaseOrResponse instanceof Response) return leaseOrResponse;
|
|
2439
2419
|
lease = leaseOrResponse;
|
|
@@ -2441,7 +2421,7 @@ async function executeCredentialedEgressRequest(input) {
|
|
|
2441
2421
|
continue;
|
|
2442
2422
|
}
|
|
2443
2423
|
if (upstream.status === UPSTREAM_PERMISSION_REJECTION_STATUS) {
|
|
2444
|
-
logWarn("sandbox.egress.upstream_auth.rejected", { ...attributes(lease, upstream.status
|
|
2424
|
+
logWarn("sandbox.egress.upstream_auth.rejected", { ...attributes(lease, upstream.status) });
|
|
2445
2425
|
await clearCredentialLease(provider, lease.grant, credentialContext);
|
|
2446
2426
|
await recordPermissionDenied({
|
|
2447
2427
|
credentialContext,
|
|
@@ -2451,7 +2431,7 @@ async function executeCredentialedEgressRequest(input) {
|
|
|
2451
2431
|
upstream,
|
|
2452
2432
|
upstreamUrl
|
|
2453
2433
|
});
|
|
2454
|
-
if (pluginPermissionDenied) logWarn("sandbox.egress.upstream_permission.classified", { ...attributes(lease, upstream.status
|
|
2434
|
+
if (pluginPermissionDenied) logWarn("sandbox.egress.upstream_permission.classified", { ...attributes(lease, upstream.status) });
|
|
2455
2435
|
return new Response(upstream.body, {
|
|
2456
2436
|
status: upstream.status,
|
|
2457
2437
|
statusText: upstream.statusText,
|
|
@@ -2467,7 +2447,7 @@ async function executeCredentialedEgressRequest(input) {
|
|
|
2467
2447
|
upstream,
|
|
2468
2448
|
upstreamUrl
|
|
2469
2449
|
});
|
|
2470
|
-
logWarn("sandbox.egress.upstream_permission.classified", { ...attributes(lease, upstream.status
|
|
2450
|
+
logWarn("sandbox.egress.upstream_permission.classified", { ...attributes(lease, upstream.status) });
|
|
2471
2451
|
}
|
|
2472
2452
|
return new Response(upstream.body, {
|
|
2473
2453
|
status: upstream.status,
|
|
@@ -2477,22 +2457,12 @@ async function executeCredentialedEgressRequest(input) {
|
|
|
2477
2457
|
}
|
|
2478
2458
|
}
|
|
2479
2459
|
// src/chat/experimental.ts
|
|
2480
|
-
var experimental_exports = /* @__PURE__ */ __exportAll({
|
|
2481
|
-
EXPERIMENTAL_FEATURES: () => EXPERIMENTAL_FEATURES,
|
|
2482
|
-
getExperimentalFeatures: () => getExperimentalFeatures,
|
|
2483
|
-
isExperimentalFeatureEnabled: () => isExperimentalFeatureEnabled,
|
|
2484
|
-
setExperimentalFeatures: () => setExperimentalFeatures
|
|
2485
|
-
});
|
|
2486
2460
|
/**
|
|
2487
2461
|
* Known unstable product features that must be opted into explicitly.
|
|
2488
2462
|
* Add new keys here as features graduate from private experiments; remove them
|
|
2489
2463
|
* once they become stable defaults.
|
|
2490
2464
|
*/
|
|
2491
|
-
const EXPERIMENTAL_FEATURES = [
|
|
2492
|
-
"operator-tools",
|
|
2493
|
-
"passive-routing",
|
|
2494
|
-
"subagents"
|
|
2495
|
-
];
|
|
2465
|
+
const EXPERIMENTAL_FEATURES = ["operator-tools", "passive-routing"];
|
|
2496
2466
|
const EXPERIMENTAL_FEATURE_SET = new Set(EXPERIMENTAL_FEATURES);
|
|
2497
2467
|
let configuredExperimental = {};
|
|
2498
2468
|
function isExperimentalFeature(value) {
|
|
@@ -2969,6 +2939,17 @@ function buildDeterministicAssistantMessageId(turnId) {
|
|
|
2969
2939
|
* both in sync without requiring the full prompt module.
|
|
2970
2940
|
*/
|
|
2971
2941
|
const TURN_CONTEXT_TAG = "runtime-turn-context";
|
|
2942
|
+
/** Turn context section that only session context includes. */
|
|
2943
|
+
const SESSION_CONTEXT_SECTION_TAG = "runtime";
|
|
2944
|
+
/**
|
|
2945
|
+
* Turn context sections that are true only for the Turn that received them.
|
|
2946
|
+
* Context compaction removes them from the context of earlier Turns.
|
|
2947
|
+
*/
|
|
2948
|
+
const REQUEST_CONTEXT_SECTION_TAG = {
|
|
2949
|
+
pluginContext: "plugin-context",
|
|
2950
|
+
conversationNotes: "conversation-notes",
|
|
2951
|
+
disabledTools: "disabled-tools"
|
|
2952
|
+
};
|
|
2972
2953
|
// src/chat/pi/transcript.ts
|
|
2973
2954
|
const RUNTIME_TURN_CONTEXT_START = `<${TURN_CONTEXT_TAG}>`;
|
|
2974
2955
|
const AGENTS_INSTRUCTIONS_START = "# AGENTS.md instructions";
|
|
@@ -3303,6 +3284,7 @@ const storedTurnRecordSchema = z.object({
|
|
|
3303
3284
|
errorMessage: z.string().optional(),
|
|
3304
3285
|
cumulativeToolCallCount: z.number().int().nonnegative().optional(),
|
|
3305
3286
|
turnLimitWrappedUp: z.boolean().optional(),
|
|
3287
|
+
lostWorkerResumeCount: z.number().int().nonnegative().optional(),
|
|
3306
3288
|
turnStartSeq: seqCursorSchema.optional(),
|
|
3307
3289
|
runtimeContext: z.array(piMessageSchema).optional()
|
|
3308
3290
|
}).strip();
|
|
@@ -3400,6 +3382,7 @@ function materializeTurnRecord(stored, piProjection, turnStartMessageIndex, runt
|
|
|
3400
3382
|
credentialSubject: stored.credentialSubject,
|
|
3401
3383
|
cumulativeToolCallCount: stored.cumulativeToolCallCount,
|
|
3402
3384
|
turnLimitWrappedUp: stored.turnLimitWrappedUp,
|
|
3385
|
+
lostWorkerResumeCount: stored.lostWorkerResumeCount,
|
|
3403
3386
|
cumulativeUsage: runtimeMetrics?.cumulativeUsage,
|
|
3404
3387
|
dispatchId: stored.dispatchId,
|
|
3405
3388
|
dispatchOutcome: stored.dispatchOutcome,
|
|
@@ -3471,6 +3454,7 @@ function buildStoredRecord(args) {
|
|
|
3471
3454
|
credentialSubject: args.credentialSubject,
|
|
3472
3455
|
cumulativeToolCallCount: args.cumulativeToolCallCount,
|
|
3473
3456
|
turnLimitWrappedUp: args.turnLimitWrappedUp,
|
|
3457
|
+
lostWorkerResumeCount: args.lostWorkerResumeCount,
|
|
3474
3458
|
dispatchId: args.dispatchId,
|
|
3475
3459
|
dispatchOutcome: args.dispatchOutcome,
|
|
3476
3460
|
errorMessage: args.errorMessage,
|
|
@@ -3548,6 +3532,7 @@ async function updateTurnState(args) {
|
|
|
3548
3532
|
credentialSubject: args.existing.credentialSubject,
|
|
3549
3533
|
cumulativeToolCallCount: args.existing.cumulativeToolCallCount,
|
|
3550
3534
|
turnLimitWrappedUp: args.existing.turnLimitWrappedUp,
|
|
3535
|
+
lostWorkerResumeCount: args.existing.lostWorkerResumeCount,
|
|
3551
3536
|
dispatchId: args.existing.dispatchId,
|
|
3552
3537
|
dispatchOutcome: args.existing.dispatchOutcome,
|
|
3553
3538
|
errorMessage: args.errorMessage ?? args.existing.errorMessage,
|
|
@@ -3623,6 +3608,7 @@ async function upsertTurnRecordLocked(args, fence) {
|
|
|
3623
3608
|
credentialSubject: existingRecord?.credentialSubject ?? args.credentialSubject,
|
|
3624
3609
|
cumulativeToolCallCount: args.cumulativeToolCallCount ?? existingRecord?.cumulativeToolCallCount,
|
|
3625
3610
|
turnLimitWrappedUp: args.turnLimitWrappedUp ?? existingRecord?.turnLimitWrappedUp,
|
|
3611
|
+
lostWorkerResumeCount: args.lostWorkerResumeCount ?? existingRecord?.lostWorkerResumeCount,
|
|
3626
3612
|
dispatchId,
|
|
3627
3613
|
dispatchOutcome: args.dispatchOutcome ?? existingRecord?.dispatchOutcome,
|
|
3628
3614
|
errorMessage: args.errorMessage,
|
|
@@ -3806,7 +3792,8 @@ function sharedWrite(args, latest) {
|
|
|
3806
3792
|
traceId: getActiveTraceId() ?? latest?.traceId,
|
|
3807
3793
|
turnStartMessageIndex: args.turnStartMessageIndex ?? latest?.turnStartMessageIndex,
|
|
3808
3794
|
cumulativeToolCallCount: args.cumulativeToolCallCount ?? latest?.cumulativeToolCallCount,
|
|
3809
|
-
turnLimitWrappedUp: args.turnLimitWrappedUp ?? latest?.turnLimitWrappedUp
|
|
3795
|
+
turnLimitWrappedUp: args.turnLimitWrappedUp ?? latest?.turnLimitWrappedUp,
|
|
3796
|
+
lostWorkerResumeCount: args.lostWorkerResumeCount ?? latest?.lostWorkerResumeCount
|
|
3810
3797
|
})
|
|
3811
3798
|
};
|
|
3812
3799
|
}
|
|
@@ -4186,6 +4173,7 @@ async function getPluginConversationTitleContext(args) {
|
|
|
4186
4173
|
egress,
|
|
4187
4174
|
log: createPluginLogger(plugin.manifest.name),
|
|
4188
4175
|
plugin: { name: plugin.manifest.name },
|
|
4176
|
+
cache: createPluginCache(plugin.manifest.name),
|
|
4189
4177
|
signal,
|
|
4190
4178
|
text: args.text
|
|
4191
4179
|
}), timedOut]);
|
|
@@ -5338,14 +5326,6 @@ async function recordGuardianActionReviewed(args) {
|
|
|
5338
5326
|
createdAtMs: Date.now()
|
|
5339
5327
|
}]);
|
|
5340
5328
|
}
|
|
5341
|
-
// src/chat/tools/execution/tool-input-error.ts
|
|
5342
|
-
/** Thrown when a tool fails due to invalid model/user input, not a system error. */
|
|
5343
|
-
var ToolInputError = class extends Error {
|
|
5344
|
-
constructor(message, options) {
|
|
5345
|
-
super(message, options);
|
|
5346
|
-
this.name = "ToolInputError";
|
|
5347
|
-
}
|
|
5348
|
-
};
|
|
5349
5329
|
// src/chat/automations/revision.ts
|
|
5350
5330
|
/** Storage revisions prevent stale edits from replacing newer values. */
|
|
5351
5331
|
var AutomationConflictError = class extends ToolInputError {
|
|
@@ -5834,4 +5814,4 @@ async function saveScheduledAutomation(db, task, expectedRevision, editedBy) {
|
|
|
5834
5814
|
async function saveScheduledAutomationInLock(db, task, current) {
|
|
5835
5815
|
await writeScheduledAutomation(db, requireStoredTask(task), current);
|
|
5836
5816
|
}
|
|
5837
|
-
export {
|
|
5817
|
+
export { persistConversationMessageSummaries as $, resolvePluginOAuthAccount as $n, isToolResultMessage as $t, commitAcceptedReply as A, createSandboxEgressCredentialToken as An, abandonTurnRecord as At, recordAttachmentsDelivered as B, normalizeSlackReplyMarkdown as Bn, buildTurnErrorResponse as Bt, automationVersionOf as C, resolveSandboxEgressProviderForHost as Cn, canReusePendingAuthLink as Ct, AutomationConflictError as D, clearSandboxEgressSignals as Dn, continuableMessages as Dt, sameDefinitionValue as E, SANDBOX_EGRESS_PROXY_PATH as En, wasPendingAuthStopped as Et, loadProjection as F, parseOAuthStatePayload as Fn, recordTurnSummary as Ft, recordMcpProviderConnected as G, getSlackMessagePermalink as Gn, getPiMessageRole as Gt, recordAuthorizationCompleted as H, slackMention as Hn, isTurnExecutionLimitExceededError as Ht, loadTurnProjection as I, resolveBaseUrl as In, TURN_LIMIT_DISABLED_REASON as It, recordTurnRoute as J, removeReactionFromMessage as Jn, hasRuntimeTurnContext as Jt, recordSubscribedReplyRoute as K, openSlackDirectMessage as Kn, getTerminalAssistantMessages as Kt, loadTurnRoute as L, startOAuthFlow as Ln, TurnBudgetExceededError as Lt, loadConnectedMcpProviders as M, sandboxEgressSignalsResponseSchema as Mn, failTurnRecord as Mt, loadConversationProjection as N, deliverOAuthAuthorization as Nn, getTurnRecord as Nt, automationRevision as O, consumeSandboxEgressAuthRequiredSignal as On, loadTurnCheckpoint as Ot, loadLastModelProfile as P, formatProviderLabel as Pn, listTurnSummaries as Pt, projectConversationMessages as Q, getOAuthAccountProviders as Qn, isToolResultError as Qt, openConversationProjection as R, escapeSlackMrkdwnText as Rn, TurnSliceLimitExceededError as Rt, automationDefinition as S, resolveSandboxCommandEnvironment as Sn, abandonReplacedPendingAuth as St, readAutomationVersion as T, shouldPropagateSandboxEgressTrace as Tn, getConversationPendingAuth as Tt, recordAuthorizationRequested as U, truncateStatusText as Un, persistWithRetry as Ut, recordAuthenticationLinked as V, normalizeSlackStatusText as Vn, createTurnLimitGate as Vt, recordGuardianActionReviewed as W, addReactionToMessage as Wn, extractAssistantText as Wt, hydrateConversationMessages as X, slackEntitySchema as Xn, isAssistantMessage as Xt, appendConversationMessages as Y, uploadFilesToConversation as Yn, instructionTextForProjection as Yt, persistConversationMessages as Z, slackExternalRefIdSchema as Zn, isContinuablePiBoundary as Zt, parseEventAutomationRow as _, isExperimentalFeatureEnabled as _n, createPluginAuthOrchestration as _t, saveScheduledAutomation as a, SESSION_CONTEXT_SECTION_TAG as an, setConfigDefaults as ar, buildConversationContext as at, admitEventAutomationRun as b, createUserTokenStore as bn, AuthorizationFlowDisabledError as bt, withScheduledAutomationLock as c, buildDeterministicTurnId as cn, getConversationMessageSlackTs as ct, createEventAutomation as d, getSubscribedReplyPreflightDecision as dn, normalizeConversationText as dt, normalizeToolNameFromResult as en, createDurableLocationConfigurationService as er, resolveConversationTitle as et, deleteEventAutomation as f, getThreadStopDecision as fn, recordDeliveredAssistantMessage as ft, listEventAutomationsForTeam as g, getExperimentalFeatures as gn, PluginCredentialFailureError as gt, listDeletedEventAutomationsCreatedBy as h, getAgentContextInputLimitTokens as hn, createPluginEgress as ht, readScheduledAutomation as i, REQUEST_CONTEXT_SECTION_TAG as in, getConfigDefaults as ir, appendThreadContextMessages as it, commitMessages as j, parseSandboxEgressCredentialToken as jn, completeTurnRecord as jt, requireAutomationRevision as k, consumeSandboxEgressPermissionDeniedSignal as kn, saveTurnCheckpoint as kt, blockEventAutomation as l, SubscribedReplyReason as ln, isHumanConversationMessage as lt, getEventAutomation as m, getAgentContextCompactionTriggerTokens as mn, upsertConversationMessage as mt, listScheduledAutomationsForTeam as n, stripRuntimeTurnContext as nn, historyItemFromPiMessage as nr, fallbackShortTitle as nt, saveScheduledAutomationInLock as o, TURN_CONTEXT_TAG as on, createConversationMemoryService as ot, findMatchingEventAutomations as p, estimateTextTokens as pn, turnHasReply as pt, recordToolExecutionStarted as q, postSlackMessage as qn, getUserMessageInstructionText as qt, parseScheduledAutomationRow as r, trimTrailingAssistantMessages as rn, piMessageFromHistoryItem as rr, resolveTaskTitle as rt, scheduledRunId as s, buildDeterministicAssistantMessageId as sn, estimateConversationContextTokens as st, createScheduledAutomation as t, retainRuntimeTurnContext as tn, configValueSchema as tr, settleConversationTitleWork as tt, collectEventAutomationMatchKeys as u, decideSubscribedThreadReply as un, markConversationMessage as ut, saveEventAutomation as v, setExperimentalFeatures as vn, authorizationId as vt, listAutomationVersions as w, normalizeSandboxEgressTracePropagationDomains as wn, clearPendingAuth as wt, eventAutomationRunLimitReason as x, buildSandboxEgressNetworkPolicy as xn, AuthorizationPauseError as xt, setEventAutomationStatus as y, executeCredentialedEgressRequest as yn, AuthPausePersistenceError as yt, recordAgentsInstructionsUpdated as z, formatSlackLink as zn, TurnToolCallLimitExceededError as zt };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { B as toOptionalNumber, V as toOptionalString, z as isRecord } from "./logging-
|
|
3
|
-
import { d as getDb } from "./viewer-
|
|
4
|
-
import { gt as JUNIOR_THREAD_STATE_TTL_MS } from "./agent-hooks-
|
|
5
|
-
import { r as getStateAdapter } from "./adapter-
|
|
1
|
+
import { Z as persistConversationMessages, er as createDurableLocationConfigurationService } from "./tasks-LOItiYgL.js";
|
|
2
|
+
import { B as toOptionalNumber, V as toOptionalString, z as isRecord } from "./logging-Dk_FpF36.js";
|
|
3
|
+
import { d as getDb } from "./viewer-DmNRM88V.js";
|
|
4
|
+
import { gt as JUNIOR_THREAD_STATE_TTL_MS } from "./agent-hooks-CqnZfuCt.js";
|
|
5
|
+
import { r as getStateAdapter } from "./adapter-BIacI0Bt.js";
|
|
6
6
|
// src/chat/state/conversation.ts
|
|
7
7
|
function defaultConversationState() {
|
|
8
8
|
return {
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { _ as getProviderErrorAttributes, g as findProviderError, m as ProviderError, v as getProviderErrorUserMessage } from "./client-
|
|
3
|
-
import { t as buildTurnFailureResponse, z as isRecord } from "./logging-
|
|
1
|
+
import { X as hydrateConversationMessages, cn as buildDeterministicTurnId, ut as markConversationMessage, wt as clearPendingAuth } from "./tasks-LOItiYgL.js";
|
|
2
|
+
import { _ as getProviderErrorAttributes, g as findProviderError, m as ProviderError, v as getProviderErrorUserMessage } from "./client-DZBCBj1M.js";
|
|
3
|
+
import { t as buildTurnFailureResponse, z as isRecord } from "./logging-Dk_FpF36.js";
|
|
4
4
|
import { g as parseSlackMessageTs } from "./actor-tlxzqaRe.js";
|
|
5
|
-
import { c as getConversationEventStore, d as getDb } from "./viewer-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { o as persistThreadStateById, r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-
|
|
5
|
+
import { c as getConversationEventStore, d as getDb } from "./viewer-DmNRM88V.js";
|
|
6
|
+
import { qt as listConversationAnnotations } from "./agent-hooks-CqnZfuCt.js";
|
|
7
|
+
import { F as readMessageCardRefs, I as removedCardSchema, L as resolveMessageCards } from "./conversation-B0baEwoA.js";
|
|
8
|
+
import { D as parseAgentInvocationResultMessageId, J as markTurnClosed, Y as markTurnCompleted, c as getAgentInvocation, m as getAgentInvocationTurnId } from "./store-TKg1HVKx.js";
|
|
9
|
+
import { o as persistThreadStateById, r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-IDHdZA7R.js";
|
|
10
10
|
// src/chat/conversations/pending-cards.ts
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Add the cards that tool results selected since the last visible assistant
|
|
13
|
+
* Message or Turn start, scanning back from `beforeSeq`. Returns the input
|
|
14
|
+
* message ids of the Turn start that ended the scan.
|
|
15
|
+
*/
|
|
16
|
+
async function selectTurnCards(conversationId, selection, beforeSeq) {
|
|
17
|
+
while (true) {
|
|
17
18
|
const page = await getConversationEventStore().query(conversationId, {
|
|
18
19
|
beforeSeq,
|
|
19
20
|
limit: 100,
|
|
@@ -25,20 +26,45 @@ async function loadPendingMessageCards(conversationId) {
|
|
|
25
26
|
});
|
|
26
27
|
for (const event of [...page.events].reverse()) {
|
|
27
28
|
const data = event.data;
|
|
28
|
-
if (data.type === "turn_started"
|
|
29
|
+
if (data.type === "turn_started") return data.inputMessageIds;
|
|
30
|
+
if (data.type === "message" && data.role === "assistant") return [];
|
|
29
31
|
if (data.type !== "tool_result" || data.isError || typeof data.toolName !== "string" || !isRecord(data.details)) continue;
|
|
30
32
|
if (data.details.timed_out === true) continue;
|
|
31
|
-
if (Array.isArray(data.details.removedCards)) for (const ref of removedCardSchema.array().parse(data.details.removedCards)) deleted.add(JSON.stringify([ref.plugin, ref.key]));
|
|
33
|
+
if (Array.isArray(data.details.removedCards)) for (const ref of removedCardSchema.array().parse(data.details.removedCards)) selection.deleted.add(JSON.stringify([ref.plugin, ref.key]));
|
|
32
34
|
for (const card of readMessageCardRefs(data.details)) {
|
|
33
35
|
const key = JSON.stringify([card.plugin, card.key]);
|
|
34
|
-
if (!deleted.has(key) && !cards.has(key)) cards.set(key, card);
|
|
36
|
+
if (!selection.deleted.has(key) && !selection.cards.has(key)) selection.cards.set(key, card);
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
|
-
if (!page.hasOlder || page.events.length === 0)
|
|
39
|
+
if (!page.hasOlder || page.events.length === 0) return [];
|
|
38
40
|
beforeSeq = page.events[0].seq;
|
|
39
41
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Add the cards of child agents whose results started this Turn. A child
|
|
45
|
+
* cannot reply to people, so its parent's reply delivers its cards.
|
|
46
|
+
*/
|
|
47
|
+
async function selectChildResultCards(inputMessageIds, selection) {
|
|
48
|
+
const events = getConversationEventStore();
|
|
49
|
+
for (const messageId of [...inputMessageIds].reverse()) {
|
|
50
|
+
const invocationId = parseAgentInvocationResultMessageId(messageId);
|
|
51
|
+
const invocation = invocationId ? await getAgentInvocation(invocationId) : void 0;
|
|
52
|
+
if (!invocation) continue;
|
|
53
|
+
const turnId = getAgentInvocationTurnId(invocation.invocationId);
|
|
54
|
+
const terminal = await events.loadByIdempotencyKey(invocation.childConversationId, `turn:${turnId}:terminal`);
|
|
55
|
+
if (!terminal) continue;
|
|
56
|
+
await selectTurnCards(invocation.childConversationId, selection, terminal.seq);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/** Select undelivered cards and load their latest saved facts. */
|
|
60
|
+
async function loadPendingMessageCards(conversationId) {
|
|
61
|
+
const selection = {
|
|
62
|
+
cards: /* @__PURE__ */ new Map(),
|
|
63
|
+
deleted: /* @__PURE__ */ new Set()
|
|
64
|
+
};
|
|
65
|
+
await selectChildResultCards(await selectTurnCards(conversationId, selection), selection);
|
|
66
|
+
if (selection.cards.size === 0) return [];
|
|
67
|
+
return resolveMessageCards([...selection.cards.values()].reverse(), await listConversationAnnotations(getDb(), conversationId));
|
|
42
68
|
}
|
|
43
69
|
// src/chat/interruption-marker.ts
|
|
44
70
|
const INTERRUPTED_MARKER = "\n\n[Response interrupted before completion]";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as getConversationEventStore } from "./viewer-
|
|
1
|
+
import { c as getConversationEventStore } from "./viewer-DmNRM88V.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 {
|
|
@@ -34,7 +34,7 @@ function slackSourceForDestination(args) {
|
|
|
34
34
|
* Reads parent Conversations when this Conversation has no Destination.
|
|
35
35
|
*/
|
|
36
36
|
async function resolveConversationRouting(args) {
|
|
37
|
-
const conversationStore = args.conversationStore ?? (await import("./viewer-
|
|
37
|
+
const conversationStore = args.conversationStore ?? (await import("./viewer-DmNRM88V.js").then((n) => n.s)).getConversationStore();
|
|
38
38
|
const chain = await loadConversationChain(args.conversationId, conversationStore);
|
|
39
39
|
let destination;
|
|
40
40
|
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-Suf-aLlh.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.263.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-BQX_hLDC.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
|
|
2
|
-
import { I as GOOGLE_IDENTITY_PROVIDER, R as normalizeIdentityEmail } from "./logging-
|
|
3
|
-
import { i as getChatConfig } from "./config-
|
|
2
|
+
import { I as GOOGLE_IDENTITY_PROVIDER, R as normalizeIdentityEmail } from "./logging-Dk_FpF36.js";
|
|
3
|
+
import { i as getChatConfig } from "./config-Dnv8KmNs.js";
|
|
4
4
|
import { d as parseSlackTeamId, o as parseActorUserId, u as parseSlackChannelReferenceId } from "./actor-tlxzqaRe.js";
|
|
5
|
-
import { c as juniorIdentities, d as juniorDestinations, l as juniorUsers, o as conversationReadColumns, s as juniorConversations } from "./agent-invocations-
|
|
6
|
-
import { _ as juniorConversationAnnotations, d as juniorConversationBindings, h as juniorConversationEvents, m as juniorConversationMetrics, p as CONVERSATION_METRICS, t as createJuniorSqlExecutor, u as juniorConversationParticipants } from "./executor-
|
|
5
|
+
import { c as juniorIdentities, d as juniorDestinations, l as juniorUsers, o as conversationReadColumns, s as juniorConversations } from "./agent-invocations-CxKldAeB.js";
|
|
6
|
+
import { _ as juniorConversationAnnotations, d as juniorConversationBindings, h as juniorConversationEvents, m as juniorConversationMetrics, p as CONVERSATION_METRICS, t as createJuniorSqlExecutor, u as juniorConversationParticipants } from "./executor-J9k2sp9m.js";
|
|
7
7
|
import { c as newConversationEventSchema, h as usageSchema, l as encodeHistoryPayload, o as decodeStoredConversationEvent, r as conversationEventDataSchema, s as historyReplacementSchema } from "./history-AY8rs-FR.js";
|
|
8
8
|
import { randomUUID } from "node:crypto";
|
|
9
9
|
import { and, asc, desc, eq, gt, gte, inArray, isNull, lt, lte, ne, or, sql } from "drizzle-orm";
|