eversince 0.2.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.
@@ -0,0 +1,201 @@
1
+ import { stat, readdir } from 'node:fs/promises';
2
+ import { createReadStream } from 'node:fs';
3
+ import { Readable } from 'node:stream';
4
+ import { basename, extname, join, resolve } from 'node:path';
5
+ import { Client, ApiError } from '../client.js';
6
+ import { line, note, printResult } from '../output.js';
7
+ import { USER_AGENT } from '../version.js';
8
+ const CONTENT_TYPES = {
9
+ '.png': 'image/png',
10
+ '.jpg': 'image/jpeg',
11
+ '.jpeg': 'image/jpeg',
12
+ '.webp': 'image/webp',
13
+ '.gif': 'image/gif',
14
+ '.heic': 'image/heic',
15
+ '.heif': 'image/heif',
16
+ '.avif': 'image/avif',
17
+ '.svg': 'image/svg+xml',
18
+ '.tif': 'image/tiff',
19
+ '.tiff': 'image/tiff',
20
+ '.mp4': 'video/mp4',
21
+ '.mov': 'video/quicktime',
22
+ '.webm': 'video/webm',
23
+ '.m4v': 'video/x-m4v',
24
+ '.avi': 'video/x-msvideo',
25
+ '.mkv': 'video/x-matroska',
26
+ '.mp3': 'audio/mpeg',
27
+ '.wav': 'audio/wav',
28
+ '.m4a': 'audio/mp4',
29
+ '.aac': 'audio/aac',
30
+ '.flac': 'audio/flac',
31
+ '.ogg': 'audio/ogg',
32
+ '.pdf': 'application/pdf',
33
+ '.txt': 'text/plain',
34
+ '.md': 'text/markdown',
35
+ '.json': 'application/json',
36
+ '.csv': 'text/csv',
37
+ };
38
+ const FALLBACK_LIMITS = {
39
+ image: { bytes: 2 * 1024 * 1024 * 1024, label: '2GB' },
40
+ video: { bytes: 2 * 1024 * 1024 * 1024, label: '2GB' },
41
+ audio: { bytes: 2 * 1024 * 1024 * 1024, label: '2GB' },
42
+ document: { bytes: 2 * 1024 * 1024 * 1024, label: '2GB' },
43
+ };
44
+ export function contentTypeFor(path) {
45
+ return CONTENT_TYPES[extname(path).toLowerCase()] ?? 'application/octet-stream';
46
+ }
47
+ export function kindFor(contentType) {
48
+ if (contentType.startsWith('image/'))
49
+ return 'image';
50
+ if (contentType.startsWith('video/'))
51
+ return 'video';
52
+ if (contentType.startsWith('audio/'))
53
+ return 'audio';
54
+ return 'document';
55
+ }
56
+ export function limitsFromIndex(wire) {
57
+ const source = (wire && typeof wire === 'object' ? wire : {});
58
+ const out = { ...FALLBACK_LIMITS };
59
+ for (const kind of Object.keys(FALLBACK_LIMITS)) {
60
+ const entry = source[kind];
61
+ const bytes = entry?.max_bytes;
62
+ const label = entry?.label;
63
+ if (typeof bytes === 'number' && bytes > 0) {
64
+ out[kind] = { bytes, label: typeof label === 'string' && label ? label : `${Math.round(bytes / 1048576)}MB` };
65
+ }
66
+ }
67
+ return out;
68
+ }
69
+ async function fetchLimits(client) {
70
+ try {
71
+ const data = (await client.get('/api/v1/tools', { schemas: 'false' }));
72
+ return limitsFromIndex(data.ingest_limits);
73
+ }
74
+ catch {
75
+ return FALLBACK_LIMITS;
76
+ }
77
+ }
78
+ async function expandPaths(paths) {
79
+ const files = [];
80
+ const skipped = [];
81
+ for (const path of paths) {
82
+ const full = resolve(path);
83
+ let info;
84
+ try {
85
+ info = await stat(full);
86
+ }
87
+ catch {
88
+ throw new Error(`No such file or folder: ${path}`);
89
+ }
90
+ if (info.isDirectory()) {
91
+ const entries = await readdir(full, { withFileTypes: true });
92
+ for (const entry of entries) {
93
+ if (entry.name.startsWith('.'))
94
+ continue;
95
+ if (entry.isFile())
96
+ files.push(join(full, entry.name));
97
+ else if (entry.isDirectory())
98
+ skipped.push(join(full, entry.name));
99
+ }
100
+ }
101
+ else {
102
+ files.push(full);
103
+ }
104
+ }
105
+ return { files, skipped };
106
+ }
107
+ async function uploadOne(client, path, opts) {
108
+ const info = await stat(path);
109
+ if (!info.isFile())
110
+ return { file: path, ok: false, error: 'Not a file' };
111
+ if (info.size === 0)
112
+ return { file: path, ok: false, error: 'File is empty' };
113
+ const fileName = basename(path);
114
+ const contentType = contentTypeFor(path);
115
+ const limit = opts.limits[kindFor(contentType)];
116
+ if (info.size > limit.bytes) {
117
+ return { file: path, ok: false, error: `Larger than the ${limit.label} limit for this type` };
118
+ }
119
+ const presigned = (await client.post('/api/v1/uploads', {
120
+ file_name: fileName,
121
+ content_type: contentType,
122
+ file_size: info.size,
123
+ }));
124
+ const put = await fetch(presigned.upload_url, {
125
+ method: 'PUT',
126
+ headers: {
127
+ 'content-type': contentType,
128
+ 'content-length': String(info.size),
129
+ 'user-agent': USER_AGENT,
130
+ },
131
+ body: Readable.toWeb(createReadStream(path)),
132
+ duplex: 'half',
133
+ });
134
+ if (!put.ok) {
135
+ return { file: path, ok: false, error: `Storage rejected the file (${put.status})` };
136
+ }
137
+ const confirmed = (await client.post('/api/v1/uploads/confirm', {
138
+ r2_key: presigned.r2_key,
139
+ file_name: fileName,
140
+ file_size: info.size,
141
+ content_type: contentType,
142
+ enrich: opts.enrich,
143
+ ...(opts.enrich ? { on_servers: true } : {}),
144
+ ...(opts.description ? { description: opts.description } : {}),
145
+ }));
146
+ return { file: path, ok: true, item: confirmed.upload_id, type: confirmed.type };
147
+ }
148
+ export async function upload(argv, connection, mode) {
149
+ if (argv.paths.length === 0)
150
+ throw new Error('Which files? `eversince upload ./shot.png` or a folder.');
151
+ const { files, skipped } = await expandPaths(argv.paths);
152
+ if (files.length === 0)
153
+ throw new Error('Nothing to upload — no files in what you gave me.');
154
+ if (skipped.length && !mode.json) {
155
+ note(`Left ${skipped.length} nested folder${skipped.length === 1 ? '' : 's'} alone — name one to upload it.`);
156
+ }
157
+ const client = await Client.create(connection);
158
+ const limits = await fetchLimits(client);
159
+ const results = [];
160
+ const limit = Math.max(1, Math.min(argv.concurrency ?? 3, 8));
161
+ let cursor = 0;
162
+ let done = 0;
163
+ async function worker() {
164
+ for (;;) {
165
+ const index = cursor++;
166
+ const path = files[index];
167
+ if (!path)
168
+ return;
169
+ try {
170
+ results[index] = await uploadOne(client, path, {
171
+ enrich: argv.enrich === true,
172
+ description: argv.describe,
173
+ limits,
174
+ });
175
+ }
176
+ catch (error) {
177
+ const message = error instanceof ApiError ? error.body.message : error instanceof Error ? error.message : String(error);
178
+ results[index] = { file: path, ok: false, error: message };
179
+ }
180
+ done += 1;
181
+ if (!mode.json)
182
+ note(`[${done}/${files.length}] ${basename(path)}`);
183
+ }
184
+ }
185
+ await Promise.all(Array.from({ length: Math.min(limit, files.length) }, worker));
186
+ const uploaded = results.filter((r) => r?.ok);
187
+ const failed = results.filter((r) => r && !r.ok);
188
+ printResult(mode, { uploaded, failed, skipped_folders: skipped }, () => {
189
+ for (const result of results) {
190
+ if (!result)
191
+ continue;
192
+ line(result.ok
193
+ ? `${result.item} ${result.type} ${basename(result.file)}`
194
+ : `failed ${basename(result.file)} — ${result.error}`);
195
+ }
196
+ line();
197
+ line(`${uploaded.length} uploaded${failed.length ? `, ${failed.length} failed` : ''}.`);
198
+ });
199
+ if (failed.length)
200
+ process.exitCode = 1;
201
+ }
@@ -0,0 +1,51 @@
1
+ import { Client } from '../client.js';
2
+ import { resolveBaseUrl, resolveWorkspace, setWorkspaceFor, hostOf } from '../config.js';
3
+ import { line, note, pad, printResult } from '../output.js';
4
+ async function list(client) {
5
+ const data = (await client.tool('list_workspaces', {}));
6
+ return data.workspaces ?? [];
7
+ }
8
+ export async function workspace(argv, connection, mode) {
9
+ const baseUrl = await resolveBaseUrl(connection.baseUrl);
10
+ const action = argv.action ?? 'list';
11
+ if (action === 'clear') {
12
+ await setWorkspaceFor(baseUrl, null);
13
+ printResult(mode, { workspace: null }, () => line('Using the account default workspace.'));
14
+ return;
15
+ }
16
+ const client = await Client.create({ ...connection, baseUrl });
17
+ if (action === 'use') {
18
+ if (!argv.target)
19
+ throw new Error('Which workspace? `eversince workspace use <name|id>`');
20
+ if (client.authKind === 'api_key') {
21
+ throw new Error('This API key is locked to one workspace. Sign in with `eversince login` to switch, or use a key from the workspace you want.');
22
+ }
23
+ const workspaces = await list(client);
24
+ const wanted = argv.target.trim().toLowerCase();
25
+ const match = workspaces.find((w) => w.id === argv.target.trim()) ??
26
+ workspaces.find((w) => (w.name ?? '').trim().toLowerCase() === wanted);
27
+ if (!match) {
28
+ throw new Error(`No workspace called "${argv.target}". \`eversince workspace\` lists what this account can reach.`);
29
+ }
30
+ await setWorkspaceFor(baseUrl, match.id);
31
+ printResult(mode, { workspace: match }, () => {
32
+ line(`Now working in ${match.name}.`);
33
+ note('This applies to the CLI only — connected apps keep the workspace they were on.');
34
+ });
35
+ return;
36
+ }
37
+ const [workspaces, current] = await Promise.all([list(client), resolveWorkspace(baseUrl, connection.workspace)]);
38
+ printResult(mode, { workspaces, current: current ?? null }, () => {
39
+ if (workspaces.length === 0) {
40
+ line('No workspaces on this account.');
41
+ return;
42
+ }
43
+ const width = Math.max(...workspaces.map((w) => (w.name ?? '').length)) + 2;
44
+ for (const w of workspaces) {
45
+ const marker = current === w.id ? '*' : ' ';
46
+ line(`${marker} ${pad(w.name ?? '(unnamed)', width)}${w.id}`);
47
+ }
48
+ if (!current)
49
+ note(`\nNo CLI workspace set for ${hostOf(baseUrl)} — using the account default.`);
50
+ });
51
+ }
package/dist/config.js ADDED
@@ -0,0 +1,61 @@
1
+ import { join } from 'node:path';
2
+ import { mkdir, readFile, writeFile } from 'node:fs/promises';
3
+ import { stateDir } from './auth/store.js';
4
+ export const DEFAULT_BASE_URL = 'https://eversince.ai';
5
+ export function settingsPath() {
6
+ return join(stateDir(), 'settings.json');
7
+ }
8
+ export async function readSettings() {
9
+ try {
10
+ const raw = await readFile(settingsPath(), 'utf8');
11
+ const parsed = JSON.parse(raw);
12
+ return parsed && typeof parsed === 'object' ? parsed : {};
13
+ }
14
+ catch {
15
+ return {};
16
+ }
17
+ }
18
+ export async function writeSettings(next) {
19
+ await mkdir(stateDir(), { recursive: true, mode: 0o700 });
20
+ const current = await readSettings();
21
+ await writeFile(settingsPath(), `${JSON.stringify({ ...current, ...next }, null, 2)}\n`, { mode: 0o600 });
22
+ }
23
+ export function normalizeBaseUrl(value) {
24
+ const withScheme = /^https?:\/\//i.test(value) ? value : `https://${value}`;
25
+ return withScheme.replace(/\/+$/, '');
26
+ }
27
+ export async function resolveBaseUrl(override) {
28
+ if (override)
29
+ return normalizeBaseUrl(override);
30
+ const fromEnv = process.env.ES_BASE_URL?.trim();
31
+ if (fromEnv)
32
+ return normalizeBaseUrl(fromEnv);
33
+ const settings = await readSettings();
34
+ return normalizeBaseUrl(settings.baseUrl ?? DEFAULT_BASE_URL);
35
+ }
36
+ export async function resolveWorkspace(baseUrl, override) {
37
+ if (override)
38
+ return override;
39
+ const fromEnv = process.env.ES_WORKSPACE?.trim();
40
+ if (fromEnv)
41
+ return fromEnv;
42
+ const settings = await readSettings();
43
+ return settings.workspaces?.[hostOf(baseUrl)];
44
+ }
45
+ export async function setWorkspaceFor(baseUrl, workspaceId) {
46
+ const settings = await readSettings();
47
+ const workspaces = { ...(settings.workspaces ?? {}) };
48
+ if (workspaceId)
49
+ workspaces[hostOf(baseUrl)] = workspaceId;
50
+ else
51
+ delete workspaces[hostOf(baseUrl)];
52
+ await writeSettings({ workspaces });
53
+ }
54
+ export function hostOf(baseUrl) {
55
+ try {
56
+ return new URL(baseUrl).host;
57
+ }
58
+ catch {
59
+ return baseUrl;
60
+ }
61
+ }
package/dist/door.js ADDED
@@ -0,0 +1,124 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { createHmac, randomBytes, timingSafeEqual } from 'node:crypto';
3
+ import { existsSync, readFileSync } from 'node:fs';
4
+ import { homedir } from 'node:os';
5
+ import { dirname, join } from 'node:path';
6
+ export const START_WAIT_MS = 45_000;
7
+ export function stateFile() {
8
+ if (process.env.ES_DESKTOP_STATE)
9
+ return process.env.ES_DESKTOP_STATE;
10
+ const home = homedir();
11
+ const dir = process.platform === 'darwin'
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');
17
+ }
18
+ export function cacheFile(file = stateFile()) {
19
+ return join(dirname(file), 'agent-door-cache.json');
20
+ }
21
+ export function readJson(file) {
22
+ try {
23
+ return JSON.parse(readFileSync(file, 'utf8'));
24
+ }
25
+ catch {
26
+ return null;
27
+ }
28
+ }
29
+ export function readState(file = stateFile()) {
30
+ const state = readJson(file);
31
+ return state && typeof state.port === 'number' && typeof state.app === 'string' ? state : null;
32
+ }
33
+ export class DoorBlocked extends Error {
34
+ constructor() {
35
+ super('This command runs in a sandbox that blocks connections to the Eversince app on this computer. '
36
+ + 'Allow network access for it, or run it outside the sandbox.');
37
+ this.name = 'DoorBlocked';
38
+ }
39
+ }
40
+ export function sandboxedWithoutNetwork() {
41
+ return process.env.CODEX_SANDBOX_NETWORK_DISABLED === '1';
42
+ }
43
+ function errorCode(error) {
44
+ const e = error;
45
+ const code = e?.cause?.code ?? e?.code;
46
+ return typeof code === 'string' ? code : undefined;
47
+ }
48
+ export function isRefused(error) {
49
+ const code = errorCode(error);
50
+ return code === 'ECONNREFUSED' || code === 'ECONNRESET';
51
+ }
52
+ export function isBlocked(error) {
53
+ const code = errorCode(error);
54
+ return code === 'EPERM' || code === 'EACCES';
55
+ }
56
+ export function proofFor(key, nonce) {
57
+ return createHmac('sha256', key).update(`eversince-door:${nonce}`).digest('hex');
58
+ }
59
+ export async function probe(state) {
60
+ if (sandboxedWithoutNetwork())
61
+ return 'blocked';
62
+ const nonce = randomBytes(16).toString('hex');
63
+ let body;
64
+ try {
65
+ const res = await fetch(`http://127.0.0.1:${state.port}/?nonce=${nonce}`, { signal: AbortSignal.timeout(3000) });
66
+ body = (await res.json().catch(() => null));
67
+ }
68
+ catch (error) {
69
+ if (isBlocked(error))
70
+ return 'blocked';
71
+ return 'closed';
72
+ }
73
+ if (!state.connectKey || typeof body?.proof !== 'string')
74
+ return 'stranger';
75
+ const expected = Buffer.from(proofFor(state.connectKey, nonce));
76
+ const given = Buffer.from(body.proof);
77
+ return expected.length === given.length && timingSafeEqual(expected, given) ? 'ours' : 'stranger';
78
+ }
79
+ export function launch(state) {
80
+ if (!existsSync(state.app))
81
+ return false;
82
+ const dev = state.launch && typeof state.launch === 'object' ? state.launch : null;
83
+ if (process.platform === 'darwin' && !dev) {
84
+ const bundle = state.app.replace(/\/Contents\/MacOS\/.*$/, '');
85
+ spawn('open', ['-a', bundle], { stdio: 'ignore', detached: true }).on('error', () => undefined).unref();
86
+ return true;
87
+ }
88
+ const env = { ...process.env, ...(dev?.env && typeof dev.env === 'object' ? dev.env : {}) };
89
+ delete env.ELECTRON_RUN_AS_NODE;
90
+ const args = Array.isArray(dev?.args) ? dev.args.filter((a) => typeof a === 'string') : [];
91
+ spawn(state.app, args, { stdio: 'ignore', detached: true, env }).on('error', () => undefined).unref();
92
+ return true;
93
+ }
94
+ export async function reachApp(file = stateFile(), onStart) {
95
+ const state = readState(file);
96
+ if (!state)
97
+ return null;
98
+ const first = await probe(state);
99
+ if (first === 'ours')
100
+ return state;
101
+ if (first === 'blocked')
102
+ throw new DoorBlocked();
103
+ onStart?.();
104
+ try {
105
+ if (!launch(state))
106
+ return null;
107
+ }
108
+ catch {
109
+ return null;
110
+ }
111
+ const until = Date.now() + START_WAIT_MS;
112
+ while (Date.now() < until) {
113
+ await new Promise((r) => setTimeout(r, 750));
114
+ const now = readState(file);
115
+ if (!now)
116
+ continue;
117
+ const seen = await probe(now);
118
+ if (seen === 'ours')
119
+ return now;
120
+ if (seen === 'blocked')
121
+ throw new DoorBlocked();
122
+ }
123
+ return null;
124
+ }
package/dist/index.js ADDED
@@ -0,0 +1,193 @@
1
+ #!/usr/bin/env node
2
+ import { parseArgs } from 'node:util';
3
+ import { login, logout, status } from './commands/auth.js';
4
+ import { workspace } from './commands/workspace.js';
5
+ import { tools } from './commands/tools.js';
6
+ import { run } from './commands/run.js';
7
+ import { upload } from './commands/upload.js';
8
+ import { download } from './commands/download.js';
9
+ import { jobs } from './commands/jobs.js';
10
+ import { init, APP_AGENTS } from './commands/init.js';
11
+ import { runBridge } from './bridge.js';
12
+ import { fail, line } from './output.js';
13
+ import { VERSION } from './version.js';
14
+ const USAGE = `eversince — your workspace, from the command line
15
+
16
+ Getting set up
17
+ eversince login sign in through the browser
18
+ eversince login --key es_live_… or with an API key (CI, no browser)
19
+ eversince logout
20
+ eversince status
21
+ eversince init connect the agents on this machine
22
+ eversince init --agent codex connect one agent (claude-code, codex,
23
+ cursor, vscode, claude-desktop, other)
24
+ eversince mcp --agent <agent> the desktop app as a stdio MCP server;
25
+ init writes this into the agent's settings
26
+
27
+ Working
28
+ eversince tools [name] what this workspace can do, live
29
+ eversince run <tool> '<json>' call any tool (--wait to follow async work)
30
+ eversince run <tool> - arguments from stdin
31
+ eversince upload <files|folder> local files into the library
32
+ eversince download <refs…> library items onto disk
33
+ eversince jobs <ids…> check async work (--wait to follow)
34
+ eversince jobs cancel <ids…>
35
+ eversince workspace [use <name>] which workspace the CLI acts in
36
+
37
+ Options
38
+ --json machine-readable output, on success and failure
39
+ --wait follow async work to completion
40
+ --timeout <seconds> ceiling on a request, and on --wait (default 1800)
41
+ --out <dir> where downloads land
42
+ --describe <text> description for an upload
43
+ --enrich describe and tag each image upload
44
+ --concurrency <n> parallel uploads (default 3, max 8)
45
+ --workspace <id> act in this workspace, this once
46
+ --cloud use eversince.ai even with the desktop app here
47
+ --base-url <url> point at another deployment
48
+ --debug print each request and response
49
+ --json / -h / -v
50
+
51
+ Environment
52
+ ES_API_KEY use this key instead of the stored credential
53
+ ES_WORKSPACE workspace for this shell
54
+ ES_BASE_URL deployment for this shell
55
+ ES_DEBUG=1 same as --debug
56
+
57
+ With the Eversince desktop app on this computer, commands go through it and
58
+ the work it does is free, and init connects agents through it rather than
59
+ eversince.ai. The app opens if it is closed. --cloud, --base-url, --workspace,
60
+ ES_API_KEY or ES_BASE_URL keep a command on the cloud, which needs
61
+ eversince login.
62
+
63
+ Credentials are stored per deployment, in the system keychain where there is
64
+ one. The CLI's sign-in is its own: connecting or disconnecting an agent's MCP
65
+ connection leaves it alone, and signing out here leaves the agent working.
66
+ `;
67
+ function toNumber(value, name) {
68
+ if (value === undefined)
69
+ return undefined;
70
+ const parsed = Number(value);
71
+ if (!Number.isFinite(parsed))
72
+ throw new Error(`--${name} must be a number.`);
73
+ return parsed;
74
+ }
75
+ const OPTIONS = {
76
+ json: { type: 'boolean', default: false },
77
+ key: { type: 'string' },
78
+ 'base-url': { type: 'string' },
79
+ cloud: { type: 'boolean', default: false },
80
+ workspace: { type: 'string' },
81
+ out: { type: 'string', short: 'o' },
82
+ schemas: { type: 'boolean', default: false },
83
+ annotation: { type: 'string' },
84
+ describe: { type: 'string' },
85
+ concurrency: { type: 'string' },
86
+ enrich: { type: 'boolean', default: false },
87
+ 'no-enrich': { type: 'boolean', default: false },
88
+ wait: { type: 'boolean', default: false },
89
+ timeout: { type: 'string' },
90
+ 'idempotency-key': { type: 'string' },
91
+ 'no-browser': { type: 'boolean', default: false },
92
+ scope: { type: 'string' },
93
+ agent: { type: 'string' },
94
+ connection: { type: 'string' },
95
+ 'no-mcp': { type: 'boolean', default: false },
96
+ 'no-skills': { type: 'boolean', default: false },
97
+ force: { type: 'boolean', default: false },
98
+ 'dry-run': { type: 'boolean', default: false },
99
+ debug: { type: 'boolean', default: false },
100
+ help: { type: 'boolean', short: 'h', default: false },
101
+ version: { type: 'boolean', short: 'v', default: false },
102
+ };
103
+ function parse(argv) {
104
+ try {
105
+ return parseArgs({ args: argv, allowPositionals: true, strict: true, options: OPTIONS });
106
+ }
107
+ catch (error) {
108
+ const message = (error instanceof Error ? error.message : String(error))
109
+ .replace(/\. To specify a positional[\s\S]*$/, '')
110
+ .replace(/\.$/, '');
111
+ throw new Error(`${message}. Run \`eversince help\` for the options.`);
112
+ }
113
+ }
114
+ async function main() {
115
+ const { values, positionals } = parse(process.argv.slice(2));
116
+ const mode = { json: values.json };
117
+ const [command, ...rest] = positionals;
118
+ if (values.version) {
119
+ line(VERSION);
120
+ return;
121
+ }
122
+ if (values.help || !command || command === 'help') {
123
+ process.stdout.write(USAGE);
124
+ return;
125
+ }
126
+ if (values.debug)
127
+ process.env.ES_DEBUG = '1';
128
+ const timeout = toNumber(values.timeout, 'timeout');
129
+ const connection = {
130
+ baseUrl: values['base-url'],
131
+ workspace: values.workspace,
132
+ timeout,
133
+ cloud: values.cloud,
134
+ };
135
+ try {
136
+ switch (command) {
137
+ case 'login':
138
+ return await login({ key: values.key, noBrowser: values['no-browser'] }, connection, mode);
139
+ case 'logout':
140
+ return await logout(connection, mode);
141
+ case 'status':
142
+ return await status(connection, mode);
143
+ case 'workspace':
144
+ return await workspace({ action: rest[0], target: rest[1] }, connection, mode);
145
+ case 'tools':
146
+ return await tools({ name: rest[0], schemas: values.schemas, annotation: values.annotation }, connection, mode);
147
+ case 'run':
148
+ return await run({
149
+ name: rest[0],
150
+ input: rest[1],
151
+ wait: values.wait,
152
+ timeout,
153
+ idempotencyKey: values['idempotency-key'],
154
+ }, connection, mode);
155
+ case 'upload':
156
+ return await upload({
157
+ paths: rest,
158
+ enrich: values.enrich && !values['no-enrich'],
159
+ describe: values.describe,
160
+ concurrency: toNumber(values.concurrency, 'concurrency'),
161
+ }, connection, mode);
162
+ case 'download':
163
+ return await download({ refs: rest, out: values.out }, connection, mode);
164
+ case 'jobs':
165
+ return rest[0] === 'cancel'
166
+ ? await jobs({ action: 'cancel', ids: rest.slice(1) }, connection, mode)
167
+ : await jobs({ ids: rest, wait: values.wait, timeout }, connection, mode);
168
+ case 'mcp': {
169
+ const agent = values.agent;
170
+ if (!agent || !APP_AGENTS.includes(agent)) {
171
+ throw new Error(`eversince mcp needs --agent, one of ${APP_AGENTS.join(', ')}.`);
172
+ }
173
+ runBridge({ agent, connectionId: values.connection });
174
+ return;
175
+ }
176
+ case 'init':
177
+ return await init({
178
+ scope: values.scope,
179
+ mcp: !values['no-mcp'],
180
+ skills: !values['no-skills'],
181
+ force: values.force,
182
+ dryRun: values['dry-run'],
183
+ agent: values.agent,
184
+ }, connection, mode);
185
+ default:
186
+ throw new Error(`Unknown command "${command}". Run \`eversince help\`.`);
187
+ }
188
+ }
189
+ catch (error) {
190
+ fail(mode, error);
191
+ }
192
+ }
193
+ main().catch((error) => fail({ json: process.argv.includes('--json') }, error));