@agntk/core 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-v2.d.ts +48 -0
- package/dist/agent-v2.d.ts.map +1 -0
- package/dist/agent-v2.js +365 -0
- package/dist/agent-v2.js.map +1 -0
- package/dist/memory/engine.d.ts +130 -0
- package/dist/memory/engine.d.ts.map +1 -0
- package/dist/memory/engine.js +227 -0
- package/dist/memory/engine.js.map +1 -0
- package/dist/memory/vectra-store.d.ts +31 -0
- package/dist/memory/vectra-store.d.ts.map +1 -0
- package/dist/memory/vectra-store.js +122 -0
- package/dist/memory/vectra-store.js.map +1 -0
- package/dist/models.js +1 -1
- package/dist/models.js.map +1 -1
- package/dist/pool/index.d.ts +7 -0
- package/dist/pool/index.d.ts.map +1 -0
- package/dist/pool/index.js +6 -0
- package/dist/pool/index.js.map +1 -0
- package/dist/pool/specialist-pool.d.ts +59 -0
- package/dist/pool/specialist-pool.d.ts.map +1 -0
- package/dist/pool/specialist-pool.js +224 -0
- package/dist/pool/specialist-pool.js.map +1 -0
- package/dist/pool/tools.d.ts +63 -0
- package/dist/pool/tools.d.ts.map +1 -0
- package/dist/pool/tools.js +83 -0
- package/dist/pool/tools.js.map +1 -0
- package/dist/pool/types.d.ts +79 -0
- package/dist/pool/types.d.ts.map +1 -0
- package/dist/pool/types.js +5 -0
- package/dist/pool/types.js.map +1 -0
- package/dist/presets/index.d.ts +5 -0
- package/dist/presets/index.d.ts.map +1 -0
- package/dist/presets/index.js +5 -0
- package/dist/presets/index.js.map +1 -0
- package/dist/presets/role-registry.d.ts +41 -0
- package/dist/presets/role-registry.d.ts.map +1 -0
- package/dist/presets/role-registry.js +213 -0
- package/dist/presets/role-registry.js.map +1 -0
- package/dist/presets/roles.d.ts +105 -0
- package/dist/presets/roles.d.ts.map +1 -0
- package/dist/presets/roles.js +207 -0
- package/dist/presets/roles.js.map +1 -0
- package/dist/prompts/templates.d.ts +11 -0
- package/dist/prompts/templates.d.ts.map +1 -0
- package/dist/prompts/templates.js +115 -0
- package/dist/prompts/templates.js.map +1 -0
- package/dist/streaming/data-parts.d.ts +163 -0
- package/dist/streaming/data-parts.d.ts.map +1 -0
- package/dist/streaming/data-parts.js +14 -0
- package/dist/streaming/data-parts.js.map +1 -0
- package/dist/streaming/index.d.ts +8 -0
- package/dist/streaming/index.d.ts.map +1 -0
- package/dist/streaming/index.js +10 -0
- package/dist/streaming/index.js.map +1 -0
- package/dist/streaming/transient.d.ts +136 -0
- package/dist/streaming/transient.d.ts.map +1 -0
- package/dist/streaming/transient.js +201 -0
- package/dist/streaming/transient.js.map +1 -0
- package/dist/tools/factory.d.ts +109 -0
- package/dist/tools/factory.d.ts.map +1 -0
- package/dist/tools/factory.js +166 -0
- package/dist/tools/factory.js.map +1 -0
- package/dist/tools/provider.d.ts +97 -0
- package/dist/tools/provider.d.ts.map +1 -0
- package/dist/tools/provider.js +178 -0
- package/dist/tools/provider.js.map +1 -0
- package/dist/types/agent-v2.d.ts +83 -0
- package/dist/types/agent-v2.d.ts.map +1 -0
- package/dist/types/agent-v2.js +8 -0
- package/dist/types/agent-v2.js.map +1 -0
- package/dist/utils/logger.d.ts +35 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +149 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/workflow/builders/adapt.d.ts +20 -0
- package/dist/workflow/builders/adapt.d.ts.map +1 -0
- package/dist/workflow/builders/adapt.js +33 -0
- package/dist/workflow/builders/adapt.js.map +1 -0
- package/dist/workflow/builders/index.d.ts +8 -0
- package/dist/workflow/builders/index.d.ts.map +1 -0
- package/dist/workflow/builders/index.js +7 -0
- package/dist/workflow/builders/index.js.map +1 -0
- package/dist/workflow/builders/parallel.d.ts +25 -0
- package/dist/workflow/builders/parallel.d.ts.map +1 -0
- package/dist/workflow/builders/parallel.js +60 -0
- package/dist/workflow/builders/parallel.js.map +1 -0
- package/dist/workflow/builders/pipeline.d.ts +22 -0
- package/dist/workflow/builders/pipeline.d.ts.map +1 -0
- package/dist/workflow/builders/pipeline.js +48 -0
- package/dist/workflow/builders/pipeline.js.map +1 -0
- package/dist/workflow/builders/types.d.ts +54 -0
- package/dist/workflow/builders/types.d.ts.map +1 -0
- package/dist/workflow/builders/types.js +5 -0
- package/dist/workflow/builders/types.js.map +1 -0
- package/dist/workflow/durable-agent.d.ts +128 -0
- package/dist/workflow/durable-agent.d.ts.map +1 -0
- package/dist/workflow/durable-agent.js +323 -0
- package/dist/workflow/durable-agent.js.map +1 -0
- package/dist/workflow/schedulers.d.ts +231 -0
- package/dist/workflow/schedulers.d.ts.map +1 -0
- package/dist/workflow/schedulers.js +250 -0
- package/dist/workflow/schedulers.js.map +1 -0
- package/dist/workflow/team/create-team.d.ts +34 -0
- package/dist/workflow/team/create-team.d.ts.map +1 -0
- package/dist/workflow/team/create-team.js +242 -0
- package/dist/workflow/team/create-team.js.map +1 -0
- package/dist/workflow/team/index.d.ts +9 -0
- package/dist/workflow/team/index.d.ts.map +1 -0
- package/dist/workflow/team/index.js +8 -0
- package/dist/workflow/team/index.js.map +1 -0
- package/dist/workflow/team/machines.d.ts +152 -0
- package/dist/workflow/team/machines.d.ts.map +1 -0
- package/dist/workflow/team/machines.js +197 -0
- package/dist/workflow/team/machines.js.map +1 -0
- package/dist/workflow/team/task-board.d.ts +47 -0
- package/dist/workflow/team/task-board.d.ts.map +1 -0
- package/dist/workflow/team/task-board.js +111 -0
- package/dist/workflow/team/task-board.js.map +1 -0
- package/dist/workflow/team/tools.d.ts +66 -0
- package/dist/workflow/team/tools.d.ts.map +1 -0
- package/dist/workflow/team/tools.js +100 -0
- package/dist/workflow/team/tools.js.map +1 -0
- package/dist/workflow/team/types.d.ts +109 -0
- package/dist/workflow/team/types.d.ts.map +1 -0
- package/dist/workflow/team/types.js +5 -0
- package/dist/workflow/team/types.js.map +1 -0
- package/dist/workflow/templates.d.ts +71 -0
- package/dist/workflow/templates.d.ts.map +1 -0
- package/dist/workflow/templates.js +132 -0
- package/dist/workflow/templates.js.map +1 -0
- package/package.json +13 -13
- package/LICENSE +0 -22
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-v2.js","sourceRoot":"","sources":["../../src/types/agent-v2.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agntk/core - Minimal Logger
|
|
3
|
+
* Zero-dependency logger that works in Node, Bun, and browser environments
|
|
4
|
+
*/
|
|
5
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
6
|
+
export interface LoggerOptions {
|
|
7
|
+
level?: LogLevel;
|
|
8
|
+
enableColors?: boolean;
|
|
9
|
+
enableTimestamps?: boolean;
|
|
10
|
+
prefix?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface AgentContext {
|
|
13
|
+
type: 'main' | 'spawned';
|
|
14
|
+
taskId?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface LogEntry {
|
|
17
|
+
timestamp: number;
|
|
18
|
+
level: LogLevel;
|
|
19
|
+
message: string;
|
|
20
|
+
meta: Record<string, unknown> | undefined;
|
|
21
|
+
formattedMessage: string;
|
|
22
|
+
}
|
|
23
|
+
export type LogSubscriber = (entry: LogEntry) => void;
|
|
24
|
+
export interface Logger {
|
|
25
|
+
debug(message: string, meta?: Record<string, unknown>): void;
|
|
26
|
+
info(message: string, meta?: Record<string, unknown>): void;
|
|
27
|
+
warn(message: string, meta?: Record<string, unknown>): void;
|
|
28
|
+
error(message: string, meta?: Record<string, unknown>): void;
|
|
29
|
+
setLevel(level: LogLevel): void;
|
|
30
|
+
setAgentContext(context: AgentContext): void;
|
|
31
|
+
subscribe(callback: LogSubscriber): () => void;
|
|
32
|
+
}
|
|
33
|
+
export declare function createLogger(options?: LoggerOptions): Logger;
|
|
34
|
+
export declare const logger: Logger;
|
|
35
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@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AAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC7D,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;IAChC,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;IAC7C,SAAS,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,IAAI,CAAC;CAChD;AAgCD,wBAAgB,YAAY,CAAC,OAAO,GAAE,aAAkB,GAAG,MAAM,CA2IhE;AAED,eAAO,MAAM,MAAM,QAAiB,CAAC"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agntk/core - Minimal Logger
|
|
3
|
+
* Zero-dependency logger that works in Node, Bun, and browser environments
|
|
4
|
+
*/
|
|
5
|
+
const LOG_LEVELS = {
|
|
6
|
+
debug: 0,
|
|
7
|
+
info: 1,
|
|
8
|
+
warn: 2,
|
|
9
|
+
error: 3,
|
|
10
|
+
};
|
|
11
|
+
const LOG_COLORS = {
|
|
12
|
+
debug: '\x1b[36m',
|
|
13
|
+
info: '\x1b[32m',
|
|
14
|
+
warn: '\x1b[33m',
|
|
15
|
+
error: '\x1b[31m',
|
|
16
|
+
};
|
|
17
|
+
const RESET_COLOR = '\x1b[0m';
|
|
18
|
+
// Runtime detection for browser vs Node/Bun
|
|
19
|
+
const isBrowser = typeof globalThis !== 'undefined'
|
|
20
|
+
&& typeof globalThis.document !== 'undefined';
|
|
21
|
+
function getEnvLogLevel() {
|
|
22
|
+
if (isBrowser)
|
|
23
|
+
return 'info';
|
|
24
|
+
const envLevel = (typeof process !== 'undefined' ? process.env?.['LOG_LEVEL'] : undefined)?.toLowerCase();
|
|
25
|
+
if (envLevel && envLevel in LOG_LEVELS) {
|
|
26
|
+
return envLevel;
|
|
27
|
+
}
|
|
28
|
+
return 'info';
|
|
29
|
+
}
|
|
30
|
+
export function createLogger(options = {}) {
|
|
31
|
+
let currentLevel = options.level ?? getEnvLogLevel();
|
|
32
|
+
const enableColors = options.enableColors ?? !isBrowser;
|
|
33
|
+
const enableTimestamps = options.enableTimestamps ?? true;
|
|
34
|
+
const prefix = options.prefix;
|
|
35
|
+
let agentContext;
|
|
36
|
+
const subscribers = new Set();
|
|
37
|
+
function shouldLog(level) {
|
|
38
|
+
return LOG_LEVELS[level] >= LOG_LEVELS[currentLevel];
|
|
39
|
+
}
|
|
40
|
+
function formatMessage(level, message, meta, useColors = enableColors) {
|
|
41
|
+
const parts = [];
|
|
42
|
+
if (enableTimestamps) {
|
|
43
|
+
const timestamp = new Date().toISOString();
|
|
44
|
+
parts.push(`[${timestamp}]`);
|
|
45
|
+
}
|
|
46
|
+
const levelString = level.toUpperCase().padEnd(5);
|
|
47
|
+
if (useColors && !isBrowser) {
|
|
48
|
+
parts.push(`${LOG_COLORS[level]}${levelString}${RESET_COLOR}`);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
parts.push(levelString);
|
|
52
|
+
}
|
|
53
|
+
if (prefix) {
|
|
54
|
+
parts.push(`[${prefix}]`);
|
|
55
|
+
}
|
|
56
|
+
if (agentContext) {
|
|
57
|
+
if (agentContext.type === 'main') {
|
|
58
|
+
const ctxLabel = useColors && !isBrowser ? '\x1b[1m[MAIN]\x1b[0m' : '[MAIN]';
|
|
59
|
+
parts.push(ctxLabel);
|
|
60
|
+
}
|
|
61
|
+
else if (agentContext.type === 'spawned') {
|
|
62
|
+
const taskLabel = agentContext.taskId ? agentContext.taskId.slice(-8) : 'sub';
|
|
63
|
+
const ctxLabel = useColors && !isBrowser
|
|
64
|
+
? `\x1b[90m[SUB:${taskLabel}]\x1b[0m`
|
|
65
|
+
: `[SUB:${taskLabel}]`;
|
|
66
|
+
parts.push(ctxLabel);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
parts.push(message);
|
|
70
|
+
if (meta && Object.keys(meta).length > 0) {
|
|
71
|
+
parts.push(JSON.stringify(meta));
|
|
72
|
+
}
|
|
73
|
+
return parts.join(' ');
|
|
74
|
+
}
|
|
75
|
+
function log(level, message, meta) {
|
|
76
|
+
if (!shouldLog(level)) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const formatted = formatMessage(level, message, meta);
|
|
80
|
+
if (isBrowser) {
|
|
81
|
+
// Browser-compatible logging with colors via console API
|
|
82
|
+
const style = level === 'error' ? 'color: red'
|
|
83
|
+
: level === 'warn' ? 'color: orange'
|
|
84
|
+
: level === 'debug' ? 'color: cyan'
|
|
85
|
+
: 'color: green';
|
|
86
|
+
console[level === 'debug' ? 'log' : level](`%c${formatted}`, style);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
// Node/Bun logging
|
|
90
|
+
switch (level) {
|
|
91
|
+
case 'error':
|
|
92
|
+
console.error(formatted);
|
|
93
|
+
break;
|
|
94
|
+
case 'warn':
|
|
95
|
+
console.warn(formatted);
|
|
96
|
+
break;
|
|
97
|
+
case 'info':
|
|
98
|
+
case 'debug':
|
|
99
|
+
console.log(formatted);
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (subscribers.size > 0) {
|
|
104
|
+
const entry = {
|
|
105
|
+
timestamp: Date.now(),
|
|
106
|
+
level,
|
|
107
|
+
message,
|
|
108
|
+
meta,
|
|
109
|
+
formattedMessage: formatMessage(level, message, meta, false),
|
|
110
|
+
};
|
|
111
|
+
for (const callback of Array.from(subscribers)) {
|
|
112
|
+
try {
|
|
113
|
+
callback(entry);
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
// Ignore subscriber errors
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
debug(message, meta) {
|
|
123
|
+
log('debug', message, meta);
|
|
124
|
+
},
|
|
125
|
+
info(message, meta) {
|
|
126
|
+
log('info', message, meta);
|
|
127
|
+
},
|
|
128
|
+
warn(message, meta) {
|
|
129
|
+
log('warn', message, meta);
|
|
130
|
+
},
|
|
131
|
+
error(message, meta) {
|
|
132
|
+
log('error', message, meta);
|
|
133
|
+
},
|
|
134
|
+
setLevel(level) {
|
|
135
|
+
currentLevel = level;
|
|
136
|
+
},
|
|
137
|
+
setAgentContext(context) {
|
|
138
|
+
agentContext = context;
|
|
139
|
+
},
|
|
140
|
+
subscribe(callback) {
|
|
141
|
+
subscribers.add(callback);
|
|
142
|
+
return () => {
|
|
143
|
+
subscribers.delete(callback);
|
|
144
|
+
};
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
export const logger = createLogger();
|
|
149
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAoCH,MAAM,UAAU,GAA6B;IAC3C,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;CACT,CAAC;AAEF,MAAM,UAAU,GAA6B;IAC3C,KAAK,EAAE,UAAU;IACjB,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,UAAU;CAClB,CAAC;AAEF,MAAM,WAAW,GAAG,SAAS,CAAC;AAE9B,4CAA4C;AAC5C,MAAM,SAAS,GAAG,OAAO,UAAU,KAAK,WAAW;OAC9C,OAAQ,UAAyD,CAAC,QAAQ,KAAK,WAAW,CAAC;AAEhG,SAAS,cAAc;IACrB,IAAI,SAAS;QAAE,OAAO,MAAM,CAAC;IAE7B,MAAM,QAAQ,GAAG,CAAC,OAAO,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,WAAW,EAAE,CAAC;IAC1G,IAAI,QAAQ,IAAI,QAAQ,IAAI,UAAU,EAAE,CAAC;QACvC,OAAO,QAAoB,CAAC;IAC9B,CAAC;IACD,O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OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QAC9B,CAAC;QAED,IAAI,CAAC,OAAe,EAAE,IAA8B;YAClD,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QAC7B,CAAC;QAED,IAAI,CAAC,OAAe,EAAE,IAA8B;YAClD,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QAC7B,CAAC;QAED,KAAK,CAAC,OAAe,EAAE,IAA8B;YACnD,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QAC9B,CAAC;QAED,QAAQ,CAAC,KAAe;YACtB,YAAY,GAAG,KAAK,CAAC;QACvB,CAAC;QAED,eAAe,CAAC,OAAqB;YACnC,YAAY,GAAG,OAAO,CAAC;QACzB,CAAC;QAED,SAAS,CAAC,QAAuB;YAC/B,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC1B,OAAO,GAAG,EAAE;gBACV,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC/B,CAAC,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agntk/core - Agent → WorkflowStep Adapter
|
|
3
|
+
*
|
|
4
|
+
* Converts an Agent to a WorkflowStep so agents and workflows are interchangeable.
|
|
5
|
+
*/
|
|
6
|
+
import type { Agent } from '../../agent.js';
|
|
7
|
+
import type { WorkflowStep } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Adapt an Agent to a WorkflowStep.
|
|
10
|
+
* The agent's generate() method is called with the workflow input prompt.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const pipeline = createPipeline({
|
|
15
|
+
* steps: [asStep(researchAgent), asStep(writerAgent)],
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function asStep(agent: Agent): WorkflowStep;
|
|
20
|
+
//# sourceMappingURL=adapt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapt.d.ts","sourceRoot":"","sources":["../../../src/workflow/builders/adapt.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,EAAE,YAAY,EAAiC,MAAM,SAAS,CAAC;AAE3E;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,YAAY,CAejD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agntk/core - Agent → WorkflowStep Adapter
|
|
3
|
+
*
|
|
4
|
+
* Converts an Agent to a WorkflowStep so agents and workflows are interchangeable.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Adapt an Agent to a WorkflowStep.
|
|
8
|
+
* The agent's generate() method is called with the workflow input prompt.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const pipeline = createPipeline({
|
|
13
|
+
* steps: [asStep(researchAgent), asStep(writerAgent)],
|
|
14
|
+
* });
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export function asStep(agent) {
|
|
18
|
+
return {
|
|
19
|
+
async execute(input) {
|
|
20
|
+
const result = await agent.generate({ prompt: input.prompt });
|
|
21
|
+
return {
|
|
22
|
+
text: result.text ?? '',
|
|
23
|
+
metadata: {
|
|
24
|
+
agentId: agent.agentId,
|
|
25
|
+
role: agent.role,
|
|
26
|
+
steps: result.steps?.length ?? 0,
|
|
27
|
+
usage: result.totalUsage,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=adapt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapt.js","sourceRoot":"","sources":["../../../src/workflow/builders/adapt.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH;;;;;;;;;;GAUG;AACH,MAAM,UAAU,MAAM,CAAC,KAAY;IACjC,OAAO;QACL,KAAK,CAAC,OAAO,CAAC,KAAoB;YAChC,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;YAC9D,OAAO;gBACL,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,EAAE;gBACvB,QAAQ,EAAE;oBACR,OAAO,EAAE,KAAK,CAAC,OAAO;oBACtB,IAAI,EAAE,KAAK,CAAC,IAAI;oBAChB,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC;oBAChC,KAAK,EAAE,MAAM,CAAC,UAAU;iBACzB;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Workflow builders public API.
|
|
3
|
+
*/
|
|
4
|
+
export type { Workflow, WorkflowStep, WorkflowInput, WorkflowOutput, SynthesizeFn, PipelineConfig, ParallelConfig, } from './types.js';
|
|
5
|
+
export { createPipeline } from './pipeline.js';
|
|
6
|
+
export { createParallel } from './parallel.js';
|
|
7
|
+
export { asStep } from './adapt.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/workflow/builders/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,YAAY,EACV,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,cAAc,EACd,YAAY,EACZ,cAAc,EACd,cAAc,GACf,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/workflow/builders/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAYH,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agntk/core - Parallel Workflow Builder
|
|
3
|
+
*
|
|
4
|
+
* Fan out to multiple agents/workflows concurrently,
|
|
5
|
+
* then synthesize the results.
|
|
6
|
+
*/
|
|
7
|
+
import type { Workflow, ParallelConfig } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Create a parallel workflow that fans out to multiple steps concurrently.
|
|
10
|
+
* All steps receive the same input prompt. Results are merged by the synthesize function.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const parallel = createParallel({
|
|
15
|
+
* name: 'multi-analysis',
|
|
16
|
+
* steps: [securityAgent, performanceAgent, codeQualityAgent],
|
|
17
|
+
* synthesize: (outputs) => ({
|
|
18
|
+
* text: outputs.map(o => o.text).join('\n\n---\n\n'),
|
|
19
|
+
* }),
|
|
20
|
+
* });
|
|
21
|
+
* const result = await parallel.execute({ prompt: 'Analyze this codebase' });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function createParallel(config: ParallelConfig): Workflow;
|
|
25
|
+
//# sourceMappingURL=parallel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parallel.d.ts","sourceRoot":"","sources":["../../../src/workflow/builders/parallel.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAiC,cAAc,EAAE,MAAM,SAAS,CAAC;AAIvF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,QAAQ,CA2C/D"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agntk/core - Parallel Workflow Builder
|
|
3
|
+
*
|
|
4
|
+
* Fan out to multiple agents/workflows concurrently,
|
|
5
|
+
* then synthesize the results.
|
|
6
|
+
*/
|
|
7
|
+
import { createLogger } from '@agntk/logger';
|
|
8
|
+
const log = createLogger('@agntk/core:workflow:parallel');
|
|
9
|
+
/**
|
|
10
|
+
* Create a parallel workflow that fans out to multiple steps concurrently.
|
|
11
|
+
* All steps receive the same input prompt. Results are merged by the synthesize function.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const parallel = createParallel({
|
|
16
|
+
* name: 'multi-analysis',
|
|
17
|
+
* steps: [securityAgent, performanceAgent, codeQualityAgent],
|
|
18
|
+
* synthesize: (outputs) => ({
|
|
19
|
+
* text: outputs.map(o => o.text).join('\n\n---\n\n'),
|
|
20
|
+
* }),
|
|
21
|
+
* });
|
|
22
|
+
* const result = await parallel.execute({ prompt: 'Analyze this codebase' });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export function createParallel(config) {
|
|
26
|
+
const { name = 'parallel', steps, synthesize } = config;
|
|
27
|
+
if (steps.length === 0) {
|
|
28
|
+
throw new Error('Parallel workflow must have at least one step');
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
name,
|
|
32
|
+
stepCount: steps.length,
|
|
33
|
+
async execute(input) {
|
|
34
|
+
log.info('Parallel started', { name, stepCount: steps.length, promptLength: input.prompt.length });
|
|
35
|
+
const results = await Promise.allSettled(steps.map((step, i) => {
|
|
36
|
+
log.debug('Parallel step launched', { name, step: i + 1 });
|
|
37
|
+
return step.execute(input);
|
|
38
|
+
}));
|
|
39
|
+
const outputs = [];
|
|
40
|
+
for (let i = 0; i < results.length; i++) {
|
|
41
|
+
const result = results[i];
|
|
42
|
+
if (result.status === 'fulfilled') {
|
|
43
|
+
outputs.push(result.value);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
log.error('Parallel step failed', { name, step: i + 1, error: String(result.reason) });
|
|
47
|
+
outputs.push({
|
|
48
|
+
text: `[Step ${i + 1} failed: ${result.reason instanceof Error ? result.reason.message : String(result.reason)}]`,
|
|
49
|
+
metadata: { error: true },
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
log.debug('Synthesizing parallel outputs', { name, outputCount: outputs.length });
|
|
54
|
+
const synthesized = await synthesize(outputs);
|
|
55
|
+
log.info('Parallel completed', { name, textLength: synthesized.text.length });
|
|
56
|
+
return synthesized;
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=parallel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parallel.js","sourceRoot":"","sources":["../../../src/workflow/builders/parallel.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG7C,MAAM,GAAG,GAAG,YAAY,CAAC,+BAA+B,CAAC,CAAC;AAE1D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,cAAc,CAAC,MAAsB;IACnD,MAAM,EAAE,IAAI,GAAG,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAExD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;IACnE,CAAC;IAED,OAAO;QACL,IAAI;QACJ,SAAS,EAAE,KAAK,CAAC,MAAM;QAEvB,KAAK,CAAC,OAAO,C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E,KAAK,EAAE,IAAI,EAAE;qBAC1B,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;YAED,GAAG,CAAC,KAAK,CAAC,+BAA+B,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;YAClF,MAAM,WAAW,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,CAAC;YAE9C,GAAG,CAAC,IAAI,CAAC,oBAAoB,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;YAE9E,OAAO,WAAW,CAAC;QACrB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agntk/core - Pipeline Workflow Builder
|
|
3
|
+
*
|
|
4
|
+
* Chain agents/workflows sequentially. Each step's output
|
|
5
|
+
* becomes the next step's input prompt.
|
|
6
|
+
*/
|
|
7
|
+
import type { Workflow, PipelineConfig } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Create a pipeline that chains steps sequentially.
|
|
10
|
+
* Each step's text output becomes the next step's prompt.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const pipeline = createPipeline({
|
|
15
|
+
* name: 'research-then-write',
|
|
16
|
+
* steps: [researchAgent, writerAgent],
|
|
17
|
+
* });
|
|
18
|
+
* const result = await pipeline.execute({ prompt: 'Write about quantum computing' });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function createPipeline(config: PipelineConfig): Workflow;
|
|
22
|
+
//# sourceMappingURL=pipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../../src/workflow/builders/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAiC,cAAc,EAAE,MAAM,SAAS,CAAC;AAIvF;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,QAAQ,CAkC/D"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agntk/core - Pipeline Workflow Builder
|
|
3
|
+
*
|
|
4
|
+
* Chain agents/workflows sequentially. Each step's output
|
|
5
|
+
* becomes the next step's input prompt.
|
|
6
|
+
*/
|
|
7
|
+
import { createLogger } from '@agntk/logger';
|
|
8
|
+
const log = createLogger('@agntk/core:workflow:pipeline');
|
|
9
|
+
/**
|
|
10
|
+
* Create a pipeline that chains steps sequentially.
|
|
11
|
+
* Each step's text output becomes the next step's prompt.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const pipeline = createPipeline({
|
|
16
|
+
* name: 'research-then-write',
|
|
17
|
+
* steps: [researchAgent, writerAgent],
|
|
18
|
+
* });
|
|
19
|
+
* const result = await pipeline.execute({ prompt: 'Write about quantum computing' });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export function createPipeline(config) {
|
|
23
|
+
const { name = 'pipeline', steps, transform } = config;
|
|
24
|
+
if (steps.length === 0) {
|
|
25
|
+
throw new Error('Pipeline must have at least one step');
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
name,
|
|
29
|
+
stepCount: steps.length,
|
|
30
|
+
async execute(input) {
|
|
31
|
+
log.info('Pipeline started', { name, stepCount: steps.length, promptLength: input.prompt.length });
|
|
32
|
+
let currentOutput = { text: input.prompt };
|
|
33
|
+
for (let i = 0; i < steps.length; i++) {
|
|
34
|
+
const step = steps[i];
|
|
35
|
+
const prompt = i === 0
|
|
36
|
+
? input.prompt
|
|
37
|
+
: transform
|
|
38
|
+
? transform(currentOutput, i)
|
|
39
|
+
: currentOutput.text;
|
|
40
|
+
log.debug('Pipeline step', { name, step: i + 1, total: steps.length, promptLength: prompt.length });
|
|
41
|
+
currentOutput = await step.execute({ prompt });
|
|
42
|
+
}
|
|
43
|
+
log.info('Pipeline completed', { name, textLength: currentOutput.text.length });
|
|
44
|
+
return currentOutput;
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=pipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../../src/workflow/builders/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG7C,MAAM,GAAG,GAAG,YAAY,CAAC,+BAA+B,CAAC,CAAC;AAE1D;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,cAAc,CAAC,MAAsB;IACnD,MAAM,EAAE,IAAI,GAAG,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;IAEvD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO;QACL,IAAI;QACJ,SAAS,EAAE,KAAK,CAAC,MAAM;QAEvB,KAAK,CAAC,OAAO,CAAC,KAAoB;YAChC,GAAG,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;YAEnG,IAAI,aAAa,GAAmB,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;YAE3D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACtC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBACtB,MAAM,MAAM,GAAG,CAAC,KAAK,CAAC;oBACpB,CAAC,CAAC,KAAK,CAAC,MAAM;oBACd,CAAC,CAAC,SAAS;wBACT,CAAC,CAAC,SAAS,CAAC,aAAa,EAAE,CAAC,CAAC;wBAC7B,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC;gBAEzB,GAAG,CAAC,KAAK,CAAC,eAAe,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;gBAEpG,aAAa,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;YACjD,CAAC;YAED,GAAG,CAAC,IAAI,CAAC,oBAAoB,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,aAAa,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;YAEhF,OAAO,aAAa,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Types for workflow builders (Pipeline, Parallel).
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* A Workflow step that can execute with a prompt and return text.
|
|
6
|
+
* Compatible with the Agent interface so agents and workflows are interchangeable.
|
|
7
|
+
*/
|
|
8
|
+
export interface WorkflowStep {
|
|
9
|
+
/** Execute the step with a prompt. */
|
|
10
|
+
execute: (input: WorkflowInput) => Promise<WorkflowOutput>;
|
|
11
|
+
}
|
|
12
|
+
/** Input to a workflow step. */
|
|
13
|
+
export interface WorkflowInput {
|
|
14
|
+
prompt: string;
|
|
15
|
+
}
|
|
16
|
+
/** Output from a workflow step. */
|
|
17
|
+
export interface WorkflowOutput {
|
|
18
|
+
text: string;
|
|
19
|
+
metadata?: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A Workflow that composes multiple steps.
|
|
23
|
+
* Implements WorkflowStep so it can nest inside other workflows.
|
|
24
|
+
*/
|
|
25
|
+
export interface Workflow extends WorkflowStep {
|
|
26
|
+
/** Name of this workflow. */
|
|
27
|
+
name: string;
|
|
28
|
+
/** Number of steps in this workflow. */
|
|
29
|
+
stepCount: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Synthesize function for parallel workflows.
|
|
33
|
+
* Receives all outputs and produces a merged result.
|
|
34
|
+
*/
|
|
35
|
+
export type SynthesizeFn = (outputs: WorkflowOutput[]) => WorkflowOutput | Promise<WorkflowOutput>;
|
|
36
|
+
/** Configuration for createPipeline. */
|
|
37
|
+
export interface PipelineConfig {
|
|
38
|
+
/** Pipeline name. */
|
|
39
|
+
name?: string;
|
|
40
|
+
/** Steps to execute sequentially. */
|
|
41
|
+
steps: WorkflowStep[];
|
|
42
|
+
/** Optional transform between steps (receives previous output, returns next prompt). */
|
|
43
|
+
transform?: (output: WorkflowOutput, stepIndex: number) => string;
|
|
44
|
+
}
|
|
45
|
+
/** Configuration for createParallel. */
|
|
46
|
+
export interface ParallelConfig {
|
|
47
|
+
/** Parallel workflow name. */
|
|
48
|
+
name?: string;
|
|
49
|
+
/** Steps to execute concurrently. */
|
|
50
|
+
steps: WorkflowStep[];
|
|
51
|
+
/** Function to synthesize/merge parallel outputs. */
|
|
52
|
+
synthesize: SynthesizeFn;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/workflow/builders/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,sCAAsC;IACtC,OAAO,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;CAC5D;AAED,gCAAgC;AAChC,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,mCAAmC;AACnC,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;;GAGG;AACH,MAAM,WAAW,QAAS,SAAQ,YAAY;IAC5C,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAEnG,wCAAwC;AACxC,MAAM,WAAW,cAAc;IAC7B,qBAAqB;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,wFAAwF;IACxF,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;CACnE;AAED,wCAAwC;AACxC,MAAM,WAAW,cAAc;IAC7B,8BAA8B;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,qDAAqD;IACrD,UAAU,EAAE,YAAY,CAAC;CAC1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/workflow/builders/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|