@sentry/junior 0.225.0 → 0.227.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 (65) hide show
  1. package/dist/{agent-hooks-CRuRcOg9.js → agent-hooks-bEwEJhlg.js} +231 -17
  2. package/dist/{agent-runner-Cad1RtWn.js → agent-runner-BGDSjciH.js} +2899 -159
  3. package/dist/api/schema.d.ts +417 -15
  4. package/dist/api/schema.js +4 -4
  5. package/dist/api.js +57 -32
  6. package/dist/{app-BbSD6EtD.d.ts → app-CjRIKZb5.d.ts} +1 -1
  7. package/dist/app.d.ts +1 -1
  8. package/dist/app.js +971 -7685
  9. package/dist/{briefs-BtnkPWT5.js → briefs-BkM_ZW4B.js} +4 -4
  10. package/dist/{catalog-runtime-pv4grNNb.js → catalog-runtime-Cw9V2jpn.js} +1 -1
  11. package/dist/{checkpoint-6fkAdB3g.js → checkpoint-oZYD3-Ar.js} +77 -11
  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-ihmkx60d.js → client-Pcxo3lGn.js} +2 -2
  19. package/dist/{config-DMg679BW.js → config-CYvEow1F.js} +2 -2
  20. package/dist/{context-Bplcgypl.js → context-0Et9iVSB.js} +1 -1
  21. package/dist/{conversation-Bygi39Xj.js → conversation-BnhOMfEB.js} +113 -25
  22. package/dist/{conversation-privacy-ZYy05Y3q.js → conversation-privacy-hQmyZbOC.js} +1 -1
  23. package/dist/{credential-sync-DCB2SwnQ.js → credential-sync-CUGbiiCM.js} +15 -135
  24. package/dist/{executor-B9R4cHte.js → executor-BXMlFrV6.js} +1 -1
  25. package/dist/history-nukv1YN8.d.ts +127 -0
  26. package/dist/images-8siTAUNW.js +82 -0
  27. package/dist/instrumentation.js +2 -2
  28. package/dist/{vercel-queue-DIkVcfK4.js → job-queue-AI0_QAgc.js} +61 -2
  29. package/dist/{logging-CcTvYQ8A.js → logging-BPBx6WF-.js} +1 -1
  30. package/dist/nitro.d.ts +1 -1
  31. package/dist/nitro.js +3 -4
  32. package/dist/{oauth-authorization-BS4vPJmu.js → oauth-authorization-Cq1GaLIP.js} +1 -1
  33. package/dist/{oauth-callback-server-DnlQsGBJ.js → oauth-callback-server-CnF03VYh.js} +2 -2
  34. package/dist/pending-auth-CHUjr_6d.js +59 -0
  35. package/dist/{profile-CV97YuiL.js → profile-upzC-wN1.js} +4 -4
  36. package/dist/{prompt-CL8zxsmm.js → prompt-CZIQcPHy.js} +1 -1
  37. package/dist/{registry-C8I4IejN.js → registry-DM5aMhjm.js} +2 -2
  38. package/dist/{resolve-DXVAzYa3.js → resolve-sF6Lg7Ay.js} +2 -2
  39. package/dist/{runner-Die1RJ_z.js → runner-Bu2wYpK8.js} +10 -10
  40. package/dist/{sandbox-egress-signals-BZepyVh1.js → sandbox-egress-signals-Dgerhizb.js} +1 -1
  41. package/dist/{schema-BE4uso4i.js → schema-BSiwcvjm.js} +2 -2
  42. package/dist/{skills-DUcDEgDI.js → skills-CAI5s___.js} +2 -2
  43. package/dist/{spawn-o15i3tJu.js → spawn-DRK9TBgY.js} +2 -2
  44. package/dist/{task-queue-D3PLY59C.js → task-queue-iuDAqfZg.js} +3 -4
  45. package/dist/{task-runner-BMl2aM2v.js → task-runner-S3QtH38c.js} +381 -12
  46. package/dist/{thread-state-CAR6gdAm.js → thread-state-C_arVuaN.js} +5 -5
  47. package/dist/{turn-failure-response-CZyoUMkD.js → turn-failure-response-DarwGYgC.js} +9 -10
  48. package/dist/{turn-lifecycle-DPDHKi2U.js → turn-lifecycle-CdiIejXH.js} +1 -1
  49. package/dist/{turn-session-routing-Jkmmxpp-.js → turn-session-routing-DyLGd_wU.js} +1 -1
  50. package/dist/{validation-BcGGxOa6.js → validation-BMig74Zp.js} +1 -1
  51. package/dist/{version-DYcuOFQb.js → version-lhQSfLjx.js} +1 -1
  52. package/dist/version.js +1 -1
  53. package/dist/web-authorization-r2lKYKJ2.js +162 -0
  54. package/dist/web-input-BU-Fu7iq.js +7784 -0
  55. package/dist/{reporting-window-DbUqng0P.js → web-message-id-xPI_EFSC.js} +11 -1
  56. package/dist/{work-Bm90pR9P.js → work-B9koS8sW.js} +7 -8
  57. package/dist/{worker-BvHr6JhE.js → worker-C_iJSRgG.js} +5 -6
  58. package/package.json +5 -4
  59. package/dist/execution-stats-CR9CYpyj.js +0 -373
  60. package/dist/history-yaSjGMD_.d.ts +0 -65
  61. package/dist/job-queue-D2SiTrnt.js +0 -63
  62. package/dist/short-title-3wYH3ipl.js +0 -71
  63. package/dist/stats-DawHjcTw.js +0 -2758
  64. package/dist/web-authorization-B09B8A8R.js +0 -38
  65. package/dist/web-input-CGE58TpK.js +0 -899
@@ -0,0 +1,162 @@
1
+ import { Ht as requestConversationWork, Mt as ensureConversationWake } from "./agent-runner-BGDSjciH.js";
2
+ import { Xt as getConversationEventStore } from "./agent-hooks-bEwEJhlg.js";
3
+ import { n as loadTurnCheckpoint, o as failTurnRecord, s as getTurnRecord } from "./checkpoint-oZYD3-Ar.js";
4
+ import { w as getStateAdapter } from "./profile-upzC-wN1.js";
5
+ import { a as getVercelConversationWorkQueue } from "./job-queue-AI0_QAgc.js";
6
+ import { n as resolveTurnSessionRouting } from "./turn-session-routing-DyLGd_wU.js";
7
+ import { z } from "zod";
8
+ import { randomUUID } from "node:crypto";
9
+ //#region src/chat/task-execution/authorized-turn.ts
10
+ /**
11
+ * OAuth callbacks save readiness, not agent history. The conversation worker
12
+ * consumes this event under its lease before it resumes the paused Turn.
13
+ */
14
+ const authorizationSchema = z.object({
15
+ kind: z.enum(["mcp", "plugin"]),
16
+ provider: z.string().min(1),
17
+ actorId: z.string().min(1),
18
+ authorizationId: z.string().min(1),
19
+ authSessionId: z.string().optional(),
20
+ scope: z.string().optional(),
21
+ configuration: z.record(z.string(), z.unknown()).optional(),
22
+ toolChannelId: z.string().optional()
23
+ });
24
+ function authorizationKey$1(turn) {
25
+ return `turn:${turn.turnId}:authorization:${turn.version}`;
26
+ }
27
+ /** Save authorization for this parked boundary without changing model history. */
28
+ async function recordTurnAuthorization(args) {
29
+ const turn = await getTurnRecord(args.conversationId, args.turnId);
30
+ if (!turn || turn.state !== "paused" || turn.resumeReason !== "auth") return;
31
+ await getConversationEventStore().append(args.conversationId, [{
32
+ idempotencyKey: authorizationKey$1(turn),
33
+ createdAtMs: Date.now(),
34
+ data: {
35
+ type: "structured_event",
36
+ namespace: "junior",
37
+ name: "turn_authorized",
38
+ version: 1,
39
+ turnId: turn.turnId,
40
+ content: authorizationSchema.parse(args)
41
+ }
42
+ }], { activity: "preserve" });
43
+ return {
44
+ conversationId: args.conversationId,
45
+ destination: args.destination,
46
+ turnId: turn.turnId,
47
+ expectedVersion: turn.version
48
+ };
49
+ }
50
+ /** Read authorization for the exact pause; a later auth pause needs its own callback. */
51
+ async function getTurnAuthorization(turn) {
52
+ const event = await getConversationEventStore().loadByIdempotencyKey(turn.conversationId, authorizationKey$1(turn));
53
+ if (event?.data.type !== "structured_event") return void 0;
54
+ return authorizationSchema.parse(event.data.content);
55
+ }
56
+ //#endregion
57
+ //#region src/chat/task-execution/turn-wake.ts
58
+ /** Build the worker input for a paused turn. */
59
+ async function getPausedTurnRequest(args) {
60
+ const turn = (await loadTurnCheckpoint({
61
+ conversationId: args.conversationId,
62
+ turnId: args.turnId
63
+ })).record;
64
+ if (!turn || turn.state !== "paused" || turn.resumeReason !== "timeout" && turn.resumeReason !== "yield" && turn.resumeReason !== "retry" && !(turn.resumeReason === "auth" && await getTurnAuthorization(turn)) || turn.resumeReason === "timeout" && turn.sliceId < 2) return;
65
+ let routing;
66
+ try {
67
+ routing = await resolveTurnSessionRouting({
68
+ conversationId: args.conversationId,
69
+ conversationStore: args.conversationStore
70
+ });
71
+ } catch (error) {
72
+ await failTurnRecord({
73
+ conversationId: args.conversationId,
74
+ expectedVersion: turn.version,
75
+ turnId: args.turnId,
76
+ errorMessage: error instanceof Error ? error.message : String(error)
77
+ });
78
+ return;
79
+ }
80
+ return {
81
+ conversationId: args.conversationId,
82
+ destination: routing.destination,
83
+ turnId: args.turnId,
84
+ expectedVersion: turn.version
85
+ };
86
+ }
87
+ /** Wake the conversation worker for a paused turn. */
88
+ async function wakePausedTurn(request, options = {}) {
89
+ const nowMs = options.nowMs ?? Date.now();
90
+ await requestConversationWork({
91
+ conversationId: request.conversationId,
92
+ destination: request.destination,
93
+ nowMs,
94
+ state: options.state
95
+ });
96
+ const queue = options.queue ?? getVercelConversationWorkQueue();
97
+ await ensureConversationWake({
98
+ conversationId: request.conversationId,
99
+ idempotencyKey: [
100
+ "agent-continue",
101
+ request.conversationId,
102
+ request.turnId,
103
+ request.expectedVersion,
104
+ nowMs
105
+ ].join(":"),
106
+ nowMs,
107
+ queue,
108
+ state: options.state
109
+ });
110
+ }
111
+ /** Create paused Turn operations for one app. */
112
+ function createPausedTurns(options = {}) {
113
+ return {
114
+ get: (args) => getPausedTurnRequest({
115
+ ...args,
116
+ conversationStore: options.conversationStore
117
+ }),
118
+ wake: (request) => wakePausedTurn(request, options)
119
+ };
120
+ }
121
+ /** Record completed authorization and wake the sole execution owner. */
122
+ async function wakeAuthorizedTurn(args, queue) {
123
+ const request = await recordTurnAuthorization(args);
124
+ if (request) await wakePausedTurn(request, { queue });
125
+ }
126
+ //#endregion
127
+ //#region src/chat/conversations/web-authorization.ts
128
+ const WEB_AUTHORIZATION_PREFIX = "junior:web_authorization:v1";
129
+ const WEB_AUTHORIZATION_TTL_MS = 864e5;
130
+ function authorizationKey(conversationId, actorId) {
131
+ return `${WEB_AUTHORIZATION_PREFIX}:${conversationId}:${actorId}`;
132
+ }
133
+ /** Build authorization delivery for one web turn. */
134
+ function createWebAuthorization(args) {
135
+ return {
136
+ createState: async () => randomUUID(),
137
+ deliver: async (request) => {
138
+ await getStateAdapter().set(authorizationKey(args.conversationId, args.actorId), JSON.stringify({
139
+ ...request,
140
+ ...args
141
+ }), WEB_AUTHORIZATION_TTL_MS);
142
+ }
143
+ };
144
+ }
145
+ /** Read the pending authorization request for one web actor. */
146
+ async function getWebAuthorization(args) {
147
+ const value = await getStateAdapter().get(authorizationKey(args.conversationId, args.actorId));
148
+ if (typeof value !== "string") return void 0;
149
+ try {
150
+ const parsed = JSON.parse(value);
151
+ if (parsed.actorId !== args.actorId || parsed.conversationId !== args.conversationId || typeof parsed.authorizationUrl !== "string" || typeof parsed.label !== "string" || typeof parsed.completionText !== "string") return;
152
+ return parsed;
153
+ } catch {
154
+ return;
155
+ }
156
+ }
157
+ /** Remove a web authorization request after the parked turn continues. */
158
+ async function deleteWebAuthorization(args) {
159
+ await getStateAdapter().delete(authorizationKey(args.conversationId, args.actorId));
160
+ }
161
+ //#endregion
162
+ export { getPausedTurnRequest as a, getTurnAuthorization as c, createPausedTurns as i, deleteWebAuthorization as n, wakeAuthorizedTurn as o, getWebAuthorization as r, wakePausedTurn as s, createWebAuthorization as t };