@sentry/junior 0.234.0 → 0.236.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/{agent-hooks-BcH6E48y.js → agent-hooks-Da_H0jHv.js} +17 -10
- package/dist/{agent-runner-DUkGlK89.js → agent-runner-uP7QRc4c.js} +484 -162
- package/dist/api/schema.d.ts +288 -2
- package/dist/api/schema.js +5 -4
- package/dist/api.d.ts +8 -2
- package/dist/api.js +524 -83
- package/dist/{app-xk2-Id1T.d.ts → app-MEd7wbF0.d.ts} +83 -49
- package/dist/app.d.ts +3 -3
- package/dist/app.js +164 -119
- package/dist/{types-Du-HbEun.js → automation-B9Kc1gcf.js} +304 -33
- package/dist/{briefs-lyAQbDxJ.js → briefs-DrjBPQFy.js} +4 -4
- package/dist/{catalog-runtime-BSgsPVnr.js → catalog-runtime-C7339Cfm.js} +1 -1
- package/dist/{checkpoint-BNfXlq_1.js → checkpoint-DaD7_Gsb.js} +16 -9
- package/dist/cli/chat.d.ts +1 -1
- package/dist/cli/chat.js +14 -14
- package/dist/cli/check.js +4 -4
- package/dist/cli/main.js +1 -1
- package/dist/cli/plugins.d.ts +1 -1
- package/dist/cli/plugins.js +4 -4
- package/dist/cli/snapshot-create.js +3 -3
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +5 -5
- package/dist/{client-BX5lJRqW.js → client-Ch9Hg9NU.js} +2 -2
- package/dist/{config-DuCzUoCo.js → config-JR9wke1W.js} +57 -17
- package/dist/{conversation-CPjHYOV5.js → conversation-9Fxa1Zbq.js} +14 -1
- package/dist/{conversation-privacy-CSxvdSoV.js → conversation-privacy-au02dyZK.js} +1 -1
- package/dist/{credential-sync-BO4DfH9a.js → credential-sync-BWTA3LnL.js} +14 -14
- package/dist/{executor--jWf-Nnm.js → executor-BW9XWgUQ.js} +70 -6
- package/dist/{images-BaL19wFC.js → images-BdG7zcNf.js} +3 -3
- package/dist/instrumentation.js +2 -2
- package/dist/{job-queue-cwHVOwVZ.js → job-queue-BqXd0ZPV.js} +1 -1
- package/dist/{logging-Cox1Mgcv.js → logging-B4sKwmCG.js} +1 -1
- package/dist/nitro.d.ts +2 -2
- package/dist/nitro.js +5 -5
- package/dist/{oauth-authorization-CC8a1JKP.js → oauth-authorization-BjRN99dc.js} +1 -1
- package/dist/{oauth-callback-server-Z7QSt416.js → oauth-callback-server-B_1p98Mb.js} +2 -2
- package/dist/{pending-auth-DQhC3eSR.js → pending-auth-WqF4Gh8Z.js} +1 -1
- package/dist/{plugins-BT2l4We3.d.ts → plugins-CjfUP5gJ.d.ts} +1 -0
- package/dist/{profile-BdApelHS.js → profile-BamYnmhO.js} +4 -4
- package/dist/{prompt-3D0sSbTC.js → prompt-Ctwy6hSI.js} +1 -1
- package/dist/queue-B5SnqRln.d.ts +25 -0
- package/dist/{registry-DiY6B8CN.js → registry-CXNv9fDX.js} +38 -2
- package/dist/{resolve-VpJoiDpc.js → resolve-C9ETkt4T.js} +2 -2
- package/dist/{runner-BIMegnPE.js → runner-DnBGVRnW.js} +9 -9
- package/dist/{sandbox-egress-signals-Cbtxe492.js → sandbox-egress-signals-DwJ7Boi_.js} +1 -1
- package/dist/{schema-CxwnlTDN.js → schema-CJiqDc5r.js} +26 -3
- package/dist/{skills-WttpPJUy.js → skills-Dd8O9Aav.js} +3 -3
- package/dist/{spawn-DhfMKt4y.js → spawn-DFdRspSD.js} +2 -2
- package/dist/{task-queue-CZqUNJD0.js → task-queue-DGQEOk1A.js} +16 -10
- package/dist/{task-runner-BZaqoUCT.js → task-runner-C5XCIDSF.js} +9 -9
- package/dist/{thread-state-8tXZhu0y.js → thread-state-D3E29wZk.js} +5 -5
- package/dist/{turn-failure-response-DFJ9L9NQ.js → turn-failure-response-TDoj0aZz.js} +8 -8
- package/dist/{turn-lifecycle-WbpTUQ_r.js → turn-lifecycle-DOnU45p7.js} +1 -1
- package/dist/{turn-session-routing--EhI76rH.js → turn-session-routing-DbpZZoin.js} +1 -1
- package/dist/{validation-0F9IgG3b.js → validation-B9lMbisx.js} +1 -1
- package/dist/{version-A7-RRBOE.js → version-CWkIGcLU.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{web-authorization-BJggXofy.js → web-authorization-PPaoj2ns.js} +6 -6
- package/dist/{web-input-B-siN5Dr.js → web-input-CfNxXtHm.js} +86 -34
- package/dist/web-message-id-xPI_EFSC.js +239 -0
- package/dist/{work-CNc0ejGG.js → work-DNaoFrEe.js} +7 -7
- package/dist/{worker-BHbqpUAu.js → worker-xeJLxYwm.js} +5 -5
- package/migrations/0045_conversation_forks.sql +3 -0
- package/migrations/0046_automation_versions.sql +71 -0
- package/migrations/meta/0045_snapshot.json +3503 -0
- package/migrations/meta/0046_snapshot.json +3707 -0
- package/migrations/meta/_journal.json +15 -1
- package/package.json +5 -5
- package/dist/web-message-id-CVVCTWUb.js +0 -464
- package/dist/{package-discovery-7a9YqLhE.js → package-discovery-BVvSnQBB.js} +1 -1
- package/dist/{plugin-module-BKGOXca2.js → plugin-module-CVvEUSMH.js} +1 -1
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/reporting-schema.ts
|
|
3
|
+
const healthReportSchema = z.object({
|
|
4
|
+
status: z.literal("ok"),
|
|
5
|
+
service: z.string(),
|
|
6
|
+
timestamp: z.string()
|
|
7
|
+
}).strict();
|
|
8
|
+
const pluginSchema = z.object({
|
|
9
|
+
configKeys: z.array(z.string()),
|
|
10
|
+
description: z.string(),
|
|
11
|
+
displayName: z.string(),
|
|
12
|
+
name: z.string()
|
|
13
|
+
}).strict();
|
|
14
|
+
const pluginsSchema = z.array(pluginSchema);
|
|
15
|
+
const skillReportSchema = z.object({
|
|
16
|
+
name: z.string(),
|
|
17
|
+
pluginProvider: z.string().optional()
|
|
18
|
+
}).strict();
|
|
19
|
+
const skillReportsSchema = z.array(skillReportSchema);
|
|
20
|
+
const pluginPackageContentItemReportSchema = z.object({
|
|
21
|
+
dir: z.string(),
|
|
22
|
+
hasMigrationsDir: z.boolean(),
|
|
23
|
+
hasSkillsDir: z.boolean(),
|
|
24
|
+
packageName: z.string()
|
|
25
|
+
}).strict();
|
|
26
|
+
const pluginPackageContentReportSchema = z.object({
|
|
27
|
+
packageNames: z.array(z.string()),
|
|
28
|
+
packages: z.array(pluginPackageContentItemReportSchema),
|
|
29
|
+
manifestRoots: z.array(z.string()),
|
|
30
|
+
skillRoots: z.array(z.string()),
|
|
31
|
+
tracingIncludes: z.array(z.string())
|
|
32
|
+
}).strict();
|
|
33
|
+
const runtimeInfoReportSchema = z.object({
|
|
34
|
+
cwd: z.string(),
|
|
35
|
+
homeDir: z.string(),
|
|
36
|
+
descriptionText: z.string().optional(),
|
|
37
|
+
providers: z.array(z.string()),
|
|
38
|
+
skills: z.array(skillReportSchema),
|
|
39
|
+
packagedContent: pluginPackageContentReportSchema
|
|
40
|
+
}).strict();
|
|
41
|
+
const pluginOperationalToneSchema = z.enum([
|
|
42
|
+
"danger",
|
|
43
|
+
"good",
|
|
44
|
+
"neutral",
|
|
45
|
+
"warning"
|
|
46
|
+
]);
|
|
47
|
+
const pluginOperationalMetricSchema = z.object({
|
|
48
|
+
label: z.string(),
|
|
49
|
+
tone: pluginOperationalToneSchema.optional(),
|
|
50
|
+
value: z.string()
|
|
51
|
+
}).strict();
|
|
52
|
+
const pluginOperationalFieldSchema = z.object({
|
|
53
|
+
key: z.string(),
|
|
54
|
+
label: z.string()
|
|
55
|
+
}).strict();
|
|
56
|
+
const pluginOperationalRecordSchema = z.object({
|
|
57
|
+
id: z.string(),
|
|
58
|
+
tone: pluginOperationalToneSchema.optional(),
|
|
59
|
+
values: z.record(z.string(), z.string())
|
|
60
|
+
}).strict();
|
|
61
|
+
const pluginOperationalRecordSetSchema = z.object({
|
|
62
|
+
fields: z.array(pluginOperationalFieldSchema).optional(),
|
|
63
|
+
emptyText: z.string().optional(),
|
|
64
|
+
records: z.array(pluginOperationalRecordSchema).optional(),
|
|
65
|
+
title: z.string()
|
|
66
|
+
}).strict();
|
|
67
|
+
const pluginOperationalBarChartWidgetSchema = z.object({
|
|
68
|
+
categories: z.array(z.object({
|
|
69
|
+
id: z.string().min(1),
|
|
70
|
+
label: z.string().min(1),
|
|
71
|
+
values: z.record(z.string(), z.number().finite())
|
|
72
|
+
}).strict()).max(100),
|
|
73
|
+
description: z.string().optional(),
|
|
74
|
+
emptyText: z.string().optional(),
|
|
75
|
+
id: z.string().min(1),
|
|
76
|
+
series: z.array(z.object({
|
|
77
|
+
format: z.literal("usd").optional(),
|
|
78
|
+
key: z.string().min(1),
|
|
79
|
+
label: z.string().min(1),
|
|
80
|
+
tone: pluginOperationalToneSchema.optional()
|
|
81
|
+
}).strict()).min(1).max(8),
|
|
82
|
+
timeRangeDays: z.array(z.union([
|
|
83
|
+
z.literal(1),
|
|
84
|
+
z.literal(7),
|
|
85
|
+
z.literal(30),
|
|
86
|
+
z.literal(90)
|
|
87
|
+
])).min(1).max(4).optional(),
|
|
88
|
+
title: z.string().min(1),
|
|
89
|
+
type: z.literal("bar_chart")
|
|
90
|
+
}).strict();
|
|
91
|
+
const pluginOperationalReportSchema = z.object({
|
|
92
|
+
generatedAt: z.string().optional(),
|
|
93
|
+
metrics: z.array(pluginOperationalMetricSchema).optional(),
|
|
94
|
+
recordSets: z.array(pluginOperationalRecordSetSchema).optional(),
|
|
95
|
+
title: z.string().optional(),
|
|
96
|
+
pluginName: z.string(),
|
|
97
|
+
widgets: z.array(pluginOperationalBarChartWidgetSchema).max(12).optional()
|
|
98
|
+
}).strict();
|
|
99
|
+
const pluginOperationalReportFeedSchema = z.object({
|
|
100
|
+
generatedAt: z.string(),
|
|
101
|
+
reports: z.array(pluginOperationalReportSchema),
|
|
102
|
+
source: z.literal("plugins")
|
|
103
|
+
}).strict();
|
|
104
|
+
//#endregion
|
|
105
|
+
//#region src/api/reporting-window.ts
|
|
106
|
+
/** Shared UTC day/hour/six-hour windows for dashboard activity series. */
|
|
107
|
+
const HOUR_MS = 36e5;
|
|
108
|
+
const SIX_HOUR_MS = 6 * HOUR_MS;
|
|
109
|
+
const DAY_MS = 24 * HOUR_MS;
|
|
110
|
+
/** Start of the UTC calendar day containing `valueMs`. */
|
|
111
|
+
function startOfUtcDay(valueMs) {
|
|
112
|
+
const date = new Date(valueMs);
|
|
113
|
+
date.setUTCHours(0, 0, 0, 0);
|
|
114
|
+
return date;
|
|
115
|
+
}
|
|
116
|
+
/** Start of the UTC hour containing `valueMs`. */
|
|
117
|
+
function startOfUtcHour(valueMs) {
|
|
118
|
+
const date = new Date(valueMs);
|
|
119
|
+
date.setUTCMinutes(0, 0, 0);
|
|
120
|
+
return date;
|
|
121
|
+
}
|
|
122
|
+
/** Start of the UTC 6-hour bucket containing `valueMs` (00/06/12/18). */
|
|
123
|
+
function startOfUtcSixHour(valueMs) {
|
|
124
|
+
const date = startOfUtcHour(valueMs);
|
|
125
|
+
date.setUTCHours(Math.floor(date.getUTCHours() / 6) * 6, 0, 0, 0);
|
|
126
|
+
return date;
|
|
127
|
+
}
|
|
128
|
+
/** UTC day key `YYYY-MM-DD`. */
|
|
129
|
+
function utcDayKey(value) {
|
|
130
|
+
return (typeof value === "number" ? new Date(value) : value).toISOString().slice(0, 10);
|
|
131
|
+
}
|
|
132
|
+
/** UTC hour key `YYYY-MM-DDTHH`. */
|
|
133
|
+
function utcHourKey(value) {
|
|
134
|
+
return (typeof value === "number" ? new Date(value) : value).toISOString().slice(0, 13);
|
|
135
|
+
}
|
|
136
|
+
/** UTC 6-hour bucket key `YYYY-MM-DDTHH` at 00/06/12/18. */
|
|
137
|
+
function utcSixHourKey(value) {
|
|
138
|
+
return utcHourKey(startOfUtcSixHour(typeof value === "number" ? value : value.getTime()));
|
|
139
|
+
}
|
|
140
|
+
/** Inclusive trailing UTC day window ending on today's UTC day. */
|
|
141
|
+
function trailingUtcDayWindow(nowMs, dayCount) {
|
|
142
|
+
const end = startOfUtcDay(nowMs);
|
|
143
|
+
const start = new Date(end);
|
|
144
|
+
start.setUTCDate(start.getUTCDate() - (dayCount - 1));
|
|
145
|
+
return {
|
|
146
|
+
end,
|
|
147
|
+
start
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/** Inclusive trailing UTC hour window ending on the current UTC hour. */
|
|
151
|
+
function trailingUtcHourWindow(nowMs, hourCount = 24) {
|
|
152
|
+
const end = startOfUtcHour(nowMs);
|
|
153
|
+
return {
|
|
154
|
+
end,
|
|
155
|
+
start: /* @__PURE__ */ new Date(end.getTime() - (hourCount - 1) * HOUR_MS)
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
/** Inclusive trailing UTC 6-hour window ending on the current 6h bucket. */
|
|
159
|
+
function trailingUtcSixHourWindow(nowMs, bucketCount = 28) {
|
|
160
|
+
const end = startOfUtcSixHour(nowMs);
|
|
161
|
+
return {
|
|
162
|
+
end,
|
|
163
|
+
start: /* @__PURE__ */ new Date(end.getTime() - (bucketCount - 1) * SIX_HOUR_MS)
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
/** Fill a fixed UTC day window from a sparse map. */
|
|
167
|
+
function fillUtcDays(args) {
|
|
168
|
+
const { end, start } = trailingUtcDayWindow(args.nowMs, args.count);
|
|
169
|
+
const items = [];
|
|
170
|
+
for (const cursor = new Date(start); cursor.getTime() <= end.getTime(); cursor.setUTCDate(cursor.getUTCDate() + 1)) {
|
|
171
|
+
const date = utcDayKey(cursor);
|
|
172
|
+
items.push(args.rows.get(date) ?? args.empty(date));
|
|
173
|
+
}
|
|
174
|
+
return items;
|
|
175
|
+
}
|
|
176
|
+
/** Fill a fixed UTC hour window from a sparse map. */
|
|
177
|
+
function fillUtcHours(args) {
|
|
178
|
+
const hourCount = args.count ?? 24;
|
|
179
|
+
const { end, start } = trailingUtcHourWindow(args.nowMs, hourCount);
|
|
180
|
+
const items = [];
|
|
181
|
+
for (const cursor = new Date(start); cursor.getTime() <= end.getTime(); cursor.setTime(cursor.getTime() + HOUR_MS)) {
|
|
182
|
+
const date = utcHourKey(cursor);
|
|
183
|
+
items.push(args.rows.get(date) ?? args.empty(date));
|
|
184
|
+
}
|
|
185
|
+
return items;
|
|
186
|
+
}
|
|
187
|
+
/** Fill a fixed UTC 6-hour window from a map of known rows. */
|
|
188
|
+
function fillUtcSixHours(args) {
|
|
189
|
+
const bucketCount = args.count ?? 28;
|
|
190
|
+
const { end, start } = trailingUtcSixHourWindow(args.nowMs, bucketCount);
|
|
191
|
+
const items = [];
|
|
192
|
+
for (const cursor = new Date(start); cursor.getTime() <= end.getTime(); cursor.setTime(cursor.getTime() + SIX_HOUR_MS)) {
|
|
193
|
+
const date = utcSixHourKey(cursor);
|
|
194
|
+
items.push(args.rows.get(date) ?? args.empty(date));
|
|
195
|
+
}
|
|
196
|
+
return items;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Sum hour rows into trailing 6-hour buckets.
|
|
200
|
+
* Adds number fields. Keeps other fields from the first row in the bucket.
|
|
201
|
+
* Sets `date` to the 6-hour bucket key.
|
|
202
|
+
*/
|
|
203
|
+
function sumUtcHoursIntoSixHours(args) {
|
|
204
|
+
const bucketCount = args.count ?? 28;
|
|
205
|
+
const bySix = /* @__PURE__ */ new Map();
|
|
206
|
+
for (const hour of args.hours) {
|
|
207
|
+
const key = utcSixHourKey(Date.parse(`${hour.date}:00:00.000Z`));
|
|
208
|
+
const next = {
|
|
209
|
+
...bySix.get(key) ?? args.empty(key),
|
|
210
|
+
date: key
|
|
211
|
+
};
|
|
212
|
+
for (const [field, value] of Object.entries(hour)) {
|
|
213
|
+
if (field === "date") continue;
|
|
214
|
+
if (typeof value === "number") {
|
|
215
|
+
const prior = next[field];
|
|
216
|
+
next[field] = (typeof prior === "number" ? prior : 0) + value;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
bySix.set(key, next);
|
|
220
|
+
}
|
|
221
|
+
return fillUtcSixHours({
|
|
222
|
+
count: bucketCount,
|
|
223
|
+
empty: args.empty,
|
|
224
|
+
nowMs: args.nowMs,
|
|
225
|
+
rows: bySix
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region src/chat/conversations/web-message-id.ts
|
|
230
|
+
/**
|
|
231
|
+
* Build the retry-stable Message id shared by web ingress and browser sends.
|
|
232
|
+
* Keep the existing hash and prefix so retries still address stored Messages.
|
|
233
|
+
*/
|
|
234
|
+
async function webMessageId(args) {
|
|
235
|
+
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(`${args.conversationId}\u0000${args.idempotencyKey}`));
|
|
236
|
+
return `api-msg:${Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("").slice(0, 24)}`;
|
|
237
|
+
}
|
|
238
|
+
//#endregion
|
|
239
|
+
export { skillReportsSchema as C, skillReportSchema as S, pluginPackageContentItemReportSchema as _, fillUtcHours as a, pluginsSchema as b, sumUtcHoursIntoSixHours as c, trailingUtcSixHourWindow as d, utcDayKey as f, pluginOperationalReportSchema as g, pluginOperationalReportFeedSchema as h, fillUtcDays as i, trailingUtcDayWindow as l, healthReportSchema as m, DAY_MS as n, fillUtcSixHours as o, utcHourKey as p, HOUR_MS as r, startOfUtcHour as s, webMessageId as t, trailingUtcHourWindow as u, pluginPackageContentReportSchema as v, runtimeInfoReportSchema as x, pluginSchema as y };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { d as getConversationTurnBoundaryError, l as TurnInputCommitLostError, p as isTurnInputCommitLostError, r as getAssistantReplyText } from "./oauth-authorization-
|
|
7
|
-
import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-
|
|
8
|
-
import { n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState } from "./thread-state-
|
|
2
|
+
import { _t as agentInvocationSchema, bt as AgentInvocationLimitError, gt as agentBindingSchema, jt as appendAndEnqueueInboundMessage, m as PluginCredentialFailureError, n as runAgentWithTimeout, vt as createAgentInvocationSchema, yt as AgentInvocationBusyError, zn as AuthorizationFlowDisabledError } from "./agent-runner-uP7QRc4c.js";
|
|
3
|
+
import { Qt as getConversationEventStore, en as getConversationStore, nn as getSqlExecutor } from "./agent-hooks-Da_H0jHv.js";
|
|
4
|
+
import { m as juniorAgentInvocations, p as juniorAgentBindings } from "./executor-BW9XWgUQ.js";
|
|
5
|
+
import { L as openConversationProjection, _ as getTerminalAssistantMessages, o as failTurnRecord, r as saveTurnCheckpoint, s as getTurnRecord } from "./checkpoint-DaD7_Gsb.js";
|
|
6
|
+
import { d as getConversationTurnBoundaryError, l as TurnInputCommitLostError, p as isTurnInputCommitLostError, r as getAssistantReplyText } from "./oauth-authorization-BjRN99dc.js";
|
|
7
|
+
import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-DOnU45p7.js";
|
|
8
|
+
import { n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState } from "./thread-state-D3E29wZk.js";
|
|
9
9
|
import { z } from "zod";
|
|
10
10
|
import { createHash } from "node:crypto";
|
|
11
11
|
import { and, asc, count, eq, inArray } from "drizzle-orm";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
|
|
2
|
-
import { $t as
|
|
3
|
-
import { v as isProviderRetryError } from "./client-
|
|
4
|
-
import { C as withLogContext, d as logException, f as logInfo, p as logWarn } from "./logging-
|
|
5
|
-
import {
|
|
6
|
-
import { f as getTurnRequestDeadline, m as ConversationQueueMessageRejectedError } from "./job-queue-
|
|
2
|
+
import { $t as startConversationWork, Bt as deadLetterAttempt, Ft as clearConsumedConversationWake, Ht as ensureConversationWake, Jt as recordConversationRetry, Lt as completeConversationStop, Mt as beginConversationResume, Pt as checkInConversationWork, Rt as completeConversationWork, Vt as drainConversationMailbox, Wt as getConversationWorkState, Yt as releaseConversationWork, Zt as requestAnotherSlice, an as isFinalAttempt, kt as ackMessages, on as isInvalidConversationRecordError, qt as recordAttemptFailure, rn as hasConversationStop, zt as countPendingConversationMessages } from "./agent-runner-uP7QRc4c.js";
|
|
3
|
+
import { v as isProviderRetryError } from "./client-Ch9Hg9NU.js";
|
|
4
|
+
import { C as withLogContext, d as logException, f as logInfo, p as logWarn } from "./logging-B4sKwmCG.js";
|
|
5
|
+
import { i as getChatConfig } from "./config-JR9wke1W.js";
|
|
6
|
+
import { f as getTurnRequestDeadline, m as ConversationQueueMessageRejectedError } from "./job-queue-BqXd0ZPV.js";
|
|
7
7
|
//#region src/chat/task-execution/worker.ts
|
|
8
8
|
var worker_exports = /* @__PURE__ */ __exportAll({
|
|
9
9
|
CONVERSATION_WORK_DEFER_DELAY_MS: () => CONVERSATION_WORK_DEFER_DELAY_MS,
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
ALTER TABLE "junior_conversations" ADD COLUMN "forked_from_conversation_id" text;--> statement-breakpoint
|
|
2
|
+
ALTER TABLE "junior_conversations" ADD CONSTRAINT "junior_conversations_forked_from_conversation_id_junior_conversations_conversation_id_fk" FOREIGN KEY ("forked_from_conversation_id") REFERENCES "public"."junior_conversations"("conversation_id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
3
|
+
CREATE INDEX "junior_conversations_forked_from_idx" ON "junior_conversations" USING btree ("forked_from_conversation_id");
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
CREATE TABLE "junior_automation_versions" (
|
|
2
|
+
"kind" text NOT NULL,
|
|
3
|
+
"automation_id" text NOT NULL,
|
|
4
|
+
"version" integer NOT NULL,
|
|
5
|
+
"created_at_ms" bigint NOT NULL,
|
|
6
|
+
"edited_by" jsonb,
|
|
7
|
+
"definition" jsonb NOT NULL,
|
|
8
|
+
CONSTRAINT "junior_automation_versions_pk" PRIMARY KEY("kind","automation_id","version"),
|
|
9
|
+
CONSTRAINT "junior_automation_versions_kind_check" CHECK ("junior_automation_versions"."kind" in ('scheduled', 'event'))
|
|
10
|
+
);
|
|
11
|
+
--> statement-breakpoint
|
|
12
|
+
-- Save the current definition of each live Automation as version 1.
|
|
13
|
+
-- The editor is unknown and the time is the upgrade time.
|
|
14
|
+
-- Older workers can still write thread destinations, so remove threadTs.
|
|
15
|
+
INSERT INTO "junior_automation_versions" ("kind", "automation_id", "version", "created_at_ms", "edited_by", "definition")
|
|
16
|
+
SELECT
|
|
17
|
+
'scheduled',
|
|
18
|
+
"id",
|
|
19
|
+
1,
|
|
20
|
+
(extract(epoch from now()) * 1000)::bigint,
|
|
21
|
+
NULL,
|
|
22
|
+
jsonb_build_object(
|
|
23
|
+
'title', nullif(btrim("title"), ''),
|
|
24
|
+
'instruction', "record"->'task'->>'text',
|
|
25
|
+
'credentialMode', "record"->>'credentialMode',
|
|
26
|
+
'destination', ("record"->'destination') - 'threadTs',
|
|
27
|
+
'outcomes', coalesce(
|
|
28
|
+
(
|
|
29
|
+
SELECT jsonb_agg(
|
|
30
|
+
jsonb_set("outcome", '{destination}', ("outcome"->'destination') - 'threadTs', false)
|
|
31
|
+
ORDER BY "ordinality"
|
|
32
|
+
)
|
|
33
|
+
FROM jsonb_array_elements("record"->'outcomes') WITH ORDINALITY AS "items"("outcome", "ordinality")
|
|
34
|
+
),
|
|
35
|
+
'[]'::jsonb
|
|
36
|
+
),
|
|
37
|
+
'schedule', "record"->'schedule'
|
|
38
|
+
)
|
|
39
|
+
FROM "junior_scheduler_tasks"
|
|
40
|
+
WHERE "status" <> 'deleted'
|
|
41
|
+
AND "record"->'task' ? 'text'
|
|
42
|
+
AND "record" ?& array['credentialMode', 'destination', 'outcomes', 'schedule'];
|
|
43
|
+
--> statement-breakpoint
|
|
44
|
+
INSERT INTO "junior_automation_versions" ("kind", "automation_id", "version", "created_at_ms", "edited_by", "definition")
|
|
45
|
+
SELECT
|
|
46
|
+
'event',
|
|
47
|
+
"id",
|
|
48
|
+
1,
|
|
49
|
+
(extract(epoch from now()) * 1000)::bigint,
|
|
50
|
+
NULL,
|
|
51
|
+
jsonb_build_object(
|
|
52
|
+
'title', nullif(btrim("title"), ''),
|
|
53
|
+
'instruction', "task_json"->'task'->>'text',
|
|
54
|
+
'credentialMode', "task_json"->>'credentialMode',
|
|
55
|
+
'destination', ("task_json"->'destination') - 'threadTs',
|
|
56
|
+
'outcomes', coalesce(
|
|
57
|
+
(
|
|
58
|
+
SELECT jsonb_agg(
|
|
59
|
+
jsonb_set("outcome", '{destination}', ("outcome"->'destination') - 'threadTs', false)
|
|
60
|
+
ORDER BY "ordinality"
|
|
61
|
+
)
|
|
62
|
+
FROM jsonb_array_elements("task_json"->'outcomes') WITH ORDINALITY AS "items"("outcome", "ordinality")
|
|
63
|
+
),
|
|
64
|
+
'[]'::jsonb
|
|
65
|
+
),
|
|
66
|
+
'trigger', "task_json"->'trigger'
|
|
67
|
+
)
|
|
68
|
+
FROM "junior_event_tasks"
|
|
69
|
+
WHERE "status" <> 'deleted'
|
|
70
|
+
AND "task_json"->'task' ? 'text'
|
|
71
|
+
AND "task_json" ?& array['credentialMode', 'destination', 'outcomes', 'trigger'];
|