veryfront 0.1.623 → 0.1.625
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 +3 -3
- package/esm/cli/commands/knowledge/command-help.d.ts.map +1 -1
- package/esm/cli/commands/knowledge/command-help.js +2 -3
- package/esm/cli/commands/knowledge/command.d.ts +2 -47
- package/esm/cli/commands/knowledge/command.d.ts.map +1 -1
- package/esm/cli/commands/knowledge/command.js +22 -124
- package/esm/cli/commands/knowledge/parser.d.ts +40 -0
- package/esm/cli/commands/knowledge/parser.d.ts.map +1 -0
- package/esm/cli/commands/knowledge/parser.js +353 -0
- package/esm/cli/commands/knowledge/result.d.ts +3 -3
- package/esm/cli/commands/knowledge/result.js +1 -1
- package/esm/cli/commands/styles/command.js +2 -2
- package/esm/cli/commands/task/command.js +4 -4
- package/esm/cli/commands/worker/command-help.js +4 -4
- package/esm/cli/commands/worker/command.d.ts +1 -1
- package/esm/cli/commands/worker/command.js +9 -9
- package/esm/cli/commands/workflow/command.js +4 -4
- package/esm/cli/utils/sanitize-run-output.d.ts +2 -0
- package/esm/cli/utils/sanitize-run-output.d.ts.map +1 -0
- package/esm/cli/utils/{sanitize-job-output.js → sanitize-run-output.js} +1 -1
- package/esm/cli/utils/write-run-result.d.ts +2 -0
- package/esm/cli/utils/write-run-result.d.ts.map +1 -0
- package/esm/cli/utils/write-run-result.js +16 -0
- package/esm/deno.d.ts +4 -3
- package/esm/deno.js +6 -5
- package/esm/src/build/production-build/static-generation.d.ts.map +1 -1
- package/esm/src/build/production-build/static-generation.js +85 -0
- package/esm/src/html/hydration-script-builder/templates/renderer.d.ts.map +1 -1
- package/esm/src/html/hydration-script-builder/templates/renderer.js +37 -4
- package/esm/src/integrations/_data.js +1 -1
- package/esm/src/integrations/schema.d.ts +8 -0
- package/esm/src/integrations/schema.d.ts.map +1 -1
- package/esm/src/integrations/schema.js +3 -0
- package/esm/src/internal-agents/run-stream.d.ts.map +1 -1
- package/esm/src/internal-agents/run-stream.js +20 -3
- package/esm/src/platform/adapters/veryfront-api-client/operations.d.ts +2 -2
- package/esm/src/platform/adapters/veryfront-api-client/operations.d.ts.map +1 -1
- package/esm/src/platform/adapters/veryfront-api-client/operations.js +2 -2
- package/esm/src/platform/adapters/veryfront-api-client/schemas/api.schema.d.ts +1 -1
- package/esm/src/platform/adapters/veryfront-api-client/schemas/api.schema.js +1 -1
- package/esm/src/react/components/chat/chat/components/attachment-pill.js +1 -1
- package/esm/src/react/components/chat/chat/composition/chat-composer.d.ts +1 -0
- package/esm/src/react/components/chat/chat/composition/chat-composer.d.ts.map +1 -1
- package/esm/src/react/components/chat/chat/composition/chat-composer.js +27 -11
- package/esm/src/react/components/chat/chat/index.d.ts +1 -0
- package/esm/src/react/components/chat/chat/index.d.ts.map +1 -1
- package/esm/src/react/components/chat/chat/index.js +2 -2
- package/esm/src/react/components/chat/theme.js +1 -1
- package/esm/src/rendering/layouts/utils/applicator.d.ts.map +1 -1
- package/esm/src/rendering/layouts/utils/applicator.js +1 -1
- package/esm/src/rendering/layouts/utils/component-loader.d.ts +8 -0
- package/esm/src/rendering/layouts/utils/component-loader.d.ts.map +1 -1
- package/esm/src/rendering/layouts/utils/component-loader.js +19 -0
- package/esm/src/rendering/rsc/client-boot.ts +23 -6
- package/esm/src/runs/index.d.ts +27 -0
- package/esm/src/runs/index.d.ts.map +1 -0
- package/esm/src/runs/index.js +26 -0
- package/esm/src/runs/runs-client.d.ts +95 -0
- package/esm/src/runs/runs-client.d.ts.map +1 -0
- package/esm/src/runs/runs-client.js +181 -0
- package/esm/src/{jobs → runs}/runtime-env.d.ts.map +1 -1
- package/esm/src/{jobs → runs}/runtime-env.js +2 -2
- package/esm/src/runs/schemas.d.ts +236 -0
- package/esm/src/runs/schemas.d.ts.map +1 -0
- package/esm/src/runs/schemas.js +61 -0
- package/esm/src/security/deno-permissions.d.ts +2 -2
- package/esm/src/security/deno-permissions.js +2 -2
- package/esm/src/security/index.d.ts +1 -1
- package/esm/src/security/index.js +1 -1
- package/esm/src/server/build-app-route-renderer.d.ts +2 -0
- package/esm/src/server/build-app-route-renderer.d.ts.map +1 -1
- package/esm/src/server/build-app-route-renderer.js +51 -28
- package/esm/src/server/handlers/dev/framework-candidates.generated.d.ts.map +1 -1
- package/esm/src/server/handlers/dev/framework-candidates.generated.js +54 -8
- package/esm/src/server/services/rsc/endpoints/rsc-bundles.generated.d.ts.map +1 -1
- package/esm/src/server/services/rsc/endpoints/rsc-bundles.generated.js +1 -1
- package/esm/src/server/services/static/static-file.service.d.ts.map +1 -1
- package/esm/src/server/services/static/static-file.service.js +9 -4
- package/esm/src/skill/index.d.ts +1 -1
- package/esm/src/skill/index.d.ts.map +1 -1
- package/esm/src/skill/index.js +1 -1
- package/esm/src/skill/prompt-augmentation.js +2 -2
- package/esm/src/skill/tools.d.ts +1 -1
- package/esm/src/skill/tools.d.ts.map +1 -1
- package/esm/src/skill/tools.js +11 -9
- package/esm/src/skill/types.d.ts +1 -0
- package/esm/src/skill/types.d.ts.map +1 -1
- package/esm/src/skill/types.js +1 -0
- package/esm/src/task/runner.js +1 -1
- package/esm/src/task/types.d.ts +4 -4
- package/esm/src/task/types.d.ts.map +1 -1
- package/esm/src/task/types.js +1 -1
- package/esm/src/tool/factory.d.ts.map +1 -1
- package/esm/src/tool/factory.js +10 -0
- package/esm/src/tool/types.d.ts +5 -4
- package/esm/src/tool/types.d.ts.map +1 -1
- package/esm/src/utils/index.d.ts +1 -1
- package/esm/src/utils/index.js +1 -1
- package/esm/src/utils/logger/index.d.ts +1 -1
- package/esm/src/utils/logger/index.js +1 -1
- package/esm/src/utils/logger/logger.d.ts +6 -6
- package/esm/src/utils/logger/logger.d.ts.map +1 -1
- package/esm/src/utils/logger/logger.js +10 -10
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/esm/src/workflow/executor/workflow-executor.js +3 -3
- package/esm/src/workflow/worker/{dynamic-job-entrypoint.d.ts → dynamic-run-entrypoint.d.ts} +2 -2
- package/esm/src/workflow/worker/{dynamic-job-entrypoint.d.ts.map → dynamic-run-entrypoint.d.ts.map} +1 -1
- package/esm/src/workflow/worker/{dynamic-job-entrypoint.js → dynamic-run-entrypoint.js} +1 -1
- package/esm/src/workflow/worker/executors/index.d.ts +8 -8
- package/esm/src/workflow/worker/executors/index.d.ts.map +1 -1
- package/esm/src/workflow/worker/executors/index.js +5 -5
- package/esm/src/workflow/worker/executors/k8s.d.ts +34 -34
- package/esm/src/workflow/worker/executors/k8s.d.ts.map +1 -1
- package/esm/src/workflow/worker/executors/k8s.js +59 -58
- package/esm/src/workflow/worker/executors/process.d.ts +15 -15
- package/esm/src/workflow/worker/executors/process.d.ts.map +1 -1
- package/esm/src/workflow/worker/executors/process.js +86 -86
- package/esm/src/workflow/worker/executors/types.d.ts +38 -39
- package/esm/src/workflow/worker/executors/types.d.ts.map +1 -1
- package/esm/src/workflow/worker/executors/types.js +9 -10
- package/esm/src/workflow/worker/index.d.ts +7 -7
- package/esm/src/workflow/worker/index.d.ts.map +1 -1
- package/esm/src/workflow/worker/index.js +9 -9
- package/esm/src/workflow/worker/{job-entrypoint.d.ts → run-entrypoint.d.ts} +3 -3
- package/esm/src/workflow/worker/{job-entrypoint.d.ts.map → run-entrypoint.d.ts.map} +1 -1
- package/esm/src/workflow/worker/{job-entrypoint.js → run-entrypoint.js} +2 -2
- package/esm/src/workflow/worker/{job-manager.d.ts → run-manager.d.ts} +32 -32
- package/esm/src/workflow/worker/run-manager.d.ts.map +1 -0
- package/esm/src/workflow/worker/{job-manager.js → run-manager.js} +63 -63
- package/esm/src/workflow/worker/shared.js +1 -1
- package/package.json +4 -4
- package/esm/cli/commands/knowledge/parser-source.d.ts +0 -2
- package/esm/cli/commands/knowledge/parser-source.d.ts.map +0 -1
- package/esm/cli/commands/knowledge/parser-source.js +0 -641
- package/esm/cli/utils/sanitize-job-output.d.ts +0 -2
- package/esm/cli/utils/sanitize-job-output.d.ts.map +0 -1
- package/esm/cli/utils/write-job-result.d.ts +0 -2
- package/esm/cli/utils/write-job-result.d.ts.map +0 -1
- package/esm/cli/utils/write-job-result.js +0 -16
- package/esm/src/jobs/index.d.ts +0 -25
- package/esm/src/jobs/index.d.ts.map +0 -1
- package/esm/src/jobs/index.js +0 -24
- package/esm/src/jobs/jobs-client.d.ts +0 -182
- package/esm/src/jobs/jobs-client.d.ts.map +0 -1
- package/esm/src/jobs/jobs-client.js +0 -255
- package/esm/src/jobs/schemas.d.ts +0 -1146
- package/esm/src/jobs/schemas.d.ts.map +0 -1
- package/esm/src/jobs/schemas.js +0 -294
- package/esm/src/workflow/worker/job-manager.d.ts.map +0 -1
- /package/esm/src/{jobs → runs}/runtime-env.d.ts +0 -0
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { type WorkflowBackend } from "../backends/types.js";
|
|
2
|
-
import type {
|
|
3
|
-
export type {
|
|
2
|
+
import type { RunExecutionStatus, RunExecutor } from "./executors/types.js";
|
|
3
|
+
export type { RunExecutionInfo, RunExecutionStatus, RunExecutor } from "./executors/types.js";
|
|
4
4
|
/**
|
|
5
|
-
* Configuration for the workflow run manager backed by
|
|
5
|
+
* Configuration for the workflow run manager backed by run executors.
|
|
6
6
|
*/
|
|
7
7
|
export interface WorkflowRunManagerConfig {
|
|
8
8
|
/** Backend for workflow persistence */
|
|
9
9
|
backend: WorkflowBackend;
|
|
10
|
-
/**
|
|
11
|
-
executor:
|
|
12
|
-
/** Environment variables to inject into
|
|
10
|
+
/** Run executor (Kubernetes, Docker, Process, etc.) */
|
|
11
|
+
executor: RunExecutor;
|
|
12
|
+
/** Environment variables to inject into run executions */
|
|
13
13
|
env?: Record<string, string>;
|
|
14
14
|
/** Poll interval for checking pending workflows (ms) */
|
|
15
15
|
pollInterval?: number;
|
|
16
|
-
/** Maximum concurrent
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
|
|
16
|
+
/** Maximum concurrent run executions */
|
|
17
|
+
maxConcurrentExecutions?: number;
|
|
18
|
+
/** Run timeout (ms) - kills execution if it exceeds this */
|
|
19
|
+
executionTimeout?: number;
|
|
20
20
|
/** Time after which a run is considered stalled (ms) - for crash recovery */
|
|
21
21
|
stalledThreshold?: number;
|
|
22
22
|
/** Enable debug logging */
|
|
@@ -34,32 +34,32 @@ export interface ManagerStats {
|
|
|
34
34
|
managerId: string;
|
|
35
35
|
startedAt?: Date;
|
|
36
36
|
pollCount: number;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
executionsCreated: number;
|
|
38
|
+
executionsCompleted: number;
|
|
39
|
+
executionsFailed: number;
|
|
40
|
+
activeExecutions: number;
|
|
41
41
|
lastPollAt?: Date;
|
|
42
42
|
lastErrorAt?: Date;
|
|
43
43
|
lastError?: string;
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
|
-
* Internal
|
|
46
|
+
* Internal run execution tracking
|
|
47
47
|
*/
|
|
48
|
-
interface
|
|
49
|
-
|
|
48
|
+
interface TrackedExecution {
|
|
49
|
+
executionId: string;
|
|
50
50
|
runId: string;
|
|
51
|
-
status:
|
|
51
|
+
status: RunExecutionStatus;
|
|
52
52
|
createdAt: Date;
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
55
|
* Workflow run manager
|
|
56
56
|
*
|
|
57
|
-
* Orchestrates workflow execution via pluggable
|
|
57
|
+
* Orchestrates workflow execution via pluggable run executors.
|
|
58
58
|
* Each workflow runs in complete isolation.
|
|
59
59
|
*
|
|
60
60
|
* @example K8s
|
|
61
61
|
* ```typescript
|
|
62
|
-
* const executor = new
|
|
62
|
+
* const executor = new K8sRunExecutor({
|
|
63
63
|
* image: "my-app:latest",
|
|
64
64
|
* namespace: "workflows",
|
|
65
65
|
* }, k8sClient);
|
|
@@ -74,8 +74,8 @@ interface TrackedJob {
|
|
|
74
74
|
*
|
|
75
75
|
* @example Local Process
|
|
76
76
|
* ```typescript
|
|
77
|
-
* const executor = new
|
|
78
|
-
* entrypointPath: "./
|
|
77
|
+
* const executor = new ProcessRunExecutor({
|
|
78
|
+
* entrypointPath: "./workflow-run.ts",
|
|
79
79
|
* });
|
|
80
80
|
*
|
|
81
81
|
* const manager = new WorkflowRunManager({
|
|
@@ -90,7 +90,7 @@ export declare class WorkflowRunManager {
|
|
|
90
90
|
private config;
|
|
91
91
|
private status;
|
|
92
92
|
private pollTimeout?;
|
|
93
|
-
private
|
|
93
|
+
private activeExecutions;
|
|
94
94
|
private stats;
|
|
95
95
|
private managerId;
|
|
96
96
|
constructor(config: WorkflowRunManagerConfig);
|
|
@@ -107,9 +107,9 @@ export declare class WorkflowRunManager {
|
|
|
107
107
|
*/
|
|
108
108
|
getStats(): ManagerStats;
|
|
109
109
|
/**
|
|
110
|
-
* Get active
|
|
110
|
+
* Get active executions
|
|
111
111
|
*/
|
|
112
|
-
|
|
112
|
+
getActiveExecutions(): TrackedExecution[];
|
|
113
113
|
/**
|
|
114
114
|
* Get manager ID
|
|
115
115
|
*/
|
|
@@ -119,24 +119,24 @@ export declare class WorkflowRunManager {
|
|
|
119
119
|
*/
|
|
120
120
|
private scheduleNextPoll;
|
|
121
121
|
/**
|
|
122
|
-
* Poll for pending workflows and manage
|
|
122
|
+
* Poll for pending workflows and manage run executions
|
|
123
123
|
*/
|
|
124
124
|
private poll;
|
|
125
125
|
/**
|
|
126
|
-
* Sync
|
|
126
|
+
* Sync run execution statuses with executor
|
|
127
127
|
*/
|
|
128
|
-
private
|
|
128
|
+
private syncRunExecutionStatuses;
|
|
129
129
|
/**
|
|
130
|
-
* Create
|
|
130
|
+
* Create an isolated execution for a workflow run
|
|
131
131
|
*/
|
|
132
|
-
private
|
|
132
|
+
private createExecutionForWorkflow;
|
|
133
133
|
/**
|
|
134
134
|
* Record an error in stats
|
|
135
135
|
*/
|
|
136
136
|
private recordError;
|
|
137
137
|
}
|
|
138
138
|
/**
|
|
139
|
-
* Create a workflow run manager backed by
|
|
139
|
+
* Create a workflow run manager backed by run executors.
|
|
140
140
|
*/
|
|
141
141
|
export declare function createWorkflowRunManager(config: WorkflowRunManagerConfig): WorkflowRunManager;
|
|
142
|
-
//# sourceMappingURL=
|
|
142
|
+
//# sourceMappingURL=run-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-manager.d.ts","sourceRoot":"","sources":["../../../../src/src/workflow/worker/run-manager.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG9F,OAAO,KAAK,EAAsB,kBAAkB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAehG,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE9F;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,uCAAuC;IACvC,OAAO,EAAE,eAAe,CAAC;IAEzB,uDAAuD;IACvD,QAAQ,EAAE,WAAW,CAAC;IAEtB,0DAA0D;IAC1D,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE7B,wDAAwD;IACxD,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,wCAAwC;IACxC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IAEjC,4DAA4D;IAC5D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,6EAA6E;IAC7E,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAC;AAExE;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,aAAa,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,IAAI,CAAC;IAClB,WAAW,CAAC,EAAE,IAAI,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,UAAU,gBAAgB;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,kBAAkB,CAAC;IAC3B,SAAS,EAAE,IAAI,CAAC;CACjB;AAOD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,MAAM,CAAyB;IACvC,OAAO,CAAC,WAAW,CAAC,CAAwC;IAC5D,OAAO,CAAC,gBAAgB,CAAuC;IAC/D,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,SAAS,CAAS;gBAEd,MAAM,EAAE,wBAAwB;IAuB5C;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAsB5B;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA+B3B;;OAEG;IACH,QAAQ,IAAI,YAAY;IAIxB;;OAEG;IACH,mBAAmB,IAAI,gBAAgB,EAAE;IAIzC;;OAEG;IACH,YAAY,IAAI,MAAM;IAItB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAWxB;;OAEG;YACW,IAAI;IAyGlB;;OAEG;YACW,wBAAwB;IAuCtC;;OAEG;YACW,0BAA0B;IAoDxC;;OAEG;IACH,OAAO,CAAC,WAAW;CAIpB;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,wBAAwB,GAC/B,kBAAkB,CAEpB"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Workflow run manager
|
|
3
3
|
*
|
|
4
|
-
* Orchestrates workflow run execution via isolated
|
|
5
|
-
* Uses pluggable
|
|
4
|
+
* Orchestrates workflow run execution via isolated run executors.
|
|
5
|
+
* Uses pluggable RunExecutor interface for runtime flexibility.
|
|
6
6
|
*
|
|
7
7
|
* Supported runtimes:
|
|
8
|
-
* -
|
|
9
|
-
* -
|
|
10
|
-
* -
|
|
8
|
+
* - K8sRunExecutor: Kubernetes Job adapter (production)
|
|
9
|
+
* - ProcessRunExecutor: Child processes (local dev)
|
|
10
|
+
* - DockerRunExecutor: Docker containers (future)
|
|
11
11
|
*
|
|
12
12
|
* Key properties:
|
|
13
13
|
* - Each workflow runs in isolation (no shared state)
|
|
14
|
-
* - Supports crash recovery via stalled
|
|
15
|
-
* - Runtime-agnostic through
|
|
14
|
+
* - Supports crash recovery via stalled execution detection
|
|
15
|
+
* - Runtime-agnostic through RunExecutor abstraction
|
|
16
16
|
*/
|
|
17
17
|
import * as dntShim from "../../../_dnt.shims.js";
|
|
18
18
|
import { logger as baseLogger } from "../../utils/index.js";
|
|
@@ -22,19 +22,19 @@ import { ORCHESTRATION_ERROR } from "../../errors/index.js";
|
|
|
22
22
|
const logger = baseLogger.component("workflow-run-manager");
|
|
23
23
|
/** Default interval between poll cycles */
|
|
24
24
|
const DEFAULT_POLL_INTERVAL_MS = 5_000;
|
|
25
|
-
/** Default timeout for a single
|
|
26
|
-
const
|
|
25
|
+
/** Default timeout for a single run execution (30 minutes) */
|
|
26
|
+
const DEFAULT_EXECUTION_TIMEOUT_MS = 30 * 60 * 1_000;
|
|
27
27
|
/** Default threshold after which a run is considered stalled */
|
|
28
28
|
const DEFAULT_STALLED_THRESHOLD_MS = 60_000;
|
|
29
29
|
/**
|
|
30
30
|
* Workflow run manager
|
|
31
31
|
*
|
|
32
|
-
* Orchestrates workflow execution via pluggable
|
|
32
|
+
* Orchestrates workflow execution via pluggable run executors.
|
|
33
33
|
* Each workflow runs in complete isolation.
|
|
34
34
|
*
|
|
35
35
|
* @example K8s
|
|
36
36
|
* ```typescript
|
|
37
|
-
* const executor = new
|
|
37
|
+
* const executor = new K8sRunExecutor({
|
|
38
38
|
* image: "my-app:latest",
|
|
39
39
|
* namespace: "workflows",
|
|
40
40
|
* }, k8sClient);
|
|
@@ -49,8 +49,8 @@ const DEFAULT_STALLED_THRESHOLD_MS = 60_000;
|
|
|
49
49
|
*
|
|
50
50
|
* @example Local Process
|
|
51
51
|
* ```typescript
|
|
52
|
-
* const executor = new
|
|
53
|
-
* entrypointPath: "./
|
|
52
|
+
* const executor = new ProcessRunExecutor({
|
|
53
|
+
* entrypointPath: "./workflow-run.ts",
|
|
54
54
|
* });
|
|
55
55
|
*
|
|
56
56
|
* const manager = new WorkflowRunManager({
|
|
@@ -65,15 +65,15 @@ export class WorkflowRunManager {
|
|
|
65
65
|
config;
|
|
66
66
|
status = "idle";
|
|
67
67
|
pollTimeout;
|
|
68
|
-
|
|
68
|
+
activeExecutions = new Map();
|
|
69
69
|
stats;
|
|
70
70
|
managerId;
|
|
71
71
|
constructor(config) {
|
|
72
72
|
this.managerId = generateId("mgr");
|
|
73
73
|
this.config = {
|
|
74
74
|
pollInterval: DEFAULT_POLL_INTERVAL_MS,
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
maxConcurrentExecutions: 10,
|
|
76
|
+
executionTimeout: DEFAULT_EXECUTION_TIMEOUT_MS,
|
|
77
77
|
stalledThreshold: DEFAULT_STALLED_THRESHOLD_MS,
|
|
78
78
|
debug: false,
|
|
79
79
|
...config,
|
|
@@ -82,10 +82,10 @@ export class WorkflowRunManager {
|
|
|
82
82
|
status: "idle",
|
|
83
83
|
managerId: this.managerId,
|
|
84
84
|
pollCount: 0,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
executionsCreated: 0,
|
|
86
|
+
executionsCompleted: 0,
|
|
87
|
+
executionsFailed: 0,
|
|
88
|
+
activeExecutions: 0,
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
@@ -139,13 +139,13 @@ export class WorkflowRunManager {
|
|
|
139
139
|
* Get manager statistics
|
|
140
140
|
*/
|
|
141
141
|
getStats() {
|
|
142
|
-
return { ...this.stats,
|
|
142
|
+
return { ...this.stats, activeExecutions: this.activeExecutions.size };
|
|
143
143
|
}
|
|
144
144
|
/**
|
|
145
|
-
* Get active
|
|
145
|
+
* Get active executions
|
|
146
146
|
*/
|
|
147
|
-
|
|
148
|
-
return Array.from(this.
|
|
147
|
+
getActiveExecutions() {
|
|
148
|
+
return Array.from(this.activeExecutions.values());
|
|
149
149
|
}
|
|
150
150
|
/**
|
|
151
151
|
* Get manager ID
|
|
@@ -166,7 +166,7 @@ export class WorkflowRunManager {
|
|
|
166
166
|
}, this.config.pollInterval);
|
|
167
167
|
}
|
|
168
168
|
/**
|
|
169
|
-
* Poll for pending workflows and manage
|
|
169
|
+
* Poll for pending workflows and manage run executions
|
|
170
170
|
*/
|
|
171
171
|
async poll() {
|
|
172
172
|
if (this.status !== "running") {
|
|
@@ -175,10 +175,10 @@ export class WorkflowRunManager {
|
|
|
175
175
|
this.stats.pollCount++;
|
|
176
176
|
this.stats.lastPollAt = new Date();
|
|
177
177
|
try {
|
|
178
|
-
// 1. Check status of active
|
|
179
|
-
await this.
|
|
178
|
+
// 1. Check status of active executions
|
|
179
|
+
await this.syncRunExecutionStatuses();
|
|
180
180
|
// 2. Find workflows that need execution
|
|
181
|
-
const availableSlots = this.config.
|
|
181
|
+
const availableSlots = this.config.maxConcurrentExecutions - this.activeExecutions.size;
|
|
182
182
|
if (availableSlots <= 0) {
|
|
183
183
|
return;
|
|
184
184
|
}
|
|
@@ -187,7 +187,7 @@ export class WorkflowRunManager {
|
|
|
187
187
|
status: "pending",
|
|
188
188
|
limit: availableSlots,
|
|
189
189
|
});
|
|
190
|
-
// Also check for stalled workflows (crashed
|
|
190
|
+
// Also check for stalled workflows (crashed run executions)
|
|
191
191
|
let stalledRuns = [];
|
|
192
192
|
if (hasWorkerSupport(this.config.backend)) {
|
|
193
193
|
stalledRuns = await this.config.backend.findStalledRuns(this.config.stalledThreshold);
|
|
@@ -198,8 +198,8 @@ export class WorkflowRunManager {
|
|
|
198
198
|
// Combine pending and stalled runs
|
|
199
199
|
const runsToProcess = [...pendingRuns, ...stalledRuns].slice(0, availableSlots);
|
|
200
200
|
for (const run of runsToProcess) {
|
|
201
|
-
// Skip if already has an active
|
|
202
|
-
if (this.
|
|
201
|
+
// Skip if already has an active execution
|
|
202
|
+
if (this.activeExecutions.has(run.id)) {
|
|
203
203
|
continue;
|
|
204
204
|
}
|
|
205
205
|
let pendingLockAcquired = false;
|
|
@@ -213,7 +213,7 @@ export class WorkflowRunManager {
|
|
|
213
213
|
continue;
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
|
-
// For pending runs, acquire a short lock to avoid duplicate
|
|
216
|
+
// For pending runs, acquire a short lock to avoid duplicate execution creation
|
|
217
217
|
// across managers between listRuns() and updateRun().
|
|
218
218
|
if (run.status === "pending" && hasLockSupport(this.config.backend)) {
|
|
219
219
|
pendingLockAcquired = await this.config.backend.acquireLock(run.id, this.config.stalledThreshold);
|
|
@@ -230,7 +230,7 @@ export class WorkflowRunManager {
|
|
|
230
230
|
if (!runToProcess) {
|
|
231
231
|
continue;
|
|
232
232
|
}
|
|
233
|
-
await this.
|
|
233
|
+
await this.createExecutionForWorkflow(runToProcess);
|
|
234
234
|
}
|
|
235
235
|
finally {
|
|
236
236
|
if (pendingLockAcquired) {
|
|
@@ -250,81 +250,81 @@ export class WorkflowRunManager {
|
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
252
|
/**
|
|
253
|
-
* Sync
|
|
253
|
+
* Sync run execution statuses with executor
|
|
254
254
|
*/
|
|
255
|
-
async
|
|
255
|
+
async syncRunExecutionStatuses() {
|
|
256
256
|
try {
|
|
257
|
-
const
|
|
258
|
-
for (const
|
|
259
|
-
const tracked = this.
|
|
257
|
+
const executions = await this.config.executor.listRunExecutions(this.managerId);
|
|
258
|
+
for (const executionInfo of executions) {
|
|
259
|
+
const tracked = this.activeExecutions.get(executionInfo.runId);
|
|
260
260
|
if (!tracked) {
|
|
261
261
|
continue;
|
|
262
262
|
}
|
|
263
|
-
if (
|
|
263
|
+
if (executionInfo.status === tracked.status) {
|
|
264
264
|
continue;
|
|
265
265
|
}
|
|
266
|
-
tracked.status =
|
|
266
|
+
tracked.status = executionInfo.status;
|
|
267
267
|
// Handle terminal states
|
|
268
|
-
if (
|
|
269
|
-
this.
|
|
270
|
-
if (
|
|
271
|
-
this.stats.
|
|
268
|
+
if (executionInfo.status === "succeeded" || executionInfo.status === "failed") {
|
|
269
|
+
this.activeExecutions.delete(executionInfo.runId);
|
|
270
|
+
if (executionInfo.status === "succeeded") {
|
|
271
|
+
this.stats.executionsCompleted++;
|
|
272
272
|
if (this.config.debug) {
|
|
273
|
-
logger.info(`
|
|
273
|
+
logger.info(`Run execution completed: ${executionInfo.executionId}`);
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
276
|
else {
|
|
277
|
-
this.stats.
|
|
278
|
-
logger.error(`[WorkflowRunManager]
|
|
277
|
+
this.stats.executionsFailed++;
|
|
278
|
+
logger.error(`[WorkflowRunManager] Run execution failed: ${executionInfo.executionId}`, executionInfo.error);
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
catch (error) {
|
|
284
|
-
logger.error(`Failed to sync
|
|
284
|
+
logger.error(`Failed to sync run execution statuses:`, error);
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
287
|
/**
|
|
288
|
-
* Create
|
|
288
|
+
* Create an isolated execution for a workflow run
|
|
289
289
|
*/
|
|
290
|
-
async
|
|
291
|
-
const
|
|
292
|
-
const
|
|
293
|
-
|
|
290
|
+
async createExecutionForWorkflow(run) {
|
|
291
|
+
const executionId = generateId("run_exec");
|
|
292
|
+
const executionConfig = {
|
|
293
|
+
executionId,
|
|
294
294
|
run,
|
|
295
295
|
managerId: this.managerId,
|
|
296
|
-
timeout: this.config.
|
|
296
|
+
timeout: this.config.executionTimeout,
|
|
297
297
|
env: this.config.env ?? {},
|
|
298
298
|
debug: this.config.debug,
|
|
299
299
|
};
|
|
300
300
|
try {
|
|
301
|
-
await this.config.executor.
|
|
301
|
+
await this.config.executor.createRunExecution(executionConfig);
|
|
302
302
|
const tracked = {
|
|
303
|
-
|
|
303
|
+
executionId,
|
|
304
304
|
runId: run.id,
|
|
305
305
|
status: "pending",
|
|
306
306
|
createdAt: new Date(),
|
|
307
307
|
};
|
|
308
|
-
this.
|
|
309
|
-
this.stats.
|
|
308
|
+
this.activeExecutions.set(run.id, tracked);
|
|
309
|
+
this.stats.executionsCreated++;
|
|
310
310
|
// Mark workflow as running
|
|
311
311
|
await this.config.backend.updateRun(run.id, {
|
|
312
312
|
status: "running",
|
|
313
313
|
startedAt: new Date(),
|
|
314
314
|
heartbeatAt: new Date(),
|
|
315
|
-
workerId: `
|
|
315
|
+
workerId: `run-execution:${executionId}`,
|
|
316
316
|
});
|
|
317
317
|
if (this.config.debug) {
|
|
318
|
-
logger.info(`Created
|
|
318
|
+
logger.info(`Created run execution ${executionId} for workflow ${run.id}`);
|
|
319
319
|
}
|
|
320
320
|
}
|
|
321
321
|
catch (error) {
|
|
322
|
-
logger.error(`Failed to create
|
|
322
|
+
logger.error(`Failed to create run execution for ${run.id}:`, error);
|
|
323
323
|
// Mark workflow as failed
|
|
324
324
|
await this.config.backend.updateRun(run.id, {
|
|
325
325
|
status: "failed",
|
|
326
326
|
error: {
|
|
327
|
-
message: `
|
|
327
|
+
message: `RUN_EXECUTION_CREATION_FAILED: Failed to create run execution: ${error instanceof Error ? error.message : String(error)}`,
|
|
328
328
|
},
|
|
329
329
|
completedAt: new Date(),
|
|
330
330
|
});
|
|
@@ -339,7 +339,7 @@ export class WorkflowRunManager {
|
|
|
339
339
|
}
|
|
340
340
|
}
|
|
341
341
|
/**
|
|
342
|
-
* Create a workflow run manager backed by
|
|
342
|
+
* Create a workflow run manager backed by run executors.
|
|
343
343
|
*/
|
|
344
344
|
export function createWorkflowRunManager(config) {
|
|
345
345
|
return new WorkflowRunManager(config);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { env as getProcessEnv } from "../../platform/compat/process.js";
|
|
2
2
|
import { runWithRequestContext } from "../../platform/adapters/fs/veryfront/multi-project-adapter.js";
|
|
3
3
|
import { getEnv } from "../../platform/compat/process.js";
|
|
4
|
-
import { mergeInjectedWorkflowEnv } from "../../
|
|
4
|
+
import { mergeInjectedWorkflowEnv } from "../../runs/runtime-env.js";
|
|
5
5
|
export function getTenantFromEnv() {
|
|
6
6
|
const projectSlug = getEnv("TENANT_PROJECT_SLUG");
|
|
7
7
|
const token = getEnv("TENANT_TOKEN");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "veryfront",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.625",
|
|
4
4
|
"description": "The simplest way to build AI-powered apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -137,9 +137,9 @@
|
|
|
137
137
|
"import": "./esm/src/resource/index.js",
|
|
138
138
|
"types": "./esm/src/resource/index.d.ts"
|
|
139
139
|
},
|
|
140
|
-
"./
|
|
141
|
-
"import": "./esm/src/
|
|
142
|
-
"types": "./esm/src/
|
|
140
|
+
"./runs": {
|
|
141
|
+
"import": "./esm/src/runs/index.js",
|
|
142
|
+
"types": "./esm/src/runs/index.d.ts"
|
|
143
143
|
},
|
|
144
144
|
"./mcp": {
|
|
145
145
|
"import": "./esm/src/mcp/index.js",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parser-source.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/knowledge/parser-source.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,2BAA2B,QAgoBvC,CAAC"}
|