@sentry/junior 0.114.0 → 0.116.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-WNBUY4OB.js → agent-hooks-67NFITDH.js} +13 -12
- package/dist/api/conversations/detail.d.ts +20 -0
- package/dist/api/conversations/event-list.d.ts +2 -0
- package/dist/api/conversations/event-page.d.ts +1 -1
- package/dist/api/conversations/events.d.ts +1 -1
- package/dist/api/health.d.ts +7 -0
- package/dist/api/people/profile.d.ts +2 -2
- package/dist/api/people/shared.d.ts +1 -1
- package/dist/api/personal-tokens/create.d.ts +11 -0
- package/dist/api/personal-tokens/list.d.ts +12 -0
- package/dist/api/personal-tokens/revoke.d.ts +5 -0
- package/dist/api/personal-tokens/routes.d.ts +4 -0
- package/dist/api/plugin-reports.d.ts +62 -0
- package/dist/api/plugins.d.ts +8 -0
- package/dist/api/route.d.ts +1 -1
- package/dist/api/runtime.d.ts +24 -0
- package/dist/api/schema/conversation.d.ts +26 -0
- package/dist/api/schema/person.d.ts +3 -3
- package/dist/api/schema/personal-token.d.ts +38 -0
- package/dist/api/schema.d.ts +4 -2
- package/dist/api/schema.js +19 -7
- package/dist/api/skills.d.ts +6 -0
- package/dist/api.d.ts +1 -0
- package/dist/api.js +285 -121
- package/dist/app.js +1957 -5677
- package/dist/catalog-runtime-CWZY6GTH.js +18 -0
- package/dist/chat/agent/request.d.ts +7 -0
- package/dist/chat/agent/resume.d.ts +1 -0
- package/dist/chat/agent/sandbox.d.ts +3 -0
- package/dist/chat/agent/tools.d.ts +3 -0
- package/dist/chat/agent-dispatch/context.d.ts +2 -0
- package/dist/chat/agent-dispatch/heartbeat.d.ts +11 -5
- package/dist/chat/agent-dispatch/signing.d.ts +14 -5
- package/dist/chat/agent-dispatch/store.d.ts +36 -15
- package/dist/chat/agent-dispatch/types.d.ts +23 -10
- package/dist/chat/agent-dispatch/work.d.ts +58 -0
- package/dist/chat/app/factory.d.ts +12 -3
- package/dist/chat/config.d.ts +2 -0
- package/dist/chat/conversations/history.d.ts +291 -290
- package/dist/chat/conversations/projection.d.ts +2 -2
- package/dist/chat/local/credential-sync.d.ts +5 -0
- package/dist/chat/local/oauth-relay.d.ts +4 -0
- package/dist/chat/mcp/oauth.d.ts +1 -0
- package/dist/chat/mcp/tool-manager.d.ts +2 -1
- package/dist/chat/oauth-authorization.d.ts +17 -0
- package/dist/chat/oauth-flow.d.ts +9 -0
- package/dist/chat/pi/conversation-events.d.ts +6 -2
- package/dist/chat/plugins/annotations.d.ts +8 -0
- package/dist/chat/plugins/registry.d.ts +0 -3
- package/dist/chat/plugins/types.d.ts +0 -2
- package/dist/chat/runtime/agent-continue-runner.d.ts +4 -0
- package/dist/chat/runtime/reply-executor.d.ts +6 -1
- package/dist/chat/runtime/slack-resume.d.ts +5 -1
- package/dist/chat/runtime/turn-input.d.ts +3 -0
- package/dist/chat/sandbox/egress/schemas.d.ts +46 -0
- package/dist/chat/sandbox/egress/signals.d.ts +9 -0
- package/dist/chat/sandbox/sandbox.d.ts +4 -1
- package/dist/chat/sandbox/session.d.ts +2 -11
- package/dist/chat/sandbox/workspace.d.ts +10 -2
- package/dist/chat/sentry-payload-filter.d.ts +4 -4
- package/dist/chat/services/mcp-auth-orchestration.d.ts +5 -3
- package/dist/chat/services/plugin-auth-orchestration.d.ts +2 -0
- package/dist/chat/services/turn-session-record.d.ts +14 -1
- package/dist/chat/slack/dispatch-turn.d.ts +25 -0
- package/dist/chat/slack/message-control.d.ts +2 -0
- package/dist/chat/slack/oauth-authorization-message.d.ts +3 -0
- package/dist/chat/state/turn-session.d.ts +11 -0
- package/dist/chat/task-execution/slack-work.d.ts +2 -0
- package/dist/chat/tool-support/text-range-result.d.ts +3 -0
- package/dist/chat/tool-support/zod-tool.d.ts +2 -1
- package/dist/chat/tools/definition.d.ts +3 -5
- package/dist/chat/tools/query-conversation-events.d.ts +68 -0
- package/dist/chat/tools/sandbox/file-utils.d.ts +8 -1
- package/dist/chat/tools/sandbox/find-files.d.ts +2 -1
- package/dist/chat/tools/sandbox/grep.d.ts +2 -1
- package/dist/{chunk-OSKEC4XU.js → chunk-25GU5B5E.js} +1 -1
- package/dist/{chunk-XLFBQJUO.js → chunk-3H45VOBZ.js} +32 -7
- package/dist/{chunk-4FUEG3QY.js → chunk-3JOGUT46.js} +4 -16
- package/dist/chunk-4CODA7P5.js +43 -0
- package/dist/{chunk-O4GT7LYB.js → chunk-4DD6AOCG.js} +3 -43
- package/dist/{chunk-YU6PO42Q.js → chunk-53ZKTQO6.js} +1 -1
- package/dist/{chunk-WV4UJBAS.js → chunk-5UNB623T.js} +1282 -2536
- package/dist/{chunk-TLGM5X2M.js → chunk-6RQ5GCWH.js} +2 -2
- package/dist/{chunk-MIAKQNYX.js → chunk-6ZK6FZIV.js} +1 -1
- package/dist/{chunk-W6RDUAO3.js → chunk-BXLS3I4W.js} +1 -1
- package/dist/{chunk-RD7EJI7H.js → chunk-CI3VK7X5.js} +69 -3
- package/dist/chunk-DIB4GX3G.js +8 -0
- package/dist/{chunk-42WRQLJ6.js → chunk-F3B2YJ76.js} +0 -14
- package/dist/chunk-FA6POGLH.js +70 -0
- package/dist/{chunk-6Y5L4BOM.js → chunk-FXOYURO4.js} +5 -3
- package/dist/chunk-HDSDCEPK.js +80 -0
- package/dist/{chunk-C4MZ3GP5.js → chunk-HZF5P5UN.js} +1 -1
- package/dist/{chunk-K2W4CK7K.js → chunk-JZPQ5K4V.js} +10 -129
- package/dist/{chunk-FIGAF6KL.js → chunk-KBNDFU6J.js} +108 -38
- package/dist/{chunk-PM3PX42K.js → chunk-MGH5ADQS.js} +1 -2
- package/dist/{chunk-5CZ7RETL.js → chunk-N7TMYLF2.js} +1 -1
- package/dist/chunk-OB42YVAE.js +16 -0
- package/dist/{chunk-6QWPVTMO.js → chunk-OF5FODBL.js} +125 -23
- package/dist/{chunk-2ZTTXTSZ.js → chunk-PE44LDDQ.js} +9 -4
- package/dist/chunk-PGKWXHYJ.js +1870 -0
- package/dist/{chunk-ZGXH3REA.js → chunk-PZGPCOSD.js} +12 -2
- package/dist/{chunk-JQFJO5WH.js → chunk-RXRQJF7Y.js} +74 -17
- package/dist/{chunk-S4QDH23A.js → chunk-TC4ZEM2D.js} +113 -79
- package/dist/{chunk-ABPSDO6M.js → chunk-UEVLIYK5.js} +234 -165
- package/dist/chunk-VKZ6WVAY.js +4318 -0
- package/dist/{chunk-VNNBSKCO.js → chunk-VZCSLYCE.js} +22 -7
- package/dist/chunk-W3U3YQYI.js +71 -0
- package/dist/{chunk-SG5WAA7H.js → chunk-WKU7TY22.js} +0 -3
- package/dist/cli/chat.js +74 -42
- package/dist/cli/check.js +10 -8
- package/dist/cli/init.js +1 -0
- package/dist/cli/plugins.js +18 -16
- package/dist/cli/snapshot-warmup.js +13 -11
- package/dist/cli/upgrade.js +12 -10
- package/dist/db/schema/api-tokens.d.ts +160 -0
- package/dist/db/schema/conversation-annotations.d.ts +142 -0
- package/dist/db/schema.d.ts +305 -1
- package/dist/{db-4VLP7KBF.js → db-57FHVGGQ.js} +9 -8
- package/dist/handlers/agent-dispatch.d.ts +7 -3
- package/dist/handlers/sandbox-egress-signals.d.ts +4 -0
- package/dist/instrumentation.js +72 -4
- package/dist/nitro.js +5 -5
- package/dist/oauth-callback-server-PAQRPXZX.js +231 -0
- package/dist/oauth-relay-3ZU72UGL.js +9 -0
- package/dist/personal-tokens/store.d.ts +27 -0
- package/dist/{plugins-PZMDS7AT.js → plugins-IUJA4VBU.js} +1 -1
- package/dist/reporting-schema.d.ts +10 -4
- package/dist/reporting.d.ts +5 -5
- package/dist/{runner-IPXLWQOF.js → runner-4ISZYJEX.js} +141 -74
- package/dist/sandbox-egress-signals-CDFAP67O.js +75 -0
- package/dist/{skills-QCNZISNF.js → skills-UE2KXQMB.js} +10 -8
- package/dist/validation-PO5LHTJT.js +21 -0
- package/dist/version.js +1 -1
- package/migrations/0008_sticky_rage.sql +14 -0
- package/migrations/0009_slippery_harrier.sql +12 -0
- package/migrations/0010_native_conversation_history.sql +142 -0
- package/migrations/meta/0008_snapshot.json +1076 -0
- package/migrations/meta/0009_snapshot.json +1146 -0
- package/migrations/meta/0010_snapshot.json +1190 -0
- package/migrations/meta/_journal.json +22 -1
- package/package.json +6 -7
- package/dist/catalog-runtime-6O4M6JGA.js +0 -16
- package/dist/chat/agent-dispatch/runner.d.ts +0 -13
- package/dist/chat/capabilities/catalog.d.ts +0 -16
- package/dist/chat/oauth-authorization-message.d.ts +0 -6
- package/dist/validation-I2BW3UHD.js +0 -19
- package/dist/{chunk-KNFROR7R.js → chunk-5I6ORJUY.js} +1 -1
package/dist/api.js
CHANGED
|
@@ -14,59 +14,70 @@ import {
|
|
|
14
14
|
conversationParamsSchema,
|
|
15
15
|
conversationReportEventSchema,
|
|
16
16
|
conversationStatsReportSchema,
|
|
17
|
+
createPersonalTokenBodySchema,
|
|
18
|
+
createdPersonalTokenSchema,
|
|
17
19
|
locationDetailReportSchema,
|
|
18
20
|
locationDirectoryReportSchema,
|
|
19
21
|
locationParamsSchema,
|
|
20
|
-
personParamsSchema
|
|
21
|
-
|
|
22
|
+
personParamsSchema,
|
|
23
|
+
personalTokenListSchema,
|
|
24
|
+
personalTokenParamsSchema,
|
|
25
|
+
revokePersonalTokenResponseSchema
|
|
26
|
+
} from "./chunk-TC4ZEM2D.js";
|
|
22
27
|
import {
|
|
23
|
-
buildSentryConversationUrl,
|
|
24
28
|
formatSlackConversationRedactedLabel,
|
|
25
29
|
readHealthReport,
|
|
26
30
|
resolveSlackConversationContextFromThreadId
|
|
27
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-4DD6AOCG.js";
|
|
32
|
+
import {
|
|
33
|
+
buildSentryConversationUrl
|
|
34
|
+
} from "./chunk-4CODA7P5.js";
|
|
28
35
|
import {
|
|
29
36
|
healthReportSchema,
|
|
30
37
|
pluginOperationalReportFeedSchema,
|
|
31
|
-
|
|
38
|
+
pluginsSchema,
|
|
32
39
|
runtimeInfoReportSchema,
|
|
33
40
|
skillReportsSchema
|
|
34
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-PE44LDDQ.js";
|
|
35
42
|
import {
|
|
36
43
|
agentTurnUsageSchema,
|
|
37
44
|
hasAgentTurnUsage
|
|
38
45
|
} from "./chunk-MU6HHZEN.js";
|
|
39
46
|
import "./chunk-PDO5BLNM.js";
|
|
40
|
-
import
|
|
47
|
+
import {
|
|
48
|
+
listConversationAnnotations
|
|
49
|
+
} from "./chunk-CI3VK7X5.js";
|
|
41
50
|
import {
|
|
42
51
|
decodeStoredConversationEvent,
|
|
43
52
|
getDb,
|
|
44
53
|
getSqlExecutor
|
|
45
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-KBNDFU6J.js";
|
|
46
55
|
import {
|
|
56
|
+
juniorApiTokens,
|
|
47
57
|
juniorConversationEvents,
|
|
48
58
|
juniorConversations,
|
|
49
59
|
juniorIdentities,
|
|
50
60
|
juniorUsers
|
|
51
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-RXRQJF7Y.js";
|
|
52
62
|
import "./chunk-4ZNGQH7C.js";
|
|
53
|
-
import "./chunk-
|
|
63
|
+
import "./chunk-PZGPCOSD.js";
|
|
54
64
|
import {
|
|
55
65
|
juniorDestinations
|
|
56
66
|
} from "./chunk-VFUK3X5B.js";
|
|
57
67
|
import {
|
|
58
68
|
canExposeConversationPayload,
|
|
59
69
|
parseSlackThreadId
|
|
60
|
-
} from "./chunk-
|
|
61
|
-
import "./chunk-
|
|
62
|
-
import "./chunk-
|
|
70
|
+
} from "./chunk-FXOYURO4.js";
|
|
71
|
+
import "./chunk-3JOGUT46.js";
|
|
72
|
+
import "./chunk-OB42YVAE.js";
|
|
73
|
+
import "./chunk-F3B2YJ76.js";
|
|
63
74
|
import "./chunk-6GWA276C.js";
|
|
64
|
-
import "./chunk-
|
|
65
|
-
import "./chunk-
|
|
75
|
+
import "./chunk-N7TMYLF2.js";
|
|
76
|
+
import "./chunk-MGH5ADQS.js";
|
|
66
77
|
import "./chunk-MLKGABMK.js";
|
|
67
78
|
|
|
68
79
|
// src/api.ts
|
|
69
|
-
import { Hono as
|
|
80
|
+
import { Hono as Hono5 } from "hono";
|
|
70
81
|
|
|
71
82
|
// src/api/conversations/routes.ts
|
|
72
83
|
import { Hono } from "hono";
|
|
@@ -103,8 +114,8 @@ function parseBody(schema, body) {
|
|
|
103
114
|
function defineApiRoute(route) {
|
|
104
115
|
return route;
|
|
105
116
|
}
|
|
106
|
-
function registerApiRoutes(app,
|
|
107
|
-
for (const route of
|
|
117
|
+
function registerApiRoutes(app, routes6) {
|
|
118
|
+
for (const route of routes6) {
|
|
108
119
|
app.on(
|
|
109
120
|
route.method,
|
|
110
121
|
route.path,
|
|
@@ -161,7 +172,7 @@ var archive_default = defineApiRoute({
|
|
|
161
172
|
|
|
162
173
|
// src/chat/pi/sql-model-usage.ts
|
|
163
174
|
import { and as and2, eq as eq2, sql } from "drizzle-orm";
|
|
164
|
-
var message = sql`${juniorConversationEvents.payload}
|
|
175
|
+
var message = sql`${juniorConversationEvents.payload}`;
|
|
165
176
|
var usage = sql`${message}->'usage'`;
|
|
166
177
|
var cost = sql`${usage}->'cost'`;
|
|
167
178
|
function nonnegativeNumber(source, field, fallbackField, floor = false) {
|
|
@@ -261,8 +272,7 @@ async function readConversationModelUsageFromSql(executor, options) {
|
|
|
261
272
|
).where(
|
|
262
273
|
and2(
|
|
263
274
|
options.includeDescendants ? eq2(juniorConversations.rootConversationId, options.conversationId) : eq2(juniorConversationEvents.conversationId, options.conversationId),
|
|
264
|
-
eq2(juniorConversationEvents.type, "
|
|
265
|
-
sql`${message}->>'role' = 'assistant'`,
|
|
275
|
+
eq2(juniorConversationEvents.type, "assistant_message"),
|
|
266
276
|
sql`jsonb_typeof(${message}->'provider') = 'string'`,
|
|
267
277
|
sql`jsonb_typeof(${message}->'model') = 'string'`,
|
|
268
278
|
sql`coalesce(${message}->>'provider', '') <> ''`,
|
|
@@ -339,7 +349,8 @@ import { z as z2 } from "zod";
|
|
|
339
349
|
var conversationReportSourceEventTypes = [
|
|
340
350
|
"message",
|
|
341
351
|
"message_handled",
|
|
342
|
-
"
|
|
352
|
+
"assistant_message",
|
|
353
|
+
"tool_result",
|
|
343
354
|
"tool_execution_started",
|
|
344
355
|
"turn_started",
|
|
345
356
|
"turn_routed",
|
|
@@ -351,7 +362,7 @@ var conversationReportSourceEventTypes = [
|
|
|
351
362
|
"subagent_ended"
|
|
352
363
|
];
|
|
353
364
|
var reportingAssistantMessageSchema = z2.object({
|
|
354
|
-
|
|
365
|
+
type: z2.literal("assistant_message"),
|
|
355
366
|
content: z2.array(z2.unknown())
|
|
356
367
|
}).passthrough();
|
|
357
368
|
var reportingToolCallPartSchema = z2.object({
|
|
@@ -361,7 +372,7 @@ var reportingToolCallPartSchema = z2.object({
|
|
|
361
372
|
arguments: z2.unknown()
|
|
362
373
|
}).passthrough();
|
|
363
374
|
var reportingToolResultMessageSchema = z2.object({
|
|
364
|
-
|
|
375
|
+
type: z2.literal("tool_result"),
|
|
365
376
|
toolCallId: z2.string().min(1),
|
|
366
377
|
toolName: z2.string().min(1).optional(),
|
|
367
378
|
name: z2.string().min(1).optional(),
|
|
@@ -444,10 +455,7 @@ function conversationReportToolResultIds(events) {
|
|
|
444
455
|
return [
|
|
445
456
|
...new Set(
|
|
446
457
|
events.flatMap((event) => {
|
|
447
|
-
|
|
448
|
-
const result = reportingToolResultMessageSchema.safeParse(
|
|
449
|
-
event.data.message
|
|
450
|
-
);
|
|
458
|
+
const result = reportingToolResultMessageSchema.safeParse(event.data);
|
|
451
459
|
return result.success ? [result.data.toolCallId] : [];
|
|
452
460
|
})
|
|
453
461
|
)
|
|
@@ -503,6 +511,7 @@ function reportEventData(args) {
|
|
|
503
511
|
type: "compaction",
|
|
504
512
|
modelProfile: data.modelProfile,
|
|
505
513
|
modelId: data.modelId,
|
|
514
|
+
...args.canExposePayload && data.summary ? { summary: data.summary } : {},
|
|
506
515
|
...data.details ? { details: data.details } : {}
|
|
507
516
|
};
|
|
508
517
|
default:
|
|
@@ -536,20 +545,18 @@ function projectConversationReportEventPage(args) {
|
|
|
536
545
|
const projected = [];
|
|
537
546
|
for (const event of args.events) {
|
|
538
547
|
let data;
|
|
539
|
-
if (event.data.type === "
|
|
548
|
+
if (event.data.type === "assistant_message" || event.data.type === "tool_result") {
|
|
540
549
|
const reportArgs = {
|
|
541
550
|
canExposePayload: args.canExposePayload,
|
|
542
551
|
createdAtMs: event.createdAtMs,
|
|
543
|
-
message: event.data
|
|
552
|
+
message: event.data,
|
|
544
553
|
seq: event.seq
|
|
545
554
|
};
|
|
546
|
-
const result = reportingToolResultMessageSchema.safeParse(
|
|
547
|
-
event.data.message
|
|
548
|
-
);
|
|
555
|
+
const result = reportingToolResultMessageSchema.safeParse(event.data);
|
|
549
556
|
const start = result.success ? toolStarts.get(result.data.toolCallId) : void 0;
|
|
550
557
|
data = reportToolCalls(reportArgs) ?? reportToolResult({
|
|
551
558
|
canExposePayload: args.canExposePayload,
|
|
552
|
-
message: event.data
|
|
559
|
+
message: event.data,
|
|
553
560
|
...start && start.seq < event.seq ? { start } : {}
|
|
554
561
|
});
|
|
555
562
|
} else if (event.data.type === "tool_execution_started") {
|
|
@@ -605,7 +612,8 @@ function projectConversationReportEventPage(args) {
|
|
|
605
612
|
modelProfile: event.data.modelProfile,
|
|
606
613
|
modelId: event.data.modelId,
|
|
607
614
|
...event.data.reasoningLevel ? { reasoningLevel: event.data.reasoningLevel } : {},
|
|
608
|
-
...event.data.triggeringToolCallId ? { triggeringToolCallId: event.data.triggeringToolCallId } : {}
|
|
615
|
+
...event.data.triggeringToolCallId ? { triggeringToolCallId: event.data.triggeringToolCallId } : {},
|
|
616
|
+
...args.canExposePayload && event.data.summary ? { summary: event.data.summary } : {}
|
|
609
617
|
};
|
|
610
618
|
} else {
|
|
611
619
|
data = reportEventData({
|
|
@@ -1206,6 +1214,7 @@ function projectConversationDetail(args) {
|
|
|
1206
1214
|
...args.locationId ? { locationId: args.locationId } : {},
|
|
1207
1215
|
usage: args.usage
|
|
1208
1216
|
}),
|
|
1217
|
+
annotations: canExposePayload ? args.annotations : [],
|
|
1209
1218
|
events: args.events,
|
|
1210
1219
|
...args.previousSeq !== void 0 ? {
|
|
1211
1220
|
previousCursor: encodeConversationCursor({
|
|
@@ -1227,12 +1236,13 @@ async function readConversationDetailFromSql(conversationId, options) {
|
|
|
1227
1236
|
if (!record) return void 0;
|
|
1228
1237
|
const executor = getSqlExecutor();
|
|
1229
1238
|
const includeDescendantMetrics = record.rootConversationId === conversationId;
|
|
1230
|
-
const [accessByConversation, modelUsage, metricsByRoot] = await Promise.all([
|
|
1239
|
+
const [accessByConversation, annotations, modelUsage, metricsByRoot] = await Promise.all([
|
|
1231
1240
|
readConversationAccessFromSql(
|
|
1232
1241
|
getDb(),
|
|
1233
1242
|
[conversationId],
|
|
1234
1243
|
options.verifiedViewerEmail
|
|
1235
1244
|
),
|
|
1245
|
+
listConversationAnnotations(getDb(), conversationId),
|
|
1236
1246
|
record.conversation.transcriptPurgedAtMs === void 0 ? readConversationModelUsageFromSql(executor, {
|
|
1237
1247
|
conversationId,
|
|
1238
1248
|
includeDescendants: includeDescendantMetrics
|
|
@@ -1252,6 +1262,7 @@ async function readConversationDetailFromSql(conversationId, options) {
|
|
|
1252
1262
|
return projectConversationDetail({
|
|
1253
1263
|
...record,
|
|
1254
1264
|
access,
|
|
1265
|
+
annotations,
|
|
1255
1266
|
durationMs: metrics?.durationMs ?? record.durationMs,
|
|
1256
1267
|
events: page.events,
|
|
1257
1268
|
modelUsage,
|
|
@@ -1654,6 +1665,73 @@ function createConversationRoutes() {
|
|
|
1654
1665
|
return app;
|
|
1655
1666
|
}
|
|
1656
1667
|
|
|
1668
|
+
// src/reporting.ts
|
|
1669
|
+
import { readFileSync } from "fs";
|
|
1670
|
+
import path from "path";
|
|
1671
|
+
function readDescriptionText(home) {
|
|
1672
|
+
try {
|
|
1673
|
+
const raw = readFileSync(path.join(home, "DESCRIPTION.md"), "utf8").trim();
|
|
1674
|
+
return raw || void 0;
|
|
1675
|
+
} catch {
|
|
1676
|
+
return void 0;
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
async function readSkillReports() {
|
|
1680
|
+
const { discoverSkills } = await import("./skills-UE2KXQMB.js");
|
|
1681
|
+
const skills = await discoverSkills();
|
|
1682
|
+
return skillReportsSchema.parse(
|
|
1683
|
+
skills.map((skill) => ({
|
|
1684
|
+
name: skill.name,
|
|
1685
|
+
pluginProvider: skill.pluginProvider
|
|
1686
|
+
}))
|
|
1687
|
+
);
|
|
1688
|
+
}
|
|
1689
|
+
async function readPlugins() {
|
|
1690
|
+
const { pluginCatalogRuntime } = await import("./catalog-runtime-CWZY6GTH.js");
|
|
1691
|
+
return pluginsSchema.parse(
|
|
1692
|
+
pluginCatalogRuntime.getProviders().map((plugin) => ({
|
|
1693
|
+
configKeys: plugin.manifest.configKeys ?? [],
|
|
1694
|
+
description: plugin.manifest.description,
|
|
1695
|
+
displayName: plugin.manifest.displayName,
|
|
1696
|
+
name: plugin.manifest.name
|
|
1697
|
+
}))
|
|
1698
|
+
);
|
|
1699
|
+
}
|
|
1700
|
+
async function readRuntimeInfoReport() {
|
|
1701
|
+
const [{ homeDir }, { pluginCatalogRuntime }, plugins, skills] = await Promise.all([
|
|
1702
|
+
import("./discovery-RMHYSRL7.js"),
|
|
1703
|
+
import("./catalog-runtime-CWZY6GTH.js"),
|
|
1704
|
+
readPlugins(),
|
|
1705
|
+
readSkillReports()
|
|
1706
|
+
]);
|
|
1707
|
+
const home = homeDir();
|
|
1708
|
+
return runtimeInfoReportSchema.parse({
|
|
1709
|
+
cwd: process.cwd(),
|
|
1710
|
+
homeDir: home,
|
|
1711
|
+
descriptionText: readDescriptionText(home),
|
|
1712
|
+
providers: plugins.map((plugin) => plugin.name),
|
|
1713
|
+
skills,
|
|
1714
|
+
packagedContent: pluginCatalogRuntime.getPackageContent()
|
|
1715
|
+
});
|
|
1716
|
+
}
|
|
1717
|
+
async function readPluginOperationalReportFeed() {
|
|
1718
|
+
const nowMs = Date.now();
|
|
1719
|
+
const { getPluginOperationalReports } = await import("./agent-hooks-67NFITDH.js");
|
|
1720
|
+
return pluginOperationalReportFeedSchema.parse({
|
|
1721
|
+
source: "plugins",
|
|
1722
|
+
generatedAt: new Date(nowMs).toISOString(),
|
|
1723
|
+
reports: await getPluginOperationalReports(nowMs)
|
|
1724
|
+
});
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
// src/api/health.ts
|
|
1728
|
+
var health_default = defineApiRoute({
|
|
1729
|
+
method: "get",
|
|
1730
|
+
path: "/api/health",
|
|
1731
|
+
responseSchema: healthReportSchema,
|
|
1732
|
+
handler: readHealthReport
|
|
1733
|
+
});
|
|
1734
|
+
|
|
1657
1735
|
// src/api/locations/routes.ts
|
|
1658
1736
|
import { Hono as Hono2 } from "hono";
|
|
1659
1737
|
|
|
@@ -2567,99 +2645,184 @@ function createPeopleRoutes() {
|
|
|
2567
2645
|
return app;
|
|
2568
2646
|
}
|
|
2569
2647
|
|
|
2570
|
-
// src/
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2648
|
+
// src/api/plugin-reports.ts
|
|
2649
|
+
var plugin_reports_default = defineApiRoute({
|
|
2650
|
+
method: "get",
|
|
2651
|
+
path: "/api/plugin-reports",
|
|
2652
|
+
responseSchema: pluginOperationalReportFeedSchema,
|
|
2653
|
+
handler: readPluginOperationalReportFeed
|
|
2654
|
+
});
|
|
2655
|
+
|
|
2656
|
+
// src/api/personal-tokens/routes.ts
|
|
2657
|
+
import { Hono as Hono4 } from "hono";
|
|
2658
|
+
|
|
2659
|
+
// src/personal-tokens/store.ts
|
|
2660
|
+
import { createHash, randomBytes, randomUUID } from "crypto";
|
|
2661
|
+
import { and as and11, desc as desc5, eq as eq12, gt, isNull as isNull6 } from "drizzle-orm";
|
|
2662
|
+
var TOKEN_PREFIX = "jr_pat_";
|
|
2663
|
+
var TOKEN_SUFFIX_LENGTH = 8;
|
|
2664
|
+
var DEFAULT_TOKEN_LIFETIME_MS = 90 * 24 * 60 * 60 * 1e3;
|
|
2665
|
+
function normalizeEmail2(email) {
|
|
2666
|
+
return email.trim().toLowerCase();
|
|
2667
|
+
}
|
|
2668
|
+
function hashToken(token2) {
|
|
2669
|
+
return createHash("sha256").update(token2, "utf8").digest("hex");
|
|
2670
|
+
}
|
|
2671
|
+
function metadata(row) {
|
|
2672
|
+
return {
|
|
2673
|
+
id: row.id,
|
|
2674
|
+
name: row.name,
|
|
2675
|
+
tokenSuffix: row.tokenSuffix,
|
|
2676
|
+
createdAt: row.createdAt.toISOString(),
|
|
2677
|
+
expiresAt: row.expiresAt.toISOString(),
|
|
2678
|
+
lastUsedAt: row.lastUsedAt?.toISOString() ?? null
|
|
2679
|
+
};
|
|
2598
2680
|
}
|
|
2599
|
-
async function
|
|
2600
|
-
const
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2681
|
+
async function createPersonalToken(args) {
|
|
2682
|
+
const now = args.now ?? /* @__PURE__ */ new Date();
|
|
2683
|
+
const token2 = `${TOKEN_PREFIX}${randomBytes(32).toString("base64url")}`;
|
|
2684
|
+
const row = {
|
|
2685
|
+
id: randomUUID(),
|
|
2686
|
+
ownerEmailNormalized: normalizeEmail2(args.email),
|
|
2687
|
+
name: args.name.trim(),
|
|
2688
|
+
tokenHash: hashToken(token2),
|
|
2689
|
+
tokenSuffix: token2.slice(-TOKEN_SUFFIX_LENGTH),
|
|
2690
|
+
createdAt: now,
|
|
2691
|
+
expiresAt: new Date(now.getTime() + DEFAULT_TOKEN_LIFETIME_MS)
|
|
2692
|
+
};
|
|
2693
|
+
await getDb().insert(juniorApiTokens).values(row);
|
|
2694
|
+
return { ...metadata({ ...row, lastUsedAt: null, revokedAt: null }), token: token2 };
|
|
2695
|
+
}
|
|
2696
|
+
async function listPersonalTokens(email, now = /* @__PURE__ */ new Date()) {
|
|
2697
|
+
const rows = await getDb().select().from(juniorApiTokens).where(
|
|
2698
|
+
and11(
|
|
2699
|
+
eq12(juniorApiTokens.ownerEmailNormalized, normalizeEmail2(email)),
|
|
2700
|
+
isNull6(juniorApiTokens.revokedAt),
|
|
2701
|
+
gt(juniorApiTokens.expiresAt, now)
|
|
2702
|
+
)
|
|
2703
|
+
).orderBy(desc5(juniorApiTokens.createdAt));
|
|
2704
|
+
return rows.map(metadata);
|
|
2705
|
+
}
|
|
2706
|
+
async function revokePersonalToken(args) {
|
|
2707
|
+
const rows = await getDb().update(juniorApiTokens).set({ revokedAt: args.now ?? /* @__PURE__ */ new Date() }).where(
|
|
2708
|
+
and11(
|
|
2709
|
+
eq12(juniorApiTokens.id, args.id),
|
|
2710
|
+
eq12(juniorApiTokens.ownerEmailNormalized, normalizeEmail2(args.email)),
|
|
2711
|
+
isNull6(juniorApiTokens.revokedAt)
|
|
2712
|
+
)
|
|
2713
|
+
).returning({ id: juniorApiTokens.id });
|
|
2714
|
+
return rows.length > 0;
|
|
2715
|
+
}
|
|
2716
|
+
async function authenticatePersonalToken(token2, now = /* @__PURE__ */ new Date()) {
|
|
2717
|
+
if (!token2.startsWith(TOKEN_PREFIX)) return void 0;
|
|
2718
|
+
const rows = await getDb().select({
|
|
2719
|
+
id: juniorApiTokens.id,
|
|
2720
|
+
ownerEmailNormalized: juniorApiTokens.ownerEmailNormalized
|
|
2721
|
+
}).from(juniorApiTokens).where(
|
|
2722
|
+
and11(
|
|
2723
|
+
eq12(juniorApiTokens.tokenHash, hashToken(token2)),
|
|
2724
|
+
isNull6(juniorApiTokens.revokedAt),
|
|
2725
|
+
gt(juniorApiTokens.expiresAt, now)
|
|
2726
|
+
)
|
|
2727
|
+
).limit(1);
|
|
2728
|
+
const match = rows[0];
|
|
2729
|
+
if (!match) return void 0;
|
|
2730
|
+
await getDb().update(juniorApiTokens).set({ lastUsedAt: now }).where(eq12(juniorApiTokens.id, match.id));
|
|
2731
|
+
return match.ownerEmailNormalized;
|
|
2615
2732
|
}
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2733
|
+
|
|
2734
|
+
// src/api/personal-tokens/create.ts
|
|
2735
|
+
var create_default = defineApiRoute({
|
|
2736
|
+
method: "post",
|
|
2737
|
+
path: "/",
|
|
2738
|
+
responseSchema: createdPersonalTokenSchema,
|
|
2739
|
+
handler: async (c) => {
|
|
2740
|
+
const email = c.get("verifiedViewerEmail");
|
|
2741
|
+
if (!email) throwApiError(403, "Verified viewer email required.");
|
|
2742
|
+
let input;
|
|
2743
|
+
try {
|
|
2744
|
+
input = await c.req.json();
|
|
2745
|
+
} catch (error) {
|
|
2746
|
+
throwApiError(400, "Invalid request body.", error);
|
|
2747
|
+
}
|
|
2748
|
+
const body = parseBody(createPersonalTokenBodySchema, input);
|
|
2749
|
+
return createPersonalToken({ email, name: body.name });
|
|
2750
|
+
}
|
|
2751
|
+
});
|
|
2752
|
+
|
|
2753
|
+
// src/api/personal-tokens/list.ts
|
|
2754
|
+
var list_default4 = defineApiRoute({
|
|
2755
|
+
method: "get",
|
|
2756
|
+
path: "/",
|
|
2757
|
+
responseSchema: personalTokenListSchema,
|
|
2758
|
+
handler: async (c) => {
|
|
2759
|
+
const email = c.get("verifiedViewerEmail");
|
|
2760
|
+
if (!email) throwApiError(403, "Verified viewer email required.");
|
|
2761
|
+
return { tokens: await listPersonalTokens(email) };
|
|
2762
|
+
}
|
|
2763
|
+
});
|
|
2764
|
+
|
|
2765
|
+
// src/api/personal-tokens/revoke.ts
|
|
2766
|
+
var revoke_default = defineApiRoute({
|
|
2767
|
+
method: "delete",
|
|
2768
|
+
path: "/:id",
|
|
2769
|
+
responseSchema: revokePersonalTokenResponseSchema,
|
|
2770
|
+
handler: async (c) => {
|
|
2771
|
+
const email = c.get("verifiedViewerEmail");
|
|
2772
|
+
if (!email) throwApiError(403, "Verified viewer email required.");
|
|
2773
|
+
const { id } = parseParams(personalTokenParamsSchema, c.req.param());
|
|
2774
|
+
if (!await revokePersonalToken({ email, id })) {
|
|
2775
|
+
throwApiError(404, "Personal API token not found.");
|
|
2776
|
+
}
|
|
2777
|
+
return { revoked: true };
|
|
2778
|
+
}
|
|
2779
|
+
});
|
|
2780
|
+
|
|
2781
|
+
// src/api/personal-tokens/routes.ts
|
|
2782
|
+
var routes4 = [list_default4, create_default, revoke_default];
|
|
2783
|
+
function createPersonalTokenRoutes() {
|
|
2784
|
+
const app = new Hono4();
|
|
2785
|
+
registerApiRoutes(app, routes4);
|
|
2786
|
+
return app;
|
|
2624
2787
|
}
|
|
2625
2788
|
|
|
2789
|
+
// src/api/plugins.ts
|
|
2790
|
+
var plugins_default = defineApiRoute({
|
|
2791
|
+
method: "get",
|
|
2792
|
+
path: "/api/plugins",
|
|
2793
|
+
responseSchema: pluginsSchema,
|
|
2794
|
+
handler: readPlugins
|
|
2795
|
+
});
|
|
2796
|
+
|
|
2797
|
+
// src/api/runtime.ts
|
|
2798
|
+
var runtime_default = defineApiRoute({
|
|
2799
|
+
method: "get",
|
|
2800
|
+
path: "/api/runtime",
|
|
2801
|
+
responseSchema: runtimeInfoReportSchema,
|
|
2802
|
+
handler: readRuntimeInfoReport
|
|
2803
|
+
});
|
|
2804
|
+
|
|
2805
|
+
// src/api/skills.ts
|
|
2806
|
+
var skills_default = defineApiRoute({
|
|
2807
|
+
method: "get",
|
|
2808
|
+
path: "/api/skills",
|
|
2809
|
+
responseSchema: skillReportsSchema,
|
|
2810
|
+
handler: readSkillReports
|
|
2811
|
+
});
|
|
2812
|
+
|
|
2626
2813
|
// src/api.ts
|
|
2627
|
-
var
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
}),
|
|
2634
|
-
defineApiRoute({
|
|
2635
|
-
method: "get",
|
|
2636
|
-
path: "/api/runtime",
|
|
2637
|
-
responseSchema: runtimeInfoReportSchema,
|
|
2638
|
-
handler: readRuntimeInfoReport
|
|
2639
|
-
}),
|
|
2640
|
-
defineApiRoute({
|
|
2641
|
-
method: "get",
|
|
2642
|
-
path: "/api/plugins",
|
|
2643
|
-
responseSchema: pluginReportsSchema,
|
|
2644
|
-
handler: readPluginReports
|
|
2645
|
-
}),
|
|
2646
|
-
defineApiRoute({
|
|
2647
|
-
method: "get",
|
|
2648
|
-
path: "/api/skills",
|
|
2649
|
-
responseSchema: skillReportsSchema,
|
|
2650
|
-
handler: readSkillReports
|
|
2651
|
-
}),
|
|
2652
|
-
defineApiRoute({
|
|
2653
|
-
method: "get",
|
|
2654
|
-
path: "/api/plugin-reports",
|
|
2655
|
-
responseSchema: pluginOperationalReportFeedSchema,
|
|
2656
|
-
handler: readPluginOperationalReportFeed
|
|
2657
|
-
})
|
|
2814
|
+
var routes5 = [
|
|
2815
|
+
health_default,
|
|
2816
|
+
runtime_default,
|
|
2817
|
+
plugins_default,
|
|
2818
|
+
skills_default,
|
|
2819
|
+
plugin_reports_default
|
|
2658
2820
|
];
|
|
2659
2821
|
function createJuniorApi() {
|
|
2660
|
-
const app = new
|
|
2661
|
-
registerApiRoutes(app,
|
|
2822
|
+
const app = new Hono5();
|
|
2823
|
+
registerApiRoutes(app, routes5);
|
|
2662
2824
|
app.route("/api/conversations", createConversationRoutes());
|
|
2825
|
+
app.route("/api/personal-tokens", createPersonalTokenRoutes());
|
|
2663
2826
|
app.route("/api/people", createPeopleRoutes());
|
|
2664
2827
|
app.route("/api/locations", createLocationRoutes());
|
|
2665
2828
|
app.notFound(
|
|
@@ -2674,6 +2837,7 @@ function createJuniorApi() {
|
|
|
2674
2837
|
return app;
|
|
2675
2838
|
}
|
|
2676
2839
|
export {
|
|
2840
|
+
authenticatePersonalToken,
|
|
2677
2841
|
createJuniorApi,
|
|
2678
2842
|
jsonResponse
|
|
2679
2843
|
};
|