@tempoxyz/patron 0.0.24 → 0.0.25
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/dist/bin.js +3 -3
- package/dist/chunks/{-CTLNBCDF.js → -ZZLSTHT6.js} +9 -1
- package/dist/chunks/{chunk-SIIFXQ6S.js → chunk-HVTTV2A5.js} +8 -1
- package/dist/chunks/{hook-RJN6WCIT.js → hook-OZRD6I6F.js} +1 -1
- package/dist/chunks/{hook-process-QIK6YAOS.js → hook-process-ZPEWRFL2.js} +2 -2
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -4,14 +4,14 @@ const require = __patronCreateRequire(import.meta.url)
|
|
|
4
4
|
|
|
5
5
|
// src/bin.ts
|
|
6
6
|
if (process.argv[2] === "hook") {
|
|
7
|
-
const { runHookProcess } = await import("./chunks/hook-process-
|
|
7
|
+
const { runHookProcess } = await import("./chunks/hook-process-ZPEWRFL2.js");
|
|
8
8
|
await runHookProcess().catch(() => void 0);
|
|
9
9
|
process.exit(0);
|
|
10
10
|
} else if (process.argv[2] === "pay") {
|
|
11
|
-
const { runPayProcess } = await import("./chunks/hook-process-
|
|
11
|
+
const { runPayProcess } = await import("./chunks/hook-process-ZPEWRFL2.js");
|
|
12
12
|
await runPayProcess().catch(() => void 0);
|
|
13
13
|
process.exit(0);
|
|
14
14
|
} else {
|
|
15
|
-
const { run } = await import("./chunks/-
|
|
15
|
+
const { run } = await import("./chunks/-ZZLSTHT6.js");
|
|
16
16
|
process.exitCode = await run(process.argv.slice(2));
|
|
17
17
|
}
|
|
@@ -92,6 +92,13 @@ export const description = 'Patron: pays $0.001 to each site Amp reads with read
|
|
|
92
92
|
const COMMAND = ${JSON.stringify(command)}
|
|
93
93
|
const TOOLS = new Set(${JSON.stringify(AMP_WEB_TOOLS)})
|
|
94
94
|
|
|
95
|
+
/** Length of a tool's output; 0 for none or blank text. */
|
|
96
|
+
function size(output: unknown): number {
|
|
97
|
+
if (output === undefined || output === null) return 0
|
|
98
|
+
const text = typeof output === 'string' ? output : JSON.stringify(output)
|
|
99
|
+
return text.trim().length
|
|
100
|
+
}
|
|
101
|
+
|
|
95
102
|
export default function (amp: PluginAPI) {
|
|
96
103
|
amp.on('tool.result', (event) => {
|
|
97
104
|
if (event.status !== 'done' || !TOOLS.has(event.tool)) return
|
|
@@ -104,7 +111,8 @@ export default function (amp: PluginAPI) {
|
|
|
104
111
|
hook_event_name: 'tool.result',
|
|
105
112
|
tool_input: event.input,
|
|
106
113
|
tool_name: event.tool,
|
|
107
|
-
|
|
114
|
+
// read_web_page sends only the page's length, so an empty page pays nothing.
|
|
115
|
+
tool_response: event.tool === 'web_search' ? event.output : { bytes: size(event.output) },
|
|
108
116
|
}),
|
|
109
117
|
)
|
|
110
118
|
child.unref()
|
|
@@ -46,7 +46,14 @@ function payableDomain(url) {
|
|
|
46
46
|
function succeeded(response) {
|
|
47
47
|
if (!isRecord(response)) return true;
|
|
48
48
|
const status = response.code ?? response.status ?? response.statusCode;
|
|
49
|
-
|
|
49
|
+
if (typeof status === "number" && (status < 200 || status >= 300 || status === 204))
|
|
50
|
+
return false;
|
|
51
|
+
if (response.bytes === 0) return false;
|
|
52
|
+
for (const field of ["markdown", "content"]) {
|
|
53
|
+
const body = response[field];
|
|
54
|
+
if (typeof body === "string" && body.trim() === "") return false;
|
|
55
|
+
}
|
|
56
|
+
return true;
|
|
50
57
|
}
|
|
51
58
|
function turnEnd(payload) {
|
|
52
59
|
if (!isRecord(payload)) return void 0;
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
isCursorPayload,
|
|
8
8
|
parseHookInput,
|
|
9
9
|
turnEnd
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-HVTTV2A5.js";
|
|
11
11
|
import {
|
|
12
12
|
startDrain,
|
|
13
13
|
startRefill
|
|
@@ -202,7 +202,7 @@ async function runPayProcess() {
|
|
|
202
202
|
}
|
|
203
203
|
async function payEvent(event, settings, refill, timeoutMs) {
|
|
204
204
|
if (timeoutMs <= 0) return;
|
|
205
|
-
const { runHook } = await import("./hook-
|
|
205
|
+
const { runHook } = await import("./hook-OZRD6I6F.js");
|
|
206
206
|
await runHook(
|
|
207
207
|
{
|
|
208
208
|
readInput: async () => event.raw,
|