pushary 1.9.43 → 1.9.45

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 (105) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +1 -0
  3. package/dist/bin/pushary-bell-hook.js +26 -26
  4. package/dist/bin/pushary-bell.js +11 -11
  5. package/dist/bin/pushary-claude.js +33 -33
  6. package/dist/bin/pushary-clean.js +38 -38
  7. package/dist/bin/pushary-codex-bridge.js +22 -680
  8. package/dist/bin/pushary-codex-hook.js +32 -32
  9. package/dist/bin/pushary-codex-session.d.ts +1 -0
  10. package/dist/bin/pushary-codex-session.js +649 -0
  11. package/dist/bin/pushary-codex.js +12 -12
  12. package/dist/bin/pushary-connect.js +27 -27
  13. package/dist/bin/pushary-cowork.js +6 -6
  14. package/dist/bin/pushary-daemon.js +55 -55
  15. package/dist/bin/pushary-disconnect.js +26 -26
  16. package/dist/bin/pushary-doctor.js +84 -82
  17. package/dist/bin/pushary-elicitation-hook.js +26 -26
  18. package/dist/bin/pushary-gemini-bridge.js +15 -15
  19. package/dist/bin/pushary-gemini-hook.js +29 -29
  20. package/dist/bin/pushary-hook.js +32 -32
  21. package/dist/bin/pushary-login.js +16 -16
  22. package/dist/bin/pushary-logout.js +27 -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 +25 -25
  26. package/dist/bin/pushary-opencode-hook.js +28 -28
  27. package/dist/bin/pushary-permission-denied-hook.js +30 -30
  28. package/dist/bin/pushary-permission-hook.js +29 -29
  29. package/dist/bin/pushary-post-hook.js +25 -25
  30. package/dist/bin/pushary-prompt-hook.js +25 -25
  31. package/dist/bin/pushary-session-end-hook.js +25 -25
  32. package/dist/bin/pushary-session-start-hook.js +30 -30
  33. package/dist/bin/pushary-setup.js +164 -112
  34. package/dist/bin/pushary-stats.js +5 -5
  35. package/dist/bin/pushary-status.js +34 -34
  36. package/dist/bin/pushary-stop-hook.js +25 -25
  37. package/dist/bin/pushary-stopfailure-hook.js +25 -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 -41
  42. package/dist/bin/pushary-wait.js +14 -14
  43. package/dist/bin/pushary.js +7 -6
  44. package/dist/{chunk-HC4DQXAT.js → chunk-2DORVRDB.js} +2 -2
  45. package/dist/{chunk-C6QBNBL4.js → chunk-2FUHSKXH.js} +7 -7
  46. package/dist/{chunk-45W43U2Q.js → chunk-2SXXH6JY.js} +5 -5
  47. package/dist/{chunk-JE6GG3OV.js → chunk-335ZDJ7R.js} +1 -1
  48. package/dist/{chunk-S4QT3YFG.js → chunk-3PM62C2R.js} +15 -15
  49. package/dist/{chunk-Y3N3SYBX.js → chunk-46F4BRUQ.js} +1 -1
  50. package/dist/{chunk-W3BO56VE.js → chunk-4A6VUVXV.js} +1 -1
  51. package/dist/{chunk-LDCRV6HG.js → chunk-57M4ERJK.js} +2 -1
  52. package/dist/{chunk-IMD5FN6Y.js → chunk-5DCZL3BC.js} +3 -3
  53. package/dist/chunk-6JPDAUFP.js +866 -0
  54. package/dist/{chunk-H6V5S52A.js → chunk-6TYKZ4DN.js} +3 -3
  55. package/dist/{chunk-VQL62ECJ.js → chunk-7SGYCU5C.js} +1 -1
  56. package/dist/{chunk-SATOTPXW.js → chunk-7URSJMAB.js} +1 -1
  57. package/dist/{chunk-PIZ65U3D.js → chunk-ASK2MSD2.js} +5 -5
  58. package/dist/{chunk-SCYAXV7U.js → chunk-AUOSFZJ3.js} +7 -7
  59. package/dist/{chunk-LOUZNXTJ.js → chunk-BT57FUMT.js} +2 -2
  60. package/dist/{chunk-4T2TGP4T.js → chunk-CDERSTBO.js} +94 -7
  61. package/dist/{chunk-LAAOHBLO.js → chunk-CFMCV6Z7.js} +2 -2
  62. package/dist/{chunk-ENGASUEL.js → chunk-DSGB5JLG.js} +4 -4
  63. package/dist/{chunk-ZJXEQV3A.js → chunk-ECFEYB6Z.js} +1 -1
  64. package/dist/{chunk-CIERFMQT.js → chunk-EH5ZDG6V.js} +4 -4
  65. package/dist/{chunk-IDVKJICN.js → chunk-EKGQEDQ4.js} +3 -11
  66. package/dist/{chunk-GTOBOC6M.js → chunk-EWC4P4ZL.js} +1 -1
  67. package/dist/{chunk-F7SZ2RCK.js → chunk-FOUK4CBO.js} +4 -4
  68. package/dist/{chunk-LE2YVPAT.js → chunk-GQ5KCVGK.js} +11 -11
  69. package/dist/{chunk-YRE6GUFZ.js → chunk-GZSSAY6N.js} +75 -161
  70. package/dist/{chunk-LWW7SBK3.js → chunk-H4ODQD3Y.js} +2 -2
  71. package/dist/{chunk-O7ADPLBF.js → chunk-HHX6IRSH.js} +1 -1
  72. package/dist/{chunk-H64CU2VB.js → chunk-IFT3GU7Y.js} +2 -2
  73. package/dist/{chunk-FPJHS6PA.js → chunk-IKYI63RF.js} +6 -6
  74. package/dist/{chunk-S3OWTQ6Z.js → chunk-IOVJVGIT.js} +12 -5
  75. package/dist/{chunk-RXXKFM22.js → chunk-K7EGWMDU.js} +370 -138
  76. package/dist/{chunk-AVT7GPOF.js → chunk-KS7NA5CK.js} +10 -10
  77. package/dist/{chunk-A64UCGX3.js → chunk-N2K3BSCA.js} +5 -5
  78. package/dist/{chunk-ZORCUL3Z.js → chunk-NJN5NRHZ.js} +4 -4
  79. package/dist/{chunk-Q7CUTGT4.js → chunk-OHFC3GJY.js} +1 -1
  80. package/dist/{chunk-JW4S4O4W.js → chunk-P2F3JUFX.js} +4 -4
  81. package/dist/{chunk-C54VJJ37.js → chunk-PWUIPQ2I.js} +3 -3
  82. package/dist/{chunk-F5ALKPNS.js → chunk-QQXP3CQA.js} +1 -1
  83. package/dist/{chunk-EA5NWDK7.js → chunk-R7ZQHAVL.js} +29 -0
  84. package/dist/{chunk-V5SUKRRI.js → chunk-RBJWPUI6.js} +4 -4
  85. package/dist/{chunk-J6MVBWF2.js → chunk-RFQWB5ZV.js} +1 -1
  86. package/dist/{chunk-NKBAEGT7.js → chunk-S6EGJBI5.js} +1 -1
  87. package/dist/{chunk-53KLSE2F.js → chunk-SFQSOBLM.js} +3 -3
  88. package/dist/{chunk-MSUMSXTI.js → chunk-SIN7NJD7.js} +1 -1
  89. package/dist/{chunk-55FB6OSG.js → chunk-U45OINYS.js} +1 -1
  90. package/dist/{chunk-TH74SUVV.js → chunk-U6Z56IQS.js} +2 -2
  91. package/dist/{chunk-JJWG7CBT.js → chunk-VO6XI6AX.js} +3 -3
  92. package/dist/{chunk-VIVLJK3T.js → chunk-WDIX4XZH.js} +2 -2
  93. package/dist/{chunk-Y4VZYKSW.js → chunk-WM76AN4X.js} +11 -11
  94. package/dist/{chunk-NV2LARV4.js → chunk-WPPKXVV3.js} +2 -2
  95. package/dist/{chunk-VGPEXMYM.js → chunk-XFHISCJM.js} +42 -7
  96. package/dist/{chunk-C3RVRTHS.js → chunk-YK7FGPYS.js} +3 -3
  97. package/dist/{chunk-JB4JCGRW.js → chunk-YWIFK2UB.js} +2 -2
  98. package/dist/{chunk-O4SYJVAF.js → chunk-YXGWG5PO.js} +5 -5
  99. package/dist/{chunk-XLHFWG2E.js → chunk-ZSY6BWUD.js} +2 -2
  100. package/dist/{global-upgrade-FFWOHOJ4.js → global-upgrade-U6NWZA5W.js} +6 -6
  101. package/dist/{paths-Y2WPCM5Y.js → paths-IQTB3ZZI.js} +2 -2
  102. package/dist/{reapply-N3MV3CKD.js → reapply-LILGWJO3.js} +21 -21
  103. package/dist/src/index.js +19 -19
  104. package/dist/{upgrade-lock-ZXXNRH2P.js → upgrade-lock-2BVFIDU4.js} +3 -3
  105. 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,120 @@ 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 COMPUTER_USE_META_KEYS = [...MCP_META_KEYS, "riskLevel", "subtitle", "tool_call_id"];
2666
+ var computerUseDisplay = (value) => Array.isArray(value) && value.length <= 16 && value.every((item) => record2(item) && keys(item, ["name", "display_name", "value"]) && text(item.name) && text(item.display_name) && text(item.value));
2667
+ var isExecpolicyAmendment = (value) => Array.isArray(value) && value.length > 0 && value.length <= 128 && value.every((token) => typeof token === "string" && token.length <= 16384);
2668
+ var isCommandDecision = (value) => {
2669
+ if (typeof value === "string") return ["accept", "acceptForSession", "decline", "cancel"].includes(value);
2670
+ if (!record2(value) || !keys(value, ["acceptWithExecpolicyAmendment"]) || !record2(value.acceptWithExecpolicyAmendment)) return false;
2671
+ return keys(value.acceptWithExecpolicyAmendment, ["execpolicy_amendment"]) && isExecpolicyAmendment(value.acceptWithExecpolicyAmendment.execpolicy_amendment);
2672
+ };
2673
+ var parseCodexNativeApproval = (value) => {
2674
+ if (!record2(value) || !keys(value, ["method", "params", "changes"]) || !isMethod(value.method) || !record2(value.params) || !boundedJson(value)) return null;
2675
+ const p = value.params;
2676
+ if (!identifier2(p.threadId) || !optionalIdentifier(p.turnId) || !optionalIdentifier(p.itemId)) return null;
2677
+ const request = { method: value.method, params: p, ...Array.isArray(value.changes) ? { changes: value.changes } : {} };
2678
+ const base = {
2679
+ request,
2680
+ threadId: p.threadId,
2681
+ turnId: typeof p.turnId === "string" ? p.turnId : null,
2682
+ itemId: typeof p.itemId === "string" ? p.itemId : null,
2683
+ options: [CODEX_NATIVE_APPROVAL_CHOICES.once, CODEX_NATIVE_APPROVAL_CHOICES.deny],
2684
+ negativeDecision: "decline"
2685
+ };
2686
+ if (value.method === "mcpServer/elicitation/request") {
2687
+ const meta = p._meta;
2688
+ const computerUse = record2(meta) && meta.connector_id === "computer-use";
2689
+ if (value.changes !== void 0 || !keys(p, ["threadId", "turnId", "serverName", "mode", "message", "requestedSchema", "_meta"]) || !(p.mode === "form" || computerUse && (p.mode === "openai/form" || p.mode === "openaiForm")) || !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;
2690
+ if (!record2(meta) || !keys(meta, computerUse ? COMPUTER_USE_META_KEYS : MCP_META_KEYS) || meta.codex_approval_kind !== "mcp_tool_call" || !identifier2(meta.tool_name) || !record2(meta.tool_params) || meta.tool_params_display != null && !(computerUse ? computerUseDisplay(meta.tool_params_display) : record2(meta.tool_params_display))) return null;
2691
+ if (computerUse && (meta.riskLevel !== "low" && meta.riskLevel !== "high" || meta.subtitle != null && !text(meta.subtitle) || !optionalIdentifier(meta.tool_call_id))) return null;
2692
+ if (["codex_requires_user_input", "codex_strict_auto_review", "codex_sensitive_action"].some((key) => meta[key] != null && typeof meta[key] !== "boolean")) return null;
2693
+ if (meta.approvals_reviewer != null && meta.approvals_reviewer !== "user") return null;
2694
+ if (meta.codex_request_type != null && meta.codex_request_type !== "approval_request") return null;
2695
+ if (["source", "connector_id", "connector_name", "connector_description", "tool_title", "tool_description"].some((key) => meta[key] != null && !text(meta[key]))) return null;
2696
+ const persistence = meta.persist == null ? [] : typeof meta.persist === "string" ? [meta.persist] : meta.persist;
2697
+ if (!Array.isArray(persistence) || persistence.some((v) => v !== "session" && v !== "always")) return null;
2698
+ if (computerUse) {
2699
+ if (!persistence.includes("session")) return null;
2700
+ return {
2701
+ ...base,
2702
+ toolName: `mcp__${p.serverName}__${meta.tool_name}`,
2703
+ toolInputs: [meta.tool_params],
2704
+ question: p.message,
2705
+ detail: [`Risk: ${meta.riskLevel}`, meta.subtitle, JSON.stringify(meta.tool_params)].filter(Boolean).join("\n"),
2706
+ options: [CODEX_NATIVE_APPROVAL_CHOICES.session, CODEX_NATIVE_APPROVAL_CHOICES.deny]
2707
+ };
2708
+ }
2709
+ return {
2710
+ ...base,
2711
+ toolName: `mcp__${p.serverName}__${meta.tool_name}`,
2712
+ toolInputs: [meta.tool_params],
2713
+ question: p.message,
2714
+ detail: JSON.stringify(meta.tool_params),
2715
+ options: persistence.includes("session") ? [CODEX_NATIVE_APPROVAL_CHOICES.once, CODEX_NATIVE_APPROVAL_CHOICES.session, CODEX_NATIVE_APPROVAL_CHOICES.deny] : base.options
2716
+ };
2717
+ }
2718
+ if (!identifier2(p.turnId) || !identifier2(p.itemId) || !Number.isSafeInteger(p.startedAtMs) || p.reason != null && !text(p.reason)) return null;
2719
+ if (value.method === "item/commandExecution/requestApproval") {
2720
+ 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;
2721
+ const decisions = p.availableDecisions ?? ["accept", "decline", "cancel"];
2722
+ if (!Array.isArray(decisions) || !decisions.includes("accept") || !decisions.some((v) => v === "decline" || v === "cancel") || !decisions.every(isCommandDecision)) return null;
2723
+ return {
2724
+ ...base,
2725
+ toolName: "Bash",
2726
+ toolInputs: [{ command: p.command }],
2727
+ cwd: p.cwd,
2728
+ question: "Allow this command once?",
2729
+ detail: p.command,
2730
+ negativeDecision: decisions.includes("decline") ? "decline" : "cancel"
2731
+ };
2732
+ }
2733
+ if (!keys(p, [...BASE_KEYS, "grantRoot"]) || p.grantRoot != null || !Array.isArray(value.changes) || value.changes.length === 0 || value.changes.length > 32) return null;
2734
+ const paths = [], diffs = [];
2735
+ for (const change of value.changes) {
2736
+ 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;
2737
+ paths.push(change.path);
2738
+ diffs.push(`${change.path}
2739
+ ${change.diff}`);
2740
+ }
2741
+ return {
2742
+ ...base,
2743
+ toolName: "Edit",
2744
+ toolInputs: paths.map((file_path) => ({ file_path })),
2745
+ scopePaths: paths,
2746
+ question: `Allow these ${paths.length} file changes once?`,
2747
+ detail: diffs.join("\n\n")
2748
+ };
2749
+ };
2750
+ var codexNativeApprovalResponse = (approval, answer) => {
2751
+ const accepted = approval.options.includes(answer) && (answer === CODEX_NATIVE_APPROVAL_CHOICES.once || answer === CODEX_NATIVE_APPROVAL_CHOICES.session);
2752
+ if (approval.request.method === "mcpServer/elicitation/request") return {
2753
+ action: accepted ? "accept" : "decline",
2754
+ content: null,
2755
+ _meta: accepted && answer === CODEX_NATIVE_APPROVAL_CHOICES.session ? { persist: "session" } : null
2756
+ };
2757
+ return { decision: accepted ? "accept" : approval.negativeDecision };
2758
+ };
2759
+
2537
2760
  // ../contracts/src/index.ts
2538
2761
  var KEY_SCOPES = ["full_access", "agent", "connector", "bound"];
2539
2762
  var normalizeKeyScope = (value) => typeof value === "string" && KEY_SCOPES.includes(value) ? value : null;
@@ -2561,6 +2784,8 @@ var approvalModeWithoutLocalPrompt = (mode) => {
2561
2784
  };
2562
2785
  var TIMEOUT_ACTION_THAT_REFUSES = "deny";
2563
2786
  var timeoutActionWithoutLocalPrompt = ({ mode, timeoutAction }) => mode !== "push_only" && timeoutAction === "approve" ? TIMEOUT_ACTION_THAT_REFUSES : timeoutAction;
2787
+ var TIMEOUT_ACTIONS = ["approve", "deny", "escalate", "wait"];
2788
+ var isTimeoutAction = (value) => typeof value === "string" && TIMEOUT_ACTIONS.includes(value);
2564
2789
  var MAX_AGENT_QUESTIONS = 4;
2565
2790
  var AGENT_QUESTION_HEADER_MAX = 40;
2566
2791
  var AGENT_QUESTION_OPTION_MAX = 100;
@@ -2608,9 +2833,9 @@ var isAgentQuestionSet = (value) => {
2608
2833
  const labels = /* @__PURE__ */ new Set();
2609
2834
  for (const option of question.options) {
2610
2835
  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;
2836
+ const record3 = option;
2837
+ const label = record3.label;
2838
+ if (typeof label !== "string" || label.length === 0 || labels.has(label) || record3.description !== void 0 && typeof record3.description !== "string") return false;
2614
2839
  labels.add(label);
2615
2840
  }
2616
2841
  questions.add(question.question);
@@ -2727,7 +2952,7 @@ var HOOK_HOLD_BUDGET_FLAG = "--hold-budget";
2727
2952
  var HOOK_HOLD_BUDGET_ENV = "PUSHARY_HOLD_BUDGET_SECONDS";
2728
2953
  var HOOK_BRIDGE_SOURCE_FLAG = "--source";
2729
2954
  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;
2955
+ var hookHoldBudgetSeconds = (text2) => text2 !== void 0 && HOOK_HOLD_BUDGET_SECONDS.test(text2) ? Number(text2) : void 0;
2731
2956
  var hookHoldBudgetArgument = (seconds) => `${HOOK_HOLD_BUDGET_FLAG}=${seconds}`;
2732
2957
  var withHookHoldBudget = (command, holdBudgetSeconds) => holdBudgetSeconds === void 0 ? command : `${command} ${hookHoldBudgetArgument(holdBudgetSeconds)}`;
2733
2958
  var registeredHookHoldBudget = (args) => {
@@ -2836,8 +3061,8 @@ var tokenizeGlob = (glob) => {
2836
3061
  return tokens;
2837
3062
  };
2838
3063
  var SLASH = "/".charCodeAt(0);
2839
- var matchGlobTokens = (tokens, text) => {
2840
- const n = text.length;
3064
+ var matchGlobTokens = (tokens, text2) => {
3065
+ const n = text2.length;
2841
3066
  let reachable = new Uint8Array(n + 1);
2842
3067
  reachable[0] = 1;
2843
3068
  for (const token of tokens) {
@@ -2845,13 +3070,13 @@ var matchGlobTokens = (tokens, text) => {
2845
3070
  if (token.kind === "literal") {
2846
3071
  const { value } = token;
2847
3072
  for (let p = 0; p <= n - value.length; p += 1) {
2848
- if (reachable[p] && text.startsWith(value, p)) next[p + value.length] = 1;
3073
+ if (reachable[p] && text2.startsWith(value, p)) next[p + value.length] = 1;
2849
3074
  }
2850
3075
  } else {
2851
3076
  const spansSeparators = token.kind === "globstar";
2852
3077
  let open = 0;
2853
3078
  for (let p = 0; p <= n; p += 1) {
2854
- if (!spansSeparators && p > 0 && text.charCodeAt(p - 1) === SLASH) open = 0;
3079
+ if (!spansSeparators && p > 0 && text2.charCodeAt(p - 1) === SLASH) open = 0;
2855
3080
  if (reachable[p]) open = 1;
2856
3081
  if (open) next[p] = 1;
2857
3082
  }
@@ -3232,7 +3457,7 @@ var argumentsMayExpand = (segment) => {
3232
3457
  const visible = shellVisibleText(segment);
3233
3458
  return visible === null || EXPANSION_THAT_CAN_BECOME_A_FLAG.test(visible.replace(SHELL_QUOTE_CHARACTERS, ""));
3234
3459
  };
3235
- var blankedSafeRedirections = (text) => text.replace(SAFE_REDIRECTION, (redirection) => " ".repeat(redirection.length));
3460
+ var blankedSafeRedirections = (text2) => text2.replace(SAFE_REDIRECTION, (redirection) => " ".repeat(redirection.length));
3236
3461
  var segmentsSplitWhereVisible = (command, visible, separators) => {
3237
3462
  const segments = [];
3238
3463
  let start = 0;
@@ -3381,10 +3606,10 @@ var DESTRUCTIVE_WORDS_IN_ANY_CASE_BY_COMMAND = /* @__PURE__ */ new Map([
3381
3606
  ]);
3382
3607
  var namesDestructiveWordInAnyCase = (name, texts) => {
3383
3608
  const words = DESTRUCTIVE_WORDS_IN_ANY_CASE_BY_COMMAND.get(name);
3384
- return words !== void 0 && texts.some((text) => words.has(text.toLowerCase()));
3609
+ return words !== void 0 && texts.some((text2) => words.has(text2.toLowerCase()));
3385
3610
  };
3386
3611
  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}`));
3612
+ 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
3613
  var RUNNER_SUBCOMMANDS = /* @__PURE__ */ new Set(["exec", "dlx"]);
3389
3614
  var SUBCOMMAND_CLIS = /* @__PURE__ */ new Set([
3390
3615
  "git",
@@ -3511,7 +3736,7 @@ var argumentsHideTheEffect = (name, args) => {
3511
3736
  const texts = args.map((arg) => arg.text);
3512
3737
  if (INLINE_CODE_INTERPRETERS.has(name.replace(/\d+(?:\.\d+)*$/, "")) && interpreterRunsUnreadableCode(texts)) return true;
3513
3738
  const destructiveArguments = destructiveArgumentsOf(name, args);
3514
- if (destructiveArguments && texts.some((text) => namesDestructiveArgument(text, destructiveArguments))) return true;
3739
+ if (destructiveArguments && texts.some((text2) => namesDestructiveArgument(text2, destructiveArguments))) return true;
3515
3740
  if (namesDestructiveWordInAnyCase(name, texts)) return true;
3516
3741
  if (!SUBCOMMAND_CLIS.has(name)) return false;
3517
3742
  const meaningful = argsAfterHarmlessGlobalFlags(args);
@@ -3530,7 +3755,7 @@ var normalizedInvocation = (invocation) => invocationTextWith(invocation, (word)
3530
3755
  var SHELL_METACHARACTER = /[\s;&|<>()$`\\"'*?[\]#~{}!]/;
3531
3756
  var SINGLE_QUOTE2 = "'";
3532
3757
  var ESCAPED_SINGLE_QUOTE = `'\\''`;
3533
- var asOneShellWord = (text) => SHELL_METACHARACTER.test(text) ? `${SINGLE_QUOTE2}${text.replaceAll(SINGLE_QUOTE2, ESCAPED_SINGLE_QUOTE)}${SINGLE_QUOTE2}` : text;
3758
+ var asOneShellWord = (text2) => SHELL_METACHARACTER.test(text2) ? `${SINGLE_QUOTE2}${text2.replaceAll(SINGLE_QUOTE2, ESCAPED_SINGLE_QUOTE)}${SINGLE_QUOTE2}` : text2;
3534
3759
  var quotedInvocation = (invocation) => invocationTextWith(invocation, (word) => asOneShellWord(word.text));
3535
3760
  var normalizedCommand = (command) => {
3536
3761
  const segments = readableCommandSegments(command);
@@ -3631,8 +3856,8 @@ var SQL_WRITE_STATEMENT = new RegExp([
3631
3856
  String.raw`\.(?:insert|update|delete|replace|remove|drop|rename|create|bulkwrite|findoneand)\w*\s*\(`
3632
3857
  ].join("|"), "i");
3633
3858
  var SQL_READ_PHRASE = /\bshow\s+create\b/gi;
3634
- var sqlTextWrites = (text) => {
3635
- const statement = text.replace(SQL_READ_PHRASE, "");
3859
+ var sqlTextWrites = (text2) => {
3860
+ const statement = text2.replace(SQL_READ_PHRASE, "");
3636
3861
  return SQL_WRITE_STATEMENT.test(statement) || SQL_CLIENT_FILE_COMMAND.test(statement);
3637
3862
  };
3638
3863
  var writesThroughSql = (sql, lexicon) => {
@@ -3648,7 +3873,7 @@ var SQL_CLIENT_FILE_COMMAND = new RegExp([
3648
3873
  var SHORT_FLAG_CLUSTER_ONLY = /^-([A-Za-z0-9]+)$/;
3649
3874
  var LEADING_OPTION_DASHES = /^-+/;
3650
3875
  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("--"));
3876
+ var shortFlagOf = (flags, text2) => [...flags].find((flag) => /^-[A-Za-z]$/.test(flag) && text2.startsWith(flag) && text2.length > flag.length && !text2.startsWith("--"));
3652
3877
  var sqlArgumentAt = (args, index, syntax) => {
3653
3878
  const arg = args[index];
3654
3879
  if (arg === void 0) return NO_SQL;
@@ -3668,7 +3893,7 @@ var sqlArgumentAt = (args, index, syntax) => {
3668
3893
  if (cluster && cluster.length > 1 && syntax.inlineFlags.has(last)) return valueOf(next);
3669
3894
  return { script: false, sql: arg.text.replace(LEADING_OPTION_DASHES, ""), hidden: false };
3670
3895
  };
3671
- var namesALongFlagValue = (text, flags) => [...flags].some((flag) => flag.startsWith("--") && text.startsWith(`${flag}${FLAG_VALUE_SEPARATOR}`));
3896
+ var namesALongFlagValue = (text2, flags) => [...flags].some((flag) => flag.startsWith("--") && text2.startsWith(`${flag}${FLAG_VALUE_SEPARATOR}`));
3672
3897
  var positionalSqlIsHidden = (args, syntax) => syntax.positionalSql && args.filter((arg) => !arg.text.startsWith("-")).slice(1).some((arg) => arg.expands);
3673
3898
  var sqlClientSyntaxOf = ({ program }) => program === void 0 ? void 0 : SQL_CLIENT_SYNTAX.get(basenameOf(program.text));
3674
3899
  var sqlClientChangesData = (invocation) => {
@@ -4042,7 +4267,7 @@ var gitDiscardsWork = ({ program, args }) => {
4042
4267
  const [subcommand, ...rest] = argsAfterHarmlessGlobalFlags(args);
4043
4268
  const discards = GIT_WORK_DISCARDERS.get(subcommand?.text ?? "");
4044
4269
  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)));
4270
+ return discards !== void 0 && discards(texts.filter((text2) => FLAG.test(text2)), texts.filter((text2) => !FLAG.test(text2)));
4046
4271
  };
4047
4272
  var PACKAGE_MANAGERS = /* @__PURE__ */ new Set([
4048
4273
  "npm",
@@ -4190,25 +4415,25 @@ var WRAPPER_SYNTAX = /* @__PURE__ */ new Map([
4190
4415
  ]);
4191
4416
  var EVAL = "eval";
4192
4417
  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;
4418
+ var shortValueOptionPosition = (text2, options) => {
4419
+ if (!text2.startsWith("-") || text2.startsWith("--")) return -1;
4420
+ for (let index = 1; index < text2.length; index += 1) {
4421
+ if (options.has(`-${text2[index]}`)) return index;
4197
4422
  }
4198
4423
  return -1;
4199
4424
  };
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;
4425
+ var wrapperOptionConsumesNextWord = (text2, options) => {
4426
+ if (options.has(text2)) return true;
4427
+ const position = shortValueOptionPosition(text2, options);
4428
+ return position !== -1 && position === text2.length - 1;
4204
4429
  };
4205
4430
  var commandStartAfterWrapper = (words, syntax) => {
4206
4431
  let index = 0;
4207
4432
  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;
4433
+ const text2 = words[index]?.text ?? "";
4434
+ if (text2 === END_OF_OPTIONS3) return index + 1 + syntax.operandsBeforeTheCommand;
4435
+ if (!SHELL_ENV_ASSIGNMENT.test(text2) && (!FLAG.test(text2) || text2 === STANDARD_INPUT_ARGUMENT)) break;
4436
+ index += wrapperOptionConsumesNextWord(text2, syntax.optionsWithAValue) ? 2 : 1;
4212
4437
  }
4213
4438
  return index + syntax.operandsBeforeTheCommand;
4214
4439
  };
@@ -4310,16 +4535,16 @@ var pipesFetchedCodeIntoAnInterpreter = (command, invocations) => invocations.so
4310
4535
  var WORDS_THAT_OPEN_A_COMMAND = String.raw`if|then|elif|else|do|while|until|!`;
4311
4536
  var SHELL_GROUPING_PREFIX = new RegExp(String.raw`^\s*(?:(?:${WORDS_THAT_OPEN_A_COMMAND})\s+|[({]\s*)+`);
4312
4537
  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) ?? "";
4538
+ var occurrencesOf = (text2, character) => text2.split(character).length - 1;
4539
+ var closesAGroupItDidNotOpen = (text2) => {
4540
+ const last = text2.at(-1) ?? "";
4316
4541
  const opener = GROUP_OPENER_BY_CLOSER.get(last);
4317
- return opener !== void 0 && occurrencesOf(text, last) > occurrencesOf(text, opener);
4542
+ return opener !== void 0 && occurrencesOf(text2, last) > occurrencesOf(text2, opener);
4318
4543
  };
4319
4544
  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;
4545
+ let text2 = segment.replace(SHELL_GROUPING_PREFIX, "").trimEnd();
4546
+ while (closesAGroupItDidNotOpen(text2)) text2 = text2.slice(0, -1).trimEnd();
4547
+ return text2;
4323
4548
  };
4324
4549
  var HEREDOC_OPERATOR = /(?<!<)\d*<<(?!<)-?[ \t]*(?:'([A-Za-z_]\w*)'|"([A-Za-z_]\w*)"|\\?([A-Za-z_]\w*))/g;
4325
4550
  var HEREDOC_MARK = "\uE001";
@@ -4352,24 +4577,24 @@ var SEPARATORS_INSIDE_DOUBLE_QUOTES = /* @__PURE__ */ new Set(["$(", "`", ")"]);
4352
4577
  var PIPE3 = "|";
4353
4578
  var SUBSTITUTION_OPENERS = /* @__PURE__ */ new Set(["$(", "`"]);
4354
4579
  var QUOTE_CHARACTERS = /['"]/g;
4355
- var roughPiecesOf = (text) => {
4580
+ var roughPiecesOf = (text2) => {
4356
4581
  const pieces = [];
4357
4582
  let current = "";
4358
4583
  let before = "";
4359
4584
  let quote = null;
4360
- for (let index = 0; index < text.length; index += 1) {
4361
- const char = text.charAt(index);
4585
+ for (let index = 0; index < text2.length; index += 1) {
4586
+ const char = text2.charAt(index);
4362
4587
  if (quote === "'") {
4363
4588
  current += char;
4364
4589
  if (char === "'") quote = null;
4365
4590
  continue;
4366
4591
  }
4367
4592
  if (char === "\\") {
4368
- current += text.slice(index, index + 2);
4593
+ current += text2.slice(index, index + 2);
4369
4594
  index += 1;
4370
4595
  continue;
4371
4596
  }
4372
- const separator = ROUGH_SEPARATORS.find((candidate) => text.startsWith(candidate, index) && (quote === null || SEPARATORS_INSIDE_DOUBLE_QUOTES.has(candidate)));
4597
+ const separator = ROUGH_SEPARATORS.find((candidate) => text2.startsWith(candidate, index) && (quote === null || SEPARATORS_INSIDE_DOUBLE_QUOTES.has(candidate)));
4373
4598
  if (separator !== void 0) {
4374
4599
  pieces.push({ text: current, before });
4375
4600
  current = "";
@@ -4382,14 +4607,14 @@ var roughPiecesOf = (text) => {
4382
4607
  }
4383
4608
  return [...pieces, { text: current, before }];
4384
4609
  };
4385
- var invocationOfRoughPiece = (text) => {
4386
- const piece = withoutShellGrouping(text.replaceAll(REDIRECTED_INPUT_MARK, "").replaceAll(HEREDOC_MARK, ""));
4610
+ var invocationOfRoughPiece = (text2) => {
4611
+ const piece = withoutShellGrouping(text2.replaceAll(REDIRECTED_INPUT_MARK, "").replaceAll(HEREDOC_MARK, ""));
4387
4612
  const parsed = invocationOf(piece);
4388
4613
  return parsed.program !== void 0 ? parsed : invocationOf(piece.replace(QUOTE_CHARACTERS, ""));
4389
4614
  };
4390
4615
  var roughSegmentsOf = (command) => {
4391
- const { text, bodies } = withHeredocBodiesSetAside(commandForReading(command));
4392
- const pieces = roughPiecesOf(text.replace(INPUT_REDIRECTION, ` ${REDIRECTED_INPUT_MARK} `).replace(OUTPUT_REDIRECTION, " "));
4616
+ const { text: text2, bodies } = withHeredocBodiesSetAside(commandForReading(command));
4617
+ const pieces = roughPiecesOf(text2.replace(INPUT_REDIRECTION, ` ${REDIRECTED_INPUT_MARK} `).replace(OUTPUT_REDIRECTION, " "));
4393
4618
  let heredocsSeen = 0;
4394
4619
  return pieces.map((piece, index) => {
4395
4620
  const heredocCount = occurrencesOf(piece.text, HEREDOC_MARK);
@@ -4426,7 +4651,7 @@ var commandHasAVisibleConsequenceAt = (toolName, command, depth) => {
4426
4651
  };
4427
4652
  var posixCommandOf = (words) => words.map(asOneShellWord).join(" ");
4428
4653
  var posixShellJudgeFor = (toolName) => ({
4429
- namesADestructiveAction: (text) => classifyDecisionRisk(toolName, text) === "destructive",
4654
+ namesADestructiveAction: (text2) => classifyDecisionRisk(toolName, text2) === "destructive",
4430
4655
  invocationShowsAConsequence: (invocation) => invocationHasAVisibleConsequence(SHELL_TOOL, invocation, 0),
4431
4656
  commandShowsAConsequence: (words) => commandHasAVisibleConsequenceAt(SHELL_TOOL, posixCommandOf(words), 1),
4432
4657
  onlyReads: (words) => isSafeReadOnlyCommand(posixCommandOf(words)),
@@ -4469,9 +4694,9 @@ var GIT_GLOBAL_FLAGS = /* @__PURE__ */ new Set([
4469
4694
  var GIT_OPTION_AND_ITS_VALUE = 2;
4470
4695
  var GIT_OPTION_ALONE = 1;
4471
4696
  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);
4697
+ var gitGlobalOptionWidth = (text2) => {
4698
+ if (GIT_GLOBAL_OPTIONS_WITH_A_VALUE.has(text2)) return GIT_OPTION_AND_ITS_VALUE;
4699
+ const name = longOptionName(text2);
4475
4700
  return GIT_GLOBAL_OPTIONS_WITH_A_VALUE.has(name) || GIT_GLOBAL_FLAGS.has(name) ? GIT_OPTION_ALONE : NOT_A_GIT_GLOBAL_OPTION;
4476
4701
  };
4477
4702
  var argsAfterGitGlobalOptions = (args) => {
@@ -4490,7 +4715,7 @@ var gitReadingsPastGlobalOptions = ({ program, args }) => {
4490
4715
  };
4491
4716
  var CURRENT_DIRECTORY_STEP = /\/\.(?=\/)/g;
4492
4717
  var LEADING_CURRENT_DIRECTORY = /^(?:\.\/+)+(?=[^/])/;
4493
- var canonicalPathWord = (text) => text.replace(CURRENT_DIRECTORY_STEP, "").replace(LEADING_CURRENT_DIRECTORY, "");
4718
+ var canonicalPathWord = (text2) => text2.replace(CURRENT_DIRECTORY_STEP, "").replace(LEADING_CURRENT_DIRECTORY, "");
4494
4719
  var verbatimInvocationText = (invocation) => wordsOfInvocation(invocation).map((word) => asOneShellWord(word.text)).join(" ");
4495
4720
  var canonicalInvocationText = (invocation) => invocationTextWith(invocation, (word) => asOneShellWord(canonicalPathWord(word.text)));
4496
4721
  var spellingsOfAnInvocation = (invocation, innermost) => [invocation, innermost, ...gitReadingsPastGlobalOptions(innermost), ...readingsPastGlobalFlags(innermost)].flatMap((reading) => [verbatimInvocationText(reading), canonicalInvocationText(reading)]);
@@ -4529,8 +4754,8 @@ var runsASubstitutionAsAProgram = (command) => {
4529
4754
  return visible !== null && SUBSTITUTION_AS_A_PROGRAM.test(visible);
4530
4755
  };
4531
4756
  var parsedSpelledSegment = (segment) => {
4532
- const text = withoutShellGrouping(segment);
4533
- return { text, invocation: invocationOf(text), heredocs: [], feedsASubstitution: false };
4757
+ const text2 = withoutShellGrouping(segment);
4758
+ return { text: text2, invocation: invocationOf(text2), heredocs: [], feedsASubstitution: false };
4534
4759
  };
4535
4760
  var roughSpelledSegment = ({ invocation, heredocs, feedsASubstitution }) => ({ text: verbatimInvocationText(invocation), invocation, heredocs, feedsASubstitution });
4536
4761
  var segmentHidesWhatItRuns = (segment, innermost, scripts) => programIsHidden(innermost) || scripts.kind === "hidden" || segment.feedsASubstitution && passesAnInlineScript(innermost);
@@ -4671,11 +4896,11 @@ var ASK_CONTEXT_MAX = 500;
4671
4896
  var ASK_AGENT_NAME_MAX = 100;
4672
4897
  var TRUNCATION_MARK = "\u2026";
4673
4898
  var isHighSurrogate = (code) => code >= 55296 && code <= 56319;
4674
- var truncateLine = (text, max, mark = TRUNCATION_MARK) => {
4675
- if (text.length <= max) return text;
4899
+ var truncateLine = (text2, max, mark = TRUNCATION_MARK) => {
4900
+ if (text2.length <= max) return text2;
4676
4901
  const end = max - mark.length;
4677
- const keep = isHighSurrogate(text.charCodeAt(end - 1)) ? end - 1 : end;
4678
- return `${text.slice(0, keep)}${mark}`;
4902
+ const keep = isHighSurrogate(text2.charCodeAt(end - 1)) ? end - 1 : end;
4903
+ return `${text2.slice(0, keep)}${mark}`;
4679
4904
  };
4680
4905
  var APPROVAL_FATIGUE_FLAG_PATTERNS = [
4681
4906
  /\brm\s+-[a-z]*r/i,
@@ -4737,9 +4962,9 @@ var addAlnumTokens = (source, set) => {
4737
4962
  if (raw) set.add(raw);
4738
4963
  }
4739
4964
  };
4740
- var tokenize = (text) => {
4965
+ var tokenize = (text2) => {
4741
4966
  const set = /* @__PURE__ */ new Set();
4742
- for (const raw of text.toLowerCase().split(/[^a-z0-9]+/)) {
4967
+ for (const raw of text2.toLowerCase().split(/[^a-z0-9]+/)) {
4743
4968
  if (raw && !DELTA_STOPWORDS.has(raw)) set.add(raw);
4744
4969
  }
4745
4970
  return set;
@@ -5010,19 +5235,19 @@ var deriveTargetClass = (path) => {
5010
5235
  var bucketArgCount = (n) => n <= 0 ? "none" : n <= 3 ? "few" : "many";
5011
5236
  var bucketLength = (n) => n < 40 ? "short" : n < 200 ? "medium" : "long";
5012
5237
  var deriveArgShape = (isCommand, commandText, path) => {
5013
- const text = isCommand ? commandText : path;
5014
- const tokenCount = isCommand ? text.trim().split(/\s+/).filter(Boolean).length : 0;
5238
+ const text2 = isCommand ? commandText : path;
5239
+ const tokenCount = isCommand ? text2.trim().split(/\s+/).filter(Boolean).length : 0;
5015
5240
  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)),
5241
+ hasPipe: isCommand && /(?<!\|)\|(?!\|)/.test(text2),
5242
+ hasRedirect: isCommand && /(?<![0-9])[<>]/.test(text2),
5243
+ hasChain: isCommand && /&&|\|\||;/.test(text2),
5244
+ hasSudo: /\bsudo\b/i.test(text2),
5245
+ hasGlob: isCommand && /[*?]/.test(text2),
5246
+ hasSubshell: isCommand && /\$\(|`/.test(text2),
5247
+ touchesSecretPath: SECRET_TARGET_PATTERNS.some((re) => re.test(text2)),
5023
5248
  // The command word itself is not an argument, so subtract one.
5024
5249
  argCountBucket: bucketArgCount(isCommand ? Math.max(0, tokenCount - 1) : 0),
5025
- lengthBucket: bucketLength(text.length)
5250
+ lengthBucket: bucketLength(text2.length)
5026
5251
  };
5027
5252
  };
5028
5253
  var deriveReversibility = (capability, riskClass) => {
@@ -5340,8 +5565,8 @@ var isBlockedActionRequest = (request) => isBlockedActionEvent(request) && block
5340
5565
  var canonicalJsonText = (value) => {
5341
5566
  if (Array.isArray(value)) return `[${value.map(canonicalJsonText).join(",")}]`;
5342
5567
  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(",")}}`;
5568
+ const record3 = value;
5569
+ return `{${Object.keys(record3).filter((key) => record3[key] !== void 0).sort().map((key) => `${JSON.stringify(key)}:${canonicalJsonText(record3[key])}`).join(",")}}`;
5345
5570
  }
5346
5571
  return JSON.stringify(value) ?? "null";
5347
5572
  };
@@ -5721,11 +5946,11 @@ var elicitationEnum = (property) => {
5721
5946
  return members.length === property.enum.length && members.length >= ELICITATION_MIN_OPTIONS ? members : null;
5722
5947
  };
5723
5948
  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;
5949
+ const record3 = elicitationRecord(schema);
5950
+ const properties = elicitationRecord(record3?.properties);
5951
+ if (!properties || record3?.type !== "object") return null;
5952
+ if (Object.keys(record3).some((key) => !["type", "properties", "required", "$schema"].includes(key))) return null;
5953
+ if (record3.required !== void 0 && (!Array.isArray(record3.required) || !record3.required.every((name) => typeof name === "string" && Object.hasOwn(properties, name)))) return null;
5729
5954
  const entries = Object.entries(properties);
5730
5955
  if (entries.length === 0) return null;
5731
5956
  const fields = [];
@@ -6040,8 +6265,10 @@ export {
6040
6265
  SETUP_AGENT_CHOICES,
6041
6266
  isComputerAgent,
6042
6267
  NO_PAIRING_COMPUTER,
6268
+ readSetupAgentFailures,
6043
6269
  SETUP_CONNECT_MODES,
6044
6270
  isSetupConnectMode,
6271
+ readSetupOutcomeProperties,
6045
6272
  DECLINED_AGENTS_FILE,
6046
6273
  parseDeclinedAgents,
6047
6274
  serializeDeclinedAgents,
@@ -6050,10 +6277,15 @@ export {
6050
6277
  isAutoUpdateResult,
6051
6278
  PERSONAL_QUESTION_CAPABILITY,
6052
6279
  isQuestionOwner,
6280
+ CODEX_NATIVE_APPROVAL_CAPABILITY,
6281
+ CODEX_NATIVE_APPROVAL_METHODS,
6282
+ parseCodexNativeApproval,
6283
+ codexNativeApprovalResponse,
6053
6284
  normalizeKeyScope,
6054
6285
  isApprovalMode,
6055
6286
  approvalModeWithoutLocalPrompt,
6056
6287
  timeoutActionWithoutLocalPrompt,
6288
+ isTimeoutAction,
6057
6289
  AGENT_QUESTION_HEADER_MAX,
6058
6290
  AGENT_QUESTION_OPTION_MAX,
6059
6291
  AGENT_QUESTION_DESCRIPTION_MAX,