Add cheap model profiles for local adapters (#4881)
## Thinking Path > - Paperclip is a control plane for autonomous AI companies, where adapters are the boundary between the board, agents, and execution runtimes. > - Local adapters currently expose a primary runtime configuration, but operators often need a cheaper model lane for routine or low-risk work. > - That cheap lane has to stay adapter-owned: runtime profile settings should not mutate the primary adapter config or bypass existing auth/secret mediation. > - Issue creation also needs an ergonomic way to request primary, cheap, or custom model behavior for a selected assignee. > - This pull request adds a first-class `cheap` model profile contract across adapter capabilities, heartbeat config resolution, agent configuration, and issue creation. > - The benefit is cheaper task execution can be configured and requested explicitly while preserving adapter boundaries, secret handling, and audit visibility. ## What Changed - Added adapter model-profile capability metadata and a `cheap` profile contract for supported local adapters. - Applied `runtimeConfig.modelProfiles.cheap.adapterConfig` during heartbeat config resolution, including requested/applied/fallback run metadata. - Added agent configuration UI for cheap model profile settings without writing those settings into primary `adapterConfig`. - Added New Issue assignee model lane controls for Primary / Cheap / Custom and request payload handling. - Added run ledger profile badges and Storybook stories for the new cheap-lane UI states. - Added tests for validators, heartbeat model profile application, permission/secret mediation, UI payload helpers, and run ledger rendering. - Added committed UI verification screenshots under `docs/pr-screenshots/pap-2837/`. - Addressed Greptile review feedback around cheap-profile defaults, shared profile types, and fallback test data. ## Verification Local: - `pnpm exec vitest run packages/shared/src/validators/issue.test.ts server/src/__tests__/adapter-registry.test.ts server/src/__tests__/agent-permissions-routes.test.ts server/src/__tests__/heartbeat-model-profile.test.ts ui/src/components/IssueRunLedger.test.tsx ui/src/lib/agent-config-patch.test.ts ui/src/lib/issue-assignee-overrides.test.ts ui/src/lib/new-agent-runtime-config.test.ts` — passed, 8 files / 103 tests. - `pnpm exec vitest run ui/src/lib/new-agent-runtime-config.test.ts ui/src/components/IssueRunLedger.test.tsx` — passed after Greptile/rebase follow-up, 2 files / 17 tests. - `pnpm --filter @paperclipai/ui typecheck` — passed after Greptile/rebase follow-up. - `pnpm -r typecheck` — passed. - `pnpm build` — passed. - `pnpm test:run` — did not complete successfully in this local worktree: it stopped in pre-existing `@paperclipai/adapter-utils` sandbox/SSH fixture suites outside this PR diff. Failures were 5s local timeouts plus `git init -b` unsupported by this machine's Git 2.21.0. The branch-specific targeted suites above passed. - Branch was fetched/rebased onto `public-gh/master`; `git rev-list --left-right --count public-gh/master...HEAD` reports `0 9`. Remote PR checks on latest head `e30bf399146451c86cee98ed528d51d33fa5af5a`: - `policy` — passed. - `verify` — passed. - `e2e` — passed. - `Greptile Review` — passed, confidence score 5/5; Greptile review threads resolved. - `security/snyk (cryppadotta)` — passed. Screenshots: - [New issue cheap lane desktop](https://github.com/paperclipai/paperclip/blob/PAP-2837-plan-cheap-model-for-adapters-that-can-support-it/docs/pr-screenshots/pap-2837/newissue-cheap-desktop.png) - [New issue custom lane desktop](https://github.com/paperclipai/paperclip/blob/PAP-2837-plan-cheap-model-for-adapters-that-can-support-it/docs/pr-screenshots/pap-2837/newissue-custom-desktop.png) - [New issue unsupported adapter desktop](https://github.com/paperclipai/paperclip/blob/PAP-2837-plan-cheap-model-for-adapters-that-can-support-it/docs/pr-screenshots/pap-2837/newissue-unsupported-desktop.png) - [Run ledger model profile badges desktop](https://github.com/paperclipai/paperclip/blob/PAP-2837-plan-cheap-model-for-adapters-that-can-support-it/docs/pr-screenshots/pap-2837/runledger-profile-badges-desktop.png) - Mobile variants are also in `docs/pr-screenshots/pap-2837/`. ## Risks - Medium: heartbeat config mediation now merges runtime model profiles into adapter configs, so adapter secret normalization and host-command restrictions must keep covering nested config paths. - Medium: the UI adds another issue creation choice; unsupported adapters must keep hiding the cheap lane and preserve primary behavior. - Low migration risk: no database migration is included. > For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and discuss it in `#dev` before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See `CONTRIBUTING.md`. ## Model Used OpenAI Codex coding agent using GPT-5-class reasoning with repo tool use and command execution. Exact served model/context window was not exposed by the runtime. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [ ] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] If this change affects the UI, I have included before/after screenshots - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
|
|
@ -150,7 +150,7 @@ Invariant: every business record belongs to exactly one company.
|
||||||
- `capabilities` text null
|
- `capabilities` text null
|
||||||
- `adapter_type` text; built-ins include `process`, `http`, `claude_local`, `codex_local`, `gemini_local`, `opencode_local`, `pi_local`, `cursor`, and `openclaw_gateway`
|
- `adapter_type` text; built-ins include `process`, `http`, `claude_local`, `codex_local`, `gemini_local`, `opencode_local`, `pi_local`, `cursor`, and `openclaw_gateway`
|
||||||
- `adapter_config` jsonb not null
|
- `adapter_config` jsonb not null
|
||||||
- `runtime_config` jsonb not null default `{}`
|
- `runtime_config` jsonb not null default `{}`; may include Paperclip runtime policy such as `modelProfiles.cheap.adapterConfig` for an optional low-cost model lane that does not change the primary adapter config
|
||||||
- `default_environment_id` uuid fk `environments.id` null
|
- `default_environment_id` uuid fk `environments.id` null
|
||||||
- `context_mode` enum: `thin | fat` default `thin`
|
- `context_mode` enum: `thin | fat` default `thin`
|
||||||
- `budget_monthly_cents` int not null default 0
|
- `budget_monthly_cents` int not null default 0
|
||||||
|
|
|
||||||
BIN
docs/pr-screenshots/pap-2837/newissue-cheap-desktop.png
Normal file
|
After Width: | Height: | Size: 182 KiB |
BIN
docs/pr-screenshots/pap-2837/newissue-cheap-mobile.png
Normal file
|
After Width: | Height: | Size: 108 KiB |
BIN
docs/pr-screenshots/pap-2837/newissue-custom-desktop.png
Normal file
|
After Width: | Height: | Size: 191 KiB |
BIN
docs/pr-screenshots/pap-2837/newissue-custom-mobile.png
Normal file
|
After Width: | Height: | Size: 121 KiB |
BIN
docs/pr-screenshots/pap-2837/newissue-primary-desktop.png
Normal file
|
After Width: | Height: | Size: 183 KiB |
BIN
docs/pr-screenshots/pap-2837/newissue-primary-mobile.png
Normal file
|
After Width: | Height: | Size: 105 KiB |
BIN
docs/pr-screenshots/pap-2837/newissue-unsupported-desktop.png
Normal file
|
After Width: | Height: | Size: 188 KiB |
BIN
docs/pr-screenshots/pap-2837/newissue-unsupported-mobile.png
Normal file
|
After Width: | Height: | Size: 106 KiB |
|
After Width: | Height: | Size: 335 KiB |
BIN
docs/pr-screenshots/pap-2837/runledger-profile-badges-mobile.png
Normal file
|
After Width: | Height: | Size: 151 KiB |
|
|
@ -20,6 +20,8 @@ export type {
|
||||||
AdapterSkillContext,
|
AdapterSkillContext,
|
||||||
AdapterSessionCodec,
|
AdapterSessionCodec,
|
||||||
AdapterModel,
|
AdapterModel,
|
||||||
|
AdapterModelProfileKey,
|
||||||
|
AdapterModelProfileDefinition,
|
||||||
HireApprovedPayload,
|
HireApprovedPayload,
|
||||||
HireApprovedHookResult,
|
HireApprovedHookResult,
|
||||||
ConfigFieldOption,
|
ConfigFieldOption,
|
||||||
|
|
|
||||||
|
|
@ -144,6 +144,16 @@ export interface AdapterModel {
|
||||||
label: string;
|
label: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type AdapterModelProfileKey = "cheap";
|
||||||
|
|
||||||
|
export interface AdapterModelProfileDefinition {
|
||||||
|
key: AdapterModelProfileKey;
|
||||||
|
label: string;
|
||||||
|
description?: string;
|
||||||
|
adapterConfig: Record<string, unknown>;
|
||||||
|
source?: "adapter_default" | "discovered";
|
||||||
|
}
|
||||||
|
|
||||||
export type AdapterEnvironmentCheckLevel = "info" | "warn" | "error";
|
export type AdapterEnvironmentCheckLevel = "info" | "warn" | "error";
|
||||||
|
|
||||||
export interface AdapterEnvironmentCheck {
|
export interface AdapterEnvironmentCheck {
|
||||||
|
|
@ -329,6 +339,8 @@ export interface ServerAdapterModule {
|
||||||
supportsLocalAgentJwt?: boolean;
|
supportsLocalAgentJwt?: boolean;
|
||||||
models?: AdapterModel[];
|
models?: AdapterModel[];
|
||||||
listModels?: () => Promise<AdapterModel[]>;
|
listModels?: () => Promise<AdapterModel[]>;
|
||||||
|
modelProfiles?: AdapterModelProfileDefinition[];
|
||||||
|
listModelProfiles?: () => Promise<AdapterModelProfileDefinition[]>;
|
||||||
/**
|
/**
|
||||||
* Optional explicit refresh hook for model discovery.
|
* Optional explicit refresh hook for model discovery.
|
||||||
* Use this when the adapter caches discovered models and needs a bypass path
|
* Use this when the adapter caches discovered models and needs a bypass path
|
||||||
|
|
@ -435,6 +447,14 @@ export interface CreateConfigValues {
|
||||||
promptTemplate: string;
|
promptTemplate: string;
|
||||||
model: string;
|
model: string;
|
||||||
thinkingEffort: string;
|
thinkingEffort: string;
|
||||||
|
/**
|
||||||
|
* Optional cheap model profile config for new agents on adapters that
|
||||||
|
* support model profiles. Persisted under
|
||||||
|
* `runtimeConfig.modelProfiles.cheap.adapterConfig`, never on the primary
|
||||||
|
* `adapterConfig`.
|
||||||
|
*/
|
||||||
|
cheapModel?: string;
|
||||||
|
cheapModelEnabled?: boolean;
|
||||||
chrome: boolean;
|
chrome: boolean;
|
||||||
dangerouslySkipPermissions: boolean;
|
dangerouslySkipPermissions: boolean;
|
||||||
search: boolean;
|
search: boolean;
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import type { AdapterModelProfileDefinition } from "@paperclipai/adapter-utils";
|
||||||
|
|
||||||
export const type = "claude_local";
|
export const type = "claude_local";
|
||||||
export const label = "Claude Code (local)";
|
export const label = "Claude Code (local)";
|
||||||
|
|
||||||
|
|
@ -10,6 +12,19 @@ export const models = [
|
||||||
{ id: "claude-haiku-4-5-20251001", label: "Claude Haiku 4.5" },
|
{ id: "claude-haiku-4-5-20251001", label: "Claude Haiku 4.5" },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const modelProfiles: AdapterModelProfileDefinition[] = [
|
||||||
|
{
|
||||||
|
key: "cheap",
|
||||||
|
label: "Cheap",
|
||||||
|
description: "Use Claude Sonnet as the lower-cost Claude Code lane while preserving the agent's primary model.",
|
||||||
|
adapterConfig: {
|
||||||
|
model: "claude-sonnet-4-6",
|
||||||
|
effort: "low",
|
||||||
|
},
|
||||||
|
source: "adapter_default",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
export const agentConfigurationDoc = `# claude_local agent configuration
|
export const agentConfigurationDoc = `# claude_local agent configuration
|
||||||
|
|
||||||
Adapter: claude_local
|
Adapter: claude_local
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
|
import type { AdapterModelProfileDefinition } from "@paperclipai/adapter-utils";
|
||||||
|
|
||||||
export const type = "codex_local";
|
export const type = "codex_local";
|
||||||
export const label = "Codex (local)";
|
export const label = "Codex (local)";
|
||||||
|
|
||||||
export const DEFAULT_CODEX_LOCAL_MODEL = "gpt-5.3-codex";
|
export const DEFAULT_CODEX_LOCAL_MODEL = "gpt-5.3-codex";
|
||||||
export const DEFAULT_CODEX_LOCAL_BYPASS_APPROVALS_AND_SANDBOX = true;
|
export const DEFAULT_CODEX_LOCAL_BYPASS_APPROVALS_AND_SANDBOX = true;
|
||||||
export const CODEX_LOCAL_FAST_MODE_SUPPORTED_MODELS = ["gpt-5.4"] as const;
|
export const CODEX_LOCAL_FAST_MODE_SUPPORTED_MODELS = ["gpt-5.4"] as const;
|
||||||
|
|
@ -40,6 +43,19 @@ export const models = [
|
||||||
{ id: "codex-mini-latest", label: "Codex Mini" },
|
{ id: "codex-mini-latest", label: "Codex Mini" },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const modelProfiles: AdapterModelProfileDefinition[] = [
|
||||||
|
{
|
||||||
|
key: "cheap",
|
||||||
|
label: "Cheap",
|
||||||
|
description: "Use the lowest-cost known Codex local model lane without changing the primary model.",
|
||||||
|
adapterConfig: {
|
||||||
|
model: "gpt-5.3-codex-spark",
|
||||||
|
modelReasoningEffort: "low",
|
||||||
|
},
|
||||||
|
source: "adapter_default",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
export const agentConfigurationDoc = `# codex_local agent configuration
|
export const agentConfigurationDoc = `# codex_local agent configuration
|
||||||
|
|
||||||
Adapter: codex_local
|
Adapter: codex_local
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
|
import type { AdapterModelProfileDefinition } from "@paperclipai/adapter-utils";
|
||||||
|
|
||||||
export const type = "cursor";
|
export const type = "cursor";
|
||||||
export const label = "Cursor CLI (local)";
|
export const label = "Cursor CLI (local)";
|
||||||
|
|
||||||
export const DEFAULT_CURSOR_LOCAL_MODEL = "auto";
|
export const DEFAULT_CURSOR_LOCAL_MODEL = "auto";
|
||||||
|
|
||||||
const CURSOR_FALLBACK_MODEL_IDS = [
|
const CURSOR_FALLBACK_MODEL_IDS = [
|
||||||
|
|
@ -46,6 +49,18 @@ const CURSOR_FALLBACK_MODEL_IDS = [
|
||||||
|
|
||||||
export const models = CURSOR_FALLBACK_MODEL_IDS.map((id) => ({ id, label: id }));
|
export const models = CURSOR_FALLBACK_MODEL_IDS.map((id) => ({ id, label: id }));
|
||||||
|
|
||||||
|
export const modelProfiles: AdapterModelProfileDefinition[] = [
|
||||||
|
{
|
||||||
|
key: "cheap",
|
||||||
|
label: "Cheap",
|
||||||
|
description: "Use Cursor's known Codex mini model as the budget lane instead of assuming auto is cheap.",
|
||||||
|
adapterConfig: {
|
||||||
|
model: "gpt-5.1-codex-mini",
|
||||||
|
},
|
||||||
|
source: "adapter_default",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
export const agentConfigurationDoc = `# cursor agent configuration
|
export const agentConfigurationDoc = `# cursor agent configuration
|
||||||
|
|
||||||
Adapter: cursor
|
Adapter: cursor
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
|
import type { AdapterModelProfileDefinition } from "@paperclipai/adapter-utils";
|
||||||
|
|
||||||
export const type = "gemini_local";
|
export const type = "gemini_local";
|
||||||
export const label = "Gemini CLI (local)";
|
export const label = "Gemini CLI (local)";
|
||||||
|
|
||||||
export const DEFAULT_GEMINI_LOCAL_MODEL = "auto";
|
export const DEFAULT_GEMINI_LOCAL_MODEL = "auto";
|
||||||
|
|
||||||
export const models = [
|
export const models = [
|
||||||
|
|
@ -11,6 +14,18 @@ export const models = [
|
||||||
{ id: "gemini-2.0-flash-lite", label: "Gemini 2.0 Flash Lite" },
|
{ id: "gemini-2.0-flash-lite", label: "Gemini 2.0 Flash Lite" },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const modelProfiles: AdapterModelProfileDefinition[] = [
|
||||||
|
{
|
||||||
|
key: "cheap",
|
||||||
|
label: "Cheap",
|
||||||
|
description: "Use Gemini Flash Lite as the budget Gemini CLI lane while preserving the primary model.",
|
||||||
|
adapterConfig: {
|
||||||
|
model: "gemini-2.5-flash-lite",
|
||||||
|
},
|
||||||
|
source: "adapter_default",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
export const agentConfigurationDoc = `# gemini_local agent configuration
|
export const agentConfigurationDoc = `# gemini_local agent configuration
|
||||||
|
|
||||||
Adapter: gemini_local
|
Adapter: gemini_local
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import type { AdapterModelProfileDefinition } from "@paperclipai/adapter-utils";
|
||||||
|
|
||||||
export const type = "opencode_local";
|
export const type = "opencode_local";
|
||||||
export const label = "OpenCode (local)";
|
export const label = "OpenCode (local)";
|
||||||
|
|
||||||
|
|
@ -11,6 +13,19 @@ export const models: Array<{ id: string; label: string }> = [
|
||||||
{ id: "openai/gpt-5.1-codex-mini", label: "openai/gpt-5.1-codex-mini" },
|
{ id: "openai/gpt-5.1-codex-mini", label: "openai/gpt-5.1-codex-mini" },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const modelProfiles: AdapterModelProfileDefinition[] = [
|
||||||
|
{
|
||||||
|
key: "cheap",
|
||||||
|
label: "Cheap",
|
||||||
|
description: "Use OpenCode's known Codex mini model as the budget lane.",
|
||||||
|
adapterConfig: {
|
||||||
|
model: "openai/gpt-5.1-codex-mini",
|
||||||
|
variant: "low",
|
||||||
|
},
|
||||||
|
source: "adapter_default",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
export const agentConfigurationDoc = `# opencode_local agent configuration
|
export const agentConfigurationDoc = `# opencode_local agent configuration
|
||||||
|
|
||||||
Adapter: opencode_local
|
Adapter: opencode_local
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,12 @@
|
||||||
|
import type { AdapterModelProfileDefinition } from "@paperclipai/adapter-utils";
|
||||||
|
|
||||||
export const type = "pi_local";
|
export const type = "pi_local";
|
||||||
export const label = "Pi (local)";
|
export const label = "Pi (local)";
|
||||||
|
|
||||||
export const models: Array<{ id: string; label: string }> = [];
|
export const models: Array<{ id: string; label: string }> = [];
|
||||||
|
|
||||||
|
export const modelProfiles: AdapterModelProfileDefinition[] = [];
|
||||||
|
|
||||||
export const agentConfigurationDoc = `# pi_local agent configuration
|
export const agentConfigurationDoc = `# pi_local agent configuration
|
||||||
|
|
||||||
Adapter: pi_local
|
Adapter: pi_local
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,10 @@ export const AGENT_ROLE_LABELS: Record<AgentRole, string> = {
|
||||||
|
|
||||||
export const AGENT_DEFAULT_MAX_CONCURRENT_RUNS = 5;
|
export const AGENT_DEFAULT_MAX_CONCURRENT_RUNS = 5;
|
||||||
export const WORKSPACE_BRANCH_ROUTINE_VARIABLE = "workspaceBranch";
|
export const WORKSPACE_BRANCH_ROUTINE_VARIABLE = "workspaceBranch";
|
||||||
|
|
||||||
|
export const MODEL_PROFILE_KEYS = ["cheap"] as const;
|
||||||
|
export type ModelProfileKey = (typeof MODEL_PROFILE_KEYS)[number];
|
||||||
|
|
||||||
export const AGENT_ICON_NAMES = [
|
export const AGENT_ICON_NAMES = [
|
||||||
"bot",
|
"bot",
|
||||||
"cpu",
|
"cpu",
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ export {
|
||||||
AGENT_ROLE_LABELS,
|
AGENT_ROLE_LABELS,
|
||||||
AGENT_DEFAULT_MAX_CONCURRENT_RUNS,
|
AGENT_DEFAULT_MAX_CONCURRENT_RUNS,
|
||||||
WORKSPACE_BRANCH_ROUTINE_VARIABLE,
|
WORKSPACE_BRANCH_ROUTINE_VARIABLE,
|
||||||
|
MODEL_PROFILE_KEYS,
|
||||||
AGENT_ICON_NAMES,
|
AGENT_ICON_NAMES,
|
||||||
ISSUE_STATUSES,
|
ISSUE_STATUSES,
|
||||||
INBOX_MINE_ISSUE_STATUSES,
|
INBOX_MINE_ISSUE_STATUSES,
|
||||||
|
|
@ -117,6 +118,7 @@ export {
|
||||||
type AgentStatus,
|
type AgentStatus,
|
||||||
type AgentAdapterType,
|
type AgentAdapterType,
|
||||||
type AgentRole,
|
type AgentRole,
|
||||||
|
type ModelProfileKey,
|
||||||
type AgentIconName,
|
type AgentIconName,
|
||||||
type IssueStatus,
|
type IssueStatus,
|
||||||
type IssuePriority,
|
type IssuePriority,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import type {
|
import type {
|
||||||
AgentAdapterType,
|
AgentAdapterType,
|
||||||
|
ModelProfileKey,
|
||||||
PauseReason,
|
PauseReason,
|
||||||
AgentRole,
|
AgentRole,
|
||||||
AgentStatus,
|
AgentStatus,
|
||||||
|
|
@ -13,6 +14,16 @@ export interface AgentPermissions {
|
||||||
canCreateAgents: boolean;
|
canCreateAgents: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface AgentModelProfileConfig {
|
||||||
|
enabled?: boolean;
|
||||||
|
label?: string;
|
||||||
|
adapterConfig: Record<string, unknown>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AgentRuntimeConfig extends Record<string, unknown> {
|
||||||
|
modelProfiles?: Partial<Record<ModelProfileKey, AgentModelProfileConfig>>;
|
||||||
|
}
|
||||||
|
|
||||||
export type AgentInstructionsBundleMode = "managed" | "external";
|
export type AgentInstructionsBundleMode = "managed" | "external";
|
||||||
|
|
||||||
export interface AgentInstructionsFileSummary {
|
export interface AgentInstructionsFileSummary {
|
||||||
|
|
@ -72,7 +83,7 @@ export interface Agent {
|
||||||
capabilities: string | null;
|
capabilities: string | null;
|
||||||
adapterType: AgentAdapterType;
|
adapterType: AgentAdapterType;
|
||||||
adapterConfig: Record<string, unknown>;
|
adapterConfig: Record<string, unknown>;
|
||||||
runtimeConfig: Record<string, unknown>;
|
runtimeConfig: AgentRuntimeConfig;
|
||||||
defaultEnvironmentId?: string | null;
|
defaultEnvironmentId?: string | null;
|
||||||
budgetMonthlyCents: number;
|
budgetMonthlyCents: number;
|
||||||
spentMonthlyCents: number;
|
spentMonthlyCents: number;
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,9 @@ export type {
|
||||||
AgentAccessState,
|
AgentAccessState,
|
||||||
AgentChainOfCommandEntry,
|
AgentChainOfCommandEntry,
|
||||||
AgentDetail,
|
AgentDetail,
|
||||||
|
AgentModelProfileConfig,
|
||||||
AgentPermissions,
|
AgentPermissions,
|
||||||
|
AgentRuntimeConfig,
|
||||||
AgentInstructionsBundleMode,
|
AgentInstructionsBundleMode,
|
||||||
AgentInstructionsFileSummary,
|
AgentInstructionsFileSummary,
|
||||||
AgentInstructionsFileDetail,
|
AgentInstructionsFileDetail,
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import type {
|
||||||
IssueExecutionStateStatus,
|
IssueExecutionStateStatus,
|
||||||
IssueOriginKind,
|
IssueOriginKind,
|
||||||
IssuePriority,
|
IssuePriority,
|
||||||
|
ModelProfileKey,
|
||||||
IssueThreadInteractionContinuationPolicy,
|
IssueThreadInteractionContinuationPolicy,
|
||||||
IssueThreadInteractionKind,
|
IssueThreadInteractionKind,
|
||||||
IssueThreadInteractionStatus,
|
IssueThreadInteractionStatus,
|
||||||
|
|
@ -59,6 +60,7 @@ export interface IssueLabel {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IssueAssigneeAdapterOverrides {
|
export interface IssueAssigneeAdapterOverrides {
|
||||||
|
modelProfile?: ModelProfileKey;
|
||||||
adapterConfig?: Record<string, unknown>;
|
adapterConfig?: Record<string, unknown>;
|
||||||
useProjectWorkspace?: boolean;
|
useProjectWorkspace?: boolean;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,18 @@ export const createAgentInstructionsBundleSchema = z.object({
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const agentModelProfileConfigSchema = z.object({
|
||||||
|
enabled: z.boolean().optional(),
|
||||||
|
label: z.string().trim().min(1).optional(),
|
||||||
|
adapterConfig: adapterConfigSchema,
|
||||||
|
}).strict();
|
||||||
|
|
||||||
|
export const agentRuntimeConfigSchema = z.object({
|
||||||
|
modelProfiles: z.object({
|
||||||
|
cheap: agentModelProfileConfigSchema.optional(),
|
||||||
|
}).strict().optional(),
|
||||||
|
}).catchall(z.unknown());
|
||||||
|
|
||||||
export const createAgentSchema = z.object({
|
export const createAgentSchema = z.object({
|
||||||
name: z.string().min(1),
|
name: z.string().min(1),
|
||||||
role: z.enum(AGENT_ROLES).optional().default("general"),
|
role: z.enum(AGENT_ROLES).optional().default("general"),
|
||||||
|
|
@ -62,7 +74,7 @@ export const createAgentSchema = z.object({
|
||||||
adapterType: agentAdapterTypeSchema,
|
adapterType: agentAdapterTypeSchema,
|
||||||
adapterConfig: adapterConfigSchema.optional().default({}),
|
adapterConfig: adapterConfigSchema.optional().default({}),
|
||||||
instructionsBundle: createAgentInstructionsBundleSchema.optional(),
|
instructionsBundle: createAgentInstructionsBundleSchema.optional(),
|
||||||
runtimeConfig: z.record(z.unknown()).optional().default({}),
|
runtimeConfig: agentRuntimeConfigSchema.optional().default({}),
|
||||||
defaultEnvironmentId: z.string().uuid().optional().nullable(),
|
defaultEnvironmentId: z.string().uuid().optional().nullable(),
|
||||||
budgetMonthlyCents: z.number().int().nonnegative().optional().default(0),
|
budgetMonthlyCents: z.number().int().nonnegative().optional().default(0),
|
||||||
permissions: agentPermissionsSchema.optional(),
|
permissions: agentPermissionsSchema.optional(),
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,7 @@ export {
|
||||||
createAgentSchema,
|
createAgentSchema,
|
||||||
createAgentHireSchema,
|
createAgentHireSchema,
|
||||||
updateAgentSchema,
|
updateAgentSchema,
|
||||||
|
agentRuntimeConfigSchema,
|
||||||
agentInstructionsBundleModeSchema,
|
agentInstructionsBundleModeSchema,
|
||||||
updateAgentInstructionsBundleSchema,
|
updateAgentInstructionsBundleSchema,
|
||||||
upsertAgentInstructionsFileSchema,
|
upsertAgentInstructionsFileSchema,
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import {
|
||||||
updateIssueSchema,
|
updateIssueSchema,
|
||||||
upsertIssueDocumentSchema,
|
upsertIssueDocumentSchema,
|
||||||
} from "./issue.js";
|
} from "./issue.js";
|
||||||
|
import { createAgentSchema } from "./agent.js";
|
||||||
|
|
||||||
describe("issue validators", () => {
|
describe("issue validators", () => {
|
||||||
it("passes real line breaks through unchanged", () => {
|
it("passes real line breaks through unchanged", () => {
|
||||||
|
|
@ -93,4 +94,87 @@ describe("issue validators", () => {
|
||||||
|
|
||||||
expect(parsed.requestDepth).toBe(MAX_ISSUE_REQUEST_DEPTH);
|
expect(parsed.requestDepth).toBe(MAX_ISSUE_REQUEST_DEPTH);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("accepts the cheap model profile in issue assignee adapter overrides", () => {
|
||||||
|
const parsed = createIssueSchema.parse({
|
||||||
|
title: "Run a cheap heartbeat",
|
||||||
|
assigneeAdapterOverrides: {
|
||||||
|
modelProfile: "cheap",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(parsed.assigneeAdapterOverrides?.modelProfile).toBe("cheap");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("rejects unknown issue model profile keys", () => {
|
||||||
|
const parsed = updateIssueSchema.safeParse({
|
||||||
|
assigneeAdapterOverrides: {
|
||||||
|
modelProfile: "fast",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(parsed.success).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("validates agent runtime cheap model profile config without rejecting other runtime fields", () => {
|
||||||
|
const parsed = createAgentSchema.parse({
|
||||||
|
name: "Coder",
|
||||||
|
adapterType: "codex_local",
|
||||||
|
runtimeConfig: {
|
||||||
|
heartbeat: { enabled: true },
|
||||||
|
modelProfiles: {
|
||||||
|
cheap: {
|
||||||
|
enabled: true,
|
||||||
|
label: "Cheap Codex",
|
||||||
|
adapterConfig: {
|
||||||
|
model: "gpt-5.3-codex-spark",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(parsed.runtimeConfig.modelProfiles?.cheap?.adapterConfig).toEqual({
|
||||||
|
model: "gpt-5.3-codex-spark",
|
||||||
|
});
|
||||||
|
expect(parsed.runtimeConfig.heartbeat).toEqual({ enabled: true });
|
||||||
|
});
|
||||||
|
|
||||||
|
it("validates cheap model profile env bindings like top-level adapter config", () => {
|
||||||
|
const parsed = createAgentSchema.safeParse({
|
||||||
|
name: "Coder",
|
||||||
|
adapterType: "codex_local",
|
||||||
|
runtimeConfig: {
|
||||||
|
modelProfiles: {
|
||||||
|
cheap: {
|
||||||
|
adapterConfig: {
|
||||||
|
env: {
|
||||||
|
API_TOKEN: 123,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(parsed.success).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("rejects unknown agent runtime model profile keys", () => {
|
||||||
|
const parsed = createAgentSchema.safeParse({
|
||||||
|
name: "Coder",
|
||||||
|
adapterType: "codex_local",
|
||||||
|
runtimeConfig: {
|
||||||
|
modelProfiles: {
|
||||||
|
fast: {
|
||||||
|
adapterConfig: {
|
||||||
|
model: "gpt-5-mini",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(parsed.success).toBe(false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import {
|
||||||
ISSUE_THREAD_INTERACTION_CONTINUATION_POLICIES,
|
ISSUE_THREAD_INTERACTION_CONTINUATION_POLICIES,
|
||||||
ISSUE_THREAD_INTERACTION_KINDS,
|
ISSUE_THREAD_INTERACTION_KINDS,
|
||||||
ISSUE_THREAD_INTERACTION_STATUSES,
|
ISSUE_THREAD_INTERACTION_STATUSES,
|
||||||
|
MODEL_PROFILE_KEYS,
|
||||||
} from "../constants.js";
|
} from "../constants.js";
|
||||||
import { multilineTextSchema } from "./text.js";
|
import { multilineTextSchema } from "./text.js";
|
||||||
|
|
||||||
|
|
@ -44,6 +45,7 @@ export const issueExecutionWorkspaceSettingsSchema = z
|
||||||
|
|
||||||
export const issueAssigneeAdapterOverridesSchema = z
|
export const issueAssigneeAdapterOverridesSchema = z
|
||||||
.object({
|
.object({
|
||||||
|
modelProfile: z.enum(MODEL_PROFILE_KEYS).optional(),
|
||||||
adapterConfig: z.record(z.unknown()).optional(),
|
adapterConfig: z.record(z.unknown()).optional(),
|
||||||
useProjectWorkspace: z.boolean().optional(),
|
useProjectWorkspace: z.boolean().optional(),
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ import {
|
||||||
findActiveServerAdapter,
|
findActiveServerAdapter,
|
||||||
findServerAdapter,
|
findServerAdapter,
|
||||||
listAdapterModels,
|
listAdapterModels,
|
||||||
|
listAdapterModelProfiles,
|
||||||
registerServerAdapter,
|
registerServerAdapter,
|
||||||
requireServerAdapter,
|
requireServerAdapter,
|
||||||
unregisterServerAdapter,
|
unregisterServerAdapter,
|
||||||
|
|
@ -79,6 +80,31 @@ describe("server adapter registry", () => {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("exposes adapter model profiles when adapters declare them", async () => {
|
||||||
|
const adapterWithProfiles: ServerAdapterModule = {
|
||||||
|
...externalAdapter,
|
||||||
|
modelProfiles: [
|
||||||
|
{
|
||||||
|
key: "cheap",
|
||||||
|
label: "Cheap",
|
||||||
|
adapterConfig: { model: "external-mini" },
|
||||||
|
source: "adapter_default",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
registerServerAdapter(adapterWithProfiles);
|
||||||
|
|
||||||
|
expect(await listAdapterModelProfiles("external_test")).toEqual([
|
||||||
|
{
|
||||||
|
key: "cheap",
|
||||||
|
label: "Cheap",
|
||||||
|
adapterConfig: { model: "external-mini" },
|
||||||
|
source: "adapter_default",
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
it("removes external adapters when unregistered", () => {
|
it("removes external adapters when unregistered", () => {
|
||||||
registerServerAdapter(externalAdapter);
|
registerServerAdapter(externalAdapter);
|
||||||
|
|
||||||
|
|
@ -167,6 +193,45 @@ describe("server adapter registry", () => {
|
||||||
expect(adapter!.supportsLocalAgentJwt).toBe(true);
|
expect(adapter!.supportsLocalAgentJwt).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("built-in local adapters declare cheap model profile defaults where supported", async () => {
|
||||||
|
await expect(listAdapterModelProfiles("claude_local")).resolves.toEqual([
|
||||||
|
expect.objectContaining({
|
||||||
|
key: "cheap",
|
||||||
|
adapterConfig: expect.objectContaining({ model: "claude-sonnet-4-6" }),
|
||||||
|
source: "adapter_default",
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
await expect(listAdapterModelProfiles("codex_local")).resolves.toEqual([
|
||||||
|
expect.objectContaining({
|
||||||
|
key: "cheap",
|
||||||
|
adapterConfig: expect.objectContaining({ model: "gpt-5.3-codex-spark" }),
|
||||||
|
source: "adapter_default",
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
await expect(listAdapterModelProfiles("gemini_local")).resolves.toEqual([
|
||||||
|
expect.objectContaining({
|
||||||
|
key: "cheap",
|
||||||
|
adapterConfig: expect.objectContaining({ model: "gemini-2.5-flash-lite" }),
|
||||||
|
source: "adapter_default",
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
await expect(listAdapterModelProfiles("opencode_local")).resolves.toEqual([
|
||||||
|
expect.objectContaining({
|
||||||
|
key: "cheap",
|
||||||
|
adapterConfig: expect.objectContaining({ model: "openai/gpt-5.1-codex-mini" }),
|
||||||
|
source: "adapter_default",
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
await expect(listAdapterModelProfiles("cursor")).resolves.toEqual([
|
||||||
|
expect.objectContaining({
|
||||||
|
key: "cheap",
|
||||||
|
adapterConfig: expect.objectContaining({ model: "gpt-5.1-codex-mini" }),
|
||||||
|
source: "adapter_default",
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
await expect(listAdapterModelProfiles("pi_local")).resolves.toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
it("switches active adapter behavior back to the builtin when an override is paused", async () => {
|
it("switches active adapter behavior back to the builtin when an override is paused", async () => {
|
||||||
const builtIn = findServerAdapter("claude_local");
|
const builtIn = findServerAdapter("claude_local");
|
||||||
expect(builtIn).not.toBeNull();
|
expect(builtIn).not.toBeNull();
|
||||||
|
|
|
||||||
|
|
@ -496,6 +496,165 @@ describe.sequential("agent permission routes", () => {
|
||||||
expect(mockLogActivity).not.toHaveBeenCalled();
|
expect(mockLogActivity).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("blocks agent-authenticated self-updates that set cheap-profile host-executed workspace commands", async () => {
|
||||||
|
mockAgentService.getById.mockResolvedValue({
|
||||||
|
...baseAgent,
|
||||||
|
adapterType: "codex_local",
|
||||||
|
});
|
||||||
|
|
||||||
|
const app = await createApp({
|
||||||
|
type: "agent",
|
||||||
|
agentId,
|
||||||
|
companyId,
|
||||||
|
source: "agent_key",
|
||||||
|
runId: "run-1",
|
||||||
|
});
|
||||||
|
|
||||||
|
const res = await requestApp(app, (baseUrl) => request(baseUrl)
|
||||||
|
.patch(`/api/agents/${agentId}`)
|
||||||
|
.send({
|
||||||
|
runtimeConfig: {
|
||||||
|
modelProfiles: {
|
||||||
|
cheap: {
|
||||||
|
adapterConfig: {
|
||||||
|
workspaceStrategy: {
|
||||||
|
type: "git_worktree",
|
||||||
|
provisionCommand: "touch /tmp/paperclip-rce",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
expect(res.status).toBe(403);
|
||||||
|
expect(res.body.error).toContain("host-executed workspace commands");
|
||||||
|
expect(res.body.error).toContain(
|
||||||
|
"runtimeConfig.modelProfiles.cheap.adapterConfig.workspaceStrategy.provisionCommand",
|
||||||
|
);
|
||||||
|
expect(mockLogActivity).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("allows board updates that set cheap-profile workspace commands", async () => {
|
||||||
|
mockAgentService.getById.mockResolvedValue({
|
||||||
|
...baseAgent,
|
||||||
|
adapterType: "codex_local",
|
||||||
|
});
|
||||||
|
|
||||||
|
const app = await createApp({
|
||||||
|
type: "board",
|
||||||
|
userId: "board-user",
|
||||||
|
source: "local_implicit",
|
||||||
|
isInstanceAdmin: true,
|
||||||
|
companyIds: [companyId],
|
||||||
|
});
|
||||||
|
|
||||||
|
const runtimeConfig = {
|
||||||
|
modelProfiles: {
|
||||||
|
cheap: {
|
||||||
|
adapterConfig: {
|
||||||
|
workspaceStrategy: {
|
||||||
|
type: "git_worktree",
|
||||||
|
provisionCommand: "bash ./scripts/provision-worktree.sh",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const res = await requestApp(app, (baseUrl) => request(baseUrl)
|
||||||
|
.patch(`/api/agents/${agentId}`)
|
||||||
|
.send({ runtimeConfig }));
|
||||||
|
|
||||||
|
expect(res.status, JSON.stringify(res.body)).toBe(200);
|
||||||
|
expect(mockAgentService.update).toHaveBeenCalledWith(
|
||||||
|
agentId,
|
||||||
|
expect.objectContaining({ runtimeConfig }),
|
||||||
|
expect.anything(),
|
||||||
|
);
|
||||||
|
expect(mockLogActivity).toHaveBeenCalledWith(expect.anything(), expect.objectContaining({
|
||||||
|
action: "agent.updated",
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
|
it("normalizes cheap-profile env bindings through the adapter config secret pipeline", async () => {
|
||||||
|
mockAgentService.getById.mockResolvedValue({
|
||||||
|
...baseAgent,
|
||||||
|
adapterType: "codex_local",
|
||||||
|
});
|
||||||
|
mockSecretService.normalizeAdapterConfigForPersistence.mockImplementation(async (_companyId, config) => ({
|
||||||
|
...config,
|
||||||
|
env: {
|
||||||
|
API_TOKEN: {
|
||||||
|
type: "secret_ref",
|
||||||
|
secretId: "33333333-3333-4333-8333-333333333333",
|
||||||
|
version: "latest",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const app = await createApp({
|
||||||
|
type: "board",
|
||||||
|
userId: "board-user",
|
||||||
|
source: "local_implicit",
|
||||||
|
isInstanceAdmin: true,
|
||||||
|
companyIds: [companyId],
|
||||||
|
});
|
||||||
|
|
||||||
|
const res = await requestApp(app, (baseUrl) => request(baseUrl)
|
||||||
|
.patch(`/api/agents/${agentId}`)
|
||||||
|
.send({
|
||||||
|
runtimeConfig: {
|
||||||
|
modelProfiles: {
|
||||||
|
cheap: {
|
||||||
|
adapterConfig: {
|
||||||
|
model: "gpt-5.3-codex-spark",
|
||||||
|
env: {
|
||||||
|
API_TOKEN: {
|
||||||
|
type: "secret_ref",
|
||||||
|
secretId: "33333333-3333-4333-8333-333333333333",
|
||||||
|
version: "latest",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
expect(res.status, JSON.stringify(res.body)).toBe(200);
|
||||||
|
expect(mockSecretService.normalizeAdapterConfigForPersistence).toHaveBeenCalledWith(
|
||||||
|
companyId,
|
||||||
|
expect.objectContaining({
|
||||||
|
model: "gpt-5.3-codex-spark",
|
||||||
|
env: expect.any(Object),
|
||||||
|
}),
|
||||||
|
{ strictMode: false },
|
||||||
|
);
|
||||||
|
expect(mockAgentService.update).toHaveBeenCalledWith(
|
||||||
|
agentId,
|
||||||
|
expect.objectContaining({
|
||||||
|
runtimeConfig: {
|
||||||
|
modelProfiles: {
|
||||||
|
cheap: {
|
||||||
|
adapterConfig: {
|
||||||
|
model: "gpt-5.3-codex-spark",
|
||||||
|
env: {
|
||||||
|
API_TOKEN: {
|
||||||
|
type: "secret_ref",
|
||||||
|
secretId: "33333333-3333-4333-8333-333333333333",
|
||||||
|
version: "latest",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
expect.anything(),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it("blocks agent-authenticated self-updates that set instructions bundle roots", async () => {
|
it("blocks agent-authenticated self-updates that set instructions bundle roots", async () => {
|
||||||
const app = await createApp({
|
const app = await createApp({
|
||||||
type: "agent",
|
type: "agent",
|
||||||
|
|
|
||||||
123
server/src/__tests__/heartbeat-model-profile.test.ts
Normal file
|
|
@ -0,0 +1,123 @@
|
||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
import type { AdapterModelProfileDefinition } from "../adapters/index.js";
|
||||||
|
import {
|
||||||
|
mergeModelProfileAdapterConfig,
|
||||||
|
normalizeModelProfileWakeContext,
|
||||||
|
resolveModelProfileApplication,
|
||||||
|
} from "../services/heartbeat.ts";
|
||||||
|
|
||||||
|
const cheapProfile: AdapterModelProfileDefinition = {
|
||||||
|
key: "cheap",
|
||||||
|
label: "Cheap",
|
||||||
|
adapterConfig: {
|
||||||
|
model: "adapter-cheap",
|
||||||
|
modelReasoningEffort: "low",
|
||||||
|
},
|
||||||
|
source: "adapter_default",
|
||||||
|
};
|
||||||
|
|
||||||
|
describe("heartbeat model profile application", () => {
|
||||||
|
it("applies cheap profile patches before explicit issue adapter config overrides", () => {
|
||||||
|
const modelProfile = resolveModelProfileApplication({
|
||||||
|
adapterModelProfiles: [cheapProfile],
|
||||||
|
agentRuntimeConfig: {},
|
||||||
|
issueModelProfile: "cheap",
|
||||||
|
contextSnapshot: {},
|
||||||
|
});
|
||||||
|
|
||||||
|
const merged = mergeModelProfileAdapterConfig({
|
||||||
|
baseConfig: {
|
||||||
|
model: "primary",
|
||||||
|
modelReasoningEffort: "high",
|
||||||
|
approvalPolicy: "strict",
|
||||||
|
},
|
||||||
|
modelProfile,
|
||||||
|
issueAdapterConfig: {
|
||||||
|
model: "issue-explicit",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(modelProfile).toMatchObject({
|
||||||
|
requested: "cheap",
|
||||||
|
requestedBy: "issue_override",
|
||||||
|
applied: "cheap",
|
||||||
|
configSource: "adapter_default",
|
||||||
|
fallbackReason: null,
|
||||||
|
});
|
||||||
|
expect(merged).toEqual({
|
||||||
|
model: "issue-explicit",
|
||||||
|
modelReasoningEffort: "low",
|
||||||
|
approvalPolicy: "strict",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("lets agent runtime profile config customize adapter defaults", () => {
|
||||||
|
const modelProfile = resolveModelProfileApplication({
|
||||||
|
adapterModelProfiles: [cheapProfile],
|
||||||
|
agentRuntimeConfig: {
|
||||||
|
modelProfiles: {
|
||||||
|
cheap: {
|
||||||
|
adapterConfig: {
|
||||||
|
model: "agent-cheap",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
issueModelProfile: null,
|
||||||
|
contextSnapshot: { modelProfile: "cheap" },
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(modelProfile).toMatchObject({
|
||||||
|
requested: "cheap",
|
||||||
|
requestedBy: "wake_context",
|
||||||
|
applied: "cheap",
|
||||||
|
configSource: "agent_runtime",
|
||||||
|
adapterConfig: {
|
||||||
|
model: "agent-cheap",
|
||||||
|
modelReasoningEffort: "low",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("falls back to the primary config when the adapter does not support the requested profile", () => {
|
||||||
|
const modelProfile = resolveModelProfileApplication({
|
||||||
|
adapterModelProfiles: [],
|
||||||
|
agentRuntimeConfig: {
|
||||||
|
modelProfiles: {
|
||||||
|
cheap: {
|
||||||
|
adapterConfig: {
|
||||||
|
model: "agent-cheap",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
issueModelProfile: null,
|
||||||
|
contextSnapshot: { modelProfile: "cheap" },
|
||||||
|
});
|
||||||
|
|
||||||
|
const merged = mergeModelProfileAdapterConfig({
|
||||||
|
baseConfig: {
|
||||||
|
model: "primary",
|
||||||
|
},
|
||||||
|
modelProfile,
|
||||||
|
issueAdapterConfig: null,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(modelProfile).toMatchObject({
|
||||||
|
requested: "cheap",
|
||||||
|
applied: null,
|
||||||
|
fallbackReason: "adapter_profile_not_supported",
|
||||||
|
adapterConfig: null,
|
||||||
|
});
|
||||||
|
expect(merged).toEqual({ model: "primary" });
|
||||||
|
});
|
||||||
|
|
||||||
|
it("normalizes a wake payload model profile into run context", () => {
|
||||||
|
const contextSnapshot = normalizeModelProfileWakeContext({
|
||||||
|
contextSnapshot: {},
|
||||||
|
payload: { modelProfile: "cheap" },
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(contextSnapshot).toMatchObject({ modelProfile: "cheap" });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -6,6 +6,7 @@ export {
|
||||||
findServerAdapter,
|
findServerAdapter,
|
||||||
findActiveServerAdapter,
|
findActiveServerAdapter,
|
||||||
detectAdapterModel,
|
detectAdapterModel,
|
||||||
|
listAdapterModelProfiles,
|
||||||
registerServerAdapter,
|
registerServerAdapter,
|
||||||
unregisterServerAdapter,
|
unregisterServerAdapter,
|
||||||
requireServerAdapter,
|
requireServerAdapter,
|
||||||
|
|
@ -15,6 +16,7 @@ export type {
|
||||||
AdapterExecutionContext,
|
AdapterExecutionContext,
|
||||||
AdapterExecutionResult,
|
AdapterExecutionResult,
|
||||||
AdapterInvocationMeta,
|
AdapterInvocationMeta,
|
||||||
|
AdapterModelProfileDefinition,
|
||||||
AdapterEnvironmentCheckLevel,
|
AdapterEnvironmentCheckLevel,
|
||||||
AdapterEnvironmentCheck,
|
AdapterEnvironmentCheck,
|
||||||
AdapterEnvironmentTestStatus,
|
AdapterEnvironmentTestStatus,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import type { ServerAdapterModule } from "./types.js";
|
import type { AdapterModelProfileDefinition, ServerAdapterModule } from "./types.js";
|
||||||
import { getAdapterSessionManagement } from "@paperclipai/adapter-utils";
|
import { getAdapterSessionManagement } from "@paperclipai/adapter-utils";
|
||||||
import {
|
import {
|
||||||
execute as claudeExecute,
|
execute as claudeExecute,
|
||||||
|
|
@ -9,7 +9,11 @@ import {
|
||||||
sessionCodec as claudeSessionCodec,
|
sessionCodec as claudeSessionCodec,
|
||||||
getQuotaWindows as claudeGetQuotaWindows,
|
getQuotaWindows as claudeGetQuotaWindows,
|
||||||
} from "@paperclipai/adapter-claude-local/server";
|
} from "@paperclipai/adapter-claude-local/server";
|
||||||
import { agentConfigurationDoc as claudeAgentConfigurationDoc, models as claudeModels } from "@paperclipai/adapter-claude-local";
|
import {
|
||||||
|
agentConfigurationDoc as claudeAgentConfigurationDoc,
|
||||||
|
models as claudeModels,
|
||||||
|
modelProfiles as claudeModelProfiles,
|
||||||
|
} from "@paperclipai/adapter-claude-local";
|
||||||
import {
|
import {
|
||||||
execute as codexExecute,
|
execute as codexExecute,
|
||||||
listCodexSkills,
|
listCodexSkills,
|
||||||
|
|
@ -18,7 +22,11 @@ import {
|
||||||
sessionCodec as codexSessionCodec,
|
sessionCodec as codexSessionCodec,
|
||||||
getQuotaWindows as codexGetQuotaWindows,
|
getQuotaWindows as codexGetQuotaWindows,
|
||||||
} from "@paperclipai/adapter-codex-local/server";
|
} from "@paperclipai/adapter-codex-local/server";
|
||||||
import { agentConfigurationDoc as codexAgentConfigurationDoc, models as codexModels } from "@paperclipai/adapter-codex-local";
|
import {
|
||||||
|
agentConfigurationDoc as codexAgentConfigurationDoc,
|
||||||
|
models as codexModels,
|
||||||
|
modelProfiles as codexModelProfiles,
|
||||||
|
} from "@paperclipai/adapter-codex-local";
|
||||||
import {
|
import {
|
||||||
execute as cursorExecute,
|
execute as cursorExecute,
|
||||||
listCursorSkills,
|
listCursorSkills,
|
||||||
|
|
@ -26,7 +34,11 @@ import {
|
||||||
testEnvironment as cursorTestEnvironment,
|
testEnvironment as cursorTestEnvironment,
|
||||||
sessionCodec as cursorSessionCodec,
|
sessionCodec as cursorSessionCodec,
|
||||||
} from "@paperclipai/adapter-cursor-local/server";
|
} from "@paperclipai/adapter-cursor-local/server";
|
||||||
import { agentConfigurationDoc as cursorAgentConfigurationDoc, models as cursorModels } from "@paperclipai/adapter-cursor-local";
|
import {
|
||||||
|
agentConfigurationDoc as cursorAgentConfigurationDoc,
|
||||||
|
models as cursorModels,
|
||||||
|
modelProfiles as cursorModelProfiles,
|
||||||
|
} from "@paperclipai/adapter-cursor-local";
|
||||||
import {
|
import {
|
||||||
execute as geminiExecute,
|
execute as geminiExecute,
|
||||||
listGeminiSkills,
|
listGeminiSkills,
|
||||||
|
|
@ -34,7 +46,11 @@ import {
|
||||||
testEnvironment as geminiTestEnvironment,
|
testEnvironment as geminiTestEnvironment,
|
||||||
sessionCodec as geminiSessionCodec,
|
sessionCodec as geminiSessionCodec,
|
||||||
} from "@paperclipai/adapter-gemini-local/server";
|
} from "@paperclipai/adapter-gemini-local/server";
|
||||||
import { agentConfigurationDoc as geminiAgentConfigurationDoc, models as geminiModels } from "@paperclipai/adapter-gemini-local";
|
import {
|
||||||
|
agentConfigurationDoc as geminiAgentConfigurationDoc,
|
||||||
|
models as geminiModels,
|
||||||
|
modelProfiles as geminiModelProfiles,
|
||||||
|
} from "@paperclipai/adapter-gemini-local";
|
||||||
import {
|
import {
|
||||||
execute as openCodeExecute,
|
execute as openCodeExecute,
|
||||||
listOpenCodeSkills,
|
listOpenCodeSkills,
|
||||||
|
|
@ -46,6 +62,7 @@ import {
|
||||||
import {
|
import {
|
||||||
agentConfigurationDoc as openCodeAgentConfigurationDoc,
|
agentConfigurationDoc as openCodeAgentConfigurationDoc,
|
||||||
models as openCodeModels,
|
models as openCodeModels,
|
||||||
|
modelProfiles as openCodeModelProfiles,
|
||||||
} from "@paperclipai/adapter-opencode-local";
|
} from "@paperclipai/adapter-opencode-local";
|
||||||
import {
|
import {
|
||||||
execute as openclawGatewayExecute,
|
execute as openclawGatewayExecute,
|
||||||
|
|
@ -67,6 +84,7 @@ import {
|
||||||
} from "@paperclipai/adapter-pi-local/server";
|
} from "@paperclipai/adapter-pi-local/server";
|
||||||
import {
|
import {
|
||||||
agentConfigurationDoc as piAgentConfigurationDoc,
|
agentConfigurationDoc as piAgentConfigurationDoc,
|
||||||
|
modelProfiles as piModelProfiles,
|
||||||
} from "@paperclipai/adapter-pi-local";
|
} from "@paperclipai/adapter-pi-local";
|
||||||
import {
|
import {
|
||||||
execute as hermesExecute,
|
execute as hermesExecute,
|
||||||
|
|
@ -126,6 +144,7 @@ const claudeLocalAdapter: ServerAdapterModule = {
|
||||||
sessionCodec: claudeSessionCodec,
|
sessionCodec: claudeSessionCodec,
|
||||||
sessionManagement: getAdapterSessionManagement("claude_local") ?? undefined,
|
sessionManagement: getAdapterSessionManagement("claude_local") ?? undefined,
|
||||||
models: claudeModels,
|
models: claudeModels,
|
||||||
|
modelProfiles: claudeModelProfiles,
|
||||||
listModels: listClaudeModels,
|
listModels: listClaudeModels,
|
||||||
supportsLocalAgentJwt: true,
|
supportsLocalAgentJwt: true,
|
||||||
supportsInstructionsBundle: true,
|
supportsInstructionsBundle: true,
|
||||||
|
|
@ -144,6 +163,7 @@ const codexLocalAdapter: ServerAdapterModule = {
|
||||||
sessionCodec: codexSessionCodec,
|
sessionCodec: codexSessionCodec,
|
||||||
sessionManagement: getAdapterSessionManagement("codex_local") ?? undefined,
|
sessionManagement: getAdapterSessionManagement("codex_local") ?? undefined,
|
||||||
models: codexModels,
|
models: codexModels,
|
||||||
|
modelProfiles: codexModelProfiles,
|
||||||
listModels: listCodexModels,
|
listModels: listCodexModels,
|
||||||
refreshModels: refreshCodexModels,
|
refreshModels: refreshCodexModels,
|
||||||
supportsLocalAgentJwt: true,
|
supportsLocalAgentJwt: true,
|
||||||
|
|
@ -163,6 +183,7 @@ const cursorLocalAdapter: ServerAdapterModule = {
|
||||||
sessionCodec: cursorSessionCodec,
|
sessionCodec: cursorSessionCodec,
|
||||||
sessionManagement: getAdapterSessionManagement("cursor") ?? undefined,
|
sessionManagement: getAdapterSessionManagement("cursor") ?? undefined,
|
||||||
models: cursorModels,
|
models: cursorModels,
|
||||||
|
modelProfiles: cursorModelProfiles,
|
||||||
listModels: listCursorModels,
|
listModels: listCursorModels,
|
||||||
supportsLocalAgentJwt: true,
|
supportsLocalAgentJwt: true,
|
||||||
supportsInstructionsBundle: true,
|
supportsInstructionsBundle: true,
|
||||||
|
|
@ -180,6 +201,7 @@ const geminiLocalAdapter: ServerAdapterModule = {
|
||||||
sessionCodec: geminiSessionCodec,
|
sessionCodec: geminiSessionCodec,
|
||||||
sessionManagement: getAdapterSessionManagement("gemini_local") ?? undefined,
|
sessionManagement: getAdapterSessionManagement("gemini_local") ?? undefined,
|
||||||
models: geminiModels,
|
models: geminiModels,
|
||||||
|
modelProfiles: geminiModelProfiles,
|
||||||
supportsLocalAgentJwt: true,
|
supportsLocalAgentJwt: true,
|
||||||
supportsInstructionsBundle: true,
|
supportsInstructionsBundle: true,
|
||||||
instructionsPathKey: "instructionsFilePath",
|
instructionsPathKey: "instructionsFilePath",
|
||||||
|
|
@ -206,6 +228,7 @@ const openCodeLocalAdapter: ServerAdapterModule = {
|
||||||
syncSkills: syncOpenCodeSkills,
|
syncSkills: syncOpenCodeSkills,
|
||||||
sessionCodec: openCodeSessionCodec,
|
sessionCodec: openCodeSessionCodec,
|
||||||
models: openCodeModels,
|
models: openCodeModels,
|
||||||
|
modelProfiles: openCodeModelProfiles,
|
||||||
sessionManagement: getAdapterSessionManagement("opencode_local") ?? undefined,
|
sessionManagement: getAdapterSessionManagement("opencode_local") ?? undefined,
|
||||||
listModels: listOpenCodeModels,
|
listModels: listOpenCodeModels,
|
||||||
supportsLocalAgentJwt: true,
|
supportsLocalAgentJwt: true,
|
||||||
|
|
@ -224,6 +247,7 @@ const piLocalAdapter: ServerAdapterModule = {
|
||||||
sessionCodec: piSessionCodec,
|
sessionCodec: piSessionCodec,
|
||||||
sessionManagement: getAdapterSessionManagement("pi_local") ?? undefined,
|
sessionManagement: getAdapterSessionManagement("pi_local") ?? undefined,
|
||||||
models: [],
|
models: [],
|
||||||
|
modelProfiles: piModelProfiles,
|
||||||
listModels: listPiModels,
|
listModels: listPiModels,
|
||||||
supportsLocalAgentJwt: true,
|
supportsLocalAgentJwt: true,
|
||||||
supportsInstructionsBundle: true,
|
supportsInstructionsBundle: true,
|
||||||
|
|
@ -474,6 +498,16 @@ export async function refreshAdapterModels(type: string): Promise<{ id: string;
|
||||||
return adapter.models ?? [];
|
return adapter.models ?? [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function listAdapterModelProfiles(type: string): Promise<AdapterModelProfileDefinition[]> {
|
||||||
|
const adapter = findActiveServerAdapter(type);
|
||||||
|
if (!adapter) return [];
|
||||||
|
if (adapter.listModelProfiles) {
|
||||||
|
const discovered = await adapter.listModelProfiles();
|
||||||
|
if (discovered.length > 0) return discovered;
|
||||||
|
}
|
||||||
|
return adapter.modelProfiles ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
export function listServerAdapters(): ServerAdapterModule[] {
|
export function listServerAdapters(): ServerAdapterModule[] {
|
||||||
return Array.from(adaptersByType.values());
|
return Array.from(adaptersByType.values());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ export type {
|
||||||
AdapterSkillContext,
|
AdapterSkillContext,
|
||||||
AdapterSessionCodec,
|
AdapterSessionCodec,
|
||||||
AdapterModel,
|
AdapterModel,
|
||||||
|
AdapterModelProfileKey,
|
||||||
|
AdapterModelProfileDefinition,
|
||||||
NativeContextManagement,
|
NativeContextManagement,
|
||||||
ResolvedSessionCompactionPolicy,
|
ResolvedSessionCompactionPolicy,
|
||||||
SessionCompactionPolicy,
|
SessionCompactionPolicy,
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ interface AdapterCapabilities {
|
||||||
supportsSkills: boolean;
|
supportsSkills: boolean;
|
||||||
supportsLocalAgentJwt: boolean;
|
supportsLocalAgentJwt: boolean;
|
||||||
requiresMaterializedRuntimeSkills: boolean;
|
requiresMaterializedRuntimeSkills: boolean;
|
||||||
|
supportsModelProfiles: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AdapterInfo {
|
interface AdapterInfo {
|
||||||
|
|
@ -119,6 +120,7 @@ function buildAdapterCapabilities(adapter: ServerAdapterModule): AdapterCapabili
|
||||||
supportsSkills: Boolean(adapter.listSkills || adapter.syncSkills),
|
supportsSkills: Boolean(adapter.listSkills || adapter.syncSkills),
|
||||||
supportsLocalAgentJwt: adapter.supportsLocalAgentJwt ?? false,
|
supportsLocalAgentJwt: adapter.supportsLocalAgentJwt ?? false,
|
||||||
requiresMaterializedRuntimeSkills: adapter.requiresMaterializedRuntimeSkills ?? false,
|
requiresMaterializedRuntimeSkills: adapter.requiresMaterializedRuntimeSkills ?? false,
|
||||||
|
supportsModelProfiles: Boolean(adapter.modelProfiles?.length || adapter.listModelProfiles),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ import {
|
||||||
findActiveServerAdapter,
|
findActiveServerAdapter,
|
||||||
findServerAdapter,
|
findServerAdapter,
|
||||||
listAdapterModels,
|
listAdapterModels,
|
||||||
|
listAdapterModelProfiles,
|
||||||
refreshAdapterModels,
|
refreshAdapterModels,
|
||||||
requireServerAdapter,
|
requireServerAdapter,
|
||||||
} from "../adapters/index.js";
|
} from "../adapters/index.js";
|
||||||
|
|
@ -710,6 +711,99 @@ export function agentRoutes(
|
||||||
return normalizedRuntimeConfig;
|
return normalizedRuntimeConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function listRuntimeModelProfileAdapterConfigs(runtimeConfig: unknown): Array<{
|
||||||
|
profileKey: string;
|
||||||
|
profile: Record<string, unknown>;
|
||||||
|
adapterConfig: Record<string, unknown>;
|
||||||
|
path: string;
|
||||||
|
}> {
|
||||||
|
const runtimeRecord = asRecord(runtimeConfig);
|
||||||
|
const modelProfiles = asRecord(runtimeRecord?.modelProfiles);
|
||||||
|
if (!modelProfiles) return [];
|
||||||
|
|
||||||
|
const entries: Array<{
|
||||||
|
profileKey: string;
|
||||||
|
profile: Record<string, unknown>;
|
||||||
|
adapterConfig: Record<string, unknown>;
|
||||||
|
path: string;
|
||||||
|
}> = [];
|
||||||
|
for (const [profileKey, rawProfile] of Object.entries(modelProfiles)) {
|
||||||
|
const profile = asRecord(rawProfile);
|
||||||
|
const adapterConfig = asRecord(profile?.adapterConfig);
|
||||||
|
if (!profile || !adapterConfig) continue;
|
||||||
|
entries.push({
|
||||||
|
profileKey,
|
||||||
|
profile,
|
||||||
|
adapterConfig,
|
||||||
|
path: `runtimeConfig.modelProfiles.${profileKey}.adapterConfig`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertNoAgentRuntimeConfigAdapterConfigMutation(req: Request, runtimeConfig: unknown) {
|
||||||
|
for (const entry of listRuntimeModelProfileAdapterConfigs(runtimeConfig)) {
|
||||||
|
assertNoAgentAdapterConfigMutation(req, entry.adapterConfig, entry.path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function normalizeMediatedAdapterConfigForPersistence(input: {
|
||||||
|
companyId: string;
|
||||||
|
adapterType: string | null | undefined;
|
||||||
|
adapterConfig: Record<string, unknown>;
|
||||||
|
constraintAdapterConfig?: Record<string, unknown>;
|
||||||
|
}): Promise<Record<string, unknown>> {
|
||||||
|
const normalizedAdapterConfig = await secretsSvc.normalizeAdapterConfigForPersistence(
|
||||||
|
input.companyId,
|
||||||
|
input.adapterConfig,
|
||||||
|
{ strictMode: strictSecretsMode },
|
||||||
|
);
|
||||||
|
await assertAdapterConfigConstraints(
|
||||||
|
input.companyId,
|
||||||
|
input.adapterType,
|
||||||
|
input.constraintAdapterConfig
|
||||||
|
? { ...input.constraintAdapterConfig, ...normalizedAdapterConfig }
|
||||||
|
: normalizedAdapterConfig,
|
||||||
|
);
|
||||||
|
return normalizedAdapterConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function normalizeRuntimeConfigAdapterConfigsForPersistence(
|
||||||
|
companyId: string,
|
||||||
|
adapterType: string,
|
||||||
|
runtimeConfig: Record<string, unknown>,
|
||||||
|
baseAdapterConfig: Record<string, unknown>,
|
||||||
|
): Promise<Record<string, unknown>> {
|
||||||
|
const entries = listRuntimeModelProfileAdapterConfigs(runtimeConfig);
|
||||||
|
if (entries.length === 0) return runtimeConfig;
|
||||||
|
const adapterModelProfiles = await listAdapterModelProfiles(adapterType);
|
||||||
|
|
||||||
|
const normalizedRuntimeConfig = { ...runtimeConfig };
|
||||||
|
const modelProfiles = asRecord(runtimeConfig.modelProfiles) ?? {};
|
||||||
|
const normalizedModelProfiles = { ...modelProfiles };
|
||||||
|
normalizedRuntimeConfig.modelProfiles = normalizedModelProfiles;
|
||||||
|
|
||||||
|
for (const entry of entries) {
|
||||||
|
const adapterProfile = adapterModelProfiles.find((profile) => profile.key === entry.profileKey);
|
||||||
|
const adapterDefaultConfig = asRecord(adapterProfile?.adapterConfig) ?? {};
|
||||||
|
const normalizedAdapterConfig = await normalizeMediatedAdapterConfigForPersistence({
|
||||||
|
companyId,
|
||||||
|
adapterType,
|
||||||
|
adapterConfig: entry.adapterConfig,
|
||||||
|
constraintAdapterConfig: {
|
||||||
|
...baseAdapterConfig,
|
||||||
|
...adapterDefaultConfig,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
normalizedModelProfiles[entry.profileKey] = {
|
||||||
|
...entry.profile,
|
||||||
|
adapterConfig: normalizedAdapterConfig,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return normalizedRuntimeConfig;
|
||||||
|
}
|
||||||
|
|
||||||
function generateEd25519PrivateKeyPem(): string {
|
function generateEd25519PrivateKeyPem(): string {
|
||||||
const { privateKey } = generateKeyPairSync("ed25519");
|
const { privateKey } = generateKeyPairSync("ed25519");
|
||||||
return privateKey.export({ type: "pkcs8", format: "pem" }).toString();
|
return privateKey.export({ type: "pkcs8", format: "pem" }).toString();
|
||||||
|
|
@ -866,15 +960,34 @@ export function agentRoutes(
|
||||||
function assertNoAgentInstructionsConfigMutation(
|
function assertNoAgentInstructionsConfigMutation(
|
||||||
req: Request,
|
req: Request,
|
||||||
adapterConfig: Record<string, unknown> | null | undefined,
|
adapterConfig: Record<string, unknown> | null | undefined,
|
||||||
|
path = "adapterConfig",
|
||||||
) {
|
) {
|
||||||
if (req.actor.type !== "agent" || !adapterConfig) return;
|
if (req.actor.type !== "agent" || !adapterConfig) return;
|
||||||
const changedSensitiveKeys = KNOWN_INSTRUCTIONS_BUNDLE_KEYS.filter((key) => adapterConfig[key] !== undefined);
|
const changedSensitiveKeys = KNOWN_INSTRUCTIONS_BUNDLE_KEYS
|
||||||
|
.filter((key) => adapterConfig[key] !== undefined)
|
||||||
|
.map((key) => `${path}.${key}`);
|
||||||
if (changedSensitiveKeys.length === 0) return;
|
if (changedSensitiveKeys.length === 0) return;
|
||||||
throw forbidden(
|
throw forbidden(
|
||||||
`Agent-authenticated callers cannot modify instructions path or bundle configuration (${changedSensitiveKeys.join(", ")})`,
|
`Agent-authenticated callers cannot modify instructions path or bundle configuration (${changedSensitiveKeys.join(", ")})`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function adapterConfigTouchesInstructionsConfig(adapterConfig: Record<string, unknown>) {
|
||||||
|
return KNOWN_INSTRUCTIONS_BUNDLE_KEYS.some((key) => adapterConfig[key] !== undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertNoAgentAdapterConfigMutation(
|
||||||
|
req: Request,
|
||||||
|
adapterConfig: Record<string, unknown>,
|
||||||
|
path = "adapterConfig",
|
||||||
|
) {
|
||||||
|
assertNoAgentInstructionsConfigMutation(req, adapterConfig, path);
|
||||||
|
assertNoAgentHostWorkspaceCommandMutation(
|
||||||
|
req,
|
||||||
|
collectAgentAdapterWorkspaceCommandPaths(adapterConfig, path),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function summarizeAgentUpdateDetails(patch: Record<string, unknown>) {
|
function summarizeAgentUpdateDetails(patch: Record<string, unknown>) {
|
||||||
const changedTopLevelKeys = Object.keys(patch).sort();
|
const changedTopLevelKeys = Object.keys(patch).sort();
|
||||||
const details: Record<string, unknown> = { changedTopLevelKeys };
|
const details: Record<string, unknown> = { changedTopLevelKeys };
|
||||||
|
|
@ -1064,6 +1177,14 @@ export function agentRoutes(
|
||||||
res.json(models);
|
res.json(models);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.get("/companies/:companyId/adapters/:type/model-profiles", async (req, res) => {
|
||||||
|
const companyId = req.params.companyId as string;
|
||||||
|
assertCompanyAccess(req, companyId);
|
||||||
|
const type = assertKnownAdapterType(req.params.type as string);
|
||||||
|
const profiles = await listAdapterModelProfiles(type);
|
||||||
|
res.json(profiles);
|
||||||
|
});
|
||||||
|
|
||||||
router.get("/companies/:companyId/adapters/:type/detect-model", async (req, res) => {
|
router.get("/companies/:companyId/adapters/:type/detect-model", async (req, res) => {
|
||||||
const companyId = req.params.companyId as string;
|
const companyId = req.params.companyId as string;
|
||||||
assertCompanyAccess(req, companyId);
|
assertCompanyAccess(req, companyId);
|
||||||
|
|
@ -1624,21 +1745,16 @@ export function agentRoutes(
|
||||||
...hireInput
|
...hireInput
|
||||||
} = req.body;
|
} = req.body;
|
||||||
hireInput.adapterType = assertKnownAdapterType(hireInput.adapterType);
|
hireInput.adapterType = assertKnownAdapterType(hireInput.adapterType);
|
||||||
|
const rawHireAdapterConfig = (hireInput.adapterConfig ?? {}) as Record<string, unknown>;
|
||||||
assertNoNewAgentLegacyPromptTemplate(
|
assertNoNewAgentLegacyPromptTemplate(
|
||||||
hireInput.adapterType,
|
hireInput.adapterType,
|
||||||
(hireInput.adapterConfig ?? {}) as Record<string, unknown>,
|
rawHireAdapterConfig,
|
||||||
);
|
|
||||||
assertNoAgentHostWorkspaceCommandMutation(
|
|
||||||
req,
|
|
||||||
collectAgentAdapterWorkspaceCommandPaths(hireInput.adapterConfig),
|
|
||||||
);
|
|
||||||
assertNoAgentInstructionsConfigMutation(
|
|
||||||
req,
|
|
||||||
(hireInput.adapterConfig ?? {}) as Record<string, unknown>,
|
|
||||||
);
|
);
|
||||||
|
assertNoAgentAdapterConfigMutation(req, rawHireAdapterConfig);
|
||||||
|
assertNoAgentRuntimeConfigAdapterConfigMutation(req, hireInput.runtimeConfig);
|
||||||
const requestedAdapterConfig = applyCreateDefaultsByAdapterType(
|
const requestedAdapterConfig = applyCreateDefaultsByAdapterType(
|
||||||
hireInput.adapterType,
|
hireInput.adapterType,
|
||||||
((hireInput.adapterConfig ?? {}) as Record<string, unknown>),
|
rawHireAdapterConfig,
|
||||||
);
|
);
|
||||||
const desiredSkillAssignment = await resolveDesiredSkillAssignment(
|
const desiredSkillAssignment = await resolveDesiredSkillAssignment(
|
||||||
companyId,
|
companyId,
|
||||||
|
|
@ -1646,20 +1762,21 @@ export function agentRoutes(
|
||||||
requestedAdapterConfig,
|
requestedAdapterConfig,
|
||||||
Array.isArray(requestedDesiredSkills) ? requestedDesiredSkills : undefined,
|
Array.isArray(requestedDesiredSkills) ? requestedDesiredSkills : undefined,
|
||||||
);
|
);
|
||||||
const normalizedAdapterConfig = await secretsSvc.normalizeAdapterConfigForPersistence(
|
const normalizedAdapterConfig = await normalizeMediatedAdapterConfigForPersistence({
|
||||||
companyId,
|
companyId,
|
||||||
desiredSkillAssignment.adapterConfig,
|
adapterType: hireInput.adapterType,
|
||||||
{ strictMode: strictSecretsMode },
|
adapterConfig: desiredSkillAssignment.adapterConfig,
|
||||||
);
|
});
|
||||||
await assertAdapterConfigConstraints(
|
const normalizedRuntimeConfig = await normalizeRuntimeConfigAdapterConfigsForPersistence(
|
||||||
companyId,
|
companyId,
|
||||||
hireInput.adapterType,
|
hireInput.adapterType,
|
||||||
|
normalizeNewAgentRuntimeConfig(hireInput.runtimeConfig),
|
||||||
normalizedAdapterConfig,
|
normalizedAdapterConfig,
|
||||||
);
|
);
|
||||||
const normalizedHireInput = {
|
const normalizedHireInput = {
|
||||||
...hireInput,
|
...hireInput,
|
||||||
adapterConfig: normalizedAdapterConfig,
|
adapterConfig: normalizedAdapterConfig,
|
||||||
runtimeConfig: normalizeNewAgentRuntimeConfig(hireInput.runtimeConfig),
|
runtimeConfig: normalizedRuntimeConfig,
|
||||||
};
|
};
|
||||||
|
|
||||||
const company = await db
|
const company = await db
|
||||||
|
|
@ -1814,21 +1931,16 @@ export function agentRoutes(
|
||||||
...createInput
|
...createInput
|
||||||
} = req.body;
|
} = req.body;
|
||||||
createInput.adapterType = assertKnownAdapterType(createInput.adapterType);
|
createInput.adapterType = assertKnownAdapterType(createInput.adapterType);
|
||||||
|
const rawCreateAdapterConfig = (createInput.adapterConfig ?? {}) as Record<string, unknown>;
|
||||||
assertNoNewAgentLegacyPromptTemplate(
|
assertNoNewAgentLegacyPromptTemplate(
|
||||||
createInput.adapterType,
|
createInput.adapterType,
|
||||||
(createInput.adapterConfig ?? {}) as Record<string, unknown>,
|
rawCreateAdapterConfig,
|
||||||
);
|
|
||||||
assertNoAgentHostWorkspaceCommandMutation(
|
|
||||||
req,
|
|
||||||
collectAgentAdapterWorkspaceCommandPaths(createInput.adapterConfig),
|
|
||||||
);
|
|
||||||
assertNoAgentInstructionsConfigMutation(
|
|
||||||
req,
|
|
||||||
(createInput.adapterConfig ?? {}) as Record<string, unknown>,
|
|
||||||
);
|
);
|
||||||
|
assertNoAgentAdapterConfigMutation(req, rawCreateAdapterConfig);
|
||||||
|
assertNoAgentRuntimeConfigAdapterConfigMutation(req, createInput.runtimeConfig);
|
||||||
const requestedAdapterConfig = applyCreateDefaultsByAdapterType(
|
const requestedAdapterConfig = applyCreateDefaultsByAdapterType(
|
||||||
createInput.adapterType,
|
createInput.adapterType,
|
||||||
((createInput.adapterConfig ?? {}) as Record<string, unknown>),
|
rawCreateAdapterConfig,
|
||||||
);
|
);
|
||||||
const desiredSkillAssignment = await resolveDesiredSkillAssignment(
|
const desiredSkillAssignment = await resolveDesiredSkillAssignment(
|
||||||
companyId,
|
companyId,
|
||||||
|
|
@ -1836,14 +1948,15 @@ export function agentRoutes(
|
||||||
requestedAdapterConfig,
|
requestedAdapterConfig,
|
||||||
Array.isArray(requestedDesiredSkills) ? requestedDesiredSkills : undefined,
|
Array.isArray(requestedDesiredSkills) ? requestedDesiredSkills : undefined,
|
||||||
);
|
);
|
||||||
const normalizedAdapterConfig = await secretsSvc.normalizeAdapterConfigForPersistence(
|
const normalizedAdapterConfig = await normalizeMediatedAdapterConfigForPersistence({
|
||||||
companyId,
|
companyId,
|
||||||
desiredSkillAssignment.adapterConfig,
|
adapterType: createInput.adapterType,
|
||||||
{ strictMode: strictSecretsMode },
|
adapterConfig: desiredSkillAssignment.adapterConfig,
|
||||||
);
|
});
|
||||||
await assertAdapterConfigConstraints(
|
const normalizedRuntimeConfig = await normalizeRuntimeConfigAdapterConfigsForPersistence(
|
||||||
companyId,
|
companyId,
|
||||||
createInput.adapterType,
|
createInput.adapterType,
|
||||||
|
normalizeNewAgentRuntimeConfig(createInput.runtimeConfig),
|
||||||
normalizedAdapterConfig,
|
normalizedAdapterConfig,
|
||||||
);
|
);
|
||||||
await assertAgentEnvironmentSelection(companyId, createInput.adapterType, createInput.defaultEnvironmentId);
|
await assertAgentEnvironmentSelection(companyId, createInput.adapterType, createInput.defaultEnvironmentId);
|
||||||
|
|
@ -1855,7 +1968,7 @@ export function agentRoutes(
|
||||||
const createdAgent = await svc.create(companyId, {
|
const createdAgent = await svc.create(companyId, {
|
||||||
...createInput,
|
...createInput,
|
||||||
adapterConfig: normalizedAdapterConfig,
|
adapterConfig: normalizedAdapterConfig,
|
||||||
runtimeConfig: normalizeNewAgentRuntimeConfig(createInput.runtimeConfig),
|
runtimeConfig: normalizedRuntimeConfig,
|
||||||
status: "idle",
|
status: "idle",
|
||||||
spentMonthlyCents: 0,
|
spentMonthlyCents: 0,
|
||||||
lastHeartbeatAt: null,
|
lastHeartbeatAt: null,
|
||||||
|
|
@ -2230,14 +2343,8 @@ export function agentRoutes(
|
||||||
res.status(422).json({ error: "adapterConfig must be an object" });
|
res.status(422).json({ error: "adapterConfig must be an object" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
assertNoAgentInstructionsConfigMutation(req, adapterConfig);
|
assertNoAgentAdapterConfigMutation(req, adapterConfig);
|
||||||
assertNoAgentHostWorkspaceCommandMutation(
|
const changingInstructionsConfig = adapterConfigTouchesInstructionsConfig(adapterConfig);
|
||||||
req,
|
|
||||||
collectAgentAdapterWorkspaceCommandPaths(adapterConfig),
|
|
||||||
);
|
|
||||||
const changingInstructionsConfig = Object.keys(adapterConfig).some((key) =>
|
|
||||||
KNOWN_INSTRUCTIONS_BUNDLE_KEYS.includes(key as (typeof KNOWN_INSTRUCTIONS_BUNDLE_KEYS)[number]),
|
|
||||||
);
|
|
||||||
if (changingInstructionsConfig) {
|
if (changingInstructionsConfig) {
|
||||||
await assertCanManageInstructionsPath(req, existing);
|
await assertCanManageInstructionsPath(req, existing);
|
||||||
}
|
}
|
||||||
|
|
@ -2247,6 +2354,16 @@ export function agentRoutes(
|
||||||
const requestedAdapterType = hasOwn(patchData, "adapterType")
|
const requestedAdapterType = hasOwn(patchData, "adapterType")
|
||||||
? assertKnownAdapterType(patchData.adapterType as string | null | undefined)
|
? assertKnownAdapterType(patchData.adapterType as string | null | undefined)
|
||||||
: existing.adapterType;
|
: existing.adapterType;
|
||||||
|
let requestedRuntimeConfig: Record<string, unknown> | null = null;
|
||||||
|
if (hasOwn(patchData, "runtimeConfig")) {
|
||||||
|
const runtimeConfig = asRecord(patchData.runtimeConfig);
|
||||||
|
if (!runtimeConfig) {
|
||||||
|
res.status(422).json({ error: "runtimeConfig must be an object" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
assertNoAgentRuntimeConfigAdapterConfigMutation(req, runtimeConfig);
|
||||||
|
requestedRuntimeConfig = runtimeConfig;
|
||||||
|
}
|
||||||
const touchesAdapterConfiguration =
|
const touchesAdapterConfiguration =
|
||||||
hasOwn(patchData, "adapterType") ||
|
hasOwn(patchData, "adapterType") ||
|
||||||
hasOwn(patchData, "adapterConfig");
|
hasOwn(patchData, "adapterConfig");
|
||||||
|
|
@ -2292,19 +2409,20 @@ export function agentRoutes(
|
||||||
requestedAdapterType,
|
requestedAdapterType,
|
||||||
rawEffectiveAdapterConfig,
|
rawEffectiveAdapterConfig,
|
||||||
);
|
);
|
||||||
const normalizedEffectiveAdapterConfig = await secretsSvc.normalizeAdapterConfigForPersistence(
|
const normalizedEffectiveAdapterConfig = await normalizeMediatedAdapterConfigForPersistence({
|
||||||
existing.companyId,
|
companyId: existing.companyId,
|
||||||
effectiveAdapterConfig,
|
adapterType: requestedAdapterType,
|
||||||
{ strictMode: strictSecretsMode },
|
adapterConfig: effectiveAdapterConfig,
|
||||||
);
|
});
|
||||||
patchData.adapterConfig = syncInstructionsBundleConfigFromFilePath(existing, normalizedEffectiveAdapterConfig);
|
patchData.adapterConfig = syncInstructionsBundleConfigFromFilePath(existing, normalizedEffectiveAdapterConfig);
|
||||||
}
|
}
|
||||||
if (touchesAdapterConfiguration && requestedAdapterType === "opencode_local") {
|
if (requestedRuntimeConfig) {
|
||||||
const effectiveAdapterConfig = asRecord(patchData.adapterConfig) ?? {};
|
const baseAdapterConfig = asRecord(patchData.adapterConfig) ?? asRecord(existing.adapterConfig) ?? {};
|
||||||
await assertAdapterConfigConstraints(
|
patchData.runtimeConfig = await normalizeRuntimeConfigAdapterConfigsForPersistence(
|
||||||
existing.companyId,
|
existing.companyId,
|
||||||
requestedAdapterType,
|
requestedAdapterType,
|
||||||
effectiveAdapterConfig,
|
requestedRuntimeConfig,
|
||||||
|
baseAdapterConfig,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (touchesAdapterConfiguration || Object.prototype.hasOwnProperty.call(patchData, "defaultEnvironmentId")) {
|
if (touchesAdapterConfiguration || Object.prototype.hasOwnProperty.call(patchData, "defaultEnvironmentId")) {
|
||||||
|
|
|
||||||
|
|
@ -47,11 +47,14 @@ export function assertNoAgentHostWorkspaceCommandMutation(req: Request, paths: s
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function collectAgentAdapterWorkspaceCommandPaths(adapterConfig: unknown): string[] {
|
export function collectAgentAdapterWorkspaceCommandPaths(
|
||||||
|
adapterConfig: unknown,
|
||||||
|
prefix = "adapterConfig",
|
||||||
|
): string[] {
|
||||||
if (!isRecord(adapterConfig)) return [];
|
if (!isRecord(adapterConfig)) return [];
|
||||||
return collectWorkspaceStrategyCommandPaths(
|
return collectWorkspaceStrategyCommandPaths(
|
||||||
adapterConfig.workspaceStrategy,
|
adapterConfig.workspaceStrategy,
|
||||||
"adapterConfig.workspaceStrategy",
|
`${prefix}.workspaceStrategy`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,13 @@ import type { Db } from "@paperclipai/db";
|
||||||
import {
|
import {
|
||||||
AGENT_DEFAULT_MAX_CONCURRENT_RUNS,
|
AGENT_DEFAULT_MAX_CONCURRENT_RUNS,
|
||||||
ISSUE_CONTINUATION_SUMMARY_DOCUMENT_KEY,
|
ISSUE_CONTINUATION_SUMMARY_DOCUMENT_KEY,
|
||||||
|
MODEL_PROFILE_KEYS,
|
||||||
isEnvironmentDriverSupportedForAdapter,
|
isEnvironmentDriverSupportedForAdapter,
|
||||||
type BillingType,
|
type BillingType,
|
||||||
type EnvironmentLeaseStatus,
|
type EnvironmentLeaseStatus,
|
||||||
type ExecutionWorkspace,
|
type ExecutionWorkspace,
|
||||||
type ExecutionWorkspaceConfig,
|
type ExecutionWorkspaceConfig,
|
||||||
|
type ModelProfileKey,
|
||||||
type RunLivenessState,
|
type RunLivenessState,
|
||||||
} from "@paperclipai/shared";
|
} from "@paperclipai/shared";
|
||||||
import {
|
import {
|
||||||
|
|
@ -38,8 +40,14 @@ import { conflict, HttpError, notFound } from "../errors.js";
|
||||||
import { logger } from "../middleware/logger.js";
|
import { logger } from "../middleware/logger.js";
|
||||||
import { publishLiveEvent } from "./live-events.js";
|
import { publishLiveEvent } from "./live-events.js";
|
||||||
import { getRunLogStore, type RunLogHandle } from "./run-log-store.js";
|
import { getRunLogStore, type RunLogHandle } from "./run-log-store.js";
|
||||||
import { getServerAdapter, runningProcesses } from "../adapters/index.js";
|
import { getServerAdapter, listAdapterModelProfiles, runningProcesses } from "../adapters/index.js";
|
||||||
import type { AdapterExecutionResult, AdapterInvocationMeta, AdapterSessionCodec, UsageSummary } from "../adapters/index.js";
|
import type {
|
||||||
|
AdapterExecutionResult,
|
||||||
|
AdapterInvocationMeta,
|
||||||
|
AdapterModelProfileDefinition,
|
||||||
|
AdapterSessionCodec,
|
||||||
|
UsageSummary,
|
||||||
|
} from "../adapters/index.js";
|
||||||
import { createLocalAgentJwt } from "../agent-auth-jwt.js";
|
import { createLocalAgentJwt } from "../agent-auth-jwt.js";
|
||||||
import { parseObject, asBoolean, asNumber, appendWithByteCap, MAX_EXCERPT_BYTES } from "../adapters/utils.js";
|
import { parseObject, asBoolean, asNumber, appendWithByteCap, MAX_EXCERPT_BYTES } from "../adapters/utils.js";
|
||||||
import { costService } from "./costs.js";
|
import { costService } from "./costs.js";
|
||||||
|
|
@ -879,10 +887,23 @@ type SessionCompactionDecision = {
|
||||||
};
|
};
|
||||||
|
|
||||||
interface ParsedIssueAssigneeAdapterOverrides {
|
interface ParsedIssueAssigneeAdapterOverrides {
|
||||||
|
modelProfile: ModelProfileKey | null;
|
||||||
adapterConfig: Record<string, unknown> | null;
|
adapterConfig: Record<string, unknown> | null;
|
||||||
useProjectWorkspace: boolean | null;
|
useProjectWorkspace: boolean | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ModelProfileRequestSource = "issue_override" | "wake_context";
|
||||||
|
type AppliedModelProfileConfigSource = "agent_runtime" | "adapter_default";
|
||||||
|
|
||||||
|
export interface ModelProfileApplication {
|
||||||
|
requested: ModelProfileKey | null;
|
||||||
|
requestedBy: ModelProfileRequestSource | null;
|
||||||
|
applied: ModelProfileKey | null;
|
||||||
|
configSource: AppliedModelProfileConfigSource | null;
|
||||||
|
fallbackReason: string | null;
|
||||||
|
adapterConfig: Record<string, unknown> | null;
|
||||||
|
}
|
||||||
|
|
||||||
export type ResolvedWorkspaceForRun = {
|
export type ResolvedWorkspaceForRun = {
|
||||||
cwd: string;
|
cwd: string;
|
||||||
source: "project_primary" | "task_session" | "agent_home";
|
source: "project_primary" | "task_session" | "agent_home";
|
||||||
|
|
@ -917,6 +938,147 @@ function readNonEmptyString(value: unknown): string | null {
|
||||||
return typeof value === "string" && value.trim().length > 0 ? value : null;
|
return typeof value === "string" && value.trim().length > 0 ? value : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function readModelProfileKey(value: unknown): ModelProfileKey | null {
|
||||||
|
return MODEL_PROFILE_KEYS.includes(value as ModelProfileKey)
|
||||||
|
? (value as ModelProfileKey)
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function readContextModelProfile(
|
||||||
|
contextSnapshot: Record<string, unknown> | null | undefined,
|
||||||
|
): ModelProfileKey | null {
|
||||||
|
return readModelProfileKey(contextSnapshot?.modelProfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function normalizeModelProfileWakeContext(input: {
|
||||||
|
contextSnapshot: Record<string, unknown>;
|
||||||
|
payload: Record<string, unknown> | null | undefined;
|
||||||
|
}): Record<string, unknown> {
|
||||||
|
const modelProfileFromPayload = readModelProfileKey(input.payload?.modelProfile);
|
||||||
|
if (!readContextModelProfile(input.contextSnapshot) && modelProfileFromPayload) {
|
||||||
|
input.contextSnapshot.modelProfile = modelProfileFromPayload;
|
||||||
|
}
|
||||||
|
return input.contextSnapshot;
|
||||||
|
}
|
||||||
|
|
||||||
|
function readAgentRuntimeModelProfile(
|
||||||
|
runtimeConfig: unknown,
|
||||||
|
key: ModelProfileKey,
|
||||||
|
): { enabled: boolean; adapterConfig: Record<string, unknown>; configured: boolean } {
|
||||||
|
const modelProfiles = parseObject(parseObject(runtimeConfig).modelProfiles);
|
||||||
|
const profile = parseObject(modelProfiles[key]);
|
||||||
|
if (Object.keys(profile).length === 0) {
|
||||||
|
return { enabled: true, adapterConfig: {}, configured: false };
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
enabled: profile.enabled !== false,
|
||||||
|
adapterConfig: parseObject(profile.adapterConfig),
|
||||||
|
configured: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function resolveModelProfileApplication(input: {
|
||||||
|
adapterModelProfiles: AdapterModelProfileDefinition[];
|
||||||
|
agentRuntimeConfig: unknown;
|
||||||
|
issueModelProfile: ModelProfileKey | null | undefined;
|
||||||
|
contextSnapshot: Record<string, unknown> | null | undefined;
|
||||||
|
profileResolutionFallbackReason?: string | null;
|
||||||
|
}): ModelProfileApplication {
|
||||||
|
const issueModelProfile = input.issueModelProfile ?? null;
|
||||||
|
const contextModelProfile = readContextModelProfile(input.contextSnapshot);
|
||||||
|
const requested = issueModelProfile ?? contextModelProfile;
|
||||||
|
const requestedBy: ModelProfileRequestSource | null = issueModelProfile
|
||||||
|
? "issue_override"
|
||||||
|
: contextModelProfile
|
||||||
|
? "wake_context"
|
||||||
|
: null;
|
||||||
|
|
||||||
|
if (!requested) {
|
||||||
|
return {
|
||||||
|
requested: null,
|
||||||
|
requestedBy: null,
|
||||||
|
applied: null,
|
||||||
|
configSource: null,
|
||||||
|
fallbackReason: null,
|
||||||
|
adapterConfig: null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const adapterProfile = input.adapterModelProfiles.find((profile) => profile.key === requested) ?? null;
|
||||||
|
if (!adapterProfile) {
|
||||||
|
return {
|
||||||
|
requested,
|
||||||
|
requestedBy,
|
||||||
|
applied: null,
|
||||||
|
configSource: null,
|
||||||
|
fallbackReason: input.profileResolutionFallbackReason ?? "adapter_profile_not_supported",
|
||||||
|
adapterConfig: null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const runtimeProfile = readAgentRuntimeModelProfile(input.agentRuntimeConfig, requested);
|
||||||
|
if (!runtimeProfile.enabled) {
|
||||||
|
return {
|
||||||
|
requested,
|
||||||
|
requestedBy,
|
||||||
|
applied: null,
|
||||||
|
configSource: null,
|
||||||
|
fallbackReason: "agent_runtime_profile_disabled",
|
||||||
|
adapterConfig: null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
requested,
|
||||||
|
requestedBy,
|
||||||
|
applied: requested,
|
||||||
|
configSource: runtimeProfile.configured ? "agent_runtime" : "adapter_default",
|
||||||
|
fallbackReason: null,
|
||||||
|
adapterConfig: {
|
||||||
|
...parseObject(adapterProfile.adapterConfig),
|
||||||
|
...runtimeProfile.adapterConfig,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function mergeModelProfileAdapterConfig(input: {
|
||||||
|
baseConfig: Record<string, unknown>;
|
||||||
|
modelProfile: ModelProfileApplication;
|
||||||
|
issueAdapterConfig: Record<string, unknown> | null | undefined;
|
||||||
|
}): Record<string, unknown> {
|
||||||
|
return {
|
||||||
|
...input.baseConfig,
|
||||||
|
...(input.modelProfile.adapterConfig ?? {}),
|
||||||
|
...(input.issueAdapterConfig ?? {}),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function modelProfileRunMetadata(
|
||||||
|
modelProfile: ModelProfileApplication,
|
||||||
|
): Record<string, unknown> | null {
|
||||||
|
if (!modelProfile.requested) return null;
|
||||||
|
return {
|
||||||
|
requested: modelProfile.requested,
|
||||||
|
requestedBy: modelProfile.requestedBy,
|
||||||
|
applied: modelProfile.applied,
|
||||||
|
configSource: modelProfile.configSource,
|
||||||
|
fallbackReason: modelProfile.fallbackReason,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function mergeModelProfileRunMetadata(
|
||||||
|
resultJson: Record<string, unknown> | null,
|
||||||
|
modelProfile: ModelProfileApplication,
|
||||||
|
): Record<string, unknown> | null {
|
||||||
|
const metadata = modelProfileRunMetadata(modelProfile);
|
||||||
|
if (!metadata) return resultJson;
|
||||||
|
return {
|
||||||
|
...(resultJson ?? {}),
|
||||||
|
modelProfile: metadata,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function summarizeHeartbeatRunContextSnapshot(
|
export function summarizeHeartbeatRunContextSnapshot(
|
||||||
contextSnapshot: Record<string, unknown> | null | undefined,
|
contextSnapshot: Record<string, unknown> | null | undefined,
|
||||||
): Record<string, unknown> | null {
|
): Record<string, unknown> | null {
|
||||||
|
|
@ -930,6 +1092,7 @@ export function summarizeHeartbeatRunContextSnapshot(
|
||||||
"wakeReason",
|
"wakeReason",
|
||||||
"wakeSource",
|
"wakeSource",
|
||||||
"wakeTriggerDetail",
|
"wakeTriggerDetail",
|
||||||
|
"modelProfile",
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
for (const key of allowedKeys) {
|
for (const key of allowedKeys) {
|
||||||
|
|
@ -1259,6 +1422,9 @@ function parseIssueAssigneeAdapterOverrides(
|
||||||
raw: unknown,
|
raw: unknown,
|
||||||
): ParsedIssueAssigneeAdapterOverrides | null {
|
): ParsedIssueAssigneeAdapterOverrides | null {
|
||||||
const parsed = parseObject(raw);
|
const parsed = parseObject(raw);
|
||||||
|
const modelProfile = MODEL_PROFILE_KEYS.includes(parsed.modelProfile as ModelProfileKey)
|
||||||
|
? parsed.modelProfile as ModelProfileKey
|
||||||
|
: null;
|
||||||
const parsedAdapterConfig = parseObject(parsed.adapterConfig);
|
const parsedAdapterConfig = parseObject(parsed.adapterConfig);
|
||||||
const adapterConfig =
|
const adapterConfig =
|
||||||
Object.keys(parsedAdapterConfig).length > 0 ? parsedAdapterConfig : null;
|
Object.keys(parsedAdapterConfig).length > 0 ? parsedAdapterConfig : null;
|
||||||
|
|
@ -1266,8 +1432,9 @@ function parseIssueAssigneeAdapterOverrides(
|
||||||
typeof parsed.useProjectWorkspace === "boolean"
|
typeof parsed.useProjectWorkspace === "boolean"
|
||||||
? parsed.useProjectWorkspace
|
? parsed.useProjectWorkspace
|
||||||
: null;
|
: null;
|
||||||
if (!adapterConfig && useProjectWorkspace === null) return null;
|
if (!modelProfile && !adapterConfig && useProjectWorkspace === null) return null;
|
||||||
return {
|
return {
|
||||||
|
modelProfile,
|
||||||
adapterConfig,
|
adapterConfig,
|
||||||
useProjectWorkspace,
|
useProjectWorkspace,
|
||||||
};
|
};
|
||||||
|
|
@ -1551,6 +1718,7 @@ function enrichWakeContextSnapshot(input: {
|
||||||
if (!readNonEmptyString(contextSnapshot["wakeTriggerDetail"]) && triggerDetail) {
|
if (!readNonEmptyString(contextSnapshot["wakeTriggerDetail"]) && triggerDetail) {
|
||||||
contextSnapshot.wakeTriggerDetail = triggerDetail;
|
contextSnapshot.wakeTriggerDetail = triggerDetail;
|
||||||
}
|
}
|
||||||
|
normalizeModelProfileWakeContext({ contextSnapshot, payload });
|
||||||
|
|
||||||
return {
|
return {
|
||||||
contextSnapshot,
|
contextSnapshot,
|
||||||
|
|
@ -4964,9 +5132,42 @@ export function heartbeatService(db: Db, options: HeartbeatServiceOptions = {})
|
||||||
workspaceConfig: existingExecutionWorkspace?.config ?? null,
|
workspaceConfig: existingExecutionWorkspace?.config ?? null,
|
||||||
mode: effectiveExecutionWorkspaceMode,
|
mode: effectiveExecutionWorkspaceMode,
|
||||||
});
|
});
|
||||||
const mergedConfig = issueAssigneeOverrides?.adapterConfig
|
let adapterModelProfiles: AdapterModelProfileDefinition[] = [];
|
||||||
? { ...persistedWorkspaceManagedConfig, ...issueAssigneeOverrides.adapterConfig }
|
let profileResolutionFallbackReason: string | null = null;
|
||||||
: persistedWorkspaceManagedConfig;
|
try {
|
||||||
|
adapterModelProfiles = await listAdapterModelProfiles(agent.adapterType);
|
||||||
|
} catch (error) {
|
||||||
|
profileResolutionFallbackReason = "adapter_profile_resolution_failed";
|
||||||
|
logger.warn(
|
||||||
|
{
|
||||||
|
err: error,
|
||||||
|
companyId: agent.companyId,
|
||||||
|
agentId: agent.id,
|
||||||
|
adapterType: agent.adapterType,
|
||||||
|
runId: run.id,
|
||||||
|
},
|
||||||
|
"Failed to resolve adapter model profiles; falling back to primary adapter config",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const modelProfileApplication = resolveModelProfileApplication({
|
||||||
|
adapterModelProfiles,
|
||||||
|
agentRuntimeConfig: agent.runtimeConfig,
|
||||||
|
issueModelProfile: issueAssigneeOverrides?.modelProfile ?? null,
|
||||||
|
contextSnapshot: context,
|
||||||
|
profileResolutionFallbackReason,
|
||||||
|
});
|
||||||
|
const modelProfileMetadata = modelProfileRunMetadata(modelProfileApplication);
|
||||||
|
if (modelProfileMetadata) {
|
||||||
|
context.paperclipModelProfile = modelProfileMetadata;
|
||||||
|
if (modelProfileApplication.requested) context.modelProfile = modelProfileApplication.requested;
|
||||||
|
} else {
|
||||||
|
delete context.paperclipModelProfile;
|
||||||
|
}
|
||||||
|
const mergedConfig = mergeModelProfileAdapterConfig({
|
||||||
|
baseConfig: persistedWorkspaceManagedConfig,
|
||||||
|
modelProfile: modelProfileApplication,
|
||||||
|
issueAdapterConfig: issueAssigneeOverrides?.adapterConfig ?? null,
|
||||||
|
});
|
||||||
const configSnapshot = buildExecutionWorkspaceConfigSnapshot(mergedConfig, selectedEnvironmentId);
|
const configSnapshot = buildExecutionWorkspaceConfigSnapshot(mergedConfig, selectedEnvironmentId);
|
||||||
const executionRunConfig = stripWorkspaceRuntimeFromExecutionRunConfig(mergedConfig);
|
const executionRunConfig = stripWorkspaceRuntimeFromExecutionRunConfig(mergedConfig);
|
||||||
const { resolvedConfig, secretKeys } = await resolveExecutionRunAdapterConfig({
|
const { resolvedConfig, secretKeys } = await resolveExecutionRunAdapterConfig({
|
||||||
|
|
@ -5527,12 +5728,16 @@ export function heartbeatService(db: Db, options: HeartbeatServiceOptions = {})
|
||||||
if (key in meta.env) meta.env[key] = "***REDACTED***";
|
if (key in meta.env) meta.env[key] = "***REDACTED***";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const modelProfileMetadata = modelProfileRunMetadata(modelProfileApplication);
|
||||||
await appendRunEvent(currentRun, seq++, {
|
await appendRunEvent(currentRun, seq++, {
|
||||||
eventType: "adapter.invoke",
|
eventType: "adapter.invoke",
|
||||||
stream: "system",
|
stream: "system",
|
||||||
level: "info",
|
level: "info",
|
||||||
message: "adapter invocation",
|
message: "adapter invocation",
|
||||||
payload: meta as unknown as Record<string, unknown>,
|
payload: {
|
||||||
|
...(meta as unknown as Record<string, unknown>),
|
||||||
|
...(modelProfileMetadata ? { modelProfile: modelProfileMetadata } : {}),
|
||||||
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -5715,11 +5920,14 @@ export function heartbeatService(db: Db, options: HeartbeatServiceOptions = {})
|
||||||
|
|
||||||
const persistedResultJson = mergeHeartbeatRunResultJson(
|
const persistedResultJson = mergeHeartbeatRunResultJson(
|
||||||
mergeRunStopMetadataForAgent(agent, outcome, {
|
mergeRunStopMetadataForAgent(agent, outcome, {
|
||||||
resultJson: mergeAdapterRecoveryMetadata({
|
resultJson: mergeModelProfileRunMetadata(
|
||||||
resultJson: adapterResult.resultJson ?? null,
|
mergeAdapterRecoveryMetadata({
|
||||||
errorFamily: adapterResult.errorFamily ?? null,
|
resultJson: adapterResult.resultJson ?? null,
|
||||||
retryNotBefore: adapterResult.retryNotBefore ?? null,
|
errorFamily: adapterResult.errorFamily ?? null,
|
||||||
}),
|
retryNotBefore: adapterResult.retryNotBefore ?? null,
|
||||||
|
}),
|
||||||
|
modelProfileApplication,
|
||||||
|
),
|
||||||
errorCode: runErrorCode,
|
errorCode: runErrorCode,
|
||||||
errorMessage: runErrorMessage,
|
errorMessage: runErrorMessage,
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ const ALL_FALSE: AdapterCapabilities = {
|
||||||
supportsSkills: false,
|
supportsSkills: false,
|
||||||
supportsLocalAgentJwt: false,
|
supportsLocalAgentJwt: false,
|
||||||
requiresMaterializedRuntimeSkills: false,
|
requiresMaterializedRuntimeSkills: false,
|
||||||
|
supportsModelProfiles: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -15,13 +16,13 @@ const ALL_FALSE: AdapterCapabilities = {
|
||||||
* return correct values on first render before the /api/adapters call resolves.
|
* return correct values on first render before the /api/adapters call resolves.
|
||||||
*/
|
*/
|
||||||
const KNOWN_DEFAULTS: Record<string, AdapterCapabilities> = {
|
const KNOWN_DEFAULTS: Record<string, AdapterCapabilities> = {
|
||||||
claude_local: { supportsInstructionsBundle: true, supportsSkills: true, supportsLocalAgentJwt: true, requiresMaterializedRuntimeSkills: false },
|
claude_local: { supportsInstructionsBundle: true, supportsSkills: true, supportsLocalAgentJwt: true, requiresMaterializedRuntimeSkills: false, supportsModelProfiles: true },
|
||||||
codex_local: { supportsInstructionsBundle: true, supportsSkills: true, supportsLocalAgentJwt: true, requiresMaterializedRuntimeSkills: false },
|
codex_local: { supportsInstructionsBundle: true, supportsSkills: true, supportsLocalAgentJwt: true, requiresMaterializedRuntimeSkills: false, supportsModelProfiles: true },
|
||||||
cursor: { supportsInstructionsBundle: true, supportsSkills: true, supportsLocalAgentJwt: true, requiresMaterializedRuntimeSkills: true },
|
cursor: { supportsInstructionsBundle: true, supportsSkills: true, supportsLocalAgentJwt: true, requiresMaterializedRuntimeSkills: true, supportsModelProfiles: true },
|
||||||
gemini_local: { supportsInstructionsBundle: true, supportsSkills: true, supportsLocalAgentJwt: true, requiresMaterializedRuntimeSkills: true },
|
gemini_local: { supportsInstructionsBundle: true, supportsSkills: true, supportsLocalAgentJwt: true, requiresMaterializedRuntimeSkills: true, supportsModelProfiles: true },
|
||||||
opencode_local: { supportsInstructionsBundle: true, supportsSkills: true, supportsLocalAgentJwt: true, requiresMaterializedRuntimeSkills: true },
|
opencode_local: { supportsInstructionsBundle: true, supportsSkills: true, supportsLocalAgentJwt: true, requiresMaterializedRuntimeSkills: true, supportsModelProfiles: true },
|
||||||
pi_local: { supportsInstructionsBundle: true, supportsSkills: true, supportsLocalAgentJwt: true, requiresMaterializedRuntimeSkills: true },
|
pi_local: { supportsInstructionsBundle: true, supportsSkills: true, supportsLocalAgentJwt: true, requiresMaterializedRuntimeSkills: true, supportsModelProfiles: false },
|
||||||
hermes_local: { supportsInstructionsBundle: false, supportsSkills: true, supportsLocalAgentJwt: true, requiresMaterializedRuntimeSkills: false },
|
hermes_local: { supportsInstructionsBundle: false, supportsSkills: true, supportsLocalAgentJwt: true, requiresMaterializedRuntimeSkills: false, supportsModelProfiles: false },
|
||||||
openclaw_gateway: ALL_FALSE,
|
openclaw_gateway: ALL_FALSE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ export interface AdapterCapabilities {
|
||||||
supportsSkills: boolean;
|
supportsSkills: boolean;
|
||||||
supportsLocalAgentJwt: boolean;
|
supportsLocalAgentJwt: boolean;
|
||||||
requiresMaterializedRuntimeSkills: boolean;
|
requiresMaterializedRuntimeSkills: boolean;
|
||||||
|
supportsModelProfiles: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AdapterInfo {
|
export interface AdapterInfo {
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,10 @@ import type {
|
||||||
Approval,
|
Approval,
|
||||||
AgentConfigRevision,
|
AgentConfigRevision,
|
||||||
} from "@paperclipai/shared";
|
} from "@paperclipai/shared";
|
||||||
|
import type {
|
||||||
|
AdapterModelProfileDefinition,
|
||||||
|
AdapterModelProfileKey,
|
||||||
|
} from "@paperclipai/adapter-utils";
|
||||||
import { isUuidLike, normalizeAgentUrlKey } from "@paperclipai/shared";
|
import { isUuidLike, normalizeAgentUrlKey } from "@paperclipai/shared";
|
||||||
import { ApiError, api } from "./client";
|
import { ApiError, api } from "./client";
|
||||||
|
|
||||||
|
|
@ -28,6 +32,9 @@ export interface AdapterModel {
|
||||||
label: string;
|
label: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type { AdapterModelProfileKey };
|
||||||
|
export type AdapterModelProfile = AdapterModelProfileDefinition;
|
||||||
|
|
||||||
export interface DetectedAdapterModel {
|
export interface DetectedAdapterModel {
|
||||||
model: string;
|
model: string;
|
||||||
provider: string;
|
provider: string;
|
||||||
|
|
@ -172,6 +179,10 @@ export const agentsApi = {
|
||||||
api.get<DetectedAdapterModel | null>(
|
api.get<DetectedAdapterModel | null>(
|
||||||
`/companies/${encodeURIComponent(companyId)}/adapters/${encodeURIComponent(type)}/detect-model`,
|
`/companies/${encodeURIComponent(companyId)}/adapters/${encodeURIComponent(type)}/detect-model`,
|
||||||
),
|
),
|
||||||
|
adapterModelProfiles: (companyId: string, type: string) =>
|
||||||
|
api.get<AdapterModelProfile[]>(
|
||||||
|
`/companies/${encodeURIComponent(companyId)}/adapters/${encodeURIComponent(type)}/model-profiles`,
|
||||||
|
),
|
||||||
testEnvironment: (
|
testEnvironment: (
|
||||||
companyId: string,
|
companyId: string,
|
||||||
type: string,
|
type: string,
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ import {
|
||||||
help,
|
help,
|
||||||
adapterLabels,
|
adapterLabels,
|
||||||
} from "./agent-config-primitives";
|
} from "./agent-config-primitives";
|
||||||
|
import { ToggleSwitch } from "@/components/ui/toggle-switch";
|
||||||
import { defaultCreateValues } from "./agent-config-defaults";
|
import { defaultCreateValues } from "./agent-config-defaults";
|
||||||
import { getUIAdapter } from "../adapters";
|
import { getUIAdapter } from "../adapters";
|
||||||
import { ClaudeLocalAdvancedFields } from "../adapters/claude-local/config-fields";
|
import { ClaudeLocalAdvancedFields } from "../adapters/claude-local/config-fields";
|
||||||
|
|
@ -117,7 +118,8 @@ function isOverlayDirty(o: AgentConfigOverlay): boolean {
|
||||||
o.adapterType !== undefined ||
|
o.adapterType !== undefined ||
|
||||||
Object.keys(o.adapterConfig).length > 0 ||
|
Object.keys(o.adapterConfig).length > 0 ||
|
||||||
Object.keys(o.heartbeat).length > 0 ||
|
Object.keys(o.heartbeat).length > 0 ||
|
||||||
Object.keys(o.runtime).length > 0
|
Object.keys(o.runtime).length > 0 ||
|
||||||
|
o.modelProfiles?.cheap !== undefined
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -244,15 +246,17 @@ export function AgentConfigForm(props: AgentConfigFormProps) {
|
||||||
|
|
||||||
const isDirty = !isCreate && isOverlayDirty(overlay);
|
const isDirty = !isCreate && isOverlayDirty(overlay);
|
||||||
|
|
||||||
|
type RecordOverlayGroup = "identity" | "adapterConfig" | "heartbeat" | "runtime";
|
||||||
|
|
||||||
/** Read effective value: overlay if dirty, else original */
|
/** Read effective value: overlay if dirty, else original */
|
||||||
function eff<T>(group: keyof Omit<AgentConfigOverlay, "adapterType">, field: string, original: T): T {
|
function eff<T>(group: RecordOverlayGroup, field: string, original: T): T {
|
||||||
const o = overlay[group];
|
const o = overlay[group];
|
||||||
if (field in o) return o[field] as T;
|
if (field in o) return o[field] as T;
|
||||||
return original;
|
return original;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Mark field dirty in overlay */
|
/** Mark field dirty in overlay */
|
||||||
function mark(group: keyof Omit<AgentConfigOverlay, "adapterType">, field: string, value: unknown) {
|
function mark(group: RecordOverlayGroup, field: string, value: unknown) {
|
||||||
setOverlay((prev) => ({
|
setOverlay((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
[group]: { ...prev[group], [field]: value },
|
[group]: { ...prev[group], [field]: value },
|
||||||
|
|
@ -374,8 +378,30 @@ export function AgentConfigForm(props: AgentConfigFormProps) {
|
||||||
const [runPolicyAdvancedOpen, setRunPolicyAdvancedOpen] = useState(false);
|
const [runPolicyAdvancedOpen, setRunPolicyAdvancedOpen] = useState(false);
|
||||||
// Popover states
|
// Popover states
|
||||||
const [modelOpen, setModelOpen] = useState(false);
|
const [modelOpen, setModelOpen] = useState(false);
|
||||||
|
const [cheapModelOpen, setCheapModelOpen] = useState(false);
|
||||||
const [thinkingEffortOpen, setThinkingEffortOpen] = useState(false);
|
const [thinkingEffortOpen, setThinkingEffortOpen] = useState(false);
|
||||||
|
|
||||||
|
// Cheap model profile state — only relevant when the adapter advertises
|
||||||
|
// `supportsModelProfiles`. Defaults are sourced from the adapter's
|
||||||
|
// /model-profiles endpoint so the UI does not encode adapter-specific
|
||||||
|
// cheap defaults.
|
||||||
|
const supportsModelProfiles = adapterCaps.supportsModelProfiles;
|
||||||
|
const { data: adapterCheapProfileDefinitions } = useQuery({
|
||||||
|
queryKey: selectedCompanyId
|
||||||
|
? queryKeys.agents.adapterModelProfiles(selectedCompanyId, adapterType)
|
||||||
|
: ["agents", "none", "adapter-model-profiles", adapterType],
|
||||||
|
queryFn: () => agentsApi.adapterModelProfiles(selectedCompanyId!, adapterType),
|
||||||
|
enabled: Boolean(selectedCompanyId) && supportsModelProfiles,
|
||||||
|
});
|
||||||
|
const adapterCheapDefault = useMemo(() => {
|
||||||
|
return (adapterCheapProfileDefinitions ?? []).find((profile) => profile.key === "cheap") ?? null;
|
||||||
|
}, [adapterCheapProfileDefinitions]);
|
||||||
|
const adapterCheapDefaultModel = useMemo(() => {
|
||||||
|
const adapterConfig = adapterCheapDefault?.adapterConfig ?? {};
|
||||||
|
const value = (adapterConfig as Record<string, unknown>).model;
|
||||||
|
return typeof value === "string" ? value : "";
|
||||||
|
}, [adapterCheapDefault]);
|
||||||
|
|
||||||
// Create mode helpers
|
// Create mode helpers
|
||||||
const val = isCreate ? props.values : null;
|
const val = isCreate ? props.values : null;
|
||||||
const set = isCreate
|
const set = isCreate
|
||||||
|
|
@ -516,6 +542,69 @@ export function AgentConfigForm(props: AgentConfigFormProps) {
|
||||||
const codexSearchEnabled = adapterType === "codex_local"
|
const codexSearchEnabled = adapterType === "codex_local"
|
||||||
? (isCreate ? Boolean(val!.search) : eff("adapterConfig", "search", Boolean(config.search)))
|
? (isCreate ? Boolean(val!.search) : eff("adapterConfig", "search", Boolean(config.search)))
|
||||||
: false;
|
: false;
|
||||||
|
// Cheap profile read/write helpers. Edit-mode values come from
|
||||||
|
// runtimeConfig.modelProfiles.cheap with overlay overrides on top; create-mode
|
||||||
|
// values come straight from CreateConfigValues (cheapModel + cheapModelEnabled).
|
||||||
|
const cheapProfileFromAgent = useMemo(() => {
|
||||||
|
const profiles = (runtimeConfig.modelProfiles ?? {}) as Record<string, unknown>;
|
||||||
|
const cheap = (profiles.cheap ?? {}) as Record<string, unknown>;
|
||||||
|
const cheapAdapterConfig = (cheap.adapterConfig ?? {}) as Record<string, unknown>;
|
||||||
|
return {
|
||||||
|
enabled: cheap.enabled !== false,
|
||||||
|
model: typeof cheapAdapterConfig.model === "string" ? cheapAdapterConfig.model : "",
|
||||||
|
};
|
||||||
|
}, [runtimeConfig]);
|
||||||
|
const cheapOverlay = !isCreate ? overlay.modelProfiles?.cheap : undefined;
|
||||||
|
const currentCheapEnabled = isCreate
|
||||||
|
? val!.cheapModelEnabled ?? false
|
||||||
|
: cheapOverlay?.enabled ?? cheapProfileFromAgent.enabled;
|
||||||
|
const currentCheapModel = isCreate
|
||||||
|
? val!.cheapModel ?? ""
|
||||||
|
: (() => {
|
||||||
|
const overlayModel = (cheapOverlay?.adapterConfig as Record<string, unknown> | undefined)?.model;
|
||||||
|
if (typeof overlayModel === "string") return overlayModel;
|
||||||
|
return cheapProfileFromAgent.model;
|
||||||
|
})();
|
||||||
|
|
||||||
|
function setCheapEnabled(next: boolean) {
|
||||||
|
if (isCreate) {
|
||||||
|
set!({ cheapModelEnabled: next });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setOverlay((prev) => ({
|
||||||
|
...prev,
|
||||||
|
modelProfiles: {
|
||||||
|
cheap: {
|
||||||
|
...(prev.modelProfiles?.cheap ?? {}),
|
||||||
|
enabled: next,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
function setCheapModel(next: string) {
|
||||||
|
if (isCreate) {
|
||||||
|
set!({ cheapModel: next });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setOverlay((prev) => {
|
||||||
|
const existing = prev.modelProfiles?.cheap ?? {};
|
||||||
|
const nextAdapterConfig = {
|
||||||
|
...((existing.adapterConfig ?? {}) as Record<string, unknown>),
|
||||||
|
model: next || undefined,
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
...prev,
|
||||||
|
modelProfiles: {
|
||||||
|
cheap: {
|
||||||
|
...existing,
|
||||||
|
adapterConfig: nextAdapterConfig,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const effectiveRuntimeConfig = useMemo(() => {
|
const effectiveRuntimeConfig = useMemo(() => {
|
||||||
if (isCreate) {
|
if (isCreate) {
|
||||||
return {
|
return {
|
||||||
|
|
@ -720,6 +809,7 @@ export function AgentConfigForm(props: AgentConfigFormProps) {
|
||||||
setOverlay((prev) => ({
|
setOverlay((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
adapterType: t,
|
adapterType: t,
|
||||||
|
modelProfiles: { cheap: { cleared: true } },
|
||||||
adapterConfig: {
|
adapterConfig: {
|
||||||
model:
|
model:
|
||||||
t === "codex_local"
|
t === "codex_local"
|
||||||
|
|
@ -832,6 +922,9 @@ export function AgentConfigForm(props: AgentConfigFormProps) {
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
|
{supportsModelProfiles && (
|
||||||
|
<div className="text-[11px] uppercase tracking-wide text-muted-foreground">Primary model</div>
|
||||||
|
)}
|
||||||
<ModelDropdown
|
<ModelDropdown
|
||||||
models={models}
|
models={models}
|
||||||
value={currentModelId}
|
value={currentModelId}
|
||||||
|
|
@ -866,6 +959,20 @@ export function AgentConfigForm(props: AgentConfigFormProps) {
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{supportsModelProfiles && (
|
||||||
|
<CheapModelSection
|
||||||
|
enabled={currentCheapEnabled}
|
||||||
|
model={currentCheapModel}
|
||||||
|
models={models}
|
||||||
|
adapterType={adapterType}
|
||||||
|
adapterDefaultModel={adapterCheapDefaultModel}
|
||||||
|
onEnabledChange={setCheapEnabled}
|
||||||
|
onModelChange={setCheapModel}
|
||||||
|
open={cheapModelOpen}
|
||||||
|
onOpenChange={setCheapModelOpen}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
{showThinkingEffort && (
|
{showThinkingEffort && (
|
||||||
<>
|
<>
|
||||||
<ThinkingEffortDropdown
|
<ThinkingEffortDropdown
|
||||||
|
|
@ -1201,6 +1308,7 @@ function ModelDropdown({
|
||||||
refreshingModels,
|
refreshingModels,
|
||||||
detectModelLabel,
|
detectModelLabel,
|
||||||
emptyDetectHint,
|
emptyDetectHint,
|
||||||
|
defaultLabel,
|
||||||
}: {
|
}: {
|
||||||
models: AdapterModel[];
|
models: AdapterModel[];
|
||||||
value: string;
|
value: string;
|
||||||
|
|
@ -1218,6 +1326,7 @@ function ModelDropdown({
|
||||||
refreshingModels?: boolean;
|
refreshingModels?: boolean;
|
||||||
detectModelLabel?: string;
|
detectModelLabel?: string;
|
||||||
emptyDetectHint?: string;
|
emptyDetectHint?: string;
|
||||||
|
defaultLabel?: string;
|
||||||
}) {
|
}) {
|
||||||
const [modelSearch, setModelSearch] = useState("");
|
const [modelSearch, setModelSearch] = useState("");
|
||||||
const [detectingModel, setDetectingModel] = useState(false);
|
const [detectingModel, setDetectingModel] = useState(false);
|
||||||
|
|
@ -1304,7 +1413,8 @@ function ModelDropdown({
|
||||||
<span className={cn(!value && "text-muted-foreground")}>
|
<span className={cn(!value && "text-muted-foreground")}>
|
||||||
{selected
|
{selected
|
||||||
? selected.label
|
? selected.label
|
||||||
: value || (allowDefault ? "Default" : required ? "Select model (required)" : "Select model")}
|
: value
|
||||||
|
|| (allowDefault ? (defaultLabel ?? "Default") : required ? "Select model (required)" : "Select model")}
|
||||||
</span>
|
</span>
|
||||||
<ChevronDown className="h-3 w-3 text-muted-foreground" />
|
<ChevronDown className="h-3 w-3 text-muted-foreground" />
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -1500,6 +1610,72 @@ function ModelDropdown({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function CheapModelSection({
|
||||||
|
enabled,
|
||||||
|
model,
|
||||||
|
models,
|
||||||
|
adapterType,
|
||||||
|
adapterDefaultModel,
|
||||||
|
onEnabledChange,
|
||||||
|
onModelChange,
|
||||||
|
open,
|
||||||
|
onOpenChange,
|
||||||
|
}: {
|
||||||
|
enabled: boolean;
|
||||||
|
model: string;
|
||||||
|
models: AdapterModel[];
|
||||||
|
adapterType: string;
|
||||||
|
adapterDefaultModel: string;
|
||||||
|
onEnabledChange: (next: boolean) => void;
|
||||||
|
onModelChange: (next: string) => void;
|
||||||
|
open: boolean;
|
||||||
|
onOpenChange: (open: boolean) => void;
|
||||||
|
}) {
|
||||||
|
const placeholderHint = adapterDefaultModel
|
||||||
|
? `Adapter default · ${adapterDefaultModel}`
|
||||||
|
: "No adapter default — choose a cheaper model";
|
||||||
|
return (
|
||||||
|
<div className="rounded-md border border-border/70 bg-muted/20 p-3 space-y-3">
|
||||||
|
<div className="flex items-center justify-between gap-3">
|
||||||
|
<div className="min-w-0">
|
||||||
|
<div className="text-[11px] uppercase tracking-wide text-muted-foreground">Cheap model</div>
|
||||||
|
<p className="text-xs text-muted-foreground">
|
||||||
|
Used when a run requests the cheap profile (e.g. routine summaries). The primary model stays unchanged.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<ToggleSwitch checked={enabled} onCheckedChange={onEnabledChange} />
|
||||||
|
</div>
|
||||||
|
{enabled ? (
|
||||||
|
<ModelDropdown
|
||||||
|
models={models}
|
||||||
|
value={model}
|
||||||
|
onChange={onModelChange}
|
||||||
|
open={open}
|
||||||
|
onOpenChange={onOpenChange}
|
||||||
|
allowDefault
|
||||||
|
required={false}
|
||||||
|
groupByProvider={adapterType === "opencode_local"}
|
||||||
|
creatable
|
||||||
|
detectedModel={null}
|
||||||
|
detectedModelCandidates={[]}
|
||||||
|
emptyDetectHint={placeholderHint}
|
||||||
|
defaultLabel={placeholderHint}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
{enabled && !model && adapterDefaultModel ? (
|
||||||
|
<p className="text-[11px] text-muted-foreground">
|
||||||
|
No explicit cheap model selected — runtime falls back to <code>{adapterDefaultModel}</code>.
|
||||||
|
</p>
|
||||||
|
) : null}
|
||||||
|
{enabled && !model && !adapterDefaultModel ? (
|
||||||
|
<p className="text-[11px] text-amber-500">
|
||||||
|
No cheap model selected and the adapter has no default. Cheap-lane runs will continue on the primary model with a fallback note.
|
||||||
|
</p>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function ThinkingEffortDropdown({
|
function ThinkingEffortDropdown({
|
||||||
value,
|
value,
|
||||||
options,
|
options,
|
||||||
|
|
|
||||||
|
|
@ -431,6 +431,41 @@ describe("IssueRunLedger", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("renders requested/applied model profile and surfaces fallback reasons", () => {
|
||||||
|
renderLedger({
|
||||||
|
runs: [
|
||||||
|
createRun({
|
||||||
|
runId: "run-cheap-applied",
|
||||||
|
resultJson: {
|
||||||
|
modelProfile: {
|
||||||
|
requested: "cheap",
|
||||||
|
applied: "cheap",
|
||||||
|
configSource: "agent_runtime",
|
||||||
|
fallbackReason: null,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
createRun({
|
||||||
|
runId: "run-cheap-fallback",
|
||||||
|
createdAt: "2026-04-18T19:50:00.000Z",
|
||||||
|
resultJson: {
|
||||||
|
modelProfile: {
|
||||||
|
requested: "cheap",
|
||||||
|
applied: null,
|
||||||
|
configSource: null,
|
||||||
|
fallbackReason: "agent_runtime_profile_disabled",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(container.textContent).toContain("Profile: cheap");
|
||||||
|
expect(container.textContent).toContain("Profile: cheap (unavailable)");
|
||||||
|
expect(container.textContent).toContain("Cheap profile fell back to primary");
|
||||||
|
expect(container.textContent).toContain("agent_runtime_profile_disabled");
|
||||||
|
});
|
||||||
|
|
||||||
it("hides watchdog decision actions for known non-owner viewers", () => {
|
it("hides watchdog decision actions for known non-owner viewers", () => {
|
||||||
const onWatchdogDecision = vi.fn();
|
const onWatchdogDecision = vi.fn();
|
||||||
renderLedger({
|
renderLedger({
|
||||||
|
|
|
||||||
|
|
@ -159,6 +159,45 @@ function readString(value: unknown) {
|
||||||
return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ModelProfileSummary {
|
||||||
|
requested: string;
|
||||||
|
applied: string | null;
|
||||||
|
configSource: string | null;
|
||||||
|
fallbackReason: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function modelProfileForRun(run: RunForIssue): ModelProfileSummary | null {
|
||||||
|
const result = asRecord(run.resultJson);
|
||||||
|
const profile = asRecord(result?.modelProfile);
|
||||||
|
if (!profile) return null;
|
||||||
|
const requested = readString(profile.requested);
|
||||||
|
if (!requested) return null;
|
||||||
|
return {
|
||||||
|
requested,
|
||||||
|
applied: readString(profile.applied),
|
||||||
|
configSource: readString(profile.configSource),
|
||||||
|
fallbackReason: readString(profile.fallbackReason),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function modelProfileBadgeTone(summary: ModelProfileSummary) {
|
||||||
|
if (summary.applied === summary.requested) {
|
||||||
|
return "border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300";
|
||||||
|
}
|
||||||
|
if (summary.fallbackReason) {
|
||||||
|
return "border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300";
|
||||||
|
}
|
||||||
|
return "border-border bg-background text-muted-foreground";
|
||||||
|
}
|
||||||
|
|
||||||
|
function modelProfileTitle(summary: ModelProfileSummary) {
|
||||||
|
const lines = [`Requested: ${summary.requested}`];
|
||||||
|
if (summary.applied) lines.push(`Applied: ${summary.applied}`);
|
||||||
|
if (summary.configSource) lines.push(`Source: ${summary.configSource}`);
|
||||||
|
if (summary.fallbackReason) lines.push(`Fallback: ${summary.fallbackReason}`);
|
||||||
|
return lines.join("\n");
|
||||||
|
}
|
||||||
|
|
||||||
function readNumber(value: unknown) {
|
function readNumber(value: unknown) {
|
||||||
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
||||||
}
|
}
|
||||||
|
|
@ -713,6 +752,26 @@ export function IssueRunLedgerContent({
|
||||||
{RUN_OUTPUT_SILENCE_COPY[run.outputSilence.level]?.label}
|
{RUN_OUTPUT_SILENCE_COPY[run.outputSilence.level]?.label}
|
||||||
</span>
|
</span>
|
||||||
) : null}
|
) : null}
|
||||||
|
{(() => {
|
||||||
|
const profile = modelProfileForRun(run);
|
||||||
|
if (!profile) return null;
|
||||||
|
const label = profile.applied === profile.requested
|
||||||
|
? `Profile: ${profile.requested}`
|
||||||
|
: profile.applied
|
||||||
|
? `Profile: ${profile.requested} → ${profile.applied}`
|
||||||
|
: `Profile: ${profile.requested} (unavailable)`;
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
className={cn(
|
||||||
|
"rounded-md border px-1.5 py-0.5 text-[11px] font-medium",
|
||||||
|
modelProfileBadgeTone(profile),
|
||||||
|
)}
|
||||||
|
title={modelProfileTitle(profile)}
|
||||||
|
>
|
||||||
|
{label}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
})()}
|
||||||
<span className="ml-auto shrink-0">{relativeTime(item.timestamp)}</span>
|
<span className="ml-auto shrink-0">{relativeTime(item.timestamp)}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -749,6 +808,20 @@ export function IssueRunLedgerContent({
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
|
{(() => {
|
||||||
|
const profile = modelProfileForRun(run);
|
||||||
|
if (!profile?.fallbackReason || profile.applied === profile.requested) return null;
|
||||||
|
return (
|
||||||
|
<p className="min-w-0 break-words text-[11px] leading-5 text-amber-700 dark:text-amber-300">
|
||||||
|
{profile.requested === "cheap"
|
||||||
|
? "Cheap profile fell back to primary"
|
||||||
|
: `${profile.requested} profile unavailable`}
|
||||||
|
{": "}
|
||||||
|
<span className="font-mono">{profile.fallbackReason}</span>
|
||||||
|
</p>
|
||||||
|
);
|
||||||
|
})()}
|
||||||
|
|
||||||
{run.livenessReason ? (
|
{run.livenessReason ? (
|
||||||
<p className="min-w-0 break-words text-xs leading-5 text-muted-foreground">
|
<p className="min-w-0 break-words text-xs leading-5 text-muted-foreground">
|
||||||
{run.livenessReason}
|
{run.livenessReason}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
||||||
import { pickTextColorForSolidBg } from "@/lib/color-contrast";
|
import { pickTextColorForSolidBg } from "@/lib/color-contrast";
|
||||||
import { useDialog } from "../context/DialogContext";
|
import { useDialog } from "../context/DialogContext";
|
||||||
import { useCompany } from "../context/CompanyContext";
|
import { useCompany } from "../context/CompanyContext";
|
||||||
|
import { useAdapterCapabilities } from "../adapters/use-adapter-capabilities";
|
||||||
import { executionWorkspacesApi } from "../api/execution-workspaces";
|
import { executionWorkspacesApi } from "../api/execution-workspaces";
|
||||||
import { issuesApi } from "../api/issues";
|
import { issuesApi } from "../api/issues";
|
||||||
import { instanceSettingsApi } from "../api/instanceSettings";
|
import { instanceSettingsApi } from "../api/instanceSettings";
|
||||||
|
|
@ -77,6 +78,7 @@ interface IssueDraft {
|
||||||
assigneeId?: string;
|
assigneeId?: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
projectWorkspaceId?: string;
|
projectWorkspaceId?: string;
|
||||||
|
assigneeModelLane?: IssueModelLane;
|
||||||
assigneeModelOverride: string;
|
assigneeModelOverride: string;
|
||||||
assigneeThinkingEffort: string;
|
assigneeThinkingEffort: string;
|
||||||
assigneeChrome: boolean;
|
assigneeChrome: boolean;
|
||||||
|
|
@ -93,7 +95,12 @@ type StagedIssueFile = {
|
||||||
title?: string | null;
|
title?: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const ISSUE_OVERRIDE_ADAPTER_TYPES = new Set(["claude_local", "codex_local", "opencode_local"]);
|
import {
|
||||||
|
buildAssigneeAdapterOverrides,
|
||||||
|
ISSUE_OVERRIDE_ADAPTER_TYPES,
|
||||||
|
type IssueModelLane,
|
||||||
|
} from "../lib/issue-assignee-overrides";
|
||||||
|
|
||||||
const STAGED_FILE_ACCEPT = "image/*,application/pdf,text/plain,text/markdown,application/json,text/csv,text/html,.md,.markdown";
|
const STAGED_FILE_ACCEPT = "image/*,application/pdf,text/plain,text/markdown,application/json,text/csv,text/html,.md,.markdown";
|
||||||
|
|
||||||
const ISSUE_THINKING_EFFORT_OPTIONS = {
|
const ISSUE_THINKING_EFFORT_OPTIONS = {
|
||||||
|
|
@ -122,41 +129,6 @@ const ISSUE_THINKING_EFFORT_OPTIONS = {
|
||||||
],
|
],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
function buildAssigneeAdapterOverrides(input: {
|
|
||||||
adapterType: string | null | undefined;
|
|
||||||
modelOverride: string;
|
|
||||||
thinkingEffortOverride: string;
|
|
||||||
chrome: boolean;
|
|
||||||
}): Record<string, unknown> | null {
|
|
||||||
const adapterType = input.adapterType ?? null;
|
|
||||||
if (!adapterType || !ISSUE_OVERRIDE_ADAPTER_TYPES.has(adapterType)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const adapterConfig: Record<string, unknown> = {};
|
|
||||||
if (input.modelOverride) adapterConfig.model = input.modelOverride;
|
|
||||||
if (input.thinkingEffortOverride) {
|
|
||||||
if (adapterType === "codex_local") {
|
|
||||||
adapterConfig.modelReasoningEffort = input.thinkingEffortOverride;
|
|
||||||
} else if (adapterType === "opencode_local") {
|
|
||||||
adapterConfig.variant = input.thinkingEffortOverride;
|
|
||||||
} else if (adapterType === "claude_local") {
|
|
||||||
adapterConfig.effort = input.thinkingEffortOverride;
|
|
||||||
} else if (adapterType === "opencode_local") {
|
|
||||||
adapterConfig.variant = input.thinkingEffortOverride;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (adapterType === "claude_local" && input.chrome) {
|
|
||||||
adapterConfig.chrome = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const overrides: Record<string, unknown> = {};
|
|
||||||
if (Object.keys(adapterConfig).length > 0) {
|
|
||||||
overrides.adapterConfig = adapterConfig;
|
|
||||||
}
|
|
||||||
return Object.keys(overrides).length > 0 ? overrides : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadDraft(): IssueDraft | null {
|
function loadDraft(): IssueDraft | null {
|
||||||
try {
|
try {
|
||||||
const raw = localStorage.getItem(DRAFT_KEY);
|
const raw = localStorage.getItem(DRAFT_KEY);
|
||||||
|
|
@ -406,6 +378,7 @@ export function NewIssueDialog() {
|
||||||
const [projectId, setProjectId] = useState("");
|
const [projectId, setProjectId] = useState("");
|
||||||
const [projectWorkspaceId, setProjectWorkspaceId] = useState("");
|
const [projectWorkspaceId, setProjectWorkspaceId] = useState("");
|
||||||
const [assigneeOptionsOpen, setAssigneeOptionsOpen] = useState(false);
|
const [assigneeOptionsOpen, setAssigneeOptionsOpen] = useState(false);
|
||||||
|
const [assigneeModelLane, setAssigneeModelLane] = useState<IssueModelLane>("primary");
|
||||||
const [assigneeModelOverride, setAssigneeModelOverride] = useState("");
|
const [assigneeModelOverride, setAssigneeModelOverride] = useState("");
|
||||||
const [assigneeThinkingEffort, setAssigneeThinkingEffort] = useState("");
|
const [assigneeThinkingEffort, setAssigneeThinkingEffort] = useState("");
|
||||||
const [assigneeChrome, setAssigneeChrome] = useState(false);
|
const [assigneeChrome, setAssigneeChrome] = useState(false);
|
||||||
|
|
@ -496,6 +469,25 @@ export function NewIssueDialog() {
|
||||||
const supportsAssigneeOverrides = Boolean(
|
const supportsAssigneeOverrides = Boolean(
|
||||||
assigneeAdapterType && ISSUE_OVERRIDE_ADAPTER_TYPES.has(assigneeAdapterType),
|
assigneeAdapterType && ISSUE_OVERRIDE_ADAPTER_TYPES.has(assigneeAdapterType),
|
||||||
);
|
);
|
||||||
|
const getAdapterCapabilities = useAdapterCapabilities();
|
||||||
|
const assigneeAdapterCapabilities = assigneeAdapterType
|
||||||
|
? getAdapterCapabilities(assigneeAdapterType)
|
||||||
|
: null;
|
||||||
|
const assigneeSupportsCheapLane = Boolean(
|
||||||
|
supportsAssigneeOverrides && assigneeAdapterCapabilities?.supportsModelProfiles,
|
||||||
|
);
|
||||||
|
|
||||||
|
const { data: assigneeCheapProfiles } = useQuery({
|
||||||
|
queryKey: effectiveCompanyId && assigneeAdapterType
|
||||||
|
? queryKeys.agents.adapterModelProfiles(effectiveCompanyId, assigneeAdapterType)
|
||||||
|
: ["agents", "none", "adapter-model-profiles", assigneeAdapterType ?? "none"],
|
||||||
|
queryFn: () => agentsApi.adapterModelProfiles(effectiveCompanyId!, assigneeAdapterType!),
|
||||||
|
enabled: Boolean(effectiveCompanyId) && newIssueOpen && assigneeSupportsCheapLane,
|
||||||
|
});
|
||||||
|
const assigneeCheapProfile = useMemo(
|
||||||
|
() => (assigneeCheapProfiles ?? []).find((profile) => profile.key === "cheap") ?? null,
|
||||||
|
[assigneeCheapProfiles],
|
||||||
|
);
|
||||||
const mentionOptions = useMemo<MentionOption[]>(() => {
|
const mentionOptions = useMemo<MentionOption[]>(() => {
|
||||||
return buildMarkdownMentionOptions({
|
return buildMarkdownMentionOptions({
|
||||||
agents,
|
agents,
|
||||||
|
|
@ -612,6 +604,7 @@ export function NewIssueDialog() {
|
||||||
approverValue,
|
approverValue,
|
||||||
projectId,
|
projectId,
|
||||||
projectWorkspaceId,
|
projectWorkspaceId,
|
||||||
|
assigneeModelLane,
|
||||||
assigneeModelOverride,
|
assigneeModelOverride,
|
||||||
assigneeThinkingEffort,
|
assigneeThinkingEffort,
|
||||||
assigneeChrome,
|
assigneeChrome,
|
||||||
|
|
@ -663,6 +656,7 @@ export function NewIssueDialog() {
|
||||||
approverValue,
|
approverValue,
|
||||||
projectId,
|
projectId,
|
||||||
projectWorkspaceId,
|
projectWorkspaceId,
|
||||||
|
assigneeModelLane,
|
||||||
assigneeModelOverride,
|
assigneeModelOverride,
|
||||||
assigneeThinkingEffort,
|
assigneeThinkingEffort,
|
||||||
assigneeChrome,
|
assigneeChrome,
|
||||||
|
|
@ -700,6 +694,7 @@ export function NewIssueDialog() {
|
||||||
setProjectId(defaultProjectId);
|
setProjectId(defaultProjectId);
|
||||||
setProjectWorkspaceId(defaultProjectWorkspaceId);
|
setProjectWorkspaceId(defaultProjectWorkspaceId);
|
||||||
setAssigneeValue(assigneeValueFromSelection(newIssueDefaults));
|
setAssigneeValue(assigneeValueFromSelection(newIssueDefaults));
|
||||||
|
setAssigneeModelLane("primary");
|
||||||
setAssigneeModelOverride("");
|
setAssigneeModelOverride("");
|
||||||
setAssigneeThinkingEffort("");
|
setAssigneeThinkingEffort("");
|
||||||
setAssigneeChrome(false);
|
setAssigneeChrome(false);
|
||||||
|
|
@ -744,6 +739,7 @@ export function NewIssueDialog() {
|
||||||
setShowApproverRow(!!(draft.approverValue));
|
setShowApproverRow(!!(draft.approverValue));
|
||||||
setProjectId(restoredProjectId);
|
setProjectId(restoredProjectId);
|
||||||
setProjectWorkspaceId(draft.projectWorkspaceId ?? defaultProjectWorkspaceIdForProject(restoredProject));
|
setProjectWorkspaceId(draft.projectWorkspaceId ?? defaultProjectWorkspaceIdForProject(restoredProject));
|
||||||
|
setAssigneeModelLane(draft.assigneeModelLane ?? "primary");
|
||||||
setAssigneeModelOverride(draft.assigneeModelOverride ?? "");
|
setAssigneeModelOverride(draft.assigneeModelOverride ?? "");
|
||||||
setAssigneeThinkingEffort(draft.assigneeThinkingEffort ?? "");
|
setAssigneeThinkingEffort(draft.assigneeThinkingEffort ?? "");
|
||||||
setAssigneeChrome(draft.assigneeChrome ?? false);
|
setAssigneeChrome(draft.assigneeChrome ?? false);
|
||||||
|
|
@ -780,11 +776,15 @@ export function NewIssueDialog() {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!supportsAssigneeOverrides) {
|
if (!supportsAssigneeOverrides) {
|
||||||
setAssigneeOptionsOpen(false);
|
setAssigneeOptionsOpen(false);
|
||||||
|
setAssigneeModelLane("primary");
|
||||||
setAssigneeModelOverride("");
|
setAssigneeModelOverride("");
|
||||||
setAssigneeThinkingEffort("");
|
setAssigneeThinkingEffort("");
|
||||||
setAssigneeChrome(false);
|
setAssigneeChrome(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!assigneeSupportsCheapLane && assigneeModelLane === "cheap") {
|
||||||
|
setAssigneeModelLane("primary");
|
||||||
|
}
|
||||||
|
|
||||||
const validThinkingValues =
|
const validThinkingValues =
|
||||||
assigneeAdapterType === "codex_local"
|
assigneeAdapterType === "codex_local"
|
||||||
|
|
@ -795,7 +795,13 @@ export function NewIssueDialog() {
|
||||||
if (!validThinkingValues.some((option) => option.value === assigneeThinkingEffort)) {
|
if (!validThinkingValues.some((option) => option.value === assigneeThinkingEffort)) {
|
||||||
setAssigneeThinkingEffort("");
|
setAssigneeThinkingEffort("");
|
||||||
}
|
}
|
||||||
}, [supportsAssigneeOverrides, assigneeAdapterType, assigneeThinkingEffort]);
|
}, [
|
||||||
|
supportsAssigneeOverrides,
|
||||||
|
assigneeAdapterType,
|
||||||
|
assigneeThinkingEffort,
|
||||||
|
assigneeSupportsCheapLane,
|
||||||
|
assigneeModelLane,
|
||||||
|
]);
|
||||||
|
|
||||||
// Cleanup timer on unmount
|
// Cleanup timer on unmount
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -816,6 +822,7 @@ export function NewIssueDialog() {
|
||||||
setProjectId("");
|
setProjectId("");
|
||||||
setProjectWorkspaceId("");
|
setProjectWorkspaceId("");
|
||||||
setAssigneeOptionsOpen(false);
|
setAssigneeOptionsOpen(false);
|
||||||
|
setAssigneeModelLane("primary");
|
||||||
setAssigneeModelOverride("");
|
setAssigneeModelOverride("");
|
||||||
setAssigneeThinkingEffort("");
|
setAssigneeThinkingEffort("");
|
||||||
setAssigneeChrome(false);
|
setAssigneeChrome(false);
|
||||||
|
|
@ -841,6 +848,7 @@ export function NewIssueDialog() {
|
||||||
setShowApproverRow(false);
|
setShowApproverRow(false);
|
||||||
setProjectId("");
|
setProjectId("");
|
||||||
setProjectWorkspaceId("");
|
setProjectWorkspaceId("");
|
||||||
|
setAssigneeModelLane("primary");
|
||||||
setAssigneeModelOverride("");
|
setAssigneeModelOverride("");
|
||||||
setAssigneeThinkingEffort("");
|
setAssigneeThinkingEffort("");
|
||||||
setAssigneeChrome(false);
|
setAssigneeChrome(false);
|
||||||
|
|
@ -858,8 +866,14 @@ export function NewIssueDialog() {
|
||||||
const currentTitle = titleRef.current.trim();
|
const currentTitle = titleRef.current.trim();
|
||||||
const currentDescription = descriptionRef.current.trim();
|
const currentDescription = descriptionRef.current.trim();
|
||||||
if (!effectiveCompanyId || !currentTitle || createIssue.isPending) return;
|
if (!effectiveCompanyId || !currentTitle || createIssue.isPending) return;
|
||||||
|
const effectiveLane = assigneeSupportsCheapLane
|
||||||
|
? assigneeModelLane
|
||||||
|
: assigneeModelLane === "cheap"
|
||||||
|
? "primary"
|
||||||
|
: assigneeModelLane;
|
||||||
const assigneeAdapterOverrides = buildAssigneeAdapterOverrides({
|
const assigneeAdapterOverrides = buildAssigneeAdapterOverrides({
|
||||||
adapterType: assigneeAdapterType,
|
adapterType: assigneeAdapterType,
|
||||||
|
lane: effectiveLane,
|
||||||
modelOverride: assigneeModelOverride,
|
modelOverride: assigneeModelOverride,
|
||||||
thinkingEffortOverride: assigneeThinkingEffort,
|
thinkingEffortOverride: assigneeThinkingEffort,
|
||||||
chrome: assigneeChrome,
|
chrome: assigneeChrome,
|
||||||
|
|
@ -1557,36 +1571,84 @@ export function NewIssueDialog() {
|
||||||
{assigneeOptionsOpen && (
|
{assigneeOptionsOpen && (
|
||||||
<div className="mt-2 rounded-md border border-border p-3 bg-muted/20 space-y-3">
|
<div className="mt-2 rounded-md border border-border p-3 bg-muted/20 space-y-3">
|
||||||
<div className="space-y-1.5">
|
<div className="space-y-1.5">
|
||||||
<div className="text-xs text-muted-foreground">Model</div>
|
<div className="text-xs text-muted-foreground">Model lane</div>
|
||||||
<InlineEntitySelector
|
<div
|
||||||
value={assigneeModelOverride}
|
className="flex w-full overflow-hidden rounded-md border border-border"
|
||||||
options={modelOverrideOptions}
|
role="radiogroup"
|
||||||
placeholder="Default model"
|
aria-label="Model lane"
|
||||||
disablePortal
|
>
|
||||||
noneLabel="Default model"
|
{(["primary", ...(assigneeSupportsCheapLane ? (["cheap"] as const) : ([] as const)), "custom"] as const).map((lane) => (
|
||||||
searchPlaceholder="Search models..."
|
|
||||||
emptyMessage="No models found."
|
|
||||||
onChange={setAssigneeModelOverride}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="space-y-1.5">
|
|
||||||
<div className="text-xs text-muted-foreground">Thinking effort</div>
|
|
||||||
<div className="flex items-center gap-1.5 flex-wrap">
|
|
||||||
{thinkingEffortOptions.map((option) => (
|
|
||||||
<button
|
<button
|
||||||
key={option.value || "default"}
|
key={lane}
|
||||||
|
type="button"
|
||||||
|
role="radio"
|
||||||
|
aria-checked={assigneeModelLane === lane}
|
||||||
className={cn(
|
className={cn(
|
||||||
"px-2 py-1 rounded-md text-xs border border-border hover:bg-accent/50 transition-colors",
|
"flex-1 px-2 py-1 text-xs capitalize transition-colors hover:bg-accent/40",
|
||||||
assigneeThinkingEffort === option.value && "bg-accent"
|
assigneeModelLane === lane && "bg-accent text-foreground",
|
||||||
)}
|
)}
|
||||||
onClick={() => setAssigneeThinkingEffort(option.value)}
|
onClick={() => setAssigneeModelLane(lane)}
|
||||||
>
|
>
|
||||||
{option.label}
|
{lane === "primary"
|
||||||
|
? "Primary"
|
||||||
|
: lane === "cheap"
|
||||||
|
? "Cheap"
|
||||||
|
: "Custom"}
|
||||||
</button>
|
</button>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
{assigneeModelLane === "cheap" && (
|
||||||
|
<p className="text-[11px] text-muted-foreground">
|
||||||
|
Sends <code>modelProfile: "cheap"</code>{" "}
|
||||||
|
{assigneeCheapProfile?.adapterConfig && typeof (assigneeCheapProfile.adapterConfig as Record<string, unknown>).model === "string"
|
||||||
|
? <>· adapter default <code>{String((assigneeCheapProfile.adapterConfig as Record<string, unknown>).model)}</code></>
|
||||||
|
: assigneeCheapProfile
|
||||||
|
? <>· uses the agent's configured cheap profile</>
|
||||||
|
: <>· falls back to the primary model if no cheap profile is configured</>}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
{assigneeModelLane === "primary" && (
|
||||||
|
<p className="text-[11px] text-muted-foreground">Runs on the agent's primary model.</p>
|
||||||
|
)}
|
||||||
|
{assigneeModelLane === "custom" && (
|
||||||
|
<p className="text-[11px] text-muted-foreground">Override the model and effort for this issue only.</p>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
{assigneeAdapterType === "claude_local" && (
|
{assigneeModelLane === "custom" && (
|
||||||
|
<div className="space-y-1.5">
|
||||||
|
<div className="text-xs text-muted-foreground">Model</div>
|
||||||
|
<InlineEntitySelector
|
||||||
|
value={assigneeModelOverride}
|
||||||
|
options={modelOverrideOptions}
|
||||||
|
placeholder="Default model"
|
||||||
|
disablePortal
|
||||||
|
noneLabel="Default model"
|
||||||
|
searchPlaceholder="Search models..."
|
||||||
|
emptyMessage="No models found."
|
||||||
|
onChange={setAssigneeModelOverride}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{assigneeModelLane === "custom" && (
|
||||||
|
<div className="space-y-1.5">
|
||||||
|
<div className="text-xs text-muted-foreground">Thinking effort</div>
|
||||||
|
<div className="flex items-center gap-1.5 flex-wrap">
|
||||||
|
{thinkingEffortOptions.map((option) => (
|
||||||
|
<button
|
||||||
|
key={option.value || "default"}
|
||||||
|
className={cn(
|
||||||
|
"px-2 py-1 rounded-md text-xs border border-border hover:bg-accent/50 transition-colors",
|
||||||
|
assigneeThinkingEffort === option.value && "bg-accent"
|
||||||
|
)}
|
||||||
|
onClick={() => setAssigneeThinkingEffort(option.value)}
|
||||||
|
>
|
||||||
|
{option.label}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{assigneeAdapterType === "claude_local" && assigneeModelLane === "custom" && (
|
||||||
<div className="flex items-center justify-between rounded-md border border-border px-2 py-1.5">
|
<div className="flex items-center justify-between rounded-md border border-border px-2 py-1.5">
|
||||||
<div className="text-xs text-muted-foreground">Enable Chrome (--chrome)</div>
|
<div className="text-xs text-muted-foreground">Enable Chrome (--chrome)</div>
|
||||||
<ToggleSwitch
|
<ToggleSwitch
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,92 @@ describe("buildAgentUpdatePatch", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("writes the cheap profile under runtimeConfig.modelProfiles, never on primary adapterConfig", () => {
|
||||||
|
const patch = buildAgentUpdatePatch(
|
||||||
|
makeAgent(),
|
||||||
|
makeOverlay({
|
||||||
|
modelProfiles: {
|
||||||
|
cheap: {
|
||||||
|
enabled: true,
|
||||||
|
adapterConfig: { model: "claude-haiku-4-5" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(patch).toEqual({
|
||||||
|
runtimeConfig: {
|
||||||
|
heartbeat: {
|
||||||
|
enabled: true,
|
||||||
|
intervalSec: 300,
|
||||||
|
},
|
||||||
|
modelProfiles: {
|
||||||
|
cheap: {
|
||||||
|
enabled: true,
|
||||||
|
adapterConfig: { model: "claude-haiku-4-5" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
// The primary adapterConfig is untouched.
|
||||||
|
expect(patch.adapterConfig).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("merges cheap profile changes onto existing runtimeConfig.modelProfiles state", () => {
|
||||||
|
const agent = makeAgent();
|
||||||
|
agent.runtimeConfig = {
|
||||||
|
heartbeat: { enabled: true, intervalSec: 300 },
|
||||||
|
modelProfiles: {
|
||||||
|
cheap: {
|
||||||
|
enabled: false,
|
||||||
|
adapterConfig: { model: "old-cheap" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const patch = buildAgentUpdatePatch(
|
||||||
|
agent,
|
||||||
|
makeOverlay({
|
||||||
|
modelProfiles: {
|
||||||
|
cheap: {
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect((patch.runtimeConfig as Record<string, unknown>).modelProfiles).toEqual({
|
||||||
|
cheap: {
|
||||||
|
enabled: true,
|
||||||
|
adapterConfig: { model: "old-cheap" },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("clears the cheap profile when the overlay marks it cleared", () => {
|
||||||
|
const agent = makeAgent();
|
||||||
|
agent.runtimeConfig = {
|
||||||
|
heartbeat: { enabled: true, intervalSec: 300 },
|
||||||
|
modelProfiles: {
|
||||||
|
cheap: {
|
||||||
|
enabled: true,
|
||||||
|
adapterConfig: { model: "claude-haiku-4-5" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const patch = buildAgentUpdatePatch(
|
||||||
|
agent,
|
||||||
|
makeOverlay({
|
||||||
|
modelProfiles: { cheap: { cleared: true } },
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(patch.runtimeConfig).toEqual({
|
||||||
|
heartbeat: { enabled: true, intervalSec: 300 },
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("preserves adapter-agnostic keys when changing adapter types", () => {
|
it("preserves adapter-agnostic keys when changing adapter types", () => {
|
||||||
const patch = buildAgentUpdatePatch(
|
const patch = buildAgentUpdatePatch(
|
||||||
makeAgent(),
|
makeAgent(),
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,22 @@
|
||||||
import type { Agent } from "@paperclipai/shared";
|
import type { Agent } from "@paperclipai/shared";
|
||||||
|
|
||||||
|
export interface AgentModelProfileOverlay {
|
||||||
|
enabled?: boolean;
|
||||||
|
adapterConfig?: Record<string, unknown>;
|
||||||
|
/**
|
||||||
|
* Mark the cheap profile for clearing. When true, the patch removes
|
||||||
|
* `runtimeConfig.modelProfiles.cheap` instead of merging into it.
|
||||||
|
*/
|
||||||
|
cleared?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export interface AgentConfigOverlay {
|
export interface AgentConfigOverlay {
|
||||||
identity: Record<string, unknown>;
|
identity: Record<string, unknown>;
|
||||||
adapterType?: string;
|
adapterType?: string;
|
||||||
adapterConfig: Record<string, unknown>;
|
adapterConfig: Record<string, unknown>;
|
||||||
heartbeat: Record<string, unknown>;
|
heartbeat: Record<string, unknown>;
|
||||||
runtime: Record<string, unknown>;
|
runtime: Record<string, unknown>;
|
||||||
|
modelProfiles?: { cheap?: AgentModelProfileOverlay };
|
||||||
}
|
}
|
||||||
|
|
||||||
const ADAPTER_AGNOSTIC_KEYS = [
|
const ADAPTER_AGNOSTIC_KEYS = [
|
||||||
|
|
@ -56,10 +67,47 @@ export function buildAgentUpdatePatch(agent: Agent, overlay: AgentConfigOverlay)
|
||||||
patch.replaceAdapterConfig = true;
|
patch.replaceAdapterConfig = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Object.keys(overlay.heartbeat).length > 0) {
|
const cheapOverlay = overlay.modelProfiles?.cheap;
|
||||||
|
const hasModelProfileChange = cheapOverlay !== undefined;
|
||||||
|
|
||||||
|
if (Object.keys(overlay.heartbeat).length > 0 || hasModelProfileChange) {
|
||||||
const existingRc = (agent.runtimeConfig ?? {}) as Record<string, unknown>;
|
const existingRc = (agent.runtimeConfig ?? {}) as Record<string, unknown>;
|
||||||
const existingHb = (existingRc.heartbeat ?? {}) as Record<string, unknown>;
|
const nextRuntimeConfig: Record<string, unknown> = (patch.runtimeConfig as Record<string, unknown> | undefined)
|
||||||
patch.runtimeConfig = { ...existingRc, heartbeat: { ...existingHb, ...overlay.heartbeat } };
|
?? { ...existingRc };
|
||||||
|
|
||||||
|
if (Object.keys(overlay.heartbeat).length > 0) {
|
||||||
|
const existingHb = (existingRc.heartbeat ?? {}) as Record<string, unknown>;
|
||||||
|
nextRuntimeConfig.heartbeat = { ...existingHb, ...overlay.heartbeat };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasModelProfileChange) {
|
||||||
|
const existingProfiles = ((existingRc.modelProfiles ?? {}) as Record<string, unknown>);
|
||||||
|
const existingCheap = ((existingProfiles.cheap ?? {}) as Record<string, unknown>);
|
||||||
|
const nextProfiles = { ...existingProfiles };
|
||||||
|
|
||||||
|
if (cheapOverlay?.cleared) {
|
||||||
|
delete nextProfiles.cheap;
|
||||||
|
} else if (cheapOverlay) {
|
||||||
|
const mergedAdapterConfig = {
|
||||||
|
...((existingCheap.adapterConfig ?? {}) as Record<string, unknown>),
|
||||||
|
...(cheapOverlay.adapterConfig ?? {}),
|
||||||
|
};
|
||||||
|
const enabled = cheapOverlay.enabled ?? (existingCheap.enabled !== false);
|
||||||
|
nextProfiles.cheap = {
|
||||||
|
...existingCheap,
|
||||||
|
enabled,
|
||||||
|
adapterConfig: mergedAdapterConfig,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Object.keys(nextProfiles).length === 0) {
|
||||||
|
delete nextRuntimeConfig.modelProfiles;
|
||||||
|
} else {
|
||||||
|
nextRuntimeConfig.modelProfiles = nextProfiles;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
patch.runtimeConfig = nextRuntimeConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Object.keys(overlay.runtime).length > 0) {
|
if (Object.keys(overlay.runtime).length > 0) {
|
||||||
|
|
|
||||||
97
ui/src/lib/issue-assignee-overrides.test.ts
Normal file
|
|
@ -0,0 +1,97 @@
|
||||||
|
// @vitest-environment node
|
||||||
|
|
||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
import { buildAssigneeAdapterOverrides } from "./issue-assignee-overrides";
|
||||||
|
|
||||||
|
describe("buildAssigneeAdapterOverrides", () => {
|
||||||
|
it("returns null for adapters that do not accept issue overrides", () => {
|
||||||
|
expect(
|
||||||
|
buildAssigneeAdapterOverrides({
|
||||||
|
adapterType: "process",
|
||||||
|
lane: "custom",
|
||||||
|
modelOverride: "anything",
|
||||||
|
thinkingEffortOverride: "high",
|
||||||
|
chrome: true,
|
||||||
|
}),
|
||||||
|
).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("primary lane sends nothing", () => {
|
||||||
|
expect(
|
||||||
|
buildAssigneeAdapterOverrides({
|
||||||
|
adapterType: "claude_local",
|
||||||
|
lane: "primary",
|
||||||
|
modelOverride: "",
|
||||||
|
thinkingEffortOverride: "",
|
||||||
|
chrome: false,
|
||||||
|
}),
|
||||||
|
).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("cheap lane sends modelProfile=cheap and no adapterConfig", () => {
|
||||||
|
expect(
|
||||||
|
buildAssigneeAdapterOverrides({
|
||||||
|
adapterType: "codex_local",
|
||||||
|
lane: "cheap",
|
||||||
|
modelOverride: "ignored",
|
||||||
|
thinkingEffortOverride: "high",
|
||||||
|
chrome: false,
|
||||||
|
}),
|
||||||
|
).toEqual({ modelProfile: "cheap" });
|
||||||
|
});
|
||||||
|
|
||||||
|
it("custom lane preserves explicit model + thinking effort + chrome overrides", () => {
|
||||||
|
expect(
|
||||||
|
buildAssigneeAdapterOverrides({
|
||||||
|
adapterType: "claude_local",
|
||||||
|
lane: "custom",
|
||||||
|
modelOverride: "claude-haiku-4-5",
|
||||||
|
thinkingEffortOverride: "high",
|
||||||
|
chrome: true,
|
||||||
|
}),
|
||||||
|
).toEqual({
|
||||||
|
adapterConfig: {
|
||||||
|
model: "claude-haiku-4-5",
|
||||||
|
effort: "high",
|
||||||
|
chrome: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("custom lane returns null when no fields are set", () => {
|
||||||
|
expect(
|
||||||
|
buildAssigneeAdapterOverrides({
|
||||||
|
adapterType: "codex_local",
|
||||||
|
lane: "custom",
|
||||||
|
modelOverride: "",
|
||||||
|
thinkingEffortOverride: "",
|
||||||
|
chrome: false,
|
||||||
|
}),
|
||||||
|
).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("custom lane uses adapter-specific keys for thinking effort", () => {
|
||||||
|
expect(
|
||||||
|
buildAssigneeAdapterOverrides({
|
||||||
|
adapterType: "codex_local",
|
||||||
|
lane: "custom",
|
||||||
|
modelOverride: "",
|
||||||
|
thinkingEffortOverride: "minimal",
|
||||||
|
chrome: false,
|
||||||
|
}),
|
||||||
|
).toEqual({
|
||||||
|
adapterConfig: { modelReasoningEffort: "minimal" },
|
||||||
|
});
|
||||||
|
expect(
|
||||||
|
buildAssigneeAdapterOverrides({
|
||||||
|
adapterType: "opencode_local",
|
||||||
|
lane: "custom",
|
||||||
|
modelOverride: "",
|
||||||
|
thinkingEffortOverride: "max",
|
||||||
|
chrome: false,
|
||||||
|
}),
|
||||||
|
).toEqual({
|
||||||
|
adapterConfig: { variant: "max" },
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
60
ui/src/lib/issue-assignee-overrides.ts
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
export const ISSUE_OVERRIDE_ADAPTER_TYPES = new Set([
|
||||||
|
"claude_local",
|
||||||
|
"codex_local",
|
||||||
|
"opencode_local",
|
||||||
|
]);
|
||||||
|
|
||||||
|
export type IssueModelLane = "primary" | "cheap" | "custom";
|
||||||
|
|
||||||
|
export interface BuildAssigneeAdapterOverridesInput {
|
||||||
|
adapterType: string | null | undefined;
|
||||||
|
lane: IssueModelLane;
|
||||||
|
modelOverride: string;
|
||||||
|
thinkingEffortOverride: string;
|
||||||
|
chrome: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build the `assigneeAdapterOverrides` payload sent to the issue create API.
|
||||||
|
*
|
||||||
|
* Lane semantics:
|
||||||
|
* - "primary" → no overrides, runs on the agent's primary model.
|
||||||
|
* - "cheap" → `modelProfile: "cheap"` only; the runtime resolves the actual
|
||||||
|
* adapter config from the agent's runtimeConfig + adapter default.
|
||||||
|
* - "custom" → preserves the legacy explicit override path
|
||||||
|
* (`adapterConfig.model`, thinking effort, chrome).
|
||||||
|
*/
|
||||||
|
export function buildAssigneeAdapterOverrides(
|
||||||
|
input: BuildAssigneeAdapterOverridesInput,
|
||||||
|
): Record<string, unknown> | null {
|
||||||
|
const adapterType = input.adapterType ?? null;
|
||||||
|
if (!adapterType || !ISSUE_OVERRIDE_ADAPTER_TYPES.has(adapterType)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (input.lane === "primary") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (input.lane === "cheap") {
|
||||||
|
return { modelProfile: "cheap" };
|
||||||
|
}
|
||||||
|
|
||||||
|
const adapterConfig: Record<string, unknown> = {};
|
||||||
|
if (input.modelOverride) adapterConfig.model = input.modelOverride;
|
||||||
|
if (input.thinkingEffortOverride) {
|
||||||
|
if (adapterType === "codex_local") {
|
||||||
|
adapterConfig.modelReasoningEffort = input.thinkingEffortOverride;
|
||||||
|
} else if (adapterType === "opencode_local") {
|
||||||
|
adapterConfig.variant = input.thinkingEffortOverride;
|
||||||
|
} else if (adapterType === "claude_local") {
|
||||||
|
adapterConfig.effort = input.thinkingEffortOverride;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (adapterType === "claude_local" && input.chrome) {
|
||||||
|
adapterConfig.chrome = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Object.keys(adapterConfig).length === 0) return null;
|
||||||
|
return { adapterConfig };
|
||||||
|
}
|
||||||
|
|
@ -32,6 +32,8 @@ export function buildNewAgentHirePayload(input: {
|
||||||
runtimeConfig: buildNewAgentRuntimeConfig({
|
runtimeConfig: buildNewAgentRuntimeConfig({
|
||||||
heartbeatEnabled: configValues.heartbeatEnabled,
|
heartbeatEnabled: configValues.heartbeatEnabled,
|
||||||
intervalSec: configValues.intervalSec,
|
intervalSec: configValues.intervalSec,
|
||||||
|
cheapModel: configValues.cheapModel,
|
||||||
|
cheapModelEnabled: configValues.cheapModelEnabled,
|
||||||
}),
|
}),
|
||||||
budgetMonthlyCents: 0,
|
budgetMonthlyCents: 0,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -31,4 +31,35 @@ describe("buildNewAgentRuntimeConfig", () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("stores cheap model under modelProfiles.cheap, not primary adapterConfig", () => {
|
||||||
|
const config = buildNewAgentRuntimeConfig({
|
||||||
|
heartbeatEnabled: true,
|
||||||
|
intervalSec: 600,
|
||||||
|
cheapModel: "claude-sonnet-4-6",
|
||||||
|
cheapModelEnabled: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(config.modelProfiles).toEqual({
|
||||||
|
cheap: {
|
||||||
|
enabled: true,
|
||||||
|
adapterConfig: { model: "claude-sonnet-4-6" },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
// primary heartbeat config still present
|
||||||
|
expect(config.heartbeat).toMatchObject({ enabled: true, intervalSec: 600 });
|
||||||
|
});
|
||||||
|
|
||||||
|
it("omits modelProfiles when no cheap model is configured", () => {
|
||||||
|
const config = buildNewAgentRuntimeConfig({ heartbeatEnabled: false });
|
||||||
|
expect(config.modelProfiles).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("omits modelProfiles when cheap model is set but explicitly disabled", () => {
|
||||||
|
const config = buildNewAgentRuntimeConfig({
|
||||||
|
cheapModel: "claude-sonnet-4-6",
|
||||||
|
cheapModelEnabled: false,
|
||||||
|
});
|
||||||
|
expect(config.modelProfiles).toBeUndefined();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,10 @@ import { defaultCreateValues } from "../components/agent-config-defaults";
|
||||||
export function buildNewAgentRuntimeConfig(input?: {
|
export function buildNewAgentRuntimeConfig(input?: {
|
||||||
heartbeatEnabled?: boolean;
|
heartbeatEnabled?: boolean;
|
||||||
intervalSec?: number;
|
intervalSec?: number;
|
||||||
}) {
|
cheapModel?: string;
|
||||||
return {
|
cheapModelEnabled?: boolean;
|
||||||
|
}): Record<string, unknown> {
|
||||||
|
const config: Record<string, unknown> = {
|
||||||
heartbeat: {
|
heartbeat: {
|
||||||
enabled: input?.heartbeatEnabled ?? defaultCreateValues.heartbeatEnabled,
|
enabled: input?.heartbeatEnabled ?? defaultCreateValues.heartbeatEnabled,
|
||||||
intervalSec: input?.intervalSec ?? defaultCreateValues.intervalSec,
|
intervalSec: input?.intervalSec ?? defaultCreateValues.intervalSec,
|
||||||
|
|
@ -14,4 +16,17 @@ export function buildNewAgentRuntimeConfig(input?: {
|
||||||
maxConcurrentRuns: AGENT_DEFAULT_MAX_CONCURRENT_RUNS,
|
maxConcurrentRuns: AGENT_DEFAULT_MAX_CONCURRENT_RUNS,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const cheapModel = input?.cheapModel?.trim() ?? "";
|
||||||
|
const cheapEnabled = input?.cheapModelEnabled ?? false;
|
||||||
|
if (cheapModel && cheapEnabled) {
|
||||||
|
config.modelProfiles = {
|
||||||
|
cheap: {
|
||||||
|
enabled: true,
|
||||||
|
adapterConfig: { model: cheapModel },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return config;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@ export const queryKeys = {
|
||||||
configRevisions: (agentId: string) => ["agents", "config-revisions", agentId] as const,
|
configRevisions: (agentId: string) => ["agents", "config-revisions", agentId] as const,
|
||||||
adapterModels: (companyId: string, adapterType: string) =>
|
adapterModels: (companyId: string, adapterType: string) =>
|
||||||
["agents", companyId, "adapter-models", adapterType] as const,
|
["agents", companyId, "adapter-models", adapterType] as const,
|
||||||
|
adapterModelProfiles: (companyId: string, adapterType: string) =>
|
||||||
|
["agents", companyId, "adapter-model-profiles", adapterType] as const,
|
||||||
detectModel: (companyId: string, adapterType: string) =>
|
detectModel: (companyId: string, adapterType: string) =>
|
||||||
["agents", companyId, "detect-model", adapterType] as const,
|
["agents", companyId, "detect-model", adapterType] as const,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -615,6 +615,7 @@ export function AdapterManager() {
|
||||||
supportsSkills: false,
|
supportsSkills: false,
|
||||||
supportsLocalAgentJwt: false,
|
supportsLocalAgentJwt: false,
|
||||||
requiresMaterializedRuntimeSkills: false,
|
requiresMaterializedRuntimeSkills: false,
|
||||||
|
supportsModelProfiles: false,
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
canRemove={false}
|
canRemove={false}
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,63 @@ function installStorybookApiFixtures() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (url.pathname === "/api/adapters") {
|
||||||
|
return Response.json([
|
||||||
|
{
|
||||||
|
type: "claude_local",
|
||||||
|
label: "Claude Local",
|
||||||
|
source: "builtin",
|
||||||
|
modelsCount: 2,
|
||||||
|
loaded: true,
|
||||||
|
disabled: false,
|
||||||
|
capabilities: {
|
||||||
|
supportsInstructionsBundle: true,
|
||||||
|
supportsSkills: true,
|
||||||
|
supportsLocalAgentJwt: true,
|
||||||
|
requiresMaterializedRuntimeSkills: false,
|
||||||
|
supportsModelProfiles: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "codex_local",
|
||||||
|
label: "Codex Local",
|
||||||
|
source: "builtin",
|
||||||
|
modelsCount: 3,
|
||||||
|
loaded: true,
|
||||||
|
disabled: false,
|
||||||
|
capabilities: {
|
||||||
|
supportsInstructionsBundle: true,
|
||||||
|
supportsSkills: true,
|
||||||
|
supportsLocalAgentJwt: true,
|
||||||
|
requiresMaterializedRuntimeSkills: false,
|
||||||
|
supportsModelProfiles: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const adapterModelsMatch = url.pathname.match(
|
||||||
|
/^\/api\/companies\/[^/]+\/adapters\/([^/]+)\/(models|model-profiles)$/,
|
||||||
|
);
|
||||||
|
if (adapterModelsMatch) {
|
||||||
|
const [, , resource] = adapterModelsMatch;
|
||||||
|
if (resource === "models") {
|
||||||
|
return Response.json([
|
||||||
|
{ id: "claude-opus-4-7", label: "Claude Opus 4.7" },
|
||||||
|
{ id: "claude-sonnet-4-6", label: "Claude Sonnet 4.6" },
|
||||||
|
{ id: "claude-haiku-4-5", label: "Claude Haiku 4.5" },
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
return Response.json([
|
||||||
|
{
|
||||||
|
key: "cheap",
|
||||||
|
label: "Cheap",
|
||||||
|
adapterConfig: { model: "claude-sonnet-4-6" },
|
||||||
|
source: "adapter_default",
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
if (url.pathname === "/api/plugins/ui-contributions") {
|
if (url.pathname === "/api/plugins/ui-contributions") {
|
||||||
return Response.json([]);
|
return Response.json([]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -291,6 +291,7 @@ const adapterFixtures: AdapterInfo[] = [
|
||||||
supportsSkills: true,
|
supportsSkills: true,
|
||||||
supportsLocalAgentJwt: true,
|
supportsLocalAgentJwt: true,
|
||||||
requiresMaterializedRuntimeSkills: true,
|
requiresMaterializedRuntimeSkills: true,
|
||||||
|
supportsModelProfiles: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -305,6 +306,7 @@ const adapterFixtures: AdapterInfo[] = [
|
||||||
supportsSkills: true,
|
supportsSkills: true,
|
||||||
supportsLocalAgentJwt: true,
|
supportsLocalAgentJwt: true,
|
||||||
requiresMaterializedRuntimeSkills: true,
|
requiresMaterializedRuntimeSkills: true,
|
||||||
|
supportsModelProfiles: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -319,6 +321,7 @@ const adapterFixtures: AdapterInfo[] = [
|
||||||
supportsSkills: false,
|
supportsSkills: false,
|
||||||
supportsLocalAgentJwt: false,
|
supportsLocalAgentJwt: false,
|
||||||
requiresMaterializedRuntimeSkills: false,
|
requiresMaterializedRuntimeSkills: false,
|
||||||
|
supportsModelProfiles: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ import { PathInstructionsModal } from "@/components/PathInstructionsModal";
|
||||||
import { useCompany } from "@/context/CompanyContext";
|
import { useCompany } from "@/context/CompanyContext";
|
||||||
import { useDialog } from "@/context/DialogContext";
|
import { useDialog } from "@/context/DialogContext";
|
||||||
import { queryKeys } from "@/lib/queryKeys";
|
import { queryKeys } from "@/lib/queryKeys";
|
||||||
|
import type { Agent } from "@paperclipai/shared";
|
||||||
import {
|
import {
|
||||||
storybookAgents,
|
storybookAgents,
|
||||||
storybookAuthSession,
|
storybookAuthSession,
|
||||||
|
|
@ -328,7 +329,7 @@ function DialogBackdropFrame({
|
||||||
}
|
}
|
||||||
|
|
||||||
function hydrateDialogQueries(queryClient: ReturnType<typeof useQueryClient>) {
|
function hydrateDialogQueries(queryClient: ReturnType<typeof useQueryClient>) {
|
||||||
queryClient.setQueryData(queryKeys.companies.all, storybookCompanies);
|
queryClient.setQueryData(queryKeys.companies.all, { companies: storybookCompanies, unauthorized: false });
|
||||||
queryClient.setQueryData(queryKeys.auth.session, storybookAuthSession);
|
queryClient.setQueryData(queryKeys.auth.session, storybookAuthSession);
|
||||||
queryClient.setQueryData(queryKeys.agents.list(COMPANY_ID), storybookAgents);
|
queryClient.setQueryData(queryKeys.agents.list(COMPANY_ID), storybookAgents);
|
||||||
queryClient.setQueryData(queryKeys.projects.list(COMPANY_ID), storybookProjects);
|
queryClient.setQueryData(queryKeys.projects.list(COMPANY_ID), storybookProjects);
|
||||||
|
|
@ -382,6 +383,7 @@ function hydrateDialogQueries(queryClient: ReturnType<typeof useQueryClient>) {
|
||||||
supportsSkills: true,
|
supportsSkills: true,
|
||||||
supportsLocalAgentJwt: true,
|
supportsLocalAgentJwt: true,
|
||||||
requiresMaterializedRuntimeSkills: false,
|
requiresMaterializedRuntimeSkills: false,
|
||||||
|
supportsModelProfiles: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -396,6 +398,7 @@ function hydrateDialogQueries(queryClient: ReturnType<typeof useQueryClient>) {
|
||||||
supportsSkills: true,
|
supportsSkills: true,
|
||||||
supportsLocalAgentJwt: true,
|
supportsLocalAgentJwt: true,
|
||||||
requiresMaterializedRuntimeSkills: false,
|
requiresMaterializedRuntimeSkills: false,
|
||||||
|
supportsModelProfiles: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
@ -403,8 +406,41 @@ function hydrateDialogQueries(queryClient: ReturnType<typeof useQueryClient>) {
|
||||||
{ id: "gpt-5.4", label: "GPT-5.4" },
|
{ id: "gpt-5.4", label: "GPT-5.4" },
|
||||||
{ id: "gpt-5.4-mini", label: "GPT-5.4 Mini" },
|
{ id: "gpt-5.4-mini", label: "GPT-5.4 Mini" },
|
||||||
]);
|
]);
|
||||||
|
queryClient.setQueryData(queryKeys.agents.adapterModelProfiles(COMPANY_ID, "codex_local"), [
|
||||||
|
{
|
||||||
|
key: "cheap",
|
||||||
|
label: "Cheap",
|
||||||
|
adapterConfig: { model: "gpt-5.4-mini" },
|
||||||
|
source: "adapter_default",
|
||||||
|
},
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const HERMES_AGENT: Agent = {
|
||||||
|
id: "agent-hermes",
|
||||||
|
companyId: COMPANY_ID,
|
||||||
|
name: "HermesRouter",
|
||||||
|
urlKey: "hermesrouter",
|
||||||
|
role: "engineer",
|
||||||
|
title: "Lightweight Routing",
|
||||||
|
icon: "code",
|
||||||
|
status: "idle",
|
||||||
|
reportsTo: "agent-cto",
|
||||||
|
capabilities: "Hermes-backed assistant on an adapter without the cheap-profile contract.",
|
||||||
|
adapterType: "opencode_local",
|
||||||
|
adapterConfig: {},
|
||||||
|
runtimeConfig: {},
|
||||||
|
budgetMonthlyCents: 60_000,
|
||||||
|
spentMonthlyCents: 9_000,
|
||||||
|
pauseReason: null,
|
||||||
|
pausedAt: null,
|
||||||
|
permissions: { canCreateAgents: false },
|
||||||
|
lastHeartbeatAt: new Date("2026-04-29T08:30:00.000Z"),
|
||||||
|
metadata: null,
|
||||||
|
createdAt: new Date("2026-04-12T08:00:00.000Z"),
|
||||||
|
updatedAt: new Date("2026-04-29T08:30:00.000Z"),
|
||||||
|
};
|
||||||
|
|
||||||
function StorybookDialogFixtures({ children }: { children: ReactNode }) {
|
function StorybookDialogFixtures({ children }: { children: ReactNode }) {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const [ready] = useState(() => {
|
const [ready] = useState(() => {
|
||||||
|
|
@ -655,6 +691,128 @@ function ImageGalleryModalStory() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CheapLaneVariant = "primary" | "cheap" | "custom" | "unsupported";
|
||||||
|
|
||||||
|
function clickModelLaneButton(label: "Primary" | "Cheap" | "Custom") {
|
||||||
|
const radiogroup = document.querySelector<HTMLElement>("[aria-label='Model lane']");
|
||||||
|
if (!radiogroup) return false;
|
||||||
|
const buttons = Array.from(radiogroup.querySelectorAll<HTMLButtonElement>("button[role='radio']"));
|
||||||
|
const button = buttons.find((candidate) => candidate.textContent?.trim() === label);
|
||||||
|
if (!button) return false;
|
||||||
|
button.click();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function findAssigneeOptionsButton() {
|
||||||
|
const buttons = Array.from(document.querySelectorAll<HTMLButtonElement>("button"));
|
||||||
|
return (
|
||||||
|
buttons.find((candidate) => /(Codex|Claude|OpenCode|Agent) options$/.test(candidate.textContent?.trim() ?? "")) ?? null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function useCheapLaneAdapterOverrides(variant: CheapLaneVariant) {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
if (variant !== "unsupported") return;
|
||||||
|
queryClient.setQueryData(
|
||||||
|
queryKeys.agents.list(COMPANY_ID),
|
||||||
|
[...storybookAgents, HERMES_AGENT],
|
||||||
|
);
|
||||||
|
queryClient.setQueryData(queryKeys.adapters.all, [
|
||||||
|
{
|
||||||
|
type: "codex_local",
|
||||||
|
label: "Codex local",
|
||||||
|
source: "builtin",
|
||||||
|
modelsCount: 5,
|
||||||
|
loaded: true,
|
||||||
|
disabled: false,
|
||||||
|
capabilities: {
|
||||||
|
supportsInstructionsBundle: true,
|
||||||
|
supportsSkills: true,
|
||||||
|
supportsLocalAgentJwt: true,
|
||||||
|
requiresMaterializedRuntimeSkills: false,
|
||||||
|
supportsModelProfiles: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "opencode_local",
|
||||||
|
label: "OpenCode local",
|
||||||
|
source: "builtin",
|
||||||
|
modelsCount: 2,
|
||||||
|
loaded: true,
|
||||||
|
disabled: false,
|
||||||
|
capabilities: {
|
||||||
|
supportsInstructionsBundle: true,
|
||||||
|
supportsSkills: true,
|
||||||
|
supportsLocalAgentJwt: true,
|
||||||
|
requiresMaterializedRuntimeSkills: true,
|
||||||
|
supportsModelProfiles: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
queryClient.setQueryData(queryKeys.agents.adapterModels(COMPANY_ID, "opencode_local"), [
|
||||||
|
{ id: "anthropic/claude-haiku-4-5", label: "Claude Haiku 4.5" },
|
||||||
|
{ id: "openai/gpt-5.4-mini", label: "GPT-5.4 Mini" },
|
||||||
|
]);
|
||||||
|
}, [queryClient, variant]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function CheapLaneIssueDialogOpener({ variant }: { variant: CheapLaneVariant }) {
|
||||||
|
const { openNewIssue } = useDialog();
|
||||||
|
useCheapLaneAdapterOverrides(variant);
|
||||||
|
|
||||||
|
const assigneeAgentId = variant === "unsupported" ? "agent-hermes" : "agent-codex";
|
||||||
|
const title =
|
||||||
|
variant === "unsupported"
|
||||||
|
? "Route research summary to HermesRouter"
|
||||||
|
: "Generate weekly Storybook coverage report";
|
||||||
|
const description =
|
||||||
|
variant === "unsupported"
|
||||||
|
? "HermesRouter runs on an adapter that does not advertise a cheap profile, so the Cheap lane should disappear instead of being greyed."
|
||||||
|
: "Lower-cost runs should still pick up the agent's cheap profile so the model badge can show the requested lane.";
|
||||||
|
|
||||||
|
useOpenWhenCompanyReady(() => {
|
||||||
|
openNewIssue({
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
status: "todo",
|
||||||
|
priority: "medium",
|
||||||
|
projectId: "project-board-ui",
|
||||||
|
projectWorkspaceId: "workspace-board-ui",
|
||||||
|
assigneeAgentId,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let cancelled = false;
|
||||||
|
const timers: number[] = [];
|
||||||
|
|
||||||
|
timers.push(
|
||||||
|
window.setTimeout(() => {
|
||||||
|
if (cancelled) return;
|
||||||
|
const optionsButton = findAssigneeOptionsButton();
|
||||||
|
optionsButton?.click();
|
||||||
|
}, 300),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (variant === "cheap" || variant === "custom") {
|
||||||
|
timers.push(
|
||||||
|
window.setTimeout(() => {
|
||||||
|
if (cancelled) return;
|
||||||
|
clickModelLaneButton(variant === "cheap" ? "Cheap" : "Custom");
|
||||||
|
}, 600),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
cancelled = true;
|
||||||
|
for (const timer of timers) window.clearTimeout(timer);
|
||||||
|
};
|
||||||
|
}, [variant]);
|
||||||
|
|
||||||
|
return <NewIssueDialog />;
|
||||||
|
}
|
||||||
|
|
||||||
function PathInstructionsModalStory() {
|
function PathInstructionsModalStory() {
|
||||||
return (
|
return (
|
||||||
<DialogStory
|
<DialogStory
|
||||||
|
|
@ -726,6 +884,62 @@ export const NewIssueValidationError: Story = {
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const NewIssueCheapLanePrimary: Story = {
|
||||||
|
name: "New Issue - Cheap lane (Primary)",
|
||||||
|
render: () => (
|
||||||
|
<DialogStory
|
||||||
|
eyebrow="NewIssueDialog"
|
||||||
|
title="Model lane segmented control - Primary selected"
|
||||||
|
description="Codex assignee with the assignee-options drawer expanded so the Primary | Cheap | Custom segmented control is visible. Default helper copy is shown."
|
||||||
|
badges={["model lane", "primary", "default"]}
|
||||||
|
>
|
||||||
|
<CheapLaneIssueDialogOpener variant="primary" />
|
||||||
|
</DialogStory>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const NewIssueCheapLaneCheap: Story = {
|
||||||
|
name: "New Issue - Cheap lane (Cheap)",
|
||||||
|
render: () => (
|
||||||
|
<DialogStory
|
||||||
|
eyebrow="NewIssueDialog"
|
||||||
|
title="Model lane segmented control - Cheap selected"
|
||||||
|
description='Codex assignee with the Cheap lane selected so the helper line "Sends modelProfile: \"cheap\" · adapter default …" is visible.'
|
||||||
|
badges={["model lane", "cheap", "modelProfile"]}
|
||||||
|
>
|
||||||
|
<CheapLaneIssueDialogOpener variant="cheap" />
|
||||||
|
</DialogStory>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const NewIssueCheapLaneCustom: Story = {
|
||||||
|
name: "New Issue - Cheap lane (Custom)",
|
||||||
|
render: () => (
|
||||||
|
<DialogStory
|
||||||
|
eyebrow="NewIssueDialog"
|
||||||
|
title="Model lane segmented control - Custom selected"
|
||||||
|
description="Custom selected so the explicit model picker and thinking-effort sub-fields render the way they did before the cheap lane was added."
|
||||||
|
badges={["model lane", "custom", "regression"]}
|
||||||
|
>
|
||||||
|
<CheapLaneIssueDialogOpener variant="custom" />
|
||||||
|
</DialogStory>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const NewIssueCheapLaneUnsupported: Story = {
|
||||||
|
name: "New Issue - Cheap lane (Unsupported adapter)",
|
||||||
|
render: () => (
|
||||||
|
<DialogStory
|
||||||
|
eyebrow="NewIssueDialog"
|
||||||
|
title="Model lane on an adapter without supportsModelProfiles"
|
||||||
|
description="HermesRouter runs on opencode_local with supportsModelProfiles disabled, so the Cheap option should be hidden — the segmented control collapses to Primary | Custom rather than showing a greyed Cheap entry."
|
||||||
|
badges={["model lane", "unsupported", "cheap hidden"]}
|
||||||
|
>
|
||||||
|
<CheapLaneIssueDialogOpener variant="unsupported" />
|
||||||
|
</DialogStory>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
export const NewAgentRecommendation: Story = {
|
export const NewAgentRecommendation: Story = {
|
||||||
name: "New Agent - Recommendation",
|
name: "New Agent - Recommendation",
|
||||||
render: () => (
|
render: () => (
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { useEffect, useMemo, useRef, useState } from "react";
|
import { useEffect, useMemo, useRef, useState } from "react";
|
||||||
import type { Meta, StoryObj } from "@storybook/react-vite";
|
import type { Meta, StoryObj } from "@storybook/react-vite";
|
||||||
import type { Issue } from "@paperclipai/shared";
|
import type { Issue } from "@paperclipai/shared";
|
||||||
|
import type { RunForIssue } from "@/api/activity";
|
||||||
import { useQueryClient } from "@tanstack/react-query";
|
import { useQueryClient } from "@tanstack/react-query";
|
||||||
import {
|
import {
|
||||||
ArrowDownAZ,
|
ArrowDownAZ,
|
||||||
|
|
@ -83,7 +84,7 @@ function Section({
|
||||||
}
|
}
|
||||||
|
|
||||||
function hydrateStorybookQueries(queryClient: ReturnType<typeof useQueryClient>) {
|
function hydrateStorybookQueries(queryClient: ReturnType<typeof useQueryClient>) {
|
||||||
queryClient.setQueryData(queryKeys.companies.all, storybookCompanies);
|
queryClient.setQueryData(queryKeys.companies.all, { companies: storybookCompanies, unauthorized: false });
|
||||||
queryClient.setQueryData(queryKeys.auth.session, storybookAuthSession);
|
queryClient.setQueryData(queryKeys.auth.session, storybookAuthSession);
|
||||||
queryClient.setQueryData(queryKeys.agents.list(companyId), storybookAgents);
|
queryClient.setQueryData(queryKeys.agents.list(companyId), storybookAgents);
|
||||||
queryClient.setQueryData(queryKeys.projects.list(companyId), storybookProjects);
|
queryClient.setQueryData(queryKeys.projects.list(companyId), storybookProjects);
|
||||||
|
|
@ -334,6 +335,116 @@ function OpenFiltersPopover() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const modelProfileLedgerRuns: RunForIssue[] = [
|
||||||
|
{
|
||||||
|
runId: "run-cheap-applied",
|
||||||
|
status: "succeeded",
|
||||||
|
agentId: "agent-codex",
|
||||||
|
adapterType: "codex_local",
|
||||||
|
startedAt: "2026-04-29T09:30:00.000Z",
|
||||||
|
finishedAt: "2026-04-29T09:32:14.000Z",
|
||||||
|
createdAt: "2026-04-29T09:29:55.000Z",
|
||||||
|
invocationSource: "manual",
|
||||||
|
usageJson: { costCents: 17, inputTokens: 6400, outputTokens: 480 },
|
||||||
|
resultJson: {
|
||||||
|
stopReason: "completed",
|
||||||
|
modelProfile: {
|
||||||
|
requested: "cheap",
|
||||||
|
applied: "cheap",
|
||||||
|
configSource: "agent_runtime_config",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
livenessState: "advanced",
|
||||||
|
livenessReason: "Cheap-lane summary completed inside the planned scope.",
|
||||||
|
continuationAttempt: 0,
|
||||||
|
lastUsefulActionAt: "2026-04-29T09:32:10.000Z",
|
||||||
|
nextAction: "Hand the routine output back to the operator inbox.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
runId: "run-cheap-fallback",
|
||||||
|
status: "succeeded",
|
||||||
|
agentId: "agent-codex",
|
||||||
|
adapterType: "codex_local",
|
||||||
|
startedAt: "2026-04-29T08:10:00.000Z",
|
||||||
|
finishedAt: "2026-04-29T08:14:42.000Z",
|
||||||
|
createdAt: "2026-04-29T08:09:50.000Z",
|
||||||
|
invocationSource: "manual",
|
||||||
|
usageJson: { costCents: 91, inputTokens: 21800, outputTokens: 3200 },
|
||||||
|
resultJson: {
|
||||||
|
stopReason: "completed",
|
||||||
|
modelProfile: {
|
||||||
|
requested: "cheap",
|
||||||
|
applied: "primary",
|
||||||
|
configSource: "adapter_default",
|
||||||
|
fallbackReason: "Cheap profile not configured for this agent",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
livenessState: "advanced",
|
||||||
|
livenessReason: "Routine fell back to the primary model after the cheap lookup missed.",
|
||||||
|
continuationAttempt: 0,
|
||||||
|
lastUsefulActionAt: "2026-04-29T08:14:36.000Z",
|
||||||
|
nextAction: "Configure agent-codex with a cheap profile to avoid the fallback.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
runId: "run-baseline",
|
||||||
|
status: "succeeded",
|
||||||
|
agentId: "agent-codex",
|
||||||
|
adapterType: "codex_local",
|
||||||
|
startedAt: "2026-04-28T18:05:00.000Z",
|
||||||
|
finishedAt: "2026-04-28T18:14:11.000Z",
|
||||||
|
createdAt: "2026-04-28T18:04:50.000Z",
|
||||||
|
invocationSource: "scheduler",
|
||||||
|
usageJson: { costCents: 142, inputTokens: 38400, outputTokens: 7200 },
|
||||||
|
resultJson: { stopReason: "completed" },
|
||||||
|
livenessState: "advanced",
|
||||||
|
livenessReason: "Standard primary-lane run with no profile metadata recorded.",
|
||||||
|
continuationAttempt: 0,
|
||||||
|
lastUsefulActionAt: "2026-04-28T18:13:58.000Z",
|
||||||
|
nextAction: "Continue with the next planned subtask.",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
function ModelProfileBadgeLedger() {
|
||||||
|
return (
|
||||||
|
<div className="grid gap-5 xl:grid-cols-[minmax(0,1fr)_360px]">
|
||||||
|
<IssueRunLedgerContent
|
||||||
|
runs={modelProfileLedgerRuns}
|
||||||
|
activeRun={null}
|
||||||
|
liveRuns={[]}
|
||||||
|
issueStatus="in_progress"
|
||||||
|
childIssues={[]}
|
||||||
|
agentMap={storybookAgentMap}
|
||||||
|
/>
|
||||||
|
<Card className="shadow-none">
|
||||||
|
<CardHeader>
|
||||||
|
<CardTitle className="flex items-center gap-2">
|
||||||
|
<GitBranch className="h-4 w-4" />
|
||||||
|
Model profile metadata
|
||||||
|
</CardTitle>
|
||||||
|
<CardDescription>
|
||||||
|
Profile badges read <code>resultJson.modelProfile</code> on each run. Applied matching the request renders
|
||||||
|
emerald; an applied fallback renders amber and surfaces the inline reason.
|
||||||
|
</CardDescription>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent className="space-y-3 text-xs text-muted-foreground">
|
||||||
|
<div className="rounded-md border border-border bg-background/70 p-3">
|
||||||
|
<div className="font-mono text-emerald-600 dark:text-emerald-400">Profile: cheap</div>
|
||||||
|
<p className="mt-1">requested + applied both equal cheap → emerald badge.</p>
|
||||||
|
</div>
|
||||||
|
<div className="rounded-md border border-border bg-background/70 p-3">
|
||||||
|
<div className="font-mono text-amber-600 dark:text-amber-400">Profile: cheap → primary</div>
|
||||||
|
<p className="mt-1">cheap requested but primary applied → amber badge plus inline fallback reason.</p>
|
||||||
|
</div>
|
||||||
|
<div className="rounded-md border border-border bg-background/70 p-3">
|
||||||
|
<div className="font-mono text-muted-foreground">No profile badge</div>
|
||||||
|
<p className="mt-1">Run with no <code>modelProfile</code> metadata renders without a badge for visual contrast.</p>
|
||||||
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function RunLedgerWithCostColumns() {
|
function RunLedgerWithCostColumns() {
|
||||||
return (
|
return (
|
||||||
<div className="grid gap-5 xl:grid-cols-[minmax(0,1fr)_380px]">
|
<div className="grid gap-5 xl:grid-cols-[minmax(0,1fr)_380px]">
|
||||||
|
|
@ -549,6 +660,10 @@ function IssueManagementStories() {
|
||||||
<RunLedgerWithCostColumns />
|
<RunLedgerWithCostColumns />
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
|
<Section eyebrow="IssueRunLedger" title="Model profile badges for cheap, fallback, and baseline runs">
|
||||||
|
<ModelProfileBadgeLedger />
|
||||||
|
</Section>
|
||||||
|
|
||||||
<Section eyebrow="IssueWorkspaceCard" title="Workspace info card with branch, path, and runtime status">
|
<Section eyebrow="IssueWorkspaceCard" title="Workspace info card with branch, path, and runtime status">
|
||||||
<WorkspaceCardWithRuntime />
|
<WorkspaceCardWithRuntime />
|
||||||
</Section>
|
</Section>
|
||||||
|
|
@ -599,3 +714,40 @@ export default meta;
|
||||||
type Story = StoryObj<typeof meta>;
|
type Story = StoryObj<typeof meta>;
|
||||||
|
|
||||||
export const FullSurfaceMatrix: Story = {};
|
export const FullSurfaceMatrix: Story = {};
|
||||||
|
|
||||||
|
function ModelProfileLedgerStandalone() {
|
||||||
|
return (
|
||||||
|
<StorybookData>
|
||||||
|
<div className="paperclip-story">
|
||||||
|
<main className="paperclip-story__inner space-y-6">
|
||||||
|
<section className="paperclip-story__frame p-6">
|
||||||
|
<div className="flex flex-wrap items-start justify-between gap-5">
|
||||||
|
<div>
|
||||||
|
<div className="paperclip-story__label">IssueRunLedger</div>
|
||||||
|
<h1 className="mt-2 text-3xl font-semibold tracking-tight">Model profile badges</h1>
|
||||||
|
<p className="mt-3 max-w-3xl text-sm leading-6 text-muted-foreground">
|
||||||
|
Run ledger isolated to the cheap-lane visual states: an emerald applied=cheap badge, an amber
|
||||||
|
cheap-fell-back-to-primary badge with the inline fallback reason, and a baseline run without a
|
||||||
|
modelProfile so the visual diff stays obvious.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-wrap gap-2">
|
||||||
|
<Badge variant="outline">cheap applied</Badge>
|
||||||
|
<Badge variant="outline">cheap → primary</Badge>
|
||||||
|
<Badge variant="outline">no profile</Badge>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<Section eyebrow="IssueRunLedger" title="Cheap, fallback, and baseline runs">
|
||||||
|
<ModelProfileBadgeLedger />
|
||||||
|
</Section>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
</StorybookData>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const RunLedgerModelProfileBadges: Story = {
|
||||||
|
name: "Run ledger - Model profile badges",
|
||||||
|
render: () => <ModelProfileLedgerStandalone />,
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ function Section({
|
||||||
|
|
||||||
function hydrateStorybookQueries(queryClient: ReturnType<typeof useQueryClient>) {
|
function hydrateStorybookQueries(queryClient: ReturnType<typeof useQueryClient>) {
|
||||||
queryClient.setQueryData(queryKeys.auth.session, storybookAuthSession);
|
queryClient.setQueryData(queryKeys.auth.session, storybookAuthSession);
|
||||||
queryClient.setQueryData(queryKeys.companies.all, storybookCompanies);
|
queryClient.setQueryData(queryKeys.companies.all, { companies: storybookCompanies, unauthorized: false });
|
||||||
queryClient.setQueryData(queryKeys.agents.list(COMPANY_ID), storybookAgents);
|
queryClient.setQueryData(queryKeys.agents.list(COMPANY_ID), storybookAgents);
|
||||||
queryClient.setQueryData(queryKeys.projects.list(COMPANY_ID), storybookProjects);
|
queryClient.setQueryData(queryKeys.projects.list(COMPANY_ID), storybookProjects);
|
||||||
queryClient.setQueryData(queryKeys.projects.detail(boardProject.id), boardProject);
|
queryClient.setQueryData(queryKeys.projects.detail(boardProject.id), boardProject);
|
||||||
|
|
|
||||||
|
|
@ -172,7 +172,7 @@ const viewStateKey = "storybook:sub-issues-workflow:list";
|
||||||
const scopedKey = `${viewStateKey}:${companyId}`;
|
const scopedKey = `${viewStateKey}:${companyId}`;
|
||||||
|
|
||||||
function hydrateQueries(client: ReturnType<typeof useQueryClient>) {
|
function hydrateQueries(client: ReturnType<typeof useQueryClient>) {
|
||||||
client.setQueryData(queryKeys.companies.all, storybookCompanies);
|
client.setQueryData(queryKeys.companies.all, { companies: storybookCompanies, unauthorized: false });
|
||||||
client.setQueryData(queryKeys.auth.session, storybookAuthSession);
|
client.setQueryData(queryKeys.auth.session, storybookAuthSession);
|
||||||
client.setQueryData(queryKeys.agents.list(companyId), storybookAgents);
|
client.setQueryData(queryKeys.agents.list(companyId), storybookAgents);
|
||||||
client.setQueryData(queryKeys.projects.list(companyId), storybookProjects);
|
client.setQueryData(queryKeys.projects.list(companyId), storybookProjects);
|
||||||
|
|
|
||||||