@sentry/junior 0.96.0 → 0.97.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.
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 +100 -366
  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 +14 -18
  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
@@ -5,8 +5,15 @@
5
5
  {
6
6
  "idx": 0,
7
7
  "version": "7",
8
- "when": 1783631415804,
9
- "tag": "0000_overconfident_exodus",
8
+ "when": 1783781927194,
9
+ "tag": "0000_initial",
10
+ "breakpoints": true
11
+ },
12
+ {
13
+ "idx": 1,
14
+ "version": "7",
15
+ "when": 1783781940092,
16
+ "tag": "0001_conversation_metrics",
10
17
  "breakpoints": true
11
18
  }
12
19
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/junior",
3
- "version": "0.96.0",
3
+ "version": "0.97.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -28,17 +28,13 @@
28
28
  "types": "./dist/nitro.d.ts",
29
29
  "default": "./dist/nitro.js"
30
30
  },
31
- "./api/people/list": {
32
- "types": "./dist/api/people/list.d.ts",
33
- "default": "./dist/api/people/list.js"
31
+ "./api": {
32
+ "types": "./dist/api.d.ts",
33
+ "default": "./dist/api.js"
34
34
  },
35
- "./api/people/profile": {
36
- "types": "./dist/api/people/profile.d.ts",
37
- "default": "./dist/api/people/profile.js"
38
- },
39
- "./reporting": {
40
- "types": "./dist/reporting.d.ts",
41
- "default": "./dist/reporting.js"
35
+ "./api/schema": {
36
+ "types": "./dist/api/schema.d.ts",
37
+ "default": "./dist/api/schema.js"
42
38
  },
43
39
  "./vercel": {
44
40
  "types": "./dist/vercel.d.ts",
@@ -55,8 +51,8 @@
55
51
  "@chat-adapter/slack": "4.29.0",
56
52
  "@chat-adapter/state-memory": "4.29.0",
57
53
  "@chat-adapter/state-redis": "4.29.0",
58
- "@earendil-works/pi-agent-core": "0.80.5",
59
- "@earendil-works/pi-ai": "0.80.5",
54
+ "@earendil-works/pi-agent-core": "0.80.6",
55
+ "@earendil-works/pi-ai": "0.80.6",
60
56
  "@logtape/logtape": "^2.1.1",
61
57
  "@modelcontextprotocol/sdk": "1.29.0",
62
58
  "@neondatabase/serverless": "^1.1.0",
@@ -79,7 +75,7 @@
79
75
  "pg": "^8.16.3",
80
76
  "yaml": "^2.9.0",
81
77
  "zod": "^4.4.3",
82
- "@sentry/junior-plugin-api": "0.96.0"
78
+ "@sentry/junior-plugin-api": "0.97.0"
83
79
  },
84
80
  "devDependencies": {
85
81
  "@emnapi/core": "^1.10.0",
@@ -96,10 +92,10 @@
96
92
  "typescript": "^6.0.3",
97
93
  "vercel": "^54.4.0",
98
94
  "vitest": "^4.1.7",
99
- "@sentry/junior-github": "0.96.0",
100
- "@sentry/junior-scheduler": "0.96.0",
101
- "@sentry/junior-memory": "0.96.0",
102
- "@sentry/junior-testing": "0.0.0"
95
+ "@sentry/junior-github": "0.97.0",
96
+ "@sentry/junior-testing": "0.0.0",
97
+ "@sentry/junior-memory": "0.97.0",
98
+ "@sentry/junior-scheduler": "0.97.0"
103
99
  },
104
100
  "scripts": {
105
101
  "build": "tsup && tsc -p tsconfig.build.json --emitDeclarationOnly",
@@ -1,85 +0,0 @@
1
- export type PeopleConversationStatus = "active" | "completed" | "failed" | "hung";
2
- export type PeopleConversationSurface = "api" | "internal" | "scheduler" | "slack";
3
- export interface ActorIdentity {
4
- email?: string;
5
- fullName?: string;
6
- slackUserId?: string;
7
- slackUserName?: string;
8
- }
9
- export interface ConversationSummaryReport {
10
- cumulativeDurationMs: number;
11
- conversationId: string;
12
- displayTitle: string;
13
- id: string;
14
- lastProgressAt: string;
15
- lastSeenAt: string;
16
- startedAt: string;
17
- status: PeopleConversationStatus;
18
- surface: PeopleConversationSurface;
19
- channel?: string;
20
- channelName?: string;
21
- channelNameRedacted?: boolean;
22
- actorIdentity?: ActorIdentity;
23
- }
24
- export interface ConversationStatsItem {
25
- active: number;
26
- conversations: number;
27
- durationMs: number;
28
- failed: number;
29
- hung: number;
30
- label: string;
31
- runs: number;
32
- tokens?: number;
33
- }
34
- export interface ActorActivityDayReport {
35
- active: number;
36
- conversations: number;
37
- date: string;
38
- durationMs: number;
39
- failed: number;
40
- hung: number;
41
- runs: number;
42
- tokens?: number;
43
- }
44
- export interface ActorTotalsReport {
45
- active: number;
46
- activeDays: number;
47
- conversations: number;
48
- durationMs: number;
49
- failed: number;
50
- hung: number;
51
- runs: number;
52
- tokens?: number;
53
- }
54
- export interface ActorSummaryReport extends ActorTotalsReport {
55
- firstSeenAt: string;
56
- lastSeenAt: string;
57
- actor: ActorIdentity & {
58
- email: string;
59
- };
60
- }
61
- export interface ActorDirectoryReport {
62
- generatedAt: string;
63
- people: ActorSummaryReport[];
64
- sampleLimit: number;
65
- sampleSize: number;
66
- source: "conversation_index";
67
- truncated: boolean;
68
- }
69
- export interface ActorProfileReport {
70
- activityDays: ActorActivityDayReport[];
71
- generatedAt: string;
72
- locations: ConversationStatsItem[];
73
- recentConversations: ConversationSummaryReport[];
74
- actor: ActorIdentity & {
75
- email: string;
76
- };
77
- sampleLimit: number;
78
- sampleSize: number;
79
- source: "conversation_index";
80
- surfaces: ConversationStatsItem[];
81
- totals: ActorTotalsReport;
82
- truncated: boolean;
83
- windowEnd: string;
84
- windowStart: string;
85
- }
@@ -1,4 +0,0 @@
1
- /** Render the executor's advisor request in stable model-facing boundaries. */
2
- export declare function renderAdvisorRequest(question: string, context: string): string;
3
- /** Recover readable task and context text from an advisor request message. */
4
- export declare function unwrapAdvisorRequest(text: string): string | undefined;
@@ -1,22 +0,0 @@
1
- import type { JuniorSqlMigrationExecutor } from "@/db/db";
2
- import { juniorSqlSchema as schema } from "@/db/schema";
3
- export interface Migration {
4
- checksum: string;
5
- id: string;
6
- statements: readonly string[];
7
- }
8
- /**
9
- * Register a drizzle-kit-generated `.sql` file as a checksum-pinned migration.
10
- *
11
- * Migrations 0006 onward are authored by editing the Drizzle schema and running
12
- * `pnpm --filter @sentry/junior db:generate`; each generated file becomes one
13
- * line here. Statements are split on drizzle-kit's `--> statement-breakpoint`
14
- * markers and applied by the custom `junior upgrade` runner (never
15
- * `drizzle-kit migrate`). Migrations 0001–0005 predate kit and stay inline so
16
- * their recorded checksums remain byte-stable.
17
- */
18
- export declare function defineMigrationFromFile(id: string, fileName: string): Migration;
19
- export declare const migrations: readonly [Migration, Migration, Migration, Migration, Migration];
20
- export { schema };
21
- /** Apply pending SQL schema migrations for queryable conversation records. */
22
- export declare function migrateSchema(executor: JuniorSqlMigrationExecutor, migrationList?: readonly Migration[]): Promise<void>;
@@ -1,9 +0,0 @@
1
- import type { PiMessage } from "@/chat/pi/messages";
2
- export interface AdvisorSessionStore {
3
- load: (conversationId: string) => Promise<PiMessage[]>;
4
- save: (conversationId: string, messages: PiMessage[]) => Promise<void>;
5
- }
6
- /** Return the durable advisor session key for an opaque parent conversation id. */
7
- export declare function getAdvisorSessionKey(conversationId: string): string;
8
- /** Create the production advisor message store backed by the chat state adapter. */
9
- export declare function createStateAdvisorSessionStore(): AdvisorSessionStore;
@@ -1,72 +0,0 @@
1
- import { type AgentTool, type StreamFn } from "@earendil-works/pi-agent-core";
2
- import type { AdvisorConfig } from "@/chat/config";
3
- import { type ConversationPrivacy } from "@/chat/conversation-privacy";
4
- import { type LogContext } from "@/chat/logging";
5
- import type { ConversationStore } from "@/chat/conversations/store";
6
- import type { AnyToolDefinition } from "@/chat/tools/definition";
7
- export type AdvisorErrorCode = "invalid_context" | "invalid_question" | "missing_conversation_id" | "session_unavailable" | "unavailable";
8
- export type AdvisorToolResult = {
9
- memo: string;
10
- ok: boolean;
11
- status: "error" | "success";
12
- error_code?: AdvisorErrorCode;
13
- } & Record<string, unknown>;
14
- export interface AdvisorToolRuntimeContext {
15
- config: AdvisorConfig;
16
- conversationId?: string;
17
- conversationPrivacy?: ConversationPrivacy;
18
- getTools: () => AgentTool[];
19
- logContext?: LogContext;
20
- /** Metadata store used to link the advisor child conversation to its parent. */
21
- conversationStore?: ConversationStore;
22
- streamFn?: StreamFn;
23
- }
24
- /**
25
- * Deterministic advisor child conversation id derived from the parent so
26
- * repeated advisor calls in one parent conversation append to the same history.
27
- */
28
- export declare function advisorChildConversationId(parentConversationId: string): string;
29
- /** Build the advisor's read-only tool definition subset. */
30
- export declare function createAdvisorToolDefinitions(definitions: Record<string, AnyToolDefinition>): Record<string, AnyToolDefinition>;
31
- /** Create the advisor tool backed by a child-conversation message history. */
32
- export declare function createAdvisorTool(context: AdvisorToolRuntimeContext): Omit<AnyToolDefinition, "inputSchema" | "outputSchema" | "prepareArguments" | "execute"> & {
33
- inputSchema: import("@/chat/tools/definition").JsonSchemaObject;
34
- outputSchema: import("@/chat/tools/definition").JsonSchemaObject;
35
- prepareArguments(args: unknown): {
36
- question: string;
37
- context: string;
38
- };
39
- execute?: ((input: unknown, options: import("@/chat/tools/definition").ToolExecuteOptions) => {
40
- [x: string]: unknown;
41
- ok: boolean;
42
- status: "error" | "success";
43
- target?: string | undefined;
44
- data?: unknown;
45
- truncated?: boolean | undefined;
46
- continuation?: {
47
- arguments: Record<string, unknown>;
48
- reason?: string | undefined;
49
- } | undefined;
50
- error?: string | {
51
- kind: string;
52
- message: string;
53
- retryable?: boolean | undefined;
54
- } | undefined;
55
- } | Promise<{
56
- [x: string]: unknown;
57
- ok: boolean;
58
- status: "error" | "success";
59
- target?: string | undefined;
60
- data?: unknown;
61
- truncated?: boolean | undefined;
62
- continuation?: {
63
- arguments: Record<string, unknown>;
64
- reason?: string | undefined;
65
- } | undefined;
66
- error?: string | {
67
- kind: string;
68
- message: string;
69
- retryable?: boolean | undefined;
70
- } | undefined;
71
- }>) | undefined;
72
- };
@@ -1,142 +0,0 @@
1
- import {
2
- isRecord,
3
- toOptionalNumber,
4
- toOptionalString
5
- } from "./chunk-OB42YVAE.js";
6
-
7
- // src/chat/state/conversation.ts
8
- function defaultConversationState() {
9
- const nowMs = Date.now();
10
- return {
11
- schemaVersion: 1,
12
- messages: [],
13
- compactions: [],
14
- backfill: {},
15
- processing: {},
16
- stats: {
17
- estimatedContextTokens: 0,
18
- totalMessageCount: 0,
19
- compactedMessageCount: 0,
20
- updatedAtMs: nowMs
21
- },
22
- vision: {
23
- byFileId: {}
24
- }
25
- };
26
- }
27
- function coercePendingAuthState(value) {
28
- if (!isRecord(value)) {
29
- return void 0;
30
- }
31
- const kind = value.kind;
32
- const provider = toOptionalString(value.provider);
33
- const actorId = toOptionalString(value.actorId);
34
- const scope = toOptionalString(value.scope);
35
- const sessionId = toOptionalString(value.sessionId);
36
- const linkSentAtMs = toOptionalNumber(value.linkSentAtMs);
37
- if (kind !== "mcp" && kind !== "plugin" || !provider || !actorId || !sessionId || typeof linkSentAtMs !== "number") {
38
- return void 0;
39
- }
40
- return {
41
- kind,
42
- provider,
43
- actorId,
44
- ...scope ? { scope } : {},
45
- sessionId,
46
- linkSentAtMs
47
- };
48
- }
49
- function coerceThreadConversationState(value) {
50
- if (!isRecord(value)) {
51
- return defaultConversationState();
52
- }
53
- const root = value;
54
- const rawConversation = isRecord(root.conversation) ? root.conversation : {};
55
- const base = defaultConversationState();
56
- const messages = [];
57
- const rawCompactions = Array.isArray(rawConversation.compactions) ? rawConversation.compactions : [];
58
- const compactions = [];
59
- for (const item of rawCompactions) {
60
- if (!isRecord(item)) continue;
61
- const id = toOptionalString(item.id);
62
- const summary = toOptionalString(item.summary);
63
- const createdAtMs = toOptionalNumber(item.createdAtMs);
64
- if (!id || !summary || !createdAtMs) continue;
65
- const coveredMessageIds = Array.isArray(item.coveredMessageIds) ? item.coveredMessageIds.filter(
66
- (entry) => typeof entry === "string" && entry.length > 0
67
- ) : [];
68
- compactions.push({
69
- id,
70
- summary,
71
- createdAtMs,
72
- coveredMessageIds
73
- });
74
- }
75
- const rawBackfill = isRecord(rawConversation.backfill) ? rawConversation.backfill : {};
76
- const backfill = {
77
- completedAtMs: toOptionalNumber(rawBackfill.completedAtMs),
78
- source: rawBackfill.source === "recent_messages" || rawBackfill.source === "thread_fetch" ? rawBackfill.source : void 0
79
- };
80
- const rawProcessing = isRecord(rawConversation.processing) ? rawConversation.processing : {};
81
- const processing = {
82
- activeTurnId: toOptionalString(rawProcessing.activeTurnId),
83
- lastCompletedAtMs: toOptionalNumber(rawProcessing.lastCompletedAtMs),
84
- pendingAuth: coercePendingAuthState(rawProcessing.pendingAuth)
85
- };
86
- const rawStats = isRecord(rawConversation.stats) ? rawConversation.stats : {};
87
- const stats = {
88
- estimatedContextTokens: toOptionalNumber(rawStats.estimatedContextTokens) ?? base.stats.estimatedContextTokens,
89
- totalMessageCount: toOptionalNumber(rawStats.totalMessageCount) ?? messages.length,
90
- compactedMessageCount: toOptionalNumber(rawStats.compactedMessageCount) ?? 0,
91
- updatedAtMs: toOptionalNumber(rawStats.updatedAtMs) ?? base.stats.updatedAtMs
92
- };
93
- const rawVision = isRecord(rawConversation.vision) ? rawConversation.vision : {};
94
- const rawVisionByFileId = isRecord(rawVision.byFileId) ? rawVision.byFileId : {};
95
- const byFileId = {};
96
- for (const [fileId, value2] of Object.entries(rawVisionByFileId)) {
97
- if (typeof fileId !== "string" || fileId.trim().length === 0) continue;
98
- if (!isRecord(value2)) continue;
99
- const summary = toOptionalString(value2.summary);
100
- const analyzedAtMs = toOptionalNumber(value2.analyzedAtMs);
101
- if (!summary || !analyzedAtMs) continue;
102
- byFileId[fileId] = {
103
- summary,
104
- analyzedAtMs
105
- };
106
- }
107
- return {
108
- schemaVersion: 1,
109
- messages,
110
- compactions,
111
- backfill,
112
- processing,
113
- stats,
114
- vision: {
115
- backfillCompletedAtMs: toOptionalNumber(rawVision.backfillCompletedAtMs),
116
- byFileId
117
- }
118
- };
119
- }
120
- function buildConversationStatePatch(conversation) {
121
- const {
122
- compactions: _compactions,
123
- messages: _messages,
124
- ...scratch
125
- } = conversation;
126
- return {
127
- conversation: {
128
- ...scratch,
129
- schemaVersion: 1,
130
- stats: {
131
- ...conversation.stats,
132
- totalMessageCount: conversation.messages.length,
133
- updatedAtMs: Date.now()
134
- }
135
- }
136
- };
137
- }
138
-
139
- export {
140
- coerceThreadConversationState,
141
- buildConversationStatePatch
142
- };
@@ -1,48 +0,0 @@
1
- import {
2
- escapeXml,
3
- unescapeXml
4
- } from "./chunk-YDVEH3SB.js";
5
-
6
- // src/chat/advisor-request.ts
7
- var TASK_OPEN = "<advisor-task>\n";
8
- var TASK_CLOSE = "\n</advisor-task>";
9
- var CONTEXT_OPEN = "<executor-context>\n";
10
- var CONTEXT_CLOSE = "\n</executor-context>";
11
- function renderAdvisorRequest(question, context) {
12
- return [
13
- TASK_OPEN,
14
- escapeXml(question),
15
- TASK_CLOSE,
16
- "\n\n",
17
- CONTEXT_OPEN,
18
- escapeXml(context),
19
- CONTEXT_CLOSE
20
- ].join("");
21
- }
22
- function unwrapAdvisorRequest(text) {
23
- if (!text.startsWith(TASK_OPEN) || !text.endsWith(CONTEXT_CLOSE)) {
24
- return void 0;
25
- }
26
- const taskEnd = text.indexOf(TASK_CLOSE, TASK_OPEN.length);
27
- if (taskEnd < 0) {
28
- return void 0;
29
- }
30
- const contextStart = taskEnd + TASK_CLOSE.length + 2;
31
- if (!text.startsWith(CONTEXT_OPEN, contextStart)) {
32
- return void 0;
33
- }
34
- const task = text.slice(TASK_OPEN.length, taskEnd);
35
- const context = text.slice(
36
- contextStart + CONTEXT_OPEN.length,
37
- -CONTEXT_CLOSE.length
38
- );
39
- return `${unescapeXml(task)}
40
-
41
- Executor context:
42
- ${unescapeXml(context)}`;
43
- }
44
-
45
- export {
46
- renderAdvisorRequest,
47
- unwrapAdvisorRequest
48
- };
@@ -1,58 +0,0 @@
1
- export declare const juniorSchemaMigrations: import("drizzle-orm/pg-core").PgTableWithColumns<{
2
- name: "junior_schema_migrations";
3
- schema: undefined;
4
- columns: {
5
- id: import("drizzle-orm/pg-core").PgColumn<{
6
- name: "id";
7
- tableName: "junior_schema_migrations";
8
- dataType: "string";
9
- columnType: "PgText";
10
- data: string;
11
- driverParam: string;
12
- notNull: true;
13
- hasDefault: false;
14
- isPrimaryKey: true;
15
- isAutoincrement: false;
16
- hasRuntimeDefault: false;
17
- enumValues: [string, ...string[]];
18
- baseColumn: never;
19
- identity: undefined;
20
- generated: undefined;
21
- }, {}, {}>;
22
- checksum: import("drizzle-orm/pg-core").PgColumn<{
23
- name: "checksum";
24
- tableName: "junior_schema_migrations";
25
- dataType: "string";
26
- columnType: "PgText";
27
- data: string;
28
- driverParam: string;
29
- notNull: true;
30
- hasDefault: false;
31
- isPrimaryKey: false;
32
- isAutoincrement: false;
33
- hasRuntimeDefault: false;
34
- enumValues: [string, ...string[]];
35
- baseColumn: never;
36
- identity: undefined;
37
- generated: undefined;
38
- }, {}, {}>;
39
- appliedAt: import("drizzle-orm/pg-core").PgColumn<{
40
- name: string;
41
- tableName: "junior_schema_migrations";
42
- dataType: "date";
43
- columnType: "PgTimestamp";
44
- data: Date;
45
- driverParam: string;
46
- notNull: true;
47
- hasDefault: true;
48
- isPrimaryKey: false;
49
- isAutoincrement: false;
50
- hasRuntimeDefault: false;
51
- enumValues: undefined;
52
- baseColumn: never;
53
- identity: undefined;
54
- generated: undefined;
55
- }, {}, {}>;
56
- };
57
- dialect: "pg";
58
- }>;
@@ -1,8 +0,0 @@
1
- import type { ConversationMessageStore } from "@/chat/conversations/messages";
2
- import type { ConversationStore } from "@/chat/conversations/store";
3
- export interface ConversationReaderOptions {
4
- messageStore?: ConversationMessageStore;
5
- conversationStore?: ConversationStore;
6
- }
7
- /** Resolve the conversation store supplied by a reporting consumer. */
8
- export declare function conversationStore(options?: ConversationReaderOptions): ConversationStore;
@@ -1,6 +0,0 @@
1
- import { type ConversationReaderOptions } from "./context";
2
- import type { ConversationReport, ConversationSubagentTranscriptReport } from "./types";
3
- /** Read one conversation transcript for reporting consumers. */
4
- export declare function readConversationReport(conversationId: string, options?: ConversationReaderOptions): Promise<ConversationReport>;
5
- /** Read one child-agent transcript through its parent conversation. */
6
- export declare function readConversationSubagentTranscriptReport(conversationId: string, _runId: string, subagentId: string, options?: ConversationReaderOptions): Promise<ConversationSubagentTranscriptReport>;
@@ -1,4 +0,0 @@
1
- export { readConversationReport, readConversationSubagentTranscriptReport, } from "./details";
2
- export { listRecentConversationSummaries, readConversationFeed, } from "./summaries";
3
- export { readConversationStatsReport } from "./statistics";
4
- export * from "./types";
@@ -1,4 +0,0 @@
1
- import { type ConversationReaderOptions } from "./context";
2
- import type { ConversationStatsReport } from "./types";
3
- export declare function readConversationStatsReport(options?: ConversationReaderOptions): Promise<ConversationStatsReport>;
4
- /** List recent conversation summaries for plugin operational reports. */
@@ -1,20 +0,0 @@
1
- import type { AgentTurnSessionSummary } from "@/chat/state/turn-session";
2
- import type { Conversation as StoredConversation } from "@/chat/conversations/store";
3
- import { type ConversationReaderOptions } from "./context";
4
- import type { ConversationFeed, ConversationSummaryReport, ConversationSurface, PluginConversationSummary } from "./types";
5
- /** Build the privacy-safe title shared by summary and detail reports. */
6
- export declare function titleFromConversation(args: {
7
- conversation: StoredConversation;
8
- surface: ConversationSurface;
9
- }): string;
10
- /** Project the current stored execution into the public run summary shape. */
11
- export declare function sessionReportFromConversation(conversation: StoredConversation, nowMs: number): ConversationSummaryReport;
12
- /** Enrich a durable conversation projection with one complete turn summary. */
13
- export declare function sessionReportFromTurnSummary(conversation: StoredConversation, summary: AgentTurnSessionSummary, nowMs: number): ConversationSummaryReport;
14
- /** Read the recent conversation feed for reporting consumers. */
15
- export declare function readConversationFeed(options?: ConversationReaderOptions): Promise<ConversationFeed>;
16
- /** List recent conversation summaries for plugin operational reports. */
17
- export declare function listRecentConversationSummaries(options?: {
18
- limit?: number;
19
- } & ConversationReaderOptions): Promise<PluginConversationSummary[]>;
20
- /** Build the current run's reportable content from the current context epoch. */