@workflow/world-local 5.0.0-beta.10 → 5.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.d.ts +17 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +18 -13
- package/dist/config.js.map +1 -1
- package/dist/fs.d.ts +102 -2
- package/dist/fs.d.ts.map +1 -1
- package/dist/fs.js +291 -24
- package/dist/fs.js.map +1 -1
- package/dist/index.d.ts +15 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +82 -5
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +91 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +268 -0
- package/dist/init.js.map +1 -0
- package/dist/instrumentObject.d.ts +8 -0
- package/dist/instrumentObject.d.ts.map +1 -0
- package/dist/instrumentObject.js +66 -0
- package/dist/instrumentObject.js.map +1 -0
- package/dist/queue.d.ts +8 -1
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +164 -53
- package/dist/queue.js.map +1 -1
- package/dist/storage/events-storage.d.ts +7 -0
- package/dist/storage/events-storage.d.ts.map +1 -0
- package/dist/storage/events-storage.js +760 -0
- package/dist/storage/events-storage.js.map +1 -0
- package/dist/storage/filters.d.ts +22 -0
- package/dist/storage/filters.d.ts.map +1 -0
- package/dist/storage/filters.js +33 -0
- package/dist/storage/filters.js.map +1 -0
- package/dist/storage/helpers.d.ts +18 -0
- package/dist/storage/helpers.d.ts.map +1 -0
- package/dist/storage/helpers.js +44 -0
- package/dist/storage/helpers.js.map +1 -0
- package/dist/storage/hooks-storage.d.ts +12 -0
- package/dist/storage/hooks-storage.d.ts.map +1 -0
- package/dist/storage/hooks-storage.js +93 -0
- package/dist/storage/hooks-storage.js.map +1 -0
- package/dist/storage/index.d.ts +12 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +32 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/legacy.d.ts +13 -0
- package/dist/storage/legacy.d.ts.map +1 -0
- package/dist/storage/legacy.js +77 -0
- package/dist/storage/legacy.js.map +1 -0
- package/dist/storage/runs-storage.d.ts +7 -0
- package/dist/storage/runs-storage.d.ts.map +1 -0
- package/dist/storage/runs-storage.js +59 -0
- package/dist/storage/runs-storage.js.map +1 -0
- package/dist/storage/steps-storage.d.ts +7 -0
- package/dist/storage/steps-storage.d.ts.map +1 -0
- package/dist/storage/steps-storage.js +52 -0
- package/dist/storage/steps-storage.js.map +1 -0
- package/dist/storage.d.ts +9 -2
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +8 -455
- package/dist/storage.js.map +1 -1
- package/dist/streamer.d.ts +4 -2
- package/dist/streamer.d.ts.map +1 -1
- package/dist/streamer.js +456 -104
- package/dist/streamer.js.map +1 -1
- package/dist/telemetry.d.ts +28 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +71 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/test-helpers.d.ts +54 -0
- package/dist/test-helpers.d.ts.map +1 -0
- package/dist/test-helpers.js +118 -0
- package/dist/test-helpers.js.map +1 -0
- package/dist/util.js.map +1 -1
- package/package.json +12 -11
package/dist/fs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../src/fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AACpD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,IAAI,GAAG,gBAAgB,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;AAEnD,MAAM,IAAI,GAAG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ACtB,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,GAAG,KAAK,CAAC;IAC1C,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;IAChE,MAAM,UAAU,GACd,KAAK,CAAC,MAAM,GAAG,CAAC;QACd,CAAC,CAAC,YAAY,CACV,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,SAAS,EACjC,KAAK,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CACjC;QACH,CAAC,CAAC,IAAI,CAAC;IAEX,OAAO;QACL,IAAI,EAAE,KAAK;QACX,MAAM,EAAE,UAAU;QAClB,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["import { promises as fs } from 'node:fs';\nimport path from 'node:path';\nimport { EntityConflictError, WorkflowWorldError } from '@workflow/errors';\nimport type { PaginatedResponse } from '@workflow/world';\nimport { monotonicFactory } from 'ulid';\nimport { z } from 'zod';\n\nconst ulid = monotonicFactory(() => Math.random());\n\n/**\n * Truncate a possibly-untrusted value for inclusion in an error message.\n * Keeps error output actionable for developers in dev mode while limiting\n * the amount of attacker-controlled data reflected back if a `world-local`\n * backend is ever run in a context that surfaces these messages to clients.\n */\nfunction truncateForError(value: unknown): string {\n const s = typeof value === 'string' ? value : String(value);\n const MAX = 48;\n return s.length > MAX ? `${s.slice(0, MAX)}…` : s;\n}\n\n/**\n * Thrown when a caller-supplied entity ID contains characters that would\n * escape the storage root (path traversal) or otherwise produce an unsafe\n * filename. Extends {@link WorkflowWorldError} so the platform's standard\n * error-to-HTTP mapping handles it alongside other world-layer errors.\n */\nexport class UnsafeEntityIdError extends WorkflowWorldError {\n constructor(kind: string, value: string) {\n super(\n `Unsafe ${kind} \"${truncateForError(value)}\": must not be empty, start with \".\", or contain path separators or null bytes`\n );\n this.name = 'UnsafeEntityIdError';\n }\n\n static is(value: unknown): value is UnsafeEntityIdError {\n return value instanceof Error && value.name === 'UnsafeEntityIdError';\n }\n}\n\n/**\n * Validate that a string is safe to embed in a filesystem path as a single\n * path component. Rejects values that are:\n * - empty\n * - starting with `.` (blocks `.`, `..`, `.locks`, `.tmp`, and other\n * hidden or reserved filenames)\n * - containing `/`, `\\`, or a NUL byte\n *\n * This is the primary defense against path-traversal attacks where a\n * request body supplies a `runId` / `stepId` / `correlationId` containing\n * `../` sequences to read or write files outside the storage root.\n * {@link resolveWithinBase} provides a belt-and-suspenders containment\n * check at the point of `path.join` for defense in depth.\n *\n * @param kind - Human-readable label used in the error message (e.g. \"runId\")\n * @param value - The value to validate; throws {@link UnsafeEntityIdError}\n * if the value is not safe.\n */\nexport function assertSafeEntityId(kind: string, value: string): void {\n if (\n value.length === 0 ||\n value.startsWith('.') ||\n value.includes('/') ||\n value.includes('\\\\') ||\n value.includes('\\0')\n ) {\n throw new UnsafeEntityIdError(kind, value);\n }\n}\n\n/**\n * Join `basedir` with an entity-relative path and assert the result stays\n * inside `basedir`. Complements {@link assertSafeEntityId}: per-entry-point\n * validation is the primary defense, and this final check catches any path\n * escape that slipped past (e.g. a new call site that forgot to validate,\n * or an unusual character combination on a future filesystem). Throws\n * {@link UnsafeEntityIdError} if the joined path escapes `basedir`.\n */\nexport function resolveWithinBase(\n basedir: string,\n ...segments: string[]\n): string {\n const resolvedBase = path.resolve(basedir);\n const joined = path.resolve(basedir, ...segments);\n if (joined !== resolvedBase && !joined.startsWith(resolvedBase + path.sep)) {\n throw new UnsafeEntityIdError('path', segments.join('/'));\n }\n return joined;\n}\n\nconst isWindows = process.platform === 'win32';\n\n/**\n * Execute a filesystem operation with retry logic on Windows.\n * On Windows, file operations can fail with EPERM/EBUSY/EACCES when files\n * are briefly locked by another process or antivirus. This wrapper adds\n * exponential backoff retry logic. On non-Windows platforms, executes directly.\n */\nasync function withWindowsRetry<T>(\n fn: () => Promise<T>,\n maxRetries = 5\n): Promise<T> {\n if (!isWindows) return fn();\n\n const retryableErrors = ['EPERM', 'EBUSY', 'EACCES'];\n const baseDelayMs = 10;\n\n for (let attempt = 0; attempt <= maxRetries; attempt++) {\n try {\n return await fn();\n } catch (error: any) {\n const isRetryable =\n attempt < maxRetries && retryableErrors.includes(error.code);\n if (!isRetryable) throw error;\n // Exponential backoff with jitter\n const delay = baseDelayMs * 2 ** attempt + Math.random() * baseDelayMs;\n await new Promise((resolve) => setTimeout(resolve, delay));\n }\n }\n // TypeScript: unreachable, but satisfies return type\n throw new Error('Retry loop exited unexpectedly');\n}\n\n// In-memory cache of created files to avoid expensive fs.access() calls\n// This is safe because we only write once per file path (no overwrites without explicit flag)\nconst createdFilesCache = new Set<string>();\n\n/**\n * Clear the created files cache. Useful for testing or when files are deleted externally.\n */\nexport function clearCreatedFilesCache(): void {\n createdFilesCache.clear();\n}\n\nexport { ulidToDate } from '@workflow/world';\n\n/**\n * Regex matching a tag suffix on a fileId (after `.json` has been stripped).\n * E.g., `wrun_ABC.vitest-0` → the `.vitest-0` part.\n * Tags start with a letter and contain alphanumeric chars and hyphens.\n * Entity IDs (ULIDs, step_N, etc.) never contain dots, so the first dot\n * always marks the tag boundary.\n */\nconst TAG_PATTERN = /\\.[a-zA-Z][a-zA-Z0-9-]*$/;\n\n/**\n * Strip a tag suffix from a fileId.\n * `wrun_ABC.vitest-0` → `wrun_ABC`\n * `wrun_ABC` → `wrun_ABC` (no-op if no tag)\n */\nexport function stripTag(fileId: string): string {\n return fileId.replace(TAG_PATTERN, '');\n}\n\n/**\n * Build the file path for an entity, with optional tag embedded in the filename.\n * `taggedPath('/data', 'runs', 'wrun_ABC', 'vitest-0')` → `/data/runs/wrun_ABC.vitest-0.json`\n * `taggedPath('/data', 'runs', 'wrun_ABC')` → `/data/runs/wrun_ABC.json`\n *\n * The `fileId` and `tag` are validated with {@link assertSafeEntityId} and\n * the result is containment-checked with {@link resolveWithinBase} to\n * prevent path-traversal attacks when values are derived from untrusted\n * request input.\n */\nexport function taggedPath(\n basedir: string,\n entityDir: string,\n fileId: string,\n tag?: string\n): string {\n assertSafeEntityId('fileId', fileId);\n if (tag !== undefined) assertSafeEntityId('tag', tag);\n const filename = tag ? `${fileId}.${tag}.json` : `${fileId}.json`;\n return resolveWithinBase(basedir, entityDir, filename);\n}\n\n/**\n * Read a JSON entity with tagged fallback.\n * When a tag is set, tries the tagged path first, then falls back to the\n * untagged path (so a tagged world can read entities written without a tag).\n */\nexport async function readJSONWithFallback<T>(\n basedir: string,\n entityDir: string,\n fileId: string,\n schema: z.ZodType<T>,\n tag?: string\n): Promise<T | null> {\n assertSafeEntityId('fileId', fileId);\n if (tag !== undefined) assertSafeEntityId('tag', tag);\n if (tag) {\n const result = await readJSON(\n resolveWithinBase(basedir, entityDir, `${fileId}.${tag}.json`),\n schema\n );\n if (result !== null) return result;\n }\n return readJSON(\n resolveWithinBase(basedir, entityDir, `${fileId}.json`),\n schema\n );\n}\n\n/**\n * List all filenames in a directory that have a specific tag.\n * Returns full filenames (e.g., `wrun_ABC.vitest-0.json`).\n */\nexport async function listTaggedFiles(\n dirPath: string,\n tag: string\n): Promise<string[]> {\n const suffix = `.${tag}.json`;\n try {\n const files = await fs.readdir(dirPath);\n return files.filter((f) => f.endsWith(suffix));\n } catch (error) {\n if ((error as any).code === 'ENOENT') return [];\n throw error;\n }\n}\n\n/**\n * List all filenames in a directory that have a specific tag and extension.\n * Returns full filenames (e.g., `stream-chnk_ABC.vitest-0.bin`).\n */\nexport async function listTaggedFilesByExtension(\n dirPath: string,\n tag: string,\n extension: string\n): Promise<string[]> {\n const suffix = `.${tag}${extension}`;\n try {\n const files = await fs.readdir(dirPath);\n return files.filter((f) => f.endsWith(suffix));\n } catch (error) {\n if ((error as any).code === 'ENOENT') return [];\n throw error;\n }\n}\n\nexport async function ensureDir(dirPath: string): Promise<void> {\n try {\n await fs.mkdir(dirPath, { recursive: true });\n } catch (_error) {\n // Ignore if already exists\n }\n}\n\ninterface WriteOptions {\n overwrite?: boolean;\n}\n\n/**\n * Custom JSON replacer that encodes Uint8Array as base64 strings.\n * Format: { __type: 'Uint8Array', data: '<base64>' }\n */\nexport function jsonReplacer(_key: string, value: unknown): unknown {\n if (value instanceof Uint8Array) {\n return {\n __type: 'Uint8Array',\n data: Buffer.from(value).toString('base64'),\n };\n }\n return value;\n}\n\n/**\n * Custom JSON reviver that decodes base64 strings back to Uint8Array.\n */\nexport function jsonReviver(_key: string, value: unknown): unknown {\n if (\n value !== null &&\n typeof value === 'object' &&\n (value as any).__type === 'Uint8Array' &&\n typeof (value as any).data === 'string'\n ) {\n return new Uint8Array(Buffer.from((value as any).data, 'base64'));\n }\n return value;\n}\n\nexport async function writeJSON(\n filePath: string,\n data: any,\n opts?: WriteOptions\n): Promise<void> {\n return write(filePath, JSON.stringify(data, jsonReplacer, 2), opts);\n}\n\n/**\n * Writes data to a file using atomic write-rename pattern.\n *\n * Note: While this function uses temp files to avoid partial writes,\n * it does not provide protection against concurrent writes from multiple\n * processes. In a multi-writer scenario, the last writer wins.\n * For production use with multiple writers, consider using a proper\n * database or locking mechanism.\n */\nexport async function write(\n filePath: string,\n data: string | Buffer,\n opts?: WriteOptions\n): Promise<void> {\n if (!opts?.overwrite) {\n // Fast path: check in-memory cache first to avoid expensive fs.access() calls\n // This provides significant performance improvement when creating many files\n if (createdFilesCache.has(filePath)) {\n throw new EntityConflictError(\n `File ${filePath} already exists and 'overwrite' is false`\n );\n }\n\n // Slow path: check filesystem for files created before this process started\n try {\n await fs.access(filePath);\n // File exists on disk, add to cache for future checks\n createdFilesCache.add(filePath);\n throw new EntityConflictError(\n `File ${filePath} already exists and 'overwrite' is false`\n );\n } catch (error: any) {\n // If file doesn't exist (ENOENT), continue with write\n if (error.code !== 'ENOENT') {\n throw error;\n }\n }\n }\n\n const tempPath = `${filePath}.tmp.${ulid()}`;\n let tempFileCreated = false;\n try {\n await ensureDir(path.dirname(filePath));\n await fs.writeFile(tempPath, data);\n tempFileCreated = true;\n await withWindowsRetry(() => fs.rename(tempPath, filePath));\n // Track this file in cache so future writes know it exists\n createdFilesCache.add(filePath);\n } catch (error) {\n // Only try to clean up temp file if it was actually created\n if (tempFileCreated) {\n await withWindowsRetry(() => fs.unlink(tempPath), 3).catch(() => {});\n }\n throw error;\n }\n}\n\nexport async function readJSON<T>(\n filePath: string,\n decoder: z.ZodType<T>\n): Promise<T | null> {\n try {\n const content = await fs.readFile(filePath, 'utf-8');\n return decoder.parse(JSON.parse(content, jsonReviver));\n } catch (error) {\n if ((error as any).code === 'ENOENT') return null;\n throw error;\n }\n}\n\nexport async function readBuffer(filePath: string): Promise<Buffer> {\n const content = await fs.readFile(filePath);\n return content;\n}\n\nexport async function deleteJSON(filePath: string): Promise<void> {\n try {\n await fs.unlink(filePath);\n } catch (error) {\n if ((error as any).code !== 'ENOENT') throw error;\n }\n}\n\n/**\n * Atomically create a file using O_CREAT | O_EXCL flags.\n * Returns true if the file was created, false if it already exists.\n * This is atomic at the OS level, safe for concurrent access.\n */\nexport async function writeExclusive(\n filePath: string,\n data: string\n): Promise<boolean> {\n await ensureDir(path.dirname(filePath));\n try {\n await fs.writeFile(filePath, data, { flag: 'wx' });\n return true;\n } catch (error: any) {\n if (error.code === 'EEXIST') {\n return false;\n }\n throw error;\n }\n}\n\nexport async function listJSONFiles(dirPath: string): Promise<string[]> {\n return listFilesByExtension(dirPath, '.json');\n}\n\nexport async function listFilesByExtension(\n dirPath: string,\n extension: string\n): Promise<string[]> {\n try {\n const files = await fs.readdir(dirPath);\n return files\n .filter((f) => f.endsWith(extension))\n .map((f) => f.slice(0, -extension.length));\n } catch (error) {\n if ((error as any).code === 'ENOENT') return [];\n throw error;\n }\n}\n\ninterface PaginatedFileSystemQueryConfig<T> {\n directory: string;\n schema: z.ZodType<T>;\n filePrefix?: string;\n filter?: (item: T) => boolean;\n sortOrder?: 'asc' | 'desc';\n limit?: number;\n cursor?: string;\n getCreatedAt(filename: string): Date | null;\n getId?(item: T): string;\n}\n// Cursor format: \"timestamp|id\" for tie-breaking\ninterface ParsedCursor {\n timestamp: Date;\n id: string | null;\n}\n\nfunction parseCursor(cursor: string | undefined): ParsedCursor | null {\n if (!cursor) return null;\n\n const parts = cursor.split('|');\n return {\n timestamp: new Date(parts[0]),\n id: parts[1] || null,\n };\n}\n\nfunction createCursor(timestamp: Date, id: string | undefined): string {\n return id ? `${timestamp.toISOString()}|${id}` : timestamp.toISOString();\n}\n\nexport async function paginatedFileSystemQuery<T extends { createdAt: Date }>(\n config: PaginatedFileSystemQueryConfig<T>\n): Promise<PaginatedResponse<T>> {\n const {\n directory,\n schema,\n filePrefix,\n filter,\n sortOrder = 'desc',\n limit = 20,\n cursor,\n getCreatedAt,\n getId,\n } = config;\n\n // Validate filePrefix (typically `${runId}-`) so request-derived prefixes\n // consistently reject unsafe characters. filePrefix is only used below to\n // filter readdir() results by prefix — it doesn't participate in path\n // construction — but keeping the validation rule uniform across the\n // storage layer avoids special cases and catches bad values earlier.\n if (filePrefix !== undefined) {\n assertSafeEntityId('filePrefix', filePrefix);\n }\n\n // 1. Get all JSON files in directory\n const fileIds = await listJSONFiles(directory);\n\n // 2. Filter by prefix if provided\n const relevantFileIds = filePrefix\n ? fileIds.filter((fileId) => fileId.startsWith(filePrefix))\n : fileIds;\n\n // 3. ULID Optimization: Filter by cursor using filename timestamps before loading JSON\n const parsedCursor = parseCursor(cursor);\n let candidateFileIds = relevantFileIds;\n\n if (parsedCursor) {\n candidateFileIds = relevantFileIds.filter((fileId) => {\n const filenameDate = getCreatedAt(`${fileId}.json`);\n if (filenameDate) {\n // Use filename timestamp for cursor filtering\n // We need to be careful here: if parsedCursor has an ID (for tie-breaking),\n // we need to include items with the same timestamp for later ID-based filtering.\n // If no ID, we can use strict inequality for optimization.\n const cursorTime = parsedCursor.timestamp.getTime();\n const fileTime = filenameDate.getTime();\n\n if (parsedCursor.id) {\n // Tie-breaking mode: include items at or near cursor timestamp\n return sortOrder === 'desc'\n ? fileTime <= cursorTime\n : fileTime >= cursorTime;\n } else {\n // No tie-breaking: strict inequality\n return sortOrder === 'desc'\n ? fileTime < cursorTime\n : fileTime > cursorTime;\n }\n }\n // Can't extract timestamp from filename (e.g., steps use sequential IDs).\n // Include the file and defer to JSON-based filtering below.\n return true;\n });\n }\n\n // 4. Load files individually and collect valid items\n const validItems: T[] = [];\n\n for (const fileId of candidateFileIds) {\n const filePath = path.join(directory, `${fileId}.json`);\n let item: T | null = null;\n try {\n item = await readJSON(filePath, schema);\n } catch (error: unknown) {\n // We don't expect zod errors to happen, but if the JSON does get malformed,\n // we skip the item. Preferably, we'd have a way to mark items as malformed,\n // so that the UI can display them as such, with richer messaging. In the meantime,\n // we just log a warning and skip the item.\n if (error instanceof z.ZodError) {\n console.warn(\n `Skipping item ${fileId} due to malformed JSON: ${error.message}`\n );\n continue;\n }\n throw error;\n }\n\n if (item) {\n // Apply custom filter early if provided\n if (filter && !filter(item)) continue;\n\n // Double-check cursor filtering with actual createdAt from JSON\n // (in case ULID timestamp differs from stored createdAt)\n if (parsedCursor) {\n const itemTime = item.createdAt.getTime();\n const cursorTime = parsedCursor.timestamp.getTime();\n\n if (sortOrder === 'desc') {\n // For descending order, skip items >= cursor\n if (itemTime > cursorTime) continue;\n // If timestamps are equal, use ID for tie-breaking (skip if ID >= cursorId)\n if (itemTime === cursorTime && parsedCursor.id && getId) {\n const itemId = getId(item);\n if (itemId >= parsedCursor.id) continue;\n }\n } else {\n // For ascending order, skip items <= cursor\n if (itemTime < cursorTime) continue;\n // If timestamps are equal, use ID for tie-breaking (skip if ID <= cursorId)\n if (itemTime === cursorTime && parsedCursor.id && getId) {\n const itemId = getId(item);\n if (itemId <= parsedCursor.id) continue;\n }\n }\n }\n\n validItems.push(item);\n }\n }\n\n // 5. Sort by createdAt (and by ID for tie-breaking if getId is provided)\n validItems.sort((a, b) => {\n const aTime = a.createdAt.getTime();\n const bTime = b.createdAt.getTime();\n const timeComparison = sortOrder === 'asc' ? aTime - bTime : bTime - aTime;\n\n // If timestamps are equal and we have getId, use ID for stable sorting\n if (timeComparison === 0 && getId) {\n const aId = getId(a);\n const bId = getId(b);\n return sortOrder === 'asc'\n ? aId.localeCompare(bId)\n : bId.localeCompare(aId);\n }\n\n return timeComparison;\n });\n\n // 6. Apply pagination\n const hasMore = validItems.length > limit;\n const items = hasMore ? validItems.slice(0, limit) : validItems;\n const nextCursor =\n items.length > 0\n ? createCursor(\n items[items.length - 1].createdAt,\n getId?.(items[items.length - 1])\n )\n : null;\n\n return {\n data: items,\n cursor: nextCursor,\n hasMore,\n };\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
import type { World } from '@workflow/world';
|
|
2
2
|
import type { Config } from './config.js';
|
|
3
|
+
import { type DirectHandler } from './queue.js';
|
|
4
|
+
export { DataDirAccessError, DataDirVersionError, ensureDataDir, initDataDir, type ParsedVersion, parseVersion, } from './init.js';
|
|
5
|
+
export type { DirectHandler } from './queue.js';
|
|
6
|
+
export type LocalWorld = World & {
|
|
7
|
+
/** Register a direct in-process handler for a queue prefix, bypassing HTTP. */
|
|
8
|
+
registerHandler(prefix: '__wkf_step_' | '__wkf_workflow_', handler: DirectHandler): void;
|
|
9
|
+
/** Clear all workflow data (runs, steps, events, hooks, streams). */
|
|
10
|
+
clear(): Promise<void>;
|
|
11
|
+
};
|
|
3
12
|
/**
|
|
4
|
-
* Creates
|
|
13
|
+
* Creates a local world instance that combines queue, storage, and streamer functionalities.
|
|
5
14
|
*
|
|
6
15
|
* @param args - Optional configuration object
|
|
7
16
|
* @param args.dataDir - Directory for storing workflow data (default: `.workflow-data/`)
|
|
8
17
|
* @param args.port - Port override for queue transport (default: auto-detected)
|
|
9
18
|
* @param args.baseUrl - Full base URL override for queue transport (default: `http://localhost:{port}`)
|
|
19
|
+
* @param args.tag - Optional tag to scope files (e.g., `vitest-0`). When set, files are written
|
|
20
|
+
* as `{id}.{tag}.json` and `clear()` only deletes files matching this tag.
|
|
21
|
+
* @throws {DataDirAccessError} If the data directory cannot be created or accessed
|
|
22
|
+
* @throws {DataDirVersionError} If the data directory version is incompatible
|
|
10
23
|
*/
|
|
11
|
-
export declare function
|
|
24
|
+
export declare function createLocalWorld(args?: Partial<Config>): LocalWorld;
|
|
12
25
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAW1C,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAM7D,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACb,WAAW,EACX,KAAK,aAAa,EAClB,YAAY,GACb,MAAM,WAAW,CAAC;AAEnB,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG;IAC/B,+EAA+E;IAC/E,eAAe,CACb,MAAM,EAAE,aAAa,GAAG,iBAAiB,EACzC,OAAO,EAAE,aAAa,GACrB,IAAI,CAAC;IACR,qEAAqE;IACrE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,UAAU,CA+FnE"}
|
package/dist/index.js
CHANGED
|
@@ -1,24 +1,101 @@
|
|
|
1
|
+
import { promises as fs } from 'node:fs';
|
|
2
|
+
import { rm } from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { reenqueueActiveRuns, SPEC_VERSION_CURRENT } from '@workflow/world';
|
|
1
5
|
import { config } from './config.js';
|
|
6
|
+
import { clearCreatedFilesCache, deleteJSON, listTaggedFiles, listTaggedFilesByExtension, readJSON, } from './fs.js';
|
|
7
|
+
import { initDataDir } from './init.js';
|
|
8
|
+
import { instrumentObject } from './instrumentObject.js';
|
|
2
9
|
import { createQueue } from './queue.js';
|
|
10
|
+
import { hashToken } from './storage/helpers.js';
|
|
3
11
|
import { createStorage } from './storage.js';
|
|
4
12
|
import { createStreamer } from './streamer.js';
|
|
13
|
+
// Re-export init types and utilities for consumers
|
|
14
|
+
export { DataDirAccessError, DataDirVersionError, ensureDataDir, initDataDir, parseVersion, } from './init.js';
|
|
5
15
|
/**
|
|
6
|
-
* Creates
|
|
16
|
+
* Creates a local world instance that combines queue, storage, and streamer functionalities.
|
|
7
17
|
*
|
|
8
18
|
* @param args - Optional configuration object
|
|
9
19
|
* @param args.dataDir - Directory for storing workflow data (default: `.workflow-data/`)
|
|
10
20
|
* @param args.port - Port override for queue transport (default: auto-detected)
|
|
11
21
|
* @param args.baseUrl - Full base URL override for queue transport (default: `http://localhost:{port}`)
|
|
22
|
+
* @param args.tag - Optional tag to scope files (e.g., `vitest-0`). When set, files are written
|
|
23
|
+
* as `{id}.{tag}.json` and `clear()` only deletes files matching this tag.
|
|
24
|
+
* @throws {DataDirAccessError} If the data directory cannot be created or accessed
|
|
25
|
+
* @throws {DataDirVersionError} If the data directory version is incompatible
|
|
12
26
|
*/
|
|
13
|
-
export function
|
|
27
|
+
export function createLocalWorld(args) {
|
|
14
28
|
const definedArgs = args
|
|
15
29
|
? Object.fromEntries(Object.entries(args).filter(([, value]) => value !== undefined))
|
|
16
30
|
: {};
|
|
17
31
|
const mergedConfig = { ...config.value, ...definedArgs };
|
|
32
|
+
const tag = mergedConfig.tag;
|
|
33
|
+
const queue = createQueue(mergedConfig);
|
|
34
|
+
const storage = createStorage(mergedConfig.dataDir, tag);
|
|
18
35
|
return {
|
|
19
|
-
|
|
20
|
-
...
|
|
21
|
-
...
|
|
36
|
+
specVersion: SPEC_VERSION_CURRENT,
|
|
37
|
+
...queue,
|
|
38
|
+
...createStorage(mergedConfig.dataDir, tag),
|
|
39
|
+
...instrumentObject('world.streams', {
|
|
40
|
+
...createStreamer(mergedConfig.dataDir, tag),
|
|
41
|
+
...(mergedConfig.streamFlushIntervalMs !== undefined && {
|
|
42
|
+
streamFlushIntervalMs: mergedConfig.streamFlushIntervalMs,
|
|
43
|
+
}),
|
|
44
|
+
}),
|
|
45
|
+
async start() {
|
|
46
|
+
await initDataDir(mergedConfig.dataDir);
|
|
47
|
+
await reenqueueActiveRuns(storage.runs, queue.queue, 'world-local');
|
|
48
|
+
},
|
|
49
|
+
async close() {
|
|
50
|
+
await queue.close();
|
|
51
|
+
},
|
|
52
|
+
async clear() {
|
|
53
|
+
if (tag) {
|
|
54
|
+
// Selectively delete only files matching this tag
|
|
55
|
+
const basedir = mergedConfig.dataDir;
|
|
56
|
+
// Delete hook token constraint files BEFORE deleting the hooks,
|
|
57
|
+
// since we need to read each hook to extract its token hash.
|
|
58
|
+
// Constraint files are untagged ({sha256}.json) so listTaggedFiles
|
|
59
|
+
// won't find them — we must resolve them via the hook data.
|
|
60
|
+
const hooksDir = path.join(basedir, 'hooks');
|
|
61
|
+
const taggedHookFiles = await listTaggedFiles(hooksDir, tag);
|
|
62
|
+
const { HookSchema } = await import('@workflow/world');
|
|
63
|
+
await Promise.all(taggedHookFiles.map(async (hookFile) => {
|
|
64
|
+
const hook = await readJSON(path.join(hooksDir, hookFile), HookSchema);
|
|
65
|
+
if (hook?.token) {
|
|
66
|
+
await deleteJSON(path.join(hooksDir, 'tokens', `${hashToken(hook.token)}.json`));
|
|
67
|
+
}
|
|
68
|
+
}));
|
|
69
|
+
// Delete tagged entity files across all directories
|
|
70
|
+
const entityDirs = [
|
|
71
|
+
'runs',
|
|
72
|
+
'steps',
|
|
73
|
+
'events',
|
|
74
|
+
'hooks',
|
|
75
|
+
'waits',
|
|
76
|
+
'streams/runs',
|
|
77
|
+
];
|
|
78
|
+
await Promise.all(entityDirs.map(async (dir) => {
|
|
79
|
+
const fullDir = path.join(basedir, dir);
|
|
80
|
+
const files = await listTaggedFiles(fullDir, tag);
|
|
81
|
+
await Promise.all(files.map((f) => deleteJSON(path.join(fullDir, f))));
|
|
82
|
+
}));
|
|
83
|
+
// Clean up lock files used for atomic terminal-state guards
|
|
84
|
+
await fs
|
|
85
|
+
.rm(path.join(basedir, '.locks'), { recursive: true, force: true })
|
|
86
|
+
.catch(() => { });
|
|
87
|
+
// Delete tagged stream chunks (.{tag}.bin files)
|
|
88
|
+
const chunksDir = path.join(basedir, 'streams', 'chunks');
|
|
89
|
+
const taggedBinFiles = await listTaggedFilesByExtension(chunksDir, tag, '.bin');
|
|
90
|
+
await Promise.all(taggedBinFiles.map((f) => fs.unlink(path.join(chunksDir, f)).catch(() => { })));
|
|
91
|
+
// Clear the in-memory write cache so deleted paths are forgotten
|
|
92
|
+
clearCreatedFilesCache();
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
await rm(mergedConfig.dataDir, { recursive: true, force: true });
|
|
96
|
+
await initDataDir(mergedConfig.dataDir);
|
|
97
|
+
}
|
|
98
|
+
},
|
|
22
99
|
};
|
|
23
100
|
}
|
|
24
101
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAE5E,OAAO,EAAE,MAAM,EA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AC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CACnD,CACF,CAAC;gBACF,iEAAiE;gBACjE,sBAAsB,EAAE,CAAC;YAC3B,CAAC;iBAAM,CAAC;gBACN,MAAM,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;gBACjE,MAAM,WAAW,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;YAC1C,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { promises as fs } from 'node:fs';\nimport { rm } from 'node:fs/promises';\nimport path from 'node:path';\nimport type { World } from '@workflow/world';\nimport { reenqueueActiveRuns, SPEC_VERSION_CURRENT } from '@workflow/world';\nimport type { Config } from './config.js';\nimport { config } from './config.js';\nimport {\n clearCreatedFilesCache,\n deleteJSON,\n listTaggedFiles,\n listTaggedFilesByExtension,\n readJSON,\n} from './fs.js';\nimport { initDataDir } from './init.js';\nimport { instrumentObject } from './instrumentObject.js';\nimport { createQueue, type DirectHandler } from './queue.js';\nimport { hashToken } from './storage/helpers.js';\nimport { createStorage } from './storage.js';\nimport { createStreamer } from './streamer.js';\n\n// Re-export init types and utilities for consumers\nexport {\n DataDirAccessError,\n DataDirVersionError,\n ensureDataDir,\n initDataDir,\n type ParsedVersion,\n parseVersion,\n} from './init.js';\n\nexport type { DirectHandler } from './queue.js';\n\nexport type LocalWorld = World & {\n /** Register a direct in-process handler for a queue prefix, bypassing HTTP. */\n registerHandler(\n prefix: '__wkf_step_' | '__wkf_workflow_',\n handler: DirectHandler\n ): void;\n /** Clear all workflow data (runs, steps, events, hooks, streams). */\n clear(): Promise<void>;\n};\n\n/**\n * Creates a local world instance that combines queue, storage, and streamer functionalities.\n *\n * @param args - Optional configuration object\n * @param args.dataDir - Directory for storing workflow data (default: `.workflow-data/`)\n * @param args.port - Port override for queue transport (default: auto-detected)\n * @param args.baseUrl - Full base URL override for queue transport (default: `http://localhost:{port}`)\n * @param args.tag - Optional tag to scope files (e.g., `vitest-0`). When set, files are written\n * as `{id}.{tag}.json` and `clear()` only deletes files matching this tag.\n * @throws {DataDirAccessError} If the data directory cannot be created or accessed\n * @throws {DataDirVersionError} If the data directory version is incompatible\n */\nexport function createLocalWorld(args?: Partial<Config>): LocalWorld {\n const definedArgs = args\n ? Object.fromEntries(\n Object.entries(args).filter(([, value]) => value !== undefined)\n )\n : {};\n const mergedConfig = { ...config.value, ...definedArgs };\n const tag = mergedConfig.tag;\n const queue = createQueue(mergedConfig);\n const storage = createStorage(mergedConfig.dataDir, tag);\n return {\n specVersion: SPEC_VERSION_CURRENT,\n ...queue,\n ...createStorage(mergedConfig.dataDir, tag),\n ...instrumentObject('world.streams', {\n ...createStreamer(mergedConfig.dataDir, tag),\n ...(mergedConfig.streamFlushIntervalMs !== undefined && {\n streamFlushIntervalMs: mergedConfig.streamFlushIntervalMs,\n }),\n }),\n async start() {\n await initDataDir(mergedConfig.dataDir);\n await reenqueueActiveRuns(storage.runs, queue.queue, 'world-local');\n },\n async close() {\n await queue.close();\n },\n async clear() {\n if (tag) {\n // Selectively delete only files matching this tag\n const basedir = mergedConfig.dataDir;\n\n // Delete hook token constraint files BEFORE deleting the hooks,\n // since we need to read each hook to extract its token hash.\n // Constraint files are untagged ({sha256}.json) so listTaggedFiles\n // won't find them — we must resolve them via the hook data.\n const hooksDir = path.join(basedir, 'hooks');\n const taggedHookFiles = await listTaggedFiles(hooksDir, tag);\n const { HookSchema } = await import('@workflow/world');\n await Promise.all(\n taggedHookFiles.map(async (hookFile) => {\n const hook = await readJSON(\n path.join(hooksDir, hookFile),\n HookSchema\n );\n if (hook?.token) {\n await deleteJSON(\n path.join(hooksDir, 'tokens', `${hashToken(hook.token)}.json`)\n );\n }\n })\n );\n\n // Delete tagged entity files across all directories\n const entityDirs = [\n 'runs',\n 'steps',\n 'events',\n 'hooks',\n 'waits',\n 'streams/runs',\n ];\n await Promise.all(\n entityDirs.map(async (dir) => {\n const fullDir = path.join(basedir, dir);\n const files = await listTaggedFiles(fullDir, tag);\n await Promise.all(\n files.map((f) => deleteJSON(path.join(fullDir, f)))\n );\n })\n );\n // Clean up lock files used for atomic terminal-state guards\n await fs\n .rm(path.join(basedir, '.locks'), { recursive: true, force: true })\n .catch(() => {});\n // Delete tagged stream chunks (.{tag}.bin files)\n const chunksDir = path.join(basedir, 'streams', 'chunks');\n const taggedBinFiles = await listTaggedFilesByExtension(\n chunksDir,\n tag,\n '.bin'\n );\n await Promise.all(\n taggedBinFiles.map((f) =>\n fs.unlink(path.join(chunksDir, f)).catch(() => {})\n )\n );\n // Clear the in-memory write cache so deleted paths are forgotten\n clearCreatedFilesCache();\n } else {\n await rm(mergedConfig.dataDir, { recursive: true, force: true });\n await initDataDir(mergedConfig.dataDir);\n }\n },\n };\n}\n"]}
|
package/dist/init.d.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
interface PackageInfo {
|
|
2
|
+
name: string;
|
|
3
|
+
version: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Returns the package name and version from package.json.
|
|
7
|
+
* The result is cached after the first read.
|
|
8
|
+
*
|
|
9
|
+
* In bundled contexts where package.json cannot be read,
|
|
10
|
+
* returns 'bundled' as the version.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getPackageInfo(): Promise<PackageInfo>;
|
|
13
|
+
/**
|
|
14
|
+
* Represents a parsed semantic version with optional prerelease tag.
|
|
15
|
+
*/
|
|
16
|
+
export interface ParsedVersion {
|
|
17
|
+
major: number;
|
|
18
|
+
minor: number;
|
|
19
|
+
patch: number;
|
|
20
|
+
prerelease?: string;
|
|
21
|
+
raw: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Error thrown when the data directory cannot be accessed or created.
|
|
25
|
+
*/
|
|
26
|
+
export declare class DataDirAccessError extends Error {
|
|
27
|
+
readonly dataDir: string;
|
|
28
|
+
readonly code?: string;
|
|
29
|
+
constructor(message: string, dataDir: string, code?: string);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Error thrown when data directory version is incompatible.
|
|
33
|
+
*/
|
|
34
|
+
export declare class DataDirVersionError extends Error {
|
|
35
|
+
readonly oldVersion: ParsedVersion;
|
|
36
|
+
readonly newVersion: ParsedVersion;
|
|
37
|
+
readonly suggestedVersion?: string;
|
|
38
|
+
constructor(message: string, oldVersion: ParsedVersion, newVersion: ParsedVersion, suggestedVersion?: string);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Parses a version string into its components.
|
|
42
|
+
*
|
|
43
|
+
* @param versionString - Version string like "4.0.1" or "4.0.1-beta.20"
|
|
44
|
+
* @returns Parsed version object with major, minor, patch, and optional prerelease
|
|
45
|
+
*/
|
|
46
|
+
export declare function parseVersion(versionString: string): ParsedVersion;
|
|
47
|
+
/**
|
|
48
|
+
* Formats a parsed version back to a string.
|
|
49
|
+
*/
|
|
50
|
+
export declare function formatVersion(version: ParsedVersion): string;
|
|
51
|
+
/**
|
|
52
|
+
* Parses the version file content to extract package name and version.
|
|
53
|
+
*
|
|
54
|
+
* @param content - Content like "@workflow/world-local@4.0.1-beta.20"
|
|
55
|
+
* @returns Object with packageName and version
|
|
56
|
+
*/
|
|
57
|
+
export declare function parseVersionFile(content: string): {
|
|
58
|
+
packageName: string;
|
|
59
|
+
version: ParsedVersion;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Formats the version file content.
|
|
63
|
+
*/
|
|
64
|
+
export declare function formatVersionFile(packageName: string, version: ParsedVersion): string;
|
|
65
|
+
/**
|
|
66
|
+
* Handles version upgrades between old and new versions.
|
|
67
|
+
* This function is called when the data directory was created with a different version.
|
|
68
|
+
*
|
|
69
|
+
* @param oldVersion - The version that created the data directory
|
|
70
|
+
* @param newVersion - The current package version
|
|
71
|
+
* @throws {DataDirVersionError} If the versions are incompatible
|
|
72
|
+
*/
|
|
73
|
+
export declare function upgradeVersion(oldVersion: ParsedVersion, newVersion: ParsedVersion): void;
|
|
74
|
+
/**
|
|
75
|
+
* Ensures the data directory exists and is writable.
|
|
76
|
+
* Creates the directory if it doesn't exist.
|
|
77
|
+
*
|
|
78
|
+
* @param dataDir - The path to the data directory
|
|
79
|
+
* @throws {DataDirAccessError} If the directory cannot be created or accessed
|
|
80
|
+
*/
|
|
81
|
+
export declare function ensureDataDir(dataDir: string): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Initializes the data directory, ensuring it exists, is accessible,
|
|
84
|
+
* and handles version compatibility.
|
|
85
|
+
*
|
|
86
|
+
* @param dataDir - The path to the data directory
|
|
87
|
+
* @throws {DataDirAccessError} If the directory cannot be created or accessed
|
|
88
|
+
*/
|
|
89
|
+
export declare function initDataDir(dataDir: string): Promise<void>;
|
|
90
|
+
export {};
|
|
91
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAcA,UAAU,WAAW;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAgBD;;;;;;GAMG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC,CAyB3D;AAKD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;gBAEX,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;CAM5D;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;IACnC,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;IACnC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;gBAGjC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,aAAa,EACzB,UAAU,EAAE,aAAa,EACzB,gBAAgB,CAAC,EAAE,MAAM;CAQ5B;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,aAAa,EAAE,MAAM,GAAG,aAAa,CAejE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAG5D;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG;IACjD,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,aAAa,CAAC;CACxB,CAeA;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,aAAa,GACrB,MAAM,CAER;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,aAAa,EACzB,UAAU,EAAE,aAAa,GACxB,IAAI,CAIN;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAkDlE;AA4DD;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgDhE"}
|
package/dist/init.js
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { access, constants, mkdir, readFile, unlink, writeFile, } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
/** Package name - hardcoded since it doesn't change */
|
|
5
|
+
const PACKAGE_NAME = '@workflow/world-local';
|
|
6
|
+
let cachedPackageInfo = null;
|
|
7
|
+
/**
|
|
8
|
+
* Get the directory path for this module.
|
|
9
|
+
* Works in ESM and falls back to a constant in CJS contexts (which shouldn't happen)
|
|
10
|
+
*/
|
|
11
|
+
function getModuleDir() {
|
|
12
|
+
// In bundled CJS contexts, import.meta.url may be undefined or empty
|
|
13
|
+
if (typeof import.meta.url === 'string' && import.meta.url) {
|
|
14
|
+
return path.dirname(fileURLToPath(import.meta.url));
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Returns the package name and version from package.json.
|
|
20
|
+
* The result is cached after the first read.
|
|
21
|
+
*
|
|
22
|
+
* In bundled contexts where package.json cannot be read,
|
|
23
|
+
* returns 'bundled' as the version.
|
|
24
|
+
*/
|
|
25
|
+
export async function getPackageInfo() {
|
|
26
|
+
if (cachedPackageInfo) {
|
|
27
|
+
return cachedPackageInfo;
|
|
28
|
+
}
|
|
29
|
+
const moduleDir = getModuleDir();
|
|
30
|
+
if (moduleDir) {
|
|
31
|
+
try {
|
|
32
|
+
const content = await readFile(path.join(moduleDir, '../package.json'), 'utf-8');
|
|
33
|
+
cachedPackageInfo = JSON.parse(content);
|
|
34
|
+
return cachedPackageInfo;
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
// Fall through to bundled fallback
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// Bundled context - package.json not accessible
|
|
41
|
+
cachedPackageInfo = {
|
|
42
|
+
name: PACKAGE_NAME,
|
|
43
|
+
version: 'bundled',
|
|
44
|
+
};
|
|
45
|
+
return cachedPackageInfo;
|
|
46
|
+
}
|
|
47
|
+
/** Filename for storing version information in the data directory */
|
|
48
|
+
const VERSION_FILENAME = 'version.txt';
|
|
49
|
+
/**
|
|
50
|
+
* Error thrown when the data directory cannot be accessed or created.
|
|
51
|
+
*/
|
|
52
|
+
export class DataDirAccessError extends Error {
|
|
53
|
+
dataDir;
|
|
54
|
+
code;
|
|
55
|
+
constructor(message, dataDir, code) {
|
|
56
|
+
super(message);
|
|
57
|
+
this.name = 'DataDirAccessError';
|
|
58
|
+
this.dataDir = dataDir;
|
|
59
|
+
this.code = code;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Error thrown when data directory version is incompatible.
|
|
64
|
+
*/
|
|
65
|
+
export class DataDirVersionError extends Error {
|
|
66
|
+
oldVersion;
|
|
67
|
+
newVersion;
|
|
68
|
+
suggestedVersion;
|
|
69
|
+
constructor(message, oldVersion, newVersion, suggestedVersion) {
|
|
70
|
+
super(message);
|
|
71
|
+
this.name = 'DataDirVersionError';
|
|
72
|
+
this.oldVersion = oldVersion;
|
|
73
|
+
this.newVersion = newVersion;
|
|
74
|
+
this.suggestedVersion = suggestedVersion;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Parses a version string into its components.
|
|
79
|
+
*
|
|
80
|
+
* @param versionString - Version string like "4.0.1" or "4.0.1-beta.20"
|
|
81
|
+
* @returns Parsed version object with major, minor, patch, and optional prerelease
|
|
82
|
+
*/
|
|
83
|
+
export function parseVersion(versionString) {
|
|
84
|
+
// Match: major.minor.patch with optional prerelease
|
|
85
|
+
const match = versionString.match(/^(\d+)\.(\d+)\.(\d+)(?:-(.+))?$/);
|
|
86
|
+
if (!match) {
|
|
87
|
+
throw new Error(`Invalid version string: "${versionString}"`);
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
major: parseInt(match[1], 10),
|
|
91
|
+
minor: parseInt(match[2], 10),
|
|
92
|
+
patch: parseInt(match[3], 10),
|
|
93
|
+
prerelease: match[4],
|
|
94
|
+
raw: versionString,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Formats a parsed version back to a string.
|
|
99
|
+
*/
|
|
100
|
+
export function formatVersion(version) {
|
|
101
|
+
const base = `${version.major}.${version.minor}.${version.patch}`;
|
|
102
|
+
return version.prerelease ? `${base}-${version.prerelease}` : base;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Parses the version file content to extract package name and version.
|
|
106
|
+
*
|
|
107
|
+
* @param content - Content like "@workflow/world-local@4.0.1-beta.20"
|
|
108
|
+
* @returns Object with packageName and version
|
|
109
|
+
*/
|
|
110
|
+
export function parseVersionFile(content) {
|
|
111
|
+
const trimmed = content.trim();
|
|
112
|
+
const lastAtIndex = trimmed.lastIndexOf('@');
|
|
113
|
+
if (lastAtIndex <= 0) {
|
|
114
|
+
throw new Error(`Invalid version file content: "${content}"`);
|
|
115
|
+
}
|
|
116
|
+
const packageName = trimmed.substring(0, lastAtIndex);
|
|
117
|
+
const versionString = trimmed.substring(lastAtIndex + 1);
|
|
118
|
+
return {
|
|
119
|
+
packageName,
|
|
120
|
+
version: parseVersion(versionString),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Formats the version file content.
|
|
125
|
+
*/
|
|
126
|
+
export function formatVersionFile(packageName, version) {
|
|
127
|
+
return `${packageName}@${formatVersion(version)}`;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Handles version upgrades between old and new versions.
|
|
131
|
+
* This function is called when the data directory was created with a different version.
|
|
132
|
+
*
|
|
133
|
+
* @param oldVersion - The version that created the data directory
|
|
134
|
+
* @param newVersion - The current package version
|
|
135
|
+
* @throws {DataDirVersionError} If the versions are incompatible
|
|
136
|
+
*/
|
|
137
|
+
export function upgradeVersion(oldVersion, newVersion) {
|
|
138
|
+
console.log(`[world-local] Upgrading from version ${formatVersion(oldVersion)} to ${formatVersion(newVersion)}`);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Ensures the data directory exists and is writable.
|
|
142
|
+
* Creates the directory if it doesn't exist.
|
|
143
|
+
*
|
|
144
|
+
* @param dataDir - The path to the data directory
|
|
145
|
+
* @throws {DataDirAccessError} If the directory cannot be created or accessed
|
|
146
|
+
*/
|
|
147
|
+
export async function ensureDataDir(dataDir) {
|
|
148
|
+
const absolutePath = path.resolve(dataDir);
|
|
149
|
+
// Try to create the directory if it doesn't exist
|
|
150
|
+
try {
|
|
151
|
+
await mkdir(absolutePath, { recursive: true });
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
const nodeError = error;
|
|
155
|
+
// EEXIST is fine - directory already exists
|
|
156
|
+
if (nodeError.code !== 'EEXIST') {
|
|
157
|
+
throw new DataDirAccessError(`Failed to create data directory "${absolutePath}": ${nodeError.message}`, absolutePath, nodeError.code);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
// Verify the directory is accessible (readable)
|
|
161
|
+
try {
|
|
162
|
+
await access(absolutePath, constants.R_OK);
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
const nodeError = error;
|
|
166
|
+
throw new DataDirAccessError(`Data directory "${absolutePath}" is not readable: ${nodeError.message}`, absolutePath, nodeError.code);
|
|
167
|
+
}
|
|
168
|
+
// Verify the directory is writable by attempting to write a temp file
|
|
169
|
+
const testFile = path.join(absolutePath, `.workflow-write-test-${Date.now()}`);
|
|
170
|
+
try {
|
|
171
|
+
await writeFile(testFile, '');
|
|
172
|
+
// Clean up test file — ENOENT during cleanup is harmless (may race
|
|
173
|
+
// with another process performing the same check concurrently)
|
|
174
|
+
await unlink(testFile).catch((e) => {
|
|
175
|
+
if (e.code !== 'ENOENT')
|
|
176
|
+
throw e;
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
const nodeError = error;
|
|
181
|
+
throw new DataDirAccessError(`Data directory "${absolutePath}" is not writable: ${nodeError.message}`, absolutePath, nodeError.code);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Reads the version from the data directory's version file.
|
|
186
|
+
*
|
|
187
|
+
* @param dataDir - Path to the data directory
|
|
188
|
+
* @returns The parsed version info, or null if the file doesn't exist
|
|
189
|
+
*/
|
|
190
|
+
async function readVersionFile(dataDir) {
|
|
191
|
+
const versionFilePath = path.join(path.resolve(dataDir), VERSION_FILENAME);
|
|
192
|
+
try {
|
|
193
|
+
const content = await readFile(versionFilePath, 'utf-8');
|
|
194
|
+
return parseVersionFile(content);
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
const nodeError = error;
|
|
198
|
+
if (nodeError.code === 'ENOENT') {
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
throw error;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Writes the current version to the data directory's version file.
|
|
206
|
+
*
|
|
207
|
+
* @param dataDir - Path to the data directory
|
|
208
|
+
* @param version - The version to write
|
|
209
|
+
*/
|
|
210
|
+
async function writeVersionFile(dataDir, version) {
|
|
211
|
+
const versionFilePath = path.join(path.resolve(dataDir), VERSION_FILENAME);
|
|
212
|
+
const packageInfo = await getPackageInfo();
|
|
213
|
+
const content = formatVersionFile(packageInfo.name, version);
|
|
214
|
+
await writeFile(versionFilePath, content);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Gets the suggested downgrade version based on the old version.
|
|
218
|
+
* If a specific version is suggested in the error, use that.
|
|
219
|
+
* Otherwise, suggest the previous minor version if patch is 0,
|
|
220
|
+
* or previous major version if minor is also 0.
|
|
221
|
+
*/
|
|
222
|
+
function getSuggestedDowngradeVersion(oldVersion, suggestedVersion) {
|
|
223
|
+
if (suggestedVersion) {
|
|
224
|
+
return suggestedVersion;
|
|
225
|
+
}
|
|
226
|
+
// Suggest the old version as the downgrade target
|
|
227
|
+
return formatVersion(oldVersion);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Initializes the data directory, ensuring it exists, is accessible,
|
|
231
|
+
* and handles version compatibility.
|
|
232
|
+
*
|
|
233
|
+
* @param dataDir - The path to the data directory
|
|
234
|
+
* @throws {DataDirAccessError} If the directory cannot be created or accessed
|
|
235
|
+
*/
|
|
236
|
+
export async function initDataDir(dataDir) {
|
|
237
|
+
// First ensure the directory exists and is accessible
|
|
238
|
+
await ensureDataDir(dataDir);
|
|
239
|
+
const packageInfo = await getPackageInfo();
|
|
240
|
+
const currentVersion = parseVersion(packageInfo.version);
|
|
241
|
+
// Read existing version file
|
|
242
|
+
const existingVersionInfo = await readVersionFile(dataDir);
|
|
243
|
+
if (existingVersionInfo === null) {
|
|
244
|
+
// New data directory - write the current version
|
|
245
|
+
await writeVersionFile(dataDir, currentVersion);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
const { version: oldVersion } = existingVersionInfo;
|
|
249
|
+
// Check if versions are the same (no upgrade needed)
|
|
250
|
+
if (formatVersion(oldVersion) === formatVersion(currentVersion)) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
// Attempt upgrade
|
|
254
|
+
try {
|
|
255
|
+
upgradeVersion(oldVersion, currentVersion);
|
|
256
|
+
// Upgrade succeeded - write the new version
|
|
257
|
+
await writeVersionFile(dataDir, currentVersion);
|
|
258
|
+
}
|
|
259
|
+
catch (error) {
|
|
260
|
+
const suggestedVersion = error instanceof DataDirVersionError ? error.suggestedVersion : undefined;
|
|
261
|
+
const downgradeTarget = getSuggestedDowngradeVersion(oldVersion, suggestedVersion);
|
|
262
|
+
console.error(`[world-local] Failed to upgrade data directory from version ${formatVersion(oldVersion)} to ${formatVersion(currentVersion)}:`, error instanceof Error ? error.message : error);
|
|
263
|
+
console.error(`[world-local] Data is not compatible with the current version. ` +
|
|
264
|
+
`Please downgrade to ${packageInfo.name}@${downgradeTarget}`);
|
|
265
|
+
throw error;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
//# sourceMappingURL=init.js.map
|