@koda-sl/baker-cli 0.372.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.
package/README.md CHANGED
@@ -721,7 +721,7 @@ Command groups: `budgets`, `campaigns`, `ad-groups`, `keywords` (add/update/remo
721
721
 
722
722
  **Amending a staged op** — `draft amend <ref> (--file patch.json | --patch '<json>')` merges a JSON patch into an already-staged op's payload (objects deep-merge, `null` deletes a key, arrays/scalars replace) and re-validates it in full. Always prefer this over removing and re-staging — it preserves the op's ref (so dependents don't break) and its position in the draft. `draft show <ref>` prints the full staged payload (including warnings/annotations) so you can verify a change looks right before publish.
723
723
 
724
- **Reading an earlier chat's changes** — `draft list` and `draft show` take `--chat <chat-id>` to read another chat in the same company instead of the current one. Every staged-draft family accepts it: `ads google|meta|linkedin draft list|show`, `tag-manager draft list|show`, `actions draft`, `tags draft`, and `scheduled-agents list|get`. A published draft is kept in full, so this returns what that chat actually wrote — every headline, bid and target — plus each op's outcome and error. Use it when asked to redo or reapply earlier work rather than reconstructing copy from a summary. Read-only: staging, `amend`, `remove` and `clear` stay bound to `BAKER_CHAT_ID`, so one chat can never edit another's draft. To re-run only the changes a publish failed to land, use the chat's **Retry** control in the dashboard — it re-sends exactly those and leaves the ones that applied untouched.
724
+ **Reading an earlier chat's changes** — `draft list` and `draft show` take `--chat <chat-id>` to read another chat in the same company instead of the current one. Every staged-draft family accepts it: `ads google|meta|linkedin draft list|show`, `tag-manager draft list|show`, `actions draft`, `tags draft`, and `scheduled-agents list|get` (`list` leaves briefs out; `get <id>` or `list --full` returns them). A published draft is kept in full, so this returns what that chat actually wrote — every headline, bid and target — plus each op's outcome and error. Use it when asked to redo or reapply earlier work rather than reconstructing copy from a summary. Read-only: staging, `amend`, `remove` and `clear` stay bound to `BAKER_CHAT_ID`, so one chat can never edit another's draft. To re-run only the changes a publish failed to land, use the chat's **Retry** control in the dashboard — it re-sends exactly those and leaves the ones that applied untouched.
725
725
 
726
726
  **Already-satisfied writes aren't staged** — an update or pause/resume whose every field already holds the requested value on the live account is dropped instead of staged: the envelope returns `"staged": false, "noop": true` with a `reason` ("this ad is already Paused on Google Ads"), plus a hint. This is a success, not an error — there is nothing to publish. Only a positively-read live snapshot can trigger it; a failed or empty read always stages. Batch responses list the dropped ops under `skipped`, and `count` reflects what actually entered the draft.
727
727
 
@@ -3312,7 +3312,7 @@ A Scheduled agent is a **trigger** and a **prompt**. When the trigger fires, a S
3312
3312
  baker scheduled-agents triggers # every trigger kind, by group, compact
3313
3313
  baker scheduled-agents triggers --trigger experiment.decided # one kind (or a family: --trigger experiment) in full, with its payload fields
3314
3314
  baker scheduled-agents triggers --group tasks # one group in full; --full for the whole catalog
3315
- baker scheduled-agents list
3315
+ baker scheduled-agents list # id, name, trigger, status; briefs left out (--full for everything)
3316
3316
  baker scheduled-agents get <id-or-temp_agent_id>
3317
3317
 
3318
3318
  baker scheduled-agents create --name "Weekly report" --description "Prepare report" --prompt "Review last week's spend." --cron "0 9 * * MON" --timezone Europe/Madrid
package/dist/cli.js CHANGED
@@ -7143,37 +7143,10 @@ function parseConditionsExpression(expression) {
7143
7143
  }
7144
7144
 
7145
7145
  // ../api/src/scheduledAgents.ts
7146
- import { z as z24 } from "zod";
7147
- var scheduledAgentRunsAsSchema = z24.object({
7148
- /** The person each run acts as; null when nobody owns it, so only the company's tools load. */
7149
- name: z24.string().nullable(),
7150
- /** That person's own connected tools. */
7151
- personalTools: z24.array(z24.string()),
7152
- /** The company's and organization's tools, and the platforms Baker connects to directly. */
7153
- companyTools: z24.array(z24.string()),
7154
- /** Set up, but nobody has signed in to them, so a run gets nothing from them. */
7155
- notSignedIn: z24.array(z24.string()).optional(),
7156
- /** The company switched connected tools off: only the platforms load. */
7157
- toolsOff: z24.literal(true).optional()
7158
- });
7159
- 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.';
7160
- var scheduledAgentsUnstageRequestSchema = z24.object({
7161
- chatId: z24.string().min(1),
7162
- /** The item: a published id or a temp_agent_* id this chat staged. */
7163
- ref: z24.string().min(1),
7164
- /** One change of it, by its `index` in `list`'s draft. Left out, every change staged on it. */
7165
- index: z24.number().int().min(0).optional()
7166
- });
7167
- var scheduledAgentsUnstageResponseSchema = z24.object({
7168
- ok: z24.literal(true),
7169
- data: z24.object({ ref: z24.string(), removed: z24.number().int().min(1) })
7170
- });
7171
-
7172
- // ../api/src/scheduledAgentTriggerCatalog.ts
7173
- import { z as z26 } from "zod";
7146
+ import { z as z25 } from "zod";
7174
7147
 
7175
7148
  // ../api/src/scheduledAgentTriggers.ts
7176
- import { z as z25 } from "zod";
7149
+ import { z as z24 } from "zod";
7177
7150
  var TRIGGER_GROUPS = {
7178
7151
  time: { label: "Time", blurb: "On a clock you set." },
7179
7152
  incoming: { label: "Incoming", blurb: "Another tool or your site calls in." },
@@ -7539,152 +7512,233 @@ var TRIGGER_TARGETS = {
7539
7512
  "review.received": [target("sourceId", { open: false })],
7540
7513
  "advertiser.new_ads": [target("advertiserId", { open: false })]
7541
7514
  };
7542
- var triggerTargetOptionSchema = z25.object({
7543
- value: z25.string(),
7544
- label: z25.string(),
7515
+ var triggerTargetOptionSchema = z24.object({
7516
+ value: z24.string(),
7517
+ label: z24.string(),
7545
7518
  /** A second line: a status, a tag list, where it comes from. */
7546
- detail: z25.string().optional(),
7519
+ detail: z24.string().optional(),
7547
7520
  /** A mark: a path under the dashboard's `/logos/`, or an absolute image URL. */
7548
- logo: z25.string().optional()
7521
+ logo: z24.string().optional()
7549
7522
  });
7550
- var scheduledAgentTriggerSchema = z25.discriminatedUnion("kind", [
7551
- z25.object({
7552
- kind: z25.literal("time.once"),
7523
+ var scheduledAgentTriggerSchema = z24.discriminatedUnion("kind", [
7524
+ z24.object({
7525
+ kind: z24.literal("time.once"),
7553
7526
  /** Epoch ms. Must still be in the future when the item is written. */
7554
- runAt: z25.number(),
7527
+ runAt: z24.number(),
7555
7528
  /** IANA zone. Defaults to the company's. */
7556
- tz: z25.string()
7529
+ tz: z24.string()
7557
7530
  }),
7558
- z25.object({
7559
- kind: z25.literal("time.cron"),
7531
+ z24.object({
7532
+ kind: z24.literal("time.cron"),
7560
7533
  /** Five-field cron expression. */
7561
- cronspec: z25.string(),
7562
- tz: z25.string()
7534
+ cronspec: z24.string(),
7535
+ tz: z24.string()
7563
7536
  }),
7564
- z25.object({ kind: z25.literal("webhook.received") }),
7565
- z25.object({
7566
- kind: z25.literal("app.event"),
7537
+ z24.object({ kind: z24.literal("webhook.received") }),
7538
+ z24.object({
7539
+ kind: z24.literal("app.event"),
7567
7540
  /** The connected tool, by its toolkit slug: `gmail`, `slack`. */
7568
- toolkit: z25.string(),
7541
+ toolkit: z24.string(),
7569
7542
  /** What happens in it, by the tool's own trigger id: `GMAIL_NEW_GMAIL_MESSAGE`. */
7570
- appEvent: z25.string(),
7543
+ appEvent: z24.string(),
7571
7544
  /** Which connected account — a tool can be connected more than once. */
7572
- account: z25.string(),
7545
+ account: z24.string(),
7573
7546
  /** The tool's own settings for the event (a label, a channel, a repository), as JSON text. */
7574
- configJson: z25.string().optional()
7547
+ configJson: z24.string().optional()
7575
7548
  }),
7576
- z25.object({
7577
- kind: z25.literal("event.received"),
7549
+ z24.object({
7550
+ kind: z24.literal("event.received"),
7578
7551
  /** Absent = any event. */
7579
- eventName: z25.string().optional()
7552
+ eventName: z24.string().optional()
7580
7553
  }),
7581
- z25.object({
7582
- kind: z25.literal("connection.created"),
7554
+ z24.object({
7555
+ kind: z24.literal("connection.created"),
7583
7556
  /** Absent = any tool. An OAuth provider type, or a Composio toolkit slug. */
7584
- provider: z25.string().optional()
7557
+ provider: z24.string().optional()
7585
7558
  }),
7586
- z25.object({
7587
- kind: z25.literal("connection.removed"),
7588
- provider: z25.string().optional()
7559
+ z24.object({
7560
+ kind: z24.literal("connection.removed"),
7561
+ provider: z24.string().optional()
7589
7562
  }),
7590
- z25.object({
7591
- kind: z25.literal("form.submitted"),
7563
+ z24.object({
7564
+ kind: z24.literal("form.submitted"),
7592
7565
  /** Absent = any Form. */
7593
- flowId: z25.string().optional()
7566
+ flowId: z24.string().optional()
7594
7567
  }),
7595
- z25.object({
7596
- kind: z25.literal("flow.step.submitted"),
7597
- flowId: z25.string(),
7598
- stepId: z25.string()
7568
+ z24.object({
7569
+ kind: z24.literal("flow.step.submitted"),
7570
+ flowId: z24.string(),
7571
+ stepId: z24.string()
7599
7572
  }),
7600
- z25.object({
7601
- kind: z25.literal("landing.created"),
7573
+ z24.object({
7574
+ kind: z24.literal("landing.created"),
7602
7575
  /** Absent = any page. A page's slug. */
7603
- page: z25.string().optional(),
7576
+ page: z24.string().optional(),
7604
7577
  /** Absent = any tag. */
7605
- tag: z25.string().optional()
7578
+ tag: z24.string().optional()
7606
7579
  }),
7607
- z25.object({
7608
- kind: z25.literal("landing.published"),
7609
- page: z25.string().optional(),
7610
- tag: z25.string().optional()
7580
+ z24.object({
7581
+ kind: z24.literal("landing.published"),
7582
+ page: z24.string().optional(),
7583
+ tag: z24.string().optional()
7611
7584
  }),
7612
- z25.object({
7613
- kind: z25.literal("experiment.started"),
7585
+ z24.object({
7586
+ kind: z24.literal("experiment.started"),
7614
7587
  /** Absent = any test. */
7615
- experimentId: z25.string().optional()
7588
+ experimentId: z24.string().optional()
7616
7589
  }),
7617
- z25.object({
7618
- kind: z25.literal("experiment.decided"),
7619
- experimentId: z25.string().optional()
7590
+ z24.object({
7591
+ kind: z24.literal("experiment.decided"),
7592
+ experimentId: z24.string().optional()
7620
7593
  }),
7621
- z25.object({
7622
- kind: z25.literal("experiment.ended"),
7623
- experimentId: z25.string().optional()
7594
+ z24.object({
7595
+ kind: z24.literal("experiment.ended"),
7596
+ experimentId: z24.string().optional()
7624
7597
  }),
7625
- z25.object({
7626
- kind: z25.literal("experiment.concluded"),
7627
- experimentId: z25.string().optional()
7598
+ z24.object({
7599
+ kind: z24.literal("experiment.concluded"),
7600
+ experimentId: z24.string().optional()
7628
7601
  }),
7629
- z25.object({
7630
- kind: z25.literal("task.created"),
7602
+ z24.object({
7603
+ kind: z24.literal("task.created"),
7631
7604
  /** Absent = any Task. */
7632
- tag: z25.string().optional()
7605
+ tag: z24.string().optional()
7633
7606
  }),
7634
- z25.object({
7635
- kind: z25.literal("task.claimed"),
7607
+ z24.object({
7608
+ kind: z24.literal("task.claimed"),
7636
7609
  /** Absent = any Task. One Task, by id. */
7637
- taskId: z25.string().optional(),
7638
- tag: z25.string().optional()
7610
+ taskId: z24.string().optional(),
7611
+ tag: z24.string().optional()
7639
7612
  }),
7640
- z25.object({
7641
- kind: z25.literal("task.completed"),
7642
- taskId: z25.string().optional(),
7643
- tag: z25.string().optional()
7613
+ z24.object({
7614
+ kind: z24.literal("task.completed"),
7615
+ taskId: z24.string().optional(),
7616
+ tag: z24.string().optional()
7644
7617
  }),
7645
- z25.object({
7646
- kind: z25.literal("session.published"),
7618
+ z24.object({
7619
+ kind: z24.literal("session.published"),
7647
7620
  /** Absent = any agent. Only the runs of this Scheduled agent. */
7648
- agentId: z25.string().optional()
7621
+ agentId: z24.string().optional()
7649
7622
  }),
7650
- z25.object({
7651
- kind: z25.literal("session.publish_failed"),
7652
- agentId: z25.string().optional()
7623
+ z24.object({
7624
+ kind: z24.literal("session.publish_failed"),
7625
+ agentId: z24.string().optional()
7653
7626
  }),
7654
- z25.object({
7655
- kind: z25.literal("knowledge.updated"),
7627
+ z24.object({
7628
+ kind: z24.literal("knowledge.updated"),
7656
7629
  /** Absent = any collection. */
7657
- collection: z25.string().optional()
7630
+ collection: z24.string().optional()
7658
7631
  }),
7659
- z25.object({ kind: z25.literal("brand.updated") }),
7660
- z25.object({ kind: z25.literal("creative.created") }),
7661
- z25.object({
7662
- kind: z25.literal("connection.needs_reconnect"),
7663
- 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()
7664
7637
  }),
7665
- z25.object({
7666
- kind: z25.literal("session.publish_incomplete"),
7638
+ z24.object({
7639
+ kind: z24.literal("session.publish_incomplete"),
7667
7640
  /** Absent = any platform. One of `PUBLISH_PLATFORMS`. */
7668
- platform: z25.string().optional(),
7669
- agentId: z25.string().optional()
7641
+ platform: z24.string().optional(),
7642
+ agentId: z24.string().optional()
7670
7643
  }),
7671
- z25.object({
7672
- kind: z25.literal("review.received"),
7644
+ z24.object({
7645
+ kind: z24.literal("review.received"),
7673
7646
  /** Absent = any review source. */
7674
- sourceId: z25.string().optional()
7647
+ sourceId: z24.string().optional()
7675
7648
  }),
7676
- z25.object({
7677
- kind: z25.literal("advertiser.new_ads"),
7649
+ z24.object({
7650
+ kind: z24.literal("advertiser.new_ads"),
7678
7651
  /** Absent = any followed advertiser. */
7679
- advertiserId: z25.string().optional()
7652
+ advertiserId: z24.string().optional()
7680
7653
  })
7681
7654
  ]);
7682
- var occurrencesSchema = z25.array(z25.number().int().positive()).max(32);
7655
+ var occurrencesSchema = z24.array(z24.number().int().positive()).max(32);
7683
7656
  function firstTimes(count2) {
7684
7657
  return Array.from({ length: Math.max(0, Math.floor(count2)) }, (_, index) => index + 1);
7685
7658
  }
7686
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
+
7687
7740
  // ../api/src/scheduledAgentTriggerCatalog.ts
7741
+ import { z as z26 } from "zod";
7688
7742
  var catalogTriggerSchema = z26.object({
7689
7743
  kind: z26.string(),
7690
7744
  label: z26.string(),
@@ -64254,27 +64308,32 @@ var getCommand4 = defineCommand199({
64254
64308
 
64255
64309
  // src/commands/scheduled-agents/list.ts
64256
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.";
64257
64312
  registerSchema({
64258
64313
  command: "scheduled-agents.list",
64259
- 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.",
64260
64315
  args: {
64261
- 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 }
64262
64318
  }
64263
64319
  });
64264
64320
  var listCommand17 = defineCommand200({
64265
64321
  meta: {
64266
64322
  name: "list",
64267
- 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 }
64268
64328
  },
64269
- args: { chat: CHAT_READ_ARG },
64270
64329
  run: async ({ args: args5 }) => {
64271
64330
  try {
64272
64331
  const env = getEnv();
64273
- const body = {};
64274
64332
  const chatId = typeof args5.chat === "string" && args5.chat.length > 0 ? args5.chat : env.BAKER_CHAT_ID;
64275
- if (chatId) {
64276
- body.chatId = chatId;
64277
- }
64333
+ const body = {
64334
+ ...chatId ? { chatId } : {},
64335
+ ...args5.full === true ? { full: true } : {}
64336
+ };
64278
64337
  const response = await apiPost("/api/scheduled-agents/list", body);
64279
64338
  writeJson(response);
64280
64339
  } catch (err) {