@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,59 @@
|
|
|
1
|
+
import { type z } from 'zod';
|
|
2
|
+
import type { AgentManifest, ConversationalContext } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for execute wrappers
|
|
5
|
+
*/
|
|
6
|
+
export interface ExecuteWrapperConfig<TInput, TOutput> {
|
|
7
|
+
inputSchema: z.ZodType<TInput>;
|
|
8
|
+
outputSchema: z.ZodType<TOutput>;
|
|
9
|
+
name: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Builds an agent manifest from configuration.
|
|
13
|
+
*
|
|
14
|
+
* @param config - Base configuration with name, description, version, schemas
|
|
15
|
+
* @param archetype - The agent archetype name
|
|
16
|
+
* @param metadata - Optional additional metadata to merge
|
|
17
|
+
* @returns Agent manifest with JSON schemas
|
|
18
|
+
*/
|
|
19
|
+
export declare function buildManifest<TInput, TOutput>(config: {
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
version: string;
|
|
23
|
+
inputSchema: z.ZodType<TInput>;
|
|
24
|
+
outputSchema: z.ZodType<TOutput>;
|
|
25
|
+
metadata?: Record<string, unknown>;
|
|
26
|
+
}, archetype: string, metadata?: Record<string, unknown>): AgentManifest;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a validated execute wrapper for pure (synchronous) functions.
|
|
29
|
+
*
|
|
30
|
+
* @param config - Configuration containing input/output schemas and agent name
|
|
31
|
+
* @param handler - Pure function that transforms input to output
|
|
32
|
+
* @returns Validated execute function
|
|
33
|
+
*/
|
|
34
|
+
export declare function createPureExecuteWrapper<TInput, TOutput>(config: ExecuteWrapperConfig<TInput, TOutput>, handler: (input: TInput) => TOutput): (input: TInput) => TOutput;
|
|
35
|
+
/**
|
|
36
|
+
* Creates a validated execute wrapper for async functions with simple context.
|
|
37
|
+
* Context is passed through without modification.
|
|
38
|
+
*
|
|
39
|
+
* @param config - Configuration containing input/output schemas and agent name
|
|
40
|
+
* @param handler - Async function that transforms input to output using context
|
|
41
|
+
* @returns Validated async execute function
|
|
42
|
+
*/
|
|
43
|
+
export declare function createAsyncExecuteWrapper<TInput, TOutput, TContext>(config: ExecuteWrapperConfig<TInput, TOutput>, handler: (input: TInput, ctx: TContext) => Promise<TOutput>): (input: TInput, ...args: unknown[]) => Promise<TOutput>;
|
|
44
|
+
/**
|
|
45
|
+
* Creates a validated execute wrapper for async functions with context merging.
|
|
46
|
+
* Builds context by merging runtime context with config values using a builder function.
|
|
47
|
+
*
|
|
48
|
+
* @param config - Configuration containing input/output schemas and agent name
|
|
49
|
+
* @param handler - Async function that transforms input to output using context
|
|
50
|
+
* @param contextBuilder - Function that builds full context from runtime context and config
|
|
51
|
+
* @returns Validated async execute function
|
|
52
|
+
*/
|
|
53
|
+
export declare function createAsyncExecuteWrapperWithContext<TInput, TOutput, TContext>(config: ExecuteWrapperConfig<TInput, TOutput>, handler: (input: TInput, ctx: TContext) => Promise<TOutput>, contextBuilder: (runtimeCtx: TContext) => TContext): (input: TInput, ...args: unknown[]) => Promise<TOutput>;
|
|
54
|
+
/**
|
|
55
|
+
* Creates a standard context mapper for conversational agents
|
|
56
|
+
* (shared to avoid duplication across conversational agent types)
|
|
57
|
+
*/
|
|
58
|
+
export declare function createConversationalContextMapper(mockable: boolean): (ctx: ConversationalContext) => ConversationalContext;
|
|
59
|
+
//# sourceMappingURL=execute-wrapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-wrapper.d.ts","sourceRoot":"","sources":["../src/execute-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,CAAC;AAG7B,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,oBAAoB,CAAC,MAAM,EAAE,OAAO;IACnD,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/B,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;CACd;AA4BD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,OAAO,EAC3C,MAAM,EAAE;IACN,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/B,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,EACD,SAAS,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,aAAa,CAsBf;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,OAAO,EACtD,MAAM,EAAE,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7C,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,GAClC,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAE5B;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EACjE,MAAM,EAAE,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7C,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,KAAK,OAAO,CAAC,OAAO,CAAC,GAC1D,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAOzD;AAED;;;;;;;;GAQG;AACH,wBAAgB,oCAAoC,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAC5E,MAAM,EAAE,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7C,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,KAAK,OAAO,CAAC,OAAO,CAAC,EAC3D,cAAc,EAAE,CAAC,UAAU,EAAE,QAAQ,KAAK,QAAQ,GACjD,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAQzD;AAED;;;GAGG;AACH,wBAAgB,iCAAiC,CAC/C,QAAQ,EAAE,OAAO,GAChB,CAAC,GAAG,EAAE,qBAAqB,KAAK,qBAAqB,CAOvD"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { convertToJsonSchema, validateInput, validateOutput } from './shared-validation.js';
|
|
2
|
+
/**
|
|
3
|
+
* Validates input for synchronous execution
|
|
4
|
+
*/
|
|
5
|
+
function executeWithValidationSync(input, config, handler) {
|
|
6
|
+
const validatedInput = validateInput(input, config.inputSchema, config.name);
|
|
7
|
+
const output = handler(validatedInput);
|
|
8
|
+
return validateOutput(output, config.outputSchema, config.name);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Validates input and output for async execution
|
|
12
|
+
*/
|
|
13
|
+
async function executeWithValidationAsync(input, config, handler) {
|
|
14
|
+
const validatedInput = validateInput(input, config.inputSchema, config.name);
|
|
15
|
+
const output = await handler(validatedInput);
|
|
16
|
+
return validateOutput(output, config.outputSchema, config.name);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Builds an agent manifest from configuration.
|
|
20
|
+
*
|
|
21
|
+
* @param config - Base configuration with name, description, version, schemas
|
|
22
|
+
* @param archetype - The agent archetype name
|
|
23
|
+
* @param metadata - Optional additional metadata to merge
|
|
24
|
+
* @returns Agent manifest with JSON schemas
|
|
25
|
+
*/
|
|
26
|
+
export function buildManifest(config, archetype, metadata) {
|
|
27
|
+
const inputJsonSchema = convertToJsonSchema(config.inputSchema, `${config.name}Input`);
|
|
28
|
+
const outputJsonSchema = convertToJsonSchema(config.outputSchema, `${config.name}Output`);
|
|
29
|
+
const manifest = {
|
|
30
|
+
name: config.name,
|
|
31
|
+
description: config.description,
|
|
32
|
+
version: config.version,
|
|
33
|
+
inputSchema: inputJsonSchema,
|
|
34
|
+
outputSchema: outputJsonSchema,
|
|
35
|
+
archetype,
|
|
36
|
+
};
|
|
37
|
+
// Merge metadata if provided
|
|
38
|
+
if (config.metadata || metadata) {
|
|
39
|
+
manifest.metadata = {
|
|
40
|
+
...config.metadata,
|
|
41
|
+
...metadata,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return manifest;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Creates a validated execute wrapper for pure (synchronous) functions.
|
|
48
|
+
*
|
|
49
|
+
* @param config - Configuration containing input/output schemas and agent name
|
|
50
|
+
* @param handler - Pure function that transforms input to output
|
|
51
|
+
* @returns Validated execute function
|
|
52
|
+
*/
|
|
53
|
+
export function createPureExecuteWrapper(config, handler) {
|
|
54
|
+
return (input) => executeWithValidationSync(input, config, handler);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Creates a validated execute wrapper for async functions with simple context.
|
|
58
|
+
* Context is passed through without modification.
|
|
59
|
+
*
|
|
60
|
+
* @param config - Configuration containing input/output schemas and agent name
|
|
61
|
+
* @param handler - Async function that transforms input to output using context
|
|
62
|
+
* @returns Validated async execute function
|
|
63
|
+
*/
|
|
64
|
+
export function createAsyncExecuteWrapper(config, handler) {
|
|
65
|
+
return (input, ...args) => {
|
|
66
|
+
const ctx = args[0];
|
|
67
|
+
return executeWithValidationAsync(input, config, (validatedInput) => handler(validatedInput, ctx));
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Creates a validated execute wrapper for async functions with context merging.
|
|
72
|
+
* Builds context by merging runtime context with config values using a builder function.
|
|
73
|
+
*
|
|
74
|
+
* @param config - Configuration containing input/output schemas and agent name
|
|
75
|
+
* @param handler - Async function that transforms input to output using context
|
|
76
|
+
* @param contextBuilder - Function that builds full context from runtime context and config
|
|
77
|
+
* @returns Validated async execute function
|
|
78
|
+
*/
|
|
79
|
+
export function createAsyncExecuteWrapperWithContext(config, handler, contextBuilder) {
|
|
80
|
+
return (input, ...args) => {
|
|
81
|
+
const runtimeCtx = args[0];
|
|
82
|
+
const fullContext = contextBuilder(runtimeCtx);
|
|
83
|
+
return executeWithValidationAsync(input, config, (validatedInput) => handler(validatedInput, fullContext));
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Creates a standard context mapper for conversational agents
|
|
88
|
+
* (shared to avoid duplication across conversational agent types)
|
|
89
|
+
*/
|
|
90
|
+
export function createConversationalContextMapper(mockable) {
|
|
91
|
+
return (ctx) => ({
|
|
92
|
+
mockable,
|
|
93
|
+
history: ctx.history,
|
|
94
|
+
addToHistory: ctx.addToHistory,
|
|
95
|
+
callLLM: ctx.callLLM,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=execute-wrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-wrapper.js","sourceRoot":"","sources":["../src/execute-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,iCAAiC,CAC/C,QAAiB;IAEjB,OAAO,CAAC,GAA0B,EAAyB,EAAE,CAAC,CAAC;QAC7D,QAAQ;QACR,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,YAAY,EAAE,GAAG,CAAC,YAAY;QAC9B,OAAO,EAAE,GAAG,CAAC,OAAO;KACrB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type z } from 'zod';
|
|
2
|
+
import type { Agent, ExternalEventContext } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for defining an external event integrator agent
|
|
5
|
+
*/
|
|
6
|
+
export interface ExternalEventIntegratorConfig<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
|
+
/** Timeout in milliseconds (optional) */
|
|
18
|
+
timeoutMs?: number;
|
|
19
|
+
/** Action to take on timeout: approve, reject, or error (default: error) */
|
|
20
|
+
onTimeout?: 'approve' | 'reject' | 'error';
|
|
21
|
+
/** Additional metadata */
|
|
22
|
+
metadata?: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Defines an external event integrator agent that coordinates with
|
|
26
|
+
* external systems or human users via events.
|
|
27
|
+
*
|
|
28
|
+
* The agent validates inputs and outputs using Zod schemas and provides
|
|
29
|
+
* utilities for emitting events and waiting for responses with timeout handling.
|
|
30
|
+
*
|
|
31
|
+
* @param config - Agent configuration including schemas and timeout settings
|
|
32
|
+
* @param handler - Async function that integrates with external events
|
|
33
|
+
* @returns Agent with validated execute function and manifest
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const approvalAgent = defineExternalEventIntegrator(
|
|
38
|
+
* {
|
|
39
|
+
* name: 'human-approval',
|
|
40
|
+
* description: 'Requests human approval for actions',
|
|
41
|
+
* version: '1.0.0',
|
|
42
|
+
* inputSchema: z.object({ action: z.string(), details: z.string() }),
|
|
43
|
+
* outputSchema: z.object({ approved: z.boolean(), feedback: z.string().optional() }),
|
|
44
|
+
* timeoutMs: 60000, // 1 minute
|
|
45
|
+
* onTimeout: 'reject',
|
|
46
|
+
* },
|
|
47
|
+
* async (input, ctx) => {
|
|
48
|
+
* // Emit approval request to external system
|
|
49
|
+
* await ctx.emit('approval.requested', {
|
|
50
|
+
* action: input.action,
|
|
51
|
+
* details: input.details,
|
|
52
|
+
* });
|
|
53
|
+
*
|
|
54
|
+
* // Wait for human response
|
|
55
|
+
* const response = await ctx.waitFor<{ approved: boolean; feedback?: string }>(
|
|
56
|
+
* 'approval.response',
|
|
57
|
+
* ctx.timeoutMs ?? 60000
|
|
58
|
+
* );
|
|
59
|
+
*
|
|
60
|
+
* return response;
|
|
61
|
+
* }
|
|
62
|
+
* );
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare function defineExternalEventIntegrator<TInput, TOutput>(config: ExternalEventIntegratorConfig<TInput, TOutput>, handler: (input: TInput, ctx: ExternalEventContext) => Promise<TOutput>): Agent<TInput, TOutput>;
|
|
66
|
+
//# sourceMappingURL=external-event-integrator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external-event-integrator.d.ts","sourceRoot":"","sources":["../src/external-event-integrator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,CAAC;AAG7B,OAAO,KAAK,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,6BAA6B,CAAC,MAAM,EAAE,OAAO;IAC5D,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,yCAAyC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,4EAA4E;IAC5E,SAAS,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAC;IAE3C,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,OAAO,EAC3D,MAAM,EAAE,6BAA6B,CAAC,MAAM,EAAE,OAAO,CAAC,EACtD,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,oBAAoB,KAAK,OAAO,CAAC,OAAO,CAAC,GACtE,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAwBxB"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { buildManifest, createAsyncExecuteWrapperWithContext } from './execute-wrapper.js';
|
|
2
|
+
/**
|
|
3
|
+
* Defines an external event integrator agent that coordinates with
|
|
4
|
+
* external systems or human users via events.
|
|
5
|
+
*
|
|
6
|
+
* The agent validates inputs and outputs using Zod schemas and provides
|
|
7
|
+
* utilities for emitting events and waiting for responses with timeout handling.
|
|
8
|
+
*
|
|
9
|
+
* @param config - Agent configuration including schemas and timeout settings
|
|
10
|
+
* @param handler - Async function that integrates with external events
|
|
11
|
+
* @returns Agent with validated execute function and manifest
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const approvalAgent = defineExternalEventIntegrator(
|
|
16
|
+
* {
|
|
17
|
+
* name: 'human-approval',
|
|
18
|
+
* description: 'Requests human approval for actions',
|
|
19
|
+
* version: '1.0.0',
|
|
20
|
+
* inputSchema: z.object({ action: z.string(), details: z.string() }),
|
|
21
|
+
* outputSchema: z.object({ approved: z.boolean(), feedback: z.string().optional() }),
|
|
22
|
+
* timeoutMs: 60000, // 1 minute
|
|
23
|
+
* onTimeout: 'reject',
|
|
24
|
+
* },
|
|
25
|
+
* async (input, ctx) => {
|
|
26
|
+
* // Emit approval request to external system
|
|
27
|
+
* await ctx.emit('approval.requested', {
|
|
28
|
+
* action: input.action,
|
|
29
|
+
* details: input.details,
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* // Wait for human response
|
|
33
|
+
* const response = await ctx.waitFor<{ approved: boolean; feedback?: string }>(
|
|
34
|
+
* 'approval.response',
|
|
35
|
+
* ctx.timeoutMs ?? 60000
|
|
36
|
+
* );
|
|
37
|
+
*
|
|
38
|
+
* return response;
|
|
39
|
+
* }
|
|
40
|
+
* );
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export function defineExternalEventIntegrator(config, handler) {
|
|
44
|
+
// Build manifest
|
|
45
|
+
const manifest = buildManifest(config, 'external-event-integrator', {
|
|
46
|
+
...(config.timeoutMs === undefined ? {} : { timeoutMs: config.timeoutMs }),
|
|
47
|
+
onTimeout: config.onTimeout ?? 'error',
|
|
48
|
+
});
|
|
49
|
+
// Create validated execute function
|
|
50
|
+
const execute = createAsyncExecuteWrapperWithContext(config, handler, (ctx) => ({
|
|
51
|
+
emit: ctx.emit,
|
|
52
|
+
waitFor: ctx.waitFor,
|
|
53
|
+
...(config.timeoutMs !== undefined && { timeoutMs: config.timeoutMs }),
|
|
54
|
+
onTimeout: config.onTimeout ?? 'error',
|
|
55
|
+
}));
|
|
56
|
+
return {
|
|
57
|
+
name: config.name,
|
|
58
|
+
execute,
|
|
59
|
+
manifest,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=external-event-integrator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external-event-integrator.js","sourceRoot":"","sources":["../src/external-event-integrator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,oCAAoC,EAAE,MAAM,sBAAsB,CAAC;AAgC3F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,UAAU,6BAA6B,CAC3C,MAAsD,EACtD,OAAuE;IAEvE,iBAAiB;IACjB,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,EAAE,2BAA2B,EAAE;QAClE,GAAG,CAAC,MAAM,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC;QAC1E,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,OAAO;KACvC,CAAC,CAAC;IAEH,oCAAoC;IACpC,MAAM,OAAO,GAAG,oCAAoC,CAClD,MAAM,EACN,OAAO,EACP,CAAC,GAAyB,EAAwB,EAAE,CAAC,CAAC;QACpD,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,GAAG,CAAC,MAAM,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC;QACtE,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,OAAO;KACvC,CAAC,CACH,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,OAAO;QACP,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { type z } from 'zod';
|
|
2
|
+
import type { Agent, EventConsumerContext } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for defining a function event consumer agent
|
|
5
|
+
*/
|
|
6
|
+
export interface FunctionEventConsumerConfig<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
|
+
/** Additional metadata */
|
|
20
|
+
metadata?: Record<string, unknown>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Defines a function event consumer agent that reacts to events
|
|
24
|
+
* using deterministic processing logic.
|
|
25
|
+
*
|
|
26
|
+
* The agent validates inputs and outputs using Zod schemas and provides
|
|
27
|
+
* access to event data and the ability to emit new events.
|
|
28
|
+
*
|
|
29
|
+
* @param config - Agent configuration including schemas and event subscriptions
|
|
30
|
+
* @param handler - Async function that processes events
|
|
31
|
+
* @returns Agent with validated execute function and manifest
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const consumer = defineFunctionEventConsumer(
|
|
36
|
+
* {
|
|
37
|
+
* name: 'order-processor',
|
|
38
|
+
* description: 'Processes order events',
|
|
39
|
+
* version: '1.0.0',
|
|
40
|
+
* inputSchema: z.object({ orderId: z.string() }),
|
|
41
|
+
* outputSchema: z.object({ processed: z.boolean() }),
|
|
42
|
+
* subscribesTo: ['order.created', 'order.updated'],
|
|
43
|
+
* },
|
|
44
|
+
* async (input, ctx) => {
|
|
45
|
+
* // Process the order
|
|
46
|
+
* console.log(`Processing ${ctx.eventType}: ${input.orderId}`);
|
|
47
|
+
*
|
|
48
|
+
* // Store state
|
|
49
|
+
* ctx.state.set(`order:${input.orderId}`, ctx.eventData);
|
|
50
|
+
*
|
|
51
|
+
* // Emit completion event
|
|
52
|
+
* await ctx.emit('order.processed', { orderId: input.orderId });
|
|
53
|
+
*
|
|
54
|
+
* return { processed: true };
|
|
55
|
+
* }
|
|
56
|
+
* );
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function defineFunctionEventConsumer<TInput, TOutput>(config: FunctionEventConsumerConfig<TInput, TOutput>, handler: (input: TInput, ctx: EventConsumerContext) => Promise<TOutput>): Agent<TInput, TOutput>;
|
|
60
|
+
//# sourceMappingURL=function-event-consumer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function-event-consumer.d.ts","sourceRoot":"","sources":["../src/function-event-consumer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,CAAC;AAG7B,OAAO,KAAK,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,2BAA2B,CAAC,MAAM,EAAE,OAAO;IAC1D,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,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,OAAO,EACzD,MAAM,EAAE,2BAA2B,CAAC,MAAM,EAAE,OAAO,CAAC,EACpD,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,oBAAoB,KAAK,OAAO,CAAC,OAAO,CAAC,GACtE,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAcxB"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { buildManifest, createAsyncExecuteWrapper } from './execute-wrapper.js';
|
|
2
|
+
/**
|
|
3
|
+
* Defines a function event consumer agent that reacts to events
|
|
4
|
+
* using deterministic processing logic.
|
|
5
|
+
*
|
|
6
|
+
* The agent validates inputs and outputs using Zod schemas and provides
|
|
7
|
+
* access to event data and the ability to emit new events.
|
|
8
|
+
*
|
|
9
|
+
* @param config - Agent configuration including schemas and event subscriptions
|
|
10
|
+
* @param handler - Async function that processes events
|
|
11
|
+
* @returns Agent with validated execute function and manifest
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const consumer = defineFunctionEventConsumer(
|
|
16
|
+
* {
|
|
17
|
+
* name: 'order-processor',
|
|
18
|
+
* description: 'Processes order events',
|
|
19
|
+
* version: '1.0.0',
|
|
20
|
+
* inputSchema: z.object({ orderId: z.string() }),
|
|
21
|
+
* outputSchema: z.object({ processed: z.boolean() }),
|
|
22
|
+
* subscribesTo: ['order.created', 'order.updated'],
|
|
23
|
+
* },
|
|
24
|
+
* async (input, ctx) => {
|
|
25
|
+
* // Process the order
|
|
26
|
+
* console.log(`Processing ${ctx.eventType}: ${input.orderId}`);
|
|
27
|
+
*
|
|
28
|
+
* // Store state
|
|
29
|
+
* ctx.state.set(`order:${input.orderId}`, ctx.eventData);
|
|
30
|
+
*
|
|
31
|
+
* // Emit completion event
|
|
32
|
+
* await ctx.emit('order.processed', { orderId: input.orderId });
|
|
33
|
+
*
|
|
34
|
+
* return { processed: true };
|
|
35
|
+
* }
|
|
36
|
+
* );
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export function defineFunctionEventConsumer(config, handler) {
|
|
40
|
+
// Build manifest
|
|
41
|
+
const manifest = buildManifest(config, 'function-event-consumer', {
|
|
42
|
+
...(config.subscribesTo && { subscribesTo: config.subscribesTo }),
|
|
43
|
+
});
|
|
44
|
+
// Create validated execute function
|
|
45
|
+
const execute = createAsyncExecuteWrapper(config, handler);
|
|
46
|
+
return {
|
|
47
|
+
name: config.name,
|
|
48
|
+
execute,
|
|
49
|
+
manifest,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=function-event-consumer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function-event-consumer.js","sourceRoot":"","sources":["../src/function-event-consumer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AA6BhF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,UAAU,2BAA2B,CACzC,MAAoD,EACpD,OAAuE;IAEvE,iBAAiB;IACjB,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,EAAE,yBAAyB,EAAE;QAChE,GAAG,CAAC,MAAM,CAAC,YAAY,IAAI,EAAE,YAAY,EAAE,MAAM,CAAC,YAAY,EAAE,CAAC;KAClE,CAAC,CAAC;IAEH,oCAAoC;IACpC,MAAM,OAAO,GAAG,yBAAyB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE3D,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,OAAO;QACP,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Agent, BaseAgentConfig, OrchestratorContext } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for defining a function orchestrator agent
|
|
4
|
+
*/
|
|
5
|
+
export type FunctionOrchestratorConfig<TInput, TOutput> = BaseAgentConfig<TInput, TOutput>;
|
|
6
|
+
/**
|
|
7
|
+
* Defines a function orchestrator agent that coordinates multiple other
|
|
8
|
+
* agents or functions to accomplish complex workflows.
|
|
9
|
+
*
|
|
10
|
+
* The agent validates inputs and outputs using Zod schemas and provides
|
|
11
|
+
* utilities for calling other agents, parallel execution, and retries.
|
|
12
|
+
*
|
|
13
|
+
* @param config - Agent configuration including schemas
|
|
14
|
+
* @param handler - Async function that orchestrates other agents
|
|
15
|
+
* @returns Agent with validated execute function and manifest
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const orchestrator = defineFunctionOrchestrator(
|
|
20
|
+
* {
|
|
21
|
+
* name: 'data-pipeline',
|
|
22
|
+
* description: 'Orchestrates data processing pipeline',
|
|
23
|
+
* version: '1.0.0',
|
|
24
|
+
* inputSchema: z.object({ data: z.array(z.string()) }),
|
|
25
|
+
* outputSchema: z.object({ processed: z.array(z.string()) }),
|
|
26
|
+
* },
|
|
27
|
+
* async (input, ctx) => {
|
|
28
|
+
* // Process items in parallel
|
|
29
|
+
* const results = await ctx.parallel(
|
|
30
|
+
* input.data.map(item => () => ctx.call('process-item', { item }))
|
|
31
|
+
* );
|
|
32
|
+
*
|
|
33
|
+
* // Aggregate with retry
|
|
34
|
+
* const aggregated = await ctx.retry(
|
|
35
|
+
* () => ctx.call('aggregate', { results }),
|
|
36
|
+
* { maxAttempts: 3 }
|
|
37
|
+
* );
|
|
38
|
+
*
|
|
39
|
+
* return { processed: aggregated };
|
|
40
|
+
* }
|
|
41
|
+
* );
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function defineFunctionOrchestrator<TInput, TOutput>(config: FunctionOrchestratorConfig<TInput, TOutput>, handler: (input: TInput, ctx: OrchestratorContext) => Promise<TOutput>): Agent<TInput, TOutput>;
|
|
45
|
+
//# sourceMappingURL=function-orchestrator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function-orchestrator.d.ts","sourceRoot":"","sources":["../src/function-orchestrator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAE9E;;GAEG;AACH,MAAM,MAAM,0BAA0B,CAAC,MAAM,EAAE,OAAO,IAAI,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE3F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,OAAO,EACxD,MAAM,EAAE,0BAA0B,CAAC,MAAM,EAAE,OAAO,CAAC,EACnD,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,mBAAmB,KAAK,OAAO,CAAC,OAAO,CAAC,GACrE,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAYxB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { buildManifest, createAsyncExecuteWrapper } from './execute-wrapper.js';
|
|
2
|
+
/**
|
|
3
|
+
* Defines a function orchestrator agent that coordinates multiple other
|
|
4
|
+
* agents or functions to accomplish complex workflows.
|
|
5
|
+
*
|
|
6
|
+
* The agent validates inputs and outputs using Zod schemas and provides
|
|
7
|
+
* utilities for calling other agents, parallel execution, and retries.
|
|
8
|
+
*
|
|
9
|
+
* @param config - Agent configuration including schemas
|
|
10
|
+
* @param handler - Async function that orchestrates other agents
|
|
11
|
+
* @returns Agent with validated execute function and manifest
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const orchestrator = defineFunctionOrchestrator(
|
|
16
|
+
* {
|
|
17
|
+
* name: 'data-pipeline',
|
|
18
|
+
* description: 'Orchestrates data processing pipeline',
|
|
19
|
+
* version: '1.0.0',
|
|
20
|
+
* inputSchema: z.object({ data: z.array(z.string()) }),
|
|
21
|
+
* outputSchema: z.object({ processed: z.array(z.string()) }),
|
|
22
|
+
* },
|
|
23
|
+
* async (input, ctx) => {
|
|
24
|
+
* // Process items in parallel
|
|
25
|
+
* const results = await ctx.parallel(
|
|
26
|
+
* input.data.map(item => () => ctx.call('process-item', { item }))
|
|
27
|
+
* );
|
|
28
|
+
*
|
|
29
|
+
* // Aggregate with retry
|
|
30
|
+
* const aggregated = await ctx.retry(
|
|
31
|
+
* () => ctx.call('aggregate', { results }),
|
|
32
|
+
* { maxAttempts: 3 }
|
|
33
|
+
* );
|
|
34
|
+
*
|
|
35
|
+
* return { processed: aggregated };
|
|
36
|
+
* }
|
|
37
|
+
* );
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export function defineFunctionOrchestrator(config, handler) {
|
|
41
|
+
// Build manifest
|
|
42
|
+
const manifest = buildManifest(config, 'function-orchestrator');
|
|
43
|
+
// Create validated execute function
|
|
44
|
+
const execute = createAsyncExecuteWrapper(config, handler);
|
|
45
|
+
return {
|
|
46
|
+
name: config.name,
|
|
47
|
+
execute,
|
|
48
|
+
manifest,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=function-orchestrator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function-orchestrator.js","sourceRoot":"","sources":["../src/function-orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAQhF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,UAAU,0BAA0B,CACxC,MAAmD,EACnD,OAAsE;IAEtE,iBAAiB;IACjB,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;IAEhE,oCAAoC;IACpC,MAAM,OAAO,GAAG,yBAAyB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE3D,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,OAAO;QACP,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VAT Agent Runtime Framework
|
|
3
|
+
*
|
|
4
|
+
* Provides APIs for defining portable, executable agents with validated
|
|
5
|
+
* input/output contracts and manifest generation.
|
|
6
|
+
*/
|
|
7
|
+
export { definePureFunction, type PureFunctionConfig } from './pure-function.js';
|
|
8
|
+
export { defineLLMAnalyzer, type LLMAnalyzerConfig } from './llm-analyzer.js';
|
|
9
|
+
export { defineConversationalAssistant, type ConversationalAssistantConfig, } from './conversational-assistant.js';
|
|
10
|
+
export { defineTwoPhaseConversationalAssistant, generateGatheringPrompt, generateExtractionPrompt, type TwoPhaseConversationalConfig, type GatheringPhaseConfig, type ExtractionPhaseConfig, type FactorDefinition, } from './two-phase-conversational.js';
|
|
11
|
+
export { defineAgenticResearcher, type AgenticResearcherConfig, } from './agentic-researcher.js';
|
|
12
|
+
export { defineFunctionOrchestrator, type FunctionOrchestratorConfig, } from './function-orchestrator.js';
|
|
13
|
+
export { defineLLMCoordinator, type LLMCoordinatorConfig } from './llm-coordinator.js';
|
|
14
|
+
export { defineFunctionEventConsumer, type FunctionEventConsumerConfig, } from './function-event-consumer.js';
|
|
15
|
+
export { defineLLMEventHandler, type LLMEventHandlerConfig, } from './llm-event-handler.js';
|
|
16
|
+
export { defineExternalEventIntegrator, type ExternalEventIntegratorConfig, } from './external-event-integrator.js';
|
|
17
|
+
export type { Agent, AgentManifest, ConversationalContext, CoordinatorContext, EventConsumerContext, ExternalEventContext, LLMAnalyzerContext, LLMEventHandlerContext, Message, OrchestratorContext, PureFunctionAgent, ResearcherContext, RetryOptions, } from './types.js';
|
|
18
|
+
export { batchConvert, type LLMAnalyzerConversionConfig, type LLMAnalyzerConversionConfigs, type ToolConversionConfig, type ToolConversionConfigs, } from './adapter-types.js';
|
|
19
|
+
export { createConversationalContext } from './conversational-helpers.js';
|
|
20
|
+
export type { Message as SessionMessage, RuntimeSession, SessionMetadata, SessionStore, SessionStoreOptions, FileSessionStoreOptions, } from './session/index.js';
|
|
21
|
+
export { SessionNotFoundError, MemorySessionStore, FileSessionStore, createInitialSession, isSessionExpired, updateSessionAccess, validateSessionId, } from './session/index.js';
|
|
22
|
+
export { andThen, mapResult, match, unwrap, withRetry, withTiming } from './result-helpers.js';
|
|
23
|
+
export { executeExternalEvent, executeLLMAnalyzer, executeLLMCall, validateAgentInput, } from './agent-helpers.js';
|
|
24
|
+
export { createSuccess, createError, createInProgress, RESULT_SUCCESS, RESULT_ERROR, RESULT_IN_PROGRESS, LLM_REFUSAL, LLM_INVALID_OUTPUT, LLM_TIMEOUT, LLM_RATE_LIMIT, LLM_TOKEN_LIMIT, LLM_UNAVAILABLE, EVENT_TIMEOUT, EVENT_UNAVAILABLE, EVENT_REJECTED, EVENT_INVALID_RESPONSE, type AgentResult, type StatefulAgentResult, type ExecutionMetadata, type LLMError, type ExternalEventError, } from '@vibe-agent-toolkit/agent-schema';
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,kBAAkB,EAAE,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EACL,6BAA6B,EAC7B,KAAK,6BAA6B,GACnC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,qCAAqC,EACrC,uBAAuB,EACvB,wBAAwB,EACxB,KAAK,4BAA4B,EACjC,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,GACtB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,uBAAuB,EACvB,KAAK,uBAAuB,GAC7B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,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,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAClB,WAAW,EACX,cAAc,EACd,eAAe,EACf,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,sBAAsB,EACtB,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,QAAQ,EACb,KAAK,kBAAkB,GACxB,MAAM,kCAAkC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VAT Agent Runtime Framework
|
|
3
|
+
*
|
|
4
|
+
* Provides APIs for defining portable, executable agents with validated
|
|
5
|
+
* input/output contracts and manifest generation.
|
|
6
|
+
*/
|
|
7
|
+
export { definePureFunction } from './pure-function.js';
|
|
8
|
+
export { defineLLMAnalyzer } from './llm-analyzer.js';
|
|
9
|
+
export { defineConversationalAssistant, } from './conversational-assistant.js';
|
|
10
|
+
export { defineTwoPhaseConversationalAssistant, generateGatheringPrompt, generateExtractionPrompt, } from './two-phase-conversational.js';
|
|
11
|
+
export { defineAgenticResearcher, } from './agentic-researcher.js';
|
|
12
|
+
export { defineFunctionOrchestrator, } from './function-orchestrator.js';
|
|
13
|
+
export { defineLLMCoordinator } from './llm-coordinator.js';
|
|
14
|
+
export { defineFunctionEventConsumer, } from './function-event-consumer.js';
|
|
15
|
+
export { defineLLMEventHandler, } from './llm-event-handler.js';
|
|
16
|
+
export { defineExternalEventIntegrator, } from './external-event-integrator.js';
|
|
17
|
+
export { batchConvert, } from './adapter-types.js';
|
|
18
|
+
export { createConversationalContext } from './conversational-helpers.js';
|
|
19
|
+
export { SessionNotFoundError, MemorySessionStore, FileSessionStore, createInitialSession, isSessionExpired, updateSessionAccess, validateSessionId, } from './session/index.js';
|
|
20
|
+
export { andThen, mapResult, match, unwrap, withRetry, withTiming } from './result-helpers.js';
|
|
21
|
+
export { executeExternalEvent, executeLLMAnalyzer, executeLLMCall, validateAgentInput, } from './agent-helpers.js';
|
|
22
|
+
// Re-export result constructors and constants from agent-schema for convenience
|
|
23
|
+
// This allows users to import everything they need from agent-runtime
|
|
24
|
+
export { createSuccess, createError, createInProgress, RESULT_SUCCESS, RESULT_ERROR, RESULT_IN_PROGRESS, LLM_REFUSAL, LLM_INVALID_OUTPUT, LLM_TIMEOUT, LLM_RATE_LIMIT, LLM_TOKEN_LIMIT, LLM_UNAVAILABLE, EVENT_TIMEOUT, EVENT_UNAVAILABLE, EVENT_REJECTED, EVENT_INVALID_RESPONSE, } from '@vibe-agent-toolkit/agent-schema';
|
|
25
|
+
// NOTE: resultMatchers is NOT exported from main index to avoid importing vitest
|
|
26
|
+
// in production code. Import directly from './test-helpers.js' in test files.
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,kBAAkB,EAA2B,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAA0B,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EACL,6BAA6B,GAE9B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,qCAAqC,EACrC,uBAAuB,EACvB,wBAAwB,GAKzB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,uBAAuB,GAExB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,0BAA0B,GAE3B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAA6B,MAAM,sBAAsB,CAAC;AACvF,OAAO,EACL,2BAA2B,GAE5B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,qBAAqB,GAEtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,6BAA6B,GAE9B,MAAM,gCAAgC,CAAC;AAkBxC,OAAO,EACL,YAAY,GAKb,MAAM,oB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