@sentry/junior 0.96.0 → 0.97.1

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.
Files changed (135) hide show
  1. package/dist/{agent-hooks-5URSMY3O.js → agent-hooks-XSUIVRQS.js} +8 -6
  2. package/dist/{reporting → api}/conversations/activity.d.ts +1 -1
  3. package/dist/api/conversations/detail-projection.d.ts +10 -0
  4. package/dist/api/conversations/detail.d.ts +3 -0
  5. package/dist/api/conversations/detail.query.d.ts +3 -0
  6. package/dist/api/conversations/list.d.ts +3 -0
  7. package/dist/api/conversations/list.query.d.ts +94 -0
  8. package/dist/api/conversations/projection.d.ts +14 -0
  9. package/dist/api/conversations/schema.d.ts +683 -0
  10. package/dist/{reporting → api}/conversations/shared.d.ts +1 -5
  11. package/dist/api/conversations/stats.d.ts +3 -0
  12. package/dist/api/conversations/stats.query.d.ts +3 -0
  13. package/dist/api/conversations/subagent.d.ts +3 -0
  14. package/dist/{reporting → api}/conversations/transcript.d.ts +4 -4
  15. package/dist/api/people/list.d.ts +1 -2
  16. package/dist/api/people/list.query.d.ts +3 -4
  17. package/dist/api/people/profile.d.ts +1 -2
  18. package/dist/api/people/profile.query.d.ts +3 -4
  19. package/dist/api/people/schema.d.ts +193 -0
  20. package/dist/api/people/shared.d.ts +31 -9
  21. package/dist/api/schema.d.ts +20 -0
  22. package/dist/api/schema.js +50 -0
  23. package/dist/api-reference.d.ts +4 -3
  24. package/dist/api.d.ts +3 -0
  25. package/dist/api.js +156 -0
  26. package/dist/app.d.ts +1 -4
  27. package/dist/app.js +101 -367
  28. package/dist/build/virtual-config.d.ts +2 -2
  29. package/dist/{catalog-runtime-MSMAYYIK.js → catalog-runtime-PFHVMHDR.js} +3 -2
  30. package/dist/chat/agent/resume.d.ts +3 -1
  31. package/dist/chat/agent/tools.d.ts +2 -1
  32. package/dist/chat/config.d.ts +1 -8
  33. package/dist/chat/conversations/history.d.ts +241 -27
  34. package/dist/chat/conversations/legacy-advisor-session.d.ts +7 -0
  35. package/dist/chat/conversations/legacy-import.d.ts +2 -2
  36. package/dist/chat/conversations/projection.d.ts +19 -3
  37. package/dist/chat/conversations/sql/legacy-history-import.d.ts +1 -1
  38. package/dist/chat/conversations/sql/store.d.ts +15 -9
  39. package/dist/chat/conversations/store.d.ts +9 -4
  40. package/dist/chat/model-profile.d.ts +14 -0
  41. package/dist/chat/pi/transcript.d.ts +5 -3
  42. package/dist/chat/resource-events/store.d.ts +2 -2
  43. package/dist/chat/services/context-compaction.d.ts +15 -0
  44. package/dist/chat/services/turn-result.d.ts +1 -0
  45. package/dist/chat/services/turn-session-record.d.ts +6 -6
  46. package/dist/chat/state/turn-session.d.ts +16 -5
  47. package/dist/chat/task-execution/store.d.ts +2 -2
  48. package/dist/chat/tools/handoff/tool.d.ts +45 -0
  49. package/dist/chat/tools/types.d.ts +7 -2
  50. package/dist/chat/usage.d.ts +25 -25
  51. package/dist/{chunk-RITD7E5L.js → chunk-35BNLDOJ.js} +338 -577
  52. package/dist/{chunk-PMNN6ST4.js → chunk-3ECW2K2O.js} +7 -2
  53. package/dist/{chunk-5C6XTTFI.js → chunk-3F4OPKGF.js} +89 -55
  54. package/dist/chunk-3V7OFJZC.js +264 -0
  55. package/dist/chunk-4ZNGQH7C.js +25 -0
  56. package/dist/{chunk-S5KZ5LPG.js → chunk-5HLDPVYS.js} +14 -447
  57. package/dist/{chunk-DZENG5ML.js → chunk-6U26PYI5.js} +24 -14
  58. package/dist/chunk-AUUCAFDE.js +546 -0
  59. package/dist/{chunk-6APU57E6.js → chunk-B3IT5END.js} +41 -260
  60. package/dist/chunk-CEA3A3UA.js +86 -0
  61. package/dist/{chunk-YDT7SNCN.js → chunk-D5KZYS4T.js} +1 -1
  62. package/dist/{chunk-YDVEH3SB.js → chunk-EEZCY5WX.js} +78 -28
  63. package/dist/{chunk-2NAZZPPS.js → chunk-EOWXRY5E.js} +1 -1
  64. package/dist/{chunk-GQ3GK22G.js → chunk-FBHZJFHI.js} +2 -2
  65. package/dist/{chunk-CZEX6KIQ.js → chunk-G3E7SCME.js} +0 -23
  66. package/dist/chunk-GUAP3H7O.js +319 -0
  67. package/dist/{chunk-BYZWPRJA.js → chunk-H66UCBPW.js} +6 -4
  68. package/dist/{chunk-L7CDEIVJ.js → chunk-LMJPRYHP.js} +4 -2
  69. package/dist/chunk-LUAE4MGW.js +199 -0
  70. package/dist/{chunk-GY34VGP5.js → chunk-LVA4I4H7.js} +3 -1
  71. package/dist/chunk-LVUKF5CE.js +63 -0
  72. package/dist/{chunk-AAZXTVJT.js → chunk-NG2AV7IB.js} +2 -72
  73. package/dist/chunk-ON6YKIQ7.js +260 -0
  74. package/dist/chunk-PDO5BLNM.js +22 -0
  75. package/dist/chunk-QNVHH5PU.js +20 -0
  76. package/dist/{chunk-P3YFQLEN.js → chunk-T533JLM3.js} +8 -10
  77. package/dist/chunk-UAMKJPDF.js +11 -0
  78. package/dist/chunk-VFH4ZKZT.js +66 -0
  79. package/dist/{chunk-UKHVMPX5.js → chunk-WGXMTFNU.js} +15 -17
  80. package/dist/{chunk-MNTINMWR.js → chunk-WJOSZOON.js} +184 -300
  81. package/dist/chunk-WTYEKPXU.js +451 -0
  82. package/dist/{chunk-IYM2SIVG.js → chunk-XIRPQQVE.js} +605 -363
  83. package/dist/cli/chat.js +24 -21
  84. package/dist/cli/check.js +4 -3
  85. package/dist/cli/init.js +12 -0
  86. package/dist/cli/plugins.js +12 -9
  87. package/dist/cli/snapshot-warmup.js +8 -6
  88. package/dist/cli/upgrade.js +265 -137
  89. package/dist/db/db.d.ts +4 -0
  90. package/dist/db/schema/conversations.d.ts +128 -0
  91. package/dist/db/schema.d.ts +129 -60
  92. package/dist/{db-2D6RMG67.js → db-BWXYIKFQ.js} +3 -3
  93. package/dist/detail-GA6NXWQJ.js +43 -0
  94. package/dist/discovery-RMHYSRL7.js +43 -0
  95. package/dist/handlers/health.d.ts +3 -0
  96. package/dist/instrumentation.js +1 -1
  97. package/dist/{legacy-import-VZ2MEGP7.js → legacy-import-3NQJVGQL.js} +4 -4
  98. package/dist/{api/people/list.js → list-A3WFRIYX.js} +26 -16
  99. package/dist/list-UXJI5Q5X.js +27 -0
  100. package/dist/nitro.d.ts +1 -1
  101. package/dist/nitro.js +2 -1
  102. package/dist/plugin-conversations-DDNGC35A.js +36 -0
  103. package/dist/{api/people/profile.js → profile-4RYDXWTF.js} +33 -18
  104. package/dist/reporting/plugin-conversations.d.ts +3 -0
  105. package/dist/reporting-schema.d.ts +140 -0
  106. package/dist/reporting.d.ts +12 -81
  107. package/dist/{runner-JZBRQP4F.js → runner-JALSYH2P.js} +17 -12
  108. package/dist/skills-MAZXZ2KE.js +26 -0
  109. package/dist/stats-XKXH3PTY.js +217 -0
  110. package/dist/subagent-TZ55XY37.js +48 -0
  111. package/dist/usage-schema.d.ts +25 -0
  112. package/dist/{validation-6XOOQGME.js → validation-FMEAEKCY.js} +4 -3
  113. package/migrations/0000_initial.sql +115 -0
  114. package/migrations/0001_conversation_metrics.sql +4 -0
  115. package/migrations/README.md +12 -30
  116. package/migrations/meta/0000_snapshot.json +1 -33
  117. package/migrations/meta/0001_snapshot.json +972 -0
  118. package/migrations/meta/_journal.json +9 -2
  119. package/package.json +13 -17
  120. package/dist/api/people/types.d.ts +0 -85
  121. package/dist/chat/advisor-request.d.ts +0 -4
  122. package/dist/chat/conversations/sql/migrations.d.ts +0 -22
  123. package/dist/chat/tools/advisor/session-store.d.ts +0 -9
  124. package/dist/chat/tools/advisor/tool.d.ts +0 -72
  125. package/dist/chunk-RAIB6WSG.js +0 -142
  126. package/dist/chunk-WM6KHPBQ.js +0 -48
  127. package/dist/db/schema/migrations.d.ts +0 -58
  128. package/dist/reporting/conversations/context.d.ts +0 -8
  129. package/dist/reporting/conversations/details.d.ts +0 -6
  130. package/dist/reporting/conversations/index.d.ts +0 -4
  131. package/dist/reporting/conversations/statistics.d.ts +0 -4
  132. package/dist/reporting/conversations/summaries.d.ts +0 -20
  133. package/dist/reporting/conversations/types.d.ts +0 -191
  134. package/dist/reporting/conversations.d.ts +0 -1
  135. package/dist/reporting.js +0 -1155
@@ -0,0 +1,140 @@
1
+ import { z } from "zod";
2
+ export declare const healthReportSchema: z.ZodObject<{
3
+ status: z.ZodLiteral<"ok">;
4
+ service: z.ZodString;
5
+ timestamp: z.ZodString;
6
+ }, z.core.$strict>;
7
+ export declare const pluginReportSchema: z.ZodObject<{
8
+ name: z.ZodString;
9
+ }, z.core.$strict>;
10
+ export declare const pluginReportsSchema: z.ZodArray<z.ZodObject<{
11
+ name: z.ZodString;
12
+ }, z.core.$strict>>;
13
+ export declare const skillReportSchema: z.ZodObject<{
14
+ name: z.ZodString;
15
+ pluginProvider: z.ZodOptional<z.ZodString>;
16
+ }, z.core.$strict>;
17
+ export declare const skillReportsSchema: z.ZodArray<z.ZodObject<{
18
+ name: z.ZodString;
19
+ pluginProvider: z.ZodOptional<z.ZodString>;
20
+ }, z.core.$strict>>;
21
+ export declare const pluginPackageContentItemReportSchema: z.ZodObject<{
22
+ dir: z.ZodString;
23
+ hasMigrationsDir: z.ZodBoolean;
24
+ hasSkillsDir: z.ZodBoolean;
25
+ packageName: z.ZodString;
26
+ }, z.core.$strict>;
27
+ export declare const pluginPackageContentReportSchema: z.ZodObject<{
28
+ packageNames: z.ZodArray<z.ZodString>;
29
+ packages: z.ZodArray<z.ZodObject<{
30
+ dir: z.ZodString;
31
+ hasMigrationsDir: z.ZodBoolean;
32
+ hasSkillsDir: z.ZodBoolean;
33
+ packageName: z.ZodString;
34
+ }, z.core.$strict>>;
35
+ manifestRoots: z.ZodArray<z.ZodString>;
36
+ skillRoots: z.ZodArray<z.ZodString>;
37
+ tracingIncludes: z.ZodArray<z.ZodString>;
38
+ }, z.core.$strict>;
39
+ export declare const runtimeInfoReportSchema: z.ZodObject<{
40
+ cwd: z.ZodString;
41
+ homeDir: z.ZodString;
42
+ descriptionText: z.ZodOptional<z.ZodString>;
43
+ providers: z.ZodArray<z.ZodString>;
44
+ skills: z.ZodArray<z.ZodObject<{
45
+ name: z.ZodString;
46
+ pluginProvider: z.ZodOptional<z.ZodString>;
47
+ }, z.core.$strict>>;
48
+ packagedContent: z.ZodObject<{
49
+ packageNames: z.ZodArray<z.ZodString>;
50
+ packages: z.ZodArray<z.ZodObject<{
51
+ dir: z.ZodString;
52
+ hasMigrationsDir: z.ZodBoolean;
53
+ hasSkillsDir: z.ZodBoolean;
54
+ packageName: z.ZodString;
55
+ }, z.core.$strict>>;
56
+ manifestRoots: z.ZodArray<z.ZodString>;
57
+ skillRoots: z.ZodArray<z.ZodString>;
58
+ tracingIncludes: z.ZodArray<z.ZodString>;
59
+ }, z.core.$strict>;
60
+ }, z.core.$strict>;
61
+ export declare const pluginOperationalReportSchema: z.ZodObject<{
62
+ generatedAt: z.ZodOptional<z.ZodString>;
63
+ metrics: z.ZodOptional<z.ZodArray<z.ZodObject<{
64
+ label: z.ZodString;
65
+ tone: z.ZodOptional<z.ZodEnum<{
66
+ danger: "danger";
67
+ good: "good";
68
+ neutral: "neutral";
69
+ warning: "warning";
70
+ }>>;
71
+ value: z.ZodString;
72
+ }, z.core.$strict>>>;
73
+ recordSets: z.ZodOptional<z.ZodArray<z.ZodObject<{
74
+ fields: z.ZodOptional<z.ZodArray<z.ZodObject<{
75
+ key: z.ZodString;
76
+ label: z.ZodString;
77
+ }, z.core.$strict>>>;
78
+ emptyText: z.ZodOptional<z.ZodString>;
79
+ records: z.ZodOptional<z.ZodArray<z.ZodObject<{
80
+ id: z.ZodString;
81
+ tone: z.ZodOptional<z.ZodEnum<{
82
+ danger: "danger";
83
+ good: "good";
84
+ neutral: "neutral";
85
+ warning: "warning";
86
+ }>>;
87
+ values: z.ZodRecord<z.ZodString, z.ZodString>;
88
+ }, z.core.$strict>>>;
89
+ title: z.ZodString;
90
+ }, z.core.$strict>>>;
91
+ title: z.ZodOptional<z.ZodString>;
92
+ pluginName: z.ZodString;
93
+ }, z.core.$strict>;
94
+ export declare const pluginOperationalReportFeedSchema: z.ZodObject<{
95
+ generatedAt: z.ZodString;
96
+ reports: z.ZodArray<z.ZodObject<{
97
+ generatedAt: z.ZodOptional<z.ZodString>;
98
+ metrics: z.ZodOptional<z.ZodArray<z.ZodObject<{
99
+ label: z.ZodString;
100
+ tone: z.ZodOptional<z.ZodEnum<{
101
+ danger: "danger";
102
+ good: "good";
103
+ neutral: "neutral";
104
+ warning: "warning";
105
+ }>>;
106
+ value: z.ZodString;
107
+ }, z.core.$strict>>>;
108
+ recordSets: z.ZodOptional<z.ZodArray<z.ZodObject<{
109
+ fields: z.ZodOptional<z.ZodArray<z.ZodObject<{
110
+ key: z.ZodString;
111
+ label: z.ZodString;
112
+ }, z.core.$strict>>>;
113
+ emptyText: z.ZodOptional<z.ZodString>;
114
+ records: z.ZodOptional<z.ZodArray<z.ZodObject<{
115
+ id: z.ZodString;
116
+ tone: z.ZodOptional<z.ZodEnum<{
117
+ danger: "danger";
118
+ good: "good";
119
+ neutral: "neutral";
120
+ warning: "warning";
121
+ }>>;
122
+ values: z.ZodRecord<z.ZodString, z.ZodString>;
123
+ }, z.core.$strict>>>;
124
+ title: z.ZodString;
125
+ }, z.core.$strict>>>;
126
+ title: z.ZodOptional<z.ZodString>;
127
+ pluginName: z.ZodString;
128
+ }, z.core.$strict>>;
129
+ source: z.ZodLiteral<"plugins">;
130
+ }, z.core.$strict>;
131
+ export type HealthReport = z.infer<typeof healthReportSchema>;
132
+ export type PluginReport = z.infer<typeof pluginReportSchema>;
133
+ export type PluginReports = z.infer<typeof pluginReportsSchema>;
134
+ export type SkillReport = z.infer<typeof skillReportSchema>;
135
+ export type SkillReports = z.infer<typeof skillReportsSchema>;
136
+ export type RuntimeInfoReport = z.infer<typeof runtimeInfoReportSchema>;
137
+ export type PluginPackageContentItemReport = z.infer<typeof pluginPackageContentItemReportSchema>;
138
+ export type PluginPackageContentReport = z.infer<typeof pluginPackageContentReportSchema>;
139
+ export type PluginOperationalReport = z.infer<typeof pluginOperationalReportSchema>;
140
+ export type PluginOperationalReportFeed = z.infer<typeof pluginOperationalReportFeedSchema>;
@@ -1,81 +1,12 @@
1
- import type { PluginOperationalReport } from "@sentry/junior-plugin-api";
2
- import { type ConversationFeed, type PluginConversationSummary, type ConversationReport, type ConversationSubagentTranscriptReport, type ConversationStatsReport } from "./reporting/conversations";
3
- export type { PluginConversationStatus, PluginConversations, PluginConversationSummary, ConversationActivityReport, ConversationActivityStatus, ConversationCost, ConversationFeed, ConversationReport, ConversationReportStatus, ConversationRunReport, ConversationSubagentActivityReport, ConversationSubagentTranscriptReport, ConversationStatsItem, ConversationStatsReport, ConversationSummaryReport, ConversationSurface, ConversationToolActivityReport, ConversationUsage, ActorIdentity, TranscriptMessage, TranscriptPart, TranscriptPartType, TranscriptRole, } from "./reporting/conversations";
4
- export interface HealthReport {
5
- status: "ok";
6
- service: string;
7
- timestamp: string;
8
- }
9
- export interface PluginReport {
10
- name: string;
11
- }
12
- export interface SkillReport {
13
- name: string;
14
- pluginProvider?: string;
15
- }
16
- export interface RuntimeInfoReport {
17
- cwd: string;
18
- homeDir: string;
19
- descriptionText?: string;
20
- providers: string[];
21
- skills: SkillReport[];
22
- packagedContent: PluginPackageContentReport;
23
- }
24
- export interface PluginPackageContentItemReport {
25
- dir: string;
26
- hasMigrationsDir: boolean;
27
- hasSkillsDir: boolean;
28
- packageName: string;
29
- }
30
- export interface PluginPackageContentReport {
31
- packageNames: string[];
32
- packages: PluginPackageContentItemReport[];
33
- manifestRoots: string[];
34
- skillRoots: string[];
35
- tracingIncludes: string[];
36
- }
37
- export type { PluginOperationalReport } from "@sentry/junior-plugin-api";
38
- export interface PluginOperationalReportFeed {
39
- generatedAt: string;
40
- reports: PluginOperationalReport[];
41
- source: "plugins";
42
- }
43
- export interface JuniorReporting {
44
- /** Read the public runtime health snapshot without exposing discovery data. */
45
- getHealth(): Promise<HealthReport>;
46
- /** Read authenticated runtime discovery data for reporting consumers. */
47
- getRuntimeInfo(): Promise<RuntimeInfoReport>;
48
- /** Read configured plugin names for reporting consumers. */
49
- getPlugins(): Promise<PluginReport[]>;
50
- /** Read discovered skill names for reporting consumers. */
51
- getSkills(): Promise<SkillReport[]>;
52
- /** List recent conversation summaries for reporting consumers. */
53
- listConversations(): Promise<ConversationFeed>;
54
- /** Read aggregate conversation stats for reporting consumers. */
55
- getConversationStats?(): Promise<ConversationStatsReport>;
56
- /** Read recent conversation summaries without transcript payloads. */
57
- listRecentConversations?(options?: {
58
- limit?: number;
59
- }): Promise<PluginConversationSummary[]>;
60
- /** Read sanitized operational summaries contributed by plugins. */
61
- getPluginOperationalReports?(): Promise<PluginOperationalReportFeed>;
62
- /**
63
- * Read one conversation transcript for reporting consumers.
64
- *
65
- * Transcript messages and activity steps come from SQL (`junior_agent_steps`
66
- * / `junior_conversation_messages`); the API should stay compatible with a
67
- * future Sentry trace-history source, so avoid fields that require store
68
- * internals.
69
- */
70
- getConversation(conversationId: string): Promise<ConversationReport>;
71
- /** Load a child-agent transcript only when an operator opens that subagent. */
72
- getConversationSubagentTranscript(conversationId: string, runId: string, subagentId: string): Promise<ConversationSubagentTranscriptReport>;
73
- }
74
- /** Create the read-only reporting boundary used by plugins and other consumers. */
75
- export declare function createJuniorReporting(): JuniorReporting & {
76
- getConversationStats(): Promise<ConversationStatsReport>;
77
- listRecentConversations(options?: {
78
- limit?: number;
79
- }): Promise<PluginConversationSummary[]>;
80
- getPluginOperationalReports(): Promise<PluginOperationalReportFeed>;
81
- };
1
+ import type { PluginOperationalReportFeed, PluginReport, RuntimeInfoReport, SkillReport } from "./reporting-schema";
2
+ export { healthReportSchema, pluginOperationalReportFeedSchema, pluginOperationalReportSchema, pluginPackageContentItemReportSchema, pluginPackageContentReportSchema, pluginReportSchema, pluginReportsSchema, runtimeInfoReportSchema, skillReportSchema, skillReportsSchema, } from "./reporting-schema";
3
+ export { readHealthReport } from "./handlers/health";
4
+ export type { HealthReport, PluginOperationalReport, PluginOperationalReportFeed, PluginPackageContentItemReport, PluginPackageContentReport, PluginReport, PluginReports, RuntimeInfoReport, SkillReport, SkillReports, } from "./reporting-schema";
5
+ /** Read discovered skill names for authenticated runtime diagnostics. */
6
+ export declare function readSkillReports(): Promise<SkillReport[]>;
7
+ /** Read configured plugin names for authenticated runtime diagnostics. */
8
+ export declare function readPluginReports(): Promise<PluginReport[]>;
9
+ /** Read authenticated runtime discovery data. */
10
+ export declare function readRuntimeInfoReport(): Promise<RuntimeInfoReport>;
11
+ /** Read sanitized operational summaries contributed by plugins. */
12
+ export declare function readPluginOperationalReportFeed(): Promise<PluginOperationalReportFeed>;
@@ -3,7 +3,7 @@ import {
3
3
  finalizeFailedTurnReply,
4
4
  processPluginTask,
5
5
  scheduleSessionCompletedPluginTasks
6
- } from "./chunk-P3YFQLEN.js";
6
+ } from "./chunk-T533JLM3.js";
7
7
  import "./chunk-KNFROR7R.js";
8
8
  import {
9
9
  coerceThreadArtifactsState,
@@ -13,14 +13,14 @@ import {
13
13
  markTurnFailed,
14
14
  persistThreadStateById,
15
15
  startActiveTurn
16
- } from "./chunk-UKHVMPX5.js";
16
+ } from "./chunk-WGXMTFNU.js";
17
17
  import {
18
18
  coerceThreadConversationState
19
- } from "./chunk-RAIB6WSG.js";
19
+ } from "./chunk-WJOSZOON.js";
20
20
  import {
21
21
  commitMessages,
22
22
  loadProjection
23
- } from "./chunk-MNTINMWR.js";
23
+ } from "./chunk-GUAP3H7O.js";
24
24
  import {
25
25
  buildConversationContext,
26
26
  hydrateConversationMessages,
@@ -28,18 +28,21 @@ import {
28
28
  normalizeConversationText,
29
29
  updateConversationStats,
30
30
  upsertConversationMessage
31
- } from "./chunk-5C6XTTFI.js";
32
- import "./chunk-S5KZ5LPG.js";
33
- import "./chunk-2NAZZPPS.js";
31
+ } from "./chunk-3F4OPKGF.js";
32
+ import "./chunk-PDO5BLNM.js";
33
+ import "./chunk-5HLDPVYS.js";
34
+ import "./chunk-WTYEKPXU.js";
35
+ import "./chunk-EOWXRY5E.js";
36
+ import "./chunk-35BNLDOJ.js";
37
+ import "./chunk-G3E7SCME.js";
34
38
  import {
35
39
  sleep
36
- } from "./chunk-CZEX6KIQ.js";
37
- import "./chunk-RITD7E5L.js";
40
+ } from "./chunk-4ZNGQH7C.js";
38
41
  import {
39
42
  stripRuntimeTurnContext,
40
43
  trimTrailingAssistantMessages
41
- } from "./chunk-YDVEH3SB.js";
42
- import "./chunk-GY34VGP5.js";
44
+ } from "./chunk-EEZCY5WX.js";
45
+ import "./chunk-LVA4I4H7.js";
43
46
  import "./chunk-B7PUBQQM.js";
44
47
  import {
45
48
  logException
@@ -248,6 +251,7 @@ async function runLocalAgentTurn(input, deps) {
248
251
  if (reply) {
249
252
  await commitMessages({
250
253
  conversationId: input.conversationId,
254
+ modelId: reply.diagnostics.modelId,
251
255
  messages: piMessagesBeforeRun ?? []
252
256
  });
253
257
  }
@@ -279,6 +283,7 @@ async function runLocalAgentTurn(input, deps) {
279
283
  sessionId: turnId,
280
284
  sliceId: 1,
281
285
  messages: reply.piMessages,
286
+ modelId: reply.diagnostics.modelId,
282
287
  durationMs: reply.diagnostics.durationMs,
283
288
  usage: reply.diagnostics.usage,
284
289
  reasoningLevel: reply.diagnostics.thinkingLevel,
@@ -286,7 +291,7 @@ async function runLocalAgentTurn(input, deps) {
286
291
  source,
287
292
  actor: localActor,
288
293
  surface: "internal",
289
- logContext: { modelId: reply.diagnostics.modelId }
294
+ logContext: {}
290
295
  });
291
296
  }
292
297
  if (reply.diagnostics.outcome === "success") {
@@ -0,0 +1,26 @@
1
+ import {
2
+ discoverSkills,
3
+ findSkillByName,
4
+ loadSkillsByName,
5
+ parseSkillFile,
6
+ parseSkillInvocation,
7
+ resetSkillDiscoveryCache,
8
+ stripFrontmatter
9
+ } from "./chunk-3ECW2K2O.js";
10
+ import "./chunk-LMJPRYHP.js";
11
+ import "./chunk-I35CTGPO.js";
12
+ import "./chunk-OB42YVAE.js";
13
+ import "./chunk-6GWA276C.js";
14
+ import "./chunk-B3IT5END.js";
15
+ import "./chunk-7FBGKXPE.js";
16
+ import "./chunk-3V7OFJZC.js";
17
+ import "./chunk-MLKGABMK.js";
18
+ export {
19
+ discoverSkills,
20
+ findSkillByName,
21
+ loadSkillsByName,
22
+ parseSkillFile,
23
+ parseSkillInvocation,
24
+ resetSkillDiscoveryCache,
25
+ stripFrontmatter
26
+ };
@@ -0,0 +1,217 @@
1
+ import {
2
+ conversationStatsReportSchema
3
+ } from "./chunk-LUAE4MGW.js";
4
+ import "./chunk-PDO5BLNM.js";
5
+ import {
6
+ getDb,
7
+ juniorConversations,
8
+ juniorDestinations,
9
+ juniorIdentities,
10
+ juniorUsers
11
+ } from "./chunk-35BNLDOJ.js";
12
+ import "./chunk-EEZCY5WX.js";
13
+ import "./chunk-LVA4I4H7.js";
14
+ import "./chunk-B7PUBQQM.js";
15
+ import "./chunk-I35CTGPO.js";
16
+ import "./chunk-OB42YVAE.js";
17
+ import "./chunk-6GWA276C.js";
18
+ import "./chunk-7FBGKXPE.js";
19
+ import "./chunk-MLKGABMK.js";
20
+
21
+ // src/api/conversations/stats.query.ts
22
+ import { and, asc, desc, eq, gte, isNull, lte } from "drizzle-orm";
23
+ var SAMPLE_LIMIT = 5e3;
24
+ var WINDOW_MS = 7 * 24 * 60 * 60 * 1e3;
25
+ var HUNG_PROGRESS_MS = 5 * 60 * 1e3;
26
+ function emptyStatsItem(label) {
27
+ return {
28
+ active: 0,
29
+ conversations: 0,
30
+ durationMs: 0,
31
+ failed: 0,
32
+ hung: 0,
33
+ label
34
+ };
35
+ }
36
+ function addUsd(current, next) {
37
+ return Math.round(((current ?? 0) + next) * 1e12) / 1e12;
38
+ }
39
+ function actorLabel(row) {
40
+ return row.userEmail?.trim() || row.identityEmail?.trim() || row.userDisplayName?.trim() || row.identityDisplayName?.trim() || row.identityHandle?.trim() || row.identitySubjectId?.trim() || "Unknown";
41
+ }
42
+ function surfaceLabel(source) {
43
+ if (source === "scheduler") return "Scheduler";
44
+ if (source === "api") return "API";
45
+ if (source === "internal" || source === "local") return "Internal";
46
+ return "Conversation";
47
+ }
48
+ function locationLabel(row) {
49
+ if (row.destinationProvider !== "slack") {
50
+ return surfaceLabel(row.source);
51
+ }
52
+ if (row.destinationKind === "dm") {
53
+ return "Direct Message";
54
+ }
55
+ if (row.destinationVisibility !== "public") {
56
+ return "Private Conversation";
57
+ }
58
+ const name = (row.channelName ?? row.destinationDisplayName)?.trim().replace(/^#/, "");
59
+ return name ? `#${name}` : "Public Channel";
60
+ }
61
+ function signals(row, nowMs) {
62
+ if (row.executionStatus === "failed") {
63
+ return { active: false, failed: true, hung: false };
64
+ }
65
+ if (row.executionStatus === "idle") {
66
+ return { active: false, failed: false, hung: false };
67
+ }
68
+ const updatedAt = (row.executionUpdatedAt ?? row.updatedAt).getTime();
69
+ const hung = row.executionStatus === "running" && nowMs - updatedAt > HUNG_PROGRESS_MS;
70
+ return { active: !hung, failed: false, hung };
71
+ }
72
+ function addConversation(map, label, rowSignals, metrics) {
73
+ const item = map.get(label) ?? emptyStatsItem(label);
74
+ item.conversations += 1;
75
+ item.durationMs += metrics.durationMs;
76
+ if (metrics.tokens !== void 0) {
77
+ item.tokens = (item.tokens ?? 0) + metrics.tokens;
78
+ }
79
+ if (metrics.costUsd !== void 0) {
80
+ item.costUsd = addUsd(item.costUsd, metrics.costUsd);
81
+ }
82
+ item.active += rowSignals.active ? 1 : 0;
83
+ item.failed += rowSignals.failed ? 1 : 0;
84
+ item.hung += rowSignals.hung ? 1 : 0;
85
+ map.set(label, item);
86
+ }
87
+ function statsItems(map) {
88
+ return [...map.values()].sort(
89
+ (left, right) => right.conversations - left.conversations || left.label.localeCompare(right.label)
90
+ );
91
+ }
92
+ async function statsRows(db, start, end) {
93
+ return db.select({
94
+ channelName: juniorConversations.channelName,
95
+ destinationDisplayName: juniorDestinations.displayName,
96
+ destinationKind: juniorDestinations.kind,
97
+ destinationProvider: juniorDestinations.provider,
98
+ destinationVisibility: juniorDestinations.visibility,
99
+ durationMs: juniorConversations.durationMs,
100
+ executionStatus: juniorConversations.executionStatus,
101
+ executionUpdatedAt: juniorConversations.executionUpdatedAt,
102
+ identityDisplayName: juniorIdentities.displayName,
103
+ identityEmail: juniorIdentities.emailNormalized,
104
+ identityHandle: juniorIdentities.handle,
105
+ identitySubjectId: juniorIdentities.providerSubjectId,
106
+ source: juniorConversations.source,
107
+ updatedAt: juniorConversations.updatedAt,
108
+ usage: juniorConversations.usage,
109
+ userDisplayName: juniorUsers.displayName,
110
+ userEmail: juniorUsers.primaryEmailNormalized
111
+ }).from(juniorConversations).leftJoin(
112
+ juniorIdentities,
113
+ eq(juniorIdentities.id, juniorConversations.actorIdentityId)
114
+ ).leftJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).leftJoin(
115
+ juniorDestinations,
116
+ eq(juniorDestinations.id, juniorConversations.destinationId)
117
+ ).where(
118
+ and(
119
+ isNull(juniorConversations.parentConversationId),
120
+ gte(juniorConversations.lastActivityAt, start),
121
+ lte(juniorConversations.lastActivityAt, end)
122
+ )
123
+ ).orderBy(
124
+ desc(juniorConversations.lastActivityAt),
125
+ asc(juniorConversations.conversationId)
126
+ ).limit(SAMPLE_LIMIT);
127
+ }
128
+ function usageTokens(usage) {
129
+ if (!usage) return void 0;
130
+ if (usage.totalTokens !== void 0) return usage.totalTokens;
131
+ const values = [
132
+ usage.inputTokens,
133
+ usage.outputTokens,
134
+ usage.cachedInputTokens,
135
+ usage.cacheCreationTokens
136
+ ].filter((value) => value !== void 0);
137
+ return values.length > 0 ? values.reduce((sum, value) => sum + value, 0) : void 0;
138
+ }
139
+ function usageCostUsd(usage) {
140
+ const cost = usage?.cost;
141
+ if (!cost) return void 0;
142
+ if (cost.total !== void 0) return cost.total;
143
+ const values = [
144
+ cost.input,
145
+ cost.output,
146
+ cost.cacheRead,
147
+ cost.cacheWrite
148
+ ].filter((value) => value !== void 0);
149
+ return values.length > 0 ? values.reduce((sum, value) => sum + value, 0) : void 0;
150
+ }
151
+ async function readConversationStatsFromSql() {
152
+ const nowMs = Date.now();
153
+ const windowStartMs = nowMs - WINDOW_MS;
154
+ const rows = await statsRows(
155
+ getDb(),
156
+ new Date(windowStartMs),
157
+ new Date(nowMs)
158
+ );
159
+ const actors = /* @__PURE__ */ new Map();
160
+ const locations = /* @__PURE__ */ new Map();
161
+ let active = 0;
162
+ let costUsd;
163
+ let durationMs = 0;
164
+ let failed = 0;
165
+ let hung = 0;
166
+ let tokens;
167
+ for (const row of rows) {
168
+ const rowSignals = signals(row, nowMs);
169
+ active += rowSignals.active ? 1 : 0;
170
+ failed += rowSignals.failed ? 1 : 0;
171
+ hung += rowSignals.hung ? 1 : 0;
172
+ const rowTokens = usageTokens(row.usage);
173
+ const rowCostUsd = usageCostUsd(row.usage);
174
+ const metrics = {
175
+ ...rowCostUsd !== void 0 ? { costUsd: rowCostUsd } : {},
176
+ durationMs: row.durationMs,
177
+ ...rowTokens !== void 0 ? { tokens: rowTokens } : {}
178
+ };
179
+ durationMs += metrics.durationMs;
180
+ if (metrics.tokens !== void 0) {
181
+ tokens = (tokens ?? 0) + metrics.tokens;
182
+ }
183
+ if (metrics.costUsd !== void 0) {
184
+ costUsd = addUsd(costUsd, metrics.costUsd);
185
+ }
186
+ addConversation(actors, actorLabel(row), rowSignals, metrics);
187
+ addConversation(locations, locationLabel(row), rowSignals, metrics);
188
+ }
189
+ return {
190
+ active,
191
+ conversations: rows.length,
192
+ durationMs,
193
+ failed,
194
+ generatedAt: new Date(nowMs).toISOString(),
195
+ hung,
196
+ locations: statsItems(locations),
197
+ actors: statsItems(actors),
198
+ sampleLimit: SAMPLE_LIMIT,
199
+ sampleSize: rows.length,
200
+ source: "conversation_index",
201
+ ...costUsd !== void 0 ? { costUsd } : {},
202
+ ...tokens !== void 0 ? { tokens } : {},
203
+ truncated: rows.length >= SAMPLE_LIMIT,
204
+ windowEnd: new Date(nowMs).toISOString(),
205
+ windowStart: new Date(windowStartMs).toISOString()
206
+ };
207
+ }
208
+
209
+ // src/api/conversations/stats.ts
210
+ async function readConversationStats() {
211
+ return conversationStatsReportSchema.parse(
212
+ await readConversationStatsFromSql()
213
+ );
214
+ }
215
+ export {
216
+ readConversationStats
217
+ };
@@ -0,0 +1,48 @@
1
+ import {
2
+ buildConversationSubagent
3
+ } from "./chunk-AUUCAFDE.js";
4
+ import {
5
+ readConversationRecordFromSql
6
+ } from "./chunk-ON6YKIQ7.js";
7
+ import {
8
+ conversationSubagentTranscriptReportSchema
9
+ } from "./chunk-LUAE4MGW.js";
10
+ import "./chunk-LVUKF5CE.js";
11
+ import "./chunk-NG2AV7IB.js";
12
+ import "./chunk-GUAP3H7O.js";
13
+ import "./chunk-3F4OPKGF.js";
14
+ import "./chunk-PDO5BLNM.js";
15
+ import "./chunk-WTYEKPXU.js";
16
+ import "./chunk-35BNLDOJ.js";
17
+ import "./chunk-4ZNGQH7C.js";
18
+ import "./chunk-EEZCY5WX.js";
19
+ import "./chunk-LVA4I4H7.js";
20
+ import "./chunk-B7PUBQQM.js";
21
+ import "./chunk-I35CTGPO.js";
22
+ import "./chunk-OB42YVAE.js";
23
+ import "./chunk-6GWA276C.js";
24
+ import "./chunk-7FBGKXPE.js";
25
+ import "./chunk-MLKGABMK.js";
26
+
27
+ // src/api/conversations/subagent.ts
28
+ async function readConversationSubagent(conversationId, subagentId) {
29
+ const record = await readConversationRecordFromSql(conversationId);
30
+ if (!record) {
31
+ return conversationSubagentTranscriptReportSchema.parse({
32
+ type: "subagent",
33
+ createdAt: (/* @__PURE__ */ new Date(0)).toISOString(),
34
+ id: subagentId,
35
+ status: "error",
36
+ subagentKind: "unknown",
37
+ transcript: [],
38
+ transcriptAvailable: false,
39
+ unavailableReason: "not_found"
40
+ });
41
+ }
42
+ return conversationSubagentTranscriptReportSchema.parse(
43
+ await buildConversationSubagent(record.conversation, subagentId)
44
+ );
45
+ }
46
+ export {
47
+ readConversationSubagent
48
+ };
@@ -0,0 +1,25 @@
1
+ import { z } from "zod";
2
+ export declare const usageCostSchema: z.ZodObject<{
3
+ input: z.ZodOptional<z.ZodNumber>;
4
+ output: z.ZodOptional<z.ZodNumber>;
5
+ cacheRead: z.ZodOptional<z.ZodNumber>;
6
+ cacheWrite: z.ZodOptional<z.ZodNumber>;
7
+ total: z.ZodOptional<z.ZodNumber>;
8
+ }, z.core.$strict>;
9
+ export declare const usageSchema: z.ZodObject<{
10
+ inputTokens: z.ZodOptional<z.ZodNumber>;
11
+ outputTokens: z.ZodOptional<z.ZodNumber>;
12
+ cachedInputTokens: z.ZodOptional<z.ZodNumber>;
13
+ cacheCreationTokens: z.ZodOptional<z.ZodNumber>;
14
+ reasoningTokens: z.ZodOptional<z.ZodNumber>;
15
+ totalTokens: z.ZodOptional<z.ZodNumber>;
16
+ cost: z.ZodOptional<z.ZodObject<{
17
+ input: z.ZodOptional<z.ZodNumber>;
18
+ output: z.ZodOptional<z.ZodNumber>;
19
+ cacheRead: z.ZodOptional<z.ZodNumber>;
20
+ cacheWrite: z.ZodOptional<z.ZodNumber>;
21
+ total: z.ZodOptional<z.ZodNumber>;
22
+ }, z.core.$strict>>;
23
+ }, z.core.$strict>;
24
+ export type UsageCost = z.output<typeof usageCostSchema>;
25
+ export type Usage = z.output<typeof usageSchema>;
@@ -1,13 +1,14 @@
1
1
  import {
2
2
  validatePluginEgressCredentialHooks,
3
3
  validatePluginRegistrations
4
- } from "./chunk-YDT7SNCN.js";
5
- import "./chunk-L7CDEIVJ.js";
4
+ } from "./chunk-D5KZYS4T.js";
5
+ import "./chunk-LMJPRYHP.js";
6
6
  import "./chunk-I35CTGPO.js";
7
7
  import "./chunk-OB42YVAE.js";
8
8
  import "./chunk-6GWA276C.js";
9
- import "./chunk-6APU57E6.js";
9
+ import "./chunk-B3IT5END.js";
10
10
  import "./chunk-7FBGKXPE.js";
11
+ import "./chunk-3V7OFJZC.js";
11
12
  import "./chunk-MLKGABMK.js";
12
13
  export {
13
14
  validatePluginEgressCredentialHooks,