@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,106 @@
|
|
|
1
|
+
// Small shared helpers for the dreamlake CLI subcommands. Adapted from
|
|
2
|
+
// lakeshore/src/cli/helpers.ts — zero dependencies beyond `yaml` (already
|
|
3
|
+
// a dep for the auth file). Keep this file presentation-only: glyphs,
|
|
4
|
+
// table rendering, JSON emit, CSV/tag parsing.
|
|
5
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import YAML from "yaml";
|
|
8
|
+
// ─── ✓ / ✗ / ⚠ glyph wrappers ────────────────────────────────────────
|
|
9
|
+
export function ok(line) {
|
|
10
|
+
process.stdout.write(`✓ ${line}\n`);
|
|
11
|
+
}
|
|
12
|
+
export function warn(line) {
|
|
13
|
+
process.stdout.write(`⚠ ${line}\n`);
|
|
14
|
+
}
|
|
15
|
+
export function fail(line) {
|
|
16
|
+
process.stderr.write(`✗ ${line}\n`);
|
|
17
|
+
}
|
|
18
|
+
// ─── splitCsv — comma-separated values → trimmed non-empty list ──────
|
|
19
|
+
//
|
|
20
|
+
// Used for `--tags a,b,c` and `--bindr name1,name2`. Mirrors the Python
|
|
21
|
+
// CLI's `[t.strip() for t in s.split(",") if t.strip()]`.
|
|
22
|
+
export function splitCsv(raw) {
|
|
23
|
+
if (!raw)
|
|
24
|
+
return [];
|
|
25
|
+
return raw
|
|
26
|
+
.split(",")
|
|
27
|
+
.map((s) => s.trim())
|
|
28
|
+
.filter((s) => s.length > 0);
|
|
29
|
+
}
|
|
30
|
+
// ─── renderTable ─────────────────────────────────────────────────────
|
|
31
|
+
//
|
|
32
|
+
// Minimal monospaced table renderer. Columns are exactly the `cols`
|
|
33
|
+
// names; each row may have arbitrary keys (others are ignored).
|
|
34
|
+
// Returns the rendered string (caller prints).
|
|
35
|
+
export function renderTable(rows, cols) {
|
|
36
|
+
if (rows.length === 0) {
|
|
37
|
+
return "(none)\n";
|
|
38
|
+
}
|
|
39
|
+
const stringRows = rows.map((r) => cols.map((c) => stringifyCell(r[c])));
|
|
40
|
+
const widths = cols.map((c, i) => Math.max(c.length, ...stringRows.map((r) => r[i].length)));
|
|
41
|
+
const lines = [];
|
|
42
|
+
// Header.
|
|
43
|
+
lines.push(cols
|
|
44
|
+
.map((c, i) => c.padEnd(widths[i]))
|
|
45
|
+
.join(" ")
|
|
46
|
+
.trimEnd());
|
|
47
|
+
// Body.
|
|
48
|
+
for (const r of stringRows) {
|
|
49
|
+
lines.push(r.map((cell, i) => cell.padEnd(widths[i])).join(" ").trimEnd());
|
|
50
|
+
}
|
|
51
|
+
return lines.join("\n") + "\n";
|
|
52
|
+
}
|
|
53
|
+
function stringifyCell(v) {
|
|
54
|
+
if (v == null)
|
|
55
|
+
return "—";
|
|
56
|
+
if (typeof v === "string")
|
|
57
|
+
return v;
|
|
58
|
+
if (typeof v === "number" || typeof v === "boolean")
|
|
59
|
+
return String(v);
|
|
60
|
+
if (Array.isArray(v))
|
|
61
|
+
return v.map(stringifyCell).join(", ");
|
|
62
|
+
return JSON.stringify(v);
|
|
63
|
+
}
|
|
64
|
+
// ─── emitJson — for `--json` / `--json-output` flags ─────────────────
|
|
65
|
+
//
|
|
66
|
+
// Single canonical JSON emitter. 2-space indent, trailing newline.
|
|
67
|
+
export function emitJson(value) {
|
|
68
|
+
process.stdout.write(JSON.stringify(value, null, 2) + "\n");
|
|
69
|
+
}
|
|
70
|
+
// ─── loadStructuredFile — YAML or JSON ───────────────────────────────
|
|
71
|
+
export function loadStructuredFile(filePath) {
|
|
72
|
+
const resolved = path.resolve(filePath);
|
|
73
|
+
if (!existsSync(resolved)) {
|
|
74
|
+
throw new Error(`file not found: ${resolved}`);
|
|
75
|
+
}
|
|
76
|
+
const text = readFileSync(resolved, "utf8");
|
|
77
|
+
const trimmed = text.trim();
|
|
78
|
+
if (trimmed.startsWith("{")) {
|
|
79
|
+
try {
|
|
80
|
+
const parsed = JSON.parse(trimmed);
|
|
81
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
82
|
+
return parsed;
|
|
83
|
+
}
|
|
84
|
+
throw new Error("expected an object at top level");
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
throw new Error(`failed to parse JSON ${resolved}: ${err.message}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
const parsed = YAML.parse(text);
|
|
92
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
93
|
+
return parsed;
|
|
94
|
+
}
|
|
95
|
+
throw new Error("expected an object at top level");
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
throw new Error(`failed to parse YAML ${resolved}: ${err.message}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// ─── humanSize — bytes → "1.5 MB" / "12.3 KB" ───────────────────────
|
|
102
|
+
export function humanSize(bytes) {
|
|
103
|
+
if (bytes > 1024 * 1024)
|
|
104
|
+
return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
|
|
105
|
+
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
106
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface HostEnrollmentResponse {
|
|
2
|
+
host: {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
};
|
|
6
|
+
enrollment: {
|
|
7
|
+
id: string;
|
|
8
|
+
machineId: string;
|
|
9
|
+
};
|
|
10
|
+
bootstrap: {
|
|
11
|
+
controlPlaneUrl: string;
|
|
12
|
+
namespace: string;
|
|
13
|
+
token: string;
|
|
14
|
+
expiresAt: string;
|
|
15
|
+
};
|
|
16
|
+
operationId: string;
|
|
17
|
+
}
|
|
18
|
+
export declare class HostApiError extends Error {
|
|
19
|
+
readonly status?: number | undefined;
|
|
20
|
+
readonly operationId?: string | undefined;
|
|
21
|
+
readonly retryAt?: string | undefined;
|
|
22
|
+
readonly code?: string | undefined;
|
|
23
|
+
constructor(message: string, status?: number | undefined, operationId?: string | undefined, retryAt?: string | undefined, code?: string | undefined);
|
|
24
|
+
}
|
|
25
|
+
export declare function hostRequest(path: string, method?: string, body?: unknown, connection?: {
|
|
26
|
+
remote: string;
|
|
27
|
+
token: string | null;
|
|
28
|
+
}): Promise<any>;
|
|
29
|
+
export declare function hostApiPath(namespace: string): string;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { resolveRemote, resolveToken } from "../config.js";
|
|
2
|
+
const SAFE_POWER_CODES = new Set([
|
|
3
|
+
"host_power_unsupported", "provider_binding_ambiguous", "enrollment_not_provider_bound",
|
|
4
|
+
"provider_binding_revoked", "enrollment_revoked", "active_work_present", "request_id_conflict",
|
|
5
|
+
"invalid_power_request", "invalid_request_id", "volume_disposition_required", "host_lifecycle_unavailable",
|
|
6
|
+
]);
|
|
7
|
+
export class HostApiError extends Error {
|
|
8
|
+
status;
|
|
9
|
+
operationId;
|
|
10
|
+
retryAt;
|
|
11
|
+
code;
|
|
12
|
+
constructor(message, status, operationId, retryAt, code) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.status = status;
|
|
15
|
+
this.operationId = operationId;
|
|
16
|
+
this.retryAt = retryAt;
|
|
17
|
+
this.code = code;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export async function hostRequest(path, method = "GET", body, connection) {
|
|
21
|
+
const token = connection ? connection.token : resolveToken();
|
|
22
|
+
if (!token)
|
|
23
|
+
throw new Error("Log in to DreamLake before enrolling or inspecting a host");
|
|
24
|
+
let result;
|
|
25
|
+
try {
|
|
26
|
+
result = await fetch(`${connection?.remote ?? resolveRemote()}${path}`, {
|
|
27
|
+
method,
|
|
28
|
+
headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
|
|
29
|
+
body: body === undefined ? undefined : JSON.stringify(body),
|
|
30
|
+
signal: AbortSignal.timeout(30_000),
|
|
31
|
+
redirect: "error",
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
throw new HostApiError("Host API could not be reached; the outcome of a submitted write may be unknown");
|
|
36
|
+
}
|
|
37
|
+
// Do not echo backend errors that may contain grants or credentials.
|
|
38
|
+
if (!result.ok) {
|
|
39
|
+
const data = await result.json().catch(() => ({}));
|
|
40
|
+
const operationId = typeof data.operationId === "string" && /^[a-f0-9]{24}$/i.test(data.operationId) ? data.operationId : undefined;
|
|
41
|
+
const retryAt = typeof data.retryAt === "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(data.retryAt) && Number.isFinite(Date.parse(data.retryAt)) ? data.retryAt : undefined;
|
|
42
|
+
const code = typeof data.code === "string" && SAFE_POWER_CODES.has(data.code) ? data.code : undefined;
|
|
43
|
+
throw new HostApiError(`Host API request failed (HTTP ${result.status})${code ? `: ${code}` : ""}`, result.status, operationId, retryAt, code);
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
return await result.json();
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
throw new Error("Host API returned invalid JSON");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export function hostApiPath(namespace) {
|
|
53
|
+
return `/namespaces/${encodeURIComponent(namespace)}/hosts`;
|
|
54
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const BOOTSTRAP_PYTHON = "import base64, fcntl, pwd, hashlib, json, os, pathlib, shutil, subprocess, sys, tempfile, re, urllib.request, plistlib\n\ndef run(args, **kwargs):\n return subprocess.run(args, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs)\ndef prerequisite_error(code):\n print(json.dumps({'code': code}))\n sys.exit(1)\ndef openssl_binary():\n # Apple's bundled LibreSSL does not reliably support Ed25519 DER keys.\n candidates = ([str(pathlib.Path.home() / '.local/bin/openssl'),\n '/opt/homebrew/opt/openssl@3/bin/openssl',\n '/usr/local/opt/openssl@3/bin/openssl'] if sys.platform == 'darwin' else [])\n candidates.append(shutil.which('openssl'))\n for binary in candidates:\n if not binary or not os.access(binary, os.X_OK):\n continue\n try:\n result = run([binary, 'pkey', '-inform', 'DER', '-pubout', '-outform', 'DER'],\n input=bytes.fromhex('302e020100300506032b657004220420') + bytes(32)).stdout\n if len(result) == 44 and result[:12] == bytes.fromhex('302a300506032b6570032100'):\n return binary\n except Exception:\n pass\n prerequisite_error('openssl_ed25519_required')\n\ndef check_prerequisites():\n openssl = openssl_binary()\n if sys.platform == 'darwin':\n if os.getuid() == 0:\n prerequisite_error('macos_user_required')\n try:\n run(['launchctl', 'print', 'gui/' + str(os.getuid())])\n except Exception:\n prerequisite_error('launchd_gui_unavailable')\n return openssl\n if sys.platform != 'linux':\n prerequisite_error('platform_unsupported')\n try:\n run(['systemctl', '--user', 'show-environment'])\n except Exception:\n prerequisite_error('systemd_user_unavailable')\n try:\n linger = run(['loginctl', 'show-user', pwd.getpwuid(os.getuid()).pw_name, '-p', 'Linger', '--value']).stdout.strip()\n except Exception:\n prerequisite_error('linger_unavailable')\n if linger != b'yes':\n prerequisite_error('linger_required')\n return openssl\ndef write(path, value):\n fd, tmp = tempfile.mkstemp(dir=str(path.parent))\n try:\n os.fchmod(fd, 0o600)\n with os.fdopen(fd, 'w') as f: f.write(value)\n os.replace(tmp, path)\n finally:\n if os.path.exists(tmp): os.unlink(tmp)\ndef nymph_binary(p, home):\n binary = shutil.which('nymph')\n if not binary:\n bindir = home / '.local/bin'\n bindir.mkdir(parents=True, exist_ok=True)\n binary = str(bindir / 'nymph')\n if not pathlib.Path(binary).exists():\n with urllib.request.urlopen('https://dreamlake.ai/dreamlake/nymph/install.sh', timeout=30) as response:\n installer = response.read()\n # Published immutable release directories use v-prefixed tags.\n version = p.get('version', 'latest')\n if re.fullmatch(r'\\d+\\.\\d+\\.\\d+(?:-[A-Za-z0-9.-]+)?', version):\n version = 'v' + version\n run(['bash','-s','--','--dest',str(bindir),'--version',version], input=installer)\n return binary\n\ndef main():\n p = json.load(sys.stdin)\n # Check before identity creation or requesting an enrollment grant.\n openssl = check_prerequisites()\n home = pathlib.Path.home()\n root = home / '.local/state/dreamlake/hosts' / hashlib.sha256(p['name'].encode()).hexdigest()\n root.mkdir(parents=True, exist_ok=True, mode=0o700)\n os.chmod(root, 0o700)\n with open(root / 'lock', 'a') as lock:\n fcntl.flock(lock, fcntl.LOCK_EX)\n if p.get('managedAccess'):\n binary = nymph_binary(p, home)\n try: run([binary, 'access', '--help'])\n except Exception: prerequisite_error('nymph_access_version_required')\n if (root / 'nymph.toml').exists() and not (root / 'access.json').exists():\n prerequisite_error('nymph_access_migration_required')\n key = root / 'identity.key'\n if not key.exists(): write(key, base64.urlsafe_b64encode(os.urandom(32)).decode().rstrip('='))\n os.chmod(key, 0o600)\n raw = base64.urlsafe_b64decode(key.read_text().strip() + '==')\n if len(raw) != 32: raise RuntimeError('identity format')\n public = run([openssl,'pkey','-inform','DER','-pubout','-outform','DER'], input=bytes.fromhex('302e020100300506032b657004220420') + raw).stdout\n if len(public) != 44 or public[:12] != bytes.fromhex('302a300506032b6570032100'): raise RuntimeError('public format')\n public_key = base64.urlsafe_b64encode(public[12:]).decode().rstrip('=')\n if p['action'] == 'probe':\n print(json.dumps({'unixUser':pwd.getpwuid(os.getuid()).pw_name,'publicKey':public_key}))\n return\n if public_key != p['publicKey']: raise RuntimeError('identity changed')\n # Never fall back to a privileged system unit or an unsupervised daemon.\n binary = nymph_binary(p, home)\n web_terminal = p.get('webTerminal', True)\n if not isinstance(web_terminal, bool): raise RuntimeError('invalid web terminal option')\n sshd = '/usr/sbin/sshd'\n if web_terminal:\n if not os.access(sshd, os.X_OK): prerequisite_error('sshd_required')\n try: run([sshd, '-V'])\n except Exception: prerequisite_error('sshd_required')\n version = run([binary, '--version']).stdout.decode('utf8', errors='replace')\n match = re.search(r'\\b(\\d+)\\.(\\d+)\\.(\\d+)\\b', version)\n if not match or tuple(map(int, match.groups())) < (0, 1, 11):\n prerequisite_error('nymph_ssh_version_required')\n if sys.platform == 'linux':\n privilege_dir = pathlib.Path('/run/sshd')\n if not privilege_dir.is_dir() or privilege_dir.stat().st_uid != 0 or privilege_dir.stat().st_mode & 0o022:\n prerequisite_error('sshd_privilege_directory_required')\n (root / 'ssh').mkdir(exist_ok=True, mode=0o700)\n os.chmod(root / 'ssh', 0o700)\n grant = root / 'enroll-token'\n if p.get('token'): write(grant, p['token'])\n q = json.dumps\n config = '\\n'.join([\n '[server]', 'url = ' + q(p['controlPlaneUrl']), 'namespace = ' + q(p['namespace']),\n '[daemon]', 'machine_id = ' + q(p['machineId']), 'label = ' + q(p['name']),\n '[runtime]', 'keep_alive_s = -1', 'workdir = ' + q(str(root / 'work')), 'runners = [\"process\"]', 'default_runner = \"process\"',\n '[identity]', 'enabled = true', 'key_file = ' + q(str(key)), 'enroll_token_file = ' + q(str(grant)),\n ]) + '\\n'\n if p.get('managedAccess'):\n access = root / 'access.json'\n if not access.exists():\n write(access, json.dumps({'version': 1, 'scope': {'server': p['controlPlaneUrl'], 'namespace': p['namespace'], 'machine_id': p['machineId']}, 'permissions': {'upload': False, 'command_execution': False}}))\n config = 'access_file = ' + q(str(access)) + '\\n' + config\n if web_terminal:\n config += '\\n'.join(['[ssh]', 'enabled = true', 'state_dir = ' + q(str(root / 'ssh')),\n 'sshd = ' + q(sshd), 'max_duration_s = 3600']) + '\\n'\n (root / 'work').mkdir(exist_ok=True)\n config_file = root / 'nymph.toml'\n changed = not config_file.exists() or config_file.read_text() != config\n reload_marker = root / 'launchd-reload-required'\n if sys.platform == 'darwin' and changed:\n write(reload_marker, 'pending')\n write(config_file, config)\n service_path = str(home / '.local/bin') + (':/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin' if sys.platform == 'darwin' else ':/usr/local/bin:/usr/bin:/bin')\n if sys.platform == 'darwin':\n label = 'ai.dreamlake.host.' + hashlib.sha256(p['name'].encode()).hexdigest()[:24]\n domain = 'gui/' + str(os.getuid())\n target = domain + '/' + label\n agents = home / 'Library/LaunchAgents'\n agents.mkdir(parents=True, exist_ok=True)\n agent_file = agents / (label + '.plist')\n agent = plistlib.dumps({\n 'Label': label,\n 'ProgramArguments': [binary, '--config', str(config_file)],\n 'EnvironmentVariables': {'PATH': service_path, 'HOME': str(home)},\n 'WorkingDirectory': str(root / 'work'),\n 'RunAtLoad': True,\n 'KeepAlive': True,\n 'ThrottleInterval': 3,\n # Daemon output can contain sensitive workloads: do not persist it.\n 'StandardOutPath': '/dev/null',\n 'StandardErrorPath': '/dev/null',\n }, sort_keys=True).decode('utf8')\n changed = changed or not agent_file.exists() or agent_file.read_text() != agent or reload_marker.exists()\n if changed:\n write(reload_marker, 'pending')\n # Unload before replacing a loaded definition. Never ignore bootout failure.\n loaded = subprocess.run(['launchctl', 'print', target], stdout=subprocess.DEVNULL,\n stderr=subprocess.DEVNULL).returncode == 0\n if loaded and changed:\n run(['launchctl', 'bootout', target])\n loaded = False\n write(agent_file, agent)\n run(['launchctl', 'enable', target])\n if not loaded:\n run(['launchctl', 'bootstrap', domain, str(agent_file)])\n # No -k: replay must not kill a healthy daemon or its active workloads.\n run(['launchctl', 'kickstart', target])\n run(['launchctl', 'print', target])\n if reload_marker.exists():\n reload_marker.unlink()\n else:\n # JSON string escaping covers quoted systemd arguments; percent must be escaped separately.\n unit_quote = lambda s: q(s.replace('%','%%'))\n unit_name = 'dreamlake-host-' + hashlib.sha256(p['name'].encode()).hexdigest()[:24] + '.service'\n unit_dir = home / '.config/systemd/user'\n unit_dir.mkdir(parents=True, exist_ok=True)\n unit = '[Unit]\\nDescription=DreamLake nymph host\\n[Service]\\nEnvironment=' + unit_quote('PATH=' + service_path) + '\\nExecStart=' + unit_quote(binary) + ' --config ' + unit_quote(str(config_file)) + '\\nRestart=on-failure\\nRestartSec=3\\n[Install]\\nWantedBy=default.target\\n'\n unit_file = unit_dir / unit_name\n changed = changed or not unit_file.exists() or unit_file.read_text() != unit\n write(unit_file, unit)\n run(['systemctl','--user','daemon-reload'])\n run(['systemctl','--user','enable',unit_name])\n run(['systemctl','--user','restart' if changed else 'start',unit_name])\n print(json.dumps({'started':True}))\ntry:\n main()\nexcept Exception:\n # Never forward child stdout/stderr or payloads: these can contain grants.\n print(json.dumps({'error':'Remote bootstrap failed. Verify Python 3, OpenSSL, the platform user-service manager, OpenSSL Ed25519 support, and nymph installation access.'}))\n sys.exit(1)\n";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// Generated by scripts/gen-host-bootstrap.mjs from bootstrap.py.
|
|
2
|
+
export const BOOTSTRAP_PYTHON = "import base64, fcntl, pwd, hashlib, json, os, pathlib, shutil, subprocess, sys, tempfile, re, urllib.request, plistlib\n\ndef run(args, **kwargs):\n return subprocess.run(args, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs)\ndef prerequisite_error(code):\n print(json.dumps({'code': code}))\n sys.exit(1)\ndef openssl_binary():\n # Apple's bundled LibreSSL does not reliably support Ed25519 DER keys.\n candidates = ([str(pathlib.Path.home() / '.local/bin/openssl'),\n '/opt/homebrew/opt/openssl@3/bin/openssl',\n '/usr/local/opt/openssl@3/bin/openssl'] if sys.platform == 'darwin' else [])\n candidates.append(shutil.which('openssl'))\n for binary in candidates:\n if not binary or not os.access(binary, os.X_OK):\n continue\n try:\n result = run([binary, 'pkey', '-inform', 'DER', '-pubout', '-outform', 'DER'],\n input=bytes.fromhex('302e020100300506032b657004220420') + bytes(32)).stdout\n if len(result) == 44 and result[:12] == bytes.fromhex('302a300506032b6570032100'):\n return binary\n except Exception:\n pass\n prerequisite_error('openssl_ed25519_required')\n\ndef check_prerequisites():\n openssl = openssl_binary()\n if sys.platform == 'darwin':\n if os.getuid() == 0:\n prerequisite_error('macos_user_required')\n try:\n run(['launchctl', 'print', 'gui/' + str(os.getuid())])\n except Exception:\n prerequisite_error('launchd_gui_unavailable')\n return openssl\n if sys.platform != 'linux':\n prerequisite_error('platform_unsupported')\n try:\n run(['systemctl', '--user', 'show-environment'])\n except Exception:\n prerequisite_error('systemd_user_unavailable')\n try:\n linger = run(['loginctl', 'show-user', pwd.getpwuid(os.getuid()).pw_name, '-p', 'Linger', '--value']).stdout.strip()\n except Exception:\n prerequisite_error('linger_unavailable')\n if linger != b'yes':\n prerequisite_error('linger_required')\n return openssl\ndef write(path, value):\n fd, tmp = tempfile.mkstemp(dir=str(path.parent))\n try:\n os.fchmod(fd, 0o600)\n with os.fdopen(fd, 'w') as f: f.write(value)\n os.replace(tmp, path)\n finally:\n if os.path.exists(tmp): os.unlink(tmp)\ndef nymph_binary(p, home):\n binary = shutil.which('nymph')\n if not binary:\n bindir = home / '.local/bin'\n bindir.mkdir(parents=True, exist_ok=True)\n binary = str(bindir / 'nymph')\n if not pathlib.Path(binary).exists():\n with urllib.request.urlopen('https://dreamlake.ai/dreamlake/nymph/install.sh', timeout=30) as response:\n installer = response.read()\n # Published immutable release directories use v-prefixed tags.\n version = p.get('version', 'latest')\n if re.fullmatch(r'\\d+\\.\\d+\\.\\d+(?:-[A-Za-z0-9.-]+)?', version):\n version = 'v' + version\n run(['bash','-s','--','--dest',str(bindir),'--version',version], input=installer)\n return binary\n\ndef main():\n p = json.load(sys.stdin)\n # Check before identity creation or requesting an enrollment grant.\n openssl = check_prerequisites()\n home = pathlib.Path.home()\n root = home / '.local/state/dreamlake/hosts' / hashlib.sha256(p['name'].encode()).hexdigest()\n root.mkdir(parents=True, exist_ok=True, mode=0o700)\n os.chmod(root, 0o700)\n with open(root / 'lock', 'a') as lock:\n fcntl.flock(lock, fcntl.LOCK_EX)\n if p.get('managedAccess'):\n binary = nymph_binary(p, home)\n try: run([binary, 'access', '--help'])\n except Exception: prerequisite_error('nymph_access_version_required')\n if (root / 'nymph.toml').exists() and not (root / 'access.json').exists():\n prerequisite_error('nymph_access_migration_required')\n key = root / 'identity.key'\n if not key.exists(): write(key, base64.urlsafe_b64encode(os.urandom(32)).decode().rstrip('='))\n os.chmod(key, 0o600)\n raw = base64.urlsafe_b64decode(key.read_text().strip() + '==')\n if len(raw) != 32: raise RuntimeError('identity format')\n public = run([openssl,'pkey','-inform','DER','-pubout','-outform','DER'], input=bytes.fromhex('302e020100300506032b657004220420') + raw).stdout\n if len(public) != 44 or public[:12] != bytes.fromhex('302a300506032b6570032100'): raise RuntimeError('public format')\n public_key = base64.urlsafe_b64encode(public[12:]).decode().rstrip('=')\n if p['action'] == 'probe':\n print(json.dumps({'unixUser':pwd.getpwuid(os.getuid()).pw_name,'publicKey':public_key}))\n return\n if public_key != p['publicKey']: raise RuntimeError('identity changed')\n # Never fall back to a privileged system unit or an unsupervised daemon.\n binary = nymph_binary(p, home)\n web_terminal = p.get('webTerminal', True)\n if not isinstance(web_terminal, bool): raise RuntimeError('invalid web terminal option')\n sshd = '/usr/sbin/sshd'\n if web_terminal:\n if not os.access(sshd, os.X_OK): prerequisite_error('sshd_required')\n try: run([sshd, '-V'])\n except Exception: prerequisite_error('sshd_required')\n version = run([binary, '--version']).stdout.decode('utf8', errors='replace')\n match = re.search(r'\\b(\\d+)\\.(\\d+)\\.(\\d+)\\b', version)\n if not match or tuple(map(int, match.groups())) < (0, 1, 11):\n prerequisite_error('nymph_ssh_version_required')\n if sys.platform == 'linux':\n privilege_dir = pathlib.Path('/run/sshd')\n if not privilege_dir.is_dir() or privilege_dir.stat().st_uid != 0 or privilege_dir.stat().st_mode & 0o022:\n prerequisite_error('sshd_privilege_directory_required')\n (root / 'ssh').mkdir(exist_ok=True, mode=0o700)\n os.chmod(root / 'ssh', 0o700)\n grant = root / 'enroll-token'\n if p.get('token'): write(grant, p['token'])\n q = json.dumps\n config = '\\n'.join([\n '[server]', 'url = ' + q(p['controlPlaneUrl']), 'namespace = ' + q(p['namespace']),\n '[daemon]', 'machine_id = ' + q(p['machineId']), 'label = ' + q(p['name']),\n '[runtime]', 'keep_alive_s = -1', 'workdir = ' + q(str(root / 'work')), 'runners = [\"process\"]', 'default_runner = \"process\"',\n '[identity]', 'enabled = true', 'key_file = ' + q(str(key)), 'enroll_token_file = ' + q(str(grant)),\n ]) + '\\n'\n if p.get('managedAccess'):\n access = root / 'access.json'\n if not access.exists():\n write(access, json.dumps({'version': 1, 'scope': {'server': p['controlPlaneUrl'], 'namespace': p['namespace'], 'machine_id': p['machineId']}, 'permissions': {'upload': False, 'command_execution': False}}))\n config = 'access_file = ' + q(str(access)) + '\\n' + config\n if web_terminal:\n config += '\\n'.join(['[ssh]', 'enabled = true', 'state_dir = ' + q(str(root / 'ssh')),\n 'sshd = ' + q(sshd), 'max_duration_s = 3600']) + '\\n'\n (root / 'work').mkdir(exist_ok=True)\n config_file = root / 'nymph.toml'\n changed = not config_file.exists() or config_file.read_text() != config\n reload_marker = root / 'launchd-reload-required'\n if sys.platform == 'darwin' and changed:\n write(reload_marker, 'pending')\n write(config_file, config)\n service_path = str(home / '.local/bin') + (':/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin' if sys.platform == 'darwin' else ':/usr/local/bin:/usr/bin:/bin')\n if sys.platform == 'darwin':\n label = 'ai.dreamlake.host.' + hashlib.sha256(p['name'].encode()).hexdigest()[:24]\n domain = 'gui/' + str(os.getuid())\n target = domain + '/' + label\n agents = home / 'Library/LaunchAgents'\n agents.mkdir(parents=True, exist_ok=True)\n agent_file = agents / (label + '.plist')\n agent = plistlib.dumps({\n 'Label': label,\n 'ProgramArguments': [binary, '--config', str(config_file)],\n 'EnvironmentVariables': {'PATH': service_path, 'HOME': str(home)},\n 'WorkingDirectory': str(root / 'work'),\n 'RunAtLoad': True,\n 'KeepAlive': True,\n 'ThrottleInterval': 3,\n # Daemon output can contain sensitive workloads: do not persist it.\n 'StandardOutPath': '/dev/null',\n 'StandardErrorPath': '/dev/null',\n }, sort_keys=True).decode('utf8')\n changed = changed or not agent_file.exists() or agent_file.read_text() != agent or reload_marker.exists()\n if changed:\n write(reload_marker, 'pending')\n # Unload before replacing a loaded definition. Never ignore bootout failure.\n loaded = subprocess.run(['launchctl', 'print', target], stdout=subprocess.DEVNULL,\n stderr=subprocess.DEVNULL).returncode == 0\n if loaded and changed:\n run(['launchctl', 'bootout', target])\n loaded = False\n write(agent_file, agent)\n run(['launchctl', 'enable', target])\n if not loaded:\n run(['launchctl', 'bootstrap', domain, str(agent_file)])\n # No -k: replay must not kill a healthy daemon or its active workloads.\n run(['launchctl', 'kickstart', target])\n run(['launchctl', 'print', target])\n if reload_marker.exists():\n reload_marker.unlink()\n else:\n # JSON string escaping covers quoted systemd arguments; percent must be escaped separately.\n unit_quote = lambda s: q(s.replace('%','%%'))\n unit_name = 'dreamlake-host-' + hashlib.sha256(p['name'].encode()).hexdigest()[:24] + '.service'\n unit_dir = home / '.config/systemd/user'\n unit_dir.mkdir(parents=True, exist_ok=True)\n unit = '[Unit]\\nDescription=DreamLake nymph host\\n[Service]\\nEnvironment=' + unit_quote('PATH=' + service_path) + '\\nExecStart=' + unit_quote(binary) + ' --config ' + unit_quote(str(config_file)) + '\\nRestart=on-failure\\nRestartSec=3\\n[Install]\\nWantedBy=default.target\\n'\n unit_file = unit_dir / unit_name\n changed = changed or not unit_file.exists() or unit_file.read_text() != unit\n write(unit_file, unit)\n run(['systemctl','--user','daemon-reload'])\n run(['systemctl','--user','enable',unit_name])\n run(['systemctl','--user','restart' if changed else 'start',unit_name])\n print(json.dumps({'started':True}))\ntry:\n main()\nexcept Exception:\n # Never forward child stdout/stderr or payloads: these can contain grants.\n print(json.dumps({'error':'Remote bootstrap failed. Verify Python 3, OpenSSL, the platform user-service manager, OpenSSL Ed25519 support, and nymph installation access.'}))\n sys.exit(1)\n";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { hostRequest } from "./api.js";
|
|
2
|
+
export interface HostCatalogState {
|
|
3
|
+
hostId: string;
|
|
4
|
+
namespaceId: string;
|
|
5
|
+
catalogState: "active" | "archived";
|
|
6
|
+
revision: number;
|
|
7
|
+
archivedAt: string | null;
|
|
8
|
+
executionAffected: false;
|
|
9
|
+
retirementSupported: false;
|
|
10
|
+
}
|
|
11
|
+
export interface HostCatalogReceipt extends HostCatalogState {
|
|
12
|
+
operationId: string;
|
|
13
|
+
requestId: string;
|
|
14
|
+
action: "archive" | "restore";
|
|
15
|
+
recordedAt: string;
|
|
16
|
+
replayed: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare function inspectHostCatalog(hostId: string, opts: {
|
|
19
|
+
namespace?: string;
|
|
20
|
+
}, request?: typeof hostRequest): Promise<HostCatalogState>;
|
|
21
|
+
export declare function changeHostCatalog(hostId: string, action: "archive" | "restore", opts: {
|
|
22
|
+
namespace?: string;
|
|
23
|
+
requestId: string;
|
|
24
|
+
expectedRevision: string;
|
|
25
|
+
}, request?: typeof hostRequest): Promise<HostCatalogReceipt>;
|
|
26
|
+
export declare function formatHostCatalog(value: HostCatalogState | HostCatalogReceipt): string;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { hostApiPath, hostRequest } from "./api.js";
|
|
2
|
+
import { resolveHostNamespace } from "./inventory.js";
|
|
3
|
+
function exactHost(id) {
|
|
4
|
+
if (!/^[a-f0-9]{24}$/.test(id))
|
|
5
|
+
throw new Error("Use one exact lowercase 24-character Host ID; names and wildcards are not accepted");
|
|
6
|
+
}
|
|
7
|
+
function iso(value) {
|
|
8
|
+
return typeof value === "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(value) &&
|
|
9
|
+
Number.isFinite(Date.parse(value)) && new Date(value).toISOString() === value;
|
|
10
|
+
}
|
|
11
|
+
function state(value, hostId) {
|
|
12
|
+
if (!value || value.hostId !== hostId || typeof value.namespaceId !== "string" ||
|
|
13
|
+
!["active", "archived"].includes(value.catalogState) || !Number.isInteger(value.revision) || value.revision < 0 || value.revision > 2147483647 ||
|
|
14
|
+
value.executionAffected !== false || value.retirementSupported !== false ||
|
|
15
|
+
(value.catalogState === "active" ? value.archivedAt !== null : !iso(value.archivedAt))) {
|
|
16
|
+
throw new Error("Host API returned an invalid catalog state");
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export async function inspectHostCatalog(hostId, opts, request = hostRequest) {
|
|
20
|
+
exactHost(hostId);
|
|
21
|
+
const namespace = await resolveHostNamespace(opts.namespace);
|
|
22
|
+
const result = await request(`${hostApiPath(namespace)}/${hostId}/lifecycle`);
|
|
23
|
+
state(result, hostId);
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
export async function changeHostCatalog(hostId, action, opts, request = hostRequest) {
|
|
27
|
+
exactHost(hostId);
|
|
28
|
+
if (typeof opts.requestId !== "string" || typeof opts.expectedRevision !== "string" ||
|
|
29
|
+
!/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,127}$/.test(opts.requestId) || !/^(0|[1-9][0-9]*)$/.test(opts.expectedRevision) ||
|
|
30
|
+
Number(opts.expectedRevision) >= 2147483647)
|
|
31
|
+
throw new Error("Use a valid --request-id and --expected-revision between 0 and 2147483646");
|
|
32
|
+
const namespace = await resolveHostNamespace(opts.namespace);
|
|
33
|
+
// One submission; an ambiguous response is retried only by the user with the
|
|
34
|
+
// SAME request ID, action, host and expected revision. Never auto-refresh CAS.
|
|
35
|
+
const result = await request(`${hostApiPath(namespace)}/${hostId}/${action}`, "POST", {
|
|
36
|
+
requestId: opts.requestId, expectedRevision: Number(opts.expectedRevision),
|
|
37
|
+
});
|
|
38
|
+
state(result, hostId);
|
|
39
|
+
const receipt = result;
|
|
40
|
+
if (receipt.action !== action || receipt.requestId !== opts.requestId || !/^[a-f0-9]{64}$/.test(receipt.operationId) ||
|
|
41
|
+
receipt.revision !== Number(opts.expectedRevision) + 1 || typeof receipt.replayed !== "boolean" ||
|
|
42
|
+
receipt.catalogState !== (action === "archive" ? "archived" : "active") || !iso(receipt.recordedAt))
|
|
43
|
+
throw new Error("Host API returned an invalid catalog operation receipt");
|
|
44
|
+
return receipt;
|
|
45
|
+
}
|
|
46
|
+
export function formatHostCatalog(value) {
|
|
47
|
+
return [
|
|
48
|
+
`Host ID: ${value.hostId}`, `Catalog: ${value.catalogState}`, `Revision: ${value.revision}`,
|
|
49
|
+
`Archived at: ${value.archivedAt ?? "not archived"}`,
|
|
50
|
+
...("requestId" in value ? [`Request ID: ${value.requestId}`, `Operation ID: ${value.operationId}`, `Replayed: ${value.replayed ? "yes" : "no"}`] : []),
|
|
51
|
+
...("replayed" in value && value.replayed ? ["Stored receipt from the original action; use hosts lifecycle for current catalog state."] : []),
|
|
52
|
+
"Catalog visibility only. Runtime, enrollments and credentials remain active; future work is still permitted.",
|
|
53
|
+
"This does not retire a host or verify inactivity.",
|
|
54
|
+
].join("\n");
|
|
55
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export interface EnrollOptions {
|
|
2
|
+
/** Separate local consent; requires Nymph access policy support. */
|
|
3
|
+
managedAccess?: boolean;
|
|
4
|
+
name?: string;
|
|
5
|
+
prefix?: string;
|
|
6
|
+
ssh?: string;
|
|
7
|
+
local?: boolean;
|
|
8
|
+
config?: string;
|
|
9
|
+
json?: boolean;
|
|
10
|
+
dryRun?: boolean;
|
|
11
|
+
saveCredentials?: boolean;
|
|
12
|
+
quiet?: boolean;
|
|
13
|
+
targetPassword?: string[];
|
|
14
|
+
targetKey?: string[];
|
|
15
|
+
jumpPassword?: string[];
|
|
16
|
+
jumpKey?: string[];
|
|
17
|
+
passwordFd?: string[];
|
|
18
|
+
waitSeconds?: string | number;
|
|
19
|
+
requestId?: string;
|
|
20
|
+
lakeshoreId?: string;
|
|
21
|
+
nymphVersion?: string;
|
|
22
|
+
webTerminal?: boolean;
|
|
23
|
+
}
|
|
24
|
+
interface EnrollmentIdentity {
|
|
25
|
+
name: string;
|
|
26
|
+
webTerminal: boolean;
|
|
27
|
+
namespace: string;
|
|
28
|
+
group: string;
|
|
29
|
+
hostName: string;
|
|
30
|
+
}
|
|
31
|
+
export type EnrollmentPlan = EnrollmentIdentity & ({
|
|
32
|
+
local: true;
|
|
33
|
+
ssh?: never;
|
|
34
|
+
} | {
|
|
35
|
+
local?: false;
|
|
36
|
+
ssh: {
|
|
37
|
+
executable: "ssh";
|
|
38
|
+
args: string[];
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
/** Tokenize argument text, without expansion, shell execution, or eval. */
|
|
42
|
+
export declare function splitSshArguments(input: string): string[];
|
|
43
|
+
export declare function validateSshArguments(args: string[]): string[];
|
|
44
|
+
export declare function resolveEnrollment(opts: EnrollOptions): EnrollmentPlan;
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
function object(value, label) {
|
|
3
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
4
|
+
throw new Error(`${label} must be an object`);
|
|
5
|
+
return value;
|
|
6
|
+
}
|
|
7
|
+
function keys(value, allowed, label) {
|
|
8
|
+
for (const key of Object.keys(value))
|
|
9
|
+
if (!allowed.includes(key))
|
|
10
|
+
throw new Error(`unknown ${label} field`);
|
|
11
|
+
}
|
|
12
|
+
function string(value, label) {
|
|
13
|
+
if (typeof value !== "string" || !value.trim() || /[\x00-\x1f\x7f]/.test(value))
|
|
14
|
+
throw new Error(`${label} must be a nonempty string without control characters`);
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
/** Tokenize argument text, without expansion, shell execution, or eval. */
|
|
18
|
+
export function splitSshArguments(input) {
|
|
19
|
+
const result = [];
|
|
20
|
+
let token = "", quote = "", started = false;
|
|
21
|
+
for (let i = 0; i < input.length; i++) {
|
|
22
|
+
const c = input[i];
|
|
23
|
+
if (c === "\\" && quote !== "'") {
|
|
24
|
+
const next = input[++i];
|
|
25
|
+
if (next === undefined)
|
|
26
|
+
throw new Error("--ssh has a trailing escape");
|
|
27
|
+
if (next !== "\n") {
|
|
28
|
+
token += next;
|
|
29
|
+
started = true;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else if (quote) {
|
|
33
|
+
if (c === quote)
|
|
34
|
+
quote = "";
|
|
35
|
+
else
|
|
36
|
+
token += c;
|
|
37
|
+
}
|
|
38
|
+
else if (c === "'" || c === '"') {
|
|
39
|
+
quote = c;
|
|
40
|
+
started = true;
|
|
41
|
+
}
|
|
42
|
+
else if (/\s/.test(c)) {
|
|
43
|
+
if (started) {
|
|
44
|
+
result.push(token);
|
|
45
|
+
token = "";
|
|
46
|
+
started = false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
token += c;
|
|
51
|
+
started = true;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (quote)
|
|
55
|
+
throw new Error("--ssh has an unterminated quote");
|
|
56
|
+
if (started)
|
|
57
|
+
result.push(token);
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
// A deliberately bounded bootstrap surface. Arbitrary -o options can launch
|
|
61
|
+
// local processes or change SSH into forwarding/config-query mode.
|
|
62
|
+
const SSH_OPTIONS = new Set(["BatchMode", "ServerAliveInterval", "ServerAliveCountMax", "ConnectTimeout", "IdentitiesOnly", "StrictHostKeyChecking", "UserKnownHostsFile"]);
|
|
63
|
+
function option(value) {
|
|
64
|
+
const match = /^([A-Za-z]+)=(.+)$/.exec(value);
|
|
65
|
+
if (!match || !SSH_OPTIONS.has(match[1]))
|
|
66
|
+
throw new Error("unsupported SSH option; configure advanced transport in ~/.ssh/config");
|
|
67
|
+
string(value, "SSH option");
|
|
68
|
+
}
|
|
69
|
+
function port(value) {
|
|
70
|
+
if (!/^\d+$/.test(value) || Number(value) < 1 || Number(value) > 65535)
|
|
71
|
+
throw new Error("SSH port must be an integer from 1 to 65535");
|
|
72
|
+
}
|
|
73
|
+
function destination(value) {
|
|
74
|
+
if (!/^(?:[A-Za-z0-9_.-]+@)?[A-Za-z0-9_\[][A-Za-z0-9_.:\[\]-]*$/.test(value))
|
|
75
|
+
throw new Error("SSH destination must be an alias, hostname, or user@host");
|
|
76
|
+
}
|
|
77
|
+
export function validateSshArguments(args) {
|
|
78
|
+
if (!args.length)
|
|
79
|
+
throw new Error("--ssh requires a destination");
|
|
80
|
+
let i = 0;
|
|
81
|
+
while (i < args.length - 1) {
|
|
82
|
+
const flag = args[i++];
|
|
83
|
+
if (!["-i", "-J", "-p", "-o", "-l", "-F"].includes(flag))
|
|
84
|
+
throw new Error("unsupported SSH argument; use separate option values and no remote command");
|
|
85
|
+
const value = args[i++];
|
|
86
|
+
if (value === undefined || i === args.length)
|
|
87
|
+
throw new Error(`${flag} requires a value followed by an SSH destination`);
|
|
88
|
+
string(value, flag);
|
|
89
|
+
if (value.startsWith("-"))
|
|
90
|
+
throw new Error(`${flag} value cannot start with '-'`);
|
|
91
|
+
if (flag === "-p")
|
|
92
|
+
port(value);
|
|
93
|
+
if (flag === "-o")
|
|
94
|
+
option(value);
|
|
95
|
+
if (flag === "-l" && !/^[A-Za-z0-9_.-]+$/.test(value))
|
|
96
|
+
throw new Error("invalid SSH user");
|
|
97
|
+
if (flag === "-J" && !/^[A-Za-z0-9_@.,:\[\]-]+$/.test(value))
|
|
98
|
+
throw new Error("invalid SSH jump host");
|
|
99
|
+
}
|
|
100
|
+
if (i !== args.length - 1)
|
|
101
|
+
throw new Error("--ssh requires exactly one destination and no remote command");
|
|
102
|
+
destination(args[i]);
|
|
103
|
+
return args;
|
|
104
|
+
}
|
|
105
|
+
function structuredSsh(value) {
|
|
106
|
+
const ssh = object(value, "ssh");
|
|
107
|
+
keys(ssh, ["host", "user", "port", "identityFile", "jumpHost", "options"], "ssh");
|
|
108
|
+
const args = [];
|
|
109
|
+
if (ssh.port !== undefined) {
|
|
110
|
+
if (typeof ssh.port !== "number" || !Number.isInteger(ssh.port))
|
|
111
|
+
throw new Error("ssh.port must be an integer");
|
|
112
|
+
args.push("-p", String(ssh.port));
|
|
113
|
+
}
|
|
114
|
+
for (const [field, flag] of [["identityFile", "-i"], ["jumpHost", "-J"], ["user", "-l"]]) {
|
|
115
|
+
if (ssh[field] !== undefined)
|
|
116
|
+
args.push(flag, string(ssh[field], `ssh.${field}`));
|
|
117
|
+
}
|
|
118
|
+
if (ssh.options !== undefined) {
|
|
119
|
+
for (const [key, value] of Object.entries(object(ssh.options, "ssh.options")))
|
|
120
|
+
args.push("-o", `${key}=${string(value, "ssh.options value")}`);
|
|
121
|
+
}
|
|
122
|
+
const host = string(ssh.host, "ssh.host");
|
|
123
|
+
if (ssh.user !== undefined && host.includes("@"))
|
|
124
|
+
throw new Error("ssh.user conflicts with user@host; specify the user once");
|
|
125
|
+
args.push(host);
|
|
126
|
+
return validateSshArguments(args);
|
|
127
|
+
}
|
|
128
|
+
export function resolveEnrollment(opts) {
|
|
129
|
+
let config = {};
|
|
130
|
+
if (opts.config) {
|
|
131
|
+
let input;
|
|
132
|
+
try {
|
|
133
|
+
input = readFileSync(opts.config, "utf8");
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
throw new Error("cannot read enrollment config file");
|
|
137
|
+
}
|
|
138
|
+
let parsed;
|
|
139
|
+
try {
|
|
140
|
+
parsed = JSON.parse(input);
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
throw new Error("enrollment config must contain valid JSON");
|
|
144
|
+
}
|
|
145
|
+
config = object(parsed, "config");
|
|
146
|
+
}
|
|
147
|
+
keys(config, ["name", "prefix", "ssh", "local", "webTerminal"], "config");
|
|
148
|
+
if (config.local !== undefined && typeof config.local !== "boolean")
|
|
149
|
+
throw new Error("local must be a boolean");
|
|
150
|
+
if (config.webTerminal !== undefined && typeof config.webTerminal !== "boolean")
|
|
151
|
+
throw new Error("webTerminal must be a boolean");
|
|
152
|
+
const webTerminal = opts.webTerminal ?? config.webTerminal ?? true;
|
|
153
|
+
const local = opts.local ?? config.local ?? false;
|
|
154
|
+
if (local && (opts.ssh !== undefined || config.ssh !== undefined))
|
|
155
|
+
throw new Error("Choose --local or --ssh, not both (including config fields)");
|
|
156
|
+
if (local && (opts.saveCredentials === true || [opts.targetPassword, opts.targetKey, opts.jumpPassword, opts.jumpKey, opts.passwordFd].some(values => values?.length))) {
|
|
157
|
+
throw new Error("Local enrollment does not use SSH credentials; remove credential-saving options");
|
|
158
|
+
}
|
|
159
|
+
// Explicit CLI values override file fields; --ssh replaces the whole object.
|
|
160
|
+
const name = string(opts.name ?? config.name, "name");
|
|
161
|
+
const prefix = opts.prefix ?? config.prefix;
|
|
162
|
+
const segment = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;
|
|
163
|
+
let parts = name.split("/");
|
|
164
|
+
if (prefix !== undefined) {
|
|
165
|
+
const p = string(prefix, "prefix").split("/");
|
|
166
|
+
if (p.length !== 2 || !p.every(s => segment.test(s)))
|
|
167
|
+
throw new Error("prefix must be namespace/group");
|
|
168
|
+
if (parts.length === 1)
|
|
169
|
+
parts = [...p, name];
|
|
170
|
+
else if (parts.slice(0, 2).join("/") !== p.join("/"))
|
|
171
|
+
throw new Error("name and prefix conflict");
|
|
172
|
+
}
|
|
173
|
+
if (parts.length !== 3 || !parts.every(s => segment.test(s)))
|
|
174
|
+
throw new Error("name must be namespace/group/host, or use --prefix namespace/group with --name host; wildcards are not enrollment names");
|
|
175
|
+
if (local)
|
|
176
|
+
return { name: parts.join("/"), webTerminal, namespace: parts[0], group: parts[1], hostName: parts[2], local: true };
|
|
177
|
+
const args = opts.ssh !== undefined ? validateSshArguments(splitSshArguments(opts.ssh)) : structuredSsh(config.ssh);
|
|
178
|
+
return { name: parts.join("/"), webTerminal, namespace: parts[0], group: parts[1], hostName: parts[2], ssh: { executable: "ssh", args } };
|
|
179
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { EnrollmentPlan, EnrollOptions } from './config.js';
|
|
2
|
+
type Source = {
|
|
3
|
+
role: 'target' | 'jump';
|
|
4
|
+
endpoint: string;
|
|
5
|
+
kind: 'password' | 'private_key';
|
|
6
|
+
name: string;
|
|
7
|
+
keyFile?: string;
|
|
8
|
+
fd?: number;
|
|
9
|
+
};
|
|
10
|
+
export type SaveReport = {
|
|
11
|
+
status: string;
|
|
12
|
+
entries: Record<string, unknown>[];
|
|
13
|
+
};
|
|
14
|
+
export declare function selectedSources(opts: EnrollOptions, target: string): Source[];
|
|
15
|
+
export declare function saveCredentials(result: Record<string, any>, plan: EnrollmentPlan, opts: EnrollOptions, pinned?: {
|
|
16
|
+
remote: string;
|
|
17
|
+
token: string | null;
|
|
18
|
+
}): Promise<SaveReport>;
|
|
19
|
+
export {};
|