maoda-commander-tt 0.0.37 → 0.0.38

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/main.js CHANGED
@@ -4983,6 +4983,74 @@ var AiVideoWaitCommand = class extends AiBaseCommand {
4983
4983
  }
4984
4984
  };
4985
4985
 
4986
+ // src/commands/ai/ai-video-submit-progress.ts
4987
+ var VIDEO_SUBMIT_HEARTBEAT_INTERVAL_MS = 1e4;
4988
+ var DEFAULT_RUNTIME = {
4989
+ now: Date.now,
4990
+ setInterval: (handler, timeoutMs) => setInterval(handler, timeoutMs),
4991
+ clearInterval: (timer) => clearInterval(timer),
4992
+ writeStderr: (text) => {
4993
+ process.stderr.write(text);
4994
+ }
4995
+ };
4996
+ function createVideoSubmitProgressReporter(options) {
4997
+ return new VideoSubmitProgressReporter(options);
4998
+ }
4999
+ var VideoSubmitProgressReporter = class {
5000
+ constructor(_options) {
5001
+ this._options = _options;
5002
+ this._runtime = _options.runtime ?? DEFAULT_RUNTIME;
5003
+ this._heartbeatIntervalMs = _options.heartbeatIntervalMs ?? VIDEO_SUBMIT_HEARTBEAT_INTERVAL_MS;
5004
+ }
5005
+ _runtime;
5006
+ _heartbeatIntervalMs;
5007
+ _startedAt;
5008
+ _timer;
5009
+ start() {
5010
+ if (!this._options.enabled || this._startedAt !== void 0) {
5011
+ return;
5012
+ }
5013
+ this._startedAt = this._runtime.now();
5014
+ this._emitProgress();
5015
+ this._timer = this._runtime.setInterval(
5016
+ () => this._emitProgress(),
5017
+ this._heartbeatIntervalMs
5018
+ );
5019
+ this._timer.unref?.();
5020
+ }
5021
+ stop() {
5022
+ if (this._timer !== void 0) {
5023
+ this._runtime.clearInterval(this._timer);
5024
+ this._timer = void 0;
5025
+ }
5026
+ }
5027
+ _emitProgress() {
5028
+ if (this._startedAt === void 0) {
5029
+ return;
5030
+ }
5031
+ const elapsedSeconds = Math.max(
5032
+ 0,
5033
+ Math.floor((this._runtime.now() - this._startedAt) / 1e3)
5034
+ );
5035
+ const event = {
5036
+ protocol: "tt.agent.v1",
5037
+ type: "progress",
5038
+ command: "ai video",
5039
+ phase: "submitting",
5040
+ state: "working",
5041
+ elapsedSeconds,
5042
+ taskIdAvailable: false,
5043
+ final: false,
5044
+ message: "\u6B63\u5728\u6821\u9A8C\u8BF7\u6C42\u3001\u521D\u59CB\u5316\u4F1A\u8BDD\u3001\u4E0A\u4F20\u53C2\u8003\u7D20\u6750\u5E76\u521B\u5EFA\u8FDC\u7AEF\u4EFB\u52A1\uFF1B\u8FD9\u4E0D\u662F\u6700\u7EC8\u7ED3\u679C\uFF0C\u8BF7\u7B49\u5F85\u8FDB\u7A0B\u9000\u51FA\u540E\u8BFB\u53D6 stdout\u3002"
5045
+ };
5046
+ try {
5047
+ this._runtime.writeStderr(`${JSON.stringify(event)}
5048
+ `);
5049
+ } catch {
5050
+ }
5051
+ }
5052
+ };
5053
+
4986
5054
  // src/commands/ai/ai-video-command.ts
4987
5055
  var AiVideoCommand = class extends BaseSubcommandHost {
4988
5056
  constructor(_videoGenerationService = createDefaultVideoGenerationService()) {
@@ -4992,7 +5060,7 @@ var AiVideoCommand = class extends BaseSubcommandHost {
4992
5060
  _meta() {
4993
5061
  return {
4994
5062
  name: "video",
4995
- description: "\u63D0\u4EA4\u89C6\u9891\u751F\u6210\u4EFB\u52A1\uFF1B\u9ED8\u8BA4\u8FD4\u56DE taskId\uFF0C\u4E5F\u53EF\u7B49\u5F85\u7EA6 5 \u5206\u949F\u5E76\u76F4\u63A5\u83B7\u53D6\u4EA7\u7269"
5063
+ description: "\u63D0\u4EA4\u89C6\u9891\u751F\u6210\u4EFB\u52A1\uFF1B\u9ED8\u8BA4\u5728\u7D20\u6750\u4E0A\u4F20\u548C\u4EFB\u52A1\u521B\u5EFA\u5B8C\u6210\u540E\u8FD4\u56DE taskId\uFF0C\u4E5F\u53EF\u7EE7\u7EED\u7B49\u5F85\u4EA7\u7269"
4996
5064
  };
4997
5065
  }
4998
5066
  _configureOptions(cmd) {
@@ -5044,7 +5112,13 @@ var AiVideoCommand = class extends BaseSubcommandHost {
5044
5112
  cmd.addOption(
5045
5113
  new Option10(
5046
5114
  "--wait",
5047
- "\u63D0\u4EA4\u540E\u7B49\u5F85\u4EA7\u7269\uFF1B\u672A\u6307\u5B9A\u65F6\u7ACB\u5373\u8FD4\u56DE taskId"
5115
+ "\u4EFB\u52A1\u521B\u5EFA\u540E\u7EE7\u7EED\u7B49\u5F85\u4EA7\u7269\uFF1B\u672A\u6307\u5B9A\u65F6\u5728\u7D20\u6750\u4E0A\u4F20\u548C\u4EFB\u52A1\u521B\u5EFA\u5B8C\u6210\u540E\u8FD4\u56DE taskId"
5116
+ ).default(false)
5117
+ );
5118
+ cmd.addOption(
5119
+ new Option10(
5120
+ "--quiet",
5121
+ "\u4E0D\u5411 stderr \u8F93\u51FA\u63D0\u4EA4\u9636\u6BB5\u7684\u7ED3\u6784\u5316\u8FDB\u5EA6\u548C\u5FC3\u8DF3"
5048
5122
  ).default(false)
5049
5123
  );
5050
5124
  cmd.addOption(
@@ -5064,7 +5138,10 @@ var AiVideoCommand = class extends BaseSubcommandHost {
5064
5138
  [
5065
5139
  "",
5066
5140
  "Agent \u8C03\u7528\u5951\u7EA6:",
5067
- " \u9ED8\u8BA4: \u5F02\u6B65\u63D0\u4EA4\uFF0C\u8FD4\u56DE taskId \u548C estimatedWaitSeconds\uFF1B\u968F\u540E\u53EF\u8C03\u7528 video wait\u3002",
5141
+ " \u9ED8\u8BA4: \u751F\u6210\u8FC7\u7A0B\u5F02\u6B65\uFF0C\u4F46\u672C\u547D\u4EE4\u4F1A\u540C\u6B65\u5B8C\u6210\u4F1A\u8BDD\u521D\u59CB\u5316\u3001\u53C2\u8003\u7D20\u6750\u4E0A\u4F20\u548C\u8FDC\u7AEF\u4EFB\u52A1\u521B\u5EFA\uFF0C\u4E4B\u540E\u624D\u8FD4\u56DE taskId\u3002",
5142
+ " \u63D0\u4EA4\u671F\u95F4 stderr \u7ACB\u5373\u8F93\u51FA\u7ED3\u6784\u5316 progress\uFF0C\u4E4B\u540E\u6BCF 10 \u79D2\u5FC3\u8DF3\uFF1B\u6700\u7EC8 stdout \u59CB\u7EC8\u53EA\u6709\u4E00\u4E2A JSON\u3002",
5143
+ " progress \u4E0D\u662F\u6700\u7EC8\u7ED3\u679C\uFF1B\u5FC5\u987B\u7B49\u5F85\u8FDB\u7A0B\u9000\u51FA\u3002\u82E5 runner \u8FD4\u56DE session/process handle\uFF0C\u7EE7\u7EED\u8F6E\u8BE2\u76F4\u5230\u62FF\u5230 exit code\u3002",
5144
+ " --quiet: \u5173\u95ED\u975E\u9519\u8BEF stderr progress\uFF1B\u771F\u5B9E\u9519\u8BEF\u4ECD\u4F1A\u5199\u5165 stderr\u3002",
5068
5145
  " --wait: \u5355\u6B21\u8C03\u7528\u7B49\u5F85\u5B8C\u6210\uFF0C\u8FD4\u56DE\u6700\u9AD8\u753B\u8D28\u89C6\u9891\u4E91\u94FE\u63A5\u3002",
5069
5146
  " --output <path>: \u81EA\u52A8\u9690\u542B --wait\uFF0C\u8FD4\u56DE\u4E0B\u8F7D\u540E\u7684\u7EDD\u5BF9 localPath\u3002",
5070
5147
  " \u751F\u6210\u901A\u5E38\u7EA6 5 \u5206\u949F\uFF1B\u7B49\u5F85\u8D85\u65F6\u4ECD\u8FD4\u56DE taskId\uFF0C\u53EF\u7EE7\u7EED\u8C03\u7528 video wait\u3002",
@@ -5095,19 +5172,27 @@ var AiVideoCommand = class extends BaseSubcommandHost {
5095
5172
  return this._makeError(timeoutResult.code, timeoutResult.msg);
5096
5173
  }
5097
5174
  }
5098
- const result = await this._videoGenerationService.generate(
5099
- {
5100
- prompt: readPrompt(ctx),
5101
- imagePaths: options.images,
5102
- videoPaths: options.videos,
5103
- audioPaths: options.audios,
5104
- aspectRatio: options.aspectRatio,
5105
- resolution: options.resolution,
5106
- durationSeconds: options.durationSeconds,
5107
- outputCount: options.outputCount,
5108
- modelId: options.modelId
5175
+ const submitProgress = createVideoSubmitProgressReporter({
5176
+ enabled: !options.quiet
5177
+ });
5178
+ submitProgress.start();
5179
+ const result = await (async () => {
5180
+ try {
5181
+ return await this._videoGenerationService.generate({
5182
+ prompt: readPrompt(ctx),
5183
+ imagePaths: options.images,
5184
+ videoPaths: options.videos,
5185
+ audioPaths: options.audios,
5186
+ aspectRatio: options.aspectRatio,
5187
+ resolution: options.resolution,
5188
+ durationSeconds: options.durationSeconds,
5189
+ outputCount: options.outputCount,
5190
+ modelId: options.modelId
5191
+ });
5192
+ } finally {
5193
+ submitProgress.stop();
5109
5194
  }
5110
- );
5195
+ })();
5111
5196
  if (!result.ok) {
5112
5197
  process.stdout.write(
5113
5198
  `${JSON.stringify(