@sentry/junior 0.297.0 → 0.299.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/{actor-6jsm_v96.js → actor-D2iXzvlN.js} +2 -1
- package/dist/{state-DFnmLmfn.js → adapter-AgCNqqsG.js} +49 -133
- package/dist/{admin-tmGIw4KS.js → admin-1VwEXztm.js} +2 -2
- package/dist/{agent-runner-CneTquAE.js → agent-runner-Ciet8_nn.js} +1067 -1353
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +8 -7
- package/dist/api.d.ts +1 -1
- package/dist/api.js +125 -43
- package/dist/{app-BJojZ7HL.d.ts → app--ky-Eu33.d.ts} +6 -4
- package/dist/app.d.ts +1 -1
- package/dist/app.js +126 -299
- package/dist/{automation-BrP6ImrC.js → automation-M3RFJUBf.js} +1 -1
- package/dist/{background-compaction-queue-CwfJy3Cd.js → background-compaction-queue-CnimvRdk.js} +4 -4
- package/dist/{briefs-uFTuhMqA.js → briefs-CwzvgdCa.js} +4 -4
- package/dist/{catalog-runtime-0kuQqYL4.js → catalog-runtime-DaBaHY7u.js} +1 -1
- package/dist/cli/chat.js +17 -17
- package/dist/cli/check.js +3 -3
- package/dist/cli/main.js +3 -3
- package/dist/cli/plugins.js +5 -5
- package/dist/cli/snapshot-create.js +4 -4
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +4 -4
- package/dist/{config-Dj9M_nqB.js → config-CAXIpWQb.js} +80 -6
- package/dist/{connections-B96JUM5o.js → connections-Dy0hPdUq.js} +6 -6
- package/dist/continue-in-slack-DIOjFj76.js +176 -0
- package/dist/{conversation-CvcBU1z2.js → conversation-fCWD9Az3.js} +73 -13
- package/dist/{conversation-feed-BSMlGZnS.js → conversation-feed-BPK8vkkZ.js} +88 -3
- package/dist/{conversation-privacy-DI29jbZV.js → conversation-privacy-DUgtRkf8.js} +1 -1
- package/dist/{conversation-turn-CZWBr091.js → conversation-turn-DkJB6yMF.js} +85 -68
- package/dist/{credential-sync-Blhx4_xf.js → credential-sync-RX24Y8aY.js} +18 -18
- package/dist/{db-CrtyFRz7.d.ts → db-B07FtU9g.d.ts} +1 -1
- package/dist/{db-Br0tfAo7.js → db-COYOGzYS.js} +171 -12
- package/dist/{executor-BMPipFVA.js → executor-BWmAgSyi.js} +40 -11
- package/dist/{media-BepyEUNm.js → history-IjdmO_r6.js} +1 -85
- package/dist/instrumentation.js +2 -2
- package/dist/lineage-D-5jm_oj.js +37 -0
- package/dist/{logging-CQjlDQYX.js → logging-DPLEa8Bn.js} +1 -1
- package/dist/media-BAHvgkok.js +85 -0
- package/dist/{message-BOZEIuxy.js → message-BIHR1yRk.js} +9 -10
- package/dist/model-input-BPZYH8Nd.js +82 -0
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +17 -9
- package/dist/{oauth-callback-server-V_DuMuNX.js → oauth-callback-server-R7qvSzFG.js} +2 -2
- package/dist/{plugins-HYh_JOdw.js → plugins-CBW2Prb_.js} +1 -1
- package/dist/{projection-B08mfi0u.js → projection-DEdP1q6f.js} +261 -36
- package/dist/{prompt-BlutWLNt.js → prompt-4M98h_tC.js} +4 -4
- package/dist/{registry-BDWgCJDf.js → registry-BTKmKM-r.js} +3 -3
- package/dist/{resolve-2Z_o_SsI.js → resolve-B8hXNVZ3.js} +3 -3
- package/dist/{result-CAujiaci.js → result-g-XAaOj6.js} +158 -69
- package/dist/{runner-D2Chc02N.js → runner-BlPSA5A8.js} +9 -9
- package/dist/{sandbox-egress-signals-CFoJduFj.js → sandbox-egress-signals-Pai-MzEY.js} +1 -1
- package/dist/{schema-Bqa5NbcP.js → schema-BNnY_trV.js} +47 -7
- package/dist/{schema-Ce2XCS7O.d.ts → schema-DbuWR-DN.d.ts} +663 -346
- package/dist/{service-account-C9kRQEb_.js → service-account-9OLNQMyz.js} +4 -4
- package/dist/{service-account-CERfXEVU.js → service-account-BYGZ08DQ.js} +3 -3
- package/dist/session-stop-2XJrcNCy.js +3356 -0
- package/dist/{skills-B0m1nZ_j.js → skills-DpBQoeHV.js} +3 -3
- package/dist/slack-conversation-unfurl-BcDIWo67.js +370 -0
- package/dist/spawn-09GssFod.js +73 -0
- package/dist/state-Cufq0_rH.js +132 -0
- package/dist/{user-input-request-CXNIov9n.js → statuses-B8mUfghF.js} +30 -25
- package/dist/{stop-BCH9VNGf.js → stop-U7iUrR1g.js} +6011 -5773
- package/dist/{store-B59rOYbS.js → store-BHiaHCQu.js} +24 -4
- package/dist/{store-m5bmdmsP.js → store-CSgUTMdv.js} +10 -10
- package/dist/{task-queue-N0kuCknH.js → task-queue-bMNq0clp.js} +4 -4
- package/dist/{task-runner-COOwR8qm.js → task-runner-B__rxwxU.js} +10 -10
- package/dist/{thread-context-Cd44z_W5.js → thread-context-d0ceWbVT.js} +18 -18
- package/dist/{turn-session-routing-BlCtVFRN.js → turn-session-routing-BVZHBFCF.js} +5 -5
- package/dist/turn-user-message-BEw7acTP.js +355 -0
- package/dist/users-BK3dbxZL.js +424 -0
- package/dist/{validation-Ba2OcUse.js → validation-BDVJjO2E.js} +1 -1
- package/dist/{version-KNDzIAh6.js → version-DQgZoQ3D.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-BPpuN2f9.js → viewer-CAWfFo29.js} +25 -54
- package/dist/{warmup-Bskrwmk1.js → warmup-9ySPacF9.js} +1137 -143
- package/dist/{worker-B1skZlit.js → worker-D8jJO-WO.js} +8 -7
- package/migrations/0104_code_change_draft.sql +1 -0
- package/migrations/0105_attachment_uploads.sql +14 -0
- package/migrations/0106_conversation_agent_config.sql +1 -0
- package/migrations/meta/0104_snapshot.json +4516 -0
- package/migrations/meta/0105_snapshot.json +4611 -0
- package/migrations/meta/0106_snapshot.json +4617 -0
- package/migrations/meta/_journal.json +21 -0
- package/package.json +4 -4
- package/dist/attempt-selection-ClP3MMPr.js +0 -61
- package/dist/locks-D-0h111u.js +0 -48
- package/dist/notification-gusCgdQ6.js +0 -1284
- package/dist/prompt-input-Dxn8cDC0.js +0 -1424
- package/dist/session-stop-B-I1rAS1.js +0 -181
- package/dist/spawn-CwMjRRtn.js +0 -80
- package/dist/turn-cancel-DDu8TOwt.js +0 -201
- package/dist/turn-user-message-ygLG3ylQ.js +0 -641
- package/dist/turn-wake-DmQec4AG.js +0 -161
- package/dist/{oauth-relay-CsfIazeF.js → oauth-relay-DRzq73b6.js} +1 -1
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { v as __exportAll } from "./sentry-BRTJqumy.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { f as credentialContextForActor } from "./registry-
|
|
5
|
-
import { a as EVENT_SYSTEM_ACTOR } from "./prompt-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
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";
|
|
2
|
+
import { Jn as renderUntrustedTag } from "./projection-DEdP1q6f.js";
|
|
3
|
+
import { E as turnBehavior, a as getConversationStore, j as SYSTEM_IDENTITY_ID } from "./db-COYOGzYS.js";
|
|
4
|
+
import { f as credentialContextForActor } from "./registry-BTKmKM-r.js";
|
|
5
|
+
import { a as EVENT_SYSTEM_ACTOR } from "./prompt-4M98h_tC.js";
|
|
6
|
+
import { D as parseEventMessages, E as listActiveMailboxTurns, I as renderEventBatchInputs, L as timerWatchCredentialSubject, M as EVENT_WAIT_MS, O as resolveMailboxTurnWork, P as eventBatchMessageMeta, s as eventReviewItemInputs, t as getConversationStoppedAtMs, w as getEventBatchDelayMs } from "./session-stop-2XJrcNCy.js";
|
|
7
|
+
import { A as readChildConversationSender, B as endActiveAgentInvocations, D as sendsResultToParent, E as reportReplacedWithoutOpenWork, F as parentMessageText, H as enqueueAgentInvocation, L as readParentMessage, O as childAgentInput, P as logDroppedParentMessage, Q as createAgentInvocationFromLatest, R as createAgentInvocationWorker, T as markAgentInvocationParentMailboxAppended, U as resolveAgentInvocationId, V as endAgentInvocationsOfStoppedWork, b as isTerminalAgentInvocation, h as TERMINAL_AGENT_INVOCATION_STATUSES, j as routeChildInput, k as getChildAgentInputSender, m as NON_TERMINAL_AGENT_INVOCATION_STATUSES, p as listUnreportedSiblingAgents, x as listAgentInvocationsForConversation, y as getLatestAgentInvocationForConversation } from "./warmup-9ySPacF9.js";
|
|
8
|
+
import { A as getAgentInvocationResultMessageId, C as ownAgentInvocation, D as getAgentInvocationIdForMessage, E as getAgentInvocationIdForEvents, F as getTurnReplyKey, M as getAgentReplyMessageId, O as getAgentInvocationIdForResult, R as buildDeterministicTurnId, S as listChildMessages, b as hasAgentInvocationReply, j as getAgentInvocationTurnId, y as childMessageSenderMetadata } from "./turn-user-message-BEw7acTP.js";
|
|
9
|
+
import { _ as getConversationWorkState, r as appendAndEnqueueInboundMessage } from "./store-BHiaHCQu.js";
|
|
10
|
+
import { _ as AGENT_REPLY_EVENT_TYPE, h as AGENT_MESSAGE_EVENT_TYPE, m as AGENT_INVOCATION_EVENT_NAMESPACE, v as agentInvocationResultEventType } from "./statuses-B8mUfghF.js";
|
|
11
|
+
import { actorSchema } from "@sentry/junior-plugin-api";
|
|
13
12
|
// src/chat/agent-invocations/result.ts
|
|
14
13
|
var result_exports = /* @__PURE__ */ __exportAll({
|
|
15
14
|
createChildConversationWorker: () => createChildConversationWorker,
|
|
@@ -74,7 +73,7 @@ function siblingLabel(sibling) {
|
|
|
74
73
|
* sent at the same moment, so two siblings cannot each name the other.
|
|
75
74
|
*/
|
|
76
75
|
function renderResultUnderLock(sender, result) {
|
|
77
|
-
return async (parentInboundMessageIds) => renderResultInput(sender, result, await listUnreportedSiblingAgents(sender.parentConversationId, sender.childConversationId, parentInboundMessageIds));
|
|
76
|
+
return async (parentInboundMessageIds, messageSenders) => renderResultInput(sender, result, await listUnreportedSiblingAgents(sender.parentConversationId, sender.childConversationId, await listChildMessages(parentInboundMessageIds, messageSenders)));
|
|
78
77
|
}
|
|
79
78
|
function terminalResult(invocation) {
|
|
80
79
|
return {
|
|
@@ -96,7 +95,12 @@ function buildResultInboundMessage(invocation, nowMs) {
|
|
|
96
95
|
identifier: invocation.invocationId,
|
|
97
96
|
namespace: AGENT_INVOCATION_EVENT_NAMESPACE,
|
|
98
97
|
trustedSummary: summary
|
|
99
|
-
}
|
|
98
|
+
},
|
|
99
|
+
...childMessageSenderMetadata({
|
|
100
|
+
agentInvocationId: invocation.invocationId,
|
|
101
|
+
conversationId: invocation.childConversationId,
|
|
102
|
+
turnId: getAgentInvocationTurnId(invocation.invocationId)
|
|
103
|
+
})
|
|
100
104
|
};
|
|
101
105
|
return {
|
|
102
106
|
conversationId: invocation.parentConversationId,
|
|
@@ -125,10 +129,10 @@ function buildResultInboundMessage(invocation, nowMs) {
|
|
|
125
129
|
async function enqueueAgentInvocationResult(invocation, options) {
|
|
126
130
|
if (invocation.parentMailboxStatus !== "pending") return;
|
|
127
131
|
const nowMs = options.nowMs ?? Date.now();
|
|
128
|
-
const
|
|
129
|
-
if (!sendsResultToParent(invocation,
|
|
132
|
+
const parentMessages = await readParentChildMessages(invocation.parentConversationId, options.state);
|
|
133
|
+
if (!sendsResultToParent(invocation, parentMessages)) {
|
|
130
134
|
await markAgentInvocationParentMailboxAppended(invocation.invocationId, nowMs);
|
|
131
|
-
const replaced =
|
|
135
|
+
const replaced = hasAgentInvocationReply(parentMessages, invocation.invocationId) ? void 0 : await reportReplacedWithoutOpenWork(invocation.parentConversationId, nowMs);
|
|
132
136
|
if (replaced && isTerminalAgentInvocation(replaced)) await enqueueAgentInvocationResult(replaced, options);
|
|
133
137
|
return;
|
|
134
138
|
}
|
|
@@ -142,17 +146,39 @@ async function enqueueAgentInvocationResult(invocation, options) {
|
|
|
142
146
|
await markAgentInvocationParentMailboxAppended(invocation.invocationId, nowMs);
|
|
143
147
|
}
|
|
144
148
|
/**
|
|
145
|
-
* Read
|
|
146
|
-
* whose `reply` is among them has answered.
|
|
149
|
+
* Read every child reply and result that reached the parent's mailbox. A
|
|
150
|
+
* sibling whose `reply` is among them has answered.
|
|
147
151
|
*/
|
|
148
|
-
async function
|
|
149
|
-
|
|
152
|
+
async function readParentChildMessages(parentConversationId, state) {
|
|
153
|
+
const work = await getConversationWorkState({
|
|
150
154
|
conversationId: parentConversationId,
|
|
151
155
|
state
|
|
152
|
-
})
|
|
156
|
+
});
|
|
157
|
+
return await listChildMessages(work?.execution.inboundMessageIds ?? [], work?.execution.messageSenders ?? {});
|
|
153
158
|
}
|
|
154
|
-
function childAgentLabel(
|
|
155
|
-
return
|
|
159
|
+
function childAgentLabel(sender) {
|
|
160
|
+
return sender.agentName ? `Child agent "${sender.agentName}"` : "Child agent";
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Mailbox metadata of a reply or message from a child that no Agent
|
|
164
|
+
* invocation names. It carries the Actor of the child's Turn, so the parent
|
|
165
|
+
* runs with no more authority than that Turn. The author id must match it.
|
|
166
|
+
*/
|
|
167
|
+
function senderEventMetadata(sender, actor, event) {
|
|
168
|
+
return sender.invocationId ? {
|
|
169
|
+
kind: "event",
|
|
170
|
+
event
|
|
171
|
+
} : {
|
|
172
|
+
kind: "event",
|
|
173
|
+
event,
|
|
174
|
+
actor
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
/** Read the Actor that a reply or message from a child without an Agent invocation carries. */
|
|
178
|
+
function senderActorFromMetadata(metadata) {
|
|
179
|
+
const actor = metadata?.actor;
|
|
180
|
+
const parsed = actorSchema.safeParse(actor);
|
|
181
|
+
return parsed.success ? parsed.data : void 0;
|
|
156
182
|
}
|
|
157
183
|
function renderMessageInput(sender, text) {
|
|
158
184
|
return renderUntrustedTag("agent-message", {
|
|
@@ -170,18 +196,16 @@ function renderMessageInput(sender, text) {
|
|
|
170
196
|
*/
|
|
171
197
|
async function enqueueAgentMessageToParent(args) {
|
|
172
198
|
const nowMs = args.nowMs ?? Date.now();
|
|
173
|
-
const
|
|
199
|
+
const senderId = args.sender.invocationId ?? args.sender.childConversationId;
|
|
200
|
+
const inboundMessageId = `agent-invocation:${senderId}:message:${args.messageKey}`;
|
|
174
201
|
const summary = `${childAgentLabel(args.sender)} sent a message.`;
|
|
175
|
-
const metadata = {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
trustedSummary: summary
|
|
183
|
-
}
|
|
184
|
-
};
|
|
202
|
+
const metadata = senderEventMetadata(args.sender, args.actor, {
|
|
203
|
+
eventKey: inboundMessageId,
|
|
204
|
+
eventType: AGENT_MESSAGE_EVENT_TYPE,
|
|
205
|
+
identifier: senderId,
|
|
206
|
+
namespace: AGENT_INVOCATION_EVENT_NAMESPACE,
|
|
207
|
+
trustedSummary: summary
|
|
208
|
+
});
|
|
185
209
|
await appendAndEnqueueInboundMessage({
|
|
186
210
|
message: {
|
|
187
211
|
conversationId: args.sender.parentConversationId,
|
|
@@ -210,15 +234,18 @@ const RESULT_SUMMARIES = {
|
|
|
210
234
|
/**
|
|
211
235
|
* Append the result of one child agent Turn to its parent mailbox and wake
|
|
212
236
|
* the parent: a `reply`, which the parent reads as a completed
|
|
213
|
-
* `<agent-result>`, or a blocked or failed result. `sender`
|
|
214
|
-
*
|
|
215
|
-
* child's Turn; the parent never runs
|
|
216
|
-
* of the result, the `reply` tool call
|
|
217
|
-
* so a repeat call is safe.
|
|
237
|
+
* `<agent-result>`, or a blocked or failed result. `sender` names the child:
|
|
238
|
+
* an agent invocation, open or not, or the child Conversation when none
|
|
239
|
+
* names it. `actor` is the Actor of the child's Turn; the parent never runs
|
|
240
|
+
* with more authority than it. The key of the result, the `reply` tool call
|
|
241
|
+
* id or the Turn id, keys the message, so a repeat call is safe.
|
|
218
242
|
*/
|
|
219
243
|
async function enqueueChildResultToParent(args) {
|
|
220
244
|
const nowMs = args.nowMs ?? Date.now();
|
|
221
|
-
const
|
|
245
|
+
const actor = args.actor ?? args.sender.actor;
|
|
246
|
+
if (!actor) throw new Error(`Reply of ${args.sender.childConversationId} has no Actor for its parent`);
|
|
247
|
+
const senderId = args.sender.invocationId ?? args.sender.childConversationId;
|
|
248
|
+
const inboundMessageId = getAgentReplyMessageId(senderId, args.messageKey);
|
|
222
249
|
const rendered = args.result.kind === "reply" ? {
|
|
223
250
|
output: args.result.reply.text,
|
|
224
251
|
status: "completed"
|
|
@@ -226,15 +253,20 @@ async function enqueueChildResultToParent(args) {
|
|
|
226
253
|
output: args.result.text,
|
|
227
254
|
status: args.result.kind
|
|
228
255
|
};
|
|
256
|
+
const sender = {
|
|
257
|
+
...args.sender.invocationId ? { agentInvocationId: args.sender.invocationId } : void 0,
|
|
258
|
+
conversationId: args.sender.childConversationId,
|
|
259
|
+
turnId: args.turnId
|
|
260
|
+
};
|
|
229
261
|
const metadata = {
|
|
230
|
-
|
|
231
|
-
event: {
|
|
262
|
+
...senderEventMetadata(args.sender, actor, {
|
|
232
263
|
eventKey: inboundMessageId,
|
|
233
264
|
eventType: AGENT_REPLY_EVENT_TYPE,
|
|
234
|
-
identifier:
|
|
265
|
+
identifier: senderId,
|
|
235
266
|
namespace: AGENT_INVOCATION_EVENT_NAMESPACE,
|
|
236
267
|
trustedSummary: `${childAgentLabel(args.sender)} ${RESULT_SUMMARIES[args.result.kind]}`
|
|
237
|
-
}
|
|
268
|
+
}),
|
|
269
|
+
...childMessageSenderMetadata(sender)
|
|
238
270
|
};
|
|
239
271
|
await appendAndEnqueueInboundMessage({
|
|
240
272
|
message: {
|
|
@@ -243,7 +275,7 @@ async function enqueueChildResultToParent(args) {
|
|
|
243
275
|
delivery: "defer",
|
|
244
276
|
inboundMessageId,
|
|
245
277
|
input: {
|
|
246
|
-
authorId: resultAuthorId(
|
|
278
|
+
authorId: resultAuthorId(actor),
|
|
247
279
|
authorIdentityId: SYSTEM_IDENTITY_ID,
|
|
248
280
|
metadata,
|
|
249
281
|
text: renderResultInput(args.sender, rendered, [])
|
|
@@ -251,7 +283,7 @@ async function enqueueChildResultToParent(args) {
|
|
|
251
283
|
receivedAtMs: nowMs,
|
|
252
284
|
source: "event"
|
|
253
285
|
},
|
|
254
|
-
renderText: async (parentInboundMessageIds) =>
|
|
286
|
+
renderText: async (parentInboundMessageIds, messageSenders) => !ownAgentInvocation(sender) && await getConversationStoppedAtMs(args.sender.childConversationId) !== void 0 ? void 0 : await renderResultUnderLock(args.sender, rendered)(parentInboundMessageIds, messageSenders),
|
|
255
287
|
queue: args.queue,
|
|
256
288
|
queueDelayMs: EVENT_WAIT_MS,
|
|
257
289
|
state: args.state
|
|
@@ -260,19 +292,21 @@ async function enqueueChildResultToParent(args) {
|
|
|
260
292
|
/**
|
|
261
293
|
* Build the parent delivery of child agent Turns that run on the
|
|
262
294
|
* Conversation loop. Such a Turn has no open agent invocation, so its
|
|
263
|
-
* newest finished agent invocation names the child for the parent.
|
|
295
|
+
* newest finished agent invocation names the child for the parent. A child
|
|
296
|
+
* that no agent invocation names is named by its child Conversation.
|
|
264
297
|
*/
|
|
265
298
|
function createDeliverToParent(options) {
|
|
266
299
|
return async ({ actor, result, conversationId, turnId }) => {
|
|
267
|
-
const sender = (await listAgentInvocationsForConversation(conversationId, TERMINAL_AGENT_INVOCATION_STATUSES)).at(-1);
|
|
268
|
-
if (!sender) throw new Error(`
|
|
300
|
+
const sender = (await listAgentInvocationsForConversation(conversationId, TERMINAL_AGENT_INVOCATION_STATUSES)).at(-1) ?? await readChildConversationSender(conversationId);
|
|
301
|
+
if (!sender) throw new Error(`Conversation ${conversationId} has no parent agent`);
|
|
269
302
|
await enqueueChildResultToParent({
|
|
270
303
|
actor,
|
|
271
304
|
result,
|
|
272
305
|
messageKey: result.kind === "reply" ? getTurnReplyKey(turnId, result.reply.toolCallId) : turnId,
|
|
273
306
|
queue: options.queue,
|
|
274
307
|
sender,
|
|
275
|
-
state: options.state
|
|
308
|
+
state: options.state,
|
|
309
|
+
turnId
|
|
276
310
|
});
|
|
277
311
|
};
|
|
278
312
|
}
|
|
@@ -297,11 +331,8 @@ function createEndStoppedChildWork(options) {
|
|
|
297
331
|
const turns = await listActiveMailboxTurns(conversationId);
|
|
298
332
|
const pending = (await getConversationWorkState({ conversationId }))?.execution.pendingMessages ?? [];
|
|
299
333
|
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
|
|
302
|
-
const turnId = parseTurnReplyMessageId(messageId);
|
|
303
|
-
return turnId !== void 0 && turnIds.has(turnId) && isAgentReplyMessageId(messageId, sender.invocationId);
|
|
304
|
-
})) return;
|
|
334
|
+
const sender = await getLatestAgentInvocationForConversation(conversationId) ?? await readChildConversationSender(conversationId);
|
|
335
|
+
if (sender && (await readParentChildMessages(sender.parentConversationId, void 0)).some((message) => message.sender.conversationId === conversationId && turnIds.has(message.sender.turnId))) return;
|
|
305
336
|
const [turn] = turns;
|
|
306
337
|
await deliverToParent({
|
|
307
338
|
actor: turn?.actor ?? EVENT_SYSTEM_ACTOR,
|
|
@@ -332,7 +363,7 @@ async function startAgentInvocationsForChildInput(context, options) {
|
|
|
332
363
|
const routes = await Promise.all(messages.map((message) => routeChildInput(message, latest, stoppedAtMs)));
|
|
333
364
|
if (!routes.includes("agent invocation")) return;
|
|
334
365
|
const inputs = messages.map(childAgentInput);
|
|
335
|
-
const isAgentInput =
|
|
366
|
+
const isAgentInput = messages.every((message, index) => inputs[index] !== void 0 || readParentMessage(message) !== void 0);
|
|
336
367
|
const events = isAgentInput ? [] : parseEventMessages(messages);
|
|
337
368
|
if (!isAgentInput && events.length === 0) return;
|
|
338
369
|
if (!isAgentInput) {
|
|
@@ -360,14 +391,32 @@ async function startAgentInvocationsForChildInput(context, options) {
|
|
|
360
391
|
return { status: "completed" };
|
|
361
392
|
}
|
|
362
393
|
for (const [index, message] of messages.entries()) {
|
|
363
|
-
|
|
394
|
+
const parentMessage = readParentMessage(message);
|
|
395
|
+
if (routes[index] === "dropped") {
|
|
396
|
+
if (parentMessage) logDroppedParentMessage(message, parentMessage);
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
if (parentMessage) {
|
|
400
|
+
await enqueueAgentInvocation(await createAgentInvocationFromLatest({
|
|
401
|
+
input: message.input.text.trim(),
|
|
402
|
+
invocationId: getAgentInvocationIdForMessage(message.inboundMessageId),
|
|
403
|
+
latest,
|
|
404
|
+
runAs: {
|
|
405
|
+
actor: parentMessage.actor,
|
|
406
|
+
credentialContext: parentMessage.credentialContext,
|
|
407
|
+
fork: parentMessage.fork,
|
|
408
|
+
parentToolCallId: parentMessage.parentToolCallId
|
|
409
|
+
}
|
|
410
|
+
}), options);
|
|
411
|
+
continue;
|
|
412
|
+
}
|
|
364
413
|
const input = inputs[index];
|
|
365
|
-
const source = await
|
|
414
|
+
const { invocation: source } = await getChildAgentInputSender(message, input);
|
|
366
415
|
const invocation = await createAgentInvocationFromLatest({
|
|
367
416
|
input: message.input.text.trim(),
|
|
368
|
-
invocationId: input.kind === "result" ? getAgentInvocationIdForResult(source.invocationId) : getAgentInvocationIdForMessage(message.inboundMessageId),
|
|
417
|
+
invocationId: input.kind === "result" && source ? getAgentInvocationIdForResult(source.invocationId) : getAgentInvocationIdForMessage(message.inboundMessageId),
|
|
369
418
|
latest,
|
|
370
|
-
...input.kind === "result" ? { runAs: {
|
|
419
|
+
...input.kind === "result" && source ? { runAs: {
|
|
371
420
|
actor: source.actor,
|
|
372
421
|
credentialContext: source.credentialContext
|
|
373
422
|
} } : void 0
|
|
@@ -399,7 +448,8 @@ function createChildConversationWorker(agentRunner, options) {
|
|
|
399
448
|
messageKey: reply.toolCallId,
|
|
400
449
|
queue: options.queue,
|
|
401
450
|
sender,
|
|
402
|
-
state: options.state
|
|
451
|
+
state: options.state,
|
|
452
|
+
turnId: getAgentInvocationTurnId(sender.invocationId)
|
|
403
453
|
})
|
|
404
454
|
});
|
|
405
455
|
return async (context) => {
|
|
@@ -421,14 +471,32 @@ function createChildConversationWorker(agentRunner, options) {
|
|
|
421
471
|
await context.attempt.ack();
|
|
422
472
|
return { status: "completed" };
|
|
423
473
|
}
|
|
424
|
-
|
|
474
|
+
const result = await options.runTurn(context, kept);
|
|
475
|
+
if (result.status === "completed") await reportParentWithoutOpenWork(context.conversationId, options);
|
|
476
|
+
return result;
|
|
425
477
|
};
|
|
426
478
|
}
|
|
427
479
|
/**
|
|
480
|
+
* A completed Turn of a child that no Agent invocation names can end the
|
|
481
|
+
* last open work of its parent, such as a Turn that ends with `noReply`. A
|
|
482
|
+
* `replaced` result of that parent then reports, as when a child row ends.
|
|
483
|
+
* A child with a row reports when its row ends, as on `main`.
|
|
484
|
+
*
|
|
485
|
+
* TODO(dcramer): Remove with the `replaced` result (#3060 step 7).
|
|
486
|
+
*/
|
|
487
|
+
async function reportParentWithoutOpenWork(conversationId, options) {
|
|
488
|
+
if (await getLatestAgentInvocationForConversation(conversationId)) return;
|
|
489
|
+
const sender = await readChildConversationSender(conversationId);
|
|
490
|
+
const replaced = sender ? await reportReplacedWithoutOpenWork(sender.parentConversationId) : void 0;
|
|
491
|
+
if (replaced && isTerminalAgentInvocation(replaced)) await enqueueAgentInvocationResult(replaced, options);
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
428
494
|
* Run each agent invocation result or message as the Actor that triggered the
|
|
429
495
|
* child, user or system, with its grants. This is on purpose: the result
|
|
430
|
-
* continues that Actor's work. The Actor comes from SQL
|
|
431
|
-
*
|
|
496
|
+
* continues that Actor's work. The Actor comes from SQL when an agent
|
|
497
|
+
* invocation names the child, so the parent Turn has the same authority it
|
|
498
|
+
* had at spawn time. Otherwise the input carries it, and so does a parent
|
|
499
|
+
* task to a child.
|
|
432
500
|
* Input that a child's Turn with another Actor sent runs as the Event system
|
|
433
501
|
* Actor, so it never gets more authority than that Turn. A result that a stop
|
|
434
502
|
* skipped is dropped. Returns undefined when no input is left.
|
|
@@ -438,21 +506,42 @@ async function withAgentInvocationResultActors(work) {
|
|
|
438
506
|
const conversationId = work.batch[0]?.message.conversationId;
|
|
439
507
|
const [latest, stoppedAtMs] = conversationId ? await Promise.all([getLatestAgentInvocationForConversation(conversationId), getConversationStoppedAtMs(conversationId)]) : [void 0, void 0];
|
|
440
508
|
const kept = (await Promise.all(work.batch.map(async (entry) => {
|
|
509
|
+
const parentMessage = readParentMessage(entry.message);
|
|
510
|
+
if (parentMessage) {
|
|
511
|
+
if (await routeChildInput(entry.message, latest, stoppedAtMs) === "dropped") {
|
|
512
|
+
logDroppedParentMessage(entry.message, parentMessage);
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
const text = await parentMessageText(entry.message, parentMessage);
|
|
516
|
+
return {
|
|
517
|
+
...entry,
|
|
518
|
+
actor: parentMessage.actor,
|
|
519
|
+
...parentMessage.credentialContext ? { credentialContext: parentMessage.credentialContext } : void 0,
|
|
520
|
+
message: {
|
|
521
|
+
...entry.message,
|
|
522
|
+
input: {
|
|
523
|
+
...entry.message.input,
|
|
524
|
+
text
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
}
|
|
441
529
|
const input = childAgentInput(entry.message);
|
|
442
530
|
if (!input) return entry;
|
|
443
531
|
if (await routeChildInput(entry.message, latest, stoppedAtMs) === "dropped") return;
|
|
444
|
-
const invocation = await
|
|
445
|
-
|
|
532
|
+
const { invocation } = await getChildAgentInputSender(entry.message, input);
|
|
533
|
+
const actor = invocation?.actor ?? senderActorFromMetadata(entry.message.input.metadata);
|
|
534
|
+
if (!actor || entry.message.input.authorId !== resultAuthorId(actor)) return {
|
|
446
535
|
...entry,
|
|
447
536
|
actor: EVENT_SYSTEM_ACTOR
|
|
448
537
|
};
|
|
449
|
-
return input.kind === "result" && invocation
|
|
538
|
+
return input.kind === "result" && invocation?.credentialContext ? {
|
|
450
539
|
...entry,
|
|
451
|
-
actor
|
|
540
|
+
actor,
|
|
452
541
|
credentialContext: invocation.credentialContext
|
|
453
542
|
} : {
|
|
454
543
|
...entry,
|
|
455
|
-
actor
|
|
544
|
+
actor
|
|
456
545
|
};
|
|
457
546
|
}))).filter((entry) => entry !== void 0);
|
|
458
547
|
return kept.length > 0 ? {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { A as latestConversationMessageSeq, I as upsertConversationMessage, M as normalizeConversationText, N as recordDeliveredAssistantMessage, W as authorizationId, a as loadProjection,
|
|
2
|
-
import { S as setTags, T as withLogContext, p as logException } from "./logging-
|
|
3
|
-
import {
|
|
4
|
-
import { f as credentialContextForActor } from "./registry-
|
|
5
|
-
import {
|
|
6
|
-
import { _ as ConversationTurnLifecycleService, g as startActiveTurn, h as markTurnFailed } from "./turn-user-message-
|
|
7
|
-
import { a as getPersistedThreadState, c as coerceThreadConversationState, i as getPersistedSandboxState, s as persistThreadStateById } from "./turn-session-routing-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
import { A as latestConversationMessageSeq, I as upsertConversationMessage, M as normalizeConversationText, N as recordDeliveredAssistantMessage, W as authorizationId, a as loadProjection, b as persistConversationMessages, bn as persistWithRetry, d as recordAuthorizationCompleted, j as markConversationMessage, nt as saveTurnCheckpoint, t as commitAcceptedReply, un as getAssistantReplyText, v as hydrateConversationMessages } from "./projection-DEdP1q6f.js";
|
|
2
|
+
import { S as setTags, T as withLogContext, p as logException } from "./logging-DPLEa8Bn.js";
|
|
3
|
+
import { a as getConversationStore, j as SYSTEM_IDENTITY_ID, r as getConversationEventStore } from "./db-COYOGzYS.js";
|
|
4
|
+
import { f as credentialContextForActor } from "./registry-BTKmKM-r.js";
|
|
5
|
+
import { B as messageCardText } from "./conversation-fCWD9Az3.js";
|
|
6
|
+
import { _ as ConversationTurnLifecycleService, g as startActiveTurn, h as markTurnFailed } from "./turn-user-message-BEw7acTP.js";
|
|
7
|
+
import { a as getPersistedThreadState, c as coerceThreadConversationState, i as getPersistedSandboxState, s as persistThreadStateById } from "./turn-session-routing-BVZHBFCF.js";
|
|
8
|
+
import { c as buildDeliveredTurnStatePatch, l as loadPendingMessageCards, o as completeAuthPauseTurn, r as finalizeFailedTurnReplyWithEvent, t as buildTurnThreadContext } from "./thread-context-d0ceWbVT.js";
|
|
9
|
+
import { n as scheduleSessionCompletedPluginTasks, t as processPluginTask } from "./task-runner-B__rxwxU.js";
|
|
10
10
|
import { randomUUID } from "node:crypto";
|
|
11
11
|
import { createLocalSource, localDestinationSchema } from "@sentry/junior-plugin-api";
|
|
12
12
|
// src/chat/local/runner.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ro as sandboxEgressSignalsResponseSchema } from "./projection-DEdP1q6f.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;
|
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
import { r as notificationScheduleSchema } from "./schedule-cP0AACm1.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { D as conversationChildAgentTotalsSchema, E as idempotencyKeySchema, K as inputFileSchema, i as actorIdentitySchema, s as conversationAuxiliaryCostsSchema, x as conversationUsageSchema, y as conversationSummaryReportSchema } from "./conversation-fCWD9Az3.js";
|
|
3
|
+
import { r as AGENT_INVOCATION_STATUSES, u as userInputRequestSchema } from "./statuses-B8mUfghF.js";
|
|
4
4
|
import { i as fillUtcHours, r as fillUtcDays, s as sumUtcHoursIntoSixHours } from "./reporting-window-DopzcOHh.js";
|
|
5
|
-
import "./automation-
|
|
6
|
-
import "./conversation-feed-
|
|
5
|
+
import "./automation-M3RFJUBf.js";
|
|
6
|
+
import "./conversation-feed-BPK8vkkZ.js";
|
|
7
7
|
import { t as isPushServiceEndpoint } from "./push-endpoint-CO-nomUd.js";
|
|
8
8
|
import * as z from "zod";
|
|
9
|
-
import { codeChangeStateSchema, eventMatchSchema } from "@sentry/junior-plugin-api";
|
|
9
|
+
import { codeChangeStateSchema, eventMatchSchema, ownedObjectAnnotationSchema } from "@sentry/junior-plugin-api";
|
|
10
|
+
// src/api/schema/conversation-attachment-upload.ts
|
|
11
|
+
/**
|
|
12
|
+
* Ask to upload one file for a Message. `conversationId` names an existing
|
|
13
|
+
* Conversation; without it, the file is for the Conversation that the first
|
|
14
|
+
* Message with this idempotency key creates.
|
|
15
|
+
*/
|
|
16
|
+
const createAttachmentUploadBodySchema = inputFileSchema.safeExtend({
|
|
17
|
+
conversationId: z.string().min(1).optional(),
|
|
18
|
+
idempotencyKey: idempotencyKeySchema
|
|
19
|
+
}).strict();
|
|
20
|
+
/** Upload id and the request that writes the file bytes. */
|
|
21
|
+
const attachmentUploadSchema = z.object({
|
|
22
|
+
uploadId: z.string().min(1),
|
|
23
|
+
target: z.object({
|
|
24
|
+
headers: z.record(z.string(), z.string()),
|
|
25
|
+
method: z.literal("PUT"),
|
|
26
|
+
url: z.string().min(1)
|
|
27
|
+
}).strict()
|
|
28
|
+
}).strict();
|
|
29
|
+
const attachmentUploadParamsSchema = z.object({ uploadId: z.string().uuid() }).strict();
|
|
10
30
|
// src/api/schema/conversation-catch-up.ts
|
|
11
31
|
/**
|
|
12
32
|
* The unread rows to summarize: every event after `afterSeq`, through
|
|
@@ -300,6 +320,8 @@ const codeRepositorySummarySchema = z.object({
|
|
|
300
320
|
}).strict();
|
|
301
321
|
const codeChangeSummaryReportSchema = z.object({
|
|
302
322
|
closedAt: z.string().optional(),
|
|
323
|
+
/** Whether the code change is a draft. Readers ignore it unless open. */
|
|
324
|
+
draft: z.boolean(),
|
|
303
325
|
id: z.string().uuid(),
|
|
304
326
|
/**
|
|
305
327
|
* Latest push, review, or comment by a person. Absent when the code
|
|
@@ -408,6 +430,17 @@ const pushSubscriptionBodySchema = z.object({
|
|
|
408
430
|
}).strict();
|
|
409
431
|
const pushSubscriptionDeleteBodySchema = z.object({ endpoint: z.string().url().max(2048) }).strict();
|
|
410
432
|
const testNotificationResponseSchema = z.object({ delivered: z.number().int().nonnegative() }).strict();
|
|
433
|
+
// src/api/schema/object-link.ts
|
|
434
|
+
/** The most links that one object request may resolve. */
|
|
435
|
+
const MAX_OBJECT_LINKS = 20;
|
|
436
|
+
const objectLinkUrlSchema = z.string().trim().min(1).max(2048);
|
|
437
|
+
/** One or more `url` query values. */
|
|
438
|
+
const objectLinksQuerySchema = z.object({ url: z.preprocess((value) => typeof value === "string" ? [value] : value, z.array(objectLinkUrlSchema).min(1).max(20)) }).strict();
|
|
439
|
+
/** The object cards of the links that resolved for the viewer. */
|
|
440
|
+
const objectLinksReportSchema = z.object({ objects: z.array(z.object({
|
|
441
|
+
object: ownedObjectAnnotationSchema,
|
|
442
|
+
url: objectLinkUrlSchema
|
|
443
|
+
}).strict()).max(20) }).strict();
|
|
411
444
|
// src/api/activity.ts
|
|
412
445
|
const dailyConversationActivitySchema = z.object({
|
|
413
446
|
active: z.number(),
|
|
@@ -602,7 +635,14 @@ const personalTokenMetadataSchema = z.object({
|
|
|
602
635
|
lastUsedAt: z.string().datetime().nullable()
|
|
603
636
|
}).strict();
|
|
604
637
|
const personalTokenListSchema = z.object({ tokens: z.array(personalTokenMetadataSchema) }).strict();
|
|
605
|
-
const createPersonalTokenBodySchema = z.object({
|
|
638
|
+
const createPersonalTokenBodySchema = z.object({
|
|
639
|
+
name: z.string().trim().min(1).max(80),
|
|
640
|
+
/**
|
|
641
|
+
* Origin of a Preview that will receive the token. The API creates the
|
|
642
|
+
* token only when Junior made that Preview for the viewer.
|
|
643
|
+
*/
|
|
644
|
+
previewOrigin: z.string().url().refine((value) => new URL(value).origin === value, "Expected an origin.").optional()
|
|
645
|
+
}).strict();
|
|
606
646
|
const createdPersonalTokenSchema = personalTokenMetadataSchema.extend({ token: z.string().startsWith("jr_pat_") }).strict();
|
|
607
647
|
const personalTokenParamsSchema = z.object({ id: z.string().uuid() }).strict();
|
|
608
648
|
const revokePersonalTokenResponseSchema = z.object({ revoked: z.literal(true) }).strict();
|
|
@@ -844,4 +884,4 @@ const versionsSchema = z.object({
|
|
|
844
884
|
/** The viewer's rolling model spend. */
|
|
845
885
|
spend: z.string().min(1)
|
|
846
886
|
}).strict();
|
|
847
|
-
export {
|
|
887
|
+
export { connectionSchema as $, revokePersonalTokenResponseSchema as A, reorderPinnedConversationsBodySchema as At, activityDays as B, serviceAccountSchema as C, conversationAutoArchiveSchema as Ct, personalTokenListSchema as D, conversationDeliveryResponseSchema as Dt, createdPersonalTokenSchema as E, conversationDeliveryBodySchema as Et, personalSpendReportSchema as F, attachmentUploadSchema as Ft, objectLinksQuerySchema as G, activitySixHours as H, locationActivityDayReportSchema as I, createAttachmentUploadBodySchema as It, pushSubscriptionBodySchema as J, objectLinksReportSchema as K, locationDetailReportSchema as L, actorProfileReportSchema as M, conversationCatchUpBodySchema as Mt, avatarParamsSchema as N, conversationCatchUpSchema as Nt, personalTokenMetadataSchema as O, pinConversationBodySchema as Ot, personParamsSchema as P, attachmentUploadParamsSchema as Pt, connectionParamsSchema as Q, locationDirectoryReportSchema as R, serviceAccountParamsSchema as S, archiveDoneConversationsResponseSchema as St, createPersonalTokenBodySchema as T, conversationSubscriptionResponseSchema as Tt, dailyConversationActivitySchema as U, activityHours as V, MAX_OBJECT_LINKS as W, testNotificationResponseSchema as X, pushSubscriptionDeleteBodySchema as Y, connectionListSchema as Z, reviewItemParamsSchema as _, conversationStatsReportSchema as _t, replyTimeSegmentsReportSchema as a, codeOverviewReportSchema as at, disconnectServiceAccountResponseSchema as b, archiveConversationBodySchema as bt, workspaceBodySchema as c, codeRepositoryReportSchema as ct, workspaceRepoSchema as d, conversationWatchesReportSchema as dt, disconnectConnectionResponseSchema as et, workspaceSchema as f, conversationChildAgentSchema as ft, reviewItemListSchema as g, stopConversationTurnResponseSchema as gt, reviewItemListQuerySchema as h, continueConversationInSlackResponseSchema as ht, statsReportSchema as i, codeChangeSummarySchema as it, actorDirectoryReportSchema as j, reorderPinnedConversationsResponseSchema as jt, personalTokenParamsSchema as k, pinConversationResponseSchema as kt, workspaceListSchema as l, codeRepositorySummarySchema as lt, reviewItemCountSchema as m, continueConversationInSlackBodySchema as mt, versionsSchema as n, codeActivityDaySchema as nt, baselineSnapshotSchema as o, codePersonReportSchema as ot, reviewItemActionSchema as p, conversationChildAgentsReportSchema as pt, notificationSettingsSchema as q, statSchema as r, codeChangeSummaryReportSchema as rt, deleteWorkspaceResponseSchema as s, codeRepositoryParamsSchema as st, versionsQuerySchema as t, startConnectionResponseSchema as tt, workspaceParamsSchema as u, conversationWatchSchema as ut, reviewItemSchema as v, CONVERSATION_OUTLINE_TEXT_LENGTH as vt, startServiceAccountSignInResponseSchema as w, conversationSubscriptionBodySchema as wt, serviceAccountListSchema as x, archiveConversationResponseSchema as xt, reviewItemWaitingConversationsSchema as y, conversationOutlineSchema as yt, locationParamsSchema as z };
|