@pptalker/agent 1.0.2 → 1.0.4

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/dist/config.js CHANGED
@@ -39,11 +39,27 @@ export function loadConfig(env = process.env) {
39
39
  if (!Number.isInteger(defaultSpeed) || defaultSpeed < 80 || defaultSpeed > 150) {
40
40
  throw new Error('PPTALKER_SPEED 必须为 80–150 的整数');
41
41
  }
42
+ // 字幕逐维可配;未设置时用后端默认(显示、字号 medium、白色、半透明底)。
43
+ const rawSubtitles = env.PPTALKER_SUBTITLES;
44
+ let defaultSubtitles = null;
45
+ if (rawSubtitles !== undefined && rawSubtitles !== '') {
46
+ if (!['true', 'false'].includes(rawSubtitles)) throw new Error('PPTALKER_SUBTITLES 只能是 true 或 false');
47
+ defaultSubtitles = rawSubtitles === 'true';
48
+ }
49
+ const pick = (name, allowed) => {
50
+ const value = (env[name] || '').trim().toLowerCase() || null;
51
+ if (value && !allowed.includes(value)) throw new Error(`${name} 只能是 ${allowed.join(' / ')}`);
52
+ return value;
53
+ };
54
+ const defaultSubtitleSize = pick('PPTALKER_SUBTITLE_SIZE', ['small', 'medium', 'large']);
55
+ const defaultSubtitleColor = pick('PPTALKER_SUBTITLE_COLOR', ['white', 'yellow', 'black', 'blue']);
56
+ const defaultSubtitleBg = pick('PPTALKER_SUBTITLE_BG', ['none', 'semi-transparent', 'solid']);
42
57
  const cacheDir = env.PPTALKER_RECOVERY_DIR === 'off' ? null
43
58
  : env.PPTALKER_RECOVERY_DIR || join(homedir(), '.pptalker-agent', 'recovery', 'v2');
44
59
  if (cacheDir && !isAbsolute(cacheDir)) throw new Error('PPTALKER_RECOVERY_DIR 必须为绝对路径或 off');
45
60
  return { apiBase: url.toString().replace(/\/+$/, ''), apiKey, waitSeconds, operationSeconds,
46
61
  cacheDir, defaultLanguage: env.PPTALKER_LANGUAGE || 'zh-CN', defaultStyle,
47
- defaultVoice, defaultSpeed };
62
+ defaultVoice, defaultSpeed, defaultSubtitles, defaultSubtitleSize,
63
+ defaultSubtitleColor, defaultSubtitleBg };
48
64
  }
49
65
  export const CONFIG_HELP = '设置 PPTALKER_AGENT_API_BASE(独立 Agent endpoint)及 PPTALKER_API_KEY。';
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import { realpathSync } from 'node:fs';
2
3
  import { createRequire } from 'node:module';
3
4
  import { resolve } from 'node:path';
4
5
  import { fileURLToPath } from 'node:url';
@@ -33,6 +34,11 @@ const RenderInput = z.object({
33
34
  voice: z.string().max(80).optional().describe('音色名称或 ID,可取 account 返回的 voices(标准音色)或 cloned_voices(克隆音色)。不传则用 PPTALKER_VOICE 或该语言默认音色。'),
34
35
  style: z.enum(['clean', 'bold']).optional(),
35
36
  speed: z.number().int().min(80).max(150).optional().describe('语速 80–150;不传则用 PPTALKER_SPEED(默认 100)。慢≈85,快≈120。'),
37
+ subtitles: z.boolean().optional().describe('是否显示字幕;不传则用 PPTALKER_SUBTITLES(默认显示)。'),
38
+ subtitle_size: z.enum(['small', 'medium', 'large']).optional().describe('字幕字号档位,默认 medium。'),
39
+ subtitle_color: z.enum(['white', 'yellow', 'black', 'blue']).optional().describe('字幕颜色,默认 white。'),
40
+ subtitle_bg: z.enum(['none', 'semi-transparent', 'solid']).optional()
41
+ .describe('字幕背景:none 无底 / semi-transparent 半透明黑底 / solid 实心黑底,默认 semi-transparent。'),
36
42
  video_title: z.string().max(200).optional().describe('视频标题;对应当前独立后端的 video_title 字段。'),
37
43
  is_public: z.boolean().default(false).describe('是否生成公开分享页;默认 false(私有,只给临时签名链接)。'),
38
44
  wait,
@@ -90,7 +96,20 @@ async function main() {
90
96
  console.error(`[pptalker-agent] v${PKG.version} 就绪`);
91
97
  }
92
98
 
93
- if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
99
+ // npx / node_modules/.bin 通过符号链接执行本文件,process.argv[1] 是链接路径,
100
+ // 而 import.meta.url 已被 Node 解析成真实路径。必须 realpath 归一后再比较,
101
+ // 否则直接运行为“静默退出”(exit 0、无任何输出),表现为 MCP 客户端 -32000。
102
+ function isDirectRun() {
103
+ const entry = process.argv[1];
104
+ if (!entry) return false;
105
+ try {
106
+ return realpathSync(resolve(entry)) === realpathSync(fileURLToPath(import.meta.url));
107
+ } catch {
108
+ return false;
109
+ }
110
+ }
111
+
112
+ if (isDirectRun()) {
94
113
  main().catch(() => {
95
114
  console.error(`[pptalker-agent] 启动失败。${CONFIG_HELP}`);
96
115
  process.exitCode = 1;
@@ -103,7 +103,11 @@ export async function handleRender(client, cfg, input, extra = {}) {
103
103
  voice: input.voice || cfg.defaultVoice || undefined,
104
104
  style: input.style || cfg.defaultStyle,
105
105
  speed: input.speed ?? cfg.defaultSpeed ?? 100,
106
- video_title: input.video_title || '', is_public: input.is_public === true },
106
+ video_title: input.video_title || '', is_public: input.is_public === true,
107
+ subtitles: input.subtitles ?? cfg.defaultSubtitles ?? undefined,
108
+ subtitle_size: input.subtitle_size || cfg.defaultSubtitleSize || undefined,
109
+ subtitle_color: input.subtitle_color || cfg.defaultSubtitleColor || undefined,
110
+ subtitle_bg: input.subtitle_bg || cfg.defaultSubtitleBg || undefined },
107
111
  }), Math.min(120000, remaining()), extra.signal);
108
112
  const result = normalizeTask(raw, { ...context, submission: 'accepted' });
109
113
  context = result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pptalker/agent",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "独立 PPTalker Agent MCP:异步准备、讲稿确认、私有视频与可取消的短状态查询。",
5
5
  "keywords": [
6
6
  "mcp",
Binary file
@@ -46,10 +46,14 @@ Key 从 https://www.pptalker.com/profile 获取,与网页端用的是同一个
46
46
  |---|---|---|---|
47
47
  | `PPTALKER_AGENT_API_BASE` | ✅ | — | `https://api.pptalker.com`。只填 origin,**不要带 `/api/v1/agent`**,带上会直接报配置错误 |
48
48
  | `PPTALKER_API_KEY` | ✅ | — | `pptk_live_` 开头的 key |
49
- | `PPTALKER_LANGUAGE` | — | `zh-CN` | 默认旁白语言,可被单次调用覆盖 |
49
+ | `PPTALKER_LANGUAGE` | — | `zh-CN` | 默认旁白语言。接受 BCP-47(`zh-CN`)或友好名(`Chinese`/`中文`/`English`) |
50
50
  | `PPTALKER_STYLE` | — | `clean` | `clean` 或 `bold` |
51
51
  | `PPTALKER_VOICE` | — | 按语言取 | 全局默认音色。标准音色填名称或 ID,克隆音色填 `cloned_voices` 里的 `name` 或 `id` |
52
52
  | `PPTALKER_SPEED` | — | `100` | 全局默认语速,整数 80–150 |
53
+ | `PPTALKER_SUBTITLES` | — | 显示 | 是否显示字幕,`true`/`false` |
54
+ | `PPTALKER_SUBTITLE_SIZE` | — | `medium` | 字幕字号 `small`/`medium`/`large` |
55
+ | `PPTALKER_SUBTITLE_COLOR` | — | `white` | 字幕颜色 `white`/`yellow`/`black`/`blue` |
56
+ | `PPTALKER_SUBTITLE_BG` | — | `semi-transparent` | 字幕背景 `none`/`semi-transparent`/`solid` |
53
57
  | `PPTALKER_WAIT_SECONDS` | — | `30` | 仅 `wait=true` 时的客户端轮询预算,整数 10–45 |
54
58
  | `PPTALKER_OPERATION_SECONDS` | — | `180` | 单个新任务的总预算(上传 + 首次解析),整数 10–300 |
55
59
  | `PPTALKER_RECOVERY_DIR` | — | `~/.pptalker-agent/recovery/v2` | 本地恢复日志目录;填 `off` 关闭(关闭后中断任务只能靠用户自己记 id) |