@sentry/junior 0.53.0 → 0.54.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 (222) hide show
  1. package/README.md +3 -2
  2. package/dist/api-reference.d.ts +7 -0
  3. package/dist/app.d.ts +5 -10
  4. package/dist/app.js +1934 -1658
  5. package/dist/build/copy-build-content.d.ts +4 -0
  6. package/dist/build/glob-to-regex.d.ts +2 -0
  7. package/dist/build/rolldown-workarounds.d.ts +14 -0
  8. package/dist/build/virtual-config.d.ts +4 -0
  9. package/dist/chat/app/factory.d.ts +10 -0
  10. package/dist/chat/app/production.d.ts +6 -0
  11. package/dist/chat/app/services.d.ts +17 -0
  12. package/dist/chat/capabilities/catalog.d.ts +16 -0
  13. package/dist/chat/capabilities/factory.d.ts +10 -0
  14. package/dist/chat/capabilities/jr-rpc-command.d.ts +26 -0
  15. package/dist/chat/capabilities/router.d.ts +19 -0
  16. package/dist/chat/coerce.d.ts +6 -0
  17. package/dist/chat/config.d.ts +46 -0
  18. package/dist/chat/configuration/defaults.d.ts +4 -0
  19. package/dist/chat/configuration/service.d.ts +2 -0
  20. package/dist/chat/configuration/types.d.ts +37 -0
  21. package/dist/chat/configuration/validation.d.ts +2 -0
  22. package/dist/chat/credentials/broker.d.ts +22 -0
  23. package/dist/chat/credentials/header-transforms.d.ts +3 -0
  24. package/dist/chat/credentials/oauth-scope.d.ts +4 -0
  25. package/dist/chat/credentials/state-adapter-token-store.d.ts +9 -0
  26. package/dist/chat/credentials/test-broker.d.ts +19 -0
  27. package/dist/chat/credentials/unlink-provider.d.ts +2 -0
  28. package/dist/chat/credentials/user-token-store.d.ts +11 -0
  29. package/dist/chat/discovery.d.ts +47 -0
  30. package/dist/chat/ingress/junior-chat.d.ts +26 -0
  31. package/dist/chat/ingress/message-changed.d.ts +50 -0
  32. package/dist/chat/ingress/message-router.d.ts +9 -0
  33. package/dist/chat/ingress/slash-command.d.ts +3 -0
  34. package/dist/chat/ingress/workspace-membership.d.ts +10 -0
  35. package/dist/chat/interruption-marker.d.ts +2 -0
  36. package/dist/chat/logging.d.ts +88 -0
  37. package/dist/chat/mcp/auth-store.d.ts +41 -0
  38. package/dist/chat/mcp/client.d.ts +34 -0
  39. package/dist/chat/mcp/errors.d.ts +8 -0
  40. package/dist/chat/mcp/oauth-provider.d.ts +27 -0
  41. package/dist/chat/mcp/oauth.d.ts +17 -0
  42. package/dist/chat/mcp/tool-manager.d.ts +60 -0
  43. package/dist/chat/oauth-flow.d.ts +45 -0
  44. package/dist/chat/optional-string.d.ts +5 -0
  45. package/dist/chat/pi/client.d.ts +49 -0
  46. package/dist/chat/pi/messages.d.ts +3 -0
  47. package/dist/chat/pi/traced-stream.d.ts +9 -0
  48. package/dist/chat/plugins/auth/api-headers-broker.d.ts +6 -0
  49. package/dist/chat/plugins/auth/auth-token-placeholder.d.ts +3 -0
  50. package/dist/chat/plugins/auth/github-app-broker.d.ts +4 -0
  51. package/dist/chat/plugins/auth/oauth-bearer-broker.d.ts +6 -0
  52. package/dist/chat/plugins/auth/oauth-request.d.ts +18 -0
  53. package/dist/chat/plugins/command-env.d.ts +3 -0
  54. package/dist/chat/plugins/manifest.d.ts +3 -0
  55. package/dist/chat/plugins/package-discovery.d.ts +14 -0
  56. package/dist/chat/plugins/registry.d.ts +23 -0
  57. package/dist/chat/plugins/types.d.ts +146 -0
  58. package/dist/chat/prompt.d.ts +39 -0
  59. package/dist/chat/queue/thread-message-dispatcher.d.ts +33 -0
  60. package/dist/chat/respond-helpers.d.ts +77 -0
  61. package/dist/chat/respond.d.ts +64 -0
  62. package/dist/chat/runtime/auth-pause-state.d.ts +11 -0
  63. package/dist/chat/runtime/delivered-turn-state.d.ts +15 -0
  64. package/dist/chat/runtime/dev-agent-trace.d.ts +1 -0
  65. package/dist/chat/runtime/processing-reaction.d.ts +25 -0
  66. package/dist/chat/runtime/reply-executor.d.ts +56 -0
  67. package/dist/chat/runtime/report-progress.d.ts +3 -0
  68. package/dist/chat/runtime/slack-resume.d.ts +50 -0
  69. package/dist/chat/runtime/slack-runtime.d.ts +100 -0
  70. package/dist/chat/runtime/thread-context.d.ts +22 -0
  71. package/dist/chat/runtime/thread-state.d.ts +28 -0
  72. package/dist/chat/runtime/turn-preparation.d.ts +43 -0
  73. package/dist/chat/runtime/turn-user-message.d.ts +12 -0
  74. package/dist/chat/runtime/turn.d.ts +69 -0
  75. package/dist/chat/sandbox/credentials.d.ts +11 -0
  76. package/dist/chat/sandbox/egress-oidc.d.ts +3 -0
  77. package/dist/chat/sandbox/egress-policy.d.ts +11 -0
  78. package/dist/chat/sandbox/egress-proxy.d.ts +10 -0
  79. package/dist/chat/sandbox/egress-session.d.ts +27 -0
  80. package/dist/chat/sandbox/errors.d.ts +12 -0
  81. package/dist/chat/sandbox/eval-gh-stub.d.ts +2 -0
  82. package/dist/chat/sandbox/eval-oauth-stub.d.ts +2 -0
  83. package/dist/chat/sandbox/eval-sentry-stub.d.ts +2 -0
  84. package/dist/chat/sandbox/fault-injection.d.ts +2 -0
  85. package/dist/chat/sandbox/http-error-details.d.ts +18 -0
  86. package/dist/chat/sandbox/noninteractive-command.d.ts +17 -0
  87. package/dist/chat/sandbox/paths.d.ts +5 -0
  88. package/dist/chat/sandbox/runtime-dependency-snapshots.d.ts +20 -0
  89. package/dist/chat/sandbox/sandbox.d.ts +52 -0
  90. package/dist/chat/sandbox/session.d.ts +53 -0
  91. package/dist/chat/sandbox/skill-sandbox.d.ts +42 -0
  92. package/dist/chat/sandbox/skill-sync.d.ts +17 -0
  93. package/dist/chat/sandbox/workspace.d.ts +55 -0
  94. package/dist/chat/sentry.d.ts +2 -0
  95. package/dist/chat/services/attachment-claims.d.ts +2 -0
  96. package/dist/chat/services/auth-pause-response.d.ts +2 -0
  97. package/dist/chat/services/auth-pause.d.ts +12 -0
  98. package/dist/chat/services/channel-intent.d.ts +2 -0
  99. package/dist/chat/services/conversation-memory.d.ts +33 -0
  100. package/dist/chat/services/mcp-auth-orchestration.d.ts +29 -0
  101. package/dist/chat/services/pending-auth.d.ts +27 -0
  102. package/dist/chat/services/plugin-auth-orchestration.d.ts +36 -0
  103. package/dist/chat/services/provider-default-config.d.ts +9 -0
  104. package/dist/chat/services/provider-retry.d.ts +6 -0
  105. package/dist/chat/services/reply-delivery-plan.d.ts +17 -0
  106. package/dist/chat/services/subscribed-decision.d.ts +63 -0
  107. package/dist/chat/services/subscribed-reply-policy.d.ts +23 -0
  108. package/dist/chat/services/timeout-resume.d.ts +17 -0
  109. package/dist/chat/services/turn-checkpoint.d.ts +74 -0
  110. package/dist/chat/services/turn-continuation-response.d.ts +2 -0
  111. package/dist/chat/services/turn-failure-response.d.ts +15 -0
  112. package/dist/chat/services/turn-result.d.ts +55 -0
  113. package/dist/chat/services/turn-thinking-level.d.ts +49 -0
  114. package/dist/chat/services/vision-context.d.ts +61 -0
  115. package/dist/chat/skills.d.ts +48 -0
  116. package/dist/chat/slack/adapter.d.ts +9 -0
  117. package/dist/chat/slack/app-home.d.ts +11 -0
  118. package/dist/chat/slack/assistant-thread/lifecycle.d.ts +13 -0
  119. package/dist/chat/slack/assistant-thread/status-render.d.ts +28 -0
  120. package/dist/chat/slack/assistant-thread/status-scheduler.d.ts +23 -0
  121. package/dist/chat/slack/assistant-thread/status-send.d.ts +31 -0
  122. package/dist/chat/slack/assistant-thread/status.d.ts +36 -0
  123. package/dist/chat/slack/assistant-thread/title.d.ts +28 -0
  124. package/dist/chat/slack/canvas-references.d.ts +2 -0
  125. package/dist/chat/slack/channel.d.ts +48 -0
  126. package/dist/chat/slack/client.d.ts +52 -0
  127. package/dist/chat/slack/context.d.ts +9 -0
  128. package/dist/chat/slack/emoji.d.ts +1 -0
  129. package/dist/chat/slack/errors.d.ts +6 -0
  130. package/dist/chat/slack/footer.d.ts +42 -0
  131. package/dist/chat/slack/legacy-attachments.d.ts +4 -0
  132. package/dist/chat/slack/message.d.ts +6 -0
  133. package/dist/chat/slack/mrkdwn.d.ts +12 -0
  134. package/dist/chat/slack/outbound.d.ts +57 -0
  135. package/dist/chat/slack/output.d.ts +54 -0
  136. package/dist/chat/slack/reply.d.ts +33 -0
  137. package/dist/chat/slack/status-format.d.ts +2 -0
  138. package/dist/chat/slack/turn-continuation-notice.d.ts +8 -0
  139. package/dist/chat/slack/user.d.ts +7 -0
  140. package/dist/chat/slack/users.d.ts +39 -0
  141. package/dist/chat/state/adapter.d.ts +9 -0
  142. package/dist/chat/state/artifacts.d.ts +29 -0
  143. package/dist/chat/state/conversation.d.ts +81 -0
  144. package/dist/chat/state/pi-session-message-store.d.ts +15 -0
  145. package/dist/chat/state/turn-id.d.ts +2 -0
  146. package/dist/chat/state/turn-session-store.d.ts +49 -0
  147. package/dist/chat/tools/advisor/session-store.d.ts +9 -0
  148. package/dist/chat/tools/advisor/tool.d.ts +33 -0
  149. package/dist/chat/tools/agent-tools.d.ts +9 -0
  150. package/dist/chat/tools/channel-capabilities.d.ts +11 -0
  151. package/dist/chat/tools/definition.d.ts +17 -0
  152. package/dist/chat/tools/execution/build-sandbox-input.d.ts +2 -0
  153. package/dist/chat/tools/execution/normalize-result.d.ts +6 -0
  154. package/dist/chat/tools/execution/tool-error-handler.d.ts +3 -0
  155. package/dist/chat/tools/execution/tool-input-error.d.ts +6 -0
  156. package/dist/chat/tools/idempotency.d.ts +1 -0
  157. package/dist/chat/tools/index.d.ts +5 -0
  158. package/dist/chat/tools/runtime/report-progress.d.ts +4 -0
  159. package/dist/chat/tools/sandbox/attach-file.d.ts +7 -0
  160. package/dist/chat/tools/sandbox/bash.d.ts +5 -0
  161. package/dist/chat/tools/sandbox/edit-file.d.ts +37 -0
  162. package/dist/chat/tools/sandbox/file-utils.d.ts +52 -0
  163. package/dist/chat/tools/sandbox/find-files.d.ts +24 -0
  164. package/dist/chat/tools/sandbox/grep.d.ts +33 -0
  165. package/dist/chat/tools/sandbox/list-dir.d.ts +22 -0
  166. package/dist/chat/tools/sandbox/read-file.d.ts +32 -0
  167. package/dist/chat/tools/sandbox/text-edits.d.ts +28 -0
  168. package/dist/chat/tools/sandbox/write-file.d.ts +5 -0
  169. package/dist/chat/tools/skill/call-mcp-tool.d.ts +7 -0
  170. package/dist/chat/tools/skill/load-skill.d.ts +22 -0
  171. package/dist/chat/tools/skill/mcp-tool-summary.d.ts +31 -0
  172. package/dist/chat/tools/skill/search-mcp-tools.d.ts +8 -0
  173. package/dist/chat/tools/slack/canvas-tools.d.ts +29 -0
  174. package/dist/chat/tools/slack/canvases.d.ts +45 -0
  175. package/dist/chat/tools/slack/channel-list-messages.d.ts +9 -0
  176. package/dist/chat/tools/slack/channel-post-message.d.ts +4 -0
  177. package/dist/chat/tools/slack/list-tools.d.ts +21 -0
  178. package/dist/chat/tools/slack/lists.d.ts +42 -0
  179. package/dist/chat/tools/slack/message-add-reaction.d.ts +4 -0
  180. package/dist/chat/tools/slack/slack-message-url.d.ts +18 -0
  181. package/dist/chat/tools/slack/thread-read.d.ts +9 -0
  182. package/dist/chat/tools/slack/user-lookup.d.ts +8 -0
  183. package/dist/chat/tools/system-time.d.ts +1 -0
  184. package/dist/chat/tools/types.d.ts +55 -0
  185. package/dist/chat/tools/web/constants.d.ts +6 -0
  186. package/dist/chat/tools/web/fetch-content.d.ts +23 -0
  187. package/dist/chat/tools/web/fetch-tool.d.ts +5 -0
  188. package/dist/chat/tools/web/image-generate.d.ts +4 -0
  189. package/dist/chat/tools/web/network.d.ts +6 -0
  190. package/dist/chat/tools/web/search.d.ts +5 -0
  191. package/dist/chat/turn-context-tag.d.ts +6 -0
  192. package/dist/chat/usage.d.ts +24 -0
  193. package/dist/chat/xml.d.ts +1 -0
  194. package/dist/{chunk-XPXD3FCE.js → chunk-5LUISFEY.js} +189 -35
  195. package/dist/{chunk-KCOKQLBF.js → chunk-7WTXNEPF.js} +120 -15
  196. package/dist/{chunk-ZNFNY53B.js → chunk-QCHPJ4FD.js} +2 -2
  197. package/dist/{chunk-Q3FDONU7.js → chunk-YITDDLS3.js} +34 -28
  198. package/dist/cli/check.js +3 -3
  199. package/dist/cli/init.js +1 -0
  200. package/dist/cli/snapshot-warmup.js +3 -3
  201. package/dist/handlers/diagnostics-dashboard.d.ts +2 -0
  202. package/dist/handlers/diagnostics.d.ts +2 -0
  203. package/dist/handlers/health.d.ts +4 -0
  204. package/dist/handlers/mcp-oauth-callback.d.ts +2 -0
  205. package/dist/handlers/oauth-callback.d.ts +2 -0
  206. package/dist/handlers/oauth-html.d.ts +2 -0
  207. package/dist/handlers/sandbox-egress-proxy.d.ts +4 -0
  208. package/dist/handlers/turn-resume.d.ts +3 -0
  209. package/dist/handlers/types.d.ts +2 -0
  210. package/dist/handlers/webhooks.d.ts +15 -0
  211. package/dist/instrumentation.d.ts +1 -3
  212. package/dist/nitro.d.ts +4 -7
  213. package/dist/nitro.js +112 -54
  214. package/dist/package-resolution.d.ts +13 -0
  215. package/dist/vercel.d.ts +2 -4
  216. package/package.json +25 -25
  217. package/dist/cli/check.d.ts +0 -8
  218. package/dist/cli/env.d.ts +0 -7
  219. package/dist/cli/init.d.ts +0 -3
  220. package/dist/cli/run.d.ts +0 -12
  221. package/dist/cli/snapshot-warmup.d.ts +0 -3
  222. package/dist/types-X_iCClPb.d.ts +0 -75
@@ -0,0 +1 @@
1
+ export declare function escapeXml(value: string): string;
@@ -1,6 +1,3 @@
1
- // src/chat/plugins/package-discovery.ts
2
- import path2 from "path";
3
-
4
1
  // src/chat/discovery.ts
5
2
  import fs, { statSync } from "fs";
6
3
  import path from "path";
@@ -220,9 +217,146 @@ function listReferenceFiles() {
220
217
  }
221
218
  }
222
219
 
220
+ // src/package-resolution.ts
221
+ import { statSync as statSync2 } from "fs";
222
+ import { createRequire } from "module";
223
+ import path2 from "path";
224
+ function isDirectory2(targetPath) {
225
+ try {
226
+ return statSync2(targetPath).isDirectory();
227
+ } catch {
228
+ return false;
229
+ }
230
+ }
231
+ function isFile2(targetPath) {
232
+ try {
233
+ return statSync2(targetPath).isFile();
234
+ } catch {
235
+ return false;
236
+ }
237
+ }
238
+ function uniqueResolvedPathsInOrder2(values) {
239
+ const seen = /* @__PURE__ */ new Set();
240
+ const resolved = [];
241
+ for (const value of values) {
242
+ const normalized = path2.resolve(value);
243
+ if (seen.has(normalized)) {
244
+ continue;
245
+ }
246
+ seen.add(normalized);
247
+ resolved.push(normalized);
248
+ }
249
+ return resolved;
250
+ }
251
+ function ancestorNodeModulesDirs(cwd) {
252
+ const dirs = [];
253
+ let current = path2.resolve(cwd);
254
+ while (true) {
255
+ const nodeModulesDir = path2.join(current, "node_modules");
256
+ if (isDirectory2(nodeModulesDir)) {
257
+ dirs.push(nodeModulesDir);
258
+ }
259
+ const parent = path2.dirname(current);
260
+ if (parent === current) {
261
+ break;
262
+ }
263
+ current = parent;
264
+ }
265
+ return dirs;
266
+ }
267
+ function packageDirInNodeModules(nodeModulesDir, packageName) {
268
+ const packageDir = path2.join(nodeModulesDir, ...packageName.split("/"));
269
+ return isDirectory2(packageDir) ? path2.resolve(packageDir) : void 0;
270
+ }
271
+ function isValidPackageSegment(segment) {
272
+ return Boolean(segment) && segment !== "." && segment !== ".." && !segment.startsWith(".") && /^[A-Za-z0-9._~-]+$/.test(segment);
273
+ }
274
+ function isValidPackageName(packageName) {
275
+ if (!packageName || packageName.includes("\\") || path2.isAbsolute(packageName)) {
276
+ return false;
277
+ }
278
+ const parts = packageName.split("/");
279
+ if (parts[0].startsWith("@")) {
280
+ return parts.length === 2 && parts[0].length > 1 && isValidPackageSegment(parts[0].slice(1)) && isValidPackageSegment(parts[1]);
281
+ }
282
+ return parts.length === 1 && isValidPackageSegment(parts[0]);
283
+ }
284
+ function findPackageRoot(entryPath) {
285
+ let dir = path2.dirname(entryPath);
286
+ while (dir !== path2.dirname(dir)) {
287
+ if (isFile2(path2.join(dir, "package.json"))) {
288
+ return path2.resolve(dir);
289
+ }
290
+ dir = path2.dirname(dir);
291
+ }
292
+ return void 0;
293
+ }
294
+ function findPackageNodeModulesDir(packageDir, packageName) {
295
+ const parts = path2.resolve(packageDir).split(path2.sep);
296
+ const packageParts = packageName.split("/");
297
+ for (let index = parts.length - 1; index >= 0; index -= 1) {
298
+ if (parts[index] !== "node_modules") {
299
+ continue;
300
+ }
301
+ const candidatePackageParts = parts.slice(
302
+ index + 1,
303
+ index + 1 + packageParts.length
304
+ );
305
+ if (candidatePackageParts.join("/") !== packageParts.join("/")) {
306
+ continue;
307
+ }
308
+ return path2.resolve(parts.slice(0, index + 1).join(path2.sep) || path2.sep);
309
+ }
310
+ return void 0;
311
+ }
312
+ function resolvePackageWithNode(cwd, packageName) {
313
+ let requireFromCwd;
314
+ try {
315
+ requireFromCwd = createRequire(path2.join(cwd, "package.json"));
316
+ } catch {
317
+ return void 0;
318
+ }
319
+ for (const specifier of [`${packageName}/package.json`, packageName]) {
320
+ try {
321
+ const resolved = requireFromCwd.resolve(specifier);
322
+ const dir = specifier.endsWith("/package.json") ? path2.dirname(resolved) : findPackageRoot(resolved);
323
+ if (!dir) {
324
+ continue;
325
+ }
326
+ const nodeModulesDir = findPackageNodeModulesDir(dir, packageName);
327
+ return {
328
+ dir,
329
+ ...nodeModulesDir ? { nodeModulesDir } : {}
330
+ };
331
+ } catch {
332
+ }
333
+ }
334
+ return void 0;
335
+ }
336
+ function resolvePackageLocation(cwd, packageName, options) {
337
+ if (!isValidPackageName(packageName)) {
338
+ return void 0;
339
+ }
340
+ const nodeModulesDirs = uniqueResolvedPathsInOrder2([
341
+ ...options?.nodeModulesDirs ?? [],
342
+ ...ancestorNodeModulesDirs(cwd)
343
+ ]);
344
+ for (const nodeModulesDir of nodeModulesDirs) {
345
+ const dir = packageDirInNodeModules(nodeModulesDir, packageName);
346
+ if (dir) {
347
+ return { dir, nodeModulesDir };
348
+ }
349
+ }
350
+ return resolvePackageWithNode(cwd, packageName);
351
+ }
352
+ function resolvePackageDir(cwd, packageName) {
353
+ return resolvePackageLocation(cwd, packageName)?.dir;
354
+ }
355
+
223
356
  // src/chat/plugins/package-discovery.ts
357
+ import path3 from "path";
224
358
  function normalizeForGlob(targetPath) {
225
- return targetPath.split(path2.sep).join("/");
359
+ return targetPath.split(path3.sep).join("/");
226
360
  }
227
361
  function uniqueStringsInOrder(values) {
228
362
  const seen = /* @__PURE__ */ new Set();
@@ -237,33 +371,47 @@ function uniqueStringsInOrder(values) {
237
371
  return resolved;
238
372
  }
239
373
  function pathForTracingInclude(cwd, targetPath) {
240
- const relative = path2.relative(cwd, targetPath);
241
- if (!relative || path2.isAbsolute(relative)) {
374
+ const relative = path3.relative(cwd, targetPath);
375
+ if (!relative || path3.isAbsolute(relative) || relative === ".." || relative.startsWith(`..${path3.sep}`)) {
242
376
  return null;
243
377
  }
244
378
  const normalized = normalizeForGlob(relative);
245
379
  return normalized.startsWith(".") ? normalized : `./${normalized}`;
246
380
  }
247
- var configuredPluginPackages;
248
- function setPluginPackages(packages) {
249
- configuredPluginPackages = packages;
250
- }
251
- function resolvePackageDirFromName(packageName, candidateNodeModulesDirs) {
252
- for (const nodeModulesDir of candidateNodeModulesDirs) {
253
- const packageDir = path2.join(nodeModulesDir, ...packageName.split("/"));
254
- if (isDirectory(packageDir)) {
255
- return {
256
- dir: path2.resolve(packageDir),
257
- nodeModulesDir: path2.resolve(nodeModulesDir)
258
- };
381
+ function normalizePluginPackageNames(packageNames) {
382
+ if (packageNames === void 0) {
383
+ return [];
384
+ }
385
+ if (!Array.isArray(packageNames)) {
386
+ throw new Error("plugins.packages must be an array of package names");
387
+ }
388
+ const normalized = [];
389
+ const seen = /* @__PURE__ */ new Set();
390
+ for (const packageName of packageNames) {
391
+ const normalizedPackageName = typeof packageName === "string" ? packageName.trim() : "";
392
+ if (!normalizedPackageName || !isValidPackageName(normalizedPackageName)) {
393
+ throw new Error("Plugin package names must be valid npm package names");
394
+ }
395
+ if (seen.has(normalizedPackageName)) {
396
+ continue;
259
397
  }
398
+ seen.add(normalizedPackageName);
399
+ normalized.push(normalizedPackageName);
260
400
  }
261
- return null;
401
+ return normalized;
402
+ }
403
+ function formatNodeModulesDirs(candidateNodeModulesDirs) {
404
+ return candidateNodeModulesDirs.length > 0 ? candidateNodeModulesDirs.join(", ") : "none found";
405
+ }
406
+ function resolvePackageDirFromName(cwd, packageName, candidateNodeModulesDirs) {
407
+ return resolvePackageLocation(cwd, packageName, {
408
+ nodeModulesDirs: candidateNodeModulesDirs
409
+ }) ?? null;
262
410
  }
263
411
  function readPluginPackageFlags(dir) {
264
- const hasRootPluginManifest = isFile(path2.join(dir, "plugin.yaml"));
265
- const hasPluginsDir = isDirectory(path2.join(dir, "plugins"));
266
- const hasSkillsDir = isDirectory(path2.join(dir, "skills"));
412
+ const hasRootPluginManifest = isFile(path3.join(dir, "plugin.yaml"));
413
+ const hasPluginsDir = isDirectory(path3.join(dir, "plugins"));
414
+ const hasSkillsDir = isDirectory(path3.join(dir, "skills"));
267
415
  if (!hasRootPluginManifest && !hasPluginsDir && !hasSkillsDir) {
268
416
  return null;
269
417
  }
@@ -273,26 +421,29 @@ function readPluginPackageFlags(dir) {
273
421
  hasSkillsDir
274
422
  };
275
423
  }
276
- function discoverDeclaredPackages(packageNames, candidateNodeModulesDirs) {
424
+ function discoverDeclaredPackages(packageNames, candidateNodeModulesDirs, cwd) {
277
425
  const discovered = [];
278
- const seenPackageNames = /* @__PURE__ */ new Set();
279
426
  const seenPackageDirs = /* @__PURE__ */ new Set();
280
427
  for (const packageName of packageNames) {
281
428
  const resolved = resolvePackageDirFromName(
429
+ cwd,
282
430
  packageName,
283
431
  candidateNodeModulesDirs
284
432
  );
285
433
  if (!resolved) {
286
- continue;
434
+ throw new Error(
435
+ `Plugin package "${packageName}" was configured but could not be resolved from node_modules or package resolution (${formatNodeModulesDirs(candidateNodeModulesDirs)})`
436
+ );
287
437
  }
288
- if (seenPackageNames.has(packageName) || seenPackageDirs.has(resolved.dir)) {
438
+ if (seenPackageDirs.has(resolved.dir)) {
289
439
  continue;
290
440
  }
291
441
  const pluginFlags = readPluginPackageFlags(resolved.dir);
292
442
  if (!pluginFlags) {
293
- continue;
443
+ throw new Error(
444
+ `Plugin package "${packageName}" was configured but does not contain plugin content; expected plugin.yaml, plugins/, or skills/ in ${resolved.dir}`
445
+ );
294
446
  }
295
- seenPackageNames.add(packageName);
296
447
  seenPackageDirs.add(resolved.dir);
297
448
  discovered.push({
298
449
  name: packageName,
@@ -304,12 +455,13 @@ function discoverDeclaredPackages(packageNames, candidateNodeModulesDirs) {
304
455
  return discovered;
305
456
  }
306
457
  function discoverInstalledPluginPackageContent(cwd = process.cwd(), options) {
307
- const resolvedCwd = path2.resolve(cwd);
308
- const packageNames = options?.packageNames ?? configuredPluginPackages ?? [];
458
+ const resolvedCwd = path3.resolve(cwd);
459
+ const packageNames = normalizePluginPackageNames(options?.packageNames);
309
460
  const nodeModulesDirs = options?.nodeModulesDirs ?? discoverNodeModulesDirs(resolvedCwd);
310
461
  const discoveredPackages = discoverDeclaredPackages(
311
462
  packageNames,
312
- nodeModulesDirs
463
+ nodeModulesDirs,
464
+ resolvedCwd
313
465
  );
314
466
  const manifestRoots = [];
315
467
  const skillRoots2 = [];
@@ -317,7 +469,7 @@ function discoverInstalledPluginPackageContent(cwd = process.cwd(), options) {
317
469
  for (const pkg of discoveredPackages) {
318
470
  const tracingBasePath = pkg.nodeModulesDir ? pathForTracingInclude(
319
471
  resolvedCwd,
320
- path2.join(pkg.nodeModulesDir, ...pkg.name.split("/"))
472
+ path3.join(pkg.nodeModulesDir, ...pkg.name.split("/"))
321
473
  ) : pathForTracingInclude(resolvedCwd, pkg.dir);
322
474
  if (pkg.hasRootPluginManifest) {
323
475
  manifestRoots.push(pkg.dir);
@@ -326,13 +478,13 @@ function discoverInstalledPluginPackageContent(cwd = process.cwd(), options) {
326
478
  }
327
479
  }
328
480
  if (pkg.hasPluginsDir) {
329
- manifestRoots.push(path2.join(pkg.dir, "plugins"));
481
+ manifestRoots.push(path3.join(pkg.dir, "plugins"));
330
482
  if (tracingBasePath) {
331
483
  tracingIncludes.push(`${tracingBasePath}/plugins/**/*`);
332
484
  }
333
485
  }
334
486
  if (pkg.hasSkillsDir) {
335
- skillRoots2.push(path2.join(pkg.dir, "skills"));
487
+ skillRoots2.push(path3.join(pkg.dir, "skills"));
336
488
  if (tracingBasePath) {
337
489
  tracingIncludes.push(`${tracingBasePath}/skills/**/*`);
338
490
  }
@@ -355,6 +507,8 @@ export {
355
507
  soulPathCandidates,
356
508
  worldPathCandidates,
357
509
  listReferenceFiles,
358
- setPluginPackages,
510
+ isValidPackageName,
511
+ resolvePackageDir,
512
+ normalizePluginPackageNames,
359
513
  discoverInstalledPluginPackageContent
360
514
  };
@@ -7,14 +7,14 @@ import {
7
7
  serializeGenAiAttribute,
8
8
  setSpanAttributes,
9
9
  withSpan
10
- } from "./chunk-Q3FDONU7.js";
10
+ } from "./chunk-YITDDLS3.js";
11
11
 
12
12
  // src/chat/state/adapter.ts
13
13
  import { createMemoryState } from "@chat-adapter/state-memory";
14
14
  import { createRedisState } from "@chat-adapter/state-redis";
15
15
 
16
16
  // src/chat/config.ts
17
- import { getModel } from "@mariozechner/pi-ai";
17
+ import { getModel } from "@earendil-works/pi-ai";
18
18
 
19
19
  // src/chat/optional-string.ts
20
20
  function toOptionalTrimmed(value) {
@@ -31,11 +31,11 @@ import {
31
31
  getEnvApiKey,
32
32
  getModels,
33
33
  registerApiProvider
34
- } from "@mariozechner/pi-ai";
34
+ } from "@earendil-works/pi-ai";
35
35
  import {
36
36
  streamAnthropic,
37
37
  streamSimpleAnthropic
38
- } from "@mariozechner/pi-ai/anthropic";
38
+ } from "@earendil-works/pi-ai/anthropic";
39
39
  registerApiProvider({
40
40
  api: "anthropic-messages",
41
41
  stream: streamAnthropic,
@@ -413,25 +413,124 @@ function getRuntimeMetadata() {
413
413
  }
414
414
 
415
415
  // src/chat/state/adapter.ts
416
- var MIN_LOCK_TTL_MS = 1e3 * 60 * 5;
416
+ var ACTIVE_LOCK_TTL_MS = 9e4;
417
+ var ACTIVE_LOCK_HEARTBEAT_MS = 3e4;
417
418
  var stateAdapter;
418
419
  var redisStateAdapter;
419
- function createQueuedStateAdapter(base) {
420
+ function createQueuedStateAdapter(base, options) {
421
+ const heartbeats = /* @__PURE__ */ new Map();
422
+ const effectiveLockTtlMs = (ttlMs) => Math.max(ttlMs, ACTIVE_LOCK_TTL_MS);
423
+ const shouldHeartbeatLock = (ttlMs) => ttlMs <= ACTIVE_LOCK_TTL_MS;
424
+ const heartbeatKey = (lock) => `${lock.threadId}:${lock.token}`;
425
+ const stopHeartbeatByKey = (key) => {
426
+ const heartbeat = heartbeats.get(key);
427
+ if (!heartbeat) {
428
+ return;
429
+ }
430
+ clearInterval(heartbeat.timer);
431
+ heartbeats.delete(key);
432
+ };
433
+ const stopHeartbeat = (lock) => {
434
+ stopHeartbeatByKey(heartbeatKey(lock));
435
+ };
436
+ const stopHeartbeatsForThread = (threadId) => {
437
+ for (const [key, heartbeat] of heartbeats) {
438
+ if (heartbeat.lock.threadId === threadId) {
439
+ stopHeartbeatByKey(key);
440
+ }
441
+ }
442
+ };
443
+ const stopAllHeartbeats = () => {
444
+ for (const key of heartbeats.keys()) {
445
+ stopHeartbeatByKey(key);
446
+ }
447
+ };
448
+ const runHeartbeat = async (key) => {
449
+ const heartbeat = heartbeats.get(key);
450
+ if (!heartbeat || heartbeat.inFlight) {
451
+ return;
452
+ }
453
+ heartbeat.inFlight = true;
454
+ try {
455
+ if (Date.now() - heartbeat.startedAtMs >= options.activeLockMaxAgeMs) {
456
+ stopHeartbeatByKey(key);
457
+ return;
458
+ }
459
+ const extended = await base.extendLock(heartbeat.lock, heartbeat.ttlMs);
460
+ if (!extended) {
461
+ stopHeartbeatByKey(key);
462
+ return;
463
+ }
464
+ heartbeat.lock.expiresAt = Date.now() + heartbeat.ttlMs;
465
+ } catch {
466
+ } finally {
467
+ const current = heartbeats.get(key);
468
+ if (current === heartbeat) {
469
+ current.inFlight = false;
470
+ }
471
+ }
472
+ };
473
+ const startOrUpdateHeartbeat = (lock, ttlMs) => {
474
+ const key = heartbeatKey(lock);
475
+ const existing = heartbeats.get(key);
476
+ if (existing) {
477
+ existing.ttlMs = ttlMs;
478
+ return;
479
+ }
480
+ const timer = setInterval(() => {
481
+ void runHeartbeat(key);
482
+ }, ACTIVE_LOCK_HEARTBEAT_MS);
483
+ timer.unref?.();
484
+ heartbeats.set(key, {
485
+ inFlight: false,
486
+ lock,
487
+ startedAtMs: Date.now(),
488
+ timer,
489
+ ttlMs
490
+ });
491
+ };
420
492
  const acquireLock = async (threadId, ttlMs) => {
421
- const effectiveTtlMs = Math.max(ttlMs, MIN_LOCK_TTL_MS);
422
- return await base.acquireLock(threadId, effectiveTtlMs);
493
+ const effectiveTtlMs = effectiveLockTtlMs(ttlMs);
494
+ const lock = await base.acquireLock(threadId, effectiveTtlMs);
495
+ if (lock && shouldHeartbeatLock(ttlMs)) {
496
+ startOrUpdateHeartbeat(lock, effectiveTtlMs);
497
+ }
498
+ return lock;
423
499
  };
424
500
  return {
425
- appendToList: (key, value, options) => base.appendToList(key, value, options),
501
+ appendToList: (key, value, options2) => base.appendToList(key, value, options2),
426
502
  connect: () => base.connect(),
427
- disconnect: () => base.disconnect(),
503
+ disconnect: async () => {
504
+ stopAllHeartbeats();
505
+ await base.disconnect();
506
+ },
428
507
  subscribe: (threadId) => base.subscribe(threadId),
429
508
  unsubscribe: (threadId) => base.unsubscribe(threadId),
430
509
  isSubscribed: (threadId) => base.isSubscribed(threadId),
431
510
  acquireLock,
432
- releaseLock: (lock) => base.releaseLock(lock),
433
- extendLock: (lock, ttlMs) => base.extendLock(lock, Math.max(ttlMs, MIN_LOCK_TTL_MS)),
434
- forceReleaseLock: (threadId) => base.forceReleaseLock(threadId),
511
+ releaseLock: async (lock) => {
512
+ stopHeartbeat(lock);
513
+ await base.releaseLock(lock);
514
+ },
515
+ extendLock: async (lock, ttlMs) => {
516
+ const effectiveTtlMs = effectiveLockTtlMs(ttlMs);
517
+ const extended = await base.extendLock(lock, effectiveTtlMs);
518
+ if (extended) {
519
+ lock.expiresAt = Date.now() + effectiveTtlMs;
520
+ if (shouldHeartbeatLock(ttlMs)) {
521
+ startOrUpdateHeartbeat(lock, effectiveTtlMs);
522
+ } else {
523
+ stopHeartbeat(lock);
524
+ }
525
+ } else {
526
+ stopHeartbeat(lock);
527
+ }
528
+ return extended;
529
+ },
530
+ forceReleaseLock: async (threadId) => {
531
+ stopHeartbeatsForThread(threadId);
532
+ await base.forceReleaseLock(threadId);
533
+ },
435
534
  enqueue: (threadId, entry, maxSize) => base.enqueue(threadId, entry, maxSize),
436
535
  dequeue: (threadId) => base.dequeue(threadId),
437
536
  queueDepth: (threadId) => base.queueDepth(threadId),
@@ -444,9 +543,12 @@ function createQueuedStateAdapter(base) {
444
543
  }
445
544
  function createStateAdapter() {
446
545
  const config = getChatConfig();
546
+ const activeLockMaxAgeMs = config.bot.turnTimeoutMs + ACTIVE_LOCK_TTL_MS;
447
547
  if (config.state.adapter === "memory") {
448
548
  redisStateAdapter = void 0;
449
- return createQueuedStateAdapter(createMemoryState());
549
+ return createQueuedStateAdapter(createMemoryState(), {
550
+ activeLockMaxAgeMs
551
+ });
450
552
  }
451
553
  if (!config.state.redisUrl) {
452
554
  throw new Error("REDIS_URL is required for durable Slack thread state");
@@ -455,7 +557,9 @@ function createStateAdapter() {
455
557
  url: config.state.redisUrl
456
558
  });
457
559
  redisStateAdapter = redisState;
458
- return createQueuedStateAdapter(redisState);
560
+ return createQueuedStateAdapter(redisState, {
561
+ activeLockMaxAgeMs
562
+ });
459
563
  }
460
564
  function getStateAdapter() {
461
565
  if (!stateAdapter) {
@@ -1173,6 +1277,7 @@ export {
1173
1277
  getSlackClientId,
1174
1278
  getSlackClientSecret,
1175
1279
  getRuntimeMetadata,
1280
+ ACTIVE_LOCK_TTL_MS,
1176
1281
  getStateAdapter,
1177
1282
  disconnectStateAdapter,
1178
1283
  SANDBOX_WORKSPACE_ROOT,
@@ -2,10 +2,10 @@ import {
2
2
  getPluginForSkillPath,
3
3
  getPluginSkillRoots,
4
4
  logWarn
5
- } from "./chunk-Q3FDONU7.js";
5
+ } from "./chunk-YITDDLS3.js";
6
6
  import {
7
7
  skillRoots
8
- } from "./chunk-XPXD3FCE.js";
8
+ } from "./chunk-5LUISFEY.js";
9
9
 
10
10
  // src/chat/skills.ts
11
11
  import fs from "fs/promises";
@@ -3,8 +3,9 @@ import {
3
3
  } from "./chunk-Z3YD6NHK.js";
4
4
  import {
5
5
  discoverInstalledPluginPackageContent,
6
+ normalizePluginPackageNames,
6
7
  pluginRoots
7
- } from "./chunk-XPXD3FCE.js";
8
+ } from "./chunk-5LUISFEY.js";
8
9
 
9
10
  // src/chat/logging.ts
10
11
  import { AsyncLocalStorage } from "async_hooks";
@@ -2881,33 +2882,9 @@ function normalizePluginRoots(roots) {
2881
2882
  }
2882
2883
  return resolved;
2883
2884
  }
2884
- function getExtraPluginRoots() {
2885
- const raw = process.env.JUNIOR_EXTRA_PLUGIN_ROOTS?.trim();
2886
- if (!raw) {
2887
- return [];
2888
- }
2889
- if (raw.startsWith("[")) {
2890
- try {
2891
- const parsed = JSON.parse(raw);
2892
- if (Array.isArray(parsed)) {
2893
- return normalizePluginRoots(
2894
- parsed.filter((value) => typeof value === "string")
2895
- );
2896
- }
2897
- } catch {
2898
- return [];
2899
- }
2900
- }
2901
- return normalizePluginRoots(
2902
- raw.split(path2.delimiter).map((entry) => entry.trim()).filter((entry) => entry.length > 0)
2903
- );
2904
- }
2905
2885
  function getPluginCatalogSource() {
2906
- const packagedContent = discoverInstalledPluginPackageContent();
2907
- const localRoots = normalizePluginRoots([
2908
- ...pluginRoots(),
2909
- ...getExtraPluginRoots()
2910
- ]);
2886
+ const packagedContent = discoverConfiguredPluginPackageContent();
2887
+ const localRoots = normalizePluginRoots(pluginRoots());
2911
2888
  const manifestRoots = normalizePluginRoots([
2912
2889
  ...localRoots,
2913
2890
  ...packagedContent.manifestRoots
@@ -2924,6 +2901,29 @@ function getPluginCatalogSource() {
2924
2901
  })
2925
2902
  };
2926
2903
  }
2904
+ function normalizePluginConfig(config) {
2905
+ if (!config) {
2906
+ return void 0;
2907
+ }
2908
+ return {
2909
+ packages: normalizePluginPackageNames(config.packages),
2910
+ ...config.manifests ? { manifests: structuredClone(config.manifests) } : {}
2911
+ };
2912
+ }
2913
+ function clonePluginConfig(config) {
2914
+ if (!config) {
2915
+ return void 0;
2916
+ }
2917
+ return {
2918
+ packages: [...config.packages ?? []],
2919
+ ...config.manifests ? { manifests: structuredClone(config.manifests) } : {}
2920
+ };
2921
+ }
2922
+ function discoverConfiguredPluginPackageContent() {
2923
+ return discoverInstalledPluginPackageContent(process.cwd(), {
2924
+ packageNames: pluginConfig?.packages
2925
+ });
2926
+ }
2927
2927
  function buildLoadedPluginState(source) {
2928
2928
  const state = createLoadedPluginState(source.signature);
2929
2929
  for (const skillRoot of source.packagedSkillRoots) {
@@ -3037,7 +3037,12 @@ function ensurePluginsLoaded() {
3037
3037
  return state;
3038
3038
  }
3039
3039
  function setPluginConfig(config) {
3040
- pluginConfig = config;
3040
+ const previousConfig = clonePluginConfig(pluginConfig);
3041
+ pluginConfig = normalizePluginConfig(config);
3042
+ return previousConfig;
3043
+ }
3044
+ function getPluginPackageContent() {
3045
+ return discoverConfiguredPluginPackageContent();
3041
3046
  }
3042
3047
  function getPluginCatalogSignature() {
3043
3048
  return ensurePluginsLoaded().signature;
@@ -3208,6 +3213,7 @@ export {
3208
3213
  buildOAuthTokenRequest,
3209
3214
  parseOAuthTokenResponse,
3210
3215
  setPluginConfig,
3216
+ getPluginPackageContent,
3211
3217
  getPluginCatalogSignature,
3212
3218
  getPluginCapabilityProviders,
3213
3219
  getPluginProviders,
package/dist/cli/check.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  parseSkillFile
3
- } from "../chunk-ZNFNY53B.js";
3
+ } from "../chunk-QCHPJ4FD.js";
4
4
  import {
5
5
  parsePluginManifest
6
- } from "../chunk-Q3FDONU7.js";
6
+ } from "../chunk-YITDDLS3.js";
7
7
  import "../chunk-Z3YD6NHK.js";
8
- import "../chunk-XPXD3FCE.js";
8
+ import "../chunk-5LUISFEY.js";
9
9
  import "../chunk-2KG3PWR4.js";
10
10
 
11
11
  // src/cli/check.ts
package/dist/cli/init.js CHANGED
@@ -171,6 +171,7 @@ Operational context and domain knowledge for ${name}.
171
171
  path.join(target, ".env.example"),
172
172
  `SLACK_BOT_TOKEN=
173
173
  SLACK_SIGNING_SECRET=
174
+ JUNIOR_SECRET=
174
175
  JUNIOR_BOT_NAME=
175
176
  AI_MODEL=
176
177
  AI_FAST_MODEL=
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  disconnectStateAdapter,
3
3
  resolveRuntimeDependencySnapshot
4
- } from "../chunk-KCOKQLBF.js";
4
+ } from "../chunk-7WTXNEPF.js";
5
5
  import {
6
6
  getPluginProviders,
7
7
  getPluginRuntimeDependencies,
8
8
  getPluginRuntimePostinstall
9
- } from "../chunk-Q3FDONU7.js";
9
+ } from "../chunk-YITDDLS3.js";
10
10
  import "../chunk-Z3YD6NHK.js";
11
- import "../chunk-XPXD3FCE.js";
11
+ import "../chunk-5LUISFEY.js";
12
12
  import "../chunk-2KG3PWR4.js";
13
13
 
14
14
  // src/cli/snapshot-warmup.ts
@@ -0,0 +1,2 @@
1
+ /** Serve an HTML diagnostics dashboard showing health, plugins, and skills. */
2
+ export declare function GET(): Promise<Response>;
@@ -0,0 +1,2 @@
1
+ /** Return a runtime discovery snapshot for built-app diagnostics. */
2
+ export declare function GET(): Promise<Response>;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Returns a minimal JSON health response for runtime health checks.
3
+ */
4
+ export declare function GET(): Response;
@@ -0,0 +1,2 @@
1
+ import type { WaitUntilFn } from "@/handlers/types";
2
+ export declare function GET(request: Request, provider: string, waitUntil: WaitUntilFn): Promise<Response>;
@@ -0,0 +1,2 @@
1
+ import type { WaitUntilFn } from "@/handlers/types";
2
+ export declare function GET(request: Request, provider: string, waitUntil: WaitUntilFn): Promise<Response>;
@@ -0,0 +1,2 @@
1
+ /** Build a simple centered HTML callback page. Callers must pre-escape dynamic strings. */
2
+ export declare function htmlCallbackResponse(title: string, message: string, status: number): Response;