latentcode 0.1.0-alpha.1 → 0.1.0-alpha.3

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.
@@ -28208,11 +28208,11 @@ var require_react_jsx_runtime_development = __commonJS({
28208
28208
  return jsxWithValidation(type, props, key, false);
28209
28209
  }
28210
28210
  }
28211
- var jsx9 = jsxWithValidationDynamic;
28212
- var jsxs7 = jsxWithValidationStatic;
28211
+ var jsx10 = jsxWithValidationDynamic;
28212
+ var jsxs8 = jsxWithValidationStatic;
28213
28213
  exports.Fragment = REACT_FRAGMENT_TYPE;
28214
- exports.jsx = jsx9;
28215
- exports.jsxs = jsxs7;
28214
+ exports.jsx = jsx10;
28215
+ exports.jsxs = jsxs8;
28216
28216
  })();
28217
28217
  }
28218
28218
  }
@@ -33576,6 +33576,12 @@ function Static(props) {
33576
33576
 
33577
33577
  // node_modules/ink/build/components/Transform.js
33578
33578
  var import_react12 = __toESM(require_react(), 1);
33579
+ function Transform({ children, transform }) {
33580
+ if (children === void 0 || children === null) {
33581
+ return null;
33582
+ }
33583
+ return import_react12.default.createElement("ink-text", { style: { flexGrow: 0, flexShrink: 1, flexDirection: "row" }, internal_transform: transform }, children);
33584
+ }
33579
33585
 
33580
33586
  // node_modules/ink/build/components/Newline.js
33581
33587
  var import_react13 = __toESM(require_react(), 1);
@@ -33965,6 +33971,9 @@ function describeConnection(provider, integration) {
33965
33971
  if (conn.method === "external") return { kind: "local", via: "local login" };
33966
33972
  return { kind: "key", via: "API key" };
33967
33973
  }
33974
+ if (provider.settings?.apiKey !== "public" && provider.activation === "enabled" && /-compatible$/.test(provider.package ?? "")) {
33975
+ return { kind: "local", via: "custom endpoint" };
33976
+ }
33968
33977
  if (provider.settings?.apiKey === "public" || provider.activation === "enabled") {
33969
33978
  return { kind: "builtin", via: "built in \xB7 free models" };
33970
33979
  }
@@ -34233,6 +34242,41 @@ ${seen.slice(-800)}`));
34233
34242
  return buildCatalog(providers.data, integrations, models.data);
34234
34243
  }
34235
34244
  /** Store an API key for a provider. The key goes to the local engine only. */
34245
+ /** The engine's global config directory, as it reports it (`GET /api/config`). */
34246
+ async configDir() {
34247
+ try {
34248
+ const r = await this.call(
34249
+ "GET",
34250
+ "/api/config"
34251
+ );
34252
+ const list = Array.isArray(r) ? r : r.data ?? [];
34253
+ const dir = list.find((x) => x.type === "directory" && x.path);
34254
+ return dir?.path ?? null;
34255
+ } catch {
34256
+ return null;
34257
+ }
34258
+ }
34259
+ /**
34260
+ * Re-read the config files. Running sessions carry on; the event stream
34261
+ * stays open. The new providers can lag the response by a moment, so
34262
+ * `waitForIntegration` polls for the one we expect.
34263
+ */
34264
+ async reloadConfig() {
34265
+ await this.call("POST", "/api/location/reload");
34266
+ }
34267
+ async waitForIntegration(id, timeoutMs = 1e4) {
34268
+ const until = Date.now() + timeoutMs;
34269
+ let last;
34270
+ while (Date.now() < until) {
34271
+ try {
34272
+ return (await this.call("GET", `/api/integration/${encodeURIComponent(id)}`)).data;
34273
+ } catch (e) {
34274
+ last = e;
34275
+ }
34276
+ await new Promise((r) => setTimeout(r, 250));
34277
+ }
34278
+ throw new EngineError(`The engine did not pick up provider "${id}" after reloading its config. ${last instanceof Error ? last.message : ""}`.trim());
34279
+ }
34236
34280
  async connectKey(integrationID, key) {
34237
34281
  await this.call("POST", `/api/integration/${encodeURIComponent(integrationID)}/connect/key`, { key });
34238
34282
  }
@@ -34500,6 +34544,96 @@ function chooseStartModel(def, all, store) {
34500
34544
  return ok ? { model: ok, switchedFrom: def } : { model: def };
34501
34545
  }
34502
34546
 
34547
+ // src/ads/controller.ts
34548
+ import { randomUUID } from "node:crypto";
34549
+
34550
+ // src/ads/sanitize.ts
34551
+ var ESC_SEQ = /\x1b\][\s\S]*?(?:\x07|\x1b\\|$)|\x1b\[[0-?]*[ -/]*[@-~]|\x1b[ -/]*[0-~]|\x1b[@-_]/g;
34552
+ var CONTROL = /[\x00-\x1f\x7f-\x9f]/g;
34553
+ var BIDI = /[‪-‮⁦-⁩‎‏؜]/g;
34554
+ function sanitizeAdText(input, max = 140) {
34555
+ let s2 = String(input ?? "");
34556
+ s2 = s2.replace(ESC_SEQ, "").replace(CONTROL, " ").replace(BIDI, "");
34557
+ s2 = s2.replace(/\s+/g, " ").trim();
34558
+ if (max > 0 && s2.length > max) s2 = `${s2.slice(0, Math.max(0, max - 1)).trimEnd()}\u2026`;
34559
+ return s2;
34560
+ }
34561
+ var AD_LIMITS = { title: 30, body: 140, cta_text: 24 };
34562
+
34563
+ // src/ads/adline.ts
34564
+ var WORD = /[\p{L}\p{N}]/u;
34565
+ var LEAD_SEP = /^[\s\-:–—]+/;
34566
+ function clampField(value, max) {
34567
+ const t = value.trim();
34568
+ if (t.length <= max) return t;
34569
+ return `${t.slice(0, Math.max(1, max - 1)).trimEnd()}\u2026`;
34570
+ }
34571
+ function dedupeBrand(brand, body) {
34572
+ let t = body.trim();
34573
+ const b = brand.trim();
34574
+ if (!b) return t;
34575
+ const lb = b.toLowerCase();
34576
+ while (t.toLowerCase().startsWith(lb)) {
34577
+ const after = t.charAt(b.length);
34578
+ if (after !== "" && WORD.test(after)) break;
34579
+ const rest = t.slice(b.length).replace(LEAD_SEP, "");
34580
+ if (rest === t) break;
34581
+ t = rest;
34582
+ if (t === "") break;
34583
+ }
34584
+ return t;
34585
+ }
34586
+ function composeAdCopy(title, body) {
34587
+ const brandRaw = sanitizeAdText(title, 0);
34588
+ const bodyRaw = sanitizeAdText(body, 0);
34589
+ return { brand: clampField(brandRaw, 30), line: clampField(dedupeBrand(brandRaw, bodyRaw), 60) };
34590
+ }
34591
+ function isSafeUrl(raw, allowLoopbackHttp = false) {
34592
+ if (typeof raw !== "string" || !raw) return false;
34593
+ if (/[\x00-\x20\x7f-\x9f]/.test(raw)) return false;
34594
+ try {
34595
+ const u = new URL(raw);
34596
+ if (u.username || u.password) return false;
34597
+ if (u.protocol === "https:") return true;
34598
+ return allowLoopbackHttp && u.protocol === "http:" && (u.hostname === "127.0.0.1" || u.hostname === "localhost");
34599
+ } catch {
34600
+ return false;
34601
+ }
34602
+ }
34603
+ function displayUrl(url) {
34604
+ return url.startsWith("https://") ? url.slice("https://".length).replace(/\/$/, "") : "";
34605
+ }
34606
+ function clickLink(server, ad, wallet, ctaUrl) {
34607
+ const base = server.replace(/\/+$/, "");
34608
+ if (!ad.click_token || !isSafeUrl(base, true)) return ctaUrl;
34609
+ return `${base}/ad/click?ad=${encodeURIComponent(ad.ad_id)}&w=${encodeURIComponent(wallet)}&t=${encodeURIComponent(ad.click_token)}`;
34610
+ }
34611
+ function linkShape(env3 = process.env, platform2 = process.platform) {
34612
+ if (env3.LATENTCODE_LINKS === "osc8" || env3.LATENTCODE_LINKS === "plain" || env3.LATENTCODE_LINKS === "hybrid") {
34613
+ return env3.LATENTCODE_LINKS;
34614
+ }
34615
+ if (env3.TMUX) return "plain";
34616
+ if (env3.SSH_TTY || env3.SSH_CONNECTION) return "hybrid";
34617
+ if (env3.KITTY_WINDOW_ID || env3.WEZTERM_PANE || env3.ITERM_SESSION_ID || env3.GHOSTTY_RESOURCES_DIR) return "osc8";
34618
+ if (env3.ALACRITTY_SOCKET || env3.ALACRITTY_WINDOW_ID) return "plain";
34619
+ const term = env3.TERM_PROGRAM || "";
34620
+ if (term === "vscode" || term === "iTerm.app" || term === "WezTerm" || term === "ghostty") return "osc8";
34621
+ if (term === "Apple_Terminal" || term === "WarpTerminal") return "plain";
34622
+ if (env3.WT_SESSION) return "osc8";
34623
+ return platform2 === "win32" ? "plain" : "hybrid";
34624
+ }
34625
+ function osc8(text, url) {
34626
+ if (!isSafeUrl(url, true)) return text;
34627
+ return `\x1B]8;;${url}\x1B\\${text}\x1B]8;;\x1B\\`;
34628
+ }
34629
+ var BADGE_COLORS = ["#F87171", "#FB923C", "#FBBF24", "#A3E635", "#34D399", "#22D3EE", "#60A5FA", "#A78BFA", "#F472B6"];
34630
+ function adBadge(brand) {
34631
+ const letter = ([...brand].find((c) => /[\p{L}\p{N}]/u.test(c)) ?? "").toLocaleUpperCase();
34632
+ let h = 2166136261;
34633
+ for (const c of brand.toLowerCase()) h = Math.imul(h ^ c.codePointAt(0), 16777619);
34634
+ return { letter: letter || "\u2022", color: BADGE_COLORS[(h >>> 0) % BADGE_COLORS.length] };
34635
+ }
34636
+
34503
34637
  // src/ads/classify.ts
34504
34638
  import { existsSync as existsSync3, readFileSync as readFileSync5 } from "node:fs";
34505
34639
  import { join as join4 } from "node:path";
@@ -34695,43 +34829,28 @@ function classifyPrompt(prompt, cwd2 = process.cwd()) {
34695
34829
  return best;
34696
34830
  }
34697
34831
 
34698
- // src/ads/sanitize.ts
34699
- var ESC_SEQ = /\x1b\][\s\S]*?(?:\x07|\x1b\\|$)|\x1b\[[0-?]*[ -/]*[@-~]|\x1b[ -/]*[0-~]|\x1b[@-_]/g;
34700
- var CONTROL = /[\x00-\x1f\x7f-\x9f]/g;
34701
- var BIDI = /[‪-‮⁦-⁩‎‏؜]/g;
34702
- function sanitizeAdText(input, max = 140) {
34703
- let s2 = String(input ?? "");
34704
- s2 = s2.replace(ESC_SEQ, "").replace(CONTROL, " ").replace(BIDI, "");
34705
- s2 = s2.replace(/\s+/g, " ").trim();
34706
- if (max > 0 && s2.length > max) s2 = `${s2.slice(0, Math.max(0, max - 1)).trimEnd()}\u2026`;
34707
- return s2;
34708
- }
34709
- var AD_LIMITS = { title: 30, body: 140, cta_text: 24 };
34710
-
34711
34832
  // src/ads/controller.ts
34712
- var MIN_VISIBLE_MS = 2e3;
34713
- var ROTATE_MS = 3e4;
34833
+ var MIN_VISIBLE_MS = 1e4;
34834
+ var ROTATE_MS = 1e4;
34835
+ var HOLD_MS = 27e4;
34714
34836
  function safeUrl(raw) {
34715
- if (!raw) return "";
34716
- if (/[\x00-\x1f\x7f-\x9f\s]/.test(raw)) return "";
34717
- try {
34718
- const u = new URL(raw);
34719
- return u.protocol === "https:" ? u.toString() : "";
34720
- } catch {
34721
- return "";
34722
- }
34837
+ return raw && isSafeUrl(raw) ? new URL(raw).toString() : "";
34723
34838
  }
34724
- function toDisplayAd(ad) {
34725
- const title = sanitizeAdText(ad.title, AD_LIMITS.title);
34726
- const body = sanitizeAdText(ad.body, AD_LIMITS.body);
34727
- if (!title && !body) return null;
34839
+ function toDisplayAd(ad, opts = {}) {
34840
+ const { brand, line } = composeAdCopy(ad.title, ad.body);
34841
+ if (!brand && !line) return null;
34842
+ const url = safeUrl(ad.cta_url);
34728
34843
  return {
34729
34844
  ad,
34730
- title,
34731
- body,
34845
+ title: brand,
34846
+ body: line,
34732
34847
  ctaText: sanitizeAdText(ad.cta_text, AD_LIMITS.cta_text) || "Learn more",
34733
- url: safeUrl(ad.cta_url),
34734
- earn: typeof ad.earn_amount === "number" && Number.isFinite(ad.earn_amount) ? ad.earn_amount : 0
34848
+ url,
34849
+ link: url && opts.server && opts.wallet ? clickLink(opts.server, ad, opts.wallet, url) : url,
34850
+ shownUrl: displayUrl(url),
34851
+ earn: typeof ad.earn_amount === "number" && Number.isFinite(ad.earn_amount) ? ad.earn_amount : 0,
34852
+ eventUuid: randomUUID(),
34853
+ fetchedAt: opts.now ?? Date.now()
34735
34854
  };
34736
34855
  }
34737
34856
  var AdController = class {
@@ -34757,6 +34876,7 @@ var AdController = class {
34757
34876
  now: opts.now ?? Date.now,
34758
34877
  minVisibleMs: opts.minVisibleMs ?? MIN_VISIBLE_MS,
34759
34878
  rotateMs: opts.rotateMs ?? ROTATE_MS,
34879
+ holdMs: opts.holdMs ?? HOLD_MS,
34760
34880
  classify: opts.classify ?? ((p, cwd2) => classifyPrompt(p, cwd2))
34761
34881
  };
34762
34882
  opts.focus.onChange(() => this.emit());
@@ -34803,29 +34923,49 @@ var AdController = class {
34803
34923
  this.lastTick = this.o.now();
34804
34924
  if (working) {
34805
34925
  this.context = this.o.classify(prompt, this.o.cwd);
34806
- void this.fetchNext();
34807
- } else {
34926
+ if (!this.holding()) {
34927
+ this.clear();
34928
+ void this.fetchNext();
34929
+ }
34930
+ } else if (this.billed || !this.current) {
34808
34931
  this.clear();
34932
+ } else {
34933
+ this.generation += 1;
34809
34934
  }
34810
34935
  this.emit();
34811
34936
  }
34937
+ /** An un-billed ad that may still be shown and billed. */
34938
+ holding() {
34939
+ return !!this.current && !this.billed && this.o.now() - this.current.fetchedAt < this.o.holdMs;
34940
+ }
34812
34941
  /** Advance the attention clock. Call every ~250ms. */
34813
34942
  tick() {
34814
34943
  const now = this.o.now();
34815
34944
  const dt = Math.max(0, now - this.lastTick);
34816
34945
  this.lastTick = now;
34817
34946
  if (!this.working || !this.current) return;
34947
+ if (!this.billed && !this.holding()) {
34948
+ this.clear();
34949
+ void this.fetchNext();
34950
+ return;
34951
+ }
34818
34952
  if (this.o.focus.focused) this.visibleMs += dt;
34819
34953
  if (!this.billed && this.visibleMs >= this.o.minVisibleMs) {
34820
34954
  this.billed = true;
34821
- this.impressions += 1;
34822
- this.sessionEarned += this.current.earn;
34955
+ const shown = this.current;
34823
34956
  void this.o.api.impression({
34824
- ad: this.current.ad,
34957
+ ad: shown.ad,
34825
34958
  wallet: this.o.wallet,
34826
34959
  context: this.context,
34827
34960
  displayedMs: this.visibleMs,
34828
- focusTracked: this.o.focus.known
34961
+ focusTracked: this.o.focus.known,
34962
+ eventUuid: shown.eventUuid
34963
+ }).then((result) => {
34964
+ if (result !== "tracked") return;
34965
+ this.impressions += 1;
34966
+ this.sessionEarned += shown.earn;
34967
+ this.emit();
34968
+ }).catch(() => {
34829
34969
  });
34830
34970
  this.emit();
34831
34971
  }
@@ -34833,12 +34973,10 @@ var AdController = class {
34833
34973
  void this.fetchNext();
34834
34974
  }
34835
34975
  }
34836
- /** User pressed the open key: log the click, return the URL to open (or null). */
34976
+ /** User asked to open the ad (keyboard): the tracked link, or null. The server counts the click on redirect. */
34837
34977
  click() {
34838
34978
  const ad = this.working ? this.current : null;
34839
- if (!ad || !ad.url) return null;
34840
- void this.o.api.click({ ad: ad.ad, wallet: this.o.wallet, context: this.context });
34841
- return ad.url;
34979
+ return ad?.link || null;
34842
34980
  }
34843
34981
  clear() {
34844
34982
  this.generation += 1;
@@ -34853,7 +34991,7 @@ var AdController = class {
34853
34991
  try {
34854
34992
  const ad = await this.o.api.request({ wallet: this.o.wallet, context: this.context, sessionId: this.o.sessionId });
34855
34993
  if (gen !== this.generation || !this.working || this.status !== "ok") return;
34856
- const display = ad ? toDisplayAd(ad) : null;
34994
+ const display = ad ? toDisplayAd(ad, { server: this.o.api.server, wallet: this.o.wallet, now: this.o.now() }) : null;
34857
34995
  if (!display) {
34858
34996
  if (this.current) this.shownAt = this.o.now();
34859
34997
  return;
@@ -34874,9 +35012,6 @@ var AdController = class {
34874
35012
  }
34875
35013
  };
34876
35014
 
34877
- // src/ads/api.ts
34878
- import { randomUUID } from "node:crypto";
34879
-
34880
35015
  // src/ads/killswitch.ts
34881
35016
  import { existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync6, writeFileSync as writeFileSync3 } from "node:fs";
34882
35017
  import { join as join5 } from "node:path";
@@ -34959,6 +35094,7 @@ function recordServerResult(ok, now = Date.now()) {
34959
35094
  var SURFACE_WORKING_BAR = "status_line";
34960
35095
  function httpAdApi(server = resolveServer()) {
34961
35096
  return {
35097
+ server,
34962
35098
  async request({ wallet, context, sessionId }) {
34963
35099
  void refreshKillswitch(server);
34964
35100
  if (!shouldServe().ok) return null;
@@ -34987,8 +35123,8 @@ function httpAdApi(server = resolveServer()) {
34987
35123
  return null;
34988
35124
  }
34989
35125
  },
34990
- async impression({ ad, wallet, context, displayedMs, focusTracked }) {
34991
- if (!shouldServe().ok) return;
35126
+ async impression({ ad, wallet, context, displayedMs, focusTracked, eventUuid }) {
35127
+ if (!shouldServe().ok) return "error";
34992
35128
  const device = await ensureDeviceCredential(server);
34993
35129
  try {
34994
35130
  const res = await fetch(`${server}/ad/impression`, {
@@ -35002,7 +35138,7 @@ function httpAdApi(server = resolveServer()) {
35002
35138
  surface: SURFACE_WORKING_BAR,
35003
35139
  context,
35004
35140
  device_id: device,
35005
- event_uuid: randomUUID(),
35141
+ event_uuid: eventUuid,
35006
35142
  displayed_ms: Math.round(displayedMs),
35007
35143
  // Attention signal: the dwell above was measured with real terminal
35008
35144
  // focus events, not assumed. Servers that don't know it ignore it.
@@ -35011,27 +35147,12 @@ function httpAdApi(server = resolveServer()) {
35011
35147
  signal: AbortSignal.timeout(2e3)
35012
35148
  });
35013
35149
  recordServerResult(res.status < 500);
35150
+ if (!res.ok) return "error";
35151
+ const status2 = (await res.json().catch(() => ({}))).status;
35152
+ return status2 === "tracked" || status2 === "skipped" || status2 === "unearned" ? status2 : "error";
35014
35153
  } catch {
35015
35154
  recordServerResult(false);
35016
- }
35017
- },
35018
- async click({ ad, wallet, context }) {
35019
- const device = await ensureDeviceCredential(server);
35020
- try {
35021
- await fetch(`${server}/ad/click`, {
35022
- method: "POST",
35023
- headers: { "Content-Type": "application/json" },
35024
- body: JSON.stringify({
35025
- ad_id: ad.ad_id,
35026
- user_wallet: wallet,
35027
- agent: AGENT_LATENTCODE,
35028
- surface: SURFACE_WORKING_BAR,
35029
- context,
35030
- device_id: device
35031
- }),
35032
- signal: AbortSignal.timeout(2e3)
35033
- });
35034
- } catch {
35155
+ return "error";
35035
35156
  }
35036
35157
  },
35037
35158
  async balance(wallet) {
@@ -35219,7 +35340,7 @@ function firstLine(e) {
35219
35340
 
35220
35341
  // src/ui/App.tsx
35221
35342
  var import_react26 = __toESM(require_react(), 1);
35222
- import { homedir as homedir3 } from "node:os";
35343
+ import { homedir as homedir4 } from "node:os";
35223
35344
 
35224
35345
  // src/util/open.ts
35225
35346
  import { spawn as spawn2 } from "node:child_process";
@@ -35452,6 +35573,51 @@ function reduce(state, ev, now = Date.now()) {
35452
35573
  }
35453
35574
  }
35454
35575
 
35576
+ // src/ui/SponsoredLine.tsx
35577
+ var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
35578
+ var MAX_BARE_URL = 60;
35579
+ var SHAPE = linkShape();
35580
+ function SponsoredLine({ ad, billed, shape = SHAPE }) {
35581
+ const linked = !!ad.link && shape !== "plain";
35582
+ const showUrl = !!ad.shownUrl && shape !== "osc8" && ad.shownUrl.length <= MAX_BARE_URL;
35583
+ const badge = adBadge(ad.title || ad.body);
35584
+ const copy = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [
35585
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { bold: true, underline: linked, children: ad.title || ad.body }),
35586
+ ad.title && ad.body ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { color: C.muted, children: [
35587
+ " \u2014 ",
35588
+ ad.body
35589
+ ] }) : null
35590
+ ] });
35591
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box_default, { justifyContent: "space-between", children: [
35592
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { wrap: "truncate-end", children: [
35593
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { color: C.earn, children: [
35594
+ G.earn,
35595
+ " Sponsored"
35596
+ ] }),
35597
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { color: C.faint, children: [
35598
+ " ",
35599
+ G.thin,
35600
+ " "
35601
+ ] }),
35602
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { backgroundColor: badge.color, color: "#111827", bold: true, children: ` ${badge.letter} ` }),
35603
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: " " }),
35604
+ linked ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Transform, { transform: (out) => osc8(out, ad.link), children: copy }) : copy,
35605
+ showUrl ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { color: C.accent2, children: [
35606
+ " \xB7 ",
35607
+ ad.shownUrl
35608
+ ] }) : null,
35609
+ ad.link ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { color: C.faint, children: [
35610
+ " \xB7 ctrl+o ",
35611
+ ad.ctaText
35612
+ ] }) : null
35613
+ ] }),
35614
+ billed && ad.earn > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { color: C.earn, children: [
35615
+ " +$",
35616
+ ad.earn.toFixed(4)
35617
+ ] }) : null
35618
+ ] });
35619
+ }
35620
+
35455
35621
  // src/ui/components.tsx
35456
35622
  var import_react22 = __toESM(require_react(), 1);
35457
35623
 
@@ -35668,7 +35834,7 @@ function parseDiff(patch, max = 14) {
35668
35834
  }
35669
35835
 
35670
35836
  // src/ui/components.tsx
35671
- var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
35837
+ var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
35672
35838
  function useTermSize() {
35673
35839
  const { stdout } = use_stdout_default();
35674
35840
  const read = () => ({ cols: stdout.columns || 80, rows: stdout.rows || 24 });
@@ -35688,21 +35854,21 @@ function Spinner({ color = C.accent }) {
35688
35854
  const t = setInterval(() => setI((n) => (n + 1) % SPINNER.length), 90);
35689
35855
  return () => clearInterval(t);
35690
35856
  }, []);
35691
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color, children: SPINNER[i] });
35857
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color, children: SPINNER[i] });
35692
35858
  }
35693
35859
  function Logo({ version }) {
35694
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box_default, { flexDirection: "column", children: [0, 1].map((row2) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [
35695
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: C.accent, children: LOGO.latent[row2] }),
35696
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: " " }),
35697
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: C.accent2, children: LOGO.code[row2] }),
35698
- row2 === 1 && version ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { color: C.faint, children: [
35860
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Box_default, { flexDirection: "column", children: [0, 1].map((row2) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { children: [
35861
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color: C.accent, children: LOGO.latent[row2] }),
35862
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { children: " " }),
35863
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color: C.accent2, children: LOGO.code[row2] }),
35864
+ row2 === 1 && version ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { color: C.faint, children: [
35699
35865
  " v",
35700
35866
  version
35701
35867
  ] }) : null
35702
35868
  ] }, row2)) });
35703
35869
  }
35704
35870
  function Panel(props) {
35705
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
35871
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
35706
35872
  Box_default,
35707
35873
  {
35708
35874
  flexDirection: "column",
@@ -35712,21 +35878,21 @@ function Panel(props) {
35712
35878
  width: props.width,
35713
35879
  marginTop: 1,
35714
35880
  children: [
35715
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box_default, { justifyContent: "space-between", children: [
35716
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { bold: true, color: props.color ?? C.accent, children: props.title }),
35717
- props.right ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: C.faint, children: props.right }) : null
35881
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { justifyContent: "space-between", children: [
35882
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { bold: true, color: props.color ?? C.accent, children: props.title }),
35883
+ props.right ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color: C.faint, children: props.right }) : null
35718
35884
  ] }),
35719
35885
  props.children,
35720
- props.footer ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box_default, { marginTop: 1, children: props.footer }) : null
35886
+ props.footer ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Box_default, { marginTop: 1, children: props.footer }) : null
35721
35887
  ]
35722
35888
  }
35723
35889
  );
35724
35890
  }
35725
35891
  function Hints({ items }) {
35726
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { wrap: "truncate-end", children: items.map(([k, label2], i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [
35727
- i ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: C.faint, children: " \xB7 " }) : null,
35728
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: C.muted, children: k }),
35729
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { color: C.faint, children: [
35892
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { wrap: "truncate-end", children: items.map(([k, label2], i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { children: [
35893
+ i ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color: C.faint, children: " \xB7 " }) : null,
35894
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color: C.muted, children: k }),
35895
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { color: C.faint, children: [
35730
35896
  " ",
35731
35897
  label2
35732
35898
  ] })
@@ -35744,16 +35910,16 @@ function usePaste(handler, active = true) {
35744
35910
  }
35745
35911
  function FieldText({ state, mask, placeholder }) {
35746
35912
  if (!state.text && placeholder) {
35747
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [
35748
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { inverse: true, children: " " }),
35749
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: C.faint, children: placeholder })
35913
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { children: [
35914
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { inverse: true, children: " " }),
35915
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color: C.faint, children: placeholder })
35750
35916
  ] });
35751
35917
  }
35752
35918
  const shown = mask ? { ...state, text: "\u2022".repeat(state.text.length) } : state;
35753
35919
  const { before, at, after } = splitAtCursor(shown);
35754
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [
35920
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { children: [
35755
35921
  before,
35756
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { inverse: true, children: at }),
35922
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { inverse: true, children: at }),
35757
35923
  after
35758
35924
  ] });
35759
35925
  }
@@ -35779,64 +35945,64 @@ function useLineField(opts) {
35779
35945
  return { state, text: state.text, set: (t) => update(setText(ref.current, t)) };
35780
35946
  }
35781
35947
  function Spans({ spans }) {
35782
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: spans.map((s2, i) => {
35948
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: spans.map((s2, i) => {
35783
35949
  switch (s2.t) {
35784
35950
  case "bold":
35785
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { bold: true, children: s2.v }, i);
35951
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { bold: true, children: s2.v }, i);
35786
35952
  case "italic":
35787
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { italic: true, children: s2.v }, i);
35953
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { italic: true, children: s2.v }, i);
35788
35954
  case "code":
35789
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: C.code, children: s2.v }, i);
35955
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color: C.code, children: s2.v }, i);
35790
35956
  case "link":
35791
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [
35792
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { underline: true, children: s2.v }),
35793
- s2.url !== s2.v ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { color: C.faint, children: [
35957
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { children: [
35958
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { underline: true, children: s2.v }),
35959
+ s2.url !== s2.v ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { color: C.faint, children: [
35794
35960
  " (",
35795
35961
  s2.url,
35796
35962
  ")"
35797
35963
  ] }) : null
35798
35964
  ] }, i);
35799
35965
  default:
35800
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: s2.v }, i);
35966
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { children: s2.v }, i);
35801
35967
  }
35802
35968
  }) });
35803
35969
  }
35804
35970
  function BlockView({ b }) {
35805
35971
  switch (b.t) {
35806
35972
  case "h":
35807
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { bold: true, color: b.level <= 2 ? C.accent : void 0, underline: b.level === 1, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spans, { spans: b.spans }) });
35973
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { bold: true, color: b.level <= 2 ? C.accent : void 0, underline: b.level === 1, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Spans, { spans: b.spans }) });
35808
35974
  case "li":
35809
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box_default, { marginLeft: b.indent * 2, children: [
35810
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { color: C.accent, children: [
35975
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { marginLeft: b.indent * 2, children: [
35976
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { color: C.accent, children: [
35811
35977
  b.marker,
35812
35978
  " "
35813
35979
  ] }),
35814
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spans, { spans: b.spans }) })
35980
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Spans, { spans: b.spans }) })
35815
35981
  ] });
35816
35982
  case "quote":
35817
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box_default, { children: [
35818
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { color: C.faint, children: [
35983
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { children: [
35984
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { color: C.faint, children: [
35819
35985
  G.thin,
35820
35986
  " "
35821
35987
  ] }),
35822
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: C.muted, italic: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spans, { spans: b.spans }) })
35988
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color: C.muted, italic: true, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Spans, { spans: b.spans }) })
35823
35989
  ] });
35824
35990
  case "code":
35825
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box_default, { flexDirection: "column", borderStyle: "single", borderColor: C.border, borderTop: false, borderRight: false, borderBottom: false, paddingLeft: 1, children: [
35826
- b.lang ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: C.faint, children: b.lang }) : null,
35827
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: C.code, children: b.lines.join("\n") || " " })
35991
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { flexDirection: "column", borderStyle: "single", borderColor: C.border, borderTop: false, borderRight: false, borderBottom: false, paddingLeft: 1, children: [
35992
+ b.lang ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color: C.faint, children: b.lang }) : null,
35993
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color: C.code, children: b.lines.join("\n") || " " })
35828
35994
  ] });
35829
35995
  case "rule":
35830
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: C.faint, children: "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500" });
35996
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color: C.faint, children: "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500" });
35831
35997
  case "gap":
35832
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: " " });
35998
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { children: " " });
35833
35999
  default:
35834
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spans, { spans: b.spans }) });
36000
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Spans, { spans: b.spans }) });
35835
36001
  }
35836
36002
  }
35837
36003
  function Markdown({ text }) {
35838
36004
  const blocks = parseMarkdown(text);
35839
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box_default, { flexDirection: "column", children: blocks.map((b, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BlockView, { b }, i)) });
36005
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Box_default, { flexDirection: "column", children: blocks.map((b, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BlockView, { b }, i)) });
35840
36006
  }
35841
36007
  function windowAround(total, selected, size) {
35842
36008
  if (total <= size) return { start: 0, end: total };
@@ -35882,7 +36048,7 @@ function parseCommandLine(line) {
35882
36048
  }
35883
36049
 
35884
36050
  // src/ui/Transcript.tsx
35885
- var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
36051
+ var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
35886
36052
  function lastLines(text, n) {
35887
36053
  const lines = text.trimEnd().split("\n");
35888
36054
  return lines.length <= n ? lines.join("\n") : lines.slice(-n).join("\n");
@@ -35937,55 +36103,55 @@ function ToolView({ item, cwd: cwd2, width }) {
35937
36103
  const diff2 = item.diff ? parseDiff(item.diff) : null;
35938
36104
  const showOutput = item.output && (failed || !QUIET.has(item.name)) && !diff2;
35939
36105
  const out = showOutput ? firstLines(item.output, failed ? 8 : 6) : null;
35940
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { marginTop: 1, flexDirection: "column", width, children: [
35941
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { wrap: "truncate-end", children: [
35942
- running ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Spinner, { color: C.warn }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color: failed ? C.err : C.ok, children: G.dot }),
35943
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { bold: true, color: t.verb === "$" ? C.accent2 : void 0, children: [
36106
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Box_default, { marginTop: 1, flexDirection: "column", width, children: [
36107
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { wrap: "truncate-end", children: [
36108
+ running ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Spinner, { color: C.warn }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { color: failed ? C.err : C.ok, children: G.dot }),
36109
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { bold: true, color: t.verb === "$" ? C.accent2 : void 0, children: [
35944
36110
  " ",
35945
36111
  t.verb
35946
36112
  ] }),
35947
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { children: [
36113
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { children: [
35948
36114
  " ",
35949
36115
  clip(t.target, Math.max(20, width - t.verb.length - 24))
35950
36116
  ] }),
35951
- t.extra ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { color: C.faint, children: [
36117
+ t.extra ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { color: C.faint, children: [
35952
36118
  " ",
35953
36119
  t.extra
35954
36120
  ] }) : null,
35955
- item.additions || item.deletions ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { children: [
35956
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { color: C.add, children: [
36121
+ item.additions || item.deletions ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { children: [
36122
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { color: C.add, children: [
35957
36123
  " +",
35958
36124
  item.additions ?? 0
35959
36125
  ] }),
35960
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { color: C.del, children: [
36126
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { color: C.del, children: [
35961
36127
  " \u2212",
35962
36128
  item.deletions ?? 0
35963
36129
  ] })
35964
36130
  ] }) : null,
35965
- item.ms !== void 0 && item.ms >= 1e3 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { color: C.faint, children: [
36131
+ item.ms !== void 0 && item.ms >= 1e3 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { color: C.faint, children: [
35966
36132
  " \xB7 ",
35967
36133
  fmtDuration(item.ms)
35968
36134
  ] }) : null
35969
36135
  ] }),
35970
- diff2 && diff2.lines.length ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { flexDirection: "column", marginLeft: 2, children: [
35971
- diff2.lines.map((l, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { wrap: "truncate-end", color: l.t === "add" ? C.add : l.t === "del" ? C.del : C.faint, children: [
36136
+ diff2 && diff2.lines.length ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Box_default, { flexDirection: "column", marginLeft: 2, children: [
36137
+ diff2.lines.map((l, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { wrap: "truncate-end", color: l.t === "add" ? C.add : l.t === "del" ? C.del : C.faint, children: [
35972
36138
  l.t === "add" ? "+ " : l.t === "del" ? "\u2212 " : l.t === "hunk" ? "" : " ",
35973
36139
  l.t === "hunk" ? "\u22EF" : l.text
35974
36140
  ] }, i)),
35975
- diff2.more ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { color: C.faint, children: [
36141
+ diff2.more ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { color: C.faint, children: [
35976
36142
  "\u2026 ",
35977
36143
  diff2.more,
35978
36144
  " more lines"
35979
36145
  ] }) : null
35980
36146
  ] }) : null,
35981
- out ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { marginLeft: 2, children: [
35982
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Box_default, { flexShrink: 0, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { color: C.faint, children: [
36147
+ out ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Box_default, { marginLeft: 2, children: [
36148
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Box_default, { flexShrink: 0, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { color: C.faint, children: [
35983
36149
  G.elbow,
35984
36150
  " "
35985
36151
  ] }) }),
35986
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { flexDirection: "column", children: [
35987
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color: failed ? C.err : C.muted, children: out.text }),
35988
- out.more ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { color: C.faint, children: [
36152
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Box_default, { flexDirection: "column", children: [
36153
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { color: failed ? C.err : C.muted, children: out.text }),
36154
+ out.more ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { color: C.faint, children: [
35989
36155
  "\u2026 ",
35990
36156
  out.more,
35991
36157
  " more lines"
@@ -35999,25 +36165,25 @@ var NOTICE_MARK = { info: G.bullet, ok: G.ok, warn: G.warn, error: G.no };
35999
36165
  function ItemView({ item, live, cwd: cwd2, width, maxLines }) {
36000
36166
  switch (item.kind) {
36001
36167
  case "user":
36002
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { marginTop: 1, width, children: [
36003
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Box_default, { flexShrink: 0, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { color: C.accent, bold: true, children: [
36168
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Box_default, { marginTop: 1, width, children: [
36169
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Box_default, { flexShrink: 0, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { color: C.accent, bold: true, children: [
36004
36170
  G.prompt,
36005
36171
  " "
36006
36172
  ] }) }),
36007
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { bold: true, children: item.text })
36173
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { bold: true, children: item.text })
36008
36174
  ] });
36009
36175
  case "reasoning": {
36010
36176
  const text = item.text.trim();
36011
36177
  if (!text) return null;
36012
36178
  const shown = live ? lastLines(text, 4) : firstLines(text, 2);
36013
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { marginTop: 1, width, children: [
36014
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Box_default, { flexShrink: 0, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { color: C.faint, children: [
36179
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Box_default, { marginTop: 1, width, children: [
36180
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Box_default, { flexShrink: 0, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { color: C.faint, children: [
36015
36181
  G.thin,
36016
36182
  " "
36017
36183
  ] }) }),
36018
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { flexDirection: "column", children: [
36019
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color: C.faint, italic: true, children: typeof shown === "string" ? shown : shown.text }),
36020
- typeof shown !== "string" && shown.more ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { color: C.faint, children: [
36184
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Box_default, { flexDirection: "column", children: [
36185
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { color: C.faint, italic: true, children: typeof shown === "string" ? shown : shown.text }),
36186
+ typeof shown !== "string" && shown.more ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { color: C.faint, children: [
36021
36187
  "\u2026 thought for ",
36022
36188
  shown.more,
36023
36189
  " more lines"
@@ -36026,25 +36192,25 @@ function ItemView({ item, live, cwd: cwd2, width, maxLines }) {
36026
36192
  ] });
36027
36193
  }
36028
36194
  case "text":
36029
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Box_default, { marginTop: 1, width, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Markdown, { text: live ? lastLines(item.text, maxLines) : item.text }) });
36195
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Box_default, { marginTop: 1, width, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Markdown, { text: live ? lastLines(item.text, maxLines) : item.text }) });
36030
36196
  case "tool":
36031
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ToolView, { item, cwd: cwd2, width });
36197
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ToolView, { item, cwd: cwd2, width });
36032
36198
  case "error":
36033
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { marginTop: 1, width, children: [
36034
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Box_default, { flexShrink: 0, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { color: C.err, children: [
36199
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Box_default, { marginTop: 1, width, children: [
36200
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Box_default, { flexShrink: 0, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { color: C.err, children: [
36035
36201
  G.no,
36036
36202
  " "
36037
36203
  ] }) }),
36038
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color: C.err, wrap: "wrap", children: item.text })
36204
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { color: C.err, wrap: "wrap", children: item.text })
36039
36205
  ] });
36040
36206
  case "notice": {
36041
36207
  const tone = item.tone ?? "info";
36042
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { marginTop: 1, width, children: [
36043
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Box_default, { flexShrink: 0, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { color: NOTICE_COLOR[tone], children: [
36208
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Box_default, { marginTop: 1, width, children: [
36209
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Box_default, { flexShrink: 0, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { color: NOTICE_COLOR[tone], children: [
36044
36210
  NOTICE_MARK[tone],
36045
36211
  " "
36046
36212
  ] }) }),
36047
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color: tone === "info" ? C.muted : NOTICE_COLOR[tone], wrap: "wrap", children: item.text })
36213
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { color: tone === "info" ? C.muted : NOTICE_COLOR[tone], wrap: "wrap", children: item.text })
36048
36214
  ] });
36049
36215
  }
36050
36216
  }
@@ -36058,19 +36224,19 @@ function PermissionPrompt({ perm, selected, cwd: cwd2, width }) {
36058
36224
  const options = ["Allow once", "Always allow", "Reject"];
36059
36225
  const keys = ["y", "a", "n"];
36060
36226
  const what = perm.resources.map((r) => relPath(r, cwd2)).join(", ") || perm.message || "";
36061
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { marginTop: 1, borderStyle: "round", borderColor: C.warn, paddingX: 1, flexDirection: "column", width, children: [
36062
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Box_default, { justifyContent: "space-between", children: [
36063
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { bold: true, color: C.warn, children: PERMISSION_TITLE[perm.action] ?? `Allow ${perm.action}?` }),
36064
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color: C.faint, children: perm.action })
36227
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Box_default, { marginTop: 1, borderStyle: "round", borderColor: C.warn, paddingX: 1, flexDirection: "column", width, children: [
36228
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Box_default, { justifyContent: "space-between", children: [
36229
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { bold: true, color: C.warn, children: PERMISSION_TITLE[perm.action] ?? `Allow ${perm.action}?` }),
36230
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { color: C.faint, children: perm.action })
36065
36231
  ] }),
36066
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Box_default, { marginY: 1, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { color: perm.action === "shell" ? C.accent2 : void 0, wrap: "wrap", children: [
36232
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Box_default, { marginY: 1, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { color: perm.action === "shell" ? C.accent2 : void 0, wrap: "wrap", children: [
36067
36233
  perm.action === "shell" ? "$ " : "",
36068
36234
  clip(what, 600)
36069
36235
  ] }) }),
36070
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { children: [
36236
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { children: [
36071
36237
  i ? " " : "",
36072
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { color: i === selected ? i === 2 ? C.err : C.ok : C.muted, bold: i === selected, inverse: i === selected, children: ` ${o} ` }),
36073
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Text, { color: C.faint, children: [
36238
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { color: i === selected ? i === 2 ? C.err : C.ok : C.muted, bold: i === selected, inverse: i === selected, children: ` ${o} ` }),
36239
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { color: C.faint, children: [
36074
36240
  " ",
36075
36241
  keys[i]
36076
36242
  ] })
@@ -36080,22 +36246,22 @@ function PermissionPrompt({ perm, selected, cwd: cwd2, width }) {
36080
36246
 
36081
36247
  // src/ui/panels/ModelPicker.tsx
36082
36248
  var import_react23 = __toESM(require_react(), 1);
36083
- var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
36249
+ var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
36084
36250
  function Mark({ status: status2, testing }) {
36085
- if (testing) return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Spinner, {});
36251
+ if (testing) return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Spinner, {});
36086
36252
  switch (status2) {
36087
36253
  case "ok":
36088
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { color: C.ok, children: G.ok });
36254
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.ok, children: G.ok });
36089
36255
  case "unsupported":
36090
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { color: C.err, children: G.no });
36256
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.err, children: G.no });
36091
36257
  case "rate-limited":
36092
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { color: C.warn, children: G.wait });
36258
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.warn, children: G.wait });
36093
36259
  case "auth":
36094
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { color: C.warn, children: G.key });
36260
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.warn, children: G.key });
36095
36261
  case "error":
36096
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { color: C.err, children: G.warn });
36262
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.err, children: G.warn });
36097
36263
  default:
36098
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { color: C.faint, children: "\xB7" });
36264
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.faint, children: "\xB7" });
36099
36265
  }
36100
36266
  }
36101
36267
  function ModelPicker(p) {
@@ -36184,14 +36350,14 @@ function ModelPicker(p) {
36184
36350
  const wId = Math.max(0, rest - wName);
36185
36351
  const kindOf = (id) => p.catalog.providers.find((x) => x.id === id)?.kind ?? "unknown";
36186
36352
  const verified = p.catalog.models.filter((m) => p.status(m.key) === "ok").length;
36187
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
36353
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
36188
36354
  Panel,
36189
36355
  {
36190
36356
  title: "Models",
36191
36357
  right: `${p.catalog.models.length} models \xB7 ${verified} verified with your account`,
36192
36358
  width: p.width,
36193
36359
  color: C.accent,
36194
- footer: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
36360
+ footer: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
36195
36361
  Hints,
36196
36362
  {
36197
36363
  items: [
@@ -36205,36 +36371,36 @@ function ModelPicker(p) {
36205
36371
  }
36206
36372
  ),
36207
36373
  children: [
36208
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Box_default, { marginTop: 1, children: [
36209
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { color: C.accent, children: [
36374
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Box_default, { marginTop: 1, children: [
36375
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { color: C.accent, children: [
36210
36376
  G.search,
36211
36377
  " "
36212
36378
  ] }),
36213
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FieldText, { state: field.state, placeholder: "type to search \u2014 name, id or provider" })
36379
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FieldText, { state: field.state, placeholder: "type to search \u2014 name, id or provider" })
36214
36380
  ] }),
36215
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Box_default, { marginTop: 1, flexWrap: "wrap", children: tabs.map((id, i) => {
36381
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Box_default, { marginTop: 1, flexWrap: "wrap", children: tabs.map((id, i) => {
36216
36382
  const prov = p.catalog.providers.find((x) => x.id === id);
36217
36383
  const text = prov ? `${prov.name} ${prov.models}` : `All ${p.catalog.models.length}`;
36218
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Box_default, { marginRight: 2, children: i === tab2 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { bold: true, color: C.accent, underline: true, children: text }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { color: C.muted, children: text }) }, id ?? "all");
36384
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Box_default, { marginRight: 2, children: i === tab2 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { bold: true, color: C.accent, underline: true, children: text }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.muted, children: text }) }, id ?? "all");
36219
36385
  }) }),
36220
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Box_default, { flexDirection: "column", marginTop: 1, children: [
36221
- above ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { color: C.faint, children: [
36386
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Box_default, { flexDirection: "column", marginTop: 1, children: [
36387
+ above ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { color: C.faint, children: [
36222
36388
  " ",
36223
36389
  G.up,
36224
36390
  " ",
36225
36391
  above,
36226
36392
  " more"
36227
36393
  ] }) : null,
36228
- shown.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { color: C.muted, children: [
36394
+ shown.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { color: C.muted, children: [
36229
36395
  " No model matches \u201C",
36230
36396
  field.text,
36231
36397
  "\u201D."
36232
36398
  ] }) : null,
36233
36399
  shown.map((r, i) => {
36234
36400
  if (r.t === "head") {
36235
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { wrap: "truncate-end", children: [
36236
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { bold: true, color: C.muted, children: r.label }),
36237
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { color: C.faint, children: [
36401
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { wrap: "truncate-end", children: [
36402
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { bold: true, color: C.muted, children: r.label }),
36403
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { color: C.faint, children: [
36238
36404
  " ",
36239
36405
  r.hint
36240
36406
  ] })
@@ -36245,33 +36411,33 @@ function ModelPicker(p) {
36245
36411
  const st = p.status(m.key);
36246
36412
  const dead = st === "unsupported";
36247
36413
  const note = m.key === p.current ? "current" : st === "unsupported" ? "not on your plan" : st !== "unknown" && st !== "ok" ? label(st) : "";
36248
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { wrap: "truncate-end", children: [
36249
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { color: C.accent, children: [
36414
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { wrap: "truncate-end", children: [
36415
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { color: C.accent, children: [
36250
36416
  on2 ? G.prompt : " ",
36251
36417
  " "
36252
36418
  ] }),
36253
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Mark, { status: st, testing: testing.has(m.key) }),
36254
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { children: " " }),
36255
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { bold: on2, color: dead ? C.faint : on2 ? C.text : void 0, children: pad(m.name, wName) }),
36256
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { color: C.faint, children: [
36419
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Mark, { status: st, testing: testing.has(m.key) }),
36420
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { children: " " }),
36421
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { bold: on2, color: dead ? C.faint : on2 ? C.text : void 0, children: pad(m.name, wName) }),
36422
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { color: C.faint, children: [
36257
36423
  " ",
36258
36424
  pad(field.text || !provider ? m.key : m.id, wId)
36259
36425
  ] }),
36260
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { color: C.muted, children: [
36426
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { color: C.muted, children: [
36261
36427
  " ",
36262
36428
  padStart(fmtContext(m.context), wCtx)
36263
36429
  ] }),
36264
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { color: m.costIn === 0 && m.costOut === 0 ? C.ok : C.muted, children: [
36430
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { color: m.costIn === 0 && m.costOut === 0 ? C.ok : C.muted, children: [
36265
36431
  " ",
36266
36432
  padStart(fmtPrice(m, kindOf(m.providerID)), wPrice)
36267
36433
  ] }),
36268
- note ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { color: m.key === p.current ? C.accent2 : dead ? C.faint : C.warn, children: [
36434
+ note ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { color: m.key === p.current ? C.accent2 : dead ? C.faint : C.warn, children: [
36269
36435
  " ",
36270
36436
  note
36271
36437
  ] }) : null
36272
36438
  ] }, m.key);
36273
36439
  }),
36274
- below ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { color: C.faint, children: [
36440
+ below ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { color: C.faint, children: [
36275
36441
  " ",
36276
36442
  G.down,
36277
36443
  " ",
@@ -36279,13 +36445,13 @@ function ModelPicker(p) {
36279
36445
  " more"
36280
36446
  ] }) : null
36281
36447
  ] }),
36282
- chosen ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Box_default, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { wrap: "truncate-end", children: [
36283
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { color: C.faint, children: "effort " }),
36284
- efforts.length > 1 ? efforts.map((e, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { color: i === effortAt ? C.accent2 : C.faint, bold: i === effortAt, children: [
36448
+ chosen ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Box_default, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { wrap: "truncate-end", children: [
36449
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.faint, children: "effort " }),
36450
+ efforts.length > 1 ? efforts.map((e, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { color: i === effortAt ? C.accent2 : C.faint, bold: i === effortAt, children: [
36285
36451
  i === effortAt ? `\u2039 ${e} \u203A` : e,
36286
36452
  i < efforts.length - 1 ? " " : ""
36287
- ] }, e)) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { color: C.faint, children: "fixed for this model" }),
36288
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { color: C.faint, children: " ctx \xB7 $ in/out per 1M tokens" })
36453
+ ] }, e)) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.faint, children: "fixed for this model" }),
36454
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.faint, children: " ctx \xB7 $ in/out per 1M tokens" })
36289
36455
  ] }) }) : null
36290
36456
  ]
36291
36457
  }
@@ -36294,7 +36460,155 @@ function ModelPicker(p) {
36294
36460
 
36295
36461
  // src/ui/panels/ProviderPanel.tsx
36296
36462
  var import_react24 = __toESM(require_react(), 1);
36297
- var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
36463
+
36464
+ // src/engine/customProvider.ts
36465
+ import { existsSync as existsSync5, mkdirSync as mkdirSync4, readFileSync as readFileSync7, renameSync, writeFileSync as writeFileSync4, copyFileSync } from "node:fs";
36466
+ import { homedir as homedir3 } from "node:os";
36467
+ import { join as join6 } from "node:path";
36468
+ var KIND_PACKAGE = {
36469
+ openai: "@opencode/ai/providers/openai-compatible",
36470
+ anthropic: "@opencode/ai/providers/anthropic-compatible"
36471
+ };
36472
+ var KIND_LABEL = {
36473
+ openai: "OpenAI-compatible",
36474
+ anthropic: "Anthropic-compatible"
36475
+ };
36476
+ var CONFIG_FILES = ["opencode.json", "opencode.jsonc"];
36477
+ function slugify(name) {
36478
+ return name.normalize("NFKD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 40);
36479
+ }
36480
+ function providerIdFor(name, taken, custom) {
36481
+ const base = slugify(name) || "custom";
36482
+ if (custom.has(base) || !taken.has(base)) return base;
36483
+ for (let i = 0; ; i++) {
36484
+ const id = i === 0 ? `${base}-custom` : `${base}-custom-${i + 1}`;
36485
+ if (custom.has(id) || !taken.has(id)) return id;
36486
+ }
36487
+ }
36488
+ function normalizeBaseURL(raw) {
36489
+ const s2 = raw.trim();
36490
+ let u;
36491
+ try {
36492
+ u = new URL(s2);
36493
+ } catch {
36494
+ throw new Error("That is not a URL. Example: https://api.example.com/v1");
36495
+ }
36496
+ if (u.protocol !== "https:" && u.protocol !== "http:") throw new Error("The base URL must start with https:// or http://");
36497
+ if (u.search || u.hash) throw new Error("Leave out the query string \u2014 just the base URL, e.g. https://api.example.com/v1");
36498
+ return u.toString().replace(/\/+$/, "");
36499
+ }
36500
+ function parseModelList(raw) {
36501
+ const seen = /* @__PURE__ */ new Set();
36502
+ for (const part of raw.split(/[\s,]+/)) {
36503
+ const id = part.trim();
36504
+ if (id) seen.add(id);
36505
+ }
36506
+ return [...seen];
36507
+ }
36508
+ function providerEntry(input) {
36509
+ const models = {};
36510
+ for (const id of input.models) models[id] = { name: id };
36511
+ return {
36512
+ name: input.name.trim(),
36513
+ package: KIND_PACKAGE[input.kind],
36514
+ settings: { baseURL: input.baseURL },
36515
+ models
36516
+ };
36517
+ }
36518
+ function parseJsonc(text) {
36519
+ let out = "";
36520
+ let hadComments = false;
36521
+ let i = 0;
36522
+ while (i < text.length) {
36523
+ const ch = text[i];
36524
+ if (ch === '"') {
36525
+ let j = i + 1;
36526
+ while (j < text.length && text[j] !== '"') j += text[j] === "\\" ? 2 : 1;
36527
+ out += text.slice(i, j + 1);
36528
+ i = j + 1;
36529
+ } else if (ch === "/" && text[i + 1] === "/") {
36530
+ hadComments = true;
36531
+ while (i < text.length && text[i] !== "\n") i++;
36532
+ } else if (ch === "/" && text[i + 1] === "*") {
36533
+ hadComments = true;
36534
+ const end2 = text.indexOf("*/", i + 2);
36535
+ i = end2 < 0 ? text.length : end2 + 2;
36536
+ } else {
36537
+ if (ch === "}" || ch === "]") {
36538
+ const m = out.match(/,\s*$/);
36539
+ if (m) out = out.slice(0, out.length - m[0].length) + m[0].slice(1);
36540
+ }
36541
+ out += ch;
36542
+ i++;
36543
+ }
36544
+ }
36545
+ return { value: out.trim() ? JSON.parse(out) : {}, hadComments };
36546
+ }
36547
+ function mergeProvider(existing, id, entry) {
36548
+ const { value, hadComments } = existing ? parseJsonc(existing) : { value: {}, hadComments: false };
36549
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("The engine config file is not a JSON object.");
36550
+ const config = value;
36551
+ const providers = config.providers;
36552
+ if (providers !== void 0 && (typeof providers !== "object" || providers === null || Array.isArray(providers))) {
36553
+ throw new Error('The engine config has a "providers" value that is not an object.');
36554
+ }
36555
+ const next = { ...config, providers: { ...providers ?? {}, [id]: entry } };
36556
+ if (!("$schema" in next)) next.$schema = "https://opencode.ai/config.json";
36557
+ return { text: JSON.stringify(next, null, 2) + "\n", hadComments };
36558
+ }
36559
+ function configuredProviderIds(text) {
36560
+ if (!text) return /* @__PURE__ */ new Set();
36561
+ try {
36562
+ const v = parseJsonc(text).value;
36563
+ return new Set(Object.keys(v?.providers ?? {}));
36564
+ } catch {
36565
+ return /* @__PURE__ */ new Set();
36566
+ }
36567
+ }
36568
+ function defaultConfigDir(env3 = process.env) {
36569
+ return join6(env3.XDG_CONFIG_HOME || join6(homedir3(), ".config"), "opencode");
36570
+ }
36571
+ function configFileIn(dir, exists = existsSync5) {
36572
+ const present = CONFIG_FILES.map((f) => join6(dir, f)).filter(exists);
36573
+ return present.at(-1) ?? join6(dir, "opencode.json");
36574
+ }
36575
+ function readConfigText(file) {
36576
+ try {
36577
+ return readFileSync7(file, "utf8");
36578
+ } catch {
36579
+ return null;
36580
+ }
36581
+ }
36582
+ function writeProviderConfig(file, id, input) {
36583
+ const existing = readConfigText(file);
36584
+ const { text, hadComments } = mergeProvider(existing, id, providerEntry(input));
36585
+ mkdirSync4(join6(file, ".."), { recursive: true });
36586
+ let backup;
36587
+ if (existing !== null && hadComments) {
36588
+ backup = file + ".bak";
36589
+ copyFileSync(file, backup);
36590
+ }
36591
+ const tmp = `${file}.${process.pid}.tmp`;
36592
+ writeFileSync4(tmp, text);
36593
+ renameSync(tmp, file);
36594
+ return { file, backup };
36595
+ }
36596
+ async function discoverModels(kind, baseURL, key, timeoutMs = 1e4) {
36597
+ const headers = kind === "anthropic" ? { "anthropic-version": "2023-06-01", ...key ? { "x-api-key": key } : {} } : key ? { authorization: `Bearer ${key}` } : {};
36598
+ const res = await fetch(baseURL + "/models", { headers, signal: AbortSignal.timeout(timeoutMs) });
36599
+ if (!res.ok) throw new Error(`${baseURL}/models answered ${res.status}`);
36600
+ return parseModelsResponse(await res.json());
36601
+ }
36602
+ function parseModelsResponse(body) {
36603
+ const data = body?.data ?? body?.models;
36604
+ if (!Array.isArray(data)) throw new Error("The /models answer has no model list.");
36605
+ return parseModelList(
36606
+ data.map((m) => typeof m === "string" ? m : typeof m === "object" && m ? String(m.id ?? "") : "").join(" ")
36607
+ );
36608
+ }
36609
+
36610
+ // src/ui/panels/ProviderPanel.tsx
36611
+ var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
36298
36612
  var usable = (i) => i.methods.filter((m) => m.type === "key" || m.type === "oauth");
36299
36613
  var needsForm = (m) => "form" in m && Array.isArray(m.form) && m.form.some((f) => !f.hidden && f.required);
36300
36614
  var methodLabel = (m) => m.type === "key" ? m.label || "API key" : m.label;
@@ -36333,15 +36647,15 @@ function ProviderPanel(p) {
36333
36647
  }
36334
36648
  go({ v: "oauth", integration, method });
36335
36649
  };
36336
- const finish = async (integration) => {
36650
+ const finish = async (integration, note) => {
36337
36651
  const next = await p.onConnected(integration.name);
36338
36652
  const models = next.providers.filter((x) => x.integrationID === integration.id).reduce((n, x) => n + x.models, 0);
36339
- go({ v: "done", name: integration.name, models });
36653
+ go({ v: "done", name: integration.name, models, note });
36340
36654
  };
36341
36655
  const common = { width: p.width, color: C.accent };
36342
36656
  switch (view.v) {
36343
36657
  case "list":
36344
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
36658
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
36345
36659
  ProviderList,
36346
36660
  {
36347
36661
  ...p,
@@ -36350,7 +36664,7 @@ function ProviderPanel(p) {
36350
36664
  }
36351
36665
  );
36352
36666
  case "pick":
36353
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
36667
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
36354
36668
  IntegrationPicker,
36355
36669
  {
36356
36670
  ...common,
@@ -36360,11 +36674,23 @@ function ProviderPanel(p) {
36360
36674
  query: p.query,
36361
36675
  error,
36362
36676
  onPick: choose,
36677
+ onCustom: () => go({ v: "custom" }),
36363
36678
  onBack: () => p.connect ? p.onClose() : go({ v: "list" })
36364
36679
  }
36365
36680
  );
36681
+ case "custom":
36682
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
36683
+ CustomProviderForm,
36684
+ {
36685
+ ...common,
36686
+ engine: p.engine,
36687
+ taken: /* @__PURE__ */ new Set([...(integrations ?? []).map((i) => i.id), ...p.catalog.providers.map((x) => x.id)]),
36688
+ onDone: (integration, note) => finish(integration, note),
36689
+ onBack: () => go({ v: "pick" })
36690
+ }
36691
+ );
36366
36692
  case "method":
36367
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
36693
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
36368
36694
  MethodPicker,
36369
36695
  {
36370
36696
  ...common,
@@ -36375,7 +36701,7 @@ function ProviderPanel(p) {
36375
36701
  }
36376
36702
  );
36377
36703
  case "key":
36378
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
36704
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
36379
36705
  KeyEntry,
36380
36706
  {
36381
36707
  ...common,
@@ -36386,7 +36712,7 @@ function ProviderPanel(p) {
36386
36712
  }
36387
36713
  );
36388
36714
  case "oauth":
36389
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
36715
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
36390
36716
  OAuthFlow,
36391
36717
  {
36392
36718
  ...common,
@@ -36398,7 +36724,7 @@ function ProviderPanel(p) {
36398
36724
  }
36399
36725
  );
36400
36726
  case "done":
36401
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Done, { ...common, name: view.name, models: view.models, onClose: p.onClose, onModels: () => p.onBrowse("") });
36727
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Done, { ...common, name: view.name, models: view.models, note: view.note, onClose: p.onClose, onModels: () => p.onBrowse("") });
36402
36728
  }
36403
36729
  }
36404
36730
  function ProviderList(p) {
@@ -36419,39 +36745,39 @@ function ProviderList(p) {
36419
36745
  const inner = p.width - 4;
36420
36746
  const wName = Math.min(24, Math.max(12, ...items.map((x) => x.name.length)) + 1);
36421
36747
  const wVia = Math.min(26, Math.max(10, ...items.map((x) => x.via.length)) + 1);
36422
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
36748
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
36423
36749
  Panel,
36424
36750
  {
36425
36751
  title: "Providers",
36426
36752
  right: `${items.length} connected \xB7 ${p.catalog.models.length} models`,
36427
36753
  width: p.width,
36428
36754
  color: C.accent,
36429
- footer: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Hints, { items: [["\u2191\u2193", "move"], ["enter", "browse models"], ["c", "connect a provider"], ["esc", "close"]] }),
36755
+ footer: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Hints, { items: [["\u2191\u2193", "move"], ["enter", "browse models"], ["c", "connect a provider"], ["esc", "close"]] }),
36430
36756
  children: [
36431
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Box_default, { flexDirection: "column", marginTop: 1, children: [
36757
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Box_default, { flexDirection: "column", marginTop: 1, children: [
36432
36758
  items.map((prov, i) => {
36433
36759
  const ok = p.catalog.models.filter((m) => m.providerID === prov.id && p.status(m.key) === "ok").length;
36434
36760
  const dot = prov.kind === "builtin" ? C.faint : C.ok;
36435
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { wrap: "truncate-end", children: [
36436
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { color: C.accent, children: [
36761
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { wrap: "truncate-end", children: [
36762
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { color: C.accent, children: [
36437
36763
  i === sel ? G.prompt : " ",
36438
36764
  " "
36439
36765
  ] }),
36440
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { color: dot, children: [
36766
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { color: dot, children: [
36441
36767
  G.dot,
36442
36768
  " "
36443
36769
  ] }),
36444
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { bold: i === sel, children: pad(prov.name, wName) }),
36445
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { color: C.muted, children: [
36770
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { bold: i === sel, children: pad(prov.name, wName) }),
36771
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { color: C.muted, children: [
36446
36772
  " ",
36447
36773
  pad(prov.via, wVia)
36448
36774
  ] }),
36449
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { color: C.muted, children: [
36775
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { color: C.muted, children: [
36450
36776
  " ",
36451
36777
  String(prov.models).padStart(3),
36452
36778
  " models"
36453
36779
  ] }),
36454
- ok ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { color: C.ok, children: [
36780
+ ok ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { color: C.ok, children: [
36455
36781
  " ",
36456
36782
  G.ok,
36457
36783
  " ",
@@ -36460,16 +36786,16 @@ function ProviderList(p) {
36460
36786
  ] }) : null
36461
36787
  ] }, prov.id);
36462
36788
  }),
36463
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { children: [
36464
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { color: C.accent, children: [
36789
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { children: [
36790
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { color: C.accent, children: [
36465
36791
  sel === items.length ? G.prompt : " ",
36466
36792
  " "
36467
36793
  ] }),
36468
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.accent2, bold: sel === items.length, children: "+ Connect a provider\u2026" })
36794
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.accent2, bold: sel === items.length, children: "+ Connect a provider\u2026" })
36469
36795
  ] })
36470
36796
  ] }),
36471
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Box_default, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.faint, wrap: "wrap", children: clipTo("Bring your own access: an API key, or a subscription where the provider allows third-party clients. Credentials stay in the local engine.", inner * 2) }) }),
36472
- p.error ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.err, children: p.error }) : null
36797
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Box_default, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.faint, wrap: "wrap", children: clipTo("Bring your own access: an API key, or a subscription where the provider allows third-party clients. Credentials stay in the local engine.", inner * 2) }) }),
36798
+ p.error ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.err, children: p.error }) : null
36473
36799
  ]
36474
36800
  }
36475
36801
  );
@@ -36487,9 +36813,10 @@ function IntegrationPicker(p) {
36487
36813
  return true;
36488
36814
  }
36489
36815
  if (key.upArrow) return void setSel((s2) => Math.max(0, s2 - 1)), true;
36490
- if (key.downArrow) return void setSel((s2) => Math.min(list.length - 1, s2 + 1)), true;
36816
+ if (key.downArrow) return void setSel((s2) => Math.min(list.length, s2 + 1)), true;
36491
36817
  if (key.return) {
36492
- const it = list[Math.min(sel, list.length - 1)];
36818
+ if (selected === list.length) return p.onCustom(), true;
36819
+ const it = list[selected];
36493
36820
  if (it) p.onPick(it);
36494
36821
  return true;
36495
36822
  }
@@ -36497,37 +36824,37 @@ function IntegrationPicker(p) {
36497
36824
  }
36498
36825
  });
36499
36826
  const list = (0, import_react24.useMemo)(() => searchIntegrations(p.integrations ?? [], field.text), [p.integrations, field.text]);
36500
- const selected = Math.min(sel, Math.max(0, list.length - 1));
36501
- const visible = Math.max(5, Math.min(11, p.rows - 14));
36502
- const win = windowAround(list.length, selected, visible);
36503
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
36827
+ const selected = Math.min(sel, list.length);
36828
+ const visible = Math.max(5, Math.min(11, p.rows - 15));
36829
+ const win = windowAround(list.length, Math.min(selected, Math.max(0, list.length - 1)), visible);
36830
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
36504
36831
  Panel,
36505
36832
  {
36506
36833
  title: "Connect a provider",
36507
36834
  right: p.integrations ? `${list.length} available` : "",
36508
36835
  width: p.width,
36509
36836
  color: p.color,
36510
- footer: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Hints, { items: [["\u2191\u2193", "move"], ["enter", "choose"], ["esc", field.text ? "clear" : "back"]] }),
36837
+ footer: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Hints, { items: [["\u2191\u2193", "move"], ["enter", "choose"], ["esc", field.text ? "clear" : "back"]] }),
36511
36838
  children: [
36512
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Box_default, { marginTop: 1, children: [
36513
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { color: C.accent, children: [
36839
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Box_default, { marginTop: 1, children: [
36840
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { color: C.accent, children: [
36514
36841
  G.search,
36515
36842
  " "
36516
36843
  ] }),
36517
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FieldText, { state: field.state, placeholder: "search \u2014 Anthropic, OpenRouter, Google\u2026" })
36844
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FieldText, { state: field.state, placeholder: "search \u2014 Anthropic, OpenRouter, Google\u2026" })
36518
36845
  ] }),
36519
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Box_default, { flexDirection: "column", marginTop: 1, children: [
36520
- !p.integrations && !p.error ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { children: [
36521
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Spinner, {}),
36846
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Box_default, { flexDirection: "column", marginTop: 1, children: [
36847
+ !p.integrations && !p.error ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { children: [
36848
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Spinner, {}),
36522
36849
  " ",
36523
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.muted, children: "Loading providers\u2026" })
36850
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.muted, children: "Loading providers\u2026" })
36524
36851
  ] }) : null,
36525
- p.integrations && !list.length ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { color: C.muted, children: [
36852
+ p.integrations && !list.length ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { color: C.muted, children: [
36526
36853
  " Nothing matches \u201C",
36527
36854
  field.text,
36528
36855
  "\u201D."
36529
36856
  ] }) : null,
36530
- win.start > 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { color: C.faint, children: [
36857
+ win.start > 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { color: C.faint, children: [
36531
36858
  " ",
36532
36859
  G.up,
36533
36860
  " ",
@@ -36538,32 +36865,40 @@ function IntegrationPicker(p) {
36538
36865
  const on2 = win.start + i === selected;
36539
36866
  const labels = usable(it).map((m) => m.type === "key" ? "API key" : m.label);
36540
36867
  const methods = labels.slice(0, 2).join(" \xB7 ") + (labels.length > 2 ? ` +${labels.length - 2}` : "");
36541
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { wrap: "truncate-end", children: [
36542
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { color: C.accent, children: [
36868
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { wrap: "truncate-end", children: [
36869
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { color: C.accent, children: [
36543
36870
  on2 ? G.prompt : " ",
36544
36871
  " "
36545
36872
  ] }),
36546
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { bold: on2, children: pad(it.name, 26) }),
36547
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { color: C.muted, children: [
36873
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { bold: on2, children: pad(it.name, 26) }),
36874
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { color: C.muted, children: [
36548
36875
  " ",
36549
36876
  methods
36550
36877
  ] }),
36551
- p.connected.has(it.id) ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { color: C.ok, children: [
36878
+ p.connected.has(it.id) ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { color: C.ok, children: [
36552
36879
  " ",
36553
36880
  G.ok,
36554
36881
  " connected"
36555
36882
  ] }) : null
36556
36883
  ] }, it.id);
36557
36884
  }),
36558
- win.end < list.length ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { color: C.faint, children: [
36885
+ win.end < list.length ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { color: C.faint, children: [
36559
36886
  " ",
36560
36887
  G.down,
36561
36888
  " ",
36562
36889
  list.length - win.end,
36563
36890
  " more"
36891
+ ] }) : null,
36892
+ p.integrations ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { wrap: "truncate-end", children: [
36893
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { color: C.accent, children: [
36894
+ selected === list.length ? G.prompt : " ",
36895
+ " "
36896
+ ] }),
36897
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.accent2, bold: selected === list.length, children: pad("+ Custom provider\u2026", 26) }),
36898
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.muted, children: " any OpenAI- or Anthropic-compatible endpoint" })
36564
36899
  ] }) : null
36565
36900
  ] }),
36566
- p.error ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.err, children: p.error }) : null
36901
+ p.error ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.err, children: p.error }) : null
36567
36902
  ]
36568
36903
  }
36569
36904
  );
@@ -36579,31 +36914,31 @@ function MethodPicker(p) {
36579
36914
  });
36580
36915
  const wLabel = Math.min(40, Math.max(...methods.map((m) => methodLabel(m).length)) + 2);
36581
36916
  const env3 = p.integration.methods.find((m) => m.type === "env");
36582
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
36917
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
36583
36918
  Panel,
36584
36919
  {
36585
36920
  title: `Connect ${p.integration.name}`,
36586
36921
  width: p.width,
36587
36922
  color: p.color,
36588
- footer: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Hints, { items: [["\u2191\u2193", "move"], ["enter", "continue"], ["esc", "back"]] }),
36923
+ footer: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Hints, { items: [["\u2191\u2193", "move"], ["enter", "continue"], ["esc", "back"]] }),
36589
36924
  children: [
36590
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Box_default, { flexDirection: "column", marginTop: 1, children: [
36591
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.muted, children: "How do you want to connect?" }),
36592
- methods.map((m, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { children: [
36593
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { color: C.accent, children: [
36925
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Box_default, { flexDirection: "column", marginTop: 1, children: [
36926
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.muted, children: "How do you want to connect?" }),
36927
+ methods.map((m, i) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { children: [
36928
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { color: C.accent, children: [
36594
36929
  i === sel ? G.prompt : " ",
36595
36930
  " "
36596
36931
  ] }),
36597
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { bold: i === sel, children: pad(methodLabel(m), wLabel) }),
36598
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.faint, children: m.type === "oauth" ? "opens your browser" : "paste a key" })
36932
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { bold: i === sel, children: pad(methodLabel(m), wLabel) }),
36933
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.faint, children: m.type === "oauth" ? "opens your browser" : "paste a key" })
36599
36934
  ] }, m.type + ("id" in m ? m.id : "")))
36600
36935
  ] }),
36601
- env3 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Box_default, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { color: C.faint, children: [
36936
+ env3 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Box_default, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { color: C.faint, children: [
36602
36937
  "Or set ",
36603
36938
  env3.names[0],
36604
36939
  " in your shell before starting LatentCode."
36605
36940
  ] }) }) : null,
36606
- p.error ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.err, children: p.error }) : null
36941
+ p.error ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.err, children: p.error }) : null
36607
36942
  ]
36608
36943
  }
36609
36944
  );
@@ -36629,33 +36964,33 @@ function KeyEntry(p) {
36629
36964
  return false;
36630
36965
  }
36631
36966
  });
36632
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
36967
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
36633
36968
  Panel,
36634
36969
  {
36635
36970
  title: `Connect ${p.integration.name}`,
36636
36971
  right: "API key",
36637
36972
  width: p.width,
36638
36973
  color: p.color,
36639
- footer: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Hints, { items: [["enter", "save"], ["esc", "back"]] }),
36640
- children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Box_default, { flexDirection: "column", marginTop: 1, children: [
36641
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { color: C.muted, children: [
36974
+ footer: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Hints, { items: [["enter", "save"], ["esc", "back"]] }),
36975
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Box_default, { flexDirection: "column", marginTop: 1, children: [
36976
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { color: C.muted, children: [
36642
36977
  "Paste your ",
36643
36978
  p.integration.name,
36644
36979
  " API key."
36645
36980
  ] }),
36646
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Box_default, { marginTop: 1, children: [
36647
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { color: C.accent, children: [
36981
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Box_default, { marginTop: 1, children: [
36982
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { color: C.accent, children: [
36648
36983
  G.key,
36649
36984
  " "
36650
36985
  ] }),
36651
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FieldText, { state: field.state, mask: true, placeholder: "paste the key here" })
36986
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FieldText, { state: field.state, mask: true, placeholder: "paste the key here" })
36652
36987
  ] }),
36653
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Box_default, { marginTop: 1, children: busy ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { children: [
36654
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Spinner, {}),
36988
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Box_default, { marginTop: 1, children: busy ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { children: [
36989
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Spinner, {}),
36655
36990
  " ",
36656
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.muted, children: "Saving\u2026" })
36657
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.faint, children: "Stored by the local engine on this machine. Never sent to Latent." }) }),
36658
- error ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.err, children: error }) : null
36991
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.muted, children: "Saving\u2026" })
36992
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.faint, children: "Stored by the local engine on this machine. Never sent to Latent." }) }),
36993
+ error ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.err, children: error }) : null
36659
36994
  ] })
36660
36995
  }
36661
36996
  );
@@ -36722,37 +37057,200 @@ function OAuthFlow(p) {
36722
37057
  return false;
36723
37058
  }
36724
37059
  });
36725
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
37060
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
36726
37061
  Panel,
36727
37062
  {
36728
37063
  title: `Connect ${p.integration.name}`,
36729
37064
  right: p.method.label,
36730
37065
  width: p.width,
36731
37066
  color: p.color,
36732
- footer: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Hints, { items: codeMode ? [["enter", "submit code"], ["esc", "cancel"]] : [["esc", "cancel"]] }),
36733
- children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Box_default, { flexDirection: "column", marginTop: 1, children: [
36734
- !attempt && !error ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { children: [
36735
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Spinner, {}),
37067
+ footer: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Hints, { items: codeMode ? [["enter", "submit code"], ["esc", "cancel"]] : [["esc", "cancel"]] }),
37068
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Box_default, { flexDirection: "column", marginTop: 1, children: [
37069
+ !attempt && !error ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { children: [
37070
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Spinner, {}),
36736
37071
  " ",
36737
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.muted, children: "Starting sign-in\u2026" })
37072
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.muted, children: "Starting sign-in\u2026" })
36738
37073
  ] }) : null,
36739
- attempt ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
36740
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.muted, children: "Your browser should open. If it does not, open this link:" }),
36741
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.accent2, wrap: "wrap", children: attempt.url }),
36742
- attempt.instructions ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Box_default, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { bold: true, children: attempt.instructions }) }) : null,
36743
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Box_default, { marginTop: 1, children: codeMode ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { children: [
36744
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { color: C.accent, children: [
37074
+ attempt ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
37075
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.muted, children: "Your browser should open. If it does not, open this link:" }),
37076
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.accent2, wrap: "wrap", children: attempt.url }),
37077
+ attempt.instructions ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Box_default, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { bold: true, children: attempt.instructions }) }) : null,
37078
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Box_default, { marginTop: 1, children: codeMode ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { children: [
37079
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { color: C.accent, children: [
36745
37080
  G.key,
36746
37081
  " "
36747
37082
  ] }),
36748
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FieldText, { state: field.state, placeholder: "paste the code from the browser" })
36749
- ] }) : error ? null : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { children: [
36750
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Spinner, {}),
37083
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FieldText, { state: field.state, placeholder: "paste the code from the browser" })
37084
+ ] }) : error ? null : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { children: [
37085
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Spinner, {}),
36751
37086
  " ",
36752
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.muted, children: "Waiting for you to finish in the browser\u2026" })
37087
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.muted, children: "Waiting for you to finish in the browser\u2026" })
36753
37088
  ] }) })
36754
37089
  ] }) : null,
36755
- error ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.err, children: error }) : null
37090
+ error ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.err, children: error }) : null
37091
+ ] })
37092
+ }
37093
+ );
37094
+ }
37095
+ var KINDS = ["openai", "anthropic"];
37096
+ function CustomProviderForm(p) {
37097
+ const [step, setStep] = (0, import_react24.useState)("name");
37098
+ const [name, setName] = (0, import_react24.useState)("");
37099
+ const [kind, setKind] = (0, import_react24.useState)("openai");
37100
+ const [url, setUrl] = (0, import_react24.useState)("");
37101
+ const [key, setKey] = (0, import_react24.useState)("");
37102
+ const [busy, setBusy] = (0, import_react24.useState)("");
37103
+ const [error, setError] = (0, import_react24.useState)("");
37104
+ const order = ["name", "kind", "url", "key", "models"];
37105
+ const back = () => {
37106
+ setError("");
37107
+ const i = order.indexOf(step);
37108
+ if (i <= 0) return p.onBack();
37109
+ const prev = order[i - 1];
37110
+ setStep(prev);
37111
+ field.set(prev === "name" ? name : prev === "url" ? url : prev === "key" ? key : "");
37112
+ };
37113
+ const next = (to, initial = "") => {
37114
+ setError("");
37115
+ setStep(to);
37116
+ field.set(initial);
37117
+ };
37118
+ const save2 = async (modelText) => {
37119
+ setError("");
37120
+ try {
37121
+ let models = parseModelList(modelText);
37122
+ if (!models.length) {
37123
+ setBusy(`Asking ${url}/models\u2026`);
37124
+ try {
37125
+ models = await discoverModels(kind, url, key);
37126
+ } catch (e) {
37127
+ throw new Error(`Could not list the models (${errText(e)}). Type the model ids, separated by commas.`);
37128
+ }
37129
+ if (!models.length) throw new Error("The endpoint lists no models. Type the model ids, separated by commas.");
37130
+ }
37131
+ setBusy("Saving to the engine config\u2026");
37132
+ const dir = await p.engine.configDir() ?? defaultConfigDir();
37133
+ const file = configFileIn(dir);
37134
+ const id = providerIdFor(name, p.taken, configuredProviderIds(readConfigText(file)));
37135
+ const written = writeProviderConfig(file, id, { name, kind, baseURL: url, models });
37136
+ setBusy("Reloading the engine\u2026");
37137
+ await p.engine.reloadConfig();
37138
+ const integration = await p.engine.waitForIntegration(id);
37139
+ if (key) {
37140
+ setBusy("Saving the key\u2026");
37141
+ await p.engine.connectKey(id, key);
37142
+ }
37143
+ const note = `Added as "${id}" (${KIND_LABEL[kind]}, ${models.length} model${models.length === 1 ? "" : "s"}) in ${written.file}.` + (written.backup ? ` Comments in that file could not be kept; the original is at ${written.backup}.` : "") + ` Use it with --model ${id}/${models[0]}.`;
37144
+ await p.onDone(integration, note);
37145
+ } catch (e) {
37146
+ setError(errText(e));
37147
+ setBusy("");
37148
+ }
37149
+ };
37150
+ const field = useLineField({
37151
+ active: !busy && step !== "kind",
37152
+ onChange: () => setError(""),
37153
+ onKey: (_ch, k) => {
37154
+ if (k.escape) return back(), true;
37155
+ if (!k.return) return false;
37156
+ const text = field.text.trim();
37157
+ if (step === "name") {
37158
+ if (!text) return setError("Give it a name, e.g. My Gateway."), true;
37159
+ setName(text);
37160
+ next("kind");
37161
+ } else if (step === "url") {
37162
+ try {
37163
+ const u = normalizeBaseURL(text);
37164
+ setUrl(u);
37165
+ next("key", key);
37166
+ } catch (e) {
37167
+ setError(errText(e));
37168
+ }
37169
+ } else if (step === "key") {
37170
+ setKey(text);
37171
+ next("models");
37172
+ } else if (step === "models") {
37173
+ void save2(text);
37174
+ }
37175
+ return true;
37176
+ }
37177
+ });
37178
+ use_input_default(
37179
+ (_ch, k) => {
37180
+ if (k.escape) return back();
37181
+ if (k.upArrow || k.downArrow || k.tab) return setKind((x) => x === "openai" ? "anthropic" : "openai");
37182
+ if (k.return) next("url", url);
37183
+ },
37184
+ { isActive: !busy && step === "kind" }
37185
+ );
37186
+ const done = (label2, value) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { wrap: "truncate-end", children: [
37187
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { color: C.ok, children: [
37188
+ G.ok,
37189
+ " "
37190
+ ] }),
37191
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.muted, children: pad(label2, 10) }),
37192
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { children: value })
37193
+ ] });
37194
+ const at = order.indexOf(step);
37195
+ const prompt = {
37196
+ name: { label: "Name", hint: "What to call it in the model picker.", placeholder: "e.g. My Gateway" },
37197
+ url: {
37198
+ label: "Base URL",
37199
+ hint: kind === "openai" ? "The URL before /chat/completions \u2014 usually ends in /v1." : "The URL before /messages \u2014 usually ends in /v1.",
37200
+ placeholder: "https://api.example.com/v1"
37201
+ },
37202
+ key: { label: "API key", hint: "Leave empty if the endpoint needs no key (e.g. a local server).", placeholder: "paste the key, or enter to skip" },
37203
+ models: {
37204
+ label: "Models",
37205
+ hint: "Model ids, separated by commas. Leave empty to import every model from the endpoint's /models list.",
37206
+ placeholder: "e.g. gpt-4.1, claude-sonnet-4"
37207
+ }
37208
+ };
37209
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
37210
+ Panel,
37211
+ {
37212
+ title: "Custom provider",
37213
+ right: `step ${at + 1} of ${order.length}`,
37214
+ width: p.width,
37215
+ color: p.color,
37216
+ footer: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
37217
+ Hints,
37218
+ {
37219
+ items: step === "kind" ? [["\u2191\u2193", "choose"], ["enter", "continue"], ["esc", "back"]] : [["enter", step === "models" ? "save" : "continue"], ["esc", "back"]]
37220
+ }
37221
+ ),
37222
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Box_default, { flexDirection: "column", marginTop: 1, children: [
37223
+ at > 0 ? done("Name", name) : null,
37224
+ at > 1 ? done("Type", KIND_LABEL[kind]) : null,
37225
+ at > 2 ? done("Base URL", url) : null,
37226
+ at > 3 ? done("API key", key ? "\u2022".repeat(Math.min(key.length, 12)) : "none") : null,
37227
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Box_default, { marginTop: at > 0 ? 1 : 0, flexDirection: "column", children: step === "kind" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
37228
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.muted, children: "Which API does the endpoint speak?" }),
37229
+ KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { children: [
37230
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { color: C.accent, children: [
37231
+ k === kind ? G.prompt : " ",
37232
+ " "
37233
+ ] }),
37234
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { bold: k === kind, children: pad(KIND_LABEL[k], 24) }),
37235
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.faint, children: k === "openai" ? "/chat/completions \u2014 most gateways, vLLM, Ollama" : "/messages \u2014 Anthropic-style proxies" })
37236
+ ] }, k))
37237
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
37238
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.muted, children: prompt[step].hint }),
37239
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Box_default, { marginTop: 1, children: [
37240
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { color: C.accent, children: [
37241
+ step === "key" ? G.key : G.prompt,
37242
+ " "
37243
+ ] }),
37244
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { bold: true, children: pad(prompt[step].label, 10) }),
37245
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FieldText, { state: field.state, mask: step === "key", placeholder: prompt[step].placeholder })
37246
+ ] })
37247
+ ] }) }),
37248
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Box_default, { marginTop: 1, children: busy ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { children: [
37249
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Spinner, {}),
37250
+ " ",
37251
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.muted, children: busy })
37252
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.faint, children: "The endpoint goes into the engine config; the key into the engine's credential store. Never sent to Latent." }) }),
37253
+ error ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.err, wrap: "wrap", children: error }) : null
36756
37254
  ] })
36757
37255
  }
36758
37256
  );
@@ -36762,21 +37260,24 @@ function Done(p) {
36762
37260
  if (key.return) return p.onModels();
36763
37261
  if (key.escape) p.onClose();
36764
37262
  });
36765
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
37263
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
36766
37264
  Panel,
36767
37265
  {
36768
37266
  title: "Connected",
36769
37267
  width: p.width,
36770
37268
  color: C.ok,
36771
- footer: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Hints, { items: [["enter", "pick a model"], ["esc", "close"]] }),
36772
- children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Box_default, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { children: [
36773
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Text, { color: C.ok, children: [
36774
- G.ok,
36775
- " "
36776
- ] }),
36777
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { bold: true, children: p.name }),
36778
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.muted, children: p.models ? ` is connected \u2014 ${p.models} models available.` : " is connected. Its models will appear after a moment." })
36779
- ] }) })
37269
+ footer: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Hints, { items: [["enter", "pick a model"], ["esc", "close"]] }),
37270
+ children: [
37271
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Box_default, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { children: [
37272
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { color: C.ok, children: [
37273
+ G.ok,
37274
+ " "
37275
+ ] }),
37276
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { bold: true, children: p.name }),
37277
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.muted, children: p.models ? ` is connected \u2014 ${p.models} models available.` : " is connected. Its models will appear after a moment." })
37278
+ ] }) }),
37279
+ p.note ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Box_default, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.faint, wrap: "wrap", children: p.note }) }) : null
37280
+ ]
36780
37281
  }
36781
37282
  );
36782
37283
  }
@@ -36947,7 +37448,7 @@ You can still connect an address you control: latentcode login --wallet 0x\u2026
36947
37448
  }
36948
37449
 
36949
37450
  // src/ui/panels/WalletPanel.tsx
36950
- var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
37451
+ var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
36951
37452
  var deps = (server, extra) => ({
36952
37453
  server,
36953
37454
  log: () => {
@@ -36965,13 +37466,13 @@ function WalletPanel(p) {
36965
37466
  };
36966
37467
  switch (view.v) {
36967
37468
  case "menu":
36968
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Menu, { ...p, onPick: (v) => setView({ v }) });
37469
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Menu, { ...p, onPick: (v) => setView({ v }) });
36969
37470
  case "link":
36970
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(AuthLink, { ...p, onDone: done, onBack: () => setView({ v: "menu" }) });
37471
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AuthLink, { ...p, onDone: done, onBack: () => setView({ v: "menu" }) });
36971
37472
  case "address":
36972
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Address, { ...p, onDone: done, onBack: () => setView({ v: "menu" }) });
37473
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Address, { ...p, onDone: done, onBack: () => setView({ v: "menu" }) });
36973
37474
  case "done":
36974
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Done2, { width: p.width, wallet: view.wallet, onClose: p.onClose });
37475
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Done2, { width: p.width, wallet: view.wallet, onClose: p.onClose });
36975
37476
  }
36976
37477
  }
36977
37478
  function Menu(p) {
@@ -36985,23 +37486,23 @@ function Menu(p) {
36985
37486
  if (key.upArrow || key.downArrow || key.tab) return setSel((s2) => (s2 + 1) % options.length);
36986
37487
  if (key.return) p.onPick(options[sel].id);
36987
37488
  });
36988
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
37489
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
36989
37490
  Panel,
36990
37491
  {
36991
37492
  title: "Wallet",
36992
37493
  right: p.wallet ? `connected \xB7 ${shortWallet(p.wallet)}` : "not connected",
36993
37494
  width: p.width,
36994
37495
  color: C.earn,
36995
- footer: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Hints, { items: [["\u2191\u2193", "move"], ["enter", "continue"], ["esc", "close"]] }),
36996
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Box_default, { flexDirection: "column", marginTop: 1, children: [
36997
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.muted, wrap: "wrap", children: p.wallet ? "Earn mode pays into this wallet. Connect a different one:" : "Earn mode pays you in USDC while the agent works. Connect the wallet it should pay into:" }),
36998
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Box_default, { flexDirection: "column", marginTop: 1, children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { children: [
36999
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { color: C.earn, children: [
37496
+ footer: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Hints, { items: [["\u2191\u2193", "move"], ["enter", "continue"], ["esc", "close"]] }),
37497
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Box_default, { flexDirection: "column", marginTop: 1, children: [
37498
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: C.muted, wrap: "wrap", children: p.wallet ? "Earn mode pays into this wallet. Connect a different one:" : "Earn mode pays you in USDC while the agent works. Connect the wallet it should pay into:" }),
37499
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Box_default, { flexDirection: "column", marginTop: 1, children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { children: [
37500
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { color: C.earn, children: [
37000
37501
  i === sel ? G.prompt : " ",
37001
37502
  " "
37002
37503
  ] }),
37003
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { bold: i === sel, children: o.label.padEnd(27) }),
37004
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.faint, children: o.hint })
37504
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { bold: i === sel, children: o.label.padEnd(27) }),
37505
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: C.faint, children: o.hint })
37005
37506
  ] }, o.id)) })
37006
37507
  ] })
37007
37508
  }
@@ -37030,34 +37531,34 @@ function AuthLink(p) {
37030
37531
  if (key.escape) p.onBack();
37031
37532
  if (key.return && link2) openUrl(link2.url);
37032
37533
  });
37033
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
37534
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
37034
37535
  Panel,
37035
37536
  {
37036
37537
  title: "Sign in",
37037
37538
  right: "Latent wallet",
37038
37539
  width: p.width,
37039
37540
  color: C.earn,
37040
- footer: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Hints, { items: [["enter", "open the link again"], ["esc", "cancel"]] }),
37041
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Box_default, { flexDirection: "column", marginTop: 1, children: [
37042
- !link2 && !error ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { children: [
37043
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Spinner, { color: C.earn }),
37541
+ footer: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Hints, { items: [["enter", "open the link again"], ["esc", "cancel"]] }),
37542
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Box_default, { flexDirection: "column", marginTop: 1, children: [
37543
+ !link2 && !error ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { children: [
37544
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Spinner, { color: C.earn }),
37044
37545
  " ",
37045
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.muted, children: "Preparing your sign-in link\u2026" })
37546
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: C.muted, children: "Preparing your sign-in link\u2026" })
37046
37547
  ] }) : null,
37047
- link2 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
37048
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.muted, children: "Your browser should open. If it does not, open:" }),
37049
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.accent2, wrap: "wrap", children: link2.url }),
37050
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Box_default, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { children: [
37051
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.muted, children: "Code " }),
37052
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { bold: true, color: C.earn, children: link2.code })
37548
+ link2 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
37549
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: C.muted, children: "Your browser should open. If it does not, open:" }),
37550
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: C.accent2, wrap: "wrap", children: link2.url }),
37551
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Box_default, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { children: [
37552
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: C.muted, children: "Code " }),
37553
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { bold: true, color: C.earn, children: link2.code })
37053
37554
  ] }) }),
37054
- error ? null : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Box_default, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { children: [
37055
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Spinner, { color: C.earn }),
37555
+ error ? null : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Box_default, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { children: [
37556
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Spinner, { color: C.earn }),
37056
37557
  " ",
37057
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.muted, children: "Waiting for you to finish in the browser\u2026" })
37558
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: C.muted, children: "Waiting for you to finish in the browser\u2026" })
37058
37559
  ] }) })
37059
37560
  ] }) : null,
37060
- error ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Box_default, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.err, wrap: "wrap", children: error }) }) : null
37561
+ error ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Box_default, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: C.err, wrap: "wrap", children: error }) }) : null
37061
37562
  ] })
37062
37563
  }
37063
37564
  );
@@ -37080,23 +37581,23 @@ function Address(p) {
37080
37581
  return false;
37081
37582
  }
37082
37583
  });
37083
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
37584
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
37084
37585
  Panel,
37085
37586
  {
37086
37587
  title: "Wallet address",
37087
37588
  width: p.width,
37088
37589
  color: C.earn,
37089
- footer: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Hints, { items: [["enter", "save"], ["esc", "back"]] }),
37090
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Box_default, { flexDirection: "column", marginTop: 1, children: [
37091
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.muted, children: "Earnings are paid in USDC to this address. Use one you control." }),
37092
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Box_default, { marginTop: 1, children: [
37093
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { color: C.earn, children: [
37590
+ footer: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Hints, { items: [["enter", "save"], ["esc", "back"]] }),
37591
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Box_default, { flexDirection: "column", marginTop: 1, children: [
37592
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: C.muted, children: "Earnings are paid in USDC to this address. Use one you control." }),
37593
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Box_default, { marginTop: 1, children: [
37594
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { color: C.earn, children: [
37094
37595
  G.earn,
37095
37596
  " "
37096
37597
  ] }),
37097
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FieldText, { state: field.state, placeholder: "0x\u2026" })
37598
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FieldText, { state: field.state, placeholder: "0x\u2026" })
37098
37599
  ] }),
37099
- error ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.err, children: error }) : null
37600
+ error ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: C.err, children: error }) : null
37100
37601
  ] })
37101
37602
  }
37102
37603
  );
@@ -37105,19 +37606,19 @@ function Done2(p) {
37105
37606
  use_input_default((_ch, key) => {
37106
37607
  if (key.return || key.escape) p.onClose();
37107
37608
  });
37108
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Panel, { title: "Wallet connected", width: p.width, color: C.ok, footer: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Hints, { items: [["enter", "continue"]] }), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Box_default, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { children: [
37109
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Text, { color: C.ok, children: [
37609
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Panel, { title: "Wallet connected", width: p.width, color: C.ok, footer: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Hints, { items: [["enter", "continue"]] }), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Box_default, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { children: [
37610
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { color: C.ok, children: [
37110
37611
  G.ok,
37111
37612
  " "
37112
37613
  ] }),
37113
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { children: "Earn mode pays into " }),
37114
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { bold: true, children: shortWallet(p.wallet) }),
37115
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Text, { color: C.muted, children: ". You earn while the agent works." })
37614
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { children: "Earn mode pays into " }),
37615
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { bold: true, children: shortWallet(p.wallet) }),
37616
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: C.muted, children: ". You earn while the agent works." })
37116
37617
  ] }) }) });
37117
37618
  }
37118
37619
 
37119
37620
  // src/ui/App.tsx
37120
- var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
37621
+ var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
37121
37622
  var notice = (text, tone = "info") => ({
37122
37623
  type: "latentcode.notice",
37123
37624
  created: Date.now(),
@@ -37149,42 +37650,42 @@ function activityLabel(s2) {
37149
37650
  function StepMark({ status: status2 }) {
37150
37651
  switch (status2) {
37151
37652
  case "run":
37152
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Spinner, {});
37653
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Spinner, {});
37153
37654
  case "ok":
37154
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: C.ok, children: G.ok });
37655
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.ok, children: G.ok });
37155
37656
  case "warn":
37156
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: C.warn, children: G.ring });
37657
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.warn, children: G.ring });
37157
37658
  case "fail":
37158
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: C.err, children: G.no });
37659
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.err, children: G.no });
37159
37660
  default:
37160
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: C.faint, children: "\xB7" });
37661
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.faint, children: "\xB7" });
37161
37662
  }
37162
37663
  }
37163
37664
  function BootCard(p) {
37164
37665
  const wLabel = 10;
37165
37666
  const inner = p.width - 4;
37166
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Box_default, { flexDirection: "column", children: [
37167
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Box_default, { marginTop: 1, marginLeft: 1, flexDirection: "column", children: [
37168
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Logo, { version: p.version }),
37169
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: C.muted, children: TAGLINE })
37667
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Box_default, { flexDirection: "column", children: [
37668
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Box_default, { marginTop: 1, marginLeft: 1, flexDirection: "column", children: [
37669
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Logo, { version: p.version }),
37670
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.muted, children: TAGLINE })
37170
37671
  ] }),
37171
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Box_default, { marginTop: 1, flexDirection: "column", borderStyle: "round", borderColor: p.error ? C.err : C.border, paddingX: 1, width: p.width, children: [
37172
- p.steps.map((st) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { wrap: "truncate-end", children: [
37173
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(StepMark, { status: st.status }),
37174
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { bold: st.status === "run", color: st.status === "pending" ? C.faint : void 0, children: [
37672
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Box_default, { marginTop: 1, flexDirection: "column", borderStyle: "round", borderColor: p.error ? C.err : C.border, paddingX: 1, width: p.width, children: [
37673
+ p.steps.map((st) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { wrap: "truncate-end", children: [
37674
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StepMark, { status: st.status }),
37675
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { bold: st.status === "run", color: st.status === "pending" ? C.faint : void 0, children: [
37175
37676
  " ",
37176
37677
  pad(st.label, wLabel)
37177
37678
  ] }),
37178
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: st.status === "fail" ? C.err : st.status === "warn" ? C.warn : C.muted, children: st.status === "run" && !st.detail ? "starting\u2026" : clip(st.detail, inner - wLabel - 4) })
37679
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: st.status === "fail" ? C.err : st.status === "warn" ? C.warn : C.muted, children: st.status === "run" && !st.detail ? "starting\u2026" : clip(st.detail, inner - wLabel - 4) })
37179
37680
  ] }, st.id)),
37180
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { wrap: "truncate-end", children: [
37181
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: C.faint, children: "\xB7 " }),
37182
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: C.faint, children: pad("Project", wLabel) }),
37183
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: C.muted, children: shortPath(p.cwd, homedir3(), inner - wLabel - 4) })
37681
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { wrap: "truncate-end", children: [
37682
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.faint, children: "\xB7 " }),
37683
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.faint, children: pad("Project", wLabel) }),
37684
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.muted, children: shortPath(p.cwd, homedir4(), inner - wLabel - 4) })
37184
37685
  ] })
37185
37686
  ] }),
37186
- p.error ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Box_default, { marginLeft: 1, marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: C.err, wrap: "wrap", children: p.error }) }) : null,
37187
- p.ready ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Box_default, { marginLeft: 1, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
37687
+ p.error ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Box_default, { marginLeft: 1, marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.err, wrap: "wrap", children: p.error }) }) : null,
37688
+ p.ready ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Box_default, { marginLeft: 1, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
37188
37689
  Hints,
37189
37690
  {
37190
37691
  items: [
@@ -37213,26 +37714,26 @@ function HelpPanel({ width, commands, onClose }) {
37213
37714
  ["ctrl+o", "open the sponsored link"],
37214
37715
  ["ctrl+c", "clear the line, twice to quit"]
37215
37716
  ];
37216
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Panel, { title: "Help", width, color: C.accent, footer: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Hints, { items: [["esc", "close"]] }), children: [
37717
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Panel, { title: "Help", width, color: C.accent, footer: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Hints, { items: [["esc", "close"]] }), children: [
37217
37718
  groups.map((g) => {
37218
37719
  const list = commands.filter((c) => c.group === g);
37219
37720
  if (!list.length) return null;
37220
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Box_default, { flexDirection: "column", marginTop: 1, children: [
37221
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { bold: true, color: C.muted, children: g }),
37222
- list.map((c) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { wrap: "truncate-end", children: [
37223
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: C.accent2, children: pad(`/${c.name}${c.args ? " " + c.args : ""}`, 22) }),
37224
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: C.muted, children: c.desc })
37721
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Box_default, { flexDirection: "column", marginTop: 1, children: [
37722
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { bold: true, color: C.muted, children: g }),
37723
+ list.map((c) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { wrap: "truncate-end", children: [
37724
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.accent2, children: pad(`/${c.name}${c.args ? " " + c.args : ""}`, 22) }),
37725
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.muted, children: c.desc })
37225
37726
  ] }, c.name))
37226
37727
  ] }, g);
37227
37728
  }),
37228
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Box_default, { flexDirection: "column", marginTop: 1, children: [
37229
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { bold: true, color: C.muted, children: "Keys" }),
37230
- keys.map(([k, d]) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { children: [
37231
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: C.accent2, children: pad(k, 22) }),
37232
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: C.muted, children: d })
37729
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Box_default, { flexDirection: "column", marginTop: 1, children: [
37730
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { bold: true, color: C.muted, children: "Keys" }),
37731
+ keys.map(([k, d]) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { children: [
37732
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.accent2, children: pad(k, 22) }),
37733
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.muted, children: d })
37233
37734
  ] }, k))
37234
37735
  ] }),
37235
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Box_default, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: C.faint, wrap: "wrap", children: `Privacy: ads never enter the model's context or its answers. The only thing sent to the ad server is a coarse category (for example "backend"), worked out on this machine.` }) })
37736
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Box_default, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.faint, wrap: "wrap", children: `Privacy: ads never enter the model's context or its answers. The only thing sent to the ad server is a coarse category (for example "backend"), worked out on this machine.` }) })
37236
37737
  ] });
37237
37738
  }
37238
37739
  function App2(props) {
@@ -37530,19 +38031,19 @@ Wallet ${shortWallet(wallet)} \xB7 unpaid balance ${bal === null ? "unavailable
37530
38031
  const current = catalog.models.find((m) => m.key === state.model);
37531
38032
  const provider = catalog.providers.find((p) => p.id === (current?.providerID ?? parseKey(state.model)?.providerID));
37532
38033
  const close = () => setOverlay(null);
37533
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
37534
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Static, { items: [header, ...done.map((it) => ({ id: it.id, it }))], children: (entry) => "it" in entry ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ItemView, { item: entry.it, live: false, cwd: cwd2, width, maxLines }, entry.id) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(BootCard, { steps: props.bootSteps, version, cwd: cwd2, width, ready: true }, entry.id) }),
37535
- live.map((it) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ItemView, { item: it, live: true, cwd: cwd2, width, maxLines }, it.id)),
37536
- perm ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PermissionPrompt, { perm, selected: permAt, cwd: cwd2, width }) : null,
37537
- state.working ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Box_default, { marginTop: 1, flexDirection: "column", width, children: [
37538
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { wrap: "truncate-end", children: [
37539
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Spinner, {}),
37540
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { children: [
38034
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
38035
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Static, { items: [header, ...done.map((it) => ({ id: it.id, it }))], children: (entry) => "it" in entry ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ItemView, { item: entry.it, live: false, cwd: cwd2, width, maxLines }, entry.id) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(BootCard, { steps: props.bootSteps, version, cwd: cwd2, width, ready: true }, entry.id) }),
38036
+ live.map((it) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ItemView, { item: it, live: true, cwd: cwd2, width, maxLines }, it.id)),
38037
+ perm ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(PermissionPrompt, { perm, selected: permAt, cwd: cwd2, width }) : null,
38038
+ state.working ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Box_default, { marginTop: 1, flexDirection: "column", width, children: [
38039
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { wrap: "truncate-end", children: [
38040
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Spinner, {}),
38041
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { children: [
37541
38042
  " ",
37542
38043
  activityLabel(state),
37543
38044
  "\u2026"
37544
38045
  ] }),
37545
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { color: C.faint, children: [
38046
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { color: C.faint, children: [
37546
38047
  " ",
37547
38048
  elapsed,
37548
38049
  "s \xB7 ",
@@ -37554,34 +38055,9 @@ Wallet ${shortWallet(wallet)} \xB7 unpaid balance ${bal === null ? "unavailable
37554
38055
  " \xB7 esc to interrupt"
37555
38056
  ] })
37556
38057
  ] }),
37557
- ad.current ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Box_default, { justifyContent: "space-between", children: [
37558
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { wrap: "truncate-end", children: [
37559
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { color: C.earn, children: [
37560
- G.earn,
37561
- " Sponsored"
37562
- ] }),
37563
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { color: C.faint, children: [
37564
- " ",
37565
- G.thin,
37566
- " "
37567
- ] }),
37568
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { bold: true, children: ad.current.title }),
37569
- ad.current.body ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { color: C.muted, children: [
37570
- " \u2014 ",
37571
- ad.current.body
37572
- ] }) : null,
37573
- ad.current.url ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { color: C.faint, children: [
37574
- " \xB7 ctrl+o ",
37575
- ad.current.ctaText
37576
- ] }) : null
37577
- ] }),
37578
- ad.billed && ad.current.earn > 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { color: C.earn, children: [
37579
- " +$",
37580
- ad.current.earn.toFixed(4)
37581
- ] }) : null
37582
- ] }) : null
38058
+ ad.current ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SponsoredLine, { ad: ad.current, billed: ad.billed }) : null
37583
38059
  ] }) : null,
37584
- overlay?.t === "model" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
38060
+ overlay?.t === "model" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
37585
38061
  ModelPicker,
37586
38062
  {
37587
38063
  catalog,
@@ -37600,7 +38076,7 @@ Wallet ${shortWallet(wallet)} \xB7 unpaid balance ${bal === null ? "unavailable
37600
38076
  onClose: close
37601
38077
  }
37602
38078
  ) : null,
37603
- overlay?.t === "providers" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
38079
+ overlay?.t === "providers" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
37604
38080
  ProviderPanel,
37605
38081
  {
37606
38082
  engine,
@@ -37619,10 +38095,10 @@ Wallet ${shortWallet(wallet)} \xB7 unpaid balance ${bal === null ? "unavailable
37619
38095
  onClose: close
37620
38096
  }
37621
38097
  ) : null,
37622
- overlay?.t === "wallet" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(WalletPanel, { server: props.server, wallet, width, onWallet: changeWallet, onClose: close }) : null,
37623
- overlay?.t === "help" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(HelpPanel, { width, commands: allCommands, onClose: close }) : null,
37624
- overlay === null && !perm && !leaving ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
37625
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
38098
+ overlay?.t === "wallet" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(WalletPanel, { server: props.server, wallet, width, onWallet: changeWallet, onClose: close }) : null,
38099
+ overlay?.t === "help" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(HelpPanel, { width, commands: allCommands, onClose: close }) : null,
38100
+ overlay === null && !perm && !leaving ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
38101
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
37626
38102
  Box_default,
37627
38103
  {
37628
38104
  marginTop: 1,
@@ -37631,45 +38107,45 @@ Wallet ${shortWallet(wallet)} \xB7 unpaid balance ${bal === null ? "unavailable
37631
38107
  paddingX: 1,
37632
38108
  width,
37633
38109
  children: [
37634
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Box_default, { flexShrink: 0, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { color: C.accent, bold: true, children: [
38110
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Box_default, { flexShrink: 0, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { color: C.accent, bold: true, children: [
37635
38111
  G.prompt,
37636
38112
  " "
37637
38113
  ] }) }),
37638
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FieldText, { state: editor, placeholder: state.turns ? "reply, or / for commands" : "ask anything, or / for commands" })
38114
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FieldText, { state: editor, placeholder: state.turns ? "reply, or / for commands" : "ask anything, or / for commands" })
37639
38115
  ]
37640
38116
  }
37641
38117
  ),
37642
- paletteOpen ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Box_default, { flexDirection: "column", paddingX: 2, width, children: [
37643
- matches.slice(0, 8).map((c, i) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { wrap: "truncate-end", children: [
37644
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { color: C.accent, children: [
38118
+ paletteOpen ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Box_default, { flexDirection: "column", paddingX: 2, width, children: [
38119
+ matches.slice(0, 8).map((c, i) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { wrap: "truncate-end", children: [
38120
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { color: C.accent, children: [
37645
38121
  i === paletteSel ? G.prompt : " ",
37646
38122
  " "
37647
38123
  ] }),
37648
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { bold: i === paletteSel, color: i === paletteSel ? C.accent2 : C.text, children: pad(`/${c.name}${c.args ? " " + c.args : ""}`, 20) }),
37649
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: C.muted, children: c.desc })
38124
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { bold: i === paletteSel, color: i === paletteSel ? C.accent2 : C.text, children: pad(`/${c.name}${c.args ? " " + c.args : ""}`, 20) }),
38125
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.muted, children: c.desc })
37650
38126
  ] }, c.name)),
37651
- matches.length > 8 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { color: C.faint, children: [
38127
+ matches.length > 8 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { color: C.faint, children: [
37652
38128
  " ",
37653
38129
  G.down,
37654
38130
  " ",
37655
38131
  matches.length - 8,
37656
38132
  " more \u2014 keep typing"
37657
38133
  ] }) : null,
37658
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Hints, { items: [["\u2191\u2193", "move"], ["tab", "complete"], ["enter", "run"], ["esc", "dismiss"]] })
38134
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Hints, { items: [["\u2191\u2193", "move"], ["tab", "complete"], ["enter", "run"], ["esc", "dismiss"]] })
37659
38135
  ] }) : null
37660
38136
  ] }) : null,
37661
- paletteOpen || leaving ? null : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Box_default, { width, justifyContent: "space-between", paddingX: 1, children: [
37662
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { wrap: "truncate-end", children: quitArmed ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: C.warn, children: "Press ctrl+c again to quit" }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
37663
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { color: current ? C.text : C.warn, children: current?.name ?? (state.model || "no model") }),
37664
- state.variant ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { color: C.accent2, children: [
38137
+ paletteOpen || leaving ? null : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Box_default, { width, justifyContent: "space-between", paddingX: 1, children: [
38138
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { wrap: "truncate-end", children: quitArmed ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.warn, children: "Press ctrl+c again to quit" }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
38139
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: current ? C.text : C.warn, children: current?.name ?? (state.model || "no model") }),
38140
+ state.variant ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { color: C.accent2, children: [
37665
38141
  " ",
37666
38142
  state.variant
37667
38143
  ] }) : null,
37668
- provider ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { color: C.faint, children: [
38144
+ provider ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { color: C.faint, children: [
37669
38145
  " \xB7 ",
37670
38146
  provider.name
37671
38147
  ] }) : null,
37672
- state.tokens.input + state.tokens.output ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { color: C.faint, children: [
38148
+ state.tokens.input + state.tokens.output ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { color: C.faint, children: [
37673
38149
  " ",
37674
38150
  "\xB7 ",
37675
38151
  fmtTokens(state.tokens.input + state.tokens.output),
@@ -37677,21 +38153,21 @@ Wallet ${shortWallet(wallet)} \xB7 unpaid balance ${bal === null ? "unavailable
37677
38153
  state.cost ? ` \xB7 ${fmtUsd(state.cost)}` : ""
37678
38154
  ] }) : null
37679
38155
  ] }) }),
37680
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { wrap: "truncate-end", children: ad.status === "ok" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { color: C.earn, children: [
38156
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { wrap: "truncate-end", children: ad.status === "ok" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { color: C.earn, children: [
37681
38157
  G.earn,
37682
38158
  " $",
37683
38159
  ad.sessionEarned.toFixed(4),
37684
38160
  " earned",
37685
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { color: C.faint, children: [
38161
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { color: C.faint, children: [
37686
38162
  " \xB7 ",
37687
38163
  ad.impressions,
37688
38164
  " view",
37689
38165
  ad.impressions === 1 ? "" : "s"
37690
38166
  ] })
37691
- ] }) : ad.status === "disabled" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { color: C.faint, children: [
38167
+ ] }) : ad.status === "disabled" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { color: C.faint, children: [
37692
38168
  G.earn,
37693
38169
  " Earn off \xB7 /ads on"
37694
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text, { color: C.warn, children: [
38170
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { color: C.warn, children: [
37695
38171
  G.earn,
37696
38172
  " /login to start earning"
37697
38173
  ] }) })
@@ -37700,7 +38176,7 @@ Wallet ${shortWallet(wallet)} \xB7 unpaid balance ${bal === null ? "unavailable
37700
38176
  }
37701
38177
 
37702
38178
  // src/ui/Root.tsx
37703
- var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
38179
+ var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
37704
38180
  function Root(p) {
37705
38181
  const { exit } = use_app_default();
37706
38182
  const { cols } = useTermSize();
@@ -37722,7 +38198,7 @@ function Root(p) {
37722
38198
  { isActive: !booted }
37723
38199
  );
37724
38200
  if (!booted) {
37725
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
38201
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
37726
38202
  BootCard,
37727
38203
  {
37728
38204
  steps,
@@ -37734,7 +38210,7 @@ function Root(p) {
37734
38210
  }
37735
38211
  );
37736
38212
  }
37737
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(PasteContext.Provider, { value: p.paste, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(App2, { ...booted, version: p.version, bootSteps: steps, summary: p.summary }) });
38213
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(PasteContext.Provider, { value: p.paste, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(App2, { ...booted, version: p.version, bootSteps: steps, summary: p.summary }) });
37738
38214
  }
37739
38215
 
37740
38216
  // src/ads/attention.ts
@@ -37784,6 +38260,27 @@ var FocusTracker = class {
37784
38260
  }
37785
38261
  };
37786
38262
 
38263
+ // src/ui/syncOutput.ts
38264
+ var BSU = "\x1B[?2026h";
38265
+ var ESU = "\x1B[?2026l";
38266
+ function wrapFrame(chunk) {
38267
+ if (typeof chunk === "string") return chunk ? BSU + chunk + ESU : chunk;
38268
+ if (!chunk.length) return chunk;
38269
+ return Buffer.concat([Buffer.from(BSU), chunk, Buffer.from(ESU)]);
38270
+ }
38271
+ function syncedStdout(stream = process.stdout, env3 = process.env) {
38272
+ if (env3.LATENTCODE_SYNC_OUTPUT === "off") return stream;
38273
+ return new Proxy(stream, {
38274
+ get(target, prop) {
38275
+ if (prop === "write") {
38276
+ return (chunk, ...rest) => target.write(wrapFrame(chunk), ...rest);
38277
+ }
38278
+ const v = Reflect.get(target, prop, target);
38279
+ return typeof v === "function" ? v.bind(target) : v;
38280
+ }
38281
+ });
38282
+ }
38283
+
37787
38284
  // src/ui/stdin.ts
37788
38285
  import { PassThrough as PassThrough2 } from "node:stream";
37789
38286
  var PASTE_ENABLE = "\x1B[?2004h";
@@ -37929,8 +38426,8 @@ function row(mark, label2, value, width = 10) {
37929
38426
  }
37930
38427
 
37931
38428
  // src/index.tsx
37932
- var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
37933
- var VERSION = "0.1.0-alpha.1";
38429
+ var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
38430
+ var VERSION = "0.1.0-alpha.3";
37934
38431
  var usage = () => `${logo()}
37935
38432
  ${a.dim(`v${VERSION} \xB7 terminal coding agent. Bring your own model access; earn while it works.`)}
37936
38433
 
@@ -38070,7 +38567,7 @@ async function main() {
38070
38567
  const summary = { current: { turns: 0, tokens: 0, cost: 0, earned: 0, impressions: 0 } };
38071
38568
  let fatal = false;
38072
38569
  const app = render_default(
38073
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
38570
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
38074
38571
  Root,
38075
38572
  {
38076
38573
  args: { cwd: cwd2, model: args.model, noAds: args.noAds, auto: args.auto },
@@ -38083,7 +38580,7 @@ async function main() {
38083
38580
  }
38084
38581
  }
38085
38582
  ),
38086
- { stdin, exitOnCtrlC: false }
38583
+ { stdin, stdout: syncedStdout(), exitOnCtrlC: false }
38087
38584
  );
38088
38585
  await app.waitUntilExit();
38089
38586
  if (!fatal && (summary.current.turns || summary.current.impressions)) process.stdout.write(goodbye(summary.current));