Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.
JavaScript agent-collaborationagent-harnessagent-orchestrationagent-teamagent-workflowai-assistantai-automationai-employeeai-productivityai-teamai-workflowautonomous-agentsclaude-code-guiclaude-coworkdesktop-agentlocal-firstmulti-agentmulti-agent-systemself-evolving-agentstask-automation
Realign tests with current spec for catalog, auth ordering, and session healing
wyte349bab76cf6
diff --git a/src/core-agent/test/evolution.test.ts b/src/core-agent/test/evolution.test.tsindex b90438f6..359d8448 100644--- a/src/core-agent/test/evolution.test.ts+++ b/src/core-agent/test/evolution.test.ts@@ -584,9 +584,12 @@ describe("Evolution: AgentRunner integration", () => {const evaluation = runner.evaluateReflection(result);expect(evaluation).not.toBeNull();expect(evaluation!.primaryFocus).toBe("error_recovery");+ // Adaptive review prompt is now English-headed (`buildAdaptiveReviewPrompt`+ // in metacognition.ts), but `buildConversationDigest` still emits zh+ // lines (`结果: 从错误中恢复,任务完成` etc.) in the body. Assert both:+ // the English head + the zh recovery line + the user-supplied result.text.+ expect(evaluation!.prompt).toContain("conversation digest");expect(evaluation!.prompt).toContain("从错误中恢复");- // Should include conversation digest with context- expect(evaluation!.prompt).toContain("对话摘要");expect(evaluation!.prompt).toContain("Task completed");});diff --git a/src/core-agent/test/persistent-session.test.ts b/src/core-agent/test/persistent-session.test.tsindex f2f9bd3b..1e051e7e 100644--- a/src/core-agent/test/persistent-session.test.ts+++ b/src/core-agent/test/persistent-session.test.ts@@ -3,6 +3,7 @@ import fs from "node:fs";import os from "node:os";import path from "node:path";import { PersistentSession } from "../src/agent/persistent-session.js";+import type { MessageContent } from "../src/shared/types.js";// Mirrors the constant in persistent-session.ts; kept inline (not exported)// so the heal contract is testable without leaking an internal sentinel.@@ -108,17 +109,58 @@ describe("PersistentSession", () => {expect(fs.statSync(file).size).toBe(0);});- it("tool result messages round-trip", () => {+ it("paired tool_use + tool_result round-trip through reload", () => {+ // 验证 valid pair 完整保留:assistant.tool_use 后接 user.tool_result。+ // 这是 healOrphanToolUses 不会动的 happy path。const s1 = new PersistentSession({ sessionFile: file });+ s1.addAssistantMessage([+ { type: "tool_use", id: "call-123", name: "test_tool", input: {} } as MessageContent,+ ]);s1.addToolResult("call-123", "tool output", undefined, false);const s2 = new PersistentSession({ sessionFile: file });- expect(s2.length).toBe(1);- const c = s2.getMessages()[0].content[0];+ expect(s2.length).toBe(2);+ const toolResultMsg = s2.getMessages()[1];+ expect(toolResultMsg.role).toBe("user");+ const c = toolResultMsg.content[0];expect(c.type).toBe("tool_result");expect((c as { toolUseId: string }).toolUseId).toBe("call-123");});+ it("orphan tool_result (no preceding tool_use) is dropped at load", () => {+ // 锁住 `4773be73` 修的不变量:孤儿 tool_result 在 load 时被+ // healOrphanToolUses 丢弃。否则下一次 provider 调用会被拒+ // ("No tool call found for function call output with call_id ...")。+ // 之前生产报这个错频繁,fix 是在 load 时主动清理;这条测试守住"清"+ // 这个动作不能被未来的重构撤回。+ const s1 = new PersistentSession({ sessionFile: file });+ s1.addToolResult("call-orphan", "tool output", undefined, false);+ expect(s1.length).toBe(1); // 写入时不拦,刚 add 还在内存里++ const s2 = new PersistentSession({ sessionFile: file });+ expect(s2.length).toBe(0); // load 时 healOrphanToolUses 把它丢了+ });++ it("orphan tool_result mixed with valid pair: orphan dropped, pair kept", () => {+ // 一条 user 消息可以同时携带多个 tool_result block——只丢孤儿那个,+ // 不要把整条 message 全删掉(否则会误伤同 message 里的合法 result)。+ const s1 = new PersistentSession({ sessionFile: file });+ s1.addAssistantMessage([+ { type: "tool_use", id: "call-good", name: "t1", input: {} } as MessageContent,+ ]);+ // 手工拼一条同时包含合法 + 孤儿两个 tool_result 的 user 消息+ s1.addMessage("user", [+ { type: "tool_result", toolUseId: "call-good", content: "ok", isError: false } as MessageContent,+ { type: "tool_result", toolUseId: "call-orphan", content: "stray", isError: false } as MessageContent,+ ]);++ const s2 = new PersistentSession({ sessionFile: file });+ expect(s2.length).toBe(2);+ const blocks = s2.getMessages()[1].content;+ expect(blocks).toHaveLength(1);+ expect((blocks[0] as { toolUseId: string }).toolUseId).toBe("call-good");+ });+it("creates parent directories if missing", () => {const nested = path.join(os.tmpdir(), `core-agent-psess-${Date.now()}`, "sub", "dir", "chat.jsonl");try {diff --git a/test/main/features/auth.test.ts b/test/main/features/auth.test.tsindex df51cda4..fd248fd8 100644--- a/test/main/features/auth.test.ts+++ b/test/main/features/auth.test.ts@@ -62,21 +62,25 @@ describe('auth › maskKey', () => {describe('auth › FEATURED_PROVIDERS', () => {it('lists the curated API-key providers in CATALOG order', async () => {const a = await import('../../../src/main/features/auth');- // Global frontier labs → China mainstream → aggregators. Must match- // `CATALOG` in provider_catalog.ts (minus `oauthOnly: true` entries).+ // DeepSeek 直连先(pi-ai 不带,自建适配)→ 全球前沿 OpenAI / Google /+ // Anthropic(去掉 oauthOnly 的 OpenAI Codex)→ CN 主流(Zhipu / Moonshot+ // / Kimi-Coding / MiniMax / Doubao;去掉 oauthOnly 的 minimax-portal*)+ // → 聚合器 OpenRouter。必须严格跟 CATALOG 对齐(减 oauthOnly 项)。expect(a.FEATURED_PROVIDERS).toEqual([- 'anthropic',+ 'deepseek','openai','google',+ 'anthropic','zai','moonshot','kimi-coding','minimax-cn',+ 'doubao','openrouter',]);- // minimax-portal / minimax-portal-cn are oauthOnly and excluded from- // the API-key docs list (FEATURED_PROVIDERS). They still appear in- // CATALOG / VISIBLE_PROVIDERS.+ // openai-codex / minimax-portal / minimax-portal-cn are oauthOnly and+ // excluded from the API-key docs list (FEATURED_PROVIDERS). They still+ // appear in CATALOG / VISIBLE_PROVIDERS.});});@@ -162,11 +166,14 @@ describe('auth › multi-profile store (addApiKey / removeCredential / renameProdescribe('auth › listProviders grouping', () => {it('returns providers in catalog order regardless of insertion order', async () => {const a = await import('../../../src/main/features/auth');- await a.addApiKey('openai', 'k-xxxxxxxxxxxx');+ // 插入顺序:anthropic → openai。CATALOG 顺序:openai 在 anthropic 之前。+ // listProviders 必须按 CATALOG 排,所以即便先插 anthropic、再插 openai,+ // 也要 openai.indexOf < anthropic.indexOf(CATALOG 排序压过插入顺序)。await a.addApiKey('anthropic', 'k-xxxxxxxxxxxx');+ await a.addApiKey('openai', 'k-xxxxxxxxxxxx');const { providers } = await a.listProviders();const ids = providers.map((p) => p.id);- expect(ids.indexOf('anthropic')).toBeLessThan(ids.indexOf('openai'));+ expect(ids.indexOf('openai')).toBeLessThan(ids.indexOf('anthropic'));});it('exposes supportsApiKey / supportsOAuth flags consistent with the catalog', async () => {diff --git a/test/main/features/image_gen.test.ts b/test/main/features/image_gen.test.tsindex adccb8f0..8bda6611 100644--- a/test/main/features/image_gen.test.ts+++ b/test/main/features/image_gen.test.ts@@ -123,7 +123,7 @@ describe('image_gen › pickImageGenProfile', () => {expect(picked).not.toBeNull();expect(picked!.entry.provider).toBe('openai');expect(picked!.entry.apiKey).toBe('sk-openai-xxx');- expect(picked!.capability.model).toBe('gpt-image-1');+ expect(picked!.capability.model).toBe('gpt-image-2');expect(picked!.capability.api).toBe('openai');});@@ -144,7 +144,7 @@ describe('image_gen › pickImageGenProfile', () => {const m = await import('../../../src/main/features/image_gen');const picked = m.pickImageGenProfile();expect(picked!.entry.profileId).toBe('google:studio');- expect(picked!.capability.model).toBe('gemini-2.5-flash-image-preview');+ expect(picked!.capability.model).toBe('gemini-3.1-flash-image-preview');expect(picked!.capability.api).toBe('gemini');});});diff --git a/test/main/features/search/index.test.ts b/test/main/features/search/index.test.tsindex 5f651a64..8eed1704 100644--- a/test/main/features/search/index.test.ts+++ b/test/main/features/search/index.test.ts@@ -186,9 +186,11 @@ describe('search › re-exports from indexer', () => {expect(typeof s.upsertContext).toBe('function');expect(typeof s.dropContext).toBe('function');expect(typeof s.indexChatMessage).toBe('function');- expect(typeof s.indexSkillChatMessage).toBe('function');- expect(typeof s.indexAgentChatMessage).toBe('function');expect(typeof s.dropChatConversation).toBe('function');expect(typeof s.flushAll).toBe('function');+ // skill / agent chat-message indexers were removed alongside the+ // skill_chats / agent_chats search scopes (see `_unlinkLegacyIndexes`).+ // Don't add assertions for them back — those scopes are intentionally+ // out of search.});});diff --git a/test/main/features/search/indexer.test.ts b/test/main/features/search/indexer.test.tsindex 5c21742d..6df60965 100644--- a/test/main/features/search/indexer.test.ts+++ b/test/main/features/search/indexer.test.ts@@ -43,12 +43,6 @@ function writeChat(uid: string, cid: string, messages: unknown[]): void {fs.writeFileSync(file, messages.map((m) => JSON.stringify(m)).join('\n') + '\n');}-function writeSkillChat(uid: string, sid: string, messages: unknown[]): void {- const dir = path.join(tmpDir, uid, 'cloud', 'chats', 'skill', sid);- fs.mkdirSync(dir, { recursive: true });- fs.writeFileSync(path.join(dir, 'chat.jsonl'), messages.map((m) => JSON.stringify(m)).join('\n') + '\n');-}-describe('search/indexer › reconcileContextsIndex', () => {it('returns silently when CONTEXTS_DIR is missing', async () => {const ix = await loadIndexer();@@ -237,16 +231,18 @@ describe('search/indexer › upsertContext / dropContext', () => {});});-describe('search/indexer › reconcileSkillChatsIndex', () => {- it('indexes per-skill chat.jsonl files', async () => {- writeSkillChat('u1', 's1', [{ role: 'user', content: 'skill keyword', time: 't' }]);- writeSkillChat('u1', 's2', [{ role: 'assistant', content: 'another skill', time: 't' }]);+// 锁住 `9529d52c` 改的 spec:技能编辑 / 智能体编辑会话**不**进 search 索引。+// 之前老版本有 reconcileSkillChatsIndex / reconcileAgentChatsIndex 会按 skill_id+// 建索引,现在被剔除——search 只索引 contexts + 主对话 + agent/skill 本体规格。+// 下次如有人把这两条索引函数复活,或者新人改 reconcileAll 时不小心把 skill_chats+// 加回扫描列表,这里负责拦截。+describe('search/indexer › skill / agent edit chats are out of search scope', () => {+ it('does not expose `reconcileSkillChatsIndex` / `reconcileAgentChatsIndex`', async () => {const ix = await loadIndexer();- await ix.reconcileSkillChatsIndex('u1');- const paths = await import('../../../../src/main/paths');- const entry = await ix.getEntry(paths.userSkillChatsIndexPath('u1'), 'skill_chat');- expect(Object.keys(entry.idx.files).sort()).toEqual(['s1', 's2']);- expect(entry.idx.docs['skill_chat:s1:0']).toMatchObject({ skill_id: 's1' });+ expect((ix as Record<string, unknown>).reconcileSkillChatsIndex).toBeUndefined();+ expect((ix as Record<string, unknown>).reconcileAgentChatsIndex).toBeUndefined();+ expect((ix as Record<string, unknown>).indexSkillChatMessage).toBeUndefined();+ expect((ix as Record<string, unknown>).indexAgentChatMessage).toBeUndefined();});});diff --git a/test/main/model/provider_catalog.test.ts b/test/main/model/provider_catalog.test.tsindex eabe31d3..0676a69d 100644--- a/test/main/model/provider_catalog.test.ts+++ b/test/main/model/provider_catalog.test.ts@@ -20,18 +20,22 @@ describe('provider_catalog › CATALOG', () => {it('holds unique provider ids in display order', () => {const ids = CATALOG.map((p) => p.id);expect(new Set(ids).size).toBe(ids.length);- // Global frontier labs first, then CN mainstream, then aggregators.+ // DeepSeek 直连先(pi-ai 不带,自建适配),然后全球前沿(OpenAI Codex /+ // OpenAI / Google / Anthropic),CN 主流(Zhipu / Moonshot / Kimi-Coding /+ // MiniMax × 3 / Doubao),最后聚合器(OpenRouter)。expect(ids).toEqual([- 'anthropic',+ 'deepseek','openai-codex','openai','google',+ 'anthropic','zai','moonshot','kimi-coding','minimax-portal','minimax-portal-cn','minimax-cn',+ 'doubao','openrouter',]);});@@ -59,6 +63,7 @@ describe('provider_catalog › CATALOG', () => {'minimax-portal','minimax-portal-cn','minimax-cn',+ 'doubao',]);});@@ -145,18 +150,19 @@ describe('provider_catalog › labels and docs', () => {it('providerSubscriptionNote 在两条 Moonshot endpoint 上都给出明确前提', () => {// 用户反馈:开放平台按量付费和 Moonshot Coding Plan 订阅是两套独立账户,// 一张 key 不能两边通用。UI 必须在卡片/表单上把前提标清楚。- const moonshotNote = providerSubscriptionNote('moonshot');- const codingNote = providerSubscriptionNote('kimi-coding');- expect(moonshotNote).toMatch(/开放平台/);- expect(moonshotNote).toMatch(/按量|付费/);- expect(codingNote).toMatch(/Coding Plan/);- expect(codingNote).toMatch(/订阅|月付/);+ // catalog 把前提存成 i18n key(renderer 端 t() 翻译),这里验 key 命名+ // 语义自带"paygo / subscription"区分,避免上线时两条混淆。+ expect(providerSubscriptionNote('moonshot')).toBe('provider.moonshot.note_paygo');+ expect(providerSubscriptionNote('kimi-coding')).toBe('provider.kimi_coding.note_subscription');});- it('providerSubscriptionNote 对没前提要求的 provider 返 undefined', () => {+ it('providerSubscriptionNote 对没前提要求的 provider 返 undefined / 空串', () => {+ // anthropic / openai 没声明 subscriptionNote → undefined;+ // doubao 在 catalog 里显式写了空串占位 → 空串。两种都视为"无前提"。expect(providerSubscriptionNote('anthropic')).toBeUndefined();expect(providerSubscriptionNote('openai')).toBeUndefined();expect(providerSubscriptionNote('totally-unknown')).toBeUndefined();+ expect(providerSubscriptionNote('doubao') || undefined).toBeUndefined();});});@@ -166,7 +172,9 @@ describe('provider_catalog › EXTERNAL_API_PROVIDERS', () => {// `auth.ts::testConnection` 的分发依据——名单必须和 CATALOG 里真实// 标记为"外部"的 provider 严格一致,否则会出现"能选但调用报// No model found for provider"。- expect([...EXTERNAL_API_PROVIDERS]).toEqual(['moonshot']);+ // 当前外部适配层支持:moonshot(OpenAI 兼容 endpoint)+ deepseek(pi-ai+ // 0.68.1 不带)+ doubao(火山方舟)。+ expect([...EXTERNAL_API_PROVIDERS]).toEqual(['moonshot', 'deepseek', 'doubao']);});it('每个外部 provider 都在 CATALOG + CURATED_MODELS 有对应条目', () => {