taskmeld 0.1.2 → 0.1.41
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 +176 -176
- package/README.zh-CN.md +176 -176
- package/dist/src/app/app-context-env.js +1 -1
- package/dist/src/app/create-app-context.js +3 -3
- package/dist/src/app/data-dir.js +13 -3
- package/dist/src/app/pipeline-config.js +4 -4
- package/dist/src/app/pipeline-registry.js +11 -11
- package/dist/src/app/pipeline-runtime.js +6 -9
- package/dist/src/app/runtime-store.js +3 -3
- package/dist/src/artifacts/artifact-cleanup.js +17 -17
- package/dist/src/artifacts/artifact-index.js +14 -14
- package/dist/src/artifacts/artifact-rebuilder.js +3 -3
- package/dist/src/artifacts/storage-service.js +18 -18
- package/dist/src/cli/bootstrap.js +7 -7
- package/dist/src/cli/commands/agent.js +12 -11
- package/dist/src/cli/commands/artifact.js +31 -30
- package/dist/src/cli/commands/init.js +49 -47
- package/dist/src/cli/commands/pipeline/result.js +9 -8
- package/dist/src/cli/commands/pipeline/selector.js +1 -1
- package/dist/src/cli/commands/pipeline/watch.js +2 -2
- package/dist/src/cli/commands/pipeline.js +54 -53
- package/dist/src/cli/commands/scheduler.js +9 -8
- package/dist/src/cli/commands/server.js +12 -11
- package/dist/src/cli/commands/system.js +4 -3
- package/dist/src/cli/errors.js +2 -2
- package/dist/src/cli/help.js +18 -17
- package/dist/src/cli/i18n.js +46 -0
- package/dist/src/cli/locales/en.json +244 -0
- package/dist/src/cli/locales/zh.json +244 -0
- package/dist/src/cli/output.js +3 -3
- package/dist/src/cli/renderers/engine/markdown.js +1 -1
- package/dist/src/cli/renderers/specs/index.js +1 -1
- package/dist/src/cli/router.js +1 -1
- package/dist/src/cli/server-runtime-client.js +54 -95
- package/dist/src/cli/ui-prompts.js +96 -0
- package/dist/src/cli/ws-runtime-client.js +51 -0
- package/dist/src/gateway/gateway-client.js +4 -4
- package/dist/src/index.js +28 -2
- package/dist/src/logs/run-log-reader.js +1 -1
- package/dist/src/pipeline/agent-activity.js +2 -2
- package/dist/src/pipeline/artifact-storage.js +11 -11
- package/dist/src/pipeline/diagnostics/dependency-diagnostic.js +11 -11
- package/dist/src/pipeline/dispatch/pipeline-inbound-queue.js +2 -2
- package/dist/src/pipeline/execution/group-item-executor.js +1 -1
- package/dist/src/pipeline/execution/node-item-executor.js +3 -3
- package/dist/src/pipeline/execution/node-runner.js +7 -7
- package/dist/src/pipeline/execution/readiness-state.js +1 -1
- package/dist/src/pipeline/execution/reject-handler.js +5 -5
- package/dist/src/pipeline/execution/rejected-artifact-archiver.js +1 -1
- package/dist/src/pipeline/execution/route-item-manager.js +4 -4
- package/dist/src/pipeline/execution/run-abort-controller.js +5 -5
- package/dist/src/pipeline/execution/run-state-helpers.js +2 -2
- package/dist/src/pipeline/execution/service.js +4 -4
- package/dist/src/pipeline/execution/structured-node-runner.js +24 -24
- package/dist/src/pipeline/execution-timeout.js +3 -3
- package/dist/src/pipeline/identity/index.js +3 -3
- package/dist/src/pipeline/item-batch-controller.js +6 -6
- package/dist/src/pipeline/scheduler/dependency-state.js +5 -5
- package/dist/src/pipeline/scheduler-service.js +24 -24
- package/dist/src/pipeline/state-machine.js +2 -2
- package/dist/src/pipeline/structured-output/contract.js +4 -4
- package/dist/src/pipeline/structured-output/index.js +2 -2
- package/dist/src/pipeline/structured-output/parser.js +5 -5
- package/dist/src/pipeline/structured-output/prompt.js +38 -38
- package/dist/src/pipeline/structured-output/waiter.js +6 -6
- package/dist/src/pipeline/template.js +5 -5
- package/dist/src/pipeline/timeline-log-store.js +5 -5
- package/dist/src/pipeline/tool-activity.js +3 -3
- package/dist/src/pipeline/types/pipeline-output.js +1 -1
- package/dist/src/pipeline/workflow/branch-rules.js +19 -19
- package/dist/src/pipeline/workflow/io.js +1 -1
- package/dist/src/pipeline/workflow/normalize.js +18 -18
- package/dist/src/pipeline/workflow/template-mapper.js +3 -3
- package/dist/src/pipeline/workflow/validate.js +39 -39
- package/dist/src/pipeline/workflow-graph.js +10 -10
- package/dist/src/server/http-handler.js +74 -0
- package/dist/src/services/agent-service.js +2 -2
- package/dist/src/services/gateway-read-helpers.js +1 -1
- package/dist/src/services/pipeline-service.js +19 -19
- package/dist/src/services/pipeline-status.js +4 -4
- package/dist/src/services/read-services.js +1 -1
- package/dist/src/services/session-service.js +6 -6
- package/dist/src/services/system-service.js +1 -1
- package/dist/src/transport/ws-broker.js +12 -1
- package/dist/src/transport/ws-handler.js +60 -0
- package/dist/src/transport/ws-methods/agents.js +144 -0
- package/dist/src/transport/ws-methods/artifacts.js +171 -0
- package/dist/src/transport/ws-methods/gateway.js +16 -0
- package/dist/src/transport/ws-methods/logs.js +43 -0
- package/dist/src/transport/ws-methods/pipeline-batch.js +68 -0
- package/dist/src/transport/ws-methods/pipeline-links.js +100 -0
- package/dist/src/transport/ws-methods/pipeline-queue.js +51 -0
- package/dist/src/transport/ws-methods/pipeline-runtime.js +151 -0
- package/dist/src/transport/ws-methods/pipeline-scheduler.js +48 -0
- package/dist/src/transport/ws-methods/pipeline-workflow.js +127 -0
- package/dist/src/transport/ws-methods/pipelines.js +56 -0
- package/dist/src/transport/ws-methods/register-all.js +32 -0
- package/dist/src/transport/ws-methods/sessions.js +154 -0
- package/dist/src/transport/ws-methods/timeline.js +10 -0
- package/dist/src/{server/routes/pipeline-identity.js → transport/ws-methods/utils.js} +14 -9
- package/dist/src/version.js +1 -1
- package/package.json +15 -7
- package/web/dist/assets/agent-DP6TMcLj.js +1 -0
- package/web/dist/assets/agent-DmJHzLyj.js +1 -0
- package/web/dist/assets/artifact-BqnoZy2M.js +1 -0
- package/web/dist/assets/artifact-DfDkgkno.js +1 -0
- package/web/dist/assets/common-DRMTVwE9.js +1 -0
- package/web/dist/assets/common-DeXccbr2.js +1 -0
- package/web/dist/assets/dispatch-CBskGCQI.js +1 -0
- package/web/dist/assets/dispatch-sk4Wp30e.js +1 -0
- package/web/dist/assets/index-C8wTjZvH.css +1 -0
- package/web/dist/assets/index-DYDQZRLk.js +58 -0
- package/web/dist/assets/log-DN8cjb0w.js +1 -0
- package/web/dist/assets/log-HSeA_dYy.js +1 -0
- package/web/dist/assets/modal-BdNai9jf.js +1 -0
- package/web/dist/assets/modal-D9_KDpFD.js +1 -0
- package/web/dist/assets/nav-BmF7oAKg.js +1 -0
- package/web/dist/assets/nav-IjC2xqXQ.js +1 -0
- package/web/dist/assets/node-detail-CENRXcrh.js +1 -0
- package/web/dist/assets/node-detail-bndPr0IM.js +1 -0
- package/web/dist/assets/overview-B87zWAxq.js +1 -0
- package/web/dist/assets/overview-gQvk-NOK.js +1 -0
- package/web/dist/assets/pipeline-D4dSJRDz.js +1 -0
- package/web/dist/assets/pipeline-DZzyOqQa.js +1 -0
- package/web/dist/assets/session-CUWvU14v.js +5 -0
- package/web/dist/assets/session-DQ6UuCaJ.js +5 -0
- package/web/dist/assets/timeline-8y_2_0Em.js +1 -0
- package/web/dist/assets/timeline-CAPsXUTC.js +1 -0
- package/web/dist/index.html +3 -3
- package/dist/src/app/pipeline-plugin-config.js +0 -2
- package/dist/src/server/api-handler.js +0 -163
- package/dist/src/server/http-utils.js +0 -34
- package/dist/src/server/middleware.js +0 -61
- package/dist/src/server/router.js +0 -105
- package/dist/src/server/routes/agents.js +0 -189
- package/dist/src/server/routes/artifacts.js +0 -163
- package/dist/src/server/routes/gateway.js +0 -18
- package/dist/src/server/routes/health.js +0 -16
- package/dist/src/server/routes/logs.js +0 -73
- package/dist/src/server/routes/pipeline-batch.js +0 -163
- package/dist/src/server/routes/pipeline-diagnostics.js +0 -33
- package/dist/src/server/routes/pipeline-links.js +0 -117
- package/dist/src/server/routes/pipeline-outputs.js +0 -27
- package/dist/src/server/routes/pipeline-queue.js +0 -62
- package/dist/src/server/routes/pipeline-runtime.js +0 -162
- package/dist/src/server/routes/pipeline-scheduler.js +0 -69
- package/dist/src/server/routes/pipeline-workflow.js +0 -180
- package/dist/src/server/routes/pipelines.js +0 -96
- package/dist/src/server/routes/sessions.js +0 -244
- package/dist/src/server/routes/timeline.js +0 -14
- package/dist/src/server/serve-static.js +0 -42
- package/web/dist/assets/index-CWnfhkn-.js +0 -65
- package/web/dist/assets/index-gZ0xOfSO.css +0 -1
- /package/dist/src/{server → transport/ws-methods}/types.js +0 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerArtifactWsMethods = void 0;
|
|
4
|
+
const storage_service_1 = require("../../artifacts/storage-service");
|
|
5
|
+
const artifact_index_1 = require("../../artifacts/artifact-index");
|
|
6
|
+
const artifact_cleanup_1 = require("../../artifacts/artifact-cleanup");
|
|
7
|
+
const storage_service_2 = require("../../artifacts/storage-service");
|
|
8
|
+
const parseCsvParam = (value) => {
|
|
9
|
+
if (typeof value !== "string")
|
|
10
|
+
return [];
|
|
11
|
+
return value.split(",").map((s) => s.trim()).filter(Boolean);
|
|
12
|
+
};
|
|
13
|
+
const registerArtifactWsMethods = (registry) => {
|
|
14
|
+
registry.register("artifact.list", async (params, ctx) => {
|
|
15
|
+
try {
|
|
16
|
+
const pipelineIds = parseCsvParam(params.pipelineId);
|
|
17
|
+
const nodeIds = parseCsvParam(params.nodeId);
|
|
18
|
+
const statuses = parseCsvParam(params.status);
|
|
19
|
+
const kinds = parseCsvParam(params.kind);
|
|
20
|
+
const dateFrom = typeof params.dateFrom === "string" && params.dateFrom.trim() ? params.dateFrom.trim() : null;
|
|
21
|
+
const dateTo = typeof params.dateTo === "string" && params.dateTo.trim() ? params.dateTo.trim() : null;
|
|
22
|
+
const cursor = typeof params.cursor === "string" && params.cursor.trim() ? params.cursor.trim() : undefined;
|
|
23
|
+
const batchRunId = typeof params.batchRunId === "string" && params.batchRunId.trim() ? params.batchRunId.trim() : undefined;
|
|
24
|
+
const runId = typeof params.runId === "string" && params.runId.trim() ? params.runId.trim() : undefined;
|
|
25
|
+
const limitRaw = typeof params.limit === "number" ? params.limit : 100;
|
|
26
|
+
const result = await (0, storage_service_1.listStoredArtifacts)(ctx.app.listPipelines(), {
|
|
27
|
+
pipelineIds,
|
|
28
|
+
nodeIds,
|
|
29
|
+
dateFrom,
|
|
30
|
+
dateTo,
|
|
31
|
+
limit: Number.isFinite(limitRaw) ? limitRaw : 100,
|
|
32
|
+
cursor,
|
|
33
|
+
statuses: statuses.length ? statuses : undefined,
|
|
34
|
+
kinds: kinds.length ? kinds : undefined,
|
|
35
|
+
batchRunId,
|
|
36
|
+
runId,
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
39
|
+
ok: true,
|
|
40
|
+
payload: { items: result.items, nextCursor: result.nextCursor, source: result.source },
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
return { ok: false, error: String(error) };
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
registry.register("artifact.content.get", async (params, ctx) => {
|
|
48
|
+
try {
|
|
49
|
+
const pipelineId = typeof params.pipelineId === "string" ? params.pipelineId.trim() : "";
|
|
50
|
+
const relativePath = typeof params.relativePath === "string" ? params.relativePath.trim() : "";
|
|
51
|
+
const artifactId = typeof params.artifactId === "string" ? params.artifactId.trim() : "";
|
|
52
|
+
if (!pipelineId || (!relativePath && !artifactId)) {
|
|
53
|
+
return { ok: false, error: "invalid_artifact_query" };
|
|
54
|
+
}
|
|
55
|
+
const definition = ctx.app.getPipelineDefinition(pipelineId);
|
|
56
|
+
if (!definition) {
|
|
57
|
+
return { ok: false, error: "pipeline_not_found" };
|
|
58
|
+
}
|
|
59
|
+
let resolvedPath = relativePath || undefined;
|
|
60
|
+
if (!resolvedPath && artifactId) {
|
|
61
|
+
const listResult = await (0, storage_service_1.listStoredArtifacts)(ctx.app.listPipelines(), {
|
|
62
|
+
pipelineIds: [pipelineId],
|
|
63
|
+
limit: 5000,
|
|
64
|
+
});
|
|
65
|
+
const match = listResult.items.find((item) => item.artifactId === artifactId);
|
|
66
|
+
resolvedPath = match?.relativePath ?? undefined;
|
|
67
|
+
}
|
|
68
|
+
if (!resolvedPath) {
|
|
69
|
+
return { ok: false, error: "artifact_not_found" };
|
|
70
|
+
}
|
|
71
|
+
const content = await (0, storage_service_1.readStoredArtifactContent)(definition, resolvedPath);
|
|
72
|
+
if (!content) {
|
|
73
|
+
return { ok: false, error: "artifact_not_found" };
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
ok: true,
|
|
77
|
+
payload: { pipelineId, relativePath: resolvedPath, artifactId: artifactId || null, content },
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
return { ok: false, error: String(error) };
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
registry.register("artifact.export", async (params, ctx) => {
|
|
85
|
+
try {
|
|
86
|
+
const pipelineIds = parseCsvParam(params.pipelineId);
|
|
87
|
+
const nodeIds = parseCsvParam(params.nodeId);
|
|
88
|
+
const dateFrom = typeof params.dateFrom === "string" && params.dateFrom.trim() ? params.dateFrom.trim() : null;
|
|
89
|
+
const dateTo = typeof params.dateTo === "string" && params.dateTo.trim() ? params.dateTo.trim() : null;
|
|
90
|
+
const limitRaw = typeof params.limit === "number" ? params.limit : 20000;
|
|
91
|
+
const kinds = parseCsvParam(params.kind);
|
|
92
|
+
const effectiveKinds = kinds.length > 0 ? kinds : ["artifact", "adapter", "group"];
|
|
93
|
+
const data = await (0, storage_service_1.exportStoredArtifactContents)(ctx.app.listPipelines(), {
|
|
94
|
+
pipelineIds,
|
|
95
|
+
nodeIds,
|
|
96
|
+
dateFrom,
|
|
97
|
+
dateTo,
|
|
98
|
+
limit: Number.isFinite(limitRaw) ? limitRaw : 20000,
|
|
99
|
+
kinds: effectiveKinds,
|
|
100
|
+
});
|
|
101
|
+
return { ok: true, payload: { data } };
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
return { ok: false, error: String(error) };
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
registry.register("artifact.cleanup", async (params, ctx) => {
|
|
108
|
+
try {
|
|
109
|
+
const pipelineId = typeof params.pipelineId === "string" ? params.pipelineId.trim() : undefined;
|
|
110
|
+
const olderThanDaysRaw = typeof params.olderThanDays === "number" ? params.olderThanDays : 0;
|
|
111
|
+
const olderThanDays = olderThanDaysRaw || undefined;
|
|
112
|
+
const statusParam = typeof params.status === "string" ? params.status : "";
|
|
113
|
+
const statuses = statusParam ? statusParam.split(",").map((s) => s.trim()).filter(Boolean) : undefined;
|
|
114
|
+
const confirm = params.confirm === true;
|
|
115
|
+
const definitions = pipelineId
|
|
116
|
+
? [ctx.app.getPipelineDefinition(pipelineId)].filter(Boolean)
|
|
117
|
+
: ctx.app.listPipelines();
|
|
118
|
+
if (definitions.length === 0) {
|
|
119
|
+
return { ok: false, error: "pipeline_not_found" };
|
|
120
|
+
}
|
|
121
|
+
let totalFiles = 0;
|
|
122
|
+
let totalSizeBytes = 0;
|
|
123
|
+
let deleted = 0;
|
|
124
|
+
let failed = 0;
|
|
125
|
+
const allWarnings = [];
|
|
126
|
+
for (const definition of definitions) {
|
|
127
|
+
const plan = await (0, artifact_cleanup_1.planCleanup)(definition, { olderThanDays, statuses });
|
|
128
|
+
totalFiles += plan.files.length;
|
|
129
|
+
totalSizeBytes += plan.totalSizeBytes;
|
|
130
|
+
if (confirm) {
|
|
131
|
+
const execResult = await (0, artifact_cleanup_1.executeCleanup)(definition, plan);
|
|
132
|
+
deleted += execResult.deleted;
|
|
133
|
+
failed += execResult.failed;
|
|
134
|
+
allWarnings.push(...execResult.warnings);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
ok: true,
|
|
139
|
+
payload: { totalFiles, totalSizeBytes, deleted, failed, dryRun: !confirm, warnings: allWarnings },
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
return { ok: false, error: String(error) };
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
registry.register("artifact.rebuildIndex", async (params, ctx) => {
|
|
147
|
+
try {
|
|
148
|
+
const pipelineId = typeof params.pipelineId === "string" ? params.pipelineId.trim() : undefined;
|
|
149
|
+
const definitions = pipelineId
|
|
150
|
+
? [ctx.app.getPipelineDefinition(pipelineId)].filter(Boolean)
|
|
151
|
+
: ctx.app.listPipelines();
|
|
152
|
+
if (definitions.length === 0) {
|
|
153
|
+
return { ok: false, error: "pipeline_not_found" };
|
|
154
|
+
}
|
|
155
|
+
let indexed = 0;
|
|
156
|
+
let skipped = 0;
|
|
157
|
+
const warnings = [];
|
|
158
|
+
for (const definition of definitions) {
|
|
159
|
+
const result = await (0, artifact_index_1.rebuildArtifactIndex)(definition, (d) => (0, storage_service_2.scanStoredArtifacts)([d]));
|
|
160
|
+
indexed += result.indexed;
|
|
161
|
+
skipped += result.skipped;
|
|
162
|
+
warnings.push(...result.warnings);
|
|
163
|
+
}
|
|
164
|
+
return { ok: true, payload: { indexed, skipped, warnings } };
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
return { ok: false, error: String(error) };
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
};
|
|
171
|
+
exports.registerArtifactWsMethods = registerArtifactWsMethods;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerGatewayWsMethods = void 0;
|
|
4
|
+
const registerGatewayWsMethods = (registry) => {
|
|
5
|
+
registry.register("gateway.status", (_params, ctx) => {
|
|
6
|
+
return {
|
|
7
|
+
ok: true,
|
|
8
|
+
payload: {
|
|
9
|
+
status: ctx.services.getLatestStatus?.() ?? ctx.services.client?.getStatus?.(),
|
|
10
|
+
hello: ctx.services.getLatestHello?.(),
|
|
11
|
+
lastFrame: ctx.services.getLastFrame?.(),
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
exports.registerGatewayWsMethods = registerGatewayWsMethods;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerLogWsMethods = void 0;
|
|
4
|
+
const registerLogWsMethods = (registry) => {
|
|
5
|
+
registry.register("log.runs.list", async (_params, ctx) => {
|
|
6
|
+
try {
|
|
7
|
+
const items = ctx.services.runLogService ? await ctx.services.runLogService.listRuns() : [];
|
|
8
|
+
return { ok: true, payload: { items } };
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
return { ok: false, error: String(error) };
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
registry.register("log.timeline", async (params, ctx) => {
|
|
15
|
+
const runId = typeof params.runId === "string" ? params.runId : "";
|
|
16
|
+
if (!runId || !ctx.services.runLogService) {
|
|
17
|
+
return { ok: false, error: runId ? "run_log_not_available" : "invalid_run_id" };
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
const levelParam = typeof params.level === "string" ? params.level : "";
|
|
21
|
+
const levels = levelParam
|
|
22
|
+
? (levelParam.split(",").map((s) => s.trim()).filter((s) => s === "info" || s === "warn" || s === "error"))
|
|
23
|
+
: undefined;
|
|
24
|
+
const offset = typeof params.offset === "number" && Number.isFinite(params.offset) ? params.offset : 0;
|
|
25
|
+
const limit = typeof params.limit === "number" && Number.isFinite(params.limit) ? params.limit : undefined;
|
|
26
|
+
const keyword = typeof params.keyword === "string" && params.keyword.trim() ? params.keyword.trim() : undefined;
|
|
27
|
+
const order = params.order === "asc" ? "asc" : "desc";
|
|
28
|
+
const page = await ctx.services.runLogService.queryTimeline({
|
|
29
|
+
runId,
|
|
30
|
+
offset,
|
|
31
|
+
limit,
|
|
32
|
+
keyword,
|
|
33
|
+
levels,
|
|
34
|
+
order,
|
|
35
|
+
});
|
|
36
|
+
return { ok: true, payload: page };
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
return { ok: false, error: String(error) };
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
exports.registerLogWsMethods = registerLogWsMethods;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerPipelineBatchWsMethods = void 0;
|
|
4
|
+
const item_batch_controller_1 = require("../../pipeline/item-batch-controller");
|
|
5
|
+
const pipeline_service_1 = require("../../services/pipeline-service");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
const registerPipelineBatchWsMethods = (registry) => {
|
|
8
|
+
// pipeline.batchRun.status
|
|
9
|
+
registry.register("pipeline.batchRun.status", (params, ctx) => {
|
|
10
|
+
const pipelineId = typeof params.pipelineId === "string" ? params.pipelineId : "";
|
|
11
|
+
const runtime = ctx.app.getPipelineRuntime(pipelineId);
|
|
12
|
+
if (!runtime)
|
|
13
|
+
return { ok: false, error: "pipeline_not_found" };
|
|
14
|
+
const batchRunState = runtime.pipeline.getBatchRunState();
|
|
15
|
+
const identity = (0, pipeline_service_1.readPipelineIdentitySnapshot)(pipelineId, runtime.runtime.getRun(), batchRunState);
|
|
16
|
+
return { ok: true, payload: { ok: true, state: batchRunState, ...identity } };
|
|
17
|
+
});
|
|
18
|
+
// pipeline.batchRun.start
|
|
19
|
+
registry.register("pipeline.batchRun.start", async (params, ctx) => {
|
|
20
|
+
const pipelineId = typeof params.pipelineId === "string" ? params.pipelineId : "";
|
|
21
|
+
const runtime = ctx.app.getPipelineRuntime(pipelineId);
|
|
22
|
+
if (!runtime)
|
|
23
|
+
return { ok: false, error: "pipeline_not_found" };
|
|
24
|
+
const items = (0, item_batch_controller_1.normalizePoolItems)(params.items ?? params.keywords ?? params.pool ?? params);
|
|
25
|
+
const batchSize = typeof params.batchSize === "number" ? params.batchSize
|
|
26
|
+
: typeof params.size === "number" ? params.size
|
|
27
|
+
: typeof params.chunkSize === "number" ? params.chunkSize : undefined;
|
|
28
|
+
const startIndex = typeof params.startIndex === "number" ? params.startIndex : undefined;
|
|
29
|
+
const startBatch = typeof params.startBatch === "number" ? params.startBatch : undefined;
|
|
30
|
+
const started = ctx.services.pipelineService.startBatchRun({ pipelineId, items, batchSize, startIndex, startBatch });
|
|
31
|
+
if (started.ok === false) {
|
|
32
|
+
return { ok: false, error: started.error, payload: { ...started } };
|
|
33
|
+
}
|
|
34
|
+
return { ok: true, payload: { ok: true, state: started.state, pipelineId } };
|
|
35
|
+
});
|
|
36
|
+
// pipeline.batchRun.startRemote
|
|
37
|
+
registry.register("pipeline.batchRun.startRemote", async (params, ctx) => {
|
|
38
|
+
const pipelineId = typeof params.pipelineId === "string" ? params.pipelineId : "";
|
|
39
|
+
const runtime = ctx.app.getPipelineRuntime(pipelineId);
|
|
40
|
+
if (!runtime)
|
|
41
|
+
return { ok: false, error: "pipeline_not_found" };
|
|
42
|
+
const remoteUrl = typeof params.url === "string" ? params.url : undefined;
|
|
43
|
+
const batchSize = typeof params.batchSize === "number" ? params.batchSize
|
|
44
|
+
: typeof params.size === "number" ? params.size
|
|
45
|
+
: typeof params.chunkSize === "number" ? params.chunkSize : undefined;
|
|
46
|
+
const startIndex = typeof params.startIndex === "number" ? params.startIndex : undefined;
|
|
47
|
+
const startBatch = typeof params.startBatch === "number" ? params.startBatch : undefined;
|
|
48
|
+
const started = await ctx.services.pipelineService.startRemoteBatchRun({ pipelineId, url: remoteUrl, batchSize, startIndex, startBatch });
|
|
49
|
+
if (started.ok === false) {
|
|
50
|
+
return { ok: false, error: started.error, payload: { ...started } };
|
|
51
|
+
}
|
|
52
|
+
return { ok: true, payload: { ok: true, state: started.state, remoteUrl: started.remoteUrl, totalFetched: started.totalFetched, pipelineId } };
|
|
53
|
+
});
|
|
54
|
+
// pipeline.batchRun.stop
|
|
55
|
+
registry.register("pipeline.batchRun.stop", async (params, ctx) => {
|
|
56
|
+
const pipelineId = typeof params.pipelineId === "string" ? params.pipelineId : "";
|
|
57
|
+
const runtime = ctx.app.getPipelineRuntime(pipelineId);
|
|
58
|
+
if (!runtime)
|
|
59
|
+
return { ok: false, error: "pipeline_not_found" };
|
|
60
|
+
const target = (0, utils_1.mergeIdentityTargets)((0, utils_1.readIdentityTargetFromBody)(params), { runId: typeof params.runId === "string" ? params.runId : undefined, batchRunId: typeof params.batchRunId === "string" ? params.batchRunId : undefined });
|
|
61
|
+
const stopped = ctx.services.pipelineService.stopPipeline(pipelineId, target);
|
|
62
|
+
if (stopped.ok === false) {
|
|
63
|
+
return { ok: false, error: stopped.error, payload: { ...stopped } };
|
|
64
|
+
}
|
|
65
|
+
return { ok: true, payload: stopped };
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
exports.registerPipelineBatchWsMethods = registerPipelineBatchWsMethods;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerPipelineLinksWsMethods = void 0;
|
|
4
|
+
const node_crypto_1 = require("node:crypto");
|
|
5
|
+
const pipeline_link_1 = require("../../pipeline/types/pipeline-link");
|
|
6
|
+
const registerPipelineLinksWsMethods = (registry) => {
|
|
7
|
+
// pipeline.link.list
|
|
8
|
+
registry.register("pipeline.link.list", async (_params, ctx) => {
|
|
9
|
+
const links = await ctx.app.dispatch.listLinks();
|
|
10
|
+
return { ok: true, payload: { ok: true, items: links } };
|
|
11
|
+
});
|
|
12
|
+
// pipeline.link.create
|
|
13
|
+
registry.register("pipeline.link.create", async (params, ctx) => {
|
|
14
|
+
const id = typeof params.id === "string" ? params.id.trim() : `link:${(0, node_crypto_1.randomUUID)()}`;
|
|
15
|
+
if (!(0, pipeline_link_1.isValidLinkId)(id)) {
|
|
16
|
+
return { ok: false, error: "pipeline_link_invalid_id" };
|
|
17
|
+
}
|
|
18
|
+
const fromPipelineId = typeof params.fromPipelineId === "string" ? params.fromPipelineId.trim() : "";
|
|
19
|
+
const toPipelineId = typeof params.toPipelineId === "string" ? params.toPipelineId.trim() : "";
|
|
20
|
+
if (!fromPipelineId || !toPipelineId) {
|
|
21
|
+
return { ok: false, error: "pipeline_link_missing_pipelines" };
|
|
22
|
+
}
|
|
23
|
+
if (!ctx.app.getPipelineDefinition(fromPipelineId)) {
|
|
24
|
+
return { ok: false, error: "pipeline_not_found" };
|
|
25
|
+
}
|
|
26
|
+
if (!ctx.app.getPipelineDefinition(toPipelineId)) {
|
|
27
|
+
return { ok: false, error: "pipeline_not_found" };
|
|
28
|
+
}
|
|
29
|
+
const contract = params.inputContract && typeof params.inputContract === "object"
|
|
30
|
+
? {
|
|
31
|
+
requireType: typeof params.inputContract.requireType === "string"
|
|
32
|
+
? params.inputContract.requireType : undefined,
|
|
33
|
+
requireSchemaVersion: typeof params.inputContract.requireSchemaVersion === "number"
|
|
34
|
+
? params.inputContract.requireSchemaVersion : undefined,
|
|
35
|
+
} : null;
|
|
36
|
+
const maxPendingJobs = typeof params.maxPendingJobs === "number" && Number.isFinite(params.maxPendingJobs)
|
|
37
|
+
? Math.min(10000, Math.max(1, Math.trunc(params.maxPendingJobs))) : 100;
|
|
38
|
+
const onJobFailed = params.onJobFailed === "pause" ? "pause" : "continue";
|
|
39
|
+
const now = new Date().toISOString();
|
|
40
|
+
const link = {
|
|
41
|
+
schemaVersion: 1,
|
|
42
|
+
id,
|
|
43
|
+
enabled: params.enabled !== false,
|
|
44
|
+
fromPipelineId,
|
|
45
|
+
toPipelineId,
|
|
46
|
+
trigger: "on_success",
|
|
47
|
+
dispatchPolicy: "fifo",
|
|
48
|
+
inputContract: contract,
|
|
49
|
+
onJobFailed,
|
|
50
|
+
maxPendingJobs,
|
|
51
|
+
createdAt: now,
|
|
52
|
+
updatedAt: now,
|
|
53
|
+
};
|
|
54
|
+
const result = await ctx.app.dispatch.createLink(link);
|
|
55
|
+
if (!result.ok) {
|
|
56
|
+
return { ok: false, error: result.error };
|
|
57
|
+
}
|
|
58
|
+
return { ok: true, payload: { ok: true, link: result.link } };
|
|
59
|
+
});
|
|
60
|
+
// pipeline.link.update
|
|
61
|
+
registry.register("pipeline.link.update", async (params, ctx) => {
|
|
62
|
+
const linkId = typeof params.linkId === "string" ? params.linkId : "";
|
|
63
|
+
if (!linkId)
|
|
64
|
+
return { ok: false, error: "pipeline_link_id_required" };
|
|
65
|
+
const patch = {};
|
|
66
|
+
if (typeof params.enabled === "boolean")
|
|
67
|
+
patch.enabled = params.enabled;
|
|
68
|
+
if (params.inputContract !== undefined) {
|
|
69
|
+
patch.inputContract = params.inputContract && typeof params.inputContract === "object"
|
|
70
|
+
? {
|
|
71
|
+
requireType: typeof params.inputContract.requireType === "string"
|
|
72
|
+
? params.inputContract.requireType : undefined,
|
|
73
|
+
requireSchemaVersion: typeof params.inputContract.requireSchemaVersion === "number"
|
|
74
|
+
? params.inputContract.requireSchemaVersion : undefined,
|
|
75
|
+
} : null;
|
|
76
|
+
}
|
|
77
|
+
if (params.onJobFailed === "continue" || params.onJobFailed === "pause")
|
|
78
|
+
patch.onJobFailed = params.onJobFailed;
|
|
79
|
+
if (typeof params.maxPendingJobs === "number" && Number.isFinite(params.maxPendingJobs)) {
|
|
80
|
+
patch.maxPendingJobs = Math.min(10000, Math.max(1, Math.trunc(params.maxPendingJobs)));
|
|
81
|
+
}
|
|
82
|
+
const result = await ctx.app.dispatch.updateLink(linkId, patch);
|
|
83
|
+
if (!result.ok) {
|
|
84
|
+
return { ok: false, error: result.error };
|
|
85
|
+
}
|
|
86
|
+
return { ok: true, payload: { ok: true, link: result.link } };
|
|
87
|
+
});
|
|
88
|
+
// pipeline.link.delete
|
|
89
|
+
registry.register("pipeline.link.delete", async (params, ctx) => {
|
|
90
|
+
const linkId = typeof params.linkId === "string" ? params.linkId : "";
|
|
91
|
+
if (!linkId)
|
|
92
|
+
return { ok: false, error: "pipeline_link_id_required" };
|
|
93
|
+
const result = await ctx.app.dispatch.deleteLink(linkId);
|
|
94
|
+
if (!result.ok) {
|
|
95
|
+
return { ok: false, error: result.error };
|
|
96
|
+
}
|
|
97
|
+
return { ok: true, payload: { ok: true } };
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
exports.registerPipelineLinksWsMethods = registerPipelineLinksWsMethods;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerPipelineQueueWsMethods = void 0;
|
|
4
|
+
const registerPipelineQueueWsMethods = (registry) => {
|
|
5
|
+
// pipeline.queue.list
|
|
6
|
+
registry.register("pipeline.queue.list", (params, ctx) => {
|
|
7
|
+
const pipelineId = typeof params.pipelineId === "string" ? params.pipelineId : "";
|
|
8
|
+
if (!ctx.app.getPipelineDefinition(pipelineId)) {
|
|
9
|
+
return { ok: false, error: "pipeline_not_found" };
|
|
10
|
+
}
|
|
11
|
+
const items = ctx.app.dispatch.getQueue(pipelineId);
|
|
12
|
+
return { ok: true, payload: { ok: true, pipelineId, items } };
|
|
13
|
+
});
|
|
14
|
+
// pipeline.queue.retry
|
|
15
|
+
registry.register("pipeline.queue.retry", async (params, ctx) => {
|
|
16
|
+
const pipelineId = typeof params.pipelineId === "string" ? params.pipelineId : "";
|
|
17
|
+
const jobId = typeof params.jobId === "string" ? params.jobId : "";
|
|
18
|
+
if (!ctx.app.getPipelineDefinition(pipelineId)) {
|
|
19
|
+
return { ok: false, error: "pipeline_not_found" };
|
|
20
|
+
}
|
|
21
|
+
const result = await ctx.app.dispatch.retryJob(jobId);
|
|
22
|
+
if (!result.ok) {
|
|
23
|
+
return { ok: false, error: result.error };
|
|
24
|
+
}
|
|
25
|
+
return { ok: true, payload: { ok: true, job: result.job } };
|
|
26
|
+
});
|
|
27
|
+
// pipeline.queue.cancel
|
|
28
|
+
registry.register("pipeline.queue.cancel", async (params, ctx) => {
|
|
29
|
+
const pipelineId = typeof params.pipelineId === "string" ? params.pipelineId : "";
|
|
30
|
+
const jobId = typeof params.jobId === "string" ? params.jobId : "";
|
|
31
|
+
const reason = typeof params.reason === "string" && params.reason.trim() ? params.reason.trim() : "canceled_by_user";
|
|
32
|
+
if (!ctx.app.getPipelineDefinition(pipelineId)) {
|
|
33
|
+
return { ok: false, error: "pipeline_not_found" };
|
|
34
|
+
}
|
|
35
|
+
const result = await ctx.app.dispatch.cancelJob(jobId, reason);
|
|
36
|
+
if (!result.ok) {
|
|
37
|
+
return { ok: false, error: result.error };
|
|
38
|
+
}
|
|
39
|
+
return { ok: true, payload: { ok: true } };
|
|
40
|
+
});
|
|
41
|
+
// pipeline.queue.drain
|
|
42
|
+
registry.register("pipeline.queue.drain", (params, ctx) => {
|
|
43
|
+
const pipelineId = typeof params.pipelineId === "string" ? params.pipelineId : "";
|
|
44
|
+
if (!ctx.app.getPipelineDefinition(pipelineId)) {
|
|
45
|
+
return { ok: false, error: "pipeline_not_found" };
|
|
46
|
+
}
|
|
47
|
+
ctx.app.dispatch.drainQueue(pipelineId);
|
|
48
|
+
return { ok: true, payload: { ok: true, pipelineId } };
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
exports.registerPipelineQueueWsMethods = registerPipelineQueueWsMethods;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerPipelineRuntimeWsMethods = void 0;
|
|
4
|
+
const index_1 = require("../../pipeline/diagnostics/index");
|
|
5
|
+
const utils_1 = require("./utils");
|
|
6
|
+
const registerPipelineRuntimeWsMethods = (registry) => {
|
|
7
|
+
// pipeline.current
|
|
8
|
+
registry.register("pipeline.current", (params, ctx) => {
|
|
9
|
+
const pipelineId = typeof params.pipelineId === "string" ? params.pipelineId : "";
|
|
10
|
+
const runtime = ctx.app.getPipelineRuntime(pipelineId);
|
|
11
|
+
const definition = ctx.app.getPipelineDefinition(pipelineId);
|
|
12
|
+
if (!runtime || !definition) {
|
|
13
|
+
return { ok: false, error: "pipeline_not_found" };
|
|
14
|
+
}
|
|
15
|
+
const run = runtime.runtime.getRun();
|
|
16
|
+
const workflow = runtime.workflow.getWorkflow();
|
|
17
|
+
const nodes = workflow?.nodes && workflow.nodes.length > 0
|
|
18
|
+
? run.nodes.map((node) => {
|
|
19
|
+
const matched = workflow.nodes.find((wNode) => wNode.id === node.id);
|
|
20
|
+
return { ...node, isMainline: matched?.isMainline ?? true, lane: matched?.lane ?? "main", parallelGroupId: matched?.parallelGroupId ?? null };
|
|
21
|
+
})
|
|
22
|
+
: run.nodes;
|
|
23
|
+
return {
|
|
24
|
+
ok: true,
|
|
25
|
+
payload: { run: { ...run, nodes }, runId: run.id, nodes, scheduler: runtime.pipeline.getSchedulerState(), pipelineId },
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
// pipeline.status
|
|
29
|
+
registry.register("pipeline.status", (params, ctx) => {
|
|
30
|
+
const pipelineId = typeof params.pipelineId === "string" ? params.pipelineId : "";
|
|
31
|
+
const runtime = ctx.app.getPipelineRuntime(pipelineId);
|
|
32
|
+
if (!runtime) {
|
|
33
|
+
return { ok: false, error: "pipeline_not_found" };
|
|
34
|
+
}
|
|
35
|
+
const target = (typeof params.runId === "string" || typeof params.batchRunId === "string")
|
|
36
|
+
? { runId: typeof params.runId === "string" ? params.runId : undefined, batchRunId: typeof params.batchRunId === "string" ? params.batchRunId : undefined }
|
|
37
|
+
: undefined;
|
|
38
|
+
const result = ctx.services.pipelineService.getPipelineExecutionStatus(pipelineId, target);
|
|
39
|
+
return { ok: true, payload: result };
|
|
40
|
+
});
|
|
41
|
+
// pipeline.run
|
|
42
|
+
registry.register("pipeline.run", async (params, ctx) => {
|
|
43
|
+
const pipelineId = typeof params.pipelineId === "string" ? params.pipelineId : "";
|
|
44
|
+
const runtime = ctx.app.getPipelineRuntime(pipelineId);
|
|
45
|
+
if (!runtime) {
|
|
46
|
+
return { ok: false, error: "pipeline_not_found" };
|
|
47
|
+
}
|
|
48
|
+
const started = await ctx.services.pipelineService.startPipeline(pipelineId);
|
|
49
|
+
if (started.ok === false) {
|
|
50
|
+
return { ok: false, error: started.error, payload: { ...started } };
|
|
51
|
+
}
|
|
52
|
+
return { ok: true, payload: started };
|
|
53
|
+
});
|
|
54
|
+
// pipeline.stop
|
|
55
|
+
registry.register("pipeline.stop", async (params, ctx) => {
|
|
56
|
+
const pipelineId = typeof params.pipelineId === "string" ? params.pipelineId : "";
|
|
57
|
+
const runtime = ctx.app.getPipelineRuntime(pipelineId);
|
|
58
|
+
if (!runtime) {
|
|
59
|
+
return { ok: false, error: "pipeline_not_found" };
|
|
60
|
+
}
|
|
61
|
+
const target = (0, utils_1.mergeIdentityTargets)((0, utils_1.readIdentityTargetFromBody)(params), { runId: typeof params.runId === "string" ? params.runId : undefined, batchRunId: typeof params.batchRunId === "string" ? params.batchRunId : undefined });
|
|
62
|
+
const stopped = ctx.services.pipelineService.stopPipeline(pipelineId, target);
|
|
63
|
+
if (stopped.ok === false) {
|
|
64
|
+
return { ok: false, error: stopped.error, payload: { ...stopped } };
|
|
65
|
+
}
|
|
66
|
+
return { ok: true, payload: stopped };
|
|
67
|
+
});
|
|
68
|
+
// pipeline.executorBindings
|
|
69
|
+
registry.register("pipeline.executorBindings", (params, ctx) => {
|
|
70
|
+
const pipelineId = typeof params.pipelineId === "string" ? params.pipelineId : "";
|
|
71
|
+
const runtime = ctx.app.getPipelineRuntime(pipelineId);
|
|
72
|
+
if (!runtime) {
|
|
73
|
+
return { ok: false, error: "pipeline_not_found" };
|
|
74
|
+
}
|
|
75
|
+
const executorSessionByAgentId = runtime.gateway.getExecutorSessionByAgentId();
|
|
76
|
+
const sessionCache = runtime.gateway.getSessionCache();
|
|
77
|
+
return {
|
|
78
|
+
ok: true,
|
|
79
|
+
payload: {
|
|
80
|
+
bindings: Object.fromEntries(executorSessionByAgentId.entries()),
|
|
81
|
+
sessions: sessionCache.map((s) => ({ id: s.id, title: s.title })),
|
|
82
|
+
pipelineId,
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
// pipeline.node.retry
|
|
87
|
+
registry.register("pipeline.node.retry", async (params, ctx) => {
|
|
88
|
+
const pipelineId = typeof params.pipelineId === "string" ? params.pipelineId : "";
|
|
89
|
+
const nodeId = typeof params.nodeId === "string" ? params.nodeId : "";
|
|
90
|
+
const itemKey = typeof params.itemKey === "string" && params.itemKey.trim() ? params.itemKey.trim() : undefined;
|
|
91
|
+
const runtime = ctx.app.getPipelineRuntime(pipelineId);
|
|
92
|
+
if (!runtime) {
|
|
93
|
+
return { ok: false, error: "pipeline_not_found" };
|
|
94
|
+
}
|
|
95
|
+
if (!nodeId) {
|
|
96
|
+
return { ok: false, error: "node_id_required" };
|
|
97
|
+
}
|
|
98
|
+
const result = await ctx.services.pipelineService.retryNode({ pipelineId, nodeId, itemKey });
|
|
99
|
+
if (!result.ok) {
|
|
100
|
+
return { ok: false, error: result.error ?? "retry_failed", payload: result };
|
|
101
|
+
}
|
|
102
|
+
return { ok: true, payload: result };
|
|
103
|
+
});
|
|
104
|
+
// pipeline.node.diagnostics
|
|
105
|
+
registry.register("pipeline.node.diagnostics", (params, ctx) => {
|
|
106
|
+
const pipelineId = typeof params.pipelineId === "string" ? params.pipelineId : "";
|
|
107
|
+
const nodeId = typeof params.nodeId === "string" ? params.nodeId : "";
|
|
108
|
+
const itemKey = typeof params.itemKey === "string" && params.itemKey.trim() ? params.itemKey.trim() : undefined;
|
|
109
|
+
const runtime = ctx.app.getPipelineRuntime(pipelineId);
|
|
110
|
+
if (!runtime) {
|
|
111
|
+
return { ok: false, error: "pipeline_not_found" };
|
|
112
|
+
}
|
|
113
|
+
if (!nodeId) {
|
|
114
|
+
return { ok: false, error: "node_id_required" };
|
|
115
|
+
}
|
|
116
|
+
const workflowNode = runtime.workflow.getWorkflowNodeById(nodeId);
|
|
117
|
+
if (!workflowNode) {
|
|
118
|
+
return { ok: false, error: "node_not_found" };
|
|
119
|
+
}
|
|
120
|
+
const diagnostics = (0, index_1.diagnoseNodeDependency)(runtime.runtime.getRun(), runtime.workflow, nodeId, itemKey);
|
|
121
|
+
return { ok: true, payload: { nodeId, itemKey: itemKey ?? null, diagnostics } };
|
|
122
|
+
});
|
|
123
|
+
// pipeline.items
|
|
124
|
+
registry.register("pipeline.items", (params, ctx) => {
|
|
125
|
+
const pipelineId = typeof params.pipelineId === "string" ? params.pipelineId : "";
|
|
126
|
+
const runtime = ctx.app.getPipelineRuntime(pipelineId);
|
|
127
|
+
if (!runtime) {
|
|
128
|
+
return { ok: false, error: "pipeline_not_found" };
|
|
129
|
+
}
|
|
130
|
+
return { ok: true, payload: { items: runtime.pipeline.getItemRuns(), pipelineId } };
|
|
131
|
+
});
|
|
132
|
+
// pipeline.output.list
|
|
133
|
+
registry.register("pipeline.output.list", async (params, ctx) => {
|
|
134
|
+
const pipelineId = typeof params.pipelineId === "string" ? params.pipelineId : "";
|
|
135
|
+
const runtime = ctx.app.getPipelineRuntime(pipelineId);
|
|
136
|
+
if (!runtime) {
|
|
137
|
+
return { ok: false, error: "pipeline_not_found" };
|
|
138
|
+
}
|
|
139
|
+
const runId = typeof params.runId === "string" && params.runId.trim() ? params.runId.trim() : undefined;
|
|
140
|
+
const batchRunId = typeof params.batchRunId === "string" && params.batchRunId.trim() ? params.batchRunId.trim() : undefined;
|
|
141
|
+
const outputs = await runtime.output.list();
|
|
142
|
+
let filtered = outputs;
|
|
143
|
+
if (runId)
|
|
144
|
+
filtered = filtered.filter((o) => o.runId === runId);
|
|
145
|
+
if (batchRunId)
|
|
146
|
+
filtered = filtered.filter((o) => o.batchRunId === batchRunId);
|
|
147
|
+
filtered.sort((a, b) => b.producedAt.localeCompare(a.producedAt));
|
|
148
|
+
return { ok: true, payload: { ok: true, pipelineId, items: filtered } };
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
exports.registerPipelineRuntimeWsMethods = registerPipelineRuntimeWsMethods;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerPipelineSchedulerWsMethods = void 0;
|
|
4
|
+
const registerPipelineSchedulerWsMethods = (registry) => {
|
|
5
|
+
// pipeline.scheduler.toggle
|
|
6
|
+
registry.register("pipeline.scheduler.toggle", async (params, ctx) => {
|
|
7
|
+
const pipelineId = typeof params.pipelineId === "string" ? params.pipelineId : "";
|
|
8
|
+
const runtime = ctx.app.getPipelineRuntime(pipelineId);
|
|
9
|
+
if (!runtime)
|
|
10
|
+
return { ok: false, error: "pipeline_not_found" };
|
|
11
|
+
const enabled = params.enabled !== false;
|
|
12
|
+
const toggled = ctx.services.schedulerService.toggleScheduler(pipelineId, enabled);
|
|
13
|
+
if (!toggled.ok) {
|
|
14
|
+
return { ok: false, error: toggled.error };
|
|
15
|
+
}
|
|
16
|
+
runtime.runtime.pushTimeline(`[${pipelineId}] Scheduler ${toggled.scheduler.enabled ? "enabled" : "disabled"}`);
|
|
17
|
+
return { ok: true, payload: toggled };
|
|
18
|
+
});
|
|
19
|
+
// pipeline.scheduler.mode
|
|
20
|
+
registry.register("pipeline.scheduler.mode", async (params, ctx) => {
|
|
21
|
+
const pipelineId = typeof params.pipelineId === "string" ? params.pipelineId : "";
|
|
22
|
+
const runtime = ctx.app.getPipelineRuntime(pipelineId);
|
|
23
|
+
if (!runtime)
|
|
24
|
+
return { ok: false, error: "pipeline_not_found" };
|
|
25
|
+
const mode = params.mode === "manual" ? "manual" : "auto";
|
|
26
|
+
const updated = ctx.services.schedulerService.setSchedulerMode(pipelineId, mode);
|
|
27
|
+
if (!updated.ok) {
|
|
28
|
+
return { ok: false, error: updated.error };
|
|
29
|
+
}
|
|
30
|
+
runtime.runtime.pushTimeline(`[${pipelineId}] Scheduler mode switched to: ${updated.scheduler.mode}`);
|
|
31
|
+
return { ok: true, payload: updated };
|
|
32
|
+
});
|
|
33
|
+
// pipeline.tick
|
|
34
|
+
registry.register("pipeline.tick", async (params, ctx) => {
|
|
35
|
+
const pipelineId = typeof params.pipelineId === "string" ? params.pipelineId : "";
|
|
36
|
+
const runtime = ctx.app.getPipelineRuntime(pipelineId);
|
|
37
|
+
if (!runtime)
|
|
38
|
+
return { ok: false, error: "pipeline_not_found" };
|
|
39
|
+
const workflow = runtime.workflow.getWorkflow();
|
|
40
|
+
if (!workflow || !workflow.plugins.scheduler.enabled) {
|
|
41
|
+
return { ok: false, error: "pipeline_plugin_disabled" };
|
|
42
|
+
}
|
|
43
|
+
const drained = await runtime.pipeline.drainPipeline("manual_tick");
|
|
44
|
+
const run = runtime.runtime.getRun();
|
|
45
|
+
return { ok: true, payload: { ok: true, run, drained, pipelineId } };
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
exports.registerPipelineSchedulerWsMethods = registerPipelineSchedulerWsMethods;
|