@everyai/cli 0.6.4 → 0.7.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 +9 -5
- package/dist/commands/aliases.js +75 -28
- package/dist/commands/auth.js +119 -21
- package/dist/index.js +21 -8
- package/dist/lib/auth/flow.js +1 -1
- package/dist/lib/auth/userinfo.js +13 -6
- package/dist/lib/policy.js +7 -6
- package/package.json +1 -1
- package/skills/use-every/SKILL.md +13 -9
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @everyai/cli
|
|
2
2
|
|
|
3
|
-
The **agent-agnostic** command line for [Every AI](https://every.ai) — manage invoices,
|
|
3
|
+
The **agent-agnostic** command line for [Every AI](https://every.ai) — manage invoices, People, Companies, proposals, deals, and pipeline work from any shell, coding agent, or CI job.
|
|
4
4
|
|
|
5
5
|
Install once, log in once, and teach each coding agent the same `every` command instead of wiring MCP + OAuth separately into every host.
|
|
6
6
|
|
|
@@ -17,8 +17,7 @@ One-shot invoice example with inline args:
|
|
|
17
17
|
```bash
|
|
18
18
|
every invoice list --status overdue --json
|
|
19
19
|
every tool call create_invoice \
|
|
20
|
-
--arg
|
|
21
|
-
--arg line_items='[{"description":"Strategy work","quantity":1,"unit_price":1500}]' \
|
|
20
|
+
--arg command='{"operation_id":"<uuid>","party":{"kind":"company","id":"client_123"},"line_items":[{"description":"Strategy work","quantity":1,"unit_price":1500}]}' \
|
|
22
21
|
--yes \
|
|
23
22
|
--json
|
|
24
23
|
```
|
|
@@ -48,8 +47,9 @@ The CLI talks to the same Every MCP server (`admin-mcp.every.ai`) and inherits i
|
|
|
48
47
|
|
|
49
48
|
```bash
|
|
50
49
|
# Auth
|
|
51
|
-
every login [--create-account] [--staging] # browser OAuth; keychain storage; refresh handled
|
|
52
|
-
every logout | whoami | auth status
|
|
50
|
+
every login [--create-account] [--org <name|slug|id>] [--staging] # browser OAuth; keychain storage; refresh handled
|
|
51
|
+
every logout | whoami | auth status
|
|
52
|
+
every org [switch --org <name|slug|id>]
|
|
53
53
|
|
|
54
54
|
# Discovery
|
|
55
55
|
every docs
|
|
@@ -76,6 +76,10 @@ every skills install codex # → .agents/skills/use-every/
|
|
|
76
76
|
|
|
77
77
|
Run `every login` to choose between logging in and creating an account, or use `every login --create-account` to open Every's signup page directly. After you create your account and workspace, return to the terminal and press Enter; the CLI connects through the normal browser OAuth flow.
|
|
78
78
|
|
|
79
|
+
## Switching workspaces
|
|
80
|
+
|
|
81
|
+
Run `every org switch` and pick the workspace in the browser consent page's selector. The token binds one workspace per environment; add `--staging` to switch staging. Use `every org switch --org "<name|slug|id>"` (or `every login --org "<name|slug|id>"`) to verify the selection after login. `--org` does not preselect a workspace; a mismatch keeps your previous credentials. Names can be ambiguous, so use the workspace id when needed. Verify the result with `every whoami --json`. Unset `EVERY_TOKEN` before switching because it overrides stored credentials.
|
|
82
|
+
|
|
79
83
|
## Output contract
|
|
80
84
|
|
|
81
85
|
Every command supports `--json`: exactly one JSON document on stdout, nothing else.
|
package/dist/commands/aliases.js
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
1
2
|
import { CliError } from '../lib/errors.js';
|
|
2
3
|
import { ExitCode } from '../lib/exit-codes.js';
|
|
3
4
|
import { executeToolCall, invokeToolCall, } from './tools.js';
|
|
4
5
|
const INVOICE_STATUSES = new Set(['draft', 'issued', 'void']);
|
|
5
6
|
const PAYMENT_STATUSES = new Set(['unpaid', 'paid', 'overdue', 'partial']);
|
|
6
7
|
const DEAL_STAGES = new Set(['lead', 'opportunity', 'won', 'lost']);
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
// list_companies/list_people (the live People/Companies search tools) take a
|
|
9
|
+
// free-text `query` param — the retired list_clients/list_contacts tools took `name`.
|
|
10
|
+
const NETWORK_SEARCH_QUERY_PARAM = 'query';
|
|
11
|
+
// create_invoice's arguments now nest under a single structured `command` object
|
|
12
|
+
// (server commit that retired the flat client_id argument): command.operation_id
|
|
13
|
+
// (a fresh UUID per write, reused only for the exact server-directed retry),
|
|
14
|
+
// command.party = {kind: person|company, id}, and command.line_items.
|
|
15
|
+
const CREATE_INVOICE_COMMAND_PARAM = 'command';
|
|
16
|
+
const CREATE_INVOICE_OPERATION_ID_PARAM = 'operation_id';
|
|
17
|
+
const CREATE_INVOICE_PARTY_PARAM = 'party';
|
|
9
18
|
const CREATE_INVOICE_LINE_ITEMS_PARAM = 'line_items';
|
|
19
|
+
const PARTY_KIND_PARAM = 'kind';
|
|
20
|
+
const PARTY_ID_PARAM = 'id';
|
|
10
21
|
const LINE_ITEM_DESCRIPTION_PARAM = 'description';
|
|
11
22
|
const LINE_ITEM_QUANTITY_PARAM = 'quantity';
|
|
12
23
|
const LINE_ITEM_UNIT_PRICE_PARAM = 'unit_price';
|
|
@@ -77,7 +88,7 @@ function stripMarkdown(value) {
|
|
|
77
88
|
function cleanClientNameFromLine(value) {
|
|
78
89
|
let name = stripMarkdown(value)
|
|
79
90
|
.replace(/^\s*(?:[-*+]|\d+[.)])\s*/, '')
|
|
80
|
-
.replace(/^client(?:\s+name)?:\s*/i, '')
|
|
91
|
+
.replace(/^(?:client|company|person)(?:\s+name)?:\s*/i, '')
|
|
81
92
|
// Drop a trailing status parenthetical like "(active)" / "(archived)".
|
|
82
93
|
.replace(/\s*\((?:active|inactive|archived)\)\s*$/i, '')
|
|
83
94
|
.trim();
|
|
@@ -124,8 +135,16 @@ function collectStructuredCandidates(value, seen = new Set()) {
|
|
|
124
135
|
}
|
|
125
136
|
const record = value;
|
|
126
137
|
const direct = candidateFromObject(record);
|
|
127
|
-
|
|
128
|
-
|
|
138
|
+
// Once a record itself resolves to a candidate, its own nested fields describe
|
|
139
|
+
// THAT candidate (e.g. a Person/Company's `affiliations[].person`/`.company`
|
|
140
|
+
// sub-objects, which carry their own id+name) rather than sibling matches. Real
|
|
141
|
+
// list_people/list_companies results nest exactly this shape, so descending
|
|
142
|
+
// into an already-matched record's children turned every single real match into
|
|
143
|
+
// a false "multiple candidates" ambiguity — only keep walking children when the
|
|
144
|
+
// current object was NOT itself a match.
|
|
145
|
+
if (direct)
|
|
146
|
+
return [direct];
|
|
147
|
+
return Object.values(record).flatMap((entry) => collectStructuredCandidates(entry, seen));
|
|
129
148
|
}
|
|
130
149
|
function textFromContent(content) {
|
|
131
150
|
if (typeof content === 'string')
|
|
@@ -171,31 +190,49 @@ export function parseClientCandidates(result) {
|
|
|
171
190
|
...parseClientCandidatesFromText(textFromContent(result.content)),
|
|
172
191
|
]);
|
|
173
192
|
}
|
|
174
|
-
function
|
|
193
|
+
function partyCandidatesMessage(label, query, candidates) {
|
|
175
194
|
return [
|
|
176
|
-
`Multiple
|
|
195
|
+
`Multiple ${label}s matching "${query}".`,
|
|
177
196
|
...candidates.map((candidate) => `${candidate.client_id} ${candidate.name}`),
|
|
178
197
|
'Re-run with --client-id <id>',
|
|
179
198
|
].join('\n');
|
|
180
199
|
}
|
|
200
|
+
// --client is the deprecated alias for --company (the historical "client" concept is
|
|
201
|
+
// now the Company record); --person resolves via the People half of the same schema.
|
|
202
|
+
function selectParty(opts) {
|
|
203
|
+
const companyName = nonEmpty(opts.company) ?? nonEmpty(opts.client);
|
|
204
|
+
const personName = nonEmpty(opts.person);
|
|
205
|
+
if (companyName && personName) {
|
|
206
|
+
throw new CliError('Use only one of --company/--client or --person to resolve the invoice recipient', ExitCode.USAGE, 'usage');
|
|
207
|
+
}
|
|
208
|
+
if (personName)
|
|
209
|
+
return { kind: 'person', name: personName };
|
|
210
|
+
if (companyName)
|
|
211
|
+
return { kind: 'company', name: companyName };
|
|
212
|
+
return undefined;
|
|
213
|
+
}
|
|
181
214
|
async function resolveClient(opts) {
|
|
182
215
|
const clientId = nonEmpty(opts.clientId);
|
|
183
|
-
const
|
|
184
|
-
if (clientId)
|
|
185
|
-
return { client_id: clientId, name:
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
216
|
+
const selector = selectParty(opts);
|
|
217
|
+
if (clientId) {
|
|
218
|
+
return { client_id: clientId, kind: selector?.kind ?? 'company', name: selector?.name ?? null };
|
|
219
|
+
}
|
|
220
|
+
if (!selector) {
|
|
221
|
+
throw new CliError('--client, --company, --person, or --client-id is required', ExitCode.USAGE, 'usage');
|
|
222
|
+
}
|
|
223
|
+
const tool = selector.kind === 'person' ? 'list_people' : 'list_companies';
|
|
224
|
+
const label = selector.kind;
|
|
225
|
+
const result = await invokeToolCall(tool, opts, async () => ({
|
|
226
|
+
[NETWORK_SEARCH_QUERY_PARAM]: selector.name,
|
|
191
227
|
}));
|
|
192
228
|
const candidates = parseClientCandidates(result);
|
|
193
|
-
if (candidates.length === 1)
|
|
194
|
-
return candidates[0];
|
|
229
|
+
if (candidates.length === 1) {
|
|
230
|
+
return { client_id: candidates[0].client_id, kind: selector.kind, name: candidates[0].name };
|
|
231
|
+
}
|
|
195
232
|
if (candidates.length === 0) {
|
|
196
|
-
throw new CliError(`No
|
|
233
|
+
throw new CliError(`No ${label} matching "${selector.name}". Run: every tool call ${tool} --json`, ExitCode.NOT_FOUND, 'not_found');
|
|
197
234
|
}
|
|
198
|
-
throw new CliError(
|
|
235
|
+
throw new CliError(partyCandidatesMessage(label, selector.name, candidates), ExitCode.NOT_FOUND, 'not_found', { candidates });
|
|
199
236
|
}
|
|
200
237
|
export async function invoiceListCommand(opts = {}) {
|
|
201
238
|
const args = {};
|
|
@@ -214,15 +251,24 @@ export async function invoiceCreateCommand(opts = {}) {
|
|
|
214
251
|
? 1
|
|
215
252
|
: parsePositiveNumber(opts.quantity, '--quantity');
|
|
216
253
|
const resolvedClient = await resolveClient(opts);
|
|
254
|
+
// A fresh operation_id per invocation, computed once here (not inside the args
|
|
255
|
+
// factory) so the one server-directed confirmation retry in tools.ts reuses this
|
|
256
|
+
// exact same closed-over `args` object/UUID instead of minting a second one.
|
|
217
257
|
const args = {
|
|
218
|
-
[
|
|
219
|
-
|
|
220
|
-
{
|
|
221
|
-
[
|
|
222
|
-
[
|
|
223
|
-
[LINE_ITEM_UNIT_PRICE_PARAM]: amount,
|
|
258
|
+
[CREATE_INVOICE_COMMAND_PARAM]: {
|
|
259
|
+
[CREATE_INVOICE_OPERATION_ID_PARAM]: randomUUID(),
|
|
260
|
+
[CREATE_INVOICE_PARTY_PARAM]: {
|
|
261
|
+
[PARTY_KIND_PARAM]: resolvedClient.kind,
|
|
262
|
+
[PARTY_ID_PARAM]: resolvedClient.client_id,
|
|
224
263
|
},
|
|
225
|
-
|
|
264
|
+
[CREATE_INVOICE_LINE_ITEMS_PARAM]: [
|
|
265
|
+
{
|
|
266
|
+
[LINE_ITEM_DESCRIPTION_PARAM]: opts.description ?? 'Services',
|
|
267
|
+
[LINE_ITEM_QUANTITY_PARAM]: quantity,
|
|
268
|
+
[LINE_ITEM_UNIT_PRICE_PARAM]: amount,
|
|
269
|
+
},
|
|
270
|
+
],
|
|
271
|
+
},
|
|
226
272
|
};
|
|
227
273
|
await executeToolCall('create_invoice', opts, async () => args, (data) => ({ ...data, resolved_client: resolvedClient }));
|
|
228
274
|
}
|
|
@@ -244,7 +290,8 @@ export async function dealMoveCommand(dealId, stage, opts = {}) {
|
|
|
244
290
|
export async function contactListCommand(opts = {}) {
|
|
245
291
|
const args = {};
|
|
246
292
|
if (opts.search !== undefined)
|
|
247
|
-
args
|
|
293
|
+
args[NETWORK_SEARCH_QUERY_PARAM] = opts.search;
|
|
248
294
|
addLimit(args, opts.limit);
|
|
249
|
-
|
|
295
|
+
// list_contacts is retired; list_people is the live People/Companies replacement.
|
|
296
|
+
await executeToolCall('list_people', opts, async () => args);
|
|
250
297
|
}
|
package/dist/commands/auth.js
CHANGED
|
@@ -9,7 +9,7 @@ import { mcpCall } from '../lib/mcp.js';
|
|
|
9
9
|
import { loginFlow, openBrowser as openBrowserDefault } from '../lib/auth/flow.js';
|
|
10
10
|
import { decodeJwtClaims } from '../lib/auth/jwt.js';
|
|
11
11
|
import { createTokenStore, deleteTokenFromAllStores, getAuthStatus, getToken, resolveAuthTarget, } from '../lib/auth/tokens.js';
|
|
12
|
-
import { fetchUserInfo } from '../lib/auth/userinfo.js';
|
|
12
|
+
import { fetchUserInfo, invalidateUserInfoCache, readCachedUserInfo, requestUserInfo, writeUserInfoCache, } from '../lib/auth/userinfo.js';
|
|
13
13
|
import { maybeShowSkillHint, readHints, writeHints, } from '../lib/hints.js';
|
|
14
14
|
import { emit } from '../lib/output.js';
|
|
15
15
|
import { installBundledSkill } from './skills.js';
|
|
@@ -134,7 +134,7 @@ function loginHuman(data) {
|
|
|
134
134
|
if (data.every_token)
|
|
135
135
|
return 'EVERY_TOKEN is set; login is unnecessary.';
|
|
136
136
|
const identity = data.email ?? data.subject;
|
|
137
|
-
return
|
|
137
|
+
return `Logged in as ${identity ?? 'unknown'} · workspace ${formatOrg(data.org_name, data.org_id)}\nSwitch workspace: every org switch`;
|
|
138
138
|
}
|
|
139
139
|
function loginNextSteps() {
|
|
140
140
|
return [
|
|
@@ -181,6 +181,7 @@ function orgHuman(org) {
|
|
|
181
181
|
`Org: ${formatOrg(org.org_name, org.org_id)}`,
|
|
182
182
|
`Slug: ${org.org_slug ?? 'none'}`,
|
|
183
183
|
'Note: the server scopes writes to this org.',
|
|
184
|
+
'Switch: every org switch [--org <name|slug|id>]',
|
|
184
185
|
];
|
|
185
186
|
return lines.join('\n');
|
|
186
187
|
}
|
|
@@ -201,39 +202,131 @@ async function verifyMcpLiveness(baseUrl, token) {
|
|
|
201
202
|
tools: Array.isArray(body.tools) ? body.tools.length : 0,
|
|
202
203
|
};
|
|
203
204
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
205
|
+
function validateOrgTarget(target) {
|
|
206
|
+
if (!target.trim()) {
|
|
207
|
+
throw new CliError('--org must not be empty or whitespace-only', ExitCode.USAGE, 'usage');
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
/** IDs are exact; slugs ignore case; display names also trim and normalize Unicode. */
|
|
211
|
+
export function matchesOrg(target, info) {
|
|
212
|
+
validateOrgTarget(target);
|
|
213
|
+
const name = (value) => value.trim().normalize('NFC').toLowerCase();
|
|
214
|
+
return target === info.org_id ||
|
|
215
|
+
(info.org_slug !== null && target.toLowerCase() === info.org_slug.toLowerCase()) ||
|
|
216
|
+
(info.org_name !== null && name(target) === name(info.org_name));
|
|
217
|
+
}
|
|
218
|
+
function validateBrowserLogin(opts, switching = false) {
|
|
219
|
+
if (opts.org !== undefined)
|
|
220
|
+
validateOrgTarget(opts.org);
|
|
221
|
+
if (process.env.EVERY_TOKEN && (switching || opts.org !== undefined)) {
|
|
222
|
+
throw new CliError('Workspace switching requires stored credentials; unset EVERY_TOKEN and try again.', ExitCode.USAGE, 'usage');
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/** Exchange, verify, then commit. A failed assertion never mutates stored auth or identity. */
|
|
226
|
+
export async function completeBrowserLogin(opts, deps = {}, switching = false) {
|
|
227
|
+
validateBrowserLogin(opts, switching);
|
|
228
|
+
const errorOutput = deps.errorOutput ?? process.stderr;
|
|
209
229
|
const baseUrl = resolveBaseUrl({ staging: opts.staging });
|
|
210
230
|
const { environmentKey } = resolveAuthTarget({ baseUrl });
|
|
211
|
-
|
|
231
|
+
errorOutput.write(opts.org === undefined
|
|
232
|
+
? "Pick the workspace in the consent page's selector.\n"
|
|
233
|
+
: `In the consent page's selector, pick "${opts.org}".\n`);
|
|
234
|
+
const tokenSet = await (deps.loginFlow ?? loginFlow)({
|
|
212
235
|
baseUrl,
|
|
213
236
|
onAuthorizationUrl(url) {
|
|
214
|
-
|
|
237
|
+
errorOutput.write(`Open this URL to log in:\n${url}\n`);
|
|
215
238
|
},
|
|
216
239
|
});
|
|
217
|
-
|
|
218
|
-
|
|
240
|
+
let userinfo;
|
|
241
|
+
try {
|
|
242
|
+
userinfo = await requestUserInfo({ baseUrl, accessToken: tokenSet.access_token });
|
|
243
|
+
}
|
|
244
|
+
catch {
|
|
245
|
+
if (switching || opts.org !== undefined) {
|
|
246
|
+
throw new CliError('Could not verify the workspace because userinfo is unreachable. Previous credentials kept; try again.', ExitCode.NETWORK, 'network');
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
if (opts.org !== undefined && userinfo && !matchesOrg(opts.org, userinfo)) {
|
|
250
|
+
throw new CliError(`Token is bound to workspace ${formatOrg(userinfo.org_name, userinfo.org_id)}, but requested "${opts.org}". ` +
|
|
251
|
+
`Retry: every org switch --org "${opts.org}" and pick that workspace in the consent page. ` +
|
|
252
|
+
'Use the workspace id as the unambiguous form.', ExitCode.GENERIC, 'org_mismatch');
|
|
253
|
+
}
|
|
254
|
+
const store = deps.store ?? await createTokenStore();
|
|
255
|
+
const previous = await store.get(environmentKey);
|
|
256
|
+
try {
|
|
257
|
+
await store.set(environmentKey, tokenSet);
|
|
258
|
+
}
|
|
259
|
+
catch (err) {
|
|
260
|
+
try {
|
|
261
|
+
if (previous)
|
|
262
|
+
await store.set(environmentKey, previous);
|
|
263
|
+
else
|
|
264
|
+
await store.delete(environmentKey);
|
|
265
|
+
}
|
|
266
|
+
catch {
|
|
267
|
+
errorOutput.write('Warning: could not restore previous credentials after a storage failure.\n');
|
|
268
|
+
}
|
|
269
|
+
throw err;
|
|
270
|
+
}
|
|
271
|
+
if (userinfo) {
|
|
272
|
+
try {
|
|
273
|
+
await writeUserInfoCache(baseUrl, userinfo);
|
|
274
|
+
}
|
|
275
|
+
catch {
|
|
276
|
+
// A failed write may have left the old identity behind. Remove it if possible.
|
|
277
|
+
await invalidateUserInfoCache(baseUrl).catch(() => undefined);
|
|
278
|
+
errorOutput.write('Warning: logged in, but could not cache the current identity.\n');
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
await invalidateUserInfoCache(baseUrl).catch(() => {
|
|
283
|
+
errorOutput.write('Warning: could not invalidate the previous identity cache.\n');
|
|
284
|
+
});
|
|
285
|
+
errorOutput.write('Warning: logged in, but userinfo is unreachable; workspace identity is unknown.\n');
|
|
286
|
+
}
|
|
219
287
|
const identity = identityFromToken(tokenSet.access_token);
|
|
220
|
-
|
|
288
|
+
return {
|
|
221
289
|
logged_in: true,
|
|
222
290
|
issuer: tokenSet.issuer,
|
|
223
|
-
subject: identity.subject,
|
|
224
|
-
email: identity.email,
|
|
291
|
+
subject: userinfo?.user_id ?? identity.subject,
|
|
292
|
+
email: userinfo?.email ?? identity.email,
|
|
225
293
|
storage_backend: store.backend,
|
|
226
294
|
every_token: false,
|
|
295
|
+
user_id: userinfo?.user_id ?? null,
|
|
296
|
+
org_id: userinfo?.org_id ?? null,
|
|
297
|
+
org_slug: userinfo?.org_slug ?? null,
|
|
298
|
+
org_name: userinfo?.org_name ?? null,
|
|
227
299
|
};
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
300
|
+
}
|
|
301
|
+
export async function runBrowserLogin(opts, deps = {}) {
|
|
302
|
+
const data = await completeBrowserLogin(opts, deps);
|
|
303
|
+
emitLogin(data, opts, deps.output, deps.errorOutput);
|
|
304
|
+
await maybeOfferSkillAfterLogin({ json: opts.json, ...deps });
|
|
305
|
+
}
|
|
306
|
+
export async function orgSwitchCommand(opts = {}, deps = {}) {
|
|
307
|
+
validateBrowserLogin(opts, true);
|
|
308
|
+
if (!(deps.output ?? process.stdout).isTTY) {
|
|
309
|
+
throw new CliError('org switch requires a browser and an interactive terminal', ExitCode.AUTH, 'auth');
|
|
310
|
+
}
|
|
311
|
+
const baseUrl = resolveBaseUrl({ staging: opts.staging });
|
|
312
|
+
const previous = await readCachedUserInfo(baseUrl, { allowStale: true }).catch(() => undefined);
|
|
313
|
+
const login = await completeBrowserLogin(opts, deps, true);
|
|
314
|
+
const data = {
|
|
315
|
+
switched: true,
|
|
316
|
+
org_id: login.org_id,
|
|
317
|
+
org_slug: login.org_slug,
|
|
318
|
+
org_name: login.org_name,
|
|
319
|
+
previous_org_id: previous?.org_id ?? null,
|
|
320
|
+
environment: environmentNameForBaseUrl(baseUrl),
|
|
321
|
+
};
|
|
322
|
+
if (opts.json)
|
|
323
|
+
emit(data, { json: true, staging: opts.staging });
|
|
324
|
+
else
|
|
325
|
+
(deps.output ?? process.stdout).write(`Switched to ${formatOrg(data.org_name, data.org_id)} · ${login.email ?? 'unknown'}\n`);
|
|
326
|
+
await maybeOfferSkillAfterLogin({ json: opts.json, ...deps });
|
|
235
327
|
}
|
|
236
328
|
export async function createAccountFlow(opts = {}) {
|
|
329
|
+
validateBrowserLogin(opts);
|
|
237
330
|
const input = opts.input ?? process.stdin;
|
|
238
331
|
const output = opts.output ?? process.stdout;
|
|
239
332
|
const errorOutput = opts.errorOutput ?? process.stderr;
|
|
@@ -275,6 +368,7 @@ async function promptForLoggedOutAction() {
|
|
|
275
368
|
}
|
|
276
369
|
}
|
|
277
370
|
export async function loginCommand(opts = {}) {
|
|
371
|
+
validateBrowserLogin(opts);
|
|
278
372
|
if (process.env.EVERY_TOKEN) {
|
|
279
373
|
const identity = identityFromToken(process.env.EVERY_TOKEN);
|
|
280
374
|
const data = {
|
|
@@ -284,6 +378,10 @@ export async function loginCommand(opts = {}) {
|
|
|
284
378
|
email: identity.email,
|
|
285
379
|
storage_backend: null,
|
|
286
380
|
every_token: true,
|
|
381
|
+
user_id: null,
|
|
382
|
+
org_id: null,
|
|
383
|
+
org_slug: null,
|
|
384
|
+
org_name: null,
|
|
287
385
|
};
|
|
288
386
|
emitLogin(data, opts);
|
|
289
387
|
return;
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { readFileSync } from 'node:fs';
|
|
|
3
3
|
import { Command, CommanderError } from 'commander';
|
|
4
4
|
import { pingCommand } from './commands/ping.js';
|
|
5
5
|
import { docsCommand } from './commands/docs.js';
|
|
6
|
-
import { authStatusCommand, loginCommand, logoutCommand, orgCommand, whoamiCommand, } from './commands/auth.js';
|
|
6
|
+
import { authStatusCommand, loginCommand, logoutCommand, orgCommand, orgSwitchCommand, whoamiCommand, } from './commands/auth.js';
|
|
7
7
|
import { policyExplainCommand } from './commands/policy.js';
|
|
8
8
|
import { toolCallCommand, toolsDescribeCommand, toolsListCommand, } from './commands/tools.js';
|
|
9
9
|
import { contactListCommand, dealListCommand, dealMoveCommand, invoiceCreateCommand, invoiceListCommand, invoiceSendCommand, } from './commands/aliases.js';
|
|
@@ -60,12 +60,14 @@ withGlobalOptions(program
|
|
|
60
60
|
withGlobalOptions(program
|
|
61
61
|
.command('login')
|
|
62
62
|
.description('Log in (or create an account) with browser-based OAuth and store tokens locally')
|
|
63
|
-
.option('--create-account', 'create a new Every account, then connect the CLI')
|
|
63
|
+
.option('--create-account', 'create a new Every account, then connect the CLI')
|
|
64
|
+
.option('--org <id|slug|name>', 'verify the workspace selected during login')).action(async (_options, command) => {
|
|
64
65
|
const opts = command.optsWithGlobals();
|
|
65
66
|
await loginCommand({
|
|
66
67
|
json: opts.json,
|
|
67
68
|
staging: opts.staging,
|
|
68
69
|
createAccount: opts.createAccount,
|
|
70
|
+
org: opts.org,
|
|
69
71
|
});
|
|
70
72
|
});
|
|
71
73
|
withGlobalOptions(program
|
|
@@ -85,12 +87,19 @@ withGlobalOptions(authCommand.command('status').description('Show local auth sta
|
|
|
85
87
|
const opts = command.optsWithGlobals();
|
|
86
88
|
await authStatusCommand({ json: opts.json, staging: opts.staging });
|
|
87
89
|
});
|
|
88
|
-
withGlobalOptions(program
|
|
90
|
+
const org = withGlobalOptions(program
|
|
89
91
|
.command('org')
|
|
90
|
-
.
|
|
92
|
+
.allowExcessArguments(false)
|
|
93
|
+
.description('Show or switch the workspace bound to the current token')).action(async (_options, command) => {
|
|
91
94
|
const opts = command.optsWithGlobals();
|
|
92
95
|
await orgCommand({ json: opts.json, staging: opts.staging });
|
|
93
96
|
});
|
|
97
|
+
withGlobalOptions(org.command('switch')
|
|
98
|
+
.description('Switch workspace using the browser consent selector')
|
|
99
|
+
.option('--org <ref>', 'verify the selected workspace by id, slug, or name')).action(async (_options, command) => {
|
|
100
|
+
const opts = command.optsWithGlobals();
|
|
101
|
+
await orgSwitchCommand({ json: opts.json, staging: opts.staging, org: opts.org });
|
|
102
|
+
});
|
|
94
103
|
const toolsCommand = withGlobalOptions(program.command('tools').description('Inspect the Every MCP tool registry'));
|
|
95
104
|
withGlobalOptions(toolsCommand
|
|
96
105
|
.command('list')
|
|
@@ -163,10 +172,10 @@ const invoiceCommand = withToolExecutionOptions(withGlobalOptions(program
|
|
|
163
172
|
.addHelpText('after', [
|
|
164
173
|
'',
|
|
165
174
|
'Create a simple invoice:',
|
|
166
|
-
' every invoice create --
|
|
175
|
+
' every invoice create --company "Acme" --amount 100 --yes --json',
|
|
167
176
|
'',
|
|
168
177
|
'For rich invoices, use the full tool:',
|
|
169
|
-
' every tool call create_invoice --arg
|
|
178
|
+
' every tool call create_invoice --arg command=\'{"operation_id":"<uuid>","party":{"kind":"company","id":"<id>"},"line_items":[{"description":"Work","quantity":1,"unit_price":100}]}\'',
|
|
170
179
|
' every tool call create_invoice --args -',
|
|
171
180
|
' every tool call create_invoice --args file.json',
|
|
172
181
|
'',
|
|
@@ -174,8 +183,10 @@ const invoiceCommand = withToolExecutionOptions(withGlobalOptions(program
|
|
|
174
183
|
withGlobalOptions(withToolExecutionOptions(invoiceCommand
|
|
175
184
|
.command('create')
|
|
176
185
|
.description('Create a simple draft invoice')
|
|
177
|
-
.option('--client <name>', '
|
|
178
|
-
.option('--
|
|
186
|
+
.option('--client <name>', 'company name to resolve via list_companies (deprecated alias for --company)')
|
|
187
|
+
.option('--company <name>', 'company name to resolve via list_companies')
|
|
188
|
+
.option('--person <name>', 'person name to resolve via list_people')
|
|
189
|
+
.option('--client-id <id>', 'client id; skips name resolution')
|
|
179
190
|
.requiredOption('--amount <n>', 'unit price for the single line item')
|
|
180
191
|
.option('--description <text>', 'line item description')
|
|
181
192
|
.option('--quantity <q>', 'line item quantity'))).action(async (_options, command) => {
|
|
@@ -189,6 +200,8 @@ withGlobalOptions(withToolExecutionOptions(invoiceCommand
|
|
|
189
200
|
readOnly: opts.readOnly,
|
|
190
201
|
timeout: opts.timeout,
|
|
191
202
|
client: opts.client,
|
|
203
|
+
company: opts.company,
|
|
204
|
+
person: opts.person,
|
|
192
205
|
clientId: opts.clientId,
|
|
193
206
|
amount: opts.amount,
|
|
194
207
|
description: opts.description,
|
package/dist/lib/auth/flow.js
CHANGED
|
@@ -136,7 +136,7 @@ export async function loginFlow(opts) {
|
|
|
136
136
|
const startedAt = Date.now();
|
|
137
137
|
const state = createState();
|
|
138
138
|
const pkce = createPkcePair();
|
|
139
|
-
const loopback = await createLoopbackCallbackServer(state);
|
|
139
|
+
const loopback = await (opts.createCallbackServer ?? createLoopbackCallbackServer)(state);
|
|
140
140
|
const timeout = new Promise((_, reject) => {
|
|
141
141
|
setTimeout(() => {
|
|
142
142
|
reject(new CliError('Login timed out after 300s', ExitCode.AUTH, 'auth'));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mkdir, readFile, rename, stat, writeFile, chmod } from 'node:fs/promises';
|
|
1
|
+
import { mkdir, readFile, rename, stat, writeFile, chmod, rm } from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { getConfigDir } from '../config.js';
|
|
4
4
|
import { CliError } from '../errors.js';
|
|
@@ -64,7 +64,7 @@ export async function readCachedUserInfo(baseUrl, { allowStale = false, now = Da
|
|
|
64
64
|
}
|
|
65
65
|
return parsed.userinfo;
|
|
66
66
|
}
|
|
67
|
-
async function writeUserInfoCache(baseUrl, userinfo) {
|
|
67
|
+
export async function writeUserInfoCache(baseUrl, userinfo) {
|
|
68
68
|
const filePath = userInfoCacheFilePath(baseUrl);
|
|
69
69
|
await mkdir(path.dirname(filePath), { recursive: true, mode: 0o700 });
|
|
70
70
|
const tempPath = `${filePath}.${process.pid}.tmp`;
|
|
@@ -73,6 +73,9 @@ async function writeUserInfoCache(baseUrl, userinfo) {
|
|
|
73
73
|
await rename(tempPath, filePath);
|
|
74
74
|
await chmod(filePath, 0o600);
|
|
75
75
|
}
|
|
76
|
+
export async function invalidateUserInfoCache(baseUrl) {
|
|
77
|
+
await rm(userInfoCacheFilePath(baseUrl), { force: true });
|
|
78
|
+
}
|
|
76
79
|
export async function userInfoCacheFileMode(baseUrl) {
|
|
77
80
|
try {
|
|
78
81
|
return (await stat(userInfoCacheFilePath(baseUrl))).mode & 0o777;
|
|
@@ -100,6 +103,12 @@ export async function fetchUserInfo(opts = {}) {
|
|
|
100
103
|
if (cached)
|
|
101
104
|
return cached;
|
|
102
105
|
}
|
|
106
|
+
const userinfo = await requestUserInfo({ baseUrl, accessToken: token });
|
|
107
|
+
await writeUserInfoCache(baseUrl, userinfo);
|
|
108
|
+
return userinfo;
|
|
109
|
+
}
|
|
110
|
+
/** Verify a candidate credential without reading or changing stored auth/identity. */
|
|
111
|
+
export async function requestUserInfo({ baseUrl, accessToken }) {
|
|
103
112
|
const discovery = await discoverOAuth(baseUrl);
|
|
104
113
|
const openid = await fetchOpenIdConfiguration(discovery.authServer.issuer);
|
|
105
114
|
let raw;
|
|
@@ -107,7 +116,7 @@ export async function fetchUserInfo(opts = {}) {
|
|
|
107
116
|
raw = await fetchJsonWithTimeout(openid.userinfo_endpoint, {
|
|
108
117
|
headers: {
|
|
109
118
|
accept: 'application/json',
|
|
110
|
-
authorization: `Bearer ${
|
|
119
|
+
authorization: `Bearer ${accessToken}`,
|
|
111
120
|
},
|
|
112
121
|
}, USERINFO_TIMEOUT_MS);
|
|
113
122
|
}
|
|
@@ -120,7 +129,5 @@ export async function fetchUserInfo(opts = {}) {
|
|
|
120
129
|
}
|
|
121
130
|
throw err;
|
|
122
131
|
}
|
|
123
|
-
|
|
124
|
-
await writeUserInfoCache(baseUrl, userinfo);
|
|
125
|
-
return userinfo;
|
|
132
|
+
return normalizeUserInfo(raw);
|
|
126
133
|
}
|
package/dist/lib/policy.js
CHANGED
|
@@ -58,14 +58,15 @@ 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
|
-
//
|
|
62
|
-
//
|
|
63
|
-
//
|
|
64
|
-
|
|
61
|
+
// 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). None
|
|
63
|
+
// match the send_/delete_/void_/cancel_ name patterns, so without these
|
|
64
|
+
// entries their tier would rest entirely on server annotations.
|
|
65
|
+
if (name === 'create_delivery_deal') {
|
|
65
66
|
return {
|
|
66
67
|
level: 'write',
|
|
67
68
|
source: 'override',
|
|
68
|
-
reason: '
|
|
69
|
+
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.',
|
|
69
70
|
};
|
|
70
71
|
}
|
|
71
72
|
if (name === 'set_deal_title') {
|
|
@@ -86,7 +87,7 @@ function overrideClassification(name) {
|
|
|
86
87
|
return {
|
|
87
88
|
level: 'destructive',
|
|
88
89
|
source: 'override',
|
|
89
|
-
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
|
|
90
|
+
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.',
|
|
90
91
|
};
|
|
91
92
|
}
|
|
92
93
|
return undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: use-every
|
|
3
|
-
description: Drive the Every AI CLI (`every`) to manage the user's service business — invoices,
|
|
3
|
+
description: Drive the Every AI CLI (`every`) to manage the user's service business — invoices, People, Companies, proposals, deals, pipeline, payments, services, custom fields, and scheduled tasks. Use when the user asks “who owes me money?”, wants a lead or deal follow-up, asks to look up, create, update, convert, or send a business record, or mentions their Every workspace.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Use Every
|
|
@@ -13,7 +13,7 @@ For headless use, accept `EVERY_TOKEN` from the environment instead of browser l
|
|
|
13
13
|
|
|
14
14
|
## What Every Is
|
|
15
15
|
|
|
16
|
-
Use Every as a service-business workspace for the sales pipeline, deals,
|
|
16
|
+
Use Every as a service-business workspace for the sales pipeline, deals, People and Companies, proposals, invoices, payments, and services. The authenticated CLI operates on one connected Every workspace at a time. The token binds one workspace per environment; follow the workspace switching rule below when the user means a different business.
|
|
17
17
|
|
|
18
18
|
## Required Workflow
|
|
19
19
|
|
|
@@ -69,9 +69,13 @@ Use `every whoami --json` to verify the authenticated user, org, environment, ba
|
|
|
69
69
|
|
|
70
70
|
## Domain Rules
|
|
71
71
|
|
|
72
|
+
### Verify the workspace before acting
|
|
73
|
+
|
|
74
|
+
Never assume the bound workspace. When the user names a different workspace, run `every org switch --org "<name>" --json`, then re-verify with `every whoami --json` before continuing. The browser consent page is the picker; `--org` verifies the selection after login. A token binds one workspace per environment. Use the workspace id when names are ambiguous. If `EVERY_TOKEN` is set, ask the user to unset it before switching.
|
|
75
|
+
|
|
72
76
|
### Deal activity auto-tracking is creation-only
|
|
73
77
|
|
|
74
|
-
Creating a proposal or invoice automatically records activity on a matching deal when exactly one deal/
|
|
78
|
+
Creating a proposal or invoice automatically records activity on a matching deal when exactly one deal/party (Person or Company) matches. After an Every creation command, never double-log that action:
|
|
75
79
|
|
|
76
80
|
```bash
|
|
77
81
|
every invoice create --client-id <client_id> --amount 100 --yes --json
|
|
@@ -85,7 +89,7 @@ every deal list --search "Acme" --json
|
|
|
85
89
|
every tool call log_deal_activity --arg deal_id=<deal_id> --arg note="Call completed; client approved scope" --yes --json
|
|
86
90
|
```
|
|
87
91
|
|
|
88
|
-
### Won deals require
|
|
92
|
+
### Won deals require a linked Person or Company
|
|
89
93
|
|
|
90
94
|
Pipeline stages are `lead`, `opportunity`, `won`, and `lost`:
|
|
91
95
|
|
|
@@ -93,7 +97,7 @@ Pipeline stages are `lead`, `opportunity`, `won`, and `lost`:
|
|
|
93
97
|
every deal move <deal_id> won --yes --json
|
|
94
98
|
```
|
|
95
99
|
|
|
96
|
-
Moving to `won` requires
|
|
100
|
+
Moving to `won` requires the deal to already be linked to a Person or Company. If the command errors because no party is assigned, assign one first (e.g. via `create_deal`'s `party`, or by updating the deal's target in the Every app), then retry the same command.
|
|
97
101
|
|
|
98
102
|
### Invoice rates and tax
|
|
99
103
|
|
|
@@ -101,7 +105,7 @@ Treat `unit_price` as the per-unit rate, not the line total. The simple CLI's `-
|
|
|
101
105
|
|
|
102
106
|
```bash
|
|
103
107
|
every invoice create --client-id <client_id> --description "Workshop" --quantity 3 --amount 100 --yes --json
|
|
104
|
-
every tool call create_invoice --arg client_id
|
|
108
|
+
every tool call create_invoice --arg command='{"operation_id":"<uuid>","party":{"kind":"company","id":"<client_id>"},"line_items":[{"description":"Workshop","quantity":3,"unit_price":100}]}' --yes --json
|
|
105
109
|
```
|
|
106
110
|
|
|
107
111
|
Leave `sales_tax_applied` unset so the business default applies. Never add tax as a line item. When currency, tax, or timezone matters, read settings first with `every tool call business_settings --json`; let Every compute tax, numbering, due dates, and totals.
|
|
@@ -140,7 +144,7 @@ Calendar tools operate on the user's personal calendar. Confirm attendees and ti
|
|
|
140
144
|
|
|
141
145
|
### Custom fields are schema, not events
|
|
142
146
|
|
|
143
|
-
`every tool call set_meta_fields ...` stores current state (e.g. a tracked boolean) on a
|
|
147
|
+
`every tool call set_meta_fields ...` stores current state (e.g. a tracked boolean) on a Person, Company, or deal; missing field definitions are created automatically, but check `every tool call list_meta_field_definitions --json` first and reuse an existing one when it fits. Something that *happened* (a call, visit, touchpoint) belongs in `log_deal_activity`, not a meta field. Tags are the `custom.tags` list field, not a separate feature.
|
|
144
148
|
|
|
145
149
|
### Scheduled tasks report in-app, never in this session
|
|
146
150
|
|
|
@@ -207,11 +211,11 @@ Intake a new lead:
|
|
|
207
211
|
|
|
208
212
|
```bash
|
|
209
213
|
every contact list --search "person@example.com" --json
|
|
210
|
-
every tool call
|
|
214
|
+
every tool call create_person --args person.json --yes --json
|
|
211
215
|
every tool call create_deal --args deal.json --yes --json
|
|
212
216
|
```
|
|
213
217
|
|
|
214
|
-
Search
|
|
218
|
+
Search People first because email deduplication is real. Create only missing records, then progress the deal as the relationship develops.
|
|
215
219
|
|
|
216
220
|
For a general activity snapshot, combine complete/paginated invoice reads with recent payments and expenses. Use the currency from `business_settings`; if any source is only a partial page, describe it as recent activity rather than a definitive cash position.
|
|
217
221
|
|