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
Keep switch-buddy's template and what Console assumes of it in step
Simon Flack513545c3b86d
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-buddy/switch-buddy-drift.test.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-buddy/switch-buddy-drift.test.tsnew file mode 100644index 000000000..7671efec3--- /dev/null+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-buddy/switch-buddy-drift.test.ts@@ -0,0 +1,85 @@+/**+ * What Switch Console assumes about switch-buddy's template, which the server+ * ships: kept equal here, so a change on one side that the other does not+ * follow fails a test rather than a person's onboarding.+ */+import { readFileSync } from 'node:fs';+import { join } from 'node:path';+import { PROVIDER_RUNTIMES } from '@switch-console/agent-providers';+import { load } from 'js-yaml';+import { beforeEach, describe, expect, it, vi } from 'vitest';+import { BUDDY_ICON_URL } from '@shared/core/agents/switch-buddy';++const runTemplateDocument = vi.hoisted(() => vi.fn());+const report = vi.hoisted(() => vi.fn());+vi.mock('@renderer/lib/ipc', () => ({+ rpc: {+ managedAgents: { list: async () => [] },+ workspaces: {+ getTemplateDetail: async () => ({ name: 'switch-buddy', definition: 'version: 2' }),+ runTemplateDocument,+ },+ },+}));+vi.mock('@renderer/lib/telemetry/report', () => ({ report }));+vi.mock('@renderer/features/workspaces/workspaces-store', () => ({+ workspacesStore: { idOnServerInScope: () => 'ws-1' },+}));++const { createBuddy } = await import('./create-buddy');+const { reportBuddyStep } = await import('./buddy-telemetry');++type BuddyTemplate = {+ params: Record<string, unknown>;+ resources: { buddy: { icon_url: string } };+};++const template = load(+ readFileSync(+ join(+ __dirname,+ '../../../../../../../core/switch_core/official_templates/switch-buddy/template.yaml'+ ),+ 'utf8'+ )+) as BuddyTemplate;++beforeEach(() => {+ vi.clearAllMocks();+});++describe("switch-buddy's template, as Console uses it", () => {+ it('carries the icon Console shows its bundled copy for', () => {+ expect(template.resources.buddy.icon_url).toBe(BUDDY_ICON_URL);+ });++ it('declares every input Console fills when it creates the buddy', async () => {+ runTemplateDocument.mockResolvedValue({+ kind: 'created',+ createdAgents: [{ agentId: 'a-1', name: 'switch-buddy-max' }],+ });++ await createBuddy({+ serverId: 'srv-1',+ workspaceId: 'ws-1',+ machineId: 'm-1',+ provider: 'claude',+ person: { name: 'Max', email: null },+ entryPoint: 'onboarding',+ });++ const sent = Object.keys(runTemplateDocument.mock.calls[0]![1].inputs);+ expect(sent.length).toBeGreaterThan(0);+ // The server refuses an input the template does not declare, and with it+ // the whole buddy.+ expect(sent.filter((name) => !(name in template.params))).toEqual([]);+ });++ it("reports every provider Console runs by its own name in the buddy's telemetry", () => {+ for (const runtime of PROVIDER_RUNTIMES) reportBuddyStep('start', runtime.id);++ expect(report.mock.calls.map(([, payload]) => payload.provider)).toEqual(+ PROVIDER_RUNTIMES.map((runtime) => runtime.id)+ );+ });+});diff --git a/core/tests/switch_core/test_official_templates.py b/core/tests/switch_core/test_official_templates.pyindex c604bcbc2..bd99f4a54 100644--- a/core/tests/switch_core/test_official_templates.py+++ b/core/tests/switch_core/test_official_templates.py@@ -16,6 +16,7 @@ from switch_core.official_templates import (released_agent_fingerprints,revisions,)+from switch_core.providers.registry import provider_idsfrom switch_core.template_installs import fingerprints, render_agentsfrom switch_core.template_lint import lint_template@@ -203,3 +204,23 @@ def test_released_fingerprints_list_every_revision_newest_first():range(current_revision("switch-buddy"), 0, -1))assert all("buddy" in agents for _, agents in released)+++def test_switch_buddy_offers_every_provider_switch_runs():+ """The template's provider param lists the providers to try in order; a+ provider added to Switch and not to it is one buddy is never created+ with outside Switch Console, which always names one."""+ template = yaml.safe_load(+ (_PACKAGED / "switch-buddy" / "template.yaml").read_text(encoding="utf-8")+ )+ assert sorted(template["params"]["provider"]["default"]) == sorted(provider_ids())+++def test_switch_buddy_declares_the_inputs_switch_console_fills():+ """Switch Console fills these when it creates a buddy (create-buddy.ts),+ and the server refuses an input a template does not declare: dropping or+ renaming one stops every Console that sends it from creating a buddy."""+ template = yaml.safe_load(+ (_PACKAGED / "switch-buddy" / "template.yaml").read_text(encoding="utf-8")+ )+ assert {"agent_name", "provider", "machine"} <= set(template["params"])