@toon-protocol/rig 2.13.2 → 3.0.0

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/rig.js CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  setHeadSymref,
19
19
  updateRef,
20
20
  writeGitObjects
21
- } from "../chunk-EEUHZNWS.js";
21
+ } from "../chunk-FBIHO3RS.js";
22
22
  import {
23
23
  DEFAULT_KEYSTORE_PASSWORD,
24
24
  MinaZkAppStore,
@@ -33,15 +33,16 @@ import {
33
33
  } from "../chunk-FFQXFV4W.js";
34
34
  import {
35
35
  ChannelMapStore,
36
+ RIG_STANDALONE_ENV,
36
37
  channelStatus,
37
38
  defaultDaemonPort,
38
39
  resolveChannelPaths,
39
- resolveConflictingPath
40
- } from "../chunk-FQXNLPUR.js";
40
+ resolveConflictingPath,
41
+ standaloneForced
42
+ } from "../chunk-LCYCKWAT.js";
41
43
  import {
42
- MAX_OBJECT_SIZE,
43
- flooredUploadFee
44
- } from "../chunk-35ALWUDJ.js";
44
+ MAX_OBJECT_SIZE
45
+ } from "../chunk-B5ISARMU.js";
45
46
  import {
46
47
  minaPresetForChain
47
48
  } from "../chunk-ACTH6ISJ.js";
@@ -199,6 +200,18 @@ var DaemonGitClient = class {
199
200
  };
200
201
  async function resolvePaidSession(options) {
201
202
  const fetchImpl = options.fetchImpl ?? fetch;
203
+ if (standaloneForced(options.env)) {
204
+ options.warn(
205
+ "rig: paid path: standalone (RIG_STANDALONE set \u2014 toon-clientd bypassed)"
206
+ );
207
+ const ctx2 = await options.loadStandalone({
208
+ env: options.env,
209
+ cwd: options.cwd,
210
+ warn: options.warn,
211
+ ...options.relayUrl !== void 0 ? { relayUrl: options.relayUrl } : {}
212
+ });
213
+ return { path: "standalone", ctx: ctx2 };
214
+ }
202
215
  const probe = await (options.probeDaemon ?? probeDaemon)(
203
216
  options.env,
204
217
  fetchImpl
@@ -1070,6 +1083,9 @@ async function runRemote(args, deps) {
1070
1083
  }
1071
1084
 
1072
1085
  // src/cli/push.ts
1086
+ function withForcedStandalone(deps) {
1087
+ return { ...deps, env: { ...deps.env, [RIG_STANDALONE_ENV]: "1" } };
1088
+ }
1073
1089
  function loadPaidSession(deps, relayUrl) {
1074
1090
  return resolvePaidSession({
1075
1091
  env: deps.env,
@@ -1082,7 +1098,7 @@ function loadPaidSession(deps, relayUrl) {
1082
1098
  });
1083
1099
  }
1084
1100
  var defaultLoadStandalone = async (options) => {
1085
- const mod = await import("../standalone-mode-RG4PGALC.js");
1101
+ const mod = await import("../standalone-mode-X6W2RLTE.js");
1086
1102
  return mod.createStandaloneContext(options);
1087
1103
  };
1088
1104
  function identityReport(ctx) {
@@ -1130,6 +1146,9 @@ Options:
1130
1146
  as a fallback, with a migration nudge
1131
1147
  --repo-id <id> repository id / NIP-34 d-tag (default: git config
1132
1148
  toon.repoid \u2014 run \`rig init\` to set it)
1149
+ --standalone always run embedded, bypassing a running toon-clientd
1150
+ (alias: --no-daemon). Same as RIG_STANDALONE=1 \u2014 set that
1151
+ env var to make it the durable default
1133
1152
  -h, --help show this help`;
1134
1153
  function noSuchRefMessage(spec, head, refs, remoteName) {
1135
1154
  const branches = refs.filter((r) => r.refname.startsWith("refs/heads/")).map((r) => r.refname.slice("refs/heads/".length));
@@ -1198,6 +1217,8 @@ function parsePushArgs(args) {
1198
1217
  json: { type: "boolean", default: false },
1199
1218
  relay: { type: "string", multiple: true },
1200
1219
  "repo-id": { type: "string" },
1220
+ standalone: { type: "boolean", default: false },
1221
+ "no-daemon": { type: "boolean", default: false },
1201
1222
  help: { type: "boolean", short: "h", default: false }
1202
1223
  },
1203
1224
  allowPositionals: true
@@ -1210,6 +1231,7 @@ function parsePushArgs(args) {
1210
1231
  yes: values.yes ?? false,
1211
1232
  json: values.json ?? false,
1212
1233
  relay: values.relay ?? [],
1234
+ standalone: (values.standalone ?? false) || (values["no-daemon"] ?? false),
1213
1235
  help: values.help ?? false,
1214
1236
  positionals
1215
1237
  };
@@ -1233,7 +1255,10 @@ function planRigPointer(args) {
1233
1255
  entryJs: args.env[RIG_WEB_ENTRY_JS_ENV] ?? DEFAULT_RIG_WEB_BUNDLE.entryJs,
1234
1256
  entryCss: args.env[RIG_WEB_ENTRY_CSS_ENV] ?? DEFAULT_RIG_WEB_BUNDLE.entryCss
1235
1257
  },
1236
- gateway: (args.env[RIG_WEB_GATEWAY_ENV] ?? DEFAULT_RIG_WEB_GATEWAY).replace(/\/+$/, ""),
1258
+ gateway: (args.env[RIG_WEB_GATEWAY_ENV] ?? DEFAULT_RIG_WEB_GATEWAY).replace(
1259
+ /\/+$/,
1260
+ ""
1261
+ ),
1237
1262
  rigWebUrl: args.env[RIG_WEB_URL_ENV] ?? DEFAULT_RIG_WEB_URL,
1238
1263
  relay: args.relay,
1239
1264
  ownerNpub: hexToNpub(args.ownerPubkey),
@@ -1257,7 +1282,7 @@ function planRigPointer(args) {
1257
1282
  html,
1258
1283
  contentHash,
1259
1284
  bytes,
1260
- fee: flooredUploadFee(bytes, args.uploadFeePerByte, args.minUploadFee)
1285
+ fee: args.uploadFee
1261
1286
  };
1262
1287
  }
1263
1288
  async function runPush(args, deps) {
@@ -1274,6 +1299,7 @@ async function runPush(args, deps) {
1274
1299
  io2.out(PUSH_USAGE);
1275
1300
  return 0;
1276
1301
  }
1302
+ if (flags.standalone) deps = withForcedStandalone(deps);
1277
1303
  let standaloneCtx;
1278
1304
  try {
1279
1305
  const repoRoot = await resolveRepoRoot(deps.cwd);
@@ -1377,8 +1403,7 @@ async function runPush(args, deps) {
1377
1403
  ownerPubkey: ctx.ownerPubkey,
1378
1404
  repoId,
1379
1405
  relay: relaysUsed[0],
1380
- uploadFeePerByte: feeRates.uploadFeePerByte,
1381
- ...feeRates.minUploadFee !== void 0 ? { minUploadFee: feeRates.minUploadFee } : {}
1406
+ uploadFee: feeRates.uploadFee
1382
1407
  });
1383
1408
  }
1384
1409
  } else {
@@ -1556,7 +1581,10 @@ async function runPush(args, deps) {
1556
1581
  const result = await execute();
1557
1582
  let rigPage;
1558
1583
  if (!pointerPlan) {
1559
- rigPage = { status: "skipped", ...rigPageSkipDetail ? { detail: rigPageSkipDetail } : {} };
1584
+ rigPage = {
1585
+ status: "skipped",
1586
+ ...rigPageSkipDetail ? { detail: rigPageSkipDetail } : {}
1587
+ };
1560
1588
  } else if (pointerPlan.action === "unchanged") {
1561
1589
  rigPage = {
1562
1590
  status: "unchanged",
@@ -3425,6 +3453,8 @@ var COMMON_FLAGS_USAGE = ` --repo-id <id> repository id / NIP-34 d-tag (d
3425
3453
  --yes skip the fee confirmation (required when not a TTY)
3426
3454
  --json machine-readable receipt; without --yes it is a pure
3427
3455
  estimate (nothing published, exit 0)
3456
+ --standalone always run embedded, bypassing a running toon-clientd
3457
+ (alias: --no-daemon; same as RIG_STANDALONE=1)
3428
3458
  -h, --help show this help`;
3429
3459
  var ISSUE_USAGE = `Usage: rig issue create --title <title> [options]
3430
3460
 
@@ -3513,6 +3543,8 @@ var COMMON_OPTIONS = {
3513
3543
  remote: { type: "string" },
3514
3544
  "repo-id": { type: "string" },
3515
3545
  owner: { type: "string" },
3546
+ standalone: { type: "boolean", default: false },
3547
+ "no-daemon": { type: "boolean", default: false },
3516
3548
  help: { type: "boolean", short: "h", default: false }
3517
3549
  };
3518
3550
  function pickCommon(values) {
@@ -3520,6 +3552,7 @@ function pickCommon(values) {
3520
3552
  yes: values["yes"] === true,
3521
3553
  json: values["json"] === true,
3522
3554
  relay: Array.isArray(values["relay"]) ? values["relay"] : [],
3555
+ standalone: values["standalone"] === true || values["no-daemon"] === true,
3523
3556
  help: values["help"] === true
3524
3557
  };
3525
3558
  const remote = values["remote"];
@@ -3534,7 +3567,8 @@ function pickCommon(values) {
3534
3567
  return flags;
3535
3568
  }
3536
3569
  async function runEvent(opts) {
3537
- const { command, flags, deps, actionLabel } = opts;
3570
+ const { command, flags, actionLabel } = opts;
3571
+ const deps = flags.standalone ? withForcedStandalone(opts.deps) : opts.deps;
3538
3572
  const { io: io2 } = deps;
3539
3573
  let standaloneCtx;
3540
3574
  try {
@@ -7209,7 +7243,12 @@ async function runSitePublish(args, deps) {
7209
7243
  const repoId = flags.repoId ?? toonConfig.repoId;
7210
7244
  if (!repoId) throw new UnconfiguredRepoAddressError("repository id");
7211
7245
  const reader = new GitRepoReader(repoRoot);
7212
- const selected = await selectRefspecs(reader, flags.positionals, false, false);
7246
+ const selected = await selectRefspecs(
7247
+ reader,
7248
+ flags.positionals,
7249
+ false,
7250
+ false
7251
+ );
7213
7252
  if (selected.length !== 1) {
7214
7253
  throw new Error(
7215
7254
  `rig site publish builds ONE ref into a site \u2014 got ${selected.length} (${selected.join(", ")}); pass a single branch or tag`
@@ -7284,7 +7323,7 @@ async function runSitePublish(args, deps) {
7284
7323
  }
7285
7324
  }
7286
7325
  const feeRates = await ctx.publisher.getFeeRates();
7287
- const { uploadFeePerByte, minUploadFee } = feeRates;
7326
+ const { uploadFee } = feeRates;
7288
7327
  const previewEntries = blobs.map((b) => ({
7289
7328
  path: b.path,
7290
7329
  txId: known.get(b.sha) ?? PLACEHOLDER_TX
@@ -7300,16 +7339,9 @@ async function runSitePublish(args, deps) {
7300
7339
  if (flags.forceReupload) {
7301
7340
  const { objects } = await reader.statObjects(uniqueShas);
7302
7341
  reuploadBytes = objects.reduce((sum, o) => sum + o.size, 0);
7303
- reuploadFee = objects.reduce(
7304
- (sum, o) => sum + flooredUploadFee(o.size, uploadFeePerByte, minUploadFee),
7305
- 0n
7306
- );
7342
+ reuploadFee = BigInt(objects.length) * uploadFee;
7307
7343
  }
7308
- const manifestFee = flooredUploadFee(
7309
- manifestBytes,
7310
- uploadFeePerByte,
7311
- minUploadFee
7312
- );
7344
+ const manifestFee = uploadFee;
7313
7345
  const totalFee = manifestFee + reuploadFee;
7314
7346
  const gateway = flags.gateway ?? deps.env["RIG_ARWEAVE_GATEWAY"] ?? DEFAULT_GATEWAY;
7315
7347
  const baseJson = () => ({
@@ -7330,10 +7362,14 @@ async function runSitePublish(args, deps) {
7330
7362
  if (!flags.json) {
7331
7363
  io2.out(`Site publish plan for ${ref} (repo ${repoId}):`);
7332
7364
  io2.out(` files: ${blobs.length}`);
7333
- io2.out(` index: ${flags.index}${pathSet.has(flags.index) ? "" : " (missing!)"}`);
7365
+ io2.out(
7366
+ ` index: ${flags.index}${pathSet.has(flags.index) ? "" : " (missing!)"}`
7367
+ );
7334
7368
  if (fallbackPath) io2.out(` fallback: ${fallbackPath}`);
7335
7369
  if (flags.forceReupload) {
7336
- io2.out(` re-upload ${uniqueShas.length} blob(s), ${reuploadBytes} bytes (paid)`);
7370
+ io2.out(
7371
+ ` re-upload ${uniqueShas.length} blob(s), ${reuploadBytes} bytes (paid)`
7372
+ );
7337
7373
  }
7338
7374
  io2.out(` manifest: ${manifestBytes} bytes`);
7339
7375
  io2.out(` total fee: ${totalFee} base units`);
@@ -7452,7 +7488,12 @@ async function runSiteUrl(args, deps) {
7452
7488
  const repoId = flags.repoId ?? toonConfig.repoId;
7453
7489
  if (!repoId) throw new UnconfiguredRepoAddressError("repository id");
7454
7490
  const reader = new GitRepoReader(repoRoot);
7455
- const selected = await selectRefspecs(reader, flags.positionals, false, false);
7491
+ const selected = await selectRefspecs(
7492
+ reader,
7493
+ flags.positionals,
7494
+ false,
7495
+ false
7496
+ );
7456
7497
  if (selected.length !== 1) {
7457
7498
  throw new Error(
7458
7499
  `rig site url takes ONE ref \u2014 got ${selected.length} (${selected.join(", ")})`
@@ -7585,7 +7626,16 @@ goes to stderr), so \`rig <command> --json | jq\` always parses. --json is a
7585
7626
  per-subcommand flag on the commands rig owns, NOT a global rig flag: it does
7586
7627
  not apply to the git passthrough (\`rig status --json\` runs
7587
7628
  \`git status --json\`), and flags placed before the subcommand
7588
- (\`rig --json status\`) pass through to git untouched.`;
7629
+ (\`rig --json status\`) pass through to git untouched.
7630
+
7631
+ STANDALONE MODE: by default rig delegates paid commands to a running
7632
+ toon-clientd that holds the same identity (it owns the payment channel and its
7633
+ bootstrap is warm). To bypass the daemon and always sign for yourself, set
7634
+ RIG_STANDALONE=1 in your environment (the durable, applies-to-everything
7635
+ switch) or pass --standalone / --no-daemon to a paid command. rig then runs
7636
+ fully embedded; a per-identity lockfile still stops two rig processes from
7637
+ racing the channel. If a daemon is ALSO actively writing on this identity,
7638
+ stop it (its pid is in ~/.toon-client/daemon.pid) to avoid a claim race.`;
7589
7639
  function rigVersion() {
7590
7640
  const require2 = createRequire(import.meta.url);
7591
7641
  for (const rel of ["../package.json", "../../package.json", "../../../package.json"]) {