cli4ai 1.2.5 → 1.2.6
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/dist/cli.js +31 -0
- package/dist/commands/add.js +5 -1
- package/dist/commands/browse.js +65 -52
- package/dist/commands/download.d.ts +7 -0
- package/dist/commands/download.js +36 -0
- package/dist/commands/routines.js +7 -3
- package/dist/commands/secrets.js +37 -24
- package/dist/commands/serve.d.ts +4 -0
- package/dist/commands/serve.js +9 -0
- package/dist/core/execute.d.ts +4 -0
- package/dist/core/execute.js +37 -12
- package/dist/core/remote-client.d.ts +8 -0
- package/dist/core/remote-client.js +67 -0
- package/dist/core/routine-engine.d.ts +90 -6
- package/dist/core/routine-engine.js +766 -221
- package/dist/core/routines.d.ts +5 -0
- package/dist/core/routines.js +20 -0
- package/dist/core/scheduler.d.ts +19 -0
- package/dist/core/scheduler.js +79 -1
- package/dist/dashboard/api/endpoints.d.ts +14 -0
- package/dist/dashboard/api/endpoints.js +562 -0
- package/dist/dashboard/api/websocket.d.ts +133 -0
- package/dist/dashboard/api/websocket.js +278 -0
- package/dist/dashboard/db/index.d.ts +33 -0
- package/dist/dashboard/db/index.js +69 -0
- package/dist/dashboard/db/runs.d.ts +170 -0
- package/dist/dashboard/db/runs.js +475 -0
- package/dist/dashboard/db/schema.d.ts +64 -0
- package/dist/dashboard/db/schema.js +157 -0
- package/dist/server/service.d.ts +8 -0
- package/dist/server/service.js +192 -6
- package/package.json +11 -3
- package/src/dashboard/public/assets/index-DN1hIAMO.css +1 -0
- package/src/dashboard/public/assets/index-pZeAAQwj.js +331 -0
- package/src/dashboard/public/index.html +14 -0
|
@@ -1,6 +1,39 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Structured routine runner (v1).
|
|
3
3
|
*/
|
|
4
|
+
import { EventEmitter } from 'events';
|
|
5
|
+
/**
|
|
6
|
+
* Event emitter for routine execution events.
|
|
7
|
+
* Used by the dashboard for real-time updates.
|
|
8
|
+
*/
|
|
9
|
+
export declare const routineEvents: EventEmitter<[never]>;
|
|
10
|
+
export interface RoutineRunStartedEvent {
|
|
11
|
+
runId: string;
|
|
12
|
+
routineName: string;
|
|
13
|
+
triggerType: 'scheduled' | 'manual' | 'api';
|
|
14
|
+
}
|
|
15
|
+
export interface RoutineLogEvent {
|
|
16
|
+
runId: string;
|
|
17
|
+
stream: 'stdout' | 'stderr';
|
|
18
|
+
line: string;
|
|
19
|
+
stepId?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface RoutineStepEvent {
|
|
22
|
+
runId: string;
|
|
23
|
+
stepId: string;
|
|
24
|
+
stepType: string;
|
|
25
|
+
status: 'running' | 'success' | 'failed' | 'skipped' | 'caught';
|
|
26
|
+
exitCode?: number;
|
|
27
|
+
durationMs?: number;
|
|
28
|
+
stdout?: string;
|
|
29
|
+
stderr?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface RoutineRunFinishedEvent {
|
|
32
|
+
runId: string;
|
|
33
|
+
status: 'success' | 'failed';
|
|
34
|
+
exitCode: number;
|
|
35
|
+
durationMs: number;
|
|
36
|
+
}
|
|
4
37
|
export declare class RoutineParseError extends Error {
|
|
5
38
|
path: string;
|
|
6
39
|
constructor(path: string, message: string);
|
|
@@ -63,6 +96,32 @@ export interface RoutineExecStep extends RoutineBaseStep {
|
|
|
63
96
|
capture?: Exclude<StepCapture, 'inherit'>;
|
|
64
97
|
}
|
|
65
98
|
export type RoutineStep = RoutineC4aiStep | RoutineSetStep | RoutineExecStep;
|
|
99
|
+
export interface RoutineParallelGroup {
|
|
100
|
+
/** Steps to execute in parallel (only cli4ai and exec allowed) */
|
|
101
|
+
parallel: RoutineStep[];
|
|
102
|
+
/** If true (default), fail immediately on first error. If false, wait for all to complete. */
|
|
103
|
+
failFast?: boolean;
|
|
104
|
+
}
|
|
105
|
+
export interface RoutineTryBlock {
|
|
106
|
+
/** Steps to attempt */
|
|
107
|
+
try: RoutineStep[];
|
|
108
|
+
/** Steps to run if any try step fails (has access to {{error}} context) */
|
|
109
|
+
catch?: RoutineStep[];
|
|
110
|
+
/** Steps to always run after try/catch */
|
|
111
|
+
finally?: RoutineStep[];
|
|
112
|
+
}
|
|
113
|
+
/** Error context available in catch blocks via {{error}} */
|
|
114
|
+
export interface ErrorContext {
|
|
115
|
+
stepId: string;
|
|
116
|
+
stepType: string;
|
|
117
|
+
code: string;
|
|
118
|
+
message: string;
|
|
119
|
+
exitCode?: number;
|
|
120
|
+
stdout?: string;
|
|
121
|
+
stderr?: string;
|
|
122
|
+
}
|
|
123
|
+
/** A step entry can be a regular step, parallel group, or try block */
|
|
124
|
+
export type RoutineStepEntry = RoutineStep | RoutineParallelGroup | RoutineTryBlock;
|
|
66
125
|
export interface RoutineDefinition {
|
|
67
126
|
version: 1;
|
|
68
127
|
name: string;
|
|
@@ -74,13 +133,13 @@ export interface RoutineDefinition {
|
|
|
74
133
|
vars?: Record<string, RoutineVarDef>;
|
|
75
134
|
/** Schedule configuration for automatic execution */
|
|
76
135
|
schedule?: RoutineSchedule;
|
|
77
|
-
steps:
|
|
136
|
+
steps: RoutineStepEntry[];
|
|
78
137
|
result?: unknown;
|
|
79
138
|
}
|
|
80
139
|
export interface StepRunResult {
|
|
81
140
|
id: string;
|
|
82
|
-
type: RoutineStep['type'];
|
|
83
|
-
status: 'success' | 'failed' | 'skipped';
|
|
141
|
+
type: RoutineStep['type'] | 'parallel' | 'try';
|
|
142
|
+
status: 'success' | 'failed' | 'skipped' | 'caught';
|
|
84
143
|
exitCode?: number;
|
|
85
144
|
durationMs?: number;
|
|
86
145
|
stdout?: string;
|
|
@@ -103,9 +162,16 @@ export interface RoutineRunSummary {
|
|
|
103
162
|
result?: unknown;
|
|
104
163
|
}
|
|
105
164
|
export interface RoutineDryRunStep {
|
|
106
|
-
id
|
|
107
|
-
type: RoutineStep['type'];
|
|
108
|
-
rendered
|
|
165
|
+
id?: string;
|
|
166
|
+
type: RoutineStep['type'] | 'parallel' | 'try';
|
|
167
|
+
rendered?: Record<string, unknown>;
|
|
168
|
+
/** For parallel groups */
|
|
169
|
+
steps?: RoutineDryRunStep[];
|
|
170
|
+
failFast?: boolean;
|
|
171
|
+
/** For try blocks */
|
|
172
|
+
try?: RoutineDryRunStep[];
|
|
173
|
+
catch?: RoutineDryRunStep[];
|
|
174
|
+
finally?: RoutineDryRunStep[];
|
|
109
175
|
}
|
|
110
176
|
export interface RoutineDryRunPlan {
|
|
111
177
|
routine: string;
|
|
@@ -115,10 +181,28 @@ export interface RoutineDryRunPlan {
|
|
|
115
181
|
result?: unknown;
|
|
116
182
|
}
|
|
117
183
|
export declare function loadRoutineDefinition(path: string): RoutineDefinition;
|
|
184
|
+
/**
|
|
185
|
+
* Serialize a routine definition to YAML or JSON string.
|
|
186
|
+
*/
|
|
187
|
+
export declare function serializeRoutineDefinition(def: RoutineDefinition, format?: 'yaml' | 'json'): string;
|
|
118
188
|
/**
|
|
119
189
|
* Validate a schedule configuration.
|
|
120
190
|
* Exported for use by scheduler and tests.
|
|
121
191
|
*/
|
|
122
192
|
export declare function validateScheduleConfig(schedule: unknown, source?: string): RoutineSchedule;
|
|
193
|
+
export declare function isParallelGroup(entry: unknown): entry is RoutineParallelGroup;
|
|
194
|
+
export declare function isTryBlock(entry: unknown): entry is RoutineTryBlock;
|
|
123
195
|
export declare function dryRunRoutine(def: RoutineDefinition, vars: Record<string, string>, invocationDir: string): Promise<RoutineDryRunPlan>;
|
|
124
196
|
export declare function runRoutine(def: RoutineDefinition, vars: Record<string, string>, invocationDir: string): Promise<RoutineRunSummary>;
|
|
197
|
+
export interface TrackedRunOptions {
|
|
198
|
+
runId?: string;
|
|
199
|
+
triggerType?: 'scheduled' | 'manual' | 'api';
|
|
200
|
+
}
|
|
201
|
+
export interface TrackedRunResult extends RoutineRunSummary {
|
|
202
|
+
runId: string;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Run a routine with event emissions for real-time tracking.
|
|
206
|
+
* Emits events: run:started, run:log, run:step, run:finished
|
|
207
|
+
*/
|
|
208
|
+
export declare function runRoutineTracked(def: RoutineDefinition, vars: Record<string, string>, invocationDir: string, options?: TrackedRunOptions): Promise<TrackedRunResult>;
|