@sentry/junior 0.296.0 → 0.297.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-z_lgDi-z.js → admin-tmGIw4KS.js} +2 -2
- package/dist/{agent-runner-HoQiUKLL.js → agent-runner-CneTquAE.js} +378 -1919
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +7 -7
- package/dist/api.d.ts +1 -1
- package/dist/api.js +38 -267
- package/dist/{app-C75Ft-A_.d.ts → app-BJojZ7HL.d.ts} +7 -2
- package/dist/app.d.ts +1 -1
- package/dist/app.js +64 -44
- package/dist/attempt-selection-ClP3MMPr.js +61 -0
- package/dist/{automation-yJX3C7i3.js → automation-BrP6ImrC.js} +1 -1
- package/dist/{background-compaction-queue-Cre1wFt9.js → background-compaction-queue-CwfJy3Cd.js} +4 -88
- package/dist/{briefs-BXECHduJ.js → briefs-uFTuhMqA.js} +3 -3
- package/dist/{catalog-runtime-CpCmlD9L.js → catalog-runtime-0kuQqYL4.js} +1 -1
- package/dist/cli/chat.js +19 -15
- package/dist/cli/check.js +3 -3
- package/dist/cli/main.js +3 -3
- package/dist/cli/plugins.js +4 -4
- package/dist/cli/snapshot-create.js +4 -4
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +3 -3
- package/dist/{config-CCPHvTqx.js → config-Dj9M_nqB.js} +2 -2
- package/dist/{connections-B5pWh8e2.js → connections-B96JUM5o.js} +6 -6
- package/dist/{conversation-CMkSmi02.js → conversation-CvcBU1z2.js} +2 -16
- package/dist/{conversation-feed-BVAOga0H.js → conversation-feed-BSMlGZnS.js} +1 -1
- package/dist/{conversation-privacy-CZD5soDW.js → conversation-privacy-DI29jbZV.js} +1 -1
- package/dist/conversation-turn-CZWBr091.js +805 -0
- package/dist/{credential-sync-DwLkIvXI.js → credential-sync-Blhx4_xf.js} +14 -13
- package/dist/{db-C1M1y-bh.js → db-Br0tfAo7.js} +43 -15
- package/dist/{db-B3iyr_Or.d.ts → db-CrtyFRz7.d.ts} +13 -1
- package/dist/{executor-DUSEwXaO.js → executor-BMPipFVA.js} +14 -6
- package/dist/instrumentation.js +2 -2
- package/dist/{logging-D0svFM8r.js → logging-CQjlDQYX.js} +1 -1
- package/dist/{message-BFnIwKpx.js → message-BOZEIuxy.js} +15 -13
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +3 -2
- package/dist/{session-stop-hYNTNpVf.js → notification-gusCgdQ6.js} +11 -930
- package/dist/{oauth-callback-server-BXRtD6Fk.js → oauth-callback-server-V_DuMuNX.js} +2 -2
- package/dist/{projection-B6VS7kbo.js → projection-B08mfi0u.js} +333 -106
- package/dist/{prompt-CD11tfG8.js → prompt-BlutWLNt.js} +4 -4
- package/dist/prompt-input-Dxn8cDC0.js +1424 -0
- package/dist/{registry-CHewwYEo.js → registry-BDWgCJDf.js} +1 -1
- package/dist/reporting-window-DopzcOHh.js +137 -0
- package/dist/{resolve-1owMH4qo.js → resolve-2Z_o_SsI.js} +3 -3
- package/dist/result-CAujiaci.js +463 -0
- package/dist/{runner-BtWvJslp.js → runner-D2Chc02N.js} +9 -8
- package/dist/{sandbox-egress-signals-ByftwJVt.js → sandbox-egress-signals-CFoJduFj.js} +1 -1
- package/dist/{schema-D2iGyYIp.js → schema-Bqa5NbcP.js} +11 -48
- package/dist/{schema-Ct1Zf2xy.d.ts → schema-Ce2XCS7O.d.ts} +8 -107
- package/dist/{service-account-DLoeoHww.js → service-account-C9kRQEb_.js} +3 -3
- package/dist/{service-account-BZEuMKdo.js → service-account-CERfXEVU.js} +3 -3
- package/dist/session-stop-B-I1rAS1.js +181 -0
- package/dist/{skills-DXgd5Inh.js → skills-B0m1nZ_j.js} +2 -2
- package/dist/{spawn-YeqlNDv8.js → spawn-CwMjRRtn.js} +6 -5
- package/dist/{state-C3CbtD_m.js → state-DFnmLmfn.js} +2 -2
- package/dist/{stop-Cze_pEL8.js → stop-BCH9VNGf.js} +63 -158
- package/dist/{store-CZ9vqR4P.js → store-B59rOYbS.js} +11 -4
- package/dist/{task-runner-CMiNGsER.js → store-m5bmdmsP.js} +939 -1593
- package/dist/task-queue-N0kuCknH.js +89 -0
- package/dist/task-runner-COOwR8qm.js +291 -0
- package/dist/thread-context-Cd44z_W5.js +248 -0
- package/dist/turn-cancel-DDu8TOwt.js +201 -0
- package/dist/turn-session-routing-BlCtVFRN.js +380 -0
- package/dist/{turn-failure-response-pXhZ2wMK.js → turn-user-message-ygLG3ylQ.js} +183 -361
- package/dist/turn-wake-DmQec4AG.js +161 -0
- package/dist/{reporting-window-B3Ze-Qnt.js → user-input-request-CXNIov9n.js} +24 -143
- package/dist/{validation-Du7NdkOR.js → validation-Ba2OcUse.js} +1 -1
- package/dist/{version-EN3Wnq-R.js → version-KNDzIAh6.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-Agxi_o5c.js → viewer-BPpuN2f9.js} +3 -3
- package/dist/warmup-Bskrwmk1.js +2697 -0
- package/dist/{worker-BALVdWbv.js → worker-B1skZlit.js} +20 -8
- package/migrations/0102_code_change_last_activity.sql +1 -0
- package/migrations/0103_agent_invocation_fork.sql +8 -0
- package/migrations/meta/0102_snapshot.json +4502 -0
- package/migrations/meta/0103_snapshot.json +4509 -0
- package/migrations/meta/_journal.json +14 -0
- package/package.json +4 -4
- package/dist/result-CEqQFrEf.js +0 -305
- package/dist/result-event-type-DD6BAgT7.js +0 -11
- package/dist/warmup-CY2ArYag.js +0 -2017
- package/dist/work-EA98F0ia.js +0 -768
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as setSpanAttributes, h as logWarn, m as logInfo } from "./logging-
|
|
1
|
+
import { b as setSpanAttributes, h as logWarn, m as logInfo } from "./logging-CQjlDQYX.js";
|
|
2
2
|
import { o as isUserActor, s as parseActorUserId } from "./actor-6jsm_v96.js";
|
|
3
3
|
import { n as normalizePluginPackageNames, o as pluginRoots, t as discoverInstalledPluginPackageContent } from "./package-discovery-DJhGdS4c.js";
|
|
4
4
|
import path from "node:path";
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
// src/api/schema/common.ts
|
|
3
|
+
/** Stable error body returned by Junior-owned REST endpoints. */
|
|
4
|
+
const apiErrorSchema = z.object({ error: z.string().min(1) }).strict();
|
|
5
|
+
// src/chat/conversations/web-message-id.ts
|
|
6
|
+
/**
|
|
7
|
+
* Build the retry-stable Message id shared by web ingress and browser sends.
|
|
8
|
+
* Keep the existing hash and prefix so retries still address stored Messages.
|
|
9
|
+
*/
|
|
10
|
+
async function webMessageId(args) {
|
|
11
|
+
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(`${args.conversationId}\u0000${args.idempotencyKey}`));
|
|
12
|
+
return `api-msg:${Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("").slice(0, 24)}`;
|
|
13
|
+
}
|
|
14
|
+
// src/api/reporting-window.ts
|
|
15
|
+
/** Shared UTC day/hour/six-hour windows for dashboard activity series. */
|
|
16
|
+
const HOUR_MS = 36e5;
|
|
17
|
+
const SIX_HOUR_MS = 6 * HOUR_MS;
|
|
18
|
+
const DAY_MS = 24 * HOUR_MS;
|
|
19
|
+
/** Start of the UTC calendar day containing `valueMs`. */
|
|
20
|
+
function startOfUtcDay(valueMs) {
|
|
21
|
+
const date = new Date(valueMs);
|
|
22
|
+
date.setUTCHours(0, 0, 0, 0);
|
|
23
|
+
return date;
|
|
24
|
+
}
|
|
25
|
+
/** Start of the UTC hour containing `valueMs`. */
|
|
26
|
+
function startOfUtcHour(valueMs) {
|
|
27
|
+
const date = new Date(valueMs);
|
|
28
|
+
date.setUTCMinutes(0, 0, 0);
|
|
29
|
+
return date;
|
|
30
|
+
}
|
|
31
|
+
/** Start of the UTC 6-hour bucket containing `valueMs` (00/06/12/18). */
|
|
32
|
+
function startOfUtcSixHour(valueMs) {
|
|
33
|
+
const date = startOfUtcHour(valueMs);
|
|
34
|
+
date.setUTCHours(Math.floor(date.getUTCHours() / 6) * 6, 0, 0, 0);
|
|
35
|
+
return date;
|
|
36
|
+
}
|
|
37
|
+
/** UTC day key `YYYY-MM-DD`. */
|
|
38
|
+
function utcDayKey(value) {
|
|
39
|
+
return (typeof value === "number" ? new Date(value) : value).toISOString().slice(0, 10);
|
|
40
|
+
}
|
|
41
|
+
/** UTC hour key `YYYY-MM-DDTHH`. */
|
|
42
|
+
function utcHourKey(value) {
|
|
43
|
+
return (typeof value === "number" ? new Date(value) : value).toISOString().slice(0, 13);
|
|
44
|
+
}
|
|
45
|
+
/** UTC 6-hour bucket key `YYYY-MM-DDTHH` at 00/06/12/18. */
|
|
46
|
+
function utcSixHourKey(value) {
|
|
47
|
+
return utcHourKey(startOfUtcSixHour(typeof value === "number" ? value : value.getTime()));
|
|
48
|
+
}
|
|
49
|
+
/** Inclusive trailing UTC day window ending on today's UTC day. */
|
|
50
|
+
function trailingUtcDayWindow(nowMs, dayCount) {
|
|
51
|
+
const end = startOfUtcDay(nowMs);
|
|
52
|
+
const start = new Date(end);
|
|
53
|
+
start.setUTCDate(start.getUTCDate() - (dayCount - 1));
|
|
54
|
+
return {
|
|
55
|
+
end,
|
|
56
|
+
start
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** Inclusive trailing UTC hour window ending on the current UTC hour. */
|
|
60
|
+
function trailingUtcHourWindow(nowMs, hourCount = 24) {
|
|
61
|
+
const end = startOfUtcHour(nowMs);
|
|
62
|
+
return {
|
|
63
|
+
end,
|
|
64
|
+
start: /* @__PURE__ */ new Date(end.getTime() - (hourCount - 1) * HOUR_MS)
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/** Inclusive trailing UTC 6-hour window ending on the current 6h bucket. */
|
|
68
|
+
function trailingUtcSixHourWindow(nowMs, bucketCount = 28) {
|
|
69
|
+
const end = startOfUtcSixHour(nowMs);
|
|
70
|
+
return {
|
|
71
|
+
end,
|
|
72
|
+
start: /* @__PURE__ */ new Date(end.getTime() - (bucketCount - 1) * SIX_HOUR_MS)
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/** Fill a fixed UTC day window from a sparse map. */
|
|
76
|
+
function fillUtcDays(args) {
|
|
77
|
+
const { end, start } = trailingUtcDayWindow(args.nowMs, args.count);
|
|
78
|
+
const items = [];
|
|
79
|
+
for (const cursor = new Date(start); cursor.getTime() <= end.getTime(); cursor.setUTCDate(cursor.getUTCDate() + 1)) {
|
|
80
|
+
const date = utcDayKey(cursor);
|
|
81
|
+
items.push(args.rows.get(date) ?? args.empty(date));
|
|
82
|
+
}
|
|
83
|
+
return items;
|
|
84
|
+
}
|
|
85
|
+
/** Fill a fixed UTC hour window from a sparse map. */
|
|
86
|
+
function fillUtcHours(args) {
|
|
87
|
+
const hourCount = args.count ?? 24;
|
|
88
|
+
const { end, start } = trailingUtcHourWindow(args.nowMs, hourCount);
|
|
89
|
+
const items = [];
|
|
90
|
+
for (const cursor = new Date(start); cursor.getTime() <= end.getTime(); cursor.setTime(cursor.getTime() + HOUR_MS)) {
|
|
91
|
+
const date = utcHourKey(cursor);
|
|
92
|
+
items.push(args.rows.get(date) ?? args.empty(date));
|
|
93
|
+
}
|
|
94
|
+
return items;
|
|
95
|
+
}
|
|
96
|
+
/** Fill a fixed UTC 6-hour window from a map of known rows. */
|
|
97
|
+
function fillUtcSixHours(args) {
|
|
98
|
+
const bucketCount = args.count ?? 28;
|
|
99
|
+
const { end, start } = trailingUtcSixHourWindow(args.nowMs, bucketCount);
|
|
100
|
+
const items = [];
|
|
101
|
+
for (const cursor = new Date(start); cursor.getTime() <= end.getTime(); cursor.setTime(cursor.getTime() + SIX_HOUR_MS)) {
|
|
102
|
+
const date = utcSixHourKey(cursor);
|
|
103
|
+
items.push(args.rows.get(date) ?? args.empty(date));
|
|
104
|
+
}
|
|
105
|
+
return items;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Sum hour rows into trailing 6-hour buckets.
|
|
109
|
+
* Adds number fields. Keeps other fields from the first row in the bucket.
|
|
110
|
+
* Sets `date` to the 6-hour bucket key.
|
|
111
|
+
*/
|
|
112
|
+
function sumUtcHoursIntoSixHours(args) {
|
|
113
|
+
const bucketCount = args.count ?? 28;
|
|
114
|
+
const bySix = /* @__PURE__ */ new Map();
|
|
115
|
+
for (const hour of args.hours) {
|
|
116
|
+
const key = utcSixHourKey(Date.parse(`${hour.date}:00:00.000Z`));
|
|
117
|
+
const next = {
|
|
118
|
+
...bySix.get(key) ?? args.empty(key),
|
|
119
|
+
date: key
|
|
120
|
+
};
|
|
121
|
+
for (const [field, value] of Object.entries(hour)) {
|
|
122
|
+
if (field === "date") continue;
|
|
123
|
+
if (typeof value === "number") {
|
|
124
|
+
const prior = next[field];
|
|
125
|
+
next[field] = (typeof prior === "number" ? prior : 0) + value;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
bySix.set(key, next);
|
|
129
|
+
}
|
|
130
|
+
return fillUtcSixHours({
|
|
131
|
+
count: bucketCount,
|
|
132
|
+
empty: args.empty,
|
|
133
|
+
nowMs: args.nowMs,
|
|
134
|
+
rows: bySix
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
export { fillUtcSixHours as a, trailingUtcDayWindow as c, utcDayKey as d, utcHourKey as f, fillUtcHours as i, trailingUtcHourWindow as l, apiErrorSchema as m, HOUR_MS as n, startOfUtcHour as o, webMessageId as p, fillUtcDays as r, sumUtcHoursIntoSixHours as s, DAY_MS as t, trailingUtcSixHourWindow as u };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { E as withSpan, b as setSpanAttributes } from "./logging-
|
|
3
|
-
import { a as getStateAdapter } from "./state-
|
|
1
|
+
import { Gi as getSandboxProvider, Ja as sleep, Ui as isStale, Vi as create, eo as SANDBOX_COMMAND_PATH, io as SANDBOX_WORKSPACE_ROOT, uo as runNonInteractiveCommand } from "./projection-B08mfi0u.js";
|
|
2
|
+
import { E as withSpan, b as setSpanAttributes } from "./logging-CQjlDQYX.js";
|
|
3
|
+
import { a as getStateAdapter } from "./state-DFnmLmfn.js";
|
|
4
4
|
import * as z from "zod";
|
|
5
5
|
// src/chat/sandbox/resources.ts
|
|
6
6
|
let configuredResources;
|
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
import { v as __exportAll } from "./sentry-BRTJqumy.js";
|
|
2
|
+
import { zn as renderUntrustedTag } from "./projection-B08mfi0u.js";
|
|
3
|
+
import { D as turnBehavior, M as SYSTEM_IDENTITY_ID, a as getConversationStore } from "./db-Br0tfAo7.js";
|
|
4
|
+
import { f as credentialContextForActor } from "./registry-BDWgCJDf.js";
|
|
5
|
+
import { a as EVENT_SYSTEM_ACTOR } from "./prompt-BlutWLNt.js";
|
|
6
|
+
import { _ as getEventBatchDelayMs, b as resolveMailboxTurnWork, t as eventReviewItemInputs, v as listActiveMailboxTurns, y as parseEventMessages } from "./prompt-input-Dxn8cDC0.js";
|
|
7
|
+
import { S as resolveAgentInvocationId, _ as createAgentInvocationWorker, b as endAgentInvocationsOfStoppedWork, g as routeChildInput, h as getChildAgentInputInvocation, k as createAgentInvocationFromLatest, m as childAgentInput, p as listUnreportedSiblingAgents, x as enqueueAgentInvocation, y as endActiveAgentInvocations } from "./warmup-Bskrwmk1.js";
|
|
8
|
+
import { t as getConversationStoppedAtMs } from "./session-stop-B-I1rAS1.js";
|
|
9
|
+
import { $ as getAgentInvocationIdForMessage, A as listAgentInvocationsForConversation, B as reportReplacedWithoutOpenWork, E as getLatestAgentInvocationForConversation, F as markAgentInvocationParentMailboxAppended, Q as getAgentInvocationIdForEvents, V as sendsResultToParent, b as NON_TERMINAL_AGENT_INVOCATION_STATUSES, et as getAgentInvocationIdForResult, ft as parseTurnReplyMessageId, it as getAgentReplyMessageId, k as isTerminalAgentInvocation, lt as isAgentReplyMessageId, mt as buildDeterministicTurnId, nt as getAgentInvocationResultMessageId, st as getTurnReplyKey, x as TERMINAL_AGENT_INVOCATION_STATUSES } from "./turn-user-message-ygLG3ylQ.js";
|
|
10
|
+
import { a as renderEventBatchInputs, o as timerWatchCredentialSubject, r as eventBatchMessageMeta, t as EVENT_WAIT_MS } from "./notification-gusCgdQ6.js";
|
|
11
|
+
import { _ as getConversationWorkState, r as appendAndEnqueueInboundMessage } from "./store-B59rOYbS.js";
|
|
12
|
+
import { _ as agentInvocationResultEventType, g as AGENT_REPLY_EVENT_TYPE, h as AGENT_MESSAGE_EVENT_TYPE, m as AGENT_INVOCATION_EVENT_NAMESPACE } from "./user-input-request-CXNIov9n.js";
|
|
13
|
+
// src/chat/agent-invocations/result.ts
|
|
14
|
+
var result_exports = /* @__PURE__ */ __exportAll({
|
|
15
|
+
createChildConversationWorker: () => createChildConversationWorker,
|
|
16
|
+
createDeliverToParent: () => createDeliverToParent,
|
|
17
|
+
createEndStoppedChildWork: () => createEndStoppedChildWork,
|
|
18
|
+
enqueueAgentInvocationResult: () => enqueueAgentInvocationResult,
|
|
19
|
+
enqueueAgentMessageToParent: () => enqueueAgentMessageToParent,
|
|
20
|
+
enqueueChildResultToParent: () => enqueueChildResultToParent,
|
|
21
|
+
withAgentInvocationResultActors: () => withAgentInvocationResultActors
|
|
22
|
+
});
|
|
23
|
+
const AGENT_INVOCATION_RESULT_MAX_LENGTH = 12e3;
|
|
24
|
+
/**
|
|
25
|
+
* Return the Inbound message author id for results sent by one Actor.
|
|
26
|
+
* `selectContiguousTurnBatch` in `task-execution/worker.ts` puts messages in
|
|
27
|
+
* one attempt only when their author ids and sources match. Mid-Turn drains
|
|
28
|
+
* take only `interrupt` messages, and results are `defer`. So results never
|
|
29
|
+
* share a Turn and its credentials with another Actor or with watch Events.
|
|
30
|
+
* Keep this id unique per Actor if either rule changes.
|
|
31
|
+
*/
|
|
32
|
+
function resultAuthorId(actor) {
|
|
33
|
+
switch (actor.platform) {
|
|
34
|
+
case "system": return `agent-invocation:system:${actor.name}`;
|
|
35
|
+
case "slack": return `agent-invocation:slack:${actor.teamId}:${actor.userId}`;
|
|
36
|
+
default: return `agent-invocation:${actor.platform}:${actor.userId}`;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Error messages can contain text from tools or providers, so the trusted
|
|
41
|
+
* summary in the mailbox metadata has only the status.
|
|
42
|
+
*/
|
|
43
|
+
function trustedSummary(invocation, agent) {
|
|
44
|
+
switch (invocation.status) {
|
|
45
|
+
case "completed": return `${agent} finished its task.`;
|
|
46
|
+
case "blocked": return `${agent} is blocked.`;
|
|
47
|
+
case "failed": return `${agent} failed.`;
|
|
48
|
+
case "stopped": return `${agent} was stopped.`;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Render the parent agent input for one child agent result as one
|
|
53
|
+
* `<agent-result>`. A child agent wrote the output, so it is escaped data.
|
|
54
|
+
* `status` and `waiting_on` are runtime facts. The system prompt says what to
|
|
55
|
+
* do for each status, so the input repeats no guidance.
|
|
56
|
+
*/
|
|
57
|
+
function renderResultInput(sender, result, openSiblings) {
|
|
58
|
+
const output = result.output.trim().slice(0, AGENT_INVOCATION_RESULT_MAX_LENGTH);
|
|
59
|
+
return renderUntrustedTag("agent-result", {
|
|
60
|
+
conversation_id: sender.childConversationId,
|
|
61
|
+
name: sender.agentName,
|
|
62
|
+
source: "child_agent",
|
|
63
|
+
status: result.status,
|
|
64
|
+
title: sender.title,
|
|
65
|
+
waiting_on: openSiblings.length ? openSiblings.map(siblingLabel).join(", ") : void 0
|
|
66
|
+
}, "A child agent that you started", output || "(empty)");
|
|
67
|
+
}
|
|
68
|
+
function siblingLabel(sibling) {
|
|
69
|
+
return sibling.agentName ?? sibling.title ?? sibling.childConversationId;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Render one `<agent-result>` under the parent's mailbox lock. `waiting_on`
|
|
73
|
+
* then sees every `reply` that reached the parent, also one that a sibling
|
|
74
|
+
* sent at the same moment, so two siblings cannot each name the other.
|
|
75
|
+
*/
|
|
76
|
+
function renderResultUnderLock(sender, result) {
|
|
77
|
+
return async (parentInboundMessageIds) => renderResultInput(sender, result, await listUnreportedSiblingAgents(sender.parentConversationId, sender.childConversationId, parentInboundMessageIds));
|
|
78
|
+
}
|
|
79
|
+
function terminalResult(invocation) {
|
|
80
|
+
return {
|
|
81
|
+
output: invocation.status === "completed" ? invocation.result : invocation.errorMessage,
|
|
82
|
+
status: invocation.status
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Build the parent Inbound message for one terminal agent invocation. Its
|
|
87
|
+
* text names no siblings: `renderResultUnderLock` adds `waiting_on`.
|
|
88
|
+
*/
|
|
89
|
+
function buildResultInboundMessage(invocation, nowMs) {
|
|
90
|
+
const summary = trustedSummary(invocation, childAgentLabel(invocation));
|
|
91
|
+
const metadata = {
|
|
92
|
+
kind: "event",
|
|
93
|
+
event: {
|
|
94
|
+
eventKey: invocation.invocationId,
|
|
95
|
+
eventType: agentInvocationResultEventType(invocation.status),
|
|
96
|
+
identifier: invocation.invocationId,
|
|
97
|
+
namespace: AGENT_INVOCATION_EVENT_NAMESPACE,
|
|
98
|
+
trustedSummary: summary
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
return {
|
|
102
|
+
conversationId: invocation.parentConversationId,
|
|
103
|
+
createdAtMs: invocation.terminalAtMs,
|
|
104
|
+
delivery: "defer",
|
|
105
|
+
inboundMessageId: getAgentInvocationResultMessageId(invocation.invocationId),
|
|
106
|
+
input: {
|
|
107
|
+
authorId: resultAuthorId(invocation.actor),
|
|
108
|
+
authorIdentityId: SYSTEM_IDENTITY_ID,
|
|
109
|
+
metadata,
|
|
110
|
+
text: renderResultInput(invocation, terminalResult(invocation), [])
|
|
111
|
+
},
|
|
112
|
+
receivedAtMs: nowMs,
|
|
113
|
+
source: "event"
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Append one terminal agent invocation result to the parent mailbox and wake
|
|
118
|
+
* the parent. Repeat calls are safe.
|
|
119
|
+
*
|
|
120
|
+
* Results do not go through `admitAutomatedTurn`, so the automated-turn limit
|
|
121
|
+
* never drops them. Result Turns still count toward that limit.
|
|
122
|
+
* TODO(dcramer): Add a per-parent total invocation limit as the loop guard
|
|
123
|
+
* for spawn -> result -> spawn chains (#881).
|
|
124
|
+
*/
|
|
125
|
+
async function enqueueAgentInvocationResult(invocation, options) {
|
|
126
|
+
if (invocation.parentMailboxStatus !== "pending") return;
|
|
127
|
+
const nowMs = options.nowMs ?? Date.now();
|
|
128
|
+
const parentInboundMessageIds = await readParentInboundMessageIds(invocation.parentConversationId, options.state);
|
|
129
|
+
if (!sendsResultToParent(invocation, parentInboundMessageIds)) {
|
|
130
|
+
await markAgentInvocationParentMailboxAppended(invocation.invocationId, nowMs);
|
|
131
|
+
const replaced = parentInboundMessageIds.some((messageId) => isAgentReplyMessageId(messageId, invocation.invocationId)) ? void 0 : await reportReplacedWithoutOpenWork(invocation.parentConversationId, nowMs);
|
|
132
|
+
if (replaced && isTerminalAgentInvocation(replaced)) await enqueueAgentInvocationResult(replaced, options);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
await appendAndEnqueueInboundMessage({
|
|
136
|
+
message: buildResultInboundMessage(invocation, nowMs),
|
|
137
|
+
renderText: renderResultUnderLock(invocation, terminalResult(invocation)),
|
|
138
|
+
queue: options.queue,
|
|
139
|
+
queueDelayMs: EVENT_WAIT_MS,
|
|
140
|
+
state: options.state
|
|
141
|
+
});
|
|
142
|
+
await markAgentInvocationParentMailboxAppended(invocation.invocationId, nowMs);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Read the ids of every message that reached the parent's mailbox. A sibling
|
|
146
|
+
* whose `reply` is among them has answered.
|
|
147
|
+
*/
|
|
148
|
+
async function readParentInboundMessageIds(parentConversationId, state) {
|
|
149
|
+
return (await getConversationWorkState({
|
|
150
|
+
conversationId: parentConversationId,
|
|
151
|
+
state
|
|
152
|
+
}))?.execution.inboundMessageIds ?? [];
|
|
153
|
+
}
|
|
154
|
+
function childAgentLabel(invocation) {
|
|
155
|
+
return invocation.agentName ? `Child agent "${invocation.agentName}"` : "Child agent";
|
|
156
|
+
}
|
|
157
|
+
function renderMessageInput(sender, text) {
|
|
158
|
+
return renderUntrustedTag("agent-message", {
|
|
159
|
+
conversation_id: sender.childConversationId,
|
|
160
|
+
name: sender.agentName,
|
|
161
|
+
source: "child_agent",
|
|
162
|
+
title: sender.title
|
|
163
|
+
}, "A child agent that you started", text.trim());
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Append one message from a child agent to its parent mailbox and wake the
|
|
167
|
+
* parent. `sender` names the child, and `actor` is the Actor of the child's
|
|
168
|
+
* Turn. The parent handles the message like a result. Repeat calls with the
|
|
169
|
+
* same `messageKey` are safe.
|
|
170
|
+
*/
|
|
171
|
+
async function enqueueAgentMessageToParent(args) {
|
|
172
|
+
const nowMs = args.nowMs ?? Date.now();
|
|
173
|
+
const inboundMessageId = `agent-invocation:${args.sender.invocationId}:message:${args.messageKey}`;
|
|
174
|
+
const summary = `${childAgentLabel(args.sender)} sent a message.`;
|
|
175
|
+
const metadata = {
|
|
176
|
+
kind: "event",
|
|
177
|
+
event: {
|
|
178
|
+
eventKey: inboundMessageId,
|
|
179
|
+
eventType: AGENT_MESSAGE_EVENT_TYPE,
|
|
180
|
+
identifier: args.sender.invocationId,
|
|
181
|
+
namespace: AGENT_INVOCATION_EVENT_NAMESPACE,
|
|
182
|
+
trustedSummary: summary
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
await appendAndEnqueueInboundMessage({
|
|
186
|
+
message: {
|
|
187
|
+
conversationId: args.sender.parentConversationId,
|
|
188
|
+
createdAtMs: nowMs,
|
|
189
|
+
delivery: "defer",
|
|
190
|
+
inboundMessageId,
|
|
191
|
+
input: {
|
|
192
|
+
authorId: resultAuthorId(args.actor),
|
|
193
|
+
authorIdentityId: SYSTEM_IDENTITY_ID,
|
|
194
|
+
metadata,
|
|
195
|
+
text: renderMessageInput(args.sender, args.text)
|
|
196
|
+
},
|
|
197
|
+
receivedAtMs: nowMs,
|
|
198
|
+
source: "event"
|
|
199
|
+
},
|
|
200
|
+
queue: args.queue,
|
|
201
|
+
queueDelayMs: EVENT_WAIT_MS,
|
|
202
|
+
state: args.state
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
const RESULT_SUMMARIES = {
|
|
206
|
+
blocked: "is blocked.",
|
|
207
|
+
failed: "failed.",
|
|
208
|
+
reply: "replied."
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* Append the result of one child agent Turn to its parent mailbox and wake
|
|
212
|
+
* the parent: a `reply`, which the parent reads as a completed
|
|
213
|
+
* `<agent-result>`, or a blocked or failed result. `sender` is the agent
|
|
214
|
+
* invocation that names the child, open or not. `actor` is the Actor of the
|
|
215
|
+
* child's Turn; the parent never runs with more authority than it. The key
|
|
216
|
+
* of the result, the `reply` tool call id or the Turn id, keys the message,
|
|
217
|
+
* so a repeat call is safe.
|
|
218
|
+
*/
|
|
219
|
+
async function enqueueChildResultToParent(args) {
|
|
220
|
+
const nowMs = args.nowMs ?? Date.now();
|
|
221
|
+
const inboundMessageId = getAgentReplyMessageId(args.sender.invocationId, args.messageKey);
|
|
222
|
+
const rendered = args.result.kind === "reply" ? {
|
|
223
|
+
output: args.result.reply.text,
|
|
224
|
+
status: "completed"
|
|
225
|
+
} : {
|
|
226
|
+
output: args.result.text,
|
|
227
|
+
status: args.result.kind
|
|
228
|
+
};
|
|
229
|
+
const metadata = {
|
|
230
|
+
kind: "event",
|
|
231
|
+
event: {
|
|
232
|
+
eventKey: inboundMessageId,
|
|
233
|
+
eventType: AGENT_REPLY_EVENT_TYPE,
|
|
234
|
+
identifier: args.sender.invocationId,
|
|
235
|
+
namespace: AGENT_INVOCATION_EVENT_NAMESPACE,
|
|
236
|
+
trustedSummary: `${childAgentLabel(args.sender)} ${RESULT_SUMMARIES[args.result.kind]}`
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
await appendAndEnqueueInboundMessage({
|
|
240
|
+
message: {
|
|
241
|
+
conversationId: args.sender.parentConversationId,
|
|
242
|
+
createdAtMs: nowMs,
|
|
243
|
+
delivery: "defer",
|
|
244
|
+
inboundMessageId,
|
|
245
|
+
input: {
|
|
246
|
+
authorId: resultAuthorId(args.actor ?? args.sender.actor),
|
|
247
|
+
authorIdentityId: SYSTEM_IDENTITY_ID,
|
|
248
|
+
metadata,
|
|
249
|
+
text: renderResultInput(args.sender, rendered, [])
|
|
250
|
+
},
|
|
251
|
+
receivedAtMs: nowMs,
|
|
252
|
+
source: "event"
|
|
253
|
+
},
|
|
254
|
+
renderText: async (parentInboundMessageIds) => parseTurnReplyMessageId(inboundMessageId) !== void 0 && await getConversationStoppedAtMs(args.sender.childConversationId) !== void 0 ? void 0 : await renderResultUnderLock(args.sender, rendered)(parentInboundMessageIds),
|
|
255
|
+
queue: args.queue,
|
|
256
|
+
queueDelayMs: EVENT_WAIT_MS,
|
|
257
|
+
state: args.state
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Build the parent delivery of child agent Turns that run on the
|
|
262
|
+
* Conversation loop. Such a Turn has no open agent invocation, so its
|
|
263
|
+
* newest finished agent invocation names the child for the parent.
|
|
264
|
+
*/
|
|
265
|
+
function createDeliverToParent(options) {
|
|
266
|
+
return async ({ actor, result, conversationId, turnId }) => {
|
|
267
|
+
const sender = (await listAgentInvocationsForConversation(conversationId, TERMINAL_AGENT_INVOCATION_STATUSES)).at(-1);
|
|
268
|
+
if (!sender) throw new Error(`Child conversation ${conversationId} has no agent invocation`);
|
|
269
|
+
await enqueueChildResultToParent({
|
|
270
|
+
actor,
|
|
271
|
+
result,
|
|
272
|
+
messageKey: result.kind === "reply" ? getTurnReplyKey(turnId, result.reply.toolCallId) : turnId,
|
|
273
|
+
queue: options.queue,
|
|
274
|
+
sender,
|
|
275
|
+
state: options.state
|
|
276
|
+
});
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* End the work of a child Conversation whose last attempt lost its worker.
|
|
281
|
+
* Its open agent invocations end as before. A Turn on the Conversation loop
|
|
282
|
+
* has none, so a Task tells its parent that it failed, as a failed Turn
|
|
283
|
+
* does. A Thread keeps the stored failure and its telemetry.
|
|
284
|
+
*/
|
|
285
|
+
function createEndStoppedChildWork(options) {
|
|
286
|
+
const deliverToParent = createDeliverToParent(options);
|
|
287
|
+
return async (conversationId, inboundMessageIds) => {
|
|
288
|
+
if ((await listAgentInvocationsForConversation(conversationId, NON_TERMINAL_AGENT_INVOCATION_STATUSES)).length > 0) {
|
|
289
|
+
await endAgentInvocationsOfStoppedWork(conversationId, inboundMessageIds);
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
const conversation = await getConversationStore().get({ conversationId });
|
|
293
|
+
if (!conversation || turnBehavior({
|
|
294
|
+
kind: conversation.kind,
|
|
295
|
+
personInput: false
|
|
296
|
+
}).failureNotice !== "parent") return;
|
|
297
|
+
const turns = await listActiveMailboxTurns(conversationId);
|
|
298
|
+
const pending = (await getConversationWorkState({ conversationId }))?.execution.pendingMessages ?? [];
|
|
299
|
+
const turnIds = /* @__PURE__ */ new Set([...turns.map((turn) => turn.turnId), ...pending.map((message) => buildDeterministicTurnId(message.inboundMessageId))]);
|
|
300
|
+
const sender = await getLatestAgentInvocationForConversation(conversationId);
|
|
301
|
+
if (sender && (await readParentInboundMessageIds(sender.parentConversationId, void 0)).some((messageId) => {
|
|
302
|
+
const turnId = parseTurnReplyMessageId(messageId);
|
|
303
|
+
return turnId !== void 0 && turnIds.has(turnId) && isAgentReplyMessageId(messageId, sender.invocationId);
|
|
304
|
+
})) return;
|
|
305
|
+
const [turn] = turns;
|
|
306
|
+
await deliverToParent({
|
|
307
|
+
actor: turn?.actor ?? EVENT_SYSTEM_ACTOR,
|
|
308
|
+
result: {
|
|
309
|
+
kind: "failed",
|
|
310
|
+
text: "This task stopped because its worker failed repeatedly."
|
|
311
|
+
},
|
|
312
|
+
conversationId,
|
|
313
|
+
turnId: turn?.turnId ?? `lost:${inboundMessageIds.at(-1) ?? "input"}`
|
|
314
|
+
});
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Give input to a child Conversation whose task is not done to that task, as
|
|
319
|
+
* `routeChildInput` decides. Each result or message from its own child
|
|
320
|
+
* agents, or each batch of its watch events while an agent invocation is
|
|
321
|
+
* open, starts a new agent invocation that reports to the parent. Returns
|
|
322
|
+
* undefined when no input goes to an agent invocation: the Conversation loop
|
|
323
|
+
* runs it and drops what a stop skips.
|
|
324
|
+
*
|
|
325
|
+
* TODO(dcramer): Remove with the legacy child worker (#3060 step 7).
|
|
326
|
+
*/
|
|
327
|
+
async function startAgentInvocationsForChildInput(context, options) {
|
|
328
|
+
const messages = context.attempt.messages;
|
|
329
|
+
const latest = await getLatestAgentInvocationForConversation(context.conversationId);
|
|
330
|
+
if (messages.length === 0 || !latest) return;
|
|
331
|
+
const stoppedAtMs = await getConversationStoppedAtMs(context.conversationId);
|
|
332
|
+
const routes = await Promise.all(messages.map((message) => routeChildInput(message, latest, stoppedAtMs)));
|
|
333
|
+
if (!routes.includes("agent invocation")) return;
|
|
334
|
+
const inputs = messages.map(childAgentInput);
|
|
335
|
+
const isAgentInput = inputs.every((input) => input !== void 0);
|
|
336
|
+
const events = isAgentInput ? [] : parseEventMessages(messages);
|
|
337
|
+
if (!isAgentInput && events.length === 0) return;
|
|
338
|
+
if (!isAgentInput) {
|
|
339
|
+
const delayMs = getEventBatchDelayMs(messages);
|
|
340
|
+
if (delayMs > 0) return {
|
|
341
|
+
status: "deferred",
|
|
342
|
+
delayMs
|
|
343
|
+
};
|
|
344
|
+
const { actor, source } = events[0];
|
|
345
|
+
const invocation = await createAgentInvocationFromLatest({
|
|
346
|
+
input: renderEventBatchInputs(messages, await eventReviewItemInputs(messages)).join("\n\n"),
|
|
347
|
+
invocationId: getAgentInvocationIdForEvents(messages[0].inboundMessageId),
|
|
348
|
+
latest,
|
|
349
|
+
runAs: {
|
|
350
|
+
actor,
|
|
351
|
+
credentialContext: credentialContextForActor(actor, timerWatchCredentialSubject(context.conversationId, messages)),
|
|
352
|
+
source
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
await enqueueAgentInvocation(invocation, {
|
|
356
|
+
...options,
|
|
357
|
+
eventMeta: eventBatchMessageMeta(messages)
|
|
358
|
+
});
|
|
359
|
+
await context.attempt.ack();
|
|
360
|
+
return { status: "completed" };
|
|
361
|
+
}
|
|
362
|
+
for (const [index, message] of messages.entries()) {
|
|
363
|
+
if (routes[index] === "dropped") continue;
|
|
364
|
+
const input = inputs[index];
|
|
365
|
+
const source = await getChildAgentInputInvocation(message, input);
|
|
366
|
+
const invocation = await createAgentInvocationFromLatest({
|
|
367
|
+
input: message.input.text.trim(),
|
|
368
|
+
invocationId: input.kind === "result" ? getAgentInvocationIdForResult(source.invocationId) : getAgentInvocationIdForMessage(message.inboundMessageId),
|
|
369
|
+
latest,
|
|
370
|
+
...input.kind === "result" ? { runAs: {
|
|
371
|
+
actor: source.actor,
|
|
372
|
+
credentialContext: source.credentialContext
|
|
373
|
+
} } : void 0
|
|
374
|
+
});
|
|
375
|
+
await enqueueAgentInvocation(invocation, {
|
|
376
|
+
...options,
|
|
377
|
+
eventMeta: eventBatchMessageMeta([message])
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
await context.attempt.ack();
|
|
381
|
+
return { status: "completed" };
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Build the worker for all work of a child Conversation. The caller selects
|
|
385
|
+
* it from the stored kind of the Conversation, never from a Turn Source. A
|
|
386
|
+
* parent task or message runs on its agent invocation. Every other input,
|
|
387
|
+
* such as a person's Message in a Thread, a Watch Event, or a reply or result
|
|
388
|
+
* of the child's own child agent, runs on the Conversation loop,
|
|
389
|
+
* like input to a root.
|
|
390
|
+
*/
|
|
391
|
+
function createChildConversationWorker(agentRunner, options) {
|
|
392
|
+
const invocationWorker = createAgentInvocationWorker(agentRunner, {
|
|
393
|
+
...options,
|
|
394
|
+
sendReply: async (sender, reply) => await enqueueChildResultToParent({
|
|
395
|
+
result: {
|
|
396
|
+
kind: "reply",
|
|
397
|
+
reply
|
|
398
|
+
},
|
|
399
|
+
messageKey: reply.toolCallId,
|
|
400
|
+
queue: options.queue,
|
|
401
|
+
sender,
|
|
402
|
+
state: options.state
|
|
403
|
+
})
|
|
404
|
+
});
|
|
405
|
+
return async (context) => {
|
|
406
|
+
const invocationId = await resolveAgentInvocationId(context);
|
|
407
|
+
if (invocationId) return await invocationWorker(context, invocationId);
|
|
408
|
+
const started = await startAgentInvocationsForChildInput(context, options);
|
|
409
|
+
if (started) return started;
|
|
410
|
+
const work = await resolveMailboxTurnWork(context);
|
|
411
|
+
if (!work) {
|
|
412
|
+
await context.attempt.ack();
|
|
413
|
+
return { status: "completed" };
|
|
414
|
+
}
|
|
415
|
+
if (work.kind === "mailbox") await endActiveAgentInvocations(context.conversationId, {
|
|
416
|
+
enqueueResult: options.enqueueResult,
|
|
417
|
+
errorMessage: "A person sent a Message in this Thread, so this task ended without a result. Send messageAgent again if you still need this work."
|
|
418
|
+
});
|
|
419
|
+
const kept = await withAgentInvocationResultActors(work);
|
|
420
|
+
if (!kept) {
|
|
421
|
+
await context.attempt.ack();
|
|
422
|
+
return { status: "completed" };
|
|
423
|
+
}
|
|
424
|
+
return await options.runTurn(context, kept);
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Run each agent invocation result or message as the Actor that triggered the
|
|
429
|
+
* child, user or system, with its grants. This is on purpose: the result
|
|
430
|
+
* continues that Actor's work. The Actor comes from SQL, not from mailbox
|
|
431
|
+
* metadata, so the parent Turn has the same authority it had at spawn time.
|
|
432
|
+
* Input that a child's Turn with another Actor sent runs as the Event system
|
|
433
|
+
* Actor, so it never gets more authority than that Turn. A result that a stop
|
|
434
|
+
* skipped is dropped. Returns undefined when no input is left.
|
|
435
|
+
*/
|
|
436
|
+
async function withAgentInvocationResultActors(work) {
|
|
437
|
+
if (work.kind !== "mailbox") return work;
|
|
438
|
+
const conversationId = work.batch[0]?.message.conversationId;
|
|
439
|
+
const [latest, stoppedAtMs] = conversationId ? await Promise.all([getLatestAgentInvocationForConversation(conversationId), getConversationStoppedAtMs(conversationId)]) : [void 0, void 0];
|
|
440
|
+
const kept = (await Promise.all(work.batch.map(async (entry) => {
|
|
441
|
+
const input = childAgentInput(entry.message);
|
|
442
|
+
if (!input) return entry;
|
|
443
|
+
if (await routeChildInput(entry.message, latest, stoppedAtMs) === "dropped") return;
|
|
444
|
+
const invocation = await getChildAgentInputInvocation(entry.message, input);
|
|
445
|
+
if (entry.message.input.authorId !== resultAuthorId(invocation.actor)) return {
|
|
446
|
+
...entry,
|
|
447
|
+
actor: EVENT_SYSTEM_ACTOR
|
|
448
|
+
};
|
|
449
|
+
return input.kind === "result" && invocation.credentialContext ? {
|
|
450
|
+
...entry,
|
|
451
|
+
actor: invocation.actor,
|
|
452
|
+
credentialContext: invocation.credentialContext
|
|
453
|
+
} : {
|
|
454
|
+
...entry,
|
|
455
|
+
actor: invocation.actor
|
|
456
|
+
};
|
|
457
|
+
}))).filter((entry) => entry !== void 0);
|
|
458
|
+
return kept.length > 0 ? {
|
|
459
|
+
kind: "mailbox",
|
|
460
|
+
batch: kept
|
|
461
|
+
} : void 0;
|
|
462
|
+
}
|
|
463
|
+
export { enqueueAgentMessageToParent as a, enqueueAgentInvocationResult as i, createDeliverToParent as n, result_exports as o, createEndStoppedChildWork as r, withAgentInvocationResultActors as s, createChildConversationWorker as t };
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { A as latestConversationMessageSeq, I as upsertConversationMessage, M as normalizeConversationText, N as recordDeliveredAssistantMessage,
|
|
2
|
-
import { S as setTags, T as withLogContext, p as logException } from "./logging-
|
|
3
|
-
import { M as SYSTEM_IDENTITY_ID, a as getConversationStore, r as getConversationEventStore } from "./db-
|
|
4
|
-
import { f as credentialContextForActor } from "./registry-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
1
|
+
import { A as latestConversationMessageSeq, I as upsertConversationMessage, M as normalizeConversationText, N as recordDeliveredAssistantMessage, W as authorizationId, a as loadProjection, an as getAssistantReplyText, b as persistConversationMessages, d as recordAuthorizationCompleted, j as markConversationMessage, mn as persistWithRetry, nt as saveTurnCheckpoint, t as commitAcceptedReply, v as hydrateConversationMessages } from "./projection-B08mfi0u.js";
|
|
2
|
+
import { S as setTags, T as withLogContext, p as logException } from "./logging-CQjlDQYX.js";
|
|
3
|
+
import { M as SYSTEM_IDENTITY_ID, a as getConversationStore, r as getConversationEventStore } from "./db-Br0tfAo7.js";
|
|
4
|
+
import { f as credentialContextForActor } from "./registry-BDWgCJDf.js";
|
|
5
|
+
import { F as messageCardText } from "./conversation-CvcBU1z2.js";
|
|
6
|
+
import { _ as ConversationTurnLifecycleService, g as startActiveTurn, h as markTurnFailed } from "./turn-user-message-ygLG3ylQ.js";
|
|
7
|
+
import { a as getPersistedThreadState, c as coerceThreadConversationState, i as getPersistedSandboxState, s as persistThreadStateById } from "./turn-session-routing-BlCtVFRN.js";
|
|
8
|
+
import { n as scheduleSessionCompletedPluginTasks, t as processPluginTask } from "./task-runner-COOwR8qm.js";
|
|
9
|
+
import { c as buildDeliveredTurnStatePatch, l as loadPendingMessageCards, o as completeAuthPauseTurn, r as finalizeFailedTurnReplyWithEvent, t as buildTurnThreadContext } from "./thread-context-Cd44z_W5.js";
|
|
9
10
|
import { randomUUID } from "node:crypto";
|
|
10
11
|
import { createLocalSource, localDestinationSchema } from "@sentry/junior-plugin-api";
|
|
11
12
|
// src/chat/local/runner.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ua as sandboxEgressSignalsResponseSchema } from "./projection-B08mfi0u.js";
|
|
2
2
|
// src/chat/local/sandbox-egress-signals.ts
|
|
3
3
|
const SANDBOX_EGRESS_SIGNALS_PATH = "/api/internal/sandbox-egress/signals";
|
|
4
4
|
const LOCAL_DEV_SERVER_TIMEOUT_MS = 1e3;
|