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