elasticdash-test 0.1.25-alpha-2 → 0.1.25
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.
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
> **When to use**: Follow this guide step-by-step when a user asks you to "integrate ElasticDash", "set up ElasticDash testing", "implement elasticdash-test", or similar. Each step produces a specific file — work through them in order.
|
|
6
6
|
>
|
|
7
7
|
> **How to use**: Read the full guide first to understand the project's structure, then execute each step. Use the decision trees section to choose the right pattern for the user's project (framework type, module system, tool architecture).
|
|
8
|
+
>
|
|
9
|
+
> **Important**: Do NOT leave `YOUR_TOOL_NAME` / `YOUR_WORKFLOW_NAME` placeholders in generated files. Before creating `ed_tools.ts` and `ed_workflows.ts`, scan the user's codebase to identify their actual tool functions (functions that call external APIs, databases, or services) and workflow functions (async functions that orchestrate LLM calls and tool calls). Create the files with the real function names, imports, and types found in the codebase. If no tools or workflows exist yet, ask the user which functions to instrument rather than generating placeholder files.
|
|
8
10
|
|
|
9
11
|
---
|
|
10
12
|
|
|
@@ -12,9 +14,18 @@
|
|
|
12
14
|
|
|
13
15
|
- Node.js >= 20
|
|
14
16
|
- npm, yarn, or pnpm
|
|
15
|
-
- At least one AI workflow function (a callable async function that makes LLM/tool calls)
|
|
16
17
|
- LLM provider API keys for providers used in workflows (e.g., `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`)
|
|
17
18
|
|
|
19
|
+
### Identify tools and workflows in the codebase
|
|
20
|
+
|
|
21
|
+
Before starting, scan the project to find:
|
|
22
|
+
|
|
23
|
+
- **Tool functions**: Exported async functions that call external services (APIs, databases, search, etc.). Look for functions that use `fetch`, database clients, SDK calls, or any external I/O. These go in `ed_tools.ts`.
|
|
24
|
+
- **Workflow functions**: Exported async functions that orchestrate an AI pipeline — typically calling an LLM and one or more tools. Look for functions that call OpenAI, Anthropic, Gemini, or similar SDKs. These go in `ed_workflows.ts`.
|
|
25
|
+
|
|
26
|
+
If the project has no clear tool or workflow functions yet, ask the user:
|
|
27
|
+
> "Which functions in your codebase make external API/service calls (tools), and which functions orchestrate your AI workflow? I need to know so I can set up ElasticDash instrumentation."
|
|
28
|
+
|
|
18
29
|
### Detect project type before starting
|
|
19
30
|
|
|
20
31
|
Check these before choosing patterns:
|
|
@@ -47,6 +58,8 @@ Add to `.gitignore`:
|
|
|
47
58
|
|
|
48
59
|
Create `ed_tools.ts` in the project root. This file wraps each tool function with tracing so ElasticDash can record and replay tool calls.
|
|
49
60
|
|
|
61
|
+
**Before writing this file**: Search the codebase for functions that call external services (APIs, databases, SDKs). Each one becomes a wrapped export in `ed_tools.ts`. Replace all `YOUR_TOOL_*` and `YOUR_SOURCE_PATH_*` placeholders below with the actual function names and import paths found in the project.
|
|
62
|
+
|
|
50
63
|
### Choose your pattern
|
|
51
64
|
|
|
52
65
|
- **Pattern B (recommended for most projects)**: inline async with mock support. Use when tools are imported individually, no central dispatcher exists, or you want dashboard mock support.
|
|
@@ -221,6 +234,8 @@ export default nextConfig
|
|
|
221
234
|
|
|
222
235
|
Create `ed_workflows.ts` in the project root. This file exports workflow functions for the ElasticDash runner.
|
|
223
236
|
|
|
237
|
+
**Before writing this file**: Search the codebase for the main AI workflow functions — async functions that orchestrate LLM calls and tool calls (e.g., a chat handler, an agent loop, a pipeline function). Replace all `YOUR_WORKFLOW` and `YOUR_SOURCE_PATH` placeholders below with the actual function names and import paths.
|
|
238
|
+
|
|
224
239
|
### Simple case — direct re-export
|
|
225
240
|
|
|
226
241
|
```ts
|
|
@@ -292,19 +307,53 @@ export { chatStreamHandler } from './app/api/chat-stream/chatStreamHandler'
|
|
|
292
307
|
|
|
293
308
|
---
|
|
294
309
|
|
|
295
|
-
## Step 4:
|
|
310
|
+
## Step 4: Wire `ed_workflows.ts` to use `ed_tools.ts`
|
|
311
|
+
|
|
312
|
+
> **Do not modify the user's existing production source files.** Only `ed_workflows.ts` needs to import from `ed_tools.ts`. The production codebase stays untouched.
|
|
313
|
+
|
|
314
|
+
The ElasticDash layer sits alongside the production code, not inside it:
|
|
315
|
+
|
|
316
|
+
```
|
|
317
|
+
Production code (unchanged):
|
|
318
|
+
src/workflows/checkout.ts → imports from src/services/payments.ts directly
|
|
319
|
+
|
|
320
|
+
ElasticDash layer (new files only):
|
|
321
|
+
ed_workflows.ts → imports tools from ed_tools.ts → calls the real service functions
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### What to do
|
|
296
325
|
|
|
297
|
-
|
|
326
|
+
In `ed_workflows.ts`, write wrapper functions that call tools through `ed_tools.ts` instead of importing from the original source. The ElasticDash test runner and dashboard call `ed_workflows.ts` — not the production code directly.
|
|
327
|
+
|
|
328
|
+
### Example
|
|
298
329
|
|
|
299
330
|
```ts
|
|
300
|
-
//
|
|
301
|
-
|
|
331
|
+
// ed_workflows.ts
|
|
332
|
+
// Import tools from ed_tools.ts (instrumented), NOT from original source
|
|
333
|
+
import { chargeCard, getOrderDetails } from './ed_tools'
|
|
334
|
+
|
|
335
|
+
// Re-create the workflow logic using instrumented tools
|
|
336
|
+
export async function checkoutFlow(input: { orderId: string }) {
|
|
337
|
+
const order = await getOrderDetails({ orderId: input.orderId })
|
|
338
|
+
const payment = await chargeCard({ amount: order.total })
|
|
339
|
+
return { orderId: order.orderId, paymentId: payment.id }
|
|
340
|
+
}
|
|
341
|
+
```
|
|
302
342
|
|
|
303
|
-
|
|
304
|
-
|
|
343
|
+
```ts
|
|
344
|
+
// ed_tools.ts
|
|
345
|
+
// Import from the ORIGINAL source
|
|
346
|
+
import { chargeCard as chargeCardImpl } from './src/services/payments'
|
|
347
|
+
import { getOrderDetails as getOrderDetailsImpl } from './src/services/orders'
|
|
348
|
+
|
|
349
|
+
// ... wrap with resolveMock + safeRecordToolCall pattern
|
|
305
350
|
```
|
|
306
351
|
|
|
307
|
-
|
|
352
|
+
### Why this approach
|
|
353
|
+
|
|
354
|
+
- **No production risk**: Existing source files are never modified. Production imports stay as-is.
|
|
355
|
+
- **Clean separation**: The `ed_` files are a parallel test/observability layer, not a refactor of the codebase.
|
|
356
|
+
- **Easy removal**: Delete `ed_tools.ts` and `ed_workflows.ts` to fully remove ElasticDash — no rollback needed.
|
|
308
357
|
|
|
309
358
|
---
|
|
310
359
|
|