koneck 2.72.0 → 2.73.1

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.
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Reading the system clipboard, for when the terminal's own paste will not do.
3
+ *
4
+ * Pasting into a terminal is not one mechanism, it is several: bracketed paste if the terminal
5
+ * offers it, a plain burst of characters if not, a middle-click that KONECK may have taken over for
6
+ * its own mouse handling, and on Windows a Ctrl+V that some hosts deliver as a control code rather
7
+ * than as text. Somebody trying to put an API key into a prompt does not care which of those their
8
+ * terminal does, and telling them to type a sixty-character secret by hand is not an answer.
9
+ *
10
+ * So the prompt can go and fetch it. Every desktop already has a command for this, and KONECK
11
+ * already shells out to their write-side counterparts for /copy; this is the same list read the
12
+ * other way round.
13
+ */
14
+ export interface ClipboardRead {
15
+ ok: boolean;
16
+ text: string;
17
+ /** Which command answered, so it can be named. */
18
+ by?: string;
19
+ /** Why nothing came back, when nothing did. */
20
+ reason?: string;
21
+ }
22
+ /**
23
+ * What is on the clipboard, or why it could not be read.
24
+ *
25
+ * Each reader gets a short deadline: a clipboard tool that hangs — xclip waiting on an X server
26
+ * that is not there is the usual way — must not hold a keystroke open. Failure is ordinary and is
27
+ * reported rather than thrown: a machine reached over SSH has no clipboard, and that is a fact
28
+ * about the machine rather than an error in the program.
29
+ */
30
+ export declare function readClipboard(readers?: ReadonlyArray<{
31
+ file: string;
32
+ args: string[];
33
+ }>, timeoutMs?: number): Promise<ClipboardRead>;
34
+ /**
35
+ * A pasted secret, made safe to use as one.
36
+ *
37
+ * Three things go, each for its own reason. Surrounding whitespace, because a key copied out of a
38
+ * file or a password manager carries a trailing newline that is not part of it. Bracketed paste
39
+ * markers, because a terminal that announces a paste mid-chunk can leave the literal text "[200~"
40
+ * in the field, and a key with that in front of it fails at the provider with an authentication
41
+ * error that says nothing about where it came from. And control characters, which are invalid in an
42
+ * HTTP header — a key carrying one is rejected by the transport before the provider ever sees it,
43
+ * which is the least informative way for this to go wrong.
44
+ */
45
+ export declare function cleanPastedSecret(text: string): string;
46
+ //# sourceMappingURL=clipboard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clipboard.d.ts","sourceRoot":"","sources":["../src/clipboard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAaH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,OAAO,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,+CAA+C;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,OAAO,GAAE,aAAa,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAAW,EAClE,SAAS,SAAQ,GAChB,OAAO,CAAC,aAAa,CAAC,CAmBxB;AAeD;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKtD"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Reading the system clipboard, for when the terminal's own paste will not do.
3
+ *
4
+ * Pasting into a terminal is not one mechanism, it is several: bracketed paste if the terminal
5
+ * offers it, a plain burst of characters if not, a middle-click that KONECK may have taken over for
6
+ * its own mouse handling, and on Windows a Ctrl+V that some hosts deliver as a control code rather
7
+ * than as text. Somebody trying to put an API key into a prompt does not care which of those their
8
+ * terminal does, and telling them to type a sixty-character secret by hand is not an answer.
9
+ *
10
+ * So the prompt can go and fetch it. Every desktop already has a command for this, and KONECK
11
+ * already shells out to their write-side counterparts for /copy; this is the same list read the
12
+ * other way round.
13
+ */
14
+ /** The readers worth trying, in order. The first that exists and answers wins. */
15
+ const READERS = [
16
+ // Wayland, then X11's two common tools, then macOS.
17
+ { file: 'wl-paste', args: ['--no-newline'] },
18
+ { file: 'xclip', args: ['-selection', 'clipboard', '-o'] },
19
+ { file: 'xsel', args: ['--clipboard', '--output'] },
20
+ { file: 'pbpaste', args: [] },
21
+ // Windows, and WSL — where the Windows clipboard is the one holding what was copied.
22
+ { file: 'powershell.exe', args: ['-NoProfile', '-Command', 'Get-Clipboard'] },
23
+ ];
24
+ /**
25
+ * What is on the clipboard, or why it could not be read.
26
+ *
27
+ * Each reader gets a short deadline: a clipboard tool that hangs — xclip waiting on an X server
28
+ * that is not there is the usual way — must not hold a keystroke open. Failure is ordinary and is
29
+ * reported rather than thrown: a machine reached over SSH has no clipboard, and that is a fact
30
+ * about the machine rather than an error in the program.
31
+ */
32
+ export async function readClipboard(readers = READERS, timeoutMs = 1_500) {
33
+ const { execa } = await import('execa');
34
+ for (const reader of readers) {
35
+ try {
36
+ const done = await execa(reader.file, [...reader.args], {
37
+ reject: false, timeout: timeoutMs, stripFinalNewline: true,
38
+ });
39
+ if (done.exitCode !== 0)
40
+ continue;
41
+ // An empty clipboard is a successful read of nothing, and worth reporting as its own thing:
42
+ // it means the copy did not happen, not that KONECK cannot see the clipboard.
43
+ return { ok: true, text: String(done.stdout ?? ''), by: reader.file };
44
+ }
45
+ catch {
46
+ // ENOENT for a tool that is not installed, which is the ordinary case for all but one of
47
+ // these on any given machine.
48
+ }
49
+ }
50
+ return { ok: false, text: '', reason: 'No clipboard tool answered. On Linux that is usually the wl-clipboard package (Wayland) or '
51
+ + 'xclip (X11); over SSH there is no clipboard to read at all.' };
52
+ }
53
+ /**
54
+ * Bracketed-paste markers, as a terminal writes them and as Ink sometimes forwards them.
55
+ *
56
+ * Built from escapes rather than written literally, so this file stays free of raw control
57
+ * characters — a source file carrying one reads as binary to some tools and is invisible to a
58
+ * reviewer in all of them. The escape is optional in the pattern because Ink strips it from the
59
+ * opening marker before handing input over, so the literal that reaches a field is "[200~".
60
+ */
61
+ const PASTE_MARKERS = new RegExp('\\u001b?\\[2(?:00|01)~', 'g');
62
+ /** Anything below space, plus DEL. No credential holds one, and an HTTP header cannot carry one. */
63
+ const CONTROL_CHARS = new RegExp('[\\u0000-\\u001f\\u007f]', 'g');
64
+ /**
65
+ * A pasted secret, made safe to use as one.
66
+ *
67
+ * Three things go, each for its own reason. Surrounding whitespace, because a key copied out of a
68
+ * file or a password manager carries a trailing newline that is not part of it. Bracketed paste
69
+ * markers, because a terminal that announces a paste mid-chunk can leave the literal text "[200~"
70
+ * in the field, and a key with that in front of it fails at the provider with an authentication
71
+ * error that says nothing about where it came from. And control characters, which are invalid in an
72
+ * HTTP header — a key carrying one is rejected by the transport before the provider ever sees it,
73
+ * which is the least informative way for this to go wrong.
74
+ */
75
+ export function cleanPastedSecret(text) {
76
+ return String(text ?? '')
77
+ .replace(PASTE_MARKERS, '')
78
+ .replace(CONTROL_CHARS, '')
79
+ .trim();
80
+ }
81
+ //# sourceMappingURL=clipboard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clipboard.js","sourceRoot":"","sources":["../src/clipboard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,kFAAkF;AAClF,MAAM,OAAO,GAAoD;IAC/D,oDAAoD;IACpD,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,cAAc,CAAC,EAAE;IAC5C,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,YAAY,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE;IAC1D,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,aAAa,EAAE,UAAU,CAAC,EAAE;IACnD,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE;IAC7B,qFAAqF;IACrF,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,YAAY,EAAE,UAAU,EAAE,eAAe,CAAC,EAAE;CAC9E,CAAC;AAWF;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,UAA2D,OAAO,EAClE,SAAS,GAAG,KAAK;IAEjB,MAAM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AAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAarE;AAED,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,WAAW,EACnB,eAAe,CAAC,EAAE,OAAO,EAAE;AAC3B;;;;;;;GAOG;AACH,YAAY,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC;AAClC,iGAAiG;AACjG,WAAW,CAAC,EAAE,IAAI,GACjB,OAAO,CAAC,YAAY,CAAC,CAwRvB;AAwBD;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,uFAAuF;IACvF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sFAAsF;IACtF,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAGD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAExD;AAED,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,EACnB,eAAe,CAAC,EAAE,OAAO,EAAE,EAC3B,MAAM,CAAC,EAAE,YAAY,GACpB,OAAO,CAAC,YAAY,CAAC,CAwKvB"}
package/dist/engine.js CHANGED
@@ -8,7 +8,7 @@ import { TOOL_DEFINITIONS, dispatchTool, describeShell, unknownToolError, resolv
8
8
  import { tui } from './tui.js';
9
9
  import { hasWorkspaceOwnedGitRepo, gitScope, createWorktree, mergeWorktree, preservedWorktreeNotice } from './worktree.js';
10
10
  import { resolveProvider, getApiKey, keyProvenance, servesLocally, servesOwnWeights, isPrivateHost } from './providers.js';
11
- import { wireEffort, looksLikeEffortUnsupported } from './pace.js';
11
+ import { wireEffort, looksLikeEffortUnsupported, acceptedEfforts, nearestAccepted } from './pace.js';
12
12
  import { triggerFor, pickNext, describeSwitch, askSwitch, keyOf as failoverKey } from './failover.js';
13
13
  import { findChurn, describeChurn, WINDOW as CHURN_WINDOW } from './cycle.js';
14
14
  import { claim, release, describeClaims } from './claims.js';
@@ -1065,6 +1065,13 @@ detectedContext = { current: 0 }) {
1065
1065
  let toolsDisabled = false;
1066
1066
  // Set only when the endpoint says so, and only for this run.
1067
1067
  let effortRefused = false;
1068
+ /**
1069
+ * The value this model has said it will take, once it has said so.
1070
+ *
1071
+ * Null until a refusal names an accepted set. Kept for the run rather than the turn, so the
1072
+ * substitution is made once and not relearned on every request.
1073
+ */
1074
+ let effortValue = null;
1068
1075
  /** The loudest threshold already announced, so each is said once rather than every turn. */
1069
1076
  let loudestSaid = 0;
1070
1077
  /*
@@ -1477,7 +1484,9 @@ detectedContext = { current: 0 }) {
1477
1484
  * deliberation. Measured: KONECK's own overhead for a command is about forty milliseconds.
1478
1485
  */
1479
1486
  const paceField = config.pace && !effortRefused
1480
- ? { reasoning_effort: wireEffort(config.pace) }
1487
+ // effortValue is set when a provider has told us which values it takes; until then the
1488
+ // ordinary mapping applies.
1489
+ ? { reasoning_effort: effortValue ?? wireEffort(config.pace) }
1481
1490
  : {};
1482
1491
  const stream = await client.chat.completions.create({
1483
1492
  model: config.model,
@@ -1816,6 +1825,32 @@ detectedContext = { current: 0 }) {
1816
1825
  * that ever had a bad day.
1817
1826
  */
1818
1827
  if (looksLikeEffortUnsupported(err) && config.pace && !effortRefused) {
1828
+ /*
1829
+ * A provider that names the values it takes is telling us how to fix this.
1830
+ *
1831
+ * Dropping the parameter was the only response there was, and for a model that refuses it
1832
+ * outright that is right. But the refusal often arrives with the answer attached — "please
1833
+ * use low, high or max" — and throwing that away means sending nothing where the setting
1834
+ * would have worked perfectly with one word changed. The pill would then say medium while
1835
+ * the model ran at whatever its default was, which is the pace feature lying.
1836
+ *
1837
+ * Learned from the endpoint's own answer rather than guessed from the model's name, the
1838
+ * same way tool support and the context window are.
1839
+ */
1840
+ const accepted = acceptedEfforts(err);
1841
+ const instead = accepted.length > 0 ? nearestAccepted(config.pace, accepted) : null;
1842
+ if (instead && instead !== config.pace) {
1843
+ effortValue = wireEffort(instead) === instead ? instead : wireEffort(instead);
1844
+ // Named rather than silent: this is a change to what was asked for, and the person who
1845
+ // chose the pace is the one who can decide whether the substitute suits them.
1846
+ if (!silent) {
1847
+ tui.printWarning(`"${config.model}" does not take a ${config.pace} reasoning effort — `
1848
+ + `it accepts ${accepted.join(', ')}. Using ${instead} for this run; `
1849
+ + `set another with /pace.`);
1850
+ }
1851
+ turn--;
1852
+ continue;
1853
+ }
1819
1854
  effortRefused = true;
1820
1855
  if (!silent) {
1821
1856
  tui.printWarning(`"${config.model}" does not take a reasoning setting — continuing `