@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
package/LICENSE.md ADDED
@@ -0,0 +1,50 @@
1
+ # Business Source License 1.1
2
+
3
+ Copyright (c) 2025 Elara AI Pty Ltd
4
+
5
+ ## License
6
+
7
+ **Licensor:** Elara AI Pty Ltd
8
+
9
+ **Licensed Work:** @elaraai/e3-core
10
+
11
+ **Change Date:** Four years from the date of each release
12
+
13
+ **Change License:** AGPL-3.0
14
+
15
+ ## Terms
16
+
17
+ The Licensed Work is provided under the terms of the Business Source License 1.1 as detailed below.
18
+
19
+ ### Grant of Rights
20
+
21
+ The Licensor grants you the right to copy, modify, create derivative works, redistribute, and make non-production use of the Licensed Work.
22
+
23
+ ### Production Use Limitation
24
+
25
+ **"Production Use"** means any use by or on behalf of a for-profit entity, other than for evaluation, testing, or development purposes.
26
+
27
+ Production Use requires a separate commercial license from the Licensor.
28
+
29
+ ### Change Date
30
+
31
+ On the Change Date (four years after each release), the Licensed Work will be made available under the Change License (AGPL-3.0).
32
+
33
+ ### No Warranty
34
+
35
+ THE LICENSED WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. THE LICENSOR DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
36
+
37
+ ## Commercial Licensing
38
+
39
+ To obtain a commercial license for Production Use, contact:
40
+
41
+ **Email:** support@elara.ai
42
+ **Website:** https://elaraai.com
43
+
44
+ ## Governing Law
45
+
46
+ This license is governed by the laws of New South Wales, Australia.
47
+
48
+ ---
49
+
50
+ *Elara AI Pty Ltd*
package/README.md ADDED
@@ -0,0 +1,103 @@
1
+ # @elaraai/e3-core
2
+
3
+ Core library for e3 repository operations, similar to libgit2 for git.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @elaraai/e3-core
9
+ ```
10
+
11
+ ## Overview
12
+
13
+ Pure business logic with no UI dependencies. Use this to build custom tools, integrations, or alternative interfaces on top of e3.
14
+
15
+ ## API
16
+
17
+ ### Repository
18
+
19
+ ```typescript
20
+ import { initRepository, findRepository, getRepository } from '@elaraai/e3-core';
21
+
22
+ initRepository('/path/to/project');
23
+ const repoPath = findRepository(); // Searches cwd and parents
24
+ ```
25
+
26
+ ### Objects
27
+
28
+ ```typescript
29
+ import { storeObject, loadObject, computeTaskId } from '@elaraai/e3-core';
30
+
31
+ const hash = await storeObject(repoPath, data, '.beast2');
32
+ const data = await loadObject(repoPath, hash, '.beast2');
33
+ const taskId = computeTaskId(irHash, argsHashes);
34
+ ```
35
+
36
+ ### Commits
37
+
38
+ ```typescript
39
+ import { createNewTaskCommit, createTaskDoneCommit, loadCommit } from '@elaraai/e3-core';
40
+
41
+ const commitHash = await createNewTaskCommit(repoPath, taskId, irHash, argsHashes, 'node', null);
42
+ const commit = await loadCommit(repoPath, commitHash);
43
+ ```
44
+
45
+ ### Tasks
46
+
47
+ ```typescript
48
+ import { updateTaskState, getTaskState, listTasks } from '@elaraai/e3-core';
49
+
50
+ await updateTaskState(repoPath, taskId, commitHash);
51
+ const commit = await getTaskState(repoPath, taskId);
52
+ const tasks = await listTasks(repoPath);
53
+ ```
54
+
55
+ ### Refs
56
+
57
+ ```typescript
58
+ import { setTaskRef, deleteTaskRef, listTaskRefs, resolveToTaskId } from '@elaraai/e3-core';
59
+
60
+ await setTaskRef(repoPath, 'my-task', taskId);
61
+ const taskId = await resolveToTaskId(repoPath, 'my-task');
62
+ ```
63
+ ## License
64
+
65
+ BSL 1.1. See [LICENSE.md](./LICENSE.md).
66
+
67
+ ### Ecosystem
68
+
69
+ - **[East Node](https://github.com/elaraai/east-node)**: Node.js platform functions for I/O, databases, and system operations. Connect East programs to filesystems, SQL/NoSQL databases, cloud storage, and network services.
70
+ - [@elaraai/east-node-std](https://www.npmjs.com/package/@elaraai/east-node-std): Filesystem, console, HTTP fetch, crypto, random distributions, timestamps
71
+ - [@elaraai/east-node-io](https://www.npmjs.com/package/@elaraai/east-node-io): SQLite, PostgreSQL, MySQL, MongoDB, S3, FTP, SFTP
72
+ - [@elaraai/east-node-cli](https://www.npmjs.com/package/@elaraai/east-node-cli): CLI for running East IR programs in Node.js
73
+
74
+ - **[East Python](https://github.com/elaraai/east-py)**: Python runtime and platform functions for data science and machine learning. Execute East programs with access to optimization solvers, gradient boosting, neural networks, and model explainability.
75
+ - [@elaraai/east-py-datascience](https://www.npmjs.com/package/@elaraai/east-py-datascience): TypeScript types for optimization, gradient boosting, neural networks, explainability
76
+
77
+ - **[East UI](https://github.com/elaraai/east-ui)**: East types and expressions for building dashboards and interactive layouts. Define UIs as data structures that render consistently across React, web, and other environments.
78
+ - [@elaraai/east-ui](https://www.npmjs.com/package/@elaraai/east-ui): 50+ typed UI components for layouts, forms, charts, tables, dialogs
79
+ - [@elaraai/east-ui-components](https://www.npmjs.com/package/@elaraai/east-ui-components): React renderer with Chakra UI styling
80
+
81
+ - **[e3 - East Execution Engine](https://github.com/elaraai/e3)**: Durable execution engine for running East pipelines at scale. Features Git-like content-addressable storage, automatic memoization, task queuing, and real-time monitoring.
82
+ - [@elaraai/e3](https://www.npmjs.com/package/@elaraai/e3): SDK for authoring e3 packages with typed tasks and pipelines
83
+ - [@elaraai/e3-core](https://www.npmjs.com/package/@elaraai/e3-core): Git-like object store, task queue, result caching
84
+ - [@elaraai/e3-types](https://www.npmjs.com/package/@elaraai/e3-types): Shared type definitions for e3 packages
85
+ - [@elaraai/e3-cli](https://www.npmjs.com/package/@elaraai/e3-cli): `e3 init`, `e3 run`, `e3 logs` commands for managing and monitoring tasks
86
+ - [@elaraai/e3-api-client](https://www.npmjs.com/package/@elaraai/e3-api-client): HTTP client for remote e3 servers
87
+ - [@elaraai/e3-api-server](https://www.npmjs.com/package/@elaraai/e3-api-server): REST API server for e3 repositories
88
+
89
+ ## Links
90
+
91
+ - [East Language](https://github.com/elaraai/east)
92
+ - [East Python Runtime](https://github.com/elaraai/east-py)
93
+ - [Elara AI](https://elaraai.com/)
94
+ - [Issues](https://github.com/elaraai/e3/issues)
95
+ - support@elara.ai
96
+
97
+ ## About Elara
98
+
99
+ East is developed by [Elara AI Pty Ltd](https://elaraai.com/), an AI-powered platform that creates economic digital twins of businesses that optimize performance. Elara combines business objectives, decisions and data to help organizations make data-driven decisions across operations, purchasing, sales and customer engagement, and project and investment planning. East powers the computational layer of Elara solutions, enabling the expression of complex business logic and data in a simple, type-safe and portable language.
100
+
101
+ ---
102
+
103
+ *Developed by [Elara AI Pty Ltd](https://elaraai.com/)*
@@ -0,0 +1,136 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ import { type WorkspaceLockHandle } from './workspaceLock.js';
6
+ /**
7
+ * Result of executing a single task in the dataflow.
8
+ */
9
+ export interface TaskExecutionResult {
10
+ /** Task name */
11
+ name: string;
12
+ /** Whether the task was cached */
13
+ cached: boolean;
14
+ /** Final state */
15
+ state: 'success' | 'failed' | 'error' | 'skipped';
16
+ /** Error message if state is 'error' */
17
+ error?: string;
18
+ /** Exit code if state is 'failed' */
19
+ exitCode?: number;
20
+ /** Duration in milliseconds */
21
+ duration: number;
22
+ }
23
+ /**
24
+ * Result of a dataflow execution.
25
+ */
26
+ export interface DataflowResult {
27
+ /** Overall success - true if all tasks completed successfully */
28
+ success: boolean;
29
+ /** Number of tasks executed (not from cache) */
30
+ executed: number;
31
+ /** Number of tasks served from cache */
32
+ cached: number;
33
+ /** Number of tasks that failed */
34
+ failed: number;
35
+ /** Number of tasks skipped due to upstream failure */
36
+ skipped: number;
37
+ /** Per-task results */
38
+ tasks: TaskExecutionResult[];
39
+ /** Total duration in milliseconds */
40
+ duration: number;
41
+ }
42
+ /**
43
+ * Options for dataflow execution.
44
+ */
45
+ export interface DataflowOptions {
46
+ /** Maximum concurrent task executions (default: 4) */
47
+ concurrency?: number;
48
+ /** Force re-execution even if cached (default: false) */
49
+ force?: boolean;
50
+ /** Filter to run only specific task(s) by exact name */
51
+ filter?: string;
52
+ /**
53
+ * External workspace lock to use. If provided, the caller is responsible
54
+ * for releasing the lock after execution. If not provided, dataflowExecute
55
+ * will acquire and release a lock internally.
56
+ *
57
+ * Use an external lock when you need to hold the lock across multiple
58
+ * operations (e.g., API server that cancels and restarts dataflow on writes).
59
+ */
60
+ lock?: WorkspaceLockHandle;
61
+ /**
62
+ * AbortSignal for cancellation. When aborted:
63
+ * - No new tasks will be started
64
+ * - Running tasks will be killed (SIGTERM, then SIGKILL)
65
+ * - DataflowAbortedError will be thrown with partial results
66
+ */
67
+ signal?: AbortSignal;
68
+ /** Callback when a task starts */
69
+ onTaskStart?: (name: string) => void;
70
+ /** Callback when a task completes */
71
+ onTaskComplete?: (result: TaskExecutionResult) => void;
72
+ /** Callback for task stdout */
73
+ onStdout?: (taskName: string, data: string) => void;
74
+ /** Callback for task stderr */
75
+ onStderr?: (taskName: string, data: string) => void;
76
+ }
77
+ /**
78
+ * Execute all tasks in a workspace according to the dependency graph.
79
+ *
80
+ * Tasks are executed in parallel where dependencies allow, respecting
81
+ * the concurrency limit. On failure, no new tasks are launched but
82
+ * running tasks are allowed to complete.
83
+ *
84
+ * Acquires an exclusive lock on the workspace for the duration of execution
85
+ * to prevent concurrent modifications. If options.lock is provided, uses that
86
+ * lock instead (caller is responsible for releasing it).
87
+ *
88
+ * @param repoPath - Path to .e3 repository
89
+ * @param ws - Workspace name
90
+ * @param options - Execution options
91
+ * @returns Result of the dataflow execution
92
+ * @throws {WorkspaceLockError} If workspace is locked by another process
93
+ * @throws {WorkspaceNotFoundError} If workspace doesn't exist
94
+ * @throws {WorkspaceNotDeployedError} If workspace has no package deployed
95
+ * @throws {TaskNotFoundError} If filter specifies a task that doesn't exist
96
+ * @throws {DataflowError} If execution fails for other reasons
97
+ */
98
+ export declare function dataflowExecute(repoPath: string, ws: string, options?: DataflowOptions): Promise<DataflowResult>;
99
+ /**
100
+ * Start dataflow execution in the background (non-blocking).
101
+ *
102
+ * Returns a promise immediately without awaiting execution. The lock is
103
+ * released automatically when execution completes.
104
+ *
105
+ * @param repoPath - Path to .e3 repository
106
+ * @param ws - Workspace name
107
+ * @param options - Execution options (lock must be provided)
108
+ * @returns Promise that resolves when execution completes
109
+ * @throws {WorkspaceNotFoundError} If workspace doesn't exist
110
+ * @throws {WorkspaceNotDeployedError} If workspace has no package deployed
111
+ * @throws {TaskNotFoundError} If filter specifies a task that doesn't exist
112
+ * @throws {DataflowError} If execution fails for other reasons
113
+ */
114
+ export declare function dataflowStart(repoPath: string, ws: string, options: DataflowOptions & {
115
+ lock: WorkspaceLockHandle;
116
+ }): Promise<DataflowResult>;
117
+ /**
118
+ * Get the dependency graph for a workspace (for visualization/debugging).
119
+ *
120
+ * @param repoPath - Path to .e3 repository
121
+ * @param ws - Workspace name
122
+ * @returns Graph information
123
+ * @throws {WorkspaceNotFoundError} If workspace doesn't exist
124
+ * @throws {WorkspaceNotDeployedError} If workspace has no package deployed
125
+ * @throws {DataflowError} If graph building fails for other reasons
126
+ */
127
+ export declare function dataflowGetGraph(repoPath: string, ws: string): Promise<{
128
+ tasks: Array<{
129
+ name: string;
130
+ hash: string;
131
+ inputs: string[];
132
+ output: string;
133
+ dependsOn: string[];
134
+ }>;
135
+ }>;
136
+ //# sourceMappingURL=dataflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataflow.d.ts","sourceRoot":"","sources":["../../src/dataflow.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAmDH,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,oBAAoB,CAAC;AA2E5B;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,gBAAgB;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,MAAM,EAAE,OAAO,CAAC;IAChB,kBAAkB;IAClB,KAAK,EAAE,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;IAClD,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,iEAAiE;IACjE,OAAO,EAAE,OAAO,CAAC;IACjB,gDAAgD;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,OAAO,EAAE,MAAM,CAAC;IAChB,uBAAuB;IACvB,KAAK,EAAE,mBAAmB,EAAE,CAAC;IAC7B,qCAAqC;IACrC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,sDAAsD;IACtD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yDAAyD;IACzD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,wDAAwD;IACxD,MAAM,CA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