@sentry/junior 0.179.0 → 0.181.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 (137) hide show
  1. package/dist/{agent-hooks-32IDCLMW.js → agent-hooks-IQUW6ERD.js} +16 -18
  2. package/dist/api/schema/workspace.d.ts +2 -0
  3. package/dist/api/schema.js +1 -2
  4. package/dist/api.js +202 -199
  5. package/dist/app.d.ts +4 -0
  6. package/dist/app.js +300 -1259
  7. package/dist/catalog-runtime-PMQWNIXA.js +14 -0
  8. package/dist/chat/agent/sandbox.d.ts +0 -2
  9. package/dist/chat/api-turns/routing.d.ts +4 -0
  10. package/dist/chat/api-turns/work.d.ts +5 -0
  11. package/dist/chat/config.d.ts +5 -2
  12. package/dist/chat/configuration/defaults.d.ts +1 -1
  13. package/dist/chat/conversations/projection.d.ts +6 -4
  14. package/dist/chat/ingress/message-router.d.ts +3 -0
  15. package/dist/chat/model-profile.d.ts +8 -10
  16. package/dist/chat/pi/conversation-events.d.ts +3 -2
  17. package/dist/chat/plugins/agent-hooks.d.ts +1 -1
  18. package/dist/chat/plugins/task-queue.d.ts +40 -3
  19. package/dist/chat/plugins/task-runner.d.ts +1 -1
  20. package/dist/chat/queue/callback.d.ts +26 -0
  21. package/dist/chat/queue/sign.d.ts +30 -0
  22. package/dist/chat/sandbox/sandbox.d.ts +0 -2
  23. package/dist/chat/sandbox/session.d.ts +0 -2
  24. package/dist/chat/sandbox/skill-sync.d.ts +1 -1
  25. package/dist/chat/sandbox/snapshot/events.d.ts +23 -0
  26. package/dist/chat/sandbox/snapshot/job-callback.d.ts +5 -0
  27. package/dist/chat/sandbox/snapshot/job-queue.d.ts +26 -0
  28. package/dist/chat/sandbox/snapshot/job-runner.d.ts +11 -0
  29. package/dist/chat/sandbox/snapshot/not-ready-error.d.ts +6 -0
  30. package/dist/chat/sandbox/snapshot/workspace.d.ts +9 -3
  31. package/dist/chat/services/turn-router.d.ts +4 -3
  32. package/dist/chat/services/turn-session-routing.d.ts +1 -0
  33. package/dist/chat/task-execution/queue-signing.d.ts +10 -21
  34. package/dist/chat/task-execution/state.d.ts +48 -0
  35. package/dist/chat/task-execution/store.d.ts +28 -2
  36. package/dist/chat/task-execution/worker.d.ts +4 -1
  37. package/dist/chat/tools/handoff/tool.d.ts +1 -1
  38. package/dist/chat/tools/types.d.ts +2 -0
  39. package/dist/chat/workspaces/types.d.ts +2 -0
  40. package/dist/{chunk-Q5B3WTGG.js → chunk-3KCQEG6W.js} +42 -41
  41. package/dist/{chunk-XZY6G5YZ.js → chunk-3KSSALN4.js} +180 -87
  42. package/dist/{chunk-3AFVR5UC.js → chunk-3X55QRAG.js} +18 -16
  43. package/dist/{chunk-SLGGOASN.js → chunk-4IX32NSL.js} +46 -46
  44. package/dist/{chunk-6ZWRNC4D.js → chunk-6Y5B5PEX.js} +1 -1
  45. package/dist/chunk-7H2VZTWN.js +103 -0
  46. package/dist/{chunk-CGA4ERJ5.js → chunk-CEMMLV5L.js} +1 -1
  47. package/dist/{chunk-FIANEE7Z.js → chunk-CM5HNV2W.js} +6 -6
  48. package/dist/{chunk-TKB25A3L.js → chunk-CZYNWPWD.js} +2 -1
  49. package/dist/{chunk-3I7XE3PA.js → chunk-D6ZD7VXP.js} +49 -38
  50. package/dist/chunk-DKIJ2RP5.js +68 -0
  51. package/dist/{chunk-G2CAC4CV.js → chunk-DSA6WTRP.js} +74 -68
  52. package/dist/{chunk-OOUNJNMR.js → chunk-DWPN6SCH.js} +1 -1
  53. package/dist/{chunk-HQNE5APD.js → chunk-EBMRB6Z6.js} +100 -79
  54. package/dist/{chunk-ZQMG3CL5.js → chunk-EM7EECT5.js} +16 -16
  55. package/dist/{chunk-XSPSCWLH.js → chunk-ETJTXYHY.js} +4 -4
  56. package/dist/{chunk-FTGD2FBP.js → chunk-EU7KJDOG.js} +2 -2
  57. package/dist/{chunk-CJLBLELR.js → chunk-FWILPBVQ.js} +8 -61
  58. package/dist/{chunk-4GWXAILB.js → chunk-GPA3ZSYY.js} +1 -1
  59. package/dist/{chunk-U4TKB6F6.js → chunk-GREV5PJK.js} +108 -5
  60. package/dist/{chunk-KJLHIHFF.js → chunk-GWFRPQNP.js} +43 -230
  61. package/dist/{chunk-YFNAMRGE.js → chunk-HEBMSITT.js} +1 -1
  62. package/dist/chunk-HJ27A6YB.js +218 -0
  63. package/dist/{chunk-R5NWWYIS.js → chunk-HZHUMCNV.js} +5 -5
  64. package/dist/{chunk-RTRBYSF3.js → chunk-IJ6SS4WB.js} +1 -1
  65. package/dist/{chunk-B6ECUSVX.js → chunk-IKKETMQC.js} +8 -8
  66. package/dist/{chunk-R6U7N4FS.js → chunk-KKSVCHDO.js} +10 -3
  67. package/dist/{chunk-JMJNFEDC.js → chunk-KMBU4PJP.js} +9 -54
  68. package/dist/chunk-KQZX24QQ.js +164 -0
  69. package/dist/{chunk-GPLAT6H7.js → chunk-LCNPXLE7.js} +22 -18
  70. package/dist/{chunk-2HIPYNQI.js → chunk-LG5MYY6U.js} +33 -32
  71. package/dist/chunk-LZOQFC5F.js +209 -0
  72. package/dist/chunk-M3QYTBQ6.js +55 -0
  73. package/dist/{chunk-M63DETLL.js → chunk-N7TMSOZH.js} +6 -6
  74. package/dist/{chunk-FIDMHAO6.js → chunk-NQTA72Q3.js} +84 -274
  75. package/dist/{chunk-RZRYOLCE.js → chunk-PBKZQAUA.js} +2315 -1150
  76. package/dist/chunk-PEQXYSSE.js +45 -0
  77. package/dist/{chunk-3TM3FYLQ.js → chunk-PL57B6NC.js} +1 -1
  78. package/dist/{chunk-JT4WMD3C.js → chunk-PPYDHUEL.js} +144 -218
  79. package/dist/{chunk-5IRROPA5.js → chunk-Q2KY27IX.js} +129 -31
  80. package/dist/{chunk-VP4OVRDD.js → chunk-RNMASWLP.js} +69 -73
  81. package/dist/{chunk-FAS6AIMF.js → chunk-TDT2R77B.js} +8 -8
  82. package/dist/{chunk-TIEKUH4Q.js → chunk-TJHSAHQN.js} +4 -3
  83. package/dist/{chunk-H4HBKISO.js → chunk-TXKUKMVO.js} +1 -1
  84. package/dist/chunk-X6GDDWQH.js +60 -0
  85. package/dist/{chunk-GENV6KF2.js → chunk-XYTJUHRZ.js} +108 -76
  86. package/dist/cli/chat.js +47 -43
  87. package/dist/cli/check.js +13 -15
  88. package/dist/cli/env.js +0 -1
  89. package/dist/cli/init.js +0 -1
  90. package/dist/cli/main.js +2 -3
  91. package/dist/cli/plugins.js +18 -20
  92. package/dist/cli/run.js +0 -1
  93. package/dist/cli/snapshot-create.js +14 -16
  94. package/dist/cli/upgrade.js +16 -18
  95. package/dist/{conversation-work-KATFHLG3.js → conversation-work-VIOQ5ZF3.js} +0 -2
  96. package/dist/db/schema/snapshots.d.ts +17 -0
  97. package/dist/db/schema.d.ts +17 -0
  98. package/dist/{db-EJAV7JL6.js → db-QNPVCQPT.js} +8 -10
  99. package/dist/deployment.d.ts +1 -0
  100. package/dist/{discovery-GUFTFBTL.js → discovery-DWVDM7UK.js} +1 -2
  101. package/dist/{experimental-XVDOSRBS.js → experimental-SIJSRDJD.js} +0 -1
  102. package/dist/instrumentation.js +7 -9
  103. package/dist/nitro.js +39 -13
  104. package/dist/{oauth-callback-server-GAVSUBTQ.js → oauth-callback-server-KYMPJOTC.js} +34 -32
  105. package/dist/{oauth-relay-3ZU72UGL.js → oauth-relay-5XPVRPYB.js} +0 -1
  106. package/dist/{plugins-HW4VWW6G.js → plugins-YTYJMMJF.js} +1 -2
  107. package/dist/{runner-34JL64JF.js → runner-3RS2D2ZR.js} +39 -33
  108. package/dist/{sandbox-egress-signals-DXOOBSBI.js → sandbox-egress-signals-FIL7EGPR.js} +5 -6
  109. package/dist/{sentry-JMWTS32N.js → sentry-MB3NL3IR.js} +1 -2
  110. package/dist/skills-5B3Y6XX6.js +27 -0
  111. package/dist/spawn-VYARS3DU.js +37 -0
  112. package/dist/task-runner-4IXKKZHL.js +32 -0
  113. package/dist/validation-Q65QD27B.js +17 -0
  114. package/dist/vercel.js +0 -1
  115. package/dist/version.js +1 -2
  116. package/dist/work-DCMQWAAP.js +45 -0
  117. package/dist/worker-QL3CHLZL.js +22 -0
  118. package/migrations/0035_workspace_snapshot_size_bytes.sql +2 -0
  119. package/migrations/meta/0035_snapshot.json +3048 -0
  120. package/migrations/meta/_journal.json +7 -0
  121. package/package.json +7 -6
  122. package/dist/catalog-runtime-FBVA6WAQ.js +0 -16
  123. package/dist/chat/plugins/task-callback.d.ts +0 -5
  124. package/dist/chat/plugins/task-message.d.ts +0 -23
  125. package/dist/chat/plugins/task-signing.d.ts +0 -31
  126. package/dist/chat/sandbox/snapshot/waiting-error.d.ts +0 -15
  127. package/dist/chat/services/workspace-snapshot-wait.d.ts +0 -27
  128. package/dist/chunk-5I6ORJUY.js +0 -127
  129. package/dist/chunk-6GWA276C.js +0 -72
  130. package/dist/chunk-MLKGABMK.js +0 -9
  131. package/dist/chunk-UT6X7XN7.js +0 -51
  132. package/dist/chunk-WR76IVA5.js +0 -130
  133. package/dist/skills-U545HALM.js +0 -29
  134. package/dist/spawn-I2S4IDUQ.js +0 -37
  135. package/dist/validation-EVXVGA44.js +0 -19
  136. package/dist/work-QOAUPDBU.js +0 -45
  137. package/dist/worker-5GX2IKLZ.js +0 -24
@@ -2,10 +2,10 @@ import {
2
2
  parseSlackChannelId,
3
3
  parseSlackMessageTs,
4
4
  parseSlackTeamId
5
- } from "./chunk-M63DETLL.js";
5
+ } from "./chunk-N7TMSOZH.js";
6
6
  import {
7
7
  toOptionalString
8
- } from "./chunk-HQNE5APD.js";
8
+ } from "./chunk-EBMRB6Z6.js";
9
9
 
10
10
  // src/chat/slack/context.ts
11
11
  import { z } from "zod";
@@ -45,12 +45,12 @@ function readSlackRawMessageContext(message) {
45
45
  const teamId = parseSlackTeamId(raw.data.team_id) ?? parseSlackTeamId(raw.data.team);
46
46
  const authorTeamId = parseSlackTeamId(raw.data.user_team);
47
47
  return {
48
- ...channelId ? { channelId } : {},
49
- ...threadTs ? { threadTs } : {},
50
- ...messageTs ? { messageTs } : {},
51
- ...nestedMessageTs ? { nestedMessageTs } : {},
52
- ...teamId ? { teamId } : {},
53
- ...authorTeamId ? { authorTeamId } : {}
48
+ ...channelId ? { channelId } : void 0,
49
+ ...threadTs ? { threadTs } : void 0,
50
+ ...messageTs ? { messageTs } : void 0,
51
+ ...nestedMessageTs ? { nestedMessageTs } : void 0,
52
+ ...teamId ? { teamId } : void 0,
53
+ ...authorTeamId ? { authorTeamId } : void 0
54
54
  };
55
55
  }
56
56
  function parseSlackThreadId(threadId) {
@@ -1,7 +1,7 @@
1
1
  // package.json
2
2
  var package_default = {
3
3
  name: "@sentry/junior",
4
- version: "0.179.0",
4
+ version: "0.181.0",
5
5
  private: false,
6
6
  publishConfig: {
7
7
  access: "public"
@@ -105,9 +105,10 @@ var package_default = {
105
105
  zod: "catalog:"
106
106
  },
107
107
  devDependencies: {
108
- "@hono/node-server": "1.19.14",
109
108
  "@emnapi/core": "^1.10.0",
110
109
  "@emnapi/runtime": "^1.10.0",
110
+ "@hono/node-server": "1.19.14",
111
+ "@oxlint/plugins": "1.79.0",
111
112
  "@sentry/junior-github": "workspace:*",
112
113
  "@sentry/junior-memory": "workspace:*",
113
114
  "@sentry/junior-testing": "workspace:*",
@@ -118,7 +119,7 @@ var package_default = {
118
119
  "drizzle-kit": "catalog:",
119
120
  msw: "^2.14.6",
120
121
  nitro: "3.0.260522-beta",
121
- oxlint: "^1.66.0",
122
+ oxlint: "^1.79.0",
122
123
  tsup: "^8.5.1",
123
124
  typescript: "^6.0.3",
124
125
  vercel: "^54.4.0",
@@ -112,7 +112,7 @@ function resolvePackageWithNode(cwd, packageName) {
112
112
  const nodeModulesDir = findPackageNodeModulesDir(dir, packageName);
113
113
  return {
114
114
  dir,
115
- ...nodeModulesDir ? { nodeModulesDir } : {}
115
+ ...nodeModulesDir ? { nodeModulesDir } : void 0
116
116
  };
117
117
  } catch {
118
118
  }
@@ -0,0 +1,60 @@
1
+ import {
2
+ QUEUE_SIGNATURE_MAX_AGE_MS,
3
+ createVercelQueueClient,
4
+ signQueueMessage,
5
+ verifyQueueMessage
6
+ } from "./chunk-7H2VZTWN.js";
7
+
8
+ // src/chat/sandbox/snapshot/job-queue.ts
9
+ import { createHash } from "crypto";
10
+ import { z } from "zod";
11
+ var SIGNATURE_CONTEXT = "junior.workspace_snapshot_queue.v1";
12
+ var SIGNATURE_VERSION = "v1";
13
+ var WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC = "junior_workspace_snapshots";
14
+ var workspaceSnapshotJobMessageSchema = z.object({
15
+ workspaceId: z.string().uuid(),
16
+ profileHash: z.string().min(1)
17
+ }).strict();
18
+ var workspaceSnapshotJobSign = {
19
+ context: SIGNATURE_CONTEXT,
20
+ schema: workspaceSnapshotJobMessageSchema,
21
+ signatureVersion: SIGNATURE_VERSION,
22
+ parts: (message) => [
23
+ message.workspaceId,
24
+ message.profileHash
25
+ ]
26
+ };
27
+ function jobId(message) {
28
+ const digest = createHash("sha256").update(message.workspaceId).update("\0").update(message.profileHash).digest("hex").slice(0, 32);
29
+ return `workspace-snapshot_${digest}`;
30
+ }
31
+ function signWorkspaceSnapshotJobMessage(message, nowMs = Date.now()) {
32
+ return signQueueMessage(workspaceSnapshotJobSign, message, nowMs);
33
+ }
34
+ function verifyWorkspaceSnapshotJobMessage(value, nowMs = Date.now()) {
35
+ return verifyQueueMessage(workspaceSnapshotJobSign, value, nowMs);
36
+ }
37
+ async function send(message, idempotencyKey) {
38
+ const options = {
39
+ retentionSeconds: QUEUE_SIGNATURE_MAX_AGE_MS / 1e3
40
+ };
41
+ if (idempotencyKey) options.idempotencyKey = idempotencyKey;
42
+ await createVercelQueueClient().send(
43
+ WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC,
44
+ signWorkspaceSnapshotJobMessage(message),
45
+ options
46
+ );
47
+ }
48
+ async function sendWorkspaceSnapshotJob(message) {
49
+ await send(message, jobId(message));
50
+ }
51
+ async function sendNextWorkspaceSnapshotJob(message) {
52
+ await send(message);
53
+ }
54
+
55
+ export {
56
+ WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC,
57
+ verifyWorkspaceSnapshotJobMessage,
58
+ sendWorkspaceSnapshotJob,
59
+ sendNextWorkspaceSnapshotJob
60
+ };
@@ -3,7 +3,7 @@ import {
3
3
  toCanonicalInputMessage,
4
4
  toCanonicalOutputMessage,
5
5
  toGenAiMessagesTraceAttributes
6
- } from "./chunk-XSPSCWLH.js";
6
+ } from "./chunk-ETJTXYHY.js";
7
7
  import {
8
8
  extractGenAiUsageAttributes,
9
9
  logException,
@@ -11,7 +11,7 @@ import {
11
11
  normalizeGenAiFinishReason,
12
12
  serializeGenAiAttribute,
13
13
  withSpan
14
- } from "./chunk-HQNE5APD.js";
14
+ } from "./chunk-EBMRB6Z6.js";
15
15
 
16
16
  // src/chat/services/provider-error.ts
17
17
  var ProviderError = class extends Error {
@@ -74,17 +74,17 @@ function providerMessage(error) {
74
74
  }
75
75
  function extractTransportKind(error, depth = 0) {
76
76
  if (!(error instanceof Error) || depth > 4) return void 0;
77
- const shaped = error;
78
- const code = typeof shaped.code === "string" ? shaped.code.toUpperCase() : void 0;
77
+ const providerError = error;
78
+ const code = typeof providerError.code === "string" ? providerError.code.toUpperCase() : void 0;
79
79
  if (code && TIMEOUT_ERROR_CODES.has(code)) return "timeout";
80
80
  if (code && NETWORK_ERROR_CODES.has(code)) return "network";
81
- return extractTransportKind(shaped.cause, depth + 1);
81
+ return extractTransportKind(providerError.cause, depth + 1);
82
82
  }
83
83
  function extractStatus(error, message) {
84
84
  if (error instanceof Error) {
85
- const shaped = error;
86
- if (typeof shaped.status === "number") return shaped.status;
87
- if (typeof shaped.statusCode === "number") return shaped.statusCode;
85
+ const providerError = error;
86
+ if (typeof providerError.status === "number") return providerError.status;
87
+ if (typeof providerError.statusCode === "number") return providerError.statusCode;
88
88
  }
89
89
  const match = message.match(
90
90
  /^(?:Error:\s*)?([45]\d\d)\b|\bstatus(?:Code)?["'=:\s]+([45]\d\d)\b/i
@@ -189,9 +189,9 @@ function getProviderErrorAttributes(error) {
189
189
  return {
190
190
  "app.ai.provider_error.kind": error.kind,
191
191
  "app.ai.provider_error.retryable": error.retryable,
192
- ...error.status !== void 0 ? { "app.ai.provider_error.status": error.status } : {},
193
- ...error.retryAfterMs !== void 0 ? { "app.ai.provider_error.retry_after_ms": error.retryAfterMs } : {},
194
- ...error.modelId ? { "gen_ai.request.model": error.modelId } : {}
192
+ ...error.status !== void 0 ? { "app.ai.provider_error.status": error.status } : void 0,
193
+ ...error.retryAfterMs !== void 0 ? { "app.ai.provider_error.retry_after_ms": error.retryAfterMs } : void 0,
194
+ ...error.modelId ? { "gen_ai.request.model": error.modelId } : void 0
195
195
  };
196
196
  }
197
197
 
@@ -385,21 +385,21 @@ async function completeText(params) {
385
385
  "gen_ai.operation.name": GEN_AI_OPERATION_CHAT,
386
386
  "gen_ai.request.model": params.modelId,
387
387
  "gen_ai.output.type": "text",
388
- ...params.promptName ? { "gen_ai.prompt.name": params.promptName } : {},
388
+ ...params.promptName ? { "gen_ai.prompt.name": params.promptName } : void 0,
389
389
  "server.address": GEN_AI_SERVER_ADDRESS,
390
390
  "server.port": GEN_AI_SERVER_PORT,
391
- ...hasCompactedConversationContext(params.messages) ? { "gen_ai.conversation.compacted": true } : {},
391
+ ...hasCompactedConversationContext(params.messages) ? { "gen_ai.conversation.compacted": true } : void 0,
392
392
  "app.conversation.privacy": effectivePrivacy,
393
- ...params.thinkingLevel ? { "gen_ai.request.reasoning.level": params.thinkingLevel } : {},
394
- ...params.temperature !== void 0 ? { "gen_ai.request.temperature": params.temperature } : {},
395
- ...params.maxTokens !== void 0 ? { "gen_ai.request.max_tokens": params.maxTokens } : {}
393
+ ...params.thinkingLevel ? { "gen_ai.request.reasoning.level": params.thinkingLevel } : void 0,
394
+ ...params.temperature !== void 0 ? { "gen_ai.request.temperature": params.temperature } : void 0,
395
+ ...params.maxTokens !== void 0 ? { "gen_ai.request.max_tokens": params.maxTokens } : void 0
396
396
  };
397
397
  const startAttributes = {
398
398
  ...baseAttributes,
399
399
  ...toGenAiMessagesTraceAttributes("gen_ai.input", params.messages),
400
- ...params.system ? { "gen_ai.system_instructions.content_chars": params.system.length } : {},
401
- ...systemInstructionsAttribute ? { "gen_ai.system_instructions": systemInstructionsAttribute } : {},
402
- ...requestMessagesAttribute ? { "gen_ai.input.messages": requestMessagesAttribute } : {},
400
+ ...params.system ? { "gen_ai.system_instructions.content_chars": params.system.length } : void 0,
401
+ ...systemInstructionsAttribute ? { "gen_ai.system_instructions": systemInstructionsAttribute } : void 0,
402
+ ...requestMessagesAttribute ? { "gen_ai.input.messages": requestMessagesAttribute } : void 0,
403
403
  "gen_ai.provider.auth_mode": authMode
404
404
  };
405
405
  return withSpan(
@@ -416,7 +416,7 @@ async function completeText(params) {
416
416
  messages: params.messages
417
417
  },
418
418
  {
419
- ...apiKey ? { apiKey } : {},
419
+ ...apiKey ? { apiKey } : void 0,
420
420
  temperature: params.temperature,
421
421
  maxTokens: params.maxTokens,
422
422
  reasoning: params.thinkingLevel,
@@ -440,14 +440,14 @@ async function completeText(params) {
440
440
  content: outputText ? [{ type: "text", text: outputText }] : []
441
441
  }
442
442
  ]),
443
- ...outputMessagesAttribute ? { "gen_ai.output.messages": outputMessagesAttribute } : {},
443
+ ...outputMessagesAttribute ? { "gen_ai.output.messages": outputMessagesAttribute } : void 0,
444
444
  ...usageAttributes,
445
445
  ...message.stopReason ? {
446
446
  "gen_ai.response.finish_reasons": [
447
447
  normalizeGenAiFinishReason(message.stopReason)
448
448
  ]
449
- } : {},
450
- ...message.model ? { "gen_ai.response.model": message.model } : {}
449
+ } : void 0,
450
+ ...message.model ? { "gen_ai.response.model": message.model } : void 0
451
451
  };
452
452
  setSpanAttributes(endAttributes);
453
453
  if (message.stopReason === "error") {
@@ -473,10 +473,10 @@ function logContextFromMetadata(modelId, metadata) {
473
473
  const runId = typeof metadata?.runId === "string" ? metadata.runId : void 0;
474
474
  return {
475
475
  modelId,
476
- ...conversationId ? { conversationId } : {},
477
- ...messageConversationId ? { messageConversationId } : {},
478
- ...destinationName ? { destinationName } : {},
479
- ...runId ? { runId } : {}
476
+ ...conversationId ? { conversationId } : void 0,
477
+ ...messageConversationId ? { messageConversationId } : void 0,
478
+ ...destinationName ? { destinationName } : void 0,
479
+ ...runId ? { runId } : void 0
480
480
  };
481
481
  }
482
482
  function objectCompletionCost(modelId, usage) {
@@ -491,7 +491,7 @@ function objectCompletionCost(modelId, usage) {
491
491
  output: usage.outputTokens ?? 0,
492
492
  cacheRead: cacheRead ?? 0,
493
493
  cacheWrite: cacheWrite ?? 0,
494
- ...usage.outputTokenDetails.reasoningTokens !== void 0 ? { reasoning: usage.outputTokenDetails.reasoningTokens } : {},
494
+ ...usage.outputTokenDetails.reasoningTokens !== void 0 ? { reasoning: usage.outputTokenDetails.reasoningTokens } : void 0,
495
495
  totalTokens: usage.totalTokens ?? (input ?? 0) + (usage.outputTokens ?? 0) + (cacheRead ?? 0) + (cacheWrite ?? 0),
496
496
  cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 }
497
497
  }).total;
@@ -523,17 +523,17 @@ async function completeObject(params) {
523
523
  model: provider.chat(params.modelId),
524
524
  schema: params.schema,
525
525
  prompt: params.prompt,
526
- ...params.system !== void 0 ? { system: params.system } : {},
527
- ...params.temperature !== void 0 ? { temperature: params.temperature } : {},
528
- ...params.maxTokens !== void 0 ? { maxOutputTokens: params.maxTokens } : {},
526
+ ...params.system !== void 0 ? { system: params.system } : void 0,
527
+ ...params.temperature !== void 0 ? { temperature: params.temperature } : void 0,
528
+ ...params.maxTokens !== void 0 ? { maxOutputTokens: params.maxTokens } : void 0,
529
529
  ...params.recordTelemetryPayloads === false ? {
530
530
  experimental_telemetry: {
531
531
  isEnabled: true,
532
532
  recordInputs: false,
533
533
  recordOutputs: false
534
534
  }
535
- } : {},
536
- ...params.signal !== void 0 ? { abortSignal: params.signal } : {}
535
+ } : void 0,
536
+ ...params.signal !== void 0 ? { abortSignal: params.signal } : void 0
537
537
  });
538
538
  setSpanAttributes({
539
539
  "gen_ai.response.finish_reasons": [result2.finishReason],
@@ -546,18 +546,18 @@ async function completeObject(params) {
546
546
  "gen_ai.operation.name": GEN_AI_OPERATION_CHAT,
547
547
  "gen_ai.request.model": params.modelId,
548
548
  "gen_ai.output.type": "json",
549
- ...params.promptName ? { "gen_ai.prompt.name": params.promptName } : {},
549
+ ...params.promptName ? { "gen_ai.prompt.name": params.promptName } : void 0,
550
550
  "server.address": GEN_AI_SERVER_ADDRESS,
551
551
  "server.port": GEN_AI_SERVER_PORT,
552
552
  "gen_ai.provider.auth_mode": credential?.mode ?? "api_key",
553
- ...params.thinkingLevel ? { "gen_ai.request.reasoning.level": params.thinkingLevel } : {},
554
- ...params.temperature !== void 0 ? { "gen_ai.request.temperature": params.temperature } : {},
555
- ...params.maxTokens !== void 0 ? { "gen_ai.request.max_tokens": params.maxTokens } : {}
553
+ ...params.thinkingLevel ? { "gen_ai.request.reasoning.level": params.thinkingLevel } : void 0,
554
+ ...params.temperature !== void 0 ? { "gen_ai.request.temperature": params.temperature } : void 0,
555
+ ...params.maxTokens !== void 0 ? { "gen_ai.request.max_tokens": params.maxTokens } : void 0
556
556
  }
557
557
  );
558
558
  } catch (error) {
559
559
  const providerError = createProviderError(error, {
560
- ...NoObjectGeneratedError.isInstance(error) ? { kind: "invalid_response" } : {},
560
+ ...NoObjectGeneratedError.isInstance(error) ? { kind: "invalid_response" } : void 0,
561
561
  modelId: params.modelId
562
562
  });
563
563
  throw providerError;
@@ -565,7 +565,7 @@ async function completeObject(params) {
565
565
  const costUsd = bestEffortObjectCompletionCost(params.modelId, result.usage);
566
566
  return {
567
567
  object: result.object,
568
- ...costUsd !== void 0 ? { costUsd } : {}
568
+ ...costUsd !== void 0 ? { costUsd } : void 0
569
569
  };
570
570
  }
571
571
  async function embedTexts(params) {
@@ -586,7 +586,7 @@ async function embedTexts(params) {
586
586
  const result2 = await embedMany({
587
587
  model: provider.embeddingModel(params.modelId),
588
588
  values: texts,
589
- ...params.signal !== void 0 ? { abortSignal: params.signal } : {}
589
+ ...params.signal !== void 0 ? { abortSignal: params.signal } : void 0
590
590
  });
591
591
  const dimensions = result2.embeddings[0]?.length;
592
592
  if (result2.embeddings.length !== texts.length || !dimensions || !result2.embeddings.every(
@@ -605,7 +605,7 @@ async function embedTexts(params) {
605
605
  "gen_ai.embeddings.dimension.count": dimensions,
606
606
  ...extractGenAiUsageAttributes({
607
607
  inputTokens: result2.usage.tokens,
608
- ...costUsd !== void 0 ? { cost: { input: costUsd, total: costUsd } } : {}
608
+ ...costUsd !== void 0 ? { cost: { input: costUsd, total: costUsd } } : void 0
609
609
  })
610
610
  });
611
611
  return { costUsd, dimensions, result: result2 };
@@ -620,7 +620,7 @@ async function embedTexts(params) {
620
620
  }
621
621
  );
622
622
  return {
623
- ...result.costUsd !== void 0 ? { costUsd: result.costUsd } : {},
623
+ ...result.costUsd !== void 0 ? { costUsd: result.costUsd } : void 0,
624
624
  dimensions: result.dimensions,
625
625
  model: params.modelId,
626
626
  provider: GEN_AI_PROVIDER_NAME,
@@ -668,8 +668,6 @@ function parseTurnReasoningLevel(value) {
668
668
 
669
669
  // src/chat/model-profile.ts
670
670
  import { z as z2 } from "zod";
671
- var STANDARD_MODEL_PROFILE = "standard";
672
- var DEFAULT_HANDOFF_MODEL_PROFILE = "handoff";
673
671
  var modelProfileSchema = z2.string().regex(/^[a-z][a-z0-9_-]*$/);
674
672
  var ModelProfileNotConfiguredError = class extends Error {
675
673
  constructor(profile) {
@@ -680,8 +678,8 @@ var ModelProfileNotConfiguredError = class extends Error {
680
678
  function modelIdForProfile(config, profile) {
681
679
  return profileConfig(config, profile).modelId;
682
680
  }
683
- function standardModelId(config) {
684
- return modelIdForProfile(config, STANDARD_MODEL_PROFILE);
681
+ function defaultModelId(config) {
682
+ return modelIdForProfile(config, config.defaultProfile);
685
683
  }
686
684
  function profileConfig(config, profile) {
687
685
  const profileConfig2 = Object.hasOwn(config.profiles, profile) ? config.profiles[profile] : void 0;
@@ -826,47 +824,49 @@ function validateGatewayModelId(raw) {
826
824
  function validateEmbeddingModelId(raw) {
827
825
  return toOptionalTrimmed(raw);
828
826
  }
829
- function parseProfiles(rawValue, standardModelId2, handoffModelId) {
830
- const profiles = {
831
- [STANDARD_MODEL_PROFILE]: { modelId: standardModelId2 },
832
- [DEFAULT_HANDOFF_MODEL_PROFILE]: {
833
- modelId: handoffModelId,
834
- reasoningLevel: "high"
835
- }
836
- };
837
- const trimmed = toOptionalTrimmed(rawValue);
838
- if (trimmed === void 0) {
839
- return profiles;
840
- }
841
- let parsed;
842
- try {
843
- parsed = JSON.parse(trimmed);
844
- } catch {
845
- throw new Error("AI_MODEL_PROFILES must be a JSON object");
827
+ function parseProfileMap(rawProfiles, configName) {
828
+ if (!rawProfiles || typeof rawProfiles !== "object" || Array.isArray(rawProfiles)) {
829
+ const objectType = configName === "AI_MODEL_PROFILES" ? "a JSON object" : "an object";
830
+ throw new Error(`${configName} must be ${objectType}`);
846
831
  }
847
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
848
- throw new Error("AI_MODEL_PROFILES must be a JSON object");
849
- }
850
- for (const [profile, rawModelId] of Object.entries(parsed)) {
832
+ const profiles = {};
833
+ for (const [profile, rawModelId] of Object.entries(rawProfiles)) {
851
834
  if (!modelProfileSchema.safeParse(profile).success) {
852
835
  throw new Error(
853
- `AI_MODEL_PROFILES profile "${profile}" must match ^[a-z][a-z0-9_-]*$`
836
+ `${configName} profile "${profile}" must match ^[a-z][a-z0-9_-]*$`
854
837
  );
855
838
  }
856
- if (profile === STANDARD_MODEL_PROFILE || profile === DEFAULT_HANDOFF_MODEL_PROFILE) {
857
- throw new Error(`AI_MODEL_PROFILES profile "${profile}" is reserved`);
858
- }
859
839
  if (typeof rawModelId !== "string") {
860
- throw new Error(`AI_MODEL_PROFILES.${profile} must be a model id string`);
840
+ throw new Error(`${configName}.${profile} must be a model id string`);
861
841
  }
862
842
  const modelId = validateGatewayModelId(rawModelId);
863
843
  if (!modelId) {
864
- throw new Error(`AI_MODEL_PROFILES.${profile} must not be empty`);
844
+ throw new Error(`${configName}.${profile} must not be empty`);
865
845
  }
866
846
  profiles[profile] = { modelId };
867
847
  }
868
848
  return profiles;
869
849
  }
850
+ function parseProfiles(rawValue, standardModelId, handoffModelId) {
851
+ const profiles = {
852
+ standard: { modelId: standardModelId },
853
+ handoff: { modelId: handoffModelId, reasoningLevel: "high" }
854
+ };
855
+ const trimmed = toOptionalTrimmed(rawValue);
856
+ if (trimmed === void 0) {
857
+ return profiles;
858
+ }
859
+ let parsed;
860
+ try {
861
+ parsed = JSON.parse(trimmed);
862
+ } catch {
863
+ throw new Error("AI_MODEL_PROFILES must be a JSON object");
864
+ }
865
+ return {
866
+ ...profiles,
867
+ ...parseProfileMap(parsed, "AI_MODEL_PROFILES")
868
+ };
869
+ }
870
870
  function parseReactionEmoji(envName, rawValue, defaultEmoji) {
871
871
  const trimmed = toOptionalTrimmed(rawValue);
872
872
  if (trimmed === void 0) {
@@ -880,7 +880,22 @@ function parseReactionEmoji(envName, rawValue, defaultEmoji) {
880
880
  }
881
881
  return normalized;
882
882
  }
883
+ function warnDeprecatedProfileEnv(env) {
884
+ for (const envName of [
885
+ "AI_MODEL",
886
+ "AI_HANDOFF_MODEL",
887
+ "AI_MODEL_PROFILES"
888
+ ]) {
889
+ if (toOptionalTrimmed(env[envName]) !== void 0) {
890
+ logWarn("config.profile_env.deprecated", {
891
+ "app.config.env_name": envName,
892
+ "app.config.replacement": "createApp({ defaultProfile, profiles })"
893
+ });
894
+ }
895
+ }
896
+ }
883
897
  function readBotConfig(env, functionMaxDurationSeconds) {
898
+ warnDeprecatedProfileEnv(env);
884
899
  const maxTurnTimeoutMs = resolveMaxTurnTimeoutMs(functionMaxDurationSeconds);
885
900
  const modelId = validateGatewayModelId(env.AI_MODEL) ?? DEFAULT_MODEL_ID;
886
901
  const reasoningLevel = toOptionalTrimmed(env.AI_REASONING_LEVEL);
@@ -889,6 +904,7 @@ function readBotConfig(env, functionMaxDurationSeconds) {
889
904
  const handoffModelId = validateGatewayModelId(env.AI_HANDOFF_MODEL) ?? DEFAULT_HANDOFF_MODEL_ID;
890
905
  return {
891
906
  userName: toOptionalTrimmed(env.JUNIOR_BOT_NAME) ?? "junior",
907
+ defaultProfile: "standard",
892
908
  crossActorMidRunMode: parseCrossActorMidRunMode(
893
909
  env.JUNIOR_CROSS_ACTOR_MID_RUN_MODE
894
910
  ),
@@ -1021,6 +1037,23 @@ function getRuntimeMetadata() {
1021
1037
  version: toOptionalTrimmed(process.env.VERCEL_GIT_COMMIT_SHA)
1022
1038
  };
1023
1039
  }
1040
+ function setProfiles(profiles, defaultProfile) {
1041
+ if (!profiles || !defaultProfile) {
1042
+ throw new Error("profiles and defaultProfile must be configured together");
1043
+ }
1044
+ const configuredProfiles = parseProfileMap(profiles, "profiles");
1045
+ const selectedDefault = defaultProfile;
1046
+ if (!modelProfileSchema.safeParse(selectedDefault).success) {
1047
+ throw new Error(
1048
+ `defaultProfile "${selectedDefault}" must match ^[a-z][a-z0-9_-]*$`
1049
+ );
1050
+ }
1051
+ if (!Object.hasOwn(configuredProfiles, selectedDefault)) {
1052
+ throw new Error(`defaultProfile "${selectedDefault}" is not configured`);
1053
+ }
1054
+ botConfig.profiles = configuredProfiles;
1055
+ botConfig.defaultProfile = selectedDefault;
1056
+ }
1024
1057
  function getSlackReactionConfig() {
1025
1058
  return {
1026
1059
  completedReactionEmoji: chatConfig.slack.completedReactionEmoji,
@@ -1072,12 +1105,10 @@ export {
1072
1105
  embedTexts,
1073
1106
  normalizeSlackEmojiName,
1074
1107
  TURN_REASONING_LEVELS,
1075
- STANDARD_MODEL_PROFILE,
1076
- DEFAULT_HANDOFF_MODEL_PROFILE,
1077
1108
  modelProfileSchema,
1078
1109
  ModelProfileNotConfiguredError,
1079
1110
  modelIdForProfile,
1080
- standardModelId,
1111
+ defaultModelId,
1081
1112
  profileConfig,
1082
1113
  DEFAULT_SQL_STATEMENT_TIMEOUT_MS,
1083
1114
  FUNCTION_TIMEOUT_BUFFER_SECONDS,
@@ -1089,6 +1120,7 @@ export {
1089
1120
  getSlackClientId,
1090
1121
  getSlackClientSecret,
1091
1122
  getRuntimeMetadata,
1123
+ setProfiles,
1092
1124
  getSlackReactionConfig,
1093
1125
  setSlackReactionConfig
1094
1126
  };
package/dist/cli/chat.js CHANGED
@@ -1,46 +1,50 @@
1
1
  import {
2
2
  executeAgentRun
3
- } from "../chunk-RZRYOLCE.js";
4
- import "../chunk-3AFVR5UC.js";
3
+ } from "../chunk-PBKZQAUA.js";
4
+ import "../chunk-3X55QRAG.js";
5
+ import "../chunk-6Y5B5PEX.js";
5
6
  import "../chunk-DIB4GX3G.js";
6
7
  import {
7
8
  createAgentRunner
8
- } from "../chunk-Q5B3WTGG.js";
9
- import "../chunk-4GWXAILB.js";
9
+ } from "../chunk-3KCQEG6W.js";
10
10
  import "../chunk-RF6J3DIO.js";
11
- import "../chunk-2HIPYNQI.js";
12
- import "../chunk-6ZWRNC4D.js";
11
+ import "../chunk-LG5MYY6U.js";
13
12
  import "../chunk-VRS6WDK5.js";
14
- import "../chunk-XZY6G5YZ.js";
15
- import "../chunk-FAS6AIMF.js";
16
- import "../chunk-FIDMHAO6.js";
17
- import "../chunk-B6ECUSVX.js";
13
+ import "../chunk-3KSSALN4.js";
14
+ import "../chunk-TDT2R77B.js";
15
+ import "../chunk-Q2KY27IX.js";
16
+ import "../chunk-HJ27A6YB.js";
17
+ import "../chunk-NQTA72Q3.js";
18
+ import "../chunk-IKKETMQC.js";
18
19
  import "../chunk-PDO5BLNM.js";
19
20
  import "../chunk-UIE3R5XU.js";
21
+ import "../chunk-X6GDDWQH.js";
22
+ import "../chunk-DKIJ2RP5.js";
23
+ import "../chunk-JAL3CH4G.js";
24
+ import "../chunk-7H2VZTWN.js";
25
+ import "../chunk-GPA3ZSYY.js";
20
26
  import {
21
27
  loadAppPluginSet
22
28
  } from "../chunk-Y2CM7HXH.js";
23
- import "../chunk-3I7XE3PA.js";
29
+ import "../chunk-D6ZD7VXP.js";
24
30
  import "../chunk-3Y47VMHV.js";
25
- import "../chunk-VP4OVRDD.js";
26
- import "../chunk-R6U7N4FS.js";
27
- import "../chunk-JMJNFEDC.js";
28
- import "../chunk-3TM3FYLQ.js";
29
- import "../chunk-GENV6KF2.js";
31
+ import "../chunk-RNMASWLP.js";
32
+ import "../chunk-KKSVCHDO.js";
33
+ import "../chunk-KMBU4PJP.js";
34
+ import "../chunk-PL57B6NC.js";
30
35
  import "../chunk-VFUK3X5B.js";
31
- import "../chunk-XSPSCWLH.js";
32
- import "../chunk-ZQMG3CL5.js";
33
- import "../chunk-YFNAMRGE.js";
34
- import "../chunk-SLGGOASN.js";
35
- import "../chunk-CGA4ERJ5.js";
36
- import "../chunk-M63DETLL.js";
37
- import "../chunk-HQNE5APD.js";
38
- import "../chunk-6GWA276C.js";
39
- import "../chunk-OOUNJNMR.js";
40
- import "../chunk-H4HBKISO.js";
41
- import "../chunk-UT6X7XN7.js";
42
- import "../chunk-TIEKUH4Q.js";
43
- import "../chunk-MLKGABMK.js";
36
+ import "../chunk-XYTJUHRZ.js";
37
+ import "../chunk-ETJTXYHY.js";
38
+ import "../chunk-EM7EECT5.js";
39
+ import "../chunk-HEBMSITT.js";
40
+ import "../chunk-4IX32NSL.js";
41
+ import "../chunk-CEMMLV5L.js";
42
+ import "../chunk-N7TMSOZH.js";
43
+ import "../chunk-DWPN6SCH.js";
44
+ import "../chunk-TXKUKMVO.js";
45
+ import "../chunk-EBMRB6Z6.js";
46
+ import "../chunk-PEQXYSSE.js";
47
+ import "../chunk-TJHSAHQN.js";
44
48
 
45
49
  // src/cli/chat.ts
46
50
  import {
@@ -161,11 +165,11 @@ async function configureLocalChatPlugins(pluginSet) {
161
165
  validationModule,
162
166
  databaseModule
163
167
  ] = await Promise.all([
164
- import("../plugins-HW4VWW6G.js"),
165
- import("../agent-hooks-32IDCLMW.js"),
166
- import("../catalog-runtime-FBVA6WAQ.js"),
167
- import("../validation-EVXVGA44.js"),
168
- import("../db-EJAV7JL6.js")
168
+ import("../plugins-YTYJMMJF.js"),
169
+ import("../agent-hooks-IQUW6ERD.js"),
170
+ import("../catalog-runtime-PMQWNIXA.js"),
171
+ import("../validation-Q65QD27B.js"),
172
+ import("../db-QNPVCQPT.js")
169
173
  ]);
170
174
  const resolvedPluginSet = pluginSet === void 0 ? await loadLocalPluginSet() : pluginSet ?? void 0;
171
175
  const plugins = pluginsModule.pluginRuntimeRegistrationsFromPluginSet(resolvedPluginSet);
@@ -229,16 +233,16 @@ function localDevServerUrl() {
229
233
  async function prepareLocalChatRun(io, pluginSet) {
230
234
  defaultStateAdapterForLocalChat();
231
235
  await configureLocalChatPlugins(pluginSet);
232
- const { setExperimentalFeatures } = await import("../experimental-XVDOSRBS.js");
236
+ const { setExperimentalFeatures } = await import("../experimental-SIJSRDJD.js");
233
237
  setExperimentalFeatures({ subagents: true });
234
- const { runLocalAgentTurn } = await import("../runner-34JL64JF.js");
235
- const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-GAVSUBTQ.js");
236
- const { createLocalOAuthState } = await import("../oauth-relay-3ZU72UGL.js");
237
- const { createLocalSandboxEgressSignalTransport } = await import("../sandbox-egress-signals-DXOOBSBI.js");
238
- const { bindSpawnAgent } = await import("../spawn-I2S4IDUQ.js");
239
- const { createAgentInvocationWorker, routeAgentInvocationWork } = await import("../work-QOAUPDBU.js");
240
- const { createLocalConversationWork } = await import("../conversation-work-KATFHLG3.js");
241
- const { processConversationWork } = await import("../worker-5GX2IKLZ.js");
238
+ const { runLocalAgentTurn } = await import("../runner-3RS2D2ZR.js");
239
+ const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-KYMPJOTC.js");
240
+ const { createLocalOAuthState } = await import("../oauth-relay-5XPVRPYB.js");
241
+ const { createLocalSandboxEgressSignalTransport } = await import("../sandbox-egress-signals-FIL7EGPR.js");
242
+ const { bindSpawnAgent } = await import("../spawn-VYARS3DU.js");
243
+ const { createAgentInvocationWorker, routeAgentInvocationWork } = await import("../work-DCMQWAAP.js");
244
+ const { createLocalConversationWork } = await import("../conversation-work-VIOQ5ZF3.js");
245
+ const { processConversationWork } = await import("../worker-QL3CHLZL.js");
242
246
  let agentRunner;
243
247
  const localConversationWork = createLocalConversationWork(async (message) => {
244
248
  if (!agentRunner) {