@pushary/agent-hooks 1.9.43 → 1.9.44

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 (106) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +1 -0
  3. package/dist/bin/pushary-bell-hook.js +27 -26
  4. package/dist/bin/pushary-bell.js +11 -11
  5. package/dist/bin/pushary-claude.js +30 -28
  6. package/dist/bin/pushary-clean.js +39 -38
  7. package/dist/bin/pushary-codex-bridge.js +38 -28
  8. package/dist/bin/pushary-codex-hook.js +35 -33
  9. package/dist/bin/pushary-codex-session.d.ts +1 -0
  10. package/dist/bin/pushary-codex-session.js +253 -0
  11. package/dist/bin/pushary-codex.js +13 -12
  12. package/dist/bin/pushary-connect.js +28 -27
  13. package/dist/bin/pushary-cowork.js +6 -6
  14. package/dist/bin/pushary-daemon.js +48 -47
  15. package/dist/bin/pushary-disconnect.js +27 -26
  16. package/dist/bin/pushary-doctor.js +85 -82
  17. package/dist/bin/pushary-elicitation-hook.js +27 -26
  18. package/dist/bin/pushary-gemini-bridge.js +22 -22
  19. package/dist/bin/pushary-gemini-hook.js +32 -30
  20. package/dist/bin/pushary-hook.js +33 -32
  21. package/dist/bin/pushary-login.js +16 -16
  22. package/dist/bin/pushary-logout.js +28 -27
  23. package/dist/bin/pushary-mcp.js +9 -9
  24. package/dist/bin/pushary-mode.js +14 -14
  25. package/dist/bin/pushary-notification-hook.js +26 -25
  26. package/dist/bin/pushary-opencode-hook.js +31 -29
  27. package/dist/bin/pushary-permission-denied-hook.js +31 -30
  28. package/dist/bin/pushary-permission-hook.js +30 -29
  29. package/dist/bin/pushary-post-hook.js +26 -25
  30. package/dist/bin/pushary-prompt-hook.js +26 -25
  31. package/dist/bin/pushary-session-end-hook.js +26 -25
  32. package/dist/bin/pushary-session-start-hook.js +31 -30
  33. package/dist/bin/pushary-setup.js +165 -112
  34. package/dist/bin/pushary-stats.js +5 -5
  35. package/dist/bin/pushary-status.js +35 -34
  36. package/dist/bin/pushary-stop-hook.js +26 -25
  37. package/dist/bin/pushary-stopfailure-hook.js +26 -25
  38. package/dist/bin/pushary-suggestions.js +14 -14
  39. package/dist/bin/pushary-transcript-register.js +18 -18
  40. package/dist/bin/pushary-transcripts.js +7 -7
  41. package/dist/bin/pushary-upgrade.js +41 -40
  42. package/dist/bin/pushary-wait.js +14 -14
  43. package/dist/bin/pushary.js +7 -6
  44. package/dist/{chunk-ZJXEQV3A.js → chunk-2NVXFWQY.js} +1 -1
  45. package/dist/{chunk-H64CU2VB.js → chunk-3IRC3XFG.js} +2 -2
  46. package/dist/{chunk-JB4JCGRW.js → chunk-42CVAOC5.js} +2 -2
  47. package/dist/{chunk-S3OWTQ6Z.js → chunk-4JHEZ2PV.js} +12 -5
  48. package/dist/{chunk-LE2YVPAT.js → chunk-4WBAHVBK.js} +11 -11
  49. package/dist/{chunk-53KLSE2F.js → chunk-53UZN7JW.js} +3 -3
  50. package/dist/{chunk-4T2TGP4T.js → chunk-5ZSBQHCM.js} +12 -173
  51. package/dist/{chunk-Q7CUTGT4.js → chunk-6EV3B5CD.js} +1 -1
  52. package/dist/{chunk-MSUMSXTI.js → chunk-75M7NFFC.js} +1 -1
  53. package/dist/{chunk-VIVLJK3T.js → chunk-7UM4NCUI.js} +2 -2
  54. package/dist/{chunk-F5ALKPNS.js → chunk-ALY7ZBNB.js} +1 -1
  55. package/dist/{chunk-YRE6GUFZ.js → chunk-BKK3JCTD.js} +80 -164
  56. package/dist/{chunk-O7ADPLBF.js → chunk-CAJCCQ7N.js} +1 -1
  57. package/dist/{chunk-AVT7GPOF.js → chunk-CESLE4UN.js} +10 -10
  58. package/dist/{chunk-Y4VZYKSW.js → chunk-CEZTYTBN.js} +13 -11
  59. package/dist/{chunk-CIERFMQT.js → chunk-DD6IBKEJ.js} +4 -4
  60. package/dist/{chunk-TH74SUVV.js → chunk-E76QCZIA.js} +2 -2
  61. package/dist/{chunk-ENGASUEL.js → chunk-FI2F5KZJ.js} +4 -4
  62. package/dist/{chunk-V5SUKRRI.js → chunk-FKDZU6YX.js} +4 -4
  63. package/dist/{chunk-EA5NWDK7.js → chunk-FYNMFSIZ.js} +29 -0
  64. package/dist/{chunk-JJWG7CBT.js → chunk-GBCR2FH2.js} +3 -3
  65. package/dist/chunk-GOEIW2VH.js +266 -0
  66. package/dist/{chunk-Y3N3SYBX.js → chunk-GRAPJKDK.js} +1 -1
  67. package/dist/{chunk-ZORCUL3Z.js → chunk-HV4TEKNP.js} +4 -4
  68. package/dist/{chunk-A64UCGX3.js → chunk-IWHDNMM3.js} +5 -5
  69. package/dist/{chunk-RXXKFM22.js → chunk-JNU3LV47.js} +355 -138
  70. package/dist/{chunk-C6QBNBL4.js → chunk-KILK6SWZ.js} +7 -7
  71. package/dist/{chunk-SATOTPXW.js → chunk-KYLY6UMN.js} +1 -1
  72. package/dist/{chunk-NV2LARV4.js → chunk-L2ZM7LXN.js} +2 -2
  73. package/dist/{chunk-F7SZ2RCK.js → chunk-LEHBWBCG.js} +4 -4
  74. package/dist/{chunk-LAAOHBLO.js → chunk-M2L7625S.js} +2 -2
  75. package/dist/{chunk-HC4DQXAT.js → chunk-MIBCRQWK.js} +2 -2
  76. package/dist/{chunk-J6MVBWF2.js → chunk-MRQJCIFO.js} +1 -1
  77. package/dist/{chunk-XLHFWG2E.js → chunk-OR6KJOHE.js} +2 -2
  78. package/dist/{chunk-55FB6OSG.js → chunk-OSMNLNPF.js} +1 -1
  79. package/dist/{chunk-GTOBOC6M.js → chunk-OWQOMGBF.js} +1 -1
  80. package/dist/{chunk-S4QT3YFG.js → chunk-OZ7MLVDM.js} +15 -15
  81. package/dist/{chunk-LWW7SBK3.js → chunk-PGHN5D4N.js} +2 -2
  82. package/dist/{chunk-IDVKJICN.js → chunk-PQAFH4DF.js} +3 -11
  83. package/dist/{chunk-VGPEXMYM.js → chunk-RGBTKOCC.js} +42 -7
  84. package/dist/{chunk-H6V5S52A.js → chunk-S2ALW446.js} +3 -3
  85. package/dist/{chunk-IMD5FN6Y.js → chunk-SI2NC6UU.js} +3 -3
  86. package/dist/chunk-SVCT5D7K.js +196 -0
  87. package/dist/{chunk-JW4S4O4W.js → chunk-SWDPCDLT.js} +4 -4
  88. package/dist/{chunk-LDCRV6HG.js → chunk-T3KMJI4W.js} +2 -1
  89. package/dist/{chunk-PIZ65U3D.js → chunk-T4CKP47U.js} +5 -5
  90. package/dist/{chunk-C3RVRTHS.js → chunk-TJZUQRMH.js} +3 -3
  91. package/dist/{chunk-C54VJJ37.js → chunk-TKTS3SIM.js} +3 -3
  92. package/dist/{chunk-LOUZNXTJ.js → chunk-TWATOPHK.js} +2 -2
  93. package/dist/{chunk-FPJHS6PA.js → chunk-UC4PNLMK.js} +6 -6
  94. package/dist/{chunk-JE6GG3OV.js → chunk-UJXLVH66.js} +1 -1
  95. package/dist/{chunk-45W43U2Q.js → chunk-UY5E2UUW.js} +5 -5
  96. package/dist/{chunk-O4SYJVAF.js → chunk-UZVF6MP2.js} +5 -5
  97. package/dist/{chunk-SCYAXV7U.js → chunk-W2TA4EVZ.js} +5 -5
  98. package/dist/{chunk-VQL62ECJ.js → chunk-WBD7HZEZ.js} +1 -1
  99. package/dist/{chunk-W3BO56VE.js → chunk-WMO2XVG4.js} +1 -1
  100. package/dist/{chunk-NKBAEGT7.js → chunk-XPQDBTW4.js} +1 -1
  101. package/dist/{global-upgrade-FFWOHOJ4.js → global-upgrade-QSSDYZCZ.js} +6 -6
  102. package/dist/{paths-Y2WPCM5Y.js → paths-55DDFLY4.js} +2 -2
  103. package/dist/{reapply-N3MV3CKD.js → reapply-MEU66ALO.js} +23 -22
  104. package/dist/src/index.js +20 -19
  105. package/dist/{upgrade-lock-ZXXNRH2P.js → upgrade-lock-YLXAU4AD.js} +3 -3
  106. package/package.json +5 -2
@@ -388,9 +388,9 @@ var CANONICAL_COMMAND_KEYS = ["command"];
388
388
  var SHELL_TOOLS = /* @__PURE__ */ new Set([SHELL_TOOL, POWERSHELL_TOOL]);
389
389
  var PATH_TOOLS = /* @__PURE__ */ new Set(["Write", "Edit", "MultiEdit", "NotebookEdit", "Read"]);
390
390
  var PHONE_ANSWERED_TOOLS = /* @__PURE__ */ new Set(["AskUserQuestion", "ExitPlanMode"]);
391
- var firstString = (record2, keys) => {
392
- for (const key of keys) {
393
- const value = record2[key];
391
+ var firstString = (record3, keys2) => {
392
+ for (const key of keys2) {
393
+ const value = record3[key];
394
394
  if (typeof value === "string" && value.length > 0) return value;
395
395
  }
396
396
  return void 0;
@@ -406,12 +406,12 @@ var BLANK_TASK_INPUT_TOOL = "TaskInput";
406
406
  var typesText = (value) => typeof value === "string" && value.trim().length > 0;
407
407
  var taskIdOf = (control, toolInput) => typeof toolInput[control.taskKey] === "string" ? { task_id: toolInput[control.taskKey] } : {};
408
408
  var typedIntoTask = (control, toolInput) => {
409
- const text = toolInput[control.inputKey];
410
- if (typesText(text)) return { tool: SHELL_TOOL, input: { command: text }, unreadable: false };
411
- if (text !== void 0 && typeof text !== "string") return { tool: control.name, input: toolInput, unreadable: true };
409
+ const text2 = toolInput[control.inputKey];
410
+ if (typesText(text2)) return { tool: SHELL_TOOL, input: { command: text2 }, unreadable: false };
411
+ if (text2 !== void 0 && typeof text2 !== "string") return { tool: control.name, input: toolInput, unreadable: true };
412
412
  return {
413
413
  tool: BLANK_TASK_INPUT_TOOL,
414
- input: { ...taskIdOf(control, toolInput), input: text ?? "" },
414
+ input: { ...taskIdOf(control, toolInput), input: text2 ?? "" },
415
415
  unreadable: false
416
416
  };
417
417
  };
@@ -838,10 +838,10 @@ var secretRedactionRules = (shapes) => [
838
838
  var SECRET_REDACTION_RULES = secretRedactionRules(DISPLAYED_SECRET_SHAPES);
839
839
  var CUT_OFF_TEXT_REDACTION_RULES = secretRedactionRules(CUT_OFF_SECRET_SHAPES);
840
840
  var HIGH_ENTROPY_RULE = { pattern: /[A-Za-z0-9+/]{40,}={0,2}/g, replacement: "[redacted]" };
841
- var applyRedactionRules = (rules, text) => rules.reduce((acc, rule) => acc.replace(rule.pattern, rule.replacement), text);
842
- var redactSecrets = (text) => applyRedactionRules(SECRET_REDACTION_RULES, text);
843
- var redactSecretsFromContent = (text) => applyRedactionRules(CUT_OFF_TEXT_REDACTION_RULES, text);
844
- var redactSecretsDeep = (text) => redactSecrets(text).replace(HIGH_ENTROPY_RULE.pattern, HIGH_ENTROPY_RULE.replacement);
841
+ var applyRedactionRules = (rules, text2) => rules.reduce((acc, rule) => acc.replace(rule.pattern, rule.replacement), text2);
842
+ var redactSecrets = (text2) => applyRedactionRules(SECRET_REDACTION_RULES, text2);
843
+ var redactSecretsFromContent = (text2) => applyRedactionRules(CUT_OFF_TEXT_REDACTION_RULES, text2);
844
+ var redactSecretsDeep = (text2) => redactSecrets(text2).replace(HIGH_ENTROPY_RULE.pattern, HIGH_ENTROPY_RULE.replacement);
845
845
 
846
846
  // ../contracts/src/shell-analysis.ts
847
847
  var SHELL_WORD_SEPARATOR = /[ \t\n]/;
@@ -880,16 +880,16 @@ var splitShellSegments = (command) => {
880
880
  let consumed = -1;
881
881
  let readsPipe = false;
882
882
  for (const lexeme of lexemes) {
883
- const { index, text, quote, kind } = lexeme;
883
+ const { index, text: text2, quote, kind } = lexeme;
884
884
  if (index <= consumed || kind !== "text" || quote === "'") continue;
885
- if (text === "`" || text === "$" && command[index + 1] === "(") return null;
885
+ if (text2 === "`" || text2 === "$" && command[index + 1] === "(") return null;
886
886
  if (quote !== null) continue;
887
- if (UNDECOMPOSABLE.has(text)) return null;
888
- if (!SEGMENT_SEPARATORS.has(text)) continue;
889
- const doubled = DOUBLED_SEPARATORS.has(text) && command[index + 1] === text;
887
+ if (UNDECOMPOSABLE.has(text2)) return null;
888
+ if (!SEGMENT_SEPARATORS.has(text2)) continue;
889
+ const doubled = DOUBLED_SEPARATORS.has(text2) && command[index + 1] === text2;
890
890
  consumed = index + (doubled ? 1 : 0);
891
891
  segments.push({ text: trimShellWhitespace(command.slice(start, index)), readsPipe });
892
- readsPipe = text === PIPE && !doubled;
892
+ readsPipe = text2 === PIPE && !doubled;
893
893
  start = consumed + 1;
894
894
  }
895
895
  segments.push({ text: trimShellWhitespace(command.slice(start)), readsPipe });
@@ -987,10 +987,10 @@ var shellVisibleText = (command) => {
987
987
  const lexemes = scanShell(command);
988
988
  if (lexemes === null) return null;
989
989
  let visible = "";
990
- for (const { text, quote, kind } of lexemes) {
990
+ for (const { text: text2, quote, kind } of lexemes) {
991
991
  if (kind === "escape" && quote === '"') return null;
992
- const literal = kind === "text" && (quote === "'" || quote === '"' && LITERAL_IN_DOUBLE_QUOTES.has(text));
993
- visible += literal ? "_".repeat(text.length) : text;
992
+ const literal = kind === "text" && (quote === "'" || quote === '"' && LITERAL_IN_DOUBLE_QUOTES.has(text2));
993
+ visible += literal ? "_".repeat(text2.length) : text2;
994
994
  }
995
995
  return visible;
996
996
  };
@@ -1006,14 +1006,14 @@ var shellWordsOf = (command) => {
1006
1006
  const lexemes = scanShell(command);
1007
1007
  if (lexemes === null) return null;
1008
1008
  const words = [];
1009
- let text = "";
1009
+ let text2 = "";
1010
1010
  let plain = true;
1011
1011
  let expands = false;
1012
1012
  let comment = false;
1013
1013
  let started = false;
1014
1014
  const finishWord = () => {
1015
- if (started) words.push({ text, plain, expands, comment });
1016
- text = "";
1015
+ if (started) words.push({ text: text2, plain, expands, comment });
1016
+ text2 = "";
1017
1017
  plain = true;
1018
1018
  expands = false;
1019
1019
  comment = false;
@@ -1026,7 +1026,7 @@ var shellWordsOf = (command) => {
1026
1026
  continue;
1027
1027
  }
1028
1028
  if (lexeme.kind === "escape") {
1029
- text += lexeme.text.slice(1);
1029
+ text2 += lexeme.text.slice(1);
1030
1030
  plain = false;
1031
1031
  started = true;
1032
1032
  continue;
@@ -1037,7 +1037,7 @@ var shellWordsOf = (command) => {
1037
1037
  }
1038
1038
  comment ||= lexeme.quote === null && !started && lexeme.text === "#";
1039
1039
  expands ||= lexeme.quote !== "'" && lexeme.text === "$";
1040
- text += lexeme.text;
1040
+ text2 += lexeme.text;
1041
1041
  started = true;
1042
1042
  }
1043
1043
  finishWord();
@@ -1094,40 +1094,40 @@ var opensAHereString = (source, index) => {
1094
1094
  return source.charAt(index) === HERE_STRING_SIGIL && (SINGLE_QUOTES.has(quote) || DOUBLE_QUOTES.has(quote)) && HERE_STRING_HEADER_REST.test(source.slice(index + 2));
1095
1095
  };
1096
1096
  var singleQuotedTextAt = (source, open) => {
1097
- let text = "";
1097
+ let text2 = "";
1098
1098
  for (let index = open + 1; index < source.length; index += 1) {
1099
1099
  const char = source.charAt(index);
1100
1100
  if (!SINGLE_QUOTES.has(char)) {
1101
- text += char;
1101
+ text2 += char;
1102
1102
  } else if (SINGLE_QUOTES.has(source.charAt(index + 1))) {
1103
- text += char;
1103
+ text2 += char;
1104
1104
  index += 1;
1105
1105
  } else {
1106
- return { end: index + 1, text, expands: false, nested: [] };
1106
+ return { end: index + 1, text: text2, expands: false, nested: [] };
1107
1107
  }
1108
1108
  }
1109
1109
  return null;
1110
1110
  };
1111
1111
  var expandableTextUntil = (source, start, closesAt, nesting) => {
1112
- let text = "";
1112
+ let text2 = "";
1113
1113
  let expands = false;
1114
1114
  const nested = [];
1115
1115
  for (let index = start; index < source.length; index += 1) {
1116
1116
  const char = source.charAt(index);
1117
- if (closesAt(index)) return { end: index + 1, text, expands, nested };
1117
+ if (closesAt(index)) return { end: index + 1, text: text2, expands, nested };
1118
1118
  if (char === ESCAPE || DOUBLE_QUOTES.has(char) && DOUBLE_QUOTES.has(source.charAt(index + 1))) {
1119
- text += source.charAt(index + 1);
1119
+ text2 += source.charAt(index + 1);
1120
1120
  index += 1;
1121
1121
  } else if (source.startsWith(SUBEXPRESSION_OPEN, index)) {
1122
1122
  const group = groupAt(source, index + SUBEXPRESSION_OPEN.length, ")", nesting + 1);
1123
1123
  if (group === null) return null;
1124
1124
  nested.push(group.inner);
1125
- text += SUBEXPRESSION_PLACEHOLDER;
1125
+ text2 += SUBEXPRESSION_PLACEHOLDER;
1126
1126
  expands = true;
1127
1127
  index = group.end - 1;
1128
1128
  } else {
1129
1129
  expands ||= opensAVariable(source, index);
1130
- text += char;
1130
+ text2 += char;
1131
1131
  }
1132
1132
  }
1133
1133
  return null;
@@ -1626,12 +1626,12 @@ var parameterValueOf = (command, fullName, shortestPrefix) => {
1626
1626
  };
1627
1627
  var operandTextsOf = (command) => command.args.flatMap((arg) => {
1628
1628
  const parameter = parameterOf(arg);
1629
- const text = parameter === null ? arg.text : parameter.value;
1630
- return text === void 0 ? [] : text.split(POWERSHELL_ARRAY_SEPARATOR);
1629
+ const text2 = parameter === null ? arg.text : parameter.value;
1630
+ return text2 === void 0 ? [] : text2.split(POWERSHELL_ARRAY_SEPARATOR);
1631
1631
  });
1632
1632
  var positionalTextsOf = (command) => command.args.filter((arg) => parameterOf(arg) === null).map((arg) => arg.text);
1633
1633
  var firstOperandOf = (command, isSwitch) => command.args.find((arg) => !isSwitch.test(arg.text))?.text;
1634
- var namesASecretPath = (text, judge) => judge.namesASecretFile(fileNameOf(text.trim()));
1634
+ var namesASecretPath = (text2, judge) => judge.namesASecretFile(fileNameOf(text2.trim()));
1635
1635
  var isAssignmentTarget = (word) => POWERSHELL_ASSIGNMENT_TARGET.test(word.text) || word.text === POWERSHELL_ARRAY_SEPARATOR;
1636
1636
  var wordsAfterAnAssignment = (words) => {
1637
1637
  const operator = words.findIndex((word) => isPowerShellAssignmentOperator(word));
@@ -1690,7 +1690,7 @@ var copyDestinationOf = (command) => {
1690
1690
  };
1691
1691
  var writesASecretFileFromPowerShell = (command, judge) => {
1692
1692
  if (command.cmdlet !== COPY_ITEM) {
1693
- return POWERSHELL_FILE_WRITERS.has(command.cmdlet) && operandTextsOf(command).some((text) => namesASecretPath(text, judge));
1693
+ return POWERSHELL_FILE_WRITERS.has(command.cmdlet) && operandTextsOf(command).some((text2) => namesASecretPath(text2, judge));
1694
1694
  }
1695
1695
  const destination = copyDestinationOf(command);
1696
1696
  return destination !== void 0 && namesASecretPath(destination, judge);
@@ -1698,7 +1698,7 @@ var writesASecretFileFromPowerShell = (command, judge) => {
1698
1698
  var formatsADisk = (command) => DISK_ERASERS.has(command.cmdlet);
1699
1699
  var changesAWindowsService = (command) => {
1700
1700
  if (WINDOWS_SERVICE_CHANGERS.has(command.cmdlet)) return true;
1701
- const [verb, ...operands] = command.args.map((arg) => arg.text.toLowerCase()).filter((text) => !text.startsWith(REMOTE_MACHINE_PREFIX));
1701
+ const [verb, ...operands] = command.args.map((arg) => arg.text.toLowerCase()).filter((text2) => !text2.startsWith(REMOTE_MACHINE_PREFIX));
1702
1702
  if (command.name === SERVICE_CONTROL_PROGRAM) return SERVICE_CONTROL_VERBS_THAT_CHANGE.has(verb ?? "");
1703
1703
  return NET_PROGRAMS.has(command.name) && (NET_VERBS_THAT_CHANGE_A_SERVICE.has(verb ?? "") || verb === NET_START && operands.length > 0);
1704
1704
  };
@@ -1722,7 +1722,7 @@ var runsTextAsCode = (stage, judge) => {
1722
1722
  return SCRIPTBLOCK_FROM_TEXT.test(stage.source) || command !== null && (command.cmdlet === INVOKE_EXPRESSION || stage.readsAPipe && judge.runsWhatItReads(posixInvocationOf(command)));
1723
1723
  };
1724
1724
  var runsFetchedPowerShellCode = (stages, judge) => stages.some((stage) => fetchesWithPowerShell(stage, judge)) && stages.some((stage) => runsTextAsCode(stage, judge));
1725
- var downloadedFileNameOf = (text) => fileNameOf(text.replace(URL_QUERY_OR_FRAGMENT, "")).toLowerCase();
1725
+ var downloadedFileNameOf = (text2) => fileNameOf(text2.replace(URL_QUERY_OR_FRAGMENT, "")).toLowerCase();
1726
1726
  var downloadedFileNamesOf = (stages, judge) => new Set(stages.filter((stage) => fetchesWithPowerShell(stage, judge)).flatMap((stage) => {
1727
1727
  const command = powerShellCommandOf(stage);
1728
1728
  return command === null ? [] : operandTextsOf(command).map(downloadedFileNameOf);
@@ -1754,12 +1754,12 @@ var hostedPowerShellScriptOf = (command) => {
1754
1754
  if (!POWERSHELL_HOSTS.has(command.name)) return { kind: "none" };
1755
1755
  const texts = command.args.map((arg) => arg.text);
1756
1756
  for (let index = 0; index < texts.length; index += 1) {
1757
- const text = (texts[index] ?? "").trim();
1758
- if (!text) continue;
1759
- if (!POWERSHELL_HOST_SWITCH.test(text)) {
1757
+ const text2 = (texts[index] ?? "").trim();
1758
+ if (!text2) continue;
1759
+ if (!POWERSHELL_HOST_SWITCH.test(text2)) {
1760
1760
  return command.name === WINDOWS_POWERSHELL_HOST ? { kind: "script", script: texts.slice(index).join(" ") } : { kind: "none" };
1761
1761
  }
1762
- const option = text.toLowerCase().replace(POWERSHELL_HOST_SWITCH_PREFIX, "");
1762
+ const option = text2.toLowerCase().replace(POWERSHELL_HOST_SWITCH_PREFIX, "");
1763
1763
  if (option && (POWERSHELL_HOST_ENCODED_PARAMETER.startsWith(option) || option === POWERSHELL_HOST_ENCODED_ALIAS)) {
1764
1764
  return { kind: "incomplete", reason: "encoded_command" };
1765
1765
  }
@@ -1809,9 +1809,9 @@ var wslCommandWordsOf = (command) => {
1809
1809
  const texts = command.args.map((arg) => arg.text);
1810
1810
  let index = 0;
1811
1811
  while (index < texts.length && POSIX_FLAG.test(texts[index] ?? "")) {
1812
- const text = texts[index] ?? "";
1813
- index += WSL_OPTIONS_WITH_A_VALUE.has(text) ? 2 : 1;
1814
- if (WSL_COMMAND_MARKERS.has(text)) break;
1812
+ const text2 = texts[index] ?? "";
1813
+ index += WSL_OPTIONS_WITH_A_VALUE.has(text2) ? 2 : 1;
1814
+ if (WSL_COMMAND_MARKERS.has(text2)) break;
1815
1815
  }
1816
1816
  return index < texts.length ? texts.slice(index) : void 0;
1817
1817
  };
@@ -2010,8 +2010,8 @@ var quotedToken = (source, start, reading, inside) => {
2010
2010
  }
2011
2011
  if (swallowsABacktick(source, start, end, reading.lexicon)) return "uncertain";
2012
2012
  const quote = source.charAt(start);
2013
- const text = syntax.content === "hidden" ? STRING_PLACEHOLDER : visibleQuotedText(source.slice(start + opener.length, end - opener.length).replaceAll(quote + quote, quote));
2014
- return { text, end, insideExecutableComment: inside };
2013
+ const text2 = syntax.content === "hidden" ? STRING_PLACEHOLDER : visibleQuotedText(source.slice(start + opener.length, end - opener.length).replaceAll(quote + quote, quote));
2014
+ return { text: text2, end, insideExecutableComment: inside };
2015
2015
  };
2016
2016
  var lineCommentEnd = (source, start, lexicon) => {
2017
2017
  const terminator = endOfRun(source, start, (character) => !isLineCommentTerminator(character));
@@ -2061,9 +2061,9 @@ var dollarToken = (source, start, lexicon, inside) => {
2061
2061
  };
2062
2062
  var numberToken = (source, start, inside) => {
2063
2063
  const end = endOfRun(source, start, isWordCharacter);
2064
- const text = source.slice(start, end);
2065
- if (!DECIMAL_DIGITS.test(text) && dollarQuoteDelimiterAt(source, end) !== void 0) return "uncertain";
2066
- return { text, end, insideExecutableComment: inside };
2064
+ const text2 = source.slice(start, end);
2065
+ if (!DECIMAL_DIGITS.test(text2) && dollarQuoteDelimiterAt(source, end) !== void 0) return "uncertain";
2066
+ return { text: text2, end, insideExecutableComment: inside };
2067
2067
  };
2068
2068
  var identifierToken = (source, start, inside) => {
2069
2069
  const end = endOfRun(source, start, isIdentifierPart);
@@ -2271,13 +2271,13 @@ var splitReading = (args, index, clusterBefore, attached) => {
2271
2271
  return { kind: "split", prefix, value: args[index + 1], rest: index + 2 };
2272
2272
  };
2273
2273
  var requiredValueStep = (args, index) => index + 1 < args.length ? nextOption(index + 2) : finished(EXITS);
2274
- var shortOptionStep = (args, index, text, options) => {
2275
- for (let position = 1; position < text.length; position += 1) {
2276
- const letter = text.charAt(position);
2274
+ var shortOptionStep = (args, index, text2, options) => {
2275
+ for (let position = 1; position < text2.length; position += 1) {
2276
+ const letter = text2.charAt(position);
2277
2277
  if (options.switches.has(letter)) continue;
2278
2278
  if (!options.withAValue.has(letter)) return finished(EXITS);
2279
- const attached = text.slice(position + 1);
2280
- if (letter === SPLIT_STRING_LETTER) return finished(splitReading(args, index, text.slice(0, position), attached === "" ? void 0 : attached));
2279
+ const attached = text2.slice(position + 1);
2280
+ if (letter === SPLIT_STRING_LETTER) return finished(splitReading(args, index, text2.slice(0, position), attached === "" ? void 0 : attached));
2281
2281
  return attached === "" ? requiredValueStep(args, index) : nextOption(index + 1);
2282
2282
  }
2283
2283
  return nextOption(index + 1);
@@ -2288,8 +2288,8 @@ var gnuLongOptionAbbreviatedBy = (name, options) => {
2288
2288
  const candidates = options.filter((option) => option.name.startsWith(name));
2289
2289
  return candidates.length === 1 ? candidates[0] : void 0;
2290
2290
  };
2291
- var longOptionStep = (args, index, text, options) => {
2292
- const body = text.slice(LONG_OPTION_PREFIX.length);
2291
+ var longOptionStep = (args, index, text2, options) => {
2292
+ const body = text2.slice(LONG_OPTION_PREFIX.length);
2293
2293
  const separator = body.indexOf(ASSIGNMENT_SEPARATOR);
2294
2294
  const attached = separator === -1 ? void 0 : body.slice(separator + 1);
2295
2295
  const option = gnuLongOptionAbbreviatedBy(separator === -1 ? body : body.slice(0, separator), options);
@@ -2319,7 +2319,7 @@ var runsSomething = (reading) => reading.kind === "command" || reading.kind ===
2319
2319
  var sameEnvReading = (left, right) => {
2320
2320
  if (left.kind === "command" && right.kind === "command") return left.start === right.start;
2321
2321
  if (left.kind !== "split" || right.kind !== "split") return false;
2322
- return left.rest === right.rest && left.prefix.length === right.prefix.length && left.prefix.every((text, position) => text === right.prefix[position]) && left.value?.text === right.value?.text && left.value?.expands === right.value?.expands;
2322
+ return left.rest === right.rest && left.prefix.length === right.prefix.length && left.prefix.every((text2, position) => text2 === right.prefix[position]) && left.value?.text === right.value?.text && left.value?.expands === right.value?.expands;
2323
2323
  };
2324
2324
  var envReadingOf = (args) => {
2325
2325
  const readings = ENV_FLAVORS.map((flavor) => flavorReadingOf(args, flavor));
@@ -2363,8 +2363,8 @@ var clusterReadingOf = (cluster, syntax) => {
2363
2363
  endsOptions: [...letters].some((letter) => syntax.lettersThatEndOptions.has(letter))
2364
2364
  };
2365
2365
  };
2366
- var endsOptionParsing = (text) => text === END_OF_OPTIONS2 || text === LONE_DASH2;
2367
- var isAnOperand = (text) => !text.startsWith("-") && !text.startsWith("+");
2366
+ var endsOptionParsing = (text2) => text2 === END_OF_OPTIONS2 || text2 === LONE_DASH2;
2367
+ var isAnOperand = (text2) => !text2.startsWith("-") && !text2.startsWith("+");
2368
2368
  var optionValueIsUnreadable = (value) => value === void 0 || value.expands;
2369
2369
  var shellCommandStringOf = (shell, args) => {
2370
2370
  const syntax = SHELL_OPTION_SYNTAX.get(shell);
@@ -2463,6 +2463,22 @@ var AUTH_REJECTION_REASONS = [
2463
2463
 
2464
2464
  // ../contracts/src/setup-wire.ts
2465
2465
  var PAIR_TTL_SECONDS = 900;
2466
+ var SETUP_ABORT_REASONS = [
2467
+ "no-key",
2468
+ "invalid-key",
2469
+ "key-refused",
2470
+ "pairing-cancelled",
2471
+ "pairing-failed",
2472
+ "login-rejected",
2473
+ "no-agents-detected",
2474
+ "interrupted",
2475
+ "crashed"
2476
+ ];
2477
+ var isSetupAbortReason = (value) => typeof value === "string" && SETUP_ABORT_REASONS.includes(value);
2478
+ var CODEX_TRUST_OUTCOMES = ["pretrusted", "manual", "verified", "unverified"];
2479
+ var isCodexTrustOutcome = (value) => typeof value === "string" && CODEX_TRUST_OUTCOMES.includes(value);
2480
+ var COMPUTER_OS_VALUES = ["mac", "windows", "linux"];
2481
+ var isComputerOs = (value) => typeof value === "string" && COMPUTER_OS_VALUES.includes(value);
2466
2482
  var computerOsOfPlatform = (platform) => {
2467
2483
  switch (platform) {
2468
2484
  case "darwin":
@@ -2475,6 +2491,10 @@ var computerOsOfPlatform = (platform) => {
2475
2491
  return null;
2476
2492
  }
2477
2493
  };
2494
+ var SETUP_STEP_MAX_LENGTH = 64;
2495
+ var SETUP_STEP_PATTERN = /^[a-z0-9][a-z0-9:_-]*$/;
2496
+ var isSetupStep = (value) => typeof value === "string" && value.length <= SETUP_STEP_MAX_LENGTH && SETUP_STEP_PATTERN.test(value);
2497
+ var isProcessExitCode = (value) => typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= 255;
2478
2498
  var SETUP_AGENT_CHOICES = [
2479
2499
  "claude_code",
2480
2500
  "codex",
@@ -2487,10 +2507,99 @@ var SETUP_AGENT_CHOICES = [
2487
2507
  ...COMPATIBLE_AGENT_TYPES,
2488
2508
  "custom"
2489
2509
  ];
2510
+ var isSetupAgentChoice = (value) => typeof value === "string" && SETUP_AGENT_CHOICES.includes(value);
2511
+ var isSetupAgentCount = (value) => typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= SETUP_AGENT_CHOICES.length;
2512
+ var readSetupAgentChoices = (value) => Array.isArray(value) ? [...new Set(value.filter(isSetupAgentChoice))] : [];
2490
2513
  var isComputerAgent = (agent) => agent !== "custom";
2491
2514
  var NO_PAIRING_COMPUTER = { computerName: null, os: null, agents: null };
2515
+ var SETUP_AGENT_FAILURE_KINDS = [
2516
+ "config-unparseable",
2517
+ "config-unreadable",
2518
+ "installer-error",
2519
+ "not-wired",
2520
+ "app-account-mismatch"
2521
+ ];
2522
+ var isSetupAgentFailureKind = (value) => typeof value === "string" && SETUP_AGENT_FAILURE_KINDS.includes(value);
2523
+ var SETUP_AGENT_FAILURE_CODES = ["npm-missing", "npm-global-prefix-denied", "npm-file-in-use", "npm-install-failed", "config-write-failed"];
2524
+ var SETUP_AGENT_FAILURE_STAGES = ["runtime-install", "config-read", "config-write", "hook-validation", "account-check", "unknown"];
2525
+ var isSetupAgentFailureStage = (value) => typeof value === "string" && SETUP_AGENT_FAILURE_STAGES.includes(value);
2526
+ var SETUP_AGENT_FAILURE_REMEDIES = ["retry-agent", "install-node", "fix-npm-prefix", "close-node-programs", "match-mac-account"];
2527
+ var isSetupAgentFailureCode = (value) => typeof value === "string" && SETUP_AGENT_FAILURE_CODES.includes(value);
2528
+ var isSetupAgentFailureRemedy = (value) => typeof value === "string" && SETUP_AGENT_FAILURE_REMEDIES.includes(value);
2529
+ var isSetupAgentFailure = (value) => {
2530
+ if (typeof value !== "object" || value === null) return false;
2531
+ return "agent" in value && isSetupAgentChoice(value.agent) && "kind" in value && isSetupAgentFailureKind(value.kind);
2532
+ };
2533
+ var firstFailurePerAgent = (failures) => failures.filter((failure, index) => failures.findIndex((other) => other.agent === failure.agent) === index);
2534
+ var safeSetupFailure = (failure) => {
2535
+ const diagnosticCode = "diagnosticCode" in failure ? failure.diagnosticCode : void 0;
2536
+ const remedy = "remedy" in failure ? failure.remedy : void 0;
2537
+ const stage = "stage" in failure ? failure.stage : void 0;
2538
+ return {
2539
+ agent: failure.agent,
2540
+ kind: failure.kind,
2541
+ ...isSetupAgentFailureCode(diagnosticCode) ? { diagnosticCode } : {},
2542
+ ...isSetupAgentFailureRemedy(remedy) ? { remedy } : {},
2543
+ ...isSetupAgentFailureStage(stage) ? { stage } : {}
2544
+ };
2545
+ };
2546
+ var readSetupAgentFailures = (value) => Array.isArray(value) ? firstFailurePerAgent(value.filter(isSetupAgentFailure).map(safeSetupFailure)) : [];
2547
+ var SETUP_CLOSING_REASONS = [
2548
+ "configured-nothing",
2549
+ "agents-failed",
2550
+ "stale-environment-key",
2551
+ "control-unready",
2552
+ "synthetic-answer",
2553
+ "phone-unverified",
2554
+ "roundtrip-unanswered",
2555
+ "phone-skipped",
2556
+ "complete",
2557
+ "plan-inactive",
2558
+ "key-unverified"
2559
+ ];
2560
+ var isSetupClosingReason = (value) => typeof value === "string" && SETUP_CLOSING_REASONS.includes(value);
2561
+ var SETUP_CONTROL_FAILURE_STAGES = [
2562
+ "package-install",
2563
+ "service-install",
2564
+ "daemon-start",
2565
+ "remote-proof",
2566
+ "server-readiness",
2567
+ "lifecycle",
2568
+ "unsupported"
2569
+ ];
2570
+ var isSetupControlFailureStage = (value) => typeof value === "string" && SETUP_CONTROL_FAILURE_STAGES.includes(value);
2571
+ var SETUP_CONNECT_OUTCOMES = ["answered", "delivered", "unreachable", "skipped"];
2572
+ var isSetupConnectOutcome = (value) => typeof value === "string" && SETUP_CONNECT_OUTCOMES.includes(value);
2573
+ var CLI_VERSION_MAX_LENGTH = 64;
2574
+ var CLI_VERSION_PATTERN = /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/;
2575
+ var isCliVersion = (value) => typeof value === "string" && value.length <= CLI_VERSION_MAX_LENGTH && CLI_VERSION_PATTERN.test(value);
2492
2576
  var SETUP_CONNECT_MODES = ["app", "browser", "web", "none"];
2493
2577
  var isSetupConnectMode = (value) => typeof value === "string" && SETUP_CONNECT_MODES.includes(value);
2578
+ var SETUP_KEY_CHECKS = ["ok", "malformed", "rejected", "locked", "unreachable", "skipped", "unknown"];
2579
+ var isSetupKeyCheck = (value) => typeof value === "string" && SETUP_KEY_CHECKS.includes(value);
2580
+ var readOptional = (value, isValid) => isValid(value) ? value : null;
2581
+ var isBoolean = (value) => typeof value === "boolean";
2582
+ var readSetupOutcomeProperties = (body) => {
2583
+ const agentFailures = readSetupAgentFailures(body.agentFailures);
2584
+ return {
2585
+ abortReason: readOptional(body.abortReason, isSetupAbortReason),
2586
+ abandonedAt: readOptional(body.abandonedAt, isSetupStep),
2587
+ exitCode: readOptional(body.exitCode, isProcessExitCode),
2588
+ codexTrust: readOptional(body.codexTrust, isCodexTrustOutcome),
2589
+ agentFailures,
2590
+ failedAgentIds: agentFailures.map((failure) => failure.agent),
2591
+ failedAgents: readOptional(body.failedAgents, isSetupAgentCount),
2592
+ skippedAgents: readSetupAgentChoices(body.skippedAgents),
2593
+ closingReason: readOptional(body.closingReason, isSetupClosingReason),
2594
+ controlFailureStage: readOptional(body.controlFailureStage, isSetupControlFailureStage),
2595
+ connectMode: readOptional(body.connectMode, isSetupConnectMode),
2596
+ connectOutcome: readOptional(body.connectOutcome, isSetupConnectOutcome),
2597
+ keyCheck: readOptional(body.keyCheck, isSetupKeyCheck),
2598
+ nonInteractive: readOptional(body.nonInteractive, isBoolean),
2599
+ cliVersion: readOptional(body.cliVersion, isCliVersion),
2600
+ os: readOptional(body.os, isComputerOs)
2601
+ };
2602
+ };
2494
2603
 
2495
2604
  // ../contracts/src/declined-agents.ts
2496
2605
  var DECLINED_AGENTS_FILE = "declined-agents.json";
@@ -2534,6 +2643,105 @@ var record = (value) => value !== null && typeof value === "object" && !Array.is
2534
2643
  var identifier = (value) => typeof value === "string" && value.length > 0 && value.length <= 200;
2535
2644
  var isQuestionOwner = (value) => record(value) && value.capability === PERSONAL_QUESTION_CAPABILITY && identifier(value.machineId) && identifier(value.generation) && identifier(value.threadId) && identifier(value.turnId) && identifier(value.itemId) && (identifier(value.requestId) || typeof value.requestId === "number" && Number.isSafeInteger(value.requestId)) && value.method === "item/tool/requestUserInput" && typeof value.subjectHash === "string" && /^[a-f0-9]{64}$/.test(value.subjectHash) && Object.keys(value).length === 9;
2536
2645
 
2646
+ // ../contracts/src/codex-native-approval.ts
2647
+ var CODEX_NATIVE_APPROVAL_CAPABILITY = "codex-native-approval-v1";
2648
+ var CODEX_NATIVE_APPROVAL_METHODS = ["item/commandExecution/requestApproval", "item/fileChange/requestApproval", "mcpServer/elicitation/request"];
2649
+ var CODEX_NATIVE_APPROVAL_CHOICES = { once: "Allow once", session: "Allow this conversation", deny: "Deny" };
2650
+ var record2 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
2651
+ var identifier2 = (v) => typeof v === "string" && v.length > 0 && v.length <= 200;
2652
+ var text = (v) => typeof v === "string" && v.trim().length > 0 && v.length <= 16384;
2653
+ var optionalIdentifier = (v) => v == null || identifier2(v);
2654
+ var keys = (v, allowed) => Object.keys(v).every((key) => allowed.includes(key));
2655
+ var isMethod = (v) => typeof v === "string" && CODEX_NATIVE_APPROVAL_METHODS.some((method) => method === v);
2656
+ var boundedJson = (value) => {
2657
+ try {
2658
+ return JSON.stringify(value).length <= 64 * 1024;
2659
+ } catch {
2660
+ return false;
2661
+ }
2662
+ };
2663
+ var BASE_KEYS = ["threadId", "turnId", "itemId", "startedAtMs", "reason"];
2664
+ var MCP_META_KEYS = ["codex_approval_kind", "codex_requires_user_input", "codex_request_type", "codex_strict_auto_review", "codex_sensitive_action", "approvals_reviewer", "persist", "source", "connector_id", "connector_name", "connector_description", "tool_name", "tool_title", "tool_description", "tool_params", "tool_params_display"];
2665
+ var isExecpolicyAmendment = (value) => Array.isArray(value) && value.length > 0 && value.length <= 128 && value.every((token) => typeof token === "string" && token.length <= 16384);
2666
+ var isCommandDecision = (value) => {
2667
+ if (typeof value === "string") return ["accept", "acceptForSession", "decline", "cancel"].includes(value);
2668
+ if (!record2(value) || !keys(value, ["acceptWithExecpolicyAmendment"]) || !record2(value.acceptWithExecpolicyAmendment)) return false;
2669
+ return keys(value.acceptWithExecpolicyAmendment, ["execpolicy_amendment"]) && isExecpolicyAmendment(value.acceptWithExecpolicyAmendment.execpolicy_amendment);
2670
+ };
2671
+ var parseCodexNativeApproval = (value) => {
2672
+ if (!record2(value) || !keys(value, ["method", "params", "changes"]) || !isMethod(value.method) || !record2(value.params) || !boundedJson(value)) return null;
2673
+ const p = value.params;
2674
+ if (!identifier2(p.threadId) || !optionalIdentifier(p.turnId) || !optionalIdentifier(p.itemId)) return null;
2675
+ const request = { method: value.method, params: p, ...Array.isArray(value.changes) ? { changes: value.changes } : {} };
2676
+ const base = {
2677
+ request,
2678
+ threadId: p.threadId,
2679
+ turnId: typeof p.turnId === "string" ? p.turnId : null,
2680
+ itemId: typeof p.itemId === "string" ? p.itemId : null,
2681
+ options: [CODEX_NATIVE_APPROVAL_CHOICES.once, CODEX_NATIVE_APPROVAL_CHOICES.deny],
2682
+ negativeDecision: "decline"
2683
+ };
2684
+ if (value.method === "mcpServer/elicitation/request") {
2685
+ if (value.changes !== void 0 || !keys(p, ["threadId", "turnId", "serverName", "mode", "message", "requestedSchema", "_meta"]) || p.mode !== "form" || !identifier2(p.serverName) || !text(p.message) || p.message.length > 500 || !record2(p.requestedSchema) || !keys(p.requestedSchema, ["type", "properties", "required", "$schema"]) || p.requestedSchema.type !== "object" || !record2(p.requestedSchema.properties) || Object.keys(p.requestedSchema.properties).length !== 0 || p.requestedSchema.required != null && (!Array.isArray(p.requestedSchema.required) || p.requestedSchema.required.length !== 0)) return null;
2686
+ const meta = p._meta;
2687
+ if (!record2(meta) || !keys(meta, MCP_META_KEYS) || meta.codex_approval_kind !== "mcp_tool_call" || !identifier2(meta.tool_name) || !record2(meta.tool_params) || meta.tool_params_display != null && !record2(meta.tool_params_display)) return null;
2688
+ if (["codex_requires_user_input", "codex_strict_auto_review", "codex_sensitive_action"].some((key) => meta[key] != null && typeof meta[key] !== "boolean")) return null;
2689
+ if (meta.approvals_reviewer != null && meta.approvals_reviewer !== "user") return null;
2690
+ if (meta.codex_request_type != null && meta.codex_request_type !== "approval_request") return null;
2691
+ if (["source", "connector_id", "connector_name", "connector_description", "tool_title", "tool_description"].some((key) => meta[key] != null && !text(meta[key]))) return null;
2692
+ const persistence = meta.persist == null ? [] : typeof meta.persist === "string" ? [meta.persist] : meta.persist;
2693
+ if (!Array.isArray(persistence) || persistence.some((v) => v !== "session" && v !== "always")) return null;
2694
+ return {
2695
+ ...base,
2696
+ toolName: `mcp__${p.serverName}__${meta.tool_name}`,
2697
+ toolInputs: [meta.tool_params],
2698
+ question: p.message,
2699
+ detail: JSON.stringify(meta.tool_params),
2700
+ options: persistence.includes("session") ? [CODEX_NATIVE_APPROVAL_CHOICES.once, CODEX_NATIVE_APPROVAL_CHOICES.session, CODEX_NATIVE_APPROVAL_CHOICES.deny] : base.options
2701
+ };
2702
+ }
2703
+ if (!identifier2(p.turnId) || !identifier2(p.itemId) || !Number.isSafeInteger(p.startedAtMs) || p.reason != null && !text(p.reason)) return null;
2704
+ if (value.method === "item/commandExecution/requestApproval") {
2705
+ if (value.changes !== void 0 || !keys(p, [...BASE_KEYS, "approvalId", "kind", "environmentId", "command", "cwd", "commandActions", "networkApprovalContext", "proposedExecpolicyAmendment", "proposedNetworkPolicyAmendments", "availableDecisions"]) || !optionalIdentifier(p.approvalId) || p.kind != null && p.kind !== "command" || p.environmentId != null && p.environmentId !== "local" || p.networkApprovalContext != null || p.proposedNetworkPolicyAmendments != null || p.proposedExecpolicyAmendment != null && !isExecpolicyAmendment(p.proposedExecpolicyAmendment) || !text(p.command) || !text(p.cwd)) return null;
2706
+ const decisions = p.availableDecisions ?? ["accept", "decline", "cancel"];
2707
+ if (!Array.isArray(decisions) || !decisions.includes("accept") || !decisions.some((v) => v === "decline" || v === "cancel") || !decisions.every(isCommandDecision)) return null;
2708
+ return {
2709
+ ...base,
2710
+ toolName: "Bash",
2711
+ toolInputs: [{ command: p.command }],
2712
+ cwd: p.cwd,
2713
+ question: "Allow this command once?",
2714
+ detail: p.command,
2715
+ negativeDecision: decisions.includes("decline") ? "decline" : "cancel"
2716
+ };
2717
+ }
2718
+ if (!keys(p, [...BASE_KEYS, "grantRoot"]) || p.grantRoot != null || !Array.isArray(value.changes) || value.changes.length === 0 || value.changes.length > 32) return null;
2719
+ const paths = [], diffs = [];
2720
+ for (const change of value.changes) {
2721
+ if (!record2(change) || !keys(change, ["path", "kind", "diff"]) || !text(change.path) || typeof change.diff !== "string" || !record2(change.kind) || !keys(change.kind, ["type", "move_path"]) || !["add", "delete", "update"].includes(String(change.kind.type)) || change.kind.move_path != null) return null;
2722
+ paths.push(change.path);
2723
+ diffs.push(`${change.path}
2724
+ ${change.diff}`);
2725
+ }
2726
+ return {
2727
+ ...base,
2728
+ toolName: "Write",
2729
+ toolInputs: paths.map((file_path) => ({ file_path })),
2730
+ scopePaths: paths,
2731
+ question: `Allow these ${paths.length} file changes once?`,
2732
+ detail: diffs.join("\n\n")
2733
+ };
2734
+ };
2735
+ var codexNativeApprovalResponse = (approval, answer) => {
2736
+ const accepted = approval.options.includes(answer) && (answer === CODEX_NATIVE_APPROVAL_CHOICES.once || answer === CODEX_NATIVE_APPROVAL_CHOICES.session);
2737
+ if (approval.request.method === "mcpServer/elicitation/request") return {
2738
+ action: accepted ? "accept" : "decline",
2739
+ content: null,
2740
+ _meta: accepted && answer === CODEX_NATIVE_APPROVAL_CHOICES.session ? { persist: "session" } : null
2741
+ };
2742
+ return { decision: accepted ? "accept" : approval.negativeDecision };
2743
+ };
2744
+
2537
2745
  // ../contracts/src/index.ts
2538
2746
  var KEY_SCOPES = ["full_access", "agent", "connector", "bound"];
2539
2747
  var normalizeKeyScope = (value) => typeof value === "string" && KEY_SCOPES.includes(value) ? value : null;
@@ -2561,6 +2769,8 @@ var approvalModeWithoutLocalPrompt = (mode) => {
2561
2769
  };
2562
2770
  var TIMEOUT_ACTION_THAT_REFUSES = "deny";
2563
2771
  var timeoutActionWithoutLocalPrompt = ({ mode, timeoutAction }) => mode !== "push_only" && timeoutAction === "approve" ? TIMEOUT_ACTION_THAT_REFUSES : timeoutAction;
2772
+ var TIMEOUT_ACTIONS = ["approve", "deny", "escalate", "wait"];
2773
+ var isTimeoutAction = (value) => typeof value === "string" && TIMEOUT_ACTIONS.includes(value);
2564
2774
  var MAX_AGENT_QUESTIONS = 4;
2565
2775
  var AGENT_QUESTION_HEADER_MAX = 40;
2566
2776
  var AGENT_QUESTION_OPTION_MAX = 100;
@@ -2608,9 +2818,9 @@ var isAgentQuestionSet = (value) => {
2608
2818
  const labels = /* @__PURE__ */ new Set();
2609
2819
  for (const option of question.options) {
2610
2820
  if (!option || typeof option !== "object" || Array.isArray(option)) return false;
2611
- const record2 = option;
2612
- const label = record2.label;
2613
- if (typeof label !== "string" || label.length === 0 || labels.has(label) || record2.description !== void 0 && typeof record2.description !== "string") return false;
2821
+ const record3 = option;
2822
+ const label = record3.label;
2823
+ if (typeof label !== "string" || label.length === 0 || labels.has(label) || record3.description !== void 0 && typeof record3.description !== "string") return false;
2614
2824
  labels.add(label);
2615
2825
  }
2616
2826
  questions.add(question.question);
@@ -2727,7 +2937,7 @@ var HOOK_HOLD_BUDGET_FLAG = "--hold-budget";
2727
2937
  var HOOK_HOLD_BUDGET_ENV = "PUSHARY_HOLD_BUDGET_SECONDS";
2728
2938
  var HOOK_BRIDGE_SOURCE_FLAG = "--source";
2729
2939
  var HOOK_HOLD_BUDGET_SECONDS = /^[1-9]\d{0,5}$/;
2730
- var hookHoldBudgetSeconds = (text) => text !== void 0 && HOOK_HOLD_BUDGET_SECONDS.test(text) ? Number(text) : void 0;
2940
+ var hookHoldBudgetSeconds = (text2) => text2 !== void 0 && HOOK_HOLD_BUDGET_SECONDS.test(text2) ? Number(text2) : void 0;
2731
2941
  var hookHoldBudgetArgument = (seconds) => `${HOOK_HOLD_BUDGET_FLAG}=${seconds}`;
2732
2942
  var withHookHoldBudget = (command, holdBudgetSeconds) => holdBudgetSeconds === void 0 ? command : `${command} ${hookHoldBudgetArgument(holdBudgetSeconds)}`;
2733
2943
  var registeredHookHoldBudget = (args) => {
@@ -2836,8 +3046,8 @@ var tokenizeGlob = (glob) => {
2836
3046
  return tokens;
2837
3047
  };
2838
3048
  var SLASH = "/".charCodeAt(0);
2839
- var matchGlobTokens = (tokens, text) => {
2840
- const n = text.length;
3049
+ var matchGlobTokens = (tokens, text2) => {
3050
+ const n = text2.length;
2841
3051
  let reachable = new Uint8Array(n + 1);
2842
3052
  reachable[0] = 1;
2843
3053
  for (const token of tokens) {
@@ -2845,13 +3055,13 @@ var matchGlobTokens = (tokens, text) => {
2845
3055
  if (token.kind === "literal") {
2846
3056
  const { value } = token;
2847
3057
  for (let p = 0; p <= n - value.length; p += 1) {
2848
- if (reachable[p] && text.startsWith(value, p)) next[p + value.length] = 1;
3058
+ if (reachable[p] && text2.startsWith(value, p)) next[p + value.length] = 1;
2849
3059
  }
2850
3060
  } else {
2851
3061
  const spansSeparators = token.kind === "globstar";
2852
3062
  let open = 0;
2853
3063
  for (let p = 0; p <= n; p += 1) {
2854
- if (!spansSeparators && p > 0 && text.charCodeAt(p - 1) === SLASH) open = 0;
3064
+ if (!spansSeparators && p > 0 && text2.charCodeAt(p - 1) === SLASH) open = 0;
2855
3065
  if (reachable[p]) open = 1;
2856
3066
  if (open) next[p] = 1;
2857
3067
  }
@@ -3232,7 +3442,7 @@ var argumentsMayExpand = (segment) => {
3232
3442
  const visible = shellVisibleText(segment);
3233
3443
  return visible === null || EXPANSION_THAT_CAN_BECOME_A_FLAG.test(visible.replace(SHELL_QUOTE_CHARACTERS, ""));
3234
3444
  };
3235
- var blankedSafeRedirections = (text) => text.replace(SAFE_REDIRECTION, (redirection) => " ".repeat(redirection.length));
3445
+ var blankedSafeRedirections = (text2) => text2.replace(SAFE_REDIRECTION, (redirection) => " ".repeat(redirection.length));
3236
3446
  var segmentsSplitWhereVisible = (command, visible, separators) => {
3237
3447
  const segments = [];
3238
3448
  let start = 0;
@@ -3381,10 +3591,10 @@ var DESTRUCTIVE_WORDS_IN_ANY_CASE_BY_COMMAND = /* @__PURE__ */ new Map([
3381
3591
  ]);
3382
3592
  var namesDestructiveWordInAnyCase = (name, texts) => {
3383
3593
  const words = DESTRUCTIVE_WORDS_IN_ANY_CASE_BY_COMMAND.get(name);
3384
- return words !== void 0 && texts.some((text) => words.has(text.toLowerCase()));
3594
+ return words !== void 0 && texts.some((text2) => words.has(text2.toLowerCase()));
3385
3595
  };
3386
3596
  var LONG_OPTION = /^--[A-Za-z]/;
3387
- var namesDestructiveArgument = (text, destructiveArguments) => destructiveArguments.has(text) || LONG_OPTION.test(text) && [...destructiveArguments].some((argument) => argument.startsWith(text)) || [...SHORT_FLAG_CLUSTER.exec(text)?.[1] ?? ""].some((letter) => destructiveArguments.has(`-${letter}`));
3597
+ var namesDestructiveArgument = (text2, destructiveArguments) => destructiveArguments.has(text2) || LONG_OPTION.test(text2) && [...destructiveArguments].some((argument) => argument.startsWith(text2)) || [...SHORT_FLAG_CLUSTER.exec(text2)?.[1] ?? ""].some((letter) => destructiveArguments.has(`-${letter}`));
3388
3598
  var RUNNER_SUBCOMMANDS = /* @__PURE__ */ new Set(["exec", "dlx"]);
3389
3599
  var SUBCOMMAND_CLIS = /* @__PURE__ */ new Set([
3390
3600
  "git",
@@ -3511,7 +3721,7 @@ var argumentsHideTheEffect = (name, args) => {
3511
3721
  const texts = args.map((arg) => arg.text);
3512
3722
  if (INLINE_CODE_INTERPRETERS.has(name.replace(/\d+(?:\.\d+)*$/, "")) && interpreterRunsUnreadableCode(texts)) return true;
3513
3723
  const destructiveArguments = destructiveArgumentsOf(name, args);
3514
- if (destructiveArguments && texts.some((text) => namesDestructiveArgument(text, destructiveArguments))) return true;
3724
+ if (destructiveArguments && texts.some((text2) => namesDestructiveArgument(text2, destructiveArguments))) return true;
3515
3725
  if (namesDestructiveWordInAnyCase(name, texts)) return true;
3516
3726
  if (!SUBCOMMAND_CLIS.has(name)) return false;
3517
3727
  const meaningful = argsAfterHarmlessGlobalFlags(args);
@@ -3530,7 +3740,7 @@ var normalizedInvocation = (invocation) => invocationTextWith(invocation, (word)
3530
3740
  var SHELL_METACHARACTER = /[\s;&|<>()$`\\"'*?[\]#~{}!]/;
3531
3741
  var SINGLE_QUOTE2 = "'";
3532
3742
  var ESCAPED_SINGLE_QUOTE = `'\\''`;
3533
- var asOneShellWord = (text) => SHELL_METACHARACTER.test(text) ? `${SINGLE_QUOTE2}${text.replaceAll(SINGLE_QUOTE2, ESCAPED_SINGLE_QUOTE)}${SINGLE_QUOTE2}` : text;
3743
+ var asOneShellWord = (text2) => SHELL_METACHARACTER.test(text2) ? `${SINGLE_QUOTE2}${text2.replaceAll(SINGLE_QUOTE2, ESCAPED_SINGLE_QUOTE)}${SINGLE_QUOTE2}` : text2;
3534
3744
  var quotedInvocation = (invocation) => invocationTextWith(invocation, (word) => asOneShellWord(word.text));
3535
3745
  var normalizedCommand = (command) => {
3536
3746
  const segments = readableCommandSegments(command);
@@ -3631,8 +3841,8 @@ var SQL_WRITE_STATEMENT = new RegExp([
3631
3841
  String.raw`\.(?:insert|update|delete|replace|remove|drop|rename|create|bulkwrite|findoneand)\w*\s*\(`
3632
3842
  ].join("|"), "i");
3633
3843
  var SQL_READ_PHRASE = /\bshow\s+create\b/gi;
3634
- var sqlTextWrites = (text) => {
3635
- const statement = text.replace(SQL_READ_PHRASE, "");
3844
+ var sqlTextWrites = (text2) => {
3845
+ const statement = text2.replace(SQL_READ_PHRASE, "");
3636
3846
  return SQL_WRITE_STATEMENT.test(statement) || SQL_CLIENT_FILE_COMMAND.test(statement);
3637
3847
  };
3638
3848
  var writesThroughSql = (sql, lexicon) => {
@@ -3648,7 +3858,7 @@ var SQL_CLIENT_FILE_COMMAND = new RegExp([
3648
3858
  var SHORT_FLAG_CLUSTER_ONLY = /^-([A-Za-z0-9]+)$/;
3649
3859
  var LEADING_OPTION_DASHES = /^-+/;
3650
3860
  var NO_SQL = { script: false, sql: null, hidden: false };
3651
- var shortFlagOf = (flags, text) => [...flags].find((flag) => /^-[A-Za-z]$/.test(flag) && text.startsWith(flag) && text.length > flag.length && !text.startsWith("--"));
3861
+ var shortFlagOf = (flags, text2) => [...flags].find((flag) => /^-[A-Za-z]$/.test(flag) && text2.startsWith(flag) && text2.length > flag.length && !text2.startsWith("--"));
3652
3862
  var sqlArgumentAt = (args, index, syntax) => {
3653
3863
  const arg = args[index];
3654
3864
  if (arg === void 0) return NO_SQL;
@@ -3668,7 +3878,7 @@ var sqlArgumentAt = (args, index, syntax) => {
3668
3878
  if (cluster && cluster.length > 1 && syntax.inlineFlags.has(last)) return valueOf(next);
3669
3879
  return { script: false, sql: arg.text.replace(LEADING_OPTION_DASHES, ""), hidden: false };
3670
3880
  };
3671
- var namesALongFlagValue = (text, flags) => [...flags].some((flag) => flag.startsWith("--") && text.startsWith(`${flag}${FLAG_VALUE_SEPARATOR}`));
3881
+ var namesALongFlagValue = (text2, flags) => [...flags].some((flag) => flag.startsWith("--") && text2.startsWith(`${flag}${FLAG_VALUE_SEPARATOR}`));
3672
3882
  var positionalSqlIsHidden = (args, syntax) => syntax.positionalSql && args.filter((arg) => !arg.text.startsWith("-")).slice(1).some((arg) => arg.expands);
3673
3883
  var sqlClientSyntaxOf = ({ program }) => program === void 0 ? void 0 : SQL_CLIENT_SYNTAX.get(basenameOf(program.text));
3674
3884
  var sqlClientChangesData = (invocation) => {
@@ -4042,7 +4252,7 @@ var gitDiscardsWork = ({ program, args }) => {
4042
4252
  const [subcommand, ...rest] = argsAfterHarmlessGlobalFlags(args);
4043
4253
  const discards = GIT_WORK_DISCARDERS.get(subcommand?.text ?? "");
4044
4254
  const texts = rest.map((arg) => arg.text);
4045
- return discards !== void 0 && discards(texts.filter((text) => FLAG.test(text)), texts.filter((text) => !FLAG.test(text)));
4255
+ return discards !== void 0 && discards(texts.filter((text2) => FLAG.test(text2)), texts.filter((text2) => !FLAG.test(text2)));
4046
4256
  };
4047
4257
  var PACKAGE_MANAGERS = /* @__PURE__ */ new Set([
4048
4258
  "npm",
@@ -4190,25 +4400,25 @@ var WRAPPER_SYNTAX = /* @__PURE__ */ new Map([
4190
4400
  ]);
4191
4401
  var EVAL = "eval";
4192
4402
  var MAX_CONSEQUENCE_DEPTH = 4;
4193
- var shortValueOptionPosition = (text, options) => {
4194
- if (!text.startsWith("-") || text.startsWith("--")) return -1;
4195
- for (let index = 1; index < text.length; index += 1) {
4196
- if (options.has(`-${text[index]}`)) return index;
4403
+ var shortValueOptionPosition = (text2, options) => {
4404
+ if (!text2.startsWith("-") || text2.startsWith("--")) return -1;
4405
+ for (let index = 1; index < text2.length; index += 1) {
4406
+ if (options.has(`-${text2[index]}`)) return index;
4197
4407
  }
4198
4408
  return -1;
4199
4409
  };
4200
- var wrapperOptionConsumesNextWord = (text, options) => {
4201
- if (options.has(text)) return true;
4202
- const position = shortValueOptionPosition(text, options);
4203
- return position !== -1 && position === text.length - 1;
4410
+ var wrapperOptionConsumesNextWord = (text2, options) => {
4411
+ if (options.has(text2)) return true;
4412
+ const position = shortValueOptionPosition(text2, options);
4413
+ return position !== -1 && position === text2.length - 1;
4204
4414
  };
4205
4415
  var commandStartAfterWrapper = (words, syntax) => {
4206
4416
  let index = 0;
4207
4417
  while (index < words.length) {
4208
- const text = words[index]?.text ?? "";
4209
- if (text === END_OF_OPTIONS3) return index + 1 + syntax.operandsBeforeTheCommand;
4210
- if (!SHELL_ENV_ASSIGNMENT.test(text) && (!FLAG.test(text) || text === STANDARD_INPUT_ARGUMENT)) break;
4211
- index += wrapperOptionConsumesNextWord(text, syntax.optionsWithAValue) ? 2 : 1;
4418
+ const text2 = words[index]?.text ?? "";
4419
+ if (text2 === END_OF_OPTIONS3) return index + 1 + syntax.operandsBeforeTheCommand;
4420
+ if (!SHELL_ENV_ASSIGNMENT.test(text2) && (!FLAG.test(text2) || text2 === STANDARD_INPUT_ARGUMENT)) break;
4421
+ index += wrapperOptionConsumesNextWord(text2, syntax.optionsWithAValue) ? 2 : 1;
4212
4422
  }
4213
4423
  return index + syntax.operandsBeforeTheCommand;
4214
4424
  };
@@ -4310,16 +4520,16 @@ var pipesFetchedCodeIntoAnInterpreter = (command, invocations) => invocations.so
4310
4520
  var WORDS_THAT_OPEN_A_COMMAND = String.raw`if|then|elif|else|do|while|until|!`;
4311
4521
  var SHELL_GROUPING_PREFIX = new RegExp(String.raw`^\s*(?:(?:${WORDS_THAT_OPEN_A_COMMAND})\s+|[({]\s*)+`);
4312
4522
  var GROUP_OPENER_BY_CLOSER = /* @__PURE__ */ new Map([[")", "("], ["}", "{"]]);
4313
- var occurrencesOf = (text, character) => text.split(character).length - 1;
4314
- var closesAGroupItDidNotOpen = (text) => {
4315
- const last = text.at(-1) ?? "";
4523
+ var occurrencesOf = (text2, character) => text2.split(character).length - 1;
4524
+ var closesAGroupItDidNotOpen = (text2) => {
4525
+ const last = text2.at(-1) ?? "";
4316
4526
  const opener = GROUP_OPENER_BY_CLOSER.get(last);
4317
- return opener !== void 0 && occurrencesOf(text, last) > occurrencesOf(text, opener);
4527
+ return opener !== void 0 && occurrencesOf(text2, last) > occurrencesOf(text2, opener);
4318
4528
  };
4319
4529
  var withoutShellGrouping = (segment) => {
4320
- let text = segment.replace(SHELL_GROUPING_PREFIX, "").trimEnd();
4321
- while (closesAGroupItDidNotOpen(text)) text = text.slice(0, -1).trimEnd();
4322
- return text;
4530
+ let text2 = segment.replace(SHELL_GROUPING_PREFIX, "").trimEnd();
4531
+ while (closesAGroupItDidNotOpen(text2)) text2 = text2.slice(0, -1).trimEnd();
4532
+ return text2;
4323
4533
  };
4324
4534
  var HEREDOC_OPERATOR = /(?<!<)\d*<<(?!<)-?[ \t]*(?:'([A-Za-z_]\w*)'|"([A-Za-z_]\w*)"|\\?([A-Za-z_]\w*))/g;
4325
4535
  var HEREDOC_MARK = "\uE001";
@@ -4352,24 +4562,24 @@ var SEPARATORS_INSIDE_DOUBLE_QUOTES = /* @__PURE__ */ new Set(["$(", "`", ")"]);
4352
4562
  var PIPE3 = "|";
4353
4563
  var SUBSTITUTION_OPENERS = /* @__PURE__ */ new Set(["$(", "`"]);
4354
4564
  var QUOTE_CHARACTERS = /['"]/g;
4355
- var roughPiecesOf = (text) => {
4565
+ var roughPiecesOf = (text2) => {
4356
4566
  const pieces = [];
4357
4567
  let current = "";
4358
4568
  let before = "";
4359
4569
  let quote = null;
4360
- for (let index = 0; index < text.length; index += 1) {
4361
- const char = text.charAt(index);
4570
+ for (let index = 0; index < text2.length; index += 1) {
4571
+ const char = text2.charAt(index);
4362
4572
  if (quote === "'") {
4363
4573
  current += char;
4364
4574
  if (char === "'") quote = null;
4365
4575
  continue;
4366
4576
  }
4367
4577
  if (char === "\\") {
4368
- current += text.slice(index, index + 2);
4578
+ current += text2.slice(index, index + 2);
4369
4579
  index += 1;
4370
4580
  continue;
4371
4581
  }
4372
- const separator = ROUGH_SEPARATORS.find((candidate) => text.startsWith(candidate, index) && (quote === null || SEPARATORS_INSIDE_DOUBLE_QUOTES.has(candidate)));
4582
+ const separator = ROUGH_SEPARATORS.find((candidate) => text2.startsWith(candidate, index) && (quote === null || SEPARATORS_INSIDE_DOUBLE_QUOTES.has(candidate)));
4373
4583
  if (separator !== void 0) {
4374
4584
  pieces.push({ text: current, before });
4375
4585
  current = "";
@@ -4382,14 +4592,14 @@ var roughPiecesOf = (text) => {
4382
4592
  }
4383
4593
  return [...pieces, { text: current, before }];
4384
4594
  };
4385
- var invocationOfRoughPiece = (text) => {
4386
- const piece = withoutShellGrouping(text.replaceAll(REDIRECTED_INPUT_MARK, "").replaceAll(HEREDOC_MARK, ""));
4595
+ var invocationOfRoughPiece = (text2) => {
4596
+ const piece = withoutShellGrouping(text2.replaceAll(REDIRECTED_INPUT_MARK, "").replaceAll(HEREDOC_MARK, ""));
4387
4597
  const parsed = invocationOf(piece);
4388
4598
  return parsed.program !== void 0 ? parsed : invocationOf(piece.replace(QUOTE_CHARACTERS, ""));
4389
4599
  };
4390
4600
  var roughSegmentsOf = (command) => {
4391
- const { text, bodies } = withHeredocBodiesSetAside(commandForReading(command));
4392
- const pieces = roughPiecesOf(text.replace(INPUT_REDIRECTION, ` ${REDIRECTED_INPUT_MARK} `).replace(OUTPUT_REDIRECTION, " "));
4601
+ const { text: text2, bodies } = withHeredocBodiesSetAside(commandForReading(command));
4602
+ const pieces = roughPiecesOf(text2.replace(INPUT_REDIRECTION, ` ${REDIRECTED_INPUT_MARK} `).replace(OUTPUT_REDIRECTION, " "));
4393
4603
  let heredocsSeen = 0;
4394
4604
  return pieces.map((piece, index) => {
4395
4605
  const heredocCount = occurrencesOf(piece.text, HEREDOC_MARK);
@@ -4426,7 +4636,7 @@ var commandHasAVisibleConsequenceAt = (toolName, command, depth) => {
4426
4636
  };
4427
4637
  var posixCommandOf = (words) => words.map(asOneShellWord).join(" ");
4428
4638
  var posixShellJudgeFor = (toolName) => ({
4429
- namesADestructiveAction: (text) => classifyDecisionRisk(toolName, text) === "destructive",
4639
+ namesADestructiveAction: (text2) => classifyDecisionRisk(toolName, text2) === "destructive",
4430
4640
  invocationShowsAConsequence: (invocation) => invocationHasAVisibleConsequence(SHELL_TOOL, invocation, 0),
4431
4641
  commandShowsAConsequence: (words) => commandHasAVisibleConsequenceAt(SHELL_TOOL, posixCommandOf(words), 1),
4432
4642
  onlyReads: (words) => isSafeReadOnlyCommand(posixCommandOf(words)),
@@ -4469,9 +4679,9 @@ var GIT_GLOBAL_FLAGS = /* @__PURE__ */ new Set([
4469
4679
  var GIT_OPTION_AND_ITS_VALUE = 2;
4470
4680
  var GIT_OPTION_ALONE = 1;
4471
4681
  var NOT_A_GIT_GLOBAL_OPTION = 0;
4472
- var gitGlobalOptionWidth = (text) => {
4473
- if (GIT_GLOBAL_OPTIONS_WITH_A_VALUE.has(text)) return GIT_OPTION_AND_ITS_VALUE;
4474
- const name = longOptionName(text);
4682
+ var gitGlobalOptionWidth = (text2) => {
4683
+ if (GIT_GLOBAL_OPTIONS_WITH_A_VALUE.has(text2)) return GIT_OPTION_AND_ITS_VALUE;
4684
+ const name = longOptionName(text2);
4475
4685
  return GIT_GLOBAL_OPTIONS_WITH_A_VALUE.has(name) || GIT_GLOBAL_FLAGS.has(name) ? GIT_OPTION_ALONE : NOT_A_GIT_GLOBAL_OPTION;
4476
4686
  };
4477
4687
  var argsAfterGitGlobalOptions = (args) => {
@@ -4490,7 +4700,7 @@ var gitReadingsPastGlobalOptions = ({ program, args }) => {
4490
4700
  };
4491
4701
  var CURRENT_DIRECTORY_STEP = /\/\.(?=\/)/g;
4492
4702
  var LEADING_CURRENT_DIRECTORY = /^(?:\.\/+)+(?=[^/])/;
4493
- var canonicalPathWord = (text) => text.replace(CURRENT_DIRECTORY_STEP, "").replace(LEADING_CURRENT_DIRECTORY, "");
4703
+ var canonicalPathWord = (text2) => text2.replace(CURRENT_DIRECTORY_STEP, "").replace(LEADING_CURRENT_DIRECTORY, "");
4494
4704
  var verbatimInvocationText = (invocation) => wordsOfInvocation(invocation).map((word) => asOneShellWord(word.text)).join(" ");
4495
4705
  var canonicalInvocationText = (invocation) => invocationTextWith(invocation, (word) => asOneShellWord(canonicalPathWord(word.text)));
4496
4706
  var spellingsOfAnInvocation = (invocation, innermost) => [invocation, innermost, ...gitReadingsPastGlobalOptions(innermost), ...readingsPastGlobalFlags(innermost)].flatMap((reading) => [verbatimInvocationText(reading), canonicalInvocationText(reading)]);
@@ -4529,8 +4739,8 @@ var runsASubstitutionAsAProgram = (command) => {
4529
4739
  return visible !== null && SUBSTITUTION_AS_A_PROGRAM.test(visible);
4530
4740
  };
4531
4741
  var parsedSpelledSegment = (segment) => {
4532
- const text = withoutShellGrouping(segment);
4533
- return { text, invocation: invocationOf(text), heredocs: [], feedsASubstitution: false };
4742
+ const text2 = withoutShellGrouping(segment);
4743
+ return { text: text2, invocation: invocationOf(text2), heredocs: [], feedsASubstitution: false };
4534
4744
  };
4535
4745
  var roughSpelledSegment = ({ invocation, heredocs, feedsASubstitution }) => ({ text: verbatimInvocationText(invocation), invocation, heredocs, feedsASubstitution });
4536
4746
  var segmentHidesWhatItRuns = (segment, innermost, scripts) => programIsHidden(innermost) || scripts.kind === "hidden" || segment.feedsASubstitution && passesAnInlineScript(innermost);
@@ -4671,11 +4881,11 @@ var ASK_CONTEXT_MAX = 500;
4671
4881
  var ASK_AGENT_NAME_MAX = 100;
4672
4882
  var TRUNCATION_MARK = "\u2026";
4673
4883
  var isHighSurrogate = (code) => code >= 55296 && code <= 56319;
4674
- var truncateLine = (text, max, mark = TRUNCATION_MARK) => {
4675
- if (text.length <= max) return text;
4884
+ var truncateLine = (text2, max, mark = TRUNCATION_MARK) => {
4885
+ if (text2.length <= max) return text2;
4676
4886
  const end = max - mark.length;
4677
- const keep = isHighSurrogate(text.charCodeAt(end - 1)) ? end - 1 : end;
4678
- return `${text.slice(0, keep)}${mark}`;
4887
+ const keep = isHighSurrogate(text2.charCodeAt(end - 1)) ? end - 1 : end;
4888
+ return `${text2.slice(0, keep)}${mark}`;
4679
4889
  };
4680
4890
  var APPROVAL_FATIGUE_FLAG_PATTERNS = [
4681
4891
  /\brm\s+-[a-z]*r/i,
@@ -4737,9 +4947,9 @@ var addAlnumTokens = (source, set) => {
4737
4947
  if (raw) set.add(raw);
4738
4948
  }
4739
4949
  };
4740
- var tokenize = (text) => {
4950
+ var tokenize = (text2) => {
4741
4951
  const set = /* @__PURE__ */ new Set();
4742
- for (const raw of text.toLowerCase().split(/[^a-z0-9]+/)) {
4952
+ for (const raw of text2.toLowerCase().split(/[^a-z0-9]+/)) {
4743
4953
  if (raw && !DELTA_STOPWORDS.has(raw)) set.add(raw);
4744
4954
  }
4745
4955
  return set;
@@ -5010,19 +5220,19 @@ var deriveTargetClass = (path) => {
5010
5220
  var bucketArgCount = (n) => n <= 0 ? "none" : n <= 3 ? "few" : "many";
5011
5221
  var bucketLength = (n) => n < 40 ? "short" : n < 200 ? "medium" : "long";
5012
5222
  var deriveArgShape = (isCommand, commandText, path) => {
5013
- const text = isCommand ? commandText : path;
5014
- const tokenCount = isCommand ? text.trim().split(/\s+/).filter(Boolean).length : 0;
5223
+ const text2 = isCommand ? commandText : path;
5224
+ const tokenCount = isCommand ? text2.trim().split(/\s+/).filter(Boolean).length : 0;
5015
5225
  return {
5016
- hasPipe: isCommand && /(?<!\|)\|(?!\|)/.test(text),
5017
- hasRedirect: isCommand && /(?<![0-9])[<>]/.test(text),
5018
- hasChain: isCommand && /&&|\|\||;/.test(text),
5019
- hasSudo: /\bsudo\b/i.test(text),
5020
- hasGlob: isCommand && /[*?]/.test(text),
5021
- hasSubshell: isCommand && /\$\(|`/.test(text),
5022
- touchesSecretPath: SECRET_TARGET_PATTERNS.some((re) => re.test(text)),
5226
+ hasPipe: isCommand && /(?<!\|)\|(?!\|)/.test(text2),
5227
+ hasRedirect: isCommand && /(?<![0-9])[<>]/.test(text2),
5228
+ hasChain: isCommand && /&&|\|\||;/.test(text2),
5229
+ hasSudo: /\bsudo\b/i.test(text2),
5230
+ hasGlob: isCommand && /[*?]/.test(text2),
5231
+ hasSubshell: isCommand && /\$\(|`/.test(text2),
5232
+ touchesSecretPath: SECRET_TARGET_PATTERNS.some((re) => re.test(text2)),
5023
5233
  // The command word itself is not an argument, so subtract one.
5024
5234
  argCountBucket: bucketArgCount(isCommand ? Math.max(0, tokenCount - 1) : 0),
5025
- lengthBucket: bucketLength(text.length)
5235
+ lengthBucket: bucketLength(text2.length)
5026
5236
  };
5027
5237
  };
5028
5238
  var deriveReversibility = (capability, riskClass) => {
@@ -5340,8 +5550,8 @@ var isBlockedActionRequest = (request) => isBlockedActionEvent(request) && block
5340
5550
  var canonicalJsonText = (value) => {
5341
5551
  if (Array.isArray(value)) return `[${value.map(canonicalJsonText).join(",")}]`;
5342
5552
  if (value !== null && typeof value === "object") {
5343
- const record2 = value;
5344
- return `{${Object.keys(record2).filter((key) => record2[key] !== void 0).sort().map((key) => `${JSON.stringify(key)}:${canonicalJsonText(record2[key])}`).join(",")}}`;
5553
+ const record3 = value;
5554
+ return `{${Object.keys(record3).filter((key) => record3[key] !== void 0).sort().map((key) => `${JSON.stringify(key)}:${canonicalJsonText(record3[key])}`).join(",")}}`;
5345
5555
  }
5346
5556
  return JSON.stringify(value) ?? "null";
5347
5557
  };
@@ -5721,11 +5931,11 @@ var elicitationEnum = (property) => {
5721
5931
  return members.length === property.enum.length && members.length >= ELICITATION_MIN_OPTIONS ? members : null;
5722
5932
  };
5723
5933
  var readElicitationFields = (schema) => {
5724
- const record2 = elicitationRecord(schema);
5725
- const properties = elicitationRecord(record2?.properties);
5726
- if (!properties || record2?.type !== "object") return null;
5727
- if (Object.keys(record2).some((key) => !["type", "properties", "required", "$schema"].includes(key))) return null;
5728
- if (record2.required !== void 0 && (!Array.isArray(record2.required) || !record2.required.every((name) => typeof name === "string" && Object.hasOwn(properties, name)))) return null;
5934
+ const record3 = elicitationRecord(schema);
5935
+ const properties = elicitationRecord(record3?.properties);
5936
+ if (!properties || record3?.type !== "object") return null;
5937
+ if (Object.keys(record3).some((key) => !["type", "properties", "required", "$schema"].includes(key))) return null;
5938
+ if (record3.required !== void 0 && (!Array.isArray(record3.required) || !record3.required.every((name) => typeof name === "string" && Object.hasOwn(properties, name)))) return null;
5729
5939
  const entries = Object.entries(properties);
5730
5940
  if (entries.length === 0) return null;
5731
5941
  const fields = [];
@@ -6040,8 +6250,10 @@ export {
6040
6250
  SETUP_AGENT_CHOICES,
6041
6251
  isComputerAgent,
6042
6252
  NO_PAIRING_COMPUTER,
6253
+ readSetupAgentFailures,
6043
6254
  SETUP_CONNECT_MODES,
6044
6255
  isSetupConnectMode,
6256
+ readSetupOutcomeProperties,
6045
6257
  DECLINED_AGENTS_FILE,
6046
6258
  parseDeclinedAgents,
6047
6259
  serializeDeclinedAgents,
@@ -6050,10 +6262,15 @@ export {
6050
6262
  isAutoUpdateResult,
6051
6263
  PERSONAL_QUESTION_CAPABILITY,
6052
6264
  isQuestionOwner,
6265
+ CODEX_NATIVE_APPROVAL_CAPABILITY,
6266
+ CODEX_NATIVE_APPROVAL_METHODS,
6267
+ parseCodexNativeApproval,
6268
+ codexNativeApprovalResponse,
6053
6269
  normalizeKeyScope,
6054
6270
  isApprovalMode,
6055
6271
  approvalModeWithoutLocalPrompt,
6056
6272
  timeoutActionWithoutLocalPrompt,
6273
+ isTimeoutAction,
6057
6274
  AGENT_QUESTION_HEADER_MAX,
6058
6275
  AGENT_QUESTION_OPTION_MAX,
6059
6276
  AGENT_QUESTION_DESCRIPTION_MAX,