fluncle 0.243.0 → 0.245.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.
Files changed (2) hide show
  1. package/bin/fluncle.mjs +92 -11
  2. package/package.json +1 -1
package/bin/fluncle.mjs CHANGED
@@ -622,7 +622,7 @@ function parseVersion(version) {
622
622
  var currentVersion;
623
623
  var init_version = __esm(() => {
624
624
  init_output();
625
- currentVersion = "0.243.0".trim() ? "0.243.0".trim() : "0.1.0";
625
+ currentVersion = "0.245.0".trim() ? "0.245.0".trim() : "0.1.0";
626
626
  });
627
627
 
628
628
  // src/update-notifier.ts
@@ -2335,7 +2335,7 @@ function parseVersion2(version) {
2335
2335
  var currentVersion2, latestReleaseUrl = "https://api.github.com/repos/mauricekleine/fluncle/releases/latest";
2336
2336
  var init_version2 = __esm(() => {
2337
2337
  init_output();
2338
- currentVersion2 = "0.243.0".trim() ? "0.243.0".trim() : "0.1.0";
2338
+ currentVersion2 = "0.245.0".trim() ? "0.245.0".trim() : "0.1.0";
2339
2339
  });
2340
2340
 
2341
2341
  // ../../packages/registry/src/index.ts
@@ -11435,7 +11435,7 @@ var init_admin_bios = __esm(() => {
11435
11435
  });
11436
11436
 
11437
11437
  // ../../packages/contracts/src/orpc/admin-catalogue.ts
11438
- var CatalogueLensSchema, CapturePriorityReasonSchema, CatalogueMatchSchema, CatalogueTrackItemSchema, CatalogueSummarySchema, listCatalogueTracks, rankCatalogue, recordDemand, clearWrongAudio, requeueUnmatchedCaptures, requeueAnchor, requeueIsrcRecovery, flagWrongAudio, forceCapture, certifyTrack, setTrackDismissed, CaptureVerifyItemSchema, listUnverifiedCaptures, verifyCapture, CrawlPassSchema, CrawlPhaseInitializationSchema, MAX_CRAWL_PREPARE_LIMIT = 6, CrawlFetchPlanSchema, SuppliedCrawlBodySchema, MAX_CRAWL_COMMIT_BATCH, CRAWL_COMMIT_TOKEN_MAX_BYTES, CRAWL_COMMIT_BATCH_MAX_TOTAL_BYTES, CrawlCommitItemSchema, CrawlCommitReceiptSchema, CrawlPhaseCapabilitiesSchema, CrawlPhaseInputSchema, CrawlPhaseOutputSchema, CrawlStatusSchema, crawlCatalogue, commitCrawlNodes, getCrawlStatus, ANCHOR_CANDIDATE_LIMIT = 100, ANCHOR_ARTIST_LIMIT = 20, ANCHOR_TEXT_MAX = 300, ANCHOR_ISRC_MAX = 64, ANCHOR_ID_MAX = 64, ANCHOR_URL_MAX = 2048, AnchorCandidateSchema, anchorTrack, DEEZER_CANDIDATE_LIMIT = 5, DEEZER_TEXT_MAX = 300, DEEZER_ISRC_MAX = 64, DEEZER_TRACK_ID_MAX = 32, DeezerIsrcCandidateSchema, resolveAnchor, resolveAnchorReview, setAnchorSearch, setAnchorApify, CaptureBudgetStateSchema, getCaptureBudget, setCaptureBudget, SpotifyAnchorBreakerStateSchema, AnchorRungFlagsSchema, getSpotifyAnchorBreaker, resetSpotifyAnchorBreaker, AppleBreakerStateSchema, resetAppleBreaker, adminCatalogueContract;
11438
+ var CatalogueLensSchema, CapturePriorityReasonSchema, CatalogueMatchSchema, CatalogueTrackItemSchema, CatalogueSummarySchema, listCatalogueTracks, rankCatalogue, recordDemand, clearWrongAudio, requeueUnmatchedCaptures, requeueAnchor, requeueIsrcRecovery, flagWrongAudio, forceCapture, certifyTrack, setTrackDismissed, CaptureVerifyItemSchema, listUnverifiedCaptures, verifyCapture, CrawlPassSchema, CrawlPhaseInitializationSchema, MAX_CRAWL_PREPARE_LIMIT = 6, CrawlFetchPlanSchema, SuppliedCrawlBodySchema, MAX_CRAWL_COMMIT_BATCH, CRAWL_COMMIT_TOKEN_MAX_BYTES, CRAWL_COMMIT_BATCH_MAX_TOTAL_BYTES, CrawlCommitItemSchema, CrawlCommitReceiptSchema, CrawlPhaseCapabilitiesSchema, CrawlPhaseInputSchema, CrawlPhaseOutputSchema, CrawlStatusSchema, crawlCatalogue, commitCrawlNodes, getCrawlStatus, ANCHOR_CANDIDATE_LIMIT = 100, ANCHOR_ARTIST_LIMIT = 20, ANCHOR_TEXT_MAX = 300, ANCHOR_ISRC_MAX = 64, ANCHOR_ID_MAX = 64, ANCHOR_URL_MAX = 2048, AnchorCandidateSchema, anchorTrack, DEEZER_CANDIDATE_LIMIT = 5, DEEZER_TEXT_MAX = 300, DEEZER_ISRC_MAX = 64, DEEZER_TRACK_ID_MAX = 32, DeezerIsrcCandidateSchema, resolveAnchor, resolveAnchorReview, setAnchorSearch, setAnchorApify, CaptureBudgetStateSchema, getCaptureBudget, setCaptureBudget, AnchorApifyBudgetSchema, getAnchorApifyBudget, setAnchorApifyBudget, SpotifyAnchorBreakerStateSchema, AnchorRungFlagsSchema, getSpotifyAnchorBreaker, resetSpotifyAnchorBreaker, AppleBreakerStateSchema, resetAppleBreaker, adminCatalogueContract;
11439
11439
  var init_admin_catalogue = __esm(() => {
11440
11440
  init_dist3();
11441
11441
  init_zod();
@@ -11896,7 +11896,10 @@ var init_admin_catalogue = __esm(() => {
11896
11896
  trackId: string2().min(1)
11897
11897
  })).output(object({
11898
11898
  anchored: boolean2(),
11899
+ apifyBudgetRemaining: number2().int().nonnegative(),
11900
+ apifyEligible: boolean2(),
11899
11901
  apifyEnabled: boolean2(),
11902
+ apifyIneligibleReason: _enum(["apify_budget_spent", "awaiting_free_ask"]).nullable(),
11900
11903
  freeDurationMsOmitted: number2().int().nonnegative(),
11901
11904
  isrcRecoveredByDeezer: boolean2(),
11902
11905
  listenbrainzOutcome: _enum([
@@ -11978,6 +11981,27 @@ var init_admin_catalogue = __esm(() => {
11978
11981
  dailyTracks: number2().int().min(0).optional(),
11979
11982
  paused: boolean2().optional()
11980
11983
  })).output(CaptureBudgetStateSchema.extend({ ok: literal(true) }));
11984
+ AnchorApifyBudgetSchema = object({
11985
+ dailyRows: number2(),
11986
+ day: string2(),
11987
+ remainingRows: number2(),
11988
+ rowsSent: number2(),
11989
+ spent: boolean2()
11990
+ }).meta({ id: "AnchorApifyBudget" });
11991
+ getAnchorApifyBudget = oc.route({
11992
+ method: "GET",
11993
+ operationId: "getAnchorApifyBudget",
11994
+ path: "/admin/catalogue/anchor/apify-budget",
11995
+ summary: "The metered Apify anchor rung's daily row cap, today's spend, and what is left",
11996
+ tags: ["Admin"]
11997
+ }).input(object({})).output(AnchorApifyBudgetSchema.extend({ ok: literal(true) }));
11998
+ setAnchorApifyBudget = oc.route({
11999
+ method: "PUT",
12000
+ operationId: "setAnchorApifyBudget",
12001
+ path: "/admin/catalogue/anchor/apify-budget",
12002
+ summary: "Set the metered Apify anchor rung's daily row cap (operator)",
12003
+ tags: ["Admin"]
12004
+ }).input(object({ dailyRows: number2().int().min(0) })).output(AnchorApifyBudgetSchema.extend({ ok: literal(true) }));
11981
12005
  SpotifyAnchorBreakerStateSchema = object({
11982
12006
  cooldownRemainingMs: number2(),
11983
12007
  reason: string2().nullable(),
@@ -11986,6 +12010,7 @@ var init_admin_catalogue = __esm(() => {
11986
12010
  trippedAt: string2().nullable()
11987
12011
  }).meta({ id: "SpotifyAnchorBreakerState" });
11988
12012
  AnchorRungFlagsSchema = object({
12013
+ apifyBudget: AnchorApifyBudgetSchema,
11989
12014
  apifyEnabled: boolean2(),
11990
12015
  spotifySearchEnabled: boolean2()
11991
12016
  }).meta({ id: "AnchorRungFlags" });
@@ -12024,6 +12049,7 @@ var init_admin_catalogue = __esm(() => {
12024
12049
  crawl_catalogue: crawlCatalogue,
12025
12050
  flag_wrong_audio: flagWrongAudio,
12026
12051
  force_capture: forceCapture,
12052
+ get_anchor_apify_budget: getAnchorApifyBudget,
12027
12053
  get_capture_budget: getCaptureBudget,
12028
12054
  get_crawl_status: getCrawlStatus,
12029
12055
  get_spotify_anchor_breaker: getSpotifyAnchorBreaker,
@@ -12039,6 +12065,7 @@ var init_admin_catalogue = __esm(() => {
12039
12065
  resolve_anchor: resolveAnchor,
12040
12066
  resolve_anchor_review: resolveAnchorReview,
12041
12067
  set_anchor_apify: setAnchorApify,
12068
+ set_anchor_apify_budget: setAnchorApifyBudget,
12042
12069
  set_anchor_search: setAnchorSearch,
12043
12070
  set_capture_budget: setCaptureBudget,
12044
12071
  set_track_dismissed: setTrackDismissed,
@@ -12373,7 +12400,9 @@ var init_admin_projections = __esm(() => {
12373
12400
  artistQualification: ProjectionFamilyStatusSchema,
12374
12401
  crawlDueWork: ProjectionFamilyStatusSchema,
12375
12402
  publicAggregates: ProjectionFamilyStatusSchema.extend({ anchorsReady: boolean2() }),
12376
- trackDueWork: ProjectionFamilyStatusSchema
12403
+ trackDueWork: ProjectionFamilyStatusSchema.extend({
12404
+ catalogueRankMarkerAgeMs: CountSchema.nullable().optional()
12405
+ })
12377
12406
  }),
12378
12407
  readyToOpen: object({
12379
12408
  crawlDueWork: boolean2(),
@@ -16815,16 +16844,29 @@ async function getProjectionStatusCommand() {
16815
16844
  return adminApiGet("/api/v1/admin/projections/status");
16816
16845
  }
16817
16846
  async function advanceProjectionCommand(input) {
16818
- const { includeTerminalStatus = true, maxSteps = 1, target, ...body } = input;
16847
+ const {
16848
+ includeTerminalStatus = true,
16849
+ maxSteps = 1,
16850
+ now = () => Date.now(),
16851
+ target,
16852
+ wallMs,
16853
+ ...body
16854
+ } = input;
16819
16855
  if (!includeTerminalStatus && input.action !== "repair") {
16820
16856
  throw new Error("terminal status may be omitted only for repair automation");
16821
16857
  }
16822
16858
  const stepBody = maxSteps > 1 || !includeTerminalStatus ? { ...body, includeStatus: false } : body;
16859
+ const startedAt = now();
16823
16860
  let response = await adminApiPost(`/api/v1/admin/projections/${target}/advance`, stepBody);
16824
16861
  let steps = 1;
16825
16862
  let processed = response.processed;
16826
16863
  let scheduled = response.scheduled;
16864
+ let wallStopped = false;
16827
16865
  while (!response.complete && steps < maxSteps) {
16866
+ if (wallMs !== undefined && now() - startedAt >= wallMs) {
16867
+ wallStopped = true;
16868
+ break;
16869
+ }
16828
16870
  response = await adminApiPost(`/api/v1/admin/projections/${target}/advance`, stepBody);
16829
16871
  steps += 1;
16830
16872
  processed += response.processed;
@@ -16832,10 +16874,10 @@ async function advanceProjectionCommand(input) {
16832
16874
  }
16833
16875
  if (!includeTerminalStatus) {
16834
16876
  const { status: _status, ...withoutStatus } = response;
16835
- return { ...withoutStatus, processed, scheduled, steps };
16877
+ return { ...withoutStatus, processed, scheduled, steps, wallStopped };
16836
16878
  }
16837
16879
  const status = response.status ?? (await getProjectionStatusCommand()).status;
16838
- return { ...response, processed, scheduled, status, steps };
16880
+ return { ...response, processed, scheduled, status, steps, wallStopped };
16839
16881
  }
16840
16882
  async function setProjectionCutoverCommand(input) {
16841
16883
  const { enabled, target } = input;
@@ -16861,6 +16903,13 @@ function parseProjectionMaxSteps(value) {
16861
16903
  }
16862
16904
  return maxSteps;
16863
16905
  }
16906
+ function parseProjectionWallMs(value) {
16907
+ const wallMs = Number(value);
16908
+ if (!Number.isSafeInteger(wallMs) || wallMs < PROJECTION_WALL_MS_MIN || wallMs > PROJECTION_WALL_MS_MAX) {
16909
+ throw new Error(`--wall-ms must be a whole number of milliseconds from ${PROJECTION_WALL_MS_MIN} through ${PROJECTION_WALL_MS_MAX}`);
16910
+ }
16911
+ return wallMs;
16912
+ }
16864
16913
  function parseProjectionTarget(value) {
16865
16914
  if (value !== "artist_qualification" && value !== "crawl_due_work" && value !== "public_aggregates" && value !== "track_due_work") {
16866
16915
  throw new Error("--target must be artist_qualification, crawl_due_work, public_aggregates, or track_due_work");
@@ -16888,7 +16937,7 @@ function projectionStatusLines(status) {
16888
16937
  row("Artist qualification", status.projections.artistQualification, status.cutovers.publicProjections)
16889
16938
  ];
16890
16939
  }
16891
- var PROJECTION_MAX_STEPS = 100;
16940
+ var PROJECTION_MAX_STEPS = 100, PROJECTION_WALL_MS_MIN = 1000, PROJECTION_WALL_MS_MAX = 600000;
16892
16941
  var init_admin_projections2 = __esm(() => {
16893
16942
  init_orpc();
16894
16943
  init_api();
@@ -18742,6 +18791,12 @@ async function requeueAnchorCommand(trackIds) {
18742
18791
  async function requeueIsrcRecoveryCommand(input) {
18743
18792
  return adminApiPost("/api/v1/admin/catalogue/isrc-recovery/requeue", input);
18744
18793
  }
18794
+ async function anchorApifyBudgetCommand() {
18795
+ return adminApiGet("/api/v1/admin/catalogue/anchor/apify-budget");
18796
+ }
18797
+ async function setAnchorApifyBudgetCommand(dailyRows) {
18798
+ return adminApiPut("/api/v1/admin/catalogue/anchor/apify-budget", { dailyRows });
18799
+ }
18745
18800
  async function anchorBreakerCommand() {
18746
18801
  return adminApiGet("/api/v1/admin/catalogue/anchor/breaker");
18747
18802
  }
@@ -21711,7 +21766,7 @@ JSON field reference:
21711
21766
  console.log(projectionStatusLines(result.status).join(`
21712
21767
  `));
21713
21768
  });
21714
- adminProjections.command("advance").description("Run bounded, resumable rebuild, repair, or audit steps").requiredOption("--target <target>", "track_due_work, crawl_due_work, public_aggregates, or artist_qualification").requiredOption("--action <action>", "rebuild, repair, or audit").option("--limit <limit>", "Maximum rows or repairs in this request (1-500)", "100").option("--max-steps <steps>", "Maximum sequential advance calls (1-100)").option("--no-terminal-status", "Omit the terminal readiness snapshot (JSON repair automation only)").option("--json", "Print the aggregate result and default readiness as JSON", false).action(async (options) => {
21769
+ adminProjections.command("advance").description("Run bounded, resumable rebuild, repair, or audit steps").requiredOption("--target <target>", "track_due_work, crawl_due_work, public_aggregates, or artist_qualification").requiredOption("--action <action>", "rebuild, repair, or audit").option("--limit <limit>", "Maximum rows or repairs in this request (1-500)", "100").option("--max-steps <steps>", "Maximum sequential advance calls (1-100)").option("--wall-ms <ms>", "Stop issuing further steps once this many milliseconds have elapsed (1000-600000)").option("--no-terminal-status", "Omit the terminal readiness snapshot (JSON repair automation only)").option("--json", "Print the aggregate result and default readiness as JSON", false).action(async (options) => {
21715
21770
  const projections = await Promise.resolve().then(() => (init_admin_projections2(), {}));
21716
21771
  const action = parseProjectionAction(options.action);
21717
21772
  if (!options.terminalStatus && (!options.json || action !== "repair")) {
@@ -21722,13 +21777,14 @@ JSON field reference:
21722
21777
  includeTerminalStatus: options.terminalStatus,
21723
21778
  limit: parseProjectionLimit(options.limit),
21724
21779
  maxSteps: options.maxSteps === undefined ? undefined : parseProjectionMaxSteps(options.maxSteps),
21725
- target: parseProjectionTarget(options.target)
21780
+ target: parseProjectionTarget(options.target),
21781
+ wallMs: options.wallMs === undefined ? undefined : parseProjectionWallMs(options.wallMs)
21726
21782
  });
21727
21783
  if (options.json) {
21728
21784
  printJson(result);
21729
21785
  return;
21730
21786
  }
21731
- console.log(`${result.target} ${result.action}: steps ${result.steps}, processed ${result.processed}, scheduled ${result.scheduled}, ${result.complete ? "complete" : "more work remains"}.`);
21787
+ console.log(`${result.target} ${result.action}: steps ${result.steps}, processed ${result.processed}, scheduled ${result.scheduled}, ${result.complete ? "complete" : result.wallStopped ? "wall budget spent, more work remains" : "more work remains"}.`);
21732
21788
  });
21733
21789
  adminProjections.command("set").description("Open or close one readiness-gated projection cutover").requiredOption("--target <target>", "track_due_work, crawl_due_work, or public_projections").requiredOption("--enabled <boolean>", "true opens; false closes unconditionally").option("--json", "Print the stored flag and current readiness as JSON", false).action(async (options) => {
21734
21790
  const projections = await Promise.resolve().then(() => (init_admin_projections2(), {}));
@@ -22427,10 +22483,24 @@ JSON field reference:
22427
22483
  const minutes = Math.ceil(state.cooldownRemainingMs / 60000);
22428
22484
  console.log(state.tripped ? `BREAKER TRIPPED \u2014 ${state.reason ?? "unknown"}, ~${minutes}m left (${state.throttlesInWindow} throttle(s) in window)` : `BREAKER CLEAR \u2014 ${state.throttlesInWindow} throttle(s) in window`);
22429
22485
  console.log(`RUNGS \u2014 spotify search ${state.rungs.spotifySearchEnabled ? "ARMED" : "OFF"} \xB7 apify fallback ${state.rungs.apifyEnabled ? "ARMED" : "OFF"}`);
22486
+ const budget = state.rungs.apifyBudget;
22487
+ console.log(`APIFY BUDGET \u2014 ${budget.rowsSent}/${budget.dailyRows} rows today \xB7 ${budget.remainingRows} left${budget.spent ? " \xB7 SPENT" : ""}`);
22430
22488
  if (!state.rungs.spotifySearchEnabled && !state.rungs.apifyEnabled) {
22431
22489
  console.log("No rung can conclude \u2014 ListenBrainz still runs and can win, but its miss settles nothing.");
22432
22490
  }
22433
22491
  });
22492
+ const anchorApifyBudget = catalogue.command("anchor-apify-budget").description("The paid Apify anchor rung's daily row cap, today's spend, and what is left").option("--json", "Print JSON", false).action(async (options) => {
22493
+ await Promise.resolve().then(() => init_admin_catalogue2());
22494
+ printAnchorApifyBudget(await anchorApifyBudgetCommand(), options);
22495
+ });
22496
+ anchorApifyBudget.command("set").description("Set the paid Apify anchor rung's daily row cap (operator)").requiredOption("--rows <n>", "Max catalogue rows sent to the Apify actor per UTC day").option("--json", "Print JSON", false).action(async (options) => {
22497
+ const dailyRows = Number(options.rows);
22498
+ if (!Number.isInteger(dailyRows) || dailyRows < 0) {
22499
+ throw new Error("--rows must be a non-negative whole number of rows");
22500
+ }
22501
+ await Promise.resolve().then(() => init_admin_catalogue2());
22502
+ printAnchorApifyBudget(await setAnchorApifyBudgetCommand(dailyRows), options);
22503
+ });
22434
22504
  catalogue.command("requeue-isrc-recovery").description("Clear Deezer-empty ISRC-recovery stamps from a window (dry-run; --apply to take)").requiredOption("--since <iso>", "Inclusive lower bound on the stamp (2026-09-09)").option("--apply", "Actually clear the stamps (default is a dry-run count)", false).option("--json", "Print JSON", false).action(async (options) => {
22435
22505
  await Promise.resolve().then(() => init_admin_catalogue2());
22436
22506
  const result = await requeueIsrcRecoveryCommand({
@@ -24479,6 +24549,15 @@ async function runPublishAdvance(options, publishAdvanceCommand) {
24479
24549
  console.log(`Failed ${failure.platform} for ${failure.trackId} \u2014 left for the operator.`);
24480
24550
  }
24481
24551
  }
24552
+ function printAnchorApifyBudget(state, options) {
24553
+ if (options.json) {
24554
+ printJson({ ...state, ok: true });
24555
+ return;
24556
+ }
24557
+ console.log(state.spent ? `APIFY ROWS SPENT for ${state.day} \u2014 the paid anchor rung sends nothing more today.` : `APIFY ROWS OPEN for ${state.day} \u2014 the paid anchor rung may still be sent rows.`);
24558
+ console.log(` Today: ${state.rowsSent} of ${state.dailyRows} row(s)`);
24559
+ console.log(` Left: ${state.remainingRows} row(s)`);
24560
+ }
24482
24561
  var GB = 1073741824;
24483
24562
  function formatGb(bytes) {
24484
24563
  return `${(bytes / GB).toFixed(2)} GB`;
@@ -25731,6 +25810,7 @@ var stringOptions = new Set([
25731
25810
  "--reasoning",
25732
25811
  "--recorded-at",
25733
25812
  "--recording",
25813
+ "--rows",
25734
25814
  "--rules-file",
25735
25815
  "--render",
25736
25816
  "--scene",
@@ -25763,6 +25843,7 @@ var stringOptions = new Set([
25763
25843
  "--video-url",
25764
25844
  "--view",
25765
25845
  "--voice-id",
25846
+ "--wall-ms",
25766
25847
  "--window-since",
25767
25848
  "--window-until"
25768
25849
  ]);
package/package.json CHANGED
@@ -31,5 +31,5 @@
31
31
  "url": "git+https://github.com/mauricekleine/fluncle.git"
32
32
  },
33
33
  "type": "module",
34
- "version": "0.243.0"
34
+ "version": "0.245.0"
35
35
  }