@hoknie/aip 0.0.0-stage → 0.1.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/.claude-plugin/marketplace.json +13 -0
- package/README.md +74 -2
- package/dist/app/agents.js +18 -0
- package/dist/app/agents.js.map +1 -0
- package/dist/app/application.js +173 -0
- package/dist/app/application.js.map +1 -0
- package/dist/app/daemon.js +71 -0
- package/dist/app/daemon.js.map +1 -0
- package/dist/app/index.js +5 -0
- package/dist/app/index.js.map +1 -0
- package/dist/app/lifecycle.js +30 -0
- package/dist/app/lifecycle.js.map +1 -0
- package/dist/app/maintenance.js +27 -0
- package/dist/app/maintenance.js.map +1 -0
- package/dist/app/timings.js +23 -0
- package/dist/app/timings.js.map +1 -0
- package/dist/app/wiring.js +57 -0
- package/dist/app/wiring.js.map +1 -0
- package/dist/cli/clean.js +71 -0
- package/dist/cli/clean.js.map +1 -0
- package/dist/cli/commands.js +963 -0
- package/dist/cli/commands.js.map +1 -0
- package/dist/cli/config-check.js +173 -0
- package/dist/cli/config-check.js.map +1 -0
- package/dist/cli/daemon.js +199 -0
- package/dist/cli/daemon.js.map +1 -0
- package/dist/cli/help.js +50 -0
- package/dist/cli/help.js.map +1 -0
- package/dist/cli/init.js +43 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/cli/io.js +13 -0
- package/dist/cli/io.js.map +1 -0
- package/dist/cli/main.js +31 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/cli/probe.js +12 -0
- package/dist/cli/probe.js.map +1 -0
- package/dist/cli/program.js +48 -0
- package/dist/cli/program.js.map +1 -0
- package/dist/cli/setup.js +406 -0
- package/dist/cli/setup.js.map +1 -0
- package/dist/cli/version.js +6 -0
- package/dist/cli/version.js.map +1 -0
- package/dist/cli/watch.js +24 -0
- package/dist/cli/watch.js.map +1 -0
- package/dist/cli/web/daemon-panel.js +185 -0
- package/dist/cli/web/daemon-panel.js.map +1 -0
- package/dist/cli/web/default-repository.js +12 -0
- package/dist/cli/web/default-repository.js.map +1 -0
- package/dist/cli/web/errors.js +60 -0
- package/dist/cli/web/errors.js.map +1 -0
- package/dist/cli/web/open.js +12 -0
- package/dist/cli/web/open.js.map +1 -0
- package/dist/cli/web/page.js +465 -0
- package/dist/cli/web/page.js.map +1 -0
- package/dist/cli/web/server.js +1191 -0
- package/dist/cli/web/server.js.map +1 -0
- package/dist/cli/web/standby.js +119 -0
- package/dist/cli/web/standby.js.map +1 -0
- package/dist/cli/web/state.js +69 -0
- package/dist/cli/web/state.js.map +1 -0
- package/dist/cli/web/system.js +66 -0
- package/dist/cli/web/system.js.map +1 -0
- package/dist/cli/web-control.js +173 -0
- package/dist/cli/web-control.js.map +1 -0
- package/dist/config/discover.js +25 -0
- package/dist/config/discover.js.map +1 -0
- package/dist/config/duration.js +17 -0
- package/dist/config/duration.js.map +1 -0
- package/dist/config/edit.js +966 -0
- package/dist/config/edit.js.map +1 -0
- package/dist/config/errors.js +29 -0
- package/dist/config/errors.js.map +1 -0
- package/dist/config/index.js +14 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/load.js +412 -0
- package/dist/config/load.js.map +1 -0
- package/dist/config/merge.js +45 -0
- package/dist/config/merge.js.map +1 -0
- package/dist/config/model.js +171 -0
- package/dist/config/model.js.map +1 -0
- package/dist/config/paths.js +31 -0
- package/dist/config/paths.js.map +1 -0
- package/dist/config/prompt.js +33 -0
- package/dist/config/prompt.js.map +1 -0
- package/dist/config/shared-pipelines.js +71 -0
- package/dist/config/shared-pipelines.js.map +1 -0
- package/dist/config/shared-specialists.js +68 -0
- package/dist/config/shared-specialists.js.map +1 -0
- package/dist/config/shared-workflows.js +71 -0
- package/dist/config/shared-workflows.js.map +1 -0
- package/dist/config/specialist-tags.js +214 -0
- package/dist/config/specialist-tags.js.map +1 -0
- package/dist/config/tag-names.js +43 -0
- package/dist/config/tag-names.js.map +1 -0
- package/dist/config/validate.js +872 -0
- package/dist/config/validate.js.map +1 -0
- package/dist/core/artifacts.js +37 -0
- package/dist/core/artifacts.js.map +1 -0
- package/dist/core/create.js +75 -0
- package/dist/core/create.js.map +1 -0
- package/dist/core/delivery.js +366 -0
- package/dist/core/delivery.js.map +1 -0
- package/dist/core/errors.js +7 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/ids.js +99 -0
- package/dist/core/ids.js.map +1 -0
- package/dist/core/index.js +21 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/input.js +45 -0
- package/dist/core/input.js.map +1 -0
- package/dist/core/machine.js +1021 -0
- package/dist/core/machine.js.map +1 -0
- package/dist/core/model.js +460 -0
- package/dist/core/model.js.map +1 -0
- package/dist/core/observer.js +193 -0
- package/dist/core/observer.js.map +1 -0
- package/dist/core/occupancy.js +63 -0
- package/dist/core/occupancy.js.map +1 -0
- package/dist/core/permissions.js +222 -0
- package/dist/core/permissions.js.map +1 -0
- package/dist/core/plan.js +99 -0
- package/dist/core/plan.js.map +1 -0
- package/dist/core/progress.js +43 -0
- package/dist/core/progress.js.map +1 -0
- package/dist/core/questions.js +19 -0
- package/dist/core/questions.js.map +1 -0
- package/dist/core/queue.js +859 -0
- package/dist/core/queue.js.map +1 -0
- package/dist/core/retryable.js +8 -0
- package/dist/core/retryable.js.map +1 -0
- package/dist/core/scheduler.js +160 -0
- package/dist/core/scheduler.js.map +1 -0
- package/dist/core/skip.js +109 -0
- package/dist/core/skip.js.map +1 -0
- package/dist/core/stages.js +304 -0
- package/dist/core/stages.js.map +1 -0
- package/dist/core/summary.js +35 -0
- package/dist/core/summary.js.map +1 -0
- package/dist/core/tags.js +184 -0
- package/dist/core/tags.js.map +1 -0
- package/dist/core/topology.js +162 -0
- package/dist/core/topology.js.map +1 -0
- package/dist/daemon/artifacts.js +84 -0
- package/dist/daemon/artifacts.js.map +1 -0
- package/dist/daemon/daemon.js +1442 -0
- package/dist/daemon/daemon.js.map +1 -0
- package/dist/daemon/executor.js +749 -0
- package/dist/daemon/executor.js.map +1 -0
- package/dist/daemon/helpers.js +38 -0
- package/dist/daemon/helpers.js.map +1 -0
- package/dist/daemon/index.js +4 -0
- package/dist/daemon/index.js.map +1 -0
- package/dist/daemon/logs.js +69 -0
- package/dist/daemon/logs.js.map +1 -0
- package/dist/daemon/observers.js +93 -0
- package/dist/daemon/observers.js.map +1 -0
- package/dist/daemon/patches.js +76 -0
- package/dist/daemon/patches.js.map +1 -0
- package/dist/daemon/ports.js +2 -0
- package/dist/daemon/ports.js.map +1 -0
- package/dist/daemon/processes.js +98 -0
- package/dist/daemon/processes.js.map +1 -0
- package/dist/daemon/repositories.js +2 -0
- package/dist/daemon/repositories.js.map +1 -0
- package/dist/daemon/server.js +164 -0
- package/dist/daemon/server.js.map +1 -0
- package/dist/daemon/supervisor.js +140 -0
- package/dist/daemon/supervisor.js.map +1 -0
- package/dist/daemon/timings.js +23 -0
- package/dist/daemon/timings.js.map +1 -0
- package/dist/feature/agents/clients/agy/events.js +36 -0
- package/dist/feature/agents/clients/agy/events.js.map +1 -0
- package/dist/feature/agents/clients/agy/guard-commands.js +29 -0
- package/dist/feature/agents/clients/agy/guard-commands.js.map +1 -0
- package/dist/feature/agents/clients/agy/guard-paths.js +36 -0
- package/dist/feature/agents/clients/agy/guard-paths.js.map +1 -0
- package/dist/feature/agents/clients/agy/guard.js +77 -0
- package/dist/feature/agents/clients/agy/guard.js.map +1 -0
- package/dist/feature/agents/clients/agy/hooks.js +46 -0
- package/dist/feature/agents/clients/agy/hooks.js.map +1 -0
- package/dist/feature/agents/clients/agy/index.js +5 -0
- package/dist/feature/agents/clients/agy/index.js.map +1 -0
- package/dist/feature/agents/clients/agy/parser.js +63 -0
- package/dist/feature/agents/clients/agy/parser.js.map +1 -0
- package/dist/feature/agents/clients/agy/permissions.js +40 -0
- package/dist/feature/agents/clients/agy/permissions.js.map +1 -0
- package/dist/feature/agents/clients/agy/runtime.js +114 -0
- package/dist/feature/agents/clients/agy/runtime.js.map +1 -0
- package/dist/feature/agents/clients/agy/transcript.js +65 -0
- package/dist/feature/agents/clients/agy/transcript.js.map +1 -0
- package/dist/feature/agents/clients/claude/index.js +5 -0
- package/dist/feature/agents/clients/claude/index.js.map +1 -0
- package/dist/feature/agents/clients/claude/parser.js +221 -0
- package/dist/feature/agents/clients/claude/parser.js.map +1 -0
- package/dist/feature/agents/clients/claude/permissions.js +70 -0
- package/dist/feature/agents/clients/claude/permissions.js.map +1 -0
- package/dist/feature/agents/clients/claude/runtime.js +116 -0
- package/dist/feature/agents/clients/claude/runtime.js.map +1 -0
- package/dist/feature/agents/clients/claude/transcript.js +105 -0
- package/dist/feature/agents/clients/claude/transcript.js.map +1 -0
- package/dist/feature/agents/clients/naming/index.js +2 -0
- package/dist/feature/agents/clients/naming/index.js.map +1 -0
- package/dist/feature/agents/clients/naming/naming.js +15 -0
- package/dist/feature/agents/clients/naming/naming.js.map +1 -0
- package/dist/feature/agents/clients/opencode/index.js +4 -0
- package/dist/feature/agents/clients/opencode/index.js.map +1 -0
- package/dist/feature/agents/clients/opencode/parser.js +84 -0
- package/dist/feature/agents/clients/opencode/parser.js.map +1 -0
- package/dist/feature/agents/clients/opencode/runtime.js +129 -0
- package/dist/feature/agents/clients/opencode/runtime.js.map +1 -0
- package/dist/feature/agents/clients/opencode/transcript.js +77 -0
- package/dist/feature/agents/clients/opencode/transcript.js.map +1 -0
- package/dist/feature/agents/ports/index.js +2 -0
- package/dist/feature/agents/ports/index.js.map +1 -0
- package/dist/feature/agents/ports/naming.js +2 -0
- package/dist/feature/agents/ports/naming.js.map +1 -0
- package/dist/feature/agents/ports/runtime-factory.js +2 -0
- package/dist/feature/agents/ports/runtime-factory.js.map +1 -0
- package/dist/feature/agents/services/agents.js +38 -0
- package/dist/feature/agents/services/agents.js.map +1 -0
- package/dist/feature/agents/services/catalog.js +117 -0
- package/dist/feature/agents/services/catalog.js.map +1 -0
- package/dist/feature/agents/services/create.js +5 -0
- package/dist/feature/agents/services/create.js.map +1 -0
- package/dist/feature/agents/services/index.js +7 -0
- package/dist/feature/agents/services/index.js.map +1 -0
- package/dist/feature/agents/services/logs.js +69 -0
- package/dist/feature/agents/services/logs.js.map +1 -0
- package/dist/feature/agents/services/skills.js +17 -0
- package/dist/feature/agents/services/skills.js.map +1 -0
- package/dist/feature/agents/services/supervisor.js +160 -0
- package/dist/feature/agents/services/supervisor.js.map +1 -0
- package/dist/feature/agents/types/catalog.js +2 -0
- package/dist/feature/agents/types/catalog.js.map +1 -0
- package/dist/feature/agents/types/index.js +12 -0
- package/dist/feature/agents/types/index.js.map +1 -0
- package/dist/feature/agents/types/message.js +48 -0
- package/dist/feature/agents/types/message.js.map +1 -0
- package/dist/feature/agents/types/naming.js +4 -0
- package/dist/feature/agents/types/naming.js.map +1 -0
- package/dist/feature/agents/types/permissions.js +235 -0
- package/dist/feature/agents/types/permissions.js.map +1 -0
- package/dist/feature/agents/types/run-naming.js +66 -0
- package/dist/feature/agents/types/run-naming.js.map +1 -0
- package/dist/feature/agents/types/runtime.js +18 -0
- package/dist/feature/agents/types/runtime.js.map +1 -0
- package/dist/feature/agents/types/step-input.js +2 -0
- package/dist/feature/agents/types/step-input.js.map +1 -0
- package/dist/feature/agents/types/transcript-parts.js +62 -0
- package/dist/feature/agents/types/transcript-parts.js.map +1 -0
- package/dist/feature/agents/types/transcript.js +8 -0
- package/dist/feature/agents/types/transcript.js.map +1 -0
- package/dist/feature/agents/types/usage.js +14 -0
- package/dist/feature/agents/types/usage.js.map +1 -0
- package/dist/feature/agents/types/worker-tools.js +20 -0
- package/dist/feature/agents/types/worker-tools.js.map +1 -0
- package/dist/feature/artifacts/ports/index.js +2 -0
- package/dist/feature/artifacts/ports/index.js.map +1 -0
- package/dist/feature/artifacts/ports/publish.js +2 -0
- package/dist/feature/artifacts/ports/publish.js.map +1 -0
- package/dist/feature/artifacts/repositories/artifact-storage.js +84 -0
- package/dist/feature/artifacts/repositories/artifact-storage.js.map +1 -0
- package/dist/feature/artifacts/repositories/artifacts.js +85 -0
- package/dist/feature/artifacts/repositories/artifacts.js.map +1 -0
- package/dist/feature/artifacts/repositories/index.js +3 -0
- package/dist/feature/artifacts/repositories/index.js.map +1 -0
- package/dist/feature/artifacts/services/artifacts.js +105 -0
- package/dist/feature/artifacts/services/artifacts.js.map +1 -0
- package/dist/feature/artifacts/services/create.js +14 -0
- package/dist/feature/artifacts/services/create.js.map +1 -0
- package/dist/feature/artifacts/services/files.js +42 -0
- package/dist/feature/artifacts/services/files.js.map +1 -0
- package/dist/feature/artifacts/services/index.js +3 -0
- package/dist/feature/artifacts/services/index.js.map +1 -0
- package/dist/feature/artifacts/types/artifacts.js +36 -0
- package/dist/feature/artifacts/types/artifacts.js.map +1 -0
- package/dist/feature/artifacts/types/index.js +2 -0
- package/dist/feature/artifacts/types/index.js.map +1 -0
- package/dist/feature/artifacts/types/views.js +2 -0
- package/dist/feature/artifacts/types/views.js.map +1 -0
- package/dist/feature/compose/services/create.js +11 -0
- package/dist/feature/compose/services/create.js.map +1 -0
- package/dist/feature/compose/services/index.js +5 -0
- package/dist/feature/compose/services/index.js.map +1 -0
- package/dist/feature/compose/services/repository-edit.js +20 -0
- package/dist/feature/compose/services/repository-edit.js.map +1 -0
- package/dist/feature/compose/services/repository-move.js +35 -0
- package/dist/feature/compose/services/repository-move.js.map +1 -0
- package/dist/feature/compose/services/repository-removal.js +38 -0
- package/dist/feature/compose/services/repository-removal.js.map +1 -0
- package/dist/feature/delivery/ports/index.js +2 -0
- package/dist/feature/delivery/ports/index.js.map +1 -0
- package/dist/feature/delivery/ports/publish.js +2 -0
- package/dist/feature/delivery/ports/publish.js.map +1 -0
- package/dist/feature/delivery/repositories/index.js +3 -0
- package/dist/feature/delivery/repositories/index.js.map +1 -0
- package/dist/feature/delivery/repositories/patch-storage.js +76 -0
- package/dist/feature/delivery/repositories/patch-storage.js.map +1 -0
- package/dist/feature/delivery/repositories/patches.js +28 -0
- package/dist/feature/delivery/repositories/patches.js.map +1 -0
- package/dist/feature/delivery/services/create.js +21 -0
- package/dist/feature/delivery/services/create.js.map +1 -0
- package/dist/feature/delivery/services/deliver.js +67 -0
- package/dist/feature/delivery/services/deliver.js.map +1 -0
- package/dist/feature/delivery/services/diffs.js +153 -0
- package/dist/feature/delivery/services/diffs.js.map +1 -0
- package/dist/feature/delivery/services/index.js +5 -0
- package/dist/feature/delivery/services/index.js.map +1 -0
- package/dist/feature/delivery/services/patches.js +96 -0
- package/dist/feature/delivery/services/patches.js.map +1 -0
- package/dist/feature/delivery/types/index.js +3 -0
- package/dist/feature/delivery/types/index.js.map +1 -0
- package/dist/feature/delivery/types/outcomes.js +2 -0
- package/dist/feature/delivery/types/outcomes.js.map +1 -0
- package/dist/feature/delivery/types/spec-change.js +18 -0
- package/dist/feature/delivery/types/spec-change.js.map +1 -0
- package/dist/feature/observers/ports/index.js +2 -0
- package/dist/feature/observers/ports/index.js.map +1 -0
- package/dist/feature/observers/ports/publish.js +2 -0
- package/dist/feature/observers/ports/publish.js.map +1 -0
- package/dist/feature/observers/repositories/index.js +2 -0
- package/dist/feature/observers/repositories/index.js.map +1 -0
- package/dist/feature/observers/repositories/observers.js +28 -0
- package/dist/feature/observers/repositories/observers.js.map +1 -0
- package/dist/feature/observers/services/create.js +11 -0
- package/dist/feature/observers/services/create.js.map +1 -0
- package/dist/feature/observers/services/history.js +76 -0
- package/dist/feature/observers/services/history.js.map +1 -0
- package/dist/feature/observers/services/index.js +5 -0
- package/dist/feature/observers/services/index.js.map +1 -0
- package/dist/feature/observers/services/observers.js +178 -0
- package/dist/feature/observers/services/observers.js.map +1 -0
- package/dist/feature/observers/services/settings-check.js +93 -0
- package/dist/feature/observers/services/settings-check.js.map +1 -0
- package/dist/feature/observers/types/actions.js +2 -0
- package/dist/feature/observers/types/actions.js.map +1 -0
- package/dist/feature/observers/types/index.js +4 -0
- package/dist/feature/observers/types/index.js.map +1 -0
- package/dist/feature/observers/types/plan-repairs.js +109 -0
- package/dist/feature/observers/types/plan-repairs.js.map +1 -0
- package/dist/feature/observers/types/settings.js +13 -0
- package/dist/feature/observers/types/settings.js.map +1 -0
- package/dist/feature/processes/ports/index.js +2 -0
- package/dist/feature/processes/ports/index.js.map +1 -0
- package/dist/feature/processes/ports/publish.js +2 -0
- package/dist/feature/processes/ports/publish.js.map +1 -0
- package/dist/feature/processes/services/create.js +5 -0
- package/dist/feature/processes/services/create.js.map +1 -0
- package/dist/feature/processes/services/index.js +4 -0
- package/dist/feature/processes/services/index.js.map +1 -0
- package/dist/feature/processes/services/processes.js +131 -0
- package/dist/feature/processes/services/processes.js.map +1 -0
- package/dist/feature/processes/services/tree.js +98 -0
- package/dist/feature/processes/services/tree.js.map +1 -0
- package/dist/feature/processes/types/background.js +2 -0
- package/dist/feature/processes/types/background.js.map +1 -0
- package/dist/feature/processes/types/index.js +2 -0
- package/dist/feature/processes/types/index.js.map +1 -0
- package/dist/feature/queue/ports/index.js +2 -0
- package/dist/feature/queue/ports/index.js.map +1 -0
- package/dist/feature/queue/ports/observe.js +2 -0
- package/dist/feature/queue/ports/observe.js.map +1 -0
- package/dist/feature/queue/ports/publish.js +2 -0
- package/dist/feature/queue/ports/publish.js.map +1 -0
- package/dist/feature/queue/ports/repair-policy.js +2 -0
- package/dist/feature/queue/ports/repair-policy.js.map +1 -0
- package/dist/feature/queue/repositories/index.js +2 -0
- package/dist/feature/queue/repositories/index.js.map +1 -0
- package/dist/feature/queue/repositories/queues.js +100 -0
- package/dist/feature/queue/repositories/queues.js.map +1 -0
- package/dist/feature/queue/services/advance.js +214 -0
- package/dist/feature/queue/services/advance.js.map +1 -0
- package/dist/feature/queue/services/control.js +153 -0
- package/dist/feature/queue/services/control.js.map +1 -0
- package/dist/feature/queue/services/create.js +26 -0
- package/dist/feature/queue/services/create.js.map +1 -0
- package/dist/feature/queue/services/edit.js +126 -0
- package/dist/feature/queue/services/edit.js.map +1 -0
- package/dist/feature/queue/services/index.js +8 -0
- package/dist/feature/queue/services/index.js.map +1 -0
- package/dist/feature/queue/services/items.js +173 -0
- package/dist/feature/queue/services/items.js.map +1 -0
- package/dist/feature/queue/services/store.js +61 -0
- package/dist/feature/queue/services/store.js.map +1 -0
- package/dist/feature/queue/services/task-tags.js +103 -0
- package/dist/feature/queue/services/task-tags.js.map +1 -0
- package/dist/feature/queue/types/advance.js +183 -0
- package/dist/feature/queue/types/advance.js.map +1 -0
- package/dist/feature/queue/types/dependencies.js +98 -0
- package/dist/feature/queue/types/dependencies.js.map +1 -0
- package/dist/feature/queue/types/edit.js +180 -0
- package/dist/feature/queue/types/edit.js.map +1 -0
- package/dist/feature/queue/types/ids.js +7 -0
- package/dist/feature/queue/types/ids.js.map +1 -0
- package/dist/feature/queue/types/index.js +10 -0
- package/dist/feature/queue/types/index.js.map +1 -0
- package/dist/feature/queue/types/items.js +46 -0
- package/dist/feature/queue/types/items.js.map +1 -0
- package/dist/feature/queue/types/limit-hits.js +50 -0
- package/dist/feature/queue/types/limit-hits.js.map +1 -0
- package/dist/feature/queue/types/requests.js +2 -0
- package/dist/feature/queue/types/requests.js.map +1 -0
- package/dist/feature/queue/types/returns.js +182 -0
- package/dist/feature/queue/types/returns.js.map +1 -0
- package/dist/feature/queue/types/settings.js +117 -0
- package/dist/feature/queue/types/settings.js.map +1 -0
- package/dist/feature/repos/ports/index.js +2 -0
- package/dist/feature/repos/ports/index.js.map +1 -0
- package/dist/feature/repos/ports/publish.js +2 -0
- package/dist/feature/repos/ports/publish.js.map +1 -0
- package/dist/feature/repos/repositories/index.js +2 -0
- package/dist/feature/repos/repositories/index.js.map +1 -0
- package/dist/feature/repos/repositories/known.js +41 -0
- package/dist/feature/repos/repositories/known.js.map +1 -0
- package/dist/feature/repos/services/create.js +13 -0
- package/dist/feature/repos/services/create.js.map +1 -0
- package/dist/feature/repos/services/index.js +4 -0
- package/dist/feature/repos/services/index.js.map +1 -0
- package/dist/feature/repos/services/projects.js +50 -0
- package/dist/feature/repos/services/projects.js.map +1 -0
- package/dist/feature/repos/services/registry.js +138 -0
- package/dist/feature/repos/services/registry.js.map +1 -0
- package/dist/feature/repos/types/index.js +2 -0
- package/dist/feature/repos/types/index.js.map +1 -0
- package/dist/feature/repos/types/project.js +80 -0
- package/dist/feature/repos/types/project.js.map +1 -0
- package/dist/feature/repos/types/registry.js +2 -0
- package/dist/feature/repos/types/registry.js.map +1 -0
- package/dist/feature/runs/machine/answers.js +112 -0
- package/dist/feature/runs/machine/answers.js.map +1 -0
- package/dist/feature/runs/machine/delivery-checks.js +91 -0
- package/dist/feature/runs/machine/delivery-checks.js.map +1 -0
- package/dist/feature/runs/machine/delivery-flow.js +211 -0
- package/dist/feature/runs/machine/delivery-flow.js.map +1 -0
- package/dist/feature/runs/machine/events.js +2 -0
- package/dist/feature/runs/machine/events.js.map +1 -0
- package/dist/feature/runs/machine/exits.js +207 -0
- package/dist/feature/runs/machine/exits.js.map +1 -0
- package/dist/feature/runs/machine/index.js +7 -0
- package/dist/feature/runs/machine/index.js.map +1 -0
- package/dist/feature/runs/machine/plan.js +111 -0
- package/dist/feature/runs/machine/plan.js.map +1 -0
- package/dist/feature/runs/machine/repair.js +155 -0
- package/dist/feature/runs/machine/repair.js.map +1 -0
- package/dist/feature/runs/machine/run-control.js +276 -0
- package/dist/feature/runs/machine/run-control.js.map +1 -0
- package/dist/feature/runs/machine/scheduler.js +119 -0
- package/dist/feature/runs/machine/scheduler.js.map +1 -0
- package/dist/feature/runs/machine/steps.js +275 -0
- package/dist/feature/runs/machine/steps.js.map +1 -0
- package/dist/feature/runs/machine/texts.js +69 -0
- package/dist/feature/runs/machine/texts.js.map +1 -0
- package/dist/feature/runs/machine/transition.js +113 -0
- package/dist/feature/runs/machine/transition.js.map +1 -0
- package/dist/feature/runs/ports/agent-exit.js +2 -0
- package/dist/feature/runs/ports/agent-exit.js.map +1 -0
- package/dist/feature/runs/ports/diff.js +2 -0
- package/dist/feature/runs/ports/diff.js.map +1 -0
- package/dist/feature/runs/ports/index.js +2 -0
- package/dist/feature/runs/ports/index.js.map +1 -0
- package/dist/feature/runs/ports/observe.js +2 -0
- package/dist/feature/runs/ports/observe.js.map +1 -0
- package/dist/feature/runs/ports/publish.js +2 -0
- package/dist/feature/runs/ports/publish.js.map +1 -0
- package/dist/feature/runs/ports/queue-advance.js +2 -0
- package/dist/feature/runs/ports/queue-advance.js.map +1 -0
- package/dist/feature/runs/repositories/attempt-history.js +116 -0
- package/dist/feature/runs/repositories/attempt-history.js.map +1 -0
- package/dist/feature/runs/repositories/finished-runs.js +42 -0
- package/dist/feature/runs/repositories/finished-runs.js.map +1 -0
- package/dist/feature/runs/repositories/index.js +4 -0
- package/dist/feature/runs/repositories/index.js.map +1 -0
- package/dist/feature/runs/repositories/rows.js +110 -0
- package/dist/feature/runs/repositories/rows.js.map +1 -0
- package/dist/feature/runs/repositories/runs.js +76 -0
- package/dist/feature/runs/repositories/runs.js.map +1 -0
- package/dist/feature/runs/repositories/write.js +31 -0
- package/dist/feature/runs/repositories/write.js.map +1 -0
- package/dist/feature/runs/services/archive.js +17 -0
- package/dist/feature/runs/services/archive.js.map +1 -0
- package/dist/feature/runs/services/attempt-history.js +11 -0
- package/dist/feature/runs/services/attempt-history.js.map +1 -0
- package/dist/feature/runs/services/create.js +43 -0
- package/dist/feature/runs/services/create.js.map +1 -0
- package/dist/feature/runs/services/effects/actions.js +150 -0
- package/dist/feature/runs/services/effects/actions.js.map +1 -0
- package/dist/feature/runs/services/effects/attempts.js +179 -0
- package/dist/feature/runs/services/effects/attempts.js.map +1 -0
- package/dist/feature/runs/services/effects/context.js +7 -0
- package/dist/feature/runs/services/effects/context.js.map +1 -0
- package/dist/feature/runs/services/effects/effects.js +82 -0
- package/dist/feature/runs/services/effects/effects.js.map +1 -0
- package/dist/feature/runs/services/effects/git.js +168 -0
- package/dist/feature/runs/services/effects/git.js.map +1 -0
- package/dist/feature/runs/services/effects/naming.js +62 -0
- package/dist/feature/runs/services/effects/naming.js.map +1 -0
- package/dist/feature/runs/services/effects/outside.js +83 -0
- package/dist/feature/runs/services/effects/outside.js.map +1 -0
- package/dist/feature/runs/services/effects/running.js +76 -0
- package/dist/feature/runs/services/effects/running.js.map +1 -0
- package/dist/feature/runs/services/effects/usage.js +61 -0
- package/dist/feature/runs/services/effects/usage.js.map +1 -0
- package/dist/feature/runs/services/effects/worktrees.js +49 -0
- package/dist/feature/runs/services/effects/worktrees.js.map +1 -0
- package/dist/feature/runs/services/engine.js +163 -0
- package/dist/feature/runs/services/engine.js.map +1 -0
- package/dist/feature/runs/services/index.js +15 -0
- package/dist/feature/runs/services/index.js.map +1 -0
- package/dist/feature/runs/services/occupancy.js +62 -0
- package/dist/feature/runs/services/occupancy.js.map +1 -0
- package/dist/feature/runs/services/progress.js +42 -0
- package/dist/feature/runs/services/progress.js.map +1 -0
- package/dist/feature/runs/services/reads.js +54 -0
- package/dist/feature/runs/services/reads.js.map +1 -0
- package/dist/feature/runs/services/recovery.js +17 -0
- package/dist/feature/runs/services/recovery.js.map +1 -0
- package/dist/feature/runs/services/refresh.js +29 -0
- package/dist/feature/runs/services/refresh.js.map +1 -0
- package/dist/feature/runs/services/requests.js +88 -0
- package/dist/feature/runs/services/requests.js.map +1 -0
- package/dist/feature/runs/services/states.js +112 -0
- package/dist/feature/runs/services/states.js.map +1 -0
- package/dist/feature/runs/services/summary.js +38 -0
- package/dist/feature/runs/services/summary.js.map +1 -0
- package/dist/feature/runs/types/attempt.js +102 -0
- package/dist/feature/runs/types/attempt.js.map +1 -0
- package/dist/feature/runs/types/constants.js +45 -0
- package/dist/feature/runs/types/constants.js.map +1 -0
- package/dist/feature/runs/types/create.js +177 -0
- package/dist/feature/runs/types/create.js.map +1 -0
- package/dist/feature/runs/types/group.js +152 -0
- package/dist/feature/runs/types/group.js.map +1 -0
- package/dist/feature/runs/types/history/attempt-history.js +16 -0
- package/dist/feature/runs/types/history/attempt-history.js.map +1 -0
- package/dist/feature/runs/types/index.js +15 -0
- package/dist/feature/runs/types/index.js.map +1 -0
- package/dist/feature/runs/types/input.js +57 -0
- package/dist/feature/runs/types/input.js.map +1 -0
- package/dist/feature/runs/types/limits.js +151 -0
- package/dist/feature/runs/types/limits.js.map +1 -0
- package/dist/feature/runs/types/problems.js +74 -0
- package/dist/feature/runs/types/problems.js.map +1 -0
- package/dist/feature/runs/types/run.js +162 -0
- package/dist/feature/runs/types/run.js.map +1 -0
- package/dist/feature/runs/types/skip.js +110 -0
- package/dist/feature/runs/types/skip.js.map +1 -0
- package/dist/feature/runs/types/stage-status.js +156 -0
- package/dist/feature/runs/types/stage-status.js.map +1 -0
- package/dist/feature/runs/types/stages.js +158 -0
- package/dist/feature/runs/types/stages.js.map +1 -0
- package/dist/feature/runs/types/topology.js +165 -0
- package/dist/feature/runs/types/topology.js.map +1 -0
- package/dist/feature/swarm-config/repositories/config-files.js +141 -0
- package/dist/feature/swarm-config/repositories/config-files.js.map +1 -0
- package/dist/feature/swarm-config/services/assemble.js +212 -0
- package/dist/feature/swarm-config/services/assemble.js.map +1 -0
- package/dist/feature/swarm-config/services/create.js +5 -0
- package/dist/feature/swarm-config/services/create.js.map +1 -0
- package/dist/feature/swarm-config/services/discover.js +19 -0
- package/dist/feature/swarm-config/services/discover.js.map +1 -0
- package/dist/feature/swarm-config/services/index.js +9 -0
- package/dist/feature/swarm-config/services/index.js.map +1 -0
- package/dist/feature/swarm-config/services/load.js +86 -0
- package/dist/feature/swarm-config/services/load.js.map +1 -0
- package/dist/feature/swarm-config/services/settings.js +50 -0
- package/dist/feature/swarm-config/services/settings.js.map +1 -0
- package/dist/feature/swarm-config/services/validate-actions.js +117 -0
- package/dist/feature/swarm-config/services/validate-actions.js.map +1 -0
- package/dist/feature/swarm-config/services/validate-context.js +91 -0
- package/dist/feature/swarm-config/services/validate-context.js.map +1 -0
- package/dist/feature/swarm-config/services/validate-pipelines.js +170 -0
- package/dist/feature/swarm-config/services/validate-pipelines.js.map +1 -0
- package/dist/feature/swarm-config/services/validate-runtimes.js +212 -0
- package/dist/feature/swarm-config/services/validate-runtimes.js.map +1 -0
- package/dist/feature/swarm-config/services/validate-settings.js +177 -0
- package/dist/feature/swarm-config/services/validate-settings.js.map +1 -0
- package/dist/feature/swarm-config/services/validate-specialists.js +152 -0
- package/dist/feature/swarm-config/services/validate-specialists.js.map +1 -0
- package/dist/feature/swarm-config/services/validate.js +174 -0
- package/dist/feature/swarm-config/services/validate.js.map +1 -0
- package/dist/feature/swarm-config/types/action.js +11 -0
- package/dist/feature/swarm-config/types/action.js.map +1 -0
- package/dist/feature/swarm-config/types/chain.js +2 -0
- package/dist/feature/swarm-config/types/chain.js.map +1 -0
- package/dist/feature/swarm-config/types/duration.js +17 -0
- package/dist/feature/swarm-config/types/duration.js.map +1 -0
- package/dist/feature/swarm-config/types/errors.js +57 -0
- package/dist/feature/swarm-config/types/errors.js.map +1 -0
- package/dist/feature/swarm-config/types/index.js +13 -0
- package/dist/feature/swarm-config/types/index.js.map +1 -0
- package/dist/feature/swarm-config/types/levels.js +16 -0
- package/dist/feature/swarm-config/types/levels.js.map +1 -0
- package/dist/feature/swarm-config/types/lookups.js +53 -0
- package/dist/feature/swarm-config/types/lookups.js.map +1 -0
- package/dist/feature/swarm-config/types/merge.js +46 -0
- package/dist/feature/swarm-config/types/merge.js.map +1 -0
- package/dist/feature/swarm-config/types/pipeline.js +5 -0
- package/dist/feature/swarm-config/types/pipeline.js.map +1 -0
- package/dist/feature/swarm-config/types/prompt.js +33 -0
- package/dist/feature/swarm-config/types/prompt.js.map +1 -0
- package/dist/feature/swarm-config/types/settings.js +116 -0
- package/dist/feature/swarm-config/types/settings.js.map +1 -0
- package/dist/feature/swarm-config/types/specialist.js +38 -0
- package/dist/feature/swarm-config/types/specialist.js.map +1 -0
- package/dist/feature/swarm-config/types/tag-names.js +43 -0
- package/dist/feature/swarm-config/types/tag-names.js.map +1 -0
- package/dist/feature/swarm-edit/ports/config-changed.js +2 -0
- package/dist/feature/swarm-edit/ports/config-changed.js.map +1 -0
- package/dist/feature/swarm-edit/ports/index.js +2 -0
- package/dist/feature/swarm-edit/ports/index.js.map +1 -0
- package/dist/feature/swarm-edit/repositories/documents.js +144 -0
- package/dist/feature/swarm-edit/repositories/documents.js.map +1 -0
- package/dist/feature/swarm-edit/services/config-edits.js +116 -0
- package/dist/feature/swarm-edit/services/config-edits.js.map +1 -0
- package/dist/feature/swarm-edit/services/create.js +7 -0
- package/dist/feature/swarm-edit/services/create.js.map +1 -0
- package/dist/feature/swarm-edit/services/editor-settings.js +143 -0
- package/dist/feature/swarm-edit/services/editor-settings.js.map +1 -0
- package/dist/feature/swarm-edit/services/editor-view.js +144 -0
- package/dist/feature/swarm-edit/services/editor-view.js.map +1 -0
- package/dist/feature/swarm-edit/services/index.js +12 -0
- package/dist/feature/swarm-edit/services/index.js.map +1 -0
- package/dist/feature/swarm-edit/services/levels.js +30 -0
- package/dist/feature/swarm-edit/services/levels.js.map +1 -0
- package/dist/feature/swarm-edit/services/plan-edit.js +217 -0
- package/dist/feature/swarm-edit/services/plan-edit.js.map +1 -0
- package/dist/feature/swarm-edit/services/plan-settings.js +198 -0
- package/dist/feature/swarm-edit/services/plan-settings.js.map +1 -0
- package/dist/feature/swarm-edit/services/references.js +85 -0
- package/dist/feature/swarm-edit/services/references.js.map +1 -0
- package/dist/feature/swarm-edit/services/shared-config.js +128 -0
- package/dist/feature/swarm-edit/services/shared-config.js.map +1 -0
- package/dist/feature/swarm-edit/services/shared-pipelines.js +72 -0
- package/dist/feature/swarm-edit/services/shared-pipelines.js.map +1 -0
- package/dist/feature/swarm-edit/services/shared-specialists.js +70 -0
- package/dist/feature/swarm-edit/services/shared-specialists.js.map +1 -0
- package/dist/feature/swarm-edit/services/specialist-tags.js +215 -0
- package/dist/feature/swarm-edit/services/specialist-tags.js.map +1 -0
- package/dist/feature/swarm-edit/types/editor.js +27 -0
- package/dist/feature/swarm-edit/types/editor.js.map +1 -0
- package/dist/feature/swarm-edit/types/index.js +7 -0
- package/dist/feature/swarm-edit/types/index.js.map +1 -0
- package/dist/feature/swarm-edit/types/setting-fields.js +64 -0
- package/dist/feature/swarm-edit/types/setting-fields.js.map +1 -0
- package/dist/feature/swarm-edit/types/shared.js +2 -0
- package/dist/feature/swarm-edit/types/shared.js.map +1 -0
- package/dist/feature/swarm-edit/types/stages.js +69 -0
- package/dist/feature/swarm-edit/types/stages.js.map +1 -0
- package/dist/feature/swarm-edit/types/tag-folders.js +2 -0
- package/dist/feature/swarm-edit/types/tag-folders.js.map +1 -0
- package/dist/feature/swarm-edit/types/views.js +2 -0
- package/dist/feature/swarm-edit/types/views.js.map +1 -0
- package/dist/feature/tags/ports/index.js +2 -0
- package/dist/feature/tags/ports/index.js.map +1 -0
- package/dist/feature/tags/ports/publish.js +2 -0
- package/dist/feature/tags/ports/publish.js.map +1 -0
- package/dist/feature/tags/repositories/index.js +2 -0
- package/dist/feature/tags/repositories/index.js.map +1 -0
- package/dist/feature/tags/repositories/tags.js +36 -0
- package/dist/feature/tags/repositories/tags.js.map +1 -0
- package/dist/feature/tags/services/catalog.js +73 -0
- package/dist/feature/tags/services/catalog.js.map +1 -0
- package/dist/feature/tags/services/create.js +7 -0
- package/dist/feature/tags/services/create.js.map +1 -0
- package/dist/feature/tags/services/index.js +3 -0
- package/dist/feature/tags/services/index.js.map +1 -0
- package/dist/feature/tags/types/ids.js +7 -0
- package/dist/feature/tags/types/ids.js.map +1 -0
- package/dist/feature/tags/types/index.js +3 -0
- package/dist/feature/tags/types/index.js.map +1 -0
- package/dist/feature/tags/types/tags.js +184 -0
- package/dist/feature/tags/types/tags.js.map +1 -0
- package/dist/git/delivery.js +284 -0
- package/dist/git/delivery.js.map +1 -0
- package/dist/git/index.js +4 -0
- package/dist/git/index.js.map +1 -0
- package/dist/git/runner.js +60 -0
- package/dist/git/runner.js.map +1 -0
- package/dist/git/workspace.js +366 -0
- package/dist/git/workspace.js.map +1 -0
- package/dist/mcp/host.js +401 -0
- package/dist/mcp/host.js.map +1 -0
- package/dist/mcp/index.js +3 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/tools.js +19 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/mcp/version.js +5 -0
- package/dist/mcp/version.js.map +1 -0
- package/dist/mcp/worker.js +230 -0
- package/dist/mcp/worker.js.map +1 -0
- package/dist/platform/build/fingerprint.js +36 -0
- package/dist/platform/build/fingerprint.js.map +1 -0
- package/dist/platform/build/index.js +3 -0
- package/dist/platform/build/index.js.map +1 -0
- package/dist/platform/build/locations.js +16 -0
- package/dist/platform/build/locations.js.map +1 -0
- package/dist/platform/errors/app-error.js +39 -0
- package/dist/platform/errors/app-error.js.map +1 -0
- package/dist/platform/errors/index.js +2 -0
- package/dist/platform/errors/index.js.map +1 -0
- package/dist/platform/git/delivery.js +284 -0
- package/dist/platform/git/delivery.js.map +1 -0
- package/dist/platform/git/index.js +4 -0
- package/dist/platform/git/index.js.map +1 -0
- package/dist/platform/git/runner.js +65 -0
- package/dist/platform/git/runner.js.map +1 -0
- package/dist/platform/git/workspace.js +366 -0
- package/dist/platform/git/workspace.js.map +1 -0
- package/dist/platform/paths/index.js +2 -0
- package/dist/platform/paths/index.js.map +1 -0
- package/dist/platform/paths/paths.js +39 -0
- package/dist/platform/paths/paths.js.map +1 -0
- package/dist/platform/process/index.js +3 -0
- package/dist/platform/process/index.js.map +1 -0
- package/dist/platform/process/ps.js +42 -0
- package/dist/platform/process/ps.js.map +1 -0
- package/dist/platform/process/which.js +21 -0
- package/dist/platform/process/which.js.map +1 -0
- package/dist/platform/sqlite/database.js +36 -0
- package/dist/platform/sqlite/database.js.map +1 -0
- package/dist/platform/sqlite/index.js +4 -0
- package/dist/platform/sqlite/index.js.map +1 -0
- package/dist/platform/sqlite/migrations.js +297 -0
- package/dist/platform/sqlite/migrations.js.map +1 -0
- package/dist/platform/sqlite/rows.js +13 -0
- package/dist/platform/sqlite/rows.js.map +1 -0
- package/dist/presentation/cli/commands/daemon.js +216 -0
- package/dist/presentation/cli/commands/daemon.js.map +1 -0
- package/dist/presentation/cli/commands/group.js +88 -0
- package/dist/presentation/cli/commands/group.js.map +1 -0
- package/dist/presentation/cli/commands/mcp.js +44 -0
- package/dist/presentation/cli/commands/mcp.js.map +1 -0
- package/dist/presentation/cli/commands/queue-edit.js +155 -0
- package/dist/presentation/cli/commands/queue-edit.js.map +1 -0
- package/dist/presentation/cli/commands/queue.js +222 -0
- package/dist/presentation/cli/commands/queue.js.map +1 -0
- package/dist/presentation/cli/commands/repositories.js +129 -0
- package/dist/presentation/cli/commands/repositories.js.map +1 -0
- package/dist/presentation/cli/commands/run-delivery.js +116 -0
- package/dist/presentation/cli/commands/run-delivery.js.map +1 -0
- package/dist/presentation/cli/commands/run.js +156 -0
- package/dist/presentation/cli/commands/run.js.map +1 -0
- package/dist/presentation/cli/commands/setup.js +97 -0
- package/dist/presentation/cli/commands/setup.js.map +1 -0
- package/dist/presentation/cli/commands/tag.js +92 -0
- package/dist/presentation/cli/commands/tag.js.map +1 -0
- package/dist/presentation/cli/commands/web.js +100 -0
- package/dist/presentation/cli/commands/web.js.map +1 -0
- package/dist/presentation/cli/context.js +49 -0
- package/dist/presentation/cli/context.js.map +1 -0
- package/dist/presentation/cli/help.js +49 -0
- package/dist/presentation/cli/help.js.map +1 -0
- package/dist/presentation/cli/io.js +13 -0
- package/dist/presentation/cli/io.js.map +1 -0
- package/dist/presentation/cli/local/clean.js +72 -0
- package/dist/presentation/cli/local/clean.js.map +1 -0
- package/dist/presentation/cli/local/config-check.js +207 -0
- package/dist/presentation/cli/local/config-check.js.map +1 -0
- package/dist/presentation/cli/local/init.js +44 -0
- package/dist/presentation/cli/local/init.js.map +1 -0
- package/dist/presentation/cli/options.js +34 -0
- package/dist/presentation/cli/options.js.map +1 -0
- package/dist/presentation/cli/probe.js +12 -0
- package/dist/presentation/cli/probe.js.map +1 -0
- package/dist/presentation/cli/program.js +76 -0
- package/dist/presentation/cli/program.js.map +1 -0
- package/dist/presentation/cli/setup/actions.js +206 -0
- package/dist/presentation/cli/setup/actions.js.map +1 -0
- package/dist/presentation/cli/setup/command.js +80 -0
- package/dist/presentation/cli/setup/command.js.map +1 -0
- package/dist/presentation/cli/setup/host.js +20 -0
- package/dist/presentation/cli/setup/host.js.map +1 -0
- package/dist/presentation/cli/setup/index.js +5 -0
- package/dist/presentation/cli/setup/index.js.map +1 -0
- package/dist/presentation/cli/setup/run.js +63 -0
- package/dist/presentation/cli/setup/run.js.map +1 -0
- package/dist/presentation/cli/setup/system.js +53 -0
- package/dist/presentation/cli/setup/system.js.map +1 -0
- package/dist/presentation/cli/setup/types.js +3 -0
- package/dist/presentation/cli/setup/types.js.map +1 -0
- package/dist/presentation/cli/watch.js +24 -0
- package/dist/presentation/cli/watch.js.map +1 -0
- package/dist/presentation/cli/web-control.js +172 -0
- package/dist/presentation/cli/web-control.js.map +1 -0
- package/dist/presentation/format/groups.js +99 -0
- package/dist/presentation/format/groups.js.map +1 -0
- package/dist/presentation/format/index.js +7 -0
- package/dist/presentation/format/index.js.map +1 -0
- package/dist/presentation/format/queue.js +109 -0
- package/dist/presentation/format/queue.js.map +1 -0
- package/dist/presentation/format/runs.js +202 -0
- package/dist/presentation/format/runs.js.map +1 -0
- package/dist/presentation/format/style.js +81 -0
- package/dist/presentation/format/style.js.map +1 -0
- package/dist/presentation/format/table.js +62 -0
- package/dist/presentation/format/table.js.map +1 -0
- package/dist/presentation/format/tags.js +26 -0
- package/dist/presentation/format/tags.js.map +1 -0
- package/dist/presentation/ipc/client/autostart.js +171 -0
- package/dist/presentation/ipc/client/autostart.js.map +1 -0
- package/dist/presentation/ipc/client/client.js +83 -0
- package/dist/presentation/ipc/client/client.js.map +1 -0
- package/dist/presentation/ipc/client/index.js +4 -0
- package/dist/presentation/ipc/client/index.js.map +1 -0
- package/dist/presentation/ipc/client/repository-argument.js +13 -0
- package/dist/presentation/ipc/client/repository-argument.js.map +1 -0
- package/dist/presentation/ipc/contract/agents.js +79 -0
- package/dist/presentation/ipc/contract/agents.js.map +1 -0
- package/dist/presentation/ipc/contract/artifacts.js +27 -0
- package/dist/presentation/ipc/contract/artifacts.js.map +1 -0
- package/dist/presentation/ipc/contract/config.js +141 -0
- package/dist/presentation/ipc/contract/config.js.map +1 -0
- package/dist/presentation/ipc/contract/envelope.js +97 -0
- package/dist/presentation/ipc/contract/envelope.js.map +1 -0
- package/dist/presentation/ipc/contract/groups.js +48 -0
- package/dist/presentation/ipc/contract/groups.js.map +1 -0
- package/dist/presentation/ipc/contract/index.js +14 -0
- package/dist/presentation/ipc/contract/index.js.map +1 -0
- package/dist/presentation/ipc/contract/observers/history.js +26 -0
- package/dist/presentation/ipc/contract/observers/history.js.map +1 -0
- package/dist/presentation/ipc/contract/observers.js +16 -0
- package/dist/presentation/ipc/contract/observers.js.map +1 -0
- package/dist/presentation/ipc/contract/panel.js +53 -0
- package/dist/presentation/ipc/contract/panel.js.map +1 -0
- package/dist/presentation/ipc/contract/processes.js +9 -0
- package/dist/presentation/ipc/contract/processes.js.map +1 -0
- package/dist/presentation/ipc/contract/queue.js +115 -0
- package/dist/presentation/ipc/contract/queue.js.map +1 -0
- package/dist/presentation/ipc/contract/repositories.js +33 -0
- package/dist/presentation/ipc/contract/repositories.js.map +1 -0
- package/dist/presentation/ipc/contract/responses/artifacts.js +2 -0
- package/dist/presentation/ipc/contract/responses/artifacts.js.map +1 -0
- package/dist/presentation/ipc/contract/responses/config.js +2 -0
- package/dist/presentation/ipc/contract/responses/config.js.map +1 -0
- package/dist/presentation/ipc/contract/responses/groups.js +2 -0
- package/dist/presentation/ipc/contract/responses/groups.js.map +1 -0
- package/dist/presentation/ipc/contract/responses/index.js +11 -0
- package/dist/presentation/ipc/contract/responses/index.js.map +1 -0
- package/dist/presentation/ipc/contract/responses/observer-history.js +2 -0
- package/dist/presentation/ipc/contract/responses/observer-history.js.map +1 -0
- package/dist/presentation/ipc/contract/responses/observers.js +2 -0
- package/dist/presentation/ipc/contract/responses/observers.js.map +1 -0
- package/dist/presentation/ipc/contract/responses/processes.js +2 -0
- package/dist/presentation/ipc/contract/responses/processes.js.map +1 -0
- package/dist/presentation/ipc/contract/responses/queue.js +2 -0
- package/dist/presentation/ipc/contract/responses/queue.js.map +1 -0
- package/dist/presentation/ipc/contract/responses/repositories.js +2 -0
- package/dist/presentation/ipc/contract/responses/repositories.js.map +1 -0
- package/dist/presentation/ipc/contract/responses/runs.js +2 -0
- package/dist/presentation/ipc/contract/responses/runs.js.map +1 -0
- package/dist/presentation/ipc/contract/responses/tags.js +2 -0
- package/dist/presentation/ipc/contract/responses/tags.js.map +1 -0
- package/dist/presentation/ipc/contract/runs.js +112 -0
- package/dist/presentation/ipc/contract/runs.js.map +1 -0
- package/dist/presentation/ipc/contract/tags.js +40 -0
- package/dist/presentation/ipc/contract/tags.js.map +1 -0
- package/dist/presentation/ipc/handlers/config.js +38 -0
- package/dist/presentation/ipc/handlers/config.js.map +1 -0
- package/dist/presentation/ipc/handlers/groups.js +14 -0
- package/dist/presentation/ipc/handlers/groups.js.map +1 -0
- package/dist/presentation/ipc/handlers/index.js +2 -0
- package/dist/presentation/ipc/handlers/index.js.map +1 -0
- package/dist/presentation/ipc/handlers/observers.js +14 -0
- package/dist/presentation/ipc/handlers/observers.js.map +1 -0
- package/dist/presentation/ipc/handlers/queue.js +36 -0
- package/dist/presentation/ipc/handlers/queue.js.map +1 -0
- package/dist/presentation/ipc/handlers/repositories.js +26 -0
- package/dist/presentation/ipc/handlers/repositories.js.map +1 -0
- package/dist/presentation/ipc/handlers/runs.js +55 -0
- package/dist/presentation/ipc/handlers/runs.js.map +1 -0
- package/dist/presentation/ipc/handlers/system.js +38 -0
- package/dist/presentation/ipc/handlers/system.js.map +1 -0
- package/dist/presentation/ipc/handlers/table.js +23 -0
- package/dist/presentation/ipc/handlers/table.js.map +1 -0
- package/dist/presentation/ipc/handlers/types.js +2 -0
- package/dist/presentation/ipc/handlers/types.js.map +1 -0
- package/dist/presentation/ipc/publisher.js +175 -0
- package/dist/presentation/ipc/publisher.js.map +1 -0
- package/dist/presentation/ipc/server.js +164 -0
- package/dist/presentation/ipc/server.js.map +1 -0
- package/dist/presentation/ipc/services.js +2 -0
- package/dist/presentation/ipc/services.js.map +1 -0
- package/dist/presentation/ipc/snapshots.js +60 -0
- package/dist/presentation/ipc/snapshots.js.map +1 -0
- package/dist/presentation/ipc/views/catalog.js +9 -0
- package/dist/presentation/ipc/views/catalog.js.map +1 -0
- package/dist/presentation/ipc/views/groups.js +112 -0
- package/dist/presentation/ipc/views/groups.js.map +1 -0
- package/dist/presentation/ipc/views/index.js +10 -0
- package/dist/presentation/ipc/views/index.js.map +1 -0
- package/dist/presentation/ipc/views/observer-history.js +26 -0
- package/dist/presentation/ipc/views/observer-history.js.map +1 -0
- package/dist/presentation/ipc/views/observers.js +16 -0
- package/dist/presentation/ipc/views/observers.js.map +1 -0
- package/dist/presentation/ipc/views/queue.js +151 -0
- package/dist/presentation/ipc/views/queue.js.map +1 -0
- package/dist/presentation/ipc/views/repositories.js +34 -0
- package/dist/presentation/ipc/views/repositories.js.map +1 -0
- package/dist/presentation/ipc/views/rows.js +117 -0
- package/dist/presentation/ipc/views/rows.js.map +1 -0
- package/dist/presentation/ipc/views/run-stages.js +66 -0
- package/dist/presentation/ipc/views/run-stages.js.map +1 -0
- package/dist/presentation/ipc/views/runs.js +201 -0
- package/dist/presentation/ipc/views/runs.js.map +1 -0
- package/dist/presentation/ipc/views/tags.js +19 -0
- package/dist/presentation/ipc/views/tags.js.map +1 -0
- package/dist/presentation/mcp/host-kit.js +67 -0
- package/dist/presentation/mcp/host-kit.js.map +1 -0
- package/dist/presentation/mcp/host-queue-control.js +135 -0
- package/dist/presentation/mcp/host-queue-control.js.map +1 -0
- package/dist/presentation/mcp/host-queue.js +124 -0
- package/dist/presentation/mcp/host-queue.js.map +1 -0
- package/dist/presentation/mcp/host-runs.js +173 -0
- package/dist/presentation/mcp/host-runs.js.map +1 -0
- package/dist/presentation/mcp/host.js +34 -0
- package/dist/presentation/mcp/host.js.map +1 -0
- package/dist/presentation/mcp/index.js +3 -0
- package/dist/presentation/mcp/index.js.map +1 -0
- package/dist/presentation/mcp/tools.js +19 -0
- package/dist/presentation/mcp/tools.js.map +1 -0
- package/dist/presentation/mcp/worker-extra.js +144 -0
- package/dist/presentation/mcp/worker-extra.js.map +1 -0
- package/dist/presentation/mcp/worker-tools.js +107 -0
- package/dist/presentation/mcp/worker-tools.js.map +1 -0
- package/dist/presentation/mcp/worker.js +12 -0
- package/dist/presentation/mcp/worker.js.map +1 -0
- package/dist/presentation/web/errors.js +60 -0
- package/dist/presentation/web/errors.js.map +1 -0
- package/dist/presentation/web/http.js +130 -0
- package/dist/presentation/web/http.js.map +1 -0
- package/dist/presentation/web/hub.js +164 -0
- package/dist/presentation/web/hub.js.map +1 -0
- package/dist/presentation/web/index.js +7 -0
- package/dist/presentation/web/index.js.map +1 -0
- package/dist/presentation/web/options.js +7 -0
- package/dist/presentation/web/options.js.map +1 -0
- package/dist/presentation/web/pages.js +44 -0
- package/dist/presentation/web/pages.js.map +1 -0
- package/dist/presentation/web/panel/daemon-panel.js +207 -0
- package/dist/presentation/web/panel/daemon-panel.js.map +1 -0
- package/dist/presentation/web/panel/default-repository.js +14 -0
- package/dist/presentation/web/panel/default-repository.js.map +1 -0
- package/dist/presentation/web/panel/directories.js +48 -0
- package/dist/presentation/web/panel/directories.js.map +1 -0
- package/dist/presentation/web/panel/open.js +12 -0
- package/dist/presentation/web/panel/open.js.map +1 -0
- package/dist/presentation/web/panel/standby.js +119 -0
- package/dist/presentation/web/panel/standby.js.map +1 -0
- package/dist/presentation/web/panel/state.js +69 -0
- package/dist/presentation/web/panel/state.js.map +1 -0
- package/dist/presentation/web/panel/system.js +66 -0
- package/dist/presentation/web/panel/system.js.map +1 -0
- package/dist/presentation/web/request.js +123 -0
- package/dist/presentation/web/request.js.map +1 -0
- package/dist/presentation/web/routes/config.js +166 -0
- package/dist/presentation/web/routes/config.js.map +1 -0
- package/dist/presentation/web/routes/directories.js +60 -0
- package/dist/presentation/web/routes/directories.js.map +1 -0
- package/dist/presentation/web/routes/downloads.js +65 -0
- package/dist/presentation/web/routes/downloads.js.map +1 -0
- package/dist/presentation/web/routes/groups.js +85 -0
- package/dist/presentation/web/routes/groups.js.map +1 -0
- package/dist/presentation/web/routes/observers/history.js +19 -0
- package/dist/presentation/web/routes/observers/history.js.map +1 -0
- package/dist/presentation/web/routes/processes.js +21 -0
- package/dist/presentation/web/routes/processes.js.map +1 -0
- package/dist/presentation/web/routes/queue.js +80 -0
- package/dist/presentation/web/routes/queue.js.map +1 -0
- package/dist/presentation/web/routes/repositories.js +66 -0
- package/dist/presentation/web/routes/repositories.js.map +1 -0
- package/dist/presentation/web/routes/runs.js +76 -0
- package/dist/presentation/web/routes/runs.js.map +1 -0
- package/dist/presentation/web/routes/settings.js +74 -0
- package/dist/presentation/web/routes/settings.js.map +1 -0
- package/dist/presentation/web/routes/specialists.js +74 -0
- package/dist/presentation/web/routes/specialists.js.map +1 -0
- package/dist/presentation/web/routes/system.js +96 -0
- package/dist/presentation/web/routes/system.js.map +1 -0
- package/dist/presentation/web/routes/tags.js +46 -0
- package/dist/presentation/web/routes/tags.js.map +1 -0
- package/dist/presentation/web/routes/types.js +2 -0
- package/dist/presentation/web/routes/types.js.map +1 -0
- package/dist/presentation/web/server.js +185 -0
- package/dist/presentation/web/server.js.map +1 -0
- package/dist/protocol/autostart.js +171 -0
- package/dist/protocol/autostart.js.map +1 -0
- package/dist/protocol/build.js +38 -0
- package/dist/protocol/build.js.map +1 -0
- package/dist/protocol/catalog.js +18 -0
- package/dist/protocol/catalog.js.map +1 -0
- package/dist/protocol/client.js +83 -0
- package/dist/protocol/client.js.map +1 -0
- package/dist/protocol/format.js +477 -0
- package/dist/protocol/format.js.map +1 -0
- package/dist/protocol/index.js +11 -0
- package/dist/protocol/index.js.map +1 -0
- package/dist/protocol/messages.js +598 -0
- package/dist/protocol/messages.js.map +1 -0
- package/dist/protocol/style.js +81 -0
- package/dist/protocol/style.js.map +1 -0
- package/dist/protocol/transcript.js +49 -0
- package/dist/protocol/transcript.js.map +1 -0
- package/dist/protocol/views.js +696 -0
- package/dist/protocol/views.js.map +1 -0
- package/dist/runtime/catalog.js +117 -0
- package/dist/runtime/catalog.js.map +1 -0
- package/dist/runtime/claude.js +399 -0
- package/dist/runtime/claude.js.map +1 -0
- package/dist/runtime/index.js +34 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/message.js +48 -0
- package/dist/runtime/message.js.map +1 -0
- package/dist/runtime/naming.js +69 -0
- package/dist/runtime/naming.js.map +1 -0
- package/dist/runtime/opencode.js +189 -0
- package/dist/runtime/opencode.js.map +1 -0
- package/dist/runtime/skills.js +17 -0
- package/dist/runtime/skills.js.map +1 -0
- package/dist/runtime/transcript.js +227 -0
- package/dist/runtime/transcript.js.map +1 -0
- package/dist/runtime/types.js +12 -0
- package/dist/runtime/types.js.map +1 -0
- package/dist/runtime/which.js +21 -0
- package/dist/runtime/which.js.map +1 -0
- package/dist/store/index.js +3 -0
- package/dist/store/index.js.map +1 -0
- package/dist/store/schema.js +286 -0
- package/dist/store/schema.js.map +1 -0
- package/dist/store/store.js +491 -0
- package/dist/store/store.js.map +1 -0
- package/dist/web/assets/EntryList-CnfGgjEY.js +1 -0
- package/dist/web/assets/FilePath-C0X8-keS.js +1 -0
- package/dist/web/assets/SettingsForm-BcyBWJbn.js +1 -0
- package/dist/web/assets/SharedPipelinesGroup-a368-IQ0.js +1 -0
- package/dist/web/assets/card-DkikoTxR.js +1 -0
- package/dist/web/assets/deliveryModes-funlvXVC.js +1 -0
- package/dist/web/assets/index-B-oJ93zH.js +22 -0
- package/dist/web/assets/index-BZE36gYR.css +2 -0
- package/dist/web/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
- package/dist/web/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
- package/dist/web/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
- package/dist/web/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
- package/dist/web/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
- package/dist/web/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
- package/dist/web/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
- package/dist/web/assets/locales-DtRrxYzg.js +1 -0
- package/dist/web/assets/pipelines-D48ggDNe.js +1 -0
- package/dist/web/assets/queue-D8_RY4IY.js +16 -0
- package/dist/web/assets/rolldown-runtime-XKyaHtl9.js +1 -0
- package/dist/web/assets/select-J4oIrmYh.js +1 -0
- package/dist/web/assets/settings-B0-0Vaia.js +2 -0
- package/dist/web/assets/skeleton-CCKCQF5n.js +1 -0
- package/dist/web/assets/specialists-DH8tyluO.js +1 -0
- package/dist/web/assets/switch-CWFAgxG1.js +41 -0
- package/dist/web/assets/topology-CNQ28AB2.js +7 -0
- package/dist/web/assets/topology-DLioOiRN.css +1 -0
- package/dist/web/assets/vendor-markdown-DwXfjc7L.js +32 -0
- package/dist/web/assets/vendor-react-C1iE8mnY.js +9 -0
- package/dist/web/index.html +21 -0
- package/integrations/claude-code/.claude-plugin/plugin.json +19 -0
- package/integrations/claude-code/commands/apply.md +6 -0
- package/integrations/claude-code/commands/panel.md +6 -0
- package/integrations/claude-code/commands/run.md +6 -0
- package/integrations/claude-code/commands/status.md +6 -0
- package/integrations/claude-code/commands/web.md +6 -0
- package/integrations/claude-code/hooks/aip.ts +365 -0
- package/integrations/claude-code/hooks/feed.ts +923 -0
- package/integrations/claude-code/hooks/hooks.json +1 -0
- package/integrations/claude-code/hooks/pane.ts +396 -0
- package/integrations/claude-code/hooks/register.tsx +156 -0
- package/integrations/claude-code/hooks/theme.ts +59 -0
- package/integrations/claude-code/hooks/transcript.tsx +44 -0
- package/integrations/claude-code/hooks/view.tsx +378 -0
- package/integrations/claude-code/hooks/web.ts +162 -0
- package/integrations/claude-code/tsconfig.json +18 -0
- package/integrations/claude-code/types/index.d.ts +89 -0
- package/package.json +70 -4
- package/templates/aip/pipelines/feature.yaml +4 -0
- package/templates/aip/settings.yaml +10 -0
- package/templates/aip/specialists/coder.yaml +4 -0
- package/templates/aip/specialists/reviewer.yaml +5 -0
|
@@ -0,0 +1,1191 @@
|
|
|
1
|
+
import { randomBytes, timingSafeEqual } from 'node:crypto';
|
|
2
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
3
|
+
import { createServer } from 'node:http';
|
|
4
|
+
import { extname, isAbsolute, join, normalize, sep } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { settingFieldOf } from '../../feature/swarm-edit/types/index.js';
|
|
8
|
+
import { SLUG_PATTERN_TEXT, isValidSlug } from '../../feature/swarm-config/types/index.js';
|
|
9
|
+
import { checkDaemon, currentBuild, MESSAGE_TEXT_LIMIT, pingDaemon, request, settingValueSchema, streamEventSchema, subscribe, } from '../../protocol/index.js';
|
|
10
|
+
import { artifactPreview } from '../../feature/artifacts/types/index.js';
|
|
11
|
+
import { RUN_TITLE_LIMIT } from '../../feature/agents/types/index.js';
|
|
12
|
+
import { TOKEN_HINT, configError, panel, renderPanelError } from './errors.js';
|
|
13
|
+
import { systemView } from './system.js';
|
|
14
|
+
/** How often a daemon older than the panel is checked again, so it is replaced once idle. */
|
|
15
|
+
export const RECHECK_MS = 30_000;
|
|
16
|
+
/** dist/web of the package, both from the sources (src/cli/web) and the build (dist/cli/web). */
|
|
17
|
+
export const DEFAULT_ASSETS = fileURLToPath(new URL('../../../dist/web/', import.meta.url));
|
|
18
|
+
const TYPES = {
|
|
19
|
+
'.js': 'text/javascript',
|
|
20
|
+
'.css': 'text/css',
|
|
21
|
+
'.svg': 'image/svg+xml',
|
|
22
|
+
'.png': 'image/png',
|
|
23
|
+
'.ico': 'image/x-icon',
|
|
24
|
+
'.woff2': 'font/woff2',
|
|
25
|
+
'.map': 'application/json',
|
|
26
|
+
};
|
|
27
|
+
const PAGE_POLICY = "default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; connect-src 'self'; img-src 'self' data:; font-src 'self'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'";
|
|
28
|
+
const MISSING_BUILD = `<!doctype html><html lang="en"><head><meta charset="utf-8"><title>aip</title></head><body><h1>aip web</h1><p>The panel is not built. Run <code>npm run build</code> in the aip repository and reload this page.</p></body></html>`;
|
|
29
|
+
const COOKIE = 'aip_token';
|
|
30
|
+
const BODY_LIMIT = 64 * 1024;
|
|
31
|
+
const skipBody = z.object({ step: z.string().trim().min(1), skip: z.boolean() });
|
|
32
|
+
const answerBody = z.object({ answer: z.string().trim().min(1) });
|
|
33
|
+
const messageBody = z.object({
|
|
34
|
+
seq: z.number().int().positive(),
|
|
35
|
+
text: z.string().trim().min(1).max(MESSAGE_TEXT_LIMIT),
|
|
36
|
+
});
|
|
37
|
+
const retryBody = z.object({ refreshConfig: z.boolean().optional() });
|
|
38
|
+
const applyBody = z.object({
|
|
39
|
+
groups: z.array(z.string().min(1)).optional(),
|
|
40
|
+
force: z.boolean().optional(),
|
|
41
|
+
});
|
|
42
|
+
const markDeliveredBody = z.object({ groups: z.array(z.string().min(1)).optional() });
|
|
43
|
+
const tagName = z.string().trim().min(1);
|
|
44
|
+
const tagAddBody = z.object({ name: tagName, color: z.string().optional() });
|
|
45
|
+
const tagEditBody = z
|
|
46
|
+
.object({ tag: tagName, name: tagName.optional(), color: z.string().optional() })
|
|
47
|
+
.refine((body) => body.name !== undefined || body.color !== undefined, {
|
|
48
|
+
message: 'pass a new name or a new color',
|
|
49
|
+
});
|
|
50
|
+
const tagRemoveBody = z.object({ tag: tagName });
|
|
51
|
+
const runTagsBody = z
|
|
52
|
+
.object({ add: z.array(tagName).max(20).optional(), remove: z.array(tagName).max(20).optional() })
|
|
53
|
+
.refine((body) => (body.add?.length ?? 0) + (body.remove?.length ?? 0) > 0, {
|
|
54
|
+
message: 'pass tags to add or remove',
|
|
55
|
+
});
|
|
56
|
+
const runTitleBody = z.object({ title: z.string().trim().min(1).max(RUN_TITLE_LIMIT) });
|
|
57
|
+
const levelParam = z.enum(['project', 'global']);
|
|
58
|
+
const previewBody = z.object({
|
|
59
|
+
value: z.record(z.string(), z.unknown()),
|
|
60
|
+
level: levelParam.optional(),
|
|
61
|
+
});
|
|
62
|
+
const writeBody = z.object({
|
|
63
|
+
value: z.record(z.string(), z.unknown()),
|
|
64
|
+
revision: z.string().min(1).nullable(),
|
|
65
|
+
level: levelParam.optional(),
|
|
66
|
+
});
|
|
67
|
+
/** Repository of the project level; null is the shared level. */
|
|
68
|
+
const levelRepository = z
|
|
69
|
+
.string()
|
|
70
|
+
.nullable()
|
|
71
|
+
.refine((value) => value === null || isAbsolute(value), {
|
|
72
|
+
message: 'repository must be an absolute path',
|
|
73
|
+
});
|
|
74
|
+
const tagsSetBody = z.object({
|
|
75
|
+
repository: levelRepository,
|
|
76
|
+
tags: z.array(z.string()),
|
|
77
|
+
revision: z.string().min(1).nullable(),
|
|
78
|
+
});
|
|
79
|
+
const tagRenameBody = z.object({
|
|
80
|
+
repository: levelRepository,
|
|
81
|
+
from: z.string().min(1),
|
|
82
|
+
to: z.string().min(1),
|
|
83
|
+
});
|
|
84
|
+
const specialistTagRemoveBody = z.object({ repository: levelRepository, tag: z.string().min(1) });
|
|
85
|
+
const importBody = z.object({
|
|
86
|
+
source: z.string().refine((value) => isAbsolute(value), {
|
|
87
|
+
message: 'source must be an absolute path',
|
|
88
|
+
}),
|
|
89
|
+
slugs: z.array(z.string().min(1)).min(1),
|
|
90
|
+
});
|
|
91
|
+
const pipelineImportBody = z.object({
|
|
92
|
+
source: z.string().refine((value) => isAbsolute(value), {
|
|
93
|
+
message: 'source must be an absolute path',
|
|
94
|
+
}),
|
|
95
|
+
ids: z.array(z.string().min(1)).min(1),
|
|
96
|
+
});
|
|
97
|
+
const forceBody = z.object({ force: z.boolean().optional() });
|
|
98
|
+
const SYSTEM_ACTIONS = {
|
|
99
|
+
'/api/system/web/restart': 'web_restart',
|
|
100
|
+
'/api/system/daemon/restart': 'daemon_restart',
|
|
101
|
+
'/api/system/daemon/stop': 'daemon_stop',
|
|
102
|
+
'/api/system/daemon/start': 'daemon_start',
|
|
103
|
+
};
|
|
104
|
+
const settingBody = z.object({
|
|
105
|
+
value: settingValueSchema,
|
|
106
|
+
revision: z.string().min(1).nullable(),
|
|
107
|
+
level: levelParam.optional(),
|
|
108
|
+
});
|
|
109
|
+
const settingsBody = z.object({
|
|
110
|
+
values: z.record(z.string(), settingValueSchema),
|
|
111
|
+
revision: z.string().min(1).nullable(),
|
|
112
|
+
level: levelParam.optional(),
|
|
113
|
+
});
|
|
114
|
+
/** A handler result with its own status code. */
|
|
115
|
+
class Reply {
|
|
116
|
+
status;
|
|
117
|
+
value;
|
|
118
|
+
constructor(status, value) {
|
|
119
|
+
this.status = status;
|
|
120
|
+
this.value = value;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/** Maps the outcome of a configuration edit onto HTTP: 200, 422 for errors, 409 for a conflict. */
|
|
124
|
+
function editReply(result) {
|
|
125
|
+
if (result.ok)
|
|
126
|
+
return new Reply(200, result);
|
|
127
|
+
if (result.reason === 'conflict')
|
|
128
|
+
return new Reply(409, { error: result.message });
|
|
129
|
+
return new Reply(422, { errors: result.errors, references: result.references ?? [] });
|
|
130
|
+
}
|
|
131
|
+
/** Reply of a tag edit or an import: 200 with the outcome, 422 for errors, 409 for a conflict. */
|
|
132
|
+
function tagReply(result) {
|
|
133
|
+
if (result.ok)
|
|
134
|
+
return new Reply(200, result);
|
|
135
|
+
if (result.reason === 'conflict') {
|
|
136
|
+
return new Reply(409, { error: result.message, slugs: result.slugs ?? [] });
|
|
137
|
+
}
|
|
138
|
+
return new Reply(422, { errors: result.errors, references: [] });
|
|
139
|
+
}
|
|
140
|
+
function entryId(value) {
|
|
141
|
+
const id = value ?? '';
|
|
142
|
+
if (!isValidSlug(id))
|
|
143
|
+
throw panel('invalid', `id must match ${SLUG_PATTERN_TEXT}`);
|
|
144
|
+
return id;
|
|
145
|
+
}
|
|
146
|
+
function sameToken(given, expected) {
|
|
147
|
+
if (given === undefined)
|
|
148
|
+
return false;
|
|
149
|
+
const a = Buffer.from(given);
|
|
150
|
+
const b = Buffer.from(expected);
|
|
151
|
+
return a.length === b.length && timingSafeEqual(a, b);
|
|
152
|
+
}
|
|
153
|
+
function cookieToken(header) {
|
|
154
|
+
for (const part of (header ?? '').split(';')) {
|
|
155
|
+
const [name, ...value] = part.trim().split('=');
|
|
156
|
+
if (name === COOKIE)
|
|
157
|
+
return value.join('=');
|
|
158
|
+
}
|
|
159
|
+
return undefined;
|
|
160
|
+
}
|
|
161
|
+
function send(response, status, body, type, headers = {}) {
|
|
162
|
+
response.writeHead(status, {
|
|
163
|
+
'content-type': `${type}; charset=utf-8`,
|
|
164
|
+
'cache-control': 'no-store',
|
|
165
|
+
'x-content-type-options': 'nosniff',
|
|
166
|
+
'referrer-policy': 'no-referrer',
|
|
167
|
+
...headers,
|
|
168
|
+
});
|
|
169
|
+
response.end(body);
|
|
170
|
+
}
|
|
171
|
+
function json(response, status, value) {
|
|
172
|
+
send(response, status, JSON.stringify(value), 'application/json');
|
|
173
|
+
}
|
|
174
|
+
async function readJson(incoming) {
|
|
175
|
+
if (!(incoming.headers['content-type'] ?? '').startsWith('application/json'))
|
|
176
|
+
throw panel('unsupported', 'content-type must be application/json');
|
|
177
|
+
let size = 0;
|
|
178
|
+
const chunks = [];
|
|
179
|
+
for await (const chunk of incoming) {
|
|
180
|
+
size += chunk.length;
|
|
181
|
+
if (size > BODY_LIMIT)
|
|
182
|
+
throw panel('too_large', 'request body is too large');
|
|
183
|
+
chunks.push(chunk);
|
|
184
|
+
}
|
|
185
|
+
if (size === 0)
|
|
186
|
+
return {};
|
|
187
|
+
try {
|
|
188
|
+
return JSON.parse(Buffer.concat(chunks).toString('utf8'));
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
191
|
+
throw panel('invalid', 'invalid JSON');
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
const runObserverBody = z.object({ enabled: z.boolean() });
|
|
195
|
+
function parseBody(schema, value) {
|
|
196
|
+
const parsed = schema.safeParse(value);
|
|
197
|
+
if (!parsed.success)
|
|
198
|
+
throw panel('invalid', z.prettifyError(parsed.error));
|
|
199
|
+
return parsed.data;
|
|
200
|
+
}
|
|
201
|
+
/** Fan-out of the daemon event stream; keeps the latest state of every run. */
|
|
202
|
+
class Hub {
|
|
203
|
+
socket;
|
|
204
|
+
runs = new Map();
|
|
205
|
+
queues = new Map();
|
|
206
|
+
repositories = [];
|
|
207
|
+
tags = [];
|
|
208
|
+
/** The last `processes` event of the daemon, without `seq`; null until it sends one. */
|
|
209
|
+
processes = null;
|
|
210
|
+
seq = 0;
|
|
211
|
+
ready = false;
|
|
212
|
+
stopped = false;
|
|
213
|
+
abort = new AbortController();
|
|
214
|
+
clients = new Set();
|
|
215
|
+
ensure;
|
|
216
|
+
/** Build mismatch with the daemon, as the panel shows it; null when the builds match. */
|
|
217
|
+
daemon = null;
|
|
218
|
+
checking = null;
|
|
219
|
+
recheck;
|
|
220
|
+
constructor(socket, ensure) {
|
|
221
|
+
this.socket = socket;
|
|
222
|
+
this.ensure = ensure;
|
|
223
|
+
this.recheck = setInterval(() => {
|
|
224
|
+
if (this.daemon?.outdated === 'daemon')
|
|
225
|
+
void this.check();
|
|
226
|
+
}, RECHECK_MS);
|
|
227
|
+
this.recheck.unref();
|
|
228
|
+
void this.connect();
|
|
229
|
+
}
|
|
230
|
+
check() {
|
|
231
|
+
this.checking ??= this.ensure()
|
|
232
|
+
.then((result) => {
|
|
233
|
+
if (JSON.stringify(result.mismatch) === JSON.stringify(this.daemon))
|
|
234
|
+
return;
|
|
235
|
+
this.daemon = result.mismatch;
|
|
236
|
+
this.broadcast({ event: 'daemon', daemon: this.daemon });
|
|
237
|
+
}, () => undefined)
|
|
238
|
+
.finally(() => {
|
|
239
|
+
this.checking = null;
|
|
240
|
+
});
|
|
241
|
+
return this.checking;
|
|
242
|
+
}
|
|
243
|
+
async connect() {
|
|
244
|
+
while (!this.stopped) {
|
|
245
|
+
await this.check();
|
|
246
|
+
if (this.stopped)
|
|
247
|
+
break;
|
|
248
|
+
try {
|
|
249
|
+
await subscribe(this.socket, (line) => this.onLine(line), this.abort.signal);
|
|
250
|
+
}
|
|
251
|
+
catch {
|
|
252
|
+
// the daemon is not reachable yet; retry below
|
|
253
|
+
}
|
|
254
|
+
this.ready = false;
|
|
255
|
+
if (!this.stopped)
|
|
256
|
+
await new Promise((resolve) => {
|
|
257
|
+
const timer = setTimeout(resolve, 1000);
|
|
258
|
+
this.abort.signal.addEventListener('abort', () => {
|
|
259
|
+
clearTimeout(timer);
|
|
260
|
+
resolve(undefined);
|
|
261
|
+
}, { once: true });
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
onLine(line) {
|
|
266
|
+
let event;
|
|
267
|
+
try {
|
|
268
|
+
event = streamEventSchema.parse(JSON.parse(line));
|
|
269
|
+
}
|
|
270
|
+
catch {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
if (event.event === 'snapshot') {
|
|
274
|
+
this.tags = event.tags ?? [];
|
|
275
|
+
this.runs = new Map(event.runs.map((run) => [run.id, run]));
|
|
276
|
+
this.queues = new Map((event.queues ?? []).map((queue) => [queue.repository, queue]));
|
|
277
|
+
this.repositories = event.repositories ?? [];
|
|
278
|
+
this.processes = null;
|
|
279
|
+
this.ready = true;
|
|
280
|
+
this.seq = event.seq;
|
|
281
|
+
this.broadcast(this.snapshot());
|
|
282
|
+
}
|
|
283
|
+
else if (event.event === 'run') {
|
|
284
|
+
this.runs.set(event.run.id, event.run);
|
|
285
|
+
this.seq = event.seq;
|
|
286
|
+
this.broadcast(event);
|
|
287
|
+
}
|
|
288
|
+
else if (event.event === 'repositories') {
|
|
289
|
+
this.repositories = event.repositories;
|
|
290
|
+
this.seq = event.seq;
|
|
291
|
+
this.broadcast(event);
|
|
292
|
+
}
|
|
293
|
+
else if (event.event === 'queue') {
|
|
294
|
+
this.queues.set(event.queue.repository, event.queue);
|
|
295
|
+
this.seq = event.seq;
|
|
296
|
+
this.broadcast(event);
|
|
297
|
+
}
|
|
298
|
+
else if (event.event === 'tags') {
|
|
299
|
+
this.tags = event.tags;
|
|
300
|
+
this.seq = event.seq;
|
|
301
|
+
this.broadcast(event);
|
|
302
|
+
}
|
|
303
|
+
else if (event.event === 'observers') {
|
|
304
|
+
// Not kept: the snapshot has no observers, a new tab reads GET /api/observers.
|
|
305
|
+
this.seq = event.seq;
|
|
306
|
+
this.broadcast(event);
|
|
307
|
+
}
|
|
308
|
+
else if (event.event === 'processes') {
|
|
309
|
+
const { seq, ...rest } = event;
|
|
310
|
+
this.processes = rest;
|
|
311
|
+
this.seq = seq;
|
|
312
|
+
this.broadcast(event);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
snapshot() {
|
|
316
|
+
return {
|
|
317
|
+
event: 'snapshot',
|
|
318
|
+
seq: this.seq,
|
|
319
|
+
runs: [...this.runs.values()],
|
|
320
|
+
queues: [...this.queues.values()],
|
|
321
|
+
repositories: this.repositories,
|
|
322
|
+
tags: this.tags,
|
|
323
|
+
daemon: this.daemon,
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
broadcast(event) {
|
|
327
|
+
const frame = `data: ${JSON.stringify(event)}\n\n`;
|
|
328
|
+
for (const client of this.clients)
|
|
329
|
+
client.write(frame);
|
|
330
|
+
}
|
|
331
|
+
attach(incoming, response) {
|
|
332
|
+
response.writeHead(200, {
|
|
333
|
+
'content-type': 'text/event-stream; charset=utf-8',
|
|
334
|
+
'cache-control': 'no-store',
|
|
335
|
+
connection: 'keep-alive',
|
|
336
|
+
'x-accel-buffering': 'no',
|
|
337
|
+
});
|
|
338
|
+
response.write('retry: 2000\n\n');
|
|
339
|
+
this.clients.add(response);
|
|
340
|
+
if (this.ready) {
|
|
341
|
+
response.write(`data: ${JSON.stringify(this.snapshot())}\n\n`);
|
|
342
|
+
if (this.processes) {
|
|
343
|
+
response.write(`data: ${JSON.stringify({ ...this.processes, seq: this.seq })}\n\n`);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
const beat = setInterval(() => response.write(': ping\n\n'), 15_000);
|
|
347
|
+
incoming.on('close', () => {
|
|
348
|
+
clearInterval(beat);
|
|
349
|
+
this.clients.delete(response);
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
stop() {
|
|
353
|
+
this.stopped = true;
|
|
354
|
+
clearInterval(this.recheck);
|
|
355
|
+
this.abort.abort();
|
|
356
|
+
for (const client of this.clients)
|
|
357
|
+
client.end();
|
|
358
|
+
this.clients.clear();
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
function transcriptQuery(search) {
|
|
362
|
+
const query = {};
|
|
363
|
+
for (const [key, low] of [
|
|
364
|
+
['seq', 1],
|
|
365
|
+
['after', 0],
|
|
366
|
+
]) {
|
|
367
|
+
const value = search.get(key);
|
|
368
|
+
if (value === null)
|
|
369
|
+
continue;
|
|
370
|
+
const number = Number(value);
|
|
371
|
+
if (!Number.isInteger(number) || number < low)
|
|
372
|
+
throw panel('invalid', `${key} must be an integer from ${low}`);
|
|
373
|
+
query[key] = number;
|
|
374
|
+
}
|
|
375
|
+
return query;
|
|
376
|
+
}
|
|
377
|
+
export function assertLoopbackHost(host) {
|
|
378
|
+
if (!['127.0.0.1', 'localhost', '::1'].includes(host))
|
|
379
|
+
throw configError('the web panel only listens on loopback: use 127.0.0.1, localhost or ::1');
|
|
380
|
+
}
|
|
381
|
+
const TOKEN_PATTERN = /^[A-Za-z0-9_-]{16,128}$/;
|
|
382
|
+
/** The fixed access token from `AIP_WEB_TOKEN`, or undefined when the variable is not set. */
|
|
383
|
+
export function webTokenFromEnv(env) {
|
|
384
|
+
const value = env.AIP_WEB_TOKEN;
|
|
385
|
+
if (value === undefined || value === '')
|
|
386
|
+
return undefined;
|
|
387
|
+
if (!TOKEN_PATTERN.test(value))
|
|
388
|
+
throw configError('AIP_WEB_TOKEN must be 16-128 characters of A-Z, a-z, 0-9, - and _');
|
|
389
|
+
return value;
|
|
390
|
+
}
|
|
391
|
+
export async function startWebServer(options) {
|
|
392
|
+
const open = options.auth === 'none';
|
|
393
|
+
const token = open ? null : (options.token ?? randomBytes(24).toString('base64url'));
|
|
394
|
+
const host = options.host ?? '127.0.0.1';
|
|
395
|
+
assertLoopbackHost(host);
|
|
396
|
+
const hub = new Hub(options.socket, options.ensureDaemon ?? (() => checkDaemon(options.socket)));
|
|
397
|
+
const assets = normalize(options.assets ?? DEFAULT_ASSETS);
|
|
398
|
+
const call = (method, params) => request(options.socket, method, params);
|
|
399
|
+
let port = options.port ?? 0;
|
|
400
|
+
const segment = '([^/]+)';
|
|
401
|
+
/** The repository of a request: `?repository=` (absolute path) or the one of the panel. */
|
|
402
|
+
const requestRepository = async (searchParams) => {
|
|
403
|
+
const chosen = searchParams.get('repository');
|
|
404
|
+
if (chosen === null || chosen === '') {
|
|
405
|
+
if (options.repository !== undefined)
|
|
406
|
+
return options.repository;
|
|
407
|
+
const found = (await options.defaultRepository?.()) ?? null;
|
|
408
|
+
if (found === null)
|
|
409
|
+
throw panel('conflict', 'no repository yet: add one in the panel');
|
|
410
|
+
return found;
|
|
411
|
+
}
|
|
412
|
+
if (!isAbsolute(chosen))
|
|
413
|
+
throw panel('invalid', 'repository must be an absolute path');
|
|
414
|
+
return chosen;
|
|
415
|
+
};
|
|
416
|
+
/** Fields of a queue request body; the repository comes from the query string, never the body. */
|
|
417
|
+
const queueBody = (body) => parseBody(z.record(z.string(), z.unknown()), body);
|
|
418
|
+
const routes = [
|
|
419
|
+
{ method: 'GET', pattern: /^\/api\/runs$/, handle: () => call('status', {}) },
|
|
420
|
+
{
|
|
421
|
+
method: 'GET',
|
|
422
|
+
pattern: /^\/api\/finished-runs$/,
|
|
423
|
+
handle: (_match, body) => call('finished_runs', body),
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
method: 'GET',
|
|
427
|
+
pattern: new RegExp(`^/api/runs/${segment}$`),
|
|
428
|
+
handle: ([runId]) => call('status', { runId: runId ?? '' }),
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
method: 'GET',
|
|
432
|
+
pattern: new RegExp(`^/api/runs/${segment}/groups/${segment}$`),
|
|
433
|
+
handle: ([runId, group], body) => call('group', {
|
|
434
|
+
runId: runId ?? '',
|
|
435
|
+
group: group ?? '',
|
|
436
|
+
tailLines: body.tail,
|
|
437
|
+
}),
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
method: 'GET',
|
|
441
|
+
pattern: new RegExp(`^/api/runs/${segment}/groups/${segment}/spec$`),
|
|
442
|
+
handle: ([runId, group]) => call('group_spec', { runId: runId ?? '', group: group ?? '' }),
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
method: 'GET',
|
|
446
|
+
pattern: new RegExp(`^/api/runs/${segment}/groups/${segment}/artifacts$`),
|
|
447
|
+
handle: async ([runId, group]) => ({
|
|
448
|
+
artifacts: await call('group_artifacts', { runId: runId ?? '', group: group ?? '' }),
|
|
449
|
+
}),
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
method: 'GET',
|
|
453
|
+
pattern: new RegExp(`^/api/runs/${segment}/groups/${segment}/transcript$`),
|
|
454
|
+
handle: ([runId, group], body) => call('transcript', {
|
|
455
|
+
runId: runId ?? '',
|
|
456
|
+
group: group ?? '',
|
|
457
|
+
...body,
|
|
458
|
+
}),
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
method: 'GET',
|
|
462
|
+
pattern: new RegExp(`^/api/runs/${segment}/groups/${segment}/diff$`),
|
|
463
|
+
handle: ([runId, group], body) => call('group_file_diff', {
|
|
464
|
+
runId: runId ?? '',
|
|
465
|
+
group: group ?? '',
|
|
466
|
+
path: body.path,
|
|
467
|
+
}),
|
|
468
|
+
},
|
|
469
|
+
{
|
|
470
|
+
method: 'GET',
|
|
471
|
+
pattern: /^\/api\/pipelines$/,
|
|
472
|
+
handle: (_match, _body, repository) => call('pipelines', { repository }),
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
method: 'GET',
|
|
476
|
+
pattern: /^\/api\/system-stages$/,
|
|
477
|
+
handle: (_match, _body, repository) => call('system_stages', { repository }),
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
method: 'GET',
|
|
481
|
+
pattern: /^\/api\/queue$/,
|
|
482
|
+
handle: (_match, _body, repository) => call('queue', { repository }),
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
method: 'POST',
|
|
486
|
+
pattern: /^\/api\/queue\/items$/,
|
|
487
|
+
handle: async (_, body, repository) => call('queue_add', {
|
|
488
|
+
...queueBody(body),
|
|
489
|
+
repository,
|
|
490
|
+
}),
|
|
491
|
+
},
|
|
492
|
+
{
|
|
493
|
+
method: 'POST',
|
|
494
|
+
pattern: new RegExp(`^/api/queue/items/${segment}$`),
|
|
495
|
+
handle: async ([item], body, repository) => call('queue_edit', {
|
|
496
|
+
...queueBody(body),
|
|
497
|
+
item: item ?? '',
|
|
498
|
+
repository,
|
|
499
|
+
}),
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
method: 'POST',
|
|
503
|
+
pattern: new RegExp(`^/api/queue/items/${segment}/remove$`),
|
|
504
|
+
handle: ([item], _body, repository) => call('queue_remove', { item: item ?? '', repository }),
|
|
505
|
+
},
|
|
506
|
+
{
|
|
507
|
+
method: 'POST',
|
|
508
|
+
pattern: new RegExp(`^/api/queue/items/${segment}/run$`),
|
|
509
|
+
handle: ([item], _body, repository) => call('queue_run_now', { item: item ?? '', repository }),
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
method: 'POST',
|
|
513
|
+
pattern: /^\/api\/queue\/start$/,
|
|
514
|
+
handle: async (_, body, repository) => call('queue_start', {
|
|
515
|
+
...queueBody(body),
|
|
516
|
+
repository,
|
|
517
|
+
}),
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
method: 'POST',
|
|
521
|
+
pattern: /^\/api\/queue\/pause$/,
|
|
522
|
+
handle: (_match, _body, repository) => call('queue_pause', { repository }),
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
method: 'POST',
|
|
526
|
+
pattern: /^\/api\/queue\/return$/,
|
|
527
|
+
handle: async (_, body, repository) => {
|
|
528
|
+
const { run } = parseBody(z.object({ run: z.string().min(1) }), body);
|
|
529
|
+
return call('queue_return', { runId: run, ...(repository ? { repository } : {}) });
|
|
530
|
+
},
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
method: 'POST',
|
|
534
|
+
pattern: /^\/api\/queue\/dismiss$/,
|
|
535
|
+
handle: async (_, body, repository) => {
|
|
536
|
+
const { run } = parseBody(z.object({ run: z.string().min(1) }), body);
|
|
537
|
+
return call('queue_dismiss', { runId: run, ...(repository ? { repository } : {}) });
|
|
538
|
+
},
|
|
539
|
+
},
|
|
540
|
+
{
|
|
541
|
+
method: 'POST',
|
|
542
|
+
pattern: /^\/api\/queue\/settings$/,
|
|
543
|
+
handle: async (_, body, repository) => call('queue_settings', {
|
|
544
|
+
...queueBody(body),
|
|
545
|
+
repository,
|
|
546
|
+
}),
|
|
547
|
+
},
|
|
548
|
+
{
|
|
549
|
+
method: 'GET',
|
|
550
|
+
pattern: /^\/api\/config$/,
|
|
551
|
+
handle: (_match, _body, repository) => call('config', { repository }),
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
method: 'GET',
|
|
555
|
+
pattern: /^\/api\/config\/catalog$/,
|
|
556
|
+
handle: (_match, _body, repository) => call('config_catalog', { repository }),
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
method: 'PUT',
|
|
560
|
+
pattern: new RegExp(`^/api/config/specialists/${segment}$`),
|
|
561
|
+
handle: async ([id], body, repository) => {
|
|
562
|
+
const { value, revision, level } = parseBody(writeBody, body);
|
|
563
|
+
return editReply((await call('config_write', {
|
|
564
|
+
repository,
|
|
565
|
+
kind: 'specialist',
|
|
566
|
+
id: entryId(id),
|
|
567
|
+
value,
|
|
568
|
+
revision,
|
|
569
|
+
level,
|
|
570
|
+
})));
|
|
571
|
+
},
|
|
572
|
+
},
|
|
573
|
+
{
|
|
574
|
+
method: 'GET',
|
|
575
|
+
pattern: /^\/api\/shared-pipelines$/,
|
|
576
|
+
handle: () => call('shared_pipelines', {}),
|
|
577
|
+
},
|
|
578
|
+
{
|
|
579
|
+
method: 'POST',
|
|
580
|
+
pattern: /^\/api\/config\/pipelines\/import$/,
|
|
581
|
+
handle: async (_match, body, repository) => {
|
|
582
|
+
const result = (await call('pipelines_import', {
|
|
583
|
+
repository,
|
|
584
|
+
...parseBody(pipelineImportBody, body),
|
|
585
|
+
}));
|
|
586
|
+
if (result.ok)
|
|
587
|
+
return new Reply(200, result);
|
|
588
|
+
if (result.reason === 'conflict') {
|
|
589
|
+
return new Reply(409, { error: result.message, ids: result.ids ?? [] });
|
|
590
|
+
}
|
|
591
|
+
return new Reply(422, { errors: result.errors, references: [] });
|
|
592
|
+
},
|
|
593
|
+
},
|
|
594
|
+
{
|
|
595
|
+
method: 'GET',
|
|
596
|
+
pattern: /^\/api\/shared-specialists$/,
|
|
597
|
+
handle: () => call('shared_specialists', {}),
|
|
598
|
+
},
|
|
599
|
+
{
|
|
600
|
+
method: 'GET',
|
|
601
|
+
pattern: /^\/api\/observers$/,
|
|
602
|
+
handle: () => call('observers', {}),
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
method: 'PUT',
|
|
606
|
+
pattern: /^\/api\/observers$/,
|
|
607
|
+
handle: async (_match, body) => {
|
|
608
|
+
const settings = parseBody(z.record(z.string(), z.unknown()), body);
|
|
609
|
+
const result = (await call('observers_set', { settings }));
|
|
610
|
+
if (result.ok)
|
|
611
|
+
return new Reply(200, result.view);
|
|
612
|
+
return new Reply(422, { errors: result.errors });
|
|
613
|
+
},
|
|
614
|
+
},
|
|
615
|
+
{
|
|
616
|
+
method: 'POST',
|
|
617
|
+
pattern: new RegExp(`^/api/runs/${segment}/observer$`),
|
|
618
|
+
handle: async ([runId], body) => call('run_observer', { runId: runId ?? '', ...parseBody(runObserverBody, body) }),
|
|
619
|
+
},
|
|
620
|
+
{
|
|
621
|
+
method: 'GET',
|
|
622
|
+
pattern: /^\/api\/specialist-tags$/,
|
|
623
|
+
handle: () => call('specialist_tags', {}),
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
method: 'PUT',
|
|
627
|
+
pattern: new RegExp(`^/api/specialist-tags/specialists/${segment}$`),
|
|
628
|
+
handle: async ([slug], body) => tagReply((await call('specialist_tags_set', {
|
|
629
|
+
...parseBody(tagsSetBody, body),
|
|
630
|
+
slug: entryId(slug),
|
|
631
|
+
}))),
|
|
632
|
+
},
|
|
633
|
+
{
|
|
634
|
+
method: 'POST',
|
|
635
|
+
pattern: /^\/api\/specialist-tags\/rename$/,
|
|
636
|
+
handle: async (_match, body) => tagReply((await call('specialist_tag_rename', parseBody(tagRenameBody, body)))),
|
|
637
|
+
},
|
|
638
|
+
{
|
|
639
|
+
method: 'POST',
|
|
640
|
+
pattern: /^\/api\/specialist-tags\/remove$/,
|
|
641
|
+
handle: async (_match, body) => tagReply((await call('specialist_tag_remove', parseBody(specialistTagRemoveBody, body)))),
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
method: 'POST',
|
|
645
|
+
pattern: /^\/api\/config\/specialists\/import$/,
|
|
646
|
+
handle: async (_match, body, repository) => tagReply((await call('specialists_import', {
|
|
647
|
+
repository,
|
|
648
|
+
...parseBody(importBody, body),
|
|
649
|
+
}))),
|
|
650
|
+
},
|
|
651
|
+
{
|
|
652
|
+
method: 'PUT',
|
|
653
|
+
pattern: /^\/api\/config\/settings$/,
|
|
654
|
+
handle: async (_match, body, repository) => {
|
|
655
|
+
const { values, revision, level } = parseBody(settingsBody, body);
|
|
656
|
+
const unknown = Object.keys(values).filter((path) => settingFieldOf(path) === undefined);
|
|
657
|
+
if (unknown.length > 0) {
|
|
658
|
+
throw panel('not_found', `setting \`${unknown.join('`, `')}\` cannot be written`);
|
|
659
|
+
}
|
|
660
|
+
if (Object.keys(values).length === 0)
|
|
661
|
+
throw panel('invalid', 'values must not be empty');
|
|
662
|
+
return editReply((await call('config_settings', {
|
|
663
|
+
repository,
|
|
664
|
+
values,
|
|
665
|
+
revision,
|
|
666
|
+
level: level ?? 'global',
|
|
667
|
+
})));
|
|
668
|
+
},
|
|
669
|
+
},
|
|
670
|
+
{
|
|
671
|
+
method: 'PUT',
|
|
672
|
+
pattern: new RegExp(`^/api/config/settings/${segment}$`),
|
|
673
|
+
handle: async ([path], body, repository) => {
|
|
674
|
+
const known = path !== undefined && settingFieldOf(path) !== undefined ? path : undefined;
|
|
675
|
+
if (known === undefined) {
|
|
676
|
+
throw panel('not_found', `setting \`${path ?? ''}\` cannot be written`);
|
|
677
|
+
}
|
|
678
|
+
const { value, revision, level } = parseBody(settingBody, body);
|
|
679
|
+
return editReply((await call('config_setting', {
|
|
680
|
+
repository,
|
|
681
|
+
path: known,
|
|
682
|
+
value,
|
|
683
|
+
revision,
|
|
684
|
+
level: level ?? 'global',
|
|
685
|
+
})));
|
|
686
|
+
},
|
|
687
|
+
},
|
|
688
|
+
{
|
|
689
|
+
method: 'DELETE',
|
|
690
|
+
pattern: new RegExp(`^/api/config/(specialists|pipelines|actions)/${segment}$`),
|
|
691
|
+
handle: async ([section, id], body, repository) => {
|
|
692
|
+
const { revision, level } = body;
|
|
693
|
+
if (!revision)
|
|
694
|
+
throw panel('invalid', 'revision is required');
|
|
695
|
+
return editReply((await call('config_delete', {
|
|
696
|
+
repository,
|
|
697
|
+
kind: section === 'pipelines'
|
|
698
|
+
? 'pipeline'
|
|
699
|
+
: section === 'actions'
|
|
700
|
+
? 'action'
|
|
701
|
+
: 'specialist',
|
|
702
|
+
id: entryId(id),
|
|
703
|
+
revision,
|
|
704
|
+
level,
|
|
705
|
+
})));
|
|
706
|
+
},
|
|
707
|
+
},
|
|
708
|
+
{
|
|
709
|
+
method: 'PUT',
|
|
710
|
+
pattern: new RegExp(`^/api/config/pipelines/${segment}$`),
|
|
711
|
+
handle: async ([id], body, repository) => {
|
|
712
|
+
const { value, revision, level } = parseBody(writeBody, body);
|
|
713
|
+
return editReply((await call('config_write', {
|
|
714
|
+
repository,
|
|
715
|
+
kind: 'pipeline',
|
|
716
|
+
id: entryId(id),
|
|
717
|
+
value,
|
|
718
|
+
revision,
|
|
719
|
+
level,
|
|
720
|
+
})));
|
|
721
|
+
},
|
|
722
|
+
},
|
|
723
|
+
{
|
|
724
|
+
method: 'PUT',
|
|
725
|
+
pattern: new RegExp(`^/api/config/actions/${segment}$`),
|
|
726
|
+
handle: async ([id], body, repository) => {
|
|
727
|
+
const { value, revision, level } = parseBody(writeBody, body);
|
|
728
|
+
return editReply((await call('config_write', {
|
|
729
|
+
repository,
|
|
730
|
+
kind: 'action',
|
|
731
|
+
id: entryId(id),
|
|
732
|
+
value,
|
|
733
|
+
revision,
|
|
734
|
+
level,
|
|
735
|
+
})));
|
|
736
|
+
},
|
|
737
|
+
},
|
|
738
|
+
{
|
|
739
|
+
method: 'POST',
|
|
740
|
+
pattern: new RegExp(`^/api/config/pipelines/${segment}/preview$`),
|
|
741
|
+
handle: async ([id], body, repository) => call('config_preview', {
|
|
742
|
+
repository,
|
|
743
|
+
kind: 'pipeline',
|
|
744
|
+
id: entryId(id),
|
|
745
|
+
value: parseBody(previewBody, body).value,
|
|
746
|
+
level: parseBody(previewBody, body).level,
|
|
747
|
+
}),
|
|
748
|
+
},
|
|
749
|
+
{
|
|
750
|
+
method: 'GET',
|
|
751
|
+
pattern: /^\/api\/tags$/,
|
|
752
|
+
handle: (_match, _body, repository) => call('tags', { repository }),
|
|
753
|
+
},
|
|
754
|
+
{
|
|
755
|
+
method: 'POST',
|
|
756
|
+
pattern: /^\/api\/tags$/,
|
|
757
|
+
handle: async (_, body, repository) => call('tag_add', { repository, ...parseBody(tagAddBody, body) }),
|
|
758
|
+
},
|
|
759
|
+
{
|
|
760
|
+
method: 'POST',
|
|
761
|
+
pattern: /^\/api\/tags\/edit$/,
|
|
762
|
+
handle: async (_, body, repository) => call('tag_edit', { repository, ...parseBody(tagEditBody, body) }),
|
|
763
|
+
},
|
|
764
|
+
{
|
|
765
|
+
method: 'POST',
|
|
766
|
+
pattern: /^\/api\/tags\/remove$/,
|
|
767
|
+
handle: async (_, body, repository) => call('tag_remove', { repository, ...parseBody(tagRemoveBody, body) }),
|
|
768
|
+
},
|
|
769
|
+
{
|
|
770
|
+
method: 'POST',
|
|
771
|
+
pattern: new RegExp(`^/api/runs/${segment}/tags$`),
|
|
772
|
+
handle: async ([runId], body) => call('run_tags', { runId: runId ?? '', ...parseBody(runTagsBody, body) }),
|
|
773
|
+
},
|
|
774
|
+
{
|
|
775
|
+
method: 'POST',
|
|
776
|
+
pattern: new RegExp(`^/api/runs/${segment}/title$`),
|
|
777
|
+
handle: async ([runId], body) => call('run_title', { runId: runId ?? '', ...parseBody(runTitleBody, body) }),
|
|
778
|
+
},
|
|
779
|
+
{
|
|
780
|
+
method: 'GET',
|
|
781
|
+
pattern: /^\/api\/processes$/,
|
|
782
|
+
handle: () => call('processes', {}),
|
|
783
|
+
},
|
|
784
|
+
{
|
|
785
|
+
method: 'POST',
|
|
786
|
+
pattern: /^\/api\/processes\/([^/]+)\/kill$/,
|
|
787
|
+
handle: ([pid]) => {
|
|
788
|
+
if (!/^\d+$/.test(pid ?? ''))
|
|
789
|
+
throw panel('invalid', 'pid must be a positive integer');
|
|
790
|
+
return call('process_kill', { pid: Number(pid) });
|
|
791
|
+
},
|
|
792
|
+
},
|
|
793
|
+
{
|
|
794
|
+
method: 'POST',
|
|
795
|
+
pattern: new RegExp(`^/api/runs/${segment}/cancel$`),
|
|
796
|
+
handle: ([runId]) => call('cancel', { runId: runId ?? '' }),
|
|
797
|
+
},
|
|
798
|
+
{
|
|
799
|
+
method: 'POST',
|
|
800
|
+
pattern: new RegExp(`^/api/runs/${segment}/pause$`),
|
|
801
|
+
handle: ([runId]) => call('run_pause', { runId: runId ?? '' }),
|
|
802
|
+
},
|
|
803
|
+
{
|
|
804
|
+
method: 'POST',
|
|
805
|
+
pattern: new RegExp(`^/api/runs/${segment}/skip$`),
|
|
806
|
+
handle: async ([runId], body) => {
|
|
807
|
+
const { step, skip } = parseBody(skipBody, body);
|
|
808
|
+
return call('run_skip', { runId: runId ?? '', step, skip });
|
|
809
|
+
},
|
|
810
|
+
},
|
|
811
|
+
{
|
|
812
|
+
method: 'POST',
|
|
813
|
+
pattern: new RegExp(`^/api/runs/${segment}/apply$`),
|
|
814
|
+
handle: async ([runId], body) => {
|
|
815
|
+
const { groups, force } = parseBody(applyBody, body);
|
|
816
|
+
return call('apply', {
|
|
817
|
+
runId: runId ?? '',
|
|
818
|
+
...(groups ? { groups } : {}),
|
|
819
|
+
...(force ? { force: true } : {}),
|
|
820
|
+
});
|
|
821
|
+
},
|
|
822
|
+
},
|
|
823
|
+
{
|
|
824
|
+
method: 'POST',
|
|
825
|
+
pattern: new RegExp(`^/api/runs/${segment}/delivered$`),
|
|
826
|
+
handle: async ([runId], body) => {
|
|
827
|
+
const { groups } = parseBody(markDeliveredBody, body);
|
|
828
|
+
return call('run_mark_delivered', { runId: runId ?? '', ...(groups ? { groups } : {}) });
|
|
829
|
+
},
|
|
830
|
+
},
|
|
831
|
+
{
|
|
832
|
+
method: 'POST',
|
|
833
|
+
pattern: new RegExp(`^/api/runs/${segment}/groups/${segment}/(cancel|retry)$`),
|
|
834
|
+
handle: ([runId, group, action], body) => {
|
|
835
|
+
if (action !== 'retry')
|
|
836
|
+
return call('cancel', { runId: runId ?? '', group: group ?? '' });
|
|
837
|
+
const { refreshConfig } = parseBody(retryBody, body);
|
|
838
|
+
return call('retry', {
|
|
839
|
+
runId: runId ?? '',
|
|
840
|
+
group: group ?? '',
|
|
841
|
+
...(refreshConfig ? { refreshConfig: true } : {}),
|
|
842
|
+
});
|
|
843
|
+
},
|
|
844
|
+
},
|
|
845
|
+
{
|
|
846
|
+
method: 'POST',
|
|
847
|
+
pattern: new RegExp(`^/api/runs/${segment}/groups/${segment}/answer$`),
|
|
848
|
+
handle: async ([runId, group], body) => call('answer', {
|
|
849
|
+
runId: runId ?? '',
|
|
850
|
+
group: group ?? '',
|
|
851
|
+
answer: parseBody(answerBody, body).answer,
|
|
852
|
+
}),
|
|
853
|
+
},
|
|
854
|
+
{
|
|
855
|
+
method: 'POST',
|
|
856
|
+
pattern: new RegExp(`^/api/runs/${segment}/groups/${segment}/message$`),
|
|
857
|
+
handle: async ([runId, group], body) => {
|
|
858
|
+
const { seq, text } = parseBody(messageBody, body);
|
|
859
|
+
return call('message', { runId: runId ?? '', group: group ?? '', seq, text });
|
|
860
|
+
},
|
|
861
|
+
},
|
|
862
|
+
];
|
|
863
|
+
function hostAllowed(incoming) {
|
|
864
|
+
const given = incoming.headers.host?.toLowerCase();
|
|
865
|
+
if (given === undefined)
|
|
866
|
+
return false;
|
|
867
|
+
const allowed = new Set([`127.0.0.1:${port}`, `localhost:${port}`, `[::1]:${port}`]);
|
|
868
|
+
if (!allowed.has(given))
|
|
869
|
+
return false;
|
|
870
|
+
const origin = incoming.headers.origin;
|
|
871
|
+
if (origin === undefined)
|
|
872
|
+
return true;
|
|
873
|
+
try {
|
|
874
|
+
return new URL(origin).host.toLowerCase() === given;
|
|
875
|
+
}
|
|
876
|
+
catch {
|
|
877
|
+
return false;
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
/** Runs `action` once the response is on its way: the restart closes this very server. */
|
|
881
|
+
function afterResponse(response, label, action) {
|
|
882
|
+
response.once('finish', () => {
|
|
883
|
+
setImmediate(() => {
|
|
884
|
+
action().catch((error) => {
|
|
885
|
+
options.log?.(`aip web: ${label} failed: ${error.message}`);
|
|
886
|
+
});
|
|
887
|
+
});
|
|
888
|
+
});
|
|
889
|
+
}
|
|
890
|
+
async function handleSystem(incoming, response, path, verb) {
|
|
891
|
+
const hooks = options.system;
|
|
892
|
+
if (path === '/api/system') {
|
|
893
|
+
if (verb !== 'GET')
|
|
894
|
+
throw panel('method_not_allowed', 'method not allowed');
|
|
895
|
+
const ping = await pingDaemon(options.socket).catch(() => null);
|
|
896
|
+
const check = ping === null
|
|
897
|
+
? null
|
|
898
|
+
: await (options.ensureDaemon ?? (() => checkDaemon(options.socket)))().catch(() => null);
|
|
899
|
+
return json(response, 200, systemView({
|
|
900
|
+
ping,
|
|
901
|
+
check,
|
|
902
|
+
panelBuild: currentBuild(),
|
|
903
|
+
servedBy: hooks === undefined ? 'standalone' : (hooks.servedBy ?? 'daemon'),
|
|
904
|
+
panel: { pid: process.pid, host, port, auth: open ? 'none' : 'token' },
|
|
905
|
+
logPath: hooks?.logPath ?? null,
|
|
906
|
+
}));
|
|
907
|
+
}
|
|
908
|
+
const action = SYSTEM_ACTIONS[path];
|
|
909
|
+
if (action === undefined)
|
|
910
|
+
throw panel('not_found', 'not found');
|
|
911
|
+
if (verb !== 'POST')
|
|
912
|
+
throw panel('method_not_allowed', 'method not allowed');
|
|
913
|
+
const body = parseBody(action === 'web_restart' ? z.object({}) : forceBody, await readJson(incoming));
|
|
914
|
+
const force = body.force === true;
|
|
915
|
+
if (hooks === undefined) {
|
|
916
|
+
throw panel('conflict', 'this panel was started by `aip web`: control the daemon in the terminal', 'web_standalone');
|
|
917
|
+
}
|
|
918
|
+
const hook = action === 'web_restart'
|
|
919
|
+
? hooks.restartWeb
|
|
920
|
+
: action === 'daemon_restart'
|
|
921
|
+
? hooks.restartDaemon
|
|
922
|
+
: action === 'daemon_stop'
|
|
923
|
+
? hooks.stopDaemon
|
|
924
|
+
: hooks.startDaemon;
|
|
925
|
+
if (hook === undefined) {
|
|
926
|
+
if (action === 'daemon_start')
|
|
927
|
+
throw panel('conflict', 'the daemon is already running', 'daemon_running');
|
|
928
|
+
throw panel('conflict', 'the daemon is stopped: start it first', 'daemon_stopped');
|
|
929
|
+
}
|
|
930
|
+
if ((action === 'daemon_restart' || action === 'daemon_stop') && !force) {
|
|
931
|
+
const ping = await pingDaemon(options.socket).catch(() => null);
|
|
932
|
+
if (ping?.busy === true)
|
|
933
|
+
throw panel('conflict', `agents are running: ${action === 'daemon_stop' ? 'stop' : 'restart'} anyway to stop them`, 'daemon_busy');
|
|
934
|
+
}
|
|
935
|
+
afterResponse(response, action.replace('_', ' '), () => hook(force));
|
|
936
|
+
json(response, 202, {
|
|
937
|
+
state: action === 'daemon_stop'
|
|
938
|
+
? 'stopping'
|
|
939
|
+
: action === 'daemon_start'
|
|
940
|
+
? 'starting'
|
|
941
|
+
: 'restarting',
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
async function handle(incoming, response) {
|
|
945
|
+
if (!hostAllowed(incoming))
|
|
946
|
+
throw panel('forbidden', 'forbidden host or origin');
|
|
947
|
+
const url = new URL(incoming.url ?? '/', `http://${incoming.headers.host}`);
|
|
948
|
+
const verb = incoming.method ?? 'GET';
|
|
949
|
+
if (url.pathname === '/' || url.pathname === '/index.html') {
|
|
950
|
+
if (verb !== 'GET')
|
|
951
|
+
throw panel('method_not_allowed', 'method not allowed');
|
|
952
|
+
const fromQuery = url.searchParams.get('token') ?? undefined;
|
|
953
|
+
if (token !== null &&
|
|
954
|
+
!sameToken(fromQuery, token) &&
|
|
955
|
+
!sameToken(cookieToken(incoming.headers.cookie), token))
|
|
956
|
+
throw panel('unauthorized', TOKEN_HINT);
|
|
957
|
+
const index = join(assets, 'index.html');
|
|
958
|
+
const page = existsSync(index) ? readFileSync(index, 'utf8') : MISSING_BUILD;
|
|
959
|
+
send(response, 200, page, 'text/html', {
|
|
960
|
+
...(token === null
|
|
961
|
+
? {}
|
|
962
|
+
: { 'set-cookie': `${COOKIE}=${token}; Path=/; HttpOnly; SameSite=Strict` }),
|
|
963
|
+
'content-security-policy': PAGE_POLICY,
|
|
964
|
+
'cache-control': 'no-cache',
|
|
965
|
+
});
|
|
966
|
+
return;
|
|
967
|
+
}
|
|
968
|
+
if (url.pathname.startsWith('/assets/')) {
|
|
969
|
+
if (verb !== 'GET')
|
|
970
|
+
throw panel('method_not_allowed', 'method not allowed');
|
|
971
|
+
const file = normalize(join(assets, decodeURIComponent(url.pathname)));
|
|
972
|
+
if (!file.startsWith(assets.endsWith(sep) ? assets : `${assets}${sep}`) || !existsSync(file))
|
|
973
|
+
throw panel('not_found', 'not found');
|
|
974
|
+
const type = TYPES[extname(file)] ?? 'application/octet-stream';
|
|
975
|
+
response.writeHead(200, {
|
|
976
|
+
'content-type': type.startsWith('text/') ? `${type}; charset=utf-8` : type,
|
|
977
|
+
// Vite names assets by their content hash, so they never change.
|
|
978
|
+
'cache-control': 'public, max-age=31536000, immutable',
|
|
979
|
+
'x-content-type-options': 'nosniff',
|
|
980
|
+
});
|
|
981
|
+
response.end(readFileSync(file));
|
|
982
|
+
return;
|
|
983
|
+
}
|
|
984
|
+
if (!url.pathname.startsWith('/api/'))
|
|
985
|
+
throw panel('not_found', 'not found');
|
|
986
|
+
if (token !== null) {
|
|
987
|
+
const given = incoming.headers['x-aip-token'] ??
|
|
988
|
+
cookieToken(incoming.headers.cookie);
|
|
989
|
+
if (!sameToken(given, token))
|
|
990
|
+
throw panel('unauthorized', 'missing or invalid token');
|
|
991
|
+
}
|
|
992
|
+
if (url.pathname === '/api/events') {
|
|
993
|
+
if (verb !== 'GET')
|
|
994
|
+
throw panel('method_not_allowed', 'method not allowed');
|
|
995
|
+
hub.attach(incoming, response);
|
|
996
|
+
return;
|
|
997
|
+
}
|
|
998
|
+
if (url.pathname === '/api/repositories') {
|
|
999
|
+
if (verb === 'GET')
|
|
1000
|
+
return json(response, 200, await call('repositories', {}));
|
|
1001
|
+
if (verb === 'POST') {
|
|
1002
|
+
const { path } = parseBody(z.object({ path: z.string().min(1) }), await readJson(incoming));
|
|
1003
|
+
if (!isAbsolute(path))
|
|
1004
|
+
throw panel('invalid', 'path must be an absolute path');
|
|
1005
|
+
return json(response, 200, await call('repository_add', { path }));
|
|
1006
|
+
}
|
|
1007
|
+
if (verb === 'DELETE') {
|
|
1008
|
+
const path = url.searchParams.get('repository');
|
|
1009
|
+
if (path === null || !isAbsolute(path)) {
|
|
1010
|
+
throw panel('invalid', 'repository must be an absolute path');
|
|
1011
|
+
}
|
|
1012
|
+
return json(response, 200, await call('repository_remove', { path }));
|
|
1013
|
+
}
|
|
1014
|
+
throw panel('method_not_allowed', 'method not allowed');
|
|
1015
|
+
}
|
|
1016
|
+
if (url.pathname === '/api/system' || url.pathname.startsWith('/api/system/')) {
|
|
1017
|
+
await handleSystem(incoming, response, url.pathname, verb);
|
|
1018
|
+
return;
|
|
1019
|
+
}
|
|
1020
|
+
const patchMatch = new RegExp(`^/api/runs/${segment}/patch$`).exec(url.pathname);
|
|
1021
|
+
if (patchMatch) {
|
|
1022
|
+
if (verb !== 'GET')
|
|
1023
|
+
throw panel('method_not_allowed', 'method not allowed');
|
|
1024
|
+
let runId;
|
|
1025
|
+
try {
|
|
1026
|
+
runId = decodeURIComponent(patchMatch[1] ?? '');
|
|
1027
|
+
}
|
|
1028
|
+
catch {
|
|
1029
|
+
throw panel('invalid', 'malformed percent-encoding in path');
|
|
1030
|
+
}
|
|
1031
|
+
const patch = (await call('run_patch', { runId }));
|
|
1032
|
+
const bytes = Buffer.from(patch.base64, 'base64');
|
|
1033
|
+
response.writeHead(200, {
|
|
1034
|
+
'Content-Type': 'text/x-diff; charset=binary',
|
|
1035
|
+
'Content-Disposition': `attachment; filename="${patch.fileName.replace(/[^A-Za-z0-9._-]/g, '_')}"`,
|
|
1036
|
+
'Content-Length': bytes.length,
|
|
1037
|
+
'Cache-Control': 'no-store',
|
|
1038
|
+
});
|
|
1039
|
+
response.end(bytes);
|
|
1040
|
+
return;
|
|
1041
|
+
}
|
|
1042
|
+
const artifactMatch = new RegExp(`^/api/runs/${segment}/groups/${segment}/artifacts/${segment}$`).exec(url.pathname);
|
|
1043
|
+
if (artifactMatch) {
|
|
1044
|
+
if (verb !== 'GET')
|
|
1045
|
+
throw panel('method_not_allowed', 'method not allowed');
|
|
1046
|
+
let parts;
|
|
1047
|
+
try {
|
|
1048
|
+
parts = artifactMatch.slice(1).map((part) => decodeURIComponent(part));
|
|
1049
|
+
}
|
|
1050
|
+
catch {
|
|
1051
|
+
throw panel('invalid', 'malformed percent-encoding in path');
|
|
1052
|
+
}
|
|
1053
|
+
const [runId = '', group = '', id = ''] = parts;
|
|
1054
|
+
const inline = url.searchParams.get('inline') === '1';
|
|
1055
|
+
const artifact = (await call('artifact', { runId, group, id }));
|
|
1056
|
+
const preview = artifactPreview(artifact.fileName);
|
|
1057
|
+
if (inline && preview === null) {
|
|
1058
|
+
throw panel('invalid', 'only .md and .log artifacts can be shown inline');
|
|
1059
|
+
}
|
|
1060
|
+
const bytes = Buffer.from(artifact.base64, 'base64');
|
|
1061
|
+
const headers = {
|
|
1062
|
+
'Content-Length': bytes.length,
|
|
1063
|
+
'X-Content-Type-Options': 'nosniff',
|
|
1064
|
+
'Cache-Control': 'no-store',
|
|
1065
|
+
};
|
|
1066
|
+
if (inline) {
|
|
1067
|
+
headers['Content-Type'] = 'text/plain; charset=utf-8';
|
|
1068
|
+
}
|
|
1069
|
+
else {
|
|
1070
|
+
headers['Content-Type'] =
|
|
1071
|
+
preview === 'markdown'
|
|
1072
|
+
? 'text/markdown; charset=utf-8'
|
|
1073
|
+
: preview === 'log'
|
|
1074
|
+
? 'text/plain; charset=utf-8'
|
|
1075
|
+
: 'application/octet-stream';
|
|
1076
|
+
const ascii = artifact.fileName.replace(/[^A-Za-z0-9._-]/g, '_');
|
|
1077
|
+
headers['Content-Disposition'] =
|
|
1078
|
+
`attachment; filename="${ascii}"; filename*=UTF-8''${encodeURIComponent(artifact.fileName).replace(/['()*]/g, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`)}`;
|
|
1079
|
+
}
|
|
1080
|
+
response.writeHead(200, headers);
|
|
1081
|
+
response.end(bytes);
|
|
1082
|
+
return;
|
|
1083
|
+
}
|
|
1084
|
+
let wrongMethod = false;
|
|
1085
|
+
for (const route of routes) {
|
|
1086
|
+
const match = route.pattern.exec(url.pathname);
|
|
1087
|
+
if (!match)
|
|
1088
|
+
continue;
|
|
1089
|
+
if (route.method !== verb) {
|
|
1090
|
+
wrongMethod = true;
|
|
1091
|
+
continue;
|
|
1092
|
+
}
|
|
1093
|
+
let parts;
|
|
1094
|
+
try {
|
|
1095
|
+
parts = match.slice(1).map((part) => decodeURIComponent(part));
|
|
1096
|
+
}
|
|
1097
|
+
catch {
|
|
1098
|
+
throw panel('invalid', 'malformed percent-encoding in path');
|
|
1099
|
+
}
|
|
1100
|
+
let body = {};
|
|
1101
|
+
if (verb === 'POST' || verb === 'PUT')
|
|
1102
|
+
body = await readJson(incoming);
|
|
1103
|
+
else if (verb === 'DELETE') {
|
|
1104
|
+
const revision = url.searchParams.get('revision');
|
|
1105
|
+
const level = url.searchParams.get('level');
|
|
1106
|
+
if (level !== null && level !== 'project' && level !== 'global') {
|
|
1107
|
+
throw panel('invalid', 'level must be project or global');
|
|
1108
|
+
}
|
|
1109
|
+
body = { ...(revision ? { revision } : {}), ...(level ? { level } : {}) };
|
|
1110
|
+
}
|
|
1111
|
+
else if (/\/groups\/[^/]+$/.test(url.pathname)) {
|
|
1112
|
+
const tail = Number(url.searchParams.get('tail') ?? 40);
|
|
1113
|
+
if (!Number.isInteger(tail) || tail < 1 || tail > 500)
|
|
1114
|
+
throw panel('invalid', 'tail must be an integer from 1 to 500');
|
|
1115
|
+
body = { tail };
|
|
1116
|
+
}
|
|
1117
|
+
else if (url.pathname === '/api/finished-runs') {
|
|
1118
|
+
const limit = Number(url.searchParams.get('limit') ?? 15);
|
|
1119
|
+
if (!Number.isInteger(limit) || limit < 1 || limit > 100)
|
|
1120
|
+
throw panel('invalid', 'limit must be an integer from 1 to 100');
|
|
1121
|
+
const before = url.searchParams.get('before');
|
|
1122
|
+
body = { limit, ...(before ? { before } : {}) };
|
|
1123
|
+
}
|
|
1124
|
+
else if (url.pathname.endsWith('/transcript')) {
|
|
1125
|
+
body = transcriptQuery(url.searchParams);
|
|
1126
|
+
}
|
|
1127
|
+
else if (url.pathname.endsWith('/diff')) {
|
|
1128
|
+
const path = url.searchParams.get('path');
|
|
1129
|
+
if (path === null || path === '')
|
|
1130
|
+
throw panel('invalid', 'path is required');
|
|
1131
|
+
body = { path };
|
|
1132
|
+
}
|
|
1133
|
+
// Runs belong to the daemon, not to a repository: they work without one.
|
|
1134
|
+
// A returned run belongs to its own repository unless the request names one.
|
|
1135
|
+
const ownRepository = (url.pathname === '/api/queue/return' || url.pathname === '/api/queue/dismiss') &&
|
|
1136
|
+
!url.searchParams.get('repository');
|
|
1137
|
+
const repository = url.pathname.startsWith('/api/runs') ||
|
|
1138
|
+
url.pathname === '/api/finished-runs' ||
|
|
1139
|
+
url.pathname.startsWith('/api/processes') ||
|
|
1140
|
+
url.pathname.startsWith('/api/specialist-tags') ||
|
|
1141
|
+
url.pathname === '/api/observers' ||
|
|
1142
|
+
ownRepository
|
|
1143
|
+
? ''
|
|
1144
|
+
: await requestRepository(url.searchParams);
|
|
1145
|
+
const result = await route.handle(parts, body, repository);
|
|
1146
|
+
if (result instanceof Reply)
|
|
1147
|
+
json(response, result.status, result.value);
|
|
1148
|
+
else
|
|
1149
|
+
json(response, 200, result);
|
|
1150
|
+
return;
|
|
1151
|
+
}
|
|
1152
|
+
if (wrongMethod)
|
|
1153
|
+
throw panel('method_not_allowed', 'method not allowed');
|
|
1154
|
+
throw panel('not_found', 'not found');
|
|
1155
|
+
}
|
|
1156
|
+
const server = createServer((incoming, response) => {
|
|
1157
|
+
handle(incoming, response).catch((error) => {
|
|
1158
|
+
if (response.headersSent) {
|
|
1159
|
+
response.end();
|
|
1160
|
+
return;
|
|
1161
|
+
}
|
|
1162
|
+
const rendered = renderPanelError(error);
|
|
1163
|
+
json(response, rendered.status, rendered.body);
|
|
1164
|
+
});
|
|
1165
|
+
});
|
|
1166
|
+
try {
|
|
1167
|
+
await new Promise((resolve, reject) => {
|
|
1168
|
+
server.once('error', reject);
|
|
1169
|
+
server.listen(port, host, () => resolve());
|
|
1170
|
+
});
|
|
1171
|
+
}
|
|
1172
|
+
catch (error) {
|
|
1173
|
+
hub.stop();
|
|
1174
|
+
throw error;
|
|
1175
|
+
}
|
|
1176
|
+
port = server.address().port;
|
|
1177
|
+
const shown = host.includes(':') ? `[${host}]` : host;
|
|
1178
|
+
return {
|
|
1179
|
+
server,
|
|
1180
|
+
token,
|
|
1181
|
+
host,
|
|
1182
|
+
port,
|
|
1183
|
+
url: `http://${shown}:${port}/${token === null ? '' : `?token=${token}`}`,
|
|
1184
|
+
close: () => new Promise((resolve) => {
|
|
1185
|
+
hub.stop();
|
|
1186
|
+
server.close(() => resolve());
|
|
1187
|
+
server.closeAllConnections();
|
|
1188
|
+
}),
|
|
1189
|
+
};
|
|
1190
|
+
}
|
|
1191
|
+
//# sourceMappingURL=server.js.map
|