@koda-sl/baker-cli 0.547.0 → 0.549.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.
@@ -9,7 +9,7 @@ import {
9
9
  accountsInfluencedRequestSchema,
10
10
  influenceParams,
11
11
  warmAccounts
12
- } from "./chunk-UZ4L5ERW.js";
12
+ } from "./chunk-TBIDT7FG.js";
13
13
  import {
14
14
  readTargetsFile
15
15
  } from "./chunk-4S5ZAG4S.js";
@@ -692,10 +692,10 @@ var accountsCommand = defineCommand({
692
692
  warm: warmCommand,
693
693
  company: companyCommand,
694
694
  campaigns: campaignsCommand,
695
- crm: () => import("./crm-CD7QLN65.js").then((m) => m.crmCommand)
695
+ crm: () => import("./crm-4GXVHO4R.js").then((m) => m.crmCommand)
696
696
  }
697
697
  });
698
698
  export {
699
699
  accountsCommand
700
700
  };
701
- //# sourceMappingURL=accounts-PU2GGSH4.js.map
701
+ //# sourceMappingURL=accounts-PLZTPM52.js.map
@@ -67,6 +67,7 @@ var INFLUENCE_MODEL_KINDS = ["engagement", "awareness", "intent"];
67
67
  var INFLUENCE_METRICS = ["impressions", "engagements", "clicks"];
68
68
  var DEFAULT_LOOKBACK_MONTHS = 12;
69
69
  var MATCH_CONFIDENCES = ["high", "low"];
70
+ var MATCH_METHODS = ["override", "linkedin_page", "domain", "name"];
70
71
  var MODEL_METRIC = {
71
72
  engagement: { metric: "engagements", threshold: 3 },
72
73
  awareness: { metric: "impressions", threshold: 7 },
@@ -141,6 +142,10 @@ var accountEngagementRowSchema = z.object({
141
142
  crmCompanyId: z.string().nullable(),
142
143
  /** The matched CRM company's name; null without a match. Optional for older servers. */
143
144
  crmCompanyName: z.string().nullable().optional(),
145
+ /** The matched CRM company's own website; null when it has none. Optional for older servers. */
146
+ crmCompanyDomain: z.string().nullable().optional(),
147
+ /** What the match was read off; null without a match. Optional for older servers. */
148
+ matchMethod: z.enum(MATCH_METHODS).nullable().optional(),
144
149
  matchConfidence: z.enum(MATCH_CONFIDENCES).nullable(),
145
150
  hasOpenDeal: z.boolean(),
146
151
  hasWonDeal: z.boolean(),
@@ -384,4 +389,4 @@ export {
384
389
  accountsCampaignsRequestSchema,
385
390
  ACCOUNTS_NO_SETTINGS_MESSAGE
386
391
  };
387
- //# sourceMappingURL=chunk-UZ4L5ERW.js.map
392
+ //# sourceMappingURL=chunk-TBIDT7FG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../api/src/accounts/crm-columns.ts","../../api/src/accounts/index.ts"],"sourcesContent":["import { CRM_COLUMN_FIELDS, CRM_DEAL_STATUSES, type CrmColumnField } from \"./crm\";\n\n/** A Jev Choice, as each caller's own Jev module sends it. */\nexport interface CrmColumnQuestion {\n type: \"choice\";\n instructions: Record<string, string>;\n criteria: Record<string, string>;\n}\n/** A Jev answer, as each caller's own Jev module reads it. */\nexport type CrmColumnAnswer =\n | { noul: number }\n | { choice: string; probabilities: Record<string, number> }\n | { score: number; probabilities: Record<string, number> };\n\n/**\n * What each column of a CRM spreadsheet holds, read by Jev from its header in\n * any language and a few of its cells — a Spanish \"Importe\", a Polish \"Kwota\",\n * a Pipedrive \"Deal - Value\" alike. Pure: the backend's action and `baker\n * accounts crm check` ask, these build the questions and read the answers,\n * so the upload and the check read a sheet alike. Baker's own headers never get here\n * (`exactCrmColumns`).\n */\n\n/**\n * A column is read only when Jev is this sure of its field; below it the\n * column is left behind and named as such, never filled with a guess. Set\n * from `scripts/crm-column-evals` against `JEV_MODEL`.\n */\nexport const COLUMN_HELD = 0.7;\n\nconst NONE = \"none\";\n\n/** Cells longer than this say nothing more about what the column is. */\nconst SAMPLE_CHARS = 60;\nconst EMAIL = /[^\\s@]+@[^\\s@]+\\.[^\\s@]+/g;\n\n/** Each field in plain words, with its boundary cases: Jev reads the criteria literally. */\nconst CRITERIA: Readonly<Record<CrmColumnField | typeof NONE, string>> = {\n id: \"The deal's own unique id or number in the CRM (a deal, opportunity or record id of the deal), not the company's id\",\n name: \"The deal's own title (a deal or opportunity name), not the name of the company or of a person\",\n companyId: \"The CRM's unique id (or record id) of the company or account the row is about or the deal is with\",\n companyName: \"The name of the company, account or organization the row is about or the deal is with\",\n companyDomain: \"The company's website or web domain, like acme.com\",\n companyLinkedinPage: \"The company's LinkedIn page address\",\n amount:\n \"The deal's own value in money (its amount, value or size), not a weighted or forecast amount, not a company's revenue or turnover, not a probability, a percentage or a count\",\n currency: \"The currency the amount is in, like EUR or USD\",\n pipeline: \"Which sales pipeline the deal belongs to, not its stage\",\n stage:\n \"The deal's stage or state in the sales pipeline, in any words (like Proposal, Negotiation, Closed Won, Ganado), not the status of a lead or a contact\",\n status: \"Whether the deal is open, won or lost, written as exactly the English word open, won or lost\",\n createdAt: \"The date the deal or the company was created, opened or added to the CRM\",\n closedAt: \"The date the deal was closed (won or lost) or is expected to close\",\n none: \"Anything else: a person (an owner, a contact, a person's name, email or phone), who created or last changed the record, a probability, a weighted amount, a company's revenue or size, a lead's or contact's status, a next step, a source, notes, an industry, a date of last activity, or any other field\",\n};\n\nconst QUESTION =\n \"`column` is the header of a column in a spreadsheet exported from a CRM, in any language or in the CRM's own wording, and `cells` are values from that column. `sheet` lists every header of the spreadsheet, for context. Which field does `column` hold?\";\n\n/** A cell as Jev sees it: an email address is shown as one, never sent. */\nfunction sampleCell(cell: string): string {\n return cell.replace(EMAIL, \"<email address>\").slice(0, SAMPLE_CHARS);\n}\n\nexport interface SampledColumn {\n header: string;\n samples: readonly string[];\n}\n\n/** One Choice per column, the column inside its own question, beside every header of the sheet (`headers`). */\nexport function crmColumnQuestions(\n columns: readonly SampledColumn[],\n headers: readonly string[] = columns.map((column) => column.header),\n): CrmColumnQuestion[] {\n const sheet = headers.join(\" | \");\n return columns.map(({ header, samples }) => ({\n type: \"choice\",\n instructions: {\n sheet,\n column: header,\n cells: samples.length > 0 ? samples.map(sampleCell).join(\" | \") : \"(empty)\",\n question: QUESTION,\n },\n criteria: CRITERIA,\n }));\n}\n\nexport const isCrmColumnField = (choice: string): choice is CrmColumnField =>\n (CRM_COLUMN_FIELDS as readonly string[]).includes(choice);\n\n/** Cells the contract takes as a status: anything else in a status column names the deal's state in its own words. */\nconst isStatusCell = (cell: string) => (CRM_DEAL_STATUSES as readonly string[]).includes(cell.trim().toLowerCase());\n\n/**\n * Each column Jev placed at `COLUMN_HELD` or above, and the field it holds;\n * `none` and unsure ones are absent. A status column whose cells are not\n * open, won and lost (\"Ganho\", \"Perdido\") is read as the deal's stage, so its\n * deals arrive with the stage a manager says won or lost, instead of every one\n * refused.\n */\nexport function crmColumnMeanings(\n columns: readonly SampledColumn[],\n answers: readonly CrmColumnAnswer[],\n held = COLUMN_HELD,\n): Record<string, CrmColumnField> {\n const meanings: Record<string, CrmColumnField> = {};\n columns.forEach(({ header, samples }, index) => {\n const answer = answers[index];\n if (answer === undefined || !(\"choice\" in answer)) return;\n const { choice, probabilities } = answer;\n if (!isCrmColumnField(choice) || (probabilities[choice] ?? 0) < held) return;\n meanings[header] = choice === \"status\" && !samples.every(isStatusCell) ? \"stage\" : choice;\n });\n return meanings;\n}\n","/**\n * Wire contract for `baker accounts` — which companies the LinkedIn ads are\n * warming, and which CRM deals they influenced — plus the pure rules every\n * reader of those numbers shares.\n *\n * \"Influenced\" is a labelled rule, not credit: a deal is influenced when its\n * company crossed the model's threshold in the months up to and including the\n * deal's reference month. A deal counts in full for every campaign that touched\n * it, so campaign numbers overlap and never sum to the total.\n */\n\nimport { z } from \"zod\";\nimport { calendarDaySchema, todayUtc, windowTooLong } from \"../calendarDays\";\nimport { targetAccountsSchema, targetsSummarySchema } from \"./targets\";\n\nexport const INFLUENCE_MODEL_KINDS = [\"engagement\", \"awareness\", \"intent\"] as const;\nexport type InfluenceModelKind = (typeof INFLUENCE_MODEL_KINDS)[number];\n\nexport const INFLUENCE_METRICS = [\"impressions\", \"engagements\", \"clicks\"] as const;\nexport type InfluenceMetric = (typeof INFLUENCE_METRICS)[number];\n\nexport const DEFAULT_LOOKBACK_MONTHS = 12;\n\n/** `low` is a match read off a subdomain or a name: kept, but out of the headline until confirmed. */\nexport const MATCH_CONFIDENCES = [\"high\", \"low\"] as const;\n\n/** What a match was read off: a person's choice, the LinkedIn page the CRM holds, the website, or the name. */\nexport const MATCH_METHODS = [\"override\", \"linkedin_page\", \"domain\", \"name\"] as const;\nexport type MatchMethod = (typeof MATCH_METHODS)[number];\n\nconst MODEL_METRIC: Record<InfluenceModelKind, { metric: InfluenceMetric; threshold: number }> = {\n engagement: { metric: \"engagements\", threshold: 3 },\n awareness: { metric: \"impressions\", threshold: 7 },\n intent: { metric: \"clicks\", threshold: 3 },\n};\n\nexport interface InfluenceParams {\n metric: InfluenceMetric;\n threshold: number;\n lookbackMonths: number;\n}\n\n/** A rule read for one report only — the saved settings stay as they are. */\nexport interface InfluenceRuleOverride {\n model?: InfluenceModelKind;\n threshold?: number;\n}\n\n/**\n * What the store counts for a company's settings: which metric, how many, how\n * far back. An override's model brings its own default threshold unless the\n * override names one too; the lookback is always the saved one.\n */\nexport function influenceParams(\n settings: {\n model: { kind: InfluenceModelKind; threshold?: number };\n lookbackMonths?: number;\n },\n override: InfluenceRuleOverride = {},\n): InfluenceParams {\n const kind = override.model ?? settings.model.kind;\n const model = MODEL_METRIC[kind];\n const wholeAtLeastOne = (value: number | undefined): value is number =>\n value !== undefined && Number.isInteger(value) && value >= 1;\n const threshold = override.threshold ?? (override.model === undefined ? settings.model.threshold : undefined);\n return {\n metric: model.metric,\n threshold: wholeAtLeastOne(threshold) ? threshold : model.threshold,\n lookbackMonths: wholeAtLeastOne(settings.lookbackMonths) ? settings.lookbackMonths : DEFAULT_LOOKBACK_MONTHS,\n };\n}\n\nexport type WarmFlag = \"new\" | \"rising\";\n\n/**\n * Whether a company is warming, by one metric this period against the period\n * of the same length just before it: `new` when it did nothing before,\n * `rising` when it at least doubled.\n */\nexport function warmFlag(current: number, previous: number): WarmFlag | null {\n if (current <= 0) return null;\n if (previous <= 0) return \"new\";\n return current >= 2 * previous ? \"rising\" : null;\n}\n\n// --- Windows ---\n\n/** The months the nightly sync keeps. */\nexport const ACCOUNTS_MAX_MONTHS = 24;\n\nconst windowFields = {\n /** Calendar months including the current one. */\n lastMonths: z.number().int().min(1).max(ACCOUNTS_MAX_MONTHS).optional(),\n start: calendarDaySchema.optional(),\n end: calendarDaySchema.optional(),\n};\n\n/** A rule read for one report (`InfluenceRuleOverride`); the saved settings stay as they are. */\nconst ruleOverrideFields = {\n model: z.enum(INFLUENCE_MODEL_KINDS).optional(),\n threshold: z.number().int().min(1).optional(),\n};\n\n/** Only these companies (`targets.ts`): the rows and numbers narrow to them, and `targets` says how far the ads got. */\nconst targetsField = { targets: targetAccountsSchema.optional() };\n\n/** How far the ads got with the targets the read named; absent without targets. */\nconst targetsSummaryField = { targets: targetsSummarySchema.optional() };\n\nfunction windowRules(req: { lastMonths?: number; start?: string; end?: string }, ctx: z.RefinementCtx): void {\n if (req.start !== undefined && req.lastMonths !== undefined) {\n ctx.addIssue({ code: \"custom\", path: [\"lastMonths\"], message: \"pass lastMonths or start/end, not both\" });\n }\n if (req.end !== undefined && req.start === undefined) {\n ctx.addIssue({ code: \"custom\", path: [\"end\"], message: \"end needs a start\" });\n }\n if (req.start !== undefined && req.end !== undefined && req.end < req.start) {\n ctx.addIssue({ code: \"custom\", path: [\"end\"], message: \"end is before start\" });\n return;\n }\n const tooLong = req.start === undefined ? null : windowTooLong(req.start, req.end ?? todayUtc(), ACCOUNTS_MAX_MONTHS);\n if (tooLong !== null) ctx.addIssue({ code: \"custom\", path: [\"start\"], message: tooLong });\n}\n\nexport const accountsWindowSchema = z.object({ start: z.string(), end: z.string() });\nexport type AccountsWindow = z.infer<typeof accountsWindowSchema>;\n\n/**\n * The inclusive days a request reads. `lastMonths` counts calendar months\n * including the current one, because the store holds whole months.\n */\nexport function accountsWindow(\n req: { lastMonths?: number; start?: string; end?: string },\n today: string,\n defaultMonths: number,\n): AccountsWindow {\n if (req.start !== undefined) return { start: req.start, end: req.end ?? today };\n const months = req.lastMonths ?? defaultMonths;\n const [year, month] = today.split(\"-\").map(Number);\n const first = new Date(Date.UTC(year ?? 1970, (month ?? 1) - 1 - (months - 1), 1));\n return { start: first.toISOString().slice(0, 10), end: today };\n}\n\nfunction monthIndex(day: string): number {\n const [year, month] = day.split(\"-\").map(Number);\n return (year ?? 1970) * 12 + ((month ?? 1) - 1);\n}\n\nfunction monthStart(index: number): Date {\n return new Date(Date.UTC(Math.floor(index / 12), index % 12, 1));\n}\n\n/**\n * The period New and Rising compare against: as many whole calendar months as\n * the window touches, ending the month before it starts. Whole months, because\n * that is the grain the store keeps.\n */\nexport function previousWindow(window: AccountsWindow): AccountsWindow {\n const first = monthIndex(window.start);\n const months = monthIndex(window.end) - first + 1;\n const lastDay = new Date(monthStart(first).getTime() - 24 * 60 * 60 * 1000);\n return {\n start: monthStart(first - months)\n .toISOString()\n .slice(0, 10),\n end: lastDay.toISOString().slice(0, 10),\n };\n}\n\nconst influenceParamsSchema = z.object({\n metric: z.enum(INFLUENCE_METRICS),\n threshold: z.number(),\n lookbackMonths: z.number(),\n});\n\n// --- Companies reached ---\n\nexport const ACCOUNTS_ENGAGEMENT_DEFAULT_LIMIT = 500;\nexport const ACCOUNTS_ENGAGEMENT_MAX_LIMIT = 5000;\n\nexport const accountEngagementRowSchema = z.object({\n /** LinkedIn organization id; `urn:li:organization:<orgId>` on LinkedIn. */\n orgId: z.string(),\n /** Empty until the nightly sync has looked the company up. */\n name: z.string(),\n domain: z.string(),\n impressions: z.number(),\n clicks: z.number(),\n engagements: z.number(),\n videoViews: z.number(),\n /** LinkedIn does not always report spend per company; 0 then. */\n costLocal: z.number(),\n currency: z.string(),\n /** Months in the window the company saw or did anything. */\n monthsActive: z.number(),\n lastMonth: z.string().nullable(),\n /** The same-length period just before the window. */\n previous: z.object({ impressions: z.number(), clicks: z.number(), engagements: z.number() }),\n /** By engagements against the previous period. */\n flag: z.enum([\"new\", \"rising\"]).nullable(),\n crmCompanyId: z.string().nullable(),\n /** The matched CRM company's name; null without a match. Optional for older servers. */\n crmCompanyName: z.string().nullable().optional(),\n /** The matched CRM company's own website; null when it has none. Optional for older servers. */\n crmCompanyDomain: z.string().nullable().optional(),\n /** What the match was read off; null without a match. Optional for older servers. */\n matchMethod: z.enum(MATCH_METHODS).nullable().optional(),\n matchConfidence: z.enum(MATCH_CONFIDENCES).nullable(),\n hasOpenDeal: z.boolean(),\n hasWonDeal: z.boolean(),\n hasLostDeal: z.boolean(),\n /** When the company's most recent lost deal closed (created, when it has no close date), ISO; null without one. */\n lastLostAt: z.string().nullable(),\n /**\n * People whose work email named the company's domain on the website or the\n * API in the period, and how many became leads — the touches beside the ads.\n * Null when none did; absent from older servers.\n */\n website: z.object({ people: z.number(), leads: z.number() }).nullable().optional(),\n /**\n * Visits from the company's own network in the period (`baker analytics\n * companies`): visits, distinct pages read, and when it was last seen.\n * Matched by normalised name (`companyNameKey`) against the LinkedIn name or\n * the CRM match's name — the network gives no website to match on. Null when\n * none matched; absent from older servers.\n */\n visitorCompany: z.object({ visits: z.number(), pages: z.number(), lastSeen: z.string() }).nullable().optional(),\n});\nexport type AccountEngagementRow = z.infer<typeof accountEngagementRowSchema>;\n\n// --- Website people per company ---\n\n/**\n * One company domain's website people, by the work address they gave: how\n * many were seen in the window, how many of them handed a Form a step, and\n * when the first and last of them were seen. `domain` is registrable, as\n * `AccountEngagementRow.domain` is, so the two join on equality. Shown beside\n * LinkedIn engagement, never folded into influence.\n */\nexport const accountWebsiteRowSchema = z.object({\n domain: z.string(),\n people: z.number(),\n leads: z.number(),\n /** ISO. */\n firstSeen: z.string(),\n /** ISO. */\n lastSeen: z.string(),\n});\nexport type AccountWebsiteRow = z.infer<typeof accountWebsiteRowSchema>;\n\nexport const ACCOUNT_DEAL_STATUSES = [\"won\", \"open\", \"lost\", \"none\"] as const;\nexport type AccountDealStatus = (typeof ACCOUNT_DEAL_STATUSES)[number];\n\n/**\n * Where a company stands in the CRM, strongest fact first: a won deal outranks\n * an open one, an open one a lost one; `lost` means every deal it had was lost.\n */\nexport function accountDealStatus(row: {\n hasWonDeal: boolean;\n hasOpenDeal: boolean;\n hasLostDeal: boolean;\n}): AccountDealStatus {\n if (row.hasWonDeal) return \"won\";\n if (row.hasOpenDeal) return \"open\";\n if (row.hasLostDeal) return \"lost\";\n return \"none\";\n}\n\n/** A lost deal stops a company being warm for this many calendar months after it closed. */\nexport const LOST_DEAL_COOLDOWN_MONTHS = 6;\n\n/** `day` minus whole calendar months, clamped to the month's last day: 2026-08-31 − 6 → 2026-02-28. */\nfunction monthsBefore(day: string, months: number): string {\n const [year, month, date] = day.split(\"-\").map(Number);\n const index = (year ?? 1970) * 12 + ((month ?? 1) - 1) - months;\n const lastDate = new Date(Date.UTC(Math.floor(index / 12), (index % 12) + 1, 0)).getUTCDate();\n return new Date(Date.UTC(Math.floor(index / 12), index % 12, Math.min(date ?? 1, lastDate)))\n .toISOString()\n .slice(0, 10);\n}\n\nexport interface WarmAccountsOptions {\n /** Leave out a company below this on one metric in the period — e.g. the influence rule's threshold. */\n minimum?: { metric: InfluenceMetric; value: number };\n}\n\n/**\n * Warm accounts: engaging more than before, and not already somebody's deal —\n * no open deal, never won (a customer is not a prospect), and no deal lost in\n * the last six months. A loss older than that no longer counts, the same rule\n * Fibbler uses, so a company can warm up again. `today` is `YYYY-MM-DD`.\n * Without a `minimum`, one engagement after none already reads as New.\n */\nexport function warmAccounts(\n rows: readonly AccountEngagementRow[],\n today: string,\n options: WarmAccountsOptions = {},\n): AccountEngagementRow[] {\n const cooldownStart = monthsBefore(today, LOST_DEAL_COOLDOWN_MONTHS);\n const { minimum } = options;\n return rows.filter(\n (row) =>\n row.flag !== null &&\n (minimum === undefined || row[minimum.metric] >= minimum.value) &&\n !row.hasOpenDeal &&\n !row.hasWonDeal &&\n !(row.lastLostAt !== null && row.lastLostAt.slice(0, 10) >= cooldownStart),\n );\n}\n\nexport const accountsEngagementRequestSchema = z\n .object({\n ...windowFields,\n /** One campaign's companies; every campaign together when absent. */\n campaignId: z.string().regex(/^\\d+$/, \"use the numeric campaign id\").optional(),\n /** Companies per page. */\n limit: z.number().int().min(1).max(ACCOUNTS_ENGAGEMENT_MAX_LIMIT).default(ACCOUNTS_ENGAGEMENT_DEFAULT_LIMIT),\n /** Which page, 1-based, most engaged first. */\n page: z.number().int().min(1).default(1),\n ...targetsField,\n })\n .superRefine(windowRules);\nexport type AccountsEngagementRequest = z.input<typeof accountsEngagementRequestSchema>;\n\nexport const accountsEngagementResponseSchema = z.object({\n ok: z.literal(true),\n data: z.object({\n window: accountsWindowSchema,\n previousWindow: accountsWindowSchema,\n companies: z.array(accountEngagementRowSchema),\n /** True when more companies were reached than this page and the ones before it hold. */\n truncated: z.boolean(),\n /** Which page this is, and how many companies there are in all. Absent from older servers. */\n pageInfo: z.object({ page: z.number(), pageSize: z.number(), total: z.number(), hasMore: z.boolean() }).optional(),\n /** The company's influence rule (the default one before setup): the minimum `baker accounts warm` applies. */\n rule: influenceParamsSchema.optional(),\n ...targetsSummaryField,\n }),\n});\nexport type AccountsEngagementResponse = z.infer<typeof accountsEngagementResponseSchema>;\n\n// --- Influenced deals ---\n\nexport const INFLUENCE_BASES = [\"pipeline\", \"revenue\"] as const;\nexport type InfluenceBasis = (typeof INFLUENCE_BASES)[number];\n\nexport const accountDealRowSchema = z.object({\n dealId: z.string(),\n dealName: z.string(),\n crmCompanyId: z.string(),\n companyName: z.string(),\n domain: z.string(),\n /** Null when the deal has no amount — unknown, not zero. */\n amount: z.number().nullable(),\n currency: z.string(),\n /** Created (pipeline) or closed won (revenue), ISO. The date the lookback counts back from. */\n referenceAt: z.string(),\n /** By the won and lost stages chosen in the settings. */\n status: z.enum([\"open\", \"won\", \"lost\"]),\n /** The model's metric, summed over the company's lookback months. */\n touchValue: z.number(),\n /** The first month inside the lookback the company was reached, `YYYY-MM-01`. */\n firstTouchMonth: z.string().nullable(),\n /** How surely the CRM company is the LinkedIn one; null when no LinkedIn company matched. */\n matchConfidence: z.enum(MATCH_CONFIDENCES).nullable(),\n /** The company crossed the threshold — whatever the match confidence. */\n influenced: z.boolean(),\n});\nexport type AccountDealRow = z.infer<typeof accountDealRowSchema>;\n\n/** An amount per currency. Amounts in different currencies are never added together. */\nexport type MoneyByCurrency = Record<string, number>;\n\nexport const moneyByCurrencySchema = z.record(z.string(), z.number());\n\nexport const influenceSummarySchema = z.object({\n /** Every deal in the window for this basis. */\n deals: z.number(),\n /** Influenced, confirmed matches only — the headline. */\n influencedDeals: z.number(),\n influencedValue: moneyByCurrencySchema,\n /** Influenced deals with no amount entered: counted, not valued. */\n dealsWithoutAmount: z.number(),\n /** Influenced through a match nobody confirmed yet; not in the headline. */\n lowConfidenceDeals: z.number(),\n lowConfidenceValue: moneyByCurrencySchema,\n /** LinkedIn spend on the companies reached in the window, per currency. */\n spend: moneyByCurrencySchema,\n /** Influenced value per 1 of spend — only when both are in the same single currency. */\n valuePerSpend: z.object({ currency: z.string(), value: z.number() }).nullable(),\n});\nexport type InfluenceSummary = z.infer<typeof influenceSummarySchema>;\n\nfunction addMoney(into: MoneyByCurrency, currency: string, amount: number): void {\n const key = currency.trim().toUpperCase() || \"UNKNOWN\";\n into[key] = (into[key] ?? 0) + amount;\n}\n\n/** The headline numbers over one basis's deals. */\nexport function influenceSummary(deals: readonly AccountDealRow[], spend: MoneyByCurrency): InfluenceSummary {\n const influencedValue: MoneyByCurrency = {};\n const lowConfidenceValue: MoneyByCurrency = {};\n let influencedDeals = 0;\n let lowConfidenceDeals = 0;\n let dealsWithoutAmount = 0;\n for (const row of deals) {\n if (!row.influenced || row.matchConfidence === null) continue;\n if (row.matchConfidence === \"low\") {\n lowConfidenceDeals += 1;\n if (row.amount !== null) addMoney(lowConfidenceValue, row.currency, row.amount);\n continue;\n }\n influencedDeals += 1;\n if (row.amount === null) dealsWithoutAmount += 1;\n else addMoney(influencedValue, row.currency, row.amount);\n }\n return {\n deals: deals.length,\n influencedDeals,\n influencedValue,\n dealsWithoutAmount,\n lowConfidenceDeals,\n lowConfidenceValue,\n spend,\n valuePerSpend: valuePerSpend(influencedValue, spend),\n };\n}\n\nfunction valuePerSpend(value: MoneyByCurrency, spend: MoneyByCurrency): InfluenceSummary[\"valuePerSpend\"] {\n const valueCurrencies = Object.keys(value);\n const spendCurrencies = Object.keys(spend).filter((currency) => (spend[currency] ?? 0) > 0);\n const [currency] = valueCurrencies;\n if (currency === undefined || valueCurrencies.length !== 1 || spendCurrencies.length !== 1) return null;\n const spent = spend[spendCurrencies[0] ?? \"\"];\n if (spendCurrencies[0]?.toUpperCase() !== currency || spent === undefined) return null;\n return { currency, value: Math.round(((value[currency] ?? 0) / spent) * 100) / 100 };\n}\n\nexport const ACCOUNTS_INFLUENCED_DEFAULT_MONTHS = 12;\n\nexport const accountsInfluencedRequestSchema = z\n .object({\n ...windowFields,\n /** `pipeline`: deals created in the window and not won. `revenue`: deals closed won in the window. */\n basis: z.enum(INFLUENCE_BASES).default(\"pipeline\"),\n /** Every deal in the window, influenced or not; compact returns the influenced ones. */\n full: z.boolean().default(false),\n ...ruleOverrideFields,\n ...targetsField,\n })\n .superRefine(windowRules);\nexport type AccountsInfluencedRequest = z.input<typeof accountsInfluencedRequestSchema>;\n\nexport const accountsInfluencedResponseSchema = z.object({\n ok: z.literal(true),\n data: z.object({\n window: accountsWindowSchema,\n basis: z.enum(INFLUENCE_BASES),\n rule: influenceParamsSchema,\n summary: influenceSummarySchema,\n /** Influenced deals on confirmed matches; with `full`, every deal in the window. */\n deals: z.array(accountDealRowSchema),\n /** Influenced through a match nobody confirmed yet. Not in `summary`'s headline. */\n lowConfidence: z.array(accountDealRowSchema),\n /** True when the window held more deals than one read returns. */\n truncated: z.boolean(),\n ...targetsSummaryField,\n }),\n});\nexport type AccountsInfluencedResponse = z.infer<typeof accountsInfluencedResponseSchema>;\n\n// --- One company's timeline ---\n\nexport const accountsCompanyRequestSchema = z\n .object({\n /** LinkedIn organization id, or its `urn:li:organization:` URN. */\n orgId: z\n .string()\n .transform((value) => value.replace(/^urn:li:organization:/, \"\"))\n .pipe(z.string().regex(/^\\d+$/, \"use the LinkedIn company id or its urn:li:organization URN\"))\n .optional(),\n /** The company's website domain, `acme.com`. */\n domain: z\n .string()\n .min(3)\n .max(253)\n .transform((value) =>\n value\n .trim()\n .toLowerCase()\n .replace(/^https?:\\/\\//, \"\")\n .replace(/^www\\./, \"\")\n .replace(/\\/.*$/, \"\"),\n )\n .optional(),\n })\n .refine((req) => (req.orgId === undefined) !== (req.domain === undefined), {\n message: \"Give a LinkedIn company id or a domain, one of the two.\",\n });\nexport type AccountsCompanyRequest = z.input<typeof accountsCompanyRequestSchema>;\n\nexport const accountCompanyMonthSchema = z.object({\n orgId: z.string(),\n /** Empty for the whole ad account; a campaign id otherwise. */\n campaignId: z.string(),\n /** LinkedIn's name for the campaign; null for the account-wide row, or when LinkedIn could not be asked. */\n campaignName: z.string().nullable(),\n month: z.string(),\n impressions: z.number(),\n clicks: z.number(),\n engagements: z.number(),\n});\nexport type AccountCompanyMonth = z.infer<typeof accountCompanyMonthSchema>;\n\nexport const accountCompanyDealSchema = z.object({\n dealId: z.string(),\n dealName: z.string(),\n amount: z.number().nullable(),\n currency: z.string(),\n status: z.enum([\"open\", \"won\", \"lost\"]),\n createdAt: z.string(),\n closedAt: z.string().nullable(),\n /**\n * The rule's metric over the lookback ending with the deal's reference month\n * (created; closed for a won deal), from the pages in `orgs`. Absent before\n * setup or when the company matched no CRM company.\n */\n touchValue: z.number().optional(),\n /** `touchValue` reached the rule's threshold. */\n influenced: z.boolean().optional(),\n});\nexport type AccountCompanyDeal = z.infer<typeof accountCompanyDealSchema>;\n\nexport const accountCompanyOrgSchema = z.object({\n orgId: z.string(),\n name: z.string(),\n domain: z.string(),\n crmCompanyId: z.string().nullable(),\n matchConfidence: z.enum(MATCH_CONFIDENCES).nullable(),\n});\nexport type AccountCompanyOrg = z.infer<typeof accountCompanyOrgSchema>;\n\nexport const accountsCompanyResponseSchema = z.object({\n ok: z.literal(true),\n data: z.object({\n /** Usually one; a domain can name several LinkedIn pages of the same company. */\n orgs: z.array(accountCompanyOrgSchema),\n /** Month by month, per campaign (and the account-wide row, `campaignId: \"\"`), oldest first. */\n months: z.array(accountCompanyMonthSchema),\n /** Deals of the matched CRM company, oldest first. */\n deals: z.array(accountCompanyDealSchema),\n /** The rule `influenced` and `touchValue` on each deal were read with; absent before setup. */\n rule: influenceParamsSchema.optional(),\n }),\n});\nexport type AccountsCompanyResponse = z.infer<typeof accountsCompanyResponseSchema>;\n\n// --- Campaigns ---\n\nexport const accountsCampaignsRequestSchema = z\n .object({\n ...windowFields,\n ...ruleOverrideFields,\n basis: z.enum(INFLUENCE_BASES).default(\"pipeline\"),\n ...targetsField,\n })\n .superRefine(windowRules);\nexport type AccountsCampaignsRequest = z.input<typeof accountsCampaignsRequestSchema>;\n\nexport const accountCampaignRowSchema = z.object({\n campaignId: z.string(),\n /** LinkedIn's name for the campaign; null when LinkedIn could not be asked or no longer lists it. */\n campaignName: z.string().nullable(),\n /** Companies that saw at least one impression in the window. */\n companiesReached: z.number(),\n /** Companies with at least one engagement in the window. */\n companiesEngaged: z.number(),\n /** Influenced deals (of the read's basis) this campaign touched in their lookback. Overlaps other campaigns. */\n influencedDeals: z.number(),\n influencedValue: moneyByCurrencySchema,\n});\nexport type AccountCampaignRow = z.infer<typeof accountCampaignRowSchema>;\n\nexport const accountsCampaignsResponseSchema = z.object({\n ok: z.literal(true),\n data: z.object({\n window: accountsWindowSchema,\n /** Optional for older servers, which read pipeline only. */\n basis: z.enum(INFLUENCE_BASES).optional(),\n rule: influenceParamsSchema,\n campaigns: z.array(accountCampaignRowSchema),\n ...targetsSummaryField,\n }),\n});\nexport type AccountsCampaignsResponse = z.infer<typeof accountsCampaignsResponseSchema>;\n\n// --- Refusals the agent relays ---\n\n/** Deals cannot be counted until someone says where they are and what won and lost mean. */\nexport const ACCOUNTS_NO_SETTINGS_MESSAGE =\n \"Account insights are not set up yet: in Measure → Accounts, say where your deals are (HubSpot or another CRM) and what won and lost mean.\";\nexport * from \"./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AER,OAAO,EAAE,KAAK,eAAe,EAAE,SAAS;AAAA,IACxC,MAAM;AAAA,IACN,WAAW,EAAE,MAAM,wBAAwB;AAAA,IAC3C,GAAG;AAAA,EACL,CAAC;AACH,CAAC;AAMM,IAAM,+BACX;","names":[]}
package/dist/cli.js CHANGED
@@ -478,7 +478,7 @@ Introspection: Run 'baker schema <command>' to inspect argument schemas.`
478
478
  images: () => import("./images-Q5MZ75SL.js").then((m) => m.imagesCommand),
479
479
  studio: () => import("./studio-6ZXUKA4G.js").then((m) => m.studioCommand),
480
480
  avatars: () => import("./avatars-HH4LOUA3.js").then((m) => m.avatarsCommand),
481
- landing: () => import("./landing-ZHDHE65Z.js").then((m) => m.landingCommand),
481
+ landing: () => import("./landing-EAEMVCED.js").then((m) => m.landingCommand),
482
482
  videos: () => import("./videos-HMKEY5WY.js").then((m) => m.videosCommand),
483
483
  testimonials: () => import("./testimonials-P63TKNJ2.js").then((m) => m.testimonialsCommand),
484
484
  canvas: () => import("./canvas-E4ZT2K7I.js").then((m) => m.canvasCommand),
@@ -489,7 +489,7 @@ Introspection: Run 'baker schema <command>' to inspect argument schemas.`
489
489
  credentials: () => import("./credentials-YQND7EIL.js").then((m) => m.credentialsCommand),
490
490
  hubspot: () => import("./hubspot-WGP36QI3.js").then((m) => m.hubspotCommand),
491
491
  activecampaign: () => import("./activecampaign-LQHDIHN5.js").then((m) => m.activecampaignCommand),
492
- accounts: () => import("./accounts-PU2GGSH4.js").then((m) => m.accountsCommand),
492
+ accounts: () => import("./accounts-PLZTPM52.js").then((m) => m.accountsCommand),
493
493
  shopify: () => import("./shopify-PKWH7WXV.js").then((m) => m.shopifyCommand),
494
494
  "winning-ads": () => import("./winning-ads-74BKOBVN.js").then((m) => m.winningAdsCommand),
495
495
  "media-sources": () => import("./media-sources-ZBSBTB4C.js").then((m) => m.mediaSourcesCommand),
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  crmColumnMeanings,
3
3
  crmColumnQuestions
4
- } from "./chunk-UZ4L5ERW.js";
4
+ } from "./chunk-TBIDT7FG.js";
5
5
  import {
6
6
  crmBatchFromSheet,
7
7
  crmColumnReading,
@@ -320,4 +320,4 @@ export {
320
320
  sheetFailureFix,
321
321
  statusHints
322
322
  };
323
- //# sourceMappingURL=crm-CD7QLN65.js.map
323
+ //# sourceMappingURL=crm-4GXVHO4R.js.map
@@ -12,7 +12,7 @@ Start here: \`baker landing inspiration search "<what you want to see>"\` during
12
12
  This is inspiration, never a clipboard. Take the mechanism \u2014 what the eye hits first, what proof arrives before the ask, how the grid is split. The words are never yours to reuse: shipping a reference's headline is a Tier 0 message-match failure.
13
13
 
14
14
  Subcommands:
15
- baker landing inspiration search "<query>" \u2014 search by look, section type, composition, register or motion; saves screenshots you can Read
15
+ baker landing inspiration search "<query>" \u2014 search by look, section type, composition, register or motion; saves screenshots to look at through visual-check
16
16
  baker landing inspiration view <id> \u2014 one section in full: tokens, motion filmstrip, why it works, what to change
17
17
  baker landing inspiration code <id> \u2014 its standalone HTML+CSS, for structure only
18
18
  baker landing inspiration page <id> \u2014 a whole page as a sequence: how it orders its sections
@@ -34,8 +34,8 @@ Examples:
34
34
  Full guide: __tooling__/docs/tools/baker/landing.md`
35
35
  },
36
36
  subCommands: {
37
- search: () => import("./search-BR5KK7BE.js").then((m) => m.searchCommand),
38
- view: () => import("./view-VFZUL5UL.js").then((m) => m.viewCommand),
37
+ search: () => import("./search-37JQZPX3.js").then((m) => m.searchCommand),
38
+ view: () => import("./view-OZLXM7R6.js").then((m) => m.viewCommand),
39
39
  code: () => import("./code-TIM5S232.js").then((m) => m.codeCommand),
40
40
  page: () => import("./page-3Q5ZCRPX.js").then((m) => m.pageCommand),
41
41
  sequences: () => import("./sequences-RRUXKL7H.js").then((m) => m.sequencesCommand),
@@ -44,10 +44,10 @@ Full guide: __tooling__/docs/tools/baker/landing.md`
44
44
  favorite: () => import("./favorites-6GAGZDIR.js").then((m) => m.favoriteCommand),
45
45
  unfavorite: () => import("./favorites-6GAGZDIR.js").then((m) => m.unfavoriteCommand),
46
46
  "retry-failed": () => import("./retry-failed-NH47LEKA.js").then((m) => m.retryFailedCommand),
47
- scrape: () => import("./scrape-3PWNMK4D.js").then((m) => m.scrapeCommand)
47
+ scrape: () => import("./scrape-U6DIREQ2.js").then((m) => m.scrapeCommand)
48
48
  }
49
49
  });
50
50
  export {
51
51
  inspirationCommand
52
52
  };
53
- //# sourceMappingURL=inspiration-CSN3AXDD.js.map
53
+ //# sourceMappingURL=inspiration-573KZNQA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/landing/inspiration/index.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\n\nexport const inspirationCommand = defineCommand({\n meta: {\n name: \"inspiration\",\n description: `Reference library of real landing-page sections — look at how good pages actually solve a problem before you design one.\n\nStart here: \\`baker landing inspiration search \"<what you want to see>\"\\` during research, BEFORE you write the Direction Contract.\n\nThis is inspiration, never a clipboard. Take the mechanism — what the eye hits first, what proof arrives before the ask, how the grid is split. The words are never yours to reuse: shipping a reference's headline is a Tier 0 message-match failure.\n\nSubcommands:\n baker landing inspiration search \"<query>\" — search by look, section type, composition, register or motion; saves screenshots to look at through visual-check\n baker landing inspiration view <id> — one section in full: tokens, motion filmstrip, why it works, what to change\n baker landing inspiration code <id> — its standalone HTML+CSS, for structure only\n baker landing inspiration page <id> — a whole page as a sequence: how it orders its sections\n baker landing inspiration sequences \"<q>\" — what follows what across MANY pages: openers, transitions, closers\n baker landing inspiration add <url> — add a page to the library and save it to this company (returns immediately); --refresh re-studies a page that changed\n baker landing inspiration favorites — what this company has saved; the default search scope\n baker landing inspiration favorite <id> — save a section\n baker landing inspiration unfavorite <id> — unsave a section\n baker landing inspiration retry-failed — study again every saved page that failed\n baker landing inspiration scrape <url> — internal/ops: run the capture locally\n\nExamples:\n baker landing inspiration search \"pricing with a monthly/annual toggle\" --max-rank 3\n baker landing inspiration search \"dark developer hero with a terminal\" --register dev-tool-minimal --scope all\n baker landing inspiration search \"testimonial wall with faces and company logos\" --motion scroll-reveal\n baker landing inspiration sequences \"b2b saas pricing page\" --scope all\n baker landing inspiration add https://linear.app\n\nFull guide: __tooling__/docs/tools/baker/landing.md`,\n },\n subCommands: {\n search: () => import(\"./search.ts\").then((m) => m.searchCommand),\n view: () => import(\"./view.ts\").then((m) => m.viewCommand),\n code: () => import(\"./code.ts\").then((m) => m.codeCommand),\n page: () => import(\"./page.ts\").then((m) => m.pageCommand),\n sequences: () => import(\"./sequences.ts\").then((m) => m.sequencesCommand),\n add: () => import(\"./add.ts\").then((m) => m.addCommand),\n favorites: () => import(\"./favorites.ts\").then((m) => m.favoritesCommand),\n favorite: () => import(\"./favorites.ts\").then((m) => m.favoriteCommand),\n unfavorite: () => import(\"./favorites.ts\").then((m) => m.unfavoriteCommand),\n \"retry-failed\": () => import(\"./retry-failed.ts\").then((m) => m.retryFailedCommand),\n scrape: () => import(\"./scrape.ts\").then((m) => m.scrapeCommand),\n },\n});\n"],"mappings":";;;AAAA,SAAS,qBAAqB;AAEvB,IAAM,qBAAqB,cAAc;AAAA,EAC9C,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA2Bf;AAAA,EACA,aAAa;AAAA,IACX,QAAQ,MAAM,OAAO,sBAAa,EAAE,KAAK,CAAC,MAAM,EAAE,aAAa;AAAA,IAC/D,MAAM,MAAM,OAAO,oBAAW,EAAE,KAAK,CAAC,MAAM,EAAE,WAAW;AAAA,IACzD,MAAM,MAAM,OAAO,oBAAW,EAAE,KAAK,CAAC,MAAM,EAAE,WAAW;AAAA,IACzD,MAAM,MAAM,OAAO,oBAAW,EAAE,KAAK,CAAC,MAAM,EAAE,WAAW;AAAA,IACzD,WAAW,MAAM,OAAO,yBAAgB,EAAE,KAAK,CAAC,MAAM,EAAE,gBAAgB;AAAA,IACxE,KAAK,MAAM,OAAO,mBAAU,EAAE,KAAK,CAAC,MAAM,EAAE,UAAU;AAAA,IACtD,WAAW,MAAM,OAAO,yBAAgB,EAAE,KAAK,CAAC,MAAM,EAAE,gBAAgB;AAAA,IACxE,UAAU,MAAM,OAAO,yBAAgB,EAAE,KAAK,CAAC,MAAM,EAAE,eAAe;AAAA,IACtE,YAAY,MAAM,OAAO,yBAAgB,EAAE,KAAK,CAAC,MAAM,EAAE,iBAAiB;AAAA,IAC1E,gBAAgB,MAAM,OAAO,4BAAmB,EAAE,KAAK,CAAC,MAAM,EAAE,kBAAkB;AAAA,IAClF,QAAQ,MAAM,OAAO,sBAAa,EAAE,KAAK,CAAC,MAAM,EAAE,aAAa;AAAA,EACjE;AACF,CAAC;","names":[]}
@@ -16,7 +16,7 @@ Subcommands:
16
16
  baker landing export start \u2014 download the PUBLISHED landings as a ZIP of plain HTML ("download my landings", "send me the HTML"); \`baker landing export status <id>\` gives the link.`
17
17
  },
18
18
  subCommands: {
19
- inspiration: () => import("./inspiration-CSN3AXDD.js").then((m) => m.inspirationCommand),
19
+ inspiration: () => import("./inspiration-573KZNQA.js").then((m) => m.inspirationCommand),
20
20
  critique: () => import("./critique-EBQKUWBV.js").then((m) => m.critiqueCommand),
21
21
  variant: () => import("./variant-QNNTZPLR.js").then((m) => m.variantCommand),
22
22
  export: () => import("./export-QB7WA36R.js").then((m) => m.exportCommand)
@@ -25,4 +25,4 @@ Subcommands:
25
25
  export {
26
26
  landingCommand
27
27
  };
28
- //# sourceMappingURL=landing-ZHDHE65Z.js.map
28
+ //# sourceMappingURL=landing-EAEMVCED.js.map
@@ -2102,7 +2102,7 @@ function captureHints(args) {
2102
2102
  );
2103
2103
  } else {
2104
2104
  hints.push(
2105
- report ? `Read ${outDir}/report.html \u2014 every section side by side${anyScored ? " with its fidelity score" : ""}.` : `Read the section screenshots in ${outDir}/sections/*/desktop.png before you design.`,
2105
+ report ? `Look at ${outDir}/report.html \u2014 every section side by side${anyScored ? " with its fidelity score" : ""} \u2014 and the section screenshots through the visual-check subagent (the paths and what you need to learn), not by Reading them yourself: every image you Read is re-sent on every later request.` : `Look at the section screenshots in ${outDir}/sections/*/desktop.png through the visual-check subagent (the paths and what you need to learn) before you design, not by Reading them yourself: every image you Read is re-sent on every later request.`,
2106
2106
  `${shots} of ${manifest.sections.length} sections captured to ${outDir}/sections/ \u2014 look at them, then decide which the client's page actually needs.`
2107
2107
  );
2108
2108
  }
@@ -2111,7 +2111,7 @@ function captureHints(args) {
2111
2111
  }
2112
2112
  registerSchema({
2113
2113
  command: "landing.inspiration.scrape",
2114
- description: "Start here when the user points at a specific page and wants it now: capture one landing page into a directory of section screenshots, standalone HTML bundles, a whole-page reproduction and motion filmstrips. Returns when the capture is done, unlike `add`. Read the screenshots.",
2114
+ description: "Start here when the user points at a specific page and wants it now: capture one landing page into a directory of section screenshots, standalone HTML bundles, a whole-page reproduction and motion filmstrips. Returns when the capture is done, unlike `add`. Look at the screenshots through the visual-check subagent (paths and your questions), not by Reading them yourself.",
2115
2115
  args: {
2116
2116
  url: { type: "string", description: "Page to capture", required: true },
2117
2117
  out: { type: "string", description: "Output directory under .baker/", required: true },
@@ -2238,4 +2238,4 @@ var scrapeCommand = defineCommand({
2238
2238
  export {
2239
2239
  scrapeCommand
2240
2240
  };
2241
- //# sourceMappingURL=scrape-3PWNMK4D.js.map
2241
+ //# sourceMappingURL=scrape-U6DIREQ2.js.map