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.
- package/LICENSE +202 -0
- package/NOTICE +9 -0
- package/README.md +187 -0
- package/dist/auth/oauth.js +209 -0
- package/dist/auth/store.js +100 -0
- package/dist/bridge.js +198 -0
- package/dist/client.js +224 -0
- package/dist/commands/auth.js +139 -0
- package/dist/commands/download.js +80 -0
- package/dist/commands/init.js +337 -0
- package/dist/commands/jobs.js +68 -0
- package/dist/commands/run.js +71 -0
- package/dist/commands/tools.js +36 -0
- package/dist/commands/upload.js +201 -0
- package/dist/commands/workspace.js +51 -0
- package/dist/config.js +61 -0
- package/dist/door.js +124 -0
- package/dist/index.js +193 -0
- package/dist/local.js +84 -0
- package/dist/output.js +33 -0
- package/dist/version.js +15 -0
- package/package.json +42 -0
package/dist/local.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { existsSync, realpathSync } from 'node:fs';
|
|
2
|
+
import { delimiter, join } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { DoorBlocked, probe, reachApp, readState } from './door.js';
|
|
5
|
+
export function desktopInstalled() {
|
|
6
|
+
const state = readState();
|
|
7
|
+
const installed = !!state && existsSync(state.app);
|
|
8
|
+
return { installed, canConnect: installed && typeof state?.connectKey === 'string' };
|
|
9
|
+
}
|
|
10
|
+
export function cliLauncher() {
|
|
11
|
+
const script = realpathSync(fileURLToPath(new URL('./index.js', import.meta.url)));
|
|
12
|
+
let node = process.execPath;
|
|
13
|
+
const names = process.platform === 'win32' ? ['node.exe'] : ['node'];
|
|
14
|
+
for (const dir of (process.env.PATH ?? '').split(delimiter)) {
|
|
15
|
+
if (!dir)
|
|
16
|
+
continue;
|
|
17
|
+
for (const name of names) {
|
|
18
|
+
const candidate = join(dir, name);
|
|
19
|
+
try {
|
|
20
|
+
if (existsSync(candidate) && realpathSync(candidate) === realpathSync(process.execPath)) {
|
|
21
|
+
node = candidate;
|
|
22
|
+
return { node, script };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return { node, script };
|
|
30
|
+
}
|
|
31
|
+
export function launchedFromTemporaryCopy() {
|
|
32
|
+
return /[\\/]_npx[\\/]/.test(cliLauncher().script);
|
|
33
|
+
}
|
|
34
|
+
export async function connectThroughApp(agent, extra = {}) {
|
|
35
|
+
const state = await reachApp();
|
|
36
|
+
if (!state?.connectKey)
|
|
37
|
+
throw new Error('The Eversince app on this computer did not open. Open it and try again, or run with --cloud.');
|
|
38
|
+
const res = await fetch(`http://127.0.0.1:${state.port}/connect`, {
|
|
39
|
+
method: 'POST',
|
|
40
|
+
headers: { authorization: `Bearer ${state.connectKey}`, 'content-type': 'application/json' },
|
|
41
|
+
body: JSON.stringify({ agent, ...extra }),
|
|
42
|
+
});
|
|
43
|
+
const payload = (await res.json().catch(() => null));
|
|
44
|
+
if (!res.ok || !payload?.data) {
|
|
45
|
+
throw new Error(payload?.error?.message ?? `The Eversince app refused to connect ${agent} (${res.status}).`);
|
|
46
|
+
}
|
|
47
|
+
return payload.data;
|
|
48
|
+
}
|
|
49
|
+
async function connect() {
|
|
50
|
+
const { token } = await connectThroughApp('cli');
|
|
51
|
+
if (typeof token !== 'string')
|
|
52
|
+
throw new Error('The Eversince app did not return a token for the CLI.');
|
|
53
|
+
return token;
|
|
54
|
+
}
|
|
55
|
+
export async function openApp(onStart) {
|
|
56
|
+
if (!(await reachApp(undefined, onStart))) {
|
|
57
|
+
throw new Error('The Eversince app on this computer did not open. Open it and try again, or run with --cloud.');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export async function localDoor(onStart) {
|
|
61
|
+
if (!desktopInstalled().canConnect)
|
|
62
|
+
return null;
|
|
63
|
+
const state = await reachApp(undefined, onStart);
|
|
64
|
+
if (!state)
|
|
65
|
+
throw new Error('The Eversince app on this computer did not open. Open it and try again, or run with --cloud.');
|
|
66
|
+
const existing = state.connections?.find((c) => c?.agent === 'cli' && typeof c.token === 'string');
|
|
67
|
+
const token = typeof existing?.token === 'string' ? existing.token : await connect();
|
|
68
|
+
return {
|
|
69
|
+
baseUrl: `http://127.0.0.1:${state.port}`,
|
|
70
|
+
token,
|
|
71
|
+
reconnect: connect,
|
|
72
|
+
verify: async () => {
|
|
73
|
+
const now = readState();
|
|
74
|
+
if (now && (await probe(now)) === 'ours')
|
|
75
|
+
return `http://127.0.0.1:${now.port}`;
|
|
76
|
+
if (now && (await probe(now)) === 'blocked')
|
|
77
|
+
throw new DoorBlocked();
|
|
78
|
+
const opened = await reachApp(undefined, onStart);
|
|
79
|
+
if (!opened)
|
|
80
|
+
throw new Error('The Eversince app on this computer did not open. Open it and try again, or run with --cloud.');
|
|
81
|
+
return `http://127.0.0.1:${opened.port}`;
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
package/dist/output.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export function printResult(mode, value, human) {
|
|
2
|
+
if (mode.json) {
|
|
3
|
+
process.stdout.write(`${JSON.stringify({ ok: true, data: value })}\n`);
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
human();
|
|
7
|
+
}
|
|
8
|
+
export function line(text = '') {
|
|
9
|
+
process.stdout.write(`${text}\n`);
|
|
10
|
+
}
|
|
11
|
+
export function note(text) {
|
|
12
|
+
process.stderr.write(`${text}\n`);
|
|
13
|
+
}
|
|
14
|
+
export function fail(mode, error) {
|
|
15
|
+
const asApi = error && typeof error === 'object' && 'body' in error
|
|
16
|
+
? error
|
|
17
|
+
: null;
|
|
18
|
+
if (mode.json) {
|
|
19
|
+
const body = asApi?.body ?? { code: 'error', message: error instanceof Error ? error.message : String(error) };
|
|
20
|
+
process.stdout.write(`${JSON.stringify({ ok: false, error: body, ...(asApi?.requestId ? { request_id: asApi.requestId } : {}) })}\n`);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
|
|
24
|
+
if (asApi?.body.suggested_action)
|
|
25
|
+
process.stderr.write(`${asApi.body.suggested_action}\n`);
|
|
26
|
+
if (asApi?.requestId)
|
|
27
|
+
process.stderr.write(`request ${asApi.requestId}\n`);
|
|
28
|
+
}
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
export function pad(text, width) {
|
|
32
|
+
return text.length >= width ? text : text + ' '.repeat(width - text.length);
|
|
33
|
+
}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname, join } from 'node:path';
|
|
4
|
+
function read() {
|
|
5
|
+
try {
|
|
6
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
const pkg = JSON.parse(readFileSync(join(here, '..', 'package.json'), 'utf8'));
|
|
8
|
+
return pkg.version ?? '0.0.0';
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return '0.0.0';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export const VERSION = read();
|
|
15
|
+
export const USER_AGENT = `eversince-cli/${VERSION} (${process.platform}; node ${process.versions.node})`;
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "eversince",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Command-line access to your Eversince workspace — for agents and the people who run them.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"eversince": "dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE",
|
|
13
|
+
"NOTICE"
|
|
14
|
+
],
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=20"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "rm -rf dist && tsc -p tsconfig.json",
|
|
20
|
+
"dev": "tsc -p tsconfig.json --watch",
|
|
21
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
22
|
+
"test": "npm run build && node --test test/*.test.js",
|
|
23
|
+
"prepublishOnly": "npm run build && node --test test/*.test.js"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"eversince",
|
|
27
|
+
"cli",
|
|
28
|
+
"mcp",
|
|
29
|
+
"agents",
|
|
30
|
+
"media",
|
|
31
|
+
"creative"
|
|
32
|
+
],
|
|
33
|
+
"license": "Apache-2.0",
|
|
34
|
+
"homepage": "https://eversince.ai",
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://docs.eversince.ai"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/node": "^22.0.0",
|
|
40
|
+
"typescript": "^5.6.0"
|
|
41
|
+
}
|
|
42
|
+
}
|