@mindscraft/branch-video-agent-cli 0.3.0 → 0.3.2

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/README.md CHANGED
@@ -34,7 +34,7 @@ branch-video-agent --help
34
34
  - `AIHUB_AGENT_TOKEN`
35
35
  - `BRANCH_VIDEO_AGENT_BASE_URL`
36
36
 
37
- AI Gateway 调用同样只传 `AIHUB_AGENT_TOKEN`;服务端使用该 token 记录上的独立 `AiGatewayKey`,不能复用 AIHub `projectKey`。
37
+ AI Gateway 调用同样只传 `AIHUB_AGENT_TOKEN`;CLI 不读取、不传递 `AiGatewayKey` AIHub `projectKey`,上游鉴权由服务端处理。
38
38
 
39
39
  最小调用示例:
40
40
 
@@ -0,0 +1,2 @@
1
+ import type { CommandHandler } from '../lib/types.js';
2
+ export declare const agentProductionCommands: Record<string, CommandHandler>;
@@ -0,0 +1,220 @@
1
+ import { getRequiredString, omitKeys } from '../lib/payload.js';
2
+ function appendQuery(path, params) {
3
+ const query = new URLSearchParams();
4
+ for (const [key, value] of Object.entries(params)) {
5
+ if (value === undefined || value === null || value === '')
6
+ continue;
7
+ query.set(key, String(value));
8
+ }
9
+ const queryString = query.toString();
10
+ return queryString ? `${path}?${queryString}` : path;
11
+ }
12
+ function getRequiredStringAlias(payload, camelKey, snakeKey) {
13
+ const camelValue = payload[camelKey];
14
+ const value = typeof camelValue === 'string' && camelValue.trim() ? camelValue : payload[snakeKey];
15
+ return getRequiredString({ [camelKey]: value }, camelKey);
16
+ }
17
+ export const agentProductionCommands = {
18
+ create: async ({ client, payload }) => {
19
+ const result = await client.request('/api/branch-video/agent-production/create', {
20
+ method: 'POST',
21
+ body: payload,
22
+ });
23
+ return { data: result.data, requestId: result.requestId };
24
+ },
25
+ status: async ({ client, payload }) => {
26
+ const projectId = getRequiredString(payload, 'projectId');
27
+ const result = await client.request(`/api/branch-video/agent-production/${encodeURIComponent(projectId)}/status`, {
28
+ method: 'GET',
29
+ });
30
+ return { data: result.data, requestId: result.requestId };
31
+ },
32
+ cancel: async ({ client, payload }) => {
33
+ const result = await client.request('/api/branch-video/agent-production/cancel', {
34
+ method: 'POST',
35
+ body: payload,
36
+ });
37
+ return { data: result.data, requestId: result.requestId };
38
+ },
39
+ finalize: async ({ client, payload }) => {
40
+ const result = await client.request('/api/branch-video/agent-production/finalize', {
41
+ method: 'POST',
42
+ body: payload,
43
+ });
44
+ return { data: result.data, requestId: result.requestId };
45
+ },
46
+ 'autopilot-binding': async ({ client, payload }) => {
47
+ const result = await client.request('/api/branch-video/agent-production/autopilot-binding', {
48
+ method: 'POST',
49
+ body: payload,
50
+ });
51
+ return { data: result.data, requestId: result.requestId };
52
+ },
53
+ 'node.claim': async ({ client, payload }) => {
54
+ const result = await client.request('/api/branch-video/agent-production/node/claim', {
55
+ method: 'POST',
56
+ body: payload,
57
+ });
58
+ return { data: result.data, requestId: result.requestId };
59
+ },
60
+ 'node.inputs': async ({ client, payload }) => {
61
+ const nodeRunId = getRequiredString(payload, 'nodeRunId');
62
+ const result = await client.request(`/api/branch-video/agent-production/node/${encodeURIComponent(nodeRunId)}/inputs`, {
63
+ method: 'GET',
64
+ });
65
+ return { data: result.data, requestId: result.requestId };
66
+ },
67
+ 'node.complete': async ({ client, payload }) => {
68
+ const nodeRunId = getRequiredString(payload, 'nodeRunId');
69
+ const result = await client.request(`/api/branch-video/agent-production/node/${encodeURIComponent(nodeRunId)}/complete`, {
70
+ method: 'POST',
71
+ body: omitKeys(payload, ['nodeRunId']),
72
+ });
73
+ return { data: result.data, requestId: result.requestId };
74
+ },
75
+ 'node.submit': async ({ client, payload }) => {
76
+ const dagRunId = getRequiredStringAlias(payload, 'dagRunId', 'dag_run_id');
77
+ const nodeId = getRequiredStringAlias(payload, 'nodeId', 'node_id');
78
+ const nodeRunId = getRequiredStringAlias(payload, 'nodeRunId', 'node_run_id');
79
+ const body = {
80
+ ...omitKeys(payload, ['dagRunId', 'dag_run_id', 'nodeId', 'node_id', 'nodeRunId', 'node_run_id']),
81
+ dag_run_id: dagRunId,
82
+ node_id: nodeId,
83
+ node_run_id: nodeRunId,
84
+ };
85
+ const result = await client.request(`/api/branch-video/agent-production/dag-runs/${encodeURIComponent(dagRunId)}/nodes/${encodeURIComponent(nodeId)}/submit`, {
86
+ method: 'POST',
87
+ body,
88
+ });
89
+ return { data: result.data, requestId: result.requestId };
90
+ },
91
+ 'node.block': async ({ client, payload }) => {
92
+ const nodeRunId = getRequiredString(payload, 'nodeRunId');
93
+ const result = await client.request(`/api/branch-video/agent-production/node/${encodeURIComponent(nodeRunId)}/block`, {
94
+ method: 'POST',
95
+ body: omitKeys(payload, ['nodeRunId']),
96
+ });
97
+ return { data: result.data, requestId: result.requestId };
98
+ },
99
+ 'blocker.resolve': async ({ client, payload }) => {
100
+ const result = await client.request('/api/branch-video/agent-production/blocker/resolve', {
101
+ method: 'POST',
102
+ body: payload,
103
+ });
104
+ return { data: result.data, requestId: result.requestId };
105
+ },
106
+ 'node.retry': async ({ client, payload }) => {
107
+ const nodeRunId = getRequiredString(payload, 'nodeRunId');
108
+ const result = await client.request(`/api/branch-video/agent-production/node/${encodeURIComponent(nodeRunId)}/retry`, {
109
+ method: 'POST',
110
+ body: omitKeys(payload, ['nodeRunId']),
111
+ });
112
+ return { data: result.data, requestId: result.requestId };
113
+ },
114
+ 'node.expire': async ({ client, payload }) => {
115
+ const result = await client.request('/api/branch-video/agent-production/node/expire', {
116
+ method: 'POST',
117
+ body: payload,
118
+ });
119
+ return { data: result.data, requestId: result.requestId };
120
+ },
121
+ 'node.fail': async ({ client, payload }) => {
122
+ const nodeRunId = getRequiredString(payload, 'nodeRunId');
123
+ const result = await client.request(`/api/branch-video/agent-production/node/${encodeURIComponent(nodeRunId)}/fail`, {
124
+ method: 'POST',
125
+ body: omitKeys(payload, ['nodeRunId']),
126
+ });
127
+ return { data: result.data, requestId: result.requestId };
128
+ },
129
+ 'artifact.submit': async ({ client, payload }) => {
130
+ const result = await client.request('/api/branch-video/agent-production/artifact/submit', {
131
+ method: 'POST',
132
+ body: payload,
133
+ });
134
+ return { data: result.data, requestId: result.requestId };
135
+ },
136
+ 'artifact.list': async ({ client, payload }) => {
137
+ const projectId = getRequiredString(payload, 'projectId');
138
+ const result = await client.request(`/api/branch-video/agent-production/${encodeURIComponent(projectId)}/artifacts`, {
139
+ method: 'GET',
140
+ });
141
+ return { data: result.data, requestId: result.requestId };
142
+ },
143
+ 'asset-job.poll': async ({ client, payload }) => {
144
+ const result = await client.request('/api/branch-video/agent-production/asset-job/poll', {
145
+ method: 'POST',
146
+ body: payload,
147
+ });
148
+ return { data: result.data, requestId: result.requestId };
149
+ },
150
+ 'asset-job.retry': async ({ client, payload }) => {
151
+ const result = await client.request('/api/branch-video/agent-production/asset-job/retry', {
152
+ method: 'POST',
153
+ body: payload,
154
+ });
155
+ return { data: result.data, requestId: result.requestId };
156
+ },
157
+ 'asset-job.revise': async ({ client, payload }) => {
158
+ const result = await client.request('/api/branch-video/agent-production/asset-job/revise', {
159
+ method: 'POST',
160
+ body: payload,
161
+ });
162
+ return { data: result.data, requestId: result.requestId };
163
+ },
164
+ 'asset-job.attach-artifact': async ({ client, payload }) => {
165
+ const result = await client.request('/api/branch-video/agent-production/asset-job/attach-artifact', {
166
+ method: 'POST',
167
+ body: payload,
168
+ });
169
+ return { data: result.data, requestId: result.requestId };
170
+ },
171
+ 'asset-job.fail': async ({ client, payload }) => {
172
+ const result = await client.request('/api/branch-video/agent-production/asset-job/fail', {
173
+ method: 'POST',
174
+ body: payload,
175
+ });
176
+ return { data: result.data, requestId: result.requestId };
177
+ },
178
+ 'gate.evaluate': async ({ client, payload }) => {
179
+ const result = await client.request('/api/branch-video/agent-production/gate/evaluate', {
180
+ method: 'POST',
181
+ body: payload,
182
+ });
183
+ return { data: result.data, requestId: result.requestId };
184
+ },
185
+ 'gate.results': async ({ client, payload }) => {
186
+ const projectId = getRequiredString(payload, 'projectId');
187
+ const path = appendQuery(`/api/branch-video/agent-production/${encodeURIComponent(projectId)}/gates`, {
188
+ gateId: payload.gateId,
189
+ history: payload.history === undefined ? undefined : Boolean(payload.history),
190
+ });
191
+ const result = await client.request(path, {
192
+ method: 'GET',
193
+ });
194
+ return { data: result.data, requestId: result.requestId };
195
+ },
196
+ events: async ({ client, payload }) => {
197
+ const projectId = getRequiredString(payload, 'projectId');
198
+ const path = appendQuery(`/api/branch-video/agent-production/${encodeURIComponent(projectId)}/events`, {
199
+ category: payload.category,
200
+ });
201
+ const result = await client.request(path, {
202
+ method: 'GET',
203
+ });
204
+ return { data: result.data, requestId: result.requestId };
205
+ },
206
+ metrics: async ({ client, payload }) => {
207
+ const projectId = getRequiredString(payload, 'projectId');
208
+ const result = await client.request(`/api/branch-video/agent-production/${encodeURIComponent(projectId)}/metrics`, {
209
+ method: 'GET',
210
+ });
211
+ return { data: result.data, requestId: result.requestId };
212
+ },
213
+ 'multica-comment-payload': async ({ client, payload }) => {
214
+ const projectId = getRequiredString(payload, 'projectId');
215
+ const result = await client.request(`/api/branch-video/agent-production/${encodeURIComponent(projectId)}/multica-comment-payload`, {
216
+ method: 'GET',
217
+ });
218
+ return { data: result.data, requestId: result.requestId };
219
+ },
220
+ };
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { presetCommands } from './commands/preset.js';
2
2
  import { productionCommands } from './commands/production.js';
3
+ import { agentProductionCommands } from './commands/agentProduction.js';
3
4
  import { projectCommands } from './commands/project.js';
4
5
  import { versionCommands } from './commands/version.js';
5
6
  import { workflowCommands } from './commands/workflow.js';
@@ -15,7 +16,8 @@ const commandRegistry = {
15
16
  workflow: workflowCommands,
16
17
  project: projectCommands,
17
18
  version: versionCommands,
18
- production: productionCommands,
19
+ 'agent-production': agentProductionCommands,
20
+ 'aihub-production': productionCommands,
19
21
  character: characterCommands,
20
22
  'ai-gateway': aiGatewayCommands,
21
23
  };
package/dist/lib/flags.js CHANGED
@@ -84,7 +84,7 @@ export function parseCliArgs(argv) {
84
84
  }
85
85
  return {
86
86
  group: positionals[0] || '',
87
- action: positionals[1] || '',
87
+ action: positionals.slice(1).join('.') || '',
88
88
  flags,
89
89
  };
90
90
  }
@@ -97,7 +97,8 @@ export function getCliHelpText() {
97
97
  ' workflow run | status | outputs',
98
98
  ' project list | get | create | import-aihub | update | delete',
99
99
  ' version list | get | publish',
100
- ' production schema | start | status | retry',
100
+ ' agent-production create | status | cancel | finalize | autopilot-binding | events | metrics | multica-comment-payload | node claim|inputs|complete|submit|block|fail|retry|expire | blocker resolve | artifact submit|list | asset-job poll|retry|revise|attach-artifact|fail | gate evaluate|results',
101
+ ' aihub-production schema | start | status | retry',
101
102
  ' character search | create | get',
102
103
  ' ai-gateway capabilities | request | image-generate | image-edit | video-create | video-get | music-submit | music-get',
103
104
  '',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindscraft/branch-video-agent-cli",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Published CLI for branch-video and AIHub agent APIs.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -33,4 +33,4 @@
33
33
  "prepack": "npm run build",
34
34
  "smoke:help": "npm run build && node dist/bin.js --help"
35
35
  }
36
- }
36
+ }