@gobing-ai/knowledge-kit 0.1.23 → 0.1.25
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 +418 -114
- 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 +59 -18
- package/plugins/generations/episode-plan-gen/src/index.ts +71 -7
- package/plugins/generations/gemini-tts/dist/index.js +9 -9
- package/plugins/generations/image-gen/dist/index.js +9 -9
- package/plugins/generations/music-gen/dist/index.js +33 -29
- package/plugins/generations/music-gen/src/audio/measure.ts +25 -20
- package/plugins/generations/news-report-gen/dist/index.js +12 -12
- package/plugins/generations/vibe-voice-tts/dist/index.js +9 -9
- package/plugins/generations/voice-gen/dist/index.js +9 -9
- package/plugins/generations/voxcpm-tts/dist/index.js +9 -9
- 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/decisions/extract/ai-news.yaml +8 -1
- package/plugins/kk/plugin.json +1 -1
- package/plugins/kk/publish-presets/daily-ai-voice.json +20 -20
- package/plugins/kk/publish-presets/itc-main.json +39 -23
- package/plugins/kk/scripts/cover-compositor.ts +104 -26
- package/plugins/kk/scripts/daily-stages.ts +704 -53
- package/plugins/kk/scripts/kk-workflow-stages.ts +149 -6
- package/plugins/kk/scripts/series-names.ts +16 -3
- package/plugins/kk/skills/content-safety/references/platforms/apple-podcasts.md +12 -5
- package/plugins/kk/skills/content-safety/references/platforms/wechatmp.md +8 -0
- package/plugins/kk/skills/content-safety/references/platforms/xiaoyuzhou.md +5 -0
- package/plugins/kk/skills/daily-news-cover/SKILL.md +96 -0
- package/plugins/kk/skills/daily-news-illustrations/SKILL.md +123 -0
- package/plugins/kk/skills/news-editorial/SKILL.md +5 -3
- package/plugins/kk/skills/news-editorial/references/daily-visual-composition.md +150 -0
- package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +3 -3
- package/plugins/kk/workflows/kk-article-generate.yaml +13 -1
- package/plugins/kk/workflows/kk-daily-ai-voice.yaml +6 -3
- package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +6 -4
- package/plugins/kk/workflows/kk-news-generate.yaml +74 -1
- package/plugins/publishings/bilibili-pub/dist/index.js +25 -24
- package/plugins/publishings/bilibili-pub/dist/profile-check.js +25 -24
- package/plugins/publishings/cnblogs-pub/dist/index.js +25 -24
- package/plugins/publishings/cnblogs-pub/dist/profile-check.js +25 -24
- package/plugins/publishings/csdn-pub/dist/index.js +25 -24
- package/plugins/publishings/csdn-pub/dist/profile-check.js +25 -24
- package/plugins/publishings/emdash-pub/dist/index.js +9 -9
- package/plugins/publishings/infoq-pub/dist/index.js +25 -24
- package/plugins/publishings/infoq-pub/dist/profile-check.js +25 -24
- package/plugins/publishings/jike-pub/dist/index.js +25 -24
- package/plugins/publishings/jike-pub/dist/profile-check.js +25 -24
- package/plugins/publishings/juejin-pub/dist/index.js +25 -24
- package/plugins/publishings/juejin-pub/dist/profile-check.js +25 -24
- package/plugins/publishings/linkedin-pub/dist/index.js +85 -26
- package/plugins/publishings/linkedin-pub/dist/profile-check.js +25 -24
- package/plugins/publishings/linkedin-pub/src/index.ts +93 -6
- package/plugins/publishings/medium-pub/dist/index.js +9206 -287
- package/plugins/publishings/medium-pub/dist/profile-check.js +21174 -0
- package/plugins/publishings/medium-pub/package.json +3 -1
- package/plugins/publishings/medium-pub/plugin.json +6 -1
- package/plugins/publishings/medium-pub/src/browser-rail.ts +280 -0
- package/plugins/publishings/medium-pub/src/index.ts +17 -1
- package/plugins/publishings/medium-pub/src/profile-check.ts +27 -0
- 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 +29 -26
- package/plugins/publishings/shipinhao-pub/dist/profile-check.js +28 -26
- package/plugins/publishings/shipinhao-pub/src/flow.ts +5 -0
- package/plugins/publishings/shipinhao-pub/src/selectors.ts +13 -5
- package/plugins/publishings/sspai-pub/dist/index.js +25 -24
- package/plugins/publishings/sspai-pub/dist/profile-check.js +25 -24
- package/plugins/publishings/substack-pub/dist/index.js +25 -24
- package/plugins/publishings/substack-pub/dist/profile-check.js +25 -24
- package/plugins/publishings/surfdash-pub/dist/index.js +200 -92
- package/plugins/publishings/surfdash-pub/src/digest-check.ts +30 -1
- package/plugins/publishings/surfdash-pub/src/index.ts +94 -75
- package/plugins/publishings/surfdash-pub/src/media-upload.ts +83 -0
- package/plugins/publishings/surfdash-pub/src/patch.ts +28 -23
- package/plugins/publishings/surfdash-pub/src/topic-claims.ts +12 -4
- package/plugins/publishings/threads-pub/dist/index.js +39 -24
- package/plugins/publishings/threads-pub/dist/profile-check.js +30 -24
- package/plugins/publishings/threads-pub/src/post-rail.ts +20 -0
- package/plugins/publishings/wechatmp-pub/dist/index.js +438 -102
- package/plugins/publishings/wechatmp-pub/dist/profile-check.js +30 -25
- package/plugins/publishings/wechatmp-pub/src/enrich.ts +56 -10
- package/plugins/publishings/wechatmp-pub/src/flow.ts +589 -83
- package/plugins/publishings/wechatmp-pub/src/index.ts +4 -1
- package/plugins/publishings/wechatmp-pub/src/modes.ts +30 -12
- package/plugins/publishings/wechatmp-pub/src/page.ts +8 -0
- package/plugins/publishings/weibo-pub/dist/index.js +25 -24
- package/plugins/publishings/weibo-pub/dist/profile-check.js +25 -24
- package/plugins/publishings/x-pub/dist/index.js +54 -47
- package/plugins/publishings/x-pub/dist/profile-check.js +25 -24
- package/plugins/publishings/x-pub/src/post-rail.ts +40 -47
- package/plugins/publishings/xhs-pub/dist/index.js +25 -24
- package/plugins/publishings/xhs-pub/dist/profile-check.js +25 -24
- package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +25 -24
- package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +25 -24
- package/plugins/publishings/zenn-pub/dist/index.js +9 -9
package/dist/index.js
CHANGED
|
@@ -2127,7 +2127,7 @@ var init_commander = __esm(() => {
|
|
|
2127
2127
|
program = new Command;
|
|
2128
2128
|
});
|
|
2129
2129
|
|
|
2130
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
2130
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/errors.js
|
|
2131
2131
|
var ErrorCode;
|
|
2132
2132
|
var init_errors = __esm(() => {
|
|
2133
2133
|
ErrorCode = {
|
|
@@ -2138,7 +2138,7 @@ var init_errors = __esm(() => {
|
|
|
2138
2138
|
};
|
|
2139
2139
|
});
|
|
2140
2140
|
|
|
2141
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
2141
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/api-response.js
|
|
2142
2142
|
var API_ERROR_CODES, ERROR_CODE_TO_HTTP, CLIENT_SAFE_CODES;
|
|
2143
2143
|
var init_api_response = __esm(() => {
|
|
2144
2144
|
init_errors();
|
|
@@ -2161,10 +2161,10 @@ var init_api_response = __esm(() => {
|
|
|
2161
2161
|
CLIENT_SAFE_CODES = new Set([ErrorCode.NotFound, ErrorCode.Validation, ErrorCode.Conflict]);
|
|
2162
2162
|
});
|
|
2163
2163
|
|
|
2164
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
2164
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/cursor.js
|
|
2165
2165
|
var init_cursor = () => {};
|
|
2166
2166
|
|
|
2167
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
2167
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/env.js
|
|
2168
2168
|
function getEnvVar(name, fallback) {
|
|
2169
2169
|
const raw = process.env[name];
|
|
2170
2170
|
return raw === undefined ? fallback : raw;
|
|
@@ -2173,10 +2173,10 @@ function getEnvVars() {
|
|
|
2173
2173
|
return process.env;
|
|
2174
2174
|
}
|
|
2175
2175
|
|
|
2176
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
2176
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
|
|
2177
2177
|
var init_event_severity = () => {};
|
|
2178
2178
|
|
|
2179
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
2179
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/object.js
|
|
2180
2180
|
function isPlainObject(value) {
|
|
2181
2181
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2182
2182
|
}
|
|
@@ -2194,7 +2194,7 @@ function deepMerge(target, source) {
|
|
|
2194
2194
|
return result;
|
|
2195
2195
|
}
|
|
2196
2196
|
|
|
2197
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
2197
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/output.js
|
|
2198
2198
|
function processStream(name) {
|
|
2199
2199
|
const proc = globalThis.process;
|
|
2200
2200
|
const stream = proc?.[name];
|
|
@@ -2227,7 +2227,7 @@ function setDefaultOutputTargets(opts) {
|
|
|
2227
2227
|
}
|
|
2228
2228
|
var defaultStdoutTarget, defaultStderrTarget;
|
|
2229
2229
|
|
|
2230
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
2230
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/index.js
|
|
2231
2231
|
var init_dist = __esm(() => {
|
|
2232
2232
|
init_api_response();
|
|
2233
2233
|
init_cursor();
|
|
@@ -23850,7 +23850,7 @@ var init_zod = __esm(() => {
|
|
|
23850
23850
|
init_external();
|
|
23851
23851
|
});
|
|
23852
23852
|
|
|
23853
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
23853
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/config.js
|
|
23854
23854
|
function getProcessEnv() {
|
|
23855
23855
|
return getEnvVars();
|
|
23856
23856
|
}
|
|
@@ -23928,7 +23928,7 @@ var init_config = __esm(() => {
|
|
|
23928
23928
|
};
|
|
23929
23929
|
});
|
|
23930
23930
|
|
|
23931
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
23931
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
|
|
23932
23932
|
import { appendFileSync, cpSync, createReadStream, createWriteStream, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "fs";
|
|
23933
23933
|
import { dirname, resolve as resolvePath } from "path";
|
|
23934
23934
|
function createNodeFileSystem(root, paths) {
|
|
@@ -24015,7 +24015,7 @@ function findProjectRoot(startDir) {
|
|
|
24015
24015
|
}
|
|
24016
24016
|
var init_file_system_node = () => {};
|
|
24017
24017
|
|
|
24018
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
24018
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/db-errors.js
|
|
24019
24019
|
var DbModuleNotInstalledError;
|
|
24020
24020
|
var init_db_errors = __esm(() => {
|
|
24021
24021
|
DbModuleNotInstalledError = class DbModuleNotInstalledError extends Error {
|
|
@@ -31226,7 +31226,7 @@ var init_execa = __esm(() => {
|
|
|
31226
31226
|
} = getIpcExport());
|
|
31227
31227
|
});
|
|
31228
31228
|
|
|
31229
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
31229
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/process-group.js
|
|
31230
31230
|
function resolveDeadline(optionTimeout, defaultTimeout) {
|
|
31231
31231
|
if (optionTimeout === null)
|
|
31232
31232
|
return null;
|
|
@@ -31318,7 +31318,7 @@ function ownProcessGroupLifecycle(ownership) {
|
|
|
31318
31318
|
}
|
|
31319
31319
|
var MAX_TIMEOUT_MS = 2147483647, DEFAULT_KILL_GRACE_MS = 5000, GROUP_POLL_INTERVAL_MS = 25, GROUP_KILL_PATIENCE_MS = 2000;
|
|
31320
31320
|
|
|
31321
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
31321
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/process-executor.js
|
|
31322
31322
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
31323
31323
|
import { isatty } from "tty";
|
|
31324
31324
|
function processEventSeverity(reason, exitCode) {
|
|
@@ -31720,7 +31720,7 @@ var init_process_executor = __esm(() => {
|
|
|
31720
31720
|
init_config();
|
|
31721
31721
|
});
|
|
31722
31722
|
|
|
31723
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
31723
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/runtime-node-bun.js
|
|
31724
31724
|
function getNodeFileSystem() {
|
|
31725
31725
|
if (!_nodeFileSystem)
|
|
31726
31726
|
_nodeFileSystem = createNodeFileSystem();
|
|
@@ -31780,10 +31780,10 @@ var init_runtime_node_bun = __esm(() => {
|
|
|
31780
31780
|
};
|
|
31781
31781
|
});
|
|
31782
31782
|
|
|
31783
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
31783
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/context.js
|
|
31784
31784
|
var init_context = () => {};
|
|
31785
31785
|
|
|
31786
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
31786
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/path.js
|
|
31787
31787
|
function normalizeSeparators(path) {
|
|
31788
31788
|
return path.replaceAll("\\", "/");
|
|
31789
31789
|
}
|
|
@@ -31844,7 +31844,7 @@ var init_path = __esm(() => {
|
|
|
31844
31844
|
SEP = globalThis.process?.platform === "win32" ? "\\" : "/";
|
|
31845
31845
|
});
|
|
31846
31846
|
|
|
31847
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
31847
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/fs.js
|
|
31848
31848
|
async function walkDir(path, fs = createNodeFileSystem(), exclude) {
|
|
31849
31849
|
const startReal = fs.realPath?.(path) ?? path;
|
|
31850
31850
|
const visited = new Set([startReal]);
|
|
@@ -31878,17 +31878,17 @@ var init_fs = __esm(() => {
|
|
|
31878
31878
|
init_path();
|
|
31879
31879
|
});
|
|
31880
31880
|
|
|
31881
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
31881
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/schema-validation.js
|
|
31882
31882
|
var REMOTE_SCHEMA_MAX_BYTES;
|
|
31883
31883
|
var init_schema_validation = __esm(() => {
|
|
31884
31884
|
init_dist2();
|
|
31885
31885
|
REMOTE_SCHEMA_MAX_BYTES = 5 * 1024 * 1024;
|
|
31886
31886
|
});
|
|
31887
31887
|
|
|
31888
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
31888
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/types.js
|
|
31889
31889
|
var init_types = () => {};
|
|
31890
31890
|
|
|
31891
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
31891
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/index.js
|
|
31892
31892
|
var init_dist3 = __esm(() => {
|
|
31893
31893
|
init_file_system_node();
|
|
31894
31894
|
init_fs();
|
|
@@ -31902,7 +31902,7 @@ var init_dist3 = __esm(() => {
|
|
|
31902
31902
|
init_types();
|
|
31903
31903
|
});
|
|
31904
31904
|
|
|
31905
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
31905
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+01334333455a284a/node_modules/@gobing-ai/ts-runtime/dist/config.js
|
|
31906
31906
|
var configSchema2;
|
|
31907
31907
|
var init_config2 = __esm(() => {
|
|
31908
31908
|
init_dist2();
|
|
@@ -31926,7 +31926,7 @@ var init_config2 = __esm(() => {
|
|
|
31926
31926
|
});
|
|
31927
31927
|
});
|
|
31928
31928
|
|
|
31929
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
31929
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+01334333455a284a/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
|
|
31930
31930
|
import { appendFileSync as appendFileSync3, cpSync as cpSync2, createReadStream as createReadStream3, createWriteStream as createWriteStream3, existsSync as existsSync4, mkdirSync as mkdirSync2, readdirSync as readdirSync3, readFileSync as readFileSync6, realpathSync as realpathSync3, renameSync as renameSync2, rmSync as rmSync2, statSync as statSync5, writeFileSync as writeFileSync3 } from "fs";
|
|
31931
31931
|
import { dirname as dirname4, resolve as resolvePath3 } from "path";
|
|
31932
31932
|
function createNodeFileSystem2(root, paths) {
|
|
@@ -32013,10 +32013,10 @@ function findProjectRoot2(startDir) {
|
|
|
32013
32013
|
}
|
|
32014
32014
|
var init_file_system_node2 = () => {};
|
|
32015
32015
|
|
|
32016
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
32016
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+01334333455a284a/node_modules/@gobing-ai/ts-runtime/dist/context.js
|
|
32017
32017
|
var init_context2 = () => {};
|
|
32018
32018
|
|
|
32019
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
32019
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+01334333455a284a/node_modules/@gobing-ai/ts-runtime/dist/path.js
|
|
32020
32020
|
function normalizeSeparators2(path) {
|
|
32021
32021
|
return path.replaceAll("\\", "/");
|
|
32022
32022
|
}
|
|
@@ -32077,17 +32077,17 @@ var init_path2 = __esm(() => {
|
|
|
32077
32077
|
SEP2 = globalThis.process?.platform === "win32" ? "\\" : "/";
|
|
32078
32078
|
});
|
|
32079
32079
|
|
|
32080
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
32080
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+01334333455a284a/node_modules/@gobing-ai/ts-runtime/dist/schema-validation.js
|
|
32081
32081
|
var REMOTE_SCHEMA_MAX_BYTES2;
|
|
32082
32082
|
var init_schema_validation2 = __esm(() => {
|
|
32083
32083
|
init_dist2();
|
|
32084
32084
|
REMOTE_SCHEMA_MAX_BYTES2 = 5 * 1024 * 1024;
|
|
32085
32085
|
});
|
|
32086
32086
|
|
|
32087
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
32087
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+01334333455a284a/node_modules/@gobing-ai/ts-runtime/dist/types.js
|
|
32088
32088
|
var init_types2 = () => {};
|
|
32089
32089
|
|
|
32090
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
32090
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+01334333455a284a/node_modules/@gobing-ai/ts-runtime/dist/index.js
|
|
32091
32091
|
var init_dist4 = __esm(() => {
|
|
32092
32092
|
init_file_system_node2();
|
|
32093
32093
|
init_config2();
|
|
@@ -32097,7 +32097,7 @@ var init_dist4 = __esm(() => {
|
|
|
32097
32097
|
init_types2();
|
|
32098
32098
|
});
|
|
32099
32099
|
|
|
32100
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
32100
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+01334333455a284a/node_modules/@gobing-ai/ts-runtime/dist/bun-sqlite.js
|
|
32101
32101
|
import { Database } from "bun:sqlite";
|
|
32102
32102
|
var init_bun_sqlite = () => {};
|
|
32103
32103
|
|
|
@@ -36484,7 +36484,7 @@ var init_bun_sqlite2 = __esm(() => {
|
|
|
36484
36484
|
init_session2();
|
|
36485
36485
|
});
|
|
36486
36486
|
|
|
36487
|
-
// ../../node_modules/.bun/@gobing-ai+ts-db@0.
|
|
36487
|
+
// ../../node_modules/.bun/@gobing-ai+ts-db@0.8.4+5cdeb656394cd753/node_modules/@gobing-ai/ts-db/dist/schema/inbox-messages.js
|
|
36488
36488
|
var inboxMessages;
|
|
36489
36489
|
var init_inbox_messages = __esm(() => {
|
|
36490
36490
|
init_sqlite_core();
|
|
@@ -36504,7 +36504,7 @@ var init_inbox_messages = __esm(() => {
|
|
|
36504
36504
|
}, (table) => [index("idx_inbox_messages_to_status").on(table.toId, table.status)]);
|
|
36505
36505
|
});
|
|
36506
36506
|
|
|
36507
|
-
// ../../node_modules/.bun/@gobing-ai+ts-db@0.
|
|
36507
|
+
// ../../node_modules/.bun/@gobing-ai+ts-db@0.8.4+5cdeb656394cd753/node_modules/@gobing-ai/ts-db/dist/schema/common.js
|
|
36508
36508
|
function nowTimestamp() {
|
|
36509
36509
|
return Date.now();
|
|
36510
36510
|
}
|
|
@@ -36533,7 +36533,7 @@ var init_common2 = __esm(() => {
|
|
|
36533
36533
|
appendOnlyColumns = buildAppendOnlyColumns();
|
|
36534
36534
|
});
|
|
36535
36535
|
|
|
36536
|
-
// ../../node_modules/.bun/@gobing-ai+ts-db@0.
|
|
36536
|
+
// ../../node_modules/.bun/@gobing-ai+ts-db@0.8.4+5cdeb656394cd753/node_modules/@gobing-ai/ts-db/dist/schema/queue-jobs.js
|
|
36537
36537
|
var queueJobs;
|
|
36538
36538
|
var init_queue_jobs = __esm(() => {
|
|
36539
36539
|
init_sqlite_core();
|
|
@@ -36557,7 +36557,7 @@ var init_queue_jobs = __esm(() => {
|
|
|
36557
36557
|
}, (table) => [index("queue_jobs_ready_idx").on(table.status, table.nextRetryAt, table.createdAt)]);
|
|
36558
36558
|
});
|
|
36559
36559
|
|
|
36560
|
-
// ../../node_modules/.bun/@gobing-ai+ts-db@0.
|
|
36560
|
+
// ../../node_modules/.bun/@gobing-ai+ts-db@0.8.4+5cdeb656394cd753/node_modules/@gobing-ai/ts-db/dist/schema/runtime.js
|
|
36561
36561
|
var exports_runtime = {};
|
|
36562
36562
|
__export(exports_runtime, {
|
|
36563
36563
|
inboxMessages: () => inboxMessages,
|
|
@@ -36568,7 +36568,7 @@ var init_runtime = __esm(() => {
|
|
|
36568
36568
|
init_queue_jobs();
|
|
36569
36569
|
});
|
|
36570
36570
|
|
|
36571
|
-
// ../../node_modules/.bun/@gobing-ai+ts-db@0.
|
|
36571
|
+
// ../../node_modules/.bun/@gobing-ai+ts-db@0.8.4+5cdeb656394cd753/node_modules/@gobing-ai/ts-db/dist/adapters/bun-sqlite.js
|
|
36572
36572
|
class BunSqliteAdapter {
|
|
36573
36573
|
sqlite;
|
|
36574
36574
|
drizzleDb;
|
|
@@ -36874,7 +36874,7 @@ var init_d1 = __esm(() => {
|
|
|
36874
36874
|
init_session3();
|
|
36875
36875
|
});
|
|
36876
36876
|
|
|
36877
|
-
// ../../node_modules/.bun/@gobing-ai+ts-db@0.
|
|
36877
|
+
// ../../node_modules/.bun/@gobing-ai+ts-db@0.8.4+5cdeb656394cd753/node_modules/@gobing-ai/ts-db/dist/adapters/d1.js
|
|
36878
36878
|
class D1Adapter {
|
|
36879
36879
|
binding;
|
|
36880
36880
|
drizzleDb;
|
|
@@ -36933,7 +36933,7 @@ var init_d12 = __esm(() => {
|
|
|
36933
36933
|
init_runtime();
|
|
36934
36934
|
});
|
|
36935
36935
|
|
|
36936
|
-
// ../../node_modules/.bun/@gobing-ai+ts-db@0.
|
|
36936
|
+
// ../../node_modules/.bun/@gobing-ai+ts-db@0.8.4+5cdeb656394cd753/node_modules/@gobing-ai/ts-db/dist/adapter.js
|
|
36937
36937
|
async function createDbAdapter(config) {
|
|
36938
36938
|
switch (config.driver) {
|
|
36939
36939
|
case "bun-sqlite": {
|
|
@@ -36967,7 +36967,7 @@ var init_drizzle_orm = __esm(() => {
|
|
|
36967
36967
|
init_view_common();
|
|
36968
36968
|
});
|
|
36969
36969
|
|
|
36970
|
-
// ../../node_modules/.bun/@gobing-ai+ts-db@0.
|
|
36970
|
+
// ../../node_modules/.bun/@gobing-ai+ts-db@0.8.4+5cdeb656394cd753/node_modules/@gobing-ai/ts-db/dist/query-spec.js
|
|
36971
36971
|
function compilePredicate(predicate) {
|
|
36972
36972
|
if ("and" in predicate) {
|
|
36973
36973
|
const parts = predicate.and.map(compilePredicate).filter((p) => p !== undefined);
|
|
@@ -37005,7 +37005,7 @@ var init_query_spec = __esm(() => {
|
|
|
37005
37005
|
};
|
|
37006
37006
|
});
|
|
37007
37007
|
|
|
37008
|
-
// ../../node_modules/.bun/@gobing-ai+ts-db@0.
|
|
37008
|
+
// ../../node_modules/.bun/@gobing-ai+ts-db@0.8.4+5cdeb656394cd753/node_modules/@gobing-ai/ts-db/dist/base-dao.js
|
|
37009
37009
|
function asSelectQuery(query) {
|
|
37010
37010
|
return query;
|
|
37011
37011
|
}
|
|
@@ -37047,7 +37047,7 @@ var init_base_dao = __esm(() => {
|
|
|
37047
37047
|
init_query_spec();
|
|
37048
37048
|
});
|
|
37049
37049
|
|
|
37050
|
-
// ../../node_modules/.bun/@gobing-ai+ts-db@0.
|
|
37050
|
+
// ../../node_modules/.bun/@gobing-ai+ts-db@0.8.4+5cdeb656394cd753/node_modules/@gobing-ai/ts-db/dist/entity-dao.js
|
|
37051
37051
|
var EntityDao;
|
|
37052
37052
|
var init_entity_dao = __esm(() => {
|
|
37053
37053
|
init_drizzle_orm();
|
|
@@ -37209,7 +37209,7 @@ var init_entity_dao = __esm(() => {
|
|
|
37209
37209
|
};
|
|
37210
37210
|
});
|
|
37211
37211
|
|
|
37212
|
-
// ../../node_modules/.bun/@gobing-ai+ts-db@0.
|
|
37212
|
+
// ../../node_modules/.bun/@gobing-ai+ts-db@0.8.4+5cdeb656394cd753/node_modules/@gobing-ai/ts-db/dist/index.js
|
|
37213
37213
|
var init_dist5 = __esm(() => {
|
|
37214
37214
|
init_base_dao();
|
|
37215
37215
|
init_entity_dao();
|
|
@@ -37713,7 +37713,7 @@ var init_ledger2 = __esm(() => {
|
|
|
37713
37713
|
init_output2();
|
|
37714
37714
|
});
|
|
37715
37715
|
|
|
37716
|
-
// ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.
|
|
37716
|
+
// ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/errors.js
|
|
37717
37717
|
var BrowserAutomationError, InvalidProfileDirError, BrowserProfileMissingError, BrowserProfileBusyError, PlaywrightUnavailableError, LoginTimeoutError, OperationAbortedError;
|
|
37718
37718
|
var init_errors5 = __esm(() => {
|
|
37719
37719
|
BrowserAutomationError = class BrowserAutomationError extends Error {
|
|
@@ -37760,7 +37760,7 @@ var init_errors5 = __esm(() => {
|
|
|
37760
37760
|
};
|
|
37761
37761
|
});
|
|
37762
37762
|
|
|
37763
|
-
// ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.
|
|
37763
|
+
// ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/profile-dir.js
|
|
37764
37764
|
function resolveProfileDir(profileDir) {
|
|
37765
37765
|
if (profileDir.trim() === "") {
|
|
37766
37766
|
throw new InvalidProfileDirError;
|
|
@@ -37776,7 +37776,7 @@ var init_profile_dir = __esm(() => {
|
|
|
37776
37776
|
init_errors5();
|
|
37777
37777
|
});
|
|
37778
37778
|
|
|
37779
|
-
// ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.
|
|
37779
|
+
// ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/launcher.js
|
|
37780
37780
|
import { mkdir } from "fs/promises";
|
|
37781
37781
|
async function ensureProfileDir(profileDir, headless, fs) {
|
|
37782
37782
|
const existing = await fs.stat(profileDir);
|
|
@@ -37833,7 +37833,7 @@ var init_launcher = __esm(() => {
|
|
|
37833
37833
|
CHROMIUM_MISSING_PATTERN = /playwright install|executable doesn't exist/i;
|
|
37834
37834
|
});
|
|
37835
37835
|
|
|
37836
|
-
// ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.
|
|
37836
|
+
// ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/operations.js
|
|
37837
37837
|
function getDefaultLauncher() {
|
|
37838
37838
|
if (defaultLauncher === undefined)
|
|
37839
37839
|
defaultLauncher = createPersistentLauncher();
|
|
@@ -37931,7 +37931,7 @@ var init_operations = __esm(() => {
|
|
|
37931
37931
|
init_profile_dir();
|
|
37932
37932
|
});
|
|
37933
37933
|
|
|
37934
|
-
// ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.
|
|
37934
|
+
// ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/index.js
|
|
37935
37935
|
var init_dist6 = __esm(() => {
|
|
37936
37936
|
init_errors5();
|
|
37937
37937
|
init_operations();
|
|
@@ -38318,7 +38318,8 @@ async function busyGuidance(fileSystem, leaseDir) {
|
|
|
38318
38318
|
}
|
|
38319
38319
|
return `browser lease ${leaseDir} already exists with no owner record \u2014 a previous run may have crashed mid-acquire; confirm no kk browser still uses this profile, then remove ${leaseDir} manually`;
|
|
38320
38320
|
}
|
|
38321
|
-
|
|
38321
|
+
const suffix = isProcessAlive(owner.pid) ? "confirm that process and any browser for this profile have stopped; stale ownership is never auto-removed" : `pid ${owner.pid} is no longer running \u2014 confirm no browser for this profile is open, then remove the stale lease with: rm -rf ${leaseDir}`;
|
|
38322
|
+
return `browser lease ${leaseDir} is held by pid ${owner.pid} (logical ${owner.logicalPath}) \u2014 ${suffix}`;
|
|
38322
38323
|
}
|
|
38323
38324
|
async function holderResidue(fileSystem, leaseDir) {
|
|
38324
38325
|
try {
|
|
@@ -38930,6 +38931,7 @@ __export(exports_browser, {
|
|
|
38930
38931
|
createExclusiveFile: () => createExclusiveFile,
|
|
38931
38932
|
createKkBrowserLauncher: () => createKkBrowserLauncher,
|
|
38932
38933
|
createShadowFinder: () => createShadowFinder,
|
|
38934
|
+
ensureProfileDir: () => ensureProfileDir2,
|
|
38933
38935
|
enterDelegatedLease: () => enterDelegatedLease,
|
|
38934
38936
|
execBot: () => execBot,
|
|
38935
38937
|
execFailureDetail: () => execFailureDetail,
|
|
@@ -38938,6 +38940,7 @@ __export(exports_browser, {
|
|
|
38938
38940
|
findLeftoverTransaction: () => findLeftoverTransaction,
|
|
38939
38941
|
findShadowControl: () => findShadowControl,
|
|
38940
38942
|
injectBrowserAntiDetection: () => injectBrowserAntiDetection,
|
|
38943
|
+
isProcessAlive: () => isProcessAlive,
|
|
38941
38944
|
isSafeBotName: () => isSafeBotName,
|
|
38942
38945
|
isSessionFactDate: () => isSessionFactDate,
|
|
38943
38946
|
isSessionFactIdentity: () => isSessionFactIdentity,
|
|
@@ -38965,6 +38968,7 @@ __export(exports_browser, {
|
|
|
38965
38968
|
resolveSelector: () => resolveSelector,
|
|
38966
38969
|
rmdir: () => rmdir,
|
|
38967
38970
|
runProfileCli: () => runProfileCli,
|
|
38971
|
+
signalSafeRelease: () => signalSafeRelease,
|
|
38968
38972
|
uploadFile: () => uploadFile,
|
|
38969
38973
|
validateExecUrl: () => validateExecUrl,
|
|
38970
38974
|
verifyLeaseHeld: () => verifyLeaseHeld,
|
|
@@ -39090,7 +39094,7 @@ function resolveChannelProfileDir(channel, override) {
|
|
|
39090
39094
|
return resolveBrowserProfileDir(channel, chosen);
|
|
39091
39095
|
}
|
|
39092
39096
|
async function checkChannelSession(config, opts) {
|
|
39093
|
-
const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
39097
|
+
const timeoutMs = opts.timeoutMs ?? config.checkTimeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
39094
39098
|
const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
|
|
39095
39099
|
let lastDetail = `${config.channel} readiness was never probed`;
|
|
39096
39100
|
const deadline = Date.now() + timeoutMs;
|
|
@@ -39449,16 +39453,67 @@ async function readIdentityOrUndefined(readIdentity, page) {
|
|
|
39449
39453
|
return;
|
|
39450
39454
|
}
|
|
39451
39455
|
}
|
|
39456
|
+
function signalSafeRelease(options) {
|
|
39457
|
+
const sigintBefore = new Set(process.listeners("SIGINT"));
|
|
39458
|
+
let releasing;
|
|
39459
|
+
const release = (signal) => {
|
|
39460
|
+
releasing ??= (async () => {
|
|
39461
|
+
await options.close().catch(() => {});
|
|
39462
|
+
await options.release().catch((error) => {
|
|
39463
|
+
echoError(`kk: releasing the profile lease after ${signal ?? "shutdown"} failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
39464
|
+
});
|
|
39465
|
+
if (signal !== undefined)
|
|
39466
|
+
process.exit(signal === "SIGINT" ? 130 : 143);
|
|
39467
|
+
})();
|
|
39468
|
+
return releasing;
|
|
39469
|
+
};
|
|
39470
|
+
const onSigint = () => void release("SIGINT");
|
|
39471
|
+
const onSigterm = () => void release("SIGTERM");
|
|
39472
|
+
process.once("SIGINT", onSigint);
|
|
39473
|
+
process.once("SIGTERM", onSigterm);
|
|
39474
|
+
return {
|
|
39475
|
+
park: () => {
|
|
39476
|
+
const parked = process.listeners("SIGINT").filter((listener) => !sigintBefore.has(listener) && listener !== onSigint);
|
|
39477
|
+
for (const listener of parked)
|
|
39478
|
+
process.off("SIGINT", listener);
|
|
39479
|
+
return () => {
|
|
39480
|
+
for (const listener of parked)
|
|
39481
|
+
process.on("SIGINT", listener);
|
|
39482
|
+
};
|
|
39483
|
+
},
|
|
39484
|
+
shutdown: async (signal) => {
|
|
39485
|
+
process.off("SIGINT", onSigint);
|
|
39486
|
+
process.off("SIGTERM", onSigterm);
|
|
39487
|
+
await release(signal);
|
|
39488
|
+
}
|
|
39489
|
+
};
|
|
39490
|
+
}
|
|
39452
39491
|
async function loginBot(name, url, options = {}) {
|
|
39453
39492
|
assertSafeBotName(name);
|
|
39454
39493
|
const defaultUrl = normalizeBotDefaultUrl(url);
|
|
39455
39494
|
const navigationUrl = url.trim();
|
|
39456
39495
|
const fileSystem = options.fileSystem ?? createNodeFileSystem();
|
|
39457
39496
|
const profileDir = resolveBotProfileDir(name, { root: options.root });
|
|
39458
|
-
const lease = await acquireProfileLease(profileDir, { leaseRoot: options.leaseRoot, fileSystem });
|
|
39459
39497
|
let transaction;
|
|
39460
39498
|
let context;
|
|
39461
39499
|
let promoting = false;
|
|
39500
|
+
const childAbort = new AbortController;
|
|
39501
|
+
const leaseRef = {};
|
|
39502
|
+
const shutdown = signalSafeRelease({
|
|
39503
|
+
close: async () => {
|
|
39504
|
+
childAbort.abort();
|
|
39505
|
+
await closeBotContext(context);
|
|
39506
|
+
if (!promoting)
|
|
39507
|
+
await transaction?.abort().catch(() => {});
|
|
39508
|
+
},
|
|
39509
|
+
release: () => leaseRef.current?.release() ?? Promise.resolve()
|
|
39510
|
+
});
|
|
39511
|
+
const lease = await acquireProfileLease(profileDir, { leaseRoot: options.leaseRoot, fileSystem }).catch(async (error) => {
|
|
39512
|
+
await shutdown.shutdown();
|
|
39513
|
+
throw error;
|
|
39514
|
+
});
|
|
39515
|
+
leaseRef.current = lease;
|
|
39516
|
+
let unpark;
|
|
39462
39517
|
try {
|
|
39463
39518
|
transaction = await beginBotTransaction({
|
|
39464
39519
|
name,
|
|
@@ -39472,11 +39527,13 @@ async function loginBot(name, url, options = {}) {
|
|
|
39472
39527
|
adapter: options.adapter,
|
|
39473
39528
|
transaction,
|
|
39474
39529
|
lease,
|
|
39475
|
-
fileSystem
|
|
39530
|
+
fileSystem,
|
|
39531
|
+
signal: childAbort.signal
|
|
39476
39532
|
});
|
|
39477
39533
|
}
|
|
39478
39534
|
const launcher = options.launcher ?? createKkBrowserLauncher(undefined, { lease, physicalProfileDir: transaction.stageDir }, { leaseRoot: options.leaseRoot, fileSystem });
|
|
39479
39535
|
context = await launcher.launch({ profileDir: transaction.stageDir, headless: false });
|
|
39536
|
+
unpark = shutdown.park();
|
|
39480
39537
|
const page = await openBotPage(context);
|
|
39481
39538
|
await navigateBot(page, navigationUrl);
|
|
39482
39539
|
await focusBotPage(page);
|
|
@@ -39505,21 +39562,24 @@ async function loginBot(name, url, options = {}) {
|
|
|
39505
39562
|
};
|
|
39506
39563
|
} catch (error) {
|
|
39507
39564
|
await closeBotContext(context);
|
|
39565
|
+
context = undefined;
|
|
39508
39566
|
if (!promoting && transaction !== undefined) {
|
|
39509
39567
|
await transaction.abort().catch(() => {});
|
|
39510
39568
|
}
|
|
39511
39569
|
throw error;
|
|
39512
39570
|
} finally {
|
|
39513
|
-
await
|
|
39571
|
+
await shutdown.shutdown();
|
|
39572
|
+
unpark?.();
|
|
39514
39573
|
}
|
|
39515
39574
|
}
|
|
39516
39575
|
async function runAdapterLogin(name, url, ctx) {
|
|
39517
|
-
const { adapter, transaction, lease, fileSystem } = ctx;
|
|
39576
|
+
const { adapter, transaction, lease, fileSystem, signal } = ctx;
|
|
39518
39577
|
const child = await adapter.run({
|
|
39519
39578
|
mode: "login",
|
|
39520
39579
|
profileDir: transaction.stageDir,
|
|
39521
39580
|
url,
|
|
39522
|
-
env: await lease.delegatedEnv(transaction.stageDir)
|
|
39581
|
+
env: await lease.delegatedEnv(transaction.stageDir),
|
|
39582
|
+
...signal === undefined ? {} : { signal }
|
|
39523
39583
|
});
|
|
39524
39584
|
if (child.exitCode === 2) {
|
|
39525
39585
|
throw new BotError("usage", `session adapter '${adapter.pluginName}' reported a usage error (exit 2) \u2014 nothing was saved`);
|
|
@@ -39599,14 +39659,29 @@ async function openBot(name, options = {}) {
|
|
|
39599
39659
|
if (openUrl === undefined) {
|
|
39600
39660
|
throw missingBotProfile(name, lstat(profileDir) !== null);
|
|
39601
39661
|
}
|
|
39602
|
-
const
|
|
39662
|
+
const leaseRef = {};
|
|
39663
|
+
let context;
|
|
39664
|
+
const childAbort = new AbortController;
|
|
39665
|
+
const shutdown = signalSafeRelease({
|
|
39666
|
+
close: async () => {
|
|
39667
|
+
childAbort.abort();
|
|
39668
|
+
await closeBotContext(context);
|
|
39669
|
+
},
|
|
39670
|
+
release: () => leaseRef.current?.release() ?? Promise.resolve()
|
|
39671
|
+
});
|
|
39672
|
+
const lease = await acquireProfileLease(profileDir, { leaseRoot: options.leaseRoot, fileSystem }).catch(async (error) => {
|
|
39673
|
+
await shutdown.shutdown();
|
|
39674
|
+
throw error;
|
|
39675
|
+
});
|
|
39676
|
+
leaseRef.current = lease;
|
|
39603
39677
|
if (options.adapter !== undefined) {
|
|
39604
39678
|
try {
|
|
39605
39679
|
const child = await options.adapter.run({
|
|
39606
39680
|
mode: "open",
|
|
39607
39681
|
profileDir,
|
|
39608
39682
|
url: openUrl,
|
|
39609
|
-
env: await lease.delegatedEnv(profileDir)
|
|
39683
|
+
env: await lease.delegatedEnv(profileDir),
|
|
39684
|
+
signal: childAbort.signal
|
|
39610
39685
|
});
|
|
39611
39686
|
if (child.exitCode === 2) {
|
|
39612
39687
|
throw new BotError("usage", `session adapter '${options.adapter.pluginName}' reported a usage error (exit 2)`);
|
|
@@ -39620,13 +39695,14 @@ async function openBot(name, options = {}) {
|
|
|
39620
39695
|
message: `closed the local session for bot '${name}' \u2014 the saved profile is unchanged`
|
|
39621
39696
|
};
|
|
39622
39697
|
} finally {
|
|
39623
|
-
await
|
|
39698
|
+
await shutdown.shutdown();
|
|
39624
39699
|
}
|
|
39625
39700
|
}
|
|
39626
|
-
let
|
|
39701
|
+
let unpark;
|
|
39627
39702
|
try {
|
|
39628
39703
|
const launcher = options.launcher ?? createKkBrowserLauncher(undefined, { lease, physicalProfileDir: profileDir }, { leaseRoot: options.leaseRoot, fileSystem });
|
|
39629
39704
|
context = await launcher.launch({ profileDir, headless: false });
|
|
39705
|
+
unpark = shutdown.park();
|
|
39630
39706
|
const closed = new Promise((resolveClose) => {
|
|
39631
39707
|
context?.once("close", () => resolveClose());
|
|
39632
39708
|
});
|
|
@@ -39641,9 +39717,11 @@ async function openBot(name, options = {}) {
|
|
|
39641
39717
|
};
|
|
39642
39718
|
} catch (error) {
|
|
39643
39719
|
await closeBotContext(context);
|
|
39720
|
+
context = undefined;
|
|
39644
39721
|
throw error;
|
|
39645
39722
|
} finally {
|
|
39646
|
-
await
|
|
39723
|
+
await shutdown.shutdown();
|
|
39724
|
+
unpark?.();
|
|
39647
39725
|
}
|
|
39648
39726
|
}
|
|
39649
39727
|
async function execBot(name, request, options = {}) {
|
|
@@ -39853,6 +39931,7 @@ var init_browser = __esm(() => {
|
|
|
39853
39931
|
init_bot_transaction();
|
|
39854
39932
|
init_src();
|
|
39855
39933
|
init_profile_dir2();
|
|
39934
|
+
init_profile_dir2();
|
|
39856
39935
|
init_profile_lease();
|
|
39857
39936
|
init_browser_anti_detection();
|
|
39858
39937
|
init_bot();
|
|
@@ -41072,6 +41151,7 @@ async function replayBotSession(bot, transcript, options) {
|
|
|
41072
41151
|
return { bot, rows, stoppedBeforeSubmit: false };
|
|
41073
41152
|
}
|
|
41074
41153
|
async function replayBot(bot, transcript, options = {}) {
|
|
41154
|
+
await Promise.resolve().then(() => init_browser());
|
|
41075
41155
|
await Promise.resolve().then(() => init_browser());
|
|
41076
41156
|
const { mkdirSync } = await import("fs");
|
|
41077
41157
|
const { join } = await import("path");
|
|
@@ -41080,11 +41160,22 @@ async function replayBot(bot, transcript, options = {}) {
|
|
|
41080
41160
|
const profileDir = resolveBotProfileDir(bot, { root: options.root });
|
|
41081
41161
|
const outDir = options.outDir ?? join(".spur", "run", `bot-replay-${bot}`);
|
|
41082
41162
|
mkdirSync(outDir, { recursive: true });
|
|
41083
|
-
const lease = await acquireProfileLease(profileDir, { leaseRoot: options.leaseRoot, fileSystem });
|
|
41084
41163
|
let context;
|
|
41164
|
+
const leaseRef = {};
|
|
41165
|
+
const shutdown = signalSafeRelease({
|
|
41166
|
+
close: () => closeBotContext(context),
|
|
41167
|
+
release: () => leaseRef.current?.release() ?? Promise.resolve()
|
|
41168
|
+
});
|
|
41169
|
+
const lease = await acquireProfileLease(profileDir, { leaseRoot: options.leaseRoot, fileSystem }).catch(async (error) => {
|
|
41170
|
+
await shutdown.shutdown();
|
|
41171
|
+
throw error;
|
|
41172
|
+
});
|
|
41173
|
+
leaseRef.current = lease;
|
|
41174
|
+
let unpark;
|
|
41085
41175
|
try {
|
|
41086
41176
|
const launcher = options.launcher ?? createKkBrowserLauncher(undefined, { lease, physicalProfileDir: profileDir }, { leaseRoot: options.leaseRoot, fileSystem });
|
|
41087
41177
|
context = await launcher.launch({ profileDir, headless: false });
|
|
41178
|
+
unpark = shutdown.park();
|
|
41088
41179
|
const page = await openBotPage(context);
|
|
41089
41180
|
const shots = [];
|
|
41090
41181
|
const result = await replayBotSession(bot, transcript, {
|
|
@@ -41104,8 +41195,8 @@ async function replayBot(bot, transcript, options = {}) {
|
|
|
41104
41195
|
`);
|
|
41105
41196
|
return { result, outDir, replayPath };
|
|
41106
41197
|
} finally {
|
|
41107
|
-
await
|
|
41108
|
-
|
|
41198
|
+
await shutdown.shutdown();
|
|
41199
|
+
unpark?.();
|
|
41109
41200
|
}
|
|
41110
41201
|
}
|
|
41111
41202
|
var UNREACHABLE = '[aria-hidden="true"], [inert]';
|
|
@@ -43237,7 +43328,7 @@ var ConfigError = class extends Error {
|
|
|
43237
43328
|
}
|
|
43238
43329
|
};
|
|
43239
43330
|
|
|
43240
|
-
// ../../node_modules/.bun/@gobing-ai+ts-infra@0.
|
|
43331
|
+
// ../../node_modules/.bun/@gobing-ai+ts-infra@0.8.4+5042690a1c1c0ae5/node_modules/@gobing-ai/ts-infra/dist/logger.js
|
|
43241
43332
|
var ROOT_CATEGORY = "app";
|
|
43242
43333
|
function toLogTapeLevel(level) {
|
|
43243
43334
|
return level === "warn" ? "warning" : level;
|
|
@@ -43927,6 +44018,17 @@ function pluginEnvFromConfig(kind, name, configFile = resolveKkConfigPath()) {
|
|
|
43927
44018
|
break;
|
|
43928
44019
|
}
|
|
43929
44020
|
}
|
|
44021
|
+
if (name === "surfdash-pub") {
|
|
44022
|
+
const podcastNode = collectionNode["podcast-pub"];
|
|
44023
|
+
if (isPlainObject5(podcastNode) && isPlainObject5(podcastNode.env)) {
|
|
44024
|
+
for (const key of ["MICROFEED_BASE_URL", "MICROFEED_API_KEY"]) {
|
|
44025
|
+
const inherited = stringifyEnvValue(podcastNode.env[key]);
|
|
44026
|
+
if (inherited !== undefined && inherited !== "") {
|
|
44027
|
+
out[key] = inherited;
|
|
44028
|
+
}
|
|
44029
|
+
}
|
|
44030
|
+
}
|
|
44031
|
+
}
|
|
43930
44032
|
}
|
|
43931
44033
|
const pluginNode = collectionNode[name];
|
|
43932
44034
|
if (!isPlainObject5(pluginNode) || !isPlainObject5(pluginNode.env)) {
|
|
@@ -44002,7 +44104,8 @@ async function spawnPluginSession(opts) {
|
|
|
44002
44104
|
env: pluginEntryEnv(opts),
|
|
44003
44105
|
stdin: "inherit",
|
|
44004
44106
|
stdout: "pipe",
|
|
44005
|
-
stderr: "inherit"
|
|
44107
|
+
stderr: "inherit",
|
|
44108
|
+
...opts.signal === undefined ? {} : { signal: opts.signal }
|
|
44006
44109
|
});
|
|
44007
44110
|
} catch {
|
|
44008
44111
|
return null;
|
|
@@ -45514,11 +45617,11 @@ async function resolveStorePath(configFile, explicitPath) {
|
|
|
45514
45617
|
// ../../packages/kk-store/src/dao/collect-runs.ts
|
|
45515
45618
|
init_dist5();
|
|
45516
45619
|
|
|
45517
|
-
// ../../node_modules/.bun/@gobing-ai+ts-db@0.
|
|
45620
|
+
// ../../node_modules/.bun/@gobing-ai+ts-db@0.8.4+5cdeb656394cd753/node_modules/@gobing-ai/ts-db/dist/schema/index.js
|
|
45518
45621
|
init_sqlite_core();
|
|
45519
45622
|
init_common2();
|
|
45520
45623
|
|
|
45521
|
-
// ../../node_modules/.bun/@gobing-ai+ts-db@0.
|
|
45624
|
+
// ../../node_modules/.bun/@gobing-ai+ts-db@0.8.4+5cdeb656394cd753/node_modules/@gobing-ai/ts-db/dist/schema/define-table.js
|
|
45522
45625
|
init_sqlite_core();
|
|
45523
45626
|
|
|
45524
45627
|
// ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/index.js
|
|
@@ -45790,10 +45893,10 @@ var createInsertSchema = (entity, refine) => {
|
|
|
45790
45893
|
return handleColumns(columns, refine ?? {}, insertConditions);
|
|
45791
45894
|
};
|
|
45792
45895
|
|
|
45793
|
-
// ../../node_modules/.bun/@gobing-ai+ts-db@0.
|
|
45896
|
+
// ../../node_modules/.bun/@gobing-ai+ts-db@0.8.4+5cdeb656394cd753/node_modules/@gobing-ai/ts-db/dist/schema/ddl.js
|
|
45794
45897
|
init_sqlite_core();
|
|
45795
45898
|
|
|
45796
|
-
// ../../node_modules/.bun/@gobing-ai+ts-db@0.
|
|
45899
|
+
// ../../node_modules/.bun/@gobing-ai+ts-db@0.8.4+5cdeb656394cd753/node_modules/@gobing-ai/ts-db/dist/schema/drizzle-internals.js
|
|
45797
45900
|
function sqlExpressionToText(value) {
|
|
45798
45901
|
if (typeof value !== "object" || value === null || !("queryChunks" in value)) {
|
|
45799
45902
|
return;
|
|
@@ -45816,7 +45919,7 @@ function getDrizzleTableName(table) {
|
|
|
45816
45919
|
return String(table[nameSym]);
|
|
45817
45920
|
}
|
|
45818
45921
|
|
|
45819
|
-
// ../../node_modules/.bun/@gobing-ai+ts-db@0.
|
|
45922
|
+
// ../../node_modules/.bun/@gobing-ai+ts-db@0.8.4+5cdeb656394cd753/node_modules/@gobing-ai/ts-db/dist/schema/ddl.js
|
|
45820
45923
|
function quoteIdent(name) {
|
|
45821
45924
|
return `"${name.replace(/"/g, '""')}"`;
|
|
45822
45925
|
}
|
|
@@ -45907,7 +46010,7 @@ function generateCreateTableSql(table) {
|
|
|
45907
46010
|
)`;
|
|
45908
46011
|
}
|
|
45909
46012
|
|
|
45910
|
-
// ../../node_modules/.bun/@gobing-ai+ts-db@0.
|
|
46013
|
+
// ../../node_modules/.bun/@gobing-ai+ts-db@0.8.4+5cdeb656394cd753/node_modules/@gobing-ai/ts-db/dist/schema/define-table.js
|
|
45911
46014
|
function defineTable(name, columns) {
|
|
45912
46015
|
const table = sqliteTable(name, columns);
|
|
45913
46016
|
let insert;
|
|
@@ -49508,13 +49611,20 @@ async function sendRows(options) {
|
|
|
49508
49611
|
if (retry) {
|
|
49509
49612
|
if (!await fs.exists(targetReceiptPath))
|
|
49510
49613
|
continue;
|
|
49614
|
+
let priorRetry;
|
|
49511
49615
|
try {
|
|
49512
|
-
|
|
49513
|
-
if (priorReceipt.status === "succeeded" || priorReceipt.effect !== "none")
|
|
49514
|
-
continue;
|
|
49616
|
+
priorRetry = JSON.parse(await fs.readFile(targetReceiptPath));
|
|
49515
49617
|
} catch {
|
|
49516
49618
|
continue;
|
|
49517
49619
|
}
|
|
49620
|
+
if (priorRetry.status === "succeeded")
|
|
49621
|
+
continue;
|
|
49622
|
+
if (priorRetry.effect !== "none") {
|
|
49623
|
+
const unknownEffect = (priorRetry.status === "uncertain" || priorRetry.effect === "unknown") && (row.mode === "live" || priorRetry.mode === "live");
|
|
49624
|
+
if (!unknownEffect || options.confirmNone !== true)
|
|
49625
|
+
continue;
|
|
49626
|
+
echoError(`${label}: ${row.key} re-attempted on the operator's confirmation that the unknown-effect attempt published nothing (--confirm-none)`);
|
|
49627
|
+
}
|
|
49518
49628
|
reattempt = true;
|
|
49519
49629
|
} else if (await fs.exists(targetReceiptPath)) {
|
|
49520
49630
|
const priorRaw = await fs.exists(targetReceiptPath) ? await fs.readFile(targetReceiptPath) : undefined;
|
|
@@ -50097,7 +50207,7 @@ class UnknownChannelModeError extends Error {
|
|
|
50097
50207
|
}
|
|
50098
50208
|
}
|
|
50099
50209
|
function targetMatchesChannel(target, token) {
|
|
50100
|
-
return target.plugin === token || target.id === token || target.variant !== undefined && `${target.plugin}/${target.variant}` === token;
|
|
50210
|
+
return target.plugin === token || target.id === token || targetId(target) === token || target.variant !== undefined && `${target.plugin}/${target.variant}` === token;
|
|
50101
50211
|
}
|
|
50102
50212
|
function validatePublishChannelTokens(preset, tokens) {
|
|
50103
50213
|
for (const token of tokens) {
|
|
@@ -50325,7 +50435,7 @@ async function composePlan(fs, input) {
|
|
|
50325
50435
|
throw new Error(`channel '${liveToken}' is dummy-only and cannot be promoted to live`);
|
|
50326
50436
|
}
|
|
50327
50437
|
const mode = input.dummy ? "dummy" : liveToken !== undefined || target.mode === "live" ? "live" : target.mode === "dummy" ? "dummy" : "draft";
|
|
50328
|
-
if (mode === "live" && safety === undefined) {
|
|
50438
|
+
if (mode === "live" && safety === undefined && bundle.contentType === "news") {
|
|
50329
50439
|
throw new Error(`bundle has no final-variant safety evidence; run the variants safety gate (kk-daily-safety scope=variants) before a live launch`);
|
|
50330
50440
|
}
|
|
50331
50441
|
if (target.variant === undefined) {
|
|
@@ -50360,7 +50470,17 @@ async function composePlan(fs, input) {
|
|
|
50360
50470
|
delete inherited.publishStatus;
|
|
50361
50471
|
delete inherited.published;
|
|
50362
50472
|
delete inherited.status;
|
|
50363
|
-
const nativeMode = mode === "live" ? {
|
|
50473
|
+
const nativeMode = mode === "live" ? {
|
|
50474
|
+
"surfdash-pub": { published: true },
|
|
50475
|
+
"podcast-pub": { status: "published" },
|
|
50476
|
+
"qiita-pub": { private: false, published: true },
|
|
50477
|
+
"zenn-pub": { published: true }
|
|
50478
|
+
} : {
|
|
50479
|
+
"surfdash-pub": { published: false },
|
|
50480
|
+
"podcast-pub": { status: "unpublished" },
|
|
50481
|
+
"qiita-pub": { private: true, published: false },
|
|
50482
|
+
"zenn-pub": { published: false }
|
|
50483
|
+
};
|
|
50364
50484
|
const payload = {
|
|
50365
50485
|
...parsedContent.data,
|
|
50366
50486
|
metadata: {
|
|
@@ -50373,6 +50493,7 @@ async function composePlan(fs, input) {
|
|
|
50373
50493
|
const payloadRelative = `4-publish/payloads/content.${id}.json`;
|
|
50374
50494
|
const payloadText = `${JSON.stringify(payload, null, 2)}
|
|
50375
50495
|
`;
|
|
50496
|
+
const explicitlySelected = mode !== "dummy" && (liveToken !== undefined || input.channels.some((token) => matches(target, token)));
|
|
50376
50497
|
rows.push({
|
|
50377
50498
|
id,
|
|
50378
50499
|
plugin: target.plugin,
|
|
@@ -50381,7 +50502,7 @@ async function composePlan(fs, input) {
|
|
|
50381
50502
|
tier: target.tier ?? 3,
|
|
50382
50503
|
window: input.window,
|
|
50383
50504
|
mode,
|
|
50384
|
-
required: target.required ?? false,
|
|
50505
|
+
required: (target.required ?? false) || explicitlySelected,
|
|
50385
50506
|
approval: mode === "live" ? "required" : "none",
|
|
50386
50507
|
status: "planned",
|
|
50387
50508
|
...target.transport !== undefined ? { transport: target.transport } : {},
|
|
@@ -50882,6 +51003,30 @@ async function readLinkMap(fs, publishDir, plan) {
|
|
|
50882
51003
|
}
|
|
50883
51004
|
return { real, live, all };
|
|
50884
51005
|
}
|
|
51006
|
+
async function readPodcastTier0AssetLinks(fs, receiptsDir, parentRunId, consumerMode) {
|
|
51007
|
+
if (!await fs.exists(receiptsDir))
|
|
51008
|
+
return null;
|
|
51009
|
+
for (const name of (await fs.readDir(receiptsDir)).filter((entry) => entry.endsWith(".json"))) {
|
|
51010
|
+
try {
|
|
51011
|
+
const receipt = JSON.parse(await fs.readFile(join10(receiptsDir, name)));
|
|
51012
|
+
if (receipt.plugin !== "podcast-pub" || receipt.parentRunId !== parentRunId || receipt.status !== "succeeded" || receipt.dummy === true || consumerMode === "live" && receipt.mode !== "live" || receipt.aggregatePath === undefined) {
|
|
51013
|
+
continue;
|
|
51014
|
+
}
|
|
51015
|
+
if (!await fs.exists(receipt.aggregatePath))
|
|
51016
|
+
continue;
|
|
51017
|
+
const aggregate = JSON.parse(await fs.readFile(receipt.aggregatePath));
|
|
51018
|
+
const first = aggregate.targets?.[0];
|
|
51019
|
+
const rawImage = typeof first?.metadata?.imageUrl === "string" ? first.metadata.imageUrl : undefined;
|
|
51020
|
+
const rawUrl = typeof first?.url === "string" ? first.url : receipt.url;
|
|
51021
|
+
const imageUrl = rawImage !== undefined && /^https:\/\//.test(rawImage) ? rawImage : undefined;
|
|
51022
|
+
const podcastUrl = rawUrl !== undefined && /^https:\/\//.test(rawUrl) ? rawUrl : undefined;
|
|
51023
|
+
if (imageUrl !== undefined || podcastUrl !== undefined) {
|
|
51024
|
+
return { ...imageUrl ? { imageUrl } : {}, ...podcastUrl ? { podcastUrl } : {} };
|
|
51025
|
+
}
|
|
51026
|
+
} catch {}
|
|
51027
|
+
}
|
|
51028
|
+
return null;
|
|
51029
|
+
}
|
|
50885
51030
|
async function readOwnerReceipts(fs, publishDir) {
|
|
50886
51031
|
const receiptsDir = join10(publishDir, "receipts");
|
|
50887
51032
|
if (!await fs.exists(receiptsDir))
|
|
@@ -51064,8 +51209,36 @@ async function sendPublishMatrix(args, deps = {}) {
|
|
|
51064
51209
|
...deps.dispatch ? { dispatch: deps.dispatch } : {},
|
|
51065
51210
|
dummyReceipt: (row, context) => writeDummyReceipt(fs, row, { ...context, parentRunId: plan.parentRunId, planDigest }),
|
|
51066
51211
|
preparePayload: async (row) => {
|
|
51067
|
-
if (tier === 0)
|
|
51212
|
+
if (tier === 0) {
|
|
51213
|
+
if (row.plugin === "surfdash-pub" && await fs.exists(row.payloadPath)) {
|
|
51214
|
+
const rawDigest = createHash2("sha256").update(await fs.readFile(row.payloadPath)).digest("hex");
|
|
51215
|
+
const priorReceiptPath = join10(receiptsDir, `${row.key}.json`);
|
|
51216
|
+
if (await fs.exists(priorReceiptPath)) {
|
|
51217
|
+
try {
|
|
51218
|
+
const prior = JSON.parse(await fs.readFile(priorReceiptPath));
|
|
51219
|
+
if (prior.status === "succeeded" && prior.dummy !== true && prior.parentRunId === plan.parentRunId && prior.payloadDigest === rawDigest) {
|
|
51220
|
+
return { payloadPath: row.payloadPath };
|
|
51221
|
+
}
|
|
51222
|
+
} catch {}
|
|
51223
|
+
}
|
|
51224
|
+
const podcastLinks = await readPodcastTier0AssetLinks(fs, receiptsDir, plan.parentRunId, row.mode);
|
|
51225
|
+
if (podcastLinks !== null) {
|
|
51226
|
+
const parsed = JSON.parse(await fs.readFile(row.payloadPath));
|
|
51227
|
+
const nextMetadata = { ...parsed.metadata ?? {} };
|
|
51228
|
+
if (podcastLinks.imageUrl !== undefined) {
|
|
51229
|
+
nextMetadata.coverImage = podcastLinks.imageUrl;
|
|
51230
|
+
}
|
|
51231
|
+
if (podcastLinks.podcastUrl !== undefined) {
|
|
51232
|
+
nextMetadata.podcastUrl = podcastLinks.podcastUrl;
|
|
51233
|
+
}
|
|
51234
|
+
const resolvedPath = join10(workDir, "4-publish", "payloads", `content.${row.key}.resolved.json`);
|
|
51235
|
+
await fs.writeFile(resolvedPath, `${JSON.stringify({ ...parsed, metadata: nextMetadata }, null, 2)}
|
|
51236
|
+
`);
|
|
51237
|
+
return { payloadPath: resolvedPath };
|
|
51238
|
+
}
|
|
51239
|
+
}
|
|
51068
51240
|
return { payloadPath: row.payloadPath };
|
|
51241
|
+
}
|
|
51069
51242
|
const raw = await fs.exists(row.payloadPath) ? await fs.readFile(row.payloadPath) : "";
|
|
51070
51243
|
const links = row.mode === "dummy" ? linkMaps.all : row.mode === "live" ? linkMaps.live : linkMaps.real;
|
|
51071
51244
|
let cardLink;
|
|
@@ -53596,7 +53769,8 @@ function bindAdapterSession(candidate) {
|
|
|
53596
53769
|
url: request.url,
|
|
53597
53770
|
extraEnv: request.env,
|
|
53598
53771
|
pluginKind: record.kind,
|
|
53599
|
-
pluginName: record.name
|
|
53772
|
+
pluginName: record.name,
|
|
53773
|
+
...request.signal === undefined ? {} : { signal: request.signal }
|
|
53600
53774
|
});
|
|
53601
53775
|
}
|
|
53602
53776
|
};
|
|
@@ -56613,10 +56787,14 @@ async function validatePreset(fs, presetName, variants) {
|
|
|
56613
56787
|
}
|
|
56614
56788
|
async function runFreezeStage(input, fs) {
|
|
56615
56789
|
const bundlePath = join28(input.workDir, PUBLISH_DIR, "bundle.json");
|
|
56616
|
-
const
|
|
56617
|
-
|
|
56618
|
-
|
|
56619
|
-
|
|
56790
|
+
const request = await readJson3(fs, join28(input.workDir, REQUEST_FILE));
|
|
56791
|
+
const seededFromFile = typeof request?.from === "string" && request.from.trim() !== "";
|
|
56792
|
+
if (!seededFromFile) {
|
|
56793
|
+
const completed = await deps.runItc(["itc-author-complete", input.workDir, input.runId]);
|
|
56794
|
+
if (completed !== 0) {
|
|
56795
|
+
echoError(`kk generate-bundle: itc-author-complete failed (exit ${completed}) for ${input.workDir}`);
|
|
56796
|
+
return 1;
|
|
56797
|
+
}
|
|
56620
56798
|
}
|
|
56621
56799
|
const content = await readJson3(fs, join28(input.workDir, PUBLISH_DIR, CONTENT_FILE));
|
|
56622
56800
|
if (content === null) {
|
|
@@ -56628,13 +56806,23 @@ async function runFreezeStage(input, fs) {
|
|
|
56628
56806
|
echoError(`kk generate-bundle: ${join28(input.workDir, PUBLISH_DIR, CONTENT_FILE)} has no title; the draft's H1 is the bundle title`);
|
|
56629
56807
|
return 1;
|
|
56630
56808
|
}
|
|
56631
|
-
const sourceLocale = typeof content.sourceLocale === "string" ? content.sourceLocale : "en";
|
|
56809
|
+
const sourceLocale = typeof content.sourceLocale === "string" ? content.sourceLocale : typeof request?.locale === "string" ? request.locale : "en";
|
|
56632
56810
|
const variants = {};
|
|
56633
56811
|
for (const [key, variant] of Object.entries(generationVariants(content))) {
|
|
56634
56812
|
if (!variant.adapt)
|
|
56635
56813
|
continue;
|
|
56636
56814
|
variants[key] = await variantEntry(fs, input.workDir, variant.file);
|
|
56637
56815
|
}
|
|
56816
|
+
if (isObject3(request?.variants)) {
|
|
56817
|
+
for (const name of Object.keys(request.variants)) {
|
|
56818
|
+
if (variants[name] !== undefined)
|
|
56819
|
+
continue;
|
|
56820
|
+
const file = `content.${name}.json`;
|
|
56821
|
+
if (await fs.exists(join28(input.workDir, PUBLISH_DIR, file))) {
|
|
56822
|
+
variants[name] = await variantEntry(fs, input.workDir, file);
|
|
56823
|
+
}
|
|
56824
|
+
}
|
|
56825
|
+
}
|
|
56638
56826
|
const source = await variantEntry(fs, input.workDir, CONTENT_FILE);
|
|
56639
56827
|
variants.article = source;
|
|
56640
56828
|
variants[`${sourceLocale}-article`] = source;
|
|
@@ -57198,7 +57386,20 @@ async function countFiles(ctx, dir, suffix) {
|
|
|
57198
57386
|
const path = join29(ctx.workDir, dir);
|
|
57199
57387
|
if (!await ctx.fs.exists(path))
|
|
57200
57388
|
return 0;
|
|
57201
|
-
|
|
57389
|
+
let count = 0;
|
|
57390
|
+
for (const entry of await ctx.fs.readDir(path)) {
|
|
57391
|
+
if (entry.endsWith(suffix)) {
|
|
57392
|
+
count += 1;
|
|
57393
|
+
continue;
|
|
57394
|
+
}
|
|
57395
|
+
const nested = join29(path, entry);
|
|
57396
|
+
if (!await ctx.fs.exists(nested))
|
|
57397
|
+
continue;
|
|
57398
|
+
try {
|
|
57399
|
+
count += (await ctx.fs.readDir(nested)).filter((child) => child.endsWith(suffix)).length;
|
|
57400
|
+
} catch {}
|
|
57401
|
+
}
|
|
57402
|
+
return count;
|
|
57202
57403
|
}
|
|
57203
57404
|
var newsVariantsStage = (ctx) => ctx.noun === "news" && ctx.bundleStage === "variants";
|
|
57204
57405
|
var GENERATE_ROWS = [
|
|
@@ -57709,7 +57910,7 @@ async function runPreflight(deps, context) {
|
|
|
57709
57910
|
...await diffDirs(deps, join30(context.harnessRoot, "plugins", "kk", "scripts"), join30(install, "plugins", "kk", "scripts"))
|
|
57710
57911
|
];
|
|
57711
57912
|
if (diffs.length > 0) {
|
|
57712
|
-
reasons.push(`checkout diverges from installed kk (${install}): ${diffs.join("; ")}`);
|
|
57913
|
+
reasons.push(`checkout diverges from installed kk (${install}): ${diffs.join("; ")} \u2014 refresh the stale side: \`bun scripts/bundle-plugins.ts\` in a checkout, or reinstall the package when the install is behind`);
|
|
57713
57914
|
}
|
|
57714
57915
|
}
|
|
57715
57916
|
const target = context.agent === "inline" ? "scribe" : context.agent;
|
|
@@ -58114,10 +58315,8 @@ function validateLiveTokens(preset, window, tokens, presetName) {
|
|
|
58114
58315
|
fail2(5, "kk.content.publish", `cannot validate --live-channels: preset '${presetName}' was not found`);
|
|
58115
58316
|
}
|
|
58116
58317
|
const inWindow = (preset.targets ?? []).filter((target) => (target.window ?? "after-generate") === window);
|
|
58117
|
-
const
|
|
58118
|
-
|
|
58119
|
-
return row === undefined || (row.mode ?? "draft") === "off";
|
|
58120
|
-
});
|
|
58318
|
+
const computedId = (target) => target.id ?? (target.plugin && target.operation ? `${target.plugin}.${target.operation.trim().replace(/[\s/]+/g, "-")}` : target.plugin);
|
|
58319
|
+
const refused = tokens.filter((token) => !inWindow.some((target) => (target.plugin === token || target.id === token || computedId(target) === token) && (target.mode ?? "draft") !== "off"));
|
|
58121
58320
|
if (refused.length > 0) {
|
|
58122
58321
|
fail2(5, "kk.content.publish", `live token(s) ${refused.join(", ")} have no active row in window '${window}' of preset '${presetName}'`);
|
|
58123
58322
|
}
|
|
@@ -58127,6 +58326,22 @@ async function readPreset(presetName, fs) {
|
|
|
58127
58326
|
const path = join31(root, "plugins", "kk", "publish-presets", `${presetName}.json`);
|
|
58128
58327
|
return await readJson4(fs, path);
|
|
58129
58328
|
}
|
|
58329
|
+
var INLINE_FIGURE_OPERATION = "\u6587\u7AE0";
|
|
58330
|
+
var INLINE_FIGURE_VARIANT = "article";
|
|
58331
|
+
function targetSelectedBy(target, tokens) {
|
|
58332
|
+
return tokens.some((token) => target.plugin === token || target.id === token || target.plugin !== undefined && target.variant !== undefined && `${target.plugin}/${target.variant}` === token);
|
|
58333
|
+
}
|
|
58334
|
+
function inlineFigureRefusal(presetName, targets, channels) {
|
|
58335
|
+
const rows = targets.filter((target) => target.plugin === "wechatmp-pub" && target.operation === INLINE_FIGURE_OPERATION && target.variant === INLINE_FIGURE_VARIANT);
|
|
58336
|
+
const enabled = rows.filter((target) => target.mode !== undefined && target.mode !== "off");
|
|
58337
|
+
if (enabled.length === 0) {
|
|
58338
|
+
return rows.length === 0 ? `--inline-illustrations: preset '${presetName}' declares no wechatmp-pub ${INLINE_FIGURE_OPERATION} (${INLINE_FIGURE_VARIANT}) target to carry the figures` : `--inline-illustrations: no enabled wechatmp-pub ${INLINE_FIGURE_OPERATION} (${INLINE_FIGURE_VARIANT}) target in preset '${presetName}'`;
|
|
58339
|
+
}
|
|
58340
|
+
if (channels !== undefined && channels.length > 0 && !enabled.some((target) => targetSelectedBy(target, channels))) {
|
|
58341
|
+
return `--inline-illustrations: --channels (${channels.join(", ")}) excludes the wechatmp-pub ${INLINE_FIGURE_OPERATION} (${INLINE_FIGURE_VARIANT}) target, so no article would carry the figures`;
|
|
58342
|
+
}
|
|
58343
|
+
return null;
|
|
58344
|
+
}
|
|
58130
58345
|
async function generateAction(noun, defaultType, options) {
|
|
58131
58346
|
const fs = createNodeFileSystem();
|
|
58132
58347
|
const type = options.type ?? defaultType;
|
|
@@ -58146,7 +58361,21 @@ async function generateAction(noun, defaultType, options) {
|
|
|
58146
58361
|
const workflowPath = await resolveWorkflowPath(resolved.workflow, config, fs);
|
|
58147
58362
|
const channels = channelList(options.channels);
|
|
58148
58363
|
const liveChannels = channelList(options.liveChannels);
|
|
58364
|
+
const packageRoot = await resolvePackageRoot(fs);
|
|
58149
58365
|
const vars = { skill_dir: resolved.skillDir, preset: resolved.publish_preset };
|
|
58366
|
+
if (type === "news")
|
|
58367
|
+
vars.visual_skill_root = join31(packageRoot, "plugins", "kk", "skills");
|
|
58368
|
+
if (options.inlineIllustrations === true) {
|
|
58369
|
+
if (type !== "news") {
|
|
58370
|
+
fail2(2, "kk.content.generate", `'--inline-illustrations' is news-only: the '${type}' workflow declares no inline-figure stage`);
|
|
58371
|
+
}
|
|
58372
|
+
const preset = await readPreset(resolved.publish_preset, fs);
|
|
58373
|
+
const selected = channels === undefined ? undefined : channels.split(",").map((token) => token.trim());
|
|
58374
|
+
const refusal = inlineFigureRefusal(resolved.publish_preset, preset?.targets ?? [], selected);
|
|
58375
|
+
if (refusal !== null)
|
|
58376
|
+
fail2(5, "kk.content.generate", refusal);
|
|
58377
|
+
vars.inline_illustrations = "true";
|
|
58378
|
+
}
|
|
58150
58379
|
if (options.skipReview === true)
|
|
58151
58380
|
vars.skip_review = "true";
|
|
58152
58381
|
if (options.auto === true) {
|
|
@@ -58155,6 +58384,16 @@ async function generateAction(noun, defaultType, options) {
|
|
|
58155
58384
|
}
|
|
58156
58385
|
vars.auto = "true";
|
|
58157
58386
|
}
|
|
58387
|
+
if (options.adaptOnly === true) {
|
|
58388
|
+
if (type !== "itc") {
|
|
58389
|
+
fail2(2, "kk.content.generate", `--adapt-only is article-only: the '${type}' workflow declares no 'adapt_only' var`);
|
|
58390
|
+
}
|
|
58391
|
+
const draftPath = join31(run.workDir, "3-draft-draft-article.md");
|
|
58392
|
+
if (!await fs.exists(draftPath)) {
|
|
58393
|
+
fail2(5, "kk.content.generate", `--adapt-only requires an existing draft at ${draftPath}; seed with \`kk article new --from <file.md>\` first`);
|
|
58394
|
+
}
|
|
58395
|
+
vars.adapt_only = "true";
|
|
58396
|
+
}
|
|
58158
58397
|
const receipt = await launchWorkflow({
|
|
58159
58398
|
type,
|
|
58160
58399
|
workflow: resolved.workflow,
|
|
@@ -58162,7 +58401,7 @@ async function generateAction(noun, defaultType, options) {
|
|
|
58162
58401
|
run: run.run,
|
|
58163
58402
|
workDir: run.workDir,
|
|
58164
58403
|
worksDir,
|
|
58165
|
-
harnessRoot:
|
|
58404
|
+
harnessRoot: packageRoot,
|
|
58166
58405
|
identityVar: type === "news" ? "run_date" : "slug",
|
|
58167
58406
|
vars,
|
|
58168
58407
|
writerSkill: { dir: resolved.skillDir, sha256: resolved.skillSha256 },
|
|
@@ -58255,6 +58494,24 @@ async function publishRun(settings) {
|
|
|
58255
58494
|
}
|
|
58256
58495
|
}
|
|
58257
58496
|
}
|
|
58497
|
+
if (bundle === null && type !== "news" && settings.dryRun !== true) {
|
|
58498
|
+
const request = await readJson4(fs, join31(run.workDir, "request.json"));
|
|
58499
|
+
if (typeof request?.from === "string" && request.from.trim() !== "" && await fs.exists(join31(publishDir, "content.json"))) {
|
|
58500
|
+
const frozen = await runArticleBundle({
|
|
58501
|
+
workDir: run.workDir,
|
|
58502
|
+
type,
|
|
58503
|
+
runId: `kk-content-${run.run}`,
|
|
58504
|
+
preset: presetName,
|
|
58505
|
+
maxRevisions: DEFAULT_MAX_REVISIONS,
|
|
58506
|
+
step: "",
|
|
58507
|
+
bundleStage: "freeze"
|
|
58508
|
+
}, fs);
|
|
58509
|
+
if (frozen.code !== 0) {
|
|
58510
|
+
fail2(5, "kk.content.publish", `failed to freeze seeded article bundle in ${run.workDir}`);
|
|
58511
|
+
}
|
|
58512
|
+
bundle = await readJson4(fs, await resolveBundlePath(fs, run.workDir));
|
|
58513
|
+
}
|
|
58514
|
+
}
|
|
58258
58515
|
if (bundle === null && settings.dryRun !== true) {
|
|
58259
58516
|
fail2(5, "kk.content.publish", `no publishable bundle at ${bundlePath}`);
|
|
58260
58517
|
}
|
|
@@ -58295,6 +58552,7 @@ async function publishRun(settings) {
|
|
|
58295
58552
|
receiptPath,
|
|
58296
58553
|
...settings.agent === undefined ? {} : { agent: settings.agent },
|
|
58297
58554
|
...settings.timeoutMs === undefined ? {} : { timeoutMs: settings.timeoutMs },
|
|
58555
|
+
...settings.allowDirty === undefined ? {} : { allowDirty: settings.allowDirty },
|
|
58298
58556
|
...settings.dryRun === undefined ? {} : { dryRun: settings.dryRun }
|
|
58299
58557
|
});
|
|
58300
58558
|
if (receipt.dryRun === undefined || planned.length === 0)
|
|
@@ -58358,6 +58616,7 @@ async function publishAction(noun, defaultType, options) {
|
|
|
58358
58616
|
...options.retry === undefined ? {} : { retry: options.retry },
|
|
58359
58617
|
...options.agent === undefined ? {} : { agent: options.agent },
|
|
58360
58618
|
...timeoutMs === undefined ? {} : { timeoutMs },
|
|
58619
|
+
...options.allowDirty === undefined ? {} : { allowDirty: options.allowDirty },
|
|
58361
58620
|
...options.dryRun === undefined ? {} : { dryRun: options.dryRun }
|
|
58362
58621
|
});
|
|
58363
58622
|
const code = reportReceipt(receipt);
|
|
@@ -58370,7 +58629,7 @@ function configureGenerate(command, noun, defaultType) {
|
|
|
58370
58629
|
} else {
|
|
58371
58630
|
command.option("--run-date <YYYYMMDD>", "news run date");
|
|
58372
58631
|
}
|
|
58373
|
-
command.option("--agent <executor>", "executor the workflow dispatches to (default: inline)").option("--skip-review", "skip the workflow review pause").option("--auto", "skip the human gates (article only)").option("--publish", "launch publish for window after-generate once generation is green").option("--channels <a,b>", "publish plan rows or plugins to include").option("--live-channels <a,b>", "promote enabled rows to live; off rows stay disabled").option("--timeout-ms <n>", "deadline for the workflow child in milliseconds").option("--allow-dirty", "launch even when harness paths are dirty").option("--dry-run", "run the preflight and print the planned launch without taking the lock").action((options) => generateAction(noun, defaultType, options));
|
|
58632
|
+
command.option("--agent <executor>", "executor the workflow dispatches to (default: inline)").option("--skip-review", "skip the workflow review pause").option("--auto", "skip the human gates (article only)").option("--inline-illustrations", "render figures inline in the WeChat article (news only)").option("--adapt-only", "skip authoring and run adapt + freeze over an existing draft (article only)").option("--publish", "launch publish for window after-generate once generation is green").option("--channels <a,b>", "publish plan rows or plugins to include").option("--live-channels <a,b>", "promote enabled rows to live; off rows stay disabled").option("--timeout-ms <n>", "deadline for the workflow child in milliseconds").option("--allow-dirty", "launch even when harness paths are dirty").option("--dry-run", "run the preflight and print the planned launch without taking the lock").action((options) => generateAction(noun, defaultType, options));
|
|
58374
58633
|
}
|
|
58375
58634
|
function configurePublish(command, noun, defaultType) {
|
|
58376
58635
|
if (noun === "article") {
|
|
@@ -58378,7 +58637,7 @@ function configurePublish(command, noun, defaultType) {
|
|
|
58378
58637
|
} else {
|
|
58379
58638
|
command.option("--run-date <YYYYMMDD>", "news run date");
|
|
58380
58639
|
}
|
|
58381
|
-
command.option("--work-dir <dir>", "explicit run directory").option("--window <window>", `publish window (${PUBLISH_WINDOWS2.join("|")})`, "after-generate").option("--preset <name>", "publish preset").option("--channels <a,b>", "plan rows or plugins to include").option("--live-channels <a,b>", "promote enabled rows to live; off rows stay disabled").option("--live-confirm", "pause for live approval before sending").option("--dummy", "plan and validate every row without dispatching").option("--retry", "retry the rows a previous window left failed").option("--agent <executor>", "executor the workflow dispatches to (default: inline)").option("--unattended", "scheduled posture: generate once when the bundle is missing").option("--yes", "consent to that one generate without --unattended").option("--timeout-ms <n>", "deadline for the workflow child in milliseconds").option("--dry-run", "run the preflight and print the planned launch without taking the lock").action((options) => publishAction(noun, defaultType, options));
|
|
58640
|
+
command.option("--work-dir <dir>", "explicit run directory").option("--window <window>", `publish window (${PUBLISH_WINDOWS2.join("|")})`, "after-generate").option("--preset <name>", "publish preset").option("--channels <a,b>", "plan rows or plugins to include").option("--live-channels <a,b>", "promote enabled rows to live; off rows stay disabled").option("--live-confirm", "pause for live approval before sending").option("--dummy", "plan and validate every row without dispatching").option("--retry", "retry the rows a previous window left failed").option("--agent <executor>", "executor the workflow dispatches to (default: inline)").option("--unattended", "scheduled posture: generate once when the bundle is missing").option("--yes", "consent to that one generate without --unattended").option("--timeout-ms <n>", "deadline for the workflow child in milliseconds").option("--allow-dirty", "launch even when harness paths are dirty").option("--dry-run", "run the preflight and print the planned launch without taking the lock").action((options) => publishAction(noun, defaultType, options));
|
|
58382
58641
|
}
|
|
58383
58642
|
function registerContentLaunchVerbs(group, noun, defaultType) {
|
|
58384
58643
|
configureGenerate(group.command("generate").description("launch the generation workflow for a run"), noun, defaultType);
|
|
@@ -58425,6 +58684,13 @@ function commandFailure(command, code, message) {
|
|
|
58425
58684
|
function isOutcomeRows(value) {
|
|
58426
58685
|
return typeof value === "object" && value !== null && Array.isArray(value.rows);
|
|
58427
58686
|
}
|
|
58687
|
+
async function everyPlannedRealRowFailed(fs, workDir, window, rows) {
|
|
58688
|
+
const plan = await readJson5(fs, join32(workDir, "4-publish", `plan.${window}.json`));
|
|
58689
|
+
const planRows = Array.isArray(plan?.rows) ? plan.rows : [];
|
|
58690
|
+
const rehearsalIds = new Set(planRows.filter((row) => row.mode === "dummy").map((row) => String(row.id)));
|
|
58691
|
+
const real = rows.filter((row) => !rehearsalIds.has(String(row.id)) && row.dummy !== true);
|
|
58692
|
+
return real.length > 0 && real.every((row) => row.status !== "succeeded");
|
|
58693
|
+
}
|
|
58428
58694
|
function quietStdout2(action) {
|
|
58429
58695
|
const restore = setDefaultOutputTargets({ stdout: { write() {} } });
|
|
58430
58696
|
return action().finally(restore);
|
|
@@ -58484,6 +58750,9 @@ async function planAction(type, options) {
|
|
|
58484
58750
|
const command = "kk.content.publish-plan";
|
|
58485
58751
|
const fs = createNodeFileSystem();
|
|
58486
58752
|
const context = await loadContext(type, options, command, fs);
|
|
58753
|
+
const stalePlanPath = join32(context.workDir, "4-publish", `plan.${context.window}.json`);
|
|
58754
|
+
if (await fs.exists(stalePlanPath))
|
|
58755
|
+
await fs.deleteFile(stalePlanPath);
|
|
58487
58756
|
const applied = (() => {
|
|
58488
58757
|
try {
|
|
58489
58758
|
validatePublishChannelTokens(context.preset, [
|
|
@@ -58634,6 +58903,7 @@ async function settleAction(type, options) {
|
|
|
58634
58903
|
return commandFailure(command, 1, "publish-settle: classification failed");
|
|
58635
58904
|
if (context.window === "after-generate") {
|
|
58636
58905
|
await quietStdout2(() => runStageCancellable(["publish-matrix-patch-surfdash", context.workDir, "--window", context.window]));
|
|
58906
|
+
await quietStdout2(() => runStageCancellable(["publish-matrix-patch-podcast", context.workDir, "--window", context.window]));
|
|
58637
58907
|
}
|
|
58638
58908
|
const statusPath = join32(context.workDir, "4-publish", `publish-status.${context.window}.txt`);
|
|
58639
58909
|
if (await fs.exists(statusPath) && /^(full|partial|none)$/.test((await fs.readFile(statusPath)).trim())) {
|
|
@@ -58657,7 +58927,7 @@ async function settleAction(type, options) {
|
|
|
58657
58927
|
}
|
|
58658
58928
|
const outcomePath = join32(context.workDir, "4-publish", `outcome.${context.window}.json`);
|
|
58659
58929
|
const outcome = PublishOutcomeSchema.parse.bind(PublishOutcomeSchema)(parseJson7(await fs.readFile(outcomePath)));
|
|
58660
|
-
const failedRequired = outcome.rows.some((row) => row.required && !row.dummy && row.status !== "succeeded");
|
|
58930
|
+
const failedRequired = outcome.rows.some((row) => row.required && !row.dummy && row.status !== "succeeded") || await everyPlannedRealRowFailed(fs, context.workDir, context.window, outcome.rows);
|
|
58661
58931
|
consoleOutput.write(JSON.stringify(outcome));
|
|
58662
58932
|
if (settleCode !== 0 || failedRequired)
|
|
58663
58933
|
throw new CommanderError(1, command, "publish-settle: required targets failed");
|
|
@@ -58716,7 +58986,7 @@ async function reportAction(type, options) {
|
|
|
58716
58986
|
} catch {
|
|
58717
58987
|
return commandFailure(command, 1, `publish-report: ${outcomePath} is unreadable or malformed`);
|
|
58718
58988
|
}
|
|
58719
|
-
const failed = rows.some((row) => row.required === true && row.dummy !== true && row.status !== "succeeded");
|
|
58989
|
+
const failed = rows.some((row) => row.required === true && row.dummy !== true && row.status !== "succeeded") || await everyPlannedRealRowFailed(fs, context.workDir, context.window, rows);
|
|
58720
58990
|
if (failed) {
|
|
58721
58991
|
return commandFailure(command, 1, `publish-report: required targets failed \u2014 see outcome.${context.window}.json and the page`);
|
|
58722
58992
|
}
|
|
@@ -58874,28 +59144,47 @@ function splitMarkdown(markdown, fallbackTitle, titleOverride) {
|
|
|
58874
59144
|
`).trim();
|
|
58875
59145
|
return { title, body };
|
|
58876
59146
|
}
|
|
58877
|
-
async function writeSeededContent(fs, workDir, locale, markdown, options) {
|
|
59147
|
+
async function writeSeededContent(fs, workDir, locale, markdown, options, coverDest, variants) {
|
|
58878
59148
|
const contentDir = join33(workDir, "content", locale);
|
|
58879
59149
|
await fs.ensureDir(contentDir);
|
|
58880
59150
|
await fs.writeFile(join33(contentDir, "article.md"), markdown);
|
|
59151
|
+
await fs.writeFile(join33(workDir, "3-draft-draft-article.md"), markdown);
|
|
58881
59152
|
const fallbackTitle = options.slug?.replaceAll("-", " ") ?? "article";
|
|
58882
59153
|
const article = splitMarkdown(markdown, fallbackTitle, options.title);
|
|
58883
59154
|
if (article.body === "")
|
|
58884
59155
|
fail3(2, "kk.content.new", `source file is empty: ${options.from ?? "(source)"}`);
|
|
59156
|
+
const metadata = {
|
|
59157
|
+
published: false,
|
|
59158
|
+
...parseTags(options.tags) !== undefined ? { tags: parseTags(options.tags) } : {},
|
|
59159
|
+
...options.description !== undefined ? { description: options.description } : {},
|
|
59160
|
+
...coverDest !== undefined ? { coverImage: coverDest } : {}
|
|
59161
|
+
};
|
|
58885
59162
|
const content = {
|
|
58886
59163
|
title: article.title,
|
|
58887
59164
|
format: "markdown",
|
|
58888
59165
|
body: article.body,
|
|
58889
|
-
metadata
|
|
58890
|
-
published: false,
|
|
58891
|
-
...parseTags(options.tags) !== undefined ? { tags: parseTags(options.tags) } : {},
|
|
58892
|
-
...options.description !== undefined ? { description: options.description } : {}
|
|
58893
|
-
}
|
|
59166
|
+
metadata
|
|
58894
59167
|
};
|
|
58895
59168
|
const publishDir = join33(workDir, "4-publish");
|
|
58896
59169
|
await fs.ensureDir(publishDir);
|
|
58897
59170
|
await fs.writeFile(join33(publishDir, "content.json"), `${JSON.stringify(content, null, 2)}
|
|
58898
59171
|
`);
|
|
59172
|
+
if (variants !== undefined) {
|
|
59173
|
+
for (const [name, sourcePath] of Object.entries(variants)) {
|
|
59174
|
+
const variantMd = await fs.readFile(sourcePath);
|
|
59175
|
+
const split = splitMarkdown(variantMd, article.title);
|
|
59176
|
+
if (split.body === "")
|
|
59177
|
+
fail3(2, "kk.content.new", `variant file is empty: ${sourcePath}`);
|
|
59178
|
+
const variantContent = {
|
|
59179
|
+
title: split.title,
|
|
59180
|
+
format: "markdown",
|
|
59181
|
+
body: split.body,
|
|
59182
|
+
metadata
|
|
59183
|
+
};
|
|
59184
|
+
await fs.writeFile(join33(publishDir, `content.${name}.json`), `${JSON.stringify(variantContent, null, 2)}
|
|
59185
|
+
`);
|
|
59186
|
+
}
|
|
59187
|
+
}
|
|
58899
59188
|
}
|
|
58900
59189
|
async function seedItcPreparation(fs, workDir, run, options, preset) {
|
|
58901
59190
|
const launchPath = join33(workDir, ".content-itc-prepare.json");
|
|
@@ -58970,13 +59259,16 @@ async function newAction(defaultType, options, article) {
|
|
|
58970
59259
|
await fs.ensureDir(run.workDir);
|
|
58971
59260
|
if (article)
|
|
58972
59261
|
await seedItcPreparation(fs, run.workDir, run, options, resolved.publish_preset);
|
|
58973
|
-
|
|
58974
|
-
await writeSeededContent(fs, run.workDir, locale, await fs.readFile(fromPath), options);
|
|
59262
|
+
let coverDest;
|
|
58975
59263
|
if (options.cover !== undefined) {
|
|
58976
59264
|
const coverPath = resolve26(expandHome4(options.cover));
|
|
58977
59265
|
const coverDir = join33(run.workDir, "4-illustrations");
|
|
58978
59266
|
await fs.ensureDir(coverDir);
|
|
58979
|
-
|
|
59267
|
+
coverDest = join33(coverDir, `cover${extname(coverPath) || ".png"}`);
|
|
59268
|
+
await fs.copy(coverPath, coverDest);
|
|
59269
|
+
}
|
|
59270
|
+
if (fromPath !== undefined) {
|
|
59271
|
+
await writeSeededContent(fs, run.workDir, locale, await fs.readFile(fromPath), options, coverDest, variants);
|
|
58980
59272
|
}
|
|
58981
59273
|
const request = requestObject(type, resolved, run, options, locale, variants, run.workDir);
|
|
58982
59274
|
await fs.writeFile(requestPath, `${JSON.stringify(request, null, 2)}
|
|
@@ -60613,19 +60905,22 @@ var SILENCE_EDGE_TOLERANCE_SECONDS = 0.05;
|
|
|
60613
60905
|
var DEFAULT_SILENCE_NOISE_DB = -50;
|
|
60614
60906
|
var DEFAULT_SILENCE_MIN_SECONDS = 0.5;
|
|
60615
60907
|
var processExecutor = new NodeProcessExecutor;
|
|
60616
|
-
|
|
60617
|
-
|
|
60618
|
-
|
|
60619
|
-
|
|
60620
|
-
|
|
60621
|
-
|
|
60622
|
-
|
|
60623
|
-
|
|
60624
|
-
|
|
60625
|
-
|
|
60626
|
-
|
|
60627
|
-
|
|
60628
|
-
};
|
|
60908
|
+
function createSpawnRunner(executor = processExecutor) {
|
|
60909
|
+
return async (argv) => {
|
|
60910
|
+
const [bin, ...args] = argv;
|
|
60911
|
+
if (bin === undefined) {
|
|
60912
|
+
throw new AudioToolError("ffmpeg", "spawn", "no binary was given to the audio runner", "");
|
|
60913
|
+
}
|
|
60914
|
+
const result = await executor.run({ command: bin, args, label: `audio ${bin}` });
|
|
60915
|
+
if (result.exitCode === null) {
|
|
60916
|
+
const detail = result.stderr.trim();
|
|
60917
|
+
const killed = result.signal === undefined ? "" : ` (killed by ${result.signal})`;
|
|
60918
|
+
throw new AudioToolError(bin, "spawn", `could not be executed${detail === "" ? "" : ` (${detail})`}${killed} \u2014 install ffmpeg or point ffmpegBin/ffprobeBin at it`, "");
|
|
60919
|
+
}
|
|
60920
|
+
return { exitCode: result.exitCode, stdout: result.stdout, stderr: result.stderr };
|
|
60921
|
+
};
|
|
60922
|
+
}
|
|
60923
|
+
var spawnRunner = createSpawnRunner();
|
|
60629
60924
|
function ffprobeArgs(path, bin = DEFAULT_FFPROBE_BIN) {
|
|
60630
60925
|
return [bin, "-v", "error", "-print_format", "json", "-show_format", "-show_streams", path];
|
|
60631
60926
|
}
|
|
@@ -64025,6 +64320,7 @@ async function readLabelItems(items, ids) {
|
|
|
64025
64320
|
title: row.title,
|
|
64026
64321
|
body: row.body,
|
|
64027
64322
|
source: row.source,
|
|
64323
|
+
sourceUri: row.canonicalUrl,
|
|
64028
64324
|
contentHash: row.contentHash,
|
|
64029
64325
|
metadata: parseMetadata(row.metadataJson)
|
|
64030
64326
|
});
|
|
@@ -64078,6 +64374,7 @@ async function heuristicAnnotations(fs, scratch, runId, items) {
|
|
|
64078
64374
|
id: item.id,
|
|
64079
64375
|
title: item.title,
|
|
64080
64376
|
body: item.body,
|
|
64377
|
+
...item.sourceUri === null ? {} : { sourceUri: item.sourceUri },
|
|
64081
64378
|
metadata: item.metadata
|
|
64082
64379
|
}));
|
|
64083
64380
|
await fs.writeFile(inputPath, JSON.stringify(docs));
|
|
@@ -66332,6 +66629,10 @@ async function main2(argv = process.argv, options = {}) {
|
|
|
66332
66629
|
};
|
|
66333
66630
|
inheritSettings(program);
|
|
66334
66631
|
const userArgs = argv.slice(2);
|
|
66632
|
+
const isHelpOrVersion = userArgs.length === 0 || userArgs[0] === "help" || ["--help", "-h", "--version", "-V"].some((flag) => userArgs.includes(flag));
|
|
66633
|
+
const previousExitCode = process.exitCode;
|
|
66634
|
+
if (isHelpOrVersion)
|
|
66635
|
+
process.exitCode = 0;
|
|
66335
66636
|
try {
|
|
66336
66637
|
if (userArgs.length === 0) {
|
|
66337
66638
|
program.help();
|
|
@@ -66346,6 +66647,9 @@ async function main2(argv = process.argv, options = {}) {
|
|
|
66346
66647
|
return err.exitCode;
|
|
66347
66648
|
}
|
|
66348
66649
|
throw err;
|
|
66650
|
+
} finally {
|
|
66651
|
+
if (isHelpOrVersion)
|
|
66652
|
+
process.exitCode = previousExitCode;
|
|
66349
66653
|
}
|
|
66350
66654
|
}
|
|
66351
66655
|
|