@hoknie/aip 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/agents.js +2 -0
- package/dist/app/agents.js.map +1 -1
- package/dist/app/application.js +34 -2
- package/dist/app/application.js.map +1 -1
- package/dist/app/lifecycle.js +5 -1
- package/dist/app/lifecycle.js.map +1 -1
- package/dist/app/timings.js +1 -0
- package/dist/app/timings.js.map +1 -1
- package/dist/app/wiring.js +1 -0
- package/dist/app/wiring.js.map +1 -1
- package/dist/cli/main.js +0 -0
- package/dist/feature/agents/clients/agy/runtime.js +1 -0
- package/dist/feature/agents/clients/agy/runtime.js.map +1 -1
- package/dist/feature/agents/clients/claude/index.js +1 -0
- package/dist/feature/agents/clients/claude/index.js.map +1 -1
- package/dist/feature/agents/clients/claude/models.js +8 -0
- package/dist/feature/agents/clients/claude/models.js.map +1 -0
- package/dist/feature/agents/clients/claude/parser.js +8 -0
- package/dist/feature/agents/clients/claude/parser.js.map +1 -1
- package/dist/feature/agents/clients/claude/runtime.js +2 -0
- package/dist/feature/agents/clients/claude/runtime.js.map +1 -1
- package/dist/feature/agents/clients/opencode/index.js +1 -0
- package/dist/feature/agents/clients/opencode/index.js.map +1 -1
- package/dist/feature/agents/clients/opencode/models.js +38 -0
- package/dist/feature/agents/clients/opencode/models.js.map +1 -0
- package/dist/feature/agents/clients/opencode/runtime.js +2 -0
- package/dist/feature/agents/clients/opencode/runtime.js.map +1 -1
- package/dist/feature/agents/ports/command.js +2 -0
- package/dist/feature/agents/ports/command.js.map +1 -0
- package/dist/feature/agents/services/agents.js +42 -1
- package/dist/feature/agents/services/agents.js.map +1 -1
- package/dist/feature/agents/services/catalog.js +1 -1
- package/dist/feature/agents/services/catalog.js.map +1 -1
- package/dist/feature/agents/types/index.js +1 -0
- package/dist/feature/agents/types/index.js.map +1 -1
- package/dist/feature/agents/types/message.js +1 -0
- package/dist/feature/agents/types/message.js.map +1 -1
- package/dist/feature/agents/types/models.js +2 -0
- package/dist/feature/agents/types/models.js.map +1 -0
- package/dist/feature/agents/types/runtime.js.map +1 -1
- package/dist/feature/agents/types/worker-tools.js +2 -0
- package/dist/feature/agents/types/worker-tools.js.map +1 -1
- package/dist/feature/network/ports/changed.js +2 -0
- package/dist/feature/network/ports/changed.js.map +1 -0
- package/dist/feature/network/ports/index.js +2 -0
- package/dist/feature/network/ports/index.js.map +1 -0
- package/dist/feature/network/services/create.js +5 -0
- package/dist/feature/network/services/create.js.map +1 -0
- package/dist/feature/network/services/index.js +3 -0
- package/dist/feature/network/services/index.js.map +1 -0
- package/dist/feature/network/services/monitor.js +140 -0
- package/dist/feature/network/services/monitor.js.map +1 -0
- package/dist/feature/network/types/index.js +4 -0
- package/dist/feature/network/types/index.js.map +1 -0
- package/dist/feature/network/types/network.js +8 -0
- package/dist/feature/network/types/network.js.map +1 -0
- package/dist/feature/network/types/proxy.js +95 -0
- package/dist/feature/network/types/proxy.js.map +1 -0
- package/dist/feature/network/types/state.js +36 -0
- package/dist/feature/network/types/state.js.map +1 -0
- package/dist/feature/observers/repositories/observers.js +7 -1
- package/dist/feature/observers/repositories/observers.js.map +1 -1
- package/dist/feature/observers/services/observers.js +14 -4
- package/dist/feature/observers/services/observers.js.map +1 -1
- package/dist/feature/observers/services/settings-check.js +1 -7
- package/dist/feature/observers/services/settings-check.js.map +1 -1
- package/dist/feature/observers/types/plan-repairs.js +14 -7
- package/dist/feature/observers/types/plan-repairs.js.map +1 -1
- package/dist/feature/observers/types/settings.js +0 -1
- package/dist/feature/observers/types/settings.js.map +1 -1
- package/dist/feature/queue/services/control.js +23 -7
- package/dist/feature/queue/services/control.js.map +1 -1
- package/dist/feature/queue/types/advance.js +26 -11
- package/dist/feature/queue/types/advance.js.map +1 -1
- package/dist/feature/queue/types/returns.js +18 -3
- package/dist/feature/queue/types/returns.js.map +1 -1
- package/dist/feature/runs/machine/exits.js +23 -1
- package/dist/feature/runs/machine/exits.js.map +1 -1
- package/dist/feature/runs/machine/plan.js +38 -16
- package/dist/feature/runs/machine/plan.js.map +1 -1
- package/dist/feature/runs/machine/repair.js +5 -2
- package/dist/feature/runs/machine/repair.js.map +1 -1
- package/dist/feature/runs/machine/scheduler.js +10 -3
- package/dist/feature/runs/machine/scheduler.js.map +1 -1
- package/dist/feature/runs/machine/steps.js +7 -7
- package/dist/feature/runs/machine/steps.js.map +1 -1
- package/dist/feature/runs/machine/transition.js +5 -1
- package/dist/feature/runs/machine/transition.js.map +1 -1
- package/dist/feature/runs/repositories/finished-runs.js +14 -10
- package/dist/feature/runs/repositories/finished-runs.js.map +1 -1
- package/dist/feature/runs/services/create.js +1 -0
- package/dist/feature/runs/services/create.js.map +1 -1
- package/dist/feature/runs/services/effects/actions.js +3 -2
- package/dist/feature/runs/services/effects/actions.js.map +1 -1
- package/dist/feature/runs/services/effects/attempts.js +44 -4
- package/dist/feature/runs/services/effects/attempts.js.map +1 -1
- package/dist/feature/runs/services/effects/context.js.map +1 -1
- package/dist/feature/runs/services/effects/naming.js +4 -1
- package/dist/feature/runs/services/effects/naming.js.map +1 -1
- package/dist/feature/runs/services/effects/proxy.js +5 -0
- package/dist/feature/runs/services/effects/proxy.js.map +1 -0
- package/dist/feature/runs/services/engine.js +14 -5
- package/dist/feature/runs/services/engine.js.map +1 -1
- package/dist/feature/runs/services/index.js.map +1 -1
- package/dist/feature/runs/services/reads.js +40 -1
- package/dist/feature/runs/services/reads.js.map +1 -1
- package/dist/feature/runs/services/states.js +2 -2
- package/dist/feature/runs/services/states.js.map +1 -1
- package/dist/feature/runs/types/attempt.js +4 -0
- package/dist/feature/runs/types/attempt.js.map +1 -1
- package/dist/feature/runs/types/group.js.map +1 -1
- package/dist/feature/runs/types/input.js +33 -0
- package/dist/feature/runs/types/input.js.map +1 -1
- package/dist/feature/runs/types/limits.js +13 -1
- package/dist/feature/runs/types/limits.js.map +1 -1
- package/dist/feature/stats/repositories/index.js +4 -0
- package/dist/feature/stats/repositories/index.js.map +1 -0
- package/dist/feature/stats/repositories/meta.js +19 -0
- package/dist/feature/stats/repositories/meta.js.map +1 -0
- package/dist/feature/stats/repositories/records.js +46 -0
- package/dist/feature/stats/repositories/records.js.map +1 -0
- package/dist/feature/stats/repositories/report.js +105 -0
- package/dist/feature/stats/repositories/report.js.map +1 -0
- package/dist/feature/stats/services/create.js +44 -0
- package/dist/feature/stats/services/create.js.map +1 -0
- package/dist/feature/stats/services/index.js +4 -0
- package/dist/feature/stats/services/index.js.map +1 -0
- package/dist/feature/stats/services/ledger.js +137 -0
- package/dist/feature/stats/services/ledger.js.map +1 -0
- package/dist/feature/stats/services/report.js +56 -0
- package/dist/feature/stats/services/report.js.map +1 -0
- package/dist/feature/stats/types/aggregate.js +179 -0
- package/dist/feature/stats/types/aggregate.js.map +1 -0
- package/dist/feature/stats/types/capture.js +79 -0
- package/dist/feature/stats/types/capture.js.map +1 -0
- package/dist/feature/stats/types/index.js +6 -0
- package/dist/feature/stats/types/index.js.map +1 -0
- package/dist/feature/stats/types/records.js +5 -0
- package/dist/feature/stats/types/records.js.map +1 -0
- package/dist/feature/stats/types/report.js +25 -0
- package/dist/feature/stats/types/report.js.map +1 -0
- package/dist/feature/stats/types/settings.js +2 -0
- package/dist/feature/stats/types/settings.js.map +1 -0
- package/dist/feature/swarm-config/services/assemble.js +1 -1
- package/dist/feature/swarm-config/services/assemble.js.map +1 -1
- package/dist/feature/swarm-config/services/index.js +3 -2
- package/dist/feature/swarm-config/services/index.js.map +1 -1
- package/dist/feature/swarm-config/services/load.js +17 -2
- package/dist/feature/swarm-config/services/load.js.map +1 -1
- package/dist/feature/swarm-config/services/sections/stats.js +28 -0
- package/dist/feature/swarm-config/services/sections/stats.js.map +1 -0
- package/dist/feature/swarm-config/services/settings.js +23 -1
- package/dist/feature/swarm-config/services/settings.js.map +1 -1
- package/dist/feature/swarm-config/services/validate-actions.js +9 -1
- package/dist/feature/swarm-config/services/validate-actions.js.map +1 -1
- package/dist/feature/swarm-config/services/validate-runtimes.js +3 -1
- package/dist/feature/swarm-config/services/validate-runtimes.js.map +1 -1
- package/dist/feature/swarm-config/services/validate-settings.js +65 -0
- package/dist/feature/swarm-config/services/validate-settings.js.map +1 -1
- package/dist/feature/swarm-config/services/validate.js +17 -2
- package/dist/feature/swarm-config/services/validate.js.map +1 -1
- package/dist/feature/swarm-config/types/action.js +9 -0
- package/dist/feature/swarm-config/types/action.js.map +1 -1
- package/dist/feature/swarm-config/types/settings.js +35 -5
- package/dist/feature/swarm-config/types/settings.js.map +1 -1
- package/dist/feature/swarm-edit/services/config-edits.js +14 -1
- package/dist/feature/swarm-edit/services/config-edits.js.map +1 -1
- package/dist/feature/swarm-edit/services/editor-settings.js +36 -7
- package/dist/feature/swarm-edit/services/editor-settings.js.map +1 -1
- package/dist/feature/swarm-edit/services/plan-settings.js +3 -1
- package/dist/feature/swarm-edit/services/plan-settings.js.map +1 -1
- package/dist/feature/swarm-edit/types/editor.js.map +1 -1
- package/dist/feature/swarm-edit/types/setting-fields.js +12 -0
- package/dist/feature/swarm-edit/types/setting-fields.js.map +1 -1
- package/dist/platform/git/delivery.js +1 -1
- package/dist/platform/git/delivery.js.map +1 -1
- package/dist/platform/network/index.js +4 -0
- package/dist/platform/network/index.js.map +1 -0
- package/dist/platform/network/interfaces.js +7 -0
- package/dist/platform/network/interfaces.js.map +1 -0
- package/dist/platform/network/probe.js +128 -0
- package/dist/platform/network/probe.js.map +1 -0
- package/dist/platform/network/tunnel.js +87 -0
- package/dist/platform/network/tunnel.js.map +1 -0
- package/dist/platform/process/command.js +23 -0
- package/dist/platform/process/command.js.map +1 -0
- package/dist/platform/process/index.js +1 -0
- package/dist/platform/process/index.js.map +1 -1
- package/dist/platform/sqlite/migrations.js +2 -0
- package/dist/platform/sqlite/migrations.js.map +1 -1
- package/dist/platform/sqlite/stats-migration.js +42 -0
- package/dist/platform/sqlite/stats-migration.js.map +1 -0
- package/dist/presentation/cli/commands/stats.js +41 -0
- package/dist/presentation/cli/commands/stats.js.map +1 -0
- package/dist/presentation/cli/help.js +1 -1
- package/dist/presentation/cli/help.js.map +1 -1
- package/dist/presentation/cli/local/config-check.js +23 -5
- package/dist/presentation/cli/local/config-check.js.map +1 -1
- package/dist/presentation/cli/program.js +2 -0
- package/dist/presentation/cli/program.js.map +1 -1
- package/dist/presentation/format/index.js +1 -0
- package/dist/presentation/format/index.js.map +1 -1
- package/dist/presentation/format/queue.js +1 -1
- package/dist/presentation/format/queue.js.map +1 -1
- package/dist/presentation/format/runs.js +8 -1
- package/dist/presentation/format/runs.js.map +1 -1
- package/dist/presentation/format/stats.js +79 -0
- package/dist/presentation/format/stats.js.map +1 -0
- package/dist/presentation/ipc/contract/agents.js +18 -0
- package/dist/presentation/ipc/contract/agents.js.map +1 -1
- package/dist/presentation/ipc/contract/config.js +4 -0
- package/dist/presentation/ipc/contract/config.js.map +1 -1
- package/dist/presentation/ipc/contract/envelope.js +4 -1
- package/dist/presentation/ipc/contract/envelope.js.map +1 -1
- package/dist/presentation/ipc/contract/groups.js +9 -0
- package/dist/presentation/ipc/contract/groups.js.map +1 -1
- package/dist/presentation/ipc/contract/index.js +1 -0
- package/dist/presentation/ipc/contract/index.js.map +1 -1
- package/dist/presentation/ipc/contract/panel.js +11 -0
- package/dist/presentation/ipc/contract/panel.js.map +1 -1
- package/dist/presentation/ipc/contract/responses/index.js +1 -0
- package/dist/presentation/ipc/contract/responses/index.js.map +1 -1
- package/dist/presentation/ipc/contract/responses/stats.js +67 -0
- package/dist/presentation/ipc/contract/responses/stats.js.map +1 -0
- package/dist/presentation/ipc/contract/runs.js +6 -0
- package/dist/presentation/ipc/contract/runs.js.map +1 -1
- package/dist/presentation/ipc/contract/stats/stats.js +20 -0
- package/dist/presentation/ipc/contract/stats/stats.js.map +1 -0
- package/dist/presentation/ipc/handlers/config.js +1 -0
- package/dist/presentation/ipc/handlers/config.js.map +1 -1
- package/dist/presentation/ipc/handlers/groups.js +8 -0
- package/dist/presentation/ipc/handlers/groups.js.map +1 -1
- package/dist/presentation/ipc/handlers/runs.js +1 -1
- package/dist/presentation/ipc/handlers/runs.js.map +1 -1
- package/dist/presentation/ipc/handlers/stats.js +17 -0
- package/dist/presentation/ipc/handlers/stats.js.map +1 -0
- package/dist/presentation/ipc/handlers/system.js +2 -0
- package/dist/presentation/ipc/handlers/system.js.map +1 -1
- package/dist/presentation/ipc/handlers/table.js +2 -0
- package/dist/presentation/ipc/handlers/table.js.map +1 -1
- package/dist/presentation/ipc/publisher.js +1 -0
- package/dist/presentation/ipc/publisher.js.map +1 -1
- package/dist/presentation/ipc/views/catalog.js +3 -3
- package/dist/presentation/ipc/views/catalog.js.map +1 -1
- package/dist/presentation/ipc/views/index.js +1 -0
- package/dist/presentation/ipc/views/index.js.map +1 -1
- package/dist/presentation/ipc/views/queue.js +5 -1
- package/dist/presentation/ipc/views/queue.js.map +1 -1
- package/dist/presentation/ipc/views/runs.js +1 -1
- package/dist/presentation/ipc/views/runs.js.map +1 -1
- package/dist/presentation/ipc/views/stats.js +5 -0
- package/dist/presentation/ipc/views/stats.js.map +1 -0
- package/dist/presentation/mcp/worker-extra.js +2 -2
- package/dist/presentation/mcp/worker-extra.js.map +1 -1
- package/dist/presentation/mcp/worker-read.js +45 -0
- package/dist/presentation/mcp/worker-read.js.map +1 -0
- package/dist/presentation/mcp/worker.js +2 -0
- package/dist/presentation/mcp/worker.js.map +1 -1
- package/dist/presentation/web/hub.js +4 -0
- package/dist/presentation/web/hub.js.map +1 -1
- package/dist/presentation/web/panel/directories.js +1 -1
- package/dist/presentation/web/panel/directories.js.map +1 -1
- package/dist/presentation/web/panel/system.js +1 -0
- package/dist/presentation/web/panel/system.js.map +1 -1
- package/dist/presentation/web/request.js +28 -1
- package/dist/presentation/web/request.js.map +1 -1
- package/dist/presentation/web/routes/config.js +5 -0
- package/dist/presentation/web/routes/config.js.map +1 -1
- package/dist/presentation/web/routes/runs.js.map +1 -1
- package/dist/presentation/web/routes/stats/stats.js +22 -0
- package/dist/presentation/web/routes/stats/stats.js.map +1 -0
- package/dist/presentation/web/server.js +3 -1
- package/dist/presentation/web/server.js.map +1 -1
- package/dist/web/assets/FilterColumn-BCMp-JO4.js +1 -0
- package/dist/web/assets/SharedPipelinesGroup-DJRGFtzx.js +1 -0
- package/dist/web/assets/badge-C_7kALlW.js +1 -0
- package/dist/web/assets/{card-DkikoTxR.js → card-C9eXOVuF.js} +1 -1
- package/dist/web/assets/empty-ACC2KkXk.js +41 -0
- package/dist/web/assets/index-CsVQUXJH.js +21 -0
- package/dist/web/assets/index-Ds1nt_qm.css +2 -0
- package/dist/web/assets/locales-fB1w2oER.js +1 -0
- package/dist/web/assets/pipelines-DQglwIkL.js +10 -0
- package/dist/web/assets/queue-CAuAo--6.js +16 -0
- package/dist/web/assets/select-BSqaxwh1.js +1 -0
- package/dist/web/assets/settingFields-DVg9TQK2.js +1 -0
- package/dist/web/assets/settings-6eHKYbS7.js +2 -0
- package/dist/web/assets/skeleton-CfLYGtNX.js +1 -0
- package/dist/web/assets/specialists-Durm0DgK.js +1 -0
- package/dist/web/assets/stats-67akPa3A.js +1 -0
- package/dist/web/assets/topology-DQu3su19.js +1 -0
- package/dist/web/assets/trash-ChYI9ms1.js +1 -0
- package/dist/web/assets/useListDrag-0GPS1X83.js +1 -0
- package/dist/web/index.html +7 -6
- package/integrations/claude-code/.claude-plugin/plugin.json +1 -1
- package/package.json +1 -1
- package/dist/cli/clean.js +0 -71
- package/dist/cli/clean.js.map +0 -1
- package/dist/cli/commands.js +0 -963
- package/dist/cli/commands.js.map +0 -1
- package/dist/cli/config-check.js +0 -173
- package/dist/cli/config-check.js.map +0 -1
- package/dist/cli/daemon.js +0 -199
- package/dist/cli/daemon.js.map +0 -1
- package/dist/cli/help.js +0 -50
- package/dist/cli/help.js.map +0 -1
- package/dist/cli/init.js +0 -43
- package/dist/cli/init.js.map +0 -1
- package/dist/cli/io.js +0 -13
- package/dist/cli/io.js.map +0 -1
- package/dist/cli/probe.js +0 -12
- package/dist/cli/probe.js.map +0 -1
- package/dist/cli/program.js +0 -48
- package/dist/cli/program.js.map +0 -1
- package/dist/cli/setup.js +0 -406
- package/dist/cli/setup.js.map +0 -1
- package/dist/cli/version.js +0 -6
- package/dist/cli/version.js.map +0 -1
- package/dist/cli/watch.js +0 -24
- package/dist/cli/watch.js.map +0 -1
- package/dist/cli/web/daemon-panel.js +0 -185
- package/dist/cli/web/daemon-panel.js.map +0 -1
- package/dist/cli/web/default-repository.js +0 -12
- package/dist/cli/web/default-repository.js.map +0 -1
- package/dist/cli/web/errors.js +0 -60
- package/dist/cli/web/errors.js.map +0 -1
- package/dist/cli/web/open.js +0 -12
- package/dist/cli/web/open.js.map +0 -1
- package/dist/cli/web/page.js +0 -465
- package/dist/cli/web/page.js.map +0 -1
- package/dist/cli/web/server.js +0 -1191
- package/dist/cli/web/server.js.map +0 -1
- package/dist/cli/web/standby.js +0 -119
- package/dist/cli/web/standby.js.map +0 -1
- package/dist/cli/web/state.js +0 -69
- package/dist/cli/web/state.js.map +0 -1
- package/dist/cli/web/system.js +0 -66
- package/dist/cli/web/system.js.map +0 -1
- package/dist/cli/web-control.js +0 -173
- package/dist/cli/web-control.js.map +0 -1
- package/dist/config/discover.js +0 -25
- package/dist/config/discover.js.map +0 -1
- package/dist/config/duration.js +0 -17
- package/dist/config/duration.js.map +0 -1
- package/dist/config/edit.js +0 -966
- package/dist/config/edit.js.map +0 -1
- package/dist/config/errors.js +0 -29
- package/dist/config/errors.js.map +0 -1
- package/dist/config/index.js +0 -14
- package/dist/config/index.js.map +0 -1
- package/dist/config/load.js +0 -412
- package/dist/config/load.js.map +0 -1
- package/dist/config/merge.js +0 -45
- package/dist/config/merge.js.map +0 -1
- package/dist/config/model.js +0 -171
- package/dist/config/model.js.map +0 -1
- package/dist/config/paths.js +0 -31
- package/dist/config/paths.js.map +0 -1
- package/dist/config/prompt.js +0 -33
- package/dist/config/prompt.js.map +0 -1
- package/dist/config/shared-pipelines.js +0 -71
- package/dist/config/shared-pipelines.js.map +0 -1
- package/dist/config/shared-specialists.js +0 -68
- package/dist/config/shared-specialists.js.map +0 -1
- package/dist/config/shared-workflows.js +0 -71
- package/dist/config/shared-workflows.js.map +0 -1
- package/dist/config/specialist-tags.js +0 -214
- package/dist/config/specialist-tags.js.map +0 -1
- package/dist/config/tag-names.js +0 -43
- package/dist/config/tag-names.js.map +0 -1
- package/dist/config/validate.js +0 -872
- package/dist/config/validate.js.map +0 -1
- package/dist/core/artifacts.js +0 -37
- package/dist/core/artifacts.js.map +0 -1
- package/dist/core/create.js +0 -75
- package/dist/core/create.js.map +0 -1
- package/dist/core/delivery.js +0 -366
- package/dist/core/delivery.js.map +0 -1
- package/dist/core/errors.js +0 -7
- package/dist/core/errors.js.map +0 -1
- package/dist/core/ids.js +0 -99
- package/dist/core/ids.js.map +0 -1
- package/dist/core/index.js +0 -21
- package/dist/core/index.js.map +0 -1
- package/dist/core/input.js +0 -45
- package/dist/core/input.js.map +0 -1
- package/dist/core/machine.js +0 -1021
- package/dist/core/machine.js.map +0 -1
- package/dist/core/model.js +0 -460
- package/dist/core/model.js.map +0 -1
- package/dist/core/observer.js +0 -193
- package/dist/core/observer.js.map +0 -1
- package/dist/core/occupancy.js +0 -63
- package/dist/core/occupancy.js.map +0 -1
- package/dist/core/permissions.js +0 -222
- package/dist/core/permissions.js.map +0 -1
- package/dist/core/plan.js +0 -99
- package/dist/core/plan.js.map +0 -1
- package/dist/core/progress.js +0 -43
- package/dist/core/progress.js.map +0 -1
- package/dist/core/questions.js +0 -19
- package/dist/core/questions.js.map +0 -1
- package/dist/core/queue.js +0 -859
- package/dist/core/queue.js.map +0 -1
- package/dist/core/retryable.js +0 -8
- package/dist/core/retryable.js.map +0 -1
- package/dist/core/scheduler.js +0 -160
- package/dist/core/scheduler.js.map +0 -1
- package/dist/core/skip.js +0 -109
- package/dist/core/skip.js.map +0 -1
- package/dist/core/stages.js +0 -304
- package/dist/core/stages.js.map +0 -1
- package/dist/core/summary.js +0 -35
- package/dist/core/summary.js.map +0 -1
- package/dist/core/tags.js +0 -184
- package/dist/core/tags.js.map +0 -1
- package/dist/core/topology.js +0 -162
- package/dist/core/topology.js.map +0 -1
- package/dist/daemon/artifacts.js +0 -84
- package/dist/daemon/artifacts.js.map +0 -1
- package/dist/daemon/daemon.js +0 -1442
- package/dist/daemon/daemon.js.map +0 -1
- package/dist/daemon/executor.js +0 -749
- package/dist/daemon/executor.js.map +0 -1
- package/dist/daemon/helpers.js +0 -38
- package/dist/daemon/helpers.js.map +0 -1
- package/dist/daemon/index.js +0 -4
- package/dist/daemon/index.js.map +0 -1
- package/dist/daemon/logs.js +0 -69
- package/dist/daemon/logs.js.map +0 -1
- package/dist/daemon/observers.js +0 -93
- package/dist/daemon/observers.js.map +0 -1
- package/dist/daemon/patches.js +0 -76
- package/dist/daemon/patches.js.map +0 -1
- package/dist/daemon/ports.js +0 -2
- package/dist/daemon/ports.js.map +0 -1
- package/dist/daemon/processes.js +0 -98
- package/dist/daemon/processes.js.map +0 -1
- package/dist/daemon/repositories.js +0 -2
- package/dist/daemon/repositories.js.map +0 -1
- package/dist/daemon/server.js +0 -164
- package/dist/daemon/server.js.map +0 -1
- package/dist/daemon/supervisor.js +0 -140
- package/dist/daemon/supervisor.js.map +0 -1
- package/dist/daemon/timings.js +0 -23
- package/dist/daemon/timings.js.map +0 -1
- package/dist/git/delivery.js +0 -284
- package/dist/git/delivery.js.map +0 -1
- package/dist/git/index.js +0 -4
- package/dist/git/index.js.map +0 -1
- package/dist/git/runner.js +0 -60
- package/dist/git/runner.js.map +0 -1
- package/dist/git/workspace.js +0 -366
- package/dist/git/workspace.js.map +0 -1
- package/dist/mcp/host.js +0 -401
- package/dist/mcp/host.js.map +0 -1
- package/dist/mcp/index.js +0 -3
- package/dist/mcp/index.js.map +0 -1
- package/dist/mcp/tools.js +0 -19
- package/dist/mcp/tools.js.map +0 -1
- package/dist/mcp/version.js +0 -5
- package/dist/mcp/version.js.map +0 -1
- package/dist/mcp/worker.js +0 -230
- package/dist/mcp/worker.js.map +0 -1
- package/dist/presentation/web/routes/directories.js +0 -60
- package/dist/presentation/web/routes/directories.js.map +0 -1
- package/dist/protocol/autostart.js +0 -171
- package/dist/protocol/autostart.js.map +0 -1
- package/dist/protocol/build.js +0 -38
- package/dist/protocol/build.js.map +0 -1
- package/dist/protocol/catalog.js +0 -18
- package/dist/protocol/catalog.js.map +0 -1
- package/dist/protocol/client.js +0 -83
- package/dist/protocol/client.js.map +0 -1
- package/dist/protocol/format.js +0 -477
- package/dist/protocol/format.js.map +0 -1
- package/dist/protocol/index.js +0 -11
- package/dist/protocol/index.js.map +0 -1
- package/dist/protocol/messages.js +0 -598
- package/dist/protocol/messages.js.map +0 -1
- package/dist/protocol/style.js +0 -81
- package/dist/protocol/style.js.map +0 -1
- package/dist/protocol/transcript.js +0 -49
- package/dist/protocol/transcript.js.map +0 -1
- package/dist/protocol/views.js +0 -696
- package/dist/protocol/views.js.map +0 -1
- package/dist/runtime/catalog.js +0 -117
- package/dist/runtime/catalog.js.map +0 -1
- package/dist/runtime/claude.js +0 -399
- package/dist/runtime/claude.js.map +0 -1
- package/dist/runtime/index.js +0 -34
- package/dist/runtime/index.js.map +0 -1
- package/dist/runtime/message.js +0 -48
- package/dist/runtime/message.js.map +0 -1
- package/dist/runtime/naming.js +0 -69
- package/dist/runtime/naming.js.map +0 -1
- package/dist/runtime/opencode.js +0 -189
- package/dist/runtime/opencode.js.map +0 -1
- package/dist/runtime/skills.js +0 -17
- package/dist/runtime/skills.js.map +0 -1
- package/dist/runtime/transcript.js +0 -227
- package/dist/runtime/transcript.js.map +0 -1
- package/dist/runtime/types.js +0 -12
- package/dist/runtime/types.js.map +0 -1
- package/dist/runtime/which.js +0 -21
- package/dist/runtime/which.js.map +0 -1
- package/dist/store/index.js +0 -3
- package/dist/store/index.js.map +0 -1
- package/dist/store/schema.js +0 -286
- package/dist/store/schema.js.map +0 -1
- package/dist/store/store.js +0 -491
- package/dist/store/store.js.map +0 -1
- package/dist/web/assets/EntryList-CnfGgjEY.js +0 -1
- package/dist/web/assets/FilePath-C0X8-keS.js +0 -1
- package/dist/web/assets/SettingsForm-BcyBWJbn.js +0 -1
- package/dist/web/assets/SharedPipelinesGroup-a368-IQ0.js +0 -1
- package/dist/web/assets/index-B-oJ93zH.js +0 -22
- package/dist/web/assets/index-BZE36gYR.css +0 -2
- package/dist/web/assets/locales-DtRrxYzg.js +0 -1
- package/dist/web/assets/pipelines-D48ggDNe.js +0 -1
- package/dist/web/assets/queue-D8_RY4IY.js +0 -16
- package/dist/web/assets/select-J4oIrmYh.js +0 -1
- package/dist/web/assets/settings-B0-0Vaia.js +0 -2
- package/dist/web/assets/skeleton-CCKCQF5n.js +0 -1
- package/dist/web/assets/specialists-DH8tyluO.js +0 -1
- package/dist/web/assets/switch-CWFAgxG1.js +0 -41
- package/dist/web/assets/topology-CNQ28AB2.js +0 -7
- /package/dist/web/assets/{topology-DLioOiRN.css → pipelines-DLioOiRN.css} +0 -0
package/dist/cli/web/server.js
DELETED
|
@@ -1,1191 +0,0 @@
|
|
|
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
|