@sentry/junior 0.137.0 → 0.138.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-MZOKEP3J.js → agent-hooks-SCR74Q3E.js} +11 -9
- package/dist/api.js +21 -18
- package/dist/app.d.ts +7 -0
- package/dist/app.js +248 -689
- package/dist/{catalog-runtime-MD66YLFV.js → catalog-runtime-IU3QF4GG.js} +5 -5
- package/dist/chat/agent/request.d.ts +32 -2
- package/dist/chat/agent-dispatch/heartbeat.d.ts +5 -0
- package/dist/chat/agent-dispatch/types.d.ts +1 -1
- package/dist/chat/agent-invocations/errors.d.ts +8 -0
- package/dist/chat/agent-invocations/spawn.d.ts +12 -0
- package/dist/chat/agent-invocations/store.d.ts +44 -0
- package/dist/chat/agent-invocations/types.d.ts +449 -0
- package/dist/chat/agent-invocations/work.d.ts +31 -0
- package/dist/chat/config.d.ts +1 -0
- package/dist/chat/conversations/sql/store.d.ts +8 -0
- package/dist/chat/conversations/store.d.ts +7 -0
- package/dist/chat/experimental.d.ts +16 -0
- package/dist/chat/runtime/agent-runner.d.ts +2 -1
- package/dist/chat/services/auth-pause.d.ts +0 -1
- package/dist/chat/services/mcp-auth-orchestration.d.ts +3 -2
- package/dist/chat/services/plugin-auth-orchestration.d.ts +3 -2
- package/dist/chat/state/turn-session.d.ts +0 -2
- package/dist/chat/task-execution/state.d.ts +23 -11
- package/dist/chat/task-execution/store.d.ts +20 -11
- package/dist/chat/task-execution/worker.d.ts +2 -2
- package/dist/chat/tools/runtime/spawn-agent.d.ts +31 -0
- package/dist/chat/tools/types.d.ts +2 -0
- package/dist/chunk-3Y47VMHV.js +6 -0
- package/dist/chunk-5IDFPCON.js +46 -0
- package/dist/chunk-5LTJ4ITU.js +1523 -0
- package/dist/{chunk-WPPXIAFB.js → chunk-5MXWHTCK.js} +17 -434
- package/dist/{chunk-UOXATPSI.js → chunk-A7WCHXZV.js} +7 -5
- package/dist/{chunk-5G34IEK2.js → chunk-BOLJOV5T.js} +2 -56
- package/dist/{chunk-UG6ZYPBI.js → chunk-BYW4B4PR.js} +73 -60
- package/dist/{chunk-XZ7NPXAB.js → chunk-C7ZVPO4Z.js} +1 -1
- package/dist/{chunk-RB4NJKEX.js → chunk-DCLLQGS6.js} +119 -50
- package/dist/{chunk-DQXAAVTR.js → chunk-E5UYAIKJ.js} +44 -1467
- package/dist/{chunk-6QW2RRQT.js → chunk-ELKW5FIB.js} +5 -5
- package/dist/chunk-EM225ITJ.js +56 -0
- package/dist/{chunk-SYCX4DOK.js → chunk-FEUNPTGV.js} +7 -60
- package/dist/{chunk-YRPC6MJY.js → chunk-FNLBTB4K.js} +1 -1
- package/dist/chunk-HIWJWWMT.js +668 -0
- package/dist/chunk-IUFM5JWV.js +24 -0
- package/dist/{chunk-T6Z5S6PQ.js → chunk-JNNJZURV.js} +1 -1
- package/dist/{chunk-6ZK6FZIV.js → chunk-KCBZSJRU.js} +6 -27
- package/dist/{chunk-5PNJMOY5.js → chunk-KDCHVT25.js} +1 -1
- package/dist/{chunk-BZAMASJP.js → chunk-KFRHRSCJ.js} +1 -1
- package/dist/chunk-LPVUNO2W.js +320 -0
- package/dist/{chunk-EWDSB24B.js → chunk-N7WARMC6.js} +16 -776
- package/dist/chunk-PB3CXNVL.js +41 -0
- package/dist/chunk-Q6QZTTLS.js +55 -0
- package/dist/{chunk-36EG34YI.js → chunk-QS527AV5.js} +1 -1
- package/dist/chunk-R776HKPK.js +81 -0
- package/dist/{chunk-KJ4HGRHN.js → chunk-RZIBSCYC.js} +507 -596
- package/dist/chunk-SD3OFRWY.js +714 -0
- package/dist/{chunk-ZFS67WIR.js → chunk-SIPKWSXK.js} +57 -6
- package/dist/chunk-TCS76X5D.js +441 -0
- package/dist/{chunk-K2NCQJKH.js → chunk-TDJCLNDH.js} +3 -3
- package/dist/{chunk-POBSY47Q.js → chunk-TUUDXEXU.js} +336 -302
- package/dist/{chunk-YNFERGKP.js → chunk-VPZFVJND.js} +1 -1
- package/dist/{chunk-UZQ4VY3M.js → chunk-YU5QUF67.js} +1 -1
- package/dist/chunk-ZBSMCXKV.js +710 -0
- package/dist/{chunk-3Q342EJJ.js → chunk-ZXNTJJIE.js} +2 -2
- package/dist/cli/chat.js +65 -26
- package/dist/cli/check.js +6 -6
- package/dist/cli/plugins.js +14 -12
- package/dist/cli/snapshot-create.js +10 -9
- package/dist/cli/upgrade.js +7 -7
- package/dist/conversation-work-KATFHLG3.js +56 -0
- package/dist/db/schema/agent-invocations.d.ts +544 -0
- package/dist/db/schema.d.ts +543 -1
- package/dist/{db-66E7VDNC.js → db-UO2IWXGA.js} +7 -7
- package/dist/experimental-HH6OM6UH.js +13 -0
- package/dist/instrumentation.js +4 -4
- package/dist/nitro.js +4 -3
- package/dist/{oauth-callback-server-7QPD4Q7P.js → oauth-callback-server-MAQI43LX.js} +26 -18
- package/dist/{runner-L2BKJKOD.js → runner-PIUQEXKE.js} +26 -14
- package/dist/{skills-HOQ2NSPW.js → skills-4ARJADHQ.js} +6 -6
- package/dist/spawn-G2AWPMCT.js +38 -0
- package/dist/{validation-ENHI7S2C.js → validation-S3EE3HWL.js} +6 -6
- package/dist/version.js +1 -1
- package/dist/work-UARRUAW3.js +46 -0
- package/dist/worker-DOCIRVD3.js +24 -0
- package/migrations/0021_first_warhawk.sql +35 -0
- package/migrations/meta/0021_snapshot.json +2176 -0
- package/migrations/meta/_journal.json +8 -1
- package/package.json +5 -5
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
toCanonicalInputMessage,
|
|
4
4
|
toCanonicalOutputMessage,
|
|
5
5
|
toGenAiMessagesTraceAttributes
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-VPZFVJND.js";
|
|
7
7
|
import {
|
|
8
8
|
extractGenAiUsageAttributes,
|
|
9
9
|
logException,
|
|
@@ -11,65 +11,7 @@ import {
|
|
|
11
11
|
normalizeGenAiFinishReason,
|
|
12
12
|
serializeGenAiAttribute,
|
|
13
13
|
withSpan
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
|
|
16
|
-
// src/chat/config.ts
|
|
17
|
-
import { getModel as getModel2 } from "@earendil-works/pi-ai/compat";
|
|
18
|
-
|
|
19
|
-
// src/chat/optional-string.ts
|
|
20
|
-
function toOptionalTrimmed(value) {
|
|
21
|
-
if (!value) {
|
|
22
|
-
return void 0;
|
|
23
|
-
}
|
|
24
|
-
const trimmed = value.trim();
|
|
25
|
-
return trimmed.length > 0 ? trimmed : void 0;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// src/chat/pi/sdk.ts
|
|
29
|
-
import {
|
|
30
|
-
calculateCost,
|
|
31
|
-
completeSimple,
|
|
32
|
-
getEnvApiKey,
|
|
33
|
-
getModel,
|
|
34
|
-
getModels,
|
|
35
|
-
isRetryableAssistantError,
|
|
36
|
-
registerApiProvider
|
|
37
|
-
} from "@earendil-works/pi-ai/compat";
|
|
38
|
-
import {
|
|
39
|
-
stream,
|
|
40
|
-
streamSimple
|
|
41
|
-
} from "@earendil-works/pi-ai/api/anthropic-messages";
|
|
42
|
-
|
|
43
|
-
// src/chat/pi/client.ts
|
|
44
|
-
import { createGatewayProvider } from "@ai-sdk/gateway";
|
|
45
|
-
|
|
46
|
-
// src/chat/pi/gateway-auth.ts
|
|
47
|
-
import { getVercelOidcToken } from "@vercel/oidc";
|
|
48
|
-
var MISSING_GATEWAY_CREDENTIALS_ERROR = "Missing AI gateway credentials (enable Vercel OIDC or set AI_GATEWAY_API_KEY)";
|
|
49
|
-
async function resolveGatewayCredential() {
|
|
50
|
-
try {
|
|
51
|
-
const oidcToken = toOptionalTrimmed(await getVercelOidcToken());
|
|
52
|
-
if (oidcToken) {
|
|
53
|
-
return { mode: "oidc", token: oidcToken };
|
|
54
|
-
}
|
|
55
|
-
} catch {
|
|
56
|
-
}
|
|
57
|
-
const apiKey = toOptionalTrimmed(getEnvApiKey("vercel-ai-gateway"));
|
|
58
|
-
if (apiKey) {
|
|
59
|
-
return { mode: "api_key", token: apiKey };
|
|
60
|
-
}
|
|
61
|
-
return void 0;
|
|
62
|
-
}
|
|
63
|
-
async function getGatewayApiKey() {
|
|
64
|
-
return (await resolveGatewayCredential())?.token;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// src/chat/pi/client.ts
|
|
68
|
-
import {
|
|
69
|
-
embedMany,
|
|
70
|
-
generateObject,
|
|
71
|
-
NoObjectGeneratedError
|
|
72
|
-
} from "ai";
|
|
14
|
+
} from "./chunk-JNNJZURV.js";
|
|
73
15
|
|
|
74
16
|
// src/chat/services/provider-error.ts
|
|
75
17
|
var ProviderError = class extends Error {
|
|
@@ -253,6 +195,64 @@ function getProviderErrorAttributes(error) {
|
|
|
253
195
|
};
|
|
254
196
|
}
|
|
255
197
|
|
|
198
|
+
// src/chat/config.ts
|
|
199
|
+
import { getModel as getModel2 } from "@earendil-works/pi-ai/compat";
|
|
200
|
+
|
|
201
|
+
// src/chat/optional-string.ts
|
|
202
|
+
function toOptionalTrimmed(value) {
|
|
203
|
+
if (!value) {
|
|
204
|
+
return void 0;
|
|
205
|
+
}
|
|
206
|
+
const trimmed = value.trim();
|
|
207
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// src/chat/pi/sdk.ts
|
|
211
|
+
import {
|
|
212
|
+
calculateCost,
|
|
213
|
+
completeSimple,
|
|
214
|
+
getEnvApiKey,
|
|
215
|
+
getModel,
|
|
216
|
+
getModels,
|
|
217
|
+
isRetryableAssistantError,
|
|
218
|
+
registerApiProvider
|
|
219
|
+
} from "@earendil-works/pi-ai/compat";
|
|
220
|
+
import {
|
|
221
|
+
stream,
|
|
222
|
+
streamSimple
|
|
223
|
+
} from "@earendil-works/pi-ai/api/anthropic-messages";
|
|
224
|
+
|
|
225
|
+
// src/chat/pi/client.ts
|
|
226
|
+
import { createGatewayProvider } from "@ai-sdk/gateway";
|
|
227
|
+
|
|
228
|
+
// src/chat/pi/gateway-auth.ts
|
|
229
|
+
import { getVercelOidcToken } from "@vercel/oidc";
|
|
230
|
+
var MISSING_GATEWAY_CREDENTIALS_ERROR = "Missing AI gateway credentials (enable Vercel OIDC or set AI_GATEWAY_API_KEY)";
|
|
231
|
+
async function resolveGatewayCredential() {
|
|
232
|
+
try {
|
|
233
|
+
const oidcToken = toOptionalTrimmed(await getVercelOidcToken());
|
|
234
|
+
if (oidcToken) {
|
|
235
|
+
return { mode: "oidc", token: oidcToken };
|
|
236
|
+
}
|
|
237
|
+
} catch {
|
|
238
|
+
}
|
|
239
|
+
const apiKey = toOptionalTrimmed(getEnvApiKey("vercel-ai-gateway"));
|
|
240
|
+
if (apiKey) {
|
|
241
|
+
return { mode: "api_key", token: apiKey };
|
|
242
|
+
}
|
|
243
|
+
return void 0;
|
|
244
|
+
}
|
|
245
|
+
async function getGatewayApiKey() {
|
|
246
|
+
return (await resolveGatewayCredential())?.token;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// src/chat/pi/client.ts
|
|
250
|
+
import {
|
|
251
|
+
embedMany,
|
|
252
|
+
generateObject,
|
|
253
|
+
NoObjectGeneratedError
|
|
254
|
+
} from "ai";
|
|
255
|
+
|
|
256
256
|
// src/chat/xml.ts
|
|
257
257
|
function escapeXml(value) {
|
|
258
258
|
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
@@ -779,6 +779,16 @@ function parseSlashCommand(rawValue) {
|
|
|
779
779
|
}
|
|
780
780
|
return command;
|
|
781
781
|
}
|
|
782
|
+
function parseConversationWorkEnabled(rawValue) {
|
|
783
|
+
const value = toOptionalTrimmed(rawValue)?.toLowerCase();
|
|
784
|
+
if (value === void 0 || value === "true") {
|
|
785
|
+
return true;
|
|
786
|
+
}
|
|
787
|
+
if (value === "false") {
|
|
788
|
+
return false;
|
|
789
|
+
}
|
|
790
|
+
throw new Error("JUNIOR_CONVERSATION_WORK_ENABLED must be true or false");
|
|
791
|
+
}
|
|
782
792
|
function parseCrossActorMidRunMode(rawValue) {
|
|
783
793
|
const value = toOptionalTrimmed(rawValue) ?? "follow_up";
|
|
784
794
|
if (value === "follow_up" || value === "steer") {
|
|
@@ -949,6 +959,9 @@ function readChatConfig(env = process.env, functionMaxDurationSeconds = DEFAULT_
|
|
|
949
959
|
return {
|
|
950
960
|
bot: readBotConfig(env, resolvedFunctionMaxDurationSeconds),
|
|
951
961
|
functionMaxDurationSeconds: resolvedFunctionMaxDurationSeconds,
|
|
962
|
+
conversationWorkEnabled: parseConversationWorkEnabled(
|
|
963
|
+
env.JUNIOR_CONVERSATION_WORK_ENABLED
|
|
964
|
+
),
|
|
952
965
|
conversationWorkSoftYieldAfterMs: resolveConversationWorkSoftYieldAfterMs(
|
|
953
966
|
resolvedFunctionMaxDurationSeconds
|
|
954
967
|
),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DEFAULT_SQL_STATEMENT_TIMEOUT_MS
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-BYW4B4PR.js";
|
|
4
4
|
import {
|
|
5
5
|
juniorDestinations,
|
|
6
6
|
timestamptz
|
|
@@ -305,25 +305,89 @@ var juniorConversationBindings = pgTable7(
|
|
|
305
305
|
]
|
|
306
306
|
);
|
|
307
307
|
|
|
308
|
+
// src/db/schema/agent-invocations.ts
|
|
309
|
+
import {
|
|
310
|
+
index as index6,
|
|
311
|
+
jsonb as jsonb5,
|
|
312
|
+
pgTable as pgTable8,
|
|
313
|
+
primaryKey as primaryKey4,
|
|
314
|
+
text as text8,
|
|
315
|
+
uniqueIndex as uniqueIndex5
|
|
316
|
+
} from "drizzle-orm/pg-core";
|
|
317
|
+
var AGENT_INVOCATION_MAILBOX_STATUSES = [
|
|
318
|
+
"pending",
|
|
319
|
+
"appended"
|
|
320
|
+
];
|
|
321
|
+
var juniorAgentBindings = pgTable8(
|
|
322
|
+
"junior_agent_bindings",
|
|
323
|
+
{
|
|
324
|
+
parentConversationId: text8("parent_conversation_id").notNull().references(() => juniorConversations.conversationId),
|
|
325
|
+
name: text8("name").notNull(),
|
|
326
|
+
childConversationId: text8("child_conversation_id").notNull().references(() => juniorConversations.conversationId)
|
|
327
|
+
},
|
|
328
|
+
(table) => [
|
|
329
|
+
primaryKey4({
|
|
330
|
+
columns: [table.parentConversationId, table.name]
|
|
331
|
+
}),
|
|
332
|
+
uniqueIndex5("junior_agent_bindings_child_idx").on(
|
|
333
|
+
table.childConversationId
|
|
334
|
+
)
|
|
335
|
+
]
|
|
336
|
+
);
|
|
337
|
+
var juniorAgentInvocations = pgTable8(
|
|
338
|
+
"junior_agent_invocations",
|
|
339
|
+
{
|
|
340
|
+
invocationId: text8("invocation_id").primaryKey(),
|
|
341
|
+
parentConversationId: text8("parent_conversation_id").notNull().references(() => juniorConversations.conversationId),
|
|
342
|
+
childConversationId: text8("child_conversation_id").notNull().references(() => juniorConversations.conversationId),
|
|
343
|
+
agentName: text8("agent_name"),
|
|
344
|
+
input: text8("input").notNull(),
|
|
345
|
+
actor: jsonb5("actor_json").$type().notNull(),
|
|
346
|
+
credentialContext: jsonb5(
|
|
347
|
+
"credential_context_json"
|
|
348
|
+
).$type(),
|
|
349
|
+
source: jsonb5("source_json").$type().notNull(),
|
|
350
|
+
destination: jsonb5("destination_json").$type().notNull(),
|
|
351
|
+
destinationVisibility: text8(
|
|
352
|
+
"destination_visibility"
|
|
353
|
+
).$type(),
|
|
354
|
+
reasoningLevel: text8("reasoning_level").$type(),
|
|
355
|
+
status: text8("status").$type().notNull(),
|
|
356
|
+
mailboxStatus: text8("mailbox_status").$type().notNull(),
|
|
357
|
+
result: text8("result"),
|
|
358
|
+
errorMessage: text8("error_message"),
|
|
359
|
+
createdAt: timestamptz("created_at").notNull(),
|
|
360
|
+
updatedAt: timestamptz("updated_at").notNull(),
|
|
361
|
+
terminalAt: timestamptz("terminal_at")
|
|
362
|
+
},
|
|
363
|
+
(table) => [
|
|
364
|
+
index6("junior_agent_invocations_child_idx").on(table.childConversationId),
|
|
365
|
+
index6("junior_agent_invocations_mailbox_idx").on(
|
|
366
|
+
table.mailboxStatus,
|
|
367
|
+
table.createdAt
|
|
368
|
+
)
|
|
369
|
+
]
|
|
370
|
+
);
|
|
371
|
+
|
|
308
372
|
// src/db/schema/event-tasks.ts
|
|
309
|
-
import { bigint, index as
|
|
310
|
-
var juniorEventTasks =
|
|
373
|
+
import { bigint, index as index7, jsonb as jsonb6, pgTable as pgTable9, text as text9 } from "drizzle-orm/pg-core";
|
|
374
|
+
var juniorEventTasks = pgTable9(
|
|
311
375
|
"junior_event_tasks",
|
|
312
376
|
{
|
|
313
|
-
id:
|
|
314
|
-
teamId:
|
|
315
|
-
namespace:
|
|
316
|
-
identifier:
|
|
377
|
+
id: text9("id").primaryKey(),
|
|
378
|
+
teamId: text9("team_id").notNull(),
|
|
379
|
+
namespace: text9("namespace").notNull(),
|
|
380
|
+
identifier: text9("identifier").notNull(),
|
|
317
381
|
createdAtMs: bigint("created_at_ms", { mode: "number" }).notNull(),
|
|
318
|
-
task:
|
|
382
|
+
task: jsonb6("task_json").$type().notNull()
|
|
319
383
|
},
|
|
320
384
|
(table) => [
|
|
321
|
-
|
|
385
|
+
index7("junior_event_tasks_team_idx").on(
|
|
322
386
|
table.teamId,
|
|
323
387
|
table.createdAtMs,
|
|
324
388
|
table.id
|
|
325
389
|
),
|
|
326
|
-
|
|
390
|
+
index7("junior_event_tasks_match_idx").on(
|
|
327
391
|
table.namespace,
|
|
328
392
|
table.identifier,
|
|
329
393
|
table.createdAtMs,
|
|
@@ -333,18 +397,18 @@ var juniorEventTasks = pgTable8(
|
|
|
333
397
|
);
|
|
334
398
|
|
|
335
399
|
// src/db/schema/stats.ts
|
|
336
|
-
import { date, integer as integer3, pgTable as
|
|
337
|
-
var juniorStats =
|
|
400
|
+
import { date, integer as integer3, pgTable as pgTable10, primaryKey as primaryKey5, text as text10 } from "drizzle-orm/pg-core";
|
|
401
|
+
var juniorStats = pgTable10(
|
|
338
402
|
"junior_stats",
|
|
339
403
|
{
|
|
340
404
|
date: date("date", { mode: "string" }).notNull(),
|
|
341
|
-
namespace:
|
|
342
|
-
metric:
|
|
343
|
-
name:
|
|
405
|
+
namespace: text10("namespace").notNull(),
|
|
406
|
+
metric: text10("metric").notNull(),
|
|
407
|
+
name: text10("name").notNull(),
|
|
344
408
|
count: integer3("count").notNull().default(0)
|
|
345
409
|
},
|
|
346
410
|
(table) => [
|
|
347
|
-
|
|
411
|
+
primaryKey5({
|
|
348
412
|
name: "junior_stats_date_namespace_metric_name_pk",
|
|
349
413
|
columns: [table.date, table.namespace, table.metric, table.name]
|
|
350
414
|
})
|
|
@@ -357,19 +421,19 @@ import {
|
|
|
357
421
|
bigint as bigint2,
|
|
358
422
|
check,
|
|
359
423
|
foreignKey as foreignKey3,
|
|
360
|
-
index as
|
|
361
|
-
pgTable as
|
|
362
|
-
primaryKey as
|
|
363
|
-
text as
|
|
424
|
+
index as index8,
|
|
425
|
+
pgTable as pgTable11,
|
|
426
|
+
primaryKey as primaryKey6,
|
|
427
|
+
text as text11
|
|
364
428
|
} from "drizzle-orm/pg-core";
|
|
365
|
-
var juniorTaskExecutions =
|
|
429
|
+
var juniorTaskExecutions = pgTable11(
|
|
366
430
|
"junior_task_executions",
|
|
367
431
|
{
|
|
368
|
-
executionId:
|
|
369
|
-
kind:
|
|
370
|
-
namespace:
|
|
371
|
-
taskId:
|
|
372
|
-
conversationId:
|
|
432
|
+
executionId: text11("execution_id").notNull(),
|
|
433
|
+
kind: text11("kind").notNull(),
|
|
434
|
+
namespace: text11("namespace").notNull(),
|
|
435
|
+
taskId: text11("task_id").notNull(),
|
|
436
|
+
conversationId: text11("conversation_id").notNull(),
|
|
373
437
|
executedAtMs: bigint2("executed_at_ms", { mode: "number" }).notNull()
|
|
374
438
|
},
|
|
375
439
|
(table) => [
|
|
@@ -377,7 +441,7 @@ var juniorTaskExecutions = pgTable10(
|
|
|
377
441
|
"junior_task_executions_kind_check",
|
|
378
442
|
sql4`${table.kind} in ('scheduled', 'event')`
|
|
379
443
|
),
|
|
380
|
-
|
|
444
|
+
primaryKey6({
|
|
381
445
|
name: "junior_task_executions_kind_namespace_execution_id_pk",
|
|
382
446
|
columns: [table.kind, table.namespace, table.executionId]
|
|
383
447
|
}),
|
|
@@ -386,17 +450,17 @@ var juniorTaskExecutions = pgTable10(
|
|
|
386
450
|
columns: [table.conversationId],
|
|
387
451
|
foreignColumns: [juniorConversations.conversationId]
|
|
388
452
|
}),
|
|
389
|
-
|
|
453
|
+
index8("junior_task_executions_task_time_idx").on(
|
|
390
454
|
table.kind,
|
|
391
455
|
table.namespace,
|
|
392
456
|
table.taskId,
|
|
393
457
|
table.executedAtMs
|
|
394
458
|
),
|
|
395
|
-
|
|
459
|
+
index8("junior_task_executions_time_kind_idx").on(
|
|
396
460
|
table.executedAtMs,
|
|
397
461
|
table.kind
|
|
398
462
|
),
|
|
399
|
-
|
|
463
|
+
index8("junior_task_executions_conversation_time_idx").on(
|
|
400
464
|
table.conversationId,
|
|
401
465
|
table.executedAtMs
|
|
402
466
|
)
|
|
@@ -405,52 +469,52 @@ var juniorTaskExecutions = pgTable10(
|
|
|
405
469
|
|
|
406
470
|
// src/db/schema/scheduled-tasks.ts
|
|
407
471
|
import { sql as sql5 } from "drizzle-orm";
|
|
408
|
-
import { bigint as bigint3, index as
|
|
409
|
-
var juniorSchedulerTasks =
|
|
472
|
+
import { bigint as bigint3, index as index9, jsonb as jsonb7, pgTable as pgTable12, text as text12 } from "drizzle-orm/pg-core";
|
|
473
|
+
var juniorSchedulerTasks = pgTable12(
|
|
410
474
|
"junior_scheduler_tasks",
|
|
411
475
|
{
|
|
412
|
-
id:
|
|
413
|
-
teamId:
|
|
476
|
+
id: text12("id").primaryKey(),
|
|
477
|
+
teamId: text12("team_id").notNull(),
|
|
414
478
|
// TODO(v0.128.0): Remove after v0.127.x runtimes no longer write this column.
|
|
415
|
-
creatorSlackUserId:
|
|
416
|
-
creatorIdentityId:
|
|
417
|
-
status:
|
|
479
|
+
creatorSlackUserId: text12("creator_slack_user_id"),
|
|
480
|
+
creatorIdentityId: text12("creator_identity_id"),
|
|
481
|
+
status: text12("status").notNull(),
|
|
418
482
|
nextRunAtMs: bigint3("next_run_at_ms", { mode: "number" }),
|
|
419
483
|
runNowAtMs: bigint3("run_now_at_ms", { mode: "number" }),
|
|
420
484
|
createdAtMs: bigint3("created_at_ms", { mode: "number" }).notNull(),
|
|
421
|
-
record:
|
|
485
|
+
record: jsonb7("record").$type().notNull()
|
|
422
486
|
},
|
|
423
487
|
(table) => [
|
|
424
488
|
// TODO(v0.128.0): Remove with creatorSlackUserId.
|
|
425
|
-
|
|
426
|
-
|
|
489
|
+
index9("junior_scheduler_tasks_creator_idx").on(table.teamId, table.creatorSlackUserId, table.createdAtMs, table.id).where(sql5`${table.status} <> 'deleted'`),
|
|
490
|
+
index9("junior_scheduler_tasks_creator_identity_idx").on(table.creatorIdentityId, table.createdAtMs, table.id).where(
|
|
427
491
|
sql5`${table.status} <> 'deleted' AND ${table.creatorIdentityId} IS NOT NULL`
|
|
428
492
|
),
|
|
429
|
-
|
|
430
|
-
|
|
493
|
+
index9("junior_scheduler_tasks_team_status_idx").on(table.teamId, table.createdAtMs, table.id).where(sql5`${table.status} <> 'deleted'`),
|
|
494
|
+
index9("junior_scheduler_tasks_run_now_due_idx").on(table.runNowAtMs, table.createdAtMs, table.id).where(
|
|
431
495
|
sql5`${table.status} = 'active' AND ${table.runNowAtMs} IS NOT NULL`
|
|
432
496
|
),
|
|
433
|
-
|
|
497
|
+
index9("junior_scheduler_tasks_next_run_due_idx").on(table.nextRunAtMs, table.createdAtMs, table.id).where(
|
|
434
498
|
sql5`${table.status} = 'active' AND ${table.nextRunAtMs} IS NOT NULL`
|
|
435
499
|
)
|
|
436
500
|
]
|
|
437
501
|
);
|
|
438
|
-
var juniorSchedulerRuns =
|
|
502
|
+
var juniorSchedulerRuns = pgTable12(
|
|
439
503
|
"junior_scheduler_runs",
|
|
440
504
|
{
|
|
441
|
-
id:
|
|
442
|
-
taskId:
|
|
443
|
-
status:
|
|
505
|
+
id: text12("id").primaryKey(),
|
|
506
|
+
taskId: text12("task_id").notNull(),
|
|
507
|
+
status: text12("status").notNull(),
|
|
444
508
|
scheduledForMs: bigint3("scheduled_for_ms", { mode: "number" }).notNull(),
|
|
445
|
-
record:
|
|
509
|
+
record: jsonb7("record").$type().notNull()
|
|
446
510
|
},
|
|
447
511
|
(table) => [
|
|
448
|
-
|
|
512
|
+
index9("junior_scheduler_runs_task_status_idx").on(
|
|
449
513
|
table.taskId,
|
|
450
514
|
table.status,
|
|
451
515
|
table.scheduledForMs
|
|
452
516
|
),
|
|
453
|
-
|
|
517
|
+
index9("junior_scheduler_runs_status_idx").on(
|
|
454
518
|
table.status,
|
|
455
519
|
table.scheduledForMs
|
|
456
520
|
)
|
|
@@ -461,6 +525,8 @@ var juniorSchedulerRuns = pgTable11(
|
|
|
461
525
|
var juniorSqlSchema = {
|
|
462
526
|
juniorConversationAnnotations,
|
|
463
527
|
juniorApiTokens,
|
|
528
|
+
juniorAgentBindings,
|
|
529
|
+
juniorAgentInvocations,
|
|
464
530
|
juniorConversationEvents,
|
|
465
531
|
juniorConversationBindings,
|
|
466
532
|
juniorConversations,
|
|
@@ -731,6 +797,9 @@ export {
|
|
|
731
797
|
juniorApiTokens,
|
|
732
798
|
juniorConversationEvents,
|
|
733
799
|
juniorConversationBindings,
|
|
800
|
+
AGENT_INVOCATION_MAILBOX_STATUSES,
|
|
801
|
+
juniorAgentBindings,
|
|
802
|
+
juniorAgentInvocations,
|
|
734
803
|
juniorEventTasks,
|
|
735
804
|
juniorStats,
|
|
736
805
|
juniorTaskExecutions,
|