@everyai/cli 0.8.1 → 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 +35 -5
- package/dist/commands/aliases.js +329 -17
- package/dist/commands/crm.js +453 -0
- package/dist/commands/docs.js +6 -0
- package/dist/commands/policy.js +4 -1
- package/dist/commands/tools.js +44 -8
- package/dist/index.js +260 -9
- package/dist/lib/config.js +9 -0
- package/dist/lib/mcp.js +43 -2
- package/dist/lib/policy.js +39 -0
- package/dist/lib/recipients.js +60 -0
- package/dist/lib/table.js +41 -0
- package/package.json +1 -1
- package/skills/use-every/SKILL.md +159 -10
package/dist/index.js
CHANGED
|
@@ -7,7 +7,8 @@ import { authStatusCommand, loginCommand, logoutCommand, orgCommand, orgSwitchCo
|
|
|
7
7
|
import { policyExplainCommand } from './commands/policy.js';
|
|
8
8
|
import { signupCommand, signupCompleteCommand, signupStatusCommand, } from './commands/signup.js';
|
|
9
9
|
import { toolCallCommand, toolsDescribeCommand, toolsListCommand, } from './commands/tools.js';
|
|
10
|
-
import {
|
|
10
|
+
import { approvalsCommand, companyCreateCommand, companyListCommand, companyViewCommand, dealCreateCommand, dealUpdateCommand, dealViewCommand, outreachCancelCommand, outreachEditCommand, outreachSendCommand, personCreateCommand, personViewCommand, } from './commands/crm.js';
|
|
11
|
+
import { dealListCommand, dealMoveCommand, dealStagesCommand, invoiceCreateCommand, invoiceListCommand, invoiceSendCommand, personListCommand, proposalSendCommand, recipientsGetCommand, recipientsSetCommand, } from './commands/aliases.js';
|
|
11
12
|
import { skillsInstallCommand, skillsListCommand } from './commands/skills.js';
|
|
12
13
|
import { CliError } from './lib/errors.js';
|
|
13
14
|
import { deprecationNote, emit, emitError } from './lib/output.js';
|
|
@@ -168,7 +169,7 @@ withGlobalOptions(toolsCommand
|
|
|
168
169
|
});
|
|
169
170
|
});
|
|
170
171
|
const toolCommand = withGlobalOptions(program.command('tool').description('Invoke a single Every MCP tool'));
|
|
171
|
-
function collectOption(value, previous) {
|
|
172
|
+
function collectOption(value, previous = []) {
|
|
172
173
|
previous.push(value);
|
|
173
174
|
return previous;
|
|
174
175
|
}
|
|
@@ -180,6 +181,19 @@ function withToolExecutionOptions(cmd) {
|
|
|
180
181
|
.option('--read-only', 'deny write, destructive, and AI-mediated tool calls')
|
|
181
182
|
.option('--timeout <secs>', 'tool call timeout in seconds');
|
|
182
183
|
}
|
|
184
|
+
/** The tool execution options of a parsed command, for the short commands. */
|
|
185
|
+
function executionOptions(opts) {
|
|
186
|
+
return {
|
|
187
|
+
json: opts.json,
|
|
188
|
+
staging: opts.staging,
|
|
189
|
+
// Commander represents --no-cache as cache:false.
|
|
190
|
+
noCache: opts.cache === false,
|
|
191
|
+
yes: opts.yes,
|
|
192
|
+
allowDestructive: opts.allowDestructive,
|
|
193
|
+
readOnly: opts.readOnly,
|
|
194
|
+
timeout: opts.timeout,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
183
197
|
const TOOL_CALL_HELP = [
|
|
184
198
|
'',
|
|
185
199
|
'Fastest full-tool argument forms:',
|
|
@@ -281,19 +295,49 @@ withGlobalOptions(withToolExecutionOptions(invoiceCommand
|
|
|
281
295
|
});
|
|
282
296
|
withGlobalOptions(withToolExecutionOptions(invoiceCommand
|
|
283
297
|
.command('send')
|
|
284
|
-
.description('
|
|
298
|
+
.description('Preview recipients, confirm, and send an invoice')
|
|
299
|
+
.option('--expect-digest <digest>', 'require the digest from the approved recipient preview')
|
|
285
300
|
.argument('<invoice_id>', 'invoice id'))).action(async (invoiceId, _options, command) => {
|
|
286
301
|
const opts = command.optsWithGlobals();
|
|
287
302
|
await invoiceSendCommand(invoiceId, {
|
|
288
303
|
json: opts.json,
|
|
289
304
|
staging: opts.staging,
|
|
290
|
-
noCache: opts.
|
|
305
|
+
noCache: opts.cache === false,
|
|
291
306
|
yes: opts.yes,
|
|
292
307
|
allowDestructive: opts.allowDestructive,
|
|
293
308
|
readOnly: opts.readOnly,
|
|
294
309
|
timeout: opts.timeout,
|
|
310
|
+
expectDigest: opts.expectDigest,
|
|
295
311
|
});
|
|
296
312
|
});
|
|
313
|
+
const proposalCommand = withToolExecutionOptions(withGlobalOptions(program.command('proposal').description('Work with proposals')));
|
|
314
|
+
withGlobalOptions(withToolExecutionOptions(proposalCommand.command('send').description('Preview recipients, confirm, and send a proposal')
|
|
315
|
+
.option('--expect-digest <digest>', 'require the digest from the approved recipient preview')
|
|
316
|
+
.argument('<proposal>', 'proposal id'))).action(async (proposal, _options, command) => {
|
|
317
|
+
const opts = command.optsWithGlobals();
|
|
318
|
+
await proposalSendCommand(proposal, { ...opts, noCache: opts.cache === false });
|
|
319
|
+
});
|
|
320
|
+
const recipientsCommand = withToolExecutionOptions(withGlobalOptions(program.command('recipients').description('Read or set invoice and proposal recipients')));
|
|
321
|
+
for (const action of ['get', 'set']) {
|
|
322
|
+
const command = withGlobalOptions(withToolExecutionOptions(recipientsCommand.command(action).description(`${action === 'get' ? 'Read' : 'Set'} exact To and CC recipients`)
|
|
323
|
+
.argument('<party>', 'Person or Company name')
|
|
324
|
+
.requiredOption('--kind <kind>', 'invoice or proposal')
|
|
325
|
+
.option('--company <name>', 'Company name to resolve via list_companies')
|
|
326
|
+
.option('--person <name>', 'Person name to resolve via list_people')
|
|
327
|
+
.option('--company-id <id>', 'Company id; skips name resolution')
|
|
328
|
+
.option('--person-id <id>', 'Person id; skips name resolution')));
|
|
329
|
+
if (action === 'set') {
|
|
330
|
+
command.requiredOption('--to <email-or-id>', 'To email address or eligible method id')
|
|
331
|
+
.option('--cc <email-or-id>', 'CC email address or eligible method id; repeat for more recipients', collectOption)
|
|
332
|
+
.option('--clear-cc', 'remove all CC recipients');
|
|
333
|
+
}
|
|
334
|
+
command.action(async (party, _options, cmd) => {
|
|
335
|
+
const opts = cmd.optsWithGlobals();
|
|
336
|
+
// Commander represents --no-cache as cache:false.
|
|
337
|
+
opts.noCache = opts.cache === false;
|
|
338
|
+
await (action === 'get' ? recipientsGetCommand : recipientsSetCommand)(party, opts);
|
|
339
|
+
});
|
|
340
|
+
}
|
|
297
341
|
const dealCommand = withToolExecutionOptions(withGlobalOptions(program
|
|
298
342
|
.command('deal')
|
|
299
343
|
.description('Work with deals')
|
|
@@ -301,9 +345,15 @@ const dealCommand = withToolExecutionOptions(withGlobalOptions(program
|
|
|
301
345
|
withGlobalOptions(withToolExecutionOptions(dealCommand
|
|
302
346
|
.command('list')
|
|
303
347
|
.description('List deals')
|
|
304
|
-
.option('--stage <s>', 'deal stage filter')
|
|
348
|
+
.option('--stage <s>', 'deal stage filter: a key or label from `every deal stages`')
|
|
305
349
|
.option('--search <q>', 'deal search query')
|
|
306
|
-
.option('--limit <n>', 'maximum number of deals to return')
|
|
350
|
+
.option('--limit <n>', 'maximum number of deals to return')
|
|
351
|
+
.option('--attention <reason>', 'only deals that need work: needs_reply, step_due, draft_ready, stale; repeat or use a comma list', collectOption)
|
|
352
|
+
.option('--stale-days <n>', 'only deals with no activity for at least this many days')
|
|
353
|
+
.option('--owner <owner>', 'only deals owned by: me, a teammate\'s email, or a user id')
|
|
354
|
+
.option('--mine', 'only your deals (same as --owner me)')
|
|
355
|
+
.option('--since <time>', 'only deals changed at or after this ISO 8601 time')
|
|
356
|
+
.option('--sort <field>', 'sort order: last_activity_at'))).action(async (_options, command) => {
|
|
307
357
|
const opts = command.optsWithGlobals();
|
|
308
358
|
await dealListCommand({
|
|
309
359
|
json: opts.json,
|
|
@@ -316,13 +366,116 @@ withGlobalOptions(withToolExecutionOptions(dealCommand
|
|
|
316
366
|
stage: opts.stage,
|
|
317
367
|
search: opts.search,
|
|
318
368
|
limit: opts.limit,
|
|
369
|
+
attention: opts.attention,
|
|
370
|
+
staleDays: opts.staleDays,
|
|
371
|
+
owner: opts.owner,
|
|
372
|
+
mine: opts.mine,
|
|
373
|
+
since: opts.since,
|
|
374
|
+
sort: opts.sort,
|
|
319
375
|
});
|
|
320
376
|
});
|
|
377
|
+
withGlobalOptions(withToolExecutionOptions(dealCommand
|
|
378
|
+
.command('view')
|
|
379
|
+
.description('Show one deal')
|
|
380
|
+
.argument('<deal_id>', 'deal id')
|
|
381
|
+
.option('--plan', 'add every open plan step')
|
|
382
|
+
.option('--draft', 'add the unsent draft and its draft version')
|
|
383
|
+
.option('--auto-sends', 'add scheduled and recent sends'))).action(async (dealId, _options, command) => {
|
|
384
|
+
const opts = command.optsWithGlobals();
|
|
385
|
+
await dealViewCommand(dealId, { ...executionOptions(opts), plan: opts.plan, draft: opts.draft, autoSends: opts.autoSends });
|
|
386
|
+
});
|
|
387
|
+
withGlobalOptions(withToolExecutionOptions(dealCommand
|
|
388
|
+
.command('create')
|
|
389
|
+
.description('Create a deal with an existing Person or Company, or with a new Person')
|
|
390
|
+
.option('--person-id <id>', 'existing Person id')
|
|
391
|
+
.option('--company-id <id>', 'existing Company id')
|
|
392
|
+
.option('--name <name>', 'name of a new Person (when no id is given)')
|
|
393
|
+
.option('--email <email>', 'email of a new Person')
|
|
394
|
+
.option('--stage <s>', 'stage key or label (default: Lead)')
|
|
395
|
+
.option('--deal-name <name>', 'what the deal is called, for example "Q3 brand refresh"')
|
|
396
|
+
.option('--value <amount>', 'expected value in the workspace currency')
|
|
397
|
+
.option('--owner <owner>', 'deal owner: me, a teammate\'s email, or a user id')
|
|
398
|
+
.option('--goal <text>', 'what the deal sells, in one or two sentences'))).action(async (_options, command) => {
|
|
399
|
+
const opts = command.optsWithGlobals();
|
|
400
|
+
await dealCreateCommand({
|
|
401
|
+
...executionOptions(opts),
|
|
402
|
+
personId: opts.personId,
|
|
403
|
+
companyId: opts.companyId,
|
|
404
|
+
name: opts.name,
|
|
405
|
+
email: opts.email,
|
|
406
|
+
stage: opts.stage,
|
|
407
|
+
dealName: opts.dealName,
|
|
408
|
+
value: opts.value,
|
|
409
|
+
owner: opts.owner,
|
|
410
|
+
goal: opts.goal,
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
withGlobalOptions(withToolExecutionOptions(dealCommand
|
|
414
|
+
.command('update')
|
|
415
|
+
.description('Change deal fields; a flag you leave out does not change')
|
|
416
|
+
.argument('<deal_id>', 'deal id')
|
|
417
|
+
.option('--name <name>', 'what the deal is called; "" resets the default name')
|
|
418
|
+
.option('--value <amount>', 'expected value; 0 clears it')
|
|
419
|
+
.option('--owner <owner>', 'new owner: me, a teammate\'s email, or a user id')
|
|
420
|
+
.option('--person-id <id>', 'set the deal\'s Person')
|
|
421
|
+
.option('--company-id <id>', 'set the deal\'s Company')
|
|
422
|
+
.option('--add-member <id>', 'add a teammate (user id or email); repeatable', collectOption)
|
|
423
|
+
.option('--remove-member <id>', 'remove a teammate (user id or email); waits for approval in Every; repeatable', collectOption))).action(async (dealId, _options, command) => {
|
|
424
|
+
const opts = command.optsWithGlobals();
|
|
425
|
+
await dealUpdateCommand(dealId, {
|
|
426
|
+
...executionOptions(opts),
|
|
427
|
+
name: opts.name,
|
|
428
|
+
value: opts.value,
|
|
429
|
+
owner: opts.owner,
|
|
430
|
+
personId: opts.personId,
|
|
431
|
+
companyId: opts.companyId,
|
|
432
|
+
addMember: opts.addMember,
|
|
433
|
+
removeMember: opts.removeMember,
|
|
434
|
+
});
|
|
435
|
+
});
|
|
436
|
+
const outreachCommand = withToolExecutionOptions(withGlobalOptions(dealCommand.command('outreach').description("Edit, send, or cancel a deal's message")));
|
|
437
|
+
withGlobalOptions(withToolExecutionOptions(outreachCommand
|
|
438
|
+
.command('edit')
|
|
439
|
+
.description("Edit the deal's unsent draft (write: needs --yes)")
|
|
440
|
+
.argument('<deal_id>', 'deal id')
|
|
441
|
+
.option('--subject <text>', 'new email subject')
|
|
442
|
+
.option('--body <text>', 'new message text')
|
|
443
|
+
.option('--body-file <path>', 'read the new message text from a file; - for stdin')
|
|
444
|
+
.option('--recipient <email>', 'new email recipient: an email of a Person on the deal')
|
|
445
|
+
.option('--thread <id>', 'Gmail thread of the deal to reply in, or "new"')
|
|
446
|
+
.option('--draft-version <v>', 'refuse the edit if the draft changed since this version'))).action(async (dealId, _options, command) => {
|
|
447
|
+
const opts = command.optsWithGlobals();
|
|
448
|
+
await outreachEditCommand(dealId, {
|
|
449
|
+
...executionOptions(opts),
|
|
450
|
+
subject: opts.subject,
|
|
451
|
+
body: opts.body,
|
|
452
|
+
bodyFile: opts.bodyFile,
|
|
453
|
+
recipient: opts.recipient,
|
|
454
|
+
thread: opts.thread,
|
|
455
|
+
draftVersion: opts.draftVersion,
|
|
456
|
+
});
|
|
457
|
+
});
|
|
458
|
+
withGlobalOptions(withToolExecutionOptions(outreachCommand
|
|
459
|
+
.command('send')
|
|
460
|
+
.description("Preview, confirm, and send the deal's draft; the owner approves it in Every (destructive)")
|
|
461
|
+
.argument('<deal_id>', 'deal id')
|
|
462
|
+
.option('--draft-version <v>', 'send this exact draft version without reading the draft first'))).action(async (dealId, _options, command) => {
|
|
463
|
+
const opts = command.optsWithGlobals();
|
|
464
|
+
await outreachSendCommand(dealId, { ...executionOptions(opts), draftVersion: opts.draftVersion });
|
|
465
|
+
});
|
|
466
|
+
withGlobalOptions(withToolExecutionOptions(outreachCommand
|
|
467
|
+
.command('cancel')
|
|
468
|
+
.description('Stop a scheduled or held send (write: needs --yes)')
|
|
469
|
+
.argument('<deal_id>', 'deal id')
|
|
470
|
+
.requiredOption('--send-id <id>', 'send id from every deal view <deal_id> --auto-sends'))).action(async (dealId, _options, command) => {
|
|
471
|
+
const opts = command.optsWithGlobals();
|
|
472
|
+
await outreachCancelCommand(dealId, { ...executionOptions(opts), sendId: opts.sendId });
|
|
473
|
+
});
|
|
321
474
|
withGlobalOptions(withToolExecutionOptions(dealCommand
|
|
322
475
|
.command('move')
|
|
323
476
|
.description('Move a deal to another stage')
|
|
324
477
|
.argument('<deal_id>', 'deal id')
|
|
325
|
-
.argument('<stage>', 'target stage'))).action(async (dealId, stage, _options, command) => {
|
|
478
|
+
.argument('<stage>', 'target stage: a key or label from `every deal stages`'))).action(async (dealId, stage, _options, command) => {
|
|
326
479
|
const opts = command.optsWithGlobals();
|
|
327
480
|
await dealMoveCommand(dealId, stage, {
|
|
328
481
|
json: opts.json,
|
|
@@ -334,6 +487,20 @@ withGlobalOptions(withToolExecutionOptions(dealCommand
|
|
|
334
487
|
timeout: opts.timeout,
|
|
335
488
|
});
|
|
336
489
|
});
|
|
490
|
+
withGlobalOptions(withToolExecutionOptions(dealCommand
|
|
491
|
+
.command('stages')
|
|
492
|
+
.description("List this workspace's pipeline stages (label, key, role, criteria)"))).action(async (_options, command) => {
|
|
493
|
+
const opts = command.optsWithGlobals();
|
|
494
|
+
await dealStagesCommand({
|
|
495
|
+
json: opts.json,
|
|
496
|
+
staging: opts.staging,
|
|
497
|
+
noCache: opts.noCache,
|
|
498
|
+
yes: opts.yes,
|
|
499
|
+
allowDestructive: opts.allowDestructive,
|
|
500
|
+
readOnly: opts.readOnly,
|
|
501
|
+
timeout: opts.timeout,
|
|
502
|
+
});
|
|
503
|
+
});
|
|
337
504
|
/**
|
|
338
505
|
* Register `list` under `every person` and under the hidden, deprecated
|
|
339
506
|
* `every contact` alias ("contact" is retired vocabulary: the product's people
|
|
@@ -361,10 +528,94 @@ function addPersonListCommand(parent, deprecation) {
|
|
|
361
528
|
});
|
|
362
529
|
});
|
|
363
530
|
}
|
|
364
|
-
|
|
531
|
+
const personCommand = withToolExecutionOptions(withGlobalOptions(program
|
|
365
532
|
.command('person')
|
|
366
533
|
.description('Work with People')
|
|
367
|
-
.addHelpText('after', TOOL_CALL_HELP)))
|
|
534
|
+
.addHelpText('after', TOOL_CALL_HELP)));
|
|
535
|
+
addPersonListCommand(personCommand);
|
|
536
|
+
withGlobalOptions(withToolExecutionOptions(personCommand
|
|
537
|
+
.command('view')
|
|
538
|
+
.description('Show one Person')
|
|
539
|
+
.argument('<person_id>', 'Person id'))).action(async (personId, _options, command) => {
|
|
540
|
+
await personViewCommand(personId, executionOptions(command.optsWithGlobals()));
|
|
541
|
+
});
|
|
542
|
+
withGlobalOptions(withToolExecutionOptions(personCommand
|
|
543
|
+
.command('create')
|
|
544
|
+
.description('Create a Person (write: needs --yes); search with every person list first')
|
|
545
|
+
.requiredOption('--name <name>', 'full name')
|
|
546
|
+
.option('--email <email>', 'primary email')
|
|
547
|
+
.option('--phone <phone>', 'primary phone')
|
|
548
|
+
.option('--job-title <title>', 'job title')
|
|
549
|
+
.option('--company <name>', 'employer name as text')
|
|
550
|
+
.option('--location <text>', 'location')
|
|
551
|
+
.option('--headline <text>', 'short headline')
|
|
552
|
+
.option('--industry <text>', 'industry')
|
|
553
|
+
.option('--address <text>', 'postal address')
|
|
554
|
+
.option('--notes <text>', 'notes'))).action(async (_options, command) => {
|
|
555
|
+
const opts = command.optsWithGlobals();
|
|
556
|
+
await personCreateCommand({
|
|
557
|
+
...executionOptions(opts),
|
|
558
|
+
name: opts.name,
|
|
559
|
+
email: opts.email,
|
|
560
|
+
phone: opts.phone,
|
|
561
|
+
jobTitle: opts.jobTitle,
|
|
562
|
+
company: opts.company,
|
|
563
|
+
location: opts.location,
|
|
564
|
+
headline: opts.headline,
|
|
565
|
+
industry: opts.industry,
|
|
566
|
+
address: opts.address,
|
|
567
|
+
notes: opts.notes,
|
|
568
|
+
});
|
|
569
|
+
});
|
|
570
|
+
const companyCommand = withToolExecutionOptions(withGlobalOptions(program
|
|
571
|
+
.command('company')
|
|
572
|
+
.description('Work with Companies')
|
|
573
|
+
.addHelpText('after', TOOL_CALL_HELP)));
|
|
574
|
+
withGlobalOptions(withToolExecutionOptions(companyCommand
|
|
575
|
+
.command('list')
|
|
576
|
+
.description('List Companies')
|
|
577
|
+
.option('--search <q>', 'search Companies by name, email, phone, or industry')
|
|
578
|
+
.option('--limit <n>', 'maximum number of Companies to return (up to 100)'))).action(async (_options, command) => {
|
|
579
|
+
const opts = command.optsWithGlobals();
|
|
580
|
+
await companyListCommand({ ...executionOptions(opts), search: opts.search, limit: opts.limit });
|
|
581
|
+
});
|
|
582
|
+
withGlobalOptions(withToolExecutionOptions(companyCommand
|
|
583
|
+
.command('view')
|
|
584
|
+
.description('Show one Company')
|
|
585
|
+
.argument('<company_id>', 'Company id'))).action(async (companyId, _options, command) => {
|
|
586
|
+
await companyViewCommand(companyId, executionOptions(command.optsWithGlobals()));
|
|
587
|
+
});
|
|
588
|
+
withGlobalOptions(withToolExecutionOptions(companyCommand
|
|
589
|
+
.command('create')
|
|
590
|
+
.description('Create a Company (write: needs --yes); search with every company list first')
|
|
591
|
+
.requiredOption('--name <name>', 'Company name')
|
|
592
|
+
.option('--email <email>', 'primary email')
|
|
593
|
+
.option('--phone <phone>', 'primary phone')
|
|
594
|
+
.option('--website <url>', 'website')
|
|
595
|
+
.option('--industry <text>', 'industry')
|
|
596
|
+
.option('--address <text>', 'postal address')
|
|
597
|
+
.option('--lead-source <text>', 'where the Company came from')
|
|
598
|
+
.option('--notes <text>', 'notes'))).action(async (_options, command) => {
|
|
599
|
+
const opts = command.optsWithGlobals();
|
|
600
|
+
await companyCreateCommand({
|
|
601
|
+
...executionOptions(opts),
|
|
602
|
+
name: opts.name,
|
|
603
|
+
email: opts.email,
|
|
604
|
+
phone: opts.phone,
|
|
605
|
+
website: opts.website,
|
|
606
|
+
industry: opts.industry,
|
|
607
|
+
address: opts.address,
|
|
608
|
+
leadSource: opts.leadSource,
|
|
609
|
+
notes: opts.notes,
|
|
610
|
+
});
|
|
611
|
+
});
|
|
612
|
+
withGlobalOptions(withToolExecutionOptions(program
|
|
613
|
+
.command('approvals')
|
|
614
|
+
.description('List requests that wait for approval in Every (read only)')
|
|
615
|
+
.option('--all', 'show every request of the last 24 hours, from every connection'))).action(async (_options, command) => {
|
|
616
|
+
const opts = command.optsWithGlobals();
|
|
617
|
+
await approvalsCommand({ ...executionOptions(opts), all: opts.all });
|
|
618
|
+
});
|
|
368
619
|
addPersonListCommand(withToolExecutionOptions(withGlobalOptions(program
|
|
369
620
|
.command('contact', { hidden: true })
|
|
370
621
|
.description('Deprecated alias for every person'))), '`every contact` is deprecated; use `every person`.');
|
package/dist/lib/config.js
CHANGED
|
@@ -18,6 +18,9 @@ export const STAGING_BASE_URL = 'https://admin-mcp-staging.up.railway.app';
|
|
|
18
18
|
/** Where an org admin mints, inspects and revokes org API keys. */
|
|
19
19
|
export const PROD_API_KEYS_URL = 'https://app.every.ai/settings/api-keys';
|
|
20
20
|
export const STAGING_API_KEYS_URL = 'https://app.staging.every.ai/settings/api-keys';
|
|
21
|
+
/** Where a person approves or cancels the requests that wait for approval. */
|
|
22
|
+
export const PROD_APPROVALS_URL = 'https://app.every.ai/settings/approvals';
|
|
23
|
+
export const STAGING_APPROVALS_URL = 'https://app.staging.every.ai/settings/approvals';
|
|
21
24
|
/**
|
|
22
25
|
* Resolve the MCP base URL to target.
|
|
23
26
|
*
|
|
@@ -57,3 +60,9 @@ export function apiKeysUrlForBaseUrl(baseUrl) {
|
|
|
57
60
|
? STAGING_API_KEYS_URL
|
|
58
61
|
: PROD_API_KEYS_URL;
|
|
59
62
|
}
|
|
63
|
+
/** The web-app page where a person approves the requests that a given MCP base URL holds. */
|
|
64
|
+
export function approvalsUrlForBaseUrl(baseUrl) {
|
|
65
|
+
return environmentNameForBaseUrl(baseUrl) === 'staging'
|
|
66
|
+
? STAGING_APPROVALS_URL
|
|
67
|
+
: PROD_APPROVALS_URL;
|
|
68
|
+
}
|
package/dist/lib/mcp.js
CHANGED
|
@@ -123,6 +123,48 @@ async function unauthorizedError(response, baseUrl, token) {
|
|
|
123
123
|
}
|
|
124
124
|
return new CliError(apiKeyRejectedMessage(baseUrl, reason), ExitCode.AUTH, 'auth');
|
|
125
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Explain a non-401 refusal with the server's own words when it sent them.
|
|
128
|
+
*
|
|
129
|
+
* admin-mcp refuses some requests on purpose with an RFC 6750 style body,
|
|
130
|
+
* for example `{"error":"workspace_not_selected","error_description":"..."}`
|
|
131
|
+
* (403) or `{"error":"org_binding_unavailable",...}` (503). The description
|
|
132
|
+
* already tells the user what to do, so the CLI shows it. A body that is not
|
|
133
|
+
* that shape keeps the generic "HTTP <status>" message. The exit code and the
|
|
134
|
+
* machine `code` come from the status only, so scripts see no change.
|
|
135
|
+
*/
|
|
136
|
+
async function httpStatusError(response, method, url) {
|
|
137
|
+
const classified = classifyHttpStatus(response.status);
|
|
138
|
+
let raw = '';
|
|
139
|
+
try {
|
|
140
|
+
raw = await response.text();
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
// A body that cannot be read falls back to the status message.
|
|
144
|
+
}
|
|
145
|
+
const reason = authErrorReasonFromBody(raw);
|
|
146
|
+
const serverError = serverErrorCode(raw);
|
|
147
|
+
const details = { http_status: response.status };
|
|
148
|
+
if (serverError !== undefined)
|
|
149
|
+
details.server_error = serverError;
|
|
150
|
+
const message = reason === undefined
|
|
151
|
+
? `MCP ${method} failed for ${url}: HTTP ${response.status}`
|
|
152
|
+
: `${reason} (HTTP ${response.status})`;
|
|
153
|
+
return new CliError(message, classified.exitCode, classified.code, details);
|
|
154
|
+
}
|
|
155
|
+
function serverErrorCode(raw) {
|
|
156
|
+
try {
|
|
157
|
+
const body = JSON.parse(raw);
|
|
158
|
+
if (!body || typeof body !== 'object' || Array.isArray(body))
|
|
159
|
+
return undefined;
|
|
160
|
+
const value = body.error;
|
|
161
|
+
// A machine code only: short and without spaces, so it is safe in --json.
|
|
162
|
+
return typeof value === 'string' && /^[a-z0-9_.-]{1,64}$/i.test(value) ? value : undefined;
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
return undefined;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
126
168
|
export async function mcpCall(baseUrl, token, method, params = {}, { timeoutMs = DEFAULT_MCP_TIMEOUT_MS } = {}) {
|
|
127
169
|
const url = mcpUrl(baseUrl);
|
|
128
170
|
let response;
|
|
@@ -154,8 +196,7 @@ export async function mcpCall(baseUrl, token, method, params = {}, { timeoutMs =
|
|
|
154
196
|
throw await unauthorizedError(response, baseUrl, token);
|
|
155
197
|
}
|
|
156
198
|
if (!response.ok) {
|
|
157
|
-
|
|
158
|
-
throw new CliError(`MCP ${method} failed for ${url}: HTTP ${response.status}`, classified.exitCode, classified.code);
|
|
199
|
+
throw await httpStatusError(response, method, url);
|
|
159
200
|
}
|
|
160
201
|
return parseJsonRpcResponse(await response.text(), params);
|
|
161
202
|
}
|
package/dist/lib/policy.js
CHANGED
|
@@ -58,6 +58,13 @@ function overrideClassification(name) {
|
|
|
58
58
|
reason: 'approve_pending_deal activates a deal and queues its plan; hard to undo, so pin write tier regardless of server annotation drift.',
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
+
if (name === 'set_recipient_defaults') {
|
|
62
|
+
return {
|
|
63
|
+
level: 'destructive',
|
|
64
|
+
source: 'override',
|
|
65
|
+
reason: 'set_recipient_defaults changes the audience for future document sends. Require destructive confirmation regardless of server annotations.',
|
|
66
|
+
};
|
|
67
|
+
}
|
|
61
68
|
// approve_prospect is the owner/bookkeeper review action next to
|
|
62
69
|
// approve_pending_deal (the path open to API keys); pin it the same way.
|
|
63
70
|
if (name === 'approve_prospect') {
|
|
@@ -86,6 +93,25 @@ function overrideClassification(name) {
|
|
|
86
93
|
reason: 'set_deal_name renames a deal, or clears the name back to the system default; pin write tier regardless of server annotation drift.',
|
|
87
94
|
};
|
|
88
95
|
}
|
|
96
|
+
// Agent CRM automation tools (2026-11). update_deal replaces set_deal_name and
|
|
97
|
+
// set_deal_value_estimate. deal_outreach edits, sends, schedules and cancels
|
|
98
|
+
// the deal's outbound message. Its name does not match send_ or cancel_, and
|
|
99
|
+
// one tool has one local tier, so the send action sets the tier for all
|
|
100
|
+
// actions.
|
|
101
|
+
if (name === 'update_deal') {
|
|
102
|
+
return {
|
|
103
|
+
level: 'write',
|
|
104
|
+
source: 'override',
|
|
105
|
+
reason: 'update_deal changes the name, value estimate, owner, party, members or goal of a deal; pin write tier regardless of server annotation drift.',
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
if (name === 'deal_outreach') {
|
|
109
|
+
return {
|
|
110
|
+
level: 'destructive',
|
|
111
|
+
source: 'override',
|
|
112
|
+
reason: 'deal_outreach can send or schedule a message to real recipients on email, LinkedIn or Instagram; sending has external impact, so every action needs destructive confirmation.',
|
|
113
|
+
};
|
|
114
|
+
}
|
|
89
115
|
if (name === 'link_deal_item') {
|
|
90
116
|
return {
|
|
91
117
|
level: 'write',
|
|
@@ -120,6 +146,19 @@ function overrideClassification(name) {
|
|
|
120
146
|
}
|
|
121
147
|
return undefined;
|
|
122
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* How the short commands gate a tool that has more than one action. The tool
|
|
151
|
+
* keeps one tier for `every tool call`, because that path cannot know the
|
|
152
|
+
* action before the call. A short command knows its action, so it gates by
|
|
153
|
+
* action.
|
|
154
|
+
*/
|
|
155
|
+
export function shortCommandNote(name) {
|
|
156
|
+
if (name === 'deal_outreach') {
|
|
157
|
+
return 'The short commands gate by action: `every deal outreach edit` and `every deal outreach cancel` are writes (--yes). ' +
|
|
158
|
+
'`every deal outreach send` is destructive (--yes --allow-destructive). `every tool call deal_outreach` stays destructive for every action.';
|
|
159
|
+
}
|
|
160
|
+
return undefined;
|
|
161
|
+
}
|
|
123
162
|
export function classify(tool) {
|
|
124
163
|
const overridden = overrideClassification(tool.name);
|
|
125
164
|
if (overridden)
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { CliError } from './errors.js';
|
|
2
|
+
import { ExitCode } from './exit-codes.js';
|
|
3
|
+
export function documentKind(value) {
|
|
4
|
+
if (value !== 'invoice' && value !== 'proposal') {
|
|
5
|
+
throw new CliError('--kind must be invoice or proposal', ExitCode.USAGE, 'usage');
|
|
6
|
+
}
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
export function record(value) {
|
|
10
|
+
return value && typeof value === 'object' && !Array.isArray(value)
|
|
11
|
+
? value
|
|
12
|
+
: {};
|
|
13
|
+
}
|
|
14
|
+
/** Validate the server object without changing any binding field. */
|
|
15
|
+
export function recipientBinding(value, source = 'preview') {
|
|
16
|
+
const binding = record(value);
|
|
17
|
+
if (Object.keys(binding).sort().join(',') !== 'cc,digest,to' ||
|
|
18
|
+
typeof binding.digest !== 'string' || !/^[a-f0-9]{64}$/.test(binding.digest) ||
|
|
19
|
+
typeof binding.to !== 'string' || binding.to.length === 0 ||
|
|
20
|
+
!Array.isArray(binding.cc) || !binding.cc.every((address) => typeof address === 'string')) {
|
|
21
|
+
if (source === 'argument') {
|
|
22
|
+
throw new CliError('Document sends require a recipients binding with exactly {digest, to, cc} from preview_document_send.', ExitCode.USAGE, 'usage');
|
|
23
|
+
}
|
|
24
|
+
throw new CliError('The server returned an invalid recipient preview. No document was sent.');
|
|
25
|
+
}
|
|
26
|
+
return binding;
|
|
27
|
+
}
|
|
28
|
+
/** Older servers omit model_state but return the complete exclusion list. */
|
|
29
|
+
export function preservedExclusions(defaults) {
|
|
30
|
+
const ids = defaults.none_method_ids;
|
|
31
|
+
const state = defaults.model_state;
|
|
32
|
+
if (!Array.isArray(ids) || !ids.every((id) => typeof id === 'string' &&
|
|
33
|
+
/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(id))) {
|
|
34
|
+
throw new CliError('The server cannot confirm current recipient exclusions. No defaults were changed.', ExitCode.PERMISSION, 'recipient_exclusions_unavailable');
|
|
35
|
+
}
|
|
36
|
+
if ((state !== undefined && state !== 'v1' && state !== 'v2') || (state === 'v2' && ids.length > 0)) {
|
|
37
|
+
throw new CliError('This recipient model cannot preserve the existing exclusions. No defaults were changed.', ExitCode.PERMISSION, 'recipient_exclusions_unavailable', { model_state: state });
|
|
38
|
+
}
|
|
39
|
+
return ids;
|
|
40
|
+
}
|
|
41
|
+
/** Use transport addresses as authority. Optional display details supply names only. */
|
|
42
|
+
export function recipientLines(data) {
|
|
43
|
+
const envelope = record(data.recipients ?? data.recipient_preview);
|
|
44
|
+
const details = record(data.recipient_details);
|
|
45
|
+
const detailRows = [details.to, ...(Array.isArray(details.cc) ? details.cc : [])].map(record);
|
|
46
|
+
const methods = (Array.isArray(data.eligible_methods) ? data.eligible_methods : []).map(record);
|
|
47
|
+
const line = (role, address) => {
|
|
48
|
+
const detail = detailRows.find((entry) => entry.address === address);
|
|
49
|
+
const method = methods.find((entry) => entry.delivery_address === address);
|
|
50
|
+
const name = detail?.owner_name ?? record(method?.owner).name;
|
|
51
|
+
return `${role}: ${typeof name === 'string' && name ? name : 'Name unavailable'} <${address}>`;
|
|
52
|
+
};
|
|
53
|
+
const cc = Array.isArray(envelope.cc) ? envelope.cc : [];
|
|
54
|
+
return [
|
|
55
|
+
typeof envelope.to === 'string' ? line('To', envelope.to) : 'To: none',
|
|
56
|
+
...cc.map((address) => line('CC', String(address))),
|
|
57
|
+
...(cc.length === 0 ? ['CC: none'] : []),
|
|
58
|
+
...(envelope.error ? [`Recipient error: ${envelope.error}`] : []),
|
|
59
|
+
].join('\n');
|
|
60
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plain-text tables for human output, in the same layout as `every tools list`
|
|
3
|
+
* and `every deal stages`: a header row, a dash row, then one row per record.
|
|
4
|
+
* The last column is not padded. A cell longer than its column width ends in
|
|
5
|
+
* "...".
|
|
6
|
+
*/
|
|
7
|
+
/** One line of text: whitespace collapses, and a long value ends in "...". */
|
|
8
|
+
export function cell(value, max = 60) {
|
|
9
|
+
if (value === null || value === undefined)
|
|
10
|
+
return '';
|
|
11
|
+
const text = String(value).replace(/\s+/g, ' ').trim();
|
|
12
|
+
return text.length > max ? `${text.slice(0, Math.max(0, max - 3))}...` : text;
|
|
13
|
+
}
|
|
14
|
+
export function renderTable(columns, rows) {
|
|
15
|
+
const widths = columns.map((column, index) => {
|
|
16
|
+
const longest = Math.max(column.header.length, ...rows.map((row) => (row[index] ?? '').length));
|
|
17
|
+
return column.max === undefined ? longest : Math.min(column.max, longest);
|
|
18
|
+
});
|
|
19
|
+
const last = columns.length - 1;
|
|
20
|
+
const line = (cells) => cells
|
|
21
|
+
.map((value, index) => {
|
|
22
|
+
const text = cell(value, columns[index].max ?? Number.MAX_SAFE_INTEGER);
|
|
23
|
+
return index === last ? text : text.padEnd(widths[index]);
|
|
24
|
+
})
|
|
25
|
+
.join(' ')
|
|
26
|
+
.trimEnd();
|
|
27
|
+
return [
|
|
28
|
+
line(columns.map((column) => column.header)),
|
|
29
|
+
line(widths.map((width) => '-'.repeat(width))),
|
|
30
|
+
...rows.map(line),
|
|
31
|
+
].join('\n');
|
|
32
|
+
}
|
|
33
|
+
/** An ISO time as `YYYY-MM-DD HH:MM` (UTC), or the value as given when it does not parse. */
|
|
34
|
+
export function shortTime(value) {
|
|
35
|
+
if (typeof value !== 'string' || !value.trim())
|
|
36
|
+
return '';
|
|
37
|
+
const time = Date.parse(value);
|
|
38
|
+
if (Number.isNaN(time))
|
|
39
|
+
return value;
|
|
40
|
+
return new Date(time).toISOString().slice(0, 16).replace('T', ' ');
|
|
41
|
+
}
|