agent-recorder 2.0.12 → 2.0.14

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 (188) hide show
  1. package/dist/bundle.js +4 -0
  2. package/dist/bundle.js.map +1 -1
  3. package/dist/embed.d.ts +21 -0
  4. package/dist/embed.d.ts.map +1 -0
  5. package/dist/embed.js +22 -0
  6. package/dist/embed.js.map +1 -0
  7. package/package.json +8 -1
  8. package/vendor/node_modules/@agent-recorder/cli/analytics/session-analytics.test.js +3 -0
  9. package/vendor/node_modules/@agent-recorder/cli/analytics/session-analytics.test.js.map +1 -1
  10. package/vendor/node_modules/@agent-recorder/cli/commands/mcp-server.d.ts +11 -0
  11. package/vendor/node_modules/@agent-recorder/cli/commands/mcp-server.d.ts.map +1 -0
  12. package/vendor/node_modules/@agent-recorder/cli/commands/mcp-server.js +442 -0
  13. package/vendor/node_modules/@agent-recorder/cli/commands/mcp-server.js.map +1 -0
  14. package/vendor/node_modules/@agent-recorder/cli/commands/sessions.d.ts.map +1 -1
  15. package/vendor/node_modules/@agent-recorder/cli/commands/sessions.js +8 -5
  16. package/vendor/node_modules/@agent-recorder/cli/commands/sessions.js.map +1 -1
  17. package/vendor/node_modules/@agent-recorder/cli/config/claude-paths.d.ts +2 -51
  18. package/vendor/node_modules/@agent-recorder/cli/config/claude-paths.d.ts.map +1 -1
  19. package/vendor/node_modules/@agent-recorder/cli/config/claude-paths.js +2 -113
  20. package/vendor/node_modules/@agent-recorder/cli/config/claude-paths.js.map +1 -1
  21. package/vendor/node_modules/@agent-recorder/cli/config/claude-paths.test.js +1 -1
  22. package/vendor/node_modules/@agent-recorder/cli/config/claude-paths.test.js.map +1 -1
  23. package/vendor/node_modules/@agent-recorder/cli/index.js +10 -0
  24. package/vendor/node_modules/@agent-recorder/cli/index.js.map +1 -1
  25. package/vendor/node_modules/@agent-recorder/cli/package.json +1 -1
  26. package/vendor/node_modules/@agent-recorder/cli/tui/components/EventInspectPanel.d.ts.map +1 -1
  27. package/vendor/node_modules/@agent-recorder/cli/tui/components/EventInspectPanel.js +1 -1
  28. package/vendor/node_modules/@agent-recorder/cli/tui/components/EventInspectPanel.js.map +1 -1
  29. package/vendor/node_modules/@agent-recorder/core/claude-config.d.ts +23 -0
  30. package/vendor/node_modules/@agent-recorder/core/claude-config.d.ts.map +1 -1
  31. package/vendor/node_modules/@agent-recorder/core/claude-config.js +50 -0
  32. package/vendor/node_modules/@agent-recorder/core/claude-config.js.map +1 -1
  33. package/vendor/node_modules/@agent-recorder/core/config.d.ts +10 -1
  34. package/vendor/node_modules/@agent-recorder/core/config.d.ts.map +1 -1
  35. package/vendor/node_modules/@agent-recorder/core/config.js +11 -1
  36. package/vendor/node_modules/@agent-recorder/core/config.js.map +1 -1
  37. package/vendor/node_modules/@agent-recorder/core/db/events-complete.test.d.ts +5 -0
  38. package/vendor/node_modules/@agent-recorder/core/db/events-complete.test.d.ts.map +1 -0
  39. package/vendor/node_modules/@agent-recorder/core/db/events-complete.test.js +133 -0
  40. package/vendor/node_modules/@agent-recorder/core/db/events-complete.test.js.map +1 -0
  41. package/vendor/node_modules/@agent-recorder/core/db/events.d.ts +23 -36
  42. package/vendor/node_modules/@agent-recorder/core/db/events.d.ts.map +1 -1
  43. package/vendor/node_modules/@agent-recorder/core/db/events.js +74 -3
  44. package/vendor/node_modules/@agent-recorder/core/db/events.js.map +1 -1
  45. package/vendor/node_modules/@agent-recorder/core/db/events.test.js +62 -1
  46. package/vendor/node_modules/@agent-recorder/core/db/events.test.js.map +1 -1
  47. package/vendor/node_modules/@agent-recorder/core/db/index.d.ts +2 -1
  48. package/vendor/node_modules/@agent-recorder/core/db/index.d.ts.map +1 -1
  49. package/vendor/node_modules/@agent-recorder/core/db/index.js +2 -1
  50. package/vendor/node_modules/@agent-recorder/core/db/index.js.map +1 -1
  51. package/vendor/node_modules/@agent-recorder/core/db/sessions.d.ts +2 -5
  52. package/vendor/node_modules/@agent-recorder/core/db/sessions.d.ts.map +1 -1
  53. package/vendor/node_modules/@agent-recorder/core/db/sessions.js.map +1 -1
  54. package/vendor/node_modules/@agent-recorder/core/db/token-metrics.d.ts +33 -0
  55. package/vendor/node_modules/@agent-recorder/core/db/token-metrics.d.ts.map +1 -0
  56. package/vendor/node_modules/@agent-recorder/core/db/token-metrics.js +88 -0
  57. package/vendor/node_modules/@agent-recorder/core/db/token-metrics.js.map +1 -0
  58. package/vendor/node_modules/@agent-recorder/core/db/token-metrics.test.d.ts +5 -0
  59. package/vendor/node_modules/@agent-recorder/core/db/token-metrics.test.d.ts.map +1 -0
  60. package/vendor/node_modules/@agent-recorder/core/db/token-metrics.test.js +167 -0
  61. package/vendor/node_modules/@agent-recorder/core/db/token-metrics.test.js.map +1 -0
  62. package/vendor/node_modules/@agent-recorder/core/index.d.ts +1 -1
  63. package/vendor/node_modules/@agent-recorder/core/index.d.ts.map +1 -1
  64. package/vendor/node_modules/@agent-recorder/core/index.js +1 -1
  65. package/vendor/node_modules/@agent-recorder/core/index.js.map +1 -1
  66. package/vendor/node_modules/@agent-recorder/core/migrations/007_add_correlation_id.sql +11 -0
  67. package/vendor/node_modules/@agent-recorder/core/migrations/007_add_token_columns.sql +19 -0
  68. package/vendor/node_modules/@agent-recorder/core/package.json +1 -1
  69. package/vendor/node_modules/@agent-recorder/core/types/index.d.ts +4 -2
  70. package/vendor/node_modules/@agent-recorder/core/types/index.d.ts.map +1 -1
  71. package/vendor/node_modules/@agent-recorder/core/types/index.js +3 -0
  72. package/vendor/node_modules/@agent-recorder/core/types/index.js.map +1 -1
  73. package/vendor/node_modules/@agent-recorder/core/utils/index.d.ts +1 -0
  74. package/vendor/node_modules/@agent-recorder/core/utils/index.d.ts.map +1 -1
  75. package/vendor/node_modules/@agent-recorder/core/utils/index.js +1 -0
  76. package/vendor/node_modules/@agent-recorder/core/utils/index.js.map +1 -1
  77. package/vendor/node_modules/@agent-recorder/core/utils/redact.d.ts.map +1 -1
  78. package/vendor/node_modules/@agent-recorder/core/utils/redact.js +6 -3
  79. package/vendor/node_modules/@agent-recorder/core/utils/redact.js.map +1 -1
  80. package/vendor/node_modules/@agent-recorder/core/utils/redact.test.d.ts +6 -0
  81. package/vendor/node_modules/@agent-recorder/core/utils/redact.test.d.ts.map +1 -0
  82. package/vendor/node_modules/@agent-recorder/core/utils/redact.test.js +82 -0
  83. package/vendor/node_modules/@agent-recorder/core/utils/redact.test.js.map +1 -0
  84. package/vendor/node_modules/@agent-recorder/core/utils/tokens.d.ts +24 -0
  85. package/vendor/node_modules/@agent-recorder/core/utils/tokens.d.ts.map +1 -0
  86. package/vendor/node_modules/@agent-recorder/core/utils/tokens.js +31 -0
  87. package/vendor/node_modules/@agent-recorder/core/utils/tokens.js.map +1 -0
  88. package/vendor/node_modules/@agent-recorder/core/utils/tokens.test.d.ts +5 -0
  89. package/vendor/node_modules/@agent-recorder/core/utils/tokens.test.d.ts.map +1 -0
  90. package/vendor/node_modules/@agent-recorder/core/utils/tokens.test.js +80 -0
  91. package/vendor/node_modules/@agent-recorder/core/utils/tokens.test.js.map +1 -0
  92. package/vendor/node_modules/@agent-recorder/hooks/package.json +1 -1
  93. package/vendor/node_modules/@agent-recorder/service/daemon-context.d.ts +14 -0
  94. package/vendor/node_modules/@agent-recorder/service/daemon-context.d.ts.map +1 -0
  95. package/vendor/node_modules/@agent-recorder/service/daemon-context.js +15 -0
  96. package/vendor/node_modules/@agent-recorder/service/daemon-context.js.map +1 -0
  97. package/vendor/node_modules/@agent-recorder/service/index.d.ts +1 -8
  98. package/vendor/node_modules/@agent-recorder/service/index.d.ts.map +1 -1
  99. package/vendor/node_modules/@agent-recorder/service/index.js +15 -22
  100. package/vendor/node_modules/@agent-recorder/service/index.js.map +1 -1
  101. package/vendor/node_modules/@agent-recorder/service/mcp/proxy.d.ts +27 -0
  102. package/vendor/node_modules/@agent-recorder/service/mcp/proxy.d.ts.map +1 -1
  103. package/vendor/node_modules/@agent-recorder/service/mcp/proxy.js +141 -35
  104. package/vendor/node_modules/@agent-recorder/service/mcp/proxy.js.map +1 -1
  105. package/vendor/node_modules/@agent-recorder/service/mcp/recorder.d.ts +4 -0
  106. package/vendor/node_modules/@agent-recorder/service/mcp/recorder.d.ts.map +1 -1
  107. package/vendor/node_modules/@agent-recorder/service/mcp/recorder.js +56 -14
  108. package/vendor/node_modules/@agent-recorder/service/mcp/recorder.js.map +1 -1
  109. package/vendor/node_modules/@agent-recorder/service/mcp/recorder.test.d.ts +5 -0
  110. package/vendor/node_modules/@agent-recorder/service/mcp/recorder.test.d.ts.map +1 -0
  111. package/vendor/node_modules/@agent-recorder/service/mcp/recorder.test.js +143 -0
  112. package/vendor/node_modules/@agent-recorder/service/mcp/recorder.test.js.map +1 -0
  113. package/vendor/node_modules/@agent-recorder/service/mcp/types.d.ts +5 -31
  114. package/vendor/node_modules/@agent-recorder/service/mcp/types.d.ts.map +1 -1
  115. package/vendor/node_modules/@agent-recorder/service/mcp/types.js +3 -1
  116. package/vendor/node_modules/@agent-recorder/service/mcp/types.js.map +1 -1
  117. package/vendor/node_modules/@agent-recorder/service/mcp/upstreams-cache.test.d.ts +5 -0
  118. package/vendor/node_modules/@agent-recorder/service/mcp/upstreams-cache.test.d.ts.map +1 -0
  119. package/vendor/node_modules/@agent-recorder/service/mcp/upstreams-cache.test.js +66 -0
  120. package/vendor/node_modules/@agent-recorder/service/mcp/upstreams-cache.test.js.map +1 -0
  121. package/vendor/node_modules/@agent-recorder/service/package.json +1 -1
  122. package/vendor/node_modules/@agent-recorder/service/routes/events.d.ts.map +1 -1
  123. package/vendor/node_modules/@agent-recorder/service/routes/events.js +42 -1
  124. package/vendor/node_modules/@agent-recorder/service/routes/events.js.map +1 -1
  125. package/vendor/node_modules/@agent-recorder/service/routes/health.d.ts +6 -1
  126. package/vendor/node_modules/@agent-recorder/service/routes/health.d.ts.map +1 -1
  127. package/vendor/node_modules/@agent-recorder/service/routes/health.js +5 -6
  128. package/vendor/node_modules/@agent-recorder/service/routes/health.js.map +1 -1
  129. package/vendor/node_modules/@agent-recorder/service/routes/hooks.d.ts +20 -0
  130. package/vendor/node_modules/@agent-recorder/service/routes/hooks.d.ts.map +1 -1
  131. package/vendor/node_modules/@agent-recorder/service/routes/hooks.js +403 -49
  132. package/vendor/node_modules/@agent-recorder/service/routes/hooks.js.map +1 -1
  133. package/vendor/node_modules/@agent-recorder/service/routes/hooks.test.d.ts +9 -0
  134. package/vendor/node_modules/@agent-recorder/service/routes/hooks.test.d.ts.map +1 -0
  135. package/vendor/node_modules/@agent-recorder/service/routes/hooks.test.js +406 -0
  136. package/vendor/node_modules/@agent-recorder/service/routes/hooks.test.js.map +1 -0
  137. package/vendor/node_modules/@agent-recorder/service/routes/isToolResponseError.test.d.ts +8 -0
  138. package/vendor/node_modules/@agent-recorder/service/routes/isToolResponseError.test.d.ts.map +1 -0
  139. package/vendor/node_modules/@agent-recorder/service/routes/isToolResponseError.test.js +65 -0
  140. package/vendor/node_modules/@agent-recorder/service/routes/isToolResponseError.test.js.map +1 -0
  141. package/vendor/node_modules/@agent-recorder/service/routes/sessions.d.ts.map +1 -1
  142. package/vendor/node_modules/@agent-recorder/service/routes/sessions.js +19 -1
  143. package/vendor/node_modules/@agent-recorder/service/routes/sessions.js.map +1 -1
  144. package/vendor/node_modules/@agent-recorder/service/routes/stdio.d.ts.map +1 -1
  145. package/vendor/node_modules/@agent-recorder/service/routes/stdio.js +20 -1
  146. package/vendor/node_modules/@agent-recorder/service/routes/stdio.js.map +1 -1
  147. package/vendor/node_modules/@agent-recorder/service/routes/tokens.d.ts +12 -0
  148. package/vendor/node_modules/@agent-recorder/service/routes/tokens.d.ts.map +1 -0
  149. package/vendor/node_modules/@agent-recorder/service/routes/tokens.js +18 -0
  150. package/vendor/node_modules/@agent-recorder/service/routes/tokens.js.map +1 -0
  151. package/vendor/node_modules/@agent-recorder/service/routes/tokens.test.d.ts +5 -0
  152. package/vendor/node_modules/@agent-recorder/service/routes/tokens.test.d.ts.map +1 -0
  153. package/vendor/node_modules/@agent-recorder/service/routes/tokens.test.js +88 -0
  154. package/vendor/node_modules/@agent-recorder/service/routes/tokens.test.js.map +1 -0
  155. package/vendor/node_modules/@agent-recorder/service/server.d.ts +4 -0
  156. package/vendor/node_modules/@agent-recorder/service/server.d.ts.map +1 -1
  157. package/vendor/node_modules/@agent-recorder/service/server.js +33 -3
  158. package/vendor/node_modules/@agent-recorder/service/server.js.map +1 -1
  159. package/vendor/node_modules/@agent-recorder/stdio-proxy/package.json +1 -1
  160. package/vendor/node_modules/@agent-recorder/stdio-proxy/types.d.ts +3 -19
  161. package/vendor/node_modules/@agent-recorder/stdio-proxy/types.d.ts.map +1 -1
  162. package/vendor/node_modules/@agent-recorder/stdio-proxy/types.js +2 -1
  163. package/vendor/node_modules/@agent-recorder/stdio-proxy/types.js.map +1 -1
  164. package/vendor/node_modules/@agent-recorder/{core/types → types}/events.d.ts +9 -0
  165. package/vendor/node_modules/@agent-recorder/types/events.d.ts.map +1 -0
  166. package/vendor/node_modules/@agent-recorder/types/events.js +9 -0
  167. package/vendor/node_modules/@agent-recorder/types/events.js.map +1 -0
  168. package/vendor/node_modules/@agent-recorder/types/index.d.ts +12 -0
  169. package/vendor/node_modules/@agent-recorder/types/index.d.ts.map +1 -0
  170. package/vendor/node_modules/@agent-recorder/types/index.js +9 -0
  171. package/vendor/node_modules/@agent-recorder/types/index.js.map +1 -0
  172. package/vendor/node_modules/@agent-recorder/types/jsonrpc.d.ts +35 -0
  173. package/vendor/node_modules/@agent-recorder/types/jsonrpc.d.ts.map +1 -0
  174. package/vendor/node_modules/@agent-recorder/types/jsonrpc.js +6 -0
  175. package/vendor/node_modules/@agent-recorder/types/jsonrpc.js.map +1 -0
  176. package/vendor/node_modules/@agent-recorder/types/package.json +12 -0
  177. package/vendor/node_modules/@agent-recorder/{core/types → types}/session.d.ts +6 -0
  178. package/vendor/node_modules/@agent-recorder/types/session.d.ts.map +1 -0
  179. package/vendor/node_modules/@agent-recorder/{core/types → types}/session.js.map +1 -1
  180. package/vendor/node_modules/@agent-recorder/types/storage.d.ts +80 -0
  181. package/vendor/node_modules/@agent-recorder/types/storage.d.ts.map +1 -0
  182. package/vendor/node_modules/@agent-recorder/types/storage.js +9 -0
  183. package/vendor/node_modules/@agent-recorder/types/storage.js.map +1 -0
  184. package/vendor/node_modules/@agent-recorder/core/types/events.d.ts.map +0 -1
  185. package/vendor/node_modules/@agent-recorder/core/types/events.js +0 -6
  186. package/vendor/node_modules/@agent-recorder/core/types/events.js.map +0 -1
  187. package/vendor/node_modules/@agent-recorder/core/types/session.d.ts.map +0 -1
  188. /package/vendor/node_modules/@agent-recorder/{core/types → types}/session.js +0 -0
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Token monitoring endpoints.
3
+ */
4
+ import { getTokenSummary } from "@agent-recorder/core";
5
+ export async function registerTokensRoutes(app, options) {
6
+ const { db, contextBudgetTokens } = options;
7
+ app.get("/api/sessions/:sessionId/tokens", async (request, reply) => {
8
+ try {
9
+ const { sessionId } = request.params;
10
+ return getTokenSummary(db, sessionId, contextBudgetTokens);
11
+ }
12
+ catch (error) {
13
+ console.error("Failed to get token summary:", error);
14
+ return reply.code(500).send({ error: "Failed to get token summary" });
15
+ }
16
+ });
17
+ }
18
+ //# sourceMappingURL=tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../src/routes/tokens.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAOvD,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,GAAoB,EACpB,OAA4B;IAE5B,MAAM,EAAE,EAAE,EAAE,mBAAmB,EAAE,GAAG,OAAO,CAAC;IAE5C,GAAG,CAAC,GAAG,CACL,iCAAiC,EACjC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;QACvB,IAAI,CAAC;YACH,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;YACrC,OAAO,eAAe,CAAC,EAAE,EAAE,SAAS,EAAE,mBAAmB,CAAC,CAAC;QAC7D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,KAAK,CAAC,CAAC;YACrD,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,6BAA6B,EAAE,CAAC,CAAC;QACxE,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Tests for the token monitoring REST endpoint.
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=tokens.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.test.d.ts","sourceRoot":"","sources":["../../src/routes/tokens.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Tests for the token monitoring REST endpoint.
3
+ */
4
+ import { describe, it, expect, beforeAll, afterAll } from "vitest";
5
+ import { randomUUID } from "node:crypto";
6
+ import { openMemoryDatabase, runMigrations, createSession, insertEvent, upsertToolSchemaMetric, } from "@agent-recorder/core";
7
+ import { createServer } from "../server.js";
8
+ import { join, dirname } from "node:path";
9
+ import { fileURLToPath } from "node:url";
10
+ const __dirname = dirname(fileURLToPath(import.meta.url));
11
+ function migrationsDir() {
12
+ return join(__dirname, "..", "..", "..", "core", "migrations");
13
+ }
14
+ describe("GET /api/sessions/:sessionId/tokens", () => {
15
+ let app;
16
+ let db;
17
+ let sessionId;
18
+ beforeAll(async () => {
19
+ db = openMemoryDatabase();
20
+ runMigrations(db, migrationsDir());
21
+ sessionId = randomUUID();
22
+ createSession(db, sessionId, new Date().toISOString());
23
+ insertEvent(db, {
24
+ id: randomUUID(),
25
+ sessionId,
26
+ sequence: 1,
27
+ eventType: "tool_call",
28
+ agentRole: "main",
29
+ agentName: "claude-code",
30
+ toolName: "execute_sql",
31
+ upstreamKey: "supabase",
32
+ startedAt: new Date().toISOString(),
33
+ status: "success",
34
+ inputTokens: 100,
35
+ outputTokens: 200,
36
+ });
37
+ upsertToolSchemaMetric(db, {
38
+ sessionId,
39
+ upstreamKey: "supabase",
40
+ toolName: "execute_sql",
41
+ schemaTokens: 50,
42
+ });
43
+ app = await createServer({ db, contextBudgetTokens: 150000 });
44
+ await app.ready();
45
+ });
46
+ afterAll(async () => {
47
+ await app.close();
48
+ db.close();
49
+ });
50
+ it("returns 200 with valid token summary shape", async () => {
51
+ const res = await app.inject({
52
+ method: "GET",
53
+ url: `/api/sessions/${sessionId}/tokens`,
54
+ });
55
+ expect(res.statusCode).toBe(200);
56
+ const body = res.json();
57
+ expect(body).toHaveProperty("sessionId", sessionId);
58
+ expect(body).toHaveProperty("estimatedTotalTokens");
59
+ expect(body).toHaveProperty("budgetTokens", 150000);
60
+ expect(body).toHaveProperty("percentUsed");
61
+ expect(body).toHaveProperty("budgetExceeded", false);
62
+ expect(body).toHaveProperty("byUpstream");
63
+ expect(body).toHaveProperty("byTool");
64
+ expect(body.estimatedTotalTokens).toBe(350); // 100+200 call + 50 schema
65
+ });
66
+ it("byTool contains the recorded tool with correct token counts", async () => {
67
+ const res = await app.inject({
68
+ method: "GET",
69
+ url: `/api/sessions/${sessionId}/tokens`,
70
+ });
71
+ const body = res.json();
72
+ const tool = body.byTool.find((t) => t.toolName === "execute_sql");
73
+ expect(tool).toBeDefined();
74
+ expect(tool.totalInputTokens).toBe(100);
75
+ expect(tool.totalOutputTokens).toBe(200);
76
+ });
77
+ it("returns empty summary for unknown session", async () => {
78
+ const res = await app.inject({
79
+ method: "GET",
80
+ url: `/api/sessions/${randomUUID()}/tokens`,
81
+ });
82
+ expect(res.statusCode).toBe(200);
83
+ const body = res.json();
84
+ expect(body.estimatedTotalTokens).toBe(0);
85
+ expect(body.byTool).toHaveLength(0);
86
+ });
87
+ });
88
+ //# sourceMappingURL=tokens.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.test.js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G,CAAC,CAAC;QACjC,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;QACxB,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC1C,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -4,10 +4,14 @@
4
4
  */
5
5
  import { type FastifyInstance } from "fastify";
6
6
  import type Database from "better-sqlite3";
7
+ import type { DaemonContext } from "./daemon-context.js";
7
8
  export interface CreateServerOptions {
8
9
  db: Database.Database;
9
10
  currentSessionId?: string | null;
10
11
  debug?: boolean;
12
+ daemonContext?: DaemonContext;
13
+ redactKeys?: string[];
14
+ contextBudgetTokens?: number;
11
15
  }
12
16
  /**
13
17
  * Create a configured Fastify server instance.
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAO3C,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,QAAQ,CAAC,QAAQ,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,eAAe,CAAC,CAkB1B;AAwCD;;;;GAIG;AACH,wBAAsB,WAAW,CAC/B,GAAG,EAAE,eAAe,EACpB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,MAAM,CAAC,CAwBjB"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAgB,EAAE,KAAK,eAAe,EAAqB,MAAM,SAAS,CAAC;AAC3E,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAQ3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,QAAQ,CAAC,QAAQ,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;GAEG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,eAAe,CAAC,CAwD1B;AAwCD;;;;GAIG;AACH,wBAAsB,WAAW,CAC/B,GAAG,EAAE,eAAe,EACpB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,MAAM,CAAC,CAwBjB"}
@@ -9,23 +9,53 @@ import { registerSessionsRoutes } from "./routes/sessions.js";
9
9
  import { registerEventsRoutes } from "./routes/events.js";
10
10
  import { registerHooksRoutes } from "./routes/hooks.js";
11
11
  import { registerStdioRoutes } from "./routes/stdio.js";
12
+ import { registerTokensRoutes } from "./routes/tokens.js";
13
+ import { DEFAULT_CONTEXT_BUDGET_TOKENS } from "@agent-recorder/core";
12
14
  /**
13
15
  * Create a configured Fastify server instance.
14
16
  */
15
17
  export async function createServer(options) {
16
- const { db, currentSessionId, debug } = options;
18
+ const { db, currentSessionId, debug, daemonContext, redactKeys, contextBudgetTokens, } = options;
17
19
  const app = Fastify({
18
20
  logger: true,
19
21
  });
22
+ // Custom error handler: fail-open for hooks/stdio validation errors
23
+ app.setErrorHandler(async (error, request, reply) => {
24
+ if (error.validation) {
25
+ const url = request.url;
26
+ // Fail-open for hooks and stdio — validation errors should not block Claude
27
+ if (url.startsWith("/api/hooks") || url.startsWith("/api/stdio")) {
28
+ console.error(`[validation] ${url}: ${error.message} (fail-open, returning 200)`);
29
+ return reply.code(200).send({ ok: true, error: "validation" });
30
+ }
31
+ // Standard validation error for other routes
32
+ return reply.code(400).send({
33
+ error: "Validation error",
34
+ message: error.message,
35
+ });
36
+ }
37
+ // Re-throw non-validation errors
38
+ return reply.code(error.statusCode ?? 500).send({
39
+ error: error.message,
40
+ });
41
+ });
20
42
  // Register routes
21
- await registerHealthRoutes(app);
43
+ await registerHealthRoutes(app, { daemonContext });
22
44
  await registerSessionsRoutes(app, {
23
45
  db,
24
46
  currentSessionId: currentSessionId ?? null,
25
47
  });
26
48
  await registerEventsRoutes(app, { db });
27
- await registerHooksRoutes(app, { db, debug: debug ?? false });
49
+ await registerHooksRoutes(app, {
50
+ db,
51
+ debug: debug ?? false,
52
+ redactKeys: redactKeys ?? [],
53
+ });
28
54
  await registerStdioRoutes(app, { db, debug: debug ?? false });
55
+ await registerTokensRoutes(app, {
56
+ db,
57
+ contextBudgetTokens: contextBudgetTokens ?? DEFAULT_CONTEXT_BUDGET_TOKENS,
58
+ });
29
59
  return app;
30
60
  }
31
61
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,IAAI,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,OAAO,EAAE,EAAwB,MAAM,SAAS,CAAC;AAExD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAQxD;;GAEG;AACH,MAAM,CA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;IAC1E,MAAM,IAAI,GAAG,MAAM,iBAAiB,CAAC,aAAa,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;IAEvE,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAClB,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,GAAG,WAAW,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;QACjE,MAAM,IAAI,KAAK,CAAC,8BAA8B,aAAa,IAAI,OAAO,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED,mCAAmC;IACnC,MAAM,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAEjC,IAAI,IAAI,KAAK,aAAa,EAAE,CAAC;QAC3B,OAAO,CAAC,GAAG,CACT,QAAQ,aAAa,6BAA6B,IAAI,IAAI,IAAI,UAAU,CACzE,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,6CAA6C,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-recorder/stdio-proxy",
3
- "version": "2.0.8",
3
+ "version": "2.0.14",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,24 +1,8 @@
1
1
  /**
2
- * Types for the STDIO proxy
2
+ * Types for the STDIO proxy.
3
+ * JSON-RPC types are imported from @agent-recorder/types.
3
4
  */
4
- /** JSON-RPC 2.0 request structure */
5
- export interface JsonRpcRequest {
6
- jsonrpc: "2.0";
7
- method: string;
8
- params?: unknown;
9
- id?: string | number | null;
10
- }
11
- /** JSON-RPC 2.0 response structure */
12
- export interface JsonRpcResponse {
13
- jsonrpc: "2.0";
14
- result?: unknown;
15
- error?: {
16
- code: number;
17
- message: string;
18
- data?: unknown;
19
- };
20
- id: string | number | null;
21
- }
5
+ export type { JsonRpcRequest, JsonRpcResponse } from "@agent-recorder/types";
22
6
  /** Recorded MCP message for telemetry */
23
7
  export interface McpMessage {
24
8
  /** Timestamp when message was captured */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qCAAqC;AACrC,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,sCAAsC;AACtC,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,OAAO,CAAC;KAChB,CAAC;IACF,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,yCAAyC;AACzC,MAAM,WAAW,UAAU;IACzB,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,oDAAoD;IACpD,SAAS,EAAE,SAAS,GAAG,UAAU,CAAC;IAClC,2BAA2B;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,kCAAkC;IAClC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACxC,wCAAwC;IACxC,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAC/B;AAED,kCAAkC;AAClC,MAAM,WAAW,YAAY;IAC3B,uCAAuC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,gCAAgC;IAChC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,wBAAwB;IACxB,GAAG,CA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AED,kCAAkC;AAClC,MAAM,WAAW,YAAY;IAC3B,uCAAuC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,gCAAgC;IAChC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,wBAAwB;IACxB,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,oCAAoC;IACpC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IACzC,iCAAiC;IACjC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,qCAAqC;IACrC,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B,iCAAiC;IACjC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC;AAED,kBAAkB;AAClB,MAAM,WAAW,UAAU;IACzB,wBAAwB;IACxB,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,+BAA+B;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,sBAAsB;IACtB,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,qBAAqB;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;CACvB"}
@@ -1,5 +1,6 @@
1
1
  /**
2
- * Types for the STDIO proxy
2
+ * Types for the STDIO proxy.
3
+ * JSON-RPC types are imported from @agent-recorder/types.
3
4
  */
4
5
  export {};
5
6
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -1,6 +1,9 @@
1
1
  /**
2
2
  * Event types for Agent Recorder.
3
3
  * Records observable execution boundaries only — no prompts, no reasoning.
4
+ *
5
+ * This package has ZERO dependencies and is safe to import anywhere:
6
+ * agents, SDKs, cloud services, web frontends.
4
7
  */
5
8
  /** Supported event types in the execution hierarchy */
6
9
  export type EventType = "agent_call" | "subagent_call" | "skill_call" | "tool_call";
@@ -35,6 +38,8 @@ export interface BaseEvent {
35
38
  mcpMethod: string | null;
36
39
  /** Upstream server key (for router mode, null for legacy single-upstream) */
37
40
  upstreamKey: string | null;
41
+ /** Correlation ID for matching PreToolUse → PostToolUse (null until Claude Code provides one) */
42
+ correlationId: string | null;
38
43
  /** When this event started (ISO 8601) */
39
44
  startedAt: string;
40
45
  /** When this event ended (ISO 8601, null if still running) */
@@ -47,6 +52,10 @@ export interface BaseEvent {
47
52
  outputJson: string | null;
48
53
  /** Error category for failed events (null if success/running) */
49
54
  errorCategory: ErrorCategory | null;
55
+ /** Estimated input token count for this event (null if not measured) */
56
+ inputTokens: number | null;
57
+ /** Estimated output token count for this event (null if not measured) */
58
+ outputTokens: number | null;
50
59
  /** When this record was created (ISO 8601) */
51
60
  createdAt: string;
52
61
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,uDAAuD;AACvD,MAAM,MAAM,SAAS,GACjB,YAAY,GACZ,eAAe,GACf,YAAY,GACZ,WAAW,CAAC;AAEhB,yBAAyB;AACzB,MAAM,MAAM,WAAW,GACnB,SAAS,GACT,SAAS,GACT,OAAO,GACP,SAAS,GACT,WAAW,CAAC;AAEhB,iEAAiE;AACjE,MAAM,MAAM,aAAa,GACrB,oBAAoB,GACpB,wBAAwB,GACxB,iBAAiB,GACjB,eAAe,GACf,SAAS,CAAC;AAEd;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,6BAA6B;IAC7B,EAAE,EAAE,MAAM,CAAC;IAEX,oCAAoC;IACpC,SAAS,EAAE,MAAM,CAAC;IAElB,iDAAiD;IACjD,aAAa,E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SAAS,EAAE,YAAY,CAAC;CACzB;AAED,mDAAmD;AACnD,MAAM,WAAW,aAAc,SAAQ,SAAS;IAC9C,SAAS,EAAE,WAAW,CAAC;CACxB;AAED,qCAAqC;AACrC,MAAM,MAAM,aAAa,GACrB,cAAc,GACd,iBAAiB,GACjB,cAAc,GACd,aAAa,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Event types for Agent Recorder.
3
+ * Records observable execution boundaries only — no prompts, no reasoning.
4
+ *
5
+ * This package has ZERO dependencies and is safe to import anywhere:
6
+ * agents, SDKs, cloud services, web frontends.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @agent-recorder/types
3
+ *
4
+ * Portable type definitions for Agent Recorder.
5
+ * ZERO dependencies — safe to import in any context:
6
+ * agents, SDKs, cloud services, web frontends, tests.
7
+ */
8
+ export type { EventType, EventStatus, ErrorCategory, BaseEvent, AgentCallEvent, SubagentCallEvent, SkillCallEvent, ToolCallEvent, RecordedEvent, } from "./events.js";
9
+ export type { SessionStatus, Session, SessionWithActivity } from "./session.js";
10
+ export type { InsertEventInput, EventQueryOptions, EventFilterOptions, StorageAdapter, } from "./storage.js";
11
+ export type { JsonRpcRequest, JsonRpcSuccessResponse, JsonRpcErrorResponse, JsonRpcResponse, ToolsCallParams, } from "./jsonrpc.js";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,EACV,SAAS,EACT,WAAW,EACX,aAAa,EACb,SAAS,EACT,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,aAAa,GACd,MAAM,aAAa,CAAC;AAErB,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEhF,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,GACf,MAAM,cAAc,CAAC;AAEtB,YAAY,EACV,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,eAAe,EACf,eAAe,GAChB,MAAM,cAAc,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @agent-recorder/types
3
+ *
4
+ * Portable type definitions for Agent Recorder.
5
+ * ZERO dependencies — safe to import in any context:
6
+ * agents, SDKs, cloud services, web frontends, tests.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * JSON-RPC 2.0 types for MCP protocol.
3
+ * Shared between service and stdio-proxy packages.
4
+ */
5
+ /** Base JSON-RPC request structure */
6
+ export interface JsonRpcRequest {
7
+ jsonrpc: "2.0";
8
+ method: string;
9
+ params?: unknown;
10
+ id?: string | number | null;
11
+ }
12
+ /** JSON-RPC success response */
13
+ export interface JsonRpcSuccessResponse {
14
+ jsonrpc: "2.0";
15
+ result: unknown;
16
+ id: string | number | null;
17
+ }
18
+ /** JSON-RPC error response */
19
+ export interface JsonRpcErrorResponse {
20
+ jsonrpc: "2.0";
21
+ error: {
22
+ code: number;
23
+ message: string;
24
+ data?: unknown;
25
+ };
26
+ id: string | number | null;
27
+ }
28
+ /** Union of JSON-RPC response types */
29
+ export type JsonRpcResponse = JsonRpcSuccessResponse | JsonRpcErrorResponse;
30
+ /** MCP tools/call request params */
31
+ export interface ToolsCallParams {
32
+ name: string;
33
+ arguments?: Record<string, unknown>;
34
+ }
35
+ //# sourceMappingURL=jsonrpc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonrpc.d.ts","sourceRoot":"","sources":["../src/jsonrpc.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,sCAAsC;AACtC,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,gCAAgC;AAChC,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,8BAA8B;AAC9B,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,KAAK,CAAC;IACf,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,OAAO,CAAC;KAChB,CAAC;IACF,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,uCAAuC;AACvC,MAAM,MAAM,eAAe,GAAG,sBAAsB,GAAG,oBAAoB,CAAC;AAE5E,oCAAoC;AACpC,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * JSON-RPC 2.0 types for MCP protocol.
3
+ * Shared between service and stdio-proxy packages.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=jsonrpc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonrpc.js","sourceRoot":"","sources":["../src/jsonrpc.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "@agent-recorder/types",
3
+ "version": "2.0.14",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": {
7
+ "types": "./index.d.ts",
8
+ "import": "./index.js"
9
+ }
10
+ },
11
+ "dependencies": {}
12
+ }
@@ -19,4 +19,10 @@ export interface Session {
19
19
  /** When this record was created (ISO 8601) */
20
20
  createdAt: string;
21
21
  }
22
+ /**
23
+ * Session with last activity timestamp, used by REST API responses.
24
+ */
25
+ export interface SessionWithActivity extends Session {
26
+ lastActivityAt: string | null;
27
+ }
22
28
  //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,oCAAoC;AACpC,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,WAAW,GAAG,OAAO,GAAG,WAAW,CAAC;AAE3E;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,+BAA+B;IAC/B,EAAE,EAAE,MAAM,CAAC;IAEX,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAElB,8DAA8D;IAC9D,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAEvB,qCAAqC;IACrC,MAAM,EAAE,aAAa,CAAC;IAEtB,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,OAAO;IAClD,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B"}
@@ -1 +1 @@
1
- {"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/types/session.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
1
+ {"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Storage adapter interface for pluggable persistence.
3
+ *
4
+ * Implement this interface to use a custom storage backend
5
+ * (e.g., PostgreSQL, in-memory for tests, cloud storage).
6
+ * The default implementation uses SQLite (in @agent-recorder/core).
7
+ */
8
+ import type { BaseEvent, EventStatus, ErrorCategory, EventType } from "./events.js";
9
+ import type { Session, SessionStatus } from "./session.js";
10
+ /** Input for inserting a new event */
11
+ export interface InsertEventInput {
12
+ id: string;
13
+ sessionId: string;
14
+ parentEventId?: string | null;
15
+ sequence: number;
16
+ eventType: EventType;
17
+ agentRole: string;
18
+ agentName: string;
19
+ skillName?: string | null;
20
+ toolName?: string | null;
21
+ mcpMethod?: string | null;
22
+ upstreamKey?: string | null;
23
+ correlationId?: string | null;
24
+ startedAt: string;
25
+ endedAt?: string | null;
26
+ status: EventStatus;
27
+ inputJson?: string | null;
28
+ outputJson?: string | null;
29
+ errorCategory?: ErrorCategory | null;
30
+ inputTokens?: number | null;
31
+ outputTokens?: number | null;
32
+ }
33
+ /** Query options for paginated event retrieval */
34
+ export interface EventQueryOptions {
35
+ /** Only return events with sequence > after (default: 0) */
36
+ after?: number;
37
+ /** Maximum number of events to return (default: 200) */
38
+ limit?: number;
39
+ }
40
+ /** Filter options for event queries */
41
+ export interface EventFilterOptions {
42
+ toolName?: string;
43
+ status?: EventStatus;
44
+ errorCategory?: ErrorCategory;
45
+ upstreamKey?: string;
46
+ sinceSeq?: number;
47
+ limit?: number;
48
+ }
49
+ /**
50
+ * Abstract storage adapter.
51
+ * All methods should be synchronous or return promises consistently.
52
+ * The SQLite implementation is synchronous; other backends may be async.
53
+ *
54
+ * @alpha This interface is unstable and may change without notice between
55
+ * minor versions. It defines the target contract for pluggable storage
56
+ * backends but is not yet implemented. The current SQLite functions in
57
+ * `@agent-recorder/core` take `Database.Database` directly. Do not depend
58
+ * on this interface in production code.
59
+ *
60
+ * Note: All methods return bare values (not `Promise<T>`), making this
61
+ * sync-only. Async backends (PostgreSQL, cloud) would need a wrapper or
62
+ * a future `AsyncStorageAdapter` interface.
63
+ */
64
+ export interface StorageAdapter {
65
+ createSession(id: string, startedAt: string): Session;
66
+ endSession(id: string, endedAt: string, status: SessionStatus): Session | null;
67
+ getSessionById(id: string): Session | null;
68
+ listSessions(status?: SessionStatus): Session[];
69
+ insertEvent(event: InsertEventInput): BaseEvent;
70
+ getEventById(id: string): BaseEvent | null;
71
+ getEventsBySession(sessionId: string): BaseEvent[];
72
+ getEventsBySessionPaginated(sessionId: string, options?: EventQueryOptions): BaseEvent[];
73
+ countEventsBySession(sessionId: string): number;
74
+ updateEventStatus(id: string, status: EventStatus, endedAt?: string): BaseEvent | null;
75
+ completeEvent(id: string, status: EventStatus, endedAt: string, outputJson?: string | null, errorCategory?: ErrorCategory | null, outputTokens?: number | null): BaseEvent | null;
76
+ findRunningEvent(sessionId: string, toolName: string, correlationId?: string | null): BaseEvent | null;
77
+ allocateSequence(sessionId: string): number;
78
+ close(): void;
79
+ }
80
+ //# sourceMappingURL=storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,WAAW,EACX,aAAa,EACb,SAAS,EACV,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE3D,sCAAsC;AACtC,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,SAAS,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,SAAS,EAA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AS,GAAG,IAAI,CAAC;IAC3C,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,CAAC;IACnD,2BAA2B,CACzB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,SAAS,EAAE,CAAC;IACf,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;IAChD,iBAAiB,CACf,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,WAAW,EACnB,OAAO,CAAC,EAAE,MAAM,GACf,SAAS,GAAG,IAAI,CAAC;IACpB,aAAa,CACX,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,EAC1B,aAAa,CAAC,EAAE,aAAa,GAAG,IAAI,EACpC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,GAC3B,SAAS,GAAG,IAAI,CAAC;IACpB,gBAAgB,CACd,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,GAC5B,SAAS,GAAG,IAAI,CAAC;IAGpB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;IAG5C,KAAK,IAAI,IAAI,CAAC;CACf"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Storage adapter interface for pluggable persistence.
3
+ *
4
+ * Implement this interface to use a custom storage backend
5
+ * (e.g., PostgreSQL, in-memory for tests, cloud storage).
6
+ * The default implementation uses SQLite (in @agent-recorder/core).
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.js","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA;;;GAGG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AEpC,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,mDAAmD;AACnD,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C,SAAS,EAAE,YAAY,CAAC;CACzB;AAED,yEAAyE;AACzE,MAAM,WAAW,iBAAkB,SAAQ,SAAS;IAClD,SAAS,EAAE,eAAe,CAAC;CAC5B;AAED,mDAAmD;AACnD,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C,SAAS,EAAE,YAAY,CAAC;CACzB;AAED,mDAAmD;AACnD,MAAM,WAAW,aAAc,SAAQ,SAAS;IAC9C,SAAS,EAAE,WAAW,CAAC;CACxB;AAED,qCAAqC;AACrC,MAAM,MAAM,aAAa,GACrB,cAAc,GACd,iBAAiB,GACjB,cAAc,GACd,aAAa,CAAC"}
@@ -1,6 +0,0 @@
1
- /**
2
- * Event types for Agent Recorder.
3
- * Records observable execution boundaries only — no prompts, no reasoning.
4
- */
5
- export {};
6
- //# sourceMappingURL=events.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/types/session.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,oCAAoC;AACpC,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,WAAW,GAAG,OAAO,GAAG,WAAW,CAAC;AAE3E;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,+BAA+B;IAC/B,EAAE,EAAE,MAAM,CAAC;IAEX,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAElB,8DAA8D;IAC9D,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAEvB,qCAAqC;IACrC,MAAM,EAAE,aAAa,CAAC;IAEtB,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CAAC;CACnB"}