@koda-sl/baker-cli 0.371.0 → 0.373.0

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 (26) hide show
  1. package/README.md +18 -2
  2. package/dist/{chunk-L4QXAYIC.js → chunk-4ACU7GBN.js} +4 -4
  3. package/dist/{chunk-3NIBJ3GL.js → chunk-FGHMWBUD.js} +3 -3
  4. package/dist/{chunk-2OKSJNLA.js → chunk-HJEMOSPH.js} +439 -2
  5. package/dist/chunk-HJEMOSPH.js.map +1 -0
  6. package/dist/{chunk-MZQC4LII.js → chunk-MF7YA62W.js} +3 -3
  7. package/dist/{chunk-XWHHYHKQ.js → chunk-VZEDAFAR.js} +2 -2
  8. package/dist/{chunk-FXVELNAS.js → chunk-ZI7TPBXB.js} +3 -3
  9. package/dist/cli.js +217 -423
  10. package/dist/cli.js.map +1 -1
  11. package/dist/{client-3DGBQ2H3.js → client-GR6YL3YX.js} +4 -4
  12. package/dist/engine/index.js +3 -3
  13. package/dist/{env-BSG7TY5Y.js → env-4P5HOGNA.js} +2 -2
  14. package/dist/{output-AT5SRVH7.js → output-KMEPFOFT.js} +5 -5
  15. package/dist/{shared-HZ44PY2F.js → shared-26NWGQ5G.js} +6 -6
  16. package/package.json +1 -1
  17. package/dist/chunk-2OKSJNLA.js.map +0 -1
  18. /package/dist/{chunk-L4QXAYIC.js.map → chunk-4ACU7GBN.js.map} +0 -0
  19. /package/dist/{chunk-3NIBJ3GL.js.map → chunk-FGHMWBUD.js.map} +0 -0
  20. /package/dist/{chunk-MZQC4LII.js.map → chunk-MF7YA62W.js.map} +0 -0
  21. /package/dist/{chunk-XWHHYHKQ.js.map → chunk-VZEDAFAR.js.map} +0 -0
  22. /package/dist/{chunk-FXVELNAS.js.map → chunk-ZI7TPBXB.js.map} +0 -0
  23. /package/dist/{client-3DGBQ2H3.js.map → client-GR6YL3YX.js.map} +0 -0
  24. /package/dist/{env-BSG7TY5Y.js.map → env-4P5HOGNA.js.map} +0 -0
  25. /package/dist/{output-AT5SRVH7.js.map → output-KMEPFOFT.js.map} +0 -0
  26. /package/dist/{shared-HZ44PY2F.js.map → shared-26NWGQ5G.js.map} +0 -0
package/dist/cli.js CHANGED
@@ -70,7 +70,7 @@ import {
70
70
  validateCanvasDeep,
71
71
  withoutCastName,
72
72
  ytDlpBlockSignal
73
- } from "./chunk-3NIBJ3GL.js";
73
+ } from "./chunk-FGHMWBUD.js";
74
74
  import {
75
75
  csvOrJson,
76
76
  daysAgoIso,
@@ -80,7 +80,7 @@ import {
80
80
  resolveEffectiveStatus,
81
81
  statusFilterHints,
82
82
  todayIso
83
- } from "./chunk-L4QXAYIC.js";
83
+ } from "./chunk-4ACU7GBN.js";
84
84
  import {
85
85
  buildQueryCacheKey,
86
86
  cacheGet,
@@ -96,42 +96,50 @@ import {
96
96
  writeAdsJson,
97
97
  writeAdsOutput,
98
98
  writeJsonEnvelope
99
- } from "./chunk-FXVELNAS.js";
99
+ } from "./chunk-ZI7TPBXB.js";
100
100
  import {
101
101
  ApiError,
102
102
  apiGet,
103
103
  apiGetWithHeaders,
104
104
  apiPost,
105
105
  validateConvexId
106
- } from "./chunk-MZQC4LII.js";
106
+ } from "./chunk-MF7YA62W.js";
107
107
  import {
108
108
  installExitRecord,
109
109
  installStreamTaps,
110
110
  logInvocation
111
- } from "./chunk-XWHHYHKQ.js";
111
+ } from "./chunk-VZEDAFAR.js";
112
112
  import {
113
113
  adContentNormalizer,
114
114
  captureBudgetMs,
115
115
  captureProxyCredentials,
116
116
  captureVimeoCookie,
117
+ commandPathOf,
117
118
  compactImage,
118
119
  compactVideo,
120
+ findSchema,
119
121
  getEnv,
120
122
  hasOpenRouterKey,
123
+ installFieldMask,
121
124
  isProxyFailure,
125
+ listSchemas,
122
126
  openRouterKey,
123
127
  optionalChatId,
128
+ outputFlagForCommand,
124
129
  plannedRoutes,
125
130
  refuseNonPublicUrl,
131
+ refuseUnknownFlags,
132
+ registerSchema,
126
133
  requireChatId,
127
134
  resolveChatId,
128
135
  shouldEscalate,
136
+ takeFieldsFlag,
129
137
  testimonialNormalizer,
130
138
  videoNormalizer,
131
139
  winningAdNormalizer,
132
140
  writeJson,
133
141
  writeOutput
134
- } from "./chunk-2OKSJNLA.js";
142
+ } from "./chunk-HJEMOSPH.js";
135
143
 
136
144
  // src/cli.ts
137
145
  import { defineCommand as defineCommand248, runMain } from "citty";
@@ -172,30 +180,6 @@ import { defineCommand as defineCommand18 } from "citty";
172
180
  // src/commands/actions/claim.ts
173
181
  import { defineCommand } from "citty";
174
182
 
175
- // src/schemas.ts
176
- var registry = /* @__PURE__ */ new Map();
177
- function registerSchema(schema) {
178
- registry.set(schema.command, schema);
179
- }
180
- function listSchemas() {
181
- return [...registry.keys()];
182
- }
183
- function spellingKey(name) {
184
- return name.toLowerCase().replaceAll("-", "");
185
- }
186
- function resolveSchemaName(words2, names) {
187
- const joined = words2.join(".");
188
- if (names.includes(joined)) {
189
- return joined;
190
- }
191
- const matches = names.filter((name) => spellingKey(name) === spellingKey(joined));
192
- return matches.length === 1 ? matches[0] : void 0;
193
- }
194
- function findSchema(words2) {
195
- const name = resolveSchemaName(words2, listSchemas());
196
- return name === void 0 ? void 0 : registry.get(name);
197
- }
198
-
199
183
  // ../api/src/actions.ts
200
184
  import { z } from "zod";
201
185
  var actionStatusSchema = z.enum(["pending", "in_progress", "completed", "discarded"]);
@@ -7159,37 +7143,10 @@ function parseConditionsExpression(expression) {
7159
7143
  }
7160
7144
 
7161
7145
  // ../api/src/scheduledAgents.ts
7162
- import { z as z24 } from "zod";
7163
- var scheduledAgentRunsAsSchema = z24.object({
7164
- /** The person each run acts as; null when nobody owns it, so only the company's tools load. */
7165
- name: z24.string().nullable(),
7166
- /** That person's own connected tools. */
7167
- personalTools: z24.array(z24.string()),
7168
- /** The company's and organization's tools, and the platforms Baker connects to directly. */
7169
- companyTools: z24.array(z24.string()),
7170
- /** Set up, but nobody has signed in to them, so a run gets nothing from them. */
7171
- notSignedIn: z24.array(z24.string()).optional(),
7172
- /** The company switched connected tools off: only the platforms load. */
7173
- toolsOff: z24.literal(true).optional()
7174
- });
7175
- var AUTO_PUBLISH_REFUSAL = 'Publishing every run unreviewed is a standing authorization only the user can grant, on the item itself, so it is recorded against their name. Stage the item without it, and once this chat is published ask the user to switch on "Publish its work on its own" (under "When a run finishes") on the item in Scheduled agents.';
7176
- var scheduledAgentsUnstageRequestSchema = z24.object({
7177
- chatId: z24.string().min(1),
7178
- /** The item: a published id or a temp_agent_* id this chat staged. */
7179
- ref: z24.string().min(1),
7180
- /** One change of it, by its `index` in `list`'s draft. Left out, every change staged on it. */
7181
- index: z24.number().int().min(0).optional()
7182
- });
7183
- var scheduledAgentsUnstageResponseSchema = z24.object({
7184
- ok: z24.literal(true),
7185
- data: z24.object({ ref: z24.string(), removed: z24.number().int().min(1) })
7186
- });
7187
-
7188
- // ../api/src/scheduledAgentTriggerCatalog.ts
7189
- import { z as z26 } from "zod";
7146
+ import { z as z25 } from "zod";
7190
7147
 
7191
7148
  // ../api/src/scheduledAgentTriggers.ts
7192
- import { z as z25 } from "zod";
7149
+ import { z as z24 } from "zod";
7193
7150
  var TRIGGER_GROUPS = {
7194
7151
  time: { label: "Time", blurb: "On a clock you set." },
7195
7152
  incoming: { label: "Incoming", blurb: "Another tool or your site calls in." },
@@ -7555,152 +7512,233 @@ var TRIGGER_TARGETS = {
7555
7512
  "review.received": [target("sourceId", { open: false })],
7556
7513
  "advertiser.new_ads": [target("advertiserId", { open: false })]
7557
7514
  };
7558
- var triggerTargetOptionSchema = z25.object({
7559
- value: z25.string(),
7560
- label: z25.string(),
7515
+ var triggerTargetOptionSchema = z24.object({
7516
+ value: z24.string(),
7517
+ label: z24.string(),
7561
7518
  /** A second line: a status, a tag list, where it comes from. */
7562
- detail: z25.string().optional(),
7519
+ detail: z24.string().optional(),
7563
7520
  /** A mark: a path under the dashboard's `/logos/`, or an absolute image URL. */
7564
- logo: z25.string().optional()
7521
+ logo: z24.string().optional()
7565
7522
  });
7566
- var scheduledAgentTriggerSchema = z25.discriminatedUnion("kind", [
7567
- z25.object({
7568
- kind: z25.literal("time.once"),
7523
+ var scheduledAgentTriggerSchema = z24.discriminatedUnion("kind", [
7524
+ z24.object({
7525
+ kind: z24.literal("time.once"),
7569
7526
  /** Epoch ms. Must still be in the future when the item is written. */
7570
- runAt: z25.number(),
7527
+ runAt: z24.number(),
7571
7528
  /** IANA zone. Defaults to the company's. */
7572
- tz: z25.string()
7529
+ tz: z24.string()
7573
7530
  }),
7574
- z25.object({
7575
- kind: z25.literal("time.cron"),
7531
+ z24.object({
7532
+ kind: z24.literal("time.cron"),
7576
7533
  /** Five-field cron expression. */
7577
- cronspec: z25.string(),
7578
- tz: z25.string()
7534
+ cronspec: z24.string(),
7535
+ tz: z24.string()
7579
7536
  }),
7580
- z25.object({ kind: z25.literal("webhook.received") }),
7581
- z25.object({
7582
- kind: z25.literal("app.event"),
7537
+ z24.object({ kind: z24.literal("webhook.received") }),
7538
+ z24.object({
7539
+ kind: z24.literal("app.event"),
7583
7540
  /** The connected tool, by its toolkit slug: `gmail`, `slack`. */
7584
- toolkit: z25.string(),
7541
+ toolkit: z24.string(),
7585
7542
  /** What happens in it, by the tool's own trigger id: `GMAIL_NEW_GMAIL_MESSAGE`. */
7586
- appEvent: z25.string(),
7543
+ appEvent: z24.string(),
7587
7544
  /** Which connected account — a tool can be connected more than once. */
7588
- account: z25.string(),
7545
+ account: z24.string(),
7589
7546
  /** The tool's own settings for the event (a label, a channel, a repository), as JSON text. */
7590
- configJson: z25.string().optional()
7547
+ configJson: z24.string().optional()
7591
7548
  }),
7592
- z25.object({
7593
- kind: z25.literal("event.received"),
7549
+ z24.object({
7550
+ kind: z24.literal("event.received"),
7594
7551
  /** Absent = any event. */
7595
- eventName: z25.string().optional()
7552
+ eventName: z24.string().optional()
7596
7553
  }),
7597
- z25.object({
7598
- kind: z25.literal("connection.created"),
7554
+ z24.object({
7555
+ kind: z24.literal("connection.created"),
7599
7556
  /** Absent = any tool. An OAuth provider type, or a Composio toolkit slug. */
7600
- provider: z25.string().optional()
7557
+ provider: z24.string().optional()
7601
7558
  }),
7602
- z25.object({
7603
- kind: z25.literal("connection.removed"),
7604
- provider: z25.string().optional()
7559
+ z24.object({
7560
+ kind: z24.literal("connection.removed"),
7561
+ provider: z24.string().optional()
7605
7562
  }),
7606
- z25.object({
7607
- kind: z25.literal("form.submitted"),
7563
+ z24.object({
7564
+ kind: z24.literal("form.submitted"),
7608
7565
  /** Absent = any Form. */
7609
- flowId: z25.string().optional()
7566
+ flowId: z24.string().optional()
7610
7567
  }),
7611
- z25.object({
7612
- kind: z25.literal("flow.step.submitted"),
7613
- flowId: z25.string(),
7614
- stepId: z25.string()
7568
+ z24.object({
7569
+ kind: z24.literal("flow.step.submitted"),
7570
+ flowId: z24.string(),
7571
+ stepId: z24.string()
7615
7572
  }),
7616
- z25.object({
7617
- kind: z25.literal("landing.created"),
7573
+ z24.object({
7574
+ kind: z24.literal("landing.created"),
7618
7575
  /** Absent = any page. A page's slug. */
7619
- page: z25.string().optional(),
7576
+ page: z24.string().optional(),
7620
7577
  /** Absent = any tag. */
7621
- tag: z25.string().optional()
7578
+ tag: z24.string().optional()
7622
7579
  }),
7623
- z25.object({
7624
- kind: z25.literal("landing.published"),
7625
- page: z25.string().optional(),
7626
- tag: z25.string().optional()
7580
+ z24.object({
7581
+ kind: z24.literal("landing.published"),
7582
+ page: z24.string().optional(),
7583
+ tag: z24.string().optional()
7627
7584
  }),
7628
- z25.object({
7629
- kind: z25.literal("experiment.started"),
7585
+ z24.object({
7586
+ kind: z24.literal("experiment.started"),
7630
7587
  /** Absent = any test. */
7631
- experimentId: z25.string().optional()
7588
+ experimentId: z24.string().optional()
7632
7589
  }),
7633
- z25.object({
7634
- kind: z25.literal("experiment.decided"),
7635
- experimentId: z25.string().optional()
7590
+ z24.object({
7591
+ kind: z24.literal("experiment.decided"),
7592
+ experimentId: z24.string().optional()
7636
7593
  }),
7637
- z25.object({
7638
- kind: z25.literal("experiment.ended"),
7639
- experimentId: z25.string().optional()
7594
+ z24.object({
7595
+ kind: z24.literal("experiment.ended"),
7596
+ experimentId: z24.string().optional()
7640
7597
  }),
7641
- z25.object({
7642
- kind: z25.literal("experiment.concluded"),
7643
- experimentId: z25.string().optional()
7598
+ z24.object({
7599
+ kind: z24.literal("experiment.concluded"),
7600
+ experimentId: z24.string().optional()
7644
7601
  }),
7645
- z25.object({
7646
- kind: z25.literal("task.created"),
7602
+ z24.object({
7603
+ kind: z24.literal("task.created"),
7647
7604
  /** Absent = any Task. */
7648
- tag: z25.string().optional()
7605
+ tag: z24.string().optional()
7649
7606
  }),
7650
- z25.object({
7651
- kind: z25.literal("task.claimed"),
7607
+ z24.object({
7608
+ kind: z24.literal("task.claimed"),
7652
7609
  /** Absent = any Task. One Task, by id. */
7653
- taskId: z25.string().optional(),
7654
- tag: z25.string().optional()
7610
+ taskId: z24.string().optional(),
7611
+ tag: z24.string().optional()
7655
7612
  }),
7656
- z25.object({
7657
- kind: z25.literal("task.completed"),
7658
- taskId: z25.string().optional(),
7659
- tag: z25.string().optional()
7613
+ z24.object({
7614
+ kind: z24.literal("task.completed"),
7615
+ taskId: z24.string().optional(),
7616
+ tag: z24.string().optional()
7660
7617
  }),
7661
- z25.object({
7662
- kind: z25.literal("session.published"),
7618
+ z24.object({
7619
+ kind: z24.literal("session.published"),
7663
7620
  /** Absent = any agent. Only the runs of this Scheduled agent. */
7664
- agentId: z25.string().optional()
7621
+ agentId: z24.string().optional()
7665
7622
  }),
7666
- z25.object({
7667
- kind: z25.literal("session.publish_failed"),
7668
- agentId: z25.string().optional()
7623
+ z24.object({
7624
+ kind: z24.literal("session.publish_failed"),
7625
+ agentId: z24.string().optional()
7669
7626
  }),
7670
- z25.object({
7671
- kind: z25.literal("knowledge.updated"),
7627
+ z24.object({
7628
+ kind: z24.literal("knowledge.updated"),
7672
7629
  /** Absent = any collection. */
7673
- collection: z25.string().optional()
7630
+ collection: z24.string().optional()
7674
7631
  }),
7675
- z25.object({ kind: z25.literal("brand.updated") }),
7676
- z25.object({ kind: z25.literal("creative.created") }),
7677
- z25.object({
7678
- kind: z25.literal("connection.needs_reconnect"),
7679
- provider: z25.string().optional()
7632
+ z24.object({ kind: z24.literal("brand.updated") }),
7633
+ z24.object({ kind: z24.literal("creative.created") }),
7634
+ z24.object({
7635
+ kind: z24.literal("connection.needs_reconnect"),
7636
+ provider: z24.string().optional()
7680
7637
  }),
7681
- z25.object({
7682
- kind: z25.literal("session.publish_incomplete"),
7638
+ z24.object({
7639
+ kind: z24.literal("session.publish_incomplete"),
7683
7640
  /** Absent = any platform. One of `PUBLISH_PLATFORMS`. */
7684
- platform: z25.string().optional(),
7685
- agentId: z25.string().optional()
7641
+ platform: z24.string().optional(),
7642
+ agentId: z24.string().optional()
7686
7643
  }),
7687
- z25.object({
7688
- kind: z25.literal("review.received"),
7644
+ z24.object({
7645
+ kind: z24.literal("review.received"),
7689
7646
  /** Absent = any review source. */
7690
- sourceId: z25.string().optional()
7647
+ sourceId: z24.string().optional()
7691
7648
  }),
7692
- z25.object({
7693
- kind: z25.literal("advertiser.new_ads"),
7649
+ z24.object({
7650
+ kind: z24.literal("advertiser.new_ads"),
7694
7651
  /** Absent = any followed advertiser. */
7695
- advertiserId: z25.string().optional()
7652
+ advertiserId: z24.string().optional()
7696
7653
  })
7697
7654
  ]);
7698
- var occurrencesSchema = z25.array(z25.number().int().positive()).max(32);
7655
+ var occurrencesSchema = z24.array(z24.number().int().positive()).max(32);
7699
7656
  function firstTimes(count2) {
7700
7657
  return Array.from({ length: Math.max(0, Math.floor(count2)) }, (_, index) => index + 1);
7701
7658
  }
7702
7659
 
7660
+ // ../api/src/scheduledAgents.ts
7661
+ var scheduledAgentRunsAsSchema = z25.object({
7662
+ /** The person each run acts as; null when nobody owns it, so only the company's tools load. */
7663
+ name: z25.string().nullable(),
7664
+ /** That person's own connected tools. */
7665
+ personalTools: z25.array(z25.string()),
7666
+ /** The company's and organization's tools, and the platforms Baker connects to directly. */
7667
+ companyTools: z25.array(z25.string()),
7668
+ /** Set up, but nobody has signed in to them, so a run gets nothing from them. */
7669
+ notSignedIn: z25.array(z25.string()).optional(),
7670
+ /** The company switched connected tools off: only the platforms load. */
7671
+ toolsOff: z25.literal(true).optional()
7672
+ });
7673
+ var AUTO_PUBLISH_REFUSAL = 'Publishing every run unreviewed is a standing authorization only the user can grant, on the item itself, so it is recorded against their name. Stage the item without it, and once this chat is published ask the user to switch on "Publish its work on its own" (under "When a run finishes") on the item in Scheduled agents.';
7674
+ var scheduledAgentsUnstageRequestSchema = z25.object({
7675
+ chatId: z25.string().min(1),
7676
+ /** The item: a published id or a temp_agent_* id this chat staged. */
7677
+ ref: z25.string().min(1),
7678
+ /** One change of it, by its `index` in `list`'s draft. Left out, every change staged on it. */
7679
+ index: z25.number().int().min(0).optional()
7680
+ });
7681
+ var scheduledAgentsUnstageResponseSchema = z25.object({
7682
+ ok: z25.literal(true),
7683
+ data: z25.object({ ref: z25.string(), removed: z25.number().int().min(1) })
7684
+ });
7685
+ var scheduledAgentsListRequestSchema = z25.object({
7686
+ /** Also return what this chat staged. */
7687
+ chatId: z25.string().min(1).optional(),
7688
+ /** Every item and staged change as stored, briefs included. Left out, the compact view below. */
7689
+ full: z25.boolean().optional()
7690
+ });
7691
+ var scheduledAgentListItemSchema = z25.object({
7692
+ id: z25.string(),
7693
+ name: z25.string(),
7694
+ description: z25.string(),
7695
+ enabled: z25.boolean(),
7696
+ trigger: scheduledAgentTriggerSchema,
7697
+ occurrences: occurrencesSchema.optional(),
7698
+ conditions: conditionsSchema.optional(),
7699
+ cooldownMinutes: z25.number().optional(),
7700
+ /** ISO. Only a one-off knows its next moment. */
7701
+ nextRunAt: z25.string().optional(),
7702
+ /** ISO. */
7703
+ lastRunAt: z25.string().optional(),
7704
+ firedCount: z25.number(),
7705
+ totalRuns: z25.number(),
7706
+ templateName: z25.string().optional(),
7707
+ publishesOwnWork: z25.literal(true).optional(),
7708
+ /** Whether the connected tool is reporting to an `app.event` item. */
7709
+ listening: z25.object({ status: z25.string(), reason: z25.string().optional() }).optional()
7710
+ });
7711
+ var scheduledAgentStagedChangeSchema = z25.object({
7712
+ index: z25.number().int().min(0),
7713
+ kind: z25.enum(["create", "update", "delete"]),
7714
+ /** The published id, or the temp_agent_* id a create returned. */
7715
+ ref: z25.string(),
7716
+ name: z25.string(),
7717
+ description: z25.string().optional(),
7718
+ trigger: scheduledAgentTriggerSchema.optional(),
7719
+ enabled: z25.boolean().optional(),
7720
+ /** For an update: the fields it changes. */
7721
+ changes: z25.array(z25.string()).optional(),
7722
+ result: z25.object({
7723
+ status: z25.enum(["applied", "skipped", "failed"]),
7724
+ reason: z25.string().optional(),
7725
+ scheduledAgentId: z25.string().optional()
7726
+ }).optional()
7727
+ });
7728
+ var scheduledAgentsListResponseSchema = z25.object({
7729
+ ok: z25.literal(true),
7730
+ data: z25.object({
7731
+ published: z25.array(scheduledAgentListItemSchema),
7732
+ draft: z25.object({
7733
+ status: z25.enum(["active", "publishing", "discarded", "applied"]).nullable(),
7734
+ ops: z25.array(scheduledAgentStagedChangeSchema)
7735
+ }).nullable()
7736
+ }),
7737
+ hints: z25.array(z25.string()).optional()
7738
+ });
7739
+
7703
7740
  // ../api/src/scheduledAgentTriggerCatalog.ts
7741
+ import { z as z26 } from "zod";
7704
7742
  var catalogTriggerSchema = z26.object({
7705
7743
  kind: z26.string(),
7706
7744
  label: z26.string(),
@@ -26580,10 +26618,10 @@ Example: baker ads meta ads retag 120252158038400247 --url-tags "utm_source={{si
26580
26618
  }
26581
26619
  },
26582
26620
  run: async ({ args: args5 }) => {
26583
- const { apiPost: apiPost2 } = await import("./client-3DGBQ2H3.js");
26584
- const { requireChatId: requireChatId2 } = await import("./env-BSG7TY5Y.js");
26585
- const { writeJsonEnvelope: writeJsonEnvelope2 } = await import("./output-AT5SRVH7.js");
26586
- const { handleMetaError: handleMetaError2 } = await import("./shared-HZ44PY2F.js");
26621
+ const { apiPost: apiPost2 } = await import("./client-GR6YL3YX.js");
26622
+ const { requireChatId: requireChatId2 } = await import("./env-4P5HOGNA.js");
26623
+ const { writeJsonEnvelope: writeJsonEnvelope2 } = await import("./output-KMEPFOFT.js");
26624
+ const { handleMetaError: handleMetaError2 } = await import("./shared-26NWGQ5G.js");
26587
26625
  try {
26588
26626
  const accountId = bareAccountId2(args5);
26589
26627
  const urlTags = typeof args5["url-tags"] === "string" ? args5["url-tags"] : void 0;
@@ -26728,10 +26766,10 @@ function duplicateCommand2(entity, label) {
26728
26766
  replace: { type: "boolean", description: "Pause the original once the copy publishes" }
26729
26767
  },
26730
26768
  run: async ({ args: args5 }) => {
26731
- const { apiPost: apiPost2 } = await import("./client-3DGBQ2H3.js");
26732
- const { requireChatId: requireChatId2 } = await import("./env-BSG7TY5Y.js");
26733
- const { writeJsonEnvelope: writeJsonEnvelope2 } = await import("./output-AT5SRVH7.js");
26734
- const { handleMetaError: handleMetaError2 } = await import("./shared-HZ44PY2F.js");
26769
+ const { apiPost: apiPost2 } = await import("./client-GR6YL3YX.js");
26770
+ const { requireChatId: requireChatId2 } = await import("./env-4P5HOGNA.js");
26771
+ const { writeJsonEnvelope: writeJsonEnvelope2 } = await import("./output-KMEPFOFT.js");
26772
+ const { handleMetaError: handleMetaError2 } = await import("./shared-26NWGQ5G.js");
26735
26773
  try {
26736
26774
  const accountId = bareAccountId2(args5);
26737
26775
  const chatId = requireChatId2();
@@ -64270,27 +64308,32 @@ var getCommand4 = defineCommand199({
64270
64308
 
64271
64309
  // src/commands/scheduled-agents/list.ts
64272
64310
  import { defineCommand as defineCommand200 } from "citty";
64311
+ var FULL_DESCRIPTION = "Return every item and staged change as stored, briefs included (tens of KB). Prefer `get <id>` for one item.";
64273
64312
  registerSchema({
64274
64313
  command: "scheduled-agents.list",
64275
- description: "List published scheduled agents. Includes draft state when BAKER_CHAT_ID is set, or --chat <id> to read an earlier chat's staged items instead.",
64314
+ description: "List scheduled agents compactly: each published item's id, name, trigger, enabled and run counts, and each change this chat staged (index, kind, ref, name, trigger). Briefs are left out \u2014 `get <id>` returns one item in full, --full returns everything as stored. Includes draft state when BAKER_CHAT_ID is set, or --chat <id> to read an earlier chat's staged items instead.",
64276
64315
  args: {
64277
- chat: { type: "string", description: CHAT_READ_ARG.description, required: false }
64316
+ chat: { type: "string", description: CHAT_READ_ARG.description, required: false },
64317
+ full: { type: "boolean", description: FULL_DESCRIPTION, required: false }
64278
64318
  }
64279
64319
  });
64280
64320
  var listCommand17 = defineCommand200({
64281
64321
  meta: {
64282
64322
  name: "list",
64283
- description: "List scheduled agents. Includes staged draft ops when BAKER_CHAT_ID is set, or --chat <id> to read an earlier chat's staged items instead."
64323
+ description: "List scheduled agents: id, name, trigger and status for each, plus this chat's staged changes when BAKER_CHAT_ID is set (or --chat <id> for an earlier chat's). Briefs are left out. Start here: baker scheduled-agents list; then baker scheduled-agents get <id> for one item's brief."
64324
+ },
64325
+ args: {
64326
+ chat: CHAT_READ_ARG,
64327
+ full: { type: "boolean", description: FULL_DESCRIPTION, required: false, default: false }
64284
64328
  },
64285
- args: { chat: CHAT_READ_ARG },
64286
64329
  run: async ({ args: args5 }) => {
64287
64330
  try {
64288
64331
  const env = getEnv();
64289
- const body = {};
64290
64332
  const chatId = typeof args5.chat === "string" && args5.chat.length > 0 ? args5.chat : env.BAKER_CHAT_ID;
64291
- if (chatId) {
64292
- body.chatId = chatId;
64293
- }
64333
+ const body = {
64334
+ ...chatId ? { chatId } : {},
64335
+ ...args5.full === true ? { full: true } : {}
64336
+ };
64294
64337
  const response = await apiPost("/api/scheduled-agents/list", body);
64295
64338
  writeJson(response);
64296
64339
  } catch (err) {
@@ -69383,261 +69426,6 @@ Full guide: __tooling__/docs/tools/baker/winning-ads.md`
69383
69426
  }
69384
69427
  });
69385
69428
 
69386
- // src/unknown-flags.ts
69387
- var ALWAYS_ACCEPTED = /* @__PURE__ */ new Set(["help", "h", "version"]);
69388
- function subCommandsOf(command) {
69389
- const sub = command.subCommands;
69390
- return sub && typeof sub === "object" ? sub : null;
69391
- }
69392
- function argsOf(command) {
69393
- const args5 = command.args;
69394
- return args5 && typeof args5 === "object" ? args5 : null;
69395
- }
69396
- function resolveCommand2(root, argv) {
69397
- let command = root;
69398
- for (const token of argv) {
69399
- if (token === "--" || token.startsWith("-")) {
69400
- break;
69401
- }
69402
- const subCommands = subCommandsOf(command);
69403
- if (!subCommands) {
69404
- break;
69405
- }
69406
- const next = subCommands[token];
69407
- if (next === void 0) {
69408
- break;
69409
- }
69410
- if (typeof next !== "object") {
69411
- return { command, resolved: false };
69412
- }
69413
- command = next;
69414
- }
69415
- return { command, resolved: true };
69416
- }
69417
- function typeOf(def) {
69418
- return def && typeof def === "object" ? def.type : void 0;
69419
- }
69420
- function acceptedNames(command) {
69421
- const args5 = argsOf(command);
69422
- if (!args5) {
69423
- return null;
69424
- }
69425
- const names = new Set(ALWAYS_ACCEPTED);
69426
- for (const [name, def] of Object.entries(args5)) {
69427
- if (typeOf(def) === "positional") {
69428
- continue;
69429
- }
69430
- for (const spelling of [name, kebab(name), camel(name)]) {
69431
- names.add(spelling);
69432
- if (typeOf(def) === "boolean") {
69433
- names.add(`no-${spelling}`);
69434
- }
69435
- }
69436
- }
69437
- return names;
69438
- }
69439
- function kebab(name) {
69440
- return name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
69441
- }
69442
- function camel(name) {
69443
- return name.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
69444
- }
69445
- function findUnknownFlags(root, argv) {
69446
- const { command, resolved } = resolveCommand2(root, argv);
69447
- if (!resolved) {
69448
- return [];
69449
- }
69450
- const accepted = acceptedNames(command);
69451
- if (!accepted) {
69452
- return [];
69453
- }
69454
- const unknown = [];
69455
- for (const token of argv) {
69456
- if (token === "--") {
69457
- break;
69458
- }
69459
- if (!token.startsWith("--")) {
69460
- continue;
69461
- }
69462
- const name = token.slice(2).split("=")[0] ?? "";
69463
- if (name.length > 0 && !accepted.has(name) && !unknown.includes(token)) {
69464
- unknown.push(token);
69465
- }
69466
- }
69467
- return unknown;
69468
- }
69469
- var SYNONYMS = {
69470
- from: ["start-date", "start", "since"],
69471
- since: ["start-date", "start"],
69472
- start: ["start-date", "since"],
69473
- to: ["end-date", "end", "until"],
69474
- until: ["end-date", "end"],
69475
- end: ["end-date", "until"],
69476
- path: ["landing"],
69477
- url: ["landing"]
69478
- };
69479
- function closestFlag(unknown, command) {
69480
- const accepted = acceptedNames(command);
69481
- if (!accepted) {
69482
- return null;
69483
- }
69484
- const name = unknown.replace(/^--/, "").split("=")[0] ?? "";
69485
- const synonym = SYNONYMS[name]?.find((candidate) => accepted.has(candidate));
69486
- if (synonym) {
69487
- return `--${synonym}`;
69488
- }
69489
- const scored = [...accepted].filter((candidate) => !ALWAYS_ACCEPTED.has(candidate)).map((candidate) => ({
69490
- candidate,
69491
- prefix: sharedPrefix(name, candidate),
69492
- distance: editDistance(name, candidate)
69493
- })).filter(({ prefix, distance }) => prefix >= 4 || distance <= typoBudget(name)).sort((a, b) => b.prefix - a.prefix || a.distance - b.distance);
69494
- return scored[0] ? `--${scored[0].candidate}` : null;
69495
- }
69496
- function typoBudget(name) {
69497
- return Math.max(1, Math.floor(name.length / 3));
69498
- }
69499
- function sharedPrefix(a, b) {
69500
- let i = 0;
69501
- while (i < a.length && i < b.length && a[i] === b[i]) {
69502
- i++;
69503
- }
69504
- return i;
69505
- }
69506
- function editDistance(a, b) {
69507
- let previous = Array.from({ length: b.length + 1 }, (_, j) => j);
69508
- for (let i = 1; i <= a.length; i++) {
69509
- const current = [i];
69510
- for (let j = 1; j <= b.length; j++) {
69511
- const substitution = (previous[j - 1] ?? 0) + (a[i - 1] === b[j - 1] ? 0 : 1);
69512
- current.push(Math.min((previous[j] ?? 0) + 1, (current[j - 1] ?? 0) + 1, substitution));
69513
- }
69514
- previous = current;
69515
- }
69516
- return previous[b.length] ?? 0;
69517
- }
69518
- function commandFor(root, argv) {
69519
- const { command, resolved } = resolveCommand2(root, argv);
69520
- return resolved ? command : null;
69521
- }
69522
- function suggestFlag(unknown, command) {
69523
- const flag = closestFlag(unknown, command);
69524
- if (!flag) {
69525
- return null;
69526
- }
69527
- const args5 = argsOf(command) ?? {};
69528
- const name = flag.slice(2);
69529
- const def = args5[name] ?? args5[camel(name)];
69530
- const described = def && typeof def === "object" ? def.description : void 0;
69531
- const description = typeof described === "string" ? described.split(/(?<!\b(?:e\.g|i\.e|vs))\.\s/)[0]?.trim().replace(/\.$/, "") : "";
69532
- return description ? { flag, description } : { flag };
69533
- }
69534
- function suggestionText(suggestion) {
69535
- if (!suggestion) {
69536
- return "";
69537
- }
69538
- return suggestion.description ? `Did you mean ${suggestion.flag}? It is described as: ${suggestion.description}. ` : `Did you mean ${suggestion.flag}? `;
69539
- }
69540
- var OUTPUT_EXPLANATION = "This command has no --output option: `--output json` is accepted by every command that prints the JSON envelope, and md or files only where `baker schema` lists `output`. Drop the option and read the default output. ";
69541
- function unknownFlagEnvelope(unknown, commandPath, suggestion, hasSchema) {
69542
- const list = unknown.join(", ");
69543
- return {
69544
- ok: false,
69545
- error: {
69546
- code: "UNKNOWN_ARGUMENT",
69547
- message: `${list} ${unknown.length > 1 ? "are not options" : "is not an option"} of \`baker ${commandPath}\`.`,
69548
- fix: {
69549
- action: hasSchema ? "check_schema" : "check_help",
69550
- explanation: (unknown.some((flag) => flag === "--output" || flag.startsWith("--output=")) ? OUTPUT_EXPLANATION : "") + suggestionText(suggestion) + `Run \`${hasSchema ? `baker schema ${commandPath}` : `baker ${commandPath} --help`}\` to see every option this command takes. Do not re-run the same call: until this version an unrecognised option was accepted and ignored, so a command that looked like it had filtered or narrowed the result was in fact answering the unfiltered question.`
69551
- },
69552
- retryable: false
69553
- }
69554
- };
69555
- }
69556
- function commandPathOf(root, argv) {
69557
- const path48 = [];
69558
- let command = root;
69559
- for (const token of argv) {
69560
- if (token === "--" || token.startsWith("-")) {
69561
- break;
69562
- }
69563
- const subCommands = subCommandsOf(command);
69564
- const next = subCommands?.[token];
69565
- if (next === void 0 || typeof next !== "object") {
69566
- break;
69567
- }
69568
- path48.push(token);
69569
- command = next;
69570
- }
69571
- return path48.join(" ");
69572
- }
69573
- function refuseUnknownFlags(root, argv) {
69574
- const unknown = findUnknownFlags(root, argv);
69575
- if (unknown.length === 0) {
69576
- return;
69577
- }
69578
- const command = commandFor(root, argv);
69579
- const first = unknown[0];
69580
- const suggestion = command && first ? suggestFlag(first, command) : null;
69581
- const path48 = commandPathOf(root, argv);
69582
- process.stdout.write(
69583
- `${JSON.stringify(unknownFlagEnvelope(unknown, path48, suggestion, findSchema(path48.split(" ")) !== void 0), null, 2)}
69584
- `
69585
- );
69586
- process.exit(1);
69587
- }
69588
-
69589
- // src/output-flag.ts
69590
- var FLAG = "--output";
69591
- var ENVELOPE = "json";
69592
- var PRINTS_NO_ENVELOPE = /* @__PURE__ */ new Set([
69593
- "analytics sending-events",
69594
- "canvas run",
69595
- "canvas rerun",
69596
- "canvas sync-definition"
69597
- ]);
69598
- function declaredArg(command, name) {
69599
- const args5 = command.args;
69600
- if (!args5 || typeof args5 !== "object" || !(name in args5)) {
69601
- return null;
69602
- }
69603
- const def = args5[name];
69604
- return def && typeof def === "object" ? def : {};
69605
- }
69606
- function envelopeRequests(argv) {
69607
- const end = argv.indexOf("--");
69608
- const limit = end === -1 ? argv.length : end;
69609
- const found = [];
69610
- for (let index = 0; index < limit; index++) {
69611
- const token = argv[index];
69612
- if (token === `${FLAG}=${ENVELOPE}`) {
69613
- found.push({ index, length: 1 });
69614
- } else if (token === FLAG && argv[index + 1] === ENVELOPE && index + 1 < limit) {
69615
- found.push({ index, length: 2 });
69616
- index++;
69617
- }
69618
- }
69619
- return found;
69620
- }
69621
- function outputFlagForCommand(root, argv) {
69622
- const requests = envelopeRequests(argv);
69623
- if (requests.length === 0) {
69624
- return argv;
69625
- }
69626
- const command = commandFor(root, argv);
69627
- if (!command || declaredArg(command, "output") || PRINTS_NO_ENVELOPE.has(commandPathOf(root, argv))) {
69628
- return argv;
69629
- }
69630
- const jsonSwitch = declaredArg(command, "json")?.type === "boolean";
69631
- const dropped = new Set(requests.flatMap(({ index, length }) => length === 2 ? [index, index + 1] : [index]));
69632
- const first = requests[0]?.index;
69633
- return argv.flatMap((token, index) => {
69634
- if (!dropped.has(index)) {
69635
- return [token];
69636
- }
69637
- return jsonSwitch && index === first ? ["--json"] : [];
69638
- });
69639
- }
69640
-
69641
69429
  // src/version.ts
69642
69430
  import { readFileSync as readFileSync21 } from "fs";
69643
69431
  function packageJsonUrl() {
@@ -69664,6 +69452,7 @@ var main = defineCommand248({
69664
69452
  Auth: Set BAKER_API_KEY (starts with bk_) and BAKER_API_URL environment variables.
69665
69453
  Chat: Set BAKER_CHAT_ID for action and scheduled-agent commands that stage changes against a chat.
69666
69454
  Output: All commands return JSON envelopes: { ok: true, data: ... } or { ok: false, error: { code, message } }.
69455
+ Fields: --fields a,b,c keeps only those keys of each record in data, on every command that prints the envelope.
69667
69456
  Formats: --output json works on every command that prints the envelope. --output md|files only where 'baker schema <command>' lists output. (The research commands additionally accept csv and jsonl.)
69668
69457
  Introspection: Run 'baker schema <command>' to inspect argument schemas.`
69669
69458
  },
@@ -69703,6 +69492,11 @@ installStreamTaps();
69703
69492
  logInvocation(process.argv.slice(2));
69704
69493
  installExitRecord();
69705
69494
  process.argv = [...process.argv.slice(0, 2), ...outputFlagForCommand(main, process.argv.slice(2))];
69495
+ var fieldsFlag = takeFieldsFlag(main, process.argv.slice(2));
69496
+ if (fieldsFlag.fields) {
69497
+ process.argv = [...process.argv.slice(0, 2), ...fieldsFlag.argv];
69498
+ installFieldMask(fieldsFlag.fields, commandPathOf(main, fieldsFlag.argv));
69499
+ }
69706
69500
  refuseUnknownFlags(main, process.argv.slice(2));
69707
69501
  process.argv = [...process.argv.slice(0, 2), ...cacheFlagForParser(process.argv.slice(2))];
69708
69502
  runMain(main);