@sentry/junior 0.203.0 → 0.204.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-CMyTD4DD.js +17509 -0
- package/dist/agent-hooks-Bbcp9e33.js +4040 -0
- package/dist/agent-runner-DNb1A49M.js +678 -0
- package/dist/api/schema.d.ts +2728 -2639
- package/dist/api/schema.js +4 -169
- package/dist/api.d.ts +23 -17
- package/dist/api.js +3881 -5326
- package/dist/app-B1TOqBI8.d.ts +246 -0
- package/dist/app.d.ts +4 -520
- package/dist/app.js +9522 -11875
- package/dist/auth-pause-state-DosEalIG.js +168 -0
- package/dist/catalog-runtime-BReos-D4.js +7 -0
- package/dist/checkpoint-CNrPyRJN.js +2450 -0
- package/dist/cli/chat.d.ts +20 -0
- package/dist/cli/chat.js +229 -336
- package/dist/cli/check.d.ts +8 -0
- package/dist/cli/check.js +513 -806
- package/dist/cli/env.d.ts +13 -0
- package/dist/cli/env.js +63 -12
- package/dist/cli/init.d.ts +3 -0
- package/dist/cli/init.js +90 -159
- package/dist/cli/main.d.ts +6 -0
- package/dist/cli/main.js +43 -64
- package/dist/cli/plugins.d.ts +13 -0
- package/dist/cli/plugins.js +148 -227
- package/dist/cli/run.d.ts +16 -0
- package/dist/cli/run.js +52 -8
- package/dist/cli/snapshot-create.d.ts +4 -0
- package/dist/cli/snapshot-create.js +71 -125
- package/dist/cli/upgrade.d.ts +15 -0
- package/dist/cli/upgrade.js +232 -335
- package/dist/config-nGCW1OTG.js +941 -0
- package/dist/context-B45_WqVX.js +298 -0
- package/dist/conversation-privacy-B4voFRSm.js +182 -0
- package/dist/conversation-work-C6y3T5Hx.js +51 -0
- package/dist/credential-sync-kXr1hvO1.js +2660 -0
- package/dist/db-BeyXKJOI.d.ts +5 -0
- package/dist/destinations-BeBiJeEM.js +29 -0
- package/dist/execution-stats-DWfSihcH.js +373 -0
- package/dist/executor-DcMSlI5c.js +721 -0
- package/dist/experimental-CIXf7Uye.js +46 -0
- package/dist/history-ClE4toxe.d.ts +32 -0
- package/dist/history-CqTuSAdI.js +441 -0
- package/dist/instrumentation.d.ts +3 -3
- package/dist/instrumentation.js +130 -176
- package/dist/job-queue-Drn_LXlM.js +63 -0
- package/dist/logging-BzAk1S_s.js +1210 -0
- package/dist/model-profile-CZmVoGdX.js +49 -0
- package/dist/nitro.d.ts +31 -36
- package/dist/nitro.js +275 -456
- package/dist/oauth-callback-server-JiftokvA.js +130 -0
- package/dist/oauth-relay-CdCnu80W.js +62 -0
- package/dist/package-discovery-7a9YqLhE.js +455 -0
- package/dist/pending-auth-CWmSdZVg.js +185 -0
- package/dist/plugin-module-BKGOXca2.js +81 -0
- package/dist/plugins-BI9A1vKA.d.ts +95 -0
- package/dist/plugins-egKWjgue.js +99 -0
- package/dist/private-trace-result-BLvBjy_e.js +16 -0
- package/dist/profile-CrT5nXbw.js +861 -0
- package/dist/registry-DH1xUo2N.js +1419 -0
- package/dist/reporting-schema-DosTN__Q.js +105 -0
- package/dist/resolve-CZHnfxaS.js +546 -0
- package/dist/rolldown-runtime-B4FMCO8f.js +28 -0
- package/dist/runner-CZV2sC46.js +392 -0
- package/dist/sandbox-egress-signals-bHZfmhbd.js +46 -0
- package/dist/schema-Rn8-XEaN.js +1140 -0
- package/dist/sentry-CD3SdJl-.js +26 -0
- package/dist/skills-CIcDQSgM.js +316 -0
- package/dist/spawn-DdkUFRmq.js +29 -0
- package/dist/stats-DTUbAb88.js +2634 -0
- package/dist/store-C5qxF2ac.d.ts +208 -0
- package/dist/task-queue-CJIR4RF7.js +136 -0
- package/dist/task-runner-D-O3A-Cp.js +639 -0
- package/dist/thread-state-CRc9jTJS.js +431 -0
- package/dist/turn-execution-BkinIdJF.js +47 -0
- package/dist/turn-lifecycle-DQV19VTW.js +54 -0
- package/dist/usage-D3EbSO7w.js +296 -0
- package/dist/usage-schema-CKaDkH_j.js +20 -0
- package/dist/validation-C2CR-OX3.js +40 -0
- package/dist/vercel-queue-DIkVcfK4.js +167 -0
- package/dist/vercel.d.ts +6 -6
- package/dist/vercel.js +14 -6
- package/dist/version-CnXZ614E.d.ts +5 -0
- package/dist/version-DxcWdoKa.js +8 -0
- package/dist/version.d.ts +2 -4
- package/dist/version.js +2 -6
- package/dist/web-authorization-RMBxAR_t.js +76 -0
- package/dist/web-input-3EPfpf55.js +494 -0
- package/dist/work-fGofI7Op.js +509 -0
- package/dist/worker-CsOLq-mR.js +625 -0
- package/package.json +8 -8
- package/dist/agent-hooks-GB2VPTNA.js +0 -51
- package/dist/catalog-runtime-UBLIWD3O.js +0 -14
- package/dist/chunk-2LYHWMR4.js +0 -46
- package/dist/chunk-352OWAZH.js +0 -320
- package/dist/chunk-3Y47VMHV.js +0 -6
- package/dist/chunk-3YJSKOWF.js +0 -164
- package/dist/chunk-4KSSKTQ5.js +0 -229
- package/dist/chunk-4UO6FK4G.js +0 -64
- package/dist/chunk-5AHX53NQ.js +0 -717
- package/dist/chunk-5J3E5FWA.js +0 -700
- package/dist/chunk-5PDAG6O3.js +0 -206
- package/dist/chunk-6Y5B5PEX.js +0 -80
- package/dist/chunk-7GWQ5S5R.js +0 -2086
- package/dist/chunk-7H2VZTWN.js +0 -103
- package/dist/chunk-7NL7T6VU.js +0 -406
- package/dist/chunk-A5L27LE4.js +0 -387
- package/dist/chunk-ADIAWL34.js +0 -81
- package/dist/chunk-ASTEMBKJ.js +0 -519
- package/dist/chunk-CEMMLV5L.js +0 -98
- package/dist/chunk-CM5HNV2W.js +0 -131
- package/dist/chunk-CRTRBBRI.js +0 -105
- package/dist/chunk-DA2KGZZI.js +0 -13
- package/dist/chunk-DIB4GX3G.js +0 -8
- package/dist/chunk-DKIJ2RP5.js +0 -68
- package/dist/chunk-DWPN6SCH.js +0 -172
- package/dist/chunk-EDKUFGPL.js +0 -64
- package/dist/chunk-ENY6SKIU.js +0 -1228
- package/dist/chunk-F4MGCZOX.js +0 -2943
- package/dist/chunk-FA6POGLH.js +0 -70
- package/dist/chunk-FSUR7GTG.js +0 -20475
- package/dist/chunk-GKEOHJL5.js +0 -1856
- package/dist/chunk-GMCB6W5Y.js +0 -333
- package/dist/chunk-IE2VPG7O.js +0 -1135
- package/dist/chunk-IZ5B5IHQ.js +0 -3656
- package/dist/chunk-JAL3CH4G.js +0 -27
- package/dist/chunk-KIIEUXD3.js +0 -1764
- package/dist/chunk-KXU4NIL7.js +0 -692
- package/dist/chunk-MTM5IFCY.js +0 -1190
- package/dist/chunk-N7TMSOZH.js +0 -235
- package/dist/chunk-NCEBK6PH.js +0 -36
- package/dist/chunk-NHJU2ZAL.js +0 -56
- package/dist/chunk-P6KTRNVC.js +0 -321
- package/dist/chunk-PDO5BLNM.js +0 -22
- package/dist/chunk-PDRNLLFT.js +0 -3295
- package/dist/chunk-PEQXYSSE.js +0 -45
- package/dist/chunk-PKEX2AQX.js +0 -198
- package/dist/chunk-PSJCGIGO.js +0 -1163
- package/dist/chunk-PZUSUL55.js +0 -506
- package/dist/chunk-R45M4TUS.js +0 -37
- package/dist/chunk-RC745GGZ.js +0 -122
- package/dist/chunk-SP3QKZXJ.js +0 -820
- package/dist/chunk-TXKUKMVO.js +0 -417
- package/dist/chunk-UE4GPWSD.js +0 -931
- package/dist/chunk-UIE3R5XU.js +0 -17
- package/dist/chunk-UXPG6ZIN.js +0 -84
- package/dist/chunk-VFUK3X5B.js +0 -50
- package/dist/chunk-VNMJWREK.js +0 -787
- package/dist/chunk-VZ7CSOX2.js +0 -706
- package/dist/chunk-WCNQJKFT.js +0 -10
- package/dist/chunk-WDZR3QQM.js +0 -135
- package/dist/chunk-WLYVJCHV.js +0 -1433
- package/dist/chunk-WS7NAFTM.js +0 -1520
- package/dist/chunk-X6GDDWQH.js +0 -60
- package/dist/chunk-XPDEYNQI.js +0 -102
- package/dist/chunk-XRW44VGM.js +0 -58
- package/dist/chunk-Y2CM7HXH.js +0 -111
- package/dist/chunk-Y7X25LFY.js +0 -15
- package/dist/conversation-work-VIOQ5ZF3.js +0 -54
- package/dist/db-NGDJV7YH.js +0 -26
- package/dist/discovery-DWVDM7UK.js +0 -44
- package/dist/experimental-P5FZM4CU.js +0 -12
- package/dist/oauth-callback-server-YFY7YEGK.js +0 -243
- package/dist/oauth-relay-5XPVRPYB.js +0 -8
- package/dist/plugins-YTYJMMJF.js +0 -14
- package/dist/runner-ORTNSB2Q.js +0 -522
- package/dist/sandbox-egress-signals-FIL7EGPR.js +0 -73
- package/dist/sentry-MB3NL3IR.js +0 -42
- package/dist/skills-H376WQOH.js +0 -27
- package/dist/spawn-T43WHLOS.js +0 -42
- package/dist/task-runner-LBZWF32V.js +0 -36
- package/dist/validation-REJLRKI6.js +0 -17
- package/dist/work-3KJ3RE76.js +0 -51
- package/dist/worker-QFEBU72E.js +0 -24
package/dist/chunk-GMCB6W5Y.js
DELETED
|
@@ -1,333 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
usageSchema
|
|
3
|
-
} from "./chunk-PDO5BLNM.js";
|
|
4
|
-
import {
|
|
5
|
-
botConfig
|
|
6
|
-
} from "./chunk-ENY6SKIU.js";
|
|
7
|
-
import {
|
|
8
|
-
logWarn
|
|
9
|
-
} from "./chunk-WS7NAFTM.js";
|
|
10
|
-
|
|
11
|
-
// src/chat/conversations/structured-events.ts
|
|
12
|
-
import {
|
|
13
|
-
conversationEventPresentationSchema,
|
|
14
|
-
defineConversationEvent
|
|
15
|
-
} from "@sentry/junior-plugin-api";
|
|
16
|
-
import { z } from "zod";
|
|
17
|
-
var JUNIOR_NATIVE_EVENT_NAMESPACE = "junior";
|
|
18
|
-
var authenticationEventContentSchema = z.object({
|
|
19
|
-
accountLabel: z.string().trim().min(1).max(120).optional(),
|
|
20
|
-
actorId: z.string().min(1),
|
|
21
|
-
authorizationId: z.string().min(1).optional(),
|
|
22
|
-
provider: z.string().regex(/^[a-z][a-z0-9-]*$/),
|
|
23
|
-
providerLabel: z.string().trim().min(1).max(80).optional()
|
|
24
|
-
}).strict();
|
|
25
|
-
var agentsInstructionsUpdatedContentSchema = z.object({
|
|
26
|
-
action: z.enum(["loaded", "replaced", "cleared"]),
|
|
27
|
-
directory: z.string().trim().min(1).max(500).optional(),
|
|
28
|
-
fingerprint: z.string().trim().min(1).max(128),
|
|
29
|
-
sources: z.array(
|
|
30
|
-
z.object({
|
|
31
|
-
content: z.string().min(1).max(32 * 1024),
|
|
32
|
-
path: z.string().trim().min(1).max(500)
|
|
33
|
-
}).strict()
|
|
34
|
-
).max(32),
|
|
35
|
-
textBytes: z.number().int().nonnegative().optional()
|
|
36
|
-
}).strict();
|
|
37
|
-
function providerTitle(content) {
|
|
38
|
-
return content.providerLabel?.trim() || content.provider;
|
|
39
|
-
}
|
|
40
|
-
function agentsInstructionsTitle(action) {
|
|
41
|
-
if (action === "loaded") return "Loaded AGENTS.md";
|
|
42
|
-
if (action === "replaced") return "Updated AGENTS.md";
|
|
43
|
-
return "Cleared AGENTS.md";
|
|
44
|
-
}
|
|
45
|
-
function sourceFilename(sourcePath) {
|
|
46
|
-
return sourcePath.split("/").at(-1) || sourcePath;
|
|
47
|
-
}
|
|
48
|
-
function formatBytes(bytes) {
|
|
49
|
-
if (bytes < 1024) return `${bytes} bytes`;
|
|
50
|
-
const kilobytes = bytes / 1024;
|
|
51
|
-
return `${Number.isInteger(kilobytes) ? kilobytes : kilobytes.toFixed(1)} KB`;
|
|
52
|
-
}
|
|
53
|
-
function agentsInstructionsPreview(content) {
|
|
54
|
-
const source = content.sources[0];
|
|
55
|
-
if (!source) return void 0;
|
|
56
|
-
const filename = sourceFilename(source.path);
|
|
57
|
-
const label = content.sources.length === 1 ? filename : `${content.sources.length} AGENTS.md files`;
|
|
58
|
-
return typeof content.textBytes === "number" ? `${label} \xB7 ${formatBytes(content.textBytes)}` : label;
|
|
59
|
-
}
|
|
60
|
-
var authenticationLinkedEvent = defineConversationEvent({
|
|
61
|
-
name: "authentication_linked",
|
|
62
|
-
version: 1,
|
|
63
|
-
schema: authenticationEventContentSchema,
|
|
64
|
-
renderEvent(event) {
|
|
65
|
-
const provider = providerTitle(event);
|
|
66
|
-
return {
|
|
67
|
-
icon: "link",
|
|
68
|
-
title: `${provider} connected`,
|
|
69
|
-
...event.accountLabel ? { preview: `Connected as \`${event.accountLabel}\`` } : void 0,
|
|
70
|
-
details: [
|
|
71
|
-
{
|
|
72
|
-
title: `${provider} connected`,
|
|
73
|
-
...event.accountLabel ? { description: `Connected as \`${event.accountLabel}\`` } : void 0,
|
|
74
|
-
metadata: [event.provider]
|
|
75
|
-
}
|
|
76
|
-
]
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
var authenticationUnlinkedEvent = defineConversationEvent({
|
|
81
|
-
name: "authentication_unlinked",
|
|
82
|
-
version: 1,
|
|
83
|
-
schema: authenticationEventContentSchema,
|
|
84
|
-
renderEvent(event) {
|
|
85
|
-
const provider = providerTitle(event);
|
|
86
|
-
return {
|
|
87
|
-
icon: "key",
|
|
88
|
-
title: `${provider} disconnected`,
|
|
89
|
-
details: [
|
|
90
|
-
{
|
|
91
|
-
title: `${provider} disconnected`,
|
|
92
|
-
metadata: [event.provider]
|
|
93
|
-
}
|
|
94
|
-
]
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
var agentsInstructionsUpdatedEvent = defineConversationEvent({
|
|
99
|
-
name: "agents_instructions_updated",
|
|
100
|
-
version: 1,
|
|
101
|
-
schema: agentsInstructionsUpdatedContentSchema,
|
|
102
|
-
renderEvent(event) {
|
|
103
|
-
const title = agentsInstructionsTitle(event.action);
|
|
104
|
-
const preview = agentsInstructionsPreview(event);
|
|
105
|
-
return {
|
|
106
|
-
icon: "brain",
|
|
107
|
-
title,
|
|
108
|
-
...preview ? { preview } : void 0,
|
|
109
|
-
...event.sources.length > 0 ? {
|
|
110
|
-
details: event.sources.map((source) => ({
|
|
111
|
-
title: sourceFilename(source.path),
|
|
112
|
-
content: source.content
|
|
113
|
-
}))
|
|
114
|
-
} : void 0
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
var NATIVE_EVENT_DEFINITIONS = [
|
|
119
|
-
authenticationLinkedEvent,
|
|
120
|
-
authenticationUnlinkedEvent,
|
|
121
|
-
agentsInstructionsUpdatedEvent
|
|
122
|
-
];
|
|
123
|
-
function getJuniorNativeEventDefinition(args) {
|
|
124
|
-
return NATIVE_EVENT_DEFINITIONS.find(
|
|
125
|
-
(definition) => definition.eventName === args.name && definition.version === args.version
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
function renderJuniorNativeConversationEvent(args) {
|
|
129
|
-
if (args.namespace !== JUNIOR_NATIVE_EVENT_NAMESPACE) return void 0;
|
|
130
|
-
const definition = getJuniorNativeEventDefinition(args);
|
|
131
|
-
if (!definition) return void 0;
|
|
132
|
-
const presentation = definition.renderEvent(definition.parse(args.content));
|
|
133
|
-
return presentation === void 0 ? void 0 : conversationEventPresentationSchema.parse(presentation);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// src/chat/usage.ts
|
|
137
|
-
var agentTurnUsageSchema = usageSchema;
|
|
138
|
-
var COMPONENT_USAGE_FIELDS = [
|
|
139
|
-
"inputTokens",
|
|
140
|
-
"outputTokens",
|
|
141
|
-
"cachedInputTokens",
|
|
142
|
-
"cacheCreationTokens"
|
|
143
|
-
];
|
|
144
|
-
var COST_COMPONENT_FIELDS = [
|
|
145
|
-
"input",
|
|
146
|
-
"output",
|
|
147
|
-
"cacheRead",
|
|
148
|
-
"cacheWrite"
|
|
149
|
-
];
|
|
150
|
-
function hasAgentTurnUsage(usage) {
|
|
151
|
-
return Boolean(
|
|
152
|
-
usage && (Object.entries(usage).some(
|
|
153
|
-
([field, value]) => field !== "cost" && typeof value === "number" && Number.isFinite(value)
|
|
154
|
-
) || Object.values(usage.cost ?? {}).some(
|
|
155
|
-
(value) => typeof value === "number" && Number.isFinite(value)
|
|
156
|
-
))
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
function getFiniteCount(value) {
|
|
160
|
-
return typeof value === "number" && Number.isFinite(value) ? Math.max(0, Math.floor(value)) : void 0;
|
|
161
|
-
}
|
|
162
|
-
function getFiniteCost(value) {
|
|
163
|
-
return typeof value === "number" && Number.isFinite(value) ? Math.max(0, value) : void 0;
|
|
164
|
-
}
|
|
165
|
-
function addCost(left, right) {
|
|
166
|
-
return Math.round(((left ?? 0) + right) * 1e12) / 1e12;
|
|
167
|
-
}
|
|
168
|
-
function getComponentTotal(usage) {
|
|
169
|
-
let total;
|
|
170
|
-
for (const field of COMPONENT_USAGE_FIELDS) {
|
|
171
|
-
const value = getFiniteCount(usage[field]);
|
|
172
|
-
if (value === void 0) continue;
|
|
173
|
-
total = (total ?? 0) + value;
|
|
174
|
-
}
|
|
175
|
-
return total;
|
|
176
|
-
}
|
|
177
|
-
function agentTurnCostUsd(usage) {
|
|
178
|
-
if (!usage?.cost) return void 0;
|
|
179
|
-
const total = getFiniteCost(usage.cost.total);
|
|
180
|
-
if (total !== void 0) return total;
|
|
181
|
-
let componentTotal = 0;
|
|
182
|
-
let hasComponent = false;
|
|
183
|
-
for (const field of COST_COMPONENT_FIELDS) {
|
|
184
|
-
const value = getFiniteCost(usage.cost[field]);
|
|
185
|
-
if (value === void 0) continue;
|
|
186
|
-
hasComponent = true;
|
|
187
|
-
componentTotal = addCost(componentTotal, value);
|
|
188
|
-
}
|
|
189
|
-
return hasComponent ? componentTotal : void 0;
|
|
190
|
-
}
|
|
191
|
-
function agentTurnTotalTokens(usage) {
|
|
192
|
-
if (!usage) return void 0;
|
|
193
|
-
const componentTotal = getComponentTotal(usage);
|
|
194
|
-
if (componentTotal !== void 0) return componentTotal;
|
|
195
|
-
return getFiniteCount(usage.totalTokens);
|
|
196
|
-
}
|
|
197
|
-
function addAgentTurnUsage(...usages) {
|
|
198
|
-
const components = {};
|
|
199
|
-
let componentTotal;
|
|
200
|
-
let totalOnlyTokens;
|
|
201
|
-
let reasoningTokens;
|
|
202
|
-
const cost = {};
|
|
203
|
-
for (const usage of usages) {
|
|
204
|
-
if (!usage) continue;
|
|
205
|
-
const reasoning = getFiniteCount(usage.reasoningTokens);
|
|
206
|
-
if (reasoning !== void 0) {
|
|
207
|
-
reasoningTokens = (reasoningTokens ?? 0) + reasoning;
|
|
208
|
-
}
|
|
209
|
-
if (usage.cost) {
|
|
210
|
-
for (const field of [...COST_COMPONENT_FIELDS, "total"]) {
|
|
211
|
-
const value = getFiniteCost(usage.cost[field]);
|
|
212
|
-
if (value === void 0) continue;
|
|
213
|
-
cost[field] = addCost(cost[field], value);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
const usageComponentTotal = getComponentTotal(usage);
|
|
217
|
-
if (usageComponentTotal !== void 0) {
|
|
218
|
-
componentTotal = (componentTotal ?? 0) + usageComponentTotal;
|
|
219
|
-
for (const field of COMPONENT_USAGE_FIELDS) {
|
|
220
|
-
const value = getFiniteCount(usage[field]);
|
|
221
|
-
if (value === void 0) continue;
|
|
222
|
-
components[field] = (components[field] ?? 0) + value;
|
|
223
|
-
}
|
|
224
|
-
continue;
|
|
225
|
-
}
|
|
226
|
-
const totalTokens = getFiniteCount(usage.totalTokens);
|
|
227
|
-
if (totalTokens !== void 0) {
|
|
228
|
-
totalOnlyTokens = (totalOnlyTokens ?? 0) + totalTokens;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
if (totalOnlyTokens !== void 0) {
|
|
232
|
-
return {
|
|
233
|
-
totalTokens: totalOnlyTokens + (componentTotal ?? 0),
|
|
234
|
-
...reasoningTokens !== void 0 ? { reasoningTokens } : void 0,
|
|
235
|
-
...Object.keys(cost).length > 0 ? { cost } : void 0
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
const result = {
|
|
239
|
-
...components,
|
|
240
|
-
...reasoningTokens !== void 0 ? { reasoningTokens } : void 0,
|
|
241
|
-
...Object.keys(cost).length > 0 ? { cost } : void 0
|
|
242
|
-
};
|
|
243
|
-
return hasAgentTurnUsage(result) ? result : void 0;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
// src/chat/services/short-title.ts
|
|
247
|
-
var SHORT_TITLE_MAX_LENGTH = 60;
|
|
248
|
-
var TITLE_PROMPTS = {
|
|
249
|
-
conversation: [
|
|
250
|
-
"Generate a concise 5-8 word conversation title from the first user message below.",
|
|
251
|
-
"Capture the user's main request.",
|
|
252
|
-
"Reply with ONLY the title, with no quotes or trailing punctuation."
|
|
253
|
-
],
|
|
254
|
-
task: [
|
|
255
|
-
"Generate a concise 5-8 word task title from the task instruction below.",
|
|
256
|
-
"Capture the task's main purpose.",
|
|
257
|
-
"Reply with ONLY the title, with no quotes or trailing punctuation."
|
|
258
|
-
]
|
|
259
|
-
};
|
|
260
|
-
function normalizeShortTitle(value) {
|
|
261
|
-
return value.replace(/\s+/g, " ").trim().slice(0, SHORT_TITLE_MAX_LENGTH);
|
|
262
|
-
}
|
|
263
|
-
function fallbackShortTitle(sourceText, fallback = "Untitled") {
|
|
264
|
-
const firstLine = sourceText.split(/\r?\n/).map((line) => line.trim()).find((line) => line.length > 0) ?? "";
|
|
265
|
-
return normalizeShortTitle(firstLine) || fallback;
|
|
266
|
-
}
|
|
267
|
-
async function generateShortTitle(args) {
|
|
268
|
-
const sourceText = args.sourceText.trim();
|
|
269
|
-
if (!sourceText) return void 0;
|
|
270
|
-
try {
|
|
271
|
-
const result = await args.completeText({
|
|
272
|
-
modelId: botConfig.fastModelId,
|
|
273
|
-
temperature: 0,
|
|
274
|
-
promptName: `junior.${args.kind}_title`,
|
|
275
|
-
messages: [
|
|
276
|
-
{
|
|
277
|
-
role: "user",
|
|
278
|
-
content: [
|
|
279
|
-
...TITLE_PROMPTS[args.kind],
|
|
280
|
-
"",
|
|
281
|
-
args.kind === "conversation" ? `First user message: ${sourceText.slice(0, 500)}` : `Task instruction: ${sourceText.slice(0, 500)}`
|
|
282
|
-
].join("\n"),
|
|
283
|
-
timestamp: Date.now()
|
|
284
|
-
}
|
|
285
|
-
],
|
|
286
|
-
metadata: {
|
|
287
|
-
modelId: botConfig.fastModelId
|
|
288
|
-
}
|
|
289
|
-
});
|
|
290
|
-
const title = normalizeShortTitle(result.text);
|
|
291
|
-
return title || void 0;
|
|
292
|
-
} catch (error) {
|
|
293
|
-
logWarn(`${args.kind}.title.generation.failed`, {
|
|
294
|
-
"exception.message": error instanceof Error ? error.message : String(error)
|
|
295
|
-
});
|
|
296
|
-
return void 0;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
async function resolveTaskTitle(args) {
|
|
300
|
-
const explicit = normalizeShortTitle(args.title ?? "");
|
|
301
|
-
if (explicit) return explicit;
|
|
302
|
-
return generateShortTitle({
|
|
303
|
-
completeText: args.completeText,
|
|
304
|
-
kind: "task",
|
|
305
|
-
sourceText: args.instruction
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
// src/chat/tools/execution/tool-input-error.ts
|
|
310
|
-
var ToolInputError = class extends Error {
|
|
311
|
-
constructor(message, options) {
|
|
312
|
-
super(message, options);
|
|
313
|
-
this.name = "ToolInputError";
|
|
314
|
-
}
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
export {
|
|
318
|
-
JUNIOR_NATIVE_EVENT_NAMESPACE,
|
|
319
|
-
authenticationLinkedEvent,
|
|
320
|
-
authenticationUnlinkedEvent,
|
|
321
|
-
agentsInstructionsUpdatedEvent,
|
|
322
|
-
renderJuniorNativeConversationEvent,
|
|
323
|
-
SHORT_TITLE_MAX_LENGTH,
|
|
324
|
-
fallbackShortTitle,
|
|
325
|
-
generateShortTitle,
|
|
326
|
-
resolveTaskTitle,
|
|
327
|
-
ToolInputError,
|
|
328
|
-
agentTurnUsageSchema,
|
|
329
|
-
hasAgentTurnUsage,
|
|
330
|
-
agentTurnCostUsd,
|
|
331
|
-
agentTurnTotalTokens,
|
|
332
|
-
addAgentTurnUsage
|
|
333
|
-
};
|