@draht/durable 2026.11.27 → 2026.12.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/CHANGELOG.md +37 -0
- package/dist/codemode/codemode.d.ts.map +1 -1
- package/dist/codemode/codemode.js +39 -0
- package/dist/codemode/codemode.js.map +1 -1
- package/dist/documents.d.ts.map +1 -1
- package/dist/documents.js +7 -2
- package/dist/documents.js.map +1 -1
- package/dist/env/index.d.ts +11 -0
- package/dist/env/index.d.ts.map +1 -1
- package/dist/env/index.js.map +1 -1
- package/dist/env/node.d.ts +1 -0
- package/dist/env/node.d.ts.map +1 -1
- package/dist/env/node.js +114 -34
- package/dist/env/node.js.map +1 -1
- package/dist/harness/task-graph.d.ts.map +1 -1
- package/dist/harness/task-graph.js +26 -13
- package/dist/harness/task-graph.js.map +1 -1
- package/dist/harness/usage.d.ts.map +1 -1
- package/dist/harness/usage.js +2 -0
- package/dist/harness/usage.js.map +1 -1
- package/dist/harness/view.d.ts +5 -1
- package/dist/harness/view.d.ts.map +1 -1
- package/dist/harness/view.js +36 -24
- package/dist/harness/view.js.map +1 -1
- package/dist/ids.d.ts +10 -0
- package/dist/ids.d.ts.map +1 -1
- package/dist/ids.js +21 -0
- package/dist/ids.js.map +1 -1
- package/dist/images/encode.d.ts +33 -0
- package/dist/images/encode.d.ts.map +1 -0
- package/dist/images/encode.js +69 -0
- package/dist/images/encode.js.map +1 -0
- package/dist/images/index.d.ts +4 -4
- package/dist/images/index.d.ts.map +1 -1
- package/dist/images/index.js +41 -58
- package/dist/images/index.js.map +1 -1
- package/dist/images/node-worker.d.ts +1 -18
- package/dist/images/node-worker.d.ts.map +1 -1
- package/dist/images/node-worker.js +2 -12
- package/dist/images/node-worker.js.map +1 -1
- package/dist/images/node.d.ts.map +1 -1
- package/dist/images/node.js +4 -103
- package/dist/images/node.js.map +1 -1
- package/dist/images/pi-images/cloudflare.d.ts +8 -0
- package/dist/images/pi-images/cloudflare.d.ts.map +1 -0
- package/dist/images/pi-images/cloudflare.js +14 -0
- package/dist/images/pi-images/cloudflare.js.map +1 -0
- package/dist/images/pi-images/index.d.ts +37 -0
- package/dist/images/pi-images/index.d.ts.map +1 -0
- package/dist/images/pi-images/index.js +22 -0
- package/dist/images/pi-images/index.js.map +1 -0
- package/dist/images/pi-images/installed.d.ts +8 -0
- package/dist/images/pi-images/installed.d.ts.map +1 -0
- package/dist/images/pi-images/installed.js +24 -0
- package/dist/images/pi-images/installed.js.map +1 -0
- package/dist/images/pi-images/node-worker.d.ts +2 -0
- package/dist/images/pi-images/node-worker.d.ts.map +1 -0
- package/dist/images/pi-images/node-worker.js +7 -0
- package/dist/images/pi-images/node-worker.js.map +1 -0
- package/dist/images/pi-images/node.d.ts +24 -0
- package/dist/images/pi-images/node.d.ts.map +1 -0
- package/dist/images/pi-images/node.js +18 -0
- package/dist/images/pi-images/node.js.map +1 -0
- package/dist/images/pi-images/processor.d.ts +21 -0
- package/dist/images/pi-images/processor.d.ts.map +1 -0
- package/dist/images/pi-images/processor.js +117 -0
- package/dist/images/pi-images/processor.js.map +1 -0
- package/dist/images/thread.d.ts +27 -0
- package/dist/images/thread.d.ts.map +1 -0
- package/dist/images/thread.js +131 -0
- package/dist/images/thread.js.map +1 -0
- package/dist/session/session.js +32 -6
- package/dist/session/session.js.map +1 -1
- package/dist/session/transaction.d.ts.map +1 -1
- package/dist/session/transaction.js +3 -0
- package/dist/session/transaction.js.map +1 -1
- package/dist/storage/jsonl/storage.d.ts +6 -0
- package/dist/storage/jsonl/storage.d.ts.map +1 -1
- package/dist/storage/jsonl/storage.js +65 -0
- package/dist/storage/jsonl/storage.js.map +1 -1
- package/dist/storage/sqlite/commit.d.ts.map +1 -1
- package/dist/storage/sqlite/commit.js +3 -3
- package/dist/storage/sqlite/commit.js.map +1 -1
- package/dist/storage/sqlite/migrations.d.ts.map +1 -1
- package/dist/storage/sqlite/migrations.js +20 -0
- package/dist/storage/sqlite/migrations.js.map +1 -1
- package/dist/storage/sqlite/rows.d.ts +0 -2
- package/dist/storage/sqlite/rows.d.ts.map +1 -1
- package/dist/storage/sqlite/rows.js +3 -5
- package/dist/storage/sqlite/rows.js.map +1 -1
- package/dist/storage/sqlite/storage.d.ts +1 -1
- package/dist/storage/sqlite/storage.d.ts.map +1 -1
- package/dist/storage/sqlite/storage.js +11 -10
- package/dist/storage/sqlite/storage.js.map +1 -1
- package/dist/storage/store/documents.d.ts.map +1 -1
- package/dist/storage/store/documents.js +4 -6
- package/dist/storage/store/documents.js.map +1 -1
- package/dist/storage/store/migrations.d.ts +10 -0
- package/dist/storage/store/migrations.d.ts.map +1 -0
- package/dist/storage/store/migrations.js +44 -0
- package/dist/storage/store/migrations.js.map +1 -0
- package/dist/storage/store/storage.d.ts +3 -2
- package/dist/storage/store/storage.d.ts.map +1 -1
- package/dist/storage/store/storage.js +9 -6
- package/dist/storage/store/storage.js.map +1 -1
- package/dist/storage/store/tables.d.ts +21 -3
- package/dist/storage/store/tables.d.ts.map +1 -1
- package/dist/storage/store/tables.js +14 -10
- package/dist/storage/store/tables.js.map +1 -1
- package/dist/tasks.d.ts.map +1 -1
- package/dist/tasks.js +2 -0
- package/dist/tasks.js.map +1 -1
- package/dist/testing/storage-conformance.d.ts.map +1 -1
- package/dist/testing/storage-conformance.js +0 -74
- package/dist/testing/storage-conformance.js.map +1 -1
- package/dist/types.d.ts +4 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +26 -6
package/dist/documents.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documents.js","sourceRoot":"","sources":["../src/documents.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAkB,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAmDxC,MAAM,UAAU,SAAS,CAAuB,UAA4B;IAC3E,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAC/B,OAAO,EAA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O,SAAS,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;IACnH,CAAC;IACD,IAAI,OAAO,GAAG,UAAU,CAAC,OAAO,IAAI,UAAU,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QACtE,MAAM,IAAI,KAAK,CAAC,YAAY,MAAM,CAAC,EAAE,KAAK,MAAM,CAAC,IAAI,qCAAqC,OAAO,EAAE,CAAC,CAAC;IACtG,CAAC;AACF,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,mBAAmB,CAAC,UAA4B,EAAE,MAAsB;IACvF,OAAO,wBAAwB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;AAC1F,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,wBAAwB,CACvC,UAA4B,EAC5B,MAAuC,EACvC,OAAe,EACf,KAAiB;IAEjB,gBAAgB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IACrC,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAChD,IAAI,OAAO,KAAK,UAAU,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IACjD,OAAO,QAAQ,CAAC,UAAU,CAAC,OAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAe,CAAC;AACpE,CAAC","sourcesContent":["import type { Op } from \"@draht/chord/delta\";\nimport { copyJson, type JsonValue } from \"@draht/chord/json\";\nimport { idFromNumber } from \"./ids.ts\";\nimport type {\n\tCheckpointInfo,\n\tCommonDocDefinition,\n\tConversationDocFamilyToken,\n\tConversationDocToken,\n\tConversationId,\n\tDocDefinition,\n\tDocFamilyDefinition,\n\tDocFamilyToken,\n\tDocToken,\n\tDocumentAddress,\n\tDocumentCreate,\n\tDocumentId,\n\tDocumentRecord,\n\tDocumentSemantics,\n\tId,\n\tJsonObject,\n\tLatestConversationSemantics,\n\tRewindableConversationDocFamilyToken,\n\tRewindableConversationDocToken,\n\tRewindableConversationSemantics,\n\tSessionDocFamilyToken,\n\tSessionDocToken,\n\tStoredDocument,\n\tTaskDocFamilyToken,\n\tTaskDocToken,\n\tTaskId,\n} from \"./types.ts\";\n\ntype FamilyInput<T extends JsonObject, I extends JsonValue> = Omit<CommonDocDefinition<T>, \"initial\"> & {\n\treadonly family: true;\n\tinitial(seed: I): T;\n};\n\n/** Define a Session-scoped singleton document. */\nexport function defineDoc<T extends JsonObject>(\n\tdefinition: CommonDocDefinition<T> & { readonly scope: \"session\" },\n): SessionDocToken<T>;\n/** Define a latest-only conversation singleton document. */\nexport function defineDoc<T extends JsonObject>(\n\tdefinition: CommonDocDefinition<T> & LatestConversationSemantics,\n): ConversationDocToken<T>;\n/** Define a rewindable conversation singleton document. */\nexport function defineDoc<T extends JsonObject>(\n\tdefinition: CommonDocDefinition<T> & RewindableConversationSemantics,\n): RewindableConversationDocToken<T>;\n/** Define a task-scoped singleton document. */\nexport function defineDoc<T extends JsonObject>(\n\tdefinition: CommonDocDefinition<T> & { readonly scope: \"task\" },\n): TaskDocToken<T>;\nexport function defineDoc<T extends JsonObject>(definition: DocDefinition<T>): DocToken<T, DocDefinition<T>> {\n\tvalidateDefinition(definition);\n\treturn { definition };\n}\n\n/** Define a Session-scoped document family. */\nexport function defineDocFamily<T extends JsonObject, I extends JsonValue>(\n\tdefinition: FamilyInput<T, I> & { readonly scope: \"session\" },\n): SessionDocFamilyToken<T, I>;\n/** Define a latest-only conversation document family. */\nexport function defineDocFamily<T extends JsonObject, I extends JsonValue>(\n\tdefinition: FamilyInput<T, I> & LatestConversationSemantics,\n): ConversationDocFamilyToken<T, I>;\n/** Define a rewindable conversation document family. */\nexport function defineDocFamily<T extends JsonObject, I extends JsonValue>(\n\tdefinition: FamilyInput<T, I> & RewindableConversationSemantics,\n): RewindableConversationDocFamilyToken<T, I>;\n/** Define a task-scoped document family. */\nexport function defineDocFamily<T extends JsonObject, I extends JsonValue>(\n\tdefinition: FamilyInput<T, I> & { readonly scope: \"task\" },\n): TaskDocFamilyToken<T, I>;\nexport function defineDocFamily<T extends JsonObject, I extends JsonValue>(\n\tdefinition: DocFamilyDefinition<T, I>,\n): DocFamilyToken<T, I, DocFamilyDefinition<T, I>> {\n\tvalidateDefinition(definition);\n\treturn { definition };\n}\n\n/** Erased definition shape used by the Session after overload resolution. */\nexport type AnyDocDefinition = DocumentSemantics & {\n\treadonly kind: string;\n\treadonly version: number;\n\treadonly family?: true;\n\tinitial(seed?: JsonValue): JsonObject;\n\tmigrate?(value: JsonObject, fromVersion: number): JsonObject;\n\tcheckpointWhen(value: Readonly<JsonObject>, ops: readonly Op[], info: CheckpointInfo): boolean;\n};\n\n/** Erased singleton or family token. */\nexport type AnyDocToken = { readonly definition: AnyDocDefinition };\n\nfunction validateDefinition(definition: AnyDocDefinition): void {\n\tif (!Number.isSafeInteger(definition.version) || definition.version < 1) {\n\t\tthrow new TypeError(`Document ${definition.kind} version must be a positive integer`);\n\t}\n}\n\n/** Logical address plus its string identity for maps. */\nexport type ResolvedAddress = {\n\treadonly address: DocumentAddress;\n\treadonly id: string;\n\treadonly nextArgument: number;\n};\n\n/** Resolve an overloaded argument list and return the index after the owner and family key. */\nexport function resolveAddress(definition: AnyDocDefinition, args: readonly unknown[]): ResolvedAddress {\n\tlet index = 0;\n\tlet scope: DocumentAddress[\"scope\"];\n\tswitch (definition.scope) {\n\t\tcase \"session\":\n\t\t\tscope = { kind: \"session\" };\n\t\t\tbreak;\n\t\tcase \"conversation\":\n\t\t\tscope = { kind: \"conversation\", conversationId: ownerId<ConversationId>(args[index++], definition) };\n\t\t\tbreak;\n\t\tcase \"task\":\n\t\t\tscope = { kind: \"task\", taskId: ownerId<TaskId>(args[index++], definition) };\n\t\t\tbreak;\n\t}\n\tconst key = definition.family === true ? (args[index++] as string) : undefined;\n\tconst address: DocumentAddress =\n\t\tkey === undefined ? { kind: definition.kind, scope } : { kind: definition.kind, scope, key };\n\treturn { address, id: addressId(address), nextArgument: index };\n}\n\nfunction ownerId<I extends Id<string>>(value: unknown, definition: AnyDocDefinition): I {\n\tif (typeof value !== \"number\" || !Number.isSafeInteger(value)) {\n\t\tthrow new TypeError(`Document ${definition.kind} requires a ${definition.scope} ID`);\n\t}\n\treturn idFromNumber<I>(value);\n}\n\n/** Stable string identity of one logical address. */\nexport function addressId(address: DocumentAddress): string {\n\tconst owner =\n\t\taddress.scope.kind === \"session\"\n\t\t\t? null\n\t\t\t: address.scope.kind === \"conversation\"\n\t\t\t\t? address.scope.conversationId\n\t\t\t\t: address.scope.taskId;\n\treturn JSON.stringify([address.kind, address.scope.kind, owner, address.key ?? null]);\n}\n\n/** Build the storage create record for a new incarnation at an address. */\nexport function documentCreate(definition: AnyDocDefinition, address: DocumentAddress, id: DocumentId): DocumentCreate {\n\tconst key = address.key === undefined ? {} : { key: address.key };\n\tswitch (address.scope.kind) {\n\t\tcase \"session\":\n\t\t\treturn { id, kind: address.kind, ...key, scope: address.scope };\n\t\tcase \"task\":\n\t\t\treturn { id, kind: address.kind, ...key, scope: address.scope };\n\t\tcase \"conversation\":\n\t\t\treturn {\n\t\t\t\tid,\n\t\t\t\tkind: address.kind,\n\t\t\t\t...key,\n\t\t\t\tscope: address.scope,\n\t\t\t\thistory: definition.history!,\n\t\t\t\tfork: definition.fork!,\n\t\t\t} as DocumentCreate;\n\t}\n}\n\n/** Reject typed access whose token disagrees with the persisted scope, history, or fork semantics. */\nexport function checkRecordScope(definition: AnyDocDefinition, record: DocumentCreate | DocumentRecord): void {\n\tif (\n\t\trecord.scope.kind !== definition.scope ||\n\t\t(record.scope.kind === \"conversation\" &&\n\t\t\t(record.history !== definition.history || record.fork !== definition.fork))\n\t) {\n\t\tthrow new TypeError(`Document ${record.id} (${record.kind}) does not match the supplied definition semantics`);\n\t}\n}\n\n/** Reject typed access to a stored version the supplied definition cannot use. */\nexport function checkRecordVersion(\n\tdefinition: AnyDocDefinition,\n\trecord: DocumentCreate | DocumentRecord,\n\tversion: number,\n): void {\n\tif (version > definition.version) {\n\t\tthrow new Error(`Document ${record.id} (${record.kind}) has newer version ${version} than ${definition.version}`);\n\t}\n\tif (version < definition.version && definition.migrate === undefined) {\n\t\tthrow new Error(`Document ${record.id} (${record.kind}) requires migration from version ${version}`);\n\t}\n}\n\n/** Validate and materialize a detached stored value for typed access. */\nexport function materializeDocument(definition: AnyDocDefinition, stored: StoredDocument): JsonObject {\n\treturn materializeDocumentValue(definition, stored.record, stored.version, stored.value);\n}\n\n/** Validate and materialize one detached value before its first persisted incarnation. */\nexport function materializeDocumentValue(\n\tdefinition: AnyDocDefinition,\n\trecord: DocumentCreate | DocumentRecord,\n\tversion: number,\n\tvalue: JsonObject,\n): JsonObject {\n\tcheckRecordScope(definition, record);\n\tcheckRecordVersion(definition, record, version);\n\tif (version === definition.version) return value;\n\treturn copyJson(definition.migrate!(value, version)) as JsonObject;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"documents.js","sourceRoot":"","sources":["../src/documents.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAkB,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAmDvD,MAAM,UAAU,SAAS,CAAuB,UAA4B;IAC3E,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAC/B,OAAO,EAAE,UAAU,EAAE,CAAC;AACvB,CAAC;AAkBD,MAAM,UAAU,eAAe,CAC9B,UAAqC;IAErC,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAC/B,OAAO,EAAE,UAAU,EAAE,CAAC;AACvB,CAAC;AAeD,SAAS,kBAAkB,CAAC,UAA4B;IACvD,aAAa,CAAC,eAAe,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;IAChD,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,UAAU,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC;QACzE,MAAM,IAAI,SAAS,CAAC,YAAY,UAAU,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,qCAAqC,OAAO,EAAE,CAAC,CAAC;IACtG,CAAC;AACF,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,mBAAmB,CAAC,UAA4B,EAAE,MAAsB;IACvF,OAAO,wBAAwB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;AAC1F,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,wBAAwB,CACvC,UAA4B,EAC5B,MAAuC,EACvC,OAAe,EACf,KAAiB;IAEjB,gBAAgB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IACrC,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAChD,IAAI,OAAO,KAAK,UAAU,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IACjD,OAAO,QAAQ,CAAC,UAAU,CAAC,OAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAe,CAAC;AACpE,CAAC","sourcesContent":["import type { Op } from \"@draht/chord/delta\";\nimport { copyJson, type JsonValue } from \"@draht/chord/json\";\nimport { checkIdentity, idFromNumber } from \"./ids.ts\";\nimport type {\n\tCheckpointInfo,\n\tCommonDocDefinition,\n\tConversationDocFamilyToken,\n\tConversationDocToken,\n\tConversationId,\n\tDocDefinition,\n\tDocFamilyDefinition,\n\tDocFamilyToken,\n\tDocToken,\n\tDocumentAddress,\n\tDocumentCreate,\n\tDocumentId,\n\tDocumentRecord,\n\tDocumentSemantics,\n\tId,\n\tJsonObject,\n\tLatestConversationSemantics,\n\tRewindableConversationDocFamilyToken,\n\tRewindableConversationDocToken,\n\tRewindableConversationSemantics,\n\tSessionDocFamilyToken,\n\tSessionDocToken,\n\tStoredDocument,\n\tTaskDocFamilyToken,\n\tTaskDocToken,\n\tTaskId,\n} from \"./types.ts\";\n\ntype FamilyInput<T extends JsonObject, I extends JsonValue> = Omit<CommonDocDefinition<T>, \"initial\"> & {\n\treadonly family: true;\n\tinitial(seed: I): T;\n};\n\n/** Define a Session-scoped singleton document. */\nexport function defineDoc<T extends JsonObject>(\n\tdefinition: CommonDocDefinition<T> & { readonly scope: \"session\" },\n): SessionDocToken<T>;\n/** Define a latest-only conversation singleton document. */\nexport function defineDoc<T extends JsonObject>(\n\tdefinition: CommonDocDefinition<T> & LatestConversationSemantics,\n): ConversationDocToken<T>;\n/** Define a rewindable conversation singleton document. */\nexport function defineDoc<T extends JsonObject>(\n\tdefinition: CommonDocDefinition<T> & RewindableConversationSemantics,\n): RewindableConversationDocToken<T>;\n/** Define a task-scoped singleton document. */\nexport function defineDoc<T extends JsonObject>(\n\tdefinition: CommonDocDefinition<T> & { readonly scope: \"task\" },\n): TaskDocToken<T>;\nexport function defineDoc<T extends JsonObject>(definition: DocDefinition<T>): DocToken<T, DocDefinition<T>> {\n\tvalidateDefinition(definition);\n\treturn { definition };\n}\n\n/** Define a Session-scoped document family. */\nexport function defineDocFamily<T extends JsonObject, I extends JsonValue>(\n\tdefinition: FamilyInput<T, I> & { readonly scope: \"session\" },\n): SessionDocFamilyToken<T, I>;\n/** Define a latest-only conversation document family. */\nexport function defineDocFamily<T extends JsonObject, I extends JsonValue>(\n\tdefinition: FamilyInput<T, I> & LatestConversationSemantics,\n): ConversationDocFamilyToken<T, I>;\n/** Define a rewindable conversation document family. */\nexport function defineDocFamily<T extends JsonObject, I extends JsonValue>(\n\tdefinition: FamilyInput<T, I> & RewindableConversationSemantics,\n): RewindableConversationDocFamilyToken<T, I>;\n/** Define a task-scoped document family. */\nexport function defineDocFamily<T extends JsonObject, I extends JsonValue>(\n\tdefinition: FamilyInput<T, I> & { readonly scope: \"task\" },\n): TaskDocFamilyToken<T, I>;\nexport function defineDocFamily<T extends JsonObject, I extends JsonValue>(\n\tdefinition: DocFamilyDefinition<T, I>,\n): DocFamilyToken<T, I, DocFamilyDefinition<T, I>> {\n\tvalidateDefinition(definition);\n\treturn { definition };\n}\n\n/** Erased definition shape used by the Session after overload resolution. */\nexport type AnyDocDefinition = DocumentSemantics & {\n\treadonly kind: string;\n\treadonly version: number;\n\treadonly family?: true;\n\tinitial(seed?: JsonValue): JsonObject;\n\tmigrate?(value: JsonObject, fromVersion: number): JsonObject;\n\tcheckpointWhen(value: Readonly<JsonObject>, ops: readonly Op[], info: CheckpointInfo): boolean;\n};\n\n/** Erased singleton or family token. */\nexport type AnyDocToken = { readonly definition: AnyDocDefinition };\n\nfunction validateDefinition(definition: AnyDocDefinition): void {\n\tcheckIdentity(\"Document kind\", definition.kind);\n\tif (!Number.isSafeInteger(definition.version) || definition.version < 1) {\n\t\tthrow new TypeError(`Document ${definition.kind} version must be a positive integer`);\n\t}\n}\n\n/** Logical address plus its string identity for maps. */\nexport type ResolvedAddress = {\n\treadonly address: DocumentAddress;\n\treadonly id: string;\n\treadonly nextArgument: number;\n};\n\n/** Resolve an overloaded argument list and return the index after the owner and family key. */\nexport function resolveAddress(definition: AnyDocDefinition, args: readonly unknown[]): ResolvedAddress {\n\tlet index = 0;\n\tlet scope: DocumentAddress[\"scope\"];\n\tswitch (definition.scope) {\n\t\tcase \"session\":\n\t\t\tscope = { kind: \"session\" };\n\t\t\tbreak;\n\t\tcase \"conversation\":\n\t\t\tscope = { kind: \"conversation\", conversationId: ownerId<ConversationId>(args[index++], definition) };\n\t\t\tbreak;\n\t\tcase \"task\":\n\t\t\tscope = { kind: \"task\", taskId: ownerId<TaskId>(args[index++], definition) };\n\t\t\tbreak;\n\t}\n\t// A key comes from data (a name, a slice of text): its lone surrogates become U+FFFD as in Chord's store, so the\n\t// stored key, the record's and every lookup's are one string.\n\tconst key = definition.family === true ? (args[index++] as string).toWellFormed() : undefined;\n\tif (key !== undefined) checkIdentity(\"Document key\", key);\n\tconst address: DocumentAddress =\n\t\tkey === undefined ? { kind: definition.kind, scope } : { kind: definition.kind, scope, key };\n\treturn { address, id: addressId(address), nextArgument: index };\n}\n\nfunction ownerId<I extends Id<string>>(value: unknown, definition: AnyDocDefinition): I {\n\tif (typeof value !== \"number\" || !Number.isSafeInteger(value)) {\n\t\tthrow new TypeError(`Document ${definition.kind} requires a ${definition.scope} ID`);\n\t}\n\treturn idFromNumber<I>(value);\n}\n\n/** Stable string identity of one logical address. */\nexport function addressId(address: DocumentAddress): string {\n\tconst owner =\n\t\taddress.scope.kind === \"session\"\n\t\t\t? null\n\t\t\t: address.scope.kind === \"conversation\"\n\t\t\t\t? address.scope.conversationId\n\t\t\t\t: address.scope.taskId;\n\treturn JSON.stringify([address.kind, address.scope.kind, owner, address.key ?? null]);\n}\n\n/** Build the storage create record for a new incarnation at an address. */\nexport function documentCreate(definition: AnyDocDefinition, address: DocumentAddress, id: DocumentId): DocumentCreate {\n\tconst key = address.key === undefined ? {} : { key: address.key };\n\tswitch (address.scope.kind) {\n\t\tcase \"session\":\n\t\t\treturn { id, kind: address.kind, ...key, scope: address.scope };\n\t\tcase \"task\":\n\t\t\treturn { id, kind: address.kind, ...key, scope: address.scope };\n\t\tcase \"conversation\":\n\t\t\treturn {\n\t\t\t\tid,\n\t\t\t\tkind: address.kind,\n\t\t\t\t...key,\n\t\t\t\tscope: address.scope,\n\t\t\t\thistory: definition.history!,\n\t\t\t\tfork: definition.fork!,\n\t\t\t} as DocumentCreate;\n\t}\n}\n\n/** Reject typed access whose token disagrees with the persisted scope, history, or fork semantics. */\nexport function checkRecordScope(definition: AnyDocDefinition, record: DocumentCreate | DocumentRecord): void {\n\tif (\n\t\trecord.scope.kind !== definition.scope ||\n\t\t(record.scope.kind === \"conversation\" &&\n\t\t\t(record.history !== definition.history || record.fork !== definition.fork))\n\t) {\n\t\tthrow new TypeError(`Document ${record.id} (${record.kind}) does not match the supplied definition semantics`);\n\t}\n}\n\n/** Reject typed access to a stored version the supplied definition cannot use. */\nexport function checkRecordVersion(\n\tdefinition: AnyDocDefinition,\n\trecord: DocumentCreate | DocumentRecord,\n\tversion: number,\n): void {\n\tif (version > definition.version) {\n\t\tthrow new Error(`Document ${record.id} (${record.kind}) has newer version ${version} than ${definition.version}`);\n\t}\n\tif (version < definition.version && definition.migrate === undefined) {\n\t\tthrow new Error(`Document ${record.id} (${record.kind}) requires migration from version ${version}`);\n\t}\n}\n\n/** Validate and materialize a detached stored value for typed access. */\nexport function materializeDocument(definition: AnyDocDefinition, stored: StoredDocument): JsonObject {\n\treturn materializeDocumentValue(definition, stored.record, stored.version, stored.value);\n}\n\n/** Validate and materialize one detached value before its first persisted incarnation. */\nexport function materializeDocumentValue(\n\tdefinition: AnyDocDefinition,\n\trecord: DocumentCreate | DocumentRecord,\n\tversion: number,\n\tvalue: JsonObject,\n): JsonObject {\n\tcheckRecordScope(definition, record);\n\tcheckRecordVersion(definition, record, version);\n\tif (version === definition.version) return value;\n\treturn copyJson(definition.migrate!(value, version)) as JsonObject;\n}\n"]}
|
package/dist/env/index.d.ts
CHANGED
|
@@ -192,6 +192,17 @@ export interface FileSystem {
|
|
|
192
192
|
truncateFile(path: string, size: number, context: Context): Promise<Result<void, FileError>>;
|
|
193
193
|
/** Flush file contents and metadata needed to retrieve them from an open file handle. */
|
|
194
194
|
flushFile(path: string, context: Context): Promise<Result<void, FileError>>;
|
|
195
|
+
/**
|
|
196
|
+
* Flush a directory's list of names to disk: files created, renamed or removed in it, and directories created in
|
|
197
|
+
* it, survive a power loss or an OS crash once this returns. This directory only, not its parents: a directory's
|
|
198
|
+
* own name lives in its parent, so a caller that created directories flushes each new one's parent too.
|
|
199
|
+
* `createDir` flushes nothing. A path that is no directory fails with `not_directory`.
|
|
200
|
+
*
|
|
201
|
+
* POSIX: the directory is opened read-only (with `O_DIRECTORY`) and fsynced. Windows: it is opened with write
|
|
202
|
+
* access (Windows flushes a handle only so) and flushed with `FlushFileBuffers`; CI showed this succeeds on NTFS,
|
|
203
|
+
* but no test there can show that a rename then survives a power loss.
|
|
204
|
+
*/
|
|
205
|
+
flushDir(path: string, context: Context): Promise<Result<void, FileError>>;
|
|
195
206
|
renameFile(sourcePath: string, destinationPath: string, context: Context): Promise<Result<void, FileError>>;
|
|
196
207
|
fileInfo(path: string, context: Context): Promise<Result<FileInfo, FileError>>;
|
|
197
208
|
listDir(path: string, context: Context): Promise<Result<FileInfo[], FileError>>;
|
package/dist/env/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/env/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,wFAAwF;AACxF,MAAM,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,IAAI;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhG,wBAAgB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAExE;AAED,wBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAEzE;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAGjF;AAED,wBAAgB,cAAc,CAAC,MAAM,SAAS,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,GAAG,SAAS,CAEhH;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAQ7C;AAED,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,SAAS,CAAC;AAExD,MAAM,MAAM,aAAa,GACtB,SAAS,GACT,WAAW,GACX,mBAAmB,GACnB,eAAe,GACf,cAAc,GACd,SAAS,GACT,eAAe,GACf,SAAS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,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;CACD;AAUD,MAAM,OAAO,cAAe,SAAQ,KAAK;IACjC,IAAI,CAAqB;IAChC,2GAA2G;IACpG,SAAS,CAAU;IAE1B,YAAY,IAAwB,EAAE,OAAe,EAAE,KAAa;QACnE,KAAK,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;CACD;AAgTD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["import type { Context } from \"@draht/chord/context\";\n\n/** Result of a fallible operation. Expected failures are returned instead of thrown. */\nexport type Result<TValue, TError> = { ok: true; value: TValue } | { ok: false; error: TError };\n\nexport function ok<TValue, TError>(value: TValue): Result<TValue, TError> {\n\treturn { ok: true, value };\n}\n\nexport function err<TValue, TError>(error: TError): Result<TValue, TError> {\n\treturn { ok: false, error };\n}\n\nexport function getOrThrow<TValue, TError>(result: Result<TValue, TError>): TValue {\n\tif (!result.ok) throw result.error;\n\treturn result.value;\n}\n\nexport function getOrUndefined<TValue extends object, TError>(result: Result<TValue, TError>): TValue | undefined {\n\treturn result.ok ? result.value : undefined;\n}\n\nexport function toError(error: unknown): Error {\n\tif (error instanceof Error) return error;\n\tif (typeof error === \"string\") return new Error(error);\n\ttry {\n\t\treturn new Error(JSON.stringify(error));\n\t} catch {\n\t\treturn new Error(String(error));\n\t}\n}\n\nexport type FileKind = \"file\" | \"directory\" | \"symlink\";\n\nexport type FileErrorCode =\n\t| \"aborted\"\n\t| \"not_found\"\n\t| \"permission_denied\"\n\t| \"not_directory\"\n\t| \"is_directory\"\n\t| \"invalid\"\n\t| \"not_supported\"\n\t| \"unknown\";\n\nexport class FileError extends Error {\n\tpublic code: FileErrorCode;\n\tpublic path?: string;\n\n\tconstructor(code: FileErrorCode, message: string, path?: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"FileError\";\n\t\tthis.code = code;\n\t\tthis.path = path;\n\t}\n}\n\nexport type ExecutionErrorCode =\n\t| \"aborted\"\n\t| \"timeout\"\n\t| \"shell_unavailable\"\n\t| \"spawn_error\"\n\t| \"callback_error\"\n\t| \"unknown\";\n\nexport class ExecutionError extends Error {\n\tpublic code: ExecutionErrorCode;\n\t/** Spill file of a command that timed out or was aborted after its output crossed the spill thresholds. */\n\tpublic spillPath?: string;\n\n\tconstructor(code: ExecutionErrorCode, message: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"ExecutionError\";\n\t\tthis.code = code;\n\t}\n}\n\nexport interface FileInfo {\n\tname: string;\n\tpath: string;\n\tkind: FileKind;\n\tsize: number;\n\tmtimeMs: number;\n}\n\nexport interface TextLine {\n\ttext: string;\n\tterminated: boolean;\n}\n\nexport interface TextLineReader {\n\treadLine(context: Context): Promise<Result<TextLine | undefined, FileError>>;\n\tclose(context: Context): Promise<void>;\n}\n\n/** Positional reads from one opened regular file; all calls see the same file even if its path is renamed. */\nexport interface BinaryReader {\n\t/** Metadata of the opened file, not of whatever its path names now. */\n\tinfo(context: Context): Promise<Result<FileInfo, FileError>>;\n\t/** Up to `length` bytes at `offset`; fewer only at end of file. */\n\tread(offset: number, length: number, context: Context): Promise<Result<Uint8Array, FileError>>;\n\t/**\n\t * One pass over the file that locates lines `[startLine, endLine)` (`endLine` absent: to the end), 0-based, where line\n\t * `k` starts after the `k`-th newline byte. Decoded sizes are those of the text `new TextDecoder().decode(file)` would\n\t * produce for that range, so a byte-order mark at the start of the file is not counted.\n\t */\n\tscanLines(options: { startLine: number; endLine?: number }, context: Context): Promise<Result<LineScan, FileError>>;\n\tclose(context: Context): Promise<void>;\n}\n\n/** A file or directory to watch. It may be missing; creating it is a change. */\nexport interface WatchTarget {\n\tpath: string;\n\t/** Watch everything below a directory, not only its entries. Symbolic links below it are not followed. */\n\trecursive?: boolean;\n\t/** Entries below `path` that are neither watched nor reported: names starting with `.`, or these names. */\n\texclude?: { hidden?: boolean; names?: readonly string[] };\n}\n\n/**\n * What changed, tagged by `kind`:\n * - `paths`: something at or below each path may have changed (a directory path covers its whole subtree). Calls may be\n * spurious; a change is never missed while the watcher is healthy.\n * - `overflow`: coverage was uncertain for a while (lost events, reconnect); rescan everything that is watched.\n * - `failed`: the watcher stopped with `error`, for example because the watched tree grew past the environment's limit;\n * no calls follow.\n */\nexport type FileChange =\n\t| { readonly kind: \"paths\"; readonly paths: string[] }\n\t| { readonly kind: \"overflow\" }\n\t| { readonly kind: \"failed\"; readonly error: FileError };\n\nexport interface FileWatcher {\n\t/**\n\t * `native`: changes are reported within about two seconds. `polling`: the environment compares snapshots, because\n\t * the file system does not report changes reliably (network and FUSE file systems); a change undone between two\n\t * snapshots can be missed.\n\t */\n\treadonly mode: \"native\" | \"polling\";\n\t/** Stop watching; no `onChange` call starts after this resolves. Idempotent. */\n\tstop(context: Context): Promise<void>;\n}\n\n/** Where lines of a file are, as `BinaryReader.scanLines` found them. */\nexport interface LineScan {\n\t/** Newline bytes in the whole file; it has `newlines + 1` lines. */\n\tnewlines: number;\n\t/**\n\t * Byte range of the selected lines: from the start of the first to the end of the last, without the newline that\n\t * ends it. A selection past the last line is empty at the end of the file.\n\t */\n\tstart: number;\n\tend: number;\n\t/** Where the first selected line ends: its newline, or the end of the file. */\n\tfirstLineEnd: number;\n\t/** Where the last selected line starts. */\n\tlastLineStart: number;\n\t/** UTF-8 byte length of the decoded selection and of its first line. */\n\tselectedBytes: number;\n\tfirstLineBytes: number;\n}\n\n/** Pages of one directory's entries. */\nexport interface DirReader {\n\t/**\n\t * Up to `maxEntries` entries in the order the file system returns them, continuing where the previous call stopped.\n\t * `done` marks the end; it may come with the last entries or with an empty page. An entry that disappears before its\n\t * metadata is read is skipped, as are entries of unsupported kinds. After a failed or aborted call, close the reader.\n\t */\n\tnext(maxEntries: number, context: Context): Promise<Result<{ entries: FileInfo[]; done: boolean }, FileError>>;\n\tclose(context: Context): Promise<void>;\n}\n\n/** What `FileSystem.listFiles` lists. */\nexport interface ListFilesOptions {\n\t/**\n\t * Include names starting with `.` (on Windows also files with the hidden attribute); default true. Entries named\n\t * `.git` are never listed.\n\t */\n\thidden?: boolean;\n\t/**\n\t * Inside a git work tree, skip what git ignores: the `.gitignore` files of the directory, its subdirectories and its\n\t * parents, `.git/info/exclude`, and the global excludes file; default true. Unlike `git ls-files`, a tracked file that\n\t * matches an ignore rule is skipped too. Outside work trees, `.gitignore` files have no effect.\n\t */\n\tgitignore?: boolean;\n\t/** Names of entries to skip with everything below them, such as `node_modules`. */\n\texclude?: readonly string[];\n\t/** Most entries to list; default 50 000. */\n\tmaxEntries?: number;\n\t/** Most bytes of the listing: each entry's UTF-8 path plus two; default 4 MiB, at most 15.9 MiB. */\n\tmaxBytes?: number;\n\t/** Time after which the listing stops; default 10 000 ms. */\n\ttimeoutMs?: number;\n}\n\n/** One entry of a `FileListing`. */\nexport interface FileListEntry {\n\t/** Relative to the listed directory, with `/` separators on every system. */\n\tpath: string;\n\t/** A symbolic link is listed as such and not followed. */\n\tkind: FileKind;\n}\n\nexport interface FileListing {\n\t/** Depth first, parents before their entries, siblings in byte order of their names. */\n\tentries: FileListEntry[];\n\t/** A bound in `ListFilesOptions` ended the listing early. */\n\ttruncated: boolean;\n}\n\n/** Portable filesystem capability. Operations return failures rather than throwing. */\nexport interface FileSystem {\n\t/**\n\t * The file namespace: equal ids see the same files at the same paths, whatever their `cwd`. Every local Node\n\t * environment shares one id; each container or remote host has its own.\n\t */\n\treadonly id: string;\n\tcwd: string;\n\tabsolutePath(path: string, context: Context): Promise<Result<string, FileError>>;\n\tjoinPath(parts: string[], context: Context): Promise<Result<string, FileError>>;\n\treadTextFile(path: string, context: Context): Promise<Result<string, FileError>>;\n\topenTextLineReader(path: string, context: Context): Promise<Result<TextLineReader, FileError>>;\n\treadTextLines(\n\t\tpath: string,\n\t\toptions: { maxLines?: number } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<string[], FileError>>;\n\treadBinaryFile(path: string, context: Context): Promise<Result<Uint8Array, FileError>>;\n\t/**\n\t * Open a regular file for bounded positional reads. A directory fails with `is_directory`, other non-regular files\n\t * with `invalid`. With `noFollow`, a symbolic link as the final path component fails with `invalid` instead of being\n\t * followed; earlier components are still resolved.\n\t */\n\topenBinaryReader(\n\t\tpath: string,\n\t\toptions: { noFollow?: boolean } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<BinaryReader, FileError>>;\n\twriteFile(path: string, content: string | Uint8Array, context: Context): Promise<Result<void, FileError>>;\n\tappendFile(path: string, content: string | Uint8Array, context: Context): Promise<Result<void, FileError>>;\n\t/** Truncate or extend a file to exactly `size` bytes. */\n\ttruncateFile(path: string, size: number, context: Context): Promise<Result<void, FileError>>;\n\t/** Flush file contents and metadata needed to retrieve them from an open file handle. */\n\tflushFile(path: string, context: Context): Promise<Result<void, FileError>>;\n\trenameFile(sourcePath: string, destinationPath: string, context: Context): Promise<Result<void, FileError>>;\n\tfileInfo(path: string, context: Context): Promise<Result<FileInfo, FileError>>;\n\tlistDir(path: string, context: Context): Promise<Result<FileInfo[], FileError>>;\n\t/**\n\t * Optional: the files, directories and symbolic links below a directory, at any depth, for indexes such as file\n\t * completion. Symbolic links are not followed; other kinds of files are not listed; entries that cannot be read are\n\t * skipped. See `ListFilesOptions` for hidden and ignored files and for the bounds. Fails with `not_supported` when\n\t * the environment cannot list right now (an older remote daemon), so callers fall back to their own walk.\n\t */\n\tlistFiles?(\n\t\tpath: string,\n\t\toptions: ListFilesOptions | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<FileListing, FileError>>;\n\topenDirReader(path: string, context: Context): Promise<Result<DirReader, FileError>>;\n\t/**\n\t * Report changes to files and directories, for hosts that load resources from the environment. When the returned\n\t * watcher exists, coverage is established: a host that watches before it loads cannot miss a change made during the\n\t * load. See `FileChange` for what is reported and `FileWatcher.mode` for how reliably.\n\t */\n\twatch(\n\t\ttargets: readonly WatchTarget[],\n\t\tonChange: (change: FileChange) => void,\n\t\tcontext: Context,\n\t): Promise<Result<FileWatcher, FileError>>;\n\tcanonicalPath(path: string, context: Context): Promise<Result<string, FileError>>;\n\texists(path: string, context: Context): Promise<Result<boolean, FileError>>;\n\tcreateDir(\n\t\tpath: string,\n\t\toptions: { recursive?: boolean } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<void, FileError>>;\n\tremove(\n\t\tpath: string,\n\t\toptions: { recursive?: boolean; force?: boolean } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<void, FileError>>;\n\tcreateTempDir(prefix: string | undefined, context: Context): Promise<Result<string, FileError>>;\n\tcreateTempFile(\n\t\toptions: { prefix?: string; suffix?: string } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<string, FileError>>;\n\tcleanup(context: Context): Promise<void>;\n}\n\n/** Spill the complete output to a temporary file once it exceeds either threshold. */\nexport interface ShellSpillOptions {\n\tafterBytes: number;\n\t/** Complete or partial lines. */\n\tafterLines: number;\n}\n\nexport interface ShellExecResult {\n\texitCode: number;\n\t/** Temporary file holding the complete raw output, when the spill thresholds were exceeded. */\n\tspillPath?: string;\n}\n\nexport interface ShellExecOptions {\n\tcwd?: string;\n\tenv?: Record<string, string>;\n\tinheritEnv?: boolean;\n\ttimeout?: number;\n\t/**\n\t * Every decoded chunk of stdout and stderr as it arrives, in arrival order, with the stream it came from: raw,\n\t * unbounded, and unthrottled. Each stream is decoded separately, so a character split across chunks survives.\n\t */\n\tonOutput?: (text: string, context: Context, info: ShellOutputInfo) => void;\n\tspill?: ShellSpillOptions;\n\t/**\n\t * The caller keeps only this tail of the output, so the environment may omit output outside it and report the omission\n\t * as `info.skipped`. Without it, every chunk is delivered.\n\t */\n\twindow?: ShellOutputWindow;\n}\n\n/**\n * The tail of the combined output a caller keeps, and how often it samples it. An environment that transfers output\n * over a slow link uses it to omit what the caller would drop anyway and to send no faster than the caller commits.\n */\nexport interface ShellOutputWindow {\n\t/** UTF-8 bytes of decoded text kept at the end of the output. */\n\tmaxBytes: number;\n\t/** Lines kept at the end of the output. */\n\tmaxLines: number;\n\t/** Minimum pause between the caller's samples of the output. */\n\tminIntervalMs: number;\n\t/** Each sample also pauses the caller in proportion to its size at this rate. */\n\tbytesPerSecond: number;\n}\n\n/**\n * Output an environment omitted, measured on the decoded text `onOutput` would have received: every U+FFFD counts as\n * three bytes, and no sanitizing is applied.\n */\n/** The shape of `OutputSkip` from `@draht/chord/output`, which `OutputBuffer.push()` accepts. */\nexport interface ShellOutputSkip {\n\t/** UTF-8 byte length of the omitted text. */\n\tbytes: number;\n\t/** Newlines (U+000A) in the omitted text. */\n\tnewlines: number;\n\t/** Whether the omitted text ends with a newline. */\n\tendsWithNewline: boolean;\n}\n\nexport interface ShellOutputInfo {\n\tstream: \"stdout\" | \"stderr\";\n\t/**\n\t * Output omitted immediately before this chunk, only with `window`. The chunk then holds all output after the\n\t * omission up to its end, and that is more than the window by at least one byte or one line: more than\n\t * `window.maxBytes` bytes or more than `window.maxLines` newlines. So the omitted text can never be in the kept tail.\n\t * The omission and such a chunk may span both streams in arrival order; `stream` then names the chunk's last stream.\n\t * Callers that need the streams apart do not pass `window`.\n\t */\n\tskipped?: ShellOutputSkip;\n}\n\nexport interface Shell {\n\t/**\n\t * Run a command. A string runs through the environment's shell. An array runs `command[0]` directly with the rest\n\t * as its arguments, without a shell, so they reach the program unparsed. Aborting the context or a timeout kills\n\t * only this command's processes.\n\t */\n\texec(\n\t\tcommand: string | readonly string[],\n\t\toptions: ShellExecOptions | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<ShellExecResult, ExecutionError>>;\n\t/** Kill every command this environment still runs; for its owner's shutdown, never for one request. */\n\tcleanup(context: Context): Promise<void>;\n}\n\nexport interface ExecutionEnv extends FileSystem, Shell {}\n\nexport { rangeDecoder, StreamDecoder, startsWithBom } from \"./decode.ts\";\nexport { LineScanner } from \"./line-scan.ts\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/env/index.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,EAAE,CAAiB,KAAa;IAC/C,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,GAAG,CAAiB,KAAa;IAChD,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,UAAU,CAAiB,MAA8B;IACxE,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,MAAM,MAAM,CAAC,KAAK,CAAC;IACnC,OAAO,MAAM,CAAC,KAAK,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,cAAc,CAAgC,MAA8B;IAC3F,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,KAAc;IACrC,IAAI,KAAK,YAAY,KAAK;QAAE,OAAO,KAAK,CAAC;IACzC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;IACvD,IAAI,CAAC;QACJ,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IACzC,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACjC,CAAC;AACF,CAAC;AAcD,MAAM,OAAO,SAAU,SAAQ,KAAK;IAC5B,IAAI,CAAgB;IACpB,IAAI,CAAU;IAErB,YAAY,IAAmB,EAAE,OAAe,EAAE,IAAa,EAAE,KAAa;QAC7E,KAAK,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;CACD;AAUD,MAAM,OAAO,cAAe,SAAQ,KAAK;IACjC,IAAI,CAAqB;IAChC,2GAA2G;IACpG,SAAS,CAAU;IAE1B,YAAY,IAAwB,EAAE,OAAe,EAAE,KAAa;QACnE,KAAK,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;CACD;AA2TD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["import type { Context } from \"@draht/chord/context\";\n\n/** Result of a fallible operation. Expected failures are returned instead of thrown. */\nexport type Result<TValue, TError> = { ok: true; value: TValue } | { ok: false; error: TError };\n\nexport function ok<TValue, TError>(value: TValue): Result<TValue, TError> {\n\treturn { ok: true, value };\n}\n\nexport function err<TValue, TError>(error: TError): Result<TValue, TError> {\n\treturn { ok: false, error };\n}\n\nexport function getOrThrow<TValue, TError>(result: Result<TValue, TError>): TValue {\n\tif (!result.ok) throw result.error;\n\treturn result.value;\n}\n\nexport function getOrUndefined<TValue extends object, TError>(result: Result<TValue, TError>): TValue | undefined {\n\treturn result.ok ? result.value : undefined;\n}\n\nexport function toError(error: unknown): Error {\n\tif (error instanceof Error) return error;\n\tif (typeof error === \"string\") return new Error(error);\n\ttry {\n\t\treturn new Error(JSON.stringify(error));\n\t} catch {\n\t\treturn new Error(String(error));\n\t}\n}\n\nexport type FileKind = \"file\" | \"directory\" | \"symlink\";\n\nexport type FileErrorCode =\n\t| \"aborted\"\n\t| \"not_found\"\n\t| \"permission_denied\"\n\t| \"not_directory\"\n\t| \"is_directory\"\n\t| \"invalid\"\n\t| \"not_supported\"\n\t| \"unknown\";\n\nexport class FileError extends Error {\n\tpublic code: FileErrorCode;\n\tpublic path?: string;\n\n\tconstructor(code: FileErrorCode, message: string, path?: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"FileError\";\n\t\tthis.code = code;\n\t\tthis.path = path;\n\t}\n}\n\nexport type ExecutionErrorCode =\n\t| \"aborted\"\n\t| \"timeout\"\n\t| \"shell_unavailable\"\n\t| \"spawn_error\"\n\t| \"callback_error\"\n\t| \"unknown\";\n\nexport class ExecutionError extends Error {\n\tpublic code: ExecutionErrorCode;\n\t/** Spill file of a command that timed out or was aborted after its output crossed the spill thresholds. */\n\tpublic spillPath?: string;\n\n\tconstructor(code: ExecutionErrorCode, message: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"ExecutionError\";\n\t\tthis.code = code;\n\t}\n}\n\nexport interface FileInfo {\n\tname: string;\n\tpath: string;\n\tkind: FileKind;\n\tsize: number;\n\tmtimeMs: number;\n}\n\nexport interface TextLine {\n\ttext: string;\n\tterminated: boolean;\n}\n\nexport interface TextLineReader {\n\treadLine(context: Context): Promise<Result<TextLine | undefined, FileError>>;\n\tclose(context: Context): Promise<void>;\n}\n\n/** Positional reads from one opened regular file; all calls see the same file even if its path is renamed. */\nexport interface BinaryReader {\n\t/** Metadata of the opened file, not of whatever its path names now. */\n\tinfo(context: Context): Promise<Result<FileInfo, FileError>>;\n\t/** Up to `length` bytes at `offset`; fewer only at end of file. */\n\tread(offset: number, length: number, context: Context): Promise<Result<Uint8Array, FileError>>;\n\t/**\n\t * One pass over the file that locates lines `[startLine, endLine)` (`endLine` absent: to the end), 0-based, where line\n\t * `k` starts after the `k`-th newline byte. Decoded sizes are those of the text `new TextDecoder().decode(file)` would\n\t * produce for that range, so a byte-order mark at the start of the file is not counted.\n\t */\n\tscanLines(options: { startLine: number; endLine?: number }, context: Context): Promise<Result<LineScan, FileError>>;\n\tclose(context: Context): Promise<void>;\n}\n\n/** A file or directory to watch. It may be missing; creating it is a change. */\nexport interface WatchTarget {\n\tpath: string;\n\t/** Watch everything below a directory, not only its entries. Symbolic links below it are not followed. */\n\trecursive?: boolean;\n\t/** Entries below `path` that are neither watched nor reported: names starting with `.`, or these names. */\n\texclude?: { hidden?: boolean; names?: readonly string[] };\n}\n\n/**\n * What changed, tagged by `kind`:\n * - `paths`: something at or below each path may have changed (a directory path covers its whole subtree). Calls may be\n * spurious; a change is never missed while the watcher is healthy.\n * - `overflow`: coverage was uncertain for a while (lost events, reconnect); rescan everything that is watched.\n * - `failed`: the watcher stopped with `error`, for example because the watched tree grew past the environment's limit;\n * no calls follow.\n */\nexport type FileChange =\n\t| { readonly kind: \"paths\"; readonly paths: string[] }\n\t| { readonly kind: \"overflow\" }\n\t| { readonly kind: \"failed\"; readonly error: FileError };\n\nexport interface FileWatcher {\n\t/**\n\t * `native`: changes are reported within about two seconds. `polling`: the environment compares snapshots, because\n\t * the file system does not report changes reliably (network and FUSE file systems); a change undone between two\n\t * snapshots can be missed.\n\t */\n\treadonly mode: \"native\" | \"polling\";\n\t/** Stop watching; no `onChange` call starts after this resolves. Idempotent. */\n\tstop(context: Context): Promise<void>;\n}\n\n/** Where lines of a file are, as `BinaryReader.scanLines` found them. */\nexport interface LineScan {\n\t/** Newline bytes in the whole file; it has `newlines + 1` lines. */\n\tnewlines: number;\n\t/**\n\t * Byte range of the selected lines: from the start of the first to the end of the last, without the newline that\n\t * ends it. A selection past the last line is empty at the end of the file.\n\t */\n\tstart: number;\n\tend: number;\n\t/** Where the first selected line ends: its newline, or the end of the file. */\n\tfirstLineEnd: number;\n\t/** Where the last selected line starts. */\n\tlastLineStart: number;\n\t/** UTF-8 byte length of the decoded selection and of its first line. */\n\tselectedBytes: number;\n\tfirstLineBytes: number;\n}\n\n/** Pages of one directory's entries. */\nexport interface DirReader {\n\t/**\n\t * Up to `maxEntries` entries in the order the file system returns them, continuing where the previous call stopped.\n\t * `done` marks the end; it may come with the last entries or with an empty page. An entry that disappears before its\n\t * metadata is read is skipped, as are entries of unsupported kinds. After a failed or aborted call, close the reader.\n\t */\n\tnext(maxEntries: number, context: Context): Promise<Result<{ entries: FileInfo[]; done: boolean }, FileError>>;\n\tclose(context: Context): Promise<void>;\n}\n\n/** What `FileSystem.listFiles` lists. */\nexport interface ListFilesOptions {\n\t/**\n\t * Include names starting with `.` (on Windows also files with the hidden attribute); default true. Entries named\n\t * `.git` are never listed.\n\t */\n\thidden?: boolean;\n\t/**\n\t * Inside a git work tree, skip what git ignores: the `.gitignore` files of the directory, its subdirectories and its\n\t * parents, `.git/info/exclude`, and the global excludes file; default true. Unlike `git ls-files`, a tracked file that\n\t * matches an ignore rule is skipped too. Outside work trees, `.gitignore` files have no effect.\n\t */\n\tgitignore?: boolean;\n\t/** Names of entries to skip with everything below them, such as `node_modules`. */\n\texclude?: readonly string[];\n\t/** Most entries to list; default 50 000. */\n\tmaxEntries?: number;\n\t/** Most bytes of the listing: each entry's UTF-8 path plus two; default 4 MiB, at most 15.9 MiB. */\n\tmaxBytes?: number;\n\t/** Time after which the listing stops; default 10 000 ms. */\n\ttimeoutMs?: number;\n}\n\n/** One entry of a `FileListing`. */\nexport interface FileListEntry {\n\t/** Relative to the listed directory, with `/` separators on every system. */\n\tpath: string;\n\t/** A symbolic link is listed as such and not followed. */\n\tkind: FileKind;\n}\n\nexport interface FileListing {\n\t/** Depth first, parents before their entries, siblings in byte order of their names. */\n\tentries: FileListEntry[];\n\t/** A bound in `ListFilesOptions` ended the listing early. */\n\ttruncated: boolean;\n}\n\n/** Portable filesystem capability. Operations return failures rather than throwing. */\nexport interface FileSystem {\n\t/**\n\t * The file namespace: equal ids see the same files at the same paths, whatever their `cwd`. Every local Node\n\t * environment shares one id; each container or remote host has its own.\n\t */\n\treadonly id: string;\n\tcwd: string;\n\tabsolutePath(path: string, context: Context): Promise<Result<string, FileError>>;\n\tjoinPath(parts: string[], context: Context): Promise<Result<string, FileError>>;\n\treadTextFile(path: string, context: Context): Promise<Result<string, FileError>>;\n\topenTextLineReader(path: string, context: Context): Promise<Result<TextLineReader, FileError>>;\n\treadTextLines(\n\t\tpath: string,\n\t\toptions: { maxLines?: number } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<string[], FileError>>;\n\treadBinaryFile(path: string, context: Context): Promise<Result<Uint8Array, FileError>>;\n\t/**\n\t * Open a regular file for bounded positional reads. A directory fails with `is_directory`, other non-regular files\n\t * with `invalid`. With `noFollow`, a symbolic link as the final path component fails with `invalid` instead of being\n\t * followed; earlier components are still resolved.\n\t */\n\topenBinaryReader(\n\t\tpath: string,\n\t\toptions: { noFollow?: boolean } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<BinaryReader, FileError>>;\n\twriteFile(path: string, content: string | Uint8Array, context: Context): Promise<Result<void, FileError>>;\n\tappendFile(path: string, content: string | Uint8Array, context: Context): Promise<Result<void, FileError>>;\n\t/** Truncate or extend a file to exactly `size` bytes. */\n\ttruncateFile(path: string, size: number, context: Context): Promise<Result<void, FileError>>;\n\t/** Flush file contents and metadata needed to retrieve them from an open file handle. */\n\tflushFile(path: string, context: Context): Promise<Result<void, FileError>>;\n\t/**\n\t * Flush a directory's list of names to disk: files created, renamed or removed in it, and directories created in\n\t * it, survive a power loss or an OS crash once this returns. This directory only, not its parents: a directory's\n\t * own name lives in its parent, so a caller that created directories flushes each new one's parent too.\n\t * `createDir` flushes nothing. A path that is no directory fails with `not_directory`.\n\t *\n\t * POSIX: the directory is opened read-only (with `O_DIRECTORY`) and fsynced. Windows: it is opened with write\n\t * access (Windows flushes a handle only so) and flushed with `FlushFileBuffers`; CI showed this succeeds on NTFS,\n\t * but no test there can show that a rename then survives a power loss.\n\t */\n\tflushDir(path: string, context: Context): Promise<Result<void, FileError>>;\n\trenameFile(sourcePath: string, destinationPath: string, context: Context): Promise<Result<void, FileError>>;\n\tfileInfo(path: string, context: Context): Promise<Result<FileInfo, FileError>>;\n\tlistDir(path: string, context: Context): Promise<Result<FileInfo[], FileError>>;\n\t/**\n\t * Optional: the files, directories and symbolic links below a directory, at any depth, for indexes such as file\n\t * completion. Symbolic links are not followed; other kinds of files are not listed; entries that cannot be read are\n\t * skipped. See `ListFilesOptions` for hidden and ignored files and for the bounds. Fails with `not_supported` when\n\t * the environment cannot list right now (an older remote daemon), so callers fall back to their own walk.\n\t */\n\tlistFiles?(\n\t\tpath: string,\n\t\toptions: ListFilesOptions | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<FileListing, FileError>>;\n\topenDirReader(path: string, context: Context): Promise<Result<DirReader, FileError>>;\n\t/**\n\t * Report changes to files and directories, for hosts that load resources from the environment. When the returned\n\t * watcher exists, coverage is established: a host that watches before it loads cannot miss a change made during the\n\t * load. See `FileChange` for what is reported and `FileWatcher.mode` for how reliably.\n\t */\n\twatch(\n\t\ttargets: readonly WatchTarget[],\n\t\tonChange: (change: FileChange) => void,\n\t\tcontext: Context,\n\t): Promise<Result<FileWatcher, FileError>>;\n\tcanonicalPath(path: string, context: Context): Promise<Result<string, FileError>>;\n\texists(path: string, context: Context): Promise<Result<boolean, FileError>>;\n\tcreateDir(\n\t\tpath: string,\n\t\toptions: { recursive?: boolean } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<void, FileError>>;\n\tremove(\n\t\tpath: string,\n\t\toptions: { recursive?: boolean; force?: boolean } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<void, FileError>>;\n\tcreateTempDir(prefix: string | undefined, context: Context): Promise<Result<string, FileError>>;\n\tcreateTempFile(\n\t\toptions: { prefix?: string; suffix?: string } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<string, FileError>>;\n\tcleanup(context: Context): Promise<void>;\n}\n\n/** Spill the complete output to a temporary file once it exceeds either threshold. */\nexport interface ShellSpillOptions {\n\tafterBytes: number;\n\t/** Complete or partial lines. */\n\tafterLines: number;\n}\n\nexport interface ShellExecResult {\n\texitCode: number;\n\t/** Temporary file holding the complete raw output, when the spill thresholds were exceeded. */\n\tspillPath?: string;\n}\n\nexport interface ShellExecOptions {\n\tcwd?: string;\n\tenv?: Record<string, string>;\n\tinheritEnv?: boolean;\n\ttimeout?: number;\n\t/**\n\t * Every decoded chunk of stdout and stderr as it arrives, in arrival order, with the stream it came from: raw,\n\t * unbounded, and unthrottled. Each stream is decoded separately, so a character split across chunks survives.\n\t */\n\tonOutput?: (text: string, context: Context, info: ShellOutputInfo) => void;\n\tspill?: ShellSpillOptions;\n\t/**\n\t * The caller keeps only this tail of the output, so the environment may omit output outside it and report the omission\n\t * as `info.skipped`. Without it, every chunk is delivered.\n\t */\n\twindow?: ShellOutputWindow;\n}\n\n/**\n * The tail of the combined output a caller keeps, and how often it samples it. An environment that transfers output\n * over a slow link uses it to omit what the caller would drop anyway and to send no faster than the caller commits.\n */\nexport interface ShellOutputWindow {\n\t/** UTF-8 bytes of decoded text kept at the end of the output. */\n\tmaxBytes: number;\n\t/** Lines kept at the end of the output. */\n\tmaxLines: number;\n\t/** Minimum pause between the caller's samples of the output. */\n\tminIntervalMs: number;\n\t/** Each sample also pauses the caller in proportion to its size at this rate. */\n\tbytesPerSecond: number;\n}\n\n/**\n * Output an environment omitted, measured on the decoded text `onOutput` would have received: every U+FFFD counts as\n * three bytes, and no sanitizing is applied.\n */\n/** The shape of `OutputSkip` from `@draht/chord/output`, which `OutputBuffer.push()` accepts. */\nexport interface ShellOutputSkip {\n\t/** UTF-8 byte length of the omitted text. */\n\tbytes: number;\n\t/** Newlines (U+000A) in the omitted text. */\n\tnewlines: number;\n\t/** Whether the omitted text ends with a newline. */\n\tendsWithNewline: boolean;\n}\n\nexport interface ShellOutputInfo {\n\tstream: \"stdout\" | \"stderr\";\n\t/**\n\t * Output omitted immediately before this chunk, only with `window`. The chunk then holds all output after the\n\t * omission up to its end, and that is more than the window by at least one byte or one line: more than\n\t * `window.maxBytes` bytes or more than `window.maxLines` newlines. So the omitted text can never be in the kept tail.\n\t * The omission and such a chunk may span both streams in arrival order; `stream` then names the chunk's last stream.\n\t * Callers that need the streams apart do not pass `window`.\n\t */\n\tskipped?: ShellOutputSkip;\n}\n\nexport interface Shell {\n\t/**\n\t * Run a command. A string runs through the environment's shell. An array runs `command[0]` directly with the rest\n\t * as its arguments, without a shell, so they reach the program unparsed. Aborting the context or a timeout kills\n\t * only this command's processes.\n\t */\n\texec(\n\t\tcommand: string | readonly string[],\n\t\toptions: ShellExecOptions | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<ShellExecResult, ExecutionError>>;\n\t/** Kill every command this environment still runs; for its owner's shutdown, never for one request. */\n\tcleanup(context: Context): Promise<void>;\n}\n\nexport interface ExecutionEnv extends FileSystem, Shell {}\n\nexport { rangeDecoder, StreamDecoder, startsWithBom } from \"./decode.ts\";\nexport { LineScanner } from \"./line-scan.ts\";\n"]}
|
package/dist/env/node.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export declare class NodeExecutionEnv implements ExecutionEnv {
|
|
|
32
32
|
appendFile(path: string, content: string | Uint8Array, context: Context): Promise<Result<void, FileError>>;
|
|
33
33
|
truncateFile(path: string, size: number, context: Context): Promise<Result<void, FileError>>;
|
|
34
34
|
flushFile(path: string, context: Context): Promise<Result<void, FileError>>;
|
|
35
|
+
flushDir(path: string, context: Context): Promise<Result<void, FileError>>;
|
|
35
36
|
renameFile(sourcePath: string, destinationPath: string, context: Context): Promise<Result<void, FileError>>;
|
|
36
37
|
fileInfo(path: string, context: Context): Promise<Result<FileInfo, FileError>>;
|
|
37
38
|
listDir(path: string, context: Context): Promise<Result<FileInfo[], FileError>>;
|
package/dist/env/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/env/node.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/env/node.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,cAAc,EAEd,KAAK,UAAU,EACf,SAAS,EACT,KAAK,QAAQ,EAEb,KAAK,WAAW,EAGhB,KAAK,MAAM,EACX,KAAK,gBAAgB,EACrB,KAAK,eAAe,EAGpB,KAAK,cAAc,EAEnB,KAAK,WAAW,EAChB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAmB,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AA8lBzE,qBAAa,gBAAiB,YAAW,YAAY;IACpD,mDAAmD;IACnD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAgB;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,SAAS,CAAC,CAAS;IAC3B,OAAO,CAAC,QAAQ,CAAC,CAAoB;IACrC,OAAO,CAAC,YAAY,CAAmB;IACvC,OAAO,CAAC,eAAe,CAAqB;IAE5C,YAAY,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;QAAC,KAAK,CAAC,EAAE,gBAAgB,CAAA;KAAE,EAK/G;IAEK,KAAK,CACV,OAAO,EA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C,MAAM,EAAE,SAAS,CAAC,CAAC,CAUpC;IAEK,OAAO,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAG9C;CACD;AACD,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/env/node.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import { constants, createWriteStream } from "node:fs";
|
|
4
|
-
import { access, appendFile, lstat, mkdir, mkdtemp, opendir, open as openFile, readdir, readFile, realpath, rename, rm, writeFile, } from "node:fs/promises";
|
|
4
|
+
import { access, appendFile, lstat, mkdir, mkdtemp, opendir, open as openFile, readdir, readFile, realpath, rename, rm, stat, writeFile, } from "node:fs/promises";
|
|
5
5
|
import { homedir, constants as osConstants, tmpdir } from "node:os";
|
|
6
6
|
import { basename, isAbsolute, join, resolve, win32 } from "node:path";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
@@ -139,16 +139,33 @@ async function runCommand(command, args, timeoutMs) {
|
|
|
139
139
|
});
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
|
-
async function
|
|
143
|
-
const result = process.platform === "win32"
|
|
144
|
-
? await runCommand("where", ["bash.exe"], 5000)
|
|
145
|
-
: await runCommand("which", ["bash"], 5000);
|
|
142
|
+
async function findExecutableOnPath(executable) {
|
|
143
|
+
const result = await runCommand(process.platform === "win32" ? "where" : "which", [executable], 5000);
|
|
146
144
|
if (result.status !== 0 || !result.stdout)
|
|
147
145
|
return null;
|
|
148
146
|
const firstMatch = result.stdout.trim().split(/\r?\n/)[0];
|
|
149
147
|
return firstMatch && (await pathExists(firstMatch)) ? firstMatch : null;
|
|
150
148
|
}
|
|
151
149
|
// Keep in sync with packages/coding-agent/src/utils/shell.ts.
|
|
150
|
+
// Git for Windows reports its POSIX shell as `<root>/usr/bin/sh.exe`.
|
|
151
|
+
const GIT_FOR_WINDOWS_SHELL_SUFFIX = win32.join("usr", "bin", "sh.exe");
|
|
152
|
+
// Git Bash of the Git for Windows installation whose git.exe is on PATH, wherever it is installed.
|
|
153
|
+
// Returns the `<root>\bin\bash.exe` launcher, which sets up MSYSTEM and PATH for `usr\bin\bash.exe`.
|
|
154
|
+
async function findGitBashOfGitOnPath() {
|
|
155
|
+
const git = await findExecutableOnPath("git.exe");
|
|
156
|
+
if (!git)
|
|
157
|
+
return null;
|
|
158
|
+
const result = await runCommand(git, ["var", "GIT_SHELL_PATH"], 5000);
|
|
159
|
+
if (result.status !== 0)
|
|
160
|
+
return null;
|
|
161
|
+
const gitShell = win32.normalize(result.stdout.trim());
|
|
162
|
+
if (!gitShell.toLowerCase().endsWith(`\\${GIT_FOR_WINDOWS_SHELL_SUFFIX}`))
|
|
163
|
+
return null;
|
|
164
|
+
const bash = win32.join(gitShell.slice(0, -GIT_FOR_WINDOWS_SHELL_SUFFIX.length), "bin", "bash.exe");
|
|
165
|
+
return (await pathExists(bash)) ? bash : null;
|
|
166
|
+
}
|
|
167
|
+
const SHELL_COMMAND_ENV_VAR = "DRAHT_BASH_COMMAND";
|
|
168
|
+
// Keep in sync with packages/coding-agent/src/utils/shell.ts.
|
|
152
169
|
function isLegacyWslBashPath(path) {
|
|
153
170
|
const normalized = win32.normalize(path).toLowerCase();
|
|
154
171
|
const systemRoot = process.env.SystemRoot;
|
|
@@ -160,8 +177,30 @@ function isLegacyWslBashPath(path) {
|
|
|
160
177
|
// Fall back to conventional launcher paths only when the Windows directory is unknown.
|
|
161
178
|
return /^[a-z]:\\windows\\(?:system32|sysnative)\\bash\.exe$/.test(normalized);
|
|
162
179
|
}
|
|
180
|
+
// Keep in sync with packages/coding-agent/src/utils/shell.ts.
|
|
181
|
+
// Bash builds for Windows (Git Bash, MSYS2, Cygwin) parse their command line with the Cygwin
|
|
182
|
+
// runtime, which silently cuts quoted arguments after about 8 KB and splits unquoted ones at
|
|
183
|
+
// newlines (#12340), so `bash -c <command>` can run only part of a command. The command goes in
|
|
184
|
+
// an environment variable instead, which arrives whole or not at all. The runner drops the
|
|
185
|
+
// variable before the command runs so child processes do not inherit it, and fails if it is
|
|
186
|
+
// missing, for callers that still append the command to `args`. The `unset` shares the
|
|
187
|
+
// command's first line, so `$LINENO` and error line numbers match `bash -c`; `--` keeps a
|
|
188
|
+
// command that starts with `-` from being read as an option of `eval`.
|
|
189
|
+
const WINDOWS_ENV_COMMAND_RUNNER = `: "\${${SHELL_COMMAND_ENV_VAR}?draht: the command was not passed in ${SHELL_COMMAND_ENV_VAR}}"; eval -- "unset ${SHELL_COMMAND_ENV_VAR}; $${SHELL_COMMAND_ENV_VAR}"`;
|
|
163
190
|
function getBashShellConfig(shell) {
|
|
164
|
-
|
|
191
|
+
if (isLegacyWslBashPath(shell))
|
|
192
|
+
return { shell, args: ["-s"], commandTransport: "stdin" };
|
|
193
|
+
if (process.platform === "win32" && isWindowsBashPath(shell)) {
|
|
194
|
+
return { shell, args: ["-c", WINDOWS_ENV_COMMAND_RUNNER], commandTransport: "env" };
|
|
195
|
+
}
|
|
196
|
+
return { shell, args: ["-c"] };
|
|
197
|
+
}
|
|
198
|
+
// Other custom shells keep argv. Launchers under WindowsApps (the `bash.exe` alias and its
|
|
199
|
+
// package directories) start WSL, which does not receive Windows environment variables.
|
|
200
|
+
function isWindowsBashPath(path) {
|
|
201
|
+
const segments = win32.normalize(path).toLowerCase().split("\\");
|
|
202
|
+
const name = segments.pop();
|
|
203
|
+
return (name === "bash.exe" || name === "bash") && !segments.includes("windowsapps");
|
|
165
204
|
}
|
|
166
205
|
async function getShellConfig(customShellPath) {
|
|
167
206
|
if (customShellPath) {
|
|
@@ -183,7 +222,12 @@ async function getShellConfig(customShellPath) {
|
|
|
183
222
|
return ok(getBashShellConfig(candidate));
|
|
184
223
|
}
|
|
185
224
|
}
|
|
186
|
-
|
|
225
|
+
// Must precede the generic bash.exe lookup, which usually finds the WSL launcher in System32 first.
|
|
226
|
+
const gitBash = await findGitBashOfGitOnPath();
|
|
227
|
+
if (gitBash) {
|
|
228
|
+
return ok(getBashShellConfig(gitBash));
|
|
229
|
+
}
|
|
230
|
+
const bashOnPath = await findExecutableOnPath("bash.exe");
|
|
187
231
|
if (bashOnPath) {
|
|
188
232
|
return ok(getBashShellConfig(bashOnPath));
|
|
189
233
|
}
|
|
@@ -191,12 +235,13 @@ async function getShellConfig(customShellPath) {
|
|
|
191
235
|
` 1. Install Git for Windows: https://git-scm.com/download/win\n` +
|
|
192
236
|
` 2. Add your bash to PATH (Cygwin, MSYS2, etc.)\n` +
|
|
193
237
|
" 3. Configure an explicit shellPath\n\n" +
|
|
194
|
-
`Searched Git Bash in:\n${candidates.map((path) => ` ${path}`).join("\n")}`
|
|
238
|
+
`Searched Git Bash in:\n${candidates.map((path) => ` ${path}`).join("\n")}\n` +
|
|
239
|
+
" the Git for Windows installation of git.exe on PATH"));
|
|
195
240
|
}
|
|
196
241
|
if (await pathExists("/bin/bash")) {
|
|
197
242
|
return ok(getBashShellConfig("/bin/bash"));
|
|
198
243
|
}
|
|
199
|
-
const bashOnPath = await
|
|
244
|
+
const bashOnPath = await findExecutableOnPath("bash");
|
|
200
245
|
if (bashOnPath) {
|
|
201
246
|
return ok(getBashShellConfig(bashOnPath));
|
|
202
247
|
}
|
|
@@ -344,34 +389,32 @@ class NodeTextLineReader {
|
|
|
344
389
|
if (this.closed)
|
|
345
390
|
return err(new FileError("invalid", "Text line reader is closed", this.path));
|
|
346
391
|
try {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
if (newline !== -1) {
|
|
350
|
-
const text = this.buffered.slice(0, newline);
|
|
351
|
-
this.buffered = this.buffered.slice(newline + 1);
|
|
352
|
-
return ok({ text, terminated: true });
|
|
353
|
-
}
|
|
354
|
-
if (this.ended) {
|
|
355
|
-
if (this.buffered.length === 0)
|
|
356
|
-
return ok(undefined);
|
|
357
|
-
const text = this.buffered;
|
|
358
|
-
this.buffered = "";
|
|
359
|
-
return ok({ text, terminated: false });
|
|
360
|
-
}
|
|
392
|
+
let newline = this.buffered.indexOf("\n");
|
|
393
|
+
while (newline === -1 && !this.ended) {
|
|
361
394
|
// Explicit positions allow an aborted read to be retried without skipping bytes.
|
|
362
395
|
const { bytesRead } = await this.file.read(this.chunk, 0, this.chunk.length, this.byteOffset);
|
|
363
396
|
const afterReadAbort = abortResult(context.abortSignal, this.path);
|
|
364
397
|
if (afterReadAbort)
|
|
365
398
|
return afterReadAbort;
|
|
366
399
|
this.byteOffset += bytesRead;
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
400
|
+
this.ended = bytesRead === 0;
|
|
401
|
+
const text = this.ended ? this.decoder.decode() : this.decoder.decode(this.chunk.subarray(0, bytesRead));
|
|
402
|
+
// Only the new text is scanned, so a line longer than one read is not rescanned per read.
|
|
403
|
+
const found = text.indexOf("\n");
|
|
404
|
+
if (found !== -1)
|
|
405
|
+
newline = this.buffered.length + found;
|
|
406
|
+
this.buffered += text;
|
|
407
|
+
}
|
|
408
|
+
if (newline !== -1) {
|
|
409
|
+
const text = this.buffered.slice(0, newline);
|
|
410
|
+
this.buffered = this.buffered.slice(newline + 1);
|
|
411
|
+
return ok({ text, terminated: true });
|
|
374
412
|
}
|
|
413
|
+
if (this.buffered.length === 0)
|
|
414
|
+
return ok(undefined);
|
|
415
|
+
const text = this.buffered;
|
|
416
|
+
this.buffered = "";
|
|
417
|
+
return ok({ text, terminated: false });
|
|
375
418
|
}
|
|
376
419
|
catch (error) {
|
|
377
420
|
return err(toFileError(error, this.path));
|
|
@@ -598,14 +641,16 @@ export class NodeExecutionEnv {
|
|
|
598
641
|
let program;
|
|
599
642
|
let args;
|
|
600
643
|
let stdinCommand;
|
|
644
|
+
let envCommand;
|
|
601
645
|
if (typeof command === "string") {
|
|
602
646
|
const shellConfig = await getShellConfig(this.shellPath);
|
|
603
647
|
if (!shellConfig.ok)
|
|
604
648
|
return shellConfig;
|
|
605
|
-
const
|
|
649
|
+
const transport = shellConfig.value.commandTransport ?? "argv";
|
|
606
650
|
program = shellConfig.value.shell;
|
|
607
|
-
args =
|
|
608
|
-
stdinCommand =
|
|
651
|
+
args = transport === "argv" ? [...shellConfig.value.args, command] : shellConfig.value.args;
|
|
652
|
+
stdinCommand = transport === "stdin" ? command : undefined;
|
|
653
|
+
envCommand = transport === "env" ? command : undefined;
|
|
609
654
|
}
|
|
610
655
|
else {
|
|
611
656
|
const [first, ...rest] = command;
|
|
@@ -742,7 +787,7 @@ export class NodeExecutionEnv {
|
|
|
742
787
|
child = spawn(program, args, {
|
|
743
788
|
cwd,
|
|
744
789
|
detached: process.platform !== "win32",
|
|
745
|
-
env: getShellEnv(this.shellEnv, options?.env, options?.inheritEnv),
|
|
790
|
+
env: getShellEnv(this.shellEnv, envCommand === undefined ? options?.env : { ...options?.env, [SHELL_COMMAND_ENV_VAR]: envCommand }, options?.inheritEnv),
|
|
746
791
|
stdio: [stdinCommand === undefined ? "ignore" : "pipe", "pipe", "pipe"],
|
|
747
792
|
windowsHide: true,
|
|
748
793
|
});
|
|
@@ -1021,6 +1066,41 @@ export class NodeExecutionEnv {
|
|
|
1021
1066
|
await file?.close().catch(() => undefined);
|
|
1022
1067
|
}
|
|
1023
1068
|
}
|
|
1069
|
+
async flushDir(path, context) {
|
|
1070
|
+
const resolved = resolvePath(this.cwd, path);
|
|
1071
|
+
const signal = context.abortSignal;
|
|
1072
|
+
const aborted = abortResult(signal, resolved);
|
|
1073
|
+
if (aborted)
|
|
1074
|
+
return aborted;
|
|
1075
|
+
let directory;
|
|
1076
|
+
try {
|
|
1077
|
+
if (process.platform === "win32") {
|
|
1078
|
+
// Windows flushes a handle only with write access, and opens a file that way too: check the kind first.
|
|
1079
|
+
if (!(await stat(resolved)).isDirectory()) {
|
|
1080
|
+
return err(new FileError("not_directory", "Not a directory", resolved));
|
|
1081
|
+
}
|
|
1082
|
+
directory = await openFile(resolved, "r+");
|
|
1083
|
+
// Again on the handle: the path may have changed since.
|
|
1084
|
+
if (!(await directory.stat()).isDirectory()) {
|
|
1085
|
+
return err(new FileError("not_directory", "Not a directory", resolved));
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
else {
|
|
1089
|
+
// POSIX opens a directory read-only only. O_DIRECTORY refuses anything else at the open itself: without it
|
|
1090
|
+
// a FIFO would block the open until a writer came.
|
|
1091
|
+
directory = await openFile(resolved, constants.O_RDONLY | constants.O_DIRECTORY);
|
|
1092
|
+
}
|
|
1093
|
+
await directory.sync();
|
|
1094
|
+
const afterSyncAbort = abortResult(signal, resolved);
|
|
1095
|
+
return afterSyncAbort ?? ok(undefined);
|
|
1096
|
+
}
|
|
1097
|
+
catch (error) {
|
|
1098
|
+
return err(toFileError(error, resolved));
|
|
1099
|
+
}
|
|
1100
|
+
finally {
|
|
1101
|
+
await directory?.close().catch(() => undefined);
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1024
1104
|
async renameFile(sourcePath, destinationPath, context) {
|
|
1025
1105
|
const source = resolvePath(this.cwd, sourcePath);
|
|
1026
1106
|
const destination = resolvePath(this.cwd, destinationPath);
|