@sentry/junior 0.317.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-CAugg87B.js → admin-UOHix_5P.js} +1 -1
- package/dist/{agent-runner-AjrEV6Qe.js → agent-runner-DeYymwh2.js} +183 -113
- package/dist/{agent-update-delivery-B_YIZcgf.js → agent-update-delivery-DH8bx7jU.js} +5 -5
- package/dist/api/schema.d.ts +42 -28
- package/dist/api/schema.js +3 -3
- package/dist/api.js +38 -41
- package/dist/{app-MoNAsVV5.d.ts → app-DKAOuaoC.d.ts} +4 -9
- package/dist/app.d.ts +1 -1
- package/dist/app.js +62 -91
- package/dist/{thread-context-CqZDKErp.js → auth-pause-state-f9hJM_zO.js} +6 -59
- package/dist/{catalog-runtime-DfSpJZdY.js → catalog-runtime-BfdAnztW.js} +1 -1
- package/dist/{channel-access-j-YAVYK4.js → channel-access-A0de5lRv.js} +1 -1
- package/dist/{chat-core-engine-aH85nEHv.js → chat-core-engine-D3Wd7f5n.js} +6 -6
- package/dist/{child-message-DHjQLEd1.js → child-message-peFWLcCZ.js} +1 -5
- package/dist/cli/chat.js +32 -24
- package/dist/cli/check.js +4 -4
- package/dist/cli/main.js +2 -2
- package/dist/cli/plugins.js +4 -4
- package/dist/cli/snapshot-create.js +4 -5
- package/dist/cli/upgrade.js +3 -3
- package/dist/context-BKF_5zzI.js +1833 -0
- package/dist/{continue-in-slack-D-FZ8Fin.js → continue-in-slack-YxwMQVeR.js} +3 -2
- package/dist/{conversation-feed--9S0_PXL.js → conversation-feed-Cj7IuBtM.js} +1 -1
- package/dist/{conversation-privacy-B1uXn5sf.js → conversation-privacy-Cr_dNW1p.js} +1 -1
- package/dist/{conversation-turn-BUE_7xaN.js → conversation-turn-Bru4w_FD.js} +111 -18
- package/dist/{create-DoDIYgtZ.js → create-Btl1y1rq.js} +13 -15
- package/dist/{credential-sync-BJOqGnjV.js → credential-sync-DTarZ63K.js} +17 -17
- package/dist/{db-BFmyYZtJ.js → db-of6e3sGt.js} +1943 -1189
- package/dist/{deployment-DXq9ZLU4.js → deployment-C0qXa0FD.js} +1 -1
- package/dist/{engine-context-CgQ7mlHt.js → engine-context-C_QL_bMQ.js} +52 -21
- package/dist/{html-B3VKTGbJ.js → html-9_pS9SjY.js} +6 -6
- package/dist/instrumentation.js +2 -2
- package/dist/{job-runner-A1lCkybD.js → job-runner-B2XEvpif.js} +11 -12
- package/dist/{lineage-Bktb0UcV.js → lineage-nh4z9iQN.js} +1 -1
- package/dist/{list-Bxvg5wXf.js → list-HRP3TIRl.js} +45 -37
- package/dist/{logging--smS7XRK.js → logging-BnOG0qz2.js} +3 -49
- package/dist/{mailbox-turn-uSXhUFc9.js → mailbox-turn-Byrry9o1.js} +220 -223
- package/dist/{parent-result-Ck1rFYRQ.js → markers-CTTtJqYn.js} +84 -52
- package/dist/{message-BNenhsmB.js → message-BRUuLgrY.js} +9 -10
- package/dist/{model-input-BReSnwHp.js → model-input-CFC62mf-.js} +2 -2
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +4 -4
- package/dist/{oauth-callback-server-CE4soEIY.js → oauth-callback-server-CjnnUr4o.js} +2 -2
- package/dist/{oauth-relay-C36gX1gH.js → oauth-relay-BvHFH0fV.js} +1 -1
- package/dist/{profile-BQ-iBDsZ.js → profile-iHw1uu32.js} +7 -7
- package/dist/{prompt-Dv7gkpD6.js → prompt-DEkStuxG.js} +10 -10
- package/dist/{registry-iXMT5Jmh.js → registry-Cl7Labpe.js} +7 -7
- package/dist/{reports-WKHfGTsU.js → reports-C1d9azyV.js} +2 -2
- package/dist/{resolve-tony4ibz.js → resolve-DC6zBuDV.js} +5 -5
- package/dist/{result-Bta_dlWa.js → result-DxewDuXb.js} +12 -12
- package/dist/{run-conversation-DL6ru7iW.js → run-conversation-Cz2ubZK-.js} +6 -5
- package/dist/{runner-BstDRbD9.js → runner-99YxVN_r.js} +10 -18
- package/dist/{sandbox-egress-signals-oSJMJOnn.js → sandbox-egress-signals-CgoX5CTI.js} +1 -1
- package/dist/{schema-DfqrHACA.js → schema-BTojNBr5.js} +2 -2
- package/dist/{sender-actors-CPglLd5R.js → sender-actors-77zTQbSG.js} +7 -6
- package/dist/{service-account-CTV_jaNu.js → service-account-YDCPSByj.js} +3 -3
- package/dist/{skills-BCEU41zM.js → skills-CleC0Hze.js} +5 -4
- package/dist/{slack-conversation-unfurl-DxVmhbGP.js → slack-conversation-unfurl-BNQLC12R.js} +7 -7
- package/dist/{spawn-frczVPIr.js → spawn-DuZfodPa.js} +7 -10
- package/dist/{system-prompt-table-CiXy0eNR.js → system-prompt-table-Ci6Ck4gk.js} +2 -2
- package/dist/{task-runner-C9Yc2_ae.js → task-runner-BJ9Up3bG.js} +18 -15
- package/dist/{topics-SRN7IVX-.js → topics-BoCkoPJJ.js} +2 -5
- package/dist/{turn-membership-CENFf3kI.js → turn-membership-VT7XZh-L.js} +4 -4
- package/dist/{turn-wake-BhloiI2h.js → turn-wake-C7HeLHAM.js} +4 -4
- package/dist/{types-C4iC-IMC.js → types-DCzTAA63.js} +55 -49
- package/dist/{users-ByG5RCEJ.js → users-Cb9c1k9q.js} +1 -1
- package/dist/{validation-8gjfR91V.js → validation-BiUmWPhy.js} +1 -1
- package/dist/{version-BeZhWWBE.js → version-VEXiEcZu.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{worker-BqMQQNRk.js → worker-ChWYQdhm.js} +5 -5
- 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/config-CHQ8X251.js +0 -2422
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { A as setFirstConversationLocation,
|
|
2
|
-
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";
|
|
3
4
|
import { and, eq } from "drizzle-orm";
|
|
4
5
|
// src/chat/slack/continue-in-slack.ts
|
|
5
6
|
/** Refusal for a move that cannot wait for the active Run. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as actorIdentitySchema, Nt as spaceRefSchema, V as conversationDetailReportSchema, X as conversationSummaryReportSchema, Yt as messageAttachmentSchema, zt as inboxItemChangeRecordSchema } from "./types-
|
|
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;
|
|
@@ -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
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
|
|
2
|
-
import { $
|
|
3
|
-
import { Lt as readConversationAutomationRun, M as measureTurnCompactionWait, q as stopConversationAndChildAgents } from "./agent-runner-
|
|
4
|
-
import {
|
|
5
|
-
import { Xt as readMessageAttachments, wt as instructionProvenanceFor } from "./types-
|
|
6
|
-
import {
|
|
7
|
-
import { At as
|
|
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 { h as getAssistantReplyText } from "./system-prompt-table-
|
|
11
|
-
import { t as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { L as mapBounded } from "./prompt-Dv7gkpD6.js";
|
|
15
|
-
import { t as readConversationLineage } from "./lineage-Bktb0UcV.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
|
|
@@ -833,7 +921,7 @@ function createConversationTurnWorker(agentRunner, deliverMessage, updates) {
|
|
|
833
921
|
const webActor = actor.platform === "web" ? actor : void 0;
|
|
834
922
|
const signInActor = behavior.waitsForSignIn ? webActor : void 0;
|
|
835
923
|
const disabledFeatures = signInActor ? [] : ["interactive-auth"];
|
|
836
|
-
const deliverToProvider = postsToProvider && (behavior.delivery === "location" || !behavior.gated && storedConversation !== void 0 &&
|
|
924
|
+
const deliverToProvider = postsToProvider && (behavior.delivery === "location" || !behavior.gated && storedConversation !== void 0 && isTopLevel(storedConversation));
|
|
837
925
|
const surface = postsToProvider ? "slack" : "api";
|
|
838
926
|
const inputTelemetry = resolved.kind === "mailbox" ? turnInputTelemetry(resolved.batch.map((entry) => entry.message)) : void 0;
|
|
839
927
|
const turnTrace = inputTelemetry ?? (savedTurn?.traceContext ? { traceContexts: [savedTurn.traceContext] } : void 0);
|
|
@@ -985,17 +1073,21 @@ function createConversationTurnWorker(agentRunner, deliverMessage, updates) {
|
|
|
985
1073
|
turnId,
|
|
986
1074
|
runId: currentRunId,
|
|
987
1075
|
instruction: {
|
|
988
|
-
...
|
|
1076
|
+
...await withHeldInput({
|
|
1077
|
+
conversation,
|
|
1078
|
+
conversationId: context.conversationId,
|
|
1079
|
+
turnId
|
|
1080
|
+
}, instructionInputs),
|
|
989
1081
|
...instructionActor ? { actor: instructionActor } : void 0,
|
|
990
1082
|
...childTurn.instruction,
|
|
991
1083
|
storedAttachments: attachments,
|
|
992
|
-
context: await buildTurnThreadContext({
|
|
1084
|
+
context: conversationLocation?.provider === "slack" ? await buildTurnThreadContext({
|
|
993
1085
|
conversation,
|
|
994
1086
|
conversationId: context.conversationId,
|
|
995
1087
|
excludeMessageIds: inputMessageIds,
|
|
996
1088
|
hasHistory: history.messages.length > 0,
|
|
997
1089
|
turnId
|
|
998
|
-
})
|
|
1090
|
+
}) : void 0
|
|
999
1091
|
},
|
|
1000
1092
|
history,
|
|
1001
1093
|
...childTurn.run,
|
|
@@ -1005,6 +1097,7 @@ function createConversationTurnWorker(agentRunner, deliverMessage, updates) {
|
|
|
1005
1097
|
source,
|
|
1006
1098
|
...conversationLocation ? { location: conversationLocation } : void 0,
|
|
1007
1099
|
surface,
|
|
1100
|
+
deadlineAtMs: getTurnRequestDeadline()?.deadlineAtMs,
|
|
1008
1101
|
...stopSignal ? { signal: stopSignal } : void 0,
|
|
1009
1102
|
...signInActor ? { authorization: createWebAuthorization({
|
|
1010
1103
|
actorId: signInActor.userId,
|
|
@@ -1154,4 +1247,4 @@ function createConversationTurnWorker(agentRunner, deliverMessage, updates) {
|
|
|
1154
1247
|
});
|
|
1155
1248
|
};
|
|
1156
1249
|
}
|
|
1157
|
-
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 { I as AgentNameInUseError, L as AgentStoppedError, R as ChildAgentLimitError } from "./agent-runner-
|
|
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,16 +14,14 @@ async function assertCanGiveChildWork(parentConversationId) {
|
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Throw when giving work to one child agent would put its parent over
|
|
17
|
-
* `MAX_ACTIVE_CHILD_AGENTS
|
|
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
24
|
if (active.includes(childConversationId) || active.length < 8) return;
|
|
25
|
-
const parent = await getConversationStore().get({ conversationId: parentConversationId });
|
|
26
|
-
if (parent && !capsActiveChildren(parent.kind)) return;
|
|
27
25
|
throw new ChildAgentLimitError(8);
|
|
28
26
|
}
|
|
29
27
|
/**
|
|
@@ -38,7 +36,7 @@ async function createChildAgentConversation(input, childConversationId, nowMs) {
|
|
|
38
36
|
name: input.agentName,
|
|
39
37
|
parentConversationId: input.parentConversationId
|
|
40
38
|
})) throw new AgentNameInUseError(input.agentName);
|
|
41
|
-
|
|
39
|
+
assertChildAgentCapacity(await listOpenChildAgents(input.parentConversationId), childConversationId);
|
|
42
40
|
await getConversationStore().createChild({
|
|
43
41
|
childConversationId,
|
|
44
42
|
kind: input.kind,
|
|
@@ -205,7 +203,7 @@ async function messageChildAgent(input, options, nowMs = Date.now()) {
|
|
|
205
203
|
}
|
|
206
204
|
await assertCanGiveChildWork(input.parentConversationId);
|
|
207
205
|
const active = await listOpenChildAgents(input.parentConversationId);
|
|
208
|
-
|
|
206
|
+
assertChildAgentCapacity(active, input.childConversationId);
|
|
209
207
|
return {
|
|
210
208
|
delivery: "message",
|
|
211
209
|
value: active.includes(input.childConversationId) ? "queued" : "started"
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { i as finalizeMcpAuthorization } from "./agent-runner-
|
|
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
7
|
import { i as homeDir } from "./package-discovery-DD9vencX.js";
|
|
8
|
-
import { t as discoverSkills } from "./skills-
|
|
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-
|
|
10
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime-
|
|
11
|
-
import { A as createUserTokenStore, I as resolvePluginOAuthAccount } from "./profile-
|
|
12
|
-
import { i as lookupSlackUserProfile } from "./users-
|
|
13
|
-
import { a as wakePausedTurn, i as wakeAuthorizedTurn } from "./turn-wake-
|
|
14
|
-
import { s as readConnectedOAuthTokens, t as escapeHtml, u as htmlCallbackResponse } from "./html-
|
|
15
|
-
import { n as relayLocalOAuthCallback } from "./oauth-relay-
|
|
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";
|
|
16
16
|
import * as z from "zod";
|
|
17
17
|
import path from "node:path";
|
|
18
|
-
import { createHmac, createSecretKey, timingSafeEqual } from "node:crypto";
|
|
19
18
|
import { pluginStoredTokensSchema } from "@sentry/junior-plugin-api";
|
|
19
|
+
import { createHmac, createSecretKey, timingSafeEqual } from "node:crypto";
|
|
20
20
|
import fs from "node:fs";
|
|
21
21
|
// src/handlers/mcp-oauth-callback.ts
|
|
22
22
|
/**
|
|
@@ -666,7 +666,7 @@ async function syncLocalOAuthCredential(provider, tokens) {
|
|
|
666
666
|
provider,
|
|
667
667
|
tokens
|
|
668
668
|
});
|
|
669
|
-
const port =
|
|
669
|
+
const { port } = getChatConfig().development;
|
|
670
670
|
const response = await fetch(`http://127.0.0.1:${port}/api/internal/local-oauth-credentials`, {
|
|
671
671
|
method: "POST",
|
|
672
672
|
headers: {
|
|
@@ -680,7 +680,7 @@ async function syncLocalOAuthCredential(provider, tokens) {
|
|
|
680
680
|
/** Verify and store one credential sent by the local CLI over loopback. */
|
|
681
681
|
async function receiveLocalOAuthCredential(request) {
|
|
682
682
|
const hostname = new URL(request.url).hostname;
|
|
683
|
-
if (
|
|
683
|
+
if (!getChatConfig().development.enabled || hostname !== "127.0.0.1" && hostname !== "localhost") return new Response(null, { status: 404 });
|
|
684
684
|
const body = await request.text();
|
|
685
685
|
const actualSignature = request.headers.get("x-junior-local-credential-signature");
|
|
686
686
|
if (!actualSignature || !signaturesMatch(signature(body), actualSignature)) return Response.json({ error: "Unauthorized" }, { status: 401 });
|