eversince 0.2.5 → 0.2.7
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/dist/auth/oauth.js +3 -3
- package/dist/bridge.js +4 -2
- package/dist/client.js +16 -3
- package/dist/commands/auth.js +17 -1
- package/dist/commands/download.js +3 -1
- package/dist/commands/init.js +17 -15
- package/dist/commands/jobs.js +1 -1
- package/dist/host-agent.js +14 -0
- package/dist/index.js +6 -1
- package/dist/local.js +3 -1
- package/package.json +1 -1
package/dist/auth/oauth.js
CHANGED
|
@@ -83,11 +83,11 @@ function openBrowser(url) {
|
|
|
83
83
|
catch {
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
const DONE_PAGE = `<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>
|
|
86
|
+
const DONE_PAGE = `<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Signed in to Eversince</title>
|
|
87
87
|
<style>body{font-family:Inter,-apple-system,system-ui,sans-serif;display:grid;place-items:center;height:100vh;margin:0;padding:0 16px;background:#fff;color:#18181b;text-align:center;-webkit-font-smoothing:antialiased}
|
|
88
|
-
h1{font-size:14px;font-weight:
|
|
88
|
+
h1{font-size:14px;font-weight:440;margin:0}p{font-size:14px;color:#71717a;margin:6px 0 0}
|
|
89
89
|
@media(prefers-color-scheme:dark){body{background:#161616;color:#f4f4f5}p{color:#a1a1aa}}</style>
|
|
90
|
-
<body><div><h1>
|
|
90
|
+
<body><div><h1>Signed in to Eversince</h1><p>You can close this tab.</p></div>`;
|
|
91
91
|
const PREFERRED_PORTS = [51703, 51704, 51705, 0];
|
|
92
92
|
async function awaitCallback(timeoutMs) {
|
|
93
93
|
let settle = null;
|
package/dist/bridge.js
CHANGED
|
@@ -115,8 +115,10 @@ export function runBridge(options) {
|
|
|
115
115
|
}
|
|
116
116
|
const envelope = body;
|
|
117
117
|
const said = typeof envelope?.error?.message === 'string' ? envelope.error.message : null;
|
|
118
|
-
if (res.status === 503 || res.status === 504)
|
|
119
|
-
|
|
118
|
+
if (res.status === 503 || res.status === 504) {
|
|
119
|
+
const wait = Number(res.headers.get('retry-after'));
|
|
120
|
+
return rpcError(id, said ?? `Eversince is busy right now. Retry the call in ${Number.isFinite(wait) && wait > 0 ? `${wait} seconds` : 'a few seconds'}.`);
|
|
121
|
+
}
|
|
120
122
|
return rpcError(id, said ?? `Eversince could not answer (status ${res.status}). Retry the call.`);
|
|
121
123
|
}
|
|
122
124
|
async function relay(line) {
|
package/dist/client.js
CHANGED
|
@@ -29,6 +29,7 @@ const RETRYABLE_STATUS = new Set([429, 502, 503, 504]);
|
|
|
29
29
|
const MAX_ATTEMPTS = 4;
|
|
30
30
|
const MAX_WRITE_ATTEMPTS = 2;
|
|
31
31
|
const WRITE_RETRY_PAUSE_MS = 500;
|
|
32
|
+
const RETRY_PAUSE_MAX_MS = 30_000;
|
|
32
33
|
class RenewalUnreachable extends Error {
|
|
33
34
|
}
|
|
34
35
|
function sleep(ms) {
|
|
@@ -166,6 +167,7 @@ export class Client {
|
|
|
166
167
|
const idempotencyKey = options.idempotencyKey ?? (isWrite ? randomUUID() : undefined);
|
|
167
168
|
const maxAttempts = isWrite ? MAX_WRITE_ATTEMPTS : MAX_ATTEMPTS;
|
|
168
169
|
let lastError = null;
|
|
170
|
+
let giveUp = null;
|
|
169
171
|
let refreshedOnce = false;
|
|
170
172
|
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
171
173
|
if (this.local)
|
|
@@ -202,7 +204,14 @@ export class Client {
|
|
|
202
204
|
}
|
|
203
205
|
if (res.status === 401 && this.local && !refreshedOnce) {
|
|
204
206
|
refreshedOnce = true;
|
|
205
|
-
|
|
207
|
+
let token;
|
|
208
|
+
try {
|
|
209
|
+
token = await this.local.reconnect();
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
throw new ApiError(401, { code: 'unauthorized', message: error instanceof Error ? error.message : 'Run eversince init to connect again.', retryable: false }, requestId);
|
|
213
|
+
}
|
|
214
|
+
this.credentials = { ...this.credentials, token };
|
|
206
215
|
continue;
|
|
207
216
|
}
|
|
208
217
|
if (res.status === 401 && this.credentials.kind === 'oauth' && !refreshedOnce) {
|
|
@@ -218,8 +227,12 @@ export class Client {
|
|
|
218
227
|
};
|
|
219
228
|
const error = new ApiError(res.status, body, requestId);
|
|
220
229
|
const canRetry = attempt < maxAttempts - 1 && (isWrite ? res.status === 429 : RETRYABLE_STATUS.has(res.status));
|
|
230
|
+
const retryAfter = Number(res.headers.get('retry-after'));
|
|
231
|
+
if (canRetry && retryAfter * 1000 > RETRY_PAUSE_MAX_MS) {
|
|
232
|
+
giveUp = error;
|
|
233
|
+
throw error;
|
|
234
|
+
}
|
|
221
235
|
if (canRetry) {
|
|
222
|
-
const retryAfter = Number(res.headers.get('retry-after'));
|
|
223
236
|
const pause = Number.isFinite(retryAfter) && retryAfter > 0
|
|
224
237
|
? retryAfter * 1000
|
|
225
238
|
: isWrite ? WRITE_RETRY_PAUSE_MS : backoffMs(attempt);
|
|
@@ -236,7 +249,7 @@ export class Client {
|
|
|
236
249
|
}
|
|
237
250
|
catch (error) {
|
|
238
251
|
if (error instanceof ApiError) {
|
|
239
|
-
if (isWrite || attempt === maxAttempts - 1 || !RETRYABLE_STATUS.has(error.status))
|
|
252
|
+
if (error === giveUp || isWrite || attempt === maxAttempts - 1 || !RETRYABLE_STATUS.has(error.status))
|
|
240
253
|
throw error;
|
|
241
254
|
lastError = error;
|
|
242
255
|
continue;
|
package/dist/commands/auth.js
CHANGED
|
@@ -5,6 +5,7 @@ import { resolveBaseUrl, resolveWorkspace, writeSettings, hostOf } from '../conf
|
|
|
5
5
|
import { Client, ApiError, loadCredentials } from '../client.js';
|
|
6
6
|
import { line, note, printResult } from '../output.js';
|
|
7
7
|
import { desktopInstalled } from '../local.js';
|
|
8
|
+
import { detectHostAgent } from '../host-agent.js';
|
|
8
9
|
const KEY_PREFIX = 'es_live_';
|
|
9
10
|
async function readKeyFromInput(fromStdin) {
|
|
10
11
|
if (fromStdin) {
|
|
@@ -81,12 +82,27 @@ export async function login(argv, connection, mode) {
|
|
|
81
82
|
const where = await withRenewalLock(host, () => writeCredentials(stored));
|
|
82
83
|
if (connection.baseUrl)
|
|
83
84
|
await writeSettings({ baseUrl });
|
|
84
|
-
|
|
85
|
+
const name = argv.name?.trim() || detectHostAgent()?.name;
|
|
86
|
+
let unnamed = false;
|
|
87
|
+
let badName = false;
|
|
88
|
+
if (name && stored.kind === 'oauth') {
|
|
89
|
+
try {
|
|
90
|
+
const client = await Client.create({ baseUrl, credentials: stored });
|
|
91
|
+
await client.post('/api/v1/connections/agent', { name });
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
unnamed = true;
|
|
95
|
+
badName = error instanceof ApiError && error.status === 400;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
printResult(mode, { host, kind: stored.kind, storage: where, ...(unnamed ? { named: false } : {}) }, () => {
|
|
85
99
|
line(`Signed in to ${host}${stored.kind === 'api_key' ? ' with an API key' : ''}.`);
|
|
86
100
|
line(`Credential stored in the ${where === 'keychain' ? 'system keychain' : 'config file'}.`);
|
|
87
101
|
if (process.env.ES_API_KEY) {
|
|
88
102
|
note('ES_API_KEY is set in this shell and takes precedence over what was just stored.');
|
|
89
103
|
}
|
|
104
|
+
if (unnamed)
|
|
105
|
+
note(badName ? 'The name was not saved. Use letters, digits, spaces, dots and dashes.' : 'The name was not saved.');
|
|
90
106
|
});
|
|
91
107
|
}
|
|
92
108
|
export async function logout(connection, mode) {
|
|
@@ -49,8 +49,10 @@ export async function download(argv, connection, mode) {
|
|
|
49
49
|
let pending = items.filter(onItsWayUp);
|
|
50
50
|
if (pending.length && !mode.json)
|
|
51
51
|
note(`Waiting for ${pending.length === 1 ? 'it' : `${pending.length} files`} to finish uploading from the desktop app …`);
|
|
52
|
+
let pauseMs = 3000;
|
|
52
53
|
while (pending.length && Date.now() < deadline) {
|
|
53
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
54
|
+
await new Promise((resolve) => setTimeout(resolve, pauseMs));
|
|
55
|
+
pauseMs = Math.min(pauseMs * 2, 24_000);
|
|
54
56
|
const page = (await client.tool('get_items', { refs: pending.map((it) => it.item_id || it.ref).filter(Boolean) }).catch(() => ({ items: [] })));
|
|
55
57
|
for (const fresh of page.items) {
|
|
56
58
|
const at = items.findIndex((it) => (it.item_id && it.item_id === fresh.item_id) || (it.ref && it.ref === fresh.ref));
|
package/dist/commands/init.js
CHANGED
|
@@ -308,21 +308,23 @@ export async function init(argv, connection, mode) {
|
|
|
308
308
|
const connected = !(entries.length > 0 && entries.every((entry) => entry.points_to));
|
|
309
309
|
if (!dryRun && connected) {
|
|
310
310
|
const wrote = changes.filter((c) => c.action !== 'unchanged').map((c) => c.agent);
|
|
311
|
-
const named =
|
|
312
|
-
?
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
? {
|
|
316
|
-
: agent === '
|
|
317
|
-
? { name: '
|
|
318
|
-
:
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
: wrote.includes('
|
|
322
|
-
? { agent: '
|
|
323
|
-
:
|
|
324
|
-
? { agent: '
|
|
325
|
-
:
|
|
311
|
+
const named = argv.name?.trim()
|
|
312
|
+
? { name: argv.name.trim() }
|
|
313
|
+
: agent
|
|
314
|
+
? agent === 'claude-code' || agent === 'cursor' || agent === 'codex'
|
|
315
|
+
? { agent }
|
|
316
|
+
: agent === 'vscode'
|
|
317
|
+
? { name: 'VS Code' }
|
|
318
|
+
: agent === 'claude-desktop'
|
|
319
|
+
? { name: 'Claude Desktop' }
|
|
320
|
+
: null
|
|
321
|
+
: wrote.includes('Claude Code')
|
|
322
|
+
? { agent: 'claude-code' }
|
|
323
|
+
: wrote.includes('Cursor')
|
|
324
|
+
? { agent: 'cursor' }
|
|
325
|
+
: skipped.some((item) => item.agent === 'Codex')
|
|
326
|
+
? { agent: 'codex' }
|
|
327
|
+
: null;
|
|
326
328
|
if (named) {
|
|
327
329
|
try {
|
|
328
330
|
const client = await Client.create({ ...connection, baseUrl, cloud: true });
|
package/dist/commands/jobs.js
CHANGED
|
@@ -66,7 +66,7 @@ export async function jobs(argv, connection, mode) {
|
|
|
66
66
|
if (argv.ids.length === 0)
|
|
67
67
|
throw new Error('Which jobs? `eversince jobs <id…>` or `eversince jobs cancel <id…>`');
|
|
68
68
|
if (!argv.wait) {
|
|
69
|
-
const data = (await client.tool('get_jobs', { ids: argv.ids }));
|
|
69
|
+
const data = (await client.tool('get_jobs', { ids: argv.ids, wait_seconds: 0 }));
|
|
70
70
|
printResult(mode, data, () => {
|
|
71
71
|
if (data.jobs.length === 0)
|
|
72
72
|
line('None of those ids is a job of this workspace.');
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function detectHostAgent(env = process.env) {
|
|
2
|
+
const named = env.ES_AGENT_NAME?.trim();
|
|
3
|
+
if (named)
|
|
4
|
+
return { kind: 'other', name: named };
|
|
5
|
+
if (env.CLAUDECODE)
|
|
6
|
+
return { kind: 'claude-code', name: 'Claude Code' };
|
|
7
|
+
if (env.CURSOR_TRACE_ID)
|
|
8
|
+
return { kind: 'cursor', name: 'Cursor' };
|
|
9
|
+
if (env.CODEX_SANDBOX || env.CODEX_THREAD_ID)
|
|
10
|
+
return { kind: 'codex', name: 'Codex' };
|
|
11
|
+
if (env.TERM_PROGRAM === 'vscode')
|
|
12
|
+
return { kind: 'vscode', name: 'VS Code' };
|
|
13
|
+
return null;
|
|
14
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -47,6 +47,9 @@ Options
|
|
|
47
47
|
--idempotency-key <k> the key for a charged call, so a retry does not charge twice
|
|
48
48
|
--schemas with tools: include each tool's input schema
|
|
49
49
|
--annotation <kind> with tools: only read, write or destructive tools
|
|
50
|
+
--name <agent> with login or init: the agent's name, shown in Settings
|
|
51
|
+
and on the feed (otherwise the agent whose shell this
|
|
52
|
+
is: Claude Code, Cursor, Codex or VS Code; else "CLI agent")
|
|
50
53
|
--scope <where> with init: project or user, where the agent's settings are written
|
|
51
54
|
--dry-run / --force with init: preview what would be written, or overwrite what is there
|
|
52
55
|
--cloud talk to eversince.ai instead of the desktop app; to have
|
|
@@ -82,6 +85,7 @@ function toNumber(value, name) {
|
|
|
82
85
|
const OPTIONS = {
|
|
83
86
|
json: { type: 'boolean', default: false },
|
|
84
87
|
key: { type: 'string' },
|
|
88
|
+
name: { type: 'string' },
|
|
85
89
|
'base-url': { type: 'string' },
|
|
86
90
|
cloud: { type: 'boolean', default: false },
|
|
87
91
|
workspace: { type: 'string' },
|
|
@@ -141,7 +145,7 @@ async function main() {
|
|
|
141
145
|
try {
|
|
142
146
|
switch (command) {
|
|
143
147
|
case 'login':
|
|
144
|
-
return await login({ key: values.key, noBrowser: values['no-browser'] }, connection, mode);
|
|
148
|
+
return await login({ key: values.key, noBrowser: values['no-browser'], name: values.name }, connection, mode);
|
|
145
149
|
case 'logout':
|
|
146
150
|
return await logout(connection, mode);
|
|
147
151
|
case 'status':
|
|
@@ -188,6 +192,7 @@ async function main() {
|
|
|
188
192
|
force: values.force,
|
|
189
193
|
dryRun: values['dry-run'],
|
|
190
194
|
agent: values.agent,
|
|
195
|
+
name: values.name,
|
|
191
196
|
}, connection, mode);
|
|
192
197
|
default:
|
|
193
198
|
throw new Error(`Unknown command "${command}". Run \`eversince help\`.`);
|
package/dist/local.js
CHANGED
|
@@ -2,6 +2,7 @@ import { existsSync, realpathSync } from 'node:fs';
|
|
|
2
2
|
import { delimiter, join } from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
4
|
import { DoorBlocked, probe, reachApp, readState } from './door.js';
|
|
5
|
+
import { detectHostAgent } from './host-agent.js';
|
|
5
6
|
export function desktopInstalled() {
|
|
6
7
|
const state = readState();
|
|
7
8
|
return !!state && existsSync(state.app) && typeof state.connectKey === 'string';
|
|
@@ -46,7 +47,8 @@ export async function connectThroughApp(agent, extra = {}) {
|
|
|
46
47
|
return payload.data;
|
|
47
48
|
}
|
|
48
49
|
async function connect() {
|
|
49
|
-
const
|
|
50
|
+
const host = detectHostAgent();
|
|
51
|
+
const { token } = await connectThroughApp('cli', { auto: true, ...(host ? { name: host.name } : {}) });
|
|
50
52
|
if (typeof token !== 'string')
|
|
51
53
|
throw new Error('The Eversince app did not return a token for the CLI.');
|
|
52
54
|
return token;
|
package/package.json
CHANGED