@sentry/junior 0.265.0 → 0.267.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-tlxzqaRe.js → actor-DZSokpwj.js} +8 -1
- package/dist/{adapter-cUkPH3Om.js → adapter-BybMEezj.js} +2 -2
- package/dist/{admin-Cf0rDmWV.js → admin-DOs1_EiW.js} +1 -1
- package/dist/{agent-runner-C6MwHJEs.js → agent-runner-DgNATN4D.js} +874 -228
- package/dist/api/schema.d.ts +202 -23
- package/dist/api/schema.js +6 -5
- package/dist/api.d.ts +6 -1
- package/dist/api.js +130 -1205
- package/dist/{app-Csbi9dW7.d.ts → app-DAB3fzyp.d.ts} +21 -3
- package/dist/app.d.ts +2 -2
- package/dist/app.js +1611 -353
- package/dist/{assistant-reply-UPA8vKlC.js → assistant-reply-CT7VcXQe.js} +1 -1
- package/dist/{automation-2RbKzpMT.js → automation-CmeFBSEh.js} +42 -14
- package/dist/{briefs-DRjx8kQ9.js → briefs-CWKjka7v.js} +5 -5
- package/dist/{catalog-runtime-D3qbJlYz.js → catalog-runtime-cMlAI5LY.js} +1 -1
- package/dist/cli/chat.js +15 -15
- package/dist/cli/check.js +3 -3
- package/dist/cli/init.js +0 -1
- 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/{client-DX34VNtH.js → client-BjgbMawj.js} +2 -2
- package/dist/{config-BayQ9hHH.js → config-CdB6yJj5.js} +32 -10
- package/dist/{connections-mpN5Lsnj.js → connections-RE_65jzK.js} +13 -12
- package/dist/{conversation-B0baEwoA.js → conversation-DSo310Ps.js} +14 -3
- package/dist/{conversation-privacy-frjQCJa9.js → conversation-privacy-BzgJC5k0.js} +1 -1
- package/dist/{credential-sync-CZmyDNdR.js → credential-sync-DhEGEpgq.js} +15 -15
- package/dist/{credentialed-C6pKlB1p.js → credentialed-CIGwoLU2.js} +2913 -1026
- package/dist/{db-BnRqQ7G5.d.ts → db-Bg-zC3r5.d.ts} +1 -1
- package/dist/{executor-CAr7xQr2.js → executor-VYrx_K4w.js} +7 -4
- package/dist/{history-AY8rs-FR.js → history-C84mlAwO.js} +2 -1
- package/dist/{images-B2yA3HWE.js → images-CecjXAAz.js} +3 -3
- package/dist/instrumentation.js +6 -2
- package/dist/{job-queue-Cjo6Yg_b.js → job-queue-C0BZSa7r.js} +128 -3
- package/dist/{web-input-Y6aXvmfa.js → list-1XQP-o6K.js} +1374 -71
- package/dist/{logging-D2QBriUo.js → logging-DuZ1A4ab.js} +11 -3
- package/dist/{message-C9ymnpBS.js → message-NKSbbnA6.js} +4 -4
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +3 -3
- package/dist/{oauth-callback-server-BtMf3TPZ.js → oauth-callback-server-qAHLPtml.js} +2 -2
- package/dist/{prompt-CvaDdSX3.js → prompt-BW9jFsqZ.js} +1 -1
- package/dist/{registry-COTeZ2cV.js → registry-FQutO926.js} +2 -2
- package/dist/{resolve-g9PKz9pH.js → resolve-Bk4yeuHy.js} +3 -3
- package/dist/{result-COnC42GR.js → result-B9e9ATOU.js} +9 -9
- package/dist/{runner-BnTNS7x_.js → runner-C3S2ObH-.js} +11 -11
- package/dist/{sandbox-egress-signals-C_IIdLFk.js → sandbox-egress-signals-DqpGzzMB.js} +1 -1
- package/dist/{schema-D5Amlzkp.js → schema-X7Fj4fv1.js} +3 -2
- package/dist/{service-account-CwvToidT.js → service-account-BQasl-qq.js} +3 -3
- package/dist/{service-account-YdYftwV2.js → service-account-Do30HUNv.js} +3 -3
- package/dist/{session-stop-CpCUy1ZJ.js → session-stop-DkOjt46_.js} +45 -128
- package/dist/{skills-Bb2KaJ3m.js → skills-CQHrwfOa.js} +2 -2
- package/dist/{spawn-mbTcrLb3.js → spawn-BHuqN14f.js} +2 -2
- package/dist/{store-CqRnaZSq.js → store-6EetVP-m.js} +3 -3
- package/dist/{store-CG0VJyye.d.ts → store-B8CABbmR.d.ts} +10 -2
- package/dist/store-DvNZIsCr.js +295 -0
- package/dist/{task-queue-8XjDIORF.js → task-queue-B0DLgd2P.js} +10 -5
- package/dist/{task-runner-6mLmG6g_.js → task-runner-B-PD_JOj.js} +26 -14
- package/dist/{tasks-DGbrur6x.js → tasks-0ilmuCux.js} +1440 -46
- package/dist/{thread-state-D45lz-oC.js → thread-state-DRmdJ2QN.js} +5 -5
- package/dist/{turn-failure-response-CaEPLSBn.js → turn-failure-response-G11cs2gE.js} +9 -9
- package/dist/{turn-lifecycle-C35IyRGp.js → turn-lifecycle-OzLIwvi1.js} +2 -2
- package/dist/{turn-session-routing-BKx6rfVd.js → turn-session-routing-Dyut9l7Y.js} +1 -1
- package/dist/user-input-request-BDFBdF8r.js +116 -0
- package/dist/{validation-C0X3CX51.js → validation-CxEmt1id.js} +1 -1
- package/dist/{version-BPHgJwnm.js → version-Bapedn4A.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-B2wXNspU.js → viewer-DrN3oC2X.js} +22 -11
- package/dist/{work-DMbqK0kT.js → work-DUQoNcqP.js} +52 -51
- package/dist/{worker-B-rDJ3XN.js → worker-D1l4Ugk0.js} +30 -19
- package/migrations/0064_any_resource_event_triggers.sql +2 -0
- package/migrations/meta/0064_snapshot.json +3505 -0
- package/migrations/meta/_journal.json +7 -0
- package/package.json +20 -5
- package/dist/store-DdT74Lvq.js +0 -1424
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { $t as appendExclusiveInboundMessage, Cn as requestConversationWork$1, En as stopConversationWork$1, Qt as ackMessages$1, Sn as requestAnotherSlice$1, Tn as steerWebPendingMessages$1, _n as markConversationWorkEnqueued$1, an as clearExpiredConversationLease$1, bn as releaseConversationWork$1, cn as deadLetterAttempt$1, dn as getConversationWorkState$1, en as appendInboundMessage, gn as listActiveConversationIds$1, in as clearConsumedConversationWake$1, ln as drainConversationMailbox$1, nn as cancelHumanFacingPendingMessages$1, on as completeConversationStop$1, rn as checkInConversationWork$1, sn as completeConversationWork$1, tn as beginConversationResume$1, un as getConversation$1, vn as recordAttemptFailure$1, wn as startConversationWork$1, xn as removeActiveConversation$1, yn as recordConversationRetry$1 } from "./tasks-0ilmuCux.js";
|
|
2
|
+
import { f as getConversationStore } from "./viewer-DrN3oC2X.js";
|
|
3
|
+
import "./job-queue-C0BZSa7r.js";
|
|
4
|
+
// src/chat/task-execution/store.ts
|
|
5
|
+
function metadataStore(options) {
|
|
6
|
+
return options.conversationStore ?? getConversationStore();
|
|
7
|
+
}
|
|
8
|
+
function duplicateInboundNudgeIdempotencyKey(message, nowMs) {
|
|
9
|
+
return `duplicate:${message.conversationId}:${message.inboundMessageId}:${nowMs}`;
|
|
10
|
+
}
|
|
11
|
+
function hasRecentEnqueueMarker(conversation, nowMs) {
|
|
12
|
+
const lastEnqueuedAtMs = conversation.execution.lastEnqueuedAtMs;
|
|
13
|
+
return typeof lastEnqueuedAtMs === "number" && lastEnqueuedAtMs + 6e4 > nowMs;
|
|
14
|
+
}
|
|
15
|
+
function now() {
|
|
16
|
+
return Date.now();
|
|
17
|
+
}
|
|
18
|
+
async function recordExecutionMetadata(args) {
|
|
19
|
+
const conversation = await getConversation$1({
|
|
20
|
+
conversationId: args.conversationId,
|
|
21
|
+
state: args.state
|
|
22
|
+
});
|
|
23
|
+
if (!conversation) return;
|
|
24
|
+
await metadataStore(args).recordExecution({
|
|
25
|
+
channelName: conversation.channelName,
|
|
26
|
+
conversationId: conversation.conversationId,
|
|
27
|
+
createdAtMs: conversation.createdAtMs,
|
|
28
|
+
destination: conversation.destination,
|
|
29
|
+
execution: {
|
|
30
|
+
lastCheckpointAtMs: conversation.execution.lastCheckpointAtMs,
|
|
31
|
+
lastEnqueuedAtMs: conversation.execution.lastEnqueuedAtMs,
|
|
32
|
+
runId: conversation.execution.runId,
|
|
33
|
+
status: conversation.execution.status,
|
|
34
|
+
updatedAtMs: conversation.execution.updatedAtMs
|
|
35
|
+
},
|
|
36
|
+
lastActivityAtMs: conversation.lastActivityAtMs,
|
|
37
|
+
metrics: null,
|
|
38
|
+
actor: conversation.actor,
|
|
39
|
+
source: conversation.source,
|
|
40
|
+
title: conversation.title,
|
|
41
|
+
updatedAtMs: conversation.updatedAtMs
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/** Return a persisted conversation record, if one exists. */
|
|
45
|
+
async function getConversation(args) {
|
|
46
|
+
return await getConversation$1(args);
|
|
47
|
+
}
|
|
48
|
+
/** Return a persisted conversation work record, if one exists. */
|
|
49
|
+
async function getConversationWorkState(args) {
|
|
50
|
+
return await getConversationWorkState$1(args);
|
|
51
|
+
}
|
|
52
|
+
/** Count one failed conversation execution and persist its terminal retry state. */
|
|
53
|
+
async function recordConversationRetry(args) {
|
|
54
|
+
const result = await recordConversationRetry$1(args);
|
|
55
|
+
await recordExecutionMetadata(args);
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
/** Count mailbox messages that have not yet reached the conversation event log. */
|
|
59
|
+
function countPendingConversationMessages(conversation) {
|
|
60
|
+
return conversation.execution.pendingMessages.length;
|
|
61
|
+
}
|
|
62
|
+
/** Return whether a conversation has pending or resumable execution work. */
|
|
63
|
+
function hasRunnableConversationWork(conversation) {
|
|
64
|
+
return conversation.execution.status !== "idle" || countPendingConversationMessages(conversation) > 0;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Ensure runnable conversation work has one accepted queue wake-up nudge.
|
|
68
|
+
*
|
|
69
|
+
* Ordinary wakes coalesce on a recent accepted marker. A caller can ignore the
|
|
70
|
+
* marker without replacing an active lease. Replacement is only for consumed
|
|
71
|
+
* or known-stale deliveries where another queue nudge must exist.
|
|
72
|
+
*/
|
|
73
|
+
async function ensureConversationWake(args) {
|
|
74
|
+
const nowMs = args.nowMs ?? now();
|
|
75
|
+
const conversation = await getConversation$1({
|
|
76
|
+
conversationId: args.conversationId,
|
|
77
|
+
state: args.state
|
|
78
|
+
});
|
|
79
|
+
if (!conversation || !hasRunnableConversationWork(conversation)) return { status: "no_work" };
|
|
80
|
+
if (args.replaceExistingWake !== true && conversation.execution.lease && conversation.execution.lease.expiresAtMs > nowMs) return { status: "lease_active" };
|
|
81
|
+
if (args.ignoreEnqueueMarker !== true && args.replaceExistingWake !== true && hasRecentEnqueueMarker(conversation, nowMs)) return { status: "already_enqueued" };
|
|
82
|
+
const queueResult = await args.queue.send({
|
|
83
|
+
schemaVersion: 2,
|
|
84
|
+
conversationId: args.conversationId
|
|
85
|
+
}, {
|
|
86
|
+
delayMs: args.delayMs,
|
|
87
|
+
idempotencyKey: args.idempotencyKey
|
|
88
|
+
});
|
|
89
|
+
await markConversationWorkEnqueued({
|
|
90
|
+
conversationId: args.conversationId,
|
|
91
|
+
conversationStore: args.conversationStore,
|
|
92
|
+
nowMs,
|
|
93
|
+
state: args.state
|
|
94
|
+
});
|
|
95
|
+
return {
|
|
96
|
+
status: "enqueued",
|
|
97
|
+
queueMessageId: queueResult?.messageId
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
async function enqueueAfterAppend(args) {
|
|
101
|
+
const nowMs = args.nowMs ?? now();
|
|
102
|
+
const appendResult = args.appendResult;
|
|
103
|
+
if (appendResult.status === "active") return appendResult;
|
|
104
|
+
let idempotencyKey = args.message.inboundMessageId;
|
|
105
|
+
if (appendResult.status === "duplicate") {
|
|
106
|
+
const conversation = await getConversation$1({
|
|
107
|
+
conversationId: args.message.conversationId,
|
|
108
|
+
state: args.state
|
|
109
|
+
});
|
|
110
|
+
if (!conversation) return appendResult;
|
|
111
|
+
if (hasRecentEnqueueMarker(conversation, nowMs)) {
|
|
112
|
+
await recordExecutionMetadata({
|
|
113
|
+
conversationId: args.message.conversationId,
|
|
114
|
+
conversationStore: args.conversationStore,
|
|
115
|
+
state: args.state
|
|
116
|
+
});
|
|
117
|
+
return appendResult;
|
|
118
|
+
}
|
|
119
|
+
if (!conversation.execution.pendingMessages.some((message) => message.inboundMessageId === args.message.inboundMessageId)) {
|
|
120
|
+
await recordExecutionMetadata({
|
|
121
|
+
conversationId: args.message.conversationId,
|
|
122
|
+
conversationStore: args.conversationStore,
|
|
123
|
+
state: args.state
|
|
124
|
+
});
|
|
125
|
+
return appendResult;
|
|
126
|
+
}
|
|
127
|
+
idempotencyKey = duplicateInboundNudgeIdempotencyKey(args.message, nowMs);
|
|
128
|
+
}
|
|
129
|
+
const wake = await ensureConversationWake({
|
|
130
|
+
conversationId: args.message.conversationId,
|
|
131
|
+
conversationStore: args.conversationStore,
|
|
132
|
+
delayMs: args.queueDelayMs,
|
|
133
|
+
idempotencyKey,
|
|
134
|
+
ignoreEnqueueMarker: args.message.source === "event" ? void 0 : true,
|
|
135
|
+
nowMs,
|
|
136
|
+
queue: args.queue,
|
|
137
|
+
replaceExistingWake: args.replaceExistingWake,
|
|
138
|
+
state: args.state
|
|
139
|
+
});
|
|
140
|
+
if (wake.status !== "enqueued") await recordExecutionMetadata({
|
|
141
|
+
conversationId: args.message.conversationId,
|
|
142
|
+
conversationStore: args.conversationStore,
|
|
143
|
+
state: args.state
|
|
144
|
+
});
|
|
145
|
+
return {
|
|
146
|
+
...appendResult,
|
|
147
|
+
...wake.status === "enqueued" ? { queueMessageId: wake.queueMessageId } : void 0
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/** Persist inbound work and ensure a worker wake-up. */
|
|
151
|
+
async function appendAndEnqueueInboundMessage(args) {
|
|
152
|
+
const nowMs = args.nowMs ?? now();
|
|
153
|
+
const result = await enqueueAfterAppend({
|
|
154
|
+
...args,
|
|
155
|
+
appendResult: await appendInboundMessage({
|
|
156
|
+
message: args.message,
|
|
157
|
+
nowMs,
|
|
158
|
+
state: args.state
|
|
159
|
+
}),
|
|
160
|
+
nowMs
|
|
161
|
+
});
|
|
162
|
+
if (result.status === "active") throw new Error("Non-exclusive mailbox enqueue returned active");
|
|
163
|
+
return result;
|
|
164
|
+
}
|
|
165
|
+
/** Persist exclusive inbound work and wake its worker when admitted. */
|
|
166
|
+
async function appendAndEnqueueExclusiveInboundMessage(args) {
|
|
167
|
+
const nowMs = args.nowMs ?? now();
|
|
168
|
+
return await enqueueAfterAppend({
|
|
169
|
+
...args,
|
|
170
|
+
appendResult: await appendExclusiveInboundMessage({
|
|
171
|
+
message: args.message,
|
|
172
|
+
nowMs,
|
|
173
|
+
state: args.state
|
|
174
|
+
}),
|
|
175
|
+
nowMs
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
/** Persist a stop request for the current Conversation run. */
|
|
179
|
+
async function stopConversationWork(args) {
|
|
180
|
+
const result = await stopConversationWork$1(args);
|
|
181
|
+
if (result.status === "requested") await recordExecutionMetadata(args);
|
|
182
|
+
return result;
|
|
183
|
+
}
|
|
184
|
+
/** Finish an observed stop request under the current worker lease. */
|
|
185
|
+
async function completeConversationStop(args) {
|
|
186
|
+
const result = await completeConversationStop$1(args);
|
|
187
|
+
if (result.status === "cleared") await recordExecutionMetadata(args);
|
|
188
|
+
return result;
|
|
189
|
+
}
|
|
190
|
+
/** Clear an accepted wake marker after its delivery finds no runnable work. */
|
|
191
|
+
async function clearConsumedConversationWake(args) {
|
|
192
|
+
const result = await clearConsumedConversationWake$1(args);
|
|
193
|
+
if (result) await recordExecutionMetadata(args);
|
|
194
|
+
return result;
|
|
195
|
+
}
|
|
196
|
+
/** Mark a conversation runnable when there is no new mailbox message. */
|
|
197
|
+
async function requestConversationWork(args) {
|
|
198
|
+
const result = await requestConversationWork$1(args);
|
|
199
|
+
await recordExecutionMetadata({
|
|
200
|
+
conversationId: args.conversationId,
|
|
201
|
+
conversationStore: args.conversationStore,
|
|
202
|
+
state: args.state
|
|
203
|
+
});
|
|
204
|
+
return result;
|
|
205
|
+
}
|
|
206
|
+
/** Record that a wake-up nudge was accepted for the conversation. */
|
|
207
|
+
async function markConversationWorkEnqueued(args) {
|
|
208
|
+
await markConversationWorkEnqueued$1(args);
|
|
209
|
+
await recordExecutionMetadata(args);
|
|
210
|
+
}
|
|
211
|
+
/** Try to acquire the durable execution lease for one conversation. */
|
|
212
|
+
async function startConversationWork(args) {
|
|
213
|
+
const result = await startConversationWork$1(args);
|
|
214
|
+
await recordExecutionMetadata(args);
|
|
215
|
+
return result;
|
|
216
|
+
}
|
|
217
|
+
/** Extend the durable execution lease when the worker checks in. */
|
|
218
|
+
async function checkInConversationWork(args) {
|
|
219
|
+
const result = await checkInConversationWork$1(args);
|
|
220
|
+
if (result) await recordExecutionMetadata(args);
|
|
221
|
+
return result;
|
|
222
|
+
}
|
|
223
|
+
/** Drain pending mailbox entries after the caller accepts responsibility. */
|
|
224
|
+
async function drainConversationMailbox(args) {
|
|
225
|
+
const result = await drainConversationMailbox$1(args);
|
|
226
|
+
if (result.changed) await recordExecutionMetadata(args);
|
|
227
|
+
return result.messages;
|
|
228
|
+
}
|
|
229
|
+
/** Acknowledge leased mailbox entries after the handler accepts responsibility. */
|
|
230
|
+
async function ackMessages(args) {
|
|
231
|
+
const result = await ackMessages$1(args);
|
|
232
|
+
await recordExecutionMetadata(args);
|
|
233
|
+
return result;
|
|
234
|
+
}
|
|
235
|
+
/** Cancel human-facing pending mailbox rows without requiring a worker lease. */
|
|
236
|
+
async function cancelHumanFacingPendingMessages(args) {
|
|
237
|
+
const result = await cancelHumanFacingPendingMessages$1(args);
|
|
238
|
+
if (result.cancelledInboundMessageIds.length > 0) await recordExecutionMetadata(args);
|
|
239
|
+
return result;
|
|
240
|
+
}
|
|
241
|
+
/** Mark one author's queued web messages as interrupts. */
|
|
242
|
+
async function steerWebPendingMessages(args) {
|
|
243
|
+
return await steerWebPendingMessages$1(args);
|
|
244
|
+
}
|
|
245
|
+
/** Mark the leased conversation as needing another queue-delivered slice. */
|
|
246
|
+
async function requestAnotherSlice(args) {
|
|
247
|
+
const result = await requestAnotherSlice$1(args);
|
|
248
|
+
await recordExecutionMetadata(args);
|
|
249
|
+
return result;
|
|
250
|
+
}
|
|
251
|
+
/** Begin a requested turn resume without releasing the current lease. */
|
|
252
|
+
async function beginConversationResume(args) {
|
|
253
|
+
const result = await beginConversationResume$1(args);
|
|
254
|
+
if (result) await recordExecutionMetadata(args);
|
|
255
|
+
return result;
|
|
256
|
+
}
|
|
257
|
+
/** Release the durable execution lease without changing completion state. */
|
|
258
|
+
async function releaseConversationWork(args) {
|
|
259
|
+
const result = await releaseConversationWork$1(args);
|
|
260
|
+
await recordExecutionMetadata(args);
|
|
261
|
+
return result;
|
|
262
|
+
}
|
|
263
|
+
/** Finish a leased conversation and report whether runnable work remains. */
|
|
264
|
+
async function completeConversationWork(args) {
|
|
265
|
+
const result = await completeConversationWork$1(args);
|
|
266
|
+
await recordExecutionMetadata(args);
|
|
267
|
+
return result;
|
|
268
|
+
}
|
|
269
|
+
/** Record one failed delivery attempt and dead-letter messages at their limit. */
|
|
270
|
+
async function recordAttemptFailure(args) {
|
|
271
|
+
const result = await recordAttemptFailure$1(args);
|
|
272
|
+
if (result.status === "recorded") await recordExecutionMetadata(args);
|
|
273
|
+
return result;
|
|
274
|
+
}
|
|
275
|
+
/** Record a terminal failure completion for a leased conversation. */
|
|
276
|
+
async function deadLetterAttempt(args) {
|
|
277
|
+
const result = await deadLetterAttempt$1(args);
|
|
278
|
+
await recordExecutionMetadata(args);
|
|
279
|
+
return result;
|
|
280
|
+
}
|
|
281
|
+
/** Recover an expired lease and persist the resulting retry state. */
|
|
282
|
+
async function clearExpiredConversationLease(args) {
|
|
283
|
+
const result = await clearExpiredConversationLease$1(args);
|
|
284
|
+
await recordExecutionMetadata(args);
|
|
285
|
+
return result;
|
|
286
|
+
}
|
|
287
|
+
/** Remove one conversation from the active index after it is missing or idle. */
|
|
288
|
+
async function removeActiveConversation(args) {
|
|
289
|
+
return await removeActiveConversation$1(args);
|
|
290
|
+
}
|
|
291
|
+
/** List active conversation ids by oldest execution update first. */
|
|
292
|
+
async function listActiveConversationIds(args = {}) {
|
|
293
|
+
return await listActiveConversationIds$1(args);
|
|
294
|
+
}
|
|
295
|
+
export { requestAnotherSlice as C, stopConversationWork as D, steerWebPendingMessages as E, removeActiveConversation as S, startConversationWork as T, hasRunnableConversationWork as _, cancelHumanFacingPendingMessages as a, recordConversationRetry as b, clearExpiredConversationLease as c, countPendingConversationMessages as d, deadLetterAttempt as f, getConversationWorkState as g, getConversation as h, beginConversationResume as i, completeConversationStop as l, ensureConversationWake as m, appendAndEnqueueExclusiveInboundMessage as n, checkInConversationWork as o, drainConversationMailbox as p, appendAndEnqueueInboundMessage as r, clearConsumedConversationWake as s, ackMessages as t, completeConversationWork as u, listActiveConversationIds as v, requestConversationWork as w, releaseConversationWork as x, recordAttemptFailure as y };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as QUEUE_SIGNATURE_MAX_AGE_MS, d as getQueueProvider, l as signQueueMessage, p as runWithTurnRequestDeadline, u as verifyQueueMessage } from "./job-queue-
|
|
1
|
+
import { h as logWarn } from "./logging-DuZ1A4ab.js";
|
|
2
|
+
import { c as QUEUE_SIGNATURE_MAX_AGE_MS, d as getQueueProvider, l as signQueueMessage, p as runWithTurnRequestDeadline, u as verifyQueueMessage } from "./job-queue-C0BZSa7r.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
5
5
|
// src/chat/queue/callback.ts
|
|
@@ -44,10 +44,11 @@ function queueCallback(options) {
|
|
|
44
44
|
return {
|
|
45
45
|
/** Run a message that an in-process queue already trusts. */
|
|
46
46
|
consume,
|
|
47
|
+
consumer,
|
|
47
48
|
create: () => getQueueProvider().createCallback(consumer),
|
|
48
49
|
registerDev: () => {
|
|
49
50
|
if (process.env.NODE_ENV !== "development") return;
|
|
50
|
-
return getQueueProvider().registerDevConsumer(consumer);
|
|
51
|
+
return getQueueProvider().registerDevConsumer?.(consumer);
|
|
51
52
|
}
|
|
52
53
|
};
|
|
53
54
|
}
|
|
@@ -109,7 +110,7 @@ function pluginTaskCallback() {
|
|
|
109
110
|
maxDeliveries: PLUGIN_TASK_MAX_DELIVERIES,
|
|
110
111
|
onRejected: logPluginTaskQueueMessageRejected,
|
|
111
112
|
run: async (message) => {
|
|
112
|
-
const { processPluginTask } = await import("./task-runner-
|
|
113
|
+
const { processPluginTask } = await import("./task-runner-B-PD_JOj.js").then((n) => n.r);
|
|
113
114
|
await processPluginTask(message);
|
|
114
115
|
},
|
|
115
116
|
topic: PLUGIN_TASK_QUEUE_TOPIC,
|
|
@@ -127,8 +128,12 @@ async function sendVercelPluginTask(message) {
|
|
|
127
128
|
function createVercelPluginTaskCallback() {
|
|
128
129
|
return pluginTaskCallback().create();
|
|
129
130
|
}
|
|
131
|
+
/** Return the queue consumer for plugin tasks, for a pulling queue worker. */
|
|
132
|
+
function pluginTaskQueueConsumer() {
|
|
133
|
+
return pluginTaskCallback().consumer;
|
|
134
|
+
}
|
|
130
135
|
/** Register the local-dev consumer for plugin tasks. */
|
|
131
136
|
function registerVercelPluginTaskDevConsumer() {
|
|
132
137
|
return pluginTaskCallback().registerDev();
|
|
133
138
|
}
|
|
134
|
-
export {
|
|
139
|
+
export { pluginTaskQueueConsumer as a, queueCallback as c, pluginTaskParamsSchema as i, createVercelPluginTaskCallback as n, registerVercelPluginTaskDevConsumer as o, pluginTaskId as r, sendVercelPluginTask as s, PLUGIN_TASK_QUEUE_TOPIC as t };
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { Bn as instructionTextForProjection, Gn as normalizeToolNameFromResult, In as getPiMessageRole, Un as isToolResultError, Wn as isToolResultMessage, gt as fallbackShortTitle, i as readScheduledAutomation, l as blockEventAutomation, m as getEventAutomation, qn as stripRuntimeTurnContext, qt as getTurnRecord, ut as hydrateConversationMessages } from "./tasks-0ilmuCux.js";
|
|
3
|
+
import { _ as runBestEffort, h as logWarn } from "./logging-DuZ1A4ab.js";
|
|
4
|
+
import { p as parseSlackMessageTs } from "./actor-DZSokpwj.js";
|
|
5
|
+
import { D as agentTurnTotalTokens, E as agentTurnCostUsd, f as getConversationStore, p as getDb, r as readActorIdentity } from "./viewer-DrN3oC2X.js";
|
|
6
6
|
import { s as juniorConversations } from "./agent-invocations-CxKldAeB.js";
|
|
7
|
-
import { a as juniorAutomationRuns, o as juniorAutomationVersions, s as juniorAutomations } from "./executor-
|
|
8
|
-
import { m as sameActorIdentity } from "./history-
|
|
9
|
-
import { h as credentialSubjectSchema } from "./registry-
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-
|
|
13
|
-
import { t as resolveConversationRouting } from "./turn-session-routing-
|
|
14
|
-
import { i as pluginTaskParamsSchema,
|
|
7
|
+
import { a as juniorAutomationRuns, o as juniorAutomationVersions, s as juniorAutomations } from "./executor-VYrx_K4w.js";
|
|
8
|
+
import { m as sameActorIdentity } from "./history-C84mlAwO.js";
|
|
9
|
+
import { h as credentialSubjectSchema } from "./registry-FQutO926.js";
|
|
10
|
+
import { $ as postSlackMessage, An as createPluginState, Mn as createPluginModel, Nn as createPluginLogger, U as escapeSlackMrkdwnText, Un as createPluginConversationEvents, W as formatSlackLink, Z as openSlackDirectMessage, ar as createPluginCache, dn as JUNIOR_THREAD_STATE_TTL_MS, g as coreTaskRegistrations, jn as createPluginEmbedder, mn as getDashboardTaskLink, p as getPlugins } from "./credentialed-CIGwoLU2.js";
|
|
11
|
+
import { i as getStateAdapter } from "./adapter-BybMEezj.js";
|
|
12
|
+
import { r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-DRmdJ2QN.js";
|
|
13
|
+
import { t as resolveConversationRouting } from "./turn-session-routing-Dyut9l7Y.js";
|
|
14
|
+
import { i as pluginTaskParamsSchema, r as pluginTaskId, s as sendVercelPluginTask } from "./task-queue-B0DLgd2P.js";
|
|
15
15
|
import { z } from "zod";
|
|
16
16
|
import { createHash } from "node:crypto";
|
|
17
17
|
import { and, asc, count, desc, eq, gte, inArray, isNotNull, lte, max, sql } from "drizzle-orm";
|
|
@@ -117,7 +117,7 @@ const EMPTY_RUN_WINDOWS = {
|
|
|
117
117
|
30: 0,
|
|
118
118
|
90: 0
|
|
119
119
|
};
|
|
120
|
-
/** Empty run windows for automations with no execution history. */
|
|
120
|
+
/** Empty run or cost windows for automations with no execution history. */
|
|
121
121
|
function emptyAutomationRunWindows() {
|
|
122
122
|
return { ...EMPTY_RUN_WINDOWS };
|
|
123
123
|
}
|
|
@@ -199,7 +199,13 @@ async function readAutomationExecutionSummaries(automationIds, options = {}) {
|
|
|
199
199
|
conversationId: juniorAutomationRuns.conversationId,
|
|
200
200
|
automationId: juniorAutomationRuns.automationId
|
|
201
201
|
}).from(juniorAutomationRuns).where(selected).orderBy(juniorAutomationRuns.automationId, desc(juniorAutomationRuns.completedAtMs), desc(juniorAutomationRuns.id)).as("latest_task_execution");
|
|
202
|
+
const conversationCost = conversationUsageCostExpr(juniorConversations.usage);
|
|
203
|
+
const costSince = (sinceMs) => sql`coalesce(sum(${conversationCost}) filter (where ${juniorAutomationRuns.completedAtMs} >= ${sinceMs}), 0)::double precision`;
|
|
202
204
|
const rows = await db.select({
|
|
205
|
+
costLast1Day: costSince(oneDayAgoMs),
|
|
206
|
+
costLast7Days: costSince(sevenDaysAgoMs),
|
|
207
|
+
costLast30Days: costSince(thirtyDaysAgoMs),
|
|
208
|
+
costLast90Days: costSince(ninetyDaysAgoMs),
|
|
203
209
|
lastRunStatus: latest.status,
|
|
204
210
|
lastConversationId: latest.conversationId,
|
|
205
211
|
lastExecutedAtMs: max(juniorAutomationRuns.completedAtMs),
|
|
@@ -209,8 +215,14 @@ async function readAutomationExecutionSummaries(automationIds, options = {}) {
|
|
|
209
215
|
runsLast90Days: sql`count(*) filter (where ${juniorAutomationRuns.completedAtMs} >= ${ninetyDaysAgoMs})::int`,
|
|
210
216
|
automationId: juniorAutomationRuns.automationId,
|
|
211
217
|
totalRuns: sql`count(*)::int`
|
|
212
|
-
}).from(juniorAutomationRuns).innerJoin(latest, eq(latest.automationId, juniorAutomationRuns.automationId)).where(selected).groupBy(juniorAutomationRuns.automationId, latest.conversationId, latest.status);
|
|
218
|
+
}).from(juniorAutomationRuns).innerJoin(latest, eq(latest.automationId, juniorAutomationRuns.automationId)).leftJoin(juniorConversations, executionConversation()).where(selected).groupBy(juniorAutomationRuns.automationId, latest.conversationId, latest.status);
|
|
213
219
|
return new Map(rows.map((row) => [row.automationId, {
|
|
220
|
+
costUsd: {
|
|
221
|
+
1: addUsd(0, row.costLast1Day),
|
|
222
|
+
7: addUsd(0, row.costLast7Days),
|
|
223
|
+
30: addUsd(0, row.costLast30Days),
|
|
224
|
+
90: addUsd(0, row.costLast90Days)
|
|
225
|
+
},
|
|
214
226
|
lastRunStatus: row.lastRunStatus,
|
|
215
227
|
...row.lastConversationId ? { lastConversationId: row.lastConversationId } : void 0,
|
|
216
228
|
...row.lastExecutedAtMs !== null ? { lastExecutedAtMs: row.lastExecutedAtMs } : void 0,
|