agentinit 1.23.0 → 1.25.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 +17 -0
  2. package/README.md +24 -2
  3. package/dist/agents/CodexCliAgent.js +1 -1
  4. package/dist/agents/CodexCliAgent.js.map +1 -1
  5. package/dist/cli.js +932 -45
  6. package/dist/commands/agent.d.ts.map +1 -1
  7. package/dist/commands/agent.js +113 -8
  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 +4 -1
  24. package/dist/core/agentSettings/settingsManager.d.ts.map +1 -1
  25. package/dist/core/agentSettings/settingsManager.js +277 -27
  26. package/dist/core/agentSettings/settingsManager.js.map +1 -1
  27. package/dist/core/agentSettings/types.d.ts +34 -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,87 @@ 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
+ var summarizeSettingValue = function(value) {
46268
+ if (value === undefined) {
46269
+ return "not set";
46270
+ }
46271
+ if (Array.isArray(value)) {
46272
+ return `set (array, ${value.length} item${value.length === 1 ? "" : "s"})`;
46273
+ }
46274
+ if (value && typeof value === "object") {
46275
+ return "set (object)";
46276
+ }
46277
+ return JSON.stringify(value);
46278
+ };
46279
+ async function writeConfigObject(adapter, path, config) {
46280
+ await writeFile(path, stringifyConfigObject(adapter, config));
46281
+ }
46282
+ var assertHookEventSupported = function(adapter, event) {
46283
+ if (adapter.hookEvents && !adapter.hookEvents.includes(event)) {
46284
+ throw new Error(`Agent ${adapter.agent} does not support ${event} hooks. Supported: ${adapter.hookEvents.join(", ")}.`);
46285
+ }
46286
+ };
46287
+ var resolveHookScope = function(adapter, scope) {
46288
+ const resolvedScope = scope ?? getEffectiveAgentSettingsDefaultScopeSync();
46289
+ const supportedScopes = adapter.hookScopes ?? ["global", "project", "local"];
46290
+ if (!supportedScopes.includes(resolvedScope)) {
46291
+ throw new Error(`Agent ${adapter.agent} hooks do not support ${resolvedScope} scope. Supported scopes: ${supportedScopes.join(", ")}.`);
46292
+ }
46293
+ return resolvedScope;
46294
+ };
45627
46295
  var HOOK_EVENT_ALIASES = {
45628
46296
  "pre-tool-use": "PreToolUse",
45629
46297
  "before-tool-use": "PreToolUse",
@@ -45634,9 +46302,23 @@ var HOOK_EVENT_ALIASES = {
45634
46302
  "permission-request": "PermissionRequest",
45635
46303
  stop: "Stop",
45636
46304
  "session-start": "SessionStart",
45637
- "session-end": "SessionEnd"
46305
+ "session-end": "SessionEnd",
46306
+ "user-prompt-submit": "UserPromptSubmit"
45638
46307
  };
45639
46308
  var HOOK_EVENTS = new Set(Object.values(HOOK_EVENT_ALIASES));
46309
+ var CLAUDE_API_KEY_RESPONSES_DEFINITION = {
46310
+ agent: "claude",
46311
+ key: "customApiKeyResponses",
46312
+ nativePath: ["customApiKeyResponses"],
46313
+ title: "Custom API key responses",
46314
+ description: "Remembered custom API key trust responses.",
46315
+ valueType: "object",
46316
+ scopes: ["global"],
46317
+ defaultScope: "global",
46318
+ category: "auth",
46319
+ risk: "security-sensitive",
46320
+ store: "globalConfig"
46321
+ };
45640
46322
 
45641
46323
  class AgentSettingsManager {
45642
46324
  getSupportedAgents() {
@@ -45654,23 +46336,84 @@ class AgentSettingsManager {
45654
46336
  settings: adapter.definitions.map(toSchemaEntry)
45655
46337
  };
45656
46338
  }
46339
+ async listSettings(agent, options2 = {}) {
46340
+ const adapter = getAgentSettingsAdapter(agent);
46341
+ if (!adapter) {
46342
+ throw new Error(`Unsupported agent settings adapter: ${agent}. Supported: ${this.getSupportedAgents().join(", ")}`);
46343
+ }
46344
+ const scope = resolveFullReadScope(adapter, options2.scope);
46345
+ const projectPath = resolveProjectPath(options2.projectPath);
46346
+ const configByPath = new Map;
46347
+ const readConfigForDefinition = async (definition) => {
46348
+ const path = adapter.getSettingsPath(scope, projectPath, definition);
46349
+ const cached = configByPath.get(path);
46350
+ if (cached) {
46351
+ return cached;
46352
+ }
46353
+ const config = await readConfigObject(adapter, path);
46354
+ configByPath.set(path, config);
46355
+ return config;
46356
+ };
46357
+ const settings = [];
46358
+ for (const definition of adapter.definitions) {
46359
+ const schemaEntry = toSchemaEntry(definition);
46360
+ if (!definition.scopes.includes(scope)) {
46361
+ settings.push({
46362
+ ...schemaEntry,
46363
+ currentStatus: "not-applicable",
46364
+ currentSummary: "n/a"
46365
+ });
46366
+ continue;
46367
+ }
46368
+ const config = await readConfigForDefinition(definition);
46369
+ const value = getNestedValue(config, definition.nativePath);
46370
+ settings.push({
46371
+ ...schemaEntry,
46372
+ currentStatus: value === undefined ? "not-set" : "set",
46373
+ currentSummary: summarizeSettingValue(value)
46374
+ });
46375
+ }
46376
+ return {
46377
+ agent: adapter.agent,
46378
+ displayName: adapter.displayName,
46379
+ scope,
46380
+ settings
46381
+ };
46382
+ }
45657
46383
  async get(agent, key, options2 = {}) {
45658
46384
  const adapter = getAgentSettingsAdapter(agent);
45659
46385
  if (!adapter) {
45660
46386
  throw new Error(`Unsupported agent settings adapter: ${agent}. Supported: ${this.getSupportedAgents().join(", ")}`);
45661
46387
  }
45662
46388
  if (!key) {
45663
- const scope2 = options2.scope ?? getEffectiveAgentSettingsDefaultScopeSync();
46389
+ const scope2 = resolveFullReadScope(adapter, options2.scope);
45664
46390
  const path2 = adapter.getSettingsPath(scope2, resolveProjectPath(options2.projectPath));
45665
- return await readJsonObject(path2);
46391
+ const config2 = await readConfigObject(adapter, path2);
46392
+ if (scope2 !== "global") {
46393
+ return config2;
46394
+ }
46395
+ const globalConfigDefinitions = adapter.definitions.filter((definition2) => definition2.store === "globalConfig" && definition2.scopes.includes("global"));
46396
+ if (globalConfigDefinitions.length === 0) {
46397
+ return config2;
46398
+ }
46399
+ const globalConfigPath = adapter.getSettingsPath("global", resolveProjectPath(options2.projectPath), globalConfigDefinitions[0]);
46400
+ const globalConfig = await readConfigObject(adapter, globalConfigPath);
46401
+ const result = { ...config2 };
46402
+ for (const definition2 of globalConfigDefinitions) {
46403
+ const value = getNestedValue(globalConfig, definition2.nativePath);
46404
+ if (value !== undefined) {
46405
+ setNestedValue(result, definition2.nativePath, value);
46406
+ }
46407
+ }
46408
+ return result;
45666
46409
  }
45667
46410
  const definition = getAgentSettingDefinition(agent, key);
45668
46411
  if (!definition) {
45669
46412
  throw new Error(`Unknown ${agent} setting: ${key}.`);
45670
46413
  }
45671
46414
  const scope = resolveScope(definition, options2.scope);
45672
- const path = adapter.getSettingsPath(scope, resolveProjectPath(options2.projectPath));
45673
- const config = await readJsonObject(path);
46415
+ const path = adapter.getSettingsPath(scope, resolveProjectPath(options2.projectPath), definition);
46416
+ const config = await readConfigObject(adapter, path);
45674
46417
  return getNestedValue(config, definition.nativePath);
45675
46418
  }
45676
46419
  async set(agent, key, rawValue, options2 = {}) {
@@ -45683,13 +46426,13 @@ class AgentSettingsManager {
45683
46426
  throw new Error(`Unknown ${agent} setting: ${key}.`);
45684
46427
  }
45685
46428
  const scope = resolveScope(definition, options2.scope);
45686
- const path = adapter.getSettingsPath(scope, resolveProjectPath(options2.projectPath));
45687
- const config = await readJsonObject(path);
46429
+ const path = adapter.getSettingsPath(scope, resolveProjectPath(options2.projectPath), definition);
46430
+ const config = await readConfigObject(adapter, path);
45688
46431
  const previousValue = getNestedValue(config, definition.nativePath);
45689
46432
  const value = parseAgentSettingValue(definition, rawValue, options2.parseJson);
45690
46433
  setNestedValue(config, definition.nativePath, value);
45691
46434
  if (!options2.dryRun) {
45692
- await writeFile(path, `${JSON.stringify(config, null, 2)}\n`);
46435
+ await writeConfigObject(adapter, path, config);
45693
46436
  }
45694
46437
  return {
45695
46438
  agent,
@@ -45711,12 +46454,12 @@ class AgentSettingsManager {
45711
46454
  throw new Error(`Unknown ${agent} setting: ${key}.`);
45712
46455
  }
45713
46456
  const scope = resolveScope(definition, options2.scope);
45714
- const path = adapter.getSettingsPath(scope, resolveProjectPath(options2.projectPath));
45715
- const config = await readJsonObject(path);
46457
+ const path = adapter.getSettingsPath(scope, resolveProjectPath(options2.projectPath), definition);
46458
+ const config = await readConfigObject(adapter, path);
45716
46459
  const previousValue = getNestedValue(config, definition.nativePath);
45717
46460
  deleteNestedValue(config, definition.nativePath);
45718
46461
  if (!options2.dryRun) {
45719
- await writeFile(path, `${JSON.stringify(config, null, 2)}\n`);
46462
+ await writeConfigObject(adapter, path, config);
45720
46463
  }
45721
46464
  return {
45722
46465
  agent,
@@ -45732,14 +46475,18 @@ class AgentSettingsManager {
45732
46475
  if (!adapter) {
45733
46476
  throw new Error(`Unsupported agent settings adapter: ${agent}. Supported: ${this.getSupportedAgents().join(", ")}`);
45734
46477
  }
45735
- if (agent !== "claude") {
46478
+ if (!adapter.hookEvents) {
45736
46479
  throw new Error(`Agent ${agent} does not support hook management.`);
45737
46480
  }
45738
- const scope = options2.scope ?? getEffectiveAgentSettingsDefaultScopeSync();
46481
+ const hookEvent = event ? normalizeHookEvent(event) : undefined;
46482
+ if (hookEvent) {
46483
+ assertHookEventSupported(adapter, hookEvent);
46484
+ }
46485
+ const scope = resolveHookScope(adapter, options2.scope);
45739
46486
  const path = adapter.getSettingsPath(scope, resolveProjectPath(options2.projectPath));
45740
- const config = await readJsonObject(path);
45741
- if (event) {
45742
- return getHookMatchers(config, normalizeHookEvent(event));
46487
+ const config = await readConfigObject(adapter, path);
46488
+ if (hookEvent) {
46489
+ return getHookMatchers(config, hookEvent);
45743
46490
  }
45744
46491
  const hooks = getNestedValue(config, ["hooks"]);
45745
46492
  if (hooks === undefined) {
@@ -45749,8 +46496,8 @@ class AgentSettingsManager {
45749
46496
  throw new Error("Existing hooks value is not an object.");
45750
46497
  }
45751
46498
  const result = {};
45752
- for (const [hookEvent, value] of Object.entries(hooks)) {
45753
- result[hookEvent] = assertHookMatchers(value);
46499
+ for (const [hookEvent2, value] of Object.entries(hooks)) {
46500
+ result[hookEvent2] = assertHookMatchers(value);
45754
46501
  }
45755
46502
  return result;
45756
46503
  }
@@ -45759,13 +46506,14 @@ class AgentSettingsManager {
45759
46506
  if (!adapter) {
45760
46507
  throw new Error(`Unsupported agent settings adapter: ${agent}. Supported: ${this.getSupportedAgents().join(", ")}`);
45761
46508
  }
45762
- if (agent !== "claude") {
46509
+ if (!adapter.hookEvents) {
45763
46510
  throw new Error(`Agent ${agent} does not support hook management.`);
45764
46511
  }
45765
46512
  const hookEvent = normalizeHookEvent(event);
45766
- const scope = options2.scope ?? getEffectiveAgentSettingsDefaultScopeSync();
46513
+ assertHookEventSupported(adapter, hookEvent);
46514
+ const scope = resolveHookScope(adapter, options2.scope);
45767
46515
  const path = adapter.getSettingsPath(scope, resolveProjectPath(options2.projectPath));
45768
- const config = await readJsonObject(path);
46516
+ const config = await readConfigObject(adapter, path);
45769
46517
  const hook = buildHookCommand(command, options2.name);
45770
46518
  const matchers = getHookMatchers(config, hookEvent);
45771
46519
  const matcher = options2.matcher ?? "*";
@@ -45780,7 +46528,7 @@ class AgentSettingsManager {
45780
46528
  }
45781
46529
  setHookMatchers(config, hookEvent, matchers);
45782
46530
  if (!options2.dryRun) {
45783
- await writeFile(path, `${JSON.stringify(config, null, 2)}\n`);
46531
+ await writeConfigObject(adapter, path, config);
45784
46532
  }
45785
46533
  return {
45786
46534
  agent,
@@ -45796,13 +46544,14 @@ class AgentSettingsManager {
45796
46544
  if (!adapter) {
45797
46545
  throw new Error(`Unsupported agent settings adapter: ${agent}. Supported: ${this.getSupportedAgents().join(", ")}`);
45798
46546
  }
45799
- if (agent !== "claude") {
46547
+ if (!adapter.hookEvents) {
45800
46548
  throw new Error(`Agent ${agent} does not support hook management.`);
45801
46549
  }
45802
46550
  const hookEvent = normalizeHookEvent(event);
45803
- const scope = options2.scope ?? getEffectiveAgentSettingsDefaultScopeSync();
46551
+ assertHookEventSupported(adapter, hookEvent);
46552
+ const scope = resolveHookScope(adapter, options2.scope);
45804
46553
  const path = adapter.getSettingsPath(scope, resolveProjectPath(options2.projectPath));
45805
- const config = await readJsonObject(path);
46554
+ const config = await readConfigObject(adapter, path);
45806
46555
  const matchers = getHookMatchers(config, hookEvent);
45807
46556
  let removed = 0;
45808
46557
  const nextMatchers = matchers.map((entry) => {
@@ -45820,7 +46569,7 @@ class AgentSettingsManager {
45820
46569
  }).filter((entry) => entry.hooks.length > 0);
45821
46570
  setHookMatchers(config, hookEvent, nextMatchers);
45822
46571
  if (!options2.dryRun) {
45823
- await writeFile(path, `${JSON.stringify(config, null, 2)}\n`);
46572
+ await writeConfigObject(adapter, path, config);
45824
46573
  }
45825
46574
  return {
45826
46575
  agent,
@@ -45831,6 +46580,60 @@ class AgentSettingsManager {
45831
46580
  dryRun: Boolean(options2.dryRun)
45832
46581
  };
45833
46582
  }
46583
+ async getApiKeyStatus(agent, apiKey, options2 = {}) {
46584
+ const adapter = getAgentSettingsAdapter(agent);
46585
+ if (!adapter) {
46586
+ throw new Error(`Unsupported agent settings adapter: ${agent}. Supported: ${this.getSupportedAgents().join(", ")}`);
46587
+ }
46588
+ if (agent !== "claude") {
46589
+ throw new Error(`Agent ${agent} does not support API key trust management.`);
46590
+ }
46591
+ const path = adapter.getSettingsPath("global", resolveProjectPath(options2.projectPath), CLAUDE_API_KEY_RESPONSES_DEFINITION);
46592
+ const config = await readConfigObject(adapter, path);
46593
+ const fingerprint = normalizeApiKeyForConfig(apiKey);
46594
+ const responses = getApiKeyResponses(config);
46595
+ return {
46596
+ agent,
46597
+ path,
46598
+ fingerprint,
46599
+ status: getApiKeyStatusFromResponses(responses, fingerprint),
46600
+ dryRun: false
46601
+ };
46602
+ }
46603
+ async updateApiKeyTrust(agent, action, apiKey, options2 = {}) {
46604
+ const adapter = getAgentSettingsAdapter(agent);
46605
+ if (!adapter) {
46606
+ throw new Error(`Unsupported agent settings adapter: ${agent}. Supported: ${this.getSupportedAgents().join(", ")}`);
46607
+ }
46608
+ if (agent !== "claude") {
46609
+ throw new Error(`Agent ${agent} does not support API key trust management.`);
46610
+ }
46611
+ const path = adapter.getSettingsPath("global", resolveProjectPath(options2.projectPath), CLAUDE_API_KEY_RESPONSES_DEFINITION);
46612
+ const config = await readConfigObject(adapter, path);
46613
+ const fingerprint = normalizeApiKeyForConfig(apiKey);
46614
+ const responses = getApiKeyResponses(config);
46615
+ const previousStatus = getApiKeyStatusFromResponses(responses, fingerprint);
46616
+ let approved = responses.approved.filter((value) => value !== fingerprint);
46617
+ let rejected = responses.rejected.filter((value) => value !== fingerprint);
46618
+ if (action === "approve") {
46619
+ approved = [...approved, fingerprint];
46620
+ } else if (action === "reject") {
46621
+ rejected = [...rejected, fingerprint];
46622
+ }
46623
+ const status = action === "approve" ? "approved" : action === "reject" ? "rejected" : "unknown";
46624
+ setApiKeyResponses(config, approved, rejected);
46625
+ if (!options2.dryRun) {
46626
+ await writeConfigObject(adapter, path, config);
46627
+ }
46628
+ return {
46629
+ agent,
46630
+ path,
46631
+ fingerprint,
46632
+ status,
46633
+ previousStatus,
46634
+ dryRun: Boolean(options2.dryRun)
46635
+ };
46636
+ }
45834
46637
  }
45835
46638
 
45836
46639
  // dist/commands/agent.js
@@ -45864,6 +46667,14 @@ var printValue = function(value) {
45864
46667
  }
45865
46668
  printJson(value);
45866
46669
  };
46670
+ var buildSettingFlags = function(setting4) {
46671
+ return [
46672
+ setting4.valueType,
46673
+ setting4.category,
46674
+ setting4.risk !== "safe" ? setting4.risk : null,
46675
+ setting4.deprecated ? `use ${setting4.replacement}` : null
46676
+ ].filter(Boolean).join(", ");
46677
+ };
45867
46678
  var buildSetOptions = function(options2) {
45868
46679
  const result = {};
45869
46680
  const scope = resolveScopeOption(options2);
@@ -45917,6 +46728,45 @@ var buildHookRemoveOptions = function(options2) {
45917
46728
  }
45918
46729
  return result;
45919
46730
  };
46731
+ var resolveApiKeyOption = function(options2) {
46732
+ if (options2.env && options2.key) {
46733
+ throw new Error("Choose only one API key source: --env or --key.");
46734
+ }
46735
+ if (options2.env) {
46736
+ const value = process.env[options2.env];
46737
+ if (!value) {
46738
+ throw new Error(`Environment variable ${options2.env} is not set.`);
46739
+ }
46740
+ return value;
46741
+ }
46742
+ if (options2.key) {
46743
+ return options2.key;
46744
+ }
46745
+ throw new Error("API key source is required. Use --env <name> or --key <key>.");
46746
+ };
46747
+ var warnForRawApiKeyOption = function(options2) {
46748
+ if (options2.key && !options2.json) {
46749
+ logger.warning("Using --key can expose the raw API key in shell history and process listings. Prefer --env when possible.");
46750
+ }
46751
+ };
46752
+ var buildApiKeyOptions = function(options2) {
46753
+ return {
46754
+ dryRun: Boolean(options2.dryRun)
46755
+ };
46756
+ };
46757
+ var apiKeyActionVerb = function(action, dryRun) {
46758
+ if (dryRun) {
46759
+ return `Would ${action}`;
46760
+ }
46761
+ switch (action) {
46762
+ case "approve":
46763
+ return "Approved";
46764
+ case "reject":
46765
+ return "Rejected";
46766
+ case "forget":
46767
+ return "Forgot";
46768
+ }
46769
+ };
45920
46770
  function registerAgentCommand(program2) {
45921
46771
  const manager = new AgentSettingsManager;
45922
46772
  const agent = program2.command("agent").description("Manage native agent settings");
@@ -45989,6 +46839,38 @@ function registerAgentCommand(program2) {
45989
46839
  failAgentCommand(error);
45990
46840
  }
45991
46841
  });
46842
+ const apiKey = agent.command("api-key").description("Manage Claude custom API key trust responses");
46843
+ 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) => {
46844
+ try {
46845
+ warnForRawApiKeyOption(options2);
46846
+ const result = await manager.getApiKeyStatus(agentId, resolveApiKeyOption(options2));
46847
+ if (options2.json) {
46848
+ printJson(result);
46849
+ return;
46850
+ }
46851
+ logger.info(`${green(result.agent)} API key fingerprint ${cyan(result.fingerprint)} is ${result.status}.`);
46852
+ logger.info(`Path: ${result.path}`);
46853
+ } catch (error) {
46854
+ failAgentCommand(error);
46855
+ }
46856
+ });
46857
+ for (const action of ["approve", "reject", "forget"]) {
46858
+ 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) => {
46859
+ try {
46860
+ warnForRawApiKeyOption(options2);
46861
+ const result = await manager.updateApiKeyTrust(agentId, action, resolveApiKeyOption(options2), buildApiKeyOptions(options2));
46862
+ if (options2.json) {
46863
+ printJson(result);
46864
+ return;
46865
+ }
46866
+ logger.success(`${apiKeyActionVerb(action, result.dryRun)} ${green(result.agent)} API key fingerprint ${cyan(result.fingerprint)}.`);
46867
+ logger.info(`Status: ${result.status}`);
46868
+ logger.info(`Path: ${result.path}`);
46869
+ } catch (error) {
46870
+ failAgentCommand(error);
46871
+ }
46872
+ });
46873
+ }
45992
46874
  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
46875
  try {
45994
46876
  const value = await manager.get(agentId, key, buildReadOptions(options2));
@@ -46015,7 +46897,7 @@ function registerAgentCommand(program2) {
46015
46897
  failAgentCommand(error);
46016
46898
  }
46017
46899
  });
46018
- agent.command("list [agent]").description("List supported agents or setting keys for one agent").option("--json", "Print JSON output").action((agentId, options2) => {
46900
+ agent.command("list [agent]").description("List supported agents or setting keys for one agent").option("--global", "Read global user settings").option("--project", "Read shared project settings").option("--local", "Read local project settings").option("--json", "Print JSON output").option("--details", "Print detailed setting metadata with safe current-value summaries").action(async (agentId, options2) => {
46019
46901
  try {
46020
46902
  if (!agentId) {
46021
46903
  const agents = manager.getSupportedAgents();
@@ -46028,13 +46910,23 @@ function registerAgentCommand(program2) {
46028
46910
  return;
46029
46911
  }
46030
46912
  const schema2 = manager.getSchema(agentId);
46031
- const keys = schema2.settings.map((setting2) => setting2.key);
46913
+ const keys = schema2.settings.map((setting4) => setting4.key);
46032
46914
  if (options2.json) {
46915
+ if (options2.details) {
46916
+ const list2 = await manager.listSettings(agentId, buildReadOptions(options2));
46917
+ printJson(list2.settings);
46918
+ return;
46919
+ }
46033
46920
  printJson(keys);
46034
46921
  return;
46035
46922
  }
46923
+ const list = await manager.listSettings(agentId, buildReadOptions(options2));
46036
46924
  logger.titleBox(`AgentInit ${agentId} Settings`);
46037
- schema2.settings.forEach((setting2, index) => logger.tree(`${cyan(setting2.key)} ${dim(setting2.category)}`, index === schema2.settings.length - 1));
46925
+ logger.info(`Scope: ${cyan(list.scope)}`);
46926
+ list.settings.forEach((setting4, index) => {
46927
+ const flags = buildSettingFlags(setting4);
46928
+ logger.tree(`${cyan(setting4.key)} ${dim(`[${flags}]`)} ${setting4.description} ${dim(`current: ${setting4.currentSummary}`)}`, index === list.settings.length - 1);
46929
+ });
46038
46930
  } catch (error) {
46039
46931
  failAgentCommand(error);
46040
46932
  }
@@ -46048,14 +46940,9 @@ function registerAgentCommand(program2) {
46048
46940
  }
46049
46941
  logger.titleBox(`AgentInit ${schema2.displayName} Schema`);
46050
46942
  logger.info(`Default omitted scope: ${cyan(schema2.effectiveDefaultScope)}`);
46051
- for (const setting2 of schema2.settings) {
46052
- const flags = [
46053
- setting2.valueType,
46054
- setting2.category,
46055
- setting2.risk !== "safe" ? setting2.risk : null,
46056
- setting2.deprecated ? `use ${setting2.replacement}` : null
46057
- ].filter(Boolean).join(", ");
46058
- logger.tree(`${cyan(setting2.key)} ${dim(`[${flags}]`)} ${setting2.description}`, false);
46943
+ for (const setting4 of schema2.settings) {
46944
+ const flags = buildSettingFlags(setting4);
46945
+ logger.tree(`${cyan(setting4.key)} ${dim(`[${flags}]`)} ${setting4.description}`, false);
46059
46946
  }
46060
46947
  } catch (error) {
46061
46948
  failAgentCommand(error);