@earendil-works/chord 1.4.0 → 1.5.1
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 +92 -0
- package/README.md +115 -90
- package/dist/context/index.d.ts +1 -1
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +1 -1
- package/dist/context/index.js.map +1 -1
- package/dist/contracts/accepts.d.ts +81 -0
- package/dist/contracts/accepts.d.ts.map +1 -0
- package/dist/contracts/accepts.js +123 -0
- package/dist/contracts/accepts.js.map +1 -0
- package/dist/contracts/contract.d.ts +121 -0
- package/dist/contracts/contract.d.ts.map +1 -0
- package/dist/contracts/contract.js +50 -0
- package/dist/contracts/contract.js.map +1 -0
- package/dist/contracts/declare.d.ts +107 -0
- package/dist/contracts/declare.d.ts.map +1 -0
- package/dist/contracts/declare.js +136 -0
- package/dist/contracts/declare.js.map +1 -0
- package/dist/contracts/evolve.d.ts +92 -0
- package/dist/contracts/evolve.d.ts.map +1 -0
- package/dist/contracts/evolve.js +179 -0
- package/dist/contracts/evolve.js.map +1 -0
- package/dist/contracts/fingerprint.d.ts +16 -0
- package/dist/contracts/fingerprint.d.ts.map +1 -0
- package/dist/contracts/fingerprint.js +50 -0
- package/dist/contracts/fingerprint.js.map +1 -0
- package/dist/contracts/history.d.ts +71 -0
- package/dist/contracts/history.d.ts.map +1 -0
- package/dist/contracts/history.js +3 -0
- package/dist/contracts/history.js.map +1 -0
- package/dist/contracts/host-kind.d.ts +40 -0
- package/dist/contracts/host-kind.d.ts.map +1 -0
- package/dist/contracts/host-kind.js +37 -0
- package/dist/contracts/host-kind.js.map +1 -0
- package/dist/contracts/index.d.ts +7 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +6 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/contracts/internal.d.ts +10 -0
- package/dist/contracts/internal.d.ts.map +1 -0
- package/dist/contracts/internal.js +9 -0
- package/dist/contracts/internal.js.map +1 -0
- package/dist/contracts/names.d.ts +3 -0
- package/dist/contracts/names.d.ts.map +1 -0
- package/dist/contracts/names.js +13 -0
- package/dist/contracts/names.js.map +1 -0
- package/dist/contracts/params.d.ts +28 -0
- package/dist/contracts/params.d.ts.map +1 -0
- package/dist/contracts/params.js +50 -0
- package/dist/contracts/params.js.map +1 -0
- package/dist/contracts/schema.d.ts +102 -0
- package/dist/contracts/schema.d.ts.map +1 -0
- package/dist/contracts/schema.js +103 -0
- package/dist/contracts/schema.js.map +1 -0
- package/dist/contracts/snapshot.d.ts +16 -0
- package/dist/contracts/snapshot.d.ts.map +1 -0
- package/dist/contracts/snapshot.js +167 -0
- package/dist/contracts/snapshot.js.map +1 -0
- package/dist/data/args.d.ts +50 -0
- package/dist/data/args.d.ts.map +1 -0
- package/dist/data/args.js +83 -0
- package/dist/data/args.js.map +1 -0
- package/dist/data/errors.d.ts +80 -0
- package/dist/data/errors.d.ts.map +1 -0
- package/dist/data/errors.js +116 -0
- package/dist/data/errors.js.map +1 -0
- package/dist/data/failure.d.ts +26 -0
- package/dist/data/failure.d.ts.map +1 -0
- package/dist/data/failure.js +77 -0
- package/dist/data/failure.js.map +1 -0
- package/dist/data/index.d.ts +4 -0
- package/dist/data/index.d.ts.map +1 -0
- package/dist/data/index.js +5 -0
- package/dist/data/index.js.map +1 -0
- package/dist/data/internal.d.ts +7 -0
- package/dist/data/internal.d.ts.map +1 -0
- package/dist/data/internal.js +8 -0
- package/dist/data/internal.js.map +1 -0
- package/dist/data/params.d.ts +20 -0
- package/dist/data/params.d.ts.map +1 -0
- package/dist/data/params.js +31 -0
- package/dist/data/params.js.map +1 -0
- package/dist/data/principal.d.ts +22 -0
- package/dist/data/principal.d.ts.map +1 -0
- package/dist/data/principal.js +49 -0
- package/dist/data/principal.js.map +1 -0
- package/dist/data/validator.d.ts +12 -0
- package/dist/data/validator.d.ts.map +1 -0
- package/dist/data/validator.js +35 -0
- package/dist/data/validator.js.map +1 -0
- package/dist/delta/apply-immutable-trusted.js +3 -4
- package/dist/delta/apply-immutable-trusted.js.map +1 -1
- package/dist/delta/diff.d.ts.map +1 -1
- package/dist/delta/diff.js +5 -3
- package/dist/delta/diff.js.map +1 -1
- package/dist/delta/index.d.ts +9 -1
- package/dist/delta/index.d.ts.map +1 -1
- package/dist/delta/index.js +15 -11
- package/dist/delta/index.js.map +1 -1
- package/dist/delta/pending.d.ts +36 -0
- package/dist/delta/pending.d.ts.map +1 -0
- package/dist/delta/pending.js +143 -0
- package/dist/delta/pending.js.map +1 -0
- package/dist/delta/tracker.d.ts +12 -0
- package/dist/delta/tracker.d.ts.map +1 -1
- package/dist/delta/tracker.js +109 -39
- package/dist/delta/tracker.js.map +1 -1
- package/dist/documents/address-source.d.ts +20 -0
- package/dist/documents/address-source.d.ts.map +1 -0
- package/dist/documents/address-source.js +44 -0
- package/dist/documents/address-source.js.map +1 -0
- package/dist/documents/definition.d.ts +84 -0
- package/dist/documents/definition.d.ts.map +1 -0
- package/dist/documents/definition.js +74 -0
- package/dist/documents/definition.js.map +1 -0
- package/dist/documents/documents.d.ts +126 -0
- package/dist/documents/documents.d.ts.map +1 -0
- package/dist/documents/documents.js +248 -0
- package/dist/documents/documents.js.map +1 -0
- package/dist/documents/fence.d.ts +9 -0
- package/dist/documents/fence.d.ts.map +1 -0
- package/dist/documents/fence.js +15 -0
- package/dist/documents/fence.js.map +1 -0
- package/dist/documents/handles.d.ts +76 -0
- package/dist/documents/handles.d.ts.map +1 -0
- package/dist/documents/handles.js +66 -0
- package/dist/documents/handles.js.map +1 -0
- package/dist/documents/index.d.ts +4 -0
- package/dist/documents/index.d.ts.map +1 -0
- package/dist/documents/index.js +3 -0
- package/dist/documents/index.js.map +1 -0
- package/dist/documents/internal.d.ts +9 -0
- package/dist/documents/internal.d.ts.map +1 -0
- package/dist/documents/internal.js +9 -0
- package/dist/documents/internal.js.map +1 -0
- package/dist/documents/keyed-slot.d.ts +103 -0
- package/dist/documents/keyed-slot.d.ts.map +1 -0
- package/dist/documents/keyed-slot.js +395 -0
- package/dist/documents/keyed-slot.js.map +1 -0
- package/dist/documents/line.d.ts +7 -0
- package/dist/documents/line.d.ts.map +1 -0
- package/dist/documents/line.js +14 -0
- package/dist/documents/line.js.map +1 -0
- package/dist/documents/persistence.d.ts +104 -0
- package/dist/documents/persistence.d.ts.map +1 -0
- package/dist/documents/persistence.js +129 -0
- package/dist/documents/persistence.js.map +1 -0
- package/dist/documents/residency.d.ts +31 -0
- package/dist/documents/residency.d.ts.map +1 -0
- package/dist/documents/residency.js +93 -0
- package/dist/documents/residency.js.map +1 -0
- package/dist/documents/slot.d.ts +109 -0
- package/dist/documents/slot.d.ts.map +1 -0
- package/dist/documents/slot.js +181 -0
- package/dist/documents/slot.js.map +1 -0
- package/dist/documents/transaction.d.ts +143 -0
- package/dist/documents/transaction.d.ts.map +1 -0
- package/dist/documents/transaction.js +442 -0
- package/dist/documents/transaction.js.map +1 -0
- package/dist/host/activity.d.ts +31 -0
- package/dist/host/activity.d.ts.map +1 -0
- package/dist/host/activity.js +40 -0
- package/dist/host/activity.js.map +1 -0
- package/dist/host/adapted.d.ts +49 -0
- package/dist/host/adapted.d.ts.map +1 -0
- package/dist/host/adapted.js +214 -0
- package/dist/host/adapted.js.map +1 -0
- package/dist/host/attempt.d.ts +308 -0
- package/dist/host/attempt.d.ts.map +1 -0
- package/dist/host/attempt.js +1199 -0
- package/dist/host/attempt.js.map +1 -0
- package/dist/host/backoff.d.ts +29 -0
- package/dist/host/backoff.d.ts.map +1 -0
- package/dist/host/backoff.js +69 -0
- package/dist/host/backoff.js.map +1 -0
- package/dist/host/ctx.d.ts +94 -0
- package/dist/host/ctx.d.ts.map +1 -0
- package/dist/host/ctx.js +200 -0
- package/dist/host/ctx.js.map +1 -0
- package/dist/host/deadline.d.ts +12 -0
- package/dist/host/deadline.d.ts.map +1 -0
- package/dist/host/deadline.js +40 -0
- package/dist/host/deadline.js.map +1 -0
- package/dist/host/dependencies.d.ts +65 -0
- package/dist/host/dependencies.d.ts.map +1 -0
- package/dist/host/dependencies.js +115 -0
- package/dist/host/dependencies.js.map +1 -0
- package/dist/host/destination.d.ts +48 -0
- package/dist/host/destination.d.ts.map +1 -0
- package/dist/host/destination.js +101 -0
- package/dist/host/destination.js.map +1 -0
- package/dist/host/facet.d.ts +84 -0
- package/dist/host/facet.d.ts.map +1 -0
- package/dist/host/facet.js +55 -0
- package/dist/host/facet.js.map +1 -0
- package/dist/host/follow.d.ts +52 -0
- package/dist/host/follow.d.ts.map +1 -0
- package/dist/host/follow.js +207 -0
- package/dist/host/follow.js.map +1 -0
- package/dist/host/host.d.ts +571 -0
- package/dist/host/host.d.ts.map +1 -0
- package/dist/host/host.js +1318 -0
- package/dist/host/host.js.map +1 -0
- package/dist/host/index.d.ts +17 -0
- package/dist/host/index.d.ts.map +1 -0
- package/dist/host/index.js +6 -0
- package/dist/host/index.js.map +1 -0
- package/dist/host/internal.d.ts +11 -0
- package/dist/host/internal.d.ts.map +1 -0
- package/dist/host/internal.js +9 -0
- package/dist/host/internal.js.map +1 -0
- package/dist/host/members.d.ts +50 -0
- package/dist/host/members.d.ts.map +1 -0
- package/dist/host/members.js +107 -0
- package/dist/host/members.js.map +1 -0
- package/dist/host/native.d.ts +64 -0
- package/dist/host/native.d.ts.map +1 -0
- package/dist/host/native.js +126 -0
- package/dist/host/native.js.map +1 -0
- package/dist/host/object.d.ts +331 -0
- package/dist/host/object.d.ts.map +1 -0
- package/dist/host/object.js +1296 -0
- package/dist/host/object.js.map +1 -0
- package/dist/host/old-work.d.ts +34 -0
- package/dist/host/old-work.d.ts.map +1 -0
- package/dist/host/old-work.js +52 -0
- package/dist/host/old-work.js.map +1 -0
- package/dist/host/parked.d.ts +23 -0
- package/dist/host/parked.d.ts.map +1 -0
- package/dist/host/parked.js +79 -0
- package/dist/host/parked.js.map +1 -0
- package/dist/host/presence.d.ts +34 -0
- package/dist/host/presence.d.ts.map +1 -0
- package/dist/host/presence.js +117 -0
- package/dist/host/presence.js.map +1 -0
- package/dist/host/readiness.d.ts +27 -0
- package/dist/host/readiness.d.ts.map +1 -0
- package/dist/host/readiness.js +134 -0
- package/dist/host/readiness.js.map +1 -0
- package/dist/host/ref-state.d.ts +53 -0
- package/dist/host/ref-state.d.ts.map +1 -0
- package/dist/host/ref-state.js +83 -0
- package/dist/host/ref-state.js.map +1 -0
- package/dist/host/reference-keys.d.ts +36 -0
- package/dist/host/reference-keys.d.ts.map +1 -0
- package/dist/host/reference-keys.js +168 -0
- package/dist/host/reference-keys.js.map +1 -0
- package/dist/host/reference-source.d.ts +65 -0
- package/dist/host/reference-source.d.ts.map +1 -0
- package/dist/host/reference-source.js +285 -0
- package/dist/host/reference-source.js.map +1 -0
- package/dist/host/reference.d.ts +321 -0
- package/dist/host/reference.d.ts.map +1 -0
- package/dist/host/reference.js +797 -0
- package/dist/host/reference.js.map +1 -0
- package/dist/host/reload-cycle.d.ts +16 -0
- package/dist/host/reload-cycle.d.ts.map +1 -0
- package/dist/host/reload-cycle.js +81 -0
- package/dist/host/reload-cycle.js.map +1 -0
- package/dist/host/retry-on.d.ts +28 -0
- package/dist/host/retry-on.d.ts.map +1 -0
- package/dist/host/retry-on.js +52 -0
- package/dist/host/retry-on.js.map +1 -0
- package/dist/host/revocation.d.ts +16 -0
- package/dist/host/revocation.d.ts.map +1 -0
- package/dist/host/revocation.js +27 -0
- package/dist/host/revocation.js.map +1 -0
- package/dist/host/root.d.ts +37 -0
- package/dist/host/root.d.ts.map +1 -0
- package/dist/host/root.js +68 -0
- package/dist/host/root.js.map +1 -0
- package/dist/host/route.d.ts +64 -0
- package/dist/host/route.d.ts.map +1 -0
- package/dist/host/route.js +227 -0
- package/dist/host/route.js.map +1 -0
- package/dist/host/routines.d.ts +78 -0
- package/dist/host/routines.d.ts.map +1 -0
- package/dist/host/routines.js +398 -0
- package/dist/host/routines.js.map +1 -0
- package/dist/host/sleep.d.ts +9 -0
- package/dist/host/sleep.d.ts.map +1 -0
- package/dist/host/sleep.js +40 -0
- package/dist/host/sleep.js.map +1 -0
- package/dist/host/staging.d.ts +94 -0
- package/dist/host/staging.d.ts.map +1 -0
- package/dist/host/staging.js +304 -0
- package/dist/host/staging.js.map +1 -0
- package/dist/host/unbound-clock.d.ts +23 -0
- package/dist/host/unbound-clock.d.ts.map +1 -0
- package/dist/host/unbound-clock.js +58 -0
- package/dist/host/unbound-clock.js.map +1 -0
- package/dist/host/unbound.d.ts +37 -0
- package/dist/host/unbound.d.ts.map +1 -0
- package/dist/host/unbound.js +88 -0
- package/dist/host/unbound.js.map +1 -0
- package/dist/host/uuid.d.ts +3 -0
- package/dist/host/uuid.d.ts.map +1 -0
- package/dist/host/uuid.js +38 -0
- package/dist/host/uuid.js.map +1 -0
- package/dist/index.d.ts +29 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -9
- package/dist/index.js.map +1 -1
- package/dist/jobs/definition.d.ts +96 -0
- package/dist/jobs/definition.d.ts.map +1 -0
- package/dist/jobs/definition.js +83 -0
- package/dist/jobs/definition.js.map +1 -0
- package/dist/jobs/index.d.ts +5 -0
- package/dist/jobs/index.d.ts.map +1 -0
- package/dist/jobs/index.js +3 -0
- package/dist/jobs/index.js.map +1 -0
- package/dist/jobs/internal.d.ts +3 -0
- package/dist/jobs/internal.d.ts.map +1 -0
- package/dist/jobs/internal.js +4 -0
- package/dist/jobs/internal.js.map +1 -0
- package/dist/jobs/job.d.ts +149 -0
- package/dist/jobs/job.d.ts.map +1 -0
- package/dist/jobs/job.js +387 -0
- package/dist/jobs/job.js.map +1 -0
- package/dist/jobs/persisted.d.ts +38 -0
- package/dist/jobs/persisted.d.ts.map +1 -0
- package/dist/jobs/persisted.js +95 -0
- package/dist/jobs/persisted.js.map +1 -0
- package/dist/jobs/records.d.ts +231 -0
- package/dist/jobs/records.d.ts.map +1 -0
- package/dist/jobs/records.js +871 -0
- package/dist/jobs/records.js.map +1 -0
- package/dist/jobs/run-states.d.ts +69 -0
- package/dist/jobs/run-states.d.ts.map +1 -0
- package/dist/jobs/run-states.js +228 -0
- package/dist/jobs/run-states.js.map +1 -0
- package/dist/jobs/run.d.ts +117 -0
- package/dist/jobs/run.d.ts.map +1 -0
- package/dist/jobs/run.js +204 -0
- package/dist/jobs/run.js.map +1 -0
- package/dist/jobs/running.d.ts +44 -0
- package/dist/jobs/running.d.ts.map +1 -0
- package/dist/jobs/running.js +117 -0
- package/dist/jobs/running.js.map +1 -0
- package/dist/jobs/stored.d.ts +63 -0
- package/dist/jobs/stored.d.ts.map +1 -0
- package/dist/jobs/stored.js +55 -0
- package/dist/jobs/stored.js.map +1 -0
- package/dist/link/binary.d.ts +4 -0
- package/dist/link/binary.d.ts.map +1 -0
- package/dist/link/binary.js +544 -0
- package/dist/link/binary.js.map +1 -0
- package/dist/link/channel.d.ts +68 -0
- package/dist/link/channel.d.ts.map +1 -0
- package/dist/link/channel.js +215 -0
- package/dist/link/channel.js.map +1 -0
- package/dist/link/errors.d.ts +7 -0
- package/dist/link/errors.d.ts.map +1 -0
- package/dist/link/errors.js +21 -0
- package/dist/link/errors.js.map +1 -0
- package/dist/link/index.d.ts +8 -0
- package/dist/link/index.d.ts.map +1 -0
- package/dist/link/index.js +8 -0
- package/dist/link/index.js.map +1 -0
- package/dist/link/internal.d.ts +9 -0
- package/dist/link/internal.d.ts.map +1 -0
- package/dist/link/internal.js +10 -0
- package/dist/link/internal.js.map +1 -0
- package/dist/link/ipc.d.ts +22 -0
- package/dist/link/ipc.d.ts.map +1 -0
- package/dist/link/ipc.js +64 -0
- package/dist/link/ipc.js.map +1 -0
- package/dist/link/link.d.ts +34 -0
- package/dist/link/link.d.ts.map +1 -0
- package/dist/link/link.js +87 -0
- package/dist/link/link.js.map +1 -0
- package/dist/link/message.d.ts +262 -0
- package/dist/link/message.d.ts.map +1 -0
- package/dist/link/message.js +156 -0
- package/dist/link/message.js.map +1 -0
- package/dist/link/part.d.ts +80 -0
- package/dist/link/part.d.ts.map +1 -0
- package/dist/link/part.js +165 -0
- package/dist/link/part.js.map +1 -0
- package/dist/link/text.d.ts +6 -0
- package/dist/link/text.d.ts.map +1 -0
- package/dist/link/text.js +355 -0
- package/dist/link/text.js.map +1 -0
- package/dist/link/values.d.ts +40 -0
- package/dist/link/values.d.ts.map +1 -0
- package/dist/link/values.js +121 -0
- package/dist/link/values.js.map +1 -0
- package/dist/link/websocket.d.ts +26 -0
- package/dist/link/websocket.d.ts.map +1 -0
- package/dist/link/websocket.js +91 -0
- package/dist/link/websocket.js.map +1 -0
- package/dist/node/app/app.d.ts +269 -0
- package/dist/node/app/app.d.ts.map +1 -0
- package/dist/node/app/app.js +513 -0
- package/dist/node/app/app.js.map +1 -0
- package/dist/node/app/archive.d.ts +37 -0
- package/dist/node/app/archive.d.ts.map +1 -0
- package/dist/node/app/archive.js +204 -0
- package/dist/node/app/archive.js.map +1 -0
- package/dist/node/app/blobs.d.ts +23 -0
- package/dist/node/app/blobs.d.ts.map +1 -0
- package/dist/node/app/blobs.js +64 -0
- package/dist/node/app/blobs.js.map +1 -0
- package/dist/node/app/data.d.ts +35 -0
- package/dist/node/app/data.d.ts.map +1 -0
- package/dist/node/app/data.js +44 -0
- package/dist/node/app/data.js.map +1 -0
- package/dist/node/app/ephemeral-sessions.d.ts +20 -0
- package/dist/node/app/ephemeral-sessions.d.ts.map +1 -0
- package/dist/node/app/ephemeral-sessions.js +69 -0
- package/dist/node/app/ephemeral-sessions.js.map +1 -0
- package/dist/node/app/ephemeral.d.ts +11 -0
- package/dist/node/app/ephemeral.d.ts.map +1 -0
- package/dist/node/app/ephemeral.js +34 -0
- package/dist/node/app/ephemeral.js.map +1 -0
- package/dist/node/app/files-copy.d.ts +13 -0
- package/dist/node/app/files-copy.d.ts.map +1 -0
- package/dist/node/app/files-copy.js +86 -0
- package/dist/node/app/files-copy.js.map +1 -0
- package/dist/node/app/files-entry.d.ts +4 -0
- package/dist/node/app/files-entry.d.ts.map +1 -0
- package/dist/node/app/files-entry.js +7 -0
- package/dist/node/app/files-entry.js.map +1 -0
- package/dist/node/app/files-index.d.ts +180 -0
- package/dist/node/app/files-index.d.ts.map +1 -0
- package/dist/node/app/files-index.js +535 -0
- package/dist/node/app/files-index.js.map +1 -0
- package/dist/node/app/files.d.ts +363 -0
- package/dist/node/app/files.d.ts.map +1 -0
- package/dist/node/app/files.js +368 -0
- package/dist/node/app/files.js.map +1 -0
- package/dist/node/app/folder-views.d.ts +21 -0
- package/dist/node/app/folder-views.d.ts.map +1 -0
- package/dist/node/app/folder-views.js +55 -0
- package/dist/node/app/folder-views.js.map +1 -0
- package/dist/node/app/index.d.ts +12 -0
- package/dist/node/app/index.d.ts.map +1 -0
- package/dist/node/app/index.js +15 -0
- package/dist/node/app/index.js.map +1 -0
- package/dist/node/app/info.d.ts +66 -0
- package/dist/node/app/info.d.ts.map +1 -0
- package/dist/node/app/info.js +37 -0
- package/dist/node/app/info.js.map +1 -0
- package/dist/node/app/invite.d.ts +5 -0
- package/dist/node/app/invite.d.ts.map +1 -0
- package/dist/node/app/invite.js +64 -0
- package/dist/node/app/invite.js.map +1 -0
- package/dist/node/app/layout.d.ts +36 -0
- package/dist/node/app/layout.d.ts.map +1 -0
- package/dist/node/app/layout.js +87 -0
- package/dist/node/app/layout.js.map +1 -0
- package/dist/node/app/owner.d.ts +31 -0
- package/dist/node/app/owner.d.ts.map +1 -0
- package/dist/node/app/owner.js +104 -0
- package/dist/node/app/owner.js.map +1 -0
- package/dist/node/app/pairing.d.ts +55 -0
- package/dist/node/app/pairing.d.ts.map +1 -0
- package/dist/node/app/pairing.js +183 -0
- package/dist/node/app/pairing.js.map +1 -0
- package/dist/node/app/secrets.d.ts +16 -0
- package/dist/node/app/secrets.d.ts.map +1 -0
- package/dist/node/app/secrets.js +72 -0
- package/dist/node/app/secrets.js.map +1 -0
- package/dist/node/app/sessions.d.ts +72 -0
- package/dist/node/app/sessions.d.ts.map +1 -0
- package/dist/node/app/sessions.js +222 -0
- package/dist/node/app/sessions.js.map +1 -0
- package/dist/node/app/tar.d.ts +24 -0
- package/dist/node/app/tar.d.ts.map +1 -0
- package/dist/node/app/tar.js +167 -0
- package/dist/node/app/tar.js.map +1 -0
- package/dist/node/app/uploads.d.ts +37 -0
- package/dist/node/app/uploads.d.ts.map +1 -0
- package/dist/node/app/uploads.js +157 -0
- package/dist/node/app/uploads.js.map +1 -0
- package/dist/node/app/users.d.ts +37 -0
- package/dist/node/app/users.d.ts.map +1 -0
- package/dist/node/app/users.js +62 -0
- package/dist/node/app/users.js.map +1 -0
- package/dist/node/app/worker.d.ts +18 -0
- package/dist/node/app/worker.d.ts.map +1 -0
- package/dist/node/app/worker.js +84 -0
- package/dist/node/app/worker.js.map +1 -0
- package/dist/node/compression.d.ts +7 -0
- package/dist/node/compression.d.ts.map +1 -0
- package/dist/node/compression.js +25 -0
- package/dist/node/compression.js.map +1 -0
- package/dist/node/http/admission.d.ts +63 -0
- package/dist/node/http/admission.d.ts.map +1 -0
- package/dist/node/http/admission.js +134 -0
- package/dist/node/http/admission.js.map +1 -0
- package/dist/node/http/authenticate.d.ts +21 -0
- package/dist/node/http/authenticate.d.ts.map +1 -0
- package/dist/node/http/authenticate.js +34 -0
- package/dist/node/http/authenticate.js.map +1 -0
- package/dist/node/http/cookies.d.ts +32 -0
- package/dist/node/http/cookies.d.ts.map +1 -0
- package/dist/node/http/cookies.js +70 -0
- package/dist/node/http/cookies.js.map +1 -0
- package/dist/node/http/file.d.ts +23 -0
- package/dist/node/http/file.d.ts.map +1 -0
- package/dist/node/http/file.js +94 -0
- package/dist/node/http/file.js.map +1 -0
- package/dist/node/http/headers.d.ts +37 -0
- package/dist/node/http/headers.d.ts.map +1 -0
- package/dist/node/http/headers.js +136 -0
- package/dist/node/http/headers.js.map +1 -0
- package/dist/node/http/http.d.ts +111 -0
- package/dist/node/http/http.d.ts.map +1 -0
- package/dist/node/http/http.js +524 -0
- package/dist/node/http/http.js.map +1 -0
- package/dist/node/http/incoming.d.ts +19 -0
- package/dist/node/http/incoming.d.ts.map +1 -0
- package/dist/node/http/incoming.js +31 -0
- package/dist/node/http/incoming.js.map +1 -0
- package/dist/node/http/index.d.ts +11 -0
- package/dist/node/http/index.d.ts.map +1 -0
- package/dist/node/http/index.js +12 -0
- package/dist/node/http/index.js.map +1 -0
- package/dist/node/http/node.d.ts +78 -0
- package/dist/node/http/node.d.ts.map +1 -0
- package/dist/node/http/node.js +291 -0
- package/dist/node/http/node.js.map +1 -0
- package/dist/node/http/request.d.ts +60 -0
- package/dist/node/http/request.d.ts.map +1 -0
- package/dist/node/http/request.js +118 -0
- package/dist/node/http/request.js.map +1 -0
- package/dist/node/http/response.d.ts +63 -0
- package/dist/node/http/response.d.ts.map +1 -0
- package/dist/node/http/response.js +202 -0
- package/dist/node/http/response.js.map +1 -0
- package/dist/node/http/router.d.ts +132 -0
- package/dist/node/http/router.d.ts.map +1 -0
- package/dist/node/http/router.js +267 -0
- package/dist/node/http/router.js.map +1 -0
- package/dist/node/http/upgrades.d.ts +61 -0
- package/dist/node/http/upgrades.d.ts.map +1 -0
- package/dist/node/http/upgrades.js +192 -0
- package/dist/node/http/upgrades.js.map +1 -0
- package/dist/node/plugins/base-inputs.d.ts +14 -0
- package/dist/node/plugins/base-inputs.d.ts.map +1 -0
- package/dist/node/plugins/base-inputs.js +33 -0
- package/dist/node/plugins/base-inputs.js.map +1 -0
- package/dist/node/plugins/build.d.ts +77 -0
- package/dist/node/plugins/build.d.ts.map +1 -0
- package/dist/node/plugins/build.js +576 -0
- package/dist/node/plugins/build.js.map +1 -0
- package/dist/node/plugins/css-modules.d.ts +13 -0
- package/dist/node/plugins/css-modules.d.ts.map +1 -0
- package/dist/node/plugins/css-modules.js +58 -0
- package/dist/node/plugins/css-modules.js.map +1 -0
- package/dist/node/plugins/discover.d.ts +67 -0
- package/dist/node/plugins/discover.d.ts.map +1 -0
- package/dist/node/plugins/discover.js +369 -0
- package/dist/node/plugins/discover.js.map +1 -0
- package/dist/node/plugins/evaluate.d.ts +33 -0
- package/dist/node/plugins/evaluate.d.ts.map +1 -0
- package/dist/node/plugins/evaluate.js +121 -0
- package/dist/node/plugins/evaluate.js.map +1 -0
- package/dist/node/plugins/index.d.ts +11 -0
- package/dist/node/plugins/index.d.ts.map +1 -0
- package/dist/node/plugins/index.js +13 -0
- package/dist/node/plugins/index.js.map +1 -0
- package/dist/node/plugins/install.d.ts +38 -0
- package/dist/node/plugins/install.d.ts.map +1 -0
- package/dist/node/plugins/install.js +213 -0
- package/dist/node/plugins/install.js.map +1 -0
- package/dist/node/plugins/plugins.d.ts +162 -0
- package/dist/node/plugins/plugins.d.ts.map +1 -0
- package/dist/node/plugins/plugins.js +244 -0
- package/dist/node/plugins/plugins.js.map +1 -0
- package/dist/node/plugins/runtime.d.ts +57 -0
- package/dist/node/plugins/runtime.d.ts.map +1 -0
- package/dist/node/plugins/runtime.js +92 -0
- package/dist/node/plugins/runtime.js.map +1 -0
- package/dist/node/plugins/stack.d.ts +16 -0
- package/dist/node/plugins/stack.d.ts.map +1 -0
- package/dist/node/plugins/stack.js +61 -0
- package/dist/node/plugins/stack.js.map +1 -0
- package/dist/node/plugins/testing.d.ts +58 -0
- package/dist/node/plugins/testing.d.ts.map +1 -0
- package/dist/node/plugins/testing.js +210 -0
- package/dist/node/plugins/testing.js.map +1 -0
- package/dist/node/plugins/watcher.d.ts +69 -0
- package/dist/node/plugins/watcher.d.ts.map +1 -0
- package/dist/node/plugins/watcher.js +622 -0
- package/dist/node/plugins/watcher.js.map +1 -0
- package/dist/node/surfaces/bundle.d.ts +31 -0
- package/dist/node/surfaces/bundle.d.ts.map +1 -0
- package/dist/node/surfaces/bundle.js +118 -0
- package/dist/node/surfaces/bundle.js.map +1 -0
- package/dist/node/surfaces/current.d.ts +17 -0
- package/dist/node/surfaces/current.d.ts.map +1 -0
- package/dist/node/surfaces/current.js +54 -0
- package/dist/node/surfaces/current.js.map +1 -0
- package/dist/node/surfaces/index.d.ts +6 -0
- package/dist/node/surfaces/index.d.ts.map +1 -0
- package/dist/node/surfaces/index.js +6 -0
- package/dist/node/surfaces/index.js.map +1 -0
- package/dist/node/surfaces/published.d.ts +27 -0
- package/dist/node/surfaces/published.d.ts.map +1 -0
- package/dist/node/surfaces/published.js +142 -0
- package/dist/node/surfaces/published.js.map +1 -0
- package/dist/node/surfaces/served.d.ts +15 -0
- package/dist/node/surfaces/served.d.ts.map +1 -0
- package/dist/node/surfaces/served.js +42 -0
- package/dist/node/surfaces/served.js.map +1 -0
- package/dist/node/surfaces/surface-build.d.ts +53 -0
- package/dist/node/surfaces/surface-build.d.ts.map +1 -0
- package/dist/node/surfaces/surface-build.js +105 -0
- package/dist/node/surfaces/surface-build.js.map +1 -0
- package/dist/node/surfaces/tui.d.ts +40 -0
- package/dist/node/surfaces/tui.d.ts.map +1 -0
- package/dist/node/surfaces/tui.js +55 -0
- package/dist/node/surfaces/tui.js.map +1 -0
- package/dist/node/surfaces/web.d.ts +56 -0
- package/dist/node/surfaces/web.d.ts.map +1 -0
- package/dist/node/surfaces/web.js +108 -0
- package/dist/node/surfaces/web.js.map +1 -0
- package/dist/node/tui/actions.d.ts +49 -0
- package/dist/node/tui/actions.d.ts.map +1 -0
- package/dist/node/tui/actions.js +195 -0
- package/dist/node/tui/actions.js.map +1 -0
- package/dist/node/tui/credentials.d.ts +17 -0
- package/dist/node/tui/credentials.d.ts.map +1 -0
- package/dist/node/tui/credentials.js +54 -0
- package/dist/node/tui/credentials.js.map +1 -0
- package/dist/node/tui/filter.d.ts +5 -0
- package/dist/node/tui/filter.d.ts.map +1 -0
- package/dist/node/tui/filter.js +79 -0
- package/dist/node/tui/filter.js.map +1 -0
- package/dist/node/tui/index.d.ts +6 -0
- package/dist/node/tui/index.d.ts.map +1 -0
- package/dist/node/tui/index.js +6 -0
- package/dist/node/tui/index.js.map +1 -0
- package/dist/node/tui/launcher.d.ts +40 -0
- package/dist/node/tui/launcher.d.ts.map +1 -0
- package/dist/node/tui/launcher.js +439 -0
- package/dist/node/tui/launcher.js.map +1 -0
- package/dist/node/tui/pipe.d.ts +18 -0
- package/dist/node/tui/pipe.d.ts.map +1 -0
- package/dist/node/tui/pipe.js +134 -0
- package/dist/node/tui/pipe.js.map +1 -0
- package/dist/node/tui/sandbox.d.ts +54 -0
- package/dist/node/tui/sandbox.d.ts.map +1 -0
- package/dist/node/tui/sandbox.js +431 -0
- package/dist/node/tui/sandbox.js.map +1 -0
- package/dist/node/workers/base.d.ts +30 -0
- package/dist/node/workers/base.d.ts.map +1 -0
- package/dist/node/workers/base.js +255 -0
- package/dist/node/workers/base.js.map +1 -0
- package/dist/node/workers/child.d.ts +4 -0
- package/dist/node/workers/child.d.ts.map +1 -0
- package/dist/node/workers/child.js +6 -0
- package/dist/node/workers/child.js.map +1 -0
- package/dist/node/workers/control.d.ts +83 -0
- package/dist/node/workers/control.d.ts.map +1 -0
- package/dist/node/workers/control.js +77 -0
- package/dist/node/workers/control.js.map +1 -0
- package/dist/node/workers/index.d.ts +4 -0
- package/dist/node/workers/index.d.ts.map +1 -0
- package/dist/node/workers/index.js +7 -0
- package/dist/node/workers/index.js.map +1 -0
- package/dist/node/workers/lock.d.ts +30 -0
- package/dist/node/workers/lock.d.ts.map +1 -0
- package/dist/node/workers/lock.js +180 -0
- package/dist/node/workers/lock.js.map +1 -0
- package/dist/node/workers/main.d.ts +46 -0
- package/dist/node/workers/main.d.ts.map +1 -0
- package/dist/node/workers/main.js +230 -0
- package/dist/node/workers/main.js.map +1 -0
- package/dist/node/workers/process.d.ts +42 -0
- package/dist/node/workers/process.d.ts.map +1 -0
- package/dist/node/workers/process.js +125 -0
- package/dist/node/workers/process.js.map +1 -0
- package/dist/node/workers/workers.d.ts +122 -0
- package/dist/node/workers/workers.d.ts.map +1 -0
- package/dist/node/workers/workers.js +677 -0
- package/dist/node/workers/workers.js.map +1 -0
- package/dist/output.d.ts +1 -1
- package/dist/output.d.ts.map +1 -1
- package/dist/output.js +4 -2
- package/dist/output.js.map +1 -1
- package/dist/react/hooks.d.ts +43 -0
- package/dist/react/hooks.d.ts.map +1 -0
- package/dist/react/hooks.js +82 -0
- package/dist/react/hooks.js.map +1 -0
- package/dist/react/index.d.ts +3 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +4 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/stores.d.ts +9 -0
- package/dist/react/stores.d.ts.map +1 -0
- package/dist/react/stores.js +37 -0
- package/dist/react/stores.js.map +1 -0
- package/dist/registries/contribution.d.ts +50 -0
- package/dist/registries/contribution.d.ts.map +1 -0
- package/dist/registries/contribution.js +129 -0
- package/dist/registries/contribution.js.map +1 -0
- package/dist/registries/entries.d.ts +18 -0
- package/dist/registries/entries.d.ts.map +1 -0
- package/dist/registries/entries.js +42 -0
- package/dist/registries/entries.js.map +1 -0
- package/dist/registries/index.d.ts +3 -0
- package/dist/registries/index.d.ts.map +1 -0
- package/dist/registries/index.js +5 -0
- package/dist/registries/index.js.map +1 -0
- package/dist/registries/internal.d.ts +4 -0
- package/dist/registries/internal.d.ts.map +1 -0
- package/dist/registries/internal.js +5 -0
- package/dist/registries/internal.js.map +1 -0
- package/dist/registries/record.d.ts +115 -0
- package/dist/registries/record.d.ts.map +1 -0
- package/dist/registries/record.js +283 -0
- package/dist/registries/record.js.map +1 -0
- package/dist/registries/registry.d.ts +74 -0
- package/dist/registries/registry.d.ts.map +1 -0
- package/dist/registries/registry.js +14 -0
- package/dist/registries/registry.js.map +1 -0
- package/dist/registries/value.d.ts +48 -0
- package/dist/registries/value.d.ts.map +1 -0
- package/dist/registries/value.js +224 -0
- package/dist/registries/value.js.map +1 -0
- package/dist/remote/calls.d.ts +25 -0
- package/dist/remote/calls.d.ts.map +1 -0
- package/dist/remote/calls.js +62 -0
- package/dist/remote/calls.js.map +1 -0
- package/dist/remote/consumer.d.ts +43 -0
- package/dist/remote/consumer.d.ts.map +1 -0
- package/dist/remote/consumer.js +350 -0
- package/dist/remote/consumer.js.map +1 -0
- package/dist/remote/hold.d.ts +141 -0
- package/dist/remote/hold.d.ts.map +1 -0
- package/dist/remote/hold.js +579 -0
- package/dist/remote/hold.js.map +1 -0
- package/dist/remote/host-link.d.ts +77 -0
- package/dist/remote/host-link.d.ts.map +1 -0
- package/dist/remote/host-link.js +184 -0
- package/dist/remote/host-link.js.map +1 -0
- package/dist/remote/internal.d.ts +6 -0
- package/dist/remote/internal.d.ts.map +1 -0
- package/dist/remote/internal.js +6 -0
- package/dist/remote/internal.js.map +1 -0
- package/dist/remote/path.d.ts +46 -0
- package/dist/remote/path.d.ts.map +1 -0
- package/dist/remote/path.js +73 -0
- package/dist/remote/path.js.map +1 -0
- package/dist/remote/provider.d.ts +89 -0
- package/dist/remote/provider.d.ts.map +1 -0
- package/dist/remote/provider.js +597 -0
- package/dist/remote/provider.js.map +1 -0
- package/dist/remote/relay.d.ts +69 -0
- package/dist/remote/relay.d.ts.map +1 -0
- package/dist/remote/relay.js +219 -0
- package/dist/remote/relay.js.map +1 -0
- package/dist/remote/remote-object.d.ts +138 -0
- package/dist/remote/remote-object.d.ts.map +1 -0
- package/dist/remote/remote-object.js +492 -0
- package/dist/remote/remote-object.js.map +1 -0
- package/dist/remote/replica.d.ts +59 -0
- package/dist/remote/replica.d.ts.map +1 -0
- package/dist/remote/replica.js +125 -0
- package/dist/remote/replica.js.map +1 -0
- package/dist/sqlite/cloudflare.d.ts +2 -0
- package/dist/sqlite/cloudflare.d.ts.map +1 -1
- package/dist/sqlite/cloudflare.js +10 -0
- package/dist/sqlite/cloudflare.js.map +1 -1
- package/dist/sqlite/database.d.ts +5 -2
- package/dist/sqlite/database.d.ts.map +1 -1
- package/dist/sqlite/database.js.map +1 -1
- package/dist/sqlite/node.d.ts +13 -2
- package/dist/sqlite/node.d.ts.map +1 -1
- package/dist/sqlite/node.js +31 -8
- package/dist/sqlite/node.js.map +1 -1
- package/dist/state/batch.d.ts +64 -0
- package/dist/state/batch.d.ts.map +1 -0
- package/dist/state/batch.js +164 -0
- package/dist/state/batch.js.map +1 -0
- package/dist/state/derive.d.ts +52 -0
- package/dist/state/derive.d.ts.map +1 -0
- package/dist/state/derive.js +182 -0
- package/dist/state/derive.js.map +1 -0
- package/dist/state/index.d.ts +6 -0
- package/dist/state/index.d.ts.map +1 -0
- package/dist/state/index.js +4 -0
- package/dist/state/index.js.map +1 -0
- package/dist/state/internal.d.ts +6 -0
- package/dist/state/internal.d.ts.map +1 -0
- package/dist/state/internal.js +8 -0
- package/dist/state/internal.js.map +1 -0
- package/dist/state/native-source.d.ts +106 -0
- package/dist/state/native-source.d.ts.map +1 -0
- package/dist/state/native-source.js +240 -0
- package/dist/state/native-source.js.map +1 -0
- package/dist/state/watchable.d.ts +114 -0
- package/dist/state/watchable.d.ts.map +1 -0
- package/dist/state/watchable.js +156 -0
- package/dist/state/watchable.js.map +1 -0
- package/dist/state/writable.d.ts +32 -0
- package/dist/state/writable.d.ts.map +1 -0
- package/dist/state/writable.js +49 -0
- package/dist/state/writable.js.map +1 -0
- package/dist/store/adapter.d.ts +67 -0
- package/dist/store/adapter.d.ts.map +1 -0
- package/dist/store/adapter.js +118 -0
- package/dist/store/adapter.js.map +1 -0
- package/dist/store/allocator.d.ts +17 -0
- package/dist/store/allocator.d.ts.map +1 -0
- package/dist/store/allocator.js +30 -0
- package/dist/store/allocator.js.map +1 -0
- package/dist/store/applier.d.ts +8 -0
- package/dist/store/applier.d.ts.map +1 -0
- package/dist/store/applier.js +375 -0
- package/dist/store/applier.js.map +1 -0
- package/dist/store/apply-batch.d.ts +12 -0
- package/dist/store/apply-batch.d.ts.map +1 -0
- package/dist/store/apply-batch.js +83 -0
- package/dist/store/apply-batch.js.map +1 -0
- package/dist/store/archive.d.ts +32 -0
- package/dist/store/archive.d.ts.map +1 -0
- package/dist/store/archive.js +130 -0
- package/dist/store/archive.js.map +1 -0
- package/dist/store/backend.d.ts +10 -0
- package/dist/store/backend.d.ts.map +1 -0
- package/dist/store/backend.js +15 -0
- package/dist/store/backend.js.map +1 -0
- package/dist/store/catalog.d.ts +24 -0
- package/dist/store/catalog.d.ts.map +1 -0
- package/dist/store/catalog.js +17 -0
- package/dist/store/catalog.js.map +1 -0
- package/dist/store/claims.d.ts +23 -0
- package/dist/store/claims.d.ts.map +1 -0
- package/dist/store/claims.js +65 -0
- package/dist/store/claims.js.map +1 -0
- package/dist/store/columns.d.ts +77 -0
- package/dist/store/columns.d.ts.map +1 -0
- package/dist/store/columns.js +77 -0
- package/dist/store/columns.js.map +1 -0
- package/dist/store/engine.d.ts +176 -0
- package/dist/store/engine.d.ts.map +1 -0
- package/dist/store/engine.js +283 -0
- package/dist/store/engine.js.map +1 -0
- package/dist/store/evaluate.d.ts +17 -0
- package/dist/store/evaluate.d.ts.map +1 -0
- package/dist/store/evaluate.js +128 -0
- package/dist/store/evaluate.js.map +1 -0
- package/dist/store/export.d.ts +17 -0
- package/dist/store/export.d.ts.map +1 -0
- package/dist/store/export.js +200 -0
- package/dist/store/export.js.map +1 -0
- package/dist/store/expression.d.ts +150 -0
- package/dist/store/expression.d.ts.map +1 -0
- package/dist/store/expression.js +268 -0
- package/dist/store/expression.js.map +1 -0
- package/dist/store/import.d.ts +10 -0
- package/dist/store/import.d.ts.map +1 -0
- package/dist/store/import.js +276 -0
- package/dist/store/import.js.map +1 -0
- package/dist/store/index.d.ts +16 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +13 -0
- package/dist/store/index.js.map +1 -0
- package/dist/store/json-column.d.ts +33 -0
- package/dist/store/json-column.d.ts.map +1 -0
- package/dist/store/json-column.js +62 -0
- package/dist/store/json-column.js.map +1 -0
- package/dist/store/jsonl.d.ts +9 -0
- package/dist/store/jsonl.d.ts.map +1 -0
- package/dist/store/jsonl.js +61 -0
- package/dist/store/jsonl.js.map +1 -0
- package/dist/store/live-query.d.ts +108 -0
- package/dist/store/live-query.d.ts.map +1 -0
- package/dist/store/live-query.js +254 -0
- package/dist/store/live-query.js.map +1 -0
- package/dist/store/outbox.d.ts +26 -0
- package/dist/store/outbox.d.ts.map +1 -0
- package/dist/store/outbox.js +80 -0
- package/dist/store/outbox.js.map +1 -0
- package/dist/store/query.d.ts +39 -0
- package/dist/store/query.d.ts.map +1 -0
- package/dist/store/query.js +97 -0
- package/dist/store/query.js.map +1 -0
- package/dist/store/refusal.d.ts +15 -0
- package/dist/store/refusal.d.ts.map +1 -0
- package/dist/store/refusal.js +36 -0
- package/dist/store/refusal.js.map +1 -0
- package/dist/store/rows.d.ts +80 -0
- package/dist/store/rows.d.ts.map +1 -0
- package/dist/store/rows.js +183 -0
- package/dist/store/rows.js.map +1 -0
- package/dist/store/schema.d.ts +25 -0
- package/dist/store/schema.d.ts.map +1 -0
- package/dist/store/schema.js +115 -0
- package/dist/store/schema.js.map +1 -0
- package/dist/store/sql.d.ts +73 -0
- package/dist/store/sql.d.ts.map +1 -0
- package/dist/store/sql.js +234 -0
- package/dist/store/sql.js.map +1 -0
- package/dist/store/step.d.ts +50 -0
- package/dist/store/step.d.ts.map +1 -0
- package/dist/store/step.js +52 -0
- package/dist/store/step.js.map +1 -0
- package/dist/store/store.d.ts +171 -0
- package/dist/store/store.d.ts.map +1 -0
- package/dist/store/store.js +818 -0
- package/dist/store/store.js.map +1 -0
- package/dist/store/table-changes.d.ts +29 -0
- package/dist/store/table-changes.d.ts.map +1 -0
- package/dist/store/table-changes.js +102 -0
- package/dist/store/table-changes.js.map +1 -0
- package/dist/store/table-evolve.d.ts +74 -0
- package/dist/store/table-evolve.d.ts.map +1 -0
- package/dist/store/table-evolve.js +201 -0
- package/dist/store/table-evolve.js.map +1 -0
- package/dist/store/table-handle.d.ts +73 -0
- package/dist/store/table-handle.d.ts.map +1 -0
- package/dist/store/table-handle.js +101 -0
- package/dist/store/table-handle.js.map +1 -0
- package/dist/store/table-history.d.ts +75 -0
- package/dist/store/table-history.d.ts.map +1 -0
- package/dist/store/table-history.js +42 -0
- package/dist/store/table-history.js.map +1 -0
- package/dist/store/table-migration.d.ts +16 -0
- package/dist/store/table-migration.d.ts.map +1 -0
- package/dist/store/table-migration.js +202 -0
- package/dist/store/table-migration.js.map +1 -0
- package/dist/store/table-writes.d.ts +125 -0
- package/dist/store/table-writes.d.ts.map +1 -0
- package/dist/store/table-writes.js +170 -0
- package/dist/store/table-writes.js.map +1 -0
- package/dist/store/table.d.ts +80 -0
- package/dist/store/table.d.ts.map +1 -0
- package/dist/store/table.js +103 -0
- package/dist/store/table.js.map +1 -0
- package/dist/store/text.d.ts +14 -0
- package/dist/store/text.d.ts.map +1 -0
- package/dist/store/text.js +51 -0
- package/dist/store/text.js.map +1 -0
- package/dist/store/writes.d.ts +5 -0
- package/dist/store/writes.d.ts.map +1 -0
- package/dist/store/writes.js +4 -0
- package/dist/store/writes.js.map +1 -0
- package/dist/surfaces/active-language.d.ts +20 -0
- package/dist/surfaces/active-language.d.ts.map +1 -0
- package/dist/surfaces/active-language.js +78 -0
- package/dist/surfaces/active-language.js.map +1 -0
- package/dist/surfaces/active-theme.d.ts +16 -0
- package/dist/surfaces/active-theme.d.ts.map +1 -0
- package/dist/surfaces/active-theme.js +47 -0
- package/dist/surfaces/active-theme.js.map +1 -0
- package/dist/surfaces/client.d.ts +96 -0
- package/dist/surfaces/client.d.ts.map +1 -0
- package/dist/surfaces/client.js +264 -0
- package/dist/surfaces/client.js.map +1 -0
- package/dist/surfaces/connection.d.ts +49 -0
- package/dist/surfaces/connection.d.ts.map +1 -0
- package/dist/surfaces/connection.js +142 -0
- package/dist/surfaces/connection.js.map +1 -0
- package/dist/surfaces/format.d.ts +5 -0
- package/dist/surfaces/format.d.ts.map +1 -0
- package/dist/surfaces/format.js +37 -0
- package/dist/surfaces/format.js.map +1 -0
- package/dist/surfaces/index.d.ts +15 -0
- package/dist/surfaces/index.d.ts.map +1 -0
- package/dist/surfaces/index.js +18 -0
- package/dist/surfaces/index.js.map +1 -0
- package/dist/surfaces/language.d.ts +53 -0
- package/dist/surfaces/language.d.ts.map +1 -0
- package/dist/surfaces/language.js +74 -0
- package/dist/surfaces/language.js.map +1 -0
- package/dist/surfaces/loaded.d.ts +42 -0
- package/dist/surfaces/loaded.d.ts.map +1 -0
- package/dist/surfaces/loaded.js +116 -0
- package/dist/surfaces/loaded.js.map +1 -0
- package/dist/surfaces/locale-choice.d.ts +25 -0
- package/dist/surfaces/locale-choice.d.ts.map +1 -0
- package/dist/surfaces/locale-choice.js +14 -0
- package/dist/surfaces/locale-choice.js.map +1 -0
- package/dist/surfaces/messages.d.ts +67 -0
- package/dist/surfaces/messages.d.ts.map +1 -0
- package/dist/surfaces/messages.js +112 -0
- package/dist/surfaces/messages.js.map +1 -0
- package/dist/surfaces/page-state.d.ts +14 -0
- package/dist/surfaces/page-state.d.ts.map +1 -0
- package/dist/surfaces/page-state.js +43 -0
- package/dist/surfaces/page-state.js.map +1 -0
- package/dist/surfaces/preference.d.ts +32 -0
- package/dist/surfaces/preference.d.ts.map +1 -0
- package/dist/surfaces/preference.js +72 -0
- package/dist/surfaces/preference.js.map +1 -0
- package/dist/surfaces/registered.d.ts +33 -0
- package/dist/surfaces/registered.d.ts.map +1 -0
- package/dist/surfaces/registered.js +51 -0
- package/dist/surfaces/registered.js.map +1 -0
- package/dist/surfaces/scripts.d.ts +84 -0
- package/dist/surfaces/scripts.d.ts.map +1 -0
- package/dist/surfaces/scripts.js +28 -0
- package/dist/surfaces/scripts.js.map +1 -0
- package/dist/surfaces/theme-choice.d.ts +31 -0
- package/dist/surfaces/theme-choice.d.ts.map +1 -0
- package/dist/surfaces/theme-choice.js +18 -0
- package/dist/surfaces/theme-choice.js.map +1 -0
- package/dist/surfaces/themes.d.ts +43 -0
- package/dist/surfaces/themes.d.ts.map +1 -0
- package/dist/surfaces/themes.js +110 -0
- package/dist/surfaces/themes.js.map +1 -0
- package/dist/surfaces/translations.d.ts +29 -0
- package/dist/surfaces/translations.d.ts.map +1 -0
- package/dist/surfaces/translations.js +57 -0
- package/dist/surfaces/translations.js.map +1 -0
- package/dist/sync/batch.d.ts +18 -0
- package/dist/sync/batch.d.ts.map +1 -0
- package/dist/sync/batch.js +125 -0
- package/dist/sync/batch.js.map +1 -0
- package/dist/sync/client.d.ts +166 -0
- package/dist/sync/client.d.ts.map +1 -0
- package/dist/sync/client.js +438 -0
- package/dist/sync/client.js.map +1 -0
- package/dist/sync/files.d.ts +46 -0
- package/dist/sync/files.d.ts.map +1 -0
- package/dist/sync/files.js +13 -0
- package/dist/sync/files.js.map +1 -0
- package/dist/sync/filesystem.d.ts +37 -0
- package/dist/sync/filesystem.d.ts.map +1 -0
- package/dist/sync/filesystem.js +185 -0
- package/dist/sync/filesystem.js.map +1 -0
- package/dist/sync/index.d.ts +8 -0
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/index.js +9 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/sync/lines.d.ts +18 -0
- package/dist/sync/lines.d.ts.map +1 -0
- package/dist/sync/lines.js +46 -0
- package/dist/sync/lines.js.map +1 -0
- package/dist/sync/remote.d.ts +130 -0
- package/dist/sync/remote.d.ts.map +1 -0
- package/dist/sync/remote.js +46 -0
- package/dist/sync/remote.js.map +1 -0
- package/dist/sync/state.d.ts +17 -0
- package/dist/sync/state.d.ts.map +1 -0
- package/dist/sync/state.js +40 -0
- package/dist/sync/state.js.map +1 -0
- package/dist/telemetry-ingest/batch.d.ts +70 -0
- package/dist/telemetry-ingest/batch.d.ts.map +1 -0
- package/dist/telemetry-ingest/batch.js +110 -0
- package/dist/telemetry-ingest/batch.js.map +1 -0
- package/dist/telemetry-ingest/facet.d.ts +21 -0
- package/dist/telemetry-ingest/facet.d.ts.map +1 -0
- package/dist/telemetry-ingest/facet.js +96 -0
- package/dist/telemetry-ingest/facet.js.map +1 -0
- package/dist/telemetry-ingest/index.d.ts +5 -0
- package/dist/telemetry-ingest/index.d.ts.map +1 -0
- package/dist/telemetry-ingest/index.js +8 -0
- package/dist/telemetry-ingest/index.js.map +1 -0
- package/dist/telemetry-ingest/recorder.d.ts +50 -0
- package/dist/telemetry-ingest/recorder.d.ts.map +1 -0
- package/dist/telemetry-ingest/recorder.js +298 -0
- package/dist/telemetry-ingest/recorder.js.map +1 -0
- package/dist/telemetry-ingest/sender.d.ts +14 -0
- package/dist/telemetry-ingest/sender.d.ts.map +1 -0
- package/dist/telemetry-ingest/sender.js +64 -0
- package/dist/telemetry-ingest/sender.js.map +1 -0
- package/dist/telemetry-sqlite/index.d.ts +13 -4
- package/dist/telemetry-sqlite/index.d.ts.map +1 -1
- package/dist/telemetry-sqlite/index.js +81 -241
- package/dist/telemetry-sqlite/index.js.map +1 -1
- package/dist/telemetry-sqlite/node.d.ts +13 -0
- package/dist/telemetry-sqlite/node.d.ts.map +1 -0
- package/dist/telemetry-sqlite/node.js +27 -0
- package/dist/telemetry-sqlite/node.js.map +1 -0
- package/dist/telemetry-sqlite/schema.d.ts +9 -0
- package/dist/telemetry-sqlite/schema.d.ts.map +1 -0
- package/dist/telemetry-sqlite/schema.js +61 -0
- package/dist/telemetry-sqlite/schema.js.map +1 -0
- package/dist/telemetry-sqlite/store.d.ts +3 -0
- package/dist/telemetry-sqlite/store.d.ts.map +1 -1
- package/dist/telemetry-sqlite/store.js +24 -13
- package/dist/telemetry-sqlite/store.js.map +1 -1
- package/dist/telemetry.d.ts +937 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +470 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/tui/bridge.d.ts +112 -0
- package/dist/tui/bridge.d.ts.map +1 -0
- package/dist/tui/bridge.js +9 -0
- package/dist/tui/bridge.js.map +1 -0
- package/dist/tui/channel.d.ts +44 -0
- package/dist/tui/channel.d.ts.map +1 -0
- package/dist/tui/channel.js +150 -0
- package/dist/tui/channel.js.map +1 -0
- package/dist/tui/frames.d.ts +5 -0
- package/dist/tui/frames.d.ts.map +1 -0
- package/dist/tui/frames.js +52 -0
- package/dist/tui/frames.js.map +1 -0
- package/dist/tui/index.d.ts +7 -0
- package/dist/tui/index.d.ts.map +1 -0
- package/dist/tui/index.js +8 -0
- package/dist/tui/index.js.map +1 -0
- package/dist/tui/runtime.d.ts +46 -0
- package/dist/tui/runtime.d.ts.map +1 -0
- package/dist/tui/runtime.js +101 -0
- package/dist/tui/runtime.js.map +1 -0
- package/dist/tui/scope.d.ts +46 -0
- package/dist/tui/scope.d.ts.map +1 -0
- package/dist/tui/scope.js +141 -0
- package/dist/tui/scope.js.map +1 -0
- package/dist/tui/terminal.d.ts +15 -0
- package/dist/tui/terminal.d.ts.map +1 -0
- package/dist/tui/terminal.js +37 -0
- package/dist/tui/terminal.js.map +1 -0
- package/dist/tui/theme.d.ts +17 -0
- package/dist/tui/theme.d.ts.map +1 -0
- package/dist/tui/theme.js +38 -0
- package/dist/tui/theme.js.map +1 -0
- package/dist/watch.d.ts +194 -0
- package/dist/watch.d.ts.map +1 -0
- package/dist/watch.js +383 -0
- package/dist/watch.js.map +1 -0
- package/dist/web/environment.d.ts +4 -0
- package/dist/web/environment.d.ts.map +1 -0
- package/dist/web/environment.js +37 -0
- package/dist/web/environment.js.map +1 -0
- package/dist/web/index.d.ts +5 -0
- package/dist/web/index.d.ts.map +1 -0
- package/dist/web/index.js +7 -0
- package/dist/web/index.js.map +1 -0
- package/dist/web/language.d.ts +7 -0
- package/dist/web/language.d.ts.map +1 -0
- package/dist/web/language.js +21 -0
- package/dist/web/language.js.map +1 -0
- package/dist/web/page.d.ts +29 -0
- package/dist/web/page.d.ts.map +1 -0
- package/dist/web/page.js +92 -0
- package/dist/web/page.js.map +1 -0
- package/dist/web/scripts.d.ts +23 -0
- package/dist/web/scripts.d.ts.map +1 -0
- package/dist/web/scripts.js +50 -0
- package/dist/web/scripts.js.map +1 -0
- package/dist/web/styles.d.ts +17 -0
- package/dist/web/styles.d.ts.map +1 -0
- package/dist/web/styles.js +218 -0
- package/dist/web/styles.js.map +1 -0
- package/dist/web/themes.d.ts +6 -0
- package/dist/web/themes.d.ts.map +1 -0
- package/dist/web/themes.js +31 -0
- package/dist/web/themes.js.map +1 -0
- package/docs/benchmarks.md +1036 -0
- package/docs/decisions.md +3436 -0
- package/docs/dependencies/book.md +1671 -0
- package/docs/dependencies/index.html +2641 -0
- package/docs/dependencies/model.md +330 -0
- package/docs/design.md +3065 -0
- package/docs/durable-observers/book.md +432 -0
- package/docs/durable-observers/index.html +517 -0
- package/docs/flow-control/book.md +333 -0
- package/docs/flow-control/fold/index.html +265 -0
- package/docs/flow-control/index.html +548 -0
- package/docs/flow-control/window/index.html +228 -0
- package/docs/guide-plugins-hosts/book.md +957 -0
- package/docs/guide-plugins-hosts/index.html +952 -0
- package/docs/http-workers/book.md +378 -0
- package/docs/http-workers/index.html +515 -0
- package/docs/i18n/book.md +217 -0
- package/docs/i18n/index.html +344 -0
- package/docs/layer-1.md +311 -0
- package/docs/layer-2.md +216 -0
- package/docs/p3-features/README.md +6 -0
- package/docs/p3-features/book.md +478 -0
- package/docs/plugin-authoring.md +276 -0
- package/docs/plugin-model/book.md +186 -0
- package/docs/plugin-model/index.html +310 -0
- package/docs/plugin-primer/book.md +273 -0
- package/docs/plugin-primer/index.html +430 -0
- package/docs/slice-1.md +236 -0
- package/docs/slice-10.md +288 -0
- package/docs/slice-11.md +114 -0
- package/docs/slice-12.md +132 -0
- package/docs/slice-13.md +121 -0
- package/docs/slice-2.md +174 -0
- package/docs/slice-3a.md +296 -0
- package/docs/slice-3b.md +197 -0
- package/docs/slice-4.md +146 -0
- package/docs/slice-4a.md +418 -0
- package/docs/slice-4b.md +208 -0
- package/docs/slice-5.md +281 -0
- package/docs/slice-6a.md +676 -0
- package/docs/slice-6b.md +332 -0
- package/docs/slice-7a.md +130 -0
- package/docs/slice-7b/book.md +608 -0
- package/docs/slice-7b/index.html +842 -0
- package/docs/slice-7b.md +255 -0
- package/docs/slice-7c.md +165 -0
- package/docs/slice-8.md +194 -0
- package/docs/slice-9.md +110 -0
- package/docs/slices.md +241 -0
- package/docs/store/book.md +670 -0
- package/docs/store/index.html +861 -0
- package/docs/store/walkthrough.md +193 -0
- package/docs/theming/book.md +223 -0
- package/docs/theming/index.html +371 -0
- package/docs/tutorial/book.md +2169 -0
- package/docs/tutorial/index.html +2112 -0
- package/docs/tutorial/screens/click-after.png +0 -0
- package/docs/tutorial/screens/click-before.png +0 -0
- package/docs/tutorial/screens/edited.png +0 -0
- package/docs/tutorial/screens/french.png +0 -0
- package/docs/tutorial/screens/harbor.png +0 -0
- package/docs/tutorial/screens/page.png +0 -0
- package/docs/tutorial/screens/traces-ada.png +0 -0
- package/docs/tutorial/screens/traces.png +0 -0
- package/package.json +114 -20
- package/src/delta/README.md +69 -0
- package/dist/cell.d.ts +0 -122
- package/dist/cell.d.ts.map +0 -1
- package/dist/cell.js +0 -356
- package/dist/cell.js.map +0 -1
- package/dist/cluster.d.ts +0 -27
- package/dist/cluster.d.ts.map +0 -1
- package/dist/cluster.js +0 -230
- package/dist/cluster.js.map +0 -1
- package/dist/connection.d.ts +0 -270
- package/dist/connection.d.ts.map +0 -1
- package/dist/connection.js +0 -1216
- package/dist/connection.js.map +0 -1
- package/dist/contract.d.ts +0 -208
- package/dist/contract.d.ts.map +0 -1
- package/dist/contract.js +0 -246
- package/dist/contract.js.map +0 -1
- package/dist/declare.d.ts +0 -33
- package/dist/declare.d.ts.map +0 -1
- package/dist/declare.js +0 -2
- package/dist/declare.js.map +0 -1
- package/dist/errors.d.ts +0 -28
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -59
- package/dist/errors.js.map +0 -1
- package/dist/host.d.ts +0 -348
- package/dist/host.d.ts.map +0 -1
- package/dist/host.js +0 -1000
- package/dist/host.js.map +0 -1
- package/dist/link.d.ts +0 -107
- package/dist/link.d.ts.map +0 -1
- package/dist/link.js +0 -355
- package/dist/link.js.map +0 -1
- package/dist/loader.d.ts +0 -4
- package/dist/loader.d.ts.map +0 -1
- package/dist/loader.js +0 -73
- package/dist/loader.js.map +0 -1
- package/dist/manager.d.ts +0 -115
- package/dist/manager.d.ts.map +0 -1
- package/dist/manager.js +0 -345
- package/dist/manager.js.map +0 -1
- package/dist/node.d.ts +0 -4
- package/dist/node.d.ts.map +0 -1
- package/dist/node.js +0 -4
- package/dist/node.js.map +0 -1
- package/dist/object.d.ts +0 -438
- package/dist/object.d.ts.map +0 -1
- package/dist/object.js +0 -1571
- package/dist/object.js.map +0 -1
- package/dist/publish.d.ts +0 -5
- package/dist/publish.d.ts.map +0 -1
- package/dist/publish.js +0 -40
- package/dist/publish.js.map +0 -1
- package/dist/registry.d.ts +0 -25
- package/dist/registry.d.ts.map +0 -1
- package/dist/registry.js +0 -6
- package/dist/registry.js.map +0 -1
- package/dist/reload.d.ts +0 -126
- package/dist/reload.d.ts.map +0 -1
- package/dist/reload.js +0 -653
- package/dist/reload.js.map +0 -1
- package/dist/remote.d.ts +0 -165
- package/dist/remote.d.ts.map +0 -1
- package/dist/remote.js +0 -612
- package/dist/remote.js.map +0 -1
- package/dist/schema.d.ts +0 -21
- package/dist/schema.d.ts.map +0 -1
- package/dist/schema.js +0 -228
- package/dist/schema.js.map +0 -1
- package/dist/state.d.ts +0 -92
- package/dist/state.d.ts.map +0 -1
- package/dist/state.js +0 -287
- package/dist/state.js.map +0 -1
- package/dist/types.d.ts +0 -88
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/websocket.d.ts +0 -15
- package/dist/websocket.d.ts.map +0 -1
- package/dist/websocket.js +0 -16
- package/dist/websocket.js.map +0 -1
- package/dist/wire.d.ts +0 -216
- package/dist/wire.d.ts.map +0 -1
- package/dist/wire.js +0 -165
- package/dist/wire.js.map +0 -1
- package/docs/guide.md +0 -814
- package/docs/spec.md +0 -288
- package/docs/tutorial.md +0 -931
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// The launcher's end of the sandbox's pipes (slice 11 §4; fix round 2: the sandbox a child process): messages as
|
|
2
|
+
// plain length-prefixed binary frames, not Node's IPC. A frame is a 4-byte big-endian length, then the payload: a
|
|
3
|
+
// 4-byte big-endian header length, the header (the message as JSON, its body field left out), and the body (the raw
|
|
4
|
+
// bytes of `bytes`, or the UTF-8 text of `data`). The sandbox's bootstrap has the same codec (`sandbox.ts`). What the
|
|
5
|
+
// sandbox sends is untrusted: each frame is bounded, and each message checked here before the launcher acts on it.
|
|
6
|
+
/** The largest frame either side takes: 17 MiB (an attached file of 16 MiB and its header). */
|
|
7
|
+
export const MAX_PIPE_FRAME = 17 * 1024 * 1024;
|
|
8
|
+
/** The largest header of a frame from the sandbox: 1 MiB (a request's text or URL; frames carry their text as body). */
|
|
9
|
+
const MAX_HEADER = 1024 * 1024;
|
|
10
|
+
/** `message` as one frame for the sandbox. */
|
|
11
|
+
export function launcherFrame(message) {
|
|
12
|
+
if (message.kind === "input")
|
|
13
|
+
return frame({ kind: "input" }, Buffer.from(message.data));
|
|
14
|
+
if (message.kind === "socket_message")
|
|
15
|
+
return frame({ kind: message.kind, socket: message.socket }, message.bytes);
|
|
16
|
+
if (message.kind === "attached")
|
|
17
|
+
return frame({ kind: message.kind, id: message.id, name: message.name }, message.bytes);
|
|
18
|
+
return frame(message, undefined);
|
|
19
|
+
}
|
|
20
|
+
/** The first frame: the bridge's start and the base bundle's text as body. */
|
|
21
|
+
export function startFrame(start, source) {
|
|
22
|
+
return frame({ kind: "start", start }, Buffer.from(source));
|
|
23
|
+
}
|
|
24
|
+
/** A frame of `header` and `body`. */
|
|
25
|
+
function frame(header, body) {
|
|
26
|
+
const json = Buffer.from(JSON.stringify(header));
|
|
27
|
+
const prefix = Buffer.allocUnsafe(8);
|
|
28
|
+
prefix.writeUInt32BE(4 + json.length + (body?.length ?? 0), 0);
|
|
29
|
+
prefix.writeUInt32BE(json.length, 4);
|
|
30
|
+
return Buffer.concat(body === undefined ? [prefix, json] : [prefix, json, body]);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Cuts the sandbox's output into messages as chunks arrive; throws (the sandbox is ended) on a frame over
|
|
34
|
+
* `MAX_PIPE_FRAME`, a header over 1 MiB, or a message of no known shape. Each byte is copied in once, however small the
|
|
35
|
+
* chunks the sandbox writes.
|
|
36
|
+
*/
|
|
37
|
+
export class FrameReader {
|
|
38
|
+
#buffer = Buffer.alloc(64 * 1024);
|
|
39
|
+
#start = 0;
|
|
40
|
+
#end = 0;
|
|
41
|
+
/** The messages complete with `chunk`. */
|
|
42
|
+
push(chunk) {
|
|
43
|
+
this.#append(chunk);
|
|
44
|
+
const messages = [];
|
|
45
|
+
while (this.#end - this.#start >= 4) {
|
|
46
|
+
const length = this.#buffer.readUInt32BE(this.#start);
|
|
47
|
+
if (length < 4 || length > MAX_PIPE_FRAME)
|
|
48
|
+
throw new Error("terminal: the sandbox sent a malformed frame");
|
|
49
|
+
if (this.#end - this.#start < 4 + length)
|
|
50
|
+
break;
|
|
51
|
+
// The message copies what it keeps: the buffer is reused.
|
|
52
|
+
messages.push(sandboxMessage(this.#buffer.subarray(this.#start + 4, this.#start + 4 + length)));
|
|
53
|
+
this.#start += 4 + length;
|
|
54
|
+
}
|
|
55
|
+
if (this.#start === this.#end)
|
|
56
|
+
this.#start = this.#end = 0;
|
|
57
|
+
return messages;
|
|
58
|
+
}
|
|
59
|
+
/** Copies `chunk` in after the unread bytes, moving them to the front or growing the buffer when it is full. */
|
|
60
|
+
#append(chunk) {
|
|
61
|
+
const unread = this.#end - this.#start;
|
|
62
|
+
if (this.#end + chunk.length > this.#buffer.length) {
|
|
63
|
+
const needed = unread + chunk.length;
|
|
64
|
+
const target = needed <= this.#buffer.length
|
|
65
|
+
? this.#buffer
|
|
66
|
+
: Buffer.alloc(Math.max(needed, Math.min(this.#buffer.length * 2, MAX_PIPE_FRAME + 4)));
|
|
67
|
+
this.#buffer.copy(target, 0, this.#start, this.#end);
|
|
68
|
+
this.#buffer = target;
|
|
69
|
+
this.#start = 0;
|
|
70
|
+
this.#end = unread;
|
|
71
|
+
}
|
|
72
|
+
chunk.copy(this.#buffer, this.#end);
|
|
73
|
+
this.#end += chunk.length;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The message in `payload` (a frame from the sandbox, without its length); throws for anything else. Trust boundary:
|
|
78
|
+
* the sandbox's pipe.
|
|
79
|
+
*/
|
|
80
|
+
function sandboxMessage(payload) {
|
|
81
|
+
const headerLength = payload.readUInt32BE(0);
|
|
82
|
+
if (headerLength > MAX_HEADER || 4 + headerLength > payload.length)
|
|
83
|
+
throw malformed();
|
|
84
|
+
const header = JSON.parse(payload.toString("utf8", 4, 4 + headerLength));
|
|
85
|
+
const body = payload.subarray(4 + headerLength);
|
|
86
|
+
if (typeof header !== "object" || header === null)
|
|
87
|
+
throw malformed();
|
|
88
|
+
const socket = header.socket;
|
|
89
|
+
switch (header.kind) {
|
|
90
|
+
case "write":
|
|
91
|
+
return { kind: "write", data: body.toString("utf8") };
|
|
92
|
+
case "socket_send":
|
|
93
|
+
if (!Number.isSafeInteger(socket))
|
|
94
|
+
throw malformed();
|
|
95
|
+
// A copy: the payload's memory is the reader's.
|
|
96
|
+
return { kind: "socket_send", socket: socket, bytes: new Uint8Array(body) };
|
|
97
|
+
case "socket_open":
|
|
98
|
+
case "socket_close":
|
|
99
|
+
if (!Number.isSafeInteger(socket))
|
|
100
|
+
throw malformed();
|
|
101
|
+
return { kind: header.kind, socket: socket };
|
|
102
|
+
case "request":
|
|
103
|
+
if (!Number.isSafeInteger(header.id))
|
|
104
|
+
throw malformed();
|
|
105
|
+
return { kind: "request", id: header.id, request: bridgeRequest(header.request) };
|
|
106
|
+
case "outdated":
|
|
107
|
+
return { kind: "outdated" };
|
|
108
|
+
case "failed":
|
|
109
|
+
return { kind: "failed", message: String(header.message) };
|
|
110
|
+
case "exit":
|
|
111
|
+
return { kind: "exit", code: Number.isSafeInteger(header.code) ? header.code : 1 };
|
|
112
|
+
default:
|
|
113
|
+
throw malformed();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/** The request `value` names; throws for anything else. */
|
|
117
|
+
function bridgeRequest(value) {
|
|
118
|
+
const request = (typeof value === "object" && value !== null ? value : {});
|
|
119
|
+
if (request.kind === "base")
|
|
120
|
+
return { kind: "base" };
|
|
121
|
+
if (request.kind === "fetch" && typeof request.path === "string")
|
|
122
|
+
return { kind: "fetch", path: request.path };
|
|
123
|
+
if (request.kind === "copy" && typeof request.text === "string")
|
|
124
|
+
return { kind: "copy", text: request.text };
|
|
125
|
+
if (request.kind === "open" && typeof request.url === "string")
|
|
126
|
+
return { kind: "open", url: request.url };
|
|
127
|
+
if (request.kind === "attach" && typeof request.path === "string")
|
|
128
|
+
return { kind: "attach", path: request.path };
|
|
129
|
+
throw malformed();
|
|
130
|
+
}
|
|
131
|
+
function malformed() {
|
|
132
|
+
return new Error("terminal: the sandbox sent a malformed message");
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=pipe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipe.js","sourceRoot":"","sources":["../../../src/node/tui/pipe.ts"],"names":[],"mappings":"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","sourcesContent":["// The launcher's end of the sandbox's pipes (slice 11 §4; fix round 2: the sandbox a child process): messages as\n// plain length-prefixed binary frames, not Node's IPC. A frame is a 4-byte big-endian length, then the payload: a\n// 4-byte big-endian header length, the header (the message as JSON, its body field left out), and the body (the raw\n// bytes of `bytes`, or the UTF-8 text of `data`). The sandbox's bootstrap has the same codec (`sandbox.ts`). What the\n// sandbox sends is untrusted: each frame is bounded, and each message checked here before the launcher acts on it.\n\nimport type { BridgeRequest, LauncherMessage, SandboxMessage } from \"../../tui/bridge.ts\";\n\n/** The largest frame either side takes: 17 MiB (an attached file of 16 MiB and its header). */\nexport const MAX_PIPE_FRAME = 17 * 1024 * 1024;\n\n/** The largest header of a frame from the sandbox: 1 MiB (a request's text or URL; frames carry their text as body). */\nconst MAX_HEADER = 1024 * 1024;\n\n/** `message` as one frame for the sandbox. */\nexport function launcherFrame(message: LauncherMessage): Buffer {\n\tif (message.kind === \"input\") return frame({ kind: \"input\" }, Buffer.from(message.data));\n\tif (message.kind === \"socket_message\") return frame({ kind: message.kind, socket: message.socket }, message.bytes);\n\tif (message.kind === \"attached\")\n\t\treturn frame({ kind: message.kind, id: message.id, name: message.name }, message.bytes);\n\treturn frame(message, undefined);\n}\n\n/** The first frame: the bridge's start and the base bundle's text as body. */\nexport function startFrame(start: unknown, source: string): Buffer {\n\treturn frame({ kind: \"start\", start }, Buffer.from(source));\n}\n\n/** A frame of `header` and `body`. */\nfunction frame(header: object, body: Uint8Array | undefined): Buffer {\n\tconst json = Buffer.from(JSON.stringify(header));\n\tconst prefix = Buffer.allocUnsafe(8);\n\tprefix.writeUInt32BE(4 + json.length + (body?.length ?? 0), 0);\n\tprefix.writeUInt32BE(json.length, 4);\n\treturn Buffer.concat(body === undefined ? [prefix, json] : [prefix, json, body]);\n}\n\n/**\n * Cuts the sandbox's output into messages as chunks arrive; throws (the sandbox is ended) on a frame over\n * `MAX_PIPE_FRAME`, a header over 1 MiB, or a message of no known shape. Each byte is copied in once, however small the\n * chunks the sandbox writes.\n */\nexport class FrameReader {\n\t#buffer = Buffer.alloc(64 * 1024);\n\t#start = 0;\n\t#end = 0;\n\n\t/** The messages complete with `chunk`. */\n\tpush(chunk: Buffer): SandboxMessage[] {\n\t\tthis.#append(chunk);\n\t\tconst messages: SandboxMessage[] = [];\n\t\twhile (this.#end - this.#start >= 4) {\n\t\t\tconst length = this.#buffer.readUInt32BE(this.#start);\n\t\t\tif (length < 4 || length > MAX_PIPE_FRAME) throw new Error(\"terminal: the sandbox sent a malformed frame\");\n\t\t\tif (this.#end - this.#start < 4 + length) break;\n\t\t\t// The message copies what it keeps: the buffer is reused.\n\t\t\tmessages.push(sandboxMessage(this.#buffer.subarray(this.#start + 4, this.#start + 4 + length)));\n\t\t\tthis.#start += 4 + length;\n\t\t}\n\t\tif (this.#start === this.#end) this.#start = this.#end = 0;\n\t\treturn messages;\n\t}\n\n\t/** Copies `chunk` in after the unread bytes, moving them to the front or growing the buffer when it is full. */\n\t#append(chunk: Buffer): void {\n\t\tconst unread = this.#end - this.#start;\n\t\tif (this.#end + chunk.length > this.#buffer.length) {\n\t\t\tconst needed = unread + chunk.length;\n\t\t\tconst target =\n\t\t\t\tneeded <= this.#buffer.length\n\t\t\t\t\t? this.#buffer\n\t\t\t\t\t: Buffer.alloc(Math.max(needed, Math.min(this.#buffer.length * 2, MAX_PIPE_FRAME + 4)));\n\t\t\tthis.#buffer.copy(target, 0, this.#start, this.#end);\n\t\t\tthis.#buffer = target;\n\t\t\tthis.#start = 0;\n\t\t\tthis.#end = unread;\n\t\t}\n\t\tchunk.copy(this.#buffer, this.#end);\n\t\tthis.#end += chunk.length;\n\t}\n}\n\n/**\n * The message in `payload` (a frame from the sandbox, without its length); throws for anything else. Trust boundary:\n * the sandbox's pipe.\n */\nfunction sandboxMessage(payload: Buffer): SandboxMessage {\n\tconst headerLength = payload.readUInt32BE(0);\n\tif (headerLength > MAX_HEADER || 4 + headerLength > payload.length) throw malformed();\n\tconst header = JSON.parse(payload.toString(\"utf8\", 4, 4 + headerLength)) as Record<string, unknown> | null;\n\tconst body = payload.subarray(4 + headerLength);\n\tif (typeof header !== \"object\" || header === null) throw malformed();\n\tconst socket = header.socket;\n\tswitch (header.kind) {\n\t\tcase \"write\":\n\t\t\treturn { kind: \"write\", data: body.toString(\"utf8\") };\n\t\tcase \"socket_send\":\n\t\t\tif (!Number.isSafeInteger(socket)) throw malformed();\n\t\t\t// A copy: the payload's memory is the reader's.\n\t\t\treturn { kind: \"socket_send\", socket: socket as number, bytes: new Uint8Array(body) };\n\t\tcase \"socket_open\":\n\t\tcase \"socket_close\":\n\t\t\tif (!Number.isSafeInteger(socket)) throw malformed();\n\t\t\treturn { kind: header.kind, socket: socket as number };\n\t\tcase \"request\":\n\t\t\tif (!Number.isSafeInteger(header.id)) throw malformed();\n\t\t\treturn { kind: \"request\", id: header.id as number, request: bridgeRequest(header.request) };\n\t\tcase \"outdated\":\n\t\t\treturn { kind: \"outdated\" };\n\t\tcase \"failed\":\n\t\t\treturn { kind: \"failed\", message: String(header.message) };\n\t\tcase \"exit\":\n\t\t\treturn { kind: \"exit\", code: Number.isSafeInteger(header.code) ? (header.code as number) : 1 };\n\t\tdefault:\n\t\t\tthrow malformed();\n\t}\n}\n\n/** The request `value` names; throws for anything else. */\nfunction bridgeRequest(value: unknown): BridgeRequest {\n\tconst request = (typeof value === \"object\" && value !== null ? value : {}) as Record<string, unknown>;\n\tif (request.kind === \"base\") return { kind: \"base\" };\n\tif (request.kind === \"fetch\" && typeof request.path === \"string\") return { kind: \"fetch\", path: request.path };\n\tif (request.kind === \"copy\" && typeof request.text === \"string\") return { kind: \"copy\", text: request.text };\n\tif (request.kind === \"open\" && typeof request.url === \"string\") return { kind: \"open\", url: request.url };\n\tif (request.kind === \"attach\" && typeof request.path === \"string\") return { kind: \"attach\", path: request.path };\n\tthrow malformed();\n}\n\nfunction malformed(): Error {\n\treturn new Error(\"terminal: the sandbox sent a malformed message\");\n}\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { BridgeStart, LauncherMessage, SandboxMessage } from "../../tui/bridge.ts";
|
|
2
|
+
/** The largest base bundle a sandbox runs: 8 MiB. */
|
|
3
|
+
export declare const MAX_BUNDLE: number;
|
|
4
|
+
/**
|
|
5
|
+
* The builtins code in the sandbox may `require`, each computation in memory without I/O, descriptors or machine
|
|
6
|
+
* details: bytes and text (`buffer`, `string_decoder`, `punycode`, `querystring`), events and streams in memory
|
|
7
|
+
* (`events`, `stream` and its submodules), formatting and type checks (`util`, `util/types`), URL and path strings
|
|
8
|
+
* (`url`, `path`), timers, assertions, hashing and randomness (`crypto`: no keys from files, no network) and compression
|
|
9
|
+
* in memory (`zlib`). Not `fs`, `tty`, `net`, `dgram`, `dns`, `http`, `https`, `http2`, `tls`, `child_process`,
|
|
10
|
+
* `cluster`, `worker_threads`, `sqlite`, `inspector`, `vm`, `v8`, `os`, `module`, `process`, `perf_hooks`, `wasi`,
|
|
11
|
+
* `repl`, `readline`, `trace_events` or anything else.
|
|
12
|
+
*/
|
|
13
|
+
export declare const SANDBOX_BUILTINS: readonly string[];
|
|
14
|
+
/**
|
|
15
|
+
* The sandbox's `process`: a frozen plain object in place of Node's (no event emitter, so no prototype shared with
|
|
16
|
+
* Node's internals leads back to the real one). Its properties, each harmless: which Node it is (`arch`, `platform`,
|
|
17
|
+
* `version`, `versions`, `release`), time (`nextTick`, `hrtime`, `uptime`), ending the sandbox (`exit`), the permission
|
|
18
|
+
* checks (`permission`), the allowed builtins (`getBuiltinModule`), fixed values (`env` empty, `argv`, `argv0`,
|
|
19
|
+
* `execArgv`, `execPath`, `title`, `cwd` `/`), `stdout` (to the terminal through the bridge) and `stderr` (dropped),
|
|
20
|
+
* and listener calls that keep nothing (`on`, `once`, `off`, `addListener`, `removeListener`, `removeAllListeners`,
|
|
21
|
+
* `emit`, `emitWarning`, `listenerCount`, `listeners`). Not `binding`, `_linkedBinding`, `dlopen`, `_rawDebug`, `kill`,
|
|
22
|
+
* `execve`, `chdir`, `abort`, `reallyExit`, `stdin`, `openStdin`, `report`, `pid`, `ppid`, `config`, the user and group
|
|
23
|
+
* calls, `loadEnvFile`, `moduleLoadList`, resource and handle listings or any other.
|
|
24
|
+
*/
|
|
25
|
+
export declare const SANDBOX_PROCESS: readonly string[];
|
|
26
|
+
/**
|
|
27
|
+
* The child's Node flags for its script `script`: the permission model allowing only reading that file, no SQLite, a
|
|
28
|
+
* 96 MiB heap. Exported for the tests of the operating system's layer alone.
|
|
29
|
+
*/
|
|
30
|
+
export declare function sandboxFlags(script: string): string[];
|
|
31
|
+
/** The bootstrap's file in the sandbox's directory: a script, not `-e`, which puts every builtin on `globalThis`. */
|
|
32
|
+
export declare const BOOTSTRAP_FILE = "bootstrap.cjs";
|
|
33
|
+
/** Throws unless this Node is 26.5.1 or later, the Node the sandbox's permissions were checked on. */
|
|
34
|
+
export declare function requireSandboxNode(version?: string): void;
|
|
35
|
+
/**
|
|
36
|
+
* The child's environment: empty, but for `LD_LIBRARY_PATH` when the launcher has one: the launcher needed it to run
|
|
37
|
+
* this same binary (a Node built against libraries outside the system's paths), and the server cannot influence it.
|
|
38
|
+
*/
|
|
39
|
+
export declare function sandboxEnvironment(): Record<string, string>;
|
|
40
|
+
/** A running sandbox: messages both ways, and its end. */
|
|
41
|
+
export declare class Sandbox {
|
|
42
|
+
#private;
|
|
43
|
+
/**
|
|
44
|
+
* Starts a sandbox running the base bundle `source` (a CommonJS script) with `start` on its bridge; `onMessage` gets
|
|
45
|
+
* what it sends, `onEnd` its end (an exit, a crash, its memory limit, a malformed frame), once.
|
|
46
|
+
*/
|
|
47
|
+
static start(source: string, start: BridgeStart, onMessage: (message: SandboxMessage) => void, onEnd: (reason: string) => void): Promise<Sandbox>;
|
|
48
|
+
private constructor();
|
|
49
|
+
/** Sends `message` to the sandbox; a sandbox not reading what it was sent is ended. */
|
|
50
|
+
post(message: LauncherMessage): void;
|
|
51
|
+
/** Ends the sandbox and waits for its exit. */
|
|
52
|
+
terminate(): Promise<void>;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=sandbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../../src/node/tui/sandbox.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGxF,qDAAqD;AACrD,eAAO,MAAM,UAAU,QAAkB,CAAC;AAE1C;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAsB7C,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,EAAE,SAAS,MAAM,EA+B5C,CAAC;AAEF;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAErD;AAED,qHAAqH;AACrH,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAK9C,sGAAsG;AACtG,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,MAA8B,GAAG,IAAI,CAIhF;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAG3D;AAED,0DAA0D;AAC1D,qBAAa,OAAO;;IAWnB;;;OAGG;IACH,OAAa,KAAK,CACjB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,WAAW,EAClB,SAAS,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,EAC5C,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC,OAAO,CAAC,CASlB;IAED,OAAO,eAyBN;IAED,uFAAuF;IACvF,IAAI,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,CAEnC;IAED,+CAA+C;IACzC,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAI/B;CAsCD"}
|
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
// The terminal's sandbox (slice 11 §4, decision "Slice 11, P8"; fix round 2: a child process, as the owner decided
|
|
2
|
+
// after the worker thread was escaped through its shared realm): a Node child process of the launcher's binary.
|
|
3
|
+
// - The operating system's side: its stdin, stdout and stderr are pipes to the launcher (never the terminal: no
|
|
4
|
+
// descriptor of the child is a TTY), its environment empty, its directory a private one holding only the bootstrap;
|
|
5
|
+
// Node's permission model with nothing allowed but reading the bootstrap (no other file read, no write, no network,
|
|
6
|
+
// no child processes, no workers, no addons, no inspector, no WASI) and `node:sqlite` removed
|
|
7
|
+
// (`--no-experimental-sqlite`: SQLite opens files past the permission model). An escape from the JavaScript layer
|
|
8
|
+
// reaches no terminal, no file, no socket, no launcher memory or token.
|
|
9
|
+
// - The JavaScript side, a second layer: downloaded code (the base bundle, a CommonJS script; the plugins' registered
|
|
10
|
+
// scripts) is only evaluated by the bootstrap (`vm.Script` with no dynamic import callback, so `import()` throws),
|
|
11
|
+
// with a `require` answering the allowed builtins only (`SANDBOX_BUILTINS`); `process` is a substitute with
|
|
12
|
+
// `SANDBOX_PROCESS` only. The bootstrap keeps its own references to what it uses before any downloaded code runs.
|
|
13
|
+
// Messages go both ways as length-prefixed binary frames (`pipe.ts`). Known gaps, each needing the JavaScript layer
|
|
14
|
+
// broken first unless noted: the child may signal processes of the same user (Node has no permission for signals; the
|
|
15
|
+
// launcher ignores SIGUSR1, which would open its inspector), read machine details (`os`), learn whether any path exists
|
|
16
|
+
// (`require.resolve` fails one way for a file that exists, another for one that does not: Opus E13), and allocate
|
|
17
|
+
// memory outside its heap (no limit without a shell's `ulimit`; only the child dies). Needs Node 26.5.1 or later.
|
|
18
|
+
import { spawn } from "node:child_process";
|
|
19
|
+
import { mkdtemp, realpath, rm, writeFile } from "node:fs/promises";
|
|
20
|
+
import { tmpdir } from "node:os";
|
|
21
|
+
import { join } from "node:path";
|
|
22
|
+
import { FrameReader, launcherFrame, MAX_PIPE_FRAME, startFrame } from "./pipe.js";
|
|
23
|
+
/** The largest base bundle a sandbox runs: 8 MiB. */
|
|
24
|
+
export const MAX_BUNDLE = 8 * 1024 * 1024;
|
|
25
|
+
/**
|
|
26
|
+
* The builtins code in the sandbox may `require`, each computation in memory without I/O, descriptors or machine
|
|
27
|
+
* details: bytes and text (`buffer`, `string_decoder`, `punycode`, `querystring`), events and streams in memory
|
|
28
|
+
* (`events`, `stream` and its submodules), formatting and type checks (`util`, `util/types`), URL and path strings
|
|
29
|
+
* (`url`, `path`), timers, assertions, hashing and randomness (`crypto`: no keys from files, no network) and compression
|
|
30
|
+
* in memory (`zlib`). Not `fs`, `tty`, `net`, `dgram`, `dns`, `http`, `https`, `http2`, `tls`, `child_process`,
|
|
31
|
+
* `cluster`, `worker_threads`, `sqlite`, `inspector`, `vm`, `v8`, `os`, `module`, `process`, `perf_hooks`, `wasi`,
|
|
32
|
+
* `repl`, `readline`, `trace_events` or anything else.
|
|
33
|
+
*/
|
|
34
|
+
export const SANDBOX_BUILTINS = [
|
|
35
|
+
"assert",
|
|
36
|
+
"assert/strict",
|
|
37
|
+
"buffer",
|
|
38
|
+
"crypto",
|
|
39
|
+
"events",
|
|
40
|
+
"path",
|
|
41
|
+
"path/posix",
|
|
42
|
+
"path/win32",
|
|
43
|
+
"punycode",
|
|
44
|
+
"querystring",
|
|
45
|
+
"stream",
|
|
46
|
+
"stream/consumers",
|
|
47
|
+
"stream/promises",
|
|
48
|
+
"stream/web",
|
|
49
|
+
"string_decoder",
|
|
50
|
+
"timers",
|
|
51
|
+
"timers/promises",
|
|
52
|
+
"url",
|
|
53
|
+
"util",
|
|
54
|
+
"util/types",
|
|
55
|
+
"zlib",
|
|
56
|
+
];
|
|
57
|
+
/**
|
|
58
|
+
* The sandbox's `process`: a frozen plain object in place of Node's (no event emitter, so no prototype shared with
|
|
59
|
+
* Node's internals leads back to the real one). Its properties, each harmless: which Node it is (`arch`, `platform`,
|
|
60
|
+
* `version`, `versions`, `release`), time (`nextTick`, `hrtime`, `uptime`), ending the sandbox (`exit`), the permission
|
|
61
|
+
* checks (`permission`), the allowed builtins (`getBuiltinModule`), fixed values (`env` empty, `argv`, `argv0`,
|
|
62
|
+
* `execArgv`, `execPath`, `title`, `cwd` `/`), `stdout` (to the terminal through the bridge) and `stderr` (dropped),
|
|
63
|
+
* and listener calls that keep nothing (`on`, `once`, `off`, `addListener`, `removeListener`, `removeAllListeners`,
|
|
64
|
+
* `emit`, `emitWarning`, `listenerCount`, `listeners`). Not `binding`, `_linkedBinding`, `dlopen`, `_rawDebug`, `kill`,
|
|
65
|
+
* `execve`, `chdir`, `abort`, `reallyExit`, `stdin`, `openStdin`, `report`, `pid`, `ppid`, `config`, the user and group
|
|
66
|
+
* calls, `loadEnvFile`, `moduleLoadList`, resource and handle listings or any other.
|
|
67
|
+
*/
|
|
68
|
+
export const SANDBOX_PROCESS = [
|
|
69
|
+
"addListener",
|
|
70
|
+
"arch",
|
|
71
|
+
"argv",
|
|
72
|
+
"argv0",
|
|
73
|
+
"cwd",
|
|
74
|
+
"emit",
|
|
75
|
+
"emitWarning",
|
|
76
|
+
"env",
|
|
77
|
+
"execArgv",
|
|
78
|
+
"execPath",
|
|
79
|
+
"exit",
|
|
80
|
+
"getBuiltinModule",
|
|
81
|
+
"hrtime",
|
|
82
|
+
"listenerCount",
|
|
83
|
+
"listeners",
|
|
84
|
+
"nextTick",
|
|
85
|
+
"off",
|
|
86
|
+
"on",
|
|
87
|
+
"once",
|
|
88
|
+
"permission",
|
|
89
|
+
"platform",
|
|
90
|
+
"release",
|
|
91
|
+
"removeAllListeners",
|
|
92
|
+
"removeListener",
|
|
93
|
+
"stderr",
|
|
94
|
+
"stdout",
|
|
95
|
+
"title",
|
|
96
|
+
"uptime",
|
|
97
|
+
"version",
|
|
98
|
+
"versions",
|
|
99
|
+
];
|
|
100
|
+
/**
|
|
101
|
+
* The child's Node flags for its script `script`: the permission model allowing only reading that file, no SQLite, a
|
|
102
|
+
* 96 MiB heap. Exported for the tests of the operating system's layer alone.
|
|
103
|
+
*/
|
|
104
|
+
export function sandboxFlags(script) {
|
|
105
|
+
return ["--permission", `--allow-fs-read=${script}`, "--no-experimental-sqlite", "--max-old-space-size=96", script];
|
|
106
|
+
}
|
|
107
|
+
/** The bootstrap's file in the sandbox's directory: a script, not `-e`, which puts every builtin on `globalThis`. */
|
|
108
|
+
export const BOOTSTRAP_FILE = "bootstrap.cjs";
|
|
109
|
+
/** The most bytes waiting for the sandbox to read them before it counts as stuck: 64 MiB. */
|
|
110
|
+
const MAX_UNREAD = 64 * 1024 * 1024;
|
|
111
|
+
/** Throws unless this Node is 26.5.1 or later, the Node the sandbox's permissions were checked on. */
|
|
112
|
+
export function requireSandboxNode(version = process.versions.node) {
|
|
113
|
+
const [major = 0, minor = 0, patch = 0] = version.split(".").map(Number);
|
|
114
|
+
if (major > 26 || (major === 26 && (minor > 5 || (minor === 5 && patch >= 1))))
|
|
115
|
+
return;
|
|
116
|
+
throw new Error(`the terminal client needs Node 26.5.1 or later for its sandbox (this is Node ${version})`);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* The child's environment: empty, but for `LD_LIBRARY_PATH` when the launcher has one: the launcher needed it to run
|
|
120
|
+
* this same binary (a Node built against libraries outside the system's paths), and the server cannot influence it.
|
|
121
|
+
*/
|
|
122
|
+
export function sandboxEnvironment() {
|
|
123
|
+
const libraries = process.env.LD_LIBRARY_PATH;
|
|
124
|
+
return libraries === undefined ? {} : { LD_LIBRARY_PATH: libraries };
|
|
125
|
+
}
|
|
126
|
+
/** A running sandbox: messages both ways, and its end. */
|
|
127
|
+
export class Sandbox {
|
|
128
|
+
#child;
|
|
129
|
+
#directory;
|
|
130
|
+
#onMessage;
|
|
131
|
+
#onEnd;
|
|
132
|
+
#reader = new FrameReader();
|
|
133
|
+
#exited;
|
|
134
|
+
#ended = false;
|
|
135
|
+
/** Whether the child has sent anything: its bootstrap was read, so the file goes. */
|
|
136
|
+
#running = false;
|
|
137
|
+
/**
|
|
138
|
+
* Starts a sandbox running the base bundle `source` (a CommonJS script) with `start` on its bridge; `onMessage` gets
|
|
139
|
+
* what it sends, `onEnd` its end (an exit, a crash, its memory limit, a malformed frame), once.
|
|
140
|
+
*/
|
|
141
|
+
static async start(source, start, onMessage, onEnd) {
|
|
142
|
+
requireSandboxNode();
|
|
143
|
+
if (Buffer.byteLength(source) > MAX_BUNDLE)
|
|
144
|
+
throw new Error("terminal: the base bundle exceeds 8 MiB");
|
|
145
|
+
// Node resolves its entry before reading it; a symlinked ancestor would need a broader file grant.
|
|
146
|
+
const directory = await realpath(await mkdtemp(join(tmpdir(), "chord-tui-")));
|
|
147
|
+
await writeFile(join(directory, BOOTSTRAP_FILE), BOOTSTRAP);
|
|
148
|
+
const sandbox = new Sandbox(directory, onMessage, onEnd);
|
|
149
|
+
sandbox.#write(startFrame(start, source));
|
|
150
|
+
return sandbox;
|
|
151
|
+
}
|
|
152
|
+
constructor(directory, onMessage, onEnd) {
|
|
153
|
+
this.#directory = directory;
|
|
154
|
+
this.#onMessage = onMessage;
|
|
155
|
+
this.#onEnd = onEnd;
|
|
156
|
+
this.#child = spawn(process.execPath, sandboxFlags(join(directory, BOOTSTRAP_FILE)), {
|
|
157
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
158
|
+
env: sandboxEnvironment(),
|
|
159
|
+
cwd: directory,
|
|
160
|
+
windowsHide: true,
|
|
161
|
+
});
|
|
162
|
+
this.#exited = new Promise((resolve) => this.#child.once("close", () => resolve()));
|
|
163
|
+
this.#child.stdout.on("data", (chunk) => this.#read(chunk));
|
|
164
|
+
// Dropped: the sandbox writes only through the bridge, and the terminal is the launcher's.
|
|
165
|
+
this.#child.stderr.resume();
|
|
166
|
+
// A write after the child ended fails here; its end is reported by `close`.
|
|
167
|
+
this.#child.stdin.on("error", () => { });
|
|
168
|
+
this.#child.on("error", (error) => this.#end(`the terminal client failed: ${error.message}`));
|
|
169
|
+
this.#child.on("close", () => {
|
|
170
|
+
this.#end("the terminal client exited");
|
|
171
|
+
void rm(this.#directory, { recursive: true, force: true });
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
/** Sends `message` to the sandbox; a sandbox not reading what it was sent is ended. */
|
|
175
|
+
post(message) {
|
|
176
|
+
if (!this.#ended)
|
|
177
|
+
this.#write(launcherFrame(message));
|
|
178
|
+
}
|
|
179
|
+
/** Ends the sandbox and waits for its exit. */
|
|
180
|
+
async terminate() {
|
|
181
|
+
this.#ended = true;
|
|
182
|
+
this.#child.kill("SIGKILL");
|
|
183
|
+
await this.#exited;
|
|
184
|
+
}
|
|
185
|
+
#write(frame) {
|
|
186
|
+
if (this.#child.stdin.writableLength + frame.length > MAX_UNREAD + MAX_PIPE_FRAME) {
|
|
187
|
+
this.#fail("the terminal client stopped reading");
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
this.#child.stdin.write(frame);
|
|
191
|
+
}
|
|
192
|
+
/** The sandbox's output: its messages, each passed on; a malformed one ends the sandbox. */
|
|
193
|
+
#read(chunk) {
|
|
194
|
+
if (this.#ended)
|
|
195
|
+
return;
|
|
196
|
+
if (!this.#running) {
|
|
197
|
+
this.#running = true;
|
|
198
|
+
// Read once at the start; a launcher killed later leaves at most an empty directory.
|
|
199
|
+
void rm(join(this.#directory, BOOTSTRAP_FILE), { force: true });
|
|
200
|
+
}
|
|
201
|
+
let messages;
|
|
202
|
+
try {
|
|
203
|
+
messages = this.#reader.push(chunk);
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
this.#fail(error.message);
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
for (const message of messages)
|
|
210
|
+
if (!this.#ended)
|
|
211
|
+
this.#onMessage(message);
|
|
212
|
+
}
|
|
213
|
+
#fail(reason) {
|
|
214
|
+
this.#child.kill("SIGKILL");
|
|
215
|
+
this.#end(reason);
|
|
216
|
+
}
|
|
217
|
+
#end(reason) {
|
|
218
|
+
if (this.#ended)
|
|
219
|
+
return;
|
|
220
|
+
this.#ended = true;
|
|
221
|
+
this.#onEnd(reason);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* The trusted bootstrap (strict CommonJS, the child's main script). Before any downloaded code runs it keeps its own
|
|
226
|
+
* references to what it uses (so code that changes shared prototypes later cannot steer it), closes the file system's
|
|
227
|
+
* functions, shadows the real `process`'s listener calls, puts the substitute `process` in place, removes the module
|
|
228
|
+
* globals and leaves the bridge on `globalThis`; then it waits for the launcher's start frame and evaluates the base
|
|
229
|
+
* bundle through its own `require`. Frames as in `pipe.ts`.
|
|
230
|
+
*/
|
|
231
|
+
const BOOTSTRAP = `"use strict";
|
|
232
|
+
const real = process;
|
|
233
|
+
const getBuiltin = real.getBuiltinModule;
|
|
234
|
+
const apply = Reflect.apply;
|
|
235
|
+
const uncurry = Function.prototype.call.bind(Function.prototype.bind, Function.prototype.call);
|
|
236
|
+
const parse = JSON.parse;
|
|
237
|
+
const stringify = JSON.stringify;
|
|
238
|
+
const freeze = Object.freeze;
|
|
239
|
+
const define = Object.defineProperty;
|
|
240
|
+
const BufferFrom = Buffer.from;
|
|
241
|
+
const BufferAlloc = Buffer.allocUnsafe;
|
|
242
|
+
const BufferConcat = Buffer.concat;
|
|
243
|
+
const readUInt32BE = uncurry(Buffer.prototype.readUInt32BE);
|
|
244
|
+
const writeUInt32BE = uncurry(Buffer.prototype.writeUInt32BE);
|
|
245
|
+
const bufferText = uncurry(Buffer.prototype.toString);
|
|
246
|
+
const subarray = uncurry(Buffer.prototype.subarray);
|
|
247
|
+
const copyBytes = uncurry(Buffer.prototype.copy);
|
|
248
|
+
const isUint8Array = (value) => value instanceof Uint8Array;
|
|
249
|
+
const builtin0 = (id) => apply(getBuiltin, real, [id]);
|
|
250
|
+
const Script = builtin0("node:vm").Script;
|
|
251
|
+
const runInThisContext = uncurry(Script.prototype.runInThisContext);
|
|
252
|
+
const nextTick = real.nextTick;
|
|
253
|
+
const hrtime = real.hrtime;
|
|
254
|
+
const hrtimeBigint = real.hrtime.bigint;
|
|
255
|
+
const uptime = real.uptime;
|
|
256
|
+
const exit = real.exit;
|
|
257
|
+
const input = real.stdin;
|
|
258
|
+
const output = real.stdout;
|
|
259
|
+
const writeOutput = uncurry(output.write);
|
|
260
|
+
const onInput = uncurry(input.on);
|
|
261
|
+
const MAX_FRAME = ${MAX_PIPE_FRAME};
|
|
262
|
+
const deny = () => {
|
|
263
|
+
throw new Error("unavailable in the terminal's sandbox");
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
// The file system's functions closed: the permission model guards paths, not the pipes' descriptors.
|
|
267
|
+
for (const facade of [builtin0("node:fs"), builtin0("node:fs/promises")]) {
|
|
268
|
+
for (const name of Object.keys(facade)) {
|
|
269
|
+
if (typeof facade[name] === "function") define(facade, name, { value: deny, writable: false, configurable: false, enumerable: true });
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
const v8 = builtin0("node:v8");
|
|
273
|
+
for (const name of ["writeHeapSnapshot", "getHeapSnapshot", "queryObjects", "setFlagsFromString", "takeCoverage", "startCpuProfile", "startHeapProfile"]) {
|
|
274
|
+
if (typeof v8[name] === "function") v8[name] = deny;
|
|
275
|
+
}
|
|
276
|
+
builtin0("node:module").syncBuiltinESMExports();
|
|
277
|
+
// Node emits on its own process (warnings among them): its listener calls are its own properties, not the shared
|
|
278
|
+
// prototype's, which downloaded code may change.
|
|
279
|
+
const emitter = builtin0("node:events").EventEmitter.prototype;
|
|
280
|
+
for (const name of Object.getOwnPropertyNames(emitter)) {
|
|
281
|
+
if (name !== "constructor" && typeof emitter[name] === "function") define(real, name, { value: emitter[name], writable: false, configurable: false });
|
|
282
|
+
}
|
|
283
|
+
// Node reads properties its process does not have (noDeprecation, throwDeprecation, traceDeprecation,
|
|
284
|
+
// traceProcessWarnings, channel, connected, …): such a read goes up the prototype chain, where a getter would get the
|
|
285
|
+
// real process as its this (Opus E7: Buffer(1) warns, and the warning reads process.noDeprecation). Every prototype of
|
|
286
|
+
// the chain, Object.prototype included, takes no new property and keeps its own ones, so no getter and no other
|
|
287
|
+
// prototype gets in. Not frozen: Node assigns over prototype fields (\`this._events ??= {}\`).
|
|
288
|
+
for (let prototype = Object.getPrototypeOf(real); prototype !== null; prototype = Object.getPrototypeOf(prototype)) {
|
|
289
|
+
for (const key of Reflect.ownKeys(prototype)) define(prototype, key, { configurable: false });
|
|
290
|
+
Object.preventExtensions(prototype);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// The allowed builtins, by name with or without "node:"; looked up in an object of no prototype.
|
|
294
|
+
const allowed = Object.create(null);
|
|
295
|
+
for (const name of ${JSON.stringify(SANDBOX_BUILTINS)}) allowed[name] = true;
|
|
296
|
+
const builtin = (id) => {
|
|
297
|
+
if (typeof id !== "string") throw new Error("unavailable in the terminal's sandbox");
|
|
298
|
+
const name = id.length > 5 && id[0] === "n" && id[1] === "o" && id[2] === "d" && id[3] === "e" && id[4] === ":" ? id.slice(5) : id;
|
|
299
|
+
if (typeof name !== "string" || allowed[name] !== true) throw new Error(id + ": unavailable in the terminal's sandbox");
|
|
300
|
+
return builtin0("node:" + name);
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
// Frames out: the message's header as JSON, its write text or socket bytes as the body.
|
|
304
|
+
const send = (message) => {
|
|
305
|
+
const kind = message.kind;
|
|
306
|
+
let header;
|
|
307
|
+
let body;
|
|
308
|
+
if (kind === "write") {
|
|
309
|
+
const data = String(message.data);
|
|
310
|
+
// Refused before it is copied: a huge string costs no buffer of its size.
|
|
311
|
+
if (data.length > MAX_FRAME) throw new RangeError("the terminal's bridge takes frames of at most 17 MiB");
|
|
312
|
+
header = { kind };
|
|
313
|
+
body = BufferFrom(data);
|
|
314
|
+
} else if (kind === "socket_send") {
|
|
315
|
+
if (!isUint8Array(message.bytes)) throw new TypeError("socket_send: bytes expected");
|
|
316
|
+
header = { kind, socket: message.socket };
|
|
317
|
+
body = message.bytes;
|
|
318
|
+
} else {
|
|
319
|
+
header = message;
|
|
320
|
+
}
|
|
321
|
+
const json = BufferFrom(stringify(header));
|
|
322
|
+
const length = 4 + json.length + (body === undefined ? 0 : body.length);
|
|
323
|
+
if (length > MAX_FRAME) throw new RangeError("the terminal's bridge takes frames of at most 17 MiB");
|
|
324
|
+
const prefix = BufferAlloc(8);
|
|
325
|
+
writeUInt32BE(prefix, length, 0);
|
|
326
|
+
writeUInt32BE(prefix, json.length, 4);
|
|
327
|
+
writeOutput(output, BufferConcat(body === undefined ? [prefix, json] : [prefix, json, body]));
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
// The substitute process.
|
|
331
|
+
const stdout = freeze({ isTTY: false, write: (data) => (send({ kind: "write", data: String(data) }), true) });
|
|
332
|
+
const listening = (name) => [name, function () { return fake; }];
|
|
333
|
+
const fake = freeze({
|
|
334
|
+
arch: real.arch,
|
|
335
|
+
platform: real.platform,
|
|
336
|
+
version: real.version,
|
|
337
|
+
versions: freeze({ ...real.versions }),
|
|
338
|
+
release: freeze({ ...real.release }),
|
|
339
|
+
nextTick: (...args) => apply(nextTick, real, args),
|
|
340
|
+
hrtime: Object.assign((...args) => apply(hrtime, real, args), { bigint: () => apply(hrtimeBigint, real, []) }),
|
|
341
|
+
uptime: () => apply(uptime, real, []),
|
|
342
|
+
exit: (code) => apply(exit, real, [code]),
|
|
343
|
+
permission: real.permission,
|
|
344
|
+
env: freeze({}),
|
|
345
|
+
argv: freeze(["node"]),
|
|
346
|
+
argv0: "node",
|
|
347
|
+
execArgv: freeze([]),
|
|
348
|
+
execPath: "node",
|
|
349
|
+
title: "node",
|
|
350
|
+
cwd: () => "/",
|
|
351
|
+
getBuiltinModule: builtin,
|
|
352
|
+
stdout,
|
|
353
|
+
stderr: freeze({ isTTY: false, write: () => true }),
|
|
354
|
+
...Object.fromEntries(["on", "once", "off", "addListener", "removeListener", "removeAllListeners"].map(listening)),
|
|
355
|
+
emit: () => false,
|
|
356
|
+
emitWarning: () => {},
|
|
357
|
+
listenerCount: () => 0,
|
|
358
|
+
listeners: () => [],
|
|
359
|
+
});
|
|
360
|
+
define(globalThis, "process", { value: fake, writable: false, configurable: false, enumerable: false });
|
|
361
|
+
for (const name of ["BroadcastChannel", "localStorage", "sessionStorage"]) delete globalThis[name];
|
|
362
|
+
|
|
363
|
+
// Downloaded code runs only through here, with options of no prototype (nothing read from Object.prototype).
|
|
364
|
+
const evaluate = (text, filename) => {
|
|
365
|
+
const options = Object.create(null);
|
|
366
|
+
options.filename = String(filename);
|
|
367
|
+
return runInThisContext(new Script(String(text), options));
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
// Frames in: the first is the start (the bridge's start and the base bundle), the rest the launcher's messages.
|
|
371
|
+
let listener;
|
|
372
|
+
let started = false;
|
|
373
|
+
// Unread bytes: one buffer, grown by doubling, each byte copied in once.
|
|
374
|
+
let pending = BufferAlloc(64 * 1024);
|
|
375
|
+
let start = 0;
|
|
376
|
+
let end = 0;
|
|
377
|
+
const received = (payload) => {
|
|
378
|
+
const headerLength = readUInt32BE(payload, 0);
|
|
379
|
+
const header = parse(bufferText(payload, "utf8", 4, 4 + headerLength));
|
|
380
|
+
const body = subarray(payload, 4 + headerLength);
|
|
381
|
+
if (!started) {
|
|
382
|
+
started = true;
|
|
383
|
+
run(header.start, bufferText(body, "utf8"));
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
if (header.kind === "input") header.data = bufferText(body, "utf8");
|
|
387
|
+
else if (header.kind === "socket_message" || header.kind === "attached") header.bytes = new Uint8Array(body);
|
|
388
|
+
if (listener !== undefined) listener(header);
|
|
389
|
+
};
|
|
390
|
+
onInput(input, "data", (chunk) => {
|
|
391
|
+
if (end + chunk.length > pending.length) {
|
|
392
|
+
const unread = end - start;
|
|
393
|
+
const target = unread + chunk.length <= pending.length ? pending : BufferAlloc(Math.max(unread + chunk.length, pending.length * 2));
|
|
394
|
+
copyBytes(pending, target, 0, start, end);
|
|
395
|
+
pending = target;
|
|
396
|
+
start = 0;
|
|
397
|
+
end = unread;
|
|
398
|
+
}
|
|
399
|
+
copyBytes(chunk, pending, end);
|
|
400
|
+
end += chunk.length;
|
|
401
|
+
while (end - start >= 4) {
|
|
402
|
+
const length = readUInt32BE(pending, start);
|
|
403
|
+
if (length > MAX_FRAME) apply(exit, real, [70]);
|
|
404
|
+
if (end - start < 4 + length) break;
|
|
405
|
+
// A copy: the buffer is reused, and what the frame carries is kept by the sandbox.
|
|
406
|
+
const payload = BufferAlloc(length);
|
|
407
|
+
copyBytes(pending, payload, 0, start + 4, start + 4 + length);
|
|
408
|
+
start += 4 + length;
|
|
409
|
+
received(payload);
|
|
410
|
+
}
|
|
411
|
+
if (start === end) start = end = 0;
|
|
412
|
+
});
|
|
413
|
+
onInput(input, "end", () => apply(exit, real, [0]));
|
|
414
|
+
const run = (start, source) => {
|
|
415
|
+
globalThis.chordBridge = freeze({
|
|
416
|
+
start: freeze(start),
|
|
417
|
+
send,
|
|
418
|
+
onMessage: (next) => {
|
|
419
|
+
listener = next;
|
|
420
|
+
},
|
|
421
|
+
evaluate,
|
|
422
|
+
});
|
|
423
|
+
try {
|
|
424
|
+
const base = { exports: {} };
|
|
425
|
+
evaluate("(function (require, module, exports) {" + source + "\\n})", "chord-base.js")(builtin, base, base.exports);
|
|
426
|
+
} catch (error) {
|
|
427
|
+
send({ kind: "failed", message: String(error && error.message) });
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
`;
|
|
431
|
+
//# sourceMappingURL=sandbox.js.map
|