@sentry/junior 0.313.0 → 0.314.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{adapter-CYAvJzZS.js → adapter-JARQvoLw.js} +1 -2
- package/dist/{adapter-context-CVsHoVSf.js → adapter-context-B4BrJZuS.js} +2 -2
- package/dist/{admin-Cyhb4TwZ.js → admin-BXGAySz0.js} +1 -1
- package/dist/{agent-runner-B5y9MsT-.js → agent-runner-qZU5TR8i.js} +797 -118
- package/dist/agent-update-cS7Z9mnG.js +26 -0
- package/dist/agent-update-delivery-CZ5M8RDa.js +85 -0
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +6 -6
- package/dist/api.d.ts +1 -1
- package/dist/api.js +334 -100
- package/dist/{app-DA8-hCMj.d.ts → app-D7tKnw9a.d.ts} +4 -21
- package/dist/app.d.ts +2 -2
- package/dist/app.js +80 -169
- package/dist/{background-compaction-queue-iZXadLV3.js → background-compaction-queue-C_uIBUvS.js} +6 -67
- package/dist/callback-C8SdXCwr.js +68 -0
- package/dist/{catalog-runtime-kkE3hvCX.js → catalog-runtime-BLKtnUL3.js} +1 -1
- package/dist/{channel-access-mt7K6dPh.js → channel-access-BOL29BG3.js} +6 -6
- package/dist/child-message--2G3Ft26.js +19 -0
- package/dist/cli/chat.js +18 -21
- package/dist/cli/check.js +4 -4
- package/dist/cli/main.js +2 -2
- package/dist/cli/plugins.js +5 -5
- package/dist/cli/snapshot-create.js +5 -5
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +23 -4
- package/dist/{config-CWbwKj0j.js → config-BIfHKNXN.js} +40 -35
- package/dist/{continue-in-slack-CxyFzdlF.js → continue-in-slack-fnmD2Ifb.js} +5 -7
- package/dist/{conversation-feed-BEXLD3Me.js → conversation-feed-DdFQuQDR.js} +1 -1
- package/dist/{logging-DNt-qOIO.js → conversation-privacy-DtZhI91r.js} +188 -2
- package/dist/{conversation-turn-B35eu0uz.js → conversation-turn-DScuDYmN.js} +418 -33
- package/dist/create-CrNt4Ewu.js +212 -0
- package/dist/{credential-sync-DWTOEQrm.js → credential-sync-CtqsGjj1.js} +14 -17
- package/dist/{credentialed-Dyv8b-lu.js → credentialed-dWRA3-oJ.js} +910 -426
- package/dist/{db-PwSRzWWn.js → db-BTmLKZrp.js} +2235 -38
- package/dist/{db-DYGcXYl3.d.ts → db-DcmzbA55.d.ts} +2 -2
- package/dist/{history-CYstOMKX.js → history-CneKY7_V.js} +19 -1
- package/dist/{html-DidUcRhI.js → html-B8rBt7F4.js} +5 -7
- package/dist/{install-2urLLXNt.js → install-OtFboxOM.js} +2 -2
- package/dist/instrumentation.js +2 -2
- package/dist/{lineage-BXplQAVH.js → lineage-EULJkGO1.js} +1 -2
- package/dist/{list-DyIyReSV.js → list-C5400AlJ.js} +235 -77
- package/dist/{turn-membership-DTR3SaKD.js → mailbox-turn-DL3Lvsm0.js} +4698 -587
- package/dist/markers-DUP8aBOp.js +323 -0
- package/dist/{media-B0pZJ0bG.js → media-FYM-Bl3H.js} +33 -8
- package/dist/{message-Z5YKC-Af.js → message-DuDelZFr.js} +16 -29
- package/dist/{model-input-BhPJYdSV.js → model-input-0osF3pBS.js} +3 -3
- package/dist/nitro.d.ts +2 -4
- package/dist/nitro.js +340 -13
- package/dist/{oauth-callback-server-ByvDdcdY.js → oauth-callback-server-DX2fQ7Nq.js} +2 -2
- package/dist/{oauth-relay-D-kK0yoN.js → oauth-relay-PwPMdZJv.js} +1 -1
- package/dist/{plugins-Bkk0XRo2.js → plugins-BXMdNdyA.js} +1 -1
- package/dist/{registry-POH4bZC4.js → registry-D6kS6xYH.js} +1402 -64
- package/dist/{resolve-CWtBNSKP.js → resolve-D8CPJcNK.js} +3 -3
- package/dist/result-D090hxr5.js +402 -0
- package/dist/{runner-CsZ_VRxp.js → runner-BU7fgrm-.js} +7 -8
- package/dist/{sandbox-egress-signals-FbCk1FkN.js → sandbox-egress-signals-BUmVrsoG.js} +1 -1
- package/dist/{schema-DojR2uCL.js → schema-7gW9vBpJ.js} +90 -9
- package/dist/{schema-DBf18QPS.d.ts → schema-BB6E0wyV.d.ts} +138 -5
- package/dist/{service-account-CDYb9hfX.js → service-account-plA-uzIB.js} +6 -5
- package/dist/{skills-B0jP4whm.js → skills-CIosT6bS.js} +3 -3
- package/dist/{slack-conversation-unfurl-D26t9kBC.js → slack-conversation-unfurl-CBgZqth6.js} +8 -10
- package/dist/{spawn-BjljgExZ.js → spawn-DRjdzh3R.js} +9 -17
- package/dist/{start-conversation-DbVujrwO.js → start-conversation-a4NXH4X9.js} +12 -15
- package/dist/{store-CjXrp-Up.js → store-BuhF1QDm.js} +2 -4
- package/dist/{task-queue-Cwlatjz3.js → task-queue-CrRjFzOh.js} +5 -16
- package/dist/{task-runner--Ke8KSMf.js → task-runner-C-pXsgHM.js} +104 -50
- package/dist/{thread-context-B8exINEe.js → thread-context-CDX4dSZd.js} +8 -9
- package/dist/turn-session-routing-CZTRU8IY.js +116 -0
- package/dist/turn-wake-Bzq1Efrm.js +154 -0
- package/dist/user-customization-B27StpVQ.js +9 -0
- package/dist/{validation-Ce0qbMlT.js → validation-bTq88sya.js} +1 -1
- package/dist/{vercel-queue-q4z8w5QO.js → vercel-queue-nL0Hq3hr.js} +32 -147
- package/dist/{version-DFh4n9nr.js → version-DGUa1dZK.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{warmup-D5hzqTcp.js → warmup-CCOuIwAS.js} +639 -137
- package/dist/{worker-CDg9Lbpg.js → worker-AkZg7Dg1.js} +5 -6
- package/migrations/0160_money_micro_usd_repair.sql +99 -0
- package/migrations/0161_agent_config_backfill.sql +34 -0
- package/migrations/0162_inbox_item_deliveries.sql +15 -0
- package/migrations/0163_pg_trgm.sql +2 -0
- package/migrations/0164_search_indexes.sql +4 -0
- package/migrations/0165_drop_legacy_archive_columns.sql +4 -0
- package/migrations/0166_memory_prefix_index.sql +1 -0
- package/migrations/0167_todo_search_indexes.sql +2 -0
- package/migrations/0168_todo_inbox_items.sql +4 -0
- package/migrations/0169_drop_code_urls.sql +2 -0
- package/migrations/meta/0160_snapshot.json +6515 -0
- package/migrations/meta/0161_snapshot.json +6278 -0
- package/migrations/meta/0162_snapshot.json +6404 -0
- package/migrations/meta/0163_snapshot.json +6404 -0
- package/migrations/meta/0164_snapshot.json +6466 -0
- package/migrations/meta/0165_snapshot.json +6466 -0
- package/migrations/meta/0166_snapshot.json +6494 -0
- package/migrations/meta/0167_snapshot.json +6525 -0
- package/migrations/meta/0168_snapshot.json +6525 -0
- package/migrations/meta/0169_snapshot.json +6513 -0
- package/migrations/meta/_journal.json +70 -0
- package/package.json +9 -18
- package/skills/design-automation-skill/SKILL.md +2 -3
- package/dist/actor-BsBdxDXQ.js +0 -208
- package/dist/conversation-privacy-BrMiDN61.js +0 -189
- package/dist/executor-CgWyWfYz.js +0 -1858
- package/dist/fan-out-Cod-yEHG.js +0 -10
- package/dist/ingest-B0AggUEC.js +0 -7931
- package/dist/request-deadline-BUiRYQYj.js +0 -24
- package/dist/service-account-o15pZWcJ.js +0 -931
- package/dist/state-BTawTCme.js +0 -161
- package/dist/statuses-BKwqCPhj.js +0 -69
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { m as sameActorIdentity } from "./history-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { Q as conversationReportMessageEventSchema, St as readMessageCardRefs, Z as conversationReportEventSchema, kt as readMessageAttachments, vt as inboxItemChangeRecordSchema } from "./media-B0pZJ0bG.js";
|
|
2
|
+
import { $n as resolveRootVisibility, Ct as instructionTextForProjection, Dt as isToolResultError, Es as completeObject, Gn as createPluginModelCostRecorder, Gt as createPluginState, Is as renderJuniorNativeConversationEvent, Jn as renderPluginConversationEvent, Kn as createPluginTurnEventReader, Ot as isToolResultMessage, Qn as writeConversationMetadata, Rr as createPluginLogger, Un as createPluginEmbedder, Wn as createPluginModel, Zn as readConversationMetadata, bt as getUserMessageInstructionText, g as getRegistrations, h as getPlugins, jt as stripRuntimeTurnContext, kt as normalizeToolNameFromResult, lr as listConversationAnnotations, qn as createPluginConversationEvents, qr as getDispatchRecord, rr as storeConversationEmbedding, tr as createConversationEmbedder, vt as getPiMessageRole, ws as createPluginCache } from "./credentialed-dWRA3-oJ.js";
|
|
3
|
+
import { Ar as juniorConversationEvents, Br as juniorConversations, Fr as juniorCodeChanges, I as hasConversationMetadata, Ir as juniorCodeRepositories, Kn as hasAgentTurnUsage, M as createSqlStore, Xt as readActorIdentity, a as getDb, bi as parseSlackMessageTs, f as eventFromRow, i as getConversationStore, o as getSqlExecutor } from "./db-BTmLKZrp.js";
|
|
4
|
+
import { C as logInfo, F as withSpan, Q as buildSentryEventUrl, m as extractGenAiUsageSummary } from "./conversation-privacy-DtZhI91r.js";
|
|
5
|
+
import { D as isInheritedForkHistory, Si as loadTurnStart, dr as hydrateConversationMessages, ei as getTurnRecord, gt as getPersistedThreadState, kr as isEventAuthorId, m as isParentMessageAuthor, yt as coerceThreadConversationState } from "./mailbox-turn-DL3Lvsm0.js";
|
|
6
|
+
import { i as savedTurnMessages, t as resolveConversationRouting } from "./turn-session-routing-CZTRU8IY.js";
|
|
7
|
+
import { m as sameActorIdentity } from "./history-CneKY7_V.js";
|
|
8
|
+
import { gt as mapBounded, n as botConfig, z as withLock } from "./config-BIfHKNXN.js";
|
|
9
|
+
import { i as getStateAdapter } from "./adapter-JARQvoLw.js";
|
|
10
|
+
import { b as matchSlackAttachments, n as startConversationToolDefinition } from "./start-conversation-a4NXH4X9.js";
|
|
11
|
+
import { Q as conversationReportMessageEventSchema, St as readMessageCardRefs, Z as conversationReportEventSchema, kt as readMessageAttachments, vt as inboxItemChangeRecordSchema } from "./media-FYM-Bl3H.js";
|
|
13
12
|
import { h as startSpan } from "./sentry-CPbZjomA.js";
|
|
14
|
-
import { i as pluginTaskParamsSchema, r as pluginTaskId } from "./task-queue-
|
|
15
|
-
import { t as mapBounded } from "./fan-out-Cod-yEHG.js";
|
|
13
|
+
import { i as pluginTaskParamsSchema, r as pluginTaskId } from "./task-queue-CrRjFzOh.js";
|
|
16
14
|
import * as z from "zod";
|
|
17
15
|
import { objectTypeSchema, pluginRunContextSchema, renderTag, tagJson } from "@sentry/junior-plugin-api";
|
|
18
|
-
import { and, arrayContains, asc, desc, eq, getTableColumns, gt, inArray,
|
|
16
|
+
import { and, arrayContains, asc, desc, eq, getTableColumns, gt, inArray, lt, max, sql } from "drizzle-orm";
|
|
19
17
|
import { alias } from "drizzle-orm/pg-core";
|
|
20
18
|
// src/chat/conversations/metadata/generate.ts
|
|
21
19
|
const MAX_INPUT_CHARS = 6e4;
|
|
@@ -60,8 +58,6 @@ function promptInput(args) {
|
|
|
60
58
|
const entries = boundedEntries(args.input.entries);
|
|
61
59
|
const messages = entries.filter((entry) => entry.role !== "tool");
|
|
62
60
|
const tools = entries.filter((entry) => entry.role === "tool");
|
|
63
|
-
const keptMessages = [...messages];
|
|
64
|
-
const keptTools = [];
|
|
65
61
|
const base = {
|
|
66
62
|
conversation: {
|
|
67
63
|
title: args.input.title,
|
|
@@ -72,29 +68,45 @@ function promptInput(args) {
|
|
|
72
68
|
codeChanges: args.input.codeChanges,
|
|
73
69
|
resources: args.input.resources
|
|
74
70
|
};
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
let
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
71
|
+
const emptyLength = tagJson({
|
|
72
|
+
...base,
|
|
73
|
+
omitted: {
|
|
74
|
+
messages: 0,
|
|
75
|
+
toolResults: 0
|
|
76
|
+
},
|
|
77
|
+
entries: []
|
|
78
|
+
}).length;
|
|
79
|
+
const lengthOf = (keptMessages, keptTools, entryChars) => emptyLength - 2 + String(messages.length - keptMessages).length + String(tools.length - keptTools).length + entryChars + Math.max(0, keptMessages + keptTools - 1);
|
|
80
|
+
const entryLength = (entry) => tagJson(entry).length;
|
|
81
|
+
const messageLengths = messages.map(entryLength);
|
|
82
|
+
let messageChars = messageLengths.reduce((sum, length) => sum + length, 0);
|
|
83
|
+
let firstKeptMessage = 0;
|
|
84
|
+
while (firstKeptMessage < messages.length && lengthOf(messages.length - firstKeptMessage, 0, messageChars) > MAX_INPUT_CHARS) {
|
|
85
|
+
messageChars -= messageLengths[firstKeptMessage];
|
|
86
|
+
firstKeptMessage += 1;
|
|
90
87
|
}
|
|
91
|
-
|
|
88
|
+
const keptMessageCount = messages.length - firstKeptMessage;
|
|
89
|
+
if (lengthOf(keptMessageCount, 0, messageChars) > MAX_INPUT_CHARS) throw new Error("Conversation metadata input exceeds the 60,000 character limit");
|
|
90
|
+
const kept = new Set(messages.slice(firstKeptMessage));
|
|
91
|
+
let keptToolCount = 0;
|
|
92
|
+
let entryChars = messageChars;
|
|
92
93
|
for (let index = tools.length - 1; index >= 0; index -= 1) {
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
if (
|
|
96
|
-
|
|
94
|
+
const tool = tools[index];
|
|
95
|
+
const length = entryLength(tool);
|
|
96
|
+
if (lengthOf(keptMessageCount, keptToolCount + 1, entryChars + length) <= MAX_INPUT_CHARS) {
|
|
97
|
+
kept.add(tool);
|
|
98
|
+
keptToolCount += 1;
|
|
99
|
+
entryChars += length;
|
|
100
|
+
}
|
|
97
101
|
}
|
|
102
|
+
const text = tagJson({
|
|
103
|
+
...base,
|
|
104
|
+
omitted: {
|
|
105
|
+
messages: messages.length - keptMessageCount,
|
|
106
|
+
toolResults: tools.length - keptToolCount
|
|
107
|
+
},
|
|
108
|
+
entries: entries.filter((entry) => kept.has(entry))
|
|
109
|
+
});
|
|
98
110
|
return [renderTag("conversation-metadata-input", {}, [text]), "Return the next summary as structured data."].join("\n");
|
|
99
111
|
}
|
|
100
112
|
/** Generate the next summary of one Conversation. */
|
|
@@ -257,6 +269,16 @@ function reportMessageActorIdentity(data) {
|
|
|
257
269
|
};
|
|
258
270
|
return Object.keys(actorIdentity).length > 0 ? actorIdentity : void 0;
|
|
259
271
|
}
|
|
272
|
+
/**
|
|
273
|
+
* Mark a child's input that its parent agent wrote, so the dashboard does not
|
|
274
|
+
* show the person who started the root as its author. Rows from before
|
|
275
|
+
* parent messages store the id of the work that wrote them. A parent message
|
|
276
|
+
* is named by its own id.
|
|
277
|
+
*/
|
|
278
|
+
function reportParentAgentInput(message) {
|
|
279
|
+
if (typeof message.agentInvocationId === "string") return { agentInvocationId: message.agentInvocationId };
|
|
280
|
+
return isParentMessageAuthor({ userId: message.authorUserId }) ? { agentInvocationId: message.messageId } : void 0;
|
|
281
|
+
}
|
|
260
282
|
/** Project native assistant tool calls through the existing reporting shape. */
|
|
261
283
|
function reportToolCalls(args) {
|
|
262
284
|
const message = reportingAssistantMessageSchema.safeParse(args.message);
|
|
@@ -395,11 +417,17 @@ function reportEventData(args) {
|
|
|
395
417
|
...data.meta?.["source"] === "web" || data.meta?.["source"] === "slack" ? { source: data.meta["source"] } : void 0,
|
|
396
418
|
...actorIdentity ? { actorIdentity } : void 0,
|
|
397
419
|
...args.canExposePayload && data.role === "user" && data.authorIdentityId && data.authorIdentityId !== "system" ? { actorIdentityId: data.authorIdentityId } : void 0,
|
|
398
|
-
...
|
|
420
|
+
...reportParentAgentInput({
|
|
421
|
+
agentInvocationId: data.meta?.["agentInvocationId"],
|
|
422
|
+
authorUserId: reportingMessageAuthorSchema.safeParse(data.meta?.["author"]).data?.userId,
|
|
423
|
+
messageId: data.messageId
|
|
424
|
+
}),
|
|
399
425
|
...args.canExposePayload ? reportInboxItemChanges(data.meta) : void 0,
|
|
400
426
|
eventObjectType: objectTypeSchema.safeParse(data.meta?.["eventObjectType"]).data,
|
|
401
427
|
...typeof data.meta?.["eventType"] === "string" ? { eventType: data.meta["eventType"] } : void 0,
|
|
402
428
|
...typeof data.meta?.["eventNamespace"] === "string" ? { eventNamespace: data.meta["eventNamespace"] } : void 0,
|
|
429
|
+
...typeof data.meta?.["eventStatus"] === "string" ? { eventStatus: data.meta["eventStatus"] } : void 0,
|
|
430
|
+
...typeof data.meta?.["eventWatchId"] === "string" ? { eventWatchId: data.meta["eventWatchId"] } : void 0,
|
|
403
431
|
...args.canExposePayload && typeof data.meta?.["eventIdentifier"] === "string" ? { eventIdentifier: data.meta["eventIdentifier"] } : void 0,
|
|
404
432
|
...typeof data.meta?.["explicitMention"] === "boolean" ? { explicitMention: data.meta["explicitMention"] } : void 0,
|
|
405
433
|
...data.meta?.["quiet"] === true ? { quiet: true } : void 0,
|
|
@@ -831,6 +859,28 @@ async function readConversationMessageEventSeq(executor, conversationId, message
|
|
|
831
859
|
const [row] = await executor.db().select({ seq: juniorConversationEvents.seq }).from(juniorConversationEvents).where(and(eq(juniorConversationEvents.conversationId, conversationId), eq(juniorConversationEvents.type, "message"), sql`${juniorConversationEvents.payload}->>'messageId' = ${messageId}`)).orderBy(asc(juniorConversationEvents.seq)).limit(1);
|
|
832
860
|
return row?.seq;
|
|
833
861
|
}
|
|
862
|
+
// src/chat/code/links.ts
|
|
863
|
+
function codeLinks(provider) {
|
|
864
|
+
return getPlugins().find((plugin) => plugin.manifest.name === provider)?.codeLinks;
|
|
865
|
+
}
|
|
866
|
+
/** Providers whose installed plugin builds code links. */
|
|
867
|
+
function linkedCodeProviders() {
|
|
868
|
+
return getPlugins().flatMap((plugin) => plugin.codeLinks ? [plugin.manifest.name] : []);
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* Build the web page of one code change from its repository and number.
|
|
872
|
+
* Undefined when no installed plugin builds links for the provider.
|
|
873
|
+
*/
|
|
874
|
+
function codeChangeUrl(change) {
|
|
875
|
+
return codeLinks(change.provider)?.change(change);
|
|
876
|
+
}
|
|
877
|
+
/**
|
|
878
|
+
* Build the web page of one repository from its name. Undefined when no
|
|
879
|
+
* installed plugin builds links for the provider.
|
|
880
|
+
*/
|
|
881
|
+
function codeRepositoryUrl(repository) {
|
|
882
|
+
return codeLinks(repository.provider)?.repository(repository.name);
|
|
883
|
+
}
|
|
834
884
|
// src/chat/conversations/transcript-entries.ts
|
|
835
885
|
const TOOL_TEXT_LIMIT = 1500;
|
|
836
886
|
function actorIdentityKey(actor) {
|
|
@@ -953,11 +1003,11 @@ async function conversationMetadataInputFromSql(executor, conversationId, throug
|
|
|
953
1003
|
closedAt: juniorCodeChanges.closedAt,
|
|
954
1004
|
mergedAt: juniorCodeChanges.mergedAt,
|
|
955
1005
|
number: juniorCodeChanges.number,
|
|
1006
|
+
provider: juniorCodeChanges.provider,
|
|
956
1007
|
repository: juniorCodeRepositories.name,
|
|
957
1008
|
state: juniorCodeChanges.state,
|
|
958
|
-
title: juniorCodeChanges.title
|
|
959
|
-
|
|
960
|
-
}).from(juniorCodeChanges).innerJoin(juniorCodeRepositories, eq(juniorCodeRepositories.id, juniorCodeChanges.repositoryId)).where(and(arrayContains(juniorCodeChanges.conversationIds, [conversationId]), isNotNull(juniorCodeChanges.url)))
|
|
1009
|
+
title: juniorCodeChanges.title
|
|
1010
|
+
}).from(juniorCodeChanges).innerJoin(juniorCodeRepositories, eq(juniorCodeRepositories.id, juniorCodeChanges.repositoryId)).where(arrayContains(juniorCodeChanges.conversationIds, [conversationId]))
|
|
961
1011
|
]);
|
|
962
1012
|
const location = conversation.location;
|
|
963
1013
|
return {
|
|
@@ -968,15 +1018,19 @@ async function conversationMetadataInputFromSql(executor, conversationId, throug
|
|
|
968
1018
|
...conversation.channelName ? { channelName: conversation.channelName } : void 0
|
|
969
1019
|
} } : void 0,
|
|
970
1020
|
entries: transcriptEntriesFromReportEvents(events),
|
|
971
|
-
codeChanges: codeChanges.
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
1021
|
+
codeChanges: codeChanges.flatMap((change) => {
|
|
1022
|
+
const url = codeChangeUrl(change);
|
|
1023
|
+
if (!url) return [];
|
|
1024
|
+
return [{
|
|
1025
|
+
repository: change.repository,
|
|
1026
|
+
number: change.number,
|
|
1027
|
+
...change.title ? { title: change.title } : void 0,
|
|
1028
|
+
url,
|
|
1029
|
+
state: change.state,
|
|
1030
|
+
...change.mergedAt ? { mergedAt: change.mergedAt.toISOString() } : void 0,
|
|
1031
|
+
...change.closedAt ? { closedAt: change.closedAt.toISOString() } : void 0
|
|
1032
|
+
}];
|
|
1033
|
+
}),
|
|
980
1034
|
resources: annotations.flatMap((annotation) => annotation.url ? [{
|
|
981
1035
|
label: annotation.kind === "object" && annotation.title !== annotation.label ? `${annotation.label} · ${annotation.title}` : annotation.label,
|
|
982
1036
|
url: annotation.url,
|
|
@@ -1429,4 +1483,4 @@ async function processPluginTask(message, options = {}) {
|
|
|
1429
1483
|
"app.plugin.task": message.name
|
|
1430
1484
|
});
|
|
1431
1485
|
}
|
|
1432
|
-
export {
|
|
1486
|
+
export { codeChangeUrl as a, readConversationEventPage as c, readConversationLastEventSeq as d, readConversationMessageEventSeq as f, transcriptEntriesFromReportEvents as i, readConversationEventPageAfter as l, scheduleSessionCompletedPluginTasks as n, codeRepositoryUrl as o, reportParentAgentInput as p, task_runner_exports as r, linkedCodeProviders as s, processPluginTask as t, readConversationEventPageAround as u };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { Ct as removedCardSchema, St as readMessageCardRefs, wt as resolveMessageCards } from "./media-
|
|
7
|
-
import {
|
|
1
|
+
import { lr as listConversationAnnotations } from "./credentialed-dWRA3-oJ.js";
|
|
2
|
+
import { gt as mapBounded } from "./config-BIfHKNXN.js";
|
|
3
|
+
import { k as setSpanAttributes } from "./conversation-privacy-DtZhI91r.js";
|
|
4
|
+
import { a as getDb, n as getConversationEventStore } from "./db-BTmLKZrp.js";
|
|
5
|
+
import { $ as getTurnUserMessageId, Bt as getConversationWorkState, Wr as clearPendingAuth, dr as hydrateConversationMessages, dt as markTurnCompleted, gr as buildConversationContext, gt as getPersistedThreadState, ut as markTurnClosed, vt as persistThreadStateById, xr as markConversationMessage, yt as coerceThreadConversationState } from "./mailbox-turn-DL3Lvsm0.js";
|
|
6
|
+
import { Ct as removedCardSchema, St as readMessageCardRefs, wt as resolveMessageCards } from "./media-FYM-Bl3H.js";
|
|
7
|
+
import { n as listChildMessages } from "./child-message--2G3Ft26.js";
|
|
8
8
|
// src/chat/conversations/pending-cards.ts
|
|
9
9
|
/**
|
|
10
10
|
* Add the cards that tool results selected since the last visible assistant
|
|
@@ -48,12 +48,11 @@ async function selectChildResultCards(conversationId, inputMessageIds, selection
|
|
|
48
48
|
if (inputMessageIds.length === 0) return;
|
|
49
49
|
const events = getConversationEventStore();
|
|
50
50
|
const execution = (await getConversationWorkState({ conversationId }))?.execution;
|
|
51
|
-
const messages =
|
|
51
|
+
const messages = listChildMessages(inputMessageIds, execution?.messageSenders ?? {});
|
|
52
52
|
messages.reverse();
|
|
53
53
|
const terminals = await mapBounded(messages, ({ sender }) => events.loadByIdempotencyKey(sender.conversationId, `turn:${sender.turnId}:terminal`));
|
|
54
54
|
for (const [index, message] of messages.entries()) {
|
|
55
55
|
const terminal = terminals[index];
|
|
56
|
-
if (!terminal && isAgentInvocationResult(message)) continue;
|
|
57
56
|
await selectTurnCards(message.sender.conversationId, selection, terminal?.seq);
|
|
58
57
|
}
|
|
59
58
|
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { Wr as getDispatchConversationId, qr as getDispatchRecord } from "./credentialed-dWRA3-oJ.js";
|
|
2
|
+
// src/chat/task-execution/turn-membership.ts
|
|
3
|
+
/** True when the committed message at `seq` belongs to the Turn. */
|
|
4
|
+
function isTurnMessage(start, seq, message) {
|
|
5
|
+
return seq > start.seq && message.role !== "system";
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The messages of a saved Turn with their provenance. Without a
|
|
9
|
+
* `turn_started` event, nothing tells this Turn from earlier history, so it
|
|
10
|
+
* has no messages.
|
|
11
|
+
*/
|
|
12
|
+
function savedTurnMessages(record, start) {
|
|
13
|
+
if (!start) return [];
|
|
14
|
+
return record.piMessages.flatMap((message, index) => {
|
|
15
|
+
const seq = record.piMessageSeqs[index];
|
|
16
|
+
return seq !== void 0 && isTurnMessage(start, seq, message) ? [{
|
|
17
|
+
message,
|
|
18
|
+
provenance: record.piMessageProvenance[index] ?? { authority: "context" }
|
|
19
|
+
}] : [];
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
// src/chat/services/turn-session-routing.ts
|
|
23
|
+
async function loadConversationChain(conversationId, conversationStore) {
|
|
24
|
+
const chain = [];
|
|
25
|
+
const seen = /* @__PURE__ */ new Set();
|
|
26
|
+
let cursor = conversationId;
|
|
27
|
+
while (cursor && !seen.has(cursor)) {
|
|
28
|
+
seen.add(cursor);
|
|
29
|
+
const conversation = await conversationStore.get({ conversationId: cursor });
|
|
30
|
+
if (!conversation) break;
|
|
31
|
+
chain.push(conversation);
|
|
32
|
+
cursor = conversation.parentConversationId;
|
|
33
|
+
}
|
|
34
|
+
return chain;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Normalize a stored Slack session source against the conversation destination.
|
|
38
|
+
*
|
|
39
|
+
* Does not create channel or thread values from the conversation id.
|
|
40
|
+
*/
|
|
41
|
+
function slackSourceForDestination(args) {
|
|
42
|
+
if (args.source?.kind !== "slack" || args.source.channelId !== args.destination.channelId) return;
|
|
43
|
+
const threadTs = args.source.threadTs?.trim();
|
|
44
|
+
return {
|
|
45
|
+
kind: "slack",
|
|
46
|
+
visibility: args.source.visibility ?? "public",
|
|
47
|
+
teamId: args.source.teamId?.trim() || args.destination.teamId,
|
|
48
|
+
channelId: args.source.channelId,
|
|
49
|
+
...threadTs ? { threadTs } : void 0
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Resolve the Conversation Location, Destination, and session Source.
|
|
54
|
+
*
|
|
55
|
+
* Reads parent Conversations when this Conversation has no Destination.
|
|
56
|
+
*/
|
|
57
|
+
async function resolveConversationRouting(args) {
|
|
58
|
+
const conversationStore = args.conversationStore ?? (await import("./db-BTmLKZrp.js").then((n) => n.t)).getConversationStore();
|
|
59
|
+
const chain = await loadConversationChain(args.conversationId, conversationStore);
|
|
60
|
+
let destination;
|
|
61
|
+
let source;
|
|
62
|
+
let location;
|
|
63
|
+
for (const conversation of chain) {
|
|
64
|
+
destination ??= conversation.destination;
|
|
65
|
+
source ??= conversation.sessionSource;
|
|
66
|
+
location ??= conversation.location;
|
|
67
|
+
if (destination && source) break;
|
|
68
|
+
}
|
|
69
|
+
if (!destination) return;
|
|
70
|
+
if (destination.platform === "slack") {
|
|
71
|
+
const slackSource = slackSourceForDestination({
|
|
72
|
+
destination,
|
|
73
|
+
source
|
|
74
|
+
});
|
|
75
|
+
return {
|
|
76
|
+
destination,
|
|
77
|
+
...location ? { location } : void 0,
|
|
78
|
+
...slackSource ? { source: slackSource } : void 0
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
destination,
|
|
83
|
+
...location ? { location } : void 0,
|
|
84
|
+
...source ? { source } : void 0
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/** Require the Conversation Destination and Source from SQL. */
|
|
88
|
+
async function resolveTurnSessionRouting(args) {
|
|
89
|
+
const routing = await resolveConversationRouting(args);
|
|
90
|
+
if (!routing?.destination || !routing.source) throw new Error(`Conversation ${args.conversationId} is missing durable routing metadata`);
|
|
91
|
+
return {
|
|
92
|
+
destination: routing.destination,
|
|
93
|
+
...routing.location ? { location: routing.location } : void 0,
|
|
94
|
+
source: routing.source
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Require the Destination and Source to resume a Turn.
|
|
99
|
+
*
|
|
100
|
+
* A dispatch Conversation stores the dispatch Source, which has no session
|
|
101
|
+
* Source. Its dispatch record owns the Destination and Source.
|
|
102
|
+
*/
|
|
103
|
+
async function resolveTurnResumeRouting(args) {
|
|
104
|
+
if (!args.dispatchId) return await resolveTurnSessionRouting(args);
|
|
105
|
+
const dispatch = await getDispatchRecord(args.dispatchId);
|
|
106
|
+
if (!dispatch) throw new Error(`Dispatch record is missing for ${args.dispatchId}`);
|
|
107
|
+
const dispatchConversationId = getDispatchConversationId(dispatch);
|
|
108
|
+
if (dispatchConversationId !== args.conversationId) throw new Error(`Dispatch ${dispatch.id} belongs to ${dispatchConversationId}, not ${args.conversationId}`);
|
|
109
|
+
const location = (await resolveConversationRouting(args))?.location;
|
|
110
|
+
return {
|
|
111
|
+
destination: dispatch.destination,
|
|
112
|
+
...location ? { location } : void 0,
|
|
113
|
+
source: dispatch.source
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
export { savedTurnMessages as i, resolveTurnResumeRouting as n, isTurnMessage as r, resolveConversationRouting as t };
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { i as getConversationStore, n as getConversationEventStore, z as isTopLevelKind } from "./db-BTmLKZrp.js";
|
|
2
|
+
import { $r as failTurnRecord, Rt as ensureConversationWake, ei as getTurnRecord, ni as recordTurnSummary, qr as loadTurnCheckpoint, qt as requestConversationWork } from "./mailbox-turn-DL3Lvsm0.js";
|
|
3
|
+
import { n as resolveTurnResumeRouting } from "./turn-session-routing-CZTRU8IY.js";
|
|
4
|
+
import { qr as getDispatchRecord } from "./credentialed-dWRA3-oJ.js";
|
|
5
|
+
import { S as logException } from "./conversation-privacy-DtZhI91r.js";
|
|
6
|
+
import { t as getVercelConversationWorkQueue } from "./vercel-queue-nL0Hq3hr.js";
|
|
7
|
+
import * as z from "zod";
|
|
8
|
+
// src/chat/task-execution/authorized-turn.ts
|
|
9
|
+
/**
|
|
10
|
+
* OAuth callbacks save readiness, not agent history. The conversation worker
|
|
11
|
+
* consumes this event under its lease before it resumes the paused Turn.
|
|
12
|
+
*/
|
|
13
|
+
const authorizationSchema = z.object({
|
|
14
|
+
kind: z.enum(["mcp", "plugin"]),
|
|
15
|
+
provider: z.string().min(1),
|
|
16
|
+
actorId: z.string().min(1),
|
|
17
|
+
authorizationId: z.string().min(1),
|
|
18
|
+
authSessionId: z.string().optional(),
|
|
19
|
+
scope: z.string().optional(),
|
|
20
|
+
configuration: z.record(z.string(), z.unknown()).optional(),
|
|
21
|
+
toolChannelId: z.string().optional()
|
|
22
|
+
});
|
|
23
|
+
function authorizationKey(turn) {
|
|
24
|
+
return `turn:${turn.turnId}:authorization:${turn.version}`;
|
|
25
|
+
}
|
|
26
|
+
/** Save authorization for this parked boundary without changing model history. */
|
|
27
|
+
async function recordTurnAuthorization(args) {
|
|
28
|
+
const turn = await getTurnRecord(args.conversationId, args.turnId);
|
|
29
|
+
if (!turn || turn.state !== "paused" || turn.resumeReason !== "auth") return;
|
|
30
|
+
await getConversationEventStore().append(args.conversationId, [{
|
|
31
|
+
idempotencyKey: authorizationKey(turn),
|
|
32
|
+
createdAtMs: Date.now(),
|
|
33
|
+
data: {
|
|
34
|
+
type: "structured_event",
|
|
35
|
+
namespace: "junior",
|
|
36
|
+
name: "turn_authorized",
|
|
37
|
+
version: 1,
|
|
38
|
+
turnId: turn.turnId,
|
|
39
|
+
content: authorizationSchema.parse(args)
|
|
40
|
+
}
|
|
41
|
+
}], { activity: "preserve" });
|
|
42
|
+
return {
|
|
43
|
+
conversationId: args.conversationId,
|
|
44
|
+
destination: args.destination,
|
|
45
|
+
turnId: turn.turnId,
|
|
46
|
+
expectedVersion: turn.version
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** Read authorization for the exact pause; a later auth pause needs its own callback. */
|
|
50
|
+
async function getTurnAuthorization(turn) {
|
|
51
|
+
const event = await getConversationEventStore().loadByIdempotencyKey(turn.conversationId, authorizationKey(turn));
|
|
52
|
+
if (event?.data.type !== "structured_event") return void 0;
|
|
53
|
+
return authorizationSchema.parse(event.data.content);
|
|
54
|
+
}
|
|
55
|
+
// src/chat/task-execution/turn-wake.ts
|
|
56
|
+
/** Build the worker input for a paused turn. */
|
|
57
|
+
async function getPausedTurnRequest(args) {
|
|
58
|
+
const turn = (await loadTurnCheckpoint({
|
|
59
|
+
conversationId: args.conversationId,
|
|
60
|
+
turnId: args.turnId
|
|
61
|
+
})).record;
|
|
62
|
+
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;
|
|
63
|
+
let routing;
|
|
64
|
+
try {
|
|
65
|
+
routing = await resolveTurnResumeRouting({
|
|
66
|
+
conversationId: args.conversationId,
|
|
67
|
+
conversationStore: args.conversationStore,
|
|
68
|
+
dispatchId: turn.dispatchId
|
|
69
|
+
});
|
|
70
|
+
} catch (error) {
|
|
71
|
+
const failed = await failTurnRecord({
|
|
72
|
+
conversationId: args.conversationId,
|
|
73
|
+
expectedVersion: turn.version,
|
|
74
|
+
turnId: args.turnId,
|
|
75
|
+
errorMessage: error instanceof Error ? error.message : String(error)
|
|
76
|
+
});
|
|
77
|
+
if (failed) await recordFailedDispatchTurn(failed);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
conversationId: args.conversationId,
|
|
82
|
+
destination: routing.destination,
|
|
83
|
+
turnId: args.turnId,
|
|
84
|
+
expectedVersion: turn.version,
|
|
85
|
+
traceContext: turn.traceContext
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Record that a resume failed a dispatch turn for good. Without this outcome,
|
|
90
|
+
* the dispatch runs the turn again, so a failed write is only logged.
|
|
91
|
+
*/
|
|
92
|
+
async function recordFailedDispatchTurn(turn) {
|
|
93
|
+
if (!turn.dispatchId) return;
|
|
94
|
+
try {
|
|
95
|
+
const dispatch = await getDispatchRecord(turn.dispatchId);
|
|
96
|
+
await recordTurnSummary({
|
|
97
|
+
conversationId: turn.conversationId,
|
|
98
|
+
destination: dispatch?.destination,
|
|
99
|
+
dispatchId: turn.dispatchId,
|
|
100
|
+
dispatchOutcome: "failed",
|
|
101
|
+
turnId: turn.turnId,
|
|
102
|
+
sliceId: turn.sliceId,
|
|
103
|
+
source: dispatch?.source,
|
|
104
|
+
state: "failed",
|
|
105
|
+
surface: turn.surface
|
|
106
|
+
});
|
|
107
|
+
} catch (error) {
|
|
108
|
+
logException(error, "agent.continue.dispatch_failure_summary.failed", {
|
|
109
|
+
"app.ai.conversation_id": turn.conversationId,
|
|
110
|
+
"app.ai.session_id": turn.turnId
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/** Wake the conversation worker for a paused turn. */
|
|
115
|
+
async function wakePausedTurn(request, options = {}) {
|
|
116
|
+
const nowMs = options.nowMs ?? Date.now();
|
|
117
|
+
const conversation = await (options.conversationStore ?? getConversationStore()).get({ conversationId: request.conversationId });
|
|
118
|
+
await requestConversationWork({
|
|
119
|
+
conversationId: request.conversationId,
|
|
120
|
+
destination: conversation && !isTopLevelKind(conversation.kind) ? void 0 : request.destination,
|
|
121
|
+
nowMs,
|
|
122
|
+
state: options.state
|
|
123
|
+
});
|
|
124
|
+
const queue = options.queue ?? getVercelConversationWorkQueue();
|
|
125
|
+
await ensureConversationWake({
|
|
126
|
+
conversationId: request.conversationId,
|
|
127
|
+
idempotencyKey: [
|
|
128
|
+
"agent-continue",
|
|
129
|
+
request.conversationId,
|
|
130
|
+
request.turnId,
|
|
131
|
+
request.expectedVersion,
|
|
132
|
+
nowMs
|
|
133
|
+
].join(":"),
|
|
134
|
+
nowMs,
|
|
135
|
+
queue,
|
|
136
|
+
state: options.state
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
/** Create paused Turn operations for one app. */
|
|
140
|
+
function createPausedTurns(options = {}) {
|
|
141
|
+
return {
|
|
142
|
+
get: (args) => getPausedTurnRequest({
|
|
143
|
+
...args,
|
|
144
|
+
conversationStore: options.conversationStore
|
|
145
|
+
}),
|
|
146
|
+
wake: (request) => wakePausedTurn(request, options)
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/** Record completed authorization and wake the sole execution owner. */
|
|
150
|
+
async function wakeAuthorizedTurn(args, queue) {
|
|
151
|
+
const request = await recordTurnAuthorization(args);
|
|
152
|
+
if (request) await wakePausedTurn(request, { queue });
|
|
153
|
+
}
|
|
154
|
+
export { wakePausedTurn as a, wakeAuthorizedTurn as i, getPausedTurnRequest as n, getTurnAuthorization as o, recordFailedDispatchTurn as r, createPausedTurns as t };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
// src/api/schema/user-customization.ts
|
|
3
|
+
/** Longest customization text one user can save. */
|
|
4
|
+
const USER_CUSTOMIZATION_MAX_CHARS = 1e3;
|
|
5
|
+
/** Saved customization text. An empty string means none. */
|
|
6
|
+
const userCustomizationTextSchema = z.string().trim().max(USER_CUSTOMIZATION_MAX_CHARS);
|
|
7
|
+
/** Request and response body for the viewer's customization. */
|
|
8
|
+
const userCustomizationSchema = z.object({ customization: userCustomizationTextSchema }).strict();
|
|
9
|
+
export { userCustomizationSchema as n, userCustomizationTextSchema as r, USER_CUSTOMIZATION_MAX_CHARS as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
|
|
2
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime-
|
|
2
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-BLKtnUL3.js";
|
|
3
3
|
import { isDeepStrictEqual } from "node:util";
|
|
4
4
|
// src/chat/plugins/validation.ts
|
|
5
5
|
var validation_exports = /* @__PURE__ */ __exportAll({
|