@nebulaos/core 0.1.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 (150) hide show
  1. package/README.md +206 -0
  2. package/dist/__tests__/mocks/mock-provider.d.ts +15 -0
  3. package/dist/__tests__/mocks/mock-provider.js +44 -0
  4. package/dist/agent/Agent.d.ts +96 -0
  5. package/dist/agent/Agent.js +861 -0
  6. package/dist/agent/BaseAgent.d.ts +53 -0
  7. package/dist/agent/BaseAgent.js +126 -0
  8. package/dist/agent/events/events.d.ts +14 -0
  9. package/dist/agent/events/events.js +2 -0
  10. package/dist/agent/events/events.spec.d.ts +1 -0
  11. package/dist/agent/events/events.spec.js +75 -0
  12. package/dist/agent/instruction/index.d.ts +23 -0
  13. package/dist/agent/instruction/index.js +76 -0
  14. package/dist/agent/memory/in-memory.d.ts +24 -0
  15. package/dist/agent/memory/in-memory.js +78 -0
  16. package/dist/agent/memory/index.d.ts +2 -0
  17. package/dist/agent/memory/index.js +18 -0
  18. package/dist/agent/memory/memory.d.ts +43 -0
  19. package/dist/agent/memory/memory.js +7 -0
  20. package/dist/agent/provider/file-parts.spec.d.ts +1 -0
  21. package/dist/agent/provider/file-parts.spec.js +83 -0
  22. package/dist/agent/provider/index.d.ts +130 -0
  23. package/dist/agent/provider/index.js +8 -0
  24. package/dist/agent/skills/index.d.ts +61 -0
  25. package/dist/agent/skills/index.js +9 -0
  26. package/dist/agent/tools/index.d.ts +35 -0
  27. package/dist/agent/tools/index.js +87 -0
  28. package/dist/cost/add-cost.d.ts +10 -0
  29. package/dist/cost/add-cost.js +80 -0
  30. package/dist/cost/add-cost.spec.d.ts +1 -0
  31. package/dist/cost/add-cost.spec.js +36 -0
  32. package/dist/cost/index.d.ts +1 -0
  33. package/dist/cost/index.js +17 -0
  34. package/dist/domain-events/index.d.ts +16 -0
  35. package/dist/domain-events/index.js +38 -0
  36. package/dist/eval/index.d.ts +19 -0
  37. package/dist/eval/index.js +24 -0
  38. package/dist/events/base.d.ts +5 -0
  39. package/dist/events/base.js +2 -0
  40. package/dist/events/schemas.d.ts +3463 -0
  41. package/dist/events/schemas.js +244 -0
  42. package/dist/execution-context/index.d.ts +21 -0
  43. package/dist/execution-context/index.js +17 -0
  44. package/dist/index.cjs +2958 -0
  45. package/dist/index.cjs.map +1 -0
  46. package/dist/index.d.cts +3425 -0
  47. package/dist/index.d.ts +22 -0
  48. package/dist/index.js +53 -0
  49. package/dist/index.js.map +1 -0
  50. package/dist/lgpd/index.d.ts +7 -0
  51. package/dist/lgpd/index.js +21 -0
  52. package/dist/logger/agent-logger.d.ts +16 -0
  53. package/dist/logger/agent-logger.js +110 -0
  54. package/dist/logger/formatters.d.ts +32 -0
  55. package/dist/logger/formatters.js +146 -0
  56. package/dist/logger/index.d.ts +30 -0
  57. package/dist/logger/index.js +88 -0
  58. package/dist/logger/styles.d.ts +46 -0
  59. package/dist/logger/styles.js +53 -0
  60. package/dist/logger/workflow-logger.d.ts +16 -0
  61. package/dist/logger/workflow-logger.js +79 -0
  62. package/dist/multi-agent/agent-as-tool/AgentAsTool.d.ts +16 -0
  63. package/dist/multi-agent/agent-as-tool/AgentAsTool.js +54 -0
  64. package/dist/multi-agent/agent-as-tool/AgentAsTool.spec.d.ts +1 -0
  65. package/dist/multi-agent/agent-as-tool/AgentAsTool.spec.js +76 -0
  66. package/dist/multi-agent/committee-team/CommitteeTeam.d.ts +16 -0
  67. package/dist/multi-agent/committee-team/CommitteeTeam.js +150 -0
  68. package/dist/multi-agent/committee-team/CommitteeTeam.spec.d.ts +1 -0
  69. package/dist/multi-agent/committee-team/CommitteeTeam.spec.js +43 -0
  70. package/dist/multi-agent/handoff-team/HandoffTeam.d.ts +16 -0
  71. package/dist/multi-agent/handoff-team/HandoffTeam.js +185 -0
  72. package/dist/multi-agent/handoff-team/HandoffTeam.spec.d.ts +1 -0
  73. package/dist/multi-agent/handoff-team/HandoffTeam.spec.js +105 -0
  74. package/dist/multi-agent/hierarchical-team/HierarchicalTeam.d.ts +18 -0
  75. package/dist/multi-agent/hierarchical-team/HierarchicalTeam.js +164 -0
  76. package/dist/multi-agent/hierarchical-team/HierarchicalTeam.spec.d.ts +1 -0
  77. package/dist/multi-agent/hierarchical-team/HierarchicalTeam.spec.js +53 -0
  78. package/dist/multi-agent/index.d.ts +10 -0
  79. package/dist/multi-agent/index.js +26 -0
  80. package/dist/multi-agent/pipeline-team/PipelineTeam.d.ts +13 -0
  81. package/dist/multi-agent/pipeline-team/PipelineTeam.js +104 -0
  82. package/dist/multi-agent/pipeline-team/PipelineTeam.spec.d.ts +1 -0
  83. package/dist/multi-agent/pipeline-team/PipelineTeam.spec.js +54 -0
  84. package/dist/multi-agent/router-team/RouterTeam.d.ts +15 -0
  85. package/dist/multi-agent/router-team/RouterTeam.js +153 -0
  86. package/dist/multi-agent/router-team/RouterTeam.spec.d.ts +1 -0
  87. package/dist/multi-agent/router-team/RouterTeam.spec.js +69 -0
  88. package/dist/multi-agent/types/index.d.ts +349 -0
  89. package/dist/multi-agent/types/index.js +79 -0
  90. package/dist/multi-agent/utils/guardrails.d.ts +6 -0
  91. package/dist/multi-agent/utils/guardrails.js +34 -0
  92. package/dist/multi-agent/utils/memory.d.ts +8 -0
  93. package/dist/multi-agent/utils/memory.js +40 -0
  94. package/dist/multi-agent/utils/prompts.d.ts +4 -0
  95. package/dist/multi-agent/utils/prompts.js +25 -0
  96. package/dist/tracing/index.d.ts +89 -0
  97. package/dist/tracing/index.js +188 -0
  98. package/dist/tsup.config.d.ts +2 -0
  99. package/dist/tsup.config.js +11 -0
  100. package/dist/utils/schema-to-zod.d.ts +7 -0
  101. package/dist/utils/schema-to-zod.js +36 -0
  102. package/dist/workflow/Workflow.d.ts +106 -0
  103. package/dist/workflow/Workflow.js +204 -0
  104. package/dist/workflow/adapters.d.ts +61 -0
  105. package/dist/workflow/adapters.js +29 -0
  106. package/dist/workflow/definition/DefinitionBuilder.d.ts +9 -0
  107. package/dist/workflow/definition/DefinitionBuilder.js +91 -0
  108. package/dist/workflow/definition/DefinitionBuilder.spec.d.ts +1 -0
  109. package/dist/workflow/definition/DefinitionBuilder.spec.js +66 -0
  110. package/dist/workflow/definition/DefinitionHasher.d.ts +8 -0
  111. package/dist/workflow/definition/DefinitionHasher.js +11 -0
  112. package/dist/workflow/definition/DefinitionHasher.spec.d.ts +1 -0
  113. package/dist/workflow/definition/DefinitionHasher.spec.js +28 -0
  114. package/dist/workflow/definition/types.d.ts +27 -0
  115. package/dist/workflow/definition/types.js +2 -0
  116. package/dist/workflow/events.d.ts +9 -0
  117. package/dist/workflow/events.js +2 -0
  118. package/dist/workflow/execution/AgentNodeIntegration.spec.d.ts +1 -0
  119. package/dist/workflow/execution/AgentNodeIntegration.spec.js +50 -0
  120. package/dist/workflow/execution/NodeExecutor.d.ts +9 -0
  121. package/dist/workflow/execution/NodeExecutor.js +43 -0
  122. package/dist/workflow/execution/NodeExecutor.spec.d.ts +1 -0
  123. package/dist/workflow/execution/NodeExecutor.spec.js +45 -0
  124. package/dist/workflow/execution/WorkflowEventBus.d.ts +14 -0
  125. package/dist/workflow/execution/WorkflowEventBus.js +42 -0
  126. package/dist/workflow/execution/WorkflowEventBus.spec.d.ts +1 -0
  127. package/dist/workflow/execution/WorkflowEventBus.spec.js +78 -0
  128. package/dist/workflow/execution/WorkflowRunner.d.ts +26 -0
  129. package/dist/workflow/execution/WorkflowRunner.js +212 -0
  130. package/dist/workflow/execution/WorkflowRunner.spec.d.ts +1 -0
  131. package/dist/workflow/execution/WorkflowRunner.spec.js +92 -0
  132. package/dist/workflow/execution/WorkflowTelemetry.d.ts +13 -0
  133. package/dist/workflow/execution/WorkflowTelemetry.js +43 -0
  134. package/dist/workflow/execution/WorkflowTelemetry.spec.d.ts +1 -0
  135. package/dist/workflow/execution/WorkflowTelemetry.spec.js +31 -0
  136. package/dist/workflow/graph/NodeNameRegistry.d.ts +20 -0
  137. package/dist/workflow/graph/NodeNameRegistry.js +21 -0
  138. package/dist/workflow/graph/NodeNameRegistry.spec.d.ts +1 -0
  139. package/dist/workflow/graph/NodeNameRegistry.spec.js +18 -0
  140. package/dist/workflow/graph/WorkflowGraph.d.ts +14 -0
  141. package/dist/workflow/graph/WorkflowGraph.js +23 -0
  142. package/dist/workflow/graph/nodes.d.ts +26 -0
  143. package/dist/workflow/graph/nodes.js +2 -0
  144. package/dist/workflow/queue/WorkflowQueueService.d.ts +22 -0
  145. package/dist/workflow/queue/WorkflowQueueService.js +47 -0
  146. package/dist/workflow/state/WorkflowStateService.d.ts +7 -0
  147. package/dist/workflow/state/WorkflowStateService.js +20 -0
  148. package/dist/workflow/types.d.ts +16 -0
  149. package/dist/workflow/types.js +2 -0
  150. package/package.json +56 -0
package/README.md ADDED
@@ -0,0 +1,206 @@
1
+ # @starya/nebulaos-core
2
+
3
+ The core of NebulaOS for building AI Agents and complex Workflows. This package provides the essential primitives for orchestration, state management, and model abstraction.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @starya/nebulaos-core
9
+ ```
10
+
11
+ ---
12
+
13
+ ## ✨ Features Overview
14
+
15
+ ### 🤖 Agent System
16
+ - ✅ **Multi-Step Reasoning** - Automatic tool calling loops with configurable max steps
17
+ - ✅ **Streaming Support** - Real-time token streaming with `executeStream()`
18
+ - ✅ **Tool Calling** - Function calling with Zod schema validation
19
+ - ✅ **Parallel Tool Execution** - Execute multiple tools simultaneously
20
+ - ✅ **Structured Outputs** - JSON mode with schema validation
21
+ - ✅ **Memory Management** - Pluggable memory implementations (InMemory, Redis, etc.)
22
+ - ✅ **Dynamic Instructions** - Support for async instruction resolution
23
+ - ✅ **Request/Response Interceptors** - Middleware for RAG, sanitization, etc.
24
+ - ✅ **Multimodal Support** - Text + Images (via ContentPart[])
25
+
26
+ ### 🔄 Workflow Orchestration
27
+ - ✅ **Fluent API** - Declarative workflow definition (`.start().step().finish()`)
28
+ - ✅ **Branching & Parallel** - Conditional paths and concurrent execution
29
+ - ✅ **State Persistence** - Save/resume workflow state (requires state store)
30
+ - ✅ **Retry Policies** - Exponential/Linear backoff with configurable attempts
31
+ - ✅ **Input/Output Validation** - Zod schema validation at boundaries
32
+ - ✅ **Queue Integration** - Async workflow execution (requires queue adapter)
33
+ - ✅ **Event-Driven** - Lifecycle events for monitoring and logging
34
+
35
+ ### 📊 Observability & Tracing
36
+ - ✅ **Distributed Tracing** - Automatic trace/span propagation via AsyncLocalStorage
37
+ - ✅ **Event System** - Rich lifecycle events (`execution:start`, `llm:call`, `tool:result`, etc.)
38
+ - ✅ **Correlation IDs** - Track requests across nested operations
39
+ - ✅ **Structured Logging** - Beautiful console logs with ANSI colors and metadata trees
40
+ - ✅ **Log Levels** - Configurable (debug, info, warn, error)
41
+ - ✅ **Custom Loggers** - Implement `ILogger` for Datadog, CloudWatch, etc.
42
+ - ✅ **PII Masking** - GDPR/LGPD compliance with pluggable masking
43
+
44
+ ### 🧪 Testing & Quality
45
+ - ✅ **Provider Compliance Suite** - Reusable test suite for model providers
46
+ - ✅ **Mock Implementations** - MockProvider, MockStateStore for unit tests
47
+ - ✅ **Integration Tests** - Live API tests with real providers
48
+ - ✅ **Type Safety** - Full TypeScript support with strict typing
49
+ - ✅ **Test Coverage** - Comprehensive unit and integration tests
50
+
51
+ ### 🔌 Provider System
52
+ - ✅ **Provider Abstraction** - IModel interface for any LLM (OpenAI, Anthropic, etc.)
53
+ - ✅ **Token Usage Tracking** - Automatic accumulation across multi-step flows
54
+ - ✅ **Streaming Protocol** - Unified chunk types (content_delta, tool_call_start, etc.)
55
+ - ✅ **Error Handling** - Graceful degradation and retry logic
56
+
57
+ ---
58
+
59
+ ## 🆕 Recent Updates
60
+
61
+ ### v0.0.1 - Distributed Tracing & Stream Parity
62
+ - **Distributed Tracing**: Automatic trace/span propagation across Agent → Workflow → Tool chains
63
+ - **executeStream() Parity**: Full feature parity with execute() including token tracking, events, and max steps fallback
64
+ - **Enhanced Logging**: Color-coded terminal output with hierarchical metadata display
65
+ - **Response Interceptors**: Now run only on final responses (not intermediate tool calls)
66
+ - **Test Coverage**: Expanded to 22 unit tests + 7 integration tests
67
+
68
+ ---
69
+
70
+ ## Core Components
71
+
72
+ ### 1. Agent (`Agent`)
73
+
74
+ The main class that manages the lifecycle of AI interaction.
75
+
76
+ ### Key Features
77
+ * **Memory-First**: Every agent requires a memory implementation (e.g., `InMemory`) to maintain context.
78
+ * **Interceptors**: Middleware to modify requests and responses.
79
+ * **Request Interceptors**: Run before each LLM call. Useful for context injection (RAG).
80
+ * **Response Interceptors**: Run **only on the final response** (or when there are no tool calls), ideal for output sanitization and formatting.
81
+ * **Streaming**: Native support for text and tool call streaming.
82
+ * **Observability**: Integrated event-based logging system with PII Masking support (GDPR/LGPD).
83
+
84
+ ### Complete Example
85
+
86
+ ```typescript
87
+ import { Agent, InMemory, Tool, z } from "@starya/nebulaos-core";
88
+ import { OpenAI } from "@starya/nebulaos-openai";
89
+
90
+ // 1. Tools
91
+ const calculator = new Tool({
92
+ id: "calculator",
93
+ description: "Adds two numbers",
94
+ inputSchema: z.object({ a: z.number(), b: z.number() }),
95
+ handler: async (ctx, input) => ({ result: input.a + input.b })
96
+ });
97
+
98
+ // 2. Agent
99
+ const agent = new Agent({
100
+ name: "financial-assistant",
101
+ model: new OpenAI({
102
+ apiKey: process.env.OPENAI_API_KEY!,
103
+ model: "gpt-4o"
104
+ }),
105
+ memory: new InMemory(),
106
+ instructions: "You help with financial calculations.",
107
+ tools: [calculator],
108
+ logLevel: "info", // Detailed console logs
109
+ interceptors: {
110
+ response: [
111
+ async (res) => {
112
+ // Format final output to uppercase (example)
113
+ if (res.content) res.content = res.content.toUpperCase();
114
+ return res;
115
+ }
116
+ ]
117
+ }
118
+ });
119
+
120
+ // 3. Execution
121
+ await agent.addMessage({ role: "user", content: "How much is 10 + 20?" });
122
+ const result = await agent.execute();
123
+ console.log(result.content);
124
+ ```
125
+
126
+ ---
127
+
128
+ ## 🔄 Workflow (`Workflow`)
129
+
130
+ Orchestrator for long-running and complex processes, supporting persistence, retries, and validation.
131
+
132
+ ### Features
133
+ * **Fluent API**: Declarative definition (`.start().step().branch().finish()`).
134
+ * **State Persistence**: Saves the state of each step (requires `stateStore`).
135
+ * **Resilience**: Configurable Retry Policies (Exponential, Linear).
136
+ * **Type-Safe**: Input and output validation with Zod.
137
+
138
+ ### Workflow Example
139
+
140
+ ```typescript
141
+ import { Workflow, MockStateStore } from "@starya/nebulaos-core";
142
+ import { z } from "zod";
143
+
144
+ const workflow = new Workflow({
145
+ id: "order-processing",
146
+ stateStore: new MockStateStore(), // Or real implementation (Redis/Postgres)
147
+ retryPolicy: {
148
+ maxAttempts: 3,
149
+ backoff: "exponential",
150
+ initialDelay: 1000
151
+ }
152
+ })
153
+ .start(async ({ input }) => {
154
+ console.log("Validating order", input);
155
+ return input;
156
+ })
157
+ .step("payment", async ({ input }) => {
158
+ // Payment logic
159
+ return { status: "paid", id: input.id };
160
+ })
161
+ .finish(async ({ input }) => {
162
+ return { message: `Order ${input.id} processed successfully` };
163
+ });
164
+
165
+ // Execution
166
+ const result = await workflow.run({ id: 123, total: 500 });
167
+ ```
168
+
169
+ ---
170
+
171
+ ## 🛡️ Logging & Observability
172
+
173
+ The Core emits rich events during execution (`execution:start`, `llm:call`, `tool:result`).
174
+
175
+ ### Configuration
176
+ The default logger (`ConsoleLogger`) can be configured via `logLevel`. For production, you can implement the `ILogger` interface to send logs to Datadog, CloudWatch, etc.
177
+
178
+ ### PII Masking (Privacy)
179
+ Protect sensitive data in logs by configuring a `piiMasker`.
180
+
181
+ ```typescript
182
+ const agent = new Agent({
183
+ // ...
184
+ piiMasker: {
185
+ mask: (text) => text.replace(/\d{3}\.\d{3}\.\d{3}-\d{2}/g, "***") // Example mask
186
+ }
187
+ });
188
+ ```
189
+
190
+ ---
191
+
192
+ ## 🧪 Testing & Compliance
193
+
194
+ ### Package Tests
195
+ ```bash
196
+ pnpm test
197
+ ```
198
+
199
+ ### Provider Compliance Suite
200
+ If you are creating a new Provider (e.g., Anthropic), use the compliance suite to ensure full compatibility.
201
+
202
+ ```typescript
203
+ import { runProviderComplianceTests } from "@starya/nebulaos-core/test-utils";
204
+
205
+ runProviderComplianceTests(() => new MyNewProvider(...), { runLiveTests: true });
206
+ ```
@@ -0,0 +1,15 @@
1
+ import { IModel, Message, ProviderResponse, StreamChunk, ToolDefinitionForLLM, GenerateOptions } from "../../agent/provider";
2
+ export declare class MockProvider implements IModel {
3
+ providerName: string;
4
+ modelName: string;
5
+ responses: ProviderResponse[];
6
+ streams: StreamChunk[][];
7
+ calls: {
8
+ messages: Message[];
9
+ tools?: ToolDefinitionForLLM[];
10
+ }[];
11
+ enqueueResponse(response: Partial<ProviderResponse>): void;
12
+ enqueueStream(chunks: StreamChunk[]): void;
13
+ generate(messages: Message[], tools?: ToolDefinitionForLLM[], options?: GenerateOptions): Promise<ProviderResponse>;
14
+ generateStream(messages: Message[], tools?: ToolDefinitionForLLM[], options?: GenerateOptions): AsyncGenerator<StreamChunk>;
15
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MockProvider = void 0;
4
+ class MockProvider {
5
+ providerName = "mock";
6
+ modelName = "mock-model";
7
+ responses = [];
8
+ streams = [];
9
+ calls = [];
10
+ enqueueResponse(response) {
11
+ this.responses.push({
12
+ content: "",
13
+ usage: { promptTokens: 10, completionTokens: 10, totalTokens: 20 },
14
+ finishReason: "stop",
15
+ ...response
16
+ });
17
+ }
18
+ enqueueStream(chunks) {
19
+ this.streams.push(chunks);
20
+ }
21
+ async generate(messages, tools, options) {
22
+ this.calls.push({ messages, tools });
23
+ const response = this.responses.shift();
24
+ if (!response) {
25
+ // Default response if none enqueued
26
+ return {
27
+ content: "Mock default response",
28
+ finishReason: "stop",
29
+ usage: { promptTokens: 0, completionTokens: 0, totalTokens: 0 }
30
+ };
31
+ }
32
+ return response;
33
+ }
34
+ async *generateStream(messages, tools, options) {
35
+ this.calls.push({ messages, tools });
36
+ const chunks = this.streams.shift();
37
+ if (!chunks)
38
+ throw new Error("MockProvider: No stream enqueued");
39
+ for (const chunk of chunks) {
40
+ yield chunk;
41
+ }
42
+ }
43
+ }
44
+ exports.MockProvider = MockProvider;
@@ -0,0 +1,96 @@
1
+ import { IModel, Message, ToolCall, StreamChunk, ProviderResponse, ContentPart } from "./provider/index.js";
2
+ import { IMemory, MemoryExecutionContext } from "./memory/index.js";
3
+ import { Tool, ToolExecution } from "./tools/index.js";
4
+ import { ISkill } from "./skills/index.js";
5
+ import { IPIIMasker } from "../lgpd/index.js";
6
+ import { ILogger, LogLevel } from "../logger/index.js";
7
+ import { BaseAgent } from "./BaseAgent.js";
8
+ import type { IHttpClient } from "@nebulaos/types";
9
+ export interface IInstruction {
10
+ resolve(): Promise<string>;
11
+ }
12
+ export type AgentInstruction = string | IInstruction;
13
+ export interface AgentRequestContext {
14
+ messages: Message[];
15
+ tools: Tool[];
16
+ }
17
+ export type RequestInterceptor = (context: AgentRequestContext) => Promise<AgentRequestContext>;
18
+ export type ResponseInterceptor = (response: ProviderResponse) => Promise<ProviderResponse>;
19
+ export type AgentConfig = {
20
+ id: string;
21
+ name: string;
22
+ model: IModel;
23
+ memory: IMemory;
24
+ instructions: AgentInstruction;
25
+ tools?: Tool[];
26
+ skills?: ISkill[];
27
+ maxSteps?: number;
28
+ piiMasker?: IPIIMasker;
29
+ interceptors?: {
30
+ request?: RequestInterceptor[];
31
+ response?: ResponseInterceptor[];
32
+ };
33
+ logger?: ILogger;
34
+ logLevel?: LogLevel;
35
+ };
36
+ export type AgentExecuteOptions = {
37
+ responseFormat?: {
38
+ type: "json";
39
+ schema?: Record<string, any>;
40
+ };
41
+ maxSteps?: number;
42
+ disableTools?: boolean;
43
+ executionId?: string;
44
+ /** Memory partition key. When provided, memory operations are scoped to this key. */
45
+ memoryKey?: string;
46
+ };
47
+ export type AgentResult = {
48
+ content: any;
49
+ toolExecutions: ToolExecution[];
50
+ toolCalls?: ToolCall[];
51
+ llmCalls: number;
52
+ totalDurationMs: number;
53
+ truncated: boolean;
54
+ };
55
+ export type AgentStreamChunk = StreamChunk | {
56
+ type: "tool_result";
57
+ toolCallId: string;
58
+ result: any;
59
+ } | {
60
+ type: "error";
61
+ error: any;
62
+ };
63
+ export declare class Agent extends BaseAgent {
64
+ config: AgentConfig;
65
+ private resolvedInstructions?;
66
+ private requestInterceptors;
67
+ private responseInterceptors;
68
+ private loggerAdapter;
69
+ private skillsInitialized;
70
+ private httpClient?;
71
+ constructor(config: AgentConfig);
72
+ /**
73
+ * Sets the HTTP client for tool execution context.
74
+ * This is typically called by the client package with InstrumentedHttpClient.
75
+ */
76
+ setHttpClient(client: IHttpClient): void;
77
+ private initializeSkills;
78
+ private resolveInstructions;
79
+ private isInstruction;
80
+ clearInstructionsCache(): void;
81
+ addMessage(message: Message, ctx?: MemoryExecutionContext): Promise<void>;
82
+ private getMessagesWithContext;
83
+ execute(options?: AgentExecuteOptions): Promise<AgentResult>;
84
+ execute(input?: string, options?: AgentExecuteOptions): Promise<AgentResult>;
85
+ execute(input?: ContentPart[], options?: AgentExecuteOptions): Promise<AgentResult>;
86
+ executeStream(options?: AgentExecuteOptions): AsyncGenerator<AgentStreamChunk>;
87
+ private executeToolCall;
88
+ private safeParseJson;
89
+ private validateMessagesForModel;
90
+ private mimeTypeMatches;
91
+ /**
92
+ * Estimates the decoded byte length of a base64 string without decoding it.
93
+ */
94
+ private estimateBase64Bytes;
95
+ private finishResult;
96
+ }