summaryrefslogtreecommitdiffhomepage
path: root/packages/core/src/credentials
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-06-02 21:10:09 +0900
committerAdam Malczewski <[email protected]>2026-06-02 21:10:09 +0900
commitd9f53727845dface3e6d8a84ba2270b1de55482b (patch)
tree6d42f0a0fbda15057296992e78c4b4e12046f9ed /packages/core/src/credentials
parent80212bfb009eaf71a4743310dee6ed08b8f7e1da (diff)
parent9d8cf7005ba4c0bb8ade0775f54c2557aa1c5683 (diff)
downloaddispatch-d9f53727845dface3e6d8a84ba2270b1de55482b.tar.gz
dispatch-d9f53727845dface3e6d8a84ba2270b1de55482b.zip
Merge branch 'dev' into feat/cs-code-search-tool
# Conflicts: # packages/api/src/agent-manager.ts # packages/api/tests/agent-manager.test.ts # packages/frontend/src/lib/components/ToolPermissions.svelte # packages/frontend/src/lib/settings.svelte.ts
Diffstat (limited to 'packages/core/src/credentials')
-rw-r--r--packages/core/src/credentials/claude.ts17
-rw-r--r--packages/core/src/credentials/index.ts1
2 files changed, 18 insertions, 0 deletions
diff --git a/packages/core/src/credentials/claude.ts b/packages/core/src/credentials/claude.ts
index 432e403..7818222 100644
--- a/packages/core/src/credentials/claude.ts
+++ b/packages/core/src/credentials/claude.ts
@@ -483,6 +483,23 @@ export const ANTHROPIC_MODELS_FALLBACK = [
"claude-3-opus-20240229",
];
+/**
+ * Pick the model to use for a Claude "wake" probe from a list of model ids.
+ *
+ * The probe only needs a small/cheap model to register activity against the
+ * subscription, so we target Haiku. Model ids change over time (the old
+ * hardcoded `claude-3-5-haiku-20241022` started returning HTTP 404), so the
+ * caller fetches the live list from `/v1/models` and we resolve by substring.
+ *
+ * Selection: the FIRST id whose name contains "haiku" (case-insensitive).
+ * Anthropic's `/v1/models` returns models newest-first, so first-match
+ * naturally prefers the newest Haiku. Returns `null` when nothing matches so
+ * the caller can surface a clear error instead of probing an invalid model.
+ */
+export function selectHaikuModel(models: string[]): string | null {
+ return models.find((id) => id.toLowerCase().includes("haiku")) ?? null;
+}
+
// ─── Credential Validation ────────────────────────────────────
export interface ClaudeProfile {
diff --git a/packages/core/src/credentials/index.ts b/packages/core/src/credentials/index.ts
index 46fa5b6..5221dc6 100644
--- a/packages/core/src/credentials/index.ts
+++ b/packages/core/src/credentials/index.ts
@@ -24,6 +24,7 @@ export {
refreshAccountCredentials,
refreshAccountCredentialsAsync,
SYSTEM_IDENTITY,
+ selectHaikuModel,
validateAccountCredentials,
} from "./claude.js";
export {