@sentry/junior 0.294.0 → 0.296.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/{admin-vt8aSiCD.js → admin-z_lgDi-z.js} +2 -2
- package/dist/{agent-runner-DJu7w6mI.js → agent-runner-HoQiUKLL.js} +318 -199
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +5 -5
- package/dist/api.d.ts +1 -1
- package/dist/api.js +321 -331
- package/dist/{app--a5RLOrr.d.ts → app-C75Ft-A_.d.ts} +3 -3
- package/dist/app.d.ts +2 -2
- package/dist/app.js +33 -34
- package/dist/{automation-BM-OBsKW.js → automation-yJX3C7i3.js} +3 -3
- package/dist/{background-compaction-queue-D2j-0XkH.js → background-compaction-queue-Cre1wFt9.js} +7 -9
- package/dist/{briefs-JOAoCb6d.js → briefs-BXECHduJ.js} +3 -3
- package/dist/{catalog-runtime-CLMA9AXd.js → catalog-runtime-CpCmlD9L.js} +1 -1
- package/dist/cli/chat.d.ts +1 -1
- package/dist/cli/chat.js +15 -15
- package/dist/cli/check.js +3 -3
- package/dist/cli/init.js +2 -0
- package/dist/cli/main.js +3 -3
- package/dist/cli/plugins.d.ts +1 -1
- package/dist/cli/plugins.js +4 -4
- package/dist/cli/snapshot-create.js +4 -4
- package/dist/cli/upgrade.d.ts +2 -2
- package/dist/cli/upgrade.js +3 -3
- package/dist/{config-mIZeGEWv.js → config-CCPHvTqx.js} +59 -2
- package/dist/{connections-XhdVg7OR.js → connections-B5pWh8e2.js} +6 -6
- package/dist/{conversation-CDWejM4R.js → conversation-CMkSmi02.js} +2 -11
- package/dist/{conversation-pending-messages-Dh2tfbaw.js → conversation-feed-BVAOga0H.js} +27 -2
- package/dist/{conversation-privacy-C6h-X2cZ.js → conversation-privacy-CZD5soDW.js} +1 -1
- package/dist/{credential-sync-zigBlXS3.js → credential-sync-DwLkIvXI.js} +16 -15
- package/dist/{db-DV5AbcGM.d.ts → db-B3iyr_Or.d.ts} +6 -1
- package/dist/{db--xuNV7g6.js → db-C1M1y-bh.js} +64 -26
- package/dist/{executor-BItuRqAR.js → executor-DUSEwXaO.js} +16 -5
- package/dist/instrumentation.js +19 -2
- package/dist/{logging-Cb6MGvdt.js → logging-D0svFM8r.js} +2 -1
- package/dist/{message-BTGgSmaH.js → message-BFnIwKpx.js} +9 -9
- package/dist/nitro.d.ts +2 -2
- package/dist/nitro.js +2 -2
- package/dist/{oauth-callback-server-Dvh1aOIi.js → oauth-callback-server-BXRtD6Fk.js} +2 -2
- package/dist/{oauth-relay-D6xxVywK.js → oauth-relay-CsfIazeF.js} +2 -1
- package/dist/{plugins-DtmjkTza.d.ts → plugins-B_0Cr0MO.d.ts} +0 -1
- package/dist/{projection-DLQgfO5N.js → projection-B6VS7kbo.js} +386 -108
- package/dist/{prompt-qp_LdxLX.js → prompt-CD11tfG8.js} +4 -4
- package/dist/{registry-MtwokaqW.js → registry-CHewwYEo.js} +3 -13
- package/dist/{resolve-BnJA0UNE.js → resolve-1owMH4qo.js} +3 -3
- package/dist/{result-ChL-1KyW.js → result-CEqQFrEf.js} +8 -8
- package/dist/{runner-BONN7Dp2.js → runner-BtWvJslp.js} +8 -8
- package/dist/{sandbox-egress-signals-nmlmI5Ab.js → sandbox-egress-signals-ByftwJVt.js} +1 -1
- package/dist/{schema-DgvcyJ1y.d.ts → schema-Ct1Zf2xy.d.ts} +66 -14
- package/dist/{schema-yr0ccDni.js → schema-D2iGyYIp.js} +24 -6
- package/dist/secrets-DebYU866.js +18 -0
- package/dist/{service-account-Bd0lBaGr.js → service-account-BZEuMKdo.js} +3 -3
- package/dist/{service-account-kio5nXSD.js → service-account-DLoeoHww.js} +42 -26
- package/dist/{session-stop-CeCXL3j9.js → session-stop-hYNTNpVf.js} +23 -778
- package/dist/{skills-e3DDNlKO.js → skills-DXgd5Inh.js} +3 -3
- package/dist/{spawn--cRxITWQ.js → spawn-YeqlNDv8.js} +5 -5
- package/dist/{adapter-DxLhJEnO.js → state-C3CbtD_m.js} +132 -2
- package/dist/{stop-Iai5N2PU.js → stop-Cze_pEL8.js} +351 -255
- package/dist/{store-C8LsaJwS.js → store-CZ9vqR4P.js} +3 -3
- package/dist/{task-runner-Dw7exu0-.js → task-runner-CMiNGsER.js} +275 -251
- package/dist/{turn-failure-response-BqTTx3XG.js → turn-failure-response-pXhZ2wMK.js} +12 -9
- package/dist/{validation-BrGahtnv.js → validation-Du7NdkOR.js} +1 -1
- package/dist/{version-Bdqhx8Qh.js → version-EN3Wnq-R.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-CjRFHR5U.js → viewer-Agxi_o5c.js} +3 -3
- package/dist/warmup-CY2ArYag.js +2017 -0
- package/dist/{work-BWBG1EGV.js → work-EA98F0ia.js} +11 -11
- package/dist/{worker-DAnBIVMs.js → worker-BALVdWbv.js} +6 -6
- package/migrations/0098_review_item_plugin_actions.sql +5 -0
- package/migrations/0099_conversation_last_message_at.sql +1 -0
- package/migrations/0100_automation_task_kind_repair.sql +48 -0
- package/migrations/0101_drop_legacy_columns.sql +12 -0
- package/migrations/meta/0098_snapshot.json +4490 -0
- package/migrations/meta/0099_snapshot.json +4720 -0
- package/migrations/meta/0100_snapshot.json +4496 -0
- package/migrations/meta/0101_snapshot.json +4496 -0
- package/migrations/meta/_journal.json +28 -0
- package/package.json +6 -5
- package/dist/assistant-reply-iTtEdDyc.js +0 -58
- package/dist/warmup-DuxCtzKC.js +0 -1039
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import { An as resolvePluginOAuthAccount, En as createUserTokenStore, Fi as resolveBaseUrl, Ni as formatProviderLabel, Pi as parseOAuthStatePayload, Yi as postSlackMessage, Z as getConversationPendingAuth, d as recordAuthorizationCompleted, oa as getSlackClient, ot as getTurnRecord, u as recordAuthenticationLinked } from "./projection-
|
|
2
|
-
import { L as escapeXml, a as getRuntimeMetadata, n as botConfig } from "./config-
|
|
3
|
-
import { U as isNativeIdentityProvider, _ as runBestEffort, h as logWarn, p as logException } from "./logging-
|
|
1
|
+
import { An as resolvePluginOAuthAccount, En as createUserTokenStore, Fi as resolveBaseUrl, Ni as formatProviderLabel, Pi as parseOAuthStatePayload, Yi as postSlackMessage, Z as getConversationPendingAuth, d as recordAuthorizationCompleted, oa as getSlackClient, ot as getTurnRecord, u as recordAuthenticationLinked } from "./projection-B6VS7kbo.js";
|
|
2
|
+
import { L as escapeXml, a as getRuntimeMetadata, n as botConfig } from "./config-CCPHvTqx.js";
|
|
3
|
+
import { U as isNativeIdentityProvider, _ as runBestEffort, h as logWarn, p as logException } from "./logging-D0svFM8r.js";
|
|
4
4
|
import { p as parseSlackUserId } from "./actor-6jsm_v96.js";
|
|
5
|
-
import {
|
|
5
|
+
import { H as upsertLinkedIdentity, P as resolveActorIdentityId, R as findUserByVerifiedEmails, s as getSqlExecutor } from "./db-C1M1y-bh.js";
|
|
6
6
|
import { i as homeDir } from "./package-discovery-DJhGdS4c.js";
|
|
7
|
-
import { n as buildOAuthTokenRequest, r as parseOAuthTokenResponse, u as hasRequiredOAuthScope } from "./registry-
|
|
8
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime-
|
|
9
|
-
import { t as discoverSkills } from "./skills-
|
|
10
|
-
import { It as wakeAuthorizedTurn, Lt as wakePausedTurn, Yt as deleteWebAuthorization, a as finalizeMcpAuthorization, d as getMcpStoredOAuthCredentials, f as putMcpStoredOAuthCredentials, o as deleteMcpAuthSession, u as getMcpAuthSession, y as lookupSlackUserProfile } from "./agent-runner-
|
|
7
|
+
import { n as buildOAuthTokenRequest, r as parseOAuthTokenResponse, u as hasRequiredOAuthScope } from "./registry-CHewwYEo.js";
|
|
8
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-CpCmlD9L.js";
|
|
9
|
+
import { t as discoverSkills } from "./skills-DXgd5Inh.js";
|
|
10
|
+
import { It as wakeAuthorizedTurn, Lt as wakePausedTurn, Yt as deleteWebAuthorization, a as finalizeMcpAuthorization, d as getMcpStoredOAuthCredentials, f as putMcpStoredOAuthCredentials, o as deleteMcpAuthSession, u as getMcpAuthSession, y as lookupSlackUserProfile } from "./agent-runner-HoQiUKLL.js";
|
|
11
11
|
import { r as acquireActiveLock } from "./locks-D-0h111u.js";
|
|
12
|
-
import { o as readIdentityById } from "./viewer-
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
12
|
+
import { o as readIdentityById } from "./viewer-Agxi_o5c.js";
|
|
13
|
+
import { a as getStateAdapter } from "./state-C3CbtD_m.js";
|
|
14
|
+
import { t as readJuniorSecret } from "./secrets-DebYU866.js";
|
|
15
|
+
import { c as getPersistedThreadState, d as coerceThreadConversationState } from "./task-runner-CMiNGsER.js";
|
|
16
|
+
import { _ as getMcpProviderErrorAttributes } from "./service-account-DLoeoHww.js";
|
|
17
|
+
import { i as readConnectedOAuthTokens, s as htmlCallbackResponse } from "./connections-B5pWh8e2.js";
|
|
18
|
+
import { n as relayLocalOAuthCallback } from "./oauth-relay-CsfIazeF.js";
|
|
18
19
|
import path from "node:path";
|
|
19
20
|
import { createHmac, createSecretKey, timingSafeEqual } from "node:crypto";
|
|
20
21
|
import * as z from "zod";
|
|
@@ -639,7 +640,7 @@ const localCredentialSyncSchema = z.object({
|
|
|
639
640
|
tokens: pluginStoredTokensSchema
|
|
640
641
|
}).strict();
|
|
641
642
|
function syncSecret() {
|
|
642
|
-
const secret =
|
|
643
|
+
const secret = readJuniorSecret();
|
|
643
644
|
if (!secret) throw new Error("Local credential sync requires JUNIOR_SECRET");
|
|
644
645
|
return secret;
|
|
645
646
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./schema-
|
|
1
|
+
import "./schema-Ct1Zf2xy.js";
|
|
2
2
|
import * as z from "zod";
|
|
3
3
|
import "drizzle-orm";
|
|
4
4
|
import { Destination, Source, locationSchema } from "@sentry/junior-plugin-api";
|
|
@@ -209,6 +209,11 @@ interface ConversationStore {
|
|
|
209
209
|
/** Source normalized to a stable session locator; set-once when absent. */
|
|
210
210
|
sessionSource?: Source;
|
|
211
211
|
title?: string;
|
|
212
|
+
/**
|
|
213
|
+
* Kind of a new Conversation. Default `root`. An existing Conversation
|
|
214
|
+
* keeps its kind.
|
|
215
|
+
*/
|
|
216
|
+
kind?: "root" | "automation";
|
|
212
217
|
/**
|
|
213
218
|
* Current visibility from its owner, such as a Slack event channel type. It
|
|
214
219
|
* replaces the visibility of the shared Destination row. Omit it for saved
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { v as __exportAll } from "./sentry-BRTJqumy.js";
|
|
2
|
-
import { i as getChatConfig } from "./config-
|
|
3
|
-
import { H as GOOGLE_IDENTITY_PROVIDER, W as normalizeIdentityEmail, h as logWarn } from "./logging-
|
|
2
|
+
import { i as getChatConfig } from "./config-CCPHvTqx.js";
|
|
3
|
+
import { H as GOOGLE_IDENTITY_PROVIDER, W as normalizeIdentityEmail, h as logWarn } from "./logging-D0svFM8r.js";
|
|
4
4
|
import { a as isSlackUserId, d as parseSlackChannelReferenceId, f as parseSlackTeamId, s as parseActorUserId } from "./actor-6jsm_v96.js";
|
|
5
|
-
import { A as juniorConversations, E as juniorConversationAnnotations, M as juniorUsers, N as juniorDestinations, S as juniorConversationMetrics, j as juniorIdentities, t as createJuniorSqlExecutor, v as juniorConversationParticipants, w as juniorConversationEvents, x as CONVERSATION_METRICS, y as juniorConversationBindings } from "./executor-
|
|
5
|
+
import { A as juniorConversations, C as isUserInstruction, E as juniorConversationAnnotations, M as juniorUsers, N as juniorDestinations, S as juniorConversationMetrics, j as juniorIdentities, t as createJuniorSqlExecutor, v as juniorConversationParticipants, w as juniorConversationEvents, x as CONVERSATION_METRICS, y as juniorConversationBindings } from "./executor-DUSEwXaO.js";
|
|
6
6
|
import { d as historyReplacementSchema, f as newConversationEventSchema, p as encodeHistoryPayload, s as conversationEventDataSchema, u as decodeStoredConversationEvent, y as usageSchema } from "./media-BepyEUNm.js";
|
|
7
7
|
import { randomUUID } from "node:crypto";
|
|
8
8
|
import { and, asc, desc, eq, gt, gte, inArray, isNull, lt, lte, ne, or, sql } from "drizzle-orm";
|
|
@@ -860,9 +860,9 @@ const ROOT = {
|
|
|
860
860
|
reviewDesk: true,
|
|
861
861
|
subscriptions: true,
|
|
862
862
|
userCustomization: true,
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
863
|
+
reply: false,
|
|
864
|
+
reportBlocked: "none",
|
|
865
|
+
noReply: true
|
|
866
866
|
}
|
|
867
867
|
};
|
|
868
868
|
const PERSON_IN_THREAD = {
|
|
@@ -881,9 +881,9 @@ const AGENT_IN_CHILD = {
|
|
|
881
881
|
reviewDesk: false,
|
|
882
882
|
subscriptions: false,
|
|
883
883
|
userCustomization: false,
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
884
|
+
reply: false,
|
|
885
|
+
reportBlocked: "parent",
|
|
886
|
+
noReply: true
|
|
887
887
|
}
|
|
888
888
|
};
|
|
889
889
|
const AUTOMATION_RUN = {
|
|
@@ -892,20 +892,14 @@ const AUTOMATION_RUN = {
|
|
|
892
892
|
gated: true,
|
|
893
893
|
tools: {
|
|
894
894
|
...ROOT.tools,
|
|
895
|
-
|
|
896
|
-
|
|
895
|
+
reply: true,
|
|
896
|
+
reportBlocked: "automation"
|
|
897
897
|
}
|
|
898
898
|
};
|
|
899
|
-
/**
|
|
900
|
-
* Return the behavior of one Turn. `automationRun` marks a Scheduled or Event
|
|
901
|
-
* automation run. It is a temporary bridge until Conversation kind
|
|
902
|
-
* `automation` replaces it.
|
|
903
|
-
*
|
|
904
|
-
* TODO(dcramer): Remove `automationRun` when kind `automation` ships.
|
|
905
|
-
*/
|
|
899
|
+
/** Return the behavior of one Turn. */
|
|
906
900
|
function turnBehavior(args) {
|
|
907
|
-
if (args.
|
|
908
|
-
if (
|
|
901
|
+
if (args.kind === "root") return ROOT;
|
|
902
|
+
if (args.kind === "automation") return args.personInput ? ROOT : AUTOMATION_RUN;
|
|
909
903
|
if (!args.personInput) return AGENT_IN_CHILD;
|
|
910
904
|
if (args.kind === "thread") return PERSON_IN_THREAD;
|
|
911
905
|
throw new Error("A task Conversation cannot have a person's input");
|
|
@@ -931,8 +925,8 @@ function deliversFinalText(dispatch) {
|
|
|
931
925
|
* Return whether the runtime may post a failure reply or a status notice,
|
|
932
926
|
* such as an auth prompt, for a run outside `finishedRunReply`. The rule is
|
|
933
927
|
* the same as for a final response. A chat Turn may post, also in a thread
|
|
934
|
-
* that an Automation Conversation owns. An Automation run posts only
|
|
935
|
-
*
|
|
928
|
+
* that an Automation Conversation owns. An Automation run posts only its
|
|
929
|
+
* `reply` text; its failed execution shows on the Automation.
|
|
936
930
|
*/
|
|
937
931
|
function postsRunNotices(dispatch) {
|
|
938
932
|
return deliversFinalText(dispatch);
|
|
@@ -994,8 +988,7 @@ function destinationUpsertFromDestination(args) {
|
|
|
994
988
|
};
|
|
995
989
|
}
|
|
996
990
|
function executionStatusFromValue(value) {
|
|
997
|
-
if (value === "
|
|
998
|
-
if (value === "failed" || value === "idle" || value === "pending" || value === "running") return value;
|
|
991
|
+
if (value === "failed" || value === "idle" || value === "paused" || value === "pending" || value === "running") return value;
|
|
999
992
|
throw new Error("Conversation record execution status is invalid");
|
|
1000
993
|
}
|
|
1001
994
|
function destinationFromRow(destination) {
|
|
@@ -1063,7 +1056,7 @@ function emptyConversation(args) {
|
|
|
1063
1056
|
schemaVersion: 1,
|
|
1064
1057
|
conversationId: args.conversationId,
|
|
1065
1058
|
createdAtMs: args.nowMs,
|
|
1066
|
-
kind: "root",
|
|
1059
|
+
kind: args.kind ?? "root",
|
|
1067
1060
|
lastActivityAtMs: args.nowMs,
|
|
1068
1061
|
updatedAtMs: args.nowMs,
|
|
1069
1062
|
...args.destination ? { destination: args.destination } : void 0,
|
|
@@ -1143,6 +1136,7 @@ var SqlStore = class {
|
|
|
1143
1136
|
const current = existing ?? emptyConversation({
|
|
1144
1137
|
conversationId: args.conversationId,
|
|
1145
1138
|
destination: args.destination,
|
|
1139
|
+
kind: args.kind,
|
|
1146
1140
|
nowMs,
|
|
1147
1141
|
source: args.source,
|
|
1148
1142
|
...sessionSource ? { sessionSource } : void 0
|
|
@@ -1388,6 +1382,49 @@ var SqlStore = class {
|
|
|
1388
1382
|
function createSqlStore(executor) {
|
|
1389
1383
|
return new SqlStore(executor);
|
|
1390
1384
|
}
|
|
1385
|
+
// src/chat/conversations/sql/last-message.ts
|
|
1386
|
+
/**
|
|
1387
|
+
* Return a query for the newest event of one type in the outer Conversation
|
|
1388
|
+
* that matches the filter. It walks the message role or user message time
|
|
1389
|
+
* index from the newest event. The user message index has only matching
|
|
1390
|
+
* entries, so that read stops at the first one.
|
|
1391
|
+
*/
|
|
1392
|
+
function latestEventAtQuery(db, type, filter) {
|
|
1393
|
+
return db.select({ createdAt: juniorConversationEvents.createdAt }).from(juniorConversationEvents).where(and(eq(juniorConversationEvents.conversationId, juniorConversations.conversationId), eq(juniorConversationEvents.type, type), filter)).orderBy(desc(juniorConversationEvents.createdAt), desc(juniorConversationEvents.seq)).limit(1);
|
|
1394
|
+
}
|
|
1395
|
+
/**
|
|
1396
|
+
* Return queries for the latest user instruction and the latest true user
|
|
1397
|
+
* Message of the outer Conversation.
|
|
1398
|
+
*/
|
|
1399
|
+
function userMessageQueries(db) {
|
|
1400
|
+
const payload = juniorConversationEvents.payload;
|
|
1401
|
+
const authorKind = sql`(${db.select({ kind: juniorIdentities.kind }).from(juniorIdentities).where(eq(juniorIdentities.id, juniorConversationEvents.actorIdentityId))})`;
|
|
1402
|
+
return {
|
|
1403
|
+
instruction: latestEventAtQuery(db, "user_message", isUserInstruction(payload)),
|
|
1404
|
+
message: latestEventAtQuery(db, "message", sql`${payload}->>'role' = 'user' and ${authorKind} = 'user'`)
|
|
1405
|
+
};
|
|
1406
|
+
}
|
|
1407
|
+
/**
|
|
1408
|
+
* Return SQL for when the outer Conversation last got a Message that a
|
|
1409
|
+
* reader would notice: a true user message or a Junior reply that the
|
|
1410
|
+
* transcript shows. Tools, status, Events, quiet replies, and progress acks
|
|
1411
|
+
* (`meta.progress`) do not count. It is null when there is no such Message.
|
|
1412
|
+
*/
|
|
1413
|
+
function lastMessageAtSql(db) {
|
|
1414
|
+
const payload = juniorConversationEvents.payload;
|
|
1415
|
+
const { instruction, message } = userMessageQueries(db);
|
|
1416
|
+
const reply = latestEventAtQuery(db, "message", sql`${payload}->>'role' = 'assistant' and (${payload}->'meta'->>'quiet') is distinct from 'true' and (${payload}->'meta'->>'progress') is distinct from 'true'`);
|
|
1417
|
+
return sql`greatest((${instruction}), (${message}), (${reply}))`.mapWith(juniorConversations.lastMessageAt);
|
|
1418
|
+
}
|
|
1419
|
+
/**
|
|
1420
|
+
* Store `lastMessageAtSql` on the Conversation row. Event appends call this
|
|
1421
|
+
* in their transaction when they add a Message, so feed reads take the time
|
|
1422
|
+
* from the row.
|
|
1423
|
+
*/
|
|
1424
|
+
async function refreshLastMessageAt(executor, conversationId) {
|
|
1425
|
+
const db = executor.db();
|
|
1426
|
+
await db.update(juniorConversations).set({ lastMessageAt: lastMessageAtSql(db) }).where(eq(juniorConversations.conversationId, conversationId));
|
|
1427
|
+
}
|
|
1391
1428
|
// src/chat/conversations/sql/event-actor.ts
|
|
1392
1429
|
function isRecord(value) {
|
|
1393
1430
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
@@ -1714,6 +1751,7 @@ var SqlConversationEventStore = class {
|
|
|
1714
1751
|
}
|
|
1715
1752
|
const db = this.executor.db();
|
|
1716
1753
|
await db.with(conversationDetailTouch(db, [conversationId])).insert(juniorConversationEvents).values(rows);
|
|
1754
|
+
if (pending.some((event) => event.data.type === "message" || event.data.type === "user_message")) await refreshLastMessageAt(this.executor, conversationId);
|
|
1717
1755
|
for (const event of pending) if (event.data.type === "turn_started") await this.recordTurnInputParticipants(conversationId, event.data.inputMessageIds);
|
|
1718
1756
|
return rows.map((row) => ({
|
|
1719
1757
|
seq: row.seq,
|
|
@@ -2034,4 +2072,4 @@ async function closeDb() {
|
|
|
2034
2072
|
current = void 0;
|
|
2035
2073
|
await previous?.db.close();
|
|
2036
2074
|
}
|
|
2037
|
-
export {
|
|
2075
|
+
export { rootConversationIsArchived as $, setFirstConversationLocation as A, recordGoogleSignIn as B, deliversFinalText as C, turnBehavior as D, postsRunNotices as E, saveActorAvatar as F, getConversationIdByProviderConversation as G, upsertLinkedIdentity as H, deleteProviderIdentityForSlackUser as I, agentTurnCostUsd as J, parseSessionSource as K, deleteProviderIdentityForUser as L, SYSTEM_IDENTITY_ID as M, findActorIdentityId as N, conversationKindFromRow as O, resolveActorIdentityId as P, resolveRootConversationId as Q, findUserByVerifiedEmails as R, withConversationMutationLock as S, isTopLevelKind as T, bindProviderConversation as U, saveUserTimezone as V, claimProviderConversation as W, agentTurnUsageSchema as X, agentTurnTotalTokens as Y, hasAgentTurnUsage as Z, setArchivedAt as _, getConversationStore as a, requireSlackDestination as at, userMessageQueries as b, conversationIdsWithAnnotation as c, createSqlConversationEventStore as d, conversationDetailTouch as et, eventFromRow as f, readConversationTrees as g, conversationDescendants as h, getConversationMessageSearchStore as i, parseDestination as it, startLocationThread as j, locationFromRow as k, hasAnnotationKey as l, conversationAncestors as m, db_exports as n, touchConversationDetail as nt, getDb as o, sameDestination as ot, withConversationEventLock as p, addAgentTurnUsage as q, getConversationEventStore as r, createSlackDestination as rt, getSqlExecutor as s, closeDb as t, nextDetailVersion as tt, treeHasAnnotationKey as u, loadConversationSlackTenantIds as v, isPersonInput as w, createSqlStore as x, lastMessageAtSql as y, readUserTimezone as z };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _ as withScope } from "./sentry-BRTJqumy.js";
|
|
2
|
-
import "./config-
|
|
3
|
-
import { h as logWarn, p as logException } from "./logging-
|
|
2
|
+
import "./config-CCPHvTqx.js";
|
|
3
|
+
import { h as logWarn, p as logException } from "./logging-D0svFM8r.js";
|
|
4
4
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
5
5
|
import { sql } from "drizzle-orm";
|
|
6
6
|
import { bigint, boolean, check, date, doublePrecision, foreignKey, index, integer, jsonb, pgTable, primaryKey, text, timestamp, uniqueIndex, uuid } from "drizzle-orm/pg-core";
|
|
@@ -108,6 +108,11 @@ const juniorConversations = pgTable("junior_conversations", {
|
|
|
108
108
|
title: text("title"),
|
|
109
109
|
createdAt: timestamptz("created_at").notNull(),
|
|
110
110
|
lastActivityAt: timestamptz("last_activity_at").notNull(),
|
|
111
|
+
/**
|
|
112
|
+
* The newest Message that a reader would notice (`refreshLastMessageAt`).
|
|
113
|
+
* Null until the Conversation has one.
|
|
114
|
+
*/
|
|
115
|
+
lastMessageAt: timestamptz("last_message_at"),
|
|
111
116
|
updatedAt: timestamptz("updated_at").notNull(),
|
|
112
117
|
executionUpdatedAt: timestamptz("execution_updated_at"),
|
|
113
118
|
executionStatus: text("execution_status").$type().notNull(),
|
|
@@ -644,7 +649,7 @@ const juniorReviewItems = pgTable("junior_review_items", {
|
|
|
644
649
|
createdAt: timestamptz("created_at").notNull(),
|
|
645
650
|
updatedAt: timestamptz("updated_at").notNull()
|
|
646
651
|
}, (table) => [
|
|
647
|
-
check("junior_review_items_kind_check", sql`(${table.kind} = 'notice' and ${table.request} is null and ${table.answer} is null) or (${table.kind} = 'action' and ${table.request} is not null)`),
|
|
652
|
+
check("junior_review_items_kind_check", sql`(${table.kind} = 'notice' and ${table.request} is null and ${table.answer} is null) or (${table.kind} = 'action' and (${table.request} is not null or (${table.dedupeKey} like 'plugin:%' and ${table.answer} is null)))`),
|
|
648
653
|
check("junior_review_items_status_check", sql`(${table.status} = 'open' and ${table.closedAt} is null) or (${table.status} in ('done', 'dismissed') and ${table.closedAt} is not null)`),
|
|
649
654
|
check("junior_review_items_tenant_check", sql`(${table.provider} is null) = (${table.providerTenantId} is null)`),
|
|
650
655
|
check("junior_review_items_visibility_check", sql`${table.visibility} = 'public' or not ${table.assignedToEveryone}`),
|
|
@@ -890,6 +895,12 @@ async function applyMigrations(executor, config) {
|
|
|
890
895
|
}
|
|
891
896
|
// src/db/neon.ts
|
|
892
897
|
const POOL_MAX = 10;
|
|
898
|
+
function toConnectError(error) {
|
|
899
|
+
if (error instanceof Error) return error;
|
|
900
|
+
const event = error ?? {};
|
|
901
|
+
const reason = typeof event.message === "string" && event.message || event.error instanceof Error && event.error.message || typeof event.type === "string" && event.type || String(error);
|
|
902
|
+
return new Error(`WebSocket connect failed: ${reason}`, event.error === void 0 ? void 0 : { cause: event.error });
|
|
903
|
+
}
|
|
893
904
|
/**
|
|
894
905
|
* Sends a pool query over Neon's SQL-over-HTTP endpoint when no idle
|
|
895
906
|
* WebSocket client is free.
|
|
@@ -910,7 +921,7 @@ var OverflowPool = class extends Pool {
|
|
|
910
921
|
super({
|
|
911
922
|
connectionString: args.connectionString,
|
|
912
923
|
max: POOL_MAX,
|
|
913
|
-
idleTimeoutMillis:
|
|
924
|
+
idleTimeoutMillis: 3e5,
|
|
914
925
|
min: 1,
|
|
915
926
|
statement_timeout: args.statementTimeoutMs
|
|
916
927
|
});
|
|
@@ -945,7 +956,7 @@ var OverflowPool = class extends Pool {
|
|
|
945
956
|
client.release();
|
|
946
957
|
return;
|
|
947
958
|
}
|
|
948
|
-
logException(error, "db.pool.client.connect_failed", { "app.db.driver": "neon" });
|
|
959
|
+
logException(toConnectError(error), "db.pool.client.connect_failed", { "app.db.driver": "neon" });
|
|
949
960
|
});
|
|
950
961
|
}
|
|
951
962
|
/** Keep every pool query in `callback` on WebSocket. */
|
package/dist/instrumentation.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as getClient, c as init, i as getActiveSpan, o as getGlobalScope, p as spanToJSON, s as getTraceData } from "./sentry-BRTJqumy.js";
|
|
2
|
-
import { B as getDeploymentTelemetryAttributes, z as getDeploymentServiceVersion } from "./logging-
|
|
3
|
-
import { n as getCurrentConversationPrivacy } from "./conversation-privacy-
|
|
2
|
+
import { B as getDeploymentTelemetryAttributes, z as getDeploymentServiceVersion } from "./logging-D0svFM8r.js";
|
|
3
|
+
import { n as getCurrentConversationPrivacy } from "./conversation-privacy-CZD5soDW.js";
|
|
4
4
|
import { n as redactSandboxEgressProxyPath } from "./proxy-path-BHYoKZdq.js";
|
|
5
5
|
import { t as consumePrivateTraceResultMarker } from "./private-trace-result-CE7_lEdq.js";
|
|
6
6
|
import { n as promoteHttpRouteName, r as routeNameMiddleware, t as nameRequestRoute } from "./sentry-route-name-BhwWnfqj.js";
|
|
@@ -103,6 +103,23 @@ function createGatewayRequestTimingHandlers() {
|
|
|
103
103
|
* AI Gateway model requests onto their `gen_ai.chat` span. Telemetry must not
|
|
104
104
|
* fail a request, so handler errors are dropped. Returns a function that
|
|
105
105
|
* removes the subscriptions.
|
|
106
|
+
*
|
|
107
|
+
* To find where time went before the gateway saw a request, get the gateway
|
|
108
|
+
* latency for `gen_ai.response.id` from the AI Gateway generation API, then
|
|
109
|
+
* compare the phases:
|
|
110
|
+
* - High `queue_ms` on a reused socket, or high
|
|
111
|
+
* `app.ai.event_loop.utilization`: the process was busy or the pool was
|
|
112
|
+
* full. With a new socket, `queue_ms` includes the connect time.
|
|
113
|
+
* - High `connect_ms`: DNS, TCP, or TLS was slow. It is absent on a reused
|
|
114
|
+
* socket. It is best effort: overlapping connects to the same host usually
|
|
115
|
+
* record none.
|
|
116
|
+
* - High `body_send_ms`: the upload was slow.
|
|
117
|
+
* - `response_wait_ms` much larger than the gateway time to first token,
|
|
118
|
+
* with small Junior phases: the delay was in the network or at the Vercel
|
|
119
|
+
* edge. The gateway sends headers with the first token. Give Vercel
|
|
120
|
+
* `app.ai.gateway.vercel_id`.
|
|
121
|
+
* - The same `service.instance.id` on more than one slow call: they shared
|
|
122
|
+
* one process.
|
|
106
123
|
*/
|
|
107
124
|
function subscribeGatewayRequestTiming() {
|
|
108
125
|
const handlers = Object.entries(createGatewayRequestTimingHandlers()).map(([name, handler]) => [name, (message) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ as withScope, d as setTag, f as setUser, h as startSpan, i as getActiveSpan, l as logger, n as captureMessage, p as spanToJSON, s as getTraceData, t as captureException } from "./sentry-BRTJqumy.js";
|
|
2
|
-
import { t as JUNIOR_VERSION } from "./version-
|
|
2
|
+
import { t as JUNIOR_VERSION } from "./version-EN3Wnq-R.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { styleText } from "node:util";
|
|
5
5
|
import { ConfigError, configureSync, getConfig, getLogger } from "@logtape/logtape";
|
|
@@ -1240,6 +1240,7 @@ function extractGenAiUsageAttributes(...sources) {
|
|
|
1240
1240
|
...outputTokens !== void 0 ? { "gen_ai.usage.output_tokens": outputTokens } : void 0,
|
|
1241
1241
|
...cachedInputTokens !== void 0 ? { "gen_ai.usage.cache_read.input_tokens": cachedInputTokens } : void 0,
|
|
1242
1242
|
...cacheCreationTokens !== void 0 ? { "gen_ai.usage.cache_creation.input_tokens": cacheCreationTokens } : void 0,
|
|
1243
|
+
...cachedInputTokens !== void 0 && semanticInputTokens ? { "gen_ai.usage.cache_hit_ratio": cachedInputTokens / semanticInputTokens } : void 0,
|
|
1243
1244
|
...reasoningTokens !== void 0 ? { "gen_ai.usage.reasoning.output_tokens": reasoningTokens } : void 0,
|
|
1244
1245
|
...cost?.input !== void 0 ? { "app.cost.input_usd": cost.input } : void 0,
|
|
1245
1246
|
...cost?.output !== void 0 ? { "app.cost.output_usd": cost.output } : void 0,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { v as __exportAll } from "./sentry-BRTJqumy.js";
|
|
2
|
-
import { Cn as renderUntrustedTag, Za as canAccessConversation, eo as readConversationAccessFromSql } from "./projection-
|
|
3
|
-
import { n as botConfig } from "./config-
|
|
4
|
-
import {
|
|
5
|
-
import { hn as toolInvocationDestination, in as AgentMessageTargetError, mn as actorFromRun, nn as AgentMessagePausedError } from "./agent-runner-
|
|
6
|
-
import { I as PARENT_AGENT_TARGET, v as getActiveAgentInvocationForConversation } from "./turn-failure-response-
|
|
7
|
-
import { G as admitAutomatedTurn, S as EVENT_WAIT_MS, V as postAutomatedTurnLimitNoticeForConversation } from "./session-stop-
|
|
8
|
-
import { r as appendAndEnqueueInboundMessage } from "./store-
|
|
9
|
-
import { a as enqueueAgentInvocation, c as createAgentInvocationForMessage, u as findChildAgentConversationId } from "./work-
|
|
10
|
-
import { r as enqueueAgentMessageToParent } from "./result-
|
|
2
|
+
import { Cn as renderUntrustedTag, Za as canAccessConversation, eo as readConversationAccessFromSql } from "./projection-B6VS7kbo.js";
|
|
3
|
+
import { n as botConfig } from "./config-CCPHvTqx.js";
|
|
4
|
+
import { M as SYSTEM_IDENTITY_ID, a as getConversationStore, o as getDb } from "./db-C1M1y-bh.js";
|
|
5
|
+
import { hn as toolInvocationDestination, in as AgentMessageTargetError, mn as actorFromRun, nn as AgentMessagePausedError } from "./agent-runner-HoQiUKLL.js";
|
|
6
|
+
import { I as PARENT_AGENT_TARGET, v as getActiveAgentInvocationForConversation } from "./turn-failure-response-pXhZ2wMK.js";
|
|
7
|
+
import { G as admitAutomatedTurn, S as EVENT_WAIT_MS, V as postAutomatedTurnLimitNoticeForConversation } from "./session-stop-hYNTNpVf.js";
|
|
8
|
+
import { r as appendAndEnqueueInboundMessage } from "./store-CZ9vqR4P.js";
|
|
9
|
+
import { a as enqueueAgentInvocation, c as createAgentInvocationForMessage, u as findChildAgentConversationId } from "./work-EA98F0ia.js";
|
|
10
|
+
import { r as enqueueAgentMessageToParent } from "./result-CEqQFrEf.js";
|
|
11
11
|
// src/chat/agent-invocations/top-level-message.ts
|
|
12
12
|
const AGENT_MESSAGE_EVENT_NAMESPACE = "junior";
|
|
13
13
|
/** Event type of a message from another top-level agent. */
|
package/dist/nitro.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as JuniorDashboardOptions } from "./app
|
|
2
|
-
import { n as JuniorPluginSet } from "./plugins-
|
|
1
|
+
import { i as JuniorDashboardOptions } from "./app-C75Ft-A_.js";
|
|
2
|
+
import { n as JuniorPluginSet } from "./plugins-B_0Cr0MO.js";
|
|
3
3
|
import { withSentryConfig as withSentryConfig$1 } from "@sentry/nitro";
|
|
4
4
|
type SentryNitroConfig = Parameters<typeof withSentryConfig$1>[0];
|
|
5
5
|
type SentryNitroOptions = NonNullable<Parameters<typeof withSentryConfig$1>[1]>;
|
package/dist/nitro.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as JUNIOR_CONTEXT_COMPACTION_CALLBACK_ROUTE, D as JUNIOR_AUTO_ARCHIVE_CRON_SCHEDULE, F as JUNIOR_RETENTION_CRON_SCHEDULE, I as JUNIOR_RETENTION_ROUTE, L as JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, M as JUNIOR_HEARTBEAT_CRON_SCHEDULE, N as JUNIOR_HEARTBEAT_ROUTE, O as JUNIOR_AUTO_ARCHIVE_ROUTE, P as JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE, j as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, k as JUNIOR_CACHE_WARMUP_CALLBACK_ROUTE, z as getDeploymentServiceVersion } from "./logging-
|
|
1
|
+
import { A as JUNIOR_CONTEXT_COMPACTION_CALLBACK_ROUTE, D as JUNIOR_AUTO_ARCHIVE_CRON_SCHEDULE, F as JUNIOR_RETENTION_CRON_SCHEDULE, I as JUNIOR_RETENTION_ROUTE, L as JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, M as JUNIOR_HEARTBEAT_CRON_SCHEDULE, N as JUNIOR_HEARTBEAT_ROUTE, O as JUNIOR_AUTO_ARCHIVE_ROUTE, P as JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE, j as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, k as JUNIOR_CACHE_WARMUP_CALLBACK_ROUTE, z as getDeploymentServiceVersion } from "./logging-D0svFM8r.js";
|
|
2
2
|
import { d as resolvePackageDir, t as discoverInstalledPluginPackageContent, u as isValidPackageName } from "./package-discovery-DJhGdS4c.js";
|
|
3
|
-
import { S as CACHE_WARMUP_QUEUE_TOPIC, _ as resolveConversationWorkQueueTopic, a as PLUGIN_TASK_QUEUE_TOPIC, f as WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC, t as BACKGROUND_COMPACTION_QUEUE_TOPIC } from "./background-compaction-queue-
|
|
3
|
+
import { S as CACHE_WARMUP_QUEUE_TOPIC, _ as resolveConversationWorkQueueTopic, a as PLUGIN_TASK_QUEUE_TOPIC, f as WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC, t as BACKGROUND_COMPACTION_QUEUE_TOPIC } from "./background-compaction-queue-Cre1wFt9.js";
|
|
4
4
|
import { a as pluginRuntimeRegistrationsFromPluginSet, r as pluginCatalogConfigFromPluginSet } from "./plugins-HYh_JOdw.js";
|
|
5
5
|
import { n as loadPluginSetFromModule, r as resolvePluginModule } from "./plugin-module-Cf5gVPWP.js";
|
|
6
6
|
import path from "node:path";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { En as createUserTokenStore } from "./projection-
|
|
2
|
-
import { a as GET, n as syncLocalOAuthCredential, r as GET$1 } from "./credential-sync-
|
|
1
|
+
import { En as createUserTokenStore } from "./projection-B6VS7kbo.js";
|
|
2
|
+
import { a as GET, n as syncLocalOAuthCredential, r as GET$1 } from "./credential-sync-DwLkIvXI.js";
|
|
3
3
|
import { createServer } from "node:http";
|
|
4
4
|
// src/chat/local/oauth-callback-server.ts
|
|
5
5
|
const LOCAL_OAUTH_TIMEOUT_MS = 6e5;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { v as __exportAll } from "./sentry-BRTJqumy.js";
|
|
2
|
+
import { t as readJuniorSecret } from "./secrets-DebYU866.js";
|
|
2
3
|
import { randomBytes } from "node:crypto";
|
|
3
4
|
import * as z from "zod";
|
|
4
5
|
import { SignJWT, jwtVerify } from "jose";
|
|
@@ -19,7 +20,7 @@ const localOAuthRelayPayloadSchema = z.object({
|
|
|
19
20
|
}).strict();
|
|
20
21
|
/** Derive the HMAC key used only for signed local OAuth relay state. */
|
|
21
22
|
function relayKey() {
|
|
22
|
-
const secret =
|
|
23
|
+
const secret = readJuniorSecret();
|
|
23
24
|
if (!secret) throw new Error("Local OAuth requires JUNIOR_SECRET");
|
|
24
25
|
return new TextEncoder().encode(secret);
|
|
25
26
|
}
|