@n1k1t/pipelain 0.4.13 → 0.4.15
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 +34 -2
- package/assets/report/index.hbs +123 -55
- package/assets/report/main.css +13 -0
- package/cli/index.ts +77 -0
- package/lib/src/models/content/factory.d.ts +7 -1
- package/lib/src/models/content/factory.d.ts.map +1 -1
- package/lib/src/models/content/factory.js +15 -0
- package/lib/src/models/content/factory.js.map +1 -1
- package/lib/src/models/content/kinds/article.d.ts +3 -1
- package/lib/src/models/content/kinds/article.d.ts.map +1 -1
- package/lib/src/models/content/kinds/article.js +7 -0
- package/lib/src/models/content/kinds/article.js.map +1 -1
- package/lib/src/models/content/kinds/attachment.d.ts +3 -1
- package/lib/src/models/content/kinds/attachment.d.ts.map +1 -1
- package/lib/src/models/content/kinds/attachment.js +7 -0
- package/lib/src/models/content/kinds/attachment.js.map +1 -1
- package/lib/src/models/content/kinds/group.d.ts +3 -1
- package/lib/src/models/content/kinds/group.d.ts.map +1 -1
- package/lib/src/models/content/kinds/group.js +7 -0
- package/lib/src/models/content/kinds/group.js.map +1 -1
- package/lib/src/models/content/kinds/model.d.ts +5 -0
- package/lib/src/models/content/kinds/model.d.ts.map +1 -1
- package/lib/src/models/content/kinds/model.js +6 -0
- package/lib/src/models/content/kinds/model.js.map +1 -1
- package/lib/src/models/content/kinds/plain.d.ts +3 -1
- package/lib/src/models/content/kinds/plain.d.ts.map +1 -1
- package/lib/src/models/content/kinds/plain.js +7 -0
- package/lib/src/models/content/kinds/plain.js.map +1 -1
- package/lib/src/models/content/kinds/rules.d.ts +3 -1
- package/lib/src/models/content/kinds/rules.d.ts.map +1 -1
- package/lib/src/models/content/kinds/rules.js +7 -0
- package/lib/src/models/content/kinds/rules.js.map +1 -1
- package/lib/src/models/content/kinds/sources.d.ts +3 -1
- package/lib/src/models/content/kinds/sources.d.ts.map +1 -1
- package/lib/src/models/content/kinds/sources.js +7 -0
- package/lib/src/models/content/kinds/sources.js.map +1 -1
- package/lib/src/models/content/kinds/tasks.d.ts +3 -1
- package/lib/src/models/content/kinds/tasks.d.ts.map +1 -1
- package/lib/src/models/content/kinds/tasks.js +7 -0
- package/lib/src/models/content/kinds/tasks.js.map +1 -1
- package/lib/src/models/llm/providers/google.d.ts.map +1 -1
- package/lib/src/models/llm/providers/google.js +8 -1
- package/lib/src/models/llm/providers/google.js.map +1 -1
- package/lib/src/models/llm/providers/model.d.ts +4 -1
- package/lib/src/models/llm/providers/model.d.ts.map +1 -1
- package/lib/src/models/llm/providers/model.js +4 -0
- package/lib/src/models/llm/providers/model.js.map +1 -1
- package/lib/src/models/pipeline/report/types.d.ts +3 -3
- package/lib/src/models/pipeline/report/types.d.ts.map +1 -1
- package/lib/src/models/pipeline/session.d.ts +4 -13
- package/lib/src/models/pipeline/session.d.ts.map +1 -1
- package/lib/src/models/pipeline/session.js.map +1 -1
- package/lib/src/models/pipeline/steps/ai/actions/fallback.d.ts +30 -0
- package/lib/src/models/pipeline/steps/ai/actions/fallback.d.ts.map +1 -0
- package/lib/src/models/pipeline/steps/ai/actions/fallback.js +48 -0
- package/lib/src/models/pipeline/steps/ai/actions/fallback.js.map +1 -0
- package/lib/src/models/pipeline/steps/ai/actions/index.d.ts +1 -0
- package/lib/src/models/pipeline/steps/ai/actions/index.d.ts.map +1 -1
- package/lib/src/models/pipeline/steps/ai/actions/index.js +1 -0
- package/lib/src/models/pipeline/steps/ai/actions/index.js.map +1 -1
- package/lib/src/models/pipeline/steps/ai/actions/model.d.ts +1 -3
- package/lib/src/models/pipeline/steps/ai/actions/model.d.ts.map +1 -1
- package/lib/src/models/pipeline/steps/ai/actions/model.js +1 -2
- package/lib/src/models/pipeline/steps/ai/actions/model.js.map +1 -1
- package/lib/src/models/pipeline/steps/ai/actions/reasoning.js +1 -1
- package/lib/src/models/pipeline/steps/ai/actions/reasoning.js.map +1 -1
- package/lib/src/models/pipeline/steps/ai/actions/tool.js +1 -1
- package/lib/src/models/pipeline/steps/ai/actions/tool.js.map +1 -1
- package/lib/src/models/pipeline/steps/ai/index.d.ts +2 -1
- package/lib/src/models/pipeline/steps/ai/index.d.ts.map +1 -1
- package/lib/src/models/pipeline/steps/ai/index.js +104 -89
- package/lib/src/models/pipeline/steps/ai/index.js.map +1 -1
- package/lib/src/models/pipeline/steps/ai/types.d.ts +3 -0
- package/lib/src/models/pipeline/steps/ai/types.d.ts.map +1 -1
- package/lib/src/models/pipeline/steps/swarm.d.ts +13 -6
- package/lib/src/models/pipeline/steps/swarm.d.ts.map +1 -1
- package/lib/src/models/pipeline/steps/swarm.js +39 -18
- package/lib/src/models/pipeline/steps/swarm.js.map +1 -1
- package/package.json +13 -12
|
@@ -11,9 +11,13 @@ class PipelineSwarmStepCompiler extends model_1.PipelineStepCompiler {
|
|
|
11
11
|
this.definition = definition;
|
|
12
12
|
this.type = 'swarm';
|
|
13
13
|
}
|
|
14
|
-
/** Provides subtask executors */
|
|
15
|
-
|
|
16
|
-
this.
|
|
14
|
+
/** Provides a list of subtask executors */
|
|
15
|
+
list(predicate) {
|
|
16
|
+
return this.subtasks(predicate);
|
|
17
|
+
}
|
|
18
|
+
/** Provides a collection of subtask executors keyed by name */
|
|
19
|
+
map(predicate) {
|
|
20
|
+
this.definition.map = predicate;
|
|
17
21
|
return this;
|
|
18
22
|
}
|
|
19
23
|
/** Provides a bottle neck limit for parallel executions */
|
|
@@ -22,17 +26,26 @@ class PipelineSwarmStepCompiler extends model_1.PipelineStepCompiler {
|
|
|
22
26
|
return this;
|
|
23
27
|
}
|
|
24
28
|
compile(provided) {
|
|
25
|
-
if (!this.definition.
|
|
29
|
+
if (!this.definition.list && !this.definition.map) {
|
|
26
30
|
throw new errors_1.PipelineStepCompilationError(this.type, '[subtasks] are empty');
|
|
27
31
|
}
|
|
32
|
+
if (this.definition.list && this.definition.map) {
|
|
33
|
+
throw new errors_1.PipelineStepCompilationError(this.type, '[map] and [list] are conflicted');
|
|
34
|
+
}
|
|
28
35
|
return new PipelineSwarmStep(this.type, {
|
|
29
36
|
title: this.definition.title,
|
|
30
|
-
subtasks: this.definition.subtasks,
|
|
31
37
|
limit: this.definition.limit,
|
|
38
|
+
list: this.definition.list,
|
|
39
|
+
map: this.definition.map,
|
|
32
40
|
pipeline: provided.pipeline,
|
|
33
41
|
parent: provided.parent,
|
|
34
42
|
});
|
|
35
43
|
}
|
|
44
|
+
/** @deprecated Provides subtask executors (use `list` method instead) */
|
|
45
|
+
subtasks(predicate) {
|
|
46
|
+
this.definition.list = predicate;
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
36
49
|
static build(title) {
|
|
37
50
|
return new PipelineSwarmStepCompiler({ title });
|
|
38
51
|
}
|
|
@@ -41,22 +54,30 @@ exports.PipelineSwarmStepCompiler = PipelineSwarmStepCompiler;
|
|
|
41
54
|
class PipelineSwarmStep extends model_1.PipelineStep {
|
|
42
55
|
async run(parameters) {
|
|
43
56
|
const meta = (0, utils_1.buildMetaManager)();
|
|
57
|
+
const exec = async (subtask) => {
|
|
58
|
+
const compiled = await subtask.compile({ pipeline: this.pipeline, parent: this });
|
|
59
|
+
return compiled instanceof model_1.PipelineStep
|
|
60
|
+
? compiled.run(parameters)
|
|
61
|
+
: compiled.run(undefined);
|
|
62
|
+
};
|
|
44
63
|
this.pipeline.session.emit('step:run', { step: this, meta: meta.init() });
|
|
45
64
|
try {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
65
|
+
if (this.definition.map) {
|
|
66
|
+
const map = typeof this.definition.map === 'function'
|
|
67
|
+
? await this.definition.map(parameters)
|
|
68
|
+
: this.definition.map;
|
|
69
|
+
const handled = await (0, utils_2.chunkify)(Object.keys(map), this.definition.limit ?? Infinity, (key) => exec(map[key]));
|
|
70
|
+
const result = Object.fromEntries(handled.map((subtask) => [subtask.payload, subtask.result]));
|
|
71
|
+
this.pipeline.session.emit('step:run', { step: this, meta: meta.done() });
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
const subtasks = typeof this.definition.list === 'function'
|
|
75
|
+
? await this.definition.list(parameters)
|
|
76
|
+
: this.definition.list ?? [];
|
|
77
|
+
const handled = await (0, utils_2.chunkify)(subtasks, this.definition.limit ?? Infinity, exec);
|
|
78
|
+
const result = handled.map((subtask) => subtask.result);
|
|
58
79
|
this.pipeline.session.emit('step:run', { step: this, meta: meta.done() });
|
|
59
|
-
return
|
|
80
|
+
return result;
|
|
60
81
|
}
|
|
61
82
|
catch (error) {
|
|
62
83
|
this.pipeline.session.emit('step:run', { step: this, meta: meta.error() });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swarm.js","sourceRoot":"","sources":["../../../../../src/models/pipeline/steps/swarm.ts"],"names":[],"mappings":";;;AAIA,mCAA2G;AAC3G,sCAAyD;AAEzD,0CAAkD;AAClD,0CAA0C;
|
|
1
|
+
{"version":3,"file":"swarm.js","sourceRoot":"","sources":["../../../../../src/models/pipeline/steps/swarm.ts"],"names":[],"mappings":";;;AAIA,mCAA2G;AAC3G,sCAAyD;AAEzD,0CAAkD;AAClD,0CAA0C;AAa1C,MAAa,yBAIX,SAAQ,4BAA6B;IAGrC,YAAsB,UAAgD;QACpE,KAAK,EAAE,CAAC;QADY,eAAU,GAAV,UAAU,CAAsC;QAF9D,SAAI,GAAwC,OAAO,CAAC;IAI5D,CAAC;IAED,2CAA2C;IACpC,IAAI,CAGT,SAAgE;QAChE,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAClC,CAAC;IAED,+DAA+D;IACxD,GAAG,CAKR,SAA4D;QAC5D,IAAI,CAAC,UAAU,CAAC,GAAG,GAAG,SAAS,CAAC;QAChC,OAAuB,IAAI,CAAC;IAC9B,CAAC;IAED,2DAA2D;IACpD,KAAK,CAAC,KAAa;QACxB,IAAI,CAAC,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AU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBAC1E,OAAO,MAAM,CAAC;YAChB,CAAC;YAED,MAAM,QAAQ,GAAG,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,UAAU;gBACzD,CAAC,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC;gBACxC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,IAAI,EAAE,CAAC;YAE/B,MAAM,OAAO,GAAG,MAAM,IAAA,gBAAQ,EAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,KAAK,IAAI,QAAQ,EAAE,IAAI,CAAC,CAAC;YAClF,MAAM,MAAM,GAAY,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAEjE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAC1E,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAC3E,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AA3CD,8CA2CC"}
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@n1k1t/pipelain",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.15",
|
|
4
4
|
"description": "Powerful utility to build and execute type-safe AI pipelines with structured outputs and tool integration",
|
|
5
5
|
"main": "lib/src/index.js",
|
|
6
6
|
"types": "lib/src/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"test": "NODE_ENV=test jest --silent",
|
|
9
9
|
"test:coverage": "NODE_ENV=test jest --coverage",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
10
|
+
"run:pipelain:main": "npx ts-node test/index.ts",
|
|
11
|
+
"run:pipelain:tool": "npx ts-node test/tool.ts",
|
|
12
|
+
"run:pipelain:skill": "npx ts-node test/skill.ts",
|
|
13
|
+
"run:pipelain:report": "npx ts-node test/report.ts",
|
|
14
|
+
"run:pipelain:fallback": "npx ts-node test/fallback.ts",
|
|
14
15
|
"build": "rm -rf lib && npx tsc",
|
|
15
16
|
"build:check": "npx tsc --noEmit",
|
|
16
17
|
"prepare": "husky",
|
|
@@ -90,14 +91,14 @@
|
|
|
90
91
|
"typescript": "5.7.2"
|
|
91
92
|
},
|
|
92
93
|
"dependencies": {
|
|
93
|
-
"@ai-sdk/anthropic": "4.0.
|
|
94
|
-
"@ai-sdk/google": "4.0.
|
|
95
|
-
"@ai-sdk/mcp": "2.0.
|
|
96
|
-
"@ai-sdk/mistral": "4.0.
|
|
97
|
-
"@ai-sdk/openai": "4.0.
|
|
98
|
-
"@ai-sdk/openai-compatible": "3.0.
|
|
94
|
+
"@ai-sdk/anthropic": "4.0.49",
|
|
95
|
+
"@ai-sdk/google": "4.0.63",
|
|
96
|
+
"@ai-sdk/mcp": "2.0.44",
|
|
97
|
+
"@ai-sdk/mistral": "4.0.39",
|
|
98
|
+
"@ai-sdk/openai": "4.0.58",
|
|
99
|
+
"@ai-sdk/openai-compatible": "3.0.43",
|
|
99
100
|
"@ast-grep/napi": "0.42.0",
|
|
100
|
-
"ai": "7.0.
|
|
101
|
+
"ai": "7.0.92",
|
|
101
102
|
"colors": "1.4.0",
|
|
102
103
|
"commander": "9.4.0",
|
|
103
104
|
"dayjs": "1.11.21",
|