concevent-ai-agent-sdk 3.10.2 → 3.10.4

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.
@@ -1,7 +1,7 @@
1
1
  export { createAgent } from './core/agent.js';
2
2
  export type { Agent } from './core/agent.js';
3
3
  export { createOrchestratorAgent } from './core/orchestrator.js';
4
- export { PROMPT_SECURITY, PROMPT_DATA_ACCURACY, PROMPT_EFFICIENCY, PROMPT_PARALLEL_TOOL_CALLS, PROMPT_AUTONOMY, PROMPT_ERROR_HANDLING, PROMPT_FUNCTION_MEMORY, PROMPT_SUB_AGENT_DEFAULTS, PROMPT_ORCHESTRATOR_DELEGATE_ONLY, PROMPT_ORCHESTRATOR_NO_FABRICATION, PROMPT_ORCHESTRATOR_PARALLEL_DELEGATION, PROMPT_ORCHESTRATOR_DEFAULTS, } from './prompts/index.js';
4
+ export { PROMPT_SECURITY, PROMPT_DATA_ACCURACY, PROMPT_EFFICIENCY, PROMPT_PARALLEL_TOOL_CALLS, PROMPT_AUTONOMY, PROMPT_ERROR_HANDLING, PROMPT_FUNCTION_MEMORY, PROMPT_CONCISENESS, PROMPT_EMPTY_RESULTS, PROMPT_ENTITY_RESOLUTION, PROMPT_SUB_AGENT_DEFAULTS, PROMPT_ORCHESTRATOR_DELEGATE_ONLY, PROMPT_ORCHESTRATOR_NO_FABRICATION, PROMPT_ORCHESTRATOR_PARALLEL_DELEGATION, PROMPT_ORCHESTRATOR_NO_DUPLICATE_CALLS, PROMPT_ORCHESTRATOR_CONTEXT_FORWARDING, PROMPT_ORCHESTRATOR_RESPONSE_SYNTHESIS, PROMPT_ORCHESTRATOR_DEFAULTS, } from './prompts/index.js';
5
5
  export { createEvent } from './types/events.js';
6
6
  export { ENCRYPTED_REASONING_MARKER } from './core/openrouter-utils.js';
7
7
  export { AgentError, formatErrorTrace, isAbortError, AI_ERROR_CATEGORIES, formatAIError, } from './core/errors.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index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,EACV,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,eAAe,EACf,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAM1B,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACxE,YAAY,EACV,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,eAAe,EACf,gBAAgB,EAChB,cAAc,GACf,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,YAAY,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAGjE,OAAO,EAEL,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,0BAA0B,EAC1B,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,EAEzB,iCAAiC,EACjC,kCAAkC,EAClC,uCAAuC,EACvC,sCAAsC,EACtC,sCAAsC,EACtC,sCAAsC,EACtC,4BAA4B,GAC7B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAExE,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EACnB,aAAa,GACd,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExE,YAAY,EACV,eAAe,EACf,WAAW,EACX,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,WAAW,EACX,uBAAuB,EACvB,WAAW,EACX,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,WAAW,EACX,iB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AAQ,EACR,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,cAAc,EACd,WAAW,EACX,YAAY,EACZ,eAAe,EACf,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,UAAU,EACV,WAAW,EACX,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,eAAe,EACf,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAG1B,YAAY,EACV,UAAU,EACV,WAAW,EACX,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,eAAe,EACf,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAM1B,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACxE,YAAY,EACV,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,eAAe,EACf,gBAAgB,EAChB,cAAc,GACf,MAAM,sBAAsB,CAAC"}
package/dist/src/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  export { createAgent } from './core/agent.js';
2
2
  export { createOrchestratorAgent } from './core/orchestrator.js';
3
3
  // Prompts (reusable behavioral instructions for agents)
4
- export { PROMPT_SECURITY, PROMPT_DATA_ACCURACY, PROMPT_EFFICIENCY, PROMPT_PARALLEL_TOOL_CALLS, PROMPT_AUTONOMY, PROMPT_ERROR_HANDLING, PROMPT_FUNCTION_MEMORY, PROMPT_SUB_AGENT_DEFAULTS, PROMPT_ORCHESTRATOR_DELEGATE_ONLY, PROMPT_ORCHESTRATOR_NO_FABRICATION, PROMPT_ORCHESTRATOR_PARALLEL_DELEGATION, PROMPT_ORCHESTRATOR_DEFAULTS, } from './prompts/index.js';
4
+ export {
5
+ // Sub-agent defaults (auto-injected)
6
+ PROMPT_SECURITY, PROMPT_DATA_ACCURACY, PROMPT_EFFICIENCY, PROMPT_PARALLEL_TOOL_CALLS, PROMPT_AUTONOMY, PROMPT_ERROR_HANDLING, PROMPT_FUNCTION_MEMORY, PROMPT_CONCISENESS, PROMPT_EMPTY_RESULTS, PROMPT_ENTITY_RESOLUTION, PROMPT_SUB_AGENT_DEFAULTS,
7
+ // Orchestrator defaults (auto-injected)
8
+ PROMPT_ORCHESTRATOR_DELEGATE_ONLY, PROMPT_ORCHESTRATOR_NO_FABRICATION, PROMPT_ORCHESTRATOR_PARALLEL_DELEGATION, PROMPT_ORCHESTRATOR_NO_DUPLICATE_CALLS, PROMPT_ORCHESTRATOR_CONTEXT_FORWARDING, PROMPT_ORCHESTRATOR_RESPONSE_SYNTHESIS, PROMPT_ORCHESTRATOR_DEFAULTS, } from './prompts/index.js';
5
9
  export { createEvent } from './types/events.js';
6
10
  export { ENCRYPTED_REASONING_MARKER } from './core/openrouter-utils.js';
7
11
  export { AgentError, formatErrorTrace, isAbortError, AI_ERROR_CATEGORIES, formatAIError, } from './core/errors.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,wDAAwD;AACxD,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,0BAA0B,EAC1B,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,yBAAyB,EACzB,iCAAiC,EACjC,kCAAkC,EAClC,uCAAuC,EACvC,4BAA4B,GAC7B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAExE,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EACnB,aAAa,GACd,MAAM,kBAAkB,CAAC;AA2D1B,OAAO,EACL,iCAAiC,EACjC,8BA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,UAAU,EACV,eAAe,EACf,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAiB1B,+EAA+E;AAC/E,2CAA2C;AAC3C,+EAA+E;AAE/E,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -1,3 +1,3 @@
1
- export { PROMPT_SECURITY, PROMPT_DATA_ACCURACY, PROMPT_EFFICIENCY, PROMPT_PARALLEL_TOOL_CALLS, PROMPT_AUTONOMY, PROMPT_ERROR_HANDLING, PROMPT_FUNCTION_MEMORY, PROMPT_SUB_AGENT_DEFAULTS, } from './sub-agent.js';
2
- export { PROMPT_ORCHESTRATOR_DELEGATE_ONLY, PROMPT_ORCHESTRATOR_NO_FABRICATION, PROMPT_ORCHESTRATOR_PARALLEL_DELEGATION, PROMPT_ORCHESTRATOR_NO_DUPLICATE_CALLS, PROMPT_ORCHESTRATOR_DEFAULTS, } from './orchestrator.js';
1
+ export { PROMPT_SECURITY, PROMPT_DATA_ACCURACY, PROMPT_EFFICIENCY, PROMPT_PARALLEL_TOOL_CALLS, PROMPT_AUTONOMY, PROMPT_ERROR_HANDLING, PROMPT_FUNCTION_MEMORY, PROMPT_CONCISENESS, PROMPT_EMPTY_RESULTS, PROMPT_ENTITY_RESOLUTION, PROMPT_SUB_AGENT_DEFAULTS, } from './sub-agent.js';
2
+ export { PROMPT_ORCHESTRATOR_DELEGATE_ONLY, PROMPT_ORCHESTRATOR_NO_FABRICATION, PROMPT_ORCHESTRATOR_PARALLEL_DELEGATION, PROMPT_ORCHESTRATOR_NO_DUPLICATE_CALLS, PROMPT_ORCHESTRATOR_CONTEXT_FORWARDING, PROMPT_ORCHESTRATOR_RESPONSE_SYNTHESIS, PROMPT_ORCHESTRATOR_DEFAULTS, } from './orchestrator.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/prompts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,0BAA0B,EAC1B,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,iCAAiC,EACjC,kCAAkC,EAClC,uCAAuC,EACvC,sCAAsC,EACtC,4BAA4B,GAC7B,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/prompts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,0BAA0B,EAC1B,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,iCAAiC,EACjC,kCAAkC,EAClC,uCAAuC,EACvC,sCAAsC,EACtC,sCAAsC,EACtC,sCAAsC,EACtC,4BAA4B,GAC7B,MAAM,mBAAmB,CAAC"}
@@ -1,3 +1,3 @@
1
- export { PROMPT_SECURITY, PROMPT_DATA_ACCURACY, PROMPT_EFFICIENCY, PROMPT_PARALLEL_TOOL_CALLS, PROMPT_AUTONOMY, PROMPT_ERROR_HANDLING, PROMPT_FUNCTION_MEMORY, PROMPT_SUB_AGENT_DEFAULTS, } from './sub-agent.js';
2
- export { PROMPT_ORCHESTRATOR_DELEGATE_ONLY, PROMPT_ORCHESTRATOR_NO_FABRICATION, PROMPT_ORCHESTRATOR_PARALLEL_DELEGATION, PROMPT_ORCHESTRATOR_NO_DUPLICATE_CALLS, PROMPT_ORCHESTRATOR_DEFAULTS, } from './orchestrator.js';
1
+ export { PROMPT_SECURITY, PROMPT_DATA_ACCURACY, PROMPT_EFFICIENCY, PROMPT_PARALLEL_TOOL_CALLS, PROMPT_AUTONOMY, PROMPT_ERROR_HANDLING, PROMPT_FUNCTION_MEMORY, PROMPT_CONCISENESS, PROMPT_EMPTY_RESULTS, PROMPT_ENTITY_RESOLUTION, PROMPT_SUB_AGENT_DEFAULTS, } from './sub-agent.js';
2
+ export { PROMPT_ORCHESTRATOR_DELEGATE_ONLY, PROMPT_ORCHESTRATOR_NO_FABRICATION, PROMPT_ORCHESTRATOR_PARALLEL_DELEGATION, PROMPT_ORCHESTRATOR_NO_DUPLICATE_CALLS, PROMPT_ORCHESTRATOR_CONTEXT_FORWARDING, PROMPT_ORCHESTRATOR_RESPONSE_SYNTHESIS, PROMPT_ORCHESTRATOR_DEFAULTS, } from './orchestrator.js';
3
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/prompts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,0BAA0B,EAC1B,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,iCAAiC,EACjC,kCAAkC,EAClC,uCAAuC,EACvC,sCAAsC,EACtC,4BAA4B,GAC7B,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/prompts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,0BAA0B,EAC1B,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,iCAAiC,EACjC,kCAAkC,EAClC,uCAAuC,EACvC,sCAAsC,EACtC,sCAAsC,EACtC,sCAAsC,EACtC,4BAA4B,GAC7B,MAAM,mBAAmB,CAAC"}
@@ -6,5 +6,7 @@ export declare const PROMPT_ORCHESTRATOR_DELEGATE_ONLY = "## Delegate Only\n- Ne
6
6
  export declare const PROMPT_ORCHESTRATOR_NO_FABRICATION = "## No Fabrication\n- If a sub-agent returns \"no data\" or an empty list, that is the final answer.\n- Never fabricate, generate, or imagine data that was not returned by a sub-agent.\n- If there are no results, tell the user clearly that no data was found.";
7
7
  export declare const PROMPT_ORCHESTRATOR_PARALLEL_DELEGATION = "## Parallel Delegation\n- When multiple sub-agents are needed and they are independent of each other, call them in parallel.";
8
8
  export declare const PROMPT_ORCHESTRATOR_NO_DUPLICATE_CALLS = "## No Duplicate Calls\n- Never call the same sub-agent more than once in a single response.\n- If you need a sub-agent to handle multiple aspects, send one comprehensive message covering everything.\n- Calling the same agent multiple times wastes resources and may cause errors.";
9
+ export declare const PROMPT_ORCHESTRATOR_CONTEXT_FORWARDING = "## Context Forwarding\n- When delegating to a sub-agent, always include the full relevant context from the user's request.\n- Sub-agents have no prior conversation history \u2014 they only know what you include in your delegation message.";
10
+ export declare const PROMPT_ORCHESTRATOR_RESPONSE_SYNTHESIS = "## Response Synthesis\n- After receiving sub-agent responses, synthesize them into a single coherent answer.\n- Do not simply concatenate sub-agent outputs \u2014 integrate, deduplicate, and organize the information.";
9
11
  export declare const PROMPT_ORCHESTRATOR_DEFAULTS: string;
10
12
  //# sourceMappingURL=orchestrator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../../src/prompts/orchestrator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,iCAAiC,qPAE0C,CAAC;AAEzF,eAAO,MAAM,kCAAkC,sQAG0B,CAAC;AAE1E,eAAO,MAAM,uCAAuC,iIACiD,CAAC;AAEtG,eAAO,MAAM,sCAAsC,2RAG4B,CAAC;AAEhF,eAAO,MAAM,4BAA4B,QAK3B,CAAC"}
1
+ {"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../../src/prompts/orchestrator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,iCAAiC,qPAE0C,CAAC;AAEzF,eAAO,MAAM,kCAAkC,sQAG0B,CAAC;AAE1E,eAAO,MAAM,uCAAuC,iIACiD,CAAC;AAEtG,eAAO,MAAM,sCAAsC,2RAG4B,CAAC;AAEhF,eAAO,MAAM,sCAAsC,mPAE2D,CAAC;AAE/G,eAAO,MAAM,sCAAsC,6NAEmD,CAAC;AAEvG,eAAO,MAAM,4BAA4B,QAO3B,CAAC"}
@@ -15,10 +15,18 @@ export const PROMPT_ORCHESTRATOR_NO_DUPLICATE_CALLS = `## No Duplicate Calls
15
15
  - Never call the same sub-agent more than once in a single response.
16
16
  - If you need a sub-agent to handle multiple aspects, send one comprehensive message covering everything.
17
17
  - Calling the same agent multiple times wastes resources and may cause errors.`;
18
+ export const PROMPT_ORCHESTRATOR_CONTEXT_FORWARDING = `## Context Forwarding
19
+ - When delegating to a sub-agent, always include the full relevant context from the user's request.
20
+ - Sub-agents have no prior conversation history — they only know what you include in your delegation message.`;
21
+ export const PROMPT_ORCHESTRATOR_RESPONSE_SYNTHESIS = `## Response Synthesis
22
+ - After receiving sub-agent responses, synthesize them into a single coherent answer.
23
+ - Do not simply concatenate sub-agent outputs — integrate, deduplicate, and organize the information.`;
18
24
  export const PROMPT_ORCHESTRATOR_DEFAULTS = [
19
25
  PROMPT_ORCHESTRATOR_DELEGATE_ONLY,
20
26
  PROMPT_ORCHESTRATOR_NO_FABRICATION,
21
27
  PROMPT_ORCHESTRATOR_PARALLEL_DELEGATION,
22
28
  PROMPT_ORCHESTRATOR_NO_DUPLICATE_CALLS,
29
+ PROMPT_ORCHESTRATOR_CONTEXT_FORWARDING,
30
+ PROMPT_ORCHESTRATOR_RESPONSE_SYNTHESIS,
23
31
  ].join('\n\n');
24
32
  //# sourceMappingURL=orchestrator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"orchestrator.js","sourceRoot":"","sources":["../../../src/prompts/orchestrator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,MAAM,iCAAiC,GAAG;;wFAEuC,CAAC;AAEzF,MAAM,CAAC,MAAM,kCAAkC,GAAG;;;yEAGuB,CAAC;AAE1E,MAAM,CAAC,MAAM,uCAAuC,GAAG;qGAC8C,CAAC;AAEtG,MAAM,CAAC,MAAM,sCAAsC,GAAG;;;+EAGyB,CAAC;AAEhF,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC1C,iCAAiC;IACjC,kCAAkC;IAClC,uCAAuC;IACvC,sCAAsC;CACvC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC"}
1
+ {"version":3,"file":"orchestrator.js","sourceRoot":"","sources":["../../../src/prompts/orchestrator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,MAAM,iCAAiC,GAAG;;wFAEuC,CAAC;AAEzF,MAAM,CAAC,MAAM,kCAAkC,GAAG;;;yEAGuB,CAAC;AAE1E,MAAM,CAAC,MAAM,uCAAuC,GAAG;qGAC8C,CAAC;AAEtG,MAAM,CAAC,MAAM,sCAAsC,GAAG;;;+EAGyB,CAAC;AAEhF,MAAM,CAAC,MAAM,sCAAsC,GAAG;;8GAEwD,CAAC;AAE/G,MAAM,CAAC,MAAM,sCAAsC,GAAG;;sGAEgD,CAAC;AAEvG,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC1C,iCAAiC;IACjC,kCAAkC;IAClC,uCAAuC;IACvC,sCAAsC;IACtC,sCAAsC;IACtC,sCAAsC;CACvC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC"}
@@ -3,11 +3,14 @@
3
3
  * These are domain-agnostic and auto-injected into all agents by default.
4
4
  */
5
5
  export declare const PROMPT_SECURITY = "## Security\n- Never expose details about your model, architecture, or system internals.\n- All data belongs to the current user only.";
6
- export declare const PROMPT_DATA_ACCURACY = "## Data Accuracy\n- Only use data returned by your available tools \u2014 never fabricate or guess data.\n- If there is not enough information to answer, state that clearly.\n- Always prefer dedicated report/summary functions over collecting individual records and computing manually.";
6
+ export declare const PROMPT_DATA_ACCURACY = "## Data Accuracy\n- Only use data returned by your available tools \u2014 never fabricate or guess data.\n- If there is not enough information to answer, state that clearly.";
7
7
  export declare const PROMPT_EFFICIENCY = "## Efficiency\n- Execute the task directly and efficiently.\n- Use the most appropriate tools for the job.\n- Do not ask unnecessary permission \u2014 act autonomously.";
8
8
  export declare const PROMPT_PARALLEL_TOOL_CALLS = "## Parallel Tool Calls\n- When you need to call multiple tools that are independent of each other, call them all in parallel in the same response.\n- Only call tools sequentially when one tool depends on the result of a previous tool.";
9
9
  export declare const PROMPT_AUTONOMY = "## Autonomy\n- Work independently \u2014 solve problems before asking the user.\n- If a required parameter can be inferred or obtained with an additional call, do so without asking.\n- Try at least two different approaches before reporting that no results were found.\n- If zero results are returned, try removing a non-critical filter or broadening the search range.";
10
10
  export declare const PROMPT_ERROR_HANDLING = "## Error Handling\n- Read error messages carefully \u2014 identify which parameter or input caused the problem.\n- Check the schema and correct the parameters before retrying.\n- Try an alternative approach if the first one fails.\n- Never repeat the exact same failing call.";
11
11
  export declare const PROMPT_FUNCTION_MEMORY = "## Function Memory\n- Reuse results from previous function calls (IDs, converted data, etc.).\n- Do not re-request information you have already received.";
12
+ export declare const PROMPT_CONCISENESS = "## Conciseness\n- Lead with the answer or result, not with preamble or restatement of the question.\n- Omit filler phrases like \"Sure!\", \"Of course!\", \"Great question!\" unless conversational tone is explicitly requested.";
13
+ export declare const PROMPT_EMPTY_RESULTS = "## Empty Results\n- When a search or query returns no results, tell the user clearly that nothing was found.\n- Include what was searched for and any filters that were applied, so the user can adjust.";
14
+ export declare const PROMPT_ENTITY_RESOLUTION = "## Entity Resolution\n- When the user refers to an entity by name, search for it by name rather than guessing an identifier.\n- If multiple matches are found, present the options and let the user choose.";
12
15
  export declare const PROMPT_SUB_AGENT_DEFAULTS: string;
13
16
  //# sourceMappingURL=sub-agent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sub-agent.d.ts","sourceRoot":"","sources":["../../../src/prompts/sub-agent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,eAAe,2IAEiB,CAAC;AAE9C,eAAO,MAAM,oBAAoB,iSAG6E,CAAC;AAE/G,eAAO,MAAM,iBAAiB,6KAG0B,CAAC;AAEzD,eAAO,MAAM,0BAA0B,+OAEgD,CAAC;AAExF,eAAO,MAAM,eAAe,oXAIuE,CAAC;AAEpG,eAAO,MAAM,qBAAqB,wRAIU,CAAC;AAE7C,eAAO,MAAM,sBAAsB,8JAEwB,CAAC;AAE5D,eAAO,MAAM,yBAAyB,QAQxB,CAAC"}
1
+ {"version":3,"file":"sub-agent.d.ts","sourceRoot":"","sources":["../../../src/prompts/sub-agent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,eAAe,2IAEiB,CAAC;AAE9C,eAAO,MAAM,oBAAoB,kLAEmC,CAAC;AAErE,eAAO,MAAM,iBAAiB,6KAG0B,CAAC;AAEzD,eAAO,MAAM,0BAA0B,+OAEgD,CAAC;AAExF,eAAO,MAAM,eAAe,oXAIuE,CAAC;AAEpG,eAAO,MAAM,qBAAqB,wRAIU,CAAC;AAE7C,eAAO,MAAM,sBAAsB,8JAEwB,CAAC;AAE5D,eAAO,MAAM,kBAAkB,uOAEyF,CAAC;AAEzH,eAAO,MAAM,oBAAoB,6MAE0D,CAAC;AAE5F,eAAO,MAAM,wBAAwB,gNAEyC,CAAC;AAE/E,eAAO,MAAM,yBAAyB,QAWxB,CAAC"}
@@ -7,8 +7,7 @@ export const PROMPT_SECURITY = `## Security
7
7
  - All data belongs to the current user only.`;
8
8
  export const PROMPT_DATA_ACCURACY = `## Data Accuracy
9
9
  - Only use data returned by your available tools — never fabricate or guess data.
10
- - If there is not enough information to answer, state that clearly.
11
- - Always prefer dedicated report/summary functions over collecting individual records and computing manually.`;
10
+ - If there is not enough information to answer, state that clearly.`;
12
11
  export const PROMPT_EFFICIENCY = `## Efficiency
13
12
  - Execute the task directly and efficiently.
14
13
  - Use the most appropriate tools for the job.
@@ -29,6 +28,15 @@ export const PROMPT_ERROR_HANDLING = `## Error Handling
29
28
  export const PROMPT_FUNCTION_MEMORY = `## Function Memory
30
29
  - Reuse results from previous function calls (IDs, converted data, etc.).
31
30
  - Do not re-request information you have already received.`;
31
+ export const PROMPT_CONCISENESS = `## Conciseness
32
+ - Lead with the answer or result, not with preamble or restatement of the question.
33
+ - Omit filler phrases like "Sure!", "Of course!", "Great question!" unless conversational tone is explicitly requested.`;
34
+ export const PROMPT_EMPTY_RESULTS = `## Empty Results
35
+ - When a search or query returns no results, tell the user clearly that nothing was found.
36
+ - Include what was searched for and any filters that were applied, so the user can adjust.`;
37
+ export const PROMPT_ENTITY_RESOLUTION = `## Entity Resolution
38
+ - When the user refers to an entity by name, search for it by name rather than guessing an identifier.
39
+ - If multiple matches are found, present the options and let the user choose.`;
32
40
  export const PROMPT_SUB_AGENT_DEFAULTS = [
33
41
  PROMPT_SECURITY,
34
42
  PROMPT_DATA_ACCURACY,
@@ -37,5 +45,8 @@ export const PROMPT_SUB_AGENT_DEFAULTS = [
37
45
  PROMPT_AUTONOMY,
38
46
  PROMPT_ERROR_HANDLING,
39
47
  PROMPT_FUNCTION_MEMORY,
48
+ PROMPT_CONCISENESS,
49
+ PROMPT_EMPTY_RESULTS,
50
+ PROMPT_ENTITY_RESOLUTION,
40
51
  ].join('\n\n');
41
52
  //# sourceMappingURL=sub-agent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sub-agent.js","sourceRoot":"","sources":["../../../src/prompts/sub-agent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG;;6CAEc,CAAC;AAE9C,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;8GAG0E,CAAC;AAE/G,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;wDAGuB,CAAC;AAEzD,MAAM,CAAC,MAAM,0BAA0B,GAAG;;uFAE6C,CAAC;AAExF,MAAM,CAAC,MAAM,eAAe,GAAG;;;;mGAIoE,CAAC;AAEpG,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;4CAIO,CAAC;AAE7C,MAAM,CAAC,MAAM,sBAAsB,GAAG;;2DAEqB,CAAC;AAE5D,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,eAAe;IACf,oBAAoB;IACpB,iBAAiB;IACjB,0BAA0B;IAC1B,eAAe;IACf,qBAAqB;IACrB,sBAAsB;CACvB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC"}
1
+ {"version":3,"file":"sub-agent.js","sourceRoot":"","sources":["../../../src/prompts/sub-agent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG;;6CAEc,CAAC;AAE9C,MAAM,CAAC,MAAM,oBAAoB,GAAG;;oEAEgC,CAAC;AAErE,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;wDAGuB,CAAC;AAEzD,MAAM,CAAC,MAAM,0BAA0B,GAAG;;uFAE6C,CAAC;AAExF,MAAM,CAAC,MAAM,eAAe,GAAG;;;;mGAIoE,CAAC;AAEpG,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;4CAIO,CAAC;AAE7C,MAAM,CAAC,MAAM,sBAAsB,GAAG;;2DAEqB,CAAC;AAE5D,MAAM,CAAC,MAAM,kBAAkB,GAAG;;wHAEsF,CAAC;AAEzH,MAAM,CAAC,MAAM,oBAAoB,GAAG;;2FAEuD,CAAC;AAE5F,MAAM,CAAC,MAAM,wBAAwB,GAAG;;8EAEsC,CAAC;AAE/E,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,eAAe;IACf,oBAAoB;IACpB,iBAAiB;IACjB,0BAA0B;IAC1B,eAAe;IACf,qBAAqB;IACrB,sBAAsB;IACtB,kBAAkB;IAClB,oBAAoB;IACpB,wBAAwB;CACzB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC"}
@@ -1,8 +1,8 @@
1
1
  import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
2
2
  import OpenAI from 'openai';
3
3
  import { z } from 'zod';
4
- import { createAgent, createEvent, ENCRYPTED_REASONING_MARKER } from '../src/index.js';
5
- import { createMockTools, createFailingTool, createParallelTools, createTimedParallelTools, } from './mocks/tools.js';
4
+ import { createAgent, createEvent, ENCRYPTED_REASONING_MARKER, AgentError, formatErrorTrace, isAbortError, formatAIError, AI_ERROR_CATEGORIES, ToolExecutionTimeoutError, } from '../src/index.js';
5
+ import { createMockTools, createFailingTool, createParallelTools, createTimedParallelTools, createLargeResultTool, createBashLikeResultTool, createGrepLikeResultTool, createGlobLikeResultTool, createReadLikeResultTool, } from './mocks/tools.js';
6
6
  vi.mock('openai');
7
7
  function createMockOpenAIClient() {
8
8
  return {
@@ -4009,4 +4009,420 @@ describe('createAgent - image input', () => {
4009
4009
  }
4010
4010
  });
4011
4011
  });
4012
+ // ============================================================================
4013
+ // 1A. Result storage integration (tool-executor.ts coverage)
4014
+ // ============================================================================
4015
+ describe('createAgent - result storage integration', () => {
4016
+ let mockClient;
4017
+ beforeEach(() => {
4018
+ mockClient = createMockOpenAIClient();
4019
+ vi.mocked(OpenAI).mockImplementation(() => mockClient);
4020
+ });
4021
+ afterEach(() => {
4022
+ vi.clearAllMocks();
4023
+ });
4024
+ it('should store large tool results and include storage message in history', async () => {
4025
+ const agent = createAgent(createTestConfig({
4026
+ tools: [createLargeResultTool(200)],
4027
+ resultStorage: { enabled: true, sizeThresholdBytes: 50 },
4028
+ stream: false,
4029
+ }));
4030
+ // First call: LLM calls the tool
4031
+ mockClient.chat.completions.create.mockResolvedValueOnce(createMockResponse(null, [
4032
+ {
4033
+ id: 'call-large-1',
4034
+ type: 'function',
4035
+ function: { name: 'largeResultTool', arguments: '{}' },
4036
+ },
4037
+ ]));
4038
+ // Second call: LLM final response
4039
+ mockClient.chat.completions.create.mockResolvedValueOnce(createMockResponse('Here is the result summary'));
4040
+ const result = await agent.chat('Run the tool', createTestContext());
4041
+ expect(result.message).toBe('Here is the result summary');
4042
+ // Check that the conversation history contains the storage message
4043
+ const history = result.conversationHistory;
4044
+ const storageMessage = history.find((m) => m.role === 'tool-call-results' && m.content?.includes('Result of largeResultTool stored'));
4045
+ expect(storageMessage).toBeDefined();
4046
+ expect(storageMessage.content).toContain('ID:');
4047
+ expect(storageMessage.content).toContain('ReadResult');
4048
+ });
4049
+ it('should include Bash exit code summary in stored result message', async () => {
4050
+ const agent = createAgent(createTestConfig({
4051
+ tools: [createBashLikeResultTool()],
4052
+ resultStorage: { enabled: true, sizeThresholdBytes: 50 },
4053
+ stream: false,
4054
+ }));
4055
+ mockClient.chat.completions.create.mockResolvedValueOnce(createMockResponse(null, [
4056
+ {
4057
+ id: 'call-bash-1',
4058
+ type: 'function',
4059
+ function: { name: 'Bash', arguments: '{}' },
4060
+ },
4061
+ ]));
4062
+ mockClient.chat.completions.create.mockResolvedValueOnce(createMockResponse('Command completed'));
4063
+ const result = await agent.chat('Run bash', createTestContext());
4064
+ const history = result.conversationHistory;
4065
+ const storageMessage = history.find((m) => m.role === 'tool-call-results' && m.content?.includes('Result of Bash stored'));
4066
+ expect(storageMessage).toBeDefined();
4067
+ expect(storageMessage.content).toContain('Exit code: 0');
4068
+ expect(storageMessage.content).toContain('(success)');
4069
+ });
4070
+ it('should include Grep match count summary in stored result message', async () => {
4071
+ const agent = createAgent(createTestConfig({
4072
+ tools: [createGrepLikeResultTool()],
4073
+ resultStorage: { enabled: true, sizeThresholdBytes: 50 },
4074
+ stream: false,
4075
+ }));
4076
+ mockClient.chat.completions.create.mockResolvedValueOnce(createMockResponse(null, [
4077
+ {
4078
+ id: 'call-grep-1',
4079
+ type: 'function',
4080
+ function: { name: 'Grep', arguments: '{}' },
4081
+ },
4082
+ ]));
4083
+ mockClient.chat.completions.create.mockResolvedValueOnce(createMockResponse('Found matches'));
4084
+ const result = await agent.chat('Search files', createTestContext());
4085
+ const history = result.conversationHistory;
4086
+ const storageMessage = history.find((m) => m.role === 'tool-call-results' && m.content?.includes('Result of Grep stored'));
4087
+ expect(storageMessage).toBeDefined();
4088
+ expect(storageMessage.content).toContain('Found 5 match(es)');
4089
+ expect(storageMessage.content).toContain('in 3 file(s)');
4090
+ });
4091
+ it('should include Glob count summary in stored result message', async () => {
4092
+ const agent = createAgent(createTestConfig({
4093
+ tools: [createGlobLikeResultTool()],
4094
+ resultStorage: { enabled: true, sizeThresholdBytes: 50 },
4095
+ stream: false,
4096
+ }));
4097
+ mockClient.chat.completions.create.mockResolvedValueOnce(createMockResponse(null, [
4098
+ {
4099
+ id: 'call-glob-1',
4100
+ type: 'function',
4101
+ function: { name: 'Glob', arguments: '{}' },
4102
+ },
4103
+ ]));
4104
+ mockClient.chat.completions.create.mockResolvedValueOnce(createMockResponse('Found files'));
4105
+ const result = await agent.chat('Find files', createTestContext());
4106
+ const history = result.conversationHistory;
4107
+ const storageMessage = history.find((m) => m.role === 'tool-call-results' && m.content?.includes('Result of Glob stored'));
4108
+ expect(storageMessage).toBeDefined();
4109
+ expect(storageMessage.content).toContain('Found 42 file(s)');
4110
+ });
4111
+ it('should include Read total lines summary in stored result message', async () => {
4112
+ const agent = createAgent(createTestConfig({
4113
+ tools: [createReadLikeResultTool()],
4114
+ resultStorage: { enabled: true, sizeThresholdBytes: 50 },
4115
+ stream: false,
4116
+ }));
4117
+ mockClient.chat.completions.create.mockResolvedValueOnce(createMockResponse(null, [
4118
+ {
4119
+ id: 'call-read-1',
4120
+ type: 'function',
4121
+ function: { name: 'Read', arguments: '{}' },
4122
+ },
4123
+ ]));
4124
+ mockClient.chat.completions.create.mockResolvedValueOnce(createMockResponse('File content'));
4125
+ const result = await agent.chat('Read file', createTestContext());
4126
+ const history = result.conversationHistory;
4127
+ const storageMessage = history.find((m) => m.role === 'tool-call-results' && m.content?.includes('Result of Read stored'));
4128
+ expect(storageMessage).toBeDefined();
4129
+ expect(storageMessage.content).toContain('File has 500 total lines');
4130
+ });
4131
+ it('should not store small tool results', async () => {
4132
+ const smallTool = {
4133
+ declaration: {
4134
+ name: 'smallTool',
4135
+ description: 'Returns small result',
4136
+ parametersJsonSchema: { type: 'object', properties: {} },
4137
+ },
4138
+ executor: async () => ({ ok: true }),
4139
+ };
4140
+ const agent = createAgent(createTestConfig({
4141
+ tools: [smallTool],
4142
+ resultStorage: { enabled: true, sizeThresholdBytes: 50000 },
4143
+ stream: false,
4144
+ }));
4145
+ mockClient.chat.completions.create.mockResolvedValueOnce(createMockResponse(null, [
4146
+ {
4147
+ id: 'call-small-1',
4148
+ type: 'function',
4149
+ function: { name: 'smallTool', arguments: '{}' },
4150
+ },
4151
+ ]));
4152
+ mockClient.chat.completions.create.mockResolvedValueOnce(createMockResponse('Done'));
4153
+ const result = await agent.chat('Do small thing', createTestContext());
4154
+ const history = result.conversationHistory;
4155
+ const resultMessage = history.find((m) => m.role === 'tool-call-results' && m.content?.includes('Result of smallTool'));
4156
+ expect(resultMessage).toBeDefined();
4157
+ // Should be inline, not stored
4158
+ expect(resultMessage.content).not.toContain('stored (ID:');
4159
+ expect(resultMessage.content).toContain('Result of smallTool:');
4160
+ });
4161
+ it('should show large result grep tip for results with 500+ lines', async () => {
4162
+ // Create a tool that returns a very large result (500+ lines worth)
4163
+ const hugeResultTool = {
4164
+ declaration: {
4165
+ name: 'hugeResultTool',
4166
+ description: 'Returns a huge result',
4167
+ parametersJsonSchema: { type: 'object', properties: {} },
4168
+ },
4169
+ executor: async () => {
4170
+ // Return a result that will produce 500+ lines when JSON.stringified
4171
+ return {
4172
+ lines: Array.from({ length: 600 }, (_, i) => `output line ${i + 1}`),
4173
+ };
4174
+ },
4175
+ };
4176
+ const agent = createAgent(createTestConfig({
4177
+ tools: [hugeResultTool],
4178
+ resultStorage: { enabled: true, sizeThresholdBytes: 50 },
4179
+ stream: false,
4180
+ }));
4181
+ mockClient.chat.completions.create.mockResolvedValueOnce(createMockResponse(null, [
4182
+ {
4183
+ id: 'call-huge-1',
4184
+ type: 'function',
4185
+ function: { name: 'hugeResultTool', arguments: '{}' },
4186
+ },
4187
+ ]));
4188
+ mockClient.chat.completions.create.mockResolvedValueOnce(createMockResponse('Huge result processed'));
4189
+ const result = await agent.chat('Run huge tool', createTestContext());
4190
+ const history = result.conversationHistory;
4191
+ const storageMessage = history.find((m) => m.role === 'tool-call-results' && m.content?.includes('Result of hugeResultTool stored'));
4192
+ expect(storageMessage).toBeDefined();
4193
+ // Should show the grep tip for large results
4194
+ expect(storageMessage.content).toContain('grep=');
4195
+ expect(storageMessage.content).toContain('Large result');
4196
+ });
4197
+ it('should include Bash failed exit code summary', async () => {
4198
+ const failedBashTool = {
4199
+ declaration: {
4200
+ name: 'Bash',
4201
+ description: 'Failed bash',
4202
+ parametersJsonSchema: { type: 'object', properties: {} },
4203
+ },
4204
+ executor: async () => ({
4205
+ exit_code: 1,
4206
+ success: false,
4207
+ stderr: 'x'.repeat(300),
4208
+ }),
4209
+ };
4210
+ const agent = createAgent(createTestConfig({
4211
+ tools: [failedBashTool],
4212
+ resultStorage: { enabled: true, sizeThresholdBytes: 50 },
4213
+ stream: false,
4214
+ }));
4215
+ mockClient.chat.completions.create.mockResolvedValueOnce(createMockResponse(null, [
4216
+ {
4217
+ id: 'call-bash-fail',
4218
+ type: 'function',
4219
+ function: { name: 'Bash', arguments: '{}' },
4220
+ },
4221
+ ]));
4222
+ mockClient.chat.completions.create.mockResolvedValueOnce(createMockResponse('Command failed'));
4223
+ const result = await agent.chat('Run bash', createTestContext());
4224
+ const history = result.conversationHistory;
4225
+ const storageMessage = history.find((m) => m.role === 'tool-call-results' && m.content?.includes('Result of Bash stored'));
4226
+ expect(storageMessage).toBeDefined();
4227
+ expect(storageMessage.content).toContain('Exit code: 1');
4228
+ expect(storageMessage.content).toContain('(failed)');
4229
+ });
4230
+ it('should handle result storage disabled', async () => {
4231
+ const agent = createAgent(createTestConfig({
4232
+ resultStorage: { enabled: false },
4233
+ stream: false,
4234
+ }));
4235
+ mockClient.chat.completions.create.mockResolvedValueOnce(createMockResponse(null, [
4236
+ {
4237
+ id: 'call-1',
4238
+ type: 'function',
4239
+ function: { name: 'getWeather', arguments: JSON.stringify({ city: 'London' }) },
4240
+ },
4241
+ ]));
4242
+ mockClient.chat.completions.create.mockResolvedValueOnce(createMockResponse('Weather is sunny'));
4243
+ const result = await agent.chat('Weather?', createTestContext());
4244
+ expect(result.message).toBe('Weather is sunny');
4245
+ // Tool result should be inline
4246
+ const toolResult = result.conversationHistory.find((m) => m.role === 'tool-call-results');
4247
+ expect(toolResult).toBeDefined();
4248
+ expect(toolResult.content).toContain('Result of getWeather:');
4249
+ });
4250
+ });
4251
+ // ============================================================================
4252
+ // 1C. AgentError.toJSON() (errors.ts coverage)
4253
+ // ============================================================================
4254
+ describe('AgentError', () => {
4255
+ it('should serialize to JSON with toJSON()', () => {
4256
+ const error = new AgentError('EMPTY_RESPONSE', 'Custom empty message');
4257
+ const json = error.toJSON();
4258
+ expect(json).toEqual({
4259
+ code: 'EMPTY_RESPONSE',
4260
+ message: 'Custom empty message',
4261
+ recoverable: false,
4262
+ });
4263
+ });
4264
+ it('should use default message when no custom message provided', () => {
4265
+ const error = new AgentError('GENERIC_ERROR');
4266
+ expect(error.message).toBe('An internal error occurred, please try again later');
4267
+ const json = error.toJSON();
4268
+ expect(json.code).toBe('GENERIC_ERROR');
4269
+ expect(json.recoverable).toBe(false);
4270
+ });
4271
+ it('should support recoverable flag', () => {
4272
+ const error = new AgentError('MAX_ITERATIONS', undefined, true);
4273
+ const json = error.toJSON();
4274
+ expect(json).toEqual({
4275
+ code: 'MAX_ITERATIONS',
4276
+ message: 'Maximum iterations reached. Please break down your request into smaller parts.',
4277
+ recoverable: true,
4278
+ });
4279
+ });
4280
+ it('should be an instance of Error', () => {
4281
+ const error = new AgentError('API_KEY_REQUIRED');
4282
+ expect(error).toBeInstanceOf(Error);
4283
+ expect(error.name).toBe('AgentError');
4284
+ });
4285
+ });
4286
+ // ============================================================================
4287
+ // 1D. Error utilities (errors.ts coverage)
4288
+ // ============================================================================
4289
+ describe('Error utilities', () => {
4290
+ describe('formatErrorTrace', () => {
4291
+ it('should wrap error in INTERNAL_ERROR_TRACE tags', () => {
4292
+ const error = new Error('Something went wrong');
4293
+ const trace = formatErrorTrace(error);
4294
+ expect(trace).toContain('<INTERNAL_ERROR_TRACE>');
4295
+ expect(trace).toContain('</INTERNAL_ERROR_TRACE>');
4296
+ expect(trace).toContain('Error: Something went wrong');
4297
+ });
4298
+ it('should include the error name', () => {
4299
+ const error = new TypeError('Invalid type');
4300
+ const trace = formatErrorTrace(error);
4301
+ expect(trace).toContain('TypeError: Invalid type');
4302
+ });
4303
+ });
4304
+ describe('isAbortError', () => {
4305
+ it('should return true for AbortError name', () => {
4306
+ const error = new Error('Operation aborted');
4307
+ error.name = 'AbortError';
4308
+ expect(isAbortError(error)).toBe(true);
4309
+ });
4310
+ it('should return true for abort message', () => {
4311
+ const error = new Error('Request aborted before processing');
4312
+ expect(isAbortError(error)).toBe(true);
4313
+ });
4314
+ it('should return false for non-abort error', () => {
4315
+ const error = new Error('Something else');
4316
+ expect(isAbortError(error)).toBe(false);
4317
+ });
4318
+ it('should return false for non-Error objects', () => {
4319
+ expect(isAbortError('not an error')).toBe(false);
4320
+ expect(isAbortError(null)).toBe(false);
4321
+ expect(isAbortError(undefined)).toBe(false);
4322
+ });
4323
+ });
4324
+ describe('formatAIError', () => {
4325
+ it('should format error with tool name and suggestion', () => {
4326
+ const message = formatAIError(AI_ERROR_CATEGORIES.TOOL_EXECUTION_ERROR, 'File not found', {
4327
+ toolName: 'Read',
4328
+ suggestion: 'Check the file path',
4329
+ });
4330
+ expect(message).toBe('[TOOL_EXECUTION_ERROR] for tool "Read": File not found\n\nSuggestion: Check the file path');
4331
+ });
4332
+ it('should format error without tool name', () => {
4333
+ const message = formatAIError(AI_ERROR_CATEGORIES.RESPONSE_VALIDATION, 'Invalid JSON');
4334
+ expect(message).toBe('[RESPONSE_VALIDATION]: Invalid JSON');
4335
+ });
4336
+ it('should format error without suggestion', () => {
4337
+ const message = formatAIError(AI_ERROR_CATEGORIES.TOOL_NOT_FOUND, 'Tool "xyz" not found', {
4338
+ toolName: 'xyz',
4339
+ });
4340
+ expect(message).toBe('[TOOL_NOT_FOUND] for tool "xyz": Tool "xyz" not found');
4341
+ });
4342
+ });
4343
+ describe('ToolExecutionTimeoutError', () => {
4344
+ it('should contain tool name and timeout', () => {
4345
+ const error = new ToolExecutionTimeoutError('myTool', 5000);
4346
+ expect(error.message).toContain('myTool');
4347
+ expect(error.message).toContain('5000');
4348
+ expect(error.toolName).toBe('myTool');
4349
+ expect(error.timeoutMs).toBe(5000);
4350
+ expect(error).toBeInstanceOf(Error);
4351
+ });
4352
+ });
4353
+ });
4354
+ // ============================================================================
4355
+ // 1E. API key format warning (openrouter-client.ts coverage)
4356
+ // ============================================================================
4357
+ describe('createAgent - API key format warning', () => {
4358
+ let mockClient;
4359
+ beforeEach(() => {
4360
+ mockClient = createMockOpenAIClient();
4361
+ vi.mocked(OpenAI).mockImplementation(() => mockClient);
4362
+ });
4363
+ afterEach(() => {
4364
+ vi.clearAllMocks();
4365
+ });
4366
+ it('should warn for non-OpenRouter API key format', () => {
4367
+ const consoleSpy = vi.spyOn(console, 'warn').mockImplementation(() => { });
4368
+ createAgent(createTestConfig({ apiKey: 'some-other-key' }));
4369
+ expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('does not appear to be a valid OpenRouter API key'));
4370
+ consoleSpy.mockRestore();
4371
+ });
4372
+ it('should not warn for valid OpenRouter API key format', () => {
4373
+ const consoleSpy = vi.spyOn(console, 'warn').mockImplementation(() => { });
4374
+ createAgent(createTestConfig({ apiKey: 'sk-or-v1-test-key-12345' }));
4375
+ expect(consoleSpy).not.toHaveBeenCalled();
4376
+ consoleSpy.mockRestore();
4377
+ });
4378
+ });
4379
+ // ============================================================================
4380
+ // 1F. Session abort lifecycle (session.ts coverage)
4381
+ // ============================================================================
4382
+ describe('createAgent - session abort lifecycle', () => {
4383
+ let mockClient;
4384
+ beforeEach(() => {
4385
+ mockClient = createMockOpenAIClient();
4386
+ vi.mocked(OpenAI).mockImplementation(() => mockClient);
4387
+ });
4388
+ afterEach(() => {
4389
+ vi.clearAllMocks();
4390
+ });
4391
+ it('should allow chat after aborting when no active chat', async () => {
4392
+ const agent = createAgent(createTestConfig());
4393
+ // Abort before any chat (no active AbortController)
4394
+ agent.abort();
4395
+ // Subsequent chat should still work
4396
+ mockClient.chat.completions.create.mockResolvedValueOnce(createMockResponse('Hello after abort'));
4397
+ const result = await agent.chat('Hello', createTestContext());
4398
+ expect(result.message).toBe('Hello after abort');
4399
+ });
4400
+ it('should fire onAborted callback during active chat abort', async () => {
4401
+ // Use real timers for this test
4402
+ vi.useRealTimers();
4403
+ const agent = createAgent(createTestConfig());
4404
+ // Make the API call hang long enough for us to abort
4405
+ mockClient.chat.completions.create.mockImplementation(() => new Promise((_, reject) => {
4406
+ setTimeout(() => {
4407
+ const error = new Error('Request aborted before processing');
4408
+ error.name = 'AbortError';
4409
+ reject(error);
4410
+ }, 50);
4411
+ }));
4412
+ const onAborted = vi.fn();
4413
+ // Start chat and abort after a short delay
4414
+ const chatPromise = agent.chat('Hello', createTestContext(), { onAborted });
4415
+ // Abort mid-execution
4416
+ setTimeout(() => agent.abort(), 10);
4417
+ try {
4418
+ await chatPromise;
4419
+ }
4420
+ catch {
4421
+ // Expected to throw
4422
+ }
4423
+ expect(onAborted).toHaveBeenCalled();
4424
+ // Restore fake timers for other tests
4425
+ vi.useFakeTimers();
4426
+ });
4427
+ });
4012
4428
  //# sourceMappingURL=agent.test.js.map