@sentry/junior 0.258.0 → 0.260.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.
Files changed (77) hide show
  1. package/dist/adapter-Dj5BTJRd.js +270 -0
  2. package/dist/{admin-My1SLGVO.js → admin-tzkZDqrH.js} +1 -1
  3. package/dist/{agent-hooks-BJ_5mlRH.js → agent-hooks-V4Hfc2tB.js} +711 -697
  4. package/dist/{agent-runner-DGsFQw72.js → agent-runner-DvTUyGTY.js} +751 -2508
  5. package/dist/api/schema.d.ts +239 -54
  6. package/dist/api/schema.js +4 -4
  7. package/dist/api.js +218 -57
  8. package/dist/{app-PX2H1PxU.d.ts → app-BsBUs3rF.d.ts} +6 -3
  9. package/dist/app.d.ts +2 -2
  10. package/dist/app.js +31 -31
  11. package/dist/{assistant-reply-H1M-91oF.js → assistant-reply-CEOMzsWy.js} +1 -1
  12. package/dist/{automation-DWBFBenG.js → automation-DrpcA-SX.js} +3 -0
  13. package/dist/{briefs-vYoK85rJ.js → briefs-BSCkyYqs.js} +4 -4
  14. package/dist/{catalog-runtime-BN4DVxco.js → catalog-runtime-Bpcs2b2L.js} +1 -1
  15. package/dist/cli/chat.d.ts +1 -1
  16. package/dist/cli/chat.js +16 -16
  17. package/dist/cli/check.js +3 -3
  18. package/dist/cli/main.js +6 -2
  19. package/dist/cli/plugins.d.ts +1 -1
  20. package/dist/cli/plugins.js +4 -4
  21. package/dist/cli/run.d.ts +2 -1
  22. package/dist/cli/run.js +2 -1
  23. package/dist/cli/snapshot-create.js +4 -3
  24. package/dist/cli/upgrade.d.ts +1 -1
  25. package/dist/cli/upgrade.js +3 -3
  26. package/dist/{client-DbyHuMFU.js → client-JeyzRwsT.js} +57 -4
  27. package/dist/{config-_WO_AjCB.js → config-ULs6Zl9b.js} +5 -2
  28. package/dist/{connections-ag_1JOhB.js → connections-CZ7HhEmN.js} +174 -10
  29. package/dist/{conversation-DjN3mlog.js → conversation-CvuKJ3tA.js} +108 -155
  30. package/dist/{conversation-privacy-DHP_xnVj.js → conversation-privacy-BQSlZXgV.js} +1 -1
  31. package/dist/{credential-sync-B-CPX_ag.js → credential-sync-BKcv5rBe.js} +14 -177
  32. package/dist/{executor-RvG6kVe1.js → executor-BoGNVEDn.js} +3 -2
  33. package/dist/{images-C2J_bj2g.js → images-BBmDXQCB.js} +3 -3
  34. package/dist/instrumentation.js +2 -2
  35. package/dist/{job-queue-DVe37it2.js → job-queue-CbdVyaCo.js} +1 -1
  36. package/dist/{logging-DsHONhVm.js → logging-DSMmkHXG.js} +1 -1
  37. package/dist/{message-DyitL8no.js → message-zaj5gBbS.js} +3 -3
  38. package/dist/nitro.d.ts +2 -2
  39. package/dist/nitro.js +3 -3
  40. package/dist/{oauth-callback-server-CDby-pCn.js → oauth-callback-server-yYFG8Own.js} +2 -2
  41. package/dist/{plugins-B11Mfkmv.d.ts → plugins-B_0Cr0MO.d.ts} +5 -1
  42. package/dist/{profile-DpYjfKke.js → profile-ByWkAY7L.js} +24 -293
  43. package/dist/{prompt-xgpyMtg7.js → prompt-DeVax2qO.js} +1 -1
  44. package/dist/{registry-Du566MtJ.js → registry-BL-osYWN.js} +41 -2
  45. package/dist/{resolve-ClCIgh8E.js → resolve-HuPG2VMB.js} +9 -4
  46. package/dist/{result-BBbKA61B.js → result-DS7V4a3-.js} +9 -14
  47. package/dist/{runner-CCuqFSqx.js → runner-Cba_OfGl.js} +11 -11
  48. package/dist/{sandbox-egress-signals-DY1mbKF4.js → sandbox-egress-signals-C7NcPzea.js} +1 -1
  49. package/dist/{schema-DrMh3NtR.js → schema-OzL8Zw4H.js} +82 -3
  50. package/dist/service-account-DqwHhwJA.js +120 -0
  51. package/dist/service-account-Ko1Xs--F.js +661 -0
  52. package/dist/{session-stop-CIoFiwwe.js → session-stop-HfKx-pky.js} +180 -22
  53. package/dist/{skills-DyQBLIrK.js → skills-D6_bcAuW.js} +2 -2
  54. package/dist/{spawn-Dqfeo7XP.js → spawn-BWqK6EwM.js} +2 -2
  55. package/dist/{store-DJLwq4x8.js → store-DzRbd5VT.js} +6 -6
  56. package/dist/{task-queue-BzW4MaWU.js → task-queue-9LICOzcL.js} +3 -3
  57. package/dist/{task-runner-D3qJh4fK.js → task-runner-DGnd_B5X.js} +10 -10
  58. package/dist/{tasks-CEXKTASS.js → tasks-CjrS098O.js} +4928 -2389
  59. package/dist/thread-state-CqkYowEz.js +184 -0
  60. package/dist/{turn-failure-response-CWx7aNIh.js → turn-failure-response-BkKmGqFt.js} +8 -9
  61. package/dist/{turn-lifecycle-C9JFst7-.js → turn-lifecycle-DYv8IV6w.js} +1 -1
  62. package/dist/{turn-session-routing-CUxtfpr7.js → turn-session-routing-TaVhKmdz.js} +1 -1
  63. package/dist/{validation-BHRxa5G4.js → validation-BrXMYPyo.js} +1 -1
  64. package/dist/{version-C0U6rHg0.js → version-Ct049vav.js} +1 -1
  65. package/dist/version.js +1 -1
  66. package/dist/{viewer-CGvvRqKp.js → viewer-C-J0ewlH.js} +19 -10
  67. package/dist/{web-input-Keb5GRWj.js → web-input-C_xB3RXp.js} +41 -37
  68. package/dist/{work-DRcsJ3hV.js → work-D829Ue7k.js} +9 -10
  69. package/dist/{worker-Cjo-QqPq.js → worker-BRTYzlpk.js} +5 -5
  70. package/migrations/0061_workspace_vcpus.sql +1 -0
  71. package/migrations/meta/0061_snapshot.json +3471 -0
  72. package/migrations/meta/_journal.json +7 -0
  73. package/package.json +6 -6
  74. package/dist/experimental-BNK1l1jv.js +0 -49
  75. package/dist/oauth-authorization-djQn5Nhy.js +0 -97
  76. package/dist/pending-auth-D8J1uJUS.js +0 -442
  77. package/dist/thread-state-W3f6kAtz.js +0 -426
@@ -1,4 +1,5 @@
1
1
  import { a as resolveLocalScheduleAtMs, i as isValidTimeZone, r as getZonedDateTimeParts, t as getFirstRunAtMs } from "./cadence-R7Em4RjE.js";
2
+ import { n as actorIdentitySchema } from "./conversation-CvuKJ3tA.js";
2
3
  import { z } from "zod";
3
4
  import { actorUserIdSchema, destinationVisibilitySchema, eventMatchSchema, eventTypeSchema, pluginEventTypeSchema, slackDestinationSchema, taskOutcomeSchema } from "@sentry/junior-plugin-api";
4
5
  // src/chat/task-outcomes-schema.ts
@@ -395,6 +396,8 @@ const automationSummaryBaseSchema = z.object({
395
396
  destination: automationDestinationSchema,
396
397
  id: z.string().min(1),
397
398
  instruction: z.string().min(1),
399
+ /** People mentioned in the instruction, resolved at read time. */
400
+ mentions: z.array(actorIdentitySchema).optional(),
398
401
  lastConversationId: z.string().min(1).optional(),
399
402
  lastRunAt: z.string().datetime().optional(),
400
403
  lastRunStatus: z.enum([
@@ -1,7 +1,7 @@
1
- import { r as completeObject } from "./client-DbyHuMFU.js";
1
+ import { i as completeObject } from "./client-JeyzRwsT.js";
2
2
  import { r as defaultModelId } from "./model-profile-Bg8EoCKD.js";
3
- import { U as parseBriefInput, d as conversationDetailReportSchema, p as conversationEventPageSchema, z as briefCodeChangeSchema } from "./conversation-DjN3mlog.js";
4
- import { n as briefEntriesFromReportEvents, s as generateBrief, t as BRIEF_PROMPT } from "./prompt-xgpyMtg7.js";
3
+ import { J as parseBriefInput, W as briefCodeChangeSchema, d as conversationDetailReportSchema, p as conversationEventPageSchema } from "./conversation-CvuKJ3tA.js";
4
+ import { n as briefEntriesFromReportEvents, s as generateBrief, t as BRIEF_PROMPT } from "./prompt-DeVax2qO.js";
5
5
  import { CLI_USAGE } from "./cli/run.js";
6
6
  import path from "node:path";
7
7
  import { z } from "zod";
@@ -267,7 +267,7 @@ async function parseRunOptions(argv) {
267
267
  * `DATABASE_URL` at import, and `briefs pull` must work with only a token.
268
268
  */
269
269
  async function configuredDefaultModelId() {
270
- const { botConfig } = await import("./config-_WO_AjCB.js").then((n) => n.r);
270
+ const { botConfig } = await import("./config-ULs6Zl9b.js").then((n) => n.r);
271
271
  return defaultModelId(botConfig);
272
272
  }
273
273
  function apiUrl(baseUrl, pathname) {
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
2
- import { t as createPluginCatalogRuntime } from "./registry-Du566MtJ.js";
2
+ import { t as createPluginCatalogRuntime } from "./registry-BL-osYWN.js";
3
3
  // src/chat/plugins/catalog-runtime.ts
4
4
  var catalog_runtime_exports = /* @__PURE__ */ __exportAll({ pluginCatalogRuntime: () => pluginCatalogRuntime });
5
5
  const pluginCatalogRuntime = createPluginCatalogRuntime();
@@ -1,4 +1,4 @@
1
- import { n as JuniorPluginSet } from "../plugins-B11Mfkmv.js";
1
+ import { n as JuniorPluginSet } from "../plugins-B_0Cr0MO.js";
2
2
  export declare const CHAT_USAGE = "usage: junior chat\n junior chat -p <message>";
3
3
  export type ChatCommandOptions = {
4
4
  mode: "interactive";
package/dist/cli/chat.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as executeAgentRun, t as createAgentRunner } from "../agent-runner-DGsFQw72.js";
1
+ import { n as executeAgentRun, t as createAgentRunner } from "../agent-runner-DvTUyGTY.js";
2
2
  import { t as loadAppPluginSet } from "../plugin-module-Cf5gVPWP.js";
3
3
  import path from "node:path";
4
4
  import { createHash, randomUUID } from "node:crypto";
@@ -99,10 +99,10 @@ async function loadLocalPluginSet() {
99
99
  async function configureLocalChatPlugins(pluginSet) {
100
100
  const [pluginsModule, agentHooksModule, catalogRuntimeModule, validationModule, databaseModule] = await Promise.all([
101
101
  import("../plugins-DOm9Y6qI.js").then((n) => n.o),
102
- import("../agent-hooks-BJ_5mlRH.js").then((n) => n.t),
103
- import("../catalog-runtime-BN4DVxco.js").then((n) => n.t),
104
- import("../validation-BHRxa5G4.js").then((n) => n.r),
105
- import("../viewer-CGvvRqKp.js").then((n) => n.s)
102
+ import("../agent-hooks-V4Hfc2tB.js").then((n) => n.t),
103
+ import("../catalog-runtime-Bpcs2b2L.js").then((n) => n.t),
104
+ import("../validation-BrXMYPyo.js").then((n) => n.r),
105
+ import("../viewer-C-J0ewlH.js").then((n) => n.s)
106
106
  ]);
107
107
  const resolvedPluginSet = pluginSet === void 0 ? await loadLocalPluginSet() : pluginSet ?? void 0;
108
108
  const plugins = pluginsModule.pluginRuntimeRegistrationsFromPluginSet(resolvedPluginSet);
@@ -152,21 +152,21 @@ function localDevServerUrl() {
152
152
  async function prepareLocalChatRun(io, pluginSet) {
153
153
  defaultStateAdapterForLocalChat();
154
154
  await configureLocalChatPlugins(pluginSet);
155
- const { setExperimentalFeatures } = await import("../experimental-BNK1l1jv.js").then((n) => n.t);
155
+ const { setExperimentalFeatures } = await import("../tasks-CjrS098O.js").then((n) => n.hn);
156
156
  setExperimentalFeatures({ subagents: true });
157
- const { setBriefsConfig } = await import("../agent-hooks-BJ_5mlRH.js").then((n) => n.m);
157
+ const { setBriefsConfig } = await import("../agent-hooks-V4Hfc2tB.js").then((n) => n.m);
158
158
  setBriefsConfig({ enabled: true });
159
- const { runLocalAgentTurn } = await import("../runner-CCuqFSqx.js");
160
- const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-CDby-pCn.js");
159
+ const { runLocalAgentTurn } = await import("../runner-Cba_OfGl.js");
160
+ const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-yYFG8Own.js");
161
161
  const { createLocalOAuthState } = await import("../oauth-relay-CTygMkNx.js").then((n) => n.t);
162
- const { createLocalSandboxEgressSignalTransport } = await import("../sandbox-egress-signals-DY1mbKF4.js");
163
- const { bindSpawnAgent } = await import("../spawn-Dqfeo7XP.js").then((n) => n.n);
164
- const { bindMessageAgent } = await import("../message-DyitL8no.js").then((n) => n.n);
165
- const { createAgentInvocationWorker, routeAgentInvocationWork } = await import("../work-DRcsJ3hV.js").then((n) => n.a);
166
- const { startAgentInvocationsForChildInput } = await import("../result-BBbKA61B.js").then((n) => n.r);
167
- const { skipInputBeforeConversationStop } = await import("../session-stop-CIoFiwwe.js").then((n) => n.r);
162
+ const { createLocalSandboxEgressSignalTransport } = await import("../sandbox-egress-signals-C7NcPzea.js");
163
+ const { bindSpawnAgent } = await import("../spawn-BWqK6EwM.js").then((n) => n.n);
164
+ const { bindMessageAgent } = await import("../message-zaj5gBbS.js").then((n) => n.n);
165
+ const { createAgentInvocationWorker, routeAgentInvocationWork } = await import("../work-D829Ue7k.js").then((n) => n.a);
166
+ const { startAgentInvocationsForChildInput } = await import("../result-DS7V4a3-.js").then((n) => n.r);
167
+ const { skipInputBeforeConversationStop } = await import("../session-stop-HfKx-pky.js").then((n) => n.r);
168
168
  const { createLocalConversationWork } = await import("../conversation-work-BaT_T6EB.js");
169
- const { processConversationWork } = await import("../worker-Cjo-QqPq.js").then((n) => n.n);
169
+ const { processConversationWork } = await import("../worker-BRTYzlpk.js").then((n) => n.n);
170
170
  let agentRunner;
171
171
  const localConversationWork = createLocalConversationWork(async (message) => {
172
172
  if (!agentRunner) throw new Error("Local agent runner is not ready");
package/dist/cli/check.js CHANGED
@@ -1,6 +1,6 @@
1
- import { E as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, N as LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION, O as JUNIOR_HEARTBEAT_ROUTE } from "../logging-DsHONhVm.js";
2
- import { v as parseInlinePluginManifest, y as parsePluginManifest } from "../registry-Du566MtJ.js";
3
- import { i as parseSkillFile } from "../skills-DyQBLIrK.js";
1
+ import { E as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, N as LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION, O as JUNIOR_HEARTBEAT_ROUTE } from "../logging-DSMmkHXG.js";
2
+ import { v as parseInlinePluginManifest, y as parsePluginManifest } from "../registry-BL-osYWN.js";
3
+ import { i as parseSkillFile } from "../skills-D6_bcAuW.js";
4
4
  import path from "node:path";
5
5
  import fs from "node:fs/promises";
6
6
  import { pathToFileURL } from "node:url";
package/dist/cli/main.js CHANGED
@@ -25,10 +25,13 @@ async function runChat(argv, pluginSet) {
25
25
  return await (await import("./chat.js")).runChat(argv, void 0, { pluginSet });
26
26
  }
27
27
  async function runAdmin(argv) {
28
- return await (await import("../admin-My1SLGVO.js")).runAdmin(argv);
28
+ return await (await import("../admin-tzkZDqrH.js")).runAdmin(argv);
29
+ }
30
+ async function runServiceAccount(argv) {
31
+ return await (await import("../service-account-DqwHhwJA.js")).runServiceAccount(argv);
29
32
  }
30
33
  async function runBriefs(argv) {
31
- return await (await import("../briefs-vYoK85rJ.js")).runBriefs(argv);
34
+ return await (await import("../briefs-BSCkyYqs.js")).runBriefs(argv);
32
35
  }
33
36
  function topLevelCommand(argv) {
34
37
  return (argv[0] === "--" ? argv.slice(1) : argv)[0];
@@ -45,6 +48,7 @@ async function runMain(argv, options = {}) {
45
48
  const exitCode = await runCli(argv, {
46
49
  runAdmin,
47
50
  runBriefs,
51
+ runServiceAccount,
48
52
  runChat: async (chatArgv) => await runChat(chatArgv, pluginSet),
49
53
  runInit,
50
54
  runSnapshotCreate,
@@ -1,4 +1,4 @@
1
- import { n as JuniorPluginSet } from "../plugins-B11Mfkmv.js";
1
+ import { n as JuniorPluginSet } from "../plugins-B_0Cr0MO.js";
2
2
  import { PluginCliIo } from "@sentry/junior-plugin-api";
3
3
  export type PluginCommandIo = PluginCliIo;
4
4
  export interface CliPluginCommandDispatcher {
@@ -1,7 +1,7 @@
1
- import { d as getDb } from "../viewer-CGvvRqKp.js";
2
- import { n as pluginCatalogRuntime } from "../catalog-runtime-BN4DVxco.js";
3
- import { d as setPlugins, f as validatePlugins, ft as createPluginLogger } from "../agent-hooks-BJ_5mlRH.js";
4
- import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "../validation-BHRxa5G4.js";
1
+ import { d as getDb } from "../viewer-C-J0ewlH.js";
2
+ import { n as pluginCatalogRuntime } from "../catalog-runtime-Bpcs2b2L.js";
3
+ import { d as setPlugins, f as validatePlugins, wt as createPluginLogger } from "../agent-hooks-V4Hfc2tB.js";
4
+ import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "../validation-BrXMYPyo.js";
5
5
  import { a as pluginRuntimeRegistrationsFromPluginSet, i as pluginCliRegistrationsFromPluginSet, r as pluginCatalogConfigFromPluginSet } from "../plugins-DOm9Y6qI.js";
6
6
  import { t as loadAppPluginSet } from "../plugin-module-Cf5gVPWP.js";
7
7
  import { stderr, stdout } from "node:process";
package/dist/cli/run.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- export declare const CLI_USAGE = "usage: junior init <dir>\n junior admin list|grant <email>|revoke <email>\n junior snapshot create\n junior check [dir]\n junior upgrade\n junior chat\n junior chat -p <message>\n junior briefs pull <conversationId...> --base-url <url> [--token <token>] --out <dir>\n junior briefs run <snapshot...> [--model <id>] [--prompt <file>] [--turn-by-turn] [--out <dir>]";
1
+ export declare const CLI_USAGE = "usage: junior init <dir>\n junior admin list|grant <email>|revoke <email>\n junior service-account connect|status|disconnect <plugin>\n junior snapshot create\n junior check [dir]\n junior upgrade\n junior chat\n junior chat -p <message>\n junior briefs pull <conversationId...> --base-url <url> [--token <token>] --out <dir>\n junior briefs run <snapshot...> [--model <id>] [--prompt <file>] [--turn-by-turn] [--out <dir>]";
2
2
  interface CliHandlers {
3
3
  runAdmin: (argv: string[]) => Promise<number>;
4
4
  runBriefs: (argv: string[]) => Promise<number>;
5
+ runServiceAccount: (argv: string[]) => Promise<number>;
5
6
  runChat: (argv: string[]) => Promise<number>;
6
7
  runInit: (dir: string) => Promise<void>;
7
8
  runSnapshotCreate: () => Promise<void>;
package/dist/cli/run.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/cli/run.ts
2
- const CLI_USAGE = "usage: junior init <dir>\n junior admin list|grant <email>|revoke <email>\n junior snapshot create\n junior check [dir]\n junior upgrade\n junior chat\n junior chat -p <message>\n junior briefs pull <conversationId...> --base-url <url> [--token <token>] --out <dir>\n junior briefs run <snapshot...> [--model <id>] [--prompt <file>] [--turn-by-turn] [--out <dir>]";
2
+ const CLI_USAGE = "usage: junior init <dir>\n junior admin list|grant <email>|revoke <email>\n junior service-account connect|status|disconnect <plugin>\n junior snapshot create\n junior check [dir]\n junior upgrade\n junior chat\n junior chat -p <message>\n junior briefs pull <conversationId...> --base-url <url> [--token <token>] --out <dir>\n junior briefs run <snapshot...> [--model <id>] [--prompt <file>] [--turn-by-turn] [--out <dir>]";
3
3
  const DEFAULT_IO = { error: console.error };
4
4
  /** Strip Node's leading argv separator while preserving command-level flags. */
5
5
  function normalizeCliArgv(argv) {
@@ -10,6 +10,7 @@ async function runCli(argv, handlers, io = DEFAULT_IO) {
10
10
  const [command, subcommand, ...rest] = normalizeCliArgv(argv);
11
11
  if (command === "chat") return await handlers.runChat(subcommand === void 0 ? [] : [subcommand, ...rest]);
12
12
  if (command === "admin") return await handlers.runAdmin(subcommand === void 0 ? [] : [subcommand, ...rest]);
13
+ if (command === "service-account") return await handlers.runServiceAccount(subcommand === void 0 ? [] : [subcommand, ...rest]);
13
14
  if (command === "briefs") return await handlers.runBriefs(subcommand === void 0 ? [] : [subcommand, ...rest]);
14
15
  if (command === "init") {
15
16
  if (!subcommand || rest.length > 0) {
@@ -1,6 +1,7 @@
1
- import { n as pluginCatalogRuntime } from "../catalog-runtime-BN4DVxco.js";
2
- import { S as disconnectStateAdapter, t as create } from "../profile-DpYjfKke.js";
3
- import { r as resolve } from "../resolve-ClCIgh8E.js";
1
+ import { n as pluginCatalogRuntime } from "../catalog-runtime-Bpcs2b2L.js";
2
+ import { t as disconnectStateAdapter } from "../adapter-Dj5BTJRd.js";
3
+ import { t as create } from "../profile-ByWkAY7L.js";
4
+ import { r as resolve } from "../resolve-HuPG2VMB.js";
4
5
  // src/cli/snapshot-create.ts
5
6
  const DEFAULT_RUNTIME = "node22";
6
7
  const DEFAULT_TIMEOUT_MS = 6e5;
@@ -1,5 +1,5 @@
1
1
  import "../db-BnRqQ7G5.js";
2
- import { n as JuniorPluginSet } from "../plugins-B11Mfkmv.js";
2
+ import { n as JuniorPluginSet } from "../plugins-B_0Cr0MO.js";
3
3
  interface UpgradeIo {
4
4
  info: (line: string) => void;
5
5
  }
@@ -1,6 +1,6 @@
1
- import { i as getChatConfig } from "../config-_WO_AjCB.js";
2
- import { t as createJuniorSqlExecutor } from "../executor-RvG6kVe1.js";
3
- import { t as createPluginCatalogRuntime } from "../registry-Du566MtJ.js";
1
+ import { i as getChatConfig } from "../config-ULs6Zl9b.js";
2
+ import { t as createJuniorSqlExecutor } from "../executor-BoGNVEDn.js";
3
+ import { t as createPluginCatalogRuntime } from "../registry-BL-osYWN.js";
4
4
  import { n as pluginCatalogConfigFromEnv, r as pluginCatalogConfigFromPluginSet, t as defineJuniorPlugins } from "../plugins-DOm9Y6qI.js";
5
5
  import { t as loadAppPluginSet } from "../plugin-module-Cf5gVPWP.js";
6
6
  import { basename, dirname, join, resolve } from "node:path";
@@ -1,10 +1,10 @@
1
- import { T as withSpan, _ as serializeGenAiAttribute, f as logException, h as normalizeGenAiFinishReason, i as extractGenAiUsageAttributes, m as logWarn } from "./logging-DsHONhVm.js";
2
- import { a as toCanonicalInputMessage, n as getCurrentConversationPrivacy, o as toCanonicalOutputMessage, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-DHP_xnVj.js";
1
+ import { T as withSpan, _ as serializeGenAiAttribute, f as logException, h as normalizeGenAiFinishReason, i as extractGenAiUsageAttributes, m as logWarn } from "./logging-DSMmkHXG.js";
2
+ import { a as toCanonicalInputMessage, n as getCurrentConversationPrivacy, o as toCanonicalOutputMessage, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-BQSlZXgV.js";
3
3
  import { calculateCost, completeSimple, getEnvApiKey, getModels, registerApiProvider } from "@earendil-works/pi-ai/compat";
4
4
  import { stream as streamAnthropic, streamSimple as streamSimpleAnthropic } from "@earendil-works/pi-ai/api/anthropic-messages";
5
5
  import { createGatewayProvider } from "@ai-sdk/gateway";
6
6
  import { getVercelOidcToken } from "@vercel/oidc";
7
- import { NoObjectGeneratedError, embedMany, generateObject } from "ai";
7
+ import { Experimental_DecisionRefusalError, NoObjectGeneratedError, embedMany, experimental_decide, generateObject } from "ai";
8
8
  // src/chat/optional-string.ts
9
9
  /**
10
10
  * Normalize optional env-style strings so blank values do not masquerade as
@@ -400,6 +400,7 @@ const GEN_AI_PROVIDER_NAME = GATEWAY_PROVIDER;
400
400
  const GEN_AI_SERVER_ADDRESS = "ai-gateway.vercel.sh";
401
401
  const GEN_AI_OPERATION_CHAT = "chat";
402
402
  const GEN_AI_OPERATION_EMBEDDINGS = "embeddings";
403
+ const GEN_AI_OPERATION_DECIDE = "decide";
403
404
  const EMBEDDING_INPUT_COST_USD_PER_MILLION_TOKENS = {
404
405
  "cohere/embed-v4.0": .12,
405
406
  "google/gemini-embedding-001": .15,
@@ -411,6 +412,14 @@ const EMBEDDING_INPUT_COST_USD_PER_MILLION_TOKENS = {
411
412
  "voyage/voyage-3.5": .06,
412
413
  "voyage/voyage-3.5-lite": .02
413
414
  };
415
+ const DECISION_INPUT_COST_USD_PER_MILLION_TOKENS = {
416
+ "openai/gpt-6-luna-decisions": .1,
417
+ "typesafe-ai/jev": .042
418
+ };
419
+ function decisionCostUsd(modelId, inputTokens) {
420
+ const costPerMillionTokens = DECISION_INPUT_COST_USD_PER_MILLION_TOKENS[modelId];
421
+ return costPerMillionTokens === void 0 || inputTokens === void 0 ? void 0 : inputTokens * costPerMillionTokens / 1e6;
422
+ }
414
423
  function embeddingCostUsd(modelId, inputTokens) {
415
424
  const costPerMillionTokens = EMBEDDING_INPUT_COST_USD_PER_MILLION_TOKENS[modelId];
416
425
  return costPerMillionTokens === void 0 ? void 0 : inputTokens * costPerMillionTokens / 1e6;
@@ -605,6 +614,50 @@ async function completeObject(params) {
605
614
  ...costUsd !== void 0 ? { costUsd } : void 0
606
615
  };
607
616
  }
617
+ /** Answer typed decision questions with an AI Gateway decision model, such as Jev. */
618
+ async function completeDecision(params) {
619
+ const credential = await resolveGatewayCredential();
620
+ const provider = createGatewayProvider(credential ? { apiKey: credential.token } : {});
621
+ try {
622
+ const result = await withSpan(`${GEN_AI_OPERATION_DECIDE} ${params.modelId}`, "gen_ai.decide", logContextFromMetadata(params.modelId, params.metadata), async (setSpanAttributes) => {
623
+ const result = await experimental_decide({
624
+ model: provider.decisionModel(params.modelId),
625
+ state: params.state,
626
+ questions: params.questions,
627
+ ...params.signal !== void 0 ? { abortSignal: params.signal } : void 0
628
+ });
629
+ const costUsd = decisionCostUsd(params.modelId, result.usage.inputTokens);
630
+ setSpanAttributes(extractGenAiUsageAttributes({
631
+ ...result.usage,
632
+ ...costUsd !== void 0 ? { cost: {
633
+ input: costUsd,
634
+ total: costUsd
635
+ } } : void 0
636
+ }));
637
+ return {
638
+ answers: result.answers,
639
+ costUsd
640
+ };
641
+ }, {
642
+ "gen_ai.provider.name": GEN_AI_PROVIDER_NAME,
643
+ "gen_ai.operation.name": GEN_AI_OPERATION_DECIDE,
644
+ "gen_ai.request.model": params.modelId,
645
+ ...params.promptName ? { "gen_ai.prompt.name": params.promptName } : void 0,
646
+ "server.address": GEN_AI_SERVER_ADDRESS,
647
+ "server.port": 443,
648
+ "gen_ai.provider.auth_mode": credential?.mode ?? "api_key"
649
+ });
650
+ return {
651
+ answers: result.answers,
652
+ ...result.costUsd !== void 0 ? { costUsd: result.costUsd } : void 0
653
+ };
654
+ } catch (error) {
655
+ throw createProviderError(error, {
656
+ ...Experimental_DecisionRefusalError.isInstance(error) ? { kind: "invalid_response" } : void 0,
657
+ modelId: params.modelId
658
+ });
659
+ }
660
+ }
608
661
  /** Generate text embeddings through the host-owned AI Gateway provider. */
609
662
  async function embedTexts(params) {
610
663
  const texts = params.texts.map((text) => text.trim());
@@ -665,4 +718,4 @@ async function embedTexts(params) {
665
718
  throw providerError;
666
719
  }
667
720
  }
668
- export { toOptionalTrimmed as S, getProviderErrorUserMessage as _, embedTexts as a, getGatewayApiKey as b, hasCompactedConversationContext as c, unwrapCurrentInstruction as d, escapeXml as f, getProviderErrorAttributes as g, findProviderError as h, completeText as i, isCompactionSummaryText as l, createProviderError as m, GEN_AI_SERVER_ADDRESS as n, resolveGatewayModel as o, ProviderError as p, completeObject as r, COMPACTION_SUMMARY_PREFIX as s, GEN_AI_PROVIDER_NAME as t, renderCurrentInstruction as u, isProviderRetryError as v, resolveGatewayCredential as x, MISSING_GATEWAY_CREDENTIALS_ERROR as y };
721
+ export { toOptionalTrimmed as C, resolveGatewayCredential as S, getProviderErrorAttributes as _, completeText as a, MISSING_GATEWAY_CREDENTIALS_ERROR as b, COMPACTION_SUMMARY_PREFIX as c, renderCurrentInstruction as d, unwrapCurrentInstruction as f, findProviderError as g, createProviderError as h, completeObject as i, hasCompactedConversationContext as l, ProviderError as m, GEN_AI_SERVER_ADDRESS as n, embedTexts as o, escapeXml as p, completeDecision as r, resolveGatewayModel as s, GEN_AI_PROVIDER_NAME as t, isCompactionSummaryText as u, getProviderErrorUserMessage as v, getGatewayApiKey as x, isProviderRetryError as y };
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
2
- import { S as toOptionalTrimmed, o as resolveGatewayModel } from "./client-DbyHuMFU.js";
3
- import { m as logWarn } from "./logging-DsHONhVm.js";
2
+ import { C as toOptionalTrimmed, s as resolveGatewayModel } from "./client-JeyzRwsT.js";
3
+ import { m as logWarn } from "./logging-DSMmkHXG.js";
4
4
  import { l as TURN_REASONING_LEVELS, s as modelProfileSchema, t as DEFAULT_MODEL_PROFILES, u as parseTurnReasoningLevel } from "./model-profile-Bg8EoCKD.js";
5
5
  // src/chat/slack/emoji.ts
6
6
  const SLACK_EMOJI_NAME_RE = /^(?:[a-z0-9_+-]+)(?:::(?:skin-tone-[2-6]))?$/;
@@ -145,6 +145,7 @@ const DEFAULT_FAST_MODEL_ID = resolveGatewayModel("openai/gpt-6-luna").id;
145
145
  const DEFAULT_GUARDIAN_MODEL_ID = resolveGatewayModel("openai/gpt-6-luna").id;
146
146
  const DEFAULT_HANDOFF_MODEL_ID = resolveGatewayModel(DEFAULT_MODEL_PROFILES.handoff.modelId).id;
147
147
  const DEFAULT_WEB_SEARCH_MODEL_ID = resolveGatewayModel("openai/gpt-6-luna").id;
148
+ const DEFAULT_DECISION_MODEL_ID = "typesafe-ai/jev";
148
149
  const DEFAULT_EMBEDDING_MODEL_ID = "openai/text-embedding-3-small";
149
150
  const DEFAULT_IMAGE_GENERATION_MODEL_ID = "google/gemini-3-pro-image";
150
151
  const DEFAULT_VISION_MODEL_ID = resolveGatewayModel("openai/gpt-5.6-sol").id;
@@ -260,6 +261,7 @@ function readBotConfig(env, functionMaxDurationSeconds) {
260
261
  profiles: parseProfiles(env.AI_MODEL_PROFILES, modelId, handoffModelId),
261
262
  contextWindowTokens: parseOptionalPositiveInteger("AI_MODEL_CONTEXT_WINDOW_TOKENS", env.AI_MODEL_CONTEXT_WINDOW_TOKENS) ?? DEFAULT_MODEL_CONTEXT_WINDOW_TOKENS,
262
263
  reasoningLevel: reasoningLevel === void 0 ? void 0 : parseTurnReasoningLevel(reasoningLevel),
264
+ decisionModelId: toOptionalTrimmed(env.AI_DECISION_MODEL) ?? DEFAULT_DECISION_MODEL_ID,
263
265
  fastModelId,
264
266
  guardianModelId,
265
267
  imageGenerationModelId: toOptionalTrimmed(env.AI_IMAGE_MODEL) ?? DEFAULT_IMAGE_GENERATION_MODEL_ID,
@@ -422,6 +424,7 @@ function getRuntimeMetadata() {
422
424
  }
423
425
  /** Apply model overrides from createApp(). */
424
426
  function setBotModelConfig(config) {
427
+ if (config.decisionModelId !== void 0) botConfig.decisionModelId = requireModelId("decisionModelId", config.decisionModelId, toOptionalTrimmed);
425
428
  if (config.embeddingModelId !== void 0) botConfig.embeddingModelId = requireModelId("embeddingModelId", config.embeddingModelId, validateEmbeddingModelId);
426
429
  if (config.fastModelId !== void 0) botConfig.fastModelId = requireModelId("fastModelId", config.fastModelId, validateGatewayModelId);
427
430
  if (config.guardianModelId !== void 0) botConfig.guardianModelId = requireModelId("guardianModelId", config.guardianModelId, validateGatewayModelId);
@@ -1,12 +1,13 @@
1
- import { It as startOAuthFlow, c as deleteMcpAuthSessionsForUserProvider, l as deleteMcpServerSessionId, u as deleteMcpStoredOAuthCredentials } from "./agent-runner-DGsFQw72.js";
2
- import { A as deleteProviderIdentityForUser, c as getConversationEventStore, f as getSqlExecutor, k as deleteProviderIdentityForSlackUser } from "./viewer-CGvvRqKp.js";
3
- import { u as hasRequiredOAuthScope } from "./registry-Du566MtJ.js";
4
- import { n as pluginCatalogRuntime } from "./catalog-runtime-BN4DVxco.js";
5
- import { K as loadTurnCheckpoint, X as failTurnRecord, Z as getTurnRecord } from "./tasks-CEXKTASS.js";
6
- import { w as getStateAdapter } from "./profile-DpYjfKke.js";
7
- import { a as getVercelConversationWorkQueue } from "./job-queue-DVe37it2.js";
8
- import { m as ensureConversationWake, w as requestConversationWork } from "./store-DJLwq4x8.js";
9
- import { n as resolveTurnSessionRouting } from "./turn-session-routing-CUxtfpr7.js";
1
+ import { Ln as startOAuthFlow, Nt as failTurnRecord, Pt as getTurnRecord, kt as loadTurnCheckpoint } from "./tasks-CjrS098O.js";
2
+ import { n as botConfig } from "./config-ULs6Zl9b.js";
3
+ import { A as deleteProviderIdentityForUser, c as getConversationEventStore, f as getSqlExecutor, k as deleteProviderIdentityForSlackUser } from "./viewer-C-J0ewlH.js";
4
+ import { u as hasRequiredOAuthScope } from "./registry-BL-osYWN.js";
5
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-Bpcs2b2L.js";
6
+ import { c as deleteMcpServerSessionId, l as deleteMcpStoredOAuthCredentials, s as deleteMcpAuthSessionsForUserProvider } from "./agent-runner-DvTUyGTY.js";
7
+ import { r as getStateAdapter } from "./adapter-Dj5BTJRd.js";
8
+ import { a as getVercelConversationWorkQueue } from "./job-queue-CbdVyaCo.js";
9
+ import { m as ensureConversationWake, w as requestConversationWork } from "./store-DzRbd5VT.js";
10
+ import { n as resolveTurnSessionRouting } from "./turn-session-routing-TaVhKmdz.js";
10
11
  import { z } from "zod";
11
12
  import { randomBytes, randomUUID } from "node:crypto";
12
13
  // src/chat/task-execution/authorized-turn.ts
@@ -125,6 +126,169 @@ async function wakeAuthorizedTurn(args, queue) {
125
126
  const request = await recordTurnAuthorization(args);
126
127
  if (request) await wakePausedTurn(request, { queue });
127
128
  }
129
+ // src/handlers/oauth-html.ts
130
+ /** Build pre-escaped callback HTML with the shared response security policy. */
131
+ function htmlCallbackResponse(title, message, status, options = {}) {
132
+ const footerMessage = options.footerMessage ?? `You can close this tab and return to ${botConfig.userName}.`;
133
+ const isSuccess = status >= 200 && status < 300;
134
+ const statusClass = isSuccess ? "success" : "error";
135
+ const statusIcon = isSuccess ? "" : "!";
136
+ const html = `<!DOCTYPE html>
137
+ <html lang="en">
138
+ <head>
139
+ <meta charset="utf-8">
140
+ <meta name="viewport" content="width=device-width, initial-scale=1">
141
+ <meta name="color-scheme" content="light dark">
142
+ <title>${title}</title>
143
+ <style>
144
+ :root {
145
+ color-scheme: light dark;
146
+ --canvas: #f4f1fa;
147
+ --surface: #ffffff;
148
+ --text: #211a2c;
149
+ --muted: #6e6479;
150
+ --border: #ded7e8;
151
+ --accent: #6c5fc7;
152
+ --success: #16835c;
153
+ --success-soft: #ddf5ea;
154
+ --error: #bc3d50;
155
+ --error-soft: #fce7eb;
156
+ --shadow: 0 24px 64px rgba(45, 31, 63, 0.14);
157
+ }
158
+
159
+ * { box-sizing: border-box; }
160
+
161
+ body {
162
+ min-height: 100vh;
163
+ margin: 0;
164
+ display: grid;
165
+ place-items: center;
166
+ padding: 24px;
167
+ background: var(--canvas);
168
+ color: var(--text);
169
+ font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
170
+ }
171
+
172
+ main {
173
+ width: min(100%, 480px);
174
+ padding: 48px 40px 40px;
175
+ text-align: center;
176
+ background: var(--surface);
177
+ border: 1px solid var(--border);
178
+ border-radius: 24px;
179
+ box-shadow: var(--shadow);
180
+ }
181
+
182
+ .brand {
183
+ display: inline-flex;
184
+ align-items: center;
185
+ gap: 8px;
186
+ margin-bottom: 32px;
187
+ color: var(--muted);
188
+ font-size: 14px;
189
+ font-weight: 700;
190
+ letter-spacing: 0.08em;
191
+ text-transform: uppercase;
192
+ }
193
+
194
+ .brand-mark {
195
+ width: 10px;
196
+ height: 10px;
197
+ background: var(--accent);
198
+ border-radius: 3px;
199
+ transform: rotate(12deg);
200
+ }
201
+
202
+ .status {
203
+ width: 64px;
204
+ height: 64px;
205
+ margin: 0 auto 24px;
206
+ display: grid;
207
+ place-items: center;
208
+ border-radius: 20px;
209
+ font-size: 32px;
210
+ font-weight: 750;
211
+ line-height: 1;
212
+ }
213
+
214
+ .status.success { color: var(--success); background: var(--success-soft); }
215
+ .status.success::before {
216
+ content: "";
217
+ width: 12px;
218
+ height: 24px;
219
+ margin-top: -5px;
220
+ border-right: 4px solid currentColor;
221
+ border-bottom: 4px solid currentColor;
222
+ transform: rotate(45deg);
223
+ }
224
+ .status.error { color: var(--error); background: var(--error-soft); }
225
+
226
+ h1 {
227
+ margin: 0;
228
+ font-size: clamp(28px, 7vw, 36px);
229
+ line-height: 1.12;
230
+ letter-spacing: -0.035em;
231
+ }
232
+
233
+ .message {
234
+ margin: 16px auto 0;
235
+ color: var(--muted);
236
+ font-size: 17px;
237
+ line-height: 1.6;
238
+ }
239
+
240
+ .footer {
241
+ margin: 32px 0 0;
242
+ padding-top: 24px;
243
+ color: var(--muted);
244
+ border-top: 1px solid var(--border);
245
+ font-size: 14px;
246
+ line-height: 1.5;
247
+ }
248
+
249
+ @media (prefers-color-scheme: dark) {
250
+ :root {
251
+ --canvas: #15121a;
252
+ --surface: #211c28;
253
+ --text: #f6f1fb;
254
+ --muted: #b8adbf;
255
+ --border: #3a3243;
256
+ --accent: #a99af0;
257
+ --success: #72d6ad;
258
+ --success-soft: #193c30;
259
+ --error: #ff9aaa;
260
+ --error-soft: #48262e;
261
+ --shadow: 0 24px 64px rgba(0, 0, 0, 0.36);
262
+ }
263
+ }
264
+
265
+ @media (max-width: 520px) {
266
+ body { padding: 16px; }
267
+ main { padding: 40px 24px 32px; border-radius: 20px; }
268
+ }
269
+ </style>
270
+ </head>
271
+ <body>
272
+ <main>
273
+ <div class="brand"><span class="brand-mark" aria-hidden="true"></span>${botConfig.userName}</div>
274
+ <div class="status ${statusClass}" aria-hidden="true">${statusIcon}</div>
275
+ <h1>${title}</h1>
276
+ <p class="message">${message}</p>
277
+ <p class="footer">${footerMessage}</p>
278
+ </main>
279
+ </body>
280
+ </html>`;
281
+ return new Response(html, {
282
+ status,
283
+ headers: {
284
+ "Cache-Control": "no-store",
285
+ "Content-Security-Policy": "default-src 'none'; style-src 'unsafe-inline'; frame-ancestors 'none'; base-uri 'none'; form-action 'none'",
286
+ "Content-Type": "text/html; charset=utf-8",
287
+ "Referrer-Policy": "no-referrer",
288
+ "X-Content-Type-Options": "nosniff"
289
+ }
290
+ });
291
+ }
128
292
  // src/chat/conversations/web-authorization.ts
129
293
  const WEB_AUTHORIZATION_PREFIX = "junior:web_authorization:v1";
130
294
  const WEB_AUTHORIZATION_TTL_MS = 864e5;
@@ -236,4 +400,4 @@ async function disconnectConnection(userId, provider, userTokenStore, viewerUser
236
400
  if (tokens?.account) await deleteProviderIdentityForUser(getSqlExecutor(), viewerUserId, provider, tokens.account.id);
237
401
  await unlinkProvider(userId, provider, userTokenStore);
238
402
  }
239
- export { startConnection as a, deleteWebAuthorization as c, getPausedTurnRequest as d, wakeAuthorizedTurn as f, readConnectedOAuthTokens as i, getWebAuthorization as l, getTurnAuthorization as m, isConnectableProvider as n, unlinkProvider as o, wakePausedTurn as p, listConnections as r, createWebAuthorization as s, disconnectConnection as t, createPausedTurns as u };
403
+ export { startConnection as a, deleteWebAuthorization as c, createPausedTurns as d, getPausedTurnRequest as f, getTurnAuthorization as h, readConnectedOAuthTokens as i, getWebAuthorization as l, wakePausedTurn as m, isConnectableProvider as n, unlinkProvider as o, wakeAuthorizedTurn as p, listConnections as r, createWebAuthorization as s, disconnectConnection as t, htmlCallbackResponse as u };