robot-resources 1.15.1 → 1.15.3
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/package.json +7 -49
- package/README.md +0 -104
- package/bin/setup.js +0 -43
- package/lib/auth.mjs +0 -261
- package/lib/config.mjs +0 -55
- package/lib/detect.js +0 -254
- package/lib/health-report.js +0 -130
- package/lib/install-node-shim.js +0 -188
- package/lib/install-python-shim.js +0 -107
- package/lib/install-router-files.js +0 -48
- package/lib/json5.js +0 -16
- package/lib/login.mjs +0 -54
- package/lib/machine-id.js +0 -31
- package/lib/non-oc-wizard.js +0 -615
- package/lib/shell-config.js +0 -183
- package/lib/source-edit-attach.js +0 -469
- package/lib/tool-config.js +0 -504
- package/lib/ui.js +0 -87
- package/lib/uninstall.js +0 -204
- package/lib/venv-detect.js +0 -85
- package/lib/windows-env.js +0 -202
- package/lib/wizard.js +0 -523
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, copyFileSync, cpSync, rmSync } from 'node:fs';
|
|
2
|
-
import { homedir } from 'node:os';
|
|
3
|
-
import { join, dirname } from 'node:path';
|
|
4
|
-
import { createRequire } from 'node:module';
|
|
5
|
-
|
|
6
|
-
const require = createRequire(import.meta.url);
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Copy `@robot-resources/router` to ~/.robot-resources/router/ and return
|
|
10
|
-
* the absolute path to its auto.cjs.
|
|
11
|
-
*
|
|
12
|
-
* Phase 8 fix. Mirrors `installPluginFiles()` in tool-config.js (the OC
|
|
13
|
-
* plugin path that's worked since Phase 0). The destination is a stable
|
|
14
|
-
* user-scoped location that survives npm/npx cache cleanups, so the
|
|
15
|
-
* NODE_OPTIONS line we write to shell rc doesn't break when caches expire.
|
|
16
|
-
*
|
|
17
|
-
* Files copied: auto.cjs, index.js, package.json, lib/ (recursive).
|
|
18
|
-
* Each call wipes lib/ first so files removed in newer router versions
|
|
19
|
-
* don't linger from a previous install.
|
|
20
|
-
*
|
|
21
|
-
* Why this is its own module: extracted from install-node-shim.js for
|
|
22
|
-
* testability — vitest can mock the whole module without us mocking
|
|
23
|
-
* node:fs / node:module manually in every install-shim test case.
|
|
24
|
-
*/
|
|
25
|
-
export function installRouterFiles({ home = homedir() } = {}) {
|
|
26
|
-
const pkgPath = require.resolve('@robot-resources/router/package.json');
|
|
27
|
-
const pkgDir = dirname(pkgPath);
|
|
28
|
-
const targetDir = join(home, '.robot-resources', 'router');
|
|
29
|
-
mkdirSync(targetDir, { recursive: true });
|
|
30
|
-
|
|
31
|
-
for (const file of ['auto.cjs', 'index.js', 'package.json']) {
|
|
32
|
-
const src = join(pkgDir, file);
|
|
33
|
-
if (existsSync(src)) {
|
|
34
|
-
copyFileSync(src, join(targetDir, file));
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Refresh lib/ — wipe + recopy so we don't accumulate stale files across
|
|
39
|
-
// router upgrades. Same pattern as tool-config.js installPluginFiles().
|
|
40
|
-
const srcLib = join(pkgDir, 'lib');
|
|
41
|
-
const dstLib = join(targetDir, 'lib');
|
|
42
|
-
if (existsSync(srcLib)) {
|
|
43
|
-
rmSync(dstLib, { recursive: true, force: true });
|
|
44
|
-
cpSync(srcLib, dstLib, { recursive: true });
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return join(targetDir, 'auto.cjs');
|
|
48
|
-
}
|
package/lib/json5.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Strip JSON5 features (comments + trailing commas) to produce valid JSON.
|
|
3
|
-
*
|
|
4
|
-
* Handles single-line comments (//), multi-line comments, and trailing
|
|
5
|
-
* commas before } or ]. Preserves // inside quoted strings (e.g. URLs).
|
|
6
|
-
*
|
|
7
|
-
* Does NOT handle: unquoted keys, hex numbers, or backtick templates.
|
|
8
|
-
* These are valid JSON5 but uncommon in OpenClaw configs.
|
|
9
|
-
*/
|
|
10
|
-
export function stripJson5(text) {
|
|
11
|
-
const clean = text.replace(
|
|
12
|
-
/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\/\/.*$|\/\*[\s\S]*?\*\//gm,
|
|
13
|
-
(match) => (match.startsWith('"') || match.startsWith("'") ? match : ''),
|
|
14
|
-
);
|
|
15
|
-
return clean.replace(/,\s*([\]}])/g, '$1');
|
|
16
|
-
}
|
package/lib/login.mjs
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { authenticate } from './auth.mjs';
|
|
2
|
-
import { writeConfig, getConfigPath } from './config.mjs';
|
|
3
|
-
|
|
4
|
-
const PLATFORM_URL = process.env.RR_PLATFORM_URL || 'https://api.robotresources.ai';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Generate an API key via the platform API.
|
|
8
|
-
*/
|
|
9
|
-
export async function createApiKey(accessToken) {
|
|
10
|
-
const res = await fetch(`${PLATFORM_URL}/v1/keys`, {
|
|
11
|
-
method: 'POST',
|
|
12
|
-
headers: {
|
|
13
|
-
'Content-Type': 'application/json',
|
|
14
|
-
Authorization: `Bearer ${accessToken}`,
|
|
15
|
-
},
|
|
16
|
-
body: JSON.stringify({ name: `cli-${new Date().toISOString().slice(0, 10)}` }),
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
if (!res.ok) {
|
|
20
|
-
const body = await res.text();
|
|
21
|
-
throw new Error(`Failed to create API key (${res.status}): ${body}`);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const { data } = await res.json();
|
|
25
|
-
return data;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export async function login() {
|
|
29
|
-
console.log('\n ██ Robot Resources — Login\n');
|
|
30
|
-
console.log(' Opening GitHub in your browser...');
|
|
31
|
-
|
|
32
|
-
try {
|
|
33
|
-
const { access_token, user } = await authenticate();
|
|
34
|
-
|
|
35
|
-
console.log(` ✓ Authenticated as ${user.user_metadata?.user_name || user.email}`);
|
|
36
|
-
console.log(' Generating API key...');
|
|
37
|
-
|
|
38
|
-
const key = await createApiKey(access_token);
|
|
39
|
-
|
|
40
|
-
writeConfig({
|
|
41
|
-
api_key: key.key,
|
|
42
|
-
key_id: key.id,
|
|
43
|
-
key_name: key.name,
|
|
44
|
-
user_email: user.email,
|
|
45
|
-
user_name: user.user_metadata?.user_name || null,
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
console.log(` ✓ API key saved to ${getConfigPath()}`);
|
|
49
|
-
console.log(`\n You're all set. Router and Scraper will pick up the key automatically.\n`);
|
|
50
|
-
} catch (err) {
|
|
51
|
-
console.error(`\n ✗ Login failed: ${err.message}\n`);
|
|
52
|
-
process.exit(1);
|
|
53
|
-
}
|
|
54
|
-
}
|
package/lib/machine-id.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { readFileSync, writeFileSync, mkdirSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { homedir } from 'node:os';
|
|
4
|
-
import { randomUUID } from 'node:crypto';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Reads or creates a persistent machine identifier.
|
|
8
|
-
* Used for telemetry deduplication across sessions.
|
|
9
|
-
*
|
|
10
|
-
* @param {string} [configDir] - Directory to store .machine-id (defaults to ~/.robot-resources)
|
|
11
|
-
* @returns {string} A UUID v4 machine identifier
|
|
12
|
-
*/
|
|
13
|
-
export function getOrCreateMachineId(configDir) {
|
|
14
|
-
const dir = configDir ?? join(homedir(), '.robot-resources');
|
|
15
|
-
const machineIdPath = join(dir, '.machine-id');
|
|
16
|
-
|
|
17
|
-
try {
|
|
18
|
-
const stored = readFileSync(machineIdPath, 'utf-8').trim();
|
|
19
|
-
if (stored) return stored;
|
|
20
|
-
} catch {
|
|
21
|
-
// File doesn't exist or can't be read — fall through to generate
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const machineId = randomUUID();
|
|
25
|
-
try {
|
|
26
|
-
mkdirSync(dir, { recursive: true });
|
|
27
|
-
writeFileSync(machineIdPath, machineId, 'utf-8');
|
|
28
|
-
} catch { /* non-fatal */ }
|
|
29
|
-
|
|
30
|
-
return machineId;
|
|
31
|
-
}
|