eversince 0.2.11 → 0.2.13
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 +5 -2
- package/dist/bridge.js +6 -5
- package/dist/commands/auth.js +14 -1
- package/dist/commands/init.js +9 -10
- package/dist/commands/run.js +18 -3
- package/dist/commands/tools.js +34 -3
- package/dist/door.js +46 -4
- package/dist/index.js +15 -2
- package/dist/local.js +56 -8
- package/dist/output.js +9 -4
- package/dist/source.sha256 +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
Your Eversince workspace, from the command line — for agents and the people who run them.
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
|
-
|
|
7
|
-
eversince init
|
|
6
|
+
npx -y eversince@latest init
|
|
8
7
|
```
|
|
9
8
|
|
|
9
|
+
With a global install (`npm install -g eversince`, where npm can write without sudo), the
|
|
10
|
+
commands below are `eversince …`; from npx they are `npx -y eversince@latest …`.
|
|
11
|
+
|
|
10
12
|
Without the desktop app, `eversince login` is needed only to run tools from the shell.
|
|
11
13
|
|
|
12
14
|
`init` connects the agents on this machine and installs a skill that teaches them
|
|
@@ -54,6 +56,7 @@ eversince init --agent codex connect one agent
|
|
|
54
56
|
eversince mcp --agent codex the desktop app as a stdio MCP server (init writes this)
|
|
55
57
|
|
|
56
58
|
eversince tools [name] what this workspace can do, live
|
|
59
|
+
eversince tools --all every tool's input fields, once
|
|
57
60
|
eversince run <tool> '<json>' call any tool (--wait to follow async work; - reads stdin)
|
|
58
61
|
eversince upload <files|folder> local files into the library
|
|
59
62
|
eversince download <refs…> library items onto disk
|
package/dist/bridge.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DoorBlocked, cacheFile as cacheFileFor, isBlocked, isRefused, probe, reachApp, readJson, readState, sandboxedWithoutNetwork, stateFile as defaultStateFile, } from './door.js';
|
|
1
|
+
import { DoorBlocked, cacheFile as cacheFileFor, isBlocked, isRefused, probe, reachApp, unreachedMessage, readJson, readState, sandboxedWithoutNetwork, stateFile as defaultStateFile, } from './door.js';
|
|
2
2
|
import { existsSync } from 'node:fs';
|
|
3
3
|
import { isConnectFailure } from './retry.js';
|
|
4
4
|
function write(message) {
|
|
@@ -14,13 +14,14 @@ function rpcError(id, message, code = -32000) {
|
|
|
14
14
|
export function runBridge(options) {
|
|
15
15
|
const file = options.stateFile ?? defaultStateFile();
|
|
16
16
|
const cacheFile = cacheFileFor(file);
|
|
17
|
-
const
|
|
17
|
+
const self = options.command ?? 'eversince';
|
|
18
|
+
const reconnect = options.reconnect ?? `Run \`${self} init --agent ${options.agent}\` to connect it again.`;
|
|
18
19
|
function connectionFor(state) {
|
|
19
20
|
const found = (state?.connections ?? []).find((c) => c && (options.connectionId ? c.id === options.connectionId : c.agent === options.agent));
|
|
20
21
|
return found && typeof found.token === 'string' ? { token: found.token } : null;
|
|
21
22
|
}
|
|
22
23
|
if (!readState(file)) {
|
|
23
|
-
process.stderr.write(
|
|
24
|
+
process.stderr.write(`eversince: the Eversince app is not set up on this computer. Install it, open it and sign in, or run \`${self} init --cloud\` to connect this agent to eversince.ai instead.\n`);
|
|
24
25
|
process.exit(1);
|
|
25
26
|
}
|
|
26
27
|
let listFromCache = null;
|
|
@@ -47,8 +48,8 @@ export function runBridge(options) {
|
|
|
47
48
|
state = await open();
|
|
48
49
|
if (!state) {
|
|
49
50
|
if (before && !existsSync(before.app))
|
|
50
|
-
throw new Error(
|
|
51
|
-
throw new Error(
|
|
51
|
+
throw new Error(`The Eversince app is no longer on this computer. Run \`${self} init\` to connect this agent to eversince.ai instead.`);
|
|
52
|
+
throw new Error(unreachedMessage(`or run \`${self} init --cloud\` to connect this agent to eversince.ai instead`));
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
const connection = connectionFor(state);
|
package/dist/commands/auth.js
CHANGED
|
@@ -5,6 +5,7 @@ import { resolveBaseUrl, resolveWorkspace, writeSettings, hostOf } from '../conf
|
|
|
5
5
|
import { Client, ApiError, loadCredentials, mayUseDesktop } from '../client.js';
|
|
6
6
|
import { line, note, printResult } from '../output.js';
|
|
7
7
|
import { desktopInstalled } from '../local.js';
|
|
8
|
+
import { probe, readState } from '../door.js';
|
|
8
9
|
import { detectHostAgent } from '../host-agent.js';
|
|
9
10
|
const KEY_PREFIX = 'es_live_';
|
|
10
11
|
async function readKeyFromInput(fromStdin) {
|
|
@@ -131,8 +132,11 @@ export async function status(connection, mode) {
|
|
|
131
132
|
const fromEnv = Boolean(process.env.ES_API_KEY);
|
|
132
133
|
const installed = desktopInstalled();
|
|
133
134
|
const desktop = installed && (await mayUseDesktop(connection));
|
|
135
|
+
const record = desktop ? readState() : null;
|
|
136
|
+
const answers = !desktop ? null : record ? await probe(record).catch(() => 'closed') : 'closed';
|
|
134
137
|
const payload = {
|
|
135
138
|
desktop_app: desktop ? 'used' : installed ? 'not_used' : 'not_installed',
|
|
139
|
+
desktop_app_state: answers === 'ours' ? 'open' : answers,
|
|
136
140
|
signed_in: credentials !== null,
|
|
137
141
|
host,
|
|
138
142
|
base_url: baseUrl,
|
|
@@ -142,7 +146,16 @@ export async function status(connection, mode) {
|
|
|
142
146
|
expires_at: credentials?.expiresAt ? new Date(credentials.expiresAt).toISOString() : null,
|
|
143
147
|
};
|
|
144
148
|
printResult(mode, payload, () => {
|
|
145
|
-
|
|
149
|
+
if (!desktop)
|
|
150
|
+
line(`Commands run in the cloud (${host}).`);
|
|
151
|
+
else if (answers === 'ours')
|
|
152
|
+
line('Commands run through the desktop app on this computer, for free. It is open.');
|
|
153
|
+
else if (answers === 'closed')
|
|
154
|
+
line('Commands run through the desktop app on this computer, for free. It is closed; the next command opens it.');
|
|
155
|
+
else if (answers === 'blocked')
|
|
156
|
+
line('Commands go to the desktop app on this computer, but this shell cannot reach it. Allow local network access, or add --cloud.');
|
|
157
|
+
else
|
|
158
|
+
line('Commands go to the desktop app on this computer, but another program answers on its port. Restart the app, or add --cloud.');
|
|
146
159
|
const how = credentials ? (credentials.kind === 'api_key' ? 'with an API key' : 'in the browser') : '';
|
|
147
160
|
const from = fromEnv ? ', from ES_API_KEY' : '';
|
|
148
161
|
if (!credentials) {
|
package/dist/commands/init.js
CHANGED
|
@@ -6,7 +6,7 @@ import { discoverAuthorizationServer } from '../auth/oauth.js';
|
|
|
6
6
|
import { Client } from '../client.js';
|
|
7
7
|
import { resolveBaseUrl, hostOf } from '../config.js';
|
|
8
8
|
import { line, note, printResult } from '../output.js';
|
|
9
|
-
import {
|
|
9
|
+
import { connectThroughApp, desktopInstalled, hereCommand, openApp, stableLauncher } from '../local.js';
|
|
10
10
|
import { detectHostAgent } from '../host-agent.js';
|
|
11
11
|
export const APP_AGENTS = ['claude-code', 'codex', 'cursor', 'vscode', 'claude-desktop', 'other', 'cli'];
|
|
12
12
|
function checkAgent(given) {
|
|
@@ -16,7 +16,7 @@ function checkAgent(given) {
|
|
|
16
16
|
throw new Error(`--agent is one of ${APP_AGENTS.join(', ')}.`);
|
|
17
17
|
return given;
|
|
18
18
|
}
|
|
19
|
-
const
|
|
19
|
+
const getTheApp = () => hereCommand('With the Eversince desktop app on this computer, the same work runs free. Get it at https://eversince.ai, then run eversince init again.');
|
|
20
20
|
const SERVER_KEY = 'eversince';
|
|
21
21
|
function vscodeUserDir() {
|
|
22
22
|
const home = homedir();
|
|
@@ -67,7 +67,7 @@ function skillTargets(scope) {
|
|
|
67
67
|
return [{ agent: 'Claude Code', path: join(root, '.claude', 'skills', 'eversince-cli', 'SKILL.md') }];
|
|
68
68
|
}
|
|
69
69
|
function skillBody(mcpWhere) {
|
|
70
|
-
return `---
|
|
70
|
+
return hereCommand(`---
|
|
71
71
|
name: eversince-cli
|
|
72
72
|
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.
|
|
73
73
|
---
|
|
@@ -110,7 +110,7 @@ files are on this machine or the work has to outlive the session.
|
|
|
110
110
|
- \`--workspace <id>\` picks the workspace for one command, on eversince.ai (it needs
|
|
111
111
|
\`eversince login\`; an API key keeps its own workspace), and changes nothing for anyone
|
|
112
112
|
else. Left off, it is the workspace the desktop app has open, or the one this sign-in uses.
|
|
113
|
-
|
|
113
|
+
`);
|
|
114
114
|
}
|
|
115
115
|
async function exists(path) {
|
|
116
116
|
try {
|
|
@@ -226,15 +226,12 @@ async function initThroughApp(argv, scope, mode) {
|
|
|
226
226
|
if (agents.length === 0) {
|
|
227
227
|
throw new Error(`Name the agent to connect with --agent: ${APP_AGENTS.join(', ')}.`);
|
|
228
228
|
}
|
|
229
|
-
if (agents.some((a) => a !== 'claude-desktop') && launchedFromTemporaryCopy()) {
|
|
230
|
-
throw new Error('This CLI is a temporary copy. Install it with `npm install -g eversince`, then run `eversince init` again.');
|
|
231
|
-
}
|
|
232
229
|
const dryRun = argv.dryRun === true;
|
|
230
|
+
const cli = await stableLauncher(dryRun);
|
|
233
231
|
const connections = [];
|
|
234
232
|
if (!dryRun) {
|
|
235
233
|
await openApp(() => { if (!mode.json)
|
|
236
234
|
note('Opening the Eversince app on this computer.'); });
|
|
237
|
-
const cli = cliLauncher();
|
|
238
235
|
for (const agent of agents)
|
|
239
236
|
connections.push(await connectThroughApp(agent, { cli, ...(name ? { name } : {}) }));
|
|
240
237
|
}
|
|
@@ -250,12 +247,14 @@ async function initThroughApp(argv, scope, mode) {
|
|
|
250
247
|
venue: 'desktop',
|
|
251
248
|
dry_run: dryRun,
|
|
252
249
|
agents,
|
|
250
|
+
runs: cli,
|
|
253
251
|
connections: connections.map(({ token: _token, ...rest }) => { void _token; return rest; }),
|
|
254
252
|
changes,
|
|
255
253
|
...(shadowed ? { shadowed_by: shadowed } : {}),
|
|
256
254
|
}, () => {
|
|
257
255
|
if (dryRun) {
|
|
258
256
|
line(`Would connect ${agents.join(', ')} through the Eversince app on this computer.`);
|
|
257
|
+
line(`The agent would run ${cli.script}`);
|
|
259
258
|
}
|
|
260
259
|
for (const c of connections) {
|
|
261
260
|
line(`Connected ${c.label} through the Eversince app on this computer. Work it does there is free.`);
|
|
@@ -337,7 +336,7 @@ export async function init(argv, connection, mode) {
|
|
|
337
336
|
}
|
|
338
337
|
}
|
|
339
338
|
}
|
|
340
|
-
printResult(mode, { venue: 'cloud', scope, mcp_url: mcpUrl, dry_run: dryRun, connected, changes, manual: skipped, ...(offerApp ? { desktop_app:
|
|
339
|
+
printResult(mode, { venue: 'cloud', scope, mcp_url: mcpUrl, dry_run: dryRun, connected, changes, manual: skipped, ...(offerApp ? { desktop_app: getTheApp() } : {}) }, () => {
|
|
341
340
|
for (const change of changes) {
|
|
342
341
|
line(`${change.action.padEnd(10)}${change.path}`);
|
|
343
342
|
if (change.backup)
|
|
@@ -361,6 +360,6 @@ export async function init(argv, connection, mode) {
|
|
|
361
360
|
line(`Connected to ${hostOf(baseUrl)}. Restart any running agent to pick it up.`);
|
|
362
361
|
note('The agent authorises its own MCP connection; it does not use the CLI credential.');
|
|
363
362
|
if (offerApp)
|
|
364
|
-
line(
|
|
363
|
+
line(getTheApp());
|
|
365
364
|
});
|
|
366
365
|
}
|
package/dist/commands/run.js
CHANGED
|
@@ -19,8 +19,10 @@ async function saveMedia(media, tool, out) {
|
|
|
19
19
|
const safe = tool.replace(/[^\w.-]+/g, '-');
|
|
20
20
|
const written = [];
|
|
21
21
|
for (const [i, picture] of media.entries()) {
|
|
22
|
-
if (typeof picture?.data !== 'string' || picture.data.length === 0)
|
|
22
|
+
if (typeof picture?.data !== 'string' || picture.data.length === 0) {
|
|
23
|
+
written.push(null);
|
|
23
24
|
continue;
|
|
25
|
+
}
|
|
24
26
|
const ext = MEDIA_EXTENSIONS[picture.mimeType ?? ''] ?? '.bin';
|
|
25
27
|
const path = join(dir, `${safe}-${stamp}${media.length > 1 ? `-${i + 1}` : ''}${ext}`);
|
|
26
28
|
await writeFile(path, Buffer.from(picture.data, 'base64'));
|
|
@@ -28,6 +30,18 @@ async function saveMedia(media, tool, out) {
|
|
|
28
30
|
}
|
|
29
31
|
return written;
|
|
30
32
|
}
|
|
33
|
+
function withPicturePaths(data, saved) {
|
|
34
|
+
const answer = (data ?? {});
|
|
35
|
+
if (!Array.isArray(answer.items))
|
|
36
|
+
return answer;
|
|
37
|
+
const items = answer.items.map((item) => {
|
|
38
|
+
const at = item?.pictures;
|
|
39
|
+
if (!Array.isArray(at))
|
|
40
|
+
return item;
|
|
41
|
+
return { ...item, pictures: at.map((n) => (typeof n === 'number' ? saved[n] ?? null : n)).filter(Boolean) };
|
|
42
|
+
});
|
|
43
|
+
return { ...answer, items };
|
|
44
|
+
}
|
|
31
45
|
async function readStdin() {
|
|
32
46
|
const chunks = [];
|
|
33
47
|
for await (const chunk of process.stdin)
|
|
@@ -69,8 +83,9 @@ export async function run(argv, connection, mode) {
|
|
|
69
83
|
}
|
|
70
84
|
const client = await Client.create(connection);
|
|
71
85
|
const answered = await client.toolWithMedia(argv.name, input, { idempotencyKey: argv.idempotencyKey });
|
|
72
|
-
const
|
|
73
|
-
const
|
|
86
|
+
const saved = await saveMedia(answered.media, argv.name, argv.out);
|
|
87
|
+
const pictures = saved.filter((p) => !!p);
|
|
88
|
+
const result = pictures.length ? { ...withPicturePaths(answered.data, saved), pictures } : answered.data;
|
|
74
89
|
if (!argv.wait) {
|
|
75
90
|
printResult(mode, result, () => {
|
|
76
91
|
line(JSON.stringify(result, null, 2));
|
package/dist/commands/tools.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Client } from '../client.js';
|
|
2
2
|
import { line, pad, printResult } from '../output.js';
|
|
3
|
+
import { hereCommand } from '../local.js';
|
|
3
4
|
export async function tools(argv, connection, mode) {
|
|
4
5
|
const client = await Client.create(connection);
|
|
5
|
-
const wantSchemas = argv.schemas === true || Boolean(argv.name) || mode.json;
|
|
6
|
+
const wantSchemas = argv.all === true || argv.schemas === true || Boolean(argv.name) || mode.json;
|
|
6
7
|
const data = (await client.get('/api/v1/tools', {
|
|
7
8
|
schemas: wantSchemas ? undefined : 'false',
|
|
8
9
|
annotation: argv.annotation,
|
|
@@ -14,6 +15,16 @@ export async function tools(argv, connection, mode) {
|
|
|
14
15
|
const near = data.tools.filter((t) => t.name.includes(argv.name)).slice(0, 5);
|
|
15
16
|
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.'}`);
|
|
16
17
|
}
|
|
18
|
+
if (argv.all && !argv.name) {
|
|
19
|
+
const compact = list.map((t) => ({ name: t.name, input: compactSchema(t.input_schema) }));
|
|
20
|
+
printResult(mode, { tools: compact }, () => {
|
|
21
|
+
for (const t of compact)
|
|
22
|
+
line(`${t.name} ${t.input}`);
|
|
23
|
+
line();
|
|
24
|
+
line(hereCommand('`eversince tools <name>` for one tool in full, with descriptions.'));
|
|
25
|
+
});
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
17
28
|
printResult(mode, argv.name ? list[0] : { instructions: data.instructions, tools: list }, () => {
|
|
18
29
|
if (argv.name) {
|
|
19
30
|
const tool = list[0];
|
|
@@ -26,7 +37,7 @@ export async function tools(argv, connection, mode) {
|
|
|
26
37
|
line(JSON.stringify(tool.input_schema, null, 2));
|
|
27
38
|
}
|
|
28
39
|
line();
|
|
29
|
-
line(`eversince run ${tool.name} '{ … }'`);
|
|
40
|
+
line(hereCommand(`eversince run ${tool.name} '{ … }'`));
|
|
30
41
|
return;
|
|
31
42
|
}
|
|
32
43
|
if (data.instructions) {
|
|
@@ -39,6 +50,26 @@ export async function tools(argv, connection, mode) {
|
|
|
39
50
|
for (const tool of list)
|
|
40
51
|
line(`${pad(tool.name, width)}${tool.description}`);
|
|
41
52
|
line();
|
|
42
|
-
line(`${list.length} tools. \`eversince tools <name>\` for one in full.`);
|
|
53
|
+
line(hereCommand(`${list.length} tools. \`eversince tools <name>\` for one in full.`));
|
|
43
54
|
});
|
|
44
55
|
}
|
|
56
|
+
function compactSchema(schema, depth = 0) {
|
|
57
|
+
const node = (schema ?? {});
|
|
58
|
+
const options = (node.anyOf ?? node.oneOf);
|
|
59
|
+
if (Array.isArray(node.enum))
|
|
60
|
+
return node.enum.map(String).join('|');
|
|
61
|
+
if (options)
|
|
62
|
+
return [...new Set(options.map((o) => compactSchema(o, depth)))].join('|');
|
|
63
|
+
if (node.type === 'array')
|
|
64
|
+
return `${compactSchema(node.items, depth)}[]`;
|
|
65
|
+
const props = node.properties;
|
|
66
|
+
if (node.type === 'object' || props) {
|
|
67
|
+
if (!props)
|
|
68
|
+
return 'object';
|
|
69
|
+
if (depth >= 3)
|
|
70
|
+
return '{…}';
|
|
71
|
+
const required = new Set(Array.isArray(node.required) ? node.required : []);
|
|
72
|
+
return `{${Object.entries(props).map(([k, v]) => `${k}${required.has(k) ? '*' : ''}: ${compactSchema(v, depth + 1)}`).join(', ')}}`;
|
|
73
|
+
}
|
|
74
|
+
return Array.isArray(node.type) ? node.type.join('|') : String(node.type ?? 'any');
|
|
75
|
+
}
|
package/dist/door.js
CHANGED
|
@@ -107,29 +107,42 @@ export function launch(state) {
|
|
|
107
107
|
spawn(state.app, args, { stdio: 'ignore', detached: true, env }).on('error', () => undefined).unref();
|
|
108
108
|
return true;
|
|
109
109
|
}
|
|
110
|
-
export async function reachApp(file
|
|
110
|
+
export async function reachApp(file, onStart) {
|
|
111
|
+
file ??= await answeringFile();
|
|
112
|
+
lastMiss = null;
|
|
111
113
|
const state = readState(file);
|
|
112
|
-
if (!state)
|
|
114
|
+
if (!state) {
|
|
115
|
+
lastMiss = 'missing';
|
|
113
116
|
return null;
|
|
117
|
+
}
|
|
114
118
|
const first = await probe(state);
|
|
115
119
|
if (first === 'ours')
|
|
116
120
|
return state;
|
|
117
121
|
if (first === 'blocked')
|
|
118
122
|
throw new DoorBlocked();
|
|
123
|
+
if (!existsSync(state.app)) {
|
|
124
|
+
lastMiss = 'missing';
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
119
127
|
const devUrl = state.launch && typeof state.launch === 'object' && state.launch.env && typeof state.launch.env === 'object'
|
|
120
128
|
? state.launch.env.EVERSINCE_DEV_URL
|
|
121
129
|
: undefined;
|
|
122
130
|
if (typeof devUrl === 'string') {
|
|
123
131
|
const up = await fetch(devUrl, { signal: AbortSignal.timeout(1500) }).then(() => true, () => false);
|
|
124
|
-
if (!up)
|
|
132
|
+
if (!up) {
|
|
133
|
+
lastMiss = 'dev-down';
|
|
125
134
|
return null;
|
|
135
|
+
}
|
|
126
136
|
}
|
|
127
137
|
onStart?.();
|
|
128
138
|
try {
|
|
129
|
-
if (!launch(state))
|
|
139
|
+
if (!launch(state)) {
|
|
140
|
+
lastMiss = 'missing';
|
|
130
141
|
return null;
|
|
142
|
+
}
|
|
131
143
|
}
|
|
132
144
|
catch {
|
|
145
|
+
lastMiss = 'slow';
|
|
133
146
|
return null;
|
|
134
147
|
}
|
|
135
148
|
const until = Date.now() + START_WAIT_MS;
|
|
@@ -144,5 +157,34 @@ export async function reachApp(file = stateFile(), onStart) {
|
|
|
144
157
|
if (seen === 'blocked')
|
|
145
158
|
throw new DoorBlocked();
|
|
146
159
|
}
|
|
160
|
+
lastMiss = 'slow';
|
|
147
161
|
return null;
|
|
148
162
|
}
|
|
163
|
+
let lastMiss = null;
|
|
164
|
+
export function unreachedMessage(cloudHint = 'or run with --cloud') {
|
|
165
|
+
switch (lastMiss) {
|
|
166
|
+
case 'missing':
|
|
167
|
+
return `The Eversince app is not installed on this computer. Install it, ${cloudHint}.`;
|
|
168
|
+
case 'dev-down':
|
|
169
|
+
return `The development copy of the Eversince app is not running and its page server is down. Start it with npm run dev:desktop, ${cloudHint}.`;
|
|
170
|
+
case 'slow':
|
|
171
|
+
default:
|
|
172
|
+
return `The Eversince app was started but did not answer in time. Try again in a moment, ${cloudHint}.`;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
export async function answeringFile() {
|
|
176
|
+
const first = stateFile();
|
|
177
|
+
if (process.env.ES_DESKTOP_STATE || !fromSource())
|
|
178
|
+
return first;
|
|
179
|
+
const firstState = readState(first);
|
|
180
|
+
if (firstState && (await probe(firstState).catch(() => 'closed')) === 'ours')
|
|
181
|
+
return first;
|
|
182
|
+
for (const file of stateCandidates()) {
|
|
183
|
+
if (file === first || !existsSync(file))
|
|
184
|
+
continue;
|
|
185
|
+
const state = readState(file);
|
|
186
|
+
if (state && (await probe(state).catch(() => 'closed')) === 'ours')
|
|
187
|
+
return file;
|
|
188
|
+
}
|
|
189
|
+
return first;
|
|
190
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import { download } from './commands/download.js';
|
|
|
9
9
|
import { jobs } from './commands/jobs.js';
|
|
10
10
|
import { init, APP_AGENTS } from './commands/init.js';
|
|
11
11
|
import { runBridge } from './bridge.js';
|
|
12
|
+
import { selfCommand } from './local.js';
|
|
12
13
|
import { fail, line } from './output.js';
|
|
13
14
|
import { VERSION } from './version.js';
|
|
14
15
|
const USAGE = `eversince — your workspace, from the command line
|
|
@@ -27,6 +28,7 @@ Getting set up
|
|
|
27
28
|
|
|
28
29
|
Working
|
|
29
30
|
eversince tools [name] what this workspace can do, live
|
|
31
|
+
eversince tools --all every tool's input fields, once
|
|
30
32
|
eversince run <tool> '<json>' call any tool (--wait to follow async work)
|
|
31
33
|
eversince run <tool> - arguments from stdin
|
|
32
34
|
eversince upload <files|folder> local files into the library (through the
|
|
@@ -96,6 +98,7 @@ const OPTIONS = {
|
|
|
96
98
|
workspace: { type: 'string' },
|
|
97
99
|
out: { type: 'string', short: 'o' },
|
|
98
100
|
schemas: { type: 'boolean', default: false },
|
|
101
|
+
all: { type: 'boolean', default: false },
|
|
99
102
|
annotation: { type: 'string' },
|
|
100
103
|
describe: { type: 'string' },
|
|
101
104
|
concurrency: { type: 'string' },
|
|
@@ -158,7 +161,7 @@ async function main() {
|
|
|
158
161
|
case 'workspace':
|
|
159
162
|
return await workspace({ action: rest[0], target: rest[1] }, connection, mode);
|
|
160
163
|
case 'tools':
|
|
161
|
-
return await tools({ name: rest[0], schemas: values.schemas, annotation: values.annotation }, connection, mode);
|
|
164
|
+
return await tools({ name: rest[0], all: values.all, schemas: values.schemas, annotation: values.annotation }, connection, mode);
|
|
162
165
|
case 'run':
|
|
163
166
|
return await run({
|
|
164
167
|
name: rest[0],
|
|
@@ -186,7 +189,7 @@ async function main() {
|
|
|
186
189
|
if (!agent || !APP_AGENTS.includes(agent)) {
|
|
187
190
|
throw new Error(`eversince mcp needs --agent, one of ${APP_AGENTS.join(', ')}.`);
|
|
188
191
|
}
|
|
189
|
-
runBridge({ agent, connectionId: values.connection });
|
|
192
|
+
runBridge({ agent, connectionId: values.connection, command: selfCommand() });
|
|
190
193
|
return;
|
|
191
194
|
}
|
|
192
195
|
case 'init':
|
|
@@ -207,4 +210,14 @@ async function main() {
|
|
|
207
210
|
fail(mode, error);
|
|
208
211
|
}
|
|
209
212
|
}
|
|
213
|
+
process.stdout.on('error', (error) => {
|
|
214
|
+
if (error.code === 'EPIPE')
|
|
215
|
+
process.exit(0);
|
|
216
|
+
throw error;
|
|
217
|
+
});
|
|
218
|
+
process.stderr.on('error', (error) => {
|
|
219
|
+
if (error.code === 'EPIPE')
|
|
220
|
+
process.exit(0);
|
|
221
|
+
throw error;
|
|
222
|
+
});
|
|
210
223
|
main().catch((error) => fail({ json: process.argv.includes('--json') }, error));
|
package/dist/local.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { existsSync, realpathSync } from 'node:fs';
|
|
2
|
-
import {
|
|
1
|
+
import { existsSync, readFileSync, realpathSync } from 'node:fs';
|
|
2
|
+
import { cp, mkdir, rename, rm } from 'node:fs/promises';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { delimiter, dirname, join, sep } from 'node:path';
|
|
3
5
|
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import { DoorBlocked, probe, reachApp, readState } from './door.js';
|
|
6
|
+
import { DoorBlocked, probe, reachApp, readState, unreachedMessage } from './door.js';
|
|
5
7
|
import { detectHostAgent, kindForName } from './host-agent.js';
|
|
6
8
|
export function desktopInstalled() {
|
|
7
9
|
const state = readState();
|
|
@@ -31,10 +33,56 @@ export function cliLauncher() {
|
|
|
31
33
|
export function launchedFromTemporaryCopy() {
|
|
32
34
|
return /[\\/]_npx[\\/]/.test(cliLauncher().script);
|
|
33
35
|
}
|
|
36
|
+
function keptRoot() {
|
|
37
|
+
const root = join(process.env.ES_STATE_DIR || join(homedir(), '.eversince'), 'cli');
|
|
38
|
+
try {
|
|
39
|
+
return realpathSync(root);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return root;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function runsFromKeptCopy() {
|
|
46
|
+
return cliLauncher().script.startsWith(keptRoot() + sep);
|
|
47
|
+
}
|
|
48
|
+
export function selfCommand() {
|
|
49
|
+
return launchedFromTemporaryCopy() || runsFromKeptCopy() ? 'npx -y eversince@latest' : 'eversince';
|
|
50
|
+
}
|
|
51
|
+
export function hereCommand(text) {
|
|
52
|
+
const self = selfCommand();
|
|
53
|
+
if (self === 'eversince')
|
|
54
|
+
return text;
|
|
55
|
+
return text.replace(/(^|[^\w@/.-])eversince (?=(?:init|login|logout|status|tools|run|upload|download|jobs|workspace|mcp|help)\b)/g, `$1${self} `);
|
|
56
|
+
}
|
|
57
|
+
export async function stableLauncher(dryRun) {
|
|
58
|
+
const here = cliLauncher();
|
|
59
|
+
if (!launchedFromTemporaryCopy())
|
|
60
|
+
return here;
|
|
61
|
+
const from = dirname(dirname(here.script));
|
|
62
|
+
const version = JSON.parse(readFileSync(join(from, 'package.json'), 'utf8')).version ?? '0.0.0';
|
|
63
|
+
const to = join(keptRoot(), version);
|
|
64
|
+
const script = join(to, 'dist', 'index.js');
|
|
65
|
+
if (dryRun || existsSync(script))
|
|
66
|
+
return { node: here.node, script };
|
|
67
|
+
await mkdir(keptRoot(), { recursive: true });
|
|
68
|
+
const temp = `${to}.tmp-${process.pid}`;
|
|
69
|
+
await rm(temp, { recursive: true, force: true });
|
|
70
|
+
await cp(join(from, 'dist'), join(temp, 'dist'), { recursive: true });
|
|
71
|
+
await cp(join(from, 'package.json'), join(temp, 'package.json'));
|
|
72
|
+
try {
|
|
73
|
+
await rename(temp, to);
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
await rm(temp, { recursive: true, force: true });
|
|
77
|
+
if (!existsSync(script))
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
return { node: here.node, script };
|
|
81
|
+
}
|
|
34
82
|
export async function connectThroughApp(agent, extra = {}) {
|
|
35
83
|
const state = await reachApp();
|
|
36
84
|
if (!state?.connectKey)
|
|
37
|
-
throw new Error(
|
|
85
|
+
throw new Error(unreachedMessage());
|
|
38
86
|
const res = await fetch(`http://127.0.0.1:${state.port}/connect`, {
|
|
39
87
|
method: 'POST',
|
|
40
88
|
headers: { authorization: `Bearer ${state.connectKey}`, 'content-type': 'application/json' },
|
|
@@ -42,7 +90,7 @@ export async function connectThroughApp(agent, extra = {}) {
|
|
|
42
90
|
});
|
|
43
91
|
const payload = (await res.json().catch(() => null));
|
|
44
92
|
if (!res.ok || !payload?.data) {
|
|
45
|
-
throw new Error(payload?.error?.message
|
|
93
|
+
throw new Error(payload?.error?.message ? hereCommand(payload.error.message) : `The Eversince app refused to connect ${agent} (${res.status}).`);
|
|
46
94
|
}
|
|
47
95
|
return payload.data;
|
|
48
96
|
}
|
|
@@ -55,7 +103,7 @@ async function connect() {
|
|
|
55
103
|
}
|
|
56
104
|
export async function openApp(onStart) {
|
|
57
105
|
if (!(await reachApp(undefined, onStart))) {
|
|
58
|
-
throw new Error(
|
|
106
|
+
throw new Error(unreachedMessage());
|
|
59
107
|
}
|
|
60
108
|
}
|
|
61
109
|
export async function localDoor(onStart) {
|
|
@@ -68,7 +116,7 @@ export async function localDoor(onStart) {
|
|
|
68
116
|
}
|
|
69
117
|
const state = await reachApp(undefined, onStart);
|
|
70
118
|
if (!state)
|
|
71
|
-
throw new Error(
|
|
119
|
+
throw new Error(unreachedMessage());
|
|
72
120
|
const host = detectHostAgent();
|
|
73
121
|
const label = host?.name ?? 'CLI agent';
|
|
74
122
|
const existing = state.connections?.find((c) => c?.label === label && c?.agent === kindForName(host?.name) && typeof c.token === 'string');
|
|
@@ -86,7 +134,7 @@ export async function localDoor(onStart) {
|
|
|
86
134
|
throw new DoorBlocked();
|
|
87
135
|
const opened = await reachApp(undefined, onStart);
|
|
88
136
|
if (!opened)
|
|
89
|
-
throw new Error(
|
|
137
|
+
throw new Error(unreachedMessage());
|
|
90
138
|
return `http://127.0.0.1:${opened.port}`;
|
|
91
139
|
},
|
|
92
140
|
};
|
package/dist/output.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { hereCommand } from './local.js';
|
|
1
2
|
export function printResult(mode, value, human) {
|
|
2
3
|
if (mode.json) {
|
|
3
4
|
process.stdout.write(`${JSON.stringify({ ok: true, data: value })}\n`);
|
|
@@ -15,14 +16,18 @@ export function fail(mode, error) {
|
|
|
15
16
|
const asApi = error && typeof error === 'object' && 'body' in error
|
|
16
17
|
? error
|
|
17
18
|
: null;
|
|
19
|
+
const message = hereCommand(error instanceof Error ? error.message : String(error));
|
|
20
|
+
const suggested = asApi?.body.suggested_action ? hereCommand(asApi.body.suggested_action) : undefined;
|
|
18
21
|
if (mode.json) {
|
|
19
|
-
const body = asApi?.body
|
|
22
|
+
const body = asApi?.body
|
|
23
|
+
? { ...asApi.body, ...(asApi.body.message ? { message: hereCommand(asApi.body.message) } : {}), ...(suggested ? { suggested_action: suggested } : {}) }
|
|
24
|
+
: { code: 'error', message, retryable: false, suggested_action: hereCommand('Run eversince help for the commands and options.') };
|
|
20
25
|
process.stdout.write(`${JSON.stringify({ ok: false, error: body, ...(asApi?.requestId ? { request_id: asApi.requestId } : {}) })}\n`);
|
|
21
26
|
}
|
|
22
27
|
else {
|
|
23
|
-
process.stderr.write(`${
|
|
24
|
-
if (
|
|
25
|
-
process.stderr.write(`${
|
|
28
|
+
process.stderr.write(`${message}\n`);
|
|
29
|
+
if (suggested)
|
|
30
|
+
process.stderr.write(`${suggested}\n`);
|
|
26
31
|
if (asApi?.requestId)
|
|
27
32
|
process.stderr.write(`request ${asApi.requestId}\n`);
|
|
28
33
|
}
|
package/dist/source.sha256
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
76558d0f394c159e4e748ea3e71c0f135e71f588067f409fb35449fff9de3a26
|
package/package.json
CHANGED