@sentry/junior 0.257.0 → 0.259.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 (104) hide show
  1. package/dist/{actor-BTtLaeWy.js → actor-tlxzqaRe.js} +3 -6
  2. package/dist/adapter-Bn0gFVSF.js +270 -0
  3. package/dist/{admin-DgIkm6Vy.js → admin-C8xz2f10.js} +2 -3
  4. package/dist/{agent-hooks-BjtTzvru.js → agent-hooks-B00FaKdP.js} +70 -109
  5. package/dist/{agent-invocations-Bdu3ROfo.js → agent-invocations-Qfz7dWgU.js} +6 -12
  6. package/dist/{agent-runner-D7OboVb3.js → agent-runner-CPSd7rKm.js} +324 -742
  7. package/dist/api/schema.d.ts +442 -447
  8. package/dist/api/schema.js +6 -6
  9. package/dist/api.d.ts +2 -12
  10. package/dist/api.js +165 -158
  11. package/dist/{app-BsU5QNBd.d.ts → app-Bbxrehjf.d.ts} +25 -45
  12. package/dist/app.d.ts +3 -3
  13. package/dist/app.js +206 -321
  14. package/dist/{assistant-reply-CbTPebzL.js → assistant-reply-CqthTerd.js} +3 -5
  15. package/dist/{automation-CHdlHVZP.js → automation-DWBFBenG.js} +6 -11
  16. package/dist/{briefs-oLOldnDM.js → briefs-DNYbQ9cD.js} +8 -11
  17. package/dist/{cadence-D00SCzT1.js → cadence-R7Em4RjE.js} +1 -2
  18. package/dist/{catalog-runtime-CZzhGQ7F.js → catalog-runtime-B8SuFPGb.js} +3 -4
  19. package/dist/cli/chat.d.ts +2 -4
  20. package/dist/cli/chat.js +22 -24
  21. package/dist/cli/check.d.ts +1 -3
  22. package/dist/cli/check.js +4 -5
  23. package/dist/cli/env.d.ts +1 -3
  24. package/dist/cli/env.js +1 -2
  25. package/dist/cli/init.d.ts +1 -3
  26. package/dist/cli/init.js +3 -3
  27. package/dist/cli/main.d.ts +1 -3
  28. package/dist/cli/main.js +8 -5
  29. package/dist/cli/plugins.d.ts +2 -4
  30. package/dist/cli/plugins.js +7 -8
  31. package/dist/cli/run.d.ts +3 -3
  32. package/dist/cli/run.js +3 -3
  33. package/dist/cli/snapshot-create.d.ts +1 -3
  34. package/dist/cli/snapshot-create.js +5 -5
  35. package/dist/cli/upgrade.d.ts +3 -6
  36. package/dist/cli/upgrade.js +11 -17
  37. package/dist/{client-D8HnkOQX.js → client-BZdxgKyL.js} +64 -18
  38. package/dist/{config-CJRnWK9H.js → config-Deqpfpg9.js} +21 -15
  39. package/dist/{connections-ClYrKzpX.js → connections-9gJkfS85.js} +179 -20
  40. package/dist/{conversation-CKNLYBJt.js → conversation-DjN3mlog.js} +8 -15
  41. package/dist/{conversation-privacy-C8b1nphZ.js → conversation-privacy-CFhNKxp-.js} +2 -3
  42. package/dist/{conversation-work-C6y3T5Hx.js → conversation-work-BaT_T6EB.js} +1 -2
  43. package/dist/{credential-sync-BXfohNmJ.js → credential-sync-BABGymK3.js} +23 -190
  44. package/dist/{db-Ca9Nt5ci.d.ts → db-BnRqQ7G5.d.ts} +1 -1
  45. package/dist/{executor-Do0THDRR.js → executor-Bb3eQb8q.js} +30 -52
  46. package/dist/{experimental-CQIvMUO7.js → experimental-BNK1l1jv.js} +2 -4
  47. package/dist/{history-9pO1Zd4Y.js → history-AY8rs-FR.js} +5 -9
  48. package/dist/{history-DvqWZlYX.d.ts → history-BgI33Kie.d.ts} +12 -20
  49. package/dist/{images-BN_BiBXF.js → images-BbSdVHC6.js} +5 -6
  50. package/dist/instrumentation.d.ts +1 -3
  51. package/dist/instrumentation.js +6 -8
  52. package/dist/{job-queue-B6SV9uVa.js → job-queue-vdGU-5ge.js} +6 -12
  53. package/dist/{logging-CWxiIuCF.js → logging-BStXN56b.js} +7 -12
  54. package/dist/{message-TUOdbSBW.js → message-DRf6m4uO.js} +5 -6
  55. package/dist/{model-profile-BwU8mqwD.js → model-profile-Bg8EoCKD.js} +2 -4
  56. package/dist/nitro.d.ts +3 -5
  57. package/dist/nitro.js +12 -17
  58. package/dist/{oauth-authorization-BA4Dt6a7.js → oauth-authorization-djQn5Nhy.js} +2 -4
  59. package/dist/{oauth-callback-server-Dj5UJODo.js → oauth-callback-server-JmOgLcGl.js} +3 -4
  60. package/dist/{oauth-relay-CdCnu80W.js → oauth-relay-CTygMkNx.js} +2 -3
  61. package/dist/{package-discovery-BVvSnQBB.js → package-discovery-DJBompdd.js} +17 -21
  62. package/dist/{pending-auth-s_QFribU.js → pending-auth-rG5U_QS1.js} +92 -83
  63. package/dist/{plugin-module-CVvEUSMH.js → plugin-module-Cf5gVPWP.js} +1 -2
  64. package/dist/{plugins-CjfUP5gJ.d.ts → plugins-B_0Cr0MO.d.ts} +5 -5
  65. package/dist/{plugins-egKWjgue.js → plugins-DOm9Y6qI.js} +2 -3
  66. package/dist/{private-trace-result-BLvBjy_e.js → private-trace-result-CE7_lEdq.js} +1 -2
  67. package/dist/{profile-h-72wM78.js → profile-qBM6B_-V.js} +14 -295
  68. package/dist/{prompt-DyoEj9c2.js → prompt-xgpyMtg7.js} +5 -9
  69. package/dist/{queue-B5SnqRln.d.ts → queue-C37RbDVc.d.ts} +0 -2
  70. package/dist/{registry-sLTr-sV9.js → registry-B_M_x_iS.js} +56 -30
  71. package/dist/{resolve-ncQPZROQ.js → resolve-BzpuLh8c.js} +8 -12
  72. package/dist/{result-C883vngT.js → result-DEZH_AnZ.js} +13 -17
  73. package/dist/{rolldown-runtime-B4FMCO8f.js → rolldown-runtime-nwUcYXjP.js} +1 -2
  74. package/dist/{runner-CzYImdOF.js → runner-BqQlG10t.js} +12 -13
  75. package/dist/{sandbox-egress-signals-CZbMINHI.js → sandbox-egress-signals-DCq3WLs5.js} +2 -3
  76. package/dist/{schema-Dy69D4Ge.js → schema-CF9HqNRY.js} +30 -27
  77. package/dist/{sentry-CgWZM_kV.js → sentry-BBUlHih9.js} +2 -3
  78. package/dist/service-account-BqTBkyD7.js +120 -0
  79. package/dist/service-account-BzhW7kXu.js +661 -0
  80. package/dist/{session-stop-CQjKd4a2.js → session-stop-CV65ZlU3.js} +23 -33
  81. package/dist/{skills-C22SLruK.js → skills-CiWS5_Ub.js} +9 -9
  82. package/dist/{spawn-DY9CLXDL.js → spawn-BSAQ7UQZ.js} +4 -5
  83. package/dist/{store-DXFIQy-G.js → store-B1GES4gC.js} +13 -15
  84. package/dist/{store-DoewL5mG.d.ts → store-CG0VJyye.d.ts} +0 -14
  85. package/dist/{task-queue-B17vV0La.js → task-queue-BAeGEMjJ.js} +5 -7
  86. package/dist/{task-runner-DUjvzYXj.js → task-runner-BlGhcQPi.js} +22 -26
  87. package/dist/{tasks-D_WIJtvO.js → tasks-DieKX3d4.js} +63 -78
  88. package/dist/{thread-state-Ch4yuCqG.js → thread-state-DpSWS4Rr.js} +13 -19
  89. package/dist/{turn-failure-response-C5nBKC4S.js → turn-failure-response-DQljogGJ.js} +16 -22
  90. package/dist/{turn-lifecycle-CO-ylUmV.js → turn-lifecycle-BLgrkV_L.js} +2 -3
  91. package/dist/{turn-session-routing-B3LWooK5.js → turn-session-routing-BlajheOU.js} +2 -3
  92. package/dist/{validation-CXYxaNYx.js → validation-23d7K9tX.js} +3 -4
  93. package/dist/vercel.d.ts +1 -3
  94. package/dist/vercel.js +1 -2
  95. package/dist/{version-BcdZy2zg.js → version-B_XumRx-.js} +3 -5
  96. package/dist/{version-CnXZ614E.d.ts → version-Cc2OFd9G.d.ts} +0 -2
  97. package/dist/version.d.ts +1 -1
  98. package/dist/version.js +1 -2
  99. package/dist/{viewer-DSZXygMU.js → viewer-B2_ABsYi.js} +26 -57
  100. package/dist/{web-input-B9Bv0_lR.js → web-input-BZDyxpzR.js} +101 -158
  101. package/dist/{web-message-id-xPI_EFSC.js → web-message-id-CJSUiksE.js} +3 -6
  102. package/dist/{work-nAfDSUFP.js → work-D3QKiV0O.js} +14 -16
  103. package/dist/{worker-vGXZ6XFT.js → worker-C8mUjYf9.js} +7 -8
  104. package/package.json +10 -9
@@ -1,20 +1,20 @@
1
- import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
2
- import { f as logException, m as logWarn, p as logInfo } from "./logging-CWxiIuCF.js";
3
- import { n as botConfig } from "./config-CJRnWK9H.js";
4
- import { d as getConversationStore, p as getSqlExecutor } from "./viewer-DSZXygMU.js";
5
- import { s as juniorConversations } from "./agent-invocations-Bdu3ROfo.js";
6
- import "./executor-Do0THDRR.js";
7
- import { h as credentialSubjectSchema } from "./registry-sLTr-sV9.js";
8
- import { B as postSlackMessage, Ct as ToolInputError, _t as isToolResultMessage, gt as isToolResultError, mt as isAssistantMessage, vt as normalizeToolNameFromResult } from "./tasks-D_WIJtvO.js";
9
- import { it as JUNIOR_THREAD_STATE_TTL_MS, rt as verifyTimerWatchCredentialSubject, u as getPlugins } from "./agent-hooks-BjtTzvru.js";
10
- import { w as getStateAdapter } from "./profile-h-72wM78.js";
11
- import { r as sanitizeAssistantText } from "./assistant-reply-CbTPebzL.js";
12
- import { r as EVENT_AUTHOR_ID } from "./prompt-DyoEj9c2.js";
13
- import { r as appendAndEnqueueInboundMessage } from "./store-DXFIQy-G.js";
1
+ import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
2
+ import { f as logException, m as logWarn, p as logInfo } from "./logging-BStXN56b.js";
3
+ import { n as botConfig } from "./config-Deqpfpg9.js";
4
+ import { f as getSqlExecutor, u as getConversationStore } from "./viewer-B2_ABsYi.js";
5
+ import { s as juniorConversations } from "./agent-invocations-Qfz7dWgU.js";
6
+ import "./executor-Bb3eQb8q.js";
7
+ import { h as credentialSubjectSchema } from "./registry-B_M_x_iS.js";
8
+ import { B as postSlackMessage, Ct as ToolInputError, _t as isToolResultMessage, gt as isToolResultError, mt as isAssistantMessage, vt as normalizeToolNameFromResult } from "./tasks-DieKX3d4.js";
9
+ import { it as JUNIOR_THREAD_STATE_TTL_MS, rt as verifyTimerWatchCredentialSubject, u as getPlugins } from "./agent-hooks-B00FaKdP.js";
10
+ import { r as sanitizeAssistantText } from "./assistant-reply-CqthTerd.js";
11
+ import { r as getStateAdapter } from "./adapter-Bn0gFVSF.js";
12
+ import { r as EVENT_AUTHOR_ID } from "./prompt-xgpyMtg7.js";
13
+ import { r as appendAndEnqueueInboundMessage } from "./store-B1GES4gC.js";
14
14
  import { z } from "zod";
15
15
  import { eq, inArray } from "drizzle-orm";
16
16
  import { eventMatchFieldsSchema, eventMatchSchema, normalizeEventIdentifier, objectTypeSchema } from "@sentry/junior-plugin-api";
17
- //#region src/chat/automation-result.ts
17
+ // src/chat/automation-result.ts
18
18
  /**
19
19
  * Automation run result.
20
20
  *
@@ -104,8 +104,7 @@ function remindMissingAutomationResult(messages) {
104
104
  timestamp: Date.now()
105
105
  }];
106
106
  }
107
- //#endregion
108
- //#region src/chat/services/automated-turn-limit.ts
107
+ // src/chat/services/automated-turn-limit.ts
109
108
  const AUTOMATED_TURN_LIMIT_PREFIX = "junior:automated_turn_limit:v1";
110
109
  const AUTOMATED_TURN_LIMIT_LOCK_TTL_MS = 5e3;
111
110
  const AUTOMATED_TURN_LIMIT_LOCK_WAIT_MS = 2e3;
@@ -272,8 +271,7 @@ async function recordFinishedTurnForAutomatedLimit(args) {
272
271
  state: args.state
273
272
  });
274
273
  }
275
- //#endregion
276
- //#region src/chat/slack/automated-turn-limit-notice.ts
274
+ // src/chat/slack/automated-turn-limit-notice.ts
277
275
  /**
278
276
  * Pause notice for the consecutive automated-turn limit.
279
277
  *
@@ -328,8 +326,7 @@ async function maybePostAutomatedTurnLimitNotice(args) {
328
326
  threadTs: args.threadTs
329
327
  });
330
328
  }
331
- //#endregion
332
- //#region src/chat/task-input.ts
329
+ // src/chat/task-input.ts
333
330
  /**
334
331
  * Shared closing lines. Automations pass outcomes and end with a declared
335
332
  * result. Watches pass no outcomes and reply in the Conversation.
@@ -376,8 +373,7 @@ function renderTaskInput(args) {
376
373
  lines.push("", ...replyContractLines(args.outcomes));
377
374
  return lines.join("\n");
378
375
  }
379
- //#endregion
380
- //#region src/chat/events/catalog.ts
376
+ // src/chat/events/catalog.ts
381
377
  /** Core-owned event namespace. Not a plugin publisher. */
382
378
  const CORE_EVENT_NAMESPACE = "junior";
383
379
  /** True when the catalog has any enabled registration. */
@@ -468,8 +464,7 @@ function requireEventIdentifier(catalog, input) {
468
464
  const fitting = resourceTypes.filter(fits).map((candidate) => candidate.type);
469
465
  throw new ToolInputError([`Identifier "${identifier}" does not fit resourceType "${input.resourceType}" in namespace "${input.namespace}". Expected format: "${resourceType.identifier.format}".`, ...fitting.length > 0 ? [`If the identifier is correct, use one of these resourceType values: ${fitting.map((type) => `"${type}"`).join(", ")}.`] : []].join(" "));
470
466
  }
471
- //#endregion
472
- //#region src/chat/sandbox/snapshot/events.ts
467
+ // src/chat/sandbox/snapshot/events.ts
473
468
  const WORKSPACE_SNAPSHOT_NAMESPACE = CORE_EVENT_NAMESPACE;
474
469
  const WORKSPACE_SNAPSHOT_RESOURCE_TYPE = "workspace_snapshot";
475
470
  const WORKSPACE_SNAPSHOT_READY_EVENT = "workspace_snapshot.ready";
@@ -523,8 +518,7 @@ function workspaceSnapshotFinishedEvent(input) {
523
518
  if (input.status === "failed" && input.error) event.untrustedText = input.error;
524
519
  return event;
525
520
  }
526
- //#endregion
527
- //#region src/chat/slack/channel-message-events.ts
521
+ // src/chat/slack/channel-message-events.ts
528
522
  /**
529
523
  * Slack channel-message Events for Event automations.
530
524
  *
@@ -622,8 +616,7 @@ function slackChannelMessageReplyThreadTs(event) {
622
616
  const messageTs = event.data?.messageTs;
623
617
  return typeof messageTs === "string" ? messageTs : void 0;
624
618
  }
625
- //#endregion
626
- //#region src/chat/events/runtime-catalog.ts
619
+ // src/chat/events/runtime-catalog.ts
627
620
  /**
628
621
  * Enabled event registrations for search, guidance, and tool schemas.
629
622
  *
@@ -648,8 +641,7 @@ function getEventCatalog() {
648
641
  }
649
642
  return catalog;
650
643
  }
651
- //#endregion
652
- //#region src/chat/events/notification.ts
644
+ // src/chat/events/notification.ts
653
645
  const EVENT_WAIT_MS = 3e4;
654
646
  /**
655
647
  * Render the runtime-owned conversation message for a subscribed event.
@@ -773,8 +765,7 @@ async function enqueueEventNotification(args) {
773
765
  state: args.state
774
766
  });
775
767
  }
776
- //#endregion
777
- //#region src/chat/conversations/session-stop.ts
768
+ // src/chat/conversations/session-stop.ts
778
769
  var session_stop_exports = /* @__PURE__ */ __exportAll({
779
770
  getConversationStoppedAtMs: () => getConversationStoppedAtMs,
780
771
  markConversationsStopped: () => markConversationsStopped,
@@ -807,5 +798,4 @@ async function skipInputBeforeConversationStop(context) {
807
798
  await context.attempt.ack();
808
799
  return { status: "completed" };
809
800
  }
810
- //#endregion
811
801
  export { maybePostAutomatedTurnLimitNotice as A, pluginSupportsEvent as C, requireEventIdentifier as D, registeredResourceTypeSchema as E, deliversFinalText as F, finishedRunReply as I, readAutomationResult as L, resetAutomatedTurnLimit as M, FINISH_AUTOMATION_RUN_TOOL_NAME as N, requireSupportedEventMatch as O, automationResultSchema as P, remindMissingAutomationResult as R, hasEventCatalogEntries as S, registeredEventTypeSchema as T, workspaceSnapshotFinishedEvent as _, EVENT_WAIT_MS as a, eventGuidance as b, timerWatchCredentialSubject as c, requireSlackChannelMessageScope as d, slackChannelMessageEvent as f, WORKSPACE_SNAPSHOT_READY_EVENT as g, WORKSPACE_SNAPSHOT_FAILED_EVENT as h, skipInputBeforeConversationStop as i, recordFinishedTurnForAutomatedLimit as j, renderTaskInput as k, getEventCatalog as l, slackChannelMessageRunsAutomation as m, markConversationsStopped as n, enqueueEventNotification as o, slackChannelMessageReplyThreadTs as p, session_stop_exports as r, isEventMailboxMetadata as s, getConversationStoppedAtMs as t, SLACK_EVENT_NAMESPACE as u, workspaceSnapshotWatch as v, registeredEventMatchSchema as w, eventNamespaceSchema as x, automationEventCatalog as y, runDispatchOutcome as z };
@@ -1,12 +1,12 @@
1
- import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
2
- import { m as logWarn } from "./logging-CWxiIuCF.js";
3
- import { s as skillRoots } from "./package-discovery-BVvSnQBB.js";
4
- import { n as pluginCatalogRuntime } from "./catalog-runtime-CZzhGQ7F.js";
1
+ import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
2
+ import { m as logWarn } from "./logging-BStXN56b.js";
3
+ import { s as skillRoots } from "./package-discovery-DJBompdd.js";
4
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-B8SuFPGb.js";
5
5
  import path from "node:path";
6
6
  import { z } from "zod";
7
7
  import fs from "node:fs/promises";
8
8
  import { parse } from "yaml";
9
- //#region src/chat/skills.ts
9
+ // src/chat/skills.ts
10
10
  var skills_exports = /* @__PURE__ */ __exportAll({
11
11
  discoverSkills: () => discoverSkills,
12
12
  findSkillByName: () => findSkillByName,
@@ -82,7 +82,7 @@ function stripFrontmatter(raw) {
82
82
  /** Parse a SKILL.md file's frontmatter and body. */
83
83
  function parseSkillFile(raw, expectedName) {
84
84
  const match = FRONTMATTER_RE.exec(raw);
85
- if (!match) return {
85
+ if (match?.[1] === void 0) return {
86
86
  ok: false,
87
87
  error: "Missing YAML frontmatter at start of file"
88
88
  };
@@ -263,13 +263,14 @@ function parseSkillInvocation(messageText, availableSkills) {
263
263
  const trimmed = messageText.trim();
264
264
  const escapePattern = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
265
265
  const slashMatch = /(?:^|\s)\/([a-z0-9]+(?:-[a-z0-9]+)*)/i.exec(trimmed);
266
- if (slashMatch) {
266
+ if (slashMatch?.[1]) {
267
267
  const skillName = slashMatch[1].toLowerCase();
268
268
  if (!availableSkills.some((skill) => skill.name === skillName)) return null;
269
269
  return { skillName };
270
270
  }
271
271
  for (const match of trimmed.matchAll(/(?:^|\s)\$([a-z0-9]+(?:-[a-z0-9]+)*)/gi)) {
272
- const skillName = match[1].toLowerCase();
272
+ const skillName = match[1]?.toLowerCase();
273
+ if (!skillName) continue;
273
274
  if (isCommonEnvironmentVariable(skillName)) continue;
274
275
  if (availableSkills.some((skill) => skill.name === skillName)) return { skillName };
275
276
  }
@@ -312,5 +313,4 @@ async function loadSkillsByName(skillNames, available) {
312
313
  }
313
314
  return skills;
314
315
  }
315
- //#endregion
316
316
  export { parseSkillInvocation as a, parseSkillFile as i, findSkillByName as n, skills_exports as o, loadSkillsByName as r, discoverSkills as t };
@@ -1,7 +1,7 @@
1
- import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
2
- import { Ht as actorFromRun, Ut as toolInvocationDestination } from "./agent-runner-D7OboVb3.js";
3
- import { n as createAndEnqueueAgentInvocation } from "./work-nAfDSUFP.js";
4
- //#region src/chat/agent-invocations/spawn.ts
1
+ import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
2
+ import { Bt as actorFromRun, Vt as toolInvocationDestination } from "./agent-runner-CPSd7rKm.js";
3
+ import { n as createAndEnqueueAgentInvocation } from "./work-D3QKiV0O.js";
4
+ // src/chat/agent-invocations/spawn.ts
5
5
  var spawn_exports = /* @__PURE__ */ __exportAll({ bindSpawnAgent: () => bindSpawnAgent });
6
6
  /** Bind a Run's Actor and credentials to new Agent invocations. */
7
7
  function bindSpawnAgent(run, options) {
@@ -28,5 +28,4 @@ function bindSpawnAgent(run, options) {
28
28
  })).childConversationId };
29
29
  };
30
30
  }
31
- //#endregion
32
31
  export { spawn_exports as n, bindSpawnAgent as t };
@@ -1,14 +1,14 @@
1
- import { B as toOptionalNumber, V as toOptionalString, z as isRecord } from "./logging-CWxiIuCF.js";
2
- import { i as getChatConfig } from "./config-CJRnWK9H.js";
3
- import { s as parseStoredSlackActor } from "./actor-BTtLaeWy.js";
4
- import { U as sameDestination, V as parseDestination, d as getConversationStore } from "./viewer-DSZXygMU.js";
5
- import { it as JUNIOR_THREAD_STATE_TTL_MS } from "./agent-hooks-BjtTzvru.js";
6
- import { C as getDefaultRedisStateAdapterFor, w as getStateAdapter } from "./profile-h-72wM78.js";
7
- import "./job-queue-B6SV9uVa.js";
1
+ import { B as toOptionalNumber, V as toOptionalString, z as isRecord } from "./logging-BStXN56b.js";
2
+ import { i as getChatConfig } from "./config-Deqpfpg9.js";
3
+ import { s as parseStoredSlackActor } from "./actor-tlxzqaRe.js";
4
+ import { B as sameDestination, R as parseDestination, u as getConversationStore } from "./viewer-B2_ABsYi.js";
5
+ import { it as JUNIOR_THREAD_STATE_TTL_MS } from "./agent-hooks-B00FaKdP.js";
6
+ import { n as getDefaultRedisStateAdapterFor, r as getStateAdapter } from "./adapter-Bn0gFVSF.js";
7
+ import "./job-queue-vdGU-5ge.js";
8
8
  import { z } from "zod";
9
9
  import { randomUUID } from "node:crypto";
10
10
  import { destinationSchema } from "@sentry/junior-plugin-api";
11
- //#region src/chat/task-execution/state.ts
11
+ // src/chat/task-execution/state.ts
12
12
  /**
13
13
  * Expiring conversation mailbox and execution index store.
14
14
  *
@@ -336,8 +336,8 @@ function uniqueIndexEntries(value) {
336
336
  return [...entries.values()];
337
337
  }
338
338
  function retainedIndexEntries(indexKey, entries) {
339
- if (indexKey === CONVERSATION_BY_ACTIVITY_INDEX_KEY) return entries.sort(compareIndexDescending).slice(0, CONVERSATION_ACTIVITY_INDEX_MAX_LENGTH);
340
- if (indexKey === CONVERSATION_ACTIVE_INDEX_KEY) return entries.sort(compareIndexAscending);
339
+ if (indexKey === "junior:conversation:v2:by-activity") return entries.sort(compareIndexDescending).slice(0, CONVERSATION_ACTIVITY_INDEX_MAX_LENGTH);
340
+ if (indexKey === "junior:conversation:v2:active") return entries.sort(compareIndexAscending);
341
341
  throw new Error(`Unknown conversation index ${indexKey}`);
342
342
  }
343
343
  function redisIndexKey(indexKey) {
@@ -402,7 +402,7 @@ function redisConversationIndexStore(client) {
402
402
  },
403
403
  async upsert(args) {
404
404
  const key = redisIndexKey(args.indexKey);
405
- if (args.indexKey === CONVERSATION_BY_ACTIVITY_INDEX_KEY) {
405
+ if (args.indexKey === "junior:conversation:v2:by-activity") {
406
406
  await client.sendCommand([
407
407
  "EVAL",
408
408
  upsertBoundedActivityScript,
@@ -415,7 +415,7 @@ function redisConversationIndexStore(client) {
415
415
  ]);
416
416
  return;
417
417
  }
418
- if (args.indexKey === CONVERSATION_ACTIVE_INDEX_KEY) {
418
+ if (args.indexKey === "junior:conversation:v2:active") {
419
419
  await client.sendCommand([
420
420
  "ZADD",
421
421
  key,
@@ -1125,8 +1125,7 @@ async function listActiveConversationIds$1(args = {}) {
1125
1125
  scoreMax: args.staleBeforeMs
1126
1126
  })).map((entry) => entry.conversationId);
1127
1127
  }
1128
- //#endregion
1129
- //#region src/chat/task-execution/store.ts
1128
+ // src/chat/task-execution/store.ts
1130
1129
  function metadataStore(options) {
1131
1130
  return options.conversationStore ?? getConversationStore();
1132
1131
  }
@@ -1413,5 +1412,4 @@ async function removeActiveConversation(args) {
1413
1412
  async function listActiveConversationIds(args = {}) {
1414
1413
  return await listActiveConversationIds$1(args);
1415
1414
  }
1416
- //#endregion
1417
1415
  export { hasRunnableConversationWork$1 as A, requestAnotherSlice as C, CONVERSATION_WORK_CHECK_IN_INTERVAL_MS as D, stopConversationWork as E, isInvalidConversationRecordError as M, CONVERSATION_WORK_STALE_ENQUEUE_MS as O, removeActiveConversation as S, startConversationWork as T, hasRunnableConversationWork as _, cancelHumanFacingPendingMessages as a, recordConversationRetry as b, clearExpiredConversationLease as c, countPendingConversationMessages as d, deadLetterAttempt as f, getConversationWorkState as g, getConversation as h, beginConversationResume as i, isFinalAttempt as j, hasConversationStop as k, completeConversationStop as l, ensureConversationWake as m, appendAndEnqueueExclusiveInboundMessage as n, checkInConversationWork as o, drainConversationMailbox as p, appendAndEnqueueInboundMessage as r, clearConsumedConversationWake as s, ackMessages as t, completeConversationWork as u, listActiveConversationIds as v, requestConversationWork as w, releaseConversationWork as x, recordAttemptFailure as y };
@@ -1,14 +1,9 @@
1
1
  import { z } from "zod";
2
2
  import { Destination, Source, locationSchema } from "@sentry/junior-plugin-api";
3
3
  import "@earendil-works/pi-ai";
4
- //#region src/chat/conversation-privacy.d.ts
5
4
  type ConversationPrivacy = "public" | "private";
6
- //#endregion
7
- //#region src/chat/conversations/location.d.ts
8
5
  /** Validated Location associated with a Conversation. */
9
6
  type Location = z.output<typeof locationSchema>;
10
- //#endregion
11
- //#region src/chat/actor.d.ts
12
7
  declare const storedSlackActorSchema: z.ZodObject<{
13
8
  email: z.ZodOptional<z.ZodString>;
14
9
  fullName: z.ZodOptional<z.ZodString>;
@@ -18,8 +13,6 @@ declare const storedSlackActorSchema: z.ZodObject<{
18
13
  teamId: z.ZodOptional<z.ZodString>;
19
14
  }, z.core.$strict>;
20
15
  type StoredSlackActor = z.output<typeof storedSlackActorSchema>;
21
- //#endregion
22
- //#region src/chat/source.d.ts
23
16
  /** Legacy provider Source fields stored on a Conversation. */
24
17
  type SessionSource = Extract<Source, {
25
18
  kind: "web";
@@ -28,8 +21,6 @@ type SessionSource = Extract<Source, {
28
21
  }> | Omit<Extract<Source, {
29
22
  kind: "slack";
30
23
  }>, "messageTs">;
31
- //#endregion
32
- //#region src/usage-schema.d.ts
33
24
  declare const usageSchema: z.ZodObject<{
34
25
  inputTokens: z.ZodOptional<z.ZodNumber>;
35
26
  outputTokens: z.ZodOptional<z.ZodNumber>;
@@ -46,8 +37,6 @@ declare const usageSchema: z.ZodObject<{
46
37
  }, z.core.$strict>>;
47
38
  }, z.core.$strict>;
48
39
  type Usage = z.output<typeof usageSchema>;
49
- //#endregion
50
- //#region src/chat/usage.d.ts
51
40
  /**
52
41
  * Structured token and cost usage captured for a single agent turn.
53
42
  *
@@ -57,8 +46,6 @@ type Usage = z.output<typeof usageSchema>;
57
46
  * whether to display a breakdown or a single aggregate.
58
47
  */
59
48
  type AgentTurnUsage = Usage;
60
- //#endregion
61
- //#region src/chat/conversations/store.d.ts
62
49
  type ConversationSource = "api" | "internal" | "local" | "plugin" | "event" | "scheduler" | "slack" | "web";
63
50
  type ConversationStatus = "paused" | "failed" | "idle" | "pending" | "running";
64
51
  interface ConversationExecution {
@@ -205,5 +192,4 @@ interface ConversationStore {
205
192
  offset?: number;
206
193
  }): Promise<Conversation[]>;
207
194
  }
208
- //#endregion
209
195
  export { ConversationStore as t };
@@ -1,9 +1,9 @@
1
- import { m as logWarn } from "./logging-CWxiIuCF.js";
2
- import { c as QUEUE_SIGNATURE_MAX_AGE_MS, d as createVercelQueueClient, l as signQueueMessage, p as runWithTurnRequestDeadline, u as verifyQueueMessage } from "./job-queue-B6SV9uVa.js";
1
+ import { m as logWarn } from "./logging-BStXN56b.js";
2
+ import { c as QUEUE_SIGNATURE_MAX_AGE_MS, d as createVercelQueueClient, l as signQueueMessage, p as runWithTurnRequestDeadline, u as verifyQueueMessage } from "./job-queue-vdGU-5ge.js";
3
3
  import { z } from "zod";
4
4
  import { createHash } from "node:crypto";
5
5
  import { handleCallback, registerDevConsumer } from "@vercel/queue";
6
- //#region src/chat/queue/callback.ts
6
+ // src/chat/queue/callback.ts
7
7
  /** Shared Vercel Queue callback wiring for signed messages. */
8
8
  /** Build the HTTP callback and local-dev consumer for one signed queue. */
9
9
  function queueCallback(options) {
@@ -56,8 +56,7 @@ function queueCallback(options) {
56
56
  }
57
57
  };
58
58
  }
59
- //#endregion
60
- //#region src/chat/plugins/task-queue.ts
59
+ // src/chat/plugins/task-queue.ts
61
60
  /**
62
61
  * Delivery for plugin-registered tasks.
63
62
  *
@@ -115,7 +114,7 @@ function pluginTaskCallback() {
115
114
  maxDeliveries: PLUGIN_TASK_MAX_DELIVERIES,
116
115
  onRejected: logPluginTaskQueueMessageRejected,
117
116
  run: async (message) => {
118
- const { processPluginTask } = await import("./task-runner-DUjvzYXj.js").then((n) => n.r);
117
+ const { processPluginTask } = await import("./task-runner-BlGhcQPi.js").then((n) => n.r);
119
118
  await processPluginTask(message);
120
119
  },
121
120
  topic: PLUGIN_TASK_QUEUE_TOPIC,
@@ -137,5 +136,4 @@ function createVercelPluginTaskCallback() {
137
136
  function registerVercelPluginTaskDevConsumer() {
138
137
  return pluginTaskCallback().registerDev();
139
138
  }
140
- //#endregion
141
139
  export { registerVercelPluginTaskDevConsumer as a, pluginTaskParamsSchema as i, createVercelPluginTaskCallback as n, sendVercelPluginTask as o, pluginTaskId as r, queueCallback as s, PLUGIN_TASK_QUEUE_TOPIC as t };
@@ -1,22 +1,22 @@
1
- import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
2
- import { g as runBestEffort, m as logWarn } from "./logging-CWxiIuCF.js";
3
- import { g as parseSlackMessageTs } from "./actor-BTtLaeWy.js";
4
- import { E as agentTurnTotalTokens, T as agentTurnCostUsd, d as getConversationStore, f as getDb, i as readActorIdentity } from "./viewer-DSZXygMU.js";
5
- import { s as juniorConversations } from "./agent-invocations-Bdu3ROfo.js";
6
- import { a as juniorAutomationRuns, s as juniorAutomations } from "./executor-Do0THDRR.js";
7
- import { m as sameActorIdentity } from "./history-9pO1Zd4Y.js";
8
- import { h as credentialSubjectSchema } from "./registry-sLTr-sV9.js";
9
- import { A as escapeSlackMrkdwnText, B as postSlackMessage, R as openSlackDirectMessage, Wt as hydrateConversationMessages, Xt as fallbackShortTitle, Z as getTurnRecord, _t as isToolResultMessage, bt as stripRuntimeTurnContext, gt as isToolResultError, i as readScheduledAutomation, j as formatSlackLink, l as blockEventAutomation, lt as getPiMessageRole, m as getEventAutomation, pt as instructionTextForProjection, vt as normalizeToolNameFromResult } from "./tasks-D_WIJtvO.js";
10
- import { St as createPluginConversationEvents, dt as createPluginModel, ft as createPluginLogger, it as JUNIOR_THREAD_STATE_TTL_MS, lt as createPluginState, p as coreTaskRegistrations, st as getDashboardTaskLink, u as getPlugins, ut as createPluginEmbedder } from "./agent-hooks-BjtTzvru.js";
11
- import { w as getStateAdapter } from "./profile-h-72wM78.js";
12
- import { r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-Ch4yuCqG.js";
13
- import { t as resolveConversationRouting } from "./turn-session-routing-B3LWooK5.js";
14
- import { i as pluginTaskParamsSchema, o as sendVercelPluginTask, r as pluginTaskId } from "./task-queue-B17vV0La.js";
1
+ import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
2
+ import { g as runBestEffort, m as logWarn } from "./logging-BStXN56b.js";
3
+ import { g as parseSlackMessageTs } from "./actor-tlxzqaRe.js";
4
+ import { T as agentTurnTotalTokens, d as getDb, r as readActorIdentity, u as getConversationStore, w as agentTurnCostUsd } from "./viewer-B2_ABsYi.js";
5
+ import { s as juniorConversations } from "./agent-invocations-Qfz7dWgU.js";
6
+ import { a as juniorAutomationRuns, s as juniorAutomations } from "./executor-Bb3eQb8q.js";
7
+ import { m as sameActorIdentity } from "./history-AY8rs-FR.js";
8
+ import { h as credentialSubjectSchema } from "./registry-B_M_x_iS.js";
9
+ import { A as escapeSlackMrkdwnText, B as postSlackMessage, R as openSlackDirectMessage, Wt as hydrateConversationMessages, Xt as fallbackShortTitle, Z as getTurnRecord, _t as isToolResultMessage, bt as stripRuntimeTurnContext, gt as isToolResultError, i as readScheduledAutomation, j as formatSlackLink, l as blockEventAutomation, lt as getPiMessageRole, m as getEventAutomation, pt as instructionTextForProjection, vt as normalizeToolNameFromResult } from "./tasks-DieKX3d4.js";
10
+ import { St as createPluginConversationEvents, dt as createPluginModel, ft as createPluginLogger, it as JUNIOR_THREAD_STATE_TTL_MS, lt as createPluginState, p as coreTaskRegistrations, st as getDashboardTaskLink, u as getPlugins, ut as createPluginEmbedder } from "./agent-hooks-B00FaKdP.js";
11
+ import { r as getStateAdapter } from "./adapter-Bn0gFVSF.js";
12
+ import { r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-DpSWS4Rr.js";
13
+ import { t as resolveConversationRouting } from "./turn-session-routing-BlajheOU.js";
14
+ import { i as pluginTaskParamsSchema, o as sendVercelPluginTask, r as pluginTaskId } from "./task-queue-BAeGEMjJ.js";
15
15
  import { z } from "zod";
16
16
  import { createHash } from "node:crypto";
17
17
  import { and, asc, count, desc, eq, gte, inArray, isNotNull, lte, max, sql } from "drizzle-orm";
18
18
  import { destinationSchema, destinationVisibilitySchema, isSlackDestination, pluginRunContextSchema, replyAttributionSchema, sourceSchema, taskOutcomeSchema } from "@sentry/junior-plugin-api";
19
- //#region src/api/conversations/aggregate.ts
19
+ // src/api/conversations/aggregate.ts
20
20
  function usageTokenValue(source, field) {
21
21
  return sql`CASE
22
22
  WHEN ${source.usage}->>${field} IS NOT NULL
@@ -98,8 +98,7 @@ function conversationRangeColumns() {
98
98
  function conversationActiveDaysColumn() {
99
99
  return sql`COUNT(DISTINCT (${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC')::date)::integer`;
100
100
  }
101
- //#endregion
102
- //#region src/chat/automations/execution-stats.ts
101
+ // src/chat/automations/execution-stats.ts
103
102
  const AUTOMATION_EXECUTION_STATUSES = [
104
103
  "blocked",
105
104
  "completed",
@@ -428,8 +427,7 @@ async function readExecutionStatusBuckets(args) {
428
427
  status: juniorAutomationRuns.status
429
428
  }).from(juniorAutomationRuns).where(and(isExecution(), eq(juniorAutomationRuns.automationId, args.automationId), gte(juniorAutomationRuns.completedAtMs, args.startMs), lte(juniorAutomationRuns.completedAtMs, args.endMs))).groupBy(args.bucket, juniorAutomationRuns.status).orderBy(asc(args.bucket), asc(juniorAutomationRuns.status));
430
429
  }
431
- //#endregion
432
- //#region src/chat/automations/blocked-notice.ts
430
+ // src/chat/automations/blocked-notice.ts
433
431
  function buildBlockedNoticeText(automationId, title, reason) {
434
432
  const url = getDashboardTaskLink(automationId);
435
433
  return [
@@ -458,8 +456,7 @@ async function notifyAutomationBlocked(ref) {
458
456
  ...ref.dispatchId ? { "app.dispatch.id": ref.dispatchId } : void 0
459
457
  });
460
458
  }
461
- //#endregion
462
- //#region src/chat/agent-dispatch/store.ts
459
+ // src/chat/agent-dispatch/store.ts
463
460
  const DISPATCH_PREFIX = "junior:agent_dispatch";
464
461
  const DISPATCH_LOCK_TTL_MS = 6e5;
465
462
  const DISPATCH_MAILBOX_APPEND_INDEX_LOCK_TTL_MS = 1e4;
@@ -555,6 +552,7 @@ function normalizeMetadata(metadata) {
555
552
  return entries.length > 0 ? Object.fromEntries(entries) : void 0;
556
553
  }
557
554
  const DISPATCH_ID_PREFIX = "agent-dispatch:";
555
+ /** Return the stable dispatch id for one plugin idempotency key. */
558
556
  function buildDispatchId(plugin, idempotencyKey) {
559
557
  return `dispatch_${createHash("sha256").update(plugin).update("\0").update(idempotencyKey).digest("hex").slice(0, 32)}`;
560
558
  }
@@ -785,8 +783,7 @@ async function getPluginDispatchProjection(args) {
785
783
  if (!record || record.plugin !== args.plugin) return;
786
784
  return toDispatchProjection(record);
787
785
  }
788
- //#endregion
789
- //#region src/chat/plugins/task-runner.ts
786
+ // src/chat/plugins/task-runner.ts
790
787
  var task_runner_exports = /* @__PURE__ */ __exportAll({
791
788
  processPluginTask: () => processPluginTask,
792
789
  scheduleSessionCompletedPluginTasks: () => scheduleSessionCompletedPluginTasks
@@ -1032,9 +1029,8 @@ async function scheduleSessionCompletedPluginTasks(params, options = {}) {
1032
1029
  async function processPluginTask(message, options = {}) {
1033
1030
  await withPluginTaskLock(pluginTaskId(message), async () => {
1034
1031
  const resolved = findPluginTask(message);
1035
- if (!resolved) throw new Error(`Plugin task "${message.plugin}.${message.name}" is not registered`);
1032
+ if (!resolved?.task) throw new Error(`Plugin task "${message.plugin}.${message.name}" is not registered`);
1036
1033
  await resolved.task.run(taskPluginContext(resolved.plugin, message, options));
1037
1034
  });
1038
1035
  }
1039
- //#endregion
1040
- export { readAutomationRuns as A, readAutomationExecutionByConversationId as C, readAutomationExecutionStatusHours as D, readAutomationExecutionStatusDays as E, conversationRangeColumns as F, recordAutomationExecution as M, conversationActiveDaysColumn as N, readAutomationExecutionSummaries as O, conversationAggregateColumns as P, existingConversationId as S, readAutomationExecutionHours as T, markDispatchCompleted as _, confirmDispatchMailboxAppend as a, notifyAutomationBlocked as b, getDispatchIdForConversation as c, getDispatchTurnId as d, getPluginDispatchProjection as f, markDispatchBlocked as g, markDispatchAwaitingResume as h, claimDispatchMailboxAppend as i, readAutomationTitlesByConversationId as j, readAutomationExecutions as k, getDispatchInputMessageId as l, listPendingDispatchMailboxAppends as m, scheduleSessionCompletedPluginTasks as n, createOrGetDispatch as o, isTerminalDispatchStatus as p, task_runner_exports as r, getDispatchConversationId as s, processPluginTask as t, getDispatchRecord as u, markDispatchFailed as v, readAutomationExecutionDays as w, emptyAutomationRunWindows as x, markDispatchRunning as y };
1036
+ export { readAutomationExecutions as A, existingConversationId as C, readAutomationExecutionStatusDays as D, readAutomationExecutionHours as E, conversationAggregateColumns as F, conversationRangeColumns as I, readAutomationTitlesByConversationId as M, recordAutomationExecution as N, readAutomationExecutionStatusHours as O, conversationActiveDaysColumn as P, emptyAutomationRunWindows as S, readAutomationExecutionDays as T, markDispatchBlocked as _, claimDispatchMailboxAppend as a, markDispatchRunning as b, getDispatchConversationId as c, getDispatchRecord as d, getDispatchTurnId as f, markDispatchAwaitingResume as g, listPendingDispatchMailboxAppends as h, buildDispatchId as i, readAutomationRuns as j, readAutomationExecutionSummaries as k, getDispatchIdForConversation as l, isTerminalDispatchStatus as m, scheduleSessionCompletedPluginTasks as n, confirmDispatchMailboxAppend as o, getPluginDispatchProjection as p, task_runner_exports as r, createOrGetDispatch as s, processPluginTask as t, getDispatchInputMessageId as u, markDispatchCompleted as v, readAutomationExecutionByConversationId as w, notifyAutomationBlocked as x, markDispatchFailed as y };