@gobing-ai/knowledge-kit 0.1.22 → 0.1.23
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/.claude-plugin/marketplace.json +1 -1
- package/dist/index.js +165 -91
- package/package.json +1 -1
- package/plugins/generations/gemini-tts/dist/index.js +47 -7
- package/plugins/generations/gemini-tts/src/gemini-client.ts +34 -6
- package/plugins/generations/music-gen/README.md +2 -2
- package/plugins/generations/music-gen/dist/index.js +46 -10
- package/plugins/generations/music-gen/presets/formats/song.yaml +6 -1
- package/plugins/generations/music-gen/presets/themes/synthwave.yaml +6 -1
- package/plugins/generations/music-gen/src/adapter/instance.ts +34 -11
- package/plugins/generations/music-gen/src/presets.ts +36 -3
- package/plugins/generations/omni-voice-gen/uv.toml +5 -0
- package/plugins/generations/vibe-voice-tts/README.md +64 -0
- package/plugins/generations/vibe-voice-tts/dist/index.js +14259 -0
- package/plugins/generations/vibe-voice-tts/package.json +16 -0
- package/plugins/generations/vibe-voice-tts/plugin.json +6 -0
- package/plugins/generations/vibe-voice-tts/profiles.json +10 -0
- package/plugins/generations/vibe-voice-tts/pyproject.toml +9 -0
- package/plugins/generations/vibe-voice-tts/python/worker.py +566 -0
- package/plugins/generations/vibe-voice-tts/src/index.ts +88 -0
- package/plugins/generations/vibe-voice-tts/src/vibevoice-client.ts +828 -0
- package/plugins/generations/vibe-voice-tts/tsconfig.json +8 -0
- package/plugins/generations/vibe-voice-tts/uv.lock +1767 -0
- package/plugins/generations/vibe-voice-tts/uv.toml +4 -0
- package/plugins/generations/voice-gen/dist/index.js +31 -1
- package/plugins/generations/voice-gen/src/voicebox-client.ts +50 -1
- package/plugins/generations/voxcpm-tts/dist/index.js +81 -9
- package/plugins/generations/voxcpm-tts/python/worker.py +9 -0
- package/plugins/generations/voxcpm-tts/src/index.ts +41 -0
- package/plugins/generations/voxcpm-tts/src/voxcpm-client.ts +32 -11
- package/plugins/generations/voxcpm-tts/uv.toml +5 -0
- package/plugins/kk/README.md +21 -0
- package/plugins/kk/decisions/kk-safety.yaml +5 -2
- package/plugins/kk/plugin.json +1 -1
- package/plugins/kk/schedules/kk-serve.launchd.plist.tmpl +12 -1
- package/plugins/kk/scripts/daily-stages.ts +274 -40
- package/plugins/kk/scripts/kk-workflow-stages.ts +74 -11
- package/plugins/kk/scripts/safety-artifact-check.ts +28 -5
- package/plugins/kk/workflows/kk-daily-ai-voice.yaml +4 -3
- package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +6 -5
- package/plugins/kk/workflows/kk-daily-safety.yaml +12 -10
- package/plugins/kk/workflows/kk-music.yaml +20 -16
- package/plugins/kk/workflows/kk-news-generate.yaml +23 -3
- package/plugins/kk/workflows/kk-publish.yaml +4 -1
- package/plugins/publishings/linkedin-pub/dist/index.js +51 -9
- package/plugins/publishings/linkedin-pub/dist/profile-check.js +5 -0
- package/plugins/publishings/linkedin-pub/src/index.ts +99 -12
- package/plugins/publishings/surfdash-pub/dist/index.js +8 -4
- package/plugins/publishings/surfdash-pub/src/index.ts +7 -1
- package/plugins/publishings/surfdash-pub/src/patch.ts +21 -3
- package/plugins/publishings/threads-pub/dist/index.js +47 -5
- package/plugins/publishings/threads-pub/dist/profile-check.js +7 -1
- package/plugins/publishings/threads-pub/src/post-rail.ts +101 -4
- package/plugins/publishings/wechatmp-pub/dist/index.js +94 -34
- package/plugins/publishings/wechatmp-pub/src/cgi-draft.ts +87 -53
- package/plugins/publishings/wechatmp-pub/src/enrich.ts +61 -3
- package/plugins/publishings/wechatmp-pub/src/flow.ts +28 -0
- package/plugins/publishings/x-pub/dist/index.js +84 -9
- package/plugins/publishings/x-pub/src/post-rail.ts +154 -12
|
@@ -12669,6 +12669,19 @@ async function auditVoiceSegments(script, segmentWavs, segmentMetadata, client)
|
|
|
12669
12669
|
}
|
|
12670
12670
|
|
|
12671
12671
|
// ../../plugins/generations/voice-gen/src/voicebox-client.ts
|
|
12672
|
+
init_dist();
|
|
12673
|
+
var GPU_BACKENDS = new Set(["gpu", "mps", "metal", "cuda"]);
|
|
12674
|
+
function detectCpuFallback(payload) {
|
|
12675
|
+
if (payload.gpu_available !== true)
|
|
12676
|
+
return;
|
|
12677
|
+
const variant = (payload.backend_variant ?? "").toLowerCase();
|
|
12678
|
+
if (!variant || GPU_BACKENDS.has(variant))
|
|
12679
|
+
return;
|
|
12680
|
+
return payload;
|
|
12681
|
+
}
|
|
12682
|
+
function requireGpu(env) {
|
|
12683
|
+
return ["1", "true", "yes"].includes((env.VOICEBOX_REQUIRE_GPU ?? "").toLowerCase());
|
|
12684
|
+
}
|
|
12672
12685
|
function resolveVoiceboxTimeoutMs() {
|
|
12673
12686
|
const raw = process.env.VOICEBOX_TIMEOUT_MS;
|
|
12674
12687
|
const parsed = raw ? Number.parseInt(raw, 10) : Number.NaN;
|
|
@@ -12683,8 +12696,9 @@ function createVoiceboxClient(options = {}) {
|
|
|
12683
12696
|
return {
|
|
12684
12697
|
url,
|
|
12685
12698
|
async health() {
|
|
12699
|
+
let res;
|
|
12686
12700
|
try {
|
|
12687
|
-
|
|
12701
|
+
res = await customFetch(`${url}/health`, { signal: AbortSignal.timeout(requestTimeoutMs) });
|
|
12688
12702
|
if (!res.ok) {
|
|
12689
12703
|
throw new Error(`HTTP ${res.status} ${res.statusText}`);
|
|
12690
12704
|
}
|
|
@@ -12692,6 +12706,21 @@ function createVoiceboxClient(options = {}) {
|
|
|
12692
12706
|
const reason = err instanceof Error ? err.message : String(err);
|
|
12693
12707
|
throw new Error(`Voicebox health check failed at ${url}: ${reason} \u2014 is Voicebox.app running with its REST server enabled? (restart the app or fix VOICEBOX_URL)`);
|
|
12694
12708
|
}
|
|
12709
|
+
let payload;
|
|
12710
|
+
try {
|
|
12711
|
+
payload = await res.json();
|
|
12712
|
+
} catch {
|
|
12713
|
+
payload = undefined;
|
|
12714
|
+
}
|
|
12715
|
+
const fallback = payload && detectCpuFallback(payload);
|
|
12716
|
+
if (fallback) {
|
|
12717
|
+
const detail = `backend_variant: "${fallback.backend_variant}", gpu_available: true, gpu_type: "${fallback.gpu_type ?? "unknown"}"`;
|
|
12718
|
+
const message = `Voicebox at ${url} is rendering on CPU (${detail}) \u2014 expect ~5.6x realtime degradation. Restart Voicebox.app while Metal is free, or set VOICEBOX_REQUIRE_GPU=0 to accept it.`;
|
|
12719
|
+
if (requireGpu(process.env)) {
|
|
12720
|
+
throw new Error(`voice-gen: ${message}`);
|
|
12721
|
+
}
|
|
12722
|
+
echoError(`voice-gen: warning: ${message}`);
|
|
12723
|
+
}
|
|
12695
12724
|
},
|
|
12696
12725
|
async resolveProfile(nameOrId) {
|
|
12697
12726
|
let res;
|
|
@@ -13545,6 +13574,7 @@ export {
|
|
|
13545
13574
|
computeExpectedDurationRange,
|
|
13546
13575
|
concatWavs,
|
|
13547
13576
|
createVoiceboxClient,
|
|
13577
|
+
detectCpuFallback,
|
|
13548
13578
|
detectLoudnessDip,
|
|
13549
13579
|
detectRepetitions,
|
|
13550
13580
|
isMp3Requested,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { echoError } from '@gobing-ai/ts-utils';
|
|
2
|
+
|
|
1
3
|
export interface EffectConfig {
|
|
2
4
|
type: string;
|
|
3
5
|
enabled?: boolean;
|
|
@@ -54,6 +56,35 @@ export interface VoiceboxClientOptions {
|
|
|
54
56
|
sleep?: (ms: number) => Promise<void>;
|
|
55
57
|
}
|
|
56
58
|
|
|
59
|
+
/** `/health` fields the CPU-fallback guard reads (observed live shape, 2026-11-20). */
|
|
60
|
+
export interface VoiceboxHealth {
|
|
61
|
+
status?: string;
|
|
62
|
+
gpu_available?: boolean;
|
|
63
|
+
gpu_type?: string;
|
|
64
|
+
backend_type?: string;
|
|
65
|
+
backend_variant?: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Backend variants that mean the GPU path is actually executing renders. */
|
|
69
|
+
const GPU_BACKENDS = new Set(['gpu', 'mps', 'metal', 'cuda']);
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Voicebox reports `gpu_available: true` while rendering on `backend_variant: "cpu"` (~5.6x RTF).
|
|
73
|
+
* Returns the payload when the GPU exists but is not used, so the degradation is surfaced instead of
|
|
74
|
+
* silently costing an hour per episode (0417 R2).
|
|
75
|
+
*/
|
|
76
|
+
export function detectCpuFallback(payload: VoiceboxHealth): VoiceboxHealth | undefined {
|
|
77
|
+
if (payload.gpu_available !== true) return undefined;
|
|
78
|
+
const variant = (payload.backend_variant ?? '').toLowerCase();
|
|
79
|
+
if (!variant || GPU_BACKENDS.has(variant)) return undefined;
|
|
80
|
+
return payload;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** `VOICEBOX_REQUIRE_GPU` turns the CPU-fallback warning into a hard failure. */
|
|
84
|
+
function requireGpu(env: Record<string, string | undefined>): boolean {
|
|
85
|
+
return ['1', 'true', 'yes'].includes((env.VOICEBOX_REQUIRE_GPU ?? '').toLowerCase());
|
|
86
|
+
}
|
|
87
|
+
|
|
57
88
|
/**
|
|
58
89
|
* Creates a client for the Voicebox local REST API.
|
|
59
90
|
*/
|
|
@@ -79,8 +110,9 @@ export function createVoiceboxClient(options: VoiceboxClientOptions = {}): Voice
|
|
|
79
110
|
url,
|
|
80
111
|
|
|
81
112
|
async health(): Promise<void> {
|
|
113
|
+
let res: Response;
|
|
82
114
|
try {
|
|
83
|
-
|
|
115
|
+
res = await customFetch(`${url}/health`, { signal: AbortSignal.timeout(requestTimeoutMs) });
|
|
84
116
|
if (!res.ok) {
|
|
85
117
|
throw new Error(`HTTP ${res.status} ${res.statusText}`);
|
|
86
118
|
}
|
|
@@ -90,6 +122,23 @@ export function createVoiceboxClient(options: VoiceboxClientOptions = {}): Voice
|
|
|
90
122
|
`Voicebox health check failed at ${url}: ${reason} — is Voicebox.app running with its REST server enabled? (restart the app or fix VOICEBOX_URL)`,
|
|
91
123
|
);
|
|
92
124
|
}
|
|
125
|
+
// body read is best-effort: an older/partial /health must not fail the run (its JSON shape
|
|
126
|
+
// is not part of the client contract), only the CPU-fallback signal matters here.
|
|
127
|
+
let payload: VoiceboxHealth | undefined;
|
|
128
|
+
try {
|
|
129
|
+
payload = (await res.json()) as VoiceboxHealth;
|
|
130
|
+
} catch {
|
|
131
|
+
payload = undefined;
|
|
132
|
+
}
|
|
133
|
+
const fallback = payload && detectCpuFallback(payload);
|
|
134
|
+
if (fallback) {
|
|
135
|
+
const detail = `backend_variant: "${fallback.backend_variant}", gpu_available: true, gpu_type: "${fallback.gpu_type ?? 'unknown'}"`;
|
|
136
|
+
const message = `Voicebox at ${url} is rendering on CPU (${detail}) — expect ~5.6x realtime degradation. Restart Voicebox.app while Metal is free, or set VOICEBOX_REQUIRE_GPU=0 to accept it.`;
|
|
137
|
+
if (requireGpu(process.env)) {
|
|
138
|
+
throw new Error(`voice-gen: ${message}`);
|
|
139
|
+
}
|
|
140
|
+
echoError(`voice-gen: warning: ${message}`);
|
|
141
|
+
}
|
|
93
142
|
},
|
|
94
143
|
|
|
95
144
|
async resolveProfile(nameOrId: string): Promise<VoiceboxProfile> {
|
|
@@ -12672,6 +12672,19 @@ async function auditVoiceSegments(script, segmentWavs, segmentMetadata, client)
|
|
|
12672
12672
|
}
|
|
12673
12673
|
|
|
12674
12674
|
// ../../plugins/generations/voice-gen/src/voicebox-client.ts
|
|
12675
|
+
init_dist();
|
|
12676
|
+
var GPU_BACKENDS = new Set(["gpu", "mps", "metal", "cuda"]);
|
|
12677
|
+
function detectCpuFallback(payload) {
|
|
12678
|
+
if (payload.gpu_available !== true)
|
|
12679
|
+
return;
|
|
12680
|
+
const variant = (payload.backend_variant ?? "").toLowerCase();
|
|
12681
|
+
if (!variant || GPU_BACKENDS.has(variant))
|
|
12682
|
+
return;
|
|
12683
|
+
return payload;
|
|
12684
|
+
}
|
|
12685
|
+
function requireGpu(env) {
|
|
12686
|
+
return ["1", "true", "yes"].includes((env.VOICEBOX_REQUIRE_GPU ?? "").toLowerCase());
|
|
12687
|
+
}
|
|
12675
12688
|
function resolveVoiceboxTimeoutMs() {
|
|
12676
12689
|
const raw = process.env.VOICEBOX_TIMEOUT_MS;
|
|
12677
12690
|
const parsed = raw ? Number.parseInt(raw, 10) : Number.NaN;
|
|
@@ -12686,8 +12699,9 @@ function createVoiceboxClient(options = {}) {
|
|
|
12686
12699
|
return {
|
|
12687
12700
|
url,
|
|
12688
12701
|
async health() {
|
|
12702
|
+
let res;
|
|
12689
12703
|
try {
|
|
12690
|
-
|
|
12704
|
+
res = await customFetch(`${url}/health`, { signal: AbortSignal.timeout(requestTimeoutMs) });
|
|
12691
12705
|
if (!res.ok) {
|
|
12692
12706
|
throw new Error(`HTTP ${res.status} ${res.statusText}`);
|
|
12693
12707
|
}
|
|
@@ -12695,6 +12709,21 @@ function createVoiceboxClient(options = {}) {
|
|
|
12695
12709
|
const reason = err instanceof Error ? err.message : String(err);
|
|
12696
12710
|
throw new Error(`Voicebox health check failed at ${url}: ${reason} \u2014 is Voicebox.app running with its REST server enabled? (restart the app or fix VOICEBOX_URL)`);
|
|
12697
12711
|
}
|
|
12712
|
+
let payload;
|
|
12713
|
+
try {
|
|
12714
|
+
payload = await res.json();
|
|
12715
|
+
} catch {
|
|
12716
|
+
payload = undefined;
|
|
12717
|
+
}
|
|
12718
|
+
const fallback = payload && detectCpuFallback(payload);
|
|
12719
|
+
if (fallback) {
|
|
12720
|
+
const detail = `backend_variant: "${fallback.backend_variant}", gpu_available: true, gpu_type: "${fallback.gpu_type ?? "unknown"}"`;
|
|
12721
|
+
const message = `Voicebox at ${url} is rendering on CPU (${detail}) \u2014 expect ~5.6x realtime degradation. Restart Voicebox.app while Metal is free, or set VOICEBOX_REQUIRE_GPU=0 to accept it.`;
|
|
12722
|
+
if (requireGpu(process.env)) {
|
|
12723
|
+
throw new Error(`voice-gen: ${message}`);
|
|
12724
|
+
}
|
|
12725
|
+
echoError(`voice-gen: warning: ${message}`);
|
|
12726
|
+
}
|
|
12698
12727
|
},
|
|
12699
12728
|
async resolveProfile(nameOrId) {
|
|
12700
12729
|
let res;
|
|
@@ -13695,6 +13724,8 @@ function createVoxCpmClient(options = {}) {
|
|
|
13695
13724
|
let fatal;
|
|
13696
13725
|
let closed = false;
|
|
13697
13726
|
let stderrTail = "";
|
|
13727
|
+
let stderrDone = Promise.resolve();
|
|
13728
|
+
let exitDetails;
|
|
13698
13729
|
let stdoutBuffer = "";
|
|
13699
13730
|
let renderInFlight;
|
|
13700
13731
|
let warnedChunk = false;
|
|
@@ -13785,22 +13816,35 @@ function createVoxCpmClient(options = {}) {
|
|
|
13785
13816
|
child = proc;
|
|
13786
13817
|
proc.on("error", (err) => fail(new Error(`voxcpm-tts: worker process error: ${err.message}`)));
|
|
13787
13818
|
proc.on("exit", (code, signal) => {
|
|
13819
|
+
exitDetails = { code, signal };
|
|
13788
13820
|
if (!closed && !fatal) {
|
|
13789
|
-
|
|
13821
|
+
Promise.race([stderrDone, new Promise((r) => setTimeout(r, 150))]).then(() => {
|
|
13822
|
+
if (!closed && !fatal) {
|
|
13823
|
+
fail(new Error(`voxcpm-tts: worker exited unexpectedly (code ${code ?? "null"}, signal ${signal ?? "none"})${stderrTail ? `: ${stderrTail.slice(-400)}` : ""}`));
|
|
13824
|
+
}
|
|
13825
|
+
});
|
|
13790
13826
|
}
|
|
13791
13827
|
});
|
|
13828
|
+
if (proc.stderr) {
|
|
13829
|
+
stderrDone = pump(proc.stderr, (text) => {
|
|
13830
|
+
stderrTail = (stderrTail + text).slice(-STDERR_MAX_CHARS);
|
|
13831
|
+
});
|
|
13832
|
+
}
|
|
13792
13833
|
if (proc.stdout) {
|
|
13793
13834
|
pump(proc.stdout, consumeStdout, () => {
|
|
13794
13835
|
if (!fatal && !closed) {
|
|
13795
|
-
|
|
13836
|
+
Promise.race([
|
|
13837
|
+
Promise.all([waitForExit(proc, 250), stderrDone]),
|
|
13838
|
+
new Promise((r) => setTimeout(r, 250))
|
|
13839
|
+
]).then(() => {
|
|
13840
|
+
if (!fatal && !closed) {
|
|
13841
|
+
const detail = exitDetails ? ` (code ${exitDetails.code ?? "null"}, signal ${exitDetails.signal ?? "none"})` : " before settling all requests";
|
|
13842
|
+
fail(new Error(`voxcpm-tts: worker closed stdout${detail}${stderrTail ? `: ${stderrTail.slice(-400)}` : ""}`));
|
|
13843
|
+
}
|
|
13844
|
+
});
|
|
13796
13845
|
}
|
|
13797
13846
|
});
|
|
13798
13847
|
}
|
|
13799
|
-
if (proc.stderr) {
|
|
13800
|
-
pump(proc.stderr, (text) => {
|
|
13801
|
-
stderrTail = (stderrTail + text).slice(-STDERR_MAX_CHARS);
|
|
13802
|
-
});
|
|
13803
|
-
}
|
|
13804
13848
|
for (const signal of SIGNAL_HANDLERS) {
|
|
13805
13849
|
const handler = () => {
|
|
13806
13850
|
close();
|
|
@@ -14136,9 +14180,37 @@ async function main2(argv = process.argv.slice(2), options = {}) {
|
|
|
14136
14180
|
args: argv,
|
|
14137
14181
|
options: {
|
|
14138
14182
|
in: { type: "string" },
|
|
14139
|
-
out: { type: "string" }
|
|
14183
|
+
out: { type: "string" },
|
|
14184
|
+
batch: { type: "string" }
|
|
14140
14185
|
}
|
|
14141
14186
|
});
|
|
14187
|
+
const env = options.env ?? process.env;
|
|
14188
|
+
const batchPath = values.batch ?? env.VOXCPM_BATCH_MANIFEST;
|
|
14189
|
+
if (batchPath) {
|
|
14190
|
+
let entries;
|
|
14191
|
+
try {
|
|
14192
|
+
const parsed = JSON.parse(await Bun.file(batchPath).text());
|
|
14193
|
+
if (!Array.isArray(parsed) || parsed.some((e) => !e || typeof e !== "object" || typeof e.in !== "string" || typeof e.out !== "string")) {
|
|
14194
|
+
throw new Error("batch manifest must be an array of { in, out } string pairs");
|
|
14195
|
+
}
|
|
14196
|
+
entries = parsed;
|
|
14197
|
+
} catch (err) {
|
|
14198
|
+
echoError(`voxcpm-tts failed: invalid batch manifest: ${err instanceof Error ? err.message : String(err)}`);
|
|
14199
|
+
return 1;
|
|
14200
|
+
}
|
|
14201
|
+
const handle = createVoxCpmClient(options);
|
|
14202
|
+
try {
|
|
14203
|
+
for (const entry of entries) {
|
|
14204
|
+
await processGeneratorIO(entry.in, entry.out, handle.client, undefined, VOXCPM_TTS_GENERATOR);
|
|
14205
|
+
}
|
|
14206
|
+
return 0;
|
|
14207
|
+
} catch (err) {
|
|
14208
|
+
echoError(`voxcpm-tts failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
14209
|
+
return 1;
|
|
14210
|
+
} finally {
|
|
14211
|
+
await handle.close();
|
|
14212
|
+
}
|
|
14213
|
+
}
|
|
14142
14214
|
if (!values.in || !values.out) {
|
|
14143
14215
|
echoError("voxcpm-tts failed: Missing required arguments: --in and --out");
|
|
14144
14216
|
return 1;
|
|
@@ -183,6 +183,15 @@ def load_backend(environ: dict[str, str]) -> dict:
|
|
|
183
183
|
if device not in ("auto", "cpu", "cuda", "mps"):
|
|
184
184
|
raise WorkerError(f"unsupported VOXCPM_DEVICE {device!r} (allowed: auto, cpu, cuda, mps)")
|
|
185
185
|
|
|
186
|
+
if device == "mps":
|
|
187
|
+
with contextlib.redirect_stdout(sys.stderr):
|
|
188
|
+
import torch # type: ignore
|
|
189
|
+
|
|
190
|
+
if not torch.backends.mps.is_available():
|
|
191
|
+
raise WorkerError(
|
|
192
|
+
"VOXCPM_DEVICE='mps' requested, but PyTorch MPS backend is unavailable (refusing CPU fallback)"
|
|
193
|
+
)
|
|
194
|
+
|
|
186
195
|
with contextlib.redirect_stdout(sys.stderr):
|
|
187
196
|
import voxcpm # type: ignore
|
|
188
197
|
from huggingface_hub import snapshot_download # type: ignore
|
|
@@ -5,11 +5,19 @@ import { createVoxCpmClient, VOXCPM_TTS_GENERATOR, type VoxCpmClientOptions } fr
|
|
|
5
5
|
|
|
6
6
|
export * from './voxcpm-client';
|
|
7
7
|
|
|
8
|
+
interface BatchManifestEntry {
|
|
9
|
+
in: string;
|
|
10
|
+
out: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
8
13
|
/**
|
|
9
14
|
* `kk` plugin entry: render Doc[] into audio Content through the shared voice-gen pipeline,
|
|
10
15
|
* injecting the invocation-scoped VoxCPM adapter and closing it (worker, signals, scratch) in
|
|
11
16
|
* `finally`. The worker stays lazy until `health()` runs after shared Doc validation, so empty
|
|
12
17
|
* input starts nothing (AC3).
|
|
18
|
+
*
|
|
19
|
+
* When `VOXCPM_BATCH_MANIFEST` (or `--batch <path>`) is set, renders every `{ in, out }` entry
|
|
20
|
+
* sequentially against one shared worker handle so the model loads at most once per episode.
|
|
13
21
|
*/
|
|
14
22
|
export async function main(argv: string[] = process.argv.slice(2), options: VoxCpmClientOptions = {}): Promise<number> {
|
|
15
23
|
const { values } = parseArgs({
|
|
@@ -17,9 +25,42 @@ export async function main(argv: string[] = process.argv.slice(2), options: VoxC
|
|
|
17
25
|
options: {
|
|
18
26
|
in: { type: 'string' },
|
|
19
27
|
out: { type: 'string' },
|
|
28
|
+
batch: { type: 'string' },
|
|
20
29
|
},
|
|
21
30
|
});
|
|
22
31
|
|
|
32
|
+
const env = options.env ?? (process.env as Record<string, string | undefined>);
|
|
33
|
+
const batchPath = values.batch ?? env.VOXCPM_BATCH_MANIFEST;
|
|
34
|
+
|
|
35
|
+
if (batchPath) {
|
|
36
|
+
let entries: BatchManifestEntry[];
|
|
37
|
+
try {
|
|
38
|
+
const parsed = JSON.parse(await Bun.file(batchPath).text()) as unknown;
|
|
39
|
+
if (
|
|
40
|
+
!Array.isArray(parsed) ||
|
|
41
|
+
parsed.some((e) => !e || typeof e !== 'object' || typeof e.in !== 'string' || typeof e.out !== 'string')
|
|
42
|
+
) {
|
|
43
|
+
throw new Error('batch manifest must be an array of { in, out } string pairs');
|
|
44
|
+
}
|
|
45
|
+
entries = parsed as BatchManifestEntry[];
|
|
46
|
+
} catch (err: unknown) {
|
|
47
|
+
echoError(`voxcpm-tts failed: invalid batch manifest: ${err instanceof Error ? err.message : String(err)}`);
|
|
48
|
+
return 1;
|
|
49
|
+
}
|
|
50
|
+
const handle = createVoxCpmClient(options);
|
|
51
|
+
try {
|
|
52
|
+
for (const entry of entries) {
|
|
53
|
+
await processGeneratorIO(entry.in, entry.out, handle.client, undefined, VOXCPM_TTS_GENERATOR);
|
|
54
|
+
}
|
|
55
|
+
return 0;
|
|
56
|
+
} catch (err: unknown) {
|
|
57
|
+
echoError(`voxcpm-tts failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
58
|
+
return 1;
|
|
59
|
+
} finally {
|
|
60
|
+
await handle.close();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
23
64
|
if (!values.in || !values.out) {
|
|
24
65
|
echoError('voxcpm-tts failed: Missing required arguments: --in and --out');
|
|
25
66
|
return 1;
|
|
@@ -269,6 +269,8 @@ export function createVoxCpmClient(options: VoxCpmClientOptions = {}): VoxCpmCli
|
|
|
269
269
|
let fatal: Error | undefined;
|
|
270
270
|
let closed = false;
|
|
271
271
|
let stderrTail = '';
|
|
272
|
+
let stderrDone: Promise<void> = Promise.resolve();
|
|
273
|
+
let exitDetails: { code: number | null; signal: NodeJS.Signals | null } | undefined;
|
|
272
274
|
let stdoutBuffer = '';
|
|
273
275
|
let renderInFlight: { id: number; dest: string } | undefined;
|
|
274
276
|
let warnedChunk = false;
|
|
@@ -363,26 +365,45 @@ export function createVoxCpmClient(options: VoxCpmClientOptions = {}): VoxCpmCli
|
|
|
363
365
|
child = proc;
|
|
364
366
|
proc.on('error', (err) => fail(new Error(`voxcpm-tts: worker process error: ${err.message}`)));
|
|
365
367
|
proc.on('exit', (code, signal) => {
|
|
368
|
+
exitDetails = { code, signal };
|
|
366
369
|
if (!closed && !fatal) {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
370
|
+
void Promise.race([stderrDone, new Promise((r) => setTimeout(r, 150))]).then(() => {
|
|
371
|
+
if (!closed && !fatal) {
|
|
372
|
+
fail(
|
|
373
|
+
new Error(
|
|
374
|
+
`voxcpm-tts: worker exited unexpectedly (code ${code ?? 'null'}, signal ${signal ?? 'none'})${stderrTail ? `: ${stderrTail.slice(-400)}` : ''}`,
|
|
375
|
+
),
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
});
|
|
372
379
|
}
|
|
373
380
|
});
|
|
381
|
+
if (proc.stderr) {
|
|
382
|
+
stderrDone = pump(proc.stderr, (text) => {
|
|
383
|
+
stderrTail = (stderrTail + text).slice(-STDERR_MAX_CHARS);
|
|
384
|
+
});
|
|
385
|
+
}
|
|
374
386
|
if (proc.stdout) {
|
|
375
387
|
void pump(proc.stdout, consumeStdout, () => {
|
|
376
388
|
if (!fatal && !closed) {
|
|
377
|
-
|
|
389
|
+
void Promise.race([
|
|
390
|
+
Promise.all([waitForExit(proc, 250), stderrDone]),
|
|
391
|
+
new Promise((r) => setTimeout(r, 250)),
|
|
392
|
+
]).then(() => {
|
|
393
|
+
if (!fatal && !closed) {
|
|
394
|
+
const detail = exitDetails
|
|
395
|
+
? ` (code ${exitDetails.code ?? 'null'}, signal ${exitDetails.signal ?? 'none'})`
|
|
396
|
+
: ' before settling all requests';
|
|
397
|
+
fail(
|
|
398
|
+
new Error(
|
|
399
|
+
`voxcpm-tts: worker closed stdout${detail}${stderrTail ? `: ${stderrTail.slice(-400)}` : ''}`,
|
|
400
|
+
),
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
});
|
|
378
404
|
}
|
|
379
405
|
});
|
|
380
406
|
}
|
|
381
|
-
if (proc.stderr) {
|
|
382
|
-
void pump(proc.stderr, (text) => {
|
|
383
|
-
stderrTail = (stderrTail + text).slice(-STDERR_MAX_CHARS);
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
407
|
// Normal-signal teardown: SIGTERM/SIGINT close, terminate and reap owned workers.
|
|
387
408
|
for (const signal of SIGNAL_HANDLERS) {
|
|
388
409
|
const handler = () => {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Hardlink wheels from the shared uv cache instead of copying them. Measured 2026-11-20: this
|
|
2
|
+
# env and omni-voice-gen's held 2.45 GiB with zero hardlinked bytes, so torch/scipy/llvmlite
|
|
3
|
+
# were stored twice on top of ~/.cache/uv/archive-v0. Hardlinks need both paths on one
|
|
4
|
+
# filesystem; override with UV_LINK_MODE=copy if the cache ever moves to another device.
|
|
5
|
+
link-mode = "hardlink"
|
package/plugins/kk/README.md
CHANGED
|
@@ -97,6 +97,27 @@ whole day, and the daily run closes as no-content. A render without the key is s
|
|
|
97
97
|
value is simply empty, which spur reads as "not set". The rendered artifact carries a live
|
|
98
98
|
credential: keep it in `~/Library/LaunchAgents` (or your crontab), never in a committed file.
|
|
99
99
|
|
|
100
|
+
The `kk-serve` plist additionally binds **`NODE_PATH` to the module root that carries
|
|
101
|
+
`@gobing-ai/spur`** (resolved from the `spur` on `PATH`, else the bun-global default). The project's
|
|
102
|
+
decision catalogs (`decisions.paths` → `plugins/kk/decisions`) declare
|
|
103
|
+
`$schema: "@gobing-ai/spur/schemas/decision-catalog.schema.json"`, and Bun's resolver does not search
|
|
104
|
+
the global install — so every job the scheduler launches, and every nested `spur`/`kk` it launches,
|
|
105
|
+
loses the whole decision layer without it. Not hypothetical: on 2026-11-19 a `bun install` run in
|
|
106
|
+
`$HOME` pruned the checkout's `/Users/robin/node_modules/@gobing-ai/spur` shadow, after which
|
|
107
|
+
`kk store label` died at catalog load (empty label artifact → `kk-collect` closed `failed-check`)
|
|
108
|
+
and spur's `decide` action silently loaded **zero** project catalogs, so `kk-safety-verdict` produced
|
|
109
|
+
no row and the safety gate refused the day's drafts. Leave the key in place when you hand-edit the
|
|
110
|
+
plist; re-rendering restores it.
|
|
111
|
+
|
|
112
|
+
Neither owner covers a bare interactive `kk store label` / `spur decision` in your own shell, which is
|
|
113
|
+
why this checkout keeps a `node_modules/@gobing-ai/spur` symlink to the installed package — the only
|
|
114
|
+
resolver that exists before any of those wrappers run. Nothing declares the package as a dependency
|
|
115
|
+
(it has to stay a latest global tool), so `bun install` is free to prune the link; `bun run prepare`
|
|
116
|
+
re-creates it from the `spur` on `PATH` on every install (`scripts/link-spur.ts`). Check with
|
|
117
|
+
`spur --no-logo decision list | grep -c plugins/kk/decisions` (0 = the decision layer is invisible) and
|
|
118
|
+
repair with `bun scripts/link-spur.ts`. A global `NODE_PATH` export in your shell rc is not the fix:
|
|
119
|
+
it leaks one checkout's global tree into every project on the machine.
|
|
120
|
+
|
|
100
121
|
`kk-collect` collects every ingestion source into the kk store and never publishes. Two ticks that
|
|
101
122
|
overlap are **one** collection: the first state takes `kk store lock acquire --name collect` and a
|
|
102
123
|
tick that finds the claim inside its TTL exits 0 (`skipped`) without collecting. Before relying on
|
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
# `kk-daily-safety` used to read the judge's self-reported `confidence` field in a shell `jq`
|
|
4
4
|
# filter on the accept edge. The verdict is now a catalog decision over the SAME artifacts as
|
|
5
5
|
# evidence, so the outcome is calibrated, ledgered (`decision_logs`) and carries a declared
|
|
6
|
-
# fallback. The fallback is `escalate`, never `pass`:
|
|
7
|
-
#
|
|
6
|
+
# fallback. The fallback is `escalate`, never `pass`: the decision can always refuse to publish.
|
|
7
|
+
# A JUDGED escalate (the model read the evidence and could not settle it) needs a human, and the
|
|
8
|
+
# accept guard refuses it for an unattended run; an ABSTAINED row (`source: "default"` — the maker
|
|
9
|
+
# refused or was unavailable, so nothing was judged) is named by `kk stage daily-safety-verdict` and
|
|
10
|
+
# leaves the gate's own verdict in charge, because an abstention is not a verdict.
|
|
8
11
|
#
|
|
9
12
|
# Resolution: registered through `decisions.paths` in `.spur/config.yaml`
|
|
10
13
|
# (project-relative `plugins/kk/decisions`). No maker is named here on purpose — the project
|
package/plugins/kk/plugin.json
CHANGED
|
@@ -46,9 +46,18 @@
|
|
|
46
46
|
</array>
|
|
47
47
|
<key>WorkingDirectory</key>
|
|
48
48
|
<string>{{repo}}</string>
|
|
49
|
-
<!-- The environment block is load-bearing
|
|
49
|
+
<!-- The environment block is load-bearing three times over:
|
|
50
50
|
- PATH — launchd starts with /usr/bin:/bin:/usr/sbin:/sbin and the scheduler's job worker
|
|
51
51
|
runs its commands through /bin/sh -c, so bare `spur`, `kk`, `jq` and `bun` must resolve.
|
|
52
|
+
- NODE_PATH — the module root carrying `@gobing-ai/spur`. Project decision catalogs
|
|
53
|
+
(`decisions.paths` → `plugins/kk/decisions`) declare `$schema:
|
|
54
|
+
"@gobing-ai/spur/schemas/decision-catalog.schema.json"`, and Bun's resolver does not
|
|
55
|
+
search the global install, so WITHOUT this every registered catalog fails to load: kk
|
|
56
|
+
answers `Decision catalog … Cannot find package '@gobing-ai/spur'` (2026-11-19: a whole
|
|
57
|
+
`kk-collect` tick lost its labels and the next 04:30 run lost its `kk-safety-verdict`
|
|
58
|
+
row, which the gate read as a refusal) and spur's `decide` action silently loads ZERO
|
|
59
|
+
project catalogs. `kk schedule render` binds the path from the `spur` on PATH that the
|
|
60
|
+
`Program` below names; render from a shell that has it.
|
|
52
61
|
- TYPESAFE_API_KEY — spur keeps the decision-maker credential env-only, and a server
|
|
53
62
|
started from launchd inherits nothing from the operator's shell; without the key every
|
|
54
63
|
`typesafe`-routed decision (kk-item-china-politics, -sensitivity, -audience) falls back
|
|
@@ -62,6 +71,8 @@
|
|
|
62
71
|
<dict>
|
|
63
72
|
<key>PATH</key>
|
|
64
73
|
<string>{{home}}/.bun/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
|
|
74
|
+
<key>NODE_PATH</key>
|
|
75
|
+
<string>{{spur_modules}}</string>
|
|
65
76
|
<key>TYPESAFE_API_KEY</key>
|
|
66
77
|
<string>{{typesafe_api_key}}</string>
|
|
67
78
|
</dict>
|