@limo-labs/deity 0.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +519 -0
- package/dist/src/component.d.ts +19 -0
- package/dist/src/component.d.ts.map +1 -0
- package/dist/src/component.js +2 -0
- package/dist/src/component.js.map +1 -0
- package/dist/src/context/context-scope.d.ts +24 -0
- package/dist/src/context/context-scope.d.ts.map +1 -0
- package/dist/src/context/context-scope.js +19 -0
- package/dist/src/context/context-scope.js.map +1 -0
- package/dist/src/context/memory-view.d.ts +62 -0
- package/dist/src/context/memory-view.d.ts.map +1 -0
- package/dist/src/context/memory-view.js +104 -0
- package/dist/src/context/memory-view.js.map +1 -0
- package/dist/src/context/scoped-context.d.ts +51 -0
- package/dist/src/context/scoped-context.d.ts.map +1 -0
- package/dist/src/context/scoped-context.js +74 -0
- package/dist/src/context/scoped-context.js.map +1 -0
- package/dist/src/context/scoped-execution-context.d.ts +55 -0
- package/dist/src/context/scoped-execution-context.d.ts.map +1 -0
- package/dist/src/context/scoped-execution-context.js +78 -0
- package/dist/src/context/scoped-execution-context.js.map +1 -0
- package/dist/src/conversation/conversation-manager.d.ts +272 -0
- package/dist/src/conversation/conversation-manager.d.ts.map +1 -0
- package/dist/src/conversation/conversation-manager.js +11 -0
- package/dist/src/conversation/conversation-manager.js.map +1 -0
- package/dist/src/conversation/conversation-pruner.d.ts +190 -0
- package/dist/src/conversation/conversation-pruner.d.ts.map +1 -0
- package/dist/src/conversation/conversation-pruner.js +274 -0
- package/dist/src/conversation/conversation-pruner.js.map +1 -0
- package/dist/src/conversation/conversation-tree.d.ts +185 -0
- package/dist/src/conversation/conversation-tree.d.ts.map +1 -0
- package/dist/src/conversation/conversation-tree.js +288 -0
- package/dist/src/conversation/conversation-tree.js.map +1 -0
- package/dist/src/conversation/file-conversation-store.d.ts +93 -0
- package/dist/src/conversation/file-conversation-store.d.ts.map +1 -0
- package/dist/src/conversation/file-conversation-store.js +284 -0
- package/dist/src/conversation/file-conversation-store.js.map +1 -0
- package/dist/src/conversation/in-memory-conversation-store.d.ts +36 -0
- package/dist/src/conversation/in-memory-conversation-store.d.ts.map +1 -0
- package/dist/src/conversation/in-memory-conversation-store.js +146 -0
- package/dist/src/conversation/in-memory-conversation-store.js.map +1 -0
- package/dist/src/copilot-adapter.d.ts +33 -0
- package/dist/src/copilot-adapter.d.ts.map +1 -0
- package/dist/src/copilot-adapter.js +119 -0
- package/dist/src/copilot-adapter.js.map +1 -0
- package/dist/src/file-trace-enhanced.d.ts +123 -0
- package/dist/src/file-trace-enhanced.d.ts.map +1 -0
- package/dist/src/file-trace-enhanced.js +177 -0
- package/dist/src/file-trace-enhanced.js.map +1 -0
- package/dist/src/file-trace.d.ts +24 -0
- package/dist/src/file-trace.d.ts.map +1 -0
- package/dist/src/file-trace.js +60 -0
- package/dist/src/file-trace.js.map +1 -0
- package/dist/src/index.d.ts +63 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +40 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/json-store.d.ts +27 -0
- package/dist/src/json-store.d.ts.map +1 -0
- package/dist/src/json-store.js +93 -0
- package/dist/src/json-store.js.map +1 -0
- package/dist/src/llm.d.ts +35 -0
- package/dist/src/llm.d.ts.map +1 -0
- package/dist/src/llm.js +2 -0
- package/dist/src/llm.js.map +1 -0
- package/dist/src/memory/cold-storage.d.ts +60 -0
- package/dist/src/memory/cold-storage.d.ts.map +1 -0
- package/dist/src/memory/cold-storage.js +132 -0
- package/dist/src/memory/cold-storage.js.map +1 -0
- package/dist/src/memory/compression.d.ts +161 -0
- package/dist/src/memory/compression.d.ts.map +1 -0
- package/dist/src/memory/compression.js +193 -0
- package/dist/src/memory/compression.js.map +1 -0
- package/dist/src/memory/hot-memory.d.ts +69 -0
- package/dist/src/memory/hot-memory.d.ts.map +1 -0
- package/dist/src/memory/hot-memory.js +116 -0
- package/dist/src/memory/hot-memory.js.map +1 -0
- package/dist/src/memory/memory-budget.d.ts +162 -0
- package/dist/src/memory/memory-budget.d.ts.map +1 -0
- package/dist/src/memory/memory-budget.js +241 -0
- package/dist/src/memory/memory-budget.js.map +1 -0
- package/dist/src/memory/memory-config.d.ts +419 -0
- package/dist/src/memory/memory-config.d.ts.map +1 -0
- package/dist/src/memory/memory-config.js +297 -0
- package/dist/src/memory/memory-config.js.map +1 -0
- package/dist/src/memory/prefetcher.d.ts +137 -0
- package/dist/src/memory/prefetcher.d.ts.map +1 -0
- package/dist/src/memory/prefetcher.js +186 -0
- package/dist/src/memory/prefetcher.js.map +1 -0
- package/dist/src/memory/tiered-memory.d.ts +116 -0
- package/dist/src/memory/tiered-memory.d.ts.map +1 -0
- package/dist/src/memory/tiered-memory.js +215 -0
- package/dist/src/memory/tiered-memory.js.map +1 -0
- package/dist/src/memory/warm-storage.d.ts +74 -0
- package/dist/src/memory/warm-storage.d.ts.map +1 -0
- package/dist/src/memory/warm-storage.js +207 -0
- package/dist/src/memory/warm-storage.js.map +1 -0
- package/dist/src/openai-adapter.d.ts +20 -0
- package/dist/src/openai-adapter.d.ts.map +1 -0
- package/dist/src/openai-adapter.js +73 -0
- package/dist/src/openai-adapter.js.map +1 -0
- package/dist/src/parser.d.ts +27 -0
- package/dist/src/parser.d.ts.map +1 -0
- package/dist/src/parser.js +76 -0
- package/dist/src/parser.js.map +1 -0
- package/dist/src/runtime.d.ts +172 -0
- package/dist/src/runtime.d.ts.map +1 -0
- package/dist/src/runtime.js +436 -0
- package/dist/src/runtime.js.map +1 -0
- package/dist/src/schema-utils.d.ts +7 -0
- package/dist/src/schema-utils.d.ts.map +1 -0
- package/dist/src/schema-utils.js +71 -0
- package/dist/src/schema-utils.js.map +1 -0
- package/dist/src/stage.d.ts +139 -0
- package/dist/src/stage.d.ts.map +1 -0
- package/dist/src/stage.js +2 -0
- package/dist/src/stage.js.map +1 -0
- package/dist/src/store.d.ts +51 -0
- package/dist/src/store.d.ts.map +1 -0
- package/dist/src/store.js +2 -0
- package/dist/src/store.js.map +1 -0
- package/dist/src/tool.d.ts +12 -0
- package/dist/src/tool.d.ts.map +1 -0
- package/dist/src/tool.js +2 -0
- package/dist/src/tool.js.map +1 -0
- package/dist/src/trace.d.ts +60 -0
- package/dist/src/trace.d.ts.map +1 -0
- package/dist/src/trace.js +2 -0
- package/dist/src/trace.js.map +1 -0
- package/dist/src/validator.d.ts +17 -0
- package/dist/src/validator.d.ts.map +1 -0
- package/dist/src/validator.js +21 -0
- package/dist/src/validator.js.map +1 -0
- package/dist/src/workflow.d.ts +192 -0
- package/dist/src/workflow.d.ts.map +1 -0
- package/dist/src/workflow.js +50 -0
- package/dist/src/workflow.js.map +1 -0
- package/package.json +62 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { zodToJsonSchema } from "./schema-utils.js";
|
|
2
|
+
/**
|
|
3
|
+
* OpenAI-compatible LLM adapter.
|
|
4
|
+
* Works with OpenAI API and compatible endpoints (Azure, local proxies).
|
|
5
|
+
*/
|
|
6
|
+
export class OpenAIAdapter {
|
|
7
|
+
apiKey;
|
|
8
|
+
model;
|
|
9
|
+
baseURL;
|
|
10
|
+
constructor(config) {
|
|
11
|
+
this.apiKey = config.apiKey;
|
|
12
|
+
this.model = config.model ?? "gpt-4o";
|
|
13
|
+
this.baseURL = config.baseURL ?? "https://api.openai.com/v1";
|
|
14
|
+
}
|
|
15
|
+
async generate(messages, tools, config) {
|
|
16
|
+
const body = {
|
|
17
|
+
model: this.model,
|
|
18
|
+
messages: messages.map((m) => {
|
|
19
|
+
const msg = {
|
|
20
|
+
role: m.role,
|
|
21
|
+
content: m.content,
|
|
22
|
+
};
|
|
23
|
+
if (m.toolCallId) {
|
|
24
|
+
msg.tool_call_id = m.toolCallId;
|
|
25
|
+
}
|
|
26
|
+
return msg;
|
|
27
|
+
}),
|
|
28
|
+
};
|
|
29
|
+
if (config?.temperature !== undefined) {
|
|
30
|
+
body.temperature = config.temperature;
|
|
31
|
+
}
|
|
32
|
+
if (config?.maxTokens !== undefined) {
|
|
33
|
+
body.max_tokens = config.maxTokens;
|
|
34
|
+
}
|
|
35
|
+
if (tools && tools.length > 0) {
|
|
36
|
+
body.tools = tools.map((tool) => ({
|
|
37
|
+
type: "function",
|
|
38
|
+
function: {
|
|
39
|
+
name: tool.name,
|
|
40
|
+
description: tool.description,
|
|
41
|
+
parameters: zodToJsonSchema(tool.inputSchema),
|
|
42
|
+
},
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
const response = await fetch(`${this.baseURL}/chat/completions`, {
|
|
46
|
+
method: "POST",
|
|
47
|
+
headers: {
|
|
48
|
+
"Content-Type": "application/json",
|
|
49
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
50
|
+
},
|
|
51
|
+
body: JSON.stringify(body),
|
|
52
|
+
});
|
|
53
|
+
if (!response.ok) {
|
|
54
|
+
const text = await response.text();
|
|
55
|
+
throw new Error(`OpenAI API error (${response.status}): ${text}`);
|
|
56
|
+
}
|
|
57
|
+
const data = (await response.json());
|
|
58
|
+
const choice = data.choices[0];
|
|
59
|
+
if (!choice) {
|
|
60
|
+
throw new Error("OpenAI returned empty response");
|
|
61
|
+
}
|
|
62
|
+
const toolCalls = choice.message.tool_calls?.map((tc) => ({
|
|
63
|
+
id: tc.id,
|
|
64
|
+
toolName: tc.function.name,
|
|
65
|
+
arguments: JSON.parse(tc.function.arguments),
|
|
66
|
+
}));
|
|
67
|
+
return {
|
|
68
|
+
content: choice.message.content ?? "",
|
|
69
|
+
toolCalls: toolCalls && toolCalls.length > 0 ? toolCalls : undefined,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=openai-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-adapter.js","sourceRoot":"","sources":["../../src/openai-adapter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAQpD;;;GAGG;AACH,MAAM,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YACrC,SAAS,EAAE,SAAS,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;SACrE,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ZodSchema } from "zod";
|
|
2
|
+
import type { LLMResponse } from "./llm.js";
|
|
3
|
+
/**
|
|
4
|
+
* Result of parsing LLM output against a schema.
|
|
5
|
+
*/
|
|
6
|
+
export interface ParseResult<T> {
|
|
7
|
+
success: boolean;
|
|
8
|
+
data?: T;
|
|
9
|
+
error?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Extract JSON from LLM text output.
|
|
13
|
+
* Handles common patterns:
|
|
14
|
+
* - Raw JSON
|
|
15
|
+
* - JSON wrapped in markdown code fences (```json ... ``` or ``` ... ```)
|
|
16
|
+
* - JSON with preamble/postamble text
|
|
17
|
+
*/
|
|
18
|
+
export declare function extractJSON(text: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Parse LLM response content against a Zod schema.
|
|
21
|
+
* 1. Extract JSON from response text
|
|
22
|
+
* 2. JSON.parse the extracted text
|
|
23
|
+
* 3. Validate against outputSchema using Zod
|
|
24
|
+
* 4. Return typed result or structured error
|
|
25
|
+
*/
|
|
26
|
+
export declare function parseOutput<T>(raw: LLMResponse, schema: ZodSchema<T>): ParseResult<T>;
|
|
27
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AACrC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAG5C;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAoChD;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CA6BrF"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { formatZodError } from "./validator.js";
|
|
2
|
+
/**
|
|
3
|
+
* Extract JSON from LLM text output.
|
|
4
|
+
* Handles common patterns:
|
|
5
|
+
* - Raw JSON
|
|
6
|
+
* - JSON wrapped in markdown code fences (```json ... ``` or ``` ... ```)
|
|
7
|
+
* - JSON with preamble/postamble text
|
|
8
|
+
*/
|
|
9
|
+
export function extractJSON(text) {
|
|
10
|
+
const trimmed = text.trim();
|
|
11
|
+
// Try raw JSON first
|
|
12
|
+
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
13
|
+
return trimmed;
|
|
14
|
+
}
|
|
15
|
+
// Try markdown code fence with json tag
|
|
16
|
+
const fencedJsonMatch = trimmed.match(/```json\s*\n([\s\S]*?)\n\s*```/);
|
|
17
|
+
if (fencedJsonMatch) {
|
|
18
|
+
return fencedJsonMatch[1].trim();
|
|
19
|
+
}
|
|
20
|
+
// Try markdown code fence without tag
|
|
21
|
+
const fencedMatch = trimmed.match(/```\s*\n([\s\S]*?)\n\s*```/);
|
|
22
|
+
if (fencedMatch) {
|
|
23
|
+
const inner = fencedMatch[1].trim();
|
|
24
|
+
if (inner.startsWith("{") || inner.startsWith("[")) {
|
|
25
|
+
return inner;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// Try to find JSON object/array in the text
|
|
29
|
+
const jsonObjectMatch = trimmed.match(/(\{[\s\S]*\})/);
|
|
30
|
+
if (jsonObjectMatch) {
|
|
31
|
+
return jsonObjectMatch[1];
|
|
32
|
+
}
|
|
33
|
+
const jsonArrayMatch = trimmed.match(/(\[[\s\S]*\])/);
|
|
34
|
+
if (jsonArrayMatch) {
|
|
35
|
+
return jsonArrayMatch[1];
|
|
36
|
+
}
|
|
37
|
+
// Return as-is, let JSON.parse fail with a clear error
|
|
38
|
+
return trimmed;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Parse LLM response content against a Zod schema.
|
|
42
|
+
* 1. Extract JSON from response text
|
|
43
|
+
* 2. JSON.parse the extracted text
|
|
44
|
+
* 3. Validate against outputSchema using Zod
|
|
45
|
+
* 4. Return typed result or structured error
|
|
46
|
+
*/
|
|
47
|
+
export function parseOutput(raw, schema) {
|
|
48
|
+
try {
|
|
49
|
+
const jsonStr = extractJSON(raw.content);
|
|
50
|
+
let parsed;
|
|
51
|
+
try {
|
|
52
|
+
parsed = JSON.parse(jsonStr);
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
return {
|
|
56
|
+
success: false,
|
|
57
|
+
error: `JSON parse error: ${e instanceof Error ? e.message : String(e)}. Raw content: ${raw.content.substring(0, 200)}...`,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const result = schema.safeParse(parsed);
|
|
61
|
+
if (!result.success) {
|
|
62
|
+
return {
|
|
63
|
+
success: false,
|
|
64
|
+
error: `Schema validation failed: ${formatZodError(result.error)}`,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return { success: true, data: result.data };
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
return {
|
|
71
|
+
success: false,
|
|
72
|
+
error: `Unexpected parse error: ${e instanceof Error ? e.message : String(e)}`,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/parser.ts"],"names":[],"mappings":"AAEA,OAAO,E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B,EAAE,MAAoB;IACnE,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACzC,IAAI,MAAe,CAAC;QAEpB,IAAI,CAAC;YACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,qBAAqB,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,kBAAkB,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK;aAC3H,CAAC;QACJ,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACxC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,6BAA6B,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;aACnE,CAAC;QACJ,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;IAC9C,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,2BAA2B,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE;SAC/E,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import type { AgentComponent } from "./stage.js";
|
|
2
|
+
import type { LLMAdapter, GenerationConfig } from "./llm.js";
|
|
3
|
+
import type { StateStore } from "./store.js";
|
|
4
|
+
import type { TraceLogger } from "./trace.js";
|
|
5
|
+
import type { MemoryConfig } from "./memory/memory-config.js";
|
|
6
|
+
import type { ConversationManager } from "./conversation/conversation-manager.js";
|
|
7
|
+
import { MemoryPresets } from "./memory/memory-config.js";
|
|
8
|
+
import type { Workflow } from "./workflow.js";
|
|
9
|
+
/**
|
|
10
|
+
* Error thrown when a stage fails permanently (exhausts all retries).
|
|
11
|
+
*/
|
|
12
|
+
export declare class StageFailedError extends Error {
|
|
13
|
+
readonly stageId: string;
|
|
14
|
+
readonly errors: string[];
|
|
15
|
+
constructor(stageId: string, errors: string[]);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Error thrown when a stage attempts to access another stage's output
|
|
19
|
+
* that is not in its declared scope.
|
|
20
|
+
*
|
|
21
|
+
* @since 2.0.0
|
|
22
|
+
*/
|
|
23
|
+
export declare class ScopeViolationError extends Error {
|
|
24
|
+
constructor(message: string);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Pipeline configuration.
|
|
28
|
+
*
|
|
29
|
+
* @deprecated Use `WorkflowConfig` interface instead. This alias will be removed in v3.0.0.
|
|
30
|
+
* See TERMINOLOGY.md for migration guide.
|
|
31
|
+
*
|
|
32
|
+
* @since 2.0.0
|
|
33
|
+
*/
|
|
34
|
+
export interface PipelineConfig {
|
|
35
|
+
/** Unique name for this pipeline */
|
|
36
|
+
name: string;
|
|
37
|
+
/** Optional description of what this pipeline does */
|
|
38
|
+
description?: string;
|
|
39
|
+
/** Default LLM adapter and generation config for all stages */
|
|
40
|
+
defaultModel?: {
|
|
41
|
+
adapter: LLMAdapter;
|
|
42
|
+
config?: GenerationConfig;
|
|
43
|
+
};
|
|
44
|
+
/** Behavior when a stage fails: "abort" stops pipeline, "skip" continues (default: "abort") */
|
|
45
|
+
onStageFailure?: "abort" | "skip";
|
|
46
|
+
/** Maximum tool calling rounds per stage (default: 10) */
|
|
47
|
+
maxToolRounds?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Memory configuration for tiered storage system.
|
|
50
|
+
*
|
|
51
|
+
* When provided, this configuration defines how the pipeline manages its memory:
|
|
52
|
+
* - Hot memory: In-memory LRU cache for frequently accessed data
|
|
53
|
+
* - Warm storage: Compressed disk cache for less frequently accessed data
|
|
54
|
+
* - Cold storage: Uncompressed disk archive for long-term storage
|
|
55
|
+
*
|
|
56
|
+
* You can use preset names ("development", "production", "minimal") or provide
|
|
57
|
+
* a full MemoryConfig object.
|
|
58
|
+
*
|
|
59
|
+
* **Note:** This configuration is not yet used by runPipeline. It will be integrated
|
|
60
|
+
* in Task 1.3 when TieredStateStore is implemented. For now, you still need to pass
|
|
61
|
+
* a StateStore directly to runPipeline().
|
|
62
|
+
*
|
|
63
|
+
* @since 2.0.0
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* // Use a preset
|
|
67
|
+
* const pipeline = definePipeline({
|
|
68
|
+
* name: "my-pipeline",
|
|
69
|
+
* memoryConfig: "production",
|
|
70
|
+
* stages: [/* ... *\/],
|
|
71
|
+
* });
|
|
72
|
+
*
|
|
73
|
+
* // Use custom config
|
|
74
|
+
* const pipeline = definePipeline({
|
|
75
|
+
* name: "my-pipeline",
|
|
76
|
+
* memoryConfig: {
|
|
77
|
+
* hot: { maxItems: 2000 },
|
|
78
|
+
* warm: { enabled: true, maxSize: 1024 * 1024 * 1024, compressionAlgorithm: "gzip", directory: ".cache" },
|
|
79
|
+
* cold: { enabled: true, directory: ".archive" },
|
|
80
|
+
* },
|
|
81
|
+
* stages: [/* ... *\/],
|
|
82
|
+
* });
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
memoryConfig?: MemoryConfig | keyof typeof MemoryPresets;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Pipeline definition combining config and stages.
|
|
89
|
+
*
|
|
90
|
+
* @deprecated Use `Workflow` type instead. This alias will be removed in v3.0.0.
|
|
91
|
+
* See TERMINOLOGY.md for migration guide.
|
|
92
|
+
*
|
|
93
|
+
* @since 2.0.0
|
|
94
|
+
*/
|
|
95
|
+
export interface Pipeline {
|
|
96
|
+
config: PipelineConfig;
|
|
97
|
+
stages: AgentComponent<any, any>[];
|
|
98
|
+
}
|
|
99
|
+
export type { Workflow, WorkflowConfig } from "./workflow.js";
|
|
100
|
+
export { defineWorkflow } from "./workflow.js";
|
|
101
|
+
/**
|
|
102
|
+
* Define a pipeline from config and stages.
|
|
103
|
+
*
|
|
104
|
+
* Creates a pipeline configuration that can be executed with runPipeline().
|
|
105
|
+
* Pipelines define a sequence of agent components (stages) that process data
|
|
106
|
+
* with automatic checkpointing, retry logic, and validation.
|
|
107
|
+
*
|
|
108
|
+
* @deprecated Use `defineWorkflow()` instead. This function will be removed in v3.0.0.
|
|
109
|
+
* See TERMINOLOGY.md for migration guide.
|
|
110
|
+
*
|
|
111
|
+
* @param options - Pipeline configuration and stages
|
|
112
|
+
* @returns Pipeline definition ready for execution
|
|
113
|
+
*
|
|
114
|
+
* @since 1.0.0
|
|
115
|
+
*/
|
|
116
|
+
export declare function definePipeline(options: PipelineConfig & {
|
|
117
|
+
stages: AgentComponent<any, any>[];
|
|
118
|
+
}): Pipeline;
|
|
119
|
+
/**
|
|
120
|
+
* Execute a complete workflow.
|
|
121
|
+
* This is the core runtime loop that drives the entire framework.
|
|
122
|
+
*
|
|
123
|
+
* A workflow represents a single agent's deterministic execution through
|
|
124
|
+
* a sequence of steps, with automatic checkpointing, retry logic, and validation.
|
|
125
|
+
*
|
|
126
|
+
* @param workflow - Workflow definition with configuration and steps
|
|
127
|
+
* @param inputs - Input data for the workflow
|
|
128
|
+
* @param store - State storage for checkpoints
|
|
129
|
+
* @param trace - Trace logger for execution history
|
|
130
|
+
* @param conversation - Optional conversation manager (defaults to in-memory store)
|
|
131
|
+
* @param adapterOverride - Optional LLM adapter override
|
|
132
|
+
* @returns Record of all step outputs
|
|
133
|
+
*
|
|
134
|
+
* @since 2.0.0
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* import { runWorkflow, defineWorkflow } from '@limo-labs/deity';
|
|
139
|
+
*
|
|
140
|
+
* const workflow = defineWorkflow({
|
|
141
|
+
* name: "research-workflow",
|
|
142
|
+
* defaultModel: { adapter: llm },
|
|
143
|
+
* steps: [ResearchStep, AnalysisStep, ReportStep]
|
|
144
|
+
* });
|
|
145
|
+
*
|
|
146
|
+
* const result = await runWorkflow(
|
|
147
|
+
* workflow,
|
|
148
|
+
* { topic: "AI agents" },
|
|
149
|
+
* store,
|
|
150
|
+
* trace
|
|
151
|
+
* );
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
export declare function runWorkflow(workflow: Workflow, inputs: unknown, store: StateStore, trace: TraceLogger, conversation?: ConversationManager, adapterOverride?: LLMAdapter): Promise<Record<string, unknown>>;
|
|
155
|
+
/**
|
|
156
|
+
* Execute a complete pipeline.
|
|
157
|
+
*
|
|
158
|
+
* @deprecated Use `runWorkflow()` instead. This function will be removed in v3.0.0.
|
|
159
|
+
* See TERMINOLOGY.md for migration guide.
|
|
160
|
+
*
|
|
161
|
+
* @param pipeline - Pipeline configuration
|
|
162
|
+
* @param inputs - Input data for the pipeline
|
|
163
|
+
* @param store - State storage for checkpoints
|
|
164
|
+
* @param trace - Trace logger for execution history
|
|
165
|
+
* @param conversation - Optional conversation manager
|
|
166
|
+
* @param adapterOverride - Optional LLM adapter override
|
|
167
|
+
* @returns Record of all stage outputs
|
|
168
|
+
*
|
|
169
|
+
* @since 1.0.0
|
|
170
|
+
*/
|
|
171
|
+
export declare function runPipeline(pipeline: Pipeline, inputs: unknown, store: StateStore, trace: TraceLogger, conversation?: ConversationManager, adapterOverride?: LLMAdapter): Promise<Record<string, unknown>>;
|
|
172
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA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