@koda-sl/baker-cli 0.488.0-dev.5028cd8d3 → 0.489.0-dev.1f5a5e8d5

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 (33) hide show
  1. package/README.md +1 -1
  2. package/dist/{chunk-RESDRJRP.js → chunk-67M2K65A.js} +2 -2
  3. package/dist/{chunk-L63JZLCX.js → chunk-YW7VMU5L.js} +8 -1
  4. package/dist/chunk-YW7VMU5L.js.map +1 -0
  5. package/dist/cli.js +4 -4
  6. package/dist/{create-W7OTXLCZ.js → create-HIGK7UKN.js} +3 -3
  7. package/dist/{delete-SRU4GRDT.js → delete-XGFIU72V.js} +3 -3
  8. package/dist/{get-GB6SPWCA.js → get-JYEQCS45.js} +3 -3
  9. package/dist/{list-N5SJXLYF.js → list-GHAMVJWS.js} +3 -3
  10. package/dist/{organization-LP3FAWFX.js → organization-ELFXEH7K.js} +268 -44
  11. package/dist/organization-ELFXEH7K.js.map +1 -0
  12. package/dist/{run-3AZJ3UQU.js → run-XGXIVUOW.js} +3 -3
  13. package/dist/{scheduled-agents-ELLU7BSE.js → scheduled-agents-ZRVXGCZA.js} +10 -10
  14. package/dist/{schema-BOOZEJPA.js → schema-XKEEAUXP.js} +2 -2
  15. package/dist/{targets-EXYCOHEX.js → targets-EGTSYGDN.js} +3 -3
  16. package/dist/{triggers-SJUXDU3X.js → triggers-B35BHU4B.js} +3 -3
  17. package/dist/{unstage-MKTIVI3I.js → unstage-J6VGWEA4.js} +3 -3
  18. package/dist/{update-COHXM25C.js → update-GBC6TJ3J.js} +3 -3
  19. package/package.json +1 -1
  20. package/dist/chunk-L63JZLCX.js.map +0 -1
  21. package/dist/organization-LP3FAWFX.js.map +0 -1
  22. /package/dist/{chunk-RESDRJRP.js.map → chunk-67M2K65A.js.map} +0 -0
  23. /package/dist/{create-W7OTXLCZ.js.map → create-HIGK7UKN.js.map} +0 -0
  24. /package/dist/{delete-SRU4GRDT.js.map → delete-XGFIU72V.js.map} +0 -0
  25. /package/dist/{get-GB6SPWCA.js.map → get-JYEQCS45.js.map} +0 -0
  26. /package/dist/{list-N5SJXLYF.js.map → list-GHAMVJWS.js.map} +0 -0
  27. /package/dist/{run-3AZJ3UQU.js.map → run-XGXIVUOW.js.map} +0 -0
  28. /package/dist/{scheduled-agents-ELLU7BSE.js.map → scheduled-agents-ZRVXGCZA.js.map} +0 -0
  29. /package/dist/{schema-BOOZEJPA.js.map → schema-XKEEAUXP.js.map} +0 -0
  30. /package/dist/{targets-EXYCOHEX.js.map → targets-EGTSYGDN.js.map} +0 -0
  31. /package/dist/{triggers-SJUXDU3X.js.map → triggers-B35BHU4B.js.map} +0 -0
  32. /package/dist/{unstage-MKTIVI3I.js.map → unstage-J6VGWEA4.js.map} +0 -0
  33. /package/dist/{update-COHXM25C.js.map → update-GBC6TJ3J.js.map} +0 -0
@@ -271,11 +271,21 @@ Examples:
271
271
  });
272
272
 
273
273
  // src/commands/organization/setup.ts
274
- import { readFileSync as readFileSync3 } from "fs";
274
+ import { mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
275
+ import { dirname, join as join3 } from "path";
275
276
 
276
277
  // ../api/src/organizationSetup.ts
277
278
  import { z } from "zod";
278
279
  var nameListSchema = z.array(z.string().trim().min(1)).max(50);
280
+ var setupKindSchema = z.enum(["agencyClient", "direct", "agency"]);
281
+ var setupTargetFields = {
282
+ companyId: z.string().min(1).optional(),
283
+ agencyId: z.string().min(1).optional()
284
+ };
285
+ function namesOneTarget(target) {
286
+ return target.companyId === void 0 !== (target.agencyId === void 0);
287
+ }
288
+ var ONE_TARGET = { message: "Name the company with --company <id> or the agency with --agency <id>, not both." };
279
289
  var clientSetupQuestionSchema = z.object({
280
290
  /** An existing question's id (from `show`), to reword or answer it; absent for a new one. */
281
291
  id: z.string().min(1).optional(),
@@ -291,6 +301,17 @@ var clientSetupBriefSchema = z.object({
291
301
  step: z.string().trim().min(1),
292
302
  note: z.string().trim().min(1).max(2e4)
293
303
  });
304
+ var clientSetupTeamSchema = z.object({
305
+ /** Every step to the kickoff, in date order. */
306
+ timeline: z.array(z.record(z.string(), z.unknown())).max(30).nullable().default(null),
307
+ /** Show or hide the timeline on the client's setup link. */
308
+ timelineShown: z.boolean().nullable().default(null),
309
+ /** The whole contract: plan, setup fee, agreement and its clauses, whether the client sees them. */
310
+ contract: z.record(z.string(), z.unknown()).nullable().default(null),
311
+ /** The client's legal and billing identity, each field a string or null to leave it. */
312
+ companyDetails: z.record(z.string(), z.string().nullable()).nullable().default(null),
313
+ welcomeEmail: z.object({ subject: z.string().trim().min(1).max(1e3), body: z.string().trim().min(1).max(2e4) }).nullable().default(null)
314
+ });
294
315
  var clientSetupSchema = z.object({
295
316
  /** What was understood about the company and why this setup, in a few lines for the reviewer. */
296
317
  summary: z.string().trim().min(1).max(4e3),
@@ -309,7 +330,9 @@ var clientSetupSchema = z.object({
309
330
  questions: z.array(clientSetupQuestionSchema).max(20).default([]),
310
331
  /** Existing questions (by id) to take off the setup. */
311
332
  removeQuestions: z.array(z.string().min(1)).max(20).default([]),
312
- briefs: z.array(clientSetupBriefSchema).max(20).default([])
333
+ briefs: z.array(clientSetupBriefSchema).max(20).default([]),
334
+ /** Baker's own team only: the timeline, contract, company details and welcome email. */
335
+ team: clientSetupTeamSchema.optional()
313
336
  });
314
337
  var clientSetupStepSchema = z.object({
315
338
  id: z.string(),
@@ -322,7 +345,16 @@ var clientSetupStepSchema = z.object({
322
345
  var clientSetupShowResponseSchema = z.object({
323
346
  ok: z.literal(true),
324
347
  data: z.object({
348
+ /** The company, or the agency being onboarded. */
325
349
  company: z.object({ id: z.string(), name: z.string(), website: z.string().nullable() }),
350
+ kind: setupKindSchema,
351
+ /**
352
+ * What this chat stages for it: the company's plan (with its questions and
353
+ * briefs), and our team's part — timeline, contract, company details,
354
+ * welcome email — under `team` (`baker organization setup team` first),
355
+ * in Baker's own team for a superadmin alone.
356
+ */
357
+ parts: z.object({ plan: z.boolean(), team: z.boolean() }),
326
358
  /** Whether the person in this chat may stage a setup: an admin of the organization. */
327
359
  canStage: z.boolean(),
328
360
  plan: z.object({
@@ -360,7 +392,8 @@ var clientSetupShowResponseSchema = z.object({
360
392
  link: z.object({ completed: z.number(), total: z.number() }).nullable(),
361
393
  /** What this chat staged for the company, if anything. */
362
394
  staged: clientSetupSchema.nullable()
363
- })
395
+ }),
396
+ hints: z.array(z.string()).optional()
364
397
  });
365
398
  var clientSetupSiteRequestSchema = z.object({
366
399
  kind: z.enum(["pages", "inspect"]),
@@ -372,45 +405,119 @@ var clientSetupSiteResponseSchema = z.object({
372
405
  ok: z.literal(true),
373
406
  data: z.record(z.string(), z.unknown())
374
407
  });
375
- var clientSetupStageRequestSchema = z.object({
376
- chatId: z.string().min(1),
377
- companyId: z.string().min(1),
378
- setup: clientSetupSchema
379
- });
408
+ var clientSetupStageRequestSchema = z.object({ chatId: z.string().min(1), ...setupTargetFields, setup: clientSetupSchema }).refine(namesOneTarget, ONE_TARGET);
380
409
  var clientSetupStageResponseSchema = z.object({
381
410
  ok: z.literal(true),
382
411
  data: z.object({
383
412
  company: z.object({ id: z.string(), name: z.string() }),
413
+ kind: setupKindSchema,
384
414
  /** What publishing would change, in the dashboard's words. */
385
415
  adds: z.array(z.string()),
386
416
  removes: z.array(z.string()),
387
417
  questions: z.object({ asked: z.number(), answered: z.number(), removed: z.number() }),
388
- briefs: z.number()
418
+ briefs: z.number(),
419
+ /** Our team's parts staged too, in Baker's own workspace: "timeline", "contract", "company details", "welcome email". */
420
+ team: z.array(z.string()).optional()
389
421
  }),
390
422
  hints: z.array(z.string()).optional()
391
423
  });
392
- var clientSetupUnstageRequestSchema = z.object({
393
- chatId: z.string().min(1),
394
- companyId: z.string().min(1)
395
- });
424
+ var clientSetupUnstageRequestSchema = z.object({ chatId: z.string().min(1), ...setupTargetFields }).refine(namesOneTarget, ONE_TARGET);
396
425
  var clientSetupUnstageResponseSchema = z.object({
397
426
  ok: z.literal(true),
398
427
  data: z.object({ removed: z.boolean() })
399
428
  });
429
+ var clientSetupClientsResponseSchema = z.object({
430
+ ok: z.literal(true),
431
+ data: z.object({
432
+ /** Baker's own team, for a superadmin: every client that signs with Baker is listed, whatever its organization. */
433
+ everyClient: z.boolean(),
434
+ companies: z.array(
435
+ z.object({
436
+ id: z.string(),
437
+ name: z.string(),
438
+ website: z.string().nullable(),
439
+ organization: z.string(),
440
+ kind: setupKindSchema,
441
+ /** It signs with Baker: our team's part of its setup (`team`) may be staged. */
442
+ signsWithBaker: z.boolean()
443
+ })
444
+ ),
445
+ /** Baker's own team, for a superadmin: the agencies to onboard (`--agency <id>`), our team's part alone. */
446
+ agencies: z.array(z.object({ id: z.string(), name: z.string() })).default([]),
447
+ /** How many more match: narrow the search. */
448
+ more: z.number()
449
+ })
450
+ });
451
+ var clientSetupTeamResponseSchema = z.object({
452
+ ok: z.literal(true),
453
+ data: z.object({
454
+ company: z.object({ id: z.string(), name: z.string() }),
455
+ kind: setupKindSchema,
456
+ /** How to stage our team's part, the planner's rules for it, and each part as it stands, as Markdown. */
457
+ guide: z.string()
458
+ })
459
+ });
460
+ var clientSetupAttioFileSchema = z.object({
461
+ id: z.string(),
462
+ name: z.string(),
463
+ contentType: z.string().nullable(),
464
+ size: z.number().nullable(),
465
+ date: z.string()
466
+ });
467
+ var clientSetupAttioResponseSchema = z.object({
468
+ ok: z.literal(true),
469
+ data: z.object({
470
+ company: z.object({ id: z.string(), name: z.string() }),
471
+ /** Whether the company is linked to its Attio record; nothing else is read when it is not. */
472
+ linked: z.boolean(),
473
+ read: z.object({ calls: z.number(), notes: z.number(), emails: z.number(), files: z.number() }).optional(),
474
+ unreadable: z.array(z.string()).optional(),
475
+ /** Every call with its transcript, note and logged email, newest first, as Markdown. */
476
+ history: z.string().optional(),
477
+ files: z.array(clientSetupAttioFileSchema).optional(),
478
+ file: z.object({ id: z.string(), text: z.string().optional(), error: z.string().optional() }).optional()
479
+ })
480
+ });
400
481
 
401
482
  // src/commands/organization/setup.ts
402
483
  import { defineCommand as defineCommand2 } from "citty";
403
484
  var DOC = "__tooling__/docs/tools/baker/organization.md";
485
+ var AGENCY_ARG = {
486
+ type: "string",
487
+ description: "An agency to onboard instead of a company (`baker organization setup clients` lists them)",
488
+ required: false
489
+ };
404
490
  registerSchema({
405
491
  command: "organization.setup.show",
406
- description: "Start here before preparing a company's setup: its setup as it stands (plan steps, platforms to connect, tags, questions with their ids and answers, step briefs), every step a plan can name, the platforms it already connected, its setup link's progress, whether the person in this chat may stage a setup (only an organization admin), and what this chat already staged. Example: baker organization setup show --company <id>.",
407
- args: {}
492
+ description: "Start here before preparing a setup: what kind it is (`kind`: agencyClient, direct or agency) and what it holds (`parts`: the company's plan, our team's part), the company's setup as it stands (plan steps, platforms to connect, tags, questions with their ids and answers, step briefs), every step a plan can name, the platforms it already connected, its setup link's progress, whether the person in this chat may stage a setup (only an organization admin), and what this chat already staged. Example: baker organization setup show --company <id>; an agency to onboard: baker organization setup show --agency <id>.",
493
+ args: { agency: AGENCY_ARG }
408
494
  });
409
495
  registerSchema({
410
496
  command: "organization.setup.stage",
411
- description: "Stage a company's whole setup on this chat \u2014 plan steps, platforms to connect, tags, questions (with the answers the conversations already give) and a brief per step \u2014 from a JSON file. Replaces what this chat staged for that company; applied to the company only when the person publishes, which also gives them the company's setup link. Only an admin of the organization. Example: baker organization setup stage --company <id> --file setup.json. File shape: { summary, sources[], steps[], connect[], tags[], keys[], apps[], questions[{id?, question, why, step?, answer?}], removeQuestions[], briefs[{step, note}] }.",
497
+ description: "Stage a whole setup on this chat \u2014 plan steps, platforms to connect, tags, questions (with the answers the conversations already give) and a brief per step \u2014 from a JSON file. Replaces what this chat staged for it; applied only when the person publishes, which also gives them the setup link. Only an admin of the organization. Example: baker organization setup stage --company <id> --file setup.json. File shape: { summary, sources[], steps[], connect[], tags[], keys[], apps[], questions[{id?, question, why, step?, answer?}], removeQuestions[], briefs[{step, note}], team? }. `team` is Baker's own team's part \u2014 { timeline, timelineShown, contract, companyDetails, welcomeEmail }, shapes in `baker organization setup team`. An agency's onboarding (--agency <id>) is { summary, sources[], team } and nothing else.",
498
+ args: {
499
+ file: { type: "string", description: "The setup as JSON (shape in the description)", required: true },
500
+ agency: AGENCY_ARG
501
+ }
502
+ });
503
+ registerSchema({
504
+ command: "organization.setup.clients",
505
+ description: "The companies this chat may prepare a setup for, when `baker organization companies` does not list the one asked for: in Baker's own team, for a superadmin, every client that signs with Baker, whatever its organization, and every agency to onboard (`agencies`, named with --agency). Example: baker organization setup clients --search acme.",
506
+ args: {
507
+ search: { type: "string", description: "Keep companies whose name or website has these words", required: false }
508
+ }
509
+ });
510
+ registerSchema({
511
+ command: "organization.setup.team",
512
+ description: "Baker's own team only, when `show` answers parts.team: true \u2014 our team's part of a setup as it stands (timeline to the kickoff, contract with Stripe's plans and coupons, company details, welcome email), the shapes to stage it under `team`, and the setup planner's rules for each (an agency's own, with --agency). Example: baker organization setup team --company <id>; baker organization setup team --agency <id>.",
513
+ args: { agency: AGENCY_ARG }
514
+ });
515
+ registerSchema({
516
+ command: "organization.setup.attio",
517
+ description: "Baker's own team only: what Baker's CRM (Attio) holds on a client that signs with Baker, or an agency to onboard \u2014 every call with its transcript, notes, logged emails \u2014 saved to a file whose path it prints, with the record's files; `--file-id` reads one file (a proposal, a deck) as text. Read it first: it is where our team's deal, offer and kickoff come from. Example: baker organization setup attio --company <id>; baker organization setup attio --agency <id>.",
412
518
  args: {
413
- file: { type: "string", description: "The setup as JSON (shape in the description)", required: true }
519
+ "file-id": { type: "string", description: "One of the record's files, to read as text", required: false },
520
+ agency: AGENCY_ARG
414
521
  }
415
522
  });
416
523
  registerSchema({
@@ -428,18 +535,34 @@ registerSchema({
428
535
  });
429
536
  registerSchema({
430
537
  command: "organization.setup.unstage",
431
- description: "Take back the setup this chat staged for a company. Example: baker organization setup unstage --company <id>.",
432
- args: {}
538
+ description: "Take back the setup this chat staged for a company, or an agency's onboarding. Example: baker organization setup unstage --company <id>.",
539
+ args: { agency: AGENCY_ARG }
433
540
  });
434
- function namedCompany() {
435
- const companyId = optionalTargetCompany();
541
+ function setupTarget(named) {
542
+ if (named.company && named.agency) {
543
+ return { ok: false, error: "Name the company with --company or the agency with --agency, not both." };
544
+ }
545
+ if (named.agency) {
546
+ return { ok: true, target: { agencyId: named.agency } };
547
+ }
548
+ if (named.company) {
549
+ return { ok: true, target: { companyId: named.company } };
550
+ }
551
+ return {
552
+ ok: false,
553
+ error: "Name the company with --company <id>, or the agency to onboard with --agency <id>. `baker organization companies` and `baker organization setup clients` list them."
554
+ };
555
+ }
556
+ function namedTarget(agency) {
557
+ const company = optionalTargetCompany();
436
558
  clearTargetCompany();
437
- if (!companyId) {
438
- failValidation("Name the company with --company <id>. `baker organization companies` lists them.");
559
+ const named = setupTarget({ ...company ? { company } : {}, ...agency ? { agency } : {} });
560
+ if (!named.ok) {
561
+ failValidation(named.error);
439
562
  }
440
- return companyId;
563
+ return named.target;
441
564
  }
442
- function stageBody(text, companyId, chatId) {
565
+ function stageBody(text, target, chatId) {
443
566
  let raw;
444
567
  try {
445
568
  raw = JSON.parse(text);
@@ -455,28 +578,29 @@ function stageBody(text, companyId, chatId) {
455
578
  error: `${where}: ${issue?.message ?? "invalid"}. See \`baker schema organization.setup.stage\`.`
456
579
  };
457
580
  }
458
- return { ok: true, body: { chatId, companyId, setup: parsed.data } };
581
+ return { ok: true, body: { chatId, ...target, setup: parsed.data } };
459
582
  }
460
583
  var show = defineCommand2({
461
584
  meta: {
462
585
  name: "show",
463
- description: `A company's setup as it stands, and what this chat staged for it.
586
+ description: `What kind of setup it is and what it holds, the company's setup as it stands, and what this chat staged for it.
464
587
 
465
588
  Read it before staging: the question ids it lists are how you reword, answer or remove one.
466
589
 
467
590
  Examples:
468
591
  baker organization setup show --company <id>
592
+ baker organization setup show --agency <id> # an agency to onboard
469
593
 
470
594
  Full guide: ${DOC}`
471
595
  },
472
- args: {},
473
- run: async () => {
474
- const companyId = namedCompany();
596
+ args: { agency: AGENCY_ARG },
597
+ run: async ({ args }) => {
598
+ const target = namedTarget(args.agency);
475
599
  try {
476
600
  const chatId = optionalChatId();
477
601
  writeJson(
478
602
  await apiGet("/api/organization/setup", {
479
- companyId,
603
+ ...target,
480
604
  ...chatId ? { chatId } : {}
481
605
  })
482
606
  );
@@ -488,27 +612,29 @@ Full guide: ${DOC}`
488
612
  var stage = defineCommand2({
489
613
  meta: {
490
614
  name: "stage",
491
- description: `Stage a company's whole setup on this chat, applied to the company when the person publishes.
615
+ description: `Stage a whole setup on this chat, applied when the person publishes.
492
616
 
493
- Only an admin of the organization. Each call replaces what this chat staged for that company.
617
+ Only an admin of the organization. Each call replaces what this chat staged for that company or agency.
494
618
 
495
619
  Examples:
496
620
  baker organization setup stage --company <id> --file setup.json
621
+ baker organization setup stage --agency <id> --file onboarding.json
497
622
 
498
623
  Full guide: ${DOC}`
499
624
  },
500
625
  args: {
501
- file: { type: "string", description: "The setup as JSON", required: true }
626
+ file: { type: "string", description: "The setup as JSON", required: true },
627
+ agency: AGENCY_ARG
502
628
  },
503
629
  run: async ({ args }) => {
504
- const companyId = namedCompany();
630
+ const target = namedTarget(args.agency);
505
631
  let text;
506
632
  try {
507
633
  text = readFileSync3(args.file, "utf8");
508
634
  } catch {
509
635
  failValidation(`Cannot read ${args.file}.`);
510
636
  }
511
- const built = stageBody(text, companyId, requireChatId());
637
+ const built = stageBody(text, target, requireChatId());
512
638
  if (!built.ok) {
513
639
  failValidation(built.error);
514
640
  }
@@ -519,6 +645,103 @@ Full guide: ${DOC}`
519
645
  }
520
646
  }
521
647
  });
648
+ var ATTIO_DIR = "/tmp/baker-attio";
649
+ function attioReport(data, dir) {
650
+ const { history, ...rest } = data;
651
+ if (history === void 0) {
652
+ return { answer: rest, write: null };
653
+ }
654
+ const path = join3(dir, `${data.company.id}.md`);
655
+ return { answer: { ...rest, history: path }, write: { path, text: history } };
656
+ }
657
+ var clients = defineCommand2({
658
+ meta: {
659
+ name: "clients",
660
+ description: `The companies this chat may prepare a setup for. In Baker's own team, for a superadmin, every client that signs with Baker, and the agencies to onboard.
661
+
662
+ Examples:
663
+ baker organization setup clients --search acme
664
+
665
+ Full guide: ${DOC}`
666
+ },
667
+ args: {
668
+ search: { type: "string", description: "Keep companies whose name or website has these words", required: false }
669
+ },
670
+ run: async ({ args }) => {
671
+ try {
672
+ writeJson(
673
+ await apiGet("/api/organization/setup/clients", {
674
+ chatId: requireChatId(),
675
+ ...args.search ? { search: args.search } : {}
676
+ })
677
+ );
678
+ } catch (err) {
679
+ failApi(err);
680
+ }
681
+ }
682
+ });
683
+ var team = defineCommand2({
684
+ meta: {
685
+ name: "team",
686
+ description: `Baker's own team: our part of a setup \u2014 timeline, contract, company details, welcome email \u2014 as it stands, how to stage it, and the rules for each.
687
+
688
+ Examples:
689
+ baker organization setup team --company <id>
690
+ baker organization setup team --agency <id>
691
+
692
+ Full guide: ${DOC}`
693
+ },
694
+ args: { agency: AGENCY_ARG },
695
+ run: async ({ args }) => {
696
+ const target = namedTarget(args.agency);
697
+ try {
698
+ const response = await apiGet("/api/organization/setup/team", {
699
+ ...target,
700
+ chatId: requireChatId()
701
+ });
702
+ process.stdout.write(`${response.data.guide}
703
+ `);
704
+ } catch (err) {
705
+ failApi(err);
706
+ }
707
+ }
708
+ });
709
+ var attio = defineCommand2({
710
+ meta: {
711
+ name: "attio",
712
+ description: `Baker's own team: what Baker's CRM holds on a client or an agency \u2014 calls with transcripts, notes, logged emails \u2014 saved to a file, with its files.
713
+
714
+ Examples:
715
+ baker organization setup attio --company <id>
716
+ baker organization setup attio --agency <id>
717
+ baker organization setup attio --company <id> --file-id <id>
718
+
719
+ Full guide: ${DOC}`
720
+ },
721
+ args: {
722
+ "file-id": { type: "string", description: "One of the record's files, to read as text", required: false },
723
+ agency: AGENCY_ARG
724
+ },
725
+ run: async ({ args }) => {
726
+ const target = namedTarget(args.agency);
727
+ const fileId = args["file-id"];
728
+ try {
729
+ const response = await apiGet("/api/organization/setup/attio", {
730
+ ...target,
731
+ chatId: requireChatId(),
732
+ ...fileId ? { fileId } : {}
733
+ });
734
+ const report = attioReport(response.data, ATTIO_DIR);
735
+ if (report.write) {
736
+ mkdirSync2(dirname(report.write.path), { recursive: true });
737
+ writeFileSync2(report.write.path, report.write.text);
738
+ }
739
+ writeJson({ ok: true, data: report.answer });
740
+ } catch (err) {
741
+ failApi(err);
742
+ }
743
+ }
744
+ });
522
745
  async function readSite(body) {
523
746
  try {
524
747
  writeJson(await apiPost("/api/organization/setup/site", body));
@@ -566,21 +789,22 @@ Full guide: ${DOC}`
566
789
  var unstage = defineCommand2({
567
790
  meta: {
568
791
  name: "unstage",
569
- description: `Take back the setup this chat staged for a company.
792
+ description: `Take back the setup this chat staged for a company, or an agency's onboarding.
570
793
 
571
794
  Examples:
572
795
  baker organization setup unstage --company <id>
796
+ baker organization setup unstage --agency <id>
573
797
 
574
798
  Full guide: ${DOC}`
575
799
  },
576
- args: {},
577
- run: async () => {
578
- const companyId = namedCompany();
800
+ args: { agency: AGENCY_ARG },
801
+ run: async ({ args }) => {
802
+ const target = namedTarget(args.agency);
579
803
  try {
580
804
  writeJson(
581
805
  await apiPost("/api/organization/setup/unstage", {
582
806
  chatId: requireChatId(),
583
- companyId
807
+ ...target
584
808
  })
585
809
  );
586
810
  } catch (err) {
@@ -591,9 +815,9 @@ Full guide: ${DOC}`
591
815
  var setupCommand = defineCommand2({
592
816
  meta: {
593
817
  name: "setup",
594
- description: "A company's setup, prepared here by an admin of the organization: `show` it, `stage` the whole of it on this chat, applied to the company at Publish."
818
+ description: "A setup, prepared here by an admin of the organization \u2014 a company's, or in Baker's own team an agency's onboarding: `show` it, `stage` the whole of it on this chat, applied at Publish."
595
819
  },
596
- subCommands: { show, pages, inspect, stage, unstage }
820
+ subCommands: { show, clients, team, attio, pages, inspect, stage, unstage }
597
821
  });
598
822
 
599
823
  // src/commands/organization/index.ts
@@ -654,4 +878,4 @@ export {
654
878
  companiesHints,
655
879
  organizationCommand
656
880
  };
657
- //# sourceMappingURL=organization-LP3FAWFX.js.map
881
+ //# sourceMappingURL=organization-ELFXEH7K.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/organization/index.ts","../src/commands/organization/pull.ts","../src/commands/organization/workspaces.ts","../src/commands/organization/setup.ts","../../api/src/organizationSetup.ts"],"sourcesContent":["import type { OrganizationCompaniesResponse, OrganizationCompany } from \"@baker/api/organization\";\nimport { defineCommand } from \"citty\";\nimport { apiGet } from \"../../client.ts\";\nimport { writeJson } from \"../../output.ts\";\nimport { registerSchema } from \"../../schemas.ts\";\nimport { failApi } from \"../actions/shared.ts\";\nimport { pullCommand } from \"./pull.ts\";\nimport { setupCommand } from \"./setup.ts\";\n\nregisterSchema({\n command: \"organization.companies\",\n description:\n \"Start here in the organization workspace: every company of the organization, with its id and the platforms it has connected. Pass an id to any read with --company <id> (e.g. baker ads meta campaigns --company <id>) to read that company; a platform it has not connected answers 'not connected'. Only the organization workspace can run it, and it can only read.\",\n args: {},\n});\n\n/** What the agent must not miss even if it skims the list. */\nexport function companiesHints(companies: OrganizationCompany[]): string[] {\n const hints: string[] = [];\n const first = companies[0];\n if (first) {\n hints.push(\n `Read one company by adding --company <id> to any read, e.g. \\`baker ads meta campaigns --company ${first.id}\\`. Writes are refused: a company changes in its own chats.`,\n );\n }\n const unconnected = companies.filter((company) => company.platforms.length === 0);\n if (unconnected.length > 0) {\n hints.push(\n `Not connected to any platform, so every platform read refuses them: ${unconnected.map((c) => c.name).join(\", \")}.`,\n );\n }\n return hints;\n}\n\nconst companies = defineCommand({\n meta: {\n name: \"companies\",\n description: `Every company of the organization, with the platforms each has connected.\n\nOnly in the organization workspace, whose Reports read across companies. Every other read is the ordinary command plus --company <id>.\n\nExamples:\n baker organization companies\n baker ads meta campaigns --company <id>\n baker ads google campaigns list --company <id>\n\nFull guide: __tooling__/docs/tools/baker/organization.md`,\n },\n args: {},\n run: async () => {\n try {\n const response = await apiGet<OrganizationCompaniesResponse>(\"/api/organization/companies\");\n const hints = companiesHints(response.data);\n writeJson({ ...response, meta: { count: response.data.length }, ...(hints.length > 0 ? { hints } : {}) });\n } catch (err) {\n failApi(err);\n }\n },\n});\n\nexport const organizationCommand = defineCommand({\n meta: {\n name: \"organization\",\n description:\n \"The organization workspace: the companies its Reports read. Start with `baker organization companies`; read any of them with --company <id>; download what each made with `baker organization pull`; prepare a company's setup with `baker organization setup`.\",\n },\n subCommands: { companies, pull: pullCommand, setup: setupCommand },\n});\n","import { execFile } from \"node:child_process\";\nimport {\n chmodSync,\n existsSync,\n mkdirSync,\n mkdtempSync,\n readFileSync,\n renameSync,\n rmSync,\n writeFileSync,\n} from \"node:fs\";\nimport { homedir, tmpdir } from \"node:os\";\nimport { basename, join, resolve } from \"node:path\";\nimport { promisify } from \"node:util\";\nimport type {\n OrganizationCompaniesResponse,\n OrganizationCompany,\n OrganizationWorkspaceResponse,\n} from \"@baker/api/organization\";\nimport { defineCommand } from \"citty\";\nimport { ApiError, apiGet, apiPost } from \"../../client.ts\";\nimport { clearTargetCompany, optionalTargetCompany, setTargetCompany } from \"../../env.ts\";\nimport { writeJson } from \"../../output.ts\";\nimport { registerSchema } from \"../../schemas.ts\";\nimport { failApi } from \"../actions/shared.ts\";\nimport {\n copyCompanySurfaces,\n folderNames,\n listFiles,\n SURFACE_GUIDE,\n staleFolders,\n VERSION_FILE,\n} from \"./workspaces.ts\";\n\nconst run = promisify(execFile);\n\ntype Pulled = {\n id: string;\n name: string;\n folder: string;\n status: \"updated\" | \"unchanged\" | \"no_workspace\" | \"failed\";\n publishedAt?: string | null;\n files?: number;\n error?: string;\n};\n\nregisterSchema({\n command: \"organization.pull\",\n description:\n \"Download what each company made — knowledge, landing pages, Forms, brand, documents, custom agents and checks, Reports — as published, into one read-only folder per company (default ~/companies), with an INDEX.md to start from. Then read and search them like any files. Add --company <id> for one company. Only what is published: a Session's unpublished work is `baker chats diff <id> --company <id>`.\",\n args: {\n dir: { type: \"string\", description: \"Where to put the companies' folders (default: ~/companies)\", required: false },\n force: { type: \"boolean\", description: \"Download again even when nothing was published since\", required: false },\n },\n});\n\nfunction readVersion(folder: string): string | null {\n try {\n return (JSON.parse(readFileSync(join(folder, VERSION_FILE), \"utf8\")) as { version?: string }).version ?? null;\n } catch {\n return null;\n }\n}\n\n/** Unpacks one archive into a fresh folder of the company's own surfaces, swapped in whole. */\nasync function unpack(url: string, target: string): Promise<number> {\n const scratch = mkdtempSync(join(tmpdir(), \"baker-workspace-\"));\n try {\n const response = await fetch(url, { signal: AbortSignal.timeout(120_000) });\n if (!response.ok) throw new Error(`download failed (${response.status})`);\n const archive = join(scratch, \"workspace.tar.gz\");\n writeFileSync(archive, Buffer.from(await response.arrayBuffer()));\n const unpacked = join(scratch, \"unpacked\");\n mkdirSync(unpacked);\n await run(\"tar\", [\"-xzf\", archive, \"-C\", unpacked, \"--strip-components=1\"]);\n const staged = `${target}.partial`;\n rmSync(staged, { recursive: true, force: true });\n copyCompanySurfaces(unpacked, staged);\n const files = listFiles(staged);\n // Read-only, so nothing here is mistaken for a change to the company.\n for (const file of files) chmodSync(join(staged, file), 0o444);\n rmSync(target, { recursive: true, force: true });\n renameSync(staged, target);\n return files.length;\n } finally {\n rmSync(scratch, { recursive: true, force: true });\n }\n}\n\n/** Downloads one company's published workspace into `target`, unless it is already there. */\nasync function pullOne(company: OrganizationCompany, target: string, force: boolean): Promise<Pulled> {\n const entry: Pulled = { id: company.id, name: company.name, folder: basename(target), status: \"failed\" };\n try {\n setTargetCompany(company.id);\n const workspace = (await apiPost<OrganizationWorkspaceResponse>(\"/api/organization/workspace\", {})).data;\n if (!workspace) return { ...entry, status: \"no_workspace\" };\n entry.publishedAt = workspace.publishedAt;\n if (!force && existsSync(target) && readVersion(target) === workspace.version) {\n return { ...entry, status: \"unchanged\", files: listFiles(target).length - 1 };\n }\n const files = await unpack(workspace.url, target);\n writeFileSync(\n join(target, VERSION_FILE),\n `${JSON.stringify({ companyId: company.id, name: company.name, version: workspace.version, publishedAt: workspace.publishedAt }, null, 2)}\\n`,\n );\n return { ...entry, status: \"updated\", files };\n } catch (err) {\n return { ...entry, error: err instanceof Error ? err.message : String(err) };\n }\n}\n\nfunction indexMarkdown(dir: string, companies: OrganizationCompany[], pulled: Pulled[]): string {\n const byId = new Map(companies.map((company) => [company.id, company]));\n const rows = pulled.map((entry) => {\n const platforms =\n byId\n .get(entry.id)\n ?.platforms.map((platform) => platform.label)\n .join(\", \") || \"none\";\n const where = entry.status === \"no_workspace\" ? \"no workspace yet\" : `${entry.folder}/`;\n return `| ${entry.name} | \\`${entry.id}\\` | ${where} | ${entry.publishedAt ?? \"—\"} | ${platforms} |`;\n });\n return [\n \"# Companies of this organization\",\n \"\",\n `Each folder holds what one company made, as published. Read-only: a change to a company is made in that company's own chat. Refresh with \\`baker organization pull\\`.`,\n \"\",\n \"| Company | Id (for --company) | Folder | Published | Connected |\",\n \"|---|---|---|---|---|\",\n ...rows,\n \"\",\n \"## Where things are, in every company's folder\",\n \"\",\n ...SURFACE_GUIDE.map(([path, what]) => `- \\`${path}\\` — ${what}`),\n \"\",\n `Search every company at once: \\`grep -rn \"<term>\" ${dir}/*/src/content\\`.`,\n \"\",\n ].join(\"\\n\");\n}\n\nexport const pullCommand = defineCommand({\n meta: {\n name: \"pull\",\n description: `Download what each company made, as published, into one read-only folder per company.\n\nKnowledge, landing pages, Forms, brand, documents, custom agents and checks, Reports. Then read and search them like any files; start with INDEX.md.\n\nExamples:\n baker organization pull\n baker organization pull --company <id>\n grep -rn \"price\" ~/companies/*/src/content`,\n },\n args: {\n dir: { type: \"string\", description: \"Where to put the companies' folders (default: ~/companies)\", required: false },\n force: { type: \"boolean\", description: \"Download again even when nothing was published since\", required: false },\n },\n run: async ({ args }) => {\n try {\n const dir = resolve(args.dir ?? join(homedir(), \"companies\"));\n const only = optionalTargetCompany();\n // The list is the workspace's own read; each company is then named in turn.\n clearTargetCompany();\n const listed = (await apiGet<OrganizationCompaniesResponse>(\"/api/organization/companies\")).data;\n const companies = only ? listed.filter((company) => company.id === only) : listed;\n if (only && companies.length === 0) {\n throw new ApiError(\n \"NOT_FOUND\",\n \"No company of this organization has that id. Run `baker organization companies` for the ones you can read.\",\n );\n }\n const folders = folderNames(listed);\n mkdirSync(dir, { recursive: true });\n // A renamed company's old folder would still answer a search across them all.\n for (const stale of staleFolders(dir, folders)) rmSync(join(dir, stale), { recursive: true, force: true });\n const pulled: Pulled[] = [];\n for (const company of companies) {\n pulled.push(await pullOne(company, join(dir, folders[company.id] ?? company.id), args.force === true));\n }\n clearTargetCompany();\n if (!only) writeFileSync(join(dir, \"INDEX.md\"), indexMarkdown(dir, listed, pulled));\n const failed = pulled.filter((entry) => entry.status === \"failed\");\n writeJson({\n ok: true,\n data: { dir, companies: pulled },\n meta: { count: pulled.length },\n hints: [\n `Start with ${join(dir, \"INDEX.md\")}; each company's folder has the same layout.`,\n ...(failed.length > 0\n ? [\n `Not downloaded: ${failed.map((entry) => entry.name).join(\", \")}. Say so in the Report; run this again to retry.`,\n ]\n : []),\n ],\n });\n } catch (err) {\n failApi(err);\n }\n },\n});\n","import { cpSync, existsSync, lstatSync, readdirSync, readFileSync } from \"node:fs\";\nimport { join, relative } from \"node:path\";\n\n/**\n * What of a company's workspace the organization's agent reads: what the\n * company made — its knowledge, landing pages, Forms, brand, documents, custom\n * agents and checks, Reports — and none of the platform's own files, which are\n * the same in every company and would only bury the answer under copies of\n * themselves.\n */\nexport const COMPANY_SURFACES: readonly string[] = [\n \"COMPANY.md\",\n \"src/content\",\n \"src/collections\",\n \"src/pages\",\n \"src/components\",\n \"src/brand\",\n \"src/documents\",\n \"src/creatives\",\n \"src/lib/flow-engine/flows\",\n \".claude/agents\",\n \"__tooling__/checks/extensions\",\n \"reports/server\",\n \"reports/public\",\n];\n\n/** Where each surface is, for the index the agent reads first. */\nexport const SURFACE_GUIDE: ReadonlyArray<readonly [string, string]> = [\n [\"COMPANY.md\", \"who the company is: offer, audience, positioning\"],\n [\"src/content/<collection>/\", \"Knowledge — one folder per collection, one file per entry\"],\n [\n \"src/pages/<landing>/\",\n \"landing pages — `_definition.md` says what each is for; `index.astro` and `_components/` are the page\",\n ],\n [\"src/lib/flow-engine/flows/<form>/_data.json\", \"Forms — steps, questions, where each submission goes\"],\n [\"src/brand/\", \"brand — `BRAND.md` guidelines, `tokens.json` colours and fonts, logos\"],\n [\"src/documents/, src/creatives/\", \"documents and creatives — `_definition.md` each\"],\n [\".claude/agents/\", \"the company's own custom agents\"],\n [\"__tooling__/checks/extensions/\", \"the company's own rules: checks its work must pass\"],\n [\"reports/\", \"the company's own Reports\"],\n];\n\n/** What a pulled company folder says about itself: which company, at which published version. */\nexport const VERSION_FILE = \".baker-workspace.json\";\n\n/** Every file under `root`, relative and sorted. */\nexport function listFiles(root: string): string[] {\n if (!existsSync(root)) return [];\n const files: string[] = [];\n const walk = (dir: string) => {\n for (const entry of readdirSync(dir)) {\n const path = join(dir, entry);\n const entryStat = lstatSync(path);\n if (entryStat.isDirectory()) walk(path);\n else if (!entryStat.isSymbolicLink()) files.push(relative(root, path).split(\"\\\\\").join(\"/\"));\n }\n };\n walk(root);\n return files.sort();\n}\n\n/**\n * Copies the company's own surfaces of an unpacked workspace `from` into `to`,\n * links left out: one would point into the unpacked copy, gone once the pull\n * ends, or outside the pull folder.\n */\nexport function copyCompanySurfaces(from: string, to: string): void {\n const notALink = (source: string) => !lstatSync(source).isSymbolicLink();\n for (const surface of COMPANY_SURFACES) {\n const source = join(from, surface);\n if (existsSync(source)) cpSync(source, join(to, surface), { recursive: true, filter: notALink });\n }\n}\n\nfunction slug(name: string): string {\n const base = name\n .normalize(\"NFKD\")\n .replace(/[\\u0300-\\u036f]/g, \"\")\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n return base || \"company\";\n}\n\n/**\n * Each company's folder: its name, so the agent finds a client by what the user\n * calls it — and its id's tail beside it when two names read alike.\n */\nexport function folderNames(companies: ReadonlyArray<{ id: string; name: string }>): Record<string, string> {\n const counts = new Map<string, number>();\n for (const company of companies) counts.set(slug(company.name), (counts.get(slug(company.name)) ?? 0) + 1);\n return Object.fromEntries(\n companies.map((company) => {\n const base = slug(company.name);\n return [company.id, (counts.get(base) ?? 0) > 1 ? `${base}-${company.id.slice(-6)}` : base];\n }),\n );\n}\n\nfunction pulledCompanyId(folder: string): string | null {\n try {\n const recorded = JSON.parse(readFileSync(join(folder, VERSION_FILE), \"utf8\")) as { companyId?: unknown };\n return typeof recorded.companyId === \"string\" ? recorded.companyId : null;\n } catch {\n return null;\n }\n}\n\n/**\n * The folders under `dir` a pull made that no longer are a company's folder:\n * the company left the organization, or its folder is now named otherwise\n * (`folders`, by company id). A folder no pull made is never one of them.\n */\nexport function staleFolders(dir: string, folders: Readonly<Record<string, string>>): string[] {\n if (!existsSync(dir)) return [];\n return readdirSync(dir)\n .filter((name) => lstatSync(join(dir, name)).isDirectory())\n .filter((name) => {\n const companyId = pulledCompanyId(join(dir, name));\n return companyId !== null && folders[companyId] !== name;\n })\n .sort();\n}\n","import { mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport {\n type ClientSetupAttioResponse,\n type ClientSetupClientsResponse,\n type ClientSetupShowResponse,\n type ClientSetupSiteRequest,\n type ClientSetupSiteResponse,\n type ClientSetupStageRequest,\n type ClientSetupStageResponse,\n type ClientSetupTeamResponse,\n type ClientSetupUnstageResponse,\n clientSetupSchema,\n} from \"@baker/api/organizationSetup\";\nimport { defineCommand } from \"citty\";\nimport { apiGet, apiPost } from \"../../client.ts\";\nimport { clearTargetCompany, optionalChatId, optionalTargetCompany, requireChatId } from \"../../env.ts\";\nimport { writeJson } from \"../../output.ts\";\nimport { registerSchema } from \"../../schemas.ts\";\nimport { failApi, failValidation } from \"../actions/shared.ts\";\n\nconst DOC = \"__tooling__/docs/tools/baker/organization.md\";\n\n/** An agency to onboard, instead of a company: Baker's own team, for a superadmin. */\nconst AGENCY_ARG = {\n type: \"string\",\n description: \"An agency to onboard instead of a company (`baker organization setup clients` lists them)\",\n required: false,\n} as const;\n\nregisterSchema({\n command: \"organization.setup.show\",\n description:\n \"Start here before preparing a setup: what kind it is (`kind`: agencyClient, direct or agency) and what it holds (`parts`: the company's plan, our team's part), the company's setup as it stands (plan steps, platforms to connect, tags, questions with their ids and answers, step briefs), every step a plan can name, the platforms it already connected, its setup link's progress, whether the person in this chat may stage a setup (only an organization admin), and what this chat already staged. Example: baker organization setup show --company <id>; an agency to onboard: baker organization setup show --agency <id>.\",\n args: { agency: AGENCY_ARG },\n});\n\nregisterSchema({\n command: \"organization.setup.stage\",\n description:\n \"Stage a whole setup on this chat — plan steps, platforms to connect, tags, questions (with the answers the conversations already give) and a brief per step — from a JSON file. Replaces what this chat staged for it; applied only when the person publishes, which also gives them the setup link. Only an admin of the organization. Example: baker organization setup stage --company <id> --file setup.json. File shape: { summary, sources[], steps[], connect[], tags[], keys[], apps[], questions[{id?, question, why, step?, answer?}], removeQuestions[], briefs[{step, note}], team? }. `team` is Baker's own team's part — { timeline, timelineShown, contract, companyDetails, welcomeEmail }, shapes in `baker organization setup team`. An agency's onboarding (--agency <id>) is { summary, sources[], team } and nothing else.\",\n args: {\n file: { type: \"string\", description: \"The setup as JSON (shape in the description)\", required: true },\n agency: AGENCY_ARG,\n },\n});\n\nregisterSchema({\n command: \"organization.setup.clients\",\n description:\n \"The companies this chat may prepare a setup for, when `baker organization companies` does not list the one asked for: in Baker's own team, for a superadmin, every client that signs with Baker, whatever its organization, and every agency to onboard (`agencies`, named with --agency). Example: baker organization setup clients --search acme.\",\n args: {\n search: { type: \"string\", description: \"Keep companies whose name or website has these words\", required: false },\n },\n});\n\nregisterSchema({\n command: \"organization.setup.team\",\n description:\n \"Baker's own team only, when `show` answers parts.team: true — our team's part of a setup as it stands (timeline to the kickoff, contract with Stripe's plans and coupons, company details, welcome email), the shapes to stage it under `team`, and the setup planner's rules for each (an agency's own, with --agency). Example: baker organization setup team --company <id>; baker organization setup team --agency <id>.\",\n args: { agency: AGENCY_ARG },\n});\n\nregisterSchema({\n command: \"organization.setup.attio\",\n description:\n \"Baker's own team only: what Baker's CRM (Attio) holds on a client that signs with Baker, or an agency to onboard — every call with its transcript, notes, logged emails — saved to a file whose path it prints, with the record's files; `--file-id` reads one file (a proposal, a deck) as text. Read it first: it is where our team's deal, offer and kickoff come from. Example: baker organization setup attio --company <id>; baker organization setup attio --agency <id>.\",\n args: {\n \"file-id\": { type: \"string\", description: \"One of the record's files, to read as text\", required: false },\n agency: AGENCY_ARG,\n },\n});\n\nregisterSchema({\n command: \"organization.setup.pages\",\n description:\n \"A client's website pages, from its sitemap (or what search engines know), to pick the few worth reading for its setup: each offer, pricing, contact, quote and demo page. Example: baker organization setup pages --url https://acme.com --search pricing. Read a page with `baker research fetch <url>`.\",\n args: {\n url: { type: \"string\", description: \"The client's website\", required: true },\n search: { type: \"string\", description: \"Keep pages whose address has these words\", required: false },\n },\n});\n\nregisterSchema({\n command: \"organization.setup.inspect\",\n description:\n \"Visit a client's page as a visitor would, in a real browser that accepts its cookie banner: which tags fire and whether the page or a Tag Manager container loads each, the containers' tags, how it asks for consent (the tool, who loads it, Google Consent Mode), every form with its fields, the chat, booking and call-tracking tools, and the company's other addresses (where its landings already live). Slow and paid: the home page, each page with a form, and any landing they run — three visits at most. Example: baker organization setup inspect --url https://acme.com.\",\n args: { url: { type: \"string\", description: \"The page to visit\", required: true } },\n});\n\nregisterSchema({\n command: \"organization.setup.unstage\",\n description:\n \"Take back the setup this chat staged for a company, or an agency's onboarding. Example: baker organization setup unstage --company <id>.\",\n args: { agency: AGENCY_ARG },\n});\n\ntype SetupTarget = { companyId: string } | { agencyId: string };\n\n/** What a setup command is about: a company (`--company`) or an agency to onboard (`--agency`), never both. */\nexport function setupTarget(named: {\n company?: string;\n agency?: string;\n}): { ok: true; target: SetupTarget } | { ok: false; error: string } {\n if (named.company && named.agency) {\n return { ok: false, error: \"Name the company with --company or the agency with --agency, not both.\" };\n }\n if (named.agency) {\n return { ok: true, target: { agencyId: named.agency } };\n }\n if (named.company) {\n return { ok: true, target: { companyId: named.company } };\n }\n return {\n ok: false,\n error:\n \"Name the company with --company <id>, or the agency to onboard with --agency <id>. `baker organization companies` and `baker organization setup clients` list them.\",\n };\n}\n\n/**\n * The company or agency these commands are about. `--company` is taken like\n * every read's, but it travels in the request rather than as the header: the\n * header makes a call a read of that company, and staging is this workspace's\n * own change.\n */\nfunction namedTarget(agency: string | undefined): SetupTarget {\n const company = optionalTargetCompany();\n clearTargetCompany();\n const named = setupTarget({ ...(company ? { company } : {}), ...(agency ? { agency } : {}) });\n if (!named.ok) {\n failValidation(named.error);\n }\n return named.target;\n}\n\n/** The stage request for a setup file's text, or why it cannot be sent. */\nexport function stageBody(\n text: string,\n target: SetupTarget,\n chatId: string,\n): { ok: true; body: ClientSetupStageRequest } | { ok: false; error: string } {\n let raw: unknown;\n try {\n raw = JSON.parse(text);\n } catch {\n return { ok: false, error: \"The setup file is not valid JSON.\" };\n }\n const parsed = clientSetupSchema.safeParse(raw);\n if (!parsed.success) {\n const issue = parsed.error.issues[0];\n const where = issue?.path.join(\".\") || \"the setup\";\n return {\n ok: false,\n error: `${where}: ${issue?.message ?? \"invalid\"}. See \\`baker schema organization.setup.stage\\`.`,\n };\n }\n return { ok: true, body: { chatId, ...target, setup: parsed.data } };\n}\n\nconst show = defineCommand({\n meta: {\n name: \"show\",\n description: `What kind of setup it is and what it holds, the company's setup as it stands, and what this chat staged for it.\n\nRead it before staging: the question ids it lists are how you reword, answer or remove one.\n\nExamples:\n baker organization setup show --company <id>\n baker organization setup show --agency <id> # an agency to onboard\n\nFull guide: ${DOC}`,\n },\n args: { agency: AGENCY_ARG },\n run: async ({ args }) => {\n const target = namedTarget(args.agency);\n try {\n const chatId = optionalChatId();\n writeJson(\n await apiGet<ClientSetupShowResponse>(\"/api/organization/setup\", {\n ...target,\n ...(chatId ? { chatId } : {}),\n }),\n );\n } catch (err) {\n failApi(err);\n }\n },\n});\n\nconst stage = defineCommand({\n meta: {\n name: \"stage\",\n description: `Stage a whole setup on this chat, applied when the person publishes.\n\nOnly an admin of the organization. Each call replaces what this chat staged for that company or agency.\n\nExamples:\n baker organization setup stage --company <id> --file setup.json\n baker organization setup stage --agency <id> --file onboarding.json\n\nFull guide: ${DOC}`,\n },\n args: {\n file: { type: \"string\", description: \"The setup as JSON\", required: true },\n agency: AGENCY_ARG,\n },\n run: async ({ args }) => {\n const target = namedTarget(args.agency);\n let text: string;\n try {\n text = readFileSync(args.file, \"utf8\");\n } catch {\n failValidation(`Cannot read ${args.file}.`);\n }\n const built = stageBody(text, target, requireChatId());\n if (!built.ok) {\n failValidation(built.error);\n }\n try {\n writeJson(await apiPost<ClientSetupStageResponse>(\"/api/organization/setup/stage\", built.body));\n } catch (err) {\n failApi(err);\n }\n },\n});\n\n/** Where a client's Attio history is saved: outside the workspace, so nothing of it is ever published. */\nexport const ATTIO_DIR = \"/tmp/baker-attio\";\n\n/**\n * What `attio` answers, and the history it saves instead of printing: a\n * client's calls with their transcripts run to hundreds of pages, read and\n * searched from a file.\n */\nexport function attioReport(\n data: ClientSetupAttioResponse[\"data\"],\n dir: string,\n): { answer: Record<string, unknown>; write: { path: string; text: string } | null } {\n const { history, ...rest } = data;\n if (history === undefined) {\n return { answer: rest, write: null };\n }\n const path = join(dir, `${data.company.id}.md`);\n return { answer: { ...rest, history: path }, write: { path, text: history } };\n}\n\nconst clients = defineCommand({\n meta: {\n name: \"clients\",\n description: `The companies this chat may prepare a setup for. In Baker's own team, for a superadmin, every client that signs with Baker, and the agencies to onboard.\n\nExamples:\n baker organization setup clients --search acme\n\nFull guide: ${DOC}`,\n },\n args: {\n search: { type: \"string\", description: \"Keep companies whose name or website has these words\", required: false },\n },\n run: async ({ args }) => {\n try {\n writeJson(\n await apiGet<ClientSetupClientsResponse>(\"/api/organization/setup/clients\", {\n chatId: requireChatId(),\n ...(args.search ? { search: args.search } : {}),\n }),\n );\n } catch (err) {\n failApi(err);\n }\n },\n});\n\nconst team = defineCommand({\n meta: {\n name: \"team\",\n description: `Baker's own team: our part of a setup — timeline, contract, company details, welcome email — as it stands, how to stage it, and the rules for each.\n\nExamples:\n baker organization setup team --company <id>\n baker organization setup team --agency <id>\n\nFull guide: ${DOC}`,\n },\n args: { agency: AGENCY_ARG },\n run: async ({ args }) => {\n const target = namedTarget(args.agency);\n try {\n const response = await apiGet<ClientSetupTeamResponse>(\"/api/organization/setup/team\", {\n ...target,\n chatId: requireChatId(),\n });\n process.stdout.write(`${response.data.guide}\\n`);\n } catch (err) {\n failApi(err);\n }\n },\n});\n\nconst attio = defineCommand({\n meta: {\n name: \"attio\",\n description: `Baker's own team: what Baker's CRM holds on a client or an agency — calls with transcripts, notes, logged emails — saved to a file, with its files.\n\nExamples:\n baker organization setup attio --company <id>\n baker organization setup attio --agency <id>\n baker organization setup attio --company <id> --file-id <id>\n\nFull guide: ${DOC}`,\n },\n args: {\n \"file-id\": { type: \"string\", description: \"One of the record's files, to read as text\", required: false },\n agency: AGENCY_ARG,\n },\n run: async ({ args }) => {\n const target = namedTarget(args.agency);\n const fileId = args[\"file-id\"];\n try {\n const response = await apiGet<ClientSetupAttioResponse>(\"/api/organization/setup/attio\", {\n ...target,\n chatId: requireChatId(),\n ...(fileId ? { fileId } : {}),\n });\n const report = attioReport(response.data, ATTIO_DIR);\n if (report.write) {\n mkdirSync(dirname(report.write.path), { recursive: true });\n writeFileSync(report.write.path, report.write.text);\n }\n writeJson({ ok: true, data: report.answer });\n } catch (err) {\n failApi(err);\n }\n },\n});\n\n/** A site read for a setup, as the backend hands it over. */\nasync function readSite(body: ClientSetupSiteRequest): Promise<void> {\n try {\n writeJson(await apiPost<ClientSetupSiteResponse>(\"/api/organization/setup/site\", body));\n } catch (err) {\n failApi(err);\n }\n}\n\nconst pages = defineCommand({\n meta: {\n name: \"pages\",\n description: `A client's website pages, to choose the few that decide its setup.\n\nExamples:\n baker organization setup pages --url https://acme.com\n baker organization setup pages --url https://acme.com --search pricing\n\nFull guide: ${DOC}`,\n },\n args: {\n url: { type: \"string\", description: \"The client's website\", required: true },\n search: { type: \"string\", description: \"Keep pages whose address has these words\", required: false },\n },\n run: async ({ args }) => {\n await readSite({ kind: \"pages\", url: args.url, ...(args.search ? { search: args.search } : {}) });\n },\n});\n\nconst inspect = defineCommand({\n meta: {\n name: \"inspect\",\n description: `Visit a client's page as a visitor would: tags that fire, Tag Manager, cookie consent, forms and their fields.\n\nSlow and paid: the home page, each page with a form, any landing they run. Three visits at most.\n\nExamples:\n baker organization setup inspect --url https://acme.com\n baker organization setup inspect --url https://acme.com/quote\n\nFull guide: ${DOC}`,\n },\n args: { url: { type: \"string\", description: \"The page to visit\", required: true } },\n run: async ({ args }) => {\n await readSite({ kind: \"inspect\", url: args.url });\n },\n});\n\nconst unstage = defineCommand({\n meta: {\n name: \"unstage\",\n description: `Take back the setup this chat staged for a company, or an agency's onboarding.\n\nExamples:\n baker organization setup unstage --company <id>\n baker organization setup unstage --agency <id>\n\nFull guide: ${DOC}`,\n },\n args: { agency: AGENCY_ARG },\n run: async ({ args }) => {\n const target = namedTarget(args.agency);\n try {\n writeJson(\n await apiPost<ClientSetupUnstageResponse>(\"/api/organization/setup/unstage\", {\n chatId: requireChatId(),\n ...target,\n }),\n );\n } catch (err) {\n failApi(err);\n }\n },\n});\n\nexport const setupCommand = defineCommand({\n meta: {\n name: \"setup\",\n description:\n \"A setup, prepared here by an admin of the organization — a company's, or in Baker's own team an agency's onboarding: `show` it, `stage` the whole of it on this chat, applied at Publish.\",\n },\n subCommands: { show, clients, team, attio, pages, inspect, stage, unstage },\n});\n","import { z } from \"zod\";\n\n/**\n * `/api/organization/setup/*` (`baker organization setup`) — a setup prepared\n * in the organization workspace, of one of three kinds (`setupKindSchema`): a\n * company's plan — what it needs set up, the questions its people are asked on\n * its setup link (with any answer already found), and the brief each step's\n * chat starts from — and, from Baker's own team, our team's part: the timeline,\n * contract, company details and welcome email of a client that signs with\n * Baker, or of an agency's onboarding.\n *\n * Staged on the workspace's chat and applied to the company at Publish. Only an\n * admin of the organization may stage one; anyone who works across it may read.\n * The valid step, connection, tag and key names are decided by the backend\n * (`convex/clientSetup/stage.ts`), which names them when it refuses one.\n */\n\nconst nameListSchema = z.array(z.string().trim().min(1)).max(50);\n\n/**\n * What a setup is, decided by the backend from who signs with Baker:\n * `agencyClient` (a company its agency pays for: its plan alone), `direct` (a\n * company that signs with Baker: its plan and our team's part), `agency` (an\n * agency's onboarding: our team's part alone).\n */\nexport const setupKindSchema = z.enum([\"agencyClient\", \"direct\", \"agency\"]);\nexport type SetupKind = z.infer<typeof setupKindSchema>;\n\n/** What a setup is for: a company (`--company <id>`) or an agency to onboard (`--agency <id>`), never both. */\nconst setupTargetFields = {\n companyId: z.string().min(1).optional(),\n agencyId: z.string().min(1).optional(),\n};\n\nfunction namesOneTarget(target: { companyId?: string; agencyId?: string }): boolean {\n return (target.companyId === undefined) !== (target.agencyId === undefined);\n}\n\nconst ONE_TARGET = { message: \"Name the company with --company <id> or the agency with --agency <id>, not both.\" };\n\nexport const clientSetupQuestionSchema = z.object({\n /** An existing question's id (from `show`), to reword or answer it; absent for a new one. */\n id: z.string().min(1).optional(),\n question: z.string().trim().min(1).max(500),\n /** Why it matters to the setup, in a sentence. */\n why: z.string().trim().min(1).max(500),\n /** The step whose chat the answer is for; absent when it is about the company as a whole. */\n step: z.string().trim().min(1).optional(),\n /** The answer, when the conversations already give it. The company's people can still change it. */\n answer: z.string().trim().min(1).max(5_000).optional(),\n});\nexport type ClientSetupQuestion = z.infer<typeof clientSetupQuestionSchema>;\n\nexport const clientSetupBriefSchema = z.object({\n step: z.string().trim().min(1),\n note: z.string().trim().min(1).max(20_000),\n});\nexport type ClientSetupBrief = z.infer<typeof clientSetupBriefSchema>;\n\n/**\n * Our team's part of a setup, staged in Baker's own workspace alone, for a\n * client that signs with Baker: each part whole as it should be after\n * Publish, or null to leave it. Its shapes are the setup planner's\n * (`baker organization setup team` prints them, with its rules), checked by the\n * backend, which names the field it refuses.\n */\nexport const clientSetupTeamSchema = z.object({\n /** Every step to the kickoff, in date order. */\n timeline: z.array(z.record(z.string(), z.unknown())).max(30).nullable().default(null),\n /** Show or hide the timeline on the client's setup link. */\n timelineShown: z.boolean().nullable().default(null),\n /** The whole contract: plan, setup fee, agreement and its clauses, whether the client sees them. */\n contract: z.record(z.string(), z.unknown()).nullable().default(null),\n /** The client's legal and billing identity, each field a string or null to leave it. */\n companyDetails: z.record(z.string(), z.string().nullable()).nullable().default(null),\n welcomeEmail: z\n .object({ subject: z.string().trim().min(1).max(1_000), body: z.string().trim().min(1).max(20_000) })\n .nullable()\n .default(null),\n});\nexport type ClientSetupTeam = z.infer<typeof clientSetupTeamSchema>;\n\n/** The whole setup, as it should be once published: every call replaces what this chat staged before. */\nexport const clientSetupSchema = z.object({\n /** What was understood about the company and why this setup, in a few lines for the reviewer. */\n summary: z.string().trim().min(1).max(4_000),\n /** Where it was learned: \"Gmail: 14 emails with acme.com\", \"Kickoff call, 3 March (Fireflies)\". */\n sources: z.array(z.string().trim().min(1).max(300)).max(30).default([]),\n /** Steps done in Baker: `competitors`, `images`, `form`, `tracking`, `landing`, `domain`, … */\n steps: nameListSchema.default([]),\n /** Accounts to connect by signing in: `google-ads`, `meta`, `google-analytics`, `hubspot`, … */\n connect: nameListSchema.default([]),\n /** Tracking tags to add: `meta`, `googleAds`, `linkedinInsightTag`, `hotjar`, … */\n tags: nameListSchema.default([]),\n /** Accounts connected by pasting a key: `chatgpt-ads`. */\n keys: nameListSchema.default([]),\n /** Apps from the app catalog, by slug (`baker mcp catalog <search>`). */\n apps: nameListSchema.default([]),\n questions: z.array(clientSetupQuestionSchema).max(20).default([]),\n /** Existing questions (by id) to take off the setup. */\n removeQuestions: z.array(z.string().min(1)).max(20).default([]),\n briefs: z.array(clientSetupBriefSchema).max(20).default([]),\n /** Baker's own team only: the timeline, contract, company details and welcome email. */\n team: clientSetupTeamSchema.optional(),\n});\nexport type ClientSetup = z.infer<typeof clientSetupSchema>;\nexport type ClientSetupInput = z.input<typeof clientSetupSchema>;\n\n// --- show (`baker organization setup show --company <id>`) ---\n\nexport const clientSetupStepSchema = z.object({\n id: z.string(),\n title: z.string(),\n /** On the company's plan right now. */\n planned: z.boolean(),\n /** Done in a chat with a brief, rather than a sign-in or a setting. */\n briefed: z.boolean(),\n});\n\nexport const clientSetupShowResponseSchema = z.object({\n ok: z.literal(true),\n data: z.object({\n /** The company, or the agency being onboarded. */\n company: z.object({ id: z.string(), name: z.string(), website: z.string().nullable() }),\n kind: setupKindSchema,\n /**\n * What this chat stages for it: the company's plan (with its questions and\n * briefs), and our team's part — timeline, contract, company details,\n * welcome email — under `team` (`baker organization setup team` first),\n * in Baker's own team for a superadmin alone.\n */\n parts: z.object({ plan: z.boolean(), team: z.boolean() }),\n /** Whether the person in this chat may stage a setup: an admin of the organization. */\n canStage: z.boolean(),\n plan: z.object({\n steps: z.array(z.string()),\n connect: z.array(z.string()),\n tags: z.array(z.string()),\n keys: z.array(z.string()),\n apps: z.array(z.string()),\n }),\n /** Every step a plan can name, and whether this company's plan has it. */\n catalog: z.array(clientSetupStepSchema),\n /** Platforms the company already connected: never ask for them again. */\n connected: z.array(z.string()),\n /** Everything else it already has — tags with their ids, apps, Forms, landings, competitors followed, steps under way. */\n alreadyHas: z.array(z.string()),\n /** How to find this client in the team's tools: its email domains, the names it goes by, and notes the admins saved. */\n recognisedBy: z.object({\n saved: z.boolean(),\n emailDomains: z.array(z.string()),\n names: z.array(z.string()),\n notes: z.string(),\n }),\n questions: z.array(\n z.object({\n id: z.string(),\n question: z.string(),\n why: z.string(),\n step: z.string().nullable(),\n answer: z.string().nullable(),\n answeredBy: z.string().nullable(),\n }),\n ),\n briefs: z.array(z.object({ step: z.string(), note: z.string() })),\n /** Its setup link's progress, when it has one. */\n link: z.object({ completed: z.number(), total: z.number() }).nullable(),\n /** What this chat staged for the company, if anything. */\n staged: clientSetupSchema.nullable(),\n }),\n hints: z.array(z.string()).optional(),\n});\nexport type ClientSetupShowResponse = z.infer<typeof clientSetupShowResponseSchema>;\n\n// --- pages / inspect (`baker organization setup pages|inspect --url <url>`) ---\n\nexport const clientSetupSiteRequestSchema = z.object({\n kind: z.enum([\"pages\", \"inspect\"]),\n url: z.string().trim().min(1),\n /** `pages` only: keep pages whose address has these words, e.g. \"pricing\". */\n search: z.string().trim().min(1).optional(),\n});\nexport type ClientSetupSiteRequest = z.infer<typeof clientSetupSiteRequestSchema>;\n\n/** The planner's own reading of a site, as it hands it to the agent: pages, or a visit's tracking, consent and forms. */\nexport const clientSetupSiteResponseSchema = z.object({\n ok: z.literal(true),\n data: z.record(z.string(), z.unknown()),\n});\nexport type ClientSetupSiteResponse = z.infer<typeof clientSetupSiteResponseSchema>;\n\n// --- stage (`baker organization setup stage --company <id> --file setup.json`) ---\n\nexport const clientSetupStageRequestSchema = z\n .object({ chatId: z.string().min(1), ...setupTargetFields, setup: clientSetupSchema })\n .refine(namesOneTarget, ONE_TARGET);\nexport type ClientSetupStageRequest = z.input<typeof clientSetupStageRequestSchema>;\n\nexport const clientSetupStageResponseSchema = z.object({\n ok: z.literal(true),\n data: z.object({\n company: z.object({ id: z.string(), name: z.string() }),\n kind: setupKindSchema,\n /** What publishing would change, in the dashboard's words. */\n adds: z.array(z.string()),\n removes: z.array(z.string()),\n questions: z.object({ asked: z.number(), answered: z.number(), removed: z.number() }),\n briefs: z.number(),\n /** Our team's parts staged too, in Baker's own workspace: \"timeline\", \"contract\", \"company details\", \"welcome email\". */\n team: z.array(z.string()).optional(),\n }),\n hints: z.array(z.string()).optional(),\n});\nexport type ClientSetupStageResponse = z.infer<typeof clientSetupStageResponseSchema>;\n\n// --- unstage (`baker organization setup unstage --company <id>`) ---\n\nexport const clientSetupUnstageRequestSchema = z\n .object({ chatId: z.string().min(1), ...setupTargetFields })\n .refine(namesOneTarget, ONE_TARGET);\nexport type ClientSetupUnstageRequest = z.infer<typeof clientSetupUnstageRequestSchema>;\n\nexport const clientSetupUnstageResponseSchema = z.object({\n ok: z.literal(true),\n data: z.object({ removed: z.boolean() }),\n});\nexport type ClientSetupUnstageResponse = z.infer<typeof clientSetupUnstageResponseSchema>;\n\n// --- clients (`baker organization setup clients [--search <words>]`) ---\n\nexport const clientSetupClientsResponseSchema = z.object({\n ok: z.literal(true),\n data: z.object({\n /** Baker's own team, for a superadmin: every client that signs with Baker is listed, whatever its organization. */\n everyClient: z.boolean(),\n companies: z.array(\n z.object({\n id: z.string(),\n name: z.string(),\n website: z.string().nullable(),\n organization: z.string(),\n kind: setupKindSchema,\n /** It signs with Baker: our team's part of its setup (`team`) may be staged. */\n signsWithBaker: z.boolean(),\n }),\n ),\n /** Baker's own team, for a superadmin: the agencies to onboard (`--agency <id>`), our team's part alone. */\n agencies: z.array(z.object({ id: z.string(), name: z.string() })).default([]),\n /** How many more match: narrow the search. */\n more: z.number(),\n }),\n});\nexport type ClientSetupClientsResponse = z.infer<typeof clientSetupClientsResponseSchema>;\n\n// --- team (`baker organization setup team --company <id>`) ---\n\nexport const clientSetupTeamResponseSchema = z.object({\n ok: z.literal(true),\n data: z.object({\n company: z.object({ id: z.string(), name: z.string() }),\n kind: setupKindSchema,\n /** How to stage our team's part, the planner's rules for it, and each part as it stands, as Markdown. */\n guide: z.string(),\n }),\n});\nexport type ClientSetupTeamResponse = z.infer<typeof clientSetupTeamResponseSchema>;\n\n// --- attio (`baker organization setup attio --company <id> [--file-id <id>]`) ---\n\nexport const clientSetupAttioFileSchema = z.object({\n id: z.string(),\n name: z.string(),\n contentType: z.string().nullable(),\n size: z.number().nullable(),\n date: z.string(),\n});\n\n/** What Attio holds on a client that signs with Baker, or one of its files as text. */\nexport const clientSetupAttioResponseSchema = z.object({\n ok: z.literal(true),\n data: z.object({\n company: z.object({ id: z.string(), name: z.string() }),\n /** Whether the company is linked to its Attio record; nothing else is read when it is not. */\n linked: z.boolean(),\n read: z.object({ calls: z.number(), notes: z.number(), emails: z.number(), files: z.number() }).optional(),\n unreadable: z.array(z.string()).optional(),\n /** Every call with its transcript, note and logged email, newest first, as Markdown. */\n history: z.string().optional(),\n files: z.array(clientSetupAttioFileSchema).optional(),\n file: z.object({ id: z.string(), text: z.string().optional(), error: z.string().optional() }).optional(),\n }),\n});\nexport type ClientSetupAttioResponse = z.infer<typeof clientSetupAttioResponseSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAAS,iBAAAA,sBAAqB;;;ACD9B,SAAS,gBAAgB;AACzB;AAAA,EACE;AAAA,EACA,cAAAC;AAAA,EACA;AAAA,EACA;AAAA,EACA,gBAAAC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,SAAS,cAAc;AAChC,SAAS,UAAU,QAAAC,OAAM,eAAe;AACxC,SAAS,iBAAiB;AAM1B,SAAS,qBAAqB;;;ACnB9B,SAAS,QAAQ,YAAY,WAAW,aAAa,oBAAoB;AACzE,SAAS,MAAM,gBAAgB;AASxB,IAAM,mBAAsC;AAAA,EACjD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGO,IAAM,gBAA0D;AAAA,EACrE,CAAC,cAAc,kDAAkD;AAAA,EACjE,CAAC,6BAA6B,gEAA2D;AAAA,EACzF;AAAA,IACE;AAAA,IACA;AAAA,EACF;AAAA,EACA,CAAC,+CAA+C,2DAAsD;AAAA,EACtG,CAAC,cAAc,4EAAuE;AAAA,EACtF,CAAC,kCAAkC,sDAAiD;AAAA,EACpF,CAAC,mBAAmB,iCAAiC;AAAA,EACrD,CAAC,kCAAkC,oDAAoD;AAAA,EACvF,CAAC,YAAY,2BAA2B;AAC1C;AAGO,IAAM,eAAe;AAGrB,SAAS,UAAU,MAAwB;AAChD,MAAI,CAAC,WAAW,IAAI,EAAG,QAAO,CAAC;AAC/B,QAAM,QAAkB,CAAC;AACzB,QAAM,OAAO,CAAC,QAAgB;AAC5B,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AM;AAAA,IACJ,MAAM;AAAA,IACN,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUf;AAAA,EACA,MAAM,CAAC;AAAA,EACP,KAAK,YAAY;AACf,QAAI;AACF,YAAM,WAAW,MAAM,OAAsC,6BAA6B;AAC1F,YAAM,QAAQ,eAAe,SAAS,IAAI;AAC1C,gBAAU,EAAE,GAAG,UAAU,MAAM,EAAE,OAAO,SAAS,KAAK,OAAO,GAAG,GAAI,MAAM,SAAS,IAAI,EAAE,MAAM,IAAI,CAAC,EAAG,CAAC;AAAA,IAC1G,SAAS,KAAK;AACZ,cAAQ,GAAG;AAAA,IACb;AAAA,EACF;AACF,CAAC;AAEM,IAAM,sBAAsBA,eAAc;AAAA,EAC/C,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,aACE;AAAA,EACJ;AAAA,EACA,aAAa,EAAE,WAAW,MAAM,aAAa,OAAO,aAAa;AACnE,CAAC;","names":["defineCommand","existsSync","readFileSync","join","companies","readFileSync","join","existsSync","companies","mkdirSync","readFileSync","writeFileSync","join","defineCommand","defineCommand","readFileSync","join","mkdirSync","writeFileSync","companies","defineCommand"]}