@sentry/junior 0.224.0 → 0.226.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/{agent-hooks-DNLBwmsh.js → agent-hooks-FUetyyLe.js} +23 -16
- package/dist/{agent-runner-9g6TQk9y.js → agent-runner-DEF7auSj.js} +3114 -318
- package/dist/api/schema.d.ts +353 -10
- package/dist/api/schema.js +4 -4
- package/dist/api.js +22 -18
- package/dist/{app-BbSD6EtD.d.ts → app-TVL42pGL.d.ts} +1 -1
- package/dist/app.d.ts +1 -1
- package/dist/app.js +893 -7660
- package/dist/{briefs-CjXnGKzZ.js → briefs-Cb4T2BUI.js} +5 -5
- package/dist/{catalog-runtime-CVZ9TEuK.js → catalog-runtime-BYGR3Dr4.js} +1 -1
- package/dist/{checkpoint-Ceck_fLO.js → checkpoint-CJe-dZFF.js} +76 -10
- package/dist/cli/chat.js +13 -13
- package/dist/cli/check.js +3 -3
- package/dist/cli/main.js +1 -1
- package/dist/cli/plugins.js +3 -3
- package/dist/cli/snapshot-create.js +3 -3
- package/dist/cli/upgrade.js +3 -3
- package/dist/{client-B27ufhzl.js → client-C2WBBx7m.js} +2 -2
- package/dist/{config-BAhl7-RC.js → config-Bws6Rpsh.js} +11 -13
- package/dist/{conversation-1HUoZr2l.js → conversation-DPbmIwjy.js} +67 -6
- package/dist/{conversation-privacy-C-4JQzKD.js → conversation-privacy-pCcW0a5Y.js} +1 -1
- package/dist/{credential-sync-BXHIxbtS.js → credential-sync-ibuNsMyl.js} +14 -134
- package/dist/{executor-BG2Armby.js → executor-D36FWjcf.js} +1 -1
- package/dist/{history-yaSjGMD_.d.ts → history-DI9KJT3J.d.ts} +38 -1
- package/dist/instrumentation.js +2 -2
- package/dist/{vercel-queue-DIkVcfK4.js → job-queue-2mFFDMHB.js} +61 -2
- package/dist/{logging-iY0ssa2q.js → logging-CvjMHRvg.js} +2 -2
- package/dist/{model-profile-CZmVoGdX.js → model-profile-BwU8mqwD.js} +14 -1
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +3 -4
- package/dist/{oauth-authorization-BIijVS2N.js → oauth-authorization-l4O1rXsL.js} +1 -1
- package/dist/{oauth-callback-server-DPkK3kzi.js → oauth-callback-server-Ds8M5FFX.js} +2 -2
- package/dist/pending-auth-DLNJbD8H.js +59 -0
- package/dist/{profile-6KWhg_-U.js → profile-dvV7PB7u.js} +4 -4
- package/dist/{prompt-90miy8VV.js → prompt-DehgjkO5.js} +1 -1
- package/dist/{registry-Ctgdjt-W.js → registry-C6FHctIu.js} +3 -3
- package/dist/{resolve-CB45ZukQ.js → resolve-DqwGI9wq.js} +2 -2
- package/dist/{runner-BwKCqoF3.js → runner-CzYEcB73.js} +9 -9
- package/dist/{sandbox-egress-signals-Cmy8ODat.js → sandbox-egress-signals-BZOv0fns.js} +1 -1
- package/dist/{schema-RpbW5Od2.js → schema-BZg-xzfG.js} +2 -2
- package/dist/{skills-c2bMDVRS.js → skills-EhiVbjF4.js} +2 -2
- package/dist/{spawn-Cg6lyjE7.js → spawn-Ck3L0rEr.js} +2 -2
- package/dist/{task-queue-SL4uLfBB.js → task-queue-TXhAWQwj.js} +3 -4
- package/dist/{task-runner-fntmnqzx.js → task-runner-axUJS1No.js} +380 -11
- package/dist/{thread-state-Wfr0GdKS.js → thread-state-CTuWhjru.js} +5 -5
- package/dist/{turn-failure-response-DLjSEm-R.js → turn-failure-response-csVoLOzx.js} +8 -9
- package/dist/{turn-lifecycle-5_jvLqRz.js → turn-lifecycle-C1S6vELh.js} +1 -1
- package/dist/{turn-session-routing-CQaysLoe.js → turn-session-routing-5RejBvit.js} +1 -1
- package/dist/{validation-CnZkCN7o.js → validation-q2PFxkTQ.js} +1 -1
- package/dist/{version-C6lA-h_o.js → version-ByLtIYyy.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/web-authorization-Biy8nsS7.js +162 -0
- package/dist/web-input-DM9LaEdn.js +7774 -0
- package/dist/{reporting-window-DbUqng0P.js → web-message-id-xPI_EFSC.js} +11 -1
- package/dist/{work-4Nhz9mVv.js → work-QrbHdXTc.js} +7 -8
- package/dist/{worker-CdWPsNL2.js → worker-r17aopXW.js} +5 -6
- package/package.json +4 -4
- package/dist/execution-stats-DikPOxJ1.js +0 -373
- package/dist/job-queue-D4oAVrL9.js +0 -63
- package/dist/short-title-xEkZwkcV.js +0 -65
- package/dist/stats-DP9zl3Jg.js +0 -2758
- package/dist/web-authorization-Bbx999_q.js +0 -38
- package/dist/web-input-BoE1xE-K.js +0 -899
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { r as completeObject } from "./client-
|
|
2
|
-
import {
|
|
3
|
-
import { P as briefCodeChangeSchema, R as parseBriefInput, d as conversationDetailReportSchema, p as conversationEventPageSchema } from "./conversation-
|
|
4
|
-
import { n as briefEntriesFromReportEvents, s as generateBrief, t as BRIEF_PROMPT } from "./prompt-
|
|
1
|
+
import { r as completeObject } from "./client-C2WBBx7m.js";
|
|
2
|
+
import { r as defaultModelId } from "./model-profile-BwU8mqwD.js";
|
|
3
|
+
import { P as briefCodeChangeSchema, R as parseBriefInput, d as conversationDetailReportSchema, p as conversationEventPageSchema } from "./conversation-DPbmIwjy.js";
|
|
4
|
+
import { n as briefEntriesFromReportEvents, s as generateBrief, t as BRIEF_PROMPT } from "./prompt-DehgjkO5.js";
|
|
5
5
|
import { CLI_USAGE } from "./cli/run.js";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { z } from "zod";
|
|
@@ -269,7 +269,7 @@ async function parseRunOptions(argv) {
|
|
|
269
269
|
* `DATABASE_URL` at import, and `briefs pull` must work with only a token.
|
|
270
270
|
*/
|
|
271
271
|
async function configuredDefaultModelId() {
|
|
272
|
-
const { botConfig } = await import("./config-
|
|
272
|
+
const { botConfig } = await import("./config-Bws6Rpsh.js").then((n) => n.r);
|
|
273
273
|
return defaultModelId(botConfig);
|
|
274
274
|
}
|
|
275
275
|
function apiUrl(baseUrl, pathname) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
|
|
2
|
-
import { t as createPluginCatalogRuntime } from "./registry-
|
|
2
|
+
import { t as createPluginCatalogRuntime } from "./registry-C6FHctIu.js";
|
|
3
3
|
//#region src/chat/plugins/catalog-runtime.ts
|
|
4
4
|
var catalog_runtime_exports = /* @__PURE__ */ __exportAll({ pluginCatalogRuntime: () => pluginCatalogRuntime });
|
|
5
5
|
const pluginCatalogRuntime = createPluginCatalogRuntime();
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { i as completeText, m as escapeXml, o as resolveGatewayModel, p as unwrapCurrentInstruction } from "./client-
|
|
2
|
-
import {
|
|
3
|
-
import { n as botConfig } from "./config-
|
|
1
|
+
import { i as completeText, m as escapeXml, o as resolveGatewayModel, p as unwrapCurrentInstruction } from "./client-C2WBBx7m.js";
|
|
2
|
+
import { d as logException, o as getActiveTraceId, p as logWarn, t as buildTurnFailureResponse, v as setSpanAttributes } from "./logging-CvjMHRvg.js";
|
|
3
|
+
import { n as botConfig } from "./config-Bws6Rpsh.js";
|
|
4
4
|
import { _ as parseSlackMessageTs, f as toStoredSlackActor } from "./context-Bplcgypl.js";
|
|
5
|
-
import { Bt as agentsInstructionsUpdatedEvent, Ht as authenticationUnlinkedEvent, Jt as getSqlExecutor, Kt as getConversationStore, Vt as authenticationLinkedEvent, Wt as getConversationEventStore, Xt as withConversationEventLock, Yt as createSqlConversationEventStore,
|
|
6
|
-
import { B as agentHistoryItemSchema, J as
|
|
7
|
-
import {
|
|
8
|
-
import { D as fenceLock, O as withLock, T as MUTATION_LOCK_TTL_MS, k as sleep, w as getStateAdapter } from "./profile-6KWhg_-U.js";
|
|
5
|
+
import { $t as bindProviderConversation, Bt as agentsInstructionsUpdatedEvent, Ht as authenticationUnlinkedEvent, Jt as getSqlExecutor, Kt as getConversationStore, Vt as authenticationLinkedEvent, Wt as getConversationEventStore, Xt as withConversationEventLock, Yt as createSqlConversationEventStore, tn as addAgentTurnUsage, zt as JUNIOR_NATIVE_EVENT_NAMESPACE } from "./agent-hooks-FUetyyLe.js";
|
|
6
|
+
import { B as agentHistoryItemSchema, J as contextProvenance, X as instructionProvenanceFor, Y as instructionActors } from "./conversation-DPbmIwjy.js";
|
|
7
|
+
import { D as fenceLock, O as withLock, T as MUTATION_LOCK_TTL_MS, k as sleep, w as getStateAdapter } from "./profile-dvV7PB7u.js";
|
|
9
8
|
import { isDeepStrictEqual } from "node:util";
|
|
10
9
|
import { z } from "zod";
|
|
11
10
|
import { createHash } from "node:crypto";
|
|
@@ -440,6 +439,73 @@ function isHumanConversationMessage(message) {
|
|
|
440
439
|
function getConversationMessageSlackTs(message) {
|
|
441
440
|
return parseSlackMessageTs(message.meta?.slackTs);
|
|
442
441
|
}
|
|
442
|
+
const TITLE_PROMPTS = {
|
|
443
|
+
conversation: [
|
|
444
|
+
"Generate a concise 5-8 word conversation title from the first user message below.",
|
|
445
|
+
"Capture the user's main request.",
|
|
446
|
+
"Reply with ONLY the title, with no quotes or trailing punctuation."
|
|
447
|
+
],
|
|
448
|
+
task: [
|
|
449
|
+
"Generate a concise 5-8 word task title from the task instruction below.",
|
|
450
|
+
"Capture the task's main purpose.",
|
|
451
|
+
"Reply with ONLY the title, with no quotes or trailing punctuation."
|
|
452
|
+
]
|
|
453
|
+
};
|
|
454
|
+
/** Collapse whitespace and cap a candidate short title. */
|
|
455
|
+
function normalizeShortTitle(value) {
|
|
456
|
+
return value.replace(/\s+/g, " ").trim().slice(0, 60);
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Deterministic display title when no generated title is stored.
|
|
460
|
+
* Uses the first non-empty line of the source text, capped like generated titles.
|
|
461
|
+
*/
|
|
462
|
+
function fallbackShortTitle(sourceText, fallback = "Untitled") {
|
|
463
|
+
return normalizeShortTitle(sourceText.split(/\r?\n/).map((line) => line.trim()).find((line) => line.length > 0) ?? "") || fallback;
|
|
464
|
+
}
|
|
465
|
+
/** Generate a short title with the fast model, or return undefined on failure. */
|
|
466
|
+
async function generateShortTitle(args) {
|
|
467
|
+
args.signal?.throwIfAborted();
|
|
468
|
+
const sourceText = args.sourceText.trim();
|
|
469
|
+
if (!sourceText) return void 0;
|
|
470
|
+
try {
|
|
471
|
+
const result = await args.completeText({
|
|
472
|
+
signal: args.signal,
|
|
473
|
+
modelId: botConfig.fastModelId,
|
|
474
|
+
temperature: 0,
|
|
475
|
+
promptName: `junior.${args.kind}_title`,
|
|
476
|
+
messages: [{
|
|
477
|
+
role: "user",
|
|
478
|
+
content: [
|
|
479
|
+
...TITLE_PROMPTS[args.kind],
|
|
480
|
+
"",
|
|
481
|
+
args.kind === "conversation" ? `First user message: ${sourceText.slice(0, 500)}` : `Task instruction: ${sourceText.slice(0, 500)}`
|
|
482
|
+
].join("\n"),
|
|
483
|
+
timestamp: Date.now()
|
|
484
|
+
}],
|
|
485
|
+
metadata: { modelId: botConfig.fastModelId }
|
|
486
|
+
});
|
|
487
|
+
args.signal?.throwIfAborted();
|
|
488
|
+
return normalizeShortTitle(result.text) || void 0;
|
|
489
|
+
} catch (error) {
|
|
490
|
+
args.signal?.throwIfAborted();
|
|
491
|
+
logWarn(`${args.kind}.title.generation.failed`, { "exception.message": error instanceof Error ? error.message : String(error) });
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Prefer an explicit task title when provided; otherwise generate one from the
|
|
497
|
+
* instruction with the fast model.
|
|
498
|
+
*/
|
|
499
|
+
async function resolveTaskTitle(args) {
|
|
500
|
+
const explicit = normalizeShortTitle(args.title ?? "");
|
|
501
|
+
if (explicit) return explicit;
|
|
502
|
+
return generateShortTitle({
|
|
503
|
+
completeText: args.completeText,
|
|
504
|
+
kind: "task",
|
|
505
|
+
sourceText: args.instruction,
|
|
506
|
+
signal: args.signal
|
|
507
|
+
});
|
|
508
|
+
}
|
|
443
509
|
//#endregion
|
|
444
510
|
//#region src/chat/services/conversation-title.ts
|
|
445
511
|
const inFlightTitles = /* @__PURE__ */ new Map();
|
|
@@ -735,9 +801,9 @@ var AgentHistoryBranchError = class extends Error {
|
|
|
735
801
|
this.name = "AgentHistoryBranchError";
|
|
736
802
|
}
|
|
737
803
|
};
|
|
738
|
-
/**
|
|
804
|
+
/** Snapshot Pi's JSON message without changing text or nested object order. */
|
|
739
805
|
function normalizeDurableMessage(message) {
|
|
740
|
-
return piMessageSchema.parse(JSON.parse(JSON.stringify(
|
|
806
|
+
return piMessageSchema.parse(JSON.parse(JSON.stringify(message)));
|
|
741
807
|
}
|
|
742
808
|
/**
|
|
743
809
|
* Identity used for append-only prefix checks.
|
|
@@ -2075,4 +2141,4 @@ async function saveDone(args) {
|
|
|
2075
2141
|
});
|
|
2076
2142
|
}
|
|
2077
2143
|
//#endregion
|
|
2078
|
-
export {
|
|
2144
|
+
export { fallbackShortTitle as $, commitAcceptedReply as A, recordAuthorizationCompleted as B, isToolResultError as C, stripRuntimeTurnContext as D, retainRuntimeTurnContext as E, loadTurnRoute as F, recordToolExecutionStarted as G, recordGuardianActionReviewed as H, openConversationProjection as I, hydrateConversationMessages as J, recordTurnRoute as K, recordAgentsInstructionsUpdated as L, loadConnectedMcpProviders as M, loadConversationProjection as N, trimTrailingAssistantMessages as O, loadProjection as P, resolveConversationTitle as Q, recordAttachmentsDelivered as R, isContinuablePiBoundary as S, normalizeToolNameFromResult as T, recordMcpProviderConnected as U, recordAuthorizationRequested as V, recordSubscribedReplyRoute as W, projectConversationMessages as X, persistConversationMessages as Y, persistConversationMessageSummaries as Z, getTerminalAssistantMessages as _, piMessageFromHistoryItem as _t, completeTurnRecord as a, estimateConversationContextTokens as at, instructionTextForProjection as b, listTurnSummaries as c, markConversationMessage as ct, TurnSliceLimitExceededError as d, turnHasReply as dt, generateShortTitle as et, assertTurnToolCallLimit as f, upsertConversationMessage as ft, getPiMessageRole as g, historyItemFromPiMessage as gt, extractAssistantText as h, getAgentContextInputLimitTokens as ht, abandonTurnRecord as i, createConversationMemoryService as it, commitMessages as j, TURN_CONTEXT_TAG as k, recordTurnSummary as l, normalizeConversationText as lt, isTurnExecutionLimitExceededError as m, getAgentContextCompactionTriggerTokens as mt, loadTurnCheckpoint as n, appendThreadContextMessages as nt, failTurnRecord as o, getConversationMessageSlackTs as ot, buildTurnErrorResponse as p, estimateTextTokens as pt, appendConversationMessages as q, saveTurnCheckpoint as r, buildConversationContext as rt, getTurnRecord as s, isHumanConversationMessage as st, continuableMessages as t, resolveTaskTitle as tt, persistWithRetry as u, recordDeliveredAssistantMessage as ut, getUserMessageInstructionText as v, isToolResultMessage as w, isAssistantMessage as x, hasRuntimeTurnContext as y, recordAuthenticationLinked as z };
|
package/dist/cli/chat.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as executeAgentRun, t as createAgentRunner } from "../agent-runner-
|
|
1
|
+
import { s as executeAgentRun, t as createAgentRunner } from "../agent-runner-DEF7auSj.js";
|
|
2
2
|
import { t as loadAppPluginSet } from "../plugin-module-BKGOXca2.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -100,10 +100,10 @@ async function loadLocalPluginSet() {
|
|
|
100
100
|
async function configureLocalChatPlugins(pluginSet) {
|
|
101
101
|
const [pluginsModule, agentHooksModule, catalogRuntimeModule, validationModule, databaseModule] = await Promise.all([
|
|
102
102
|
import("../plugins-egKWjgue.js").then((n) => n.o),
|
|
103
|
-
import("../agent-hooks-
|
|
104
|
-
import("../catalog-runtime-
|
|
105
|
-
import("../validation-
|
|
106
|
-
import("../agent-hooks-
|
|
103
|
+
import("../agent-hooks-FUetyyLe.js").then((n) => n.t),
|
|
104
|
+
import("../catalog-runtime-BYGR3Dr4.js").then((n) => n.t),
|
|
105
|
+
import("../validation-q2PFxkTQ.js").then((n) => n.r),
|
|
106
|
+
import("../agent-hooks-FUetyyLe.js").then((n) => n.Ut)
|
|
107
107
|
]);
|
|
108
108
|
const resolvedPluginSet = pluginSet === void 0 ? await loadLocalPluginSet() : pluginSet ?? void 0;
|
|
109
109
|
const plugins = pluginsModule.pluginRuntimeRegistrationsFromPluginSet(resolvedPluginSet);
|
|
@@ -153,18 +153,18 @@ function localDevServerUrl() {
|
|
|
153
153
|
async function prepareLocalChatRun(io, pluginSet) {
|
|
154
154
|
defaultStateAdapterForLocalChat();
|
|
155
155
|
await configureLocalChatPlugins(pluginSet);
|
|
156
|
-
const { setExperimentalFeatures } = await import("../agent-runner-
|
|
156
|
+
const { setExperimentalFeatures } = await import("../agent-runner-DEF7auSj.js").then((n) => n.r);
|
|
157
157
|
setExperimentalFeatures({ subagents: true });
|
|
158
|
-
const { setBriefsConfig } = await import("../agent-hooks-
|
|
158
|
+
const { setBriefsConfig } = await import("../agent-hooks-FUetyyLe.js").then((n) => n.m);
|
|
159
159
|
setBriefsConfig({ enabled: true });
|
|
160
|
-
const { runLocalAgentTurn } = await import("../runner-
|
|
161
|
-
const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-
|
|
160
|
+
const { runLocalAgentTurn } = await import("../runner-CzYEcB73.js");
|
|
161
|
+
const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-Ds8M5FFX.js");
|
|
162
162
|
const { createLocalOAuthState } = await import("../oauth-relay-CdCnu80W.js").then((n) => n.t);
|
|
163
|
-
const { createLocalSandboxEgressSignalTransport } = await import("../sandbox-egress-signals-
|
|
164
|
-
const { bindSpawnAgent } = await import("../spawn-
|
|
165
|
-
const { createAgentInvocationWorker, routeAgentInvocationWork } = await import("../work-
|
|
163
|
+
const { createLocalSandboxEgressSignalTransport } = await import("../sandbox-egress-signals-BZOv0fns.js");
|
|
164
|
+
const { bindSpawnAgent } = await import("../spawn-Ck3L0rEr.js").then((n) => n.n);
|
|
165
|
+
const { createAgentInvocationWorker, routeAgentInvocationWork } = await import("../work-QrbHdXTc.js").then((n) => n.a);
|
|
166
166
|
const { createLocalConversationWork } = await import("../conversation-work-C6y3T5Hx.js");
|
|
167
|
-
const { processConversationWork } = await import("../worker-
|
|
167
|
+
const { processConversationWork } = await import("../worker-r17aopXW.js").then((n) => n.n);
|
|
168
168
|
let agentRunner;
|
|
169
169
|
const localConversationWork = createLocalConversationWork(async (message) => {
|
|
170
170
|
if (!agentRunner) throw new Error("Local agent runner is not ready");
|
package/dist/cli/check.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { f as parseInlinePluginManifest, p as parsePluginManifest } from "../registry-
|
|
3
|
-
import { i as parseSkillFile } from "../skills-
|
|
1
|
+
import { D as JUNIOR_HEARTBEAT_ROUTE, M as LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION, T as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE } from "../logging-CvjMHRvg.js";
|
|
2
|
+
import { f as parseInlinePluginManifest, p as parsePluginManifest } from "../registry-C6FHctIu.js";
|
|
3
|
+
import { i as parseSkillFile } from "../skills-EhiVbjF4.js";
|
|
4
4
|
import { pathToFileURL } from "node:url";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import fs from "node:fs/promises";
|
package/dist/cli/main.js
CHANGED
|
@@ -25,7 +25,7 @@ async function runChat(argv, pluginSet) {
|
|
|
25
25
|
return await (await import("./chat.js")).runChat(argv, void 0, { pluginSet });
|
|
26
26
|
}
|
|
27
27
|
async function runBriefs(argv) {
|
|
28
|
-
return await (await import("../briefs-
|
|
28
|
+
return await (await import("../briefs-Cb4T2BUI.js")).runBriefs(argv);
|
|
29
29
|
}
|
|
30
30
|
function topLevelCommand(argv) {
|
|
31
31
|
return (argv[0] === "--" ? argv.slice(1) : argv)[0];
|
package/dist/cli/plugins.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { bt as createPluginLogger, d as setPlugins, f as validatePlugins, qt as getDb } from "../agent-hooks-
|
|
2
|
-
import { n as pluginCatalogRuntime } from "../catalog-runtime-
|
|
3
|
-
import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "../validation-
|
|
1
|
+
import { bt as createPluginLogger, d as setPlugins, f as validatePlugins, qt as getDb } from "../agent-hooks-FUetyyLe.js";
|
|
2
|
+
import { n as pluginCatalogRuntime } from "../catalog-runtime-BYGR3Dr4.js";
|
|
3
|
+
import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "../validation-q2PFxkTQ.js";
|
|
4
4
|
import { a as pluginRuntimeRegistrationsFromPluginSet, i as pluginCliRegistrationsFromPluginSet, r as pluginCatalogConfigFromPluginSet } from "../plugins-egKWjgue.js";
|
|
5
5
|
import { t as loadAppPluginSet } from "../plugin-module-BKGOXca2.js";
|
|
6
6
|
import { stderr, stdout } from "node:process";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as pluginCatalogRuntime } from "../catalog-runtime-
|
|
2
|
-
import { S as disconnectStateAdapter, t as create } from "../profile-
|
|
3
|
-
import { r as resolve } from "../resolve-
|
|
1
|
+
import { n as pluginCatalogRuntime } from "../catalog-runtime-BYGR3Dr4.js";
|
|
2
|
+
import { S as disconnectStateAdapter, t as create } from "../profile-dvV7PB7u.js";
|
|
3
|
+
import { r as resolve } from "../resolve-DqwGI9wq.js";
|
|
4
4
|
//#region src/cli/snapshot-create.ts
|
|
5
5
|
const DEFAULT_RUNTIME = "node22";
|
|
6
6
|
const DEFAULT_TIMEOUT_MS = 6e5;
|
package/dist/cli/upgrade.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as getChatConfig } from "../config-
|
|
2
|
-
import { t as createJuniorSqlExecutor } from "../executor-
|
|
3
|
-
import { t as createPluginCatalogRuntime } from "../registry-
|
|
1
|
+
import { a as getChatConfig } from "../config-Bws6Rpsh.js";
|
|
2
|
+
import { t as createJuniorSqlExecutor } from "../executor-D36FWjcf.js";
|
|
3
|
+
import { t as createPluginCatalogRuntime } from "../registry-C6FHctIu.js";
|
|
4
4
|
import { n as pluginCatalogConfigFromEnv, r as pluginCatalogConfigFromPluginSet, t as defineJuniorPlugins } from "../plugins-egKWjgue.js";
|
|
5
5
|
import { t as loadAppPluginSet } from "../plugin-module-BKGOXca2.js";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as toCanonicalInputMessage, n as getCurrentConversationPrivacy, o as toCanonicalOutputMessage, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-
|
|
1
|
+
import { d as logException, g as serializeGenAiAttribute, i as extractGenAiUsageAttributes, m as normalizeGenAiFinishReason, p as logWarn, w as withSpan } from "./logging-CvjMHRvg.js";
|
|
2
|
+
import { a as toCanonicalInputMessage, n as getCurrentConversationPrivacy, o as toCanonicalOutputMessage, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-pCcW0a5Y.js";
|
|
3
3
|
import { calculateCost, completeSimple, getEnvApiKey, getModels, registerApiProvider } from "@earendil-works/pi-ai/compat";
|
|
4
4
|
import { stream as streamAnthropic, streamSimple as streamSimpleAnthropic } from "@earendil-works/pi-ai/api/anthropic-messages";
|
|
5
5
|
import { createGatewayProvider } from "@ai-sdk/gateway";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
|
|
2
|
-
import { o as resolveGatewayModel, w as toOptionalTrimmed } from "./client-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { o as resolveGatewayModel, w as toOptionalTrimmed } from "./client-C2WBBx7m.js";
|
|
3
|
+
import { p as logWarn } from "./logging-CvjMHRvg.js";
|
|
4
|
+
import { l as TURN_REASONING_LEVELS, s as modelProfileSchema, t as DEFAULT_MODEL_PROFILES, u as parseTurnReasoningLevel } from "./model-profile-BwU8mqwD.js";
|
|
5
5
|
//#region src/chat/slack/emoji.ts
|
|
6
6
|
const SLACK_EMOJI_NAME_RE = /^(?:[a-z0-9_+-]+)(?:::(?:skin-tone-[2-6]))?$/;
|
|
7
7
|
function normalizeSlackEmojiName(value) {
|
|
@@ -124,13 +124,14 @@ function parseCrossActorMidRunMode(rawValue) {
|
|
|
124
124
|
if (value === "follow_up" || value === "steer") return value;
|
|
125
125
|
throw new Error("JUNIOR_CROSS_ACTOR_MID_RUN_MODE must be follow_up or steer");
|
|
126
126
|
}
|
|
127
|
-
const DEFAULT_MODEL_ID =
|
|
127
|
+
const DEFAULT_MODEL_ID = resolveGatewayModel(DEFAULT_MODEL_PROFILES.standard.modelId).id;
|
|
128
128
|
const DEFAULT_FAST_MODEL_ID = resolveGatewayModel("openai/gpt-6-luna").id;
|
|
129
129
|
const DEFAULT_GUARDIAN_MODEL_ID = resolveGatewayModel("openai/gpt-6-luna").id;
|
|
130
|
-
const DEFAULT_HANDOFF_MODEL_ID = resolveGatewayModel(
|
|
130
|
+
const DEFAULT_HANDOFF_MODEL_ID = resolveGatewayModel(DEFAULT_MODEL_PROFILES.handoff.modelId).id;
|
|
131
131
|
const DEFAULT_WEB_SEARCH_MODEL_ID = resolveGatewayModel("openai/gpt-6-luna").id;
|
|
132
132
|
const DEFAULT_EMBEDDING_MODEL_ID = "openai/text-embedding-3-small";
|
|
133
133
|
const DEFAULT_IMAGE_GENERATION_MODEL_ID = "google/gemini-3-pro-image";
|
|
134
|
+
const DEFAULT_VISION_MODEL_ID = resolveGatewayModel("openai/gpt-5.6-sol").id;
|
|
134
135
|
function validateGatewayModelId(raw) {
|
|
135
136
|
const trimmed = toOptionalTrimmed(raw);
|
|
136
137
|
if (trimmed === void 0) return void 0;
|
|
@@ -145,8 +146,6 @@ function requireModelId(configName, raw, validate) {
|
|
|
145
146
|
if (!modelId) throw new Error(`${configName} must not be empty`);
|
|
146
147
|
return modelId;
|
|
147
148
|
}
|
|
148
|
-
const DEFAULT_STANDARD_PROFILE_DESCRIPTION = "Use for default assistant work: lookups, explanations, ordinary tool use, short answers, and light investigation of one source. Avoid for implementation, debugging, multi-file changes, architecture decisions, or research across several systems.";
|
|
149
|
-
const DEFAULT_HANDOFF_PROFILE_DESCRIPTION = "Use for coding and difficult multi-step work: implementation, debugging, root-cause analysis, broad refactors, multi-file changes, architecture decisions, and research across several systems. Avoid for simple lookups, short answers, single-file reads, or ordinary tool use that the default profile can finish.";
|
|
150
149
|
function parseOptionalProfileDescription(rawDescription, configName, profile) {
|
|
151
150
|
if (rawDescription === void 0) return;
|
|
152
151
|
if (typeof rawDescription !== "string") throw new Error(`${configName}.${profile}.description must be a string when set`);
|
|
@@ -193,13 +192,12 @@ function parseProfileMap(rawProfiles, configName) {
|
|
|
193
192
|
function parseProfiles(rawValue, standardModelId, handoffModelId) {
|
|
194
193
|
const profiles = {
|
|
195
194
|
standard: {
|
|
196
|
-
|
|
197
|
-
|
|
195
|
+
...DEFAULT_MODEL_PROFILES.standard,
|
|
196
|
+
modelId: standardModelId
|
|
198
197
|
},
|
|
199
198
|
handoff: {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
reasoningLevel: "high"
|
|
199
|
+
...DEFAULT_MODEL_PROFILES.handoff,
|
|
200
|
+
modelId: handoffModelId
|
|
203
201
|
}
|
|
204
202
|
};
|
|
205
203
|
const trimmed = toOptionalTrimmed(rawValue);
|
|
@@ -252,7 +250,7 @@ function readBotConfig(env, functionMaxDurationSeconds) {
|
|
|
252
250
|
imageGenerationModelId: toOptionalTrimmed(env.AI_IMAGE_MODEL) ?? DEFAULT_IMAGE_GENERATION_MODEL_ID,
|
|
253
251
|
embeddingModelId: validateEmbeddingModelId(env.AI_EMBEDDING_MODEL) ?? DEFAULT_EMBEDDING_MODEL_ID,
|
|
254
252
|
loadingMessages: parseLoadingMessages(env.JUNIOR_LOADING_MESSAGES),
|
|
255
|
-
visionModelId: validateGatewayModelId(env.AI_VISION_MODEL),
|
|
253
|
+
visionModelId: env.AI_VISION_MODEL === void 0 ? DEFAULT_VISION_MODEL_ID : validateGatewayModelId(env.AI_VISION_MODEL),
|
|
256
254
|
maxSlicesPerTurn: MAX_SLICES_PER_TURN,
|
|
257
255
|
maxToolCallsPerTurn: MAX_TOOL_CALLS_PER_TURN,
|
|
258
256
|
maxConsecutiveAutomatedTurns: MAX_CONSECUTIVE_AUTOMATED_TURNS,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { l as TURN_REASONING_LEVELS, s as modelProfileSchema } from "./model-profile-BwU8mqwD.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { actorSchema, codeChangeStateSchema, conversationAnnotationInputSchema, conversationEventPresentationSchema, conversationSidebarAnnotationSchema, ownedObjectAnnotationSchema } from "@sentry/junior-plugin-api";
|
|
3
|
+
import { actorSchema, codeChangeStateSchema, conversationAnnotationInputSchema, conversationEventPresentationSchema, conversationSidebarAnnotationSchema, objectFactFields, ownedObjectAnnotationSchema } from "@sentry/junior-plugin-api";
|
|
4
4
|
//#region src/usage-schema.ts
|
|
5
5
|
const usageCostSchema = z.object({
|
|
6
6
|
input: z.number().finite().nonnegative().optional(),
|
|
@@ -64,6 +64,58 @@ function instructionActors(provenance) {
|
|
|
64
64
|
return actors;
|
|
65
65
|
}
|
|
66
66
|
//#endregion
|
|
67
|
+
//#region src/chat/conversations/history-payload.ts
|
|
68
|
+
const messageFieldsSchema = z.record(z.string(), z.unknown());
|
|
69
|
+
const replacementEntrySchema = z.object({ item: z.string() }).passthrough();
|
|
70
|
+
/** Identify history events that store message fields as JSON strings. */
|
|
71
|
+
function isEncodedHistoryType(type) {
|
|
72
|
+
return type === "user_message" || type === "assistant_message" || type === "tool_result" || type === "handoff" || type === "compaction";
|
|
73
|
+
}
|
|
74
|
+
/** Encode agent history before SQL can change keys or string contents. */
|
|
75
|
+
function encodeHistoryPayload(data) {
|
|
76
|
+
const { type, ...payload } = data;
|
|
77
|
+
if (!isEncodedHistoryType(type)) return {
|
|
78
|
+
schemaVersion: 1,
|
|
79
|
+
payload
|
|
80
|
+
};
|
|
81
|
+
if (data.type === "handoff" || data.type === "compaction") return {
|
|
82
|
+
schemaVersion: 2,
|
|
83
|
+
payload: {
|
|
84
|
+
...payload,
|
|
85
|
+
replacementHistory: data.replacementHistory.map(({ item, ...entry }) => ({
|
|
86
|
+
...entry,
|
|
87
|
+
item: JSON.stringify(item)
|
|
88
|
+
}))
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const { provenance, ...message } = payload;
|
|
92
|
+
return {
|
|
93
|
+
schemaVersion: 2,
|
|
94
|
+
payload: {
|
|
95
|
+
message: JSON.stringify(message),
|
|
96
|
+
provenance,
|
|
97
|
+
model: message.model,
|
|
98
|
+
provider: message.provider,
|
|
99
|
+
usage: message.usage,
|
|
100
|
+
toolCallId: message.toolCallId
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/** Decode stored history for validation by the conversation event schema. */
|
|
105
|
+
function decodeHistoryPayload(type, payload) {
|
|
106
|
+
const fields = messageFieldsSchema.parse(payload);
|
|
107
|
+
if (type === "handoff" || type === "compaction") return {
|
|
108
|
+
...fields,
|
|
109
|
+
replacementHistory: z.array(replacementEntrySchema).parse(fields.replacementHistory).map(({ item, ...entry }) => ({
|
|
110
|
+
...entry,
|
|
111
|
+
item: JSON.parse(item)
|
|
112
|
+
}))
|
|
113
|
+
};
|
|
114
|
+
const message = messageFieldsSchema.parse(JSON.parse(z.string().parse(fields.message)));
|
|
115
|
+
if (fields.provenance !== void 0) message.provenance = fields.provenance;
|
|
116
|
+
return message;
|
|
117
|
+
}
|
|
118
|
+
//#endregion
|
|
67
119
|
//#region src/chat/conversations/history.ts
|
|
68
120
|
/**
|
|
69
121
|
* Durable conversation event history port.
|
|
@@ -413,9 +465,9 @@ const conversationEventEnvelopeSchema = z.object({
|
|
|
413
465
|
* `schemaVersion` is persisted with every physical event row.
|
|
414
466
|
*/
|
|
415
467
|
const conversationEventSchema = z.union([conversationEventEnvelopeSchema.extend({
|
|
416
|
-
schemaVersion: z.literal(1),
|
|
468
|
+
schemaVersion: z.union([z.literal(1), z.literal(2)]),
|
|
417
469
|
data: conversationEventDataSchema
|
|
418
|
-
}), conversationEventEnvelopeSchema.extend({ data: unknownConversationEventDataSchema })]);
|
|
470
|
+
}).refine((event) => event.schemaVersion === 1 || isEncodedHistoryType(event.data.type)), conversationEventEnvelopeSchema.extend({ data: unknownConversationEventDataSchema })]);
|
|
419
471
|
const storedConversationEventSchema = conversationEventEnvelopeSchema.extend({
|
|
420
472
|
type: z.string().min(1),
|
|
421
473
|
payload: z.unknown()
|
|
@@ -423,13 +475,20 @@ const storedConversationEventSchema = conversationEventEnvelopeSchema.extend({
|
|
|
423
475
|
/**
|
|
424
476
|
* Decode a physical event row without making old or future event types
|
|
425
477
|
* unreadable. Unsupported rows stay opaque until an upgrade migration defines
|
|
426
|
-
* their semantics;
|
|
478
|
+
* their semantics; supported events remain strict so corrupt canonical
|
|
427
479
|
* data cannot be mistaken for compatibility data.
|
|
428
480
|
*/
|
|
429
481
|
function decodeStoredConversationEvent(value) {
|
|
430
482
|
const stored = storedConversationEventSchema.parse(value);
|
|
431
483
|
const { type, payload, ...envelope } = stored;
|
|
432
484
|
const knownType = knownConversationEventTypeSchema.safeParse(type).success;
|
|
485
|
+
if (stored.schemaVersion === 2 && isEncodedHistoryType(type)) return conversationEventSchema.parse({
|
|
486
|
+
...envelope,
|
|
487
|
+
data: {
|
|
488
|
+
...decodeHistoryPayload(type, payload),
|
|
489
|
+
type
|
|
490
|
+
}
|
|
491
|
+
});
|
|
433
492
|
if (stored.schemaVersion === 1 && knownType) {
|
|
434
493
|
const data = typeof payload === "object" && payload !== null && !Array.isArray(payload) ? {
|
|
435
494
|
...payload,
|
|
@@ -617,6 +676,8 @@ function messageCardText(card) {
|
|
|
617
676
|
card.label !== card.title ? card.label : void 0,
|
|
618
677
|
card.description,
|
|
619
678
|
card.status,
|
|
679
|
+
...objectFactFields(card.facts).map((field) => `${field.label}: ${field.value}`),
|
|
680
|
+
card.sourceUpdatedAt ? `Source updated: ${card.sourceUpdatedAt}` : void 0,
|
|
620
681
|
card.trigger,
|
|
621
682
|
card.warning,
|
|
622
683
|
card.url
|
|
@@ -1233,4 +1294,4 @@ const conversationStatsReportSchema = z.object({
|
|
|
1233
1294
|
windowStart: z.string()
|
|
1234
1295
|
}).strict();
|
|
1235
1296
|
//#endregion
|
|
1236
|
-
export { messageCardKey as A, agentHistoryItemSchema as B, conversationReportEventSchema as C, createConversationBodySchema as D, conversationSummaryReportSchema as E, briefLinkSchema as F, historyReplacementSchema as G, conversationTurnFailureCodeSchema as H, briefOutcomeStatusSchema as I,
|
|
1297
|
+
export { messageCardKey as A, agentHistoryItemSchema as B, conversationReportEventSchema as C, createConversationBodySchema as D, conversationSummaryReportSchema as E, briefLinkSchema as F, historyReplacementSchema as G, conversationTurnFailureCodeSchema as H, briefOutcomeStatusSchema as I, contextProvenance as J, newConversationEventSchema as K, conversationBriefSchema as L, messageCardText as M, readMessageCards as N, createConversationMessageBodySchema as O, briefCodeChangeSchema as P, usageSchema as Q, parseBriefInput as R, conversationReportEventDataSchema as S, conversationStatsReportSchema as T, conversationTurnFailureReasonSchema as U, conversationEventDataSchema as V, decodeStoredConversationEvent as W, instructionProvenanceFor as X, instructionActors as Y, sameActorIdentity as Z, conversationParamsSchema as _, cancelConversationPendingMessagesBodySchema as a, conversationPendingMessageSchema as b, conversationAttachmentParamsSchema as c, conversationDetailReportSchema as d, conversationEventHistorySchema as f, conversationFeedSchema as g, conversationFeedQuerySchema as h, archiveConversationResponseSchema as i, messageCardRefSchema as j, annotationCard as k, conversationAuxiliaryCostsSchema as l, conversationEventsQuerySchema as m, actorIdentitySchema as n, cancelConversationPendingMessagesResponseSchema as o, conversationEventPageSchema as p, encodeHistoryPayload as q, archiveConversationBodySchema as r, conversationActivityPreviewSchema as s, acceptedConversationMessageSchema as t, conversationDetailQuerySchema as u, conversationPendingAuthorizationSchema as v, conversationStatsItemSchema as w, conversationPendingMessagesReportSchema as x, conversationPendingMessageDeliverySchema as y, KNOWN_CONVERSATION_EVENT_TYPES as z };
|
|
@@ -1,144 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { m as escapeXml } from "./client-
|
|
3
|
-
import {
|
|
4
|
-
import { n as botConfig, o as getRuntimeMetadata } from "./config-
|
|
1
|
+
import { T as lookupSlackUserProfile, Tn as createUserTokenStore, _ as putMcpStoredOAuthCredentials, d as deleteMcpAuthSession, dn as formatProviderLabel, fn as parseOAuthStatePayload, g as getMcpStoredOAuthCredentials, h as getMcpAuthSession, mt as getMcpProviderErrorAttributes, pn as resolveBaseUrl, u as finalizeMcpAuthorization, x as resolvePluginOAuthAccount, xn as postSlackMessage } from "./agent-runner-DEF7auSj.js";
|
|
2
|
+
import { m as escapeXml } from "./client-C2WBBx7m.js";
|
|
3
|
+
import { d as logException, h as runBestEffort, p as logWarn } from "./logging-CvjMHRvg.js";
|
|
4
|
+
import { n as botConfig, o as getRuntimeMetadata } from "./config-Bws6Rpsh.js";
|
|
5
5
|
import { g as parseSlackUserId } from "./context-Bplcgypl.js";
|
|
6
|
-
import { Jt as getSqlExecutor, U as getSlackClient,
|
|
6
|
+
import { Jt as getSqlExecutor, U as getSlackClient, cn as upsertIdentity, ln as upsertLinkedIdentity } from "./agent-hooks-FUetyyLe.js";
|
|
7
7
|
import { i as homeDir } from "./package-discovery-7a9YqLhE.js";
|
|
8
|
-
import { n as buildOAuthTokenRequest, r as parseOAuthTokenResponse, u as hasRequiredOAuthScope } from "./registry-
|
|
9
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime-
|
|
10
|
-
import { t as discoverSkills } from "./skills-
|
|
11
|
-
import { B as recordAuthorizationCompleted,
|
|
12
|
-
import { E as acquireActiveLock, w as getStateAdapter } from "./profile-
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { n as resolveTurnSessionRouting } from "./turn-session-routing-CQaysLoe.js";
|
|
8
|
+
import { n as buildOAuthTokenRequest, r as parseOAuthTokenResponse, u as hasRequiredOAuthScope } from "./registry-C6FHctIu.js";
|
|
9
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-BYGR3Dr4.js";
|
|
10
|
+
import { t as discoverSkills } from "./skills-EhiVbjF4.js";
|
|
11
|
+
import { B as recordAuthorizationCompleted, s as getTurnRecord, z as recordAuthenticationLinked } from "./checkpoint-CJe-dZFF.js";
|
|
12
|
+
import { E as acquireActiveLock, w as getStateAdapter } from "./profile-dvV7PB7u.js";
|
|
13
|
+
import { i as getConversationPendingAuth } from "./pending-auth-DLNJbD8H.js";
|
|
14
|
+
import { r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-CTuWhjru.js";
|
|
15
|
+
import { n as deleteWebAuthorization, o as wakeAuthorizedTurn, s as wakePausedTurn } from "./web-authorization-Biy8nsS7.js";
|
|
17
16
|
import { n as relayLocalOAuthCallback } from "./oauth-relay-CdCnu80W.js";
|
|
18
|
-
import { n as deleteWebAuthorization } from "./web-authorization-Bbx999_q.js";
|
|
19
17
|
import path from "node:path";
|
|
20
18
|
import { z } from "zod";
|
|
21
19
|
import { createHmac, createSecretKey, timingSafeEqual } from "node:crypto";
|
|
22
20
|
import { pluginStoredTokensSchema } from "@sentry/junior-plugin-api";
|
|
23
21
|
import fs from "node:fs";
|
|
24
|
-
//#region src/chat/task-execution/authorized-turn.ts
|
|
25
|
-
/**
|
|
26
|
-
* OAuth callbacks save readiness, not agent history. The conversation worker
|
|
27
|
-
* consumes this event under its lease before it resumes the paused Turn.
|
|
28
|
-
*/
|
|
29
|
-
const authorizationSchema = z.object({
|
|
30
|
-
kind: z.enum(["mcp", "plugin"]),
|
|
31
|
-
provider: z.string().min(1),
|
|
32
|
-
actorId: z.string().min(1),
|
|
33
|
-
authorizationId: z.string().min(1),
|
|
34
|
-
authSessionId: z.string().optional(),
|
|
35
|
-
scope: z.string().optional(),
|
|
36
|
-
configuration: z.record(z.string(), z.unknown()).optional(),
|
|
37
|
-
toolChannelId: z.string().optional()
|
|
38
|
-
});
|
|
39
|
-
function authorizationKey(turn) {
|
|
40
|
-
return `turn:${turn.turnId}:authorization:${turn.version}`;
|
|
41
|
-
}
|
|
42
|
-
/** Save authorization for this parked boundary without changing model history. */
|
|
43
|
-
async function recordTurnAuthorization(args) {
|
|
44
|
-
const turn = await getTurnRecord(args.conversationId, args.turnId);
|
|
45
|
-
if (!turn || turn.state !== "paused" || turn.resumeReason !== "auth") return;
|
|
46
|
-
await getConversationEventStore().append(args.conversationId, [{
|
|
47
|
-
idempotencyKey: authorizationKey(turn),
|
|
48
|
-
createdAtMs: Date.now(),
|
|
49
|
-
data: {
|
|
50
|
-
type: "structured_event",
|
|
51
|
-
namespace: "junior",
|
|
52
|
-
name: "turn_authorized",
|
|
53
|
-
version: 1,
|
|
54
|
-
turnId: turn.turnId,
|
|
55
|
-
content: authorizationSchema.parse(args)
|
|
56
|
-
}
|
|
57
|
-
}], { activity: "preserve" });
|
|
58
|
-
return {
|
|
59
|
-
conversationId: args.conversationId,
|
|
60
|
-
destination: args.destination,
|
|
61
|
-
turnId: turn.turnId,
|
|
62
|
-
expectedVersion: turn.version
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
/** Read authorization for the exact pause; a later auth pause needs its own callback. */
|
|
66
|
-
async function getTurnAuthorization(turn) {
|
|
67
|
-
const event = await getConversationEventStore().loadByIdempotencyKey(turn.conversationId, authorizationKey(turn));
|
|
68
|
-
if (event?.data.type !== "structured_event") return void 0;
|
|
69
|
-
return authorizationSchema.parse(event.data.content);
|
|
70
|
-
}
|
|
71
|
-
//#endregion
|
|
72
|
-
//#region src/chat/task-execution/turn-wake.ts
|
|
73
|
-
/** Build the worker input for a paused turn. */
|
|
74
|
-
async function getPausedTurnRequest(args) {
|
|
75
|
-
const turn = (await loadTurnCheckpoint({
|
|
76
|
-
conversationId: args.conversationId,
|
|
77
|
-
turnId: args.turnId
|
|
78
|
-
})).record;
|
|
79
|
-
if (!turn || turn.state !== "paused" || turn.resumeReason !== "timeout" && turn.resumeReason !== "yield" && turn.resumeReason !== "retry" && !(turn.resumeReason === "auth" && await getTurnAuthorization(turn)) || turn.resumeReason === "timeout" && turn.sliceId < 2) return;
|
|
80
|
-
let routing;
|
|
81
|
-
try {
|
|
82
|
-
routing = await resolveTurnSessionRouting({
|
|
83
|
-
conversationId: args.conversationId,
|
|
84
|
-
conversationStore: args.conversationStore
|
|
85
|
-
});
|
|
86
|
-
} catch (error) {
|
|
87
|
-
await failTurnRecord({
|
|
88
|
-
conversationId: args.conversationId,
|
|
89
|
-
expectedVersion: turn.version,
|
|
90
|
-
turnId: args.turnId,
|
|
91
|
-
errorMessage: error instanceof Error ? error.message : String(error)
|
|
92
|
-
});
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
return {
|
|
96
|
-
conversationId: args.conversationId,
|
|
97
|
-
destination: routing.destination,
|
|
98
|
-
turnId: args.turnId,
|
|
99
|
-
expectedVersion: turn.version
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
/** Wake the conversation worker for a paused turn. */
|
|
103
|
-
async function wakePausedTurn(request, options = {}) {
|
|
104
|
-
const nowMs = options.nowMs ?? Date.now();
|
|
105
|
-
await requestConversationWork({
|
|
106
|
-
conversationId: request.conversationId,
|
|
107
|
-
destination: request.destination,
|
|
108
|
-
nowMs,
|
|
109
|
-
state: options.state
|
|
110
|
-
});
|
|
111
|
-
const queue = options.queue ?? getVercelConversationWorkQueue();
|
|
112
|
-
await ensureConversationWake({
|
|
113
|
-
conversationId: request.conversationId,
|
|
114
|
-
idempotencyKey: [
|
|
115
|
-
"agent-continue",
|
|
116
|
-
request.conversationId,
|
|
117
|
-
request.turnId,
|
|
118
|
-
request.expectedVersion,
|
|
119
|
-
nowMs
|
|
120
|
-
].join(":"),
|
|
121
|
-
nowMs,
|
|
122
|
-
queue,
|
|
123
|
-
state: options.state
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
/** Create paused Turn operations for one app. */
|
|
127
|
-
function createPausedTurns(options = {}) {
|
|
128
|
-
return {
|
|
129
|
-
get: (args) => getPausedTurnRequest({
|
|
130
|
-
...args,
|
|
131
|
-
conversationStore: options.conversationStore
|
|
132
|
-
}),
|
|
133
|
-
wake: (request) => wakePausedTurn(request, options)
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
/** Record completed authorization and wake the sole execution owner. */
|
|
137
|
-
async function wakeAuthorizedTurn(args, queue) {
|
|
138
|
-
const request = await recordTurnAuthorization(args);
|
|
139
|
-
if (request) await wakePausedTurn(request, { queue });
|
|
140
|
-
}
|
|
141
|
-
//#endregion
|
|
142
22
|
//#region src/handlers/oauth-html.ts
|
|
143
23
|
/** Build pre-escaped callback HTML with the shared response security policy. */
|
|
144
24
|
function htmlCallbackResponse(title, message, status, options = {}) {
|
|
@@ -937,4 +817,4 @@ async function receiveLocalOAuthCredential(request) {
|
|
|
937
817
|
return new Response(null, { status: 204 });
|
|
938
818
|
}
|
|
939
819
|
//#endregion
|
|
940
|
-
export { GET$1 as a,
|
|
820
|
+
export { GET$1 as a, publishAppHomeView as i, syncLocalOAuthCredential as n, GET as r, receiveLocalOAuthCredential as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { g as startSpanManual } from "./sentry-CgWZM_kV.js";
|
|
2
|
-
import "./config-
|
|
2
|
+
import "./config-Bws6Rpsh.js";
|
|
3
3
|
import { n as juniorDestinations, r as timestamptz } from "./destinations-BeBiJeEM.js";
|
|
4
4
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
5
5
|
import { getTableColumns, sql } from "drizzle-orm";
|