@undefineds.co/xpod 0.3.6 → 0.3.15

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 (249) hide show
  1. package/config/cli.json +1 -1
  2. package/config/cloud.json +54 -22
  3. package/config/local.json +56 -12
  4. package/config/resolver.json +10 -2
  5. package/config/xpod.base.json +50 -0
  6. package/config/xpod.json +8 -8
  7. package/dist/agents/config/resolve.js +10 -10
  8. package/dist/agents/config/resolve.js.map +1 -1
  9. package/dist/api/chatkit/index.d.ts +1 -1
  10. package/dist/api/chatkit/index.js.map +1 -1
  11. package/dist/api/chatkit/pod-store.d.ts +14 -11
  12. package/dist/api/chatkit/pod-store.js +114 -78
  13. package/dist/api/chatkit/pod-store.js.map +1 -1
  14. package/dist/api/chatkit/runtime/AcpAgentRuntime.js +1 -1
  15. package/dist/api/chatkit/runtime/AcpAgentRuntime.js.map +1 -1
  16. package/dist/api/chatkit/service.js +1 -1
  17. package/dist/api/chatkit/service.js.map +1 -1
  18. package/dist/api/chatkit/types.d.ts +11 -11
  19. package/dist/api/chatkit/types.js +3 -3
  20. package/dist/api/chatkit/types.js.map +1 -1
  21. package/dist/api/container/cloud.js +0 -8
  22. package/dist/api/container/cloud.js.map +1 -1
  23. package/dist/api/container/index.js +2 -1
  24. package/dist/api/container/index.js.map +1 -1
  25. package/dist/api/container/local.js +0 -7
  26. package/dist/api/container/local.js.map +1 -1
  27. package/dist/api/container/routes.js +3 -17
  28. package/dist/api/container/routes.js.map +1 -1
  29. package/dist/api/container/types.d.ts +0 -2
  30. package/dist/api/container/types.js.map +1 -1
  31. package/dist/api/handlers/PodManagementHandler.d.ts +3 -0
  32. package/dist/api/handlers/PodManagementHandler.js +71 -1
  33. package/dist/api/handlers/PodManagementHandler.js.map +1 -1
  34. package/dist/api/handlers/RunHandler.js +5 -5
  35. package/dist/api/handlers/RunHandler.js.map +1 -1
  36. package/dist/api/runs/AgentRuntimeTypes.d.ts +7 -8
  37. package/dist/api/runs/AgentRuntimeTypes.js.map +1 -1
  38. package/dist/api/runs/InngestRunExecutionBackend.d.ts +2 -2
  39. package/dist/api/runs/ManagedRunWorker.d.ts +1 -1
  40. package/dist/api/runs/ManagedRunWorker.js +6 -6
  41. package/dist/api/runs/ManagedRunWorker.js.map +1 -1
  42. package/dist/api/runs/PiAgentRuntimeDriver.d.ts +16 -1
  43. package/dist/api/runs/PiAgentRuntimeDriver.js +182 -23
  44. package/dist/api/runs/PiAgentRuntimeDriver.js.map +1 -1
  45. package/dist/api/runs/RunStateCenter.d.ts +3 -3
  46. package/dist/api/runs/RunStateCenter.js +13 -13
  47. package/dist/api/runs/RunStateCenter.js.map +1 -1
  48. package/dist/api/runs/store.d.ts +4 -4
  49. package/dist/api/runs/store.js +2 -2
  50. package/dist/api/runs/store.js.map +1 -1
  51. package/dist/api/service/VectorStoreService.d.ts +1 -1
  52. package/dist/api/service/VectorStoreService.js +16 -16
  53. package/dist/api/service/VectorStoreService.js.map +1 -1
  54. package/dist/api/tasks/InngestTaskScheduler.d.ts +4 -4
  55. package/dist/api/tasks/TaskMaterializer.d.ts +3 -3
  56. package/dist/api/tasks/TaskMaterializer.js +11 -11
  57. package/dist/api/tasks/TaskMaterializer.js.map +1 -1
  58. package/dist/api/tasks/TaskService.d.ts +3 -3
  59. package/dist/api/tasks/TaskService.js +11 -7
  60. package/dist/api/tasks/TaskService.js.map +1 -1
  61. package/dist/api/tasks/store.d.ts +10 -4
  62. package/dist/api/tasks/store.js +14 -4
  63. package/dist/api/tasks/store.js.map +1 -1
  64. package/dist/api/workspace/types.d.ts +3 -3
  65. package/dist/api/workspace/types.js +6 -6
  66. package/dist/api/workspace/types.js.map +1 -1
  67. package/dist/cli/commands/config.js +2 -2
  68. package/dist/cli/commands/config.js.map +1 -1
  69. package/dist/cli/commands/start.js +9 -3
  70. package/dist/cli/commands/start.js.map +1 -1
  71. package/dist/components/components.jsonld +8 -2
  72. package/dist/components/context.jsonld +308 -51
  73. package/dist/http/search/SearchHttpHandler.js +8 -8
  74. package/dist/http/search/SearchHttpHandler.js.map +1 -1
  75. package/dist/identity/drizzle/PodLookupRepository.d.ts +11 -1
  76. package/dist/identity/drizzle/PodLookupRepository.js +95 -4
  77. package/dist/identity/drizzle/PodLookupRepository.js.map +1 -1
  78. package/dist/identity/drizzle/db.js +4 -43
  79. package/dist/identity/drizzle/db.js.map +1 -1
  80. package/dist/identity/drizzle/schema.pg.d.ts +0 -5
  81. package/dist/identity/drizzle/schema.pg.js +2 -16
  82. package/dist/identity/drizzle/schema.pg.js.map +1 -1
  83. package/dist/identity/drizzle/schema.sqlite.d.ts +19 -176
  84. package/dist/identity/drizzle/schema.sqlite.js +2 -16
  85. package/dist/identity/drizzle/schema.sqlite.js.map +1 -1
  86. package/dist/identity/oidc/AutoDetectIdentityProviderHandler.d.ts +4 -4
  87. package/dist/identity/oidc/AutoDetectIdentityProviderHandler.js +7 -7
  88. package/dist/identity/oidc/AutoDetectIdentityProviderHandler.js.map +1 -1
  89. package/dist/identity/oidc/AutoDetectIdentityProviderHandler.jsonld +6 -6
  90. package/dist/identity/oidc/AutoDetectOidcHandler.d.ts +4 -4
  91. package/dist/identity/oidc/AutoDetectOidcHandler.js +6 -6
  92. package/dist/identity/oidc/AutoDetectOidcHandler.js.map +1 -1
  93. package/dist/identity/oidc/AutoDetectOidcHandler.jsonld +6 -6
  94. package/dist/identity/oidc/ScopedPickWebIdHandler.d.ts +37 -0
  95. package/dist/identity/oidc/ScopedPickWebIdHandler.js +211 -0
  96. package/dist/identity/oidc/ScopedPickWebIdHandler.js.map +1 -0
  97. package/dist/identity/oidc/ScopedPickWebIdHandler.jsonld +158 -0
  98. package/dist/index.d.ts +12 -2
  99. package/dist/index.js +16 -4
  100. package/dist/index.js.map +1 -1
  101. package/dist/main.js +8 -2
  102. package/dist/main.js.map +1 -1
  103. package/dist/provision/ProvisionPodCreator.d.ts +3 -4
  104. package/dist/provision/ProvisionPodCreator.js +8 -13
  105. package/dist/provision/ProvisionPodCreator.js.map +1 -1
  106. package/dist/provision/ProvisionPodCreator.jsonld +7 -7
  107. package/dist/runtime/Proxy.d.ts +0 -1
  108. package/dist/runtime/Proxy.js +0 -9
  109. package/dist/runtime/Proxy.js.map +1 -1
  110. package/dist/runtime/bootstrap.d.ts +1 -0
  111. package/dist/runtime/bootstrap.js +5 -2
  112. package/dist/runtime/bootstrap.js.map +1 -1
  113. package/dist/runtime/css-process.d.ts +12 -4
  114. package/dist/runtime/css-process.js +61 -14
  115. package/dist/runtime/css-process.js.map +1 -1
  116. package/dist/runtime/oidc-issuer.d.ts +3 -2
  117. package/dist/runtime/oidc-issuer.js +3 -2
  118. package/dist/runtime/oidc-issuer.js.map +1 -1
  119. package/dist/runtime/runtime-types.d.ts +1 -0
  120. package/dist/runtime/runtime-types.js.map +1 -1
  121. package/dist/solidfs/LocalFirstRdfRepresentationResolver.d.ts +21 -0
  122. package/dist/solidfs/LocalFirstRdfRepresentationResolver.js +38 -0
  123. package/dist/solidfs/LocalFirstRdfRepresentationResolver.js.map +1 -0
  124. package/dist/solidfs/LocalSolidFS.d.ts +18 -0
  125. package/dist/solidfs/LocalSolidFS.js +539 -0
  126. package/dist/solidfs/LocalSolidFS.js.map +1 -0
  127. package/dist/solidfs/PodSolidFsHttpClient.d.ts +16 -0
  128. package/dist/solidfs/PodSolidFsHttpClient.js +93 -0
  129. package/dist/solidfs/PodSolidFsHttpClient.js.map +1 -0
  130. package/dist/solidfs/PodSolidFsHydrator.d.ts +27 -0
  131. package/dist/solidfs/PodSolidFsHydrator.js +127 -0
  132. package/dist/solidfs/PodSolidFsHydrator.js.map +1 -0
  133. package/dist/solidfs/PodSolidFsSyncer.d.ts +21 -0
  134. package/dist/solidfs/PodSolidFsSyncer.js +78 -0
  135. package/dist/solidfs/PodSolidFsSyncer.js.map +1 -0
  136. package/dist/solidfs/RdfIndexSolidFsSyncer.d.ts +22 -0
  137. package/dist/solidfs/RdfIndexSolidFsSyncer.js +131 -0
  138. package/dist/solidfs/RdfIndexSolidFsSyncer.js.map +1 -0
  139. package/dist/solidfs/index.d.ts +7 -0
  140. package/dist/solidfs/index.js +24 -0
  141. package/dist/solidfs/index.js.map +1 -0
  142. package/dist/solidfs/types.d.ts +131 -0
  143. package/dist/solidfs/types.js +19 -0
  144. package/dist/solidfs/types.js.map +1 -0
  145. package/dist/storage/RepresentationPartialConvertingStore.js +6 -13
  146. package/dist/storage/RepresentationPartialConvertingStore.js.map +1 -1
  147. package/dist/storage/SparqlUpdateResourceStore.d.ts +4 -0
  148. package/dist/storage/SparqlUpdateResourceStore.js +13 -0
  149. package/dist/storage/SparqlUpdateResourceStore.js.map +1 -1
  150. package/dist/storage/SparqlUpdateResourceStore.jsonld +26 -0
  151. package/dist/storage/accessors/MixDataAccessor.d.ts +85 -4
  152. package/dist/storage/accessors/MixDataAccessor.js +511 -16
  153. package/dist/storage/accessors/MixDataAccessor.js.map +1 -1
  154. package/dist/storage/accessors/MixDataAccessor.jsonld +176 -1
  155. package/dist/storage/accessors/QuintStoreSparqlDataAccessor.d.ts +7 -0
  156. package/dist/storage/accessors/QuintStoreSparqlDataAccessor.js +72 -4
  157. package/dist/storage/accessors/QuintStoreSparqlDataAccessor.js.map +1 -1
  158. package/dist/storage/accessors/QuintStoreSparqlDataAccessor.jsonld +24 -0
  159. package/dist/storage/quint/BaseQuintStore.d.ts +3 -0
  160. package/dist/storage/quint/BaseQuintStore.js +51 -27
  161. package/dist/storage/quint/BaseQuintStore.js.map +1 -1
  162. package/dist/storage/quint/PgQuintStore.d.ts +1 -0
  163. package/dist/storage/quint/PgQuintStore.js +50 -32
  164. package/dist/storage/quint/PgQuintStore.js.map +1 -1
  165. package/dist/storage/quint/PgQuintStore.jsonld +4 -3
  166. package/dist/storage/quint/SqliteQuintStore.d.ts +5 -0
  167. package/dist/storage/quint/SqliteQuintStore.js +100 -0
  168. package/dist/storage/quint/SqliteQuintStore.js.map +1 -1
  169. package/dist/storage/quint/SqliteQuintStore.jsonld +20 -0
  170. package/dist/storage/quint/types.d.ts +16 -0
  171. package/dist/storage/quint/types.js.map +1 -1
  172. package/dist/storage/rdf/Rdf3xTripleIndex.d.ts +55 -0
  173. package/dist/storage/rdf/Rdf3xTripleIndex.js +1235 -0
  174. package/dist/storage/rdf/Rdf3xTripleIndex.js.map +1 -0
  175. package/dist/storage/rdf/RdfContentTypes.d.ts +9 -0
  176. package/dist/storage/rdf/RdfContentTypes.js +79 -0
  177. package/dist/storage/rdf/RdfContentTypes.js.map +1 -0
  178. package/dist/storage/rdf/RdfLocalQueryEngine.d.ts +79 -0
  179. package/dist/storage/rdf/RdfLocalQueryEngine.js +2705 -0
  180. package/dist/storage/rdf/RdfLocalQueryEngine.js.map +1 -0
  181. package/dist/storage/rdf/RdfQuadIndex.d.ts +98 -0
  182. package/dist/storage/rdf/RdfQuadIndex.js +1840 -0
  183. package/dist/storage/rdf/RdfQuadIndex.js.map +1 -0
  184. package/dist/storage/rdf/RdfQuadIndex.jsonld +416 -0
  185. package/dist/storage/rdf/RdfShadowComparator.d.ts +12 -0
  186. package/dist/storage/rdf/RdfShadowComparator.js +47 -0
  187. package/dist/storage/rdf/RdfShadowComparator.js.map +1 -0
  188. package/dist/storage/rdf/RdfSparqlAdapter.d.ts +147 -0
  189. package/dist/storage/rdf/RdfSparqlAdapter.js +2420 -0
  190. package/dist/storage/rdf/RdfSparqlAdapter.js.map +1 -0
  191. package/dist/storage/rdf/RdfSparqlAdapter.jsonld +414 -0
  192. package/dist/storage/rdf/RdfTermDictionary.d.ts +27 -0
  193. package/dist/storage/rdf/RdfTermDictionary.js +352 -0
  194. package/dist/storage/rdf/RdfTermDictionary.js.map +1 -0
  195. package/dist/storage/rdf/RdfTermDictionary.jsonld +114 -0
  196. package/dist/storage/rdf/RdfTermSemantics.d.ts +6 -0
  197. package/dist/storage/rdf/RdfTermSemantics.js +40 -0
  198. package/dist/storage/rdf/RdfTermSemantics.js.map +1 -0
  199. package/dist/storage/rdf/RdfTextIndex.d.ts +23 -0
  200. package/dist/storage/rdf/RdfTextIndex.js +569 -0
  201. package/dist/storage/rdf/RdfTextIndex.js.map +1 -0
  202. package/dist/storage/rdf/RdfVectorIndex.d.ts +22 -0
  203. package/dist/storage/rdf/RdfVectorIndex.js +631 -0
  204. package/dist/storage/rdf/RdfVectorIndex.js.map +1 -0
  205. package/dist/storage/rdf/RdfXmlSerializer.d.ts +2 -0
  206. package/dist/storage/rdf/RdfXmlSerializer.js +123 -0
  207. package/dist/storage/rdf/RdfXmlSerializer.js.map +1 -0
  208. package/dist/storage/rdf/ShadowRdfQuintStore.d.ts +58 -0
  209. package/dist/storage/rdf/ShadowRdfQuintStore.js +202 -0
  210. package/dist/storage/rdf/ShadowRdfQuintStore.js.map +1 -0
  211. package/dist/storage/rdf/ShadowRdfQuintStore.jsonld +308 -0
  212. package/dist/storage/rdf/SolidRdfEngine.d.ts +56 -0
  213. package/dist/storage/rdf/SolidRdfEngine.js +292 -0
  214. package/dist/storage/rdf/SolidRdfEngine.js.map +1 -0
  215. package/dist/storage/rdf/SolidRdfEngine.jsonld +372 -0
  216. package/dist/storage/rdf/SolidRdfSparqlEngine.d.ts +92 -0
  217. package/dist/storage/rdf/SolidRdfSparqlEngine.js +477 -0
  218. package/dist/storage/rdf/SolidRdfSparqlEngine.js.map +1 -0
  219. package/dist/storage/rdf/SolidRdfSparqlEngine.jsonld +257 -0
  220. package/dist/storage/rdf/index.d.ts +15 -0
  221. package/dist/storage/rdf/index.js +61 -0
  222. package/dist/storage/rdf/index.js.map +1 -0
  223. package/dist/storage/rdf/models-benchmark.d.ts +260 -0
  224. package/dist/storage/rdf/models-benchmark.js +1405 -0
  225. package/dist/storage/rdf/models-benchmark.js.map +1 -0
  226. package/dist/storage/rdf/types.d.ts +726 -0
  227. package/dist/storage/rdf/types.js +3 -0
  228. package/dist/storage/rdf/types.js.map +1 -0
  229. package/dist/storage/rdf/types.jsonld +316 -0
  230. package/dist/storage/vector/VectorIndexingListener.d.ts +5 -5
  231. package/dist/storage/vector/VectorIndexingListener.js +19 -19
  232. package/dist/storage/vector/VectorIndexingListener.js.map +1 -1
  233. package/package.json +3 -2
  234. package/templates/pod/acp/.acr.hbs +39 -0
  235. package/templates/pod/acp/README.acr +18 -0
  236. package/templates/pod/acp/profile/card.acr +22 -0
  237. package/templates/pod/base/README$.md.hbs +27 -0
  238. package/templates/pod/base/profile/card$.ttl.hbs +13 -0
  239. package/templates/pod/wac/.acl.hbs +26 -0
  240. package/templates/pod/wac/README.acl.hbs +14 -0
  241. package/templates/pod/wac/profile/card.acl.hbs +19 -0
  242. package/dist/api/handlers/WebIdProfileHandler.d.ts +0 -16
  243. package/dist/api/handlers/WebIdProfileHandler.js +0 -423
  244. package/dist/api/handlers/WebIdProfileHandler.js.map +0 -1
  245. package/dist/identity/drizzle/WebIdProfileRepository.d.ts +0 -63
  246. package/dist/identity/drizzle/WebIdProfileRepository.js +0 -168
  247. package/dist/identity/drizzle/WebIdProfileRepository.js.map +0 -1
  248. package/dist/identity/drizzle/WebIdProfileRepository.jsonld +0 -112
  249. package/dist/storage/quint/BaseQuintStore.jsonld +0 -257
@@ -0,0 +1,539 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.LocalSolidFS = void 0;
7
+ const node_crypto_1 = require("node:crypto");
8
+ const node_fs_1 = require("node:fs");
9
+ const promises_1 = require("node:fs/promises");
10
+ const node_os_1 = __importDefault(require("node:os"));
11
+ const node_path_1 = __importDefault(require("node:path"));
12
+ const node_url_1 = require("node:url");
13
+ const types_1 = require("./types");
14
+ const RdfContentTypes_1 = require("../storage/rdf/RdfContentTypes");
15
+ class LocalSolidFS {
16
+ constructor(options = {}) {
17
+ this.workRoot = options.workRoot ?? node_path_1.default.join(node_os_1.default.tmpdir(), 'xpod-solidfs');
18
+ this.syncer = options.syncer;
19
+ this.hydrator = options.hydrator;
20
+ }
21
+ async prepare(input) {
22
+ const sourceRoot = input.sourcePath
23
+ ? node_path_1.default.resolve(input.sourcePath)
24
+ : this.resolveWorkspacePath(input.workspace);
25
+ const projection = input.projection ?? 'direct';
26
+ await this.assertSourceDirectory(sourceRoot);
27
+ if (projection === 'direct') {
28
+ const trackChanges = this.syncer?.shouldTrack?.(input) ?? Boolean(this.syncer);
29
+ const syncer = this.syncer;
30
+ const changeFilter = trackChanges
31
+ ? syncer?.shouldTrackPath
32
+ ? (relativePath) => syncer.shouldTrackPath(relativePath)
33
+ : isLineAddressableRdfPath
34
+ : undefined;
35
+ const entries = changeFilter ? await snapshotDirectory(sourceRoot, changeFilter) : [];
36
+ return new LocalMaterializedWorkspace({
37
+ sourceRoot,
38
+ cwd: sourceRoot,
39
+ projection,
40
+ cleanupOnRollback: false,
41
+ manifest: this.createManifest(input.workspace, sourceRoot, projection, entries),
42
+ changeFilter,
43
+ context: input.context,
44
+ syncer: this.syncer,
45
+ hydrator: this.hydrator,
46
+ });
47
+ }
48
+ if (projection === 'hydrated-object') {
49
+ const cwd = await this.createHydratedWorkdir(sourceRoot, input.run?.id);
50
+ return new LocalMaterializedWorkspace({
51
+ sourceRoot,
52
+ cwd,
53
+ projection,
54
+ cleanupOnRollback: true,
55
+ manifest: this.createManifest(input.workspace, cwd, projection, []),
56
+ context: input.context,
57
+ hydrator: this.hydrator,
58
+ });
59
+ }
60
+ if (projection !== 'copy') {
61
+ throw new Error(`LocalSolidFS does not support projection '${projection}' yet.`);
62
+ }
63
+ const cwd = await this.createCopyWorkdir(sourceRoot, input.run?.id);
64
+ const entries = await snapshotDirectory(sourceRoot);
65
+ await (0, promises_1.cp)(sourceRoot, cwd, {
66
+ recursive: true,
67
+ force: true,
68
+ errorOnExist: false,
69
+ dereference: false,
70
+ });
71
+ return new LocalMaterializedWorkspace({
72
+ sourceRoot,
73
+ cwd,
74
+ projection,
75
+ cleanupOnRollback: true,
76
+ manifest: this.createManifest(input.workspace, cwd, projection, entries),
77
+ context: input.context,
78
+ syncer: this.syncer,
79
+ hydrator: this.hydrator,
80
+ });
81
+ }
82
+ resolveWorkspacePath(workspace) {
83
+ if (workspace.startsWith('file://')) {
84
+ const url = new URL(workspace);
85
+ const pathname = decodeURIComponent(url.pathname);
86
+ if (process.platform === 'win32' && /^\/[A-Za-z]:/.test(pathname)) {
87
+ return pathname.slice(1);
88
+ }
89
+ return pathname;
90
+ }
91
+ if (node_path_1.default.isAbsolute(workspace)) {
92
+ return workspace;
93
+ }
94
+ throw new Error(`Unsupported workspace '${workspace}'. LocalSolidFS expects file:// or absolute paths.`);
95
+ }
96
+ async createCopyWorkdir(sourceRoot, runId) {
97
+ const safeRun = (runId ?? 'run').replace(/[^a-zA-Z0-9._-]+/gu, '_');
98
+ const prefix = node_path_1.default.join(this.workRoot, `${safeRun}-`);
99
+ await (0, promises_1.mkdir)(this.workRoot, { recursive: true });
100
+ const cwd = await (0, promises_1.mkdtemp)(prefix);
101
+ const sourceName = node_path_1.default.basename(sourceRoot.replace(/[\\/]+$/u, '')) || 'workspace';
102
+ return node_path_1.default.join(cwd, sourceName);
103
+ }
104
+ async createHydratedWorkdir(sourceRoot, runId) {
105
+ const safeRun = (runId ?? 'run').replace(/[^a-zA-Z0-9._-]+/gu, '_');
106
+ await (0, promises_1.mkdir)(this.workRoot, { recursive: true });
107
+ const cwd = await (0, promises_1.mkdtemp)(node_path_1.default.join(this.workRoot, `${safeRun}-hydrated-`));
108
+ const workspaceDir = node_path_1.default.join(cwd, node_path_1.default.basename(sourceRoot.replace(/[\\/]+$/u, '')) || 'workspace');
109
+ await (0, promises_1.mkdir)(workspaceDir, { recursive: true });
110
+ return workspaceDir;
111
+ }
112
+ createManifest(workspace, cwd, projection, snapshots) {
113
+ const source = sourceForProjection(projection, workspace);
114
+ return {
115
+ workspace,
116
+ cwd,
117
+ projection,
118
+ entries: snapshots.map((snapshot) => ({
119
+ path: snapshot.relativePath,
120
+ resource: resolveWorkspaceResource(workspace, snapshot.relativePath),
121
+ source,
122
+ sourcePath: snapshot.absolutePath,
123
+ projection,
124
+ sourceVersion: snapshot.version,
125
+ workingVersion: snapshot.version,
126
+ state: 'clean',
127
+ })),
128
+ };
129
+ }
130
+ async assertSourceDirectory(sourceRoot) {
131
+ let sourceStat;
132
+ try {
133
+ sourceStat = await (0, promises_1.stat)(sourceRoot);
134
+ }
135
+ catch (error) {
136
+ if (error?.code === 'ENOENT' || error?.code === 'ENOTDIR') {
137
+ throw new Error(`SolidFS workspace does not exist: ${sourceRoot}`);
138
+ }
139
+ throw error;
140
+ }
141
+ if (!sourceStat.isDirectory()) {
142
+ throw new Error(`SolidFS workspace is not a directory: ${sourceRoot}`);
143
+ }
144
+ }
145
+ }
146
+ exports.LocalSolidFS = LocalSolidFS;
147
+ class LocalMaterializedWorkspace {
148
+ constructor(options) {
149
+ this.sourceRoot = options.sourceRoot;
150
+ this.cwd = options.cwd;
151
+ this.projection = options.projection;
152
+ this.cleanupOnRollback = options.cleanupOnRollback;
153
+ this.manifest = options.manifest;
154
+ this.changeFilter = options.changeFilter;
155
+ this.context = options.context;
156
+ this.syncer = options.syncer;
157
+ this.hydrator = options.hydrator;
158
+ this.entrySource = sourceForProjection(this.projection, this.manifest.workspace);
159
+ }
160
+ async commit() {
161
+ if (this.projection === 'hydrated-object') {
162
+ return this.commitHydratedObjects();
163
+ }
164
+ const changes = await this.detectChanges();
165
+ this.manifest.changes = changes;
166
+ if (this.projection === 'direct') {
167
+ await this.syncChanges(changes);
168
+ this.markCommitted();
169
+ return this.manifest;
170
+ }
171
+ if (this.projection !== 'copy') {
172
+ throw new Error(`Commit is not implemented for projection '${this.projection}'.`);
173
+ }
174
+ const conflicts = await this.findConflicts();
175
+ if (conflicts.length > 0) {
176
+ for (const entry of this.manifest.entries) {
177
+ if (conflicts.some((conflict) => conflict.path === entry.path)) {
178
+ entry.state = 'conflict';
179
+ }
180
+ }
181
+ throw new types_1.SolidFsConflictError(conflicts);
182
+ }
183
+ await (0, promises_1.rm)(this.sourceRoot, { recursive: true, force: true });
184
+ await (0, promises_1.cp)(this.cwd, this.sourceRoot, {
185
+ recursive: true,
186
+ force: true,
187
+ errorOnExist: false,
188
+ dereference: false,
189
+ });
190
+ await this.syncChanges(changes);
191
+ this.markCommitted();
192
+ return this.manifest;
193
+ }
194
+ async rollback() {
195
+ if (this.cleanupOnRollback) {
196
+ await (0, promises_1.rm)(node_path_1.default.dirname(this.cwd), { recursive: true, force: true });
197
+ }
198
+ }
199
+ async hydrate(relativePath) {
200
+ if (this.projection !== 'hydrated-object') {
201
+ throw new Error(`hydrate() is only supported for hydrated-object projection, not '${this.projection}'`);
202
+ }
203
+ if (!this.hydrator) {
204
+ throw new Error('SolidFS hydrated-object projection requires a hydrator');
205
+ }
206
+ const normalized = safeRelativePath(relativePath);
207
+ const targetPath = node_path_1.default.join(this.cwd, normalized);
208
+ await (0, promises_1.mkdir)(node_path_1.default.dirname(targetPath), { recursive: true });
209
+ const result = await this.hydrator.hydrate({
210
+ path: normalized,
211
+ targetPath,
212
+ workspace: this.manifest,
213
+ context: this.context,
214
+ });
215
+ const workingVersion = await fileVersion(targetPath);
216
+ let entry = this.manifest.entries.find((candidate) => candidate.path === normalized);
217
+ if (!entry) {
218
+ entry = {
219
+ path: normalized,
220
+ resource: resolveWorkspaceResource(this.manifest.workspace, normalized),
221
+ source: this.entrySource,
222
+ sourcePath: targetPath,
223
+ contentType: result?.contentType ?? contentTypeForPath(normalized),
224
+ projection: this.projection,
225
+ sourceVersion: result?.sourceVersion,
226
+ workingVersion,
227
+ lastAccessedAt: Date.now(),
228
+ state: 'clean',
229
+ };
230
+ this.manifest.entries.push(entry);
231
+ this.manifest.entries.sort((left, right) => left.path.localeCompare(right.path));
232
+ return entry;
233
+ }
234
+ entry.sourcePath = targetPath;
235
+ entry.contentType = result?.contentType ?? entry.contentType ?? contentTypeForPath(normalized);
236
+ entry.sourceVersion = result?.sourceVersion ?? entry.sourceVersion;
237
+ entry.workingVersion = workingVersion;
238
+ entry.lastAccessedAt = Date.now();
239
+ entry.state = 'clean';
240
+ return entry;
241
+ }
242
+ async prune(options = {}) {
243
+ if (this.projection !== 'hydrated-object') {
244
+ return this.manifest;
245
+ }
246
+ const now = options.now ?? Date.now();
247
+ const olderThanMs = options.olderThanMs ?? 0;
248
+ const retained = [];
249
+ for (const entry of this.manifest.entries) {
250
+ const currentVersion = await maybeFileVersion(entry.sourcePath);
251
+ const dirty = currentVersion !== undefined && currentVersion !== entry.workingVersion;
252
+ if (dirty) {
253
+ entry.state = 'dirty';
254
+ retained.push(entry);
255
+ continue;
256
+ }
257
+ const age = now - (entry.lastAccessedAt ?? now);
258
+ if (age >= olderThanMs) {
259
+ await (0, promises_1.rm)(entry.sourcePath, { force: true });
260
+ continue;
261
+ }
262
+ retained.push(entry);
263
+ }
264
+ this.manifest.entries = retained;
265
+ return this.manifest;
266
+ }
267
+ async commitHydratedObjects() {
268
+ if (!this.hydrator) {
269
+ throw new Error('SolidFS hydrated-object projection requires a hydrator');
270
+ }
271
+ const changes = await this.detectHydratedChanges();
272
+ this.manifest.changes = changes;
273
+ for (const change of changes) {
274
+ if (change.type === 'deleted' && this.hydrator.delete) {
275
+ await this.hydrator.delete({
276
+ change,
277
+ workspace: this.manifest,
278
+ context: this.context,
279
+ });
280
+ this.manifest.entries = this.manifest.entries.filter((entry) => entry.path !== change.path);
281
+ continue;
282
+ }
283
+ if (change.type !== 'deleted') {
284
+ const result = await this.hydrator.commit({
285
+ change,
286
+ workspace: this.manifest,
287
+ context: this.context,
288
+ });
289
+ const entry = this.manifest.entries.find((candidate) => candidate.path === change.path);
290
+ if (entry) {
291
+ entry.sourceVersion = result?.sourceVersion ?? entry.sourceVersion;
292
+ entry.workingVersion = await fileVersion(entry.sourcePath);
293
+ entry.lastAccessedAt = Date.now();
294
+ }
295
+ }
296
+ }
297
+ this.markCommitted();
298
+ return this.manifest;
299
+ }
300
+ async detectHydratedChanges() {
301
+ const changes = [];
302
+ const tracked = new Set(this.manifest.entries.map((entry) => entry.path));
303
+ for (const entry of this.manifest.entries) {
304
+ const currentVersion = await maybeFileVersion(entry.sourcePath);
305
+ if (currentVersion === undefined) {
306
+ changes.push({
307
+ path: entry.path,
308
+ resource: entry.resource ?? resolveWorkspaceResource(this.manifest.workspace, entry.path),
309
+ source: entry.source,
310
+ sourcePath: entry.sourcePath,
311
+ contentType: entry.contentType,
312
+ projection: this.projection,
313
+ type: 'deleted',
314
+ sourceVersion: entry.sourceVersion,
315
+ });
316
+ entry.state = 'dirty';
317
+ continue;
318
+ }
319
+ if (currentVersion !== entry.workingVersion) {
320
+ changes.push({
321
+ path: entry.path,
322
+ resource: entry.resource ?? resolveWorkspaceResource(this.manifest.workspace, entry.path),
323
+ source: entry.source,
324
+ sourcePath: entry.sourcePath,
325
+ contentType: entry.contentType,
326
+ projection: this.projection,
327
+ type: 'updated',
328
+ sourceVersion: entry.sourceVersion,
329
+ });
330
+ entry.state = 'dirty';
331
+ }
332
+ }
333
+ for (const snapshot of await snapshotDirectory(this.cwd)) {
334
+ if (tracked.has(snapshot.relativePath)) {
335
+ continue;
336
+ }
337
+ this.manifest.entries.push({
338
+ path: snapshot.relativePath,
339
+ resource: resolveWorkspaceResource(this.manifest.workspace, snapshot.relativePath),
340
+ source: this.entrySource,
341
+ sourcePath: snapshot.absolutePath,
342
+ contentType: contentTypeForPath(snapshot.relativePath),
343
+ projection: this.projection,
344
+ workingVersion: snapshot.version,
345
+ lastAccessedAt: Date.now(),
346
+ state: 'dirty',
347
+ });
348
+ changes.push({
349
+ path: snapshot.relativePath,
350
+ resource: resolveWorkspaceResource(this.manifest.workspace, snapshot.relativePath),
351
+ source: this.entrySource,
352
+ sourcePath: snapshot.absolutePath,
353
+ contentType: contentTypeForPath(snapshot.relativePath),
354
+ projection: this.projection,
355
+ type: 'created',
356
+ });
357
+ }
358
+ this.manifest.entries.sort((left, right) => left.path.localeCompare(right.path));
359
+ return changes.sort((left, right) => left.path.localeCompare(right.path));
360
+ }
361
+ async findConflicts() {
362
+ const conflicts = [];
363
+ const initialPaths = new Set(this.manifest.entries.map((entry) => entry.path));
364
+ for (const entry of this.manifest.entries) {
365
+ if (!entry.sourceVersion) {
366
+ continue;
367
+ }
368
+ const currentVersion = await maybeFileVersion(entry.sourcePath);
369
+ if (currentVersion !== entry.sourceVersion) {
370
+ conflicts.push({
371
+ path: entry.path,
372
+ sourcePath: entry.sourcePath,
373
+ expectedVersion: entry.sourceVersion,
374
+ actualVersion: currentVersion,
375
+ message: 'Source file changed after workspace prepare.',
376
+ });
377
+ }
378
+ }
379
+ const currentSourceFiles = await snapshotDirectory(this.sourceRoot);
380
+ for (const current of currentSourceFiles) {
381
+ if (!initialPaths.has(current.relativePath)) {
382
+ conflicts.push({
383
+ path: current.relativePath,
384
+ sourcePath: current.absolutePath,
385
+ actualVersion: current.version,
386
+ message: 'Source file was created after workspace prepare.',
387
+ });
388
+ }
389
+ }
390
+ return conflicts;
391
+ }
392
+ async detectChanges() {
393
+ const before = new Map(this.manifest.entries.map((entry) => [entry.path, entry]));
394
+ if (before.size === 0 && this.projection === 'direct' && !this.changeFilter) {
395
+ return [];
396
+ }
397
+ const after = new Map((await snapshotDirectory(this.cwd, this.changeFilter)).map((snapshot) => [snapshot.relativePath, snapshot]));
398
+ const changes = [];
399
+ for (const [relativePath, snapshot] of after) {
400
+ const entry = before.get(relativePath);
401
+ if (!entry) {
402
+ changes.push(this.createChange(relativePath, snapshot.absolutePath, 'created'));
403
+ continue;
404
+ }
405
+ if (entry.sourceVersion !== snapshot.version) {
406
+ changes.push(this.createChange(relativePath, snapshot.absolutePath, 'updated'));
407
+ }
408
+ }
409
+ for (const [relativePath, entry] of before) {
410
+ if (!after.has(relativePath)) {
411
+ changes.push(this.createChange(relativePath, entry.sourcePath, 'deleted'));
412
+ }
413
+ }
414
+ return changes.sort((left, right) => left.path.localeCompare(right.path));
415
+ }
416
+ createChange(relativePath, sourcePath, type) {
417
+ return {
418
+ path: relativePath,
419
+ resource: resolveWorkspaceResource(this.manifest.workspace, relativePath),
420
+ source: this.entrySource,
421
+ sourcePath,
422
+ contentType: contentTypeForPath(relativePath),
423
+ projection: this.projection,
424
+ type,
425
+ };
426
+ }
427
+ async syncChanges(changes) {
428
+ if (!this.syncer) {
429
+ return;
430
+ }
431
+ for (const change of changes) {
432
+ await this.syncer.sync(change, this.manifest, this.context);
433
+ }
434
+ }
435
+ markCommitted() {
436
+ for (const entry of this.manifest.entries) {
437
+ entry.state = 'committed';
438
+ }
439
+ }
440
+ }
441
+ function contentTypeForPath(filePath) {
442
+ const lower = filePath.toLowerCase();
443
+ const rdfContentType = (0, RdfContentTypes_1.rdfContentTypeForPath)(lower);
444
+ if (rdfContentType) {
445
+ return rdfContentType;
446
+ }
447
+ if (lower.endsWith('.md') || lower.endsWith('.markdown') || lower.endsWith('.mdown')) {
448
+ return 'text/markdown';
449
+ }
450
+ if (lower.endsWith('.txt') || lower.endsWith('.log')) {
451
+ return 'text/plain';
452
+ }
453
+ return undefined;
454
+ }
455
+ function sourceForProjection(projection, workspace) {
456
+ if (projection === 'hydrated-object') {
457
+ return 'object';
458
+ }
459
+ if (/^https?:/u.test(workspace)) {
460
+ return 'pod-http';
461
+ }
462
+ return 'filesystem';
463
+ }
464
+ function resolveWorkspaceResource(workspace, relativePath) {
465
+ if (node_path_1.default.isAbsolute(workspace)) {
466
+ return (0, node_url_1.pathToFileURL)(node_path_1.default.join(workspace, relativePath)).href;
467
+ }
468
+ try {
469
+ const base = new URL(workspace.endsWith('/') ? workspace : `${workspace}/`);
470
+ const normalized = relativePath.split(node_path_1.default.sep).join('/');
471
+ return new URL(normalized, base).href;
472
+ }
473
+ catch {
474
+ return undefined;
475
+ }
476
+ }
477
+ function isLineAddressableRdfPath(filePath) {
478
+ return (0, RdfContentTypes_1.isLineAddressableRdfPath)(filePath);
479
+ }
480
+ function safeRelativePath(input) {
481
+ const normalized = input.split(/[\\/]+/u).filter((part) => part.length > 0).join(node_path_1.default.sep);
482
+ if (!normalized || node_path_1.default.isAbsolute(input) || normalized.split(node_path_1.default.sep).includes('..')) {
483
+ throw new Error(`Invalid SolidFS relative path: ${input}`);
484
+ }
485
+ return normalized;
486
+ }
487
+ async function maybeFileVersion(filePath) {
488
+ try {
489
+ return await fileVersion(filePath);
490
+ }
491
+ catch {
492
+ return undefined;
493
+ }
494
+ }
495
+ async function fileVersion(filePath) {
496
+ const fileStat = await (0, promises_1.stat)(filePath);
497
+ const hash = (0, node_crypto_1.createHash)('sha256');
498
+ await new Promise((resolve, reject) => {
499
+ const stream = (0, node_fs_1.createReadStream)(filePath);
500
+ stream.on('data', (chunk) => hash.update(chunk));
501
+ stream.on('error', reject);
502
+ stream.on('end', resolve);
503
+ });
504
+ return `${fileStat.size}:${fileStat.mtimeMs}:${hash.digest('hex')}`;
505
+ }
506
+ async function snapshotDirectory(root, filter) {
507
+ const snapshots = [];
508
+ async function walk(current) {
509
+ let entries;
510
+ try {
511
+ entries = await (0, promises_1.readdir)(current, { withFileTypes: true });
512
+ }
513
+ catch {
514
+ return;
515
+ }
516
+ for (const entry of entries) {
517
+ const absolute = node_path_1.default.join(current, entry.name);
518
+ const relative = node_path_1.default.relative(root, absolute);
519
+ if (entry.isDirectory()) {
520
+ await walk(absolute);
521
+ continue;
522
+ }
523
+ if (!entry.isFile()) {
524
+ continue;
525
+ }
526
+ if (filter && !filter(relative)) {
527
+ continue;
528
+ }
529
+ snapshots.push({
530
+ relativePath: relative,
531
+ absolutePath: absolute,
532
+ version: await fileVersion(absolute),
533
+ });
534
+ }
535
+ }
536
+ await walk(root);
537
+ return snapshots.sort((left, right) => left.relativePath.localeCompare(right.relativePath));
538
+ }
539
+ //# sourceMappingURL=LocalSolidFS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalSolidFS.js","sourceRoot":"","sources":["../../src/solidfs/LocalSolidFS.ts"],"names":[],"mappings":";;;;;;AAAA,6CAAyC;AACzC,qCAA2C;AAC3C,+CAO0B;AAC1B,sDAAyB;AACzB,0DAA6B;AAC7B,uCAAyC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CAAC;IACH,CAAC;IAED,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC;IACjB,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;AAC9F,CAAC","sourcesContent":["import { createHash } from 'node:crypto';\nimport { createReadStream } from 'node:fs';\nimport {\n cp,\n mkdir,\n mkdtemp,\n readdir,\n rm,\n stat,\n} from 'node:fs/promises';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nimport {\n MaterializedWorkspace,\n SolidFS,\n SolidFsChange,\n SolidFsConflict,\n SolidFsConflictError,\n SolidFsEntrySource,\n SolidFsHydrator,\n SolidFsManifest,\n SolidFsManifestEntry,\n SolidFsPrepareInput,\n SolidFsPruneOptions,\n SolidFsProjection,\n SolidFsSyncer,\n} from './types';\nimport {\n isLineAddressableRdfPath as isRdfPath,\n rdfContentTypeForPath,\n} from '../storage/rdf/RdfContentTypes';\n\ninterface FileSnapshot {\n relativePath: string;\n absolutePath: string;\n version: string;\n}\n\nexport interface LocalSolidFSOptions {\n workRoot?: string;\n syncer?: SolidFsSyncer;\n hydrator?: SolidFsHydrator;\n}\n\nexport class LocalSolidFS implements SolidFS {\n private readonly workRoot: string;\n private readonly syncer?: SolidFsSyncer;\n private readonly hydrator?: SolidFsHydrator;\n\n public constructor(options: LocalSolidFSOptions = {}) {\n this.workRoot = options.workRoot ?? path.join(os.tmpdir(), 'xpod-solidfs');\n this.syncer = options.syncer;\n this.hydrator = options.hydrator;\n }\n\n public async prepare(input: SolidFsPrepareInput): Promise<MaterializedWorkspace> {\n const sourceRoot = input.sourcePath\n ? path.resolve(input.sourcePath)\n : this.resolveWorkspacePath(input.workspace);\n const projection = input.projection ?? 'direct';\n\n await this.assertSourceDirectory(sourceRoot);\n\n if (projection === 'direct') {\n const trackChanges = this.syncer?.shouldTrack?.(input) ?? Boolean(this.syncer);\n const syncer = this.syncer;\n const changeFilter = trackChanges\n ? syncer?.shouldTrackPath\n ? (relativePath: string): boolean => syncer.shouldTrackPath!(relativePath)\n : isLineAddressableRdfPath\n : undefined;\n const entries = changeFilter ? await snapshotDirectory(sourceRoot, changeFilter) : [];\n return new LocalMaterializedWorkspace({\n sourceRoot,\n cwd: sourceRoot,\n projection,\n cleanupOnRollback: false,\n manifest: this.createManifest(input.workspace, sourceRoot, projection, entries),\n changeFilter,\n context: input.context,\n syncer: this.syncer,\n hydrator: this.hydrator,\n });\n }\n\n if (projection === 'hydrated-object') {\n const cwd = await this.createHydratedWorkdir(sourceRoot, input.run?.id);\n return new LocalMaterializedWorkspace({\n sourceRoot,\n cwd,\n projection,\n cleanupOnRollback: true,\n manifest: this.createManifest(input.workspace, cwd, projection, []),\n context: input.context,\n hydrator: this.hydrator,\n });\n }\n\n if (projection !== 'copy') {\n throw new Error(`LocalSolidFS does not support projection '${projection}' yet.`);\n }\n\n const cwd = await this.createCopyWorkdir(sourceRoot, input.run?.id);\n const entries = await snapshotDirectory(sourceRoot);\n await cp(sourceRoot, cwd, {\n recursive: true,\n force: true,\n errorOnExist: false,\n dereference: false,\n });\n\n return new LocalMaterializedWorkspace({\n sourceRoot,\n cwd,\n projection,\n cleanupOnRollback: true,\n manifest: this.createManifest(input.workspace, cwd, projection, entries),\n context: input.context,\n syncer: this.syncer,\n hydrator: this.hydrator,\n });\n }\n\n private resolveWorkspacePath(workspace: string): string {\n if (workspace.startsWith('file://')) {\n const url = new URL(workspace);\n const pathname = decodeURIComponent(url.pathname);\n if (process.platform === 'win32' && /^\\/[A-Za-z]:/.test(pathname)) {\n return pathname.slice(1);\n }\n return pathname;\n }\n\n if (path.isAbsolute(workspace)) {\n return workspace;\n }\n\n throw new Error(`Unsupported workspace '${workspace}'. LocalSolidFS expects file:// or absolute paths.`);\n }\n\n private async createCopyWorkdir(sourceRoot: string, runId?: string): Promise<string> {\n const safeRun = (runId ?? 'run').replace(/[^a-zA-Z0-9._-]+/gu, '_');\n const prefix = path.join(this.workRoot, `${safeRun}-`);\n await mkdir(this.workRoot, { recursive: true });\n const cwd = await mkdtemp(prefix);\n\n const sourceName = path.basename(sourceRoot.replace(/[\\\\/]+$/u, '')) || 'workspace';\n return path.join(cwd, sourceName);\n }\n\n private async createHydratedWorkdir(sourceRoot: string, runId?: string): Promise<string> {\n const safeRun = (runId ?? 'run').replace(/[^a-zA-Z0-9._-]+/gu, '_');\n await mkdir(this.workRoot, { recursive: true });\n const cwd = await mkdtemp(path.join(this.workRoot, `${safeRun}-hydrated-`));\n const workspaceDir = path.join(cwd, path.basename(sourceRoot.replace(/[\\\\/]+$/u, '')) || 'workspace');\n await mkdir(workspaceDir, { recursive: true });\n return workspaceDir;\n }\n\n private createManifest(\n workspace: string,\n cwd: string,\n projection: SolidFsProjection,\n snapshots: FileSnapshot[],\n ): SolidFsManifest {\n const source = sourceForProjection(projection, workspace);\n return {\n workspace,\n cwd,\n projection,\n entries: snapshots.map((snapshot): SolidFsManifestEntry => ({\n path: snapshot.relativePath,\n resource: resolveWorkspaceResource(workspace, snapshot.relativePath),\n source,\n sourcePath: snapshot.absolutePath,\n projection,\n sourceVersion: snapshot.version,\n workingVersion: snapshot.version,\n state: 'clean',\n })),\n };\n }\n\n private async assertSourceDirectory(sourceRoot: string): Promise<void> {\n let sourceStat;\n try {\n sourceStat = await stat(sourceRoot);\n } catch (error: any) {\n if (error?.code === 'ENOENT' || error?.code === 'ENOTDIR') {\n throw new Error(`SolidFS workspace does not exist: ${sourceRoot}`);\n }\n throw error;\n }\n\n if (!sourceStat.isDirectory()) {\n throw new Error(`SolidFS workspace is not a directory: ${sourceRoot}`);\n }\n }\n\n}\n\ninterface LocalMaterializedWorkspaceOptions {\n sourceRoot: string;\n cwd: string;\n projection: SolidFsProjection;\n cleanupOnRollback: boolean;\n manifest: SolidFsManifest;\n changeFilter?: (relativePath: string) => boolean;\n context?: unknown;\n syncer?: SolidFsSyncer;\n hydrator?: SolidFsHydrator;\n}\n\nclass LocalMaterializedWorkspace implements MaterializedWorkspace {\n public readonly cwd: string;\n public readonly manifest: SolidFsManifest;\n\n private readonly sourceRoot: string;\n private readonly projection: SolidFsProjection;\n private readonly cleanupOnRollback: boolean;\n private readonly changeFilter?: (relativePath: string) => boolean;\n private readonly context?: unknown;\n private readonly syncer?: SolidFsSyncer;\n private readonly hydrator?: SolidFsHydrator;\n private readonly entrySource: SolidFsEntrySource;\n\n public constructor(options: LocalMaterializedWorkspaceOptions) {\n this.sourceRoot = options.sourceRoot;\n this.cwd = options.cwd;\n this.projection = options.projection;\n this.cleanupOnRollback = options.cleanupOnRollback;\n this.manifest = options.manifest;\n this.changeFilter = options.changeFilter;\n this.context = options.context;\n this.syncer = options.syncer;\n this.hydrator = options.hydrator;\n this.entrySource = sourceForProjection(this.projection, this.manifest.workspace);\n }\n\n public async commit(): Promise<SolidFsManifest> {\n if (this.projection === 'hydrated-object') {\n return this.commitHydratedObjects();\n }\n\n const changes = await this.detectChanges();\n this.manifest.changes = changes;\n\n if (this.projection === 'direct') {\n await this.syncChanges(changes);\n this.markCommitted();\n return this.manifest;\n }\n\n if (this.projection !== 'copy') {\n throw new Error(`Commit is not implemented for projection '${this.projection}'.`);\n }\n\n const conflicts = await this.findConflicts();\n if (conflicts.length > 0) {\n for (const entry of this.manifest.entries) {\n if (conflicts.some((conflict) => conflict.path === entry.path)) {\n entry.state = 'conflict';\n }\n }\n throw new SolidFsConflictError(conflicts);\n }\n\n await rm(this.sourceRoot, { recursive: true, force: true });\n await cp(this.cwd, this.sourceRoot, {\n recursive: true,\n force: true,\n errorOnExist: false,\n dereference: false,\n });\n await this.syncChanges(changes);\n this.markCommitted();\n return this.manifest;\n }\n\n public async rollback(): Promise<void> {\n if (this.cleanupOnRollback) {\n await rm(path.dirname(this.cwd), { recursive: true, force: true });\n }\n }\n\n public async hydrate(relativePath: string): Promise<SolidFsManifestEntry> {\n if (this.projection !== 'hydrated-object') {\n throw new Error(`hydrate() is only supported for hydrated-object projection, not '${this.projection}'`);\n }\n if (!this.hydrator) {\n throw new Error('SolidFS hydrated-object projection requires a hydrator');\n }\n\n const normalized = safeRelativePath(relativePath);\n const targetPath = path.join(this.cwd, normalized);\n await mkdir(path.dirname(targetPath), { recursive: true });\n\n const result = await this.hydrator.hydrate({\n path: normalized,\n targetPath,\n workspace: this.manifest,\n context: this.context,\n });\n\n const workingVersion = await fileVersion(targetPath);\n let entry = this.manifest.entries.find((candidate) => candidate.path === normalized);\n if (!entry) {\n entry = {\n path: normalized,\n resource: resolveWorkspaceResource(this.manifest.workspace, normalized),\n source: this.entrySource,\n sourcePath: targetPath,\n contentType: result?.contentType ?? contentTypeForPath(normalized),\n projection: this.projection,\n sourceVersion: result?.sourceVersion,\n workingVersion,\n lastAccessedAt: Date.now(),\n state: 'clean',\n };\n this.manifest.entries.push(entry);\n this.manifest.entries.sort((left, right) => left.path.localeCompare(right.path));\n return entry;\n }\n\n entry.sourcePath = targetPath;\n entry.contentType = result?.contentType ?? entry.contentType ?? contentTypeForPath(normalized);\n entry.sourceVersion = result?.sourceVersion ?? entry.sourceVersion;\n entry.workingVersion = workingVersion;\n entry.lastAccessedAt = Date.now();\n entry.state = 'clean';\n return entry;\n }\n\n public async prune(options: SolidFsPruneOptions = {}): Promise<SolidFsManifest> {\n if (this.projection !== 'hydrated-object') {\n return this.manifest;\n }\n\n const now = options.now ?? Date.now();\n const olderThanMs = options.olderThanMs ?? 0;\n const retained: SolidFsManifestEntry[] = [];\n\n for (const entry of this.manifest.entries) {\n const currentVersion = await maybeFileVersion(entry.sourcePath);\n const dirty = currentVersion !== undefined && currentVersion !== entry.workingVersion;\n if (dirty) {\n entry.state = 'dirty';\n retained.push(entry);\n continue;\n }\n\n const age = now - (entry.lastAccessedAt ?? now);\n if (age >= olderThanMs) {\n await rm(entry.sourcePath, { force: true });\n continue;\n }\n retained.push(entry);\n }\n\n this.manifest.entries = retained;\n return this.manifest;\n }\n\n private async commitHydratedObjects(): Promise<SolidFsManifest> {\n if (!this.hydrator) {\n throw new Error('SolidFS hydrated-object projection requires a hydrator');\n }\n\n const changes = await this.detectHydratedChanges();\n this.manifest.changes = changes;\n\n for (const change of changes) {\n if (change.type === 'deleted' && this.hydrator.delete) {\n await this.hydrator.delete({\n change,\n workspace: this.manifest,\n context: this.context,\n });\n this.manifest.entries = this.manifest.entries.filter((entry) => entry.path !== change.path);\n continue;\n }\n if (change.type !== 'deleted') {\n const result = await this.hydrator.commit({\n change,\n workspace: this.manifest,\n context: this.context,\n });\n const entry = this.manifest.entries.find((candidate) => candidate.path === change.path);\n if (entry) {\n entry.sourceVersion = result?.sourceVersion ?? entry.sourceVersion;\n entry.workingVersion = await fileVersion(entry.sourcePath);\n entry.lastAccessedAt = Date.now();\n }\n }\n }\n\n this.markCommitted();\n return this.manifest;\n }\n\n private async detectHydratedChanges(): Promise<SolidFsChange[]> {\n const changes: SolidFsChange[] = [];\n const tracked = new Set(this.manifest.entries.map((entry) => entry.path));\n for (const entry of this.manifest.entries) {\n const currentVersion = await maybeFileVersion(entry.sourcePath);\n if (currentVersion === undefined) {\n changes.push({\n path: entry.path,\n resource: entry.resource ?? resolveWorkspaceResource(this.manifest.workspace, entry.path),\n source: entry.source,\n sourcePath: entry.sourcePath,\n contentType: entry.contentType,\n projection: this.projection,\n type: 'deleted',\n sourceVersion: entry.sourceVersion,\n });\n entry.state = 'dirty';\n continue;\n }\n if (currentVersion !== entry.workingVersion) {\n changes.push({\n path: entry.path,\n resource: entry.resource ?? resolveWorkspaceResource(this.manifest.workspace, entry.path),\n source: entry.source,\n sourcePath: entry.sourcePath,\n contentType: entry.contentType,\n projection: this.projection,\n type: 'updated',\n sourceVersion: entry.sourceVersion,\n });\n entry.state = 'dirty';\n }\n }\n\n for (const snapshot of await snapshotDirectory(this.cwd)) {\n if (tracked.has(snapshot.relativePath)) {\n continue;\n }\n this.manifest.entries.push({\n path: snapshot.relativePath,\n resource: resolveWorkspaceResource(this.manifest.workspace, snapshot.relativePath),\n source: this.entrySource,\n sourcePath: snapshot.absolutePath,\n contentType: contentTypeForPath(snapshot.relativePath),\n projection: this.projection,\n workingVersion: snapshot.version,\n lastAccessedAt: Date.now(),\n state: 'dirty',\n });\n changes.push({\n path: snapshot.relativePath,\n resource: resolveWorkspaceResource(this.manifest.workspace, snapshot.relativePath),\n source: this.entrySource,\n sourcePath: snapshot.absolutePath,\n contentType: contentTypeForPath(snapshot.relativePath),\n projection: this.projection,\n type: 'created',\n });\n }\n this.manifest.entries.sort((left, right) => left.path.localeCompare(right.path));\n return changes.sort((left, right) => left.path.localeCompare(right.path));\n }\n\n private async findConflicts(): Promise<SolidFsConflict[]> {\n const conflicts: SolidFsConflict[] = [];\n const initialPaths = new Set(this.manifest.entries.map((entry) => entry.path));\n\n for (const entry of this.manifest.entries) {\n if (!entry.sourceVersion) {\n continue;\n }\n const currentVersion = await maybeFileVersion(entry.sourcePath);\n if (currentVersion !== entry.sourceVersion) {\n conflicts.push({\n path: entry.path,\n sourcePath: entry.sourcePath,\n expectedVersion: entry.sourceVersion,\n actualVersion: currentVersion,\n message: 'Source file changed after workspace prepare.',\n });\n }\n }\n\n const currentSourceFiles = await snapshotDirectory(this.sourceRoot);\n for (const current of currentSourceFiles) {\n if (!initialPaths.has(current.relativePath)) {\n conflicts.push({\n path: current.relativePath,\n sourcePath: current.absolutePath,\n actualVersion: current.version,\n message: 'Source file was created after workspace prepare.',\n });\n }\n }\n return conflicts;\n }\n\n private async detectChanges(): Promise<SolidFsChange[]> {\n const before = new Map(this.manifest.entries.map((entry) => [entry.path, entry]));\n if (before.size === 0 && this.projection === 'direct' && !this.changeFilter) {\n return [];\n }\n const after = new Map((await snapshotDirectory(this.cwd, this.changeFilter)).map((snapshot) => [snapshot.relativePath, snapshot]));\n const changes: SolidFsChange[] = [];\n\n for (const [relativePath, snapshot] of after) {\n const entry = before.get(relativePath);\n if (!entry) {\n changes.push(this.createChange(relativePath, snapshot.absolutePath, 'created'));\n continue;\n }\n if (entry.sourceVersion !== snapshot.version) {\n changes.push(this.createChange(relativePath, snapshot.absolutePath, 'updated'));\n }\n }\n\n for (const [relativePath, entry] of before) {\n if (!after.has(relativePath)) {\n changes.push(this.createChange(relativePath, entry.sourcePath, 'deleted'));\n }\n }\n\n return changes.sort((left, right) => left.path.localeCompare(right.path));\n }\n\n private createChange(\n relativePath: string,\n sourcePath: string,\n type: SolidFsChange['type'],\n ): SolidFsChange {\n return {\n path: relativePath,\n resource: resolveWorkspaceResource(this.manifest.workspace, relativePath),\n source: this.entrySource,\n sourcePath,\n contentType: contentTypeForPath(relativePath),\n projection: this.projection,\n type,\n };\n }\n\n private async syncChanges(changes: SolidFsChange[]): Promise<void> {\n if (!this.syncer) {\n return;\n }\n for (const change of changes) {\n await this.syncer.sync(change, this.manifest, this.context);\n }\n }\n\n private markCommitted(): void {\n for (const entry of this.manifest.entries) {\n entry.state = 'committed';\n }\n }\n}\n\nfunction contentTypeForPath(filePath: string): string | undefined {\n const lower = filePath.toLowerCase();\n const rdfContentType = rdfContentTypeForPath(lower);\n if (rdfContentType) {\n return rdfContentType;\n }\n if (lower.endsWith('.md') || lower.endsWith('.markdown') || lower.endsWith('.mdown')) {\n return 'text/markdown';\n }\n if (lower.endsWith('.txt') || lower.endsWith('.log')) {\n return 'text/plain';\n }\n return undefined;\n}\n\nfunction sourceForProjection(projection: SolidFsProjection, workspace: string): SolidFsEntrySource {\n if (projection === 'hydrated-object') {\n return 'object';\n }\n if (/^https?:/u.test(workspace)) {\n return 'pod-http';\n }\n return 'filesystem';\n}\n\nfunction resolveWorkspaceResource(workspace: string, relativePath: string): string | undefined {\n if (path.isAbsolute(workspace)) {\n return pathToFileURL(path.join(workspace, relativePath)).href;\n }\n\n try {\n const base = new URL(workspace.endsWith('/') ? workspace : `${workspace}/`);\n const normalized = relativePath.split(path.sep).join('/');\n return new URL(normalized, base).href;\n } catch {\n return undefined;\n }\n}\n\nfunction isLineAddressableRdfPath(filePath: string): boolean {\n return isRdfPath(filePath);\n}\n\nfunction safeRelativePath(input: string): string {\n const normalized = input.split(/[\\\\/]+/u).filter((part) => part.length > 0).join(path.sep);\n if (!normalized || path.isAbsolute(input) || normalized.split(path.sep).includes('..')) {\n throw new Error(`Invalid SolidFS relative path: ${input}`);\n }\n return normalized;\n}\n\nasync function maybeFileVersion(filePath: string): Promise<string | undefined> {\n try {\n return await fileVersion(filePath);\n } catch {\n return undefined;\n }\n}\n\nasync function fileVersion(filePath: string): Promise<string> {\n const fileStat = await stat(filePath);\n const hash = createHash('sha256');\n await new Promise<void>((resolve, reject) => {\n const stream = createReadStream(filePath);\n stream.on('data', (chunk) => hash.update(chunk));\n stream.on('error', reject);\n stream.on('end', resolve);\n });\n return `${fileStat.size}:${fileStat.mtimeMs}:${hash.digest('hex')}`;\n}\n\nasync function snapshotDirectory(\n root: string,\n filter?: (relativePath: string) => boolean,\n): Promise<FileSnapshot[]> {\n const snapshots: FileSnapshot[] = [];\n\n async function walk(current: string): Promise<void> {\n let entries;\n try {\n entries = await readdir(current, { withFileTypes: true });\n } catch {\n return;\n }\n\n for (const entry of entries) {\n const absolute = path.join(current, entry.name);\n const relative = path.relative(root, absolute);\n if (entry.isDirectory()) {\n await walk(absolute);\n continue;\n }\n if (!entry.isFile()) {\n continue;\n }\n if (filter && !filter(relative)) {\n continue;\n }\n snapshots.push({\n relativePath: relative,\n absolutePath: absolute,\n version: await fileVersion(absolute),\n });\n }\n }\n\n await walk(root);\n return snapshots.sort((left, right) => left.relativePath.localeCompare(right.relativePath));\n}\n"]}
@@ -0,0 +1,16 @@
1
+ import type { SolidAuthContext } from '../api/auth/AuthContext';
2
+ import type { SolidFsManifest } from './types';
3
+ export interface PodSolidFsHttpClientOptions {
4
+ fetch?: typeof fetch;
5
+ tokenEndpoint?: string;
6
+ }
7
+ export declare class PodSolidFsHttpClient {
8
+ private readonly fetchImpl;
9
+ private readonly tokenEndpoint?;
10
+ constructor(options?: PodSolidFsHttpClientOptions);
11
+ request(input: string, init: RequestInit): Promise<Response>;
12
+ createAuthHeaders(context: unknown, operation: string): Promise<Headers>;
13
+ private exchangeClientCredentials;
14
+ }
15
+ export declare function resolvePodWorkspaceResourceUrl(relativePath: string, workspace: SolidFsManifest): string | undefined;
16
+ export declare function solidAuthFromContext(context: unknown): SolidAuthContext | undefined;