@sentry/junior 0.98.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.
- package/dist/{agent-hooks-OSW6C3CJ.js → agent-hooks-V6KU7PQN.js} +6 -5
- package/dist/api/activity.d.ts +14 -0
- package/dist/api/conversations/aggregate.d.ts +16 -0
- package/dist/api/conversations/detail-projection.d.ts +1 -0
- package/dist/api/conversations/list.d.ts +7 -2
- package/dist/api/conversations/list.query.d.ts +12 -3
- package/dist/api/conversations/projection.d.ts +1 -0
- package/dist/api/conversations/reporting.d.ts +42 -0
- package/dist/api/conversations/schema.d.ts +7 -7
- package/dist/api/conversations/stats.query.d.ts +1 -1
- package/dist/api/locations/detail.d.ts +81 -0
- package/dist/api/locations/list.d.ts +30 -0
- package/dist/api/locations/query.d.ts +5 -0
- package/dist/api/locations/schema.d.ts +175 -0
- package/dist/api/people/list.query.d.ts +1 -1
- package/dist/api/people/profile.query.d.ts +1 -1
- package/dist/api/people/schema.d.ts +10 -14
- package/dist/api/people/shared.d.ts +38 -78
- package/dist/api/schema.d.ts +11 -0
- package/dist/api/schema.js +16 -3
- package/dist/api-reference.d.ts +1 -1
- package/dist/api.js +41 -13
- package/dist/app.js +35 -27
- package/dist/chat/agent/request.d.ts +3 -0
- package/dist/chat/config.d.ts +2 -0
- package/dist/chat/reasoning-level.d.ts +4 -0
- package/dist/chat/services/context-compaction.d.ts +1 -0
- package/dist/chat/services/{turn-thinking-level.d.ts → turn-reasoning-level.d.ts} +11 -10
- package/dist/chat/services/turn-result.d.ts +3 -3
- package/dist/chat/tools/search-tools.d.ts +2 -2
- package/dist/{chunk-UAMKJPDF.js → chunk-2RNOB32R.js} +7 -1
- package/dist/{chunk-NJEDJFK4.js → chunk-2T7DCRAW.js} +1 -1
- package/dist/{chunk-DPHWDS6I.js → chunk-45DMFMY2.js} +81 -69
- package/dist/chunk-4AQUWWEM.js +75 -0
- package/dist/{chunk-EEZCY5WX.js → chunk-A7X2FDUO.js} +18 -2
- package/dist/{chunk-WTYEKPXU.js → chunk-FP5N5OWZ.js} +1 -1
- package/dist/chunk-FXFQNHRU.js +48 -0
- package/dist/chunk-GEUUJRQF.js +102 -0
- package/dist/{chunk-CRQVIHDI.js → chunk-IDZBM3NW.js} +2 -8
- package/dist/{chunk-DHHU2WSG.js → chunk-IQIBZXGB.js} +2 -2
- package/dist/{chunk-OL6XQ23W.js → chunk-IVXL57YF.js} +3 -3
- package/dist/{chunk-IO65E4ZD.js → chunk-JPQISMMJ.js} +3 -3
- package/dist/{chunk-KJHAW6VE.js → chunk-JSAANELJ.js} +28 -9
- package/dist/{chunk-EUZ44ROE.js → chunk-MM5UFDAC.js} +1 -3
- package/dist/{chunk-WJ7STXT6.js → chunk-NSOCZGOH.js} +3 -3
- package/dist/chunk-PGGEOCQY.js +77 -0
- package/dist/{chunk-EOWXRY5E.js → chunk-PWC24W5F.js} +1 -1
- package/dist/chunk-QOZOJNSE.js +96 -0
- package/dist/chunk-QSBQJ3PA.js +275 -0
- package/dist/{chunk-FTTFV6DC.js → chunk-TPTJEHUE.js} +4 -4
- package/dist/{chunk-OGHXZ4KQ.js → chunk-VHRM6GNH.js} +88 -122
- package/dist/{chunk-NG2AV7IB.js → chunk-VVIXK2BX.js} +1 -1
- package/dist/{chunk-6HHEZENZ.js → chunk-VY7BT4SM.js} +16 -7
- package/dist/{chunk-H66UCBPW.js → chunk-XJA7BPHS.js} +1 -1
- package/dist/{chunk-ER45IV77.js → chunk-XSBIISXS.js} +9 -9
- package/dist/cli/chat.js +15 -14
- package/dist/cli/plugins.js +6 -5
- package/dist/cli/snapshot-warmup.js +2 -2
- package/dist/cli/upgrade.js +8 -7
- package/dist/db/schema/conversations.d.ts +17 -0
- package/dist/db/schema/destinations.d.ts +12 -3
- package/dist/db/schema.d.ts +19 -2
- package/dist/{db-GFSCDAHS.js → db-RCZB7KNM.js} +3 -2
- package/dist/detail-5SLCGT6J.js +29 -0
- package/dist/{detail-W4ZSD45K.js → detail-LU6COZO6.js} +11 -10
- package/dist/{legacy-import-6WWXMALY.js → legacy-import-VCYLWT2V.js} +4 -3
- package/dist/list-2FI5SFV7.js +80 -0
- package/dist/list-4ALSU6ZW.js +30 -0
- package/dist/{list-3KZNG3SJ.js → list-KHRAWZWU.js} +11 -8
- package/dist/{plugin-conversations-ZYRWZYEA.js → plugin-conversations-JANXC4GA.js} +7 -6
- package/dist/profile-3O3OVENT.js +212 -0
- package/dist/{runner-267ZRLZD.js → runner-BM7D35YW.js} +12 -11
- package/dist/stats-J3YGCYDF.js +174 -0
- package/dist/{subagent-5HZPQC7V.js → subagent-P7HOSMVC.js} +10 -9
- package/migrations/0003_peaceful_scalphunter.sql +4 -0
- package/migrations/meta/0003_snapshot.json +1035 -0
- package/migrations/meta/_journal.json +8 -1
- package/package.json +5 -5
- package/dist/chunk-CV22LUIV.js +0 -261
- package/dist/list-M5BRWW3D.js +0 -92
- package/dist/profile-UEIRSVT3.js +0 -146
- package/dist/stats-L62E4O4U.js +0 -207
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
// src/api/schema.ts
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
var conversationParamsSchema = z.object({ conversationId: z.string().min(1) }).strict();
|
|
4
|
+
var conversationFeedQuerySchema = z.object({
|
|
5
|
+
actorEmail: z.string().trim().email().transform((value) => value.toLowerCase()).optional()
|
|
6
|
+
}).strict();
|
|
4
7
|
var subagentParamsSchema = conversationParamsSchema.extend({ subagentId: z.string().min(1) }).strict();
|
|
5
8
|
var personParamsSchema = z.object({ email: z.string().trim().min(1) }).strict();
|
|
9
|
+
var locationParamsSchema = z.object({ locationId: z.string().min(1) }).strict();
|
|
6
10
|
|
|
7
11
|
export {
|
|
8
12
|
conversationParamsSchema,
|
|
13
|
+
conversationFeedQuerySchema,
|
|
9
14
|
subagentParamsSchema,
|
|
10
|
-
personParamsSchema
|
|
15
|
+
personParamsSchema,
|
|
16
|
+
locationParamsSchema
|
|
11
17
|
};
|
|
@@ -10,14 +10,14 @@ import {
|
|
|
10
10
|
persistRunningSessionRecord,
|
|
11
11
|
persistTimeoutSessionRecord,
|
|
12
12
|
persistYieldSessionRecord
|
|
13
|
-
} from "./chunk-
|
|
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-
|
|
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-
|
|
28
|
+
} from "./chunk-IQIBZXGB.js";
|
|
29
29
|
import {
|
|
30
30
|
estimateTextTokens,
|
|
31
31
|
getAgentContextCompactionTriggerTokens,
|
|
32
32
|
updateConversationStats
|
|
33
|
-
} from "./chunk-
|
|
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-
|
|
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-
|
|
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-
|
|
65
|
+
} from "./chunk-FP5N5OWZ.js";
|
|
66
66
|
import {
|
|
67
67
|
createPluginLogger
|
|
68
|
-
} from "./chunk-
|
|
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-
|
|
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-
|
|
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
|
-
|
|
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
|
-
|
|
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-
|
|
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
|
-
|
|
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
|
|
885
|
-
var
|
|
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
|
|
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
|
|
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
|
-
|
|
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.
|
|
975
|
-
"chat.
|
|
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 =
|
|
997
|
+
const normalizedSelection = applyReasoningFloor(selection, {
|
|
998
998
|
minimum: trimmedContext || turnBlockCount > 0 ? "medium" : void 0
|
|
999
999
|
});
|
|
1000
1000
|
setSpanAttributes({
|
|
1001
|
-
"app.ai.
|
|
1002
|
-
"app.ai.
|
|
1001
|
+
"app.ai.reasoning_level": normalizedSelection.reasoningLevel,
|
|
1002
|
+
"app.ai.reasoning_level_reason": normalizedSelection.reason,
|
|
1003
1003
|
...normalizedSelection.confidence !== void 0 ? {
|
|
1004
|
-
"app.ai.
|
|
1004
|
+
"app.ai.reasoning_level_confidence": normalizedSelection.confidence
|
|
1005
1005
|
} : {}
|
|
1006
1006
|
});
|
|
1007
1007
|
return normalizedSelection;
|
|
1008
1008
|
}
|
|
1009
1009
|
);
|
|
1010
1010
|
}
|
|
1011
|
-
function
|
|
1011
|
+
function applyReasoningFloor(selection, args) {
|
|
1012
1012
|
const minimum = args.minimum;
|
|
1013
|
-
if (!minimum || selection.
|
|
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
|
-
|
|
1019
|
-
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
|
-
|
|
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
|
-
|
|
1045
|
+
reasoningLevel: parsed.reasoning_level,
|
|
1046
1046
|
reason
|
|
1047
1047
|
};
|
|
1048
1048
|
} catch {
|
|
1049
1049
|
return {
|
|
1050
|
-
|
|
1050
|
+
reasoningLevel: CLASSIFIER_FALLBACK_REASONING_LEVEL,
|
|
1051
1051
|
reason: "classifier_error_default"
|
|
1052
1052
|
};
|
|
1053
1053
|
}
|
|
1054
1054
|
}
|
|
1055
|
-
function
|
|
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(
|
|
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);
|
|
@@ -15124,9 +15126,19 @@ function createContextCompactor(deps) {
|
|
|
15124
15126
|
};
|
|
15125
15127
|
}
|
|
15126
15128
|
async function compactContextForHandoff(args, deps) {
|
|
15127
|
-
const
|
|
15128
|
-
|
|
15129
|
-
|
|
15129
|
+
const runtimeMessage = args.runtimeContext.at(-1);
|
|
15130
|
+
if (!runtimeMessage) {
|
|
15131
|
+
throw new Error("Handoff requires the current runtime turn context");
|
|
15132
|
+
}
|
|
15133
|
+
const summary = `${MODEL_HANDOFF_SUMMARY_PREFIX}
|
|
15134
|
+
${await summarizeContext(args, deps)}`;
|
|
15135
|
+
const message = {
|
|
15136
|
+
...runtimeMessage,
|
|
15137
|
+
content: [
|
|
15138
|
+
...runtimeMessage.content,
|
|
15139
|
+
{ type: "text", text: renderCurrentInstruction(summary) }
|
|
15140
|
+
]
|
|
15141
|
+
};
|
|
15130
15142
|
const messages = [message];
|
|
15131
15143
|
args.signal?.throwIfAborted();
|
|
15132
15144
|
await getAgentStepStore().startEpoch(args.conversationId, {
|
|
@@ -15213,7 +15225,11 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy) {
|
|
|
15213
15225
|
let canRecordMcpProviders = false;
|
|
15214
15226
|
let turnUsage;
|
|
15215
15227
|
let handoffPhaseUsage;
|
|
15216
|
-
|
|
15228
|
+
const configuredReasoningLevel = policy.reasoningLevel ?? botConfig.reasoningLevel;
|
|
15229
|
+
let reasoningSelection = configuredReasoningLevel ? configuredTurnReasoningLevel(
|
|
15230
|
+
configuredReasoningLevel,
|
|
15231
|
+
policy.reasoningLevel ? "agent_config" : "default"
|
|
15232
|
+
) : void 0;
|
|
15217
15233
|
let activeModelProfile = STANDARD_MODEL_PROFILE;
|
|
15218
15234
|
let activeModelId = modelIdForProfile(botConfig, activeModelProfile);
|
|
15219
15235
|
const actor = actorFromRouting(routing);
|
|
@@ -15327,7 +15343,7 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy) {
|
|
|
15327
15343
|
destination: routing.destination,
|
|
15328
15344
|
durability,
|
|
15329
15345
|
getLoadedSkillNames: () => loadedSkillNamesForResume,
|
|
15330
|
-
getReasoningLevel: () =>
|
|
15346
|
+
getReasoningLevel: () => reasoningSelection?.reasoningLevel,
|
|
15331
15347
|
logContext: sessionRecordLogContext,
|
|
15332
15348
|
getModelId: () => activeModelId,
|
|
15333
15349
|
recordActiveMcpProviders,
|
|
@@ -15384,7 +15400,7 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy) {
|
|
|
15384
15400
|
});
|
|
15385
15401
|
const { routerBlocks, userContentParts } = buildPromptInput(input);
|
|
15386
15402
|
const preAgentPromptMessages = () => existingSessionRecord?.piMessages ?? [...input.piMessages ?? []];
|
|
15387
|
-
|
|
15403
|
+
reasoningSelection ??= await selectTurnReasoningLevel({
|
|
15388
15404
|
completeObject,
|
|
15389
15405
|
conversationContext: input.conversationContext,
|
|
15390
15406
|
context: {
|
|
@@ -15399,10 +15415,10 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy) {
|
|
|
15399
15415
|
});
|
|
15400
15416
|
setSpanAttributes({
|
|
15401
15417
|
"gen_ai.request.model": activeModelId,
|
|
15402
|
-
"gen_ai.request.reasoning.level":
|
|
15403
|
-
"app.ai.
|
|
15404
|
-
...
|
|
15405
|
-
"app.ai.
|
|
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
|
|
15406
15422
|
} : {}
|
|
15407
15423
|
});
|
|
15408
15424
|
const generatedFiles = [];
|
|
@@ -15429,8 +15445,8 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy) {
|
|
|
15429
15445
|
modelProfile: profile
|
|
15430
15446
|
};
|
|
15431
15447
|
const handoffModel = resolveGatewayModel(target.modelId);
|
|
15432
|
-
const handoffThinkingLevel =
|
|
15433
|
-
|
|
15448
|
+
const handoffThinkingLevel = toPiReasoningLevel(
|
|
15449
|
+
reasoningSelection.reasoningLevel
|
|
15434
15450
|
);
|
|
15435
15451
|
void (async () => {
|
|
15436
15452
|
await observers.onStatus?.({ text: "Switching models" });
|
|
@@ -15449,6 +15465,7 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy) {
|
|
|
15449
15465
|
conversationContext: input.conversationContext,
|
|
15450
15466
|
conversationId: sessionConversationId,
|
|
15451
15467
|
piMessages: sourceMessages,
|
|
15468
|
+
runtimeContext,
|
|
15452
15469
|
signal: signal2,
|
|
15453
15470
|
target,
|
|
15454
15471
|
metadata: {
|
|
@@ -15462,7 +15479,7 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy) {
|
|
|
15462
15479
|
);
|
|
15463
15480
|
handoffPhaseUsage = phaseUsage;
|
|
15464
15481
|
pendingHandoff = {
|
|
15465
|
-
messages:
|
|
15482
|
+
messages: handoffMessages,
|
|
15466
15483
|
model: handoffModel,
|
|
15467
15484
|
thinkingLevel: handoffThinkingLevel
|
|
15468
15485
|
};
|
|
@@ -15662,7 +15679,7 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy) {
|
|
|
15662
15679
|
runResume.adoptCommittedBoundary(replacement);
|
|
15663
15680
|
setSpanAttributes({
|
|
15664
15681
|
"gen_ai.request.model": activeModelId,
|
|
15665
|
-
"gen_ai.request.reasoning.level":
|
|
15682
|
+
"gen_ai.request.reasoning.level": reasoningSelection.reasoningLevel,
|
|
15666
15683
|
"app.ai.model_profile": activeModelProfile
|
|
15667
15684
|
});
|
|
15668
15685
|
update = {
|
|
@@ -15682,7 +15699,7 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy) {
|
|
|
15682
15699
|
initialState: {
|
|
15683
15700
|
systemPrompt: baseInstructions,
|
|
15684
15701
|
model: resolveGatewayModel(activeModelId),
|
|
15685
|
-
thinkingLevel:
|
|
15702
|
+
thinkingLevel: toPiReasoningLevel(reasoningSelection.reasoningLevel),
|
|
15686
15703
|
tools: wiring.agentTools
|
|
15687
15704
|
}
|
|
15688
15705
|
});
|
|
@@ -15751,7 +15768,6 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy) {
|
|
|
15751
15768
|
"gen_ai.invoke_agent",
|
|
15752
15769
|
spanContext,
|
|
15753
15770
|
async () => {
|
|
15754
|
-
let promptResult;
|
|
15755
15771
|
const freshPromptMessage = {
|
|
15756
15772
|
role: "user",
|
|
15757
15773
|
content: promptContentParts,
|
|
@@ -15813,8 +15829,8 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy) {
|
|
|
15813
15829
|
"gen_ai.provider.name": GEN_AI_PROVIDER_NAME,
|
|
15814
15830
|
"gen_ai.operation.name": "invoke_agent",
|
|
15815
15831
|
"gen_ai.request.model": activeModelId,
|
|
15816
|
-
...
|
|
15817
|
-
"gen_ai.request.reasoning.level":
|
|
15832
|
+
...reasoningSelection ? {
|
|
15833
|
+
"gen_ai.request.reasoning.level": reasoningSelection.reasoningLevel
|
|
15818
15834
|
} : {},
|
|
15819
15835
|
"app.ai.turn_timeout_ms": turnTimeoutBudgetMs,
|
|
15820
15836
|
"app.ai.turn_deadline_remaining_ms": Math.max(
|
|
@@ -15859,7 +15875,7 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy) {
|
|
|
15859
15875
|
let run = shouldPromptAgent ? agent.prompt(freshPromptMessage) : agent.continue();
|
|
15860
15876
|
let retryUsage;
|
|
15861
15877
|
for (let attempt = 0; ; attempt += 1) {
|
|
15862
|
-
|
|
15878
|
+
await runAgentStep(run);
|
|
15863
15879
|
signal?.throwIfAborted();
|
|
15864
15880
|
if (runResume.cooperativeYieldError) {
|
|
15865
15881
|
throw runResume.cooperativeYieldError;
|
|
@@ -15871,11 +15887,7 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy) {
|
|
|
15871
15887
|
const outputMessagesAttribute = serializeGenAiAttribute(
|
|
15872
15888
|
conversationPrivacy !== "public" ? outputMessages.map(toGenAiMessageMetadata) : outputMessages.map(toCanonicalOutputMessage)
|
|
15873
15889
|
);
|
|
15874
|
-
const usageSummary = extractGenAiUsageSummary(
|
|
15875
|
-
promptResult,
|
|
15876
|
-
agent.state,
|
|
15877
|
-
...outputMessages
|
|
15878
|
-
);
|
|
15890
|
+
const usageSummary = extractGenAiUsageSummary(...outputMessages);
|
|
15879
15891
|
const currentUsage = hasAgentTurnUsage(usageSummary) ? usageSummary : void 0;
|
|
15880
15892
|
const currentPhaseUsage = addAgentTurnUsage(
|
|
15881
15893
|
retryUsage,
|
|
@@ -15930,7 +15942,7 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy) {
|
|
|
15930
15942
|
...sessionConversationId ? { "app.ai.session.conversation_id": sessionConversationId } : {},
|
|
15931
15943
|
...sessionId ? { "app.ai.turn.session_id": sessionId } : {},
|
|
15932
15944
|
...currentSliceId ? { "app.ai.turn.slice_id": currentSliceId } : {},
|
|
15933
|
-
"gen_ai.request.reasoning.level":
|
|
15945
|
+
"gen_ai.request.reasoning.level": reasoningSelection.reasoningLevel,
|
|
15934
15946
|
...toGenAiMessagesTraceAttributes("app.ai.input", inputMessages),
|
|
15935
15947
|
...inputMessagesAttribute ? { "gen_ai.input.messages": inputMessagesAttribute } : {}
|
|
15936
15948
|
}
|
|
@@ -15956,7 +15968,7 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy) {
|
|
|
15956
15968
|
shouldTrace,
|
|
15957
15969
|
spanContext,
|
|
15958
15970
|
usage: turnUsage,
|
|
15959
|
-
|
|
15971
|
+
reasoningSelection,
|
|
15960
15972
|
correlation: routing.correlation,
|
|
15961
15973
|
assistantUserName: botConfig.userName,
|
|
15962
15974
|
modelId: activeModelId
|
|
@@ -16012,8 +16024,8 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy) {
|
|
|
16012
16024
|
outcome: "provider_error",
|
|
16013
16025
|
modelId: activeModelId,
|
|
16014
16026
|
assistantMessageCount: 0,
|
|
16015
|
-
...
|
|
16016
|
-
|
|
16027
|
+
...reasoningSelection ? {
|
|
16028
|
+
reasoningLevel: reasoningSelection.reasoningLevel
|
|
16017
16029
|
} : {},
|
|
16018
16030
|
toolCalls: [],
|
|
16019
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/
|
|
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 =
|
|
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,
|
|
@@ -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
|
+
};
|