@gobing-ai/knowledge-kit 0.1.22 → 0.1.24
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 +282 -147
- package/package.json +5 -5
- package/plugins/generations/content-gen/dist/index.js +9 -9
- package/plugins/generations/core-facts-gen/dist/index.js +12 -12
- package/plugins/generations/daily-article-gen/dist/index.js +12 -12
- package/plugins/generations/dailynews-gen/dist/index.js +11 -11
- package/plugins/generations/dailynews-gen/src/script-plan.ts +2 -2
- package/plugins/generations/episode-plan-gen/dist/index.js +12 -12
- package/plugins/generations/gemini-tts/dist/index.js +56 -16
- package/plugins/generations/gemini-tts/src/gemini-client.ts +34 -6
- package/plugins/generations/image-gen/dist/index.js +9 -9
- package/plugins/generations/music-gen/README.md +2 -2
- package/plugins/generations/music-gen/dist/index.js +62 -26
- 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/news-report-gen/dist/index.js +12 -12
- 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 +40 -10
- package/plugins/generations/voice-gen/src/voicebox-client.ts +50 -1
- package/plugins/generations/voxcpm-tts/dist/index.js +90 -18
- 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/ingestions/aihot-ingest/dist/index.js +12 -12
- package/plugins/ingestions/horizon-ingest/dist/index.js +12 -12
- package/plugins/ingestions/karakeep-local/dist/index.js +13 -13
- package/plugins/ingestions/last30days-ingest/dist/index.js +12 -12
- package/plugins/ingestions/web-search/dist/index.js +10 -10
- 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/publish-presets/daily-ai-voice.json +16 -16
- package/plugins/kk/schedules/kk-serve.launchd.plist.tmpl +12 -1
- package/plugins/kk/scripts/cover-compositor.ts +104 -26
- package/plugins/kk/scripts/daily-stages.ts +481 -63
- package/plugins/kk/scripts/kk-workflow-stages.ts +218 -17
- package/plugins/kk/scripts/safety-artifact-check.ts +28 -5
- package/plugins/kk/scripts/series-names.ts +16 -3
- package/plugins/kk/skills/news-editorial/SKILL.md +1 -1
- package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +3 -3
- 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 +26 -3
- package/plugins/kk/workflows/kk-publish.yaml +4 -1
- package/plugins/publishings/bilibili-pub/dist/index.js +22 -22
- package/plugins/publishings/bilibili-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/cnblogs-pub/dist/index.js +22 -22
- package/plugins/publishings/cnblogs-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/csdn-pub/dist/index.js +22 -22
- package/plugins/publishings/csdn-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/emdash-pub/dist/index.js +9 -9
- package/plugins/publishings/infoq-pub/dist/index.js +22 -22
- package/plugins/publishings/infoq-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/jike-pub/dist/index.js +22 -22
- package/plugins/publishings/jike-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/juejin-pub/dist/index.js +22 -22
- package/plugins/publishings/juejin-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/linkedin-pub/dist/index.js +133 -33
- package/plugins/publishings/linkedin-pub/dist/profile-check.js +27 -22
- package/plugins/publishings/linkedin-pub/src/index.ts +192 -18
- package/plugins/publishings/medium-pub/dist/index.js +9 -9
- package/plugins/publishings/podcast-pub/dist/index.js +240 -37
- package/plugins/publishings/podcast-pub/src/index.ts +154 -3
- package/plugins/publishings/podcast-pub/src/seo.ts +25 -8
- package/plugins/publishings/podcast-pub/src/show-notes-brief.ts +93 -23
- package/plugins/publishings/podcast-pub/src/show-notes.ts +26 -6
- package/plugins/publishings/qiita-pub/dist/index.js +9 -9
- package/plugins/publishings/shipinhao-pub/dist/index.js +23 -23
- package/plugins/publishings/shipinhao-pub/dist/profile-check.js +23 -23
- package/plugins/publishings/shipinhao-pub/src/selectors.ts +2 -1
- package/plugins/publishings/sspai-pub/dist/index.js +22 -22
- package/plugins/publishings/sspai-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/substack-pub/dist/index.js +22 -22
- package/plugins/publishings/substack-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/surfdash-pub/dist/index.js +207 -95
- package/plugins/publishings/surfdash-pub/src/digest-check.ts +30 -1
- package/plugins/publishings/surfdash-pub/src/index.ts +101 -76
- package/plugins/publishings/surfdash-pub/src/media-upload.ts +83 -0
- package/plugins/publishings/surfdash-pub/src/patch.ts +49 -26
- package/plugins/publishings/surfdash-pub/src/topic-claims.ts +12 -4
- package/plugins/publishings/threads-pub/dist/index.js +83 -27
- package/plugins/publishings/threads-pub/dist/profile-check.js +34 -23
- package/plugins/publishings/threads-pub/src/post-rail.ts +121 -4
- package/plugins/publishings/wechatmp-pub/dist/index.js +274 -98
- package/plugins/publishings/wechatmp-pub/dist/profile-check.js +27 -23
- package/plugins/publishings/wechatmp-pub/src/cgi-draft.ts +87 -53
- package/plugins/publishings/wechatmp-pub/src/enrich.ts +117 -13
- package/plugins/publishings/wechatmp-pub/src/flow.ts +183 -43
- package/plugins/publishings/wechatmp-pub/src/modes.ts +30 -12
- package/plugins/publishings/weibo-pub/dist/index.js +22 -22
- package/plugins/publishings/weibo-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/x-pub/dist/index.js +113 -32
- package/plugins/publishings/x-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/x-pub/src/post-rail.ts +155 -20
- package/plugins/publishings/xhs-pub/dist/index.js +22 -22
- package/plugins/publishings/xhs-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +22 -22
- package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/zenn-pub/dist/index.js +9 -9
|
@@ -8,6 +8,12 @@ const DEFAULT_PROFILES_PATH = new URL('../profiles.json', import.meta.url).pathn
|
|
|
8
8
|
const TRANSCRIBE_PROMPT = 'Transcribe this audio verbatim. Output only the transcript, no commentary.';
|
|
9
9
|
/** retry-after above this (Google daily-quota 429s: ~70_000s) is never actionable inside a run. */
|
|
10
10
|
const RETRY_AFTER_CAP_SEC = 120;
|
|
11
|
+
/**
|
|
12
|
+
* 4xx that retrying can never fix: auth, billing (2026-11-20: a depleted project answered 402 on
|
|
13
|
+
* every call) and malformed requests. Retried, they burn the whole per-segment budget for a
|
|
14
|
+
* certain failure, which is how one episode spent 23 minutes failing over.
|
|
15
|
+
*/
|
|
16
|
+
const TERMINAL_STATUSES = new Set([400, 401, 402, 403, 404]);
|
|
11
17
|
const PLACEHOLDER_VOICE = 'voice_REPLACE_ME';
|
|
12
18
|
|
|
13
19
|
type Env = Record<string, string | undefined>;
|
|
@@ -78,13 +84,24 @@ export function createGeminiVoiceClient(options: GeminiVoiceClientOptions = {}):
|
|
|
78
84
|
const styleOverride = env.GEMINI_TTS_STYLE;
|
|
79
85
|
const maxAttempts = positiveInt(env.GEMINI_TTS_MAX_ATTEMPTS, 4);
|
|
80
86
|
const timeoutMs = positiveInt(env.GEMINI_TTS_TIMEOUT_MS, 120_000);
|
|
87
|
+
// Wall-clock ceiling for ONE segment across every attempt and backoff, so a stalled endpoint
|
|
88
|
+
// cannot multiply the per-request timeout by the attempt count (R1).
|
|
89
|
+
const segmentTimeoutMs = positiveInt(env.GEMINI_TTS_SEGMENT_TIMEOUT_MS, 180_000);
|
|
81
90
|
const buffered = new Map<string, Uint8Array>();
|
|
82
91
|
let profiles: Record<string, { voice?: string }> | undefined;
|
|
83
92
|
let seq = 0;
|
|
84
93
|
|
|
85
94
|
async function post(body: unknown, label: string): Promise<InteractionResponse> {
|
|
86
95
|
const apiKey = env.GEMINI_API_KEY ?? '';
|
|
96
|
+
const deadline = Date.now() + segmentTimeoutMs;
|
|
87
97
|
for (let attempt = 1; ; attempt++) {
|
|
98
|
+
const remaining = deadline - Date.now();
|
|
99
|
+
if (remaining <= 0) {
|
|
100
|
+
throw new Error(
|
|
101
|
+
`${label}: segment budget ${segmentTimeoutMs}ms exhausted after ${attempt - 1} attempt(s)`,
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
const attemptMs = Math.min(timeoutMs, remaining);
|
|
88
105
|
let res: Response;
|
|
89
106
|
try {
|
|
90
107
|
res = await withDeadline(
|
|
@@ -92,18 +109,24 @@ export function createGeminiVoiceClient(options: GeminiVoiceClientOptions = {}):
|
|
|
92
109
|
method: 'POST',
|
|
93
110
|
headers: { 'content-type': 'application/json', 'x-goog-api-key': apiKey },
|
|
94
111
|
body: JSON.stringify(body),
|
|
95
|
-
signal: AbortSignal.timeout(
|
|
112
|
+
signal: AbortSignal.timeout(attemptMs),
|
|
96
113
|
}),
|
|
97
|
-
|
|
114
|
+
attemptMs,
|
|
98
115
|
);
|
|
99
116
|
} catch (err: unknown) {
|
|
100
117
|
const msg = err instanceof Error ? err.message : String(err);
|
|
101
|
-
if (attempt >= maxAttempts)
|
|
102
|
-
throw new Error(
|
|
103
|
-
|
|
118
|
+
if (attempt >= maxAttempts || Date.now() >= deadline)
|
|
119
|
+
throw new Error(
|
|
120
|
+
`${label}: request failed after ${attempt} attempt(s) within ${segmentTimeoutMs}ms: ${msg}`,
|
|
121
|
+
);
|
|
122
|
+
await sleep(Math.min(2000 * 2 ** (attempt - 1), Math.max(0, deadline - Date.now())));
|
|
104
123
|
continue;
|
|
105
124
|
}
|
|
106
|
-
if (res.ok)
|
|
125
|
+
if (res.ok)
|
|
126
|
+
return withDeadline(
|
|
127
|
+
res.json(),
|
|
128
|
+
Math.min(timeoutMs, Math.max(1, deadline - Date.now())),
|
|
129
|
+
) as Promise<InteractionResponse>;
|
|
107
130
|
const raw = await withDeadline(res.text(), timeoutMs);
|
|
108
131
|
let apiMessage = raw.slice(0, 300);
|
|
109
132
|
try {
|
|
@@ -120,6 +143,11 @@ export function createGeminiVoiceClient(options: GeminiVoiceClientOptions = {}):
|
|
|
120
143
|
`${label}: HTTP ${res.status} quota/reset horizon too far out (retry-after ${retryAfter}s ≈ ${(retryAfter / 3600).toFixed(1)}h): ${apiMessage}`,
|
|
121
144
|
);
|
|
122
145
|
}
|
|
146
|
+
if (TERMINAL_STATUSES.has(res.status)) {
|
|
147
|
+
throw new Error(
|
|
148
|
+
`${label}: HTTP ${res.status} is not retryable (auth/billing/request class) — failing fast instead of burning the segment budget: ${apiMessage}`,
|
|
149
|
+
);
|
|
150
|
+
}
|
|
123
151
|
const retryable = res.status === 429 || res.status >= 500;
|
|
124
152
|
if (!retryable || attempt >= maxAttempts) {
|
|
125
153
|
throw new Error(`${label}: HTTP ${res.status} after ${attempt} attempt(s): ${apiMessage}`);
|
|
@@ -4821,7 +4821,7 @@ var init_zod = __esm(() => {
|
|
|
4821
4821
|
init_external();
|
|
4822
4822
|
});
|
|
4823
4823
|
|
|
4824
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4824
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/errors.js
|
|
4825
4825
|
var ErrorCode;
|
|
4826
4826
|
var init_errors3 = __esm(() => {
|
|
4827
4827
|
ErrorCode = {
|
|
@@ -4832,7 +4832,7 @@ var init_errors3 = __esm(() => {
|
|
|
4832
4832
|
};
|
|
4833
4833
|
});
|
|
4834
4834
|
|
|
4835
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4835
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/api-response.js
|
|
4836
4836
|
var API_ERROR_CODES, ERROR_CODE_TO_HTTP, CLIENT_SAFE_CODES;
|
|
4837
4837
|
var init_api_response = __esm(() => {
|
|
4838
4838
|
init_errors3();
|
|
@@ -4855,13 +4855,13 @@ var init_api_response = __esm(() => {
|
|
|
4855
4855
|
CLIENT_SAFE_CODES = new Set([ErrorCode.NotFound, ErrorCode.Validation, ErrorCode.Conflict]);
|
|
4856
4856
|
});
|
|
4857
4857
|
|
|
4858
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4858
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/cursor.js
|
|
4859
4859
|
var init_cursor = () => {};
|
|
4860
4860
|
|
|
4861
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4861
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
|
|
4862
4862
|
var init_event_severity = () => {};
|
|
4863
4863
|
|
|
4864
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4864
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/output.js
|
|
4865
4865
|
function processStream(name) {
|
|
4866
4866
|
const proc = globalThis.process;
|
|
4867
4867
|
const stream = proc?.[name];
|
|
@@ -4879,7 +4879,7 @@ function echoError(message, target = defaultStderrTarget ?? processStream("stder
|
|
|
4879
4879
|
}
|
|
4880
4880
|
var defaultStderrTarget;
|
|
4881
4881
|
|
|
4882
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4882
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/index.js
|
|
4883
4883
|
var init_dist = __esm(() => {
|
|
4884
4884
|
init_api_response();
|
|
4885
4885
|
init_cursor();
|
|
@@ -11877,7 +11877,7 @@ var init_dist2 = __esm(() => {
|
|
|
11877
11877
|
$visitAsync = visit.visitAsync;
|
|
11878
11878
|
});
|
|
11879
11879
|
|
|
11880
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
11880
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/config.js
|
|
11881
11881
|
var configSchema;
|
|
11882
11882
|
var init_config = __esm(() => {
|
|
11883
11883
|
init_dist2();
|
|
@@ -11901,7 +11901,7 @@ var init_config = __esm(() => {
|
|
|
11901
11901
|
});
|
|
11902
11902
|
});
|
|
11903
11903
|
|
|
11904
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
11904
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
|
|
11905
11905
|
import { appendFileSync, cpSync, createReadStream, createWriteStream, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "fs";
|
|
11906
11906
|
import { dirname, resolve as resolvePath } from "path";
|
|
11907
11907
|
function createNodeFileSystem(root, paths) {
|
|
@@ -12589,7 +12589,7 @@ var PluginManifestSchema = PluginManifestSchemaBase.superRefine((manifest, ctx)
|
|
|
12589
12589
|
});
|
|
12590
12590
|
}
|
|
12591
12591
|
});
|
|
12592
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
12592
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/index.js
|
|
12593
12593
|
init_file_system_node();
|
|
12594
12594
|
init_config();
|
|
12595
12595
|
|
|
@@ -124,7 +124,7 @@ timestamped section skeleton. `lyrics` is the format’s policy: `forbidden` res
|
|
|
124
124
|
| `clip` | `clip` | — (clip is fixed at ~0:30) | allowed | Quick preview, a direction check before a pro run, or a short social cut. | `authored` |
|
|
125
125
|
| `jingle` | `pro` | `0:20` | allowed | Product or station ident — the hook states the name once and resolves fast. | `authored` |
|
|
126
126
|
| `loop` | `clip` | — (clip is fixed at ~0:30) | forbidden | Background bed for a talk-through, demo or menu loop; no vocals by design. | `authored` |
|
|
127
|
-
| `song` | `pro` | `2:30` | allowed | A complete track with a sung hook; the default for lyrical pieces. | `
|
|
127
|
+
| `song` | `pro` | `2:30` | allowed | A complete track with a sung hook; the default for lyrical pieces. | `verified` |
|
|
128
128
|
| `underscore` | `pro` | `0:45` | forbidden | Underscore under spoken narration or a video essay; no hook or vocal required. | `authored` |
|
|
129
129
|
|
|
130
130
|
### Themes
|
|
@@ -137,7 +137,7 @@ vocal character and production — plus its default `avoid[]`, rendered as one `
|
|
|
137
137
|
| `ambient-tech` | glassy ambient techno; 100-115 BPM, steady and unaccented; C# minor | hard drops, talkbox vocals, pop hooks, vocal chops | Product walkthroughs, conference holds, editorial beds that must stay out of the way. | `authored` |
|
|
138
138
|
| `cinematic` | cinematic orchestral hybrid score; 60-90 BPM with rubato swells; D minor | horror stingers, orchestral hits on every downbeat, distorted electric guitar, pop chorus stacks | Trailer-style openings, story intros, a track that must feel like a scene. | `authored` |
|
|
139
139
|
| `lofi` | dusty sampled lo-fi hip-hop; 70-85 BPM, swung and unhurried; A minor | trap hi-hat rolls, hard drops, EDM riser clichés, over-compressed loudness | Study/focus background, calm narration bed, unhurried social cuts. | `authored` |
|
|
140
|
-
| `synthwave` | analog synthwave revival; 90-110 BPM, straight four-on-the-floor; A minor | festival supersaws, EDM risers, distorted djent guitars, modern trap percussion | Retro-tech explainers, night-drive montages, upbeat product stings. | `
|
|
140
|
+
| `synthwave` | analog synthwave revival; 90-110 BPM, straight four-on-the-floor; A minor | festival supersaws, EDM risers, distorted djent guitars, modern trap percussion | Retro-tech explainers, night-drive montages, upbeat product stings. | `verified` |
|
|
141
141
|
<!-- preset-index:end -->
|
|
142
142
|
|
|
143
143
|
Evidence status: `authored` means written from the design contract with no generated take judged
|
|
@@ -232,14 +232,15 @@ class InstanceClient {
|
|
|
232
232
|
}
|
|
233
233
|
async attempt(method, path, body) {
|
|
234
234
|
const controller = new AbortController;
|
|
235
|
-
|
|
235
|
+
const enforceConnectTimer = method === "GET";
|
|
236
|
+
let phase = enforceConnectTimer ? "connect" : "body";
|
|
236
237
|
let abortReason;
|
|
237
|
-
const connectTimer = setTimeout(() => {
|
|
238
|
+
const connectTimer = enforceConnectTimer ? setTimeout(() => {
|
|
238
239
|
if (phase === "connect" && abortReason === undefined) {
|
|
239
240
|
abortReason = "connect-timeout";
|
|
240
241
|
controller.abort();
|
|
241
242
|
}
|
|
242
|
-
}, this.connectTimeoutMs);
|
|
243
|
+
}, this.connectTimeoutMs) : undefined;
|
|
243
244
|
const totalTimer = setTimeout(() => {
|
|
244
245
|
if (abortReason === undefined) {
|
|
245
246
|
abortReason = "generate-timeout";
|
|
@@ -258,7 +259,9 @@ class InstanceClient {
|
|
|
258
259
|
};
|
|
259
260
|
const response = await this.fetchImpl(this.url(path), init);
|
|
260
261
|
phase = "body";
|
|
261
|
-
|
|
262
|
+
if (connectTimer !== undefined) {
|
|
263
|
+
clearTimeout(connectTimer);
|
|
264
|
+
}
|
|
262
265
|
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
263
266
|
const contentType = response.headers.get("content-type") ?? undefined;
|
|
264
267
|
return {
|
|
@@ -291,7 +294,9 @@ class InstanceClient {
|
|
|
291
294
|
}
|
|
292
295
|
return { kind: "ambiguous", reason };
|
|
293
296
|
} finally {
|
|
294
|
-
|
|
297
|
+
if (connectTimer !== undefined) {
|
|
298
|
+
clearTimeout(connectTimer);
|
|
299
|
+
}
|
|
295
300
|
clearTimeout(totalTimer);
|
|
296
301
|
}
|
|
297
302
|
}
|
|
@@ -326,6 +331,17 @@ class InstanceClient {
|
|
|
326
331
|
let lastReason = "";
|
|
327
332
|
for (;; ) {
|
|
328
333
|
attempts += 1;
|
|
334
|
+
if (method === "POST") {
|
|
335
|
+
const probe = await this.attempt("GET", STATUS_PATH, undefined);
|
|
336
|
+
if (probe.kind === "connect") {
|
|
337
|
+
lastReason = probe.reason;
|
|
338
|
+
if (attempts >= maxAttempts) {
|
|
339
|
+
return { kind: "connect-exhausted", reason: lastReason, attempts };
|
|
340
|
+
}
|
|
341
|
+
await this.sleep(this.retryDelayMs * 2 ** (attempts - 1));
|
|
342
|
+
continue;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
329
345
|
const outcome = await this.attempt(method, path, body);
|
|
330
346
|
if (outcome.kind === "response") {
|
|
331
347
|
return this.classify(outcome.response, attempts);
|
|
@@ -635,7 +651,7 @@ class InstanceClient {
|
|
|
635
651
|
function createInstanceClient(options = {}) {
|
|
636
652
|
return new InstanceClient(options);
|
|
637
653
|
}
|
|
638
|
-
var GENERATE_PATH = "/api/lyria/generate", LIBRARY_PATH = "/api/generations", ANALYZE_PATH = "/api/ai/analyze", DEFAULT_CONNECT_ATTEMPTS = 3, DEFAULT_RETRY_DELAY_MS = 250, TERMINAL_STATUSES, STATUS_REMEDIATION, CONNECT_ERROR_CODES, AMBIGUOUS_ERROR_CODES, ALL_KEYS_REJECTED_PATTERN, InstanceError, platformFetch;
|
|
654
|
+
var GENERATE_PATH = "/api/lyria/generate", LIBRARY_PATH = "/api/generations", STATUS_PATH = "/api/settings/status", ANALYZE_PATH = "/api/ai/analyze", DEFAULT_CONNECT_ATTEMPTS = 3, DEFAULT_RETRY_DELAY_MS = 250, TERMINAL_STATUSES, STATUS_REMEDIATION, CONNECT_ERROR_CODES, AMBIGUOUS_ERROR_CODES, ALL_KEYS_REJECTED_PATTERN, InstanceError, platformFetch;
|
|
639
655
|
var init_instance = __esm(() => {
|
|
640
656
|
init_audio();
|
|
641
657
|
TERMINAL_STATUSES = new Set([400, 401, 402, 403, 404, 429]);
|
|
@@ -869,7 +885,7 @@ var init_artifact = __esm(() => {
|
|
|
869
885
|
};
|
|
870
886
|
});
|
|
871
887
|
|
|
872
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
888
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/errors.js
|
|
873
889
|
var ErrorCode;
|
|
874
890
|
var init_errors = __esm(() => {
|
|
875
891
|
ErrorCode = {
|
|
@@ -880,7 +896,7 @@ var init_errors = __esm(() => {
|
|
|
880
896
|
};
|
|
881
897
|
});
|
|
882
898
|
|
|
883
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
899
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/api-response.js
|
|
884
900
|
var API_ERROR_CODES, ERROR_CODE_TO_HTTP, CLIENT_SAFE_CODES;
|
|
885
901
|
var init_api_response = __esm(() => {
|
|
886
902
|
init_errors();
|
|
@@ -903,18 +919,18 @@ var init_api_response = __esm(() => {
|
|
|
903
919
|
CLIENT_SAFE_CODES = new Set([ErrorCode.NotFound, ErrorCode.Validation, ErrorCode.Conflict]);
|
|
904
920
|
});
|
|
905
921
|
|
|
906
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
922
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/cursor.js
|
|
907
923
|
var init_cursor = () => {};
|
|
908
924
|
|
|
909
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
925
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/env.js
|
|
910
926
|
function getEnvVars() {
|
|
911
927
|
return process.env;
|
|
912
928
|
}
|
|
913
929
|
|
|
914
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
930
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
|
|
915
931
|
var init_event_severity = () => {};
|
|
916
932
|
|
|
917
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
933
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/output.js
|
|
918
934
|
function processStream(name) {
|
|
919
935
|
const proc = globalThis.process;
|
|
920
936
|
const stream = proc?.[name];
|
|
@@ -935,7 +951,7 @@ function echoError(message, target = defaultStderrTarget ?? processStream("stder
|
|
|
935
951
|
}
|
|
936
952
|
var defaultStdoutTarget, defaultStderrTarget;
|
|
937
953
|
|
|
938
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
954
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/index.js
|
|
939
955
|
var init_dist = __esm(() => {
|
|
940
956
|
init_api_response();
|
|
941
957
|
init_cursor();
|
|
@@ -12741,7 +12757,7 @@ var init_zod = __esm(() => {
|
|
|
12741
12757
|
init_external();
|
|
12742
12758
|
});
|
|
12743
12759
|
|
|
12744
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
12760
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/config.js
|
|
12745
12761
|
function getProcessEnv() {
|
|
12746
12762
|
return getEnvVars();
|
|
12747
12763
|
}
|
|
@@ -12769,7 +12785,7 @@ var init_config = __esm(() => {
|
|
|
12769
12785
|
});
|
|
12770
12786
|
});
|
|
12771
12787
|
|
|
12772
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
12788
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
|
|
12773
12789
|
import { appendFileSync, cpSync, createReadStream, createWriteStream, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "fs";
|
|
12774
12790
|
import { dirname, resolve as resolvePath } from "path";
|
|
12775
12791
|
function createNodeFileSystem(root, paths) {
|
|
@@ -20056,7 +20072,7 @@ var init_execa = __esm(() => {
|
|
|
20056
20072
|
} = getIpcExport());
|
|
20057
20073
|
});
|
|
20058
20074
|
|
|
20059
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
20075
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/process-group.js
|
|
20060
20076
|
function resolveDeadline(optionTimeout, defaultTimeout) {
|
|
20061
20077
|
if (optionTimeout === null)
|
|
20062
20078
|
return null;
|
|
@@ -20148,7 +20164,7 @@ function ownProcessGroupLifecycle(ownership) {
|
|
|
20148
20164
|
}
|
|
20149
20165
|
var MAX_TIMEOUT_MS = 2147483647, DEFAULT_KILL_GRACE_MS = 5000, GROUP_POLL_INTERVAL_MS = 25, GROUP_KILL_PATIENCE_MS = 2000;
|
|
20150
20166
|
|
|
20151
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
20167
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/process-executor.js
|
|
20152
20168
|
import { isatty } from "tty";
|
|
20153
20169
|
function processEventSeverity(reason, exitCode) {
|
|
20154
20170
|
if (reason === "error")
|
|
@@ -20520,26 +20536,26 @@ var init_process_executor = __esm(() => {
|
|
|
20520
20536
|
init_config();
|
|
20521
20537
|
});
|
|
20522
20538
|
|
|
20523
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
20539
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/context.js
|
|
20524
20540
|
var init_context = () => {};
|
|
20525
20541
|
|
|
20526
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
20542
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/path.js
|
|
20527
20543
|
var SEP;
|
|
20528
20544
|
var init_path = __esm(() => {
|
|
20529
20545
|
SEP = globalThis.process?.platform === "win32" ? "\\" : "/";
|
|
20530
20546
|
});
|
|
20531
20547
|
|
|
20532
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
20548
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/schema-validation.js
|
|
20533
20549
|
var REMOTE_SCHEMA_MAX_BYTES;
|
|
20534
20550
|
var init_schema_validation = __esm(() => {
|
|
20535
20551
|
init_dist2();
|
|
20536
20552
|
REMOTE_SCHEMA_MAX_BYTES = 5 * 1024 * 1024;
|
|
20537
20553
|
});
|
|
20538
20554
|
|
|
20539
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
20555
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/types.js
|
|
20540
20556
|
var init_types = () => {};
|
|
20541
20557
|
|
|
20542
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
20558
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/index.js
|
|
20543
20559
|
var init_dist3 = __esm(() => {
|
|
20544
20560
|
init_file_system_node();
|
|
20545
20561
|
init_process_executor();
|
|
@@ -21322,7 +21338,7 @@ function buildMusicContent(input) {
|
|
|
21322
21338
|
var MUSIC_CONTENT_FORMAT = "audio";
|
|
21323
21339
|
|
|
21324
21340
|
// ../../plugins/generations/music-gen/src/presets.ts
|
|
21325
|
-
import { join as join3 } from "path";
|
|
21341
|
+
import { join as join3, resolve as resolve2 } from "path";
|
|
21326
21342
|
function describeSource(sourced) {
|
|
21327
21343
|
return sourced.origin === undefined ? sourced.source : `${sourced.source} preset "${sourced.origin}"`;
|
|
21328
21344
|
}
|
|
@@ -21550,6 +21566,25 @@ function themeDirectionGaps(theme) {
|
|
|
21550
21566
|
require2("production", theme.production);
|
|
21551
21567
|
return gaps;
|
|
21552
21568
|
}
|
|
21569
|
+
function musicPresetRootCandidates(from = import.meta.dir) {
|
|
21570
|
+
const candidates = [];
|
|
21571
|
+
let dir = resolve2(from);
|
|
21572
|
+
for (;; ) {
|
|
21573
|
+
candidates.push(join3(dir, "..", "presets"));
|
|
21574
|
+
candidates.push(join3(dir, "plugins", "generations", "music-gen", "presets"));
|
|
21575
|
+
const parent = resolve2(dir, "..");
|
|
21576
|
+
if (parent === dir)
|
|
21577
|
+
return candidates;
|
|
21578
|
+
dir = parent;
|
|
21579
|
+
}
|
|
21580
|
+
}
|
|
21581
|
+
async function resolveMusicPresetRoot(fs, from) {
|
|
21582
|
+
for (const candidate of musicPresetRootCandidates(from)) {
|
|
21583
|
+
if (await fs.exists(candidate))
|
|
21584
|
+
return candidate;
|
|
21585
|
+
}
|
|
21586
|
+
return MUSIC_PRESET_ROOT;
|
|
21587
|
+
}
|
|
21553
21588
|
async function readPresetFiles(dir, axis, fs, problems) {
|
|
21554
21589
|
if (!await fs.exists(dir)) {
|
|
21555
21590
|
problems.push({ path: dir, field: axis, message: "preset directory is missing" });
|
|
@@ -21626,8 +21661,8 @@ function collectPresets(args) {
|
|
|
21626
21661
|
return byName;
|
|
21627
21662
|
}
|
|
21628
21663
|
async function loadMusicPresets(options = {}) {
|
|
21629
|
-
const root = options.root ?? MUSIC_PRESET_ROOT;
|
|
21630
21664
|
const fs = options.fileSystem ?? createNodeFileSystem();
|
|
21665
|
+
const root = options.root ?? await resolveMusicPresetRoot(fs);
|
|
21631
21666
|
const problems = [];
|
|
21632
21667
|
const formatFiles = await readPresetFiles(join3(root, "formats"), "formats", fs, problems);
|
|
21633
21668
|
const themeFiles = await readPresetFiles(join3(root, "themes"), "themes", fs, problems);
|
|
@@ -22313,7 +22348,7 @@ var init_request = __esm(() => {
|
|
|
22313
22348
|
});
|
|
22314
22349
|
|
|
22315
22350
|
// ../../plugins/generations/music-gen/src/plugin.ts
|
|
22316
|
-
import { dirname as dirname2, join as join4, resolve as
|
|
22351
|
+
import { dirname as dirname2, join as join4, resolve as resolve3 } from "path";
|
|
22317
22352
|
import { parseArgs } from "util";
|
|
22318
22353
|
async function readMusicDocs(fileSystem, inputPath) {
|
|
22319
22354
|
let docs;
|
|
@@ -22516,7 +22551,7 @@ async function main2(argv = process.argv.slice(2)) {
|
|
|
22516
22551
|
...values.reason === undefined ? {} : { reason: values.reason },
|
|
22517
22552
|
...values.takes === undefined ? {} : { takes: parseTakesFlag(values.takes) }
|
|
22518
22553
|
};
|
|
22519
|
-
await processGeneratorIO(values.in,
|
|
22554
|
+
await processGeneratorIO(values.in, resolve3(values.out), { spend });
|
|
22520
22555
|
return 0;
|
|
22521
22556
|
} catch (err) {
|
|
22522
22557
|
echoError(`music-gen failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -23437,6 +23472,7 @@ export {
|
|
|
23437
23472
|
SILENCE_EDGE_TOLERANCE_SECONDS,
|
|
23438
23473
|
SILENT_WAV_SAMPLE_RATE,
|
|
23439
23474
|
SILENT_WAV_SECONDS,
|
|
23475
|
+
STATUS_PATH,
|
|
23440
23476
|
SpendRefusal,
|
|
23441
23477
|
StructureEntrySchema,
|
|
23442
23478
|
TAKE_SIDECAR_SUFFIX,
|
|
@@ -28,4 +28,9 @@ structure:
|
|
|
28
28
|
provenance:
|
|
29
29
|
authoring_source: task 0399 (feature D8) — docs/design/music-gen.md section 5 and the plugin README authoring form
|
|
30
30
|
authored_at: "2026-11-19"
|
|
31
|
-
status:
|
|
31
|
+
status: verified
|
|
32
|
+
evidence: >-
|
|
33
|
+
verified 2026-11-20 by 0404's dogfood round — generation gen-1795196931030-puqx6j (pro,
|
|
34
|
+
149.13 s, D minor) rendered from .works/kk-music/morning-chamber-orchids, accepted by the
|
|
35
|
+
operator; run report c73a9b02: judge PASS 0.825 (MEDIUM), delivery -14.01 LUFS / -1 dBTP at
|
|
36
|
+
the streaming profile. Evidence: docs/tasks/evidence/D8/0404/accepted/.
|
|
@@ -27,4 +27,9 @@ avoid:
|
|
|
27
27
|
provenance:
|
|
28
28
|
authoring_source: task 0399 (feature D8) — docs/design/music-gen.md section 5 and the plugin README authoring form
|
|
29
29
|
authored_at: "2026-11-19"
|
|
30
|
-
status:
|
|
30
|
+
status: verified
|
|
31
|
+
evidence: >-
|
|
32
|
+
verified 2026-11-20 by 0404's dogfood round — generation gen-1795196931030-puqx6j (pro,
|
|
33
|
+
149.13 s, D minor) rendered from .works/kk-music/morning-chamber-orchids, accepted by the
|
|
34
|
+
operator; run report c73a9b02: judge PASS 0.825 (MEDIUM), delivery -14.01 LUFS / -1 dBTP at
|
|
35
|
+
the streaming profile. Evidence: docs/tasks/evidence/D8/0404/accepted/.
|
|
@@ -38,6 +38,9 @@ export const GENERATE_PATH = '/api/lyria/generate';
|
|
|
38
38
|
/** Library route (free): the reconciliation + cache-first analyse source. */
|
|
39
39
|
export const LIBRARY_PATH = '/api/generations';
|
|
40
40
|
|
|
41
|
+
/** Cheap reachability probe route (free): decided under `connectTimeoutMs` before paid POSTs. */
|
|
42
|
+
export const STATUS_PATH = '/api/settings/status';
|
|
43
|
+
|
|
41
44
|
/** Analyse route (paid). */
|
|
42
45
|
export const ANALYZE_PATH = '/api/ai/analyze';
|
|
43
46
|
|
|
@@ -383,17 +386,22 @@ export class InstanceClient implements MusicInstance {
|
|
|
383
386
|
return new URL(`${LIBRARY_PATH}/${encodeURIComponent(instanceId)}`, `${this.baseUrl}/`).toString();
|
|
384
387
|
}
|
|
385
388
|
|
|
386
|
-
/** One round trip with
|
|
389
|
+
/** One round trip with an optional connect-phase deadline (GET only) and an end-to-end deadline. */
|
|
387
390
|
private async attempt(method: 'GET' | 'POST', path: string, body: unknown): Promise<AttemptOutcome> {
|
|
388
391
|
const controller = new AbortController();
|
|
389
|
-
|
|
392
|
+
// Paid POSTs are synchronous on the instance (headers arrive only after generation completes),
|
|
393
|
+
// so only GETs (including the pre-POST reachability probe) carry the connect-phase timer.
|
|
394
|
+
const enforceConnectTimer = method === 'GET';
|
|
395
|
+
let phase: 'connect' | 'body' = enforceConnectTimer ? 'connect' : 'body';
|
|
390
396
|
let abortReason: 'connect-timeout' | 'generate-timeout' | undefined;
|
|
391
|
-
const connectTimer =
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
+
const connectTimer = enforceConnectTimer
|
|
398
|
+
? setTimeout(() => {
|
|
399
|
+
if (phase === 'connect' && abortReason === undefined) {
|
|
400
|
+
abortReason = 'connect-timeout';
|
|
401
|
+
controller.abort();
|
|
402
|
+
}
|
|
403
|
+
}, this.connectTimeoutMs)
|
|
404
|
+
: undefined;
|
|
397
405
|
const totalTimer = setTimeout(() => {
|
|
398
406
|
if (abortReason === undefined) {
|
|
399
407
|
abortReason = 'generate-timeout';
|
|
@@ -413,7 +421,9 @@ export class InstanceClient implements MusicInstance {
|
|
|
413
421
|
const response = await this.fetchImpl(this.url(path), init);
|
|
414
422
|
// Headers arrived: the request reached the instance, so a later abort is post-send.
|
|
415
423
|
phase = 'body';
|
|
416
|
-
|
|
424
|
+
if (connectTimer !== undefined) {
|
|
425
|
+
clearTimeout(connectTimer);
|
|
426
|
+
}
|
|
417
427
|
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
418
428
|
const contentType = response.headers.get('content-type') ?? undefined;
|
|
419
429
|
return {
|
|
@@ -448,7 +458,9 @@ export class InstanceClient implements MusicInstance {
|
|
|
448
458
|
// Anything unrecognised may have reached the instance: ambiguous, never retried.
|
|
449
459
|
return { kind: 'ambiguous', reason };
|
|
450
460
|
} finally {
|
|
451
|
-
|
|
461
|
+
if (connectTimer !== undefined) {
|
|
462
|
+
clearTimeout(connectTimer);
|
|
463
|
+
}
|
|
452
464
|
clearTimeout(totalTimer);
|
|
453
465
|
}
|
|
454
466
|
}
|
|
@@ -481,13 +493,24 @@ export class InstanceClient implements MusicInstance {
|
|
|
481
493
|
return { kind: 'ambiguous', reason: `answered an unexpected ${String(status)}`, status, attempts };
|
|
482
494
|
}
|
|
483
495
|
|
|
484
|
-
/** Send one request,
|
|
496
|
+
/** Send one request, probing reachability before paid POSTs, and classify the result. */
|
|
485
497
|
private async send(method: 'GET' | 'POST', path: string, body: unknown): Promise<SendOutcome> {
|
|
486
498
|
const maxAttempts = method === 'POST' ? this.connectAttempts : 1;
|
|
487
499
|
let attempts = 0;
|
|
488
500
|
let lastReason = '';
|
|
489
501
|
for (;;) {
|
|
490
502
|
attempts += 1;
|
|
503
|
+
if (method === 'POST') {
|
|
504
|
+
const probe = await this.attempt('GET', STATUS_PATH, undefined);
|
|
505
|
+
if (probe.kind === 'connect') {
|
|
506
|
+
lastReason = probe.reason;
|
|
507
|
+
if (attempts >= maxAttempts) {
|
|
508
|
+
return { kind: 'connect-exhausted', reason: lastReason, attempts };
|
|
509
|
+
}
|
|
510
|
+
await this.sleep(this.retryDelayMs * 2 ** (attempts - 1));
|
|
511
|
+
continue;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
491
514
|
const outcome = await this.attempt(method, path, body);
|
|
492
515
|
if (outcome.kind === 'response') {
|
|
493
516
|
return this.classify(outcome.response, attempts);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { join } from 'node:path';
|
|
1
|
+
import { join, resolve } from 'node:path';
|
|
2
2
|
import { createNodeFileSystem, type FileSystem } from '@gobing-ai/ts-runtime';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import {
|
|
@@ -669,9 +669,42 @@ export class PresetDataError extends Error {
|
|
|
669
669
|
}
|
|
670
670
|
}
|
|
671
671
|
|
|
672
|
-
/**
|
|
672
|
+
/**
|
|
673
|
+
* Shipped preset root for the source layout: `plugins/generations/music-gen/presets`.
|
|
674
|
+
*
|
|
675
|
+
* A bundled `kk` puts this module inside `<pkg>/dist/index.js`, where the sibling directory does not
|
|
676
|
+
* exist — the packaged copy lives at `<pkg>/plugins/generations/music-gen/presets` instead (0413).
|
|
677
|
+
* {@link resolveMusicPresetRoot} picks the first candidate that exists; this constant stays the
|
|
678
|
+
* source-layout path and the last-resort value, so a genuinely missing corpus still fails with a
|
|
679
|
+
* recognisable path.
|
|
680
|
+
*/
|
|
673
681
|
export const MUSIC_PRESET_ROOT = join(import.meta.dir, '..', 'presets');
|
|
674
682
|
|
|
683
|
+
/**
|
|
684
|
+
* Preset-root candidates for one anchor directory, nearest first: the plugin-local sibling layout
|
|
685
|
+
* (source and any unpacked plugin dir), then the package-root layout a bundle needs, checked at
|
|
686
|
+
* every ancestor because a bundle's `import.meta.dir` is `<pkg>/dist`.
|
|
687
|
+
*/
|
|
688
|
+
export function musicPresetRootCandidates(from: string = import.meta.dir): string[] {
|
|
689
|
+
const candidates: string[] = [];
|
|
690
|
+
let dir = resolve(from);
|
|
691
|
+
for (;;) {
|
|
692
|
+
candidates.push(join(dir, '..', 'presets'));
|
|
693
|
+
candidates.push(join(dir, 'plugins', 'generations', 'music-gen', 'presets'));
|
|
694
|
+
const parent = resolve(dir, '..');
|
|
695
|
+
if (parent === dir) return candidates;
|
|
696
|
+
dir = parent;
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
/** The first candidate that exists, else the source-layout path (so the failure names a real shape). */
|
|
701
|
+
export async function resolveMusicPresetRoot(fs: FileSystem, from?: string): Promise<string> {
|
|
702
|
+
for (const candidate of musicPresetRootCandidates(from)) {
|
|
703
|
+
if (await fs.exists(candidate)) return candidate;
|
|
704
|
+
}
|
|
705
|
+
return MUSIC_PRESET_ROOT;
|
|
706
|
+
}
|
|
707
|
+
|
|
675
708
|
/** The shipped inventory: one map per axis, keyed by preset name. */
|
|
676
709
|
export interface LoadedMusicPresets {
|
|
677
710
|
/** Root the two axes were read from. */
|
|
@@ -792,8 +825,8 @@ function collectPresets<T extends { name: string }>(args: {
|
|
|
792
825
|
* {@link PresetDataError} with every problem listed — no partial set escapes.
|
|
793
826
|
*/
|
|
794
827
|
export async function loadMusicPresets(options: LoadMusicPresetsOptions = {}): Promise<LoadedMusicPresets> {
|
|
795
|
-
const root = options.root ?? MUSIC_PRESET_ROOT;
|
|
796
828
|
const fs = options.fileSystem ?? createNodeFileSystem();
|
|
829
|
+
const root = options.root ?? (await resolveMusicPresetRoot(fs));
|
|
797
830
|
const problems: MusicPresetProblem[] = [];
|
|
798
831
|
const formatFiles = await readPresetFiles(join(root, 'formats'), 'formats', fs, problems);
|
|
799
832
|
const themeFiles = await readPresetFiles(join(root, 'themes'), 'themes', fs, problems);
|