clisponsor 1.0.9 → 1.0.10

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/bin/clisponsor.mjs +23 -4
  2. package/package.json +1 -1
@@ -407,11 +407,12 @@ function agentHookSource(client, options = {}) {
407
407
  return `#!/usr/bin/env node
408
408
  import fs from "node:fs";
409
409
  import crypto from "node:crypto";
410
- const cfg = JSON.parse(fs.readFileSync(${JSON.stringify(CONFIG_PATH)}, "utf8"));
411
410
  const event = process.argv[2] || "BeforeAgent";
412
411
  const outputMode = ${JSON.stringify(outputMode)};
413
412
  const placements = { SessionStart: "StartSession", PreInvocation: "StartTurn", BeforeAgent: "StartTurn", UserPromptSubmit: "StartTurn", PreToolUse: "StartTurn", AfterAgent: "EndTurn", PostInvocation: "EndTurn", Stop: "EndTurn", StartTurn: "StartTurn" };
414
- const serveBaseUrl = cfg.serveBaseUrl || cfg.apiBaseUrl;
413
+ function writeNoop() {
414
+ if (outputMode === "antigravity") console.log(JSON.stringify({}));
415
+ }
415
416
  function sponsoredLine(line) {
416
417
  return "[Sponsored] " + line;
417
418
  }
@@ -427,11 +428,26 @@ let hookInput = {};
427
428
  try {
428
429
  hookInput = hookInputRaw.trim() ? JSON.parse(hookInputRaw) : {};
429
430
  } catch {}
431
+ let cfg = {};
432
+ try {
433
+ cfg = JSON.parse(fs.readFileSync(${JSON.stringify(CONFIG_PATH)}, "utf8"));
434
+ } catch {
435
+ writeNoop();
436
+ process.exit(0);
437
+ }
438
+ const serveBaseUrl = cfg.serveBaseUrl || cfg.apiBaseUrl;
430
439
  try {
431
- if (!serveBaseUrl || !cfg.userId || !cfg.deviceCode || !cfg.deviceSecret) process.exit(0);
440
+ if (outputMode === "antigravity" && event !== "PreInvocation") {
441
+ writeNoop();
442
+ process.exit(0);
443
+ }
444
+ if (!serveBaseUrl || !cfg.userId || !cfg.deviceCode || !cfg.deviceSecret) {
445
+ writeNoop();
446
+ process.exit(0);
447
+ }
432
448
  if (outputMode === "antigravity") {
433
449
  if (event === "PreInvocation" && Number(hookInput.invocationNum || 1) > 1) {
434
- console.log(JSON.stringify({}));
450
+ writeNoop();
435
451
  process.exit(0);
436
452
  }
437
453
  }
@@ -455,8 +471,11 @@ try {
455
471
  } else if (ad.display_line) {
456
472
  console.log(JSON.stringify({ systemMessage: sponsoredLine(ad.display_line) }));
457
473
  }
474
+ } else {
475
+ writeNoop();
458
476
  }
459
477
  } catch {
478
+ writeNoop();
460
479
  process.exit(0);
461
480
  }
462
481
  `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clisponsor",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "CLIsponsor installer for Codex, Claude Code, and Gemini sponsored CLI placements.",
5
5
  "type": "module",
6
6
  "engines": {