@sentry/junior 0.287.0 → 0.288.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/{adapter-CL-HUKgd.js → adapter-Cikcqdty.js} +1 -1
- package/dist/{admin-C9urXVfi.js → admin-BcSxHuTB.js} +2 -2
- package/dist/{agent-runner-Bfnw551N.js → agent-runner-9MXyWUL8.js} +173 -89
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +8 -7
- package/dist/api.d.ts +1 -1
- package/dist/api.js +403 -40
- package/dist/{app-DBY5TnfY.d.ts → app-BUklJVBe.d.ts} +4 -2
- package/dist/app.d.ts +1 -1
- package/dist/app.js +521 -70
- package/dist/{assistant-reply-u_PRYzuz.js → assistant-reply-mj47jMRV.js} +1 -1
- package/dist/{automation-DksGNDRO.js → automation-DDXwHQs5.js} +2 -2
- package/dist/{background-compaction-queue-CYI909P5.js → background-compaction-queue-CjllSPir.js} +161 -90
- package/dist/{briefs-DaXiMWzT.js → briefs-DW9iuolG.js} +4 -3
- package/dist/{catalog-runtime-BCIuBe4d.js → catalog-runtime-B3gfH58M.js} +1 -1
- package/dist/cli/chat.js +14 -14
- package/dist/cli/check.js +3 -3
- package/dist/cli/main.js +3 -3
- package/dist/cli/plugins.js +4 -4
- package/dist/cli/snapshot-create.js +4 -4
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +3 -3
- package/dist/{config-CkHcUMN7.js → config-CLJcyYEF.js} +401 -9
- package/dist/{connections-BnIj0wtx.js → connections-BtdJftow.js} +9 -9
- package/dist/{conversation-E7ZPJx2H.js → conversation-DhoqHtQ7.js} +23 -6
- package/dist/{conversation-pending-messages-DVch6YQw.js → conversation-pending-messages-DHV0S4uF.js} +1 -1
- package/dist/{conversation-privacy-DF1hW0ja.js → conversation-privacy-BPirIVlX.js} +1 -1
- package/dist/core-model-BTt5E5b0.js +182 -0
- package/dist/{credential-sync-CzMar9hq.js → credential-sync-Co8Q2xRW.js} +28 -20
- package/dist/{db-DJ11eZqq.js → db-Co7DTYYh.js} +30 -20
- package/dist/{db-YDKKDxlh.d.ts → db-zIs8-Ba3.d.ts} +6 -2
- package/dist/{executor-BY9TB31g.js → executor-m0kIN71Q.js} +93 -12
- package/dist/{media-Cz1ZiV1U.js → history-IjdmO_r6.js} +6 -86
- package/dist/instrumentation.js +2 -2
- package/dist/{logging-BO5zU6Mt.js → logging-DbD-dErY.js} +3 -2
- package/dist/media-BAHvgkok.js +85 -0
- package/dist/{message-CsUbuEc8.js → message-DKTdTYm-.js} +9 -9
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +19 -41
- package/dist/{oauth-callback-server-hiDKK0_n.js → oauth-callback-server-CpbepSbp.js} +2 -2
- package/dist/{projection-CL_YWeGf.js → projection-BViECfYu.js} +309 -616
- package/dist/{prompt-BHOEQSmf.js → prompt-KT6MaDHN.js} +2 -182
- package/dist/{registry-BriFLnaJ.js → registry-D-Acyjhh.js} +1 -1
- package/dist/{resolve-Bt6GgAiA.js → resolve-gkT2R66z.js} +3 -3
- package/dist/{result-Bo1TZu0Q.js → result-DHmCFEt8.js} +8 -8
- package/dist/{runner-D3YeCQgt.js → runner-DBKjGjH-.js} +8 -8
- package/dist/{sandbox-egress-signals-CcnSPP4S.js → sandbox-egress-signals-9n8hqx29.js} +1 -1
- package/dist/{schedule-BTp__wrw.js → schedule-cP0AACm1.js} +11 -2
- package/dist/{schema-C6fsEwjo.d.ts → schema-B_6aOcx5.d.ts} +114 -3
- package/dist/{schema-BWE3RJEB.js → schema-DxicIQbc.js} +66 -13
- package/dist/{service-account-r6fl0b-9.js → service-account-Bi0HsY6w.js} +3 -3
- package/dist/{service-account-DiQQuuw7.js → service-account-CDlC9ssy.js} +3 -3
- package/dist/{session-stop-B2Nut40V.js → session-stop-BWOsuo8p.js} +56 -14
- package/dist/{skills-CD5aJdzg.js → skills-DO5K68Rq.js} +2 -2
- package/dist/{spawn-CalgZQiu.js → spawn-BBqZDcPa.js} +5 -5
- package/dist/{stop-kujZLbi0.js → stop-WC97cmHz.js} +802 -338
- package/dist/{store-DdIEUL1q.js → store-ByR1Lr7e.js} +4 -16
- package/dist/{task-runner-D_RDr2Hu.js → task-runner-B-Ewf8TX.js} +30 -22
- package/dist/{turn-failure-response-B5nV1Er-.js → turn-failure-response-CpdPoZSl.js} +18 -9
- package/dist/{validation-K4pqwoVZ.js → validation-B4sbIoES.js} +1 -1
- package/dist/{version-DBvhk1X9.js → version-D6lpuAgL.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-DrMmFUul.js → viewer-CeP27tC3.js} +4 -4
- package/dist/warmup-P_GJCL1c.js +767 -0
- package/dist/{work-ljRoODGu.js → work-DI7x1Slm.js} +14 -13
- package/dist/{worker-CYO1Q0Js.js → worker-CYPTOT4j.js} +6 -6
- package/migrations/0089_conversation_paused_status.sql +3 -0
- package/migrations/0090_guardian_review_time_index.sql +20 -0
- package/migrations/meta/0089_snapshot.json +4372 -0
- package/migrations/meta/0090_snapshot.json +4388 -0
- package/migrations/meta/_journal.json +14 -0
- package/package.json +5 -4
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { C as completeText$1, S as completeObject$1, x as completeDecision$1 } from "./config-CLJcyYEF.js";
|
|
2
|
+
import { _ as runBestEffort, a as extractGenAiUsageSummary } from "./logging-DbD-dErY.js";
|
|
3
|
+
import { W as agentTurnCostUsd, r as getConversationEventStore } from "./db-Co7DTYYh.js";
|
|
4
|
+
import * as z from "zod";
|
|
5
|
+
import { conversationEventPresentationSchema, defineConversationEvent } from "@sentry/junior-plugin-api";
|
|
6
|
+
// src/chat/conversations/structured-events.ts
|
|
7
|
+
/** Reserved namespace for Junior-owned conversation metadata events. */
|
|
8
|
+
const JUNIOR_NATIVE_EVENT_NAMESPACE = "junior";
|
|
9
|
+
const authenticationEventContentSchema = z.object({
|
|
10
|
+
accountLabel: z.string().trim().min(1).max(120).optional(),
|
|
11
|
+
actorId: z.string().min(1),
|
|
12
|
+
authorizationId: z.string().min(1).optional(),
|
|
13
|
+
provider: z.string().regex(/^[a-z][a-z0-9-]*$/),
|
|
14
|
+
providerLabel: z.string().trim().min(1).max(80).optional()
|
|
15
|
+
}).strict();
|
|
16
|
+
const agentsInstructionsUpdatedContentSchema = z.object({
|
|
17
|
+
action: z.enum([
|
|
18
|
+
"loaded",
|
|
19
|
+
"replaced",
|
|
20
|
+
"cleared"
|
|
21
|
+
]),
|
|
22
|
+
directory: z.string().trim().min(1).max(500).optional(),
|
|
23
|
+
fingerprint: z.string().trim().min(1).max(128),
|
|
24
|
+
sources: z.array(z.object({
|
|
25
|
+
content: z.string().min(1).max(32768),
|
|
26
|
+
path: z.string().trim().min(1).max(500)
|
|
27
|
+
}).strict()).max(32),
|
|
28
|
+
textBytes: z.number().int().nonnegative().optional()
|
|
29
|
+
}).strict();
|
|
30
|
+
function providerTitle(content) {
|
|
31
|
+
return content.providerLabel?.trim() || content.provider;
|
|
32
|
+
}
|
|
33
|
+
function agentsInstructionsTitle(action) {
|
|
34
|
+
if (action === "loaded") return "Loaded AGENTS.md";
|
|
35
|
+
if (action === "replaced") return "Updated AGENTS.md";
|
|
36
|
+
return "Cleared AGENTS.md";
|
|
37
|
+
}
|
|
38
|
+
function sourceFilename(sourcePath) {
|
|
39
|
+
return sourcePath.split("/").at(-1) || sourcePath;
|
|
40
|
+
}
|
|
41
|
+
function formatBytes(bytes) {
|
|
42
|
+
if (bytes < 1024) return `${bytes} bytes`;
|
|
43
|
+
const kilobytes = bytes / 1024;
|
|
44
|
+
return `${Number.isInteger(kilobytes) ? kilobytes : kilobytes.toFixed(1)} KB`;
|
|
45
|
+
}
|
|
46
|
+
function agentsInstructionsPreview(content) {
|
|
47
|
+
const source = content.sources[0];
|
|
48
|
+
if (!source) return void 0;
|
|
49
|
+
const filename = sourceFilename(source.path);
|
|
50
|
+
const label = content.sources.length === 1 ? filename : `${content.sources.length} AGENTS.md files`;
|
|
51
|
+
return typeof content.textBytes === "number" ? `${label} · ${formatBytes(content.textBytes)}` : label;
|
|
52
|
+
}
|
|
53
|
+
/** Junior-owned account-link transcript event. */
|
|
54
|
+
const authenticationLinkedEvent = defineConversationEvent({
|
|
55
|
+
name: "authentication_linked",
|
|
56
|
+
version: 1,
|
|
57
|
+
schema: authenticationEventContentSchema,
|
|
58
|
+
renderEvent(event) {
|
|
59
|
+
const provider = providerTitle(event);
|
|
60
|
+
return {
|
|
61
|
+
icon: "link",
|
|
62
|
+
title: `${provider} connected`,
|
|
63
|
+
...event.accountLabel ? { preview: `Connected as \`${event.accountLabel}\`` } : void 0,
|
|
64
|
+
details: [{
|
|
65
|
+
title: `${provider} connected`,
|
|
66
|
+
...event.accountLabel ? { description: `Connected as \`${event.accountLabel}\`` } : void 0,
|
|
67
|
+
metadata: [event.provider]
|
|
68
|
+
}]
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
/** Junior-owned account-unlink transcript event. */
|
|
73
|
+
const authenticationUnlinkedEvent = defineConversationEvent({
|
|
74
|
+
name: "authentication_unlinked",
|
|
75
|
+
version: 1,
|
|
76
|
+
schema: authenticationEventContentSchema,
|
|
77
|
+
renderEvent(event) {
|
|
78
|
+
const provider = providerTitle(event);
|
|
79
|
+
return {
|
|
80
|
+
icon: "key",
|
|
81
|
+
title: `${provider} disconnected`,
|
|
82
|
+
details: [{
|
|
83
|
+
title: `${provider} disconnected`,
|
|
84
|
+
metadata: [event.provider]
|
|
85
|
+
}]
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
/** Junior-owned AGENTS.md bootstrap transition for the dashboard timeline. */
|
|
90
|
+
const agentsInstructionsUpdatedEvent = defineConversationEvent({
|
|
91
|
+
name: "agents_instructions_updated",
|
|
92
|
+
version: 1,
|
|
93
|
+
schema: agentsInstructionsUpdatedContentSchema,
|
|
94
|
+
renderEvent(event) {
|
|
95
|
+
const title = agentsInstructionsTitle(event.action);
|
|
96
|
+
const preview = agentsInstructionsPreview(event);
|
|
97
|
+
return {
|
|
98
|
+
icon: "brain",
|
|
99
|
+
title,
|
|
100
|
+
...preview ? { preview } : void 0,
|
|
101
|
+
...event.sources.length > 0 ? { details: event.sources.map((source) => ({
|
|
102
|
+
title: sourceFilename(source.path),
|
|
103
|
+
content: source.content
|
|
104
|
+
})) } : void 0
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
/** Core-written Conversation note. `notes.ts` owns when the model sees it. */
|
|
109
|
+
const conversationNoteEvent = defineConversationEvent({
|
|
110
|
+
name: "conversation_note",
|
|
111
|
+
version: 1,
|
|
112
|
+
schema: z.object({ text: z.string().trim().min(1).max(500) }).strict(),
|
|
113
|
+
renderEvent(event) {
|
|
114
|
+
return {
|
|
115
|
+
icon: "info",
|
|
116
|
+
title: "Note for the next Turn",
|
|
117
|
+
preview: event.text
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
const NATIVE_EVENT_DEFINITIONS = [
|
|
122
|
+
authenticationLinkedEvent,
|
|
123
|
+
authenticationUnlinkedEvent,
|
|
124
|
+
agentsInstructionsUpdatedEvent,
|
|
125
|
+
conversationNoteEvent
|
|
126
|
+
];
|
|
127
|
+
/** Resolve a registered Junior-native conversation event definition. */
|
|
128
|
+
function getJuniorNativeEventDefinition(args) {
|
|
129
|
+
return NATIVE_EVENT_DEFINITIONS.find((definition) => definition.eventName === args.name && definition.version === args.version);
|
|
130
|
+
}
|
|
131
|
+
/** Render one Junior-native event through its active definition. */
|
|
132
|
+
function renderJuniorNativeConversationEvent(args) {
|
|
133
|
+
if (args.namespace !== "junior") return void 0;
|
|
134
|
+
const definition = getJuniorNativeEventDefinition(args);
|
|
135
|
+
if (!definition) return void 0;
|
|
136
|
+
const presentation = definition.renderEvent(definition.parse(args.content));
|
|
137
|
+
return presentation === void 0 ? void 0 : conversationEventPresentationSchema.parse(presentation);
|
|
138
|
+
}
|
|
139
|
+
// src/chat/core-model.ts
|
|
140
|
+
function gatewayParams(params) {
|
|
141
|
+
const { cost: _cost, operation, ...rest } = params;
|
|
142
|
+
return {
|
|
143
|
+
...rest,
|
|
144
|
+
promptName: `junior.${operation}`
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
async function recordCost(attribution, costUsd) {
|
|
148
|
+
const { cost, operation } = attribution;
|
|
149
|
+
if (costUsd === void 0 || !("conversationId" in cost)) return;
|
|
150
|
+
await runBestEffort(async () => {
|
|
151
|
+
await getConversationEventStore().append(cost.conversationId, [{
|
|
152
|
+
createdAtMs: Date.now(),
|
|
153
|
+
data: {
|
|
154
|
+
type: "structured_event",
|
|
155
|
+
namespace: JUNIOR_NATIVE_EVENT_NAMESPACE,
|
|
156
|
+
name: operation,
|
|
157
|
+
version: 1,
|
|
158
|
+
...cost.turnId ? { turnId: cost.turnId } : void 0,
|
|
159
|
+
content: { costUsd }
|
|
160
|
+
}
|
|
161
|
+
}], { activity: "preserve" });
|
|
162
|
+
}, "model_cost.record.failed", { "gen_ai.prompt.name": `junior.${operation}` });
|
|
163
|
+
}
|
|
164
|
+
/** Run a text completion and attribute its cost. */
|
|
165
|
+
async function completeText(params) {
|
|
166
|
+
const result = await completeText$1(gatewayParams(params));
|
|
167
|
+
await recordCost(params, agentTurnCostUsd(extractGenAiUsageSummary(result.message)));
|
|
168
|
+
return result;
|
|
169
|
+
}
|
|
170
|
+
/** Run a schema-constrained completion and attribute its cost. */
|
|
171
|
+
async function completeObject(params) {
|
|
172
|
+
const result = await completeObject$1(gatewayParams(params));
|
|
173
|
+
await recordCost(params, result.costUsd);
|
|
174
|
+
return result;
|
|
175
|
+
}
|
|
176
|
+
/** Answer decision questions and attribute the cost. */
|
|
177
|
+
async function completeDecision(params) {
|
|
178
|
+
const result = await completeDecision$1(gatewayParams(params));
|
|
179
|
+
await recordCost(params, result.costUsd);
|
|
180
|
+
return result;
|
|
181
|
+
}
|
|
182
|
+
export { agentsInstructionsUpdatedEvent as a, conversationNoteEvent as c, JUNIOR_NATIVE_EVENT_NAMESPACE as i, renderJuniorNativeConversationEvent as l, completeObject as n, authenticationLinkedEvent as o, completeText as r, authenticationUnlinkedEvent as s, completeDecision as t };
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { Ai as parseOAuthStatePayload, Dn as createUserTokenStore, Gi as postSlackMessage, Q as getConversationPendingAuth, d as recordAuthorizationCompleted, ji as resolveBaseUrl, jn as resolvePluginOAuthAccount, ki as formatProviderLabel, na as getSlackClient, st as getTurnRecord, u as recordAuthenticationLinked } from "./projection-BViECfYu.js";
|
|
2
|
+
import { R as escapeXml, a as getRuntimeMetadata, n as botConfig } from "./config-CLJcyYEF.js";
|
|
3
|
+
import { W as isNativeIdentityProvider, _ as runBestEffort, h as logWarn, p as logException } from "./logging-DbD-dErY.js";
|
|
4
4
|
import { p as parseSlackUserId } from "./actor-6jsm_v96.js";
|
|
5
|
-
import { D as resolveActorIdentityId, F as upsertLinkedIdentity, j as findUserByVerifiedEmails, s as getSqlExecutor } from "./db-
|
|
5
|
+
import { D as resolveActorIdentityId, F as upsertLinkedIdentity, j as findUserByVerifiedEmails, s as getSqlExecutor } from "./db-Co7DTYYh.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 { a as finalizeMcpAuthorization, d as getMcpStoredOAuthCredentials, f as putMcpStoredOAuthCredentials, o as deleteMcpAuthSession, u as getMcpAuthSession, y as lookupSlackUserProfile
|
|
7
|
+
import { n as buildOAuthTokenRequest, r as parseOAuthTokenResponse, u as hasRequiredOAuthScope } from "./registry-D-Acyjhh.js";
|
|
8
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-B3gfH58M.js";
|
|
9
|
+
import { t as discoverSkills } from "./skills-DO5K68Rq.js";
|
|
10
|
+
import { Bt as deleteWebAuthorization, a as finalizeMcpAuthorization, d as getMcpStoredOAuthCredentials, f as putMcpStoredOAuthCredentials, o as deleteMcpAuthSession, u as getMcpAuthSession, y as lookupSlackUserProfile } from "./agent-runner-9MXyWUL8.js";
|
|
11
11
|
import { r as acquireActiveLock } from "./locks-D-0h111u.js";
|
|
12
|
-
import { o as readIdentityById } from "./viewer-
|
|
13
|
-
import { r as getStateAdapter } from "./adapter-
|
|
14
|
-
import { _t as getPersistedThreadState, bt as coerceThreadConversationState } from "./task-runner-
|
|
15
|
-
import { _ as getMcpProviderErrorAttributes } from "./service-account-
|
|
16
|
-
import { d as wakePausedTurn, i as readConnectedOAuthTokens, s as htmlCallbackResponse, u as wakeAuthorizedTurn } from "./connections-
|
|
12
|
+
import { o as readIdentityById } from "./viewer-CeP27tC3.js";
|
|
13
|
+
import { r as getStateAdapter } from "./adapter-Cikcqdty.js";
|
|
14
|
+
import { _t as getPersistedThreadState, bt as coerceThreadConversationState } from "./task-runner-B-Ewf8TX.js";
|
|
15
|
+
import { _ as getMcpProviderErrorAttributes } from "./service-account-CDlC9ssy.js";
|
|
16
|
+
import { d as wakePausedTurn, i as readConnectedOAuthTokens, s as htmlCallbackResponse, u as wakeAuthorizedTurn } from "./connections-BtdJftow.js";
|
|
17
17
|
import { n as relayLocalOAuthCallback } from "./oauth-relay-D6xxVywK.js";
|
|
18
18
|
import path from "node:path";
|
|
19
19
|
import { createHmac, createSecretKey, timingSafeEqual } from "node:crypto";
|
|
@@ -51,6 +51,11 @@ function callbackPages(botName) {
|
|
|
51
51
|
message: `This authorization link is no longer active. Return to ${botName} and retry the original request.`,
|
|
52
52
|
status: 400
|
|
53
53
|
},
|
|
54
|
+
connected: {
|
|
55
|
+
title: "Authorization complete",
|
|
56
|
+
message: `Your MCP access is connected. The request that asked for it no longer waits, so ask ${botName} again when you need it.`,
|
|
57
|
+
status: 200
|
|
58
|
+
},
|
|
54
59
|
success: {
|
|
55
60
|
title: "Authorization complete",
|
|
56
61
|
message: `Your MCP access is connected. ${botName} will continue the paused request.`,
|
|
@@ -79,7 +84,7 @@ function htmlResponse(kind, options) {
|
|
|
79
84
|
...pages.success,
|
|
80
85
|
message: `Your MCP access is connected. ${botName} will continue the paused request in the local client.`
|
|
81
86
|
} : pages[kind];
|
|
82
|
-
const footerMessage = kind === "success" && !options?.local ? `You can close this tab and return to ${botName}.` : void 0;
|
|
87
|
+
const footerMessage = (kind === "success" || kind === "connected") && !options?.local ? `You can close this tab and return to ${botName}.` : void 0;
|
|
83
88
|
return htmlCallbackResponse(page.title, page.message, page.status, { footerMessage });
|
|
84
89
|
}
|
|
85
90
|
/** Queue the exact MCP authorization attempt without changing thread state. */
|
|
@@ -102,9 +107,9 @@ async function wakeAuthorizedMcpTurn(args) {
|
|
|
102
107
|
})
|
|
103
108
|
}, args.queue);
|
|
104
109
|
}
|
|
105
|
-
async function
|
|
110
|
+
async function readMcpAuthorizationAttempt(authSession, provider) {
|
|
106
111
|
const conversationId = mcpConversationId(authSession);
|
|
107
|
-
if (!conversationId) return
|
|
112
|
+
if (!conversationId) return "expired";
|
|
108
113
|
const currentState = await getPersistedThreadState(conversationId);
|
|
109
114
|
const conversation = coerceThreadConversationState(currentState);
|
|
110
115
|
const pendingAuth = getConversationPendingAuth({
|
|
@@ -113,13 +118,14 @@ async function isCurrentMcpAuthorizationAttempt(authSession, provider) {
|
|
|
113
118
|
provider,
|
|
114
119
|
actorId: authSession.userId
|
|
115
120
|
});
|
|
116
|
-
|
|
121
|
+
if (!pendingAuth) return "ended";
|
|
122
|
+
return pendingAuth.authSessionId === authSession.authSessionId && pendingAuth.sessionId === authSession.sessionId ? "waiting" : "expired";
|
|
117
123
|
}
|
|
118
124
|
function mcpConversationId(authSession) {
|
|
119
125
|
if (authSession.destination?.platform === "local" || authSession.source?.kind === "web") return authSession.conversationId;
|
|
120
126
|
if (authSession.channelId && authSession.threadTs) return `slack:${authSession.channelId}:${authSession.threadTs}`;
|
|
121
127
|
}
|
|
122
|
-
/** Commit one shared credential mutation only while
|
|
128
|
+
/** Commit one shared credential mutation only while no newer attempt replaced this one. */
|
|
123
129
|
async function runCurrentMcpCredentialMutation(authSession, provider, mutation) {
|
|
124
130
|
const conversationId = mcpConversationId(authSession);
|
|
125
131
|
if (!conversationId) throw new McpOAuthAttemptExpiredError();
|
|
@@ -128,7 +134,7 @@ async function runCurrentMcpCredentialMutation(authSession, provider, mutation)
|
|
|
128
134
|
const lock = await acquireActiveLock(stateAdapter, conversationId);
|
|
129
135
|
if (!lock) throw new Error(`Could not acquire MCP OAuth callback lock for ${conversationId}`);
|
|
130
136
|
try {
|
|
131
|
-
if (
|
|
137
|
+
if (await readMcpAuthorizationAttempt(authSession, provider) === "expired") throw new McpOAuthAttemptExpiredError();
|
|
132
138
|
return await mutation();
|
|
133
139
|
} finally {
|
|
134
140
|
await stateAdapter.releaseLock(lock);
|
|
@@ -167,7 +173,8 @@ async function GET$1(request, provider, waitUntil, options) {
|
|
|
167
173
|
if (!code) return htmlResponse("missing_code");
|
|
168
174
|
try {
|
|
169
175
|
const pendingSession = await getMcpAuthSession(state);
|
|
170
|
-
|
|
176
|
+
const attempt = pendingSession?.provider === provider ? await readMcpAuthorizationAttempt(pendingSession, provider) : "expired";
|
|
177
|
+
if (!pendingSession || attempt === "expired") {
|
|
171
178
|
if (pendingSession) await deleteMcpAuthSession(pendingSession.authSessionId);
|
|
172
179
|
return htmlResponse("expired");
|
|
173
180
|
}
|
|
@@ -227,6 +234,7 @@ async function GET$1(request, provider, waitUntil, options) {
|
|
|
227
234
|
queue: options.conversationWorkQueue,
|
|
228
235
|
provider
|
|
229
236
|
});
|
|
237
|
+
if (attempt === "ended") return htmlResponse("connected");
|
|
230
238
|
return htmlResponse("success", { local: authSession.destination?.platform === "local" && authSession.source?.kind !== "web" });
|
|
231
239
|
} catch (callbackError) {
|
|
232
240
|
if (callbackError instanceof McpOAuthAttemptExpiredError) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { v as __exportAll } from "./sentry-BRTJqumy.js";
|
|
2
|
-
import { i as getChatConfig } from "./config-
|
|
3
|
-
import {
|
|
2
|
+
import { i as getChatConfig } from "./config-CLJcyYEF.js";
|
|
3
|
+
import { G as normalizeIdentityEmail, U as GOOGLE_IDENTITY_PROVIDER, h as logWarn } from "./logging-DbD-dErY.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-
|
|
6
|
-
import {
|
|
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-m0kIN71Q.js";
|
|
6
|
+
import { c as newConversationEventSchema, h as usageSchema, l as encodeHistoryPayload, o as decodeStoredConversationEvent, r as conversationEventDataSchema, s as historyReplacementSchema } from "./history-IjdmO_r6.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";
|
|
9
9
|
import { destinationSchema, locationSchema, sourceSchema } from "@sentry/junior-plugin-api";
|
|
@@ -353,12 +353,19 @@ function parseSessionSource(value) {
|
|
|
353
353
|
async function getConversationIdByProviderConversation(executor, args) {
|
|
354
354
|
return (await executor.db().select({ conversationId: juniorConversationBindings.conversationId }).from(juniorConversationBindings).where(and(eq(juniorConversationBindings.provider, args.provider), eq(juniorConversationBindings.providerTenantId, args.providerTenantId), eq(juniorConversationBindings.providerDestinationId, args.providerDestinationId), eq(juniorConversationBindings.providerConversationId, args.providerConversationId))).limit(1))[0]?.conversationId;
|
|
355
355
|
}
|
|
356
|
-
/**
|
|
357
|
-
|
|
358
|
-
|
|
356
|
+
/**
|
|
357
|
+
* Bind provider coordinates to a durable conversation unless another
|
|
358
|
+
* conversation has them. Return whether they belong to this conversation.
|
|
359
|
+
*/
|
|
360
|
+
async function claimProviderConversation(executor, args) {
|
|
361
|
+
return ((await executor.db().insert(juniorConversationBindings).values({
|
|
359
362
|
...args,
|
|
360
363
|
createdAt: /* @__PURE__ */ new Date()
|
|
361
|
-
}).onConflictDoNothing().returning({ conversationId: juniorConversationBindings.conversationId }))[0]?.conversationId ?? await getConversationIdByProviderConversation(executor, args))
|
|
364
|
+
}).onConflictDoNothing().returning({ conversationId: juniorConversationBindings.conversationId }))[0]?.conversationId ?? await getConversationIdByProviderConversation(executor, args)) === args.conversationId;
|
|
365
|
+
}
|
|
366
|
+
/** Bind provider coordinates to a durable conversation in the caller's SQL scope. */
|
|
367
|
+
async function bindProviderConversation(executor, args) {
|
|
368
|
+
if (!await claimProviderConversation(executor, args)) throw new Error("Provider conversation is already bound to another conversation");
|
|
362
369
|
}
|
|
363
370
|
// src/chat/identities/sql.ts
|
|
364
371
|
function dateFromMs$1(ms) {
|
|
@@ -872,9 +879,6 @@ function executionStatusFromValue(value) {
|
|
|
872
879
|
if (value === "failed" || value === "idle" || value === "pending" || value === "running") return value;
|
|
873
880
|
throw new Error("Conversation record execution status is invalid");
|
|
874
881
|
}
|
|
875
|
-
function executionStatusToSql(status) {
|
|
876
|
-
return status === "paused" ? "awaiting_resume" : status;
|
|
877
|
-
}
|
|
878
882
|
function destinationFromRow(destination) {
|
|
879
883
|
return parseDestination(destination?.provider === "slack" ? {
|
|
880
884
|
platform: "slack",
|
|
@@ -987,7 +991,8 @@ var SqlStore = class {
|
|
|
987
991
|
}),
|
|
988
992
|
kind: args.kind,
|
|
989
993
|
parentConversationId: args.parentConversationId,
|
|
990
|
-
...location ? { location } : void 0
|
|
994
|
+
...location ? { location } : void 0,
|
|
995
|
+
...args.title ? { title: args.title } : void 0
|
|
991
996
|
};
|
|
992
997
|
await this.upsertConversation({
|
|
993
998
|
conversation: child,
|
|
@@ -1183,7 +1188,7 @@ var SqlStore = class {
|
|
|
1183
1188
|
lastActivityAt: dateFromMs(conversation.lastActivityAtMs),
|
|
1184
1189
|
updatedAt: dateFromMs(conversation.updatedAtMs),
|
|
1185
1190
|
executionUpdatedAt: conversation.execution.updatedAtMs === void 0 ? null : dateFromMs(conversation.execution.updatedAtMs),
|
|
1186
|
-
executionStatus:
|
|
1191
|
+
executionStatus: conversation.execution.status,
|
|
1187
1192
|
runId: conversation.execution.runId ?? null,
|
|
1188
1193
|
lastCheckpointAt: conversation.execution.lastCheckpointAtMs === void 0 ? null : dateFromMs(conversation.execution.lastCheckpointAtMs),
|
|
1189
1194
|
lastEnqueuedAt: conversation.execution.lastEnqueuedAtMs === void 0 ? null : dateFromMs(conversation.execution.lastEnqueuedAtMs),
|
|
@@ -1641,18 +1646,23 @@ var SqlConversationEventStore = class {
|
|
|
1641
1646
|
return (await this.readCursor(conversationId)).maxHistoryVersion ?? 0;
|
|
1642
1647
|
}
|
|
1643
1648
|
async loadCurrentHistory(conversationId) {
|
|
1644
|
-
const
|
|
1645
|
-
|
|
1646
|
-
return (await
|
|
1649
|
+
const db = this.executor.db();
|
|
1650
|
+
const currentHistoryVersion = db.select({ historyVersion: sql`max(${juniorConversationEvents.historyVersion})` }).from(juniorConversationEvents).where(eq(juniorConversationEvents.conversationId, conversationId));
|
|
1651
|
+
return (await db.select().from(juniorConversationEvents).where(and(eq(juniorConversationEvents.conversationId, conversationId), eq(juniorConversationEvents.historyVersion, currentHistoryVersion))).orderBy(asc(juniorConversationEvents.seq))).map(eventFromRow);
|
|
1647
1652
|
}
|
|
1648
1653
|
async loadByIdempotencyKey(conversationId, idempotencyKey) {
|
|
1649
1654
|
const [row] = await this.executor.db().select().from(juniorConversationEvents).where(and(eq(juniorConversationEvents.conversationId, conversationId), eq(juniorConversationEvents.idempotencyKey, idempotencyKey))).limit(1);
|
|
1650
1655
|
return row ? eventFromRow(row) : void 0;
|
|
1651
1656
|
}
|
|
1657
|
+
async loadEventsAfter(conversationId, afterSeq) {
|
|
1658
|
+
return (await this.executor.db().select().from(juniorConversationEvents).where(and(eq(juniorConversationEvents.conversationId, conversationId), gt(juniorConversationEvents.seq, afterSeq))).orderBy(asc(juniorConversationEvents.seq))).map(eventFromRow);
|
|
1659
|
+
}
|
|
1652
1660
|
async loadHistoryContaining(conversationId, seq, throughSeq) {
|
|
1653
|
-
const
|
|
1654
|
-
|
|
1655
|
-
|
|
1661
|
+
const db = this.executor.db();
|
|
1662
|
+
const boundaryHistoryVersion = db.select({ historyVersion: juniorConversationEvents.historyVersion }).from(juniorConversationEvents).where(and(eq(juniorConversationEvents.conversationId, conversationId), eq(juniorConversationEvents.seq, seq)));
|
|
1663
|
+
const rows = await db.select().from(juniorConversationEvents).where(and(eq(juniorConversationEvents.conversationId, conversationId), eq(juniorConversationEvents.historyVersion, boundaryHistoryVersion), throughSeq === void 0 ? void 0 : lte(juniorConversationEvents.seq, Math.max(seq, throughSeq)))).orderBy(asc(juniorConversationEvents.seq));
|
|
1664
|
+
if (rows.length === 0) return void 0;
|
|
1665
|
+
return rows.filter((row) => throughSeq === void 0 || row.seq <= throughSeq).map(eventFromRow);
|
|
1656
1666
|
}
|
|
1657
1667
|
async loadLatestStructuredEvent(conversationId, namespace, name) {
|
|
1658
1668
|
const [row] = await this.executor.db().select().from(juniorConversationEvents).where(and(eq(juniorConversationEvents.conversationId, conversationId), eq(juniorConversationEvents.type, "structured_event"), sql`${juniorConversationEvents.payload}->>'namespace' = ${namespace}`, sql`${juniorConversationEvents.payload}->>'name' = ${name}`)).orderBy(desc(juniorConversationEvents.seq)).limit(1);
|
|
@@ -1903,4 +1913,4 @@ async function closeDb() {
|
|
|
1903
1913
|
current = void 0;
|
|
1904
1914
|
await previous?.db.close();
|
|
1905
1915
|
}
|
|
1906
|
-
export { deleteProviderIdentityForUser as A,
|
|
1916
|
+
export { deleteProviderIdentityForUser as A, conversationDetailTouch as B, setFirstConversationLocation as C, resolveActorIdentityId as D, findActorIdentityId as E, upsertLinkedIdentity as F, agentTurnTotalTokens as G, touchConversationDetail as H, bindProviderConversation as I, resolveRootConversationId as J, agentTurnUsageSchema as K, claimProviderConversation as L, readUserTimezone as M, recordGoogleSignIn as N, saveActorAvatar as O, saveUserTimezone as P, sameDestination as Q, getConversationIdByProviderConversation as R, locationFromRow as S, SYSTEM_IDENTITY_ID as T, addAgentTurnUsage as U, nextDetailVersion as V, agentTurnCostUsd as W, parseDestination as X, createSlackDestination as Y, requireSlackDestination as Z, setArchivedAt as _, getConversationStore as a, withConversationMutationLock as b, conversationIdsWithAnnotation as c, createSqlConversationEventStore as d, eventFromRow as f, readConversationTrees as g, conversationDescendants as h, getConversationMessageSearchStore as i, findUserByVerifiedEmails as j, deleteProviderIdentityForSlackUser as k, hasAnnotationKey as l, conversationAncestors as m, db_exports as n, getDb as o, withConversationEventLock as p, hasAgentTurnUsage as q, getConversationEventStore as r, getSqlExecutor as s, closeDb as t, treeHasAnnotationKey as u, loadConversationSlackTenantIds as v, startLocationThread as w, conversationKindFromRow as x, createSqlStore as y, parseSessionSource as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./schema-
|
|
1
|
+
import "./schema-B_6aOcx5.js";
|
|
2
2
|
import * as z from "zod";
|
|
3
3
|
import "drizzle-orm";
|
|
4
4
|
import { Destination, Source, locationSchema } from "@sentry/junior-plugin-api";
|
|
@@ -129,13 +129,17 @@ interface Conversation {
|
|
|
129
129
|
}
|
|
130
130
|
/** Persist and read durable conversation metadata for reporting surfaces. */
|
|
131
131
|
interface ConversationStore {
|
|
132
|
-
/**
|
|
132
|
+
/**
|
|
133
|
+
* Create one Conversation with an immutable parent and kind. `title` is
|
|
134
|
+
* saved only when the child is new.
|
|
135
|
+
*/
|
|
133
136
|
createChild(args: {
|
|
134
137
|
childConversationId: string;
|
|
135
138
|
kind: Exclude<ConversationKind, "root">;
|
|
136
139
|
parentConversationId: string;
|
|
137
140
|
nowMs?: number;
|
|
138
141
|
source?: ConversationSource;
|
|
142
|
+
title?: string;
|
|
139
143
|
}): Promise<void>;
|
|
140
144
|
get(args: {
|
|
141
145
|
conversationId: string;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import
|
|
1
|
+
import { _ as withScope } from "./sentry-BRTJqumy.js";
|
|
2
|
+
import "./config-CLJcyYEF.js";
|
|
3
|
+
import { p as logException } from "./logging-DbD-dErY.js";
|
|
3
4
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
5
|
import { sql } from "drizzle-orm";
|
|
5
6
|
import { bigint, boolean, check, date, doublePrecision, foreignKey, index, integer, jsonb, pgTable, primaryKey, text, timestamp, uniqueIndex, uuid } from "drizzle-orm/pg-core";
|
|
6
|
-
import { Pool } from "@neondatabase/serverless";
|
|
7
|
+
import { Pool, neon } from "@neondatabase/serverless";
|
|
7
8
|
import { drizzle } from "drizzle-orm/neon-serverless";
|
|
8
9
|
import { migrate } from "drizzle-orm/neon-serverless/migrator";
|
|
10
|
+
import { Agent } from "undici";
|
|
9
11
|
import pg from "pg";
|
|
10
12
|
import { drizzle as drizzle$1 } from "drizzle-orm/node-postgres";
|
|
11
13
|
import { migrate as migrate$1 } from "drizzle-orm/node-postgres/migrator";
|
|
@@ -53,7 +55,7 @@ const juniorUsers = pgTable("junior_users", {
|
|
|
53
55
|
timezone: text("timezone"),
|
|
54
56
|
/** Text the user saved to change how Junior replies to them. */
|
|
55
57
|
customization: text("customization"),
|
|
56
|
-
/**
|
|
58
|
+
/** Push notification hours. Null means the default schedule. */
|
|
57
59
|
notificationSchedule: jsonb("notification_schedule").$type(),
|
|
58
60
|
/** Junior-wide admin role. Only the `junior admin` CLI changes it. */
|
|
59
61
|
isAdmin: boolean("is_admin").notNull().default(false),
|
|
@@ -275,6 +277,7 @@ const juniorConversationEvents = pgTable("junior_conversation_events", {
|
|
|
275
277
|
index("junior_conversation_events_history_version_idx").on(table.conversationId, table.historyVersion, table.seq),
|
|
276
278
|
index("junior_conversation_events_type_idx").on(table.conversationId, table.type, table.seq),
|
|
277
279
|
index("junior_conversation_events_plugin_report_idx").on(sql`(${table.payload}->>'namespace')`, sql`(${table.payload}->>'name')`, table.createdAt).where(sql`${table.type} = 'structured_event'`),
|
|
280
|
+
index("junior_conversation_events_guardian_review_time_idx").on(table.createdAt).where(sql`${table.type} = 'guardian_action_reviewed'`),
|
|
278
281
|
index("junior_conversation_events_plugin_conversation_idx").on(table.conversationId, sql`(${table.payload}->>'namespace')`, sql`(${table.payload}->>'name')`, table.seq).where(sql`${table.type} = 'structured_event'`),
|
|
279
282
|
index("junior_conversation_events_actor_identity_idx").on(table.actorIdentityId, table.conversationId, table.seq),
|
|
280
283
|
index("junior_conversation_events_author_idx").on(table.conversationId, table.actorIdentityId, table.seq).where(sql`${table.actorIdentityId} is not null`),
|
|
@@ -757,13 +760,91 @@ const juniorSqlSchema = {
|
|
|
757
760
|
juniorWorkspaces
|
|
758
761
|
};
|
|
759
762
|
// src/db/neon.ts
|
|
763
|
+
/**
|
|
764
|
+
* Sends a pool query over Neon's SQL-over-HTTP endpoint when no idle
|
|
765
|
+
* WebSocket client is free.
|
|
766
|
+
*
|
|
767
|
+
* pg-pool reuses the newest idle client, so light polling keeps one or two
|
|
768
|
+
* clients warm and the rest idle out. A parallel read batch then opens about
|
|
769
|
+
* eight WebSockets, each with a new Postgres session. An HTTP query reuses the
|
|
770
|
+
* proxy's cached backend connection, so the batch skips that handshake. The
|
|
771
|
+
* warm path stays on WebSocket. `connect()` and transactions are unchanged.
|
|
772
|
+
*/
|
|
773
|
+
var OverflowPool = class extends Pool {
|
|
774
|
+
pendingAcquires = 0;
|
|
775
|
+
webSocketOnly = new AsyncLocalStorage();
|
|
776
|
+
sql;
|
|
777
|
+
dispatcher;
|
|
778
|
+
statementTimeoutMs;
|
|
779
|
+
constructor(args) {
|
|
780
|
+
super({
|
|
781
|
+
connectionString: args.connectionString,
|
|
782
|
+
max: 10,
|
|
783
|
+
idleTimeoutMillis: 6e4,
|
|
784
|
+
statement_timeout: args.statementTimeoutMs
|
|
785
|
+
});
|
|
786
|
+
this.sql = neon(args.connectionString, { fullResults: true });
|
|
787
|
+
this.dispatcher = args.dispatcher;
|
|
788
|
+
this.statementTimeoutMs = args.statementTimeoutMs;
|
|
789
|
+
}
|
|
790
|
+
query(input, values, callback) {
|
|
791
|
+
const query = typeof input === "string" ? { text: input } : input;
|
|
792
|
+
if (callback !== void 0 || typeof values === "function" || typeof query?.text !== "string" || "submit" in query) return super.query(input, values, callback);
|
|
793
|
+
const params = values ?? query.values ?? [];
|
|
794
|
+
if (this.webSocketOnly.getStore() || this.idleCount > this.pendingAcquires || this.totalCount === 0) return this.queryWebSocket(query, params);
|
|
795
|
+
return this.queryHttp(query, params);
|
|
796
|
+
}
|
|
797
|
+
/** Keep every pool query in `callback` on WebSocket. */
|
|
798
|
+
async onWebSocket(callback) {
|
|
799
|
+
return await this.webSocketOnly.run(true, callback);
|
|
800
|
+
}
|
|
801
|
+
async queryWebSocket(query, params) {
|
|
802
|
+
const client = await this.acquire();
|
|
803
|
+
try {
|
|
804
|
+
const result = await client.query({
|
|
805
|
+
...query,
|
|
806
|
+
values: params
|
|
807
|
+
});
|
|
808
|
+
client.release();
|
|
809
|
+
return result;
|
|
810
|
+
} catch (error) {
|
|
811
|
+
client.release(error);
|
|
812
|
+
throw error;
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
acquire() {
|
|
816
|
+
this.pendingAcquires++;
|
|
817
|
+
return new Promise((resolve, reject) => {
|
|
818
|
+
this.connect((error, client) => {
|
|
819
|
+
this.pendingAcquires--;
|
|
820
|
+
if (client) resolve(client);
|
|
821
|
+
else reject(error);
|
|
822
|
+
});
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
async queryHttp(query, params) {
|
|
826
|
+
const fetchOptions = { dispatcher: this.dispatcher };
|
|
827
|
+
if (this.statementTimeoutMs) fetchOptions.signal = AbortSignal.timeout(this.statementTimeoutMs);
|
|
828
|
+
return await withScope(async (scope) => {
|
|
829
|
+
scope.setAttributes({ "app.db.transport": "http" });
|
|
830
|
+
return await this.sql.query(query.text, params, {
|
|
831
|
+
arrayMode: query.rowMode === "array",
|
|
832
|
+
fullResults: true,
|
|
833
|
+
types: query.types ?? this.options.types,
|
|
834
|
+
fetchOptions
|
|
835
|
+
});
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
};
|
|
760
839
|
var NeonExecutor = class {
|
|
761
840
|
transactionClient = new AsyncLocalStorage();
|
|
762
841
|
savepointId = 0;
|
|
763
842
|
isolatedQueryId = 0;
|
|
764
843
|
pool;
|
|
765
|
-
|
|
844
|
+
dispatcher;
|
|
845
|
+
constructor(pool, dispatcher) {
|
|
766
846
|
this.pool = pool;
|
|
847
|
+
this.dispatcher = dispatcher;
|
|
767
848
|
}
|
|
768
849
|
db() {
|
|
769
850
|
return drizzle(this.queryClient(), { schema: juniorSqlSchema });
|
|
@@ -847,13 +928,14 @@ var NeonExecutor = class {
|
|
|
847
928
|
const lockName = `junior:migrate:${migrationTable}`;
|
|
848
929
|
try {
|
|
849
930
|
await client.query("SELECT pg_advisory_lock(hashtext($1))", [lockName]);
|
|
850
|
-
return await callback
|
|
931
|
+
return await this.pool.onWebSocket(callback);
|
|
851
932
|
} finally {
|
|
852
933
|
client.release(true);
|
|
853
934
|
}
|
|
854
935
|
}
|
|
855
936
|
async close() {
|
|
856
937
|
await this.pool.end();
|
|
938
|
+
await this.dispatcher.close();
|
|
857
939
|
}
|
|
858
940
|
queryClient() {
|
|
859
941
|
return this.transactionClient.getStore() ?? this.pool;
|
|
@@ -861,16 +943,15 @@ var NeonExecutor = class {
|
|
|
861
943
|
};
|
|
862
944
|
/** Create the shared Neon-backed Junior SQL executor. */
|
|
863
945
|
function createNeonJuniorSqlExecutor(args) {
|
|
864
|
-
const
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
statement_timeout: args.statementTimeoutMs
|
|
946
|
+
const dispatcher = new Agent({ allowH2: true });
|
|
947
|
+
const pool = new OverflowPool({
|
|
948
|
+
...args,
|
|
949
|
+
dispatcher
|
|
869
950
|
});
|
|
870
951
|
pool.on("error", (error) => {
|
|
871
952
|
logException(error, "db.pool.client.failed", { "app.db.driver": "neon" });
|
|
872
953
|
});
|
|
873
|
-
return new NeonExecutor(pool);
|
|
954
|
+
return new NeonExecutor(pool, dispatcher);
|
|
874
955
|
}
|
|
875
956
|
// src/db/postgres.ts
|
|
876
957
|
const { Pool: Pool$1 } = pg;
|