@dreamlake/dreamlake-cli 0.88.1 → 0.90.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/access.d.ts +83 -0
- package/dist/api/access.js +77 -0
- package/dist/api/agent.d.ts +156 -0
- package/dist/api/agent.js +111 -0
- package/dist/api/browser.d.ts +90 -0
- package/dist/api/browser.js +102 -0
- package/dist/api/client.d.ts +54 -0
- package/dist/api/client.js +102 -0
- package/dist/api/common.d.ts +28 -0
- package/dist/api/common.js +16 -0
- package/dist/api/content.d.ts +195 -0
- package/dist/api/content.js +147 -0
- package/dist/api/execution.d.ts +84 -0
- package/dist/api/execution.js +73 -0
- package/dist/api/http.d.ts +19 -0
- package/dist/api/http.js +66 -0
- package/dist/api/index.d.ts +2362 -0
- package/dist/api/index.js +116 -0
- package/dist/api/infra.d.ts +2 -0
- package/dist/api/infra.js +2 -0
- package/dist/api/jobs.d.ts +2 -0
- package/dist/api/jobs.js +2 -0
- package/dist/api/layout.d.ts +2 -0
- package/dist/api/layout.js +2 -0
- package/dist/api/library-edit.d.ts +3 -0
- package/dist/api/library-edit.js +3 -0
- package/dist/api/library-manifest.d.ts +2 -0
- package/dist/api/library-manifest.js +2 -0
- package/dist/api/note-character-plan.d.ts +2 -0
- package/dist/api/note-character-plan.js +2 -0
- package/dist/api/note-editing.d.ts +2 -0
- package/dist/api/note-editing.js +2 -0
- package/dist/api/note-edits.d.ts +21 -0
- package/dist/api/note-edits.js +10 -0
- package/dist/api/note-events.d.ts +5 -0
- package/dist/api/note-events.js +11 -0
- package/dist/api/note-files.d.ts +102 -0
- package/dist/api/note-files.js +107 -0
- package/dist/api/note-html-read.d.ts +2 -0
- package/dist/api/note-html-read.js +2 -0
- package/dist/api/note-html.d.ts +2 -0
- package/dist/api/note-html.js +2 -0
- package/dist/api/note-linger.d.ts +83 -0
- package/dist/api/note-linger.js +270 -0
- package/dist/api/note-presence.d.ts +82 -0
- package/dist/api/note-presence.js +72 -0
- package/dist/api/note-toc.d.ts +2 -0
- package/dist/api/note-toc.js +2 -0
- package/dist/api/notes.d.ts +329 -0
- package/dist/api/notes.js +209 -0
- package/dist/api/open-resources.d.ts +27 -0
- package/dist/api/open-resources.js +102 -0
- package/dist/api/ownership.d.ts +12 -0
- package/dist/api/ownership.js +24 -0
- package/dist/api/platform.d.ts +83 -0
- package/dist/api/platform.js +56 -0
- package/dist/api/presigned-transfer.d.ts +2 -0
- package/dist/api/presigned-transfer.js +2 -0
- package/dist/api/registered-runs.d.ts +48 -0
- package/dist/api/registered-runs.js +33 -0
- package/dist/api/sessions.d.ts +299 -0
- package/dist/api/sessions.js +105 -0
- package/dist/api/storage.d.ts +46 -0
- package/dist/api/storage.js +34 -0
- package/dist/api/streams.d.ts +18 -0
- package/dist/api/streams.js +70 -0
- package/dist/api/vault.d.ts +93 -0
- package/dist/api/vault.js +79 -0
- package/dist/api/workspace.d.ts +180 -0
- package/dist/api/workspace.js +146 -0
- package/dist/cli/agent-identity.d.ts +4 -0
- package/dist/cli/agent-identity.js +21 -0
- package/dist/cli/agents/identity.d.ts +50 -0
- package/dist/cli/agents/identity.js +105 -0
- package/dist/cli/agents/index.d.ts +31 -0
- package/dist/cli/agents/index.js +580 -0
- package/dist/cli/agents/manage.d.ts +43 -0
- package/dist/cli/agents/manage.js +376 -0
- package/dist/cli/agents/spec.d.ts +104 -0
- package/dist/cli/agents/spec.js +280 -0
- package/dist/cli/agents/web.d.ts +7 -0
- package/dist/cli/agents/web.js +109 -0
- package/dist/cli/artifact/incremental.d.ts +21 -0
- package/dist/cli/artifact/incremental.js +80 -0
- package/dist/cli/artifact/index.d.ts +52 -0
- package/dist/cli/artifact/index.js +405 -0
- package/dist/cli/artifact/meta.d.ts +69 -0
- package/dist/cli/artifact/meta.js +189 -0
- package/dist/cli/auth/commands.d.ts +29 -0
- package/dist/cli/auth/commands.js +327 -0
- package/dist/cli/auth/constants.d.ts +13 -0
- package/dist/cli/auth/constants.js +18 -0
- package/dist/cli/auth/credentials.d.ts +37 -0
- package/dist/cli/auth/credentials.js +155 -0
- package/dist/cli/auth/device-flow.d.ts +32 -0
- package/dist/cli/auth/device-flow.js +154 -0
- package/dist/cli/auth/device-secret.d.ts +6 -0
- package/dist/cli/auth/device-secret.js +26 -0
- package/dist/cli/auth/machine.d.ts +15 -0
- package/dist/cli/auth/machine.js +126 -0
- package/dist/cli/auth/materialized.d.ts +32 -0
- package/dist/cli/auth/materialized.js +102 -0
- package/dist/cli/auth/migrate.d.ts +10 -0
- package/dist/cli/auth/migrate.js +75 -0
- package/dist/cli/client.d.ts +102 -0
- package/dist/cli/client.js +206 -0
- package/dist/cli/collection-list.d.ts +3 -0
- package/dist/cli/collection-list.js +25 -0
- package/dist/cli/compat/ctx.d.ts +26 -0
- package/dist/cli/compat/ctx.js +76 -0
- package/dist/cli/compat/dreamdb-wasm-embedded.d.ts +2 -0
- package/dist/cli/compat/dreamdb-wasm-embedded.js +8 -0
- package/dist/cli/compat/dreamdb-wasm.d.ts +1 -0
- package/dist/cli/compat/dreamdb-wasm.js +26 -0
- package/dist/cli/compat/dreamdb.d.ts +112 -0
- package/dist/cli/compat/dreamdb.js +219 -0
- package/dist/cli/compat/flags.d.ts +2 -0
- package/dist/cli/compat/flags.js +13 -0
- package/dist/cli/compat/http.d.ts +23 -0
- package/dist/cli/compat/http.js +137 -0
- package/dist/cli/compat/presignedTransfer.d.ts +139 -0
- package/dist/cli/compat/presignedTransfer.js +580 -0
- package/dist/cli/compat/s3-backend.d.ts +73 -0
- package/dist/cli/compat/s3-backend.js +132 -0
- package/dist/cli/config.d.ts +22 -0
- package/dist/cli/config.js +96 -0
- package/dist/cli/connection/dto.d.ts +159 -0
- package/dist/cli/connection/dto.js +497 -0
- package/dist/cli/connection/index.d.ts +50 -0
- package/dist/cli/connection/index.js +413 -0
- package/dist/cli/connection/oauth.d.ts +23 -0
- package/dist/cli/connection/oauth.js +290 -0
- package/dist/cli/connection/write.d.ts +47 -0
- package/dist/cli/connection/write.js +573 -0
- package/dist/cli/create/index.d.ts +19 -0
- package/dist/cli/create/index.js +209 -0
- package/dist/cli/declare/index.d.ts +29 -0
- package/dist/cli/declare/index.js +304 -0
- package/dist/cli/delete/index.d.ts +18 -0
- package/dist/cli/delete/index.js +232 -0
- package/dist/cli/download/index.d.ts +9 -0
- package/dist/cli/download/index.js +128 -0
- package/dist/cli/env/compose.d.ts +88 -0
- package/dist/cli/env/compose.js +402 -0
- package/dist/cli/env/index.d.ts +176 -0
- package/dist/cli/env/index.js +1011 -0
- package/dist/cli/experiments/index.d.ts +11 -0
- package/dist/cli/experiments/index.js +168 -0
- package/dist/cli/glob.d.ts +1 -0
- package/dist/cli/glob.js +45 -0
- package/dist/cli/graphql-helpers.d.ts +23 -0
- package/dist/cli/graphql-helpers.js +42 -0
- package/dist/cli/graphql.d.ts +10 -0
- package/dist/cli/graphql.js +47 -0
- package/dist/cli/help-examples.generated.d.ts +1 -0
- package/dist/cli/help-examples.generated.js +192 -0
- package/dist/cli/helpers.d.ts +8 -0
- package/dist/cli/helpers.js +106 -0
- package/dist/cli/hosts/api.d.ts +29 -0
- package/dist/cli/hosts/api.js +54 -0
- package/dist/cli/hosts/bootstrap-source.d.ts +1 -0
- package/dist/cli/hosts/bootstrap-source.js +2 -0
- package/dist/cli/hosts/catalog.d.ts +26 -0
- package/dist/cli/hosts/catalog.js +55 -0
- package/dist/cli/hosts/config.d.ts +45 -0
- package/dist/cli/hosts/config.js +179 -0
- package/dist/cli/hosts/credentials.d.ts +19 -0
- package/dist/cli/hosts/credentials.js +173 -0
- package/dist/cli/hosts/enroll.d.ts +17 -0
- package/dist/cli/hosts/enroll.js +109 -0
- package/dist/cli/hosts/enrollments.d.ts +25 -0
- package/dist/cli/hosts/enrollments.js +54 -0
- package/dist/cli/hosts/index.d.ts +6 -0
- package/dist/cli/hosts/index.js +279 -0
- package/dist/cli/hosts/inventory.d.ts +40 -0
- package/dist/cli/hosts/inventory.js +91 -0
- package/dist/cli/hosts/lifecycle.d.ts +15 -0
- package/dist/cli/hosts/lifecycle.js +108 -0
- package/dist/cli/hosts/metrics-source.d.ts +12 -0
- package/dist/cli/hosts/metrics-source.js +89 -0
- package/dist/cli/hosts/observations.d.ts +39 -0
- package/dist/cli/hosts/observations.js +102 -0
- package/dist/cli/hosts/remote.d.ts +5 -0
- package/dist/cli/hosts/remote.js +66 -0
- package/dist/cli/hosts/ssh.d.ts +63 -0
- package/dist/cli/hosts/ssh.js +276 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +288 -0
- package/dist/cli/infra/api.d.ts +95 -0
- package/dist/cli/infra/api.js +291 -0
- package/dist/cli/infra/index.d.ts +5 -0
- package/dist/cli/infra/index.js +102 -0
- package/dist/cli/infra/move.d.ts +15 -0
- package/dist/cli/infra/move.js +123 -0
- package/dist/cli/infra/transfer.d.ts +15 -0
- package/dist/cli/infra/transfer.js +280 -0
- package/dist/cli/jobs/api.d.ts +69 -0
- package/dist/cli/jobs/api.js +121 -0
- package/dist/cli/jobs/index.d.ts +5 -0
- package/dist/cli/jobs/index.js +140 -0
- package/dist/cli/lakeshore/index.d.ts +98 -0
- package/dist/cli/lakeshore/index.js +502 -0
- package/dist/cli/launch/index.d.ts +43 -0
- package/dist/cli/launch/index.js +270 -0
- package/dist/cli/layout/index.d.ts +2 -0
- package/dist/cli/layout/index.js +44 -0
- package/dist/cli/layout/transport.d.ts +12 -0
- package/dist/cli/layout/transport.js +70 -0
- package/dist/cli/library/add.d.ts +60 -0
- package/dist/cli/library/add.js +348 -0
- package/dist/cli/library/cache.d.ts +26 -0
- package/dist/cli/library/cache.js +88 -0
- package/dist/cli/library/config.d.ts +75 -0
- package/dist/cli/library/config.js +198 -0
- package/dist/cli/library/digest.d.ts +5 -0
- package/dist/cli/library/digest.js +19 -0
- package/dist/cli/library/discover.d.ts +87 -0
- package/dist/cli/library/discover.js +534 -0
- package/dist/cli/library/freshness.d.ts +35 -0
- package/dist/cli/library/freshness.js +109 -0
- package/dist/cli/library/generation.d.ts +35 -0
- package/dist/cli/library/generation.js +211 -0
- package/dist/cli/library/index.d.ts +2 -0
- package/dist/cli/library/index.js +36 -0
- package/dist/cli/library/info.d.ts +69 -0
- package/dist/cli/library/info.js +311 -0
- package/dist/cli/library/list.d.ts +33 -0
- package/dist/cli/library/list.js +86 -0
- package/dist/cli/library/manifest.d.ts +81 -0
- package/dist/cli/library/manifest.js +200 -0
- package/dist/cli/library/manifestCache.d.ts +45 -0
- package/dist/cli/library/manifestCache.js +169 -0
- package/dist/cli/library/pull.d.ts +30 -0
- package/dist/cli/library/pull.js +438 -0
- package/dist/cli/library/push.d.ts +72 -0
- package/dist/cli/library/push.js +642 -0
- package/dist/cli/library/rm.d.ts +31 -0
- package/dist/cli/library/rm.js +200 -0
- package/dist/cli/library/search.d.ts +18 -0
- package/dist/cli/library/search.js +181 -0
- package/dist/cli/library/stat.d.ts +15 -0
- package/dist/cli/library/stat.js +127 -0
- package/dist/cli/library/tools.d.ts +104 -0
- package/dist/cli/library/tools.js +163 -0
- package/dist/cli/library/wire.d.ts +47 -0
- package/dist/cli/library/wire.js +120 -0
- package/dist/cli/list/index.d.ts +26 -0
- package/dist/cli/list/index.js +256 -0
- package/dist/cli/notes/api-transport.d.ts +5 -0
- package/dist/cli/notes/api-transport.js +20 -0
- package/dist/cli/notes/character-plan.d.ts +22 -0
- package/dist/cli/notes/character-plan.js +232 -0
- package/dist/cli/notes/document.d.ts +73 -0
- package/dist/cli/notes/document.js +306 -0
- package/dist/cli/notes/edit-commands.d.ts +106 -0
- package/dist/cli/notes/edit-commands.js +623 -0
- package/dist/cli/notes/editing.d.ts +81 -0
- package/dist/cli/notes/editing.js +305 -0
- package/dist/cli/notes/events.d.ts +36 -0
- package/dist/cli/notes/events.js +54 -0
- package/dist/cli/notes/files-commands.d.ts +97 -0
- package/dist/cli/notes/files-commands.js +548 -0
- package/dist/cli/notes/html-read.d.ts +9 -0
- package/dist/cli/notes/html-read.js +90 -0
- package/dist/cli/notes/html.d.ts +73 -0
- package/dist/cli/notes/html.js +381 -0
- package/dist/cli/notes/index.d.ts +123 -0
- package/dist/cli/notes/index.js +1300 -0
- package/dist/cli/notes/linger.d.ts +4 -0
- package/dist/cli/notes/linger.js +96 -0
- package/dist/cli/notes/media-commands.d.ts +5 -0
- package/dist/cli/notes/media-commands.js +51 -0
- package/dist/cli/notes/move-command.d.ts +83 -0
- package/dist/cli/notes/move-command.js +259 -0
- package/dist/cli/notes/rm-command.d.ts +22 -0
- package/dist/cli/notes/rm-command.js +110 -0
- package/dist/cli/notes/select-command.d.ts +12 -0
- package/dist/cli/notes/select-command.js +63 -0
- package/dist/cli/notes/suggest-diff.d.ts +56 -0
- package/dist/cli/notes/suggest-diff.js +311 -0
- package/dist/cli/notes/toc.d.ts +38 -0
- package/dist/cli/notes/toc.js +144 -0
- package/dist/cli/notes/transfer-command.d.ts +6 -0
- package/dist/cli/notes/transfer-command.js +9 -0
- package/dist/cli/notes/version-commands.d.ts +19 -0
- package/dist/cli/notes/version-commands.js +178 -0
- package/dist/cli/nymph/index.d.ts +74 -0
- package/dist/cli/nymph/index.js +349 -0
- package/dist/cli/org/index.d.ts +34 -0
- package/dist/cli/org/index.js +341 -0
- package/dist/cli/ownership/index.d.ts +12 -0
- package/dist/cli/ownership/index.js +122 -0
- package/dist/cli/ownership/metadata-transfer.d.ts +20 -0
- package/dist/cli/ownership/metadata-transfer.js +159 -0
- package/dist/cli/page/index.d.ts +58 -0
- package/dist/cli/page/index.js +387 -0
- package/dist/cli/pipeline/index.d.ts +69 -0
- package/dist/cli/pipeline/index.js +604 -0
- package/dist/cli/progress.d.ts +60 -0
- package/dist/cli/progress.js +276 -0
- package/dist/cli/project/attachments.d.ts +10 -0
- package/dist/cli/project/attachments.js +39 -0
- package/dist/cli/project/grants.d.ts +10 -0
- package/dist/cli/project/grants.js +39 -0
- package/dist/cli/project/index.d.ts +8 -0
- package/dist/cli/project/index.js +92 -0
- package/dist/cli/project/move.d.ts +57 -0
- package/dist/cli/project/move.js +242 -0
- package/dist/cli/project/output.d.ts +2 -0
- package/dist/cli/project/output.js +29 -0
- package/dist/cli/project/stream.d.ts +55 -0
- package/dist/cli/project/stream.js +207 -0
- package/dist/cli/project/transfer-preview.d.ts +8 -0
- package/dist/cli/project/transfer-preview.js +10 -0
- package/dist/cli/prompt.d.ts +1 -0
- package/dist/cli/prompt.js +17 -0
- package/dist/cli/provider/dreamdir.d.ts +52 -0
- package/dist/cli/provider/dreamdir.js +138 -0
- package/dist/cli/provider/index.d.ts +4 -0
- package/dist/cli/provider/index.js +419 -0
- package/dist/cli/provider/jump-worker.d.ts +9 -0
- package/dist/cli/provider/jump-worker.js +141 -0
- package/dist/cli/provider/lifecycle.d.ts +149 -0
- package/dist/cli/provider/lifecycle.js +1390 -0
- package/dist/cli/provider/machine.d.ts +17 -0
- package/dist/cli/provider/machine.js +116 -0
- package/dist/cli/provider/ssh.d.ts +105 -0
- package/dist/cli/provider/ssh.js +305 -0
- package/dist/cli/provider/terraform.d.ts +140 -0
- package/dist/cli/provider/terraform.js +288 -0
- package/dist/cli/providers/index.d.ts +18 -0
- package/dist/cli/providers/index.js +422 -0
- package/dist/cli/python.d.ts +61 -0
- package/dist/cli/python.js +255 -0
- package/dist/cli/queues/index.d.ts +33 -0
- package/dist/cli/queues/index.js +248 -0
- package/dist/cli/queues/slurm.d.ts +10 -0
- package/dist/cli/queues/slurm.js +134 -0
- package/dist/cli/resources.d.ts +72 -0
- package/dist/cli/resources.js +137 -0
- package/dist/cli/run/index.d.ts +15 -0
- package/dist/cli/run/index.js +163 -0
- package/dist/cli/run/input.d.ts +34 -0
- package/dist/cli/run/input.js +135 -0
- package/dist/cli/run/recovery.d.ts +2 -0
- package/dist/cli/run/recovery.js +18 -0
- package/dist/cli/run/setup.d.ts +3 -0
- package/dist/cli/run/setup.js +62 -0
- package/dist/cli/runconfig/index.d.ts +12 -0
- package/dist/cli/runconfig/index.js +130 -0
- package/dist/cli/runnable/index.d.ts +35 -0
- package/dist/cli/runnable/index.js +575 -0
- package/dist/cli/runnable/path.d.ts +115 -0
- package/dist/cli/runnable/path.js +288 -0
- package/dist/cli/runnable/run.d.ts +91 -0
- package/dist/cli/runnable/run.js +239 -0
- package/dist/cli/runnable/upload.d.ts +43 -0
- package/dist/cli/runnable/upload.js +342 -0
- package/dist/cli/runnable/worker.d.ts +1 -0
- package/dist/cli/runnable/worker.js +44 -0
- package/dist/cli/schemas/workflow-spec.schema.json +335 -0
- package/dist/cli/self-update/index.d.ts +5 -0
- package/dist/cli/self-update/index.js +107 -0
- package/dist/cli/self-update/install.d.ts +60 -0
- package/dist/cli/self-update/install.js +428 -0
- package/dist/cli/self-update/paths.d.ts +40 -0
- package/dist/cli/self-update/paths.js +87 -0
- package/dist/cli/self-update/releases.d.ts +41 -0
- package/dist/cli/self-update/releases.js +153 -0
- package/dist/cli/self-update/settings.d.ts +16 -0
- package/dist/cli/self-update/settings.js +68 -0
- package/dist/cli/self-update/update.d.ts +18 -0
- package/dist/cli/self-update/update.js +241 -0
- package/dist/cli/service-accounts/index.d.ts +3 -0
- package/dist/cli/service-accounts/index.js +149 -0
- package/dist/cli/session-affiliation.d.ts +26 -0
- package/dist/cli/session-affiliation.js +135 -0
- package/dist/cli/sessions/affiliation.d.ts +8 -0
- package/dist/cli/sessions/affiliation.js +66 -0
- package/dist/cli/sessions/api.d.ts +55 -0
- package/dist/cli/sessions/api.js +88 -0
- package/dist/cli/sessions/control.d.ts +6 -0
- package/dist/cli/sessions/control.js +159 -0
- package/dist/cli/sessions/conversation.d.ts +15 -0
- package/dist/cli/sessions/conversation.js +118 -0
- package/dist/cli/sessions/index.d.ts +2 -0
- package/dist/cli/sessions/index.js +209 -0
- package/dist/cli/sessions/managed.d.ts +39 -0
- package/dist/cli/sessions/managed.js +63 -0
- package/dist/cli/sessions/redaction.d.ts +2 -0
- package/dist/cli/sessions/redaction.js +11 -0
- package/dist/cli/sessions/runner/exec.d.ts +108 -0
- package/dist/cli/sessions/runner/exec.js +335 -0
- package/dist/cli/sessions/runner/journal.d.ts +26 -0
- package/dist/cli/sessions/runner/journal.js +49 -0
- package/dist/cli/sessions/runner/native.d.ts +48 -0
- package/dist/cli/sessions/runner/native.js +170 -0
- package/dist/cli/sessions/runner/pod.d.ts +30 -0
- package/dist/cli/sessions/runner/pod.js +129 -0
- package/dist/cli/sessions/runner/serve.d.ts +85 -0
- package/dist/cli/sessions/runner/serve.js +558 -0
- package/dist/cli/sessions/sync.d.ts +47 -0
- package/dist/cli/sessions/sync.js +80 -0
- package/dist/cli/sessions/transport.d.ts +14 -0
- package/dist/cli/sessions/transport.js +116 -0
- package/dist/cli/share.d.ts +15 -0
- package/dist/cli/share.js +139 -0
- package/dist/cli/skill/catalog.d.ts +141 -0
- package/dist/cli/skill/catalog.js +442 -0
- package/dist/cli/skill/files.d.ts +89 -0
- package/dist/cli/skill/files.js +264 -0
- package/dist/cli/skill/index.d.ts +268 -0
- package/dist/cli/skill/index.js +1216 -0
- package/dist/cli/skill/manifest.d.ts +30 -0
- package/dist/cli/skill/manifest.js +101 -0
- package/dist/cli/skill/prefs.d.ts +9 -0
- package/dist/cli/skill/prefs.js +32 -0
- package/dist/cli/skill/reminders.d.ts +15 -0
- package/dist/cli/skill/reminders.js +105 -0
- package/dist/cli/skill/tar.d.ts +17 -0
- package/dist/cli/skill/tar.js +195 -0
- package/dist/cli/snapshot/index.d.ts +24 -0
- package/dist/cli/snapshot/index.js +146 -0
- package/dist/cli/source/access.d.ts +45 -0
- package/dist/cli/source/access.js +563 -0
- package/dist/cli/source/control.d.ts +103 -0
- package/dist/cli/source/control.js +546 -0
- package/dist/cli/source/delete.d.ts +89 -0
- package/dist/cli/source/delete.js +463 -0
- package/dist/cli/source/index.d.ts +288 -0
- package/dist/cli/source/index.js +1348 -0
- package/dist/cli/source/share.d.ts +65 -0
- package/dist/cli/source/share.js +530 -0
- package/dist/cli/source/upload.d.ts +62 -0
- package/dist/cli/source/upload.js +258 -0
- package/dist/cli/source/write.d.ts +77 -0
- package/dist/cli/source/write.js +335 -0
- package/dist/cli/spawn.d.ts +28 -0
- package/dist/cli/spawn.js +81 -0
- package/dist/cli/target.d.ts +22 -0
- package/dist/cli/target.js +85 -0
- package/dist/cli/tasks/index.d.ts +38 -0
- package/dist/cli/tasks/index.js +365 -0
- package/dist/cli/team/index.d.ts +37 -0
- package/dist/cli/team/index.js +407 -0
- package/dist/cli/telemetry.d.ts +23 -0
- package/dist/cli/telemetry.js +262 -0
- package/dist/cli/telemetryJournal.d.ts +26 -0
- package/dist/cli/telemetryJournal.js +104 -0
- package/dist/cli/update/index.d.ts +21 -0
- package/dist/cli/update/index.js +284 -0
- package/dist/cli/upload/index.d.ts +11 -0
- package/dist/cli/upload/index.js +261 -0
- package/dist/cli/upload/kinds.d.ts +10 -0
- package/dist/cli/upload/kinds.js +85 -0
- package/dist/cli/upload/multipart.d.ts +21 -0
- package/dist/cli/upload/multipart.js +248 -0
- package/dist/cli/vault/affected-preview.d.ts +15 -0
- package/dist/cli/vault/affected-preview.js +38 -0
- package/dist/cli/vault/cloud.d.ts +55 -0
- package/dist/cli/vault/cloud.js +287 -0
- package/dist/cli/vault/format.d.ts +18 -0
- package/dist/cli/vault/format.js +104 -0
- package/dist/cli/vault/hostCredentials.d.ts +21 -0
- package/dist/cli/vault/hostCredentials.js +71 -0
- package/dist/cli/vault/hostSupersessions.d.ts +18 -0
- package/dist/cli/vault/hostSupersessions.js +68 -0
- package/dist/cli/vault/import.d.ts +3 -0
- package/dist/cli/vault/import.js +79 -0
- package/dist/cli/vault/index.d.ts +14 -0
- package/dist/cli/vault/index.js +225 -0
- package/dist/cli/vault/keys.d.ts +5 -0
- package/dist/cli/vault/keys.js +165 -0
- package/dist/cli/vault/kms.d.ts +6 -0
- package/dist/cli/vault/kms.js +169 -0
- package/dist/cli/vault/list.d.ts +13 -0
- package/dist/cli/vault/list.js +60 -0
- package/dist/cli/vault/listView.d.ts +21 -0
- package/dist/cli/vault/listView.js +123 -0
- package/dist/cli/vault/managementMetadata.d.ts +2 -0
- package/dist/cli/vault/managementMetadata.js +23 -0
- package/dist/cli/vault/mutations.d.ts +8 -0
- package/dist/cli/vault/mutations.js +151 -0
- package/dist/cli/vault/otp.d.ts +6 -0
- package/dist/cli/vault/otp.js +62 -0
- package/dist/cli/vault/otpIntent.d.ts +23 -0
- package/dist/cli/vault/otpIntent.js +76 -0
- package/dist/cli/vault/passImport.d.ts +25 -0
- package/dist/cli/vault/passImport.js +129 -0
- package/dist/cli/vault/passOtp.d.ts +51 -0
- package/dist/cli/vault/passOtp.js +101 -0
- package/dist/cli/vault/passStore.d.ts +26 -0
- package/dist/cli/vault/passStore.js +134 -0
- package/dist/cli/vault/passwordCommand.d.ts +39 -0
- package/dist/cli/vault/passwordCommand.js +101 -0
- package/dist/cli/vault/passwordProbe.d.ts +27 -0
- package/dist/cli/vault/passwordProbe.js +282 -0
- package/dist/cli/vault/passwordRotation.d.ts +9 -0
- package/dist/cli/vault/passwordRotation.js +273 -0
- package/dist/cli/vault/rotationApi.d.ts +13 -0
- package/dist/cli/vault/rotationApi.js +58 -0
- package/dist/cli/vault/rotationCommand.d.ts +2 -0
- package/dist/cli/vault/rotationCommand.js +75 -0
- package/dist/cli/vault/rotationEngine.d.ts +19 -0
- package/dist/cli/vault/rotationEngine.js +65 -0
- package/dist/cli/vault/rotationHelperSource.d.ts +2 -0
- package/dist/cli/vault/rotationHelperSource.js +3 -0
- package/dist/cli/vault/rotationInput.d.ts +11 -0
- package/dist/cli/vault/rotationInput.js +48 -0
- package/dist/cli/vault/rotationJournal.d.ts +16 -0
- package/dist/cli/vault/rotationJournal.js +183 -0
- package/dist/cli/vault/rotationKeys.d.ts +4 -0
- package/dist/cli/vault/rotationKeys.js +48 -0
- package/dist/cli/vault/rotationPrepare.d.ts +17 -0
- package/dist/cli/vault/rotationPrepare.js +108 -0
- package/dist/cli/vault/rotationRemote.d.ts +33 -0
- package/dist/cli/vault/rotationRemote.js +156 -0
- package/dist/cli/vault/rotationState.d.ts +42 -0
- package/dist/cli/vault/rotationState.js +115 -0
- package/dist/cli/vault/rotationTransport.d.ts +18 -0
- package/dist/cli/vault/rotationTransport.js +71 -0
- package/dist/cli/vault/sshSource.d.ts +18 -0
- package/dist/cli/vault/sshSource.js +196 -0
- package/dist/cli/vault/sshSync.d.ts +17 -0
- package/dist/cli/vault/sshSync.js +224 -0
- package/dist/cli/vault/sshTransfer.d.ts +22 -0
- package/dist/cli/vault/sshTransfer.js +140 -0
- package/dist/cli/vault/terraformState.d.ts +66 -0
- package/dist/cli/vault/terraformState.js +252 -0
- package/dist/cli/vault/terraformStateCommand.d.ts +2 -0
- package/dist/cli/vault/terraformStateCommand.js +61 -0
- package/dist/cli/vault/tree.d.ts +43 -0
- package/dist/cli/vault/tree.js +292 -0
- package/dist/cli/version.d.ts +1 -0
- package/dist/cli/version.js +9 -0
- package/dist/cli/workflow/index.d.ts +76 -0
- package/dist/cli/workflow/index.js +826 -0
- package/dist/cli/workflow/validate.d.ts +19 -0
- package/dist/cli/workflow/validate.js +353 -0
- package/dist/package.json +1 -0
- package/package.json +28 -10
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { hostRequest } from "./api.js";
|
|
2
|
+
interface EnrollmentOptions {
|
|
3
|
+
namespace?: string;
|
|
4
|
+
enrollment: string;
|
|
5
|
+
}
|
|
6
|
+
export interface HostMetrics {
|
|
7
|
+
hostId: string;
|
|
8
|
+
enrollmentId: string;
|
|
9
|
+
resolution: number;
|
|
10
|
+
readAt: string;
|
|
11
|
+
latest: {
|
|
12
|
+
timestamp: number;
|
|
13
|
+
values: Record<string, unknown>;
|
|
14
|
+
} | null;
|
|
15
|
+
tiers: Record<string, unknown>;
|
|
16
|
+
stale: boolean;
|
|
17
|
+
sampleFreshness: "fresh" | "stale" | "unknown";
|
|
18
|
+
sampleAgeSeconds: number | null;
|
|
19
|
+
}
|
|
20
|
+
export declare function readHostMetrics(selector: string, opts: EnrollmentOptions & {
|
|
21
|
+
resolution?: string | number;
|
|
22
|
+
}, request?: typeof hostRequest, now?: () => number, fetcher?: typeof fetch): Promise<HostMetrics>;
|
|
23
|
+
export interface HostActionCheck {
|
|
24
|
+
hostId: string;
|
|
25
|
+
enrollmentId: string;
|
|
26
|
+
machineId: string;
|
|
27
|
+
action: "ssh" | "tracked-run";
|
|
28
|
+
readiness: "ready" | "not_ready" | "unknown";
|
|
29
|
+
reason: string;
|
|
30
|
+
checkedAt: string;
|
|
31
|
+
observedAt: string | null;
|
|
32
|
+
ageSeconds: number | null;
|
|
33
|
+
}
|
|
34
|
+
export declare function checkHostAction(selector: string, opts: EnrollmentOptions & {
|
|
35
|
+
action: string;
|
|
36
|
+
}, request?: typeof hostRequest): Promise<HostActionCheck>;
|
|
37
|
+
export declare function formatHostMetrics(result: HostMetrics): string;
|
|
38
|
+
export declare function formatHostActionCheck(result: HostActionCheck): string;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { hostApiPath, hostRequest } from "./api.js";
|
|
2
|
+
import { hostStatus } from "./enroll.js";
|
|
3
|
+
import { resolveHostNamespace } from "./inventory.js";
|
|
4
|
+
import { readMetricsSource } from "./metrics-source.js";
|
|
5
|
+
async function enrollmentTarget(selector, opts, request) {
|
|
6
|
+
if (!/^[a-f0-9]{24}$/i.test(opts.enrollment ?? ""))
|
|
7
|
+
throw new Error("--enrollment must be a 24-character enrollment ID");
|
|
8
|
+
if (selector.includes("*"))
|
|
9
|
+
throw new Error("Select one host by ID or full name; wildcards are not supported");
|
|
10
|
+
if (!/^[a-f0-9]{24}$/i.test(selector) && !(selector.split("/").length === 3 && selector.split("/").every(part => /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/.test(part)))) {
|
|
11
|
+
throw new Error("Host selector must be a 24-character host ID or namespace/group/host");
|
|
12
|
+
}
|
|
13
|
+
const namespace = await resolveHostNamespace(selector.includes("/") ? selector.split("/")[0] : opts.namespace);
|
|
14
|
+
let hostId;
|
|
15
|
+
if (/^[a-f0-9]{24}$/i.test(selector))
|
|
16
|
+
hostId = selector.toLowerCase();
|
|
17
|
+
else {
|
|
18
|
+
const detail = await hostStatus(selector, { namespace: opts.namespace ?? namespace }, request);
|
|
19
|
+
if (!/^[a-f0-9]{24}$/i.test(detail?.host?.id ?? ""))
|
|
20
|
+
throw new Error("Host API returned an invalid host identity");
|
|
21
|
+
hostId = detail.host.id.toLowerCase();
|
|
22
|
+
}
|
|
23
|
+
const enrollmentId = opts.enrollment.toLowerCase();
|
|
24
|
+
return { hostId, enrollmentId, path: `${hostApiPath(namespace)}/${hostId}/enrollments/${enrollmentId}` };
|
|
25
|
+
}
|
|
26
|
+
function sampleMillis(timestamp) {
|
|
27
|
+
if (typeof timestamp !== "number" || !Number.isSafeInteger(timestamp) || timestamp < 0)
|
|
28
|
+
return null;
|
|
29
|
+
const millis = timestamp * 1000;
|
|
30
|
+
return Number.isFinite(new Date(millis).getTime()) ? millis : null;
|
|
31
|
+
}
|
|
32
|
+
export async function readHostMetrics(selector, opts, request = hostRequest, now = Date.now, fetcher = fetch) {
|
|
33
|
+
const resolution = Number(opts.resolution ?? 60);
|
|
34
|
+
if (![10, 60, 900, 3600].includes(resolution))
|
|
35
|
+
throw new Error("--resolution must be 10, 60, 900, or 3600 seconds");
|
|
36
|
+
const target = await enrollmentTarget(selector, opts, request);
|
|
37
|
+
let result = await request(`${target.path}/metrics?resolution=${resolution}`);
|
|
38
|
+
if (result?.mode === "source")
|
|
39
|
+
result = await readMetricsSource(result, resolution, now, fetcher);
|
|
40
|
+
if (!result || typeof result.stale !== "boolean" || !result.tiers || typeof result.tiers !== "object" || Array.isArray(result.tiers) ||
|
|
41
|
+
(result.latest !== null && (!result.latest || typeof result.latest !== "object" || !result.latest.values ||
|
|
42
|
+
typeof result.latest.values !== "object" || Array.isArray(result.latest.values)))) {
|
|
43
|
+
throw new Error("Host API returned invalid metrics");
|
|
44
|
+
}
|
|
45
|
+
const readTime = now();
|
|
46
|
+
const sampled = sampleMillis(result.latest?.timestamp);
|
|
47
|
+
const age = sampled === null || sampled > readTime ? null : (readTime - sampled) / 1000;
|
|
48
|
+
return { hostId: target.hostId, enrollmentId: target.enrollmentId, resolution, readAt: new Date(readTime).toISOString(),
|
|
49
|
+
latest: result.latest, tiers: result.tiers, stale: result.stale,
|
|
50
|
+
sampleFreshness: age === null ? "unknown" : result.stale || age > 90 ? "stale" : "fresh",
|
|
51
|
+
sampleAgeSeconds: age === null ? null : Math.floor(age) };
|
|
52
|
+
}
|
|
53
|
+
export async function checkHostAction(selector, opts, request = hostRequest) {
|
|
54
|
+
if (!["ssh", "tracked-run"].includes(opts.action))
|
|
55
|
+
throw new Error("--action must be ssh or tracked-run");
|
|
56
|
+
const target = await enrollmentTarget(selector, opts, request);
|
|
57
|
+
const result = await request(`${target.path}/check?action=${opts.action}`);
|
|
58
|
+
const validDate = (value) => typeof value === "string" && Number.isFinite(Date.parse(value));
|
|
59
|
+
if (!result || result.hostId !== target.hostId || result.enrollmentId !== target.enrollmentId || result.action !== opts.action ||
|
|
60
|
+
typeof result.machineId !== "string" || !result.machineId || !["ready", "not_ready", "unknown"].includes(result.readiness) ||
|
|
61
|
+
typeof result.reason !== "string" || !result.reason || !validDate(result.checkedAt) ||
|
|
62
|
+
!(result.observedAt === null || validDate(result.observedAt)) ||
|
|
63
|
+
!(result.ageSeconds === null || (Number.isInteger(result.ageSeconds) && result.ageSeconds >= 0))) {
|
|
64
|
+
throw new Error("Host API returned an invalid action check");
|
|
65
|
+
}
|
|
66
|
+
if (result.readiness === "ready") {
|
|
67
|
+
const windowSeconds = result.action === "ssh" ? 30 : 60;
|
|
68
|
+
const observationAgeMs = result.observedAt === null ? NaN : Date.parse(result.checkedAt) - Date.parse(result.observedAt);
|
|
69
|
+
// Validate the backend's claim against its own timestamps, retaining its 5s clock-skew allowance.
|
|
70
|
+
// Never upgrade a missing or stale observation to readiness on the client.
|
|
71
|
+
if (result.observedAt === null || result.ageSeconds === null || result.ageSeconds > windowSeconds ||
|
|
72
|
+
observationAgeMs < -5000 || observationAgeMs > windowSeconds * 1000) {
|
|
73
|
+
throw new Error("Host API returned an inconsistent ready observation");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return { hostId: result.hostId, enrollmentId: result.enrollmentId, machineId: result.machineId, action: result.action,
|
|
77
|
+
readiness: result.readiness, reason: result.reason, checkedAt: result.checkedAt, observedAt: result.observedAt, ageSeconds: result.ageSeconds };
|
|
78
|
+
}
|
|
79
|
+
function cell(value) {
|
|
80
|
+
return value === null ? "unknown" : value.replace(/[\x00-\x1f\x7f-\x9f]/g, " ");
|
|
81
|
+
}
|
|
82
|
+
export function formatHostMetrics(result) {
|
|
83
|
+
const sampled = sampleMillis(result.latest?.timestamp);
|
|
84
|
+
const metric = (key, unit) => {
|
|
85
|
+
const value = result.latest?.values[key];
|
|
86
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? `${value}${unit}` : "unknown";
|
|
87
|
+
};
|
|
88
|
+
return [`Host ID: ${result.hostId}`, `Enrollment ID: ${result.enrollmentId}`,
|
|
89
|
+
`Sampled at: ${sampled === null ? "unknown" : new Date(sampled).toISOString()}`, `Read at: ${result.readAt}`,
|
|
90
|
+
`Sample freshness: ${result.sampleFreshness}`, `Source stale: ${result.stale ? "yes" : "no"}`,
|
|
91
|
+
`CPU: ${metric("cpu_percent", "%")}`, `RAM used: ${metric("memory_used_bytes", " bytes")}`,
|
|
92
|
+
`RAM total: ${metric("memory_total_bytes", " bytes")}`, `Disk used: ${metric("filesystem_used_bytes", " bytes")}`,
|
|
93
|
+
`Disk total: ${metric("filesystem_total_bytes", " bytes")}`,
|
|
94
|
+
"Metrics do not establish SSH or job readiness."].join("\n");
|
|
95
|
+
}
|
|
96
|
+
export function formatHostActionCheck(result) {
|
|
97
|
+
return [`Host ID: ${result.hostId}`, `Enrollment ID: ${result.enrollmentId}`, `Machine ID: ${cell(result.machineId)}`,
|
|
98
|
+
`Action: ${result.action}`, `Readiness: ${result.readiness}`, `Reason: ${cell(result.reason)}`,
|
|
99
|
+
`Checked at: ${cell(result.checkedAt)}`, `Observed at: ${cell(result.observedAt)}`,
|
|
100
|
+
`Observation age: ${result.ageSeconds === null ? "unknown" : `${result.ageSeconds}s`}`,
|
|
101
|
+
"Ready means observed advertised capability; no SSH handshake or job execution was performed."].join("\n");
|
|
102
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** No secrets in argv; this program receives grants/config only on stdin. */
|
|
2
|
+
export { BOOTSTRAP_PYTHON } from "./bootstrap-source.js";
|
|
3
|
+
export declare function remoteBootstrap(args: string[], payload: Record<string, unknown>, executable?: string): Promise<Record<string, unknown>>;
|
|
4
|
+
/** Direct enrollment uses the same identity and service bootstrap, without a shell or SSH. */
|
|
5
|
+
export declare function localBootstrap(payload: Record<string, unknown>, executable?: string): Promise<Record<string, unknown>>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
/** No secrets in argv; this program receives grants/config only on stdin. */
|
|
3
|
+
export { BOOTSTRAP_PYTHON } from "./bootstrap-source.js";
|
|
4
|
+
import { BOOTSTRAP_PYTHON } from "./bootstrap-source.js";
|
|
5
|
+
export async function remoteBootstrap(args, payload, executable = process.env.DREAMLAKE_SSH || "ssh") {
|
|
6
|
+
const source = Buffer.from(BOOTSTRAP_PYTHON).toString("base64");
|
|
7
|
+
const remote = `python3 -c 'import base64;exec(base64.b64decode("${source}"))'`;
|
|
8
|
+
return runBootstrap(executable, ["-T", ...args, remote], payload, "SSH");
|
|
9
|
+
}
|
|
10
|
+
/** Direct enrollment uses the same identity and service bootstrap, without a shell or SSH. */
|
|
11
|
+
export async function localBootstrap(payload, executable = "python3") {
|
|
12
|
+
if (!["linux", "darwin"].includes(process.platform))
|
|
13
|
+
throw new Error("Local enrollment requires Linux/systemd or macOS/launchd");
|
|
14
|
+
return runBootstrap(executable, ["-c", BOOTSTRAP_PYTHON], payload, "Local");
|
|
15
|
+
}
|
|
16
|
+
function runBootstrap(executable, args, payload, transport) {
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
// OpenSSH prompts via /dev/tty where available; stdin is exclusively payload.
|
|
19
|
+
const child = spawn(executable, args, { stdio: ["pipe", "pipe", "pipe"] });
|
|
20
|
+
const chunks = [];
|
|
21
|
+
let bytes = 0;
|
|
22
|
+
const timer = setTimeout(() => child.kill("SIGTERM"), 180_000);
|
|
23
|
+
child.stdout.on("data", (b) => { bytes += b.length; if (bytes > 64_000)
|
|
24
|
+
child.kill();
|
|
25
|
+
else
|
|
26
|
+
chunks.push(b); });
|
|
27
|
+
child.stderr.resume();
|
|
28
|
+
child.on("error", () => { clearTimeout(timer); reject(new Error(`${transport} bootstrap could not start`)); });
|
|
29
|
+
child.on("close", code => {
|
|
30
|
+
clearTimeout(timer);
|
|
31
|
+
if (code !== 0) {
|
|
32
|
+
const messages = {
|
|
33
|
+
nymph_access_version_required: "This setup requires a Nymph release with separate access policy support; the existing service was not changed",
|
|
34
|
+
nymph_access_migration_required: "Existing enrollment uses legacy permissions; migrate it explicitly before managed setup",
|
|
35
|
+
sshd_required: "Web terminal needs /usr/sbin/sshd; install OpenSSH server or use --no-web-terminal",
|
|
36
|
+
nymph_ssh_version_required: "Web terminal needs Nymph 0.1.11 or newer; update Nymph or use --no-web-terminal",
|
|
37
|
+
sshd_privilege_directory_required: "Web terminal needs root-owned /run/sshd without group/world write permission; ask the host administrator to configure it or use --no-web-terminal",
|
|
38
|
+
openssl_ed25519_required: `${transport} target needs OpenSSL with Ed25519 support (on macOS install openssl@3 with Homebrew)`,
|
|
39
|
+
macos_user_required: "macOS enrollment must run as your logged-in user, without sudo",
|
|
40
|
+
launchd_gui_unavailable: "macOS enrollment needs your logged-in graphical user session (launchctl gui domain)",
|
|
41
|
+
platform_unsupported: "Enrollment requires Linux/systemd or macOS/launchd",
|
|
42
|
+
openssl_missing: `${transport} target needs OpenSSL before enrollment`,
|
|
43
|
+
systemd_user_unavailable: `${transport} target has no accessible systemd user manager`,
|
|
44
|
+
linger_unavailable: `${transport} target user-linger status could not be checked`,
|
|
45
|
+
linger_required: `${transport} target requires user lingering: run loginctl enable-linger for the target account before enrollment`,
|
|
46
|
+
};
|
|
47
|
+
let message;
|
|
48
|
+
try {
|
|
49
|
+
const result = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
50
|
+
if (Object.hasOwn(messages, result.code))
|
|
51
|
+
message = messages[result.code];
|
|
52
|
+
}
|
|
53
|
+
catch { }
|
|
54
|
+
return reject(new Error(message ?? `${transport} bootstrap failed; verify access, Python 3, OpenSSL, the platform user-service manager on the target`));
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
resolve(JSON.parse(Buffer.concat(chunks).toString("utf8")));
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
reject(new Error(`${transport} bootstrap returned invalid output`));
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
child.stdin.on("error", () => { });
|
|
64
|
+
child.stdin.end(JSON.stringify(payload));
|
|
65
|
+
});
|
|
66
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type ChildProcess } from 'node:child_process';
|
|
2
|
+
import { Duplex } from 'node:stream';
|
|
3
|
+
import WebSocket from 'ws';
|
|
4
|
+
import type { Command } from 'commander';
|
|
5
|
+
import { hostRequest } from './api.js';
|
|
6
|
+
export interface SshTarget {
|
|
7
|
+
hostId: string;
|
|
8
|
+
enrollmentId: string;
|
|
9
|
+
machineId: string;
|
|
10
|
+
namespace: string;
|
|
11
|
+
workerId: string;
|
|
12
|
+
username: string;
|
|
13
|
+
unixUid: number;
|
|
14
|
+
hostPublicKey: string;
|
|
15
|
+
controlPlane: string;
|
|
16
|
+
controlNamespace: string;
|
|
17
|
+
}
|
|
18
|
+
export interface SshSession {
|
|
19
|
+
id: string;
|
|
20
|
+
state: string;
|
|
21
|
+
connect_by: string;
|
|
22
|
+
expires_at: string;
|
|
23
|
+
target: {
|
|
24
|
+
worker_id: string;
|
|
25
|
+
daemon_instance_id: string;
|
|
26
|
+
unix_user: string;
|
|
27
|
+
unix_uid: number;
|
|
28
|
+
};
|
|
29
|
+
host_key: {
|
|
30
|
+
public_key: string;
|
|
31
|
+
fingerprint_sha256: string;
|
|
32
|
+
alias: string;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export interface SshOptions {
|
|
36
|
+
namespace?: string;
|
|
37
|
+
enrollment?: string;
|
|
38
|
+
duration?: string;
|
|
39
|
+
timeout?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface SshIO {
|
|
42
|
+
request: typeof hostRequest;
|
|
43
|
+
fetch: typeof fetch;
|
|
44
|
+
socket: (url: string, ticket: string) => WebSocket;
|
|
45
|
+
spawn: (args: string[]) => ChildProcess;
|
|
46
|
+
}
|
|
47
|
+
export declare function sshPublicKey(value: string): string;
|
|
48
|
+
export declare function validateSshTarget(t: SshTarget, hostId: string, namespace: string): void;
|
|
49
|
+
export declare function validateSshSession(s: SshSession, t: SshTarget, previous?: string): string;
|
|
50
|
+
/** Arguments are quoted individually for the enrolled account's POSIX shell. No implicit shell expansion. */
|
|
51
|
+
export declare function remoteCommand(argv: string[]): string;
|
|
52
|
+
/** Bounded nymph-ssh.v1 data/FIN stream. Terminal bytes are never logged or persisted. */
|
|
53
|
+
export declare class SshRelay extends Duplex {
|
|
54
|
+
private ws;
|
|
55
|
+
private remoteFin;
|
|
56
|
+
constructor(ws: WebSocket);
|
|
57
|
+
_read(): void;
|
|
58
|
+
_write(chunk: Buffer, _: BufferEncoding, done: (error?: Error | null) => void): void;
|
|
59
|
+
_final(done: (error?: Error | null) => void): void;
|
|
60
|
+
_destroy(error: Error | null, done: (error?: Error | null) => void): void;
|
|
61
|
+
}
|
|
62
|
+
export declare function runHostSsh(selector: string, opts: SshOptions, argv?: string[], io?: SshIO): Promise<number>;
|
|
63
|
+
export declare function registerHostSshCommands(hosts: Command, program: Command): void;
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { execFile, spawn } from 'node:child_process';
|
|
3
|
+
import { chmod, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import { createServer } from 'node:net';
|
|
7
|
+
import { Duplex } from 'node:stream';
|
|
8
|
+
import { promisify } from 'node:util';
|
|
9
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
10
|
+
import WebSocket from 'ws';
|
|
11
|
+
import { hostApiPath, hostRequest } from './api.js';
|
|
12
|
+
import { hostStatus } from './enroll.js';
|
|
13
|
+
import { resolveHostNamespace } from './inventory.js';
|
|
14
|
+
const ID = /^[a-f0-9]{24}$/;
|
|
15
|
+
const defaults = {
|
|
16
|
+
request: hostRequest, fetch: (...args) => fetch(...args),
|
|
17
|
+
socket: (url, ticket) => new WebSocket(url, 'nymph-ssh.v1', { headers: { Authorization: `Bearer ${ticket}` },
|
|
18
|
+
perMessageDeflate: false, maxPayload: 65537, handshakeTimeout: 10000, followRedirects: false }),
|
|
19
|
+
spawn: args => spawn('ssh', args, { stdio: 'inherit' }),
|
|
20
|
+
};
|
|
21
|
+
export function sshPublicKey(value) {
|
|
22
|
+
if (typeof value !== 'string')
|
|
23
|
+
throw new Error('Invalid SSH host key');
|
|
24
|
+
const p = value.trim().split(/\s+/), bytes = Buffer.from(p[1] ?? '', 'base64');
|
|
25
|
+
if (p[0] !== 'ssh-ed25519' || !/^[A-Za-z0-9+/]{68}$/.test(p[1] ?? '') || bytes.length !== 51 ||
|
|
26
|
+
bytes.readUInt32BE(0) !== 11 || bytes.subarray(4, 15).toString() !== 'ssh-ed25519' || bytes.readUInt32BE(15) !== 32)
|
|
27
|
+
throw new Error('Invalid SSH host key');
|
|
28
|
+
return `ssh-ed25519 ${bytes.toString('base64')}`;
|
|
29
|
+
}
|
|
30
|
+
export function validateSshTarget(t, hostId, namespace) {
|
|
31
|
+
if (!t || t.hostId !== hostId || t.namespace !== namespace || !ID.test(t.enrollmentId) || !ID.test(t.workerId) ||
|
|
32
|
+
typeof t.machineId !== 'string' || !t.machineId || !/^[A-Za-z_][A-Za-z0-9_-]*\$?$/.test(t.username) ||
|
|
33
|
+
t.username === 'root' || !Number.isSafeInteger(t.unixUid) || t.unixUid <= 0 ||
|
|
34
|
+
typeof t.controlNamespace !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/.test(t.controlNamespace))
|
|
35
|
+
throw new Error('Invalid SSH target identity');
|
|
36
|
+
const u = new URL(t.controlPlane);
|
|
37
|
+
if (u.protocol !== 'https:' || u.origin !== t.controlPlane || u.username || u.password)
|
|
38
|
+
throw new Error('SSH requires an authenticated HTTPS relay origin');
|
|
39
|
+
sshPublicKey(t.hostPublicKey);
|
|
40
|
+
}
|
|
41
|
+
export function validateSshSession(s, t, previous) {
|
|
42
|
+
const pin = sshPublicKey(t.hostPublicKey);
|
|
43
|
+
const fingerprint = 'SHA256:' + createHash('sha256').update(Buffer.from(pin.split(' ')[1], 'base64')).digest('base64').replace(/=+$/, '');
|
|
44
|
+
if (!s || !ID.test(s.id) || s.target?.worker_id !== t.workerId || s.target.unix_user !== t.username ||
|
|
45
|
+
s.target.unix_uid !== t.unixUid || typeof s.target.daemon_instance_id !== 'string' || !s.target.daemon_instance_id ||
|
|
46
|
+
sshPublicKey(s.host_key?.public_key) !== pin || s.host_key.fingerprint_sha256 !== fingerprint ||
|
|
47
|
+
!Number.isFinite(Date.parse(s.connect_by)) || !Number.isFinite(Date.parse(s.expires_at)) || Date.parse(s.expires_at) <= Date.now())
|
|
48
|
+
throw new Error('SSH session identity or host key changed');
|
|
49
|
+
const snapshot = JSON.stringify([s.id, s.target, s.host_key, s.connect_by, s.expires_at]);
|
|
50
|
+
if (previous && previous !== snapshot)
|
|
51
|
+
throw new Error('SSH session identity or host key changed');
|
|
52
|
+
return snapshot;
|
|
53
|
+
}
|
|
54
|
+
/** Arguments are quoted individually for the enrolled account's POSIX shell. No implicit shell expansion. */
|
|
55
|
+
export function remoteCommand(argv) {
|
|
56
|
+
if (!argv.length || argv.length > 128 || argv.some(a => a.includes('\0') || Buffer.byteLength(a) > 8192) ||
|
|
57
|
+
argv.reduce((n, a) => n + Buffer.byteLength(a), 0) > 65536 || !argv[0])
|
|
58
|
+
throw new Error('exec requires a bounded command and arguments');
|
|
59
|
+
return 'exec ' + argv.map(a => "'" + a.replace(/'/g, "'\\''") + "'").join(' ');
|
|
60
|
+
}
|
|
61
|
+
/** Bounded nymph-ssh.v1 data/FIN stream. Terminal bytes are never logged or persisted. */
|
|
62
|
+
export class SshRelay extends Duplex {
|
|
63
|
+
ws;
|
|
64
|
+
remoteFin = false;
|
|
65
|
+
constructor(ws) {
|
|
66
|
+
super({ highWaterMark: 65536 });
|
|
67
|
+
this.ws = ws;
|
|
68
|
+
ws.on('message', (raw, binary) => {
|
|
69
|
+
const b = Buffer.from(raw);
|
|
70
|
+
if (!binary || this.remoteFin || !b.length || b.length > 65537)
|
|
71
|
+
return this.destroy(new Error('Invalid SSH relay frame'));
|
|
72
|
+
if (b[0] === 1 && b.length === 1) {
|
|
73
|
+
this.remoteFin = true;
|
|
74
|
+
this.push(null);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (b[0] !== 0 || b.length < 2 || this.readableLength + b.length > 262144)
|
|
78
|
+
return this.destroy(new Error('Invalid SSH relay frame'));
|
|
79
|
+
if (!this.push(b.subarray(1)))
|
|
80
|
+
ws.pause();
|
|
81
|
+
});
|
|
82
|
+
ws.on('error', () => this.destroy(new Error('SSH relay disconnected')));
|
|
83
|
+
ws.on('close', () => { if (!this.remoteFin)
|
|
84
|
+
this.destroy(new Error('SSH relay closed before completion')); });
|
|
85
|
+
}
|
|
86
|
+
_read() { this.ws.resume(); }
|
|
87
|
+
_write(chunk, _, done) {
|
|
88
|
+
if (chunk.length > 262144 || this.ws.bufferedAmount > 262144)
|
|
89
|
+
return done(new Error('SSH relay buffer limit exceeded'));
|
|
90
|
+
const send = (offset) => {
|
|
91
|
+
if (offset >= chunk.length)
|
|
92
|
+
return done();
|
|
93
|
+
const data = chunk.subarray(offset, offset + 65536);
|
|
94
|
+
this.ws.send(Buffer.concat([Buffer.from([0]), data]), { binary: true }, error => error ? done(new Error('SSH relay write failed')) : send(offset + data.length));
|
|
95
|
+
};
|
|
96
|
+
send(0);
|
|
97
|
+
}
|
|
98
|
+
_final(done) { this.ws.send(Buffer.from([1]), { binary: true }, error => done(error ? new Error('SSH relay FIN failed') : undefined)); }
|
|
99
|
+
_destroy(error, done) { this.ws.terminate(); done(error); }
|
|
100
|
+
}
|
|
101
|
+
export async function runHostSsh(selector, opts, argv, io = defaults) {
|
|
102
|
+
if (process.platform === 'win32')
|
|
103
|
+
throw new Error('Host SSH currently requires Linux or macOS and OpenSSH');
|
|
104
|
+
if (selector.includes('*'))
|
|
105
|
+
throw new Error('Select one host, not a wildcard');
|
|
106
|
+
const command = argv === undefined ? undefined : remoteCommand(argv);
|
|
107
|
+
const duration = Number(opts.duration ?? 1800), timeout = opts.timeout === undefined ? undefined : Number(opts.timeout);
|
|
108
|
+
if (!Number.isInteger(duration) || duration < 120 || duration > 1800)
|
|
109
|
+
throw new Error('--duration must be 120–1800 seconds');
|
|
110
|
+
if (timeout !== undefined && (!Number.isInteger(timeout) || timeout < 1 || timeout > duration))
|
|
111
|
+
throw new Error('--timeout must be 1–duration seconds');
|
|
112
|
+
if (opts.enrollment !== undefined && !ID.test(opts.enrollment))
|
|
113
|
+
throw new Error('Use an exact enrollment ID');
|
|
114
|
+
const detail = await hostStatus(selector, opts, io.request);
|
|
115
|
+
const namespace = selector.includes('/') ? selector.split('/')[0] : await resolveHostNamespace(opts.namespace);
|
|
116
|
+
if (!ID.test(detail?.host?.id) || !Array.isArray(detail.enrollments))
|
|
117
|
+
throw new Error('Invalid host response');
|
|
118
|
+
if (/^[a-f0-9]{24}$/i.test(selector) ? detail.host.id !== selector.toLowerCase() : detail.host.name !== selector)
|
|
119
|
+
throw new Error('Host API returned a different host identity');
|
|
120
|
+
const base = hostApiPath(namespace);
|
|
121
|
+
const catalog = await io.request(`${base}/terminal-targets`);
|
|
122
|
+
if (!Array.isArray(catalog?.targets))
|
|
123
|
+
throw new Error('Invalid SSH target catalog');
|
|
124
|
+
const matches = catalog.targets.filter((t) => t.hostId === detail.host.id && (!opts.enrollment || t.enrollmentId === opts.enrollment));
|
|
125
|
+
if (matches.length !== 1)
|
|
126
|
+
throw new Error(matches.length ? 'Multiple SSH enrollments; select --enrollment' : 'No ready SSH enrollment for this host');
|
|
127
|
+
const target = matches[0];
|
|
128
|
+
validateSshTarget(target, detail.host.id, namespace);
|
|
129
|
+
if (!detail.enrollments.some((e) => e.id === target.enrollmentId && e.machineId === target.machineId && e.unixUser === target.username))
|
|
130
|
+
throw new Error('SSH enrollment identity changed');
|
|
131
|
+
const dir = await mkdtemp(join(tmpdir(), 'dreamlake-ssh-'));
|
|
132
|
+
let sessionId, credential;
|
|
133
|
+
let child, relay, socket, ws;
|
|
134
|
+
const server = createServer({ allowHalfOpen: true });
|
|
135
|
+
const abort = new AbortController();
|
|
136
|
+
let signalCode, timedOut = false;
|
|
137
|
+
const stop = (code) => { signalCode = code; abort.abort(); child?.kill('SIGTERM'); socket?.destroy(); relay?.destroy(); };
|
|
138
|
+
const sigint = () => stop(130), sigterm = () => stop(143);
|
|
139
|
+
process.on('SIGINT', sigint);
|
|
140
|
+
process.on('SIGTERM', sigterm);
|
|
141
|
+
let timer;
|
|
142
|
+
const cpBase = `${target.controlPlane}/v1/namespaces/${encodeURIComponent(target.controlNamespace)}/ssh-sessions`;
|
|
143
|
+
async function cp(path, method = 'GET', cleanup = false) {
|
|
144
|
+
const r = await io.fetch(cpBase + path, { method, redirect: 'error', signal: cleanup ? AbortSignal.timeout(3000) : AbortSignal.any([abort.signal, AbortSignal.timeout(10000)]),
|
|
145
|
+
headers: { Authorization: `Bearer ${credential}`, 'Content-Type': 'application/json' }, ...(method === 'POST' ? { body: '{}' } : {}) });
|
|
146
|
+
if (!r.ok)
|
|
147
|
+
throw new Error(`SSH session request failed (HTTP ${r.status})`);
|
|
148
|
+
return r.status === 204 ? undefined : r.json();
|
|
149
|
+
}
|
|
150
|
+
try {
|
|
151
|
+
await chmod(dir, 0o700);
|
|
152
|
+
const key = join(dir, 'identity');
|
|
153
|
+
await promisify(execFile)('ssh-keygen', ['-q', '-t', 'ed25519', '-N', '', '-f', key], { timeout: 10000 });
|
|
154
|
+
abort.signal.throwIfAborted();
|
|
155
|
+
// One submission only: an ambiguous failure must not create a second session.
|
|
156
|
+
const delegated = await io.request(`${base}/terminal-targets/${target.enrollmentId}/session`, 'POST', {
|
|
157
|
+
clientPublicKey: sshPublicKey(await readFile(key + '.pub', 'utf8')), durationSeconds: duration,
|
|
158
|
+
});
|
|
159
|
+
credential = delegated?.credential;
|
|
160
|
+
if (typeof credential !== 'string' || !credential || credential.length > 8192 || /\s/.test(credential))
|
|
161
|
+
throw new Error('Invalid SSH session credential');
|
|
162
|
+
if (ID.test(delegated?.session?.id))
|
|
163
|
+
sessionId = delegated.session.id;
|
|
164
|
+
for (const k of Object.keys(target)) {
|
|
165
|
+
// Presentation labels are not execution identity.
|
|
166
|
+
if (['name', 'id', 'kind', 'delegated'].includes(k))
|
|
167
|
+
continue;
|
|
168
|
+
if (delegated.target?.[k] !== target[k])
|
|
169
|
+
throw new Error('SSH target changed during delegation');
|
|
170
|
+
}
|
|
171
|
+
let session = delegated.session;
|
|
172
|
+
const snapshot = validateSshSession(session, target);
|
|
173
|
+
const deadline = Math.min(Date.now() + 60000, Date.parse(session.connect_by));
|
|
174
|
+
while (session.state === 'pending') {
|
|
175
|
+
if (Date.now() >= deadline)
|
|
176
|
+
throw new Error('SSH session readiness timed out');
|
|
177
|
+
await delay(200, undefined, { signal: abort.signal });
|
|
178
|
+
session = await cp(`/${sessionId}`);
|
|
179
|
+
validateSshSession(session, target, snapshot);
|
|
180
|
+
}
|
|
181
|
+
if (session.state !== 'ready')
|
|
182
|
+
throw new Error('SSH session is not ready');
|
|
183
|
+
const ticket = await cp(`/${sessionId}/attach-ticket`, 'POST');
|
|
184
|
+
if (ticket?.path !== `/v1/ssh-streams/${sessionId}/client` || typeof ticket.ticket !== 'string' || !ticket.ticket || /\s/.test(ticket.ticket) ||
|
|
185
|
+
!Number.isFinite(Date.parse(ticket.expires_at)) || Date.parse(ticket.expires_at) <= Date.now())
|
|
186
|
+
throw new Error('Invalid SSH relay ticket');
|
|
187
|
+
abort.signal.throwIfAborted();
|
|
188
|
+
ws = io.socket(target.controlPlane.replace(/^https:/, 'wss:') + ticket.path, ticket.ticket);
|
|
189
|
+
relay = new SshRelay(ws);
|
|
190
|
+
let relayError;
|
|
191
|
+
relay.on('error', e => { relayError = e; socket?.destroy(); child?.kill('SIGTERM'); });
|
|
192
|
+
await new Promise((resolve, reject) => {
|
|
193
|
+
ws.once('open', () => ws.protocol === 'nymph-ssh.v1' ? resolve() : reject(new Error('SSH relay protocol mismatch')));
|
|
194
|
+
ws.once('error', () => reject(new Error('SSH relay connection failed')));
|
|
195
|
+
ws.once('close', () => reject(new Error('SSH relay closed during setup')));
|
|
196
|
+
});
|
|
197
|
+
if (relayError)
|
|
198
|
+
throw relayError;
|
|
199
|
+
server.on('connection', s => {
|
|
200
|
+
if (socket) {
|
|
201
|
+
s.destroy();
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
socket = s;
|
|
205
|
+
server.close();
|
|
206
|
+
s.on('error', () => relay?.destroy());
|
|
207
|
+
relay.pipe(s);
|
|
208
|
+
s.pipe(relay);
|
|
209
|
+
});
|
|
210
|
+
await new Promise((resolve, reject) => { server.once('error', reject); server.listen(0, '127.0.0.1', resolve); });
|
|
211
|
+
const address = server.address();
|
|
212
|
+
if (!address || typeof address === 'string')
|
|
213
|
+
throw new Error('Local SSH bridge unavailable');
|
|
214
|
+
const knownHosts = join(dir, 'known_hosts'), alias = `dreamlake-${sessionId}`;
|
|
215
|
+
await writeFile(knownHosts, `${alias} ${sshPublicKey(target.hostPublicKey)}\n`, { mode: 0o600 });
|
|
216
|
+
abort.signal.throwIfAborted();
|
|
217
|
+
const args = ['-F', '/dev/null', '-o', 'BatchMode=yes', '-o', 'IdentitiesOnly=yes', '-o', 'IdentityAgent=none',
|
|
218
|
+
'-o', 'StrictHostKeyChecking=yes', '-o', `UserKnownHostsFile=${knownHosts}`, '-o', 'GlobalKnownHostsFile=/dev/null',
|
|
219
|
+
'-o', `HostKeyAlias=${alias}`, '-o', 'CheckHostIP=no', '-o', 'ForwardAgent=no', '-o', 'ClearAllForwardings=yes',
|
|
220
|
+
'-o', 'ControlMaster=no', '-o', 'ProxyCommand=none', '-o', 'ConnectTimeout=15', '-o', 'LogLevel=ERROR',
|
|
221
|
+
'-i', key, '-p', String(address.port), '-l', target.username, command === undefined ? '-tt' : '-T', '127.0.0.1', ...(command === undefined ? [] : [command])];
|
|
222
|
+
child = io.spawn(args);
|
|
223
|
+
const result = new Promise((resolve, reject) => {
|
|
224
|
+
child.once('error', () => reject(new Error('Could not start OpenSSH; install ssh and ssh-keygen')));
|
|
225
|
+
child.once('close', code => resolve(timedOut ? 124 : signalCode ?? code ?? 255));
|
|
226
|
+
});
|
|
227
|
+
timer = setTimeout(() => { timedOut = true; stop(124); }, Math.min((timeout ?? duration) * 1000, Date.parse(session.expires_at) - Date.now()));
|
|
228
|
+
const code = await result;
|
|
229
|
+
if (relayError && code === 0)
|
|
230
|
+
throw relayError;
|
|
231
|
+
return code;
|
|
232
|
+
}
|
|
233
|
+
catch (error) {
|
|
234
|
+
if (signalCode !== undefined)
|
|
235
|
+
return signalCode;
|
|
236
|
+
throw error;
|
|
237
|
+
}
|
|
238
|
+
finally {
|
|
239
|
+
if (timer)
|
|
240
|
+
clearTimeout(timer);
|
|
241
|
+
process.off('SIGINT', sigint);
|
|
242
|
+
process.off('SIGTERM', sigterm);
|
|
243
|
+
socket?.destroy();
|
|
244
|
+
relay?.destroy();
|
|
245
|
+
ws?.terminate();
|
|
246
|
+
server.close();
|
|
247
|
+
if (sessionId && credential)
|
|
248
|
+
await cp(`/${sessionId}`, 'DELETE', true).catch(() => {
|
|
249
|
+
console.error('SSH session cleanup could not be confirmed; the server enforces its session deadline.');
|
|
250
|
+
});
|
|
251
|
+
await rm(dir, { recursive: true, force: true });
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
export function registerHostSshCommands(hosts, program) {
|
|
255
|
+
for (const parent of [hosts, program])
|
|
256
|
+
for (const name of ['ssh', 'exec']) {
|
|
257
|
+
const c = parent.command(name).description(name === 'ssh' ? 'open a pinned SSH shell through the enrolled Nymph relay' : 'run a command over SSH; stream output and return its exit code')
|
|
258
|
+
.argument('<host>', 'host ID or namespace/group/host').option('--namespace <slug>').option('--enrollment <id>', 'select an exact SSH enrollment')
|
|
259
|
+
.option('--duration <seconds>', 'maximum session lifetime (120–1800)', '1800').option('--timeout <seconds>', 'close after this many seconds; does not guarantee detached process termination');
|
|
260
|
+
if (name === 'exec')
|
|
261
|
+
c.argument('<command...>', 'command and literal arguments after --');
|
|
262
|
+
const action = async (selector, opts, args) => {
|
|
263
|
+
try {
|
|
264
|
+
process.exitCode = await runHostSsh(selector, opts, args);
|
|
265
|
+
}
|
|
266
|
+
catch (e) {
|
|
267
|
+
console.error(e instanceof Error ? e.message : 'SSH failed');
|
|
268
|
+
process.exitCode = 255;
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
if (name === 'exec')
|
|
272
|
+
c.action((selector, args, opts) => action(selector, opts, args));
|
|
273
|
+
else
|
|
274
|
+
c.action((selector, opts) => action(selector, opts));
|
|
275
|
+
}
|
|
276
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|