@everyai/cli 0.7.2 → 0.8.1
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 +29 -8
- package/dist/commands/aliases.js +39 -13
- package/dist/commands/auth.js +32 -43
- package/dist/commands/docs.js +12 -3
- package/dist/commands/signup.js +239 -0
- package/dist/commands/tools.js +20 -5
- package/dist/index.js +95 -32
- package/dist/lib/auth/discovery.js +21 -0
- package/dist/lib/auth/flow.js +32 -7
- package/dist/lib/auth/tokens.js +1 -0
- package/dist/lib/config.js +0 -7
- package/dist/lib/output.js +8 -0
- package/dist/lib/policy.js +31 -3
- package/dist/lib/skill-refresh.js +91 -0
- package/package.json +1 -1
- package/skills/use-every/SKILL.md +47 -14
package/dist/commands/tools.js
CHANGED
|
@@ -10,6 +10,13 @@ import { getToken } from '../lib/auth/tokens.js';
|
|
|
10
10
|
import { fetchUserInfo } from '../lib/auth/userinfo.js';
|
|
11
11
|
import { maybeShowSkillHint } from '../lib/hints.js';
|
|
12
12
|
import { parseMcpGateMetadata, SERVER_CONFIRMATION_ARG, withoutMcpGateMarker, } from '../lib/mcp-gate.js';
|
|
13
|
+
/**
|
|
14
|
+
* Next steps for a tool refused because the account's signup is unfinished
|
|
15
|
+
* (`signup_incomplete`). Older CLIs show only the server's text; this one names
|
|
16
|
+
* the commands that finish it.
|
|
17
|
+
*/
|
|
18
|
+
export const SIGNUP_INCOMPLETE_GUIDANCE = 'Finish signup first: run `every signup status` to see what is needed, confirm the ' +
|
|
19
|
+
'organization name with the user, then run `every signup complete --org-name "<name>" --yes`.';
|
|
13
20
|
function emitCommand(data, human, opts) {
|
|
14
21
|
if (opts.json)
|
|
15
22
|
emit(data, { json: true, staging: opts.staging });
|
|
@@ -51,10 +58,12 @@ function toolsListHuman(tools) {
|
|
|
51
58
|
}
|
|
52
59
|
return lines.join('\n');
|
|
53
60
|
}
|
|
54
|
-
function findTool(tools, name) {
|
|
61
|
+
function findTool(tools, name, hooks = {}) {
|
|
55
62
|
const tool = tools.find((candidate) => candidate.name === name);
|
|
56
|
-
if (!tool)
|
|
57
|
-
throw
|
|
63
|
+
if (!tool) {
|
|
64
|
+
throw hooks.missingTool?.(name) ??
|
|
65
|
+
new CliError(`Tool not found: ${name}`, ExitCode.NOT_FOUND, 'not_found');
|
|
66
|
+
}
|
|
58
67
|
return tool;
|
|
59
68
|
}
|
|
60
69
|
function describeHuman(tool) {
|
|
@@ -233,11 +242,11 @@ async function resolveWriteTarget(baseUrl) {
|
|
|
233
242
|
return undefined;
|
|
234
243
|
}
|
|
235
244
|
}
|
|
236
|
-
export async function invokeToolCall(name, opts = {}, argsFactory = async () => ({})) {
|
|
245
|
+
export async function invokeToolCall(name, opts = {}, argsFactory = async () => ({}), hooks = {}) {
|
|
237
246
|
const baseUrl = resolveBaseUrl({ staging: opts.staging });
|
|
238
247
|
const token = await getToken({ baseUrl });
|
|
239
248
|
const tools = await listTools(baseUrl, token, { noCache: opts.noCache });
|
|
240
|
-
const tool = findTool(tools, name);
|
|
249
|
+
const tool = findTool(tools, name, hooks);
|
|
241
250
|
const classification = classify(tool);
|
|
242
251
|
const interactive = Boolean(process.stdin.isTTY && process.stderr.isTTY);
|
|
243
252
|
const readOnlyMode = opts.readOnly === true || process.env.EVERY_READ_ONLY === '1';
|
|
@@ -315,6 +324,12 @@ export async function invokeToolCall(name, opts = {}, argsFactory = async () =>
|
|
|
315
324
|
// under error.tool_error; older servers send none, so this falls back to
|
|
316
325
|
// 'generic' and behaves exactly as before.
|
|
317
326
|
const toolError = structuredToolError(result.structuredContent);
|
|
327
|
+
if (toolError?.code === 'signup_incomplete') {
|
|
328
|
+
throw new CliError(`${rawMessage}\n${SIGNUP_INCOMPLETE_GUIDANCE}`, ExitCode.GENERIC, toolError.code, {
|
|
329
|
+
tool_error: toolError,
|
|
330
|
+
next_steps: ['every signup status --json', 'every signup complete --org-name "<name>" --yes --json'],
|
|
331
|
+
});
|
|
332
|
+
}
|
|
318
333
|
if (toolError) {
|
|
319
334
|
throw new CliError(rawMessage, ExitCode.GENERIC, toolError.code, { tool_error: toolError });
|
|
320
335
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { readFileSync } from 'node:fs';
|
|
3
|
-
import { Command, CommanderError } from 'commander';
|
|
3
|
+
import { Command, CommanderError, Option } from 'commander';
|
|
4
4
|
import { pingCommand } from './commands/ping.js';
|
|
5
5
|
import { docsCommand } from './commands/docs.js';
|
|
6
6
|
import { authStatusCommand, loginCommand, logoutCommand, orgCommand, orgSwitchCommand, whoamiCommand, } from './commands/auth.js';
|
|
7
7
|
import { policyExplainCommand } from './commands/policy.js';
|
|
8
|
+
import { signupCommand, signupCompleteCommand, signupStatusCommand, } from './commands/signup.js';
|
|
8
9
|
import { toolCallCommand, toolsDescribeCommand, toolsListCommand, } from './commands/tools.js';
|
|
9
|
-
import {
|
|
10
|
+
import { dealListCommand, dealMoveCommand, invoiceCreateCommand, invoiceListCommand, invoiceSendCommand, personListCommand, } from './commands/aliases.js';
|
|
10
11
|
import { skillsInstallCommand, skillsListCommand } from './commands/skills.js';
|
|
11
12
|
import { CliError } from './lib/errors.js';
|
|
12
|
-
import { emit, emitError } from './lib/output.js';
|
|
13
|
+
import { deprecationNote, emit, emitError } from './lib/output.js';
|
|
13
14
|
import { ExitCode } from './lib/exit-codes.js';
|
|
14
15
|
import { runDefaultFirstRunMenu } from './lib/first-run.js';
|
|
15
16
|
const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
@@ -57,10 +58,50 @@ withGlobalOptions(program
|
|
|
57
58
|
const opts = command.optsWithGlobals();
|
|
58
59
|
await docsCommand(program, { json: opts.json, staging: opts.staging });
|
|
59
60
|
});
|
|
61
|
+
const signup = withGlobalOptions(program
|
|
62
|
+
.command('signup')
|
|
63
|
+
.allowExcessArguments(false)
|
|
64
|
+
.description('Create an Every account or sign in via one browser step; no TTY needed')
|
|
65
|
+
.option('--timeout <seconds>', 'how long to wait for the browser authorization', '300')
|
|
66
|
+
.addHelpText('after', [
|
|
67
|
+
'',
|
|
68
|
+
'With --json, stdout is NDJSON: an authorization_required event with the URL,',
|
|
69
|
+
'a waiting_for_authorization event, then the result envelope as the last line.',
|
|
70
|
+
'',
|
|
71
|
+
'Then finish signup:',
|
|
72
|
+
' every signup complete --org-name "Acme Studio" --yes --json',
|
|
73
|
+
'',
|
|
74
|
+
].join('\n'))).action(async (_options, command) => {
|
|
75
|
+
const opts = command.optsWithGlobals();
|
|
76
|
+
await signupCommand({ json: opts.json, staging: opts.staging, timeout: opts.timeout });
|
|
77
|
+
});
|
|
78
|
+
withGlobalOptions(signup.command('status').description('Show signup status and the profile still needed')).action(async (_options, command) => {
|
|
79
|
+
const opts = command.optsWithGlobals();
|
|
80
|
+
await signupStatusCommand({ json: opts.json, staging: opts.staging });
|
|
81
|
+
});
|
|
82
|
+
withGlobalOptions(signup
|
|
83
|
+
.command('complete')
|
|
84
|
+
.description('Finish signup with the organization profile the user confirmed')
|
|
85
|
+
.requiredOption('--org-name <name>', 'organization name the user confirmed (required)')
|
|
86
|
+
.option('--description <text>', 'short description of the business')
|
|
87
|
+
.option('--link <url>', 'public https link (website, LinkedIn, ...); repeatable', collectOption, [])
|
|
88
|
+
.option('--yes', 'confirm the write (required when non-interactive)')
|
|
89
|
+
.option('--read-only', 'deny the write (for automation guards)')).action(async (_options, command) => {
|
|
90
|
+
const opts = command.optsWithGlobals();
|
|
91
|
+
await signupCompleteCommand({
|
|
92
|
+
json: opts.json,
|
|
93
|
+
staging: opts.staging,
|
|
94
|
+
orgName: opts.orgName,
|
|
95
|
+
description: opts.description,
|
|
96
|
+
link: opts.link,
|
|
97
|
+
yes: opts.yes,
|
|
98
|
+
readOnly: opts.readOnly,
|
|
99
|
+
});
|
|
100
|
+
});
|
|
60
101
|
withGlobalOptions(program
|
|
61
102
|
.command('login')
|
|
62
|
-
.description('Log in
|
|
63
|
-
.option('--create-account', '
|
|
103
|
+
.description('Log in with browser OAuth and store tokens (new users: every signup)')
|
|
104
|
+
.option('--create-account', 'deprecated alias for every signup')
|
|
64
105
|
.option('--org <id|slug|name>', 'verify the workspace selected during login')).action(async (_options, command) => {
|
|
65
106
|
const opts = command.optsWithGlobals();
|
|
66
107
|
await loginCommand({
|
|
@@ -182,15 +223,23 @@ const invoiceCommand = withToolExecutionOptions(withGlobalOptions(program
|
|
|
182
223
|
].join('\n'))));
|
|
183
224
|
withGlobalOptions(withToolExecutionOptions(invoiceCommand
|
|
184
225
|
.command('create')
|
|
185
|
-
.description('Create a simple draft invoice')
|
|
186
|
-
.option('--
|
|
187
|
-
.option('--
|
|
188
|
-
.option('--
|
|
189
|
-
.option('--
|
|
226
|
+
.description('Create a simple draft invoice for a Company or a Person')
|
|
227
|
+
.option('--company <name>', 'Company name to resolve via list_companies')
|
|
228
|
+
.option('--person <name>', 'Person name to resolve via list_people')
|
|
229
|
+
.option('--company-id <id>', 'Company id; skips name resolution')
|
|
230
|
+
.option('--person-id <id>', 'Person id; skips name resolution')
|
|
231
|
+
.addOption(new Option('--client <name>', 'deprecated alias for --company').hideHelp())
|
|
232
|
+
.addOption(new Option('--client-id <id>', 'deprecated: use --company-id or --person-id').hideHelp())
|
|
190
233
|
.requiredOption('--amount <n>', 'unit price for the single line item')
|
|
191
234
|
.option('--description <text>', 'line item description')
|
|
192
235
|
.option('--quantity <q>', 'line item quantity'))).action(async (_options, command) => {
|
|
193
236
|
const opts = command.optsWithGlobals();
|
|
237
|
+
if (opts.client !== undefined) {
|
|
238
|
+
deprecationNote('`--client` is deprecated; use `--company` (or `--person` for a Person).');
|
|
239
|
+
}
|
|
240
|
+
if (opts.clientId !== undefined) {
|
|
241
|
+
deprecationNote('`--client-id` is deprecated; use `--company-id` or `--person-id`.');
|
|
242
|
+
}
|
|
194
243
|
await invoiceCreateCommand({
|
|
195
244
|
json: opts.json,
|
|
196
245
|
staging: opts.staging,
|
|
@@ -202,6 +251,8 @@ withGlobalOptions(withToolExecutionOptions(invoiceCommand
|
|
|
202
251
|
client: opts.client,
|
|
203
252
|
company: opts.company,
|
|
204
253
|
person: opts.person,
|
|
254
|
+
companyId: opts.companyId,
|
|
255
|
+
personId: opts.personId,
|
|
205
256
|
clientId: opts.clientId,
|
|
206
257
|
amount: opts.amount,
|
|
207
258
|
description: opts.description,
|
|
@@ -283,28 +334,40 @@ withGlobalOptions(withToolExecutionOptions(dealCommand
|
|
|
283
334
|
timeout: opts.timeout,
|
|
284
335
|
});
|
|
285
336
|
});
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
337
|
+
/**
|
|
338
|
+
* Register `list` under `every person` and under the hidden, deprecated
|
|
339
|
+
* `every contact` alias ("contact" is retired vocabulary: the product's people
|
|
340
|
+
* model is People and Companies).
|
|
341
|
+
*/
|
|
342
|
+
function addPersonListCommand(parent, deprecation) {
|
|
343
|
+
withGlobalOptions(withToolExecutionOptions(parent
|
|
344
|
+
.command('list')
|
|
345
|
+
.description('List People')
|
|
346
|
+
.option('--search <q>', 'search People by name, email, phone, or employer')
|
|
347
|
+
.option('--limit <n>', 'maximum number of People to return'))).action(async (_options, command) => {
|
|
348
|
+
if (deprecation)
|
|
349
|
+
deprecationNote(deprecation);
|
|
350
|
+
const opts = command.optsWithGlobals();
|
|
351
|
+
await personListCommand({
|
|
352
|
+
json: opts.json,
|
|
353
|
+
staging: opts.staging,
|
|
354
|
+
noCache: opts.noCache,
|
|
355
|
+
yes: opts.yes,
|
|
356
|
+
allowDestructive: opts.allowDestructive,
|
|
357
|
+
readOnly: opts.readOnly,
|
|
358
|
+
timeout: opts.timeout,
|
|
359
|
+
search: opts.search,
|
|
360
|
+
limit: opts.limit,
|
|
361
|
+
});
|
|
306
362
|
});
|
|
307
|
-
}
|
|
363
|
+
}
|
|
364
|
+
addPersonListCommand(withToolExecutionOptions(withGlobalOptions(program
|
|
365
|
+
.command('person')
|
|
366
|
+
.description('Work with People')
|
|
367
|
+
.addHelpText('after', TOOL_CALL_HELP))));
|
|
368
|
+
addPersonListCommand(withToolExecutionOptions(withGlobalOptions(program
|
|
369
|
+
.command('contact', { hidden: true })
|
|
370
|
+
.description('Deprecated alias for every person'))), '`every contact` is deprecated; use `every person`.');
|
|
308
371
|
const policyCommand = withGlobalOptions(program.command('policy').description('Explain local tool safety policy'));
|
|
309
372
|
withGlobalOptions(policyCommand
|
|
310
373
|
.command('explain')
|
|
@@ -365,7 +428,7 @@ async function maybeRunFirstRunMenu() {
|
|
|
365
428
|
staging: program.opts().staging,
|
|
366
429
|
showHelp: () => program.outputHelp(),
|
|
367
430
|
login: () => loginCommand({ staging: program.opts().staging, skipMenu: true }),
|
|
368
|
-
createAccount: () =>
|
|
431
|
+
createAccount: () => signupCommand({ staging: program.opts().staging }),
|
|
369
432
|
});
|
|
370
433
|
return true;
|
|
371
434
|
}
|
|
@@ -58,6 +58,26 @@ function validateAuthServer(value, url) {
|
|
|
58
58
|
}
|
|
59
59
|
return value;
|
|
60
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Prefer the resource the server names in its protected-resource metadata. Fall
|
|
63
|
+
* back to the MCP base URL when it names none, names something unparseable, or
|
|
64
|
+
* names a different origin: a metadata document may only describe the server
|
|
65
|
+
* that served it (RFC 9728 section 3.3).
|
|
66
|
+
*/
|
|
67
|
+
export function canonicalResource(mcpBaseUrl, metadata) {
|
|
68
|
+
const fallback = trimTrailingSlash(mcpBaseUrl);
|
|
69
|
+
if (typeof metadata.resource !== 'string' || metadata.resource.trim() === '')
|
|
70
|
+
return fallback;
|
|
71
|
+
try {
|
|
72
|
+
const named = new URL(metadata.resource);
|
|
73
|
+
if (named.origin !== new URL(fallback).origin || named.hash)
|
|
74
|
+
return fallback;
|
|
75
|
+
return metadata.resource;
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return fallback;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
61
81
|
async function discoverUncached(mcpBaseUrl) {
|
|
62
82
|
const protectedResourceUrl = wellKnownUrl(mcpBaseUrl, '/.well-known/oauth-protected-resource');
|
|
63
83
|
const protectedResource = validateProtectedResource(await fetchJsonWithTimeout(protectedResourceUrl), protectedResourceUrl);
|
|
@@ -66,6 +86,7 @@ async function discoverUncached(mcpBaseUrl) {
|
|
|
66
86
|
const authServer = validateAuthServer(await fetchJsonWithTimeout(authServerUrl), authServerUrl);
|
|
67
87
|
return {
|
|
68
88
|
mcpBaseUrl: trimTrailingSlash(mcpBaseUrl),
|
|
89
|
+
resource: canonicalResource(mcpBaseUrl, protectedResource),
|
|
69
90
|
protectedResource,
|
|
70
91
|
authServer,
|
|
71
92
|
};
|
package/dist/lib/auth/flow.js
CHANGED
|
@@ -85,17 +85,26 @@ function buildAuthorizationUrl(params) {
|
|
|
85
85
|
url.searchParams.set('state', params.state);
|
|
86
86
|
url.searchParams.set('code_challenge', params.codeChallenge);
|
|
87
87
|
url.searchParams.set('code_challenge_method', 'S256');
|
|
88
|
+
url.searchParams.set('resource', params.resource);
|
|
88
89
|
return url.toString();
|
|
89
90
|
}
|
|
91
|
+
/** Best-effort launch of the system browser; resolves false when it could not start. */
|
|
90
92
|
export async function openBrowser(url) {
|
|
91
93
|
const command = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'cmd' : 'xdg-open';
|
|
92
94
|
const args = process.platform === 'win32' ? ['/c', 'start', '', url] : [url];
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
return new Promise((resolve) => {
|
|
96
|
+
let child;
|
|
97
|
+
try {
|
|
98
|
+
child = spawn(command, args, { detached: true, stdio: 'ignore' });
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
resolve(false);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
child.once('error', () => resolve(false));
|
|
96
105
|
child.once('spawn', () => {
|
|
97
106
|
child.unref();
|
|
98
|
-
resolve();
|
|
107
|
+
resolve(true);
|
|
99
108
|
});
|
|
100
109
|
});
|
|
101
110
|
}
|
|
@@ -107,6 +116,8 @@ export async function exchangeAuthorizationCode(opts) {
|
|
|
107
116
|
client_id: opts.clientId,
|
|
108
117
|
code_verifier: opts.codeVerifier,
|
|
109
118
|
});
|
|
119
|
+
if (opts.resource)
|
|
120
|
+
body.set('resource', opts.resource);
|
|
110
121
|
let response;
|
|
111
122
|
try {
|
|
112
123
|
response = await fetchJsonWithTimeout(opts.metadata.token_endpoint, {
|
|
@@ -133,13 +144,18 @@ export async function exchangeAuthorizationCode(opts) {
|
|
|
133
144
|
}
|
|
134
145
|
export async function loginFlow(opts) {
|
|
135
146
|
const timeoutMs = opts.timeoutMs ?? LOGIN_TIMEOUT_MS;
|
|
147
|
+
const timeoutSeconds = Math.round(timeoutMs / 1000);
|
|
148
|
+
const timedOut = () => new CliError(`Login timed out after ${timeoutSeconds}s`, ExitCode.AUTH, 'auth', {
|
|
149
|
+
reason: 'timeout',
|
|
150
|
+
timeout_seconds: timeoutSeconds,
|
|
151
|
+
});
|
|
136
152
|
const startedAt = Date.now();
|
|
137
153
|
const state = createState();
|
|
138
154
|
const pkce = createPkcePair();
|
|
139
155
|
const loopback = await (opts.createCallbackServer ?? createLoopbackCallbackServer)(state);
|
|
140
156
|
const timeout = new Promise((_, reject) => {
|
|
141
157
|
setTimeout(() => {
|
|
142
|
-
reject(
|
|
158
|
+
reject(timedOut());
|
|
143
159
|
}, timeoutMs).unref();
|
|
144
160
|
});
|
|
145
161
|
try {
|
|
@@ -151,9 +167,17 @@ export async function loginFlow(opts) {
|
|
|
151
167
|
redirectUri: loopback.redirectUri,
|
|
152
168
|
state,
|
|
153
169
|
codeChallenge: pkce.challenge,
|
|
170
|
+
resource: discovery.resource,
|
|
154
171
|
});
|
|
155
172
|
opts.onAuthorizationUrl?.(authorizationUrl);
|
|
156
|
-
|
|
173
|
+
let opened;
|
|
174
|
+
try {
|
|
175
|
+
opened = (await (opts.openBrowser ?? openBrowser)(authorizationUrl)) !== false;
|
|
176
|
+
}
|
|
177
|
+
catch {
|
|
178
|
+
opened = false;
|
|
179
|
+
}
|
|
180
|
+
opts.onBrowserOpened?.(opened);
|
|
157
181
|
const callback = await Promise.race([loopback.waitForCallback, timeout]);
|
|
158
182
|
// RFC 9207 mix-up defense: if the server identified itself, it must be the one
|
|
159
183
|
// we discovered. Absent `iss` is left alone -- not every server sends it, and
|
|
@@ -163,7 +187,7 @@ export async function loginFlow(opts) {
|
|
|
163
187
|
}
|
|
164
188
|
const elapsed = Date.now() - startedAt;
|
|
165
189
|
if (elapsed > timeoutMs) {
|
|
166
|
-
throw
|
|
190
|
+
throw timedOut();
|
|
167
191
|
}
|
|
168
192
|
return await Promise.race([
|
|
169
193
|
exchangeAuthorizationCode({
|
|
@@ -172,6 +196,7 @@ export async function loginFlow(opts) {
|
|
|
172
196
|
redirectUri: loopback.redirectUri,
|
|
173
197
|
code: callback.code,
|
|
174
198
|
codeVerifier: pkce.verifier,
|
|
199
|
+
resource: discovery.resource,
|
|
175
200
|
now: opts.now,
|
|
176
201
|
}),
|
|
177
202
|
timeout,
|
package/dist/lib/auth/tokens.js
CHANGED
|
@@ -208,6 +208,7 @@ async function refreshToken(baseUrl, environmentKey, store, existing, now) {
|
|
|
208
208
|
grant_type: 'refresh_token',
|
|
209
209
|
refresh_token: existing.refresh_token ?? '',
|
|
210
210
|
client_id: existing.client_id,
|
|
211
|
+
resource: discovery.resource,
|
|
211
212
|
});
|
|
212
213
|
let response;
|
|
213
214
|
try {
|
package/dist/lib/config.js
CHANGED
|
@@ -15,8 +15,6 @@ export function getConfigDir() {
|
|
|
15
15
|
/** Deployed MCP base URLs. */
|
|
16
16
|
export const PROD_BASE_URL = 'https://admin-mcp.every.ai';
|
|
17
17
|
export const STAGING_BASE_URL = 'https://admin-mcp-staging.up.railway.app';
|
|
18
|
-
export const PROD_SIGNUP_URL = 'https://app.every.ai/sign-up';
|
|
19
|
-
export const STAGING_SIGNUP_URL = 'https://app.staging.every.ai/sign-up';
|
|
20
18
|
/** Where an org admin mints, inspects and revokes org API keys. */
|
|
21
19
|
export const PROD_API_KEYS_URL = 'https://app.every.ai/settings/api-keys';
|
|
22
20
|
export const STAGING_API_KEYS_URL = 'https://app.staging.every.ai/settings/api-keys';
|
|
@@ -53,11 +51,6 @@ export function environmentNameForBaseUrl(baseUrl) {
|
|
|
53
51
|
return 'staging';
|
|
54
52
|
return 'custom';
|
|
55
53
|
}
|
|
56
|
-
export function signupUrlForBaseUrl(baseUrl) {
|
|
57
|
-
return environmentNameForBaseUrl(baseUrl) === 'staging'
|
|
58
|
-
? STAGING_SIGNUP_URL
|
|
59
|
-
: PROD_SIGNUP_URL;
|
|
60
|
-
}
|
|
61
54
|
/** The web-app page that manages the API keys a given MCP base URL accepts. */
|
|
62
55
|
export function apiKeysUrlForBaseUrl(baseUrl) {
|
|
63
56
|
return environmentNameForBaseUrl(baseUrl) === 'staging'
|
package/dist/lib/output.js
CHANGED
|
@@ -69,3 +69,11 @@ export function emitError(message, code, opts = {}, details = {}) {
|
|
|
69
69
|
process.stderr.write(rendered + '\n');
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* One-line deprecation note for a renamed command or flag. It goes to stderr in
|
|
74
|
+
* every mode, like the one-time skills tip, so `--json` stdout stays a single
|
|
75
|
+
* envelope while an agent reading stderr still learns the current name.
|
|
76
|
+
*/
|
|
77
|
+
export function deprecationNote(message) {
|
|
78
|
+
process.stderr.write(`Note: ${message}\n`);
|
|
79
|
+
}
|
package/dist/lib/policy.js
CHANGED
|
@@ -58,8 +58,18 @@ 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
|
+
// approve_prospect is the owner/bookkeeper review action next to
|
|
62
|
+
// approve_pending_deal (the path open to API keys); pin it the same way.
|
|
63
|
+
if (name === 'approve_prospect') {
|
|
64
|
+
return {
|
|
65
|
+
level: 'write',
|
|
66
|
+
source: 'override',
|
|
67
|
+
reason: 'approve_prospect promotes a pending prospect into an active Deal; hard to undo, so pin write tier regardless of server annotation drift.',
|
|
68
|
+
};
|
|
69
|
+
}
|
|
61
70
|
// Deal tools (admin MCP, shipped 2026-09-03; create_client_deal renamed to
|
|
62
|
-
// create_delivery_deal in the 2026-09-09 People/Companies retirement
|
|
71
|
+
// create_delivery_deal in the 2026-09-09 People/Companies retirement, and
|
|
72
|
+
// set_deal_title to set_deal_name in the 2026-10 naming alignment). None
|
|
63
73
|
// match the send_/delete_/void_/cancel_ name patterns, so without these
|
|
64
74
|
// entries their tier would rest entirely on server annotations.
|
|
65
75
|
if (name === 'create_delivery_deal') {
|
|
@@ -69,11 +79,11 @@ function overrideClassification(name) {
|
|
|
69
79
|
reason: 'create_delivery_deal opens a new won deal for a Person or Company and makes the caller its delivery lead; pin write tier regardless of server annotation drift.',
|
|
70
80
|
};
|
|
71
81
|
}
|
|
72
|
-
if (name === '
|
|
82
|
+
if (name === 'set_deal_name') {
|
|
73
83
|
return {
|
|
74
84
|
level: 'write',
|
|
75
85
|
source: 'override',
|
|
76
|
-
reason: '
|
|
86
|
+
reason: 'set_deal_name renames a deal, or clears the name back to the system default; pin write tier regardless of server annotation drift.',
|
|
77
87
|
};
|
|
78
88
|
}
|
|
79
89
|
if (name === 'link_deal_item') {
|
|
@@ -90,6 +100,24 @@ function overrideClassification(name) {
|
|
|
90
100
|
reason: 'unlink_deal_item detaches an invoice or proposal from a deal and the automatic matcher never re-links it, so the relationship is gone for good; same destructive tier as end_affiliation.',
|
|
91
101
|
};
|
|
92
102
|
}
|
|
103
|
+
// Agent signup tools (2026-10-02). complete_signup commits the organization
|
|
104
|
+
// name the user confirmed: an ordinary idempotent write that must never need
|
|
105
|
+
// --allow-destructive. get_signup_status only reports state; pinning it keeps
|
|
106
|
+
// `every signup` usable without --yes even if its annotations drift.
|
|
107
|
+
if (name === 'complete_signup') {
|
|
108
|
+
return {
|
|
109
|
+
level: 'write',
|
|
110
|
+
source: 'override',
|
|
111
|
+
reason: 'complete_signup saves the confirmed organization profile and finishes signup; an idempotent write, never destructive.',
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
if (name === 'get_signup_status') {
|
|
115
|
+
return {
|
|
116
|
+
level: 'read',
|
|
117
|
+
source: 'override',
|
|
118
|
+
reason: 'get_signup_status reports signup state and unverified profile suggestions; it changes no records.',
|
|
119
|
+
};
|
|
120
|
+
}
|
|
93
121
|
return undefined;
|
|
94
122
|
}
|
|
95
123
|
export function classify(tool) {
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { cp, lstat, readFile, rm } from 'node:fs/promises';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
export const SKILL_NAME = 'use-every';
|
|
6
|
+
/** Frontmatter `metadata` key carrying the bundled skill's integer revision. */
|
|
7
|
+
export const SKILL_VERSION_KEY = 'every-skill-version';
|
|
8
|
+
/**
|
|
9
|
+
* Every place the CLI installs (`every skills install`, the post-login offer) or
|
|
10
|
+
* recognizes an installed `use-every` skill. Refresh only ever touches these.
|
|
11
|
+
*/
|
|
12
|
+
export function skillInstallPaths(cwd, homeDir) {
|
|
13
|
+
return {
|
|
14
|
+
claude: [
|
|
15
|
+
path.join(cwd, '.claude', 'skills', SKILL_NAME),
|
|
16
|
+
path.join(homeDir, '.claude', 'skills', SKILL_NAME),
|
|
17
|
+
],
|
|
18
|
+
codex: [
|
|
19
|
+
path.join(cwd, '.agents', 'skills', SKILL_NAME),
|
|
20
|
+
path.join(homeDir, '.codex', 'skills', SKILL_NAME),
|
|
21
|
+
path.join(homeDir, '.agents', 'skills', SKILL_NAME),
|
|
22
|
+
],
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export function bundledSkillDir() {
|
|
26
|
+
return fileURLToPath(new URL('../../skills/use-every/', import.meta.url));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Read the revision stamp from a SKILL.md frontmatter block. Copies installed
|
|
30
|
+
* before stamping existed carry none and read as `undefined`.
|
|
31
|
+
*/
|
|
32
|
+
export function parseSkillVersion(markdown) {
|
|
33
|
+
const frontmatter = markdown.match(/^---\r?\n([\s\S]*?)\r?\n---/)?.[1];
|
|
34
|
+
if (!frontmatter)
|
|
35
|
+
return undefined;
|
|
36
|
+
const pattern = new RegExp(`^\\s+${SKILL_VERSION_KEY}:\\s*["']?(\\d+)["']?\\s*$`, 'm');
|
|
37
|
+
const value = frontmatter.match(pattern)?.[1];
|
|
38
|
+
return value === undefined ? undefined : Number(value);
|
|
39
|
+
}
|
|
40
|
+
async function installedSkillText(dir) {
|
|
41
|
+
try {
|
|
42
|
+
// A symlinked install is managed by something else (a repo, a plugin); leave it.
|
|
43
|
+
if ((await lstat(dir)).isSymbolicLink())
|
|
44
|
+
return undefined;
|
|
45
|
+
return await readFile(path.join(dir, 'SKILL.md'), 'utf8');
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Replace installed copies of the bundled skill whose stamp is older or missing.
|
|
53
|
+
*
|
|
54
|
+
* An npm update ships a new skill with the CLI but never touches copies already
|
|
55
|
+
* installed into agent skill directories, so agents keep following stale
|
|
56
|
+
* guidance. Runs after a successful `every signup`/`every login`. It never
|
|
57
|
+
* installs into a location that has no copy, never downgrades a newer copy, and
|
|
58
|
+
* never fails the command that called it.
|
|
59
|
+
*/
|
|
60
|
+
export async function refreshInstalledSkills(opts = {}) {
|
|
61
|
+
const refreshed = [];
|
|
62
|
+
try {
|
|
63
|
+
const sourceDir = opts.sourceDir ?? bundledSkillDir();
|
|
64
|
+
const bundled = parseSkillVersion(await readFile(path.join(sourceDir, 'SKILL.md'), 'utf8'));
|
|
65
|
+
if (bundled === undefined)
|
|
66
|
+
return refreshed;
|
|
67
|
+
const paths = skillInstallPaths(opts.cwd ?? process.cwd(), opts.homeDir ?? os.homedir());
|
|
68
|
+
const candidates = Array.from(new Set([...paths.claude, ...paths.codex]));
|
|
69
|
+
for (const dir of candidates) {
|
|
70
|
+
const text = await installedSkillText(dir);
|
|
71
|
+
if (text === undefined)
|
|
72
|
+
continue;
|
|
73
|
+
const installed = parseSkillVersion(text);
|
|
74
|
+
if (installed !== undefined && installed >= bundled)
|
|
75
|
+
continue;
|
|
76
|
+
try {
|
|
77
|
+
await rm(dir, { recursive: true, force: true });
|
|
78
|
+
await cp(sourceDir, dir, { recursive: true, force: true });
|
|
79
|
+
refreshed.push({ path: dir, from: installed ?? null, to: bundled });
|
|
80
|
+
opts.errorOutput?.write(`Updated the use-every skill at ${dir} to revision ${bundled}.\n`);
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
opts.errorOutput?.write(`Warning: could not update the use-every skill at ${dir}.\n`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
// Keeping an agent's skill current is a courtesy; it must never fail auth.
|
|
89
|
+
}
|
|
90
|
+
return refreshed;
|
|
91
|
+
}
|