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(console): an agent's settings agree with Add agent on whether its provider is ready
raullopez-sandboxa4df965ac448
diff --git a/console/apps/switch-console-desktop/src/main/core/agents/agent-model-catalogue.test.ts b/console/apps/switch-console-desktop/src/main/core/agents/agent-model-catalogue.test.tsindex c2e2b0254..71155be8f 100644--- a/console/apps/switch-console-desktop/src/main/core/agents/agent-model-catalogue.test.ts+++ b/console/apps/switch-console-desktop/src/main/core/agents/agent-model-catalogue.test.ts@@ -1,3 +1,4 @@+import { homedir } from 'node:os';import { beforeEach, expect, it, vi } from 'vitest';const mocks = vi.hoisted(() => ({@@ -114,3 +115,18 @@ it('asks the sign-in check first for a provider whose session start may sign in'expect(catalogue).toEqual({ kind: 'unavailable', reason: 'Sign in first.' });expect(hostModes()).toEqual(['--probe']);});++it('checks this computer from home when the directory asked about does not exist yet', async () => {+ mocks.locate.mockResolvedValue({+ ctx: { exec: mocks.exec, dispose: mocks.dispose },+ entrypoint: '/home/me/.local/state/switch/sdk-host/shared-host-a.mjs',+ });++ const readiness = await getProviderReadiness(+ { providerId: 'claude', sshHost: null, dir: '/nowhere/agents/not-made-yet' },+ false+ );++ expect(readiness).toMatchObject({ installed: true, status: 'authenticated' });+ expect(mocks.locate.mock.calls[0]?.[1]).toBe(homedir());+});diff --git a/console/apps/switch-console-desktop/src/main/core/agents/agent-model-catalogue.ts b/console/apps/switch-console-desktop/src/main/core/agents/agent-model-catalogue.tsindex 6df957eec..afd966bea 100644--- a/console/apps/switch-console-desktop/src/main/core/agents/agent-model-catalogue.ts+++ b/console/apps/switch-console-desktop/src/main/core/agents/agent-model-catalogue.ts@@ -1,3 +1,4 @@+import { stat } from 'node:fs/promises';import { homedir } from 'node:os';import { providerReadinessSchema } from '@switch-console/agent-providers';import type { LaunchProfileModel } from '@switch-console/core/agents/plugins';@@ -67,7 +68,8 @@ export async function getAgentModelCatalogue(params: {let ctx: IExecutionContext | null = null;try {- const host = await resolveHost(params.sshHost, params.dir);+ const dir = params.sshHost || (await isDirectory(params.dir)) ? params.dir : homedir();+ const host = await resolveHost(params.sshHost, dir);ctx = host.ctx;const cli = await resolveAgentExecutable({@@ -144,6 +146,9 @@ export async function getProviderReadiness(models: boolean) {params = { ...params, dir: params.dir.trim() || (params.sshHost ? '.' : homedir()) };+ // The CLI and its sign-in do not depend on the directory, and one not made yet+ // (a managed agent's workspace before its first session) read as the CLI missing.+ if (!params.sshHost && !(await isDirectory(params.dir))) params = { ...params, dir: homedir() };let installed: boolean | null = null;let ctx: IExecutionContext | undefined;if (!params.sshHost) ensureUserBinDirsInPath();@@ -196,3 +201,11 @@ export async function getProviderReadiness(ctx?.dispose();}}++async function isDirectory(path: string): Promise<boolean> {+ try {+ return (await stat(path)).isDirectory();+ } catch {+ return false;+ }+}diff --git a/console/apps/switch-console-desktop/src/renderer/features/managed-agents/catalogue-as-reported.test.ts b/console/apps/switch-console-desktop/src/renderer/features/managed-agents/catalogue-as-reported.test.tsnew file mode 100644index 000000000..3b2280296--- /dev/null+++ b/console/apps/switch-console-desktop/src/renderer/features/managed-agents/catalogue-as-reported.test.ts@@ -0,0 +1,39 @@+import { describe, expect, it } from 'vitest';+import { catalogueAsReported } from './catalogue-as-reported';++const models = {+ kind: 'available' as const,+ models: [{ id: 'gpt-6-sol', name: 'GPT-6-Sol', variants: [] }],+};++describe('catalogueAsReported', () => {+ it('says what the machine reports when its provider is not ready', () => {+ expect(+ catalogueAsReported(models, 'FHXDK633MX', 'codex', { ready: false, problem: 'not signed in' })+ ).toEqual({+ kind: 'unavailable',+ reason: 'FHXDK633MX reports codex not signed in. You can enter a model ID.',+ });+ });++ it('does not call a provider the machine reports ready missing', () => {+ const outcome = catalogueAsReported(+ {+ kind: 'unavailable',+ reason: 'Codex is not installed or its selected executable cannot be found.',+ },+ 'FHXDK633MX',+ 'codex',+ { ready: true, problem: null }+ );+ expect(outcome?.kind).toBe('unavailable');+ expect(outcome && 'reason' in outcome ? outcome.reason : '').toMatch(+ /^FHXDK633MX reports codex ready/+ );+ });++ it('keeps the models when both agree, or the machine has not reported', () => {+ expect(catalogueAsReported(models, 'm', 'codex', { ready: true, problem: null })).toBe(models);+ expect(catalogueAsReported(models, 'm', 'codex', undefined)).toBe(models);+ });+});diff --git a/console/apps/switch-console-desktop/src/renderer/features/managed-agents/catalogue-as-reported.ts b/console/apps/switch-console-desktop/src/renderer/features/managed-agents/catalogue-as-reported.tsnew file mode 100644index 000000000..529a4e40d--- /dev/null+++ b/console/apps/switch-console-desktop/src/renderer/features/managed-agents/catalogue-as-reported.ts@@ -0,0 +1,25 @@+import type { ModelCatalogueResult } from '@renderer/features/locations/components/agent-model-catalogue';++/**+ * The models asked of the machine from here, squared with what the machine+ * itself reports of the provider: that report is what the agent runs on and+ * what Add agent showed, so a check from here that disagrees does not overrule it.+ */+export function catalogueAsReported(+ asked: ModelCatalogueResult | undefined,+ machineName: string,+ provider: string,+ reported: { ready: boolean; problem: string | null } | undefined+): ModelCatalogueResult | undefined {+ if (reported && !reported.ready)+ return {+ kind: 'unavailable',+ reason: `${machineName} reports ${provider} ${reported.problem ?? 'not ready'}. You can enter a model ID.`,+ };+ if (asked?.kind === 'unavailable' && reported?.ready)+ return {+ kind: 'unavailable',+ reason: `${machineName} reports ${provider} ready, but its models could not be listed from here (${asked.reason}). You can enter a model ID.`,+ };+ return asked;+}diff --git a/console/apps/switch-console-desktop/src/renderer/features/managed-agents/managed-agent-page.tsx b/console/apps/switch-console-desktop/src/renderer/features/managed-agents/managed-agent-page.tsxindex c0d4cd2b8..8346fb9b4 100644--- a/console/apps/switch-console-desktop/src/renderer/features/managed-agents/managed-agent-page.tsx+++ b/console/apps/switch-console-desktop/src/renderer/features/managed-agents/managed-agent-page.tsx@@ -55,6 +55,7 @@ import {isValidProviderId,providerDisplayName,} from '@shared/core/providers/agent-provider-registry';+import { catalogueAsReported } from './catalogue-as-reported';import { InlineEditableText } from './inline-editable-text';import {type Draft,@@ -535,7 +536,12 @@ function useHostCatalogue();if (query.error)return unavailable(failureText(query.error, 'The machine’s models could not be read.'));- return query.data;+ return catalogueAsReported(+ query.data,+ agent.machine.name,+ agent.definition.provider,+ machine.providers.find((entry) => entry.provider === providerId)+ );}/** A disabled control, with why it is disabled on hover. A span carries the tooltip: a disabled button emits no pointer events. */