@sentry/junior 0.132.0 → 0.134.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-ONXOJDR6.js → agent-hooks-HGXNYOOD.js} +9 -9
- package/dist/api/schema/task.d.ts +60 -0
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +3 -1
- package/dist/api.js +90 -20
- package/dist/app.js +110 -39
- package/dist/{catalog-runtime-BATAY4R7.js → catalog-runtime-P6QHU6XE.js} +5 -5
- package/dist/chat/agent/prompt.d.ts +7 -5
- package/dist/chat/agent/repository-context.d.ts +20 -0
- package/dist/chat/agent/sandbox.d.ts +8 -0
- package/dist/chat/agent/tools.d.ts +3 -0
- package/dist/chat/config.d.ts +2 -0
- package/dist/chat/conversations/projection.d.ts +3 -1
- package/dist/chat/conversations/sql/bindings.d.ts +13 -0
- package/dist/chat/conversations/sql/store.d.ts +3 -0
- package/dist/chat/conversations/store.d.ts +15 -0
- package/dist/chat/plugins/agent-hooks.d.ts +2 -2
- package/dist/chat/repository-instructions.d.ts +44 -0
- package/dist/chat/runtime/reply-executor.d.ts +1 -0
- package/dist/chat/runtime/slack-runtime.d.ts +2 -0
- package/dist/chat/sandbox/noninteractive-command.d.ts +2 -0
- package/dist/chat/sandbox/sandbox.d.ts +3 -0
- package/dist/chat/sandbox/session.d.ts +1 -0
- package/dist/chat/services/context-compaction.d.ts +1 -0
- package/dist/chat/slack/dispatch-turn.d.ts +1 -0
- package/dist/chat/slack/reply.d.ts +1 -1
- package/dist/chat/slack/tools/user-lookup.d.ts +2 -6
- package/dist/chat/tasks/execution-stats.d.ts +29 -0
- package/dist/chat/tasks/registered.d.ts +3 -0
- package/dist/chat/tools/index.d.ts +2 -0
- package/dist/chat/tools/sandbox/bash.d.ts +1 -0
- package/dist/chat/tools/system-time.d.ts +11 -1
- package/dist/{chunk-O2UXPUVQ.js → chunk-52DIKFJV.js} +14 -6
- package/dist/{chunk-GOEZU33G.js → chunk-6T3AYZT7.js} +1 -1
- package/dist/{chunk-GPXVDJML.js → chunk-7GKQ7UIO.js} +449 -39
- package/dist/{chunk-QVEXYYFM.js → chunk-7UTBPDXK.js} +24 -1
- package/dist/{chunk-U76PS7AT.js → chunk-AS3I7OIL.js} +2 -2
- package/dist/{chunk-HX236W2U.js → chunk-CDQ4YIZM.js} +9 -0
- package/dist/{chunk-ODIP5CEM.js → chunk-FDNAUM7X.js} +32 -32
- package/dist/{chunk-GTKNPQNN.js → chunk-FL466XX5.js} +36 -24
- package/dist/{chunk-2425Q4OR.js → chunk-GSP5SMZJ.js} +1 -1
- package/dist/{chunk-XN656LB4.js → chunk-KWGJG4HO.js} +6 -12
- package/dist/{chunk-ISNRPCPG.js → chunk-LKK4XMUV.js} +1 -1
- package/dist/{chunk-G3WYA2RS.js → chunk-MFERLE3G.js} +1 -1
- package/dist/{chunk-ZMV2YBT6.js → chunk-NF2TNZPD.js} +788 -674
- package/dist/chunk-NOA34AJY.js +122 -0
- package/dist/{chunk-JYQAE2ZU.js → chunk-NYWSCJVW.js} +1 -1
- package/dist/{chunk-KB2M27DL.js → chunk-QLEKAO7O.js} +130 -40
- package/dist/{chunk-BKE47OOW.js → chunk-S6DMTEOM.js} +2 -2
- package/dist/{chunk-ALDPUN3Z.js → chunk-TR6UEEYD.js} +8 -6
- package/dist/{chunk-WEJIS7OC.js → chunk-U3ZI7CCW.js} +1 -1
- package/dist/{chunk-B7IY6SVJ.js → chunk-VEGF62FV.js} +1 -1
- package/dist/{chunk-SKWIIUS7.js → chunk-VGXJMECA.js} +7 -7
- package/dist/{chunk-V44FFBO3.js → chunk-VP6NCPRS.js} +1 -1
- package/dist/{chunk-WYQP7QSB.js → chunk-VPYKNCTN.js} +101 -61
- package/dist/{chunk-NNHUGGO4.js → chunk-XG5PHKPM.js} +19 -3
- package/dist/{chunk-AW5Z3T7V.js → chunk-YNLQQ622.js} +9 -8
- package/dist/cli/chat.js +25 -25
- package/dist/cli/check.js +6 -6
- package/dist/cli/init.js +1 -1
- package/dist/cli/plugins.js +12 -12
- package/dist/cli/snapshot-create.js +9 -9
- package/dist/cli/upgrade.js +9 -8
- package/dist/db/executor.d.ts +2 -1
- package/dist/db/neon.d.ts +1 -0
- package/dist/db/postgres.d.ts +1 -0
- package/dist/db/schema/conversation-bindings.d.ts +110 -0
- package/dist/db/schema/task-executions.d.ts +110 -0
- package/dist/db/schema.d.ts +221 -1
- package/dist/{db-QFFZACXF.js → db-GFK4NHWJ.js} +7 -7
- package/dist/instrumentation.js +4 -4
- package/dist/nitro.js +2 -2
- package/dist/{oauth-callback-server-5WXLD533.js → oauth-callback-server-HUJLAQ5N.js} +19 -18
- package/dist/{runner-Y3LTUNAA.js → runner-T77AFAH4.js} +13 -12
- package/dist/{skills-7M5C24GM.js → skills-3KUFJOOR.js} +6 -6
- package/dist/{validation-MRILMYDI.js → validation-FMWDHKYU.js} +6 -6
- package/dist/version.js +1 -1
- package/migrations/0018_curvy_excalibur.sql +12 -0
- package/migrations/0019_lowly_valkyrie.sql +14 -0
- package/migrations/meta/0018_snapshot.json +1756 -0
- package/migrations/meta/0019_snapshot.json +1904 -0
- package/migrations/meta/_journal.json +15 -1
- package/package.json +5 -5
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createJuniorSqlExecutor,
|
|
3
|
+
juniorConversationBindings,
|
|
3
4
|
juniorConversationEvents,
|
|
4
5
|
juniorConversations,
|
|
5
6
|
juniorIdentities,
|
|
6
7
|
juniorUsers
|
|
7
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-QLEKAO7O.js";
|
|
8
9
|
import {
|
|
9
10
|
TURN_REASONING_LEVELS,
|
|
10
11
|
getChatConfig,
|
|
11
12
|
modelProfileSchema
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-XG5PHKPM.js";
|
|
13
14
|
import {
|
|
14
15
|
juniorDestinations
|
|
15
16
|
} from "./chunk-VFUK3X5B.js";
|
|
@@ -19,11 +20,11 @@ import {
|
|
|
19
20
|
} from "./chunk-F3B2YJ76.js";
|
|
20
21
|
import {
|
|
21
22
|
normalizeIdentityEmail
|
|
22
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-6T3AYZT7.js";
|
|
23
24
|
|
|
24
25
|
// src/chat/conversations/sql/store.ts
|
|
25
26
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
26
|
-
import { and as
|
|
27
|
+
import { and as and3, asc, desc, eq as eq3, isNull, sql as sql2 } from "drizzle-orm";
|
|
27
28
|
|
|
28
29
|
// src/chat/destination.ts
|
|
29
30
|
import {
|
|
@@ -197,6 +198,35 @@ function parseSessionSource(value) {
|
|
|
197
198
|
return parsed.success ? normalizeSessionSource(parsed.data) : void 0;
|
|
198
199
|
}
|
|
199
200
|
|
|
201
|
+
// src/chat/conversations/sql/bindings.ts
|
|
202
|
+
import { and as and2, eq as eq2 } from "drizzle-orm";
|
|
203
|
+
async function getConversationIdByProviderConversation(executor, args) {
|
|
204
|
+
const rows = await executor.db().select({ conversationId: juniorConversationBindings.conversationId }).from(juniorConversationBindings).where(
|
|
205
|
+
and2(
|
|
206
|
+
eq2(juniorConversationBindings.provider, args.provider),
|
|
207
|
+
eq2(juniorConversationBindings.providerTenantId, args.providerTenantId),
|
|
208
|
+
eq2(
|
|
209
|
+
juniorConversationBindings.providerDestinationId,
|
|
210
|
+
args.providerDestinationId
|
|
211
|
+
),
|
|
212
|
+
eq2(
|
|
213
|
+
juniorConversationBindings.providerConversationId,
|
|
214
|
+
args.providerConversationId
|
|
215
|
+
)
|
|
216
|
+
)
|
|
217
|
+
).limit(1);
|
|
218
|
+
return rows[0]?.conversationId;
|
|
219
|
+
}
|
|
220
|
+
async function bindProviderConversation(executor, args) {
|
|
221
|
+
const rows = await executor.db().insert(juniorConversationBindings).values({ ...args, createdAt: /* @__PURE__ */ new Date() }).onConflictDoNothing().returning({ conversationId: juniorConversationBindings.conversationId });
|
|
222
|
+
const boundConversationId = rows[0]?.conversationId ?? await getConversationIdByProviderConversation(executor, args);
|
|
223
|
+
if (boundConversationId !== args.conversationId) {
|
|
224
|
+
throw new Error(
|
|
225
|
+
"Provider conversation is already bound to another conversation"
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
200
230
|
// src/chat/conversations/location.ts
|
|
201
231
|
import { nonBlankStringSchema } from "@sentry/junior-plugin-api";
|
|
202
232
|
import { z } from "zod";
|
|
@@ -516,6 +546,12 @@ var SqlStore = class {
|
|
|
516
546
|
this.executor = executor;
|
|
517
547
|
}
|
|
518
548
|
executor;
|
|
549
|
+
async getConversationIdByProviderConversation(args) {
|
|
550
|
+
return await getConversationIdByProviderConversation(this.executor, args);
|
|
551
|
+
}
|
|
552
|
+
async bindProviderConversation(args) {
|
|
553
|
+
await bindProviderConversation(this.executor, args);
|
|
554
|
+
}
|
|
519
555
|
async get(args) {
|
|
520
556
|
const row = await this.readConversationRow(args.conversationId);
|
|
521
557
|
if (!row) {
|
|
@@ -609,7 +645,7 @@ var SqlStore = class {
|
|
|
609
645
|
metricRunId: args.execution.runId ?? null,
|
|
610
646
|
executionDurationMs: args.metrics.durationMs,
|
|
611
647
|
executionUsage: args.metrics.usage ?? (sameRun ? row?.executionUsage ?? null : null)
|
|
612
|
-
}).where(
|
|
648
|
+
}).where(eq3(juniorConversations.conversationId, args.conversationId));
|
|
613
649
|
}
|
|
614
650
|
});
|
|
615
651
|
}
|
|
@@ -621,11 +657,11 @@ var SqlStore = class {
|
|
|
621
657
|
actorUserDisplayName: juniorUsers.displayName
|
|
622
658
|
}).from(juniorConversations).leftJoin(
|
|
623
659
|
juniorDestinations,
|
|
624
|
-
|
|
660
|
+
eq3(juniorDestinations.id, juniorConversations.destinationId)
|
|
625
661
|
).leftJoin(
|
|
626
662
|
juniorIdentities,
|
|
627
|
-
|
|
628
|
-
).leftJoin(juniorUsers,
|
|
663
|
+
eq3(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
664
|
+
).leftJoin(juniorUsers, eq3(juniorUsers.id, juniorIdentities.userId)).where(isNull(juniorConversations.parentConversationId)).orderBy(
|
|
629
665
|
desc(juniorConversations.lastActivityAt),
|
|
630
666
|
asc(juniorConversations.conversationId)
|
|
631
667
|
).limit(Math.max(0, args.limit ?? 1e4)).offset(Math.max(0, args.offset ?? 0));
|
|
@@ -639,13 +675,13 @@ var SqlStore = class {
|
|
|
639
675
|
const rows = await this.executor.db().select({
|
|
640
676
|
visibility: juniorDestinations.visibility
|
|
641
677
|
}).from(juniorDestinations).where(
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
678
|
+
and3(
|
|
679
|
+
eq3(juniorDestinations.provider, args.provider),
|
|
680
|
+
eq3(
|
|
645
681
|
juniorDestinations.providerTenantId,
|
|
646
682
|
tenantId2(args.providerTenantId)
|
|
647
683
|
),
|
|
648
|
-
|
|
684
|
+
eq3(
|
|
649
685
|
juniorDestinations.providerDestinationId,
|
|
650
686
|
args.providerDestinationId
|
|
651
687
|
)
|
|
@@ -675,11 +711,11 @@ var SqlStore = class {
|
|
|
675
711
|
actorUserDisplayName: juniorUsers.displayName
|
|
676
712
|
}).from(juniorConversations).leftJoin(
|
|
677
713
|
juniorDestinations,
|
|
678
|
-
|
|
714
|
+
eq3(juniorDestinations.id, juniorConversations.destinationId)
|
|
679
715
|
).leftJoin(
|
|
680
716
|
juniorIdentities,
|
|
681
|
-
|
|
682
|
-
).leftJoin(juniorUsers,
|
|
717
|
+
eq3(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
718
|
+
).leftJoin(juniorUsers, eq3(juniorUsers.id, juniorIdentities.userId)).where(eq3(juniorConversations.conversationId, conversationId));
|
|
683
719
|
return rows[0];
|
|
684
720
|
}
|
|
685
721
|
/** Upsert the conversation row while preserving previously discovered nullable metadata fields. */
|
|
@@ -808,10 +844,10 @@ function createSqlStore(executor) {
|
|
|
808
844
|
|
|
809
845
|
// src/chat/conversations/sql/history.ts
|
|
810
846
|
import {
|
|
811
|
-
and as
|
|
847
|
+
and as and4,
|
|
812
848
|
asc as asc2,
|
|
813
849
|
desc as desc2,
|
|
814
|
-
eq as
|
|
850
|
+
eq as eq4,
|
|
815
851
|
gt,
|
|
816
852
|
gte,
|
|
817
853
|
inArray,
|
|
@@ -1287,8 +1323,8 @@ var SqlConversationEventStore = class {
|
|
|
1287
1323
|
const existingKeys = parsed.map((event) => event.idempotencyKey).filter((key) => key !== void 0);
|
|
1288
1324
|
const persistedKeys = existingKeys.length === 0 ? /* @__PURE__ */ new Set() : new Set(
|
|
1289
1325
|
(await this.executor.db().select({ key: juniorConversationEvents.idempotencyKey }).from(juniorConversationEvents).where(
|
|
1290
|
-
|
|
1291
|
-
|
|
1326
|
+
and4(
|
|
1327
|
+
eq4(
|
|
1292
1328
|
juniorConversationEvents.conversationId,
|
|
1293
1329
|
conversationId
|
|
1294
1330
|
),
|
|
@@ -1320,8 +1356,8 @@ var SqlConversationEventStore = class {
|
|
|
1320
1356
|
);
|
|
1321
1357
|
if (options.activity !== "preserve") {
|
|
1322
1358
|
await this.executor.db().update(juniorConversations).set({ archivedAt: null }).where(
|
|
1323
|
-
|
|
1324
|
-
|
|
1359
|
+
and4(
|
|
1360
|
+
eq4(juniorConversations.conversationId, conversationId),
|
|
1325
1361
|
isNotNull(juniorConversations.archivedAt)
|
|
1326
1362
|
)
|
|
1327
1363
|
);
|
|
@@ -1340,8 +1376,8 @@ var SqlConversationEventStore = class {
|
|
|
1340
1376
|
await withConversationEventLock(this.executor, conversationId, async () => {
|
|
1341
1377
|
await ensureConversationRow(this.executor, conversationId, Date.now());
|
|
1342
1378
|
await this.executor.db().update(juniorConversations).set({ archivedAt: null }).where(
|
|
1343
|
-
|
|
1344
|
-
|
|
1379
|
+
and4(
|
|
1380
|
+
eq4(juniorConversations.conversationId, conversationId),
|
|
1345
1381
|
isNotNull(juniorConversations.archivedAt)
|
|
1346
1382
|
)
|
|
1347
1383
|
);
|
|
@@ -1363,34 +1399,34 @@ var SqlConversationEventStore = class {
|
|
|
1363
1399
|
return [];
|
|
1364
1400
|
}
|
|
1365
1401
|
const rows = await this.executor.db().select().from(juniorConversationEvents).where(
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1402
|
+
and4(
|
|
1403
|
+
eq4(juniorConversationEvents.conversationId, conversationId),
|
|
1404
|
+
eq4(juniorConversationEvents.historyVersion, cursor.maxHistoryVersion)
|
|
1369
1405
|
)
|
|
1370
1406
|
).orderBy(asc2(juniorConversationEvents.seq));
|
|
1371
1407
|
return rows.map(eventFromRow);
|
|
1372
1408
|
}
|
|
1373
1409
|
async loadByIdempotencyKey(conversationId, idempotencyKey) {
|
|
1374
1410
|
const [row] = await this.executor.db().select().from(juniorConversationEvents).where(
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1411
|
+
and4(
|
|
1412
|
+
eq4(juniorConversationEvents.conversationId, conversationId),
|
|
1413
|
+
eq4(juniorConversationEvents.idempotencyKey, idempotencyKey)
|
|
1378
1414
|
)
|
|
1379
1415
|
).limit(1);
|
|
1380
1416
|
return row ? eventFromRow(row) : void 0;
|
|
1381
1417
|
}
|
|
1382
1418
|
async loadHistoryContaining(conversationId, seq, throughSeq) {
|
|
1383
1419
|
const [boundary] = await this.executor.db().select({ historyVersion: juniorConversationEvents.historyVersion }).from(juniorConversationEvents).where(
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1420
|
+
and4(
|
|
1421
|
+
eq4(juniorConversationEvents.conversationId, conversationId),
|
|
1422
|
+
eq4(juniorConversationEvents.seq, seq)
|
|
1387
1423
|
)
|
|
1388
1424
|
).limit(1);
|
|
1389
1425
|
if (!boundary) return void 0;
|
|
1390
1426
|
const rows = await this.executor.db().select().from(juniorConversationEvents).where(
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1427
|
+
and4(
|
|
1428
|
+
eq4(juniorConversationEvents.conversationId, conversationId),
|
|
1429
|
+
eq4(juniorConversationEvents.historyVersion, boundary.historyVersion),
|
|
1394
1430
|
throughSeq === void 0 ? void 0 : lte(juniorConversationEvents.seq, throughSeq)
|
|
1395
1431
|
)
|
|
1396
1432
|
).orderBy(asc2(juniorConversationEvents.seq));
|
|
@@ -1398,9 +1434,9 @@ var SqlConversationEventStore = class {
|
|
|
1398
1434
|
}
|
|
1399
1435
|
async loadLatestInstruction(conversationId) {
|
|
1400
1436
|
const [row] = await this.executor.db().select().from(juniorConversationEvents).where(
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1437
|
+
and4(
|
|
1438
|
+
eq4(juniorConversationEvents.conversationId, conversationId),
|
|
1439
|
+
eq4(juniorConversationEvents.type, "user_message"),
|
|
1404
1440
|
sql4`${juniorConversationEvents.payload}->'provenance'->>'authority' = 'instruction'`
|
|
1405
1441
|
)
|
|
1406
1442
|
).orderBy(desc2(juniorConversationEvents.seq)).limit(1);
|
|
@@ -1408,16 +1444,16 @@ var SqlConversationEventStore = class {
|
|
|
1408
1444
|
}
|
|
1409
1445
|
async loadMessageHistory(conversationId) {
|
|
1410
1446
|
const [compactionRow] = await this.executor.db().select().from(juniorConversationEvents).where(
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1447
|
+
and4(
|
|
1448
|
+
eq4(juniorConversationEvents.conversationId, conversationId),
|
|
1449
|
+
eq4(juniorConversationEvents.type, "messages_summarized")
|
|
1414
1450
|
)
|
|
1415
1451
|
).orderBy(desc2(juniorConversationEvents.seq)).limit(1);
|
|
1416
1452
|
const compaction = compactionRow ? messagesSummarizedEventFromRow(compactionRow) : void 0;
|
|
1417
1453
|
const historyFromSeq = compaction?.data.historyFromSeq ?? 0;
|
|
1418
1454
|
const rows = await this.executor.db().select().from(juniorConversationEvents).where(
|
|
1419
|
-
|
|
1420
|
-
|
|
1455
|
+
and4(
|
|
1456
|
+
eq4(juniorConversationEvents.conversationId, conversationId),
|
|
1421
1457
|
inArray(juniorConversationEvents.type, messageHistoryEventTypes),
|
|
1422
1458
|
gte(juniorConversationEvents.seq, historyFromSeq)
|
|
1423
1459
|
)
|
|
@@ -1425,7 +1461,7 @@ var SqlConversationEventStore = class {
|
|
|
1425
1461
|
return { events: rows.map(eventFromRow), compaction, historyFromSeq };
|
|
1426
1462
|
}
|
|
1427
1463
|
async loadHistory(conversationId) {
|
|
1428
|
-
const rows = await this.executor.db().select().from(juniorConversationEvents).where(
|
|
1464
|
+
const rows = await this.executor.db().select().from(juniorConversationEvents).where(eq4(juniorConversationEvents.conversationId, conversationId)).orderBy(asc2(juniorConversationEvents.seq));
|
|
1429
1465
|
return rows.map(eventFromRow);
|
|
1430
1466
|
}
|
|
1431
1467
|
async query(conversationId, query) {
|
|
@@ -1436,8 +1472,8 @@ var SqlConversationEventStore = class {
|
|
|
1436
1472
|
return { events: [], hasOlder: false, hasNewer: false };
|
|
1437
1473
|
}
|
|
1438
1474
|
const typeFilter = query.types && query.types.length > 0 ? inArray(juniorConversationEvents.type, [...query.types]) : void 0;
|
|
1439
|
-
const bounds =
|
|
1440
|
-
|
|
1475
|
+
const bounds = and4(
|
|
1476
|
+
eq4(juniorConversationEvents.conversationId, conversationId),
|
|
1441
1477
|
query.afterSeq === void 0 ? void 0 : gt(juniorConversationEvents.seq, query.afterSeq),
|
|
1442
1478
|
query.beforeSeq === void 0 ? void 0 : lt(juniorConversationEvents.seq, query.beforeSeq),
|
|
1443
1479
|
typeFilter
|
|
@@ -1474,8 +1510,8 @@ var SqlConversationEventStore = class {
|
|
|
1474
1510
|
return false;
|
|
1475
1511
|
}
|
|
1476
1512
|
const [row] = await this.executor.db().select({ seq: juniorConversationEvents.seq }).from(juniorConversationEvents).where(
|
|
1477
|
-
|
|
1478
|
-
|
|
1513
|
+
and4(
|
|
1514
|
+
eq4(juniorConversationEvents.conversationId, args.conversationId),
|
|
1479
1515
|
args.afterSeq === void 0 ? void 0 : gt(juniorConversationEvents.seq, args.afterSeq),
|
|
1480
1516
|
args.beforeSeq === void 0 ? void 0 : lt(juniorConversationEvents.seq, args.beforeSeq),
|
|
1481
1517
|
args.typeFilter
|
|
@@ -1488,7 +1524,7 @@ var SqlConversationEventStore = class {
|
|
|
1488
1524
|
const rows = await this.executor.db().select({
|
|
1489
1525
|
maxSeq: sql4`max(${juniorConversationEvents.seq})`,
|
|
1490
1526
|
maxHistoryVersion: sql4`max(${juniorConversationEvents.historyVersion})`
|
|
1491
|
-
}).from(juniorConversationEvents).where(
|
|
1527
|
+
}).from(juniorConversationEvents).where(eq4(juniorConversationEvents.conversationId, conversationId));
|
|
1492
1528
|
const maxSeq = rows[0]?.maxSeq;
|
|
1493
1529
|
const maxHistoryVersion = rows[0]?.maxHistoryVersion;
|
|
1494
1530
|
return {
|
|
@@ -1502,7 +1538,7 @@ function createSqlConversationEventStore(executor) {
|
|
|
1502
1538
|
}
|
|
1503
1539
|
|
|
1504
1540
|
// src/chat/conversations/sql/search.ts
|
|
1505
|
-
import { and as
|
|
1541
|
+
import { and as and5, desc as desc3, eq as eq5, isNull as isNull2, ne, sql as sql5 } from "drizzle-orm";
|
|
1506
1542
|
var SqlConversationSearchStore = class {
|
|
1507
1543
|
constructor(executor) {
|
|
1508
1544
|
this.executor = executor;
|
|
@@ -1527,23 +1563,23 @@ var SqlConversationSearchStore = class {
|
|
|
1527
1563
|
role: role.as("role")
|
|
1528
1564
|
}).from(juniorConversationEvents).innerJoin(
|
|
1529
1565
|
juniorConversations,
|
|
1530
|
-
|
|
1566
|
+
eq5(
|
|
1531
1567
|
juniorConversations.conversationId,
|
|
1532
1568
|
juniorConversationEvents.conversationId
|
|
1533
1569
|
)
|
|
1534
1570
|
).innerJoin(
|
|
1535
1571
|
juniorDestinations,
|
|
1536
|
-
|
|
1572
|
+
eq5(juniorDestinations.id, juniorConversations.destinationId)
|
|
1537
1573
|
).where(
|
|
1538
|
-
|
|
1539
|
-
|
|
1574
|
+
and5(
|
|
1575
|
+
eq5(juniorConversations.source, "slack"),
|
|
1540
1576
|
isNull2(juniorConversations.parentConversationId),
|
|
1541
1577
|
isNull2(juniorConversations.transcriptPurgedAt),
|
|
1542
1578
|
ne(juniorConversations.conversationId, args.currentConversationId),
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1579
|
+
eq5(juniorDestinations.provider, args.scope.provider),
|
|
1580
|
+
eq5(juniorDestinations.providerTenantId, args.scope.providerTenantId),
|
|
1581
|
+
eq5(juniorDestinations.visibility, "public"),
|
|
1582
|
+
eq5(juniorConversationEvents.type, "message"),
|
|
1547
1583
|
sql5`${role} in ('user', 'assistant')`,
|
|
1548
1584
|
sql5`to_tsvector('english', ${text}) @@ ${tsquery}`
|
|
1549
1585
|
)
|
|
@@ -1575,12 +1611,13 @@ var current;
|
|
|
1575
1611
|
function createDb(args) {
|
|
1576
1612
|
return createJuniorSqlExecutor({
|
|
1577
1613
|
connectionString: args.databaseUrl,
|
|
1578
|
-
driver: args.driver
|
|
1614
|
+
driver: args.driver,
|
|
1615
|
+
statementTimeoutMs: args.statementTimeoutMs
|
|
1579
1616
|
});
|
|
1580
1617
|
}
|
|
1581
1618
|
function getSqlExecutor() {
|
|
1582
1619
|
const { sql: sql6 } = getChatConfig();
|
|
1583
|
-
if (current?.databaseUrl !== sql6.databaseUrl || current.driver !== sql6.driver) {
|
|
1620
|
+
if (current?.databaseUrl !== sql6.databaseUrl || current.driver !== sql6.driver || current.statementTimeoutMs !== sql6.statementTimeoutMs) {
|
|
1584
1621
|
if (current) {
|
|
1585
1622
|
const previous = current;
|
|
1586
1623
|
current = void 0;
|
|
@@ -1588,11 +1625,13 @@ function getSqlExecutor() {
|
|
|
1588
1625
|
}
|
|
1589
1626
|
const db = createDb({
|
|
1590
1627
|
databaseUrl: sql6.databaseUrl,
|
|
1591
|
-
driver: sql6.driver
|
|
1628
|
+
driver: sql6.driver,
|
|
1629
|
+
statementTimeoutMs: sql6.statementTimeoutMs
|
|
1592
1630
|
});
|
|
1593
1631
|
current = {
|
|
1594
1632
|
databaseUrl: sql6.databaseUrl,
|
|
1595
1633
|
driver: sql6.driver,
|
|
1634
|
+
statementTimeoutMs: sql6.statementTimeoutMs,
|
|
1596
1635
|
db,
|
|
1597
1636
|
store: createSqlStore(db),
|
|
1598
1637
|
eventStore: createSqlConversationEventStore(db),
|
|
@@ -1628,6 +1667,7 @@ export {
|
|
|
1628
1667
|
requireSlackDestination,
|
|
1629
1668
|
sameDestination,
|
|
1630
1669
|
parseSessionSource,
|
|
1670
|
+
bindProviderConversation,
|
|
1631
1671
|
locationFromRow,
|
|
1632
1672
|
instructionProvenanceFor,
|
|
1633
1673
|
contextProvenance,
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
toCanonicalInputMessage,
|
|
4
4
|
toCanonicalOutputMessage,
|
|
5
5
|
toGenAiMessagesTraceAttributes
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-LKK4XMUV.js";
|
|
7
7
|
import {
|
|
8
8
|
extractGenAiUsageAttributes,
|
|
9
9
|
logException,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
normalizeGenAiFinishReason,
|
|
12
12
|
serializeGenAiAttribute,
|
|
13
13
|
withSpan
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-6T3AYZT7.js";
|
|
15
15
|
|
|
16
16
|
// src/chat/config.ts
|
|
17
17
|
import { getModel as getModel2 } from "@earendil-works/pi-ai/compat";
|
|
@@ -675,6 +675,7 @@ var DEFAULT_SLACK_SLASH_COMMAND = "/jr";
|
|
|
675
675
|
var DEFAULT_PROCESSING_REACTION_EMOJI = "eyes";
|
|
676
676
|
var DEFAULT_COMPLETED_REACTION_EMOJI = "white_check_mark";
|
|
677
677
|
var DEFAULT_MODEL_CONTEXT_WINDOW_TOKENS = 4e5;
|
|
678
|
+
var DEFAULT_SQL_STATEMENT_TIMEOUT_MS = 3e4;
|
|
678
679
|
var FUNCTION_TIMEOUT_BUFFER_SECONDS = 20;
|
|
679
680
|
var CONVERSATION_WORK_SOFT_YIELD_BUFFER_SECONDS = 40;
|
|
680
681
|
var DEFAULT_ASSISTANT_LOADING_MESSAGES = [
|
|
@@ -904,6 +905,19 @@ function readSqlDriver(env, databaseUrl) {
|
|
|
904
905
|
}
|
|
905
906
|
throw new Error("JUNIOR_DATABASE_DRIVER must be postgres or neon");
|
|
906
907
|
}
|
|
908
|
+
function readSqlStatementTimeoutMs(env) {
|
|
909
|
+
const rawValue = toOptionalTrimmed(env.JUNIOR_SQL_STATEMENT_TIMEOUT_MS);
|
|
910
|
+
if (rawValue === void 0) {
|
|
911
|
+
return DEFAULT_SQL_STATEMENT_TIMEOUT_MS;
|
|
912
|
+
}
|
|
913
|
+
const value = Number.parseInt(rawValue, 10);
|
|
914
|
+
if (!Number.isSafeInteger(value) || value < 0 || String(value) !== rawValue) {
|
|
915
|
+
throw new Error(
|
|
916
|
+
"JUNIOR_SQL_STATEMENT_TIMEOUT_MS must be a non-negative integer"
|
|
917
|
+
);
|
|
918
|
+
}
|
|
919
|
+
return value === 0 ? false : value;
|
|
920
|
+
}
|
|
907
921
|
function readChatConfig(env = process.env, functionMaxDurationSeconds = DEFAULT_FUNCTION_MAX_DURATION_SECONDS) {
|
|
908
922
|
const databaseUrl = readDatabaseUrl(env);
|
|
909
923
|
const resolvedFunctionMaxDurationSeconds = resolveFunctionMaxDurationSeconds(
|
|
@@ -917,7 +931,8 @@ function readChatConfig(env = process.env, functionMaxDurationSeconds = DEFAULT_
|
|
|
917
931
|
),
|
|
918
932
|
sql: {
|
|
919
933
|
databaseUrl,
|
|
920
|
-
driver: readSqlDriver(env, databaseUrl)
|
|
934
|
+
driver: readSqlDriver(env, databaseUrl),
|
|
935
|
+
statementTimeoutMs: readSqlStatementTimeoutMs(env)
|
|
921
936
|
},
|
|
922
937
|
slack: {
|
|
923
938
|
botToken: toOptionalTrimmed(env.SLACK_BOT_TOKEN) ?? toOptionalTrimmed(env.SLACK_BOT_USER_TOKEN),
|
|
@@ -1027,6 +1042,7 @@ export {
|
|
|
1027
1042
|
modelIdForProfile,
|
|
1028
1043
|
standardModelId,
|
|
1029
1044
|
profileConfig,
|
|
1045
|
+
DEFAULT_SQL_STATEMENT_TIMEOUT_MS,
|
|
1030
1046
|
FUNCTION_TIMEOUT_BUFFER_SECONDS,
|
|
1031
1047
|
configureFunctionMaxDurationSeconds,
|
|
1032
1048
|
getChatConfig,
|
|
@@ -2,18 +2,18 @@ import {
|
|
|
2
2
|
SANDBOX_WORKSPACE_ROOT,
|
|
3
3
|
getStateAdapter,
|
|
4
4
|
sleep
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-FDNAUM7X.js";
|
|
6
6
|
import {
|
|
7
7
|
toOptionalTrimmed
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-XG5PHKPM.js";
|
|
9
9
|
import {
|
|
10
10
|
pluginCatalogRuntime
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-VEGF62FV.js";
|
|
12
12
|
import {
|
|
13
13
|
setSpanAttributes,
|
|
14
14
|
setSpanStatus,
|
|
15
15
|
withSpan
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-6T3AYZT7.js";
|
|
17
17
|
|
|
18
18
|
// src/chat/sandbox/resources.ts
|
|
19
19
|
var configuredResources;
|
|
@@ -216,7 +216,7 @@ function buildEnvExports(options) {
|
|
|
216
216
|
}
|
|
217
217
|
return lines;
|
|
218
218
|
}
|
|
219
|
-
function
|
|
219
|
+
function buildCommandScript(input) {
|
|
220
220
|
return [shellQuote(input.cmd), ...(input.args ?? []).map(shellQuote)].join(
|
|
221
221
|
" "
|
|
222
222
|
);
|
|
@@ -229,7 +229,7 @@ function buildNonInteractiveCommand(input) {
|
|
|
229
229
|
cmd: "bash",
|
|
230
230
|
args: [
|
|
231
231
|
input.login ? "-lc" : "-c",
|
|
232
|
-
buildNonInteractiveShellScript(
|
|
232
|
+
buildNonInteractiveShellScript(buildCommandScript(input), {
|
|
233
233
|
env: input.env,
|
|
234
234
|
pathPrefix: input.pathPrefix
|
|
235
235
|
})
|
|
@@ -1065,6 +1065,9 @@ function isMissingError(error) {
|
|
|
1065
1065
|
}
|
|
1066
1066
|
|
|
1067
1067
|
export {
|
|
1068
|
+
buildCommandScript,
|
|
1069
|
+
buildNonInteractiveShellScript,
|
|
1070
|
+
runNonInteractiveCommand,
|
|
1068
1071
|
isAlreadyExistsError,
|
|
1069
1072
|
isSandboxUnavailableError,
|
|
1070
1073
|
isSandboxMissingError,
|
|
@@ -1073,8 +1076,6 @@ export {
|
|
|
1073
1076
|
wrapSandboxSetupError,
|
|
1074
1077
|
throwSandboxOperationError,
|
|
1075
1078
|
getVercelSandboxCredentials,
|
|
1076
|
-
buildNonInteractiveShellScript,
|
|
1077
|
-
runNonInteractiveCommand,
|
|
1078
1079
|
getSandboxResourceConfig,
|
|
1079
1080
|
setSandboxResourceConfig,
|
|
1080
1081
|
getSandboxResources,
|
package/dist/cli/chat.js
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createAgentRunner,
|
|
3
3
|
executeAgentRun
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-NF2TNZPD.js";
|
|
5
5
|
import "../chunk-DIB4GX3G.js";
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-VGXJMECA.js";
|
|
7
|
+
import "../chunk-7GKQ7UIO.js";
|
|
8
8
|
import "../chunk-EPBBYMNE.js";
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
9
|
+
import "../chunk-YNLQQ622.js";
|
|
10
|
+
import "../chunk-KWGJG4HO.js";
|
|
11
|
+
import "../chunk-MFERLE3G.js";
|
|
12
|
+
import "../chunk-CDQ4YIZM.js";
|
|
13
13
|
import "../chunk-PDO5BLNM.js";
|
|
14
14
|
import "../chunk-UIE3R5XU.js";
|
|
15
15
|
import {
|
|
16
16
|
loadAppPluginSet
|
|
17
17
|
} from "../chunk-Y2CM7HXH.js";
|
|
18
|
-
import "../chunk-
|
|
19
|
-
import "../chunk-
|
|
20
|
-
import "../chunk-
|
|
21
|
-
import "../chunk-
|
|
22
|
-
import "../chunk-
|
|
18
|
+
import "../chunk-TR6UEEYD.js";
|
|
19
|
+
import "../chunk-VPYKNCTN.js";
|
|
20
|
+
import "../chunk-QLEKAO7O.js";
|
|
21
|
+
import "../chunk-FDNAUM7X.js";
|
|
22
|
+
import "../chunk-XG5PHKPM.js";
|
|
23
23
|
import "../chunk-VFUK3X5B.js";
|
|
24
|
-
import "../chunk-
|
|
25
|
-
import "../chunk-
|
|
26
|
-
import "../chunk-
|
|
27
|
-
import "../chunk-
|
|
24
|
+
import "../chunk-LKK4XMUV.js";
|
|
25
|
+
import "../chunk-S6DMTEOM.js";
|
|
26
|
+
import "../chunk-VEGF62FV.js";
|
|
27
|
+
import "../chunk-VP6NCPRS.js";
|
|
28
28
|
import "../chunk-77VDLF3Z.js";
|
|
29
29
|
import "../chunk-HZF5P5UN.js";
|
|
30
30
|
import "../chunk-F3B2YJ76.js";
|
|
31
|
-
import "../chunk-
|
|
31
|
+
import "../chunk-6T3AYZT7.js";
|
|
32
32
|
import "../chunk-6GWA276C.js";
|
|
33
33
|
import "../chunk-OOUNJNMR.js";
|
|
34
34
|
import "../chunk-H4HBKISO.js";
|
|
35
|
-
import "../chunk-
|
|
36
|
-
import "../chunk-
|
|
35
|
+
import "../chunk-U3ZI7CCW.js";
|
|
36
|
+
import "../chunk-GSP5SMZJ.js";
|
|
37
37
|
import "../chunk-MLKGABMK.js";
|
|
38
38
|
|
|
39
39
|
// src/cli/chat.ts
|
|
@@ -156,10 +156,10 @@ async function configureLocalChatPlugins(pluginSet) {
|
|
|
156
156
|
databaseModule
|
|
157
157
|
] = await Promise.all([
|
|
158
158
|
import("../plugins-HW4VWW6G.js"),
|
|
159
|
-
import("../agent-hooks-
|
|
160
|
-
import("../catalog-runtime-
|
|
161
|
-
import("../validation-
|
|
162
|
-
import("../db-
|
|
159
|
+
import("../agent-hooks-HGXNYOOD.js"),
|
|
160
|
+
import("../catalog-runtime-P6QHU6XE.js"),
|
|
161
|
+
import("../validation-FMWDHKYU.js"),
|
|
162
|
+
import("../db-GFK4NHWJ.js")
|
|
163
163
|
]);
|
|
164
164
|
const resolvedPluginSet = pluginSet === void 0 ? await loadLocalPluginSet() : pluginSet ?? void 0;
|
|
165
165
|
const plugins = pluginsModule.pluginRuntimeRegistrationsFromPluginSet(resolvedPluginSet);
|
|
@@ -223,8 +223,8 @@ function localDevServerUrl() {
|
|
|
223
223
|
async function prepareLocalChatRun(io, pluginSet) {
|
|
224
224
|
defaultStateAdapterForLocalChat();
|
|
225
225
|
await configureLocalChatPlugins(pluginSet);
|
|
226
|
-
const { runLocalAgentTurn } = await import("../runner-
|
|
227
|
-
const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-
|
|
226
|
+
const { runLocalAgentTurn } = await import("../runner-T77AFAH4.js");
|
|
227
|
+
const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-HUJLAQ5N.js");
|
|
228
228
|
const { createLocalOAuthState } = await import("../oauth-relay-3ZU72UGL.js");
|
|
229
229
|
const { createLocalSandboxEgressSignalTransport } = await import("../sandbox-egress-signals-A5HWIQH4.js");
|
|
230
230
|
const agentRunner = createAgentRunner(executeAgentRun);
|
package/dist/cli/check.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parseSkillFile
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-S6DMTEOM.js";
|
|
4
|
+
import "../chunk-VEGF62FV.js";
|
|
5
5
|
import {
|
|
6
6
|
parseInlinePluginManifest,
|
|
7
7
|
parsePluginManifest
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-VP6NCPRS.js";
|
|
9
9
|
import "../chunk-77VDLF3Z.js";
|
|
10
10
|
import "../chunk-HZF5P5UN.js";
|
|
11
11
|
import "../chunk-F3B2YJ76.js";
|
|
12
|
-
import "../chunk-
|
|
12
|
+
import "../chunk-6T3AYZT7.js";
|
|
13
13
|
import "../chunk-6GWA276C.js";
|
|
14
14
|
import "../chunk-OOUNJNMR.js";
|
|
15
15
|
import "../chunk-H4HBKISO.js";
|
|
@@ -17,8 +17,8 @@ import {
|
|
|
17
17
|
JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE,
|
|
18
18
|
JUNIOR_HEARTBEAT_ROUTE,
|
|
19
19
|
LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION
|
|
20
|
-
} from "../chunk-
|
|
21
|
-
import "../chunk-
|
|
20
|
+
} from "../chunk-U3ZI7CCW.js";
|
|
21
|
+
import "../chunk-GSP5SMZJ.js";
|
|
22
22
|
import "../chunk-MLKGABMK.js";
|
|
23
23
|
|
|
24
24
|
// src/cli/check.ts
|
package/dist/cli/init.js
CHANGED
|
@@ -216,11 +216,11 @@ AI_HANDOFF_MODEL=
|
|
|
216
216
|
AI_MODEL_PROFILES=
|
|
217
217
|
AI_MEMORY_MODEL=
|
|
218
218
|
AI_EMBEDDING_MODEL=
|
|
219
|
-
MEMORY_RECALL_MAX_VECTOR_DISTANCE=
|
|
220
219
|
AI_VISION_MODEL=
|
|
221
220
|
AI_WEB_SEARCH_MODEL=
|
|
222
221
|
DATABASE_URL=
|
|
223
222
|
JUNIOR_DATABASE_DRIVER=
|
|
223
|
+
JUNIOR_SQL_STATEMENT_TIMEOUT_MS=
|
|
224
224
|
REDIS_URL=
|
|
225
225
|
CRON_SECRET=
|
|
226
226
|
SENTRY_DSN=
|