@gajae-code/coding-agent 0.12.16-nightly.20260807070805.31156495595.g91c4eff67ce2 → 0.12.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/types/cli/args.d.ts +2 -0
  3. package/dist/types/cli.d.ts +7 -0
  4. package/dist/types/commands/launch.d.ts +7 -0
  5. package/dist/types/config/keybindings.d.ts +5 -0
  6. package/dist/types/config/model-bindings-applier.d.ts +9 -0
  7. package/dist/types/config/model-profile-activation.d.ts +18 -3
  8. package/dist/types/config/model-registry.d.ts +11 -0
  9. package/dist/types/config/settings-schema.d.ts +31 -0
  10. package/dist/types/extensibility/extensions/compact-handler.d.ts +6 -0
  11. package/dist/types/extensibility/extensions/types.d.ts +29 -2
  12. package/dist/types/gjc-runtime/gc-runtime.d.ts +3 -0
  13. package/dist/types/gjc-runtime/gc-session-scope.d.ts +21 -0
  14. package/dist/types/modes/acp/acp-agent.d.ts +1 -0
  15. package/dist/types/modes/controllers/input-controller.d.ts +9 -0
  16. package/dist/types/modes/prompt-action-autocomplete.d.ts +1 -0
  17. package/dist/types/sdk/acp/adapter.d.ts +16 -1
  18. package/dist/types/sdk/acp/index.d.ts +1 -1
  19. package/dist/types/sdk/host/session-runtime.d.ts +11 -0
  20. package/dist/types/sdk/model-profile-model.d.ts +58 -0
  21. package/dist/types/sdk/models.d.ts +14 -0
  22. package/dist/types/sdk/session.d.ts +14 -1
  23. package/dist/types/session/agent-session.d.ts +60 -3
  24. package/dist/types/utils/clipboard.d.ts +38 -4
  25. package/package.json +8 -8
  26. package/scripts/generate-sdk-operation-inventory.ts +14 -0
  27. package/scripts/generate-tool-catalog.ts +1 -0
  28. package/src/cli/args.ts +24 -0
  29. package/src/cli/fast-help.ts +3 -0
  30. package/src/cli.ts +9 -0
  31. package/src/commands/launch.ts +7 -0
  32. package/src/config/keybindings.ts +7 -0
  33. package/src/config/model-bindings-applier.ts +60 -0
  34. package/src/config/model-profile-activation.ts +47 -12
  35. package/src/config/model-registry.ts +24 -2
  36. package/src/config/provider-ranking.ts +1 -0
  37. package/src/config/settings-schema.ts +83 -0
  38. package/src/debug/log-viewer.ts +12 -10
  39. package/src/debug/raw-sse.ts +15 -10
  40. package/src/extensibility/extensions/compact-handler.ts +14 -0
  41. package/src/extensibility/extensions/loader.ts +6 -2
  42. package/src/extensibility/extensions/runner.ts +13 -0
  43. package/src/extensibility/extensions/types.ts +44 -3
  44. package/src/gjc-runtime/gc-render.ts +17 -0
  45. package/src/gjc-runtime/gc-runtime.ts +23 -0
  46. package/src/gjc-runtime/gc-session-scope.ts +144 -0
  47. package/src/hooks/skill-keywords.ts +0 -36
  48. package/src/internal-urls/docs-index.generated.ts +9 -8
  49. package/src/main.ts +15 -0
  50. package/src/modes/acp/acp-agent.ts +99 -5
  51. package/src/modes/action-registry.ts +1 -0
  52. package/src/modes/controllers/command-controller.ts +14 -16
  53. package/src/modes/controllers/extension-ui-controller.ts +74 -19
  54. package/src/modes/controllers/input-controller.ts +73 -24
  55. package/src/modes/controllers/todo-command-controller.ts +4 -6
  56. package/src/modes/prompt-action-autocomplete.ts +8 -0
  57. package/src/modes/runtime-init.ts +68 -5
  58. package/src/prompts/system/system-prompt.md +16 -2
  59. package/src/sdk/acp/adapter.ts +43 -3
  60. package/src/sdk/acp/index.ts +1 -1
  61. package/src/sdk/bus/index.ts +156 -8
  62. package/src/sdk/host/query/revision-store.ts +40 -38
  63. package/src/sdk/host/session-runtime.ts +322 -28
  64. package/src/sdk/model-profile-model.ts +131 -0
  65. package/src/sdk/models.ts +77 -2
  66. package/src/sdk/protocol/operation-inventory.generated.json +77 -0
  67. package/src/sdk/session.ts +21 -6
  68. package/src/session/agent-session.ts +318 -9
  69. package/src/session/internal/managed-session-storage.ts +2 -1
  70. package/src/task/executor.ts +2 -2
  71. package/src/tools/tool-catalog.generated.ts +2460 -2154
  72. package/src/utils/clipboard.ts +320 -30
@@ -1062,8 +1062,60 @@ export declare class AgentSession {
1062
1062
  }): Promise<void>;
1063
1063
  setActiveModelProfile(name: string | undefined): void;
1064
1064
  getActiveModelProfile(): string | undefined;
1065
- /** Activate a complete model profile through a nonvisual session control. */
1065
+ /**
1066
+ * Record which runtime override keys a profile activation installed together
1067
+ * with their pre-profile effective baseline (durable/project value or a
1068
+ * configured `modelBindings` value). First activation for a key wins, so a
1069
+ * profile switch never captures the previous profile's roles as the
1070
+ * baseline. The session-scoped reset restores exactly these keys.
1071
+ */
1072
+ noteProfileInstalledOverrides(modelRoles: readonly string[], agentModelOverrides: readonly string[], preProfileModel: Model | undefined): void;
1073
+ /** Drop the recorded profile-installed override keys (after materialization). */
1074
+ clearProfileInstalledOverrides(): void;
1075
+ /** Current profile-installed override keys, for deriving the activation base. */
1076
+ getProfileInstalledOverrideKeys(): {
1077
+ modelRoles: readonly string[];
1078
+ agentModelOverrides: readonly string[];
1079
+ };
1080
+ /**
1081
+ * Activate a complete model profile through a nonvisual session control.
1082
+ * Session-scoped only: does not persist `modelProfile.default`.
1083
+ */
1066
1084
  activateModelProfileForControl(profileName: string): Promise<boolean>;
1085
+ /**
1086
+ * Activate a model profile from a control surface.
1087
+ *
1088
+ * Control selections are session-scoped unless the caller explicitly opts
1089
+ * into persistence. The transaction canonicalizes the profile, performs
1090
+ * credential preflight, and serializes against other session admissions.
1091
+ * Unknown/registry profile failures are surfaced as SDK `invalid_input` so
1092
+ * the ACP adapter maps them to invalid params.
1093
+ */
1094
+ /** Persist effective roles only when the active profile is a durable default. */
1095
+ materializeActiveDefaultModelProfileAssignment(model: Model): boolean;
1096
+ setDefaultModelProfileForControl(profileName: string, options?: {
1097
+ persistDefault?: boolean;
1098
+ thinkingLevelOverride?: ThinkingLevel;
1099
+ onBeforeActivation?: () => void;
1100
+ onAfterActivation?: () => void;
1101
+ }): Promise<{
1102
+ changed: boolean;
1103
+ id: string;
1104
+ }>;
1105
+ /**
1106
+ * Drop a session-only profile marker and the runtime role overrides its
1107
+ * activation installed. Exposed for the extension `setModel` seam so a
1108
+ * concrete pick clears session-only profiles without materializing them
1109
+ * globally. A stale persisted default that no longer matches the dropped
1110
+ * marker is superseded by the concrete selection and removed.
1111
+ */
1112
+ clearSessionOnlyModelProfileState(): void;
1113
+ /**
1114
+ * Run a control-surface mutation inside the session admission boundary so
1115
+ * SDK `config.patch` and other host mutations serialize against synthetic
1116
+ * profile activation and default-model selection.
1117
+ */
1118
+ withSdkControlMutation<T>(body: () => Promise<T>): Promise<T>;
1067
1119
  /** Return the persisted configured fallback selectors for a model role. */
1068
1120
  getConfiguredModelChain(role: string): readonly string[] | undefined;
1069
1121
  /** Persist the configured fallback selectors for a model role. */
@@ -1126,8 +1178,13 @@ export declare class AgentSession {
1126
1178
  signal?: AbortSignal;
1127
1179
  }): Promise<TemporaryProviderSessionScope | void>;
1128
1180
  /** Set a durable per-session model from a control surface without exposing credential errors. */
1129
- setModelTemporaryForControl(model: Model, expectedSessionId?: string): Promise<boolean>;
1130
- setDefaultModelSelection(model: Model, thinkingLevel: ThinkingLevel | undefined): Promise<DefaultModelSelectionResult>;
1181
+ setModelTemporaryForControl(model: Model, expectedSessionId?: string, thinkingLevel?: ThinkingLevel): Promise<boolean>;
1182
+ setDefaultModelSelection(model: Model, thinkingLevel: ThinkingLevel | undefined, options?: {
1183
+ /** Run inside the selection admission before the durable mutation. */
1184
+ onBeforeMutation?: () => void;
1185
+ /** Run inside the selection admission after the durable mutation. */
1186
+ onAfterMutation?: () => void;
1187
+ }): Promise<DefaultModelSelectionResult>;
1131
1188
  /**
1132
1189
  * Cycle to next/previous model.
1133
1190
  * Uses scoped models (from --models flag) if available, otherwise all available models.
@@ -1,14 +1,48 @@
1
1
  import type { ClipboardImage } from "@gajae-code/natives";
2
+ /** Thrown when an explicit clipboard transport (currently only `ssh`) fails.
3
+ *
4
+ * Explicit transports never silently fall back to native/OSC52 — the caller
5
+ * must surface this to the user and leave the editor/clipboard unchanged.
6
+ */
7
+ export declare class ClipboardTransportError extends Error {
8
+ readonly context?: Record<string, unknown> | undefined;
9
+ constructor(message: string, context?: Record<string, unknown> | undefined);
10
+ }
11
+ /**
12
+ * Read text from the configured SSH clipboard host (`pbpaste`).
13
+ *
14
+ * Reads with a bounded, fatal-UTF-8-decoding stream drain (never buffers past
15
+ * the 1 MiB cap before checking it) and rejects an inbound NUL byte. Throws
16
+ * `ClipboardTransportError` on any failure — explicit `ssh` mode never falls
17
+ * back to native/OSC52 paste.
18
+ */
19
+ export declare function pasteFromClipboardViaSsh(host: string): Promise<string>;
2
20
  /**
3
- * Copy text to the system clipboard.
21
+ * Copy text to the clipboard using the configured transport.
4
22
  *
5
- * Emits OSC 52 first when running in a real terminal (works over SSH/mosh),
6
- * then attempts native clipboard copy as best-effort for local sessions.
7
- * On Termux, tries `termux-clipboard-set` before native.
23
+ * - `auto` (default): emits OSC 52 over a real terminal, then best-effort
24
+ * native copy — unchanged from prior behavior.
25
+ * - `native`: native clipboard only, no OSC 52.
26
+ * - `osc52`: OSC 52 only, no native call.
27
+ * - `ssh`: `ssh <clipboard.sshHost> pbcopy` via argv spawn with a 5s hard
28
+ * timeout covering the whole operation. Never falls back to native/OSC52 on
29
+ * failure — throws `ClipboardTransportError` instead so the caller can
30
+ * surface it.
8
31
  *
9
32
  * @param text - UTF-8 text to place on the clipboard.
10
33
  */
11
34
  export declare function copyToClipboard(text: string): Promise<void>;
35
+ /**
36
+ * Paste text from the configured clipboard transport.
37
+ *
38
+ * Only meaningful for `clipboard.transport = ssh` today (the explicit
39
+ * "Paste text from configured clipboard" action) — other transports have no
40
+ * dedicated paste path yet and return null.
41
+ *
42
+ * @returns pasted UTF-8 text, or null when no explicit ssh transport is configured.
43
+ * @throws ClipboardTransportError on ssh failure — never returns stale/empty text silently.
44
+ */
45
+ export declare function pasteFromClipboard(): Promise<string | null>;
12
46
  /**
13
47
  * Read an image from the system clipboard.
14
48
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@gajae-code/coding-agent",
4
- "version": "0.12.16-nightly.20260807070805.31156495595.g91c4eff67ce2",
4
+ "version": "0.12.16",
5
5
  "description": "Gajae Code CLI with read, bash, edit, write tools and session management",
6
6
  "homepage": "https://gajae-code.com",
7
7
  "author": "Yeachan-Heo and Gajae Code Contributors",
@@ -54,13 +54,13 @@
54
54
  "@agentclientprotocol/sdk": "1.3.0",
55
55
  "@babel/parser": "^7.29.3",
56
56
  "@mozilla/readability": "^0.6.0",
57
- "@gajae-code/stats": "0.12.16-nightly.20260807070805.31156495595.g91c4eff67ce2",
58
- "@gajae-code/agent-core": "0.12.16-nightly.20260807070805.31156495595.g91c4eff67ce2",
59
- "@gajae-code/ai": "0.12.16-nightly.20260807070805.31156495595.g91c4eff67ce2",
60
- "@gajae-code/bridge-client": "0.12.16-nightly.20260807070805.31156495595.g91c4eff67ce2",
61
- "@gajae-code/natives": "0.12.16-nightly.20260807070805.31156495595.g91c4eff67ce2",
62
- "@gajae-code/tui": "0.12.16-nightly.20260807070805.31156495595.g91c4eff67ce2",
63
- "@gajae-code/utils": "0.12.16-nightly.20260807070805.31156495595.g91c4eff67ce2",
57
+ "@gajae-code/stats": "0.12.16",
58
+ "@gajae-code/agent-core": "0.12.16",
59
+ "@gajae-code/ai": "0.12.16",
60
+ "@gajae-code/bridge-client": "0.12.16",
61
+ "@gajae-code/natives": "0.12.16",
62
+ "@gajae-code/tui": "0.12.16",
63
+ "@gajae-code/utils": "0.12.16",
64
64
  "@puppeteer/browsers": "^2.13.0",
65
65
  "@types/turndown": "5.0.6",
66
66
  "@xterm/headless": "^6.0.0",
@@ -35,6 +35,8 @@ const LOCKED_EXCLUSIONS: Readonly<Record<string, string>> = {
35
35
  "slash_command:transcript": "visual/local-only transcript viewer, not a user-facing SDK control seam",
36
36
  "slash_command:sessions": "visual/local-only sessions dashboard, not a user-facing SDK control seam",
37
37
  "agent_session:constructor": "internal accessor/plumbing, not a user-facing control seam",
38
+ "agent_session:materializeActiveDefaultModelProfileAssignment":
39
+ "internal extension selection materialization seam, not a user-facing SDK control seam",
38
40
  "agent_session:registerToolSessionCleanup":
39
41
  "internal tool lifecycle cleanup registration, not a user-facing SDK control seam",
40
42
  "agent_session:registerToolSessionTransitionCleanup":
@@ -129,12 +131,24 @@ const LOCKED_EXCLUSIONS: Readonly<Record<string, string>> = {
129
131
  "internal owner-recovery staged restore builder after durable claims/fencing, never a user-facing SDK operation",
130
132
  "agent_session:setActiveModelProfile": "internal accessor/plumbing, not a user-facing control seam",
131
133
  "agent_session:getActiveModelProfile": "internal accessor/plumbing, not a user-facing control seam",
134
+ "agent_session:clearSessionOnlyModelProfileState":
135
+ "internal session-scoped profile lifecycle plumbing behind the reviewed model.set seam, not an independent public SDK operation",
136
+ "agent_session:noteProfileInstalledOverrides":
137
+ "internal session-scoped profile lifecycle plumbing behind the reviewed model.set seam, not an independent public SDK operation",
138
+ "agent_session:clearProfileInstalledOverrides":
139
+ "internal session-scoped profile lifecycle plumbing behind the reviewed model.set seam, not an independent public SDK operation",
140
+ "agent_session:getProfileInstalledOverrideKeys":
141
+ "internal session-scoped profile lifecycle accessor behind the reviewed model.set seam, not an independent public SDK operation",
132
142
  "agent_session:getSessionDefaultModelSelector": "internal accessor/plumbing, not a user-facing control seam",
133
143
  "agent_session:recordResumeDefaultModel": "internal accessor/plumbing, not a user-facing control seam",
134
144
  "agent_session:resolveConfiguredDefaultModel": "internal accessor/plumbing, not a user-facing control seam",
135
145
  "agent_session:setModelTemporary": "internal accessor/plumbing, not a user-facing control seam",
136
146
  "agent_session:setModelTemporaryForControl":
137
147
  "internal Telegram control wrapper over the reviewed model.set seam, not an independent public SDK operation",
148
+ "agent_session:setDefaultModelProfileForControl":
149
+ "internal control wrapper behind the reviewed model.set seam (session-scoped synthetic gajae-code selection), not an independent public SDK operation",
150
+ "agent_session:withSdkControlMutation":
151
+ "internal session admission wrapper for the reviewed config.patch seam, not an independent public SDK operation",
138
152
  "agent_session:setThinkingLevelForControl":
139
153
  "internal Telegram control wrapper over the reviewed thinking.set seam, not an independent public SDK operation",
140
154
  "agent_session:getThinkingScopeForControl":
@@ -491,6 +491,7 @@ export interface ToolCatalogEntry {
491
491
  readonly platformExclusions?: readonly { platform: string; arch?: string }[];
492
492
  }
493
493
 
494
+ // biome-ignore format: generated JSON preserves deterministic serialization
494
495
  export const TOOL_CATALOG: Readonly<Record<string, ToolCatalogEntry>> = ${JSON.stringify(catalog, null, "\t")};
495
496
  `;
496
497
  }
package/src/cli/args.ts CHANGED
@@ -24,6 +24,8 @@ export interface Args {
24
24
  credential?: string;
25
25
  systemPrompt?: string;
26
26
  appendSystemPrompt?: string;
27
+ clipboardTransport?: "auto" | "native" | "osc52" | "ssh";
28
+ clipboardSshHost?: string;
27
29
  mcpConfig?: string;
28
30
  thinking?: Effort;
29
31
  continue?: boolean;
@@ -163,6 +165,28 @@ export function parseArgs(args: string[]): Args {
163
165
  result.systemPrompt = args[++i];
164
166
  } else if (arg === "--append-system-prompt" && i + 1 < args.length) {
165
167
  result.appendSystemPrompt = args[++i];
168
+ } else if (arg === "--clipboard-transport") {
169
+ const next = args[i + 1];
170
+ if (!next || next.startsWith("-")) {
171
+ throw new CliParseError("--clipboard-transport requires <auto|native|osc52|ssh>");
172
+ }
173
+ if (next !== "auto" && next !== "native" && next !== "osc52" && next !== "ssh") {
174
+ throw new CliParseError(
175
+ `invalid --clipboard-transport value: ${next} (expected auto, native, osc52, or ssh)`,
176
+ );
177
+ }
178
+ result.clipboardTransport = args[++i] as "auto" | "native" | "osc52" | "ssh";
179
+ } else if (arg === "--clipboard-ssh-host") {
180
+ const next = args[i + 1];
181
+ if (!next || next.startsWith("-")) {
182
+ throw new CliParseError("--clipboard-ssh-host requires <alias>");
183
+ }
184
+ if (!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(next)) {
185
+ throw new CliParseError(
186
+ `invalid --clipboard-ssh-host value: ${JSON.stringify(next)} (must be a bare host alias — no whitespace, control characters, or leading dash)`,
187
+ );
188
+ }
189
+ result.clipboardSshHost = args[++i];
166
190
  } else if (arg === "--mcp-config") {
167
191
  if (result.mcpConfig !== undefined) {
168
192
  throw new CliParseError("--mcp-config can only be specified once");
@@ -7,6 +7,8 @@ export function getExtraHelpText(): string {
7
7
  ${APP_NAME} setup - Install GJC defaults or optional dependencies
8
8
  ${APP_NAME} session - List, inspect, create, remove, or attach sessions
9
9
  ${APP_NAME} state - Inspect or manage persisted GJC state
10
+ ${APP_NAME} auth-broker - Manage the auth-broker (credential vault)
11
+ ${APP_NAME} auth-gateway - Run an auth-gateway forward proxy
10
12
  ${APP_NAME} harness - Run harness control-plane commands
11
13
  ${APP_NAME} coordinator - Manage coordinator/runtime coordination helpers
12
14
  ${APP_NAME} team - Run tmux-backed coordinated execution
@@ -54,6 +56,7 @@ Environment Variables:
54
56
  KILO_API_KEY - Kilo Gateway models
55
57
  MISTRAL_API_KEY - Mistral models
56
58
  ZAI_API_KEY - z.ai models (ZhipuAI/GLM)
59
+ JUNIE_API_KEY - JetBrains AI models (Junie; Claude via JetBrains AI)
57
60
  MINIMAX_API_KEY - MiniMax models
58
61
  OPENCODE_API_KEY - OpenCode Zen/OpenCode Go models
59
62
  CURSOR_ACCESS_TOKEN - Cursor AI models
package/src/cli.ts CHANGED
@@ -34,6 +34,8 @@ export const commands: CommandEntry[] = [
34
34
  { name: "state", load: () => import("./commands/state").then(m => m.default) },
35
35
  { name: "setup", load: () => import("./commands/setup").then(m => m.default) },
36
36
  { name: "acp", load: () => import("./commands/acp").then(m => m.default) },
37
+ { name: "auth-broker", load: () => import("./commands/auth-broker").then(m => m.default) },
38
+ { name: "auth-gateway", load: () => import("./commands/auth-gateway").then(m => m.default) },
37
39
  { name: "skills", load: () => import("./commands/skills").then(m => m.default) },
38
40
  { name: "session", load: () => import("./commands/session").then(m => m.default) },
39
41
  { name: "harness", load: () => import("./commands/harness").then(m => m.default) },
@@ -272,6 +274,13 @@ export class RootHelpCommand extends Command {
272
274
  "system-prompt": Flags.string({ description: "System prompt (default: coding assistant prompt)" }),
273
275
  "append-system-prompt": Flags.string({ description: "Append text or file contents to the system prompt" }),
274
276
  "mcp-config": Flags.string({ description: "Tools-only MCP config file (absolute path)" }),
277
+ "clipboard-transport": Flags.string({
278
+ description: "Clipboard transport: auto (default), native, osc52, or ssh",
279
+ options: ["auto", "native", "osc52", "ssh"],
280
+ }),
281
+ "clipboard-ssh-host": Flags.string({
282
+ description: "SSH host alias for --clipboard-transport ssh (from ~/.ssh/config)",
283
+ }),
275
284
  "allow-home": Flags.boolean({ description: "Allow starting in ~ without auto-switching to a temp dir" }),
276
285
  mode: Flags.string({
277
286
  description: "Output mode: text (default), json, or acp",
@@ -108,6 +108,13 @@ export default class Index extends Command {
108
108
  "mcp-config": Flags.string({
109
109
  description: "Tools-only MCP config file (absolute path)",
110
110
  }),
111
+ "clipboard-transport": Flags.string({
112
+ description: "Clipboard transport: auto (default), native, osc52, or ssh",
113
+ options: ["auto", "native", "osc52", "ssh"],
114
+ }),
115
+ "clipboard-ssh-host": Flags.string({
116
+ description: "SSH host alias for --clipboard-transport ssh (from ~/.ssh/config)",
117
+ }),
111
118
  "allow-home": Flags.boolean({
112
119
  description: "Allow starting in ~ without auto-switching to a temp dir",
113
120
  }),
@@ -35,6 +35,7 @@ interface AppKeybindings {
35
35
  "app.message.queue": true;
36
36
  "app.message.dequeue": true;
37
37
  "app.clipboard.pasteImage": true;
38
+ "app.clipboard.pasteText": true;
38
39
  "app.clipboard.copyLine": true;
39
40
  "app.clipboard.copyPrompt": true;
40
41
  "app.session.new": true;
@@ -155,6 +156,11 @@ export const KEYBINDINGS = {
155
156
  defaultKeys: defaultClipboardPasteImageKeysForPlatform(),
156
157
  description: "Paste image from clipboard",
157
158
  },
159
+ "app.clipboard.pasteText": {
160
+ defaultKeys: [],
161
+ description:
162
+ "Paste text from configured clipboard transport (command palette only; no default key to avoid colliding with image paste)",
163
+ },
158
164
  "app.clipboard.copyLine": {
159
165
  defaultKeys: "alt+shift+l",
160
166
  description: "Copy current line",
@@ -289,6 +295,7 @@ const KEYBINDING_NAME_MIGRATIONS = {
289
295
  queue: "app.message.queue",
290
296
  dequeue: "app.message.dequeue",
291
297
  pasteImage: "app.clipboard.pasteImage",
298
+ pasteText: "app.clipboard.pasteText",
292
299
  copyLine: "app.clipboard.copyLine",
293
300
  copyPrompt: "app.clipboard.copyPrompt",
294
301
  newSession: "app.session.new",
@@ -17,6 +17,16 @@ export class ModelBindingsApplier {
17
17
  #lastAppliedRoles = new Map<string, ModelSelectorValue>();
18
18
  #lastAppliedAgentOverrides = new Map<string, ModelSelectorValue>();
19
19
 
20
+ /** The currently configured bindings (as installed at startup), for baseline lookup. */
21
+ getBindings(): ConfiguredModelBindings | undefined {
22
+ return (
23
+ this.#bindings && {
24
+ modelRoles: this.#cloneBindings(this.#bindings.modelRoles),
25
+ agentModelOverrides: this.#cloneBindings(this.#bindings.agentModelOverrides),
26
+ }
27
+ );
28
+ }
29
+
20
30
  setBindings(bindings: ConfiguredModelBindings | undefined): void {
21
31
  this.#bindings = bindings && {
22
32
  modelRoles: this.#cloneBindings(bindings.modelRoles),
@@ -33,6 +43,56 @@ export class ModelBindingsApplier {
33
43
  this.apply();
34
44
  }
35
45
 
46
+ /**
47
+ * Re-assert configured bindings into the target override slots, bypassing
48
+ * the user-edit-preservation heuristic. Used after a session-scoped profile
49
+ * reset removes profile-installed keys, so configured role/agent routing is
50
+ * restored exactly as it was installed at startup.
51
+ */
52
+ forceApplyTo(targetSettings: Settings): void {
53
+ if (this.#targetSettings && this.#targetSettings !== targetSettings) {
54
+ this.#restoreTarget(this.#targetSettings);
55
+ this.#clearTargetLifecycle();
56
+ }
57
+ this.#targetSettings = targetSettings;
58
+ const bindings = this.#bindings;
59
+ if (!targetSettings) return;
60
+ const modelRoles = { ...(targetSettings.get("modelRoles") ?? {}) };
61
+ this.#forceSync(
62
+ modelRoles,
63
+ bindings?.modelRoles ?? {},
64
+ this.#appliedRoles,
65
+ this.#roleBaselines,
66
+ this.#lastAppliedRoles,
67
+ );
68
+ targetSettings.override("modelRoles", modelRoles);
69
+ const agentOverrides = { ...(targetSettings.get("task.agentModelOverrides") ?? {}) };
70
+ this.#forceSync(
71
+ agentOverrides,
72
+ bindings?.agentModelOverrides ?? {},
73
+ this.#appliedAgentOverrides,
74
+ this.#agentBaselines,
75
+ this.#lastAppliedAgentOverrides,
76
+ );
77
+ targetSettings.override("task.agentModelOverrides", agentOverrides);
78
+ }
79
+
80
+ #forceSync(
81
+ target: Record<string, ModelSelectorValue>,
82
+ configured: Record<string, ModelSelectorValue>,
83
+ applied: Set<string>,
84
+ baselines: Map<string, ModelSelectorValue | undefined>,
85
+ lastApplied: Map<string, ModelSelectorValue>,
86
+ ): void {
87
+ for (const [key, value] of Object.entries(configured)) {
88
+ if (!baselines.has(key)) baselines.set(key, this.#clone(target[key]));
89
+ target[key] = this.#clone(value)!;
90
+ lastApplied.set(key, this.#clone(value)!);
91
+ }
92
+ applied.clear();
93
+ for (const key of Object.keys(configured)) applied.add(key);
94
+ }
95
+
36
96
  apply(): void {
37
97
  const targetSettings = this.#targetSettings;
38
98
  if (!targetSettings) return;
@@ -34,6 +34,16 @@ type ModelProfileActivationSession = Pick<
34
34
  setModelTemporary?: AgentSession["setModelTemporary"];
35
35
  setActiveModelProfile?: (name: string | undefined) => void;
36
36
  getActiveModelProfile?: () => string | undefined;
37
+ /** Record which runtime override keys this activation installed (session-scoped). */
38
+ noteProfileInstalledOverrides?: (
39
+ modelRoles: readonly string[],
40
+ agentModelOverrides: readonly string[],
41
+ preProfileModel: Model<Api> | undefined,
42
+ ) => void;
43
+ /** Drop the recorded profile-installed override keys (e.g. after materialization). */
44
+ clearProfileInstalledOverrides?: () => void;
45
+ /** Current profile-installed override keys, for deriving the activation base. */
46
+ getProfileInstalledOverrideKeys?: () => { modelRoles: readonly string[]; agentModelOverrides: readonly string[] };
37
47
  getSessionDefaultModelSelector?: () => string | undefined;
38
48
  recordResumeDefaultModel?: (selector: string) => void;
39
49
  seedDefaultFallbackResolution?: (activeIndex: number, skips: Array<{ selector: string; reason: string }>) => void;
@@ -52,7 +62,7 @@ export interface PrepareModelProfileActivationOptions {
52
62
  | "getCanonicalVariants"
53
63
  | "getCanonicalId"
54
64
  > & { getError?: ModelRegistry["getError"] };
55
- settings: Pick<Settings, "get">;
65
+ settings: Pick<Settings, "get" | "getGlobal">;
56
66
  profileName: string;
57
67
  }
58
68
  export interface ApplyModelProfileActivationOptions {
@@ -67,6 +77,8 @@ export interface PreparedModelProfileActivation {
67
77
  previousThinkingLevel: ThinkingLevel | undefined;
68
78
  previousAgentModelOverrides: Record<string, ModelSelectorValue>;
69
79
  previousModelRoles: Record<string, ModelSelectorValue>;
80
+ baseAgentModelOverrides: Record<string, ModelSelectorValue>;
81
+ baseModelRoles: Record<string, ModelSelectorValue>;
70
82
  previousDefaultChain: readonly string[] | undefined;
71
83
  defaultModel: Model<Api> | undefined;
72
84
  defaultThinkingLevel: ThinkingLevel | undefined;
@@ -92,7 +104,7 @@ export interface MaterializeModelProfileAssignmentOptions {
92
104
  session: Pick<
93
105
  ModelProfileActivationSession,
94
106
  "model" | "thinkingLevel" | "getConfiguredModelChain" | "setActiveModelProfile" | "getActiveModelProfile"
95
- >;
107
+ > & { clearProfileInstalledOverrides?: () => void };
96
108
  settings: Pick<Settings, "clearOverride" | "get" | "override" | "set" | "unset">;
97
109
  role: GjcModelAssignmentTargetId;
98
110
  selector: string;
@@ -102,7 +114,7 @@ export interface MaterializeModelProfileAssignmentsOptions {
102
114
  session: Pick<
103
115
  ModelProfileActivationSession,
104
116
  "model" | "thinkingLevel" | "getConfiguredModelChain" | "setActiveModelProfile" | "getActiveModelProfile"
105
- >;
117
+ > & { clearProfileInstalledOverrides?: () => void };
106
118
  settings: Pick<Settings, "clearOverride" | "get" | "override" | "set" | "unset">;
107
119
  assignments: ReadonlyMap<GjcModelAssignmentTargetId, string> | Partial<Record<GjcModelAssignmentTargetId, string>>;
108
120
  }
@@ -183,6 +195,7 @@ export function materializeActiveModelProfileAssignment(options: MaterializeMode
183
195
  options.settings.override("modelRoles", nextModelRoles);
184
196
  options.settings.override("task.agentModelOverrides", nextAgentModelOverrides);
185
197
  options.session.setActiveModelProfile?.(undefined);
198
+ options.session.clearProfileInstalledOverrides?.();
186
199
  return true;
187
200
  }
188
201
 
@@ -218,6 +231,7 @@ export function materializeActiveModelProfileAssignments(options: MaterializeMod
218
231
  options.settings.override("modelRoles", nextModelRoles);
219
232
  options.settings.override("task.agentModelOverrides", nextAgentModelOverrides);
220
233
  options.session.setActiveModelProfile?.(undefined);
234
+ options.session.clearProfileInstalledOverrides?.();
221
235
  return true;
222
236
  }
223
237
 
@@ -448,6 +462,20 @@ export async function prepareModelProfileActivation(
448
462
  previousThinkingLevel: options.session.thinkingLevel,
449
463
  previousAgentModelOverrides: { ...options.settings.get("task.agentModelOverrides") },
450
464
  previousModelRoles: { ...options.settings.get("modelRoles") },
465
+ // The activation replaces only the previously installed profile-owned
466
+ // keys: derive the base from the effective map (durable + project +
467
+ // bindings + non-profile overrides) minus those keys, so project- or
468
+ // globally-scoped role overrides the new profile omits are preserved.
469
+ baseAgentModelOverrides: Object.fromEntries(
470
+ Object.entries(options.settings.get("task.agentModelOverrides") ?? {}).filter(
471
+ ([key]) => !(options.session.getProfileInstalledOverrideKeys?.().agentModelOverrides ?? []).includes(key),
472
+ ),
473
+ ),
474
+ baseModelRoles: Object.fromEntries(
475
+ Object.entries(options.settings.get("modelRoles") ?? {}).filter(
476
+ ([key]) => !(options.session.getProfileInstalledOverrideKeys?.().modelRoles ?? []).includes(key),
477
+ ),
478
+ ),
451
479
  previousDefaultChain: options.session.getConfiguredModelChain("default"),
452
480
 
453
481
  defaultModel,
@@ -470,7 +498,7 @@ export async function applyPreparedModelProfileActivation(
470
498
  const previousThinkingLevel = prepared.previousThinkingLevel;
471
499
  const previousAgentModelOverrides = prepared.previousAgentModelOverrides;
472
500
  const previousModelRoles = prepared.previousModelRoles;
473
- const previousPersistedDefault = prepared.settings.get("modelProfile.default");
501
+ const previousPersistedDefault = prepared.settings.getGlobal("modelProfile.default");
474
502
  const previousDefaultThinkingLevel = prepared.settings.get("defaultThinkingLevel");
475
503
  const previousActiveModelProfile = prepared.previousActiveModelProfile;
476
504
  const previousSessionDefaultModel = prepared.previousSessionDefaultModel;
@@ -511,16 +539,17 @@ export async function applyPreparedModelProfileActivation(
511
539
  modelChanged = true;
512
540
  }
513
541
  if (Object.keys(prepared.modelRoles).length > 0) {
514
- prepared.settings.override("modelRoles", { ...previousModelRoles, ...prepared.modelRoles });
542
+ prepared.settings.override("modelRoles", { ...prepared.baseModelRoles, ...prepared.modelRoles });
515
543
  modelRolesChanged = true;
516
544
  }
517
- if (Object.keys(prepared.agentModelOverrides).length > 0) {
518
- prepared.settings.override("task.agentModelOverrides", {
519
- ...previousAgentModelOverrides,
520
- ...prepared.agentModelOverrides,
521
- });
522
- overridesChanged = true;
523
- }
545
+ // Always reinstall the agent role layer from the durable base plus the
546
+ // new profile's roles: a default-only or role-free successor must drop
547
+ // the previous profile's role-agent mappings rather than inheriting them.
548
+ prepared.settings.override("task.agentModelOverrides", {
549
+ ...prepared.baseAgentModelOverrides,
550
+ ...prepared.agentModelOverrides,
551
+ });
552
+ overridesChanged = true;
524
553
  if (options.persistDefault) {
525
554
  prepared.settings.set("modelRoles", {});
526
555
  prepared.settings.set("task.agentModelOverrides", {});
@@ -533,6 +562,12 @@ export async function applyPreparedModelProfileActivation(
533
562
  await prepared.settings.flush();
534
563
  }
535
564
  prepared.session.setActiveModelProfile?.(prepared.profileName);
565
+ prepared.session.noteProfileInstalledOverrides?.(
566
+ Object.keys(prepared.modelRoles),
567
+ Object.keys(prepared.agentModelOverrides),
568
+ // Snapshotted before this activation replaced the runtime model.
569
+ previousModel,
570
+ );
536
571
  } catch (error) {
537
572
  if (defaultChanged) {
538
573
  prepared.settings.set("modelProfile.default", previousPersistedDefault);
@@ -47,7 +47,7 @@ import type { AuthStorage, OAuthCredential } from "../session/auth-storage";
47
47
  import type { ActiveSearchModelContext, WebSearchMode } from "../web/search/types";
48
48
  import { type ConfigError, ConfigFile } from "./config-file";
49
49
  import { isAuthenticated, kNoAuth } from "./model-auth";
50
- import { ModelBindingsApplier } from "./model-bindings-applier";
50
+ import { type ConfiguredModelBindings, ModelBindingsApplier } from "./model-bindings-applier";
51
51
  import { ModelDiscoveryManager, type ProviderDiscoveryState } from "./model-discovery-manager";
52
52
 
53
53
  export type { ProviderDiscoveryState, ProviderDiscoveryStatus } from "./model-discovery-manager";
@@ -1979,6 +1979,20 @@ export class ModelRegistry {
1979
1979
  this.#modelBindingsApplier.applyTo(targetSettings);
1980
1980
  }
1981
1981
 
1982
+ /**
1983
+ * Re-assert configured modelBindings into the target override slots after a
1984
+ * session-scoped profile reset removed profile-installed keys. Bypasses the
1985
+ * user-edit heuristic so the startup role/agent routing is restored.
1986
+ */
1987
+ reapplyConfiguredModelBindings(targetSettings: Settings): void {
1988
+ this.#modelBindingsApplier.forceApplyTo(targetSettings);
1989
+ }
1990
+
1991
+ /** The currently configured modelBindings, for pre-profile baseline lookup. */
1992
+ getConfiguredModelBindings(): ConfiguredModelBindings | undefined {
1993
+ return this.#modelBindingsApplier.getBindings();
1994
+ }
1995
+
1982
1996
  async #refreshRuntimeDiscoveries(
1983
1997
  strategy: ModelRefreshStrategy,
1984
1998
  providerFilter?: ReadonlySet<string>,
@@ -3109,7 +3123,10 @@ export class ModelRegistry {
3109
3123
  }
3110
3124
  #applyHardcodedModelPolicies(models: Model<Api>[]): Model<Api>[] {
3111
3125
  return models.map(model => {
3112
- if (model.id !== "gpt-5.4" || model.provider === "github-copilot") {
3126
+ // `github-copilot` and `jetbrains-junie` both serve GPT-5.4 through their own
3127
+ // gateway, which enforces a smaller prompt budget than the first-party 1M
3128
+ // figure (Junie's is a probed 922K). Their bundled values are measured.
3129
+ if (model.id !== "gpt-5.4" || model.provider === "github-copilot" || model.provider === "jetbrains-junie") {
3113
3130
  return model;
3114
3131
  }
3115
3132
  const overrides = this.#modelOverrides.get(model.provider)?.get(model.id);
@@ -3201,6 +3218,11 @@ export class ModelRegistry {
3201
3218
  return this.#models;
3202
3219
  }
3203
3220
 
3221
+ /** Provider ids declared in models.yml, including override-only providers. */
3222
+ getConfiguredProviderIds(): readonly string[] {
3223
+ return [...this.#configuredProviderIds];
3224
+ }
3225
+
3204
3226
  #isModelAvailable(model: Model<Api>, disabledProviders = getDisabledProviderIdsFromSettings()): boolean {
3205
3227
  return (
3206
3228
  !disabledProviders.has(model.provider) &&
@@ -57,6 +57,7 @@ export const FAMOUS_PROVIDER_ORDER: readonly string[] = [
57
57
  "bizrouter",
58
58
  "mara",
59
59
  "github-copilot",
60
+ "jetbrains-junie",
60
61
  "cursor",
61
62
  ];
62
63