concevent-ai-agent-sdk 1.0.4 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +582 -2
- package/dist/core/agent.d.ts.map +1 -1
- package/dist/core/agent.js +153 -66
- package/dist/core/agent.js.map +1 -1
- package/dist/core/errors.d.ts +1 -1
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +4 -1
- package/dist/core/errors.js.map +1 -1
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/logger.d.ts +2 -0
- package/dist/core/logger.d.ts.map +1 -1
- package/dist/core/logger.js +8 -0
- package/dist/core/logger.js.map +1 -1
- package/dist/core/middleware.d.ts +55 -0
- package/dist/core/middleware.d.ts.map +1 -0
- package/dist/core/middleware.js +125 -0
- package/dist/core/middleware.js.map +1 -0
- package/dist/core/orchestrator.d.ts +31 -0
- package/dist/core/orchestrator.d.ts.map +1 -0
- package/dist/core/orchestrator.js +206 -0
- package/dist/core/orchestrator.js.map +1 -0
- package/dist/core/response-format.d.ts +44 -0
- package/dist/core/response-format.d.ts.map +1 -0
- package/dist/core/response-format.js +107 -0
- package/dist/core/response-format.js.map +1 -0
- package/dist/core/retry.d.ts +76 -0
- package/dist/core/retry.d.ts.map +1 -0
- package/dist/core/retry.js +164 -0
- package/dist/core/retry.js.map +1 -0
- package/dist/core/summarization.d.ts.map +1 -1
- package/dist/core/summarization.js +21 -3
- package/dist/core/summarization.js.map +1 -1
- package/dist/core/tool-executor.d.ts +18 -11
- package/dist/core/tool-executor.d.ts.map +1 -1
- package/dist/core/tool-executor.js +129 -18
- package/dist/core/tool-executor.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/types/config.d.ts +103 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js +5 -1
- package/dist/types/config.js.map +1 -1
- package/dist/types/events.d.ts +24 -1
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/events.js.map +1 -1
- package/dist/types/index.d.ts +5 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/middleware.d.ts +115 -0
- package/dist/types/middleware.d.ts.map +1 -0
- package/dist/types/middleware.js +2 -0
- package/dist/types/middleware.js.map +1 -0
- package/dist/types/orchestrator.d.ts +61 -0
- package/dist/types/orchestrator.d.ts.map +1 -0
- package/dist/types/orchestrator.js +2 -0
- package/dist/types/orchestrator.js.map +1 -0
- package/package.json +6 -1
package/dist/types/config.d.ts
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
import type { JsonSchema7Type } from 'zod-to-json-schema';
|
|
2
|
+
import type { ZodType } from 'zod';
|
|
2
3
|
import type { FunctionCallResult } from './messages.js';
|
|
4
|
+
import type { Middleware } from './middleware.js';
|
|
5
|
+
/**
|
|
6
|
+
* Configuration for structured output response format.
|
|
7
|
+
* Uses OpenAI's response_format API parameter.
|
|
8
|
+
*/
|
|
9
|
+
export type ResponseFormatConfig = {
|
|
10
|
+
type: 'text';
|
|
11
|
+
} | {
|
|
12
|
+
type: 'json_object';
|
|
13
|
+
} | {
|
|
14
|
+
type: 'json_schema';
|
|
15
|
+
/** Zod schema for response validation */
|
|
16
|
+
schema: ZodType<unknown>;
|
|
17
|
+
/** Name for the schema (used in API request) */
|
|
18
|
+
name?: string;
|
|
19
|
+
/** Whether to use strict mode (default: true) */
|
|
20
|
+
strict?: boolean;
|
|
21
|
+
};
|
|
3
22
|
export interface FunctionDeclaration {
|
|
4
23
|
name: string;
|
|
5
24
|
description: string;
|
|
@@ -14,6 +33,12 @@ export type ToolExecutor = (args: Record<string, unknown>, context: ToolExecutor
|
|
|
14
33
|
export interface ToolDefinition {
|
|
15
34
|
declaration: FunctionDeclaration;
|
|
16
35
|
executor: ToolExecutor;
|
|
36
|
+
/**
|
|
37
|
+
* Whether this tool can safely execute in parallel with other parallel-safe tools.
|
|
38
|
+
* Set to `true` for stateless operations like reading files or fetching data.
|
|
39
|
+
* Defaults to `false` (sequential execution) for safety.
|
|
40
|
+
*/
|
|
41
|
+
parallel?: boolean;
|
|
17
42
|
}
|
|
18
43
|
export interface ErrorMessages {
|
|
19
44
|
apiKeyRequired?: string;
|
|
@@ -25,13 +50,59 @@ export interface ErrorMessages {
|
|
|
25
50
|
toolExecutionFailed?: string;
|
|
26
51
|
summarizationFailed?: string;
|
|
27
52
|
genericError?: string;
|
|
53
|
+
/** Error message when JSON parsing fails */
|
|
54
|
+
jsonParseError?: string;
|
|
55
|
+
/** Error message when response doesn't match schema */
|
|
56
|
+
responseSchemaValidationFailed?: string;
|
|
28
57
|
}
|
|
29
58
|
export type ReasoningEffort = 'low' | 'medium' | 'high';
|
|
30
59
|
export interface SummarizationConfig {
|
|
31
60
|
enabled: boolean;
|
|
32
61
|
prompt?: string;
|
|
33
62
|
contextLimitTokens?: number;
|
|
63
|
+
/**
|
|
64
|
+
* Retry configuration for summarization API calls.
|
|
65
|
+
* Uses exponential backoff with jitter for transient failures.
|
|
66
|
+
*/
|
|
67
|
+
retry?: RetryConfig;
|
|
34
68
|
}
|
|
69
|
+
export interface ParallelExecutionConfig {
|
|
70
|
+
/**
|
|
71
|
+
* Maximum number of parallel-safe tools to execute concurrently.
|
|
72
|
+
* Defaults to 5.
|
|
73
|
+
*/
|
|
74
|
+
maxConcurrency?: number;
|
|
75
|
+
}
|
|
76
|
+
export declare const DEFAULT_MAX_CONCURRENCY = 5;
|
|
77
|
+
/**
|
|
78
|
+
* Configuration for retry behavior on transient API failures.
|
|
79
|
+
*/
|
|
80
|
+
export interface RetryConfig {
|
|
81
|
+
/**
|
|
82
|
+
* Maximum number of retry attempts (including the initial attempt).
|
|
83
|
+
* @default 3
|
|
84
|
+
*/
|
|
85
|
+
maxAttempts?: number;
|
|
86
|
+
/**
|
|
87
|
+
* Base delay in milliseconds before the first retry.
|
|
88
|
+
* @default 1000
|
|
89
|
+
*/
|
|
90
|
+
baseDelayMs?: number;
|
|
91
|
+
/**
|
|
92
|
+
* Maximum delay in milliseconds between retries.
|
|
93
|
+
* @default 30000
|
|
94
|
+
*/
|
|
95
|
+
maxDelayMs?: number;
|
|
96
|
+
/**
|
|
97
|
+
* Multiplier for exponential backoff.
|
|
98
|
+
* @default 2
|
|
99
|
+
*/
|
|
100
|
+
backoffMultiplier?: number;
|
|
101
|
+
}
|
|
102
|
+
export declare const DEFAULT_RETRY_MAX_ATTEMPTS = 3;
|
|
103
|
+
export declare const DEFAULT_RETRY_BASE_DELAY_MS = 1000;
|
|
104
|
+
export declare const DEFAULT_RETRY_MAX_DELAY_MS = 30000;
|
|
105
|
+
export declare const DEFAULT_RETRY_BACKOFF_MULTIPLIER = 2;
|
|
35
106
|
export interface AgentConfig {
|
|
36
107
|
apiKey: string;
|
|
37
108
|
model: string;
|
|
@@ -42,8 +113,27 @@ export interface AgentConfig {
|
|
|
42
113
|
tools: ToolDefinition[];
|
|
43
114
|
maxIterations?: number;
|
|
44
115
|
summarization?: SummarizationConfig;
|
|
116
|
+
parallelToolExecution?: ParallelExecutionConfig;
|
|
45
117
|
errorMessages?: ErrorMessages;
|
|
46
118
|
stream?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Response format configuration for structured output.
|
|
121
|
+
* - 'text': Default free-form text response
|
|
122
|
+
* - 'json_object': Forces JSON response (no schema validation)
|
|
123
|
+
* - 'json_schema': Forces JSON response with Zod schema validation
|
|
124
|
+
*/
|
|
125
|
+
responseFormat?: ResponseFormatConfig;
|
|
126
|
+
/**
|
|
127
|
+
* Retry configuration for handling transient API failures and response validation retries.
|
|
128
|
+
* Uses exponential backoff with jitter for API failures.
|
|
129
|
+
* The maxAttempts setting also controls retry attempts for schema validation failures.
|
|
130
|
+
*/
|
|
131
|
+
retry?: RetryConfig;
|
|
132
|
+
/**
|
|
133
|
+
* Middleware array for intercepting and modifying agent behavior.
|
|
134
|
+
* Middleware is executed in registration order (first in array = first executed).
|
|
135
|
+
*/
|
|
136
|
+
middleware?: Middleware[];
|
|
47
137
|
}
|
|
48
138
|
export interface UsageMetadata {
|
|
49
139
|
promptTokenCount?: number;
|
|
@@ -52,8 +142,20 @@ export interface UsageMetadata {
|
|
|
52
142
|
cachedContentTokenCount?: number;
|
|
53
143
|
reasoningTokenCount?: number;
|
|
54
144
|
}
|
|
55
|
-
|
|
145
|
+
/**
|
|
146
|
+
* Result returned from agent.chat().
|
|
147
|
+
*
|
|
148
|
+
* @typeParam T - The type of the parsed response when using responseFormat with json_schema.
|
|
149
|
+
* Defaults to `unknown` when no schema is provided.
|
|
150
|
+
*/
|
|
151
|
+
export interface AgentResult<T = unknown> {
|
|
152
|
+
/** Raw string response from the model */
|
|
56
153
|
message: string;
|
|
154
|
+
/**
|
|
155
|
+
* Parsed and validated response when using responseFormat with json_schema.
|
|
156
|
+
* Only present when a schema is configured and validation succeeds.
|
|
157
|
+
*/
|
|
158
|
+
parsedResponse?: T;
|
|
57
159
|
reasoning?: {
|
|
58
160
|
text?: string;
|
|
59
161
|
details?: import('./messages.js').ReasoningDetail[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACnC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,K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C7B,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,MAAM,EAAE,kBAAkB,CAAC;CAC5B"}
|
package/dist/types/config.js
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const DEFAULT_MAX_CONCURRENCY = 5;
|
|
2
|
+
export const DEFAULT_RETRY_MAX_ATTEMPTS = 3;
|
|
3
|
+
export const DEFAULT_RETRY_BASE_DELAY_MS = 1000;
|
|
4
|
+
export const DEFAULT_RETRY_MAX_DELAY_MS = 30000;
|
|
5
|
+
export const DEFAULT_RETRY_BACKOFF_MULTIPLIER = 2;
|
|
2
6
|
//# sourceMappingURL=config.js.map
|
package/dist/types/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAuFA,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AA4BzC,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC;AAC5C,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,CAAC;AAChD,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,CAAC;AAChD,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC"}
|
package/dist/types/events.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ReasoningDetail } from './messages.js';
|
|
2
2
|
import type { UsageMetadata, AgentResult, ToolCallStartData, ToolResultData } from './config.js';
|
|
3
|
+
import type { SubAgentStartData, SubAgentCompleteData } from './orchestrator.js';
|
|
3
4
|
export interface AgentCallbacks {
|
|
4
5
|
onThinking?: (thinking: string, details?: ReasoningDetail[]) => void;
|
|
5
6
|
onMessage?: (message: string, reasoning?: {
|
|
@@ -15,6 +16,7 @@ export interface AgentCallbacks {
|
|
|
15
16
|
onSummarizationStart?: (originalMessageCount: number) => void;
|
|
16
17
|
onSummarizationEnd?: (summary: string, tokensEstimate: number) => void;
|
|
17
18
|
onIterationStart?: (iteration: number, maxIterations: number) => void;
|
|
19
|
+
onRetry?: (attempt: number, maxAttempts: number, error: Error, delayMs: number) => void;
|
|
18
20
|
onError?: (error: {
|
|
19
21
|
code: string;
|
|
20
22
|
message: string;
|
|
@@ -22,8 +24,12 @@ export interface AgentCallbacks {
|
|
|
22
24
|
}) => void;
|
|
23
25
|
onComplete?: (result: AgentResult) => void;
|
|
24
26
|
onAborted?: () => void;
|
|
27
|
+
/** Called when orchestrator starts delegating to a sub-agent */
|
|
28
|
+
onSubAgentStart?: (data: SubAgentStartData) => void;
|
|
29
|
+
/** Called when a sub-agent completes its work */
|
|
30
|
+
onSubAgentComplete?: (data: SubAgentCompleteData) => void;
|
|
25
31
|
}
|
|
26
|
-
export type AgentEventType = 'thinking' | 'message' | 'message_delta' | 'reasoning_delta' | 'tool_call_start' | 'tool_result' | 'usage_update' | 'summarization_start' | 'summarization_end' | 'iteration_start' | 'error' | 'complete' | 'aborted';
|
|
32
|
+
export type AgentEventType = 'thinking' | 'message' | 'message_delta' | 'reasoning_delta' | 'tool_call_start' | 'tool_result' | 'usage_update' | 'summarization_start' | 'summarization_end' | 'iteration_start' | 'retry' | 'error' | 'complete' | 'aborted' | 'sub_agent_start' | 'sub_agent_complete';
|
|
27
33
|
export interface ThinkingEventData {
|
|
28
34
|
thinking: string;
|
|
29
35
|
details?: ReasoningDetail[];
|
|
@@ -56,6 +62,12 @@ export interface IterationStartEventData {
|
|
|
56
62
|
iteration: number;
|
|
57
63
|
maxIterations: number;
|
|
58
64
|
}
|
|
65
|
+
export interface RetryEventData {
|
|
66
|
+
attempt: number;
|
|
67
|
+
maxAttempts: number;
|
|
68
|
+
error: Error;
|
|
69
|
+
delayMs: number;
|
|
70
|
+
}
|
|
59
71
|
export interface ErrorEventData {
|
|
60
72
|
code: string;
|
|
61
73
|
message: string;
|
|
@@ -71,6 +83,14 @@ export interface MessageDeltaEventData {
|
|
|
71
83
|
export interface ReasoningDeltaEventData {
|
|
72
84
|
detail: ReasoningDetail;
|
|
73
85
|
}
|
|
86
|
+
export interface SubAgentStartEventData {
|
|
87
|
+
agentName: string;
|
|
88
|
+
message: string;
|
|
89
|
+
}
|
|
90
|
+
export interface SubAgentCompleteEventData {
|
|
91
|
+
agentName: string;
|
|
92
|
+
result: AgentResult;
|
|
93
|
+
}
|
|
74
94
|
export interface EventDataMap {
|
|
75
95
|
thinking: ThinkingEventData;
|
|
76
96
|
message: MessageEventData;
|
|
@@ -82,9 +102,12 @@ export interface EventDataMap {
|
|
|
82
102
|
summarization_start: SummarizationStartEventData;
|
|
83
103
|
summarization_end: SummarizationEndEventData;
|
|
84
104
|
iteration_start: IterationStartEventData;
|
|
105
|
+
retry: RetryEventData;
|
|
85
106
|
error: ErrorEventData;
|
|
86
107
|
complete: CompleteEventData;
|
|
87
108
|
aborted: AbortedEventData;
|
|
109
|
+
sub_agent_start: SubAgentStartEventData;
|
|
110
|
+
sub_agent_complete: SubAgentCompleteEventData;
|
|
88
111
|
}
|
|
89
112
|
export interface AgentEvent<T extends AgentEventType = AgentEventType> {
|
|
90
113
|
type: T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,iBAAiB,EAAE,cAAc,EA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ACzC,eAAe,EAAE,sBAAsB,CAAC;IACxC,WAAW,EAAE,mBAAmB,CAAC;IACjC,YAAY,EAAE,oBAAoB,CAAC;IACnC,mBAAmB,EAAE,2BAA2B,CAAC;IACjD,iBAAiB,EAAE,yBAAyB,CAAC;IAC7C,eAAe,EAAE,uBAAuB,CAAC;IACzC,KAAK,EAAE,cAAc,CAAC;IACtB,KAAK,EAAE,cAAc,CAAC;IACtB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,OAAO,EAAE,gBAAgB,CAAC;IAC1B,eAAe,EAAE,sBAAsB,CAAC;IACxC,kBAAkB,EAAE,yBAAyB,CAAC;CAC/C;AAED,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc;IACnE,IAAI,EAAE,CAAC,CAAC;IACR,SAAS,EAAE,IAAI,CAAC;IAChB,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;CACvB;AAED,wBAAgB,WAAW,CAAC,CAAC,SAAS,cAAc,EAClD,IAAI,EAAE,CAAC,EACP,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,GACpB,UAAU,CAAC,CAAC,CAAC,CAMf"}
|
package/dist/types/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAgJA,MAAM,UAAU,WAAW,CACzB,IAAO,EACP,IAAqB;IAErB,OAAO;QACL,IAAI;QACJ,SAAS,EAAE,IAAI,IAAI,EAAE;QACrB,IAAI;KACL,CAAC;AACJ,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export type { ReasoningDetail, ChatMessageRole, ToolCall, ChatMessage, FunctionCallResult, } from './messages.js';
|
|
2
|
-
export type { FunctionDeclaration, ToolExecutorContext, ToolExecutor, ToolDefinition, ErrorMessages, ReasoningEffort, SummarizationConfig, AgentConfig, UsageMetadata, AgentResult, ToolCallStartData, ToolResultData, ExecutedToolCall, } from './config.js';
|
|
3
|
-
export
|
|
2
|
+
export type { FunctionDeclaration, ToolExecutorContext, ToolExecutor, ToolDefinition, ErrorMessages, ReasoningEffort, SummarizationConfig, ParallelExecutionConfig, RetryConfig, AgentConfig, UsageMetadata, AgentResult, ToolCallStartData, ToolResultData, ExecutedToolCall, ResponseFormatConfig, } from './config.js';
|
|
3
|
+
export { DEFAULT_MAX_CONCURRENCY, DEFAULT_RETRY_MAX_ATTEMPTS, DEFAULT_RETRY_BASE_DELAY_MS, DEFAULT_RETRY_MAX_DELAY_MS, DEFAULT_RETRY_BACKOFF_MULTIPLIER, } from './config.js';
|
|
4
|
+
export type { AgentCallbacks, AgentEventType, ThinkingEventData, MessageEventData, MessageDeltaEventData, ReasoningDeltaEventData, ToolCallStartEventData, ToolResultEventData, UsageUpdateEventData, SummarizationStartEventData, SummarizationEndEventData, IterationStartEventData, RetryEventData, ErrorEventData, CompleteEventData, AbortedEventData, SubAgentStartEventData, SubAgentCompleteEventData, EventDataMap, AgentEvent, } from './events.js';
|
|
4
5
|
export { createEvent } from './events.js';
|
|
6
|
+
export type { Middleware, MiddlewareContext, BeforeChatContext, AfterChatContext, BeforeToolCallContext, AfterToolCallContext, ErrorContext, } from './middleware.js';
|
|
7
|
+
export type { AgentDefinition, OrchestratorConfig, OrchestratorAgent, SubAgentStartData, SubAgentCompleteData, OrchestratorCallbacks, } from './orchestrator.js';
|
|
5
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,eAAe,EACf,QAAQ,EACR,WAAW,EACX,kBAAkB,GACnB,MAAM,eAAe,CAAC;AAEvB,YAAY,EACV,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,cAAc,EACd,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,WAAW,EACX,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,eAAe,EACf,QAAQ,EACR,WAAW,EACX,kBAAkB,GACnB,MAAM,eAAe,CAAC;AAEvB,YAAY,EACV,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,cAAc,EACd,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,uBAAuB,EACvB,WAAW,EACX,WAAW,EACX,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,EAC1B,gCAAgC,GACjC,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,2BAA2B,EAC3B,yBAAyB,EACzB,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,EACtB,yBAAyB,EACzB,YAAY,EACZ,UAAU,GACX,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,YAAY,EACV,UAAU,EACV,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,YAAY,GACb,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EACV,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,mBAAmB,CAAC"}
|
package/dist/types/index.js
CHANGED
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AA2BA,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,EAC1B,gCAAgC,GACjC,MAAM,aAAa,CAAC;AAyBrB,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { ToolCall, FunctionCallResult, ChatMessage } from './messages.js';
|
|
2
|
+
import type { ToolExecutorContext, AgentResult } from './config.js';
|
|
3
|
+
import type { AgentError } from '../core/errors.js';
|
|
4
|
+
/**
|
|
5
|
+
* Context passed to middleware hooks.
|
|
6
|
+
* Contains all relevant information about the current execution state.
|
|
7
|
+
*/
|
|
8
|
+
export interface MiddlewareContext {
|
|
9
|
+
/** The user's input message */
|
|
10
|
+
message: string;
|
|
11
|
+
/** Current conversation history */
|
|
12
|
+
history: ChatMessage[];
|
|
13
|
+
/** Tool execution context (userId, timezone, abortSignal) */
|
|
14
|
+
toolContext: ToolExecutorContext;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Context for beforeChat middleware hook.
|
|
18
|
+
*/
|
|
19
|
+
export type BeforeChatContext = MiddlewareContext;
|
|
20
|
+
/**
|
|
21
|
+
* Context for afterChat middleware hook.
|
|
22
|
+
*/
|
|
23
|
+
export interface AfterChatContext extends MiddlewareContext {
|
|
24
|
+
/** The result from the chat operation */
|
|
25
|
+
result: AgentResult;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Context for beforeToolCall middleware hook.
|
|
29
|
+
*/
|
|
30
|
+
export interface BeforeToolCallContext extends MiddlewareContext {
|
|
31
|
+
/** The tool call about to be executed */
|
|
32
|
+
toolCall: ToolCall;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Context for afterToolCall middleware hook.
|
|
36
|
+
*/
|
|
37
|
+
export interface AfterToolCallContext extends MiddlewareContext {
|
|
38
|
+
/** The tool call that was executed */
|
|
39
|
+
toolCall: ToolCall;
|
|
40
|
+
/** The result from the tool execution */
|
|
41
|
+
result: FunctionCallResult;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Context for onError middleware hook.
|
|
45
|
+
*/
|
|
46
|
+
export interface ErrorContext extends MiddlewareContext {
|
|
47
|
+
/** The error that occurred */
|
|
48
|
+
error: AgentError;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Middleware interface for intercepting and modifying agent behavior.
|
|
52
|
+
*
|
|
53
|
+
* Middleware functions are executed in registration order (first registered = first executed).
|
|
54
|
+
* Each hook receives a context object and can modify the data before passing to the next middleware.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* const loggingMiddleware: Middleware = {
|
|
59
|
+
* name: 'logging',
|
|
60
|
+
* beforeChat: async (ctx) => {
|
|
61
|
+
* console.log('Chat started:', ctx.message);
|
|
62
|
+
* return ctx.message;
|
|
63
|
+
* },
|
|
64
|
+
* afterChat: async (ctx) => {
|
|
65
|
+
* console.log('Chat completed:', ctx.result.message);
|
|
66
|
+
* return ctx.result;
|
|
67
|
+
* },
|
|
68
|
+
* };
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export interface Middleware {
|
|
72
|
+
/** Unique name for this middleware (used for debugging/logging) */
|
|
73
|
+
name: string;
|
|
74
|
+
/**
|
|
75
|
+
* Called before the chat operation begins.
|
|
76
|
+
* Can modify the user message before it's sent to the model.
|
|
77
|
+
*
|
|
78
|
+
* @param ctx - Context containing the message, history, and tool context
|
|
79
|
+
* @returns The (potentially modified) message to use
|
|
80
|
+
*/
|
|
81
|
+
beforeChat?: (ctx: BeforeChatContext) => Promise<string>;
|
|
82
|
+
/**
|
|
83
|
+
* Called after the chat operation completes successfully.
|
|
84
|
+
* Can modify the result before it's returned to the caller.
|
|
85
|
+
*
|
|
86
|
+
* @param ctx - Context containing the result and original context
|
|
87
|
+
* @returns The (potentially modified) result
|
|
88
|
+
*/
|
|
89
|
+
afterChat?: (ctx: AfterChatContext) => Promise<AgentResult>;
|
|
90
|
+
/**
|
|
91
|
+
* Called before each tool is executed.
|
|
92
|
+
* Can modify the tool call arguments or skip execution by throwing.
|
|
93
|
+
*
|
|
94
|
+
* @param ctx - Context containing the tool call details
|
|
95
|
+
* @returns The (potentially modified) tool call
|
|
96
|
+
*/
|
|
97
|
+
beforeToolCall?: (ctx: BeforeToolCallContext) => Promise<ToolCall>;
|
|
98
|
+
/**
|
|
99
|
+
* Called after each tool execution completes.
|
|
100
|
+
* Can modify the result before it's added to conversation history.
|
|
101
|
+
*
|
|
102
|
+
* @param ctx - Context containing the tool call and its result
|
|
103
|
+
* @returns The (potentially modified) function call result
|
|
104
|
+
*/
|
|
105
|
+
afterToolCall?: (ctx: AfterToolCallContext) => Promise<FunctionCallResult>;
|
|
106
|
+
/**
|
|
107
|
+
* Called when an error occurs during agent execution.
|
|
108
|
+
* Can be used for logging, analytics, or error transformation.
|
|
109
|
+
* Does not modify the error - for observation only.
|
|
110
|
+
*
|
|
111
|
+
* @param ctx - Context containing the error and execution state
|
|
112
|
+
*/
|
|
113
|
+
onError?: (ctx: ErrorContext) => Promise<void>;
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/types/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAA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ACH,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,oBAAoB,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAE3E;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/types/middleware.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { Agent } from '../core/agent.js';
|
|
2
|
+
import type { AgentConfig, AgentResult } from './config.js';
|
|
3
|
+
/**
|
|
4
|
+
* Definition of a sub-agent that can be delegated to by an orchestrator.
|
|
5
|
+
*/
|
|
6
|
+
export interface AgentDefinition {
|
|
7
|
+
/** The agent instance to delegate to */
|
|
8
|
+
agent: Agent;
|
|
9
|
+
/** Unique name for this agent (used as tool name) */
|
|
10
|
+
name: string;
|
|
11
|
+
/** Description of the agent's capabilities (helps orchestrator route requests) */
|
|
12
|
+
description: string;
|
|
13
|
+
/**
|
|
14
|
+
* Whether this agent can be called in parallel with other parallel-safe agents.
|
|
15
|
+
* Defaults to false for safety.
|
|
16
|
+
*/
|
|
17
|
+
parallel?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Configuration for creating an orchestrator agent.
|
|
21
|
+
* Extends AgentConfig but excludes 'tools' since they are auto-generated from subAgents.
|
|
22
|
+
*/
|
|
23
|
+
export interface OrchestratorConfig extends Omit<AgentConfig, 'tools'> {
|
|
24
|
+
/** Array of sub-agents that the orchestrator can delegate to */
|
|
25
|
+
subAgents: AgentDefinition[];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Extended Agent interface for orchestrators with sub-agent management.
|
|
29
|
+
*/
|
|
30
|
+
export interface OrchestratorAgent extends Agent {
|
|
31
|
+
/** Returns the list of registered sub-agents */
|
|
32
|
+
getSubAgents(): AgentDefinition[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Callback fired when orchestrator starts delegating to a sub-agent.
|
|
36
|
+
*/
|
|
37
|
+
export interface SubAgentStartData {
|
|
38
|
+
/** Name of the sub-agent being called */
|
|
39
|
+
agentName: string;
|
|
40
|
+
/** Message being delegated to the sub-agent */
|
|
41
|
+
message: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Callback fired when a sub-agent completes its work.
|
|
45
|
+
*/
|
|
46
|
+
export interface SubAgentCompleteData {
|
|
47
|
+
/** Name of the sub-agent that completed */
|
|
48
|
+
agentName: string;
|
|
49
|
+
/** Result returned by the sub-agent */
|
|
50
|
+
result: AgentResult;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Extended callbacks for orchestrator-specific events.
|
|
54
|
+
*/
|
|
55
|
+
export interface OrchestratorCallbacks {
|
|
56
|
+
/** Called when orchestrator starts delegating to a sub-agent */
|
|
57
|
+
onSubAgentStart?: (data: SubAgentStartData) => void;
|
|
58
|
+
/** Called when a sub-agent completes its work */
|
|
59
|
+
onSubAgentComplete?: (data: SubAgentCompleteData) => void;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=orchestrator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../src/types/orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,wCAAwC;IACxC,KAAK,EAAE,KAAK,CAAC;IACb,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,kFAAkF;IAClF,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC;IACpE,gEAAgE;IAChE,SAAS,EAAE,eAAe,EAAE,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,KAAK;IAC9C,gDAAgD;IAChD,YAAY,IAAI,eAAe,EAAE,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,2CAA2C;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,MAAM,EAAE,WAAW,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,gEAAgE;IAChE,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACpD,iDAAiD;IACjD,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,IAAI,CAAC;CAC3D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestrator.js","sourceRoot":"","sources":["../../src/types/orchestrator.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "concevent-ai-agent-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Framework-agnostic AI Agent SDK with tool calling, conversation management, and automatic summarization",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -44,7 +44,12 @@
|
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/node": "^22.10.2",
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^8.50.1",
|
|
48
|
+
"@typescript-eslint/parser": "^8.50.1",
|
|
47
49
|
"@vitest/coverage-v8": "^2.1.9",
|
|
50
|
+
"eslint": "^9.39.2",
|
|
51
|
+
"eslint-config-prettier": "^10.1.8",
|
|
52
|
+
"globals": "^16.5.0",
|
|
48
53
|
"nock": "^14.0.1",
|
|
49
54
|
"prettier": "^3.7.4",
|
|
50
55
|
"typescript": "^5.7.2",
|