@toon-protocol/rig 4.4.0 → 4.6.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.
@@ -6,7 +6,7 @@ import {
6
6
  renderIdentityLine,
7
7
  rigVersion,
8
8
  withForcedStandalone
9
- } from "./chunk-CTRP2UAQ.js";
9
+ } from "./chunk-X232W4TG.js";
10
10
  import {
11
11
  CI_MANUAL_TRIGGER_KIND,
12
12
  CI_SECRET_UPDATE_KIND,
@@ -19,6 +19,7 @@ import {
19
19
  buildCiWorkflowProgress,
20
20
  buildCiWorkflowResult,
21
21
  collectRepoObjects,
22
+ containsSecretValue,
22
23
  decryptSecretUpdate,
23
24
  discoverWorkflows,
24
25
  effectiveSecrets,
@@ -34,19 +35,22 @@ import {
34
35
  parseCiServiceControl,
35
36
  parseRepoAddress,
36
37
  parseWorkflow,
38
+ redactSecretValues,
37
39
  repoAddress,
38
40
  runGit,
39
41
  selectServiceRequests,
40
42
  validateSecretUpdate,
41
43
  writeGitObjects
42
- } from "./chunk-RL5XUWR4.js";
44
+ } from "./chunk-DCGV6ALH.js";
43
45
  import {
46
+ ARWEAVE_GATEWAYS,
44
47
  REPOSITORY_STATE_KIND,
45
48
  authorizedStatusAuthors,
46
49
  defaultWebSocketFactory,
47
50
  fetchRemoteState,
51
+ parseStateRefTags,
48
52
  queryRelay
49
- } from "./chunk-GWA3CSUR.js";
53
+ } from "./chunk-JBFBD7HV.js";
50
54
  import {
51
55
  ChannelMapStore,
52
56
  channelStatus,
@@ -881,6 +885,7 @@ async function saveSecrets(stateDir, secrets) {
881
885
  }
882
886
 
883
887
  // src/ci/coordinator.ts
888
+ var DEFAULT_CONCURRENCY = 1;
884
889
  var DEFAULT_RUN_TIMEOUT_MS = 30 * 60 * 1e3;
885
890
  var DEFAULT_ADVERTISEMENT_TTL = 30 * 60;
886
891
  var RENEW_FRACTION = 5 / 6;
@@ -908,19 +913,6 @@ function movedRefs(before, after) {
908
913
  }
909
914
  return moved;
910
915
  }
911
- function parseRefsTags(ev) {
912
- const refs = {};
913
- let head = null;
914
- for (const [name, v1, v2] of ev.tags) {
915
- if (name === "r" && v1 && v2) {
916
- if (v1 === "HEAD" && v2.startsWith("ref: ")) head = v2.slice(5);
917
- else refs[v1] = v2;
918
- } else if (name === "HEAD" && v1?.startsWith("ref: ")) {
919
- head = v1.slice(5);
920
- }
921
- }
922
- return { refs, head };
923
- }
924
916
  function tagValues(tags, name) {
925
917
  return tags.filter((t) => t[0] === name).map((t) => t[1] ?? "").filter((v) => v !== "");
926
918
  }
@@ -935,7 +927,7 @@ var Serial = class {
935
927
  async function startCoordinator(opts) {
936
928
  const me = opts.coordinatorPubkey.toLowerCase();
937
929
  const { publisher, relayUrl, runner } = opts;
938
- const concurrency = Math.max(1, opts.concurrency ?? 1);
930
+ const concurrency = Math.max(1, opts.concurrency ?? DEFAULT_CONCURRENCY);
939
931
  const timeoutMs = opts.timeoutMs ?? DEFAULT_RUN_TIMEOUT_MS;
940
932
  const clock = opts.clock ?? nowSeconds;
941
933
  const scheduler = opts.scheduler ?? realScheduler;
@@ -1257,7 +1249,7 @@ async function startCoordinator(opts) {
1257
1249
  ]);
1258
1250
  } catch (err) {
1259
1251
  log(
1260
- `[ci] ${label}: runner failed: ${err instanceof Error ? err.message : String(err)}`
1252
+ `[ci] ${label}: runner failed: ${redactSecretValues(err instanceof Error ? err.message : String(err), Object.values(run.secrets))}`
1261
1253
  );
1262
1254
  result = {
1263
1255
  conclusion: "startup_failure",
@@ -1274,11 +1266,13 @@ async function startCoordinator(opts) {
1274
1266
  if (timedOut) conclusion = "timed_out";
1275
1267
  else if (run.superseded || stopping && abort.signal.aborted)
1276
1268
  conclusion = "cancelled";
1269
+ const secretValues = Object.values(run.secrets);
1277
1270
  for (const job of result.jobs) {
1278
- const { tail, omitted } = logTail(job.log);
1271
+ const jobLog = redactSecretValues(job.log, secretValues);
1272
+ const { tail, omitted } = logTail(jobLog);
1279
1273
  const logReceipt = await serial.run(
1280
1274
  () => uploadBlob({
1281
- body: Buffer.from(job.log, "utf-8"),
1275
+ body: Buffer.from(jobLog, "utf-8"),
1282
1276
  contentType: "text/plain; charset=utf-8",
1283
1277
  repoId: repo.repoId
1284
1278
  })
@@ -1287,6 +1281,12 @@ async function startCoordinator(opts) {
1287
1281
  for (const artifact of job.artifacts) {
1288
1282
  try {
1289
1283
  const body = await readFile2(artifact.path);
1284
+ if (containsSecretValue(body, secretValues)) {
1285
+ log(
1286
+ `[ci] ${label}: artifact ${redactSecretValues(artifact.filename, secretValues)} not uploaded \u2014 it contains an injected secret`
1287
+ );
1288
+ continue;
1289
+ }
1290
1290
  const receipt = await serial.run(
1291
1291
  () => uploadBlob({
1292
1292
  body,
@@ -1301,7 +1301,7 @@ async function startCoordinator(opts) {
1301
1301
  });
1302
1302
  } catch (err) {
1303
1303
  log(
1304
- `[ci] ${label}: artifact ${artifact.filename} skipped: ${err instanceof Error ? err.message : String(err)}`
1304
+ `[ci] ${label}: artifact ${redactSecretValues(`${artifact.filename} skipped: ${err instanceof Error ? err.message : String(err)}`, secretValues)}`
1305
1305
  );
1306
1306
  }
1307
1307
  }
@@ -1616,8 +1616,9 @@ async function startCoordinator(opts) {
1616
1616
  const handleRepoState = async (repo, ev) => {
1617
1617
  const cursor = repo.cursor;
1618
1618
  if (repoSeen(repo, ev) || ev.created_at < cursor.lastCreatedAt) return;
1619
- const { refs, head } = parseRefsTags(ev);
1620
- if (head) repo.defaultBranch = head;
1619
+ const { refs: refMap, headSymref } = parseStateRefTags(ev.tags);
1620
+ const refs = Object.fromEntries(refMap);
1621
+ if (headSymref) repo.defaultBranch = headSymref;
1621
1622
  const moved = movedRefs(cursor.refs, refs);
1622
1623
  cursor.refs = refs;
1623
1624
  markRepoProcessed(repo, ev);
@@ -2009,10 +2010,14 @@ Options:
2009
2010
  or hex; NIP-C1 operator policy); repeatable \u2014 for
2010
2011
  running your own coordinator against a repo you do
2011
2012
  not maintain; such runs show as lower trust
2012
- --concurrency <n> runs executed at once (default 1); more queue
2013
- --timeout <seconds> wall-clock budget per run \u2192 timed_out (default 1800)
2014
- --gateway <url> gateway that serves the store's raw bytes, for log +
2015
- artifact links (default: ${PREFERRED_GATEWAY})
2013
+ --concurrency <n> runs executed at once (default ${DEFAULT_CONCURRENCY}); more queue
2014
+ --timeout <seconds> wall-clock budget per run \u2192 timed_out
2015
+ (default ${DEFAULT_RUN_TIMEOUT_MS / 1e3})
2016
+ --gateway <url> gateway that serves the store's raw bytes: where log +
2017
+ artifact links point, and the first place the
2018
+ coordinator reads objects from (<url>/raw/<txId>)
2019
+ before the shared gateway list (default:
2020
+ RIG_ARWEAVE_GATEWAY, else ${PREFERRED_GATEWAY})
2016
2021
  --act-bin <path> the act executable (default: RIG_ACT_BIN, else PATH)
2017
2022
  --platform <label=img> runs-on label \u2192 Docker image; repeatable
2018
2023
  (default: ubuntu-latest=${DEFAULT_ACT_PLATFORMS["ubuntu-latest"]})
@@ -2109,7 +2114,11 @@ function parseServeArgs(args) {
2109
2114
  throw new ServeUsageError(`${flag} expects a positive integer`);
2110
2115
  return n;
2111
2116
  };
2112
- const concurrency = positiveInt("--concurrency", values.concurrency, 1);
2117
+ const concurrency = positiveInt(
2118
+ "--concurrency",
2119
+ values.concurrency,
2120
+ DEFAULT_CONCURRENCY
2121
+ );
2113
2122
  const timeoutMs = positiveInt("--timeout", values.timeout, DEFAULT_RUN_TIMEOUT_MS / 1e3) * 1e3;
2114
2123
  let platforms;
2115
2124
  if (values.platform && values.platform.length > 0) {
@@ -2130,7 +2139,7 @@ function parseServeArgs(args) {
2130
2139
  requesters,
2131
2140
  concurrency,
2132
2141
  timeoutMs,
2133
- gateway: values.gateway ?? PREFERRED_GATEWAY,
2142
+ ...values.gateway !== void 0 ? { gateway: values.gateway } : {},
2134
2143
  ...values["act-bin"] !== void 0 ? { actBin: values["act-bin"] } : {},
2135
2144
  ...platforms ? { platforms } : {},
2136
2145
  ...values.workdir !== void 0 ? { workdir: values.workdir } : {},
@@ -2230,6 +2239,8 @@ async function runCiServe(args, deps) {
2230
2239
  io.err(CI_SERVE_USAGE);
2231
2240
  return 2;
2232
2241
  }
2242
+ const gateway = (flags.gateway ?? forced.env["RIG_ARWEAVE_GATEWAY"] ?? PREFERRED_GATEWAY).replace(/\/+$/, "");
2243
+ const readGateways = [`${gateway}/raw`, ...ARWEAVE_GATEWAYS];
2233
2244
  let runner;
2234
2245
  if (forced.runner) {
2235
2246
  runner = forced.runner;
@@ -2267,7 +2278,8 @@ async function runCiServe(args, deps) {
2267
2278
  coordinatorPubkey: coordinator,
2268
2279
  publisher: ctx.publisher,
2269
2280
  relayUrl: flags.relay,
2270
- gatewayUrl: flags.gateway,
2281
+ gatewayUrl: gateway,
2282
+ gateways: readGateways,
2271
2283
  repos: flags.repos,
2272
2284
  runner,
2273
2285
  stateDir,
@@ -2300,7 +2312,7 @@ async function runCiServe(args, deps) {
2300
2312
  coordinator,
2301
2313
  coordinatorNpub: npub,
2302
2314
  relay: flags.relay,
2303
- gateway: flags.gateway,
2315
+ gateway,
2304
2316
  repos: flags.repos,
2305
2317
  requesters: flags.requesters,
2306
2318
  runner: { family: runner.family, selectors: runner.selectors },
@@ -2357,4 +2369,4 @@ export {
2357
2369
  makeAffordabilityCheck,
2358
2370
  runCiServe
2359
2371
  };
2360
- //# sourceMappingURL=ci-serve-P4HOLAMP.js.map
2372
+ //# sourceMappingURL=ci-serve-AYFZOY4O.js.map