eversince 0.2.0 → 0.2.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 +1 -1
- package/dist/auth/oauth.js +10 -5
- package/dist/bridge.js +18 -4
- package/dist/client.js +30 -9
- package/dist/commands/auth.js +7 -9
- package/dist/commands/download.js +9 -7
- package/dist/commands/init.js +16 -15
- package/dist/commands/jobs.js +22 -5
- package/dist/commands/run.js +37 -4
- package/dist/commands/tools.js +9 -1
- package/dist/commands/upload.js +3 -4
- package/dist/commands/workspace.js +4 -4
- package/dist/door.js +12 -7
- package/dist/index.js +15 -8
- package/dist/local.js +5 -5
- package/dist/output.js +1 -1
- package/dist/retry.js +37 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -41,7 +41,7 @@ always work against eversince.ai. `eversince status` says whether the app is use
|
|
|
41
41
|
|
|
42
42
|
```
|
|
43
43
|
eversince login sign in through the browser
|
|
44
|
-
eversince login --key
|
|
44
|
+
eversince login --key - or with an API key from stdin (CI, no browser)
|
|
45
45
|
eversince logout
|
|
46
46
|
eversince status
|
|
47
47
|
eversince init connect the agents on this machine
|
package/dist/auth/oauth.js
CHANGED
|
@@ -44,7 +44,7 @@ export async function discoverAuthorizationServer(baseUrl) {
|
|
|
44
44
|
}
|
|
45
45
|
export async function registerClient(server, redirectUri) {
|
|
46
46
|
if (!server.registration_endpoint) {
|
|
47
|
-
throw new Error('This authorization server does not support dynamic client registration. Sign in with an API key instead: eversince login --key
|
|
47
|
+
throw new Error('This authorization server does not support dynamic client registration. Sign in with an API key instead: `eversince login --no-browser` asks for it, or pipe it with `--key -`.');
|
|
48
48
|
}
|
|
49
49
|
const registered = (await getJson(server.registration_endpoint, {
|
|
50
50
|
method: 'POST',
|
|
@@ -64,9 +64,14 @@ export async function registerClient(server, redirectUri) {
|
|
|
64
64
|
return registered.client_id;
|
|
65
65
|
}
|
|
66
66
|
function openBrowser(url) {
|
|
67
|
-
const command = process.platform === 'darwin'
|
|
67
|
+
const [command, args] = process.platform === 'darwin'
|
|
68
|
+
? ['open', [url]]
|
|
69
|
+
: process.platform === 'win32'
|
|
70
|
+
? ['rundll32', ['url.dll,FileProtocolHandler', url]]
|
|
71
|
+
: ['xdg-open', [url]];
|
|
68
72
|
try {
|
|
69
|
-
const child = spawn(command,
|
|
73
|
+
const child = spawn(command, args, { stdio: 'ignore', detached: true });
|
|
74
|
+
child.on('error', () => undefined);
|
|
70
75
|
child.unref();
|
|
71
76
|
}
|
|
72
77
|
catch {
|
|
@@ -114,7 +119,7 @@ async function awaitCallback(timeoutMs) {
|
|
|
114
119
|
}
|
|
115
120
|
}
|
|
116
121
|
if (!listening)
|
|
117
|
-
throw new Error('Could not open a local port to receive the sign-in. Use `eversince login --key
|
|
122
|
+
throw new Error('Could not open a local port to receive the sign-in. Use an API key: `eversince login --no-browser` asks for it, or pipe it with `--key -`.');
|
|
118
123
|
const timer = setTimeout(() => settle?.({ error: 'timeout' }), timeoutMs);
|
|
119
124
|
timer.unref();
|
|
120
125
|
return {
|
|
@@ -130,7 +135,7 @@ export async function browserLogin(baseUrl, opts) {
|
|
|
130
135
|
const { server, resource } = await discoverAuthorizationServer(baseUrl);
|
|
131
136
|
const methods = server.code_challenge_methods_supported ?? [];
|
|
132
137
|
if (methods.length && !methods.includes('S256')) {
|
|
133
|
-
throw new Error('Authorization server does not support PKCE S256
|
|
138
|
+
throw new Error('Authorization server does not support PKCE S256; refusing to sign in without it.');
|
|
134
139
|
}
|
|
135
140
|
const callback = await awaitCallback(opts.timeoutMs ?? 5 * 60_000);
|
|
136
141
|
const redirectUri = `http://127.0.0.1:${callback.port}/callback`;
|
package/dist/bridge.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { DoorBlocked, cacheFile as cacheFileFor, isBlocked, isRefused, probe, reachApp, readJson, readState, sandboxedWithoutNetwork, stateFile as defaultStateFile, } from './door.js';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { isConnectFailure } from './retry.js';
|
|
2
4
|
function write(message) {
|
|
3
5
|
process.stdout.write(`${typeof message === 'string' ? message : JSON.stringify(message)}\n`);
|
|
4
6
|
}
|
|
@@ -18,7 +20,7 @@ export function runBridge(options) {
|
|
|
18
20
|
return found && typeof found.token === 'string' ? { token: found.token } : null;
|
|
19
21
|
}
|
|
20
22
|
if (!readState(file)) {
|
|
21
|
-
process.stderr.write('eversince: the Eversince app is not set up on this computer. Install it, open it and sign in.\n');
|
|
23
|
+
process.stderr.write('eversince: the Eversince app is not set up on this computer. Install it, open it and sign in, or run `eversince init --cloud` to connect this agent to eversince.ai instead.\n');
|
|
22
24
|
process.exit(1);
|
|
23
25
|
}
|
|
24
26
|
let listFromCache = null;
|
|
@@ -41,9 +43,13 @@ export function runBridge(options) {
|
|
|
41
43
|
if (seen !== 'ours') {
|
|
42
44
|
if (!mayOpen)
|
|
43
45
|
throw new Unreachable();
|
|
46
|
+
const before = state;
|
|
44
47
|
state = await open();
|
|
45
|
-
if (!state)
|
|
48
|
+
if (!state) {
|
|
49
|
+
if (before && !existsSync(before.app))
|
|
50
|
+
throw new Error('The Eversince app is no longer on this computer. Run `eversince init` to connect this agent to eversince.ai instead.');
|
|
46
51
|
throw new Error('The Eversince app did not open. Open it and try again.');
|
|
52
|
+
}
|
|
47
53
|
}
|
|
48
54
|
const connection = connectionFor(state);
|
|
49
55
|
if (!state || !connection)
|
|
@@ -110,8 +116,8 @@ export function runBridge(options) {
|
|
|
110
116
|
const envelope = body;
|
|
111
117
|
const said = typeof envelope?.error?.message === 'string' ? envelope.error.message : null;
|
|
112
118
|
if (res.status === 503 || res.status === 504)
|
|
113
|
-
return rpcError(id, said ?? 'Eversince is busy.
|
|
114
|
-
return rpcError(id, said ?? `Eversince could not answer (${res.status}).`);
|
|
119
|
+
return rpcError(id, said ?? 'Eversince is busy. Retry the call.');
|
|
120
|
+
return rpcError(id, said ?? `Eversince could not answer (status ${res.status}). Retry the call.`);
|
|
115
121
|
}
|
|
116
122
|
async function relay(line) {
|
|
117
123
|
let message = null;
|
|
@@ -134,6 +140,7 @@ export function runBridge(options) {
|
|
|
134
140
|
return;
|
|
135
141
|
}
|
|
136
142
|
const id = idOf(message);
|
|
143
|
+
const canDoWork = message?.method === 'tools/call';
|
|
137
144
|
try {
|
|
138
145
|
let res;
|
|
139
146
|
try {
|
|
@@ -142,6 +149,13 @@ export function runBridge(options) {
|
|
|
142
149
|
catch (error) {
|
|
143
150
|
if (!(error instanceof Unreachable) && !isRefused(error))
|
|
144
151
|
throw error;
|
|
152
|
+
const neverReached = error instanceof Unreachable || isConnectFailure(error);
|
|
153
|
+
if (canDoWork && !neverReached) {
|
|
154
|
+
if (id === null)
|
|
155
|
+
return;
|
|
156
|
+
write(rpcError(id, 'Eversince’s connection dropped mid-call and the call may already be running. Call get_jobs before retrying.'));
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
145
159
|
const cached = fromCache(message, id);
|
|
146
160
|
if (cached) {
|
|
147
161
|
if (cached.reply)
|
package/dist/client.js
CHANGED
|
@@ -5,6 +5,7 @@ import { note } from './output.js';
|
|
|
5
5
|
import { readCredentials, writeCredentials } from './auth/store.js';
|
|
6
6
|
import { refreshTokens } from './auth/oauth.js';
|
|
7
7
|
import { hostOf } from './config.js';
|
|
8
|
+
import { isConnectFailure } from './retry.js';
|
|
8
9
|
import { USER_AGENT } from './version.js';
|
|
9
10
|
export class ApiError extends Error {
|
|
10
11
|
status;
|
|
@@ -26,6 +27,8 @@ export class NotLoggedIn extends Error {
|
|
|
26
27
|
}
|
|
27
28
|
const RETRYABLE_STATUS = new Set([429, 502, 503, 504]);
|
|
28
29
|
const MAX_ATTEMPTS = 4;
|
|
30
|
+
const MAX_WRITE_ATTEMPTS = 2;
|
|
31
|
+
const WRITE_RETRY_PAUSE_MS = 500;
|
|
29
32
|
function sleep(ms) {
|
|
30
33
|
return new Promise((r) => setTimeout(r, ms));
|
|
31
34
|
}
|
|
@@ -74,6 +77,15 @@ export class Client {
|
|
|
74
77
|
async tool(name, input = {}, options = {}) {
|
|
75
78
|
return this.post(`/api/v1/tools/${encodeURIComponent(name)}`, input, options);
|
|
76
79
|
}
|
|
80
|
+
async toolWithMedia(name, input = {}, options = {}) {
|
|
81
|
+
const envelope = (await this.request('POST', `/api/v1/tools/${encodeURIComponent(name)}`, {
|
|
82
|
+
...options,
|
|
83
|
+
body: input,
|
|
84
|
+
whole: true,
|
|
85
|
+
}));
|
|
86
|
+
const media = Array.isArray(envelope?.media) ? envelope.media : [];
|
|
87
|
+
return { data: envelope && typeof envelope === 'object' && 'data' in envelope ? envelope.data : envelope, media };
|
|
88
|
+
}
|
|
77
89
|
async headers(method, options) {
|
|
78
90
|
await this.ensureFreshToken();
|
|
79
91
|
const headers = {
|
|
@@ -114,10 +126,12 @@ export class Client {
|
|
|
114
126
|
if (value !== undefined)
|
|
115
127
|
url.searchParams.set(key, value);
|
|
116
128
|
}
|
|
117
|
-
const
|
|
129
|
+
const isWrite = method !== 'GET';
|
|
130
|
+
const idempotencyKey = options.idempotencyKey ?? (isWrite ? randomUUID() : undefined);
|
|
131
|
+
const maxAttempts = isWrite ? MAX_WRITE_ATTEMPTS : MAX_ATTEMPTS;
|
|
118
132
|
let lastError = null;
|
|
119
133
|
let refreshedOnce = false;
|
|
120
|
-
for (let attempt = 0; attempt <
|
|
134
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
121
135
|
if (this.local)
|
|
122
136
|
url.host = new URL(await this.local.verify()).host;
|
|
123
137
|
const controller = new AbortController();
|
|
@@ -164,40 +178,47 @@ export class Client {
|
|
|
164
178
|
const body = payload?.error ?? {
|
|
165
179
|
code: 'http_error',
|
|
166
180
|
message: `Request failed (${res.status})`,
|
|
167
|
-
retryable: RETRYABLE_STATUS.has(res.status),
|
|
181
|
+
retryable: isWrite ? res.status === 429 : RETRYABLE_STATUS.has(res.status),
|
|
168
182
|
};
|
|
169
183
|
const error = new ApiError(res.status, body, requestId);
|
|
170
|
-
const canRetry = RETRYABLE_STATUS.has(res.status)
|
|
184
|
+
const canRetry = attempt < maxAttempts - 1 && (isWrite ? res.status === 429 : RETRYABLE_STATUS.has(res.status));
|
|
171
185
|
if (canRetry) {
|
|
172
186
|
const retryAfter = Number(res.headers.get('retry-after'));
|
|
173
|
-
|
|
187
|
+
const pause = Number.isFinite(retryAfter) && retryAfter > 0
|
|
188
|
+
? retryAfter * 1000
|
|
189
|
+
: isWrite ? WRITE_RETRY_PAUSE_MS : backoffMs(attempt);
|
|
190
|
+
await sleep(pause);
|
|
174
191
|
lastError = error;
|
|
175
192
|
continue;
|
|
176
193
|
}
|
|
177
194
|
throw error;
|
|
178
195
|
}
|
|
196
|
+
if (options.whole)
|
|
197
|
+
return payload;
|
|
179
198
|
const envelope = payload;
|
|
180
199
|
return envelope && typeof envelope === 'object' && 'data' in envelope ? envelope.data : payload;
|
|
181
200
|
}
|
|
182
201
|
catch (error) {
|
|
183
202
|
if (error instanceof ApiError) {
|
|
184
|
-
if (attempt ===
|
|
203
|
+
if (isWrite || attempt === maxAttempts - 1 || !RETRYABLE_STATUS.has(error.status))
|
|
185
204
|
throw error;
|
|
186
205
|
lastError = error;
|
|
187
206
|
continue;
|
|
188
207
|
}
|
|
189
208
|
const aborted = error instanceof Error && error.name === 'AbortError';
|
|
209
|
+
const connectFailure = !aborted && isConnectFailure(error);
|
|
190
210
|
const wrapped = new ApiError(0, {
|
|
191
211
|
code: aborted ? 'timeout' : 'network_error',
|
|
192
212
|
message: aborted
|
|
193
213
|
? `Timed out after ${Math.round((options.timeoutMs ?? this.defaultTimeoutMs) / 1000)}s calling ${url.pathname}`
|
|
194
214
|
: `Could not reach ${url.host}: ${error instanceof Error ? error.message : String(error)}`,
|
|
195
|
-
retryable: true,
|
|
215
|
+
retryable: isWrite ? connectFailure : true,
|
|
196
216
|
});
|
|
197
|
-
|
|
217
|
+
const canRetry = attempt < maxAttempts - 1 && (isWrite ? connectFailure : true);
|
|
218
|
+
if (!canRetry)
|
|
198
219
|
throw wrapped;
|
|
199
220
|
lastError = wrapped;
|
|
200
|
-
await sleep(backoffMs(attempt));
|
|
221
|
+
await sleep(isWrite ? WRITE_RETRY_PAUSE_MS : backoffMs(attempt));
|
|
201
222
|
}
|
|
202
223
|
finally {
|
|
203
224
|
clearTimeout(timer);
|
package/dist/commands/auth.js
CHANGED
|
@@ -14,7 +14,7 @@ async function readKeyFromInput(fromStdin) {
|
|
|
14
14
|
return Buffer.concat(chunks).toString('utf8').trim();
|
|
15
15
|
}
|
|
16
16
|
if (!process.stdin.isTTY) {
|
|
17
|
-
throw new Error('No terminal to ask on.
|
|
17
|
+
throw new Error('No terminal to ask on. Pipe the key with `--key -`, or set ES_API_KEY.');
|
|
18
18
|
}
|
|
19
19
|
const rl = createInterface({ input: process.stdin, output: process.stderr });
|
|
20
20
|
try {
|
|
@@ -40,7 +40,7 @@ export async function login(argv, connection, mode) {
|
|
|
40
40
|
if (!key)
|
|
41
41
|
throw new Error('No key given.');
|
|
42
42
|
if (!key.startsWith(KEY_PREFIX)) {
|
|
43
|
-
throw new Error(`That doesn't look like an Eversince key
|
|
43
|
+
throw new Error(`That doesn't look like an Eversince key. They start with ${KEY_PREFIX}.`);
|
|
44
44
|
}
|
|
45
45
|
stored = { kind: 'api_key', token: key, host };
|
|
46
46
|
}
|
|
@@ -73,7 +73,7 @@ export async function login(argv, connection, mode) {
|
|
|
73
73
|
throw new Error(error.status === 403
|
|
74
74
|
? error.body.message
|
|
75
75
|
: useKey
|
|
76
|
-
? 'That key was rejected. Check it in Settings
|
|
76
|
+
? 'That key was rejected. Check it in Settings, API keys.'
|
|
77
77
|
: 'Sign-in completed but the token was rejected. Try again, or use an API key.');
|
|
78
78
|
}
|
|
79
79
|
throw error;
|
|
@@ -112,7 +112,7 @@ export async function status(connection, mode) {
|
|
|
112
112
|
const fromEnv = Boolean(process.env.ES_API_KEY);
|
|
113
113
|
const desktop = desktopInstalled();
|
|
114
114
|
const payload = {
|
|
115
|
-
desktop_app: desktop
|
|
115
|
+
desktop_app: desktop ? 'used' : 'not_installed',
|
|
116
116
|
signed_in: credentials !== null,
|
|
117
117
|
host,
|
|
118
118
|
base_url: baseUrl,
|
|
@@ -122,18 +122,16 @@ export async function status(connection, mode) {
|
|
|
122
122
|
expires_at: credentials?.expiresAt ? new Date(credentials.expiresAt).toISOString() : null,
|
|
123
123
|
};
|
|
124
124
|
printResult(mode, payload, () => {
|
|
125
|
-
if (desktop
|
|
125
|
+
if (desktop)
|
|
126
126
|
line('Desktop app: commands go through it, unless run with --cloud.');
|
|
127
|
-
else if (desktop.installed)
|
|
128
|
-
line('Desktop app: update it so commands can go through it.');
|
|
129
127
|
if (!credentials) {
|
|
130
128
|
line(`Not signed in to ${host}.`);
|
|
131
129
|
return;
|
|
132
130
|
}
|
|
133
|
-
line(`${host}
|
|
131
|
+
line(`${host}: signed in (${credentials.kind === 'api_key' ? 'API key' : 'browser sign-in'}${fromEnv ? ', from ES_API_KEY' : ''})`);
|
|
134
132
|
line(`workspace: ${workspace ?? 'account default'}`);
|
|
135
133
|
if (credentials.kind === 'oauth') {
|
|
136
|
-
line(`session renews automatically${credentials.refreshToken ? '' : '
|
|
134
|
+
line(`session renews automatically${credentials.refreshToken ? '.' : '. No refresh token, sign in again when it lapses.'}`);
|
|
137
135
|
}
|
|
138
136
|
});
|
|
139
137
|
}
|
|
@@ -6,6 +6,7 @@ import { basename, join, extname } from 'node:path';
|
|
|
6
6
|
import { Client } from '../client.js';
|
|
7
7
|
import { line, note, printResult } from '../output.js';
|
|
8
8
|
import { USER_AGENT } from '../version.js';
|
|
9
|
+
const GET_ITEMS_MAX = 25;
|
|
9
10
|
const EXTENSIONS = {
|
|
10
11
|
image: '.png',
|
|
11
12
|
video: '.mp4',
|
|
@@ -31,18 +32,19 @@ export async function download(argv, connection, mode) {
|
|
|
31
32
|
const dir = argv.out ?? process.cwd();
|
|
32
33
|
await mkdir(dir, { recursive: true });
|
|
33
34
|
const client = await Client.create(connection);
|
|
34
|
-
const { items } = (await client.tool('get_items', { refs: argv.refs }));
|
|
35
35
|
const written = [];
|
|
36
36
|
const failed = [];
|
|
37
|
-
const
|
|
38
|
-
for (
|
|
39
|
-
|
|
37
|
+
const items = [];
|
|
38
|
+
for (let i = 0; i < argv.refs.length; i += GET_ITEMS_MAX) {
|
|
39
|
+
const page = (await client.tool('get_items', { refs: argv.refs.slice(i, i + GET_ITEMS_MAX) }));
|
|
40
|
+
items.push(...page.items);
|
|
41
|
+
for (const ref of page.unresolved ?? [])
|
|
40
42
|
failed.push({ ref, error: 'No such item in this workspace' });
|
|
41
43
|
}
|
|
42
44
|
for (const item of items) {
|
|
43
45
|
const ref = item.ref || item.item_id || 'item';
|
|
44
46
|
if (!item.url) {
|
|
45
|
-
failed.push({ ref, error: 'Item has no file
|
|
47
|
+
failed.push({ ref, error: item.local_only ? 'Only on a computer, not synced to the cloud. Sync it from the desktop app first' : 'Item has no file yet. Call eversince jobs on its job to check whether it is still generating.' });
|
|
46
48
|
continue;
|
|
47
49
|
}
|
|
48
50
|
if (!mode.json)
|
|
@@ -56,7 +58,7 @@ export async function download(argv, connection, mode) {
|
|
|
56
58
|
continue;
|
|
57
59
|
}
|
|
58
60
|
if (!res.ok || !res.body) {
|
|
59
|
-
failed.push({ ref, error: res.status === 403 ? 'Link expired
|
|
61
|
+
failed.push({ ref, error: res.status === 403 ? 'Link expired. Run the command again.' : `Could not fetch (${res.status})` });
|
|
60
62
|
continue;
|
|
61
63
|
}
|
|
62
64
|
const path = join(dir, fileNameFor(item));
|
|
@@ -73,7 +75,7 @@ export async function download(argv, connection, mode) {
|
|
|
73
75
|
for (const w of written)
|
|
74
76
|
line(w.path);
|
|
75
77
|
for (const f of failed)
|
|
76
|
-
line(`failed ${f.ref}
|
|
78
|
+
line(`failed ${f.ref}: ${f.error}`);
|
|
77
79
|
});
|
|
78
80
|
if (failed.length)
|
|
79
81
|
process.exitCode = 1;
|
package/dist/commands/init.js
CHANGED
|
@@ -67,14 +67,14 @@ function skillTargets(scope) {
|
|
|
67
67
|
function skillBody(mcpWhere) {
|
|
68
68
|
return `---
|
|
69
69
|
name: eversince-cli
|
|
70
|
-
description: Reach an Eversince workspace from the shell
|
|
70
|
+
description: Reach an Eversince workspace from the shell: upload local files into the library, download items onto disk, call any workspace tool, and follow generation and render to completion. Use whenever the media is on this machine, the same operation runs over many items, or the work has to continue without an agent session.
|
|
71
71
|
---
|
|
72
72
|
|
|
73
73
|
# Eversince from the command line
|
|
74
74
|
|
|
75
75
|
A media workspace this account can reach two ways. Prefer whichever fits the step.
|
|
76
76
|
|
|
77
|
-
## The CLI
|
|
77
|
+
## The CLI: local files, bulk work, no session needed
|
|
78
78
|
|
|
79
79
|
\`\`\`bash
|
|
80
80
|
eversince tools # everything this workspace can do, live
|
|
@@ -85,10 +85,10 @@ eversince download <refs> --out ./dir # library items onto disk
|
|
|
85
85
|
eversince jobs <id> --wait # follow generation, render
|
|
86
86
|
\`\`\`
|
|
87
87
|
|
|
88
|
-
Add \`--json\` for machine-readable output
|
|
88
|
+
Add \`--json\` for machine-readable output: \`{"ok":true,"data":…}\` on success,
|
|
89
89
|
\`{"ok":false,"error":…}\` on failure, so one field says which arrived.
|
|
90
90
|
|
|
91
|
-
## MCP
|
|
91
|
+
## MCP: inside the session
|
|
92
92
|
|
|
93
93
|
The same tools are available over MCP ${mcpWhere}. Use those when the work is
|
|
94
94
|
conversational and the files are already in the workspace; use the CLI when the
|
|
@@ -100,8 +100,11 @@ files are on this machine or the work has to outlive the session.
|
|
|
100
100
|
- Async tools return a job. \`--wait\` follows it; without it you get an id back.
|
|
101
101
|
- Downloaded filenames carry the item's short reference. Keep it in the name when
|
|
102
102
|
publishing, so results can be matched back to the item later.
|
|
103
|
-
- \`eversince tools
|
|
104
|
-
|
|
103
|
+
- \`eversince tools\` opens with the operating instructions (the workspace model, what
|
|
104
|
+
costs what, where work runs), then every tool; \`eversince tools <name>\` is
|
|
105
|
+
authoritative for one tool's arguments.
|
|
106
|
+
- With the desktop app on this machine, commands go through it and work the app
|
|
107
|
+
can do runs here, free; \`--cloud\` sends a command to eversince.ai instead.
|
|
105
108
|
- \`--workspace <id>\` picks the workspace for one command and changes nothing
|
|
106
109
|
for anyone else, so several agents can run at once against different ones.
|
|
107
110
|
Left off, it is the workspace this connection was signed in to.
|
|
@@ -132,7 +135,7 @@ async function writeMcpEntry(target, mcpUrl, dryRun) {
|
|
|
132
135
|
current = raw.trim() ? JSON.parse(raw) : {};
|
|
133
136
|
}
|
|
134
137
|
catch {
|
|
135
|
-
throw new Error(`${target.path} is not valid JSON
|
|
138
|
+
throw new Error(`${target.path} is not valid JSON. Fix or move it, then run init again.`);
|
|
136
139
|
}
|
|
137
140
|
}
|
|
138
141
|
const servers = { ...(current[target.key] ?? {}) };
|
|
@@ -159,7 +162,8 @@ async function writeSkill(target, body, force, dryRun) {
|
|
|
159
162
|
const current = await readFile(target.path, 'utf8');
|
|
160
163
|
if (current === body)
|
|
161
164
|
return { agent: target.agent, path: target.path, action: 'unchanged' };
|
|
162
|
-
|
|
165
|
+
const ours = current.startsWith('---\nname: eversince-cli\n');
|
|
166
|
+
if (!force && !ours) {
|
|
163
167
|
throw new Error(`${target.path} already exists and differs. Re-run with --force to replace it.`);
|
|
164
168
|
}
|
|
165
169
|
if (dryRun)
|
|
@@ -266,14 +270,11 @@ export async function init(argv, connection, mode) {
|
|
|
266
270
|
const dryRun = argv.dryRun === true;
|
|
267
271
|
const cloudChosen = connection.cloud || connection.baseUrl || process.env.ES_BASE_URL?.trim();
|
|
268
272
|
const app = desktopInstalled();
|
|
269
|
-
if (doMcp && !cloudChosen && app
|
|
273
|
+
if (doMcp && !cloudChosen && app)
|
|
270
274
|
return initThroughApp({ ...argv, agent }, scope, mode);
|
|
271
|
-
if (doMcp && !cloudChosen && app.installed && !mode.json) {
|
|
272
|
-
note('The Eversince app on this computer is too old to connect agents. Update it and run eversince init again to work free through it.');
|
|
273
|
-
}
|
|
274
275
|
const baseUrl = await resolveBaseUrl(connection.baseUrl);
|
|
275
276
|
const { resource: mcpUrl } = await discoverAuthorizationServer(baseUrl);
|
|
276
|
-
const offerApp = !app
|
|
277
|
+
const offerApp = !app;
|
|
277
278
|
const changes = [];
|
|
278
279
|
const skipped = [];
|
|
279
280
|
if (doMcp) {
|
|
@@ -322,11 +323,11 @@ export async function init(argv, connection, mode) {
|
|
|
322
323
|
}
|
|
323
324
|
for (const item of skipped) {
|
|
324
325
|
line();
|
|
325
|
-
line(`${item.agent}
|
|
326
|
+
line(`${item.agent}: ${item.reason}`);
|
|
326
327
|
}
|
|
327
328
|
line();
|
|
328
329
|
if (dryRun) {
|
|
329
|
-
line('Dry run
|
|
330
|
+
line('Dry run. Nothing was written.');
|
|
330
331
|
return;
|
|
331
332
|
}
|
|
332
333
|
line(`Connected to ${hostOf(baseUrl)}. Restart any running agent to pick it up.`);
|
package/dist/commands/jobs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Client } from '../client.js';
|
|
2
2
|
import { line, note, pad, printResult } from '../output.js';
|
|
3
3
|
const TERMINAL = new Set(['succeeded', 'failed', 'cancelled']);
|
|
4
|
-
const POLL_SECONDS =
|
|
4
|
+
const POLL_SECONDS = 25;
|
|
5
5
|
export async function waitForJobs(client, ids, opts) {
|
|
6
6
|
const deadline = Date.now() + opts.timeoutMs;
|
|
7
7
|
for (;;) {
|
|
@@ -19,9 +19,22 @@ export async function waitForJobs(client, ids, opts) {
|
|
|
19
19
|
return data.jobs;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return
|
|
22
|
+
const ID_COLUMN = 38;
|
|
23
|
+
function roughly(seconds) {
|
|
24
|
+
return seconds >= 90 ? `about ${Math.round(seconds / 60)} min` : `about ${Math.round(seconds)} sec`;
|
|
25
|
+
}
|
|
26
|
+
export function describe(job) {
|
|
27
|
+
const aside = [
|
|
28
|
+
job.place ? `${job.place} in line` : null,
|
|
29
|
+
job.progress ?? null,
|
|
30
|
+
job.retrying ? 'retrying' : null,
|
|
31
|
+
job.eta_seconds ? roughly(job.eta_seconds) : null,
|
|
32
|
+
job.refunded ? 'refunded' : null,
|
|
33
|
+
job.note ?? null,
|
|
34
|
+
job.error?.message ?? null,
|
|
35
|
+
job.error?.charged ? 'charged' : null,
|
|
36
|
+
].filter((part) => !!part);
|
|
37
|
+
return `${pad(job.job_id, ID_COLUMN)}${pad(job.kind ?? '', 14)}${job.status}${aside.length ? `: ${aside.join(', ')}` : ''}`;
|
|
25
38
|
}
|
|
26
39
|
export async function jobs(argv, connection, mode) {
|
|
27
40
|
const client = await Client.create(connection);
|
|
@@ -30,6 +43,8 @@ export async function jobs(argv, connection, mode) {
|
|
|
30
43
|
throw new Error('Which jobs? `eversince jobs cancel <id…>`');
|
|
31
44
|
const data = (await client.tool('cancel_jobs', { ids: argv.ids }));
|
|
32
45
|
printResult(mode, data, () => {
|
|
46
|
+
if (data.jobs.length === 0)
|
|
47
|
+
line('None of those ids is a job of this workspace, so nothing was cancelled.');
|
|
33
48
|
for (const job of data.jobs)
|
|
34
49
|
line(describe(job));
|
|
35
50
|
});
|
|
@@ -40,6 +55,8 @@ export async function jobs(argv, connection, mode) {
|
|
|
40
55
|
if (!argv.wait) {
|
|
41
56
|
const data = (await client.tool('get_jobs', { ids: argv.ids }));
|
|
42
57
|
printResult(mode, data, () => {
|
|
58
|
+
if (data.jobs.length === 0)
|
|
59
|
+
line('None of those ids is a job of this workspace.');
|
|
43
60
|
for (const job of data.jobs)
|
|
44
61
|
line(describe(job));
|
|
45
62
|
});
|
|
@@ -51,7 +68,7 @@ export async function jobs(argv, connection, mode) {
|
|
|
51
68
|
onTick: (current) => {
|
|
52
69
|
if (mode.json)
|
|
53
70
|
return;
|
|
54
|
-
const summary = current.map((j) => `${j.
|
|
71
|
+
const summary = current.map((j) => `${j.job_id.slice(0, 8)} ${j.status}`).join(' ');
|
|
55
72
|
if (summary !== lastLine) {
|
|
56
73
|
note(summary);
|
|
57
74
|
lastLine = summary;
|
package/dist/commands/run.js
CHANGED
|
@@ -1,6 +1,33 @@
|
|
|
1
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
1
4
|
import { Client } from '../client.js';
|
|
2
5
|
import { waitForJobs } from './jobs.js';
|
|
3
6
|
import { printResult, line, note } from '../output.js';
|
|
7
|
+
const MEDIA_EXTENSIONS = {
|
|
8
|
+
'image/png': '.png',
|
|
9
|
+
'image/jpeg': '.jpg',
|
|
10
|
+
'image/gif': '.gif',
|
|
11
|
+
'image/webp': '.webp',
|
|
12
|
+
};
|
|
13
|
+
async function saveMedia(media, tool, out) {
|
|
14
|
+
if (media.length === 0)
|
|
15
|
+
return [];
|
|
16
|
+
const dir = out ?? join(tmpdir(), 'eversince-looks');
|
|
17
|
+
await mkdir(dir, { recursive: true });
|
|
18
|
+
const stamp = Date.now();
|
|
19
|
+
const safe = tool.replace(/[^\w.-]+/g, '-');
|
|
20
|
+
const written = [];
|
|
21
|
+
for (const [i, picture] of media.entries()) {
|
|
22
|
+
if (typeof picture?.data !== 'string' || picture.data.length === 0)
|
|
23
|
+
continue;
|
|
24
|
+
const ext = MEDIA_EXTENSIONS[picture.mimeType ?? ''] ?? '.bin';
|
|
25
|
+
const path = join(dir, `${safe}-${stamp}${media.length > 1 ? `-${i + 1}` : ''}${ext}`);
|
|
26
|
+
await writeFile(path, Buffer.from(picture.data, 'base64'));
|
|
27
|
+
written.push(path);
|
|
28
|
+
}
|
|
29
|
+
return written;
|
|
30
|
+
}
|
|
4
31
|
async function readStdin() {
|
|
5
32
|
const chunks = [];
|
|
6
33
|
for await (const chunk of process.stdin)
|
|
@@ -41,9 +68,15 @@ export async function run(argv, connection, mode) {
|
|
|
41
68
|
}
|
|
42
69
|
}
|
|
43
70
|
const client = await Client.create(connection);
|
|
44
|
-
const
|
|
71
|
+
const answered = await client.toolWithMedia(argv.name, input, { idempotencyKey: argv.idempotencyKey });
|
|
72
|
+
const pictures = await saveMedia(answered.media, argv.name, argv.out);
|
|
73
|
+
const result = pictures.length ? { ...answered.data, pictures } : answered.data;
|
|
45
74
|
if (!argv.wait) {
|
|
46
|
-
printResult(mode, result, () =>
|
|
75
|
+
printResult(mode, result, () => {
|
|
76
|
+
line(JSON.stringify(result, null, 2));
|
|
77
|
+
for (const path of pictures)
|
|
78
|
+
note(`picture written to ${path}`);
|
|
79
|
+
});
|
|
47
80
|
return;
|
|
48
81
|
}
|
|
49
82
|
const ids = jobIdsIn(result);
|
|
@@ -52,13 +85,13 @@ export async function run(argv, connection, mode) {
|
|
|
52
85
|
timeoutMs: (argv.timeout ?? 1800) * 1000,
|
|
53
86
|
onTick: (jobs) => {
|
|
54
87
|
if (!mode.json)
|
|
55
|
-
note(jobs.map((j) => `${j.
|
|
88
|
+
note(jobs.map((j) => `${j.job_id.slice(0, 8)} ${j.status}`).join(' '));
|
|
56
89
|
},
|
|
57
90
|
})
|
|
58
91
|
: [];
|
|
59
92
|
if (finished.length === 0) {
|
|
60
93
|
if (!mode.json)
|
|
61
|
-
note('Nothing to wait for
|
|
94
|
+
note('Nothing to wait for. This call returned its result directly.');
|
|
62
95
|
printResult(mode, result, () => line(JSON.stringify(result, null, 2)));
|
|
63
96
|
return;
|
|
64
97
|
}
|
package/dist/commands/tools.js
CHANGED
|
@@ -6,13 +6,15 @@ export async function tools(argv, connection, mode) {
|
|
|
6
6
|
const data = (await client.get('/api/v1/tools', {
|
|
7
7
|
schemas: wantSchemas ? undefined : 'false',
|
|
8
8
|
annotation: argv.annotation,
|
|
9
|
+
instructions: argv.name ? undefined : client.local ? 'desktop' : 'cloud',
|
|
10
|
+
door: argv.name && client.local ? 'desktop' : undefined,
|
|
9
11
|
}));
|
|
10
12
|
const list = argv.name ? data.tools.filter((t) => t.name === argv.name) : data.tools;
|
|
11
13
|
if (argv.name && list.length === 0) {
|
|
12
14
|
const near = data.tools.filter((t) => t.name.includes(argv.name)).slice(0, 5);
|
|
13
15
|
throw new Error(`No tool named "${argv.name}".${near.length ? ` Did you mean: ${near.map((t) => t.name).join(', ')}?` : ' Run `eversince tools` for the list.'}`);
|
|
14
16
|
}
|
|
15
|
-
printResult(mode, argv.name ? list[0] : { tools: list }, () => {
|
|
17
|
+
printResult(mode, argv.name ? list[0] : { instructions: data.instructions, tools: list }, () => {
|
|
16
18
|
if (argv.name) {
|
|
17
19
|
const tool = list[0];
|
|
18
20
|
line(tool.name);
|
|
@@ -27,6 +29,12 @@ export async function tools(argv, connection, mode) {
|
|
|
27
29
|
line(`eversince run ${tool.name} '{ … }'`);
|
|
28
30
|
return;
|
|
29
31
|
}
|
|
32
|
+
if (data.instructions) {
|
|
33
|
+
line(data.instructions);
|
|
34
|
+
line();
|
|
35
|
+
line('# The tools');
|
|
36
|
+
line();
|
|
37
|
+
}
|
|
30
38
|
const width = Math.max(...list.map((t) => t.name.length)) + 2;
|
|
31
39
|
for (const tool of list)
|
|
32
40
|
line(`${pad(tool.name, width)}${tool.description}`);
|
package/dist/commands/upload.js
CHANGED
|
@@ -140,7 +140,6 @@ async function uploadOne(client, path, opts) {
|
|
|
140
140
|
file_size: info.size,
|
|
141
141
|
content_type: contentType,
|
|
142
142
|
enrich: opts.enrich,
|
|
143
|
-
...(opts.enrich ? { on_servers: true } : {}),
|
|
144
143
|
...(opts.description ? { description: opts.description } : {}),
|
|
145
144
|
}));
|
|
146
145
|
return { file: path, ok: true, item: confirmed.upload_id, type: confirmed.type };
|
|
@@ -150,9 +149,9 @@ export async function upload(argv, connection, mode) {
|
|
|
150
149
|
throw new Error('Which files? `eversince upload ./shot.png` or a folder.');
|
|
151
150
|
const { files, skipped } = await expandPaths(argv.paths);
|
|
152
151
|
if (files.length === 0)
|
|
153
|
-
throw new Error('Nothing to upload
|
|
152
|
+
throw new Error('Nothing to upload. No files were found in the given paths.');
|
|
154
153
|
if (skipped.length && !mode.json) {
|
|
155
|
-
note(`Left ${skipped.length} nested folder${skipped.length === 1 ? '' : 's'} alone
|
|
154
|
+
note(`Left ${skipped.length} nested folder${skipped.length === 1 ? '' : 's'} alone. Name one to upload it.`);
|
|
156
155
|
}
|
|
157
156
|
const client = await Client.create(connection);
|
|
158
157
|
const limits = await fetchLimits(client);
|
|
@@ -191,7 +190,7 @@ export async function upload(argv, connection, mode) {
|
|
|
191
190
|
continue;
|
|
192
191
|
line(result.ok
|
|
193
192
|
? `${result.item} ${result.type} ${basename(result.file)}`
|
|
194
|
-
: `failed ${basename(result.file)}
|
|
193
|
+
: `failed ${basename(result.file)}: ${result.error}`);
|
|
195
194
|
}
|
|
196
195
|
line();
|
|
197
196
|
line(`${uploaded.length} uploaded${failed.length ? `, ${failed.length} failed` : ''}.`);
|
|
@@ -2,7 +2,7 @@ import { Client } from '../client.js';
|
|
|
2
2
|
import { resolveBaseUrl, resolveWorkspace, setWorkspaceFor, hostOf } from '../config.js';
|
|
3
3
|
import { line, note, pad, printResult } from '../output.js';
|
|
4
4
|
async function list(client) {
|
|
5
|
-
const data = (await client.
|
|
5
|
+
const data = (await client.get('/api/v1/workspaces'));
|
|
6
6
|
return data.workspaces ?? [];
|
|
7
7
|
}
|
|
8
8
|
export async function workspace(argv, connection, mode) {
|
|
@@ -30,7 +30,7 @@ export async function workspace(argv, connection, mode) {
|
|
|
30
30
|
await setWorkspaceFor(baseUrl, match.id);
|
|
31
31
|
printResult(mode, { workspace: match }, () => {
|
|
32
32
|
line(`Now working in ${match.name}.`);
|
|
33
|
-
note('This applies to the CLI only
|
|
33
|
+
note('This applies to the CLI only. Connected apps keep the workspace they were on.');
|
|
34
34
|
});
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
@@ -43,9 +43,9 @@ export async function workspace(argv, connection, mode) {
|
|
|
43
43
|
const width = Math.max(...workspaces.map((w) => (w.name ?? '').length)) + 2;
|
|
44
44
|
for (const w of workspaces) {
|
|
45
45
|
const marker = current === w.id ? '*' : ' ';
|
|
46
|
-
line(`${marker} ${pad(w.name ?? '(unnamed)', width)}${w.id}`);
|
|
46
|
+
line(`${marker} ${pad(w.name ?? '(unnamed)', width)}${pad(w.role ?? '', 8)}${w.id}`);
|
|
47
47
|
}
|
|
48
48
|
if (!current)
|
|
49
|
-
note(`\nNo CLI workspace set for ${hostOf(baseUrl)}
|
|
49
|
+
note(`\nNo CLI workspace set for ${hostOf(baseUrl)}. Using the account default.`);
|
|
50
50
|
});
|
|
51
51
|
}
|
package/dist/door.js
CHANGED
|
@@ -4,16 +4,21 @@ import { existsSync, readFileSync } from 'node:fs';
|
|
|
4
4
|
import { homedir } from 'node:os';
|
|
5
5
|
import { dirname, join } from 'node:path';
|
|
6
6
|
export const START_WAIT_MS = 45_000;
|
|
7
|
+
function stateCandidates() {
|
|
8
|
+
const home = homedir();
|
|
9
|
+
const root = process.platform === 'darwin'
|
|
10
|
+
? join(home, 'Library', 'Application Support')
|
|
11
|
+
: process.platform === 'win32'
|
|
12
|
+
? process.env.APPDATA || join(home, 'AppData', 'Roaming')
|
|
13
|
+
: process.env.XDG_CONFIG_HOME || join(home, '.config');
|
|
14
|
+
const record = (...parts) => join(root, ...parts, 'agent-door.json');
|
|
15
|
+
return [record('Eversince'), record('@eversince', 'desktop-dev'), record('@eversince', 'desktop')];
|
|
16
|
+
}
|
|
7
17
|
export function stateFile() {
|
|
8
18
|
if (process.env.ES_DESKTOP_STATE)
|
|
9
19
|
return process.env.ES_DESKTOP_STATE;
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
? join(home, 'Library', 'Application Support', 'Eversince')
|
|
13
|
-
: process.platform === 'win32'
|
|
14
|
-
? join(process.env.APPDATA || join(home, 'AppData', 'Roaming'), 'Eversince')
|
|
15
|
-
: join(process.env.XDG_CONFIG_HOME || join(home, '.config'), 'Eversince');
|
|
16
|
-
return join(dir, 'agent-door.json');
|
|
20
|
+
const candidates = stateCandidates();
|
|
21
|
+
return candidates.find((file) => existsSync(file)) ?? candidates[0];
|
|
17
22
|
}
|
|
18
23
|
export function cacheFile(file = stateFile()) {
|
|
19
24
|
return join(dirname(file), 'agent-door-cache.json');
|
package/dist/index.js
CHANGED
|
@@ -15,10 +15,10 @@ const USAGE = `eversince — your workspace, from the command line
|
|
|
15
15
|
|
|
16
16
|
Getting set up
|
|
17
17
|
eversince login sign in through the browser
|
|
18
|
-
eversince login --key
|
|
18
|
+
eversince login --key - or with an API key from stdin (CI, no browser)
|
|
19
19
|
eversince logout
|
|
20
20
|
eversince status
|
|
21
|
-
eversince init connect the agents on this machine
|
|
21
|
+
eversince init connect the agents found on this machine
|
|
22
22
|
eversince init --agent codex connect one agent (claude-code, codex,
|
|
23
23
|
cursor, vscode, claude-desktop, other)
|
|
24
24
|
eversince mcp --agent <agent> the desktop app as a stdio MCP server;
|
|
@@ -32,18 +32,25 @@ Working
|
|
|
32
32
|
eversince download <refs…> library items onto disk
|
|
33
33
|
eversince jobs <ids…> check async work (--wait to follow)
|
|
34
34
|
eversince jobs cancel <ids…>
|
|
35
|
-
eversince workspace [use <name
|
|
35
|
+
eversince workspace [use <name>|clear] which workspace the CLI acts in
|
|
36
36
|
|
|
37
37
|
Options
|
|
38
38
|
--json machine-readable output, on success and failure
|
|
39
39
|
--wait follow async work to completion
|
|
40
40
|
--timeout <seconds> ceiling on a request, and on --wait (default 1800)
|
|
41
|
-
--out <dir> where downloads land
|
|
41
|
+
--out <dir> where downloads land, and where a tool's pictures go
|
|
42
|
+
(a temp folder otherwise)
|
|
42
43
|
--describe <text> description for an upload
|
|
43
|
-
--enrich describe and tag each image upload
|
|
44
|
+
--enrich describe and tag each image upload, using cloud processing
|
|
44
45
|
--concurrency <n> parallel uploads (default 3, max 8)
|
|
45
46
|
--workspace <id> act in this workspace, this once
|
|
46
|
-
--
|
|
47
|
+
--idempotency-key <k> the key for a charged call, so a retry does not charge twice
|
|
48
|
+
--schemas with tools: include each tool's input schema
|
|
49
|
+
--annotation <kind> with tools: only read, write or destructive tools
|
|
50
|
+
--scope <where> with init: project or user, where the agent's settings are written
|
|
51
|
+
--dry-run / --force with init: preview what would be written, or overwrite what is there
|
|
52
|
+
--cloud talk to eversince.ai instead of the desktop app; to have
|
|
53
|
+
the app's work done in the cloud, pass "run_on":"cloud"
|
|
47
54
|
--base-url <url> point at another deployment
|
|
48
55
|
--debug print each request and response
|
|
49
56
|
--json / -h / -v
|
|
@@ -84,7 +91,6 @@ const OPTIONS = {
|
|
|
84
91
|
describe: { type: 'string' },
|
|
85
92
|
concurrency: { type: 'string' },
|
|
86
93
|
enrich: { type: 'boolean', default: false },
|
|
87
|
-
'no-enrich': { type: 'boolean', default: false },
|
|
88
94
|
wait: { type: 'boolean', default: false },
|
|
89
95
|
timeout: { type: 'string' },
|
|
90
96
|
'idempotency-key': { type: 'string' },
|
|
@@ -151,11 +157,12 @@ async function main() {
|
|
|
151
157
|
wait: values.wait,
|
|
152
158
|
timeout,
|
|
153
159
|
idempotencyKey: values['idempotency-key'],
|
|
160
|
+
out: values.out,
|
|
154
161
|
}, connection, mode);
|
|
155
162
|
case 'upload':
|
|
156
163
|
return await upload({
|
|
157
164
|
paths: rest,
|
|
158
|
-
enrich: values.enrich
|
|
165
|
+
enrich: values.enrich,
|
|
159
166
|
describe: values.describe,
|
|
160
167
|
concurrency: toNumber(values.concurrency, 'concurrency'),
|
|
161
168
|
}, connection, mode);
|
package/dist/local.js
CHANGED
|
@@ -4,8 +4,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
4
4
|
import { DoorBlocked, probe, reachApp, readState } from './door.js';
|
|
5
5
|
export function desktopInstalled() {
|
|
6
6
|
const state = readState();
|
|
7
|
-
|
|
8
|
-
return { installed, canConnect: installed && typeof state?.connectKey === 'string' };
|
|
7
|
+
return !!state && existsSync(state.app) && typeof state.connectKey === 'string';
|
|
9
8
|
}
|
|
10
9
|
export function cliLauncher() {
|
|
11
10
|
const script = realpathSync(fileURLToPath(new URL('./index.js', import.meta.url)));
|
|
@@ -58,7 +57,7 @@ export async function openApp(onStart) {
|
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
59
|
export async function localDoor(onStart) {
|
|
61
|
-
if (!desktopInstalled()
|
|
60
|
+
if (!desktopInstalled())
|
|
62
61
|
return null;
|
|
63
62
|
const state = await reachApp(undefined, onStart);
|
|
64
63
|
if (!state)
|
|
@@ -71,9 +70,10 @@ export async function localDoor(onStart) {
|
|
|
71
70
|
reconnect: connect,
|
|
72
71
|
verify: async () => {
|
|
73
72
|
const now = readState();
|
|
74
|
-
|
|
73
|
+
const seen = now ? await probe(now) : 'closed';
|
|
74
|
+
if (now && seen === 'ours')
|
|
75
75
|
return `http://127.0.0.1:${now.port}`;
|
|
76
|
-
if (
|
|
76
|
+
if (seen === 'blocked')
|
|
77
77
|
throw new DoorBlocked();
|
|
78
78
|
const opened = await reachApp(undefined, onStart);
|
|
79
79
|
if (!opened)
|
package/dist/output.js
CHANGED
|
@@ -16,7 +16,7 @@ export function fail(mode, error) {
|
|
|
16
16
|
? error
|
|
17
17
|
: null;
|
|
18
18
|
if (mode.json) {
|
|
19
|
-
const body = asApi?.body ?? { code: 'error', message: error instanceof Error ? error.message : String(error) };
|
|
19
|
+
const body = asApi?.body ?? { code: 'error', message: error instanceof Error ? error.message : String(error), retryable: false, suggested_action: 'Run eversince help for the commands and options.' };
|
|
20
20
|
process.stdout.write(`${JSON.stringify({ ok: false, error: body, ...(asApi?.requestId ? { request_id: asApi.requestId } : {}) })}\n`);
|
|
21
21
|
}
|
|
22
22
|
else {
|
package/dist/retry.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const NOT_SENT_CODES = new Set([
|
|
2
|
+
'ECONNREFUSED',
|
|
3
|
+
'ENOTFOUND',
|
|
4
|
+
'EAI_AGAIN',
|
|
5
|
+
'EAI_NONAME',
|
|
6
|
+
'EHOSTUNREACH',
|
|
7
|
+
'ENETUNREACH',
|
|
8
|
+
'UND_ERR_CONNECT_TIMEOUT',
|
|
9
|
+
'CERT_HAS_EXPIRED',
|
|
10
|
+
'CERT_NOT_YET_VALID',
|
|
11
|
+
'DEPTH_ZERO_SELF_SIGNED_CERT',
|
|
12
|
+
'SELF_SIGNED_CERT_IN_CHAIN',
|
|
13
|
+
'UNABLE_TO_GET_ISSUER_CERT_LOCALLY',
|
|
14
|
+
'UNABLE_TO_VERIFY_LEAF_SIGNATURE',
|
|
15
|
+
]);
|
|
16
|
+
function chain(error) {
|
|
17
|
+
const out = [];
|
|
18
|
+
const seen = new Set();
|
|
19
|
+
let current = error;
|
|
20
|
+
while (current && typeof current === 'object' && !seen.has(current) && out.length < 16) {
|
|
21
|
+
seen.add(current);
|
|
22
|
+
const node = current;
|
|
23
|
+
out.push(node);
|
|
24
|
+
current = node.cause;
|
|
25
|
+
}
|
|
26
|
+
return out;
|
|
27
|
+
}
|
|
28
|
+
export function isConnectFailure(error) {
|
|
29
|
+
for (const node of chain(error)) {
|
|
30
|
+
const code = node.code;
|
|
31
|
+
if (typeof code !== 'string')
|
|
32
|
+
continue;
|
|
33
|
+
if (NOT_SENT_CODES.has(code) || code.startsWith('ERR_TLS_') || code.startsWith('ERR_SSL_'))
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eversince",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "Agent-native access to making content",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"eversince": "dist/index.js"
|