@agentxjs/devtools 1.9.5-dev → 2.0.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 (46) hide show
  1. package/README.md +284 -0
  2. package/dist/bdd/cli.d.ts +1 -0
  3. package/dist/bdd/cli.js +117 -0
  4. package/dist/bdd/cli.js.map +1 -0
  5. package/dist/bdd/index.d.ts +202 -0
  6. package/dist/bdd/index.js +381 -0
  7. package/dist/bdd/index.js.map +1 -0
  8. package/dist/chunk-6OHXS7LW.js +297 -0
  9. package/dist/chunk-6OHXS7LW.js.map +1 -0
  10. package/dist/chunk-DGUM43GV.js +11 -0
  11. package/dist/chunk-DGUM43GV.js.map +1 -0
  12. package/dist/chunk-DR45HEV4.js +152 -0
  13. package/dist/chunk-DR45HEV4.js.map +1 -0
  14. package/dist/chunk-J6L73HM5.js +301 -0
  15. package/dist/chunk-J6L73HM5.js.map +1 -0
  16. package/dist/chunk-S7J75AXG.js +64 -0
  17. package/dist/chunk-S7J75AXG.js.map +1 -0
  18. package/dist/fixtures/index.d.ts +49 -0
  19. package/dist/fixtures/index.js +22 -0
  20. package/dist/fixtures/index.js.map +1 -0
  21. package/dist/index.d.ts +240 -0
  22. package/dist/index.js +269 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/mock/index.d.ts +115 -0
  25. package/dist/mock/index.js +11 -0
  26. package/dist/mock/index.js.map +1 -0
  27. package/dist/recorder/index.d.ts +120 -0
  28. package/dist/recorder/index.js +10 -0
  29. package/dist/recorder/index.js.map +1 -0
  30. package/dist/types-C6Lf3vz2.d.ts +78 -0
  31. package/package.json +63 -8
  32. package/src/Devtools.ts +11 -14
  33. package/src/bdd/agent-doc-tester.ts +130 -0
  34. package/src/bdd/agent-ui-tester.ts +88 -0
  35. package/src/bdd/cli.ts +166 -0
  36. package/src/bdd/cucumber.config.ts +40 -0
  37. package/src/bdd/dev-server.ts +82 -0
  38. package/src/bdd/index.ts +41 -0
  39. package/src/bdd/paths.ts +140 -0
  40. package/src/bdd/playwright.ts +110 -0
  41. package/src/env.ts +97 -0
  42. package/src/index.ts +6 -1
  43. package/src/mock/MockDriver.ts +21 -12
  44. package/src/recorder/RecordingDriver.ts +1 -5
  45. package/scripts/record-fixture.ts +0 -148
  46. package/tsconfig.json +0 -10
@@ -22,12 +22,7 @@
22
22
  * ```
23
23
  */
24
24
 
25
- import type {
26
- Driver,
27
- DriverConfig,
28
- DriverState,
29
- DriverStreamEvent,
30
- } from "@agentxjs/core/driver";
25
+ import type { Driver, DriverConfig, DriverState, DriverStreamEvent } from "@agentxjs/core/driver";
31
26
  import type { UserMessage } from "@agentxjs/core/agent";
32
27
  import type { Fixture, FixtureEvent, MockDriverOptions } from "../types";
33
28
  import { BUILTIN_FIXTURES } from "../../fixtures";
@@ -65,10 +60,7 @@ export class MockDriver implements Driver {
65
60
  * @param options - MockDriverOptions or DriverConfig
66
61
  * @param mockOptions - MockDriverOptions if first param is DriverConfig
67
62
  */
68
- constructor(
69
- optionsOrConfig: MockDriverOptions | DriverConfig,
70
- mockOptions?: MockDriverOptions
71
- ) {
63
+ constructor(optionsOrConfig: MockDriverOptions | DriverConfig, mockOptions?: MockDriverOptions) {
72
64
  // Detect which constructor form is being used
73
65
  if (mockOptions !== undefined || "apiKey" in optionsOrConfig) {
74
66
  // Factory mode: (DriverConfig, MockDriverOptions)
@@ -349,12 +341,27 @@ export class MockDriver implements Driver {
349
341
  },
350
342
  };
351
343
 
344
+ case "message_delta":
345
+ return {
346
+ type: "message_delta",
347
+ timestamp,
348
+ data: {
349
+ usage: data.usage as { inputTokens: number; outputTokens: number } | undefined,
350
+ },
351
+ };
352
+
352
353
  case "message_stop":
353
354
  return {
354
355
  type: "message_stop",
355
356
  timestamp,
356
357
  data: {
357
- stopReason: (data.stopReason as "end_turn" | "tool_use" | "max_tokens" | "stop_sequence" | "other") || "end_turn",
358
+ stopReason:
359
+ (data.stopReason as
360
+ | "end_turn"
361
+ | "tool_use"
362
+ | "max_tokens"
363
+ | "stop_sequence"
364
+ | "other") || "end_turn",
358
365
  },
359
366
  };
360
367
 
@@ -391,6 +398,8 @@ export class MockDriver implements Driver {
391
398
  * @param mockOptions - Options for all created drivers
392
399
  * @returns CreateDriver function
393
400
  */
394
- export function createMockDriver(mockOptions: MockDriverOptions = {}): (config: DriverConfig) => Driver {
401
+ export function createMockDriver(
402
+ mockOptions: MockDriverOptions = {}
403
+ ): (config: DriverConfig) => Driver {
395
404
  return (config: DriverConfig) => new MockDriver(config, mockOptions);
396
405
  }
@@ -31,11 +31,7 @@
31
31
  * ```
32
32
  */
33
33
 
34
- import type {
35
- Driver,
36
- DriverState,
37
- DriverStreamEvent,
38
- } from "@agentxjs/core/driver";
34
+ import type { Driver, DriverState, DriverStreamEvent } from "@agentxjs/core/driver";
39
35
  import type { UserMessage } from "@agentxjs/core/agent";
40
36
  import type { Fixture, FixtureEvent } from "../types";
41
37
  import { createLogger } from "commonxjs/logger";
@@ -1,148 +0,0 @@
1
- #!/usr/bin/env bun
2
- /**
3
- * Record Fixture Script
4
- *
5
- * Records a real Claude conversation and saves it as a fixture.
6
- * Environment is auto-loaded from monorepo root .env.local via bunfig.toml preload.
7
- *
8
- * Usage:
9
- * bun run scripts/record-fixture.ts "Hello, how are you?" my-greeting
10
- */
11
-
12
- import { createRecordingDriver } from "../src/recorder/RecordingDriver";
13
- import { createClaudeDriverFactory } from "@agentxjs/claude-driver";
14
- import { EventBusImpl } from "@agentxjs/core/event";
15
- import { dirname, join } from "node:path";
16
- import { fileURLToPath } from "node:url";
17
-
18
- const __dirname = dirname(fileURLToPath(import.meta.url));
19
-
20
- // Parse args
21
- const message = process.argv[2] || "Hello!";
22
- const fixtureName = process.argv[3] || `fixture-${Date.now()}`;
23
-
24
- // Get config from env
25
- const apiKey = process.env.DEEPRACTICE_API_KEY;
26
- const baseUrl = process.env.DEEPRACTICE_BASE_URL;
27
- const model = process.env.DEEPRACTICE_MODEL || "claude-haiku-4-5-20251001";
28
-
29
- if (!apiKey) {
30
- console.error("Error: DEEPRACTICE_API_KEY is required");
31
- process.exit(1);
32
- }
33
-
34
- console.log(`\nšŸŽ¬ Recording fixture: ${fixtureName}`);
35
- console.log(`šŸ“ Message: "${message}"`);
36
- console.log(`šŸ”‘ API Key: ${apiKey.substring(0, 10)}...`);
37
- if (baseUrl) console.log(`🌐 Base URL: ${baseUrl}`);
38
-
39
- async function main() {
40
- // Create EventBus
41
- const bus = new EventBusImpl();
42
-
43
- // Create real Claude driver
44
- const claudeFactory = createClaudeDriverFactory();
45
- const realDriver = claudeFactory.createDriver({
46
- agentId: "recording-agent",
47
- config: {
48
- apiKey: apiKey!,
49
- baseUrl,
50
- model,
51
- systemPrompt: "You are a helpful assistant. Keep responses brief.",
52
- cwd: process.cwd(), // Enable Bash tool execution
53
- },
54
- });
55
-
56
- // Wrap with recorder
57
- const recorder = createRecordingDriver({
58
- driver: realDriver,
59
- name: fixtureName,
60
- description: `Recording of: "${message}"`,
61
- });
62
-
63
- // Connect
64
- recorder.connect(bus.asConsumer(), bus.asProducer());
65
-
66
- // Track when we get message_stop with end_turn (not tool_use)
67
- let completed = false;
68
- bus.on("message_stop", (evt) => {
69
- const data = evt.data as { stopReason?: string };
70
- // Only finish when it's truly done, not when waiting for tool result
71
- if (data.stopReason === "end_turn") {
72
- completed = true;
73
- }
74
- });
75
-
76
- // Track text deltas
77
- let fullText = "";
78
- bus.on("text_delta", (evt) => {
79
- const text = (evt.data as { text: string }).text;
80
- fullText += text;
81
- process.stdout.write(text);
82
- });
83
-
84
- // Track tool calls
85
- bus.on("tool_use_content_block_start", (evt) => {
86
- const data = evt.data as { name?: string };
87
- console.log(`\nšŸ”§ Tool call: ${data.name || "unknown"}`);
88
- });
89
-
90
- bus.on("tool_result", (evt) => {
91
- const data = evt.data as { isError?: boolean };
92
- console.log(`šŸ“¤ Tool result ${data.isError ? "(error)" : "(success)"}`);
93
- });
94
-
95
- console.log("\n\nšŸ“¤ Sending message...\n");
96
- console.log("------- Response -------");
97
-
98
- // Send user message
99
- bus.emit({
100
- type: "user_message",
101
- timestamp: Date.now(),
102
- source: "test",
103
- category: "message",
104
- intent: "request",
105
- data: {
106
- id: `msg_${Date.now()}`,
107
- role: "user",
108
- subtype: "user",
109
- content: message,
110
- timestamp: Date.now(),
111
- },
112
- context: {
113
- agentId: "recording-agent",
114
- sessionId: "recording-session",
115
- },
116
- } as never);
117
-
118
- // Wait for completion (longer timeout for tool calls)
119
- const timeout = 120000; // 2 minutes
120
- const start = Date.now();
121
- while (!completed && Date.now() - start < timeout) {
122
- await new Promise((r) => setTimeout(r, 100));
123
- }
124
-
125
- console.log("\n------------------------\n");
126
-
127
- if (!completed) {
128
- console.error("āš ļø Timeout waiting for response");
129
- }
130
-
131
- // Save fixture
132
- const outputPath = join(__dirname, "..", "fixtures", `${fixtureName}.json`);
133
- await recorder.saveFixture(outputPath);
134
-
135
- console.log(`āœ… Fixture saved: ${outputPath}`);
136
- console.log(`šŸ“Š Events recorded: ${recorder.eventCount}`);
137
- console.log(`šŸ“ Response length: ${fullText.length} chars`);
138
-
139
- // Cleanup
140
- recorder.dispose();
141
-
142
- process.exit(0);
143
- }
144
-
145
- main().catch((err) => {
146
- console.error("Error:", err);
147
- process.exit(1);
148
- });
package/tsconfig.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "outDir": "./dist",
5
- "rootDir": ".",
6
- "types": ["bun-types"]
7
- },
8
- "include": ["src/**/*", "fixtures/**/*"],
9
- "exclude": ["src/**/__tests__/**/*", "src/**/*.test.ts", "src/**/*.spec.ts", "scripts/**/*"]
10
- }