agentinit 1.23.0 → 1.24.0

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 (32) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +23 -2
  3. package/dist/agents/CodexCliAgent.js +1 -1
  4. package/dist/agents/CodexCliAgent.js.map +1 -1
  5. package/dist/cli.js +860 -42
  6. package/dist/commands/agent.d.ts.map +1 -1
  7. package/dist/commands/agent.js +88 -0
  8. package/dist/commands/agent.js.map +1 -1
  9. package/dist/core/agentSettings/adapters/claude.d.ts.map +1 -1
  10. package/dist/core/agentSettings/adapters/claude.js +140 -2
  11. package/dist/core/agentSettings/adapters/claude.js.map +1 -1
  12. package/dist/core/agentSettings/adapters/codex.d.ts +3 -0
  13. package/dist/core/agentSettings/adapters/codex.d.ts.map +1 -0
  14. package/dist/core/agentSettings/adapters/codex.js +121 -0
  15. package/dist/core/agentSettings/adapters/codex.js.map +1 -0
  16. package/dist/core/agentSettings/adapters/opencode.d.ts +3 -0
  17. package/dist/core/agentSettings/adapters/opencode.d.ts.map +1 -0
  18. package/dist/core/agentSettings/adapters/opencode.js +134 -0
  19. package/dist/core/agentSettings/adapters/opencode.js.map +1 -0
  20. package/dist/core/agentSettings/registry.d.ts.map +1 -1
  21. package/dist/core/agentSettings/registry.js +4 -0
  22. package/dist/core/agentSettings/registry.js.map +1 -1
  23. package/dist/core/agentSettings/settingsManager.d.ts +3 -1
  24. package/dist/core/agentSettings/settingsManager.d.ts.map +1 -1
  25. package/dist/core/agentSettings/settingsManager.js +221 -27
  26. package/dist/core/agentSettings/settingsManager.js.map +1 -1
  27. package/dist/core/agentSettings/types.d.ts +23 -3
  28. package/dist/core/agentSettings/types.d.ts.map +1 -1
  29. package/dist/core/agentSettings/valueParser.d.ts.map +1 -1
  30. package/dist/core/agentSettings/valueParser.js +20 -0
  31. package/dist/core/agentSettings/valueParser.js.map +1 -1
  32. package/package.json +2 -1
package/dist/cli.js CHANGED
@@ -15070,7 +15070,7 @@ class CodexCliAgent extends Agent {
15070
15070
  sse: false
15071
15071
  },
15072
15072
  rules: true,
15073
- hooks: false,
15073
+ hooks: true,
15074
15074
  commands: false,
15075
15075
  subagents: false,
15076
15076
  statusline: false,
@@ -27115,6 +27115,152 @@ var require_cross_spawn = __commonJS((exports, module) => {
27115
27115
  module.exports._enoent = enoent;
27116
27116
  });
27117
27117
 
27118
+ // node_modules/jsonc-parser/lib/umd/main.js
27119
+ var require_main = __commonJS((exports, module) => {
27120
+ (function(factory) {
27121
+ if (typeof module === "object" && typeof exports === "object") {
27122
+ var v = factory(__require, exports);
27123
+ if (v !== undefined)
27124
+ module.exports = v;
27125
+ } else if (typeof define === "function" && define.amd) {
27126
+ define(["require", "exports", "./impl/format", "./impl/edit", "./impl/scanner", "./impl/parser"], factory);
27127
+ }
27128
+ })(function(require2, exports2) {
27129
+ Object.defineProperty(exports2, "__esModule", { value: true });
27130
+ exports2.applyEdits = exports2.modify = exports2.format = exports2.printParseErrorCode = exports2.ParseErrorCode = exports2.stripComments = exports2.visit = exports2.getNodeValue = exports2.getNodePath = exports2.findNodeAtOffset = exports2.findNodeAtLocation = exports2.parseTree = exports2.parse = exports2.getLocation = exports2.SyntaxKind = exports2.ScanError = exports2.createScanner = undefined;
27131
+ const formatter = require2("./impl/format");
27132
+ const edit = require2("./impl/edit");
27133
+ const scanner = require2("./impl/scanner");
27134
+ const parser = require2("./impl/parser");
27135
+ exports2.createScanner = scanner.createScanner;
27136
+ var ScanError;
27137
+ (function(ScanError2) {
27138
+ ScanError2[ScanError2["None"] = 0] = "None";
27139
+ ScanError2[ScanError2["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
27140
+ ScanError2[ScanError2["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
27141
+ ScanError2[ScanError2["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
27142
+ ScanError2[ScanError2["InvalidUnicode"] = 4] = "InvalidUnicode";
27143
+ ScanError2[ScanError2["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
27144
+ ScanError2[ScanError2["InvalidCharacter"] = 6] = "InvalidCharacter";
27145
+ })(ScanError || (exports2.ScanError = ScanError = {}));
27146
+ var SyntaxKind;
27147
+ (function(SyntaxKind2) {
27148
+ SyntaxKind2[SyntaxKind2["OpenBraceToken"] = 1] = "OpenBraceToken";
27149
+ SyntaxKind2[SyntaxKind2["CloseBraceToken"] = 2] = "CloseBraceToken";
27150
+ SyntaxKind2[SyntaxKind2["OpenBracketToken"] = 3] = "OpenBracketToken";
27151
+ SyntaxKind2[SyntaxKind2["CloseBracketToken"] = 4] = "CloseBracketToken";
27152
+ SyntaxKind2[SyntaxKind2["CommaToken"] = 5] = "CommaToken";
27153
+ SyntaxKind2[SyntaxKind2["ColonToken"] = 6] = "ColonToken";
27154
+ SyntaxKind2[SyntaxKind2["NullKeyword"] = 7] = "NullKeyword";
27155
+ SyntaxKind2[SyntaxKind2["TrueKeyword"] = 8] = "TrueKeyword";
27156
+ SyntaxKind2[SyntaxKind2["FalseKeyword"] = 9] = "FalseKeyword";
27157
+ SyntaxKind2[SyntaxKind2["StringLiteral"] = 10] = "StringLiteral";
27158
+ SyntaxKind2[SyntaxKind2["NumericLiteral"] = 11] = "NumericLiteral";
27159
+ SyntaxKind2[SyntaxKind2["LineCommentTrivia"] = 12] = "LineCommentTrivia";
27160
+ SyntaxKind2[SyntaxKind2["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
27161
+ SyntaxKind2[SyntaxKind2["LineBreakTrivia"] = 14] = "LineBreakTrivia";
27162
+ SyntaxKind2[SyntaxKind2["Trivia"] = 15] = "Trivia";
27163
+ SyntaxKind2[SyntaxKind2["Unknown"] = 16] = "Unknown";
27164
+ SyntaxKind2[SyntaxKind2["EOF"] = 17] = "EOF";
27165
+ })(SyntaxKind || (exports2.SyntaxKind = SyntaxKind = {}));
27166
+ exports2.getLocation = parser.getLocation;
27167
+ exports2.parse = parser.parse;
27168
+ exports2.parseTree = parser.parseTree;
27169
+ exports2.findNodeAtLocation = parser.findNodeAtLocation;
27170
+ exports2.findNodeAtOffset = parser.findNodeAtOffset;
27171
+ exports2.getNodePath = parser.getNodePath;
27172
+ exports2.getNodeValue = parser.getNodeValue;
27173
+ exports2.visit = parser.visit;
27174
+ exports2.stripComments = parser.stripComments;
27175
+ var ParseErrorCode;
27176
+ (function(ParseErrorCode2) {
27177
+ ParseErrorCode2[ParseErrorCode2["InvalidSymbol"] = 1] = "InvalidSymbol";
27178
+ ParseErrorCode2[ParseErrorCode2["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
27179
+ ParseErrorCode2[ParseErrorCode2["PropertyNameExpected"] = 3] = "PropertyNameExpected";
27180
+ ParseErrorCode2[ParseErrorCode2["ValueExpected"] = 4] = "ValueExpected";
27181
+ ParseErrorCode2[ParseErrorCode2["ColonExpected"] = 5] = "ColonExpected";
27182
+ ParseErrorCode2[ParseErrorCode2["CommaExpected"] = 6] = "CommaExpected";
27183
+ ParseErrorCode2[ParseErrorCode2["CloseBraceExpected"] = 7] = "CloseBraceExpected";
27184
+ ParseErrorCode2[ParseErrorCode2["CloseBracketExpected"] = 8] = "CloseBracketExpected";
27185
+ ParseErrorCode2[ParseErrorCode2["EndOfFileExpected"] = 9] = "EndOfFileExpected";
27186
+ ParseErrorCode2[ParseErrorCode2["InvalidCommentToken"] = 10] = "InvalidCommentToken";
27187
+ ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
27188
+ ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
27189
+ ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
27190
+ ParseErrorCode2[ParseErrorCode2["InvalidUnicode"] = 14] = "InvalidUnicode";
27191
+ ParseErrorCode2[ParseErrorCode2["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
27192
+ ParseErrorCode2[ParseErrorCode2["InvalidCharacter"] = 16] = "InvalidCharacter";
27193
+ })(ParseErrorCode || (exports2.ParseErrorCode = ParseErrorCode = {}));
27194
+ function printParseErrorCode(code) {
27195
+ switch (code) {
27196
+ case 1:
27197
+ return "InvalidSymbol";
27198
+ case 2:
27199
+ return "InvalidNumberFormat";
27200
+ case 3:
27201
+ return "PropertyNameExpected";
27202
+ case 4:
27203
+ return "ValueExpected";
27204
+ case 5:
27205
+ return "ColonExpected";
27206
+ case 6:
27207
+ return "CommaExpected";
27208
+ case 7:
27209
+ return "CloseBraceExpected";
27210
+ case 8:
27211
+ return "CloseBracketExpected";
27212
+ case 9:
27213
+ return "EndOfFileExpected";
27214
+ case 10:
27215
+ return "InvalidCommentToken";
27216
+ case 11:
27217
+ return "UnexpectedEndOfComment";
27218
+ case 12:
27219
+ return "UnexpectedEndOfString";
27220
+ case 13:
27221
+ return "UnexpectedEndOfNumber";
27222
+ case 14:
27223
+ return "InvalidUnicode";
27224
+ case 15:
27225
+ return "InvalidEscapeCharacter";
27226
+ case 16:
27227
+ return "InvalidCharacter";
27228
+ }
27229
+ return "<unknown ParseErrorCode>";
27230
+ }
27231
+ exports2.printParseErrorCode = printParseErrorCode;
27232
+ function format(documentText, range, options2) {
27233
+ return formatter.format(documentText, range, options2);
27234
+ }
27235
+ exports2.format = format;
27236
+ function modify(text, path, value, options2) {
27237
+ return edit.setProperty(text, path, value, options2);
27238
+ }
27239
+ exports2.modify = modify;
27240
+ function applyEdits(text, edits) {
27241
+ let sortedEdits = edits.slice(0).sort((a, b) => {
27242
+ const diff = a.offset - b.offset;
27243
+ if (diff === 0) {
27244
+ return a.length - b.length;
27245
+ }
27246
+ return diff;
27247
+ });
27248
+ let lastModifiedOffset = text.length;
27249
+ for (let i = sortedEdits.length - 1;i >= 0; i--) {
27250
+ let e = sortedEdits[i];
27251
+ if (e.offset + e.length <= lastModifiedOffset) {
27252
+ text = edit.applyEdit(text, e);
27253
+ } else {
27254
+ throw new Error("Overlapping edit");
27255
+ }
27256
+ lastModifiedOffset = e.offset;
27257
+ }
27258
+ return text;
27259
+ }
27260
+ exports2.applyEdits = applyEdits;
27261
+ });
27262
+ });
27263
+
27118
27264
  // node_modules/commander/esm.mjs
27119
27265
  var import_ = __toESM(require_commander(), 1);
27120
27266
  var {
@@ -45211,6 +45357,8 @@ Dry run \u2014 no changes made.`));
45211
45357
  }
45212
45358
 
45213
45359
  // dist/core/agentSettings/settingsManager.js
45360
+ var TOML4 = __toESM(require_toml(), 1);
45361
+ var import_jsonc_parser = __toESM(require_main(), 1);
45214
45362
  init_fs();
45215
45363
  init_userConfig();
45216
45364
 
@@ -45243,12 +45391,32 @@ function parseAgentSettingValue(definition, raw, parseJson = false) {
45243
45391
  }
45244
45392
  return value;
45245
45393
  }
45394
+ case "positiveInteger": {
45395
+ const value = Number(raw);
45396
+ if (!Number.isInteger(value) || value <= 0) {
45397
+ throw new Error(`Value for "${definition.key}" must be a positive integer.`);
45398
+ }
45399
+ return value;
45400
+ }
45246
45401
  case "enum": {
45247
45402
  if (!definition.allowedValues?.includes(raw)) {
45248
45403
  throw new Error(`Value for "${definition.key}" must be one of: ${definition.allowedValues?.join(", ")}.`);
45249
45404
  }
45250
45405
  return raw;
45251
45406
  }
45407
+ case "booleanOrEnum": {
45408
+ const normalized = raw.trim().toLowerCase();
45409
+ if (TRUE_VALUES.has(normalized)) {
45410
+ return true;
45411
+ }
45412
+ if (FALSE_VALUES.has(normalized)) {
45413
+ return false;
45414
+ }
45415
+ if (definition.allowedValues?.includes(raw)) {
45416
+ return raw;
45417
+ }
45418
+ throw new Error(`Value for "${definition.key}" must be one of: on, off, true, false, yes, no, 1, 0, ${definition.allowedValues?.join(", ")}.`);
45419
+ }
45252
45420
  case "array": {
45253
45421
  if (parseJson) {
45254
45422
  const value = parseJsonValue(raw, definition.key);
@@ -45293,6 +45461,9 @@ var setting = function(key, valueType, title, description, options2 = {}) {
45293
45461
  if (options2.allowedValues) {
45294
45462
  definition.allowedValues = options2.allowedValues;
45295
45463
  }
45464
+ if (options2.store) {
45465
+ definition.store = options2.store;
45466
+ }
45296
45467
  if (options2.deprecated !== undefined) {
45297
45468
  definition.deprecated = options2.deprecated;
45298
45469
  }
@@ -45301,12 +45472,113 @@ var setting = function(key, valueType, title, description, options2 = {}) {
45301
45472
  }
45302
45473
  return definition;
45303
45474
  };
45475
+ var globalConfigSetting = function(key, valueType, title, description, options2 = {}) {
45476
+ return setting(key, valueType, title, description, {
45477
+ ...options2,
45478
+ scopes: GLOBAL_CONFIG_SCOPES,
45479
+ defaultScope: "global",
45480
+ store: "globalConfig"
45481
+ });
45482
+ };
45304
45483
  var ALL_SCOPES = ["global", "project", "local"];
45305
45484
  var PERSONAL_SCOPES = ["global", "local"];
45485
+ var GLOBAL_CONFIG_SCOPES = ["global"];
45486
+ var CLAUDE_HOOK_EVENTS = [
45487
+ "PreToolUse",
45488
+ "PostToolUse",
45489
+ "PostToolUseFailure",
45490
+ "Notification",
45491
+ "PermissionRequest",
45492
+ "Stop",
45493
+ "SessionStart",
45494
+ "SessionEnd"
45495
+ ];
45496
+ var THEME_VALUES = ["auto", "dark", "light", "light-daltonized", "dark-daltonized", "light-ansi", "dark-ansi"];
45497
+ var NOTIFICATION_CHANNELS = ["auto", "iterm2", "iterm2_with_bell", "terminal_bell", "kitty", "ghostty", "notifications_disabled"];
45498
+ var TEAMMATE_MODES = ["auto", "tmux", "in-process"];
45306
45499
  var claudeSettingsAdapter = {
45307
45500
  agent: "claude",
45308
45501
  displayName: "Claude Code",
45502
+ hookEvents: CLAUDE_HOOK_EVENTS,
45503
+ hookScopes: ALL_SCOPES,
45309
45504
  definitions: [
45505
+ globalConfigSetting("theme", "enum", "Theme", "Claude Code UI color theme.", {
45506
+ allowedValues: THEME_VALUES,
45507
+ category: "ui"
45508
+ }),
45509
+ globalConfigSetting("editorMode", "enum", "Editor mode", "Keyboard editing mode.", {
45510
+ allowedValues: ["normal", "vim"],
45511
+ category: "ui"
45512
+ }),
45513
+ globalConfigSetting("verbose", "boolean", "Verbose output", "Show detailed debug output.", {
45514
+ category: "runtime"
45515
+ }),
45516
+ globalConfigSetting("preferredNotifChannel", "enum", "Notification channel", "Preferred local notification delivery method.", {
45517
+ allowedValues: NOTIFICATION_CHANNELS,
45518
+ category: "notifications"
45519
+ }),
45520
+ globalConfigSetting("autoCompactEnabled", "boolean", "Auto compact", "Auto-compact conversation context when it gets full.", {
45521
+ category: "runtime"
45522
+ }),
45523
+ globalConfigSetting("fileCheckpointingEnabled", "boolean", "File checkpointing", "Enable code rewind checkpoint snapshots.", {
45524
+ category: "runtime"
45525
+ }),
45526
+ globalConfigSetting("showTurnDuration", "boolean", "Turn duration", "Show how long Claude spent on each turn.", {
45527
+ category: "ui"
45528
+ }),
45529
+ globalConfigSetting("terminalProgressBarEnabled", "boolean", "Terminal progress bar", "Show terminal progress in supported terminals.", {
45530
+ category: "ui"
45531
+ }),
45532
+ globalConfigSetting("todoFeatureEnabled", "boolean", "Todo feature", "Enable Claude todo and task tracking.", {
45533
+ category: "ui"
45534
+ }),
45535
+ globalConfigSetting("teammateMode", "enum", "Teammate mode", "Control how Claude spawns teammate agents.", {
45536
+ allowedValues: TEAMMATE_MODES,
45537
+ category: "agents"
45538
+ }),
45539
+ globalConfigSetting("autoConnectIde", "boolean", "Auto-connect IDE", "Auto-connect to an IDE from external terminals.", {
45540
+ category: "ide"
45541
+ }),
45542
+ globalConfigSetting("autoInstallIdeExtension", "boolean", "Auto-install IDE extension", "Auto-install the IDE extension when supported.", {
45543
+ category: "ide"
45544
+ }),
45545
+ globalConfigSetting("diffTool", "enum", "Diff tool", "Choose where diffs are shown.", {
45546
+ allowedValues: ["terminal", "auto"],
45547
+ category: "ide"
45548
+ }),
45549
+ globalConfigSetting("respectGitignore", "boolean", "Respect gitignore", "Hide gitignored files from Claude file pickers.", {
45550
+ category: "ui"
45551
+ }),
45552
+ globalConfigSetting("copyFullResponse", "boolean", "Copy full response", "Copy full responses without the copy picker flow.", {
45553
+ category: "ui"
45554
+ }),
45555
+ globalConfigSetting("copyOnSelect", "boolean", "Copy on select", "Copy selected text automatically in fullscreen mode.", {
45556
+ category: "ui"
45557
+ }),
45558
+ globalConfigSetting("remoteControlAtStartup", "boolean", "Remote control at startup", "Enable Remote Control for new Claude sessions. Unset to restore Claude defaults.", {
45559
+ category: "remote-control"
45560
+ }),
45561
+ globalConfigSetting("taskCompleteNotifEnabled", "boolean", "Task complete push notifications", "Push when Claude finishes and becomes idle.", {
45562
+ category: "notifications"
45563
+ }),
45564
+ globalConfigSetting("inputNeededNotifEnabled", "boolean", "Input needed push notifications", "Push when Claude needs user input.", {
45565
+ category: "notifications"
45566
+ }),
45567
+ globalConfigSetting("agentPushNotifEnabled", "boolean", "Agent push notifications", "Allow Claude to decide when to send push notifications.", {
45568
+ category: "notifications"
45569
+ }),
45570
+ globalConfigSetting("showStatusInTerminalTab", "boolean", "Terminal tab status", "Show Claude status in the terminal tab status area.", {
45571
+ category: "ui"
45572
+ }),
45573
+ globalConfigSetting("prStatusFooterEnabled", "boolean", "PR status footer", "Show pull request status in Claude footer.", {
45574
+ category: "git"
45575
+ }),
45576
+ globalConfigSetting("claudeInChromeDefaultEnabled", "boolean", "Claude in Chrome default", "Enable Claude in Chrome by default.", {
45577
+ category: "browser"
45578
+ }),
45579
+ globalConfigSetting("teammateDefaultModel", "string", "Teammate default model", "Default model for spawned teammate agents.", {
45580
+ category: "agents"
45581
+ }),
45310
45582
  setting("model", "string", "Model", "Override the default Claude Code model.", {
45311
45583
  defaultScope: "global",
45312
45584
  category: "model"
@@ -45327,7 +45599,12 @@ var claudeSettingsAdapter = {
45327
45599
  category: "permissions"
45328
45600
  }),
45329
45601
  setting("permissions.defaultMode", "enum", "Default permission mode", "Default permission mode when opening Claude Code.", {
45330
- allowedValues: ["default", "acceptEdits", "plan"],
45602
+ allowedValues: ["default", "acceptEdits", "plan", "dontAsk"],
45603
+ category: "permissions",
45604
+ risk: "security-sensitive"
45605
+ }),
45606
+ setting("permissions.disableBypassPermissionsMode", "enum", "Disable bypass permissions mode", "Disable Claude bypass-permissions mode.", {
45607
+ allowedValues: ["disable"],
45331
45608
  category: "permissions",
45332
45609
  risk: "security-sensitive"
45333
45610
  }),
@@ -45348,6 +45625,14 @@ var claudeSettingsAdapter = {
45348
45625
  defaultScope: "global",
45349
45626
  category: "memory"
45350
45627
  }),
45628
+ setting("autoMemoryEnabled", "boolean", "Auto memory", "Enable automatic memory capture.", {
45629
+ defaultScope: "global",
45630
+ category: "memory"
45631
+ }),
45632
+ setting("autoDreamEnabled", "boolean", "Auto dream", "Enable background memory consolidation.", {
45633
+ defaultScope: "global",
45634
+ category: "memory"
45635
+ }),
45351
45636
  setting("alwaysThinkingEnabled", "boolean", "Always thinking", "Enable extended thinking by default for Claude Code sessions.", {
45352
45637
  defaultScope: "global",
45353
45638
  category: "model"
@@ -45386,6 +45671,24 @@ var claudeSettingsAdapter = {
45386
45671
  defaultScope: "global",
45387
45672
  category: "runtime"
45388
45673
  }),
45674
+ setting("language", "string", "Language", "Preferred language for Claude responses and voice dictation.", {
45675
+ defaultScope: "global",
45676
+ category: "ui"
45677
+ }),
45678
+ setting("outputStyle", "string", "Output style", "Claude response output style.", {
45679
+ defaultScope: "global",
45680
+ category: "ui"
45681
+ }),
45682
+ setting("defaultView", "enum", "Default view", "Default Claude view. Unset to restore Claude defaults.", {
45683
+ allowedValues: ["transcript", "chat"],
45684
+ category: "ui"
45685
+ }),
45686
+ setting("useAutoModeDuringPlan", "boolean", "Use auto mode during plan", "Allow auto permission mode during plan mode.", {
45687
+ scopes: PERSONAL_SCOPES,
45688
+ defaultScope: "global",
45689
+ category: "permissions",
45690
+ risk: "security-sensitive"
45691
+ }),
45389
45692
  setting("includeCoAuthoredBy", "boolean", "Include co-authored-by", "Deprecated Claude Code attribution toggle.", {
45390
45693
  defaultScope: "global",
45391
45694
  category: "git",
@@ -45410,7 +45713,10 @@ var claudeSettingsAdapter = {
45410
45713
  risk: "security-sensitive"
45411
45714
  })
45412
45715
  ],
45413
- getSettingsPath(scope, projectPath) {
45716
+ getSettingsPath(scope, projectPath, definition) {
45717
+ if (definition?.store === "globalConfig") {
45718
+ return expandTilde("~/.claude.json");
45719
+ }
45414
45720
  switch (scope) {
45415
45721
  case "global":
45416
45722
  return expandTilde("~/.claude/settings.json");
@@ -45422,6 +45728,263 @@ var claudeSettingsAdapter = {
45422
45728
  }
45423
45729
  };
45424
45730
 
45731
+ // dist/core/agentSettings/adapters/codex.js
45732
+ init_paths();
45733
+ import {join as join13} from "path";
45734
+ var setting2 = function(key, valueType, title, description, options2 = {}) {
45735
+ const definition = {
45736
+ agent: "codex",
45737
+ key,
45738
+ nativePath: key.split("."),
45739
+ title,
45740
+ description,
45741
+ valueType,
45742
+ scopes: options2.scopes ?? ALL_SCOPES2,
45743
+ defaultScope: options2.defaultScope ?? "global",
45744
+ category: options2.category ?? "settings",
45745
+ risk: options2.risk ?? "safe"
45746
+ };
45747
+ if (options2.allowedValues) {
45748
+ definition.allowedValues = options2.allowedValues;
45749
+ }
45750
+ if (options2.deprecated !== undefined) {
45751
+ definition.deprecated = options2.deprecated;
45752
+ }
45753
+ if (options2.replacement) {
45754
+ definition.replacement = options2.replacement;
45755
+ }
45756
+ return definition;
45757
+ };
45758
+ var featureSetting = function(key, title, description, options2 = {}) {
45759
+ return setting2(`features.${key}`, "boolean", title, description, {
45760
+ ...options2,
45761
+ category: "features"
45762
+ });
45763
+ };
45764
+ var ALL_SCOPES2 = ["global", "project"];
45765
+ var CODEX_HOOK_EVENTS = [
45766
+ "PreToolUse",
45767
+ "PermissionRequest",
45768
+ "PostToolUse",
45769
+ "SessionStart",
45770
+ "UserPromptSubmit",
45771
+ "Stop"
45772
+ ];
45773
+ var codexSettingsAdapter = {
45774
+ agent: "codex",
45775
+ displayName: "OpenAI Codex CLI",
45776
+ format: "toml",
45777
+ hookEvents: CODEX_HOOK_EVENTS,
45778
+ hookScopes: ALL_SCOPES2,
45779
+ definitions: [
45780
+ setting2("model", "string", "Model", "Override the default Codex model.", {
45781
+ category: "model"
45782
+ }),
45783
+ setting2("model_provider", "string", "Model provider", "Select a configured model provider.", {
45784
+ category: "model"
45785
+ }),
45786
+ setting2("model_reasoning_effort", "enum", "Reasoning effort", "Reasoning effort for supported models.", {
45787
+ allowedValues: ["minimal", "low", "medium", "high"],
45788
+ category: "model"
45789
+ }),
45790
+ setting2("approval_policy", "enum", "Approval policy", "Control when Codex asks for approval before running commands.", {
45791
+ allowedValues: ["untrusted", "on-failure", "on-request", "never"],
45792
+ category: "permissions",
45793
+ risk: "security-sensitive"
45794
+ }),
45795
+ setting2("sandbox_mode", "enum", "Sandbox mode", "Control Codex command sandboxing.", {
45796
+ allowedValues: ["read-only", "workspace-write", "danger-full-access"],
45797
+ category: "permissions",
45798
+ risk: "security-sensitive"
45799
+ }),
45800
+ setting2("web_search", "enum", "Web search", "Top-level Codex web search mode.", {
45801
+ allowedValues: ["live", "cached", "disabled"],
45802
+ category: "tools"
45803
+ }),
45804
+ setting2("notify", "array", "Notifications", "Program arguments for a notification command run after agent turns.", {
45805
+ category: "notifications"
45806
+ }),
45807
+ setting2("instructions", "string", "Instructions", "Additional user instructions for Codex.", {
45808
+ category: "runtime"
45809
+ }),
45810
+ setting2("model_instructions_file", "string", "Model instructions file", "Path to a model instructions file for Codex.", {
45811
+ category: "runtime"
45812
+ }),
45813
+ featureSetting("apps", "Apps", "Enable ChatGPT Apps/connectors support.", {
45814
+ risk: "risky"
45815
+ }),
45816
+ featureSetting("codex_hooks", "Codex hooks", "Enable lifecycle hooks from hooks.json or inline [hooks]."),
45817
+ featureSetting("fast_mode", "Fast mode", 'Enable Fast mode selection and the service_tier = "fast" path.'),
45818
+ featureSetting("memories", "Memories", "Enable Codex Memories."),
45819
+ featureSetting("multi_agent", "Multi-agent", "Enable subagent collaboration tools."),
45820
+ featureSetting("personality", "Personality", "Enable personality selection controls."),
45821
+ featureSetting("shell_snapshot", "Shell snapshot", "Snapshot your shell environment to speed up repeated commands."),
45822
+ featureSetting("shell_tool", "Shell tool", "Enable the default shell tool."),
45823
+ featureSetting("unified_exec", "Unified exec", "Use the unified PTY-backed exec tool."),
45824
+ featureSetting("undo", "Undo", "Enable undo via per-turn git ghost snapshots."),
45825
+ featureSetting("web_search", "Legacy web search feature", "Deprecated legacy web search feature toggle; prefer top-level web_search.", {
45826
+ risk: "deprecated",
45827
+ deprecated: true,
45828
+ replacement: "web_search"
45829
+ }),
45830
+ featureSetting("web_search_cached", "Legacy cached web search", 'Deprecated legacy toggle that maps to web_search = "cached" when unset.', {
45831
+ risk: "deprecated",
45832
+ deprecated: true,
45833
+ replacement: "web_search"
45834
+ }),
45835
+ featureSetting("web_search_request", "Legacy live web search", 'Deprecated legacy toggle that maps to web_search = "live" when unset.', {
45836
+ risk: "deprecated",
45837
+ deprecated: true,
45838
+ replacement: "web_search"
45839
+ })
45840
+ ],
45841
+ getSettingsPath(scope, projectPath) {
45842
+ switch (scope) {
45843
+ case "global":
45844
+ return expandTilde("~/.codex/config.toml");
45845
+ case "project":
45846
+ return join13(projectPath, ".codex", "config.toml");
45847
+ case "local":
45848
+ return join13(projectPath, ".codex", "config.toml");
45849
+ }
45850
+ }
45851
+ };
45852
+
45853
+ // dist/core/agentSettings/adapters/opencode.js
45854
+ init_paths();
45855
+ import {existsSync as existsSync3} from "fs";
45856
+ import {join as join14} from "path";
45857
+ var firstExistingPath = function(paths9, fallback2) {
45858
+ return paths9.find((candidate) => existsSync3(candidate)) ?? fallback2;
45859
+ };
45860
+ var setting3 = function(key, valueType, title, description, options2 = {}) {
45861
+ const definition = {
45862
+ agent: "opencode",
45863
+ key,
45864
+ nativePath: options2.nativePath ?? key.split("."),
45865
+ title,
45866
+ description,
45867
+ valueType,
45868
+ scopes: options2.scopes ?? SUPPORTED_SCOPES,
45869
+ defaultScope: options2.defaultScope ?? "global",
45870
+ category: options2.category ?? "settings",
45871
+ risk: options2.risk ?? "safe"
45872
+ };
45873
+ if (options2.allowedValues) {
45874
+ definition.allowedValues = options2.allowedValues;
45875
+ }
45876
+ if (options2.deprecated !== undefined) {
45877
+ definition.deprecated = options2.deprecated;
45878
+ }
45879
+ if (options2.replacement) {
45880
+ definition.replacement = options2.replacement;
45881
+ }
45882
+ return definition;
45883
+ };
45884
+ var SUPPORTED_SCOPES = ["global", "project"];
45885
+ var PERMISSION_ACTIONS = ["allow", "ask", "deny"];
45886
+ var opencodeSettingsAdapter = {
45887
+ agent: "opencode",
45888
+ displayName: "OpenCode",
45889
+ format: "jsonc",
45890
+ definitions: [
45891
+ setting3("model", "string", "Model", "Default model identifier in provider/model format (e.g. anthropic/claude-sonnet-4-5).", {
45892
+ category: "model"
45893
+ }),
45894
+ setting3("small_model", "string", "Small model", "Small model used for tasks such as title generation, in provider/model format.", {
45895
+ category: "model"
45896
+ }),
45897
+ setting3("provider", "object", "Providers", "Custom OpenCode provider configurations and model overrides.", {
45898
+ category: "provider",
45899
+ risk: "security-sensitive"
45900
+ }),
45901
+ setting3("default_agent", "string", "Default agent", "Default primary agent to use when none is specified.", {
45902
+ category: "agent"
45903
+ }),
45904
+ setting3("autoupdate", "booleanOrEnum", "Auto update", "Control automatic updates: true, false, or notify.", {
45905
+ allowedValues: ["notify"],
45906
+ scopes: ["global"],
45907
+ defaultScope: "global",
45908
+ category: "runtime"
45909
+ }),
45910
+ setting3("shell", "string", "Shell", "Default shell to use for terminal and bash tool execution.", {
45911
+ category: "runtime"
45912
+ }),
45913
+ setting3("share", "enum", "Share", "Control sharing behavior: manual, auto, or disabled.", {
45914
+ allowedValues: ["manual", "auto", "disabled"],
45915
+ category: "sharing"
45916
+ }),
45917
+ setting3("username", "string", "Username", "Custom username displayed in conversations instead of system username.", {
45918
+ category: "ui"
45919
+ }),
45920
+ setting3("logLevel", "enum", "Log level", "Log verbosity level.", {
45921
+ allowedValues: ["DEBUG", "INFO", "WARN", "ERROR"],
45922
+ category: "runtime"
45923
+ }),
45924
+ setting3("snapshot", "boolean", "Snapshot tracking", "Enable or disable filesystem snapshot tracking for undo/redo.", {
45925
+ category: "runtime"
45926
+ }),
45927
+ setting3("permission.*", "enum", "Default permission", "Fallback permission rule for all tools: allow, ask, or deny.", {
45928
+ nativePath: ["permission", "*"],
45929
+ category: "permissions",
45930
+ risk: "security-sensitive",
45931
+ allowedValues: PERMISSION_ACTIONS
45932
+ }),
45933
+ setting3("permission.bash", "enum", "Bash permission", "Permission rule for shell command execution.", {
45934
+ category: "permissions",
45935
+ risk: "security-sensitive",
45936
+ allowedValues: PERMISSION_ACTIONS
45937
+ }),
45938
+ setting3("permission.read", "enum", "Read permission", "Permission rule for file reads.", {
45939
+ category: "permissions",
45940
+ allowedValues: PERMISSION_ACTIONS
45941
+ }),
45942
+ setting3("permission.edit", "enum", "Edit permission", "Permission rule for editing and writing files.", {
45943
+ category: "permissions",
45944
+ risk: "risky",
45945
+ allowedValues: PERMISSION_ACTIONS
45946
+ }),
45947
+ setting3("permission.webfetch", "enum", "Web fetch permission", "Permission rule for fetching external URLs.", {
45948
+ category: "permissions",
45949
+ allowedValues: PERMISSION_ACTIONS
45950
+ }),
45951
+ setting3("permission.task", "enum", "Task permission", "Permission rule for spawning subagent tasks.", {
45952
+ category: "permissions",
45953
+ allowedValues: PERMISSION_ACTIONS
45954
+ }),
45955
+ setting3("permission.websearch", "enum", "Web search permission", "Permission rule for web search operations.", {
45956
+ category: "permissions",
45957
+ allowedValues: PERMISSION_ACTIONS
45958
+ }),
45959
+ setting3("compaction.auto", "boolean", "Auto compaction", "Enable automatic context compaction when context is full.", {
45960
+ category: "compaction"
45961
+ }),
45962
+ setting3("tool_output.max_lines", "positiveInteger", "Tool output max lines", "Maximum lines of tool output before truncation.", {
45963
+ category: "output"
45964
+ }),
45965
+ setting3("tool_output.max_bytes", "positiveInteger", "Tool output max bytes", "Maximum bytes of tool output before truncation.", {
45966
+ category: "output"
45967
+ })
45968
+ ],
45969
+ getSettingsPath(scope, projectPath) {
45970
+ switch (scope) {
45971
+ case "global":
45972
+ return firstExistingPath([
45973
+ expandTilde("~/.config/opencode/opencode.jsonc"),
45974
+ expandTilde("~/.config/opencode/opencode.json"),
45975
+ expandTilde("~/.config/opencode/config.json")
45976
+ ], expandTilde("~/.config/opencode/opencode.json"));
45977
+ case "project":
45978
+ return firstExistingPath([
45979
+ join14(projectPath, ".opencode", "opencode.jsonc"),
45980
+ join14(projectPath, ".opencode", "opencode.json")
45981
+ ], join14(projectPath, ".opencode", "opencode.json"));
45982
+ case "local":
45983
+ throw new Error("OpenCode settings do not support local scope. Use --global or --project.");
45984
+ }
45985
+ }
45986
+ };
45987
+
45425
45988
  // dist/core/agentSettings/registry.js
45426
45989
  function getAgentSettingsAdapters() {
45427
45990
  return [...ADAPTERS];
@@ -45439,7 +46002,9 @@ function toSchemaEntry(definition) {
45439
46002
  };
45440
46003
  }
45441
46004
  var ADAPTERS = [
45442
- claudeSettingsAdapter
46005
+ claudeSettingsAdapter,
46006
+ codexSettingsAdapter,
46007
+ opencodeSettingsAdapter
45443
46008
  ];
45444
46009
 
45445
46010
  // dist/core/agentSettings/settingsManager.js
@@ -45571,6 +46136,48 @@ var buildHookCommand = function(command, name) {
45571
46136
  ...name ? { name } : {}
45572
46137
  };
45573
46138
  };
46139
+ var normalizeApiKeyForConfig = function(apiKey) {
46140
+ const trimmed = apiKey.trim();
46141
+ if (!trimmed) {
46142
+ throw new Error("API key cannot be empty.");
46143
+ }
46144
+ return trimmed.slice(-20);
46145
+ };
46146
+ var getApiKeyResponses = function(config) {
46147
+ const current = config.customApiKeyResponses;
46148
+ if (current !== undefined && (!current || typeof current !== "object" || Array.isArray(current))) {
46149
+ throw new Error("Existing customApiKeyResponses value is not an object.");
46150
+ }
46151
+ const responses = current ?? {};
46152
+ const approved = responses.approved ?? [];
46153
+ const rejected = responses.rejected ?? [];
46154
+ if (!Array.isArray(approved) || !approved.every((value) => typeof value === "string")) {
46155
+ throw new Error("Existing customApiKeyResponses.approved value must be an array of strings.");
46156
+ }
46157
+ if (!Array.isArray(rejected) || !rejected.every((value) => typeof value === "string")) {
46158
+ throw new Error("Existing customApiKeyResponses.rejected value must be an array of strings.");
46159
+ }
46160
+ return {
46161
+ approved,
46162
+ rejected
46163
+ };
46164
+ };
46165
+ var getApiKeyStatusFromResponses = function(responses, fingerprint) {
46166
+ if (responses.approved.includes(fingerprint)) {
46167
+ return "approved";
46168
+ }
46169
+ if (responses.rejected.includes(fingerprint)) {
46170
+ return "rejected";
46171
+ }
46172
+ return "unknown";
46173
+ };
46174
+ var setApiKeyResponses = function(config, approved, rejected) {
46175
+ config.customApiKeyResponses = {
46176
+ ...config.customApiKeyResponses && typeof config.customApiKeyResponses === "object" && !Array.isArray(config.customApiKeyResponses) ? config.customApiKeyResponses : {},
46177
+ approved,
46178
+ rejected
46179
+ };
46180
+ };
45574
46181
  var deleteNestedValue = function(config, path) {
45575
46182
  const parents = [];
45576
46183
  let current = config;
@@ -45604,26 +46211,75 @@ var resolveProjectPath = function(projectPath) {
45604
46211
  return projectPath ?? process.cwd();
45605
46212
  };
45606
46213
  var resolveScope = function(definition, scope) {
45607
- const resolvedScope = scope ?? getEffectiveAgentSettingsDefaultScopeSync();
46214
+ const defaultScope = getEffectiveAgentSettingsDefaultScopeSync();
46215
+ const resolvedScope = scope ?? (definition.store === "globalConfig" && !definition.scopes.includes(defaultScope) ? definition.defaultScope : defaultScope);
45608
46216
  if (!definition.scopes.includes(resolvedScope)) {
45609
46217
  throw new Error(`"${definition.key}" does not support ${resolvedScope} scope. Supported scopes: ${definition.scopes.join(", ")}.`);
45610
46218
  }
45611
46219
  return resolvedScope;
45612
46220
  };
45613
- async function readJsonObject(path) {
46221
+ var getSupportedSettingScopes = function(adapter) {
46222
+ return [...new Set(adapter.definitions.flatMap((definition) => definition.scopes))];
46223
+ };
46224
+ var resolveFullReadScope = function(adapter, scope) {
46225
+ const resolvedScope = scope ?? getEffectiveAgentSettingsDefaultScopeSync();
46226
+ const supportedScopes = getSupportedSettingScopes(adapter);
46227
+ if (!supportedScopes.includes(resolvedScope)) {
46228
+ throw new Error(`Agent ${adapter.agent} settings do not support ${resolvedScope} scope. Supported scopes: ${supportedScopes.join(", ")}.`);
46229
+ }
46230
+ return resolvedScope;
46231
+ };
46232
+ async function readConfigObject(adapter, path) {
45614
46233
  const content = await readFileIfExists(path);
45615
46234
  if (!content) {
45616
46235
  return {};
45617
46236
  }
46237
+ if (adapter.format === "toml") {
46238
+ try {
46239
+ return assertObject(TOML4.parse(content), path);
46240
+ } catch (error) {
46241
+ if (error instanceof SyntaxError || error instanceof Error) {
46242
+ throw new Error(`${path} contains invalid TOML.`);
46243
+ }
46244
+ throw error;
46245
+ }
46246
+ }
45618
46247
  try {
45619
- return assertObject(JSON.parse(content), path);
46248
+ const errors5 = [];
46249
+ const value = adapter.format === "jsonc" ? import_jsonc_parser.parse(content, errors5, { allowTrailingComma: true }) : JSON.parse(content);
46250
+ if (errors5.length > 0) {
46251
+ throw new SyntaxError("Invalid JSONC");
46252
+ }
46253
+ return assertObject(value, path);
45620
46254
  } catch (error) {
45621
46255
  if (error instanceof SyntaxError) {
45622
- throw new Error(`${path} contains invalid JSON.`);
46256
+ throw new Error(`${path} contains invalid ${adapter.format === "jsonc" ? "JSONC" : "JSON"}.`);
45623
46257
  }
45624
46258
  throw error;
45625
46259
  }
45626
46260
  }
46261
+ var stringifyConfigObject = function(adapter, config) {
46262
+ if (adapter.format === "toml") {
46263
+ return TOML4.stringify(config);
46264
+ }
46265
+ return `${JSON.stringify(config, null, 2)}\n`;
46266
+ };
46267
+ async function writeConfigObject(adapter, path, config) {
46268
+ await writeFile(path, stringifyConfigObject(adapter, config));
46269
+ }
46270
+ var assertHookEventSupported = function(adapter, event) {
46271
+ if (adapter.hookEvents && !adapter.hookEvents.includes(event)) {
46272
+ throw new Error(`Agent ${adapter.agent} does not support ${event} hooks. Supported: ${adapter.hookEvents.join(", ")}.`);
46273
+ }
46274
+ };
46275
+ var resolveHookScope = function(adapter, scope) {
46276
+ const resolvedScope = scope ?? getEffectiveAgentSettingsDefaultScopeSync();
46277
+ const supportedScopes = adapter.hookScopes ?? ["global", "project", "local"];
46278
+ if (!supportedScopes.includes(resolvedScope)) {
46279
+ throw new Error(`Agent ${adapter.agent} hooks do not support ${resolvedScope} scope. Supported scopes: ${supportedScopes.join(", ")}.`);
46280
+ }
46281
+ return resolvedScope;
46282
+ };
45627
46283
  var HOOK_EVENT_ALIASES = {
45628
46284
  "pre-tool-use": "PreToolUse",
45629
46285
  "before-tool-use": "PreToolUse",
@@ -45634,9 +46290,23 @@ var HOOK_EVENT_ALIASES = {
45634
46290
  "permission-request": "PermissionRequest",
45635
46291
  stop: "Stop",
45636
46292
  "session-start": "SessionStart",
45637
- "session-end": "SessionEnd"
46293
+ "session-end": "SessionEnd",
46294
+ "user-prompt-submit": "UserPromptSubmit"
45638
46295
  };
45639
46296
  var HOOK_EVENTS = new Set(Object.values(HOOK_EVENT_ALIASES));
46297
+ var CLAUDE_API_KEY_RESPONSES_DEFINITION = {
46298
+ agent: "claude",
46299
+ key: "customApiKeyResponses",
46300
+ nativePath: ["customApiKeyResponses"],
46301
+ title: "Custom API key responses",
46302
+ description: "Remembered custom API key trust responses.",
46303
+ valueType: "object",
46304
+ scopes: ["global"],
46305
+ defaultScope: "global",
46306
+ category: "auth",
46307
+ risk: "security-sensitive",
46308
+ store: "globalConfig"
46309
+ };
45640
46310
 
45641
46311
  class AgentSettingsManager {
45642
46312
  getSupportedAgents() {
@@ -45660,17 +46330,34 @@ class AgentSettingsManager {
45660
46330
  throw new Error(`Unsupported agent settings adapter: ${agent}. Supported: ${this.getSupportedAgents().join(", ")}`);
45661
46331
  }
45662
46332
  if (!key) {
45663
- const scope2 = options2.scope ?? getEffectiveAgentSettingsDefaultScopeSync();
46333
+ const scope2 = resolveFullReadScope(adapter, options2.scope);
45664
46334
  const path2 = adapter.getSettingsPath(scope2, resolveProjectPath(options2.projectPath));
45665
- return await readJsonObject(path2);
46335
+ const config2 = await readConfigObject(adapter, path2);
46336
+ if (scope2 !== "global") {
46337
+ return config2;
46338
+ }
46339
+ const globalConfigDefinitions = adapter.definitions.filter((definition2) => definition2.store === "globalConfig" && definition2.scopes.includes("global"));
46340
+ if (globalConfigDefinitions.length === 0) {
46341
+ return config2;
46342
+ }
46343
+ const globalConfigPath = adapter.getSettingsPath("global", resolveProjectPath(options2.projectPath), globalConfigDefinitions[0]);
46344
+ const globalConfig = await readConfigObject(adapter, globalConfigPath);
46345
+ const result = { ...config2 };
46346
+ for (const definition2 of globalConfigDefinitions) {
46347
+ const value = getNestedValue(globalConfig, definition2.nativePath);
46348
+ if (value !== undefined) {
46349
+ setNestedValue(result, definition2.nativePath, value);
46350
+ }
46351
+ }
46352
+ return result;
45666
46353
  }
45667
46354
  const definition = getAgentSettingDefinition(agent, key);
45668
46355
  if (!definition) {
45669
46356
  throw new Error(`Unknown ${agent} setting: ${key}.`);
45670
46357
  }
45671
46358
  const scope = resolveScope(definition, options2.scope);
45672
- const path = adapter.getSettingsPath(scope, resolveProjectPath(options2.projectPath));
45673
- const config = await readJsonObject(path);
46359
+ const path = adapter.getSettingsPath(scope, resolveProjectPath(options2.projectPath), definition);
46360
+ const config = await readConfigObject(adapter, path);
45674
46361
  return getNestedValue(config, definition.nativePath);
45675
46362
  }
45676
46363
  async set(agent, key, rawValue, options2 = {}) {
@@ -45683,13 +46370,13 @@ class AgentSettingsManager {
45683
46370
  throw new Error(`Unknown ${agent} setting: ${key}.`);
45684
46371
  }
45685
46372
  const scope = resolveScope(definition, options2.scope);
45686
- const path = adapter.getSettingsPath(scope, resolveProjectPath(options2.projectPath));
45687
- const config = await readJsonObject(path);
46373
+ const path = adapter.getSettingsPath(scope, resolveProjectPath(options2.projectPath), definition);
46374
+ const config = await readConfigObject(adapter, path);
45688
46375
  const previousValue = getNestedValue(config, definition.nativePath);
45689
46376
  const value = parseAgentSettingValue(definition, rawValue, options2.parseJson);
45690
46377
  setNestedValue(config, definition.nativePath, value);
45691
46378
  if (!options2.dryRun) {
45692
- await writeFile(path, `${JSON.stringify(config, null, 2)}\n`);
46379
+ await writeConfigObject(adapter, path, config);
45693
46380
  }
45694
46381
  return {
45695
46382
  agent,
@@ -45711,12 +46398,12 @@ class AgentSettingsManager {
45711
46398
  throw new Error(`Unknown ${agent} setting: ${key}.`);
45712
46399
  }
45713
46400
  const scope = resolveScope(definition, options2.scope);
45714
- const path = adapter.getSettingsPath(scope, resolveProjectPath(options2.projectPath));
45715
- const config = await readJsonObject(path);
46401
+ const path = adapter.getSettingsPath(scope, resolveProjectPath(options2.projectPath), definition);
46402
+ const config = await readConfigObject(adapter, path);
45716
46403
  const previousValue = getNestedValue(config, definition.nativePath);
45717
46404
  deleteNestedValue(config, definition.nativePath);
45718
46405
  if (!options2.dryRun) {
45719
- await writeFile(path, `${JSON.stringify(config, null, 2)}\n`);
46406
+ await writeConfigObject(adapter, path, config);
45720
46407
  }
45721
46408
  return {
45722
46409
  agent,
@@ -45732,14 +46419,18 @@ class AgentSettingsManager {
45732
46419
  if (!adapter) {
45733
46420
  throw new Error(`Unsupported agent settings adapter: ${agent}. Supported: ${this.getSupportedAgents().join(", ")}`);
45734
46421
  }
45735
- if (agent !== "claude") {
46422
+ if (!adapter.hookEvents) {
45736
46423
  throw new Error(`Agent ${agent} does not support hook management.`);
45737
46424
  }
45738
- const scope = options2.scope ?? getEffectiveAgentSettingsDefaultScopeSync();
46425
+ const hookEvent = event ? normalizeHookEvent(event) : undefined;
46426
+ if (hookEvent) {
46427
+ assertHookEventSupported(adapter, hookEvent);
46428
+ }
46429
+ const scope = resolveHookScope(adapter, options2.scope);
45739
46430
  const path = adapter.getSettingsPath(scope, resolveProjectPath(options2.projectPath));
45740
- const config = await readJsonObject(path);
45741
- if (event) {
45742
- return getHookMatchers(config, normalizeHookEvent(event));
46431
+ const config = await readConfigObject(adapter, path);
46432
+ if (hookEvent) {
46433
+ return getHookMatchers(config, hookEvent);
45743
46434
  }
45744
46435
  const hooks = getNestedValue(config, ["hooks"]);
45745
46436
  if (hooks === undefined) {
@@ -45749,8 +46440,8 @@ class AgentSettingsManager {
45749
46440
  throw new Error("Existing hooks value is not an object.");
45750
46441
  }
45751
46442
  const result = {};
45752
- for (const [hookEvent, value] of Object.entries(hooks)) {
45753
- result[hookEvent] = assertHookMatchers(value);
46443
+ for (const [hookEvent2, value] of Object.entries(hooks)) {
46444
+ result[hookEvent2] = assertHookMatchers(value);
45754
46445
  }
45755
46446
  return result;
45756
46447
  }
@@ -45759,13 +46450,14 @@ class AgentSettingsManager {
45759
46450
  if (!adapter) {
45760
46451
  throw new Error(`Unsupported agent settings adapter: ${agent}. Supported: ${this.getSupportedAgents().join(", ")}`);
45761
46452
  }
45762
- if (agent !== "claude") {
46453
+ if (!adapter.hookEvents) {
45763
46454
  throw new Error(`Agent ${agent} does not support hook management.`);
45764
46455
  }
45765
46456
  const hookEvent = normalizeHookEvent(event);
45766
- const scope = options2.scope ?? getEffectiveAgentSettingsDefaultScopeSync();
46457
+ assertHookEventSupported(adapter, hookEvent);
46458
+ const scope = resolveHookScope(adapter, options2.scope);
45767
46459
  const path = adapter.getSettingsPath(scope, resolveProjectPath(options2.projectPath));
45768
- const config = await readJsonObject(path);
46460
+ const config = await readConfigObject(adapter, path);
45769
46461
  const hook = buildHookCommand(command, options2.name);
45770
46462
  const matchers = getHookMatchers(config, hookEvent);
45771
46463
  const matcher = options2.matcher ?? "*";
@@ -45780,7 +46472,7 @@ class AgentSettingsManager {
45780
46472
  }
45781
46473
  setHookMatchers(config, hookEvent, matchers);
45782
46474
  if (!options2.dryRun) {
45783
- await writeFile(path, `${JSON.stringify(config, null, 2)}\n`);
46475
+ await writeConfigObject(adapter, path, config);
45784
46476
  }
45785
46477
  return {
45786
46478
  agent,
@@ -45796,13 +46488,14 @@ class AgentSettingsManager {
45796
46488
  if (!adapter) {
45797
46489
  throw new Error(`Unsupported agent settings adapter: ${agent}. Supported: ${this.getSupportedAgents().join(", ")}`);
45798
46490
  }
45799
- if (agent !== "claude") {
46491
+ if (!adapter.hookEvents) {
45800
46492
  throw new Error(`Agent ${agent} does not support hook management.`);
45801
46493
  }
45802
46494
  const hookEvent = normalizeHookEvent(event);
45803
- const scope = options2.scope ?? getEffectiveAgentSettingsDefaultScopeSync();
46495
+ assertHookEventSupported(adapter, hookEvent);
46496
+ const scope = resolveHookScope(adapter, options2.scope);
45804
46497
  const path = adapter.getSettingsPath(scope, resolveProjectPath(options2.projectPath));
45805
- const config = await readJsonObject(path);
46498
+ const config = await readConfigObject(adapter, path);
45806
46499
  const matchers = getHookMatchers(config, hookEvent);
45807
46500
  let removed = 0;
45808
46501
  const nextMatchers = matchers.map((entry) => {
@@ -45820,7 +46513,7 @@ class AgentSettingsManager {
45820
46513
  }).filter((entry) => entry.hooks.length > 0);
45821
46514
  setHookMatchers(config, hookEvent, nextMatchers);
45822
46515
  if (!options2.dryRun) {
45823
- await writeFile(path, `${JSON.stringify(config, null, 2)}\n`);
46516
+ await writeConfigObject(adapter, path, config);
45824
46517
  }
45825
46518
  return {
45826
46519
  agent,
@@ -45831,6 +46524,60 @@ class AgentSettingsManager {
45831
46524
  dryRun: Boolean(options2.dryRun)
45832
46525
  };
45833
46526
  }
46527
+ async getApiKeyStatus(agent, apiKey, options2 = {}) {
46528
+ const adapter = getAgentSettingsAdapter(agent);
46529
+ if (!adapter) {
46530
+ throw new Error(`Unsupported agent settings adapter: ${agent}. Supported: ${this.getSupportedAgents().join(", ")}`);
46531
+ }
46532
+ if (agent !== "claude") {
46533
+ throw new Error(`Agent ${agent} does not support API key trust management.`);
46534
+ }
46535
+ const path = adapter.getSettingsPath("global", resolveProjectPath(options2.projectPath), CLAUDE_API_KEY_RESPONSES_DEFINITION);
46536
+ const config = await readConfigObject(adapter, path);
46537
+ const fingerprint = normalizeApiKeyForConfig(apiKey);
46538
+ const responses = getApiKeyResponses(config);
46539
+ return {
46540
+ agent,
46541
+ path,
46542
+ fingerprint,
46543
+ status: getApiKeyStatusFromResponses(responses, fingerprint),
46544
+ dryRun: false
46545
+ };
46546
+ }
46547
+ async updateApiKeyTrust(agent, action, apiKey, options2 = {}) {
46548
+ const adapter = getAgentSettingsAdapter(agent);
46549
+ if (!adapter) {
46550
+ throw new Error(`Unsupported agent settings adapter: ${agent}. Supported: ${this.getSupportedAgents().join(", ")}`);
46551
+ }
46552
+ if (agent !== "claude") {
46553
+ throw new Error(`Agent ${agent} does not support API key trust management.`);
46554
+ }
46555
+ const path = adapter.getSettingsPath("global", resolveProjectPath(options2.projectPath), CLAUDE_API_KEY_RESPONSES_DEFINITION);
46556
+ const config = await readConfigObject(adapter, path);
46557
+ const fingerprint = normalizeApiKeyForConfig(apiKey);
46558
+ const responses = getApiKeyResponses(config);
46559
+ const previousStatus = getApiKeyStatusFromResponses(responses, fingerprint);
46560
+ let approved = responses.approved.filter((value) => value !== fingerprint);
46561
+ let rejected = responses.rejected.filter((value) => value !== fingerprint);
46562
+ if (action === "approve") {
46563
+ approved = [...approved, fingerprint];
46564
+ } else if (action === "reject") {
46565
+ rejected = [...rejected, fingerprint];
46566
+ }
46567
+ const status = action === "approve" ? "approved" : action === "reject" ? "rejected" : "unknown";
46568
+ setApiKeyResponses(config, approved, rejected);
46569
+ if (!options2.dryRun) {
46570
+ await writeConfigObject(adapter, path, config);
46571
+ }
46572
+ return {
46573
+ agent,
46574
+ path,
46575
+ fingerprint,
46576
+ status,
46577
+ previousStatus,
46578
+ dryRun: Boolean(options2.dryRun)
46579
+ };
46580
+ }
45834
46581
  }
45835
46582
 
45836
46583
  // dist/commands/agent.js
@@ -45917,6 +46664,45 @@ var buildHookRemoveOptions = function(options2) {
45917
46664
  }
45918
46665
  return result;
45919
46666
  };
46667
+ var resolveApiKeyOption = function(options2) {
46668
+ if (options2.env && options2.key) {
46669
+ throw new Error("Choose only one API key source: --env or --key.");
46670
+ }
46671
+ if (options2.env) {
46672
+ const value = process.env[options2.env];
46673
+ if (!value) {
46674
+ throw new Error(`Environment variable ${options2.env} is not set.`);
46675
+ }
46676
+ return value;
46677
+ }
46678
+ if (options2.key) {
46679
+ return options2.key;
46680
+ }
46681
+ throw new Error("API key source is required. Use --env <name> or --key <key>.");
46682
+ };
46683
+ var warnForRawApiKeyOption = function(options2) {
46684
+ if (options2.key && !options2.json) {
46685
+ logger.warning("Using --key can expose the raw API key in shell history and process listings. Prefer --env when possible.");
46686
+ }
46687
+ };
46688
+ var buildApiKeyOptions = function(options2) {
46689
+ return {
46690
+ dryRun: Boolean(options2.dryRun)
46691
+ };
46692
+ };
46693
+ var apiKeyActionVerb = function(action, dryRun) {
46694
+ if (dryRun) {
46695
+ return `Would ${action}`;
46696
+ }
46697
+ switch (action) {
46698
+ case "approve":
46699
+ return "Approved";
46700
+ case "reject":
46701
+ return "Rejected";
46702
+ case "forget":
46703
+ return "Forgot";
46704
+ }
46705
+ };
45920
46706
  function registerAgentCommand(program2) {
45921
46707
  const manager = new AgentSettingsManager;
45922
46708
  const agent = program2.command("agent").description("Manage native agent settings");
@@ -45989,6 +46775,38 @@ function registerAgentCommand(program2) {
45989
46775
  failAgentCommand(error);
45990
46776
  }
45991
46777
  });
46778
+ const apiKey = agent.command("api-key").description("Manage Claude custom API key trust responses");
46779
+ apiKey.command("status <agent>").description("Check whether a custom API key is approved, rejected, or unknown").option("--env <name>", "Read the API key from this environment variable").option("--key <key>", "Use this API key value directly; prefer --env to avoid shell-history exposure").option("--json", "Print JSON output").action(async (agentId, options2) => {
46780
+ try {
46781
+ warnForRawApiKeyOption(options2);
46782
+ const result = await manager.getApiKeyStatus(agentId, resolveApiKeyOption(options2));
46783
+ if (options2.json) {
46784
+ printJson(result);
46785
+ return;
46786
+ }
46787
+ logger.info(`${green(result.agent)} API key fingerprint ${cyan(result.fingerprint)} is ${result.status}.`);
46788
+ logger.info(`Path: ${result.path}`);
46789
+ } catch (error) {
46790
+ failAgentCommand(error);
46791
+ }
46792
+ });
46793
+ for (const action of ["approve", "reject", "forget"]) {
46794
+ apiKey.command(`${action} <agent>`).description(`${action[0].toUpperCase()}${action.slice(1)} a custom API key trust response`).option("--env <name>", "Read the API key from this environment variable").option("--key <key>", "Use this API key value directly; prefer --env to avoid shell-history exposure").option("--json", "Print JSON output").option("--dry-run", "Preview the write without changing files").action(async (agentId, options2) => {
46795
+ try {
46796
+ warnForRawApiKeyOption(options2);
46797
+ const result = await manager.updateApiKeyTrust(agentId, action, resolveApiKeyOption(options2), buildApiKeyOptions(options2));
46798
+ if (options2.json) {
46799
+ printJson(result);
46800
+ return;
46801
+ }
46802
+ logger.success(`${apiKeyActionVerb(action, result.dryRun)} ${green(result.agent)} API key fingerprint ${cyan(result.fingerprint)}.`);
46803
+ logger.info(`Status: ${result.status}`);
46804
+ logger.info(`Path: ${result.path}`);
46805
+ } catch (error) {
46806
+ failAgentCommand(error);
46807
+ }
46808
+ });
46809
+ }
45992
46810
  agent.command("get <agent> [key]").description("Get an agent setting or settings file").option("--global", "Read global user settings").option("--project", "Read shared project settings").option("--local", "Read local project settings").option("--json", "Print JSON output").action(async (agentId, key, options2) => {
45993
46811
  try {
45994
46812
  const value = await manager.get(agentId, key, buildReadOptions(options2));
@@ -46028,13 +46846,13 @@ function registerAgentCommand(program2) {
46028
46846
  return;
46029
46847
  }
46030
46848
  const schema2 = manager.getSchema(agentId);
46031
- const keys = schema2.settings.map((setting2) => setting2.key);
46849
+ const keys = schema2.settings.map((setting4) => setting4.key);
46032
46850
  if (options2.json) {
46033
46851
  printJson(keys);
46034
46852
  return;
46035
46853
  }
46036
46854
  logger.titleBox(`AgentInit ${agentId} Settings`);
46037
- schema2.settings.forEach((setting2, index) => logger.tree(`${cyan(setting2.key)} ${dim(setting2.category)}`, index === schema2.settings.length - 1));
46855
+ schema2.settings.forEach((setting4, index) => logger.tree(`${cyan(setting4.key)} ${dim(setting4.category)}`, index === schema2.settings.length - 1));
46038
46856
  } catch (error) {
46039
46857
  failAgentCommand(error);
46040
46858
  }
@@ -46048,14 +46866,14 @@ function registerAgentCommand(program2) {
46048
46866
  }
46049
46867
  logger.titleBox(`AgentInit ${schema2.displayName} Schema`);
46050
46868
  logger.info(`Default omitted scope: ${cyan(schema2.effectiveDefaultScope)}`);
46051
- for (const setting2 of schema2.settings) {
46869
+ for (const setting4 of schema2.settings) {
46052
46870
  const flags = [
46053
- setting2.valueType,
46054
- setting2.category,
46055
- setting2.risk !== "safe" ? setting2.risk : null,
46056
- setting2.deprecated ? `use ${setting2.replacement}` : null
46871
+ setting4.valueType,
46872
+ setting4.category,
46873
+ setting4.risk !== "safe" ? setting4.risk : null,
46874
+ setting4.deprecated ? `use ${setting4.replacement}` : null
46057
46875
  ].filter(Boolean).join(", ");
46058
- logger.tree(`${cyan(setting2.key)} ${dim(`[${flags}]`)} ${setting2.description}`, false);
46876
+ logger.tree(`${cyan(setting4.key)} ${dim(`[${flags}]`)} ${setting4.description}`, false);
46059
46877
  }
46060
46878
  } catch (error) {
46061
46879
  failAgentCommand(error);