@sentry/junior 0.99.0 → 0.100.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 (79) hide show
  1. package/dist/{agent-hooks-OSW6C3CJ.js → agent-hooks-V6KU7PQN.js} +6 -5
  2. package/dist/api/activity.d.ts +14 -0
  3. package/dist/api/conversations/aggregate.d.ts +16 -0
  4. package/dist/api/conversations/detail-projection.d.ts +1 -0
  5. package/dist/api/conversations/list.query.d.ts +3 -0
  6. package/dist/api/conversations/projection.d.ts +1 -0
  7. package/dist/api/conversations/reporting.d.ts +42 -0
  8. package/dist/api/conversations/schema.d.ts +7 -7
  9. package/dist/api/conversations/stats.query.d.ts +1 -1
  10. package/dist/api/locations/detail.d.ts +81 -0
  11. package/dist/api/locations/list.d.ts +30 -0
  12. package/dist/api/locations/query.d.ts +5 -0
  13. package/dist/api/locations/schema.d.ts +175 -0
  14. package/dist/api/people/list.query.d.ts +1 -1
  15. package/dist/api/people/profile.query.d.ts +1 -1
  16. package/dist/api/people/schema.d.ts +10 -14
  17. package/dist/api/people/shared.d.ts +38 -78
  18. package/dist/api/schema.d.ts +8 -0
  19. package/dist/api/schema.js +14 -3
  20. package/dist/api.js +24 -11
  21. package/dist/app.js +25 -19
  22. package/dist/chat/agent/request.d.ts +3 -0
  23. package/dist/chat/config.d.ts +2 -0
  24. package/dist/chat/reasoning-level.d.ts +4 -0
  25. package/dist/chat/services/{turn-thinking-level.d.ts → turn-reasoning-level.d.ts} +11 -10
  26. package/dist/chat/services/turn-result.d.ts +3 -3
  27. package/dist/chat/tools/search-tools.d.ts +2 -2
  28. package/dist/{chunk-T55RBE4Z.js → chunk-2RNOB32R.js} +3 -1
  29. package/dist/{chunk-NJEDJFK4.js → chunk-2T7DCRAW.js} +1 -1
  30. package/dist/{chunk-PYK7R5A7.js → chunk-45DMFMY2.js} +66 -65
  31. package/dist/chunk-4AQUWWEM.js +75 -0
  32. package/dist/{chunk-EEZCY5WX.js → chunk-A7X2FDUO.js} +18 -2
  33. package/dist/{chunk-WTYEKPXU.js → chunk-FP5N5OWZ.js} +1 -1
  34. package/dist/chunk-FXFQNHRU.js +48 -0
  35. package/dist/chunk-GEUUJRQF.js +102 -0
  36. package/dist/{chunk-CRQVIHDI.js → chunk-IDZBM3NW.js} +2 -8
  37. package/dist/{chunk-DHHU2WSG.js → chunk-IQIBZXGB.js} +2 -2
  38. package/dist/{chunk-OL6XQ23W.js → chunk-IVXL57YF.js} +3 -3
  39. package/dist/{chunk-IO65E4ZD.js → chunk-JPQISMMJ.js} +3 -3
  40. package/dist/{chunk-KFUSLFLL.js → chunk-JSAANELJ.js} +11 -4
  41. package/dist/{chunk-EUZ44ROE.js → chunk-MM5UFDAC.js} +1 -3
  42. package/dist/{chunk-WJ7STXT6.js → chunk-NSOCZGOH.js} +3 -3
  43. package/dist/chunk-PGGEOCQY.js +77 -0
  44. package/dist/{chunk-EOWXRY5E.js → chunk-PWC24W5F.js} +1 -1
  45. package/dist/chunk-QOZOJNSE.js +96 -0
  46. package/dist/chunk-QSBQJ3PA.js +275 -0
  47. package/dist/{chunk-FTTFV6DC.js → chunk-TPTJEHUE.js} +4 -4
  48. package/dist/{chunk-OGHXZ4KQ.js → chunk-VHRM6GNH.js} +88 -122
  49. package/dist/{chunk-NG2AV7IB.js → chunk-VVIXK2BX.js} +1 -1
  50. package/dist/{chunk-ZZUBLPXD.js → chunk-VY7BT4SM.js} +5 -4
  51. package/dist/{chunk-H66UCBPW.js → chunk-XJA7BPHS.js} +1 -1
  52. package/dist/{chunk-ER45IV77.js → chunk-XSBIISXS.js} +9 -9
  53. package/dist/cli/chat.js +15 -14
  54. package/dist/cli/plugins.js +6 -5
  55. package/dist/cli/snapshot-warmup.js +2 -2
  56. package/dist/cli/upgrade.js +8 -7
  57. package/dist/db/schema/conversations.d.ts +17 -0
  58. package/dist/db/schema/destinations.d.ts +12 -3
  59. package/dist/db/schema.d.ts +19 -2
  60. package/dist/{db-GFSCDAHS.js → db-RCZB7KNM.js} +3 -2
  61. package/dist/detail-5SLCGT6J.js +29 -0
  62. package/dist/{detail-Q4IVDNGS.js → detail-LU6COZO6.js} +11 -10
  63. package/dist/{legacy-import-6WWXMALY.js → legacy-import-VCYLWT2V.js} +4 -3
  64. package/dist/list-2FI5SFV7.js +80 -0
  65. package/dist/list-4ALSU6ZW.js +30 -0
  66. package/dist/{list-A3F5JDYV.js → list-KHRAWZWU.js} +7 -6
  67. package/dist/{plugin-conversations-PDCQWU3O.js → plugin-conversations-JANXC4GA.js} +6 -5
  68. package/dist/profile-3O3OVENT.js +212 -0
  69. package/dist/{runner-267ZRLZD.js → runner-BM7D35YW.js} +12 -11
  70. package/dist/stats-J3YGCYDF.js +174 -0
  71. package/dist/{subagent-UN3MP6LV.js → subagent-P7HOSMVC.js} +10 -9
  72. package/migrations/0003_peaceful_scalphunter.sql +4 -0
  73. package/migrations/meta/0003_snapshot.json +1035 -0
  74. package/migrations/meta/_journal.json +8 -1
  75. package/package.json +5 -5
  76. package/dist/chunk-CV22LUIV.js +0 -261
  77. package/dist/list-M5BRWW3D.js +0 -92
  78. package/dist/profile-UEIRSVT3.js +0 -146
  79. package/dist/stats-L62E4O4U.js +0 -207
@@ -10,14 +10,14 @@ import {
10
10
  persistRunningSessionRecord,
11
11
  persistTimeoutSessionRecord,
12
12
  persistYieldSessionRecord
13
- } from "./chunk-WJ7STXT6.js";
13
+ } from "./chunk-NSOCZGOH.js";
14
14
  import {
15
15
  JUNIOR_THREAD_STATE_TTL_MS
16
16
  } from "./chunk-6DTVCPLO.js";
17
17
  import {
18
18
  addAgentTurnUsage,
19
19
  hasAgentTurnUsage
20
- } from "./chunk-OL6XQ23W.js";
20
+ } from "./chunk-IVXL57YF.js";
21
21
  import {
22
22
  loadConnectedMcpProviders,
23
23
  loadConversationProjection,
@@ -25,12 +25,12 @@ import {
25
25
  recordAuthorizationRequested,
26
26
  recordMcpProviderConnected,
27
27
  recordToolExecutionStarted
28
- } from "./chunk-DHHU2WSG.js";
28
+ } from "./chunk-IQIBZXGB.js";
29
29
  import {
30
30
  estimateTextTokens,
31
31
  getAgentContextCompactionTriggerTokens,
32
32
  updateConversationStats
33
- } from "./chunk-IO65E4ZD.js";
33
+ } from "./chunk-JPQISMMJ.js";
34
34
  import {
35
35
  buildNonInteractiveShellScript,
36
36
  createSandboxInstance,
@@ -40,7 +40,7 @@ import {
40
40
  isSnapshotMissingError,
41
41
  resolveRuntimeDependencySnapshot,
42
42
  runNonInteractiveCommand
43
- } from "./chunk-H66UCBPW.js";
43
+ } from "./chunk-XJA7BPHS.js";
44
44
  import {
45
45
  privateTraceResultAttributes
46
46
  } from "./chunk-CM5EZD5F.js";
@@ -52,7 +52,7 @@ import {
52
52
  getPlugins,
53
53
  getSlackToolContext,
54
54
  resolveChannelCapabilities
55
- } from "./chunk-FTTFV6DC.js";
55
+ } from "./chunk-TPTJEHUE.js";
56
56
  import {
57
57
  SlackActionError,
58
58
  downloadPrivateSlackFile,
@@ -62,10 +62,10 @@ import {
62
62
  isDmChannel,
63
63
  normalizeSlackConversationId,
64
64
  withSlackRetries
65
- } from "./chunk-WTYEKPXU.js";
65
+ } from "./chunk-FP5N5OWZ.js";
66
66
  import {
67
67
  createPluginLogger
68
- } from "./chunk-EOWXRY5E.js";
68
+ } from "./chunk-PWC24W5F.js";
69
69
  import {
70
70
  contextProvenance,
71
71
  getAgentStepStore,
@@ -74,7 +74,7 @@ import {
74
74
  getDb,
75
75
  instructionActors,
76
76
  instructionProvenanceFor
77
- } from "./chunk-OGHXZ4KQ.js";
77
+ } from "./chunk-VHRM6GNH.js";
78
78
  import {
79
79
  SANDBOX_DATA_ROOT,
80
80
  SANDBOX_SKILLS_ROOT,
@@ -94,6 +94,7 @@ import {
94
94
  ModelProfileNotConfiguredError,
95
95
  STANDARD_MODEL_PROFILE,
96
96
  TURN_CONTEXT_TAG,
97
+ TURN_REASONING_LEVELS,
97
98
  acquireActiveLock,
98
99
  botConfig,
99
100
  completeObject,
@@ -119,7 +120,7 @@ import {
119
120
  stripRuntimeTurnContext,
120
121
  trimTrailingAssistantMessages,
121
122
  unwrapCurrentInstruction
122
- } from "./chunk-EEZCY5WX.js";
123
+ } from "./chunk-A7X2FDUO.js";
123
124
  import {
124
125
  parseSlackThreadId,
125
126
  resolveConversationPrivacy,
@@ -687,7 +688,7 @@ function buildTurnResult(input) {
687
688
  shouldTrace,
688
689
  spanContext,
689
690
  usage,
690
- thinkingSelection,
691
+ reasoningSelection,
691
692
  correlation,
692
693
  assistantUserName,
693
694
  modelId
@@ -817,7 +818,7 @@ function buildTurnResult(input) {
817
818
  outcome: resolvedOutcome,
818
819
  modelId,
819
820
  assistantMessageCount: assistantMessages.length,
820
- thinkingLevel: thinkingSelection.thinkingLevel,
821
+ reasoningLevel: reasoningSelection.reasoningLevel,
821
822
  toolCalls,
822
823
  toolResultCount: toolResults.length,
823
824
  toolErrorCount,
@@ -840,20 +841,13 @@ function buildTurnResult(input) {
840
841
  };
841
842
  }
842
843
 
843
- // src/chat/services/turn-thinking-level.ts
844
+ // src/chat/services/turn-reasoning-level.ts
844
845
  import { z } from "zod";
845
846
  var CLASSIFIER_CONFIDENCE_THRESHOLD = 0.75;
846
847
  var MAX_ROUTER_CONTEXT_CHARS = 8e3;
847
848
  var ROUTER_CONTEXT_HEAD_CHARS = 3e3;
848
849
  var ROUTER_CONTEXT_TAIL_CHARS = 5e3;
849
850
  var TRUNCATION_MARKER = "\n\u2026[truncated]\u2026\n";
850
- var TURN_THINKING_LEVELS = [
851
- "none",
852
- "low",
853
- "medium",
854
- "high",
855
- "xhigh"
856
- ];
857
851
  var CONFIDENCE_LABELS = {
858
852
  low: 0.5,
859
853
  medium: CLASSIFIER_CONFIDENCE_THRESHOLD,
@@ -874,15 +868,15 @@ function coerceClassifierConfidence(value) {
874
868
  return CONFIDENCE_LABELS[trimmed] ?? value;
875
869
  }
876
870
  var turnExecutionProfileSchema = z.object({
877
- thinking_level: z.enum(TURN_THINKING_LEVELS),
871
+ reasoning_level: z.enum(TURN_REASONING_LEVELS),
878
872
  confidence: z.preprocess(
879
873
  coerceClassifierConfidence,
880
874
  z.number().min(0).max(1)
881
875
  ),
882
876
  reason: z.string().min(1)
883
877
  });
884
- var DEFAULT_THINKING_LEVEL = "medium";
885
- var THINKING_LEVEL_RANK = {
878
+ var CLASSIFIER_FALLBACK_REASONING_LEVEL = "medium";
879
+ var REASONING_LEVEL_RANK = {
886
880
  none: 0,
887
881
  low: 1,
888
882
  medium: 2,
@@ -911,7 +905,7 @@ function trimContextForRouter(text) {
911
905
  }
912
906
  function buildClassifierSystemPrompt() {
913
907
  return [
914
- "You route assistant turns to the thinking level most likely to produce a complete, source-grounded answer.",
908
+ "You route assistant turns to the reasoning level most likely to produce a complete, source-grounded answer.",
915
909
  "Choose exactly one bucket: none, low, medium, high, or xhigh.",
916
910
  "",
917
911
  "Use none only for greetings, acknowledgments, and turns that need no substantive assistant work.",
@@ -923,7 +917,7 @@ function buildClassifierSystemPrompt() {
923
917
  "",
924
918
  "Classify based on the substance of the task, not the length of the current message. When the current instruction is a short affirmation (for example: 'go', 'do it', 'yes please', 'proceed') and prior thread context contains a pending task, classify the pending task \u2014 not the affirmation.",
925
919
  "",
926
- "Return JSON only with thinking_level, confidence, and reason.",
920
+ "Return JSON only with reasoning_level, confidence, and reason.",
927
921
  "confidence must be a number from 0 to 1, not a word label."
928
922
  ].join("\n");
929
923
  }
@@ -952,7 +946,13 @@ function buildClassifierPrompt(args) {
952
946
  }
953
947
  return sections.join("\n");
954
948
  }
955
- async function selectTurnThinkingLevel(args) {
949
+ function configuredTurnReasoningLevel(reasoningLevel, source) {
950
+ return {
951
+ reasoningLevel,
952
+ reason: `configured:${source}`
953
+ };
954
+ }
955
+ async function selectTurnReasoningLevel(args) {
956
956
  const trimmedContext = trimContextForRouter(args.conversationContext);
957
957
  const instructionLength = args.messageText.trim().length;
958
958
  const turnBlockCount = (args.currentTurnBlocks ?? []).filter(
@@ -971,8 +971,8 @@ async function selectTurnThinkingLevel(args) {
971
971
  modelId: args.fastModelId
972
972
  };
973
973
  return withSpan(
974
- "chat.route_thinking",
975
- "chat.route_thinking",
974
+ "chat.route_reasoning",
975
+ "chat.route_reasoning",
976
976
  logContext,
977
977
  async () => {
978
978
  setSpanAttributes({
@@ -994,29 +994,29 @@ async function selectTurnThinkingLevel(args) {
994
994
  },
995
995
  prompt
996
996
  });
997
- const normalizedSelection = applyThinkingFloor(selection, {
997
+ const normalizedSelection = applyReasoningFloor(selection, {
998
998
  minimum: trimmedContext || turnBlockCount > 0 ? "medium" : void 0
999
999
  });
1000
1000
  setSpanAttributes({
1001
- "app.ai.thinking_level": normalizedSelection.thinkingLevel,
1002
- "app.ai.thinking_level_reason": normalizedSelection.reason,
1001
+ "app.ai.reasoning_level": normalizedSelection.reasoningLevel,
1002
+ "app.ai.reasoning_level_reason": normalizedSelection.reason,
1003
1003
  ...normalizedSelection.confidence !== void 0 ? {
1004
- "app.ai.thinking_level_confidence": normalizedSelection.confidence
1004
+ "app.ai.reasoning_level_confidence": normalizedSelection.confidence
1005
1005
  } : {}
1006
1006
  });
1007
1007
  return normalizedSelection;
1008
1008
  }
1009
1009
  );
1010
1010
  }
1011
- function applyThinkingFloor(selection, args) {
1011
+ function applyReasoningFloor(selection, args) {
1012
1012
  const minimum = args.minimum;
1013
- if (!minimum || selection.thinkingLevel === "none" || THINKING_LEVEL_RANK[selection.thinkingLevel] >= THINKING_LEVEL_RANK[minimum]) {
1013
+ if (!minimum || selection.reasoningLevel === "none" || REASONING_LEVEL_RANK[selection.reasoningLevel] >= REASONING_LEVEL_RANK[minimum]) {
1014
1014
  return selection;
1015
1015
  }
1016
1016
  return {
1017
1017
  ...selection,
1018
- thinkingLevel: minimum,
1019
- reason: `thinking_floor:${minimum}:${selection.reason}`
1018
+ reasoningLevel: minimum,
1019
+ reason: `reasoning_floor:${minimum}:${selection.reason}`
1020
1020
  };
1021
1021
  }
1022
1022
  async function classifyTurn(args) {
@@ -1036,23 +1036,23 @@ async function classifyTurn(args) {
1036
1036
  if (parsed.confidence < CLASSIFIER_CONFIDENCE_THRESHOLD) {
1037
1037
  return {
1038
1038
  confidence: parsed.confidence,
1039
- thinkingLevel: DEFAULT_THINKING_LEVEL,
1039
+ reasoningLevel: CLASSIFIER_FALLBACK_REASONING_LEVEL,
1040
1040
  reason: `low_confidence_medium_default:${reason}`
1041
1041
  };
1042
1042
  }
1043
1043
  return {
1044
1044
  confidence: parsed.confidence,
1045
- thinkingLevel: parsed.thinking_level,
1045
+ reasoningLevel: parsed.reasoning_level,
1046
1046
  reason
1047
1047
  };
1048
1048
  } catch {
1049
1049
  return {
1050
- thinkingLevel: DEFAULT_THINKING_LEVEL,
1050
+ reasoningLevel: CLASSIFIER_FALLBACK_REASONING_LEVEL,
1051
1051
  reason: "classifier_error_default"
1052
1052
  };
1053
1053
  }
1054
1054
  }
1055
- function toAgentThinkingLevel(level) {
1055
+ function toPiReasoningLevel(level) {
1056
1056
  switch (level) {
1057
1057
  case "none":
1058
1058
  return "off";
@@ -6680,7 +6680,9 @@ function stableSerialize(value) {
6680
6680
  return `[${value.map((entry) => stableSerialize(entry)).join(",")}]`;
6681
6681
  }
6682
6682
  if (value && typeof value === "object") {
6683
- const entries = Object.entries(value).sort((a, b) => a[0].localeCompare(b[0]));
6683
+ const entries = Object.entries(value).sort(
6684
+ (a, b) => a[0].localeCompare(b[0])
6685
+ );
6684
6686
  return `{${entries.map(([key, entry]) => `${JSON.stringify(key)}:${stableSerialize(entry)}`).join(",")}}`;
6685
6687
  }
6686
6688
  const serialized = JSON.stringify(value);
@@ -15223,7 +15225,11 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy) {
15223
15225
  let canRecordMcpProviders = false;
15224
15226
  let turnUsage;
15225
15227
  let handoffPhaseUsage;
15226
- let thinkingSelection;
15228
+ const configuredReasoningLevel = policy.reasoningLevel ?? botConfig.reasoningLevel;
15229
+ let reasoningSelection = configuredReasoningLevel ? configuredTurnReasoningLevel(
15230
+ configuredReasoningLevel,
15231
+ policy.reasoningLevel ? "agent_config" : "default"
15232
+ ) : void 0;
15227
15233
  let activeModelProfile = STANDARD_MODEL_PROFILE;
15228
15234
  let activeModelId = modelIdForProfile(botConfig, activeModelProfile);
15229
15235
  const actor = actorFromRouting(routing);
@@ -15337,7 +15343,7 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy) {
15337
15343
  destination: routing.destination,
15338
15344
  durability,
15339
15345
  getLoadedSkillNames: () => loadedSkillNamesForResume,
15340
- getReasoningLevel: () => thinkingSelection?.thinkingLevel,
15346
+ getReasoningLevel: () => reasoningSelection?.reasoningLevel,
15341
15347
  logContext: sessionRecordLogContext,
15342
15348
  getModelId: () => activeModelId,
15343
15349
  recordActiveMcpProviders,
@@ -15394,7 +15400,7 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy) {
15394
15400
  });
15395
15401
  const { routerBlocks, userContentParts } = buildPromptInput(input);
15396
15402
  const preAgentPromptMessages = () => existingSessionRecord?.piMessages ?? [...input.piMessages ?? []];
15397
- thinkingSelection = await selectTurnThinkingLevel({
15403
+ reasoningSelection ??= await selectTurnReasoningLevel({
15398
15404
  completeObject,
15399
15405
  conversationContext: input.conversationContext,
15400
15406
  context: {
@@ -15409,10 +15415,10 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy) {
15409
15415
  });
15410
15416
  setSpanAttributes({
15411
15417
  "gen_ai.request.model": activeModelId,
15412
- "gen_ai.request.reasoning.level": thinkingSelection.thinkingLevel,
15413
- "app.ai.thinking_level_reason": thinkingSelection.reason,
15414
- ...thinkingSelection.confidence !== void 0 ? {
15415
- "app.ai.thinking_level_confidence": thinkingSelection.confidence
15418
+ "gen_ai.request.reasoning.level": reasoningSelection.reasoningLevel,
15419
+ "app.ai.reasoning_level_reason": reasoningSelection.reason,
15420
+ ...reasoningSelection.confidence !== void 0 ? {
15421
+ "app.ai.reasoning_level_confidence": reasoningSelection.confidence
15416
15422
  } : {}
15417
15423
  });
15418
15424
  const generatedFiles = [];
@@ -15439,8 +15445,8 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy) {
15439
15445
  modelProfile: profile
15440
15446
  };
15441
15447
  const handoffModel = resolveGatewayModel(target.modelId);
15442
- const handoffThinkingLevel = toAgentThinkingLevel(
15443
- thinkingSelection.thinkingLevel
15448
+ const handoffThinkingLevel = toPiReasoningLevel(
15449
+ reasoningSelection.reasoningLevel
15444
15450
  );
15445
15451
  void (async () => {
15446
15452
  await observers.onStatus?.({ text: "Switching models" });
@@ -15673,7 +15679,7 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy) {
15673
15679
  runResume.adoptCommittedBoundary(replacement);
15674
15680
  setSpanAttributes({
15675
15681
  "gen_ai.request.model": activeModelId,
15676
- "gen_ai.request.reasoning.level": thinkingSelection.thinkingLevel,
15682
+ "gen_ai.request.reasoning.level": reasoningSelection.reasoningLevel,
15677
15683
  "app.ai.model_profile": activeModelProfile
15678
15684
  });
15679
15685
  update = {
@@ -15693,7 +15699,7 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy) {
15693
15699
  initialState: {
15694
15700
  systemPrompt: baseInstructions,
15695
15701
  model: resolveGatewayModel(activeModelId),
15696
- thinkingLevel: toAgentThinkingLevel(thinkingSelection.thinkingLevel),
15702
+ thinkingLevel: toPiReasoningLevel(reasoningSelection.reasoningLevel),
15697
15703
  tools: wiring.agentTools
15698
15704
  }
15699
15705
  });
@@ -15762,7 +15768,6 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy) {
15762
15768
  "gen_ai.invoke_agent",
15763
15769
  spanContext,
15764
15770
  async () => {
15765
- let promptResult;
15766
15771
  const freshPromptMessage = {
15767
15772
  role: "user",
15768
15773
  content: promptContentParts,
@@ -15824,8 +15829,8 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy) {
15824
15829
  "gen_ai.provider.name": GEN_AI_PROVIDER_NAME,
15825
15830
  "gen_ai.operation.name": "invoke_agent",
15826
15831
  "gen_ai.request.model": activeModelId,
15827
- ...thinkingSelection ? {
15828
- "gen_ai.request.reasoning.level": thinkingSelection.thinkingLevel
15832
+ ...reasoningSelection ? {
15833
+ "gen_ai.request.reasoning.level": reasoningSelection.reasoningLevel
15829
15834
  } : {},
15830
15835
  "app.ai.turn_timeout_ms": turnTimeoutBudgetMs,
15831
15836
  "app.ai.turn_deadline_remaining_ms": Math.max(
@@ -15870,7 +15875,7 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy) {
15870
15875
  let run = shouldPromptAgent ? agent.prompt(freshPromptMessage) : agent.continue();
15871
15876
  let retryUsage;
15872
15877
  for (let attempt = 0; ; attempt += 1) {
15873
- promptResult = await runAgentStep(run);
15878
+ await runAgentStep(run);
15874
15879
  signal?.throwIfAborted();
15875
15880
  if (runResume.cooperativeYieldError) {
15876
15881
  throw runResume.cooperativeYieldError;
@@ -15882,11 +15887,7 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy) {
15882
15887
  const outputMessagesAttribute = serializeGenAiAttribute(
15883
15888
  conversationPrivacy !== "public" ? outputMessages.map(toGenAiMessageMetadata) : outputMessages.map(toCanonicalOutputMessage)
15884
15889
  );
15885
- const usageSummary = extractGenAiUsageSummary(
15886
- promptResult,
15887
- agent.state,
15888
- ...outputMessages
15889
- );
15890
+ const usageSummary = extractGenAiUsageSummary(...outputMessages);
15890
15891
  const currentUsage = hasAgentTurnUsage(usageSummary) ? usageSummary : void 0;
15891
15892
  const currentPhaseUsage = addAgentTurnUsage(
15892
15893
  retryUsage,
@@ -15941,7 +15942,7 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy) {
15941
15942
  ...sessionConversationId ? { "app.ai.session.conversation_id": sessionConversationId } : {},
15942
15943
  ...sessionId ? { "app.ai.turn.session_id": sessionId } : {},
15943
15944
  ...currentSliceId ? { "app.ai.turn.slice_id": currentSliceId } : {},
15944
- "gen_ai.request.reasoning.level": thinkingSelection.thinkingLevel,
15945
+ "gen_ai.request.reasoning.level": reasoningSelection.reasoningLevel,
15945
15946
  ...toGenAiMessagesTraceAttributes("app.ai.input", inputMessages),
15946
15947
  ...inputMessagesAttribute ? { "gen_ai.input.messages": inputMessagesAttribute } : {}
15947
15948
  }
@@ -15967,7 +15968,7 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy) {
15967
15968
  shouldTrace,
15968
15969
  spanContext,
15969
15970
  usage: turnUsage,
15970
- thinkingSelection,
15971
+ reasoningSelection,
15971
15972
  correlation: routing.correlation,
15972
15973
  assistantUserName: botConfig.userName,
15973
15974
  modelId: activeModelId
@@ -16023,8 +16024,8 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy) {
16023
16024
  outcome: "provider_error",
16024
16025
  modelId: activeModelId,
16025
16026
  assistantMessageCount: 0,
16026
- ...thinkingSelection ? {
16027
- thinkingLevel: thinkingSelection.thinkingLevel
16027
+ ...reasoningSelection ? {
16028
+ reasoningLevel: reasoningSelection.reasoningLevel
16028
16029
  } : {},
16029
16030
  toolCalls: [],
16030
16031
  toolResultCount: 0,
@@ -0,0 +1,75 @@
1
+ import {
2
+ actorIdentitySchema,
3
+ conversationStatsItemSchema,
4
+ conversationSummaryReportSchema
5
+ } from "./chunk-MM5UFDAC.js";
6
+ import {
7
+ juniorDestinationKindSchema
8
+ } from "./chunk-FXFQNHRU.js";
9
+
10
+ // src/api/activity.ts
11
+ import { z } from "zod";
12
+ var dailyConversationActivitySchema = z.object({
13
+ active: z.number(),
14
+ conversations: z.number(),
15
+ date: z.string(),
16
+ durationMs: z.number(),
17
+ failed: z.number(),
18
+ tokens: z.number().optional()
19
+ }).strict();
20
+ function emptyActivityDay(date) {
21
+ return {
22
+ active: 0,
23
+ conversations: 0,
24
+ date,
25
+ durationMs: 0,
26
+ failed: 0
27
+ };
28
+ }
29
+ function activityDays(days, nowMs, count) {
30
+ const items = [];
31
+ const end = new Date(nowMs);
32
+ end.setUTCHours(0, 0, 0, 0);
33
+ const start = new Date(end);
34
+ start.setUTCDate(start.getUTCDate() - (count - 1));
35
+ for (const cursor = new Date(start); cursor.getTime() <= end.getTime(); cursor.setUTCDate(cursor.getUTCDate() + 1)) {
36
+ const date = cursor.toISOString().slice(0, 10);
37
+ items.push(days.get(date) ?? emptyActivityDay(date));
38
+ }
39
+ return items;
40
+ }
41
+
42
+ // src/api/locations/schema.ts
43
+ import { z as z2 } from "zod";
44
+ var locationSummaryReportSchema = conversationStatsItemSchema.extend({
45
+ id: z2.string(),
46
+ firstSeenAt: z2.string(),
47
+ kind: juniorDestinationKindSchema,
48
+ lastSeenAt: z2.string(),
49
+ provider: z2.string(),
50
+ providerDestinationId: z2.string(),
51
+ visibility: z2.literal("public")
52
+ }).strict();
53
+ var locationActorSummaryReportSchema = conversationStatsItemSchema.extend({ actor: actorIdentitySchema }).strict();
54
+ var locationDirectoryReportSchema = z2.object({
55
+ generatedAt: z2.string(),
56
+ locations: z2.array(locationSummaryReportSchema),
57
+ privateActivity: conversationStatsItemSchema,
58
+ source: z2.literal("conversation_index")
59
+ }).strict();
60
+ var locationDetailReportSchema = locationSummaryReportSchema.extend({
61
+ activityDays: z2.array(dailyConversationActivitySchema),
62
+ actors: z2.array(locationActorSummaryReportSchema),
63
+ generatedAt: z2.string(),
64
+ recentConversations: z2.array(conversationSummaryReportSchema),
65
+ source: z2.literal("conversation_index"),
66
+ windowEnd: z2.string(),
67
+ windowStart: z2.string()
68
+ }).strict();
69
+
70
+ export {
71
+ dailyConversationActivitySchema,
72
+ activityDays,
73
+ locationDirectoryReportSchema,
74
+ locationDetailReportSchema
75
+ };
@@ -541,11 +541,24 @@ function normalizeSlackEmojiName(value) {
541
541
  return SLACK_EMOJI_NAME_RE.test(normalized) ? normalized : null;
542
542
  }
543
543
 
544
- // src/chat/model-profile.ts
544
+ // src/chat/reasoning-level.ts
545
545
  import { z } from "zod";
546
+ var TURN_REASONING_LEVELS = [
547
+ "none",
548
+ "low",
549
+ "medium",
550
+ "high",
551
+ "xhigh"
552
+ ];
553
+ function parseTurnReasoningLevel(value) {
554
+ return z.enum(TURN_REASONING_LEVELS).parse(value);
555
+ }
556
+
557
+ // src/chat/model-profile.ts
558
+ import { z as z2 } from "zod";
546
559
  var STANDARD_MODEL_PROFILE = "standard";
547
560
  var DEFAULT_HANDOFF_MODEL_PROFILE = "handoff";
548
- var modelProfileSchema = z.string().regex(/^[a-z][a-z0-9_-]*$/);
561
+ var modelProfileSchema = z2.string().regex(/^[a-z][a-z0-9_-]*$/);
549
562
  var ModelProfileNotConfiguredError = class extends Error {
550
563
  constructor(profile) {
551
564
  super(`Model profile "${profile}" is not configured`);
@@ -721,6 +734,7 @@ function readBotConfig(env) {
721
734
  const functionMaxDurationSeconds = resolveFunctionMaxDurationSeconds(env);
722
735
  const maxTurnTimeoutMs = resolveMaxTurnTimeoutMs(functionMaxDurationSeconds);
723
736
  const modelId = validateGatewayModelId(env.AI_MODEL) ?? DEFAULT_MODEL_ID;
737
+ const reasoningLevel = toOptionalTrimmed(env.AI_REASONING_LEVEL);
724
738
  const fastModelId = validateGatewayModelId(env.AI_FAST_MODEL ?? env.AI_MODEL) ?? DEFAULT_FAST_MODEL_ID;
725
739
  const handoffModelId = validateGatewayModelId(env.AI_HANDOFF_MODEL) ?? DEFAULT_HANDOFF_MODEL_ID;
726
740
  return {
@@ -731,6 +745,7 @@ function readBotConfig(env) {
731
745
  "AI_MODEL_CONTEXT_WINDOW_TOKENS",
732
746
  env.AI_MODEL_CONTEXT_WINDOW_TOKENS
733
747
  ),
748
+ reasoningLevel: reasoningLevel === void 0 ? void 0 : parseTurnReasoningLevel(reasoningLevel),
734
749
  fastModelId,
735
750
  embeddingModelId: validateEmbeddingModelId(env.AI_EMBEDDING_MODEL) ?? DEFAULT_EMBEDDING_MODEL_ID,
736
751
  loadingMessages: parseLoadingMessages(env.JUNIOR_LOADING_MESSAGES),
@@ -1110,6 +1125,7 @@ export {
1110
1125
  completeObject,
1111
1126
  embedTexts,
1112
1127
  normalizeSlackEmojiName,
1128
+ TURN_REASONING_LEVELS,
1113
1129
  STANDARD_MODEL_PROFILE,
1114
1130
  DEFAULT_HANDOFF_MODEL_PROFILE,
1115
1131
  modelProfileSchema,
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-4ZNGQH7C.js";
4
4
  import {
5
5
  getSlackBotToken
6
- } from "./chunk-EEZCY5WX.js";
6
+ } from "./chunk-A7X2FDUO.js";
7
7
  import {
8
8
  logWarn,
9
9
  setSpanAttributes,
@@ -0,0 +1,48 @@
1
+ // src/db/schema/timestamps.ts
2
+ import { timestamp } from "drizzle-orm/pg-core";
3
+ var timestamptz = (name) => timestamp(name, { withTimezone: true });
4
+
5
+ // src/db/schema/destinations.ts
6
+ import { index, jsonb, pgTable, text, uniqueIndex } from "drizzle-orm/pg-core";
7
+ import { z } from "zod";
8
+ var juniorDestinationKindSchema = z.enum([
9
+ "channel",
10
+ "dm",
11
+ "group",
12
+ "local_conversation",
13
+ "thread",
14
+ "web_session"
15
+ ]);
16
+ var juniorDestinations = pgTable(
17
+ "junior_destinations",
18
+ {
19
+ id: text("id").primaryKey(),
20
+ provider: text("provider").notNull(),
21
+ providerTenantId: text("provider_tenant_id").notNull().default(""),
22
+ providerDestinationId: text("provider_destination_id").notNull(),
23
+ kind: text("kind").$type().notNull(),
24
+ parentDestinationId: text("parent_destination_id"),
25
+ displayName: text("display_name"),
26
+ visibility: text("visibility").$type().notNull().default("unknown"),
27
+ metadata: jsonb("metadata_json"),
28
+ createdAt: timestamptz("created_at").notNull(),
29
+ updatedAt: timestamptz("updated_at").notNull()
30
+ },
31
+ (table) => [
32
+ uniqueIndex("junior_destinations_provider_destination_uidx").on(
33
+ table.provider,
34
+ table.providerTenantId,
35
+ table.providerDestinationId
36
+ ),
37
+ index("junior_destinations_provider_kind_idx").on(
38
+ table.provider,
39
+ table.kind
40
+ )
41
+ ]
42
+ );
43
+
44
+ export {
45
+ timestamptz,
46
+ juniorDestinationKindSchema,
47
+ juniorDestinations
48
+ };