@warlock.js/devtools 5.37.0 → 5.38.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 (35) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/cjs/{ai-source-lia4YS30.cjs → ai-source-BMYIA6u_.cjs} +120 -2
  3. package/cjs/ai-source-BMYIA6u_.cjs.map +1 -0
  4. package/cjs/index.cjs +1 -1
  5. package/cjs/{server-BNlyhwiR.cjs → server-DibKdNmA.cjs} +192 -7
  6. package/cjs/server-DibKdNmA.cjs.map +1 -0
  7. package/cjs/{src-CiNStw0i.cjs → src-B2mqnOZC.cjs} +28 -4
  8. package/cjs/src-B2mqnOZC.cjs.map +1 -0
  9. package/esm/devtools-connector.d.mts.map +1 -1
  10. package/esm/devtools-connector.mjs +25 -0
  11. package/esm/devtools-connector.mjs.map +1 -1
  12. package/esm/index.d.mts +3 -2
  13. package/esm/request-history.mjs +118 -0
  14. package/esm/request-history.mjs.map +1 -0
  15. package/esm/server/ai-routes.mjs +20 -0
  16. package/esm/server/ai-routes.mjs.map +1 -1
  17. package/esm/server/index.mjs.map +1 -1
  18. package/esm/server/requests-routes.mjs +53 -5
  19. package/esm/server/requests-routes.mjs.map +1 -1
  20. package/esm/server/stream-route.mjs +4 -0
  21. package/esm/server/stream-route.mjs.map +1 -1
  22. package/esm/sources/agent-trace-source.d.mts +27 -0
  23. package/esm/sources/agent-trace-source.d.mts.map +1 -0
  24. package/esm/sources/agent-trace-source.mjs +108 -0
  25. package/esm/sources/agent-trace-source.mjs.map +1 -0
  26. package/esm/types.d.mts +18 -1
  27. package/esm/types.d.mts.map +1 -1
  28. package/llms-full.txt +34 -0
  29. package/package.json +6 -6
  30. package/skills/SKILL.md +34 -0
  31. package/ui/app.js +282 -15
  32. package/ui/index.html +1 -0
  33. package/cjs/ai-source-lia4YS30.cjs.map +0 -1
  34. package/cjs/server-BNlyhwiR.cjs.map +0 -1
  35. package/cjs/src-CiNStw0i.cjs.map +0 -1
@@ -0,0 +1,108 @@
1
+ //#region ../../packages/devtools/src/sources/agent-trace-source.ts
2
+ /**
3
+ * Key `@warlock.js/ai` publishes its agent trace store under on
4
+ * `globalThis`. Reading the store from the registry, not by importing the
5
+ * package, keeps devtools free of an AI dependency and shares one store
6
+ * even when two copies of the package are installed.
7
+ */
8
+ const AGENT_TRACES_KEY = Symbol.for("@warlock.js/ai.agentTraces");
9
+ const AGENT_TRACE_INSTALL_GUIDANCE = "No agent traces yet. Install @warlock.js/ai 5.38 or newer and run an agent in development (agents record traces by default there; `trace: true` turns it on elsewhere), then reload.";
10
+ /** One list row for a trace. */
11
+ function summarizeAgentTrace(trace, requestId) {
12
+ let toolCalls = 0;
13
+ let refusals = 0;
14
+ for (const turn of trace.turns) {
15
+ toolCalls += turn.toolCalls.length;
16
+ refusals += turn.toolCalls.filter((call) => call.refusal !== void 0).length;
17
+ }
18
+ return {
19
+ runId: trace.runId,
20
+ agent: trace.agent,
21
+ status: trace.status,
22
+ startedAt: trace.startedAt,
23
+ durationMs: trace.durationMs,
24
+ model: `${trace.model.provider}/${trace.model.name}`,
25
+ turns: trace.turns.length,
26
+ toolCalls,
27
+ refusals,
28
+ usage: {
29
+ input: trace.usage.input,
30
+ output: trace.usage.output
31
+ },
32
+ cost: trace.cost,
33
+ ...requestId ? { requestId } : {}
34
+ };
35
+ }
36
+ const MAX_REQUEST_LINKS = 500;
37
+ /**
38
+ * Attach to the shared agent trace store. The store is looked up lazily on
39
+ * every call, so it works whichever of devtools and `@warlock.js/ai` loads
40
+ * first. Runs are linked to the HTTP request that was active when the
41
+ * store first reported them.
42
+ */
43
+ async function attachAgentTraceSource() {
44
+ const { currentRequestId } = await import("../current-request-id.mjs");
45
+ const listeners = /* @__PURE__ */ new Set();
46
+ const requestIds = /* @__PURE__ */ new Map();
47
+ let attachedStore;
48
+ let detach;
49
+ const findStore = () => {
50
+ const store = globalThis[AGENT_TRACES_KEY];
51
+ return store && typeof store.list === "function" ? store : void 0;
52
+ };
53
+ const ensureAttached = () => {
54
+ const store = findStore();
55
+ if (store && store !== attachedStore) {
56
+ detach?.();
57
+ attachedStore = store;
58
+ detach = store.subscribe((event) => {
59
+ let requestId = requestIds.get(event.runId);
60
+ if (!requestId) {
61
+ requestId = currentRequestId();
62
+ if (requestId) {
63
+ requestIds.set(event.runId, requestId);
64
+ if (requestIds.size > MAX_REQUEST_LINKS) {
65
+ const oldest = requestIds.keys().next();
66
+ if (!oldest.done) requestIds.delete(oldest.value);
67
+ }
68
+ }
69
+ }
70
+ for (const listener of listeners) try {
71
+ listener({
72
+ ...event,
73
+ ...requestId ? { requestId } : {}
74
+ });
75
+ } catch {}
76
+ });
77
+ }
78
+ return store;
79
+ };
80
+ ensureAttached();
81
+ return {
82
+ available: () => ensureAttached() !== void 0,
83
+ list(filter) {
84
+ const store = ensureAttached();
85
+ if (!store) return [];
86
+ return store.list().map((trace) => summarizeAgentTrace(trace, requestIds.get(trace.runId))).filter((run) => filter?.requestId === void 0 || run.requestId === filter.requestId);
87
+ },
88
+ get: (runId) => ensureAttached()?.get(runId),
89
+ subscribe(listener) {
90
+ ensureAttached();
91
+ listeners.add(listener);
92
+ return () => {
93
+ listeners.delete(listener);
94
+ };
95
+ },
96
+ dispose() {
97
+ detach?.();
98
+ detach = void 0;
99
+ attachedStore = void 0;
100
+ listeners.clear();
101
+ requestIds.clear();
102
+ }
103
+ };
104
+ }
105
+
106
+ //#endregion
107
+ export { AGENT_TRACES_KEY, AGENT_TRACE_INSTALL_GUIDANCE, attachAgentTraceSource, summarizeAgentTrace };
108
+ //# sourceMappingURL=agent-trace-source.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-trace-source.mjs","names":[],"sources":["../../../../../../../../packages/devtools/src/sources/agent-trace-source.ts"],"sourcesContent":["import type { DevtoolsDisposer } from \"../types\";\n\n/**\n * Key `@warlock.js/ai` publishes its agent trace store under on\n * `globalThis`. Reading the store from the registry, not by importing the\n * package, keeps devtools free of an AI dependency and shares one store\n * even when two copies of the package are installed.\n */\nexport const AGENT_TRACES_KEY = Symbol.for(\"@warlock.js/ai.agentTraces\");\n\nexport const AGENT_TRACE_INSTALL_GUIDANCE =\n \"No agent traces yet. Install @warlock.js/ai 5.38 or newer and run an agent in development (agents record traces by default there; `trace: true` turns it on elsewhere), then reload.\";\n\n/** The part of `@warlock.js/ai`'s `AgentTrace` this panel reads; the rest passes through untouched. */\nexport type DevtoolsAgentTrace = {\n runId: string;\n agent: string;\n status: string;\n startedAt: string;\n durationMs?: number;\n model: { name: string; provider: string };\n usage: { input: number; output: number; total: number };\n cost?: number;\n turns: Array<{ toolCalls: Array<{ refusal?: string }> }>;\n};\n\n/** The part of `@warlock.js/ai`'s `AgentTraceStore` devtools uses. */\nexport type DevtoolsAgentTraceStore = {\n get(runId: string): DevtoolsAgentTrace | undefined;\n list(filter?: { limit?: number }): DevtoolsAgentTrace[];\n subscribe(listener: (event: { runId: string; status: string }) => void): () => void;\n};\n\nexport type DevtoolsAgentTraceEvent = { runId: string; status: string; requestId?: string };\n\n/** One row of the run list. */\nexport type DevtoolsAgentRun = {\n runId: string;\n agent: string;\n status: string;\n startedAt: string;\n durationMs?: number;\n model: string;\n turns: number;\n toolCalls: number;\n refusals: number;\n usage: { input: number; output: number };\n cost?: number;\n requestId?: string;\n};\n\n/** Reads agent traces from the shared store; the connector builds one in development only. */\nexport type DevtoolsAgentTraceSource = {\n /** `false` until `@warlock.js/ai` has created its store in this process. */\n available(): boolean;\n list(filter?: { requestId?: string }): DevtoolsAgentRun[];\n get(runId: string): DevtoolsAgentTrace | undefined;\n subscribe(listener: (event: DevtoolsAgentTraceEvent) => void): DevtoolsDisposer;\n dispose: DevtoolsDisposer;\n};\n\n/** One list row for a trace. */\nexport function summarizeAgentTrace(\n trace: DevtoolsAgentTrace,\n requestId?: string,\n): DevtoolsAgentRun {\n let toolCalls = 0;\n let refusals = 0;\n\n for (const turn of trace.turns) {\n toolCalls += turn.toolCalls.length;\n refusals += turn.toolCalls.filter((call) => call.refusal !== undefined).length;\n }\n\n return {\n runId: trace.runId,\n agent: trace.agent,\n status: trace.status,\n startedAt: trace.startedAt,\n durationMs: trace.durationMs,\n model: `${trace.model.provider}/${trace.model.name}`,\n turns: trace.turns.length,\n toolCalls,\n refusals,\n usage: { input: trace.usage.input, output: trace.usage.output },\n cost: trace.cost,\n ...(requestId ? { requestId } : {}),\n };\n}\n\nconst MAX_REQUEST_LINKS = 500;\n\n/**\n * Attach to the shared agent trace store. The store is looked up lazily on\n * every call, so it works whichever of devtools and `@warlock.js/ai` loads\n * first. Runs are linked to the HTTP request that was active when the\n * store first reported them.\n */\nexport async function attachAgentTraceSource(): Promise<DevtoolsAgentTraceSource> {\n const { currentRequestId } = await import(\"../current-request-id\");\n const listeners = new Set<(event: DevtoolsAgentTraceEvent) => void>();\n const requestIds = new Map<string, string>();\n let attachedStore: DevtoolsAgentTraceStore | undefined;\n let detach: (() => void) | undefined;\n\n const findStore = (): DevtoolsAgentTraceStore | undefined => {\n const store = (globalThis as { [AGENT_TRACES_KEY]?: DevtoolsAgentTraceStore })[\n AGENT_TRACES_KEY\n ];\n\n return store && typeof store.list === \"function\" ? store : undefined;\n };\n\n const ensureAttached = (): DevtoolsAgentTraceStore | undefined => {\n const store = findStore();\n\n if (store && store !== attachedStore) {\n detach?.();\n attachedStore = store;\n detach = store.subscribe((event) => {\n // Read the request id before anything asynchronous: the store\n // publishes synchronously from inside the agent run.\n let requestId = requestIds.get(event.runId);\n\n if (!requestId) {\n requestId = currentRequestId();\n\n if (requestId) {\n requestIds.set(event.runId, requestId);\n\n if (requestIds.size > MAX_REQUEST_LINKS) {\n const oldest = requestIds.keys().next();\n\n if (!oldest.done) requestIds.delete(oldest.value);\n }\n }\n }\n\n for (const listener of listeners) {\n try {\n listener({ ...event, ...(requestId ? { requestId } : {}) });\n } catch {\n /* isolate clients */\n }\n }\n });\n }\n\n return store;\n };\n\n ensureAttached();\n\n return {\n available: () => ensureAttached() !== undefined,\n\n list(filter) {\n const store = ensureAttached();\n\n if (!store) return [];\n\n return store\n .list()\n .map((trace) => summarizeAgentTrace(trace, requestIds.get(trace.runId)))\n .filter((run) => filter?.requestId === undefined || run.requestId === filter.requestId);\n },\n\n get: (runId) => ensureAttached()?.get(runId),\n\n subscribe(listener) {\n ensureAttached();\n listeners.add(listener);\n\n return () => {\n listeners.delete(listener);\n };\n },\n\n dispose() {\n detach?.();\n detach = undefined;\n attachedStore = undefined;\n listeners.clear();\n requestIds.clear();\n },\n };\n}\n"],"mappings":";;;;;;;AAQA,MAAa,mBAAmB,OAAO,IAAI,4BAA4B;AAEvE,MAAa,+BACX;;AAmDF,SAAgB,oBACd,OACA,WACkB;CAClB,IAAI,YAAY;CAChB,IAAI,WAAW;CAEf,KAAK,MAAM,QAAQ,MAAM,OAAO;EAC9B,aAAa,KAAK,UAAU;EAC5B,YAAY,KAAK,UAAU,QAAQ,SAAS,KAAK,YAAY,MAAS,CAAC,CAAC;CAC1E;CAEA,OAAO;EACL,OAAO,MAAM;EACb,OAAO,MAAM;EACb,QAAQ,MAAM;EACd,WAAW,MAAM;EACjB,YAAY,MAAM;EAClB,OAAO,GAAG,MAAM,MAAM,SAAS,GAAG,MAAM,MAAM;EAC9C,OAAO,MAAM,MAAM;EACnB;EACA;EACA,OAAO;GAAE,OAAO,MAAM,MAAM;GAAO,QAAQ,MAAM,MAAM;EAAO;EAC9D,MAAM,MAAM;EACZ,GAAI,YAAY,EAAE,UAAU,IAAI,CAAC;CACnC;AACF;AAEA,MAAM,oBAAoB;;;;;;;AAQ1B,eAAsB,yBAA4D;CAChF,MAAM,EAAE,qBAAqB,MAAM,OAAO;CAC1C,MAAM,4BAAY,IAAI,IAA8C;CACpE,MAAM,6BAAa,IAAI,IAAoB;CAC3C,IAAI;CACJ,IAAI;CAEJ,MAAM,kBAAuD;EAC3D,MAAM,QAAS,WACb;EAGF,OAAO,SAAS,OAAO,MAAM,SAAS,aAAa,QAAQ;CAC7D;CAEA,MAAM,uBAA4D;EAChE,MAAM,QAAQ,UAAU;EAExB,IAAI,SAAS,UAAU,eAAe;GACpC,SAAS;GACT,gBAAgB;GAChB,SAAS,MAAM,WAAW,UAAU;IAGlC,IAAI,YAAY,WAAW,IAAI,MAAM,KAAK;IAE1C,IAAI,CAAC,WAAW;KACd,YAAY,iBAAiB;KAE7B,IAAI,WAAW;MACb,WAAW,IAAI,MAAM,OAAO,SAAS;MAErC,IAAI,WAAW,OAAO,mBAAmB;OACvC,MAAM,SAAS,WAAW,KAAK,CAAC,CAAC,KAAK;OAEtC,IAAI,CAAC,OAAO,MAAM,WAAW,OAAO,OAAO,KAAK;MAClD;KACF;IACF;IAEA,KAAK,MAAM,YAAY,WACrB,IAAI;KACF,SAAS;MAAE,GAAG;MAAO,GAAI,YAAY,EAAE,UAAU,IAAI,CAAC;KAAG,CAAC;IAC5D,QAAQ,CAER;GAEJ,CAAC;EACH;EAEA,OAAO;CACT;CAEA,eAAe;CAEf,OAAO;EACL,iBAAiB,eAAe,MAAM;EAEtC,KAAK,QAAQ;GACX,MAAM,QAAQ,eAAe;GAE7B,IAAI,CAAC,OAAO,OAAO,CAAC;GAEpB,OAAO,MACJ,KAAK,CAAC,CACN,KAAK,UAAU,oBAAoB,OAAO,WAAW,IAAI,MAAM,KAAK,CAAC,CAAC,CAAC,CACvE,QAAQ,QAAQ,QAAQ,cAAc,UAAa,IAAI,cAAc,OAAO,SAAS;EAC1F;EAEA,MAAM,UAAU,eAAe,CAAC,EAAE,IAAI,KAAK;EAE3C,UAAU,UAAU;GAClB,eAAe;GACf,UAAU,IAAI,QAAQ;GAEtB,aAAa;IACX,UAAU,OAAO,QAAQ;GAC3B;EACF;EAEA,UAAU;GACR,SAAS;GACT,SAAS;GACT,gBAAgB;GAChB,UAAU,MAAM;GAChB,WAAW,MAAM;EACnB;CACF;AACF"}
package/esm/types.d.mts CHANGED
@@ -1,11 +1,14 @@
1
+ import { DevtoolsAgentTraceEvent } from "./sources/agent-trace-source.mjs";
1
2
  import { DevtoolsAiEvent } from "./sources/ai-source.mjs";
3
+ import { RequestLogRecord } from "@warlock.js/core";
2
4
  //#region ../../packages/devtools/src/types.d.ts
3
5
  /**
4
6
  * The records the devtools collector keeps and the dashboard API returns.
5
7
  *
6
8
  * Every timestamp is epoch milliseconds (fractional allowed); every duration
7
9
  * is milliseconds. Nothing here is persisted — the collector is an in-memory
8
- * ring buffer that is lost on restart.
10
+ * ring buffer that is lost on restart. Request history that must survive a
11
+ * restart is read from core's persistent request log instead.
9
12
  */
10
13
  /** Options accepted by `devtoolsConnector()`. */
11
14
  export type DevtoolsOptions = {
@@ -152,6 +155,17 @@ export type DevtoolsRequestSummary = {
152
155
  durationMs?: number;
153
156
  queryCount: number;
154
157
  warningCount: number;
158
+ /** Read from the persisted request log only: the request is no longer in memory. */
159
+ persisted?: true;
160
+ };
161
+ /**
162
+ * `GET <path>/api/requests/:id`: the in-memory record, or one rebuilt from
163
+ * the persisted request log. `record` is the log's full record (redacted
164
+ * headers and body, response, error with stack) when one was written.
165
+ */
166
+ export type DevtoolsRequestDetail = DevtoolsRequest & {
167
+ persisted?: true;
168
+ record?: RequestLogRecord;
155
169
  };
156
170
  /** The row the mailbox list shows; `GET <path>/api/mails` returns these. */
157
171
  export type DevtoolsMailSummary = {
@@ -183,6 +197,9 @@ export type DevtoolsStreamEvent = {
183
197
  } | {
184
198
  type: "ai";
185
199
  data: DevtoolsAiEvent;
200
+ } | {
201
+ type: "agent-trace";
202
+ data: DevtoolsAgentTraceEvent;
186
203
  };
187
204
  /** Unsubscribes a listener or detaches a source. */
188
205
  export type DevtoolsDisposer = () => void;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","names":[],"sources":["../../../../../../../packages/devtools/src/types.ts"],"mappings":";;;;;;;;;;YAWY;;;;;;EAMV;;;;;;EAMA;;;;;;;EAOA;;;YAIU,0BAA0B,SAAS;;YAGnC;;EAEV;EACA;EACA;;;YAIU;EACV;EACA;EACA;EACA,QAAQ;;;YAIE;;EAEV;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;;;;;;EAMA;;EAEA,SAAS;;;YAIC;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;;YAIU;EACV;EACA;EACA;EACA;EACA;;EAEA;;;YAIU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,SAAS;EACT,aAAa;;;YAIH;EACV;EACA;EACA;;;YAIU;EACV;EACA;EACA;EACA;EACA,SAAS;;;YAIC;;EAEV;EACA;EACA;;EAEA;EACA;EACA;;EAEA;EACA;EACA,QAAQ;EACR,SAAS;EACT,OAAO;EACP,MAAM;;EAEN;EACA,UAAU;;;YAIA;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;YAIU;EACV;EACA;EACA;EACA;EACA;;;;;;YAOU;EACV,SAAS;EACT,OAAO;EACP,MAAM;;;YAII;EACN;EAAiB,MAAM;;EACvB;EAAc,MAAM;;EACpB;EAAa,MAAM;;EACnB;EAAY,MAAM;;;YAGZ;;;;;;YAOA;EACV,aAAa;IACX;IACA;IACA;IACA;IACA;;;EAGF,WACE,YACA;IAAU;IAAiB;IAAoB;IAAgB;;EAEjE,SAAS,mBAAmB,OAAO;;EAEnC,SACE,+BACA,OAAO,KAAK,iCACX;EACH,kBAAkB,+BAA+B,WAAW;EAC5D,OAAO,+BAA+B,OAAO;EAC7C,QAAQ,MAAM;EACd,gBAAgB;EAChB,WAAW,aAAa;EACxB,aAAa;EACb,QAAQ,aAAa;EACrB,SAAS;IAAW,QAAQ;IAA2B;MAAoB;EAC3E,iBAAiB;EACjB,UAAU,WAAW,OAAO,+BAA+B;EAC3D"}
1
+ {"version":3,"file":"types.d.mts","names":[],"sources":["../../../../../../../packages/devtools/src/types.ts"],"mappings":";;;;;;;;;;;;;YAcY;;;;;;EAMV;;;;;;EAMA;;;;;;;EAOA;;;YAIU,0BAA0B,SAAS;;YAGnC;;EAEV;EACA;EACA;;;YAIU;EACV;EACA;EACA;EACA,QAAQ;;;YAIE;;EAEV;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;;;;;;EAMA;;EAEA,SAAS;;;YAIC;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;;YAIU;EACV;EACA;EACA;EACA;EACA;;EAEA;;;YAIU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,SAAS;EACT,aAAa;;;YAIH;EACV;EACA;EACA;;;YAIU;EACV;EACA;EACA;EACA;EACA,SAAS;;;YAIC;;EAEV;EACA;EACA;;EAEA;EACA;EACA;;EAEA;EACA;EACA,QAAQ;EACR,SAAS;EACT,OAAO;EACP,MAAM;;EAEN;EACA,UAAU;;;YAIA;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;;;;;;;YAQU,wBAAwB;EAClC;EACA,SAAS;;;YAIC;EACV;EACA;EACA;EACA;EACA;;;;;;YAOU;EACV,SAAS;EACT,OAAO;EACP,MAAM;;;YAII;EACN;EAAiB,MAAM;;EACvB;EAAc,MAAM;;EACpB;EAAa,MAAM;;EACnB;EAAY,MAAM;;EAClB;EAAqB,MAAM;;;YAGrB;;;;;;YAOA;EACV,aAAa;IACX;IACA;IACA;IACA;IACA;;;EAGF,WACE,YACA;IAAU;IAAiB;IAAoB;IAAgB;;EAEjE,SAAS,mBAAmB,OAAO;;EAEnC,SACE,+BACA,OAAO,KAAK,iCACX;EACH,kBAAkB,+BAA+B,WAAW;EAC5D,OAAO,+BAA+B,OAAO;EAC7C,QAAQ,MAAM;EACd,gBAAgB;EAChB,WAAW,aAAa;EACxB,aAAa;EACb,QAAQ,aAAa;EACrB,SAAS;IAAW,QAAQ;IAA2B;MAAoB;EAC3E,iBAAiB;EACjB,UAAU,WAAW,OAAO,+BAA+B;EAC3D"}
package/llms-full.txt CHANGED
@@ -52,12 +52,33 @@ of it would fail to resolve there.
52
52
  | **Mail** | Every mail sent in development: headers, HTML (sandboxed) and text, attachment names | core `mailEvents.onCaptured()` |
53
53
  | **Logs** | Log entries per request, filterable by level and module | a logger channel |
54
54
  | **Cache** | hit / miss / set / removed / `invalidated` (tags, keys removed) | cache `cache.on(...)` |
55
+ | **Agents** | Per-turn traces of `@warlock.js/ai` agents: system prompt, tools offered with schema hashes, tool calls, results and refusals, retries, usage and cost, plus a comparison with the previous run of the agent | `@warlock.js/ai` `agentTraces` store |
55
56
  | **Routes** | Every HTTP route with its method, path, name and middleware | core router |
56
57
  | **API** | The app's API reference: every route with its parameters, request body, responses and auth | core `getDevelopmentOpenApiDocument()` |
57
58
 
58
59
  Work outside a request (boot, scheduler ticks, queue jobs) goes to a separate
59
60
  background list, so it never clutters a request's timeline.
60
61
 
62
+ ## Request history survives restarts
63
+
64
+ With core's request log on (the default in development, `http.logging.requests`),
65
+ the **Requests** panel also reads `storage/logs/requests/*.jsonl`: history past
66
+ a restart and past the 200-request ring buffer, merged with live requests
67
+ without duplicates by id (saved-only rows are marked **saved**).
68
+
69
+ - Filter: `GET /__warlock/api/requests?status=5xx&route=posts&method=POST&since=1h&until=…&q=text&limit=50`
70
+ (`status` is `404` or a class like `5xx`; `since` is a duration or ISO date).
71
+ A bad value answers 400.
72
+ - Detail: `GET /__warlock/api/requests/:id` returns the in-memory request, or a
73
+ saved one rebuilt from the log; either carries `record` (the full
74
+ `RequestLogRecord`: redacted headers/body, response, error with stack, logs,
75
+ query summary) when one was written. Per-query detail and Explain exist only
76
+ for requests still in memory.
77
+ - Copy as curl: `GET /__warlock/api/requests/:id/curl` returns `{ curl }`;
78
+ redacted values stay `[REDACTED]`.
79
+
80
+ An older core without the request log leaves the panel in-memory only.
81
+
61
82
  ## AI runs alongside HTTP requests
62
83
 
63
84
  The **AI** tab and each request's **AI runs** section display completed traces
@@ -101,6 +122,19 @@ feed the panel. An installed but unobserved flow produces no trace.
101
122
  compaction-block counts; summary content is omitted. Orchestrator result-only
102
123
  compaction cannot be reconstructed from a report-only trace.
103
124
 
125
+ ### Agent traces
126
+
127
+ The **Agents** tab needs no Panoptic: `@warlock.js/ai` 5.38+ records a trace per
128
+ agent run in development and devtools reads its shared store. Endpoints:
129
+ `GET /__warlock/api/ai/agent-runs[?requestId=<id>]` (list, newest first; `available:
130
+ false` with guidance until the AI package has created its store),
131
+ `GET /__warlock/api/ai/agent-runs/<run-id>` (full trace, 404 when evicted), and
132
+ `agent-trace` events `{ runId, status, requestId? }` on the stream. Unlike the
133
+ Panoptic view these carry prompt and tool content (secret keys are redacted
134
+ before storage), so they stay behind the same development and loopback guard.
135
+ `warlock ai trace [runId] [--diff other]` prints the same data. Public types:
136
+ `DevtoolsAgentRun`, `DevtoolsAgentTraceEvent`.
137
+
104
138
  A same-origin browser tool can consume the public types directly:
105
139
 
106
140
  ```ts
package/package.json CHANGED
@@ -5,11 +5,11 @@
5
5
  "environment": "server"
6
6
  },
7
7
  "peerDependencies": {
8
- "@warlock.js/ai-panoptic": "5.37.0",
9
- "@warlock.js/cache": "5.37.0",
10
- "@warlock.js/cascade": "5.37.0",
11
- "@warlock.js/core": "5.37.0",
12
- "@warlock.js/logger": "5.37.0"
8
+ "@warlock.js/ai-panoptic": "5.38.0",
9
+ "@warlock.js/cache": "5.38.0",
10
+ "@warlock.js/cascade": "5.38.0",
11
+ "@warlock.js/core": "5.38.0",
12
+ "@warlock.js/logger": "5.38.0"
13
13
  },
14
14
  "peerDependenciesMeta": {
15
15
  "@warlock.js/ai-panoptic": {
@@ -38,7 +38,7 @@
38
38
  ],
39
39
  "author": "hassanzohdy",
40
40
  "license": "MIT",
41
- "version": "5.37.0",
41
+ "version": "5.38.0",
42
42
  "main": "./cjs/index.cjs",
43
43
  "module": "./esm/index.mjs",
44
44
  "types": "./esm/index.d.mts",
package/skills/SKILL.md CHANGED
@@ -44,12 +44,33 @@ of it would fail to resolve there.
44
44
  | **Mail** | Every mail sent in development: headers, HTML (sandboxed) and text, attachment names | core `mailEvents.onCaptured()` |
45
45
  | **Logs** | Log entries per request, filterable by level and module | a logger channel |
46
46
  | **Cache** | hit / miss / set / removed / `invalidated` (tags, keys removed) | cache `cache.on(...)` |
47
+ | **Agents** | Per-turn traces of `@warlock.js/ai` agents: system prompt, tools offered with schema hashes, tool calls, results and refusals, retries, usage and cost, plus a comparison with the previous run of the agent | `@warlock.js/ai` `agentTraces` store |
47
48
  | **Routes** | Every HTTP route with its method, path, name and middleware | core router |
48
49
  | **API** | The app's API reference: every route with its parameters, request body, responses and auth | core `getDevelopmentOpenApiDocument()` |
49
50
 
50
51
  Work outside a request (boot, scheduler ticks, queue jobs) goes to a separate
51
52
  background list, so it never clutters a request's timeline.
52
53
 
54
+ ## Request history survives restarts
55
+
56
+ With core's request log on (the default in development, `http.logging.requests`),
57
+ the **Requests** panel also reads `storage/logs/requests/*.jsonl`: history past
58
+ a restart and past the 200-request ring buffer, merged with live requests
59
+ without duplicates by id (saved-only rows are marked **saved**).
60
+
61
+ - Filter: `GET /__warlock/api/requests?status=5xx&route=posts&method=POST&since=1h&until=…&q=text&limit=50`
62
+ (`status` is `404` or a class like `5xx`; `since` is a duration or ISO date).
63
+ A bad value answers 400.
64
+ - Detail: `GET /__warlock/api/requests/:id` returns the in-memory request, or a
65
+ saved one rebuilt from the log; either carries `record` (the full
66
+ `RequestLogRecord`: redacted headers/body, response, error with stack, logs,
67
+ query summary) when one was written. Per-query detail and Explain exist only
68
+ for requests still in memory.
69
+ - Copy as curl: `GET /__warlock/api/requests/:id/curl` returns `{ curl }`;
70
+ redacted values stay `[REDACTED]`.
71
+
72
+ An older core without the request log leaves the panel in-memory only.
73
+
53
74
  ## AI runs alongside HTTP requests
54
75
 
55
76
  The **AI** tab and each request's **AI runs** section display completed traces
@@ -93,6 +114,19 @@ feed the panel. An installed but unobserved flow produces no trace.
93
114
  compaction-block counts; summary content is omitted. Orchestrator result-only
94
115
  compaction cannot be reconstructed from a report-only trace.
95
116
 
117
+ ### Agent traces
118
+
119
+ The **Agents** tab needs no Panoptic: `@warlock.js/ai` 5.38+ records a trace per
120
+ agent run in development and devtools reads its shared store. Endpoints:
121
+ `GET /__warlock/api/ai/agent-runs[?requestId=<id>]` (list, newest first; `available:
122
+ false` with guidance until the AI package has created its store),
123
+ `GET /__warlock/api/ai/agent-runs/<run-id>` (full trace, 404 when evicted), and
124
+ `agent-trace` events `{ runId, status, requestId? }` on the stream. Unlike the
125
+ Panoptic view these carry prompt and tool content (secret keys are redacted
126
+ before storage), so they stay behind the same development and loopback guard.
127
+ `warlock ai trace [runId] [--diff other]` prints the same data. Public types:
128
+ `DevtoolsAgentRun`, `DevtoolsAgentTraceEvent`.
129
+
96
130
  A same-origin browser tool can consume the public types directly:
97
131
 
98
132
  ```ts