clisponsor 1.0.2 → 1.0.3
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/bin/clisponsor.mjs
CHANGED
|
@@ -369,6 +369,9 @@ const cfg = JSON.parse(fs.readFileSync(${JSON.stringify(CONFIG_PATH)}, "utf8"));
|
|
|
369
369
|
const event = process.argv[2] || "BeforeAgent";
|
|
370
370
|
const placements = { SessionStart: "StartSession", BeforeAgent: "StartTurn", AfterAgent: "EndTurn", StartTurn: "StartTurn" };
|
|
371
371
|
const serveBaseUrl = cfg.serveBaseUrl || cfg.apiBaseUrl;
|
|
372
|
+
function sponsoredLine(line) {
|
|
373
|
+
return "[Sponsored] " + line;
|
|
374
|
+
}
|
|
372
375
|
function readStdin() {
|
|
373
376
|
return new Promise((resolve) => {
|
|
374
377
|
let data = "";
|
|
@@ -392,7 +395,7 @@ try {
|
|
|
392
395
|
});
|
|
393
396
|
if (res.ok) {
|
|
394
397
|
const ad = await res.json();
|
|
395
|
-
if (ad.display_line) console.log(JSON.stringify({ systemMessage: ad.display_line }));
|
|
398
|
+
if (ad.display_line) console.log(JSON.stringify({ systemMessage: sponsoredLine(ad.display_line) }));
|
|
396
399
|
}
|
|
397
400
|
} catch {
|
|
398
401
|
process.exit(0);
|
package/package.json
CHANGED
|
@@ -22,6 +22,10 @@ function readStdin() {
|
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
function sponsoredLine(line) {
|
|
26
|
+
return `[Sponsored] ${line}`;
|
|
27
|
+
}
|
|
28
|
+
|
|
25
29
|
await readStdin();
|
|
26
30
|
|
|
27
31
|
try {
|
|
@@ -46,7 +50,7 @@ try {
|
|
|
46
50
|
});
|
|
47
51
|
if (!res.ok) process.exit(0);
|
|
48
52
|
const ad = await res.json();
|
|
49
|
-
if (ad.display_line) console.log(JSON.stringify({ systemMessage: ad.display_line }));
|
|
53
|
+
if (ad.display_line) console.log(JSON.stringify({ systemMessage: sponsoredLine(ad.display_line) }));
|
|
50
54
|
} catch {
|
|
51
55
|
process.exit(0);
|
|
52
56
|
}
|
|
@@ -23,6 +23,10 @@ function readConfig() {
|
|
|
23
23
|
return JSON.parse(fs.readFileSync(CONFIG_PATH, "utf8"));
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
function sponsoredLine(line) {
|
|
27
|
+
return `[Sponsored] ${line}`;
|
|
28
|
+
}
|
|
29
|
+
|
|
26
30
|
const cfg = readConfig();
|
|
27
31
|
const serveBaseUrl = cfg.serveBaseUrl || cfg.apiBaseUrl;
|
|
28
32
|
await readStdin();
|
|
@@ -50,7 +54,7 @@ try {
|
|
|
50
54
|
});
|
|
51
55
|
if (!res.ok) process.exit(0);
|
|
52
56
|
const ad = await res.json();
|
|
53
|
-
if (ad.display_line) console.log(JSON.stringify({ systemMessage: ad.display_line }));
|
|
57
|
+
if (ad.display_line) console.log(JSON.stringify({ systemMessage: sponsoredLine(ad.display_line) }));
|
|
54
58
|
} catch {
|
|
55
59
|
process.exit(0);
|
|
56
60
|
}
|