latentcode 0.1.0-alpha.7 → 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 +4 -2
- package/dist/latentcode.mjs +302 -113
- package/package.json +1 -1
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
|
|
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. |
|
package/dist/latentcode.mjs
CHANGED
|
@@ -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
|
|
23436
|
-
if (!Number.isInteger(
|
|
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 =
|
|
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
|
|
23449
|
-
if (!Number.isInteger(
|
|
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 =
|
|
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
|
|
24169
|
-
if (
|
|
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 =
|
|
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
|
|
28212
|
-
var
|
|
28211
|
+
var jsx11 = jsxWithValidationDynamic;
|
|
28212
|
+
var jsxs9 = jsxWithValidationStatic;
|
|
28213
28213
|
exports.Fragment = REACT_FRAGMENT_TYPE;
|
|
28214
|
-
exports.jsx =
|
|
28215
|
-
exports.jsxs =
|
|
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
|
-
|
|
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
|
|
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) || (
|
|
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
|
}
|
|
@@ -34874,6 +34882,7 @@ var AdController = class {
|
|
|
34874
34882
|
shownAt = 0;
|
|
34875
34883
|
visibleMs = 0;
|
|
34876
34884
|
billed = false;
|
|
34885
|
+
verdict = null;
|
|
34877
34886
|
lastTick = 0;
|
|
34878
34887
|
fetching = false;
|
|
34879
34888
|
/** Generation of the request in flight; a stale one never blocks a new turn. */
|
|
@@ -34931,6 +34940,7 @@ var AdController = class {
|
|
|
34931
34940
|
idle: !this.working,
|
|
34932
34941
|
visibleMs: this.visibleMs,
|
|
34933
34942
|
billed: this.billed,
|
|
34943
|
+
verdict: this.verdict,
|
|
34934
34944
|
focusTracked: this.o.focus.known,
|
|
34935
34945
|
impressions: this.impressions,
|
|
34936
34946
|
sessionEarned: this.sessionEarned,
|
|
@@ -34996,12 +35006,13 @@ var AdController = class {
|
|
|
34996
35006
|
displayedMs: this.visibleMs,
|
|
34997
35007
|
focusTracked: this.o.focus.known,
|
|
34998
35008
|
eventUuid: shown.eventUuid
|
|
34999
|
-
}).then((result) => {
|
|
35000
|
-
if (
|
|
35001
|
-
|
|
35002
|
-
|
|
35009
|
+
}).catch(() => "error").then((result) => {
|
|
35010
|
+
if (this.current === shown) this.verdict = result;
|
|
35011
|
+
if (result === "tracked") {
|
|
35012
|
+
this.impressions += 1;
|
|
35013
|
+
this.sessionEarned += shown.earn;
|
|
35014
|
+
}
|
|
35003
35015
|
this.emit();
|
|
35004
|
-
}).catch(() => {
|
|
35005
35016
|
});
|
|
35006
35017
|
this.emit();
|
|
35007
35018
|
}
|
|
@@ -35018,6 +35029,7 @@ var AdController = class {
|
|
|
35018
35029
|
this.current = null;
|
|
35019
35030
|
this.visibleMs = 0;
|
|
35020
35031
|
this.billed = false;
|
|
35032
|
+
this.verdict = null;
|
|
35021
35033
|
}
|
|
35022
35034
|
async fetchNext() {
|
|
35023
35035
|
const gen = this.generation;
|
|
@@ -35038,6 +35050,7 @@ var AdController = class {
|
|
|
35038
35050
|
this.lastTick = this.shownAt;
|
|
35039
35051
|
this.visibleMs = 0;
|
|
35040
35052
|
this.billed = false;
|
|
35053
|
+
this.verdict = null;
|
|
35041
35054
|
this.emit();
|
|
35042
35055
|
} finally {
|
|
35043
35056
|
if (this.fetchingGen === gen) this.fetching = false;
|
|
@@ -35278,7 +35291,7 @@ function parseModelList(raw) {
|
|
|
35278
35291
|
}
|
|
35279
35292
|
function providerEntry(input) {
|
|
35280
35293
|
const models = {};
|
|
35281
|
-
for (const id of input.models) models[id] =
|
|
35294
|
+
for (const id of input.models) models[id] = modelEntry(id, input.details?.[id]);
|
|
35282
35295
|
return {
|
|
35283
35296
|
name: input.name.trim(),
|
|
35284
35297
|
package: KIND_PACKAGE[input.kind],
|
|
@@ -35286,6 +35299,14 @@ function providerEntry(input) {
|
|
|
35286
35299
|
models
|
|
35287
35300
|
};
|
|
35288
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
|
+
}
|
|
35289
35310
|
function parseJsonc(text) {
|
|
35290
35311
|
let out = "";
|
|
35291
35312
|
let hadComments = false;
|
|
@@ -35381,32 +35402,72 @@ function parseModelsResponse(body) {
|
|
|
35381
35402
|
|
|
35382
35403
|
// src/engine/latentProvider.ts
|
|
35383
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
|
+
}
|
|
35384
35443
|
var LATENT_KEY_RE = /^lk_[A-Za-z0-9_-]{20,}$/;
|
|
35385
35444
|
function latentBaseURL(server) {
|
|
35386
35445
|
return server.replace(/\/+$/, "") + "/v1";
|
|
35387
35446
|
}
|
|
35388
|
-
async function connectLatentKey(engine, server, key, discover =
|
|
35447
|
+
async function connectLatentKey(engine, server, key, discover = discoverLatentModels, suggested) {
|
|
35389
35448
|
const k = key.trim();
|
|
35390
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.");
|
|
35391
35450
|
const baseURL = latentBaseURL(server);
|
|
35392
|
-
let
|
|
35451
|
+
let found;
|
|
35393
35452
|
try {
|
|
35394
|
-
|
|
35453
|
+
found = await discover(baseURL, k);
|
|
35395
35454
|
} catch (e) {
|
|
35396
35455
|
const why = e instanceof Error ? e.message : String(e);
|
|
35397
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}).`);
|
|
35398
35457
|
}
|
|
35458
|
+
const models = found.models;
|
|
35399
35459
|
if (!models.length) throw new Error("Latent lists no models right now. Try again in a minute.");
|
|
35400
35460
|
const file = configFileIn(await engine.configDir() ?? defaultConfigDir());
|
|
35401
35461
|
const pick = suggested && models.includes(suggested) ? suggested : void 0;
|
|
35402
35462
|
const defaultModel = pick ? `${LATENT_PROVIDER_ID}/${pick}` : void 0;
|
|
35403
|
-
const
|
|
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);
|
|
35404
35465
|
await engine.reloadConfig();
|
|
35405
35466
|
await engine.waitForIntegration(LATENT_PROVIDER_ID);
|
|
35406
35467
|
await engine.connectKey(LATENT_PROVIDER_ID, k);
|
|
35407
35468
|
return { id: LATENT_PROVIDER_ID, models, file: written.file, backup: written.backup, defaultModel };
|
|
35408
35469
|
}
|
|
35409
|
-
async function connectPendingLatentKey(engine, server, store, discover =
|
|
35470
|
+
async function connectPendingLatentKey(engine, server, store, discover = discoverLatentModels) {
|
|
35410
35471
|
const cfg = store.load();
|
|
35411
35472
|
if (!cfg.latent_key) return null;
|
|
35412
35473
|
const res = await connectLatentKey(engine, server, cfg.latent_key, discover, cfg.latent_default_model);
|
|
@@ -35634,7 +35695,7 @@ function initialState(sessionID, model = "") {
|
|
|
35634
35695
|
};
|
|
35635
35696
|
}
|
|
35636
35697
|
var str = (v) => typeof v === "string" ? v : v == null ? "" : JSON.stringify(v);
|
|
35637
|
-
var
|
|
35698
|
+
var num2 = (v) => typeof v === "number" && Number.isFinite(v) ? v : 0;
|
|
35638
35699
|
function upsert(items, id, make, patch) {
|
|
35639
35700
|
const i = items.findIndex((it) => it.id === id);
|
|
35640
35701
|
if (i === -1) return [...items, make()];
|
|
@@ -35653,8 +35714,8 @@ function fileChange(metadata) {
|
|
|
35653
35714
|
let deletions = 0;
|
|
35654
35715
|
const patches = [];
|
|
35655
35716
|
for (const f of files) {
|
|
35656
|
-
additions +=
|
|
35657
|
-
deletions +=
|
|
35717
|
+
additions += num2(f.additions);
|
|
35718
|
+
deletions += num2(f.deletions);
|
|
35658
35719
|
if (typeof f.patch === "string") patches.push(f.patch);
|
|
35659
35720
|
}
|
|
35660
35721
|
return { diff: patches.join("\n") || void 0, additions, deletions };
|
|
@@ -35721,7 +35782,7 @@ function reduce(state, ev, now = Date.now()) {
|
|
|
35721
35782
|
case "session.reasoning.started":
|
|
35722
35783
|
case "session.reasoning.delta":
|
|
35723
35784
|
case "session.reasoning.ended": {
|
|
35724
|
-
const id = `reasoning:${str(d.assistantMessageID)}:${
|
|
35785
|
+
const id = `reasoning:${str(d.assistantMessageID)}:${num2(d.ordinal)}`;
|
|
35725
35786
|
const done = ev.type === "session.reasoning.ended";
|
|
35726
35787
|
const items = upsert(
|
|
35727
35788
|
state.items,
|
|
@@ -35734,7 +35795,7 @@ function reduce(state, ev, now = Date.now()) {
|
|
|
35734
35795
|
case "session.text.started":
|
|
35735
35796
|
case "session.text.delta":
|
|
35736
35797
|
case "session.text.ended": {
|
|
35737
|
-
const id = `text:${str(d.assistantMessageID)}:${
|
|
35798
|
+
const id = `text:${str(d.assistantMessageID)}:${num2(d.ordinal)}`;
|
|
35738
35799
|
const done = ev.type === "session.text.ended";
|
|
35739
35800
|
const items = upsert(
|
|
35740
35801
|
state.items,
|
|
@@ -35786,8 +35847,8 @@ function reduce(state, ev, now = Date.now()) {
|
|
|
35786
35847
|
const t = d.tokens ?? {};
|
|
35787
35848
|
return {
|
|
35788
35849
|
...state,
|
|
35789
|
-
cost:
|
|
35790
|
-
tokens: { input:
|
|
35850
|
+
cost: num2(d.cost),
|
|
35851
|
+
tokens: { input: num2(t.input), output: num2(t.output), reasoning: num2(t.reasoning) }
|
|
35791
35852
|
};
|
|
35792
35853
|
}
|
|
35793
35854
|
case "permission.asked": {
|
|
@@ -35838,14 +35899,29 @@ function reduce(state, ev, now = Date.now()) {
|
|
|
35838
35899
|
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
|
|
35839
35900
|
var fmtTok = (n) => n >= 1e3 ? `${(n / 1e3).toFixed(1)}k` : String(n);
|
|
35840
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`;
|
|
35841
35903
|
function Rule({ width }) {
|
|
35842
35904
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: C.border, children: "\u2500".repeat(Math.max(0, width)) });
|
|
35843
35905
|
}
|
|
35844
|
-
function
|
|
35845
|
-
|
|
35846
|
-
|
|
35847
|
-
|
|
35848
|
-
|
|
35906
|
+
function verdictLabel(v) {
|
|
35907
|
+
switch (v) {
|
|
35908
|
+
case "tracked":
|
|
35909
|
+
return { text: `${G.ok} view counted`, tone: "ok" };
|
|
35910
|
+
case "unearned":
|
|
35911
|
+
return { text: "view not paid on this device", tone: "warn" };
|
|
35912
|
+
case "skipped":
|
|
35913
|
+
return { text: "view not counted", tone: "faint" };
|
|
35914
|
+
case "error":
|
|
35915
|
+
return { text: "view not counted \xB7 server unreachable", tone: "warn" };
|
|
35916
|
+
default:
|
|
35917
|
+
return { text: "counting view\u2026", tone: "faint" };
|
|
35918
|
+
}
|
|
35919
|
+
}
|
|
35920
|
+
function Progress({ ms, of, billed, verdict }) {
|
|
35921
|
+
if (billed) {
|
|
35922
|
+
const l = verdictLabel(verdict);
|
|
35923
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: l.tone === "ok" ? C.ok : l.tone === "warn" ? C.warn : C.faint, children: l.text });
|
|
35924
|
+
}
|
|
35849
35925
|
const n = 10;
|
|
35850
35926
|
const filled = Math.min(n, Math.floor(ms / of * n));
|
|
35851
35927
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [
|
|
@@ -35866,7 +35942,8 @@ function StatusPanel(p) {
|
|
|
35866
35942
|
const name = p.model || "no model";
|
|
35867
35943
|
const prov = p.provider ? ` \xB7 ${p.provider}` : "";
|
|
35868
35944
|
const variant = p.variant ? ` ${p.variant}` : "";
|
|
35869
|
-
const
|
|
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 ");
|
|
35870
35947
|
const rightLen = usage2 ? usage2.length + 2 : 0;
|
|
35871
35948
|
const leftBudget = p.width - 9 - rightLen;
|
|
35872
35949
|
const leftText = clip(`${name}${variant}${prov}`, Math.max(8, leftBudget));
|
|
@@ -35954,7 +36031,7 @@ function StatusPanel(p) {
|
|
|
35954
36031
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Rule, { width: inner }),
|
|
35955
36032
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box_default, { justifyContent: "space-between", children: [
|
|
35956
36033
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { wrap: "truncate-end", children: [
|
|
35957
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Progress, { ms: p.visibleMs ?? 0, of: p.minVisibleMs ?? 1e4, billed: !!p.billed }),
|
|
36034
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Progress, { ms: p.visibleMs ?? 0, of: p.minVisibleMs ?? 1e4, billed: !!p.billed, verdict: p.verdict }),
|
|
35958
36035
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: C.faint, children: " \xB7 Powered by Latent Ads" })
|
|
35959
36036
|
] }),
|
|
35960
36037
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box_default, { flexShrink: 0, marginLeft: 2, children: earnings })
|
|
@@ -35975,6 +36052,40 @@ function StatusPanel(p) {
|
|
|
35975
36052
|
] });
|
|
35976
36053
|
}
|
|
35977
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
|
+
|
|
35978
36089
|
// src/ui/components.tsx
|
|
35979
36090
|
var import_react22 = __toESM(require_react(), 1);
|
|
35980
36091
|
|
|
@@ -36702,7 +36813,7 @@ function ModelPicker(p) {
|
|
|
36702
36813
|
const below = models.filter((m) => rows.findIndex((r) => r.t === "model" && r.m === m) >= start + visible).length;
|
|
36703
36814
|
const inner = p.width - 4;
|
|
36704
36815
|
const wCtx = 5;
|
|
36705
|
-
const wPrice =
|
|
36816
|
+
const wPrice = 13;
|
|
36706
36817
|
const wNote = 14;
|
|
36707
36818
|
const rest = inner - 4 - wCtx - wPrice - wNote - 3;
|
|
36708
36819
|
const wName = Math.max(16, Math.min(32, Math.floor(rest * 0.5)));
|
|
@@ -36810,7 +36921,7 @@ function ModelPicker(p) {
|
|
|
36810
36921
|
i === effortAt ? `\u2039 ${e} \u203A` : e,
|
|
36811
36922
|
i < efforts.length - 1 ? " " : ""
|
|
36812
36923
|
] }, e)) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.faint, children: "fixed for this model" }),
|
|
36813
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.faint, children: " ctx \xB7
|
|
36924
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { color: C.faint, children: " ctx \xB7 in/out per 1M tokens ($, or cr = Latent credits)" })
|
|
36814
36925
|
] }) }) : null
|
|
36815
36926
|
]
|
|
36816
36927
|
}
|
|
@@ -37860,10 +37971,52 @@ function Done2(p) {
|
|
|
37860
37971
|
] }) }) });
|
|
37861
37972
|
}
|
|
37862
37973
|
|
|
37863
|
-
// src/ui/
|
|
37974
|
+
// src/ui/panels/OverflowPanel.tsx
|
|
37864
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);
|
|
37865
38018
|
var DASHBOARD = "latentprotocol.xyz/app";
|
|
37866
|
-
var MODE = { keep: "keep and spend (bonus)", auto_sell: "sell automatically for
|
|
38019
|
+
var MODE = { keep: "keep and spend (bonus)", auto_sell: "sell automatically for USDC", auto_list: "list at my price" };
|
|
37867
38020
|
var notice = (text, tone = "info") => ({
|
|
37868
38021
|
type: "latentcode.notice",
|
|
37869
38022
|
created: Date.now(),
|
|
@@ -37895,42 +38048,42 @@ function activityLabel(s2) {
|
|
|
37895
38048
|
function StepMark({ status: status2 }) {
|
|
37896
38049
|
switch (status2) {
|
|
37897
38050
|
case "run":
|
|
37898
|
-
return /* @__PURE__ */ (0,
|
|
38051
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Spinner, {});
|
|
37899
38052
|
case "ok":
|
|
37900
|
-
return /* @__PURE__ */ (0,
|
|
38053
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { color: C.ok, children: G.ok });
|
|
37901
38054
|
case "warn":
|
|
37902
|
-
return /* @__PURE__ */ (0,
|
|
38055
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { color: C.warn, children: G.ring });
|
|
37903
38056
|
case "fail":
|
|
37904
|
-
return /* @__PURE__ */ (0,
|
|
38057
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { color: C.err, children: G.no });
|
|
37905
38058
|
default:
|
|
37906
|
-
return /* @__PURE__ */ (0,
|
|
38059
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { color: C.faint, children: "\xB7" });
|
|
37907
38060
|
}
|
|
37908
38061
|
}
|
|
37909
38062
|
function BootCard(p) {
|
|
37910
38063
|
const wLabel = 10;
|
|
37911
38064
|
const inner = p.width - 4;
|
|
37912
|
-
return /* @__PURE__ */ (0,
|
|
37913
|
-
/* @__PURE__ */ (0,
|
|
37914
|
-
/* @__PURE__ */ (0,
|
|
37915
|
-
/* @__PURE__ */ (0,
|
|
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 })
|
|
37916
38069
|
] }),
|
|
37917
|
-
/* @__PURE__ */ (0,
|
|
37918
|
-
p.steps.map((st) => /* @__PURE__ */ (0,
|
|
37919
|
-
/* @__PURE__ */ (0,
|
|
37920
|
-
/* @__PURE__ */ (0,
|
|
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: [
|
|
37921
38074
|
" ",
|
|
37922
38075
|
pad(st.label, wLabel)
|
|
37923
38076
|
] }),
|
|
37924
|
-
/* @__PURE__ */ (0,
|
|
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) })
|
|
37925
38078
|
] }, st.id)),
|
|
37926
|
-
/* @__PURE__ */ (0,
|
|
37927
|
-
/* @__PURE__ */ (0,
|
|
37928
|
-
/* @__PURE__ */ (0,
|
|
37929
|
-
/* @__PURE__ */ (0,
|
|
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) })
|
|
37930
38083
|
] })
|
|
37931
38084
|
] }),
|
|
37932
|
-
p.error ? /* @__PURE__ */ (0,
|
|
37933
|
-
p.ready ? /* @__PURE__ */ (0,
|
|
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)(
|
|
37934
38087
|
Hints,
|
|
37935
38088
|
{
|
|
37936
38089
|
items: [
|
|
@@ -37959,26 +38112,26 @@ function HelpPanel({ width, commands, onClose }) {
|
|
|
37959
38112
|
["ctrl+o", "open the sponsored link"],
|
|
37960
38113
|
["ctrl+c", "clear the line, twice to quit"]
|
|
37961
38114
|
];
|
|
37962
|
-
return /* @__PURE__ */ (0,
|
|
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: [
|
|
37963
38116
|
groups.map((g) => {
|
|
37964
38117
|
const list = commands.filter((c) => c.group === g);
|
|
37965
38118
|
if (!list.length) return null;
|
|
37966
|
-
return /* @__PURE__ */ (0,
|
|
37967
|
-
/* @__PURE__ */ (0,
|
|
37968
|
-
list.map((c) => /* @__PURE__ */ (0,
|
|
37969
|
-
/* @__PURE__ */ (0,
|
|
37970
|
-
/* @__PURE__ */ (0,
|
|
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 })
|
|
37971
38124
|
] }, c.name))
|
|
37972
38125
|
] }, g);
|
|
37973
38126
|
}),
|
|
37974
|
-
/* @__PURE__ */ (0,
|
|
37975
|
-
/* @__PURE__ */ (0,
|
|
37976
|
-
keys.map(([k, d]) => /* @__PURE__ */ (0,
|
|
37977
|
-
/* @__PURE__ */ (0,
|
|
37978
|
-
/* @__PURE__ */ (0,
|
|
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 })
|
|
37979
38132
|
] }, k))
|
|
37980
38133
|
] }),
|
|
37981
|
-
/* @__PURE__ */ (0,
|
|
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.` }) })
|
|
37982
38135
|
] });
|
|
37983
38136
|
}
|
|
37984
38137
|
var LINKS_OSC8 = linkShape() === "osc8";
|
|
@@ -38072,6 +38225,11 @@ function App2(props) {
|
|
|
38072
38225
|
return () => clearInterval(t);
|
|
38073
38226
|
}, [state.working, lingering, controller]);
|
|
38074
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());
|
|
38075
38233
|
(0, import_react26.useEffect)(() => {
|
|
38076
38234
|
if (!wallet || state.working) return;
|
|
38077
38235
|
let live2 = true;
|
|
@@ -38090,12 +38248,18 @@ function App2(props) {
|
|
|
38090
38248
|
const model = currentModel.current;
|
|
38091
38249
|
if (!model) return;
|
|
38092
38250
|
const v = classifyError(ev.data?.error);
|
|
38093
|
-
const name =
|
|
38251
|
+
const name = catalogRef.current.models.find((m) => m.key === model)?.name ?? model;
|
|
38094
38252
|
if (v.status === "unsupported") {
|
|
38095
38253
|
store.set(model, v);
|
|
38096
38254
|
say(`${name} isn't available with your connected account. /model shows which ones are (${G.ok}).`, "warn");
|
|
38097
38255
|
} else if (v.status === "rate-limited") {
|
|
38098
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
|
+
}
|
|
38099
38263
|
const mins = v.until ? Math.max(1, Math.round((v.until - Date.now()) / 6e4)) : 0;
|
|
38100
38264
|
say(`${name} is rate-limited${mins ? ` for about ${mins} min` : ""}. /model to switch.`, "warn");
|
|
38101
38265
|
} else if (v.status === "auth") {
|
|
@@ -38214,7 +38378,7 @@ Spend it here: /login connects the Latent provider (or /key lk_\u2026 with a key
|
|
|
38214
38378
|
`Latent Credit ${c.credits.toFixed(2)} credits \xB7 $1 of model usage at list price each`,
|
|
38215
38379
|
`Bonus ${c.bonus}\xD7 \u2014 every $1 earned from ads becomes ${c.bonus} credits`,
|
|
38216
38380
|
`Mode ${MODE[c.mode]}`,
|
|
38217
|
-
q?.buybackEnabled ? `Sell now ${q.buybackPrice.toFixed(2)}
|
|
38381
|
+
q?.buybackEnabled ? `Sell now ${q.buybackPrice.toFixed(2)} USDC per credit, paid on Base` : `Sell now opens soon`,
|
|
38218
38382
|
`Change it ${DASHBOARD}/settings \xB7 sell or list at ${DASHBOARD}/earn \xB7 buy at ${DASHBOARD}/credits`
|
|
38219
38383
|
].join("\n")
|
|
38220
38384
|
);
|
|
@@ -38352,18 +38516,18 @@ Spend it here: /login connects the Latent provider (or /key lk_\u2026 with a key
|
|
|
38352
38516
|
const current = catalog.models.find((m) => m.key === state.model);
|
|
38353
38517
|
const provider = catalog.providers.find((p) => p.id === (current?.providerID ?? parseKey(state.model)?.providerID));
|
|
38354
38518
|
const close = () => setOverlay(null);
|
|
38355
|
-
return /* @__PURE__ */ (0,
|
|
38356
|
-
/* @__PURE__ */ (0,
|
|
38357
|
-
live.map((it) => /* @__PURE__ */ (0,
|
|
38358
|
-
perm ? /* @__PURE__ */ (0,
|
|
38359
|
-
state.working ? /* @__PURE__ */ (0,
|
|
38360
|
-
/* @__PURE__ */ (0,
|
|
38361
|
-
/* @__PURE__ */ (0,
|
|
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: [
|
|
38362
38526
|
" ",
|
|
38363
38527
|
activityLabel(state),
|
|
38364
38528
|
"\u2026"
|
|
38365
38529
|
] }),
|
|
38366
|
-
/* @__PURE__ */ (0,
|
|
38530
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Text, { color: C.faint, children: [
|
|
38367
38531
|
" ",
|
|
38368
38532
|
elapsed,
|
|
38369
38533
|
"s \xB7 ",
|
|
@@ -38375,7 +38539,7 @@ Spend it here: /login connects the Latent provider (or /key lk_\u2026 with a key
|
|
|
38375
38539
|
" \xB7 esc to interrupt"
|
|
38376
38540
|
] })
|
|
38377
38541
|
] }) }) : null,
|
|
38378
|
-
overlay?.t === "model" ? /* @__PURE__ */ (0,
|
|
38542
|
+
overlay?.t === "model" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
38379
38543
|
ModelPicker,
|
|
38380
38544
|
{
|
|
38381
38545
|
catalog,
|
|
@@ -38394,7 +38558,7 @@ Spend it here: /login connects the Latent provider (or /key lk_\u2026 with a key
|
|
|
38394
38558
|
onClose: close
|
|
38395
38559
|
}
|
|
38396
38560
|
) : null,
|
|
38397
|
-
overlay?.t === "providers" ? /* @__PURE__ */ (0,
|
|
38561
|
+
overlay?.t === "providers" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
38398
38562
|
ProviderPanel,
|
|
38399
38563
|
{
|
|
38400
38564
|
engine,
|
|
@@ -38413,10 +38577,34 @@ Spend it here: /login connects the Latent provider (or /key lk_\u2026 with a key
|
|
|
38413
38577
|
onClose: close
|
|
38414
38578
|
}
|
|
38415
38579
|
) : null,
|
|
38416
|
-
overlay?.t === "wallet" ? /* @__PURE__ */ (0,
|
|
38417
|
-
overlay?.t === "help" ? /* @__PURE__ */ (0,
|
|
38418
|
-
overlay ===
|
|
38419
|
-
|
|
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)(
|
|
38420
38608
|
Box_default,
|
|
38421
38609
|
{
|
|
38422
38610
|
marginTop: 1,
|
|
@@ -38425,41 +38613,41 @@ Spend it here: /login connects the Latent provider (or /key lk_\u2026 with a key
|
|
|
38425
38613
|
paddingX: 1,
|
|
38426
38614
|
width,
|
|
38427
38615
|
children: [
|
|
38428
|
-
/* @__PURE__ */ (0,
|
|
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: [
|
|
38429
38617
|
G.prompt,
|
|
38430
38618
|
" "
|
|
38431
38619
|
] }) }),
|
|
38432
|
-
/* @__PURE__ */ (0,
|
|
38620
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FieldText, { state: editor, placeholder: state.turns ? "reply, or / for commands" : "ask anything, or / for commands" })
|
|
38433
38621
|
]
|
|
38434
38622
|
}
|
|
38435
38623
|
),
|
|
38436
|
-
paletteOpen ? /* @__PURE__ */ (0,
|
|
38437
|
-
matches.slice(0, 8).map((c, i) => /* @__PURE__ */ (0,
|
|
38438
|
-
/* @__PURE__ */ (0,
|
|
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: [
|
|
38439
38627
|
i === paletteSel ? G.prompt : " ",
|
|
38440
38628
|
" "
|
|
38441
38629
|
] }),
|
|
38442
|
-
/* @__PURE__ */ (0,
|
|
38443
|
-
/* @__PURE__ */ (0,
|
|
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 })
|
|
38444
38632
|
] }, c.name)),
|
|
38445
|
-
matches.length > 8 ? /* @__PURE__ */ (0,
|
|
38633
|
+
matches.length > 8 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Text, { color: C.faint, children: [
|
|
38446
38634
|
" ",
|
|
38447
38635
|
G.down,
|
|
38448
38636
|
" ",
|
|
38449
38637
|
matches.length - 8,
|
|
38450
38638
|
" more \u2014 keep typing"
|
|
38451
38639
|
] }) : null,
|
|
38452
|
-
/* @__PURE__ */ (0,
|
|
38640
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Hints, { items: [["\u2191\u2193", "move"], ["tab", "complete"], ["enter", "run"], ["esc", "dismiss"]] })
|
|
38453
38641
|
] }) : null
|
|
38454
38642
|
] }) : null,
|
|
38455
|
-
paletteOpen || leaving ? null : quitArmed ? /* @__PURE__ */ (0,
|
|
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)(
|
|
38456
38644
|
StatusPanel,
|
|
38457
38645
|
{
|
|
38458
38646
|
width,
|
|
38459
38647
|
model: current?.name ?? state.model,
|
|
38460
38648
|
variant: state.variant,
|
|
38461
38649
|
provider: provider?.name,
|
|
38462
|
-
latent: (current?.providerID ?? parseKey(state.model)?.providerID) ===
|
|
38650
|
+
latent: (current?.providerID ?? parseKey(state.model)?.providerID) === LATENT_PROVIDER_ID,
|
|
38463
38651
|
working: state.working,
|
|
38464
38652
|
tokens: state.tokens.input + state.tokens.output,
|
|
38465
38653
|
cost: state.cost,
|
|
@@ -38468,6 +38656,7 @@ Spend it here: /login connects the Latent provider (or /key lk_\u2026 with a key
|
|
|
38468
38656
|
adIndex: ad.adIndex,
|
|
38469
38657
|
visibleMs: ad.visibleMs,
|
|
38470
38658
|
billed: ad.billed,
|
|
38659
|
+
verdict: ad.verdict,
|
|
38471
38660
|
balance,
|
|
38472
38661
|
sessionCredits: credits(ad.sessionEarned, bonus),
|
|
38473
38662
|
views: ad.impressions,
|
|
@@ -38479,7 +38668,7 @@ Spend it here: /login connects the Latent provider (or /key lk_\u2026 with a key
|
|
|
38479
38668
|
}
|
|
38480
38669
|
|
|
38481
38670
|
// src/ui/Root.tsx
|
|
38482
|
-
var
|
|
38671
|
+
var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
|
|
38483
38672
|
function Root(p) {
|
|
38484
38673
|
const { exit } = use_app_default();
|
|
38485
38674
|
const { cols } = useTermSize();
|
|
@@ -38501,7 +38690,7 @@ function Root(p) {
|
|
|
38501
38690
|
{ isActive: !booted }
|
|
38502
38691
|
);
|
|
38503
38692
|
if (!booted) {
|
|
38504
|
-
return /* @__PURE__ */ (0,
|
|
38693
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
38505
38694
|
BootCard,
|
|
38506
38695
|
{
|
|
38507
38696
|
steps,
|
|
@@ -38513,7 +38702,7 @@ function Root(p) {
|
|
|
38513
38702
|
}
|
|
38514
38703
|
);
|
|
38515
38704
|
}
|
|
38516
|
-
return /* @__PURE__ */ (0,
|
|
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 }) });
|
|
38517
38706
|
}
|
|
38518
38707
|
|
|
38519
38708
|
// src/ads/attention.ts
|
|
@@ -38729,8 +38918,8 @@ function row(mark, label2, value, width = 10) {
|
|
|
38729
38918
|
}
|
|
38730
38919
|
|
|
38731
38920
|
// src/index.tsx
|
|
38732
|
-
var
|
|
38733
|
-
var VERSION = "0.1.0-alpha.
|
|
38921
|
+
var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
|
|
38922
|
+
var VERSION = "0.1.0-alpha.9";
|
|
38734
38923
|
var usage = () => `${logo()}
|
|
38735
38924
|
${a.dim(`v${VERSION} \xB7 terminal coding agent. Bring your own model access; earn while it works.`)}
|
|
38736
38925
|
|
|
@@ -38871,7 +39060,7 @@ async function main() {
|
|
|
38871
39060
|
const summary = { current: { turns: 0, tokens: 0, cost: 0, earned: 0, impressions: 0 } };
|
|
38872
39061
|
let fatal = false;
|
|
38873
39062
|
const app = render_default(
|
|
38874
|
-
/* @__PURE__ */ (0,
|
|
39063
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
38875
39064
|
Root,
|
|
38876
39065
|
{
|
|
38877
39066
|
args: { cwd: cwd2, model: args.model, noAds: args.noAds, auto: args.auto },
|
package/package.json
CHANGED