@sentry/junior 0.205.0 → 0.207.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-D4nu8MQV.js → agent-CmQlX68D.js} +603 -394
- package/dist/{agent-hooks-DXHpTJ4m.js → agent-hooks-BBX9p6aG.js} +1171 -100
- package/dist/{agent-runner-C04colea.js → agent-runner-CQD4HKK2.js} +9 -9
- package/dist/api/schema.d.ts +116 -39
- package/dist/api/schema.js +3 -3
- package/dist/api.d.ts +1 -1
- package/dist/api.js +182 -649
- package/dist/{app-Cb776lL8.d.ts → app-DfNrn_gS.d.ts} +9 -2
- package/dist/app.d.ts +1 -1
- package/dist/app.js +205 -233
- package/dist/{auth-pause-state-C2P3guS1.js → auth-pause-state-uv8on6cT.js} +7 -7
- package/dist/briefs-BXEmjD9D.js +398 -0
- package/dist/{catalog-runtime-CXw3asJD.js → catalog-runtime-1BZEOR8J.js} +1 -1
- package/dist/{checkpoint-CrViJ8Ps.js → checkpoint-B-JO5F3c.js} +9 -8
- package/dist/cli/chat.js +14 -12
- package/dist/cli/check.js +3 -3
- package/dist/cli/init.js +1 -0
- package/dist/cli/main.js +5 -1
- package/dist/cli/plugins.js +3 -3
- package/dist/cli/run.d.ts +2 -1
- package/dist/cli/run.js +2 -1
- 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/{config-BOtJQ7Pc.js → client-Bp297GA0.js} +6 -369
- package/dist/config-G2gv97R1.js +386 -0
- package/dist/{context-B45_WqVX.js → context-Bplcgypl.js} +13 -13
- package/dist/{schema-Rn8-XEaN.js → conversation-AA4R1VUn.js} +580 -558
- package/dist/{conversation-privacy-BZRA6Pes.js → conversation-privacy-BUfel19D.js} +1 -1
- package/dist/{credential-sync-Bep34IB_.js → credential-sync-D04NWqMR.js} +21 -20
- package/dist/{db-BeyXKJOI.d.ts → db-D74z7BZH.d.ts} +1 -1
- package/dist/{execution-stats-B6lgWxCK.js → execution-stats-Ds4bSvam.js} +77 -77
- package/dist/{executor-BlUhFL7_.js → executor-BZu1Ta06.js} +41 -13
- package/dist/instrumentation.js +2 -2
- package/dist/{job-queue-DLMqIK74.js → job-queue-rnAPfUhP.js} +1 -1
- package/dist/{logging-BMJzdDlP.js → logging-Dx0S5k2z.js} +1 -1
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +3 -3
- package/dist/{oauth-callback-server-WwG5_Zgm.js → oauth-callback-server-xGpwURIj.js} +2 -2
- package/dist/{pending-auth-CUbXq06G.js → pending-auth-DIZ4iZjS.js} +2 -2
- package/dist/{profile-T0tXE4zu.js → profile-d-fKypxo.js} +4 -3
- package/dist/prompt-x-0ZtTyb.js +552 -0
- package/dist/{registry-BA0__8ai.js → registry-CWKdLCTG.js} +2 -2
- package/dist/{resolve-bvD1ORdv.js → resolve-BhRB1s2A.js} +2 -2
- package/dist/{runner-BXYxfIUL.js → runner-DNml3owD.js} +10 -10
- package/dist/{sandbox-egress-signals-ngEPjSEW.js → sandbox-egress-signals-DUIl3-gW.js} +1 -1
- package/dist/schema-CwTeb-BF.js +559 -0
- package/dist/{skills-DJOlYdBs.js → skills-D9WesdJJ.js} +2 -2
- package/dist/{spawn-h0R1bTEo.js → spawn-Eh_3-s0M.js} +2 -2
- package/dist/{stats-3YZn-Swi.js → stats-CFlUGqVA.js} +292 -268
- package/dist/{store-C5qxF2ac.d.ts → store-Det8MQ9g.d.ts} +1 -1
- package/dist/{task-queue-CoXwd2eq.js → task-queue-D8I1_5wP.js} +3 -3
- package/dist/{task-runner-B2_mJZj0.js → task-runner-DO79gdho.js} +18 -18
- package/dist/{thread-state-CqZ1m-es.js → thread-state-DD6BA4xz.js} +5 -5
- package/dist/{turn-execution-fI6PZ0iI.js → turn-execution-BSIHxmQJ.js} +3 -3
- package/dist/{turn-lifecycle-CcnwrOcp.js → turn-lifecycle-DSBK4Ars.js} +1 -1
- package/dist/{usage-B5SfMb3H.js → usage-WRXkNOHp.js} +4 -125
- package/dist/{validation-DfWcvhuS.js → validation-BbHZ4r4S.js} +1 -1
- package/dist/{version-oD-oPrbO.js → version-C71UcRWw.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/web-authorization-C73gJV7l.js +38 -0
- package/dist/{web-input-BOuq3oKK.js → web-input-Ce1FcNIM.js} +8 -8
- package/dist/{work-B91LQKHr.js → work-BEzDU_2x.js} +9 -9
- package/dist/{worker-BcRRTe6k.js → worker-MK2ubOv-.js} +5 -4
- package/migrations/0040_conversation_briefs.sql +17 -0
- package/migrations/0041_automation_outcomes_backfill.sql +27 -0
- package/migrations/meta/0040_snapshot.json +3516 -0
- package/migrations/meta/0041_snapshot.json +3516 -0
- package/migrations/meta/_journal.json +14 -0
- package/package.json +4 -4
- package/dist/history-CqTuSAdI.js +0 -441
- package/dist/usage-schema-CKaDkH_j.js +0 -20
- package/dist/web-authorization-Crbzlmzo.js +0 -76
|
@@ -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-Dx0S5k2z.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-rnAPfUhP.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-DO79gdho.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 {
|
|
4
|
-
import {
|
|
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-
|
|
2
|
+
import { _ as parseSlackMessageTs, r as credentialSubjectSchema } from "./context-Bplcgypl.js";
|
|
3
|
+
import { Ft as getConversationStore, It as getDb, Q as readActorIdentity, _t as createPluginState, bt as createPluginLogger, p as coreTaskRegistrations, pt as JUNIOR_THREAD_STATE_TTL_MS, u as getPlugins, vt as createPluginEmbedder, xt as createPluginConversationEvents, yt as createPluginModel } from "./agent-hooks-BBX9p6aG.js";
|
|
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-B-JO5F3c.js";
|
|
6
|
+
import { w as getStateAdapter } from "./profile-d-fKypxo.js";
|
|
7
|
+
import { u as recordAutomationExecution } from "./execution-stats-Ds4bSvam.js";
|
|
8
|
+
import { r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-DD6BA4xz.js";
|
|
9
|
+
import { i as pluginTaskParamsSchema, o as sendVercelPluginTask, r as pluginTaskId } from "./task-queue-D8I1_5wP.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-BBX9p6aG.js").then((n) => n.Mt)).getConversationStore();
|
|
349
349
|
const chain = await loadConversationChain(args.conversationId, conversationStore);
|
|
350
350
|
let destination;
|
|
351
351
|
let source;
|
|
@@ -600,7 +600,7 @@ function taskPluginContext(plugin, message, options = {}) {
|
|
|
600
600
|
};
|
|
601
601
|
}
|
|
602
602
|
function findPluginTask(message) {
|
|
603
|
-
const plugin = getPlugins().find((candidate) => candidate.manifest.name === message.plugin);
|
|
603
|
+
const plugin = [...coreTaskRegistrations(), ...getPlugins()].find((candidate) => candidate.manifest.name === message.plugin);
|
|
604
604
|
if (!plugin?.tasks || !Object.hasOwn(plugin.tasks, message.name)) return;
|
|
605
605
|
return {
|
|
606
606
|
plugin,
|
|
@@ -610,7 +610,7 @@ function findPluginTask(message) {
|
|
|
610
610
|
/** Schedule all plugin tasks interested in a completed agent-run session. */
|
|
611
611
|
async function scheduleSessionCompletedPluginTasks(params, options = {}) {
|
|
612
612
|
const coreParams = pluginTaskParamsSchema.parse(params);
|
|
613
|
-
const taskRegistrations = getPlugins().flatMap((plugin) => Object.keys(plugin.tasks ?? {}).map((name) => ({
|
|
613
|
+
const taskRegistrations = [...getPlugins(), ...coreTaskRegistrations()].flatMap((plugin) => Object.keys(plugin.tasks ?? {}).map((name) => ({
|
|
614
614
|
name,
|
|
615
615
|
plugin
|
|
616
616
|
})));
|
|
@@ -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-Dx0S5k2z.js";
|
|
2
|
+
import { It as getDb, pt as JUNIOR_THREAD_STATE_TTL_MS } from "./agent-hooks-BBX9p6aG.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-BZu1Ta06.js";
|
|
5
|
+
import { $ as persistConversationMessages } from "./checkpoint-B-JO5F3c.js";
|
|
6
|
+
import { w as getStateAdapter } from "./profile-d-fKypxo.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 { Nt as getConversationEventStore } from "./agent-hooks-BBX9p6aG.js";
|
|
2
|
+
import { n as runAgentWithTimeout } from "./agent-runner-CQD4HKK2.js";
|
|
3
|
+
import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-DSBK4Ars.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 { Nt as getConversationEventStore } from "./agent-hooks-BBX9p6aG.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,127 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
import { conversationEventPresentationSchema, defineConversationEvent } from "@sentry/junior-plugin-api";
|
|
6
|
-
//#region 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
|
-
const NATIVE_EVENT_DEFINITIONS = [
|
|
109
|
-
authenticationLinkedEvent,
|
|
110
|
-
authenticationUnlinkedEvent,
|
|
111
|
-
agentsInstructionsUpdatedEvent
|
|
112
|
-
];
|
|
113
|
-
/** Resolve a registered Junior-native conversation event definition. */
|
|
114
|
-
function getJuniorNativeEventDefinition(args) {
|
|
115
|
-
return NATIVE_EVENT_DEFINITIONS.find((definition) => definition.eventName === args.name && definition.version === args.version);
|
|
116
|
-
}
|
|
117
|
-
/** Render one Junior-native event through its active definition. */
|
|
118
|
-
function renderJuniorNativeConversationEvent(args) {
|
|
119
|
-
if (args.namespace !== "junior") return void 0;
|
|
120
|
-
const definition = getJuniorNativeEventDefinition(args);
|
|
121
|
-
if (!definition) return void 0;
|
|
122
|
-
const presentation = definition.renderEvent(definition.parse(args.content));
|
|
123
|
-
return presentation === void 0 ? void 0 : conversationEventPresentationSchema.parse(presentation);
|
|
124
|
-
}
|
|
1
|
+
import { f as logWarn } from "./logging-Dx0S5k2z.js";
|
|
2
|
+
import { n as botConfig } from "./config-G2gv97R1.js";
|
|
3
|
+
import { P as usageSchema } from "./conversation-AA4R1VUn.js";
|
|
125
4
|
const TITLE_PROMPTS = {
|
|
126
5
|
conversation: [
|
|
127
6
|
"Generate a concise 5-8 word conversation title from the first user message below.",
|
|
@@ -293,4 +172,4 @@ function addAgentTurnUsage(...usages) {
|
|
|
293
172
|
return hasAgentTurnUsage(result) ? result : void 0;
|
|
294
173
|
}
|
|
295
174
|
//#endregion
|
|
296
|
-
export { hasAgentTurnUsage as a, generateShortTitle as c,
|
|
175
|
+
export { hasAgentTurnUsage as a, generateShortTitle as c, agentTurnUsageSchema as i, resolveTaskTitle as l, agentTurnCostUsd as n, ToolInputError as o, agentTurnTotalTokens as r, fallbackShortTitle as s, addAgentTurnUsage as t };
|
|
@@ -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-1BZEOR8J.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-C71UcRWw.js";
|
|
2
2
|
export { JUNIOR_VERSION };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { w as getStateAdapter } from "./profile-d-fKypxo.js";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
//#region src/chat/conversations/web-authorization.ts
|
|
4
|
+
const WEB_AUTHORIZATION_PREFIX = "junior:web_authorization:v1";
|
|
5
|
+
const WEB_AUTHORIZATION_TTL_MS = 864e5;
|
|
6
|
+
function authorizationKey(conversationId, actorId) {
|
|
7
|
+
return `${WEB_AUTHORIZATION_PREFIX}:${conversationId}:${actorId}`;
|
|
8
|
+
}
|
|
9
|
+
/** Build authorization delivery for one web turn. */
|
|
10
|
+
function createWebAuthorization(args) {
|
|
11
|
+
return {
|
|
12
|
+
createState: async () => randomUUID(),
|
|
13
|
+
deliver: async (request) => {
|
|
14
|
+
await getStateAdapter().set(authorizationKey(args.conversationId, args.actorId), JSON.stringify({
|
|
15
|
+
...request,
|
|
16
|
+
...args
|
|
17
|
+
}), WEB_AUTHORIZATION_TTL_MS);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** Read the pending authorization request for one web actor. */
|
|
22
|
+
async function getWebAuthorization(args) {
|
|
23
|
+
const value = await getStateAdapter().get(authorizationKey(args.conversationId, args.actorId));
|
|
24
|
+
if (typeof value !== "string") return void 0;
|
|
25
|
+
try {
|
|
26
|
+
const parsed = JSON.parse(value);
|
|
27
|
+
if (parsed.actorId !== args.actorId || parsed.conversationId !== args.conversationId || typeof parsed.authorizationUrl !== "string" || typeof parsed.label !== "string" || typeof parsed.completionText !== "string") return;
|
|
28
|
+
return parsed;
|
|
29
|
+
} catch {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** Remove a web authorization request after the parked turn continues. */
|
|
34
|
+
async function deleteWebAuthorization(args) {
|
|
35
|
+
await getStateAdapter().delete(authorizationKey(args.conversationId, args.actorId));
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { deleteWebAuthorization as n, getWebAuthorization as r, createWebAuthorization as t };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import "./context-
|
|
5
|
-
import {
|
|
1
|
+
import { f as logWarn } from "./logging-Dx0S5k2z.js";
|
|
2
|
+
import { t as canExposeConversationPayload } from "./conversation-privacy-BUfel19D.js";
|
|
3
|
+
import { s as getSlackBotToken } from "./config-G2gv97R1.js";
|
|
4
|
+
import "./context-Bplcgypl.js";
|
|
5
|
+
import { Ft as getConversationStore, It as getDb, K as normalizeSlackConversationId } from "./agent-hooks-BBX9p6aG.js";
|
|
6
6
|
import { n as juniorDestinations } from "./destinations-BeBiJeEM.js";
|
|
7
|
-
import {
|
|
8
|
-
import { Kt as buildDeterministicTurnId, c as parseSlackThreadId, ft as appendAndEnqueueExclusiveInboundMessage, pt as appendAndEnqueueInboundMessage } from "./stats-
|
|
7
|
+
import { E as juniorUsers, T as juniorIdentities, m as juniorConversationParticipants, w as juniorConversations } from "./executor-BZu1Ta06.js";
|
|
8
|
+
import { Kt as buildDeterministicTurnId, c as parseSlackThreadId, ft as appendAndEnqueueExclusiveInboundMessage, pt as appendAndEnqueueInboundMessage } from "./stats-CFlUGqVA.js";
|
|
9
9
|
import { t as healthReportSchema } from "./reporting-schema-DosTN__Q.js";
|
|
10
10
|
import { z } from "zod";
|
|
11
11
|
import { createHash } from "node:crypto";
|
|
@@ -227,7 +227,7 @@ function requireLocalDestination(conversationId) {
|
|
|
227
227
|
* Keep a stored Destination, or create the temporary local Destination.
|
|
228
228
|
*
|
|
229
229
|
* TODO(dcramer): Delete this module after Conversation and AgentRun use
|
|
230
|
-
* Location, and web and
|
|
230
|
+
* Location, and web and event Turns no longer need a local
|
|
231
231
|
* Destination.
|
|
232
232
|
*/
|
|
233
233
|
function resolveConversationDestination(args) {
|
|
@@ -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, f as PluginCredentialFailureError, j as AgentInvocationBusyError, k as agentInvocationSchema
|
|
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-CmQlX68D.js";
|
|
3
|
+
import { Ft as getConversationStore, Lt as getSqlExecutor, Nt as getConversationEventStore } from "./agent-hooks-BBX9p6aG.js";
|
|
4
|
+
import { f as juniorAgentBindings, p as juniorAgentInvocations } from "./executor-BZu1Ta06.js";
|
|
5
|
+
import { B as openConversationProjection, o as failTurnRecord, r as saveTurnCheckpoint, s as getTurnRecord, xt as getTerminalAssistantMessages } from "./checkpoint-B-JO5F3c.js";
|
|
6
|
+
import { pt as appendAndEnqueueInboundMessage } from "./stats-CFlUGqVA.js";
|
|
7
|
+
import { _ as isTurnInputCommitLostError, h as getConversationTurnBoundaryError, p as TurnInputCommitLostError, s as getAssistantReplyText } from "./pending-auth-DIZ4iZjS.js";
|
|
8
|
+
import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-DSBK4Ars.js";
|
|
9
|
+
import { n as executeTurn, t as AgentRunError } from "./turn-execution-BSIHxmQJ.js";
|
|
10
|
+
import { n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState } from "./thread-state-DD6BA4xz.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,9 +1,10 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
|
|
2
|
-
import {
|
|
3
|
-
import { S as withLogContext, d as logInfo, f as logWarn, u as logException } from "./logging-
|
|
4
|
-
import {
|
|
2
|
+
import { b as isProviderRetryError } from "./client-Bp297GA0.js";
|
|
3
|
+
import { S as withLogContext, d as logInfo, f as logWarn, u as logException } from "./logging-Dx0S5k2z.js";
|
|
4
|
+
import { a as getChatConfig } from "./config-G2gv97R1.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-CFlUGqVA.js";
|
|
5
6
|
import { c as ConversationQueueMessageRejectedError } from "./vercel-queue-DIkVcfK4.js";
|
|
6
|
-
import { a as getTurnRequestDeadline } from "./job-queue-
|
|
7
|
+
import { a as getTurnRequestDeadline } from "./job-queue-rnAPfUhP.js";
|
|
7
8
|
//#region src/chat/task-execution/worker.ts
|
|
8
9
|
var worker_exports = /* @__PURE__ */ __exportAll({
|
|
9
10
|
CONVERSATION_WORK_DEFER_DELAY_MS: () => CONVERSATION_WORK_DEFER_DELAY_MS,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
CREATE TABLE "junior_conversation_briefs" (
|
|
2
|
+
"conversation_id" text NOT NULL,
|
|
3
|
+
"version" integer NOT NULL,
|
|
4
|
+
"turn_id" text NOT NULL,
|
|
5
|
+
"through_seq" integer NOT NULL,
|
|
6
|
+
"content" jsonb NOT NULL,
|
|
7
|
+
"search_text" text NOT NULL,
|
|
8
|
+
"model_id" text NOT NULL,
|
|
9
|
+
"cost_usd" double precision,
|
|
10
|
+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
11
|
+
CONSTRAINT "junior_conversation_briefs_conversation_id_version_pk" PRIMARY KEY("conversation_id","version")
|
|
12
|
+
);
|
|
13
|
+
--> statement-breakpoint
|
|
14
|
+
ALTER TABLE "junior_conversation_briefs" ADD CONSTRAINT "junior_conversation_briefs_conversation_id_junior_conversations_conversation_id_fk" FOREIGN KEY ("conversation_id") REFERENCES "public"."junior_conversations"("conversation_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
15
|
+
CREATE UNIQUE INDEX "junior_conversation_briefs_conversation_turn_idx" ON "junior_conversation_briefs" USING btree ("conversation_id","turn_id");--> statement-breakpoint
|
|
16
|
+
CREATE INDEX "junior_conversation_briefs_conversation_version_idx" ON "junior_conversation_briefs" USING btree ("conversation_id","version" DESC NULLS LAST);--> statement-breakpoint
|
|
17
|
+
CREATE INDEX "junior_conversation_briefs_search_idx" ON "junior_conversation_briefs" USING gin (to_tsvector('english', "search_text"));
|
|
@@ -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';
|