@sentry/junior 0.114.0 → 0.116.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 (147) hide show
  1. package/dist/{agent-hooks-WNBUY4OB.js → agent-hooks-67NFITDH.js} +13 -12
  2. package/dist/api/conversations/detail.d.ts +20 -0
  3. package/dist/api/conversations/event-list.d.ts +2 -0
  4. package/dist/api/conversations/event-page.d.ts +1 -1
  5. package/dist/api/conversations/events.d.ts +1 -1
  6. package/dist/api/health.d.ts +7 -0
  7. package/dist/api/people/profile.d.ts +2 -2
  8. package/dist/api/people/shared.d.ts +1 -1
  9. package/dist/api/personal-tokens/create.d.ts +11 -0
  10. package/dist/api/personal-tokens/list.d.ts +12 -0
  11. package/dist/api/personal-tokens/revoke.d.ts +5 -0
  12. package/dist/api/personal-tokens/routes.d.ts +4 -0
  13. package/dist/api/plugin-reports.d.ts +62 -0
  14. package/dist/api/plugins.d.ts +8 -0
  15. package/dist/api/route.d.ts +1 -1
  16. package/dist/api/runtime.d.ts +24 -0
  17. package/dist/api/schema/conversation.d.ts +26 -0
  18. package/dist/api/schema/person.d.ts +3 -3
  19. package/dist/api/schema/personal-token.d.ts +38 -0
  20. package/dist/api/schema.d.ts +4 -2
  21. package/dist/api/schema.js +19 -7
  22. package/dist/api/skills.d.ts +6 -0
  23. package/dist/api.d.ts +1 -0
  24. package/dist/api.js +285 -121
  25. package/dist/app.js +1957 -5677
  26. package/dist/catalog-runtime-CWZY6GTH.js +18 -0
  27. package/dist/chat/agent/request.d.ts +7 -0
  28. package/dist/chat/agent/resume.d.ts +1 -0
  29. package/dist/chat/agent/sandbox.d.ts +3 -0
  30. package/dist/chat/agent/tools.d.ts +3 -0
  31. package/dist/chat/agent-dispatch/context.d.ts +2 -0
  32. package/dist/chat/agent-dispatch/heartbeat.d.ts +11 -5
  33. package/dist/chat/agent-dispatch/signing.d.ts +14 -5
  34. package/dist/chat/agent-dispatch/store.d.ts +36 -15
  35. package/dist/chat/agent-dispatch/types.d.ts +23 -10
  36. package/dist/chat/agent-dispatch/work.d.ts +58 -0
  37. package/dist/chat/app/factory.d.ts +12 -3
  38. package/dist/chat/config.d.ts +2 -0
  39. package/dist/chat/conversations/history.d.ts +291 -290
  40. package/dist/chat/conversations/projection.d.ts +2 -2
  41. package/dist/chat/local/credential-sync.d.ts +5 -0
  42. package/dist/chat/local/oauth-relay.d.ts +4 -0
  43. package/dist/chat/mcp/oauth.d.ts +1 -0
  44. package/dist/chat/mcp/tool-manager.d.ts +2 -1
  45. package/dist/chat/oauth-authorization.d.ts +17 -0
  46. package/dist/chat/oauth-flow.d.ts +9 -0
  47. package/dist/chat/pi/conversation-events.d.ts +6 -2
  48. package/dist/chat/plugins/annotations.d.ts +8 -0
  49. package/dist/chat/plugins/registry.d.ts +0 -3
  50. package/dist/chat/plugins/types.d.ts +0 -2
  51. package/dist/chat/runtime/agent-continue-runner.d.ts +4 -0
  52. package/dist/chat/runtime/reply-executor.d.ts +6 -1
  53. package/dist/chat/runtime/slack-resume.d.ts +5 -1
  54. package/dist/chat/runtime/turn-input.d.ts +3 -0
  55. package/dist/chat/sandbox/egress/schemas.d.ts +46 -0
  56. package/dist/chat/sandbox/egress/signals.d.ts +9 -0
  57. package/dist/chat/sandbox/sandbox.d.ts +4 -1
  58. package/dist/chat/sandbox/session.d.ts +2 -11
  59. package/dist/chat/sandbox/workspace.d.ts +10 -2
  60. package/dist/chat/sentry-payload-filter.d.ts +4 -4
  61. package/dist/chat/services/mcp-auth-orchestration.d.ts +5 -3
  62. package/dist/chat/services/plugin-auth-orchestration.d.ts +2 -0
  63. package/dist/chat/services/turn-session-record.d.ts +14 -1
  64. package/dist/chat/slack/dispatch-turn.d.ts +25 -0
  65. package/dist/chat/slack/message-control.d.ts +2 -0
  66. package/dist/chat/slack/oauth-authorization-message.d.ts +3 -0
  67. package/dist/chat/state/turn-session.d.ts +11 -0
  68. package/dist/chat/task-execution/slack-work.d.ts +2 -0
  69. package/dist/chat/tool-support/text-range-result.d.ts +3 -0
  70. package/dist/chat/tool-support/zod-tool.d.ts +2 -1
  71. package/dist/chat/tools/definition.d.ts +3 -5
  72. package/dist/chat/tools/query-conversation-events.d.ts +68 -0
  73. package/dist/chat/tools/sandbox/file-utils.d.ts +8 -1
  74. package/dist/chat/tools/sandbox/find-files.d.ts +2 -1
  75. package/dist/chat/tools/sandbox/grep.d.ts +2 -1
  76. package/dist/{chunk-OSKEC4XU.js → chunk-25GU5B5E.js} +1 -1
  77. package/dist/{chunk-XLFBQJUO.js → chunk-3H45VOBZ.js} +32 -7
  78. package/dist/{chunk-4FUEG3QY.js → chunk-3JOGUT46.js} +4 -16
  79. package/dist/chunk-4CODA7P5.js +43 -0
  80. package/dist/{chunk-O4GT7LYB.js → chunk-4DD6AOCG.js} +3 -43
  81. package/dist/{chunk-YU6PO42Q.js → chunk-53ZKTQO6.js} +1 -1
  82. package/dist/{chunk-WV4UJBAS.js → chunk-5UNB623T.js} +1282 -2536
  83. package/dist/{chunk-TLGM5X2M.js → chunk-6RQ5GCWH.js} +2 -2
  84. package/dist/{chunk-MIAKQNYX.js → chunk-6ZK6FZIV.js} +1 -1
  85. package/dist/{chunk-W6RDUAO3.js → chunk-BXLS3I4W.js} +1 -1
  86. package/dist/{chunk-RD7EJI7H.js → chunk-CI3VK7X5.js} +69 -3
  87. package/dist/chunk-DIB4GX3G.js +8 -0
  88. package/dist/{chunk-42WRQLJ6.js → chunk-F3B2YJ76.js} +0 -14
  89. package/dist/chunk-FA6POGLH.js +70 -0
  90. package/dist/{chunk-6Y5L4BOM.js → chunk-FXOYURO4.js} +5 -3
  91. package/dist/chunk-HDSDCEPK.js +80 -0
  92. package/dist/{chunk-C4MZ3GP5.js → chunk-HZF5P5UN.js} +1 -1
  93. package/dist/{chunk-K2W4CK7K.js → chunk-JZPQ5K4V.js} +10 -129
  94. package/dist/{chunk-FIGAF6KL.js → chunk-KBNDFU6J.js} +108 -38
  95. package/dist/{chunk-PM3PX42K.js → chunk-MGH5ADQS.js} +1 -2
  96. package/dist/{chunk-5CZ7RETL.js → chunk-N7TMYLF2.js} +1 -1
  97. package/dist/chunk-OB42YVAE.js +16 -0
  98. package/dist/{chunk-6QWPVTMO.js → chunk-OF5FODBL.js} +125 -23
  99. package/dist/{chunk-2ZTTXTSZ.js → chunk-PE44LDDQ.js} +9 -4
  100. package/dist/chunk-PGKWXHYJ.js +1870 -0
  101. package/dist/{chunk-ZGXH3REA.js → chunk-PZGPCOSD.js} +12 -2
  102. package/dist/{chunk-JQFJO5WH.js → chunk-RXRQJF7Y.js} +74 -17
  103. package/dist/{chunk-S4QDH23A.js → chunk-TC4ZEM2D.js} +113 -79
  104. package/dist/{chunk-ABPSDO6M.js → chunk-UEVLIYK5.js} +234 -165
  105. package/dist/chunk-VKZ6WVAY.js +4318 -0
  106. package/dist/{chunk-VNNBSKCO.js → chunk-VZCSLYCE.js} +22 -7
  107. package/dist/chunk-W3U3YQYI.js +71 -0
  108. package/dist/{chunk-SG5WAA7H.js → chunk-WKU7TY22.js} +0 -3
  109. package/dist/cli/chat.js +74 -42
  110. package/dist/cli/check.js +10 -8
  111. package/dist/cli/init.js +1 -0
  112. package/dist/cli/plugins.js +18 -16
  113. package/dist/cli/snapshot-warmup.js +13 -11
  114. package/dist/cli/upgrade.js +12 -10
  115. package/dist/db/schema/api-tokens.d.ts +160 -0
  116. package/dist/db/schema/conversation-annotations.d.ts +142 -0
  117. package/dist/db/schema.d.ts +305 -1
  118. package/dist/{db-4VLP7KBF.js → db-57FHVGGQ.js} +9 -8
  119. package/dist/handlers/agent-dispatch.d.ts +7 -3
  120. package/dist/handlers/sandbox-egress-signals.d.ts +4 -0
  121. package/dist/instrumentation.js +72 -4
  122. package/dist/nitro.js +5 -5
  123. package/dist/oauth-callback-server-PAQRPXZX.js +231 -0
  124. package/dist/oauth-relay-3ZU72UGL.js +9 -0
  125. package/dist/personal-tokens/store.d.ts +27 -0
  126. package/dist/{plugins-PZMDS7AT.js → plugins-IUJA4VBU.js} +1 -1
  127. package/dist/reporting-schema.d.ts +10 -4
  128. package/dist/reporting.d.ts +5 -5
  129. package/dist/{runner-IPXLWQOF.js → runner-4ISZYJEX.js} +141 -74
  130. package/dist/sandbox-egress-signals-CDFAP67O.js +75 -0
  131. package/dist/{skills-QCNZISNF.js → skills-UE2KXQMB.js} +10 -8
  132. package/dist/validation-PO5LHTJT.js +21 -0
  133. package/dist/version.js +1 -1
  134. package/migrations/0008_sticky_rage.sql +14 -0
  135. package/migrations/0009_slippery_harrier.sql +12 -0
  136. package/migrations/0010_native_conversation_history.sql +142 -0
  137. package/migrations/meta/0008_snapshot.json +1076 -0
  138. package/migrations/meta/0009_snapshot.json +1146 -0
  139. package/migrations/meta/0010_snapshot.json +1190 -0
  140. package/migrations/meta/_journal.json +22 -1
  141. package/package.json +6 -7
  142. package/dist/catalog-runtime-6O4M6JGA.js +0 -16
  143. package/dist/chat/agent-dispatch/runner.d.ts +0 -13
  144. package/dist/chat/capabilities/catalog.d.ts +0 -16
  145. package/dist/chat/oauth-authorization-message.d.ts +0 -6
  146. package/dist/validation-I2BW3UHD.js +0 -19
  147. package/dist/{chunk-KNFROR7R.js → chunk-5I6ORJUY.js} +1 -1
@@ -1,11 +1,15 @@
1
1
  import {
2
2
  ConversationTurnLifecycleService,
3
3
  buildDeliveredTurnStatePatch,
4
+ completeAuthPauseTurn,
4
5
  finalizeFailedTurnReplyWithEvent,
5
6
  processPluginTask,
6
7
  scheduleSessionCompletedPluginTasks
7
- } from "./chunk-ABPSDO6M.js";
8
- import "./chunk-KNFROR7R.js";
8
+ } from "./chunk-UEVLIYK5.js";
9
+ import "./chunk-5I6ORJUY.js";
10
+ import {
11
+ authorizationId
12
+ } from "./chunk-DIB4GX3G.js";
9
13
  import {
10
14
  buildConversationContext,
11
15
  coerceThreadArtifactsState,
@@ -21,34 +25,36 @@ import {
21
25
  persistConversationMessages,
22
26
  persistThreadStateById,
23
27
  persistWithRetry,
28
+ recordAuthorizationCompleted,
24
29
  recordDeliveredAssistantMessage,
25
30
  startActiveTurn,
26
31
  stripRuntimeTurnContext,
27
32
  trimTrailingAssistantMessages,
28
33
  updateConversationStats,
29
34
  upsertConversationMessage
30
- } from "./chunk-6QWPVTMO.js";
35
+ } from "./chunk-OF5FODBL.js";
31
36
  import "./chunk-MU6HHZEN.js";
32
37
  import "./chunk-PDO5BLNM.js";
33
- import "./chunk-VNNBSKCO.js";
34
- import "./chunk-YU6PO42Q.js";
35
- import "./chunk-RD7EJI7H.js";
38
+ import "./chunk-VZCSLYCE.js";
39
+ import "./chunk-53ZKTQO6.js";
40
+ import "./chunk-CI3VK7X5.js";
36
41
  import {
37
42
  getConversationEventStore
38
- } from "./chunk-FIGAF6KL.js";
39
- import "./chunk-JQFJO5WH.js";
43
+ } from "./chunk-KBNDFU6J.js";
44
+ import "./chunk-RXRQJF7Y.js";
40
45
  import "./chunk-4ZNGQH7C.js";
41
- import "./chunk-ZGXH3REA.js";
46
+ import "./chunk-PZGPCOSD.js";
42
47
  import "./chunk-VFUK3X5B.js";
43
- import "./chunk-6Y5L4BOM.js";
44
- import "./chunk-C4MZ3GP5.js";
48
+ import "./chunk-FXOYURO4.js";
49
+ import "./chunk-HZF5P5UN.js";
45
50
  import {
46
51
  logException
47
- } from "./chunk-4FUEG3QY.js";
48
- import "./chunk-42WRQLJ6.js";
52
+ } from "./chunk-3JOGUT46.js";
53
+ import "./chunk-OB42YVAE.js";
54
+ import "./chunk-F3B2YJ76.js";
49
55
  import "./chunk-6GWA276C.js";
50
- import "./chunk-5CZ7RETL.js";
51
- import "./chunk-PM3PX42K.js";
56
+ import "./chunk-N7TMYLF2.js";
57
+ import "./chunk-MGH5ADQS.js";
52
58
  import "./chunk-MLKGABMK.js";
53
59
 
54
60
  // src/chat/local/runner.ts
@@ -77,11 +83,17 @@ function localDestination(conversationId) {
77
83
  function localTurnId() {
78
84
  return `local-turn-${randomUUID()}`;
79
85
  }
86
+ function localRunId() {
87
+ return `local-run-${randomUUID()}`;
88
+ }
80
89
  function captureLocalBoundaryFailure(args) {
81
90
  const eventId = args.capture(
82
91
  args.error,
83
92
  LOCAL_FAILURE_EVENT_NAMES[args.failureCode],
84
- { conversationId: args.conversationId, runId: args.turnId },
93
+ {
94
+ conversationId: args.conversationId,
95
+ ...args.runId ? { runId: args.runId } : {}
96
+ },
85
97
  { "app.ai.failure_code": args.failureCode },
86
98
  "Local agent turn failed at its owning runtime boundary"
87
99
  );
@@ -157,6 +169,8 @@ async function runLocalAgentTurn(input, deps) {
157
169
  let failureCode = "persistence_failed";
158
170
  let modelFailureEventId;
159
171
  let modelFailureCaptureAttempted = false;
172
+ let currentRunId;
173
+ let completionSliceId = 1;
160
174
  const localActor = {
161
175
  fullName: "Local CLI",
162
176
  platform: "local",
@@ -201,66 +215,117 @@ async function runLocalAgentTurn(input, deps) {
201
215
  conversationId: input.conversationId
202
216
  });
203
217
  failureCode = "agent_run_failed";
204
- const outcome = await deps.agentRunner.run({
205
- conversationId: input.conversationId,
206
- turnId,
207
- runId: turnId,
208
- input: {
209
- messageText: text,
210
- conversationContext: buildConversationContext(conversation, {
211
- excludeMessageId: userMessageId
212
- }),
213
- piMessages
214
- },
215
- routing: {
216
- credentialContext: {
217
- actor: { platform: "system", name: "local-cli" }
218
+ const runAgent = async (messages) => {
219
+ currentRunId = localRunId();
220
+ const authorization = deps.authorization ? {
221
+ createState: deps.authorization.createState,
222
+ deliver: deps.authorization.deliver
223
+ } : void 0;
224
+ return await deps.agentRunner.run({
225
+ conversationId: input.conversationId,
226
+ turnId,
227
+ runId: currentRunId,
228
+ input: {
229
+ messageText: text,
230
+ conversationContext: buildConversationContext(conversation, {
231
+ excludeMessageId: userMessageId
232
+ }),
233
+ piMessages: messages
218
234
  },
219
- destination,
220
- source,
221
- actor: localActor,
222
- surface: "internal"
223
- },
224
- policy: {
225
- authorizationFlowMode: "disabled"
226
- },
227
- state: {
228
- artifactState: artifacts,
229
- sandboxRef
230
- },
231
- observers: {
232
- onStatus: async (status) => {
233
- await deps.onStatus?.(status.text);
235
+ routing: {
236
+ credentialContext: {
237
+ actor: { type: "user", userId: "local-cli" }
238
+ },
239
+ destination,
240
+ source,
241
+ actor: localActor,
242
+ surface: "internal"
234
243
  },
235
- onToolInvocation: async (invocation) => {
236
- await deps.onToolInvocation?.(invocation);
244
+ authorization,
245
+ policy: {
246
+ authorizationFlowMode: deps.authorization ? "interactive" : "disabled",
247
+ sandboxEgressSignals: deps.sandboxEgressSignals
237
248
  },
238
- onToolResult: async (result) => {
239
- await deps.onToolResult?.(result);
240
- }
241
- },
242
- delivery: {
243
- onAssistantMessage: deliverAssistantMessage
244
- },
245
- durability: {
246
- onArtifactStateUpdated: async (nextArtifacts) => {
247
- artifacts = nextArtifacts;
248
- await persistThreadStateById(input.conversationId, {
249
- artifacts,
250
- conversation,
251
- sandboxRef
252
- });
249
+ state: {
250
+ artifactState: artifacts,
251
+ pendingAuth: conversation.processing.pendingAuth,
252
+ sandboxRef
253
+ },
254
+ observers: {
255
+ onStatus: async (status) => {
256
+ await deps.onStatus?.(status.text);
257
+ },
258
+ onToolInvocation: async (invocation) => {
259
+ await deps.onToolInvocation?.(invocation);
260
+ },
261
+ onToolResult: async (result) => {
262
+ await deps.onToolResult?.(result);
263
+ }
264
+ },
265
+ delivery: {
266
+ onAssistantMessage: deliverAssistantMessage
253
267
  },
254
- onSandboxRefChanged: async (nextSandboxRef) => {
255
- sandboxRef = nextSandboxRef;
256
- await persistThreadStateById(input.conversationId, {
257
- artifacts,
258
- conversation,
259
- sandboxRef
260
- });
268
+ durability: {
269
+ onArtifactStateUpdated: async (nextArtifacts) => {
270
+ artifacts = nextArtifacts;
271
+ await persistThreadStateById(input.conversationId, {
272
+ artifacts,
273
+ conversation,
274
+ sandboxRef
275
+ });
276
+ },
277
+ onSandboxRefChanged: async (nextSandboxRef) => {
278
+ sandboxRef = nextSandboxRef;
279
+ await persistThreadStateById(input.conversationId, {
280
+ artifacts,
281
+ conversation,
282
+ sandboxRef
283
+ });
284
+ },
285
+ recordPendingAuth: async (pendingAuth) => {
286
+ conversation.processing.pendingAuth = pendingAuth;
287
+ await persistThreadStateById(input.conversationId, {
288
+ artifacts,
289
+ conversation,
290
+ sandboxRef
291
+ });
292
+ }
261
293
  }
294
+ });
295
+ };
296
+ let outcome = await runAgent(piMessages);
297
+ while (outcome.status === "awaiting_auth") {
298
+ const pendingAuth = conversation.processing.pendingAuth;
299
+ if (!pendingAuth || !deps.authorization) {
300
+ throw new Error(
301
+ "Local OAuth requires an active callback server and authorization delivery."
302
+ );
262
303
  }
263
- });
304
+ completeAuthPauseTurn({ conversation, sessionId: turnId });
305
+ await persistThreadStateById(input.conversationId, {
306
+ artifacts,
307
+ conversation,
308
+ sandboxRef
309
+ });
310
+ await deps.authorization.wait();
311
+ await recordAuthorizationCompleted({
312
+ conversationId: input.conversationId,
313
+ kind: pendingAuth.kind,
314
+ provider: pendingAuth.provider,
315
+ actorId: pendingAuth.actorId,
316
+ authorizationId: authorizationId({
317
+ sessionId: turnId,
318
+ kind: pendingAuth.kind,
319
+ provider: pendingAuth.provider
320
+ })
321
+ });
322
+ completionSliceId += 1;
323
+ outcome = await runAgent(
324
+ await (deps.loadPiMessages ?? loadLocalPiMessages)({
325
+ conversationId: input.conversationId
326
+ })
327
+ );
328
+ }
264
329
  if (outcome.status !== "completed") {
265
330
  throw new Error(`Local agent run ended with ${outcome.status}`);
266
331
  }
@@ -284,12 +349,13 @@ async function runLocalAgentTurn(input, deps) {
284
349
  userMessageId
285
350
  });
286
351
  } catch (error) {
352
+ deps.authorization?.cancel();
287
353
  const failureEventId = modelFailureCaptureAttempted && failureCode === "agent_run_failed" ? modelFailureEventId : captureLocalBoundaryFailure({
288
354
  capture: deps.logException ?? logException,
289
355
  conversationId: input.conversationId,
290
356
  error,
291
357
  failureCode,
292
- turnId
358
+ runId: currentRunId
293
359
  });
294
360
  try {
295
361
  markTurnFailed({
@@ -311,7 +377,7 @@ async function runLocalAgentTurn(input, deps) {
311
377
  conversationId: input.conversationId,
312
378
  error: persistenceError,
313
379
  failureCode: "persistence_failed",
314
- turnId
380
+ runId: currentRunId
315
381
  });
316
382
  await lifecycle.fail({
317
383
  conversationId: input.conversationId,
@@ -334,6 +400,7 @@ async function runLocalAgentTurn(input, deps) {
334
400
  });
335
401
  throw error;
336
402
  }
403
+ deps.authorization?.cancel();
337
404
  try {
338
405
  await persistThreadStateById(input.conversationId, {
339
406
  artifacts: completedState.artifacts ?? artifacts,
@@ -344,7 +411,7 @@ async function runLocalAgentTurn(input, deps) {
344
411
  await (deps.completeDeliveredTurn ?? completeDeliveredTurn)({
345
412
  conversationId: input.conversationId,
346
413
  sessionId: turnId,
347
- sliceId: 1,
414
+ sliceId: completionSliceId,
348
415
  messages: reply.piMessages,
349
416
  modelId: reply.diagnostics.modelId,
350
417
  durationMs: reply.diagnostics.durationMs,
@@ -362,7 +429,7 @@ async function runLocalAgentTurn(input, deps) {
362
429
  conversationId: input.conversationId,
363
430
  error,
364
431
  failureCode: "persistence_failed",
365
- turnId
432
+ runId: currentRunId
366
433
  });
367
434
  await lifecycle.fail({
368
435
  conversationId: input.conversationId,
@@ -0,0 +1,75 @@
1
+ import {
2
+ sandboxEgressSignalsResponseSchema
3
+ } from "./chunk-HDSDCEPK.js";
4
+ import "./chunk-W3U3YQYI.js";
5
+ import "./chunk-HZF5P5UN.js";
6
+ import "./chunk-F3B2YJ76.js";
7
+ import "./chunk-MLKGABMK.js";
8
+
9
+ // src/chat/local/sandbox-egress-signals.ts
10
+ var SANDBOX_EGRESS_SIGNALS_PATH = "/api/internal/sandbox-egress/signals";
11
+ var LOCAL_DEV_SERVER_TIMEOUT_MS = 1e3;
12
+ function signalRequest(baseUrl, credentialToken) {
13
+ return {
14
+ headers: {
15
+ "x-junior-sandbox-egress-token": credentialToken
16
+ },
17
+ url: `${baseUrl}${SANDBOX_EGRESS_SIGNALS_PATH}`
18
+ };
19
+ }
20
+ async function requestLocalDevServer(request, init) {
21
+ try {
22
+ return await fetch(request.url, {
23
+ ...init,
24
+ headers: request.headers,
25
+ signal: AbortSignal.timeout(LOCAL_DEV_SERVER_TIMEOUT_MS)
26
+ });
27
+ } catch {
28
+ return void 0;
29
+ }
30
+ }
31
+ function createLocalSandboxEgressSignalTransport(baseUrl) {
32
+ return {
33
+ clear: async (credentialToken) => {
34
+ const request = signalRequest(baseUrl, credentialToken);
35
+ const response = await requestLocalDevServer(request, {
36
+ method: "DELETE"
37
+ });
38
+ if (!response) {
39
+ return;
40
+ }
41
+ if (!response.ok) {
42
+ throw new Error(
43
+ `Could not clear dev-server sandbox egress signals: HTTP ${response.status}`
44
+ );
45
+ }
46
+ },
47
+ consume: async (credentialToken) => {
48
+ const request = signalRequest(baseUrl, credentialToken);
49
+ const response = await requestLocalDevServer(request);
50
+ if (!response) {
51
+ return {};
52
+ }
53
+ if (!response.ok) {
54
+ throw new Error(
55
+ `Could not consume dev-server sandbox egress signals: HTTP ${response.status}`
56
+ );
57
+ }
58
+ const value = sandboxEgressSignalsResponseSchema.safeParse(
59
+ await response.json()
60
+ );
61
+ if (!value.success) {
62
+ throw new Error("Dev-server sandbox egress signals were invalid");
63
+ }
64
+ const authRequired = value.data.auth_required;
65
+ const permissionDenied = value.data.permission_denied;
66
+ return {
67
+ ...authRequired ? { authRequired } : {},
68
+ ...permissionDenied ? { permissionDenied } : {}
69
+ };
70
+ }
71
+ };
72
+ }
73
+ export {
74
+ createLocalSandboxEgressSignalTransport
75
+ };
@@ -6,17 +6,19 @@ import {
6
6
  parseSkillInvocation,
7
7
  resetSkillDiscoveryCache,
8
8
  stripFrontmatter
9
- } from "./chunk-TLGM5X2M.js";
10
- import "./chunk-OSKEC4XU.js";
11
- import "./chunk-K2W4CK7K.js";
12
- import "./chunk-C4MZ3GP5.js";
13
- import "./chunk-4FUEG3QY.js";
14
- import "./chunk-42WRQLJ6.js";
9
+ } from "./chunk-6RQ5GCWH.js";
10
+ import "./chunk-25GU5B5E.js";
11
+ import "./chunk-JZPQ5K4V.js";
12
+ import "./chunk-W3U3YQYI.js";
13
+ import "./chunk-HZF5P5UN.js";
14
+ import "./chunk-3JOGUT46.js";
15
+ import "./chunk-OB42YVAE.js";
16
+ import "./chunk-F3B2YJ76.js";
15
17
  import "./chunk-6GWA276C.js";
16
18
  import "./chunk-B3IT5END.js";
17
19
  import "./chunk-3V7OFJZC.js";
18
- import "./chunk-5CZ7RETL.js";
19
- import "./chunk-PM3PX42K.js";
20
+ import "./chunk-N7TMYLF2.js";
21
+ import "./chunk-MGH5ADQS.js";
20
22
  import "./chunk-MLKGABMK.js";
21
23
  export {
22
24
  discoverSkills,
@@ -0,0 +1,21 @@
1
+ import {
2
+ validatePluginEgressCredentialHooks,
3
+ validatePluginRegistrations
4
+ } from "./chunk-BXLS3I4W.js";
5
+ import "./chunk-25GU5B5E.js";
6
+ import "./chunk-JZPQ5K4V.js";
7
+ import "./chunk-W3U3YQYI.js";
8
+ import "./chunk-HZF5P5UN.js";
9
+ import "./chunk-3JOGUT46.js";
10
+ import "./chunk-OB42YVAE.js";
11
+ import "./chunk-F3B2YJ76.js";
12
+ import "./chunk-6GWA276C.js";
13
+ import "./chunk-B3IT5END.js";
14
+ import "./chunk-3V7OFJZC.js";
15
+ import "./chunk-N7TMYLF2.js";
16
+ import "./chunk-MGH5ADQS.js";
17
+ import "./chunk-MLKGABMK.js";
18
+ export {
19
+ validatePluginEgressCredentialHooks,
20
+ validatePluginRegistrations
21
+ };
package/dist/version.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  JUNIOR_VERSION
3
- } from "./chunk-PM3PX42K.js";
3
+ } from "./chunk-MGH5ADQS.js";
4
4
  import "./chunk-MLKGABMK.js";
5
5
  export {
6
6
  JUNIOR_VERSION
@@ -0,0 +1,14 @@
1
+ CREATE TABLE "junior_api_tokens" (
2
+ "id" text PRIMARY KEY NOT NULL,
3
+ "owner_email_normalized" text NOT NULL,
4
+ "name" text NOT NULL,
5
+ "token_hash" text NOT NULL,
6
+ "token_suffix" text NOT NULL,
7
+ "created_at" timestamp with time zone NOT NULL,
8
+ "expires_at" timestamp with time zone NOT NULL,
9
+ "last_used_at" timestamp with time zone,
10
+ "revoked_at" timestamp with time zone
11
+ );
12
+ --> statement-breakpoint
13
+ CREATE UNIQUE INDEX "junior_api_tokens_token_hash_uidx" ON "junior_api_tokens" USING btree ("token_hash");--> statement-breakpoint
14
+ CREATE INDEX "junior_api_tokens_owner_email_idx" ON "junior_api_tokens" USING btree ("owner_email_normalized");
@@ -0,0 +1,12 @@
1
+ CREATE TABLE "junior_conversation_annotations" (
2
+ "conversation_id" text NOT NULL,
3
+ "plugin" text NOT NULL,
4
+ "kind" text NOT NULL,
5
+ "key" text NOT NULL,
6
+ "annotation_json" jsonb NOT NULL,
7
+ "created_at" timestamp with time zone NOT NULL,
8
+ "updated_at" timestamp with time zone NOT NULL,
9
+ CONSTRAINT "junior_conversation_annotations_pk" PRIMARY KEY("conversation_id","plugin","kind","key")
10
+ );
11
+ --> statement-breakpoint
12
+ ALTER TABLE "junior_conversation_annotations" ADD CONSTRAINT "junior_conversation_annotations_conversation_id_fk" FOREIGN KEY ("conversation_id") REFERENCES "public"."junior_conversations"("conversation_id") ON DELETE cascade ON UPDATE no action;
@@ -0,0 +1,142 @@
1
+ DO $$
2
+ BEGIN
3
+ IF EXISTS (
4
+ SELECT 1
5
+ FROM "junior_conversation_events"
6
+ WHERE "schema_version" = 1
7
+ AND "type" = 'agent_step'
8
+ AND (
9
+ jsonb_typeof("payload") IS DISTINCT FROM 'object'
10
+ OR jsonb_typeof("payload"->'message') IS DISTINCT FROM 'object'
11
+ OR "payload"->'message'->>'role' IS NULL
12
+ OR "payload"->'message'->>'role' NOT IN ('user', 'assistant', 'toolResult')
13
+ )
14
+ ) THEN
15
+ RAISE EXCEPTION 'Cannot migrate malformed agent_step conversation events';
16
+ END IF;
17
+
18
+ IF EXISTS (
19
+ SELECT 1
20
+ FROM "junior_conversation_events" AS "event"
21
+ WHERE "event"."schema_version" = 1
22
+ AND "event"."type" IN ('compaction', 'handoff', 'rollback')
23
+ AND (
24
+ jsonb_typeof("event"."payload") IS DISTINCT FROM 'object'
25
+ OR jsonb_typeof("event"."payload"->'replacementHistory') IS DISTINCT FROM 'array'
26
+ )
27
+ ) THEN
28
+ RAISE EXCEPTION 'Cannot migrate malformed conversation history replacements';
29
+ END IF;
30
+
31
+ IF EXISTS (
32
+ SELECT 1
33
+ FROM "junior_conversation_events" AS "event"
34
+ CROSS JOIN LATERAL jsonb_array_elements(
35
+ "event"."payload"->'replacementHistory'
36
+ ) AS "replacement"("item")
37
+ WHERE "event"."schema_version" = 1
38
+ AND "event"."type" IN ('compaction', 'handoff', 'rollback')
39
+ AND (
40
+ jsonb_typeof("replacement"."item") IS DISTINCT FROM 'object'
41
+ OR (
42
+ "replacement"."item" ? 'message'
43
+ AND (
44
+ jsonb_typeof("replacement"."item"->'message') IS DISTINCT FROM 'object'
45
+ OR "replacement"."item"->'message'->>'role' IS NULL
46
+ OR "replacement"."item"->'message'->>'role' NOT IN ('user', 'assistant', 'toolResult')
47
+ )
48
+ )
49
+ OR (
50
+ NOT ("replacement"."item" ? 'message')
51
+ AND (
52
+ jsonb_typeof("replacement"."item"->'item') IS DISTINCT FROM 'object'
53
+ OR "replacement"."item"->'item'->>'type' IS NULL
54
+ OR "replacement"."item"->'item'->>'type' NOT IN ('user_message', 'assistant_message', 'tool_result')
55
+ OR "replacement"."item"->'item' ? 'role'
56
+ OR (
57
+ "replacement"."item"->'item'->>'type' = 'user_message'
58
+ AND jsonb_typeof("replacement"."item"->'item'->'provenance') IS DISTINCT FROM 'object'
59
+ )
60
+ )
61
+ )
62
+ )
63
+ ) THEN
64
+ RAISE EXCEPTION 'Cannot migrate malformed replacement history items';
65
+ END IF;
66
+ END $$;
67
+ --> statement-breakpoint
68
+ UPDATE "junior_conversation_events"
69
+ SET
70
+ "type" = CASE "payload"->'message'->>'role'
71
+ WHEN 'user' THEN 'user_message'
72
+ WHEN 'assistant' THEN 'assistant_message'
73
+ WHEN 'toolResult' THEN 'tool_result'
74
+ END,
75
+ "payload" = CASE "payload"->'message'->>'role'
76
+ WHEN 'user' THEN
77
+ (("payload"->'message') - 'role')
78
+ || jsonb_build_object(
79
+ 'provenance',
80
+ coalesce("payload"->'provenance', '{"authority":"context"}'::jsonb)
81
+ )
82
+ ELSE ("payload"->'message') - 'role'
83
+ END
84
+ WHERE "schema_version" = 1
85
+ AND "type" = 'agent_step';
86
+ --> statement-breakpoint
87
+ UPDATE "junior_conversation_events" AS "event"
88
+ SET "payload" = jsonb_set(
89
+ "event"."payload",
90
+ '{replacementHistory}',
91
+ (
92
+ SELECT coalesce(
93
+ jsonb_agg(
94
+ CASE
95
+ WHEN "replacement"."item" ? 'message' THEN
96
+ (("replacement"."item" - 'message') - 'provenance')
97
+ || jsonb_build_object(
98
+ 'item',
99
+ CASE "replacement"."item"->'message'->>'role'
100
+ WHEN 'user' THEN
101
+ (("replacement"."item"->'message') - 'role')
102
+ || jsonb_build_object('type', 'user_message')
103
+ || jsonb_build_object(
104
+ 'provenance',
105
+ coalesce(
106
+ "replacement"."item"->'provenance',
107
+ '{"authority":"context"}'::jsonb
108
+ )
109
+ )
110
+ WHEN 'assistant' THEN
111
+ (("replacement"."item"->'message') - 'role')
112
+ || jsonb_build_object('type', 'assistant_message')
113
+ WHEN 'toolResult' THEN
114
+ (("replacement"."item"->'message') - 'role')
115
+ || jsonb_build_object('type', 'tool_result')
116
+ END
117
+ )
118
+ ELSE "replacement"."item"
119
+ END
120
+ ORDER BY "replacement"."position"
121
+ ),
122
+ '[]'::jsonb
123
+ )
124
+ FROM jsonb_array_elements(
125
+ "event"."payload"->'replacementHistory'
126
+ ) WITH ORDINALITY AS "replacement"("item", "position")
127
+ )
128
+ )
129
+ WHERE "event"."schema_version" = 1
130
+ AND "event"."type" IN ('compaction', 'handoff', 'rollback')
131
+ AND EXISTS (
132
+ SELECT 1
133
+ FROM jsonb_array_elements(
134
+ "event"."payload"->'replacementHistory'
135
+ ) AS "replacement"("item")
136
+ WHERE "replacement"."item" ? 'message'
137
+ );
138
+ --> statement-breakpoint
139
+ UPDATE "junior_conversation_events"
140
+ SET "type" = 'compaction'
141
+ WHERE "schema_version" = 1
142
+ AND "type" = 'rollback';