fluncle 0.94.0 → 0.96.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 +121 -34
  2. package/package.json +1 -1
package/bin/fluncle.mjs CHANGED
@@ -556,7 +556,7 @@ function parseVersion(version) {
556
556
  var currentVersion;
557
557
  var init_version = __esm(() => {
558
558
  init_output();
559
- currentVersion = "0.94.0".trim() ? "0.94.0".trim() : "0.1.0";
559
+ currentVersion = "0.96.0".trim() ? "0.96.0".trim() : "0.1.0";
560
560
  });
561
561
 
562
562
  // src/update-notifier.ts
@@ -2186,7 +2186,7 @@ function parseVersion2(version) {
2186
2186
  var currentVersion2, latestReleaseUrl = "https://api.github.com/repos/mauricekleine/fluncle/releases/latest";
2187
2187
  var init_version2 = __esm(() => {
2188
2188
  init_output();
2189
- currentVersion2 = "0.94.0".trim() ? "0.94.0".trim() : "0.1.0";
2189
+ currentVersion2 = "0.96.0".trim() ? "0.96.0".trim() : "0.1.0";
2190
2190
  });
2191
2191
 
2192
2192
  // ../../packages/registry/src/index.ts
@@ -2789,6 +2789,17 @@ var init_src = __esm(() => {
2789
2789
  probeConfig: { cadenceMs: 10 * MINUTE_MS, cronName: "fluncle-social-capture", kind: "cron" },
2790
2790
  weights: { status: "hidden" }
2791
2791
  },
2792
+ {
2793
+ command: "fluncle admin clips drip-pause",
2794
+ exposedContent: [
2795
+ "post the due, cut clips to Instagram on a jittered ~daily cadence via Postiz (--no-agent, Worker HTTP)"
2796
+ ],
2797
+ kind: "cron",
2798
+ name: "cron.clip-drip",
2799
+ operatorNotes: "every 20m. Pure HTTP trigger, zero LLM tokens. Admin tier (needs the Worker's Postiz key, which the box never sees — the box only triggers; the `finalize_clip_cut` / `record_health` precedent). The Worker checks the global kill switch FIRST (paused → no-op), then posts due clips bounded by a per-tick cap AND a rolling-24h IG cap. Every clip auto-enters the schedule at a jittered ~23-25h after the queue tail. The operator pauses/resumes with `fluncle admin clips drip-pause` / `drip-resume`. Source: docs/agents/hermes/scripts/clip-drip-sweep.sh. Probed on /status as cron.clip-drip.",
2800
+ probeConfig: { cadenceMs: 20 * MINUTE_MS, cronName: "fluncle-clip-drip", kind: "cron" },
2801
+ weights: { status: "hidden" }
2802
+ },
2792
2803
  {
2793
2804
  command: "fluncle admin tracks queue",
2794
2805
  exposedContent: [
@@ -3153,7 +3164,7 @@ __export(exports_helm, {
3153
3164
  helmInstallCommand: () => helmInstallCommand,
3154
3165
  buildLaunchAgentPlist: () => buildLaunchAgentPlist
3155
3166
  });
3156
- import { existsSync, mkdirSync as mkdirSync2, openSync, rmSync as rmSync2, writeFileSync as writeFileSync2 } from "node:fs";
3167
+ import { existsSync, mkdirSync as mkdirSync2, openSync, rmSync as rmSync2, writeFileSync as writeFileSync2, readFileSync as readFileSync2 } from "node:fs";
3157
3168
  import { homedir as homedir4 } from "node:os";
3158
3169
  import { dirname as dirname3, join as join4, resolve } from "node:path";
3159
3170
  function launchAgentPlistPath() {
@@ -3162,15 +3173,8 @@ function launchAgentPlistPath() {
3162
3173
  function helmLogPath() {
3163
3174
  return join4(homedir4(), "Library/Logs/fluncle-helm.log");
3164
3175
  }
3165
- function resolveHelmDir() {
3166
- const fromEnv = process.env.FLUNCLE_HELM_DIR;
3167
- if (fromEnv) {
3168
- if (!existsSync(join4(fromEnv, "src/server.ts"))) {
3169
- throw new CliError2("helm_not_found", `FLUNCLE_HELM_DIR points at ${fromEnv}, but there's no helm there (src/server.ts missing).`);
3170
- }
3171
- return resolve(fromEnv);
3172
- }
3173
- let dir = import.meta.dir;
3176
+ function walkUpForHelm(start) {
3177
+ let dir = start;
3174
3178
  for (let depth = 0;depth < 8; depth++) {
3175
3179
  const candidate = join4(dir, "apps/helm");
3176
3180
  if (existsSync(join4(candidate, "src/server.ts"))) {
@@ -3182,7 +3186,35 @@ function resolveHelmDir() {
3182
3186
  }
3183
3187
  dir = parent;
3184
3188
  }
3185
- throw new CliError2("helm_not_found", "No helm aboard. Run this from the fluncle repo, or set FLUNCLE_HELM_DIR to the apps/helm checkout.");
3189
+ return null;
3190
+ }
3191
+ function persistHelmDir(dir) {
3192
+ try {
3193
+ mkdirSync2(dirname3(HELM_DIR_FILE), { recursive: true });
3194
+ writeFileSync2(HELM_DIR_FILE, `${dir}
3195
+ `, { mode: 384 });
3196
+ } catch {}
3197
+ }
3198
+ function resolveHelmDir() {
3199
+ const fromEnv = process.env.FLUNCLE_HELM_DIR;
3200
+ if (fromEnv) {
3201
+ if (!existsSync(join4(fromEnv, "src/server.ts"))) {
3202
+ throw new CliError2("helm_not_found", `FLUNCLE_HELM_DIR points at ${fromEnv}, but there's no helm there (src/server.ts missing).`);
3203
+ }
3204
+ return resolve(fromEnv);
3205
+ }
3206
+ const found = walkUpForHelm(process.cwd()) ?? walkUpForHelm(import.meta.dir);
3207
+ if (found) {
3208
+ persistHelmDir(found);
3209
+ return found;
3210
+ }
3211
+ try {
3212
+ const remembered = readFileSync2(HELM_DIR_FILE, "utf8").trim();
3213
+ if (remembered && existsSync(join4(remembered, "src/server.ts"))) {
3214
+ return remembered;
3215
+ }
3216
+ } catch {}
3217
+ throw new CliError2("helm_not_found", "No helm aboard. Run this once from the fluncle repo (the helm remembers the way after that), or set FLUNCLE_HELM_DIR.");
3186
3218
  }
3187
3219
  function resolveBun() {
3188
3220
  const bun = Bun.which("bun");
@@ -3355,11 +3387,12 @@ async function helmUninstallCommand() {
3355
3387
  }
3356
3388
  console.log("No LaunchAgent on file. Nothing stood down.");
3357
3389
  }
3358
- var HELM_PORT = 4190, HELM_URL, LAUNCH_AGENT_LABEL = "com.fluncle.helm";
3390
+ var HELM_PORT = 4190, HELM_URL, LAUNCH_AGENT_LABEL = "com.fluncle.helm", HELM_DIR_FILE;
3359
3391
  var init_helm = __esm(() => {
3360
3392
  init_open_external();
3361
3393
  init_output();
3362
3394
  HELM_URL = `http://127.0.0.1:${HELM_PORT}`;
3395
+ HELM_DIR_FILE = join4(homedir4(), ".config/fluncle/helm-dir");
3363
3396
  });
3364
3397
 
3365
3398
  // src/commands/add.ts
@@ -4081,7 +4114,7 @@ __export(exports_recordings, {
4081
4114
  recordingDeleteCommand: () => recordingDeleteCommand,
4082
4115
  recordingCreateCommand: () => recordingCreateCommand
4083
4116
  });
4084
- import { existsSync as existsSync3, readFileSync as readFileSync2 } from "node:fs";
4117
+ import { existsSync as existsSync3, readFileSync as readFileSync3 } from "node:fs";
4085
4118
  async function recordingGet(id) {
4086
4119
  const response = await adminApiGet(`/api/admin/recordings/${encodeURIComponent(id)}`);
4087
4120
  return response.recording;
@@ -4190,7 +4223,7 @@ async function recordingUpdateCommand(id, options = {}) {
4190
4223
  throw new CliError2("file_not_found", `Tracklist file not found: ${options.tracklistFile}`);
4191
4224
  }
4192
4225
  try {
4193
- body.tracklistJson = JSON.parse(readFileSync2(options.tracklistFile, "utf8"));
4226
+ body.tracklistJson = JSON.parse(readFileSync3(options.tracklistFile, "utf8"));
4194
4227
  } catch {
4195
4228
  throw new CliError2("invalid_tracklist", `Tracklist file is not valid JSON: ${options.tracklistFile}`);
4196
4229
  }
@@ -4240,7 +4273,7 @@ async function recordingReplaceCuesCommand(id, options = {}) {
4240
4273
  }
4241
4274
  let cues;
4242
4275
  try {
4243
- cues = JSON.parse(readFileSync2(options.cuesFile, "utf8"));
4276
+ cues = JSON.parse(readFileSync3(options.cuesFile, "utf8"));
4244
4277
  } catch {
4245
4278
  throw new CliError2("invalid_cues", `Cues file is not valid JSON: ${options.cuesFile}`);
4246
4279
  }
@@ -4262,7 +4295,10 @@ var exports_clips = {};
4262
4295
  __export(exports_clips, {
4263
4296
  setVideoUrl: () => setVideoUrl,
4264
4297
  clipsListCommand: () => clipsListCommand,
4298
+ clipScheduleCommand: () => clipScheduleCommand,
4299
+ clipPostsListCommand: () => clipPostsListCommand,
4265
4300
  clipFootageKey: () => clipFootageKey,
4301
+ clipDripPauseCommand: () => clipDripPauseCommand,
4266
4302
  clipCutFilterComplex: () => clipCutFilterComplex,
4267
4303
  clipCutFfmpegArgs: () => clipCutFfmpegArgs,
4268
4304
  clipCutCommand: () => clipCutCommand,
@@ -4339,6 +4375,20 @@ async function clipsListCommand(filter = {}) {
4339
4375
  const response = await adminApiGet(`/api/admin/clips${query ? `?${query}` : ""}`);
4340
4376
  return response.clips;
4341
4377
  }
4378
+ async function clipPostsListCommand() {
4379
+ const response = await adminApiGet("/api/admin/clips/social");
4380
+ return response.posts;
4381
+ }
4382
+ async function clipScheduleCommand(clipId, scheduledFor) {
4383
+ const response = await adminApiPatch(`/api/admin/clips/${encodeURIComponent(clipId)}/schedule`, { scheduledFor });
4384
+ return response.post;
4385
+ }
4386
+ async function clipDripPauseCommand(paused) {
4387
+ const response = await adminApiPut("/api/admin/clips/drip/state", {
4388
+ paused
4389
+ });
4390
+ return response.paused;
4391
+ }
4342
4392
  async function resolveClipSource(clip) {
4343
4393
  if (!clip.recordingId) {
4344
4394
  throw new CliError2("clip_unlinked", `Clip ${clip.id} is linked to no recording`);
@@ -4444,7 +4494,7 @@ __export(exports_recordings2, {
4444
4494
  recordingDeleteCommand: () => recordingDeleteCommand2,
4445
4495
  recordingCreateCommand: () => recordingCreateCommand2
4446
4496
  });
4447
- import { existsSync as existsSync4, readFileSync as readFileSync3 } from "node:fs";
4497
+ import { existsSync as existsSync4, readFileSync as readFileSync4 } from "node:fs";
4448
4498
  async function recordingGet2(id) {
4449
4499
  const response = await adminApiGet(`/api/admin/recordings/${encodeURIComponent(id)}`);
4450
4500
  return response.recording;
@@ -4553,7 +4603,7 @@ async function recordingUpdateCommand2(id, options = {}) {
4553
4603
  throw new CliError2("file_not_found", `Tracklist file not found: ${options.tracklistFile}`);
4554
4604
  }
4555
4605
  try {
4556
- body.tracklistJson = JSON.parse(readFileSync3(options.tracklistFile, "utf8"));
4606
+ body.tracklistJson = JSON.parse(readFileSync4(options.tracklistFile, "utf8"));
4557
4607
  } catch {
4558
4608
  throw new CliError2("invalid_tracklist", `Tracklist file is not valid JSON: ${options.tracklistFile}`);
4559
4609
  }
@@ -4603,7 +4653,7 @@ async function recordingReplaceCuesCommand2(id, options = {}) {
4603
4653
  }
4604
4654
  let cues;
4605
4655
  try {
4606
- cues = JSON.parse(readFileSync3(options.cuesFile, "utf8"));
4656
+ cues = JSON.parse(readFileSync4(options.cuesFile, "utf8"));
4607
4657
  } catch {
4608
4658
  throw new CliError2("invalid_cues", `Cues file is not valid JSON: ${options.cuesFile}`);
4609
4659
  }
@@ -4629,7 +4679,7 @@ __export(exports_newsletter, {
4629
4679
  newsletterDraftCommand: () => newsletterDraftCommand,
4630
4680
  newsletterDeleteCommand: () => newsletterDeleteCommand
4631
4681
  });
4632
- import { existsSync as existsSync5, readFileSync as readFileSync4 } from "node:fs";
4682
+ import { existsSync as existsSync5, readFileSync as readFileSync5 } from "node:fs";
4633
4683
  function buildBody2(options, { requireContent }) {
4634
4684
  const body = {};
4635
4685
  if (options.contentFile !== undefined) {
@@ -4652,7 +4702,7 @@ function readContentFile(filePath) {
4652
4702
  if (!existsSync5(filePath)) {
4653
4703
  throw new CliError2("file_not_found", `Content file not found: ${filePath}`);
4654
4704
  }
4655
- const text = readFileSync4(filePath, "utf-8");
4705
+ const text = readFileSync5(filePath, "utf-8");
4656
4706
  try {
4657
4707
  return JSON.parse(text);
4658
4708
  } catch (error) {
@@ -5287,7 +5337,7 @@ var init_format2 = __esm(() => {
5287
5337
  });
5288
5338
 
5289
5339
  // src/cli.ts
5290
- import { existsSync as existsSync6, readFileSync as readFileSync5 } from "fs";
5340
+ import { existsSync as existsSync6, readFileSync as readFileSync6 } from "fs";
5291
5341
  import path2 from "path";
5292
5342
 
5293
5343
  // ../../node_modules/commander/lib/error.js
@@ -7682,8 +7732,20 @@ function addAdminCommands(program2) {
7682
7732
  adminClips.outputHelp();
7683
7733
  });
7684
7734
  adminClips.command("list").description("List clips (filter by --status pending|done and/or --recording <id>)").option("--status <status>", "Filter by cut status (pending|done)").option("--recording <id>", "Filter by recording id").option("--json", "Print JSON", false).allowExcessArguments().action(async (options) => {
7685
- const { clipsListCommand: clipsListCommand2 } = await Promise.resolve().then(() => (init_clips(), exports_clips));
7686
- await runClipsList(options, clipsListCommand2);
7735
+ const { clipsListCommand: clipsListCommand2, clipPostsListCommand: clipPostsListCommand2 } = await Promise.resolve().then(() => (init_clips(), exports_clips));
7736
+ await runClipsList(options, clipsListCommand2, clipPostsListCommand2);
7737
+ });
7738
+ adminClips.command("schedule").description("Set or override a clip's Instagram drip slot (operator)").argument("[clipId]").requiredOption("--at <iso>", "The drip slot, an ISO-8601 timestamp").option("--json", "Print JSON", false).allowExcessArguments().action(async (clipId, options) => {
7739
+ const { clipScheduleCommand: clipScheduleCommand2 } = await Promise.resolve().then(() => (init_clips(), exports_clips));
7740
+ await runClipsSchedule(clipId, options, clipScheduleCommand2);
7741
+ });
7742
+ adminClips.command("drip-pause").description("Pause the whole Instagram drip-feed \u2014 the kill switch (operator)").option("--json", "Print JSON", false).allowExcessArguments().action(async (options) => {
7743
+ const { clipDripPauseCommand: clipDripPauseCommand2 } = await Promise.resolve().then(() => (init_clips(), exports_clips));
7744
+ await runClipsDripPause(true, options, clipDripPauseCommand2);
7745
+ });
7746
+ adminClips.command("drip-resume").description("Resume the Instagram drip-feed \u2014 clear the kill switch (operator)").option("--json", "Print JSON", false).allowExcessArguments().action(async (options) => {
7747
+ const { clipDripPauseCommand: clipDripPauseCommand2 } = await Promise.resolve().then(() => (init_clips(), exports_clips));
7748
+ await runClipsDripPause(false, options, clipDripPauseCommand2);
7687
7749
  });
7688
7750
  adminClips.command("cut").description("Cut one clip's framed 9:16 footage from its set rendition, then ship it").argument("[clipId]").option("--json", "Print JSON", false).allowExcessArguments().action(async (clipId, options) => {
7689
7751
  const { clipCutCommand: clipCutCommand2 } = await Promise.resolve().then(() => (init_clips(), exports_clips));
@@ -7824,7 +7886,7 @@ async function runTrackPreviewArchive(idOrLogId, options, previewArchiveUploadCo
7824
7886
  console.log(` mime: ${result.mime}`);
7825
7887
  }
7826
7888
  async function runTrackObserve(idOrLogId, options, trackObserveCommand2) {
7827
- const script = options.scriptFile ? readFileSync5(options.scriptFile, "utf8") : options.script;
7889
+ const script = options.scriptFile ? readFileSync6(options.scriptFile, "utf8") : options.script;
7828
7890
  if (!idOrLogId || !script || !script.trim()) {
7829
7891
  throw new Error("Usage: fluncle admin tracks observe <track_id|log_id> (--script <text> | --script-file <file>) [--voice-id <id>] [--duration-ms <ms>] [--context-note <text>] [--json]");
7830
7892
  }
@@ -7880,7 +7942,7 @@ async function runTrackContext(idOrLogId, options, trackContextCommand2) {
7880
7942
  }
7881
7943
  }
7882
7944
  async function runTrackNote(idOrLogId, options, trackNoteCommand2) {
7883
- const note = options.scriptFile ? readFileSync5(options.scriptFile, "utf8") : options.script;
7945
+ const note = options.scriptFile ? readFileSync6(options.scriptFile, "utf8") : options.script;
7884
7946
  if (!idOrLogId || !note || !note.trim()) {
7885
7947
  throw new Error("Usage: fluncle admin tracks note <track_id|log_id> (--script <text> | --script-file <file>) [--json]");
7886
7948
  }
@@ -8299,13 +8361,17 @@ async function runMixtapeList(options, mixtapeListCommand2) {
8299
8361
  console.log(`${coordinate3} ${status} ${mixtape.memberCount} bangers ${mixtape.title}`);
8300
8362
  }
8301
8363
  }
8302
- async function runClipsList(options, clipsListCommand2) {
8303
- const clips = await clipsListCommand2({
8304
- recordingId: options.recording,
8305
- status: options.status
8306
- });
8364
+ async function runClipsList(options, clipsListCommand2, clipPostsListCommand2) {
8365
+ const [clips, posts] = await Promise.all([
8366
+ clipsListCommand2({ recordingId: options.recording, status: options.status }),
8367
+ clipPostsListCommand2().catch(() => [])
8368
+ ]);
8369
+ const dripByClip = new Map(posts.map((post) => [post.clipId, post]));
8307
8370
  if (options.json) {
8308
- printJson({ clips, ok: true });
8371
+ printJson({
8372
+ clips: clips.map((clip) => ({ ...clip, drip: dripByClip.get(clip.id) })),
8373
+ ok: true
8374
+ });
8309
8375
  return;
8310
8376
  }
8311
8377
  if (clips.length === 0) {
@@ -8314,7 +8380,9 @@ async function runClipsList(options, clipsListCommand2) {
8314
8380
  }
8315
8381
  for (const clip of clips) {
8316
8382
  const source = clip.recordingId ?? "\u2014";
8317
- console.log(`${clip.id} ${clip.status} ${source} ${clip.inMs}-${clip.outMs}ms x=${clip.xOffset}`);
8383
+ const post = dripByClip.get(clip.id);
8384
+ const drip = post ? `${post.status} ${post.scheduledFor}` : "\u2014";
8385
+ console.log(`${clip.id} ${clip.status} ${source} ${clip.inMs}-${clip.outMs}ms x=${clip.xOffset} ${drip}`);
8318
8386
  }
8319
8387
  }
8320
8388
  async function runClipsCut(clipId, options, clipCutCommand2) {
@@ -8329,6 +8397,25 @@ async function runClipsCut(clipId, options, clipCutCommand2) {
8329
8397
  }
8330
8398
  console.log(`Cut ${result.clipId} \u2192 ${result.url} (${(result.sizeBytes / 1e6).toFixed(1)} MB).`);
8331
8399
  }
8400
+ async function runClipsSchedule(clipId, options, clipScheduleCommand2) {
8401
+ if (!clipId) {
8402
+ throw new Error("Missing clip id. Usage: fluncle admin clips schedule <clipId> --at <iso>");
8403
+ }
8404
+ const post = await clipScheduleCommand2(clipId, options.at);
8405
+ if (options.json) {
8406
+ printJson({ ok: true, post });
8407
+ return;
8408
+ }
8409
+ console.log(`Scheduled ${post.clipId} for ${post.scheduledFor}.`);
8410
+ }
8411
+ async function runClipsDripPause(paused, options, clipDripPauseCommand2) {
8412
+ const result = await clipDripPauseCommand2(paused);
8413
+ if (options.json) {
8414
+ printJson({ ok: true, paused: result });
8415
+ return;
8416
+ }
8417
+ console.log(result ? "The drip-feed is paused." : "The drip-feed is running.");
8418
+ }
8332
8419
  async function runMixtapeGet(idOrLogId, options, mixtapeGetCommand2) {
8333
8420
  if (!idOrLogId) {
8334
8421
  throw new Error("Missing mixtape id or log id. Usage: fluncle admin mixtapes get <id|logId>");
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.94.0"
34
+ "version": "0.96.0"
35
35
  }