@geoly-ai/social-hub-cli 0.2.4 → 0.2.6

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/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command } from "commander";
3
3
  import { getSocialHubHealth, } from "@geoly-ai/social-hub-sdk";
4
- import { getBaseUrl, requireClient } from "./client.js";
4
+ import { getBaseUrl, requireClient, resolveTeamId } from "./client.js";
5
5
  import { registerAccountsExtensions, registerAuthAndConfig, registerAuthzEvaluate, registerPermissionsExplain, registerRedditExtensions, listRedditSnapshotsPaginated, redditAggregateQueryParams, } from "./register-extensions.js";
6
6
  import { registerAdminCommands } from "./register-admin.js";
7
7
  import { assertApplyOrDryRun } from "./dry-run.js";
@@ -47,12 +47,13 @@ program
47
47
  const events = program.command("events").description("互动事件");
48
48
  events
49
49
  .command("append")
50
- .requiredOption("-t, --team <teamId>", "Team UUID")
50
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
51
51
  .requiredOption("--type <type>", "事件类型,如 comment")
52
52
  .option("--external-ref <ref>", "幂等键(也可放在 payload.externalRef / event_id)")
53
53
  .option("--account <uuid>", "socialAccountId")
54
54
  .option("--subreddit <name>", "subreddit")
55
55
  .option("--result <result>", "succeeded | failed | skipped")
56
+ .option("--brand <uuid>", "品牌关联(账号绑多品牌时必须显式指定;单绑可省略,读取侧自动继承)")
56
57
  .option("--target-url <url>", "目标 URL / permalink")
57
58
  .option("--actor <actor>", "user | agent | cron")
58
59
  .option("--payload <json>", "JSON 对象", "{}")
@@ -65,8 +66,9 @@ events
65
66
  console.error("Invalid --payload JSON");
66
67
  process.exit(1);
67
68
  }
68
- const res = await requireClient().appendEvent(opts.team, {
69
+ const res = await requireClient().appendEvent(resolveTeamId(opts.team), {
69
70
  type: opts.type,
71
+ brandId: opts.brand,
70
72
  externalRef: opts.externalRef ??
71
73
  (typeof payload.externalRef === "string"
72
74
  ? payload.externalRef
@@ -101,16 +103,16 @@ events
101
103
  });
102
104
  events
103
105
  .command("list")
104
- .requiredOption("-t, --team <teamId>", "Team UUID")
106
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
105
107
  .option("-n, --limit <n>", "条数", "20")
106
108
  .action(async (opts) => {
107
- const res = await requireClient().listEvents(opts.team, Number(opts.limit));
109
+ const res = await requireClient().listEvents(resolveTeamId(opts.team), Number(opts.limit));
108
110
  console.log(JSON.stringify(res, null, 2));
109
111
  });
110
112
  events
111
113
  .command("batch")
112
114
  .description("POST /events/batch")
113
- .requiredOption("-t, --team <teamId>", "Team UUID")
115
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
114
116
  .requiredOption("-j, --json <json>", '{ "events": [ ... ] }')
115
117
  .action(async (opts) => {
116
118
  let body;
@@ -121,13 +123,13 @@ events
121
123
  console.error("Invalid -j / --json");
122
124
  process.exit(1);
123
125
  }
124
- const res = await requireClient().appendEventsBatch(opts.team, body);
126
+ const res = await requireClient().appendEventsBatch(resolveTeamId(opts.team), body);
125
127
  console.log(JSON.stringify(res, null, 2));
126
128
  });
127
129
  events
128
130
  .command("import-openclaw-history")
129
131
  .description("POST /interaction-history/import — OpenClaw v1 JSON 幂等入库")
130
- .requiredOption("-t, --team <teamId>", "Team UUID")
132
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
131
133
  .requiredOption("-f, --file <path>", "interaction-history.json 路径")
132
134
  .option("--dry-run", "只校验 schema/slot/幂等,不写库")
133
135
  .option("--no-auto-mark", "关闭 auto_metrics 阈值补 mark")
@@ -142,7 +144,7 @@ events
142
144
  console.error("Invalid JSON file");
143
145
  process.exit(1);
144
146
  }
145
- const res = await requireClient().importInteractionHistory(opts.team, {
147
+ const res = await requireClient().importInteractionHistory(resolveTeamId(opts.team), {
146
148
  ...parsed,
147
149
  sourceFile: opts.file,
148
150
  dryRun: Boolean(opts.dryRun),
@@ -153,14 +155,14 @@ events
153
155
  const styleMarks = program.command("style-marks").description("风格反馈标记");
154
156
  styleMarks
155
157
  .command("list")
156
- .requiredOption("-t, --team <teamId>", "Team UUID")
158
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
157
159
  .option("--account <uuid>", "socialAccountId")
158
160
  .option("--extract-status <st>", "pending | extracted | rejected | skipped | failed")
159
161
  .option("--approved <bool>", "true | false")
160
162
  .option("-n, --limit <n>", "limit", "50")
161
163
  .option("--offset <n>", "offset", "0")
162
164
  .action(async (opts) => {
163
- const res = await requireClient().listStyleMarks(opts.team, {
165
+ const res = await requireClient().listStyleMarks(resolveTeamId(opts.team), {
164
166
  socialAccountId: opts.account,
165
167
  extractStatus: opts.extractStatus,
166
168
  approved: opts.approved === undefined ? undefined : opts.approved === "true",
@@ -171,11 +173,11 @@ styleMarks
171
173
  });
172
174
  styleMarks
173
175
  .command("approve")
174
- .requiredOption("-t, --team <teamId>", "Team UUID")
176
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
175
177
  .requiredOption("--id <styleMarkId>", "Style mark UUID")
176
178
  .option("--note <text>", "Reviewer note")
177
179
  .action(async (opts) => {
178
- const res = await requireClient().patchStyleMark(opts.team, opts.id, {
180
+ const res = await requireClient().patchStyleMark(resolveTeamId(opts.team), opts.id, {
179
181
  approved: true,
180
182
  extractStatus: "pending",
181
183
  note: opts.note,
@@ -184,11 +186,11 @@ styleMarks
184
186
  });
185
187
  styleMarks
186
188
  .command("reject")
187
- .requiredOption("-t, --team <teamId>", "Team UUID")
189
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
188
190
  .requiredOption("--id <styleMarkId>", "Style mark UUID")
189
191
  .option("--note <text>", "Reviewer note")
190
192
  .action(async (opts) => {
191
- const res = await requireClient().patchStyleMark(opts.team, opts.id, {
193
+ const res = await requireClient().patchStyleMark(resolveTeamId(opts.team), opts.id, {
192
194
  approved: false,
193
195
  extractStatus: "rejected",
194
196
  note: opts.note,
@@ -197,11 +199,11 @@ styleMarks
197
199
  });
198
200
  styleMarks
199
201
  .command("extract")
200
- .requiredOption("-t, --team <teamId>", "Team UUID")
202
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
201
203
  .requiredOption("--id <styleMarkId>", "Style mark UUID")
202
204
  .option("--dry-run", "只预览提取结果")
203
205
  .action(async (opts) => {
204
- const res = await requireClient().extractStyleMark(opts.team, opts.id, {
206
+ const res = await requireClient().extractStyleMark(resolveTeamId(opts.team), opts.id, {
205
207
  dryRun: Boolean(opts.dryRun),
206
208
  });
207
209
  console.log(JSON.stringify(res, null, 2));
@@ -209,7 +211,7 @@ styleMarks
209
211
  styleMarks
210
212
  .command("set")
211
213
  .description("PUT /events/external/:eventExternalRef/style-mark (idempotent upsert)")
212
- .requiredOption("-t, --team <teamId>", "Team UUID")
214
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
213
215
  .requiredOption("--event-ref <ref>", "event externalRef")
214
216
  .requiredOption("-j, --json <json>", "body JSON")
215
217
  .action(async (opts) => {
@@ -221,13 +223,13 @@ styleMarks
221
223
  console.error("Invalid -j / --json");
222
224
  process.exit(1);
223
225
  }
224
- const res = await requireClient().upsertEventStyleMarkByExternalRef(opts.team, opts.eventRef, body);
226
+ const res = await requireClient().upsertEventStyleMarkByExternalRef(resolveTeamId(opts.team), opts.eventRef, body);
225
227
  console.log(JSON.stringify(res, null, 2));
226
228
  });
227
229
  styleMarks
228
230
  .command("create")
229
231
  .description("POST /style-marks(直接创建;事件可不存在,eventExternalRef 必填)")
230
- .requiredOption("-t, --team <teamId>", "Team UUID")
232
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
231
233
  .requiredOption("-j, --json <json>", "{ eventExternalRef, markExternalRef?, socialAccountId?, approved?, reasonTags?, styleTags?, note? }")
232
234
  .action(async (opts) => {
233
235
  let body;
@@ -238,18 +240,18 @@ styleMarks
238
240
  console.error("Invalid -j / --json");
239
241
  process.exit(1);
240
242
  }
241
- const res = await requireClient().createStyleMark(opts.team, body);
243
+ const res = await requireClient().createStyleMark(resolveTeamId(opts.team), body);
242
244
  console.log(JSON.stringify(res, null, 2));
243
245
  });
244
246
  const curator = program.command("curator").description("风格沉淀 curator");
245
247
  curator
246
248
  .command("run")
247
- .requiredOption("-t, --team <teamId>", "Team UUID")
249
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
248
250
  .requiredOption("--account <ref>", "账号 UUID 或 handle/slot")
249
251
  .option("--dry-run", "只预览")
250
252
  .option("-n, --limit <n>", "最多处理 pending marks", "50")
251
253
  .action(async (opts) => {
252
- const res = await requireClient().runStyleCurator(opts.team, opts.account, {
254
+ const res = await requireClient().runStyleCurator(resolveTeamId(opts.team), opts.account, {
253
255
  dryRun: Boolean(opts.dryRun),
254
256
  limit: Number(opts.limit),
255
257
  });
@@ -260,14 +262,14 @@ const dashboard = program.command("dashboard").description("运营总览");
260
262
  dashboard
261
263
  .command("summary")
262
264
  .description("GET /dashboard/summary")
263
- .requiredOption("-t, --team <teamId>", "Team UUID")
265
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
264
266
  .option("--from <iso>", "from ISO 日期")
265
267
  .option("--to <iso>", "to ISO 日期")
266
268
  .option("--trend-days <n>", "interactionTrendDays: 7 | 14 | 30")
267
269
  .option("--campaign <uuid>", "campaignId 过滤")
268
270
  .option("--brand <uuid>", "brandId 过滤")
269
271
  .action(async (opts) => {
270
- const res = await requireClient().getDashboardSummary(opts.team, {
272
+ const res = await requireClient().getDashboardSummary(resolveTeamId(opts.team), {
271
273
  from: opts.from,
272
274
  to: opts.to,
273
275
  interactionTrendDays: opts.trendDays
@@ -283,7 +285,7 @@ const calendar = program.command("calendar").description("发布日历条目");
283
285
  calendar
284
286
  .command("list")
285
287
  .description("GET /calendar-entries")
286
- .requiredOption("-t, --team <teamId>", "Team UUID")
288
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
287
289
  .option("--brand <uuid>", "brandId 过滤(推荐)")
288
290
  .option("--campaign <uuid>", "campaignId 过滤(legacy)")
289
291
  .option("--status <st>", "scheduled | running | succeeded | …")
@@ -291,7 +293,7 @@ calendar
291
293
  .option("--to <iso>", "to 时间 ISO")
292
294
  .option("-n, --limit <n>", "limit", "50")
293
295
  .action(async (opts) => {
294
- const res = await requireClient().listCalendarEntries(opts.team, {
296
+ const res = await requireClient().listCalendarEntries(resolveTeamId(opts.team), {
295
297
  brandId: opts.brand,
296
298
  campaignId: opts.campaign,
297
299
  status: opts.status,
@@ -304,7 +306,7 @@ calendar
304
306
  calendar
305
307
  .command("patch")
306
308
  .description("PATCH /calendar-entries/:id(--body 为 JSON)")
307
- .requiredOption("-t, --team <teamId>", "Team UUID")
309
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
308
310
  .requiredOption("-e, --entry <entryId>", "Calendar entry UUID")
309
311
  .requiredOption("--body <json>", '例如 {"status":"succeeded","permalink":"https://www.reddit.com/..."}')
310
312
  .action(async (opts) => {
@@ -316,7 +318,7 @@ calendar
316
318
  console.error("Invalid --body JSON");
317
319
  process.exit(1);
318
320
  }
319
- const res = await requireClient().updateCalendarEntry(opts.team, opts.entry, body);
321
+ const res = await requireClient().updateCalendarEntry(resolveTeamId(opts.team), opts.entry, body);
320
322
  console.log(JSON.stringify(res, null, 2));
321
323
  });
322
324
  // --- reddit ---
@@ -325,7 +327,7 @@ registerRedditExtensions(reddit);
325
327
  reddit
326
328
  .command("list")
327
329
  .description("GET /reddit-post-snapshots")
328
- .requiredOption("-t, --team <teamId>", "Team UUID")
330
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
329
331
  .option("--brand <uuid>", "system-level brandId")
330
332
  .option("--entry <uuid>", "calendarEntryId")
331
333
  .option("--ops-status <st>", "opsStatus filter (normal|risk|deleted|abnormal|unknown)")
@@ -342,7 +344,7 @@ reddit
342
344
  .option("--aggregate", "aggregate across all visible teams (session auth)")
343
345
  .option("--scope-team <uuid>", "narrow aggregated scope to one team")
344
346
  .action(async (opts) => {
345
- const res = await listRedditSnapshotsPaginated(opts.team, {
347
+ const res = await listRedditSnapshotsPaginated(resolveTeamId(opts.team), {
346
348
  limit: Number(opts.limit),
347
349
  offset: opts.offset !== undefined ? Number(opts.offset) : undefined,
348
350
  brandId: opts.brand,
@@ -362,7 +364,7 @@ reddit
362
364
  reddit
363
365
  .command("create-snapshot")
364
366
  .description("POST /reddit-post-snapshots(手工补录)")
365
- .requiredOption("-t, --team <teamId>", "Team UUID")
367
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
366
368
  .requiredOption("-j, --json <json>", '{"permalink":"...","subreddit":"...","score":0,"commentsCount":0,"brandNote":null,"negativeFeedback":null,"repostType":"none","firstRepostLink":null,"secondRepostLink":null}')
367
369
  .action(async (opts) => {
368
370
  let body;
@@ -373,7 +375,7 @@ reddit
373
375
  console.error("Invalid -j / --json");
374
376
  process.exit(1);
375
377
  }
376
- const res = await requireClient().createRedditPostSnapshot(opts.team, body);
378
+ const res = await requireClient().createRedditPostSnapshot(resolveTeamId(opts.team), body);
377
379
  console.log(JSON.stringify(res, null, 2));
378
380
  });
379
381
  // --- jobs ---
@@ -381,11 +383,11 @@ const jobs = program.command("jobs").description("调度任务(scheduled jobs
381
383
  jobs
382
384
  .command("list")
383
385
  .description("GET /scheduled-jobs")
384
- .requiredOption("-t, --team <teamId>", "Team UUID")
386
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
385
387
  .option("--status <st>", "scheduled | running | …")
386
388
  .option("-n, --limit <n>", "limit", "50")
387
389
  .action(async (opts) => {
388
- const res = await requireClient().listScheduledJobs(opts.team, {
390
+ const res = await requireClient().listScheduledJobs(resolveTeamId(opts.team), {
389
391
  limit: Number(opts.limit),
390
392
  status: opts.status,
391
393
  });
@@ -394,16 +396,16 @@ jobs
394
396
  jobs
395
397
  .command("summary")
396
398
  .description("GET /scheduled-jobs/automation-summary")
397
- .requiredOption("-t, --team <teamId>", "Team UUID")
399
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
398
400
  .option("--hours <n>", "时间窗口(小时)", "24")
399
401
  .action(async (opts) => {
400
- const res = await requireClient().getScheduledJobsAutomationSummary(opts.team, Number(opts.hours));
402
+ const res = await requireClient().getScheduledJobsAutomationSummary(resolveTeamId(opts.team), Number(opts.hours));
401
403
  console.log(JSON.stringify(res, null, 2));
402
404
  });
403
405
  jobs
404
406
  .command("create")
405
407
  .description("POST /scheduled-jobs(--json 为完整 body)")
406
- .requiredOption("-t, --team <teamId>", "Team UUID")
408
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
407
409
  .requiredOption("-j, --json <json>", "createScheduledJobBody JSON")
408
410
  .action(async (opts) => {
409
411
  let body;
@@ -414,13 +416,13 @@ jobs
414
416
  console.error("Invalid -j / --json");
415
417
  process.exit(1);
416
418
  }
417
- const res = await requireClient().createScheduledJob(opts.team, body);
419
+ const res = await requireClient().createScheduledJob(resolveTeamId(opts.team), body);
418
420
  console.log(JSON.stringify(res, null, 2));
419
421
  });
420
422
  jobs
421
423
  .command("batch")
422
424
  .description("POST /scheduled-jobs/batch")
423
- .requiredOption("-t, --team <teamId>", "Team UUID")
425
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
424
426
  .requiredOption("-j, --json <json>", '{ "jobs": [ ... ] }')
425
427
  .action(async (opts) => {
426
428
  let body;
@@ -431,25 +433,25 @@ jobs
431
433
  console.error("Invalid -j / --json");
432
434
  process.exit(1);
433
435
  }
434
- const res = await requireClient().createScheduledJobsBatch(opts.team, body);
436
+ const res = await requireClient().createScheduledJobsBatch(resolveTeamId(opts.team), body);
435
437
  console.log(JSON.stringify(res, null, 2));
436
438
  });
437
439
  jobs
438
440
  .command("retry")
439
441
  .description("POST /scheduled-jobs/:id/retry")
440
- .requiredOption("-t, --team <teamId>", "Team UUID")
442
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
441
443
  .requiredOption("-i, --id <jobId>", "Job UUID")
442
444
  .action(async (opts) => {
443
- const res = await requireClient().retryScheduledJob(opts.team, opts.id);
445
+ const res = await requireClient().retryScheduledJob(resolveTeamId(opts.team), opts.id);
444
446
  console.log(JSON.stringify(res, null, 2));
445
447
  });
446
448
  jobs
447
449
  .command("cancel")
448
450
  .description("POST /scheduled-jobs/:id/cancel")
449
- .requiredOption("-t, --team <teamId>", "Team UUID")
451
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
450
452
  .requiredOption("-i, --id <jobId>", "Job UUID")
451
453
  .action(async (opts) => {
452
- const res = await requireClient().cancelScheduledJob(opts.team, opts.id);
454
+ const res = await requireClient().cancelScheduledJob(resolveTeamId(opts.team), opts.id);
453
455
  console.log(JSON.stringify(res, null, 2));
454
456
  });
455
457
  // --- drafts & reports ---
@@ -459,7 +461,7 @@ const content = program
459
461
  content
460
462
  .command("review")
461
463
  .description("POST /content-review — 评论发布前独立 LLM 复审+优化(层③);degraded 时降级本地自审")
462
- .requiredOption("-t, --team <teamId>", "Team UUID")
464
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
463
465
  .requiredOption("-j, --json <json>", "{ accountId, draft, commentType, thread:{subreddit,postTitle,...}, rewrite?, stage?, attempt? }")
464
466
  .action(async (opts) => {
465
467
  let body;
@@ -470,13 +472,13 @@ content
470
472
  console.error("Invalid -j / --json");
471
473
  process.exit(1);
472
474
  }
473
- const res = await requireClient().contentReview(opts.team, body);
475
+ const res = await requireClient().contentReview(resolveTeamId(opts.team), body);
474
476
  console.log(JSON.stringify(res, null, 2));
475
477
  });
476
478
  content
477
479
  .command("post-review")
478
480
  .description("POST /post-review — 帖子(title+body)发布前独立 LLM 审核(七维,独立模型 key);仅审帖子正文,评论审核用 content review")
479
- .requiredOption("-t, --team <teamId>", "Team UUID")
481
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
480
482
  .requiredOption("-j, --json <json>", "{ accountId, title, body, subreddit, subredditRules?, rewrite?, stage?, attempt? }")
481
483
  .action(async (opts) => {
482
484
  let body;
@@ -487,19 +489,19 @@ content
487
489
  console.error("Invalid -j / --json");
488
490
  process.exit(1);
489
491
  }
490
- const res = await requireClient().postReview(opts.team, body);
492
+ const res = await requireClient().postReview(resolveTeamId(opts.team), body);
491
493
  console.log(JSON.stringify(res, null, 2));
492
494
  });
493
495
  const drafts = program.command("drafts").description("内容草稿");
494
496
  drafts
495
497
  .command("list")
496
498
  .description("GET /content-drafts")
497
- .requiredOption("-t, --team <teamId>", "Team UUID")
499
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
498
500
  .option("--brand <uuid>", "brandId 过滤(推荐)")
499
501
  .option("--campaign <uuid>", "campaignId 过滤(legacy)")
500
502
  .option("-n, --limit <n>", "limit", "50")
501
503
  .action(async (opts) => {
502
- const res = await requireClient().listContentDrafts(opts.team, {
504
+ const res = await requireClient().listContentDrafts(resolveTeamId(opts.team), {
503
505
  limit: Number(opts.limit),
504
506
  brandId: opts.brand,
505
507
  campaignId: opts.campaign,
@@ -510,11 +512,11 @@ const reports = program.command("reports").description("报告库");
510
512
  reports
511
513
  .command("list")
512
514
  .description("GET /reports")
513
- .requiredOption("-t, --team <teamId>", "Team UUID")
515
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
514
516
  .option("-n, --limit <n>", "limit", "50")
515
517
  .option("--type <t>", "reddit-post-snapshot | account-status-snapshot | campaign-digest | agent-run-summary | style-curation-report | quota-violation-report | content-weekly")
516
518
  .action(async (opts) => {
517
- const res = await requireClient().listReports(opts.team, {
519
+ const res = await requireClient().listReports(resolveTeamId(opts.team), {
518
520
  limit: Number(opts.limit),
519
521
  reportType: opts.type,
520
522
  });
@@ -523,7 +525,7 @@ reports
523
525
  reports
524
526
  .command("ingest")
525
527
  .description("POST /reports/ingest")
526
- .requiredOption("-t, --team <teamId>", "Team UUID")
528
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
527
529
  .requiredOption("-j, --json <json>", "{ reportType, source, traceId? }")
528
530
  .action(async (opts) => {
529
531
  let body;
@@ -534,7 +536,7 @@ reports
534
536
  console.error("Invalid -j / --json");
535
537
  process.exit(1);
536
538
  }
537
- const res = await requireClient().ingestReport(opts.team, {
539
+ const res = await requireClient().ingestReport(resolveTeamId(opts.team), {
538
540
  reportType: body.reportType,
539
541
  source: body.source,
540
542
  traceId: body.traceId,
@@ -547,7 +549,7 @@ registerAccountsExtensions(accounts);
547
549
  accounts
548
550
  .command("list")
549
551
  .description("GET /accounts")
550
- .requiredOption("-t, --team <teamId>", "Team UUID")
552
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
551
553
  .option("--status <st>", "warming | active | …")
552
554
  .option("--platform <p>", "平台")
553
555
  .option("--brand <uuid>", "brandId 过滤(推荐)")
@@ -556,7 +558,7 @@ accounts
556
558
  .option("--category <cat>", "人设分类")
557
559
  .option("-n, --limit <n>", "limit", "50")
558
560
  .action(async (opts) => {
559
- const res = await requireClient().listAccounts(opts.team, {
561
+ const res = await requireClient().listAccounts(resolveTeamId(opts.team), {
560
562
  limit: Number(opts.limit),
561
563
  status: opts.status,
562
564
  platform: opts.platform,
@@ -570,7 +572,7 @@ accounts
570
572
  accounts
571
573
  .command("create")
572
574
  .description("POST /accounts")
573
- .requiredOption("-t, --team <teamId>", "Team UUID")
575
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
574
576
  .requiredOption("-j, --json <json>", "createAccount body JSON")
575
577
  .action(async (opts) => {
576
578
  let body;
@@ -581,7 +583,7 @@ accounts
581
583
  console.error("Invalid -j / --json");
582
584
  process.exit(1);
583
585
  }
584
- const res = await requireClient().createAccount(opts.team, body);
586
+ const res = await requireClient().createAccount(resolveTeamId(opts.team), body);
585
587
  console.log(JSON.stringify(res, null, 2));
586
588
  });
587
589
  // --- brands & campaigns ---
@@ -633,14 +635,14 @@ brands
633
635
  brands
634
636
  .command("list")
635
637
  .description("GET /teams/:teamId/brands (compat)")
636
- .requiredOption("-t, --team <teamId>", "Team UUID")
638
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
637
639
  .action(async (opts) => {
638
- const res = await requireClient().listBrands(opts.team);
640
+ const res = await requireClient().listBrands(resolveTeamId(opts.team));
639
641
  console.log(JSON.stringify(res, null, 2));
640
642
  });
641
643
  brands
642
644
  .command("create")
643
- .requiredOption("-t, --team <teamId>", "Team UUID")
645
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
644
646
  .requiredOption("-j, --json <json>", "{ name, slug? }")
645
647
  .action(async (opts) => {
646
648
  let body;
@@ -651,7 +653,7 @@ brands
651
653
  console.error("Invalid -j / --json");
652
654
  process.exit(1);
653
655
  }
654
- const res = await requireClient().createBrand(opts.team, {
656
+ const res = await requireClient().createBrand(resolveTeamId(opts.team), {
655
657
  name: String(body.name ?? ""),
656
658
  slug: body.slug,
657
659
  });
@@ -660,7 +662,7 @@ brands
660
662
  brands
661
663
  .command("update")
662
664
  .description("PATCH /brands/:id")
663
- .requiredOption("-t, --team <teamId>", "Team UUID")
665
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
664
666
  .requiredOption("-b, --brand <brandId>", "Brand UUID")
665
667
  .requiredOption("-j, --json <json>", "update body")
666
668
  .action(async (opts) => {
@@ -672,7 +674,7 @@ brands
672
674
  console.error("Invalid -j / --json");
673
675
  process.exit(1);
674
676
  }
675
- const res = await requireClient().updateBrand(opts.team, opts.brand, body);
677
+ const res = await requireClient().updateBrand(resolveTeamId(opts.team), opts.brand, body);
676
678
  console.log(JSON.stringify(res, null, 2));
677
679
  });
678
680
  const personas = program.command("personas").description("系统级人设库");
@@ -848,10 +850,10 @@ const campaigns = program
848
850
  campaigns
849
851
  .command("list")
850
852
  .description("LEGACY list campaigns")
851
- .requiredOption("-t, --team <teamId>", "Team UUID")
853
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
852
854
  .option("--brand <uuid>", "brandId")
853
855
  .action(async (opts) => {
854
- const res = await requireClient().listCampaigns(opts.team, {
856
+ const res = await requireClient().listCampaigns(resolveTeamId(opts.team), {
855
857
  brandId: opts.brand,
856
858
  });
857
859
  console.log(JSON.stringify(res, null, 2));
@@ -859,7 +861,7 @@ campaigns
859
861
  campaigns
860
862
  .command("create")
861
863
  .description("LEGACY create campaign(新流程不要作为品牌入口)")
862
- .requiredOption("-t, --team <teamId>", "Team UUID")
864
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
863
865
  .requiredOption("-j, --json <json>", "{ brandId, name, startsAt?, endsAt? }")
864
866
  .action(async (opts) => {
865
867
  let body;
@@ -870,19 +872,19 @@ campaigns
870
872
  console.error("Invalid -j / --json");
871
873
  process.exit(1);
872
874
  }
873
- const res = await requireClient().createCampaign(opts.team, body);
875
+ const res = await requireClient().createCampaign(resolveTeamId(opts.team), body);
874
876
  console.log(JSON.stringify(res, null, 2));
875
877
  });
876
878
  // --- publishing plans ---
877
879
  const plans = program.command("plans").description("发布计划");
878
880
  plans
879
881
  .command("list")
880
- .requiredOption("-t, --team <teamId>", "Team UUID")
882
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
881
883
  .option("--brand <uuid>", "brandId 过滤(推荐)")
882
884
  .option("--campaign <uuid>", "campaignId 过滤(legacy)")
883
885
  .option("--status <status>", "派生状态过滤(scheduled/running/succeeded/failed/cancelled;无 entries 的计划保留存储值 draft/exported)")
884
886
  .action(async (opts) => {
885
- const res = await requireClient().listPublishingPlans(opts.team, {
887
+ const res = await requireClient().listPublishingPlans(resolveTeamId(opts.team), {
886
888
  brandId: opts.brand,
887
889
  campaignId: opts.campaign,
888
890
  status: opts.status,
@@ -892,7 +894,7 @@ plans
892
894
  plans
893
895
  .command("create")
894
896
  .description("POST /publishing-plans(body 需含 entries 等)")
895
- .requiredOption("-t, --team <teamId>", "Team UUID")
897
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
896
898
  .requiredOption("-j, --json <json>", "createPublishingPlanBody JSON")
897
899
  .action(async (opts) => {
898
900
  let body;
@@ -903,21 +905,21 @@ plans
903
905
  console.error("Invalid -j / --json");
904
906
  process.exit(1);
905
907
  }
906
- const res = await requireClient().createPublishingPlan(opts.team, body);
908
+ const res = await requireClient().createPublishingPlan(resolveTeamId(opts.team), body);
907
909
  console.log(JSON.stringify(res, null, 2));
908
910
  });
909
911
  // --- audit & permissions & graph ---
910
912
  const audit = program.command("audit").description("审计日志");
911
913
  audit
912
914
  .command("list")
913
- .requiredOption("-t, --team <teamId>", "Team UUID")
915
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
914
916
  .option("-n, --limit <n>", "limit", "50")
915
917
  .option("--type <t>", "事件 type 前缀")
916
918
  .option("--actor <a>", "user | agent | cron")
917
919
  .option("--result <r>", "succeeded | failed | skipped")
918
920
  .option("--account <uuid>", "socialAccountId")
919
921
  .action(async (opts) => {
920
- const res = await requireClient().listAuditLogs(opts.team, {
922
+ const res = await requireClient().listAuditLogs(resolveTeamId(opts.team), {
921
923
  limit: Number(opts.limit),
922
924
  type: opts.type,
923
925
  actor: opts.actor,
@@ -932,9 +934,9 @@ const permissionsCmd = program
932
934
  permissionsCmd
933
935
  .command("matrix")
934
936
  .description("GET /permissions-matrix(原 social-hub permissions)")
935
- .requiredOption("-t, --team <teamId>", "Team UUID")
937
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
936
938
  .action(async (opts) => {
937
- const res = await requireClient().getPermissionsMatrix(opts.team);
939
+ const res = await requireClient().getPermissionsMatrix(resolveTeamId(opts.team));
938
940
  console.log(JSON.stringify(res, null, 2));
939
941
  });
940
942
  registerPermissionsExplain(permissionsCmd);
@@ -942,12 +944,12 @@ const graph = program.command("graph").description("账号图谱");
942
944
  graph
943
945
  .command("list")
944
946
  .description("GET /account-graph")
945
- .requiredOption("-t, --team <teamId>", "Team UUID")
947
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
946
948
  .option("--account <uuid>", "socialAccountId")
947
949
  .option("--edge <type>", "edgeType")
948
950
  .option("-n, --limit <n>", "limit", "100")
949
951
  .action(async (opts) => {
950
- const res = await requireClient().listAccountGraphEdges(opts.team, {
952
+ const res = await requireClient().listAccountGraphEdges(resolveTeamId(opts.team), {
951
953
  limit: Number(opts.limit),
952
954
  socialAccountId: opts.account,
953
955
  edgeType: opts.edge,
@@ -982,18 +984,18 @@ graph
982
984
  console.log(JSON.stringify({ dryRun, teams: results.length, results }, null, 2));
983
985
  return;
984
986
  }
985
- if (!opts.team) {
987
+ if (!resolveTeamId(opts.team)) {
986
988
  console.error("Provide -t <teamId> or --all");
987
989
  process.exit(1);
988
990
  }
989
- const res = await client.runEntityGraphProjection(opts.team, { dryRun });
991
+ const res = await client.runEntityGraphProjection(resolveTeamId(opts.team), { dryRun });
990
992
  console.log(JSON.stringify(res, null, 2));
991
993
  });
992
994
  // --- drafts extended ---
993
995
  drafts
994
996
  .command("create")
995
997
  .description("POST /content-drafts")
996
- .requiredOption("-t, --team <teamId>", "Team UUID")
998
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
997
999
  .requiredOption("-j, --json <json>", "{ brandId, title, body, campaignId? }")
998
1000
  .action(async (opts) => {
999
1001
  let body;
@@ -1004,7 +1006,7 @@ drafts
1004
1006
  console.error("Invalid -j / --json");
1005
1007
  process.exit(1);
1006
1008
  }
1007
- const res = await requireClient().createContentDraft(opts.team, body);
1009
+ const res = await requireClient().createContentDraft(resolveTeamId(opts.team), body);
1008
1010
  console.log(JSON.stringify(res, null, 2));
1009
1011
  });
1010
1012
  // --- compliance ---
@@ -1012,12 +1014,12 @@ const compliance = program.command("compliance").description("合规 / 风控");
1012
1014
  compliance
1013
1015
  .command("sanctions-list")
1014
1016
  .description("GET /subreddit-sanctions")
1015
- .requiredOption("-t, --team <teamId>", "Team UUID")
1017
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1016
1018
  .option("--account <uuid>", "socialAccountId")
1017
1019
  .option("--sub <name>", "subreddit")
1018
1020
  .option("-n, --limit <n>", "limit", "50")
1019
1021
  .action(async (opts) => {
1020
- const res = await requireClient().listSubredditSanctions(opts.team, {
1022
+ const res = await requireClient().listSubredditSanctions(resolveTeamId(opts.team), {
1021
1023
  limit: Number(opts.limit),
1022
1024
  socialAccountId: opts.account,
1023
1025
  subreddit: opts.sub,
@@ -1027,7 +1029,7 @@ compliance
1027
1029
  compliance
1028
1030
  .command("sanctions-create")
1029
1031
  .description("POST /subreddit-sanctions")
1030
- .requiredOption("-t, --team <teamId>", "Team UUID")
1032
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1031
1033
  .requiredOption("-j, --json <json>", "body JSON")
1032
1034
  .action(async (opts) => {
1033
1035
  let body;
@@ -1038,13 +1040,13 @@ compliance
1038
1040
  console.error("Invalid -j / --json");
1039
1041
  process.exit(1);
1040
1042
  }
1041
- const res = await requireClient().createSubredditSanction(opts.team, body);
1043
+ const res = await requireClient().createSubredditSanction(resolveTeamId(opts.team), body);
1042
1044
  console.log(JSON.stringify(res, null, 2));
1043
1045
  });
1044
1046
  compliance
1045
1047
  .command("sanctions-update")
1046
1048
  .description("PATCH /subreddit-sanctions/:id")
1047
- .requiredOption("-t, --team <teamId>", "Team UUID")
1049
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1048
1050
  .requiredOption("--id <uuid>", "sanction id")
1049
1051
  .requiredOption("-j, --json <json>", "body JSON")
1050
1052
  .action(async (opts) => {
@@ -1056,40 +1058,40 @@ compliance
1056
1058
  console.error("Invalid -j / --json");
1057
1059
  process.exit(1);
1058
1060
  }
1059
- const res = await requireClient().updateSubredditSanction(opts.team, opts.id, body);
1061
+ const res = await requireClient().updateSubredditSanction(resolveTeamId(opts.team), opts.id, body);
1060
1062
  console.log(JSON.stringify(res, null, 2));
1061
1063
  });
1062
1064
  compliance
1063
1065
  .command("sanctions-delete")
1064
1066
  .description("DELETE /subreddit-sanctions/:id")
1065
- .requiredOption("-t, --team <teamId>", "Team UUID")
1067
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1066
1068
  .requiredOption("--id <uuid>", "sanction id")
1067
1069
  .action(async (opts) => {
1068
- const res = await requireClient().deleteSubredditSanction(opts.team, opts.id);
1070
+ const res = await requireClient().deleteSubredditSanction(resolveTeamId(opts.team), opts.id);
1069
1071
  console.log(JSON.stringify(res, null, 2));
1070
1072
  });
1071
1073
  compliance
1072
1074
  .command("risk-list")
1073
1075
  .description("GET /account-risk-profiles")
1074
- .requiredOption("-t, --team <teamId>", "Team UUID")
1076
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1075
1077
  .option("-n, --limit <n>", "limit", "100")
1076
1078
  .action(async (opts) => {
1077
- const res = await requireClient().listAccountRiskProfiles(opts.team, Number(opts.limit));
1079
+ const res = await requireClient().listAccountRiskProfiles(resolveTeamId(opts.team), Number(opts.limit));
1078
1080
  console.log(JSON.stringify(res, null, 2));
1079
1081
  });
1080
1082
  compliance
1081
1083
  .command("risk-get")
1082
1084
  .description("GET /social-accounts/:id/risk-profile")
1083
- .requiredOption("-t, --team <teamId>", "Team UUID")
1085
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1084
1086
  .requiredOption("-a, --account <uuid>", "socialAccountId")
1085
1087
  .action(async (opts) => {
1086
- const res = await requireClient().getAccountRiskProfile(opts.team, opts.account);
1088
+ const res = await requireClient().getAccountRiskProfile(resolveTeamId(opts.team), opts.account);
1087
1089
  console.log(JSON.stringify(res, null, 2));
1088
1090
  });
1089
1091
  compliance
1090
1092
  .command("risk-put")
1091
1093
  .description("PUT /social-accounts/:id/risk-profile")
1092
- .requiredOption("-t, --team <teamId>", "Team UUID")
1094
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1093
1095
  .requiredOption("-a, --account <uuid>", "socialAccountId")
1094
1096
  .requiredOption("-j, --json <json>", "body")
1095
1097
  .action(async (opts) => {
@@ -1101,16 +1103,16 @@ compliance
1101
1103
  console.error("Invalid -j / --json");
1102
1104
  process.exit(1);
1103
1105
  }
1104
- const res = await requireClient().upsertAccountRiskProfile(opts.team, opts.account, body);
1106
+ const res = await requireClient().upsertAccountRiskProfile(resolveTeamId(opts.team), opts.account, body);
1105
1107
  console.log(JSON.stringify(res, null, 2));
1106
1108
  });
1107
1109
  compliance
1108
1110
  .command("rule-caches-list")
1109
1111
  .description("GET /subreddit-rule-caches")
1110
- .requiredOption("-t, --team <teamId>", "Team UUID")
1112
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1111
1113
  .option("--include-expired", "include expired caches")
1112
1114
  .action(async (opts) => {
1113
- const res = await requireClient().listSubredditRuleCaches(opts.team, {
1115
+ const res = await requireClient().listSubredditRuleCaches(resolveTeamId(opts.team), {
1114
1116
  includeExpired: Boolean(opts.includeExpired),
1115
1117
  });
1116
1118
  console.log(JSON.stringify(res, null, 2));
@@ -1118,12 +1120,12 @@ compliance
1118
1120
  compliance
1119
1121
  .command("rule-caches-upsert")
1120
1122
  .description("PUT /subreddit-rule-caches/:subreddit")
1121
- .requiredOption("-t, --team <teamId>", "Team UUID")
1123
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1122
1124
  .requiredOption("--sub <name>", "subreddit name")
1123
1125
  .requiredOption("-j, --json <json>", "{ rulesMarkdown, sourceUrl?, expiresInDays? }")
1124
1126
  .action(async (opts) => {
1125
1127
  const body = JSON.parse(opts.json);
1126
- const res = await requireClient().upsertSubredditRuleCache(opts.team, opts.sub, body);
1128
+ const res = await requireClient().upsertSubredditRuleCache(resolveTeamId(opts.team), opts.sub, body);
1127
1129
  console.log(JSON.stringify(res, null, 2));
1128
1130
  });
1129
1131
  compliance
@@ -1133,7 +1135,7 @@ compliance
1133
1135
  .option("--kind <kind>", "blocklist kind", "bot_bouncer")
1134
1136
  .option("--include-expired", "include expired entries")
1135
1137
  .action(async (opts) => {
1136
- if (opts.team) {
1138
+ if (resolveTeamId(opts.team)) {
1137
1139
  console.error("[deprecated] -t/--team is ignored for blocklists (system-level); omit on next release.");
1138
1140
  }
1139
1141
  const res = await requireClient().listSystemSubredditBlocklists({
@@ -1150,7 +1152,7 @@ compliance
1150
1152
  .option("--kind <kind>", "blocklist kind", "bot_bouncer")
1151
1153
  .option("-j, --json <json>", "optional { reason, source, expiresInDays }", "{}")
1152
1154
  .action(async (opts) => {
1153
- if (opts.team) {
1155
+ if (resolveTeamId(opts.team)) {
1154
1156
  console.error("[deprecated] -t/--team is ignored for blocklists (system-level); omit on next release.");
1155
1157
  }
1156
1158
  let extra = {};
@@ -1174,7 +1176,7 @@ compliance
1174
1176
  .requiredOption("--sub <name>", "subreddit name")
1175
1177
  .option("--kind <kind>", "blocklist kind", "bot_bouncer")
1176
1178
  .action(async (opts) => {
1177
- if (opts.team) {
1179
+ if (resolveTeamId(opts.team)) {
1178
1180
  console.error("[deprecated] -t/--team is ignored for blocklists (system-level); omit on next release.");
1179
1181
  }
1180
1182
  const res = await requireClient().deleteSystemSubredditBlocklist(opts.sub, {
@@ -1189,22 +1191,22 @@ const openclawIngest = program
1189
1191
  openclawIngest
1190
1192
  .command("status")
1191
1193
  .description("GET /openclaw-ingest/runs/:runId")
1192
- .requiredOption("-t, --team <teamId>", "Team UUID")
1194
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1193
1195
  .requiredOption("--run <runId>", "Ingest run UUID")
1194
1196
  .action(async (opts) => {
1195
- const res = await requireClient().getOpenClawIngestRun(opts.team, opts.run);
1197
+ const res = await requireClient().getOpenClawIngestRun(resolveTeamId(opts.team), opts.run);
1196
1198
  console.log(JSON.stringify(res, null, 2));
1197
1199
  });
1198
1200
  openclawIngest
1199
1201
  .command("runs")
1200
1202
  .description("GET /openclaw-ingest/runs")
1201
- .requiredOption("-t, --team <teamId>", "Team UUID")
1203
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1202
1204
  .option("--status <status>", "queued | running | succeeded | failed | partial")
1203
1205
  .option("--mode <mode>", "dry-run | apply")
1204
1206
  .option("-n, --limit <n>", "page size (max 200)", "50")
1205
1207
  .option("--offset <n>", "offset", "0")
1206
1208
  .action(async (opts) => {
1207
- const res = await requireClient().listOpenClawIngestRuns(opts.team, {
1209
+ const res = await requireClient().listOpenClawIngestRuns(resolveTeamId(opts.team), {
1208
1210
  status: opts.status,
1209
1211
  mode: opts.mode,
1210
1212
  limit: Number(opts.limit),
@@ -1227,7 +1229,7 @@ openclawIngest
1227
1229
  .option("--op-report-file <path>", "op report file (repeatable)", collect, [])
1228
1230
  .option("-j, --json <json>", "advanced body override JSON")
1229
1231
  .action(async (opts) => {
1230
- if (!opts.team) {
1232
+ if (!resolveTeamId(opts.team)) {
1231
1233
  console.error("Missing required option -t / --team (or use: openclaw-ingest status)");
1232
1234
  process.exit(1);
1233
1235
  }
@@ -1269,7 +1271,7 @@ openclawIngest
1269
1271
  if (Object.keys(sourcePaths).length > 0) {
1270
1272
  body.sourcePaths = sourcePaths;
1271
1273
  }
1272
- const res = await requireClient().triggerOpenClawIngest(opts.team, body);
1274
+ const res = await requireClient().triggerOpenClawIngest(resolveTeamId(opts.team), body);
1273
1275
  console.log(JSON.stringify(res, null, 2));
1274
1276
  });
1275
1277
  function collect(value, previous) {
@@ -1281,10 +1283,10 @@ function collect(value, previous) {
1281
1283
  accounts
1282
1284
  .command("get")
1283
1285
  .description("GET /accounts/:id")
1284
- .requiredOption("-t, --team <teamId>", "Team UUID")
1286
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1285
1287
  .requiredOption("--account <uuid>", "Account UUID")
1286
1288
  .action(async (opts) => {
1287
- const res = await requireClient().getAccount(opts.team, opts.account);
1289
+ const res = await requireClient().getAccount(resolveTeamId(opts.team), opts.account);
1288
1290
  console.log(JSON.stringify(res, null, 2));
1289
1291
  });
1290
1292
  // 这些字段不在 social_accounts 核心表上,各自是独立资源面;放进 accounts update
@@ -1312,7 +1314,7 @@ export function detectMisplacedAccountFields(body) {
1312
1314
  accounts
1313
1315
  .command("update")
1314
1316
  .description("PATCH /accounts/:id — 更新 handle/status/karma/accountAgeDays 等核心字段。安全时段/时区/风险级别请用 `compliance risk-put`;浏览器环境请用 `browser-envs`")
1315
- .requiredOption("-t, --team <teamId>", "Team UUID")
1317
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1316
1318
  .requiredOption("--account <uuid>", "Account UUID")
1317
1319
  .requiredOption("-j, --json <json>", "{ handle?, profileUrl?, status?, externalId?, externalRef?, personaId?, karma?, accountAgeDays?, registeredAt?, workflowStage?, metricsSource?, metricsUpdatedAt?, credentialsRef?, primaryProducts? }")
1318
1320
  .action(async (opts) => {
@@ -1322,7 +1324,7 @@ accounts
1322
1324
  console.error(misplaced);
1323
1325
  process.exit(1);
1324
1326
  }
1325
- const res = await requireClient().updateAccount(opts.team, opts.account, body);
1327
+ const res = await requireClient().updateAccount(resolveTeamId(opts.team), opts.account, body);
1326
1328
  console.log(JSON.stringify(res, null, 2));
1327
1329
  });
1328
1330
  accounts
@@ -1332,7 +1334,7 @@ accounts
1332
1334
  .requiredOption("--account <uuid>", "Account UUID")
1333
1335
  .requiredOption("--to <teamId>", "目标 Team UUID")
1334
1336
  .action(async (opts) => {
1335
- const res = await requireClient().reassignAccount(opts.team, opts.account, {
1337
+ const res = await requireClient().reassignAccount(resolveTeamId(opts.team), opts.account, {
1336
1338
  toTeamId: opts.to,
1337
1339
  });
1338
1340
  console.log(JSON.stringify(res, null, 2));
@@ -1343,7 +1345,7 @@ accounts
1343
1345
  accounts
1344
1346
  .command("sync")
1345
1347
  .description("账号数据多面一次性同步(core/riskProfile/guardrails/brandBindings/personas/affinities/browserEnvironments);逐面写、汇总报告、任一失败退出码非零。core 仅核心账号字段——安全时段/时区/风险级别放 riskProfile 面,浏览器环境放 browserEnvironments 面")
1346
- .requiredOption("-t, --team <teamId>", "Team UUID")
1348
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1347
1349
  .requiredOption("--account <uuid>", "Account UUID")
1348
1350
  .requiredOption("-j, --json <json>", "{ core?, riskProfile?, guardrails?, brandBindings?: (uuid|{brandId})[], personas?: (md|{markdown})[], affinities?: {subreddit,...}[], browserEnvironments?: {browserProvider,environmentId,...}[] }")
1349
1351
  .action(async (opts) => {
@@ -1356,7 +1358,7 @@ accounts
1356
1358
  process.exit(1);
1357
1359
  }
1358
1360
  const client = requireClient();
1359
- const team = opts.team;
1361
+ const team = resolveTeamId(opts.team);
1360
1362
  const account = opts.account;
1361
1363
  const results = [];
1362
1364
  const run = async (face, target, fn) => {
@@ -1481,59 +1483,59 @@ accounts
1481
1483
  campaigns
1482
1484
  .command("get")
1483
1485
  .description("GET /campaigns/:id")
1484
- .requiredOption("-t, --team <teamId>", "Team UUID")
1486
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1485
1487
  .requiredOption("--campaign <uuid>", "Campaign UUID")
1486
1488
  .action(async (opts) => {
1487
- const res = await requireClient().getCampaign(opts.team, opts.campaign);
1489
+ const res = await requireClient().getCampaign(resolveTeamId(opts.team), opts.campaign);
1488
1490
  console.log(JSON.stringify(res, null, 2));
1489
1491
  });
1490
1492
  campaigns
1491
1493
  .command("update")
1492
1494
  .description("PATCH /campaigns/:id")
1493
- .requiredOption("-t, --team <teamId>", "Team UUID")
1495
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1494
1496
  .requiredOption("--campaign <uuid>", "Campaign UUID")
1495
1497
  .requiredOption("-j, --json <json>", "{ name?, startsAt?, endsAt? }")
1496
1498
  .action(async (opts) => {
1497
1499
  const body = JSON.parse(opts.json);
1498
- const res = await requireClient().updateCampaign(opts.team, opts.campaign, body);
1500
+ const res = await requireClient().updateCampaign(resolveTeamId(opts.team), opts.campaign, body);
1499
1501
  console.log(JSON.stringify(res, null, 2));
1500
1502
  });
1501
1503
  drafts
1502
1504
  .command("get")
1503
1505
  .description("GET /content-drafts/:id")
1504
- .requiredOption("-t, --team <teamId>", "Team UUID")
1506
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1505
1507
  .requiredOption("--draft <uuid>", "Draft UUID")
1506
1508
  .action(async (opts) => {
1507
- const res = await requireClient().getContentDraft(opts.team, opts.draft);
1509
+ const res = await requireClient().getContentDraft(resolveTeamId(opts.team), opts.draft);
1508
1510
  console.log(JSON.stringify(res, null, 2));
1509
1511
  });
1510
1512
  drafts
1511
1513
  .command("update")
1512
1514
  .description("PATCH /content-drafts/:id")
1513
- .requiredOption("-t, --team <teamId>", "Team UUID")
1515
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1514
1516
  .requiredOption("--draft <uuid>", "Draft UUID")
1515
1517
  .requiredOption("-j, --json <json>", "{ title?, body?, status?, expectedVersion? }(传 expectedVersion 开乐观并发,版本不匹配→409)")
1516
1518
  .action(async (opts) => {
1517
1519
  const body = JSON.parse(opts.json);
1518
- const res = await requireClient().updateContentDraft(opts.team, opts.draft, body);
1520
+ const res = await requireClient().updateContentDraft(resolveTeamId(opts.team), opts.draft, body);
1519
1521
  console.log(JSON.stringify(res, null, 2));
1520
1522
  });
1521
1523
  drafts
1522
1524
  .command("delete")
1523
1525
  .description("DELETE /content-drafts/:id")
1524
- .requiredOption("-t, --team <teamId>", "Team UUID")
1526
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1525
1527
  .requiredOption("--draft <uuid>", "Draft UUID")
1526
1528
  .action(async (opts) => {
1527
- await requireClient().deleteContentDraft(opts.team, opts.draft);
1529
+ await requireClient().deleteContentDraft(resolveTeamId(opts.team), opts.draft);
1528
1530
  console.log("OK");
1529
1531
  });
1530
1532
  plans
1531
1533
  .command("cancel")
1532
1534
  .description("DELETE /publishing-plans/:id(取消)")
1533
- .requiredOption("-t, --team <teamId>", "Team UUID")
1535
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1534
1536
  .requiredOption("--plan <uuid>", "Plan UUID")
1535
1537
  .action(async (opts) => {
1536
- await requireClient().cancelPublishingPlan(opts.team, opts.plan);
1538
+ await requireClient().cancelPublishingPlan(resolveTeamId(opts.team), opts.plan);
1537
1539
  console.log("OK");
1538
1540
  });
1539
1541
  // ═══════════════════════════════════════════════════════════════════════════
@@ -1559,7 +1561,7 @@ agentTeams
1559
1561
  agentTeams
1560
1562
  .command("workspace-docs")
1561
1563
  .description("GET /v1/agent-teams/:teamId/workspace-documents")
1562
- .requiredOption("-t, --team <teamId>", "Team UUID")
1564
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1563
1565
  .option("--kind <kind>", "file|daily_report|weekly_report|ops_record")
1564
1566
  .option("-n, --limit <n>", "limit", "50")
1565
1567
  .action(async (opts) => {
@@ -1567,9 +1569,9 @@ agentTeams
1567
1569
  command: "agent-teams workspace-docs",
1568
1570
  resource: "agentTeam",
1569
1571
  action: "read",
1570
- teamId: opts.team,
1572
+ teamId: resolveTeamId(opts.team),
1571
1573
  }, async () => {
1572
- const res = await requireClient().listWorkspaceDocuments(opts.team, {
1574
+ const res = await requireClient().listWorkspaceDocuments(resolveTeamId(opts.team), {
1573
1575
  kind: opts.kind,
1574
1576
  limit: Number(opts.limit),
1575
1577
  });
@@ -1585,11 +1587,11 @@ const migrationWorkspaceDocs = migration
1585
1587
  migrationWorkspaceDocs
1586
1588
  .command("list")
1587
1589
  .description("List workspace documents")
1588
- .requiredOption("-t, --team <teamId>", "Team UUID")
1590
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1589
1591
  .option("--kind <kind>", "document kind filter")
1590
1592
  .option("-n, --limit <n>", "limit", "50")
1591
1593
  .action(async (opts) => {
1592
- const res = await requireClient().listWorkspaceDocuments(opts.team, {
1594
+ const res = await requireClient().listWorkspaceDocuments(resolveTeamId(opts.team), {
1593
1595
  kind: opts.kind,
1594
1596
  limit: Number(opts.limit),
1595
1597
  });
@@ -1598,10 +1600,10 @@ migrationWorkspaceDocs
1598
1600
  migrationWorkspaceDocs
1599
1601
  .command("refs")
1600
1602
  .description("GET workspace document parsed refs")
1601
- .requiredOption("-t, --team <teamId>", "Team UUID")
1603
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1602
1604
  .requiredOption("--doc <documentId>", "Workspace document UUID")
1603
1605
  .action(async (opts) => {
1604
- const res = await requireClient().listWorkspaceDocumentRefs(opts.team, opts.doc);
1606
+ const res = await requireClient().listWorkspaceDocumentRefs(resolveTeamId(opts.team), opts.doc);
1605
1607
  console.log(JSON.stringify(res, null, 2));
1606
1608
  });
1607
1609
  agentTeams
@@ -1634,7 +1636,7 @@ agentTeams
1634
1636
  agentTeams
1635
1637
  .command("update")
1636
1638
  .description("PATCH /v1/agent-teams/:teamId — 更新团队(admin only)")
1637
- .requiredOption("-t, --team <teamId>", "Team UUID")
1639
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1638
1640
  .requiredOption("-j, --json <json>", "{ slug?, name? }")
1639
1641
  .option("--dry-run", "预览", false)
1640
1642
  .option("--apply", "执行写入", false)
@@ -1643,24 +1645,24 @@ agentTeams
1643
1645
  command: "agent-teams update",
1644
1646
  resource: "agentTeam",
1645
1647
  action: "update",
1646
- teamId: opts.team,
1648
+ teamId: resolveTeamId(opts.team),
1647
1649
  }, async () => {
1648
1650
  const body = JSON.parse(opts.json);
1649
1651
  if (!assertApplyOrDryRun(opts, {
1650
1652
  command: "agent-teams update",
1651
1653
  danger: "admin",
1652
- summary: { teamId: opts.team, ...body },
1654
+ summary: { teamId: resolveTeamId(opts.team), ...body },
1653
1655
  })) {
1654
1656
  return;
1655
1657
  }
1656
- const res = await requireClient().updateTeam(opts.team, body);
1658
+ const res = await requireClient().updateTeam(resolveTeamId(opts.team), body);
1657
1659
  console.log(JSON.stringify(res, null, 2));
1658
1660
  });
1659
1661
  });
1660
1662
  agentTeams
1661
1663
  .command("add-member")
1662
1664
  .description("POST /v1/agent-teams/:teamId/members — 添加成员(admin only)")
1663
- .requiredOption("-t, --team <teamId>", "Team UUID")
1665
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1664
1666
  .requiredOption("--user <userId>", "User UUID")
1665
1667
  .requiredOption("--role <role>", "admin|manager|supervisor|senior|internal|client")
1666
1668
  .option("--dry-run", "预览", false)
@@ -1670,20 +1672,20 @@ agentTeams
1670
1672
  command: "agent-teams add-member",
1671
1673
  resource: "agentTeam",
1672
1674
  action: "update",
1673
- teamId: opts.team,
1675
+ teamId: resolveTeamId(opts.team),
1674
1676
  }, async () => {
1675
1677
  if (!assertApplyOrDryRun(opts, {
1676
1678
  command: "agent-teams add-member",
1677
1679
  danger: "admin",
1678
1680
  summary: {
1679
- teamId: opts.team,
1681
+ teamId: resolveTeamId(opts.team),
1680
1682
  userId: opts.user,
1681
1683
  role: opts.role,
1682
1684
  },
1683
1685
  })) {
1684
1686
  return;
1685
1687
  }
1686
- const res = await requireClient().addTeamMember(opts.team, {
1688
+ const res = await requireClient().addTeamMember(resolveTeamId(opts.team), {
1687
1689
  userId: opts.user,
1688
1690
  role: opts.role,
1689
1691
  });
@@ -1697,14 +1699,14 @@ const pools = program
1697
1699
  pools
1698
1700
  .command("catalog-list")
1699
1701
  .description("GET .../subreddit-pools/catalog")
1700
- .requiredOption("-t, --team <teamId>", "Team UUID")
1702
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1701
1703
  .option("--status <s>", "active|paused|archived")
1702
1704
  .option("--industry-key <key>", "industryKey filter")
1703
1705
  .option("--pool-kind <kind>", "pet|common|industry|brand|other")
1704
1706
  .option("-n, --limit <n>", "limit", "50")
1705
1707
  .option("--offset <n>", "offset", "0")
1706
1708
  .action(async (opts) => {
1707
- const res = await requireClient().listSubredditPoolsCatalog(opts.team, {
1709
+ const res = await requireClient().listSubredditPoolsCatalog(resolveTeamId(opts.team), {
1708
1710
  status: opts.status,
1709
1711
  industryKey: opts.industryKey,
1710
1712
  poolKind: opts.poolKind,
@@ -1716,43 +1718,43 @@ pools
1716
1718
  pools
1717
1719
  .command("catalog-create")
1718
1720
  .description("POST .../subreddit-pools/catalog")
1719
- .requiredOption("-t, --team <teamId>", "Team UUID")
1721
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1720
1722
  .requiredOption("-j, --json <json>", "pool catalog body")
1721
1723
  .action(async (opts) => {
1722
1724
  const body = JSON.parse(opts.json);
1723
- const res = await requireClient().createSubredditPool(opts.team, body);
1725
+ const res = await requireClient().createSubredditPool(resolveTeamId(opts.team), body);
1724
1726
  console.log(JSON.stringify(res, null, 2));
1725
1727
  });
1726
1728
  pools
1727
1729
  .command("catalog-update")
1728
1730
  .description("PATCH .../subreddit-pools/catalog/:poolId")
1729
- .requiredOption("-t, --team <teamId>", "Team UUID")
1731
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1730
1732
  .requiredOption("--id <uuid>", "Pool UUID")
1731
1733
  .requiredOption("-j, --json <json>", "update body")
1732
1734
  .action(async (opts) => {
1733
1735
  const body = JSON.parse(opts.json);
1734
- const res = await requireClient().updateSubredditPool(opts.team, opts.id, body);
1736
+ const res = await requireClient().updateSubredditPool(resolveTeamId(opts.team), opts.id, body);
1735
1737
  console.log(JSON.stringify(res, null, 2));
1736
1738
  });
1737
1739
  pools
1738
1740
  .command("catalog-delete")
1739
1741
  .description("DELETE .../subreddit-pools/catalog/:poolId (archive)")
1740
- .requiredOption("-t, --team <teamId>", "Team UUID")
1742
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1741
1743
  .requiredOption("--id <uuid>", "Pool UUID")
1742
1744
  .action(async (opts) => {
1743
- const res = await requireClient().deleteSubredditPool(opts.team, opts.id);
1745
+ const res = await requireClient().deleteSubredditPool(resolveTeamId(opts.team), opts.id);
1744
1746
  console.log(JSON.stringify(res, null, 2));
1745
1747
  });
1746
1748
  pools
1747
1749
  .command("aliases-list")
1748
1750
  .description("GET .../subreddit-pools/aliases")
1749
- .requiredOption("-t, --team <teamId>", "Team UUID")
1751
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1750
1752
  .option("--alias-ref <ref>", "aliasRef filter")
1751
1753
  .option("--industry-key <key>", "industryKey filter")
1752
1754
  .option("-n, --limit <n>", "limit", "50")
1753
1755
  .option("--offset <n>", "offset", "0")
1754
1756
  .action(async (opts) => {
1755
- const res = await requireClient().listPoolAliases(opts.team, {
1757
+ const res = await requireClient().listPoolAliases(resolveTeamId(opts.team), {
1756
1758
  aliasRef: opts.aliasRef,
1757
1759
  industryKey: opts.industryKey,
1758
1760
  limit: Number(opts.limit),
@@ -1763,43 +1765,43 @@ pools
1763
1765
  pools
1764
1766
  .command("aliases-create")
1765
1767
  .description("POST .../subreddit-pools/aliases")
1766
- .requiredOption("-t, --team <teamId>", "Team UUID")
1768
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1767
1769
  .requiredOption("-j, --json <json>", "alias body")
1768
1770
  .action(async (opts) => {
1769
1771
  const body = JSON.parse(opts.json);
1770
- const res = await requireClient().createPoolAlias(opts.team, body);
1772
+ const res = await requireClient().createPoolAlias(resolveTeamId(opts.team), body);
1771
1773
  console.log(JSON.stringify(res, null, 2));
1772
1774
  });
1773
1775
  pools
1774
1776
  .command("aliases-update")
1775
1777
  .description("PATCH .../subreddit-pools/aliases/:aliasId")
1776
- .requiredOption("-t, --team <teamId>", "Team UUID")
1778
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1777
1779
  .requiredOption("--id <uuid>", "Alias UUID")
1778
1780
  .requiredOption("-j, --json <json>", "update body")
1779
1781
  .action(async (opts) => {
1780
1782
  const body = JSON.parse(opts.json);
1781
- const res = await requireClient().updatePoolAlias(opts.team, opts.id, body);
1783
+ const res = await requireClient().updatePoolAlias(resolveTeamId(opts.team), opts.id, body);
1782
1784
  console.log(JSON.stringify(res, null, 2));
1783
1785
  });
1784
1786
  pools
1785
1787
  .command("aliases-delete")
1786
1788
  .description("DELETE .../subreddit-pools/aliases/:aliasId (archive)")
1787
- .requiredOption("-t, --team <teamId>", "Team UUID")
1789
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1788
1790
  .requiredOption("--id <uuid>", "Alias UUID")
1789
1791
  .action(async (opts) => {
1790
- const res = await requireClient().deletePoolAlias(opts.team, opts.id);
1792
+ const res = await requireClient().deletePoolAlias(resolveTeamId(opts.team), opts.id);
1791
1793
  console.log(JSON.stringify(res, null, 2));
1792
1794
  });
1793
1795
  pools
1794
1796
  .command("tier-rules-list")
1795
1797
  .description("GET .../subreddit-pools/tier-rules")
1796
- .requiredOption("-t, --team <teamId>", "Team UUID")
1798
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1797
1799
  .option("--tier <tier>", "S0|S1|S2|S3")
1798
1800
  .option("--enabled <bool>", "true|false")
1799
1801
  .option("-n, --limit <n>", "limit", "50")
1800
1802
  .option("--offset <n>", "offset", "0")
1801
1803
  .action(async (opts) => {
1802
- const res = await requireClient().listSubredditPoolTierRules(opts.team, {
1804
+ const res = await requireClient().listSubredditPoolTierRules(resolveTeamId(opts.team), {
1803
1805
  tier: opts.tier,
1804
1806
  enabled: opts.enabled === undefined
1805
1807
  ? undefined
@@ -1812,31 +1814,31 @@ pools
1812
1814
  pools
1813
1815
  .command("tier-rules-create")
1814
1816
  .description("POST .../subreddit-pools/tier-rules")
1815
- .requiredOption("-t, --team <teamId>", "Team UUID")
1817
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1816
1818
  .requiredOption("-j, --json <json>", "tier rule body")
1817
1819
  .action(async (opts) => {
1818
1820
  const body = JSON.parse(opts.json);
1819
- const res = await requireClient().createSubredditPoolTierRule(opts.team, body);
1821
+ const res = await requireClient().createSubredditPoolTierRule(resolveTeamId(opts.team), body);
1820
1822
  console.log(JSON.stringify(res, null, 2));
1821
1823
  });
1822
1824
  pools
1823
1825
  .command("tier-rules-update")
1824
1826
  .description("PATCH .../subreddit-pools/tier-rules/:ruleId")
1825
- .requiredOption("-t, --team <teamId>", "Team UUID")
1827
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1826
1828
  .requiredOption("--id <uuid>", "Rule UUID")
1827
1829
  .requiredOption("-j, --json <json>", "update body")
1828
1830
  .action(async (opts) => {
1829
1831
  const body = JSON.parse(opts.json);
1830
- const res = await requireClient().updateSubredditPoolTierRule(opts.team, opts.id, body);
1832
+ const res = await requireClient().updateSubredditPoolTierRule(resolveTeamId(opts.team), opts.id, body);
1831
1833
  console.log(JSON.stringify(res, null, 2));
1832
1834
  });
1833
1835
  pools
1834
1836
  .command("tier-rules-delete")
1835
1837
  .description("DELETE .../subreddit-pools/tier-rules/:ruleId")
1836
- .requiredOption("-t, --team <teamId>", "Team UUID")
1838
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1837
1839
  .requiredOption("--id <uuid>", "Rule UUID")
1838
1840
  .action(async (opts) => {
1839
- const res = await requireClient().deleteSubredditPoolTierRule(opts.team, opts.id);
1841
+ const res = await requireClient().deleteSubredditPoolTierRule(resolveTeamId(opts.team), opts.id);
1840
1842
  console.log(JSON.stringify(res, null, 2));
1841
1843
  });
1842
1844
  const intel = program
@@ -1845,10 +1847,10 @@ const intel = program
1845
1847
  intel
1846
1848
  .command("industry-pools-list")
1847
1849
  .description("GET .../subreddit-intelligence/industry-pools")
1848
- .requiredOption("-t, --team <teamId>", "Team UUID")
1850
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1849
1851
  .option("-n, --limit <n>", "limit", "50")
1850
1852
  .action(async (opts) => {
1851
- const res = await requireClient().listIndustryPools(opts.team, {
1853
+ const res = await requireClient().listIndustryPools(resolveTeamId(opts.team), {
1852
1854
  limit: Number(opts.limit),
1853
1855
  });
1854
1856
  console.log(JSON.stringify(res, null, 2));
@@ -1963,23 +1965,23 @@ intel
1963
1965
  intel
1964
1966
  .command("dispatch")
1965
1967
  .description("POST .../subreddit-intelligence/hot-posts/dispatch-task")
1966
- .requiredOption("-t, --team <teamId>", "Team UUID")
1968
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1967
1969
  .requiredOption("-j, --json <json>", "{ hotPostId, socialAccountId, action, runAt? }")
1968
1970
  .action(async (opts) => {
1969
1971
  const body = JSON.parse(opts.json);
1970
- const res = await requireClient().dispatchTaskFromHotPost(opts.team, body);
1972
+ const res = await requireClient().dispatchTaskFromHotPost(resolveTeamId(opts.team), body);
1971
1973
  console.log(JSON.stringify(res, null, 2));
1972
1974
  });
1973
1975
  intel
1974
1976
  .command("tier-rules-list")
1975
1977
  .description("GET .../subreddit-intelligence/tier-rules")
1976
- .requiredOption("-t, --team <teamId>", "Team UUID")
1978
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1977
1979
  .option("--tier <tier>", "tier filter")
1978
1980
  .option("--enabled <bool>", "true|false")
1979
1981
  .option("-n, --limit <n>", "limit", "50")
1980
1982
  .option("--offset <n>", "offset", "0")
1981
1983
  .action(async (opts) => {
1982
- const res = await requireClient().listTierRules(opts.team, {
1984
+ const res = await requireClient().listTierRules(resolveTeamId(opts.team), {
1983
1985
  tier: opts.tier,
1984
1986
  enabled: opts.enabled === undefined
1985
1987
  ? undefined
@@ -1992,31 +1994,31 @@ intel
1992
1994
  intel
1993
1995
  .command("tier-rules-create")
1994
1996
  .description("POST .../subreddit-intelligence/tier-rules")
1995
- .requiredOption("-t, --team <teamId>", "Team UUID")
1997
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
1996
1998
  .requiredOption("-j, --json <json>", "tier rule body")
1997
1999
  .action(async (opts) => {
1998
2000
  const body = JSON.parse(opts.json);
1999
- const res = await requireClient().createTierRule(opts.team, body);
2001
+ const res = await requireClient().createTierRule(resolveTeamId(opts.team), body);
2000
2002
  console.log(JSON.stringify(res, null, 2));
2001
2003
  });
2002
2004
  intel
2003
2005
  .command("tier-rules-update")
2004
2006
  .description("PATCH .../subreddit-intelligence/tier-rules/:id")
2005
- .requiredOption("-t, --team <teamId>", "Team UUID")
2007
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2006
2008
  .requiredOption("--id <uuid>", "Tier rule UUID")
2007
2009
  .requiredOption("-j, --json <json>", "update body")
2008
2010
  .action(async (opts) => {
2009
2011
  const body = JSON.parse(opts.json);
2010
- const res = await requireClient().updateTierRule(opts.team, opts.id, body);
2012
+ const res = await requireClient().updateTierRule(resolveTeamId(opts.team), opts.id, body);
2011
2013
  console.log(JSON.stringify(res, null, 2));
2012
2014
  });
2013
2015
  intel
2014
2016
  .command("tier-rules-delete")
2015
2017
  .description("DELETE .../subreddit-intelligence/tier-rules/:id")
2016
- .requiredOption("-t, --team <teamId>", "Team UUID")
2018
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2017
2019
  .requiredOption("--id <uuid>", "Tier rule UUID")
2018
2020
  .action(async (opts) => {
2019
- const res = await requireClient().deleteTierRule(opts.team, opts.id);
2021
+ const res = await requireClient().deleteTierRule(resolveTeamId(opts.team), opts.id);
2020
2022
  console.log(JSON.stringify(res, null, 2));
2021
2023
  });
2022
2024
  intel
@@ -2204,15 +2206,15 @@ const usersCmd = program.command("users").description("团队成员管理");
2204
2206
  usersCmd
2205
2207
  .command("list")
2206
2208
  .description("GET /users")
2207
- .requiredOption("-t, --team <teamId>", "Team UUID")
2209
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2208
2210
  .action(async (opts) => {
2209
2211
  await withPermissionGate({
2210
2212
  command: "users list",
2211
2213
  resource: "systemMember",
2212
2214
  action: "list",
2213
- teamId: opts.team,
2215
+ teamId: resolveTeamId(opts.team),
2214
2216
  }, async () => {
2215
- const res = await requireClient().listUsers(opts.team);
2217
+ const res = await requireClient().listUsers(resolveTeamId(opts.team));
2216
2218
  console.log(JSON.stringify(res, null, 2));
2217
2219
  });
2218
2220
  });
@@ -2232,17 +2234,17 @@ usersCmd
2232
2234
  usersCmd
2233
2235
  .command("create")
2234
2236
  .description("POST /users")
2235
- .requiredOption("-t, --team <teamId>", "Team UUID")
2237
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2236
2238
  .requiredOption("-j, --json <json>", "{ email, password, role? }")
2237
2239
  .action(async (opts) => {
2238
2240
  await withPermissionGate({
2239
2241
  command: "users create",
2240
2242
  resource: "systemMember",
2241
2243
  action: "create",
2242
- teamId: opts.team,
2244
+ teamId: resolveTeamId(opts.team),
2243
2245
  }, async () => {
2244
2246
  const body = JSON.parse(opts.json);
2245
- const res = await requireClient().createUser(opts.team, body);
2247
+ const res = await requireClient().createUser(resolveTeamId(opts.team), body);
2246
2248
  console.log(JSON.stringify(res, null, 2));
2247
2249
  });
2248
2250
  });
@@ -2340,16 +2342,16 @@ brandMembersCmd
2340
2342
  brandMembersCmd
2341
2343
  .command("list")
2342
2344
  .description("GET /teams/:teamId/brand-members (compat)")
2343
- .requiredOption("-t, --team <teamId>", "Team UUID")
2345
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2344
2346
  .option("--user <uuid>", "userId 过滤")
2345
2347
  .action(async (opts) => {
2346
2348
  await withPermissionGate({
2347
2349
  command: "brand-members list",
2348
2350
  resource: "brandMember",
2349
2351
  action: "list",
2350
- teamId: opts.team,
2352
+ teamId: resolveTeamId(opts.team),
2351
2353
  }, async () => {
2352
- const res = await requireClient().listBrandMembers(opts.team, {
2354
+ const res = await requireClient().listBrandMembers(resolveTeamId(opts.team), {
2353
2355
  userId: opts.user,
2354
2356
  });
2355
2357
  console.log(JSON.stringify(res, null, 2));
@@ -2358,7 +2360,7 @@ brandMembersCmd
2358
2360
  brandMembersCmd
2359
2361
  .command("create")
2360
2362
  .description("POST /brand-members")
2361
- .requiredOption("-t, --team <teamId>", "Team UUID")
2363
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2362
2364
  .requiredOption("-j, --json <json>", "{ brandId, userId, role? }")
2363
2365
  .option("--dry-run", "预览", false)
2364
2366
  .option("--apply", "执行写入", false)
@@ -2367,17 +2369,17 @@ brandMembersCmd
2367
2369
  command: "brand-members create",
2368
2370
  resource: "brandMember",
2369
2371
  action: "create",
2370
- teamId: opts.team,
2372
+ teamId: resolveTeamId(opts.team),
2371
2373
  }, async () => {
2372
2374
  const body = JSON.parse(opts.json);
2373
2375
  if (!assertApplyOrDryRun(opts, {
2374
2376
  command: "brand-members create",
2375
2377
  danger: "write",
2376
- summary: { teamId: opts.team, ...body },
2378
+ summary: { teamId: resolveTeamId(opts.team), ...body },
2377
2379
  })) {
2378
2380
  return;
2379
2381
  }
2380
- const res = await requireClient().createBrandMember(opts.team, body);
2382
+ const res = await requireClient().createBrandMember(resolveTeamId(opts.team), body);
2381
2383
  console.log(JSON.stringify(res, null, 2));
2382
2384
  });
2383
2385
  });
@@ -2388,11 +2390,11 @@ const notifChannels = program
2388
2390
  notifChannels
2389
2391
  .command("list")
2390
2392
  .description("GET /notification-channels")
2391
- .requiredOption("-t, --team <teamId>", "Team UUID")
2393
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2392
2394
  .option("--brand <uuid>", "brandId 过滤(推荐)")
2393
2395
  .option("--campaign <uuid>", "campaignId 过滤(legacy)")
2394
2396
  .action(async (opts) => {
2395
- const res = await requireClient().listNotificationChannels(opts.team, {
2397
+ const res = await requireClient().listNotificationChannels(resolveTeamId(opts.team), {
2396
2398
  brandId: opts.brand,
2397
2399
  campaignId: opts.campaign,
2398
2400
  });
@@ -2401,40 +2403,40 @@ notifChannels
2401
2403
  notifChannels
2402
2404
  .command("create")
2403
2405
  .description("POST /notification-channels")
2404
- .requiredOption("-t, --team <teamId>", "Team UUID")
2406
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2405
2407
  .requiredOption("-j, --json <json>", "{ provider, externalId, minRole?, brandId?, campaignId? }")
2406
2408
  .action(async (opts) => {
2407
2409
  const body = JSON.parse(opts.json);
2408
- const res = await requireClient().createNotificationChannel(opts.team, body);
2410
+ const res = await requireClient().createNotificationChannel(resolveTeamId(opts.team), body);
2409
2411
  console.log(JSON.stringify(res, null, 2));
2410
2412
  });
2411
2413
  notifChannels
2412
2414
  .command("update")
2413
2415
  .description("PATCH /notification-channels/:id")
2414
- .requiredOption("-t, --team <teamId>", "Team UUID")
2416
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2415
2417
  .requiredOption("--channel <uuid>", "Channel UUID")
2416
2418
  .requiredOption("-j, --json <json>", "update body")
2417
2419
  .action(async (opts) => {
2418
2420
  const body = JSON.parse(opts.json);
2419
- const res = await requireClient().updateNotificationChannel(opts.team, opts.channel, body);
2421
+ const res = await requireClient().updateNotificationChannel(resolveTeamId(opts.team), opts.channel, body);
2420
2422
  console.log(JSON.stringify(res, null, 2));
2421
2423
  });
2422
2424
  notifChannels
2423
2425
  .command("delete")
2424
2426
  .description("DELETE /notification-channels/:id")
2425
- .requiredOption("-t, --team <teamId>", "Team UUID")
2427
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2426
2428
  .requiredOption("--channel <uuid>", "Channel UUID")
2427
2429
  .action(async (opts) => {
2428
- await requireClient().deleteNotificationChannel(opts.team, opts.channel);
2430
+ await requireClient().deleteNotificationChannel(resolveTeamId(opts.team), opts.channel);
2429
2431
  console.log("OK");
2430
2432
  });
2431
2433
  notifChannels
2432
2434
  .command("test")
2433
2435
  .description("POST /notification-channels/:id/test")
2434
- .requiredOption("-t, --team <teamId>", "Team UUID")
2436
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2435
2437
  .requiredOption("--channel <uuid>", "Channel UUID")
2436
2438
  .action(async (opts) => {
2437
- const res = await requireClient().testNotificationChannel(opts.team, opts.channel);
2439
+ const res = await requireClient().testNotificationChannel(resolveTeamId(opts.team), opts.channel);
2438
2440
  console.log(JSON.stringify(res, null, 2));
2439
2441
  });
2440
2442
  // --- api-keys ---
@@ -2442,16 +2444,16 @@ const apiKeys = program.command("api-keys").description("API Key 管理");
2442
2444
  apiKeys
2443
2445
  .command("list")
2444
2446
  .description("GET /api-keys")
2445
- .requiredOption("-t, --team <teamId>", "Team UUID")
2447
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2446
2448
  .option("-n, --limit <n>", "limit", "50")
2447
2449
  .action(async (opts) => {
2448
2450
  await withPermissionGate({
2449
2451
  command: "api-keys list",
2450
2452
  resource: "apiKey",
2451
2453
  action: "list",
2452
- teamId: opts.team,
2454
+ teamId: resolveTeamId(opts.team),
2453
2455
  }, async () => {
2454
- const res = await requireClient().listApiKeys(opts.team, {
2456
+ const res = await requireClient().listApiKeys(resolveTeamId(opts.team), {
2455
2457
  limit: Number(opts.limit),
2456
2458
  });
2457
2459
  console.log(JSON.stringify(res, null, 2));
@@ -2460,7 +2462,7 @@ apiKeys
2460
2462
  apiKeys
2461
2463
  .command("create")
2462
2464
  .description("POST /api-keys")
2463
- .requiredOption("-t, --team <teamId>", "Team UUID")
2465
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2464
2466
  .requiredOption("-j, --json <json>", "{ name, role, visibleCampaignIds? }")
2465
2467
  .option("--dry-run", "预览", false)
2466
2468
  .option("--apply", "执行写入", false)
@@ -2469,24 +2471,24 @@ apiKeys
2469
2471
  command: "api-keys create",
2470
2472
  resource: "apiKey",
2471
2473
  action: "create",
2472
- teamId: opts.team,
2474
+ teamId: resolveTeamId(opts.team),
2473
2475
  }, async () => {
2474
2476
  const body = JSON.parse(opts.json);
2475
2477
  if (!assertApplyOrDryRun(opts, {
2476
2478
  command: "api-keys create",
2477
2479
  danger: "secret",
2478
- summary: { teamId: opts.team, ...body },
2480
+ summary: { teamId: resolveTeamId(opts.team), ...body },
2479
2481
  })) {
2480
2482
  return;
2481
2483
  }
2482
- const res = await requireClient().createApiKey(opts.team, body);
2484
+ const res = await requireClient().createApiKey(resolveTeamId(opts.team), body);
2483
2485
  console.log(JSON.stringify(res, null, 2));
2484
2486
  });
2485
2487
  });
2486
2488
  apiKeys
2487
2489
  .command("delete")
2488
2490
  .description("DELETE /api-keys/:id")
2489
- .requiredOption("-t, --team <teamId>", "Team UUID")
2491
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2490
2492
  .requiredOption("--key <uuid>", "API Key UUID")
2491
2493
  .option("--dry-run", "预览", false)
2492
2494
  .option("--apply", "执行写入", false)
@@ -2495,23 +2497,23 @@ apiKeys
2495
2497
  command: "api-keys delete",
2496
2498
  resource: "apiKey",
2497
2499
  action: "delete",
2498
- teamId: opts.team,
2500
+ teamId: resolveTeamId(opts.team),
2499
2501
  }, async () => {
2500
2502
  if (!assertApplyOrDryRun(opts, {
2501
2503
  command: "api-keys delete",
2502
2504
  danger: "delete",
2503
- summary: { teamId: opts.team, keyId: opts.key },
2505
+ summary: { teamId: resolveTeamId(opts.team), keyId: opts.key },
2504
2506
  })) {
2505
2507
  return;
2506
2508
  }
2507
- await requireClient().deleteApiKey(opts.team, opts.key);
2509
+ await requireClient().deleteApiKey(resolveTeamId(opts.team), opts.key);
2508
2510
  console.log("OK");
2509
2511
  });
2510
2512
  });
2511
2513
  apiKeys
2512
2514
  .command("rotate")
2513
2515
  .description("POST /api-keys/:id/rotate")
2514
- .requiredOption("-t, --team <teamId>", "Team UUID")
2516
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2515
2517
  .requiredOption("--key <uuid>", "API Key UUID")
2516
2518
  .option("--dry-run", "预览", false)
2517
2519
  .option("--apply", "执行写入", false)
@@ -2520,23 +2522,23 @@ apiKeys
2520
2522
  command: "api-keys rotate",
2521
2523
  resource: "apiKey",
2522
2524
  action: "update",
2523
- teamId: opts.team,
2525
+ teamId: resolveTeamId(opts.team),
2524
2526
  }, async () => {
2525
2527
  if (!assertApplyOrDryRun(opts, {
2526
2528
  command: "api-keys rotate",
2527
2529
  danger: "secret",
2528
- summary: { teamId: opts.team, keyId: opts.key },
2530
+ summary: { teamId: resolveTeamId(opts.team), keyId: opts.key },
2529
2531
  })) {
2530
2532
  return;
2531
2533
  }
2532
- const res = await requireClient().rotateApiKey(opts.team, opts.key);
2534
+ const res = await requireClient().rotateApiKey(resolveTeamId(opts.team), opts.key);
2533
2535
  console.log(JSON.stringify(res, null, 2));
2534
2536
  });
2535
2537
  });
2536
2538
  apiKeys
2537
2539
  .command("batch-revoke")
2538
2540
  .description("POST /api-keys/batch/revoke")
2539
- .requiredOption("-t, --team <teamId>", "Team UUID")
2541
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2540
2542
  .requiredOption("-j, --json <json>", '{ "apiKeyIds": ["uuid1","uuid2"] }')
2541
2543
  .option("--dry-run", "预览", false)
2542
2544
  .option("--apply", "执行写入", false)
@@ -2545,25 +2547,25 @@ apiKeys
2545
2547
  command: "api-keys batch-revoke",
2546
2548
  resource: "apiKey",
2547
2549
  action: "delete",
2548
- teamId: opts.team,
2550
+ teamId: resolveTeamId(opts.team),
2549
2551
  }, async () => {
2550
2552
  const body = JSON.parse(opts.json);
2551
2553
  const apiKeyIds = body.apiKeyIds ?? body.ids ?? [];
2552
2554
  if (!assertApplyOrDryRun(opts, {
2553
2555
  command: "api-keys batch-revoke",
2554
2556
  danger: "delete",
2555
- summary: { teamId: opts.team, apiKeyIds },
2557
+ summary: { teamId: resolveTeamId(opts.team), apiKeyIds },
2556
2558
  })) {
2557
2559
  return;
2558
2560
  }
2559
- const res = await requireClient().batchRevokeApiKeys(opts.team, apiKeyIds);
2561
+ const res = await requireClient().batchRevokeApiKeys(resolveTeamId(opts.team), apiKeyIds);
2560
2562
  console.log(JSON.stringify(res, null, 2));
2561
2563
  });
2562
2564
  });
2563
2565
  apiKeys
2564
2566
  .command("batch-rotate")
2565
2567
  .description("POST /api-keys/batch/rotate")
2566
- .requiredOption("-t, --team <teamId>", "Team UUID")
2568
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2567
2569
  .requiredOption("-j, --json <json>", '{ "apiKeyIds": ["uuid1","uuid2"] }')
2568
2570
  .option("--dry-run", "预览", false)
2569
2571
  .option("--apply", "执行写入", false)
@@ -2572,18 +2574,18 @@ apiKeys
2572
2574
  command: "api-keys batch-rotate",
2573
2575
  resource: "apiKey",
2574
2576
  action: "update",
2575
- teamId: opts.team,
2577
+ teamId: resolveTeamId(opts.team),
2576
2578
  }, async () => {
2577
2579
  const body = JSON.parse(opts.json);
2578
2580
  const apiKeyIds = body.apiKeyIds ?? body.ids ?? [];
2579
2581
  if (!assertApplyOrDryRun(opts, {
2580
2582
  command: "api-keys batch-rotate",
2581
2583
  danger: "secret",
2582
- summary: { teamId: opts.team, apiKeyIds },
2584
+ summary: { teamId: resolveTeamId(opts.team), apiKeyIds },
2583
2585
  })) {
2584
2586
  return;
2585
2587
  }
2586
- const res = await requireClient().batchRotateApiKeys(opts.team, apiKeyIds);
2588
+ const res = await requireClient().batchRotateApiKeys(resolveTeamId(opts.team), apiKeyIds);
2587
2589
  console.log(JSON.stringify(res, null, 2));
2588
2590
  });
2589
2591
  });
@@ -2593,16 +2595,17 @@ apiKeys
2593
2595
  events
2594
2596
  .command("export-csv")
2595
2597
  .description("GET /events/export.csv(输出 CSV 到 stdout)")
2596
- .requiredOption("-t, --team <teamId>", "Team UUID")
2598
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2597
2599
  .option("--type <type>", "事件 type 过滤")
2598
2600
  .option("--actor <actor>", "user|agent|cron")
2599
2601
  .option("--result <result>", "succeeded|failed|skipped")
2602
+ .option("--brand <uuid>", "品牌过滤(显式关联或账号单绑自动继承)")
2600
2603
  .option("--account <uuid>", "socialAccountId 过滤")
2601
2604
  .option("--from <iso>", "createdFrom ISO 时间")
2602
2605
  .option("--to <iso>", "createdTo ISO 时间")
2603
2606
  .option("-n, --limit <n>", "limit", "1000")
2604
2607
  .action(async (opts) => {
2605
- const csv = await requireClient().exportEventsCsv(opts.team, {
2608
+ const csv = await requireClient().exportEventsCsv(resolveTeamId(opts.team), {
2606
2609
  type: opts.type,
2607
2610
  actor: opts.actor,
2608
2611
  result: opts.result,
@@ -2616,49 +2619,49 @@ events
2616
2619
  reports
2617
2620
  .command("create")
2618
2621
  .description("POST /reports(直写入库,非队列 ingest)")
2619
- .requiredOption("-t, --team <teamId>", "Team UUID")
2622
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2620
2623
  .requiredOption("-j, --json <json>", "{ reportType, title, source, contentMarkdown, summary?, campaignId?, traceId? }")
2621
2624
  .action(async (opts) => {
2622
2625
  const body = JSON.parse(opts.json);
2623
- const res = await requireClient().createReport(opts.team, body);
2626
+ const res = await requireClient().createReport(resolveTeamId(opts.team), body);
2624
2627
  console.log(JSON.stringify(res, null, 2));
2625
2628
  });
2626
2629
  jobs
2627
2630
  .command("agent-status")
2628
2631
  .description("POST /scheduled-jobs/:id/agent-status(Agent 回写任务状态)")
2629
- .requiredOption("-t, --team <teamId>", "Team UUID")
2632
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2630
2633
  .requiredOption("-i, --id <jobId>", "Job UUID")
2631
2634
  .requiredOption("-j, --json <json>", '{ "status": "running"|"succeeded"|"failed", "lastError"?, "payload"? }')
2632
2635
  .action(async (opts) => {
2633
2636
  const body = JSON.parse(opts.json);
2634
- const res = await requireClient().updateJobAgentStatus(opts.team, opts.id, body);
2637
+ const res = await requireClient().updateJobAgentStatus(resolveTeamId(opts.team), opts.id, body);
2635
2638
  console.log(JSON.stringify(res, null, 2));
2636
2639
  });
2637
2640
  program
2638
2641
  .command("permissions-update")
2639
2642
  .description("PATCH /permissions-matrix(更新权限矩阵,admin only)")
2640
- .requiredOption("-t, --team <teamId>", "Team UUID")
2643
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2641
2644
  .requiredOption("-j, --json <json>", "权限矩阵更新 body")
2642
2645
  .action(async (opts) => {
2643
2646
  await withPermissionGate({
2644
2647
  command: "permissions-update",
2645
2648
  resource: "permissionMatrix",
2646
2649
  action: "update",
2647
- teamId: opts.team,
2650
+ teamId: resolveTeamId(opts.team),
2648
2651
  }, async () => {
2649
2652
  const body = JSON.parse(opts.json);
2650
- const res = await requireClient().updatePermissionsMatrix(opts.team, body);
2653
+ const res = await requireClient().updatePermissionsMatrix(resolveTeamId(opts.team), body);
2651
2654
  console.log(JSON.stringify(res, null, 2));
2652
2655
  });
2653
2656
  });
2654
2657
  graph
2655
2658
  .command("drilldown")
2656
2659
  .description("GET /account-graph/drilldown(账号追溯)")
2657
- .requiredOption("-t, --team <teamId>", "Team UUID")
2660
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2658
2661
  .requiredOption("--account <uuid>", "socialAccountId")
2659
2662
  .option("-n, --limit <n>", "limit", "20")
2660
2663
  .action(async (opts) => {
2661
- const res = await requireClient().getAccountGraphDrilldown(opts.team, {
2664
+ const res = await requireClient().getAccountGraphDrilldown(resolveTeamId(opts.team), {
2662
2665
  socialAccountId: opts.account,
2663
2666
  limit: Number(opts.limit),
2664
2667
  });
@@ -2667,7 +2670,7 @@ graph
2667
2670
  graph
2668
2671
  .command("v2-ego")
2669
2672
  .description("GET /graph/v2/ego")
2670
- .requiredOption("-t, --team <teamId>", "Team UUID")
2673
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2671
2674
  .option("--node-id <uuid>", "graph nodeId")
2672
2675
  .option("--node-ref <id>", "nodeRefId (e.g. account UUID)")
2673
2676
  .option("--node-type <type>", "account|team|campaign")
@@ -2675,7 +2678,7 @@ graph
2675
2678
  .option("--edge-kind <kind>", "edgeKind filter")
2676
2679
  .option("-n, --limit <n>", "limit", "100")
2677
2680
  .action(async (opts) => {
2678
- const res = await requireClient().getGraphV2Ego(opts.team, {
2681
+ const res = await requireClient().getGraphV2Ego(resolveTeamId(opts.team), {
2679
2682
  nodeId: opts.nodeId,
2680
2683
  nodeRefId: opts.nodeRef,
2681
2684
  nodeType: opts.nodeType,
@@ -2688,7 +2691,7 @@ graph
2688
2691
  graph
2689
2692
  .command("v2-timeline")
2690
2693
  .description("GET /graph/v2/timeline")
2691
- .requiredOption("-t, --team <teamId>", "Team UUID")
2694
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2692
2695
  .option("--node-id <uuid>", "graph nodeId")
2693
2696
  .option("--node-ref <id>", "nodeRefId")
2694
2697
  .option("--node-type <type>", "account|team|campaign")
@@ -2696,7 +2699,7 @@ graph
2696
2699
  .option("--to <iso>", "to ISO time")
2697
2700
  .option("-n, --limit <n>", "limit", "100")
2698
2701
  .action(async (opts) => {
2699
- const res = await requireClient().getGraphV2Timeline(opts.team, {
2702
+ const res = await requireClient().getGraphV2Timeline(resolveTeamId(opts.team), {
2700
2703
  nodeId: opts.nodeId,
2701
2704
  nodeRefId: opts.nodeRef,
2702
2705
  nodeType: opts.nodeType,
@@ -2709,16 +2712,16 @@ graph
2709
2712
  graph
2710
2713
  .command("v2-explain")
2711
2714
  .description("GET /graph/v2/explain/:edgeId")
2712
- .requiredOption("-t, --team <teamId>", "Team UUID")
2715
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2713
2716
  .requiredOption("--edge-id <id>", "edge UUID")
2714
2717
  .action(async (opts) => {
2715
- const res = await requireClient().getGraphV2Explain(opts.team, opts.edgeId);
2718
+ const res = await requireClient().getGraphV2Explain(resolveTeamId(opts.team), opts.edgeId);
2716
2719
  console.log(JSON.stringify(res, null, 2));
2717
2720
  });
2718
2721
  graph
2719
2722
  .command("v2-path")
2720
2723
  .description("GET /graph/v2/path")
2721
- .requiredOption("-t, --team <teamId>", "Team UUID")
2724
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2722
2725
  .option("--source-id <uuid>", "source nodeId")
2723
2726
  .option("--source-ref <id>", "source nodeRefId")
2724
2727
  .option("--source-type <type>", "source nodeType")
@@ -2728,7 +2731,7 @@ graph
2728
2731
  .option("--max-depth <n>", "maxDepth", "4")
2729
2732
  .option("-n, --limit <n>", "limit", "50")
2730
2733
  .action(async (opts) => {
2731
- const res = await requireClient().getGraphV2Path(opts.team, {
2734
+ const res = await requireClient().getGraphV2Path(resolveTeamId(opts.team), {
2732
2735
  sourceNodeId: opts.sourceId,
2733
2736
  sourceNodeRefId: opts.sourceRef,
2734
2737
  sourceNodeType: opts.sourceType,
@@ -2743,13 +2746,13 @@ graph
2743
2746
  graph
2744
2747
  .command("v2-clusters")
2745
2748
  .description("GET /graph/v2/clusters")
2746
- .requiredOption("-t, --team <teamId>", "Team UUID")
2749
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2747
2750
  .option("--scope-ref <id>", "scopeNodeRefId")
2748
2751
  .option("--scope-type <type>", "scopeNodeType", "account")
2749
2752
  .option("--min-risk <n>", "minRiskScore", "60")
2750
2753
  .option("-n, --limit <n>", "limit", "100")
2751
2754
  .action(async (opts) => {
2752
- const res = await requireClient().getGraphV2Clusters(opts.team, {
2755
+ const res = await requireClient().getGraphV2Clusters(resolveTeamId(opts.team), {
2753
2756
  scopeNodeRefId: opts.scopeRef,
2754
2757
  scopeNodeType: opts.scopeType,
2755
2758
  minRiskScore: Number(opts.minRisk),
@@ -2760,12 +2763,12 @@ graph
2760
2763
  graph
2761
2764
  .command("v2-impact")
2762
2765
  .description("GET /graph/v2/impact")
2763
- .requiredOption("-t, --team <teamId>", "Team UUID")
2766
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2764
2767
  .option("--campaign-ref <id>", "campaignNodeRefId")
2765
2768
  .option("--min-reuse <n>", "minReuseCount", "2")
2766
2769
  .option("-n, --limit <n>", "limit", "100")
2767
2770
  .action(async (opts) => {
2768
- const res = await requireClient().getGraphV2Impact(opts.team, {
2771
+ const res = await requireClient().getGraphV2Impact(resolveTeamId(opts.team), {
2769
2772
  campaignNodeRefId: opts.campaignRef,
2770
2773
  minReuseCount: Number(opts.minReuse),
2771
2774
  limit: Number(opts.limit),
@@ -2779,7 +2782,7 @@ graph
2779
2782
  events
2780
2783
  .command("list-full")
2781
2784
  .description("GET /events(含全部过滤参数)")
2782
- .requiredOption("-t, --team <teamId>", "Team UUID")
2785
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2783
2786
  .option("--type <type>", "事件 type")
2784
2787
  .option("--actor <actor>", "user|agent|cron")
2785
2788
  .option("--result <result>", "succeeded|failed|skipped")
@@ -2788,7 +2791,8 @@ events
2788
2791
  .option("--to <iso>", "createdTo ISO 时间")
2789
2792
  .option("-n, --limit <n>", "limit", "100")
2790
2793
  .action(async (opts) => {
2791
- const res = await requireClient().listEventsFiltered(opts.team, {
2794
+ const res = await requireClient().listEventsFiltered(resolveTeamId(opts.team), {
2795
+ brandId: opts.brand,
2792
2796
  type: opts.type,
2793
2797
  actor: opts.actor,
2794
2798
  result: opts.result,
@@ -2802,7 +2806,7 @@ events
2802
2806
  calendar
2803
2807
  .command("list-full")
2804
2808
  .description("GET /calendar-entries(含全部过滤参数)")
2805
- .requiredOption("-t, --team <teamId>", "Team UUID")
2809
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2806
2810
  .option("--campaign <uuid>", "campaignId")
2807
2811
  .option("--plan <uuid>", "publishingPlanId")
2808
2812
  .option("--account <uuid>", "socialAccountId")
@@ -2811,7 +2815,7 @@ calendar
2811
2815
  .option("--to <iso>", "to ISO 时间")
2812
2816
  .option("-n, --limit <n>", "limit", "50")
2813
2817
  .action(async (opts) => {
2814
- const res = await requireClient().listCalendarEntries(opts.team, {
2818
+ const res = await requireClient().listCalendarEntries(resolveTeamId(opts.team), {
2815
2819
  campaignId: opts.campaign,
2816
2820
  publishingPlanId: opts.plan,
2817
2821
  socialAccountId: opts.account,
@@ -2825,14 +2829,14 @@ calendar
2825
2829
  jobs
2826
2830
  .command("list-full")
2827
2831
  .description("GET /scheduled-jobs(含全部过滤参数)")
2828
- .requiredOption("-t, --team <teamId>", "Team UUID")
2832
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2829
2833
  .option("--status <st>", "scheduled|running|…")
2830
2834
  .option("--account <uuid>", "socialAccountId")
2831
2835
  .option("--from <iso>", "from ISO 时间")
2832
2836
  .option("--to <iso>", "to ISO 时间")
2833
2837
  .option("-n, --limit <n>", "limit", "50")
2834
2838
  .action(async (opts) => {
2835
- const res = await requireClient().listScheduledJobs(opts.team, {
2839
+ const res = await requireClient().listScheduledJobs(resolveTeamId(opts.team), {
2836
2840
  status: opts.status,
2837
2841
  socialAccountId: opts.account,
2838
2842
  from: opts.from,
@@ -2844,7 +2848,7 @@ jobs
2844
2848
  reddit
2845
2849
  .command("list-full")
2846
2850
  .description("GET /reddit-post-snapshots(含全部过滤参数)")
2847
- .requiredOption("-t, --team <teamId>", "Team UUID")
2851
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2848
2852
  .option("--brand <uuid>", "system-level brandId")
2849
2853
  .option("--entry <uuid>", "calendarEntryId")
2850
2854
  .option("--account <uuid>", "socialAccountId")
@@ -2862,7 +2866,7 @@ reddit
2862
2866
  .option("--aggregate", "aggregate across all visible teams (session auth)")
2863
2867
  .option("--scope-team <uuid>", "narrow aggregated scope to one team")
2864
2868
  .action(async (opts) => {
2865
- const res = await listRedditSnapshotsPaginated(opts.team, {
2869
+ const res = await listRedditSnapshotsPaginated(resolveTeamId(opts.team), {
2866
2870
  brandId: opts.brand,
2867
2871
  calendarEntryId: opts.entry,
2868
2872
  socialAccountId: opts.account,
@@ -2915,7 +2919,9 @@ session
2915
2919
  .description("POST /v1/session/active-team")
2916
2920
  .requiredOption("--team <teamId>", "Team UUID")
2917
2921
  .action(async (opts) => {
2918
- const res = await requireClient().sessionActiveTeam({ teamId: opts.team });
2922
+ const res = await requireClient().sessionActiveTeam({
2923
+ teamId: resolveTeamId(opts.team),
2924
+ });
2919
2925
  console.log(JSON.stringify(res, null, 2));
2920
2926
  });
2921
2927
  session
@@ -2928,7 +2934,7 @@ session
2928
2934
  const res = await requireClient().sessionSetPassword({
2929
2935
  email: opts.email,
2930
2936
  password: opts.password,
2931
- teamId: opts.team,
2937
+ teamId: resolveTeamId(opts.team),
2932
2938
  });
2933
2939
  console.log(JSON.stringify(res, null, 2));
2934
2940
  });
@@ -2945,24 +2951,24 @@ const browserEnvs = accounts.command("browser-envs").description("浏览器环
2945
2951
  browserEnvs
2946
2952
  .command("list-team")
2947
2953
  .description("GET /browser-environments(Team 全量)")
2948
- .requiredOption("-t, --team <teamId>", "Team UUID")
2954
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2949
2955
  .action(async (opts) => {
2950
- const res = await requireClient().listTeamBrowserEnvironments(opts.team);
2956
+ const res = await requireClient().listTeamBrowserEnvironments(resolveTeamId(opts.team));
2951
2957
  console.log(JSON.stringify(res, null, 2));
2952
2958
  });
2953
2959
  browserEnvs
2954
2960
  .command("list")
2955
2961
  .description("GET /accounts/:accountId/browser-environments")
2956
- .requiredOption("-t, --team <teamId>", "Team UUID")
2962
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2957
2963
  .requiredOption("-a, --account <accountId>", "Account UUID")
2958
2964
  .action(async (opts) => {
2959
- const res = await requireClient().listAccountBrowserEnvironments(opts.team, opts.account);
2965
+ const res = await requireClient().listAccountBrowserEnvironments(resolveTeamId(opts.team), opts.account);
2960
2966
  console.log(JSON.stringify(res, null, 2));
2961
2967
  });
2962
2968
  browserEnvs
2963
2969
  .command("create")
2964
2970
  .description("POST /accounts/:accountId/browser-environments")
2965
- .requiredOption("-t, --team <teamId>", "Team UUID")
2971
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2966
2972
  .requiredOption("-a, --account <accountId>", "Account UUID")
2967
2973
  .option("-j, --json <json>", "env body JSON", "{}")
2968
2974
  .action(async (opts) => {
@@ -2974,13 +2980,13 @@ browserEnvs
2974
2980
  console.error("Invalid -j / --json");
2975
2981
  process.exit(1);
2976
2982
  }
2977
- const res = await requireClient().createBrowserEnvironment(opts.team, opts.account, body);
2983
+ const res = await requireClient().createBrowserEnvironment(resolveTeamId(opts.team), opts.account, body);
2978
2984
  console.log(JSON.stringify(res, null, 2));
2979
2985
  });
2980
2986
  browserEnvs
2981
2987
  .command("update")
2982
2988
  .description("PATCH /browser-environments/:envId")
2983
- .requiredOption("-t, --team <teamId>", "Team UUID")
2989
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
2984
2990
  .requiredOption("-e, --env <envId>", "Browser environment UUID")
2985
2991
  .option("-j, --json <json>", "update body JSON", "{}")
2986
2992
  .action(async (opts) => {
@@ -2988,7 +2994,7 @@ browserEnvs
2988
2994
  command: "accounts browser-envs update",
2989
2995
  resource: "browserEnvironment",
2990
2996
  action: "update",
2991
- teamId: opts.team,
2997
+ teamId: resolveTeamId(opts.team),
2992
2998
  }, async () => {
2993
2999
  let body = {};
2994
3000
  try {
@@ -2998,18 +3004,18 @@ browserEnvs
2998
3004
  console.error("Invalid -j / --json");
2999
3005
  process.exit(1);
3000
3006
  }
3001
- const res = await requireClient().updateBrowserEnvironment(opts.team, opts.env, body);
3007
+ const res = await requireClient().updateBrowserEnvironment(resolveTeamId(opts.team), opts.env, body);
3002
3008
  console.log(JSON.stringify(res, null, 2));
3003
3009
  });
3004
3010
  });
3005
3011
  browserEnvs
3006
3012
  .command("bind")
3007
3013
  .description("PATCH /browser-environments/:envId(绑定/换绑账号;--account none 解绑)")
3008
- .requiredOption("-t, --team <teamId>", "Team UUID")
3014
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
3009
3015
  .requiredOption("-e, --env <envId>", "Browser environment UUID")
3010
3016
  .requiredOption("-a, --account <uuid|none>", "目标账号 UUID,none=解绑")
3011
3017
  .action(async (opts) => {
3012
- const res = await requireClient().updateBrowserEnvironment(opts.team, opts.env, {
3018
+ const res = await requireClient().updateBrowserEnvironment(resolveTeamId(opts.team), opts.env, {
3013
3019
  socialAccountId: opts.account === "none" ? null : opts.account,
3014
3020
  });
3015
3021
  console.log(JSON.stringify(res, null, 2));
@@ -3020,37 +3026,37 @@ const browserEnvTelemetry = browserEnvs
3020
3026
  browserEnvTelemetry
3021
3027
  .command("append")
3022
3028
  .description("POST /browser-environments/:envId/telemetry-events")
3023
- .requiredOption("-t, --team <teamId>", "Team UUID")
3029
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
3024
3030
  .requiredOption("-e, --env <envId>", "Browser environment UUID")
3025
3031
  .requiredOption("-j, --json <json>", "telemetry event body JSON")
3026
3032
  .action(async (opts) => {
3027
3033
  const body = JSON.parse(opts.json);
3028
- const res = await requireClient().appendBrowserEnvironmentTelemetryEvent(opts.team, opts.env, body);
3034
+ const res = await requireClient().appendBrowserEnvironmentTelemetryEvent(resolveTeamId(opts.team), opts.env, body);
3029
3035
  console.log(JSON.stringify(res, null, 2));
3030
3036
  });
3031
3037
  browserEnvTelemetry
3032
3038
  .command("list")
3033
3039
  .description("GET /browser-environments/:envId/telemetry-events")
3034
- .requiredOption("-t, --team <teamId>", "Team UUID")
3040
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
3035
3041
  .requiredOption("-e, --env <envId>", "Browser environment UUID")
3036
3042
  .option("-n, --limit <n>", "limit", "100")
3037
3043
  .action(async (opts) => {
3038
- const res = await requireClient().listBrowserEnvironmentTelemetryEvents(opts.team, opts.env, { limit: Number(opts.limit) });
3044
+ const res = await requireClient().listBrowserEnvironmentTelemetryEvents(resolveTeamId(opts.team), opts.env, { limit: Number(opts.limit) });
3039
3045
  console.log(JSON.stringify(res, null, 2));
3040
3046
  });
3041
3047
  accounts
3042
3048
  .command("guardrails-get")
3043
3049
  .description("GET /accounts/:accountId/guardrails(互动配额/护栏)")
3044
- .requiredOption("-t, --team <teamId>", "Team UUID")
3050
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
3045
3051
  .requiredOption("-a, --account <ref>", "Account UUID or handle")
3046
3052
  .action(async (opts) => {
3047
- const res = await requireClient().getAccountGuardrails(opts.team, opts.account);
3053
+ const res = await requireClient().getAccountGuardrails(resolveTeamId(opts.team), opts.account);
3048
3054
  console.log(JSON.stringify(res, null, 2));
3049
3055
  });
3050
3056
  accounts
3051
3057
  .command("guardrails-set")
3052
3058
  .description("PUT /accounts/:accountId/guardrails(payload 浅合并;阶段晋升写回)")
3053
- .requiredOption("-t, --team <teamId>", "Team UUID")
3059
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
3054
3060
  .requiredOption("-a, --account <ref>", "Account UUID or handle")
3055
3061
  .requiredOption("-j, --json <json>", "{ stage?, payload?: { likeMin, likeMax, commentMin, commentMax, quota?, ... }, syncSource? }")
3056
3062
  .action(async (opts) => {
@@ -3062,7 +3068,7 @@ accounts
3062
3068
  console.error("Invalid -j / --json");
3063
3069
  process.exit(1);
3064
3070
  }
3065
- const res = await requireClient().upsertAccountGuardrails(opts.team, opts.account, body);
3071
+ const res = await requireClient().upsertAccountGuardrails(resolveTeamId(opts.team), opts.account, body);
3066
3072
  console.log(JSON.stringify(res, null, 2));
3067
3073
  });
3068
3074
  const accountAffinities = accounts
@@ -3071,32 +3077,32 @@ const accountAffinities = accounts
3071
3077
  accountAffinities
3072
3078
  .command("list")
3073
3079
  .description("GET /accounts/:accountId/subreddit-affinities")
3074
- .requiredOption("-t, --team <teamId>", "Team UUID")
3080
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
3075
3081
  .requiredOption("-a, --account <ref>", "Account UUID or slot")
3076
3082
  .action(async (opts) => {
3077
- const res = await requireClient().listAccountSubredditAffinities(opts.team, opts.account);
3083
+ const res = await requireClient().listAccountSubredditAffinities(resolveTeamId(opts.team), opts.account);
3078
3084
  console.log(JSON.stringify(res, null, 2));
3079
3085
  });
3080
3086
  accountAffinities
3081
3087
  .command("upsert")
3082
3088
  .description("PUT /accounts/:accountId/subreddit-affinities/:subreddit")
3083
- .requiredOption("-t, --team <teamId>", "Team UUID")
3089
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
3084
3090
  .requiredOption("-a, --account <ref>", "Account UUID or slot")
3085
3091
  .requiredOption("--subreddit <name>", "Subreddit name")
3086
3092
  .requiredOption("-j, --json <json>", "affinity body JSON")
3087
3093
  .action(async (opts) => {
3088
3094
  const body = JSON.parse(opts.json);
3089
- const res = await requireClient().upsertAccountSubredditAffinity(opts.team, opts.account, opts.subreddit, body);
3095
+ const res = await requireClient().upsertAccountSubredditAffinity(resolveTeamId(opts.team), opts.account, opts.subreddit, body);
3090
3096
  console.log(JSON.stringify(res, null, 2));
3091
3097
  });
3092
3098
  accountAffinities
3093
3099
  .command("recompute")
3094
3100
  .description("Enqueue affinity recompute worker job")
3095
- .requiredOption("-t, --team <teamId>", "Team UUID")
3101
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
3096
3102
  .requiredOption("-a, --account <uuid>", "Account UUID")
3097
3103
  .option("--dry-run", "dry run only", false)
3098
3104
  .action(async (opts) => {
3099
- const res = await requireClient().triggerOpenClawRuntimeMaintenance(opts.team, {
3105
+ const res = await requireClient().triggerOpenClawRuntimeMaintenance(resolveTeamId(opts.team), {
3100
3106
  jobType: "affinity-recompute",
3101
3107
  socialAccountId: opts.account,
3102
3108
  dryRun: Boolean(opts.dryRun),
@@ -3108,20 +3114,20 @@ const accountPersonas = accounts.command("personas").description("账号人设")
3108
3114
  accountPersonas
3109
3115
  .command("list")
3110
3116
  .description("GET /accounts/:accountId/personas")
3111
- .requiredOption("-t, --team <teamId>", "Team UUID")
3117
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
3112
3118
  .requiredOption("-a, --account <accountId>", "Account UUID")
3113
3119
  .action(async (opts) => {
3114
- const res = await requireClient().listAccountPersonas(opts.team, opts.account);
3120
+ const res = await requireClient().listAccountPersonas(resolveTeamId(opts.team), opts.account);
3115
3121
  console.log(JSON.stringify(res, null, 2));
3116
3122
  });
3117
3123
  accountPersonas
3118
3124
  .command("create")
3119
3125
  .description("POST /accounts/:accountId/personas")
3120
- .requiredOption("-t, --team <teamId>", "Team UUID")
3126
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
3121
3127
  .requiredOption("-a, --account <accountId>", "Account UUID")
3122
3128
  .requiredOption("--markdown <text>", "人设 Markdown 文本")
3123
3129
  .action(async (opts) => {
3124
- const res = await requireClient().createAccountPersona(opts.team, opts.account, { markdown: opts.markdown });
3130
+ const res = await requireClient().createAccountPersona(resolveTeamId(opts.team), opts.account, { markdown: opts.markdown });
3125
3131
  console.log(JSON.stringify(res, null, 2));
3126
3132
  });
3127
3133
  // --- campaigns accounts ---
@@ -3131,21 +3137,21 @@ const campaignAccounts = campaigns
3131
3137
  campaignAccounts
3132
3138
  .command("list")
3133
3139
  .description("LEGACY GET /campaigns/:campaignId/accounts")
3134
- .requiredOption("-t, --team <teamId>", "Team UUID")
3140
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
3135
3141
  .requiredOption("-c, --campaign <campaignId>", "Campaign UUID")
3136
3142
  .action(async (opts) => {
3137
- const res = await requireClient().listCampaignAccounts(opts.team, opts.campaign);
3143
+ const res = await requireClient().listCampaignAccounts(resolveTeamId(opts.team), opts.campaign);
3138
3144
  console.log(JSON.stringify(res, null, 2));
3139
3145
  });
3140
3146
  campaignAccounts
3141
3147
  .command("assign")
3142
3148
  .description("LEGACY POST /campaigns/:campaignId/accounts")
3143
- .requiredOption("-t, --team <teamId>", "Team UUID")
3149
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
3144
3150
  .requiredOption("-c, --campaign <campaignId>", "Campaign UUID")
3145
3151
  .requiredOption("-a, --account <socialAccountId>", "社交账号 UUID")
3146
3152
  .option("--visibility <v>", "public | private | internal")
3147
3153
  .action(async (opts) => {
3148
- const res = await requireClient().assignCampaignAccount(opts.team, opts.campaign, {
3154
+ const res = await requireClient().assignCampaignAccount(resolveTeamId(opts.team), opts.campaign, {
3149
3155
  socialAccountId: opts.account,
3150
3156
  visibility: opts.visibility,
3151
3157
  });
@@ -3154,18 +3160,18 @@ campaignAccounts
3154
3160
  campaignAccounts
3155
3161
  .command("remove")
3156
3162
  .description("LEGACY DELETE /campaigns/:campaignId/accounts/:socialAccountId")
3157
- .requiredOption("-t, --team <teamId>", "Team UUID")
3163
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
3158
3164
  .requiredOption("-c, --campaign <campaignId>", "Campaign UUID")
3159
3165
  .requiredOption("-a, --account <socialAccountId>", "社交账号 UUID")
3160
3166
  .action(async (opts) => {
3161
- const res = await requireClient().removeCampaignAccount(opts.team, opts.campaign, opts.account);
3167
+ const res = await requireClient().removeCampaignAccount(resolveTeamId(opts.team), opts.campaign, opts.account);
3162
3168
  console.log(JSON.stringify(res, null, 2));
3163
3169
  });
3164
3170
  // --- brand-members remove ---
3165
3171
  brandMembersCmd
3166
3172
  .command("remove")
3167
3173
  .description("DELETE /brand-members/:memberId")
3168
- .requiredOption("-t, --team <teamId>", "Team UUID")
3174
+ .option("-t, --team <teamId>", "Team UUID(缺省用当前 context)")
3169
3175
  .requiredOption("-m, --member <memberId>", "BrandMember UUID")
3170
3176
  .option("--dry-run", "预览", false)
3171
3177
  .option("--apply", "执行写入", false)
@@ -3174,16 +3180,19 @@ brandMembersCmd
3174
3180
  command: "brand-members remove",
3175
3181
  resource: "brandMember",
3176
3182
  action: "delete",
3177
- teamId: opts.team,
3183
+ teamId: resolveTeamId(opts.team),
3178
3184
  }, async () => {
3179
3185
  if (!assertApplyOrDryRun(opts, {
3180
3186
  command: "brand-members remove",
3181
3187
  danger: "delete",
3182
- summary: { teamId: opts.team, memberId: opts.member },
3188
+ summary: {
3189
+ teamId: resolveTeamId(opts.team),
3190
+ memberId: opts.member,
3191
+ },
3183
3192
  })) {
3184
3193
  return;
3185
3194
  }
3186
- const res = await requireClient().deleteBrandMember(opts.team, opts.member);
3195
+ const res = await requireClient().deleteBrandMember(resolveTeamId(opts.team), opts.member);
3187
3196
  console.log(JSON.stringify(res, null, 2));
3188
3197
  });
3189
3198
  });