@sentry/junior 0.223.0 → 0.224.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 (52) hide show
  1. package/dist/{agent-hooks-DZU5nsd1.js → agent-hooks-DNLBwmsh.js} +6 -6
  2. package/dist/{agent-Bzbf92vv.js → agent-runner-9g6TQk9y.js} +809 -34
  3. package/dist/api.js +14 -14
  4. package/dist/app.js +1507 -59
  5. package/dist/{briefs-BJPfCrlT.js → briefs-CjXnGKzZ.js} +2 -2
  6. package/dist/{catalog-runtime-BthunUDD.js → catalog-runtime-CVZ9TEuK.js} +1 -1
  7. package/dist/{checkpoint-Deu-OVb3.js → checkpoint-Ceck_fLO.js} +7 -7
  8. package/dist/cli/chat.js +14 -15
  9. package/dist/cli/check.js +3 -3
  10. package/dist/cli/main.js +1 -1
  11. package/dist/cli/plugins.js +3 -3
  12. package/dist/cli/snapshot-create.js +3 -3
  13. package/dist/cli/upgrade.js +3 -3
  14. package/dist/{client-DjC6-6iU.js → client-B27ufhzl.js} +2 -2
  15. package/dist/{config-CtoUVs72.js → config-BAhl7-RC.js} +2 -2
  16. package/dist/{conversation-privacy-xS1t92xa.js → conversation-privacy-C-4JQzKD.js} +1 -1
  17. package/dist/credential-sync-BXHIxbtS.js +940 -0
  18. package/dist/{execution-stats-CrXs9vSH.js → execution-stats-DikPOxJ1.js} +3 -3
  19. package/dist/{executor-AOhG9X1t.js → executor-BG2Armby.js} +1 -1
  20. package/dist/instrumentation.js +2 -2
  21. package/dist/{job-queue-CNd9cpIy.js → job-queue-D4oAVrL9.js} +1 -1
  22. package/dist/{logging-DiN3o3nB.js → logging-iY0ssa2q.js} +1 -1
  23. package/dist/nitro.js +3 -3
  24. package/dist/{pending-auth-D7vmttn_.js → oauth-authorization-BIijVS2N.js} +6 -48
  25. package/dist/{oauth-callback-server-Ca0VLUEw.js → oauth-callback-server-DPkK3kzi.js} +4 -4
  26. package/dist/{profile-BsNrw8lj.js → profile-6KWhg_-U.js} +5 -9
  27. package/dist/{registry-Dankt-Pl.js → registry-Ctgdjt-W.js} +1 -1
  28. package/dist/{resolve-B38CpJe2.js → resolve-CB45ZukQ.js} +2 -2
  29. package/dist/{runner-Ck5rEjCm.js → runner-BwKCqoF3.js} +8 -9
  30. package/dist/{sandbox-egress-signals-BOfFkvly.js → sandbox-egress-signals-Cmy8ODat.js} +1 -1
  31. package/dist/{short-title-BHd_jUFX.js → short-title-xEkZwkcV.js} +2 -2
  32. package/dist/{skills-DbP4TDft.js → skills-c2bMDVRS.js} +2 -2
  33. package/dist/{spawn-DzXc_PKO.js → spawn-Cg6lyjE7.js} +2 -2
  34. package/dist/{stats-pNGp3G5q.js → stats-DP9zl3Jg.js} +6 -6
  35. package/dist/{task-queue-Cy9y1foT.js → task-queue-SL4uLfBB.js} +3 -3
  36. package/dist/{task-runner-DI1FBJFJ.js → task-runner-fntmnqzx.js} +8 -83
  37. package/dist/{thread-state-DXgxOYpZ.js → thread-state-Wfr0GdKS.js} +5 -5
  38. package/dist/{auth-pause-state-Bn2vX4PA.js → turn-failure-response-DLjSEm-R.js} +73 -72
  39. package/dist/{turn-lifecycle-Bjf6y2GO.js → turn-lifecycle-5_jvLqRz.js} +1 -1
  40. package/dist/turn-session-routing-CQaysLoe.js +77 -0
  41. package/dist/{validation-D5CIslEu.js → validation-CnZkCN7o.js} +1 -1
  42. package/dist/{version-_ZQFlslB.js → version-C6lA-h_o.js} +1 -1
  43. package/dist/version.js +1 -1
  44. package/dist/{web-authorization-6mmfS_o-.js → web-authorization-Bbx999_q.js} +1 -1
  45. package/dist/{web-input-BJpWm6go.js → web-input-BoE1xE-K.js} +7 -7
  46. package/dist/{work-DvIlJR3C.js → work-4Nhz9mVv.js} +52 -10
  47. package/dist/{worker-D1qidg-Y.js → worker-CdWPsNL2.js} +5 -5
  48. package/package.json +4 -4
  49. package/dist/agent-runner-2VQ9WhkG.js +0 -679
  50. package/dist/credential-sync-CKdXEUDO.js +0 -2811
  51. package/dist/experimental-CIXf7Uye.js +0 -46
  52. package/dist/turn-execution-BNOXrZ-M.js +0 -47
@@ -0,0 +1,77 @@
1
+ //#region src/chat/services/turn-session-routing.ts
2
+ async function loadConversationChain(conversationId, conversationStore) {
3
+ const chain = [];
4
+ const seen = /* @__PURE__ */ new Set();
5
+ let cursor = conversationId;
6
+ while (cursor && !seen.has(cursor)) {
7
+ seen.add(cursor);
8
+ const conversation = await conversationStore.get({ conversationId: cursor });
9
+ if (!conversation) break;
10
+ chain.push(conversation);
11
+ cursor = conversation.parentConversationId;
12
+ }
13
+ return chain;
14
+ }
15
+ /**
16
+ * Normalize a stored Slack session source against the conversation destination.
17
+ *
18
+ * Does not create channel or thread values from the conversation id.
19
+ */
20
+ function slackSourceForDestination(args) {
21
+ if (args.source?.kind !== "slack" || args.source.channelId !== args.destination.channelId) return;
22
+ const threadTs = args.source.threadTs?.trim();
23
+ return {
24
+ kind: "slack",
25
+ visibility: args.source.visibility ?? "public",
26
+ teamId: args.source.teamId?.trim() || args.destination.teamId,
27
+ channelId: args.source.channelId,
28
+ ...threadTs ? { threadTs } : void 0
29
+ };
30
+ }
31
+ /**
32
+ * Resolve the Conversation Location, Destination, and session Source.
33
+ *
34
+ * Reads parent Conversations when this Conversation has no Destination.
35
+ */
36
+ async function resolveConversationRouting(args) {
37
+ const conversationStore = args.conversationStore ?? (await import("./agent-hooks-DNLBwmsh.js").then((n) => n.Ut)).getConversationStore();
38
+ const chain = await loadConversationChain(args.conversationId, conversationStore);
39
+ let destination;
40
+ let source;
41
+ let location;
42
+ for (const conversation of chain) {
43
+ destination ??= conversation.destination;
44
+ source ??= conversation.sessionSource;
45
+ location ??= conversation.location;
46
+ if (destination && source) break;
47
+ }
48
+ if (!destination) return;
49
+ if (destination.platform === "slack") {
50
+ const slackSource = slackSourceForDestination({
51
+ destination,
52
+ source
53
+ });
54
+ return {
55
+ destination,
56
+ ...location ? { location } : void 0,
57
+ ...slackSource ? { source: slackSource } : void 0
58
+ };
59
+ }
60
+ return {
61
+ destination,
62
+ ...location ? { location } : void 0,
63
+ ...source ? { source } : void 0
64
+ };
65
+ }
66
+ /** Require the Conversation Destination and Source from SQL. */
67
+ async function resolveTurnSessionRouting(args) {
68
+ const routing = await resolveConversationRouting(args);
69
+ if (!routing?.destination || !routing.source) throw new Error(`Conversation ${args.conversationId} is missing durable routing metadata`);
70
+ return {
71
+ destination: routing.destination,
72
+ ...routing.location ? { location: routing.location } : void 0,
73
+ source: routing.source
74
+ };
75
+ }
76
+ //#endregion
77
+ export { resolveTurnSessionRouting as n, resolveConversationRouting as t };
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
2
- import { n as pluginCatalogRuntime } from "./catalog-runtime-BthunUDD.js";
2
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-CVZ9TEuK.js";
3
3
  import { isDeepStrictEqual } from "node:util";
4
4
  //#region src/chat/plugins/validation.ts
5
5
  var validation_exports = /* @__PURE__ */ __exportAll({
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "0.223.0";
2
+ var version = "0.224.0";
3
3
  //#endregion
4
4
  //#region src/version.ts
5
5
  /** Installed Junior package version, or `unknown` when package metadata is unavailable. */
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
- import { t as JUNIOR_VERSION } from "./version-_ZQFlslB.js";
1
+ import { t as JUNIOR_VERSION } from "./version-C6lA-h_o.js";
2
2
  export { JUNIOR_VERSION };
@@ -1,4 +1,4 @@
1
- import { w as getStateAdapter } from "./profile-BsNrw8lj.js";
1
+ import { w as getStateAdapter } from "./profile-6KWhg_-U.js";
2
2
  import { randomUUID } from "node:crypto";
3
3
  //#region src/chat/conversations/web-authorization.ts
4
4
  const WEB_AUTHORIZATION_PREFIX = "junior:web_authorization:v1";
@@ -1,13 +1,13 @@
1
- import { f as logWarn } from "./logging-DiN3o3nB.js";
2
- import { s as getSlackBotToken } from "./config-CtoUVs72.js";
1
+ import { f as logWarn } from "./logging-iY0ssa2q.js";
2
+ import { s as getSlackBotToken } from "./config-BAhl7-RC.js";
3
3
  import "./context-Bplcgypl.js";
4
- import { K as normalizeSlackConversationId, Kt as getConversationStore, qt as getDb } from "./agent-hooks-DZU5nsd1.js";
4
+ import { K as normalizeSlackConversationId, Kt as getConversationStore, qt as getDb } from "./agent-hooks-DNLBwmsh.js";
5
5
  import { n as juniorDestinations } from "./destinations-BeBiJeEM.js";
6
- import { D as juniorIdentities, O as juniorUsers, o as juniorSchedulerTasks } from "./executor-AOhG9X1t.js";
7
- import { t as fallbackShortTitle } from "./short-title-BHd_jUFX.js";
8
- import { A as eventAutomationTriggerAvailable, F as effectiveTaskOutcomes, G as listDeletedEventAutomationsCreatedBy, H as eventAutomationBelongsToUser, J as listPublicEventAutomationsForTeams, K as listEventAutomationsCreatedBy, V as deleteEventAutomation, W as getEventAutomation, X as getEventCatalog, _ as parseScheduledAutomationRow, c as parseSlackThreadId, ft as appendAndEnqueueExclusiveInboundMessage, m as listPublicScheduledAutomationsForTeams, p as isListedScheduledAutomation, pt as appendAndEnqueueInboundMessage, qt as buildDeterministicTurnId, v as readScheduledAutomation, y as saveScheduledAutomation } from "./stats-pNGp3G5q.js";
6
+ import { D as juniorIdentities, O as juniorUsers, o as juniorSchedulerTasks } from "./executor-BG2Armby.js";
7
+ import { t as fallbackShortTitle } from "./short-title-xEkZwkcV.js";
8
+ import { A as eventAutomationTriggerAvailable, F as effectiveTaskOutcomes, G as listDeletedEventAutomationsCreatedBy, H as eventAutomationBelongsToUser, J as listPublicEventAutomationsForTeams, K as listEventAutomationsCreatedBy, V as deleteEventAutomation, W as getEventAutomation, X as getEventCatalog, _ as parseScheduledAutomationRow, c as parseSlackThreadId, ft as appendAndEnqueueExclusiveInboundMessage, m as listPublicScheduledAutomationsForTeams, p as isListedScheduledAutomation, pt as appendAndEnqueueInboundMessage, qt as buildDeterministicTurnId, v as readScheduledAutomation, y as saveScheduledAutomation } from "./stats-DP9zl3Jg.js";
9
9
  import { p as healthReportSchema, s as sumUtcHoursIntoSixHours } from "./reporting-window-DbUqng0P.js";
10
- import { a as readAutomationExecutionStatusDays, c as readAutomationExecutions, i as readAutomationExecutionHours, l as readAutomationRuns, n as readAutomationExecutionByConversationId, o as readAutomationExecutionStatusHours, r as readAutomationExecutionDays, s as readAutomationExecutionSummaries, t as emptyAutomationRunWindows } from "./execution-stats-CrXs9vSH.js";
10
+ import { a as readAutomationExecutionStatusDays, c as readAutomationExecutions, i as readAutomationExecutionHours, l as readAutomationRuns, n as readAutomationExecutionByConversationId, o as readAutomationExecutionStatusHours, r as readAutomationExecutionDays, s as readAutomationExecutionSummaries, t as emptyAutomationRunWindows } from "./execution-stats-DikPOxJ1.js";
11
11
  import { z } from "zod";
12
12
  import { createHash } from "node:crypto";
13
13
  import { and, desc, eq, inArray, lt, notInArray, or, sql } from "drizzle-orm";
@@ -1,13 +1,12 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
2
- import { $ as AuthorizationFlowDisabledError, A as createAgentInvocationSchema, M as AgentInvocationLimitError, O as agentBindingSchema, f as PluginCredentialFailureError, j as AgentInvocationBusyError, k as agentInvocationSchema } from "./agent-Bzbf92vv.js";
3
- import { Jt as getSqlExecutor, Kt as getConversationStore, Wt as getConversationEventStore } from "./agent-hooks-DZU5nsd1.js";
4
- import { f as juniorAgentBindings, p as juniorAgentInvocations } from "./executor-AOhG9X1t.js";
5
- import { L as openConversationProjection, o as failTurnRecord, r as saveTurnCheckpoint, s as getTurnRecord, v as getTerminalAssistantMessages } from "./checkpoint-Deu-OVb3.js";
6
- import { pt as appendAndEnqueueInboundMessage } from "./stats-pNGp3G5q.js";
7
- import { _ as isTurnInputCommitLostError, h as getConversationTurnBoundaryError, p as TurnInputCommitLostError, s as getAssistantReplyText } from "./pending-auth-D7vmttn_.js";
8
- import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-Bjf6y2GO.js";
9
- import { n as executeTurn, t as AgentRunError } from "./turn-execution-BNOXrZ-M.js";
10
- import { n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState } from "./thread-state-DXgxOYpZ.js";
2
+ import { B as AgentInvocationLimitError, I as agentBindingSchema, L as agentInvocationSchema, R as createAgentInvocationSchema, St as AuthorizationFlowDisabledError, n as runAgentWithTimeout, v as PluginCredentialFailureError, z as AgentInvocationBusyError } from "./agent-runner-9g6TQk9y.js";
3
+ import { Jt as getSqlExecutor, Kt as getConversationStore, Wt as getConversationEventStore } from "./agent-hooks-DNLBwmsh.js";
4
+ import { f as juniorAgentBindings, p as juniorAgentInvocations } from "./executor-BG2Armby.js";
5
+ import { I as openConversationProjection, _ as getTerminalAssistantMessages, o as failTurnRecord, r as saveTurnCheckpoint, s as getTurnRecord } from "./checkpoint-Ceck_fLO.js";
6
+ import { pt as appendAndEnqueueInboundMessage } from "./stats-DP9zl3Jg.js";
7
+ import { d as getConversationTurnBoundaryError, l as TurnInputCommitLostError, p as isTurnInputCommitLostError, r as getAssistantReplyText } from "./oauth-authorization-BIijVS2N.js";
8
+ import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-5_jvLqRz.js";
9
+ import { n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState } from "./thread-state-Wfr0GdKS.js";
11
10
  import { z } from "zod";
12
11
  import { createHash } from "node:crypto";
13
12
  import { and, asc, count, eq, inArray } from "drizzle-orm";
@@ -201,6 +200,49 @@ function isTerminalAgentInvocation(invocation) {
201
200
  return TERMINAL_AGENT_INVOCATION_STATUSES.includes(invocation.status);
202
201
  }
203
202
  //#endregion
203
+ //#region src/chat/runtime/turn-execution.ts
204
+ /** An error thrown while the agent advances a Run. */
205
+ var AgentRunError = class extends Error {
206
+ constructor(cause) {
207
+ super(cause instanceof Error ? cause.message : "Agent Run failed", { cause });
208
+ this.name = "AgentRunError";
209
+ }
210
+ };
211
+ /**
212
+ * Run the agent and finish the Turn after the caller saves its result.
213
+ *
214
+ * A paused Run, or a Run waiting for authorization, leaves the Turn open. A
215
+ * save error also leaves the Turn open so the worker can retry or recover it.
216
+ * A timeout aborts the Run before this function reports the failure.
217
+ */
218
+ async function executeTurn(agentRunner, run, saveResult, timeoutMs) {
219
+ let outcome;
220
+ try {
221
+ outcome = await runAgentWithTimeout(agentRunner, run, timeoutMs);
222
+ } catch (error) {
223
+ throw new AgentRunError(error);
224
+ }
225
+ if (outcome.status !== "completed") return outcome;
226
+ const saved = await saveResult(outcome.result);
227
+ const lifecycle = new ConversationTurnLifecycleService(getConversationEventStore());
228
+ const common = {
229
+ conversationId: run.conversationId,
230
+ createdAtMs: saved.finishedAtMs ?? Date.now(),
231
+ turnId: run.turnId
232
+ };
233
+ if (saved.outcome === "failed") await lifecycle.fail({
234
+ ...common,
235
+ ...saved.eventId ? { eventId: saved.eventId } : void 0,
236
+ failureCode: saved.failureCode,
237
+ ...saved.failureReason ? { failureReason: saved.failureReason } : void 0
238
+ });
239
+ else await lifecycle.complete({
240
+ ...common,
241
+ outcome: saved.outcome
242
+ });
243
+ return { status: "completed" };
244
+ }
245
+ //#endregion
204
246
  //#region src/chat/agent-invocations/work.ts
205
247
  var work_exports = /* @__PURE__ */ __exportAll({
206
248
  buildAgentInvocationInboundMessage: () => buildAgentInvocationInboundMessage,
@@ -506,4 +548,4 @@ function routeAgentInvocationWork(options) {
506
548
  };
507
549
  }
508
550
  //#endregion
509
- export { work_exports as a, resolveAgentInvocationId as i, createAndEnqueueAgentInvocation as n, listPendingAgentInvocationMailboxAppends as o, enqueueAgentInvocation as r, createAgentInvocationWorker as t };
551
+ export { work_exports as a, listPendingAgentInvocationMailboxAppends as c, resolveAgentInvocationId as i, createAndEnqueueAgentInvocation as n, AgentRunError as o, enqueueAgentInvocation as r, executeTurn as s, createAgentInvocationWorker as t };
@@ -1,10 +1,10 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
2
- import { b as isProviderRetryError } from "./client-DjC6-6iU.js";
3
- import { S as withLogContext, d as logInfo, f as logWarn, u as logException } from "./logging-DiN3o3nB.js";
4
- import { a as getChatConfig } from "./config-CtoUVs72.js";
5
- import { At as recordConversationRetry, Ct as drainConversationMailbox, Et as getConversationWorkState, Ft as startConversationWork, Ht as isInvalidConversationRecordError, Nt as requestAnotherSlice, St as deadLetterAttempt, Vt as isFinalAttempt, _t as clearConsumedConversationWake, bt as completeConversationWork, dt as ackMessages, gt as checkInConversationWork, jt as releaseConversationWork, kt as recordAttemptFailure, mt as beginConversationResume, wt as ensureConversationWake, xt as countPendingConversationMessages, yt as completeConversationStop, zt as hasConversationStop } from "./stats-pNGp3G5q.js";
2
+ import { b as isProviderRetryError } from "./client-B27ufhzl.js";
3
+ import { S as withLogContext, d as logInfo, f as logWarn, u as logException } from "./logging-iY0ssa2q.js";
4
+ import { a as getChatConfig } from "./config-BAhl7-RC.js";
5
+ import { At as recordConversationRetry, Ct as drainConversationMailbox, Et as getConversationWorkState, Ft as startConversationWork, Ht as isInvalidConversationRecordError, Nt as requestAnotherSlice, St as deadLetterAttempt, Vt as isFinalAttempt, _t as clearConsumedConversationWake, bt as completeConversationWork, dt as ackMessages, gt as checkInConversationWork, jt as releaseConversationWork, kt as recordAttemptFailure, mt as beginConversationResume, wt as ensureConversationWake, xt as countPendingConversationMessages, yt as completeConversationStop, zt as hasConversationStop } from "./stats-DP9zl3Jg.js";
6
6
  import { c as ConversationQueueMessageRejectedError } from "./vercel-queue-DIkVcfK4.js";
7
- import { a as getTurnRequestDeadline } from "./job-queue-CNd9cpIy.js";
7
+ import { a as getTurnRequestDeadline } from "./job-queue-D4oAVrL9.js";
8
8
  //#region src/chat/task-execution/worker.ts
9
9
  var worker_exports = /* @__PURE__ */ __exportAll({
10
10
  CONVERSATION_WORK_DEFER_DELAY_MS: () => CONVERSATION_WORK_DEFER_DELAY_MS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/junior",
3
- "version": "0.223.0",
3
+ "version": "0.224.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -85,7 +85,7 @@
85
85
  "pg": "^8.16.3",
86
86
  "yaml": "^2.9.0",
87
87
  "zod": "^4.5.4",
88
- "@sentry/junior-plugin-api": "0.223.0"
88
+ "@sentry/junior-plugin-api": "0.224.0"
89
89
  },
90
90
  "devDependencies": {
91
91
  "@emnapi/core": "^1.10.0",
@@ -104,9 +104,9 @@
104
104
  "typescript": "^6.0.3",
105
105
  "vercel": "^54.4.0",
106
106
  "vitest": "^4.1.7",
107
- "@sentry/junior-memory": "0.223.0",
107
+ "@sentry/junior-memory": "0.224.0",
108
108
  "@sentry/junior-testing": "0.0.0",
109
- "@sentry/junior-github": "0.223.0"
109
+ "@sentry/junior-github": "0.224.0"
110
110
  },
111
111
  "scripts": {
112
112
  "build": "tsdown",