@dench.com/cli 3.12.16 → 3.12.18-staging.1346

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/ads.ts CHANGED
@@ -203,7 +203,7 @@ const DEMO_ADS: Ad[] = [
203
203
  },
204
204
  {
205
205
  id: "demo-dench",
206
- label: "Dench — your AI agent workspace",
206
+ label: "Dench — your AI Revenue Engine",
207
207
  url: "https://dench.com",
208
208
  icon: "◆",
209
209
  iconUrl: "https://dench.com/logos/favicon-32x32.png",
package/app-sdk.d.ts CHANGED
@@ -474,6 +474,7 @@ export interface ApiRequests {
474
474
  "campaigns.builder.save": {
475
475
  /** Your stable id for this request, 8-64 characters. Retrying with the same id returns the same draft instead of creating another. */
476
476
  clientRequestId: string;
477
+ /** Each list holds at most 12 values; pick the most important ones. */
477
478
  targeting: {
478
479
  titles: string[];
479
480
  locations: string[];
@@ -541,7 +542,7 @@ export interface ApiRequests {
541
542
  "campaigns.builder.build": {
542
543
  draftId: string;
543
544
  };
544
- /** Create a campaign from a reviewed signal draft. Does not launch the campaign. — `dench campaign builder create` — POST /api/v1/campaigns/builder/drafts/{draftId}/create */
545
+ /** Create a campaign from a built signal draft (status ready; a changed save reopens it until built again). Does not launch the campaign. — `dench campaign builder create` — POST /api/v1/campaigns/builder/drafts/{draftId}/create */
545
546
  "campaigns.builder.create": {
546
547
  draftId: string;
547
548
  name?: string;
@@ -1030,7 +1031,7 @@ export interface ApiRequests {
1030
1031
  viewName: string;
1031
1032
  page?: number;
1032
1033
  pageSize?: number;
1033
- /** Personal scope: "me" (the signed-in member / the human behind an agent session), "unassigned", or a member userId or email. Adds one has_any / is_empty rule on the object's assignee user field; rows, totalCount, sums and analytics all follow it. Never saved onto the view. */
1034
+ /** Personal scope: "me" (the signed-in member / the human behind an agent session), "unassigned", a member userId or email, or a comma-separated list of people (me and member ids or emails). Several people add one has_any rule (rows assigned to any of them); "unassigned" is exclusive and is is_empty. Rows, totalCount, sums and analytics all follow it. Never saved onto the view. */
1034
1035
  assignedTo?: string;
1035
1036
  /** Which `user` field "assigned" means. Default: the analytics owner role, else the task `Assignee`, else a user field named like owner/assignee, else the first user field. */
1036
1037
  assigneeField?: string;
@@ -1264,7 +1265,7 @@ export interface ApiRequests {
1264
1265
  withReferences?: boolean;
1265
1266
  objectName: string;
1266
1267
  limit?: number;
1267
- /** Personal scope: "me" (the signed-in member / the human behind an agent session), "unassigned", or a member userId or email. Adds one has_any / is_empty rule on the object's assignee user field; rows, totalCount, sums and analytics all follow it. Never saved onto the view. */
1268
+ /** Personal scope: "me" (the signed-in member / the human behind an agent session), "unassigned", a member userId or email, or a comma-separated list of people (me and member ids or emails). Several people add one has_any rule (rows assigned to any of them); "unassigned" is exclusive and is is_empty. Rows, totalCount, sums and analytics all follow it. Never saved onto the view. */
1268
1269
  assignedTo?: string;
1269
1270
  /** Which `user` field "assigned" means. Default: the analytics owner role, else the task `Assignee`, else a user field named like owner/assignee, else the first user field. */
1270
1271
  assigneeField?: string;
@@ -1615,7 +1616,7 @@ export interface ApiRequests {
1615
1616
  };
1616
1617
  /** JSON string of the DSL when filters use operators like $gt/$in/$contains/$and/$or. Date fields and the system timestamps created_at/updated_at also accept $datePreset ("today", "yesterday", "this_week", "last_week", "this_month", "last_month", "this_quarter", "last_quarter", "this_year", "last_year"), and $inLast/$inNext rolling windows (a day count like 7, or {"amount":2,"unit":"weeks"} with unit days|weeks|months|quarters|years). On a date field, $gt/$gte/$lt/$lte take a day ("2026-11-03"), an ISO date-time with its offset or epoch ms; a top-level "timeZone" (IANA) says which zone a day bound means. A filter naming a field the object does not have is an error. Example: {"filter":{"updated_at":{"$datePreset":"this_month"}}}. */
1617
1618
  dslJson?: string;
1618
- /** Personal scope: "me" (the signed-in member / the human behind an agent session), "unassigned", or a member userId or email. Adds one has_any / is_empty rule on the object's assignee user field; rows, totalCount, sums and analytics all follow it. Never saved onto the view. */
1619
+ /** Personal scope: "me" (the signed-in member / the human behind an agent session), "unassigned", a member userId or email, or a comma-separated list of people (me and member ids or emails). Several people add one has_any rule (rows assigned to any of them); "unassigned" is exclusive and is is_empty. Rows, totalCount, sums and analytics all follow it. Never saved onto the view. */
1619
1620
  assignedTo?: string;
1620
1621
  /** Which `user` field "assigned" means. Default: the analytics owner role, else the task `Assignee`, else a user field named like owner/assignee, else the first user field. */
1621
1622
  assigneeField?: string;
@@ -1625,7 +1626,7 @@ export interface ApiRequests {
1625
1626
  objectName: string;
1626
1627
  dsl?: Record<string, unknown>;
1627
1628
  dslJson?: string;
1628
- /** Personal scope: "me" (the signed-in member / the human behind an agent session), "unassigned", or a member userId or email. Adds one has_any / is_empty rule on the object's assignee user field; rows, totalCount, sums and analytics all follow it. Never saved onto the view. */
1629
+ /** Personal scope: "me" (the signed-in member / the human behind an agent session), "unassigned", a member userId or email, or a comma-separated list of people (me and member ids or emails). Several people add one has_any rule (rows assigned to any of them); "unassigned" is exclusive and is is_empty. Rows, totalCount, sums and analytics all follow it. Never saved onto the view. */
1629
1630
  assignedTo?: string;
1630
1631
  /** Which `user` field "assigned" means. Default: the analytics owner role, else the task `Assignee`, else a user field named like owner/assignee, else the first user field. */
1631
1632
  assigneeField?: string;
@@ -1944,7 +1945,7 @@ export interface ApiRequests {
1944
1945
  /** Chance of closing per OPEN stage, 0..1, for the weighted forecast. Unlisted stages are spaced evenly; won = 1, lost = 0. */
1945
1946
  stageProbabilities?: Record<string, number>;
1946
1947
  };
1947
- /** Personal scope: "me" (the signed-in member / the human behind an agent session), "unassigned", or a member userId or email. Adds one has_any / is_empty rule on the object's assignee user field; rows, totalCount, sums and analytics all follow it. Never saved onto the view. */
1948
+ /** Personal scope: "me" (the signed-in member / the human behind an agent session), "unassigned", a member userId or email, or a comma-separated list of people (me and member ids or emails). Several people add one has_any rule (rows assigned to any of them); "unassigned" is exclusive and is is_empty. Rows, totalCount, sums and analytics all follow it. Never saved onto the view. */
1948
1949
  assignedTo?: string;
1949
1950
  /** Which `user` field "assigned" means. Default: the analytics owner role, else the task `Assignee`, else a user field named like owner/assignee, else the first user field. */
1950
1951
  assigneeField?: string;
@@ -2315,6 +2316,11 @@ export interface ApiRequests {
2315
2316
  contacts: Record<string, unknown>[];
2316
2317
  [key: string]: unknown;
2317
2318
  };
2319
+ /** Read a queued contact lookup by the enrichmentId it returned. Free, and never submits the lookup again: poll this, not person/contact, until status is succeeded or failed. — `dench crm enrich cell` — GET /api/v1/enrichment/jobs/{enrichmentId} */
2320
+ "enrichment.jobs.get": {
2321
+ /** The enrichmentId a queued person/contact call returned. */
2322
+ enrichmentId: string;
2323
+ };
2318
2324
  /** Look up up to 100 people or company profiles without buying emails or phones. Pass kind (people|companies) and lookups; results preserve inputIndex. People require linkedinUrl or email; companies require domain or linkedinUrl. — `dench crm enrich profiles` — POST /api/v1/enrichment/profiles/bulk */
2319
2325
  "enrichment.profiles.bulk": {
2320
2326
  kind: "people" | "companies";
@@ -2361,7 +2367,7 @@ export interface ApiRequests {
2361
2367
  columns?: string[];
2362
2368
  /** Filter in the crm.query DSL, e.g. {"Status":"Open"} or {"Score":{"$gte":50}}. Field names are case-sensitive. */
2363
2369
  where?: Record<string, unknown>;
2364
- /** Personal scope: "me" (the signed-in member / the human behind an agent session), "unassigned", or a member userId or email. Adds one has_any / is_empty rule on the object's assignee user field; rows, totalCount, sums and analytics all follow it. Never saved onto the view. */
2370
+ /** Personal scope: "me" (the signed-in member / the human behind an agent session), "unassigned", a member userId or email, or a comma-separated list of people (me and member ids or emails). Several people add one has_any rule (rows assigned to any of them); "unassigned" is exclusive and is is_empty. Rows, totalCount, sums and analytics all follow it. Never saved onto the view. */
2365
2371
  assignedTo?: string;
2366
2372
  /** Which `user` field "assigned" means. Default: the analytics owner role, else the task `Assignee`, else a user field named like owner/assignee, else the first user field. */
2367
2373
  assigneeField?: string;
@@ -4709,6 +4715,9 @@ export interface ApiResponses {
4709
4715
  target: {
4710
4716
  kind: "user";
4711
4717
  userId: string;
4718
+ } | {
4719
+ kind: "users";
4720
+ userIds: string[];
4712
4721
  } | {
4713
4722
  kind: "unassigned";
4714
4723
  };
@@ -6288,6 +6297,7 @@ export interface ApiResponses {
6288
6297
  [key: string]: unknown;
6289
6298
  };
6290
6299
  "enrichment.person.contact": Record<string, unknown>;
6300
+ "enrichment.jobs.get": unknown;
6291
6301
  "enrichment.profiles.bulk": {
6292
6302
  kind: "people" | "companies";
6293
6303
  records: Array<{
@@ -9047,7 +9057,7 @@ export type DenchApiTree = {
9047
9057
  autofill(args: Req<"campaigns.builder.autofill">): Promise<Res<"campaigns.builder.autofill">>;
9048
9058
  /** Start the same billable signal/audience/message build used by the UI; poll the draft for progress. (`dench campaign builder build`) */
9049
9059
  build(args: Req<"campaigns.builder.build">): Promise<Res<"campaigns.builder.build">>;
9050
- /** Create a campaign from a reviewed signal draft. Does not launch the campaign. (`dench campaign builder create`) */
9060
+ /** Create a campaign from a built signal draft (status ready; a changed save reopens it until built again). Does not launch the campaign. (`dench campaign builder create`) */
9051
9061
  create(args: Req<"campaigns.builder.create">): Promise<Res<"campaigns.builder.create">>;
9052
9062
  /** Discard a saved draft that has not become a campaign. (`dench campaign builder discard`) */
9053
9063
  discard(args: Req<"campaigns.builder.discard">): Promise<Res<"campaigns.builder.discard">>;
@@ -9738,6 +9748,8 @@ export type DenchApiTree = {
9738
9748
  related(args: Req<"enrichment.company.related">): Promise<Res<"enrichment.company.related">>;
9739
9749
  };
9740
9750
  jobs: {
9751
+ /** Read a queued contact lookup by the enrichmentId it returned. Free, and never submits the lookup again: poll this, not person/contact, until status is succeeded or failed. (`dench crm enrich cell`) */
9752
+ get(args: Req<"enrichment.jobs.get">): Promise<Res<"enrichment.jobs.get">>;
9741
9753
  /** Search job postings through Dench find. `companyDomains` takes up to 1000 domains (chunked automatically); `dench jobs find --company-list <id|view>` resolves a saved company list into it. (`dench jobs find`) */
9742
9754
  search(args: Req<"enrichment.jobs.search">): Promise<Res<"enrichment.jobs.search">>;
9743
9755
  };
package/crm-analytics.ts CHANGED
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * get [--view V] read config (+ the view's own dashboard)
10
10
  * compute [--view V] [--period P] [--panel ID ...] [--panels JSON] [--filters JSON]
11
- * [--assigned-to me|unassigned|<user>] [--assignee-field F] personal scope
11
+ * [--assigned-to me|unassigned|<user>[,…]] [--assignee-field F] personal scope
12
12
  * save <panelId> --panel JSON [--view V] create / replace one panel
13
13
  * update <panelId> --patch JSON [--view V] edit part of one panel (null clears)
14
14
  * hide <panelId> [--view V] keep it off the strip (full view only)
package/crm-comments.ts CHANGED
@@ -511,7 +511,7 @@ export async function runActivityCommand(ctx: CrmCliContext): Promise<void> {
511
511
  const entry = (await callQuery(
512
512
  ctx,
513
513
  makeFunctionReference<"query">("functions/crm/entries:get"),
514
- { objectName, entryId },
514
+ { objectName, entryId, missingAsNull: true },
515
515
  )) as { fields?: Record<string, unknown> } | null;
516
516
  const raw = entry?.fields?.Notes ?? entry?.fields?.notes;
517
517
  notes = typeof raw === "string" && raw.trim() ? raw : null;
package/crm.ts CHANGED
@@ -319,7 +319,7 @@ function resolveLimitFlag(
319
319
  * The personal assignee scope flags shared by every read that supports it
320
320
  * (`views entries`, `entries list`, `query`, `analytics compute`):
321
321
  *
322
- * --assigned-to me|unassigned|<userId|email> (alias: --mine)
322
+ * --assigned-to me|unassigned|<userId|email>[,…] (alias: --mine)
323
323
  * --assignee-field <Field> which `user` field counts
324
324
  *
325
325
  * Forwarded verbatim as `assignedTo` / `assigneeField`; the server resolves
@@ -346,7 +346,7 @@ export function resolveAssigneeScopeFlags(args: string[]): {
346
346
  const assignedTo = mine ? "me" : assignedToRaw?.trim();
347
347
  if (assignedTo !== undefined && assignedTo === "") {
348
348
  throw new CrmCliError(
349
- "--assigned-to needs a value: me, unassigned, or a member userId / email.",
349
+ "--assigned-to needs a value: me, unassigned, a member userId / email, or a comma-separated list of people.",
350
350
  );
351
351
  }
352
352
  if (assigneeField !== undefined && assignedTo === undefined) {
@@ -1189,7 +1189,7 @@ export async function runCrmCommand(opts: {
1189
1189
  console.log(`Usage: dench crm query <object> [--with-references] [--where '<JSON>'] [--select Name,Email] [--sort -Score] [--limit N] [--timezone <IANA zone>] [--json]
1190
1190
  --timezone America/Los_Angeles The zone date filters mean (day bounds like "2026-11-03"); defaults to $TZ, else UTC.
1191
1191
  --page [--cursor '<continueCursor>'] Return {page,isDone,continueCursor} in index order; omit --sort.
1192
- --assigned-to me|unassigned|<userId|email> (or --mine) [--assignee-field <Field>]
1192
+ --assigned-to me|unassigned|<userId|email>[,…] (or --mine) [--assignee-field <Field>]
1193
1193
  Default limit: 100. Maximum: 1000 for a one-shot array, 100 for a cursor page.
1194
1194
  Continue cursor pages until isDone, including empty filtered pages.
1195
1195
  Example: dench crm query company --where '{"Status":"New"}' --select Name --limit 25 --json`);
@@ -2811,22 +2811,21 @@ async function runEntriesCommand(ctx: CrmCliContext): Promise<void> {
2811
2811
  const withContext = hasFlag(ctx.args, "--with-context");
2812
2812
  const compact = hasFlag(ctx.args, "--compact");
2813
2813
  assertNoUnknownFlags(ctx.args, "crm entries get");
2814
- const entry = withCrmEntryDeepLinks(
2815
- ctx,
2816
- objectName,
2817
- withContext
2818
- ? await callAction(
2819
- ctx,
2820
- makeFunctionReference<"action">(
2821
- "functions/crm/recordRead:getEntry",
2822
- ),
2823
- { objectName, entryId, withContext: true },
2824
- )
2825
- : await callQuery(ctx, api.entries.get, {
2826
- objectName,
2827
- entryId: entryId as any,
2828
- }),
2829
- );
2814
+ const rawEntry = withContext
2815
+ ? await callAction(
2816
+ ctx,
2817
+ makeFunctionReference<"action">(
2818
+ "functions/crm/recordRead:getEntry",
2819
+ ),
2820
+ { objectName, entryId, withContext: true, missingAsNull: true },
2821
+ )
2822
+ : await callQuery(ctx, api.entries.get, {
2823
+ objectName,
2824
+ entryId: entryId as any,
2825
+ missingAsNull: true,
2826
+ });
2827
+ if (!rawEntry) throw new CrmCliError("Entry not found");
2828
+ const entry = withCrmEntryDeepLinks(ctx, objectName, rawEntry);
2830
2829
  const printEntry = (value: unknown) => {
2831
2830
  if (compact) {
2832
2831
  // Normalize references before measuring the exact emitted JSON. No
@@ -3180,7 +3179,9 @@ async function snapshotEntriesBeforeBulkDelete(
3180
3179
  const entry = await queryWithTransientRetry(ctx, api.entries.get, {
3181
3180
  objectName,
3182
3181
  entryId: entryId as any,
3182
+ missingAsNull: true,
3183
3183
  });
3184
+ if (!entry) throw new CrmCliError("Entry not found");
3184
3185
  lines.push(JSON.stringify(entry));
3185
3186
  }
3186
3187
  } catch (error) {
@@ -4991,6 +4992,7 @@ async function enrichCellThroughGateway(
4991
4992
  await callQuery(ctx, api.entries.get, {
4992
4993
  objectName: args.objectName,
4993
4994
  entryId: args.entryId,
4995
+ missingAsNull: true,
4994
4996
  }),
4995
4997
  );
4996
4998
  if (!entry) throw new CrmCliError("Entry not found");
@@ -5370,10 +5372,11 @@ Views (saved CRM subsets):
5370
5372
  dench crm views list <object> [--json]
5371
5373
  dench crm views get <object> <view-name> [--json]
5372
5374
  dench crm views entries <object> <view-name> [--limit N] [--page N] [--with-meta] [--json]
5373
- [--assigned-to me|unassigned|<userId|email>] [--assignee-field <Field>]
5375
+ [--assigned-to me|unassigned|<userId|email>[,…]] [--assignee-field <Field>]
5374
5376
  --assigned-to (alias --mine) is the PERSONAL scope the toolbar's
5375
5377
  avatar pill applies: rows whose people field includes that member
5376
- (or is empty for "unassigned"). It never touches the saved view.
5378
+ (or any of a comma-separated list, or is empty for "unassigned").
5379
+ It never touches the saved view.
5377
5380
  The field defaults to the analytics owner role → Assignee → a
5378
5381
  field named like owner/assignee → the first user field.
5379
5382
  dench crm views create <object> <view-name> [--where '{"Status":"Hot"}']
@@ -5492,7 +5495,7 @@ Fields (columns):
5492
5495
 
5493
5496
  Entries (rows):
5494
5497
  dench crm entries list <object> [--with-references] [--limit N] [--with-meta [--cursor '<continueCursor>']] [--json]
5495
- [--assigned-to me|unassigned|<userId|email> | --mine] [--assignee-field <Field>]
5498
+ [--assigned-to me|unassigned|<userId|email>[,…] | --mine] [--assignee-field <Field>]
5496
5499
  --with-meta includes readable pagination; totalCount is the entire object's catalog count,
5497
5500
  not a readable or assigned total. Continue only when continueCursor is returned, preserving filters.
5498
5501
  Scoped reads may be truncated with no cursor (hasMore: null); repeating the same call will not advance.
@@ -5637,7 +5640,7 @@ Query DSL:
5637
5640
  dench crm query <object> [--with-references] --where '{"Status":"New"}' --select Name,Email --sort -Score --limit 100
5638
5641
  dench crm query <object> [--with-references] --page --select Name,Email --limit 100 [--cursor '<continueCursor>'] --json
5639
5642
  Cursor pages use index order (omit --sort). Continue until isDone, including empty filtered pages.
5640
- [--assigned-to me|unassigned|<userId|email> | --mine] [--assignee-field <Field>]
5643
+ [--assigned-to me|unassigned|<userId|email>[,…] | --mine] [--assignee-field <Field>]
5641
5644
  --mine AND-s "assigned to me" onto --where without you having to
5642
5645
  know your own userId or the object's people field.
5643
5646
  Operators: $eq $ne $in $nin $gt $gte $lt $lte $exists
@@ -5712,7 +5715,7 @@ Import / export:
5712
5715
  dench crm export <object> --format csv|jsonl [--limit N]
5713
5716
  Pages with a real cursor and verifies no duplicate ids before
5714
5717
  emitting; a summary (exportedCount/uniqueIds) is printed to stderr.
5715
- dench crm exports start <object> [--columns Name,Email] [--where '<JSON>'] [--assigned-to me|unassigned|<userId|email>] [--assignee-field <Field>]
5718
+ dench crm exports start <object> [--columns Name,Email] [--where '<JSON>'] [--assigned-to me|unassigned|<userId|email>[,…]] [--assignee-field <Field>]
5716
5719
  Builds the CSV on the server into the workspace files (/exports) and
5717
5720
  returns a jobId at once. Up to 50,000 rows; one export per workspace.
5718
5721
  dench crm exports get <jobId>
@@ -5757,7 +5760,7 @@ Analytics (the dashboard strip above every object table — same math the UI dra
5757
5760
  that saved view's own dashboard (viewAnalytics; null when it inherits).
5758
5761
  dench crm analytics compute <object> [--view <view-name>] [--period this_week|this_month|last_month|this_quarter|last_quarter|this_year]
5759
5762
  [--panel <id> ...] [--panels '<JSON array of panel defs>'] [--filters '<FilterGroup JSON>'] [--json]
5760
- [--assigned-to me|unassigned|<userId|email> | --mine] [--assignee-field <Field>]
5763
+ [--assigned-to me|unassigned|<userId|email>[,…] | --mine] [--assignee-field <Field>]
5761
5764
  Chart-ready buckets / series / values for the stored dashboard, a
5762
5765
  subset of its panels (--panel), or ad-hoc definitions (--panels; nothing
5763
5766
  is persisted). --period scopes every panel AND fills previousValue from
@@ -321,7 +321,7 @@ const assigneeScopeRequest = {
321
321
  .string()
322
322
  .optional()
323
323
  .describe(
324
- 'Personal scope: "me" (the signed-in member / the human behind an agent session), "unassigned", or a member userId or email. Adds one has_any / is_empty rule on the object\'s assignee user field; rows, totalCount, sums and analytics all follow it. Never saved onto the view.',
324
+ 'Personal scope: "me" (the signed-in member / the human behind an agent session), "unassigned", a member userId or email, or a comma-separated list of people (me and member ids or emails). Several people add one has_any rule (rows assigned to any of them); "unassigned" is exclusive and is is_empty. Rows, totalCount, sums and analytics all follow it. Never saved onto the view.',
325
325
  ),
326
326
  assigneeField: z
327
327
  .string()
@@ -336,6 +336,10 @@ const assigneeScopeResponse = z
336
336
  field: z.string().describe("The user field the scope keyed on."),
337
337
  target: z.union([
338
338
  z.object({ kind: z.literal("user"), userId: z.string() }),
339
+ z.object({
340
+ kind: z.literal("users"),
341
+ userIds: z.array(z.string()),
342
+ }),
339
343
  z.object({ kind: z.literal("unassigned") }),
340
344
  ]),
341
345
  })
@@ -2684,6 +2688,55 @@ const campaignTargeting = z.object({
2684
2688
  * dropped, since dropping it would quietly widen the audience.
2685
2689
  */
2686
2690
  const campaignTargetingInput = campaignTargeting.strict();
2691
+ /**
2692
+ * The most values a builder draft keeps per targeting list: Convex's
2693
+ * `ONBOARDING_LIST_MAX` (convex/lib/onboardingCampaign/validators.ts), which
2694
+ * this build cannot import; a test keeps the two equal.
2695
+ */
2696
+ export const CAMPAIGN_BUILDER_LIST_MAX = 12;
2697
+ const CAMPAIGN_BUILDER_LIST_LABELS = {
2698
+ titles: "Job roles",
2699
+ locations: "Locations",
2700
+ companySizes: "Company size",
2701
+ industries: "Industries",
2702
+ excludes: "Exclusions",
2703
+ companies: "Companies",
2704
+ companyTypes: "Company type",
2705
+ } as const;
2706
+ /**
2707
+ * Why a builder save's targeting would be refused, mirroring
2708
+ * `targetingProblem` in convex/lib/outreachSignalCampaign/draft.ts: a list
2709
+ * with more than `CAMPAIGN_BUILDER_LIST_MAX` distinct values is refused
2710
+ * there rather than trimmed. Checked in the request schema so API, MCP and
2711
+ * CLI callers are refused with the same words before the save reaches
2712
+ * Convex (#2989). A lookalike save is not checked: its targeting comes from
2713
+ * the lookalike.
2714
+ */
2715
+ function refineBuilderTargeting(
2716
+ input: {
2717
+ targeting: Record<string, string[] | undefined>;
2718
+ lookalike?: unknown;
2719
+ },
2720
+ ctx: z.RefinementCtx,
2721
+ ) {
2722
+ if (input.lookalike) return;
2723
+ for (const [key, label] of Object.entries(CAMPAIGN_BUILDER_LIST_LABELS)) {
2724
+ const distinct = new Set(
2725
+ (input.targeting[key] ?? [])
2726
+ .map((value) => value.trim().toLowerCase())
2727
+ .filter((value) => value.length > 0),
2728
+ );
2729
+ if (distinct.size > CAMPAIGN_BUILDER_LIST_MAX)
2730
+ ctx.addIssue({
2731
+ code: "custom",
2732
+ path: ["targeting", key],
2733
+ message: `${label} can have up to ${CAMPAIGN_BUILDER_LIST_MAX}.`,
2734
+ });
2735
+ }
2736
+ }
2737
+ const campaignBuilderTargetingInput = campaignTargetingInput.describe(
2738
+ `Each list holds at most ${CAMPAIGN_BUILDER_LIST_MAX} values; pick the most important ones.`,
2739
+ );
2687
2740
  const campaignSignalTerms = z
2688
2741
  .object({
2689
2742
  post_engagement: z
@@ -3470,7 +3523,7 @@ export const requestSchemas: Record<string, ZodTypeAny> = {
3470
3523
  "campaigns.builder.save": z
3471
3524
  .object({
3472
3525
  clientRequestId: campaignClientRequestId,
3473
- targeting: campaignTargetingInput,
3526
+ targeting: campaignBuilderTargetingInput,
3474
3527
  signals: z.array(campaignSignal),
3475
3528
  signalTerms: campaignSignalTerms.optional(),
3476
3529
  findMoreMatching: z
@@ -3486,7 +3539,8 @@ export const requestSchemas: Record<string, ZodTypeAny> = {
3486
3539
  'For source lookalike: the edited result of builder lookalike, with signals ["lookalike"].',
3487
3540
  ),
3488
3541
  })
3489
- .strict(),
3542
+ .strict()
3543
+ .superRefine(refineBuilderTargeting),
3490
3544
  "campaigns.builder.get": z.object({ draftId: z.string() }).strict(),
3491
3545
  "campaigns.builder.leads": z.object({ draftId: z.string() }).strict(),
3492
3546
  "campaigns.builder.build": z.object({ draftId: z.string() }).strict(),
@@ -9018,7 +9072,7 @@ export const responseExamples: Record<string, unknown> = {
9018
9072
  ],
9019
9073
  },
9020
9074
  "search.answer": {
9021
- answer: "Dench is an AI agent workspace with a built-in CRM.",
9075
+ answer: "Dench is an AI Revenue Engine and CRM.",
9022
9076
  citations: [
9023
9077
  {
9024
9078
  url: "https://www.dench.com",
@@ -114,7 +114,7 @@ export const APP_SDK_OPERATIONS: readonly AppSdkOperationInfo[] = [
114
114
  {"id":"campaigns.builder.get","group":"campaigns","summary":"Read signal build progress, preview people, messages and errors.","cli":"dench campaign builder get","method":"GET","path":"/campaigns/builder/drafts/{draftId}","permission":"campaigns:read","pathParams":["draftId"]},
115
115
  {"id":"campaigns.builder.leads","group":"campaigns","summary":"Read every lead a signal build kept (not just the five previewed): person, company, LinkedIn URL and the signal's evidence.","cli":"dench campaign builder leads","method":"GET","path":"/campaigns/builder/drafts/{draftId}/leads","permission":"campaigns:read","pathParams":["draftId"]},
116
116
  {"id":"campaigns.builder.build","group":"campaigns","summary":"Start the same billable signal/audience/message build used by the UI; poll the draft for progress.","cli":"dench campaign builder build","method":"POST","path":"/campaigns/builder/drafts/{draftId}/build","permission":"campaigns:write","pathParams":["draftId"]},
117
- {"id":"campaigns.builder.create","group":"campaigns","summary":"Create a campaign from a reviewed signal draft. Does not launch the campaign.","cli":"dench campaign builder create","method":"POST","path":"/campaigns/builder/drafts/{draftId}/create","permission":"campaigns:write","pathParams":["draftId"]},
117
+ {"id":"campaigns.builder.create","group":"campaigns","summary":"Create a campaign from a built signal draft (status ready; a changed save reopens it until built again). Does not launch the campaign.","cli":"dench campaign builder create","method":"POST","path":"/campaigns/builder/drafts/{draftId}/create","permission":"campaigns:write","pathParams":["draftId"]},
118
118
  {"id":"campaigns.builder.opener","group":"campaigns","summary":"Edit or reset one preview person's opening line before creating the campaign.","cli":"dench campaign builder opener","method":"PUT","path":"/campaigns/builder/drafts/{draftId}/people/{leadId}/opener","permission":"campaigns:write","pathParams":["draftId","leadId"]},
119
119
  {"id":"campaigns.builder.drafts","group":"campaigns","summary":"List saved, unfinished campaign drafts that can be resumed.","cli":"dench campaign builder drafts","method":"GET","path":"/campaigns/builder/drafts","permission":"campaigns:read","pathParams":[]},
120
120
  {"id":"campaigns.builder.resume","group":"campaigns","summary":"Read a saved draft's setup (source, name, targeting, signals, terms, lookalike) to resume it.","cli":"dench campaign builder resume","method":"GET","path":"/campaigns/builder/drafts/{draftId}/setup","permission":"campaigns:read","pathParams":["draftId"]},
@@ -313,6 +313,7 @@ export const APP_SDK_OPERATIONS: readonly AppSdkOperationInfo[] = [
313
313
  {"id":"enrichment.person","group":"crm","summary":"Look up one person profile.","cli":"dench crm enrich cell","method":"POST","path":"/enrichment/person","permission":"crm:write","pathParams":[]},
314
314
  {"id":"enrichment.company","group":"crm","summary":"Look up one company profile.","cli":"dench crm enrich cell","method":"POST","path":"/enrichment/company","permission":"crm:write","pathParams":[]},
315
315
  {"id":"enrichment.person.contact","group":"crm","summary":"Look up verified emails and phones for people.","cli":"dench crm enrich cell","method":"POST","path":"/enrichment/person/contact","permission":"crm:write","pathParams":[]},
316
+ {"id":"enrichment.jobs.get","group":"crm","summary":"Read a queued contact lookup by the enrichmentId it returned. Free, and never submits the lookup again: poll this, not person/contact, until status is succeeded or failed.","cli":"dench crm enrich cell","method":"GET","path":"/enrichment/jobs/{enrichmentId}","permission":"crm:read","pathParams":["enrichmentId"]},
316
317
  {"id":"enrichment.profiles.bulk","group":"crm","summary":"Look up up to 100 people or company profiles without buying emails or phones. Pass kind (people|companies) and lookups; results preserve inputIndex. People require linkedinUrl or email; companies require domain or linkedinUrl.","cli":"dench crm enrich profiles","method":"POST","path":"/enrichment/profiles/bulk","permission":"crm:write","pathParams":[]},
317
318
  {"id":"enrichment.company.related","group":"crm","summary":"Read company employees, founders, funding, investors, acquisitions, or investments. Pass domain or linkedinUrl, kind, limit (1–100), and optional pageToken. Does not import CRM records or buy contacts.","cli":"dench companies related","method":"POST","path":"/enrichment/company/related","permission":"crm:read","pathParams":[]},
318
319
  {"id":"enrichment.search.preview","group":"crm","summary":"Preview how many records a find would return.","cli":"dench leads find --limit 1","method":"POST","path":"/enrichment/search/preview","permission":"crm:read","pathParams":[]},
@@ -1708,6 +1708,18 @@ function sharedSenderNotes(rows: SenderRow[], channel: string): string[] {
1708
1708
  );
1709
1709
  }
1710
1710
 
1711
+ /**
1712
+ * What to run after saving a draft's outreach. Create refuses a draft
1713
+ * nobody was found for yet, or one a changed save reopened (#2989: agents
1714
+ * followed a bare "create" here and were refused).
1715
+ */
1716
+ export function nextBuilderStep(status: string, draftId: string): string {
1717
+ if (status === "editing" || status === "failed")
1718
+ return `dench campaign builder build ${draftId}`;
1719
+ if (status === "building") return `dench campaign builder get ${draftId}`;
1720
+ return `dench campaign builder create ${draftId}`;
1721
+ }
1722
+
1711
1723
  function failedBuildMessage(draft: RunDraft, draftId: string): string {
1712
1724
  if (draft.errorCode === "out_of_credits")
1713
1725
  return `Finding people stopped: the workspace is out of credits. Add credits (dench billing topup --amount 10 prints a link), then run dench campaign builder run --draft ${draftId} again.`;
@@ -2126,7 +2138,7 @@ export async function runCampaignAgentCommand(
2126
2138
  steps: draft.workflowSteps ?? draft.draftSteps ?? draft.steps ?? [],
2127
2139
  sending: draft.sending ?? null,
2128
2140
  approvalMode: draft.approvalMode ?? "manual",
2129
- next: `dench campaign builder create ${input.draftId}`,
2141
+ next: nextBuilderStep(draft.status, String(input.draftId)),
2130
2142
  });
2131
2143
  }
2132
2144
  if (verb === "estimate") {
@@ -26,6 +26,12 @@ export type ConvexOperation = {
26
26
  fixedArgs?: Record<string, unknown>;
27
27
  /** Reshape validated input into backend args (e.g. update-many -> batch ops). */
28
28
  transformArgs?: (input: Record<string, unknown>) => Record<string, unknown>;
29
+ /**
30
+ * When set, a `null` result from the Convex function becomes a 404
31
+ * `{ code: "not_found", message }` instead of `200 null` — pairs with
32
+ * `missingAsNull: true` so expected 404 lookups never throw inside Convex.
33
+ */
34
+ notFoundOnNull?: string;
29
35
  };
30
36
 
31
37
  export type GatewayOperation = {
@@ -570,7 +576,7 @@ const rawApiOperations = [
570
576
  id: "campaigns.builder.create",
571
577
  group: "campaigns",
572
578
  summary:
573
- "Create a campaign from a reviewed signal draft. Does not launch the campaign.",
579
+ "Create a campaign from a built signal draft (status ready; a changed save reopens it until built again). Does not launch the campaign.",
574
580
  cli: "dench campaign builder create",
575
581
  method: "POST",
576
582
  path: "/campaigns/builder/drafts/{draftId}/create",
@@ -1757,10 +1763,12 @@ const rawApiOperations = [
1757
1763
  transformArgs: (input) => ({
1758
1764
  objectName: input.objectName,
1759
1765
  entryId: input.entryId,
1766
+ missingAsNull: true,
1760
1767
  ...(input.withContext === true || input.withContext === "true"
1761
1768
  ? { withContext: true }
1762
1769
  : {}),
1763
1770
  }),
1771
+ notFoundOnNull: "Entry not found",
1764
1772
  },
1765
1773
  }),
1766
1774
  op({
@@ -3350,6 +3358,27 @@ const rawApiOperations = [
3350
3358
  responseSchema: anyResponse,
3351
3359
  backend: gateway("POST", "/enrichment/person/contact"),
3352
3360
  }),
3361
+ op({
3362
+ id: "enrichment.jobs.get",
3363
+ group: "crm",
3364
+ summary:
3365
+ "Read a queued contact lookup by the enrichmentId it returned. Free, and never submits the lookup again: poll this, not person/contact, until status is succeeded or failed.",
3366
+ cli: "dench crm enrich cell",
3367
+ method: "GET",
3368
+ path: "/enrichment/jobs/{enrichmentId}",
3369
+ requestSchema: z
3370
+ .object({
3371
+ enrichmentId: z
3372
+ .string()
3373
+ .trim()
3374
+ .min(1)
3375
+ .max(200)
3376
+ .describe("The enrichmentId a queued person/contact call returned."),
3377
+ })
3378
+ .strict(),
3379
+ responseSchema: anyResponse,
3380
+ backend: gateway("GET", "/enrichment/jobs/{enrichmentId}"),
3381
+ }),
3353
3382
  op({
3354
3383
  id: "enrichment.profiles.bulk",
3355
3384
  group: "crm",