@koda-sl/baker-cli 0.174.0-dev.ad43411a1 → 0.176.0-dev.46d2675ee

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.
Files changed (28) hide show
  1. package/README.md +11 -0
  2. package/dist/{chunk-7I2POXSJ.js → chunk-K3PWXVF7.js} +2 -2
  3. package/dist/{chunk-7QMWNMRW.js → chunk-PXXJ3HJW.js} +4 -4
  4. package/dist/{chunk-K424D3CY.js → chunk-QPVJGKV7.js} +3 -3
  5. package/dist/{chunk-TFPZLUVM.js → chunk-X5C6HE24.js} +5 -5
  6. package/dist/chunk-X5C6HE24.js.map +1 -0
  7. package/dist/{chunk-RK67WL4O.js → chunk-YL3HDEIJ.js} +6 -2
  8. package/dist/{chunk-RK67WL4O.js.map → chunk-YL3HDEIJ.js.map} +1 -1
  9. package/dist/{chunk-ZH6ZNYPB.js → chunk-ZWYQIEBI.js} +3 -3
  10. package/dist/cli.js +180 -71
  11. package/dist/cli.js.map +1 -1
  12. package/dist/client-PJ7ID35L.js +15 -0
  13. package/dist/engine/index.js +3 -3
  14. package/dist/env-6QJCMTRK.js +13 -0
  15. package/dist/{output-FL7WRIJF.js → output-NWX3YW64.js} +5 -5
  16. package/dist/{shared-OIYLDW3G.js → shared-5ZEOG664.js} +6 -6
  17. package/package.json +1 -1
  18. package/dist/chunk-TFPZLUVM.js.map +0 -1
  19. package/dist/client-XRQWOADV.js +0 -15
  20. package/dist/env-3JMYIH25.js +0 -11
  21. /package/dist/{chunk-7I2POXSJ.js.map → chunk-K3PWXVF7.js.map} +0 -0
  22. /package/dist/{chunk-7QMWNMRW.js.map → chunk-PXXJ3HJW.js.map} +0 -0
  23. /package/dist/{chunk-K424D3CY.js.map → chunk-QPVJGKV7.js.map} +0 -0
  24. /package/dist/{chunk-ZH6ZNYPB.js.map → chunk-ZWYQIEBI.js.map} +0 -0
  25. /package/dist/{client-XRQWOADV.js.map → client-PJ7ID35L.js.map} +0 -0
  26. /package/dist/{env-3JMYIH25.js.map → env-6QJCMTRK.js.map} +0 -0
  27. /package/dist/{output-FL7WRIJF.js.map → output-NWX3YW64.js.map} +0 -0
  28. /package/dist/{shared-OIYLDW3G.js.map → shared-5ZEOG664.js.map} +0 -0
package/dist/cli.js CHANGED
@@ -36,7 +36,7 @@ import {
36
36
  toModelSafeImage,
37
37
  ulid,
38
38
  validateCanvasDeep
39
- } from "./chunk-K424D3CY.js";
39
+ } from "./chunk-QPVJGKV7.js";
40
40
  import {
41
41
  csvOrJson,
42
42
  daysAgoIso,
@@ -45,7 +45,7 @@ import {
45
45
  resolveAccountIdArg,
46
46
  resolveEffectiveStatus,
47
47
  todayIso
48
- } from "./chunk-7QMWNMRW.js";
48
+ } from "./chunk-PXXJ3HJW.js";
49
49
  import {
50
50
  buildQueryCacheKey,
51
51
  cacheGet,
@@ -61,21 +61,22 @@ import {
61
61
  writeAdsJson,
62
62
  writeAdsOutput,
63
63
  writeJsonEnvelope
64
- } from "./chunk-TFPZLUVM.js";
64
+ } from "./chunk-X5C6HE24.js";
65
65
  import {
66
66
  ApiError,
67
67
  apiGet,
68
68
  apiPost,
69
69
  validateConvexId
70
- } from "./chunk-ZH6ZNYPB.js";
70
+ } from "./chunk-ZWYQIEBI.js";
71
71
  import {
72
72
  installStreamTaps,
73
73
  logInvocation
74
- } from "./chunk-7I2POXSJ.js";
74
+ } from "./chunk-K3PWXVF7.js";
75
75
  import {
76
76
  getEnv,
77
- requireChatId
78
- } from "./chunk-RK67WL4O.js";
77
+ requireChatId,
78
+ resolveChatId
79
+ } from "./chunk-YL3HDEIJ.js";
79
80
 
80
81
  // src/cli.ts
81
82
  import { defineCommand as defineCommand188, runMain } from "citty";
@@ -2632,7 +2633,17 @@ var adEffectSchema = z7.object({
2632
2633
  staged: z7.boolean(),
2633
2634
  entity: z7.string().nullable(),
2634
2635
  operation: z7.string().nullable(),
2635
- summary: z7.string().nullable()
2636
+ summary: z7.string().nullable(),
2637
+ /** Addresses the op for `draft show --chat <thisChat> <ref>`, which returns the full payload. */
2638
+ ref: z7.string(),
2639
+ /**
2640
+ * What the publish did with this op, or null while it is still staged. Without it a reader cannot
2641
+ * tell a change that reached the platform from one that was rejected — a whole failed publish
2642
+ * reads exactly like a successful one.
2643
+ */
2644
+ outcome: z7.enum(["applied", "simulated", "failed", "skipped"]).nullable(),
2645
+ /** Why it failed, verbatim from the platform. Null unless the op failed. */
2646
+ error: z7.string().nullable()
2636
2647
  });
2637
2648
  var creativeEffectSchema = z7.object({
2638
2649
  op: effectOpSchema,
@@ -3907,11 +3918,21 @@ var discardCommand = defineCommand4({
3907
3918
 
3908
3919
  // src/commands/actions/draft.ts
3909
3920
  import { defineCommand as defineCommand5 } from "citty";
3921
+
3922
+ // src/commands/chat-arg.ts
3923
+ var CHAT_READ_ARG = {
3924
+ type: "string",
3925
+ description: "Read another chat's staged changes instead of this one's. Start here when asked to redo, reapply or explain what an earlier chat did \u2014 its changes are kept verbatim, including what happened to each one on publish. Never retype an earlier chat's work from a summary."
3926
+ };
3927
+
3928
+ // src/commands/actions/draft.ts
3910
3929
  var REMOVE_OP_KINDS = ["update", "complete", "discard"];
3911
3930
  registerSchema({
3912
3931
  command: "actions.draft.list",
3913
- description: "Review the action ops staged in THIS chat's draft before publish (creates/updates/completes/discards/links). Staged ops are invisible to `actions list`/`status` until the chat publishes \u2014 use this to verify what will apply and catch duplicates.",
3914
- args: {}
3932
+ description: "Review the action ops staged in THIS chat's draft before publish (creates/updates/completes/discards/links). Staged ops are invisible to `actions list`/`status` until the chat publishes \u2014 use this to verify what will apply and catch duplicates. Takes --chat <id> to read an earlier chat's staged ops instead.",
3933
+ args: {
3934
+ chat: { type: "string", description: CHAT_READ_ARG.description, required: false }
3935
+ }
3915
3936
  });
3916
3937
  registerSchema({
3917
3938
  command: "actions.draft.remove",
@@ -3935,9 +3956,10 @@ var listCommand = defineCommand5({
3935
3956
  name: "list",
3936
3957
  description: "Show every action op staged in this chat's draft, with footgun warnings. Example: baker actions draft"
3937
3958
  },
3938
- run: async () => {
3959
+ args: { chat: CHAT_READ_ARG },
3960
+ run: async ({ args }) => {
3939
3961
  try {
3940
- const chatId = requireChatId();
3962
+ const chatId = resolveChatId(args.chat);
3941
3963
  const response = await apiPost("/api/actions/draft", { chatId });
3942
3964
  writeJson(response);
3943
3965
  } catch (err) {
@@ -4008,8 +4030,11 @@ var clearCommand = defineCommand5({
4008
4030
  var draftCommand = defineCommand5({
4009
4031
  meta: {
4010
4032
  name: "draft",
4011
- description: "Review and edit the action ops staged in this chat BEFORE publish. Subcommands: list (default), remove, clear. Staged ops are invisible to `actions list`/`status` until publish, so check here before finishing."
4033
+ description: "Review and edit the action ops staged in this chat BEFORE publish. Subcommands: list (default), remove, clear. Staged ops are invisible to `actions list`/`status` until publish, so check here before finishing. `list` takes --chat <id> to read an earlier chat's staged ops instead."
4012
4034
  },
4035
+ // Declared on the parent too: `default: "list"` dispatches the bare `draft --chat <id>` form, and
4036
+ // citty prints help for a flag the parent does not know instead of forwarding it.
4037
+ args: { chat: CHAT_READ_ARG },
4013
4038
  subCommands: {
4014
4039
  list: listCommand,
4015
4040
  remove: removeCommand,
@@ -8258,18 +8283,18 @@ async function stageUpdate(kind, customerId, target, payload, hints) {
8258
8283
  async function stageTarget(kind, customerId, target, hints) {
8259
8284
  await stageGoogleOp({ kind, customerId, target }, hints);
8260
8285
  }
8261
- async function draftAction(path28, body) {
8286
+ async function draftAction(path28, body, chat) {
8262
8287
  try {
8263
- const chatId = requireChatId();
8288
+ const chatId = resolveChatId(chat);
8264
8289
  const response = await apiPost(path28, { chatId, ...body });
8265
8290
  writeJsonEnvelope(response);
8266
8291
  } catch (err) {
8267
8292
  handleGoogleError(err);
8268
8293
  }
8269
8294
  }
8270
- async function draftListAction(json) {
8295
+ async function draftListAction(json, chat) {
8271
8296
  try {
8272
- const chatId = requireChatId();
8297
+ const chatId = resolveChatId(chat);
8273
8298
  const response = await apiPost("/api/ads/google/draft", { chatId });
8274
8299
  if (json || !response.ok || !response.data) {
8275
8300
  writeJsonEnvelope(response);
@@ -8284,16 +8309,22 @@ async function draftListAction(json) {
8284
8309
 
8285
8310
  // src/commands/ads/google/draft.ts
8286
8311
  var draftCommand2 = defineCommand22({
8287
- meta: { name: "draft", description: "List, remove, clear, amend, or show staged Google Ads write ops for this chat" },
8312
+ meta: {
8313
+ name: "draft",
8314
+ description: "List, remove, clear, amend, or show staged Google Ads write ops for this chat. `list` and `show` take --chat <id> to read an earlier chat's changes instead."
8315
+ },
8288
8316
  subCommands: {
8289
8317
  list: defineCommand22({
8290
8318
  meta: {
8291
8319
  name: "list",
8292
8320
  description: "Review everything staged as a campaign \u25B8 ad group \u25B8 ad tree (--json for the raw envelope)"
8293
8321
  },
8294
- args: { json: { type: "boolean", description: "Print the raw JSON envelope instead of the readable tree" } },
8322
+ args: {
8323
+ json: { type: "boolean", description: "Print the raw JSON envelope instead of the readable tree" },
8324
+ chat: CHAT_READ_ARG
8325
+ },
8295
8326
  run: async ({ args }) => {
8296
- await draftListAction(args.json === true);
8327
+ await draftListAction(args.json === true, args.chat);
8297
8328
  }
8298
8329
  }),
8299
8330
  remove: defineCommand22({
@@ -8339,10 +8370,11 @@ var draftCommand2 = defineCommand22({
8339
8370
  type: "positional",
8340
8371
  description: "Staged op ref (g_temp_*) or target id/resource name",
8341
8372
  required: false
8342
- }
8373
+ },
8374
+ chat: CHAT_READ_ARG
8343
8375
  },
8344
8376
  run: async ({ args }) => {
8345
- await draftAction("/api/ads/google/draft/show", { ref: requireTarget(args, "op") });
8377
+ await draftAction("/api/ads/google/draft/show", { ref: requireTarget(args, "op") }, args.chat);
8346
8378
  }
8347
8379
  })
8348
8380
  }
@@ -11113,6 +11145,7 @@ function requireTargets(args, entity) {
11113
11145
  }
11114
11146
 
11115
11147
  // src/commands/ads/linkedin/schemas.ts
11148
+ var CHAT_READ_ARG_DESCRIPTION = CHAT_READ_ARG.description;
11116
11149
  registerSchema({
11117
11150
  command: "ads.linkedin.accounts",
11118
11151
  description: "List LinkedIn ad accounts in the company's connected scope. Pass --include-all to list every account the OAuth token can see.",
@@ -11811,7 +11844,8 @@ registerSchema({
11811
11844
  type: "boolean",
11812
11845
  description: "Print the raw JSON envelope instead of the readable tree",
11813
11846
  required: false
11814
- }
11847
+ },
11848
+ chat: { type: "string", description: CHAT_READ_ARG_DESCRIPTION, required: false }
11815
11849
  }
11816
11850
  });
11817
11851
  registerSchema({
@@ -11825,6 +11859,18 @@ registerSchema({
11825
11859
  }
11826
11860
  }
11827
11861
  });
11862
+ registerSchema({
11863
+ command: "ads.linkedin.draft.show",
11864
+ description: "Print the full staged payload for one LinkedIn op \u2014 the receipt to verify a change looks right before publish (never truncated), and the only way to read back verbatim what an earlier chat wrote.",
11865
+ args: {
11866
+ ref: {
11867
+ type: "positional",
11868
+ description: "Op ref (li_temp_* for creates, target id/URN for updates)",
11869
+ required: true
11870
+ },
11871
+ chat: { type: "string", description: CHAT_READ_ARG_DESCRIPTION, required: false }
11872
+ }
11873
+ });
11828
11874
  registerSchema({
11829
11875
  command: "ads.linkedin.draft.clear",
11830
11876
  description: "Discard ALL staged LinkedIn ops in this chat's draft. Nothing applies on publish.",
@@ -14015,9 +14061,9 @@ function renderDraftStatus2(data) {
14015
14061
  }
14016
14062
 
14017
14063
  // src/commands/ads/linkedin/draft.ts
14018
- async function listDraft(json) {
14064
+ async function listDraft(json, chat) {
14019
14065
  try {
14020
- const chatId = requireChatId();
14066
+ const chatId = resolveChatId(chat);
14021
14067
  const response = await apiPost("/api/ads/linkedin/draft", {
14022
14068
  chatId
14023
14069
  });
@@ -14036,9 +14082,12 @@ var listCommand3 = defineCommand45({
14036
14082
  name: "list",
14037
14083
  description: "Review everything staged as a Campaign group \u25B8 Campaign \u25B8 Creative tree (--json for the raw envelope). Example: baker ads linkedin draft"
14038
14084
  },
14039
- args: { json: { type: "boolean", description: "Print the raw JSON envelope instead of the readable tree" } },
14085
+ args: {
14086
+ json: { type: "boolean", description: "Print the raw JSON envelope instead of the readable tree" },
14087
+ chat: CHAT_READ_ARG
14088
+ },
14040
14089
  run: async ({ args }) => {
14041
- await listDraft(args.json === true);
14090
+ await listDraft(args.json === true, args.chat);
14042
14091
  }
14043
14092
  });
14044
14093
  var removeCommand2 = defineCommand45({
@@ -14115,12 +14164,13 @@ var showCommand = defineCommand45({
14115
14164
  description: "Print the full staged payload for one op \u2014 the receipt to verify a change looks right before publish (never truncated)."
14116
14165
  },
14117
14166
  args: {
14118
- ref: { type: "positional", description: "Staged op ref (li_temp_*) or target id/URN", required: true }
14167
+ ref: { type: "positional", description: "Staged op ref (li_temp_*) or target id/URN", required: true },
14168
+ chat: CHAT_READ_ARG
14119
14169
  },
14120
14170
  run: async ({ args }) => {
14121
14171
  const ref = requireTarget2(args, "op");
14122
14172
  try {
14123
- const chatId = requireChatId();
14173
+ const chatId = resolveChatId(args.chat);
14124
14174
  const body = { chatId, ref };
14125
14175
  const response = await apiPost(
14126
14176
  "/api/ads/linkedin/draft/show",
@@ -14135,8 +14185,11 @@ var showCommand = defineCommand45({
14135
14185
  var linkedinDraftCommand = defineCommand45({
14136
14186
  meta: {
14137
14187
  name: "draft",
14138
- description: "Review and edit the LinkedIn write ops staged in this chat BEFORE publish. Subcommands: list (default), remove, clear, amend, show. Ops never hit LinkedIn until the chat is published."
14188
+ description: "Review and edit the LinkedIn write ops staged in this chat BEFORE publish. Subcommands: list (default), remove, clear, amend, show. Ops never hit LinkedIn until the chat is published. `list` and `show` take --chat <id> to read an earlier chat's changes instead."
14139
14189
  },
14190
+ // Declared on the parent too: `default: "list"` dispatches the bare `draft --chat <id>` form, and
14191
+ // citty prints help for a flag the parent does not know instead of forwarding it.
14192
+ args: { chat: CHAT_READ_ARG },
14140
14193
  subCommands: {
14141
14194
  list: listCommand3,
14142
14195
  remove: removeCommand2,
@@ -15518,6 +15571,17 @@ var metaDraftListResponseSchema = z19.object({
15518
15571
  /** Non-blocking cross-op quality advisories — "good campaign, not just valid". */
15519
15572
  advisories: z19.array(metaDraftAdvisorySchema)
15520
15573
  });
15574
+ var metaDraftShowRequestSchema = z19.object({
15575
+ chatId: z19.string(),
15576
+ ref: z19.string()
15577
+ });
15578
+ var metaDraftShowResponseSchema = z19.object({
15579
+ op: metaDraftOpViewSchema.extend({
15580
+ payload: z19.unknown().optional(),
15581
+ warnings: z19.array(z19.string()).optional(),
15582
+ annotations: z19.unknown().optional()
15583
+ })
15584
+ });
15521
15585
  var metaDraftRemoveRequestSchema = z19.object({
15522
15586
  chatId: z19.string(),
15523
15587
  ref: z19.string()
@@ -16105,10 +16169,10 @@ function duplicateCommand2(entity, label) {
16105
16169
  replace: { type: "boolean", description: "Pause the original once the copy publishes" }
16106
16170
  },
16107
16171
  run: async ({ args }) => {
16108
- const { apiPost: apiPost2 } = await import("./client-XRQWOADV.js");
16109
- const { requireChatId: requireChatId2 } = await import("./env-3JMYIH25.js");
16110
- const { writeJsonEnvelope: writeJsonEnvelope2 } = await import("./output-FL7WRIJF.js");
16111
- const { handleMetaError: handleMetaError2 } = await import("./shared-OIYLDW3G.js");
16172
+ const { apiPost: apiPost2 } = await import("./client-PJ7ID35L.js");
16173
+ const { requireChatId: requireChatId2 } = await import("./env-6QJCMTRK.js");
16174
+ const { writeJsonEnvelope: writeJsonEnvelope2 } = await import("./output-NWX3YW64.js");
16175
+ const { handleMetaError: handleMetaError2 } = await import("./shared-5ZEOG664.js");
16112
16176
  try {
16113
16177
  const accountId = bareAccountId2(args);
16114
16178
  const chatId = requireChatId2();
@@ -16497,9 +16561,9 @@ Examples:
16497
16561
 
16498
16562
  // src/commands/ads/meta/draft.ts
16499
16563
  import { defineCommand as defineCommand62 } from "citty";
16500
- async function listDraft2() {
16564
+ async function listDraft2(chat) {
16501
16565
  try {
16502
- const chatId = requireChatId();
16566
+ const chatId = resolveChatId(chat);
16503
16567
  const response = await apiPost("/api/ads/meta/draft", { chatId });
16504
16568
  writeJsonEnvelope(response);
16505
16569
  } catch (err) {
@@ -16511,7 +16575,32 @@ var listCommand9 = defineCommand62({
16511
16575
  name: "list",
16512
16576
  description: "Show every Meta write op staged in this chat, its mode (simulated = publish will NOT hit Meta), dependencies, and post-publish results. Example: baker ads meta draft"
16513
16577
  },
16514
- run: listDraft2
16578
+ args: { chat: CHAT_READ_ARG },
16579
+ run: async ({ args }) => {
16580
+ await listDraft2(args.chat);
16581
+ }
16582
+ });
16583
+ var showCommand2 = defineCommand62({
16584
+ meta: {
16585
+ name: "show",
16586
+ description: "Print the full staged payload for one op \u2014 the receipt to verify a change looks right before publish (never truncated). Example: baker ads meta draft show meta_temp_abc123"
16587
+ },
16588
+ args: {
16589
+ ref: { type: "positional", description: "Op ref (meta_temp_* for creates, target id for updates)", required: true },
16590
+ chat: CHAT_READ_ARG
16591
+ },
16592
+ run: async ({ args }) => {
16593
+ try {
16594
+ const chatId = resolveChatId(args.chat);
16595
+ const response = await apiPost("/api/ads/meta/draft/show", {
16596
+ chatId,
16597
+ ref: args.ref
16598
+ });
16599
+ writeJsonEnvelope(response);
16600
+ } catch (err) {
16601
+ handleMetaError(err);
16602
+ }
16603
+ }
16515
16604
  });
16516
16605
  var removeCommand3 = defineCommand62({
16517
16606
  meta: {
@@ -16554,9 +16643,12 @@ var clearCommand3 = defineCommand62({
16554
16643
  var metaDraftCommand = defineCommand62({
16555
16644
  meta: {
16556
16645
  name: "draft",
16557
- description: "Review and edit the Meta write ops staged in this chat BEFORE publish. Subcommands: list (default), remove, clear. Ops never hit Meta until the chat is published."
16646
+ description: "Review and edit the Meta write ops staged in this chat BEFORE publish. Subcommands: list (default), show, remove, clear. Ops never hit Meta until the chat is published. `list` and `show` take --chat <id> to read an earlier chat's changes instead."
16558
16647
  },
16559
- subCommands: { list: listCommand9, remove: removeCommand3, clear: clearCommand3 },
16648
+ // Declared on the parent too: `default: "list"` dispatches the bare `draft --chat <id>` form, and
16649
+ // citty prints help for a flag the parent does not know instead of forwarding it.
16650
+ args: { chat: CHAT_READ_ARG },
16651
+ subCommands: { list: listCommand9, show: showCommand2, remove: removeCommand3, clear: clearCommand3 },
16560
16652
  // `default` (not `run`) dispatches the bare invocation: citty falls through to `run`
16561
16653
  // after dispatching a subcommand, so a `run` here would list the draft a second time
16562
16654
  // on every `draft list` / `draft remove` / `draft clear`.
@@ -26438,7 +26530,7 @@ var listCommand11 = defineCommand104({
26438
26530
  writeJson({ ok: true, data: { flows } });
26439
26531
  }
26440
26532
  });
26441
- var showCommand2 = defineCommand104({
26533
+ var showCommand3 = defineCommand104({
26442
26534
  meta: {
26443
26535
  name: "show",
26444
26536
  description: "Show a Form's confidential fields and their configuration status (never secret values). Example: baker flows show contact"
@@ -26474,7 +26566,7 @@ Full guide: __tooling__/docs/tools/baker/flows.md`
26474
26566
  },
26475
26567
  subCommands: {
26476
26568
  list: listCommand11,
26477
- show: showCommand2
26569
+ show: showCommand3
26478
26570
  },
26479
26571
  // Bare `baker flows` lists the Forms. This must be `default`, not `run`: citty falls
26480
26572
  // through to `run` after dispatching a subcommand, so a `run` here would also print
@@ -33453,7 +33545,8 @@ registerSchema({
33453
33545
  command: "scheduled-actions.get",
33454
33546
  description: "Get a published scheduled action or a temp_sched_* draft-created scheduled action.",
33455
33547
  args: {
33456
- id: { type: "string", description: "Published scheduled action ID or temp_sched_* draft ID", required: true }
33548
+ id: { type: "string", description: "Published scheduled action ID or temp_sched_* draft ID", required: true },
33549
+ chat: { type: "string", description: CHAT_READ_ARG.description, required: false }
33457
33550
  }
33458
33551
  });
33459
33552
  var getCommand3 = defineCommand155({
@@ -33467,7 +33560,8 @@ var getCommand3 = defineCommand155({
33467
33560
  type: "string",
33468
33561
  description: "Scheduled action ID (alternative to positional)",
33469
33562
  required: false
33470
- }
33563
+ },
33564
+ chat: CHAT_READ_ARG
33471
33565
  },
33472
33566
  run: async ({ args }) => {
33473
33567
  try {
@@ -33477,12 +33571,13 @@ var getCommand3 = defineCommand155({
33477
33571
  }
33478
33572
  validateScheduledActionRef(id);
33479
33573
  const env = getEnv();
33480
- if (isTempScheduledActionId(id) && !env.BAKER_CHAT_ID) {
33481
- failValidation2("BAKER_CHAT_ID is required to get a temp scheduled action ID.");
33574
+ const chatId = typeof args.chat === "string" && args.chat.length > 0 ? args.chat : env.BAKER_CHAT_ID;
33575
+ if (isTempScheduledActionId(id) && !chatId) {
33576
+ failValidation2("BAKER_CHAT_ID or --chat is required to get a temp scheduled action ID.");
33482
33577
  }
33483
33578
  const body = { id };
33484
- if (env.BAKER_CHAT_ID) {
33485
- body.chatId = env.BAKER_CHAT_ID;
33579
+ if (chatId) {
33580
+ body.chatId = chatId;
33486
33581
  }
33487
33582
  const response = await apiPost("/api/scheduled-actions/get", body);
33488
33583
  writeJson(response);
@@ -33496,20 +33591,24 @@ var getCommand3 = defineCommand155({
33496
33591
  import { defineCommand as defineCommand156 } from "citty";
33497
33592
  registerSchema({
33498
33593
  command: "scheduled-actions.list",
33499
- description: "List published scheduled actions. Includes draft state when BAKER_CHAT_ID is set.",
33500
- args: {}
33594
+ description: "List published scheduled actions. Includes draft state when BAKER_CHAT_ID is set, or --chat <id> to read an earlier chat's staged schedules instead.",
33595
+ args: {
33596
+ chat: { type: "string", description: CHAT_READ_ARG.description, required: false }
33597
+ }
33501
33598
  });
33502
33599
  var listCommand14 = defineCommand156({
33503
33600
  meta: {
33504
33601
  name: "list",
33505
- description: "List scheduled actions. Includes staged draft ops when BAKER_CHAT_ID is set."
33602
+ description: "List scheduled actions. Includes staged draft ops when BAKER_CHAT_ID is set, or --chat <id> to read an earlier chat's staged schedules instead."
33506
33603
  },
33507
- run: async () => {
33604
+ args: { chat: CHAT_READ_ARG },
33605
+ run: async ({ args }) => {
33508
33606
  try {
33509
33607
  const env = getEnv();
33510
33608
  const body = {};
33511
- if (env.BAKER_CHAT_ID) {
33512
- body.chatId = env.BAKER_CHAT_ID;
33609
+ const chatId = typeof args.chat === "string" && args.chat.length > 0 ? args.chat : env.BAKER_CHAT_ID;
33610
+ if (chatId) {
33611
+ body.chatId = chatId;
33513
33612
  }
33514
33613
  const response = await apiPost("/api/scheduled-actions/list", body);
33515
33614
  writeJson(response);
@@ -33809,8 +33908,8 @@ async function stageOp3(op) {
33809
33908
  handleError3(err);
33810
33909
  }
33811
33910
  }
33812
- async function draftAction2(path28, body) {
33813
- const chatId = requireChatId();
33911
+ async function draftAction2(path28, body, chat) {
33912
+ const chatId = resolveChatId(chat);
33814
33913
  try {
33815
33914
  const data = await apiPost(path28, { chatId, ...body });
33816
33915
  writeJsonEnvelope({ ok: true, data });
@@ -33841,8 +33940,8 @@ function renderDraft(response) {
33841
33940
  }
33842
33941
  return lines.join("\n");
33843
33942
  }
33844
- async function draftList(json) {
33845
- const chatId = requireChatId();
33943
+ async function draftList(json, chat) {
33944
+ const chatId = resolveChatId(chat);
33846
33945
  try {
33847
33946
  const data = await apiPost("/api/tag-manager/draft", { chatId });
33848
33947
  if (json) {
@@ -33859,15 +33958,16 @@ async function draftList(json) {
33859
33958
  // src/commands/tag-manager/draft.ts
33860
33959
  registerSchema({
33861
33960
  command: "tagManager.draft",
33862
- description: "Review and undo the Tag Manager changes staged on this chat. Use `list` to see everything staged, `show` to inspect one change in full before publish, `amend` to correct one in place, and `remove`/`clear` to drop them.",
33961
+ description: "Review and undo the Tag Manager changes staged on this chat. Use `list` to see everything staged, `show` to inspect one change in full before publish, `amend` to correct one in place, and `remove`/`clear` to drop them. `list` and `show` take --chat <id> to read an earlier chat's changes instead.",
33863
33962
  args: {
33864
- json: { type: "boolean", description: "Print the raw JSON envelope instead of the readable list", required: false }
33963
+ json: { type: "boolean", description: "Print the raw JSON envelope instead of the readable list", required: false },
33964
+ chat: { type: "string", description: CHAT_READ_ARG.description, required: false }
33865
33965
  }
33866
33966
  });
33867
33967
  var draftCommand3 = defineCommand161({
33868
33968
  meta: {
33869
33969
  name: "draft",
33870
- description: "List, show, amend, remove, or clear staged Tag Manager changes for this chat"
33970
+ description: "List, show, amend, remove, or clear staged Tag Manager changes for this chat. `list` and `show` take --chat <id> to read an earlier chat's changes instead."
33871
33971
  },
33872
33972
  subCommands: {
33873
33973
  list: defineCommand161({
@@ -33875,9 +33975,12 @@ var draftCommand3 = defineCommand161({
33875
33975
  name: "list",
33876
33976
  description: "Review everything staged on this chat (--json for the raw envelope)"
33877
33977
  },
33878
- args: { json: { type: "boolean", description: "Print the raw JSON envelope", required: false } },
33978
+ args: {
33979
+ json: { type: "boolean", description: "Print the raw JSON envelope", required: false },
33980
+ chat: CHAT_READ_ARG
33981
+ },
33879
33982
  run: async ({ args }) => {
33880
- await draftList(args.json === true);
33983
+ await draftList(args.json === true, args.chat);
33881
33984
  }
33882
33985
  }),
33883
33986
  show: defineCommand161({
@@ -33885,11 +33988,16 @@ var draftCommand3 = defineCommand161({
33885
33988
  name: "show",
33886
33989
  description: "Print the full staged payload for one change \u2014 the receipt to verify it looks right before publish (never truncated)."
33887
33990
  },
33888
- args: { ref: { type: "positional", description: "Staged ref (gtm_temp_*) or target", required: false } },
33991
+ args: {
33992
+ ref: { type: "positional", description: "Staged ref (gtm_temp_*) or target", required: false },
33993
+ chat: CHAT_READ_ARG
33994
+ },
33889
33995
  run: async ({ args }) => {
33890
- await draftAction2("/api/tag-manager/draft/show", {
33891
- ref: requireTarget4(args, "change")
33892
- });
33996
+ await draftAction2(
33997
+ "/api/tag-manager/draft/show",
33998
+ { ref: requireTarget4(args, "change") },
33999
+ args.chat
34000
+ );
33893
34001
  }
33894
34002
  }),
33895
34003
  amend: defineCommand161({
@@ -34325,9 +34433,9 @@ var listCommand15 = defineCommand165({
34325
34433
  await listTags(args.json === true);
34326
34434
  }
34327
34435
  });
34328
- async function listDraft3() {
34436
+ async function listDraft3(chat) {
34329
34437
  try {
34330
- const chatId = requireChatId();
34438
+ const chatId = resolveChatId(chat);
34331
34439
  const response = await apiPost("/api/tags/draft", { chatId });
34332
34440
  writeJson({ ok: true, data: response });
34333
34441
  } catch (err) {
@@ -34337,10 +34445,11 @@ async function listDraft3() {
34337
34445
  var draftCommand4 = defineCommand165({
34338
34446
  meta: {
34339
34447
  name: "draft",
34340
- description: "Review the tag changes staged in this chat (read-only). Staged changes were approved via request_tag_input and apply when the chat is published; to amend or drop one, propose a follow-up change through the same tool (a delete on a tag_temp_* ref drops the staged create)."
34448
+ description: "Review the tag changes staged in this chat (read-only). Staged changes were approved via request_tag_input and apply when the chat is published; to amend or drop one, propose a follow-up change through the same tool (a delete on a tag_temp_* ref drops the staged create). Takes --chat <id> to read an earlier chat's staged changes instead."
34341
34449
  },
34342
- run: async () => {
34343
- await listDraft3();
34450
+ args: { chat: CHAT_READ_ARG },
34451
+ run: async ({ args }) => {
34452
+ await listDraft3(args.chat);
34344
34453
  }
34345
34454
  });
34346
34455
  var tagsCommand3 = defineCommand165({