clixad 0.0.1-beta.29 → 0.0.1-beta.30

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.
Files changed (2) hide show
  1. package/dist/clixad.mjs +57 -10
  2. package/package.json +1 -1
package/dist/clixad.mjs CHANGED
@@ -1099,7 +1099,7 @@ var init_client = __esm({
1099
1099
  */
1100
1100
  async sponsorConfig(signal) {
1101
1101
  try {
1102
- const res = await gatewayFetch(`${this.config.gatewayUrl}/v1/sponsor/config`, {
1102
+ const res = await gatewayFetch(`${this.config.gatewayUrl}/v1/sponsor/config?direct=1`, {
1103
1103
  headers: this.headers(),
1104
1104
  ...signal ? { signal } : {}
1105
1105
  });
@@ -1175,10 +1175,10 @@ var init_client = __esm({
1175
1175
  body: JSON.stringify({ formats, cols })
1176
1176
  });
1177
1177
  if (res.status === 404) return { supported: false, lines: [] };
1178
- if (!res.ok) return { supported: true, lines: [] };
1178
+ if (!res.ok) return { supported: true, lines: [], failed: true };
1179
1179
  return { supported: true, lines: parseDirectLines(await res.json()) };
1180
1180
  } catch {
1181
- return { supported: true, lines: [] };
1181
+ return { supported: true, lines: [], failed: true };
1182
1182
  }
1183
1183
  }
1184
1184
  /**
@@ -5634,6 +5634,44 @@ var init_network = __esm({
5634
5634
  }
5635
5635
  });
5636
5636
 
5637
+ // src/sponsor/hyperlink.ts
5638
+ function version(v) {
5639
+ const m = /^(\d+)(?:\.(\d+))?/.exec(v ?? "");
5640
+ return m ? [Number(m[1]), Number(m[2] ?? 0)] : [0, 0];
5641
+ }
5642
+ function hyperlinksEnabled({ isTTY, env }) {
5643
+ const force = env.FORCE_HYPERLINK?.trim().toLowerCase();
5644
+ if (force !== void 0 && force !== "") return !(force === "0" || force === "false");
5645
+ if (!isTTY) return false;
5646
+ if (env.CI !== void 0 && env.CI !== "") return false;
5647
+ if (env.TERM === "dumb") return false;
5648
+ if (env.WT_SESSION) return true;
5649
+ switch (env.TERM_PROGRAM) {
5650
+ case "iTerm.app":
5651
+ return atLeast(version(env.TERM_PROGRAM_VERSION), 3, 1);
5652
+ case "WezTerm":
5653
+ case "ghostty":
5654
+ return true;
5655
+ case "vscode":
5656
+ return atLeast(version(env.TERM_PROGRAM_VERSION), 1, 72);
5657
+ }
5658
+ if (env.TERM === "xterm-kitty" || env.KITTY_WINDOW_ID) return true;
5659
+ if (env.KONSOLE_VERSION) return true;
5660
+ if (env.VTE_VERSION) return Number(env.VTE_VERSION) >= 5001;
5661
+ return false;
5662
+ }
5663
+ function osc8(text, url) {
5664
+ const safe = url.replace(/[\u0000-\u001f\u007f-\u009f]/g, "");
5665
+ return `\x1B]8;;${safe}\x07${text}\x1B]8;;\x07`;
5666
+ }
5667
+ var atLeast;
5668
+ var init_hyperlink = __esm({
5669
+ "src/sponsor/hyperlink.ts"() {
5670
+ "use strict";
5671
+ atLeast = (v, major, minor) => v[0] > major || v[0] === major && v[1] >= minor;
5672
+ }
5673
+ });
5674
+
5637
5675
  // src/tui/commands.ts
5638
5676
  function commandLabel(c2) {
5639
5677
  return `/${c2.name}${c2.args ? ` ${c2.args}` : ""}`;
@@ -6307,6 +6345,7 @@ function App({
6307
6345
  const pendingImpressionRef = useRef(/* @__PURE__ */ new Map());
6308
6346
  const pendingDirectRef = useRef(/* @__PURE__ */ new Map());
6309
6347
  const directSupportedRef = useRef(true);
6348
+ const knownBookedRef = useRef(/* @__PURE__ */ new Set());
6310
6349
  const drawnRef = useRef(/* @__PURE__ */ new Set());
6311
6350
  const sponsorSlotRef = useRef(
6312
6351
  /* @__PURE__ */ new Map()
@@ -6549,26 +6588,31 @@ function App({
6549
6588
  if (!adFitsFormat(format, colsRef.current)) return;
6550
6589
  if (format !== "top_bar" && modalOpenRef.current) return;
6551
6590
  const drawnId = `direct:${call}:${format}`;
6591
+ const link = line2.clickUrl;
6552
6592
  if (format === "top_bar") {
6553
6593
  if (!sponsorRow(line2.text, colsRef.current, "network")) return;
6554
- setSponsor({ text: line2.text, origin: "network", impressionId: drawnId });
6594
+ setSponsor({ text: line2.text, origin: "network", impressionId: drawnId, link });
6555
6595
  } else {
6556
- setAdSlots((slots) => ({ ...slots, [format]: { text: line2.text, impressionId: drawnId } }));
6596
+ setAdSlots((slots) => ({ ...slots, [format]: { text: line2.text, impressionId: drawnId, link } }));
6557
6597
  }
6558
6598
  pendingDirectRef.current.set(format, { call, serveToken: line2.serveToken, drawnId });
6559
6599
  };
6560
6600
  const fitting = AD_FORMATS.filter((format) => adFitsFormat(format, colsRef.current));
6561
6601
  void (async () => {
6562
6602
  let direct = [];
6603
+ let failed = false;
6563
6604
  if (directSupportedRef.current && fitting.length > 0) {
6564
6605
  const ask3 = sponsorDirect ?? ((formats, cols2, signal) => client.directSponsor(formats, cols2, signal));
6565
6606
  let answer = { supported: true, lines: [] };
6566
6607
  try {
6567
6608
  answer = await ask3(fitting, colsRef.current, AbortSignal.timeout(DIRECT_ASK_TIMEOUT_MS));
6568
6609
  } catch {
6610
+ answer = { supported: true, lines: [], failed: true };
6569
6611
  }
6570
6612
  if (!answer.supported) directSupportedRef.current = false;
6613
+ failed = answer.failed === true;
6571
6614
  direct = answer.lines;
6615
+ if (!failed) knownBookedRef.current = new Set(direct.map((line2) => line2.format));
6572
6616
  }
6573
6617
  if (call !== sponsorCallRef.current) return;
6574
6618
  for (const format of ["top_bar", ...EXTRA_AD_FORMATS]) {
@@ -6576,6 +6620,7 @@ function App({
6576
6620
  const booked = direct.find((line2) => line2.format === format);
6577
6621
  if (booked && "hold" in booked) continue;
6578
6622
  if (booked) paintDirect(booked);
6623
+ else if (failed && knownBookedRef.current.has(format)) continue;
6579
6624
  else fetchNetwork(format);
6580
6625
  }
6581
6626
  })();
@@ -7959,6 +8004,7 @@ ${dropped.map((l) => ` \xB7 ${l}`).join("\n")}`
7959
8004
  const spinner = spinnerRef.current[Math.floor(tick / SPINNER_TICKS_PER_FRAME) % spinnerRef.current.length];
7960
8005
  const sponsorLine = busy && sponsor ? sponsorRow(sponsor.text, cols, sponsor.origin) : null;
7961
8006
  const adColor = adColorEnabled({ isTTY: stdout.isTTY, env: process.env });
8007
+ const linkable = hyperlinksEnabled({ isTTY: stdout.isTTY, env: process.env });
7962
8008
  const modalOpen = Boolean(picker || ask2 || plan || buy);
7963
8009
  modalOpenRef.current = modalOpen;
7964
8010
  const card = busy && !modalOpen && adSlots.sidebar_card ? sidebarCard(adSlots.sidebar_card.text, cols) : null;
@@ -8193,7 +8239,7 @@ ${dropped.map((l) => ` \xB7 ${l}`).join("\n")}`
8193
8239
  ] }),
8194
8240
  /* @__PURE__ */ jsxs2(Box2, { children: [
8195
8241
  /* @__PURE__ */ jsx2(Text2, { dimColor: true, children: card.rule }),
8196
- /* @__PURE__ */ jsx2(Text2, { ...adColor ? { color: AD_TEXT } : { dimColor: true }, wrap: "truncate-end", children: card.body })
8242
+ /* @__PURE__ */ jsx2(Text2, { ...adColor ? { color: AD_TEXT } : { dimColor: true }, wrap: "truncate-end", children: linkable && adSlots.sidebar_card?.link ? osc8(card.body, adSlots.sidebar_card.link) : card.body })
8197
8243
  ] })
8198
8244
  ] })
8199
8245
  ] })
@@ -8239,7 +8285,7 @@ ${dropped.map((l) => ` \xB7 ${l}`).join("\n")}`
8239
8285
  ] }) : null,
8240
8286
  /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", marginTop: showCard ? 0 : 1, children: [
8241
8287
  queueRows.map((line2, i) => /* @__PURE__ */ jsx2(Text2, { dimColor: true, children: line2 }, i)),
8242
- showSponsor && sponsorLine ? /* @__PURE__ */ jsx2(SponsorRowView, { row: sponsorLine, adColor }) : null,
8288
+ showSponsor && sponsorLine ? /* @__PURE__ */ jsx2(SponsorRowView, { row: sponsorLine, adColor, link: linkable ? sponsor?.link : void 0 }) : null,
8243
8289
  inputBorder ? /* @__PURE__ */ jsxs2(Box2, { borderStyle: "round", borderColor: busy ? MANGO3 : MANGO_BRIGHT, paddingX: 1, children: [
8244
8290
  /* @__PURE__ */ jsx2(Text2, { color: MANGO_BRIGHT, children: "\u276F " }),
8245
8291
  /* @__PURE__ */ jsx2(Text2, { children: renderInput(editor, inputFrom, inputRows) })
@@ -8259,15 +8305,15 @@ ${dropped.map((l) => ` \xB7 ${l}`).join("\n")}`
8259
8305
  /* @__PURE__ */ jsx2(Text2, { dimColor: true, wrap: "truncate-end", children: statusParts.after })
8260
8306
  ] })
8261
8307
  ] }),
8262
- showStatusBar && statusBarLine ? /* @__PURE__ */ jsx2(SponsorRowView, { row: statusBarLine, adColor }) : null
8308
+ showStatusBar && statusBarLine ? /* @__PURE__ */ jsx2(SponsorRowView, { row: statusBarLine, adColor, link: linkable ? adSlots.status_bar?.link : void 0 }) : null
8263
8309
  ] })
8264
8310
  ] });
8265
8311
  }
8266
- function SponsorRowView({ row, adColor }) {
8312
+ function SponsorRowView({ row, adColor, link }) {
8267
8313
  return /* @__PURE__ */ jsxs2(Box2, { children: [
8268
8314
  /* @__PURE__ */ jsx2(Text2, { dimColor: true, wrap: "truncate-end", children: row.marker }),
8269
8315
  row.label ? /* @__PURE__ */ jsx2(Text2, { ...adColor ? { color: AD_MARK } : { dimColor: true }, wrap: "truncate-end", children: row.label }) : null,
8270
- /* @__PURE__ */ jsx2(Text2, { ...adColor && row.origin === "network" ? { color: AD_TEXT } : { dimColor: true }, wrap: "truncate-end", children: row.body })
8316
+ /* @__PURE__ */ jsx2(Text2, { ...adColor && row.origin === "network" ? { color: AD_TEXT } : { dimColor: true }, wrap: "truncate-end", children: link && row.origin === "network" ? osc8(row.body, link) : row.body })
8271
8317
  ] });
8272
8318
  }
8273
8319
  function sleep4(ms, signal) {
@@ -8434,6 +8480,7 @@ var init_app = __esm({
8434
8480
  init_network();
8435
8481
  init_formats();
8436
8482
  init_direct();
8483
+ init_hyperlink();
8437
8484
  init_render();
8438
8485
  init_commands();
8439
8486
  init_editor();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clixad",
3
- "version": "0.0.1-beta.29",
3
+ "version": "0.0.1-beta.30",
4
4
  "description": "Free AI coding agent in your terminal, funded by rewarded ads.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",