@vibe-agent-toolkit/agent-runtime 0.1.2-rc.3
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 +295 -0
- package/dist/adapter-types.d.ts +48 -0
- package/dist/adapter-types.d.ts.map +1 -0
- package/dist/adapter-types.js +24 -0
- package/dist/adapter-types.js.map +1 -0
- package/dist/agent-helpers.d.ts +128 -0
- package/dist/agent-helpers.d.ts.map +1 -0
- package/dist/agent-helpers.js +291 -0
- package/dist/agent-helpers.js.map +1 -0
- package/dist/agentic-researcher.d.ts +63 -0
- package/dist/agentic-researcher.d.ts.map +1 -0
- package/dist/agentic-researcher.js +60 -0
- package/dist/agentic-researcher.js.map +1 -0
- package/dist/conversational-assistant.d.ts +57 -0
- package/dist/conversational-assistant.d.ts.map +1 -0
- package/dist/conversational-assistant.js +48 -0
- package/dist/conversational-assistant.js.map +1 -0
- package/dist/conversational-helpers.d.ts +26 -0
- package/dist/conversational-helpers.d.ts.map +1 -0
- package/dist/conversational-helpers.js +34 -0
- package/dist/conversational-helpers.js.map +1 -0
- package/dist/execute-wrapper.d.ts +59 -0
- package/dist/execute-wrapper.d.ts.map +1 -0
- package/dist/execute-wrapper.js +98 -0
- package/dist/execute-wrapper.js.map +1 -0
- package/dist/external-event-integrator.d.ts +66 -0
- package/dist/external-event-integrator.d.ts.map +1 -0
- package/dist/external-event-integrator.js +62 -0
- package/dist/external-event-integrator.js.map +1 -0
- package/dist/function-event-consumer.d.ts +60 -0
- package/dist/function-event-consumer.d.ts.map +1 -0
- package/dist/function-event-consumer.js +52 -0
- package/dist/function-event-consumer.js.map +1 -0
- package/dist/function-orchestrator.d.ts +45 -0
- package/dist/function-orchestrator.d.ts.map +1 -0
- package/dist/function-orchestrator.js +51 -0
- package/dist/function-orchestrator.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/llm-analyzer.d.ts +58 -0
- package/dist/llm-analyzer.d.ts.map +1 -0
- package/dist/llm-analyzer.js +53 -0
- package/dist/llm-analyzer.js.map +1 -0
- package/dist/llm-coordinator.d.ts +62 -0
- package/dist/llm-coordinator.d.ts.map +1 -0
- package/dist/llm-coordinator.js +60 -0
- package/dist/llm-coordinator.js.map +1 -0
- package/dist/llm-event-handler.d.ts +67 -0
- package/dist/llm-event-handler.d.ts.map +1 -0
- package/dist/llm-event-handler.js +65 -0
- package/dist/llm-event-handler.js.map +1 -0
- package/dist/pure-function.d.ts +34 -0
- package/dist/pure-function.d.ts.map +1 -0
- package/dist/pure-function.js +40 -0
- package/dist/pure-function.js.map +1 -0
- package/dist/result-helpers.d.ts +80 -0
- package/dist/result-helpers.d.ts.map +1 -0
- package/dist/result-helpers.js +232 -0
- package/dist/result-helpers.js.map +1 -0
- package/dist/session/errors.d.ts +11 -0
- package/dist/session/errors.d.ts.map +1 -0
- package/dist/session/errors.js +15 -0
- package/dist/session/errors.js.map +1 -0
- package/dist/session/file-session-store.d.ts +46 -0
- package/dist/session/file-session-store.d.ts.map +1 -0
- package/dist/session/file-session-store.js +149 -0
- package/dist/session/file-session-store.js.map +1 -0
- package/dist/session/index.d.ts +12 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +13 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/memory-session-store.d.ts +35 -0
- package/dist/session/memory-session-store.d.ts.map +1 -0
- package/dist/session/memory-session-store.js +76 -0
- package/dist/session/memory-session-store.js.map +1 -0
- package/dist/session/session-store-helpers.d.ts +26 -0
- package/dist/session/session-store-helpers.d.ts.map +1 -0
- package/dist/session/session-store-helpers.js +54 -0
- package/dist/session/session-store-helpers.js.map +1 -0
- package/dist/session/test-helpers/index.d.ts +61 -0
- package/dist/session/test-helpers/index.d.ts.map +1 -0
- package/dist/session/test-helpers/index.js +167 -0
- package/dist/session/test-helpers/index.js.map +1 -0
- package/dist/session/types.d.ts +86 -0
- package/dist/session/types.d.ts.map +1 -0
- package/dist/session/types.js +8 -0
- package/dist/session/types.js.map +1 -0
- package/dist/shared-validation.d.ts +21 -0
- package/dist/shared-validation.d.ts.map +1 -0
- package/dist/shared-validation.js +45 -0
- package/dist/shared-validation.js.map +1 -0
- package/dist/test-helpers.d.ts +50 -0
- package/dist/test-helpers.d.ts.map +1 -0
- package/dist/test-helpers.js +47 -0
- package/dist/test-helpers.js.map +1 -0
- package/dist/two-phase-conversational.d.ts +173 -0
- package/dist/two-phase-conversational.d.ts.map +1 -0
- package/dist/two-phase-conversational.js +205 -0
- package/dist/two-phase-conversational.js.map +1 -0
- package/dist/types.d.ts +194 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type z } from 'zod';
|
|
2
|
+
import type { Agent, LLMAnalyzerContext } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for defining an LLM analyzer agent
|
|
5
|
+
*/
|
|
6
|
+
export interface LLMAnalyzerConfig<TInput, TOutput> {
|
|
7
|
+
/** Unique name for the agent */
|
|
8
|
+
name: string;
|
|
9
|
+
/** Human-readable description of what the agent does */
|
|
10
|
+
description: string;
|
|
11
|
+
/** Semantic version (e.g., "1.0.0") */
|
|
12
|
+
version: string;
|
|
13
|
+
/** Zod schema for input validation */
|
|
14
|
+
inputSchema: z.ZodType<TInput>;
|
|
15
|
+
/** Zod schema for output validation */
|
|
16
|
+
outputSchema: z.ZodType<TOutput>;
|
|
17
|
+
/** Whether this agent can be mocked in tests (default: true) */
|
|
18
|
+
mockable?: boolean;
|
|
19
|
+
/** LLM model identifier (optional) */
|
|
20
|
+
model?: string;
|
|
21
|
+
/** Temperature for LLM generation (0-1, optional) */
|
|
22
|
+
temperature?: number;
|
|
23
|
+
/** Additional metadata */
|
|
24
|
+
metadata?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Defines an LLM analyzer agent that uses language models to analyze
|
|
28
|
+
* and transform data.
|
|
29
|
+
*
|
|
30
|
+
* The agent validates inputs and outputs using Zod schemas, provides
|
|
31
|
+
* LLM context to the handler, and generates a manifest describing its
|
|
32
|
+
* interface and capabilities.
|
|
33
|
+
*
|
|
34
|
+
* @param config - Agent configuration including schemas and LLM parameters
|
|
35
|
+
* @param handler - Async function that uses LLM context to transform input
|
|
36
|
+
* @returns Agent with validated execute function and manifest
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const sentimentAgent = defineLLMAnalyzer(
|
|
41
|
+
* {
|
|
42
|
+
* name: 'sentiment-analyzer',
|
|
43
|
+
* description: 'Analyzes sentiment of text',
|
|
44
|
+
* version: '1.0.0',
|
|
45
|
+
* inputSchema: z.object({ text: z.string() }),
|
|
46
|
+
* outputSchema: z.object({ sentiment: z.enum(['positive', 'negative', 'neutral']) }),
|
|
47
|
+
* model: 'claude-3-haiku',
|
|
48
|
+
* mockable: true,
|
|
49
|
+
* },
|
|
50
|
+
* async (input, ctx) => {
|
|
51
|
+
* const response = await ctx.callLLM(`Analyze sentiment: ${input.text}`);
|
|
52
|
+
* return { sentiment: 'positive' }; // Parse response
|
|
53
|
+
* }
|
|
54
|
+
* );
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function defineLLMAnalyzer<TInput, TOutput>(config: LLMAnalyzerConfig<TInput, TOutput>, handler: (input: TInput, ctx: LLMAnalyzerContext) => Promise<TOutput>): Agent<TInput, TOutput>;
|
|
58
|
+
//# sourceMappingURL=llm-analyzer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-analyzer.d.ts","sourceRoot":"","sources":["../src/llm-analyzer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,CAAC;AAG7B,OAAO,KAAK,EAAE,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,MAAM,EAAE,OAAO;IAChD,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IAEb,wDAAwD;IACxD,WAAW,EAAE,MAAM,CAAC;IAEpB,uCAAuC;IACvC,OAAO,EAAE,MAAM,CAAC;IAEhB,sCAAsC;IACtC,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAE/B,uCAAuC;IACvC,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAEjC,gEAAgE;IAChE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,qDAAqD;IACrD,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,EAC/C,MAAM,EAAE,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1C,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,kBAAkB,KAAK,OAAO,CAAC,OAAO,CAAC,GACpE,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAyBxB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { buildManifest, createAsyncExecuteWrapperWithContext } from './execute-wrapper.js';
|
|
2
|
+
/**
|
|
3
|
+
* Defines an LLM analyzer agent that uses language models to analyze
|
|
4
|
+
* and transform data.
|
|
5
|
+
*
|
|
6
|
+
* The agent validates inputs and outputs using Zod schemas, provides
|
|
7
|
+
* LLM context to the handler, and generates a manifest describing its
|
|
8
|
+
* interface and capabilities.
|
|
9
|
+
*
|
|
10
|
+
* @param config - Agent configuration including schemas and LLM parameters
|
|
11
|
+
* @param handler - Async function that uses LLM context to transform input
|
|
12
|
+
* @returns Agent with validated execute function and manifest
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const sentimentAgent = defineLLMAnalyzer(
|
|
17
|
+
* {
|
|
18
|
+
* name: 'sentiment-analyzer',
|
|
19
|
+
* description: 'Analyzes sentiment of text',
|
|
20
|
+
* version: '1.0.0',
|
|
21
|
+
* inputSchema: z.object({ text: z.string() }),
|
|
22
|
+
* outputSchema: z.object({ sentiment: z.enum(['positive', 'negative', 'neutral']) }),
|
|
23
|
+
* model: 'claude-3-haiku',
|
|
24
|
+
* mockable: true,
|
|
25
|
+
* },
|
|
26
|
+
* async (input, ctx) => {
|
|
27
|
+
* const response = await ctx.callLLM(`Analyze sentiment: ${input.text}`);
|
|
28
|
+
* return { sentiment: 'positive' }; // Parse response
|
|
29
|
+
* }
|
|
30
|
+
* );
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export function defineLLMAnalyzer(config, handler) {
|
|
34
|
+
// Build manifest with LLM-specific metadata
|
|
35
|
+
const manifest = buildManifest(config, 'llm-analyzer', {
|
|
36
|
+
mockable: config.mockable ?? true,
|
|
37
|
+
...(config.model && { model: config.model }),
|
|
38
|
+
...(config.temperature !== undefined && { temperature: config.temperature }),
|
|
39
|
+
});
|
|
40
|
+
// Create validated execute function that accepts variable arguments
|
|
41
|
+
const execute = createAsyncExecuteWrapperWithContext(config, handler, (ctx) => ({
|
|
42
|
+
mockable: config.mockable ?? true,
|
|
43
|
+
callLLM: ctx.callLLM,
|
|
44
|
+
...(config.model && { model: config.model }),
|
|
45
|
+
...(config.temperature !== undefined && { temperature: config.temperature }),
|
|
46
|
+
}));
|
|
47
|
+
return {
|
|
48
|
+
name: config.name,
|
|
49
|
+
execute,
|
|
50
|
+
manifest,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=llm-analyzer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-analyzer.js","sourceRoot":"","sources":["../src/llm-analyzer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,oCAAoC,EAAE,MAAM,sBAAsB,CAAC;AAmC3F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAA0C,EAC1C,OAAqE;IAErE,4CAA4C;IAC5C,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,EAAE,cAAc,EAAE;QACrD,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,IAAI;QACjC,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;QAC5C,GAAG,CAAC,MAAM,CAAC,WAAW,KAAK,SAAS,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC;KAC7E,CAAC,CAAC;IAEH,oEAAoE;IACpE,MAAM,OAAO,GAAG,oCAAoC,CAClD,MAAM,EACN,OAAO,EACP,CAAC,GAAuB,EAAsB,EAAE,CAAC,CAAC;QAChD,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,IAAI;QACjC,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;QAC5C,GAAG,CAAC,MAAM,CAAC,WAAW,KAAK,SAAS,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC;KAC7E,CAAC,CACH,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,OAAO;QACP,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type z } from 'zod';
|
|
2
|
+
import type { Agent, CoordinatorContext } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for defining an LLM coordinator agent
|
|
5
|
+
*/
|
|
6
|
+
export interface LLMCoordinatorConfig<TInput, TOutput> {
|
|
7
|
+
/** Unique name for the agent */
|
|
8
|
+
name: string;
|
|
9
|
+
/** Human-readable description of what the agent does */
|
|
10
|
+
description: string;
|
|
11
|
+
/** Semantic version (e.g., "1.0.0") */
|
|
12
|
+
version: string;
|
|
13
|
+
/** Zod schema for input validation */
|
|
14
|
+
inputSchema: z.ZodType<TInput>;
|
|
15
|
+
/** Zod schema for output validation */
|
|
16
|
+
outputSchema: z.ZodType<TOutput>;
|
|
17
|
+
/** Whether this agent can be mocked in tests (default: true) */
|
|
18
|
+
mockable?: boolean;
|
|
19
|
+
/** Additional metadata */
|
|
20
|
+
metadata?: Record<string, unknown>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Defines an LLM coordinator agent that uses language models to make
|
|
24
|
+
* decisions about which agents to call and how to coordinate workflows.
|
|
25
|
+
*
|
|
26
|
+
* The agent validates inputs and outputs using Zod schemas, provides
|
|
27
|
+
* access to LLM reasoning and other agents, and supports routing logic.
|
|
28
|
+
*
|
|
29
|
+
* @param config - Agent configuration including schemas
|
|
30
|
+
* @param handler - Async function that coordinates using LLM
|
|
31
|
+
* @returns Agent with validated execute function and manifest
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const coordinator = defineLLMCoordinator(
|
|
36
|
+
* {
|
|
37
|
+
* name: 'task-coordinator',
|
|
38
|
+
* description: 'Coordinates task execution based on LLM decisions',
|
|
39
|
+
* version: '1.0.0',
|
|
40
|
+
* inputSchema: z.object({ task: z.string() }),
|
|
41
|
+
* outputSchema: z.object({ result: z.string() }),
|
|
42
|
+
* },
|
|
43
|
+
* async (input, ctx) => {
|
|
44
|
+
* // Ask LLM to decide which agent to use
|
|
45
|
+
* const decision = await ctx.callLLM(
|
|
46
|
+
* `Which agent should handle this task: ${input.task}? Choose: simple, complex, or research`
|
|
47
|
+
* );
|
|
48
|
+
*
|
|
49
|
+
* // Route to appropriate agent
|
|
50
|
+
* const result = await ctx.route(decision, {
|
|
51
|
+
* simple: () => ctx.call('simple-processor', input),
|
|
52
|
+
* complex: () => ctx.call('complex-processor', input),
|
|
53
|
+
* research: () => ctx.call('research-agent', input),
|
|
54
|
+
* });
|
|
55
|
+
*
|
|
56
|
+
* return { result: String(result) };
|
|
57
|
+
* }
|
|
58
|
+
* );
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare function defineLLMCoordinator<TInput, TOutput>(config: LLMCoordinatorConfig<TInput, TOutput>, handler: (input: TInput, ctx: CoordinatorContext) => Promise<TOutput>): Agent<TInput, TOutput>;
|
|
62
|
+
//# sourceMappingURL=llm-coordinator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-coordinator.d.ts","sourceRoot":"","sources":["../src/llm-coordinator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,CAAC;AAG7B,OAAO,KAAK,EAAE,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,oBAAoB,CAAC,MAAM,EAAE,OAAO;IACnD,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IAEb,wDAAwD;IACxD,WAAW,EAAE,MAAM,CAAC;IAEpB,uCAAuC;IACvC,OAAO,EAAE,MAAM,CAAC;IAEhB,sCAAsC;IACtC,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAE/B,uCAAuC;IACvC,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAEjC,gEAAgE;IAChE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,EAClD,MAAM,EAAE,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7C,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,kBAAkB,KAAK,OAAO,CAAC,OAAO,CAAC,GACpE,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAwBxB"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { buildManifest, createAsyncExecuteWrapperWithContext } from './execute-wrapper.js';
|
|
2
|
+
/**
|
|
3
|
+
* Defines an LLM coordinator agent that uses language models to make
|
|
4
|
+
* decisions about which agents to call and how to coordinate workflows.
|
|
5
|
+
*
|
|
6
|
+
* The agent validates inputs and outputs using Zod schemas, provides
|
|
7
|
+
* access to LLM reasoning and other agents, and supports routing logic.
|
|
8
|
+
*
|
|
9
|
+
* @param config - Agent configuration including schemas
|
|
10
|
+
* @param handler - Async function that coordinates using LLM
|
|
11
|
+
* @returns Agent with validated execute function and manifest
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const coordinator = defineLLMCoordinator(
|
|
16
|
+
* {
|
|
17
|
+
* name: 'task-coordinator',
|
|
18
|
+
* description: 'Coordinates task execution based on LLM decisions',
|
|
19
|
+
* version: '1.0.0',
|
|
20
|
+
* inputSchema: z.object({ task: z.string() }),
|
|
21
|
+
* outputSchema: z.object({ result: z.string() }),
|
|
22
|
+
* },
|
|
23
|
+
* async (input, ctx) => {
|
|
24
|
+
* // Ask LLM to decide which agent to use
|
|
25
|
+
* const decision = await ctx.callLLM(
|
|
26
|
+
* `Which agent should handle this task: ${input.task}? Choose: simple, complex, or research`
|
|
27
|
+
* );
|
|
28
|
+
*
|
|
29
|
+
* // Route to appropriate agent
|
|
30
|
+
* const result = await ctx.route(decision, {
|
|
31
|
+
* simple: () => ctx.call('simple-processor', input),
|
|
32
|
+
* complex: () => ctx.call('complex-processor', input),
|
|
33
|
+
* research: () => ctx.call('research-agent', input),
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* return { result: String(result) };
|
|
37
|
+
* }
|
|
38
|
+
* );
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export function defineLLMCoordinator(config, handler) {
|
|
42
|
+
// Build manifest
|
|
43
|
+
const manifest = buildManifest(config, 'llm-coordinator', {
|
|
44
|
+
mockable: config.mockable ?? true,
|
|
45
|
+
});
|
|
46
|
+
// Create validated execute function
|
|
47
|
+
const execute = createAsyncExecuteWrapperWithContext(config, handler, (ctx) => ({
|
|
48
|
+
mockable: config.mockable ?? true,
|
|
49
|
+
call: ctx.call,
|
|
50
|
+
callLLM: ctx.callLLM,
|
|
51
|
+
route: ctx.route,
|
|
52
|
+
state: ctx.state,
|
|
53
|
+
}));
|
|
54
|
+
return {
|
|
55
|
+
name: config.name,
|
|
56
|
+
execute,
|
|
57
|
+
manifest,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=llm-coordinator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-coordinator.js","sourceRoot":"","sources":["../src/llm-coordinator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,oCAAoC,EAAE,MAAM,sBAAsB,CAAC;AA6B3F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAA6C,EAC7C,OAAqE;IAErE,iBAAiB;IACjB,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,EAAE,iBAAiB,EAAE;QACxD,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,IAAI;KAClC,CAAC,CAAC;IAEH,oCAAoC;IACpC,MAAM,OAAO,GAAG,oCAAoC,CAClD,MAAM,EACN,OAAO,EACP,CAAC,GAAuB,EAAsB,EAAE,CAAC,CAAC;QAChD,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,IAAI;QACjC,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,KAAK,EAAE,GAAG,CAAC,KAAK;KACjB,CAAC,CACH,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,OAAO;QACP,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { type z } from 'zod';
|
|
2
|
+
import type { Agent, LLMEventHandlerContext } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for defining an LLM event handler agent
|
|
5
|
+
*/
|
|
6
|
+
export interface LLMEventHandlerConfig<TInput, TOutput> {
|
|
7
|
+
/** Unique name for the agent */
|
|
8
|
+
name: string;
|
|
9
|
+
/** Human-readable description of what the agent does */
|
|
10
|
+
description: string;
|
|
11
|
+
/** Semantic version (e.g., "1.0.0") */
|
|
12
|
+
version: string;
|
|
13
|
+
/** Zod schema for input validation */
|
|
14
|
+
inputSchema: z.ZodType<TInput>;
|
|
15
|
+
/** Zod schema for output validation */
|
|
16
|
+
outputSchema: z.ZodType<TOutput>;
|
|
17
|
+
/** Event types this agent subscribes to (optional) */
|
|
18
|
+
subscribesTo?: string[];
|
|
19
|
+
/** Whether this agent can be mocked in tests (default: true) */
|
|
20
|
+
mockable?: boolean;
|
|
21
|
+
/** Additional metadata */
|
|
22
|
+
metadata?: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Defines an LLM event handler agent that reacts to events using
|
|
26
|
+
* language model reasoning and processing.
|
|
27
|
+
*
|
|
28
|
+
* The agent validates inputs and outputs using Zod schemas and provides
|
|
29
|
+
* access to LLM capabilities, event data, and event emission.
|
|
30
|
+
*
|
|
31
|
+
* @param config - Agent configuration including schemas and event subscriptions
|
|
32
|
+
* @param handler - Async function that handles events using LLM
|
|
33
|
+
* @returns Agent with validated execute function and manifest
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const handler = defineLLMEventHandler(
|
|
38
|
+
* {
|
|
39
|
+
* name: 'support-ticket-handler',
|
|
40
|
+
* description: 'Analyzes and routes support tickets',
|
|
41
|
+
* version: '1.0.0',
|
|
42
|
+
* inputSchema: z.object({ ticketId: z.string(), content: z.string() }),
|
|
43
|
+
* outputSchema: z.object({ priority: z.string(), category: z.string() }),
|
|
44
|
+
* subscribesTo: ['ticket.created'],
|
|
45
|
+
* },
|
|
46
|
+
* async (input, ctx) => {
|
|
47
|
+
* // Use LLM to analyze ticket
|
|
48
|
+
* const analysis = await ctx.callLLM(
|
|
49
|
+
* `Analyze this support ticket and determine priority and category: ${input.content}`
|
|
50
|
+
* );
|
|
51
|
+
*
|
|
52
|
+
* // Store analysis in state
|
|
53
|
+
* ctx.state.set(`ticket:${input.ticketId}`, analysis);
|
|
54
|
+
*
|
|
55
|
+
* // Emit routing event
|
|
56
|
+
* await ctx.emit('ticket.analyzed', {
|
|
57
|
+
* ticketId: input.ticketId,
|
|
58
|
+
* analysis,
|
|
59
|
+
* });
|
|
60
|
+
*
|
|
61
|
+
* return { priority: 'high', category: 'technical' };
|
|
62
|
+
* }
|
|
63
|
+
* );
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare function defineLLMEventHandler<TInput, TOutput>(config: LLMEventHandlerConfig<TInput, TOutput>, handler: (input: TInput, ctx: LLMEventHandlerContext) => Promise<TOutput>): Agent<TInput, TOutput>;
|
|
67
|
+
//# sourceMappingURL=llm-event-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-event-handler.d.ts","sourceRoot":"","sources":["../src/llm-event-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,CAAC;AAG7B,OAAO,KAAK,EAAE,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,qBAAqB,CAAC,MAAM,EAAE,OAAO;IACpD,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IAEb,wDAAwD;IACxD,WAAW,EAAE,MAAM,CAAC;IAEpB,uCAAuC;IACvC,OAAO,EAAE,MAAM,CAAC;IAEhB,sCAAsC;IACtC,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAE/B,uCAAuC;IACvC,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAEjC,sDAAsD;IACtD,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAExB,gEAAgE;IAChE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,OAAO,EACnD,MAAM,EAAE,qBAAqB,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9C,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,sBAAsB,KAAK,OAAO,CAAC,OAAO,CAAC,GACxE,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CA0BxB"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { buildManifest, createAsyncExecuteWrapperWithContext } from './execute-wrapper.js';
|
|
2
|
+
/**
|
|
3
|
+
* Defines an LLM event handler agent that reacts to events using
|
|
4
|
+
* language model reasoning and processing.
|
|
5
|
+
*
|
|
6
|
+
* The agent validates inputs and outputs using Zod schemas and provides
|
|
7
|
+
* access to LLM capabilities, event data, and event emission.
|
|
8
|
+
*
|
|
9
|
+
* @param config - Agent configuration including schemas and event subscriptions
|
|
10
|
+
* @param handler - Async function that handles events using LLM
|
|
11
|
+
* @returns Agent with validated execute function and manifest
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const handler = defineLLMEventHandler(
|
|
16
|
+
* {
|
|
17
|
+
* name: 'support-ticket-handler',
|
|
18
|
+
* description: 'Analyzes and routes support tickets',
|
|
19
|
+
* version: '1.0.0',
|
|
20
|
+
* inputSchema: z.object({ ticketId: z.string(), content: z.string() }),
|
|
21
|
+
* outputSchema: z.object({ priority: z.string(), category: z.string() }),
|
|
22
|
+
* subscribesTo: ['ticket.created'],
|
|
23
|
+
* },
|
|
24
|
+
* async (input, ctx) => {
|
|
25
|
+
* // Use LLM to analyze ticket
|
|
26
|
+
* const analysis = await ctx.callLLM(
|
|
27
|
+
* `Analyze this support ticket and determine priority and category: ${input.content}`
|
|
28
|
+
* );
|
|
29
|
+
*
|
|
30
|
+
* // Store analysis in state
|
|
31
|
+
* ctx.state.set(`ticket:${input.ticketId}`, analysis);
|
|
32
|
+
*
|
|
33
|
+
* // Emit routing event
|
|
34
|
+
* await ctx.emit('ticket.analyzed', {
|
|
35
|
+
* ticketId: input.ticketId,
|
|
36
|
+
* analysis,
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* return { priority: 'high', category: 'technical' };
|
|
40
|
+
* }
|
|
41
|
+
* );
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export function defineLLMEventHandler(config, handler) {
|
|
45
|
+
// Build manifest
|
|
46
|
+
const manifest = buildManifest(config, 'llm-event-handler', {
|
|
47
|
+
mockable: config.mockable ?? true,
|
|
48
|
+
...(config.subscribesTo && { subscribesTo: config.subscribesTo }),
|
|
49
|
+
});
|
|
50
|
+
// Create validated execute function
|
|
51
|
+
const execute = createAsyncExecuteWrapperWithContext(config, handler, (ctx) => ({
|
|
52
|
+
mockable: config.mockable ?? true,
|
|
53
|
+
eventType: ctx.eventType,
|
|
54
|
+
eventData: ctx.eventData,
|
|
55
|
+
callLLM: ctx.callLLM,
|
|
56
|
+
emit: ctx.emit,
|
|
57
|
+
state: ctx.state,
|
|
58
|
+
}));
|
|
59
|
+
return {
|
|
60
|
+
name: config.name,
|
|
61
|
+
execute,
|
|
62
|
+
manifest,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=llm-event-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-event-handler.js","sourceRoot":"","sources":["../src/llm-event-handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,oCAAoC,EAAE,MAAM,sBAAsB,CAAC;AAgC3F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,UAAU,qBAAqB,CACnC,MAA8C,EAC9C,OAAyE;IAEzE,iBAAiB;IACjB,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,EAAE,mBAAmB,EAAE;QAC1D,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,IAAI;QACjC,GAAG,CAAC,MAAM,CAAC,YAAY,IAAI,EAAE,YAAY,EAAE,MAAM,CAAC,YAAY,EAAE,CAAC;KAClE,CAAC,CAAC;IAEH,oCAAoC;IACpC,MAAM,OAAO,GAAG,oCAAoC,CAClD,MAAM,EACN,OAAO,EACP,CAAC,GAA2B,EAA0B,EAAE,CAAC,CAAC;QACxD,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,IAAI;QACjC,SAAS,EAAE,GAAG,CAAC,SAAS;QACxB,SAAS,EAAE,GAAG,CAAC,SAAS;QACxB,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,KAAK,EAAE,GAAG,CAAC,KAAK;KACjB,CAAC,CACH,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,OAAO;QACP,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { BaseAgentConfig, PureFunctionAgent } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for defining a pure function agent
|
|
4
|
+
*/
|
|
5
|
+
export type PureFunctionConfig<TInput, TOutput> = BaseAgentConfig<TInput, TOutput>;
|
|
6
|
+
/**
|
|
7
|
+
* Defines a pure function agent that performs deterministic transformations
|
|
8
|
+
* without side effects or external dependencies.
|
|
9
|
+
*
|
|
10
|
+
* The agent validates inputs and outputs using Zod schemas and generates
|
|
11
|
+
* a manifest describing its interface.
|
|
12
|
+
*
|
|
13
|
+
* @param config - Agent configuration including schemas and metadata
|
|
14
|
+
* @param handler - Pure function that transforms input to output
|
|
15
|
+
* @returns Agent with validated execute function and manifest
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const addAgent = definePureFunction(
|
|
20
|
+
* {
|
|
21
|
+
* name: 'add',
|
|
22
|
+
* description: 'Adds two numbers',
|
|
23
|
+
* version: '1.0.0',
|
|
24
|
+
* inputSchema: z.object({ a: z.number(), b: z.number() }),
|
|
25
|
+
* outputSchema: z.number(),
|
|
26
|
+
* },
|
|
27
|
+
* (input) => input.a + input.b
|
|
28
|
+
* );
|
|
29
|
+
*
|
|
30
|
+
* const result = addAgent.execute({ a: 2, b: 3 }); // 5
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function definePureFunction<TInput, TOutput>(config: PureFunctionConfig<TInput, TOutput>, handler: (input: TInput) => TOutput): PureFunctionAgent<TInput, TOutput>;
|
|
34
|
+
//# sourceMappingURL=pure-function.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pure-function.d.ts","sourceRoot":"","sources":["../src/pure-function.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAErE;;GAEG;AACH,MAAM,MAAM,kBAAkB,CAAC,MAAM,EAAE,OAAO,IAAI,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEnF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,OAAO,EAChD,MAAM,EAAE,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3C,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,GAClC,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,CAYpC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { buildManifest, createPureExecuteWrapper } from './execute-wrapper.js';
|
|
2
|
+
/**
|
|
3
|
+
* Defines a pure function agent that performs deterministic transformations
|
|
4
|
+
* without side effects or external dependencies.
|
|
5
|
+
*
|
|
6
|
+
* The agent validates inputs and outputs using Zod schemas and generates
|
|
7
|
+
* a manifest describing its interface.
|
|
8
|
+
*
|
|
9
|
+
* @param config - Agent configuration including schemas and metadata
|
|
10
|
+
* @param handler - Pure function that transforms input to output
|
|
11
|
+
* @returns Agent with validated execute function and manifest
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const addAgent = definePureFunction(
|
|
16
|
+
* {
|
|
17
|
+
* name: 'add',
|
|
18
|
+
* description: 'Adds two numbers',
|
|
19
|
+
* version: '1.0.0',
|
|
20
|
+
* inputSchema: z.object({ a: z.number(), b: z.number() }),
|
|
21
|
+
* outputSchema: z.number(),
|
|
22
|
+
* },
|
|
23
|
+
* (input) => input.a + input.b
|
|
24
|
+
* );
|
|
25
|
+
*
|
|
26
|
+
* const result = addAgent.execute({ a: 2, b: 3 }); // 5
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export function definePureFunction(config, handler) {
|
|
30
|
+
// Build manifest
|
|
31
|
+
const manifest = buildManifest(config, 'pure-function');
|
|
32
|
+
// Create validated execute function
|
|
33
|
+
const execute = createPureExecuteWrapper(config, handler);
|
|
34
|
+
return {
|
|
35
|
+
name: config.name,
|
|
36
|
+
execute,
|
|
37
|
+
manifest,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=pure-function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pure-function.js","sourceRoot":"","sources":["../src/pure-function.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAQ/E;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,kBAAkB,CAChC,MAA2C,EAC3C,OAAmC;IAEnC,iBAAiB;IACjB,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAExD,oCAAoC;IACpC,MAAM,OAAO,GAAG,wBAAwB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE1D,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,OAAO;QACP,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper functions for working with agent results.
|
|
3
|
+
* Provides Railway-Oriented Programming patterns for orchestration.
|
|
4
|
+
*/
|
|
5
|
+
import { type AgentResult, type OneShotAgentOutput, type StatefulAgentResult } from '@vibe-agent-toolkit/agent-schema';
|
|
6
|
+
/**
|
|
7
|
+
* Map success value, propagate errors.
|
|
8
|
+
* Classic functor map operation.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const result = { status: 'success', data: 5 };
|
|
12
|
+
* const doubled = mapResult(result, x => x * 2);
|
|
13
|
+
* // doubled = { status: 'success', data: 10 }
|
|
14
|
+
*/
|
|
15
|
+
export declare function mapResult<T, U, E extends string>(result: AgentResult<T, E>, fn: (data: T) => U): AgentResult<U, E>;
|
|
16
|
+
/**
|
|
17
|
+
* Chain dependent operations (monadic bind).
|
|
18
|
+
* Only runs next operation if current succeeded.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* const result1 = await agent1.execute(input);
|
|
22
|
+
* const result2 = await andThen(result1.result, async (data) => {
|
|
23
|
+
* const output = await agent2.execute(data);
|
|
24
|
+
* return output.result;
|
|
25
|
+
* });
|
|
26
|
+
*/
|
|
27
|
+
export declare function andThen<T, U, E extends string>(result: AgentResult<T, E>, fn: (data: T) => Promise<AgentResult<U, E>>): Promise<AgentResult<U, E>>;
|
|
28
|
+
/**
|
|
29
|
+
* Pattern matching on result status.
|
|
30
|
+
* Exhaustive handling of all cases.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* const message = match(result, {
|
|
34
|
+
* success: (data) => `Success: ${data}`,
|
|
35
|
+
* error: (err) => `Error: ${err}`,
|
|
36
|
+
* inProgress: () => 'Still working...'
|
|
37
|
+
* });
|
|
38
|
+
*/
|
|
39
|
+
export declare function match<T, E extends string, R>(result: StatefulAgentResult<T, E>, handlers: {
|
|
40
|
+
success: (data: T) => R;
|
|
41
|
+
error: (error: E) => R;
|
|
42
|
+
inProgress?: (metadata?: unknown) => R;
|
|
43
|
+
}): R | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Unwrap result or throw error.
|
|
46
|
+
* Use when you want to convert to exception-based flow.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* try {
|
|
50
|
+
* const data = unwrap(result);
|
|
51
|
+
* console.log('Success:', data);
|
|
52
|
+
* } catch (err) {
|
|
53
|
+
* console.error('Failed:', err);
|
|
54
|
+
* }
|
|
55
|
+
*/
|
|
56
|
+
export declare function unwrap<T, E extends string>(result: AgentResult<T, E>): T;
|
|
57
|
+
/**
|
|
58
|
+
* Wrap agent execution with retry logic.
|
|
59
|
+
*
|
|
60
|
+
* Automatically retries on transient failures (timeouts, rate limits, unavailable),
|
|
61
|
+
* injects retry count into execution metadata, and uses exponential backoff.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* const agent = createAgent({...});
|
|
65
|
+
* const withRetries = withRetry(() => agent.execute(input), 5);
|
|
66
|
+
* const output = await withRetries;
|
|
67
|
+
* // output.result.execution.retryCount shows how many retries were needed
|
|
68
|
+
*/
|
|
69
|
+
export declare function withRetry<TData, TError extends string>(agentFn: () => Promise<OneShotAgentOutput<TData, TError>>, maxAttempts?: number): Promise<OneShotAgentOutput<TData, TError>>;
|
|
70
|
+
/**
|
|
71
|
+
* Wrap agent execution with timing metadata.
|
|
72
|
+
*
|
|
73
|
+
* Measures execution duration and injects it into ExecutionMetadata.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* const output = await withTiming(() => agent.execute(input));
|
|
77
|
+
* console.log(`Execution took ${output.result.execution?.durationMs}ms`);
|
|
78
|
+
*/
|
|
79
|
+
export declare function withTiming<TData, TError extends string>(agentFn: () => Promise<OneShotAgentOutput<TData, TError>>): Promise<OneShotAgentOutput<TData, TError>>;
|
|
80
|
+
//# sourceMappingURL=result-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result-helpers.d.ts","sourceRoot":"","sources":["../src/result-helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EASL,KAAK,WAAW,EAIhB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACzB,MAAM,kCAAkC,CAAC;AAE1C;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,MAAM,EAC9C,MAAM,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EACzB,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GACjB,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAWnB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,MAAM,EAClD,MAAM,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EACzB,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAC1C,OAAO,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAK5B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,EAAE,CAAC,EAC1C,MAAM,EAAE,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,EACjC,QAAQ,EAAE;IACR,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC;IACxB,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC;IACvB,UAAU,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,OAAO,KAAK,CAAC,CAAC;CACxC,GACA,CAAC,GAAG,SAAS,CASf;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAKxE;AAmDD;;;;;;;;;;;GAWG;AACH,wBAAsB,SAAS,CAAC,KAAK,EAAE,MAAM,SAAS,MAAM,EAC1D,OAAO,EAAE,MAAM,OAAO,CAAC,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,EACzD,WAAW,GAAE,MAAU,GACtB,OAAO,CAAC,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CA2E5C;AAED;;;;;;;;GAQG;AACH,wBAAsB,UAAU,CAAC,KAAK,EAAE,MAAM,SAAS,MAAM,EAC3D,OAAO,EAAE,MAAM,OAAO,CAAC,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,GACxD,OAAO,CAAC,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAmB5C"}
|