@sentry/junior 0.210.2 → 0.212.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-DruBLdjK.js → agent-Cgc7jAIH.js} +353 -21
- package/dist/{agent-hooks-BYZAFpgB.js → agent-hooks-B2Yt2b88.js} +207 -47
- package/dist/{agent-runner-Be5K-k2o.js → agent-runner-CkNX-ynf.js} +5 -5
- package/dist/api/schema.js +2 -2
- package/dist/api.d.ts +1 -1
- package/dist/api.js +72 -33
- package/dist/{app-gyu3D9Gn.d.ts → app-D4nNdzPG.d.ts} +1 -1
- package/dist/app.d.ts +1 -1
- package/dist/app.js +32 -32
- package/dist/{auth-pause-state-DedOKgr4.js → auth-pause-state-BbcDkPac.js} +6 -6
- package/dist/{briefs-CQDK-Dj2.js → briefs-4-OVELML.js} +4 -4
- package/dist/{catalog-runtime-Ddk0rxU3.js → catalog-runtime-BvN_lNVo.js} +1 -1
- package/dist/{checkpoint-Cto3lP0d.js → checkpoint-EAQ5Xerb.js} +151 -528
- package/dist/cli/chat.js +13 -13
- package/dist/cli/check.js +3 -3
- package/dist/cli/main.js +1 -1
- package/dist/cli/plugins.js +3 -3
- package/dist/cli/snapshot-create.js +3 -3
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +3 -3
- package/dist/{client-Dstl8V7v.js → client-C1KycWNq.js} +2 -2
- package/dist/{config-QWyCRQ8L.js → config-C0-PnQoF.js} +2 -2
- package/dist/{conversation-AA4R1VUn.js → conversation-CRWntH-A.js} +19 -19
- package/dist/{conversation-privacy-BIClFm9b.js → conversation-privacy-BFzYxnTS.js} +1 -1
- package/dist/{credential-sync-MFTk0Zba.js → credential-sync-CZz6Vk6X.js} +20 -20
- package/dist/{db-D74z7BZH.d.ts → db-Ca9Nt5ci.d.ts} +1 -1
- package/dist/{execution-stats-BEax3h2o.js → execution-stats-CoDjBQbE.js} +3 -4
- package/dist/{executor-C5onDgaC.js → executor-CaVeGYeA.js} +39 -2
- package/dist/instrumentation.js +2 -2
- package/dist/{job-queue-Dpfxr7U6.js → job-queue-BhaNX9DL.js} +1 -1
- package/dist/{logging-CKkKExae.js → logging-B5-PLvDo.js} +1 -1
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +3 -3
- package/dist/{oauth-callback-server-W_3TiFJo.js → oauth-callback-server-G5q7i0Qp.js} +2 -2
- package/dist/{pending-auth-CUOLqzoR.js → pending-auth-CDndLOLO.js} +2 -2
- package/dist/{profile-DU-tdAeS.js → profile-BcZ6EBQ4.js} +4 -4
- package/dist/{prompt-C1IA4qkj.js → prompt-kRlibHYT.js} +1 -1
- package/dist/{registry-BiaaVqDO.js → registry-BIeo1ST6.js} +1 -1
- package/dist/{resolve-B178kFFr.js → resolve-BgAZ4KxF.js} +2 -2
- package/dist/{runner-CEw5Bd40.js → runner-Cqd0EG3G.js} +10 -10
- package/dist/{sandbox-egress-signals-R9n0mBQr.js → sandbox-egress-signals-DrOoklMj.js} +1 -1
- package/dist/{schema-CwTeb-BF.js → schema-xHUgeh46.js} +1 -1
- package/dist/short-title-CxQHLU3_.js +65 -0
- package/dist/{skills-DNxkkZnA.js → skills-DlrAH1on.js} +2 -2
- package/dist/{spawn-D_d9fLq3.js → spawn-BtMqHjwx.js} +2 -2
- package/dist/{stats-BvEUKgru.js → stats-D5OWazLs.js} +15 -7
- package/dist/{store-Det8MQ9g.d.ts → store-DoewL5mG.d.ts} +3 -2
- package/dist/{task-queue-DkaL57J_.js → task-queue-C-o2Q4O-.js} +3 -3
- package/dist/{task-runner-DDuflo-o.js → task-runner-Mt_TGUBH.js} +8 -8
- package/dist/{thread-state-fcmz8adQ.js → thread-state-C81fvhJu.js} +5 -5
- package/dist/{turn-execution-BNKloE6i.js → turn-execution-Ruj9SSJU.js} +3 -3
- package/dist/{turn-lifecycle-BEcSsBf7.js → turn-lifecycle-xIZNwgaq.js} +1 -1
- package/dist/{validation-CgH5VUx2.js → validation-sgYqCVwr.js} +1 -1
- package/dist/{version-CS4pJjG8.js → version-BE7Zf9Wx.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{web-authorization-D2ts7w_1.js → web-authorization-BXrGezGm.js} +1 -1
- package/dist/{web-input-Bxb1i41z.js → web-input-FJ7NNJDx.js} +4 -4
- package/dist/{work-HzD-98Ng.js → work-DlYdbVfB.js} +9 -9
- package/dist/{worker-DWDTNdyB.js → worker-BfxedsTU.js} +5 -5
- package/migrations/0042_conversation_metrics.sql +26 -0
- package/migrations/meta/0042_snapshot.json +3610 -0
- package/migrations/meta/_journal.json +7 -0
- package/package.json +5 -5
- package/dist/usage-BU5d5wmV.js +0 -175
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
|
|
2
|
-
import { a as embedTexts, r as completeObject } from "./client-
|
|
3
|
-
import { C as withSpan, P as normalizeIdentityEmail, _ as setSpanAttributes, d as logInfo, f as logWarn, u as logException, v as setSpanStatus } from "./logging-
|
|
2
|
+
import { a as embedTexts, r as completeObject } from "./client-C1KycWNq.js";
|
|
3
|
+
import { C as withSpan, P as normalizeIdentityEmail, _ as setSpanAttributes, d as logInfo, f as logWarn, u as logException, v as setSpanStatus } from "./logging-B5-PLvDo.js";
|
|
4
4
|
import { a as getClient$1 } from "./sentry-CgWZM_kV.js";
|
|
5
|
-
import { t as canExposeConversationPayload } from "./conversation-privacy-
|
|
6
|
-
import { a as getChatConfig, n as botConfig, s as getSlackBotToken } from "./config-
|
|
5
|
+
import { t as canExposeConversationPayload } from "./conversation-privacy-BFzYxnTS.js";
|
|
6
|
+
import { a as getChatConfig, n as botConfig, s as getSlackBotToken } from "./config-C0-PnQoF.js";
|
|
7
7
|
import { n as defaultModelId } from "./model-profile-CZmVoGdX.js";
|
|
8
8
|
import { _ as parseSlackMessageTs, c as isActorUserId, h as parseSlackTeamId, m as parseSlackChannelReferenceId, u as parseActorUserId } from "./context-Bplcgypl.js";
|
|
9
9
|
import { n as juniorDestinations } from "./destinations-BeBiJeEM.js";
|
|
10
|
-
import { C as
|
|
11
|
-
import { B as
|
|
12
|
-
import { A as sleep$1, P as SANDBOX_WORKSPACE_ROOT, l as isSandboxMissingError, n as hash, v as getVercelSandboxCredentials, w as getStateAdapter, x as runNonInteractiveCommand } from "./profile-
|
|
13
|
-
import { n as briefEntriesFromReportEvents, s as generateBrief, t as BRIEF_PROMPT } from "./prompt-
|
|
10
|
+
import { C as juniorCodeRepositories, D as juniorIdentities, E as juniorConversations, O as juniorUsers, S as juniorCodeChanges, T as conversationReadColumns, _ as CONVERSATION_METRICS, g as juniorConversationBriefs, h as juniorConversationBindings, i as juniorWorkspaces, m as juniorConversationParticipants, n as juniorSnapshots, r as juniorWorkspaceRepos, t as createJuniorSqlExecutor, v as juniorConversationMetrics, x as juniorConversationAnnotations, y as juniorConversationEvents } from "./executor-CaVeGYeA.js";
|
|
11
|
+
import { B as historyReplacementSchema, C as conversationReportEventSchema, I as conversationEventDataSchema, K as usageSchema, M as conversationBriefSchema, N as parseBriefInput, V as newConversationEventSchema, z as decodeStoredConversationEvent } from "./conversation-CRWntH-A.js";
|
|
12
|
+
import { A as sleep$1, P as SANDBOX_WORKSPACE_ROOT, l as isSandboxMissingError, n as hash, v as getVercelSandboxCredentials, w as getStateAdapter, x as runNonInteractiveCommand } from "./profile-BcZ6EBQ4.js";
|
|
13
|
+
import { n as briefEntriesFromReportEvents, s as generateBrief, t as BRIEF_PROMPT } from "./prompt-kRlibHYT.js";
|
|
14
14
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
15
15
|
import { z } from "zod";
|
|
16
16
|
import { createHash, createHmac, randomUUID, timingSafeEqual } from "node:crypto";
|
|
@@ -191,6 +191,190 @@ async function recordConversationParticipant(executor, args) {
|
|
|
191
191
|
});
|
|
192
192
|
}
|
|
193
193
|
//#endregion
|
|
194
|
+
//#region src/chat/usage.ts
|
|
195
|
+
const agentTurnUsageSchema = usageSchema;
|
|
196
|
+
const COMPONENT_USAGE_FIELDS = [
|
|
197
|
+
"inputTokens",
|
|
198
|
+
"outputTokens",
|
|
199
|
+
"cachedInputTokens",
|
|
200
|
+
"cacheCreationTokens"
|
|
201
|
+
];
|
|
202
|
+
const COST_COMPONENT_FIELDS = [
|
|
203
|
+
"input",
|
|
204
|
+
"output",
|
|
205
|
+
"cacheRead",
|
|
206
|
+
"cacheWrite"
|
|
207
|
+
];
|
|
208
|
+
/** Return whether any token counter is present on a usage record. */
|
|
209
|
+
function hasAgentTurnUsage(usage) {
|
|
210
|
+
return Boolean(usage && (Object.entries(usage).some(([field, value]) => field !== "cost" && typeof value === "number" && Number.isFinite(value)) || Object.values(usage.cost ?? {}).some((value) => typeof value === "number" && Number.isFinite(value))));
|
|
211
|
+
}
|
|
212
|
+
function getFiniteCount(value) {
|
|
213
|
+
return typeof value === "number" && Number.isFinite(value) ? Math.max(0, Math.floor(value)) : void 0;
|
|
214
|
+
}
|
|
215
|
+
function getFiniteCost(value) {
|
|
216
|
+
return typeof value === "number" && Number.isFinite(value) ? Math.max(0, value) : void 0;
|
|
217
|
+
}
|
|
218
|
+
function addCost(left, right) {
|
|
219
|
+
return Math.round(((left ?? 0) + right) * 0xe8d4a51000) / 0xe8d4a51000;
|
|
220
|
+
}
|
|
221
|
+
function getComponentTotal(usage) {
|
|
222
|
+
let total;
|
|
223
|
+
for (const field of COMPONENT_USAGE_FIELDS) {
|
|
224
|
+
const value = getFiniteCount(usage[field]);
|
|
225
|
+
if (value === void 0) continue;
|
|
226
|
+
total = (total ?? 0) + value;
|
|
227
|
+
}
|
|
228
|
+
return total;
|
|
229
|
+
}
|
|
230
|
+
/** Estimated total USD cost from one usage record, when any cost field is present. */
|
|
231
|
+
function agentTurnCostUsd(usage) {
|
|
232
|
+
if (!usage?.cost) return void 0;
|
|
233
|
+
const total = getFiniteCost(usage.cost.total);
|
|
234
|
+
if (total !== void 0) return total;
|
|
235
|
+
let componentTotal = 0;
|
|
236
|
+
let hasComponent = false;
|
|
237
|
+
for (const field of COST_COMPONENT_FIELDS) {
|
|
238
|
+
const value = getFiniteCost(usage.cost[field]);
|
|
239
|
+
if (value === void 0) continue;
|
|
240
|
+
hasComponent = true;
|
|
241
|
+
componentTotal = addCost(componentTotal, value);
|
|
242
|
+
}
|
|
243
|
+
return hasComponent ? componentTotal : void 0;
|
|
244
|
+
}
|
|
245
|
+
/** Total token count from one usage record, preferring component counters. */
|
|
246
|
+
function agentTurnTotalTokens(usage) {
|
|
247
|
+
if (!usage) return void 0;
|
|
248
|
+
const componentTotal = getComponentTotal(usage);
|
|
249
|
+
if (componentTotal !== void 0) return componentTotal;
|
|
250
|
+
return getFiniteCount(usage.totalTokens);
|
|
251
|
+
}
|
|
252
|
+
/** Aggregate token usage across slices without double-counting provider totals. */
|
|
253
|
+
function addAgentTurnUsage(...usages) {
|
|
254
|
+
const components = {};
|
|
255
|
+
let componentTotal;
|
|
256
|
+
let totalOnlyTokens;
|
|
257
|
+
let reasoningTokens;
|
|
258
|
+
const cost = {};
|
|
259
|
+
for (const usage of usages) {
|
|
260
|
+
if (!usage) continue;
|
|
261
|
+
const reasoning = getFiniteCount(usage.reasoningTokens);
|
|
262
|
+
if (reasoning !== void 0) reasoningTokens = (reasoningTokens ?? 0) + reasoning;
|
|
263
|
+
if (usage.cost) for (const field of [...COST_COMPONENT_FIELDS, "total"]) {
|
|
264
|
+
const value = getFiniteCost(usage.cost[field]);
|
|
265
|
+
if (value === void 0) continue;
|
|
266
|
+
cost[field] = addCost(cost[field], value);
|
|
267
|
+
}
|
|
268
|
+
const usageComponentTotal = getComponentTotal(usage);
|
|
269
|
+
if (usageComponentTotal !== void 0) {
|
|
270
|
+
componentTotal = (componentTotal ?? 0) + usageComponentTotal;
|
|
271
|
+
for (const field of COMPONENT_USAGE_FIELDS) {
|
|
272
|
+
const value = getFiniteCount(usage[field]);
|
|
273
|
+
if (value === void 0) continue;
|
|
274
|
+
components[field] = (components[field] ?? 0) + value;
|
|
275
|
+
}
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
const totalTokens = getFiniteCount(usage.totalTokens);
|
|
279
|
+
if (totalTokens !== void 0) totalOnlyTokens = (totalOnlyTokens ?? 0) + totalTokens;
|
|
280
|
+
}
|
|
281
|
+
if (totalOnlyTokens !== void 0) return {
|
|
282
|
+
totalTokens: totalOnlyTokens + (componentTotal ?? 0),
|
|
283
|
+
...reasoningTokens !== void 0 ? { reasoningTokens } : void 0,
|
|
284
|
+
...Object.keys(cost).length > 0 ? { cost } : void 0
|
|
285
|
+
};
|
|
286
|
+
const result = {
|
|
287
|
+
...components,
|
|
288
|
+
...reasoningTokens !== void 0 ? { reasoningTokens } : void 0,
|
|
289
|
+
...Object.keys(cost).length > 0 ? { cost } : void 0
|
|
290
|
+
};
|
|
291
|
+
return hasAgentTurnUsage(result) ? result : void 0;
|
|
292
|
+
}
|
|
293
|
+
//#endregion
|
|
294
|
+
//#region src/chat/conversations/metrics.ts
|
|
295
|
+
function finite(value) {
|
|
296
|
+
return value !== void 0 && Number.isFinite(value) && value >= 0 ? value : void 0;
|
|
297
|
+
}
|
|
298
|
+
/** Convert one Run summary to metric rows. */
|
|
299
|
+
function conversationMetricValues(args) {
|
|
300
|
+
const usage = args.usage;
|
|
301
|
+
return {
|
|
302
|
+
duration_ms: Math.max(0, args.durationMs),
|
|
303
|
+
total_tokens: agentTurnTotalTokens(usage),
|
|
304
|
+
input_tokens: finite(usage?.inputTokens),
|
|
305
|
+
output_tokens: finite(usage?.outputTokens),
|
|
306
|
+
cached_input_tokens: finite(usage?.cachedInputTokens),
|
|
307
|
+
cache_creation_tokens: finite(usage?.cacheCreationTokens),
|
|
308
|
+
reasoning_tokens: finite(usage?.reasoningTokens),
|
|
309
|
+
cost_usd: agentTurnCostUsd(usage)
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
/** Replace one Run's metric rows and refresh its Conversation totals. */
|
|
313
|
+
async function replaceConversationMetrics(executor, args) {
|
|
314
|
+
const [current] = await executor.db().select({ updatedAt: juniorConversationMetrics.updatedAt }).from(juniorConversationMetrics).where(and(eq(juniorConversationMetrics.conversationId, args.conversationId), eq(juniorConversationMetrics.runId, args.runId))).limit(1);
|
|
315
|
+
if (current && current.updatedAt.getTime() > args.updatedAtMs) return;
|
|
316
|
+
await executor.db().delete(juniorConversationMetrics).where(and(eq(juniorConversationMetrics.conversationId, args.conversationId), eq(juniorConversationMetrics.runId, args.runId)));
|
|
317
|
+
const metricValues = conversationMetricValues({
|
|
318
|
+
durationMs: args.durationMs,
|
|
319
|
+
usage: args.usage
|
|
320
|
+
});
|
|
321
|
+
const values = CONVERSATION_METRICS.flatMap((metric) => {
|
|
322
|
+
const value = metricValues[metric];
|
|
323
|
+
return value === void 0 ? [] : [{
|
|
324
|
+
conversationId: args.conversationId,
|
|
325
|
+
runId: args.runId,
|
|
326
|
+
metric,
|
|
327
|
+
value,
|
|
328
|
+
occurredAt: new Date(args.occurredAtMs),
|
|
329
|
+
updatedAt: new Date(args.updatedAtMs)
|
|
330
|
+
}];
|
|
331
|
+
});
|
|
332
|
+
if (values.length > 0) await executor.db().insert(juniorConversationMetrics).values(values);
|
|
333
|
+
const metric = (name) => sql`(
|
|
334
|
+
select sum(${juniorConversationMetrics.value})
|
|
335
|
+
from ${juniorConversationMetrics}
|
|
336
|
+
where ${juniorConversationMetrics.conversationId} = ${args.conversationId}
|
|
337
|
+
and ${juniorConversationMetrics.metric} = ${name}
|
|
338
|
+
)`;
|
|
339
|
+
const totalTokens = metric("total_tokens");
|
|
340
|
+
const componentTokens = sql`
|
|
341
|
+
coalesce(${metric("input_tokens")}, 0)
|
|
342
|
+
+ coalesce(${metric("output_tokens")}, 0)
|
|
343
|
+
+ coalesce(${metric("cached_input_tokens")}, 0)
|
|
344
|
+
+ coalesce(${metric("cache_creation_tokens")}, 0)
|
|
345
|
+
`;
|
|
346
|
+
const hasComponents = sql`
|
|
347
|
+
${metric("input_tokens")} is not null
|
|
348
|
+
or ${metric("output_tokens")} is not null
|
|
349
|
+
or ${metric("cached_input_tokens")} is not null
|
|
350
|
+
or ${metric("cache_creation_tokens")} is not null
|
|
351
|
+
`;
|
|
352
|
+
const cost = sql`case when ${metric("cost_usd")} is null then null
|
|
353
|
+
else jsonb_build_object('total', ${metric("cost_usd")}) end`;
|
|
354
|
+
await executor.db().update(juniorConversations).set({
|
|
355
|
+
durationMs: sql`coalesce(${metric("duration_ms")}, 0)`,
|
|
356
|
+
usage: sql`case
|
|
357
|
+
when ${totalTokens} is not null
|
|
358
|
+
and (${hasComponents})
|
|
359
|
+
and ${totalTokens} <> ${componentTokens}
|
|
360
|
+
then jsonb_strip_nulls(jsonb_build_object(
|
|
361
|
+
'totalTokens', ${totalTokens},
|
|
362
|
+
'reasoningTokens', ${metric("reasoning_tokens")},
|
|
363
|
+
'cost', ${cost}
|
|
364
|
+
))
|
|
365
|
+
else jsonb_strip_nulls(jsonb_build_object(
|
|
366
|
+
'totalTokens', ${totalTokens},
|
|
367
|
+
'inputTokens', ${metric("input_tokens")},
|
|
368
|
+
'outputTokens', ${metric("output_tokens")},
|
|
369
|
+
'cachedInputTokens', ${metric("cached_input_tokens")},
|
|
370
|
+
'cacheCreationTokens', ${metric("cache_creation_tokens")},
|
|
371
|
+
'reasoningTokens', ${metric("reasoning_tokens")},
|
|
372
|
+
'cost', ${cost}
|
|
373
|
+
))
|
|
374
|
+
end`
|
|
375
|
+
}).where(eq(juniorConversations.conversationId, args.conversationId));
|
|
376
|
+
}
|
|
377
|
+
//#endregion
|
|
194
378
|
//#region src/chat/source.ts
|
|
195
379
|
/**
|
|
196
380
|
* Normalize a Turn Source into legacy provider fields stored on a Conversation.
|
|
@@ -522,29 +706,6 @@ function assertSameConversationDestination(args) {
|
|
|
522
706
|
if (!args.current || sameDestination(args.current, args.next)) return;
|
|
523
707
|
throw new Error(`Conversation destination changed for ${args.conversationId}`);
|
|
524
708
|
}
|
|
525
|
-
function tokenTotal(usage) {
|
|
526
|
-
if (!usage) return 0;
|
|
527
|
-
if (usage.totalTokens !== void 0) return usage.totalTokens;
|
|
528
|
-
return (usage.inputTokens ?? 0) + (usage.outputTokens ?? 0) + (usage.cachedInputTokens ?? 0) + (usage.cacheCreationTokens ?? 0);
|
|
529
|
-
}
|
|
530
|
-
function updateConversationUsage(args) {
|
|
531
|
-
const usage = { totalTokens: tokenTotal(args.current) - tokenTotal(args.previousExecution) + tokenTotal(args.nextExecution) };
|
|
532
|
-
if (args.current?.reasoningTokens !== void 0 || args.previousExecution?.reasoningTokens !== void 0 || args.nextExecution.reasoningTokens !== void 0) usage.reasoningTokens = (args.current?.reasoningTokens ?? 0) - (args.previousExecution?.reasoningTokens ?? 0) + (args.nextExecution.reasoningTokens ?? 0);
|
|
533
|
-
const costFields = [
|
|
534
|
-
"input",
|
|
535
|
-
"output",
|
|
536
|
-
"cacheRead",
|
|
537
|
-
"cacheWrite",
|
|
538
|
-
"total"
|
|
539
|
-
];
|
|
540
|
-
const cost = {};
|
|
541
|
-
for (const field of costFields) {
|
|
542
|
-
if (args.current?.cost?.[field] === void 0 && args.previousExecution?.cost?.[field] === void 0 && args.nextExecution.cost?.[field] === void 0) continue;
|
|
543
|
-
cost[field] = Math.round(((args.current?.cost?.[field] ?? 0) - (args.previousExecution?.cost?.[field] ?? 0) + (args.nextExecution.cost?.[field] ?? 0)) * 0xe8d4a51000) / 0xe8d4a51000;
|
|
544
|
-
}
|
|
545
|
-
if (Object.keys(cost).length > 0) usage.cost = cost;
|
|
546
|
-
return usage;
|
|
547
|
-
}
|
|
548
709
|
var SqlStore = class {
|
|
549
710
|
executor;
|
|
550
711
|
constructor(executor) {
|
|
@@ -623,13 +784,13 @@ var SqlStore = class {
|
|
|
623
784
|
});
|
|
624
785
|
}
|
|
625
786
|
async recordExecution(args) {
|
|
787
|
+
if (args.metrics && !args.execution.runId) throw new Error("Conversation Run metrics require a Run id");
|
|
626
788
|
await this.withConversationMutation(args.conversationId, async () => {
|
|
627
789
|
const existingRow = await this.readConversationRow(args.conversationId);
|
|
628
790
|
const existing = existingRow ? conversationFromRow(existingRow) : void 0;
|
|
629
791
|
if (!existing && !args.destination) return;
|
|
630
|
-
const
|
|
631
|
-
const
|
|
632
|
-
const sameRun = Boolean(metricRunId) && metricRunId === args.execution.runId;
|
|
792
|
+
const incomingExecutionAt = args.execution.updatedAtMs ?? args.updatedAtMs;
|
|
793
|
+
const incomingIsFresh = incomingExecutionAt >= (existing?.execution.updatedAtMs ?? existing?.updatedAtMs ?? 0);
|
|
633
794
|
const execution = incomingIsFresh ? args.execution : existing?.execution ?? args.execution;
|
|
634
795
|
await this.upsertConversation({ conversation: {
|
|
635
796
|
schemaVersion: 1,
|
|
@@ -647,19 +808,18 @@ var SqlStore = class {
|
|
|
647
808
|
...args.visibility ? { visibility: args.visibility } : void 0,
|
|
648
809
|
execution
|
|
649
810
|
} });
|
|
650
|
-
if (
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
metricRunId: args.execution.runId ?? null,
|
|
811
|
+
if (args.metrics && args.execution.runId) {
|
|
812
|
+
await replaceConversationMetrics(this.executor, {
|
|
813
|
+
conversationId: args.conversationId,
|
|
814
|
+
runId: args.execution.runId,
|
|
815
|
+
occurredAtMs: args.createdAtMs,
|
|
816
|
+
updatedAtMs: incomingExecutionAt,
|
|
817
|
+
...args.metrics
|
|
818
|
+
});
|
|
819
|
+
if (incomingIsFresh) await this.executor.db().update(juniorConversations).set({
|
|
820
|
+
metricRunId: args.execution.runId,
|
|
661
821
|
executionDurationMs: args.metrics.durationMs,
|
|
662
|
-
executionUsage: args.metrics.usage ??
|
|
822
|
+
executionUsage: args.metrics.usage ?? null
|
|
663
823
|
}).where(eq(juniorConversations.conversationId, args.conversationId));
|
|
664
824
|
}
|
|
665
825
|
});
|
|
@@ -5232,4 +5392,4 @@ function createPluginHookRunner(input = {}) {
|
|
|
5232
5392
|
};
|
|
5233
5393
|
}
|
|
5234
5394
|
//#endregion
|
|
5235
|
-
export { resolveViewerUser as $, parseSessionSource as $t, tryWorkspaceRepoCheckoutPath as A, createPluginConversationEvents as At, downloadPrivateSlackFile as B, authenticationUnlinkedEvent as Bt, invalidateReadySnapshot as C, conversationArchivedForEmail as Ct, SANDBOX_RUNTIME as D, conversationNotArchivedForEmail as Dt, setWorkspaceSnapshotBuild as E, conversationHasParticipantUser as Et, bindSlackDirectCredentialSubject as F, listConversationAnnotations as Ft, isDmChannel as G, getDb as Gt, getHeaderString as H, getConversationEventStore as Ht, verifyEventAutomationCredentialSubject as I, listConversationAnnotationsById as It, withSlackRetries as J, withConversationEventLock as Jt, normalizeSlackConversationId as K, getSqlExecutor as Kt, verifyScheduledAutomationCredentialSubject as L, JUNIOR_NATIVE_EVENT_NAMESPACE as Lt, resolveChannelCapabilities as M, readConversationEventPage as Mt, bindEventAutomationCredentialSubject as N, buildSentryConversationUrl as Nt, deleteWorkspaceSnapshotBuilders as O, conversationNotArchivedForUser as Ot, bindScheduledAutomationCredentialSubject as P, resolveRootVisibility as Pt, readActorIdentity as Q, bindProviderConversation as Qt, verifySlackDirectCredentialSubject as R, agentsInstructionsUpdatedEvent as Rt, WorkspaceValidationError as S, conversationArchiveTimes as St, setWorkspaceSnapshot as T, conversationHasParticipantEmail as Tt, getSlackClient as U, getConversationMessageSearchStore as Ut, getFilePermalink as V, db_exports as Vt, isConversationScopedChannel as W, getConversationStore as Wt, runWithWorkspaceTeamId as X, withConversationMutationLock as Xt, getWorkspaceTeamId as Y, sanitizePostgresJson as Yt, findUserByEmail as Z, locationFromRow as Zt, deleteWorkspace as _, createPluginState as _t, getPluginRoutes as a,
|
|
5395
|
+
export { resolveViewerUser as $, parseSessionSource as $t, tryWorkspaceRepoCheckoutPath as A, createPluginConversationEvents as At, downloadPrivateSlackFile as B, authenticationUnlinkedEvent as Bt, invalidateReadySnapshot as C, conversationArchivedForEmail as Ct, SANDBOX_RUNTIME as D, conversationNotArchivedForEmail as Dt, setWorkspaceSnapshotBuild as E, conversationHasParticipantUser as Et, bindSlackDirectCredentialSubject as F, listConversationAnnotations as Ft, isDmChannel as G, getDb as Gt, getHeaderString as H, getConversationEventStore as Ht, verifyEventAutomationCredentialSubject as I, listConversationAnnotationsById as It, withSlackRetries as J, withConversationEventLock as Jt, normalizeSlackConversationId as K, getSqlExecutor as Kt, verifyScheduledAutomationCredentialSubject as L, JUNIOR_NATIVE_EVENT_NAMESPACE as Lt, resolveChannelCapabilities as M, readConversationEventPage as Mt, bindEventAutomationCredentialSubject as N, buildSentryConversationUrl as Nt, deleteWorkspaceSnapshotBuilders as O, conversationNotArchivedForUser as Ot, bindScheduledAutomationCredentialSubject as P, resolveRootVisibility as Pt, readActorIdentity as Q, bindProviderConversation as Qt, verifySlackDirectCredentialSubject as R, agentsInstructionsUpdatedEvent as Rt, WorkspaceValidationError as S, conversationArchiveTimes as St, setWorkspaceSnapshot as T, conversationHasParticipantEmail as Tt, getSlackClient as U, getConversationMessageSearchStore as Ut, getFilePermalink as V, db_exports as Vt, isConversationScopedChannel as W, getConversationStore as Wt, runWithWorkspaceTeamId as X, withConversationMutationLock as Xt, getWorkspaceTeamId as Y, sanitizePostgresJson as Yt, findUserByEmail as Z, locationFromRow as Zt, deleteWorkspace as _, createPluginState as _t, getPluginRoutes as a, resolveRootConversationId as an, STOP_WATCHING_TOOL_NAME as at, listWorkspaces as b, createPluginLogger as bt, getPluginTools as c, upsertLinkedIdentity as cn, collectEventMatchKeys as ct, setPlugins as d, requireSlackDestination as dn, findMatchingWatches as dt, addAgentTurnUsage as en, updateViewerDisplayName as et, validatePlugins as f, sameDestination as fn, listWatches as ft, createWorkspace as g, setDashboardConversationLinkOptions as gt, setBriefsConfig as h, getDashboardTaskLink as ht, getPluginApiRoutes as i, hasAgentTurnUsage as in, RESOURCE_WATCH_TOOL_SOURCE as it, workspaceRepoCheckoutPath as j, readLatestConversationBrief as jt, getWorkspaceSnapshotBuilder as k, viewerConversationMembership as kt, getPluginUserPromptContributions as l, createSlackDestination as ln, createWatch as lt, registration_exports as m, getDashboardConversationLink as mt, applyPluginFormatMarkdown as n, agentTurnTotalTokens as nn, RESOURCE_SUBSCRIPTION_DEFAULT_TTL_MS as nt, getPluginSlackConversationLink as o, deleteProviderIdentityForSlackUser as on, cancelSubscriptions as ot, coreTaskRegistrations as p, JUNIOR_THREAD_STATE_TTL_MS as pt, runWithSlackInstallationToken as q, createSqlConversationEventStore as qt, createPluginHookRunner as r, agentTurnUsageSchema as rn, RESOURCE_SUBSCRIPTION_MAX_TTL_MS as rt, getPluginSystemPromptContributions as s, upsertIdentity as sn, cancelWatch as st, agent_hooks_exports as t, agentTurnCostUsd as tn, getSlackToolContext as tt, getPlugins as u, parseDestination as un, deliverWatch as ut, getWorkspace as v, createPluginEmbedder as vt, loadSnapshotsForProfile as w, conversationArchivedForUser as wt, updateWorkspace as x, readConversationAccessFromSql as xt, getWorkspaceByName as y, createPluginModel as yt, SlackActionError as z, authenticationLinkedEvent as zt };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { F as isRecord, d as logInfo, f as logWarn } from "./logging-
|
|
2
|
-
import { h as normalizeSlackEmojiName } from "./config-
|
|
1
|
+
import { F as isRecord, d as logInfo, f as logWarn } from "./logging-B5-PLvDo.js";
|
|
2
|
+
import { h as normalizeSlackEmojiName } from "./config-C0-PnQoF.js";
|
|
3
3
|
import { _ as parseSlackMessageTs, g as parseSlackUserId } from "./context-Bplcgypl.js";
|
|
4
|
-
import { G as isDmChannel, J as withSlackRetries, K as normalizeSlackConversationId, U as getSlackClient,
|
|
5
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime-
|
|
6
|
-
import { w as getStateAdapter } from "./profile-
|
|
4
|
+
import { G as isDmChannel, J as withSlackRetries, K as normalizeSlackConversationId, U as getSlackClient, n as applyPluginFormatMarkdown, un as parseDestination, z as SlackActionError } from "./agent-hooks-B2Yt2b88.js";
|
|
5
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-BvN_lNVo.js";
|
|
6
|
+
import { w as getStateAdapter } from "./profile-BcZ6EBQ4.js";
|
|
7
7
|
import { r as isExperimentalFeatureEnabled } from "./experimental-CIXf7Uye.js";
|
|
8
8
|
import { randomBytes } from "node:crypto";
|
|
9
9
|
import { actorSchema, sourceSchema } from "@sentry/junior-plugin-api";
|
package/dist/api/schema.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as conversationReportEventSchema, D as createConversationBodySchema, E as conversationSummaryReportSchema, O as createConversationMessageBodySchema, R as
|
|
1
|
+
import { C as conversationReportEventSchema, D as createConversationBodySchema, E as conversationSummaryReportSchema, L as conversationTurnFailureCodeSchema, O as createConversationMessageBodySchema, R as conversationTurnFailureReasonSchema, S as conversationReportEventDataSchema, T as conversationStatsReportSchema, _ as conversationParamsSchema, a as cancelConversationPendingMessagesBodySchema, b as conversationPendingMessageSchema, d as conversationDetailReportSchema, f as conversationEventHistorySchema, g as conversationFeedSchema, h as conversationFeedQuerySchema, i as archiveConversationResponseSchema, l as conversationAuxiliaryCostsSchema, m as conversationEventsQuerySchema, o as cancelConversationPendingMessagesResponseSchema, p as conversationEventPageSchema, r as archiveConversationBodySchema, s as conversationActivityPreviewSchema, t as acceptedConversationMessageSchema, u as conversationDetailQuerySchema, v as conversationPendingAuthorizationSchema, x as conversationPendingMessagesReportSchema, y as conversationPendingMessageDeliverySchema } from "../conversation-CRWntH-A.js";
|
|
2
2
|
import { a as pluginPackageContentReportSchema, c as runtimeInfoReportSchema, i as pluginPackageContentItemReportSchema, l as skillReportSchema, n as pluginOperationalReportFeedSchema, o as pluginSchema, r as pluginOperationalReportSchema, s as pluginsSchema, t as healthReportSchema, u as skillReportsSchema } from "../reporting-schema-DosTN__Q.js";
|
|
3
|
-
import { A as actorProfileReportSchema, B as dailyConversationActivitySchema, C as createPersonalTokenBodySchema, D as personalTokenParamsSchema, E as personalTokenMetadataSchema, F as locationDirectoryReportSchema, G as codePersonReportSchema, H as codeChangeSummaryReportSchema, I as locationParamsSchema, K as codeRepositorySummarySchema, M as personalSpendReportSchema, N as locationActivityDayReportSchema, O as revokePersonalTokenResponseSchema, P as locationDetailReportSchema, S as scheduledAutomationSummarySchema, T as personalTokenListSchema, U as codeChangeSummarySchema, V as codeActivityDaySchema, W as codeOverviewReportSchema, _ as automationRunListSchema, a as workspaceBodySchema, at as apiErrorSchema, b as automationSummarySchema, c as workspaceRepoSchema, d as automationExecutionSchema, f as automationExecutionStatusDaySchema, g as automationParamsSchema, h as automationListSchema, i as deleteWorkspaceResponseSchema, j as personParamsSchema, k as actorDirectoryReportSchema, l as workspaceSchema, m as automationListQuerySchema, n as statsReportSchema, o as workspaceListSchema, p as automationExecutionStatusSchema, r as baselineSnapshotSchema, s as workspaceParamsSchema, t as statSchema, u as automationExecutionListSchema, v as automationRunSchema, w as createdPersonalTokenSchema, x as eventAutomationSummarySchema, y as automationRunWindowsSchema } from "../schema-
|
|
3
|
+
import { A as actorProfileReportSchema, B as dailyConversationActivitySchema, C as createPersonalTokenBodySchema, D as personalTokenParamsSchema, E as personalTokenMetadataSchema, F as locationDirectoryReportSchema, G as codePersonReportSchema, H as codeChangeSummaryReportSchema, I as locationParamsSchema, K as codeRepositorySummarySchema, M as personalSpendReportSchema, N as locationActivityDayReportSchema, O as revokePersonalTokenResponseSchema, P as locationDetailReportSchema, S as scheduledAutomationSummarySchema, T as personalTokenListSchema, U as codeChangeSummarySchema, V as codeActivityDaySchema, W as codeOverviewReportSchema, _ as automationRunListSchema, a as workspaceBodySchema, at as apiErrorSchema, b as automationSummarySchema, c as workspaceRepoSchema, d as automationExecutionSchema, f as automationExecutionStatusDaySchema, g as automationParamsSchema, h as automationListSchema, i as deleteWorkspaceResponseSchema, j as personParamsSchema, k as actorDirectoryReportSchema, l as workspaceSchema, m as automationListQuerySchema, n as statsReportSchema, o as workspaceListSchema, p as automationExecutionStatusSchema, r as baselineSnapshotSchema, s as workspaceParamsSchema, t as statSchema, u as automationExecutionListSchema, v as automationRunSchema, w as createdPersonalTokenSchema, x as eventAutomationSummarySchema, y as automationRunWindowsSchema } from "../schema-xHUgeh46.js";
|
|
4
4
|
export { acceptedConversationMessageSchema, actorDirectoryReportSchema, actorProfileReportSchema, apiErrorSchema, archiveConversationBodySchema, archiveConversationResponseSchema, automationExecutionListSchema, automationExecutionSchema, automationExecutionStatusDaySchema, automationExecutionStatusSchema, automationListQuerySchema, automationListSchema, automationParamsSchema, automationRunListSchema, automationRunSchema, automationRunWindowsSchema, automationSummarySchema, baselineSnapshotSchema, cancelConversationPendingMessagesBodySchema, cancelConversationPendingMessagesResponseSchema, codeActivityDaySchema, codeChangeSummaryReportSchema, codeChangeSummarySchema, codeOverviewReportSchema, codePersonReportSchema, codeRepositorySummarySchema, conversationActivityPreviewSchema, conversationAuxiliaryCostsSchema, conversationDetailQuerySchema, conversationDetailReportSchema, conversationEventHistorySchema, conversationEventPageSchema, conversationEventsQuerySchema, conversationFeedQuerySchema, conversationFeedSchema, conversationParamsSchema, conversationPendingAuthorizationSchema, conversationPendingMessageDeliverySchema, conversationPendingMessageSchema, conversationPendingMessagesReportSchema, conversationReportEventDataSchema, conversationReportEventSchema, conversationStatsReportSchema, conversationSummaryReportSchema, conversationTurnFailureCodeSchema, conversationTurnFailureReasonSchema, createConversationBodySchema, createConversationMessageBodySchema, createPersonalTokenBodySchema, createdPersonalTokenSchema, dailyConversationActivitySchema, deleteWorkspaceResponseSchema, eventAutomationSummarySchema, healthReportSchema, locationActivityDayReportSchema, locationDetailReportSchema, locationDirectoryReportSchema, locationParamsSchema, personParamsSchema, personalSpendReportSchema, personalTokenListSchema, personalTokenMetadataSchema, personalTokenParamsSchema, pluginOperationalReportFeedSchema, pluginOperationalReportSchema, pluginPackageContentItemReportSchema, pluginPackageContentReportSchema, pluginSchema, pluginsSchema, revokePersonalTokenResponseSchema, runtimeInfoReportSchema, scheduledAutomationSummarySchema, skillReportSchema, skillReportsSchema, statSchema, statsReportSchema, workspaceBodySchema, workspaceListSchema, workspaceParamsSchema, workspaceRepoSchema, workspaceSchema };
|
package/dist/api.d.ts
CHANGED
package/dist/api.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { f as logWarn, u as logException } from "./logging-
|
|
1
|
+
import { f as logWarn, u as logException } from "./logging-B5-PLvDo.js";
|
|
2
2
|
import { _ as parseSlackMessageTs, h as parseSlackTeamId, p as parseSlackChannelId } from "./context-Bplcgypl.js";
|
|
3
|
-
import { $ as resolveViewerUser, $t as parseSessionSource, Ct as conversationArchivedForEmail, D as SANDBOX_RUNTIME, Dt as conversationNotArchivedForEmail, Et as conversationHasParticipantUser, Ft as listConversationAnnotations, Gt as getDb, It as listConversationAnnotationsById, J as withSlackRetries, Kt as getSqlExecutor, Mt as readConversationEventPage, Nt as buildSentryConversationUrl, Ot as conversationNotArchivedForUser, S as WorkspaceValidationError, St as conversationArchiveTimes, Tt as conversationHasParticipantEmail, U as getSlackClient, Wt as getConversationStore, Z as findUserByEmail, Zt as locationFromRow, _ as deleteWorkspace,
|
|
3
|
+
import { $ as resolveViewerUser, $t as parseSessionSource, Ct as conversationArchivedForEmail, D as SANDBOX_RUNTIME, Dt as conversationNotArchivedForEmail, Et as conversationHasParticipantUser, Ft as listConversationAnnotations, Gt as getDb, It as listConversationAnnotationsById, J as withSlackRetries, Kt as getSqlExecutor, Mt as readConversationEventPage, Nt as buildSentryConversationUrl, Ot as conversationNotArchivedForUser, S as WorkspaceValidationError, St as conversationArchiveTimes, Tt as conversationHasParticipantEmail, U as getSlackClient, Wt as getConversationStore, Z as findUserByEmail, Zt as locationFromRow, _ as deleteWorkspace, an as resolveRootConversationId, b as listWorkspaces, bt as createPluginLogger, et as updateViewerDisplayName, g as createWorkspace, in as hasAgentTurnUsage, j as workspaceRepoCheckoutPath, jt as readLatestConversationBrief, kt as viewerConversationMembership, rn as agentTurnUsageSchema, u as getPlugins, v as getWorkspace, wt as conversationArchivedForUser, x as updateWorkspace, xt as readConversationAccessFromSql } from "./agent-hooks-B2Yt2b88.js";
|
|
4
4
|
import { n as juniorDestinations } from "./destinations-BeBiJeEM.js";
|
|
5
|
-
import { C as
|
|
6
|
-
import { D as createConversationBodySchema, O as createConversationMessageBodySchema, T as conversationStatsReportSchema, _ as conversationParamsSchema, a as cancelConversationPendingMessagesBodySchema, c as conversationAttachmentParamsSchema, d as conversationDetailReportSchema, g as conversationFeedSchema, h as conversationFeedQuerySchema, i as archiveConversationResponseSchema, m as conversationEventsQuerySchema, o as cancelConversationPendingMessagesResponseSchema, p as conversationEventPageSchema, r as archiveConversationBodySchema, t as acceptedConversationMessageSchema, u as conversationDetailQuerySchema, x as conversationPendingMessagesReportSchema } from "./conversation-
|
|
7
|
-
import {
|
|
8
|
-
import { n as hash, t as create } from "./profile-
|
|
9
|
-
import { A as eventAutomationTriggerAvailable, F as effectiveTaskOutcomes, G as listDeletedEventAutomationsCreatedBy, H as eventAutomationBelongsToUser, J as listPublicEventAutomationsForTeams, K as listEventAutomationsCreatedBy, Tt as getConversation, V as deleteEventAutomation, W as getEventAutomation, X as getEventCatalog, _ as parseScheduledAutomationRow, c as parseSlackThreadId, ht as cancelHumanFacingPendingMessages, i as readLiveAttachment, m as listPublicScheduledAutomationsForTeams, n as readStats, p as isListedScheduledAutomation, v as readScheduledAutomation, y as saveScheduledAutomation } from "./stats-
|
|
10
|
-
import { t as getCachedSnapshot } from "./resolve-
|
|
5
|
+
import { C as juniorCodeRepositories, D as juniorIdentities, E as juniorConversations, O as juniorUsers, S as juniorCodeChanges, T as conversationReadColumns, b as juniorApiTokens, g as juniorConversationBriefs, m as juniorConversationParticipants, o as juniorSchedulerTasks, v as juniorConversationMetrics, y as juniorConversationEvents } from "./executor-CaVeGYeA.js";
|
|
6
|
+
import { D as createConversationBodySchema, O as createConversationMessageBodySchema, T as conversationStatsReportSchema, _ as conversationParamsSchema, a as cancelConversationPendingMessagesBodySchema, c as conversationAttachmentParamsSchema, d as conversationDetailReportSchema, g as conversationFeedSchema, h as conversationFeedQuerySchema, i as archiveConversationResponseSchema, m as conversationEventsQuerySchema, o as cancelConversationPendingMessagesResponseSchema, p as conversationEventPageSchema, r as archiveConversationBodySchema, t as acceptedConversationMessageSchema, u as conversationDetailQuerySchema, x as conversationPendingMessagesReportSchema } from "./conversation-CRWntH-A.js";
|
|
7
|
+
import { t as fallbackShortTitle } from "./short-title-CxQHLU3_.js";
|
|
8
|
+
import { n as hash, t as create } from "./profile-BcZ6EBQ4.js";
|
|
9
|
+
import { A as eventAutomationTriggerAvailable, F as effectiveTaskOutcomes, G as listDeletedEventAutomationsCreatedBy, H as eventAutomationBelongsToUser, J as listPublicEventAutomationsForTeams, K as listEventAutomationsCreatedBy, Tt as getConversation, V as deleteEventAutomation, W as getEventAutomation, X as getEventCatalog, _ as parseScheduledAutomationRow, c as parseSlackThreadId, ht as cancelHumanFacingPendingMessages, i as readLiveAttachment, m as listPublicScheduledAutomationsForTeams, n as readStats, p as isListedScheduledAutomation, v as readScheduledAutomation, y as saveScheduledAutomation } from "./stats-D5OWazLs.js";
|
|
10
|
+
import { t as getCachedSnapshot } from "./resolve-BgAZ4KxF.js";
|
|
11
11
|
import { t as getVercelConversationWorkQueue } from "./vercel-queue-DIkVcfK4.js";
|
|
12
12
|
import { c as runtimeInfoReportSchema, n as pluginOperationalReportFeedSchema, s as pluginsSchema, t as healthReportSchema, u as skillReportsSchema } from "./reporting-schema-DosTN__Q.js";
|
|
13
|
-
import { a as webActorFromEmail, c as formatSlackConversationRedactedLabel, d as resolveSlackConversationContextFromThreadId, f as lookupSlackUser, g as readHealthReport, m as createVercelAttachmentStorage, p as legacyWebMailboxMetadataSchema, r as createAndEnqueueConversation, t as appendAndEnqueueWebMessage } from "./web-input-
|
|
14
|
-
import { a as readAutomationExecutionStatusDays, c as readAutomationExecutions, d as conversationActiveDaysColumn, f as conversationAggregateColumns, i as readAutomationExecutionHours, l as readAutomationRuns, n as readAutomationExecutionByConversationId, o as readAutomationExecutionStatusHours, p as conversationRangeColumns, r as readAutomationExecutionDays, s as readAutomationExecutionSummaries, t as emptyAutomationRunWindows } from "./execution-stats-
|
|
15
|
-
import { r as getWebAuthorization } from "./web-authorization-
|
|
16
|
-
import { $ as sumUtcHoursIntoSixHours, A as actorProfileReportSchema, C as createPersonalTokenBodySchema, D as personalTokenParamsSchema, F as locationDirectoryReportSchema, G as codePersonReportSchema, I as locationParamsSchema, J as HOUR_MS$1, L as activityDays$1, M as personalSpendReportSchema, O as revokePersonalTokenResponseSchema, P as locationDetailReportSchema, Q as startOfUtcHour, R as activityHours$1, T as personalTokenListSchema, W as codeOverviewReportSchema, X as fillUtcHours, Y as fillUtcDays, Z as fillUtcSixHours, _ as automationRunListSchema, a as workspaceBodySchema, at as apiErrorSchema, et as trailingUtcDayWindow, g as automationParamsSchema, h as automationListSchema, i as deleteWorkspaceResponseSchema, it as utcHourKey, j as personParamsSchema, k as actorDirectoryReportSchema, l as workspaceSchema, m as automationListQuerySchema, n as statsReportSchema, nt as trailingUtcSixHourWindow, o as workspaceListSchema, q as DAY_MS$1, rt as utcDayKey, s as workspaceParamsSchema, tt as trailingUtcHourWindow, u as automationExecutionListSchema, w as createdPersonalTokenSchema, z as activitySixHours$1 } from "./schema-
|
|
13
|
+
import { a as webActorFromEmail, c as formatSlackConversationRedactedLabel, d as resolveSlackConversationContextFromThreadId, f as lookupSlackUser, g as readHealthReport, m as createVercelAttachmentStorage, p as legacyWebMailboxMetadataSchema, r as createAndEnqueueConversation, t as appendAndEnqueueWebMessage } from "./web-input-FJ7NNJDx.js";
|
|
14
|
+
import { a as readAutomationExecutionStatusDays, c as readAutomationExecutions, d as conversationActiveDaysColumn, f as conversationAggregateColumns, i as readAutomationExecutionHours, l as readAutomationRuns, n as readAutomationExecutionByConversationId, o as readAutomationExecutionStatusHours, p as conversationRangeColumns, r as readAutomationExecutionDays, s as readAutomationExecutionSummaries, t as emptyAutomationRunWindows } from "./execution-stats-CoDjBQbE.js";
|
|
15
|
+
import { r as getWebAuthorization } from "./web-authorization-BXrGezGm.js";
|
|
16
|
+
import { $ as sumUtcHoursIntoSixHours, A as actorProfileReportSchema, C as createPersonalTokenBodySchema, D as personalTokenParamsSchema, F as locationDirectoryReportSchema, G as codePersonReportSchema, I as locationParamsSchema, J as HOUR_MS$1, L as activityDays$1, M as personalSpendReportSchema, O as revokePersonalTokenResponseSchema, P as locationDetailReportSchema, Q as startOfUtcHour, R as activityHours$1, T as personalTokenListSchema, W as codeOverviewReportSchema, X as fillUtcHours, Y as fillUtcDays, Z as fillUtcSixHours, _ as automationRunListSchema, a as workspaceBodySchema, at as apiErrorSchema, et as trailingUtcDayWindow, g as automationParamsSchema, h as automationListSchema, i as deleteWorkspaceResponseSchema, it as utcHourKey, j as personParamsSchema, k as actorDirectoryReportSchema, l as workspaceSchema, m as automationListQuerySchema, n as statsReportSchema, nt as trailingUtcSixHourWindow, o as workspaceListSchema, q as DAY_MS$1, rt as utcDayKey, s as workspaceParamsSchema, tt as trailingUtcHourWindow, u as automationExecutionListSchema, w as createdPersonalTokenSchema, z as activitySixHours$1 } from "./schema-xHUgeh46.js";
|
|
17
17
|
import { Hono } from "hono";
|
|
18
18
|
import path from "node:path";
|
|
19
19
|
import { z } from "zod";
|
|
@@ -1851,6 +1851,17 @@ async function requireConversationPendingMessages(conversationId, options = {})
|
|
|
1851
1851
|
return report;
|
|
1852
1852
|
}
|
|
1853
1853
|
//#endregion
|
|
1854
|
+
//#region src/api/conversations/metric-buckets.ts
|
|
1855
|
+
/** Sum all Conversation metrics into UTC day or hour buckets. */
|
|
1856
|
+
async function readConversationMetricBuckets(db, options) {
|
|
1857
|
+
const date = options.bucket === "day" ? sql`to_char(${juniorConversationMetrics.occurredAt} at time zone 'UTC', 'YYYY-MM-DD')` : sql`to_char(${juniorConversationMetrics.occurredAt} at time zone 'UTC', 'YYYY-MM-DD"T"HH24')`;
|
|
1858
|
+
return await db.select({
|
|
1859
|
+
date,
|
|
1860
|
+
metric: juniorConversationMetrics.metric,
|
|
1861
|
+
value: sql`sum(${juniorConversationMetrics.value})::double precision`
|
|
1862
|
+
}).from(juniorConversationMetrics).where(and(gte(juniorConversationMetrics.occurredAt, options.start), lte(juniorConversationMetrics.occurredAt, options.end))).groupBy(date, juniorConversationMetrics.metric).orderBy(asc(date), asc(juniorConversationMetrics.metric));
|
|
1863
|
+
}
|
|
1864
|
+
//#endregion
|
|
1854
1865
|
//#region src/api/conversations/stats.query.ts
|
|
1855
1866
|
const treeConversation$1 = alias(juniorConversations, "stats_tree_conversation");
|
|
1856
1867
|
const treeAggregateColumns$1 = conversationAggregateColumns({
|
|
@@ -1913,6 +1924,34 @@ function statsWindow(nowMs) {
|
|
|
1913
1924
|
};
|
|
1914
1925
|
}
|
|
1915
1926
|
const HOUR_MS = 36e5;
|
|
1927
|
+
function applyMetricBuckets(rows, metrics) {
|
|
1928
|
+
const byDate = new Map(rows.map((row) => [row.date, {
|
|
1929
|
+
...row,
|
|
1930
|
+
cachedInputTokens: null,
|
|
1931
|
+
costUsd: null,
|
|
1932
|
+
durationMs: 0,
|
|
1933
|
+
inputTokens: null,
|
|
1934
|
+
tokens: null
|
|
1935
|
+
}]));
|
|
1936
|
+
for (const metric of metrics) {
|
|
1937
|
+
const row = byDate.get(metric.date) ?? {
|
|
1938
|
+
cachedInputTokens: null,
|
|
1939
|
+
conversations: 0,
|
|
1940
|
+
costUsd: null,
|
|
1941
|
+
date: metric.date,
|
|
1942
|
+
durationMs: 0,
|
|
1943
|
+
inputTokens: null,
|
|
1944
|
+
tokens: null
|
|
1945
|
+
};
|
|
1946
|
+
if (metric.metric === "cached_input_tokens") row.cachedInputTokens = metric.value;
|
|
1947
|
+
else if (metric.metric === "cost_usd") row.costUsd = metric.value;
|
|
1948
|
+
else if (metric.metric === "duration_ms") row.durationMs = metric.value;
|
|
1949
|
+
else if (metric.metric === "input_tokens") row.inputTokens = metric.value;
|
|
1950
|
+
else if (metric.metric === "total_tokens") row.tokens = metric.value;
|
|
1951
|
+
byDate.set(metric.date, row);
|
|
1952
|
+
}
|
|
1953
|
+
return [...byDate.values()];
|
|
1954
|
+
}
|
|
1916
1955
|
function metricPoint(date, row) {
|
|
1917
1956
|
return {
|
|
1918
1957
|
conversations: row?.conversations ?? 0,
|
|
@@ -2039,7 +2078,7 @@ async function aggregateStats(db, start, end) {
|
|
|
2039
2078
|
${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
|
|
2040
2079
|
'YYYY-MM-DD"T"HH24'
|
|
2041
2080
|
)`;
|
|
2042
|
-
const [totalsRows, actorRows, locationRows, metricRows, metricHourRows] = await Promise.all([
|
|
2081
|
+
const [totalsRows, actorRows, locationRows, metricRows, metricHourRows, dayMetrics, hourMetrics] = await Promise.all([
|
|
2043
2082
|
db.select(treeAggregateColumns$1).from(juniorConversations).innerJoin(treeConversation$1, eq(treeConversation$1.rootConversationId, juniorConversations.conversationId)).where(where),
|
|
2044
2083
|
db.select({
|
|
2045
2084
|
identityDisplayName: juniorIdentities.displayName,
|
|
@@ -2060,29 +2099,29 @@ async function aggregateStats(db, start, end) {
|
|
|
2060
2099
|
...treeAggregateColumns$1
|
|
2061
2100
|
}).from(juniorConversations).innerJoin(treeConversation$1, eq(treeConversation$1.rootConversationId, juniorConversations.conversationId)).leftJoin(juniorDestinations, eq(juniorDestinations.id, juniorConversations.destinationId)).where(where).groupBy(juniorConversations.channelName, juniorConversations.source, juniorDestinations.displayName, juniorDestinations.kind, juniorDestinations.provider, juniorDestinations.visibility),
|
|
2062
2101
|
db.select({
|
|
2063
|
-
cachedInputTokens: treeAggregateColumns$1.cachedInputTokens,
|
|
2064
2102
|
conversations: treeAggregateColumns$1.conversations,
|
|
2065
|
-
|
|
2066
|
-
date: activityDate,
|
|
2067
|
-
durationMs: treeAggregateColumns$1.durationMs,
|
|
2068
|
-
inputTokens: treeAggregateColumns$1.inputTokens,
|
|
2069
|
-
tokens: treeAggregateColumns$1.tokens
|
|
2103
|
+
date: activityDate
|
|
2070
2104
|
}).from(juniorConversations).innerJoin(treeConversation$1, eq(treeConversation$1.rootConversationId, juniorConversations.conversationId)).where(where).groupBy(activityDate),
|
|
2071
2105
|
db.select({
|
|
2072
|
-
cachedInputTokens: treeAggregateColumns$1.cachedInputTokens,
|
|
2073
2106
|
conversations: treeAggregateColumns$1.conversations,
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2107
|
+
date: activityHour
|
|
2108
|
+
}).from(juniorConversations).innerJoin(treeConversation$1, eq(treeConversation$1.rootConversationId, juniorConversations.conversationId)).where(where).groupBy(activityHour),
|
|
2109
|
+
readConversationMetricBuckets(db, {
|
|
2110
|
+
bucket: "day",
|
|
2111
|
+
start,
|
|
2112
|
+
end
|
|
2113
|
+
}),
|
|
2114
|
+
readConversationMetricBuckets(db, {
|
|
2115
|
+
bucket: "hour",
|
|
2116
|
+
start,
|
|
2117
|
+
end
|
|
2118
|
+
})
|
|
2080
2119
|
]);
|
|
2081
2120
|
return {
|
|
2082
2121
|
actorRows,
|
|
2083
2122
|
locationRows,
|
|
2084
|
-
metricHourRows,
|
|
2085
|
-
metricRows,
|
|
2123
|
+
metricHourRows: applyMetricBuckets(metricHourRows, hourMetrics),
|
|
2124
|
+
metricRows: applyMetricBuckets(metricRows, dayMetrics),
|
|
2086
2125
|
totals: totalsRows[0]
|
|
2087
2126
|
};
|
|
2088
2127
|
}
|
|
@@ -3409,7 +3448,7 @@ async function readPeoplePluginReports(args) {
|
|
|
3409
3448
|
reports: [],
|
|
3410
3449
|
source: "plugins"
|
|
3411
3450
|
});
|
|
3412
|
-
const { getPluginProfileReports } = await import("./agent-hooks-
|
|
3451
|
+
const { getPluginProfileReports } = await import("./agent-hooks-B2Yt2b88.js").then((n) => n.t);
|
|
3413
3452
|
return pluginOperationalReportFeedSchema.parse({
|
|
3414
3453
|
generatedAt: new Date(nowMs).toISOString(),
|
|
3415
3454
|
reports: await getPluginProfileReports({
|
|
@@ -4018,7 +4057,7 @@ function readDescriptionText(home) {
|
|
|
4018
4057
|
}
|
|
4019
4058
|
/** Read discovered skill names for authenticated runtime diagnostics. */
|
|
4020
4059
|
async function readSkillReports() {
|
|
4021
|
-
const { discoverSkills } = await import("./skills-
|
|
4060
|
+
const { discoverSkills } = await import("./skills-DlrAH1on.js").then((n) => n.o);
|
|
4022
4061
|
const skills = await discoverSkills();
|
|
4023
4062
|
return skillReportsSchema.parse(skills.map((skill) => ({
|
|
4024
4063
|
name: skill.name,
|
|
@@ -4027,7 +4066,7 @@ async function readSkillReports() {
|
|
|
4027
4066
|
}
|
|
4028
4067
|
/** Read safe configured plugin metadata for authenticated runtime diagnostics. */
|
|
4029
4068
|
async function readPlugins() {
|
|
4030
|
-
const { pluginCatalogRuntime } = await import("./catalog-runtime-
|
|
4069
|
+
const { pluginCatalogRuntime } = await import("./catalog-runtime-BvN_lNVo.js").then((n) => n.t);
|
|
4031
4070
|
return pluginsSchema.parse(pluginCatalogRuntime.getProviders().map((plugin) => ({
|
|
4032
4071
|
configKeys: plugin.manifest.configKeys ?? [],
|
|
4033
4072
|
description: plugin.manifest.description,
|
|
@@ -4039,7 +4078,7 @@ async function readPlugins() {
|
|
|
4039
4078
|
async function readRuntimeInfoReport() {
|
|
4040
4079
|
const [{ homeDir }, { pluginCatalogRuntime }, plugins, skills] = await Promise.all([
|
|
4041
4080
|
import("./package-discovery-7a9YqLhE.js").then((n) => n.r),
|
|
4042
|
-
import("./catalog-runtime-
|
|
4081
|
+
import("./catalog-runtime-BvN_lNVo.js").then((n) => n.t),
|
|
4043
4082
|
readPlugins(),
|
|
4044
4083
|
readSkillReports()
|
|
4045
4084
|
]);
|
|
@@ -4056,7 +4095,7 @@ async function readRuntimeInfoReport() {
|
|
|
4056
4095
|
/** Read sanitized operational summaries contributed by plugins. */
|
|
4057
4096
|
async function readPluginOperationalReportFeed() {
|
|
4058
4097
|
const nowMs = Date.now();
|
|
4059
|
-
const { getPluginOperationalReports } = await import("./agent-hooks-
|
|
4098
|
+
const { getPluginOperationalReports } = await import("./agent-hooks-B2Yt2b88.js").then((n) => n.t);
|
|
4060
4099
|
return pluginOperationalReportFeedSchema.parse({
|
|
4061
4100
|
source: "plugins",
|
|
4062
4101
|
generatedAt: new Date(nowMs).toISOString(),
|
package/dist/app.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as ModelProfileInput, n as JuniorDashboardOptions, r as createApp, t as JuniorAppOptions } from "./app-
|
|
1
|
+
import { i as ModelProfileInput, n as JuniorDashboardOptions, r as createApp, t as JuniorAppOptions } from "./app-D4nNdzPG.js";
|
|
2
2
|
import { i as defineJuniorPlugins, n as JuniorPluginSet, r as JuniorPluginSetOptions, t as JuniorPluginInput } from "./plugins-BI9A1vKA.js";
|
|
3
3
|
import { t as JUNIOR_VERSION } from "./version-CnXZ614E.js";
|
|
4
4
|
export { JUNIOR_VERSION, JuniorAppOptions, JuniorDashboardOptions, type JuniorPluginInput, type JuniorPluginSet, type JuniorPluginSetOptions, type ModelProfileInput, createApp, defineJuniorPlugins };
|