@elaraai/e3-core 0.0.2-beta.3 → 0.0.2-beta.31

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 (184) hide show
  1. package/README.md +25 -22
  2. package/dist/src/dataflow/api-compat.d.ts +90 -0
  3. package/dist/src/dataflow/api-compat.d.ts.map +1 -0
  4. package/dist/src/dataflow/api-compat.js +134 -0
  5. package/dist/src/dataflow/api-compat.js.map +1 -0
  6. package/dist/src/dataflow/index.d.ts +18 -0
  7. package/dist/src/dataflow/index.d.ts.map +1 -0
  8. package/dist/src/dataflow/index.js +23 -0
  9. package/dist/src/dataflow/index.js.map +1 -0
  10. package/dist/src/dataflow/orchestrator/LocalOrchestrator.d.ts +53 -0
  11. package/dist/src/dataflow/orchestrator/LocalOrchestrator.d.ts.map +1 -0
  12. package/dist/src/dataflow/orchestrator/LocalOrchestrator.js +416 -0
  13. package/dist/src/dataflow/orchestrator/LocalOrchestrator.js.map +1 -0
  14. package/dist/src/dataflow/orchestrator/index.d.ts +12 -0
  15. package/dist/src/dataflow/orchestrator/index.d.ts.map +1 -0
  16. package/dist/src/dataflow/orchestrator/index.js +12 -0
  17. package/dist/src/dataflow/orchestrator/index.js.map +1 -0
  18. package/dist/src/dataflow/orchestrator/interfaces.d.ts +157 -0
  19. package/dist/src/dataflow/orchestrator/interfaces.d.ts.map +1 -0
  20. package/dist/src/dataflow/orchestrator/interfaces.js +51 -0
  21. package/dist/src/dataflow/orchestrator/interfaces.js.map +1 -0
  22. package/dist/src/dataflow/state-store/FileStateStore.d.ts +67 -0
  23. package/dist/src/dataflow/state-store/FileStateStore.d.ts.map +1 -0
  24. package/dist/src/dataflow/state-store/FileStateStore.js +286 -0
  25. package/dist/src/dataflow/state-store/FileStateStore.js.map +1 -0
  26. package/dist/src/dataflow/state-store/InMemoryStateStore.d.ts +42 -0
  27. package/dist/src/dataflow/state-store/InMemoryStateStore.d.ts.map +1 -0
  28. package/dist/src/dataflow/state-store/InMemoryStateStore.js +214 -0
  29. package/dist/src/dataflow/state-store/InMemoryStateStore.js.map +1 -0
  30. package/dist/src/dataflow/state-store/index.d.ts +13 -0
  31. package/dist/src/dataflow/state-store/index.d.ts.map +1 -0
  32. package/dist/src/dataflow/state-store/index.js +13 -0
  33. package/dist/src/dataflow/state-store/index.js.map +1 -0
  34. package/dist/src/dataflow/state-store/interfaces.d.ts +159 -0
  35. package/dist/src/dataflow/state-store/interfaces.d.ts.map +1 -0
  36. package/dist/src/dataflow/state-store/interfaces.js +6 -0
  37. package/dist/src/dataflow/state-store/interfaces.js.map +1 -0
  38. package/dist/src/dataflow/steps.d.ts +176 -0
  39. package/dist/src/dataflow/steps.d.ts.map +1 -0
  40. package/dist/src/dataflow/steps.js +528 -0
  41. package/dist/src/dataflow/steps.js.map +1 -0
  42. package/dist/src/dataflow/types.d.ts +116 -0
  43. package/dist/src/dataflow/types.d.ts.map +1 -0
  44. package/dist/src/dataflow/types.js +7 -0
  45. package/dist/src/dataflow/types.js.map +1 -0
  46. package/dist/src/dataflow.d.ts +142 -9
  47. package/dist/src/dataflow.d.ts.map +1 -1
  48. package/dist/src/dataflow.js +427 -64
  49. package/dist/src/dataflow.js.map +1 -1
  50. package/dist/src/errors.d.ts +39 -9
  51. package/dist/src/errors.d.ts.map +1 -1
  52. package/dist/src/errors.js +51 -8
  53. package/dist/src/errors.js.map +1 -1
  54. package/dist/src/execution/LocalTaskRunner.d.ts +73 -0
  55. package/dist/src/execution/LocalTaskRunner.d.ts.map +1 -0
  56. package/dist/src/execution/LocalTaskRunner.js +399 -0
  57. package/dist/src/execution/LocalTaskRunner.js.map +1 -0
  58. package/dist/src/execution/MockTaskRunner.d.ts +49 -0
  59. package/dist/src/execution/MockTaskRunner.d.ts.map +1 -0
  60. package/dist/src/execution/MockTaskRunner.js +55 -0
  61. package/dist/src/execution/MockTaskRunner.js.map +1 -0
  62. package/dist/src/execution/index.d.ts +16 -0
  63. package/dist/src/execution/index.d.ts.map +1 -0
  64. package/dist/src/execution/index.js +8 -0
  65. package/dist/src/execution/index.js.map +1 -0
  66. package/dist/src/execution/interfaces.d.ts +246 -0
  67. package/dist/src/execution/interfaces.d.ts.map +1 -0
  68. package/dist/src/execution/interfaces.js +6 -0
  69. package/dist/src/execution/interfaces.js.map +1 -0
  70. package/dist/src/execution/processHelpers.d.ts +20 -0
  71. package/dist/src/execution/processHelpers.d.ts.map +1 -0
  72. package/dist/src/execution/processHelpers.js +62 -0
  73. package/dist/src/execution/processHelpers.js.map +1 -0
  74. package/dist/src/executions.d.ts +71 -104
  75. package/dist/src/executions.d.ts.map +1 -1
  76. package/dist/src/executions.js +110 -476
  77. package/dist/src/executions.js.map +1 -1
  78. package/dist/src/index.d.ts +17 -9
  79. package/dist/src/index.d.ts.map +1 -1
  80. package/dist/src/index.js +44 -18
  81. package/dist/src/index.js.map +1 -1
  82. package/dist/src/objects.d.ts +6 -53
  83. package/dist/src/objects.d.ts.map +1 -1
  84. package/dist/src/objects.js +11 -232
  85. package/dist/src/objects.js.map +1 -1
  86. package/dist/src/packages.d.ts +22 -14
  87. package/dist/src/packages.d.ts.map +1 -1
  88. package/dist/src/packages.js +116 -83
  89. package/dist/src/packages.js.map +1 -1
  90. package/dist/src/storage/in-memory/InMemoryRepoStore.d.ts +35 -0
  91. package/dist/src/storage/in-memory/InMemoryRepoStore.d.ts.map +1 -0
  92. package/dist/src/storage/in-memory/InMemoryRepoStore.js +107 -0
  93. package/dist/src/storage/in-memory/InMemoryRepoStore.js.map +1 -0
  94. package/dist/src/storage/in-memory/InMemoryStorage.d.ts +114 -0
  95. package/dist/src/storage/in-memory/InMemoryStorage.d.ts.map +1 -0
  96. package/dist/src/storage/in-memory/InMemoryStorage.js +349 -0
  97. package/dist/src/storage/in-memory/InMemoryStorage.js.map +1 -0
  98. package/dist/src/storage/in-memory/index.d.ts +12 -0
  99. package/dist/src/storage/in-memory/index.d.ts.map +1 -0
  100. package/dist/src/storage/in-memory/index.js +12 -0
  101. package/dist/src/storage/in-memory/index.js.map +1 -0
  102. package/dist/src/storage/index.d.ts +18 -0
  103. package/dist/src/storage/index.d.ts.map +1 -0
  104. package/dist/src/storage/index.js +10 -0
  105. package/dist/src/storage/index.js.map +1 -0
  106. package/dist/src/storage/interfaces.d.ts +520 -0
  107. package/dist/src/storage/interfaces.d.ts.map +1 -0
  108. package/dist/src/storage/interfaces.js +6 -0
  109. package/dist/src/storage/interfaces.js.map +1 -0
  110. package/dist/src/storage/local/LocalBackend.d.ts +54 -0
  111. package/dist/src/storage/local/LocalBackend.d.ts.map +1 -0
  112. package/dist/src/storage/local/LocalBackend.js +141 -0
  113. package/dist/src/storage/local/LocalBackend.js.map +1 -0
  114. package/dist/src/storage/local/LocalLockService.d.ts +105 -0
  115. package/dist/src/storage/local/LocalLockService.d.ts.map +1 -0
  116. package/dist/src/storage/local/LocalLockService.js +342 -0
  117. package/dist/src/storage/local/LocalLockService.js.map +1 -0
  118. package/dist/src/storage/local/LocalLogStore.d.ts +23 -0
  119. package/dist/src/storage/local/LocalLogStore.d.ts.map +1 -0
  120. package/dist/src/storage/local/LocalLogStore.js +66 -0
  121. package/dist/src/storage/local/LocalLogStore.js.map +1 -0
  122. package/dist/src/storage/local/LocalObjectStore.d.ts +52 -0
  123. package/dist/src/storage/local/LocalObjectStore.d.ts.map +1 -0
  124. package/dist/src/storage/local/LocalObjectStore.js +287 -0
  125. package/dist/src/storage/local/LocalObjectStore.js.map +1 -0
  126. package/dist/src/storage/local/LocalRefStore.d.ts +50 -0
  127. package/dist/src/storage/local/LocalRefStore.d.ts.map +1 -0
  128. package/dist/src/storage/local/LocalRefStore.js +337 -0
  129. package/dist/src/storage/local/LocalRefStore.js.map +1 -0
  130. package/dist/src/storage/local/LocalRepoStore.d.ts +53 -0
  131. package/dist/src/storage/local/LocalRepoStore.d.ts.map +1 -0
  132. package/dist/src/storage/local/LocalRepoStore.js +353 -0
  133. package/dist/src/storage/local/LocalRepoStore.js.map +1 -0
  134. package/dist/src/storage/local/gc.d.ts +92 -0
  135. package/dist/src/storage/local/gc.d.ts.map +1 -0
  136. package/dist/src/storage/local/gc.js +322 -0
  137. package/dist/src/storage/local/gc.js.map +1 -0
  138. package/dist/src/storage/local/index.d.ts +17 -0
  139. package/dist/src/storage/local/index.d.ts.map +1 -0
  140. package/dist/src/storage/local/index.js +17 -0
  141. package/dist/src/storage/local/index.js.map +1 -0
  142. package/dist/src/storage/local/localHelpers.d.ts +25 -0
  143. package/dist/src/storage/local/localHelpers.d.ts.map +1 -0
  144. package/dist/src/storage/local/localHelpers.js +69 -0
  145. package/dist/src/storage/local/localHelpers.js.map +1 -0
  146. package/dist/src/{repository.d.ts → storage/local/repository.d.ts} +8 -4
  147. package/dist/src/storage/local/repository.d.ts.map +1 -0
  148. package/dist/src/{repository.js → storage/local/repository.js} +31 -29
  149. package/dist/src/storage/local/repository.js.map +1 -0
  150. package/dist/src/tasks.d.ts +16 -10
  151. package/dist/src/tasks.d.ts.map +1 -1
  152. package/dist/src/tasks.js +35 -41
  153. package/dist/src/tasks.js.map +1 -1
  154. package/dist/src/test-helpers.d.ts +4 -4
  155. package/dist/src/test-helpers.d.ts.map +1 -1
  156. package/dist/src/test-helpers.js +7 -21
  157. package/dist/src/test-helpers.js.map +1 -1
  158. package/dist/src/trees.d.ts +89 -27
  159. package/dist/src/trees.d.ts.map +1 -1
  160. package/dist/src/trees.js +218 -100
  161. package/dist/src/trees.js.map +1 -1
  162. package/dist/src/uuid.d.ts +26 -0
  163. package/dist/src/uuid.d.ts.map +1 -0
  164. package/dist/src/uuid.js +80 -0
  165. package/dist/src/uuid.js.map +1 -0
  166. package/dist/src/workspaceStatus.d.ts +6 -4
  167. package/dist/src/workspaceStatus.d.ts.map +1 -1
  168. package/dist/src/workspaceStatus.js +43 -49
  169. package/dist/src/workspaceStatus.js.map +1 -1
  170. package/dist/src/workspaces.d.ts +35 -26
  171. package/dist/src/workspaces.d.ts.map +1 -1
  172. package/dist/src/workspaces.js +169 -118
  173. package/dist/src/workspaces.js.map +1 -1
  174. package/package.json +4 -4
  175. package/dist/src/gc.d.ts +0 -54
  176. package/dist/src/gc.d.ts.map +0 -1
  177. package/dist/src/gc.js +0 -233
  178. package/dist/src/gc.js.map +0 -1
  179. package/dist/src/repository.d.ts.map +0 -1
  180. package/dist/src/repository.js.map +0 -1
  181. package/dist/src/workspaceLock.d.ts +0 -67
  182. package/dist/src/workspaceLock.d.ts.map +0 -1
  183. package/dist/src/workspaceLock.js +0 -217
  184. package/dist/src/workspaceLock.js.map +0 -1
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ import * as fs from 'fs/promises';
6
+ import * as path from 'path';
7
+ import { isNotFoundError } from '../../errors.js';
8
+ /**
9
+ * Local filesystem implementation of LogStore.
10
+ *
11
+ * Logs are stored as text files in the execution directory:
12
+ * executions/<taskHash>/<inputsHash>/<executionId>/stdout.txt
13
+ * executions/<taskHash>/<inputsHash>/<executionId>/stderr.txt
14
+ *
15
+ * The `repo` parameter is the path to the e3 repository directory.
16
+ */
17
+ export class LocalLogStore {
18
+ logPath(repo, taskHash, inputsHash, executionId, stream) {
19
+ return path.join(repo, 'executions', taskHash, inputsHash, executionId, `${stream}.txt`);
20
+ }
21
+ async append(repo, taskHash, inputsHash, executionId, stream, data) {
22
+ const logFile = this.logPath(repo, taskHash, inputsHash, executionId, stream);
23
+ const dir = path.dirname(logFile);
24
+ await fs.mkdir(dir, { recursive: true });
25
+ await fs.appendFile(logFile, data);
26
+ }
27
+ async read(repo, taskHash, inputsHash, executionId, stream, options) {
28
+ const logFile = this.logPath(repo, taskHash, inputsHash, executionId, stream);
29
+ const offset = options?.offset ?? 0;
30
+ const limit = options?.limit ?? 65536; // 64KB default
31
+ try {
32
+ const stat = await fs.stat(logFile);
33
+ const totalSize = stat.size;
34
+ // Open file and read chunk
35
+ const fd = await fs.open(logFile, 'r');
36
+ try {
37
+ const buffer = Buffer.alloc(Math.min(limit, Math.max(0, totalSize - offset)));
38
+ const { bytesRead } = await fd.read(buffer, 0, buffer.length, offset);
39
+ return {
40
+ data: buffer.slice(0, bytesRead).toString('utf-8'),
41
+ offset,
42
+ size: bytesRead,
43
+ totalSize,
44
+ complete: offset + bytesRead >= totalSize,
45
+ };
46
+ }
47
+ finally {
48
+ await fd.close();
49
+ }
50
+ }
51
+ catch (err) {
52
+ if (isNotFoundError(err)) {
53
+ // Log file doesn't exist yet
54
+ return {
55
+ data: '',
56
+ offset: 0,
57
+ size: 0,
58
+ totalSize: 0,
59
+ complete: true,
60
+ };
61
+ }
62
+ throw err;
63
+ }
64
+ }
65
+ }
66
+ //# sourceMappingURL=LocalLogStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalLogStore.js","sourceRoot":"","sources":["../../../../src/storage/local/LocalLogStore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;;;;;;GAQG;AACH,MAAM,OAAO,aAAa;IAChB,OAAO,CAAC,IAAY,EAAE,QAAgB,EAAE,UAAkB,EAAE,WAAmB,EAAE,MAA2B;QAClH,OAAO,IAAI,CAAC,IAAI,CACd,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,WAAW,EACX,GAAG,MAAM,MAAM,CAChB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CACV,IAAY,EACZ,QAAgB,EAChB,UAAkB,EAClB,WAAmB,EACnB,MAA2B,EAC3B,IAAY;QAEZ,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;QAC9E,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC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AAE,SAAS;oBACf,SAAS;oBACT,QAAQ,EAAE,MAAM,GAAG,SAAS,IAAI,SAAS;iBAC1C,CAAC;YACJ,CAAC;oBAAS,CAAC;gBACT,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC;YACnB,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC;gBACzB,6BAA6B;gBAC7B,OAAO;oBACL,IAAI,EAAE,EAAE;oBACR,MAAM,EAAE,CAAC;oBACT,IAAI,EAAE,CAAC;oBACP,SAAS,EAAE,CAAC;oBACZ,QAAQ,EAAE,IAAI;iBACf,CAAC;YACJ,CAAC;YACD,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ import type { ObjectStore } from '../interfaces.js';
6
+ /**
7
+ * Atomically write an object to the repository.
8
+ *
9
+ * @param repoPath - Path to e3 repository
10
+ * @param data - Data to store
11
+ * @returns SHA256 hash of the data
12
+ */
13
+ export declare function objectWrite(repoPath: string, data: Uint8Array): Promise<string>;
14
+ /**
15
+ * Atomically write a stream to the repository.
16
+ *
17
+ * @param repoPath - Path to e3 repository
18
+ * @param stream - Stream to store
19
+ * @returns SHA256 hash of the data
20
+ */
21
+ export declare function objectWriteStream(repoPath: string, stream: ReadableStream<Uint8Array>): Promise<string>;
22
+ /**
23
+ * Read an object from the repository.
24
+ *
25
+ * @param repoPath - Path to e3 repository
26
+ * @param hash - SHA256 hash of the object
27
+ * @returns Object data
28
+ * @throws {ObjectNotFoundError} If object not found
29
+ */
30
+ export declare function objectRead(repoPath: string, hash: string): Promise<Uint8Array>;
31
+ /**
32
+ * Check if an object exists in the repository.
33
+ *
34
+ * @param repoPath - Path to e3 repository
35
+ * @param hash - SHA256 hash of the object
36
+ * @returns true if object exists
37
+ */
38
+ export declare function objectExists(repoPath: string, hash: string): Promise<boolean>;
39
+ /**
40
+ * Local filesystem implementation of ObjectStore.
41
+ *
42
+ * The `repo` parameter is the path to the e3 repository directory.
43
+ */
44
+ export declare class LocalObjectStore implements ObjectStore {
45
+ write(repo: string, data: Uint8Array): Promise<string>;
46
+ writeStream(repo: string, stream: AsyncIterable<Uint8Array>): Promise<string>;
47
+ read(repo: string, hash: string): Promise<Uint8Array>;
48
+ exists(repo: string, hash: string): Promise<boolean>;
49
+ list(repo: string): Promise<string[]>;
50
+ count(repo: string): Promise<number>;
51
+ }
52
+ //# sourceMappingURL=LocalObjectStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalObjectStore.d.ts","sourceRoot":"","sources":["../../../../src/storage/local/LocalObjectStore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAqBH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAoCpD;;;;;;GAMG;AACH,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,MAAM,CAAC,CAkDjB;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,GACjC,OAAO,CAAC,MAAM,CAAC,CAuDjB;AAED;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,UAAU,CAAC,CAerB;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,OAAO,CAAC,CASlB;AAMD;;;;GAIG;AACH,qBAAa,gBAAiB,YAAW,WAAW;IAC5C,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAItD,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAa7E,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAIrD,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIpD,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAiCrC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CA0B3C"}
@@ -0,0 +1,287 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ /**
6
+ * Local filesystem implementation of object storage.
7
+ *
8
+ * Objects are stored as files in a content-addressed layout:
9
+ * - objects/<hash[0..2]>/<hash[2..]>.beast2
10
+ *
11
+ * Writes are atomic using stage-and-rename pattern:
12
+ * 1. Write to a temporary .partial file
13
+ * 2. Rename to final destination (atomic on POSIX filesystems)
14
+ */
15
+ import * as fs from 'fs/promises';
16
+ import * as path from 'path';
17
+ import * as crypto from 'crypto';
18
+ import { Readable } from 'stream';
19
+ import { pipeline } from 'stream/promises';
20
+ import { createWriteStream } from 'fs';
21
+ import { ObjectNotFoundError, isNotFoundError } from '../../errors.js';
22
+ import { objectPath } from './localHelpers.js';
23
+ // =============================================================================
24
+ // Hash Computation
25
+ // =============================================================================
26
+ /**
27
+ * Calculate SHA256 hash of a stream
28
+ * @internal
29
+ */
30
+ async function computeHashFromStream(stream) {
31
+ const hash = crypto.createHash('sha256');
32
+ const chunks = [];
33
+ const reader = stream.getReader();
34
+ while (true) {
35
+ const { done, value } = await reader.read();
36
+ if (done)
37
+ break;
38
+ hash.update(value);
39
+ chunks.push(value);
40
+ }
41
+ return {
42
+ hash: hash.digest('hex'),
43
+ data: chunks,
44
+ };
45
+ }
46
+ // =============================================================================
47
+ // Standalone Functions (for backwards compatibility)
48
+ // =============================================================================
49
+ /**
50
+ * Atomically write an object to the repository.
51
+ *
52
+ * @param repoPath - Path to e3 repository
53
+ * @param data - Data to store
54
+ * @returns SHA256 hash of the data
55
+ */
56
+ export async function objectWrite(repoPath, data) {
57
+ const { computeHash } = await import('../../objects.js');
58
+ const extension = '.beast2';
59
+ const hash = computeHash(data);
60
+ // Split hash: first 2 chars as directory
61
+ const dirName = hash.slice(0, 2);
62
+ const fileName = hash.slice(2) + extension;
63
+ const dirPath = path.join(repoPath, 'objects', dirName);
64
+ const filePath = path.join(dirPath, fileName);
65
+ // Check if already exists
66
+ try {
67
+ await fs.access(filePath);
68
+ return hash; // Already exists
69
+ }
70
+ catch {
71
+ // Doesn't exist, continue
72
+ }
73
+ // Create directory if needed
74
+ await fs.mkdir(dirPath, { recursive: true });
75
+ // Write atomically: stage in same directory (same filesystem) + rename
76
+ // Staging files use .partial extension; gc can clean up any orphaned ones
77
+ // Use random suffix to avoid collisions with concurrent writes
78
+ const randomSuffix = Math.random().toString(36).slice(2, 10);
79
+ const stagingPath = path.join(dirPath, `${fileName}.${Date.now()}.${randomSuffix}.partial`);
80
+ await fs.writeFile(stagingPath, data);
81
+ try {
82
+ await fs.rename(stagingPath, filePath);
83
+ }
84
+ catch (err) {
85
+ // If rename fails because target exists (concurrent write won), that's fine
86
+ // Clean up our staging file
87
+ try {
88
+ await fs.unlink(stagingPath);
89
+ }
90
+ catch {
91
+ // Ignore cleanup errors
92
+ }
93
+ // Verify the file exists (another writer should have created it)
94
+ try {
95
+ await fs.access(filePath);
96
+ }
97
+ catch {
98
+ // File doesn't exist and rename failed - re-throw original error
99
+ throw err;
100
+ }
101
+ }
102
+ return hash;
103
+ }
104
+ /**
105
+ * Atomically write a stream to the repository.
106
+ *
107
+ * @param repoPath - Path to e3 repository
108
+ * @param stream - Stream to store
109
+ * @returns SHA256 hash of the data
110
+ */
111
+ export async function objectWriteStream(repoPath, stream) {
112
+ const extension = '.beast2';
113
+ // First pass: compute hash while collecting data
114
+ const { hash, data } = await computeHashFromStream(stream);
115
+ // Split hash: first 2 chars as directory
116
+ const dirName = hash.slice(0, 2);
117
+ const fileName = hash.slice(2) + extension;
118
+ const dirPath = path.join(repoPath, 'objects', dirName);
119
+ const filePath = path.join(dirPath, fileName);
120
+ // Check if already exists
121
+ try {
122
+ await fs.access(filePath);
123
+ return hash; // Already exists
124
+ }
125
+ catch {
126
+ // Doesn't exist, continue
127
+ }
128
+ // Create directory if needed
129
+ await fs.mkdir(dirPath, { recursive: true });
130
+ // Write atomically: stage in same directory (same filesystem) + rename
131
+ // Staging files use .partial extension; gc can clean up any orphaned ones
132
+ // Use random suffix to avoid collisions with concurrent writes
133
+ const randomSuffix = Math.random().toString(36).slice(2, 10);
134
+ const stagingPath = path.join(dirPath, `${fileName}.${Date.now()}.${randomSuffix}.partial`);
135
+ // Reconstruct stream from collected chunks
136
+ const nodeStream = Readable.from(data);
137
+ const writeStream = createWriteStream(stagingPath);
138
+ await pipeline(nodeStream, writeStream);
139
+ try {
140
+ await fs.rename(stagingPath, filePath);
141
+ }
142
+ catch (err) {
143
+ // If rename fails because target exists (concurrent write won), that's fine
144
+ // Clean up our staging file
145
+ try {
146
+ await fs.unlink(stagingPath);
147
+ }
148
+ catch {
149
+ // Ignore cleanup errors
150
+ }
151
+ // Verify the file exists (another writer should have created it)
152
+ try {
153
+ await fs.access(filePath);
154
+ }
155
+ catch {
156
+ // File doesn't exist and rename failed - re-throw original error
157
+ throw err;
158
+ }
159
+ }
160
+ return hash;
161
+ }
162
+ /**
163
+ * Read an object from the repository.
164
+ *
165
+ * @param repoPath - Path to e3 repository
166
+ * @param hash - SHA256 hash of the object
167
+ * @returns Object data
168
+ * @throws {ObjectNotFoundError} If object not found
169
+ */
170
+ export async function objectRead(repoPath, hash) {
171
+ const extension = '.beast2';
172
+ const dirName = hash.slice(0, 2);
173
+ const fileName = hash.slice(2) + extension;
174
+ const filePath = path.join(repoPath, 'objects', dirName, fileName);
175
+ try {
176
+ return await fs.readFile(filePath);
177
+ }
178
+ catch (err) {
179
+ if (isNotFoundError(err)) {
180
+ throw new ObjectNotFoundError(hash);
181
+ }
182
+ throw err;
183
+ }
184
+ }
185
+ /**
186
+ * Check if an object exists in the repository.
187
+ *
188
+ * @param repoPath - Path to e3 repository
189
+ * @param hash - SHA256 hash of the object
190
+ * @returns true if object exists
191
+ */
192
+ export async function objectExists(repoPath, hash) {
193
+ const filePath = objectPath(repoPath, hash);
194
+ try {
195
+ await fs.access(filePath);
196
+ return true;
197
+ }
198
+ catch {
199
+ return false;
200
+ }
201
+ }
202
+ // =============================================================================
203
+ // ObjectStore Interface Implementation
204
+ // =============================================================================
205
+ /**
206
+ * Local filesystem implementation of ObjectStore.
207
+ *
208
+ * The `repo` parameter is the path to the e3 repository directory.
209
+ */
210
+ export class LocalObjectStore {
211
+ async write(repo, data) {
212
+ return objectWrite(repo, data);
213
+ }
214
+ async writeStream(repo, stream) {
215
+ // Convert AsyncIterable to ReadableStream for objectWriteStream
216
+ const readableStream = new ReadableStream({
217
+ async start(controller) {
218
+ for await (const chunk of stream) {
219
+ controller.enqueue(chunk);
220
+ }
221
+ controller.close();
222
+ },
223
+ });
224
+ return objectWriteStream(repo, readableStream);
225
+ }
226
+ async read(repo, hash) {
227
+ return objectRead(repo, hash);
228
+ }
229
+ async exists(repo, hash) {
230
+ return objectExists(repo, hash);
231
+ }
232
+ async list(repo) {
233
+ const objectsDir = path.join(repo, 'objects');
234
+ const hashes = [];
235
+ try {
236
+ const prefixDirs = await fs.readdir(objectsDir);
237
+ for (const prefix of prefixDirs) {
238
+ if (!/^[a-f0-9]{2}$/.test(prefix))
239
+ continue;
240
+ const prefixPath = path.join(objectsDir, prefix);
241
+ const stat = await fs.stat(prefixPath);
242
+ if (!stat.isDirectory())
243
+ continue;
244
+ const files = await fs.readdir(prefixPath);
245
+ for (const file of files) {
246
+ if (file.endsWith('.beast2') && !file.includes('.partial')) {
247
+ // Reconstruct full hash: prefix + filename without extension
248
+ const hash = prefix + file.slice(0, -7);
249
+ hashes.push(hash);
250
+ }
251
+ }
252
+ }
253
+ }
254
+ catch (err) {
255
+ // Only suppress ENOENT - directory may not exist yet
256
+ if (!isNotFoundError(err)) {
257
+ throw err;
258
+ }
259
+ }
260
+ return hashes;
261
+ }
262
+ async count(repo) {
263
+ const objectsDir = path.join(repo, 'objects');
264
+ let count = 0;
265
+ try {
266
+ const prefixDirs = await fs.readdir(objectsDir);
267
+ for (const prefix of prefixDirs) {
268
+ if (!/^[a-f0-9]{2}$/.test(prefix))
269
+ continue;
270
+ const prefixPath = path.join(objectsDir, prefix);
271
+ const files = await fs.readdir(prefixPath);
272
+ for (const file of files) {
273
+ if (file.endsWith('.beast2') && !file.includes('.partial')) {
274
+ count++;
275
+ }
276
+ }
277
+ }
278
+ }
279
+ catch (err) {
280
+ if (!isNotFoundError(err)) {
281
+ throw err;
282
+ }
283
+ }
284
+ return count;
285
+ }
286
+ }
287
+ //# sourceMappingURL=LocalObjectStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalObjectStore.js","sourceRoot":"","sources":["../../../../src/storage/local/LocalObjectStore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,IAAI,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MA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I,EAAE,SAAS,CAAC,CAAC;QAC9C,IAAI,KAAK,GAAG,CAAC,CAAC;QAEd,IAAI,CAAC;YACH,MAAM,UAAU,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YAEhD,KAAK,MAAM,MAAM,IAAI,UAAU,EAAE,CAAC;gBAChC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC;oBAAE,SAAS;gBAE5C,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;gBACjD,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;gBAC3C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;oBACzB,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;wBAC3D,KAAK,EAAE,CAAC;oBACV,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC1B,MAAM,GAAG,CAAC;YACZ,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ import type { ExecutionStatus, DataflowRun } from '@elaraai/e3-types';
6
+ import type { RefStore } from '../interfaces.js';
7
+ /**
8
+ * Local filesystem implementation of RefStore.
9
+ *
10
+ * The `repo` parameter is the path to the e3 repository directory.
11
+ */
12
+ export declare class LocalRefStore implements RefStore {
13
+ packageList(repo: string): Promise<{
14
+ name: string;
15
+ version: string;
16
+ }[]>;
17
+ packageResolve(repo: string, name: string, version: string): Promise<string | null>;
18
+ packageWrite(repo: string, name: string, version: string, hash: string): Promise<void>;
19
+ packageRemove(repo: string, name: string, version: string): Promise<void>;
20
+ workspaceList(repo: string): Promise<string[]>;
21
+ workspaceRead(repo: string, name: string): Promise<Uint8Array | null>;
22
+ workspaceWrite(repo: string, name: string, state: Uint8Array): Promise<void>;
23
+ workspaceRemove(repo: string, name: string): Promise<void>;
24
+ /**
25
+ * Path to execution directory: executions/<taskHash>/<inputsHash>/<executionId>/
26
+ */
27
+ private executionDir;
28
+ /**
29
+ * Path to inputs directory: executions/<taskHash>/<inputsHash>/
30
+ */
31
+ private inputsDir;
32
+ executionGet(repo: string, taskHash: string, inputsHash: string, executionId: string): Promise<ExecutionStatus | null>;
33
+ executionWrite(repo: string, taskHash: string, inputsHash: string, executionId: string, status: ExecutionStatus): Promise<void>;
34
+ executionListIds(repo: string, taskHash: string, inputsHash: string): Promise<string[]>;
35
+ executionGetLatest(repo: string, taskHash: string, inputsHash: string): Promise<ExecutionStatus | null>;
36
+ executionGetLatestOutput(repo: string, taskHash: string, inputsHash: string): Promise<string | null>;
37
+ executionList(repo: string): Promise<{
38
+ taskHash: string;
39
+ inputsHash: string;
40
+ }[]>;
41
+ executionListForTask(repo: string, taskHash: string): Promise<string[]>;
42
+ private dataflowDir;
43
+ private dataflowRunPath;
44
+ dataflowRunGet(repo: string, workspace: string, runId: string): Promise<DataflowRun | null>;
45
+ dataflowRunWrite(repo: string, workspace: string, run: DataflowRun): Promise<void>;
46
+ dataflowRunList(repo: string, workspace: string): Promise<string[]>;
47
+ dataflowRunGetLatest(repo: string, workspace: string): Promise<DataflowRun | null>;
48
+ dataflowRunDelete(repo: string, workspace: string, runId: string): Promise<void>;
49
+ }
50
+ //# sourceMappingURL=LocalRefStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalRefStore.d.ts","sourceRoot":"","sources":["../../../../src/storage/local/LocalRefStore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,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