@hazeljs/agent 0.2.4 → 0.3.1

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 (49) hide show
  1. package/coverage/clover.xml +647 -546
  2. package/coverage/lcov-report/index.html +54 -39
  3. package/coverage/lcov.info +1058 -836
  4. package/dist/a2a/a2a.server.d.ts +92 -0
  5. package/dist/a2a/a2a.server.d.ts.map +1 -0
  6. package/dist/a2a/a2a.server.js +278 -0
  7. package/dist/a2a/a2a.server.js.map +1 -0
  8. package/dist/a2a/a2a.types.d.ts +170 -0
  9. package/dist/a2a/a2a.types.d.ts.map +1 -0
  10. package/dist/a2a/a2a.types.js +12 -0
  11. package/dist/a2a/a2a.types.js.map +1 -0
  12. package/dist/a2a/agent-card.builder.d.ts +63 -0
  13. package/dist/a2a/agent-card.builder.d.ts.map +1 -0
  14. package/dist/a2a/agent-card.builder.js +101 -0
  15. package/dist/a2a/agent-card.builder.js.map +1 -0
  16. package/dist/decorators/tool.decorator.d.ts.map +1 -1
  17. package/dist/decorators/tool.decorator.js +1 -0
  18. package/dist/decorators/tool.decorator.js.map +1 -1
  19. package/dist/executor/agent.executor.d.ts.map +1 -1
  20. package/dist/executor/agent.executor.js +44 -9
  21. package/dist/executor/agent.executor.js.map +1 -1
  22. package/dist/executor/tool.executor.d.ts.map +1 -1
  23. package/dist/executor/tool.executor.js +24 -0
  24. package/dist/executor/tool.executor.js.map +1 -1
  25. package/dist/index.d.ts +5 -0
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +8 -0
  28. package/dist/index.js.map +1 -1
  29. package/dist/registry/tool.registry.d.ts.map +1 -1
  30. package/dist/registry/tool.registry.js +16 -0
  31. package/dist/registry/tool.registry.js.map +1 -1
  32. package/dist/runtime/agent.runtime.d.ts +28 -0
  33. package/dist/runtime/agent.runtime.d.ts.map +1 -1
  34. package/dist/runtime/agent.runtime.js +51 -0
  35. package/dist/runtime/agent.runtime.js.map +1 -1
  36. package/dist/types/agent.types.d.ts +6 -0
  37. package/dist/types/agent.types.d.ts.map +1 -1
  38. package/dist/types/agent.types.js +1 -0
  39. package/dist/types/agent.types.js.map +1 -1
  40. package/dist/types/tool.types.d.ts +4 -0
  41. package/dist/types/tool.types.d.ts.map +1 -1
  42. package/dist/types/tool.types.js.map +1 -1
  43. package/logs/combined.log +1 -1
  44. package/package.json +9 -7
  45. package/tsconfig.tsbuildinfo +1 -1
  46. package/dist/executor/agent.executor.streaming.d.ts +0 -13
  47. package/dist/executor/agent.executor.streaming.d.ts.map +0 -1
  48. package/dist/executor/agent.executor.streaming.js +0 -103
  49. package/dist/executor/agent.executor.streaming.js.map +0 -1
@@ -1,13 +0,0 @@
1
- /**
2
- * Streaming-specific methods for AgentExecutor
3
- * This file contains the executeStepStream method for real-time token streaming
4
- */
5
- import { AgentContext } from '../types/agent.types';
6
- import { AgentStreamChunk } from '../types/agent.types';
7
- /**
8
- * Execute a single step with real-time token streaming.
9
- * Yields tokens as they arrive from the LLM instead of buffering them.
10
- * Note: This function is bound to AgentExecutor and accesses its private members
11
- */
12
- export declare function executeStepStream(this: any, context: AgentContext, stepNumber: number, signal?: AbortSignal): AsyncGenerator<AgentStreamChunk>;
13
- //# sourceMappingURL=agent.executor.streaming.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"agent.executor.streaming.d.ts","sourceRoot":"","sources":["../../src/executor/agent.executor.streaming.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAA0C,MAAM,sBAAsB,CAAC;AAC5F,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAIxD;;;;GAIG;AACH,wBAAuB,iBAAiB,CAEtC,IAAI,EAAE,GAAG,EACT,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,WAAW,GACnB,cAAc,CAAC,gBAAgB,CAAC,CAgGlC"}
@@ -1,103 +0,0 @@
1
- "use strict";
2
- /**
3
- * Streaming-specific methods for AgentExecutor
4
- * This file contains the executeStepStream method for real-time token streaming
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.executeStepStream = executeStepStream;
8
- const agent_types_1 = require("../types/agent.types");
9
- const crypto_1 = require("crypto");
10
- const event_types_1 = require("../types/event.types");
11
- /**
12
- * Execute a single step with real-time token streaming.
13
- * Yields tokens as they arrive from the LLM instead of buffering them.
14
- * Note: This function is bound to AgentExecutor and accesses its private members
15
- */
16
- async function* executeStepStream(context, stepNumber, signal) {
17
- const stepId = (0, crypto_1.randomUUID)();
18
- const startTime = Date.now();
19
- const step = {
20
- id: stepId,
21
- agentId: context.agentId,
22
- executionId: context.executionId,
23
- stepNumber,
24
- state: agent_types_1.AgentState.THINKING,
25
- timestamp: new Date(),
26
- };
27
- this.emitEvent(event_types_1.AgentEventType.STEP_STARTED, context.executionId, {
28
- stepNumber,
29
- state: step.state,
30
- });
31
- try {
32
- this.throwIfAborted(signal);
33
- // Build the LLM request
34
- const prompt = this.buildPrompt(context);
35
- const tools = this.toolRegistry.getToolDefinitionsForLLM(context.agentId);
36
- const messages = [
37
- { role: 'system', content: prompt.system },
38
- ...prompt.messages,
39
- { role: 'user', content: context.input },
40
- ];
41
- const request = {
42
- messages,
43
- tools: tools.length > 0 ? tools : undefined,
44
- };
45
- const streamChat = this.llmProvider?.streamChat;
46
- if (streamChat) {
47
- let content = '';
48
- // Stream tokens in real-time as they arrive
49
- for await (const chunk of streamChat(request)) {
50
- if (signal)
51
- this.throwIfAborted(signal);
52
- if (chunk.content) {
53
- content += chunk.content;
54
- // Yield each token immediately
55
- yield { type: 'token', content: chunk.content };
56
- }
57
- }
58
- // After streaming completes, create the action
59
- step.action = {
60
- type: agent_types_1.AgentActionType.RESPOND,
61
- response: content,
62
- };
63
- step.state = agent_types_1.AgentState.COMPLETED;
64
- step.result = {
65
- success: true,
66
- output: content,
67
- };
68
- }
69
- else {
70
- // Fallback to non-streaming
71
- const response = await this.llmProvider.chat(request);
72
- step.action = {
73
- type: agent_types_1.AgentActionType.RESPOND,
74
- response: response.content,
75
- };
76
- step.state = agent_types_1.AgentState.COMPLETED;
77
- step.result = {
78
- success: true,
79
- output: response.content,
80
- };
81
- }
82
- step.duration = Date.now() - startTime;
83
- this.emitEvent(event_types_1.AgentEventType.STEP_COMPLETED, context.executionId, {
84
- stepNumber,
85
- state: step.state,
86
- duration: step.duration,
87
- });
88
- // Yield the completed step
89
- yield { type: 'step', step };
90
- }
91
- catch (error) {
92
- step.state = agent_types_1.AgentState.FAILED;
93
- step.error = error;
94
- step.duration = Date.now() - startTime;
95
- this.emitEvent(event_types_1.AgentEventType.STEP_FAILED, context.executionId, {
96
- stepNumber,
97
- state: step.state,
98
- error: error.message,
99
- });
100
- yield { type: 'step', step };
101
- }
102
- }
103
- //# sourceMappingURL=agent.executor.streaming.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"agent.executor.streaming.js","sourceRoot":"","sources":["../../src/executor/agent.executor.streaming.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAYH,8CAsGC;AAhHD,sDAA4F;AAE5F,mCAAoC;AACpC,sDAAsD;AAEtD;;;;GAIG;AACI,KAAK,SAAS,CAAC,CAAC,iBAAiB,CAGtC,OAAqB,EACrB,UAAkB,EAClB,MAAoB;IAEpB,MAAM,MAAM,GAAG,IAAA,mBAAU,GAAE,CAAC;IAC5B,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE7B,MAAM,IAAI,GAAc;QACtB,EAAE,EAAE,MAAM;QACV,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,UAAU;QACV,KAAK,EAAE,wBAAU,CAAC,QAAQ;QAC1B,SAAS,EAAE,IAAI,IAAI,EAAE;KACtB,CAAC;IAEF,IAAI,CAAC,SAAS,CAAC,4BAAc,CAAC,YAAY,EAAE,OAAO,CAAC,WAAW,EAAE;QAC/D,UAAU;QACV,KA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