@sentry/junior 0.206.0 → 0.208.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-C9yuiZUF.js → agent-BfxfHsf1.js} +375 -346
- package/dist/{agent-hooks-DNjlz2A-.js → agent-hooks-CuGjLjmR.js} +224 -97
- package/dist/{agent-runner-E67lFrDG.js → agent-runner-Dz1PMKP0.js} +9 -9
- package/dist/api/schema.d.ts +39 -39
- package/dist/api/schema.js +2 -2
- package/dist/api.d.ts +1 -1
- package/dist/api.js +154 -154
- package/dist/{app-AxGmJHwK.d.ts → app-DfNrn_gS.d.ts} +2 -2
- package/dist/app.d.ts +1 -1
- package/dist/app.js +185 -183
- package/dist/{auth-pause-state-MVZ6xvEK.js → auth-pause-state-Bjoh8wCy.js} +7 -7
- package/dist/{briefs-CvJFQvhJ.js → briefs-q_onrGmf.js} +3 -3
- package/dist/{catalog-runtime-TBR8n4e1.js → catalog-runtime-D8YUMNhb.js} +1 -1
- package/dist/{checkpoint-BY47jJCB.js → checkpoint-FKMcINix.js} +8 -8
- package/dist/cli/chat.js +13 -13
- package/dist/cli/check.js +3 -3
- package/dist/cli/main.js +1 -1
- package/dist/cli/plugins.js +3 -3
- package/dist/cli/snapshot-create.js +3 -3
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +3 -3
- package/dist/{client-ceE7NtvC.js → client-bRyPqwAV.js} +4 -4
- package/dist/{config-CIE83sR2.js → config-EtF2uEaW.js} +6 -6
- package/dist/{context-B45_WqVX.js → context-Bplcgypl.js} +13 -13
- package/dist/{conversation-privacy-Auyq26XQ.js → conversation-privacy-whGaV2TG.js} +1 -1
- package/dist/{credential-sync-BO33aNQd.js → credential-sync-DM-EE1ey.js} +21 -21
- package/dist/{db-BeyXKJOI.d.ts → db-D74z7BZH.d.ts} +1 -1
- package/dist/{execution-stats-SiS2FLcv.js → execution-stats-C-f8zwMU.js} +77 -77
- package/dist/{executor-BfbYPW63.js → executor-BW5qp0jC.js} +43 -14
- package/dist/instrumentation.js +2 -2
- package/dist/{job-queue-CyTc24Es.js → job-queue-BIHNIEIX.js} +1 -1
- package/dist/{logging-D37bayDc.js → logging-sNS84Yuu.js} +1 -1
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +3 -3
- package/dist/{oauth-callback-server-BtfOeHTZ.js → oauth-callback-server-Co6D_yXP.js} +2 -2
- package/dist/{pending-auth-BPUzcs7n.js → pending-auth-CRJCt9Ux.js} +2 -2
- package/dist/{profile-CSixooTi.js → profile-BfLMVhWo.js} +4 -4
- package/dist/{prompt-3gqNY1Ka.js → prompt-x-0ZtTyb.js} +14 -14
- package/dist/{registry-DiR0-xRg.js → registry-Cyww_jnC.js} +2 -2
- package/dist/{resolve-Bn5q__9b.js → resolve-BApIFQXX.js} +2 -2
- package/dist/{runner-DFx3dIJH.js → runner-C9okx4GL.js} +10 -10
- package/dist/{sandbox-egress-signals-bwvjihxA.js → sandbox-egress-signals-BHfx0esj.js} +1 -1
- package/dist/{schema-8GXFfclK.js → schema-CwTeb-BF.js} +39 -39
- package/dist/{skills-BhM5qyCF.js → skills-DhL_wXEp.js} +2 -2
- package/dist/{spawn-Dk0PqdH6.js → spawn-msnzfE8_.js} +2 -2
- package/dist/{stats-DKRP4rsY.js → stats-Cq5w_Awk.js} +292 -268
- package/dist/{store-C5qxF2ac.d.ts → store-Det8MQ9g.d.ts} +1 -1
- package/dist/{task-queue-CdpTvu4R.js → task-queue-JfmWmpjS.js} +3 -3
- package/dist/{task-runner-alpjVSxQ.js → task-runner-Cm0gXoLH.js} +15 -15
- package/dist/{thread-state-CRK7aA41.js → thread-state-lw2QwQ-y.js} +5 -5
- package/dist/{turn-execution-XtyzIHog.js → turn-execution-C7K6lQp1.js} +3 -3
- package/dist/{turn-lifecycle-VbwZLfBv.js → turn-lifecycle-DVlJLwB0.js} +1 -1
- package/dist/{usage-D4A48Bdl.js → usage-BMuAlKIW.js} +2 -2
- package/dist/{validation-jn_46o4U.js → validation-BI-r3iQA.js} +1 -1
- package/dist/{version-DcfJxB4z.js → version-s6smK6lP.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{web-authorization-CsfLSfEs.js → web-authorization-C9MxPvXX.js} +1 -1
- package/dist/{web-input-BPp_sc7t.js → web-input-CwVlaLd0.js} +7 -109
- package/dist/{work-Di-ubSGg.js → work-BK0W1QAt.js} +9 -9
- package/dist/{worker-Cu_D5Mr8.js → worker-D-WWKHQD.js} +5 -5
- package/migrations/0041_automation_outcomes_backfill.sql +27 -0
- package/migrations/meta/0041_snapshot.json +3516 -0
- package/migrations/meta/_journal.json +7 -0
- package/package.json +5 -5
|
@@ -59,7 +59,7 @@ type Usage = z.output<typeof usageSchema>;
|
|
|
59
59
|
type AgentTurnUsage = Usage;
|
|
60
60
|
//#endregion
|
|
61
61
|
//#region src/chat/conversations/store.d.ts
|
|
62
|
-
type ConversationSource = "api" | "internal" | "local" | "plugin" | "
|
|
62
|
+
type ConversationSource = "api" | "internal" | "local" | "plugin" | "event" | "scheduler" | "slack" | "web";
|
|
63
63
|
type ConversationStatus = "paused" | "failed" | "idle" | "pending" | "running";
|
|
64
64
|
interface ConversationExecution {
|
|
65
65
|
lastCheckpointAtMs?: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { f as logWarn } from "./logging-
|
|
1
|
+
import { f as logWarn } from "./logging-sNS84Yuu.js";
|
|
2
2
|
import { a as signQueueMessage, i as QUEUE_SIGNATURE_MAX_AGE_MS, o as verifyQueueMessage, s as createVercelQueueClient } from "./vercel-queue-DIkVcfK4.js";
|
|
3
|
-
import { o as runWithTurnRequestDeadline } from "./job-queue-
|
|
3
|
+
import { o as runWithTurnRequestDeadline } from "./job-queue-BIHNIEIX.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { createHash } from "node:crypto";
|
|
6
6
|
import { handleCallback, registerDevConsumer } from "@vercel/queue";
|
|
@@ -110,7 +110,7 @@ function pluginTaskCallback() {
|
|
|
110
110
|
maxDeliveries: PLUGIN_TASK_MAX_DELIVERIES,
|
|
111
111
|
onRejected: logPluginTaskQueueMessageRejected,
|
|
112
112
|
run: async (message) => {
|
|
113
|
-
const { processPluginTask } = await import("./task-runner-
|
|
113
|
+
const { processPluginTask } = await import("./task-runner-Cm0gXoLH.js").then((n) => n.r);
|
|
114
114
|
await processPluginTask(message);
|
|
115
115
|
},
|
|
116
116
|
topic: PLUGIN_TASK_QUEUE_TOPIC,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
|
|
2
|
-
import { _ as parseSlackMessageTs, r as credentialSubjectSchema } from "./context-
|
|
3
|
-
import {
|
|
2
|
+
import { _ as parseSlackMessageTs, r as credentialSubjectSchema } from "./context-Bplcgypl.js";
|
|
3
|
+
import { At as createPluginConversationEvents, Gt as getDb, Q as readActorIdentity, Wt as getConversationStore, _t as createPluginState, bt as createPluginLogger, p as coreTaskRegistrations, pt as JUNIOR_THREAD_STATE_TTL_MS, u as getPlugins, vt as createPluginEmbedder, yt as createPluginModel } from "./agent-hooks-CuGjLjmR.js";
|
|
4
4
|
import { K as sameActorIdentity } from "./conversation-AA4R1VUn.js";
|
|
5
|
-
import { Dt as isToolResultError, Ot as isToolResultMessage, Q as hydrateConversationMessages, bt as getPiMessageRole, jt as stripRuntimeTurnContext, kt as normalizeToolNameFromResult, s as getTurnRecord, wt as instructionTextForProjection } from "./checkpoint-
|
|
6
|
-
import { w as getStateAdapter } from "./profile-
|
|
7
|
-
import { u as
|
|
8
|
-
import { r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-
|
|
9
|
-
import { i as pluginTaskParamsSchema, o as sendVercelPluginTask, r as pluginTaskId } from "./task-queue-
|
|
5
|
+
import { Dt as isToolResultError, Ot as isToolResultMessage, Q as hydrateConversationMessages, bt as getPiMessageRole, jt as stripRuntimeTurnContext, kt as normalizeToolNameFromResult, s as getTurnRecord, wt as instructionTextForProjection } from "./checkpoint-FKMcINix.js";
|
|
6
|
+
import { w as getStateAdapter } from "./profile-BfLMVhWo.js";
|
|
7
|
+
import { u as recordAutomationExecution } from "./execution-stats-C-f8zwMU.js";
|
|
8
|
+
import { r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-lw2QwQ-y.js";
|
|
9
|
+
import { i as pluginTaskParamsSchema, o as sendVercelPluginTask, r as pluginTaskId } from "./task-queue-JfmWmpjS.js";
|
|
10
10
|
import { z } from "zod";
|
|
11
11
|
import { createHash } from "node:crypto";
|
|
12
12
|
import { destinationSchema, destinationVisibilitySchema, isSlackDestination, pluginRunContextSchema, replyAttributionSchema, sourceSchema, taskOutcomeSchema } from "@sentry/junior-plugin-api";
|
|
@@ -233,14 +233,14 @@ async function markDispatchAwaitingResume(id) {
|
|
|
233
233
|
status: "awaiting_resume"
|
|
234
234
|
});
|
|
235
235
|
}
|
|
236
|
-
async function
|
|
236
|
+
async function recordEventAutomationExecution(previous, next, status) {
|
|
237
237
|
if (!next || next.status !== status || previous?.status === status) return;
|
|
238
238
|
if (next.plugin !== "junior") return;
|
|
239
|
-
const
|
|
240
|
-
if (!
|
|
239
|
+
const eventAutomationId = next.metadata?.eventAutomationId;
|
|
240
|
+
if (!eventAutomationId) return;
|
|
241
241
|
const conversationId = getDispatchConversationId(next);
|
|
242
242
|
const conversation = await getConversationStore().get({ conversationId });
|
|
243
|
-
await
|
|
243
|
+
await recordAutomationExecution("event", eventAutomationId, {
|
|
244
244
|
...conversation ? { conversationId } : void 0,
|
|
245
245
|
executionId: next.id,
|
|
246
246
|
nowMs: next.updatedAtMs,
|
|
@@ -256,7 +256,7 @@ async function markDispatchBlocked(id, errorMessage, resultMessageTs) {
|
|
|
256
256
|
...resultMessageTs ? { resultMessageTs } : void 0,
|
|
257
257
|
status: "blocked"
|
|
258
258
|
});
|
|
259
|
-
await
|
|
259
|
+
await recordEventAutomationExecution(previous, next, "blocked");
|
|
260
260
|
return next;
|
|
261
261
|
}
|
|
262
262
|
/** Project a completed turn and its accepted Slack message to the plugin API. */
|
|
@@ -268,7 +268,7 @@ async function markDispatchCompleted(id, resultMessageTs) {
|
|
|
268
268
|
...resultMessageTs ? { resultMessageTs } : void 0,
|
|
269
269
|
status: "completed"
|
|
270
270
|
});
|
|
271
|
-
await
|
|
271
|
+
await recordEventAutomationExecution(previous, next, "completed");
|
|
272
272
|
return next;
|
|
273
273
|
}
|
|
274
274
|
/** Project a terminal conversation turn failure to the plugin API. */
|
|
@@ -280,7 +280,7 @@ async function markDispatchFailed(id, errorMessage, resultMessageTs) {
|
|
|
280
280
|
...resultMessageTs ? { resultMessageTs } : void 0,
|
|
281
281
|
status: "failed"
|
|
282
282
|
});
|
|
283
|
-
await
|
|
283
|
+
await recordEventAutomationExecution(previous, next, "failed");
|
|
284
284
|
return next;
|
|
285
285
|
}
|
|
286
286
|
/** Remove a dispatch after its durable mailbox append has succeeded. */
|
|
@@ -345,7 +345,7 @@ function slackSourceForDestination(args) {
|
|
|
345
345
|
* Reads parent Conversations when this Conversation has no Destination.
|
|
346
346
|
*/
|
|
347
347
|
async function resolveConversationRouting(args) {
|
|
348
|
-
const conversationStore = args.conversationStore ?? (await import("./agent-hooks-
|
|
348
|
+
const conversationStore = args.conversationStore ?? (await import("./agent-hooks-CuGjLjmR.js").then((n) => n.Vt)).getConversationStore();
|
|
349
349
|
const chain = await loadConversationChain(args.conversationId, conversationStore);
|
|
350
350
|
let destination;
|
|
351
351
|
let source;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { F as isRecord, I as toOptionalNumber, L as toOptionalString } from "./logging-
|
|
2
|
-
import {
|
|
1
|
+
import { F as isRecord, I as toOptionalNumber, L as toOptionalString } from "./logging-sNS84Yuu.js";
|
|
2
|
+
import { Gt as getDb, pt as JUNIOR_THREAD_STATE_TTL_MS } from "./agent-hooks-CuGjLjmR.js";
|
|
3
3
|
import { n as juniorDestinations } from "./destinations-BeBiJeEM.js";
|
|
4
|
-
import { u as juniorLocationConfigurations } from "./executor-
|
|
5
|
-
import { $ as persistConversationMessages } from "./checkpoint-
|
|
6
|
-
import { w as getStateAdapter } from "./profile-
|
|
4
|
+
import { u as juniorLocationConfigurations } from "./executor-BW5qp0jC.js";
|
|
5
|
+
import { $ as persistConversationMessages } from "./checkpoint-FKMcINix.js";
|
|
6
|
+
import { w as getStateAdapter } from "./profile-BfLMVhWo.js";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
import { randomUUID } from "node:crypto";
|
|
9
9
|
import { and, eq, sql } from "drizzle-orm";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as runAgentWithTimeout } from "./agent-runner-
|
|
3
|
-
import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-
|
|
1
|
+
import { Ht as getConversationEventStore } from "./agent-hooks-CuGjLjmR.js";
|
|
2
|
+
import { n as runAgentWithTimeout } from "./agent-runner-Dz1PMKP0.js";
|
|
3
|
+
import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-DVlJLwB0.js";
|
|
4
4
|
//#region src/chat/runtime/turn-execution.ts
|
|
5
5
|
/** An error thrown while the agent advances a Run. */
|
|
6
6
|
var AgentRunError = class extends Error {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ht as getConversationEventStore } from "./agent-hooks-CuGjLjmR.js";
|
|
2
2
|
//#region src/chat/conversations/turn-lifecycle.ts
|
|
3
3
|
/** Persist correlated turn lifecycle facts with retry-safe terminal exclusion. */
|
|
4
4
|
var ConversationTurnLifecycleService = class {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { f as logWarn } from "./logging-
|
|
2
|
-
import { n as botConfig } from "./config-
|
|
1
|
+
import { f as logWarn } from "./logging-sNS84Yuu.js";
|
|
2
|
+
import { n as botConfig } from "./config-EtF2uEaW.js";
|
|
3
3
|
import { P as usageSchema } from "./conversation-AA4R1VUn.js";
|
|
4
4
|
const TITLE_PROMPTS = {
|
|
5
5
|
conversation: [
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
|
|
2
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime-
|
|
2
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-D8YUMNhb.js";
|
|
3
3
|
import { isDeepStrictEqual } from "node:util";
|
|
4
4
|
//#region src/chat/plugins/validation.ts
|
|
5
5
|
var validation_exports = /* @__PURE__ */ __exportAll({
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as JUNIOR_VERSION } from "./version-
|
|
1
|
+
import { t as JUNIOR_VERSION } from "./version-s6smK6lP.js";
|
|
2
2
|
export { JUNIOR_VERSION };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { w as getStateAdapter } from "./profile-
|
|
1
|
+
import { w as getStateAdapter } from "./profile-BfLMVhWo.js";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
//#region src/chat/conversations/web-authorization.ts
|
|
4
4
|
const WEB_AUTHORIZATION_PREFIX = "junior:web_authorization:v1";
|
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
import { f as logWarn } from "./logging-
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import "./
|
|
5
|
-
import {
|
|
6
|
-
import { n as juniorDestinations } from "./destinations-BeBiJeEM.js";
|
|
7
|
-
import { E as juniorUsers, T as juniorIdentities, m as juniorConversationParticipants, w as juniorConversations } from "./executor-BfbYPW63.js";
|
|
8
|
-
import { Kt as buildDeterministicTurnId, c as parseSlackThreadId, ft as appendAndEnqueueExclusiveInboundMessage, pt as appendAndEnqueueInboundMessage } from "./stats-DKRP4rsY.js";
|
|
1
|
+
import { f as logWarn } from "./logging-sNS84Yuu.js";
|
|
2
|
+
import { s as getSlackBotToken } from "./config-EtF2uEaW.js";
|
|
3
|
+
import "./context-Bplcgypl.js";
|
|
4
|
+
import { K as normalizeSlackConversationId, Wt as getConversationStore } from "./agent-hooks-CuGjLjmR.js";
|
|
5
|
+
import { Kt as buildDeterministicTurnId, c as parseSlackThreadId, ft as appendAndEnqueueExclusiveInboundMessage, pt as appendAndEnqueueInboundMessage } from "./stats-Cq5w_Awk.js";
|
|
9
6
|
import { t as healthReportSchema } from "./reporting-schema-DosTN__Q.js";
|
|
10
7
|
import { z } from "zod";
|
|
11
8
|
import { createHash } from "node:crypto";
|
|
12
|
-
import { and, eq, exists, gte, inArray, isNotNull, notExists, or } from "drizzle-orm";
|
|
13
9
|
import { createWebSource, localDestinationSchema } from "@sentry/junior-plugin-api";
|
|
14
|
-
import { alias } from "drizzle-orm/pg-core";
|
|
15
10
|
import { del, get, put } from "@vercel/blob";
|
|
16
11
|
//#region src/handlers/health.ts
|
|
17
12
|
/** Build Junior's process health value for HTTP and reporting consumers. */
|
|
@@ -227,110 +222,13 @@ function requireLocalDestination(conversationId) {
|
|
|
227
222
|
* Keep a stored Destination, or create the temporary local Destination.
|
|
228
223
|
*
|
|
229
224
|
* TODO(dcramer): Delete this module after Conversation and AgentRun use
|
|
230
|
-
* Location, and web and
|
|
225
|
+
* Location, and web and event Turns no longer need a local
|
|
231
226
|
* Destination.
|
|
232
227
|
*/
|
|
233
228
|
function resolveConversationDestination(args) {
|
|
234
229
|
return args.existing ?? requireLocalDestination(args.conversationId);
|
|
235
230
|
}
|
|
236
231
|
//#endregion
|
|
237
|
-
//#region src/api/conversations/membership.ts
|
|
238
|
-
/** True when the viewer is a materialized participant on this root conversation. */
|
|
239
|
-
function conversationHasParticipantUser(userId) {
|
|
240
|
-
const participant = getDb().select({ rootConversationId: juniorConversationParticipants.rootConversationId }).from(juniorConversationParticipants).where(and(eq(juniorConversationParticipants.rootConversationId, juniorConversations.conversationId), eq(juniorConversationParticipants.userId, userId)));
|
|
241
|
-
return exists(participant);
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* True when a verified primary-email user participates on this root
|
|
245
|
-
* conversation. Used only for the actorEmail feed fallback.
|
|
246
|
-
*/
|
|
247
|
-
function conversationHasParticipantEmail(email) {
|
|
248
|
-
const participant = getDb().select({ rootConversationId: juniorConversationParticipants.rootConversationId }).from(juniorConversationParticipants).innerJoin(juniorUsers, eq(juniorUsers.id, juniorConversationParticipants.userId)).where(and(eq(juniorConversationParticipants.rootConversationId, juniorConversations.conversationId), eq(juniorUsers.primaryEmailNormalized, email)));
|
|
249
|
-
return exists(participant);
|
|
250
|
-
}
|
|
251
|
-
/** True when one user's personal feed has archived this root after the cutoff. */
|
|
252
|
-
function conversationArchivedForUser(userId, archivedAfter) {
|
|
253
|
-
const archive = getDb().select({ rootConversationId: juniorConversationParticipants.rootConversationId }).from(juniorConversationParticipants).where(and(eq(juniorConversationParticipants.rootConversationId, juniorConversations.conversationId), eq(juniorConversationParticipants.userId, userId), isNotNull(juniorConversationParticipants.archivedAt), archivedAfter ? gte(juniorConversationParticipants.archivedAt, archivedAfter) : void 0));
|
|
254
|
-
return exists(archive);
|
|
255
|
-
}
|
|
256
|
-
/** True when one user's personal feed has not archived this root. */
|
|
257
|
-
function conversationNotArchivedForUser(userId) {
|
|
258
|
-
const archive = getDb().select({ rootConversationId: juniorConversationParticipants.rootConversationId }).from(juniorConversationParticipants).where(and(eq(juniorConversationParticipants.rootConversationId, juniorConversations.conversationId), eq(juniorConversationParticipants.userId, userId), isNotNull(juniorConversationParticipants.archivedAt)));
|
|
259
|
-
return notExists(archive);
|
|
260
|
-
}
|
|
261
|
-
/** True when one primary-email user's feed archived this root after the cutoff. */
|
|
262
|
-
function conversationArchivedForEmail(email, archivedAfter) {
|
|
263
|
-
const archive = getDb().select({ rootConversationId: juniorConversationParticipants.rootConversationId }).from(juniorConversationParticipants).innerJoin(juniorUsers, eq(juniorUsers.id, juniorConversationParticipants.userId)).where(and(eq(juniorConversationParticipants.rootConversationId, juniorConversations.conversationId), eq(juniorUsers.primaryEmailNormalized, email), isNotNull(juniorConversationParticipants.archivedAt), archivedAfter ? gte(juniorConversationParticipants.archivedAt, archivedAfter) : void 0));
|
|
264
|
-
return exists(archive);
|
|
265
|
-
}
|
|
266
|
-
/** True when one primary-email user's personal feed has not archived this root. */
|
|
267
|
-
function conversationNotArchivedForEmail(email) {
|
|
268
|
-
const archive = getDb().select({ rootConversationId: juniorConversationParticipants.rootConversationId }).from(juniorConversationParticipants).innerJoin(juniorUsers, eq(juniorUsers.id, juniorConversationParticipants.userId)).where(and(eq(juniorConversationParticipants.rootConversationId, juniorConversations.conversationId), eq(juniorUsers.primaryEmailNormalized, email), isNotNull(juniorConversationParticipants.archivedAt)));
|
|
269
|
-
return notExists(archive);
|
|
270
|
-
}
|
|
271
|
-
/** Root-actor ownership or a materialized participant row for the same person. */
|
|
272
|
-
function viewerConversationMembership(args) {
|
|
273
|
-
if (args.actorMatch && args.participantMatch) return or(args.actorMatch, args.participantMatch);
|
|
274
|
-
return args.actorMatch ?? args.participantMatch;
|
|
275
|
-
}
|
|
276
|
-
/** Read personal archive timestamps for a bounded set of conversation roots. */
|
|
277
|
-
async function conversationArchiveTimes(db, conversationIds, subject) {
|
|
278
|
-
if (!subject || conversationIds.length === 0) return /* @__PURE__ */ new Map();
|
|
279
|
-
const query = db.select({
|
|
280
|
-
archivedAt: juniorConversationParticipants.archivedAt,
|
|
281
|
-
rootConversationId: juniorConversationParticipants.rootConversationId
|
|
282
|
-
}).from(juniorConversationParticipants);
|
|
283
|
-
const rows = "userId" in subject ? await query.where(and(eq(juniorConversationParticipants.userId, subject.userId), inArray(juniorConversationParticipants.rootConversationId, [...conversationIds]), isNotNull(juniorConversationParticipants.archivedAt))) : await query.innerJoin(juniorUsers, eq(juniorUsers.id, juniorConversationParticipants.userId)).where(and(eq(juniorUsers.primaryEmailNormalized, subject.email), inArray(juniorConversationParticipants.rootConversationId, [...conversationIds]), isNotNull(juniorConversationParticipants.archivedAt)));
|
|
284
|
-
return new Map(rows.flatMap((row) => row.archivedAt ? [[row.rootConversationId, row.archivedAt.getTime()]] : []));
|
|
285
|
-
}
|
|
286
|
-
/** Find which of the supplied roots include the linked viewer as a participant. */
|
|
287
|
-
async function conversationIdsWithParticipantUser(db, conversationIds, userId) {
|
|
288
|
-
if (conversationIds.length === 0) return /* @__PURE__ */ new Set();
|
|
289
|
-
const rows = await db.select({ rootConversationId: juniorConversationParticipants.rootConversationId }).from(juniorConversationParticipants).where(and(eq(juniorConversationParticipants.userId, userId), inArray(juniorConversationParticipants.rootConversationId, [...conversationIds])));
|
|
290
|
-
return new Set(rows.map((row) => row.rootConversationId));
|
|
291
|
-
}
|
|
292
|
-
//#endregion
|
|
293
|
-
//#region src/api/conversations/access.ts
|
|
294
|
-
const rootConversation = alias(juniorConversations, "access_root_conversation");
|
|
295
|
-
const rootDestination = alias(juniorDestinations, "access_root_destination");
|
|
296
|
-
const rootIdentity = alias(juniorIdentities, "access_root_identity");
|
|
297
|
-
/** Resolve viewer access for a bounded set of persisted conversations. */
|
|
298
|
-
async function readConversationAccessFromSql(db, conversationIds, viewer) {
|
|
299
|
-
if (conversationIds.length === 0) return /* @__PURE__ */ new Map();
|
|
300
|
-
const normalizedViewerEmail = viewer?.email.trim().toLowerCase() || void 0;
|
|
301
|
-
const rows = await db.select({
|
|
302
|
-
conversationId: juniorConversations.conversationId,
|
|
303
|
-
parentConversationId: juniorConversations.parentConversationId,
|
|
304
|
-
storedRootConversationId: juniorConversations.rootConversationId,
|
|
305
|
-
rootConversationId: rootConversation.conversationId,
|
|
306
|
-
rootParentConversationId: rootConversation.parentConversationId,
|
|
307
|
-
rootRootConversationId: rootConversation.rootConversationId,
|
|
308
|
-
visibility: rootDestination.visibility,
|
|
309
|
-
rootEmailNormalized: rootIdentity.emailNormalized,
|
|
310
|
-
rootEmailVerified: rootIdentity.emailVerified,
|
|
311
|
-
rootUserId: rootIdentity.userId
|
|
312
|
-
}).from(juniorConversations).leftJoin(rootConversation, eq(rootConversation.conversationId, juniorConversations.rootConversationId)).leftJoin(rootDestination, eq(rootDestination.id, rootConversation.destinationId)).leftJoin(rootIdentity, eq(rootIdentity.id, rootConversation.actorIdentityId)).where(inArray(juniorConversations.conversationId, [...conversationIds]));
|
|
313
|
-
const membershipConversationIds = /* @__PURE__ */ new Set();
|
|
314
|
-
for (const row of rows) {
|
|
315
|
-
membershipConversationIds.add(row.conversationId);
|
|
316
|
-
if (row.storedRootConversationId) membershipConversationIds.add(row.storedRootConversationId);
|
|
317
|
-
}
|
|
318
|
-
const participantRootIds = viewer !== void 0 ? await conversationIdsWithParticipantUser(db, [...membershipConversationIds], viewer.id) : /* @__PURE__ */ new Set();
|
|
319
|
-
return new Map(rows.map((row) => {
|
|
320
|
-
const validRootConversationId = row.rootConversationId !== null && row.rootConversationId === row.storedRootConversationId && row.rootRootConversationId === row.rootConversationId && row.rootParentConversationId === null && (row.parentConversationId !== null || row.storedRootConversationId === row.conversationId) ? row.rootConversationId ?? void 0 : void 0;
|
|
321
|
-
const visibility = validRootConversationId === void 0 ? null : row.visibility;
|
|
322
|
-
const isRootActor = validRootConversationId !== void 0 && viewer !== void 0 && (row.rootUserId === viewer.id || normalizedViewerEmail !== void 0 && row.rootEmailVerified === true && row.rootEmailNormalized === normalizedViewerEmail);
|
|
323
|
-
const isMaterializedParticipant = participantRootIds.has(row.conversationId) || validRootConversationId !== void 0 && participantRootIds.has(validRootConversationId);
|
|
324
|
-
const isParticipant = isRootActor || isMaterializedParticipant;
|
|
325
|
-
const canViewPrivateContent = isParticipant || validRootConversationId !== void 0 && canExposeConversationPayload({ visibility: visibility ?? void 0 });
|
|
326
|
-
return [row.conversationId, {
|
|
327
|
-
canViewPrivateContent,
|
|
328
|
-
isParticipant,
|
|
329
|
-
visibility
|
|
330
|
-
}];
|
|
331
|
-
}));
|
|
332
|
-
}
|
|
333
|
-
//#endregion
|
|
334
232
|
//#region src/chat/conversations/web-input.ts
|
|
335
233
|
/** Store web input in a Conversation mailbox. */
|
|
336
234
|
function normalizeEmail(email) {
|
|
@@ -491,4 +389,4 @@ async function appendAndEnqueueWebMessage(input, options) {
|
|
|
491
389
|
};
|
|
492
390
|
}
|
|
493
391
|
//#endregion
|
|
494
|
-
export {
|
|
392
|
+
export { webActorFromEmail as a, formatSlackConversationRedactedLabel as c, resolveSlackConversationContextFromThreadId as d, lookupSlackUser as f, readHealthReport as g, GET as h, recordWebConversationActivity as i, resolveSlackChannelTypeFromMessage as l, createVercelAttachmentStorage as m, conversationTurnIdForMessage as n, resolveConversationDestination as o, legacyWebMailboxMetadataSchema as p, createAndEnqueueConversation as r, conversationVisibilityFromSlackChannelType as s, appendAndEnqueueWebMessage as t, resolveSlackConversationContext as u };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
|
|
2
|
-
import { A as createAgentInvocationSchema, M as AgentInvocationLimitError, O as agentBindingSchema, Q as AuthorizationFlowDisabledError, f as PluginCredentialFailureError, j as AgentInvocationBusyError, k as agentInvocationSchema } from "./agent-
|
|
3
|
-
import {
|
|
4
|
-
import { f as juniorAgentBindings, p as juniorAgentInvocations } from "./executor-
|
|
5
|
-
import { B as openConversationProjection, o as failTurnRecord, r as saveTurnCheckpoint, s as getTurnRecord, xt as getTerminalAssistantMessages } from "./checkpoint-
|
|
6
|
-
import { pt as appendAndEnqueueInboundMessage } from "./stats-
|
|
7
|
-
import { _ as isTurnInputCommitLostError, h as getConversationTurnBoundaryError, p as TurnInputCommitLostError, s as getAssistantReplyText } from "./pending-auth-
|
|
8
|
-
import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-
|
|
9
|
-
import { n as executeTurn, t as AgentRunError } from "./turn-execution-
|
|
10
|
-
import { n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState } from "./thread-state-
|
|
2
|
+
import { A as createAgentInvocationSchema, M as AgentInvocationLimitError, O as agentBindingSchema, Q as AuthorizationFlowDisabledError, f as PluginCredentialFailureError, j as AgentInvocationBusyError, k as agentInvocationSchema } from "./agent-BfxfHsf1.js";
|
|
3
|
+
import { Ht as getConversationEventStore, Kt as getSqlExecutor, Wt as getConversationStore } from "./agent-hooks-CuGjLjmR.js";
|
|
4
|
+
import { f as juniorAgentBindings, p as juniorAgentInvocations } from "./executor-BW5qp0jC.js";
|
|
5
|
+
import { B as openConversationProjection, o as failTurnRecord, r as saveTurnCheckpoint, s as getTurnRecord, xt as getTerminalAssistantMessages } from "./checkpoint-FKMcINix.js";
|
|
6
|
+
import { pt as appendAndEnqueueInboundMessage } from "./stats-Cq5w_Awk.js";
|
|
7
|
+
import { _ as isTurnInputCommitLostError, h as getConversationTurnBoundaryError, p as TurnInputCommitLostError, s as getAssistantReplyText } from "./pending-auth-CRJCt9Ux.js";
|
|
8
|
+
import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-DVlJLwB0.js";
|
|
9
|
+
import { n as executeTurn, t as AgentRunError } from "./turn-execution-C7K6lQp1.js";
|
|
10
|
+
import { n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState } from "./thread-state-lw2QwQ-y.js";
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
import { createHash } from "node:crypto";
|
|
13
13
|
import { and, asc, count, eq, inArray } from "drizzle-orm";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
|
|
2
|
-
import { b as isProviderRetryError } from "./client-
|
|
3
|
-
import { S as withLogContext, d as logInfo, f as logWarn, u as logException } from "./logging-
|
|
4
|
-
import { a as getChatConfig } from "./config-
|
|
5
|
-
import { At as recordConversationRetry, Bt as isFinalAttempt, Ct as drainConversationMailbox, Et as getConversationWorkState, Ft as startConversationWork, Nt as requestAnotherSlice, St as deadLetterAttempt, Vt as isInvalidConversationRecordError, _t as clearConsumedConversationWake, bt as completeConversationWork, dt as ackMessages, gt as checkInConversationWork, jt as releaseConversationWork, kt as recordAttemptFailure, mt as beginConversationResume, wt as ensureConversationWake, xt as countPendingConversationMessages, yt as completeConversationStop } from "./stats-
|
|
2
|
+
import { b as isProviderRetryError } from "./client-bRyPqwAV.js";
|
|
3
|
+
import { S as withLogContext, d as logInfo, f as logWarn, u as logException } from "./logging-sNS84Yuu.js";
|
|
4
|
+
import { a as getChatConfig } from "./config-EtF2uEaW.js";
|
|
5
|
+
import { At as recordConversationRetry, Bt as isFinalAttempt, Ct as drainConversationMailbox, Et as getConversationWorkState, Ft as startConversationWork, Nt as requestAnotherSlice, St as deadLetterAttempt, Vt as isInvalidConversationRecordError, _t as clearConsumedConversationWake, bt as completeConversationWork, dt as ackMessages, gt as checkInConversationWork, jt as releaseConversationWork, kt as recordAttemptFailure, mt as beginConversationResume, wt as ensureConversationWake, xt as countPendingConversationMessages, yt as completeConversationStop } from "./stats-Cq5w_Awk.js";
|
|
6
6
|
import { c as ConversationQueueMessageRejectedError } from "./vercel-queue-DIkVcfK4.js";
|
|
7
|
-
import { a as getTurnRequestDeadline } from "./job-queue-
|
|
7
|
+
import { a as getTurnRequestDeadline } from "./job-queue-BIHNIEIX.js";
|
|
8
8
|
//#region src/chat/task-execution/worker.ts
|
|
9
9
|
var worker_exports = /* @__PURE__ */ __exportAll({
|
|
10
10
|
CONVERSATION_WORK_DEFER_DELAY_MS: () => CONVERSATION_WORK_DEFER_DELAY_MS,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
UPDATE "junior_scheduler_tasks"
|
|
2
|
+
SET "record" = jsonb_set(
|
|
3
|
+
"record",
|
|
4
|
+
'{outcomes}',
|
|
5
|
+
jsonb_build_array(
|
|
6
|
+
jsonb_build_object(
|
|
7
|
+
'action', 'send_message',
|
|
8
|
+
'destination', "record"->'destination'
|
|
9
|
+
)
|
|
10
|
+
),
|
|
11
|
+
true
|
|
12
|
+
)
|
|
13
|
+
WHERE NOT "record" ? 'outcomes';
|
|
14
|
+
--> statement-breakpoint
|
|
15
|
+
UPDATE "junior_event_tasks"
|
|
16
|
+
SET "task_json" = jsonb_set(
|
|
17
|
+
"task_json",
|
|
18
|
+
'{outcomes}',
|
|
19
|
+
jsonb_build_array(
|
|
20
|
+
jsonb_build_object(
|
|
21
|
+
'action', 'send_message',
|
|
22
|
+
'destination', "task_json"->'destination'
|
|
23
|
+
)
|
|
24
|
+
),
|
|
25
|
+
true
|
|
26
|
+
)
|
|
27
|
+
WHERE NOT "task_json" ? 'outcomes';
|