@sentry/junior 0.224.0 → 0.226.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 (63) hide show
  1. package/dist/{agent-hooks-DNLBwmsh.js → agent-hooks-FUetyyLe.js} +23 -16
  2. package/dist/{agent-runner-9g6TQk9y.js → agent-runner-DEF7auSj.js} +3114 -318
  3. package/dist/api/schema.d.ts +353 -10
  4. package/dist/api/schema.js +4 -4
  5. package/dist/api.js +22 -18
  6. package/dist/{app-BbSD6EtD.d.ts → app-TVL42pGL.d.ts} +1 -1
  7. package/dist/app.d.ts +1 -1
  8. package/dist/app.js +893 -7660
  9. package/dist/{briefs-CjXnGKzZ.js → briefs-Cb4T2BUI.js} +5 -5
  10. package/dist/{catalog-runtime-CVZ9TEuK.js → catalog-runtime-BYGR3Dr4.js} +1 -1
  11. package/dist/{checkpoint-Ceck_fLO.js → checkpoint-CJe-dZFF.js} +76 -10
  12. package/dist/cli/chat.js +13 -13
  13. package/dist/cli/check.js +3 -3
  14. package/dist/cli/main.js +1 -1
  15. package/dist/cli/plugins.js +3 -3
  16. package/dist/cli/snapshot-create.js +3 -3
  17. package/dist/cli/upgrade.js +3 -3
  18. package/dist/{client-B27ufhzl.js → client-C2WBBx7m.js} +2 -2
  19. package/dist/{config-BAhl7-RC.js → config-Bws6Rpsh.js} +11 -13
  20. package/dist/{conversation-1HUoZr2l.js → conversation-DPbmIwjy.js} +67 -6
  21. package/dist/{conversation-privacy-C-4JQzKD.js → conversation-privacy-pCcW0a5Y.js} +1 -1
  22. package/dist/{credential-sync-BXHIxbtS.js → credential-sync-ibuNsMyl.js} +14 -134
  23. package/dist/{executor-BG2Armby.js → executor-D36FWjcf.js} +1 -1
  24. package/dist/{history-yaSjGMD_.d.ts → history-DI9KJT3J.d.ts} +38 -1
  25. package/dist/instrumentation.js +2 -2
  26. package/dist/{vercel-queue-DIkVcfK4.js → job-queue-2mFFDMHB.js} +61 -2
  27. package/dist/{logging-iY0ssa2q.js → logging-CvjMHRvg.js} +2 -2
  28. package/dist/{model-profile-CZmVoGdX.js → model-profile-BwU8mqwD.js} +14 -1
  29. package/dist/nitro.d.ts +1 -1
  30. package/dist/nitro.js +3 -4
  31. package/dist/{oauth-authorization-BIijVS2N.js → oauth-authorization-l4O1rXsL.js} +1 -1
  32. package/dist/{oauth-callback-server-DPkK3kzi.js → oauth-callback-server-Ds8M5FFX.js} +2 -2
  33. package/dist/pending-auth-DLNJbD8H.js +59 -0
  34. package/dist/{profile-6KWhg_-U.js → profile-dvV7PB7u.js} +4 -4
  35. package/dist/{prompt-90miy8VV.js → prompt-DehgjkO5.js} +1 -1
  36. package/dist/{registry-Ctgdjt-W.js → registry-C6FHctIu.js} +3 -3
  37. package/dist/{resolve-CB45ZukQ.js → resolve-DqwGI9wq.js} +2 -2
  38. package/dist/{runner-BwKCqoF3.js → runner-CzYEcB73.js} +9 -9
  39. package/dist/{sandbox-egress-signals-Cmy8ODat.js → sandbox-egress-signals-BZOv0fns.js} +1 -1
  40. package/dist/{schema-RpbW5Od2.js → schema-BZg-xzfG.js} +2 -2
  41. package/dist/{skills-c2bMDVRS.js → skills-EhiVbjF4.js} +2 -2
  42. package/dist/{spawn-Cg6lyjE7.js → spawn-Ck3L0rEr.js} +2 -2
  43. package/dist/{task-queue-SL4uLfBB.js → task-queue-TXhAWQwj.js} +3 -4
  44. package/dist/{task-runner-fntmnqzx.js → task-runner-axUJS1No.js} +380 -11
  45. package/dist/{thread-state-Wfr0GdKS.js → thread-state-CTuWhjru.js} +5 -5
  46. package/dist/{turn-failure-response-DLjSEm-R.js → turn-failure-response-csVoLOzx.js} +8 -9
  47. package/dist/{turn-lifecycle-5_jvLqRz.js → turn-lifecycle-C1S6vELh.js} +1 -1
  48. package/dist/{turn-session-routing-CQaysLoe.js → turn-session-routing-5RejBvit.js} +1 -1
  49. package/dist/{validation-CnZkCN7o.js → validation-q2PFxkTQ.js} +1 -1
  50. package/dist/{version-C6lA-h_o.js → version-ByLtIYyy.js} +1 -1
  51. package/dist/version.js +1 -1
  52. package/dist/web-authorization-Biy8nsS7.js +162 -0
  53. package/dist/web-input-DM9LaEdn.js +7774 -0
  54. package/dist/{reporting-window-DbUqng0P.js → web-message-id-xPI_EFSC.js} +11 -1
  55. package/dist/{work-4Nhz9mVv.js → work-QrbHdXTc.js} +7 -8
  56. package/dist/{worker-CdWPsNL2.js → worker-r17aopXW.js} +5 -6
  57. package/package.json +4 -4
  58. package/dist/execution-stats-DikPOxJ1.js +0 -373
  59. package/dist/job-queue-D4oAVrL9.js +0 -63
  60. package/dist/short-title-xEkZwkcV.js +0 -65
  61. package/dist/stats-DP9zl3Jg.js +0 -2758
  62. package/dist/web-authorization-Bbx999_q.js +0 -38
  63. package/dist/web-input-BoE1xE-K.js +0 -899
@@ -15,8 +15,8 @@ declare const messageCardSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
15
15
  key: z.ZodString;
16
16
  label: z.ZodString;
17
17
  objectType: z.ZodEnum<{
18
- task: "task";
19
18
  code_change: "code_change";
19
+ task: "task";
20
20
  automation: "automation";
21
21
  item: "item";
22
22
  }>;
@@ -26,6 +26,43 @@ declare const messageCardSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
26
26
  status: z.ZodOptional<z.ZodString>;
27
27
  trigger: z.ZodOptional<z.ZodString>;
28
28
  warning: z.ZodOptional<z.ZodString>;
29
+ displayType: z.ZodOptional<z.ZodString>;
30
+ sourceUpdatedAt: z.ZodOptional<z.ZodISODateTime>;
31
+ facts: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
32
+ type: z.ZodLiteral<"code_change">;
33
+ author: z.ZodOptional<z.ZodString>;
34
+ sourceBranch: z.ZodOptional<z.ZodString>;
35
+ targetBranch: z.ZodOptional<z.ZodString>;
36
+ reviewers: z.ZodOptional<z.ZodArray<z.ZodString>>;
37
+ review: z.ZodOptional<z.ZodEnum<{
38
+ required: "required";
39
+ approved: "approved";
40
+ changes_requested: "changes_requested";
41
+ }>>;
42
+ checks: z.ZodOptional<z.ZodObject<{
43
+ passed: z.ZodNumber;
44
+ failed: z.ZodNumber;
45
+ pending: z.ZodNumber;
46
+ }, z.core.$strict>>;
47
+ mergeable: z.ZodOptional<z.ZodBoolean>;
48
+ changedFiles: z.ZodOptional<z.ZodNumber>;
49
+ additions: z.ZodOptional<z.ZodNumber>;
50
+ deletions: z.ZodOptional<z.ZodNumber>;
51
+ }, z.core.$strict>, z.ZodObject<{
52
+ type: z.ZodLiteral<"task">;
53
+ assignees: z.ZodOptional<z.ZodArray<z.ZodString>>;
54
+ priority: z.ZodOptional<z.ZodString>;
55
+ project: z.ZodOptional<z.ZodString>;
56
+ cycle: z.ZodOptional<z.ZodString>;
57
+ dueDate: z.ZodOptional<z.ZodISODate>;
58
+ labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
59
+ }, z.core.$strict>, z.ZodObject<{
60
+ type: z.ZodLiteral<"deployment">;
61
+ project: z.ZodOptional<z.ZodString>;
62
+ environment: z.ZodOptional<z.ZodString>;
63
+ revision: z.ZodOptional<z.ZodString>;
64
+ branch: z.ZodOptional<z.ZodString>;
65
+ }, z.core.$strict>], "type">>;
29
66
  plugin: z.ZodString;
30
67
  }, z.core.$strict>], "kind">;
31
68
  type MessageCard = z.output<typeof messageCardSchema>;
@@ -1,6 +1,6 @@
1
- import { M as getDeploymentServiceVersion, N as getDeploymentTelemetryAttributes } from "./logging-iY0ssa2q.js";
1
+ import { N as getDeploymentServiceVersion, P as getDeploymentTelemetryAttributes } from "./logging-CvjMHRvg.js";
2
2
  import { _ as vercelAIIntegration, a as getClient, b as withStreamedSpan, c as init, o as getGlobalScope } from "./sentry-CgWZM_kV.js";
3
- import { n as getCurrentConversationPrivacy } from "./conversation-privacy-C-4JQzKD.js";
3
+ import { n as getCurrentConversationPrivacy } from "./conversation-privacy-pCcW0a5Y.js";
4
4
  import { t as consumePrivateTraceResultMarker } from "./private-trace-result-BLvBjy_e.js";
5
5
  //#region src/chat/sentry-payload-filter.ts
6
6
  const PAYLOAD_ATTRIBUTE_KEYS = /* @__PURE__ */ new Set([
@@ -1,5 +1,7 @@
1
+ import { a as getChatConfig } from "./config-Bws6Rpsh.js";
2
+ import { AsyncLocalStorage } from "node:async_hooks";
1
3
  import { z } from "zod";
2
- import { createHmac, timingSafeEqual } from "node:crypto";
4
+ import { createHash, createHmac, timingSafeEqual } from "node:crypto";
3
5
  import { QueueClient } from "@vercel/queue";
4
6
  /** Validate the v2 conversation work hint sent through Vercel Queue. */
5
7
  const conversationQueueMessageSchema = z.object({
@@ -21,6 +23,24 @@ function isConversationQueueMessageRejectedError(error) {
21
23
  return error instanceof ConversationQueueMessageRejectedError;
22
24
  }
23
25
  //#endregion
26
+ //#region src/chat/runtime/request-deadline.ts
27
+ const requestDeadlineStorage = new AsyncLocalStorage();
28
+ function createTurnRequestDeadline(startedAtMs) {
29
+ return {
30
+ startedAtMs,
31
+ deadlineAtMs: startedAtMs + Math.max(1, getChatConfig().functionMaxDurationSeconds * 1e3 - 2e4)
32
+ };
33
+ }
34
+ /** Return the host request deadline inherited by the current async turn. */
35
+ function getTurnRequestDeadline() {
36
+ return requestDeadlineStorage.getStore();
37
+ }
38
+ /** Run work with one host request deadline shared by nested queued turns. */
39
+ function runWithTurnRequestDeadline(callback, startedAtMs = Date.now()) {
40
+ if (requestDeadlineStorage.getStore()) return callback();
41
+ return requestDeadlineStorage.run(createTurnRequestDeadline(startedAtMs), callback);
42
+ }
43
+ //#endregion
24
44
  //#region src/chat/vercel-queue-client.ts
25
45
  function defaultQueueClientOptions() {
26
46
  if (process.env.VERCEL_DEPLOYMENT_ID?.trim()) return {};
@@ -164,4 +184,43 @@ function getVercelConversationWorkQueue() {
164
184
  return defaultQueue;
165
185
  }
166
186
  //#endregion
167
- export { signQueueMessage as a, ConversationQueueMessageRejectedError as c, QUEUE_SIGNATURE_MAX_AGE_MS as i, conversationQueueMessageSchema as l, resolveConversationWorkQueueTopic as n, verifyQueueMessage as o, verifyConversationQueueMessage as r, createVercelQueueClient as s, getVercelConversationWorkQueue as t, isConversationQueueMessageRejectedError as u };
187
+ //#region src/chat/sandbox/snapshot/job-queue.ts
188
+ /** Send Workspace snapshot build messages. */
189
+ const SIGNATURE_CONTEXT = "junior.workspace_snapshot_queue.v1";
190
+ const SIGNATURE_VERSION = "v1";
191
+ const WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC = "junior_workspace_snapshots";
192
+ const workspaceSnapshotJobSign = {
193
+ context: SIGNATURE_CONTEXT,
194
+ schema: z.object({
195
+ workspaceId: z.string().uuid(),
196
+ profileHash: z.string().min(1)
197
+ }).strict(),
198
+ signatureVersion: SIGNATURE_VERSION,
199
+ parts: (message) => [message.workspaceId, message.profileHash]
200
+ };
201
+ function jobId(message) {
202
+ return `workspace-snapshot_${createHash("sha256").update(message.workspaceId).update("\0").update(message.profileHash).digest("hex").slice(0, 32)}`;
203
+ }
204
+ /** Sign a Workspace snapshot job for tests and local checks. */
205
+ function signWorkspaceSnapshotJobMessage(message, nowMs = Date.now()) {
206
+ return signQueueMessage(workspaceSnapshotJobSign, message, nowMs);
207
+ }
208
+ /** Check that a recent queue message came from Junior. */
209
+ function verifyWorkspaceSnapshotJobMessage(value, nowMs = Date.now()) {
210
+ return verifyQueueMessage(workspaceSnapshotJobSign, value, nowMs);
211
+ }
212
+ async function send(message, idempotencyKey) {
213
+ const options = { retentionSeconds: QUEUE_SIGNATURE_MAX_AGE_MS / 1e3 };
214
+ if (idempotencyKey) options.idempotencyKey = idempotencyKey;
215
+ await createVercelQueueClient().send(WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC, signWorkspaceSnapshotJobMessage(message), options);
216
+ }
217
+ /** Send a job unless the same Workspace build already has one. */
218
+ async function sendWorkspaceSnapshotJob(message) {
219
+ await send(message, jobId(message));
220
+ }
221
+ /** Send the next job for a Workspace build that is still running. */
222
+ async function sendNextWorkspaceSnapshotJob(message) {
223
+ await send(message);
224
+ }
225
+ //#endregion
226
+ export { getVercelConversationWorkQueue as a, QUEUE_SIGNATURE_MAX_AGE_MS as c, createVercelQueueClient as d, getTurnRequestDeadline as f, isConversationQueueMessageRejectedError as g, conversationQueueMessageSchema as h, verifyWorkspaceSnapshotJobMessage as i, signQueueMessage as l, ConversationQueueMessageRejectedError as m, sendNextWorkspaceSnapshotJob as n, resolveConversationWorkQueueTopic as o, runWithTurnRequestDeadline as p, sendWorkspaceSnapshotJob as r, verifyConversationQueueMessage as s, WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC as t, verifyQueueMessage as u };
@@ -1,5 +1,5 @@
1
1
  import { d as setTag, f as setUser, h as startSpan, i as getActiveSpan, l as logger, n as captureMessage, p as spanToJSON, s as getTraceData, t as captureException, y as withScope } from "./sentry-CgWZM_kV.js";
2
- import { t as JUNIOR_VERSION } from "./version-C6lA-h_o.js";
2
+ import { t as JUNIOR_VERSION } from "./version-ByLtIYyy.js";
3
3
  import path from "node:path";
4
4
  import { styleText } from "node:util";
5
5
  import { ConfigError, configureSync, getConfig, getLogger } from "@logtape/logtape";
@@ -1207,4 +1207,4 @@ function extractGenAiUsageAttributes(...sources) {
1207
1207
  };
1208
1208
  }
1209
1209
  //#endregion
1210
- export { JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE as A, withSpan as C, JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE as D, JUNIOR_HEARTBEAT_ROUTE as E, isRecord as F, toOptionalNumber as I, toOptionalString as L, getDeploymentServiceVersion as M, getDeploymentTelemetryAttributes as N, JUNIOR_RETENTION_CRON_SCHEDULE as O, normalizeIdentityEmail as P, withLogContext as S, JUNIOR_HEARTBEAT_CRON_SCHEDULE as T, setSpanAttributes as _, extractGenAiUsageSummary as a, summarizeMessageText as b, getTracePropagationHeaders as c, logInfo as d, logWarn as f, setSentryUser as g, serializeGenAiAttribute as h, extractGenAiUsageAttributes as i, LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION as j, JUNIOR_RETENTION_ROUTE as k, logError as l, runBestEffort as m, createChatSdkLogger as n, getActiveTraceId as o, normalizeGenAiFinishReason as p, createRequestContext as r, getLogContextAttributesForSpan as s, buildTurnFailureResponse as t, logException as u, setSpanStatus as v, JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE as w, withContext as x, setTags as y };
1210
+ export { JUNIOR_RETENTION_ROUTE as A, withLogContext as C, JUNIOR_HEARTBEAT_ROUTE as D, JUNIOR_HEARTBEAT_CRON_SCHEDULE as E, normalizeIdentityEmail as F, isRecord as I, toOptionalNumber as L, LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION as M, getDeploymentServiceVersion as N, JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE as O, getDeploymentTelemetryAttributes as P, toOptionalString as R, withContext as S, JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE as T, setSentryUser as _, extractGenAiUsageSummary as a, setTags as b, getLogContextAttributesForSpan as c, logException as d, logInfo as f, serializeGenAiAttribute as g, runBestEffort as h, extractGenAiUsageAttributes as i, JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE as j, JUNIOR_RETENTION_CRON_SCHEDULE as k, getTracePropagationHeaders as l, normalizeGenAiFinishReason as m, createChatSdkLogger as n, getActiveTraceId as o, logWarn as p, createRequestContext as r, getLogContextAttributes as s, buildTurnFailureResponse as t, logError as u, setSpanAttributes as v, withSpan as w, summarizeMessageText as x, setSpanStatus as y };
@@ -15,6 +15,19 @@ function parseTurnReasoningLevel(value) {
15
15
  //#region src/chat/model-profile.ts
16
16
  /** Keep durable profile names stable and safe to expose in tool schemas. */
17
17
  const modelProfileSchema = z.string().regex(/^[a-z][a-z0-9_-]*$/);
18
+ /** Shared model profiles used when the app does not configure its own. */
19
+ const DEFAULT_MODEL_PROFILES = {
20
+ standard: {
21
+ modelId: "openai/gpt-6-luna",
22
+ description: "Use for lookups, explanations, summaries, routine tool use, and focused source checks, including reading a single code file. Avoid for implementation, debugging, code review, architecture decisions, or research across several systems.",
23
+ reasoningLevel: "high"
24
+ },
25
+ handoff: {
26
+ modelId: "anthropic/claude-opus-5.5",
27
+ description: "Use for implementation, debugging, code review, architecture decisions, and research across several systems. Include verification of unfinished work. Avoid for routine lookups, short explanations, or a new routine request after completed work.",
28
+ reasoningLevel: "high"
29
+ }
30
+ };
18
31
  /** Format one profile and its task-fit description. */
19
32
  function formatModelProfile(profile, description) {
20
33
  const text = description?.trim();
@@ -46,4 +59,4 @@ function profileConfig(config, profile) {
46
59
  return profileConfig;
47
60
  }
48
61
  //#endregion
49
- export { modelIdForProfile as a, TURN_REASONING_LEVELS as c, formatModelProfiles as i, parseTurnReasoningLevel as l, defaultModelId as n, modelProfileSchema as o, formatModelProfile as r, profileConfig as s, ModelProfileNotConfiguredError as t };
62
+ export { formatModelProfiles as a, profileConfig as c, formatModelProfile as i, TURN_REASONING_LEVELS as l, ModelProfileNotConfiguredError as n, modelIdForProfile as o, defaultModelId as r, modelProfileSchema as s, DEFAULT_MODEL_PROFILES as t, parseTurnReasoningLevel as u };
package/dist/nitro.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as JuniorDashboardOptions } from "./app-BbSD6EtD.js";
1
+ import { n as JuniorDashboardOptions } from "./app-TVL42pGL.js";
2
2
  import { n as JuniorPluginSet } from "./plugins-BT2l4We3.js";
3
3
  //#region src/nitro.d.ts
4
4
  export type JuniorNitroDashboardOptions = JuniorDashboardOptions;
package/dist/nitro.js CHANGED
@@ -1,9 +1,8 @@
1
- import { A as JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, D as JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE, E as JUNIOR_HEARTBEAT_ROUTE, O as JUNIOR_RETENTION_CRON_SCHEDULE, T as JUNIOR_HEARTBEAT_CRON_SCHEDULE, k as JUNIOR_RETENTION_ROUTE, w as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE } from "./logging-iY0ssa2q.js";
1
+ import { A as JUNIOR_RETENTION_ROUTE, D as JUNIOR_HEARTBEAT_ROUTE, E as JUNIOR_HEARTBEAT_CRON_SCHEDULE, O as JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE, T as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, j as JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, k as JUNIOR_RETENTION_CRON_SCHEDULE } from "./logging-CvjMHRvg.js";
2
2
  import { d as resolvePackageDir, t as discoverInstalledPluginPackageContent, u as isValidPackageName } from "./package-discovery-7a9YqLhE.js";
3
- import { n as resolveConversationWorkQueueTopic } from "./vercel-queue-DIkVcfK4.js";
4
- import { t as WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC } from "./job-queue-D4oAVrL9.js";
3
+ import { o as resolveConversationWorkQueueTopic, t as WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC } from "./job-queue-2mFFDMHB.js";
5
4
  import { a as pluginRuntimeRegistrationsFromPluginSet, r as pluginCatalogConfigFromPluginSet } from "./plugins-egKWjgue.js";
6
- import { t as PLUGIN_TASK_QUEUE_TOPIC } from "./task-queue-SL4uLfBB.js";
5
+ import { t as PLUGIN_TASK_QUEUE_TOPIC } from "./task-queue-TXhAWQwj.js";
7
6
  import { n as loadPluginSetFromModule, r as resolvePluginModule } from "./plugin-module-BKGOXca2.js";
8
7
  import path from "node:path";
9
8
  import { cpSync, existsSync, mkdirSync, readdirSync, statSync } from "node:fs";
@@ -1,4 +1,4 @@
1
- import { h as extractAssistantText } from "./checkpoint-Ceck_fLO.js";
1
+ import { h as extractAssistantText } from "./checkpoint-CJe-dZFF.js";
2
2
  //#region src/chat/runtime/turn.ts
3
3
  /** Classified Slack turn failure carrying the owning Sentry capture outward. */
4
4
  var ConversationTurnBoundaryError = class extends Error {
@@ -1,5 +1,5 @@
1
- import { gt as createUserTokenStore } from "./agent-runner-9g6TQk9y.js";
2
- import { a as GET, n as syncLocalOAuthCredential, r as GET$1 } from "./credential-sync-BXHIxbtS.js";
1
+ import { Tn as createUserTokenStore } from "./agent-runner-DEF7auSj.js";
2
+ import { a as GET, n as syncLocalOAuthCredential, r as GET$1 } from "./credential-sync-ibuNsMyl.js";
3
3
  import { createServer } from "node:http";
4
4
  //#region src/chat/local/oauth-callback-server.ts
5
5
  const LOCAL_OAUTH_TIMEOUT_MS = 6e5;
@@ -0,0 +1,59 @@
1
+ import { i as abandonTurnRecord } from "./checkpoint-CJe-dZFF.js";
2
+ //#region src/chat/state/turn-id.ts
3
+ /** Build a stable turn identifier from a message ID. */
4
+ function buildDeterministicTurnId(messageId) {
5
+ return `turn_${messageId.replace(/[^a-zA-Z0-9_-]/g, "_")}`;
6
+ }
7
+ /** Build the stable visible assistant-message identity for one logical turn. */
8
+ function buildDeterministicAssistantMessageId(turnId) {
9
+ return `${turnId}:assistant:1`;
10
+ }
11
+ //#endregion
12
+ //#region src/chat/services/pending-auth.ts
13
+ const AUTH_LINK_REUSE_WINDOW_MS = 6e5;
14
+ const NON_REQUEST_SKIPPED_REASON_PREFIXES = ["directed_to_other_party:", "side_conversation:"];
15
+ function isSkippedNonRequest(reason) {
16
+ return NON_REQUEST_SKIPPED_REASON_PREFIXES.some((prefix) => reason?.startsWith(prefix));
17
+ }
18
+ /** Decide whether the same agent-run session can reuse its fresh auth link. */
19
+ function canReusePendingAuthLink(args) {
20
+ const { pendingAuth } = args;
21
+ if (!pendingAuth) return false;
22
+ return pendingAuth.kind === args.kind && pendingAuth.provider === args.provider && pendingAuth.actorId === args.actorId && pendingAuth.scope === args.scope && pendingAuth.sessionId === args.sessionId && pendingAuth.linkSentAtMs + AUTH_LINK_REUSE_WINDOW_MS > (args.nowMs ?? Date.now());
23
+ }
24
+ function getConversationPendingAuth(args) {
25
+ const pendingAuth = args.conversation.processing.pendingAuth;
26
+ if (!pendingAuth) return;
27
+ if (pendingAuth.kind !== args.kind || pendingAuth.provider !== args.provider || pendingAuth.actorId !== args.actorId || pendingAuth.scope !== args.scope) return;
28
+ return pendingAuth;
29
+ }
30
+ function clearPendingAuth(conversation, sessionId) {
31
+ if (!conversation.processing.pendingAuth) return;
32
+ if (sessionId && conversation.processing.pendingAuth.sessionId !== sessionId) return;
33
+ conversation.processing.pendingAuth = void 0;
34
+ }
35
+ /** Mark the prior blocked turn abandoned after a new auth attempt replaces it. */
36
+ async function abandonReplacedPendingAuth(args) {
37
+ if (args.previousPendingAuth && args.previousPendingAuth.sessionId !== args.nextPendingAuth.sessionId && args.conversationId) await abandonTurnRecord({
38
+ conversationId: args.conversationId,
39
+ turnId: args.previousPendingAuth.sessionId,
40
+ errorMessage: "Abandoned by a newer auth-blocked request in the same conversation."
41
+ });
42
+ }
43
+ /**
44
+ * Decide whether an auth callback still belongs to the latest real human
45
+ * request, ignoring bot-authored and passive bystander rows while treating
46
+ * failed human turns and opt-outs as newer freshness blockers.
47
+ */
48
+ function isPendingAuthLatestRequest(conversation, pendingAuth) {
49
+ for (let index = conversation.messages.length - 1; index >= 0; index -= 1) {
50
+ const message = conversation.messages[index];
51
+ if (message?.role !== "user") continue;
52
+ if (message.author?.isBot) continue;
53
+ if (isSkippedNonRequest(message.meta?.skippedReason)) continue;
54
+ return buildDeterministicTurnId(message.id) === pendingAuth.sessionId;
55
+ }
56
+ return false;
57
+ }
58
+ //#endregion
59
+ export { isPendingAuthLatestRequest as a, getConversationPendingAuth as i, canReusePendingAuthLink as n, buildDeterministicAssistantMessageId as o, clearPendingAuth as r, buildDeterministicTurnId as s, abandonReplacedPendingAuth as t };
@@ -1,7 +1,7 @@
1
- import { w as toOptionalTrimmed } from "./client-B27ufhzl.js";
2
- import { _ as setSpanAttributes, v as setSpanStatus } from "./logging-iY0ssa2q.js";
3
- import { a as getChatConfig } from "./config-BAhl7-RC.js";
4
- import { n as pluginCatalogRuntime } from "./catalog-runtime-CVZ9TEuK.js";
1
+ import { w as toOptionalTrimmed } from "./client-C2WBBx7m.js";
2
+ import { v as setSpanAttributes, y as setSpanStatus } from "./logging-CvjMHRvg.js";
3
+ import { a as getChatConfig } from "./config-Bws6Rpsh.js";
4
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-BYGR3Dr4.js";
5
5
  import { createHash } from "node:crypto";
6
6
  import { createMemoryState } from "@chat-adapter/state-memory";
7
7
  import { createRedisState } from "@chat-adapter/state-redis";
@@ -1,4 +1,4 @@
1
- import { I as briefOutcomeStatusSchema, L as conversationBriefSchema, R as parseBriefInput } from "./conversation-1HUoZr2l.js";
1
+ import { I as briefOutcomeStatusSchema, L as conversationBriefSchema, R as parseBriefInput } from "./conversation-DPbmIwjy.js";
2
2
  import { z } from "zod";
3
3
  //#region src/chat/briefs/generate.ts
4
4
  const MAX_INPUT_CHARS = 6e4;
@@ -1,4 +1,4 @@
1
- import { _ as setSpanAttributes, d as logInfo, f as logWarn } from "./logging-iY0ssa2q.js";
1
+ import { f as logInfo, p as logWarn, v as setSpanAttributes } from "./logging-CvjMHRvg.js";
2
2
  import { i as credentialUserSubjectId } from "./context-Bplcgypl.js";
3
3
  import { n as normalizePluginPackageNames, o as pluginRoots, t as discoverInstalledPluginPackageContent } from "./package-discovery-7a9YqLhE.js";
4
4
  import path from "node:path";
@@ -1246,8 +1246,8 @@ function registerInlineManifests(state, source, config) {
1246
1246
  const migrationOwners = /* @__PURE__ */ new Map();
1247
1247
  for (const definition of source.inlineManifests) {
1248
1248
  const pkg = definition.packageName ? packageContentByName(source.packagedContent, definition.packageName) : void 0;
1249
- const dir = pkg?.dir ?? process.cwd();
1250
- const skillsDir = pkg?.hasSkillsDir ? path.join(pkg.dir, "skills") : void 0;
1249
+ const dir = pkg?.dir ?? definition.dir ?? process.cwd();
1250
+ const skillsDir = pkg?.hasSkillsDir || definition.dir && statSync(path.join(dir, "skills"), { throwIfNoEntry: false })?.isDirectory() ? path.join(dir, "skills") : void 0;
1251
1251
  const migrationsDir = pkg?.hasMigrationsDir && statSync(path.join(pkg.dir, "migrations"), { throwIfNoEntry: false })?.isDirectory() ? path.join(pkg.dir, "migrations") : void 0;
1252
1252
  const manifest = parseInlinePluginManifest(definition.manifest, dir, config);
1253
1253
  if (migrationsDir) {
@@ -1,5 +1,5 @@
1
- import { C as withSpan, _ as setSpanAttributes } from "./logging-iY0ssa2q.js";
2
- import { N as SANDBOX_WORKSPACE_ROOT, k as sleep, r as isStale, t as create, u as isSandboxUnavailableError, v as getVercelSandboxCredentials, w as getStateAdapter, x as runNonInteractiveCommand } from "./profile-6KWhg_-U.js";
1
+ import { v as setSpanAttributes, w as withSpan } from "./logging-CvjMHRvg.js";
2
+ import { N as SANDBOX_WORKSPACE_ROOT, k as sleep, r as isStale, t as create, u as isSandboxUnavailableError, v as getVercelSandboxCredentials, w as getStateAdapter, x as runNonInteractiveCommand } from "./profile-dvV7PB7u.js";
3
3
  import { z } from "zod";
4
4
  import { FileSystem, Sandbox } from "@vercel/sandbox";
5
5
  //#region src/chat/sandbox/resources.ts
@@ -1,13 +1,13 @@
1
- import { S as withLogContext, u as logException, y as setTags } from "./logging-iY0ssa2q.js";
1
+ import { C as withLogContext, b as setTags, d as logException } from "./logging-CvjMHRvg.js";
2
2
  import { t as credentialContextForActor } from "./context-Bplcgypl.js";
3
- import { Kt as getConversationStore, Wt as getConversationEventStore } from "./agent-hooks-DNLBwmsh.js";
4
- import { M as messageCardText } from "./conversation-1HUoZr2l.js";
5
- import { A as commitAcceptedReply, B as recordAuthorizationCompleted, J as hydrateConversationMessages, P as loadProjection, Y as persistConversationMessages, at as markConversationMessage, et as buildConversationContext, lt as upsertConversationMessage, ot as normalizeConversationText, r as saveTurnCheckpoint, st as recordDeliveredAssistantMessage, u as persistWithRetry } from "./checkpoint-Ceck_fLO.js";
6
- import { _ as markTurnFailed, r as getAssistantReplyText, t as authorizationId, v as startActiveTurn } from "./oauth-authorization-BIijVS2N.js";
7
- import { n as scheduleSessionCompletedPluginTasks, t as processPluginTask } from "./task-runner-fntmnqzx.js";
8
- import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-5_jvLqRz.js";
9
- import { n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-Wfr0GdKS.js";
10
- import { d as loadPendingMessageCards, i as completeAuthPauseTurn, l as buildDeliveredTurnStatePatch, t as finalizeFailedTurnReplyWithEvent } from "./turn-failure-response-DLjSEm-R.js";
3
+ import { Kt as getConversationStore, Wt as getConversationEventStore } from "./agent-hooks-FUetyyLe.js";
4
+ import { M as messageCardText } from "./conversation-DPbmIwjy.js";
5
+ import { A as commitAcceptedReply, B as recordAuthorizationCompleted, J as hydrateConversationMessages, P as loadProjection, Y as persistConversationMessages, ct as markConversationMessage, ft as upsertConversationMessage, lt as normalizeConversationText, r as saveTurnCheckpoint, rt as buildConversationContext, u as persistWithRetry, ut as recordDeliveredAssistantMessage } from "./checkpoint-CJe-dZFF.js";
6
+ import { _ as markTurnFailed, r as getAssistantReplyText, t as authorizationId, v as startActiveTurn } from "./oauth-authorization-l4O1rXsL.js";
7
+ import { n as scheduleSessionCompletedPluginTasks, t as processPluginTask } from "./task-runner-axUJS1No.js";
8
+ import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-C1S6vELh.js";
9
+ import { n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState, s as coerceThreadConversationState } from "./thread-state-CTuWhjru.js";
10
+ import { d as loadPendingMessageCards, i as completeAuthPauseTurn, l as buildDeliveredTurnStatePatch, t as finalizeFailedTurnReplyWithEvent } from "./turn-failure-response-csVoLOzx.js";
11
11
  import { randomUUID } from "node:crypto";
12
12
  import { createLocalSource, localDestinationSchema } from "@sentry/junior-plugin-api";
13
13
  //#region src/chat/local/runner.ts
@@ -1,4 +1,4 @@
1
- import { rt as sandboxEgressSignalsResponseSchema } from "./agent-runner-9g6TQk9y.js";
1
+ import { un as sandboxEgressSignalsResponseSchema } from "./agent-runner-DEF7auSj.js";
2
2
  //#region src/chat/local/sandbox-egress-signals.ts
3
3
  const SANDBOX_EGRESS_SIGNALS_PATH = "/api/internal/sandbox-egress/signals";
4
4
  const LOCAL_DEV_SERVER_TIMEOUT_MS = 1e3;
@@ -1,6 +1,6 @@
1
1
  import { t as juniorDestinationKindSchema } from "./destinations-BeBiJeEM.js";
2
- import { E as conversationSummaryReportSchema, n as actorIdentitySchema, w as conversationStatsItemSchema } from "./conversation-1HUoZr2l.js";
3
- import { i as fillUtcHours, r as fillUtcDays, s as sumUtcHoursIntoSixHours } from "./reporting-window-DbUqng0P.js";
2
+ import { E as conversationSummaryReportSchema, n as actorIdentitySchema, w as conversationStatsItemSchema } from "./conversation-DPbmIwjy.js";
3
+ import { a as fillUtcHours, c as sumUtcHoursIntoSixHours, i as fillUtcDays } from "./web-message-id-xPI_EFSC.js";
4
4
  import { z } from "zod";
5
5
  import { codeChangeStateSchema, taskOutcomeSchema } from "@sentry/junior-plugin-api";
6
6
  //#region src/api/schema/common.ts
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
2
- import { f as logWarn } from "./logging-iY0ssa2q.js";
2
+ import { p as logWarn } from "./logging-CvjMHRvg.js";
3
3
  import { s as skillRoots } from "./package-discovery-7a9YqLhE.js";
4
- import { n as pluginCatalogRuntime } from "./catalog-runtime-CVZ9TEuK.js";
4
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-BYGR3Dr4.js";
5
5
  import path from "node:path";
6
6
  import { z } from "zod";
7
7
  import fs from "node:fs/promises";
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
2
- import { bt as actorFromRun, xt as toolInvocationDestination } from "./agent-runner-9g6TQk9y.js";
3
- import { n as createAndEnqueueAgentInvocation } from "./work-4Nhz9mVv.js";
2
+ import { An as toolInvocationDestination, kn as actorFromRun } from "./agent-runner-DEF7auSj.js";
3
+ import { n as createAndEnqueueAgentInvocation } from "./work-QrbHdXTc.js";
4
4
  //#region 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. */
@@ -1,6 +1,5 @@
1
- import { f as logWarn } from "./logging-iY0ssa2q.js";
2
- import { a as signQueueMessage, i as QUEUE_SIGNATURE_MAX_AGE_MS, o as verifyQueueMessage, s as createVercelQueueClient } from "./vercel-queue-DIkVcfK4.js";
3
- import { o as runWithTurnRequestDeadline } from "./job-queue-D4oAVrL9.js";
1
+ import { p as logWarn } from "./logging-CvjMHRvg.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-2mFFDMHB.js";
4
3
  import { z } from "zod";
5
4
  import { createHash } from "node:crypto";
6
5
  import { handleCallback, registerDevConsumer } from "@vercel/queue";
@@ -110,7 +109,7 @@ function pluginTaskCallback() {
110
109
  maxDeliveries: PLUGIN_TASK_MAX_DELIVERIES,
111
110
  onRejected: logPluginTaskQueueMessageRejected,
112
111
  run: async (message) => {
113
- const { processPluginTask } = await import("./task-runner-fntmnqzx.js").then((n) => n.r);
112
+ const { processPluginTask } = await import("./task-runner-axUJS1No.js").then((n) => n.r);
114
113
  await processPluginTask(message);
115
114
  },
116
115
  topic: PLUGIN_TASK_QUEUE_TOPIC,