@dreamlake/dreamlake-cli 0.88.0 → 0.89.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 +53 -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 +2330 -0
- package/dist/api/index.js +114 -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 +75 -0
- package/dist/api/note-files.js +65 -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-toc.d.ts +2 -0
- package/dist/api/note-toc.js +2 -0
- package/dist/api/notes.d.ts +304 -0
- package/dist/api/notes.js +181 -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/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 +120 -0
- package/dist/cli/notes/files-commands.js +554 -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 +1303 -0
- package/dist/cli/notes/linger.d.ts +59 -0
- package/dist/cli/notes/linger.js +339 -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 +84 -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,335 @@
|
|
|
1
|
+
/** Process-level glue for the runner: tmux, git worktrees and the two
|
|
2
|
+
* provider CLIs. Every function takes an injected `run` so the control flow
|
|
3
|
+
* is testable without a terminal. Three rules hold throughout: arguments are
|
|
4
|
+
* arrays (never a shell string); user text reaches a provider through stdin
|
|
5
|
+
* or behind a `--` boundary (never as something that could parse as an
|
|
6
|
+
* option); and a tmux session is only acted on when its recorded owner and
|
|
7
|
+
* pane identity still match. */
|
|
8
|
+
import { spawn } from 'node:child_process';
|
|
9
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
10
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
11
|
+
import { mkdirSync, existsSync, statSync } from 'node:fs';
|
|
12
|
+
import { basename, join } from 'node:path';
|
|
13
|
+
import { claudePermissionMode, codexSandbox, tmuxSessionName } from './native.js';
|
|
14
|
+
const OUTPUT_LIMIT = 2 * 1024 * 1024;
|
|
15
|
+
/** Default process runner: own process group, bounded output and time, killable through `signal`. */
|
|
16
|
+
export const run = (command, args, options = {}) => new Promise(resolve => {
|
|
17
|
+
if (options.signal?.aborted) {
|
|
18
|
+
resolve({ code: null, spawned: false, stdout: '', stderr: '', timedOut: false, aborted: true });
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const child = spawn(command, args, { cwd: options.cwd, env: options.env ?? process.env, stdio: ['pipe', 'pipe', 'pipe'], detached: process.platform !== 'win32' });
|
|
22
|
+
let stdout = '', stderr = '', timedOut = false, aborted = false, settled = false, spawned = false;
|
|
23
|
+
child.once('spawn', () => { spawned = true; });
|
|
24
|
+
const killTree = (signal) => { try {
|
|
25
|
+
if (child.pid && process.platform !== 'win32')
|
|
26
|
+
process.kill(-child.pid, signal);
|
|
27
|
+
else
|
|
28
|
+
child.kill(signal);
|
|
29
|
+
}
|
|
30
|
+
catch { /* already gone */ } };
|
|
31
|
+
const terminate = () => { killTree('SIGTERM'); setTimeout(() => killTree('SIGKILL'), 5000).unref(); };
|
|
32
|
+
const timer = setTimeout(() => { timedOut = true; terminate(); }, options.timeoutMs ?? 60_000);
|
|
33
|
+
const onAbort = () => { aborted = true; terminate(); };
|
|
34
|
+
if (options.signal) {
|
|
35
|
+
if (options.signal.aborted)
|
|
36
|
+
onAbort();
|
|
37
|
+
else
|
|
38
|
+
options.signal.addEventListener('abort', onAbort, { once: true });
|
|
39
|
+
}
|
|
40
|
+
const finish = (result) => { if (settled)
|
|
41
|
+
return; settled = true; clearTimeout(timer); options.signal?.removeEventListener('abort', onAbort); resolve(result); };
|
|
42
|
+
child.stdout.on('data', chunk => { if (stdout.length < OUTPUT_LIMIT)
|
|
43
|
+
stdout += chunk.toString(); try {
|
|
44
|
+
options.onStdout?.(chunk.toString());
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
aborted = true;
|
|
48
|
+
stderr += 'checkpoint persistence failed';
|
|
49
|
+
terminate();
|
|
50
|
+
} });
|
|
51
|
+
child.stderr.on('data', chunk => { if (stderr.length < OUTPUT_LIMIT)
|
|
52
|
+
stderr += chunk.toString(); });
|
|
53
|
+
child.on('error', error => finish({ code: null, signal: null, spawned, stdout, stderr: stderr + String(error), timedOut, aborted }));
|
|
54
|
+
child.on('close', (code, signal) => finish({ code, signal, spawned, stdout, stderr, timedOut, aborted }));
|
|
55
|
+
child.stdin.on('error', () => undefined);
|
|
56
|
+
if (options.input !== undefined)
|
|
57
|
+
child.stdin.end(options.input);
|
|
58
|
+
else
|
|
59
|
+
child.stdin.end();
|
|
60
|
+
});
|
|
61
|
+
export class RunnerError extends Error {
|
|
62
|
+
code;
|
|
63
|
+
uncertain;
|
|
64
|
+
checkpoint;
|
|
65
|
+
constructor(code, message, uncertain = false, checkpoint = {}) {
|
|
66
|
+
super(message ?? code);
|
|
67
|
+
this.code = code;
|
|
68
|
+
this.uncertain = uncertain;
|
|
69
|
+
this.checkpoint = checkpoint;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/** A provider that ran at all may have edited files or written its transcript before failing:
|
|
73
|
+
* a nonzero exit is an uncertain effect. Only a process that never started is a plain failure. */
|
|
74
|
+
const failed = (result, code, checkpoint = {}) => {
|
|
75
|
+
// Only a process that never spawned is a plain failure; one killed by a signal still ran.
|
|
76
|
+
const neverRan = result.spawned === false || (result.spawned === undefined && result.code === null && !result.signal && !result.timedOut && !result.aborted);
|
|
77
|
+
return new RunnerError(result.aborted ? 'cancelled' : result.timedOut ? 'provider_timeout' : neverRan ? 'provider_unavailable' : code, (result.stderr || result.stdout).trim().slice(0, 500), !neverRan, checkpoint);
|
|
78
|
+
};
|
|
79
|
+
export async function hasTmux(exec) { return (await exec('tmux', ['-V'], { timeoutMs: 5000 })).code === 0; }
|
|
80
|
+
export async function tmuxAlive(exec, name) { return (await exec('tmux', ['has-session', '-t', `=${name}`], { timeoutMs: 5000 })).code === 0; }
|
|
81
|
+
/** The owner marker is written by this runner at creation; a session with another or no marker is not ours to type into or kill. */
|
|
82
|
+
export const ownerMarker = (runnerKey, nativeSessionId) => createHash('sha256').update(JSON.stringify(['dreamlake-runner', runnerKey, nativeSessionId])).digest('hex').slice(0, 32);
|
|
83
|
+
export async function markOwnership(exec, name, marker) {
|
|
84
|
+
const set = await exec('tmux', ['set-option', '-t', `=${name}`, '@dreamlake_runner', marker, ';', 'set-option', '-F', '-t', `=${name}`, '@dreamlake_pane', '#{pane_id}:#{pane_pid}'], { timeoutMs: 5000 });
|
|
85
|
+
if (set.code !== 0)
|
|
86
|
+
throw new RunnerError('tmux_mark_failed', set.stderr.trim(), true, { tmuxSession: name });
|
|
87
|
+
}
|
|
88
|
+
export async function verifyOwnership(exec, name, marker) {
|
|
89
|
+
if (!await tmuxAlive(exec, name))
|
|
90
|
+
return 'absent';
|
|
91
|
+
const shown = await exec('tmux', ['display-message', '-p', '-t', `=${name}`, '#{@dreamlake_runner}|#{pane_id}|#{pane_pid}|#{@dreamlake_pane}|#{session_windows}|#{window_panes}'], { timeoutMs: 5000 });
|
|
92
|
+
if (shown.code !== 0)
|
|
93
|
+
return 'foreign';
|
|
94
|
+
const [owner, pane, pid, bound, windows, panes] = shown.stdout.trim().split('|');
|
|
95
|
+
return owner === marker && bound === `${pane}:${pid}` && windows === '1' && panes === '1' ? 'owned' : 'foreign';
|
|
96
|
+
}
|
|
97
|
+
/** One message, pasted whole (bracketed) and submitted once; every step's exit code counts. */
|
|
98
|
+
export async function tmuxSend(exec, name, marker, text, signal) {
|
|
99
|
+
signal?.throwIfAborted();
|
|
100
|
+
const owned = await verifyOwnership(exec, name, marker);
|
|
101
|
+
if (owned === 'absent')
|
|
102
|
+
throw new RunnerError('session_not_running');
|
|
103
|
+
if (owned === 'foreign')
|
|
104
|
+
throw new RunnerError('pane_ownership_unverified');
|
|
105
|
+
// Nothing has been typed yet; a cancellation up to here is clean.
|
|
106
|
+
signal?.throwIfAborted();
|
|
107
|
+
const buffer = `dl-${randomUUID().slice(0, 8)}`;
|
|
108
|
+
let pasteAttempted = false, submitted = false;
|
|
109
|
+
const checkCancelled = () => { if (signal?.aborted)
|
|
110
|
+
throw new RunnerError('cancelled', undefined, pasteAttempted, { pasteAttempted, submitted }); };
|
|
111
|
+
try {
|
|
112
|
+
const loaded = await exec('tmux', ['load-buffer', '-b', buffer, '-'], { timeoutMs: 5000, input: text, signal });
|
|
113
|
+
checkCancelled();
|
|
114
|
+
if (loaded.code !== 0)
|
|
115
|
+
throw new RunnerError('tmux_send_failed', loaded.stderr.trim());
|
|
116
|
+
pasteAttempted = true;
|
|
117
|
+
const pasted = await exec('tmux', ['paste-buffer', '-p', '-d', '-b', buffer, '-t', `=${name}`], { timeoutMs: 5000, signal });
|
|
118
|
+
checkCancelled();
|
|
119
|
+
if (pasted.code !== 0)
|
|
120
|
+
throw new RunnerError('tmux_send_failed', pasted.stderr.trim(), true, { pasteAttempted });
|
|
121
|
+
const result = await exec('tmux', ['send-keys', '-t', `=${name}`, 'Enter'], { timeoutMs: 5000, signal });
|
|
122
|
+
submitted = result.code === 0;
|
|
123
|
+
checkCancelled();
|
|
124
|
+
if (result.code !== 0)
|
|
125
|
+
throw new RunnerError('tmux_submit_failed', result.stderr.trim(), true, { pasted: true });
|
|
126
|
+
}
|
|
127
|
+
finally {
|
|
128
|
+
// paste-buffer -d consumes it on success; on interruption remove the private buffer too.
|
|
129
|
+
if (!submitted)
|
|
130
|
+
await exec('tmux', ['delete-buffer', '-b', buffer], { timeoutMs: 5000 }).catch(() => undefined);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
export async function tmuxStop(exec, name, marker) {
|
|
134
|
+
const owned = await verifyOwnership(exec, name, marker);
|
|
135
|
+
if (owned === 'absent')
|
|
136
|
+
return false;
|
|
137
|
+
if (owned === 'foreign')
|
|
138
|
+
throw new RunnerError('pane_ownership_unverified');
|
|
139
|
+
const killed = await exec('tmux', ['kill-session', '-t', `=${name}`], { timeoutMs: 5000 });
|
|
140
|
+
if (killed.code !== 0)
|
|
141
|
+
throw new RunnerError('tmux_stop_failed', killed.stderr.trim(), true);
|
|
142
|
+
if (await tmuxAlive(exec, name))
|
|
143
|
+
throw new RunnerError('tmux_stop_unverified', undefined, true);
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
/** A fresh worktree next to the user's other DreamLake worktrees, never inside the source checkout. */
|
|
147
|
+
export async function createWorktree(exec, input) {
|
|
148
|
+
input.signal?.throwIfAborted();
|
|
149
|
+
const top = await exec('git', ['-C', input.repo, 'rev-parse', '--show-toplevel'], { timeoutMs: 10_000 });
|
|
150
|
+
if (top.code !== 0)
|
|
151
|
+
throw new RunnerError('repo_not_git', top.stderr.trim());
|
|
152
|
+
const root = top.stdout.trim();
|
|
153
|
+
const branch = input.branch ?? `dreamlake/${new Date().toISOString().slice(0, 10)}-${randomUUID().slice(0, 8)}`;
|
|
154
|
+
const path = join(input.home, '.dreamlake', 'worktrees', `${basename(root)}-${branch.replace(/[^A-Za-z0-9._-]/g, '-')}`);
|
|
155
|
+
if (existsSync(path))
|
|
156
|
+
throw new RunnerError('worktree_exists', path);
|
|
157
|
+
mkdirSync(join(input.home, '.dreamlake', 'worktrees'), { recursive: true });
|
|
158
|
+
input.checkpoint?.({ cwd: path, branch, root, phase: 'worktree-create' });
|
|
159
|
+
const exists = (await exec('git', ['-C', root, 'rev-parse', '--verify', '--quiet', `refs/heads/${branch}`], { timeoutMs: 10_000 })).code === 0;
|
|
160
|
+
const args = exists ? ['-C', root, 'worktree', 'add', '--', path, branch] : ['-C', root, 'worktree', 'add', '-b', branch, '--', path, ...(input.baseRef ? [input.baseRef] : [])];
|
|
161
|
+
input.signal?.throwIfAborted();
|
|
162
|
+
const added = await exec('git', args, { timeoutMs: 120_000, signal: input.signal });
|
|
163
|
+
if (added.code !== 0)
|
|
164
|
+
throw new RunnerError('worktree_failed', added.stderr.trim().slice(0, 500), added.spawned !== false, { cwd: path, branch, root });
|
|
165
|
+
return { path, branch, root };
|
|
166
|
+
}
|
|
167
|
+
const DEFAULT_PROMPT = 'You were started by the DreamLake built-in agent on behalf of its user. Reply with one line acknowledging the working directory, then wait for instructions.';
|
|
168
|
+
const claudeEnv = (input) => input.claudeConfigDir ? { ...process.env, CLAUDE_CONFIG_DIR: input.claudeConfigDir } : process.env;
|
|
169
|
+
const PROVIDER_TIMEOUT = 15 * 60_000;
|
|
170
|
+
/** Headless: one provider turn that creates the session; the prompt travels on stdin. */
|
|
171
|
+
export async function startHeadless(exec, launch) {
|
|
172
|
+
const prompt = launch.prompt ?? DEFAULT_PROMPT;
|
|
173
|
+
if (launch.provider === 'claude') {
|
|
174
|
+
const id = launch.nativeSessionId ?? randomUUID();
|
|
175
|
+
launch.checkpoint?.({ nativeSessionId: id, phase: 'provider-start' });
|
|
176
|
+
const result = await exec('claude', ['-p', '--session-id', id, '--permission-mode', claudePermissionMode(launch.permissionLevel), '--output-format', 'json'], { cwd: launch.cwd, timeoutMs: PROVIDER_TIMEOUT, env: claudeEnv(launch), input: prompt, signal: launch.signal });
|
|
177
|
+
// The id was chosen here, so even a failed turn leaves a reconcilable checkpoint.
|
|
178
|
+
if (result.code !== 0)
|
|
179
|
+
throw failed(result, 'claude_failed', { nativeSessionId: id });
|
|
180
|
+
return { nativeSessionId: id, reply: claudeReply(result.stdout) };
|
|
181
|
+
}
|
|
182
|
+
let stream = '', checkpointed = false;
|
|
183
|
+
launch.checkpoint?.({ phase: 'provider-start' });
|
|
184
|
+
const onStdout = (chunk) => { if (checkpointed)
|
|
185
|
+
return; stream = (stream + chunk).slice(-65536); const id = codexThreadId(stream); if (id) {
|
|
186
|
+
launch.checkpoint?.({ nativeSessionId: id, phase: 'provider-running' });
|
|
187
|
+
checkpointed = true;
|
|
188
|
+
} };
|
|
189
|
+
const result = await exec('codex', ['exec', '-C', launch.cwd, '--sandbox', codexSandbox(launch.permissionLevel), '--json', '-'], { cwd: launch.cwd, timeoutMs: PROVIDER_TIMEOUT, input: prompt, signal: launch.signal, onStdout });
|
|
190
|
+
// The identity comes from the launch's own JSON stream, never from scanning the rollout
|
|
191
|
+
// directory: a transcript that merely appeared nearby could belong to anyone.
|
|
192
|
+
const id = codexThreadId(result.stdout);
|
|
193
|
+
if (id)
|
|
194
|
+
launch.checkpoint?.({ nativeSessionId: id, phase: 'provider-result' });
|
|
195
|
+
if (result.code !== 0)
|
|
196
|
+
throw failed(result, 'codex_failed', id ? { nativeSessionId: id } : {});
|
|
197
|
+
if (!id)
|
|
198
|
+
throw new RunnerError('codex_session_id_unknown', 'codex exec --json did not report a thread id', true);
|
|
199
|
+
return { nativeSessionId: id, reply: codexReply(result.stdout) };
|
|
200
|
+
}
|
|
201
|
+
/** Stamp a fresh launch identity atomically with session creation (tmux >= 3.2).
|
|
202
|
+
* Unlike the stable runner marker, this nonce cannot match a previous/concurrent launch. */
|
|
203
|
+
async function createTmux(exec, input, work = async () => { }) {
|
|
204
|
+
input.signal?.throwIfAborted();
|
|
205
|
+
const nonce = randomUUID().replaceAll('-', '');
|
|
206
|
+
const checkpoint = { nativeSessionId: input.nativeSessionId, tmuxSession: input.name };
|
|
207
|
+
input.checkpoint?.({ ...checkpoint, launchNonce: nonce, phase: 'tmux-start' });
|
|
208
|
+
try {
|
|
209
|
+
const created = await exec('tmux', ['-u', 'new-session', '-d', '-s', input.name, '-c', input.cwd, '-e', `DREAMLAKE_LAUNCH_NONCE=${nonce}`, ...input.program], { timeoutMs: 15_000, signal: input.signal });
|
|
210
|
+
if (created.code !== 0)
|
|
211
|
+
throw new RunnerError('tmux_start_failed', created.stderr.trim(), true, checkpoint);
|
|
212
|
+
input.signal?.throwIfAborted();
|
|
213
|
+
await markOwnership(exec, input.name, input.marker);
|
|
214
|
+
input.signal?.throwIfAborted();
|
|
215
|
+
await work();
|
|
216
|
+
input.signal?.throwIfAborted();
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
// A detached session can exist even if the creating client was killed before its reply.
|
|
220
|
+
// Find its exact ID and check the nonce again in tmux's server command queue, so a foreign
|
|
221
|
+
// session that replaced the deterministic name cannot be killed by cleanup.
|
|
222
|
+
let tornDown = false;
|
|
223
|
+
try {
|
|
224
|
+
const found = await exec('tmux', ['display-message', '-p', '-t', `=${input.name}`, '#{session_id}|#{DREAMLAKE_LAUNCH_NONCE}'], { timeoutMs: 5000 });
|
|
225
|
+
const [id, actual] = found.stdout.trim().split('|');
|
|
226
|
+
if (found.code === 0 && /^\$[0-9]+$/.test(id) && actual === nonce) {
|
|
227
|
+
const killed = await exec('tmux', ['if-shell', '-F', '-t', id, `#{==:#{DREAMLAKE_LAUNCH_NONCE},${nonce}}`, `kill-session -t '${id}'`], { timeoutMs: 5000 });
|
|
228
|
+
const remaining = await exec('tmux', ['has-session', '-t', id], { timeoutMs: 5000 });
|
|
229
|
+
tornDown = killed.code === 0 && remaining.code === 1;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
catch { /* uncertain cleanup is included in the receipt */ }
|
|
233
|
+
throw new RunnerError(input.signal?.aborted ? 'cancelled' : error instanceof RunnerError ? error.code : 'tmux_start_failed', error instanceof Error ? error.message : undefined, true, { ...(error instanceof RunnerError ? error.checkpoint : {}), ...checkpoint, tornDown });
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
/** Interactive: a detached, owner-marked tmux session. Prompts sit behind `--`. */
|
|
237
|
+
export async function startTmux(exec, launch) {
|
|
238
|
+
if (launch.signal?.aborted)
|
|
239
|
+
throw new RunnerError('cancelled');
|
|
240
|
+
if (launch.provider === 'claude') {
|
|
241
|
+
const id = launch.nativeSessionId ?? randomUUID(), name = tmuxSessionName('claude', launch.cwd, id, launch.claudeConfigDir);
|
|
242
|
+
await createTmux(exec, { name, cwd: launch.cwd, marker: launch.marker(id), nativeSessionId: id, signal: launch.signal, checkpoint: launch.checkpoint,
|
|
243
|
+
program: [...(launch.claudeConfigDir ? ['env', `CLAUDE_CONFIG_DIR=${launch.claudeConfigDir}`] : []), 'claude', '--session-id', id, '--permission-mode', claudePermissionMode(launch.permissionLevel), ...(launch.prompt ? ['--', launch.prompt] : [])] });
|
|
244
|
+
return { nativeSessionId: id, tmuxSession: name };
|
|
245
|
+
}
|
|
246
|
+
// The launch's own JSON stream identifies Codex; then resume that exact thread in tmux.
|
|
247
|
+
const { nativeSessionId: id } = await startHeadless(exec, launch);
|
|
248
|
+
const name = tmuxSessionName('codex', launch.cwd, id);
|
|
249
|
+
await createTmux(exec, { name, cwd: launch.cwd, marker: launch.marker(id), nativeSessionId: id, signal: launch.signal, checkpoint: launch.checkpoint,
|
|
250
|
+
program: ['codex', '-C', launch.cwd, '--sandbox', codexSandbox(launch.permissionLevel), 'resume', id] });
|
|
251
|
+
return { nativeSessionId: id, tmuxSession: name };
|
|
252
|
+
}
|
|
253
|
+
/** Resume in tmux, re-applying the session's permission ceiling; a live session receives the prompt instead.
|
|
254
|
+
* Cancellation is honoured before and during the launch; a launch cancelled mid-way is torn down. */
|
|
255
|
+
export async function resumeTmux(exec, input) {
|
|
256
|
+
input.signal?.throwIfAborted();
|
|
257
|
+
const name = tmuxSessionName(input.provider, input.cwd, input.nativeSessionId, input.claudeConfigDir);
|
|
258
|
+
const owned = await verifyOwnership(exec, name, input.marker);
|
|
259
|
+
if (owned === 'foreign')
|
|
260
|
+
throw new RunnerError('pane_ownership_unverified');
|
|
261
|
+
input.signal?.throwIfAborted();
|
|
262
|
+
if (owned === 'owned') {
|
|
263
|
+
if (input.prompt)
|
|
264
|
+
await tmuxSend(exec, name, input.marker, input.prompt, input.signal);
|
|
265
|
+
return { tmuxSession: name, created: false, delivered: !!input.prompt };
|
|
266
|
+
}
|
|
267
|
+
const program = input.provider === 'codex' ? ['codex', '-C', input.cwd, '--sandbox', codexSandbox(input.permissionLevel), 'resume', input.nativeSessionId]
|
|
268
|
+
: [...(input.claudeConfigDir ? ['env', `CLAUDE_CONFIG_DIR=${input.claudeConfigDir}`] : []), 'claude', '--resume', input.nativeSessionId, '--permission-mode', claudePermissionMode(input.permissionLevel)];
|
|
269
|
+
await createTmux(exec, { name, cwd: input.cwd, program, marker: input.marker, nativeSessionId: input.nativeSessionId, signal: input.signal, checkpoint: input.checkpoint }, async () => {
|
|
270
|
+
if (input.prompt) {
|
|
271
|
+
await delay(3000, undefined, { signal: input.signal });
|
|
272
|
+
await tmuxSend(exec, name, input.marker, input.prompt, input.signal);
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
return { tmuxSession: name, created: true, delivered: !!input.prompt };
|
|
276
|
+
}
|
|
277
|
+
/** Headless message: one resumed turn under the session's permission ceiling; the text travels on stdin. */
|
|
278
|
+
export async function sendHeadless(exec, input) {
|
|
279
|
+
if (input.provider === 'claude') {
|
|
280
|
+
const result = await exec('claude', ['-p', '--resume', input.nativeSessionId, '--permission-mode', claudePermissionMode(input.permissionLevel), '--output-format', 'json'], { cwd: input.cwd, timeoutMs: PROVIDER_TIMEOUT, env: claudeEnv(input), input: input.text, signal: input.signal });
|
|
281
|
+
if (result.code !== 0)
|
|
282
|
+
throw failed(result, 'claude_failed');
|
|
283
|
+
return { reply: claudeReply(result.stdout) };
|
|
284
|
+
}
|
|
285
|
+
const result = await exec('codex', ['exec', '--sandbox', codexSandbox(input.permissionLevel), '--json', 'resume', input.nativeSessionId, '-'], { cwd: input.cwd, timeoutMs: PROVIDER_TIMEOUT, input: input.text, signal: input.signal });
|
|
286
|
+
if (result.code !== 0)
|
|
287
|
+
throw failed(result, 'codex_failed');
|
|
288
|
+
return { reply: codexReply(result.stdout) };
|
|
289
|
+
}
|
|
290
|
+
/** Someone (a person, another runner) is writing this conversation right now. */
|
|
291
|
+
export function nativeWriterBusy(transcriptPath, now = Date.now(), windowMs = 60_000) {
|
|
292
|
+
if (!transcriptPath)
|
|
293
|
+
return false;
|
|
294
|
+
try {
|
|
295
|
+
return now - statSync(transcriptPath).mtimeMs < windowMs;
|
|
296
|
+
}
|
|
297
|
+
catch {
|
|
298
|
+
return false;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
export function claudeReply(stdout) {
|
|
302
|
+
try {
|
|
303
|
+
const parsed = JSON.parse(stdout);
|
|
304
|
+
if (typeof parsed?.result === 'string')
|
|
305
|
+
return parsed.result.slice(0, 16_000);
|
|
306
|
+
}
|
|
307
|
+
catch { /* stream or text */ }
|
|
308
|
+
const text = stdout.trim();
|
|
309
|
+
return text ? text.slice(-16_000) : null;
|
|
310
|
+
}
|
|
311
|
+
const codexEvents = (stdout) => stdout.split('\n').flatMap(line => { try {
|
|
312
|
+
return line.trim() ? [JSON.parse(line)] : [];
|
|
313
|
+
}
|
|
314
|
+
catch {
|
|
315
|
+
return [];
|
|
316
|
+
} });
|
|
317
|
+
export function codexThreadId(stdout) {
|
|
318
|
+
for (const event of codexEvents(stdout)) {
|
|
319
|
+
const id = event.thread_id ?? event.threadId ?? event.session_id;
|
|
320
|
+
if (typeof id === 'string' && /^[a-f0-9-]{36}$/i.test(id))
|
|
321
|
+
return id.toLowerCase();
|
|
322
|
+
}
|
|
323
|
+
return null;
|
|
324
|
+
}
|
|
325
|
+
export function codexReply(stdout) {
|
|
326
|
+
let last = null;
|
|
327
|
+
for (const event of codexEvents(stdout)) {
|
|
328
|
+
const item = event.item ?? event;
|
|
329
|
+
if ((item?.type === 'agent_message' || item?.type === 'message') && typeof item.text === 'string')
|
|
330
|
+
last = item.text;
|
|
331
|
+
if (typeof event.last_agent_message === 'string')
|
|
332
|
+
last = event.last_agent_message;
|
|
333
|
+
}
|
|
334
|
+
return last ? last.slice(0, 16_000) : null;
|
|
335
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ClaimedCommand, CommandReceipt } from '../../../api/index.js';
|
|
2
|
+
export interface JournalEntry {
|
|
3
|
+
commandId: string;
|
|
4
|
+
runnerId: string;
|
|
5
|
+
kind: string;
|
|
6
|
+
sessionId: string | null;
|
|
7
|
+
state: 'prepared' | 'executing' | 'finished' | 'acknowledged';
|
|
8
|
+
updatedAt: string;
|
|
9
|
+
checkpoint?: Record<string, unknown>;
|
|
10
|
+
receipt?: CommandReceipt;
|
|
11
|
+
operatorResolution?: {
|
|
12
|
+
reason: string;
|
|
13
|
+
at: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export declare class RunnerJournal {
|
|
17
|
+
readonly directory: string;
|
|
18
|
+
constructor(directory: string);
|
|
19
|
+
private path;
|
|
20
|
+
read(id: string): JournalEntry | null;
|
|
21
|
+
list(): JournalEntry[];
|
|
22
|
+
save(entry: JournalEntry): void;
|
|
23
|
+
prepare(command: ClaimedCommand, runnerId: string): void;
|
|
24
|
+
update(id: string, changes: Partial<JournalEntry>): void;
|
|
25
|
+
checkpoint(id: string, value: Record<string, unknown>): void;
|
|
26
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** Private, fsynced intent/result journal. Recovery never replays provider side effects. */
|
|
2
|
+
import { closeSync, fsyncSync, mkdirSync, openSync, readFileSync, readdirSync, renameSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { randomUUID } from 'node:crypto';
|
|
5
|
+
export class RunnerJournal {
|
|
6
|
+
directory;
|
|
7
|
+
constructor(directory) {
|
|
8
|
+
this.directory = directory;
|
|
9
|
+
mkdirSync(directory, { recursive: true, mode: 0o700 });
|
|
10
|
+
}
|
|
11
|
+
path(id) { if (!/^[a-f0-9]{24}$/i.test(id))
|
|
12
|
+
throw new Error('invalid journal command id'); return join(this.directory, `${id}.json`); }
|
|
13
|
+
read(id) { try {
|
|
14
|
+
return JSON.parse(readFileSync(this.path(id), 'utf8'));
|
|
15
|
+
}
|
|
16
|
+
catch (e) {
|
|
17
|
+
if (e.code === 'ENOENT')
|
|
18
|
+
return null;
|
|
19
|
+
throw e;
|
|
20
|
+
} }
|
|
21
|
+
list() { return readdirSync(this.directory).filter(x => /^[a-f0-9]{24}\.json$/i.test(x)).map(x => this.read(x.slice(0, -5))); }
|
|
22
|
+
save(entry) {
|
|
23
|
+
const path = this.path(entry.commandId), temp = `${path}.${randomUUID()}.tmp`;
|
|
24
|
+
const fd = openSync(temp, 'wx', 0o600);
|
|
25
|
+
try {
|
|
26
|
+
writeFileSync(fd, JSON.stringify({ ...entry, updatedAt: new Date().toISOString() }) + '\n');
|
|
27
|
+
fsyncSync(fd);
|
|
28
|
+
}
|
|
29
|
+
finally {
|
|
30
|
+
closeSync(fd);
|
|
31
|
+
}
|
|
32
|
+
renameSync(temp, path);
|
|
33
|
+
const dir = openSync(this.directory, 'r');
|
|
34
|
+
try {
|
|
35
|
+
fsyncSync(dir);
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
closeSync(dir);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
prepare(command, runnerId) {
|
|
42
|
+
if (this.read(command.id))
|
|
43
|
+
throw new Error('command already journaled; inspect instead of replaying');
|
|
44
|
+
this.save({ commandId: command.id, runnerId, kind: command.kind, sessionId: command.sessionId ?? null, state: 'prepared', updatedAt: new Date().toISOString() });
|
|
45
|
+
}
|
|
46
|
+
update(id, changes) { const entry = this.read(id); if (!entry)
|
|
47
|
+
throw new Error('missing command journal'); this.save({ ...entry, ...changes, commandId: id }); }
|
|
48
|
+
checkpoint(id, value) { const entry = this.read(id); this.update(id, { checkpoint: { ...entry?.checkpoint, ...value } }); }
|
|
49
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export type Provider = 'codex' | 'claude';
|
|
2
|
+
export declare const UUID: RegExp;
|
|
3
|
+
export interface NativeRoots {
|
|
4
|
+
claude: string;
|
|
5
|
+
codex: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const defaultRoots: (home: string, env?: NodeJS.ProcessEnv) => NativeRoots;
|
|
8
|
+
/** Claude Code names a project directory after the working directory with every non-alphanumeric replaced. */
|
|
9
|
+
export declare const claudeProjectSlug: (cwd: string) => string;
|
|
10
|
+
export declare const claudeTranscriptPath: (root: string, cwd: string, id: string) => string;
|
|
11
|
+
export declare function findClaudeTranscript(root: string, id: string): string | null;
|
|
12
|
+
/** `~/.codex/sessions/YYYY/MM/DD/rollout-<timestamp>-<uuid>.jsonl`, newest day first. */
|
|
13
|
+
export declare function findCodexRollout(root: string, id: string, since?: number): string | null;
|
|
14
|
+
export declare function listCodexRollouts(root: string, since?: number): string[];
|
|
15
|
+
export interface TranscriptFacts {
|
|
16
|
+
cwd: string | null;
|
|
17
|
+
nativeSessionId: string | null;
|
|
18
|
+
createdAt: number | null;
|
|
19
|
+
lastRole: 'user' | 'assistant' | 'tool' | 'system' | null;
|
|
20
|
+
lastAt: number;
|
|
21
|
+
messages: number;
|
|
22
|
+
title: string | null;
|
|
23
|
+
}
|
|
24
|
+
/** Read a bounded head and tail; a multi-megabyte transcript is never loaded whole for a status check. */
|
|
25
|
+
export declare function transcriptFacts(provider: Provider, path: string, headBytes?: number, tailBytes?: number): TranscriptFacts;
|
|
26
|
+
export type RunState = 'unknown' | 'running' | 'working' | 'waiting' | 'idle' | 'error' | 'stopped';
|
|
27
|
+
/** Heuristic, stated as such in the receipt: an alive process whose transcript ends with the assistant is waiting for a human. */
|
|
28
|
+
export declare function runStateFrom(input: {
|
|
29
|
+
alive: boolean | null;
|
|
30
|
+
lastRole: TranscriptFacts['lastRole'];
|
|
31
|
+
lastAt: number;
|
|
32
|
+
now?: number;
|
|
33
|
+
busyWindowMs?: number;
|
|
34
|
+
}): RunState;
|
|
35
|
+
export interface SubagentFacts {
|
|
36
|
+
id: string;
|
|
37
|
+
agentType: string | null;
|
|
38
|
+
description: string | null;
|
|
39
|
+
finished: boolean | null;
|
|
40
|
+
lastAt: string;
|
|
41
|
+
bytes: number;
|
|
42
|
+
}
|
|
43
|
+
/** Claude Code records each spawned subagent under `<project>/<sessionId>/subagents/agent-<id>.{jsonl,meta.json}`. */
|
|
44
|
+
export declare function claudeSubagents(transcriptPath: string): SubagentFacts[];
|
|
45
|
+
/** Same names the DreamLake terminal gateway uses, so a browser terminal can attach to a runner-started session. */
|
|
46
|
+
export declare function tmuxSessionName(provider: Provider, cwd: string, nativeSessionId: string, claudeConfigDir?: string | null): string;
|
|
47
|
+
export declare const claudePermissionMode: (level: "read-only" | "workspace-write" | "full-access") => string;
|
|
48
|
+
export declare const codexSandbox: (level: "read-only" | "workspace-write" | "full-access") => string;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/** Native Codex / Claude session state on this machine, read-only.
|
|
2
|
+
*
|
|
3
|
+
* Both agents keep one JSONL transcript per session. These helpers locate a
|
|
4
|
+
* transcript by its UUID, read the few facts the control plane needs (working
|
|
5
|
+
* directory, last message role, activity time, Claude subagents) and derive a
|
|
6
|
+
* run-state heuristic. Nothing here uploads bytes; `sync` goes through the
|
|
7
|
+
* existing conversation parser and the owner's conditional upload.
|
|
8
|
+
*/
|
|
9
|
+
import { createHash } from 'node:crypto';
|
|
10
|
+
import { readdirSync, readFileSync, statSync, openSync, readSync, closeSync } from 'node:fs';
|
|
11
|
+
import { join } from 'node:path';
|
|
12
|
+
export const UUID = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i;
|
|
13
|
+
export const defaultRoots = (home, env = process.env) => ({ claude: env.CLAUDE_CONFIG_DIR || join(home, '.claude'), codex: env.CODEX_HOME || join(home, '.codex') });
|
|
14
|
+
/** Claude Code names a project directory after the working directory with every non-alphanumeric replaced. */
|
|
15
|
+
export const claudeProjectSlug = (cwd) => cwd.replace(/[^A-Za-z0-9]/g, '-');
|
|
16
|
+
export const claudeTranscriptPath = (root, cwd, id) => join(root, 'projects', claudeProjectSlug(cwd), `${id}.jsonl`);
|
|
17
|
+
export function findClaudeTranscript(root, id) {
|
|
18
|
+
if (!UUID.test(id))
|
|
19
|
+
return null;
|
|
20
|
+
let projects;
|
|
21
|
+
try {
|
|
22
|
+
projects = readdirSync(join(root, 'projects'));
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
for (const project of projects) {
|
|
28
|
+
const candidate = join(root, 'projects', project, `${id}.jsonl`);
|
|
29
|
+
try {
|
|
30
|
+
if (statSync(candidate).isFile())
|
|
31
|
+
return candidate;
|
|
32
|
+
}
|
|
33
|
+
catch { /* next */ }
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
/** `~/.codex/sessions/YYYY/MM/DD/rollout-<timestamp>-<uuid>.jsonl`, newest day first. */
|
|
38
|
+
export function findCodexRollout(root, id, since) {
|
|
39
|
+
if (!UUID.test(id))
|
|
40
|
+
return null;
|
|
41
|
+
const suffix = `-${id.toLowerCase()}.jsonl`;
|
|
42
|
+
for (const file of listCodexRollouts(root, since))
|
|
43
|
+
if (file.toLowerCase().endsWith(suffix))
|
|
44
|
+
return file;
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
export function listCodexRollouts(root, since) {
|
|
48
|
+
const out = [];
|
|
49
|
+
const walk = (dir, depth) => {
|
|
50
|
+
let entries;
|
|
51
|
+
try {
|
|
52
|
+
entries = readdirSync(dir).sort().reverse();
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
for (const entry of entries) {
|
|
58
|
+
const path = join(dir, entry);
|
|
59
|
+
let stat;
|
|
60
|
+
try {
|
|
61
|
+
stat = statSync(path);
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (stat.isDirectory() && depth < 3)
|
|
67
|
+
walk(path, depth + 1);
|
|
68
|
+
else if (stat.isFile() && entry.startsWith('rollout-') && entry.endsWith('.jsonl') && (since === undefined || stat.mtimeMs >= since))
|
|
69
|
+
out.push(path);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
walk(join(root, 'sessions'), 0);
|
|
73
|
+
return out;
|
|
74
|
+
}
|
|
75
|
+
/** Read a bounded head and tail; a multi-megabyte transcript is never loaded whole for a status check. */
|
|
76
|
+
export function transcriptFacts(provider, path, headBytes = 256 * 1024, tailBytes = 256 * 1024) {
|
|
77
|
+
const stat = statSync(path);
|
|
78
|
+
const fd = openSync(path, 'r');
|
|
79
|
+
let head = '', tail = '';
|
|
80
|
+
try {
|
|
81
|
+
const headBuffer = Buffer.alloc(Math.min(headBytes, stat.size));
|
|
82
|
+
readSync(fd, headBuffer, 0, headBuffer.length, 0);
|
|
83
|
+
head = headBuffer.toString('utf8');
|
|
84
|
+
const tailStart = Math.max(0, stat.size - tailBytes);
|
|
85
|
+
const tailBuffer = Buffer.alloc(stat.size - tailStart);
|
|
86
|
+
readSync(fd, tailBuffer, 0, tailBuffer.length, tailStart);
|
|
87
|
+
tail = tailBuffer.toString('utf8');
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
closeSync(fd);
|
|
91
|
+
}
|
|
92
|
+
const rows = (text) => text.split('\n').flatMap(line => { try {
|
|
93
|
+
return line.trim() ? [JSON.parse(line)] : [];
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return [];
|
|
97
|
+
} });
|
|
98
|
+
const facts = { cwd: null, nativeSessionId: null, createdAt: null, lastRole: null, lastAt: stat.mtimeMs, messages: 0, title: null };
|
|
99
|
+
const stamp = (value) => typeof value === 'string' && Number.isFinite(Date.parse(value)) ? Date.parse(value) : null;
|
|
100
|
+
for (const row of rows(head)) {
|
|
101
|
+
if (provider === 'codex' && row.type === 'session_meta') {
|
|
102
|
+
facts.cwd ??= typeof row.payload?.cwd === 'string' ? row.payload.cwd : null;
|
|
103
|
+
facts.nativeSessionId ??= typeof row.payload?.id === 'string' ? row.payload.id : null;
|
|
104
|
+
facts.createdAt ??= stamp(row.payload?.timestamp) ?? stamp(row.timestamp);
|
|
105
|
+
}
|
|
106
|
+
if (provider === 'claude') {
|
|
107
|
+
if (typeof row.cwd === 'string')
|
|
108
|
+
facts.cwd ??= row.cwd;
|
|
109
|
+
facts.createdAt ??= stamp(row.timestamp);
|
|
110
|
+
if (typeof row.sessionId === 'string')
|
|
111
|
+
facts.nativeSessionId ??= row.sessionId;
|
|
112
|
+
if (row.type === 'ai-title' && typeof row.title === 'string')
|
|
113
|
+
facts.title = row.title;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// The tail may start mid-line; the first fragment is dropped by the JSON parse.
|
|
117
|
+
for (const row of rows(tail)) {
|
|
118
|
+
const role = provider === 'codex'
|
|
119
|
+
? (row.type === 'response_item' && row.payload?.type === 'message' ? (row.payload.role === 'developer' ? 'system' : row.payload.role) : row.type === 'response_item' && /call/.test(String(row.payload?.type)) ? 'tool' : null)
|
|
120
|
+
: (row.type === 'user' || row.type === 'assistant') && row.message ? row.type : null;
|
|
121
|
+
if (role) {
|
|
122
|
+
facts.lastRole = role;
|
|
123
|
+
facts.messages++;
|
|
124
|
+
}
|
|
125
|
+
if (provider === 'claude' && row.type === 'ai-title' && typeof row.title === 'string')
|
|
126
|
+
facts.title = row.title;
|
|
127
|
+
}
|
|
128
|
+
return facts;
|
|
129
|
+
}
|
|
130
|
+
/** Heuristic, stated as such in the receipt: an alive process whose transcript ends with the assistant is waiting for a human. */
|
|
131
|
+
export function runStateFrom(input) {
|
|
132
|
+
const now = input.now ?? Date.now(), recent = now - input.lastAt < (input.busyWindowMs ?? 90_000);
|
|
133
|
+
if (input.alive === false)
|
|
134
|
+
return 'stopped';
|
|
135
|
+
if (input.alive === null)
|
|
136
|
+
return recent ? 'working' : 'unknown';
|
|
137
|
+
if (input.lastRole === 'assistant')
|
|
138
|
+
return recent ? 'working' : 'waiting';
|
|
139
|
+
if (input.lastRole === 'user' || input.lastRole === 'tool')
|
|
140
|
+
return recent ? 'working' : 'idle';
|
|
141
|
+
return 'idle';
|
|
142
|
+
}
|
|
143
|
+
/** Claude Code records each spawned subagent under `<project>/<sessionId>/subagents/agent-<id>.{jsonl,meta.json}`. */
|
|
144
|
+
export function claudeSubagents(transcriptPath) {
|
|
145
|
+
const dir = join(transcriptPath.replace(/\.jsonl$/, ''), 'subagents');
|
|
146
|
+
let entries;
|
|
147
|
+
try {
|
|
148
|
+
entries = readdirSync(dir);
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
return [];
|
|
152
|
+
}
|
|
153
|
+
return entries.filter(name => /^agent-[A-Za-z0-9_-]+\.jsonl$/.test(name)).map(name => {
|
|
154
|
+
const id = name.slice('agent-'.length, -'.jsonl'.length), stat = statSync(join(dir, name));
|
|
155
|
+
let meta = {};
|
|
156
|
+
try {
|
|
157
|
+
meta = JSON.parse(readFileSync(join(dir, `agent-${id}.meta.json`), 'utf8'));
|
|
158
|
+
}
|
|
159
|
+
catch { /* optional */ }
|
|
160
|
+
return { id, agentType: typeof meta.agentType === 'string' ? meta.agentType : null, description: typeof meta.description === 'string' ? meta.description.slice(0, 200) : null,
|
|
161
|
+
finished: typeof meta.finished === 'boolean' ? meta.finished : null, lastAt: stat.mtime.toISOString(), bytes: stat.size };
|
|
162
|
+
}).sort((a, b) => a.lastAt < b.lastAt ? 1 : -1).slice(0, 50);
|
|
163
|
+
}
|
|
164
|
+
/** Same names the DreamLake terminal gateway uses, so a browser terminal can attach to a runner-started session. */
|
|
165
|
+
export function tmuxSessionName(provider, cwd, nativeSessionId, claudeConfigDir) {
|
|
166
|
+
const digest = (parts) => createHash('sha256').update(JSON.stringify(parts)).digest('hex').slice(0, 32);
|
|
167
|
+
return provider === 'codex' ? `dl-codex-${digest([cwd, nativeSessionId])}` : `dl-claude-${digest([cwd, nativeSessionId, claudeConfigDir ?? null])}`;
|
|
168
|
+
}
|
|
169
|
+
export const claudePermissionMode = (level) => ({ 'read-only': 'plan', 'workspace-write': 'acceptEdits', 'full-access': 'bypassPermissions' })[level];
|
|
170
|
+
export const codexSandbox = (level) => ({ 'read-only': 'read-only', 'workspace-write': 'workspace-write', 'full-access': 'danger-full-access' })[level];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { PermissionLevel, Provider } from '../../../api/index.js';
|
|
2
|
+
import { type Run } from './exec.js';
|
|
3
|
+
export interface PodConfig {
|
|
4
|
+
image: string;
|
|
5
|
+
repositories: string[];
|
|
6
|
+
envFiles?: Partial<Record<Provider, string>>;
|
|
7
|
+
network: 'none' | 'bridge';
|
|
8
|
+
cpus: number;
|
|
9
|
+
memoryMb: number;
|
|
10
|
+
}
|
|
11
|
+
export interface PodBinding {
|
|
12
|
+
kind: 'pod';
|
|
13
|
+
container: string;
|
|
14
|
+
owner: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function loadPodConfig(path: string): PodConfig;
|
|
17
|
+
export declare class Pods {
|
|
18
|
+
private readonly exec;
|
|
19
|
+
readonly config: PodConfig;
|
|
20
|
+
private readonly owner;
|
|
21
|
+
constructor(exec: Run, config: PodConfig, owner: string);
|
|
22
|
+
inspect(binding: PodBinding): Promise<{
|
|
23
|
+
id: string;
|
|
24
|
+
running: boolean;
|
|
25
|
+
}>;
|
|
26
|
+
create(commandId: string, repo: string, provider: Provider, permission: PermissionLevel, signal: AbortSignal, checkpoint: (binding: PodBinding) => void): Promise<PodBinding>;
|
|
27
|
+
stop(binding: PodBinding): Promise<void>;
|
|
28
|
+
transcript(binding: PodBinding, provider: Provider, nativeId: string): Promise<string>;
|
|
29
|
+
run(binding: PodBinding): Run;
|
|
30
|
+
}
|