latentcode 0.1.0-alpha.8 → 0.1.0-alpha.9

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.
package/README.md CHANGED
@@ -3,7 +3,9 @@
3
3
  Terminal coding agent that pays you for its idle time.
4
4
 
5
5
  - **Bring your own model access.** API keys or a provider subscription where the provider allows third-party clients. Connect them inside the app with `/connect`.
6
- - **Earn mode.** A clearly labelled sponsored slot sits in the status dock under the input, next to your model, provider, credit balance and session earnings. It appears while the agent works and stays after the reply; a view counts after 10 s with the terminal focused (idle time counts only while you are active). You earn Latent Credit from it on your Latent wallet (the same wallet the other Latent surfaces use): $1 of model usage per credit with a bonus when you keep it — spend it with `/key`, or sell it for USDG.
6
+ - **Earn mode.** A clearly labelled sponsored slot sits in the status dock under the input, next to your model, provider, credit balance and session earnings. It appears while the agent works and stays after the reply; a view counts after 10 s with the terminal focused (idle time counts only while you are active). You earn Latent Credit from it on your Latent wallet (the same wallet the other Latent surfaces use): $1 of model usage per credit with a bonus when you keep it — spend it on the Latent provider, or sell it for USDC on Base.
7
+ - **Latent provider (via Venice).** `/login` connects it: Venice models paid from your credits at Venice list price (1 credit = $1 of list usage). The model picker lists it first, then your own Venice key, your subscriptions and the rest; Latent prices read in credits per 1M tokens, and the dock shows what the session spent in credits.
8
+ - **Overflow.** When a subscription or key hits its usage limit and you have credit, LatentCode offers to carry on with the closest Latent model (`enter` switches and continues, `s` only switches, `esc` stays). Once per model per session; `/model` switches back.
7
9
  - **The model is never for sale.** Ads never enter the model's context or output, and the agent never recommends sponsored tools. The only targeting signal that leaves your machine is a coarse category slug (for example `backend`), classified locally.
8
10
  - **Real attention.** An impression is billed once, and only after the ad has been on screen for 10 s while the terminal is focused (xterm focus events, DEC 1004) — the ad server's view floor, the same rule as every other Latent surface. A turn that ends earlier keeps the ad for the next turn instead of wasting it. Only impressions the server confirms count toward the session tally.
9
11
  - **Clickable.** In terminals with hyperlinks (iTerm2, Ghostty, Kitty, WezTerm, VS Code, Windows Terminal) the sponsored copy itself is a link; elsewhere the short URL is shown beside it. A coloured monogram badge (stable per brand) leads the line in every terminal. `ctrl+o` works everywhere. Every click goes through the ad server's tracked redirect. `LATENTCODE_LINKS=osc8|plain|hybrid` overrides the detection.
@@ -25,7 +27,7 @@ Type `/` for the command palette.
25
27
 
26
28
  | Command | What it does |
27
29
  | --- | --- |
28
- | `/model [name]` | Model picker: search across every provider, `tab` to filter by provider, `←` `→` to set the effort level, `ctrl+t` to test a model with your account. `✓` marks models proven to work with your account. |
30
+ | `/model [name]` | Model picker, Latent first: search across every provider, `tab` to filter by provider, `←` `→` to set the effort level, `ctrl+t` to test a model with your account. `✓` marks models proven to work with your account. |
29
31
  | `/providers` | Connected providers, how each is connected (account sign-in, API key, env var, built in) and how many models it offers. |
30
32
  | `/connect [provider]` | Connect a provider without leaving the app: paste an API key or sign in through the browser. Credentials are stored by the local engine. The last entry, **+ Custom provider…** (or `/connect custom`), adds any OpenAI- or Anthropic-compatible endpoint — see below. |
31
33
  | `/login` | Connect the wallet Earn mode pays into: browser sign-in, or an address you control. |
@@ -23432,26 +23432,26 @@ var require_permessage_deflate = __commonJS({
23432
23432
  value = value[0];
23433
23433
  if (key === "client_max_window_bits") {
23434
23434
  if (value !== true) {
23435
- const num2 = +value;
23436
- if (!Number.isInteger(num2) || num2 < 8 || num2 > 15) {
23435
+ const num3 = +value;
23436
+ if (!Number.isInteger(num3) || num3 < 8 || num3 > 15) {
23437
23437
  throw new TypeError(
23438
23438
  `Invalid value for parameter "${key}": ${value}`
23439
23439
  );
23440
23440
  }
23441
- value = num2;
23441
+ value = num3;
23442
23442
  } else if (!this._isServer) {
23443
23443
  throw new TypeError(
23444
23444
  `Invalid value for parameter "${key}": ${value}`
23445
23445
  );
23446
23446
  }
23447
23447
  } else if (key === "server_max_window_bits") {
23448
- const num2 = +value;
23449
- if (!Number.isInteger(num2) || num2 < 8 || num2 > 15) {
23448
+ const num3 = +value;
23449
+ if (!Number.isInteger(num3) || num3 < 8 || num3 > 15) {
23450
23450
  throw new TypeError(
23451
23451
  `Invalid value for parameter "${key}": ${value}`
23452
23452
  );
23453
23453
  }
23454
- value = num2;
23454
+ value = num3;
23455
23455
  } else if (key === "client_no_context_takeover" || key === "server_no_context_takeover") {
23456
23456
  if (value !== true) {
23457
23457
  throw new TypeError(
@@ -24165,8 +24165,8 @@ var require_receiver = __commonJS({
24165
24165
  return;
24166
24166
  }
24167
24167
  const buf = this.consume(8);
24168
- const num2 = buf.readUInt32BE(0);
24169
- if (num2 > Math.pow(2, 53 - 32) - 1) {
24168
+ const num3 = buf.readUInt32BE(0);
24169
+ if (num3 > Math.pow(2, 53 - 32) - 1) {
24170
24170
  const error = this.createError(
24171
24171
  RangeError,
24172
24172
  "Unsupported WebSocket frame: payload length > 2^53 - 1",
@@ -24177,7 +24177,7 @@ var require_receiver = __commonJS({
24177
24177
  cb(error);
24178
24178
  return;
24179
24179
  }
24180
- this._payloadLength = num2 * Math.pow(2, 32) + buf.readUInt32BE(4);
24180
+ this._payloadLength = num3 * Math.pow(2, 32) + buf.readUInt32BE(4);
24181
24181
  this.haveLength(cb);
24182
24182
  }
24183
24183
  /**
@@ -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 jsx10 = jsxWithValidationDynamic;
28212
- var jsxs8 = jsxWithValidationStatic;
28211
+ var jsx11 = jsxWithValidationDynamic;
28212
+ var jsxs9 = jsxWithValidationStatic;
28213
28213
  exports.Fragment = REACT_FRAGMENT_TYPE;
28214
- exports.jsx = jsx10;
28215
- exports.jsxs = jsxs8;
28214
+ exports.jsx = jsx11;
28215
+ exports.jsxs = jsxs9;
28216
28216
  })();
28217
28217
  }
28218
28218
  }
@@ -33963,8 +33963,12 @@ function resolveEngineBin(env3 = process.env, from) {
33963
33963
  }
33964
33964
 
33965
33965
  // src/engine/catalog.ts
33966
+ var LATENT_ID = "latent";
33967
+ var VENICE_ID = "venice";
33966
33968
  function describeConnection(provider, integration) {
33969
+ if (provider.id === LATENT_ID) return { kind: "latent", via: "paid from your credits" };
33967
33970
  const conn = integration?.connections[0];
33971
+ if (provider.id === VENICE_ID && conn?.type === "credential") return { kind: "key", via: "your Venice key \xB7 DIEM first" };
33968
33972
  if (conn?.type === "env") return { kind: "env", via: `env ${conn.name}` };
33969
33973
  if (conn?.type === "credential") {
33970
33974
  if (conn.method === "oauth") return { kind: "account", via: "account sign-in" };
@@ -34011,10 +34015,13 @@ function buildCatalog(providers, integrations, models) {
34011
34015
  for (const [id, n] of count) {
34012
34016
  if (!out.some((p) => p.id === id)) out.push({ id, name: id, integrationID: id, kind: "unknown", via: "connected", models: n });
34013
34017
  }
34014
- const rank = { account: 0, key: 1, local: 2, env: 3, unknown: 4, builtin: 5 };
34015
- out.sort((a2, b) => rank[a2.kind] - rank[b.kind] || a2.models - b.models || a2.name.localeCompare(b.name));
34018
+ out.sort((a2, b) => providerRank(a2) - providerRank(b) || a2.models - b.models || a2.name.localeCompare(b.name));
34016
34019
  return { providers: out, models: list };
34017
34020
  }
34021
+ var KIND_RANK = { latent: 0, account: 2, key: 3, local: 4, env: 5, unknown: 6, builtin: 7 };
34022
+ function providerRank(p) {
34023
+ return p.id === VENICE_ID && p.kind !== "builtin" ? 1 : KIND_RANK[p.kind];
34024
+ }
34018
34025
  var STATUS_RANK = {
34019
34026
  ok: 0,
34020
34027
  unknown: 1,
@@ -34026,7 +34033,7 @@ var STATUS_RANK = {
34026
34033
  function searchModels(catalog, query, opts = {}) {
34027
34034
  const terms = query.toLowerCase().split(/\s+/).filter(Boolean);
34028
34035
  const providerName = new Map(catalog.providers.map((p) => [p.id, p.name]));
34029
- const providerRank = new Map(catalog.providers.map((p, i) => [p.id, i]));
34036
+ const providerRank2 = new Map(catalog.providers.map((p, i) => [p.id, i]));
34030
34037
  const status2 = opts.status ?? (() => "unknown");
34031
34038
  const hits = catalog.models.filter((m) => {
34032
34039
  if (opts.provider && m.providerID !== opts.provider) return false;
@@ -34044,7 +34051,7 @@ function searchModels(catalog, query, opts = {}) {
34044
34051
  return 2;
34045
34052
  };
34046
34053
  return hits.sort(
34047
- (a2, b) => Number(b.key === opts.current) - Number(a2.key === opts.current) || STATUS_RANK[status2(a2.key)] - STATUS_RANK[status2(b.key)] || score(a2) - score(b) || (providerRank.get(a2.providerID) ?? 99) - (providerRank.get(b.providerID) ?? 99) || b.released - a2.released || a2.name.localeCompare(b.name)
34054
+ (a2, b) => Number(b.key === opts.current) - Number(a2.key === opts.current) || STATUS_RANK[status2(a2.key)] - STATUS_RANK[status2(b.key)] || score(a2) - score(b) || (providerRank2.get(a2.providerID) ?? 99) - (providerRank2.get(b.providerID) ?? 99) || b.released - a2.released || a2.name.localeCompare(b.name)
34048
34055
  );
34049
34056
  }
34050
34057
  function fmtContext(n) {
@@ -34056,7 +34063,7 @@ function fmtPrice(m, kind) {
34056
34063
  if (m.costIn === null) return kind === "account" || kind === "local" ? "plan" : "";
34057
34064
  if (!m.costIn && !m.costOut) return "free";
34058
34065
  const n = (v) => v === null ? "?" : v >= 10 ? String(Math.round(v)) : String(+v.toFixed(2));
34059
- return `$${n(m.costIn)}/${n(m.costOut)}`;
34066
+ return kind === "latent" ? `${n(m.costIn)}/${n(m.costOut)} cr` : `$${n(m.costIn)}/${n(m.costOut)}`;
34060
34067
  }
34061
34068
  function fmtTokens(n) {
34062
34069
  if (n >= 1e6) return `${(n / 1e6).toFixed(1)}M`;
@@ -34485,12 +34492,13 @@ async function ensureDeviceCredential(server) {
34485
34492
 
34486
34493
  // src/engine/models.ts
34487
34494
  var UNSUPPORTED_RE = /not supported|not available|does not have access|model_not_found|unsupported model/i;
34495
+ var LIMIT_RE = /usage limit|rate.?limit|limit (?:reached|exceeded)|reached your (?:\w+ )?limit|hit your (?:\w+ )?limit|exceeded your (?:current )?quota|too many requests/i;
34488
34496
  function classifyError(err, now = Date.now()) {
34489
34497
  const e = err && typeof err === "object" ? err : { message: String(err) };
34490
34498
  const message = typeof e.message === "string" ? e.message : String(err ?? "");
34491
34499
  const reason = String(e.reason ?? e.type ?? "");
34492
34500
  const status2 = typeof e.status === "number" ? e.status : 0;
34493
- if (/rate.?limit/i.test(reason) || status2 === 429) {
34501
+ if (/rate.?limit/i.test(reason) || status2 === 429 || LIMIT_RE.test(message)) {
34494
34502
  const retry = typeof e.retryAfterMs === "number" ? e.retryAfterMs : 15 * 6e4;
34495
34503
  return { status: "rate-limited", message, until: now + retry, at: now };
34496
34504
  }
@@ -35283,7 +35291,7 @@ function parseModelList(raw) {
35283
35291
  }
35284
35292
  function providerEntry(input) {
35285
35293
  const models = {};
35286
- for (const id of input.models) models[id] = { name: id };
35294
+ for (const id of input.models) models[id] = modelEntry(id, input.details?.[id]);
35287
35295
  return {
35288
35296
  name: input.name.trim(),
35289
35297
  package: KIND_PACKAGE[input.kind],
@@ -35291,6 +35299,14 @@ function providerEntry(input) {
35291
35299
  models
35292
35300
  };
35293
35301
  }
35302
+ function modelEntry(id, d) {
35303
+ const out = { name: d?.name || id };
35304
+ if (d?.context) out.limit = { context: d.context, ...d.output ? { output: d.output } : {} };
35305
+ if (d?.cost) {
35306
+ out.cost = [{ input: d.cost.input, output: d.cost.output, ...d.cost.cacheRead != null ? { cache: { read: d.cost.cacheRead } } : {} }];
35307
+ }
35308
+ return out;
35309
+ }
35294
35310
  function parseJsonc(text) {
35295
35311
  let out = "";
35296
35312
  let hadComments = false;
@@ -35386,32 +35402,72 @@ function parseModelsResponse(body) {
35386
35402
 
35387
35403
  // src/engine/latentProvider.ts
35388
35404
  var LATENT_PROVIDER_ID = "latent";
35405
+ var LATENT_NAME = "Latent";
35406
+ var LATENT_VENICE_NAME = "Latent \xB7 via Venice";
35407
+ var num = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 ? v : void 0;
35408
+ function parseLatentModels(body) {
35409
+ const data = body?.data;
35410
+ if (!Array.isArray(data)) throw new Error("The /models answer has no model list.");
35411
+ const details = {};
35412
+ let venice = false;
35413
+ const ids = [];
35414
+ for (const m of data) {
35415
+ if (typeof m === "string") {
35416
+ ids.push(m);
35417
+ continue;
35418
+ }
35419
+ if (!m || typeof m !== "object" || typeof m.id !== "string") continue;
35420
+ const e = m;
35421
+ const id = e.id;
35422
+ ids.push(id);
35423
+ if (e.provider === "venice") venice = true;
35424
+ const pr = e.pricing ?? {};
35425
+ const d = {};
35426
+ if (typeof e.name === "string" && e.name) d.name = e.name;
35427
+ const ctx = num(e.context_length);
35428
+ if (ctx) d.context = ctx;
35429
+ const out = num(e.max_output_tokens);
35430
+ if (out) d.output = out;
35431
+ if (num(pr.input) !== void 0 && num(pr.output) !== void 0) {
35432
+ d.cost = { input: num(pr.input), output: num(pr.output), ...num(pr.cache_input) !== void 0 ? { cacheRead: num(pr.cache_input) } : {} };
35433
+ }
35434
+ if (Object.keys(d).length) details[id] = d;
35435
+ }
35436
+ return { models: parseModelList(ids.join(" ")), details, venice };
35437
+ }
35438
+ async function discoverLatentModels(baseURL, key, timeoutMs = 1e4) {
35439
+ const res = await fetch(baseURL + "/models", { headers: { authorization: `Bearer ${key}` }, signal: AbortSignal.timeout(timeoutMs) });
35440
+ if (!res.ok) throw new Error(`${baseURL}/models answered ${res.status}`);
35441
+ return parseLatentModels(await res.json());
35442
+ }
35389
35443
  var LATENT_KEY_RE = /^lk_[A-Za-z0-9_-]{20,}$/;
35390
35444
  function latentBaseURL(server) {
35391
35445
  return server.replace(/\/+$/, "") + "/v1";
35392
35446
  }
35393
- async function connectLatentKey(engine, server, key, discover = discoverModels, suggested) {
35447
+ async function connectLatentKey(engine, server, key, discover = discoverLatentModels, suggested) {
35394
35448
  const k = key.trim();
35395
35449
  if (!LATENT_KEY_RE.test(k)) throw new Error("That is not a Latent Key \u2014 it starts with lk_. Get one at latentprotocol.xyz/app/earn.");
35396
35450
  const baseURL = latentBaseURL(server);
35397
- let models;
35451
+ let found;
35398
35452
  try {
35399
- models = await discover("openai", baseURL, k);
35453
+ found = await discover(baseURL, k);
35400
35454
  } catch (e) {
35401
35455
  const why = e instanceof Error ? e.message : String(e);
35402
35456
  throw new Error(/ 401/.test(why) ? "The ad server does not know this key \u2014 it may have been rotated." : `Could not reach Latent (${why}).`);
35403
35457
  }
35458
+ const models = found.models;
35404
35459
  if (!models.length) throw new Error("Latent lists no models right now. Try again in a minute.");
35405
35460
  const file = configFileIn(await engine.configDir() ?? defaultConfigDir());
35406
35461
  const pick = suggested && models.includes(suggested) ? suggested : void 0;
35407
35462
  const defaultModel = pick ? `${LATENT_PROVIDER_ID}/${pick}` : void 0;
35408
- const written = writeProviderConfig(file, LATENT_PROVIDER_ID, { name: "Latent", kind: "openai", baseURL, models }, defaultModel);
35463
+ const name = found.venice ? LATENT_VENICE_NAME : LATENT_NAME;
35464
+ const written = writeProviderConfig(file, LATENT_PROVIDER_ID, { name, kind: "openai", baseURL, models, details: found.details }, defaultModel);
35409
35465
  await engine.reloadConfig();
35410
35466
  await engine.waitForIntegration(LATENT_PROVIDER_ID);
35411
35467
  await engine.connectKey(LATENT_PROVIDER_ID, k);
35412
35468
  return { id: LATENT_PROVIDER_ID, models, file: written.file, backup: written.backup, defaultModel };
35413
35469
  }
35414
- async function connectPendingLatentKey(engine, server, store, discover = discoverModels) {
35470
+ async function connectPendingLatentKey(engine, server, store, discover = discoverLatentModels) {
35415
35471
  const cfg = store.load();
35416
35472
  if (!cfg.latent_key) return null;
35417
35473
  const res = await connectLatentKey(engine, server, cfg.latent_key, discover, cfg.latent_default_model);
@@ -35639,7 +35695,7 @@ function initialState(sessionID, model = "") {
35639
35695
  };
35640
35696
  }
35641
35697
  var str = (v) => typeof v === "string" ? v : v == null ? "" : JSON.stringify(v);
35642
- var num = (v) => typeof v === "number" && Number.isFinite(v) ? v : 0;
35698
+ var num2 = (v) => typeof v === "number" && Number.isFinite(v) ? v : 0;
35643
35699
  function upsert(items, id, make, patch) {
35644
35700
  const i = items.findIndex((it) => it.id === id);
35645
35701
  if (i === -1) return [...items, make()];
@@ -35658,8 +35714,8 @@ function fileChange(metadata) {
35658
35714
  let deletions = 0;
35659
35715
  const patches = [];
35660
35716
  for (const f of files) {
35661
- additions += num(f.additions);
35662
- deletions += num(f.deletions);
35717
+ additions += num2(f.additions);
35718
+ deletions += num2(f.deletions);
35663
35719
  if (typeof f.patch === "string") patches.push(f.patch);
35664
35720
  }
35665
35721
  return { diff: patches.join("\n") || void 0, additions, deletions };
@@ -35726,7 +35782,7 @@ function reduce(state, ev, now = Date.now()) {
35726
35782
  case "session.reasoning.started":
35727
35783
  case "session.reasoning.delta":
35728
35784
  case "session.reasoning.ended": {
35729
- const id = `reasoning:${str(d.assistantMessageID)}:${num(d.ordinal)}`;
35785
+ const id = `reasoning:${str(d.assistantMessageID)}:${num2(d.ordinal)}`;
35730
35786
  const done = ev.type === "session.reasoning.ended";
35731
35787
  const items = upsert(
35732
35788
  state.items,
@@ -35739,7 +35795,7 @@ function reduce(state, ev, now = Date.now()) {
35739
35795
  case "session.text.started":
35740
35796
  case "session.text.delta":
35741
35797
  case "session.text.ended": {
35742
- const id = `text:${str(d.assistantMessageID)}:${num(d.ordinal)}`;
35798
+ const id = `text:${str(d.assistantMessageID)}:${num2(d.ordinal)}`;
35743
35799
  const done = ev.type === "session.text.ended";
35744
35800
  const items = upsert(
35745
35801
  state.items,
@@ -35791,8 +35847,8 @@ function reduce(state, ev, now = Date.now()) {
35791
35847
  const t = d.tokens ?? {};
35792
35848
  return {
35793
35849
  ...state,
35794
- cost: num(d.cost),
35795
- tokens: { input: num(t.input), output: num(t.output), reasoning: num(t.reasoning) }
35850
+ cost: num2(d.cost),
35851
+ tokens: { input: num2(t.input), output: num2(t.output), reasoning: num2(t.reasoning) }
35796
35852
  };
35797
35853
  }
35798
35854
  case "permission.asked": {
@@ -35843,6 +35899,7 @@ function reduce(state, ev, now = Date.now()) {
35843
35899
  var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
35844
35900
  var fmtTok = (n) => n >= 1e3 ? `${(n / 1e3).toFixed(1)}k` : String(n);
35845
35901
  var fmtUsd2 = (n) => `$${n.toFixed(n !== 0 && Math.abs(n) < 0.01 ? 4 : 2)}`;
35902
+ var fmtCredits = (n) => `${n.toFixed(n !== 0 && Math.abs(n) < 0.01 ? 4 : 3)} cr`;
35846
35903
  function Rule({ width }) {
35847
35904
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: C.border, children: "\u2500".repeat(Math.max(0, width)) });
35848
35905
  }
@@ -35885,7 +35942,8 @@ function StatusPanel(p) {
35885
35942
  const name = p.model || "no model";
35886
35943
  const prov = p.provider ? ` \xB7 ${p.provider}` : "";
35887
35944
  const variant = p.variant ? ` ${p.variant}` : "";
35888
- const usage2 = [p.tokens ? `${fmtTok(p.tokens)} tok` : "", p.cost ? fmtUsd2(p.cost) : ""].filter(Boolean).join(" \xB7 ");
35945
+ const spent = p.cost ? p.latent ? fmtCredits(p.cost) : fmtUsd2(p.cost) : "";
35946
+ const usage2 = [p.tokens ? `${fmtTok(p.tokens)} tok` : "", spent].filter(Boolean).join(" \xB7 ");
35889
35947
  const rightLen = usage2 ? usage2.length + 2 : 0;
35890
35948
  const leftBudget = p.width - 9 - rightLen;
35891
35949
  const leftText = clip(`${name}${variant}${prov}`, Math.max(8, leftBudget));
@@ -35994,6 +36052,40 @@ function StatusPanel(p) {
35994
36052
  ] });
35995
36053
  }
35996
36054
 
36055
+ // src/engine/overflow.ts
36056
+ var OVERFLOW_MIN_CREDITS = 0.5;
36057
+ var OVERFLOW_FALLBACKS = ["claude-sonnet-5-5", "claude-opus-5-5", "z-ai-glm-5-3", "qwen3-coder-480b-a35b-instruct-turbo"];
36058
+ var compact = (s2) => s2.toLowerCase().replace(/[^a-z0-9]/g, "");
36059
+ function bareId(key) {
36060
+ const i = key.indexOf("/");
36061
+ return i >= 0 ? key.slice(i + 1) : key;
36062
+ }
36063
+ function overflowTarget(failedKey, catalog) {
36064
+ const latent = catalog.models.filter((m) => m.providerID === LATENT_ID);
36065
+ if (!latent.length) return null;
36066
+ const failed = catalog.models.find((m) => m.key === failedKey);
36067
+ const wants = [compact(bareId(bareId(failedKey))), failed ? compact(failed.name) : ""].filter((w) => w.length >= 3);
36068
+ for (const w of wants) {
36069
+ const exact = latent.find((m) => compact(m.id) === w || compact(m.name) === w);
36070
+ if (exact) return exact;
36071
+ }
36072
+ for (const w of wants) {
36073
+ const near = latent.filter((m) => compact(m.id).includes(w) || compact(m.name).includes(w)).sort((a2, b) => a2.id.length - b.id.length);
36074
+ if (near[0]) return near[0];
36075
+ }
36076
+ for (const id of OVERFLOW_FALLBACKS) {
36077
+ const m = latent.find((x) => x.id === id);
36078
+ if (m) return m;
36079
+ }
36080
+ return latent[0];
36081
+ }
36082
+ function overflowOffer(model, verdict, catalog, balance, offered) {
36083
+ if (verdict.status !== "rate-limited" || !model || model.startsWith(`${LATENT_ID}/`)) return null;
36084
+ if (balance === null || balance < OVERFLOW_MIN_CREDITS || offered.has(model)) return null;
36085
+ const to = overflowTarget(model, catalog);
36086
+ return to ? { from: model, to, credits: balance } : null;
36087
+ }
36088
+
35997
36089
  // src/ui/components.tsx
35998
36090
  var import_react22 = __toESM(require_react(), 1);
35999
36091
 
@@ -36721,7 +36813,7 @@ function ModelPicker(p) {
36721
36813
  const below = models.filter((m) => rows.findIndex((r) => r.t === "model" && r.m === m) >= start + visible).length;
36722
36814
  const inner = p.width - 4;
36723
36815
  const wCtx = 5;
36724
- const wPrice = 11;
36816
+ const wPrice = 13;
36725
36817
  const wNote = 14;
36726
36818
  const rest = inner - 4 - wCtx - wPrice - wNote - 3;
36727
36819
  const wName = Math.max(16, Math.min(32, Math.floor(rest * 0.5)));
@@ -36829,7 +36921,7 @@ function ModelPicker(p) {
36829
36921
  i === effortAt ? `\u2039 ${e} \u203A` : e,
36830
36922
  i < efforts.length - 1 ? " " : ""
36831
36923
  ] }, e)) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.faint, children: "fixed for this model" }),
36832
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.faint, children: " ctx \xB7 $ in/out per 1M tokens" })
36924
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.faint, children: " ctx \xB7 in/out per 1M tokens ($, or cr = Latent credits)" })
36833
36925
  ] }) }) : null
36834
36926
  ]
36835
36927
  }
@@ -37879,10 +37971,52 @@ function Done2(p) {
37879
37971
  ] }) }) });
37880
37972
  }
37881
37973
 
37882
- // src/ui/App.tsx
37974
+ // src/ui/panels/OverflowPanel.tsx
37883
37975
  var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
37976
+ function OverflowPanel(p) {
37977
+ use_input_default((ch, key) => {
37978
+ if (key.return) p.onContinue();
37979
+ else if (ch === "s") p.onSwitch();
37980
+ else if (key.escape || ch === "n") p.onClose();
37981
+ });
37982
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
37983
+ Panel,
37984
+ {
37985
+ title: "Limit reached",
37986
+ right: `${p.credits.toFixed(2)} credits`,
37987
+ width: p.width,
37988
+ color: C.earn,
37989
+ footer: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Hints, { items: [["enter", "switch & continue"], ["s", "switch only"], ["esc", "stay"]] }),
37990
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Box_default, { flexDirection: "column", marginTop: 1, children: [
37991
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { wrap: "wrap", children: [
37992
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { bold: true, children: p.fromName }),
37993
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.muted, children: " hit its usage limit." })
37994
+ ] }),
37995
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { wrap: "wrap", children: [
37996
+ "Continue on ",
37997
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { bold: true, color: C.earn, children: p.toName }),
37998
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { color: C.muted, children: [
37999
+ " via Venice, paid from the ",
38000
+ p.credits.toFixed(2),
38001
+ " credits you earned"
38002
+ ] }),
38003
+ p.price ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { color: C.faint, children: [
38004
+ " (",
38005
+ p.price,
38006
+ " per 1M tokens)"
38007
+ ] }) : null,
38008
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.muted, children: "?" })
38009
+ ] }),
38010
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.faint, wrap: "wrap", children: "Your own plan stays connected; /model switches back any time." })
38011
+ ] })
38012
+ }
38013
+ );
38014
+ }
38015
+
38016
+ // src/ui/App.tsx
38017
+ var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
37884
38018
  var DASHBOARD = "latentprotocol.xyz/app";
37885
- var MODE = { keep: "keep and spend (bonus)", auto_sell: "sell automatically for USDG", auto_list: "list at my price" };
38019
+ var MODE = { keep: "keep and spend (bonus)", auto_sell: "sell automatically for USDC", auto_list: "list at my price" };
37886
38020
  var notice = (text, tone = "info") => ({
37887
38021
  type: "latentcode.notice",
37888
38022
  created: Date.now(),
@@ -37914,42 +38048,42 @@ function activityLabel(s2) {
37914
38048
  function StepMark({ status: status2 }) {
37915
38049
  switch (status2) {
37916
38050
  case "run":
37917
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Spinner, {});
38051
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Spinner, {});
37918
38052
  case "ok":
37919
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.ok, children: G.ok });
38053
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { color: C.ok, children: G.ok });
37920
38054
  case "warn":
37921
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.warn, children: G.ring });
38055
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { color: C.warn, children: G.ring });
37922
38056
  case "fail":
37923
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.err, children: G.no });
38057
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { color: C.err, children: G.no });
37924
38058
  default:
37925
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.faint, children: "\xB7" });
38059
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { color: C.faint, children: "\xB7" });
37926
38060
  }
37927
38061
  }
37928
38062
  function BootCard(p) {
37929
38063
  const wLabel = 10;
37930
38064
  const inner = p.width - 4;
37931
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Box_default, { flexDirection: "column", children: [
37932
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Box_default, { marginTop: 1, marginLeft: 1, flexDirection: "column", children: [
37933
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Logo, { version: p.version }),
37934
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.muted, children: TAGLINE })
38065
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Box_default, { flexDirection: "column", children: [
38066
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Box_default, { marginTop: 1, marginLeft: 1, flexDirection: "column", children: [
38067
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Logo, { version: p.version }),
38068
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { color: C.muted, children: TAGLINE })
37935
38069
  ] }),
37936
- /* @__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: [
37937
- p.steps.map((st) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { wrap: "truncate-end", children: [
37938
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StepMark, { status: st.status }),
37939
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { bold: st.status === "run", color: st.status === "pending" ? C.faint : void 0, children: [
38070
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Box_default, { marginTop: 1, flexDirection: "column", borderStyle: "round", borderColor: p.error ? C.err : C.border, paddingX: 1, width: p.width, children: [
38071
+ p.steps.map((st) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Text, { wrap: "truncate-end", children: [
38072
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(StepMark, { status: st.status }),
38073
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Text, { bold: st.status === "run", color: st.status === "pending" ? C.faint : void 0, children: [
37940
38074
  " ",
37941
38075
  pad(st.label, wLabel)
37942
38076
  ] }),
37943
- /* @__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) })
38077
+ /* @__PURE__ */ (0, import_jsx_runtime8.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) })
37944
38078
  ] }, st.id)),
37945
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { wrap: "truncate-end", children: [
37946
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.faint, children: "\xB7 " }),
37947
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.faint, children: pad("Project", wLabel) }),
37948
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.muted, children: shortPath(p.cwd, homedir4(), inner - wLabel - 4) })
38079
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Text, { wrap: "truncate-end", children: [
38080
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { color: C.faint, children: "\xB7 " }),
38081
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { color: C.faint, children: pad("Project", wLabel) }),
38082
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { color: C.muted, children: shortPath(p.cwd, homedir4(), inner - wLabel - 4) })
37949
38083
  ] })
37950
38084
  ] }),
37951
- 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,
37952
- p.ready ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Box_default, { marginLeft: 1, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
38085
+ p.error ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box_default, { marginLeft: 1, marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { color: C.err, wrap: "wrap", children: p.error }) }) : null,
38086
+ p.ready ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box_default, { marginLeft: 1, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
37953
38087
  Hints,
37954
38088
  {
37955
38089
  items: [
@@ -37978,26 +38112,26 @@ function HelpPanel({ width, commands, onClose }) {
37978
38112
  ["ctrl+o", "open the sponsored link"],
37979
38113
  ["ctrl+c", "clear the line, twice to quit"]
37980
38114
  ];
37981
- 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: [
38115
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Panel, { title: "Help", width, color: C.accent, footer: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Hints, { items: [["esc", "close"]] }), children: [
37982
38116
  groups.map((g) => {
37983
38117
  const list = commands.filter((c) => c.group === g);
37984
38118
  if (!list.length) return null;
37985
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Box_default, { flexDirection: "column", marginTop: 1, children: [
37986
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { bold: true, color: C.muted, children: g }),
37987
- list.map((c) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { wrap: "truncate-end", children: [
37988
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.accent2, children: pad(`/${c.name}${c.args ? " " + c.args : ""}`, 22) }),
37989
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.muted, children: c.desc })
38119
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Box_default, { flexDirection: "column", marginTop: 1, children: [
38120
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { bold: true, color: C.muted, children: g }),
38121
+ list.map((c) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Text, { wrap: "truncate-end", children: [
38122
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { color: C.accent2, children: pad(`/${c.name}${c.args ? " " + c.args : ""}`, 22) }),
38123
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { color: C.muted, children: c.desc })
37990
38124
  ] }, c.name))
37991
38125
  ] }, g);
37992
38126
  }),
37993
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Box_default, { flexDirection: "column", marginTop: 1, children: [
37994
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { bold: true, color: C.muted, children: "Keys" }),
37995
- keys.map(([k, d]) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { children: [
37996
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.accent2, children: pad(k, 22) }),
37997
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.muted, children: d })
38127
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Box_default, { flexDirection: "column", marginTop: 1, children: [
38128
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { bold: true, color: C.muted, children: "Keys" }),
38129
+ keys.map(([k, d]) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Text, { children: [
38130
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { color: C.accent2, children: pad(k, 22) }),
38131
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { color: C.muted, children: d })
37998
38132
  ] }, k))
37999
38133
  ] }),
38000
- /* @__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.` }) })
38134
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box_default, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime8.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.` }) })
38001
38135
  ] });
38002
38136
  }
38003
38137
  var LINKS_OSC8 = linkShape() === "osc8";
@@ -38091,6 +38225,11 @@ function App2(props) {
38091
38225
  return () => clearInterval(t);
38092
38226
  }, [state.working, lingering, controller]);
38093
38227
  const [balance, setBalance] = (0, import_react26.useState)(null);
38228
+ const catalogRef = (0, import_react26.useRef)(catalog);
38229
+ catalogRef.current = catalog;
38230
+ const balanceRef = (0, import_react26.useRef)(balance);
38231
+ balanceRef.current = balance;
38232
+ const offered = (0, import_react26.useRef)(/* @__PURE__ */ new Set());
38094
38233
  (0, import_react26.useEffect)(() => {
38095
38234
  if (!wallet || state.working) return;
38096
38235
  let live2 = true;
@@ -38109,12 +38248,18 @@ function App2(props) {
38109
38248
  const model = currentModel.current;
38110
38249
  if (!model) return;
38111
38250
  const v = classifyError(ev.data?.error);
38112
- const name = modelName(model);
38251
+ const name = catalogRef.current.models.find((m) => m.key === model)?.name ?? model;
38113
38252
  if (v.status === "unsupported") {
38114
38253
  store.set(model, v);
38115
38254
  say(`${name} isn't available with your connected account. /model shows which ones are (${G.ok}).`, "warn");
38116
38255
  } else if (v.status === "rate-limited") {
38117
38256
  store.set(model, v);
38257
+ const offer = overflowOffer(model, v, catalogRef.current, balanceRef.current, offered.current);
38258
+ if (offer) {
38259
+ offered.current.add(model);
38260
+ setOverlay({ t: "overflow", offer });
38261
+ return;
38262
+ }
38118
38263
  const mins = v.until ? Math.max(1, Math.round((v.until - Date.now()) / 6e4)) : 0;
38119
38264
  say(`${name} is rate-limited${mins ? ` for about ${mins} min` : ""}. /model to switch.`, "warn");
38120
38265
  } else if (v.status === "auth") {
@@ -38233,7 +38378,7 @@ Spend it here: /login connects the Latent provider (or /key lk_\u2026 with a key
38233
38378
  `Latent Credit ${c.credits.toFixed(2)} credits \xB7 $1 of model usage at list price each`,
38234
38379
  `Bonus ${c.bonus}\xD7 \u2014 every $1 earned from ads becomes ${c.bonus} credits`,
38235
38380
  `Mode ${MODE[c.mode]}`,
38236
- q?.buybackEnabled ? `Sell now ${q.buybackPrice.toFixed(2)} USDG per credit, paid on Robinhood Chain` : `Sell now opens soon`,
38381
+ q?.buybackEnabled ? `Sell now ${q.buybackPrice.toFixed(2)} USDC per credit, paid on Base` : `Sell now opens soon`,
38237
38382
  `Change it ${DASHBOARD}/settings \xB7 sell or list at ${DASHBOARD}/earn \xB7 buy at ${DASHBOARD}/credits`
38238
38383
  ].join("\n")
38239
38384
  );
@@ -38371,18 +38516,18 @@ Spend it here: /login connects the Latent provider (or /key lk_\u2026 with a key
38371
38516
  const current = catalog.models.find((m) => m.key === state.model);
38372
38517
  const provider = catalog.providers.find((p) => p.id === (current?.providerID ?? parseKey(state.model)?.providerID));
38373
38518
  const close = () => setOverlay(null);
38374
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
38375
- /* @__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) }),
38376
- live.map((it) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ItemView, { item: it, live: true, cwd: cwd2, width, maxLines }, it.id)),
38377
- perm ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(PermissionPrompt, { perm, selected: permAt, cwd: cwd2, width }) : null,
38378
- state.working ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Box_default, { marginTop: 1, flexDirection: "column", width, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { wrap: "truncate-end", children: [
38379
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Spinner, {}),
38380
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { children: [
38519
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
38520
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Static, { items: [header, ...done.map((it) => ({ id: it.id, it }))], children: (entry) => "it" in entry ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ItemView, { item: entry.it, live: false, cwd: cwd2, width, maxLines }, entry.id) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(BootCard, { steps: props.bootSteps, version, cwd: cwd2, width, ready: true }, entry.id) }),
38521
+ live.map((it) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ItemView, { item: it, live: true, cwd: cwd2, width, maxLines }, it.id)),
38522
+ perm ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(PermissionPrompt, { perm, selected: permAt, cwd: cwd2, width }) : null,
38523
+ state.working ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box_default, { marginTop: 1, flexDirection: "column", width, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Text, { wrap: "truncate-end", children: [
38524
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Spinner, {}),
38525
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Text, { children: [
38381
38526
  " ",
38382
38527
  activityLabel(state),
38383
38528
  "\u2026"
38384
38529
  ] }),
38385
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { color: C.faint, children: [
38530
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Text, { color: C.faint, children: [
38386
38531
  " ",
38387
38532
  elapsed,
38388
38533
  "s \xB7 ",
@@ -38394,7 +38539,7 @@ Spend it here: /login connects the Latent provider (or /key lk_\u2026 with a key
38394
38539
  " \xB7 esc to interrupt"
38395
38540
  ] })
38396
38541
  ] }) }) : null,
38397
- overlay?.t === "model" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
38542
+ overlay?.t === "model" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
38398
38543
  ModelPicker,
38399
38544
  {
38400
38545
  catalog,
@@ -38413,7 +38558,7 @@ Spend it here: /login connects the Latent provider (or /key lk_\u2026 with a key
38413
38558
  onClose: close
38414
38559
  }
38415
38560
  ) : null,
38416
- overlay?.t === "providers" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
38561
+ overlay?.t === "providers" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
38417
38562
  ProviderPanel,
38418
38563
  {
38419
38564
  engine,
@@ -38432,10 +38577,34 @@ Spend it here: /login connects the Latent provider (or /key lk_\u2026 with a key
38432
38577
  onClose: close
38433
38578
  }
38434
38579
  ) : null,
38435
- overlay?.t === "wallet" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(WalletPanel, { server: props.server, wallet, width, onWallet: changeWallet, onClose: close }) : null,
38436
- overlay?.t === "help" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(HelpPanel, { width, commands: allCommands, onClose: close }) : null,
38437
- overlay === null && !perm && !leaving ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
38438
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
38580
+ overlay?.t === "wallet" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(WalletPanel, { server: props.server, wallet, width, onWallet: changeWallet, onClose: close }) : null,
38581
+ overlay?.t === "help" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(HelpPanel, { width, commands: allCommands, onClose: close }) : null,
38582
+ overlay?.t === "overflow" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
38583
+ OverflowPanel,
38584
+ {
38585
+ width,
38586
+ fromName: modelName(overlay.offer.from),
38587
+ toName: overlay.offer.to.name,
38588
+ price: overlay.offer.to.costIn !== null ? fmtPrice(overlay.offer.to, "latent") : void 0,
38589
+ credits: overlay.offer.credits,
38590
+ onContinue: () => {
38591
+ const to = overlay.offer.to;
38592
+ close();
38593
+ void pickModel(to, "").then(() => {
38594
+ lastPrompt.current = "Continue where you left off.";
38595
+ return engine.prompt(sessionID, lastPrompt.current);
38596
+ }).catch(fail);
38597
+ },
38598
+ onSwitch: () => {
38599
+ const to = overlay.offer.to;
38600
+ close();
38601
+ void pickModel(to, "").catch(fail);
38602
+ },
38603
+ onClose: close
38604
+ }
38605
+ ) : null,
38606
+ overlay === null && !perm && !leaving ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
38607
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
38439
38608
  Box_default,
38440
38609
  {
38441
38610
  marginTop: 1,
@@ -38444,41 +38613,41 @@ Spend it here: /login connects the Latent provider (or /key lk_\u2026 with a key
38444
38613
  paddingX: 1,
38445
38614
  width,
38446
38615
  children: [
38447
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Box_default, { flexShrink: 0, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { color: C.accent, bold: true, children: [
38616
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box_default, { flexShrink: 0, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Text, { color: C.accent, bold: true, children: [
38448
38617
  G.prompt,
38449
38618
  " "
38450
38619
  ] }) }),
38451
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FieldText, { state: editor, placeholder: state.turns ? "reply, or / for commands" : "ask anything, or / for commands" })
38620
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FieldText, { state: editor, placeholder: state.turns ? "reply, or / for commands" : "ask anything, or / for commands" })
38452
38621
  ]
38453
38622
  }
38454
38623
  ),
38455
- paletteOpen ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Box_default, { flexDirection: "column", paddingX: 2, width, children: [
38456
- matches.slice(0, 8).map((c, i) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { wrap: "truncate-end", children: [
38457
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { color: C.accent, children: [
38624
+ paletteOpen ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Box_default, { flexDirection: "column", paddingX: 2, width, children: [
38625
+ matches.slice(0, 8).map((c, i) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Text, { wrap: "truncate-end", children: [
38626
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Text, { color: C.accent, children: [
38458
38627
  i === paletteSel ? G.prompt : " ",
38459
38628
  " "
38460
38629
  ] }),
38461
- /* @__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) }),
38462
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.muted, children: c.desc })
38630
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { bold: i === paletteSel, color: i === paletteSel ? C.accent2 : C.text, children: pad(`/${c.name}${c.args ? " " + c.args : ""}`, 20) }),
38631
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { color: C.muted, children: c.desc })
38463
38632
  ] }, c.name)),
38464
- matches.length > 8 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { color: C.faint, children: [
38633
+ matches.length > 8 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Text, { color: C.faint, children: [
38465
38634
  " ",
38466
38635
  G.down,
38467
38636
  " ",
38468
38637
  matches.length - 8,
38469
38638
  " more \u2014 keep typing"
38470
38639
  ] }) : null,
38471
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Hints, { items: [["\u2191\u2193", "move"], ["tab", "complete"], ["enter", "run"], ["esc", "dismiss"]] })
38640
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Hints, { items: [["\u2191\u2193", "move"], ["tab", "complete"], ["enter", "run"], ["esc", "dismiss"]] })
38472
38641
  ] }) : null
38473
38642
  ] }) : null,
38474
- paletteOpen || leaving ? null : quitArmed ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Box_default, { paddingX: 1, width, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { color: C.warn, children: "Press ctrl+c again to quit" }) }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
38643
+ paletteOpen || leaving ? null : quitArmed ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box_default, { paddingX: 1, width, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { color: C.warn, children: "Press ctrl+c again to quit" }) }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
38475
38644
  StatusPanel,
38476
38645
  {
38477
38646
  width,
38478
38647
  model: current?.name ?? state.model,
38479
38648
  variant: state.variant,
38480
38649
  provider: provider?.name,
38481
- latent: (current?.providerID ?? parseKey(state.model)?.providerID) === "latent",
38650
+ latent: (current?.providerID ?? parseKey(state.model)?.providerID) === LATENT_PROVIDER_ID,
38482
38651
  working: state.working,
38483
38652
  tokens: state.tokens.input + state.tokens.output,
38484
38653
  cost: state.cost,
@@ -38499,7 +38668,7 @@ Spend it here: /login connects the Latent provider (or /key lk_\u2026 with a key
38499
38668
  }
38500
38669
 
38501
38670
  // src/ui/Root.tsx
38502
- var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
38671
+ var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
38503
38672
  function Root(p) {
38504
38673
  const { exit } = use_app_default();
38505
38674
  const { cols } = useTermSize();
@@ -38521,7 +38690,7 @@ function Root(p) {
38521
38690
  { isActive: !booted }
38522
38691
  );
38523
38692
  if (!booted) {
38524
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
38693
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
38525
38694
  BootCard,
38526
38695
  {
38527
38696
  steps,
@@ -38533,7 +38702,7 @@ function Root(p) {
38533
38702
  }
38534
38703
  );
38535
38704
  }
38536
- 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 }) });
38705
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PasteContext.Provider, { value: p.paste, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(App2, { ...booted, version: p.version, bootSteps: steps, summary: p.summary }) });
38537
38706
  }
38538
38707
 
38539
38708
  // src/ads/attention.ts
@@ -38749,8 +38918,8 @@ function row(mark, label2, value, width = 10) {
38749
38918
  }
38750
38919
 
38751
38920
  // src/index.tsx
38752
- var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
38753
- var VERSION = "0.1.0-alpha.8";
38921
+ var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
38922
+ var VERSION = "0.1.0-alpha.9";
38754
38923
  var usage = () => `${logo()}
38755
38924
  ${a.dim(`v${VERSION} \xB7 terminal coding agent. Bring your own model access; earn while it works.`)}
38756
38925
 
@@ -38891,7 +39060,7 @@ async function main() {
38891
39060
  const summary = { current: { turns: 0, tokens: 0, cost: 0, earned: 0, impressions: 0 } };
38892
39061
  let fatal = false;
38893
39062
  const app = render_default(
38894
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
39063
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
38895
39064
  Root,
38896
39065
  {
38897
39066
  args: { cwd: cwd2, model: args.model, noAds: args.noAds, auto: args.auto },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "latentcode",
3
- "version": "0.1.0-alpha.8",
3
+ "version": "0.1.0-alpha.9",
4
4
  "description": "Terminal coding agent that pays you for idle time. Bring your own subscription; the model is never for sale.",
5
5
  "type": "module",
6
6
  "bin": {