@dench.com/cli 2.9.2-staging.203 → 2.9.3-staging.215

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -210,7 +210,9 @@ ids, launch it once the readiness check passes, and watch it. `<campaign>`
210
210
  is an id or an exact, case-insensitive name.
211
211
 
212
212
  ```bash
213
- dench campaign create --name "Founder outreach" --timezone America/Los_Angeles --window "Mon-Fri 9-18" --daily-cap 30
213
+ dench campaign accounts --json # email + LinkedIn sender ids, availability and capacity
214
+ dench campaign create --name "Founder outreach" --timezone America/Los_Angeles --window "Mon-Fri 9-18" --daily-cap 30 --email-mailboxes <mailboxId1>,<mailboxId2> --linkedin-accounts <linkedinId>
215
+ dench campaign set <campaign> --email-mailboxes <mailboxId> --linkedin-accounts none
214
216
  dench campaign steps set <campaign> --file steps.json
215
217
  dench campaign add <campaign> --object lead --view "Q3 targets"
216
218
  dench campaign launch <campaign> --ack-linkedin-risk
@@ -228,6 +230,22 @@ including the `steps.json` shape and the `--window` spec, is
228
230
  `references/CAMPAIGNS.md` (`dench campaign help` for the flag list).
229
231
  `dench email multichannel` drives the same campaigns with fewer controls.
230
232
 
233
+ Use `--email-mailboxes` / `--linkedin-accounts` for campaign sender pools
234
+ (up to 50 accessible accounts per channel). Accepts comma-separated ids or a
235
+ JSON array; omit a flag to preserve it, or pass `none` / `'[]'` to clear it.
236
+ API fields: `emailMailboxAccountIds` / `linkedinAccountIds`. Pool campaigns
237
+ omit per-step sender ids; legacy steps remain until conversion. Launch still
238
+ checks availability, and each conversation keeps its original sender.
239
+
240
+ `dench campaign accounts --json` discovers both mailboxes and LinkedIn
241
+ accounts, including unused senders. Only the acting member's private and
242
+ workspace-shared connections are listed; provider credentials are never
243
+ returned. LinkedIn summaries expose `linkedinAccountId`, display/owner labels,
244
+ availability, `remainingToday` (invites/messages/profiles) and
245
+ `remainingInvitesThisWeek`. Capacity is an account-local usage snapshot before
246
+ queued work and campaign limits; today's invites also respect the weekly cap.
247
+ The API equivalent is `GET /v1/campaigns/accounts/linkedin`.
248
+
231
249
  Outreach needs a workspace member's credentials (a `dench signin` session, a
232
250
  member-bound `DENCH_API_KEY`, or an agent session); an organization-only key
233
251
  is refused.
package/campaign.ts CHANGED
@@ -69,6 +69,8 @@ export type CampaignRow = {
69
69
  name: string;
70
70
  status: string;
71
71
  stopOnReply?: boolean;
72
+ emailMailboxAccountIds?: string[];
73
+ linkedinAccountIds?: string[];
72
74
  timezone?: string;
73
75
  startsAt?: number;
74
76
  endsAt?: number;
@@ -758,6 +760,54 @@ function whenOrder(when: WhenFlag): number {
758
760
 
759
761
  const END_BEFORE_START = "--end must be after --start.";
760
762
 
763
+ export type SenderPoolPatch = {
764
+ emailMailboxAccountIds?: string[];
765
+ linkedinAccountIds?: string[];
766
+ };
767
+
768
+ /** Omission preserves the current model; an explicit empty list clears a pool. */
769
+ export function consumeSenderPoolFlags(args: string[]): SenderPoolPatch {
770
+ const patch: SenderPoolPatch = {};
771
+ for (const [flag, key] of [
772
+ ["--email-mailboxes", "emailMailboxAccountIds"],
773
+ ["--linkedin-accounts", "linkedinAccountIds"],
774
+ ] as const) {
775
+ const value = valueFlag(args, flag);
776
+ if (value === undefined) continue;
777
+ const raw = value.trim();
778
+ let ids: unknown;
779
+ if (raw.toLowerCase() === "none") {
780
+ ids = [];
781
+ } else if (raw.startsWith("[")) {
782
+ try {
783
+ ids = JSON.parse(raw);
784
+ } catch {
785
+ throw new CampaignCliError(
786
+ `${flag} must be a valid JSON array of account ids.`,
787
+ );
788
+ }
789
+ } else {
790
+ ids = raw.split(",");
791
+ }
792
+ if (
793
+ !Array.isArray(ids) ||
794
+ ids.some((id) => typeof id !== "string" || !id.trim())
795
+ ) {
796
+ throw new CampaignCliError(
797
+ `${flag} needs comma-separated account ids or a JSON string array. Use [] or none to clear the pool.`,
798
+ );
799
+ }
800
+ const unique = [...new Set((ids as string[]).map((id) => id.trim()))];
801
+ // Mirrors normalizeSenderPool on the backend; validate before any RPC.
802
+ if (unique.length > 50)
803
+ throw new CampaignCliError(
804
+ `${flag} accepts at most 50 senders per channel.`,
805
+ );
806
+ patch[key] = unique;
807
+ }
808
+ return patch;
809
+ }
810
+
761
811
  /**
762
812
  * Drain the schedule flags shared by `create` and `set`:
763
813
  * `--timezone`, `--daily-cap`, `--stop-on-reply|--no-stop-on-reply`,
@@ -1183,6 +1233,7 @@ async function runList(ctx: CampaignCliContext): Promise<void> {
1183
1233
  async function runCreate(ctx: CampaignCliContext): Promise<void> {
1184
1234
  const name = requiredFlag(ctx.args, "--name");
1185
1235
  const flags = consumeScheduleFlags(ctx.args);
1236
+ const senderPools = consumeSenderPoolFlags(ctx.args);
1186
1237
  unknownFlags(ctx.args, "campaign create");
1187
1238
  const timezone = flags.timezone ?? localTimezone();
1188
1239
  // Every flag is parsed before the first write, so a bad --window cannot
@@ -1194,6 +1245,7 @@ async function runCreate(ctx: CampaignCliContext): Promise<void> {
1194
1245
  const created = (await callMutation(ctx, `${OUTREACH}:createSequence`, {
1195
1246
  name,
1196
1247
  timezone,
1248
+ ...senderPools,
1197
1249
  })) as { sequenceId: string };
1198
1250
  if (hasScheduleChanges(patch)) {
1199
1251
  await callMutation(ctx, `${OUTREACH}:updateDraft`, {
@@ -1206,6 +1258,7 @@ async function runCreate(ctx: CampaignCliContext): Promise<void> {
1206
1258
  sequenceId: created.sequenceId,
1207
1259
  name,
1208
1260
  status: "draft",
1261
+ ...senderPools,
1209
1262
  timezone,
1210
1263
  sendSchedules: schedules,
1211
1264
  ...(patch.dailySendCap !== undefined
@@ -1363,17 +1416,21 @@ async function runSet(ctx: CampaignCliContext): Promise<void> {
1363
1416
  throw new CampaignCliError("--name needs the new campaign name");
1364
1417
  }
1365
1418
  const flags = consumeScheduleFlags(ctx.args);
1419
+ const senderPools = consumeSenderPoolFlags(ctx.args);
1366
1420
  const reference = shift(ctx.args, "campaign id or name");
1367
1421
  unknownFlags(ctx.args, "campaign set");
1368
1422
  const row = await resolveCampaign(ctx, reference);
1369
- const patch = schedulePatchFromFlags(flags, {
1370
- fallbackTimezone:
1371
- row.timezone ?? row.sendSchedules?.[0]?.timezone ?? localTimezone(),
1372
- existingSchedules: row.sendSchedules,
1373
- });
1423
+ const patch = {
1424
+ ...schedulePatchFromFlags(flags, {
1425
+ fallbackTimezone:
1426
+ row.timezone ?? row.sendSchedules?.[0]?.timezone ?? localTimezone(),
1427
+ existingSchedules: row.sendSchedules,
1428
+ }),
1429
+ ...senderPools,
1430
+ };
1374
1431
  if (name === undefined && !hasScheduleChanges(patch)) {
1375
1432
  throw new CampaignCliError(
1376
- "Nothing to change. Pass at least one of --name, --timezone, --window, --daily-cap, --stop-on-reply/--no-stop-on-reply, --start/--clear-start, --end/--clear-end.",
1433
+ "Nothing to change. Pass at least one of --name, --timezone, --window, --daily-cap, --email-mailboxes, --linkedin-accounts, --stop-on-reply/--no-stop-on-reply, --start/--clear-start, --end/--clear-end.",
1377
1434
  );
1378
1435
  }
1379
1436
  if (row.status === "archived") {
@@ -2132,21 +2189,38 @@ type MailboxRow = {
2132
2189
  ownerName?: string;
2133
2190
  isOwner?: boolean;
2134
2191
  visibility?: string;
2192
+ remainingToday?: number;
2193
+ };
2194
+
2195
+ type LinkedinSenderRow = {
2196
+ linkedinAccountId: string;
2197
+ displayName?: string;
2198
+ status?: string;
2199
+ ownerName?: string;
2200
+ isOwner?: boolean;
2201
+ visibility?: string;
2202
+ remainingToday?: { invites?: number; messages?: number; profiles?: number };
2203
+ remainingInvitesThisWeek?: number;
2204
+ availability?: string;
2135
2205
  };
2136
2206
 
2207
+ function remainingCapacity(value: unknown): number | null {
2208
+ return typeof value === "number" && Number.isFinite(value)
2209
+ ? Math.max(0, value)
2210
+ : null;
2211
+ }
2212
+
2137
2213
  /**
2138
- * The sending accounts a step can name. Mailboxes come from
2139
- * `emailMailboxAccounts:listAccounts`; LinkedIn accounts have no
2140
- * token-authenticated list yet, so their ids come from the app or from an
2141
- * existing campaign's steps.
2214
+ * The sending accounts a pool (or legacy step) can name. Both queries accept
2215
+ * the CLI token and scope to the acting member's usable connections. Never
2216
+ * fall back to the browser-only LinkedIn settings query or provider ids.
2142
2217
  */
2143
2218
  async function runAccounts(ctx: CampaignCliContext): Promise<void> {
2144
2219
  unknownFlags(ctx.args, "campaign accounts");
2145
- const rows = await callQuery(
2146
- ctx,
2147
- "functions/emailMailboxAccounts:listAccounts",
2148
- {},
2149
- );
2220
+ const [rows, linkedinRows] = await Promise.all([
2221
+ callQuery(ctx, "functions/emailMailboxAccounts:listAccounts", {}),
2222
+ callQuery(ctx, "functions/linkedinAccounts:listSenderAccounts", {}),
2223
+ ]);
2150
2224
  const mailboxes = (Array.isArray(rows) ? (rows as MailboxRow[]) : []).map(
2151
2225
  (row) => ({
2152
2226
  emailMailboxAccountId: row._id,
@@ -2157,13 +2231,33 @@ async function runAccounts(ctx: CampaignCliContext): Promise<void> {
2157
2231
  ownerName: row.ownerName ?? null,
2158
2232
  isOwner: row.isOwner === true,
2159
2233
  visibility: row.visibility ?? null,
2234
+ remainingToday: remainingCapacity(row.remainingToday),
2160
2235
  }),
2161
2236
  );
2237
+ // An allowlist on the client as well as the query's return validator keeps
2238
+ // provider fields out of JSON output, including when servers are upgraded.
2239
+ const linkedinAccounts = (
2240
+ Array.isArray(linkedinRows) ? (linkedinRows as LinkedinSenderRow[]) : []
2241
+ ).map((row) => ({
2242
+ linkedinAccountId: row.linkedinAccountId,
2243
+ displayName: row.displayName ?? "LinkedIn account",
2244
+ status: row.status ?? null,
2245
+ ownerName: row.ownerName ?? null,
2246
+ isOwner: row.isOwner === true,
2247
+ visibility: row.visibility ?? null,
2248
+ remainingToday: {
2249
+ invites: remainingCapacity(row.remainingToday?.invites),
2250
+ messages: remainingCapacity(row.remainingToday?.messages),
2251
+ profiles: remainingCapacity(row.remainingToday?.profiles),
2252
+ },
2253
+ remainingInvitesThisWeek: remainingCapacity(row.remainingInvitesThisWeek),
2254
+ availability: row.availability ?? "unknown",
2255
+ }));
2162
2256
  const lines = [
2163
- `Mailboxes (${mailboxes.length}) — use emailMailboxAccountId in email steps:`,
2257
+ `Mailboxes (${mailboxes.length}) — use these ids with --email-mailboxes:`,
2164
2258
  ...mailboxes.map(
2165
2259
  (m) =>
2166
- ` ${m.email ?? "(no address)"} — ${m.provider ?? "mailbox"} · ${m.status ?? "unknown"}${m.statusReason ? ` (${m.statusReason})` : ""}${m.ownerName && !m.isOwner ? ` · ${m.ownerName}` : ""}${m.visibility === "private" ? " · private" : ""} [${m.emailMailboxAccountId}]`,
2260
+ ` ${m.email ?? "(no address)"} — ${m.provider ?? "mailbox"} · ${m.status ?? "unknown"}${m.statusReason ? ` (${m.statusReason})` : ""}${m.remainingToday === null ? "" : ` · ${m.remainingToday} remaining today`}${m.ownerName && !m.isOwner ? ` · ${m.ownerName}` : ""}${m.visibility === "private" ? " · private" : ""} [${m.emailMailboxAccountId}]`,
2167
2261
  ),
2168
2262
  ];
2169
2263
  if (mailboxes.length === 0) {
@@ -2173,14 +2267,28 @@ async function runAccounts(ctx: CampaignCliContext): Promise<void> {
2173
2267
  }
2174
2268
  lines.push(
2175
2269
  "",
2176
- "LinkedIn accounts can't be listed from the CLI yet. Take linkedinAccountId from an existing campaign (dench campaign steps get <campaign>) or ask the user to copy it from Outreach → Accounts.",
2270
+ `LinkedIn accounts (${linkedinAccounts.length}) — use these ids with --linkedin-accounts:`,
2271
+ ...linkedinAccounts.map((account) => {
2272
+ const remaining = account.remainingToday;
2273
+ const availability =
2274
+ HOLD_TEXT[account.availability] ?? account.availability;
2275
+ return ` ${account.displayName} — ${availability} · ${remaining.invites ?? "?"} invites, ${remaining.messages ?? "?"} messages, ${remaining.profiles ?? "?"} profile views remaining today · ${account.remainingInvitesThisWeek ?? "?"} invites remaining this week${account.ownerName && !account.isOwner ? ` · ${account.ownerName}` : ""}${account.visibility === "private" ? " · private" : ""} [${account.linkedinAccountId}]`;
2276
+ }),
2177
2277
  );
2278
+ if (linkedinAccounts.length === 0) {
2279
+ lines.push(
2280
+ " none — connect LinkedIn under Outreach → Accounts in the Dench app",
2281
+ );
2282
+ }
2283
+ const note =
2284
+ "Capacity is a usage snapshot before queued work and campaign limits. Pool changes require access for both you and the campaign owner; launch and dispatch revalidate availability.";
2285
+ lines.push("", note);
2178
2286
  out(
2179
2287
  ctx,
2180
2288
  {
2181
2289
  mailboxes,
2182
- linkedinAccounts: null,
2183
- note: "LinkedIn accounts can't be listed from the CLI yet; take linkedinAccountId from an existing campaign's steps or from Outreach → Accounts in the app.",
2290
+ linkedinAccounts,
2291
+ note,
2184
2292
  },
2185
2293
  lines,
2186
2294
  );
@@ -2199,13 +2307,15 @@ Browse:
2199
2307
  dench campaign get <campaign> # status, schedule, funnel, Now/Next, holds, people
2200
2308
  dench campaign people <campaign> [--status active|paused|finished|replied|stopped|bounced|failed]
2201
2309
  dench campaign events <campaign> [--limit 50] [--max-pages 1] # activity log, newest first
2202
- dench campaign accounts # connected mailboxes and their ids for steps.json
2310
+ dench campaign accounts # email + LinkedIn sender ids, availability and capacity
2203
2311
 
2204
2312
  Create and configure:
2205
2313
  dench campaign create --name "Founder outreach" [--timezone America/Los_Angeles] \\
2206
2314
  [--window "Mon-Fri 9-18"] [--window "Sat 10-12"] [--daily-cap 30] \\
2315
+ [--email-mailboxes id1,id2] [--linkedin-accounts id1,id2] \\
2207
2316
  [--stop-on-reply|--no-stop-on-reply] [--start 2026-09-03T09:00:00-07:00] [--end 2026-10-01]
2208
2317
  dench campaign set <campaign> [--name "New name"] [--timezone <tz>] [--window "<spec>" ...] \\
2318
+ [--email-mailboxes id1,id2|none] [--linkedin-accounts id1,id2|none] \\
2209
2319
  [--daily-cap 1-100] [--stop-on-reply|--no-stop-on-reply] [--start <ISO>|--clear-start] [--end <ISO>|--clear-end]
2210
2320
  dench campaign steps get <campaign> # prints steps as JSON you can edit
2211
2321
  dench campaign steps set <campaign> --file steps.json # replaces every step; drafts only
@@ -2232,6 +2342,13 @@ of that day in the campaign's timezone; add a time and offset to be exact.
2232
2342
  steps.json: a JSON array of steps, in order. Types: email, wait, linkedin_visit,
2233
2343
  linkedin_connection, linkedin_message. See references/CAMPAIGNS.md for every field.
2234
2344
 
2345
+ Sender pools: --email-mailboxes and --linkedin-accounts select accounts once for
2346
+ the campaign (emailMailboxAccountIds / linkedinAccountIds in the API). Accepts
2347
+ comma-separated ids or a JSON array; [] or none clears a pool. Omit a flag to
2348
+ leave that channel unchanged. Only your accounts and accounts shared with you
2349
+ can be selected. Launch checks availability. A person's sender stays fixed for
2350
+ their conversation. Legacy step senders are preserved until a pool is configured.
2351
+
2235
2352
  A campaign holds at most ${MAX_CAMPAIGN_PEOPLE} people. Steps lock at launch; the schedule,
2236
2353
  daily cap and stop-on-reply stay editable. Leads move New → Contacted → Replied
2237
2354
  on their own as steps go out.
package/crm.ts CHANGED
@@ -1960,6 +1960,45 @@ async function runViewsCommand(ctx: CrmCliContext): Promise<void> {
1960
1960
  }
1961
1961
  }
1962
1962
 
1963
+ function getFieldCalculationFlag(args: string[]) {
1964
+ for (const flag of ["--calculation", "--campaign"]) {
1965
+ const index = args.indexOf(flag);
1966
+ if (index < 0) continue;
1967
+ const value = args[index + 1];
1968
+ if (!value || value.startsWith("--")) {
1969
+ throw new CrmCliError(`${flag} requires a value.`);
1970
+ }
1971
+ }
1972
+ const metric = getFlag(args, "--calculation");
1973
+ const campaignId = getFlag(args, "--campaign");
1974
+ const metrics = [
1975
+ "email_opened",
1976
+ "email_clicked",
1977
+ "replied",
1978
+ "linkedin_connected",
1979
+ ] as const;
1980
+ if (metric === undefined) {
1981
+ if (campaignId !== undefined) {
1982
+ throw new CrmCliError("--campaign requires --calculation <metric>.");
1983
+ }
1984
+ return undefined;
1985
+ }
1986
+ const selected = metrics.find((candidate) => candidate === metric);
1987
+ if (!selected) {
1988
+ throw new CrmCliError(
1989
+ `--calculation must be one of: ${metrics.join(", ")}.`,
1990
+ );
1991
+ }
1992
+ if (campaignId !== undefined && !campaignId.trim()) {
1993
+ throw new CrmCliError("--campaign must be a multichannel campaign ID.");
1994
+ }
1995
+ return {
1996
+ kind: "campaign_activity" as const,
1997
+ metric: selected,
1998
+ ...(campaignId === undefined ? {} : { campaignId: campaignId.trim() }),
1999
+ };
2000
+ }
2001
+
1963
2002
  async function runFieldsCommand(ctx: CrmCliContext): Promise<void> {
1964
2003
  const verb = ctx.args.shift();
1965
2004
  switch (verb) {
@@ -1976,7 +2015,9 @@ async function runFieldsCommand(ctx: CrmCliContext): Promise<void> {
1976
2015
  "field name",
1977
2016
  'dench crm fields create <object> "<Name>" --type <type>',
1978
2017
  );
1979
- const type = (getFlag(ctx.args, "--type") ?? "text") as any;
2018
+ const calculation = getFieldCalculationFlag(ctx.args);
2019
+ const type =
2020
+ getFlag(ctx.args, "--type") ?? (calculation ? "boolean" : "text");
1980
2021
  const required = hasFlag(ctx.args, "--required");
1981
2022
  const description = getFlag(ctx.args, "--description");
1982
2023
  const enumValues = parseJson(getFlag(ctx.args, "--enum-values")) as
@@ -1995,6 +2036,22 @@ async function runFieldsCommand(ctx: CrmCliContext): Promise<void> {
1995
2036
  : undefined;
1996
2037
  const enrichment = getFieldEnrichmentFlag(ctx.args);
1997
2038
  assertNoUnknownFlags(ctx.args, "crm fields create");
2039
+ if (
2040
+ calculation &&
2041
+ (type !== "boolean" ||
2042
+ required ||
2043
+ indexed ||
2044
+ enrichment ||
2045
+ enumValues !== undefined ||
2046
+ enumColors !== undefined ||
2047
+ enumMultiple ||
2048
+ relatedObjectName !== undefined ||
2049
+ relationshipType !== undefined)
2050
+ ) {
2051
+ throw new CrmCliError(
2052
+ "Campaign calculation columns are read-only booleans; --type must be boolean, without required, indexed, enrichment, enum or relation options.",
2053
+ );
2054
+ }
1998
2055
  out(
1999
2056
  ctx,
2000
2057
  await callMutation(ctx, api.fields.create, {
@@ -2010,6 +2067,7 @@ async function runFieldsCommand(ctx: CrmCliContext): Promise<void> {
2010
2067
  relationshipType,
2011
2068
  indexed,
2012
2069
  enrichment,
2070
+ calculation,
2013
2071
  }),
2014
2072
  );
2015
2073
  return;
@@ -2017,8 +2075,10 @@ async function runFieldsCommand(ctx: CrmCliContext): Promise<void> {
2017
2075
  case "update": {
2018
2076
  const objectName = shift(ctx.args, "object name");
2019
2077
  const fieldName = shift(ctx.args, "field name");
2078
+ const calculation = getFieldCalculationFlag(ctx.args);
2079
+ const clearCalculation = hasFlag(ctx.args, "--clear-calculation");
2020
2080
  const description = getFlag(ctx.args, "--description");
2021
- const required = hasFlag(ctx.args, "--required");
2081
+ const required = hasFlag(ctx.args, "--required") ? true : undefined;
2022
2082
  const enumValues = parseJson(getFlag(ctx.args, "--enum-values")) as
2023
2083
  | string[]
2024
2084
  | undefined;
@@ -2030,6 +2090,19 @@ async function runFieldsCommand(ctx: CrmCliContext): Promise<void> {
2030
2090
  const enrichment = getFieldEnrichmentFlag(ctx.args);
2031
2091
  const clearEnrichment = hasFlag(ctx.args, "--clear-enrichment");
2032
2092
  assertNoUnknownFlags(ctx.args, "crm fields update");
2093
+ if (calculation && clearCalculation) {
2094
+ throw new CrmCliError(
2095
+ "Choose --calculation or --clear-calculation, not both.",
2096
+ );
2097
+ }
2098
+ if (
2099
+ calculation &&
2100
+ (required || indexed || enrichment || enumValues !== undefined)
2101
+ ) {
2102
+ throw new CrmCliError(
2103
+ "Campaign calculation columns are read-only; required, indexed, enrichment and enum options are not supported.",
2104
+ );
2105
+ }
2033
2106
  out(
2034
2107
  ctx,
2035
2108
  await callMutation(ctx, api.fields.update, {
@@ -2041,6 +2114,8 @@ async function runFieldsCommand(ctx: CrmCliContext): Promise<void> {
2041
2114
  indexed,
2042
2115
  enrichment,
2043
2116
  clearEnrichment,
2117
+ calculation,
2118
+ clearCalculation,
2044
2119
  }),
2045
2120
  );
2046
2121
  return;
@@ -4273,6 +4348,15 @@ Fields (columns):
4273
4348
  [--indexed | --no-indexed] [--enrichment-category people|company --apollo-path <path> --input-field <field>]
4274
4349
  dench crm fields update <object> <field> [--description ...] [--required] [--enum-values JSON] [--indexed | --no-indexed] \\
4275
4350
  [--enrichment-category people|company --apollo-path <path> --input-field <field> | --clear-enrichment]
4351
+ dench crm fields create <object> "Email opened" --calculation email_opened [--campaign <id>]
4352
+ dench crm fields update <object> <field> --calculation <metric> [--campaign <id>]
4353
+ Metrics: email_opened, email_clicked, replied, linkedin_connected.
4354
+ Available on people and lead only (a Lead reads through Contact).
4355
+ Read-only boolean columns. Omit --campaign for any accessible multichannel
4356
+ campaign. No --type needed; explicit types must be boolean. No required,
4357
+ default, indexing or enrichment options. Update changes an EXISTING
4358
+ calculation; it cannot convert a stored field. --clear-calculation
4359
+ explicitly makes it an editable boolean, without snapshotting results.
4276
4360
  dench crm fields delete <object> <field>
4277
4361
  dench crm fields reorder <object> <field1> <field2> <field3> ...
4278
4362
 
@@ -47,6 +47,28 @@ const fieldType = z
47
47
  "Field data type. `relation` needs relatedObjectName + relationshipType; `enum` uses enumValues/enumColors; `user` cells store one member userId or an array of member userIds; long prose belongs in the protected `Notes` richtext field.",
48
48
  );
49
49
 
50
+ const campaignCalculation = z
51
+ .object({
52
+ kind: z.literal("campaign_activity"),
53
+ metric: z.enum([
54
+ "email_opened",
55
+ "email_clicked",
56
+ "replied",
57
+ "linkedin_connected",
58
+ ]),
59
+ campaignId: z
60
+ .string()
61
+ .min(1)
62
+ .optional()
63
+ .describe(
64
+ "Same-workspace multichannel campaign ID readable by the viewer. Omit for any accessible multichannel campaign.",
65
+ ),
66
+ })
67
+ .strict()
68
+ .describe(
69
+ "Read-only campaign activity boolean on people or lead (through Contact), not an expression. Cannot be required, indexed, enriched or have a default value.",
70
+ );
71
+
50
72
  const viewKind = z
51
73
  .enum(["table", "kanban", "calendar", "timeline", "gallery", "list"])
52
74
  .describe("Default view rendered for the object.");
@@ -229,6 +251,66 @@ const campaignRecipientInput = z.object({
229
251
  // Outreach campaign fragments (mirror convex/functions/outreachSequences.ts)
230
252
  // ---------------------------------------------------------------------------
231
253
 
254
+ const campaignSenderPools = {
255
+ emailMailboxAccountIds: z
256
+ .array(z.string().trim().min(1))
257
+ .max(50)
258
+ .optional()
259
+ .describe(
260
+ "Campaign email sender pool: up to 50 emailMailboxAccounts ids both you and the campaign owner may use. Omit to preserve existing configuration; [] clears the pool. A person's sender stays fixed for their conversation. Launch validates sender availability.",
261
+ ),
262
+ linkedinAccountIds: z
263
+ .array(z.string().trim().min(1))
264
+ .max(50)
265
+ .optional()
266
+ .describe(
267
+ "Campaign LinkedIn sender pool: up to 50 linkedinAccounts ids both you and the campaign owner may use. Omit to preserve existing configuration; [] clears the pool. Legacy step senders remain until a pool is configured.",
268
+ ),
269
+ };
270
+
271
+ const campaignLinkedinSenderSummary = z
272
+ .object({
273
+ linkedinAccountId: z
274
+ .string()
275
+ .describe(
276
+ "Local sender id for linkedinAccountIds, never a provider credential.",
277
+ ),
278
+ displayName: z.string(),
279
+ status: z.enum(["running", "paused", "disconnected", "errored"]),
280
+ ownerName: z.string(),
281
+ isOwner: z.boolean(),
282
+ visibility: z.enum(["private", "shared"]),
283
+ remainingToday: z
284
+ .object({
285
+ invites: z
286
+ .number()
287
+ .nonnegative()
288
+ .describe(
289
+ "Daily capacity, also bounded by the rolling weekly invite limit.",
290
+ ),
291
+ messages: z.number().nonnegative(),
292
+ profiles: z.number().nonnegative(),
293
+ })
294
+ .strict(),
295
+ remainingInvitesThisWeek: z.number().nonnegative(),
296
+ availability: z
297
+ .enum([
298
+ "ready",
299
+ "paused",
300
+ "disconnected",
301
+ "errored",
302
+ "disabled",
303
+ "circuit_break",
304
+ "spacing",
305
+ "outside_window",
306
+ "daily_cap",
307
+ ])
308
+ .describe(
309
+ "Account availability snapshot. Queued work, campaign limits and launch/dispatch checks still apply.",
310
+ ),
311
+ })
312
+ .strict();
313
+
232
314
  const campaignSendSchedule = z
233
315
  .object({
234
316
  name: z.string().describe('Label, e.g. "Mon-Fri 9-18".'),
@@ -275,7 +357,7 @@ const campaignStepInput = z
275
357
  .string()
276
358
  .optional()
277
359
  .describe(
278
- "email steps: the connected mailbox that sends (an emailMailboxAccounts id from `dench campaign accounts`).",
360
+ "Legacy email step sender. Pool campaigns choose senders in emailMailboxAccountIds on the campaign, not on individual steps.",
279
361
  ),
280
362
  emailSubject: z
281
363
  .string()
@@ -298,7 +380,9 @@ const campaignStepInput = z
298
380
  linkedinAccountId: z
299
381
  .string()
300
382
  .optional()
301
- .describe("LinkedIn steps: the connected LinkedIn account that acts."),
383
+ .describe(
384
+ "Legacy LinkedIn step sender. Pool campaigns use the campaign's linkedinAccountIds instead.",
385
+ ),
302
386
  linkedinMessageBody: z
303
387
  .string()
304
388
  .optional()
@@ -330,6 +414,7 @@ const campaignRow = z
330
414
  name: z.string(),
331
415
  status: campaignStatus,
332
416
  stopOnReply: z.boolean(),
417
+ ...campaignSenderPools,
333
418
  timezone: z.string().optional(),
334
419
  startsAt: z.number().optional(),
335
420
  endsAt: z.number().optional(),
@@ -721,6 +806,7 @@ const crmFieldDoc = z
721
806
  type: fieldType,
722
807
  required: z.boolean(),
723
808
  defaultValue: z.string().optional(),
809
+ calculation: campaignCalculation.optional(),
724
810
  relatedObjectId: z.string().optional(),
725
811
  relationshipType: relationshipType.optional(),
726
812
  enumValues: z.array(z.string()).optional(),
@@ -1759,6 +1845,7 @@ export const requestSchemas: Record<string, ZodTypeAny> = {
1759
1845
  "commands.list": noInput,
1760
1846
 
1761
1847
  // Outreach campaigns (dench campaign)
1848
+ "campaigns.accounts.linkedin": noInput,
1762
1849
  "campaigns.list": z.object({
1763
1850
  includeArchived: z
1764
1851
  .boolean()
@@ -1767,6 +1854,7 @@ export const requestSchemas: Record<string, ZodTypeAny> = {
1767
1854
  }),
1768
1855
  "campaigns.create": z.object({
1769
1856
  name: z.string(),
1857
+ ...campaignSenderPools,
1770
1858
  timezone: z
1771
1859
  .string()
1772
1860
  .optional()
@@ -1778,6 +1866,7 @@ export const requestSchemas: Record<string, ZodTypeAny> = {
1778
1866
  "campaigns.update": z.object({
1779
1867
  sequenceId: z.string(),
1780
1868
  name: z.string().optional(),
1869
+ ...campaignSenderPools,
1781
1870
  stopOnReply: z
1782
1871
  .boolean()
1783
1872
  .optional()
@@ -2134,7 +2223,11 @@ export const requestSchemas: Record<string, ZodTypeAny> = {
2134
2223
  "crm.fields.create": z.object({
2135
2224
  objectName: z.string(),
2136
2225
  name: z.string(),
2137
- type: fieldType,
2226
+ type: fieldType
2227
+ .optional()
2228
+ .describe(
2229
+ "Defaults to boolean with calculation, otherwise text. Calculations require boolean.",
2230
+ ),
2138
2231
  required: z.boolean().optional(),
2139
2232
  defaultValue: z.string().optional(),
2140
2233
  relatedObjectName: z
@@ -2154,6 +2247,7 @@ export const requestSchemas: Record<string, ZodTypeAny> = {
2154
2247
  description: z.string().optional(),
2155
2248
  indexed: z.boolean().optional().describe("Index for filter/search/sort."),
2156
2249
  enrichment: enrichmentConfig.optional(),
2250
+ calculation: campaignCalculation.optional(),
2157
2251
  }),
2158
2252
  "crm.fields.update": z.object({
2159
2253
  objectName: z.string(),
@@ -2170,6 +2264,17 @@ export const requestSchemas: Record<string, ZodTypeAny> = {
2170
2264
  indexed: z.boolean().optional(),
2171
2265
  enrichment: enrichmentConfig.optional(),
2172
2266
  clearEnrichment: z.boolean().optional(),
2267
+ calculation: campaignCalculation
2268
+ .optional()
2269
+ .describe(
2270
+ "Replace an existing calculation's metric/source. Stored fields cannot be converted; create a new column instead.",
2271
+ ),
2272
+ clearCalculation: z
2273
+ .boolean()
2274
+ .optional()
2275
+ .describe(
2276
+ "Explicitly remove an existing calculation, leaving an editable boolean. Does not snapshot calculated values. Mutually exclusive with calculation.",
2277
+ ),
2173
2278
  }),
2174
2279
  "crm.fields.delete": z.object({
2175
2280
  objectName: z.string(),
@@ -2974,6 +3079,7 @@ export const requestSchemas: Record<string, ZodTypeAny> = {
2974
3079
  export const responseSchemas: Record<string, ZodTypeAny> = {
2975
3080
  // Meta
2976
3081
  // Outreach campaigns (dench campaign)
3082
+ "campaigns.accounts.linkedin": z.array(campaignLinkedinSenderSummary),
2977
3083
  "campaigns.list": z.array(campaignRow),
2978
3084
  "campaigns.create": z.object({ sequenceId: z.string() }),
2979
3085
  "campaigns.get": z
@@ -3970,12 +4076,17 @@ export const convexExtras: Record<string, ConvexExtras> = {
3970
4076
  // ---------------------------------------------------------------------------
3971
4077
 
3972
4078
  export const requestExamples: Record<string, unknown> = {
4079
+ "campaigns.accounts.linkedin": {},
3973
4080
  "campaigns.create": {
3974
4081
  name: "Founder outreach",
3975
4082
  timezone: "America/Los_Angeles",
4083
+ emailMailboxAccountIds: ["<emailMailboxAccountId>"],
4084
+ linkedinAccountIds: ["<linkedinAccountId>"],
3976
4085
  },
3977
4086
  "campaigns.update": {
3978
4087
  sequenceId: "<sequenceId>",
4088
+ emailMailboxAccountIds: ["<emailMailboxAccountId>"],
4089
+ linkedinAccountIds: ["<linkedinAccountId>"],
3979
4090
  dailySendCap: 30,
3980
4091
  sendSchedules: [
3981
4092
  {
@@ -3990,17 +4101,15 @@ export const requestExamples: Record<string, unknown> = {
3990
4101
  "campaigns.steps.replace": {
3991
4102
  sequenceId: "<sequenceId>",
3992
4103
  steps: [
3993
- { type: "linkedin_visit", linkedinAccountId: "<linkedinAccountId>" },
4104
+ { type: "linkedin_visit" },
3994
4105
  {
3995
4106
  type: "linkedin_connection",
3996
- linkedinAccountId: "<linkedinAccountId>",
3997
4107
  linkedinMessageBody:
3998
4108
  "Hi {{First name}}, enjoyed your post on {{Topic}}.",
3999
4109
  },
4000
4110
  { type: "wait", waitHours: 48 },
4001
4111
  {
4002
4112
  type: "email",
4003
- emailMailboxAccountId: "<emailMailboxAccountId>",
4004
4113
  emailSubject: "Quick question, {{First name}}",
4005
4114
  emailTextBody: "Hi {{First name}}, ...",
4006
4115
  },
@@ -4279,6 +4388,19 @@ const workspaceStatusExample = {
4279
4388
  };
4280
4389
 
4281
4390
  export const responseExamples: Record<string, unknown> = {
4391
+ "campaigns.accounts.linkedin": [
4392
+ {
4393
+ linkedinAccountId: "<linkedinAccountId>",
4394
+ displayName: "Ada Lovelace",
4395
+ status: "running",
4396
+ ownerName: "Ada",
4397
+ isOwner: true,
4398
+ visibility: "private",
4399
+ remainingToday: { invites: 12, messages: 36, profiles: 40 },
4400
+ remainingInvitesThisWeek: 50,
4401
+ availability: "ready",
4402
+ },
4403
+ ],
4282
4404
  "browser.session.create": {
4283
4405
  provider: "dench_browser",
4284
4406
  sessionId: "bb_sess_123",
@@ -899,7 +899,8 @@ const rawApiOperations = [
899
899
  op({
900
900
  id: "crm.fields.list",
901
901
  group: "crm",
902
- summary: "List fields for a CRM object.",
902
+ summary:
903
+ "List fields for a CRM object, including read-only calculation metadata.",
903
904
  cli: "dench crm fields list",
904
905
  method: "GET",
905
906
  path: "/crm/objects/{objectName}/fields",
@@ -910,7 +911,8 @@ const rawApiOperations = [
910
911
  op({
911
912
  id: "crm.fields.create",
912
913
  group: "crm",
913
- summary: "Create a CRM field.",
914
+ summary:
915
+ "Create a CRM field or read-only campaign activity boolean column.",
914
916
  cli: "dench crm fields create",
915
917
  method: "POST",
916
918
  path: "/crm/objects/{objectName}/fields",
@@ -921,7 +923,8 @@ const rawApiOperations = [
921
923
  op({
922
924
  id: "crm.fields.update",
923
925
  group: "crm",
924
- summary: "Update a CRM field.",
926
+ summary:
927
+ "Update a CRM field or change/explicitly clear an existing campaign calculation.",
925
928
  cli: "dench crm fields update",
926
929
  method: "PATCH",
927
930
  path: "/crm/objects/{objectName}/fields/{fieldName}",
@@ -2633,6 +2636,18 @@ const rawApiOperations = [
2633
2636
  }),
2634
2637
 
2635
2638
  // Outreach campaigns (email + LinkedIn steps on one schedule): `dench campaign`.
2639
+ op({
2640
+ id: "campaigns.accounts.linkedin",
2641
+ group: "campaigns",
2642
+ summary:
2643
+ "Discover LinkedIn sender ids, labels, availability and remaining capacity visible to the acting workspace member. Never returns provider credentials.",
2644
+ cli: "dench campaign accounts",
2645
+ method: "GET",
2646
+ path: "/campaigns/accounts/linkedin",
2647
+ requestSchema: anyObject,
2648
+ responseSchema: anyResponse,
2649
+ backend: convex("query", "functions/linkedinAccounts:listSenderAccounts"),
2650
+ }),
2636
2651
  op({
2637
2652
  id: "campaigns.list",
2638
2653
  group: "campaigns",
@@ -2648,7 +2663,7 @@ const rawApiOperations = [
2648
2663
  id: "campaigns.create",
2649
2664
  group: "campaigns",
2650
2665
  summary:
2651
- "Create a draft outreach campaign with a business-hours send window in the given timezone.",
2666
+ "Create a draft outreach campaign with email and LinkedIn sender pools and a business-hours send window in the given timezone.",
2652
2667
  cli: "dench campaign create",
2653
2668
  method: "POST",
2654
2669
  path: "/campaigns",
@@ -2699,7 +2714,7 @@ const rawApiOperations = [
2699
2714
  id: "campaigns.update",
2700
2715
  group: "campaigns",
2701
2716
  summary:
2702
- "Change a campaign's name, send windows, daily email cap, stop-on-reply, start or end. Works until archived.",
2717
+ "Change a campaign's name, sender pools, send windows, daily email cap, stop-on-reply, start or end. Works until archived; existing conversations keep their assigned sender.",
2703
2718
  cli: "dench campaign set",
2704
2719
  method: "PATCH",
2705
2720
  path: "/campaigns/{sequenceId}",
@@ -2711,7 +2726,7 @@ const rawApiOperations = [
2711
2726
  id: "campaigns.steps.replace",
2712
2727
  group: "campaigns",
2713
2728
  summary:
2714
- "Replace every step of a draft campaign (email, wait, LinkedIn visit, connection request, message).",
2729
+ "Replace every step of a draft campaign (email, wait, LinkedIn visit, connection request, message). Configure sender pools on the campaign; step sender ids are legacy-only.",
2715
2730
  cli: "dench campaign steps set",
2716
2731
  method: "PUT",
2717
2732
  path: "/campaigns/{sequenceId}/steps",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dench.com/cli",
3
- "version": "2.9.2-staging.203",
3
+ "version": "2.9.3-staging.215",
4
4
  "description": "Dench agent workspace CLI.",
5
5
  "type": "module",
6
6
  "bin": {