@hoknie/aip 0.1.0 → 0.2.1
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 +41 -3
- 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/guard.js +26 -8
- package/dist/feature/agents/clients/agy/guard.js.map +1 -1
- package/dist/feature/agents/clients/agy/permissions.js +9 -1
- package/dist/feature/agents/clients/agy/permissions.js.map +1 -1
- package/dist/feature/agents/clients/agy/runtime.js +8 -1
- 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 +14 -1
- 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 +2 -0
- package/dist/feature/agents/types/index.js.map +1 -1
- package/dist/feature/agents/types/mcp/env.js +54 -0
- package/dist/feature/agents/types/mcp/env.js.map +1 -0
- 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 +33 -5
- 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 +48 -16
- 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/repositories/queues.js +28 -4
- package/dist/feature/queue/repositories/queues.js.map +1 -1
- package/dist/feature/queue/services/control.js +46 -8
- package/dist/feature/queue/services/control.js.map +1 -1
- package/dist/feature/queue/services/store.js +4 -0
- package/dist/feature/queue/services/store.js.map +1 -1
- package/dist/feature/queue/services/task-tags.js +4 -1
- package/dist/feature/queue/services/task-tags.js.map +1 -1
- package/dist/feature/queue/types/advance.js +29 -12
- package/dist/feature/queue/types/advance.js.map +1 -1
- package/dist/feature/queue/types/filter.js +36 -0
- package/dist/feature/queue/types/filter.js.map +1 -0
- package/dist/feature/queue/types/index.js +1 -0
- package/dist/feature/queue/types/index.js.map +1 -1
- package/dist/feature/queue/types/items.js +1 -0
- package/dist/feature/queue/types/items.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/queue/types/settings.js +14 -3
- package/dist/feature/queue/types/settings.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 +10 -3
- 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 +11 -11
- package/dist/feature/runs/machine/steps.js.map +1 -1
- package/dist/feature/runs/machine/transition.js +16 -2
- 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/repositories/write.js +1 -1
- package/dist/feature/runs/repositories/write.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 +61 -13
- 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/effects.js +5 -0
- package/dist/feature/runs/services/effects/effects.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/effects/runtime-check.js +20 -0
- package/dist/feature/runs/services/effects/runtime-check.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/requests.js +7 -1
- package/dist/feature/runs/services/requests.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 +8 -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 +4 -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/mcp-servers.js +128 -0
- package/dist/feature/swarm-config/services/sections/mcp-servers.js.map +1 -0
- 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 -51
- 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-specialists.js +5 -4
- package/dist/feature/swarm-config/services/validate-specialists.js.map +1 -1
- package/dist/feature/swarm-config/services/validate.js +24 -8
- 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/index.js +1 -0
- package/dist/feature/swarm-config/types/index.js.map +1 -1
- package/dist/feature/swarm-config/types/mcp/reference.js +40 -0
- package/dist/feature/swarm-config/types/mcp/reference.js.map +1 -0
- package/dist/feature/swarm-config/types/merge.js +1 -0
- package/dist/feature/swarm-config/types/merge.js.map +1 -1
- package/dist/feature/swarm-config/types/settings.js +37 -5
- package/dist/feature/swarm-config/types/settings.js.map +1 -1
- package/dist/feature/swarm-config/types/specialist.js.map +1 -1
- package/dist/feature/swarm-edit/services/config-edits.js +26 -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/editor-view.js +2 -0
- package/dist/feature/swarm-edit/services/editor-view.js.map +1 -1
- package/dist/feature/swarm-edit/services/index.js +1 -0
- package/dist/feature/swarm-edit/services/index.js.map +1 -1
- package/dist/feature/swarm-edit/services/mcp/editor-mcp.js +51 -0
- package/dist/feature/swarm-edit/services/mcp/editor-mcp.js.map +1 -0
- package/dist/feature/swarm-edit/services/mcp/plan-mcp-server.js +93 -0
- package/dist/feature/swarm-edit/services/mcp/plan-mcp-server.js.map +1 -0
- 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 +3 -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/queue-edit.js +23 -1
- package/dist/presentation/cli/commands/queue-edit.js.map +1 -1
- 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 +15 -2
- 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 +26 -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/queue.js +11 -1
- package/dist/presentation/ipc/contract/queue.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 +10 -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 +7 -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 +2 -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/snapshots.js +2 -2
- package/dist/presentation/ipc/snapshots.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/observers.js +2 -2
- package/dist/presentation/ipc/views/observers.js.map +1 -1
- package/dist/presentation/ipc/views/queue.js +9 -2
- package/dist/presentation/ipc/views/queue.js.map +1 -1
- package/dist/presentation/ipc/views/runs.js +3 -4
- 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/host-queue-control.js +11 -2
- package/dist/presentation/mcp/host-queue-control.js.map +1 -1
- 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/catalog/mcp-servers.js +50 -0
- package/dist/presentation/web/routes/catalog/mcp-servers.js.map +1 -0
- 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 +5 -0
- 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 +5 -1
- package/dist/presentation/web/server.js.map +1 -1
- package/dist/web/assets/FilterColumn-BrQWIM5F.js +1 -0
- package/dist/web/assets/SharedPipelinesGroup-WFngQrqI.js +1 -0
- package/dist/web/assets/badge-B_khFsd6.js +1 -0
- package/dist/web/assets/{card-DkikoTxR.js → card-COXjnc-y.js} +1 -1
- package/dist/web/assets/empty-Eb-EZDPX.js +41 -0
- package/dist/web/assets/index-DEXoIe2a.js +21 -0
- package/dist/web/assets/index-DMlIe0VD.css +2 -0
- package/dist/web/assets/locales-BlBJo1PR.js +1 -0
- package/dist/web/assets/pipelines-B3cdeex_.js +10 -0
- package/dist/web/assets/queue-HMUImu0E.js +16 -0
- package/dist/web/assets/select-MHus_Unr.js +1 -0
- package/dist/web/assets/settingFields-DVg9TQK2.js +1 -0
- package/dist/web/assets/settings-CpeEsUXX.js +6 -0
- package/dist/web/assets/skeleton-CWY1nRvW.js +1 -0
- package/dist/web/assets/specialists-BkLXuqUd.js +1 -0
- package/dist/web/assets/stats-DRg_5vll.js +1 -0
- package/dist/web/assets/topology-DGTNdDHf.js +1 -0
- package/dist/web/assets/trash-CFJeuRuc.js +1 -0
- package/dist/web/assets/useListDrag-B7Wlt2u9.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/config/edit.js
DELETED
|
@@ -1,966 +0,0 @@
|
|
|
1
|
-
import { createHash } from 'node:crypto';
|
|
2
|
-
import { existsSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync, } from 'node:fs';
|
|
3
|
-
import { basename, dirname, join, relative, resolve } from 'node:path';
|
|
4
|
-
import { Document, Scalar, isMap, isScalar, parseDocument, visit } from 'yaml';
|
|
5
|
-
import { ACTIONS_DIR, SETTINGS_NAME, SPECIALISTS_DIR, PIPELINES_DIR, LEGACY_PIPELINES_DIR, } from './discover.js';
|
|
6
|
-
import { formatDuration, parseDuration } from './duration.js';
|
|
7
|
-
import { ConfigLoadError } from './errors.js';
|
|
8
|
-
import { assembleLevel, mergeOrigins, levelIsEmpty, parseYaml, canonicalPipeline, readLevel, resolveLevels, loadRuntimeSettings, loadWebSettings, } from './load.js';
|
|
9
|
-
import { isMapping, mergeConfigs } from './merge.js';
|
|
10
|
-
import { CLAUDE_EDIT_MODES, CLAUDE_MCP_MODES, CLAUDE_SETTINGS_SOURCES, DELIVERY_MODES, MAX_RANGE, MAX_ROUNDS_RANGE, OUTSIDE_CHANGES, PERMISSIONS, RUNTIMES, WEB_AUTH_MODES, WEB_HOSTS, WORKSPACE_BASES, SLUG_PATTERN_TEXT, isValidSlug, defaultRuntimes, defaultWeb, } from './model.js';
|
|
11
|
-
import { tagsOf } from './tag-names.js';
|
|
12
|
-
import { validateConfig, validateRuntimesSection, validateWebSection } from './validate.js';
|
|
13
|
-
const KIND_DIRECTORY = {
|
|
14
|
-
specialist: SPECIALISTS_DIR,
|
|
15
|
-
pipeline: PIPELINES_DIR,
|
|
16
|
-
action: ACTIONS_DIR,
|
|
17
|
-
};
|
|
18
|
-
/** Key of the section of the configuration tree (`swarm.<section>.<id>`) that holds the kind. */
|
|
19
|
-
const KIND_SECTION = {
|
|
20
|
-
specialist: 'specialists',
|
|
21
|
-
pipeline: 'pipelines',
|
|
22
|
-
action: 'actions',
|
|
23
|
-
};
|
|
24
|
-
/** Thrown for a request that is wrong by itself, before any file is looked at. */
|
|
25
|
-
export class ConfigEditError extends Error {
|
|
26
|
-
}
|
|
27
|
-
/** sha256 of the content of a file; null for a file that does not exist. */
|
|
28
|
-
export function revisionOf(text) {
|
|
29
|
-
return text === undefined ? null : createHash('sha256').update(text).digest('hex');
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* The file of an entry on a level: `specialists/<id>.yaml` (`pipelines/<id>.yaml`) in the directory of the level, or the
|
|
33
|
-
* `.yml` file when that one exists. The id must be a slug, so the path cannot leave the directory of the kind.
|
|
34
|
-
*/
|
|
35
|
-
export function entryFile(paths, kind, id, level = 'project') {
|
|
36
|
-
if (!isValidSlug(id))
|
|
37
|
-
throw new ConfigEditError(`id must match ${SLUG_PATTERN_TEXT}`);
|
|
38
|
-
let directory = resolve(paths[level].directory, KIND_DIRECTORY[kind]);
|
|
39
|
-
const yaml = join(directory, `${id}.yaml`);
|
|
40
|
-
const yml = join(directory, `${id}.yml`);
|
|
41
|
-
let file = !existsSync(yaml) && existsSync(yml) ? yml : yaml;
|
|
42
|
-
if (kind === 'pipeline' && !existsSync(yaml) && !existsSync(yml)) {
|
|
43
|
-
const legacyDirectory = resolve(paths[level].directory, LEGACY_PIPELINES_DIR);
|
|
44
|
-
const legacyYaml = join(legacyDirectory, `${id}.yaml`);
|
|
45
|
-
const legacyYml = join(legacyDirectory, `${id}.yml`);
|
|
46
|
-
if (existsSync(legacyYaml) || existsSync(legacyYml)) {
|
|
47
|
-
directory = legacyDirectory;
|
|
48
|
-
file = existsSync(legacyYaml) ? legacyYaml : legacyYml;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
const inside = relative(directory, resolve(file));
|
|
52
|
-
if (inside.startsWith('..') || inside !== basename(file)) {
|
|
53
|
-
throw new ConfigEditError('the file must be inside the directory of its kind');
|
|
54
|
-
}
|
|
55
|
-
return file;
|
|
56
|
-
}
|
|
57
|
-
/** Deep equality of parsed YAML values; the order of keys of a mapping does not matter. */
|
|
58
|
-
function sameValue(left, right) {
|
|
59
|
-
if (Array.isArray(left) || Array.isArray(right)) {
|
|
60
|
-
return (Array.isArray(left) &&
|
|
61
|
-
Array.isArray(right) &&
|
|
62
|
-
left.length === right.length &&
|
|
63
|
-
left.every((item, index) => sameValue(item, right[index])));
|
|
64
|
-
}
|
|
65
|
-
if (isMapping(left) && isMapping(right)) {
|
|
66
|
-
const keys = Object.keys(left);
|
|
67
|
-
return (keys.length === Object.keys(right).length &&
|
|
68
|
-
keys.every((key) => key in right && sameValue(left[key], right[key])));
|
|
69
|
-
}
|
|
70
|
-
return left === right;
|
|
71
|
-
}
|
|
72
|
-
function literalMultiline(node) {
|
|
73
|
-
visit(node, {
|
|
74
|
-
Scalar(_, scalar) {
|
|
75
|
-
if (typeof scalar.value === 'string' && scalar.value.includes('\n')) {
|
|
76
|
-
scalar.type = Scalar.BLOCK_LITERAL;
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Text of a file with `value` as its content. Only the changed keys are touched, so comments, key
|
|
83
|
-
* order and the formatting of the other keys survive; keys missing from `value` are removed.
|
|
84
|
-
*/
|
|
85
|
-
export function editDocument(text, value) {
|
|
86
|
-
if (text === undefined || text.trim() === '') {
|
|
87
|
-
const fresh = new Document(value);
|
|
88
|
-
literalMultiline(fresh);
|
|
89
|
-
const body = fresh.toString({ lineWidth: 0 });
|
|
90
|
-
return Object.keys(value).length === 0 ? '{}\n' : `${text ?? ''}${body}`;
|
|
91
|
-
}
|
|
92
|
-
const document = parseDocument(text, { merge: true, uniqueKeys: true });
|
|
93
|
-
if (document.errors.length > 0) {
|
|
94
|
-
throw new ConfigEditError(`the file has a syntax error: ${document.errors[0]?.message ?? ''}`);
|
|
95
|
-
}
|
|
96
|
-
if (!isMap(document.contents))
|
|
97
|
-
document.contents = document.createNode({});
|
|
98
|
-
const current = (document.toJS({ maxAliasCount: 100 }) ?? {});
|
|
99
|
-
const map = document.contents;
|
|
100
|
-
if (!isMap(map))
|
|
101
|
-
throw new ConfigEditError('the file must contain a mapping');
|
|
102
|
-
for (const key of Object.keys(current)) {
|
|
103
|
-
if (!(key in value) && document.has(key))
|
|
104
|
-
document.delete(key);
|
|
105
|
-
}
|
|
106
|
-
for (const [key, next] of Object.entries(value)) {
|
|
107
|
-
const oldSplit = key === 'split' && isMapping(current[key]) && 'workflow' in current[key];
|
|
108
|
-
if (!oldSplit && sameValue(current[key], next))
|
|
109
|
-
continue;
|
|
110
|
-
const existing = document.get(key, true);
|
|
111
|
-
if (isScalar(existing) && (typeof next === 'string' || typeof next === 'number')) {
|
|
112
|
-
existing.value = next;
|
|
113
|
-
existing.type =
|
|
114
|
-
typeof next === 'string' && next.includes('\n') ? Scalar.BLOCK_LITERAL : undefined;
|
|
115
|
-
continue;
|
|
116
|
-
}
|
|
117
|
-
const node = document.createNode(next);
|
|
118
|
-
literalMultiline(node);
|
|
119
|
-
document.set(key, node);
|
|
120
|
-
}
|
|
121
|
-
return document.toString({ lineWidth: 0 });
|
|
122
|
-
}
|
|
123
|
-
/** Everything in a merged `{ swarm }` tree that names the specialist. */
|
|
124
|
-
export function specialistReferences(tree, slug) {
|
|
125
|
-
const swarm = isMapping(tree) && isMapping(tree.swarm) ? tree.swarm : {};
|
|
126
|
-
const references = [];
|
|
127
|
-
const pipelines = isMapping(swarm.pipelines) ? swarm.pipelines : {};
|
|
128
|
-
for (const [id, pipeline] of Object.entries(pipelines)) {
|
|
129
|
-
if (!isMapping(pipeline))
|
|
130
|
-
continue;
|
|
131
|
-
if (isMapping(pipeline.split) && pipeline.split.specialist === slug) {
|
|
132
|
-
references.push({ pipeline: id, split: true });
|
|
133
|
-
}
|
|
134
|
-
const steps = Array.isArray(pipeline.steps) ? pipeline.steps : [];
|
|
135
|
-
for (const [index, step] of steps.entries()) {
|
|
136
|
-
if (isMapping(step) && step.specialist === slug) {
|
|
137
|
-
references.push({
|
|
138
|
-
pipeline: id,
|
|
139
|
-
step: typeof step.id === 'string' ? step.id : String(index),
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
const actions = isMapping(swarm.actions) ? swarm.actions : {};
|
|
145
|
-
for (const [id, action] of Object.entries(actions)) {
|
|
146
|
-
if (isMapping(action) && action.specialist === slug)
|
|
147
|
-
references.push({ action: id });
|
|
148
|
-
}
|
|
149
|
-
const delivery = isMapping(swarm.delivery) ? swarm.delivery : {};
|
|
150
|
-
for (const field of ['resolver', 'message_specialist']) {
|
|
151
|
-
if (delivery[field] === slug)
|
|
152
|
-
references.push({ field: `delivery.${field}` });
|
|
153
|
-
}
|
|
154
|
-
return references;
|
|
155
|
-
}
|
|
156
|
-
/** Everything in a merged `{ swarm }` tree that delegates to the pipeline through `split.pipeline`. */
|
|
157
|
-
export function pipelineReferences(tree, id) {
|
|
158
|
-
const swarm = isMapping(tree) && isMapping(tree.swarm) ? tree.swarm : {};
|
|
159
|
-
const pipelines = isMapping(swarm.pipelines) ? swarm.pipelines : {};
|
|
160
|
-
const references = [];
|
|
161
|
-
for (const [name, pipeline] of Object.entries(pipelines)) {
|
|
162
|
-
if (isMapping(pipeline) && isMapping(pipeline.split) && pipeline.split.pipeline === id) {
|
|
163
|
-
references.push({ pipeline: name, split: true });
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return references;
|
|
167
|
-
}
|
|
168
|
-
/** Everything in a merged `{ swarm }` tree that names the action in a pipeline point. */
|
|
169
|
-
export function actionReferences(tree, id) {
|
|
170
|
-
const swarm = isMapping(tree) && isMapping(tree.swarm) ? tree.swarm : {};
|
|
171
|
-
const references = [];
|
|
172
|
-
const scan = (stages, owner) => {
|
|
173
|
-
if (!isMapping(stages))
|
|
174
|
-
return;
|
|
175
|
-
for (const [point, ids] of Object.entries(stages)) {
|
|
176
|
-
if (Array.isArray(ids) && ids.includes(id))
|
|
177
|
-
references.push({ ...owner, point });
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
scan(swarm.stages, {});
|
|
181
|
-
const pipelines = isMapping(swarm.pipelines) ? swarm.pipelines : {};
|
|
182
|
-
for (const [name, pipeline] of Object.entries(pipelines)) {
|
|
183
|
-
if (isMapping(pipeline))
|
|
184
|
-
scan(pipeline.stages, { pipeline: name });
|
|
185
|
-
}
|
|
186
|
-
return references;
|
|
187
|
-
}
|
|
188
|
-
function resolution(global, project) {
|
|
189
|
-
try {
|
|
190
|
-
return { config: resolveLevels(global, project).config, errors: [] };
|
|
191
|
-
}
|
|
192
|
-
catch (error) {
|
|
193
|
-
if (error instanceof ConfigLoadError && error.detail.kind === 'invalid') {
|
|
194
|
-
return { config: null, errors: error.detail.errors };
|
|
195
|
-
}
|
|
196
|
-
throw error;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
export function readText(file) {
|
|
200
|
-
try {
|
|
201
|
-
return readFileSync(file, 'utf8');
|
|
202
|
-
}
|
|
203
|
-
catch (error) {
|
|
204
|
-
if (error.code === 'ENOENT')
|
|
205
|
-
return undefined;
|
|
206
|
-
throw error;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
function sourcesOf(files, kind) {
|
|
210
|
-
return files[KIND_SECTION[kind]];
|
|
211
|
-
}
|
|
212
|
-
export function stemOf(path) {
|
|
213
|
-
return basename(path).replace(/\.ya?ml$/, '');
|
|
214
|
-
}
|
|
215
|
-
function withEntry(files, kind, id, file, text) {
|
|
216
|
-
const others = sourcesOf(files, kind).filter((source) => stemOf(source.path) !== id);
|
|
217
|
-
const parsed = text === null ? null : parseYaml(text, file);
|
|
218
|
-
const value = kind === 'pipeline' ? canonicalPipeline(parsed) : parsed;
|
|
219
|
-
const list = text === null ? others : [...others, { path: file, value, text }];
|
|
220
|
-
list.sort((left, right) => (left.path < right.path ? -1 : left.path > right.path ? 1 : 0));
|
|
221
|
-
return { ...files, [KIND_SECTION[kind]]: list };
|
|
222
|
-
}
|
|
223
|
-
/** Both levels read with broken files reported as problems, so one bad file hides nothing. */
|
|
224
|
-
function readLevels(paths) {
|
|
225
|
-
return {
|
|
226
|
-
global: readLevel(paths.global, { tolerant: true }),
|
|
227
|
-
project: readLevel(paths.project, { tolerant: true }),
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
function key(error) {
|
|
231
|
-
return `${error.path}\u0000${error.message}`;
|
|
232
|
-
}
|
|
233
|
-
/** The configuration with the edit applied in memory; nothing is read twice or written. */
|
|
234
|
-
function buildDraft(paths, edit, current) {
|
|
235
|
-
const level = edit.level ?? 'project';
|
|
236
|
-
const file = entryFile(paths, edit.kind, edit.id, level);
|
|
237
|
-
const text = edit.value === null ? null : editDocument(current, edit.value);
|
|
238
|
-
const files = readLevels(paths);
|
|
239
|
-
const drafted = withEntry(files[level], edit.kind, edit.id, file, text);
|
|
240
|
-
const draftFiles = { ...files, [level]: drafted };
|
|
241
|
-
const before = resolution(assembleLevel(files.global), assembleLevel(files.project));
|
|
242
|
-
const after = resolution(assembleLevel(draftFiles.global), assembleLevel(draftFiles.project));
|
|
243
|
-
if (level === 'global') {
|
|
244
|
-
// The global level has to work in any repository, so it is also checked on its own.
|
|
245
|
-
const alone = (global) => levelIsEmpty(global)
|
|
246
|
-
? { config: null, errors: [] }
|
|
247
|
-
: resolution(assembleLevel(global), emptyLevel());
|
|
248
|
-
const aloneBefore = alone(files.global);
|
|
249
|
-
const aloneAfter = alone(drafted);
|
|
250
|
-
const known = new Set(aloneBefore.errors.map(key));
|
|
251
|
-
const extra = aloneAfter.errors.filter((error) => !known.has(key(error)));
|
|
252
|
-
const seen = new Set(after.errors.map(key));
|
|
253
|
-
const merged = [...after.errors, ...extra.filter((error) => !seen.has(key(error)))];
|
|
254
|
-
return {
|
|
255
|
-
file,
|
|
256
|
-
text,
|
|
257
|
-
before: {
|
|
258
|
-
config: before.config,
|
|
259
|
-
errors: [
|
|
260
|
-
...before.errors,
|
|
261
|
-
...aloneBefore.errors.filter((error) => !before.errors.some((e) => key(e) === key(error))),
|
|
262
|
-
],
|
|
263
|
-
},
|
|
264
|
-
after: { config: after.config, errors: merged },
|
|
265
|
-
files,
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
return { file, text, before, after, files };
|
|
269
|
-
}
|
|
270
|
-
function emptyLevel() {
|
|
271
|
-
return assembleLevel({ specialists: [], pipelines: [], actions: [], problems: [] });
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* The configuration as it would be with the edit, without the revision check and without
|
|
275
|
-
* writing: the resolved configuration (null when it has errors) and all of its errors.
|
|
276
|
-
*/
|
|
277
|
-
export function draftConfig(paths, edit) {
|
|
278
|
-
const level = edit.level ?? 'project';
|
|
279
|
-
const file = entryFile(paths, edit.kind, edit.id, level);
|
|
280
|
-
try {
|
|
281
|
-
const draft = buildDraft(paths, { ...edit, revision: null }, readText(file));
|
|
282
|
-
if (level === 'global' && edit.value !== null) {
|
|
283
|
-
// The graph of a global draft is built from the global level alone, so a project file
|
|
284
|
-
// with the same id cannot hide the draft.
|
|
285
|
-
const files = readLevels(paths);
|
|
286
|
-
const drafted = withEntry(files.global, edit.kind, edit.id, file, draft.text);
|
|
287
|
-
const alone = resolution(assembleLevel(drafted), emptyLevel());
|
|
288
|
-
const seen = new Set(draft.after.errors.map(key));
|
|
289
|
-
return {
|
|
290
|
-
config: alone.config ?? draft.after.config,
|
|
291
|
-
errors: [...draft.after.errors, ...alone.errors.filter((error) => !seen.has(key(error)))],
|
|
292
|
-
};
|
|
293
|
-
}
|
|
294
|
-
return draft.after;
|
|
295
|
-
}
|
|
296
|
-
catch (error) {
|
|
297
|
-
if (!(error instanceof ConfigEditError))
|
|
298
|
-
throw error;
|
|
299
|
-
return {
|
|
300
|
-
config: null,
|
|
301
|
-
errors: [
|
|
302
|
-
{ file, path: `swarm.${KIND_SECTION[edit.kind]}.${edit.id}`, message: error.message },
|
|
303
|
-
],
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* New errors of the configuration when several files of the project level are added or replaced
|
|
309
|
-
* at once, without writing: the errors the current configuration does not have.
|
|
310
|
-
*/
|
|
311
|
-
export function draftProjectFiles(paths, entries) {
|
|
312
|
-
const files = readLevels(paths);
|
|
313
|
-
let drafted = files.project;
|
|
314
|
-
try {
|
|
315
|
-
for (const entry of entries) {
|
|
316
|
-
drafted = withEntry(drafted, entry.kind, entry.id, entry.file, entry.text);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
catch (error) {
|
|
320
|
-
if (!(error instanceof ConfigLoadError))
|
|
321
|
-
throw error;
|
|
322
|
-
const first = entries.find((entry) => error.message.includes(entry.file)) ?? entries[0];
|
|
323
|
-
return [
|
|
324
|
-
{
|
|
325
|
-
file: first?.file ?? '',
|
|
326
|
-
path: `swarm.${KIND_SECTION[first?.kind ?? 'specialist']}.${first?.id ?? ''}`,
|
|
327
|
-
message: error.message,
|
|
328
|
-
},
|
|
329
|
-
];
|
|
330
|
-
}
|
|
331
|
-
const before = resolution(assembleLevel(files.global), assembleLevel(files.project));
|
|
332
|
-
const after = resolution(assembleLevel(files.global), assembleLevel(drafted));
|
|
333
|
-
const known = new Set(before.errors.map(key));
|
|
334
|
-
return after.errors.filter((error) => !known.has(key(error)));
|
|
335
|
-
}
|
|
336
|
-
/**
|
|
337
|
-
* Checks an edit without writing: the revision, then the whole configuration with the file
|
|
338
|
-
* replaced in memory. Only errors the current configuration does not have reject the edit.
|
|
339
|
-
*/
|
|
340
|
-
export function planEdit(paths, request) {
|
|
341
|
-
const level = request.level ?? 'project';
|
|
342
|
-
const file = entryFile(paths, request.kind, request.id, level);
|
|
343
|
-
const current = readText(file);
|
|
344
|
-
let edit = request;
|
|
345
|
-
if (edit.kind === 'specialist' && level === 'global' && edit.value !== null) {
|
|
346
|
-
// Shared tags are changed only in the file: a write of the entry keeps them as the file has them.
|
|
347
|
-
let stored;
|
|
348
|
-
try {
|
|
349
|
-
const parsed = current === undefined ? undefined : parseYaml(current, file);
|
|
350
|
-
stored = isMapping(parsed) ? parsed.tags : undefined;
|
|
351
|
-
}
|
|
352
|
-
catch {
|
|
353
|
-
stored = undefined;
|
|
354
|
-
}
|
|
355
|
-
const { tags, ...rest } = edit.value;
|
|
356
|
-
if ('tags' in edit.value && !sameValue(tags, stored)) {
|
|
357
|
-
return {
|
|
358
|
-
ok: false,
|
|
359
|
-
reason: 'invalid',
|
|
360
|
-
errors: [
|
|
361
|
-
{
|
|
362
|
-
file,
|
|
363
|
-
path: `swarm.specialists.${edit.id}.tags`,
|
|
364
|
-
message: 'shared tags are changed only in the file',
|
|
365
|
-
},
|
|
366
|
-
],
|
|
367
|
-
};
|
|
368
|
-
}
|
|
369
|
-
edit = { ...edit, value: stored === undefined ? rest : { ...rest, tags: stored } };
|
|
370
|
-
}
|
|
371
|
-
if (revisionOf(current) !== edit.revision) {
|
|
372
|
-
return {
|
|
373
|
-
ok: false,
|
|
374
|
-
reason: 'conflict',
|
|
375
|
-
message: current === undefined
|
|
376
|
-
? `${file} does not exist any more`
|
|
377
|
-
: edit.revision === null
|
|
378
|
-
? `${file} already exists`
|
|
379
|
-
: `${file} was changed after it was read`,
|
|
380
|
-
};
|
|
381
|
-
}
|
|
382
|
-
let draft;
|
|
383
|
-
try {
|
|
384
|
-
draft = buildDraft(paths, edit, current);
|
|
385
|
-
}
|
|
386
|
-
catch (error) {
|
|
387
|
-
if (!(error instanceof ConfigEditError))
|
|
388
|
-
throw error;
|
|
389
|
-
return {
|
|
390
|
-
ok: false,
|
|
391
|
-
reason: 'invalid',
|
|
392
|
-
errors: [
|
|
393
|
-
{ file, path: `swarm.${KIND_SECTION[edit.kind]}.${edit.id}`, message: error.message },
|
|
394
|
-
],
|
|
395
|
-
};
|
|
396
|
-
}
|
|
397
|
-
if (edit.value === null && (edit.kind === 'specialist' || edit.kind === 'action')) {
|
|
398
|
-
const kind = edit.kind;
|
|
399
|
-
const referencesTo = kind === 'specialist' ? specialistReferences : actionReferences;
|
|
400
|
-
const inGlobal = sourcesOf(draft.files.global, kind).some((source) => stemOf(source.path) === edit.id);
|
|
401
|
-
const inProject = sourcesOf(draft.files.project, kind).some((source) => stemOf(source.path) === edit.id);
|
|
402
|
-
const globalTree = assembleLevel(draft.files.global).tree;
|
|
403
|
-
const projectTree = assembleLevel(draft.files.project).tree;
|
|
404
|
-
const references = [];
|
|
405
|
-
const add = (found) => {
|
|
406
|
-
for (const reference of found) {
|
|
407
|
-
if (!references.some((known) => JSON.stringify(known) === JSON.stringify(reference))) {
|
|
408
|
-
references.push(reference);
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
};
|
|
412
|
-
if (level === 'global') {
|
|
413
|
-
add(referencesTo(globalTree, edit.id));
|
|
414
|
-
if (!inProject)
|
|
415
|
-
add(referencesTo(mergeConfigs(globalTree, projectTree), edit.id));
|
|
416
|
-
}
|
|
417
|
-
else if (!inGlobal) {
|
|
418
|
-
add(referencesTo(mergeConfigs(globalTree, projectTree), edit.id));
|
|
419
|
-
}
|
|
420
|
-
if (references.length > 0)
|
|
421
|
-
return { ok: false, reason: 'invalid', errors: [], references };
|
|
422
|
-
}
|
|
423
|
-
const known = new Set(draft.before.errors.map(key));
|
|
424
|
-
const added = draft.after.errors.filter((error) => !known.has(key(error)));
|
|
425
|
-
if (added.length > 0)
|
|
426
|
-
return { ok: false, reason: 'invalid', errors: added };
|
|
427
|
-
return { ok: true, file, text: draft.text, revision: revisionOf(draft.text ?? undefined) };
|
|
428
|
-
}
|
|
429
|
-
const WEB_PORT_RANGE = [1, 65535];
|
|
430
|
-
const RESOLVER_ROUNDS_RANGE = MAX_ROUNDS_RANGE;
|
|
431
|
-
const ENV_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
432
|
-
function field(path, kind, extra = {}) {
|
|
433
|
-
return { path, kind, ...extra, globalOnly: extra.globalOnly ?? false };
|
|
434
|
-
}
|
|
435
|
-
/** Every field of settings.yaml the editor writes, in the order the editor shows them. */
|
|
436
|
-
export const SETTING_FIELDS = [
|
|
437
|
-
field('max', 'integer', { range: MAX_RANGE }),
|
|
438
|
-
field('workspace_dir', 'string'),
|
|
439
|
-
field('outside_changes', 'choice', { options: OUTSIDE_CHANGES }),
|
|
440
|
-
field('defaults.runtime', 'choice', { options: RUNTIMES }),
|
|
441
|
-
field('defaults.permissions', 'choice', { options: PERMISSIONS }),
|
|
442
|
-
field('defaults.timeout', 'duration'),
|
|
443
|
-
field('defaults.allow_commands', 'strings'),
|
|
444
|
-
field('defaults.tools', 'strings'),
|
|
445
|
-
field('claude.edit_mode', 'choice', { options: CLAUDE_EDIT_MODES }),
|
|
446
|
-
field('claude.mcp', 'choice', { options: CLAUDE_MCP_MODES }),
|
|
447
|
-
field('claude.settings', 'choice', { options: CLAUDE_SETTINGS_SOURCES }),
|
|
448
|
-
field('delivery.mode', 'choice', { options: DELIVERY_MODES }),
|
|
449
|
-
field('delivery.auto', 'boolean'),
|
|
450
|
-
field('delivery.keep', 'boolean'),
|
|
451
|
-
field('delivery.commit_message', 'string'),
|
|
452
|
-
field('delivery.message_specialist', 'specialist'),
|
|
453
|
-
field('delivery.resolver', 'specialist'),
|
|
454
|
-
field('delivery.resolver_rounds', 'integer', { range: RESOLVER_ROUNDS_RANGE }),
|
|
455
|
-
field('delivery.message_prompt', 'string'),
|
|
456
|
-
field('delivery.resolver_prompt', 'string'),
|
|
457
|
-
field('workspace.base', 'choice', { options: WORKSPACE_BASES }),
|
|
458
|
-
field('workspace.include', 'strings'),
|
|
459
|
-
field('naming.enabled', 'boolean'),
|
|
460
|
-
field('naming.runtime', 'choice', { options: RUNTIMES }),
|
|
461
|
-
field('naming.model', 'string'),
|
|
462
|
-
field('web.autostart', 'boolean', { globalOnly: true }),
|
|
463
|
-
field('web.auth', 'choice', { options: WEB_AUTH_MODES, globalOnly: true }),
|
|
464
|
-
field('web.host', 'choice', { options: WEB_HOSTS, globalOnly: true }),
|
|
465
|
-
field('web.port', 'integer', { range: WEB_PORT_RANGE, globalOnly: true }),
|
|
466
|
-
...RUNTIMES.flatMap((runtime) => [
|
|
467
|
-
field(`runtimes.${runtime}.command`, 'string', { globalOnly: true }),
|
|
468
|
-
field(`runtimes.${runtime}.args`, 'strings', { globalOnly: true }),
|
|
469
|
-
field(`runtimes.${runtime}.env`, 'env', { globalOnly: true }),
|
|
470
|
-
]),
|
|
471
|
-
];
|
|
472
|
-
const ENV_VARIABLE_PATH = /^runtimes\.([a-z]+)\.env\.(.+)$/;
|
|
473
|
-
/** The field for a path, also a single variable `runtimes.<runtime>.env.<NAME>`; undefined for any other path. */
|
|
474
|
-
export function settingFieldOf(path) {
|
|
475
|
-
const known = SETTING_FIELDS.find((candidate) => candidate.path === path);
|
|
476
|
-
if (known)
|
|
477
|
-
return known;
|
|
478
|
-
const match = ENV_VARIABLE_PATH.exec(path);
|
|
479
|
-
if (match &&
|
|
480
|
-
RUNTIMES.includes(match[1]) &&
|
|
481
|
-
ENV_NAME.test(match[2])) {
|
|
482
|
-
return field(path, 'env', { globalOnly: true });
|
|
483
|
-
}
|
|
484
|
-
return undefined;
|
|
485
|
-
}
|
|
486
|
-
/** A variable of `runtimes.<runtime>.env` (a string), as opposed to the whole `env` section. */
|
|
487
|
-
function isEnvVariable(path) {
|
|
488
|
-
return ENV_VARIABLE_PATH.test(path);
|
|
489
|
-
}
|
|
490
|
-
/** `settings.yaml` of the level, or `settings.yml` when only that one exists. */
|
|
491
|
-
export function settingsFile(paths, level = 'global') {
|
|
492
|
-
const directory = resolve(paths[level].directory);
|
|
493
|
-
const yaml = join(directory, `${SETTINGS_NAME}.yaml`);
|
|
494
|
-
const yml = join(directory, `${SETTINGS_NAME}.yml`);
|
|
495
|
-
return !existsSync(yaml) && existsSync(yml) ? yml : yaml;
|
|
496
|
-
}
|
|
497
|
-
/** Text of settings.yaml with one field set (or removed); comments and other keys survive. */
|
|
498
|
-
export function editSetting(text, path, value) {
|
|
499
|
-
const keys = path.split('.');
|
|
500
|
-
if (text === undefined || text.trim() === '') {
|
|
501
|
-
if (value === null)
|
|
502
|
-
return text ?? '';
|
|
503
|
-
const fresh = new Document({});
|
|
504
|
-
fresh.setIn(keys, value);
|
|
505
|
-
return `${text ?? ''}${fresh.toString({ lineWidth: 0 })}`;
|
|
506
|
-
}
|
|
507
|
-
const document = parseDocument(text, { merge: true, uniqueKeys: true });
|
|
508
|
-
if (document.errors.length > 0) {
|
|
509
|
-
throw new ConfigEditError(`the file has a syntax error: ${document.errors[0]?.message ?? ''}`);
|
|
510
|
-
}
|
|
511
|
-
if (!isMap(document.contents)) {
|
|
512
|
-
if (document.contents !== null &&
|
|
513
|
-
!(isScalar(document.contents) && document.contents.value === null)) {
|
|
514
|
-
throw new ConfigEditError('the file must contain a mapping');
|
|
515
|
-
}
|
|
516
|
-
document.contents = document.createNode({});
|
|
517
|
-
}
|
|
518
|
-
if (value === null) {
|
|
519
|
-
document.deleteIn(keys);
|
|
520
|
-
const parent = document.getIn(keys.slice(0, -1), true);
|
|
521
|
-
if (keys.length > 1 && isMap(parent) && parent.items.length === 0) {
|
|
522
|
-
document.deleteIn(keys.slice(0, -1));
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
else {
|
|
526
|
-
document.setIn(keys, value);
|
|
527
|
-
}
|
|
528
|
-
return document.toString({ lineWidth: 0 });
|
|
529
|
-
}
|
|
530
|
-
function textError(value) {
|
|
531
|
-
if (typeof value !== 'string')
|
|
532
|
-
return 'must be a string';
|
|
533
|
-
return value.trim() === '' ? 'must not be empty' : null;
|
|
534
|
-
}
|
|
535
|
-
/** Why the value does not fit the field: the message and the path suffix (`[1]` for a list item), or null. */
|
|
536
|
-
function settingTypeError(setting, value) {
|
|
537
|
-
if (value === null)
|
|
538
|
-
return null;
|
|
539
|
-
const fail = (message, suffix = '') => ({ message, suffix });
|
|
540
|
-
switch (setting.kind) {
|
|
541
|
-
case 'boolean':
|
|
542
|
-
return typeof value === 'boolean' ? null : fail('must be true or false');
|
|
543
|
-
case 'choice': {
|
|
544
|
-
const options = setting.options ?? [];
|
|
545
|
-
const message = textError(value);
|
|
546
|
-
if (message !== null)
|
|
547
|
-
return fail(message);
|
|
548
|
-
return options.includes(value)
|
|
549
|
-
? null
|
|
550
|
-
: fail(`must be one of ${options.join(', ')}`);
|
|
551
|
-
}
|
|
552
|
-
case 'integer': {
|
|
553
|
-
const [low, high] = setting.range ?? [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER];
|
|
554
|
-
return typeof value === 'number' && Number.isInteger(value) && value >= low && value <= high
|
|
555
|
-
? null
|
|
556
|
-
: fail(`must be an integer from ${low} to ${high}`);
|
|
557
|
-
}
|
|
558
|
-
case 'duration': {
|
|
559
|
-
const message = textError(value);
|
|
560
|
-
if (message !== null)
|
|
561
|
-
return fail(message);
|
|
562
|
-
return parseDuration(value) === null
|
|
563
|
-
? fail('must be a positive duration such as 90s, 30m or 2h')
|
|
564
|
-
: null;
|
|
565
|
-
}
|
|
566
|
-
case 'strings': {
|
|
567
|
-
if (!Array.isArray(value))
|
|
568
|
-
return fail('must be a list of strings');
|
|
569
|
-
for (const [index, item] of value.entries()) {
|
|
570
|
-
const message = textError(item);
|
|
571
|
-
if (message !== null)
|
|
572
|
-
return fail(message, `[${index}]`);
|
|
573
|
-
}
|
|
574
|
-
return null;
|
|
575
|
-
}
|
|
576
|
-
case 'env':
|
|
577
|
-
if (!isEnvVariable(setting.path))
|
|
578
|
-
return fail('cannot be written as a whole');
|
|
579
|
-
return typeof value === 'string' ? null : fail('must be a string');
|
|
580
|
-
case 'string':
|
|
581
|
-
case 'specialist': {
|
|
582
|
-
const message = textError(value);
|
|
583
|
-
return message === null ? null : fail(message);
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
/**
|
|
588
|
-
* Checks a write of several settings without writing: the types of all values, the revision, then
|
|
589
|
-
* the whole configuration with all of the edits applied to one text.
|
|
590
|
-
*/
|
|
591
|
-
export function planSettings(paths, request) {
|
|
592
|
-
const level = request.level ?? 'global';
|
|
593
|
-
const entries = Object.entries(request.values);
|
|
594
|
-
if (entries.length === 0)
|
|
595
|
-
throw new ConfigEditError('there is nothing to write');
|
|
596
|
-
const unknown = entries.filter(([path]) => settingFieldOf(path) === undefined).map(([p]) => p);
|
|
597
|
-
if (unknown.length > 0) {
|
|
598
|
-
throw new ConfigEditError(`${unknown.map((path) => `\`${path}\``).join(', ')} cannot be written; allowed: ${SETTING_FIELDS.map((setting) => setting.path).join(', ')}`);
|
|
599
|
-
}
|
|
600
|
-
const file = settingsFile(paths, level);
|
|
601
|
-
const typeErrors = [];
|
|
602
|
-
for (const [path, value] of entries) {
|
|
603
|
-
const setting = settingFieldOf(path);
|
|
604
|
-
if (setting.globalOnly && level === 'project') {
|
|
605
|
-
typeErrors.push({
|
|
606
|
-
file,
|
|
607
|
-
path: `swarm.${path}`,
|
|
608
|
-
message: 'is read only from the shared settings.yaml',
|
|
609
|
-
});
|
|
610
|
-
continue;
|
|
611
|
-
}
|
|
612
|
-
const problem = settingTypeError(setting, value);
|
|
613
|
-
if (problem !== null) {
|
|
614
|
-
typeErrors.push({ file, path: `swarm.${path}${problem.suffix}`, message: problem.message });
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
if (typeErrors.length > 0)
|
|
618
|
-
return { ok: false, reason: 'invalid', errors: typeErrors };
|
|
619
|
-
const current = readText(file);
|
|
620
|
-
if (revisionOf(current) !== request.revision) {
|
|
621
|
-
return {
|
|
622
|
-
ok: false,
|
|
623
|
-
reason: 'conflict',
|
|
624
|
-
message: current === undefined
|
|
625
|
-
? `${file} does not exist any more`
|
|
626
|
-
: request.revision === null
|
|
627
|
-
? `${file} already exists`
|
|
628
|
-
: `${file} was changed after it was read`,
|
|
629
|
-
};
|
|
630
|
-
}
|
|
631
|
-
let text = current;
|
|
632
|
-
try {
|
|
633
|
-
for (const [path, value] of entries)
|
|
634
|
-
text = editSetting(text, path, value);
|
|
635
|
-
}
|
|
636
|
-
catch (error) {
|
|
637
|
-
if (!(error instanceof ConfigEditError))
|
|
638
|
-
throw error;
|
|
639
|
-
return {
|
|
640
|
-
ok: false,
|
|
641
|
-
reason: 'invalid',
|
|
642
|
-
errors: [{ file, path: `swarm.${entries[0]?.[0] ?? ''}`, message: error.message }],
|
|
643
|
-
};
|
|
644
|
-
}
|
|
645
|
-
const written = text ?? '';
|
|
646
|
-
const files = readLevels(paths);
|
|
647
|
-
const before = resolution(assembleLevel(files.global), assembleLevel(files.project));
|
|
648
|
-
const settings = { path: file, value: parseYaml(written, file), text: written };
|
|
649
|
-
const drafted = { ...files, [level]: { ...files[level], settings } };
|
|
650
|
-
const after = resolution(assembleLevel(drafted.global), assembleLevel(drafted.project));
|
|
651
|
-
const known = new Set(before.errors.map(key));
|
|
652
|
-
const added = after.errors.filter((error) => !known.has(key(error)));
|
|
653
|
-
if (level === 'global' &&
|
|
654
|
-
entries.some(([path]) => settingFieldOf(path).globalOnly)) {
|
|
655
|
-
const sectionErrors = (source) => {
|
|
656
|
-
const root = isMapping(source?.value) ? source.value : {};
|
|
657
|
-
return [
|
|
658
|
-
...validateWebSection(root.web).errors,
|
|
659
|
-
...validateRuntimesSection(root.runtimes).errors,
|
|
660
|
-
];
|
|
661
|
-
};
|
|
662
|
-
const sectionKnown = new Set(sectionErrors(files.global.settings).map(key));
|
|
663
|
-
const seen = new Set([...known, ...added.map(key)]);
|
|
664
|
-
for (const error of sectionErrors(settings)) {
|
|
665
|
-
if (sectionKnown.has(key(error)) || seen.has(key(error)))
|
|
666
|
-
continue;
|
|
667
|
-
added.push({ ...error, file });
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
if (added.length > 0)
|
|
671
|
-
return { ok: false, reason: 'invalid', errors: added };
|
|
672
|
-
return { ok: true, file, text: written, revision: revisionOf(written) };
|
|
673
|
-
}
|
|
674
|
-
/** Checks a write of one setting without writing: the revision, then the whole configuration. */
|
|
675
|
-
export function planSetting(paths, request) {
|
|
676
|
-
return planSettings(paths, {
|
|
677
|
-
values: { [request.path]: request.value },
|
|
678
|
-
revision: request.revision,
|
|
679
|
-
...(request.level ? { level: request.level } : {}),
|
|
680
|
-
});
|
|
681
|
-
}
|
|
682
|
-
/** Writes a plan: a temporary file next to the target, then a rename; deletion is an unlink. */
|
|
683
|
-
export function commitEdit(plan) {
|
|
684
|
-
if (plan.text === null) {
|
|
685
|
-
unlinkSync(plan.file);
|
|
686
|
-
return { file: plan.file, revision: null };
|
|
687
|
-
}
|
|
688
|
-
mkdirSync(dirname(plan.file), { recursive: true });
|
|
689
|
-
const temporary = join(dirname(plan.file), `.${basename(plan.file)}.tmp-${process.pid}`);
|
|
690
|
-
try {
|
|
691
|
-
writeFileSync(temporary, plan.text);
|
|
692
|
-
renameSync(temporary, plan.file);
|
|
693
|
-
}
|
|
694
|
-
catch (error) {
|
|
695
|
-
try {
|
|
696
|
-
unlinkSync(temporary);
|
|
697
|
-
}
|
|
698
|
-
catch {
|
|
699
|
-
// nothing was written
|
|
700
|
-
}
|
|
701
|
-
throw error;
|
|
702
|
-
}
|
|
703
|
-
return { file: plan.file, revision: plan.revision };
|
|
704
|
-
}
|
|
705
|
-
function sourceOf(source) {
|
|
706
|
-
if (!source)
|
|
707
|
-
return undefined;
|
|
708
|
-
return {
|
|
709
|
-
file: source.path,
|
|
710
|
-
revision: revisionOf(source.text) ?? '',
|
|
711
|
-
raw: rawOf(source),
|
|
712
|
-
};
|
|
713
|
-
}
|
|
714
|
-
function sourcesFor(project, global) {
|
|
715
|
-
const result = {};
|
|
716
|
-
const p = sourceOf(project);
|
|
717
|
-
const g = sourceOf(global);
|
|
718
|
-
if (p)
|
|
719
|
-
result.project = p;
|
|
720
|
-
if (g)
|
|
721
|
-
result.global = g;
|
|
722
|
-
return result;
|
|
723
|
-
}
|
|
724
|
-
function valuesOf(specialist) {
|
|
725
|
-
return {
|
|
726
|
-
name: specialist.name,
|
|
727
|
-
runtime: specialist.runtime,
|
|
728
|
-
model: specialist.model,
|
|
729
|
-
permissions: specialist.permissions,
|
|
730
|
-
timeout: formatDuration(specialist.timeoutSeconds),
|
|
731
|
-
allow_commands: specialist.allowCommands,
|
|
732
|
-
tools: specialist.tools,
|
|
733
|
-
skills: specialist.skills,
|
|
734
|
-
prompt: specialist.prompt,
|
|
735
|
-
max: specialist.max,
|
|
736
|
-
};
|
|
737
|
-
}
|
|
738
|
-
function settingsOf(config) {
|
|
739
|
-
return [
|
|
740
|
-
['max', config.max],
|
|
741
|
-
['workspace_dir', config.workspaceDir],
|
|
742
|
-
['outside_changes', config.outsideChanges],
|
|
743
|
-
['defaults.runtime', config.defaults.runtime],
|
|
744
|
-
['defaults.permissions', config.defaults.permissions],
|
|
745
|
-
['defaults.timeout', formatDuration(config.defaults.timeoutSeconds)],
|
|
746
|
-
['defaults.allow_commands', config.defaults.allowCommands],
|
|
747
|
-
['defaults.tools', config.defaults.tools],
|
|
748
|
-
['claude.edit_mode', config.claude.editMode],
|
|
749
|
-
['claude.mcp', config.claude.mcp],
|
|
750
|
-
['claude.settings', config.claude.settings],
|
|
751
|
-
['delivery.mode', config.delivery.mode],
|
|
752
|
-
['delivery.auto', config.delivery.auto],
|
|
753
|
-
['delivery.keep', config.delivery.keep],
|
|
754
|
-
['delivery.commit_message', config.delivery.commitMessage],
|
|
755
|
-
['delivery.message_specialist', config.delivery.messageSpecialist],
|
|
756
|
-
['delivery.resolver', config.delivery.resolver],
|
|
757
|
-
['delivery.resolver_rounds', config.delivery.resolverRounds],
|
|
758
|
-
['delivery.message_prompt', config.delivery.messagePrompt ?? null],
|
|
759
|
-
['delivery.resolver_prompt', config.delivery.resolverPrompt ?? null],
|
|
760
|
-
['workspace.base', config.workspace.base],
|
|
761
|
-
['workspace.include', config.workspace.include],
|
|
762
|
-
['naming.enabled', config.naming.enabled],
|
|
763
|
-
['naming.runtime', config.naming.runtime],
|
|
764
|
-
['naming.model', config.naming.model],
|
|
765
|
-
];
|
|
766
|
-
}
|
|
767
|
-
/**
|
|
768
|
-
* `web.*` and `runtimes.*` as the daemon reads them: from the global settings.yaml only. The value
|
|
769
|
-
* of `env` never leaves the config layer: only the sorted names of the variables do.
|
|
770
|
-
*/
|
|
771
|
-
function globalSectionSettings(paths, global) {
|
|
772
|
-
const file = global.settings?.path ?? null;
|
|
773
|
-
const root = isMapping(global.settings?.value) ? global.settings.value : {};
|
|
774
|
-
const has = (section, ...keys) => {
|
|
775
|
-
let node = root[section];
|
|
776
|
-
for (const key of keys) {
|
|
777
|
-
if (!isMapping(node) || !(key in node))
|
|
778
|
-
return false;
|
|
779
|
-
node = node[key];
|
|
780
|
-
}
|
|
781
|
-
return true;
|
|
782
|
-
};
|
|
783
|
-
const originOf = (section, ...keys) => (has(section, ...keys) ? file : null);
|
|
784
|
-
const safe = (read, fallback) => {
|
|
785
|
-
try {
|
|
786
|
-
return read();
|
|
787
|
-
}
|
|
788
|
-
catch (error) {
|
|
789
|
-
if (error instanceof ConfigLoadError)
|
|
790
|
-
return fallback();
|
|
791
|
-
throw error;
|
|
792
|
-
}
|
|
793
|
-
};
|
|
794
|
-
const web = safe(() => loadWebSettings(paths), defaultWeb);
|
|
795
|
-
const runtimes = safe(() => loadRuntimeSettings(paths), defaultRuntimes);
|
|
796
|
-
return sectionValues(web, runtimes).map(([path, value]) => ({
|
|
797
|
-
path,
|
|
798
|
-
value,
|
|
799
|
-
file: originOf(...path.split('.')),
|
|
800
|
-
}));
|
|
801
|
-
}
|
|
802
|
-
/** `web.*` and `runtimes.*` values as pairs; the value of `env` is reduced to the sorted names. */
|
|
803
|
-
function sectionValues(web, runtimes) {
|
|
804
|
-
const result = [
|
|
805
|
-
['web.autostart', web.autostart],
|
|
806
|
-
['web.auth', web.auth],
|
|
807
|
-
['web.host', web.host],
|
|
808
|
-
['web.port', web.port],
|
|
809
|
-
];
|
|
810
|
-
for (const runtime of RUNTIMES) {
|
|
811
|
-
const command = runtimes[runtime];
|
|
812
|
-
result.push([`runtimes.${runtime}.command`, command.command], [`runtimes.${runtime}.args`, command.args], [`runtimes.${runtime}.env`, Object.keys(command.env).sort()]);
|
|
813
|
-
}
|
|
814
|
-
return result;
|
|
815
|
-
}
|
|
816
|
-
/** Settings that are not valid are shown with the defaults, the errors say what is wrong. */
|
|
817
|
-
function configOrDefaults(config) {
|
|
818
|
-
if (config)
|
|
819
|
-
return config;
|
|
820
|
-
const result = validateConfig({ swarm: {} });
|
|
821
|
-
if (!result.ok)
|
|
822
|
-
throw new Error('the empty configuration must be valid');
|
|
823
|
-
return result.config;
|
|
824
|
-
}
|
|
825
|
-
function rawOf(source) {
|
|
826
|
-
return isMapping(source?.value) ? source.value : {};
|
|
827
|
-
}
|
|
828
|
-
/** Everything the specialists tab shows, also when the configuration does not pass validation. */
|
|
829
|
-
export function editorView(paths) {
|
|
830
|
-
const files = readLevels(paths);
|
|
831
|
-
const global = assembleLevel(files.global);
|
|
832
|
-
const project = assembleLevel(files.project);
|
|
833
|
-
const { config, errors } = resolution(global, project);
|
|
834
|
-
const byStem = (sources) => new Map(sources.map((source) => [stemOf(source.path), source]));
|
|
835
|
-
const globalSpecialists = byStem(files.global.specialists);
|
|
836
|
-
const projectSpecialists = byStem(files.project.specialists);
|
|
837
|
-
const merged = mergeConfigs(global.tree, project.tree);
|
|
838
|
-
const swarm = isMapping(merged) && isMapping(merged.swarm) ? merged.swarm : {};
|
|
839
|
-
const defaults = isMapping(swarm.defaults) ? swarm.defaults : {};
|
|
840
|
-
const slugs = [...new Set([...globalSpecialists.keys(), ...projectSpecialists.keys()])].sort();
|
|
841
|
-
const specialists = slugs.map((slug) => {
|
|
842
|
-
const inProject = projectSpecialists.get(slug);
|
|
843
|
-
const inGlobal = globalSpecialists.get(slug);
|
|
844
|
-
const source = (inProject ?? inGlobal);
|
|
845
|
-
const level = inProject ? (inGlobal ? 'project_over_global' : 'project') : 'global';
|
|
846
|
-
let effective = null;
|
|
847
|
-
const resolved = config?.specialists.find((candidate) => candidate.slug === slug);
|
|
848
|
-
if (resolved)
|
|
849
|
-
effective = valuesOf(resolved);
|
|
850
|
-
else {
|
|
851
|
-
const alone = validateConfig({
|
|
852
|
-
swarm: { defaults, specialists: { [slug]: source.value ?? null } },
|
|
853
|
-
});
|
|
854
|
-
const found = alone.ok ? alone.config.specialists[0] : undefined;
|
|
855
|
-
if (found)
|
|
856
|
-
effective = valuesOf(found);
|
|
857
|
-
}
|
|
858
|
-
return {
|
|
859
|
-
slug,
|
|
860
|
-
level,
|
|
861
|
-
file: source.path,
|
|
862
|
-
revision: inProject ? revisionOf(inProject.text) : null,
|
|
863
|
-
raw: rawOf(source),
|
|
864
|
-
sources: sourcesFor(inProject, inGlobal),
|
|
865
|
-
effective,
|
|
866
|
-
shared_tags: tagsOf(rawOf(inGlobal)),
|
|
867
|
-
own_tags: tagsOf(rawOf(inProject)),
|
|
868
|
-
};
|
|
869
|
-
});
|
|
870
|
-
const globalPipelines = byStem(files.global.pipelines);
|
|
871
|
-
const projectPipelines = byStem(files.project.pipelines);
|
|
872
|
-
const pipelines = [...new Set([...globalPipelines.keys(), ...projectPipelines.keys()])]
|
|
873
|
-
.sort()
|
|
874
|
-
.map((id) => {
|
|
875
|
-
const inProject = projectPipelines.get(id);
|
|
876
|
-
const inGlobal = globalPipelines.get(id);
|
|
877
|
-
const source = (inProject ?? inGlobal);
|
|
878
|
-
return {
|
|
879
|
-
id,
|
|
880
|
-
level: inProject ? (inGlobal ? 'project_over_global' : 'project') : 'global',
|
|
881
|
-
file: source.path,
|
|
882
|
-
revision: inProject ? revisionOf(inProject.text) : null,
|
|
883
|
-
raw: rawOf(source),
|
|
884
|
-
sources: sourcesFor(inProject, inGlobal),
|
|
885
|
-
shared_tags: tagsOf(rawOf(inGlobal)),
|
|
886
|
-
own_tags: tagsOf(rawOf(inProject)),
|
|
887
|
-
};
|
|
888
|
-
});
|
|
889
|
-
const globalActions = byStem(files.global.actions);
|
|
890
|
-
const projectActions = byStem(files.project.actions);
|
|
891
|
-
const actions = [...new Set([...globalActions.keys(), ...projectActions.keys()])]
|
|
892
|
-
.sort()
|
|
893
|
-
.map((id) => {
|
|
894
|
-
const inProject = projectActions.get(id);
|
|
895
|
-
const inGlobal = globalActions.get(id);
|
|
896
|
-
const source = (inProject ?? inGlobal);
|
|
897
|
-
return {
|
|
898
|
-
id,
|
|
899
|
-
level: inProject ? (inGlobal ? 'project_over_global' : 'project') : 'global',
|
|
900
|
-
file: source.path,
|
|
901
|
-
revision: inProject ? revisionOf(inProject.text) : null,
|
|
902
|
-
raw: rawOf(source),
|
|
903
|
-
sources: sourcesFor(inProject, inGlobal),
|
|
904
|
-
};
|
|
905
|
-
});
|
|
906
|
-
const origins = mergeOrigins(global, project);
|
|
907
|
-
const base = [
|
|
908
|
-
...settingsOf(configOrDefaults(config)).map(([path, value]) => ({
|
|
909
|
-
path,
|
|
910
|
-
value,
|
|
911
|
-
file: origins.get(`swarm.${path}`) ?? null,
|
|
912
|
-
})),
|
|
913
|
-
...globalSectionSettings(paths, files.global),
|
|
914
|
-
];
|
|
915
|
-
const defaultValues = new Map([
|
|
916
|
-
...settingsOf(configOrDefaults(null)),
|
|
917
|
-
...sectionValues(defaultWeb(), defaultRuntimes()),
|
|
918
|
-
]);
|
|
919
|
-
const aloneConfig = resolution(global, emptyLevel()).config;
|
|
920
|
-
const globalValues = new Map(settingsOf(configOrDefaults(aloneConfig)));
|
|
921
|
-
const writtenOf = (source, path, kind) => {
|
|
922
|
-
let node = source?.value;
|
|
923
|
-
for (const part of path.split('.')) {
|
|
924
|
-
if (!isMapping(node) || !(part in node))
|
|
925
|
-
return undefined;
|
|
926
|
-
node = node[part];
|
|
927
|
-
}
|
|
928
|
-
return kind === 'env' && isMapping(node) ? Object.keys(node).sort() : node;
|
|
929
|
-
};
|
|
930
|
-
const settings = base.map((entry) => {
|
|
931
|
-
const setting = settingFieldOf(entry.path);
|
|
932
|
-
const written = {};
|
|
933
|
-
const inGlobal = writtenOf(files.global.settings, entry.path, setting.kind);
|
|
934
|
-
const inProject = setting.globalOnly
|
|
935
|
-
? undefined
|
|
936
|
-
: writtenOf(files.project.settings, entry.path, setting.kind);
|
|
937
|
-
if (inGlobal !== undefined)
|
|
938
|
-
written.global = inGlobal;
|
|
939
|
-
if (inProject !== undefined)
|
|
940
|
-
written.project = inProject;
|
|
941
|
-
return {
|
|
942
|
-
...entry,
|
|
943
|
-
kind: setting.kind,
|
|
944
|
-
...(setting.options ? { options: setting.options } : {}),
|
|
945
|
-
...(setting.range ? { range: setting.range } : {}),
|
|
946
|
-
globalOnly: setting.globalOnly,
|
|
947
|
-
defaultValue: defaultValues.get(entry.path),
|
|
948
|
-
globalValue: setting.globalOnly ? entry.value : globalValues.get(entry.path),
|
|
949
|
-
written,
|
|
950
|
-
};
|
|
951
|
-
});
|
|
952
|
-
const settingsView = (level) => ({
|
|
953
|
-
file: settingsFile(paths, level),
|
|
954
|
-
revision: revisionOf(files[level].settings?.text),
|
|
955
|
-
});
|
|
956
|
-
return {
|
|
957
|
-
directories: { global: paths.global.directory, project: paths.project.directory },
|
|
958
|
-
settingsFiles: { global: settingsView('global'), project: settingsView('project') },
|
|
959
|
-
specialists,
|
|
960
|
-
pipelines,
|
|
961
|
-
actions,
|
|
962
|
-
settings,
|
|
963
|
-
errors,
|
|
964
|
-
};
|
|
965
|
-
}
|
|
966
|
-
//# sourceMappingURL=edit.js.map
|