@singularity-layer/cli 0.2.1 → 0.2.2

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/cli.js CHANGED
@@ -383,7 +383,33 @@ var HELP = `singularity processors \u2014 deploy loops we host and run
383
383
  --slug <slug> when not run from a processor directory
384
384
  --json machine-readable output, for scripts and agents
385
385
  --bundle bundle with esbuild: imports and npm packages
386
- --entry <file> bundle entry (default: the manifest's $code)`;
386
+ --entry <file> bundle entry (default: the manifest's $code)
387
+
388
+ Getting paid. Buyers pay YOU directly \u2014 we never hold the money and take no cut. By default that
389
+ is USDC on Solana at your signing wallet. To be paid on more than one chain, add a "payout" block
390
+ to processor.json:
391
+
392
+ "payout": {
393
+ "solana": "<base58 wallet>", USDC
394
+ "base": "0x\u2026", USDC
395
+ "robinhood": "0x\u2026" USDG on Robinhood Chain
396
+ }
397
+
398
+ One price_usd covers all three (every asset is 6-decimal), and buyers pick a chain from the 402.
399
+ Name only the chains you want: a chain you leave out is never offered. Check each address twice \u2014
400
+ a payment cannot be reversed.`;
401
+ var PAYOUT_CHAINS = ["solana", "base", "robinhood"];
402
+ function checkPayoutAddress(chain, value) {
403
+ if (typeof value !== "string" || !value.trim()) return "must be a non-empty string";
404
+ const addr = value.trim();
405
+ if (chain === "solana") {
406
+ if (!/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(addr)) return "must be a base58 Solana address";
407
+ return null;
408
+ }
409
+ if (!/^0x[0-9a-fA-F]{40}$/.test(addr)) return "must be a 0x-prefixed 20-byte hex address";
410
+ if (/^0x0{40}$/.test(addr)) return "the zero address cannot receive payment";
411
+ return null;
412
+ }
387
413
  var STARTER_MANIFEST = (slug) => ({
388
414
  $code: "processor.js",
389
415
  manifest_version: 1,
@@ -440,11 +466,31 @@ var readConfig = () => {
440
466
  function loadManifest(flags) {
441
467
  const p = resolve(String(flags.manifest || "processor.json"));
442
468
  if (!existsSync3(p)) die(`no manifest at ${p} \u2014 run \`singularity processors init\` first`);
469
+ let m;
443
470
  try {
444
- return JSON.parse(readFileSync3(p, "utf8"));
471
+ m = JSON.parse(readFileSync3(p, "utf8"));
445
472
  } catch {
446
473
  return die(`${p} is not valid JSON`);
447
474
  }
475
+ checkPayout(m);
476
+ return m;
477
+ }
478
+ function checkPayout(m) {
479
+ if (m.payout === void 0) return;
480
+ if (typeof m.payout !== "object" || m.payout === null || Array.isArray(m.payout)) {
481
+ die('payout must be an object keyed by chain, e.g. { "solana": "\u2026", "base": "0x\u2026" }');
482
+ }
483
+ const entries = Object.entries(m.payout);
484
+ if (entries.length === 0) {
485
+ die("payout names no chain \u2014 remove it entirely to be paid in USDC on Solana at your signing wallet");
486
+ }
487
+ for (const [chain, value] of entries) {
488
+ if (!PAYOUT_CHAINS.includes(chain)) {
489
+ die(`payout.${chain}: unknown chain \u2014 supported: ${PAYOUT_CHAINS.join(", ")}`);
490
+ }
491
+ const problem = checkPayoutAddress(chain, value);
492
+ if (problem) die(`payout.${chain}: ${problem}`);
493
+ }
448
494
  }
449
495
  var clean = (m) => Object.fromEntries(Object.entries(m).filter(([k]) => !k.startsWith("$")));
450
496
  function resolveSlug(flags) {
@@ -892,7 +938,15 @@ async function run(words, flags) {
892
938
  const slug = words[1] || requireSlug(flags);
893
939
  const res = await api(BASE, "GET", `/processors/${slug}/earnings`, { kp });
894
940
  if (emit(flags, res)) break;
895
- ok(`Sales $${usd(res.sales.total_micro)} (${res.sales.count} paid runs, sent to ${res.sales.paid_to})`);
941
+ const byChain = res.sales.paid_to_by_chain;
942
+ if (byChain && Object.keys(byChain).length > 1) {
943
+ ok(`Sales $${usd(res.sales.total_micro)} (${res.sales.count} paid runs)`);
944
+ for (const [chain, addr] of Object.entries(byChain)) {
945
+ ok(` ${chain.padEnd(10)} ${addr}`);
946
+ }
947
+ } else {
948
+ ok(`Sales $${usd(res.sales.total_micro)} (${res.sales.count} paid runs, sent to ${res.sales.paid_to})`);
949
+ }
896
950
  ok(`Compute $${usd(res.runtime.spent_micro)} spent from your credit balance`);
897
951
  if (res.runtime.held_open_micro > 0) {
898
952
  ok(`Held $${usd(res.runtime.held_open_micro)} reserved for runs still in flight`);
@@ -1001,7 +1055,7 @@ async function followLogs(base, slug, kp, limit) {
1001
1055
  }
1002
1056
 
1003
1057
  // src/version.ts
1004
- var VERSION = "0.2.1";
1058
+ var VERSION = "0.2.2";
1005
1059
 
1006
1060
  // src/cli.ts
1007
1061
  var COMMANDS = {
package/dist/index.js CHANGED
@@ -294,7 +294,7 @@ function coerce(raw, type) {
294
294
  }
295
295
 
296
296
  // src/version.ts
297
- var VERSION = "0.2.1";
297
+ var VERSION = "0.2.2";
298
298
  export {
299
299
  MAX_BUNDLE_BYTES,
300
300
  VERSION,
@@ -6,5 +6,26 @@
6
6
  * reduced one — and an agent can drive it identically.
7
7
  */
8
8
  import { type Flags } from './auth.js';
9
- export declare const HELP = "singularity processors \u2014 deploy loops we host and run\n\n init [slug] scaffold processor.json + processor.js here\n configure interactive setup: keypair, defaults\n deploy create it (prints the invoke token ONCE)\n update push new code or manifest\n run '{\"n\":10}' invoke and print the output\n run --get '{\"n\":10}' invoke over GET (for methods: [\"GET\"] processors)\n call -i invoke interactively, prompted per input field\n schema [slug] the input/output schema buyers and agents see\n list your processors\n search [query] the public catalogue\n logs [slug] recent runs and failure rate\n logs --follow stream new runs as they happen\n revenue sales and compute spend across everything you own\n earnings [slug] the same, for one processor\n env list | unset KEY which secrets are set; clear one\n secrets KEY=value ... set secret values (KEY= also clears)\n pause | resume stop or restart traffic, keeping the slug\n publish | unpublish list or unlist publicly (instant, no review)\n rotate new invoke token, the old one stops working\n delete --yes soft delete (the slug is never reusable)\n\n --keypair <path> defaults to ~/.config/solana/id.json\n --slug <slug> when not run from a processor directory\n --json machine-readable output, for scripts and agents\n --bundle bundle with esbuild: imports and npm packages\n --entry <file> bundle entry (default: the manifest's $code)";
9
+ export declare const HELP = "singularity processors \u2014 deploy loops we host and run\n\n init [slug] scaffold processor.json + processor.js here\n configure interactive setup: keypair, defaults\n deploy create it (prints the invoke token ONCE)\n update push new code or manifest\n run '{\"n\":10}' invoke and print the output\n run --get '{\"n\":10}' invoke over GET (for methods: [\"GET\"] processors)\n call -i invoke interactively, prompted per input field\n schema [slug] the input/output schema buyers and agents see\n list your processors\n search [query] the public catalogue\n logs [slug] recent runs and failure rate\n logs --follow stream new runs as they happen\n revenue sales and compute spend across everything you own\n earnings [slug] the same, for one processor\n env list | unset KEY which secrets are set; clear one\n secrets KEY=value ... set secret values (KEY= also clears)\n pause | resume stop or restart traffic, keeping the slug\n publish | unpublish list or unlist publicly (instant, no review)\n rotate new invoke token, the old one stops working\n delete --yes soft delete (the slug is never reusable)\n\n --keypair <path> defaults to ~/.config/solana/id.json\n --slug <slug> when not run from a processor directory\n --json machine-readable output, for scripts and agents\n --bundle bundle with esbuild: imports and npm packages\n --entry <file> bundle entry (default: the manifest's $code)\n\nGetting paid. Buyers pay YOU directly \u2014 we never hold the money and take no cut. By default that\nis USDC on Solana at your signing wallet. To be paid on more than one chain, add a \"payout\" block\nto processor.json:\n\n \"payout\": {\n \"solana\": \"<base58 wallet>\", USDC\n \"base\": \"0x\u2026\", USDC\n \"robinhood\": \"0x\u2026\" USDG on Robinhood Chain\n }\n\nOne price_usd covers all three (every asset is 6-decimal), and buyers pick a chain from the 402.\nName only the chains you want: a chain you leave out is never offered. Check each address twice \u2014\na payment cannot be reversed.";
10
+ /**
11
+ * The chains a buyer can pay on. USDC on Solana and Base, USDG on Robinhood Chain — all three are
12
+ * 6-decimal stablecoins, so ONE `price_usd` is the price everywhere with no conversion.
13
+ */
14
+ export type PayoutChain = 'solana' | 'base' | 'robinhood';
15
+ /**
16
+ * Check a payout address BEFORE it is deployed.
17
+ *
18
+ * SHAPE ONLY, and the limit is deliberate. The server validates these too, including the EIP-55
19
+ * checksum, and its check is the one that counts. This one exists because the CLI is where a human
20
+ * pastes an address, and catching "that is not a Solana address" without a round trip is worth a few
21
+ * lines. One wrong character sends every sale for the life of the processor somewhere nobody controls.
22
+ *
23
+ * EIP-55 IS NOT VERIFIED HERE, on purpose: it needs keccak256, and adding a hash implementation — or a
24
+ * dependency — to a CLI that people hand a Solana keypair to costs more than it saves. Deploy rejects a
25
+ * bad checksum and names the address it thinks you meant.
26
+ *
27
+ * NOTHING IS CASE-FOLDED. base58 is case-sensitive, so a lowercased Solana address is a DIFFERENT
28
+ * account that still looks valid; and an EVM address's case IS its checksum.
29
+ */
30
+ export declare function checkPayoutAddress(chain: PayoutChain, value: unknown): string | null;
10
31
  export declare function run(words: string[], flags: Flags): Promise<void>;
package/dist/version.d.ts CHANGED
@@ -8,4 +8,4 @@
8
8
  *
9
9
  * Kept in sync with package.json by the release workflow, which is the only thing that bumps either.
10
10
  */
11
- export declare const VERSION = "0.2.1";
11
+ export declare const VERSION = "0.2.2";
package/package.json CHANGED
@@ -1,78 +1,78 @@
1
1
  {
2
- "name": "@singularity-layer/cli",
3
- "version": "0.2.1",
4
- "description": "Singularity developer CLI \u2014 deploy paid endpoints (Processors) on the Singularity Cloud Network",
5
- "type": "module",
6
- "bin": {
7
- "singularity": "./dist/cli.js"
8
- },
9
- "main": "./dist/index.js",
10
- "types": "./dist/index.d.ts",
11
- "exports": {
12
- ".": {
13
- "types": "./dist/index.d.ts",
14
- "import": "./dist/index.js"
15
- }
16
- },
17
- "files": [
18
- "dist",
19
- "README.md",
20
- "LICENSE"
21
- ],
22
- "engines": {
23
- "node": ">=20"
24
- },
25
- "scripts": {
26
- "build": "node build.mjs",
27
- "test": "vitest run",
28
- "typecheck": "tsc --noEmit",
29
- "prepublishOnly": "npm run typecheck && npm test && npm run build"
30
- },
31
- "dependencies": {
32
- "esbuild": "^0.25.0",
33
- "tweetnacl": "^1.0.3"
34
- },
35
- "devDependencies": {
36
- "@types/node": "^22.0.0",
37
- "typescript": "^5.6.0",
38
- "vitest": "^2.1.9"
39
- },
40
- "keywords": [
41
- "singularity",
42
- "processors",
43
- "x402",
44
- "serverless",
45
- "agents",
46
- "solana",
47
- "mcp"
48
- ],
49
- "license": "MIT",
50
- "repository": {
51
- "type": "git",
52
- "url": "git+https://github.com/Singularity-Layer/singularity-cli.git"
53
- },
54
- "//": [
55
- "PACKAGE NAME vs COMMAND NAME are deliberately different. The bare `singularity` name on npm",
56
- "belongs to someone else, so the package is scoped \u2014 matching the rest of the family. The BIN",
57
- "is still `singularity`, so users type what they expect.",
58
- "",
59
- "esbuild is a RUNTIME dependency, not a build-time one: the CLI bundles the publisher's processor",
60
- "for them. That is what makes npm packages and multi-file TypeScript processors possible at all \u2014",
61
- "bundling happens on the publisher's machine, because running `npm install` on our infrastructure",
62
- "would mean executing arbitrary postinstall scripts on a box holding platform credentials.",
63
- "",
64
- "THIS REPO IS PUBLIC ON PURPOSE. People hand this CLI a Solana keypair, so the code that signs with",
65
- "it should be readable, and npm provenance \u2014 which attests the tarball was built from a named commit",
66
- "by the release workflow \u2014 is only available for public sources.",
67
- "",
68
- "This is the DEVELOPER CLI: one command, subcommands per product. It is deliberately NOT:",
69
- " \u2022 `sgl` \u2014 the Rust node-operator daemon. Different audience and runtime, and its",
70
- " releases are hash-allowlisted, so coupling would slow both.",
71
- " \u2022 `sglcode` \u2014 the agentic coding CLI, a product in its own right.",
72
- "The rule that stops sprawl: new capabilities become SUBCOMMANDS here, never new binaries."
73
- ],
74
- "homepage": "https://github.com/Singularity-Layer/singularity-cli#readme",
75
- "bugs": {
76
- "url": "https://github.com/Singularity-Layer/singularity-cli/issues"
2
+ "name": "@singularity-layer/cli",
3
+ "version": "0.2.2",
4
+ "description": "Singularity developer CLI \u2014 deploy paid endpoints (Processors) on the Singularity Cloud Network",
5
+ "type": "module",
6
+ "bin": {
7
+ "singularity": "./dist/cli.js"
8
+ },
9
+ "main": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js"
77
15
  }
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "README.md",
20
+ "LICENSE"
21
+ ],
22
+ "engines": {
23
+ "node": ">=20"
24
+ },
25
+ "scripts": {
26
+ "build": "node build.mjs",
27
+ "test": "vitest run",
28
+ "typecheck": "tsc --noEmit",
29
+ "prepublishOnly": "npm run typecheck && npm test && npm run build"
30
+ },
31
+ "dependencies": {
32
+ "esbuild": "^0.25.0",
33
+ "tweetnacl": "^1.0.3"
34
+ },
35
+ "devDependencies": {
36
+ "@types/node": "^22.0.0",
37
+ "typescript": "^5.6.0",
38
+ "vitest": "^2.1.9"
39
+ },
40
+ "keywords": [
41
+ "singularity",
42
+ "processors",
43
+ "x402",
44
+ "serverless",
45
+ "agents",
46
+ "solana",
47
+ "mcp"
48
+ ],
49
+ "license": "MIT",
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "git+https://github.com/Singularity-Layer/singularity-cli.git"
53
+ },
54
+ "//": [
55
+ "PACKAGE NAME vs COMMAND NAME are deliberately different. The bare `singularity` name on npm",
56
+ "belongs to someone else, so the package is scoped \u2014 matching the rest of the family. The BIN",
57
+ "is still `singularity`, so users type what they expect.",
58
+ "",
59
+ "esbuild is a RUNTIME dependency, not a build-time one: the CLI bundles the publisher's processor",
60
+ "for them. That is what makes npm packages and multi-file TypeScript processors possible at all \u2014",
61
+ "bundling happens on the publisher's machine, because running `npm install` on our infrastructure",
62
+ "would mean executing arbitrary postinstall scripts on a box holding platform credentials.",
63
+ "",
64
+ "THIS REPO IS PUBLIC ON PURPOSE. People hand this CLI a Solana keypair, so the code that signs with",
65
+ "it should be readable, and npm provenance \u2014 which attests the tarball was built from a named commit",
66
+ "by the release workflow \u2014 is only available for public sources.",
67
+ "",
68
+ "This is the DEVELOPER CLI: one command, subcommands per product. It is deliberately NOT:",
69
+ " \u2022 `sgl` \u2014 the Rust node-operator daemon. Different audience and runtime, and its",
70
+ " releases are hash-allowlisted, so coupling would slow both.",
71
+ " \u2022 `sglcode` \u2014 the agentic coding CLI, a product in its own right.",
72
+ "The rule that stops sprawl: new capabilities become SUBCOMMANDS here, never new binaries."
73
+ ],
74
+ "homepage": "https://github.com/Singularity-Layer/singularity-cli#readme",
75
+ "bugs": {
76
+ "url": "https://github.com/Singularity-Layer/singularity-cli/issues"
77
+ }
78
78
  }