@sentry/junior 0.126.1 → 0.127.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-U5YGLX6Y.js → agent-hooks-HMCMFIIO.js} +8 -8
- package/dist/api/people/spend.d.ts +4 -0
- package/dist/api/people/spend.query.d.ts +3 -0
- package/dist/api/schema/person.d.ts +9 -0
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +3 -1
- package/dist/api.js +133 -33
- package/dist/app.js +29 -29
- package/dist/{catalog-runtime-OUPLWD7F.js → catalog-runtime-MI5UNBZ7.js} +5 -5
- package/dist/chat/plugins/agent-hooks.d.ts +4 -2
- package/dist/chat/resource-events/catalog.d.ts +21 -0
- package/dist/chat/resource-events/ingest.d.ts +1 -1
- package/dist/chat/resource-events/notification.d.ts +2 -2
- package/dist/chat/resource-events/store.d.ts +9 -9
- package/dist/chat/resource-events/tool-support.d.ts +10 -0
- package/dist/chat/task-execution/slack-work.d.ts +4 -4
- package/dist/chat/tools/list-resource-event-subscriptions.d.ts +80 -0
- package/dist/chat/tools/resource-events.d.ts +2 -1
- package/dist/chat/tools/search-resource-event-types.d.ts +60 -0
- package/dist/chat/tools/stop-watching-resources.d.ts +50 -0
- package/dist/chat/tools/watch-resource-events.d.ts +105 -0
- package/dist/{chunk-QMK2VF6K.js → chunk-2M6LYDTB.js} +1 -1
- package/dist/{chunk-JKV244BI.js → chunk-2N6EL22B.js} +1 -1
- package/dist/{chunk-OG6E44DH.js → chunk-4H2NZPFJ.js} +6 -6
- package/dist/{chunk-7VF3JAVF.js → chunk-6DU2ZNF7.js} +7 -7
- package/dist/{chunk-6ZBSTNYN.js → chunk-AFJF3RGU.js} +9 -0
- package/dist/{chunk-7ZMY4GCG.js → chunk-AKL3BAYJ.js} +1 -1
- package/dist/{chunk-PD6J33TO.js → chunk-AYICPT5T.js} +1 -1
- package/dist/{chunk-YUPNY2HZ.js → chunk-C7AVHH3H.js} +2 -2
- package/dist/{chunk-HXWOZ4HG.js → chunk-FVIU6NQO.js} +1 -1
- package/dist/{chunk-R3GXQJEE.js → chunk-JNYR4G7A.js} +2 -2
- package/dist/{chunk-W3JHZHAN.js → chunk-JXQWTNDI.js} +1 -1
- package/dist/{chunk-WIIPHGJY.js → chunk-L7L7RYJM.js} +2 -2
- package/dist/{chunk-U36WL4OL.js → chunk-NK7QVIMJ.js} +1 -1
- package/dist/{chunk-Y2QRKPI7.js → chunk-NYVMPADK.js} +1 -1
- package/dist/{chunk-S4LM6UB7.js → chunk-PDG3BSOD.js} +2 -2
- package/dist/{chunk-F2ARYRKC.js → chunk-SH7HDO2D.js} +1 -1
- package/dist/{chunk-YZHA2L7P.js → chunk-TLMI3Q4Q.js} +35 -12
- package/dist/{chunk-GLNB2R42.js → chunk-UEMGGJZD.js} +12 -12
- package/dist/{chunk-YFE6VNHU.js → chunk-VHUMNUJL.js} +1 -1
- package/dist/{chunk-KBW6J5GA.js → chunk-WXP2ZXC7.js} +4 -4
- package/dist/{chunk-QVSYR5CV.js → chunk-YSOZT72W.js} +4 -4
- package/dist/{chunk-SD2VFSN6.js → chunk-Z5LLJNTL.js} +669 -390
- package/dist/cli/chat.js +23 -23
- package/dist/cli/check.js +6 -6
- package/dist/cli/plugins.js +11 -11
- package/dist/cli/snapshot-create.js +9 -9
- package/dist/cli/upgrade.js +6 -6
- package/dist/{db-FQID26JW.js → db-N4EY57ZJ.js} +6 -6
- package/dist/instrumentation.js +4 -4
- package/dist/nitro.js +2 -2
- package/dist/{oauth-callback-server-Z5MHHKFD.js → oauth-callback-server-O62UOQSS.js} +16 -16
- package/dist/{runner-PGPGKYSF.js → runner-SRHRD3NX.js} +10 -10
- package/dist/{skills-BCQHR636.js → skills-V6X3JVVA.js} +6 -6
- package/dist/{validation-QP3FYBLZ.js → validation-ZZXZELGH.js} +6 -6
- package/dist/version.js +1 -1
- package/package.json +6 -6
|
@@ -11,19 +11,19 @@ import {
|
|
|
11
11
|
getPlugins,
|
|
12
12
|
setPlugins,
|
|
13
13
|
validatePlugins
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
14
|
+
} from "./chunk-TLMI3Q4Q.js";
|
|
15
|
+
import "./chunk-PDG3BSOD.js";
|
|
16
16
|
import "./chunk-S4PUICSB.js";
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-SH7HDO2D.js";
|
|
18
|
+
import "./chunk-L7L7RYJM.js";
|
|
19
19
|
import "./chunk-VFUK3X5B.js";
|
|
20
|
-
import "./chunk-
|
|
20
|
+
import "./chunk-NK7QVIMJ.js";
|
|
21
21
|
import "./chunk-HZF5P5UN.js";
|
|
22
22
|
import "./chunk-F3B2YJ76.js";
|
|
23
|
-
import "./chunk-
|
|
23
|
+
import "./chunk-AYICPT5T.js";
|
|
24
24
|
import "./chunk-6GWA276C.js";
|
|
25
|
-
import "./chunk-
|
|
26
|
-
import "./chunk-
|
|
25
|
+
import "./chunk-AKL3BAYJ.js";
|
|
26
|
+
import "./chunk-JXQWTNDI.js";
|
|
27
27
|
import "./chunk-MLKGABMK.js";
|
|
28
28
|
export {
|
|
29
29
|
PluginHookDeniedError,
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type ApiRoute } from "../route";
|
|
2
|
+
import { personalSpendReportSchema } from "../schema/person";
|
|
3
|
+
/** Create the self-only spend route with an app-scoped five-minute cache. */
|
|
4
|
+
export declare function createPersonalSpendRoute(): ApiRoute<typeof personalSpendReportSchema>;
|
|
@@ -185,6 +185,14 @@ export declare const actorProfileReportSchema: z.ZodObject<{
|
|
|
185
185
|
windowEnd: z.ZodString;
|
|
186
186
|
windowStart: z.ZodString;
|
|
187
187
|
}, z.core.$strict>;
|
|
188
|
+
export declare const personalSpendReportSchema: z.ZodObject<{
|
|
189
|
+
generatedAt: z.ZodString;
|
|
190
|
+
sevenDaysUsd: z.ZodNumber;
|
|
191
|
+
source: z.ZodLiteral<"conversation_index">;
|
|
192
|
+
thirtyDaysUsd: z.ZodNumber;
|
|
193
|
+
windowEnd: z.ZodString;
|
|
194
|
+
windowStart: z.ZodString;
|
|
195
|
+
}, z.core.$strict>;
|
|
188
196
|
export type ActorIdentity = z.infer<typeof actorIdentitySchema>;
|
|
189
197
|
export type ConversationSummaryReport = z.infer<typeof conversationSummaryReportSchema>;
|
|
190
198
|
export type ConversationStatsItem = z.infer<typeof peopleConversationStatsItemSchema>;
|
|
@@ -194,4 +202,5 @@ export type ActorTotalsReport = z.infer<typeof actorTotalsReportSchema>;
|
|
|
194
202
|
export type ActorSummaryReport = z.infer<typeof actorSummaryReportSchema>;
|
|
195
203
|
export type ActorDirectoryReport = z.infer<typeof actorDirectoryReportSchema>;
|
|
196
204
|
export type ActorProfileReport = z.infer<typeof actorProfileReportSchema>;
|
|
205
|
+
export type PersonalSpendReport = z.infer<typeof personalSpendReportSchema>;
|
|
197
206
|
export type PersonParams = z.infer<typeof personParamsSchema>;
|
package/dist/api/schema.d.ts
CHANGED
|
@@ -2,10 +2,10 @@ export { dailyConversationActivitySchema } from "./activity";
|
|
|
2
2
|
export type { DailyConversationActivity } from "./activity";
|
|
3
3
|
export { archiveConversationBodySchema, archiveConversationResponseSchema, conversationAuxiliaryCostsSchema, conversationDetailQuerySchema, conversationDetailReportSchema, conversationEventPageSchema, conversationEventHistorySchema, conversationEventsQuerySchema, conversationFeedQuerySchema, conversationFeedSchema, conversationParamsSchema, conversationReportEventDataSchema, conversationReportEventSchema, conversationStatsReportSchema, conversationSummaryReportSchema, } from "./schema/conversation";
|
|
4
4
|
export type { ArchiveConversationBody, ArchiveConversationResponse, ActorIdentity, ConversationAuxiliaryCosts, ConversationCost, ConversationDetailReport, ConversationEventPage, ConversationEventHistory, ConversationFeed, ConversationReportEvent, ConversationReportEventData, ConversationReportStatus, ConversationMetricDay, ConversationModelUsage, ConversationParams, ConversationStatsItem, ConversationStatsReport, ConversationSummaryReport, ConversationSurface, ConversationUsage, GuardianMetricDay, GuardianStats, } from "./schema/conversation";
|
|
5
|
-
export { actorDirectoryReportSchema, actorProfileReportSchema, personParamsSchema, } from "./schema/person";
|
|
5
|
+
export { actorDirectoryReportSchema, actorProfileReportSchema, personalSpendReportSchema, personParamsSchema, } from "./schema/person";
|
|
6
6
|
export { locationActivityDayReportSchema, locationDetailReportSchema, locationDirectoryReportSchema, locationParamsSchema, } from "./schema/location";
|
|
7
7
|
export type { LocationActorSummaryReport, LocationActivityDayReport, LocationDetailReport, LocationDirectoryReport, LocationSummaryReport, LocationParams, } from "./schema/location";
|
|
8
|
-
export type { ActorActivityDayReport, ActorDirectoryReport, ActorProfileReport, ActorSummaryReport, ActorTotalsReport, PeopleActivityDayReport, PersonParams, } from "./schema/person";
|
|
8
|
+
export type { ActorActivityDayReport, ActorDirectoryReport, ActorProfileReport, ActorSummaryReport, ActorTotalsReport, PeopleActivityDayReport, PersonalSpendReport, PersonParams, } from "./schema/person";
|
|
9
9
|
export { apiErrorSchema } from "./schema/common";
|
|
10
10
|
export type { ApiError } from "./schema/common";
|
|
11
11
|
export { createPersonalTokenBodySchema, createdPersonalTokenSchema, personalTokenListSchema, personalTokenMetadataSchema, personalTokenParamsSchema, revokePersonalTokenResponseSchema, } from "./schema/personal-token";
|
package/dist/api/schema.js
CHANGED
|
@@ -25,13 +25,14 @@ import {
|
|
|
25
25
|
locationDirectoryReportSchema,
|
|
26
26
|
locationParamsSchema,
|
|
27
27
|
personParamsSchema,
|
|
28
|
+
personalSpendReportSchema,
|
|
28
29
|
personalTokenListSchema,
|
|
29
30
|
personalTokenMetadataSchema,
|
|
30
31
|
personalTokenParamsSchema,
|
|
31
32
|
revokePersonalTokenResponseSchema,
|
|
32
33
|
statSchema,
|
|
33
34
|
statsReportSchema
|
|
34
|
-
} from "../chunk-
|
|
35
|
+
} from "../chunk-AFJF3RGU.js";
|
|
35
36
|
import {
|
|
36
37
|
healthReportSchema,
|
|
37
38
|
pluginOperationalReportFeedSchema,
|
|
@@ -75,6 +76,7 @@ export {
|
|
|
75
76
|
locationDirectoryReportSchema,
|
|
76
77
|
locationParamsSchema,
|
|
77
78
|
personParamsSchema,
|
|
79
|
+
personalSpendReportSchema,
|
|
78
80
|
personalTokenListSchema,
|
|
79
81
|
personalTokenMetadataSchema,
|
|
80
82
|
personalTokenParamsSchema,
|
package/dist/api.js
CHANGED
|
@@ -20,16 +20,17 @@ import {
|
|
|
20
20
|
locationDirectoryReportSchema,
|
|
21
21
|
locationParamsSchema,
|
|
22
22
|
personParamsSchema,
|
|
23
|
+
personalSpendReportSchema,
|
|
23
24
|
personalTokenListSchema,
|
|
24
25
|
personalTokenParamsSchema,
|
|
25
26
|
revokePersonalTokenResponseSchema,
|
|
26
27
|
statsReportSchema
|
|
27
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-AFJF3RGU.js";
|
|
28
29
|
import {
|
|
29
30
|
formatSlackConversationRedactedLabel,
|
|
30
31
|
readHealthReport,
|
|
31
32
|
resolveSlackConversationContextFromThreadId
|
|
32
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-C7AVHH3H.js";
|
|
33
34
|
import {
|
|
34
35
|
buildSentryConversationUrl
|
|
35
36
|
} from "./chunk-4CODA7P5.js";
|
|
@@ -42,10 +43,10 @@ import {
|
|
|
42
43
|
} from "./chunk-UTL3MHPC.js";
|
|
43
44
|
import {
|
|
44
45
|
readStats
|
|
45
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-VHUMNUJL.js";
|
|
46
47
|
import {
|
|
47
48
|
parseSlackThreadId
|
|
48
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-2M6LYDTB.js";
|
|
49
50
|
import {
|
|
50
51
|
agentTurnUsageSchema,
|
|
51
52
|
hasAgentTurnUsage,
|
|
@@ -58,13 +59,13 @@ import {
|
|
|
58
59
|
listConversationAnnotations,
|
|
59
60
|
readViewerActors,
|
|
60
61
|
renderPluginConversationEvent
|
|
61
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-TLMI3Q4Q.js";
|
|
62
63
|
import {
|
|
63
64
|
decodeStoredConversationEvent,
|
|
64
65
|
getDb,
|
|
65
66
|
getSqlExecutor,
|
|
66
67
|
parseSessionSource
|
|
67
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-PDG3BSOD.js";
|
|
68
69
|
import {
|
|
69
70
|
juniorApiTokens,
|
|
70
71
|
juniorConversationEvents,
|
|
@@ -72,23 +73,23 @@ import {
|
|
|
72
73
|
juniorIdentities,
|
|
73
74
|
juniorUsers
|
|
74
75
|
} from "./chunk-S4PUICSB.js";
|
|
75
|
-
import "./chunk-
|
|
76
|
-
import "./chunk-
|
|
76
|
+
import "./chunk-SH7HDO2D.js";
|
|
77
|
+
import "./chunk-L7L7RYJM.js";
|
|
77
78
|
import {
|
|
78
79
|
juniorDestinations
|
|
79
80
|
} from "./chunk-VFUK3X5B.js";
|
|
80
81
|
import {
|
|
81
82
|
canExposeConversationPayload
|
|
82
|
-
} from "./chunk-
|
|
83
|
+
} from "./chunk-NK7QVIMJ.js";
|
|
83
84
|
import "./chunk-HZF5P5UN.js";
|
|
84
85
|
import {
|
|
85
86
|
parseSlackChannelId,
|
|
86
87
|
parseSlackTeamId
|
|
87
88
|
} from "./chunk-F3B2YJ76.js";
|
|
88
|
-
import "./chunk-
|
|
89
|
+
import "./chunk-AYICPT5T.js";
|
|
89
90
|
import "./chunk-6GWA276C.js";
|
|
90
|
-
import "./chunk-
|
|
91
|
-
import "./chunk-
|
|
91
|
+
import "./chunk-AKL3BAYJ.js";
|
|
92
|
+
import "./chunk-JXQWTNDI.js";
|
|
92
93
|
import "./chunk-MLKGABMK.js";
|
|
93
94
|
|
|
94
95
|
// src/api.ts
|
|
@@ -129,8 +130,8 @@ function parseBody(schema, body) {
|
|
|
129
130
|
function defineApiRoute(route) {
|
|
130
131
|
return route;
|
|
131
132
|
}
|
|
132
|
-
function registerApiRoutes(app,
|
|
133
|
-
for (const route of
|
|
133
|
+
function registerApiRoutes(app, routes5) {
|
|
134
|
+
for (const route of routes5) {
|
|
134
135
|
app.on(
|
|
135
136
|
route.method,
|
|
136
137
|
route.path,
|
|
@@ -2014,7 +2015,7 @@ function readDescriptionText(home) {
|
|
|
2014
2015
|
}
|
|
2015
2016
|
}
|
|
2016
2017
|
async function readSkillReports() {
|
|
2017
|
-
const { discoverSkills } = await import("./skills-
|
|
2018
|
+
const { discoverSkills } = await import("./skills-V6X3JVVA.js");
|
|
2018
2019
|
const skills = await discoverSkills();
|
|
2019
2020
|
return skillReportsSchema.parse(
|
|
2020
2021
|
skills.map((skill) => ({
|
|
@@ -2024,7 +2025,7 @@ async function readSkillReports() {
|
|
|
2024
2025
|
);
|
|
2025
2026
|
}
|
|
2026
2027
|
async function readPlugins() {
|
|
2027
|
-
const { pluginCatalogRuntime } = await import("./catalog-runtime-
|
|
2028
|
+
const { pluginCatalogRuntime } = await import("./catalog-runtime-MI5UNBZ7.js");
|
|
2028
2029
|
return pluginsSchema.parse(
|
|
2029
2030
|
pluginCatalogRuntime.getProviders().map((plugin) => ({
|
|
2030
2031
|
configKeys: plugin.manifest.configKeys ?? [],
|
|
@@ -2037,7 +2038,7 @@ async function readPlugins() {
|
|
|
2037
2038
|
async function readRuntimeInfoReport() {
|
|
2038
2039
|
const [{ homeDir }, { pluginCatalogRuntime }, plugins, skills] = await Promise.all([
|
|
2039
2040
|
import("./discovery-GUFTFBTL.js"),
|
|
2040
|
-
import("./catalog-runtime-
|
|
2041
|
+
import("./catalog-runtime-MI5UNBZ7.js"),
|
|
2041
2042
|
readPlugins(),
|
|
2042
2043
|
readSkillReports()
|
|
2043
2044
|
]);
|
|
@@ -2053,7 +2054,7 @@ async function readRuntimeInfoReport() {
|
|
|
2053
2054
|
}
|
|
2054
2055
|
async function readPluginOperationalReportFeed() {
|
|
2055
2056
|
const nowMs = Date.now();
|
|
2056
|
-
const { getPluginOperationalReports } = await import("./agent-hooks-
|
|
2057
|
+
const { getPluginOperationalReports } = await import("./agent-hooks-HMCMFIIO.js");
|
|
2057
2058
|
return pluginOperationalReportFeedSchema.parse({
|
|
2058
2059
|
source: "plugins",
|
|
2059
2060
|
generatedAt: new Date(nowMs).toISOString(),
|
|
@@ -2974,11 +2975,110 @@ var profile_default = defineApiRoute({
|
|
|
2974
2975
|
}
|
|
2975
2976
|
});
|
|
2976
2977
|
|
|
2978
|
+
// src/api/people/spend.query.ts
|
|
2979
|
+
import { and as and12, eq as eq13, gte as gte5, lte as lte2, sql as sql11 } from "drizzle-orm";
|
|
2980
|
+
var SEVEN_DAY_OFFSET = 6;
|
|
2981
|
+
var THIRTY_DAY_OFFSET = 29;
|
|
2982
|
+
function addUsd2(current, next) {
|
|
2983
|
+
return Math.round((current + next) * 1e12) / 1e12;
|
|
2984
|
+
}
|
|
2985
|
+
function spendWindow(nowMs) {
|
|
2986
|
+
const end = new Date(nowMs);
|
|
2987
|
+
const currentDay = new Date(end);
|
|
2988
|
+
currentDay.setUTCHours(0, 0, 0, 0);
|
|
2989
|
+
const sevenDayStart = new Date(currentDay);
|
|
2990
|
+
sevenDayStart.setUTCDate(sevenDayStart.getUTCDate() - SEVEN_DAY_OFFSET);
|
|
2991
|
+
const thirtyDayStart = new Date(currentDay);
|
|
2992
|
+
thirtyDayStart.setUTCDate(thirtyDayStart.getUTCDate() - THIRTY_DAY_OFFSET);
|
|
2993
|
+
return { end, sevenDayStart, thirtyDayStart };
|
|
2994
|
+
}
|
|
2995
|
+
async function readPersonalSpendFromSql(email, nowMs = Date.now()) {
|
|
2996
|
+
const normalizedEmail = normalizeEmail(email);
|
|
2997
|
+
const { end, sevenDayStart, thirtyDayStart } = spendWindow(nowMs);
|
|
2998
|
+
const activityDate = sql11`TO_CHAR(
|
|
2999
|
+
${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
|
|
3000
|
+
'YYYY-MM-DD'
|
|
3001
|
+
)`;
|
|
3002
|
+
const metricsJoin = peopleTreeMetricsJoin();
|
|
3003
|
+
const rows = normalizedEmail ? await getDb().select({
|
|
3004
|
+
costUsd: peopleTreeAggregateColumns.costUsd,
|
|
3005
|
+
date: activityDate
|
|
3006
|
+
}).from(juniorConversations).innerJoin(
|
|
3007
|
+
juniorIdentities,
|
|
3008
|
+
eq13(juniorIdentities.id, juniorConversations.actorIdentityId)
|
|
3009
|
+
).innerJoin(juniorUsers, eq13(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, metricsJoin).where(
|
|
3010
|
+
and12(
|
|
3011
|
+
verifiedActorWhere(normalizedEmail),
|
|
3012
|
+
gte5(juniorConversations.lastActivityAt, thirtyDayStart),
|
|
3013
|
+
lte2(juniorConversations.lastActivityAt, end)
|
|
3014
|
+
)
|
|
3015
|
+
).groupBy(activityDate) : [];
|
|
3016
|
+
const sevenDayStartDate = sevenDayStart.toISOString().slice(0, 10);
|
|
3017
|
+
let sevenDaysUsd = 0;
|
|
3018
|
+
let thirtyDaysUsd = 0;
|
|
3019
|
+
for (const row of rows) {
|
|
3020
|
+
if (row.costUsd === null) continue;
|
|
3021
|
+
thirtyDaysUsd = addUsd2(thirtyDaysUsd, row.costUsd);
|
|
3022
|
+
if (row.date >= sevenDayStartDate) {
|
|
3023
|
+
sevenDaysUsd = addUsd2(sevenDaysUsd, row.costUsd);
|
|
3024
|
+
}
|
|
3025
|
+
}
|
|
3026
|
+
return {
|
|
3027
|
+
generatedAt: new Date(nowMs).toISOString(),
|
|
3028
|
+
sevenDaysUsd,
|
|
3029
|
+
source: "conversation_index",
|
|
3030
|
+
thirtyDaysUsd,
|
|
3031
|
+
windowEnd: end.toISOString(),
|
|
3032
|
+
windowStart: thirtyDayStart.toISOString()
|
|
3033
|
+
};
|
|
3034
|
+
}
|
|
3035
|
+
|
|
3036
|
+
// src/api/people/spend.ts
|
|
3037
|
+
var PERSONAL_SPEND_CACHE_TTL_MS = 5 * 6e4;
|
|
3038
|
+
function createPersonalSpendRoute() {
|
|
3039
|
+
const cache = /* @__PURE__ */ new Map();
|
|
3040
|
+
async function read(email) {
|
|
3041
|
+
const normalizedEmail = email.trim().toLowerCase();
|
|
3042
|
+
const nowMs = Date.now();
|
|
3043
|
+
const cached = cache.get(normalizedEmail);
|
|
3044
|
+
if (cached && cached.expiresAtMs > nowMs) {
|
|
3045
|
+
return cached.report;
|
|
3046
|
+
}
|
|
3047
|
+
cache.delete(normalizedEmail);
|
|
3048
|
+
const report = readPersonalSpendFromSql(normalizedEmail, nowMs);
|
|
3049
|
+
const entry = {
|
|
3050
|
+
expiresAtMs: nowMs + PERSONAL_SPEND_CACHE_TTL_MS,
|
|
3051
|
+
report
|
|
3052
|
+
};
|
|
3053
|
+
cache.set(normalizedEmail, entry);
|
|
3054
|
+
try {
|
|
3055
|
+
return await report;
|
|
3056
|
+
} catch (error) {
|
|
3057
|
+
if (cache.get(normalizedEmail) === entry) cache.delete(normalizedEmail);
|
|
3058
|
+
throw error;
|
|
3059
|
+
}
|
|
3060
|
+
}
|
|
3061
|
+
return defineApiRoute({
|
|
3062
|
+
method: "get",
|
|
3063
|
+
path: "/me/spend",
|
|
3064
|
+
responseSchema: personalSpendReportSchema,
|
|
3065
|
+
handler: async (context) => {
|
|
3066
|
+
const email = context.get("verifiedViewerEmail");
|
|
3067
|
+
if (!email) throwApiError(403, "Verified viewer email required.");
|
|
3068
|
+
return read(email);
|
|
3069
|
+
}
|
|
3070
|
+
});
|
|
3071
|
+
}
|
|
3072
|
+
|
|
2977
3073
|
// src/api/people/routes.ts
|
|
2978
|
-
var routes3 = [list_default3, profile_default];
|
|
2979
3074
|
function createPeopleRoutes() {
|
|
2980
3075
|
const app = new Hono3();
|
|
2981
|
-
|
|
3076
|
+
const routes5 = [
|
|
3077
|
+
createPersonalSpendRoute(),
|
|
3078
|
+
list_default3,
|
|
3079
|
+
profile_default
|
|
3080
|
+
];
|
|
3081
|
+
registerApiRoutes(app, routes5);
|
|
2982
3082
|
return app;
|
|
2983
3083
|
}
|
|
2984
3084
|
|
|
@@ -2995,7 +3095,7 @@ import { Hono as Hono4 } from "hono";
|
|
|
2995
3095
|
|
|
2996
3096
|
// src/personal-tokens/store.ts
|
|
2997
3097
|
import { createHash, randomBytes, randomUUID } from "crypto";
|
|
2998
|
-
import { and as
|
|
3098
|
+
import { and as and13, desc as desc5, eq as eq14, gt, isNull as isNull7 } from "drizzle-orm";
|
|
2999
3099
|
var TOKEN_PREFIX = "jr_pat_";
|
|
3000
3100
|
var TOKEN_SUFFIX_LENGTH = 8;
|
|
3001
3101
|
var DEFAULT_TOKEN_LIFETIME_MS = 90 * 24 * 60 * 60 * 1e3;
|
|
@@ -3032,8 +3132,8 @@ async function createPersonalToken(args) {
|
|
|
3032
3132
|
}
|
|
3033
3133
|
async function listPersonalTokens(email, now = /* @__PURE__ */ new Date()) {
|
|
3034
3134
|
const rows = await getDb().select().from(juniorApiTokens).where(
|
|
3035
|
-
|
|
3036
|
-
|
|
3135
|
+
and13(
|
|
3136
|
+
eq14(juniorApiTokens.ownerEmailNormalized, normalizeEmail2(email)),
|
|
3037
3137
|
isNull7(juniorApiTokens.revokedAt),
|
|
3038
3138
|
gt(juniorApiTokens.expiresAt, now)
|
|
3039
3139
|
)
|
|
@@ -3042,9 +3142,9 @@ async function listPersonalTokens(email, now = /* @__PURE__ */ new Date()) {
|
|
|
3042
3142
|
}
|
|
3043
3143
|
async function revokePersonalToken(args) {
|
|
3044
3144
|
const rows = await getDb().update(juniorApiTokens).set({ revokedAt: args.now ?? /* @__PURE__ */ new Date() }).where(
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3145
|
+
and13(
|
|
3146
|
+
eq14(juniorApiTokens.id, args.id),
|
|
3147
|
+
eq14(juniorApiTokens.ownerEmailNormalized, normalizeEmail2(args.email)),
|
|
3048
3148
|
isNull7(juniorApiTokens.revokedAt)
|
|
3049
3149
|
)
|
|
3050
3150
|
).returning({ id: juniorApiTokens.id });
|
|
@@ -3056,15 +3156,15 @@ async function authenticatePersonalToken(token2, now = /* @__PURE__ */ new Date(
|
|
|
3056
3156
|
id: juniorApiTokens.id,
|
|
3057
3157
|
ownerEmailNormalized: juniorApiTokens.ownerEmailNormalized
|
|
3058
3158
|
}).from(juniorApiTokens).where(
|
|
3059
|
-
|
|
3060
|
-
|
|
3159
|
+
and13(
|
|
3160
|
+
eq14(juniorApiTokens.tokenHash, hashToken(token2)),
|
|
3061
3161
|
isNull7(juniorApiTokens.revokedAt),
|
|
3062
3162
|
gt(juniorApiTokens.expiresAt, now)
|
|
3063
3163
|
)
|
|
3064
3164
|
).limit(1);
|
|
3065
3165
|
const match = rows[0];
|
|
3066
3166
|
if (!match) return void 0;
|
|
3067
|
-
await getDb().update(juniorApiTokens).set({ lastUsedAt: now }).where(
|
|
3167
|
+
await getDb().update(juniorApiTokens).set({ lastUsedAt: now }).where(eq14(juniorApiTokens.id, match.id));
|
|
3068
3168
|
return match.ownerEmailNormalized;
|
|
3069
3169
|
}
|
|
3070
3170
|
|
|
@@ -3116,10 +3216,10 @@ var revoke_default = defineApiRoute({
|
|
|
3116
3216
|
});
|
|
3117
3217
|
|
|
3118
3218
|
// src/api/personal-tokens/routes.ts
|
|
3119
|
-
var
|
|
3219
|
+
var routes3 = [list_default4, create_default, revoke_default];
|
|
3120
3220
|
function createPersonalTokenRoutes() {
|
|
3121
3221
|
const app = new Hono4();
|
|
3122
|
-
registerApiRoutes(app,
|
|
3222
|
+
registerApiRoutes(app, routes3);
|
|
3123
3223
|
return app;
|
|
3124
3224
|
}
|
|
3125
3225
|
|
|
@@ -3280,7 +3380,7 @@ var stats_default2 = defineApiRoute({
|
|
|
3280
3380
|
});
|
|
3281
3381
|
|
|
3282
3382
|
// src/api.ts
|
|
3283
|
-
var
|
|
3383
|
+
var routes4 = [
|
|
3284
3384
|
health_default,
|
|
3285
3385
|
runtime_default,
|
|
3286
3386
|
plugins_default,
|
|
@@ -3290,7 +3390,7 @@ var routes5 = [
|
|
|
3290
3390
|
];
|
|
3291
3391
|
function createJuniorApi() {
|
|
3292
3392
|
const app = new Hono6();
|
|
3293
|
-
registerApiRoutes(app,
|
|
3393
|
+
registerApiRoutes(app, routes4);
|
|
3294
3394
|
app.route("/api/conversations", createConversationRoutes());
|
|
3295
3395
|
app.route("/api/personal-tokens", createPersonalTokenRoutes());
|
|
3296
3396
|
app.route("/api/people", createPeopleRoutes());
|
package/dist/app.js
CHANGED
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
startConversationWork,
|
|
51
51
|
startSlackProcessingReaction,
|
|
52
52
|
stripLeadingBotMention
|
|
53
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-UEMGGJZD.js";
|
|
54
54
|
import "./chunk-FA6POGLH.js";
|
|
55
55
|
import {
|
|
56
56
|
ConversationTurnLifecycleService,
|
|
@@ -65,13 +65,13 @@ import {
|
|
|
65
65
|
processPluginTask,
|
|
66
66
|
requireTurnFailureEventId,
|
|
67
67
|
scheduleSessionCompletedPluginTasks
|
|
68
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-4H2NZPFJ.js";
|
|
69
69
|
import {
|
|
70
70
|
GET,
|
|
71
71
|
conversationVisibilityFromSlackChannelType,
|
|
72
72
|
resolveSlackChannelTypeFromMessage,
|
|
73
73
|
resolveSlackConversationContext
|
|
74
|
-
} from "./chunk-
|
|
74
|
+
} from "./chunk-C7AVHH3H.js";
|
|
75
75
|
import "./chunk-4CODA7P5.js";
|
|
76
76
|
import "./chunk-UTL3MHPC.js";
|
|
77
77
|
import {
|
|
@@ -90,7 +90,7 @@ import {
|
|
|
90
90
|
import {
|
|
91
91
|
validatePluginEgressCredentialHooks,
|
|
92
92
|
validatePluginRegistrations
|
|
93
|
-
} from "./chunk-
|
|
93
|
+
} from "./chunk-NYVMPADK.js";
|
|
94
94
|
import {
|
|
95
95
|
defineJuniorPlugins,
|
|
96
96
|
pluginCatalogConfigFromEnv,
|
|
@@ -124,7 +124,7 @@ import {
|
|
|
124
124
|
setConfigDefaults,
|
|
125
125
|
shouldEmitDevAgentTrace,
|
|
126
126
|
shouldPropagateSandboxEgressTrace
|
|
127
|
-
} from "./chunk-
|
|
127
|
+
} from "./chunk-Z5LLJNTL.js";
|
|
128
128
|
import "./chunk-DIB4GX3G.js";
|
|
129
129
|
import {
|
|
130
130
|
RetryableDeliveryError,
|
|
@@ -135,7 +135,7 @@ import {
|
|
|
135
135
|
formatProviderLabel,
|
|
136
136
|
postSlackMessage,
|
|
137
137
|
startOAuthFlow
|
|
138
|
-
} from "./chunk-
|
|
138
|
+
} from "./chunk-6DU2ZNF7.js";
|
|
139
139
|
import {
|
|
140
140
|
ConversationTurnBoundaryError,
|
|
141
141
|
CooperativeTurnYieldError,
|
|
@@ -191,13 +191,13 @@ import {
|
|
|
191
191
|
trimTrailingAssistantMessages,
|
|
192
192
|
updateConversationStats,
|
|
193
193
|
upsertConversationMessage
|
|
194
|
-
} from "./chunk-
|
|
194
|
+
} from "./chunk-WXP2ZXC7.js";
|
|
195
195
|
import "./chunk-HDSDCEPK.js";
|
|
196
|
-
import "./chunk-
|
|
197
|
-
import "./chunk-
|
|
196
|
+
import "./chunk-YSOZT72W.js";
|
|
197
|
+
import "./chunk-VHUMNUJL.js";
|
|
198
198
|
import {
|
|
199
199
|
parseSlackThreadId
|
|
200
|
-
} from "./chunk-
|
|
200
|
+
} from "./chunk-2M6LYDTB.js";
|
|
201
201
|
import "./chunk-HX236W2U.js";
|
|
202
202
|
import "./chunk-PDO5BLNM.js";
|
|
203
203
|
import "./chunk-UIE3R5XU.js";
|
|
@@ -222,7 +222,7 @@ import {
|
|
|
222
222
|
validatePlugins,
|
|
223
223
|
verifyScheduledTaskCredentialSubject,
|
|
224
224
|
verifySlackDirectCredentialSubject
|
|
225
|
-
} from "./chunk-
|
|
225
|
+
} from "./chunk-TLMI3Q4Q.js";
|
|
226
226
|
import {
|
|
227
227
|
contextProvenance,
|
|
228
228
|
createSlackDestination,
|
|
@@ -233,7 +233,7 @@ import {
|
|
|
233
233
|
instructionProvenanceFor,
|
|
234
234
|
requireSlackDestination,
|
|
235
235
|
withConversationEventLock
|
|
236
|
-
} from "./chunk-
|
|
236
|
+
} from "./chunk-PDG3BSOD.js";
|
|
237
237
|
import {
|
|
238
238
|
juniorConversationEvents,
|
|
239
239
|
juniorConversations
|
|
@@ -242,7 +242,7 @@ import {
|
|
|
242
242
|
acquireActiveLock,
|
|
243
243
|
getStateAdapter,
|
|
244
244
|
sleep
|
|
245
|
-
} from "./chunk-
|
|
245
|
+
} from "./chunk-SH7HDO2D.js";
|
|
246
246
|
import {
|
|
247
247
|
STANDARD_MODEL_PROFILE,
|
|
248
248
|
botConfig,
|
|
@@ -260,16 +260,16 @@ import {
|
|
|
260
260
|
modelIdForProfile,
|
|
261
261
|
setSlackReactionConfig,
|
|
262
262
|
standardModelId
|
|
263
|
-
} from "./chunk-
|
|
263
|
+
} from "./chunk-L7L7RYJM.js";
|
|
264
264
|
import {
|
|
265
265
|
juniorDestinations
|
|
266
266
|
} from "./chunk-VFUK3X5B.js";
|
|
267
|
-
import "./chunk-
|
|
268
|
-
import "./chunk-
|
|
267
|
+
import "./chunk-NK7QVIMJ.js";
|
|
268
|
+
import "./chunk-JNYR4G7A.js";
|
|
269
269
|
import {
|
|
270
270
|
pluginCatalogRuntime
|
|
271
|
-
} from "./chunk-
|
|
272
|
-
import "./chunk-
|
|
271
|
+
} from "./chunk-2N6EL22B.js";
|
|
272
|
+
import "./chunk-FVIU6NQO.js";
|
|
273
273
|
import {
|
|
274
274
|
credentialSubjectSchema
|
|
275
275
|
} from "./chunk-W3U3YQYI.js";
|
|
@@ -301,7 +301,7 @@ import {
|
|
|
301
301
|
withContext,
|
|
302
302
|
withLogContext,
|
|
303
303
|
withSpan
|
|
304
|
-
} from "./chunk-
|
|
304
|
+
} from "./chunk-AYICPT5T.js";
|
|
305
305
|
import {
|
|
306
306
|
continueTrace
|
|
307
307
|
} from "./chunk-6GWA276C.js";
|
|
@@ -309,10 +309,10 @@ import "./chunk-OOUNJNMR.js";
|
|
|
309
309
|
import "./chunk-H4HBKISO.js";
|
|
310
310
|
import {
|
|
311
311
|
JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE
|
|
312
|
-
} from "./chunk-
|
|
312
|
+
} from "./chunk-AKL3BAYJ.js";
|
|
313
313
|
import {
|
|
314
314
|
JUNIOR_VERSION
|
|
315
|
-
} from "./chunk-
|
|
315
|
+
} from "./chunk-JXQWTNDI.js";
|
|
316
316
|
import "./chunk-MLKGABMK.js";
|
|
317
317
|
|
|
318
318
|
// src/app.ts
|
|
@@ -2694,8 +2694,8 @@ var slackConversationMessageMetadataSchema = z5.union([
|
|
|
2694
2694
|
resourceEvent: z5.object({
|
|
2695
2695
|
eventKey: z5.string(),
|
|
2696
2696
|
eventType: z5.string(),
|
|
2697
|
-
|
|
2698
|
-
|
|
2697
|
+
namespace: z5.string(),
|
|
2698
|
+
identifier: z5.string(),
|
|
2699
2699
|
subscriptionId: z5.string()
|
|
2700
2700
|
}).strict()
|
|
2701
2701
|
}).strict()
|
|
@@ -2804,8 +2804,8 @@ function createSlackResourceEventInboundMessage(input) {
|
|
|
2804
2804
|
resourceEvent: {
|
|
2805
2805
|
eventKey: input.event.eventKey,
|
|
2806
2806
|
eventType: input.event.eventType,
|
|
2807
|
-
|
|
2808
|
-
|
|
2807
|
+
namespace: input.event.namespace,
|
|
2808
|
+
identifier: input.event.identifier,
|
|
2809
2809
|
subscriptionId: input.subscription.id
|
|
2810
2810
|
}
|
|
2811
2811
|
}
|
|
@@ -8871,8 +8871,8 @@ async function ingestResourceEvent(input, options) {
|
|
|
8871
8871
|
const subscriptions = await findMatchingResourceEventSubscriptions({
|
|
8872
8872
|
eventType: event.eventType,
|
|
8873
8873
|
nowMs,
|
|
8874
|
-
|
|
8875
|
-
|
|
8874
|
+
namespace: event.namespace,
|
|
8875
|
+
identifier: event.identifier,
|
|
8876
8876
|
state: options.state
|
|
8877
8877
|
});
|
|
8878
8878
|
let enqueued = 0;
|
|
@@ -8882,8 +8882,8 @@ async function ingestResourceEvent(input, options) {
|
|
|
8882
8882
|
try {
|
|
8883
8883
|
const delivered = await deliverResourceEventSubscription({
|
|
8884
8884
|
eventType: event.eventType,
|
|
8885
|
-
|
|
8886
|
-
|
|
8885
|
+
namespace: event.namespace,
|
|
8886
|
+
identifier: event.identifier,
|
|
8887
8887
|
terminal: event.terminal,
|
|
8888
8888
|
nowMs,
|
|
8889
8889
|
state: options.state,
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
pluginCatalogRuntime
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-2N6EL22B.js";
|
|
4
|
+
import "./chunk-FVIU6NQO.js";
|
|
5
5
|
import "./chunk-W3U3YQYI.js";
|
|
6
6
|
import "./chunk-HZF5P5UN.js";
|
|
7
7
|
import "./chunk-F3B2YJ76.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-AYICPT5T.js";
|
|
9
9
|
import "./chunk-6GWA276C.js";
|
|
10
10
|
import "./chunk-OOUNJNMR.js";
|
|
11
11
|
import "./chunk-H4HBKISO.js";
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-AKL3BAYJ.js";
|
|
13
|
+
import "./chunk-JXQWTNDI.js";
|
|
14
14
|
import "./chunk-MLKGABMK.js";
|
|
15
15
|
export {
|
|
16
16
|
pluginCatalogRuntime
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PluginRoute, PluginOperationalReport, PluginRouteApp,
|
|
1
|
+
import type { PluginRoute, PluginOperationalReport, PluginRouteApp, ResourceEvent, SlackConversationLink, PluginRegistration } from "@sentry/junior-plugin-api";
|
|
2
2
|
import type { PluginPromptContributionContext } from "@/chat/plugins/prompt";
|
|
3
3
|
import type { AnyToolDefinition } from "@/chat/tools/definition";
|
|
4
4
|
import type { ToolRuntimeContext } from "@/chat/tools/types";
|
|
@@ -54,7 +54,9 @@ export declare function getPluginUserPromptContributions(args: {
|
|
|
54
54
|
export declare function getPluginTools(context: ToolRuntimeContext): Record<string, AnyToolDefinition>;
|
|
55
55
|
/** Collect route handlers exposed by plugins for app-level mounting. */
|
|
56
56
|
export declare function getPluginRoutes(options: {
|
|
57
|
-
resourceEvents:
|
|
57
|
+
resourceEvents: {
|
|
58
|
+
publish(event: ResourceEvent): Promise<void>;
|
|
59
|
+
};
|
|
58
60
|
}): PluginRouteRegistration[];
|
|
59
61
|
/** Collect authenticated product API route apps exposed by plugins. */
|
|
60
62
|
export declare function getPluginApiRoutes(): PluginApiRouteRegistration[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type PluginResourceEvents } from "@sentry/junior-plugin-api";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
type ResourceEventRegistration = Pick<PluginResourceEvents, "resourceTypes" | "normalizeIdentifier">;
|
|
4
|
+
export type ResourceEventCatalog = Readonly<Record<string, ResourceEventRegistration>>;
|
|
5
|
+
/** Build the model-facing namespace enum from enabled resource event plugins. */
|
|
6
|
+
export declare function eventNamespaceSchema(catalog: ResourceEventCatalog): z.ZodString | z.ZodEnum<{
|
|
7
|
+
[x: string]: string;
|
|
8
|
+
}>;
|
|
9
|
+
/** Build the model-facing event enum from enabled plugin registrations. */
|
|
10
|
+
export declare function registeredEventTypeSchema(catalog: ResourceEventCatalog): z.ZodString | z.ZodEnum<{
|
|
11
|
+
[x: string]: string;
|
|
12
|
+
}>;
|
|
13
|
+
/** Build the model-facing resource type enum from enabled plugin registrations. */
|
|
14
|
+
export declare function registeredResourceTypeSchema(catalog: ResourceEventCatalog): z.ZodString | z.ZodEnum<{
|
|
15
|
+
[x: string]: string;
|
|
16
|
+
}>;
|
|
17
|
+
/** Return whether one enabled plugin declared an event type. */
|
|
18
|
+
export declare function pluginSupportsEvent(catalog: ResourceEventCatalog, namespace: string, resourceType: string, eventType: string): boolean;
|
|
19
|
+
/** Normalize one selector with the convention declared by its plugin. */
|
|
20
|
+
export declare function normalizeEventIdentifier(catalog: ResourceEventCatalog, namespace: string, identifier: string): string;
|
|
21
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { StateAdapter } from "chat";
|
|
2
2
|
import type { ConversationWorkQueue } from "@/chat/task-execution/queue";
|
|
3
|
-
/** Match a normalized
|
|
3
|
+
/** Match a normalized resource event and enqueue notifications into conversations. */
|
|
4
4
|
export declare function ingestResourceEvent(input: unknown, options: {
|
|
5
5
|
nowMs?: number;
|
|
6
6
|
queue: ConversationWorkQueue;
|