gauss-ai 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +489 -0
- package/LICENSE +21 -0
- package/README.md +269 -0
- package/dist/a2a/index.cjs +7 -0
- package/dist/a2a/index.cjs.map +1 -0
- package/dist/a2a/index.d.cts +30 -0
- package/dist/a2a/index.d.ts +30 -0
- package/dist/a2a/index.js +7 -0
- package/dist/a2a/index.js.map +1 -0
- package/dist/agent-UIQDSYCE.js +16 -0
- package/dist/agent-UIQDSYCE.js.map +1 -0
- package/dist/agent-builder-8W3mBR-N.d.ts +1075 -0
- package/dist/agent-builder-GEMYdb1p.d.cts +1075 -0
- package/dist/agent-graph-AMQYAWNF.js +1422 -0
- package/dist/agent-graph-AMQYAWNF.js.map +1 -0
- package/dist/ai-sdk-mcp.adapter-SEN6KHNU.js +124 -0
- package/dist/ai-sdk-mcp.adapter-SEN6KHNU.js.map +1 -0
- package/dist/browser/index.js +10 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/bun-runtime.adapter-MQDAJLQM.js +8 -0
- package/dist/bun-runtime.adapter-MQDAJLQM.js.map +1 -0
- package/dist/bun-runtime.adapter-XKOUXVAK.cjs +8 -0
- package/dist/bun-runtime.adapter-XKOUXVAK.cjs.map +1 -0
- package/dist/chat-A3XMRPJL.js +129 -0
- package/dist/chat-A3XMRPJL.js.map +1 -0
- package/dist/chunk-2ZRU47NC.js +91 -0
- package/dist/chunk-2ZRU47NC.js.map +1 -0
- package/dist/chunk-3LD3JTH4.cjs +18 -0
- package/dist/chunk-3LD3JTH4.cjs.map +1 -0
- package/dist/chunk-5FE5TG2W.cjs +16 -0
- package/dist/chunk-5FE5TG2W.cjs.map +1 -0
- package/dist/chunk-6XF673YC.cjs +436 -0
- package/dist/chunk-6XF673YC.cjs.map +1 -0
- package/dist/chunk-7CKWZJNS.js +230 -0
- package/dist/chunk-7CKWZJNS.js.map +1 -0
- package/dist/chunk-BI2G665F.js +4588 -0
- package/dist/chunk-BI2G665F.js.map +1 -0
- package/dist/chunk-C5NLWJS2.js +139 -0
- package/dist/chunk-C5NLWJS2.js.map +1 -0
- package/dist/chunk-CJZ66SU3.cjs +4321 -0
- package/dist/chunk-CJZ66SU3.cjs.map +1 -0
- package/dist/chunk-DAMT2CXW.cjs +91 -0
- package/dist/chunk-DAMT2CXW.cjs.map +1 -0
- package/dist/chunk-E7WG3MO5.js +18 -0
- package/dist/chunk-E7WG3MO5.js.map +1 -0
- package/dist/chunk-EFDM6R4J.js +99 -0
- package/dist/chunk-EFDM6R4J.js.map +1 -0
- package/dist/chunk-F7WIPPEO.js +256 -0
- package/dist/chunk-F7WIPPEO.js.map +1 -0
- package/dist/chunk-FAYDE67N.js +6927 -0
- package/dist/chunk-FAYDE67N.js.map +1 -0
- package/dist/chunk-GAE2KKCM.js +21 -0
- package/dist/chunk-GAE2KKCM.js.map +1 -0
- package/dist/chunk-INLNGRXM.cjs +130 -0
- package/dist/chunk-INLNGRXM.cjs.map +1 -0
- package/dist/chunk-JKXKXB5O.js +130 -0
- package/dist/chunk-JKXKXB5O.js.map +1 -0
- package/dist/chunk-K6SAETGP.js +375 -0
- package/dist/chunk-K6SAETGP.js.map +1 -0
- package/dist/chunk-KEASLAYR.js +157 -0
- package/dist/chunk-KEASLAYR.js.map +1 -0
- package/dist/chunk-KKJVNM6O.js +436 -0
- package/dist/chunk-KKJVNM6O.js.map +1 -0
- package/dist/chunk-KYIMVRIM.js +16 -0
- package/dist/chunk-KYIMVRIM.js.map +1 -0
- package/dist/chunk-MB7NXIZD.js +4321 -0
- package/dist/chunk-MB7NXIZD.js.map +1 -0
- package/dist/chunk-MHHDXPGE.js +209 -0
- package/dist/chunk-MHHDXPGE.js.map +1 -0
- package/dist/chunk-NE6JJA5W.js +401 -0
- package/dist/chunk-NE6JJA5W.js.map +1 -0
- package/dist/chunk-PF46XZBF.cjs +6927 -0
- package/dist/chunk-PF46XZBF.cjs.map +1 -0
- package/dist/chunk-PSJIAGDE.cjs +375 -0
- package/dist/chunk-PSJIAGDE.cjs.map +1 -0
- package/dist/chunk-PWOQDXNQ.js +16 -0
- package/dist/chunk-PWOQDXNQ.js.map +1 -0
- package/dist/chunk-QYOMQBBZ.cjs +230 -0
- package/dist/chunk-QYOMQBBZ.cjs.map +1 -0
- package/dist/chunk-UDFXLC4J.cjs +16 -0
- package/dist/chunk-UDFXLC4J.cjs.map +1 -0
- package/dist/chunk-UO4NGXRT.cjs +259 -0
- package/dist/chunk-UO4NGXRT.cjs.map +1 -0
- package/dist/chunk-UPFDFLEW.js +40 -0
- package/dist/chunk-UPFDFLEW.js.map +1 -0
- package/dist/chunk-V55JSQS7.cjs +16 -0
- package/dist/chunk-V55JSQS7.cjs.map +1 -0
- package/dist/chunk-VJADHXZL.cjs +16 -0
- package/dist/chunk-VJADHXZL.cjs.map +1 -0
- package/dist/chunk-VRWD7LCI.js +59 -0
- package/dist/chunk-VRWD7LCI.js.map +1 -0
- package/dist/chunk-WKKQ443C.js +487 -0
- package/dist/chunk-WKKQ443C.js.map +1 -0
- package/dist/chunk-X2GHUHAF.js +436 -0
- package/dist/chunk-X2GHUHAF.js.map +1 -0
- package/dist/chunk-XLGW3XNI.cjs +256 -0
- package/dist/chunk-XLGW3XNI.cjs.map +1 -0
- package/dist/chunk-ZFJKX4DP.js +16 -0
- package/dist/chunk-ZFJKX4DP.js.map +1 -0
- package/dist/chunk-ZM2OEWM2.js +259 -0
- package/dist/chunk-ZM2OEWM2.js.map +1 -0
- package/dist/chunk-ZNAIP2XV.js +16 -0
- package/dist/chunk-ZNAIP2XV.js.map +1 -0
- package/dist/chunk-ZYFAZYSL.js +42 -0
- package/dist/chunk-ZYFAZYSL.js.map +1 -0
- package/dist/cli/index.js +421 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/config-4MHT6TQW.js +153 -0
- package/dist/config-4MHT6TQW.js.map +1 -0
- package/dist/config-REERQFK4.cjs +153 -0
- package/dist/config-REERQFK4.cjs.map +1 -0
- package/dist/cost-tracker-JLOU7IZJ.js +7 -0
- package/dist/cost-tracker-JLOU7IZJ.js.map +1 -0
- package/dist/demo-C52GMSYH.js +188 -0
- package/dist/demo-C52GMSYH.js.map +1 -0
- package/dist/deno/index.js +306 -0
- package/dist/deno/index.js.map +1 -0
- package/dist/deno-runtime.adapter-F744HY7K.js +8 -0
- package/dist/deno-runtime.adapter-F744HY7K.js.map +1 -0
- package/dist/deno-runtime.adapter-RFEVNSCV.cjs +8 -0
- package/dist/deno-runtime.adapter-RFEVNSCV.cjs.map +1 -0
- package/dist/dev-D7DDVDA4.js +218 -0
- package/dist/dev-D7DDVDA4.js.map +1 -0
- package/dist/edge/index.js +10 -0
- package/dist/edge/index.js.map +1 -0
- package/dist/edge-runtime.adapter-UQCW2F7X.js +8 -0
- package/dist/edge-runtime.adapter-UQCW2F7X.js.map +1 -0
- package/dist/edge-runtime.adapter-YED6F3AY.cjs +8 -0
- package/dist/edge-runtime.adapter-YED6F3AY.cjs.map +1 -0
- package/dist/graph-MGFAQZ5W.js +50 -0
- package/dist/graph-MGFAQZ5W.js.map +1 -0
- package/dist/graph-visualization-HBSVQXJK.js +9 -0
- package/dist/graph-visualization-HBSVQXJK.js.map +1 -0
- package/dist/index-BRgqNnh3.d.cts +982 -0
- package/dist/index-CZxpYUxZ.d.ts +982 -0
- package/dist/index.cjs +14789 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +10275 -0
- package/dist/index.d.ts +10275 -0
- package/dist/index.js +14789 -0
- package/dist/index.js.map +1 -0
- package/dist/init-CFWXTQ35.js +133 -0
- package/dist/init-CFWXTQ35.js.map +1 -0
- package/dist/llm-VWO4MC7J.cjs +17 -0
- package/dist/llm-VWO4MC7J.cjs.map +1 -0
- package/dist/llm-XLXVSPBI.js +17 -0
- package/dist/llm-XLXVSPBI.js.map +1 -0
- package/dist/logging-WRAK5ZXT.js +33 -0
- package/dist/logging-WRAK5ZXT.js.map +1 -0
- package/dist/metrics-FAHZVVD4.js +47 -0
- package/dist/metrics-FAHZVVD4.js.map +1 -0
- package/dist/node/index.cjs +280 -0
- package/dist/node/index.cjs.map +1 -0
- package/dist/node/index.d.cts +51 -0
- package/dist/node/index.d.ts +51 -0
- package/dist/node/index.js +280 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node-runtime.adapter-5L7PJ6W2.js +8 -0
- package/dist/node-runtime.adapter-5L7PJ6W2.js.map +1 -0
- package/dist/node-runtime.adapter-CCRZVGHB.cjs +8 -0
- package/dist/node-runtime.adapter-CCRZVGHB.cjs.map +1 -0
- package/dist/persist-usage-WTBTCWEF.js +7 -0
- package/dist/persist-usage-WTBTCWEF.js.map +1 -0
- package/dist/plugin-RCPBWUUA.js +207 -0
- package/dist/plugin-RCPBWUUA.js.map +1 -0
- package/dist/plugins/index.cjs +75 -0
- package/dist/plugins/index.cjs.map +1 -0
- package/dist/plugins/index.d.cts +8 -0
- package/dist/plugins/index.d.ts +8 -0
- package/dist/plugins/index.js +75 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins-L4ING3CX.js +4625 -0
- package/dist/plugins-L4ING3CX.js.map +1 -0
- package/dist/providers/index.cjs +189 -0
- package/dist/providers/index.cjs.map +1 -0
- package/dist/providers/index.d.cts +168 -0
- package/dist/providers/index.d.ts +168 -0
- package/dist/providers/index.js +189 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers-3RNQ5CKZ.js +59 -0
- package/dist/providers-3RNQ5CKZ.js.map +1 -0
- package/dist/providers-66GPXUGQ.cjs +59 -0
- package/dist/providers-66GPXUGQ.cjs.map +1 -0
- package/dist/repl-K6QN4I2S.js +678 -0
- package/dist/repl-K6QN4I2S.js.map +1 -0
- package/dist/rest/index.cjs +17 -0
- package/dist/rest/index.cjs.map +1 -0
- package/dist/rest/index.d.cts +102 -0
- package/dist/rest/index.d.ts +102 -0
- package/dist/rest/index.js +17 -0
- package/dist/rest/index.js.map +1 -0
- package/dist/runtime-deno.js +15 -0
- package/dist/runtime-deno.js.map +1 -0
- package/dist/runtime-edge.js +15 -0
- package/dist/runtime-edge.js.map +1 -0
- package/dist/runtime-node.js +15 -0
- package/dist/runtime-node.js.map +1 -0
- package/dist/scraping/index.cjs +11 -0
- package/dist/scraping/index.cjs.map +1 -0
- package/dist/scraping/index.d.cts +17 -0
- package/dist/scraping/index.d.ts +17 -0
- package/dist/scraping/index.js +11 -0
- package/dist/scraping/index.js.map +1 -0
- package/dist/semantic-scraping.port-CZWUea88.d.cts +54 -0
- package/dist/semantic-scraping.port-CZWUea88.d.ts +54 -0
- package/dist/server/index.js +166 -0
- package/dist/server/index.js.map +1 -0
- package/dist/testing/index.cjs +25 -0
- package/dist/testing/index.cjs.map +1 -0
- package/dist/testing/index.d.cts +63 -0
- package/dist/testing/index.d.ts +63 -0
- package/dist/testing/index.js +25 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/token-counter.port-CRgxZZGe.d.ts +334 -0
- package/dist/token-counter.port-D7BHMCRR.d.cts +334 -0
- package/dist/tools-BZM33OBZ.js +10 -0
- package/dist/tools-BZM33OBZ.js.map +1 -0
- package/dist/tracing-XA3TEWP4.js +48 -0
- package/dist/tracing-XA3TEWP4.js.map +1 -0
- package/dist/types-CVsP7gFI.d.cts +235 -0
- package/dist/types-CVsP7gFI.d.ts +235 -0
- package/dist/virtual-fs.adapter-BBLS-3AY.d.ts +26 -0
- package/dist/virtual-fs.adapter-nb0CTYOj.d.cts +26 -0
- package/dist/workflow/index.cjs +9 -0
- package/dist/workflow/index.cjs.map +1 -0
- package/dist/workflow/index.d.cts +62 -0
- package/dist/workflow/index.d.ts +62 -0
- package/dist/workflow/index.js +9 -0
- package/dist/workflow/index.js.map +1 -0
- package/dist/workflow.port-BaCttxrw.d.cts +153 -0
- package/dist/workflow.port-BaCttxrw.d.ts +153 -0
- package/package.json +230 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// src/adapters/tracing/in-memory-tracing.adapter.ts
|
|
2
|
+
var InMemorySpan = class {
|
|
3
|
+
traceId;
|
|
4
|
+
spanId;
|
|
5
|
+
name;
|
|
6
|
+
attributes = /* @__PURE__ */ new Map();
|
|
7
|
+
status = "unset";
|
|
8
|
+
statusMessage;
|
|
9
|
+
ended = false;
|
|
10
|
+
constructor(name, traceId, spanId) {
|
|
11
|
+
this.name = name;
|
|
12
|
+
this.traceId = traceId;
|
|
13
|
+
this.spanId = spanId;
|
|
14
|
+
}
|
|
15
|
+
setAttribute(key, value) {
|
|
16
|
+
this.attributes.set(key, value);
|
|
17
|
+
}
|
|
18
|
+
setStatus(status, message) {
|
|
19
|
+
this.status = status;
|
|
20
|
+
this.statusMessage = message;
|
|
21
|
+
}
|
|
22
|
+
end() {
|
|
23
|
+
this.ended = true;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var InMemoryTracingAdapter = class {
|
|
27
|
+
spans = [];
|
|
28
|
+
counter = 0;
|
|
29
|
+
startSpan(name, parentSpan) {
|
|
30
|
+
const traceId = parentSpan?.traceId ?? `trace-${++this.counter}`;
|
|
31
|
+
const spanId = `span-${++this.counter}`;
|
|
32
|
+
const span = new InMemorySpan(name, traceId, spanId);
|
|
33
|
+
this.spans.push(span);
|
|
34
|
+
return span;
|
|
35
|
+
}
|
|
36
|
+
/** Get all recorded spans */
|
|
37
|
+
getSpans() {
|
|
38
|
+
return this.spans;
|
|
39
|
+
}
|
|
40
|
+
/** Clear all recorded spans */
|
|
41
|
+
clear() {
|
|
42
|
+
this.spans.length = 0;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
export {
|
|
46
|
+
InMemoryTracingAdapter
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=tracing-XA3TEWP4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/adapters/tracing/in-memory-tracing.adapter.ts"],"sourcesContent":["// =============================================================================\n// InMemoryTracingAdapter — In-memory implementation of TracingPort for testing\n// =============================================================================\n\nimport type { TracingPort, Span } from \"../../ports/tracing.port.js\";\n\nclass InMemorySpan implements Span {\n readonly traceId: string;\n readonly spanId: string;\n readonly name: string;\n readonly attributes = new Map<string, string | number | boolean>();\n status: \"ok\" | \"error\" | \"unset\" = \"unset\";\n statusMessage?: string;\n ended = false;\n\n constructor(name: string, traceId: string, spanId: string) {\n this.name = name;\n this.traceId = traceId;\n this.spanId = spanId;\n }\n\n setAttribute(key: string, value: string | number | boolean): void {\n this.attributes.set(key, value);\n }\n\n setStatus(status: \"ok\" | \"error\", message?: string): void {\n this.status = status;\n this.statusMessage = message;\n }\n\n end(): void {\n this.ended = true;\n }\n}\n\nexport class InMemoryTracingAdapter implements TracingPort {\n private readonly spans: InMemorySpan[] = [];\n private counter = 0;\n\n startSpan(name: string, parentSpan?: Span): InMemorySpan {\n const traceId = parentSpan?.traceId ?? `trace-${++this.counter}`;\n const spanId = `span-${++this.counter}`;\n const span = new InMemorySpan(name, traceId, spanId);\n this.spans.push(span);\n return span;\n }\n\n /** Get all recorded spans */\n getSpans(): readonly InMemorySpan[] {\n return this.spans;\n }\n\n /** Clear all recorded spans */\n clear(): void {\n this.spans.length = 0;\n }\n}\n"],"mappings":";AAMA,IAAM,eAAN,MAAmC;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa,oBAAI,IAAuC;AAAA,EACjE,SAAmC;AAAA,EACnC;AAAA,EACA,QAAQ;AAAA,EAER,YAAY,MAAc,SAAiB,QAAgB;AACzD,SAAK,OAAO;AACZ,SAAK,UAAU;AACf,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,aAAa,KAAa,OAAwC;AAChE,SAAK,WAAW,IAAI,KAAK,KAAK;AAAA,EAChC;AAAA,EAEA,UAAU,QAAwB,SAAwB;AACxD,SAAK,SAAS;AACd,SAAK,gBAAgB;AAAA,EACvB;AAAA,EAEA,MAAY;AACV,SAAK,QAAQ;AAAA,EACf;AACF;AAEO,IAAM,yBAAN,MAAoD;AAAA,EACxC,QAAwB,CAAC;AAAA,EAClC,UAAU;AAAA,EAElB,UAAU,MAAc,YAAiC;AACvD,UAAM,UAAU,YAAY,WAAW,SAAS,EAAE,KAAK,OAAO;AAC9D,UAAM,SAAS,QAAQ,EAAE,KAAK,OAAO;AACrC,UAAM,OAAO,IAAI,aAAa,MAAM,SAAS,MAAM;AACnD,SAAK,MAAM,KAAK,IAAI;AACpB,WAAO;AAAA,EACT;AAAA;AAAA,EAGA,WAAoC;AAClC,WAAO,KAAK;AAAA,EACd;AAAA;AAAA,EAGA,QAAc;AACZ,SAAK,MAAM,SAAS;AAAA,EACtB;AACF;","names":[]}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { ZodType } from 'zod';
|
|
2
|
+
|
|
3
|
+
interface TextPart {
|
|
4
|
+
type: "text";
|
|
5
|
+
text: string;
|
|
6
|
+
}
|
|
7
|
+
interface ToolCallPart {
|
|
8
|
+
type: "tool-call";
|
|
9
|
+
toolCallType: "function";
|
|
10
|
+
toolCallId: string;
|
|
11
|
+
toolName: string;
|
|
12
|
+
args: string;
|
|
13
|
+
}
|
|
14
|
+
interface ToolResultPart {
|
|
15
|
+
type: "tool-result";
|
|
16
|
+
toolCallId: string;
|
|
17
|
+
toolName: string;
|
|
18
|
+
result: unknown;
|
|
19
|
+
isError?: boolean;
|
|
20
|
+
}
|
|
21
|
+
type ContentPart = TextPart | ToolCallPart | ToolResultPart;
|
|
22
|
+
interface SystemMessage {
|
|
23
|
+
role: "system";
|
|
24
|
+
content: string;
|
|
25
|
+
}
|
|
26
|
+
interface UserMessage {
|
|
27
|
+
role: "user";
|
|
28
|
+
content: string | ContentPart[];
|
|
29
|
+
}
|
|
30
|
+
interface AssistantMessage {
|
|
31
|
+
role: "assistant";
|
|
32
|
+
content: string | ContentPart[];
|
|
33
|
+
}
|
|
34
|
+
interface ToolMessage {
|
|
35
|
+
role: "tool";
|
|
36
|
+
content: ToolResultPart[];
|
|
37
|
+
}
|
|
38
|
+
type CoreMessage = SystemMessage | UserMessage | AssistantMessage | ToolMessage;
|
|
39
|
+
interface TokenUsage {
|
|
40
|
+
inputTokens: number;
|
|
41
|
+
outputTokens: number;
|
|
42
|
+
totalTokens?: number;
|
|
43
|
+
}
|
|
44
|
+
interface ToolCall {
|
|
45
|
+
toolCallType: "function";
|
|
46
|
+
toolCallId: string;
|
|
47
|
+
toolName: string;
|
|
48
|
+
args: string;
|
|
49
|
+
}
|
|
50
|
+
interface ToolResult {
|
|
51
|
+
toolCallId: string;
|
|
52
|
+
toolName: string;
|
|
53
|
+
result: unknown;
|
|
54
|
+
isError?: boolean;
|
|
55
|
+
}
|
|
56
|
+
interface LanguageModelGenerateOptions {
|
|
57
|
+
inputFormat: "prompt" | "messages";
|
|
58
|
+
mode: {
|
|
59
|
+
type: "regular";
|
|
60
|
+
tools?: LanguageModelTool[];
|
|
61
|
+
toolChoice?: ToolChoice;
|
|
62
|
+
} | {
|
|
63
|
+
type: "object-json";
|
|
64
|
+
schema?: unknown;
|
|
65
|
+
} | {
|
|
66
|
+
type: "object-tool";
|
|
67
|
+
tool: LanguageModelTool;
|
|
68
|
+
};
|
|
69
|
+
prompt: CoreMessage[];
|
|
70
|
+
abortSignal?: AbortSignal;
|
|
71
|
+
headers?: Record<string, string>;
|
|
72
|
+
providerMetadata?: Record<string, unknown>;
|
|
73
|
+
}
|
|
74
|
+
interface LanguageModelTool {
|
|
75
|
+
type: "function";
|
|
76
|
+
name: string;
|
|
77
|
+
description?: string;
|
|
78
|
+
parameters: Record<string, unknown>;
|
|
79
|
+
}
|
|
80
|
+
type ToolChoice = {
|
|
81
|
+
type: "auto";
|
|
82
|
+
} | {
|
|
83
|
+
type: "none";
|
|
84
|
+
} | {
|
|
85
|
+
type: "required";
|
|
86
|
+
} | {
|
|
87
|
+
type: "tool";
|
|
88
|
+
toolName: string;
|
|
89
|
+
};
|
|
90
|
+
interface LanguageModelGenerateResult {
|
|
91
|
+
text?: string;
|
|
92
|
+
toolCalls?: ToolCall[];
|
|
93
|
+
finishReason: FinishReason;
|
|
94
|
+
usage: TokenUsage;
|
|
95
|
+
rawCall: {
|
|
96
|
+
rawPrompt: unknown;
|
|
97
|
+
rawSettings: Record<string, unknown>;
|
|
98
|
+
};
|
|
99
|
+
rawResponse?: {
|
|
100
|
+
headers?: Record<string, string>;
|
|
101
|
+
};
|
|
102
|
+
warnings?: unknown[];
|
|
103
|
+
request?: {
|
|
104
|
+
body: string;
|
|
105
|
+
};
|
|
106
|
+
response?: {
|
|
107
|
+
id: string;
|
|
108
|
+
timestamp: Date;
|
|
109
|
+
modelId: string;
|
|
110
|
+
};
|
|
111
|
+
providerMetadata?: Record<string, unknown>;
|
|
112
|
+
sources?: unknown[];
|
|
113
|
+
reasoning?: unknown;
|
|
114
|
+
}
|
|
115
|
+
type FinishReason = "stop" | "tool-calls" | "length" | "content-filter" | "error" | "other";
|
|
116
|
+
interface TextDeltaPart {
|
|
117
|
+
type: "text-delta";
|
|
118
|
+
textDelta: string;
|
|
119
|
+
}
|
|
120
|
+
interface ToolCallStreamPart {
|
|
121
|
+
type: "tool-call";
|
|
122
|
+
toolCallType: "function";
|
|
123
|
+
toolCallId: string;
|
|
124
|
+
toolName: string;
|
|
125
|
+
args: string;
|
|
126
|
+
}
|
|
127
|
+
interface ToolCallDeltaPart {
|
|
128
|
+
type: "tool-call-delta";
|
|
129
|
+
toolCallType: "function";
|
|
130
|
+
toolCallId: string;
|
|
131
|
+
toolName: string;
|
|
132
|
+
argsTextDelta: string;
|
|
133
|
+
}
|
|
134
|
+
interface FinishPart {
|
|
135
|
+
type: "finish";
|
|
136
|
+
finishReason: FinishReason;
|
|
137
|
+
usage: TokenUsage;
|
|
138
|
+
}
|
|
139
|
+
type StreamPart = TextDeltaPart | ToolCallStreamPart | ToolCallDeltaPart | FinishPart;
|
|
140
|
+
interface LanguageModelStreamResult {
|
|
141
|
+
stream: ReadableStream<StreamPart>;
|
|
142
|
+
rawCall: {
|
|
143
|
+
rawPrompt: unknown;
|
|
144
|
+
rawSettings: Record<string, unknown>;
|
|
145
|
+
};
|
|
146
|
+
rawResponse?: {
|
|
147
|
+
headers?: Record<string, string>;
|
|
148
|
+
};
|
|
149
|
+
warnings?: unknown[];
|
|
150
|
+
request?: {
|
|
151
|
+
body: string;
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Language model interface — the core provider abstraction.
|
|
156
|
+
* Implementations: MockProvider (testing), GaussProvider (Rust NAPI), or any custom provider.
|
|
157
|
+
*/
|
|
158
|
+
interface LanguageModel {
|
|
159
|
+
readonly specificationVersion: string;
|
|
160
|
+
readonly provider: string;
|
|
161
|
+
readonly modelId: string;
|
|
162
|
+
readonly defaultObjectGenerationMode?: string;
|
|
163
|
+
doGenerate(options: LanguageModelGenerateOptions): Promise<LanguageModelGenerateResult>;
|
|
164
|
+
doStream(options: LanguageModelGenerateOptions): Promise<LanguageModelStreamResult>;
|
|
165
|
+
}
|
|
166
|
+
interface ToolDefinition<PARAMS = unknown, RESULT = unknown> {
|
|
167
|
+
type: "function";
|
|
168
|
+
description?: string;
|
|
169
|
+
parameters: ZodType<PARAMS>;
|
|
170
|
+
execute?: (args: PARAMS, options?: ToolExecuteOptions) => Promise<RESULT>;
|
|
171
|
+
}
|
|
172
|
+
interface ToolExecuteOptions {
|
|
173
|
+
abortSignal?: AbortSignal;
|
|
174
|
+
toolCallId?: string;
|
|
175
|
+
messages?: Array<{
|
|
176
|
+
role: string;
|
|
177
|
+
content: string;
|
|
178
|
+
}>;
|
|
179
|
+
}
|
|
180
|
+
type Tool<PARAMS = unknown, RESULT = unknown> = ToolDefinition<PARAMS, RESULT>;
|
|
181
|
+
type ToolSet = Record<string, Tool<any, any>>;
|
|
182
|
+
interface StepResult<TOOLS extends ToolSet = ToolSet> {
|
|
183
|
+
text: string;
|
|
184
|
+
toolCalls: Array<{
|
|
185
|
+
toolCallType: "function";
|
|
186
|
+
toolCallId: string;
|
|
187
|
+
toolName: string;
|
|
188
|
+
args: unknown;
|
|
189
|
+
}>;
|
|
190
|
+
toolResults: ToolResult[];
|
|
191
|
+
finishReason: FinishReason;
|
|
192
|
+
usage: TokenUsage;
|
|
193
|
+
warnings?: unknown[];
|
|
194
|
+
response?: {
|
|
195
|
+
id: string;
|
|
196
|
+
timestamp: Date;
|
|
197
|
+
modelId: string;
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
interface GenerateTextResult<TOOLS extends ToolSet = ToolSet, OUTPUT = never> {
|
|
201
|
+
text: string;
|
|
202
|
+
toolCalls: Array<{
|
|
203
|
+
toolCallType: "function";
|
|
204
|
+
toolCallId: string;
|
|
205
|
+
toolName: string;
|
|
206
|
+
args: unknown;
|
|
207
|
+
}>;
|
|
208
|
+
toolResults: ToolResult[];
|
|
209
|
+
finishReason: FinishReason;
|
|
210
|
+
usage: TokenUsage;
|
|
211
|
+
steps: StepResult<TOOLS>[];
|
|
212
|
+
warnings?: unknown[];
|
|
213
|
+
response?: {
|
|
214
|
+
id: string;
|
|
215
|
+
timestamp: Date;
|
|
216
|
+
modelId: string;
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
interface StreamTextResult<TOOLS extends ToolSet = ToolSet, OUTPUT = never> {
|
|
220
|
+
textStream: ReadableStream<string>;
|
|
221
|
+
fullStream: ReadableStream<StreamPart>;
|
|
222
|
+
text: Promise<string>;
|
|
223
|
+
toolCalls: Promise<Array<{
|
|
224
|
+
toolCallType: "function";
|
|
225
|
+
toolCallId: string;
|
|
226
|
+
toolName: string;
|
|
227
|
+
args: unknown;
|
|
228
|
+
}>>;
|
|
229
|
+
toolResults: Promise<ToolResult[]>;
|
|
230
|
+
finishReason: Promise<FinishReason>;
|
|
231
|
+
usage: Promise<TokenUsage>;
|
|
232
|
+
steps: Promise<StepResult<TOOLS>[]>;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export type { CoreMessage as C, FinishReason as F, GenerateTextResult as G, LanguageModel as L, StepResult as S, Tool as T, ToolExecuteOptions as a, ToolSet as b, ToolChoice as c, TokenUsage as d, StreamTextResult as e, ToolResult as f };
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { ZodType } from 'zod';
|
|
2
|
+
|
|
3
|
+
interface TextPart {
|
|
4
|
+
type: "text";
|
|
5
|
+
text: string;
|
|
6
|
+
}
|
|
7
|
+
interface ToolCallPart {
|
|
8
|
+
type: "tool-call";
|
|
9
|
+
toolCallType: "function";
|
|
10
|
+
toolCallId: string;
|
|
11
|
+
toolName: string;
|
|
12
|
+
args: string;
|
|
13
|
+
}
|
|
14
|
+
interface ToolResultPart {
|
|
15
|
+
type: "tool-result";
|
|
16
|
+
toolCallId: string;
|
|
17
|
+
toolName: string;
|
|
18
|
+
result: unknown;
|
|
19
|
+
isError?: boolean;
|
|
20
|
+
}
|
|
21
|
+
type ContentPart = TextPart | ToolCallPart | ToolResultPart;
|
|
22
|
+
interface SystemMessage {
|
|
23
|
+
role: "system";
|
|
24
|
+
content: string;
|
|
25
|
+
}
|
|
26
|
+
interface UserMessage {
|
|
27
|
+
role: "user";
|
|
28
|
+
content: string | ContentPart[];
|
|
29
|
+
}
|
|
30
|
+
interface AssistantMessage {
|
|
31
|
+
role: "assistant";
|
|
32
|
+
content: string | ContentPart[];
|
|
33
|
+
}
|
|
34
|
+
interface ToolMessage {
|
|
35
|
+
role: "tool";
|
|
36
|
+
content: ToolResultPart[];
|
|
37
|
+
}
|
|
38
|
+
type CoreMessage = SystemMessage | UserMessage | AssistantMessage | ToolMessage;
|
|
39
|
+
interface TokenUsage {
|
|
40
|
+
inputTokens: number;
|
|
41
|
+
outputTokens: number;
|
|
42
|
+
totalTokens?: number;
|
|
43
|
+
}
|
|
44
|
+
interface ToolCall {
|
|
45
|
+
toolCallType: "function";
|
|
46
|
+
toolCallId: string;
|
|
47
|
+
toolName: string;
|
|
48
|
+
args: string;
|
|
49
|
+
}
|
|
50
|
+
interface ToolResult {
|
|
51
|
+
toolCallId: string;
|
|
52
|
+
toolName: string;
|
|
53
|
+
result: unknown;
|
|
54
|
+
isError?: boolean;
|
|
55
|
+
}
|
|
56
|
+
interface LanguageModelGenerateOptions {
|
|
57
|
+
inputFormat: "prompt" | "messages";
|
|
58
|
+
mode: {
|
|
59
|
+
type: "regular";
|
|
60
|
+
tools?: LanguageModelTool[];
|
|
61
|
+
toolChoice?: ToolChoice;
|
|
62
|
+
} | {
|
|
63
|
+
type: "object-json";
|
|
64
|
+
schema?: unknown;
|
|
65
|
+
} | {
|
|
66
|
+
type: "object-tool";
|
|
67
|
+
tool: LanguageModelTool;
|
|
68
|
+
};
|
|
69
|
+
prompt: CoreMessage[];
|
|
70
|
+
abortSignal?: AbortSignal;
|
|
71
|
+
headers?: Record<string, string>;
|
|
72
|
+
providerMetadata?: Record<string, unknown>;
|
|
73
|
+
}
|
|
74
|
+
interface LanguageModelTool {
|
|
75
|
+
type: "function";
|
|
76
|
+
name: string;
|
|
77
|
+
description?: string;
|
|
78
|
+
parameters: Record<string, unknown>;
|
|
79
|
+
}
|
|
80
|
+
type ToolChoice = {
|
|
81
|
+
type: "auto";
|
|
82
|
+
} | {
|
|
83
|
+
type: "none";
|
|
84
|
+
} | {
|
|
85
|
+
type: "required";
|
|
86
|
+
} | {
|
|
87
|
+
type: "tool";
|
|
88
|
+
toolName: string;
|
|
89
|
+
};
|
|
90
|
+
interface LanguageModelGenerateResult {
|
|
91
|
+
text?: string;
|
|
92
|
+
toolCalls?: ToolCall[];
|
|
93
|
+
finishReason: FinishReason;
|
|
94
|
+
usage: TokenUsage;
|
|
95
|
+
rawCall: {
|
|
96
|
+
rawPrompt: unknown;
|
|
97
|
+
rawSettings: Record<string, unknown>;
|
|
98
|
+
};
|
|
99
|
+
rawResponse?: {
|
|
100
|
+
headers?: Record<string, string>;
|
|
101
|
+
};
|
|
102
|
+
warnings?: unknown[];
|
|
103
|
+
request?: {
|
|
104
|
+
body: string;
|
|
105
|
+
};
|
|
106
|
+
response?: {
|
|
107
|
+
id: string;
|
|
108
|
+
timestamp: Date;
|
|
109
|
+
modelId: string;
|
|
110
|
+
};
|
|
111
|
+
providerMetadata?: Record<string, unknown>;
|
|
112
|
+
sources?: unknown[];
|
|
113
|
+
reasoning?: unknown;
|
|
114
|
+
}
|
|
115
|
+
type FinishReason = "stop" | "tool-calls" | "length" | "content-filter" | "error" | "other";
|
|
116
|
+
interface TextDeltaPart {
|
|
117
|
+
type: "text-delta";
|
|
118
|
+
textDelta: string;
|
|
119
|
+
}
|
|
120
|
+
interface ToolCallStreamPart {
|
|
121
|
+
type: "tool-call";
|
|
122
|
+
toolCallType: "function";
|
|
123
|
+
toolCallId: string;
|
|
124
|
+
toolName: string;
|
|
125
|
+
args: string;
|
|
126
|
+
}
|
|
127
|
+
interface ToolCallDeltaPart {
|
|
128
|
+
type: "tool-call-delta";
|
|
129
|
+
toolCallType: "function";
|
|
130
|
+
toolCallId: string;
|
|
131
|
+
toolName: string;
|
|
132
|
+
argsTextDelta: string;
|
|
133
|
+
}
|
|
134
|
+
interface FinishPart {
|
|
135
|
+
type: "finish";
|
|
136
|
+
finishReason: FinishReason;
|
|
137
|
+
usage: TokenUsage;
|
|
138
|
+
}
|
|
139
|
+
type StreamPart = TextDeltaPart | ToolCallStreamPart | ToolCallDeltaPart | FinishPart;
|
|
140
|
+
interface LanguageModelStreamResult {
|
|
141
|
+
stream: ReadableStream<StreamPart>;
|
|
142
|
+
rawCall: {
|
|
143
|
+
rawPrompt: unknown;
|
|
144
|
+
rawSettings: Record<string, unknown>;
|
|
145
|
+
};
|
|
146
|
+
rawResponse?: {
|
|
147
|
+
headers?: Record<string, string>;
|
|
148
|
+
};
|
|
149
|
+
warnings?: unknown[];
|
|
150
|
+
request?: {
|
|
151
|
+
body: string;
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Language model interface — the core provider abstraction.
|
|
156
|
+
* Implementations: MockProvider (testing), GaussProvider (Rust NAPI), or any custom provider.
|
|
157
|
+
*/
|
|
158
|
+
interface LanguageModel {
|
|
159
|
+
readonly specificationVersion: string;
|
|
160
|
+
readonly provider: string;
|
|
161
|
+
readonly modelId: string;
|
|
162
|
+
readonly defaultObjectGenerationMode?: string;
|
|
163
|
+
doGenerate(options: LanguageModelGenerateOptions): Promise<LanguageModelGenerateResult>;
|
|
164
|
+
doStream(options: LanguageModelGenerateOptions): Promise<LanguageModelStreamResult>;
|
|
165
|
+
}
|
|
166
|
+
interface ToolDefinition<PARAMS = unknown, RESULT = unknown> {
|
|
167
|
+
type: "function";
|
|
168
|
+
description?: string;
|
|
169
|
+
parameters: ZodType<PARAMS>;
|
|
170
|
+
execute?: (args: PARAMS, options?: ToolExecuteOptions) => Promise<RESULT>;
|
|
171
|
+
}
|
|
172
|
+
interface ToolExecuteOptions {
|
|
173
|
+
abortSignal?: AbortSignal;
|
|
174
|
+
toolCallId?: string;
|
|
175
|
+
messages?: Array<{
|
|
176
|
+
role: string;
|
|
177
|
+
content: string;
|
|
178
|
+
}>;
|
|
179
|
+
}
|
|
180
|
+
type Tool<PARAMS = unknown, RESULT = unknown> = ToolDefinition<PARAMS, RESULT>;
|
|
181
|
+
type ToolSet = Record<string, Tool<any, any>>;
|
|
182
|
+
interface StepResult<TOOLS extends ToolSet = ToolSet> {
|
|
183
|
+
text: string;
|
|
184
|
+
toolCalls: Array<{
|
|
185
|
+
toolCallType: "function";
|
|
186
|
+
toolCallId: string;
|
|
187
|
+
toolName: string;
|
|
188
|
+
args: unknown;
|
|
189
|
+
}>;
|
|
190
|
+
toolResults: ToolResult[];
|
|
191
|
+
finishReason: FinishReason;
|
|
192
|
+
usage: TokenUsage;
|
|
193
|
+
warnings?: unknown[];
|
|
194
|
+
response?: {
|
|
195
|
+
id: string;
|
|
196
|
+
timestamp: Date;
|
|
197
|
+
modelId: string;
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
interface GenerateTextResult<TOOLS extends ToolSet = ToolSet, OUTPUT = never> {
|
|
201
|
+
text: string;
|
|
202
|
+
toolCalls: Array<{
|
|
203
|
+
toolCallType: "function";
|
|
204
|
+
toolCallId: string;
|
|
205
|
+
toolName: string;
|
|
206
|
+
args: unknown;
|
|
207
|
+
}>;
|
|
208
|
+
toolResults: ToolResult[];
|
|
209
|
+
finishReason: FinishReason;
|
|
210
|
+
usage: TokenUsage;
|
|
211
|
+
steps: StepResult<TOOLS>[];
|
|
212
|
+
warnings?: unknown[];
|
|
213
|
+
response?: {
|
|
214
|
+
id: string;
|
|
215
|
+
timestamp: Date;
|
|
216
|
+
modelId: string;
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
interface StreamTextResult<TOOLS extends ToolSet = ToolSet, OUTPUT = never> {
|
|
220
|
+
textStream: ReadableStream<string>;
|
|
221
|
+
fullStream: ReadableStream<StreamPart>;
|
|
222
|
+
text: Promise<string>;
|
|
223
|
+
toolCalls: Promise<Array<{
|
|
224
|
+
toolCallType: "function";
|
|
225
|
+
toolCallId: string;
|
|
226
|
+
toolName: string;
|
|
227
|
+
args: unknown;
|
|
228
|
+
}>>;
|
|
229
|
+
toolResults: Promise<ToolResult[]>;
|
|
230
|
+
finishReason: Promise<FinishReason>;
|
|
231
|
+
usage: Promise<TokenUsage>;
|
|
232
|
+
steps: Promise<StepResult<TOOLS>[]>;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export type { CoreMessage as C, FinishReason as F, GenerateTextResult as G, LanguageModel as L, StepResult as S, Tool as T, ToolExecuteOptions as a, ToolSet as b, ToolChoice as c, TokenUsage as d, StreamTextResult as e, ToolResult as f };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { F as FilesystemPort, a as FilesystemZone, L as ListOptions, b as FileEntry, c as FileStat, S as SearchOptions, d as SearchResult } from './token-counter.port-CRgxZZGe.js';
|
|
2
|
+
|
|
3
|
+
type DiskSyncFn = (filePath: string, content: string) => Promise<void>;
|
|
4
|
+
interface VirtualFsOptions {
|
|
5
|
+
basePath?: string;
|
|
6
|
+
onSync?: DiskSyncFn;
|
|
7
|
+
}
|
|
8
|
+
declare class VirtualFilesystem implements FilesystemPort {
|
|
9
|
+
private readonly zones;
|
|
10
|
+
private readonly basePath;
|
|
11
|
+
private readonly onSync?;
|
|
12
|
+
constructor(options?: VirtualFsOptions);
|
|
13
|
+
read(path: string, zone?: FilesystemZone): Promise<string>;
|
|
14
|
+
write(path: string, content: string, zone?: FilesystemZone): Promise<void>;
|
|
15
|
+
exists(path: string, zone?: FilesystemZone): Promise<boolean>;
|
|
16
|
+
delete(path: string, zone?: FilesystemZone): Promise<void>;
|
|
17
|
+
list(path: string, options?: ListOptions, zone?: FilesystemZone): Promise<FileEntry[]>;
|
|
18
|
+
stat(path: string, zone?: FilesystemZone): Promise<FileStat>;
|
|
19
|
+
glob(pattern: string, zone?: FilesystemZone): Promise<string[]>;
|
|
20
|
+
search(pattern: string, options?: SearchOptions, zone?: FilesystemZone): Promise<SearchResult[]>;
|
|
21
|
+
syncToPersistent(): Promise<void>;
|
|
22
|
+
clearTransient(): Promise<void>;
|
|
23
|
+
private ensureParentDirs;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { type DiskSyncFn as D, VirtualFilesystem as V };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { F as FilesystemPort, a as FilesystemZone, L as ListOptions, b as FileEntry, c as FileStat, S as SearchOptions, d as SearchResult } from './token-counter.port-D7BHMCRR.cjs';
|
|
2
|
+
|
|
3
|
+
type DiskSyncFn = (filePath: string, content: string) => Promise<void>;
|
|
4
|
+
interface VirtualFsOptions {
|
|
5
|
+
basePath?: string;
|
|
6
|
+
onSync?: DiskSyncFn;
|
|
7
|
+
}
|
|
8
|
+
declare class VirtualFilesystem implements FilesystemPort {
|
|
9
|
+
private readonly zones;
|
|
10
|
+
private readonly basePath;
|
|
11
|
+
private readonly onSync?;
|
|
12
|
+
constructor(options?: VirtualFsOptions);
|
|
13
|
+
read(path: string, zone?: FilesystemZone): Promise<string>;
|
|
14
|
+
write(path: string, content: string, zone?: FilesystemZone): Promise<void>;
|
|
15
|
+
exists(path: string, zone?: FilesystemZone): Promise<boolean>;
|
|
16
|
+
delete(path: string, zone?: FilesystemZone): Promise<void>;
|
|
17
|
+
list(path: string, options?: ListOptions, zone?: FilesystemZone): Promise<FileEntry[]>;
|
|
18
|
+
stat(path: string, zone?: FilesystemZone): Promise<FileStat>;
|
|
19
|
+
glob(pattern: string, zone?: FilesystemZone): Promise<string[]>;
|
|
20
|
+
search(pattern: string, options?: SearchOptions, zone?: FilesystemZone): Promise<SearchResult[]>;
|
|
21
|
+
syncToPersistent(): Promise<void>;
|
|
22
|
+
clearTransient(): Promise<void>;
|
|
23
|
+
private ensureParentDirs;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { type DiskSyncFn as D, VirtualFilesystem as V };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkINLNGRXMcjs = require('../chunk-INLNGRXM.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
exports.WorkflowBuilder = _chunkINLNGRXMcjs.WorkflowBuilder; exports.defineWorkflow = _chunkINLNGRXMcjs.defineWorkflow;
|
|
9
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/giulioleone/Sviluppo/gauss/gauss-flow/dist/workflow/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,yDAA8B;AAC9B;AACE;AACA;AACF,uHAAC","file":"/Users/giulioleone/Sviluppo/gauss/gauss-flow/dist/workflow/index.cjs"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { W as WorkflowContext, h as WorkflowStep, R as RetryConfig, a as WorkflowDefinition } from '../workflow.port-BaCttxrw.cjs';
|
|
2
|
+
export { e as AnyStep, V as ValidationResult, f as WorkflowEvent, c as WorkflowEventListener, b as WorkflowPort, d as WorkflowResult } from '../workflow.port-BaCttxrw.cjs';
|
|
3
|
+
|
|
4
|
+
type ConditionFn = (ctx: WorkflowContext) => boolean;
|
|
5
|
+
type RollbackFn = (ctx: WorkflowContext) => Promise<void>;
|
|
6
|
+
type PromptFn = (ctx: WorkflowContext) => string;
|
|
7
|
+
interface ConditionalOpts {
|
|
8
|
+
condition: ConditionFn;
|
|
9
|
+
ifTrue: WorkflowStep;
|
|
10
|
+
ifFalse?: WorkflowStep;
|
|
11
|
+
}
|
|
12
|
+
interface LoopOpts {
|
|
13
|
+
body: WorkflowStep;
|
|
14
|
+
condition: ConditionFn;
|
|
15
|
+
maxIterations?: number;
|
|
16
|
+
}
|
|
17
|
+
interface ForeachOpts {
|
|
18
|
+
iterable: string;
|
|
19
|
+
step: WorkflowStep;
|
|
20
|
+
itemKey?: string;
|
|
21
|
+
indexKey?: string;
|
|
22
|
+
aggregateOutputKey?: string;
|
|
23
|
+
aggregationMode?: "array" | "concat" | "merge";
|
|
24
|
+
maxConcurrency?: number;
|
|
25
|
+
maxIterations?: number;
|
|
26
|
+
}
|
|
27
|
+
interface MapOpts {
|
|
28
|
+
input: string;
|
|
29
|
+
transform: WorkflowStep;
|
|
30
|
+
outputKey: string;
|
|
31
|
+
itemKey?: string;
|
|
32
|
+
indexKey?: string;
|
|
33
|
+
filter?: (item: unknown, index: number, ctx: WorkflowContext) => boolean;
|
|
34
|
+
maxConcurrency?: number;
|
|
35
|
+
}
|
|
36
|
+
declare class WorkflowBuilder {
|
|
37
|
+
private readonly id;
|
|
38
|
+
private readonly workflowName;
|
|
39
|
+
private readonly steps;
|
|
40
|
+
private timeoutMs?;
|
|
41
|
+
private initCtx?;
|
|
42
|
+
constructor(id: string, name: string);
|
|
43
|
+
step(id: string, name: string, execute: (ctx: WorkflowContext) => Promise<WorkflowContext>): this;
|
|
44
|
+
parallel(id: string, name: string, branches: WorkflowStep[], mergeStrategy?: 'all' | 'first' | 'race'): this;
|
|
45
|
+
conditional(id: string, name: string, opts: ConditionalOpts): this;
|
|
46
|
+
loop(id: string, name: string, opts: LoopOpts): this;
|
|
47
|
+
foreach(id: string, name: string, opts: ForeachOpts): this;
|
|
48
|
+
map(id: string, name: string, opts: MapOpts): this;
|
|
49
|
+
agentStep(id: string, name: string, prompt: string | PromptFn, outputKey: string): this;
|
|
50
|
+
/** Apply retry config to the last added step */
|
|
51
|
+
withRetry(config: Partial<RetryConfig>): this;
|
|
52
|
+
/** Apply rollback to the last added step */
|
|
53
|
+
withRollback(fn: RollbackFn): this;
|
|
54
|
+
/** Apply condition to the last added step */
|
|
55
|
+
withCondition(fn: ConditionFn): this;
|
|
56
|
+
withTimeout(ms: number): this;
|
|
57
|
+
withInitialContext(ctx: WorkflowContext): this;
|
|
58
|
+
build(): WorkflowDefinition;
|
|
59
|
+
}
|
|
60
|
+
declare function defineWorkflow(id: string, name: string): WorkflowBuilder;
|
|
61
|
+
|
|
62
|
+
export { WorkflowBuilder, WorkflowContext, WorkflowDefinition, defineWorkflow };
|