Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.
Python agent-orchestrationaiai-agentschatopsdiscordlangchainmcpmicrosoft-teamsmulti-agentopen-sourceopenaiself-hostedslack
fix(switchdash): stop a host with no GitHub CLI reporting itself Ready (CHOO-1809)
switch-worker-louis-remoteb69bf40683f3
diff --git a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/host-setup-service.ts b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/host-setup-service.tsindex b83776d09..32e0c86e7 100644--- a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/host-setup-service.ts+++ b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/host-setup-service.ts@@ -31,7 +31,12 @@ import {reconcileInterruptedPlan,} from './plan-builder';import { deleteSetupPlan, getSetupPlan, listSetupPlans, saveSetupPlan } from './setup-plan-store';-import { outcomeForDependency, outcomeForGhAuth } from './step-outcomes';+import {+ condenseCommandOutput,+ describeInstallFailure,+ outcomeForDependency,+ outcomeForGhAuth,+} from './step-outcomes';/** Runners are per-host so two hosts can be set up at once, but a host only once. */const runners = new Map<string, HostSetupRunner>();@@ -160,11 +165,15 @@ async function installStep(// Surface the installer's own words. The old page discarded these and// rendered a bare "Install failed" — or, for a Result-typed failure, nothing.+ // Its words are not always intelligible, though, so the few failures we can+ // recognise are named plainly and the raw transcript is kept underneath.const error = result.error as { message?: string; output?: string; type?: string };+ const message = error.message ?? error.type ?? 'Install failed.';+ const output = error.output ? condenseCommandOutput(error.output) : null;return {ok: false,- error: error.message ?? error.type ?? 'Install failed.',- output: error.output ?? null,+ error: describeInstallFailure(step.name, message, output),+ output,};}diff --git a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/plan-builder.test.ts b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/plan-builder.test.tsindex a5408ed3f..2f5993d88 100644--- a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/plan-builder.test.ts+++ b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/plan-builder.test.ts@@ -43,7 +43,9 @@ describe('buildSetupPlan', () => {it('marks gh and its login optional so they cannot strand a host', () => {const plan = build();const optional = plan.steps.filter((s) => s.optional).map((s) => s.id);- expect(optional).toEqual(['gh', GH_AUTH_STEP_ID]);+ // gh is required: without it the Switch connector cannot fetch its runtime,+ // so an agent on this host would start with no Switch tools (CHOO-1873).+ expect(optional).toEqual([]);});it('keeps the required core tools required', () => {diff --git a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/plan-builder.ts b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/plan-builder.tsindex 8d10832f2..6e10219ab 100644--- a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/plan-builder.ts+++ b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/plan-builder.ts@@ -80,16 +80,17 @@ export function buildSetupPlan(input: BuildPlanInput): HostSetupPlan {const steps: HostSetupStep[] = [];for (const dep of coreDependencies) {- // gh is required-but-deferrable: agents commonly want it, but it needs an- // interactive device-flow login that a user may reasonably postpone without- // the host being unusable. Blocking onboarding on it strands the host.- const optional = dep.id === 'gh';- steps.push(blankStep(dep.id, 'core-dependency', dep.name, now, { optional }));+ // gh was optional on the theory that its interactive login could be+ // deferred without the host being unusable. CHOO-1873 disproved that: the+ // Switch connector fetches its MCP runtime from GitHub Packages at session+ // start, so without gh — authenticated, with read:packages — every agent on+ // this host comes up with no Switch tools. A host in that state is not+ // ready, and calling it ready is the failure this rewrite exists to remove.+ steps.push(blankStep(dep.id, 'core-dependency', dep.name, now));if (dep.id === 'gh') {steps.push(blankStep(GH_AUTH_STEP_ID, 'gh-auth', 'GitHub CLI login', now, {- optional: true,dependsOn: ['gh'],}));diff --git a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/step-outcomes.test.ts b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/step-outcomes.test.tsindex 7387a7c7e..46750642f 100644--- a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/step-outcomes.test.ts+++ b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/step-outcomes.test.ts@@ -1,6 +1,11 @@import { describe, expect, it } from 'vitest';import type { GhAuthStatus } from '../gh-auth';-import { outcomeForDependency, outcomeForGhAuth } from './step-outcomes';+import {+ condenseCommandOutput,+ describeInstallFailure,+ outcomeForDependency,+ outcomeForGhAuth,+} from './step-outcomes';function ghStatus(overrides: Partial<GhAuthStatus>): GhAuthStatus {return {@@ -70,3 +75,68 @@ describe('outcomeForDependency', () => {).toEqual({ outcome: 'unknown', version: null, error: 'channel closed' });});});++describe('describeInstallFailure', () => {+ // Trimmed from a real failure on an EC2 Ubuntu host: the distro's own+ // automatic-updates timer held the lock while we tried to install git.+ const APT_LOCK_OUTPUT = [+ 'Hit:1 http://us-east-2.ec2.archive.ubuntu.com/ubuntu jammy InRelease',+ 'Reading package lists... Done',+ 'E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 4030760 (apt-get)',+ 'N: Be aware that removing the lock file is not a solution and may break your system.',+ 'E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?',+ ].join('\n');++ it('names the package-manager lock instead of leaving apt to explain itself', () => {+ const message = describeInstallFailure(+ 'Git',+ 'Command failed with exit code 100',+ APT_LOCK_OUTPUT+ );++ expect(message).toContain('another process on the host is using the package manager');+ expect(message).toContain('retry');+ expect(message).toContain('Git');+ });++ it('recognises the lock from the message alone', () => {+ expect(+ describeInstallFailure('Git', 'E: Could not get lock /var/lib/dpkg/lock-frontend', null)+ ).toContain('package manager');+ });++ it('leaves an error it does not recognise exactly as the installer put it', () => {+ // Guessing at an unfamiliar failure would be worse than quoting it.+ expect(describeInstallFailure('tmux', 'E: Unable to locate package tmux', 'some output')).toBe(+ 'E: Unable to locate package tmux'+ );+ });+});++describe('condenseCommandOutput', () => {+ it('keeps the final state of a redrawn progress line, not every frame', () => {+ const raw = '0% [Working]\r50% [Working]\r100% [Working]\nFetched 6649 B\n';++ expect(condenseCommandOutput(raw)).toBe('100% [Working]\nFetched 6649 B');+ });++ it('drops the blank padding apt uses to erase the previous frame', () => {+ const raw = '0% [Waiting for headers]\r \rHit:7 security.ubuntu.com\n';++ expect(condenseCommandOutput(raw)).toBe('Hit:7 security.ubuntu.com');+ });++ it('keeps the error, which is what the user is looking for', () => {+ const raw =+ '0% [Waiting]\r0% [Waiting]\r \rReading package lists... Done\n' ++ 'E: Could not get lock /var/lib/dpkg/lock-frontend\n';++ expect(condenseCommandOutput(raw)).toBe(+ 'Reading package lists... Done\nE: Could not get lock /var/lib/dpkg/lock-frontend'+ );+ });++ it('leaves output with no redraws alone', () => {+ expect(condenseCommandOutput('line one\nline two')).toBe('line one\nline two');+ });+});diff --git a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/step-outcomes.ts b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/step-outcomes.tsindex 9e3466bca..74efdc144 100644--- a/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/step-outcomes.ts+++ b/dash/apps/switchdash-desktop/src/main/core/remote-hosts/setup/step-outcomes.ts@@ -36,6 +36,52 @@ export function outcomeForDependency(return { outcome: 'unknown', version: state.version, error: state.error };}+/**+ * Collapse a terminal transcript down to what a human would read.+ *+ * `apt-get` redraws a progress line with carriage returns hundreds of times;+ * captured verbatim that is a wall of `0% [Waiting for headers]` with the one+ * line that matters at the very bottom. Keep the last state of each redrawn+ * line rather than every frame of it.+ */+export function condenseCommandOutput(raw: string): string {+ return raw+ .split('\n')+ .map(+ (line) =>+ line+ .split('\r')+ .filter((frame) => frame.trim().length > 0)+ .pop() ?? ''+ )+ .filter((line) => line.trim().length > 0)+ .join('\n');+}++/** Package managers refusing because another one holds the lock. */+const PACKAGE_MANAGER_BUSY =+ /could not get lock|unable to acquire the dpkg frontend lock|waiting for cache lock|another process using it/i;++/**+ * Explain why an install failed, in terms the user can act on.+ *+ * The lock case is worth naming: on a fresh Ubuntu host the distro's own+ * automatic-updates timer holds the dpkg lock for the first minutes after boot,+ * so an install fails through no fault of the user's and succeeds on retry. Raw+ * apt output does not say that — it says `E: Could not get lock`, buried under+ * a screen of progress redraws.+ */+export function describeInstallFailure(+ name: string,+ message: string,+ output: string | null+): string {+ if (PACKAGE_MANAGER_BUSY.test(message) || (output && PACKAGE_MANAGER_BUSY.test(output))) {+ return `Could not install ${name}: another process on the host is using the package manager — usually the system's own automatic updates. It normally clears within a few minutes; retry then.`;+ }+ return message;+}+/*** Translate a probed GitHub login into an observation.*diff --git a/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/host-status.test.ts b/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/host-status.test.tsindex 766063f70..a8699d70f 100644--- a/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/host-status.test.ts+++ b/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/host-status.test.ts@@ -56,14 +56,25 @@ describe('deriveHostStatus', () => {expect(isHostUsable(status)).toBe(true);});- it('does not count optional steps against readiness', () => {+ it('does not hold an outstanding optional step against the verdict', () => {const status = deriveHostStatus(reachability('reachable'),plan([step('git', 'satisfied'), step('gh', 'pending', true)]));expect(status.kind).toBe('ready');- expect(status.total).toBe(1);+ });++ it('counts every step shown, so the tally cannot contradict the list', () => {+ // A count that quietly excluded optional steps is how a host came to read+ // "5 of 5 required" with two rows plainly saying Not installed.+ const status = deriveHostStatus(+ reachability('reachable'),+ plan([step('git', 'satisfied'), step('gh', 'pending', true)])+ );++ expect(status.done).toBe(1);+ expect(status.total).toBe(2);});describe('readiness is withheld when the host cannot be reached', () => {diff --git a/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/host-status.ts b/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/host-status.tsindex 9858d6ae9..1f26287e8 100644--- a/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/host-status.ts+++ b/dash/apps/switchdash-desktop/src/shared/core/remote-hosts/host-status.ts@@ -45,7 +45,14 @@ export type HostStatus = {* the setup state we hold may be stale and must not be presented as current.*/readinessKnown: boolean;- /** Required steps satisfied / total, when readiness is known. */+ /**+ * Steps satisfied / total, counting everything the page lists.+ *+ * Deliberately not "required only": a count that silently excludes optional+ * steps cannot be reconciled with the list beside it, which is how a host+ * came to read "5 of 5 required" with two rows plainly saying *Not+ * installed*. The verdict below still turns on required steps alone.+ */done: number;total: number;};@@ -87,9 +94,8 @@ export function deriveHostStatus(};}- const required = plan.steps.filter((step) => !step.optional);- const total = required.length;- const done = required.filter((step) => step.state === 'satisfied').length;+ const total = plan.steps.length;+ const done = plan.steps.filter((step) => step.state === 'satisfied').length;// Work in flight lives on the step, not the plan: there is no automated run// to be "running", only whatever the user asked for a moment ago.