@sentry/junior 0.136.1 → 0.137.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 (58) hide show
  1. package/dist/{agent-hooks-2KDSPPO4.js → agent-hooks-MZOKEP3J.js} +9 -9
  2. package/dist/api/conversations/projection.d.ts +1 -0
  3. package/dist/api/conversations/stats.d.ts +1 -0
  4. package/dist/api/schema/conversation.d.ts +2 -0
  5. package/dist/api/schema.js +1 -1
  6. package/dist/api.js +185 -47
  7. package/dist/app.d.ts +1 -1
  8. package/dist/app.js +293 -193
  9. package/dist/{catalog-runtime-WSZQGC4D.js → catalog-runtime-MD66YLFV.js} +5 -5
  10. package/dist/chat/configuration/defaults.d.ts +1 -1
  11. package/dist/chat/conversations/store.d.ts +2 -1
  12. package/dist/chat/pi/client.d.ts +1 -8
  13. package/dist/chat/pi/gateway-auth.d.ts +16 -0
  14. package/dist/chat/sandbox/docker.d.ts +17 -0
  15. package/dist/chat/services/agent-continue.d.ts +2 -0
  16. package/dist/chat/services/subscribed-reply-router-policy.d.ts +12 -0
  17. package/dist/chat/services/turn-session-routing.d.ts +17 -0
  18. package/dist/chat/slack/message.d.ts +6 -1
  19. package/dist/chat/slack/source-link.d.ts +8 -2
  20. package/dist/chat/slack/team-domain.d.ts +4 -0
  21. package/dist/chat/source.d.ts +5 -5
  22. package/dist/{chunk-3QNJOHKG.js → chunk-36EG34YI.js} +1 -1
  23. package/dist/{chunk-FSYXYBWU.js → chunk-3Q342EJJ.js} +2 -2
  24. package/dist/{chunk-4YQ6I6VF.js → chunk-5G34IEK2.js} +1 -1
  25. package/dist/{chunk-BG3KWWDJ.js → chunk-5PNJMOY5.js} +1 -1
  26. package/dist/{chunk-3SUK3UXX.js → chunk-6QW2RRQT.js} +5 -5
  27. package/dist/{chunk-VH6MI4L7.js → chunk-BZAMASJP.js} +1 -1
  28. package/dist/{chunk-CDVCCOMF.js → chunk-DQXAAVTR.js} +43 -20
  29. package/dist/{chunk-G66RYKRS.js → chunk-EWDSB24B.js} +7 -7
  30. package/dist/{chunk-TRZSM67C.js → chunk-HCIVH3JS.js} +1 -0
  31. package/dist/{chunk-UX2TNH5D.js → chunk-K2NCQJKH.js} +3 -3
  32. package/dist/{chunk-OTJMQYVP.js → chunk-KJ4HGRHN.js} +24 -26
  33. package/dist/{chunk-NVVBEJUB.js → chunk-POBSY47Q.js} +6 -4
  34. package/dist/{chunk-MW2QRPGW.js → chunk-RB4NJKEX.js} +1 -1
  35. package/dist/{chunk-Y6JNHTRD.js → chunk-SYCX4DOK.js} +34 -17
  36. package/dist/{chunk-XWPA5KZF.js → chunk-T6Z5S6PQ.js} +1 -1
  37. package/dist/{chunk-XCZ6COFO.js → chunk-UG6ZYPBI.js} +42 -19
  38. package/dist/{chunk-CZZDCH3Q.js → chunk-UOXATPSI.js} +203 -77
  39. package/dist/{chunk-RFDD3Z2I.js → chunk-UZQ4VY3M.js} +1 -1
  40. package/dist/{chunk-KLBYCSLJ.js → chunk-WPPXIAFB.js} +5 -5
  41. package/dist/{chunk-JQRTXJHD.js → chunk-XZ7NPXAB.js} +2 -1
  42. package/dist/{chunk-22Z6MGMK.js → chunk-YNFERGKP.js} +1 -1
  43. package/dist/{chunk-TYNMSQKA.js → chunk-YRPC6MJY.js} +1 -1
  44. package/dist/{chunk-HIRIWTWD.js → chunk-ZFS67WIR.js} +4 -7
  45. package/dist/cli/chat.js +24 -24
  46. package/dist/cli/check.js +7 -7
  47. package/dist/cli/plugins.js +12 -12
  48. package/dist/cli/snapshot-create.js +9 -9
  49. package/dist/cli/upgrade.js +7 -7
  50. package/dist/{db-Z2NNL2JC.js → db-66E7VDNC.js} +7 -7
  51. package/dist/instrumentation.js +4 -4
  52. package/dist/nitro.js +2 -2
  53. package/dist/{oauth-callback-server-PO3M5JMG.js → oauth-callback-server-7QPD4Q7P.js} +17 -17
  54. package/dist/{runner-QHQYZYJA.js → runner-L2BKJKOD.js} +11 -11
  55. package/dist/{skills-KXMT3DRA.js → skills-HOQ2NSPW.js} +6 -6
  56. package/dist/{validation-Y42ULTT6.js → validation-ENHI7S2C.js} +6 -6
  57. package/dist/version.js +1 -1
  58. package/package.json +5 -4
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  pluginCatalogRuntime
3
- } from "./chunk-3QNJOHKG.js";
4
- import "./chunk-VH6MI4L7.js";
3
+ } from "./chunk-36EG34YI.js";
4
+ import "./chunk-BZAMASJP.js";
5
5
  import "./chunk-77VDLF3Z.js";
6
6
  import "./chunk-HZF5P5UN.js";
7
7
  import "./chunk-F3B2YJ76.js";
8
- import "./chunk-XWPA5KZF.js";
8
+ import "./chunk-T6Z5S6PQ.js";
9
9
  import "./chunk-6GWA276C.js";
10
10
  import "./chunk-OOUNJNMR.js";
11
11
  import "./chunk-H4HBKISO.js";
12
- import "./chunk-BG3KWWDJ.js";
13
- import "./chunk-JQRTXJHD.js";
12
+ import "./chunk-5PNJMOY5.js";
13
+ import "./chunk-XZ7NPXAB.js";
14
14
  import "./chunk-MLKGABMK.js";
15
15
  export {
16
16
  pluginCatalogRuntime
@@ -1,4 +1,4 @@
1
- /** Store install-wide config defaults; keys must be registered plugin config keys. */
1
+ /** Store install-wide configuration defaults. */
2
2
  export declare function setConfigDefaults(defaults: Record<string, unknown> | undefined): void;
3
3
  /** Return the install-wide configuration defaults (empty object when none set). */
4
4
  export declare function getConfigDefaults(): Record<string, unknown>;
@@ -32,7 +32,8 @@ export interface Conversation {
32
32
  source?: ConversationSource;
33
33
  /**
34
34
  * Structured inbound Source locator for this conversation session.
35
- * Session-stable (Slack thread anchor, not per-message ts). Set-once.
35
+ * Session-stable (threaded Slack keeps threadTs; channel-level turns omit
36
+ * it; never stores per-message ts). Set-once.
36
37
  */
37
38
  sessionSource?: SessionSource;
38
39
  title?: string;
@@ -1,16 +1,9 @@
1
1
  import { type Message, type Model, type ThinkingLevel } from "@/chat/pi/sdk";
2
+ export { getGatewayApiKey, MISSING_GATEWAY_CREDENTIALS_ERROR, resolveGatewayCredential, type GatewayCredential, } from "@/chat/pi/gateway-auth";
2
3
  import type { ZodTypeAny, z } from "zod";
3
4
  export declare const GEN_AI_PROVIDER_NAME: "vercel-ai-gateway";
4
5
  export declare const GEN_AI_SERVER_ADDRESS = "ai-gateway.vercel.sh";
5
6
  export declare const GEN_AI_SERVER_PORT = 443;
6
- export declare const MISSING_GATEWAY_CREDENTIALS_ERROR = "Missing AI gateway credentials (AI_GATEWAY_API_KEY or VERCEL_OIDC_TOKEN)";
7
- /**
8
- * Resolve the documented AI Gateway env credentials for the paths that need
9
- * the bearer token string directly.
10
- */
11
- export declare function getGatewayApiKey(): string | undefined;
12
- /** Return the Gateway credential shape expected by Pi Agent getApiKey hooks. */
13
- export declare function getPiGatewayApiKey(): string | undefined;
14
7
  /**
15
8
  * Look up a gateway model by id. Throws `Unknown AI Gateway model id: …` if
16
9
  * the id is not in pi-ai's registry — callers at the config boundary can use
@@ -0,0 +1,16 @@
1
+ export type GatewayCredential = {
2
+ mode: "oidc" | "api_key";
3
+ token: string;
4
+ };
5
+ export declare const MISSING_GATEWAY_CREDENTIALS_ERROR = "Missing AI gateway credentials (enable Vercel OIDC or set AI_GATEWAY_API_KEY)";
6
+ /**
7
+ * Resolve the preferred AI Gateway bearer credential.
8
+ *
9
+ * Order:
10
+ * 1. Vercel OIDC via `@vercel/oidc` (request header `x-vercel-oidc-token`,
11
+ * then `VERCEL_OIDC_TOKEN`, with local refresh when needed)
12
+ * 2. Explicit `AI_GATEWAY_API_KEY` / pi-ai env mapping for vercel-ai-gateway
13
+ */
14
+ export declare function resolveGatewayCredential(): Promise<GatewayCredential | undefined>;
15
+ /** Resolve the bearer token string for Authorization headers and Pi getApiKey. */
16
+ export declare function getGatewayApiKey(): Promise<string | undefined>;
@@ -0,0 +1,17 @@
1
+ import type { SandboxWorkspace } from "@/chat/sandbox/workspace";
2
+ /** Docker daemon config for Vercel sandbox guests (nested containers). */
3
+ export declare const DOCKER_DAEMON_JSON = "{\n \"storage-driver\": \"overlay2\",\n \"live-restore\": false\n}\n";
4
+ /**
5
+ * Start dockerd when the socket is missing and wait until `docker info` works.
6
+ * Re-execs through sudo so the sandbox user can call it without root.
7
+ */
8
+ export declare const DOCKER_ENSURE_SCRIPT = "#!/bin/sh\nset -eu\n\nif [ \"$(id -u)\" -ne 0 ]; then\n exec sudo -n \"$0\" \"$@\"\nfi\n\nSOCK=/var/run/docker.sock\nPIDFILE=/var/run/docker.pid\nLOG=/var/log/junior-dockerd.log\n\nis_ready() {\n [ -S \"$SOCK\" ] && /usr/bin/docker info >/dev/null 2>&1\n}\n\nif is_ready; then\n chmod 666 \"$SOCK\" 2>/dev/null || true\n exit 0\nfi\n\nmkdir -p /etc/docker /var/lib/docker /var/run /var/log\nif [ ! -f /etc/docker/daemon.json ]; then\n cat > /etc/docker/daemon.json <<'EOF'\n{\n \"storage-driver\": \"overlay2\",\n \"live-restore\": false\n}\nEOF\nfi\n\nif [ -f \"$PIDFILE\" ]; then\n oldpid=\"$(cat \"$PIDFILE\" 2>/dev/null || true)\"\n if [ -n \"${oldpid:-}\" ] && ! kill -0 \"$oldpid\" 2>/dev/null; then\n rm -f \"$PIDFILE\"\n fi\nfi\n\nif [ ! -f \"$PIDFILE\" ] || ! kill -0 \"$(cat \"$PIDFILE\" 2>/dev/null)\" 2>/dev/null; then\n # dockerd must outlive this helper; nohup + background is intentional.\n nohup dockerd --host=\"unix://$SOCK\" --pidfile=\"$PIDFILE\" >\"$LOG\" 2>&1 &\nfi\n\ni=0\nwhile [ \"$i\" -lt 50 ]; do\n if is_ready; then\n chmod 666 \"$SOCK\" 2>/dev/null || true\n exit 0\n fi\n i=$((i + 1))\n sleep 0.1\ndone\n\necho \"junior-ensure-docker: dockerd failed to become ready\" >&2\nif [ -f \"$LOG\" ]; then\n tail -n 50 \"$LOG\" >&2 || true\nfi\nexit 1\n";
9
+ /** PATH wrapper so plain `docker` starts the daemon on first use. */
10
+ export declare const DOCKER_CLI_WRAPPER_SCRIPT = "#!/bin/sh\nset -eu\nif command -v junior-ensure-docker >/dev/null 2>&1; then\n junior-ensure-docker\nfi\nexec /usr/bin/docker \"$@\"\n";
11
+ /** PATH wrapper so plain `docker-compose` starts the daemon on first use. */
12
+ export declare const DOCKER_COMPOSE_CLI_WRAPPER_SCRIPT = "#!/bin/sh\nset -eu\nif command -v junior-ensure-docker >/dev/null 2>&1; then\n junior-ensure-docker\nfi\nexec /usr/local/libexec/junior-docker-compose \"$@\"\n";
13
+ /**
14
+ * Best-effort dockerd start during sandbox prepare.
15
+ * Missing helper is a no-op so tests and base sandboxes stay green.
16
+ */
17
+ export declare function ensureDockerDaemon(sandbox: Pick<SandboxWorkspace, "runCommand">, signal?: AbortSignal): Promise<void>;
@@ -6,6 +6,7 @@
6
6
  */
7
7
  import type { StateAdapter } from "chat";
8
8
  import type { Destination } from "@sentry/junior-plugin-api";
9
+ import type { ConversationStore } from "@/chat/conversations/store";
9
10
  import type { ConversationWorkQueue } from "@/chat/task-execution/queue";
10
11
  export interface AgentContinueRequest {
11
12
  conversationId: string;
@@ -21,6 +22,7 @@ export interface ScheduleAgentContinueOptions {
21
22
  /** Build the queue request for an awaiting automatic agent continuation. */
22
23
  export declare function getAwaitingAgentContinueRequest(args: {
23
24
  conversationId: string;
25
+ conversationStore?: ConversationStore;
24
26
  sessionId: string;
25
27
  }): Promise<AgentContinueRequest | undefined>;
26
28
  /** Schedule durable conversation work to continue a paused agent run. */
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Passive subscribed-thread reply router policy.
3
+ *
4
+ * Modeled after Junior's Guardian action-review policy shape and the open-source
5
+ * Codex Guardian evidence/prompt pattern:
6
+ * https://github.com/openai/codex/tree/main/codex-rs/core/src/guardian
7
+ *
8
+ * Guardian judges one planned tool action from bounded transcript evidence.
9
+ * This router judges one inbound Slack message from bounded visible
10
+ * user/assistant thread evidence and decides whether Junior should reply.
11
+ */
12
+ export declare function buildSubscribedReplyRouterPolicy(assistantName: string): string;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Load turn-session routing from durable conversation metadata.
3
+ *
4
+ * SQL owns destination and session source. Resume paths query those columns
5
+ * directly — no redis fallback and no derived rebuild of missing fields.
6
+ */
7
+ import type { Destination, Source } from "@sentry/junior-plugin-api";
8
+ import type { ConversationStore } from "@/chat/conversations/store";
9
+ export interface TurnSessionRouting {
10
+ destination: Destination;
11
+ source: Source;
12
+ }
13
+ /** Require conversation destination and session source from SQL. */
14
+ export declare function resolveTurnSessionRouting(args: {
15
+ conversationId: string;
16
+ conversationStore?: ConversationStore;
17
+ }): Promise<TurnSessionRouting>;
@@ -1,7 +1,12 @@
1
- import type { Message } from "chat";
1
+ import { type Message } from "chat";
2
2
  import { type SlackMessageTs } from "@/chat/slack/timestamp";
3
3
  /**
4
4
  * Preserve the native Slack message timestamp when a synthetic message ID is
5
5
  * used for routing or deduplication.
6
6
  */
7
7
  export declare function getSlackMessageTs(message: Pick<Message, "id" | "raw">): SlackMessageTs | undefined;
8
+ /**
9
+ * Return the Chat SDK's canonical formatted representation by default.
10
+ * Fall back to plain text only when the message has no formatted content.
11
+ */
12
+ export declare function getSlackMessageText(message: Pick<Message, "formatted" | "text">): string;
@@ -1,5 +1,11 @@
1
- /** Build Slack's browser-safe redirect to a conversation when its IDs are valid. */
1
+ /** Parse a Slack workspace subdomain used in `https://{domain}.slack.com` URLs. */
2
+ export declare function parseSlackTeamDomain(value: unknown): string | undefined;
3
+ /**
4
+ * Build a direct Slack archive URL for a thread when the workspace domain is
5
+ * known. Omits a link rather than falling back to `app_redirect`.
6
+ */
2
7
  export declare function buildSlackSourceUrl(args: {
3
8
  channelId: string;
4
- teamId: string;
9
+ teamDomain: string;
10
+ threadTs: string;
5
11
  }): string | undefined;
@@ -0,0 +1,4 @@
1
+ /** Resolve a workspace subdomain via `team.info`, cached by team id. */
2
+ export declare function resolveSlackTeamDomain(teamId: string): Promise<string | undefined>;
3
+ /** Resolve workspace subdomains for the distinct team ids in one API response. */
4
+ export declare function resolveSlackTeamDomains(teamIds: Iterable<string>): Promise<ReadonlyMap<string, string>>;
@@ -2,14 +2,14 @@ import { type Source } from "@sentry/junior-plugin-api";
2
2
  /** Source coordinates reduced to the stable locator for one conversation. */
3
3
  export type SessionSource = Extract<Source, {
4
4
  platform: "local";
5
- }> | (Omit<Extract<Source, {
5
+ }> | Omit<Extract<Source, {
6
6
  platform: "slack";
7
- }>, "messageTs" | "threadTs"> & {
8
- threadTs: string;
9
- });
7
+ }>, "messageTs">;
10
8
  /**
11
9
  * Normalize a turn Source into the session-stable locator persisted on a
12
- * conversation. Drops per-message timestamps; requires a Slack thread anchor.
10
+ * conversation. Drops per-message timestamps. Threaded Slack turns keep their
11
+ * thread anchor; channel-level turns (scheduled/event dispatch) keep the
12
+ * channel locator without inventing a threadTs.
13
13
  */
14
14
  export declare function normalizeSessionSource(value: Source | undefined): SessionSource | undefined;
15
15
  /** Parse a serialized Source into the stable locator stored on a conversation. */
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createPluginCatalogRuntime
3
- } from "./chunk-VH6MI4L7.js";
3
+ } from "./chunk-BZAMASJP.js";
4
4
 
5
5
  // src/chat/plugins/catalog-runtime.ts
6
6
  var pluginCatalogRuntime = createPluginCatalogRuntime();
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  pluginCatalogRuntime
3
- } from "./chunk-3QNJOHKG.js";
3
+ } from "./chunk-36EG34YI.js";
4
4
  import {
5
5
  logWarn
6
- } from "./chunk-XWPA5KZF.js";
6
+ } from "./chunk-T6Z5S6PQ.js";
7
7
  import {
8
8
  skillRoots
9
9
  } from "./chunk-H4HBKISO.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getChatConfig
3
- } from "./chunk-XCZ6COFO.js";
3
+ } from "./chunk-UG6ZYPBI.js";
4
4
 
5
5
  // src/chat/sandbox/paths.ts
6
6
  function normalizeWorkspaceRoot(input) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  JUNIOR_VERSION
3
- } from "./chunk-JQRTXJHD.js";
3
+ } from "./chunk-XZ7NPXAB.js";
4
4
 
5
5
  // src/deployment.ts
6
6
  var JUNIOR_HEARTBEAT_ROUTE = "/api/internal/heartbeat";
@@ -3,19 +3,19 @@ import {
3
3
  } from "./chunk-UTL3MHPC.js";
4
4
  import {
5
5
  parseSlackThreadId
6
- } from "./chunk-TYNMSQKA.js";
6
+ } from "./chunk-YRPC6MJY.js";
7
7
  import {
8
8
  normalizeSlackConversationId
9
- } from "./chunk-KLBYCSLJ.js";
9
+ } from "./chunk-WPPXIAFB.js";
10
10
  import {
11
11
  getDb
12
- } from "./chunk-HIRIWTWD.js";
12
+ } from "./chunk-ZFS67WIR.js";
13
13
  import {
14
14
  juniorTaskExecutions
15
- } from "./chunk-MW2QRPGW.js";
15
+ } from "./chunk-RB4NJKEX.js";
16
16
  import {
17
17
  logWarn
18
- } from "./chunk-XWPA5KZF.js";
18
+ } from "./chunk-T6Z5S6PQ.js";
19
19
 
20
20
  // src/handlers/health.ts
21
21
  function readHealthReport() {
@@ -5,7 +5,7 @@ import {
5
5
  logInfo,
6
6
  logWarn,
7
7
  setSpanAttributes
8
- } from "./chunk-XWPA5KZF.js";
8
+ } from "./chunk-T6Z5S6PQ.js";
9
9
  import {
10
10
  discoverInstalledPluginPackageContent,
11
11
  normalizePluginPackageNames
@@ -12,8 +12,9 @@ import {
12
12
  getTurnUserSlackMessageTs,
13
13
  persistAuthPauseTurnState,
14
14
  requireTurnFailureEventId,
15
+ resolveTurnSessionRouting,
15
16
  scheduleSessionCompletedPluginTasks
16
- } from "./chunk-Y6JNHTRD.js";
17
+ } from "./chunk-SYCX4DOK.js";
17
18
  import {
18
19
  buildSentryConversationUrl
19
20
  } from "./chunk-4CODA7P5.js";
@@ -40,7 +41,7 @@ import {
40
41
  resolveBaseUrl,
41
42
  resolvePluginOAuthAccount,
42
43
  truncateStatusText
43
- } from "./chunk-G66RYKRS.js";
44
+ } from "./chunk-EWDSB24B.js";
44
45
  import {
45
46
  JUNIOR_THREAD_STATE_TTL_MS,
46
47
  TurnSliceLimitExceededError,
@@ -72,13 +73,13 @@ import {
72
73
  recordDeliveredAssistantMessage,
73
74
  turnHasReply,
74
75
  updateConversationStats
75
- } from "./chunk-NVVBEJUB.js";
76
+ } from "./chunk-POBSY47Q.js";
76
77
  import {
77
78
  parseSlackThreadId,
78
79
  readSlackRawMessageContext,
79
80
  resolveSlackChannelIdFromMessage,
80
81
  resolveSlackChannelIdFromThreadId
81
- } from "./chunk-TYNMSQKA.js";
82
+ } from "./chunk-YRPC6MJY.js";
82
83
  import {
83
84
  SlackActionError,
84
85
  getDashboardConversationLink,
@@ -87,19 +88,19 @@ import {
87
88
  getSlackClient,
88
89
  isDmChannel,
89
90
  normalizeSlackConversationId
90
- } from "./chunk-KLBYCSLJ.js";
91
+ } from "./chunk-WPPXIAFB.js";
91
92
  import {
92
93
  getConversationEventStore,
93
94
  getConversationStore,
94
95
  parseDestination,
95
96
  requireSlackDestination,
96
97
  sameDestination
97
- } from "./chunk-HIRIWTWD.js";
98
+ } from "./chunk-ZFS67WIR.js";
98
99
  import {
99
100
  acquireActiveLock,
100
101
  getDefaultRedisStateAdapterFor,
101
102
  getStateAdapter
102
- } from "./chunk-4YQ6I6VF.js";
103
+ } from "./chunk-5G34IEK2.js";
103
104
  import {
104
105
  FUNCTION_TIMEOUT_BUFFER_SECONDS,
105
106
  botConfig,
@@ -108,18 +109,18 @@ import {
108
109
  getRuntimeMetadata,
109
110
  normalizeSlackEmojiName,
110
111
  standardModelId
111
- } from "./chunk-XCZ6COFO.js";
112
+ } from "./chunk-UG6ZYPBI.js";
112
113
  import {
113
114
  discoverSkills
114
- } from "./chunk-FSYXYBWU.js";
115
+ } from "./chunk-3Q342EJJ.js";
115
116
  import {
116
117
  pluginCatalogRuntime
117
- } from "./chunk-3QNJOHKG.js";
118
+ } from "./chunk-36EG34YI.js";
118
119
  import {
119
120
  buildOAuthTokenRequest,
120
121
  hasRequiredOAuthScope,
121
122
  parseOAuthTokenResponse
122
- } from "./chunk-VH6MI4L7.js";
123
+ } from "./chunk-BZAMASJP.js";
123
124
  import {
124
125
  createSlackResumeActor,
125
126
  isUserActor,
@@ -138,7 +139,7 @@ import {
138
139
  toOptionalNumber,
139
140
  toOptionalString,
140
141
  withLogContext
141
- } from "./chunk-XWPA5KZF.js";
142
+ } from "./chunk-T6Z5S6PQ.js";
142
143
  import {
143
144
  homeDir
144
145
  } from "./chunk-H4HBKISO.js";
@@ -3152,12 +3153,24 @@ async function getAwaitingAgentContinueRequest(args) {
3152
3153
  if (!sessionRecord || sessionRecord.state !== "awaiting_resume" || sessionRecord.resumeReason !== "timeout" && sessionRecord.resumeReason !== "yield" && sessionRecord.resumeReason !== "retry" || sessionRecord.resumeReason === "timeout" && sessionRecord.sliceId < 2) {
3153
3154
  return void 0;
3154
3155
  }
3155
- if (!sessionRecord.destination) {
3156
+ let routing;
3157
+ try {
3158
+ routing = await resolveTurnSessionRouting({
3159
+ conversationId: args.conversationId,
3160
+ conversationStore: args.conversationStore
3161
+ });
3162
+ } catch (error) {
3163
+ await failAgentTurnSessionRecord({
3164
+ conversationId: args.conversationId,
3165
+ expectedVersion: sessionRecord.version,
3166
+ sessionId: args.sessionId,
3167
+ errorMessage: error instanceof Error ? error.message : String(error)
3168
+ });
3156
3169
  return void 0;
3157
3170
  }
3158
3171
  return {
3159
3172
  conversationId: args.conversationId,
3160
- destination: sessionRecord.destination,
3173
+ destination: routing.destination,
3161
3174
  sessionId: args.sessionId,
3162
3175
  expectedVersion: sessionRecord.version
3163
3176
  };
@@ -3444,12 +3457,17 @@ async function resumeAuthorizedMcpTurn(args) {
3444
3457
  });
3445
3458
  return false;
3446
3459
  }
3447
- if (!lockedSessionRecord.source) {
3460
+ let routing;
3461
+ try {
3462
+ routing = await resolveTurnSessionRouting({
3463
+ conversationId: authSession.conversationId
3464
+ });
3465
+ } catch (error) {
3448
3466
  await failAgentTurnSessionRecord({
3449
3467
  conversationId: authSession.conversationId,
3450
3468
  expectedVersion: lockedSessionRecord.version,
3451
3469
  sessionId: lockedSessionId,
3452
- errorMessage: "Stored Slack source missing for MCP OAuth resume"
3470
+ errorMessage: error instanceof Error ? error.message : String(error)
3453
3471
  });
3454
3472
  return false;
3455
3473
  }
@@ -3483,7 +3501,7 @@ async function resumeAuthorizedMcpTurn(args) {
3483
3501
  },
3484
3502
  actor,
3485
3503
  destination,
3486
- source: lockedSessionRecord.source,
3504
+ source: routing.source,
3487
3505
  toolChannelId: authSession.toolChannelId ?? lockedArtifacts.assistantContextChannelId ?? authSession.channelId
3488
3506
  },
3489
3507
  policy: {
@@ -4073,12 +4091,17 @@ async function resumeOAuthSessionRecordTurn(stored, options) {
4073
4091
  });
4074
4092
  return false;
4075
4093
  }
4076
- if (!lockedSessionRecord.source) {
4094
+ let routing;
4095
+ try {
4096
+ routing = await resolveTurnSessionRouting({
4097
+ conversationId: stored.resumeConversationId
4098
+ });
4099
+ } catch (error) {
4077
4100
  await failAgentTurnSessionRecord({
4078
4101
  conversationId: stored.resumeConversationId,
4079
4102
  expectedVersion: lockedSessionRecord.version,
4080
4103
  sessionId: lockedSessionId,
4081
- errorMessage: "Stored Slack source missing for OAuth resume"
4104
+ errorMessage: error instanceof Error ? error.message : String(error)
4082
4105
  });
4083
4106
  return false;
4084
4107
  }
@@ -4117,7 +4140,7 @@ async function resumeOAuthSessionRecordTurn(stored, options) {
4117
4140
  },
4118
4141
  actor,
4119
4142
  destination,
4120
- source: lockedSessionRecord.source,
4143
+ source: routing.source,
4121
4144
  toolChannelId: lockedArtifacts.assistantContextChannelId ?? stored.channelId
4122
4145
  },
4123
4146
  policy: {
@@ -6,25 +6,25 @@ import {
6
6
  isDmChannel,
7
7
  normalizeSlackConversationId,
8
8
  withSlackRetries
9
- } from "./chunk-KLBYCSLJ.js";
9
+ } from "./chunk-WPPXIAFB.js";
10
10
  import {
11
11
  getDb,
12
12
  parseDestination
13
- } from "./chunk-HIRIWTWD.js";
13
+ } from "./chunk-ZFS67WIR.js";
14
14
  import {
15
15
  acquireActiveLock,
16
16
  getStateAdapter,
17
17
  sleep
18
- } from "./chunk-4YQ6I6VF.js";
18
+ } from "./chunk-5G34IEK2.js";
19
19
  import {
20
20
  normalizeSlackEmojiName
21
- } from "./chunk-XCZ6COFO.js";
21
+ } from "./chunk-UG6ZYPBI.js";
22
22
  import {
23
23
  pluginCatalogRuntime
24
- } from "./chunk-3QNJOHKG.js";
24
+ } from "./chunk-36EG34YI.js";
25
25
  import {
26
26
  fetchWithBoundedOAuthErrorBodies
27
- } from "./chunk-VH6MI4L7.js";
27
+ } from "./chunk-BZAMASJP.js";
28
28
  import {
29
29
  parseSlackMessageTs,
30
30
  parseSlackUserId
@@ -33,7 +33,7 @@ import {
33
33
  isRecord,
34
34
  logInfo,
35
35
  logWarn
36
- } from "./chunk-XWPA5KZF.js";
36
+ } from "./chunk-T6Z5S6PQ.js";
37
37
 
38
38
  // src/chat/capabilities/router.ts
39
39
  var ProviderCredentialRouter = class {
@@ -433,6 +433,7 @@ var conversationStatsItemSchema = z2.object({
433
433
  tokens: z2.number().optional()
434
434
  }).strict();
435
435
  var conversationMetricDaySchema = z2.object({
436
+ conversations: z2.number(),
436
437
  costUsd: z2.number().optional(),
437
438
  date: z2.string(),
438
439
  durationMs: z2.number(),
@@ -4,16 +4,16 @@ import {
4
4
  import {
5
5
  canRouteResourceEvents,
6
6
  getPlugins
7
- } from "./chunk-KLBYCSLJ.js";
7
+ } from "./chunk-WPPXIAFB.js";
8
8
  import {
9
9
  getDb
10
- } from "./chunk-HIRIWTWD.js";
10
+ } from "./chunk-ZFS67WIR.js";
11
11
  import {
12
12
  juniorEventTasks,
13
13
  juniorSchedulerRuns,
14
14
  juniorSchedulerTasks,
15
15
  juniorStats
16
- } from "./chunk-MW2QRPGW.js";
16
+ } from "./chunk-RB4NJKEX.js";
17
17
  import {
18
18
  juniorDestinations
19
19
  } from "./chunk-VFUK3X5B.js";