latentcode 0.1.0-alpha.6 → 0.1.0-alpha.8
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 +1 -1
- package/dist/latentcode.mjs +272 -132
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
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.**
|
|
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.
|
|
7
7
|
- **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
8
|
- **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
9
|
- **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.
|
package/dist/latentcode.mjs
CHANGED
|
@@ -7941,7 +7941,7 @@ var require_react_reconciler_development = __commonJS({
|
|
|
7941
7941
|
var HostPortal = 4;
|
|
7942
7942
|
var HostComponent = 5;
|
|
7943
7943
|
var HostText = 6;
|
|
7944
|
-
var
|
|
7944
|
+
var Fragment6 = 7;
|
|
7945
7945
|
var Mode = 8;
|
|
7946
7946
|
var ContextConsumer = 9;
|
|
7947
7947
|
var ContextProvider = 10;
|
|
@@ -8081,7 +8081,7 @@ var require_react_reconciler_development = __commonJS({
|
|
|
8081
8081
|
return "DehydratedFragment";
|
|
8082
8082
|
case ForwardRef:
|
|
8083
8083
|
return getWrappedName$1(type, type.render, "ForwardRef");
|
|
8084
|
-
case
|
|
8084
|
+
case Fragment6:
|
|
8085
8085
|
return "Fragment";
|
|
8086
8086
|
case HostComponent:
|
|
8087
8087
|
return type;
|
|
@@ -11215,7 +11215,7 @@ var require_react_reconciler_development = __commonJS({
|
|
|
11215
11215
|
}
|
|
11216
11216
|
}
|
|
11217
11217
|
function updateFragment2(returnFiber, current2, fragment, lanes, key) {
|
|
11218
|
-
if (current2 === null || current2.tag !==
|
|
11218
|
+
if (current2 === null || current2.tag !== Fragment6) {
|
|
11219
11219
|
var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);
|
|
11220
11220
|
created.return = returnFiber;
|
|
11221
11221
|
return created;
|
|
@@ -11618,7 +11618,7 @@ var require_react_reconciler_development = __commonJS({
|
|
|
11618
11618
|
if (child.key === key) {
|
|
11619
11619
|
var elementType = element.type;
|
|
11620
11620
|
if (elementType === REACT_FRAGMENT_TYPE) {
|
|
11621
|
-
if (child.tag ===
|
|
11621
|
+
if (child.tag === Fragment6) {
|
|
11622
11622
|
deleteRemainingChildren(returnFiber, child.sibling);
|
|
11623
11623
|
var existing = useFiber(child, element.props.children);
|
|
11624
11624
|
existing.return = returnFiber;
|
|
@@ -17109,7 +17109,7 @@ var require_react_reconciler_development = __commonJS({
|
|
|
17109
17109
|
var _resolvedProps2 = workInProgress2.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2);
|
|
17110
17110
|
return updateForwardRef(current2, workInProgress2, type, _resolvedProps2, renderLanes2);
|
|
17111
17111
|
}
|
|
17112
|
-
case
|
|
17112
|
+
case Fragment6:
|
|
17113
17113
|
return updateFragment(current2, workInProgress2, renderLanes2);
|
|
17114
17114
|
case Mode:
|
|
17115
17115
|
return updateMode(current2, workInProgress2, renderLanes2);
|
|
@@ -17546,7 +17546,7 @@ var require_react_reconciler_development = __commonJS({
|
|
|
17546
17546
|
case SimpleMemoComponent:
|
|
17547
17547
|
case FunctionComponent:
|
|
17548
17548
|
case ForwardRef:
|
|
17549
|
-
case
|
|
17549
|
+
case Fragment6:
|
|
17550
17550
|
case Mode:
|
|
17551
17551
|
case Profiler:
|
|
17552
17552
|
case ContextConsumer:
|
|
@@ -22314,7 +22314,7 @@ var require_react_reconciler_development = __commonJS({
|
|
|
22314
22314
|
return fiber;
|
|
22315
22315
|
}
|
|
22316
22316
|
function createFiberFromFragment(elements, mode, lanes, key) {
|
|
22317
|
-
var fiber = createFiber(
|
|
22317
|
+
var fiber = createFiber(Fragment6, elements, key, mode);
|
|
22318
22318
|
fiber.lanes = lanes;
|
|
22319
22319
|
return fiber;
|
|
22320
22320
|
}
|
|
@@ -34846,6 +34846,7 @@ function classifyPrompt(prompt, cwd2 = process.cwd()) {
|
|
|
34846
34846
|
var MIN_VISIBLE_MS = 1e4;
|
|
34847
34847
|
var ROTATE_MS = 1e4;
|
|
34848
34848
|
var HOLD_MS = 27e4;
|
|
34849
|
+
var ACTIVE_MS = 6e4;
|
|
34849
34850
|
function safeUrl(raw) {
|
|
34850
34851
|
return raw && isSafeUrl(raw) ? new URL(raw).toString() : "";
|
|
34851
34852
|
}
|
|
@@ -34873,12 +34874,17 @@ var AdController = class {
|
|
|
34873
34874
|
shownAt = 0;
|
|
34874
34875
|
visibleMs = 0;
|
|
34875
34876
|
billed = false;
|
|
34877
|
+
verdict = null;
|
|
34876
34878
|
lastTick = 0;
|
|
34877
34879
|
fetching = false;
|
|
34880
|
+
/** Generation of the request in flight; a stale one never blocks a new turn. */
|
|
34881
|
+
fetchingGen = -1;
|
|
34878
34882
|
generation = 0;
|
|
34879
34883
|
context = "general";
|
|
34880
34884
|
impressions = 0;
|
|
34881
34885
|
sessionEarned = 0;
|
|
34886
|
+
adIndex = 0;
|
|
34887
|
+
lastActivity = 0;
|
|
34882
34888
|
listeners = /* @__PURE__ */ new Set();
|
|
34883
34889
|
/** Cached for useSyncExternalStore — must be referentially stable between emits. */
|
|
34884
34890
|
snap = null;
|
|
@@ -34890,6 +34896,7 @@ var AdController = class {
|
|
|
34890
34896
|
minVisibleMs: opts.minVisibleMs ?? MIN_VISIBLE_MS,
|
|
34891
34897
|
rotateMs: opts.rotateMs ?? ROTATE_MS,
|
|
34892
34898
|
holdMs: opts.holdMs ?? HOLD_MS,
|
|
34899
|
+
activeMs: opts.activeMs ?? ACTIVE_MS,
|
|
34893
34900
|
classify: opts.classify ?? ((p, cwd2) => classifyPrompt(p, cwd2))
|
|
34894
34901
|
};
|
|
34895
34902
|
opts.focus.onChange(() => this.emit());
|
|
@@ -34920,33 +34927,42 @@ var AdController = class {
|
|
|
34920
34927
|
if (this.snap) return this.snap;
|
|
34921
34928
|
return this.snap = {
|
|
34922
34929
|
status: this.status,
|
|
34923
|
-
current: this.
|
|
34930
|
+
current: this.current,
|
|
34931
|
+
adIndex: this.adIndex,
|
|
34932
|
+
idle: !this.working,
|
|
34924
34933
|
visibleMs: this.visibleMs,
|
|
34925
34934
|
billed: this.billed,
|
|
34935
|
+
verdict: this.verdict,
|
|
34926
34936
|
focusTracked: this.o.focus.known,
|
|
34927
34937
|
impressions: this.impressions,
|
|
34928
34938
|
sessionEarned: this.sessionEarned,
|
|
34929
34939
|
context: this.context
|
|
34930
34940
|
};
|
|
34931
34941
|
}
|
|
34942
|
+
/** The user typed or pasted: idle dwell may count for the next ACTIVE_MS. */
|
|
34943
|
+
noteActivity() {
|
|
34944
|
+
this.lastActivity = this.o.now();
|
|
34945
|
+
}
|
|
34932
34946
|
/** Called on execution start/end. `prompt` is classified locally, never sent. */
|
|
34933
34947
|
setWorking(working, prompt = "") {
|
|
34934
34948
|
if (working === this.working) return;
|
|
34935
34949
|
this.working = working;
|
|
34936
34950
|
this.lastTick = this.o.now();
|
|
34951
|
+
this.lastActivity = this.lastTick;
|
|
34937
34952
|
if (working) {
|
|
34938
34953
|
this.context = this.o.classify(prompt, this.o.cwd);
|
|
34939
|
-
if (!this.holding())
|
|
34940
|
-
|
|
34941
|
-
|
|
34942
|
-
}
|
|
34943
|
-
} else if (this.billed || !this.current) {
|
|
34954
|
+
if (this.current && !this.billed && !this.holding()) this.clear();
|
|
34955
|
+
if (!this.holding()) void this.fetchNext();
|
|
34956
|
+
} else if (!this.current) {
|
|
34944
34957
|
this.clear();
|
|
34945
34958
|
} else {
|
|
34946
34959
|
this.generation += 1;
|
|
34947
34960
|
}
|
|
34948
34961
|
this.emit();
|
|
34949
34962
|
}
|
|
34963
|
+
attentive(now) {
|
|
34964
|
+
return this.o.focus.focused && (this.working || now - this.lastActivity < this.o.activeMs);
|
|
34965
|
+
}
|
|
34950
34966
|
/** An un-billed ad that may still be shown and billed. */
|
|
34951
34967
|
holding() {
|
|
34952
34968
|
return !!this.current && !this.billed && this.o.now() - this.current.fetchedAt < this.o.holdMs;
|
|
@@ -34956,13 +34972,22 @@ var AdController = class {
|
|
|
34956
34972
|
const now = this.o.now();
|
|
34957
34973
|
const dt = Math.max(0, now - this.lastTick);
|
|
34958
34974
|
this.lastTick = now;
|
|
34959
|
-
if (!this.
|
|
34975
|
+
if (!this.current) return;
|
|
34960
34976
|
if (!this.billed && !this.holding()) {
|
|
34961
34977
|
this.clear();
|
|
34962
|
-
void this.fetchNext();
|
|
34978
|
+
if (this.working) void this.fetchNext();
|
|
34979
|
+
this.emit();
|
|
34963
34980
|
return;
|
|
34964
34981
|
}
|
|
34965
|
-
if (this.
|
|
34982
|
+
if (!this.working && this.billed && now - this.current.fetchedAt >= this.o.holdMs) {
|
|
34983
|
+
this.clear();
|
|
34984
|
+
this.emit();
|
|
34985
|
+
return;
|
|
34986
|
+
}
|
|
34987
|
+
if (!this.billed && this.attentive(now)) {
|
|
34988
|
+
this.visibleMs += dt;
|
|
34989
|
+
this.emit();
|
|
34990
|
+
}
|
|
34966
34991
|
if (!this.billed && this.visibleMs >= this.o.minVisibleMs) {
|
|
34967
34992
|
this.billed = true;
|
|
34968
34993
|
const shown = this.current;
|
|
@@ -34973,34 +34998,36 @@ var AdController = class {
|
|
|
34973
34998
|
displayedMs: this.visibleMs,
|
|
34974
34999
|
focusTracked: this.o.focus.known,
|
|
34975
35000
|
eventUuid: shown.eventUuid
|
|
34976
|
-
}).then((result) => {
|
|
34977
|
-
if (
|
|
34978
|
-
|
|
34979
|
-
|
|
35001
|
+
}).catch(() => "error").then((result) => {
|
|
35002
|
+
if (this.current === shown) this.verdict = result;
|
|
35003
|
+
if (result === "tracked") {
|
|
35004
|
+
this.impressions += 1;
|
|
35005
|
+
this.sessionEarned += shown.earn;
|
|
35006
|
+
}
|
|
34980
35007
|
this.emit();
|
|
34981
|
-
}).catch(() => {
|
|
34982
35008
|
});
|
|
34983
35009
|
this.emit();
|
|
34984
35010
|
}
|
|
34985
|
-
if (this.billed && now - this.shownAt >= this.o.rotateMs && !this.fetching) {
|
|
35011
|
+
if (this.working && this.billed && now - this.shownAt >= this.o.rotateMs && !this.fetching) {
|
|
34986
35012
|
void this.fetchNext();
|
|
34987
35013
|
}
|
|
34988
35014
|
}
|
|
34989
35015
|
/** User asked to open the ad (keyboard): the tracked link, or null. The server counts the click on redirect. */
|
|
34990
35016
|
click() {
|
|
34991
|
-
|
|
34992
|
-
return ad?.link || null;
|
|
35017
|
+
return this.current?.link || null;
|
|
34993
35018
|
}
|
|
34994
35019
|
clear() {
|
|
34995
35020
|
this.generation += 1;
|
|
34996
35021
|
this.current = null;
|
|
34997
35022
|
this.visibleMs = 0;
|
|
34998
35023
|
this.billed = false;
|
|
35024
|
+
this.verdict = null;
|
|
34999
35025
|
}
|
|
35000
35026
|
async fetchNext() {
|
|
35001
|
-
if (this.status !== "ok" || this.fetching) return;
|
|
35002
|
-
this.fetching = true;
|
|
35003
35027
|
const gen = this.generation;
|
|
35028
|
+
if (this.status !== "ok" || this.fetching && this.fetchingGen === gen) return;
|
|
35029
|
+
this.fetching = true;
|
|
35030
|
+
this.fetchingGen = gen;
|
|
35004
35031
|
try {
|
|
35005
35032
|
const ad = await this.o.api.request({ wallet: this.o.wallet, context: this.context, sessionId: this.o.sessionId });
|
|
35006
35033
|
if (gen !== this.generation || !this.working || this.status !== "ok") return;
|
|
@@ -35010,13 +35037,15 @@ var AdController = class {
|
|
|
35010
35037
|
return;
|
|
35011
35038
|
}
|
|
35012
35039
|
this.current = display;
|
|
35040
|
+
this.adIndex += 1;
|
|
35013
35041
|
this.shownAt = this.o.now();
|
|
35014
35042
|
this.lastTick = this.shownAt;
|
|
35015
35043
|
this.visibleMs = 0;
|
|
35016
35044
|
this.billed = false;
|
|
35045
|
+
this.verdict = null;
|
|
35017
35046
|
this.emit();
|
|
35018
35047
|
} finally {
|
|
35019
|
-
this.fetching = false;
|
|
35048
|
+
if (this.fetchingGen === gen) this.fetching = false;
|
|
35020
35049
|
}
|
|
35021
35050
|
}
|
|
35022
35051
|
emit() {
|
|
@@ -35810,48 +35839,158 @@ function reduce(state, ev, now = Date.now()) {
|
|
|
35810
35839
|
}
|
|
35811
35840
|
}
|
|
35812
35841
|
|
|
35813
|
-
// src/ui/
|
|
35842
|
+
// src/ui/StatusPanel.tsx
|
|
35814
35843
|
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
|
|
35815
|
-
var
|
|
35816
|
-
var
|
|
35817
|
-
function
|
|
35818
|
-
|
|
35819
|
-
|
|
35820
|
-
|
|
35821
|
-
|
|
35822
|
-
|
|
35823
|
-
|
|
35824
|
-
|
|
35825
|
-
|
|
35826
|
-
|
|
35844
|
+
var fmtTok = (n) => n >= 1e3 ? `${(n / 1e3).toFixed(1)}k` : String(n);
|
|
35845
|
+
var fmtUsd2 = (n) => `$${n.toFixed(n !== 0 && Math.abs(n) < 0.01 ? 4 : 2)}`;
|
|
35846
|
+
function Rule({ width }) {
|
|
35847
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: C.border, children: "\u2500".repeat(Math.max(0, width)) });
|
|
35848
|
+
}
|
|
35849
|
+
function verdictLabel(v) {
|
|
35850
|
+
switch (v) {
|
|
35851
|
+
case "tracked":
|
|
35852
|
+
return { text: `${G.ok} view counted`, tone: "ok" };
|
|
35853
|
+
case "unearned":
|
|
35854
|
+
return { text: "view not paid on this device", tone: "warn" };
|
|
35855
|
+
case "skipped":
|
|
35856
|
+
return { text: "view not counted", tone: "faint" };
|
|
35857
|
+
case "error":
|
|
35858
|
+
return { text: "view not counted \xB7 server unreachable", tone: "warn" };
|
|
35859
|
+
default:
|
|
35860
|
+
return { text: "counting view\u2026", tone: "faint" };
|
|
35861
|
+
}
|
|
35862
|
+
}
|
|
35863
|
+
function Progress({ ms, of, billed, verdict }) {
|
|
35864
|
+
if (billed) {
|
|
35865
|
+
const l = verdictLabel(verdict);
|
|
35866
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: l.tone === "ok" ? C.ok : l.tone === "warn" ? C.warn : C.faint, children: l.text });
|
|
35867
|
+
}
|
|
35868
|
+
const n = 10;
|
|
35869
|
+
const filled = Math.min(n, Math.floor(ms / of * n));
|
|
35870
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [
|
|
35871
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: C.earn, children: "\u25B0".repeat(filled) }),
|
|
35872
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: C.border, children: "\u25B1".repeat(n - filled) }),
|
|
35873
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { color: C.faint, children: [
|
|
35874
|
+
" ",
|
|
35875
|
+
Math.floor(ms / 1e3),
|
|
35876
|
+
"s / ",
|
|
35877
|
+
Math.round(of / 1e3),
|
|
35878
|
+
"s"
|
|
35879
|
+
] })
|
|
35827
35880
|
] });
|
|
35828
|
-
|
|
35829
|
-
|
|
35830
|
-
|
|
35831
|
-
|
|
35832
|
-
|
|
35833
|
-
|
|
35834
|
-
|
|
35835
|
-
|
|
35836
|
-
|
|
35837
|
-
|
|
35881
|
+
}
|
|
35882
|
+
function StatusPanel(p) {
|
|
35883
|
+
const inner = p.width - 4;
|
|
35884
|
+
const frame = p.working ? C.accent : C.border;
|
|
35885
|
+
const name = p.model || "no model";
|
|
35886
|
+
const prov = p.provider ? ` \xB7 ${p.provider}` : "";
|
|
35887
|
+
const variant = p.variant ? ` ${p.variant}` : "";
|
|
35888
|
+
const usage2 = [p.tokens ? `${fmtTok(p.tokens)} tok` : "", p.cost ? fmtUsd2(p.cost) : ""].filter(Boolean).join(" \xB7 ");
|
|
35889
|
+
const rightLen = usage2 ? usage2.length + 2 : 0;
|
|
35890
|
+
const leftBudget = p.width - 9 - rightLen;
|
|
35891
|
+
const leftText = clip(`${name}${variant}${prov}`, Math.max(8, leftBudget));
|
|
35892
|
+
const fill = Math.max(1, p.width - 8 - leftText.length - rightLen);
|
|
35893
|
+
const top = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { wrap: "truncate-end", children: [
|
|
35894
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: frame, children: "\u256D\u2500 " }),
|
|
35895
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: p.latent ? C.earn : p.working ? C.accent : C.ok, children: G.dot }),
|
|
35896
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: " " }),
|
|
35897
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { bold: true, color: C.text, children: leftText.slice(0, name.length) }),
|
|
35898
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: C.accent2, children: leftText.slice(name.length, name.length + variant.length) }),
|
|
35899
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: C.muted, children: leftText.slice(name.length + variant.length) }),
|
|
35900
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { color: frame, children: [
|
|
35901
|
+
" ",
|
|
35902
|
+
"\u2500".repeat(fill)
|
|
35903
|
+
] }),
|
|
35904
|
+
usage2 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { color: C.faint, children: [
|
|
35905
|
+
" ",
|
|
35906
|
+
usage2,
|
|
35907
|
+
" "
|
|
35908
|
+
] }) : null,
|
|
35909
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: frame, children: "\u2500\u256E" })
|
|
35910
|
+
] });
|
|
35911
|
+
const earnings = p.earn === "ok" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { wrap: "truncate-end", children: [
|
|
35912
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { color: C.earn, children: [
|
|
35913
|
+
G.earn,
|
|
35914
|
+
" "
|
|
35915
|
+
] }),
|
|
35916
|
+
p.balance != null ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
35917
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { color: C.earn, bold: true, children: [
|
|
35918
|
+
p.balance.toFixed(3),
|
|
35919
|
+
" cr"
|
|
35838
35920
|
] }),
|
|
35839
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, {
|
|
35840
|
-
|
|
35841
|
-
|
|
35842
|
-
|
|
35843
|
-
|
|
35844
|
-
ad.shownUrl
|
|
35845
|
-
] }) : null,
|
|
35846
|
-
ad.link ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { color: C.faint, children: [
|
|
35847
|
-
" \xB7 ctrl+o ",
|
|
35848
|
-
ad.ctaText
|
|
35849
|
-
] }) : null
|
|
35921
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: C.faint, children: " \xB7 " })
|
|
35922
|
+
] }) : null,
|
|
35923
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { color: C.earn, children: [
|
|
35924
|
+
"+",
|
|
35925
|
+
p.sessionCredits.toFixed(3)
|
|
35850
35926
|
] }),
|
|
35851
|
-
|
|
35852
|
-
"
|
|
35853
|
-
|
|
35854
|
-
|
|
35927
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { color: C.faint, children: [
|
|
35928
|
+
inner >= 84 ? " this session" : "",
|
|
35929
|
+
" \xB7 ",
|
|
35930
|
+
p.views,
|
|
35931
|
+
" view",
|
|
35932
|
+
p.views === 1 ? "" : "s"
|
|
35933
|
+
] })
|
|
35934
|
+
] }) : p.earn === "disabled" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { color: C.faint, children: [
|
|
35935
|
+
G.earn,
|
|
35936
|
+
" Earn off \xB7 /ads on"
|
|
35937
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { color: C.warn, children: [
|
|
35938
|
+
G.earn,
|
|
35939
|
+
" /login to start earning"
|
|
35940
|
+
] });
|
|
35941
|
+
const ad = p.earn === "ok" ? p.ad : null;
|
|
35942
|
+
let body;
|
|
35943
|
+
if (ad) {
|
|
35944
|
+
const badge = adBadge(ad.title || ad.body);
|
|
35945
|
+
const cta = ad.link ? `${ad.ctaText || "Open"} ${G.arrow}` : "";
|
|
35946
|
+
const ctaLen = cta ? cta.length + 8 : 0;
|
|
35947
|
+
const brand = ad.title || ad.body;
|
|
35948
|
+
const rest = ad.title && ad.body ? ` \u2014 ${ad.body}` : "";
|
|
35949
|
+
const copyText = clip(brand + rest, Math.max(10, inner - 4 - ctaLen));
|
|
35950
|
+
const copy = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [
|
|
35951
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { bold: true, underline: !!ad.link && p.osc8Links, children: copyText.slice(0, brand.length) }),
|
|
35952
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: C.muted, children: copyText.slice(brand.length) })
|
|
35953
|
+
] });
|
|
35954
|
+
body = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
35955
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box_default, { justifyContent: "space-between", children: [
|
|
35956
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: C.faint, bold: true, children: "SPONSORED" }),
|
|
35957
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { color: C.faint, children: [
|
|
35958
|
+
"AD \xB7 ",
|
|
35959
|
+
String(p.adIndex ?? 1).padStart(2, "0")
|
|
35960
|
+
] })
|
|
35961
|
+
] }),
|
|
35962
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box_default, { justifyContent: "space-between", children: [
|
|
35963
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { wrap: "truncate-end", children: [
|
|
35964
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { backgroundColor: badge.color, color: "#111827", bold: true, children: ` ${badge.letter} ` }),
|
|
35965
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: " " }),
|
|
35966
|
+
p.osc8Links && ad.link ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Transform, { transform: (o) => osc8(o, ad.link), children: copy }) : copy
|
|
35967
|
+
] }),
|
|
35968
|
+
cta ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { children: [
|
|
35969
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: C.accent2, bold: true, children: cta }),
|
|
35970
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: C.faint, children: " ctrl+o" })
|
|
35971
|
+
] }) : null
|
|
35972
|
+
] }),
|
|
35973
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Rule, { width: inner }),
|
|
35974
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box_default, { justifyContent: "space-between", children: [
|
|
35975
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { wrap: "truncate-end", children: [
|
|
35976
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Progress, { ms: p.visibleMs ?? 0, of: p.minVisibleMs ?? 1e4, billed: !!p.billed, verdict: p.verdict }),
|
|
35977
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: C.faint, children: " \xB7 Powered by Latent Ads" })
|
|
35978
|
+
] }),
|
|
35979
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box_default, { flexShrink: 0, marginLeft: 2, children: earnings })
|
|
35980
|
+
] })
|
|
35981
|
+
] });
|
|
35982
|
+
} else {
|
|
35983
|
+
body = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box_default, { justifyContent: "space-between", children: [
|
|
35984
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { color: C.faint, wrap: "truncate-end", children: [
|
|
35985
|
+
p.wallet ? p.wallet : "",
|
|
35986
|
+
p.earn === "ok" ? `${p.wallet ? " \xB7 " : ""}ads show while the agent works` : ""
|
|
35987
|
+
] }),
|
|
35988
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box_default, { flexShrink: 0, marginLeft: 2, children: earnings })
|
|
35989
|
+
] });
|
|
35990
|
+
}
|
|
35991
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box_default, { flexDirection: "column", width: p.width, children: [
|
|
35992
|
+
top,
|
|
35993
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box_default, { flexDirection: "column", borderStyle: "round", borderTop: false, borderColor: frame, paddingX: 1, width: p.width, children: body })
|
|
35855
35994
|
] });
|
|
35856
35995
|
}
|
|
35857
35996
|
|
|
@@ -37861,6 +38000,7 @@ function HelpPanel({ width, commands, onClose }) {
|
|
|
37861
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.` }) })
|
|
37862
38001
|
] });
|
|
37863
38002
|
}
|
|
38003
|
+
var LINKS_OSC8 = linkShape() === "osc8";
|
|
37864
38004
|
function App2(props) {
|
|
37865
38005
|
const { engine, controller, api, cwd: cwd2, version } = props;
|
|
37866
38006
|
const { exit } = use_app_default();
|
|
@@ -37938,14 +38078,27 @@ function App2(props) {
|
|
|
37938
38078
|
(0, import_react26.useEffect)(() => {
|
|
37939
38079
|
controller.setWorking(state.working, lastPrompt.current);
|
|
37940
38080
|
}, [state.working, controller]);
|
|
38081
|
+
const lingering = !state.working && !!ad.current;
|
|
37941
38082
|
(0, import_react26.useEffect)(() => {
|
|
37942
|
-
if (!state.working) return;
|
|
37943
|
-
const t = setInterval(
|
|
37944
|
-
|
|
37945
|
-
|
|
37946
|
-
|
|
38083
|
+
if (!state.working && !lingering) return;
|
|
38084
|
+
const t = setInterval(
|
|
38085
|
+
() => {
|
|
38086
|
+
controller.tick();
|
|
38087
|
+
if (state.working) tick((f) => f + 1);
|
|
38088
|
+
},
|
|
38089
|
+
state.working ? 250 : 1e3
|
|
38090
|
+
);
|
|
37947
38091
|
return () => clearInterval(t);
|
|
37948
|
-
}, [state.working, controller]);
|
|
38092
|
+
}, [state.working, lingering, controller]);
|
|
38093
|
+
const [balance, setBalance] = (0, import_react26.useState)(null);
|
|
38094
|
+
(0, import_react26.useEffect)(() => {
|
|
38095
|
+
if (!wallet || state.working) return;
|
|
38096
|
+
let live2 = true;
|
|
38097
|
+
void api.creditSummary(wallet).then((c) => live2 && setBalance(c ? c.credits : null));
|
|
38098
|
+
return () => {
|
|
38099
|
+
live2 = false;
|
|
38100
|
+
};
|
|
38101
|
+
}, [api, wallet, state.working, ad.impressions]);
|
|
37949
38102
|
(0, import_react26.useEffect)(() => setPermAt(0), [state.permissions[0]?.id]);
|
|
37950
38103
|
(0, import_react26.useEffect)(() => {
|
|
37951
38104
|
if (!quitArmed) return;
|
|
@@ -38156,9 +38309,13 @@ Spend it here: /login connects the Latent provider (or /key lk_\u2026 with a key
|
|
|
38156
38309
|
const matches = overlay || perm || paletteHidden ? [] : matchCommands(editor.text, allCommands);
|
|
38157
38310
|
const paletteOpen = matches.length > 0 && !(matches.length === 1 && "/" + matches[0].name === editor.text && !matches[0].args);
|
|
38158
38311
|
const paletteSel = Math.min(paletteAt, Math.max(0, matches.length - 1));
|
|
38159
|
-
usePaste((text) =>
|
|
38312
|
+
usePaste((text) => {
|
|
38313
|
+
controller.noteActivity();
|
|
38314
|
+
setEditor(insert(editorRef.current, text.replace(/\n+$/, "")));
|
|
38315
|
+
}, overlay === null && !perm);
|
|
38160
38316
|
use_input_default(
|
|
38161
38317
|
(ch, key) => {
|
|
38318
|
+
controller.noteActivity();
|
|
38162
38319
|
if (perm) {
|
|
38163
38320
|
const decisions = ["once", "always", "reject"];
|
|
38164
38321
|
const reply = (d) => void engine.replyPermission(sessionID, perm.id, d).catch(fail);
|
|
@@ -38218,28 +38375,25 @@ Spend it here: /login connects the Latent provider (or /key lk_\u2026 with a key
|
|
|
38218
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) }),
|
|
38219
38376
|
live.map((it) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ItemView, { item: it, live: true, cwd: cwd2, width, maxLines }, it.id)),
|
|
38220
38377
|
perm ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(PermissionPrompt, { perm, selected: permAt, cwd: cwd2, width }) : null,
|
|
38221
|
-
state.working ? /* @__PURE__ */ (0, import_jsx_runtime7.
|
|
38222
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.
|
|
38223
|
-
|
|
38224
|
-
|
|
38225
|
-
|
|
38226
|
-
|
|
38227
|
-
"\u2026"
|
|
38228
|
-
] }),
|
|
38229
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { color: C.faint, children: [
|
|
38230
|
-
" ",
|
|
38231
|
-
elapsed,
|
|
38232
|
-
"s \xB7 ",
|
|
38233
|
-
G.up,
|
|
38234
|
-
fmtTokens(state.tokens.input),
|
|
38235
|
-
" ",
|
|
38236
|
-
G.down,
|
|
38237
|
-
fmtTokens(state.tokens.output),
|
|
38238
|
-
" \xB7 esc to interrupt"
|
|
38239
|
-
] })
|
|
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: [
|
|
38381
|
+
" ",
|
|
38382
|
+
activityLabel(state),
|
|
38383
|
+
"\u2026"
|
|
38240
38384
|
] }),
|
|
38241
|
-
|
|
38242
|
-
|
|
38385
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { color: C.faint, children: [
|
|
38386
|
+
" ",
|
|
38387
|
+
elapsed,
|
|
38388
|
+
"s \xB7 ",
|
|
38389
|
+
G.up,
|
|
38390
|
+
fmtTokens(state.tokens.input),
|
|
38391
|
+
" ",
|
|
38392
|
+
G.down,
|
|
38393
|
+
fmtTokens(state.tokens.output),
|
|
38394
|
+
" \xB7 esc to interrupt"
|
|
38395
|
+
] })
|
|
38396
|
+
] }) }) : null,
|
|
38243
38397
|
overlay?.t === "model" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
38244
38398
|
ModelPicker,
|
|
38245
38399
|
{
|
|
@@ -38317,44 +38471,30 @@ Spend it here: /login connects the Latent provider (or /key lk_\u2026 with a key
|
|
|
38317
38471
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Hints, { items: [["\u2191\u2193", "move"], ["tab", "complete"], ["enter", "run"], ["esc", "dismiss"]] })
|
|
38318
38472
|
] }) : null
|
|
38319
38473
|
] }) : null,
|
|
38320
|
-
paletteOpen || leaving ? null : /* @__PURE__ */ (0, import_jsx_runtime7.
|
|
38321
|
-
|
|
38322
|
-
|
|
38323
|
-
|
|
38324
|
-
|
|
38325
|
-
|
|
38326
|
-
|
|
38327
|
-
|
|
38328
|
-
|
|
38329
|
-
|
|
38330
|
-
|
|
38331
|
-
|
|
38332
|
-
|
|
38333
|
-
|
|
38334
|
-
|
|
38335
|
-
|
|
38336
|
-
|
|
38337
|
-
|
|
38338
|
-
|
|
38339
|
-
|
|
38340
|
-
|
|
38341
|
-
|
|
38342
|
-
|
|
38343
|
-
|
|
38344
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { color: C.faint, children: [
|
|
38345
|
-
" \xB7 ",
|
|
38346
|
-
ad.impressions,
|
|
38347
|
-
" view",
|
|
38348
|
-
ad.impressions === 1 ? "" : "s"
|
|
38349
|
-
] })
|
|
38350
|
-
] }) : ad.status === "disabled" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { color: C.faint, children: [
|
|
38351
|
-
G.earn,
|
|
38352
|
-
" Earn off \xB7 /ads on"
|
|
38353
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { color: C.warn, children: [
|
|
38354
|
-
G.earn,
|
|
38355
|
-
" /login to start earning"
|
|
38356
|
-
] }) })
|
|
38357
|
-
] })
|
|
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)(
|
|
38475
|
+
StatusPanel,
|
|
38476
|
+
{
|
|
38477
|
+
width,
|
|
38478
|
+
model: current?.name ?? state.model,
|
|
38479
|
+
variant: state.variant,
|
|
38480
|
+
provider: provider?.name,
|
|
38481
|
+
latent: (current?.providerID ?? parseKey(state.model)?.providerID) === "latent",
|
|
38482
|
+
working: state.working,
|
|
38483
|
+
tokens: state.tokens.input + state.tokens.output,
|
|
38484
|
+
cost: state.cost,
|
|
38485
|
+
earn: ad.status,
|
|
38486
|
+
ad: ad.current,
|
|
38487
|
+
adIndex: ad.adIndex,
|
|
38488
|
+
visibleMs: ad.visibleMs,
|
|
38489
|
+
billed: ad.billed,
|
|
38490
|
+
verdict: ad.verdict,
|
|
38491
|
+
balance,
|
|
38492
|
+
sessionCredits: credits(ad.sessionEarned, bonus),
|
|
38493
|
+
views: ad.impressions,
|
|
38494
|
+
wallet: shortWallet(wallet),
|
|
38495
|
+
osc8Links: LINKS_OSC8
|
|
38496
|
+
}
|
|
38497
|
+
)
|
|
38358
38498
|
] });
|
|
38359
38499
|
}
|
|
38360
38500
|
|
|
@@ -38610,7 +38750,7 @@ function row(mark, label2, value, width = 10) {
|
|
|
38610
38750
|
|
|
38611
38751
|
// src/index.tsx
|
|
38612
38752
|
var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
|
|
38613
|
-
var VERSION = "0.1.0-alpha.
|
|
38753
|
+
var VERSION = "0.1.0-alpha.8";
|
|
38614
38754
|
var usage = () => `${logo()}
|
|
38615
38755
|
${a.dim(`v${VERSION} \xB7 terminal coding agent. Bring your own model access; earn while it works.`)}
|
|
38616
38756
|
|
package/package.json
CHANGED