Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
chore(ai): opus-4.5 -> opus-4.6 (#1404)
Eric Hayes3a5064e4d68b
diff --git a/.claude/skills/upgrade-model/SKILL.md b/.claude/skills/upgrade-model/SKILL.mdnew file mode 100644index 0000000000..f013f27293--- /dev/null+++ b/.claude/skills/upgrade-model/SKILL.md@@ -0,0 +1,136 @@+---+name: upgrade-model+description: Upgrade an AI chat model (fast or good) across backend and frontend.+allowed-tools: Bash, Read, Write, Edit, Grep, Glob+---++# Upgrade Chat Model++Upgrades the AI model used in the chat app. There are two model slots:+- **fast** (Enter): default/fallback model (first entry in `CHAT_MODELS`)+- **good** (Cmd+Enter): smart mode model (second entry in `CHAT_MODELS`)++The user must specify which slot to upgrade and the new model name (e.g. `claude-opus-4-6`).++## Steps++### 1. Determine the change++Ask the user (if not already provided):+- Which slot: `fast` or `good`?+- What is the new model name? (e.g. `claude-opus-4-6`)++Derive from the model name:+- `SERDE_NAME`: the kebab-case model ID sent over the wire (e.g. `claude-opus-4-6`)+- `ENUM_VARIANT`: PascalCase variant name (e.g. `Claude46Opus`)+- `CONST_NAME`: SCREAMING_SNAKE constant name (e.g. `CLAUDE_46_OPUS`)+- `CONST_VALUE`: display string used by the frontend/provider (e.g. `claude-4.6-opus`)+- `PRETTY_NAME`: human-readable name (e.g. `Claude Opus 4.6`)++### 2. Add model to AI crate (if it doesn't already exist)++File: `rust/cloud-storage/ai/src/types/model/mod.rs`++Check if the enum variant already exists. If not, add all of the following:++1. **Enum variant** in `pub enum Model` (under the Anthropic section):+ ```rust+ #[serde(rename = "{SERDE_NAME}")]+ #[strum(serialize = "{SERDE_NAME}")]+ {ENUM_VARIANT},+ ```++2. **String constant** in `pub mod constants::models`:+ ```rust+ pub const {CONST_NAME}: &str = "{CONST_VALUE}";+ ```++3. **Match arm** in `to_provider_model_string()`:+ ```rust+ Model::{ENUM_VARIANT} => (ANTHROPIC, {CONST_NAME}),+ ```++4. **Match arm** in `from_model_str()`:+ ```rust+ {CONST_NAME} => Model::{ENUM_VARIANT},+ ```++File: `rust/cloud-storage/ai/src/types/model/metadata.rs`++5. **Metadata** in `fn metadata()`:+ ```rust+ Model::{ENUM_VARIANT} => ModelMetadata {+ context_window: 200_000,+ },+ ```+ Use the correct context window for the model. Anthropic models are typically 200,000.++6. **Provider** in `fn provider()`:+ ```rust+ Model::{ENUM_VARIANT} => Provider::Anthropic,+ ```++### 3. Update DCS constants++File: `rust/cloud-storage/document_cognition_service/src/core/model.rs`++- If upgrading the **fast** slot: change the first entry in `CHAT_MODELS` and update `FALLBACK_MODEL`.+- If upgrading the **good** slot: change the second entry in `CHAT_MODELS`.++### 4. Update DCS chat message handler++File: `rust/cloud-storage/document_cognition_service/src/api/ws/chat_message/mod.rs`++Search for the old model variant being used in the model selection logic (e.g. `Model::Claude45Opus`). Update it to the new variant.++### 5. Verify Rust compiles++```bash+cd rust/cloud-storage && cargo check -p ai -p document_cognition_service+```++Fix any compilation errors before proceeding.++### 6. Generate frontend types++Run from `js/app/`:+```bash+cd js/app && bun install && bun run gen-api+```++This builds all Rust OpenAPI and models binaries from local code, generates `openapi.json`, runs orval for TypeScript types, and generates `model.ts` from the local models binary. All generated files will reflect your local Rust changes.++### 7. Run `bun check` to find frontend usages++```bash+cd js/app && bun check+```++This will report TypeScript errors everywhere the old model string is used. Fix each one. Common locations:++- `packages/core/component/AI/constant/model.ts` — `MODEL_PRETTYNAME`, `MODEL_PROVIDER_ICON`, `SMART_MODE_MODEL` / `DEFAULT_MODEL`+- `packages/core/component/AI/component/input/useChatInput.tsx` — hardcoded model references+- `packages/core/component/AI/signal/pendingSend.test.ts` — test data++Replace old model strings and update display names.++### 8. Format and verify++```bash+cd js/app && bun format && bun check+```++The only errors remaining should be **pre-existing** ones unrelated to models (e.g. `three`, `@aws-crypto/sha256-js` type issues). All model-related errors must be resolved.++Finally, run the CI check:+```bash+cd js/app && bun run gen-api -- --check+```++This must pass.++## Notes++- We only support Anthropic models for chat. Other providers exist in the AI crate but are not used for the chat feature.+- The `ExhaustiveMap` type in `constant/model.ts` requires an entry for every model in the `Model` type, so missing entries will cause type errors.+- The `SMART_MODE_MODEL` constant is the "good" model, `DEFAULT_MODEL` is the "fast" model.diff --git a/js/app/packages/core/component/AI/component/input/useChatInput.tsx b/js/app/packages/core/component/AI/component/input/useChatInput.tsxindex 79a7525c1e..d5f3aa9b38 100644--- a/js/app/packages/core/component/AI/component/input/useChatInput.tsx+++ b/js/app/packages/core/component/AI/component/input/useChatInput.tsx@@ -286,7 +286,7 @@ function ChatInput(props: ChatInputInternalProps) {<Match when={isTouchDevice()}><div class="flex flex-row gap-1 items-center shrink-0"><Show when={!generating()}>- <Button onClick={() => sendMessage('claude-opus-4-5')}>+ <Button onClick={() => sendMessage('claude-opus-4-6')}><div class="group hover:bg-accent transition ease-in-out size-6 p-[2px] border border-accent rounded-full flex items-center justify-center"><ArrowUp class="group-hover:!text-input group-hover:!fill-input !text-accent-ink !fill-accent size-4 transition ease-in-out" /></div>diff --git a/js/app/packages/core/component/AI/constant/model.ts b/js/app/packages/core/component/AI/constant/model.tsindex 993905a6df..5f07effe51 100644--- a/js/app/packages/core/component/AI/constant/model.ts+++ b/js/app/packages/core/component/AI/constant/model.ts@@ -16,15 +16,15 @@ type ExhaustiveMap = {// } as const;export const MODEL_PRETTYNAME: ExhaustiveMap = {- 'claude-opus-4-5': 'Claude Opus 4.5',+ 'claude-opus-4-6': 'Claude Opus 4.6','claude-haiku-4-5': 'Claude Haiku 4.5',} as const;export const MODEL_PROVIDER_ICON: ExhaustiveMap = {'claude-haiku-4-5': AnthropicIcon,- 'claude-opus-4-5': AnthropicIcon,+ 'claude-opus-4-6': AnthropicIcon,};-export const SMART_MODE_MODEL: Model = 'claude-opus-4-5';+export const SMART_MODE_MODEL: Model = 'claude-opus-4-6';export const DEFAULT_MODEL: Model = 'claude-haiku-4-5';diff --git a/js/app/packages/core/component/AI/signal/pendingSend.test.ts b/js/app/packages/core/component/AI/signal/pendingSend.test.tsindex 2ab59e44ed..27f4196b99 100644--- a/js/app/packages/core/component/AI/signal/pendingSend.test.ts+++ b/js/app/packages/core/component/AI/signal/pendingSend.test.ts@@ -50,7 +50,7 @@ describe('pendingSend signal', () => {created_at: '2025-01-01T00:00:00Z',} as any,],- model: 'claude-opus-4-5' as any,+ model: 'claude-opus-4-6' as any,};setPendingSendData(data);@@ -58,6 +58,6 @@ describe('pendingSend signal', () => {expect(result?.content).toBe('Message with attachment');expect(result?.attachments).toHaveLength(1);- expect(result?.model).toBe('claude-opus-4-5');+ expect(result?.model).toBe('claude-opus-4-6');});});diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/model.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/model.tsindex 472770efbe..df58b3cf9f 100644--- a/js/app/packages/service-clients/service-cognition/generated/schemas/model.ts+++ b/js/app/packages/service-clients/service-cognition/generated/schemas/model.ts@@ -8,12 +8,12 @@ export type Model = (typeof Model)[keyof typeof Model];export const Model = {'claude-haiku-4-5': 'claude-haiku-4-5',- 'claude-opus-4-5': 'claude-opus-4-5',+ 'claude-opus-4-6': 'claude-opus-4-6',} as const;export const AllModels: Model[] = ['claude-haiku-4-5',- 'claude-opus-4-5',+ 'claude-opus-4-6',] as const;const values: [Model, ...Model[]] = [Object.values(Model)[0],diff --git a/js/app/packages/service-clients/service-cognition/openapi.json b/js/app/packages/service-clients/service-cognition/openapi.jsonindex f1384e729f..19e631c481 100644--- a/js/app/packages/service-clients/service-cognition/openapi.json+++ b/js/app/packages/service-clients/service-cognition/openapi.json@@ -2460,7 +2460,8 @@"claude-sonnet-4","claude-sonnet-4-5","claude-haiku-4-5",- "claude-opus-4-5"+ "claude-opus-4-5",+ "claude-opus-4-6"]},"ModelMetadata": {diff --git a/js/app/scripts/generate-api-schema.ts b/js/app/scripts/generate-api-schema.tsindex 90c4ac3988..0f131c0aed 100644--- a/js/app/scripts/generate-api-schema.ts+++ b/js/app/scripts/generate-api-schema.ts@@ -36,6 +36,11 @@ async function buildOpenApiBinaries(crateNames: string[], rustCloudStorageDir =const packageArgs = crateNames.flatMap(crate => ['-p', crate]);const binArgs = crateNames.flatMap(crate => ['--bin', `${crate}_openapi`]);+ // Also build the DCS models binary if document_cognition_service is included+ if (crateNames.includes('document_cognition_service')) {+ binArgs.push('--bin', 'document_cognition_service_models');+ }+console.log(`Building ${crateNames.length} OpenAPI binaries in parallel...`);await $`cd ${rustCloudStorageDir} && SQLX_OFFLINE=true cargo build --release ${packageArgs} ${binArgs}`;console.log('Build complete.\n');@@ -48,6 +53,13 @@ async function runOpenApiBinary(crateName: string, rustCloudStorageDir = getRustreturn result;}+// Run a named binary from the release directory+async function runBinary(binaryName: string, rustCloudStorageDir = getRustCloudStorageDir()): Promise<string> {+ const binaryPath = path.join(rustCloudStorageDir, 'target', 'release', binaryName);+ const result = await $`${binaryPath}`.text();+ return result;+}+// Recursively sort all object keys in JSON to ensure deterministic outputfunction sortJsonKeys(obj: unknown): unknown {if (Array.isArray(obj)) {@@ -119,7 +131,18 @@ const processService = async (service: Service, { serviceClientsDir }: { service// Special handling for document-cognitionif (service.name === 'document-cognition') {- await $`cd ${path.resolve(import.meta.dirname, '..')} && bun scripts/generate-dcs-types.ts`.quiet();+ // Run the models binary to get the models JSON from local Rust code+ const rustCloudStorageDir = getRustCloudStorageDir();+ const modelsJson = await runBinary('document_cognition_service_models', rustCloudStorageDir);+ const modelsJsonPath = path.join(import.meta.dirname, '.models.json');+ await write(modelsJsonPath, modelsJson);++ const appDir = path.resolve(import.meta.dirname, '..');+ try {+ await $`cd ${appDir} && MODELS_JSON=${modelsJsonPath} bun scripts/generate-dcs-types.ts`.quiet();+ } finally {+ await $`rm -f ${modelsJsonPath}`.quiet();+ }}console.log(`[${service.name}] ✓ Done`);diff --git a/js/app/scripts/generate-dcs-models.ts b/js/app/scripts/generate-dcs-models.tsindex 3c1ce1cb0a..f09ff00639 100644--- a/js/app/scripts/generate-dcs-models.ts+++ b/js/app/scripts/generate-dcs-models.ts@@ -22,6 +22,14 @@ const ModelResponseSchema = z.object({type ModelResponse = z.infer<typeof ModelResponseSchema>;async function fetchModels(): Promise<ModelResponse> {+ // If MODELS_JSON env var is set, read from that file instead of fetching from a server+ const modelsFile = process.env.MODELS_JSON;+ if (modelsFile) {+ console.log(`Reading models from local file: ${modelsFile}`);+ const file = Bun.file(modelsFile);+ const json = await file.json();+ return ModelResponseSchema.parse(json);+ }const baseUrl = serviceUrl(documentCognitionBase)diff --git a/rust/cloud-storage/ai/src/types/model/metadata.rs b/rust/cloud-storage/ai/src/types/model/metadata.rsindex 93ebe1d855..577f6d64bb 100644--- a/rust/cloud-storage/ai/src/types/model/metadata.rs+++ b/rust/cloud-storage/ai/src/types/model/metadata.rs@@ -76,6 +76,9 @@ impl ModelWithMetadataAndProvider for Model {Model::Claude45Opus => ModelMetadata {context_window: 200_000,},+ Model::Claude46Opus => ModelMetadata {+ context_window: 200_000,+ },Model::Claude4Sonnet => ModelMetadata {context_window: 200_000,},@@ -110,6 +113,7 @@ impl ModelWithMetadataAndProvider for Model {Model::Claude45Sonnet => Provider::Anthropic,Model::Claude45Haiku => Provider::Anthropic,Model::Claude45Opus => Provider::Anthropic,+ Model::Claude46Opus => Provider::Anthropic,// XAI models //}}diff --git a/rust/cloud-storage/ai/src/types/model/mod.rs b/rust/cloud-storage/ai/src/types/model/mod.rsindex da8613b680..b4797ac0f4 100644--- a/rust/cloud-storage/ai/src/types/model/mod.rs+++ b/rust/cloud-storage/ai/src/types/model/mod.rs@@ -90,6 +90,10 @@ pub enum Model {#[serde(rename = "claude-opus-4-5")]#[strum(serialize = "claude-opus-4-5")]Claude45Opus,++ #[serde(rename = "claude-opus-4-6")]+ #[strum(serialize = "claude-opus-4-6")]+ Claude46Opus,}pub mod constants {@@ -113,6 +117,7 @@ pub mod constants {pub const CLAUDE_45_SONNET: &str = "claude-4.5-sonnet";pub const CLAUDE_45_HAIKU: &str = "claude-4.5-haiku";pub const CLAUDE_45_OPUS: &str = "claude-4.5-opus";+ pub const CLAUDE_46_OPUS: &str = "claude-4.6-opus";}/// String versions of providers@@ -145,6 +150,7 @@ impl Model {Model::Claude45Sonnet => (ANTHROPIC, CLAUDE_45_SONNET),Model::Claude45Haiku => (ANTHROPIC, CLAUDE_45_HAIKU),Model::Claude45Opus => (ANTHROPIC, CLAUDE_45_OPUS),+ Model::Claude46Opus => (ANTHROPIC, CLAUDE_46_OPUS),}}pub fn from_model_str(model: &str) -> Option<Self> {@@ -164,6 +170,7 @@ impl Model {CLAUDE_37_SONNET => Model::Claude37Sonnet,CLAUDE_45_SONNET => Model::Claude45Sonnet,CLAUDE_45_HAIKU => Model::Claude45Haiku,+ CLAUDE_46_OPUS => Model::Claude46Opus,_unknown => return None,})}diff --git a/rust/cloud-storage/document_cognition_service/Cargo.toml b/rust/cloud-storage/document_cognition_service/Cargo.tomlindex 0f7694bff4..da83194dcc 100644--- a/rust/cloud-storage/document_cognition_service/Cargo.toml+++ b/rust/cloud-storage/document_cognition_service/Cargo.toml@@ -17,6 +17,10 @@ path = "src/bin/backfill_search.rs"name = "document_cognition_service_openapi"path = "src/openapi.rs"+[[bin]]+name = "document_cognition_service_models"+path = "src/models_bin.rs"+[features]local = []local_queue = []diff --git a/rust/cloud-storage/document_cognition_service/src/api/ws/chat_message/mod.rs b/rust/cloud-storage/document_cognition_service/src/api/ws/chat_message/mod.rsindex bfd1fec862..5a5366de77 100644--- a/rust/cloud-storage/document_cognition_service/src/api/ws/chat_message/mod.rs+++ b/rust/cloud-storage/document_cognition_service/src/api/ws/chat_message/mod.rs@@ -294,8 +294,8 @@ pub async fn handle_send_chat_message(}})?;let is_first_message = chat.messages.is_empty();- let model = if incoming_message.model == Model::Claude45Opus {- Model::Claude45Opus+ let model = if incoming_message.model == Model::Claude46Opus {+ Model::Claude46Opus} else {FALLBACK_MODEL};diff --git a/rust/cloud-storage/document_cognition_service/src/core/model.rs b/rust/cloud-storage/document_cognition_service/src/core/model.rsindex b6540b1fe0..ccfed0685f 100644--- a/rust/cloud-storage/document_cognition_service/src/core/model.rs+++ b/rust/cloud-storage/document_cognition_service/src/core/model.rs@@ -1,6 +1,6 @@use ai::types::Model;-pub static CHAT_MODELS: &[Model] = &[Model::Claude45Haiku, Model::Claude45Opus];+pub static CHAT_MODELS: &[Model] = &[Model::Claude45Haiku, Model::Claude46Opus];pub static COMPLETION_MODEL: Model = Model::OpenAiGpt41;pub static COMPLETION_CONTEXT_WINDOW: i32 = 80000;diff --git a/rust/cloud-storage/document_cognition_service/src/models_bin.rs b/rust/cloud-storage/document_cognition_service/src/models_bin.rsnew file mode 100644index 0000000000..32ed339dbd--- /dev/null+++ b/rust/cloud-storage/document_cognition_service/src/models_bin.rs@@ -0,0 +1,26 @@+#![allow(unused)]++mod api;+mod config;+mod core;+mod model;+mod service;++pub use config::Config;++use crate::core::model::CHAT_MODELS;+use crate::model::response::models::{AIModel, GetModelsResponse};+use ai::types::ModelWithMetadataAndProvider;++fn main() {+ let models = CHAT_MODELS+ .iter()+ .map(|m| AIModel {+ name: m.to_string(),+ provider: m.provider(),+ metadata: m.metadata(),+ })+ .collect::<Vec<AIModel>>();+ let data = GetModelsResponse { models };+ println!("{}", serde_json::to_string_pretty(&data).unwrap());+}