@everyai/cli 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -41,7 +41,7 @@ Codex's repo-scoped marketplace location is `.agents/plugins/marketplace.json`.
41
41
  The CLI talks to the same Every MCP server (`admin-mcp.every.ai`) and inherits its full tool surface automatically — new tools appear with no CLI upgrade. What the CLI adds:
42
42
 
43
43
  - **Portability** — one install + one login covers every agent and machine context; remote-MCP config is per-host, per-format, and often impossible in CI.
44
- - **Safety gates** — reads run freely; writes require `--yes`; destructive actions (sends, deletes, voids, payments) additionally require `--allow-destructive`; `--read-only` (or `EVERY_READ_ONLY=1`) locks everything else out. Classifications are enforced locally — including for tools whose server annotations are too optimistic. When trusted MCP metadata asks for an ordinary-write text confirmation, the CLI forwards the server's exact phrase and retries once.
44
+ - **Safety gates** — reads run freely; writes require `--yes`; destructive actions (sends, deletes, voids, payments) additionally require `--allow-destructive`; `--read-only` (or `EVERY_READ_ONLY=1`) locks everything else out. Classifications are enforced locally — including for tools whose server annotations are too optimistic. `every tool call deal_outreach` is destructive for all of its actions because it can send a deal's message. The short commands gate by action: `every deal outreach edit` and `cancel` are writes, and `every deal outreach send` is destructive. `update_deal` is a write. When trusted MCP metadata asks for an ordinary-write text confirmation, the CLI forwards the server's exact phrase and retries once.
45
45
  - **Deterministic output** — a stable `--json` envelope and exit-code taxonomy an agent can parse and branch on.
46
46
 
47
47
  ## Commands
@@ -65,14 +65,40 @@ every policy explain <name> # classification + exactly what running it requir
65
65
  # Run any tool
66
66
  every tool call <name> [--args file.json|-] [--arg k=v ...] [--yes] [--allow-destructive] [--read-only]
67
67
 
68
- # Curated aliases (same gates, nicer flags)
68
+ # Short commands (same gates, nicer flags; each calls one tool)
69
69
  every invoice list [--status <s>] [--search <q>] [--limit <n>]
70
70
  every invoice create (--company <name> | --person <name> | --company-id <id> | --person-id <id>) --amount <n>
71
71
  # write: needs --yes
72
- every invoice send <invoice_id> # destructive: needs --yes --allow-destructive
73
- every deal list [--stage <s>] [--search <q>]
74
- every deal move <deal_id> <stage> # write: needs --yes
72
+ every invoice send <invoice_id> # shows the recipients, then needs --yes
73
+ every proposal send <proposal_id> # shows the recipients, then needs --yes
74
+ every recipients get|set <party> --kind invoice|proposal
75
+ every company list [--search <q>] [--limit <n>]
76
+ every company view <company_id>
77
+ every company create --name <name> [--email] [--phone] [--website] [--industry] [--address] [--lead-source] [--notes]
78
+ # write: needs --yes
75
79
  every person list [--search <q>] # People
80
+ every person view <person_id>
81
+ every person create --name <name> [--email] [--phone] [--job-title] [--company] [--location] [--headline] [--industry] [--address] [--notes]
82
+ # write: needs --yes
83
+ every deal stages # this workspace's stages: label, key, role, criteria
84
+ every deal list [--stage <s>] [--search <q>] [--limit <n>] # <s>: a stage key or label
85
+ [--attention needs_reply,step_due,draft_ready,stale] [--stale-days <n>]
86
+ [--owner <me|email|id> | --mine] [--since <iso time>] [--sort last_activity_at]
87
+ every deal view <deal_id> [--plan] [--draft] [--auto-sends]
88
+ every deal create (--person-id <id> | --company-id <id> | --name <name> [--email <email>])
89
+ [--stage <s>] [--deal-name <name>] [--value <n>] [--owner <owner>] [--goal <text>]
90
+ # write: needs --yes
91
+ every deal update <deal_id> [--name <name>] [--value <n>] [--owner <owner>]
92
+ [--person-id <id> | --company-id <id>] [--add-member <id> ...] [--remove-member <id> ...]
93
+ # write: needs --yes; a flag you leave out does not change
94
+ every deal move <deal_id> <stage> # write: needs --yes; stage = key or label
95
+ every deal outreach edit <deal_id> [--subject <text>] [--body <text> | --body-file <path>]
96
+ [--recipient <email>] [--thread <id|new>] # write: needs --yes
97
+ every deal outreach send <deal_id> [--draft-version <v>]
98
+ # destructive: needs --yes --allow-destructive;
99
+ # the owner then approves the send in Every
100
+ every deal outreach cancel <deal_id> --send-id <id> # write: needs --yes
101
+ every approvals [--all] # requests that wait in Every: Settings > Approvals
76
102
 
77
103
  # Teach your coding agent to use all of this well
78
104
  every skills install claude # → .claude/skills/use-every/
@@ -118,6 +144,10 @@ Server-side human approvals never trigger an automatic destructive retry. If Eve
118
144
 
119
145
  In `--json` mode, a server approval response uses exit `4` and includes a structured `error.mcp_gate` object. After local `--yes` or interactive consent, `type: "text_confirmation"` is retried once automatically; `type: "human_approval"` is returned to the caller without retrying.
120
146
 
147
+ ## Scheduled agent runs
148
+
149
+ The bundled `use-every` skill has an **Agent automation** part: the routine for an agent that runs the owner's deals and prospects on a schedule (start-of-run priorities and pending approvals, the attention sweep, follow-ups through `deal_outreach`, plan steps, stage moves, prune and restore, prospect triage). The server returns the same text from `get_started` with `topic=automation`. A send waits for the owner in Every → Settings → Approvals for up to 24 hours; the next run repeats the identical command.
150
+
121
151
  ## Headless / CI
122
152
 
123
153
  Set `EVERY_TOKEN` to a valid access token to skip the browser flow entirely. `login` requires a TTY by design and fails fast (exit `3`) without one; `signup` does not need one.
@@ -1,11 +1,12 @@
1
1
  import { randomUUID } from 'node:crypto';
2
2
  import { CliError } from '../lib/errors.js';
3
3
  import { ExitCode } from '../lib/exit-codes.js';
4
+ import { emit } from '../lib/output.js';
4
5
  import { documentKind, preservedExclusions, record, recipientBinding, recipientLines } from '../lib/recipients.js';
5
- import { executeToolCall, invokeToolCall, } from './tools.js';
6
+ import { renderTable, shortTime } from '../lib/table.js';
7
+ import { executeToolCall, invokeToolCall, toolCallHuman, } from './tools.js';
6
8
  const INVOICE_STATUSES = new Set(['draft', 'issued', 'void']);
7
9
  const PAYMENT_STATUSES = new Set(['unpaid', 'paid', 'overdue', 'partial']);
8
- const DEAL_STAGES = new Set(['lead', 'opportunity', 'won', 'lost']);
9
10
  // list_companies/list_people (the live People/Companies search tools) take a
10
11
  // free-text `query` param — the retired list_clients/list_contacts tools took `name`.
11
12
  const NETWORK_SEARCH_QUERY_PARAM = 'query';
@@ -31,12 +32,7 @@ function parseLimit(value) {
31
32
  }
32
33
  return limit;
33
34
  }
34
- function assertDealStage(stage) {
35
- if (!DEAL_STAGES.has(stage)) {
36
- throw new CliError(`stage must be one of: ${Array.from(DEAL_STAGES).join(', ')}`, ExitCode.USAGE, 'usage');
37
- }
38
- }
39
- function addLimit(args, value) {
35
+ export function addLimit(args, value) {
40
36
  const limit = parseLimit(value);
41
37
  if (limit !== undefined)
42
38
  args.limit = limit;
@@ -67,7 +63,7 @@ function parsePositiveNumber(value, flag) {
67
63
  }
68
64
  return parsed;
69
65
  }
70
- function nonEmpty(value) {
66
+ export function nonEmpty(value) {
71
67
  const trimmed = value?.trim();
72
68
  return trimmed ? trimmed : undefined;
73
69
  }
@@ -409,18 +405,226 @@ export async function invoiceCreateCommand(opts = {}) {
409
405
  }
410
406
  export async function dealListCommand(opts = {}) {
411
407
  const args = {};
412
- if (opts.stage !== undefined) {
413
- assertDealStage(opts.stage);
408
+ // Stages are per-workspace (a key or a label, e.g. "lead" or "Discovery
409
+ // booked"); the server resolves them and answers stage_not_found with the
410
+ // workspace's live list, so there is no client-side stage check.
411
+ if (opts.stage !== undefined)
414
412
  args.stage = opts.stage;
415
- }
416
413
  if (opts.search !== undefined)
417
414
  args.search = opts.search;
418
415
  addLimit(args, opts.limit);
419
- await executeToolCall('list_deals', opts, async () => args);
416
+ // The attention-sweep filters (list_deals, 2026-11). A call without them
417
+ // sends the same arguments and prints the same output as before.
418
+ const sweep = dealSweepArgs(opts);
419
+ Object.assign(args, sweep);
420
+ const human = Object.keys(sweep).length > 0 ? dealTableHuman : undefined;
421
+ await withStageErrors(opts.stage, () => executeToolCall('list_deals', opts, async () => args, undefined, undefined, human));
422
+ }
423
+ export const ATTENTION_REASONS = ['needs_reply', 'step_due', 'draft_ready', 'stale'];
424
+ const DEAL_SORTS = new Set(['last_activity_at']);
425
+ function parseAttention(values) {
426
+ if (values === undefined)
427
+ return undefined;
428
+ const reasons = Array.from(new Set(values
429
+ .flatMap((value) => value.split(','))
430
+ .map((value) => value.trim())
431
+ .filter(Boolean)));
432
+ const unknown = reasons.filter((reason) => !ATTENTION_REASONS.includes(reason));
433
+ if (reasons.length === 0 || unknown.length > 0) {
434
+ throw new CliError(`--attention must be one or more of: ${ATTENTION_REASONS.join(', ')}`, ExitCode.USAGE, 'usage');
435
+ }
436
+ return reasons;
437
+ }
438
+ function dealSweepArgs(opts) {
439
+ const args = {};
440
+ const attention = parseAttention(opts.attention);
441
+ if (attention)
442
+ args.attention = attention;
443
+ if (opts.staleDays !== undefined) {
444
+ const days = Number(opts.staleDays);
445
+ if (!Number.isInteger(days) || days < 1) {
446
+ throw new CliError('--stale-days must be a whole number of days, 1 or more', ExitCode.USAGE, 'usage');
447
+ }
448
+ args.inactive_days = days;
449
+ }
450
+ const owner = nonEmpty(opts.owner);
451
+ if (opts.owner !== undefined && !owner) {
452
+ throw new CliError('--owner must be me, an email, or a user id', ExitCode.USAGE, 'usage');
453
+ }
454
+ if (opts.mine && owner && owner !== 'me') {
455
+ throw new CliError('Use --mine or --owner, not both', ExitCode.USAGE, 'usage');
456
+ }
457
+ if (opts.mine)
458
+ args.owner = 'me';
459
+ else if (owner)
460
+ args.owner = owner;
461
+ if (opts.since !== undefined) {
462
+ const since = opts.since.trim();
463
+ if (!since || Number.isNaN(Date.parse(since))) {
464
+ throw new CliError('--since must be an ISO 8601 time, for example 2026-11-01T00:00:00Z', ExitCode.USAGE, 'usage');
465
+ }
466
+ args.updated_since = since;
467
+ }
468
+ if (opts.sort !== undefined) {
469
+ if (!DEAL_SORTS.has(opts.sort)) {
470
+ throw new CliError(`--sort must be: ${Array.from(DEAL_SORTS).join(', ')}`, ExitCode.USAGE, 'usage');
471
+ }
472
+ args.sort = opts.sort;
473
+ }
474
+ return args;
475
+ }
476
+ function dealName(deal) {
477
+ return stringField(deal, ['display_name', 'name', 'label', 'contact', 'company']) ?? '';
478
+ }
479
+ function nextStepText(value) {
480
+ const step = record(value);
481
+ const title = typeof step.title === 'string' ? step.title : '';
482
+ if (!title)
483
+ return '';
484
+ return typeof step.do_by === 'string' && step.do_by ? `${title} (${step.do_by})` : title;
485
+ }
486
+ /** The deal table for the attention-sweep filters. It shows only what the server returned. */
487
+ export function dealTableHuman(data) {
488
+ const structured = record(data.structured_content);
489
+ if (!Array.isArray(structured.deals))
490
+ return toolCallHuman(data);
491
+ const deals = structured.deals.map(record);
492
+ if (deals.length === 0)
493
+ return 'No deals match these filters.';
494
+ const columns = [
495
+ { header: 'id', max: 36 },
496
+ { header: 'deal', max: 32 },
497
+ { header: 'stage', max: 20 },
498
+ ];
499
+ const cells = [
500
+ (deal) => String(deal.id ?? ''),
501
+ dealName,
502
+ (deal) => stringField(deal, ['stage_label', 'stage']) ?? '',
503
+ ];
504
+ if (deals.some((deal) => typeof deal.last_activity_at === 'string')) {
505
+ columns.push({ header: 'last activity', max: 16 });
506
+ cells.push((deal) => shortTime(deal.last_activity_at));
507
+ }
508
+ if (deals.some((deal) => nextStepText(deal.next_step))) {
509
+ columns.push({ header: 'next step', max: 48 });
510
+ cells.push((deal) => nextStepText(deal.next_step));
511
+ }
512
+ if (deals.some((deal) => Array.isArray(deal.attention) && deal.attention.length > 0)) {
513
+ columns.push({ header: 'attention' });
514
+ cells.push((deal) => (Array.isArray(deal.attention) ? deal.attention.join(', ') : ''));
515
+ }
516
+ const lines = [renderTable(columns, deals.map((deal) => cells.map((render) => render(deal))))];
517
+ const page = record(structured.pagination);
518
+ if (page.has_more === true) {
519
+ const total = typeof page.total_matched === 'number' ? ` of ${page.total_matched}` : '';
520
+ lines.push('', `Showing ${deals.length}${total} deals. Raise --limit to see more.`);
521
+ }
522
+ return lines.join('\n');
420
523
  }
421
524
  export async function dealMoveCommand(dealId, stage, opts = {}) {
422
- assertDealStage(stage);
423
- await executeToolCall('move_deal_stage', opts, async () => ({ deal_id: dealId, stage }));
525
+ await withStageErrors(stage, () => executeToolCall('move_deal_stage', opts, async () => ({ deal_id: dealId, stage })));
526
+ }
527
+ function stageName(stage) {
528
+ for (const field of ['label', 'key']) {
529
+ const value = stage[field];
530
+ if (typeof value === 'string' && value.trim())
531
+ return value.trim();
532
+ }
533
+ return undefined;
534
+ }
535
+ /** `Unknown stage "<input>". Available stages: Lead, Discovery booked, ...` */
536
+ export function unknownStageMessage(input, available) {
537
+ const names = Array.isArray(available)
538
+ ? available
539
+ .map((entry) => entry && typeof entry === 'object' ? stageName(entry) : undefined)
540
+ .filter((name) => name !== undefined)
541
+ : [];
542
+ const list = names.length ? names.join(', ') : 'run `every deal stages` to list them';
543
+ return `Unknown stage "${input}". Available stages: ${list}`;
544
+ }
545
+ // The server's stage_not_found refusal carries the workspace's live stage list
546
+ // (structuredContent.error.available_stages). Re-render it as one readable
547
+ // sentence; the error code, exit status and tool_error details are unchanged.
548
+ async function withStageErrors(input, run) {
549
+ try {
550
+ await run();
551
+ }
552
+ catch (err) {
553
+ if (err instanceof CliError && err.code === 'stage_not_found') {
554
+ const toolError = (err.details?.tool_error ?? {});
555
+ const stage = typeof toolError.stage === 'string' ? toolError.stage : input ?? '';
556
+ throw new CliError(unknownStageMessage(stage, toolError.available_stages), err.exitCode, err.code, err.details);
557
+ }
558
+ throw err;
559
+ }
560
+ }
561
+ function oneLine(value, max = 80) {
562
+ const text = typeof value === 'string' ? value.replace(/\s+/g, ' ').trim() : '';
563
+ return text.length > max ? `${text.slice(0, max - 3)}...` : text;
564
+ }
565
+ /** The ordered stage list from get_pipeline_settings' structured result. */
566
+ export function parsePipelineStages(structured) {
567
+ if (!structured || typeof structured !== 'object')
568
+ return [];
569
+ const record = structured;
570
+ const body = (record.result && typeof record.result === 'object' ? record.result : record);
571
+ let entries = body.stages;
572
+ // A server that predates customizable stages returns a map keyed by the
573
+ // four default stage names instead of the ordered list.
574
+ if (entries && typeof entries === 'object' && !Array.isArray(entries)) {
575
+ entries = Object.entries(entries).map(([key, value]) => ({
576
+ ...(value && typeof value === 'object' ? value : {}),
577
+ key,
578
+ label: key.charAt(0).toUpperCase() + key.slice(1),
579
+ role: LEGACY_STAGE_ROLES[key] ?? 'middle',
580
+ }));
581
+ }
582
+ if (!Array.isArray(entries))
583
+ return [];
584
+ return entries
585
+ .filter((entry) => Boolean(entry) && typeof entry === 'object')
586
+ .map((entry) => ({
587
+ key: String(entry.key ?? entry.name ?? ''),
588
+ label: String(entry.label ?? entry.display_name ?? entry.key ?? ''),
589
+ role: String(entry.role ?? ''),
590
+ criteria: typeof entry.criteria === 'string' ? entry.criteria : '',
591
+ ...(typeof entry.agent_can_move_to_stage === 'boolean'
592
+ ? { agent_can_move_to_stage: entry.agent_can_move_to_stage }
593
+ : {}),
594
+ }))
595
+ .filter((stage) => stage.key);
596
+ }
597
+ const LEGACY_STAGE_ROLES = {
598
+ lead: 'lead',
599
+ opportunity: 'middle',
600
+ won: 'won',
601
+ lost: 'lost',
602
+ };
603
+ export function stagesHuman(stages) {
604
+ if (!stages.length) {
605
+ return 'No pipeline stages returned. Run: every tool call get_pipeline_settings --json';
606
+ }
607
+ // Labels can be up to 40 characters (the server limit), so the column fits them all.
608
+ const labelWidth = Math.min(40, Math.max('label'.length, ...stages.map((s) => s.label.length)));
609
+ const keyWidth = Math.min(20, Math.max('key'.length, ...stages.map((s) => s.key.length)));
610
+ const roleWidth = Math.max('role'.length, ...stages.map((s) => s.role.length));
611
+ const lines = [
612
+ `${'label'.padEnd(labelWidth)} ${'key'.padEnd(keyWidth)} ${'role'.padEnd(roleWidth)} criteria`,
613
+ `${'-'.repeat(labelWidth)} ${'-'.repeat(keyWidth)} ${'-'.repeat(roleWidth)} ${'-'.repeat(8)}`,
614
+ ];
615
+ for (const stage of stages) {
616
+ lines.push(`${stage.label.padEnd(labelWidth)} ${stage.key.padEnd(keyWidth)} ${stage.role.padEnd(roleWidth)} ${oneLine(stage.criteria)}`);
617
+ }
618
+ lines.push('', 'Pass a key or a label to: every deal move <deal_id> <stage> | every deal list --stage <stage>');
619
+ return lines.join('\n');
620
+ }
621
+ export async function dealStagesCommand(opts = {}) {
622
+ const data = await invokeToolCall('get_pipeline_settings', opts);
623
+ const stages = parsePipelineStages(data.structured_content);
624
+ if (opts.json)
625
+ emit({ ...data, stages }, { json: true, staging: opts.staging });
626
+ else
627
+ process.stdout.write(`${stagesHuman(stages)}\n`);
424
628
  }
425
629
  export async function personListCommand(opts = {}) {
426
630
  const args = {};