elasticdash-test 0.1.13 โ 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -5
- package/dist/cli.js +0 -0
- package/dist/dashboard-server.d.ts +9 -0
- package/dist/dashboard-server.d.ts.map +1 -1
- package/dist/dashboard-server.js +1984 -17
- package/dist/dashboard-server.js.map +1 -1
- package/dist/html/dashboard.html +161 -11
- package/dist/index.cjs +828 -108
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/interceptors/telemetry-push.d.ts +47 -0
- package/dist/interceptors/telemetry-push.d.ts.map +1 -1
- package/dist/interceptors/telemetry-push.js +139 -6
- package/dist/interceptors/telemetry-push.js.map +1 -1
- package/dist/interceptors/tool.d.ts.map +1 -1
- package/dist/interceptors/tool.js +2 -1
- package/dist/interceptors/tool.js.map +1 -1
- package/dist/interceptors/workflow-ai.d.ts.map +1 -1
- package/dist/interceptors/workflow-ai.js +28 -4
- package/dist/interceptors/workflow-ai.js.map +1 -1
- package/dist/internals/mock-resolver.d.ts +42 -5
- package/dist/internals/mock-resolver.d.ts.map +1 -1
- package/dist/internals/mock-resolver.js +124 -5
- package/dist/internals/mock-resolver.js.map +1 -1
- package/dist/workflow-runner-worker.js +8 -2
- package/dist/workflow-runner-worker.js.map +1 -1
- package/package.json +3 -2
- package/src/dashboard-server.ts +86 -17
- package/src/html/dashboard.html +161 -11
- package/src/index.ts +3 -2
- package/src/interceptors/telemetry-push.ts +158 -7
- package/src/interceptors/tool.ts +2 -1
- package/src/interceptors/workflow-ai.ts +30 -4
- package/src/internals/mock-resolver.ts +131 -5
- package/src/workflow-runner-worker.ts +23 -2
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ An AI-native test runner for ElasticDash workflow testing. Built for async AI pi
|
|
|
28
28
|
- ๐ฏ **Trace-first testing** โ every test gets a `trace` context to record and assert on LLM calls and tool invocations
|
|
29
29
|
- ๐ **Automatic AI interception** โ captures OpenAI, Gemini, and Grok calls without code changes
|
|
30
30
|
- ๐งช **AI-specific matchers** โ semantic output matching, LLM-judged evaluations, prompt assertions
|
|
31
|
-
- ๐ ๏ธ **Tool recording & replay** โ automatically trace tool calls with checkpoint-based replay
|
|
31
|
+
- ๐ ๏ธ **Tool & LLM recording & replay** โ automatically trace tool and AI calls with checkpoint-based replay and mock support
|
|
32
32
|
- ๐ **Interactive dashboard** โ browse workflows, debug traces, validate fixes visually
|
|
33
33
|
- ๐ค **Agent mid-trace replay** โ resume long-running agents from any task without re-execution
|
|
34
34
|
- ๐ **HTTP workflow mode** โ run workflows against your live dev server for framework-heavy apps (Next.js, Remix, etc.) with full AI and tool call observability
|
|
@@ -266,6 +266,8 @@ export const callClaude = wrapAI('claude-sonnet-4-5', async (messages: Anthropic
|
|
|
266
266
|
|
|
267
267
|
Use `wrapAI` when you have a custom AI wrapper or a provider not covered by automatic interception. For direct OpenAI/Anthropic/Gemini SDK calls inside a subprocess workflow, automatic interception via `installAIInterceptor` already handles recording without any code changes.
|
|
268
268
|
|
|
269
|
+
**AI mocking (subprocess / test runner mode):** `wrapAI` also checks `resolveAIMock` at call time, so the dashboard can mock LLM responses the same way it mocks tool calls โ without modifying your server code. Configure an `AIMockConfig` in the dashboard UI or pass it programmatically via the `aiMockConfig` option when running a workflow.
|
|
270
|
+
|
|
269
271
|
### HTTP Streaming Capture and Replay
|
|
270
272
|
|
|
271
273
|
ElasticDash also captures non-AI `fetch` responses that stream over HTTP (for example SSE and NDJSON endpoints) in the HTTP interceptor.
|
|
@@ -354,6 +356,25 @@ The dashboard injects `x-elasticdash-run-id` and `x-elasticdash-server` headers
|
|
|
354
356
|
|
|
355
357
|
> **Note:** Use `setHttpRunContext` (synchronous) if you only need observability and do not need step freezing. `initHttpRunContext` is required for the dashboard's breakpoint/replay functionality to work.
|
|
356
358
|
|
|
359
|
+
### Dashboard Auto-Detection (env var mode)
|
|
360
|
+
|
|
361
|
+
As an alternative to calling `initHttpRunContext` in your request handler, you can set two environment variables before starting your server or script. Every `wrapTool` and `wrapAI` call will then connect to the dashboard automatically โ no code changes needed:
|
|
362
|
+
|
|
363
|
+
```bash
|
|
364
|
+
# Required: URL of the running ElasticDash dashboard
|
|
365
|
+
ELASTICDASH_SERVER=http://localhost:4573
|
|
366
|
+
|
|
367
|
+
# Optional: pre-registered run ID to fetch frozen steps for
|
|
368
|
+
ELASTICDASH_RUN_ID=<run-id-from-dashboard>
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
- If only `ELASTICDASH_SERVER` is set, a fresh run ID is generated and all calls push live telemetry to the dashboard (observability only, no step freezing).
|
|
372
|
+
- If both variables are set, frozen steps are fetched from the dashboard at startup and replayed as configured.
|
|
373
|
+
- If the dashboard is unreachable the SDK falls through to live execution silently.
|
|
374
|
+
- The initialization runs **once per process** โ subsequent `wrapTool`/`wrapAI` calls reuse the cached context.
|
|
375
|
+
|
|
376
|
+
This mode is intended for local development and testing scenarios. For production HTTP servers with concurrent requests, continue using `initHttpRunContext` inside your request handler.
|
|
377
|
+
|
|
357
378
|
**Subprocess vs HTTP mode comparison:**
|
|
358
379
|
|
|
359
380
|
| | Subprocess (default) | HTTP mode |
|
|
@@ -361,9 +382,10 @@ The dashboard injects `x-elasticdash-run-id` and `x-elasticdash-server` headers
|
|
|
361
382
|
| Works with simple apps | Yes | Yes |
|
|
362
383
|
| Works with Next.js / Remix | No | Yes |
|
|
363
384
|
| Requires dev server running | No | Yes |
|
|
364
|
-
| App code changes needed | Extract handler to `ed_workflows.ts` | Add `initHttpRunContext` to request handler |
|
|
385
|
+
| App code changes needed | Extract handler to `ed_workflows.ts` | Add `initHttpRunContext` to request handler (or use env vars for auto-detect) |
|
|
365
386
|
| AI / tool call observability | Automatic via interceptors | Via `wrapAI` / `wrapTool` push |
|
|
366
|
-
| Step freezing / breakpoints | Yes | Yes (
|
|
387
|
+
| Step freezing / breakpoints | Yes | Yes (`initHttpRunContext`, or `ELASTICDASH_SERVER` + `ELASTICDASH_RUN_ID` env vars) |
|
|
388
|
+
| LLM response mocking | Yes (via `aiMockConfig`) | Yes (via frozen AI events) |
|
|
367
389
|
|
|
368
390
|
---
|
|
369
391
|
|
|
@@ -420,16 +442,25 @@ reportResults(results)
|
|
|
420
442
|
**HTTP mode context (call inside your request handler):**
|
|
421
443
|
|
|
422
444
|
```ts
|
|
423
|
-
import { initHttpRunContext } from 'elasticdash-test'
|
|
445
|
+
import { initHttpRunContext, setHttpRunContext } from 'elasticdash-test'
|
|
424
446
|
|
|
425
447
|
// Async โ fetches frozen steps from dashboard to enable step freezing/breakpoints
|
|
426
448
|
await initHttpRunContext(runId, dashboardUrl)
|
|
427
449
|
|
|
428
450
|
// Synchronous alternative โ observability only, no step freezing
|
|
429
|
-
import { setHttpRunContext } from 'elasticdash-test'
|
|
430
451
|
setHttpRunContext(runId, dashboardUrl)
|
|
431
452
|
```
|
|
432
453
|
|
|
454
|
+
**Dashboard auto-detection (env var mode โ no code changes needed):**
|
|
455
|
+
|
|
456
|
+
```bash
|
|
457
|
+
# Set before starting your server or script
|
|
458
|
+
ELASTICDASH_SERVER=http://localhost:4573 # required
|
|
459
|
+
ELASTICDASH_RUN_ID=<run-id-from-dashboard> # optional, enables step freezing
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
`wrapTool` and `wrapAI` will auto-connect on their first call. See [Dashboard Auto-Detection](#dashboard-auto-detection-env-var-mode) for details.
|
|
463
|
+
|
|
433
464
|
---
|
|
434
465
|
|
|
435
466
|
## License
|
package/dist/cli.js
CHANGED
|
File without changes
|
|
@@ -40,6 +40,15 @@ export interface ToolMockEntry {
|
|
|
40
40
|
export interface ToolMockConfig {
|
|
41
41
|
[toolName: string]: ToolMockEntry;
|
|
42
42
|
}
|
|
43
|
+
/** Per-model AI mock configuration sent from the dashboard UI */
|
|
44
|
+
export interface AIMockEntry {
|
|
45
|
+
mode: 'live' | 'mock-all' | 'mock-specific';
|
|
46
|
+
callIndices?: number[];
|
|
47
|
+
mockData?: Record<number, unknown>;
|
|
48
|
+
}
|
|
49
|
+
export interface AIMockConfig {
|
|
50
|
+
[modelName: string]: AIMockEntry;
|
|
51
|
+
}
|
|
43
52
|
export interface HttpWorkflowConfig {
|
|
44
53
|
mode: 'http';
|
|
45
54
|
url: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboard-server.d.ts","sourceRoot":"","sources":["../src/dashboard-server.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,YAAY,EAAE,CAAA;IACzB,KAAK,EAAE,QAAQ,EAAE,CAAA;CAClB;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACvB;AA2CD,6DAA6D;AAC7D,MAAM,WAAW,aAAa;IAC5B,oHAAoH;IACpH,IAAI,EAAE,MAAM,G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