@jterrazz/intelligence 1.2.0 → 1.3.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.
package/README.md CHANGED
@@ -30,7 +30,7 @@ Get your first agent running in under a minute. This example uses a preset to cr
30
30
 
31
31
  ```typescript
32
32
  import {
33
- ChatAgentAdapter,
33
+ AutonomousAgentAdapter,
34
34
  OpenRouterAdapter,
35
35
  SystemPromptAdapter,
36
36
  PROMPT_LIBRARY,
@@ -43,7 +43,7 @@ const model = new OpenRouterAdapter({
43
43
  });
44
44
 
45
45
  // 2. Create an agent using a preset prompt
46
- const agent = new ChatAgentAdapter('discord-bot', {
46
+ const agent = new AutonomousAgentAdapter('discord-bot', {
47
47
  model,
48
48
  systemPrompt: new SystemPromptAdapter(PROMPT_LIBRARY.PRESETS.COMMUNITY_ANIMATOR),
49
49
  });
@@ -104,7 +104,7 @@ The adapter handles errors gracefully and integrates seamlessly with the agent,
104
104
  The library is built on a hexagonal architecture.
105
105
 
106
106
  - **Ports (`/ports`)**: Define the contracts (interfaces) for core components like `Agent`, `Model`, and `Tool`.
107
- - **Adapters (`/adapters`)**: Provide concrete implementations. For example, `ChatAgentAdapter` is an adapter that uses LangChain, and `OpenRouterAdapter` is an adapter for the OpenRouter API.
107
+ - **Adapters (`/adapters`)**: Provide concrete implementations. For example, `AutonomousAgentAdapter` is an adapter that uses LangChain, and `OpenRouterAdapter` is an adapter for the OpenRouter API.
108
108
 
109
109
  This separation of concerns means you can easily create your own adapters to support different models or services without changing the application's core logic.
110
110
 
@@ -124,7 +124,7 @@ This recipe creates an agent that acts as an expert software engineer, providing
124
124
 
125
125
  ```typescript
126
126
  import {
127
- ChatAgentAdapter,
127
+ AutonomousAgentAdapter,
128
128
  OpenRouterAdapter,
129
129
  SystemPromptAdapter,
130
130
  UserPromptAdapter,
@@ -153,7 +153,7 @@ const userPrompt = new UserPromptAdapter([
153
153
  ]);
154
154
 
155
155
  // 3. Configure and run the agent
156
- const agent = new ChatAgentAdapter('code-reviewer', {
156
+ const agent = new AutonomousAgentAdapter('code-reviewer', {
157
157
  model,
158
158
  systemPrompt,
159
159
  });
@@ -163,13 +163,13 @@ const response = await agent.run(userPrompt);
163
163
  console.log(response);
164
164
  ```
165
165
 
166
- ### Recipe: Simple Text Processor (QueryAgent)
166
+ ### Recipe: Simple Text Processor (BasicAgent)
167
167
 
168
- This example shows how to use the simpler `QueryAgentAdapter` for one-shot responses without tools.
168
+ This example shows how to use the simpler `BasicAgentAdapter` for one-shot responses without tools.
169
169
 
170
170
  ```typescript
171
171
  import {
172
- QueryAgentAdapter,
172
+ BasicAgentAdapter,
173
173
  OpenRouterAdapter,
174
174
  SystemPromptAdapter,
175
175
  UserPromptAdapter,
@@ -189,8 +189,8 @@ const systemPrompt = new SystemPromptAdapter(
189
189
  'You are a helpful assistant that improves text clarity and grammar.',
190
190
  );
191
191
 
192
- // 2. Create a query agent (no tools needed)
193
- const agent = new QueryAgentAdapter('text-processor', {
192
+ // 2. Create a basic agent (no tools needed)
193
+ const agent = new BasicAgentAdapter('text-processor', {
194
194
  model,
195
195
  systemPrompt,
196
196
  });
@@ -205,13 +205,13 @@ console.log(response);
205
205
  // Expected output: A grammatically corrected and improved version of the text
206
206
  ```
207
207
 
208
- ### Recipe: Structured Data Extraction (QueryAgent with Schema)
208
+ ### Recipe: Structured Data Extraction (BasicAgent with Schema)
209
209
 
210
- This example shows how to use `QueryAgentAdapter` with schema parsing for structured responses.
210
+ This example shows how to use `BasicAgentAdapter` with schema parsing for structured responses.
211
211
 
212
212
  ```typescript
213
213
  import {
214
- QueryAgentAdapter,
214
+ BasicAgentAdapter,
215
215
  OpenRouterAdapter,
216
216
  SystemPromptAdapter,
217
217
  UserPromptAdapter,
@@ -240,8 +240,8 @@ const systemPrompt = new SystemPromptAdapter(
240
240
  'You extract contact information from text and return it as JSON.',
241
241
  );
242
242
 
243
- // 3. Create a query agent with schema parsing
244
- const agent = new QueryAgentAdapter('contact-extractor', {
243
+ // 3. Create a basic agent with schema parsing
244
+ const agent = new BasicAgentAdapter('contact-extractor', {
245
245
  model,
246
246
  schema: extractionSchema,
247
247
  systemPrompt,
@@ -266,7 +266,7 @@ This example shows how to give an agent a tool and have it respond to a user que
266
266
 
267
267
  ```typescript
268
268
  import {
269
- ChatAgentAdapter,
269
+ AutonomousAgentAdapter,
270
270
  OpenRouterAdapter,
271
271
  SafeToolAdapter,
272
272
  SystemPromptAdapter,
@@ -291,7 +291,7 @@ const weatherTool = new SafeToolAdapter(
291
291
  );
292
292
 
293
293
  // 2. Create an agent that knows how to use tools
294
- const agent = new ChatAgentAdapter('weather-bot', {
294
+ const agent = new AutonomousAgentAdapter('weather-bot', {
295
295
  model,
296
296
  systemPrompt: new SystemPromptAdapter(PROMPT_LIBRARY.PRESETS.EMPATHETIC_SUPPORT_AGENT), // A good general-purpose preset
297
297
  tools: [weatherTool], // Pass the tool instance directly
@@ -310,16 +310,16 @@ console.log(response);
310
310
 
311
311
  ### Core Components
312
312
 
313
- | Class | Description |
314
- | ------------------------ | -------------------------------------------------------------------------- |
315
- | `ChatAgentAdapter` | The main agent implementation. Runs prompts and coordinates tools. |
316
- | `QueryAgentAdapter` | A simpler agent for one-shot responses without tools or complex logic. |
317
- | `OpenRouterModelAdapter` | An adapter for connecting to any model on the OpenRouter platform. |
318
- | `SafeToolAdapter` | A type-safe wrapper for creating tools with validation and error handling. |
319
- | `SystemPromptAdapter` | A simple adapter to generate a system prompt string from a prompt array. |
320
- | `UserPromptAdapter` | A simple adapter to generate a user prompt string from a prompt array. |
321
- | `AIResponseParser` | A utility to parse a model's string output into a typed object using Zod. |
322
- | `PROMPT_LIBRARY` | A frozen object containing the entire composable prompt library. |
313
+ | Class | Description |
314
+ | ------------------------ | ------------------------------------------------------------------------------- |
315
+ | `AutonomousAgentAdapter` | The main agent implementation. Runs prompts and coordinates tools autonomously. |
316
+ | `BasicAgentAdapter` | A basic agent for one-shot responses without tools or complex logic. |
317
+ | `OpenRouterModelAdapter` | An adapter for connecting to any model on the OpenRouter platform. |
318
+ | `SafeToolAdapter` | A type-safe wrapper for creating tools with validation and error handling. |
319
+ | `SystemPromptAdapter` | A simple adapter to generate a system prompt string from a prompt array. |
320
+ | `UserPromptAdapter` | A simple adapter to generate a user prompt string from a prompt array. |
321
+ | `AIResponseParser` | A utility to parse a model's string output into a typed object using Zod. |
322
+ | `PROMPT_LIBRARY` | A frozen object containing the entire composable prompt library. |
323
323
 
324
324
  ## Contributing
325
325
 
@@ -5,7 +5,7 @@ import type { ModelPort } from '../../ports/model.port.js';
5
5
  import type { PromptPort } from '../../ports/prompt.port.js';
6
6
  import type { ToolPort } from '../../ports/tool.port.js';
7
7
  import type { SystemPromptAdapter } from '../prompts/system-prompt.adapter.js';
8
- export interface ChatAgentOptions<T = unknown> {
8
+ export interface AutonomousAgentOptions<T = unknown> {
9
9
  logger?: LoggerPort;
10
10
  model: ModelPort;
11
11
  schema?: z.ZodSchema<T>;
@@ -14,13 +14,13 @@ export interface ChatAgentOptions<T = unknown> {
14
14
  verbose?: boolean;
15
15
  }
16
16
  /**
17
- * An advanced agent that uses tools and a structured prompt to engage in conversational chat.
17
+ * An autonomous agent that uses tools and a structured prompt to accomplish tasks.
18
18
  * It can decide whether to respond or remain silent and supports schema-validated responses.
19
19
  */
20
- export declare class ChatAgentAdapter<T = unknown> implements AgentPort {
20
+ export declare class AutonomousAgentAdapter<T = unknown> implements AgentPort {
21
21
  readonly name: string;
22
22
  private readonly options;
23
- constructor(name: string, options: ChatAgentOptions<T>);
23
+ constructor(name: string, options: AutonomousAgentOptions<T>);
24
24
  run(userPrompt?: PromptPort): Promise<null | string>;
25
25
  private createExecutor;
26
26
  private parseAgentOutput;
@@ -162,18 +162,18 @@ import { AgentExecutor, createStructuredChatAgent } from 'langchain/agents';
162
162
  import { AIResponseParser } from '../utils/ai-response-parser.js';
163
163
  var SYSTEM_PROMPT_TEMPLATE = '\n<OBJECTIVE>\n{mission_prompt}\n</OBJECTIVE>\n\n<OUTPUT_FORMAT>\nCRITICAL: The format instructions in this section are the ONLY valid way to structure your response. Your entire response MUST be a single JSON markdown code block. Any formatting guidelines within the <OBJECTIVE> section apply ONLY to the content inside the "RESPOND:" part of your final "action_input".\n\nREQUIRED: You have two ways to respond:\n\n1. **Call a tool** to gather information. For this, you MUST output a JSON blob with the tool\'s name and its input.\n *Valid tool names are: {tool_names}*\n ```json\n {{\n "action": "tool_name_to_use",\n "action_input": "the input for the tool, or an empty object {{}} if no input is needed"\n }}\n ```\n\n2. **Provide the Final Answer** once you have enough information. For this, you MUST output a JSON blob with the "Final Answer" action.\n The "action_input" for a "Final Answer" MUST be a string that begins with either "RESPOND: " for a message or "SILENT: " for no message. This prefix is a literal part of the output string and MUST NOT be omitted.\n - To send a message:\n ```json\n {{\n "action": "Final Answer",\n "action_input": "RESPOND: <your response message>"\n }}\n ```\n - To stay silent:\n ```json\n {{\n "action": "Final Answer",\n "action_input": "SILENT: <your reason for staying silent>"\n }}\n ```\n\n YOU MUST ALWAYS INCLUDE "RESPOND:" OR "SILENT:" IN YOUR FINAL ANSWER\'S "action_input". FAILURE TO DO SO WILL CAUSE AN ERROR.\n</OUTPUT_FORMAT>\n\n<EXECUTION_CONTEXT>\nThis is internal data for your reference.\n\n<TOOLS>\n{tools}\n</TOOLS>\n\n<WORKING_MEMORY>\nThis is your internal thought process and previous tool usage.\n{agent_scratchpad}\n</WORKING_MEMORY>\n</EXECUTION_CONTEXT>\n';
164
164
  /**
165
- * An advanced agent that uses tools and a structured prompt to engage in conversational chat.
165
+ * An autonomous agent that uses tools and a structured prompt to accomplish tasks.
166
166
  * It can decide whether to respond or remain silent and supports schema-validated responses.
167
- */ export var ChatAgentAdapter = /*#__PURE__*/ function() {
167
+ */ export var AutonomousAgentAdapter = /*#__PURE__*/ function() {
168
168
  "use strict";
169
- function ChatAgentAdapter(name, options) {
170
- _class_call_check(this, ChatAgentAdapter);
169
+ function AutonomousAgentAdapter(name, options) {
170
+ _class_call_check(this, AutonomousAgentAdapter);
171
171
  _define_property(this, "name", void 0);
172
172
  _define_property(this, "options", void 0);
173
173
  this.name = name;
174
174
  this.options = options;
175
175
  }
176
- _create_class(ChatAgentAdapter, [
176
+ _create_class(AutonomousAgentAdapter, [
177
177
  {
178
178
  key: "run",
179
179
  value: function run(userPrompt) {
@@ -355,7 +355,7 @@ var SYSTEM_PROMPT_TEMPLATE = '\n<OBJECTIVE>\n{mission_prompt}\n</OBJECTIVE>\n\n<
355
355
  }
356
356
  }
357
357
  ]);
358
- return ChatAgentAdapter;
358
+ return AutonomousAgentAdapter;
359
359
  }();
360
360
 
361
- //# sourceMappingURL=chat-agent.adapter.js.map
361
+ //# sourceMappingURL=autonomous-agent.adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/adapters/agents/autonomous-agent.adapter.ts"],"sourcesContent":["import { type LoggerPort } from '@jterrazz/logger';\nimport { ChatPromptTemplate } from '@langchain/core/prompts';\nimport { AgentExecutor, createStructuredChatAgent } from 'langchain/agents';\nimport { type z } from 'zod/v4';\n\nimport { type AgentPort } from '../../ports/agent.port.js';\nimport type { ModelPort } from '../../ports/model.port.js';\nimport type { PromptPort } from '../../ports/prompt.port.js';\nimport type { ToolPort } from '../../ports/tool.port.js';\n\nimport { AIResponseParser } from '../utils/ai-response-parser.js';\n\nimport type { SystemPromptAdapter } from '../prompts/system-prompt.adapter.js';\n\nexport interface AutonomousAgentOptions<T = unknown> {\n logger?: LoggerPort;\n model: ModelPort;\n schema?: z.ZodSchema<T>;\n systemPrompt: SystemPromptAdapter;\n tools: ToolPort[];\n verbose?: boolean;\n}\n\nconst SYSTEM_PROMPT_TEMPLATE = `\n<OBJECTIVE>\n{mission_prompt}\n</OBJECTIVE>\n\n<OUTPUT_FORMAT>\nCRITICAL: The format instructions in this section are the ONLY valid way to structure your response. Your entire response MUST be a single JSON markdown code block. Any formatting guidelines within the <OBJECTIVE> section apply ONLY to the content inside the \"RESPOND:\" part of your final \"action_input\".\n\nREQUIRED: You have two ways to respond:\n\n1. **Call a tool** to gather information. For this, you MUST output a JSON blob with the tool's name and its input.\n *Valid tool names are: {tool_names}*\n \\`\\`\\`json\n {{\n \"action\": \"tool_name_to_use\",\n \"action_input\": \"the input for the tool, or an empty object {{}} if no input is needed\"\n }}\n \\`\\`\\`\n\n2. **Provide the Final Answer** once you have enough information. For this, you MUST output a JSON blob with the \"Final Answer\" action.\n The \"action_input\" for a \"Final Answer\" MUST be a string that begins with either \"RESPOND: \" for a message or \"SILENT: \" for no message. This prefix is a literal part of the output string and MUST NOT be omitted.\n - To send a message:\n \\`\\`\\`json\n {{\n \"action\": \"Final Answer\",\n \"action_input\": \"RESPOND: <your response message>\"\n }}\n \\`\\`\\`\n - To stay silent:\n \\`\\`\\`json\n {{\n \"action\": \"Final Answer\",\n \"action_input\": \"SILENT: <your reason for staying silent>\"\n }}\n \\`\\`\\`\n\n YOU MUST ALWAYS INCLUDE \"RESPOND:\" OR \"SILENT:\" IN YOUR FINAL ANSWER'S \"action_input\". FAILURE TO DO SO WILL CAUSE AN ERROR.\n</OUTPUT_FORMAT>\n\n<EXECUTION_CONTEXT>\nThis is internal data for your reference.\n\n<TOOLS>\n{tools}\n</TOOLS>\n\n<WORKING_MEMORY>\nThis is your internal thought process and previous tool usage.\n{agent_scratchpad}\n</WORKING_MEMORY>\n</EXECUTION_CONTEXT>\n`;\n\n/**\n * An autonomous agent that uses tools and a structured prompt to accomplish tasks.\n * It can decide whether to respond or remain silent and supports schema-validated responses.\n */\nexport class AutonomousAgentAdapter<T = unknown> implements AgentPort {\n constructor(\n public readonly name: string,\n private readonly options: AutonomousAgentOptions<T>,\n ) {}\n\n async run(userPrompt?: PromptPort): Promise<null | string> {\n this.options.logger?.debug(`[${this.name}] Starting chat execution.`);\n\n try {\n const executor = await this.createExecutor();\n const userInput = this.resolveUserInput(userPrompt);\n\n const result = await executor.invoke({ input: userInput });\n\n this.options.logger?.debug(`[${this.name}] Agent execution completed.`, {\n hasOutput: 'output' in result,\n });\n\n if (!result || typeof result.output !== 'string') {\n throw new Error('Agent returned an invalid result structure.');\n }\n\n const agentResponse = this.parseAgentOutput(result.output);\n\n if (!agentResponse) {\n return null;\n }\n\n if (!agentResponse.shouldRespond) {\n this.options.logger?.info(`[${this.name}] Agent chose to remain silent.`, {\n reason: agentResponse.reason,\n });\n return null;\n }\n\n const message = agentResponse.message ?? '';\n\n if (this.options.schema) {\n this.validateResponseContent(message, this.options.schema);\n this.options.logger?.info(\n `[${this.name}] Execution finished; response content validated.`,\n );\n } else {\n this.options.logger?.info(`[${this.name}] Execution finished.`);\n }\n\n return message;\n } catch (error) {\n this.options.logger?.error(`[${this.name}] Chat execution failed.`, {\n error: error instanceof Error ? error.message : 'Unknown error',\n });\n return null;\n }\n }\n\n private async createExecutor(): Promise<AgentExecutor> {\n const model = this.options.model.getModel();\n const tools = this.options.tools.map((tool) => tool.getDynamicTool());\n\n const prompt = ChatPromptTemplate.fromMessages([\n [\n 'system',\n SYSTEM_PROMPT_TEMPLATE.replace(\n '{mission_prompt}',\n this.options.systemPrompt.generate(),\n ),\n ],\n ['human', '{input}'],\n ]);\n\n const agent = await createStructuredChatAgent({\n llm: model,\n prompt,\n tools,\n });\n\n return AgentExecutor.fromAgentAndTools({\n agent,\n tools,\n verbose: this.options.verbose,\n });\n }\n\n private parseAgentOutput(output: string): null | {\n message?: string;\n reason?: string;\n shouldRespond: boolean;\n } {\n const text = output.trim();\n\n const respondMatch = text.match(/^RESPOND:\\s*([\\s\\S]+)$/i);\n if (respondMatch) {\n return { message: respondMatch[1].trim(), shouldRespond: true };\n }\n\n const silentMatch = text.match(/^SILENT:\\s*([\\s\\S]+)$/i);\n if (silentMatch) {\n return { reason: silentMatch[1].trim(), shouldRespond: false };\n }\n\n this.options.logger?.error(\n `[${this.name}] Agent output was missing 'RESPOND:' or 'SILENT:' prefix.`,\n { rawOutput: output },\n );\n\n return null;\n }\n\n private resolveUserInput(userPrompt?: PromptPort): string {\n if (userPrompt) {\n return userPrompt.generate();\n }\n return 'Proceed with your instructions.';\n }\n\n private validateResponseContent<TResponse>(\n content: string,\n schema: z.ZodSchema<TResponse>,\n ): void {\n try {\n new AIResponseParser(schema).parse(content);\n } catch (error) {\n this.options.logger?.error(\n `[${this.name}] Failed to validate response content against schema.`,\n {\n error: error instanceof Error ? error.message : 'Unknown error',\n rawContent: content,\n },\n );\n throw new Error('Invalid response content from model.');\n }\n }\n}\n"],"names":["ChatPromptTemplate","AgentExecutor","createStructuredChatAgent","AIResponseParser","SYSTEM_PROMPT_TEMPLATE","AutonomousAgentAdapter","name","options","run","userPrompt","executor","userInput","result","agentResponse","message","error","logger","debug","createExecutor","resolveUserInput","invoke","input","hasOutput","output","Error","parseAgentOutput","shouldRespond","info","reason","schema","validateResponseContent","model","tools","prompt","agent","getModel","map","tool","getDynamicTool","fromMessages","replace","systemPrompt","generate","llm","fromAgentAndTools","verbose","text","trim","respondMatch","match","silentMatch","rawOutput","content","parse","rawContent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAASA,kBAAkB,QAAQ,0BAA0B;AAC7D,SAASC,aAAa,EAAEC,yBAAyB,QAAQ,mBAAmB;AAQ5E,SAASC,gBAAgB,QAAQ,iCAAiC;AAalE,IAAMC,yBAA0B;AAqDhC;;;CAGC,GACD,OAAO,IAAA,AAAMC,uCAAN;;aAAMA,uBAEL,AAAgBC,IAAY,EAC5B,AAAiBC,OAAkC;gCAH9CF;;;aAEWC,OAAAA;aACCC,UAAAA;;kBAHZF;;YAMHG,KAAAA;mBAAN,SAAMA,IAAIC,UAAuB;;wBAC7B,sBAQI,uBALMC,UACAC,WAEAC,QAUAC,eAOF,uBAMYA,wBAAVC,SAIF,uBAIA,uBAICC,OACL;;;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E;gBAEA,IAAMwB,cAAcJ,KAAKG,KAAK,CAAC;gBAC/B,IAAIC,aAAa;oBACb,OAAO;wBAAEtB,QAAQsB,WAAW,CAAC,EAAE,CAACH,IAAI;wBAAIrB,eAAe;oBAAM;gBACjE;iBAEA,uBAAA,IAAI,CAACnB,OAAO,CAACS,MAAM,cAAnB,2CAAA,qBAAqBD,KAAK,CACtB,AAAC,IAAa,OAAV,IAAI,CAACT,IAAI,EAAC,+DACd;oBAAE6C,WAAW5B;gBAAO;gBAGxB,OAAO;YACX;;;YAEQJ,KAAAA;mBAAR,SAAQA,iBAAiBV,UAAuB;gBAC5C,IAAIA,YAAY;oBACZ,OAAOA,WAAWiC,QAAQ;gBAC9B;gBACA,OAAO;YACX;;;YAEQZ,KAAAA;mBAAR,SAAQA,wBACJsB,OAAe,EACfvB,MAA8B;gBAE9B,IAAI;oBACA,IAAI1B,iBAAiB0B,QAAQwB,KAAK,CAACD;gBACvC,EAAE,OAAOrC,OAAO;wBACZ;qBAAA,uBAAA,IAAI,CAACR,OAAO,CAACS,MAAM,cAAnB,2CAAA,qBAAqBD,KAAK,CACtB,AAAC,IAAa,OAAV,IAAI,CAACT,IAAI,EAAC,0DACd;wBACIS,OAAOA,AAAK,YAALA,OAAiBS,SAAQT,MAAMD,OAAO,GAAG;wBAChDwC,YAAYF;oBAChB;oBAEJ,MAAM,IAAI5B,MAAM;gBACpB;YACJ;;;WApISnB;IAqIZ"}
@@ -0,0 +1,26 @@
1
+ import { type LoggerPort } from '@jterrazz/logger';
2
+ import { type z } from 'zod/v4';
3
+ import { type AgentPort } from '../../ports/agent.port.js';
4
+ import type { ModelPort } from '../../ports/model.port.js';
5
+ import type { PromptPort } from '../../ports/prompt.port.js';
6
+ import type { SystemPromptAdapter } from '../prompts/system-prompt.adapter.js';
7
+ export interface BasicAgentOptions<T = string> {
8
+ logger?: LoggerPort;
9
+ model: ModelPort;
10
+ schema?: z.ZodSchema<T>;
11
+ systemPrompt: SystemPromptAdapter;
12
+ verbose?: boolean;
13
+ }
14
+ /**
15
+ * A basic agent for direct, one-shot interactions with a model.
16
+ * It supports optional response parsing against a Zod schema but does not use tools.
17
+ */
18
+ export declare class BasicAgentAdapter<T = string> implements AgentPort {
19
+ readonly name: string;
20
+ private readonly options;
21
+ constructor(name: string, options: BasicAgentOptions<T>);
22
+ run(userPrompt?: PromptPort): Promise<null | string>;
23
+ private invokeModel;
24
+ private parseResponse;
25
+ private resolveUserInput;
26
+ }
@@ -0,0 +1,303 @@
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
+ try {
3
+ var info = gen[key](arg);
4
+ var value = info.value;
5
+ } catch (error) {
6
+ reject(error);
7
+ return;
8
+ }
9
+ if (info.done) {
10
+ resolve(value);
11
+ } else {
12
+ Promise.resolve(value).then(_next, _throw);
13
+ }
14
+ }
15
+ function _async_to_generator(fn) {
16
+ return function() {
17
+ var self = this, args = arguments;
18
+ return new Promise(function(resolve, reject) {
19
+ var gen = fn.apply(self, args);
20
+ function _next(value) {
21
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
+ }
23
+ function _throw(err) {
24
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
+ }
26
+ _next(undefined);
27
+ });
28
+ };
29
+ }
30
+ function _class_call_check(instance, Constructor) {
31
+ if (!(instance instanceof Constructor)) {
32
+ throw new TypeError("Cannot call a class as a function");
33
+ }
34
+ }
35
+ function _defineProperties(target, props) {
36
+ for(var i = 0; i < props.length; i++){
37
+ var descriptor = props[i];
38
+ descriptor.enumerable = descriptor.enumerable || false;
39
+ descriptor.configurable = true;
40
+ if ("value" in descriptor) descriptor.writable = true;
41
+ Object.defineProperty(target, descriptor.key, descriptor);
42
+ }
43
+ }
44
+ function _create_class(Constructor, protoProps, staticProps) {
45
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
46
+ if (staticProps) _defineProperties(Constructor, staticProps);
47
+ return Constructor;
48
+ }
49
+ function _define_property(obj, key, value) {
50
+ if (key in obj) {
51
+ Object.defineProperty(obj, key, {
52
+ value: value,
53
+ enumerable: true,
54
+ configurable: true,
55
+ writable: true
56
+ });
57
+ } else {
58
+ obj[key] = value;
59
+ }
60
+ return obj;
61
+ }
62
+ function _instanceof(left, right) {
63
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
64
+ return !!right[Symbol.hasInstance](left);
65
+ } else {
66
+ return left instanceof right;
67
+ }
68
+ }
69
+ function _ts_generator(thisArg, body) {
70
+ var f, y, t, _ = {
71
+ label: 0,
72
+ sent: function() {
73
+ if (t[0] & 1) throw t[1];
74
+ return t[1];
75
+ },
76
+ trys: [],
77
+ ops: []
78
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
79
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
80
+ return this;
81
+ }), g;
82
+ function verb(n) {
83
+ return function(v) {
84
+ return step([
85
+ n,
86
+ v
87
+ ]);
88
+ };
89
+ }
90
+ function step(op) {
91
+ if (f) throw new TypeError("Generator is already executing.");
92
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
93
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
94
+ if (y = 0, t) op = [
95
+ op[0] & 2,
96
+ t.value
97
+ ];
98
+ switch(op[0]){
99
+ case 0:
100
+ case 1:
101
+ t = op;
102
+ break;
103
+ case 4:
104
+ _.label++;
105
+ return {
106
+ value: op[1],
107
+ done: false
108
+ };
109
+ case 5:
110
+ _.label++;
111
+ y = op[1];
112
+ op = [
113
+ 0
114
+ ];
115
+ continue;
116
+ case 7:
117
+ op = _.ops.pop();
118
+ _.trys.pop();
119
+ continue;
120
+ default:
121
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
122
+ _ = 0;
123
+ continue;
124
+ }
125
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
126
+ _.label = op[1];
127
+ break;
128
+ }
129
+ if (op[0] === 6 && _.label < t[1]) {
130
+ _.label = t[1];
131
+ t = op;
132
+ break;
133
+ }
134
+ if (t && _.label < t[2]) {
135
+ _.label = t[2];
136
+ _.ops.push(op);
137
+ break;
138
+ }
139
+ if (t[2]) _.ops.pop();
140
+ _.trys.pop();
141
+ continue;
142
+ }
143
+ op = body.call(thisArg, _);
144
+ } catch (e) {
145
+ op = [
146
+ 6,
147
+ e
148
+ ];
149
+ y = 0;
150
+ } finally{
151
+ f = t = 0;
152
+ }
153
+ if (op[0] & 5) throw op[1];
154
+ return {
155
+ value: op[0] ? op[1] : void 0,
156
+ done: true
157
+ };
158
+ }
159
+ }
160
+ import { AIResponseParser } from '../utils/ai-response-parser.js';
161
+ /**
162
+ * A basic agent for direct, one-shot interactions with a model.
163
+ * It supports optional response parsing against a Zod schema but does not use tools.
164
+ */ export var BasicAgentAdapter = /*#__PURE__*/ function() {
165
+ "use strict";
166
+ function BasicAgentAdapter(name, options) {
167
+ _class_call_check(this, BasicAgentAdapter);
168
+ _define_property(this, "name", void 0);
169
+ _define_property(this, "options", void 0);
170
+ this.name = name;
171
+ this.options = options;
172
+ }
173
+ _create_class(BasicAgentAdapter, [
174
+ {
175
+ key: "run",
176
+ value: function run(userPrompt) {
177
+ return _async_to_generator(function() {
178
+ var _this_options_logger, content, _this_options_logger1, _this_options_logger2, error, _this_options_logger3;
179
+ return _ts_generator(this, function(_state) {
180
+ switch(_state.label){
181
+ case 0:
182
+ (_this_options_logger = this.options.logger) === null || _this_options_logger === void 0 ? void 0 : _this_options_logger.debug("[".concat(this.name, "] Starting query execution."));
183
+ _state.label = 1;
184
+ case 1:
185
+ _state.trys.push([
186
+ 1,
187
+ 3,
188
+ ,
189
+ 4
190
+ ]);
191
+ return [
192
+ 4,
193
+ this.invokeModel(userPrompt)
194
+ ];
195
+ case 2:
196
+ content = _state.sent();
197
+ if (this.options.schema) {
198
+ ;
199
+ this.parseResponse(content, this.options.schema);
200
+ (_this_options_logger1 = this.options.logger) === null || _this_options_logger1 === void 0 ? void 0 : _this_options_logger1.info("[".concat(this.name, "] Execution finished and response parsed."));
201
+ } else {
202
+ ;
203
+ (_this_options_logger2 = this.options.logger) === null || _this_options_logger2 === void 0 ? void 0 : _this_options_logger2.info("[".concat(this.name, "] Execution finished."));
204
+ }
205
+ return [
206
+ 2,
207
+ content
208
+ ];
209
+ case 3:
210
+ error = _state.sent();
211
+ (_this_options_logger3 = this.options.logger) === null || _this_options_logger3 === void 0 ? void 0 : _this_options_logger3.error("[".concat(this.name, "] Execution failed."), {
212
+ error: _instanceof(error, Error) ? error.message : 'Unknown error'
213
+ });
214
+ return [
215
+ 2,
216
+ null
217
+ ];
218
+ case 4:
219
+ return [
220
+ 2
221
+ ];
222
+ }
223
+ });
224
+ }).call(this);
225
+ }
226
+ },
227
+ {
228
+ key: "invokeModel",
229
+ value: function invokeModel(userPrompt) {
230
+ return _async_to_generator(function() {
231
+ var _this_options_logger, userInput, systemMessage, messages, _this_options_logger1, response, content;
232
+ return _ts_generator(this, function(_state) {
233
+ switch(_state.label){
234
+ case 0:
235
+ userInput = this.resolveUserInput(userPrompt);
236
+ systemMessage = this.options.systemPrompt.generate();
237
+ messages = [
238
+ {
239
+ content: systemMessage,
240
+ role: 'system'
241
+ },
242
+ {
243
+ content: userInput,
244
+ role: 'user'
245
+ }
246
+ ];
247
+ (_this_options_logger = this.options.logger) === null || _this_options_logger === void 0 ? void 0 : _this_options_logger.debug("[".concat(this.name, "] Invoking model..."), {
248
+ hasSchema: !!this.options.schema
249
+ });
250
+ if (this.options.verbose) {
251
+ ;
252
+ (_this_options_logger1 = this.options.logger) === null || _this_options_logger1 === void 0 ? void 0 : _this_options_logger1.info("[".concat(this.name, "] Sending messages to model..."), {
253
+ messages: messages
254
+ });
255
+ }
256
+ return [
257
+ 4,
258
+ this.options.model.getModel().invoke(messages)
259
+ ];
260
+ case 1:
261
+ response = _state.sent();
262
+ content = response.content;
263
+ if (typeof content !== 'string') {
264
+ throw new Error('Model returned a non-string content type.');
265
+ }
266
+ return [
267
+ 2,
268
+ content
269
+ ];
270
+ }
271
+ });
272
+ }).call(this);
273
+ }
274
+ },
275
+ {
276
+ key: "parseResponse",
277
+ value: function parseResponse(content, schema) {
278
+ try {
279
+ new AIResponseParser(schema).parse(content);
280
+ } catch (error) {
281
+ var _this_options_logger;
282
+ (_this_options_logger = this.options.logger) === null || _this_options_logger === void 0 ? void 0 : _this_options_logger.error("[".concat(this.name, "] Failed to parse model response."), {
283
+ error: _instanceof(error, Error) ? error.message : 'Unknown error',
284
+ rawContent: content
285
+ });
286
+ throw new Error('Invalid response format from model.');
287
+ }
288
+ }
289
+ },
290
+ {
291
+ key: "resolveUserInput",
292
+ value: function resolveUserInput(userPrompt) {
293
+ if (userPrompt) {
294
+ return userPrompt.generate();
295
+ }
296
+ return 'Proceed with your instructions.';
297
+ }
298
+ }
299
+ ]);
300
+ return BasicAgentAdapter;
301
+ }();
302
+
303
+ //# sourceMappingURL=basic-agent.adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/adapters/agents/basic-agent.adapter.ts"],"sourcesContent":["import { type LoggerPort } from '@jterrazz/logger';\nimport { type z } from 'zod/v4';\n\nimport { type AgentPort } from '../../ports/agent.port.js';\nimport type { ModelPort } from '../../ports/model.port.js';\nimport type { PromptPort } from '../../ports/prompt.port.js';\n\nimport { AIResponseParser } from '../utils/ai-response-parser.js';\n\nimport type { SystemPromptAdapter } from '../prompts/system-prompt.adapter.js';\n\nexport interface BasicAgentOptions<T = string> {\n logger?: LoggerPort;\n model: ModelPort;\n schema?: z.ZodSchema<T>;\n systemPrompt: SystemPromptAdapter;\n verbose?: boolean;\n}\n\n/**\n * A basic agent for direct, one-shot interactions with a model.\n * It supports optional response parsing against a Zod schema but does not use tools.\n */\nexport class BasicAgentAdapter<T = string> implements AgentPort {\n constructor(\n public readonly name: string,\n private readonly options: BasicAgentOptions<T>,\n ) {}\n\n async run(userPrompt?: PromptPort): Promise<null | string> {\n this.options.logger?.debug(`[${this.name}] Starting query execution.`);\n\n try {\n const content = await this.invokeModel(userPrompt);\n\n if (this.options.schema) {\n this.parseResponse(content, this.options.schema);\n this.options.logger?.info(`[${this.name}] Execution finished and response parsed.`);\n } else {\n this.options.logger?.info(`[${this.name}] Execution finished.`);\n }\n\n return content;\n } catch (error) {\n this.options.logger?.error(`[${this.name}] Execution failed.`, {\n error: error instanceof Error ? error.message : 'Unknown error',\n });\n return null;\n }\n }\n\n private async invokeModel(userPrompt?: PromptPort): Promise<string> {\n const userInput = this.resolveUserInput(userPrompt);\n const systemMessage = this.options.systemPrompt.generate();\n\n const messages = [\n { content: systemMessage, role: 'system' as const },\n { content: userInput, role: 'user' as const },\n ];\n\n this.options.logger?.debug(`[${this.name}] Invoking model...`, {\n hasSchema: !!this.options.schema,\n });\n\n if (this.options.verbose) {\n this.options.logger?.info(`[${this.name}] Sending messages to model...`, {\n messages,\n });\n }\n\n const response = await this.options.model.getModel().invoke(messages);\n const { content } = response;\n\n if (typeof content !== 'string') {\n throw new Error('Model returned a non-string content type.');\n }\n\n return content;\n }\n\n private parseResponse<TResponse>(content: string, schema: z.ZodSchema<TResponse>): void {\n try {\n new AIResponseParser(schema).parse(content);\n } catch (error) {\n this.options.logger?.error(`[${this.name}] Failed to parse model response.`, {\n error: error instanceof Error ? error.message : 'Unknown error',\n rawContent: content,\n });\n throw new Error('Invalid response format from model.');\n }\n }\n\n private resolveUserInput(userPrompt?: PromptPort): string {\n if (userPrompt) {\n return userPrompt.generate();\n }\n return 'Proceed with your instructions.';\n }\n}\n"],"names":["AIResponseParser","BasicAgentAdapter","name","options","run","userPrompt","content","error","logger","debug","invokeModel","schema","parseResponse","info","Error","message","userInput","systemMessage","messages","response","resolveUserInput","systemPrompt","generate","role","hasSchema","verbose","model","getModel","invoke","parse","rawContent"],"mappings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A,qBAAqBD,KAAK,CAAC,AAAC,IAAa,OAAV,IAAI,CAACL,IAAI,EAAC,sCAAoC;wBACzEK,OAAOA,AAAK,YAALA,OAAiBO,SAAQP,MAAMQ,OAAO,GAAG;wBAChDe,YAAYxB;oBAChB;oBACA,MAAM,IAAIQ,MAAM;gBACpB;YACJ;;;YAEQM,KAAAA;mBAAR,SAAQA,iBAAiBf,UAAuB;gBAC5C,IAAIA,YAAY;oBACZ,OAAOA,WAAWiB,QAAQ;gBAC9B;gBACA,OAAO;YACX;;;WA1ESrB;IA2EZ"}
@@ -4,7 +4,7 @@ import { type AgentPort } from '../../ports/agent.port.js';
4
4
  import type { ModelPort } from '../../ports/model.port.js';
5
5
  import type { PromptPort } from '../../ports/prompt.port.js';
6
6
  import type { SystemPromptAdapter } from '../prompts/system-prompt.adapter.js';
7
- export interface QueryAgentOptions<T = string> {
7
+ export interface BasicAgentOptions<T = string> {
8
8
  logger?: LoggerPort;
9
9
  model: ModelPort;
10
10
  schema?: z.ZodSchema<T>;
@@ -12,13 +12,13 @@ export interface QueryAgentOptions<T = string> {
12
12
  verbose?: boolean;
13
13
  }
14
14
  /**
15
- * A simple agent for direct, one-shot interactions with a model.
15
+ * A basic agent for direct, one-shot interactions with a model.
16
16
  * It supports optional response parsing against a Zod schema but does not use tools.
17
17
  */
18
- export declare class QueryAgentAdapter<T = string> implements AgentPort {
18
+ export declare class BasicAgentAdapter<T = string> implements AgentPort {
19
19
  readonly name: string;
20
20
  private readonly options;
21
- constructor(name: string, options: QueryAgentOptions<T>);
21
+ constructor(name: string, options: BasicAgentOptions<T>);
22
22
  run(userPrompt?: PromptPort): Promise<null | string>;
23
23
  private invokeModel;
24
24
  private parseResponse;
@@ -159,18 +159,18 @@ function _ts_generator(thisArg, body) {
159
159
  }
160
160
  import { AIResponseParser } from '../utils/ai-response-parser.js';
161
161
  /**
162
- * A simple agent for direct, one-shot interactions with a model.
162
+ * A basic agent for direct, one-shot interactions with a model.
163
163
  * It supports optional response parsing against a Zod schema but does not use tools.
164
- */ export var QueryAgentAdapter = /*#__PURE__*/ function() {
164
+ */ export var BasicAgentAdapter = /*#__PURE__*/ function() {
165
165
  "use strict";
166
- function QueryAgentAdapter(name, options) {
167
- _class_call_check(this, QueryAgentAdapter);
166
+ function BasicAgentAdapter(name, options) {
167
+ _class_call_check(this, BasicAgentAdapter);
168
168
  _define_property(this, "name", void 0);
169
169
  _define_property(this, "options", void 0);
170
170
  this.name = name;
171
171
  this.options = options;
172
172
  }
173
- _create_class(QueryAgentAdapter, [
173
+ _create_class(BasicAgentAdapter, [
174
174
  {
175
175
  key: "run",
176
176
  value: function run(userPrompt) {
@@ -297,7 +297,7 @@ import { AIResponseParser } from '../utils/ai-response-parser.js';
297
297
  }
298
298
  }
299
299
  ]);
300
- return QueryAgentAdapter;
300
+ return BasicAgentAdapter;
301
301
  }();
302
302
 
303
303
  //# sourceMappingURL=query-agent.adapter.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapters/agents/query-agent.adapter.ts"],"sourcesContent":["import { type LoggerPort } from '@jterrazz/logger';\nimport { type z } from 'zod/v4';\n\nimport { type AgentPort } from '../../ports/agent.port.js';\nimport type { ModelPort } from '../../ports/model.port.js';\nimport type { PromptPort } from '../../ports/prompt.port.js';\n\nimport { AIResponseParser } from '../utils/ai-response-parser.js';\n\nimport type { SystemPromptAdapter } from '../prompts/system-prompt.adapter.js';\n\nexport interface QueryAgentOptions<T = string> {\n logger?: LoggerPort;\n model: ModelPort;\n schema?: z.ZodSchema<T>;\n systemPrompt: SystemPromptAdapter;\n verbose?: boolean;\n}\n\n/**\n * A simple agent for direct, one-shot interactions with a model.\n * It supports optional response parsing against a Zod schema but does not use tools.\n */\nexport class QueryAgentAdapter<T = string> implements AgentPort {\n constructor(\n public readonly name: string,\n private readonly options: QueryAgentOptions<T>,\n ) {}\n\n async run(userPrompt?: PromptPort): Promise<null | string> {\n this.options.logger?.debug(`[${this.name}] Starting query execution.`);\n\n try {\n const content = await this.invokeModel(userPrompt);\n\n if (this.options.schema) {\n this.parseResponse(content, this.options.schema);\n this.options.logger?.info(`[${this.name}] Execution finished and response parsed.`);\n } else {\n this.options.logger?.info(`[${this.name}] Execution finished.`);\n }\n\n return content;\n } catch (error) {\n this.options.logger?.error(`[${this.name}] Execution failed.`, {\n error: error instanceof Error ? error.message : 'Unknown error',\n });\n return null;\n }\n }\n\n private async invokeModel(userPrompt?: PromptPort): Promise<string> {\n const userInput = this.resolveUserInput(userPrompt);\n const systemMessage = this.options.systemPrompt.generate();\n\n const messages = [\n { content: systemMessage, role: 'system' as const },\n { content: userInput, role: 'user' as const },\n ];\n\n this.options.logger?.debug(`[${this.name}] Invoking model...`, {\n hasSchema: !!this.options.schema,\n });\n\n if (this.options.verbose) {\n this.options.logger?.info(`[${this.name}] Sending messages to model...`, {\n messages,\n });\n }\n\n const response = await this.options.model.getModel().invoke(messages);\n const { content } = response;\n\n if (typeof content !== 'string') {\n throw new Error('Model returned a non-string content type.');\n }\n\n return content;\n }\n\n private parseResponse<TResponse>(content: string, schema: z.ZodSchema<TResponse>): void {\n try {\n new AIResponseParser(schema).parse(content);\n } catch (error) {\n this.options.logger?.error(`[${this.name}] Failed to parse model response.`, {\n error: error instanceof Error ? error.message : 'Unknown error',\n rawContent: content,\n });\n throw new Error('Invalid response format from model.');\n }\n }\n\n private resolveUserInput(userPrompt?: PromptPort): string {\n if (userPrompt) {\n return userPrompt.generate();\n }\n return 'Proceed with your instructions.';\n }\n}\n"],"names":["AIResponseParser","QueryAgentAdapter","name","options","run","userPrompt","content","error","logger","debug","invokeModel","schema","parseResponse","info","Error","message","userInput","systemMessage","messages","response","resolveUserInput","systemPrompt","generate","role","hasSchema","verbose","model","getModel","invoke","parse","rawContent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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YAAYxB;oBAChB;oBACA,MAAM,IAAIQ,MAAM;gBACpB;YACJ;;;YAEQM,KAAAA;mBAAR,SAAQA,iBAAiBf,UAAuB;gBAC5C,IAAIA,YAAY;oBACZ,OAAOA,WAAWiB,QAAQ;gBAC9B;gBACA,OAAO;YACX;;;WA1ESrB;IA2EZ"}
1
+ {"version":3,"sources":["../../../src/adapters/agents/query-agent.adapter.ts"],"sourcesContent":["import { type LoggerPort } from '@jterrazz/logger';\nimport { type z } from 'zod/v4';\n\nimport { type AgentPort } from '../../ports/agent.port.js';\nimport type { ModelPort } from '../../ports/model.port.js';\nimport type { PromptPort } from '../../ports/prompt.port.js';\n\nimport { AIResponseParser } from '../utils/ai-response-parser.js';\n\nimport type { SystemPromptAdapter } from '../prompts/system-prompt.adapter.js';\n\nexport interface BasicAgentOptions<T = string> {\n logger?: LoggerPort;\n model: ModelPort;\n schema?: z.ZodSchema<T>;\n systemPrompt: SystemPromptAdapter;\n verbose?: boolean;\n}\n\n/**\n * A basic agent for direct, one-shot interactions with a model.\n * It supports optional response parsing against a Zod schema but does not use tools.\n */\nexport class BasicAgentAdapter<T = string> implements AgentPort {\n constructor(\n public readonly name: string,\n private readonly options: BasicAgentOptions<T>,\n ) {}\n\n async run(userPrompt?: PromptPort): Promise<null | string> {\n this.options.logger?.debug(`[${this.name}] Starting query execution.`);\n\n try {\n const content = await this.invokeModel(userPrompt);\n\n if (this.options.schema) {\n this.parseResponse(content, this.options.schema);\n this.options.logger?.info(`[${this.name}] Execution finished and response parsed.`);\n } else {\n this.options.logger?.info(`[${this.name}] Execution finished.`);\n }\n\n return content;\n } catch (error) {\n this.options.logger?.error(`[${this.name}] Execution failed.`, {\n error: error instanceof Error ? error.message : 'Unknown error',\n });\n return null;\n }\n }\n\n private async invokeModel(userPrompt?: PromptPort): Promise<string> {\n const userInput = this.resolveUserInput(userPrompt);\n const systemMessage = this.options.systemPrompt.generate();\n\n const messages = [\n { content: systemMessage, role: 'system' as const },\n { content: userInput, role: 'user' as const },\n ];\n\n this.options.logger?.debug(`[${this.name}] Invoking model...`, {\n hasSchema: !!this.options.schema,\n });\n\n if (this.options.verbose) {\n this.options.logger?.info(`[${this.name}] Sending messages to model...`, {\n messages,\n });\n }\n\n const response = await this.options.model.getModel().invoke(messages);\n const { content } = response;\n\n if (typeof content !== 'string') {\n throw new Error('Model returned a non-string content type.');\n }\n\n return content;\n }\n\n private parseResponse<TResponse>(content: string, schema: z.ZodSchema<TResponse>): void {\n try {\n new AIResponseParser(schema).parse(content);\n } catch (error) {\n this.options.logger?.error(`[${this.name}] Failed to parse model response.`, {\n error: error instanceof Error ? error.message : 'Unknown error',\n rawContent: content,\n });\n throw new Error('Invalid response format from model.');\n }\n }\n\n private resolveUserInput(userPrompt?: PromptPort): string {\n if (userPrompt) {\n return userPrompt.generate();\n }\n return 'Proceed with your instructions.';\n }\n}\n"],"names":["AIResponseParser","BasicAgentAdapter","name","options","run","userPrompt","content","error","logger","debug","invokeModel","schema","parseResponse","info","Error","message","userInput","systemMessage","messages","response","resolveUserInput","systemPrompt","generate","role","hasSchema","verbose","model","getModel","invoke","parse","rawContent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,SAASA,gBAAgB,QAAQ,iCAAiC;AAYlE;;;CAGC,GACD,OAAO,IAAA,AAAMC,kCAAN;;aAAMA,kBAEL,AAAgBC,IAAY,EAC5B,AAAiBC,OAA6B;gCAHzCF;;;aAEWC,OAAAA;aACCC,UAAAA;;kBAHZF;;YAMHG,KAAAA;mBAAN,SAAMA,IAAIC,UAAuB;;wBAC7B,sBAGUC,SAIF,uBAEA,uBAICC,OACL;;;;iCAdJ,uBAAA,IAAI,CAACJ,OAAO,CAACK,MAAM,cAAnB,2CAAA,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B,WAAW,CAAC,CAAC,IAAI,CAACrB,OAAO,CAACQ,MAAM;gCACpC;gCAEA,IAAI,IAAI,CAACR,OAAO,CAACsB,OAAO,EAAE;;qCACtB,wBAAA,IAAI,CAACtB,OAAO,CAACK,MAAM,cAAnB,4CAAA,sBAAqBK,IAAI,CAAC,AAAC,IAAa,OAAV,IAAI,CAACX,IAAI,EAAC,mCAAiC;wCACrEgB,UAAAA;oCACJ;gCACJ;gCAEiB;;oCAAM,IAAI,CAACf,OAAO,CAACuB,KAAK,CAACC,QAAQ,GAAGC,MAAM,CAACV;;;gCAAtDC,WAAW;gCACTb,UAAYa,SAAZb;gCAER,IAAI,OAAOA,YAAY,UAAU;oCAC7B,MAAM,IAAIQ,MAAM;gCACpB;gCAEA;;oCAAOR;;;;gBACX;;;;YAEQM,KAAAA;mBAAR,SAAQA,cAAyBN,OAAe,EAAEK,MAA8B;gBAC5E,IAAI;oBACA,IAAIX,iBAAiBW,QAAQkB,KAAK,CAACvB;gBACvC,EAAE,OAAOC,OAAO;wBACZ;qBAAA,uBAAA,IAAI,CAACJ,OAAO,CAACK,MAAM,cAAnB,2CAAA,qBAAqBD,KAAK,CAAC,AAAC,IAAa,OAAV,IAAI,CAACL,IAAI,EAAC,sCAAoC;wBACzEK,OAAOA,AAAK,YAALA,OAAiBO,SAAQP,MAAMQ,OAAO,GAAG;wBAChDe,YAAYxB;oBAChB;oBACA,MAAM,IAAIQ,MAAM;gBACpB;YACJ;;;YAEQM,KAAAA;mBAAR,SAAQA,iBAAiBf,UAAuB;gBAC5C,IAAIA,YAAY;oBACZ,OAAOA,WAAWiB,QAAQ;gBAC9B;gBACA,OAAO;YACX;;;WA1ESrB;IA2EZ"}
package/dist/index.cjs CHANGED
@@ -629,17 +629,17 @@ function _ts_generator$2(thisArg, body) {
629
629
  }
630
630
  var SYSTEM_PROMPT_TEMPLATE = '\n<OBJECTIVE>\n{mission_prompt}\n</OBJECTIVE>\n\n<OUTPUT_FORMAT>\nCRITICAL: The format instructions in this section are the ONLY valid way to structure your response. Your entire response MUST be a single JSON markdown code block. Any formatting guidelines within the <OBJECTIVE> section apply ONLY to the content inside the "RESPOND:" part of your final "action_input".\n\nREQUIRED: You have two ways to respond:\n\n1. **Call a tool** to gather information. For this, you MUST output a JSON blob with the tool\'s name and its input.\n *Valid tool names are: {tool_names}*\n ```json\n {{\n "action": "tool_name_to_use",\n "action_input": "the input for the tool, or an empty object {{}} if no input is needed"\n }}\n ```\n\n2. **Provide the Final Answer** once you have enough information. For this, you MUST output a JSON blob with the "Final Answer" action.\n The "action_input" for a "Final Answer" MUST be a string that begins with either "RESPOND: " for a message or "SILENT: " for no message. This prefix is a literal part of the output string and MUST NOT be omitted.\n - To send a message:\n ```json\n {{\n "action": "Final Answer",\n "action_input": "RESPOND: <your response message>"\n }}\n ```\n - To stay silent:\n ```json\n {{\n "action": "Final Answer",\n "action_input": "SILENT: <your reason for staying silent>"\n }}\n ```\n\n YOU MUST ALWAYS INCLUDE "RESPOND:" OR "SILENT:" IN YOUR FINAL ANSWER\'S "action_input". FAILURE TO DO SO WILL CAUSE AN ERROR.\n</OUTPUT_FORMAT>\n\n<EXECUTION_CONTEXT>\nThis is internal data for your reference.\n\n<TOOLS>\n{tools}\n</TOOLS>\n\n<WORKING_MEMORY>\nThis is your internal thought process and previous tool usage.\n{agent_scratchpad}\n</WORKING_MEMORY>\n</EXECUTION_CONTEXT>\n';
631
631
  /**
632
- * An advanced agent that uses tools and a structured prompt to engage in conversational chat.
632
+ * An autonomous agent that uses tools and a structured prompt to accomplish tasks.
633
633
  * It can decide whether to respond or remain silent and supports schema-validated responses.
634
- */ var ChatAgentAdapter = /*#__PURE__*/ function() {
635
- function ChatAgentAdapter(name, options) {
636
- _class_call_check$5(this, ChatAgentAdapter);
634
+ */ var AutonomousAgentAdapter = /*#__PURE__*/ function() {
635
+ function AutonomousAgentAdapter(name, options) {
636
+ _class_call_check$5(this, AutonomousAgentAdapter);
637
637
  _define_property$5(this, "name", void 0);
638
638
  _define_property$5(this, "options", void 0);
639
639
  this.name = name;
640
640
  this.options = options;
641
641
  }
642
- _create_class$5(ChatAgentAdapter, [
642
+ _create_class$5(AutonomousAgentAdapter, [
643
643
  {
644
644
  key: "run",
645
645
  value: function run(userPrompt) {
@@ -818,7 +818,7 @@ var SYSTEM_PROMPT_TEMPLATE = '\n<OBJECTIVE>\n{mission_prompt}\n</OBJECTIVE>\n\n<
818
818
  }
819
819
  }
820
820
  ]);
821
- return ChatAgentAdapter;
821
+ return AutonomousAgentAdapter;
822
822
  }();
823
823
 
824
824
  function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
@@ -980,17 +980,17 @@ function _ts_generator$1(thisArg, body) {
980
980
  }
981
981
  }
982
982
  /**
983
- * A simple agent for direct, one-shot interactions with a model.
983
+ * A basic agent for direct, one-shot interactions with a model.
984
984
  * It supports optional response parsing against a Zod schema but does not use tools.
985
- */ var QueryAgentAdapter = /*#__PURE__*/ function() {
986
- function QueryAgentAdapter(name, options) {
987
- _class_call_check$4(this, QueryAgentAdapter);
985
+ */ var BasicAgentAdapter = /*#__PURE__*/ function() {
986
+ function BasicAgentAdapter(name, options) {
987
+ _class_call_check$4(this, BasicAgentAdapter);
988
988
  _define_property$4(this, "name", void 0);
989
989
  _define_property$4(this, "options", void 0);
990
990
  this.name = name;
991
991
  this.options = options;
992
992
  }
993
- _create_class$4(QueryAgentAdapter, [
993
+ _create_class$4(BasicAgentAdapter, [
994
994
  {
995
995
  key: "run",
996
996
  value: function run(userPrompt) {
@@ -1114,7 +1114,7 @@ function _ts_generator$1(thisArg, body) {
1114
1114
  }
1115
1115
  }
1116
1116
  ]);
1117
- return QueryAgentAdapter;
1117
+ return BasicAgentAdapter;
1118
1118
  }();
1119
1119
 
1120
1120
  function _class_call_check$3(instance, Constructor) {
@@ -1720,10 +1720,10 @@ function _ts_generator(thisArg, body) {
1720
1720
  }();
1721
1721
 
1722
1722
  exports.AIResponseParser = AIResponseParser;
1723
- exports.ChatAgentAdapter = ChatAgentAdapter;
1723
+ exports.AutonomousAgentAdapter = AutonomousAgentAdapter;
1724
+ exports.BasicAgentAdapter = BasicAgentAdapter;
1724
1725
  exports.OpenRouterAdapter = OpenRouterModelAdapter;
1725
1726
  exports.PROMPT_LIBRARY = PROMPT_LIBRARY;
1726
- exports.QueryAgentAdapter = QueryAgentAdapter;
1727
1727
  exports.SafeToolAdapter = SafeToolAdapter;
1728
1728
  exports.SystemPromptAdapter = SystemPromptAdapter;
1729
1729
  exports.UserPromptAdapter = UserPromptAdapter;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { ChatAgentAdapter } from './adapters/agents/chat-agent.adapter.js';
2
- export { QueryAgentAdapter } from './adapters/agents/query-agent.adapter.js';
1
+ export { AutonomousAgentAdapter } from './adapters/agents/autonomous-agent.adapter.js';
2
+ export { BasicAgentAdapter } from './adapters/agents/basic-agent.adapter.js';
3
3
  export { OpenRouterModelAdapter as OpenRouterAdapter } from './adapters/models/openrouter-model.adapter.js';
4
4
  export { PROMPT_LIBRARY } from './adapters/prompts/library/index.js';
5
5
  export { SystemPromptAdapter } from './adapters/prompts/system-prompt.adapter.js';
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- export { ChatAgentAdapter } from './adapters/agents/chat-agent.adapter.js';
2
- export { QueryAgentAdapter } from './adapters/agents/query-agent.adapter.js';
1
+ export { AutonomousAgentAdapter } from './adapters/agents/autonomous-agent.adapter.js';
2
+ export { BasicAgentAdapter } from './adapters/agents/basic-agent.adapter.js';
3
3
  export { OpenRouterModelAdapter as OpenRouterAdapter } from './adapters/models/openrouter-model.adapter.js';
4
4
  export { PROMPT_LIBRARY } from './adapters/prompts/library/index.js';
5
5
  export { SystemPromptAdapter } from './adapters/prompts/system-prompt.adapter.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { ChatAgentAdapter } from './adapters/agents/chat-agent.adapter.js';\nexport { QueryAgentAdapter } from './adapters/agents/query-agent.adapter.js';\nexport { OpenRouterModelAdapter as OpenRouterAdapter } from './adapters/models/openrouter-model.adapter.js';\nexport { PROMPT_LIBRARY } from './adapters/prompts/library/index.js';\nexport { SystemPromptAdapter } from './adapters/prompts/system-prompt.adapter.js';\nexport { UserPromptAdapter } from './adapters/prompts/user-prompt.adapter.js';\nexport { SafeToolAdapter } from './adapters/tools/safe-tool.adapter.js';\nexport { AIResponseParser } from './adapters/utils/ai-response-parser.js';\n\nexport * from './ports/agent.port.js';\nexport * from './ports/model.port.js';\nexport * from './ports/prompt.port.js';\nexport * from './ports/tool.port.js';\n"],"names":["ChatAgentAdapter","QueryAgentAdapter","OpenRouterModelAdapter","OpenRouterAdapter","PROMPT_LIBRARY","SystemPromptAdapter","UserPromptAdapter","SafeToolAdapter","AIResponseParser"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,0CAA0C;AAC3E,SAASC,iBAAiB,QAAQ,2CAA2C;AAC7E,SAASC,0BAA0BC,iBAAiB,QAAQ,gDAAgD;AAC5G,SAASC,cAAc,QAAQ,sCAAsC;AACrE,SAASC,mBAAmB,QAAQ,8CAA8C;AAClF,SAASC,iBAAiB,QAAQ,4CAA4C;AAC9E,SAASC,eAAe,QAAQ,wCAAwC;AACxE,SAASC,gBAAgB,QAAQ,yCAAyC;AAE1E,cAAc,wBAAwB;AACtC,cAAc,wBAAwB;AACtC,cAAc,yBAAyB;AACvC,cAAc,uBAAuB"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { AutonomousAgentAdapter } from './adapters/agents/autonomous-agent.adapter.js';\nexport { BasicAgentAdapter } from './adapters/agents/basic-agent.adapter.js';\nexport { OpenRouterModelAdapter as OpenRouterAdapter } from './adapters/models/openrouter-model.adapter.js';\nexport { PROMPT_LIBRARY } from './adapters/prompts/library/index.js';\nexport { SystemPromptAdapter } from './adapters/prompts/system-prompt.adapter.js';\nexport { UserPromptAdapter } from './adapters/prompts/user-prompt.adapter.js';\nexport { SafeToolAdapter } from './adapters/tools/safe-tool.adapter.js';\nexport { AIResponseParser } from './adapters/utils/ai-response-parser.js';\n\nexport * from './ports/agent.port.js';\nexport * from './ports/model.port.js';\nexport * from './ports/prompt.port.js';\nexport * from './ports/tool.port.js';\n"],"names":["AutonomousAgentAdapter","BasicAgentAdapter","OpenRouterModelAdapter","OpenRouterAdapter","PROMPT_LIBRARY","SystemPromptAdapter","UserPromptAdapter","SafeToolAdapter","AIResponseParser"],"mappings":"AAAA,SAASA,sBAAsB,QAAQ,gDAAgD;AACvF,SAASC,iBAAiB,QAAQ,2CAA2C;AAC7E,SAASC,0BAA0BC,iBAAiB,QAAQ,gDAAgD;AAC5G,SAASC,cAAc,QAAQ,sCAAsC;AACrE,SAASC,mBAAmB,QAAQ,8CAA8C;AAClF,SAASC,iBAAiB,QAAQ,4CAA4C;AAC9E,SAASC,eAAe,QAAQ,wCAAwC;AACxE,SAASC,gBAAgB,QAAQ,yCAAyC;AAE1E,cAAc,wBAAwB;AACtC,cAAc,wBAAwB;AACtC,cAAc,yBAAyB;AACvC,cAAc,uBAAuB"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jterrazz/intelligence",
3
3
  "author": "Jean-Baptiste Terrazzoni <contact@jterrazz.com>",
4
- "version": "1.2.0",
4
+ "version": "1.3.0",
5
5
  "exports": {
6
6
  ".": {
7
7
  "require": "./dist/index.cjs",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/adapters/agents/chat-agent.adapter.ts"],"sourcesContent":["import { type LoggerPort } from '@jterrazz/logger';\nimport { ChatPromptTemplate } from '@langchain/core/prompts';\nimport { AgentExecutor, createStructuredChatAgent } from 'langchain/agents';\nimport { type z } from 'zod/v4';\n\nimport { type AgentPort } from '../../ports/agent.port.js';\nimport type { ModelPort } from '../../ports/model.port.js';\nimport type { PromptPort } from '../../ports/prompt.port.js';\nimport type { ToolPort } from '../../ports/tool.port.js';\n\nimport { AIResponseParser } from '../utils/ai-response-parser.js';\n\nimport type { SystemPromptAdapter } from '../prompts/system-prompt.adapter.js';\n\nexport interface ChatAgentOptions<T = unknown> {\n logger?: LoggerPort;\n model: ModelPort;\n schema?: z.ZodSchema<T>;\n systemPrompt: SystemPromptAdapter;\n tools: ToolPort[];\n verbose?: boolean;\n}\n\nconst SYSTEM_PROMPT_TEMPLATE = `\n<OBJECTIVE>\n{mission_prompt}\n</OBJECTIVE>\n\n<OUTPUT_FORMAT>\nCRITICAL: The format instructions in this section are the ONLY valid way to structure your response. Your entire response MUST be a single JSON markdown code block. Any formatting guidelines within the <OBJECTIVE> section apply ONLY to the content inside the \"RESPOND:\" part of your final \"action_input\".\n\nREQUIRED: You have two ways to respond:\n\n1. **Call a tool** to gather information. For this, you MUST output a JSON blob with the tool's name and its input.\n *Valid tool names are: {tool_names}*\n \\`\\`\\`json\n {{\n \"action\": \"tool_name_to_use\",\n \"action_input\": \"the input for the tool, or an empty object {{}} if no input is needed\"\n }}\n \\`\\`\\`\n\n2. **Provide the Final Answer** once you have enough information. For this, you MUST output a JSON blob with the \"Final Answer\" action.\n The \"action_input\" for a \"Final Answer\" MUST be a string that begins with either \"RESPOND: \" for a message or \"SILENT: \" for no message. This prefix is a literal part of the output string and MUST NOT be omitted.\n - To send a message:\n \\`\\`\\`json\n {{\n \"action\": \"Final Answer\",\n \"action_input\": \"RESPOND: <your response message>\"\n }}\n \\`\\`\\`\n - To stay silent:\n \\`\\`\\`json\n {{\n \"action\": \"Final Answer\",\n \"action_input\": \"SILENT: <your reason for staying silent>\"\n }}\n \\`\\`\\`\n\n YOU MUST ALWAYS INCLUDE \"RESPOND:\" OR \"SILENT:\" IN YOUR FINAL ANSWER'S \"action_input\". FAILURE TO DO SO WILL CAUSE AN ERROR.\n</OUTPUT_FORMAT>\n\n<EXECUTION_CONTEXT>\nThis is internal data for your reference.\n\n<TOOLS>\n{tools}\n</TOOLS>\n\n<WORKING_MEMORY>\nThis is your internal thought process and previous tool usage.\n{agent_scratchpad}\n</WORKING_MEMORY>\n</EXECUTION_CONTEXT>\n`;\n\n/**\n * An advanced agent that uses tools and a structured prompt to engage in conversational chat.\n * It can decide whether to respond or remain silent and supports schema-validated responses.\n */\nexport class ChatAgentAdapter<T = unknown> implements AgentPort {\n constructor(\n public readonly name: string,\n private readonly options: ChatAgentOptions<T>,\n ) {}\n\n async run(userPrompt?: PromptPort): Promise<null | string> {\n this.options.logger?.debug(`[${this.name}] Starting chat execution.`);\n\n try {\n const executor = await this.createExecutor();\n const userInput = this.resolveUserInput(userPrompt);\n\n const result = await executor.invoke({ input: userInput });\n\n this.options.logger?.debug(`[${this.name}] Agent execution completed.`, {\n hasOutput: 'output' in result,\n });\n\n if (!result || typeof result.output !== 'string') {\n throw new Error('Agent returned an invalid result structure.');\n }\n\n const agentResponse = this.parseAgentOutput(result.output);\n\n if (!agentResponse) {\n return null;\n }\n\n if (!agentResponse.shouldRespond) {\n this.options.logger?.info(`[${this.name}] Agent chose to remain silent.`, {\n reason: agentResponse.reason,\n });\n return null;\n }\n\n const message = agentResponse.message ?? '';\n\n if (this.options.schema) {\n this.validateResponseContent(message, this.options.schema);\n this.options.logger?.info(\n `[${this.name}] Execution finished; response content validated.`,\n );\n } else {\n this.options.logger?.info(`[${this.name}] Execution finished.`);\n }\n\n return message;\n } catch (error) {\n this.options.logger?.error(`[${this.name}] Chat execution failed.`, {\n error: error instanceof Error ? error.message : 'Unknown error',\n });\n return null;\n }\n }\n\n private async createExecutor(): Promise<AgentExecutor> {\n const model = this.options.model.getModel();\n const tools = this.options.tools.map((tool) => tool.getDynamicTool());\n\n const prompt = ChatPromptTemplate.fromMessages([\n [\n 'system',\n SYSTEM_PROMPT_TEMPLATE.replace(\n '{mission_prompt}',\n this.options.systemPrompt.generate(),\n ),\n ],\n ['human', '{input}'],\n ]);\n\n const agent = await createStructuredChatAgent({\n llm: model,\n prompt,\n tools,\n });\n\n return AgentExecutor.fromAgentAndTools({\n agent,\n tools,\n verbose: this.options.verbose,\n });\n }\n\n private parseAgentOutput(output: string): null | {\n message?: string;\n reason?: string;\n shouldRespond: boolean;\n } {\n const text = output.trim();\n\n const respondMatch = text.match(/^RESPOND:\\s*([\\s\\S]+)$/i);\n if (respondMatch) {\n return { message: respondMatch[1].trim(), shouldRespond: true };\n }\n\n const silentMatch = text.match(/^SILENT:\\s*([\\s\\S]+)$/i);\n if (silentMatch) {\n return { reason: silentMatch[1].trim(), shouldRespond: false };\n }\n\n this.options.logger?.error(\n `[${this.name}] Agent output was missing 'RESPOND:' or 'SILENT:' prefix.`,\n { rawOutput: output },\n );\n\n return null;\n }\n\n private resolveUserInput(userPrompt?: PromptPort): string {\n if (userPrompt) {\n return userPrompt.generate();\n }\n return 'Proceed with your instructions.';\n }\n\n private validateResponseContent<TResponse>(\n content: string,\n schema: z.ZodSchema<TResponse>,\n ): void {\n try {\n new AIResponseParser(schema).parse(content);\n } catch (error) {\n this.options.logger?.error(\n `[${this.name}] Failed to validate response content against schema.`,\n {\n error: error instanceof Error ? error.message : 'Unknown error',\n rawContent: content,\n },\n );\n throw new Error('Invalid response content from model.');\n }\n }\n}\n"],"names":["ChatPromptTemplate","AgentExecutor","createStructuredChatAgent","AIResponseParser","SYSTEM_PROMPT_TEMPLATE","ChatAgentAdapter","name","options","run","userPrompt","executor","userInput","result","agentResponse","message","error","logger","debug","createExecutor","resolveUserInput","invoke","input","hasOutput","output","Error","parseAgentOutput","shouldRespond","info","reason","schema","validateResponseContent","model","tools","prompt","agent","getModel","map","tool","getDynamicTool","fromMessages","replace","systemPrompt","generate","llm","fromAgentAndTools","verbose","text","trim","respondMatch","match","silentMatch","rawOutput","content","parse","rawContent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAASA,kBAA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