@sentry/junior 0.316.0 → 0.318.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{admin-QYiDMnsu.js → admin-UOHix_5P.js} +1 -1
- package/dist/{agent-runner-Cr5Fhjf-.js → agent-runner-DeYymwh2.js} +13494 -13135
- package/dist/{reporting-window-C4dbzDiR.js → agent-status-BA5x3Xtp.js} +33 -1
- package/dist/{agent-update-delivery-BY13DPSD.js → agent-update-delivery-DH8bx7jU.js} +5 -5
- package/dist/api/schema.d.ts +600 -130
- package/dist/api/schema.js +6 -6
- package/dist/api.js +228 -214
- package/dist/{app-BhvzRD__.d.ts → app-DKAOuaoC.d.ts} +33 -18
- package/dist/app.d.ts +1 -1
- package/dist/app.js +193 -177
- package/dist/{thread-context-fiMNylbg.js → auth-pause-state-f9hJM_zO.js} +6 -59
- package/dist/catalog-runtime-BfdAnztW.js +6 -0
- package/dist/{change-record-Bqsa5ZXE.d.ts → change-record-BzJgLsv7.d.ts} +60 -1
- package/dist/{adapter-context-Bref7aPI.js → channel-access-A0de5lRv.js} +2 -42
- package/dist/{chat-core-engine-3dtlMku3.js → chat-core-engine-D3Wd7f5n.js} +6 -5
- package/dist/{child-message--2G3Ft26.js → child-message-peFWLcCZ.js} +2 -6
- package/dist/cli/chat.js +38 -30
- package/dist/cli/check.js +5 -5
- package/dist/cli/main.js +2 -2
- package/dist/cli/plugins.js +5 -4
- package/dist/cli/snapshot-create.js +4 -2
- package/dist/cli/upgrade.js +5 -3
- package/dist/context-BKF_5zzI.js +1833 -0
- package/dist/{continue-in-slack-DbQUFe_F.js → continue-in-slack-YxwMQVeR.js} +3 -3
- package/dist/{conversation-feed-B84pMjHo.js → conversation-feed-Cj7IuBtM.js} +3 -3
- package/dist/{proxy-path-BTmXDjfx.js → conversation-privacy-Cr_dNW1p.js} +2 -16
- package/dist/{conversation-turn-DzEpTIaf.js → conversation-turn-Bru4w_FD.js} +196 -80
- package/dist/{create-DUJBXr6E.js → create-Btl1y1rq.js} +12 -11
- package/dist/{credential-sync-JH_K9Adg.js → credential-sync-DTarZ63K.js} +20 -15
- package/dist/{db-DhzvUY23.js → db-of6e3sGt.js} +20724 -27256
- package/dist/{deployment-BhvrhQeh.js → deployment-C0qXa0FD.js} +17 -15
- package/dist/{engine-context-C9Nal48K.js → engine-context-C_QL_bMQ.js} +304 -56
- package/dist/{html-B_12WjKT.js → html-9_pS9SjY.js} +6 -2
- package/dist/instrumentation.js +15 -7
- package/dist/{job-runner-DO8nslyY.js → job-runner-B2XEvpif.js} +392 -26
- package/dist/{lineage-D3AZAJVe.js → lineage-nh4z9iQN.js} +1 -1
- package/dist/{list-B0zsb5Cp.js → list-HRP3TIRl.js} +238 -550
- package/dist/{logging-B8KEJegM.js → logging-BnOG0qz2.js} +4 -50
- package/dist/{session-stop-DponjDUZ.js → mailbox-turn-Byrry9o1.js} +4807 -7102
- package/dist/{list-mkB_GU8R.js → markers-CTTtJqYn.js} +171 -124
- package/dist/{message-B5fKDYzz.js → message-BRUuLgrY.js} +13 -24
- package/dist/{model-input-CuMWy37l.js → model-input-CFC62mf-.js} +3 -3
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +21 -7
- package/dist/{oauth-callback-server-B3Vvlydo.js → oauth-callback-server-CjnnUr4o.js} +2 -2
- package/dist/{oauth-relay-6ERrGPbA.js → oauth-relay-BvHFH0fV.js} +2 -2
- package/dist/{package-discovery-BI6T_RkD.js → package-discovery-DD9vencX.js} +1 -50
- package/dist/{plugins-BXMdNdyA.js → plugins-D_Ru4CWc.js} +1 -1
- package/dist/profile-iHw1uu32.js +4657 -0
- package/dist/{transcript-CCi7323k.js → prompt-DEkStuxG.js} +92 -98
- package/dist/proxy-path-BHYoKZdq.js +15 -0
- package/dist/registry-Cl7Labpe.js +3279 -0
- package/dist/reports-C1d9azyV.js +195 -0
- package/dist/{resolve-D5JVvv6A.js → resolve-DC6zBuDV.js} +9 -29
- package/dist/{result-CS_7mo8a.js → result-DxewDuXb.js} +27 -118
- package/dist/run-conversation-Cz2ubZK-.js +337 -0
- package/dist/{runner-BzAES5W3.js → runner-99YxVN_r.js} +10 -18
- package/dist/{sandbox-egress-signals-Dwhk2Q5F.js → sandbox-egress-signals-CgoX5CTI.js} +1 -1
- package/dist/{schema-z5-wA6N4.js → schema-BTojNBr5.js} +48 -86
- package/dist/sender-actors-77zTQbSG.js +84 -0
- package/dist/{service-account-D6AsAtc1.js → service-account-YDCPSByj.js} +3 -1
- package/dist/{skills-DgJ9GBPR.js → skills-CleC0Hze.js} +6 -5
- package/dist/{slack-conversation-unfurl-Dq71EkhM.js → slack-conversation-unfurl-BNQLC12R.js} +7 -6
- package/dist/{spawn-BJWpdwhQ.js → spawn-DuZfodPa.js} +5 -5
- package/dist/{system-prompt-table-iIgpmslr.js → system-prompt-table-Ci6Ck4gk.js} +88 -69
- package/dist/{task-runner-BJae4JwE.js → task-runner-BJ9Up3bG.js} +30 -53
- package/dist/topics-BoCkoPJJ.js +21 -0
- package/dist/turn-membership-VT7XZh-L.js +856 -0
- package/dist/{turn-wake-BjDW7x-5.js → turn-wake-C7HeLHAM.js} +3 -4
- package/dist/{media-BebquhET.js → types-DCzTAA63.js} +629 -593
- package/dist/user-customization-CvfuY9Eo.js +93 -0
- package/dist/users-Cb9c1k9q.js +181 -0
- package/dist/{validation-D5WmmmhX.js → validation-BiUmWPhy.js} +1 -1
- package/dist/{version-CBQoanXb.js → version-VEXiEcZu.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{worker-Cyb4kF17.js → worker-ChWYQdhm.js} +5 -4
- package/migrations/20261126025226_drop_agent_invocations/migration.sql +6 -0
- package/migrations/20261126025226_drop_agent_invocations/snapshot.json +9 -0
- package/migrations/20261126033000_space_conversations_lead_children/migration.sql +155 -0
- package/migrations/20261126033000_space_conversations_lead_children/snapshot.json +9 -0
- package/migrations/20261126144620_drop_user_message_time_index/migration.sql +1 -0
- package/migrations/20261126144620_drop_user_message_time_index/snapshot.json +38 -0
- package/migrations/20261126153100_inbox_item_subjects/migration.sql +140 -0
- package/migrations/20261126153100_inbox_item_subjects/snapshot.json +9 -0
- package/migrations/20261126153103_inbox_item_subjects_not_null/migration.sql +12 -0
- package/migrations/20261126153103_inbox_item_subjects_not_null/snapshot.json +9 -0
- package/migrations/20261126153105_inbox_item_subject_indexes/migration.sql +1 -0
- package/migrations/20261126153105_inbox_item_subject_indexes/snapshot.json +9 -0
- package/migrations/20261126153108_automation_run_conversation_index/migration.sql +1 -0
- package/migrations/20261126153108_automation_run_conversation_index/snapshot.json +9 -0
- package/migrations/20261126153159_inbox_item_subjects_schema/migration.sql +4 -0
- package/migrations/20261126153159_inbox_item_subjects_schema/snapshot.json +437 -0
- package/migrations/20261126153259_inbox_questions/migration.sql +76 -0
- package/migrations/20261126153259_inbox_questions/snapshot.json +9 -0
- package/migrations/20261126153301_inbox_questions_valid/migration.sql +3 -0
- package/migrations/20261126153301_inbox_questions_valid/snapshot.json +9 -0
- package/migrations/20261126153343_inbox_questions_schema/migration.sql +5 -0
- package/migrations/20261126153343_inbox_questions_schema/snapshot.json +407 -0
- package/migrations/20261126154025_inbox_item_owners/migration.sql +74 -0
- package/migrations/20261126154025_inbox_item_owners/snapshot.json +9 -0
- package/migrations/20261126154048_inbox_item_open_subject_key_index/migration.sql +1 -0
- package/migrations/20261126154048_inbox_item_open_subject_key_index/snapshot.json +9 -0
- package/migrations/20261126154051_drop_inbox_item_owner_indexes/migration.sql +7 -0
- package/migrations/20261126154051_drop_inbox_item_owner_indexes/snapshot.json +9 -0
- package/migrations/20261126154121_inbox_item_owners_schema/migration.sql +8 -0
- package/migrations/20261126154121_inbox_item_owners_schema/snapshot.json +311 -0
- package/migrations/20261126175601_conversation_event_turn/migration.sql +5 -0
- package/migrations/20261126175601_conversation_event_turn/snapshot.json +103 -0
- package/migrations/20261126175614_conversation_event_turn_index/migration.sql +1 -0
- package/migrations/20261126175614_conversation_event_turn_index/snapshot.json +62 -0
- package/migrations/20261126230028_merge_leaves/migration.sql +2 -0
- package/migrations/20261126230028_merge_leaves/snapshot.json +12 -0
- package/migrations/20261126231932_space_lead_holds_name/migration.sql +46 -0
- package/migrations/20261126231932_space_lead_holds_name/snapshot.json +58 -0
- package/migrations/20261127001022_merge_leaves/migration.sql +2 -0
- package/migrations/20261127001022_merge_leaves/snapshot.json +12 -0
- package/migrations/20261127002500_turn_discarded_usage/migration.sql +2 -0
- package/migrations/20261127002500_turn_discarded_usage/snapshot.json +73 -0
- package/package.json +5 -5
- package/dist/people-CUtFApfL.js +0 -81
- package/dist/start-conversation-B-LIqqNi.js +0 -162
- package/dist/turn-session-routing-D15orfwy.js +0 -1309
- package/dist/user-customization-B27StpVQ.js +0 -9
- package/dist/web-message-id-C6P83ans.js +0 -10
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { A as setFirstConversationLocation, Mi as formatSlackLink, N as claimProviderConversation, O as withConversationMutationLock, P as getConversationIdByProviderConversation, Sf as juniorDestinations, Tn as moveIdleConversationDestination, a as getDb, bi as getSlackMessagePermalink, i as getConversationStore, ji as escapeSlackMrkdwnText, o as getSqlExecutor, tl as getDashboardConversationLink, wi as postSlackMessage, yi as deleteSlackMessage } from "./db-of6e3sGt.js";
|
|
2
|
+
import { E as parseSlackChannelId, P as parseSlackMessageTs, y as getStateAdapter } from "./context-BKF_5zzI.js";
|
|
3
|
+
import { n as joinPublicChannelForRead, t as checkSlackChannelReadAccess } from "./channel-access-A0de5lRv.js";
|
|
4
4
|
import { and, eq } from "drizzle-orm";
|
|
5
5
|
// src/chat/slack/continue-in-slack.ts
|
|
6
6
|
/** Refusal for a move that cannot wait for the active Run. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { F as actorIdentitySchema, Nt as spaceRefSchema, V as conversationDetailReportSchema, X as conversationSummaryReportSchema, Yt as messageAttachmentSchema, zt as inboxItemChangeRecordSchema } from "./types-DCzTAA63.js";
|
|
2
2
|
import * as z from "zod";
|
|
3
3
|
// src/api/objects/cards.ts
|
|
4
4
|
const MAX_LABEL_CHARS = 256;
|
|
@@ -345,8 +345,8 @@ const conversationSubscriptionResponseSchema = z.object({
|
|
|
345
345
|
* was the last subscriber, so leaving archived it for everyone.
|
|
346
346
|
*/
|
|
347
347
|
const conversationLeaveResponseSchema = z.object({ archivedAt: z.string().datetime().nullable().describe("Set when the conversation is archived for everyone.") }).strict();
|
|
348
|
-
/** Invite one
|
|
349
|
-
const conversationInviteBodySchema = z.object({
|
|
348
|
+
/** Invite one User, by the id that user search returns, to a Conversation. */
|
|
349
|
+
const conversationInviteBodySchema = z.object({ userId: z.string().min(1).max(64) }).strict();
|
|
350
350
|
/** `added` is false when the person was already a Participant. */
|
|
351
351
|
const conversationInviteResponseSchema = z.object({ added: z.boolean() }).strict();
|
|
352
352
|
// src/api/schema/conversation-stop.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { m as logWarn } from "./logging-BnOG0qz2.js";
|
|
2
2
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
3
|
import { renderSystemMessageUpdate } from "@earendil-works/pi-ai";
|
|
4
4
|
// src/chat/conversation-privacy.ts
|
|
@@ -186,18 +186,4 @@ function toGenAiMessagesTraceAttributes(prefix, messages) {
|
|
|
186
186
|
...partTypes.size > 0 ? { [`${prefix}.part_types`]: [...partTypes] } : void 0
|
|
187
187
|
};
|
|
188
188
|
}
|
|
189
|
-
|
|
190
|
-
const SANDBOX_EGRESS_PROXY_PATH = "/api/internal/sandbox-egress";
|
|
191
|
-
const PROXY_PATH_PREFIX = `${SANDBOX_EGRESS_PROXY_PATH}/`;
|
|
192
|
-
const SIGNALS_SEGMENT = "signals";
|
|
193
|
-
/**
|
|
194
|
-
* Replace the credential token and everything after it in a sandbox egress
|
|
195
|
-
* proxy path or URL. Other values are returned unchanged.
|
|
196
|
-
*/
|
|
197
|
-
function redactSandboxEgressProxyPath(value) {
|
|
198
|
-
const index = value.indexOf(PROXY_PATH_PREFIX);
|
|
199
|
-
if (index === -1) return value;
|
|
200
|
-
if (value.slice(index + PROXY_PATH_PREFIX.length).split(/[/?#]/, 1)[0] === SIGNALS_SEGMENT) return value;
|
|
201
|
-
return `${value.slice(0, index)}${PROXY_PATH_PREFIX}<token>`;
|
|
202
|
-
}
|
|
203
|
-
export { resolveConversationPrivacy as a, toCanonicalOutputMessage as c, toGenAiPayloadTraceAttributes as d, getCurrentConversationPrivacy as i, toGenAiMessagesTraceAttributes as l, redactSandboxEgressProxyPath as n, runWithConversationPrivacy as o, canExposeConversationPayload as r, toCanonicalInputMessage as s, SANDBOX_EGRESS_PROXY_PATH as t, toGenAiPayloadMetadata as u };
|
|
189
|
+
export { toCanonicalInputMessage as a, toGenAiPayloadMetadata as c, runWithConversationPrivacy as i, toGenAiPayloadTraceAttributes as l, getCurrentConversationPrivacy as n, toCanonicalOutputMessage as o, resolveConversationPrivacy as r, toGenAiMessagesTraceAttributes as s, canExposeConversationPayload as t };
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
|
|
2
|
-
import { $
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
2
|
+
import { $o as isConversationDeliveryPaused, An as canJoinTurn, Gl as isEventConversationMessage, Go as JUNIOR_THREAD_STATE_TTL_MS, In as isEventMailboxMetadata, Nl as isTopLevel, Pl as parentResultActor, Pn as readParentMessage, Qn as sendSlackReply, Rl as turnBehavior, Uo as verifyTimerWatchCredentialSubject, Zn as resolveSlackReplyTarget, _i as notifyAutomationBlocked, a as getDb, ai as getDispatchIdForConversation, an as getConversationWorkState, i as getConversationStore, jl as isPersonInput, n as getConversationEventStore, pa as blockEventAutomation, ra as blockScheduledAutomation, ur as getTurnRequestDeadline, uu as indexEndedTurnEvents } from "./db-of6e3sGt.js";
|
|
3
|
+
import { Lt as readConversationAutomationRun, M as measureTurnCompactionWait, mt as resolveConversationDestination, q as stopConversationAndChildAgents } from "./agent-runner-DeYymwh2.js";
|
|
4
|
+
import { T as withSpan, f as logException, m as logWarn, x as setTags, y as setSpanAttributes } from "./logging-BnOG0qz2.js";
|
|
5
|
+
import { Xt as readMessageAttachments, wt as instructionProvenanceFor } from "./types-DCzTAA63.js";
|
|
6
|
+
import { i as loadPendingMessageCards, r as buildDeliveredTurnStatePatch, t as completeAuthPauseTurn } from "./auth-pause-state-f9hJM_zO.js";
|
|
7
|
+
import { At as instructionActorFor, Cr as ConversationTurnLifecycleService, Ct as isHeldInputMessage, Gn as normalizeConversationText, In as persistConversationMessages, J as completeCancelledConversationTurn, Kn as recordDeliveredAssistantMessage, Lr as finalizeFailedTurnReplyWithEvent, M as eventBatchMessageMeta, N as renderEventBatchInputs, Nt as turnRequestText, P as timerWatchCredentialSubject, Pn as hydrateConversationMessages, Pt as withoutSavedSteeringMessages, Tt as loadThreadContextCursor, Un as latestConversationMessageSeq, Vt as buildDeterministicTurnId, Wn as markConversationMessage, Xn as upsertConversationMessage, Y as getTurnUserMessage, _n as commitAcceptedReply, _r as abandonTurnRecord, _t as createWebAuthorization, at as isTurnInputCommitLostError, bn as loadConversationProjection, br as getTurnRecord, bt as eventInboxItemInputs, c as legacyWebMailboxMetadataSchema, d as childAgentTurnOptions, ei as persistWithRetry, f as commitParentMessageFork, ft as getPersistedSandboxState, gr as saveTurnCheckpoint, gt as coerceThreadConversationState, h as isParentMessageAuthor, ht as persistThreadStateById, i as listActiveMailboxTurns, jt as instructionForInputs, kt as buildSteeringPiMessage, lt as markTurnFailed, n as getEventBatchDelayMs, o as sourceFromTurnInput, pt as getPersistedThreadState, qn as renderConversationMessageLine, rt as getConversationTurnBoundaryError, s as turnInputFactsFromConversationMessage, st as markTurnClosed, tt as TurnInputCommitLostError, ut as startActiveTurn, vt as deleteWebAuthorization, wr as getTurnLifecycle, wt as withHeldInput, xt as loadInboxItemInput, yr as failTurnRecord, zn as conversationAuthorDisplayName } from "./mailbox-turn-Byrry9o1.js";
|
|
8
|
+
import { u as isChildAgentEvent } from "./markers-CTTtJqYn.js";
|
|
9
|
+
import { B as authorAttrs, G as mapBounded, W as renderThreadContext } from "./prompt-DEkStuxG.js";
|
|
10
|
+
import { L as botConfig, n as credentialContextForActor, y as getStateAdapter } from "./context-BKF_5zzI.js";
|
|
9
11
|
import { i as getActiveSpan, r as continueTrace } from "./sentry-CPbZjomA.js";
|
|
10
|
-
import {
|
|
11
|
-
import { i as CONVERSATION_METADATA_TASK, n as scheduleSessionCompletedPluginTasks, t as processPluginTask } from "./task-runner-
|
|
12
|
-
import { n as getPausedTurnRequest } from "./turn-wake-
|
|
13
|
-
import {
|
|
14
|
-
import { g as resolveConversationDestination } from "./turn-session-routing-D15orfwy.js";
|
|
15
|
-
import { t as readConversationLineage } from "./lineage-D3AZAJVe.js";
|
|
12
|
+
import { h as getAssistantReplyText } from "./system-prompt-table-Ci6Ck4gk.js";
|
|
13
|
+
import { i as CONVERSATION_METADATA_TASK, n as scheduleSessionCompletedPluginTasks, t as processPluginTask } from "./task-runner-BJ9Up3bG.js";
|
|
14
|
+
import { n as getPausedTurnRequest } from "./turn-wake-C7HeLHAM.js";
|
|
15
|
+
import { t as readConversationLineage } from "./lineage-nh4z9iQN.js";
|
|
16
16
|
import * as z from "zod";
|
|
17
|
+
import { indentTagLines, renderTag } from "@sentry/junior-plugin-api";
|
|
17
18
|
import { isDeepStrictEqual } from "node:util";
|
|
18
19
|
import { createHash } from "node:crypto";
|
|
19
20
|
// src/chat/task-execution/turn-telemetry.ts
|
|
@@ -281,6 +282,93 @@ async function stopAtAutomatedTurnLimit(args) {
|
|
|
281
282
|
source: args.source
|
|
282
283
|
});
|
|
283
284
|
}
|
|
285
|
+
// src/chat/slack/thread-context.ts
|
|
286
|
+
const CONTEXT_MAX_MESSAGE_CHARS = 8e3;
|
|
287
|
+
const TRUNCATED_MESSAGE_NOTE = " [truncated: read the full Message with slackThreadRead]";
|
|
288
|
+
const THREAD_CONTEXT_MAX_CHARS = 6e4;
|
|
289
|
+
const THREAD_CONTEXT_OMITTED_NOTE = "Older Messages of this thread are not shown. Find them with a searchConversationEvents query, then read them with readConversationEvent.";
|
|
290
|
+
function isTakeOrDismissOnly(message) {
|
|
291
|
+
const changes = message.meta?.reviewItemChanges;
|
|
292
|
+
return Boolean(changes?.length && changes.every((change) => change.kind === "taken" || change.kind === "dismissed"));
|
|
293
|
+
}
|
|
294
|
+
function capMessageText(text) {
|
|
295
|
+
const compact = text.replace(/\s+/g, " ");
|
|
296
|
+
return compact.length > CONTEXT_MAX_MESSAGE_CHARS ? `${compact.slice(0, CONTEXT_MAX_MESSAGE_CHARS)}${TRUNCATED_MESSAGE_NOTE}` : compact;
|
|
297
|
+
}
|
|
298
|
+
function renderThreadContextMessage(message, conversation, index) {
|
|
299
|
+
return indentTagLines(renderTag("message", {
|
|
300
|
+
index,
|
|
301
|
+
sent_at: new Date(message.createdAtMs).toISOString(),
|
|
302
|
+
role: message.role,
|
|
303
|
+
...authorAttrs({
|
|
304
|
+
authorId: message.author?.userId,
|
|
305
|
+
authorName: conversationAuthorDisplayName(message)
|
|
306
|
+
}),
|
|
307
|
+
slack_ts: message.meta?.slackTs
|
|
308
|
+
}, [renderConversationMessageLine(message, conversation, capMessageText(message.text))]), " ");
|
|
309
|
+
}
|
|
310
|
+
function isUntaggedThreadMessage(message) {
|
|
311
|
+
return message.role === "user" && !message.meta?.explicitMention && !isEventConversationMessage(message);
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Render the thread Messages that this Turn needs as one evidence-only block.
|
|
315
|
+
*
|
|
316
|
+
* With agent history, earlier Turns already hold their thread context, Turn
|
|
317
|
+
* input, and replies. So only untagged Messages saved after the cursor of the
|
|
318
|
+
* previous Turn are new. Without history, show the latest Messages. Both keep
|
|
319
|
+
* the newest Messages under one hard size cap, so the block cannot grow with
|
|
320
|
+
* the thread.
|
|
321
|
+
*/
|
|
322
|
+
function buildConversationContext(conversation, options = {}) {
|
|
323
|
+
const { history } = options;
|
|
324
|
+
const candidates = conversation.messages.filter((entry) => !options.excludeMessageIds?.includes(entry.id) && !isTakeOrDismissOnly(entry) && !isHeldInputMessage(entry) && (!history || isUntaggedThreadMessage(entry) && (history.afterSeq === void 0 || entry.seq === void 0 || entry.seq > history.afterSeq)));
|
|
325
|
+
let first = candidates.length;
|
|
326
|
+
let chars = 0;
|
|
327
|
+
while (first > 0) {
|
|
328
|
+
const size = renderThreadContextMessage(candidates[first - 1], conversation, first).length;
|
|
329
|
+
if (chars + size > THREAD_CONTEXT_MAX_CHARS) break;
|
|
330
|
+
chars += size;
|
|
331
|
+
first -= 1;
|
|
332
|
+
}
|
|
333
|
+
const shown = candidates.slice(first).map((message, index) => renderThreadContextMessage(message, conversation, index + 1));
|
|
334
|
+
const counts = {
|
|
335
|
+
shownMessages: shown.length,
|
|
336
|
+
omittedMessages: candidates.length - shown.length
|
|
337
|
+
};
|
|
338
|
+
if (shown.length === 0) return counts;
|
|
339
|
+
const lines = [renderThreadContext(shown)];
|
|
340
|
+
if (shown.length < candidates.length || !history && conversation.historyFromSeq !== void 0) lines.push(THREAD_CONTEXT_OMITTED_NOTE);
|
|
341
|
+
return {
|
|
342
|
+
...counts,
|
|
343
|
+
text: lines.join("\n")
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Build the thread context of one Turn prompt in a Slack thread. With agent
|
|
348
|
+
* history, show only the thread Messages saved after the cursor of the
|
|
349
|
+
* previous Turn.
|
|
350
|
+
*
|
|
351
|
+
* Sets `app.thread_context.*` on the active span: `chat.reply` in a Slack
|
|
352
|
+
* Turn, `chat.turn` in a web or Event Turn. Cursor `missing` means that the
|
|
353
|
+
* previous Turn ran before cursors existed.
|
|
354
|
+
*/
|
|
355
|
+
async function buildTurnThreadContext(args) {
|
|
356
|
+
const afterSeq = args.hasHistory ? await loadThreadContextCursor({
|
|
357
|
+
conversationId: args.conversationId,
|
|
358
|
+
turnId: args.turnId
|
|
359
|
+
}) : void 0;
|
|
360
|
+
const block = buildConversationContext(args.conversation, {
|
|
361
|
+
excludeMessageIds: args.excludeMessageIds,
|
|
362
|
+
...args.hasHistory ? { history: { afterSeq } } : void 0
|
|
363
|
+
});
|
|
364
|
+
setSpanAttributes({
|
|
365
|
+
"app.thread_context.chars": block.text?.length ?? 0,
|
|
366
|
+
"app.thread_context.shown_messages": block.shownMessages,
|
|
367
|
+
"app.thread_context.omitted_messages": block.omittedMessages,
|
|
368
|
+
"app.thread_context.cursor": !args.hasHistory ? "no_history" : afterSeq === void 0 ? "missing" : "found"
|
|
369
|
+
});
|
|
370
|
+
return block.text;
|
|
371
|
+
}
|
|
284
372
|
// src/chat/task-execution/supersede-turns.ts
|
|
285
373
|
/**
|
|
286
374
|
* End every open mailbox Turn other than `keepTurnId`, so new input runs in
|
|
@@ -449,6 +537,81 @@ async function runTurnEndTasks(args) {
|
|
|
449
537
|
params
|
|
450
538
|
}, conversationId, turnId);
|
|
451
539
|
}
|
|
540
|
+
// src/chat/task-execution/turn-failure.ts
|
|
541
|
+
function captureConversationTurnFailure(args) {
|
|
542
|
+
const eventId = logException(args.error, `conversation.turn.${args.failureCode}`, {
|
|
543
|
+
conversationId: args.conversationId,
|
|
544
|
+
...args.runId ? { runId: args.runId } : void 0,
|
|
545
|
+
turnId: args.turnId
|
|
546
|
+
});
|
|
547
|
+
return typeof eventId === "string" ? eventId : void 0;
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Record a final-attempt failure on the Turn record, the Conversation, and
|
|
551
|
+
* the Turn lifecycle, so the Turn ends failed and its update reaches the
|
|
552
|
+
* starter and Watches. The caller still acknowledges the input.
|
|
553
|
+
*/
|
|
554
|
+
async function failConversationTurn(args) {
|
|
555
|
+
const { conversation, conversationId, failure, failureCode, runId, turnId, userMessageId } = args;
|
|
556
|
+
const failureEventId = args.modelFailureCaptureAttempted && failureCode === "agent_run_failed" ? args.modelFailureEventId : captureConversationTurnFailure({
|
|
557
|
+
conversationId,
|
|
558
|
+
error: failure,
|
|
559
|
+
failureCode,
|
|
560
|
+
runId,
|
|
561
|
+
turnId
|
|
562
|
+
});
|
|
563
|
+
try {
|
|
564
|
+
const latest = await getTurnRecord(conversationId, turnId);
|
|
565
|
+
if (latest) await failTurnRecord({
|
|
566
|
+
conversationId,
|
|
567
|
+
errorMessage: failure instanceof Error ? failure.message : String(failure),
|
|
568
|
+
expectedVersion: latest.version,
|
|
569
|
+
turnId
|
|
570
|
+
});
|
|
571
|
+
} catch (turnRecordError) {
|
|
572
|
+
captureConversationTurnFailure({
|
|
573
|
+
conversationId,
|
|
574
|
+
error: turnRecordError,
|
|
575
|
+
failureCode: "persistence_failed",
|
|
576
|
+
runId,
|
|
577
|
+
turnId
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
try {
|
|
581
|
+
markTurnFailed({
|
|
582
|
+
conversation,
|
|
583
|
+
nowMs: Date.now(),
|
|
584
|
+
sessionId: turnId,
|
|
585
|
+
userMessageId,
|
|
586
|
+
markConversationMessage
|
|
587
|
+
});
|
|
588
|
+
await persistThreadStateById(conversationId, {
|
|
589
|
+
conversation,
|
|
590
|
+
sandboxRef: args.sandboxRef ?? null
|
|
591
|
+
});
|
|
592
|
+
} catch (persistenceError) {
|
|
593
|
+
captureConversationTurnFailure({
|
|
594
|
+
conversationId,
|
|
595
|
+
error: persistenceError,
|
|
596
|
+
failureCode: "persistence_failed",
|
|
597
|
+
runId,
|
|
598
|
+
turnId
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
await args.lifecycle.fail({
|
|
602
|
+
conversationId,
|
|
603
|
+
createdAtMs: Date.now(),
|
|
604
|
+
...failureEventId ? { eventId: failureEventId } : void 0,
|
|
605
|
+
failureCode,
|
|
606
|
+
failureText: failure instanceof Error ? failure.message : String(failure),
|
|
607
|
+
reportAs: args.reportAs,
|
|
608
|
+
turnId
|
|
609
|
+
});
|
|
610
|
+
await indexEndedTurnEvents({
|
|
611
|
+
conversationId,
|
|
612
|
+
turnId
|
|
613
|
+
});
|
|
614
|
+
}
|
|
452
615
|
// src/chat/task-execution/mailbox-input.ts
|
|
453
616
|
/**
|
|
454
617
|
* Return the Turn inputs of web Messages, one per non-empty Message, in
|
|
@@ -619,14 +782,6 @@ var conversation_turn_exports = /* @__PURE__ */ __exportAll({ createConversation
|
|
|
619
782
|
function stableHex(...parts) {
|
|
620
783
|
return createHash("sha256").update(parts.join("\0")).digest("hex").slice(0, 24);
|
|
621
784
|
}
|
|
622
|
-
function captureConversationTurnFailure(args) {
|
|
623
|
-
const eventId = logException(args.error, `conversation.turn.${args.failureCode}`, {
|
|
624
|
-
conversationId: args.conversationId,
|
|
625
|
-
...args.runId ? { runId: args.runId } : void 0,
|
|
626
|
-
turnId: args.turnId
|
|
627
|
-
});
|
|
628
|
-
return typeof eventId === "string" ? eventId : void 0;
|
|
629
|
-
}
|
|
630
785
|
function hasLostTurnInputCommit(error) {
|
|
631
786
|
const cause = getConversationTurnBoundaryError(error)?.cause ?? error;
|
|
632
787
|
return isTurnInputCommitLostError(error) || isTurnInputCommitLostError(cause);
|
|
@@ -766,7 +921,7 @@ function createConversationTurnWorker(agentRunner, deliverMessage, updates) {
|
|
|
766
921
|
const webActor = actor.platform === "web" ? actor : void 0;
|
|
767
922
|
const signInActor = behavior.waitsForSignIn ? webActor : void 0;
|
|
768
923
|
const disabledFeatures = signInActor ? [] : ["interactive-auth"];
|
|
769
|
-
const deliverToProvider = postsToProvider && behavior.delivery === "location";
|
|
924
|
+
const deliverToProvider = postsToProvider && (behavior.delivery === "location" || !behavior.gated && storedConversation !== void 0 && isTopLevel(storedConversation));
|
|
770
925
|
const surface = postsToProvider ? "slack" : "api";
|
|
771
926
|
const inputTelemetry = resolved.kind === "mailbox" ? turnInputTelemetry(resolved.batch.map((entry) => entry.message)) : void 0;
|
|
772
927
|
const turnTrace = inputTelemetry ?? (savedTurn?.traceContext ? { traceContexts: [savedTurn.traceContext] } : void 0);
|
|
@@ -918,17 +1073,21 @@ function createConversationTurnWorker(agentRunner, deliverMessage, updates) {
|
|
|
918
1073
|
turnId,
|
|
919
1074
|
runId: currentRunId,
|
|
920
1075
|
instruction: {
|
|
921
|
-
...
|
|
1076
|
+
...await withHeldInput({
|
|
1077
|
+
conversation,
|
|
1078
|
+
conversationId: context.conversationId,
|
|
1079
|
+
turnId
|
|
1080
|
+
}, instructionInputs),
|
|
922
1081
|
...instructionActor ? { actor: instructionActor } : void 0,
|
|
923
1082
|
...childTurn.instruction,
|
|
924
1083
|
storedAttachments: attachments,
|
|
925
|
-
context: await buildTurnThreadContext({
|
|
1084
|
+
context: conversationLocation?.provider === "slack" ? await buildTurnThreadContext({
|
|
926
1085
|
conversation,
|
|
927
1086
|
conversationId: context.conversationId,
|
|
928
1087
|
excludeMessageIds: inputMessageIds,
|
|
929
1088
|
hasHistory: history.messages.length > 0,
|
|
930
1089
|
turnId
|
|
931
|
-
})
|
|
1090
|
+
}) : void 0
|
|
932
1091
|
},
|
|
933
1092
|
history,
|
|
934
1093
|
...childTurn.run,
|
|
@@ -938,6 +1097,7 @@ function createConversationTurnWorker(agentRunner, deliverMessage, updates) {
|
|
|
938
1097
|
source,
|
|
939
1098
|
...conversationLocation ? { location: conversationLocation } : void 0,
|
|
940
1099
|
surface,
|
|
1100
|
+
deadlineAtMs: getTurnRequestDeadline()?.deadlineAtMs,
|
|
941
1101
|
...stopSignal ? { signal: stopSignal } : void 0,
|
|
942
1102
|
...signInActor ? { authorization: createWebAuthorization({
|
|
943
1103
|
actorId: signInActor.userId,
|
|
@@ -1067,63 +1227,19 @@ function createConversationTurnWorker(agentRunner, deliverMessage, updates) {
|
|
|
1067
1227
|
if (hasLostTurnInputCommit(failure)) return { status: "lost_lease" };
|
|
1068
1228
|
if (stopSignal?.aborted) return await completeCancelledTurn();
|
|
1069
1229
|
if (!context.attempt.isFinalAttempt) throw failure;
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
error: failure,
|
|
1073
|
-
failureCode,
|
|
1074
|
-
runId: currentRunId,
|
|
1075
|
-
turnId
|
|
1076
|
-
});
|
|
1077
|
-
try {
|
|
1078
|
-
const latest = await getTurnRecord(context.conversationId, turnId);
|
|
1079
|
-
if (latest) await failTurnRecord({
|
|
1080
|
-
conversationId: context.conversationId,
|
|
1081
|
-
errorMessage: failure instanceof Error ? failure.message : String(failure),
|
|
1082
|
-
expectedVersion: latest.version,
|
|
1083
|
-
turnId
|
|
1084
|
-
});
|
|
1085
|
-
} catch (turnRecordError) {
|
|
1086
|
-
captureConversationTurnFailure({
|
|
1087
|
-
conversationId: context.conversationId,
|
|
1088
|
-
error: turnRecordError,
|
|
1089
|
-
failureCode: "persistence_failed",
|
|
1090
|
-
runId: currentRunId,
|
|
1091
|
-
turnId
|
|
1092
|
-
});
|
|
1093
|
-
}
|
|
1094
|
-
try {
|
|
1095
|
-
markTurnFailed({
|
|
1096
|
-
conversation,
|
|
1097
|
-
nowMs: Date.now(),
|
|
1098
|
-
sessionId: turnId,
|
|
1099
|
-
userMessageId,
|
|
1100
|
-
markConversationMessage
|
|
1101
|
-
});
|
|
1102
|
-
await persistThreadStateById(context.conversationId, {
|
|
1103
|
-
conversation,
|
|
1104
|
-
sandboxRef: initialSandboxRef ?? null
|
|
1105
|
-
});
|
|
1106
|
-
} catch (persistenceError) {
|
|
1107
|
-
captureConversationTurnFailure({
|
|
1108
|
-
conversationId: context.conversationId,
|
|
1109
|
-
error: persistenceError,
|
|
1110
|
-
failureCode: "persistence_failed",
|
|
1111
|
-
runId: currentRunId,
|
|
1112
|
-
turnId
|
|
1113
|
-
});
|
|
1114
|
-
}
|
|
1115
|
-
await lifecycle.fail({
|
|
1230
|
+
await failConversationTurn({
|
|
1231
|
+
conversation,
|
|
1116
1232
|
conversationId: context.conversationId,
|
|
1117
|
-
|
|
1118
|
-
...failureEventId ? { eventId: failureEventId } : void 0,
|
|
1233
|
+
failure,
|
|
1119
1234
|
failureCode,
|
|
1120
|
-
|
|
1235
|
+
lifecycle,
|
|
1236
|
+
modelFailureCaptureAttempted,
|
|
1237
|
+
modelFailureEventId,
|
|
1121
1238
|
reportAs: parentResultActor(actor, source.kind),
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
turnId
|
|
1239
|
+
runId: currentRunId,
|
|
1240
|
+
sandboxRef: initialSandboxRef,
|
|
1241
|
+
turnId,
|
|
1242
|
+
userMessageId
|
|
1127
1243
|
});
|
|
1128
1244
|
await acknowledge();
|
|
1129
1245
|
return { status: "completed" };
|
|
@@ -1131,4 +1247,4 @@ function createConversationTurnWorker(agentRunner, deliverMessage, updates) {
|
|
|
1131
1247
|
});
|
|
1132
1248
|
};
|
|
1133
1249
|
}
|
|
1134
|
-
export {
|
|
1250
|
+
export { buildTurnThreadContext as a, AgentRunError as c, turnInputTelemetry as d, withTurnSpan as f, buildConversationContext as i, executeTurn as l, createConversationTurnWorker as n, stopAtAutomatedTurnLimit as o, supersedeTurnForInput as r, recordFinishedTurnForAutomatedLimit as s, conversation_turn_exports as t, getTurnInputSpanAttributes as u };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { randomUUID } from "node:crypto";
|
|
1
|
+
import { C as getChildAgentLockName, T as getSpawnedChildConversationId, Tr as loadTurnStart, U as getConversationStoppedAtMs, b as readAgentConfig, l as appendParentMessage, u as buildParentMessage, y as agentConfigSchema, zt as addConversationNote } from "./mailbox-turn-Byrry9o1.js";
|
|
2
|
+
import { Pt as getAgentBinding, Rt as spawnChildAgentInputSchema, Zd as juniorAgentBindings, an as getConversationWorkState, hf as juniorConversations, i as getConversationStore, o as getSqlExecutor, rn as ensureConversationWake, xn as hasConversationStop, yd as nextDetailVersion } from "./db-of6e3sGt.js";
|
|
3
|
+
import { n as recordSubagentStartedMarker, o as listOpenChildAgents, p as readChildConversationSender } from "./markers-CTTtJqYn.js";
|
|
4
|
+
import { I as AgentNameInUseError, L as AgentStoppedError, R as ChildAgentLimitError } from "./agent-runner-DeYymwh2.js";
|
|
6
5
|
import { eq } from "drizzle-orm";
|
|
6
|
+
import { randomUUID } from "node:crypto";
|
|
7
7
|
/**
|
|
8
8
|
* A stopped child agent cannot start or give work to child agents until its
|
|
9
9
|
* parent gives it new work, which ends the stop. A root Conversation has no
|
|
@@ -14,14 +14,15 @@ async function assertCanGiveChildWork(parentConversationId) {
|
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Throw when giving work to one child agent would put its parent over
|
|
17
|
-
* `
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
17
|
+
* `MAX_ACTIVE_CHILD_AGENTS`. A child agent is active while its listing shows
|
|
18
|
+
* open work, so a busy child already counts and messages queued for it do not
|
|
19
|
+
* count again. A new or idle child becomes active. This is the only place the
|
|
20
|
+
* rule for which child agents count lives. `active` is the parent's active
|
|
21
|
+
* children from `listOpenChildAgents`.
|
|
22
22
|
*/
|
|
23
23
|
function assertChildAgentCapacity(active, childConversationId) {
|
|
24
|
-
if (
|
|
24
|
+
if (active.includes(childConversationId) || active.length < 8) return;
|
|
25
|
+
throw new ChildAgentLimitError(8);
|
|
25
26
|
}
|
|
26
27
|
/**
|
|
27
28
|
* Create the Conversation of one new child agent and bind its name, after
|
|
@@ -1,17 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { i as finalizeMcpAuthorization } from "./agent-runner-
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { n as
|
|
1
|
+
import { C as acquireActiveLock, L as botConfig, R as getChatConfig, k as parseSlackUserId, y as getStateAdapter, z as getRuntimeMetadata } from "./context-BKF_5zzI.js";
|
|
2
|
+
import { Js as readIdentityById, Ms as getSlackClient, cc as upsertLinkedIdentity, ec as resolveActorIdentityId, o as getSqlExecutor, oc as findUserByVerifiedEmails, wi as postSlackMessage } from "./db-of6e3sGt.js";
|
|
3
|
+
import { O as isNativeIdentityProvider, f as logException, g as runBestEffort, m as logWarn } from "./logging-BnOG0qz2.js";
|
|
4
|
+
import { G as mapBounded } from "./prompt-DEkStuxG.js";
|
|
5
|
+
import { En as recordAuthorizationCompleted, Tn as recordAuthenticationLinked, br as getTurnRecord, dr as getConversationPendingAuth, gt as coerceThreadConversationState, ir as authorizationId, ni as formatProviderLabel, pt as getPersistedThreadState, ri as parseOAuthStatePayload, vt as deleteWebAuthorization } from "./mailbox-turn-Byrry9o1.js";
|
|
6
|
+
import { i as finalizeMcpAuthorization } from "./agent-runner-DeYymwh2.js";
|
|
7
|
+
import { i as homeDir } from "./package-discovery-DD9vencX.js";
|
|
8
|
+
import { t as discoverSkills } from "./skills-CleC0Hze.js";
|
|
9
|
+
import { C as getMcpAuthSession, H as getMcpProviderErrorAttributes, T as getMcpStoredOAuthCredentials, f as buildOAuthTokenRequest, k as putMcpStoredOAuthCredentials, m as hasRequiredOAuthScope, p as parseOAuthTokenResponse, y as deleteMcpAuthSession } from "./registry-Cl7Labpe.js";
|
|
10
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-BfdAnztW.js";
|
|
11
|
+
import { A as createUserTokenStore, I as resolvePluginOAuthAccount } from "./profile-iHw1uu32.js";
|
|
12
|
+
import { i as lookupSlackUserProfile } from "./users-Cb9c1k9q.js";
|
|
13
|
+
import { a as wakePausedTurn, i as wakeAuthorizedTurn } from "./turn-wake-C7HeLHAM.js";
|
|
14
|
+
import { s as readConnectedOAuthTokens, t as escapeHtml, u as htmlCallbackResponse } from "./html-9_pS9SjY.js";
|
|
15
|
+
import { n as relayLocalOAuthCallback } from "./oauth-relay-BvHFH0fV.js";
|
|
11
16
|
import * as z from "zod";
|
|
12
17
|
import path from "node:path";
|
|
13
|
-
import { createHmac, createSecretKey, timingSafeEqual } from "node:crypto";
|
|
14
18
|
import { pluginStoredTokensSchema } from "@sentry/junior-plugin-api";
|
|
19
|
+
import { createHmac, createSecretKey, timingSafeEqual } from "node:crypto";
|
|
15
20
|
import fs from "node:fs";
|
|
16
21
|
// src/handlers/mcp-oauth-callback.ts
|
|
17
22
|
/**
|
|
@@ -495,7 +500,7 @@ async function GET(request, provider, waitUntil, options) {
|
|
|
495
500
|
const clientId = process.env[providerConfig.clientIdEnv]?.trim();
|
|
496
501
|
const clientSecret = process.env[providerConfig.clientSecretEnv]?.trim();
|
|
497
502
|
if (!clientId || !clientSecret) return htmlErrorResponse("Configuration error", "OAuth client credentials are not configured on the server.", 500);
|
|
498
|
-
const baseUrl =
|
|
503
|
+
const baseUrl = getChatConfig().deployment.baseUrl;
|
|
499
504
|
if (!baseUrl) return htmlErrorResponse("Configuration error", "The server cannot determine its base URL.", 500);
|
|
500
505
|
const redirectUri = `${baseUrl}${providerConfig.callbackPath}`;
|
|
501
506
|
const requestedScope = stored.scope ?? providerConfig.scope;
|
|
@@ -639,7 +644,7 @@ const localCredentialSyncSchema = z.object({
|
|
|
639
644
|
tokens: pluginStoredTokensSchema
|
|
640
645
|
}).strict();
|
|
641
646
|
function syncSecret() {
|
|
642
|
-
const secret =
|
|
647
|
+
const secret = getChatConfig().secrets.juniorSecret;
|
|
643
648
|
if (!secret) throw new Error("Local credential sync requires JUNIOR_SECRET");
|
|
644
649
|
return secret;
|
|
645
650
|
}
|
|
@@ -661,7 +666,7 @@ async function syncLocalOAuthCredential(provider, tokens) {
|
|
|
661
666
|
provider,
|
|
662
667
|
tokens
|
|
663
668
|
});
|
|
664
|
-
const port =
|
|
669
|
+
const { port } = getChatConfig().development;
|
|
665
670
|
const response = await fetch(`http://127.0.0.1:${port}/api/internal/local-oauth-credentials`, {
|
|
666
671
|
method: "POST",
|
|
667
672
|
headers: {
|
|
@@ -675,7 +680,7 @@ async function syncLocalOAuthCredential(provider, tokens) {
|
|
|
675
680
|
/** Verify and store one credential sent by the local CLI over loopback. */
|
|
676
681
|
async function receiveLocalOAuthCredential(request) {
|
|
677
682
|
const hostname = new URL(request.url).hostname;
|
|
678
|
-
if (
|
|
683
|
+
if (!getChatConfig().development.enabled || hostname !== "127.0.0.1" && hostname !== "localhost") return new Response(null, { status: 404 });
|
|
679
684
|
const body = await request.text();
|
|
680
685
|
const actualSignature = request.headers.get("x-junior-local-credential-signature");
|
|
681
686
|
if (!actualSignature || !signaturesMatch(signature(body), actualSignature)) return Response.json({ error: "Unauthorized" }, { status: 401 });
|