@zeroxyz/cli 0.0.21 → 0.0.22
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/index.js +68 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command as Command9 } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@zeroxyz/cli",
|
|
9
|
-
version: "0.0.
|
|
9
|
+
version: "0.0.22",
|
|
10
10
|
type: "module",
|
|
11
11
|
bin: {
|
|
12
12
|
zero: "dist/index.js",
|
|
@@ -111,6 +111,44 @@ var configCommand = (_appContext) => new Command("config").description("View or
|
|
|
111
111
|
|
|
112
112
|
// src/commands/fetch-command.ts
|
|
113
113
|
import { Command as Command2 } from "commander";
|
|
114
|
+
|
|
115
|
+
// src/util/infer-schema.ts
|
|
116
|
+
var inferSchema = (value, depth = 0) => {
|
|
117
|
+
if (depth > 6) return { type: typeOf(value) };
|
|
118
|
+
if (value === null) return { type: "null" };
|
|
119
|
+
if (Array.isArray(value)) {
|
|
120
|
+
const itemSchemas = value.slice(0, 3).map((v) => inferSchema(v, depth + 1));
|
|
121
|
+
return {
|
|
122
|
+
type: "array",
|
|
123
|
+
items: itemSchemas[0] ?? { type: "unknown" }
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
if (typeof value === "object") {
|
|
127
|
+
const obj = value;
|
|
128
|
+
const properties = {};
|
|
129
|
+
const required = [];
|
|
130
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
131
|
+
properties[k] = inferSchema(v, depth + 1);
|
|
132
|
+
required.push(k);
|
|
133
|
+
}
|
|
134
|
+
return { type: "object", properties, required };
|
|
135
|
+
}
|
|
136
|
+
return { type: typeOf(value) };
|
|
137
|
+
};
|
|
138
|
+
var typeOf = (v) => {
|
|
139
|
+
if (v === null) return "null";
|
|
140
|
+
if (Array.isArray(v)) return "array";
|
|
141
|
+
return typeof v;
|
|
142
|
+
};
|
|
143
|
+
var tryParseJson = (text) => {
|
|
144
|
+
try {
|
|
145
|
+
return JSON.parse(text);
|
|
146
|
+
} catch {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
// src/commands/fetch-command.ts
|
|
114
152
|
var detectPaymentRequirement = (headers, status) => {
|
|
115
153
|
if (status !== 402) return null;
|
|
116
154
|
const x402Header = headers.get("payment-required") ?? headers.get("x-payment-required");
|
|
@@ -249,12 +287,28 @@ var fetchCommand = (appContext) => new Command2("fetch").description("Fetch a ca
|
|
|
249
287
|
);
|
|
250
288
|
}
|
|
251
289
|
if (capabilityId && apiService.walletAddress) {
|
|
290
|
+
let requestSchema;
|
|
291
|
+
let responseSchema;
|
|
292
|
+
if (options.data) {
|
|
293
|
+
const parsedReq = tryParseJson(options.data);
|
|
294
|
+
if (parsedReq !== null && typeof parsedReq === "object") {
|
|
295
|
+
requestSchema = inferSchema(parsedReq);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
if (body) {
|
|
299
|
+
const parsedResp = tryParseJson(body);
|
|
300
|
+
if (parsedResp !== null && typeof parsedResp === "object") {
|
|
301
|
+
responseSchema = inferSchema(parsedResp);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
252
304
|
try {
|
|
253
305
|
const runResult = await apiService.createRun({
|
|
254
306
|
capabilityId,
|
|
255
307
|
searchId,
|
|
256
308
|
status: finalResponse.status,
|
|
257
309
|
latencyMs,
|
|
310
|
+
requestSchema,
|
|
311
|
+
responseSchema,
|
|
258
312
|
...paymentMeta && {
|
|
259
313
|
costAmount: paymentMeta.amount,
|
|
260
314
|
costAsset: paymentMeta.asset,
|
|
@@ -810,7 +864,13 @@ Bulk review complete: ${ok} ok, ${failed} failed`);
|
|
|
810
864
|
process.exitCode = 1;
|
|
811
865
|
return;
|
|
812
866
|
}
|
|
813
|
-
|
|
867
|
+
const [only] = list.runs;
|
|
868
|
+
if (!only) {
|
|
869
|
+
console.error("No run found for capability");
|
|
870
|
+
process.exitCode = 1;
|
|
871
|
+
return;
|
|
872
|
+
}
|
|
873
|
+
runId = only.uid;
|
|
814
874
|
console.log(`Resolved to run ${runId}`);
|
|
815
875
|
}
|
|
816
876
|
const accuracy = requireRating("accuracy", options.accuracy);
|
|
@@ -1311,6 +1371,12 @@ var capabilityResponseSchema = z3.object({
|
|
|
1311
1371
|
stars: z3.string().nullable().optional(),
|
|
1312
1372
|
state: z3.enum(["unrated", "rated"]).optional()
|
|
1313
1373
|
}),
|
|
1374
|
+
priceObserved: z3.object({
|
|
1375
|
+
medianCents: z3.string(),
|
|
1376
|
+
p95Cents: z3.string(),
|
|
1377
|
+
sampleCount: z3.number(),
|
|
1378
|
+
varies: z3.boolean()
|
|
1379
|
+
}).nullable().optional(),
|
|
1314
1380
|
paymentMethods: z3.array(
|
|
1315
1381
|
z3.object({
|
|
1316
1382
|
uid: z3.string(),
|