@sentry/junior 0.312.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-iIq7ihf7.js → adapter-JARQvoLw.js} +1 -2
- package/dist/{adapter-context-BRjEWRy1.js → adapter-context-B4BrJZuS.js} +2 -2
- package/dist/{admin-DhInw5K9.js → admin-BXGAySz0.js} +1 -1
- package/dist/{agent-runner-C9iDurwX.js → agent-runner-qZU5TR8i.js} +865 -138
- 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 +340 -106
- package/dist/{app-DRFrC8Mw.d.ts → app-D7tKnw9a.d.ts} +4 -21
- package/dist/app.d.ts +2 -2
- package/dist/app.js +80 -171
- package/dist/{background-compaction-queue-DrKi7w3d.js → background-compaction-queue-C_uIBUvS.js} +6 -17
- package/dist/{callback-mFlTUWWx.js → callback-C8SdXCwr.js} +4 -11
- package/dist/{catalog-runtime-D7xapBAX.js → catalog-runtime-BLKtnUL3.js} +1 -1
- package/dist/{channel-access-CJGfNTdn.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-kXB2Y5tl.js → config-BIfHKNXN.js} +40 -35
- package/dist/{continue-in-slack-O6pV5004.js → continue-in-slack-fnmD2Ifb.js} +5 -7
- package/dist/{conversation-feed-uNOv_x68.js → conversation-feed-DdFQuQDR.js} +13 -2
- package/dist/{logging-dQ9ZRGQ8.js → conversation-privacy-DtZhI91r.js} +188 -2
- package/dist/{conversation-turn-CeLbHqdw.js → conversation-turn-DScuDYmN.js} +465 -62
- package/dist/create-CrNt4Ewu.js +212 -0
- package/dist/{credential-sync-I8VBGk05.js → credential-sync-CtqsGjj1.js} +14 -18
- package/dist/{credentialed-Cb6E2phL.js → credentialed-dWRA3-oJ.js} +911 -429
- package/dist/{db-LAyyX8tk.js → db-BTmLKZrp.js} +2245 -50
- package/dist/{db-BbC5stfa.d.ts → db-DcmzbA55.d.ts} +2 -2
- package/dist/{history-CYstOMKX.js → history-CneKY7_V.js} +19 -1
- package/dist/{html-BCZ3Xtb_.js → html-B8rBt7F4.js} +5 -7
- package/dist/{install-DCFJFkC0.js → install-OtFboxOM.js} +2 -2
- package/dist/instrumentation.js +2 -2
- package/dist/{lineage-B_m-4TJw.js → lineage-EULJkGO1.js} +1 -2
- package/dist/{list-CN2QA2R9.js → list-C5400AlJ.js} +284 -113
- package/dist/{thread-state-DhPndWi1.js → mailbox-turn-DL3Lvsm0.js} +4830 -485
- package/dist/markers-DUP8aBOp.js +323 -0
- package/dist/{media-CYm1QD8T.js → media-FYM-Bl3H.js} +42 -14
- package/dist/{message-DSXGj1hM.js → message-DuDelZFr.js} +16 -15
- package/dist/{model-input--TrP9hYV.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-DHCZC6B4.js → oauth-callback-server-DX2fQ7Nq.js} +2 -2
- package/dist/{oauth-relay-pPMGnDZt.js → oauth-relay-PwPMdZJv.js} +1 -1
- package/dist/{plugins-Bkk0XRo2.js → plugins-BXMdNdyA.js} +1 -1
- package/dist/{registry-CZOzddwu.js → registry-D6kS6xYH.js} +1402 -64
- package/dist/{statuses-_cRJHXK7.js → reporting-window-C4dbzDiR.js} +1 -27
- package/dist/{resolve-cKOQ14Dh.js → resolve-D8CPJcNK.js} +3 -3
- package/dist/result-D090hxr5.js +402 -0
- package/dist/{runner-DBfUW44l.js → runner-BU7fgrm-.js} +7 -8
- package/dist/{sandbox-egress-signals-BVF_xAm1.js → sandbox-egress-signals-BUmVrsoG.js} +1 -1
- package/dist/{schema-Bk9Nm2E8.js → schema-7gW9vBpJ.js} +91 -10
- package/dist/{schema-BEHKxr4I.d.ts → schema-BB6E0wyV.d.ts} +2105 -2753
- package/dist/{service-account-CVYsFjty.js → service-account-plA-uzIB.js} +6 -5
- package/dist/{skills-VTnhAJWm.js → skills-CIosT6bS.js} +3 -3
- package/dist/{slack-conversation-unfurl-fuLnF1jE.js → slack-conversation-unfurl-CBgZqth6.js} +8 -10
- package/dist/spawn-DRjdzh3R.js +46 -0
- package/dist/{start-conversation-CEn2KH1A.js → start-conversation-a4NXH4X9.js} +13 -202
- package/dist/{store-DFZaN-Ix.js → store-BuhF1QDm.js} +2 -4
- package/dist/{task-queue-Cx4Lmjyk.js → task-queue-CrRjFzOh.js} +5 -16
- package/dist/{task-runner-CbTwFA6k.js → task-runner-C-pXsgHM.js} +105 -51
- package/dist/{thread-context-BkAZDTX2.js → thread-context-CDX4dSZd.js} +8 -10
- 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-nIzMtAVJ.js → validation-bTq88sya.js} +1 -1
- package/dist/{vercel-queue-hW90XzbG.js → vercel-queue-nL0Hq3hr.js} +32 -147
- package/dist/{version-Brbtz4Qf.js → version-DGUa1dZK.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{warmup-BDA5myRK.js → warmup-CCOuIwAS.js} +831 -3254
- package/dist/{worker-D63RcaVD.js → worker-AkZg7Dg1.js} +5 -6
- package/migrations/0158_keep_legacy_archive_columns.sql +5 -0
- package/migrations/0159_conversation_embeddings_fk_validate.sql +5 -0
- 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/0158_snapshot.json +6515 -0
- package/migrations/meta/0159_snapshot.json +6515 -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 +84 -0
- package/package.json +9 -18
- package/skills/design-automation-skill/SKILL.md +2 -3
- package/dist/actor-BsBdxDXQ.js +0 -208
- package/dist/child-message-DcsritGf.js +0 -179
- package/dist/conversation-privacy-L4ja1_W6.js +0 -189
- package/dist/executor-SCub-fAq.js +0 -1860
- package/dist/fan-out-Cod-yEHG.js +0 -10
- package/dist/ingest-BDf3D50j.js +0 -3836
- package/dist/result-DcvEOe1r.js +0 -574
- package/dist/result-event-type-BdIJuZxg.js +0 -48
- package/dist/service-account-Ts4ulcrV.js +0 -931
- package/dist/spawn-vxAarlX5.js +0 -73
- package/dist/state-C1P3_Ywk.js +0 -161
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { g as TURN_REASONING_LEVELS, gt as mapBounded } from "./config-BIfHKNXN.js";
|
|
2
|
+
import { Ar as juniorConversationEvents, Br as juniorConversations, L as isPersonInput, Sr as juniorAgentBindings, ct as conversationTurnFailedSql, i as getConversationStore, n as getConversationEventStore, o as getSqlExecutor } from "./db-BTmLKZrp.js";
|
|
3
|
+
import { q as credentialContextSchema } from "./registry-D6kS6xYH.js";
|
|
4
|
+
import { An as conversationSubtreeColumns, Bt as getConversationWorkState, E as isPersonStopTurnId, K as getConversationStoppedAtMs, On as buildDeterministicTurnId, P as isEventMailboxMetadata, Vt as getConversationWorkStates, _ as readChildOfStoredParent, b as readAgentConfig, bi as readParentMessage, hi as readInboundMessageSender, i as listActiveMailboxTurns, kn as conversationSubtree, r as listActiveMailboxTurnSources } from "./mailbox-turn-DL3Lvsm0.js";
|
|
5
|
+
import { sn as isAgentUpdateEventType, ut as agentTypeSchema } from "./media-FYM-Bl3H.js";
|
|
6
|
+
import * as z from "zod";
|
|
7
|
+
import pLimit from "p-limit";
|
|
8
|
+
import { actorSchema } from "@sentry/junior-plugin-api";
|
|
9
|
+
import { and, desc, eq, inArray, isNotNull, ne, sql } from "drizzle-orm";
|
|
10
|
+
import { alias } from "drizzle-orm/pg-core";
|
|
11
|
+
// src/chat/agent-invocations/child-input.ts
|
|
12
|
+
/** Read the child that one reply or message Event names. */
|
|
13
|
+
function childAgentInput(message) {
|
|
14
|
+
const metadata = message.input.metadata;
|
|
15
|
+
if (!isEventMailboxMetadata(metadata) || metadata.event.namespace !== "junior") return;
|
|
16
|
+
if (metadata.event.eventType === "agent.message") return {
|
|
17
|
+
kind: "message",
|
|
18
|
+
senderId: metadata.event.identifier
|
|
19
|
+
};
|
|
20
|
+
return isAgentUpdateEventType(metadata.event.eventType) && metadata.event.subscriptionId === void 0 ? {
|
|
21
|
+
kind: "reply",
|
|
22
|
+
senderId: metadata.event.identifier
|
|
23
|
+
} : void 0;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Return whether a Conversation drops one input, so it starts no work.
|
|
27
|
+
* Routing, the stop skips, and the child agent status all read this, so they
|
|
28
|
+
* agree on which input starts work.
|
|
29
|
+
*
|
|
30
|
+
* A parent message is dropped when it does not come from the stored parent,
|
|
31
|
+
* or when it was sent before the child's stop. A child reply that a stop
|
|
32
|
+
* skips is dropped too. A stopped Conversation never reads other automated
|
|
33
|
+
* input: `enqueueAutomatedInput` and the stop hold it first.
|
|
34
|
+
*/
|
|
35
|
+
async function isDroppedChildInput(message) {
|
|
36
|
+
if (isPersonInput(message.source)) return false;
|
|
37
|
+
const parentMessage = readParentMessage(message);
|
|
38
|
+
if (parentMessage) {
|
|
39
|
+
const child = await readChildOfStoredParent(message, parentMessage);
|
|
40
|
+
if (!child) return true;
|
|
41
|
+
const stoppedAtMs = child.stoppedAt?.getTime();
|
|
42
|
+
return stoppedAtMs !== void 0 && message.receivedAtMs <= stoppedAtMs;
|
|
43
|
+
}
|
|
44
|
+
return childAgentInput(message)?.kind === "reply" && await isSkippedReply(message);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Return whether a stop skipped this reply. A stop drops a child's unread
|
|
48
|
+
* replies from the parent's mailbox. One sent before the stop can reach the
|
|
49
|
+
* mailbox after that drop, so while the sending child is stopped, a reply
|
|
50
|
+
* that it sent after the stop is dropped too, except the `stopped` result
|
|
51
|
+
* that a person's stop sends. A message that a child sent is still
|
|
52
|
+
* delivered.
|
|
53
|
+
*/
|
|
54
|
+
async function isSkippedReply(message) {
|
|
55
|
+
const sender = readInboundMessageSender(message);
|
|
56
|
+
if (!sender || isPersonStopTurnId(sender.turnId)) return false;
|
|
57
|
+
const senderStoppedAtMs = await getConversationStoppedAtMs(sender.conversationId);
|
|
58
|
+
return senderStoppedAtMs !== void 0 && message.createdAtMs >= senderStoppedAtMs;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Read the sender of one child Conversation from its parent edge and its
|
|
62
|
+
* binding. A Conversation without a parent has none.
|
|
63
|
+
*/
|
|
64
|
+
async function readChildConversationSender(childConversationId) {
|
|
65
|
+
const parent = alias(juniorConversations, "parent");
|
|
66
|
+
const [row] = await getSqlExecutor().db().select({
|
|
67
|
+
agentName: juniorAgentBindings.name,
|
|
68
|
+
parentConversationId: parent.conversationId,
|
|
69
|
+
title: juniorConversations.title
|
|
70
|
+
}).from(juniorConversations).innerJoin(parent, eq(parent.conversationId, juniorConversations.parentConversationId)).leftJoin(juniorAgentBindings, eq(juniorAgentBindings.childConversationId, juniorConversations.conversationId)).where(eq(juniorConversations.conversationId, childConversationId));
|
|
71
|
+
return row ? {
|
|
72
|
+
...row.agentName ? { agentName: row.agentName } : void 0,
|
|
73
|
+
childConversationId,
|
|
74
|
+
parentConversationId: row.parentConversationId,
|
|
75
|
+
...row.title ? { title: row.title } : void 0
|
|
76
|
+
} : void 0;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Read the sender of one reply or message, when it is a child of the
|
|
80
|
+
* Conversation that received it. Otherwise the input has no child sender,
|
|
81
|
+
* such as one that an Agent invocation of an earlier release sent.
|
|
82
|
+
*/
|
|
83
|
+
async function getChildAgentInputSender(message, input) {
|
|
84
|
+
const sender = await readChildConversationSender(input.senderId);
|
|
85
|
+
return sender?.parentConversationId === message.conversationId ? sender : void 0;
|
|
86
|
+
}
|
|
87
|
+
// src/chat/agent-invocations/types.ts
|
|
88
|
+
const exactStringSchema = z.string().min(1).refine((value) => value === value.trim());
|
|
89
|
+
const agentNameSchema = exactStringSchema.max(64);
|
|
90
|
+
/**
|
|
91
|
+
* Kind of a new child Conversation. A Thread is a child that people can
|
|
92
|
+
* message; a Task is one that only its parent messages.
|
|
93
|
+
*/
|
|
94
|
+
const CHILD_AGENT_KINDS = ["thread", "task"];
|
|
95
|
+
/** `messageAgent` target for the parent of a child agent. */
|
|
96
|
+
const PARENT_AGENT_TARGET = "parent";
|
|
97
|
+
const agentBindingSchema = z.object({
|
|
98
|
+
childConversationId: exactStringSchema,
|
|
99
|
+
name: agentNameSchema,
|
|
100
|
+
parentConversationId: exactStringSchema
|
|
101
|
+
}).strict();
|
|
102
|
+
/** Input of one `spawnAgent` call. */
|
|
103
|
+
const spawnChildAgentInputSchema = z.object({
|
|
104
|
+
actor: actorSchema,
|
|
105
|
+
agentName: agentNameSchema.optional(),
|
|
106
|
+
credentialContext: credentialContextSchema.optional(),
|
|
107
|
+
idempotencyKey: exactStringSchema,
|
|
108
|
+
input: exactStringSchema,
|
|
109
|
+
kind: z.enum(CHILD_AGENT_KINDS).default("task"),
|
|
110
|
+
parentConversationId: exactStringSchema,
|
|
111
|
+
parentToolCallId: exactStringSchema,
|
|
112
|
+
agentType: agentTypeSchema.optional(),
|
|
113
|
+
fork: z.literal(true).optional(),
|
|
114
|
+
reasoningLevel: z.enum(TURN_REASONING_LEVELS).optional(),
|
|
115
|
+
title: exactStringSchema.optional()
|
|
116
|
+
}).strict();
|
|
117
|
+
/** How a finished task of a child agent ended. A stop is not a result. */
|
|
118
|
+
const CHILD_AGENT_RESULTS = [
|
|
119
|
+
"completed",
|
|
120
|
+
"blocked",
|
|
121
|
+
"failed"
|
|
122
|
+
];
|
|
123
|
+
// src/chat/agent-invocations/list.ts
|
|
124
|
+
const childAgentKindSchema = z.enum(CHILD_AGENT_KINDS);
|
|
125
|
+
/** Bound the child agents that one listing reads. */
|
|
126
|
+
const CHILD_AGENT_LIST_LIMIT = 200;
|
|
127
|
+
/**
|
|
128
|
+
* List the direct child agents of one parent Conversation, with the newest
|
|
129
|
+
* activity first. The state comes from each child's Turns and mailbox, not
|
|
130
|
+
* from model output. Each child agent stores its agent config, so older
|
|
131
|
+
* children of a parent, such as ones that a removed feature created, are not
|
|
132
|
+
* listed. A child is `running` while a Turn or mailbox input that answers its
|
|
133
|
+
* parent is open, and is `failed` when its last Turn failed, also when the
|
|
134
|
+
* Turn ended with a model error and execution went back to idle. Turns do
|
|
135
|
+
* not store a blocked result, so only a failure sets `lastResult`.
|
|
136
|
+
*/
|
|
137
|
+
async function listChildAgents(parentConversationId) {
|
|
138
|
+
const rows = await getSqlExecutor().db().select({
|
|
139
|
+
agentName: juniorAgentBindings.name,
|
|
140
|
+
archivedAt: juniorConversations.archivedAt,
|
|
141
|
+
conversationId: juniorConversations.conversationId,
|
|
142
|
+
executionUpdatedAt: juniorConversations.executionUpdatedAt,
|
|
143
|
+
kind: juniorConversations.kind,
|
|
144
|
+
stoppedAt: juniorConversations.stoppedAt,
|
|
145
|
+
title: juniorConversations.title,
|
|
146
|
+
turnFailed: conversationTurnFailedSql(juniorConversations),
|
|
147
|
+
updatedAt: juniorConversations.updatedAt
|
|
148
|
+
}).from(juniorConversations).leftJoin(juniorAgentBindings, eq(juniorAgentBindings.childConversationId, juniorConversations.conversationId)).where(and(eq(juniorConversations.parentConversationId, parentConversationId), isNotNull(juniorConversations.agentConfig))).orderBy(desc(sql`coalesce(${juniorConversations.executionUpdatedAt}, ${juniorConversations.updatedAt})`)).limit(CHILD_AGENT_LIST_LIMIT);
|
|
149
|
+
const ids = rows.map((row) => row.conversationId);
|
|
150
|
+
const [workStates, mailboxTurnSources] = await Promise.all([getConversationWorkStates(ids), listActiveMailboxTurnSources(ids)]);
|
|
151
|
+
const limit = pLimit(8);
|
|
152
|
+
return (await Promise.all(rows.map(async (row) => {
|
|
153
|
+
const kind = childAgentKindSchema.parse(row.kind);
|
|
154
|
+
const stoppedAtMs = row.stoppedAt?.getTime();
|
|
155
|
+
const running = stoppedAtMs === void 0 && await limit(() => runsOnConversationLoop(workStates.get(row.conversationId)?.execution.pendingMessages ?? [], mailboxTurnSources.get(row.conversationId) ?? []));
|
|
156
|
+
return {
|
|
157
|
+
...row.agentName ? { agentName: row.agentName } : void 0,
|
|
158
|
+
...row.archivedAt ? { archivedAtMs: row.archivedAt.getTime() } : void 0,
|
|
159
|
+
childConversationId: row.conversationId,
|
|
160
|
+
kind,
|
|
161
|
+
...row.turnFailed && !running ? { lastResult: "failed" } : void 0,
|
|
162
|
+
status: stoppedAtMs !== void 0 ? "stopped" : running ? "running" : row.turnFailed ? "failed" : "completed",
|
|
163
|
+
task: row.title ?? "",
|
|
164
|
+
...row.title ? { title: row.title } : void 0,
|
|
165
|
+
updatedAtMs: (row.executionUpdatedAt ?? row.updatedAt).getTime()
|
|
166
|
+
};
|
|
167
|
+
}))).sort((left, right) => right.updatedAtMs - left.updatedAtMs);
|
|
168
|
+
}
|
|
169
|
+
/** List the ids of the child agents of one parent that have open work. */
|
|
170
|
+
async function listOpenChildAgents(parentConversationId) {
|
|
171
|
+
return (await listChildAgents(parentConversationId)).filter((child) => child.status === "running").map((child) => child.childConversationId);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Return whether a child has work that will answer its parent: `pending`
|
|
175
|
+
* input that waits in the mailbox until its Turn commits it, such as a Watch
|
|
176
|
+
* Event in its debounce window, or an open mailbox Turn. Every Turn of a
|
|
177
|
+
* child answers its parent, whoever started it.
|
|
178
|
+
*/
|
|
179
|
+
async function runsOnConversationLoop(pending, mailboxTurnSources) {
|
|
180
|
+
if (mailboxTurnSources.length > 0) return true;
|
|
181
|
+
for (const message of pending) if (!await isDroppedChildInput(message)) return true;
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Return whether input waits in a child's mailbox that will run a later Turn
|
|
186
|
+
* that answers its parent, such as a fired Timer whose Watch is already gone.
|
|
187
|
+
* The input that the running attempt took belongs to its own Turn, which
|
|
188
|
+
* can ack it as late as its end.
|
|
189
|
+
*/
|
|
190
|
+
async function hasWaitingParentWork(conversationId) {
|
|
191
|
+
const work = await getConversationWorkState({ conversationId });
|
|
192
|
+
const running = new Set(work?.runningInboundMessageIds);
|
|
193
|
+
return await runsOnConversationLoop((work?.messages ?? []).filter((message) => !running.has(message.inboundMessageId)), []);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* List the ids of a child's open Turns on the Conversation loop. A Turn keeps
|
|
197
|
+
* its input in the mailbox until it commits it, so before its first
|
|
198
|
+
* checkpoint its id comes from its first input. Attempt selection can take
|
|
199
|
+
* any pending input first, so each one gives a candidate id.
|
|
200
|
+
*/
|
|
201
|
+
async function listOpenLoopTurnIds(conversationId) {
|
|
202
|
+
const [turns, work] = await Promise.all([listActiveMailboxTurns(conversationId), getConversationWorkState({ conversationId })]);
|
|
203
|
+
return [...turns.map((turn) => turn.turnId), ...(work?.execution.pendingMessages ?? []).map((message) => buildDeterministicTurnId(message.inboundMessageId))];
|
|
204
|
+
}
|
|
205
|
+
async function listAnsweredLoopChildren(children, parentMessages) {
|
|
206
|
+
if (children.length === 0 || parentMessages.length === 0) return [];
|
|
207
|
+
return (await mapBounded(children, async ({ childConversationId }) => {
|
|
208
|
+
const turnIds = await listOpenLoopTurnIds(childConversationId);
|
|
209
|
+
return parentMessages.some(({ sender }) => sender.conversationId === childConversationId && turnIds.includes(sender.turnId)) ? childConversationId : void 0;
|
|
210
|
+
})).filter((id) => id !== void 0);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* List the other child agents of one parent that still run and have not
|
|
214
|
+
* answered. A running child whose open Turn's `reply` is already among
|
|
215
|
+
* `parentMessages`, the child replies and results that reached the parent's
|
|
216
|
+
* mailbox, has answered, so it does not count.
|
|
217
|
+
*/
|
|
218
|
+
async function listUnreportedSiblingAgents(parentConversationId, childConversationId, parentMessages) {
|
|
219
|
+
const running = (await listChildAgents(parentConversationId)).filter((child) => child.childConversationId !== childConversationId && child.status === "running");
|
|
220
|
+
const answered = new Set(await listAnsweredLoopChildren(running, parentMessages));
|
|
221
|
+
return running.filter((child) => !answered.has(child.childConversationId));
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* List every child agent below one Conversation, at any depth. A parent owns
|
|
225
|
+
* the work of its child agents and of their child agents. The list never has
|
|
226
|
+
* the Conversation itself, its parent, or a sibling.
|
|
227
|
+
*/
|
|
228
|
+
async function listDescendantAgents(conversationId) {
|
|
229
|
+
return (await getSqlExecutor().db().select({
|
|
230
|
+
conversationId: juniorConversations.conversationId,
|
|
231
|
+
name: juniorAgentBindings.name
|
|
232
|
+
}).from(juniorConversations).innerJoin(conversationSubtree([conversationId]), eq(conversationSubtreeColumns.conversationId, juniorConversations.conversationId)).leftJoin(juniorAgentBindings, eq(juniorAgentBindings.childConversationId, juniorConversations.conversationId)).where(ne(juniorConversations.conversationId, conversationId)).orderBy(juniorConversations.conversationId)).map((row) => ({
|
|
233
|
+
conversationId: row.conversationId,
|
|
234
|
+
...row.name ? { name: row.name } : void 0
|
|
235
|
+
}));
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* List the agents that one Conversation can see. A root Conversation sees
|
|
239
|
+
* only its child agents. A child agent also sees itself, its parent, and the
|
|
240
|
+
* other child agents of its parent.
|
|
241
|
+
*/
|
|
242
|
+
async function listAgentRelatives(input) {
|
|
243
|
+
const { conversationId, parentConversationId } = input;
|
|
244
|
+
const [children, family, parent] = await Promise.all([
|
|
245
|
+
listChildAgents(conversationId),
|
|
246
|
+
parentConversationId ? listChildAgents(parentConversationId) : [],
|
|
247
|
+
parentConversationId ? getConversationStore().get({ conversationId: parentConversationId }) : void 0
|
|
248
|
+
]);
|
|
249
|
+
const self = family.find((agent) => agent.childConversationId === conversationId);
|
|
250
|
+
return {
|
|
251
|
+
children,
|
|
252
|
+
...parent ? { parent: {
|
|
253
|
+
conversationId: parent.conversationId,
|
|
254
|
+
status: parent.execution.status,
|
|
255
|
+
updatedAtMs: parent.execution.updatedAtMs ?? parent.updatedAtMs
|
|
256
|
+
} } : void 0,
|
|
257
|
+
...self ? { self } : void 0,
|
|
258
|
+
siblings: family.filter((agent) => agent.childConversationId !== conversationId)
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
// src/chat/agent-invocations/markers.ts
|
|
262
|
+
const SUBAGENT_KIND = "agent";
|
|
263
|
+
const SUBAGENT_STARTED_KEY_PREFIX = "subagent_started:";
|
|
264
|
+
const SUBAGENT_ENDED_KEY_PREFIX = "subagent_ended:";
|
|
265
|
+
/**
|
|
266
|
+
* Record in the parent Conversation that a child agent got one task or
|
|
267
|
+
* message. Write it before the input reaches the child's mailbox, so the
|
|
268
|
+
* child cannot end first.
|
|
269
|
+
*/
|
|
270
|
+
async function recordSubagentStartedMarker(start) {
|
|
271
|
+
await getConversationEventStore().append(start.parentConversationId, [{
|
|
272
|
+
idempotencyKey: `${SUBAGENT_STARTED_KEY_PREFIX}${start.markerId}`,
|
|
273
|
+
data: {
|
|
274
|
+
type: "subagent_started",
|
|
275
|
+
subagentInvocationId: start.markerId,
|
|
276
|
+
subagentKind: SUBAGENT_KIND,
|
|
277
|
+
childConversationId: start.childConversationId,
|
|
278
|
+
...start.agentName ? { agentName: start.agentName } : void 0,
|
|
279
|
+
parentToolCallId: start.parentToolCallId,
|
|
280
|
+
task: start.input,
|
|
281
|
+
...start.title ? { title: start.title } : void 0,
|
|
282
|
+
...start.reasoningLevel ? { reasoningLevel: start.reasoningLevel } : void 0
|
|
283
|
+
},
|
|
284
|
+
createdAtMs: start.createdAtMs
|
|
285
|
+
}]);
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Record in the parent Conversation how the work of a child agent ended.
|
|
289
|
+
* Each parent message has its own `subagent_started` marker, named by the
|
|
290
|
+
* message id, and each one that the child already took ends with `outcome`.
|
|
291
|
+
* A parent message that still waits in the child's mailbox stays open,
|
|
292
|
+
* because later work reads it, unless `includeWaiting` is set, as for a stop
|
|
293
|
+
* that skips it. Write it before the child's result reaches the parent.
|
|
294
|
+
*/
|
|
295
|
+
async function recordChildAgentEnded(childConversationId, outcome, options = {}) {
|
|
296
|
+
if (!await readAgentConfig(childConversationId)) return;
|
|
297
|
+
const work = await getConversationWorkState({
|
|
298
|
+
conversationId: childConversationId,
|
|
299
|
+
state: options.state
|
|
300
|
+
});
|
|
301
|
+
const running = new Set(work?.runningInboundMessageIds);
|
|
302
|
+
const waiting = new Set(options.includeWaiting ? [] : (work?.messages ?? []).map((message) => message.inboundMessageId).filter((id) => !running.has(id)));
|
|
303
|
+
const taken = (work?.execution.inboundMessageIds ?? []).filter((id) => !waiting.has(id));
|
|
304
|
+
if (taken.length === 0) return;
|
|
305
|
+
const sender = await readChildConversationSender(childConversationId);
|
|
306
|
+
if (!sender) return;
|
|
307
|
+
const keys = await getSqlExecutor().db().select({ idempotencyKey: juniorConversationEvents.idempotencyKey }).from(juniorConversationEvents).where(and(eq(juniorConversationEvents.conversationId, sender.parentConversationId), inArray(juniorConversationEvents.idempotencyKey, taken.flatMap((id) => [`${SUBAGENT_STARTED_KEY_PREFIX}${id}`, `${SUBAGENT_ENDED_KEY_PREFIX}${id}`]))));
|
|
308
|
+
const found = new Set(keys.map((row) => row.idempotencyKey));
|
|
309
|
+
const open = taken.filter((id) => found.has(`${SUBAGENT_STARTED_KEY_PREFIX}${id}`) && !found.has(`${SUBAGENT_ENDED_KEY_PREFIX}${id}`));
|
|
310
|
+
if (open.length > 0) await appendSubagentEnded(sender.parentConversationId, open, outcome, options.nowMs ?? Date.now());
|
|
311
|
+
}
|
|
312
|
+
async function appendSubagentEnded(parentConversationId, markerIds, outcome, createdAtMs) {
|
|
313
|
+
await getConversationEventStore().append(parentConversationId, markerIds.map((id) => ({
|
|
314
|
+
idempotencyKey: `${SUBAGENT_ENDED_KEY_PREFIX}${id}`,
|
|
315
|
+
data: {
|
|
316
|
+
type: "subagent_ended",
|
|
317
|
+
subagentInvocationId: id,
|
|
318
|
+
outcome
|
|
319
|
+
},
|
|
320
|
+
createdAtMs
|
|
321
|
+
})));
|
|
322
|
+
}
|
|
323
|
+
export { isDroppedChildInput as _, listChildAgents as a, listUnreportedSiblingAgents as c, PARENT_AGENT_TARGET as d, agentBindingSchema as f, getChildAgentInputSender as g, childAgentInput as h, listAgentRelatives as i, CHILD_AGENT_KINDS as l, spawnChildAgentInputSchema as m, recordSubagentStartedMarker as n, listDescendantAgents as o, agentNameSchema as p, hasWaitingParentWork as r, listOpenChildAgents as s, recordChildAgentEnded as t, CHILD_AGENT_RESULTS as u, readChildConversationSender as v };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as conversationTurnFailureReasonSchema,
|
|
1
|
+
import { a as conversationTurnFailureReasonSchema, b as usageSchema, i as conversationTurnFailureCodeSchema } from "./history-CneKY7_V.js";
|
|
2
2
|
import * as z from "zod";
|
|
3
3
|
import { actorUserIdSchema, conversationAnnotationInputSchema, conversationEventPresentationSchema, conversationSidebarAnnotationSchema, destinationVisibilitySchema, eventMatchFieldsSchema, eventMatchSchema, eventReachSchema, eventTypeSchema, objectFactFields, objectTypeSchema, pluginEventTypeSchema, slackDestinationSchema, taskOutcomeSchema } from "@sentry/junior-plugin-api";
|
|
4
4
|
// src/chat/automations/task.ts
|
|
@@ -43,6 +43,27 @@ function automationTaskColumns(task) {
|
|
|
43
43
|
skill: task.skill
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
+
// src/chat/agent-invocations/result-event-type.ts
|
|
47
|
+
/** Event namespace of the messages between a parent and its child agents. */
|
|
48
|
+
const AGENT_INVOCATION_EVENT_NAMESPACE = "junior";
|
|
49
|
+
const AGENT_INVOCATION_RESULT_EVENT_TYPE_PREFIX = "agent_invocation.";
|
|
50
|
+
/** True when an Event type names an agent invocation result. */
|
|
51
|
+
function isAgentInvocationResultEventType(eventType) {
|
|
52
|
+
return eventType.startsWith(AGENT_INVOCATION_RESULT_EVENT_TYPE_PREFIX);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Event type of an agent update: what a Conversation reports when a Turn
|
|
56
|
+
* ends, it waits on a person, or it stops. A parent gets it from its child
|
|
57
|
+
* agents, and a Watch on the Conversation gets the same Event.
|
|
58
|
+
*/
|
|
59
|
+
const AGENT_UPDATE_EVENT_TYPE = "agent.update";
|
|
60
|
+
const LEGACY_AGENT_REPLY_EVENT_TYPE = "agent.reply";
|
|
61
|
+
/** True when an Event type names an agent update. */
|
|
62
|
+
function isAgentUpdateEventType(eventType) {
|
|
63
|
+
return eventType === "agent.update" || eventType === LEGACY_AGENT_REPLY_EVENT_TYPE;
|
|
64
|
+
}
|
|
65
|
+
/** Event type of a message that a child agent sends to its parent. */
|
|
66
|
+
const AGENT_MESSAGE_EVENT_TYPE = "agent.message";
|
|
46
67
|
// src/chat/inbox-items/user-input-request.ts
|
|
47
68
|
const USER_INPUT_LIMITS = {
|
|
48
69
|
maxButtonOptions: 5,
|
|
@@ -691,8 +712,8 @@ function compileScheduleIntent(args) {
|
|
|
691
712
|
time: parseLocalTime(args.intent.timing.time),
|
|
692
713
|
timezone
|
|
693
714
|
});
|
|
694
|
-
if (nextRunAtMs === void 0) throw new ScheduleIntentError("The requested local date or time does not exist in that timezone.");
|
|
695
|
-
if (nextRunAtMs <= args.nowMs) throw new ScheduleIntentError("The requested one-off schedule must be in the future.");
|
|
715
|
+
if (nextRunAtMs === void 0) throw new ScheduleIntentError("The requested local date or time does not exist in that timezone. Choose another local time.");
|
|
716
|
+
if (nextRunAtMs <= args.nowMs) throw new ScheduleIntentError("The requested one-off schedule must be in the future. Set a time after now.");
|
|
696
717
|
return {
|
|
697
718
|
nextRunAtMs,
|
|
698
719
|
schedule: {
|
|
@@ -720,7 +741,7 @@ function compileScheduleIntent(args) {
|
|
|
720
741
|
recurrence: searchRecurrence,
|
|
721
742
|
timezone
|
|
722
743
|
});
|
|
723
|
-
if (nextRunAtMs === void 0) throw new ScheduleIntentError("The recurring schedule has no valid future occurrence.");
|
|
744
|
+
if (nextRunAtMs === void 0) throw new ScheduleIntentError("The recurring schedule has no valid future occurrence. Change the schedule so that it runs at least once after now.");
|
|
724
745
|
const materializedRecurrence = args.intent.startDate ? recurrence : {
|
|
725
746
|
...recurrence,
|
|
726
747
|
startDate: localDateAt(nextRunAtMs, timezone)
|
|
@@ -1062,9 +1083,9 @@ const conversationTreeStateSchema = z.enum([
|
|
|
1062
1083
|
* reads with its task. Runtime code reads only these fields, never a type
|
|
1063
1084
|
* name, so types can later come from configuration. Types do not limit tools:
|
|
1064
1085
|
* Guardian reviews each child action against the root user's messages, as for
|
|
1065
|
-
* any child. A child keeps its type for later
|
|
1086
|
+
* any child. A child keeps its type for every later task. How a child
|
|
1066
1087
|
* starts, fresh or forked from its parent's history, is not a type: see
|
|
1067
|
-
* `fork`
|
|
1088
|
+
* `fork` in its agent config.
|
|
1068
1089
|
*/
|
|
1069
1090
|
const AGENT_TYPES = ["explore", "reviewer"];
|
|
1070
1091
|
/**
|
|
@@ -1076,7 +1097,7 @@ const agentTypeSchema = z.string().regex(/^[a-z][a-z0-9_-]*$/);
|
|
|
1076
1097
|
const AGENT_TYPE_DEFINITIONS = {
|
|
1077
1098
|
explore: {
|
|
1078
1099
|
whenToUse: "Investigation across code, docs, logs, telemetry, or the web. Use it when an answer needs reading across many files or sources and you need the conclusion with evidence, not the raw output.",
|
|
1079
|
-
instructions: "You are an explore agent.
|
|
1100
|
+
instructions: "You are an explore agent. Investigate, and do not change anything outside your sandbox unless the task asks for it. Back your answer with exact evidence, such as paths, lines, links, and ids."
|
|
1080
1101
|
},
|
|
1081
1102
|
reviewer: {
|
|
1082
1103
|
whenToUse: "An independent second opinion on a change, plan, or claim. Give it the evidence to judge, not your conclusion.",
|
|
@@ -1333,12 +1354,9 @@ const conversationSummaryReportSchema = z.object({
|
|
|
1333
1354
|
locationUrl: z.string().url().optional(),
|
|
1334
1355
|
traceId: z.string().optional(),
|
|
1335
1356
|
/**
|
|
1336
|
-
* Plugin-
|
|
1337
|
-
*
|
|
1338
|
-
* Clients must not fetch provider state while rendering these links.
|
|
1357
|
+
* Plugin-selected annotations for the compact conversation row. The feed
|
|
1358
|
+
* sends only these; the detail also sends the full `annotations`.
|
|
1339
1359
|
*/
|
|
1340
|
-
annotations: z.array(conversationAnnotationReportSchema).optional(),
|
|
1341
|
-
/** Plugin-selected annotations for the compact conversation row. */
|
|
1342
1360
|
sidebarAnnotations: z.array(conversationSidebarAnnotationSchema).optional(),
|
|
1343
1361
|
assignedWork: z.boolean().optional(),
|
|
1344
1362
|
finishedWorkAt: z.string().datetime().optional(),
|
|
@@ -1384,7 +1402,7 @@ const conversationReportMessageEventDataSchema = z.object({
|
|
|
1384
1402
|
actorIdentity: actorIdentitySchema.optional(),
|
|
1385
1403
|
/** Identity id of the author. Detail `authors` maps it to the person. */
|
|
1386
1404
|
actorIdentityId: z.string().min(1).optional(),
|
|
1387
|
-
/**
|
|
1405
|
+
/** Set on input that an earlier release's agent wrote, not a person. */
|
|
1388
1406
|
agentInvocationId: z.string().min(1).optional(),
|
|
1389
1407
|
eventType: z.string().min(1).optional(),
|
|
1390
1408
|
/** Namespace of the first Event, such as `github`. */
|
|
@@ -1395,6 +1413,10 @@ const conversationReportMessageEventDataSchema = z.object({
|
|
|
1395
1413
|
*/
|
|
1396
1414
|
eventIdentifier: z.string().min(1).optional(),
|
|
1397
1415
|
eventObjectType: objectTypeSchema.optional(),
|
|
1416
|
+
/** What the first Event says happened, when it is an agent update. */
|
|
1417
|
+
eventStatus: z.string().min(1).optional(),
|
|
1418
|
+
/** Watch that delivered the first Event. */
|
|
1419
|
+
eventWatchId: z.string().min(1).optional(),
|
|
1398
1420
|
explicitMention: z.boolean().optional(),
|
|
1399
1421
|
quiet: z.literal(true).optional(),
|
|
1400
1422
|
trustedSummary: z.string().min(1).optional(),
|
|
@@ -1756,6 +1778,12 @@ const conversationDetailReportSchema = conversationSummaryReportSchema.extend({
|
|
|
1756
1778
|
* Conversation last. Root Conversations omit it.
|
|
1757
1779
|
*/
|
|
1758
1780
|
agentTree: z.array(conversationAgentTreeNodeSchema).min(2).optional(),
|
|
1781
|
+
/**
|
|
1782
|
+
* Plugin-owned annotations of this Conversation and its tree, when the
|
|
1783
|
+
* viewer can see private content. Clients must not fetch provider state
|
|
1784
|
+
* while rendering them.
|
|
1785
|
+
*/
|
|
1786
|
+
annotations: z.array(conversationAnnotationReportSchema).optional(),
|
|
1759
1787
|
/** The viewer's effective auto-archive choice. Participants only. */
|
|
1760
1788
|
autoArchive: z.boolean().optional(),
|
|
1761
1789
|
/** The viewer can fork this conversation from an assistant reply. */
|
|
@@ -2353,4 +2381,4 @@ function isVisionImageMediaType(mediaType) {
|
|
|
2353
2381
|
const normalized = mediaType.split(";", 1)[0]?.trim().toLowerCase();
|
|
2354
2382
|
return normalized ? INPUT_IMAGE_TYPES.some((type) => type === normalized) : false;
|
|
2355
2383
|
}
|
|
2356
|
-
export { conversationReportStatusSchema as $, formatUserInputAnswer as $t, automationVersionActivateSchema as A, automationContextToolSchema as At, conversationActivityPreviewSchema as B, toolScheduleIntentSchema as Bt, automationRunListSchema as C, removedCardSchema as Ct, automationSchedulePreviewSchema as D, inputFileSchema as Dt, automationScheduleIntentSchema as E, MAX_INPUT_ATTACHMENTS as Et, scheduledAutomationSummarySchema as F, scheduledAutomationSchema as Ft, conversationDetailReportSchema as G, isValidTimeZone as Gt, conversationAttachmentQuerySchema as H, getFirstRunAtMs as Ht, CONVERSATION_DETAIL_VERSION_HEADER as I, scheduledRunSchema as It, conversationEventsQuerySchema as J, inboxItemRequestSchema as Jt, conversationEventHistorySchema as K, eventAutomationSchema as Kt, CONVERSATION_VERSION_HEADER as L, ScheduleIntentError as Lt, automationVersionParamsSchema as M, automationTitleSchema as Mt, automationVersionSchema as N, taskOutcomeInputSchema as Nt, automationSummarySchema as O, messageAttachmentSchema as Ot, eventAutomationSummarySchema as P, SCHEDULED_AUTOMATION_SYSTEM_ACTOR as Pt, conversationReportMessageEventSchema as Q, buttonUserInputField as Qt, acceptedConversationMessageSchema as R, compileScheduleIntent as Rt, automationParamsSchema as S, readMessageCardRefs as St, automationRunWindowsSchema as T, MAX_ATTACHMENT_BYTES as Tt, conversationAuxiliaryCostsSchema as U, getNextRunAtMs as Ut, conversationAttachmentParamsSchema as V, weekdaySchema as Vt, conversationDetailQuerySchema as W, getZonedDateTimeParts as Wt, conversationReportEventDataSchema as X, USER_INPUT_NOTE as Xt, conversationParamsSchema as Y, USER_INPUT_LIMITS as Yt, conversationReportEventSchema as Z, answeredChoices as Zt, automationLifecycleSchema as _, conversationReadPositionSchema as _t, DEFAULT_NOTIFICATION_SCHEDULE as a,
|
|
2384
|
+
export { conversationReportStatusSchema as $, formatUserInputAnswer as $t, automationVersionActivateSchema as A, automationContextToolSchema as At, conversationActivityPreviewSchema as B, toolScheduleIntentSchema as Bt, automationRunListSchema as C, removedCardSchema as Ct, automationSchedulePreviewSchema as D, inputFileSchema as Dt, automationScheduleIntentSchema as E, MAX_INPUT_ATTACHMENTS as Et, scheduledAutomationSummarySchema as F, scheduledAutomationSchema as Ft, conversationDetailReportSchema as G, isValidTimeZone as Gt, conversationAttachmentQuerySchema as H, getFirstRunAtMs as Ht, CONVERSATION_DETAIL_VERSION_HEADER as I, scheduledRunSchema as It, conversationEventsQuerySchema as J, inboxItemRequestSchema as Jt, conversationEventHistorySchema as K, eventAutomationSchema as Kt, CONVERSATION_VERSION_HEADER as L, ScheduleIntentError as Lt, automationVersionParamsSchema as M, automationTitleSchema as Mt, automationVersionSchema as N, taskOutcomeInputSchema as Nt, automationSummarySchema as O, messageAttachmentSchema as Ot, eventAutomationSummarySchema as P, SCHEDULED_AUTOMATION_SYSTEM_ACTOR as Pt, conversationReportMessageEventSchema as Q, buttonUserInputField as Qt, acceptedConversationMessageSchema as R, compileScheduleIntent as Rt, automationParamsSchema as S, readMessageCardRefs as St, automationRunWindowsSchema as T, MAX_ATTACHMENT_BYTES as Tt, conversationAuxiliaryCostsSchema as U, getNextRunAtMs as Ut, conversationAttachmentParamsSchema as V, weekdaySchema as Vt, conversationDetailQuerySchema as W, getZonedDateTimeParts as Wt, conversationReportEventDataSchema as X, USER_INPUT_NOTE as Xt, conversationParamsSchema as Y, USER_INPUT_LIMITS as Yt, conversationReportEventSchema as Z, answeredChoices as Zt, automationLifecycleSchema as _, conversationReadPositionSchema as _t, DEFAULT_NOTIFICATION_SCHEDULE as a, AGENT_UPDATE_EVENT_TYPE as an, idempotencyKeySchema as at, automationListQuerySchema as b, messageCardRef as bt, CONTENT_VERSION_HEADER as c, automationSkillNameSchema as cn, AGENT_TYPES as ct, automationEditSchema as d, automationTaskSchema as dn, formatAgentTypes as dt, isEmptyUserInputAnswer as en, conversationSummaryReportSchema as et, automationEventCatalogSchema as f, automationTaskText as fn, conversationTreeStateSchema as ft, automationExecutionStatusSchema as g, renameConversationResponseSchema as gt, automationExecutionStatusDaySchema as h, renameConversationBodySchema as ht, isVisionImageMediaType as i, AGENT_MESSAGE_EVENT_TYPE as in, createConversationMessageBodySchema as it, automationVersionListSchema as j, automationInstructionToolSchema as jt, automationUpdateSchema as k, readMessageAttachments as kt, apiErrorSchema as l, automationTaskColumns as ln, agentTypeInstructions as lt, automationExecutionSchema as m, conversationTitleSchema as mt, INPUT_IMAGE_TYPES as n, userInputRequestSchema as nn, conversationUsageSchema as nt, isWithinNotificationSchedule as o, isAgentInvocationResultEventType as on, activityPreviewText as ot, automationExecutionListSchema as p, CONVERSATION_TITLE_MAX_LENGTH as pt, conversationEventPageSchema as q, eventAutomationTriggerSchema as qt, detectImageMediaType as r, AGENT_INVOCATION_EVENT_NAMESPACE as rn, createConversationBodySchema as rt, notificationScheduleSchema as s, isAgentUpdateEventType as sn, conversationChildAgentTotalsSchema as st, INLINE_VIDEO_TYPES as t, normalizeUserInputAnswer as tn, conversationSurfaceSchema as tt, automationEditErrorSchema as u, automationTaskDescription as un, agentTypeSchema as ut, automationListItemSchema as v, inboxItemChangeRecordSchema as vt, automationRunSchema as w, resolveMessageCards as wt, automationListSchema as x, messageCardText as xt, automationListPageSchema as y, annotationCard as yt, actorIdentitySchema as z, scheduleIntentFromTool as zt };
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
2
|
+
import { R as actorFromRun } from "./agent-runner-qZU5TR8i.js";
|
|
3
|
+
import { _t as AgentMessageTargetError, et as findChildAgentConversationId } from "./warmup-CCOuIwAS.js";
|
|
4
|
+
import { d as PARENT_AGENT_TARGET, v as readChildConversationSender } from "./markers-DUP8aBOp.js";
|
|
5
|
+
import { i as enqueueAgentMessageToParent } from "./result-D090hxr5.js";
|
|
6
|
+
import { t as messageChildAgent } from "./create-CrNt4Ewu.js";
|
|
7
|
+
import { Dn as canAccessConversation, Mn as readConversationAccessFromSql, a as getDb, dn as SYSTEM_IDENTITY_ID, i as getConversationStore } from "./db-BTmLKZrp.js";
|
|
8
|
+
import { G as enqueueAutomatedInput, k as EVENT_WAIT_MS } from "./mailbox-turn-DL3Lvsm0.js";
|
|
9
|
+
import { nt as renderDataTag } from "./config-BIfHKNXN.js";
|
|
10
|
+
import { i as leadPersonParticipates } from "./start-conversation-a4NXH4X9.js";
|
|
9
11
|
// src/chat/agent-invocations/top-level-message.ts
|
|
10
12
|
const AGENT_MESSAGE_EVENT_NAMESPACE = "junior";
|
|
11
13
|
/** Event type of a message from another top-level agent. */
|
|
@@ -40,7 +42,7 @@ async function requireTopLevelAgentAccess(args) {
|
|
|
40
42
|
})) throw new AgentMessageTargetError(`"${args.to}" is a public conversation and this conversation is private. A private conversation can message only conversations in its own channel or DM`);
|
|
41
43
|
}
|
|
42
44
|
function renderTopLevelMessageInput(args) {
|
|
43
|
-
return
|
|
45
|
+
return renderDataTag("agent-message", {
|
|
44
46
|
conversation_id: args.senderConversationId,
|
|
45
47
|
source: "top_level_agent"
|
|
46
48
|
}, "Another top-level agent", args.text.trim());
|
|
@@ -105,7 +107,7 @@ function bindMessageAgent(run, options) {
|
|
|
105
107
|
call.signal?.throwIfAborted();
|
|
106
108
|
const queue = typeof options.queue === "function" ? options.queue() : options.queue;
|
|
107
109
|
if (input.to === "parent") {
|
|
108
|
-
const sender = await
|
|
110
|
+
const sender = await readChildConversationSender(run.conversationId);
|
|
109
111
|
if (!sender) throw new AgentMessageTargetError("This conversation has no parent agent");
|
|
110
112
|
await enqueueAgentMessageToParent({
|
|
111
113
|
actor,
|
|
@@ -138,23 +140,22 @@ function bindMessageAgent(run, options) {
|
|
|
138
140
|
delivery: "queued"
|
|
139
141
|
};
|
|
140
142
|
}
|
|
141
|
-
const {
|
|
143
|
+
const { delivery } = await messageChildAgent({
|
|
142
144
|
actor,
|
|
143
145
|
childConversationId,
|
|
144
146
|
...run.credentialContext ? { credentialContext: run.credentialContext } : void 0,
|
|
145
|
-
destination: toolInvocationDestination(run),
|
|
146
147
|
idempotencyKey: `${run.turnId}:${call.toolCallId}`,
|
|
147
148
|
input: input.text,
|
|
148
149
|
parentConversationId: run.conversationId,
|
|
149
|
-
parentToolCallId: call.toolCallId
|
|
150
|
-
|
|
151
|
-
|
|
150
|
+
parentToolCallId: call.toolCallId,
|
|
151
|
+
parentTurnId: run.turnId
|
|
152
|
+
}, {
|
|
152
153
|
...options,
|
|
153
154
|
queue
|
|
154
155
|
});
|
|
155
156
|
return {
|
|
156
157
|
conversationId: childConversationId,
|
|
157
|
-
delivery
|
|
158
|
+
delivery
|
|
158
159
|
};
|
|
159
160
|
};
|
|
160
161
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
|
|
2
|
-
import {
|
|
3
|
-
import { i as isVisionImageMediaType, r as detectImageMediaType } from "./media-
|
|
4
|
-
import { i as readLiveAttachment } from "./store-
|
|
2
|
+
import { o as getSqlExecutor } from "./db-BTmLKZrp.js";
|
|
3
|
+
import { i as isVisionImageMediaType, r as detectImageMediaType } from "./media-FYM-Bl3H.js";
|
|
4
|
+
import { i as readLiveAttachment } from "./store-BuhF1QDm.js";
|
|
5
5
|
import { escapeTagText, renderTag } from "@sentry/junior-plugin-api";
|
|
6
6
|
// src/chat/attachments/model-input.ts
|
|
7
7
|
var model_input_exports = /* @__PURE__ */ __exportAll({ loadInputAttachments: () => loadInputAttachments });
|
package/dist/nitro.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as JuniorPluginSet } from "./plugins-fBrz8PCV.js";
|
|
2
|
-
import {
|
|
2
|
+
import { r as JuniorDashboardOptions } from "./app-D7tKnw9a.js";
|
|
3
3
|
import { withSentryConfig as withSentryConfig$1 } from "@sentry/nitro";
|
|
4
4
|
type SentryNitroConfig = Parameters<typeof withSentryConfig$1>[0];
|
|
5
5
|
type SentryNitroOptions = NonNullable<Parameters<typeof withSentryConfig$1>[1]>;
|
|
@@ -27,8 +27,6 @@ export interface JuniorNitroOptions {
|
|
|
27
27
|
/** Authenticated dashboard configuration injected for createApp(). */
|
|
28
28
|
dashboard?: JuniorNitroDashboardOptions;
|
|
29
29
|
maxDuration?: number;
|
|
30
|
-
/** Vercel Queue topic for durable conversation work. Must match the runtime queue producer topic. */
|
|
31
|
-
conversationWorkQueueTopic?: string;
|
|
32
30
|
/** Plugin catalog set or runtime-safe plugin module. Direct sets must not include runtime code. */
|
|
33
31
|
plugins?: JuniorNitroPluginSource;
|
|
34
32
|
/**
|
|
@@ -42,7 +40,7 @@ export interface JuniorNitroOptions {
|
|
|
42
40
|
/** Nitro module that configures deployment wiring and copies app/plugin content into the Vercel build output. */
|
|
43
41
|
export declare function juniorNitro(options?: JuniorNitroOptions): {
|
|
44
42
|
nitro: {
|
|
45
|
-
setup(nitro: unknown): void
|
|
43
|
+
setup(nitro: unknown): void | Promise<void>;
|
|
46
44
|
};
|
|
47
45
|
};
|
|
48
46
|
export {};
|