@elaraai/e3-core 0.0.1-alpha.2

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.
Files changed (63) hide show
  1. package/LICENSE.md +50 -0
  2. package/README.md +103 -0
  3. package/dist/src/dataflow.d.ts +136 -0
  4. package/dist/src/dataflow.d.ts.map +1 -0
  5. package/dist/src/dataflow.js +562 -0
  6. package/dist/src/dataflow.js.map +1 -0
  7. package/dist/src/errors.d.ts +125 -0
  8. package/dist/src/errors.d.ts.map +1 -0
  9. package/dist/src/errors.js +211 -0
  10. package/dist/src/errors.js.map +1 -0
  11. package/dist/src/executions.d.ts +176 -0
  12. package/dist/src/executions.d.ts.map +1 -0
  13. package/dist/src/executions.js +585 -0
  14. package/dist/src/executions.js.map +1 -0
  15. package/dist/src/formats.d.ts +38 -0
  16. package/dist/src/formats.d.ts.map +1 -0
  17. package/dist/src/formats.js +115 -0
  18. package/dist/src/formats.js.map +1 -0
  19. package/dist/src/gc.d.ts +54 -0
  20. package/dist/src/gc.d.ts.map +1 -0
  21. package/dist/src/gc.js +233 -0
  22. package/dist/src/gc.js.map +1 -0
  23. package/dist/src/index.d.ts +25 -0
  24. package/dist/src/index.d.ts.map +1 -0
  25. package/dist/src/index.js +72 -0
  26. package/dist/src/index.js.map +1 -0
  27. package/dist/src/objects.d.ts +62 -0
  28. package/dist/src/objects.d.ts.map +1 -0
  29. package/dist/src/objects.js +245 -0
  30. package/dist/src/objects.js.map +1 -0
  31. package/dist/src/packages.d.ts +93 -0
  32. package/dist/src/packages.d.ts.map +1 -0
  33. package/dist/src/packages.js +370 -0
  34. package/dist/src/packages.js.map +1 -0
  35. package/dist/src/repository.d.ts +38 -0
  36. package/dist/src/repository.d.ts.map +1 -0
  37. package/dist/src/repository.js +103 -0
  38. package/dist/src/repository.js.map +1 -0
  39. package/dist/src/tasks.d.ts +63 -0
  40. package/dist/src/tasks.d.ts.map +1 -0
  41. package/dist/src/tasks.js +145 -0
  42. package/dist/src/tasks.js.map +1 -0
  43. package/dist/src/test-helpers.d.ts +44 -0
  44. package/dist/src/test-helpers.d.ts.map +1 -0
  45. package/dist/src/test-helpers.js +141 -0
  46. package/dist/src/test-helpers.js.map +1 -0
  47. package/dist/src/trees.d.ts +178 -0
  48. package/dist/src/trees.d.ts.map +1 -0
  49. package/dist/src/trees.js +636 -0
  50. package/dist/src/trees.js.map +1 -0
  51. package/dist/src/workspaceLock.d.ts +67 -0
  52. package/dist/src/workspaceLock.d.ts.map +1 -0
  53. package/dist/src/workspaceLock.js +217 -0
  54. package/dist/src/workspaceLock.js.map +1 -0
  55. package/dist/src/workspaceStatus.d.ts +126 -0
  56. package/dist/src/workspaceStatus.d.ts.map +1 -0
  57. package/dist/src/workspaceStatus.js +352 -0
  58. package/dist/src/workspaceStatus.js.map +1 -0
  59. package/dist/src/workspaces.d.ts +150 -0
  60. package/dist/src/workspaces.d.ts.map +1 -0
  61. package/dist/src/workspaces.js +390 -0
  62. package/dist/src/workspaces.js.map +1 -0
  63. package/package.json +59 -0
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ /**
6
+ * Domain error types for e3-core.
7
+ *
8
+ * All e3 errors extend E3Error, allowing callers to catch all domain errors
9
+ * with `if (err instanceof E3Error)` or specific errors with their class.
10
+ */
11
+ import type { TaskExecutionResult } from './dataflow.js';
12
+ /** Base class for all e3 errors */
13
+ export declare class E3Error extends Error {
14
+ constructor(message: string);
15
+ }
16
+ export declare class RepositoryNotFoundError extends E3Error {
17
+ readonly path: string;
18
+ constructor(path: string);
19
+ }
20
+ export declare class WorkspaceNotFoundError extends E3Error {
21
+ readonly workspace: string;
22
+ constructor(workspace: string);
23
+ }
24
+ export declare class WorkspaceNotDeployedError extends E3Error {
25
+ readonly workspace: string;
26
+ constructor(workspace: string);
27
+ }
28
+ export declare class WorkspaceExistsError extends E3Error {
29
+ readonly workspace: string;
30
+ constructor(workspace: string);
31
+ }
32
+ /**
33
+ * Information about the process holding a workspace lock.
34
+ */
35
+ export interface LockHolder {
36
+ /** Process ID of the lock holder */
37
+ pid: number;
38
+ /** When the lock was acquired (ISO 8601) */
39
+ acquiredAt: string;
40
+ /** System boot ID (to detect stale locks after reboot) */
41
+ bootId?: string;
42
+ /** Process start time in jiffies (to detect PID reuse) */
43
+ startTime?: number;
44
+ /** Command that acquired the lock (for debugging) */
45
+ command?: string;
46
+ }
47
+ /**
48
+ * Thrown when a workspace is locked by another process.
49
+ *
50
+ * This error is thrown when attempting to acquire an exclusive lock on a
51
+ * workspace that is already locked by another process (e.g., another
52
+ * `e3 start` command or API server).
53
+ */
54
+ export declare class WorkspaceLockError extends E3Error {
55
+ readonly workspace: string;
56
+ readonly holder?: LockHolder | undefined;
57
+ constructor(workspace: string, holder?: LockHolder | undefined);
58
+ }
59
+ export declare class PackageNotFoundError extends E3Error {
60
+ readonly packageName: string;
61
+ readonly version?: string | undefined;
62
+ constructor(packageName: string, version?: string | undefined);
63
+ }
64
+ export declare class PackageInvalidError extends E3Error {
65
+ readonly reason: string;
66
+ constructor(reason: string);
67
+ }
68
+ export declare class PackageExistsError extends E3Error {
69
+ readonly packageName: string;
70
+ readonly version: string;
71
+ constructor(packageName: string, version: string);
72
+ }
73
+ export declare class DatasetNotFoundError extends E3Error {
74
+ readonly workspace: string;
75
+ readonly path: string;
76
+ constructor(workspace: string, path: string);
77
+ }
78
+ export declare class TaskNotFoundError extends E3Error {
79
+ readonly task: string;
80
+ constructor(task: string);
81
+ }
82
+ export declare class ObjectNotFoundError extends E3Error {
83
+ readonly hash: string;
84
+ constructor(hash: string);
85
+ }
86
+ export declare class ObjectCorruptError extends E3Error {
87
+ readonly hash: string;
88
+ readonly reason: string;
89
+ constructor(hash: string, reason: string);
90
+ }
91
+ export declare class ExecutionCorruptError extends E3Error {
92
+ readonly taskHash: string;
93
+ readonly inputsHash: string;
94
+ readonly cause: Error;
95
+ constructor(taskHash: string, inputsHash: string, cause: Error);
96
+ }
97
+ export declare class DataflowError extends E3Error {
98
+ readonly taskResults?: TaskExecutionResult[] | undefined;
99
+ readonly cause?: Error | undefined;
100
+ constructor(message: string, taskResults?: TaskExecutionResult[] | undefined, cause?: Error | undefined);
101
+ }
102
+ /**
103
+ * Thrown when a dataflow execution is aborted via AbortSignal.
104
+ *
105
+ * This is not an error condition - it indicates the execution was intentionally
106
+ * cancelled (e.g., by an API server before applying a write). The partial
107
+ * results contain the status of tasks that completed before the abort.
108
+ */
109
+ export declare class DataflowAbortedError extends E3Error {
110
+ readonly partialResults?: TaskExecutionResult[] | undefined;
111
+ constructor(partialResults?: TaskExecutionResult[] | undefined);
112
+ }
113
+ export declare class PermissionDeniedError extends E3Error {
114
+ readonly path: string;
115
+ constructor(path: string);
116
+ }
117
+ /** Check if error is ENOENT (file not found) */
118
+ export declare function isNotFoundError(err: unknown): boolean;
119
+ /** Check if error is EACCES (permission denied) */
120
+ export declare function isPermissionError(err: unknown): boolean;
121
+ /** Check if error is EEXIST (already exists) */
122
+ export declare function isExistsError(err: unknown): boolean;
123
+ /** Wrap unknown errors with context */
124
+ export declare function wrapError(err: unknown, message: string): E3Error;
125
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAMzD,mCAAmC;AACnC,qBAAa,OAAQ,SAAQ,KAAK;gBACpB,OAAO,EAAE,MAAM;CAI5B;AAMD,qBAAa,uBAAwB,SAAQ,OAAO;aACtB,IAAI,EAAE,MAAM;gBAAZ,IAAI,EAAE,MAAM;CAGzC;AAMD,qBAAa,sBAAuB,SAAQ,OAAO;aACrB,SAAS,EAAE,MAAM;gBAAjB,SAAS,EAAE,MAAM;CAG9C;AAED,qBAAa,yB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-0,0 +1,211 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ // =============================================================================
6
+ // Base Error
7
+ // =============================================================================
8
+ /** Base class for all e3 errors */
9
+ export class E3Error extends Error {
10
+ constructor(message) {
11
+ super(message);
12
+ this.name = this.constructor.name;
13
+ }
14
+ }
15
+ // =============================================================================
16
+ // Repository Errors
17
+ // =============================================================================
18
+ export class RepositoryNotFoundError extends E3Error {
19
+ path;
20
+ constructor(path) {
21
+ super(`Repository not found at '${path}'`);
22
+ this.path = path;
23
+ }
24
+ }
25
+ // =============================================================================
26
+ // Workspace Errors
27
+ // =============================================================================
28
+ export class WorkspaceNotFoundError extends E3Error {
29
+ workspace;
30
+ constructor(workspace) {
31
+ super(`Workspace '${workspace}' does not exist`);
32
+ this.workspace = workspace;
33
+ }
34
+ }
35
+ export class WorkspaceNotDeployedError extends E3Error {
36
+ workspace;
37
+ constructor(workspace) {
38
+ super(`Workspace '${workspace}' has no package deployed`);
39
+ this.workspace = workspace;
40
+ }
41
+ }
42
+ export class WorkspaceExistsError extends E3Error {
43
+ workspace;
44
+ constructor(workspace) {
45
+ super(`Workspace '${workspace}' already exists`);
46
+ this.workspace = workspace;
47
+ }
48
+ }
49
+ /**
50
+ * Thrown when a workspace is locked by another process.
51
+ *
52
+ * This error is thrown when attempting to acquire an exclusive lock on a
53
+ * workspace that is already locked by another process (e.g., another
54
+ * `e3 start` command or API server).
55
+ */
56
+ export class WorkspaceLockError extends E3Error {
57
+ workspace;
58
+ holder;
59
+ constructor(workspace, holder) {
60
+ const msg = holder
61
+ ? `Workspace '${workspace}' is locked by process ${holder.pid} (since ${holder.acquiredAt})`
62
+ : `Workspace '${workspace}' is locked by another process`;
63
+ super(msg);
64
+ this.workspace = workspace;
65
+ this.holder = holder;
66
+ }
67
+ }
68
+ // =============================================================================
69
+ // Package Errors
70
+ // =============================================================================
71
+ export class PackageNotFoundError extends E3Error {
72
+ packageName;
73
+ version;
74
+ constructor(packageName, version) {
75
+ super(version
76
+ ? `Package '${packageName}@${version}' not found`
77
+ : `Package '${packageName}' not found`);
78
+ this.packageName = packageName;
79
+ this.version = version;
80
+ }
81
+ }
82
+ export class PackageInvalidError extends E3Error {
83
+ reason;
84
+ constructor(reason) {
85
+ super(`Invalid package: ${reason}`);
86
+ this.reason = reason;
87
+ }
88
+ }
89
+ export class PackageExistsError extends E3Error {
90
+ packageName;
91
+ version;
92
+ constructor(packageName, version) {
93
+ super(`Package '${packageName}@${version}' already exists`);
94
+ this.packageName = packageName;
95
+ this.version = version;
96
+ }
97
+ }
98
+ // =============================================================================
99
+ // Dataset Errors
100
+ // =============================================================================
101
+ export class DatasetNotFoundError extends E3Error {
102
+ workspace;
103
+ path;
104
+ constructor(workspace, path) {
105
+ super(`Dataset '${path}' not found in workspace '${workspace}'`);
106
+ this.workspace = workspace;
107
+ this.path = path;
108
+ }
109
+ }
110
+ // =============================================================================
111
+ // Task Errors
112
+ // =============================================================================
113
+ export class TaskNotFoundError extends E3Error {
114
+ task;
115
+ constructor(task) {
116
+ super(`Task '${task}' not found`);
117
+ this.task = task;
118
+ }
119
+ }
120
+ // =============================================================================
121
+ // Object Errors
122
+ // =============================================================================
123
+ export class ObjectNotFoundError extends E3Error {
124
+ hash;
125
+ constructor(hash) {
126
+ super(`Object '${hash.slice(0, 8)}...' not found`);
127
+ this.hash = hash;
128
+ }
129
+ }
130
+ export class ObjectCorruptError extends E3Error {
131
+ hash;
132
+ reason;
133
+ constructor(hash, reason) {
134
+ super(`Object ${hash.slice(0, 8)}... is corrupt: ${reason}`);
135
+ this.hash = hash;
136
+ this.reason = reason;
137
+ }
138
+ }
139
+ // =============================================================================
140
+ // Execution Errors
141
+ // =============================================================================
142
+ export class ExecutionCorruptError extends E3Error {
143
+ taskHash;
144
+ inputsHash;
145
+ cause;
146
+ constructor(taskHash, inputsHash, cause) {
147
+ super(`Execution ${taskHash.slice(0, 8)}.../${inputsHash.slice(0, 8)}... is corrupt: ${cause.message}`);
148
+ this.taskHash = taskHash;
149
+ this.inputsHash = inputsHash;
150
+ this.cause = cause;
151
+ }
152
+ }
153
+ // =============================================================================
154
+ // Dataflow Errors
155
+ // =============================================================================
156
+ export class DataflowError extends E3Error {
157
+ taskResults;
158
+ cause;
159
+ constructor(message, taskResults, cause) {
160
+ super(cause ? `${message}: ${cause.message}` : message);
161
+ this.taskResults = taskResults;
162
+ this.cause = cause;
163
+ }
164
+ }
165
+ /**
166
+ * Thrown when a dataflow execution is aborted via AbortSignal.
167
+ *
168
+ * This is not an error condition - it indicates the execution was intentionally
169
+ * cancelled (e.g., by an API server before applying a write). The partial
170
+ * results contain the status of tasks that completed before the abort.
171
+ */
172
+ export class DataflowAbortedError extends E3Error {
173
+ partialResults;
174
+ constructor(partialResults) {
175
+ super('Dataflow execution was aborted');
176
+ this.partialResults = partialResults;
177
+ }
178
+ }
179
+ // =============================================================================
180
+ // Generic Errors
181
+ // =============================================================================
182
+ export class PermissionDeniedError extends E3Error {
183
+ path;
184
+ constructor(path) {
185
+ super(`Permission denied: '${path}'`);
186
+ this.path = path;
187
+ }
188
+ }
189
+ // =============================================================================
190
+ // Helper Functions
191
+ // =============================================================================
192
+ /** Check if error is ENOENT (file not found) */
193
+ export function isNotFoundError(err) {
194
+ return (err instanceof Error && err.code === 'ENOENT');
195
+ }
196
+ /** Check if error is EACCES (permission denied) */
197
+ export function isPermissionError(err) {
198
+ return (err instanceof Error && err.code === 'EACCES');
199
+ }
200
+ /** Check if error is EEXIST (already exists) */
201
+ export function isExistsError(err) {
202
+ return (err instanceof Error && err.code === 'EEXIST');
203
+ }
204
+ /** Wrap unknown errors with context */
205
+ export function wrapError(err, message) {
206
+ if (err instanceof E3Error)
207
+ return err;
208
+ const cause = err instanceof Error ? err.message : String(err);
209
+ return new E3Error(`${message}: ${cause}`);
210
+ }
211
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","source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Y,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC/D,OAAO,IAAI,OAAO,CAAC,GAAG,OAAO,KAAK,KAAK,EAAE,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,176 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ import { type ExecutionStatus } from '@elaraai/e3-types';
6
+ /**
7
+ * Compute the combined hash of input hashes.
8
+ *
9
+ * Used to create a unique identifier for an execution based on its inputs.
10
+ * The order of inputs matters - different orderings produce different hashes.
11
+ *
12
+ * @param inputHashes - Array of input dataset hashes
13
+ * @returns Combined SHA256 hash
14
+ */
15
+ export declare function inputsHash(inputHashes: string[]): string;
16
+ /**
17
+ * Get the filesystem path for an execution directory.
18
+ *
19
+ * @param repoPath - Path to .e3 repository
20
+ * @param taskHash - Hash of the task object
21
+ * @param inHash - Combined hash of input hashes
22
+ * @returns Path to execution directory: executions/<taskHash>/<inputsHash>/
23
+ */
24
+ export declare function executionPath(repoPath: string, taskHash: string, inHash: string): string;
25
+ /**
26
+ * Get execution status.
27
+ *
28
+ * @param repoPath - Path to .e3 repository
29
+ * @param taskHash - Hash of the task object
30
+ * @param inHash - Combined hash of input hashes
31
+ * @returns ExecutionStatus or null if execution doesn't exist
32
+ * @throws {ExecutionCorruptError} If status file exists but cannot be decoded
33
+ */
34
+ export declare function executionGet(repoPath: string, taskHash: string, inHash: string): Promise<ExecutionStatus | null>;
35
+ /**
36
+ * Get output hash for a completed execution.
37
+ *
38
+ * @param repoPath - Path to .e3 repository
39
+ * @param taskHash - Hash of the task object
40
+ * @param inHash - Combined hash of input hashes
41
+ * @returns Output hash or null if not complete or failed
42
+ */
43
+ export declare function executionGetOutput(repoPath: string, taskHash: string, inHash: string): Promise<string | null>;
44
+ /**
45
+ * List all input hashes that have executions for a given task.
46
+ *
47
+ * @param repoPath - Path to .e3 repository
48
+ * @param taskHash - Hash of the task object
49
+ * @returns Array of input hashes
50
+ */
51
+ export declare function executionListForTask(repoPath: string, taskHash: string): Promise<string[]>;
52
+ /**
53
+ * List all executions in the repository.
54
+ *
55
+ * @param repoPath - Path to .e3 repository
56
+ * @returns Array of { taskHash, inputsHash } objects
57
+ */
58
+ export declare function executionList(repoPath: string): Promise<Array<{
59
+ taskHash: string;
60
+ inputsHash: string;
61
+ }>>;
62
+ /**
63
+ * Options for reading execution logs
64
+ */
65
+ export interface LogReadOptions {
66
+ /** Byte offset to start reading from (default: 0) */
67
+ offset?: number;
68
+ /** Maximum bytes to read (default: 64KB) */
69
+ limit?: number;
70
+ }
71
+ /**
72
+ * Result of reading a log chunk
73
+ */
74
+ export interface LogChunk {
75
+ /** Log content (UTF-8) */
76
+ data: string;
77
+ /** Byte offset of this chunk */
78
+ offset: number;
79
+ /** Bytes in this chunk */
80
+ size: number;
81
+ /** Total log file size (for pagination) */
82
+ totalSize: number;
83
+ /** True if this is the end of the file */
84
+ complete: boolean;
85
+ }
86
+ /**
87
+ * Read execution logs with pagination support.
88
+ *
89
+ * @param repoPath - Path to .e3 repository
90
+ * @param taskHash - Hash of the task object
91
+ * @param inHash - Combined hash of input hashes
92
+ * @param stream - Which log stream to read ('stdout' or 'stderr')
93
+ * @param options - Pagination options
94
+ * @returns Log chunk with data and metadata
95
+ */
96
+ export declare function executionReadLog(repoPath: string, taskHash: string, inHash: string, stream: 'stdout' | 'stderr', options?: LogReadOptions): Promise<LogChunk>;
97
+ /**
98
+ * Evaluate command IR to get exec args.
99
+ *
100
+ * The IR is an East function: (inputs: Array<String>, output: String) -> Array<String>
101
+ *
102
+ * @param repoPath - Path to .e3 repository
103
+ * @param commandIrHash - Hash of the IR object
104
+ * @param inputPaths - Paths to staged input files
105
+ * @param outputPath - Path where output should be written
106
+ * @returns Array of strings to exec
107
+ */
108
+ export declare function evaluateCommandIr(repoPath: string, commandIrHash: string, inputPaths: string[], outputPath: string): Promise<string[]>;
109
+ /**
110
+ * Get the current system boot ID.
111
+ * Used for detecting stale locks/processes after system reboot.
112
+ */
113
+ export declare function getBootId(): Promise<string>;
114
+ /**
115
+ * Get process start time from /proc/<pid>/stat.
116
+ * Returns the starttime field (field 22) which is jiffies since boot.
117
+ * Used together with boot ID to uniquely identify a process (handles PID reuse).
118
+ */
119
+ export declare function getPidStartTime(pid: number): Promise<number>;
120
+ /**
121
+ * Check if a process is still alive based on stored identification
122
+ */
123
+ export declare function isProcessAlive(pid: number, pidStartTime: number, bootId: string): Promise<boolean>;
124
+ /**
125
+ * Options for task execution
126
+ */
127
+ export interface ExecuteOptions {
128
+ /** Re-run even if cached (default: false) */
129
+ force?: boolean;
130
+ /** Timeout in milliseconds (default: none) */
131
+ timeout?: number;
132
+ /** AbortSignal for cancellation */
133
+ signal?: AbortSignal;
134
+ /** Stream stdout callback */
135
+ onStdout?: (data: string) => void;
136
+ /** Stream stderr callback */
137
+ onStderr?: (data: string) => void;
138
+ }
139
+ /**
140
+ * Result of task execution
141
+ */
142
+ export interface ExecutionResult {
143
+ /** Combined inputs hash (identifies this execution) */
144
+ inputsHash: string;
145
+ /** True if result was from cache */
146
+ cached: boolean;
147
+ /** Final state */
148
+ state: 'success' | 'failed' | 'error';
149
+ /** Output dataset hash (null on failure) */
150
+ outputHash: string | null;
151
+ /** Process exit code (null if not applicable) */
152
+ exitCode: number | null;
153
+ /** Execution time in ms (0 if cached) */
154
+ duration: number;
155
+ /** Error message on failure */
156
+ error: string | null;
157
+ }
158
+ /**
159
+ * Execute a single task.
160
+ *
161
+ * This is the core execution primitive. It:
162
+ * 1. Computes the execution identity from task + inputs
163
+ * 2. Checks cache (unless force=true)
164
+ * 3. Marshals inputs to a scratch directory
165
+ * 4. Evaluates command IR to get exec args
166
+ * 5. Runs the command
167
+ * 6. Stores the output and updates status
168
+ *
169
+ * @param repoPath - Path to .e3 repository
170
+ * @param taskHash - Hash of the task object
171
+ * @param inputHashes - Array of input dataset hashes
172
+ * @param options - Execution options
173
+ * @returns Execution result
174
+ */
175
+ export declare function taskExecute(repoPath: string, taskHash: string, inputHashes: string[], options?: ExecuteOptions): Promise<ExecutionResult>;
176
+ //# sourceMappingURL=executions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executions.d.ts","sourceRoot":"","sources":["../../src/executions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAmBH,OAAO,EAEL,KAAK,eAAe,EAGrB,MAAM,mBAAmB,CAAC;AAQ3B;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,MAAM,CAGxD;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,MAAM,CAER;AAMD;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAChC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAoBjC;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAaxB;AAED;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,EAAE,CAAC,CAUnB;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,KAAK,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,CA0B1D;AAMD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,qDAAqD;IACrD,MAAM,CAAC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