@jterrazz/intelligence 1.5.0 → 1.6.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.
@@ -184,7 +184,9 @@ var SYSTEM_PROMPT_TEMPLATE = '\n<OBJECTIVE>\n{mission_prompt}\n</OBJECTIVE>\n\n<
184
184
  return _ts_generator(this, function(_state) {
185
185
  switch(_state.label){
186
186
  case 0:
187
- (_this_options_logger = this.options.logger) === null || _this_options_logger === void 0 ? void 0 : _this_options_logger.debug("[".concat(this.name, "] Starting chat execution."));
187
+ (_this_options_logger = this.options.logger) === null || _this_options_logger === void 0 ? void 0 : _this_options_logger.debug('Starting chat execution', {
188
+ agent: this.name
189
+ });
188
190
  _state.label = 1;
189
191
  case 1:
190
192
  _state.trys.push([
@@ -208,7 +210,8 @@ var SYSTEM_PROMPT_TEMPLATE = '\n<OBJECTIVE>\n{mission_prompt}\n</OBJECTIVE>\n\n<
208
210
  ];
209
211
  case 3:
210
212
  result = _state.sent();
211
- (_this_options_logger1 = this.options.logger) === null || _this_options_logger1 === void 0 ? void 0 : _this_options_logger1.debug("[".concat(this.name, "] Agent execution completed."), {
213
+ (_this_options_logger1 = this.options.logger) === null || _this_options_logger1 === void 0 ? void 0 : _this_options_logger1.debug('Agent execution completed', {
214
+ agent: this.name,
212
215
  hasOutput: 'output' in result
213
216
  });
214
217
  if (!result || typeof result.output !== 'string') {
@@ -223,7 +226,8 @@ var SYSTEM_PROMPT_TEMPLATE = '\n<OBJECTIVE>\n{mission_prompt}\n</OBJECTIVE>\n\n<
223
226
  }
224
227
  if (!agentResponse.shouldRespond) {
225
228
  ;
226
- (_this_options_logger2 = this.options.logger) === null || _this_options_logger2 === void 0 ? void 0 : _this_options_logger2.info("[".concat(this.name, "] Agent chose to remain silent."), {
229
+ (_this_options_logger2 = this.options.logger) === null || _this_options_logger2 === void 0 ? void 0 : _this_options_logger2.debug('Agent chose to remain silent', {
230
+ agent: this.name,
227
231
  reason: agentResponse.reason
228
232
  });
229
233
  return [
@@ -235,14 +239,18 @@ var SYSTEM_PROMPT_TEMPLATE = '\n<OBJECTIVE>\n{mission_prompt}\n</OBJECTIVE>\n\n<
235
239
  if (this.options.schema) {
236
240
  ;
237
241
  validatedResponse = this.validateResponseContent(message, this.options.schema);
238
- (_this_options_logger3 = this.options.logger) === null || _this_options_logger3 === void 0 ? void 0 : _this_options_logger3.info("[".concat(this.name, "] Execution finished; response content validated."));
242
+ (_this_options_logger3 = this.options.logger) === null || _this_options_logger3 === void 0 ? void 0 : _this_options_logger3.debug('Execution finished; response content validated.', {
243
+ agent: this.name
244
+ });
239
245
  return [
240
246
  2,
241
247
  validatedResponse
242
248
  ];
243
249
  } else {
244
250
  ;
245
- (_this_options_logger4 = this.options.logger) === null || _this_options_logger4 === void 0 ? void 0 : _this_options_logger4.info("[".concat(this.name, "] Execution finished."));
251
+ (_this_options_logger4 = this.options.logger) === null || _this_options_logger4 === void 0 ? void 0 : _this_options_logger4.debug('Execution finished', {
252
+ agent: this.name
253
+ });
246
254
  // When no schema is provided, we assume TOutput is string (default), so message is the result
247
255
  return [
248
256
  2,
@@ -255,7 +263,8 @@ var SYSTEM_PROMPT_TEMPLATE = '\n<OBJECTIVE>\n{mission_prompt}\n</OBJECTIVE>\n\n<
255
263
  ];
256
264
  case 4:
257
265
  error = _state.sent();
258
- (_this_options_logger5 = this.options.logger) === null || _this_options_logger5 === void 0 ? void 0 : _this_options_logger5.error("[".concat(this.name, "] Chat execution failed."), {
266
+ (_this_options_logger5 = this.options.logger) === null || _this_options_logger5 === void 0 ? void 0 : _this_options_logger5.error('Chat execution failed', {
267
+ agent: this.name,
259
268
  error: _instanceof(error, Error) ? error.message : 'Unknown error'
260
269
  });
261
270
  return [
@@ -352,7 +361,8 @@ var SYSTEM_PROMPT_TEMPLATE = '\n<OBJECTIVE>\n{mission_prompt}\n</OBJECTIVE>\n\n<
352
361
  shouldRespond: false
353
362
  };
354
363
  }
355
- (_this_options_logger = this.options.logger) === null || _this_options_logger === void 0 ? void 0 : _this_options_logger.error("[".concat(this.name, "] Agent output was missing 'RESPOND:' or 'SILENT:' prefix."), {
364
+ (_this_options_logger = this.options.logger) === null || _this_options_logger === void 0 ? void 0 : _this_options_logger.error("Agent output was missing 'RESPOND:' or 'SILENT:' prefix.", {
365
+ agent: this.name,
356
366
  rawOutput: output
357
367
  });
358
368
  return null;
@@ -374,7 +384,8 @@ var SYSTEM_PROMPT_TEMPLATE = '\n<OBJECTIVE>\n{mission_prompt}\n</OBJECTIVE>\n\n<
374
384
  return new AIResponseParser(schema).parse(content);
375
385
  } catch (error) {
376
386
  var _this_options_logger;
377
- (_this_options_logger = this.options.logger) === null || _this_options_logger === void 0 ? void 0 : _this_options_logger.error("[".concat(this.name, "] Failed to validate response content against schema."), {
387
+ (_this_options_logger = this.options.logger) === null || _this_options_logger === void 0 ? void 0 : _this_options_logger.error('Failed to validate response content against schema.', {
388
+ agent: this.name,
378
389
  error: _instanceof(error, Error) ? error.message : 'Unknown error',
379
390
  rawContent: content
380
391
  });
@@ -1 +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 { 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<TOutput = string> {\n logger?: LoggerPort;\n model: ModelPort;\n schema?: z.ZodSchema<TOutput>;\n systemPrompt: SystemPromptAdapter;\n tools: ToolPort[];\n verbose?: boolean;\n}\n\nconst SYSTEM_PROMPT_TEMPLATE = `\n<OBJECTIVE>\n{mission_prompt}\n</OBJECTIVE>\n\n<GLOBAL_WRAPPER_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\n{schema_format}\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 * @template TOutput - The TypeScript type of the output\n */\nexport class AutonomousAgentAdapter<TOutput = string> implements AgentPort<PromptPort, TOutput> {\n constructor(\n public readonly name: string,\n private readonly options: AutonomousAgentOptions<TOutput>,\n ) {}\n\n async run(input?: PromptPort): Promise<null | TOutput> {\n this.options.logger?.debug(`[${this.name}] Starting chat execution.`);\n\n try {\n const executor = await this.createExecutor();\n const userInput = this.resolveUserInput(input);\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 const validatedResponse = this.validateResponseContent(\n message,\n this.options.schema,\n );\n\n this.options.logger?.info(\n `[${this.name}] Execution finished; response content validated.`,\n );\n return validatedResponse;\n } else {\n this.options.logger?.info(`[${this.name}] Execution finished.`);\n // When no schema is provided, we assume TOutput is string (default), so message is the result\n return message as TOutput;\n }\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 // Add schema format instructions if schema is provided\n let schemaFormatInstructions = '';\n if (this.options.schema) {\n const jsonSchema = z.toJSONSchema(this.options.schema);\n const isPrimitiveType = ['boolean', 'integer', 'number', 'string'].includes(\n jsonSchema.type as string,\n );\n const jsonSchemaString = JSON.stringify(jsonSchema, null, 2)\n .replace(/{/g, '{{')\n .replace(/}/g, '}}');\n\n if (isPrimitiveType) {\n schemaFormatInstructions = `\n\nSCHEMA VALIDATION: When providing a \"RESPOND:\" answer, the content after \"RESPOND: \" must be a ${jsonSchema.type} value that matches this schema description:\n\n\\`\\`\\`json\n${jsonSchemaString}\n\\`\\`\\`\n\nExample format:\n\\`\\`\\`json\n{{\n \"action\": \"Final Answer\",\n \"action_input\": \"RESPOND: your ${jsonSchema.type} value here\"\n}}\n\\`\\`\\`\n\nDo not wrap the ${jsonSchema.type} value in JSON - just provide the raw value after \"RESPOND: \".`;\n } else {\n schemaFormatInstructions = `\n\nSCHEMA VALIDATION: When providing a \"RESPOND:\" answer, the content after \"RESPOND: \" must be valid JSON that matches this JSON schema description:\n\n\\`\\`\\`json\n${jsonSchemaString}\n\\`\\`\\`\n\nExample format:\n\\`\\`\\`json\n{{\n \"action\": \"Final Answer\",\n \"action_input\": \"RESPOND: {{\\\\\"field1\\\\\": \\\\\"value1\\\\\", \\\\\"field2\\\\\": \\\\\"value2\\\\\"}}\"\n}}\n\\`\\`\\`\n`;\n }\n }\n\n const prompt = ChatPromptTemplate.fromMessages([\n [\n 'system',\n SYSTEM_PROMPT_TEMPLATE.replace(\n '{mission_prompt}',\n this.options.systemPrompt.generate(),\n ).replace('{schema_format}', schemaFormatInstructions),\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(input?: PromptPort): string {\n if (input) {\n return input.generate();\n }\n return 'Proceed with your instructions.';\n }\n\n private validateResponseContent<TResponse>(\n content: string,\n schema: z.ZodSchema<TResponse>,\n ): TResponse {\n try {\n return 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","z","AIResponseParser","SYSTEM_PROMPT_TEMPLATE","AutonomousAgentAdapter","name","options","run","input","executor","userInput","result","agentResponse","message","validatedResponse","error","logger","debug","createExecutor","resolveUserInput","invoke","hasOutput","output","Error","parseAgentOutput","shouldRespond","info","reason","schema","validateResponseContent","model","tools","schemaFormatInstructions","jsonSchema","isPrimitiveType","jsonSchemaString","prompt","agent","getModel","map","tool","getDynamicTool","toJSONSchema","includes","type","JSON","stringify","replace","fromMessages","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;AAC5E,SAASC,CAAC,QAAQ,SAAS;AAO3B,SAASC,gBAAgB,QAAQ,iCAAiC;AAalE,IAAMC,yBAA0B;AAuDhC;;;;CAIC,GACD,OAAO,IAAA,AAAMC,uCAAN;;aAAMA,uBAEL,AAAgBC,IAAY,EAC5B,AAAiBC,OAAwC;gCAHpDF;;;aAEWC,OAAAA;aACCC,UAAAA;;kBAHZF;;YAMHG,KAAAA;mBAAN,SAAMA,IAAIC,KAAkB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A,MAAM0C,QAAQ;gBACzB;gBACA,OAAO;YACX;;;YAEQrB,KAAAA;mBAAR,SAAQA,wBACJ+B,OAAe,EACfhC,MAA8B;gBAE9B,IAAI;oBACA,OAAO,IAAI1B,iBAAiB0B,QAAQiC,KAAK,CAACD;gBAC9C,EAAE,OAAO7C,OAAO;wBACZ;qBAAA,uBAAA,IAAI,CAACT,OAAO,CAACU,MAAM,cAAnB,2CAAA,qBAAqBD,KAAK,CACtB,AAAC,IAAa,OAAV,IAAI,CAACV,IAAI,EAAC,0DACd;wBACIU,OAAOA,AAAK,YAALA,OAAiBQ,SAAQR,MAAMF,OAAO,GAAG;wBAChDiD,YAAYF;oBAChB;oBAEJ,MAAM,IAAIrC,MAAM;gBACpB;YACJ;;;WA1LSnB;IA2LZ"}
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 { 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<TOutput = string> {\n logger?: LoggerPort;\n model: ModelPort;\n schema?: z.ZodSchema<TOutput>;\n systemPrompt: SystemPromptAdapter;\n tools: ToolPort[];\n verbose?: boolean;\n}\n\nconst SYSTEM_PROMPT_TEMPLATE = `\n<OBJECTIVE>\n{mission_prompt}\n</OBJECTIVE>\n\n<GLOBAL_WRAPPER_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\n{schema_format}\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 * @template TOutput - The TypeScript type of the output\n */\nexport class AutonomousAgentAdapter<TOutput = string> implements AgentPort<PromptPort, TOutput> {\n constructor(\n public readonly name: string,\n private readonly options: AutonomousAgentOptions<TOutput>,\n ) {}\n\n async run(input?: PromptPort): Promise<null | TOutput> {\n this.options.logger?.debug('Starting chat execution', { agent: this.name });\n\n try {\n const executor = await this.createExecutor();\n const userInput = this.resolveUserInput(input);\n\n const result = await executor.invoke({ input: userInput });\n\n this.options.logger?.debug('Agent execution completed', {\n agent: this.name,\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?.debug('Agent chose to remain silent', {\n agent: this.name,\n reason: agentResponse.reason,\n });\n return null;\n }\n\n const message = agentResponse.message ?? '';\n\n if (this.options.schema) {\n const validatedResponse = this.validateResponseContent(\n message,\n this.options.schema,\n );\n\n this.options.logger?.debug('Execution finished; response content validated.', {\n agent: this.name,\n });\n return validatedResponse;\n } else {\n this.options.logger?.debug('Execution finished', { agent: this.name });\n // When no schema is provided, we assume TOutput is string (default), so message is the result\n return message as TOutput;\n }\n } catch (error) {\n this.options.logger?.error('Chat execution failed', {\n agent: this.name,\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 // Add schema format instructions if schema is provided\n let schemaFormatInstructions = '';\n if (this.options.schema) {\n const jsonSchema = z.toJSONSchema(this.options.schema);\n const isPrimitiveType = ['boolean', 'integer', 'number', 'string'].includes(\n jsonSchema.type as string,\n );\n const jsonSchemaString = JSON.stringify(jsonSchema, null, 2)\n .replace(/{/g, '{{')\n .replace(/}/g, '}}');\n\n if (isPrimitiveType) {\n schemaFormatInstructions = `\n\nSCHEMA VALIDATION: When providing a \"RESPOND:\" answer, the content after \"RESPOND: \" must be a ${jsonSchema.type} value that matches this schema description:\n\n\\`\\`\\`json\n${jsonSchemaString}\n\\`\\`\\`\n\nExample format:\n\\`\\`\\`json\n{{\n \"action\": \"Final Answer\",\n \"action_input\": \"RESPOND: your ${jsonSchema.type} value here\"\n}}\n\\`\\`\\`\n\nDo not wrap the ${jsonSchema.type} value in JSON - just provide the raw value after \"RESPOND: \".`;\n } else {\n schemaFormatInstructions = `\n\nSCHEMA VALIDATION: When providing a \"RESPOND:\" answer, the content after \"RESPOND: \" must be valid JSON that matches this JSON schema description:\n\n\\`\\`\\`json\n${jsonSchemaString}\n\\`\\`\\`\n\nExample format:\n\\`\\`\\`json\n{{\n \"action\": \"Final Answer\",\n \"action_input\": \"RESPOND: {{\\\\\"field1\\\\\": \\\\\"value1\\\\\", \\\\\"field2\\\\\": \\\\\"value2\\\\\"}}\"\n}}\n\\`\\`\\`\n`;\n }\n }\n\n const prompt = ChatPromptTemplate.fromMessages([\n [\n 'system',\n SYSTEM_PROMPT_TEMPLATE.replace(\n '{mission_prompt}',\n this.options.systemPrompt.generate(),\n ).replace('{schema_format}', schemaFormatInstructions),\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(\"Agent output was missing 'RESPOND:' or 'SILENT:' prefix.\", {\n agent: this.name,\n rawOutput: output,\n });\n\n return null;\n }\n\n private resolveUserInput(input?: PromptPort): string {\n if (input) {\n return input.generate();\n }\n return 'Proceed with your instructions.';\n }\n\n private validateResponseContent<TResponse>(\n content: string,\n schema: z.ZodSchema<TResponse>,\n ): TResponse {\n try {\n return new AIResponseParser(schema).parse(content);\n } catch (error) {\n this.options.logger?.error('Failed to validate response content against schema.', {\n agent: this.name,\n error: error instanceof Error ? error.message : 'Unknown error',\n rawContent: content,\n });\n throw new Error('Invalid response content from model.');\n }\n }\n}\n"],"names":["ChatPromptTemplate","AgentExecutor","createStructuredChatAgent","z","AIResponseParser","SYSTEM_PROMPT_TEMPLATE","AutonomousAgentAdapter","name","options","run","input","executor","userInput","result","agentResponse","message","validatedResponse","error","logger","debug","agent","createExecutor","resolveUserInput","invoke","hasOutput","output","Error","parseAgentOutput","shouldRespond","reason","schema","validateResponseContent","model","tools","schemaFormatInstructions","jsonSchema","isPrimitiveType","jsonSchemaString","prompt","getModel","map","tool","getDynamicTool","toJSONSchema","includes","type","JSON","stringify","replace","fromMessages","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;AAC5E,SAASC,CAAC,QAAQ,SAAS;AAO3B,SAASC,gBAAgB,QAAQ,iCAAiC;AAalE,IAAMC,yBAA0B;AAuDhC;;;;CAIC,GACD,OAAO,IAAA,AAAMC,uCAAN;;aAAMA,uBAEL,AAAgBC,IAAY,EAC5B,AAAiBC,OAAwC;gCAHpDF;;;aAEWC,OAAAA;aACCC,UAAAA;;kBAHZF;;YAMHG,KAAAA;mBAAN,SAAMA,IAAIC,KAAkB;;wBACxB,sBAQI,uBALMC,UACAC,WAEAC,QAWAC,eAOF,uBAOYA,wBAAVC,SAQF,uBALMC,mBAUN,uBAICC,OACL;;;;iCAjDJ,uBAAA,IAAI,CAACT,OAAO,CAACU,MAAM,cAAnB,2CAAA,qBAAqBC,KAAK,CAAC,2BA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,uBAAA,IAAI,CAACT,OAAO,CAACU,MAAM,cAAnB,2CAAA,qBAAqBD,KAAK,CAAC,uDAAuD;wBAC9EG,OAAO,IAAI,CAACb,IAAI;wBAChBU,OAAOA,AAAK,YAALA,OAAiBS,SAAQT,MAAMF,OAAO,GAAG;wBAChDgD,YAAYF;oBAChB;oBACA,MAAM,IAAInC,MAAM;gBACpB;YACJ;;;WA3LSpB;IA4LZ"}
@@ -181,7 +181,9 @@ import { AIResponseParser } from '../utils/ai-response-parser.js';
181
181
  return _ts_generator(this, function(_state) {
182
182
  switch(_state.label){
183
183
  case 0:
184
- (_this_options_logger = this.options.logger) === null || _this_options_logger === void 0 ? void 0 : _this_options_logger.debug("[".concat(this.name, "] Starting query execution."));
184
+ (_this_options_logger = this.options.logger) === null || _this_options_logger === void 0 ? void 0 : _this_options_logger.debug('Starting query execution', {
185
+ agent: this.name
186
+ });
185
187
  _state.label = 1;
186
188
  case 1:
187
189
  _state.trys.push([
@@ -199,14 +201,18 @@ import { AIResponseParser } from '../utils/ai-response-parser.js';
199
201
  if (this.options.schema) {
200
202
  ;
201
203
  parsedResponse = this.parseResponse(content, this.options.schema);
202
- (_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."));
204
+ (_this_options_logger1 = this.options.logger) === null || _this_options_logger1 === void 0 ? void 0 : _this_options_logger1.debug('Execution finished and response parsed', {
205
+ agent: this.name
206
+ });
203
207
  return [
204
208
  2,
205
209
  parsedResponse
206
210
  ];
207
211
  } else {
208
212
  ;
209
- (_this_options_logger2 = this.options.logger) === null || _this_options_logger2 === void 0 ? void 0 : _this_options_logger2.info("[".concat(this.name, "] Execution finished."));
213
+ (_this_options_logger2 = this.options.logger) === null || _this_options_logger2 === void 0 ? void 0 : _this_options_logger2.debug('Execution finished', {
214
+ agent: this.name
215
+ });
210
216
  // When no schema is provided, we assume TOutput is string (default), so content is the result
211
217
  return [
212
218
  2,
@@ -219,7 +225,8 @@ import { AIResponseParser } from '../utils/ai-response-parser.js';
219
225
  ];
220
226
  case 3:
221
227
  error = _state.sent();
222
- (_this_options_logger3 = this.options.logger) === null || _this_options_logger3 === void 0 ? void 0 : _this_options_logger3.error("[".concat(this.name, "] Execution failed."), {
228
+ (_this_options_logger3 = this.options.logger) === null || _this_options_logger3 === void 0 ? void 0 : _this_options_logger3.error('Execution failed', {
229
+ agent: this.name,
223
230
  error: _instanceof(error, Error) ? error.message : 'Unknown error'
224
231
  });
225
232
  return [
@@ -270,12 +277,14 @@ import { AIResponseParser } from '../utils/ai-response-parser.js';
270
277
  role: 'user'
271
278
  }
272
279
  ];
273
- (_this_options_logger = this.options.logger) === null || _this_options_logger === void 0 ? void 0 : _this_options_logger.debug("[".concat(this.name, "] Invoking model..."), {
280
+ (_this_options_logger = this.options.logger) === null || _this_options_logger === void 0 ? void 0 : _this_options_logger.debug('Invoking model...', {
281
+ agent: this.name,
274
282
  hasSchema: !!this.options.schema
275
283
  });
276
284
  if (this.options.verbose) {
277
285
  ;
278
- (_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..."), {
286
+ (_this_options_logger1 = this.options.logger) === null || _this_options_logger1 === void 0 ? void 0 : _this_options_logger1.debug('Sending messages to model...', {
287
+ agent: this.name,
279
288
  messages: messages
280
289
  });
281
290
  }
@@ -305,7 +314,8 @@ import { AIResponseParser } from '../utils/ai-response-parser.js';
305
314
  return new AIResponseParser(schema).parse(content);
306
315
  } catch (error) {
307
316
  var _this_options_logger;
308
- (_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."), {
317
+ (_this_options_logger = this.options.logger) === null || _this_options_logger === void 0 ? void 0 : _this_options_logger.error('Failed to parse model response.', {
318
+ agent: this.name,
309
319
  error: _instanceof(error, Error) ? error.message : 'Unknown error',
310
320
  rawContent: content
311
321
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapters/agents/basic-agent.adapter.ts"],"sourcesContent":["import { type LoggerPort } from '@jterrazz/logger';\nimport { 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<TOutput = string> {\n logger?: LoggerPort;\n model: ModelPort;\n schema?: z.ZodSchema<TOutput>;\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 * @template TOutput - The TypeScript type of the output\n */\nexport class BasicAgentAdapter<TOutput = string> implements AgentPort<PromptPort, TOutput> {\n constructor(\n public readonly name: string,\n private readonly options: BasicAgentOptions<TOutput>,\n ) {}\n\n async run(input?: PromptPort): Promise<null | TOutput> {\n this.options.logger?.debug(`[${this.name}] Starting query execution.`);\n\n try {\n const content = await this.invokeModel(input);\n\n if (this.options.schema) {\n const parsedResponse = this.parseResponse(content, this.options.schema);\n this.options.logger?.info(`[${this.name}] Execution finished and response parsed.`);\n return parsedResponse;\n } else {\n this.options.logger?.info(`[${this.name}] Execution finished.`);\n // When no schema is provided, we assume TOutput is string (default), so content is the result\n return content as TOutput;\n }\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(input?: PromptPort): Promise<string> {\n const userInput = this.resolveUserInput(input);\n let systemMessage = this.options.systemPrompt.generate();\n\n // Add schema definition to system prompt if schema is provided\n if (this.options.schema) {\n const jsonSchema = z.toJSONSchema(this.options.schema);\n const isPrimitiveType = ['boolean', 'integer', 'number', 'string'].includes(\n jsonSchema.type as string,\n );\n\n if (isPrimitiveType) {\n systemMessage += `\\n\\n<OUTPUT_FORMAT>\nYou must respond with a ${jsonSchema.type} value that matches this schema:\n\n\\`\\`\\`json\n${JSON.stringify(jsonSchema, null, 2)}\n\\`\\`\\`\n\nYour response should be only the ${jsonSchema.type} value, without any JSON wrapping or additional text.\n</OUTPUT_FORMAT>`;\n } else {\n systemMessage += `\\n\\n<OUTPUT_FORMAT>\nYou must respond with valid JSON that matches this JSON schema description:\n\n\\`\\`\\`json\n${JSON.stringify(jsonSchema, null, 2)}\n\\`\\`\\`\n\nYour response must be parseable JSON that validates against this schema. Do not include any text outside the JSON.\n</OUTPUT_FORMAT>`;\n }\n }\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>): TResponse {\n try {\n return 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(input?: PromptPort): string {\n if (input) {\n return input.generate();\n }\n return 'Proceed with your instructions.';\n }\n}\n"],"names":["z","AIResponseParser","BasicAgentAdapter","name","options","run","input","content","parsedResponse","error","logger","debug","invokeModel","schema","parseResponse","info","Error","message","userInput","systemMessage","jsonSchema","isPrimitiveType","messages","response","resolveUserInput","systemPrompt","generate","toJSONSchema","includes","type","JSON","stringify","role","hasSchema","verbose","model","getModel","invoke","parse","rawContent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;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AO,CAACM,MAAM,cAAnB,4CAAA,sBAAqBK,IAAI,CAAC,AAAC,IAAa,OAAV,IAAI,CAACZ,IAAI,EAAC,mCAAiC;wCACrEmB,UAAAA;oCACJ;gCACJ;gCAEiB;;oCAAM,IAAI,CAAClB,OAAO,CAAC+B,KAAK,CAACC,QAAQ,GAAGC,MAAM,CAACf;;;gCAAtDC,WAAW;gCACThB,UAAYgB,SAAZhB;gCAER,IAAI,OAAOA,YAAY,UAAU;oCAC7B,MAAM,IAAIS,MAAM;gCACpB;gCAEA;;oCAAOT;;;;gBACX;;;;YAEQO,KAAAA;mBAAR,SAAQA,cAAyBP,OAAe,EAAEM,MAA8B;gBAC5E,IAAI;oBACA,OAAO,IAAIZ,iBAAiBY,QAAQyB,KAAK,CAAC/B;gBAC9C,EAAE,OAAOE,OAAO;wBACZ;qBAAA,uBAAA,IAAI,CAACL,OAAO,CAACM,MAAM,cAAnB,2CAAA,qBAAqBD,KAAK,CAAC,AAAC,IAAa,OAAV,IAAI,CAACN,IAAI,EAAC,sCAAoC;wBACzEM,OAAOA,AAAK,YAALA,OAAiBO,SAAQP,MAAMQ,OAAO,GAAG;wBAChDsB,YAAYhC;oBAChB;oBACA,MAAM,IAAIS,MAAM;gBACpB;YACJ;;;YAEQQ,KAAAA;mBAAR,SAAQA,iBAAiBlB,KAAkB;gBACvC,IAAIA,OAAO;oBACP,OAAOA,MAAMoB,QAAQ;gBACzB;gBACA,OAAO;YACX;;;WAzGSxB;IA0GZ"}
1
+ {"version":3,"sources":["../../../src/adapters/agents/basic-agent.adapter.ts"],"sourcesContent":["import { type LoggerPort } from '@jterrazz/logger';\nimport { 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<TOutput = string> {\n logger?: LoggerPort;\n model: ModelPort;\n schema?: z.ZodSchema<TOutput>;\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 * @template TOutput - The TypeScript type of the output\n */\nexport class BasicAgentAdapter<TOutput = string> implements AgentPort<PromptPort, TOutput> {\n constructor(\n public readonly name: string,\n private readonly options: BasicAgentOptions<TOutput>,\n ) {}\n\n async run(input?: PromptPort): Promise<null | TOutput> {\n this.options.logger?.debug('Starting query execution', { agent: this.name });\n\n try {\n const content = await this.invokeModel(input);\n\n if (this.options.schema) {\n const parsedResponse = this.parseResponse(content, this.options.schema);\n this.options.logger?.debug('Execution finished and response parsed', {\n agent: this.name,\n });\n return parsedResponse;\n } else {\n this.options.logger?.debug('Execution finished', { agent: this.name });\n // When no schema is provided, we assume TOutput is string (default), so content is the result\n return content as TOutput;\n }\n } catch (error) {\n this.options.logger?.error('Execution failed', {\n agent: this.name,\n error: error instanceof Error ? error.message : 'Unknown error',\n });\n return null;\n }\n }\n\n private async invokeModel(input?: PromptPort): Promise<string> {\n const userInput = this.resolveUserInput(input);\n let systemMessage = this.options.systemPrompt.generate();\n\n // Add schema definition to system prompt if schema is provided\n if (this.options.schema) {\n const jsonSchema = z.toJSONSchema(this.options.schema);\n const isPrimitiveType = ['boolean', 'integer', 'number', 'string'].includes(\n jsonSchema.type as string,\n );\n\n if (isPrimitiveType) {\n systemMessage += `\\n\\n<OUTPUT_FORMAT>\nYou must respond with a ${jsonSchema.type} value that matches this schema:\n\n\\`\\`\\`json\n${JSON.stringify(jsonSchema, null, 2)}\n\\`\\`\\`\n\nYour response should be only the ${jsonSchema.type} value, without any JSON wrapping or additional text.\n</OUTPUT_FORMAT>`;\n } else {\n systemMessage += `\\n\\n<OUTPUT_FORMAT>\nYou must respond with valid JSON that matches this JSON schema description:\n\n\\`\\`\\`json\n${JSON.stringify(jsonSchema, null, 2)}\n\\`\\`\\`\n\nYour response must be parseable JSON that validates against this schema. Do not include any text outside the JSON.\n</OUTPUT_FORMAT>`;\n }\n }\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('Invoking model...', {\n agent: this.name,\n hasSchema: !!this.options.schema,\n });\n\n if (this.options.verbose) {\n this.options.logger?.debug('Sending messages to model...', {\n agent: this.name,\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>): TResponse {\n try {\n return new AIResponseParser(schema).parse(content);\n } catch (error) {\n this.options.logger?.error('Failed to parse model response.', {\n agent: this.name,\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(input?: PromptPort): string {\n if (input) {\n return input.generate();\n }\n return 'Proceed with your instructions.';\n }\n}\n"],"names":["z","AIResponseParser","BasicAgentAdapter","name","options","run","input","content","parsedResponse","error","logger","debug","agent","invokeModel","schema","parseResponse","Error","message","userInput","systemMessage","jsonSchema","isPrimitiveType","messages","response","resolveUserInput","systemPrompt","generate","toJSONSchema","includes","type","JSON","stringify","role","hasSchema","verbose","model","getModel","invoke","parse","rawContent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAASA,CAAC,QAAQ,SAAS;AAM3B,SAASC,gBAAgB,QAAQ,iCAAiC;AAYlE;;;;CAIC,GACD,OAAO,IAAA,AAAMC,kCAAN;;aAAMA,kBAEL,AAAgBC,IAAY,EAC5B,AAAiBC,O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AAOT;;;;gBACX;;;;YAEQQ,KAAAA;mBAAR,SAAQA,cAAyBR,OAAe,EAAEO,MAA8B;gBAC5E,IAAI;oBACA,OAAO,IAAIb,iBAAiBa,QAAQwB,KAAK,CAAC/B;gBAC9C,EAAE,OAAOE,OAAO;wBACZ;qBAAA,uBAAA,IAAI,CAACL,OAAO,CAACM,MAAM,cAAnB,2CAAA,qBAAqBD,KAAK,CAAC,mCAAmC;wBAC1DG,OAAO,IAAI,CAACT,IAAI;wBAChBM,OAAOA,AAAK,YAALA,OAAiBO,SAAQP,MAAMQ,OAAO,GAAG;wBAChDsB,YAAYhC;oBAChB;oBACA,MAAM,IAAIS,MAAM;gBACpB;YACJ;;;YAEQQ,KAAAA;mBAAR,SAAQA,iBAAiBlB,KAAkB;gBACvC,IAAIA,OAAO;oBACP,OAAOA,MAAMoB,QAAQ;gBACzB;gBACA,OAAO;YACX;;;WA/GSxB;IAgHZ"}
@@ -201,7 +201,9 @@ function _ts_generator(thisArg, body) {
201
201
  ,
202
202
  5
203
203
  ]);
204
- (_this_logger1 = this.logger) === null || _this_logger1 === void 0 ? void 0 : _this_logger1.debug("[".concat(this.name, "] Attempt ").concat(attempt, " of ").concat(maxAttempts, "."));
204
+ (_this_logger1 = this.logger) === null || _this_logger1 === void 0 ? void 0 : _this_logger1.debug("Attempt ".concat(attempt, " of ").concat(maxAttempts), {
205
+ agent: this.name
206
+ });
205
207
  return [
206
208
  4,
207
209
  this.agent.run(input)
@@ -210,20 +212,25 @@ function _ts_generator(thisArg, body) {
210
212
  result = _state.sent();
211
213
  if (result !== null) {
212
214
  ;
213
- (_this_logger3 = this.logger) === null || _this_logger3 === void 0 ? void 0 : _this_logger3.info("[".concat(this.name, "] Attempt ").concat(attempt, " of ").concat(maxAttempts, " succeeded."));
215
+ (_this_logger3 = this.logger) === null || _this_logger3 === void 0 ? void 0 : _this_logger3.debug("Attempt ".concat(attempt, " of ").concat(maxAttempts, " succeeded"), {
216
+ agent: this.name
217
+ });
214
218
  return [
215
219
  2,
216
220
  result
217
221
  ];
218
222
  }
219
- (_this_logger2 = this.logger) === null || _this_logger2 === void 0 ? void 0 : _this_logger2.warn("[".concat(this.name, "] Attempt ").concat(attempt, " of ").concat(maxAttempts, " failed: agent returned null."));
223
+ (_this_logger2 = this.logger) === null || _this_logger2 === void 0 ? void 0 : _this_logger2.debug("Attempt ".concat(attempt, " of ").concat(maxAttempts, " failed: agent returned null"), {
224
+ agent: this.name
225
+ });
220
226
  return [
221
227
  3,
222
228
  5
223
229
  ];
224
230
  case 4:
225
231
  error = _state.sent();
226
- (_this_logger4 = this.logger) === null || _this_logger4 === void 0 ? void 0 : _this_logger4.warn("[".concat(this.name, "] Attempt ").concat(attempt, " of ").concat(maxAttempts, " failed with an error."), {
232
+ (_this_logger4 = this.logger) === null || _this_logger4 === void 0 ? void 0 : _this_logger4.debug("Attempt ".concat(attempt, " of ").concat(maxAttempts, " failed with an error"), {
233
+ agent: this.name,
227
234
  error: _instanceof(error, Error) ? error.message : 'Unknown error'
228
235
  });
229
236
  return [
@@ -237,7 +244,9 @@ function _ts_generator(thisArg, body) {
237
244
  1
238
245
  ];
239
246
  case 6:
240
- (_this_logger = this.logger) === null || _this_logger === void 0 ? void 0 : _this_logger.error("[".concat(this.name, "] All ").concat(maxAttempts, " attempts failed."));
247
+ (_this_logger = this.logger) === null || _this_logger === void 0 ? void 0 : _this_logger.error("All ".concat(maxAttempts, " attempts failed"), {
248
+ agent: this.name
249
+ });
241
250
  return [
242
251
  2,
243
252
  null
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapters/agents/retryable-agent.adapter.ts"],"sourcesContent":["import { type LoggerPort } from '@jterrazz/logger';\n\nimport { type AgentPort } from '../../ports/agent.port.js';\nimport type { PromptPort } from '../../ports/prompt.port.js';\n\nexport interface RetryableAgentAdapterOptions {\n logger?: LoggerPort;\n retries?: number;\n}\n\n/**\n * A decorator agent that adds retry logic to an existing agent.\n * @template TInput - The TypeScript type of the input\n * @template TOutput - The TypeScript type of the output\n */\nexport class RetryableAgentAdapter<TInput = PromptPort, TOutput = string>\n implements AgentPort<TInput, TOutput>\n{\n public readonly name: string;\n private readonly logger?: LoggerPort;\n private readonly retries: number;\n\n constructor(\n private readonly agent: AgentPort<TInput, TOutput>,\n options: RetryableAgentAdapterOptions = {},\n ) {\n const { logger, retries = 1 } = options;\n this.name = `Retryable(${agent.name})`;\n this.logger = logger;\n this.retries = retries;\n }\n\n async run(input?: TInput): Promise<null | TOutput> {\n const maxAttempts = this.retries + 1;\n\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n try {\n this.logger?.debug(`[${this.name}] Attempt ${attempt} of ${maxAttempts}.`);\n const result = await this.agent.run(input);\n\n if (result !== null) {\n this.logger?.info(\n `[${this.name}] Attempt ${attempt} of ${maxAttempts} succeeded.`,\n );\n return result;\n }\n\n this.logger?.warn(\n `[${this.name}] Attempt ${attempt} of ${maxAttempts} failed: agent returned null.`,\n );\n } catch (error) {\n this.logger?.warn(\n `[${this.name}] Attempt ${attempt} of ${maxAttempts} failed with an error.`,\n {\n error: error instanceof Error ? error.message : 'Unknown error',\n },\n );\n }\n }\n\n this.logger?.error(`[${this.name}] All ${maxAttempts} attempts failed.`);\n return null;\n }\n}\n"],"names":["RetryableAgentAdapter","agent","options","name","logger","retries","run","input","maxAttempts","attempt","result","error","debug","info","warn","Error","message"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA;;;;CAIC,GACD,OAAO,IAAA,AAAMA,sCAAN;;aAAMA,sBAQL,AAAiBC,KAAiC;YAClDC,UAAAA,iEAAwC,CAAC;gCATpCF;;QAGT,uBAAgBG,QAAhB,KAAA;QACA,uBAAiBC,UAAjB,KAAA;QACA,uBAAiBC,W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iBI,SAAQJ,MAAMK,OAAO,GAAG;gCACpD;;;;;;gCApBkCP;;;;;;iCAyB9C,eAAA,IAAI,CAACL,MAAM,cAAX,mCAAA,aAAaO,KAAK,CAAC,AAAC,IAAqBH,OAAlB,IAAI,CAACL,IAAI,EAAC,UAAoB,OAAZK,aAAY;gCACrD;;oCAAO;;;;gBACX;;;;WA/CSR;IAgDZ"}
1
+ {"version":3,"sources":["../../../src/adapters/agents/retryable-agent.adapter.ts"],"sourcesContent":["import { type LoggerPort } from '@jterrazz/logger';\n\nimport { type AgentPort } from '../../ports/agent.port.js';\nimport type { PromptPort } from '../../ports/prompt.port.js';\n\nexport interface RetryableAgentAdapterOptions {\n logger?: LoggerPort;\n retries?: number;\n}\n\n/**\n * A decorator agent that adds retry logic to an existing agent.\n * @template TInput - The TypeScript type of the input\n * @template TOutput - The TypeScript type of the output\n */\nexport class RetryableAgentAdapter<TInput = PromptPort, TOutput = string>\n implements AgentPort<TInput, TOutput>\n{\n public readonly name: string;\n private readonly logger?: LoggerPort;\n private readonly retries: number;\n\n constructor(\n private readonly agent: AgentPort<TInput, TOutput>,\n options: RetryableAgentAdapterOptions = {},\n ) {\n const { logger, retries = 1 } = options;\n this.name = `Retryable(${agent.name})`;\n this.logger = logger;\n this.retries = retries;\n }\n\n async run(input?: TInput): Promise<null | TOutput> {\n const maxAttempts = this.retries + 1;\n\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n try {\n this.logger?.debug(`Attempt ${attempt} of ${maxAttempts}`, { agent: this.name });\n const result = await this.agent.run(input);\n\n if (result !== null) {\n this.logger?.debug(`Attempt ${attempt} of ${maxAttempts} succeeded`, {\n agent: this.name,\n });\n return result;\n }\n\n this.logger?.debug(\n `Attempt ${attempt} of ${maxAttempts} failed: agent returned null`,\n { agent: this.name },\n );\n } catch (error) {\n this.logger?.debug(`Attempt ${attempt} of ${maxAttempts} failed with an error`, {\n agent: this.name,\n error: error instanceof Error ? error.message : 'Unknown error',\n });\n }\n }\n\n this.logger?.error(`All ${maxAttempts} attempts failed`, { agent: this.name });\n return null;\n }\n}\n"],"names":["RetryableAgentAdapter","agent","options","name","logger","retries","run","input","maxAttempts","attempt","result","error","debug","Error","message"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA;;;;CAIC,GACD,OAAO,IAAA,AAAMA,sCAAN;;aAAMA,sBAQL,AAAiBC,KAAiC;YAClDC,UAAAA,iEAAwC,CAAC;gCATpCF;;QAGT,uBAAgBG,QAAhB,KAAA;QACA,uBAAiBC,UAAjB,KAAA;QACA,uBAAiBC,WAAjB,KAAA;aAGqBJ,QAAAA;QAGjB,IAAQG,SAAwBF,QAAxBE,2BAAwBF,QAAhBG,SAAAA,wCAAU;QAC1B,IAAI,CAACF,IAAI,GAAG,AAAC,aAAuB,OAAXF,MAAME,IAAI,EAAC;QACpC,IAAI,CAACC,MAAM,GAAGA;QACd,IAAI,CAACC,OAAO,GAAGA;;kBAdVL;;YAiBHM,KAAAA;mBAAN,SAAMA,IAAIC,KAAc;;wBA2BpB,cA1BMC,aAEGC,SAED,eAUA,eATMC,QAGF,eAUCC,OACL;;;;gCAnBFH,cAAc,IAAI,CAACH,OAAO,GAAG;gCAE1BI,UAAU;;;qCAAGA,CAAAA,WAAWD,WAAU;;;;;;;;;;;;iCAEnC,gBAAA,IAAI,CAACJ,MAAM,cAAX,oCAAA,cAAaQ,KAAK,CAAC,AAAC,WAAwBJ,OAAdC,SAAQ,QAAkB,OAAZD,cAAe;oCAAEP,OAAO,IAAI,CAACE,IAAI;gCAAC;gCAC/D;;oCAAM,IAAI,CAACF,KAAK,CAACK,GAAG,CAACC;;;gCAA9BG,SAAS;gCAEf,IAAIA,WAAW,MAAM;;qCACjB,gBAAA,IAAI,CAACN,MAAM,cAAX,oCAAA,cAAaQ,KAAK,CAAC,AAAC,WAAwBJ,OAAdC,SAAQ,QAAkB,OAAZD,aAAY,eAAa;wCACjEP,OAAO,IAAI,CAACE,IAAI;oCACpB;oCACA;;wCAAOO;;gCACX;iCAEA,gBAAA,IAAI,CAACN,MAAM,cAAX,oCAAA,cAAaQ,KAAK,CACd,AAAC,WAAwBJ,OAAdC,SAAQ,QAAkB,OAAZD,aAAY,iCACrC;oCAAEP,OAAO,IAAI,CAACE,IAAI;gCAAC;;;;;;gCAElBQ;iCACL,gBAAA,IAAI,CAACP,MAAM,cAAX,oCAAA,cAAaQ,KAAK,CAAC,AAAC,WAAwBJ,OAAdC,SAAQ,QAAkB,OAAZD,aAAY,0BAAwB;oCAC5EP,OAAO,IAAI,CAACE,IAAI;oCAChBQ,OAAOA,AAAK,YAALA,OAAiBE,SAAQF,MAAMG,OAAO,GAAG;gCACpD;;;;;;gCApBsCL;;;;;;iCAwB9C,eAAA,IAAI,CAACL,MAAM,cAAX,mCAAA,aAAaO,KAAK,CAAC,AAAC,OAAkB,OAAZH,aAAY,qBAAmB;oCAAEP,OAAO,IAAI,CAACE,IAAI;gCAAC;gCAC5E;;oCAAO;;;;gBACX;;;;WA9CSH;IA+CZ"}
package/dist/index.cjs CHANGED
@@ -662,7 +662,9 @@ var SYSTEM_PROMPT_TEMPLATE = '\n<OBJECTIVE>\n{mission_prompt}\n</OBJECTIVE>\n\n<
662
662
  return _ts_generator$2(this, function(_state) {
663
663
  switch(_state.label){
664
664
  case 0:
665
- (_this_options_logger = this.options.logger) === null || _this_options_logger === void 0 ? void 0 : _this_options_logger.debug("[".concat(this.name, "] Starting chat execution."));
665
+ (_this_options_logger = this.options.logger) === null || _this_options_logger === void 0 ? void 0 : _this_options_logger.debug('Starting chat execution', {
666
+ agent: this.name
667
+ });
666
668
  _state.label = 1;
667
669
  case 1:
668
670
  _state.trys.push([
@@ -686,7 +688,8 @@ var SYSTEM_PROMPT_TEMPLATE = '\n<OBJECTIVE>\n{mission_prompt}\n</OBJECTIVE>\n\n<
686
688
  ];
687
689
  case 3:
688
690
  result = _state.sent();
689
- (_this_options_logger1 = this.options.logger) === null || _this_options_logger1 === void 0 ? void 0 : _this_options_logger1.debug("[".concat(this.name, "] Agent execution completed."), {
691
+ (_this_options_logger1 = this.options.logger) === null || _this_options_logger1 === void 0 ? void 0 : _this_options_logger1.debug('Agent execution completed', {
692
+ agent: this.name,
690
693
  hasOutput: 'output' in result
691
694
  });
692
695
  if (!result || typeof result.output !== 'string') {
@@ -700,7 +703,8 @@ var SYSTEM_PROMPT_TEMPLATE = '\n<OBJECTIVE>\n{mission_prompt}\n</OBJECTIVE>\n\n<
700
703
  ];
701
704
  }
702
705
  if (!agentResponse.shouldRespond) {
703
- (_this_options_logger2 = this.options.logger) === null || _this_options_logger2 === void 0 ? void 0 : _this_options_logger2.info("[".concat(this.name, "] Agent chose to remain silent."), {
706
+ (_this_options_logger2 = this.options.logger) === null || _this_options_logger2 === void 0 ? void 0 : _this_options_logger2.debug('Agent chose to remain silent', {
707
+ agent: this.name,
704
708
  reason: agentResponse.reason
705
709
  });
706
710
  return [
@@ -711,13 +715,17 @@ var SYSTEM_PROMPT_TEMPLATE = '\n<OBJECTIVE>\n{mission_prompt}\n</OBJECTIVE>\n\n<
711
715
  message = (_agentResponse_message = agentResponse.message) !== null && _agentResponse_message !== void 0 ? _agentResponse_message : '';
712
716
  if (this.options.schema) {
713
717
  validatedResponse = this.validateResponseContent(message, this.options.schema);
714
- (_this_options_logger3 = this.options.logger) === null || _this_options_logger3 === void 0 ? void 0 : _this_options_logger3.info("[".concat(this.name, "] Execution finished; response content validated."));
718
+ (_this_options_logger3 = this.options.logger) === null || _this_options_logger3 === void 0 ? void 0 : _this_options_logger3.debug('Execution finished; response content validated.', {
719
+ agent: this.name
720
+ });
715
721
  return [
716
722
  2,
717
723
  validatedResponse
718
724
  ];
719
725
  } else {
720
- (_this_options_logger4 = this.options.logger) === null || _this_options_logger4 === void 0 ? void 0 : _this_options_logger4.info("[".concat(this.name, "] Execution finished."));
726
+ (_this_options_logger4 = this.options.logger) === null || _this_options_logger4 === void 0 ? void 0 : _this_options_logger4.debug('Execution finished', {
727
+ agent: this.name
728
+ });
721
729
  // When no schema is provided, we assume TOutput is string (default), so message is the result
722
730
  return [
723
731
  2,
@@ -726,7 +734,8 @@ var SYSTEM_PROMPT_TEMPLATE = '\n<OBJECTIVE>\n{mission_prompt}\n</OBJECTIVE>\n\n<
726
734
  }
727
735
  case 4:
728
736
  error = _state.sent();
729
- (_this_options_logger5 = this.options.logger) === null || _this_options_logger5 === void 0 ? void 0 : _this_options_logger5.error("[".concat(this.name, "] Chat execution failed."), {
737
+ (_this_options_logger5 = this.options.logger) === null || _this_options_logger5 === void 0 ? void 0 : _this_options_logger5.error('Chat execution failed', {
738
+ agent: this.name,
730
739
  error: _instanceof$2(error, Error) ? error.message : 'Unknown error'
731
740
  });
732
741
  return [
@@ -823,7 +832,8 @@ var SYSTEM_PROMPT_TEMPLATE = '\n<OBJECTIVE>\n{mission_prompt}\n</OBJECTIVE>\n\n<
823
832
  shouldRespond: false
824
833
  };
825
834
  }
826
- (_this_options_logger = this.options.logger) === null || _this_options_logger === void 0 ? void 0 : _this_options_logger.error("[".concat(this.name, "] Agent output was missing 'RESPOND:' or 'SILENT:' prefix."), {
835
+ (_this_options_logger = this.options.logger) === null || _this_options_logger === void 0 ? void 0 : _this_options_logger.error("Agent output was missing 'RESPOND:' or 'SILENT:' prefix.", {
836
+ agent: this.name,
827
837
  rawOutput: output
828
838
  });
829
839
  return null;
@@ -845,7 +855,8 @@ var SYSTEM_PROMPT_TEMPLATE = '\n<OBJECTIVE>\n{mission_prompt}\n</OBJECTIVE>\n\n<
845
855
  return new AIResponseParser(schema).parse(content);
846
856
  } catch (error) {
847
857
  var _this_options_logger;
848
- (_this_options_logger = this.options.logger) === null || _this_options_logger === void 0 ? void 0 : _this_options_logger.error("[".concat(this.name, "] Failed to validate response content against schema."), {
858
+ (_this_options_logger = this.options.logger) === null || _this_options_logger === void 0 ? void 0 : _this_options_logger.error('Failed to validate response content against schema.', {
859
+ agent: this.name,
849
860
  error: _instanceof$2(error, Error) ? error.message : 'Unknown error',
850
861
  rawContent: content
851
862
  });
@@ -1036,7 +1047,9 @@ function _ts_generator$1(thisArg, body) {
1036
1047
  return _ts_generator$1(this, function(_state) {
1037
1048
  switch(_state.label){
1038
1049
  case 0:
1039
- (_this_options_logger = this.options.logger) === null || _this_options_logger === void 0 ? void 0 : _this_options_logger.debug("[".concat(this.name, "] Starting query execution."));
1050
+ (_this_options_logger = this.options.logger) === null || _this_options_logger === void 0 ? void 0 : _this_options_logger.debug('Starting query execution', {
1051
+ agent: this.name
1052
+ });
1040
1053
  _state.label = 1;
1041
1054
  case 1:
1042
1055
  _state.trys.push([
@@ -1053,13 +1066,17 @@ function _ts_generator$1(thisArg, body) {
1053
1066
  content = _state.sent();
1054
1067
  if (this.options.schema) {
1055
1068
  parsedResponse = this.parseResponse(content, this.options.schema);
1056
- (_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."));
1069
+ (_this_options_logger1 = this.options.logger) === null || _this_options_logger1 === void 0 ? void 0 : _this_options_logger1.debug('Execution finished and response parsed', {
1070
+ agent: this.name
1071
+ });
1057
1072
  return [
1058
1073
  2,
1059
1074
  parsedResponse
1060
1075
  ];
1061
1076
  } else {
1062
- (_this_options_logger2 = this.options.logger) === null || _this_options_logger2 === void 0 ? void 0 : _this_options_logger2.info("[".concat(this.name, "] Execution finished."));
1077
+ (_this_options_logger2 = this.options.logger) === null || _this_options_logger2 === void 0 ? void 0 : _this_options_logger2.debug('Execution finished', {
1078
+ agent: this.name
1079
+ });
1063
1080
  // When no schema is provided, we assume TOutput is string (default), so content is the result
1064
1081
  return [
1065
1082
  2,
@@ -1068,7 +1085,8 @@ function _ts_generator$1(thisArg, body) {
1068
1085
  }
1069
1086
  case 3:
1070
1087
  error = _state.sent();
1071
- (_this_options_logger3 = this.options.logger) === null || _this_options_logger3 === void 0 ? void 0 : _this_options_logger3.error("[".concat(this.name, "] Execution failed."), {
1088
+ (_this_options_logger3 = this.options.logger) === null || _this_options_logger3 === void 0 ? void 0 : _this_options_logger3.error('Execution failed', {
1089
+ agent: this.name,
1072
1090
  error: _instanceof$1(error, Error) ? error.message : 'Unknown error'
1073
1091
  });
1074
1092
  return [
@@ -1119,11 +1137,13 @@ function _ts_generator$1(thisArg, body) {
1119
1137
  role: 'user'
1120
1138
  }
1121
1139
  ];
1122
- (_this_options_logger = this.options.logger) === null || _this_options_logger === void 0 ? void 0 : _this_options_logger.debug("[".concat(this.name, "] Invoking model..."), {
1140
+ (_this_options_logger = this.options.logger) === null || _this_options_logger === void 0 ? void 0 : _this_options_logger.debug('Invoking model...', {
1141
+ agent: this.name,
1123
1142
  hasSchema: !!this.options.schema
1124
1143
  });
1125
1144
  if (this.options.verbose) {
1126
- (_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..."), {
1145
+ (_this_options_logger1 = this.options.logger) === null || _this_options_logger1 === void 0 ? void 0 : _this_options_logger1.debug('Sending messages to model...', {
1146
+ agent: this.name,
1127
1147
  messages: messages
1128
1148
  });
1129
1149
  }
@@ -1153,7 +1173,8 @@ function _ts_generator$1(thisArg, body) {
1153
1173
  return new AIResponseParser(schema).parse(content);
1154
1174
  } catch (error) {
1155
1175
  var _this_options_logger;
1156
- (_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."), {
1176
+ (_this_options_logger = this.options.logger) === null || _this_options_logger === void 0 ? void 0 : _this_options_logger.error('Failed to parse model response.', {
1177
+ agent: this.name,
1157
1178
  error: _instanceof$1(error, Error) ? error.message : 'Unknown error',
1158
1179
  rawContent: content
1159
1180
  });
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.5.0",
4
+ "version": "1.6.1",
5
5
  "exports": {
6
6
  ".": {
7
7
  "require": "./dist/index.cjs",