tesseract-agent 0.11.13 → 0.11.14
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,57 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Run the bundled CLI with the APP's node_modules behind it.
|
|
4
|
+
*
|
|
5
|
+
* The CLI bundle leaves its heavy dependencies external — the agent SDK, node-pty, mesh-core
|
|
6
|
+
* (esbuild.mjs). An npm install puts them in a node_modules beside cli.js. The desktop app ships
|
|
7
|
+
* cli.js under Resources/cli, and those packages live inside app.asar instead, beside nothing
|
|
8
|
+
* cli.js can see. So the packaged `ts` and `tm` died on their first import:
|
|
9
|
+
*
|
|
10
|
+
* Cannot find package '@anthropic-ai/claude-agent-sdk' imported from …/Resources/cli/cli.js
|
|
11
|
+
*
|
|
12
|
+
* — on every install, for every command, including ones that never touch the SDK.
|
|
13
|
+
*
|
|
14
|
+
* This launcher retries a failed BARE import from inside the app's own node_modules, and changes
|
|
15
|
+
* nothing else: a package that resolves normally still does, and one that exists nowhere still
|
|
16
|
+
* fails exactly as before. Where there is no app beside it (an npm install), it registers nothing
|
|
17
|
+
* and simply runs cli.js.
|
|
18
|
+
*/
|
|
19
|
+
import { registerHooks, createRequire } from 'node:module';
|
|
20
|
+
import { dirname, join } from 'node:path';
|
|
21
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
22
|
+
import { existsSync } from 'node:fs';
|
|
23
|
+
|
|
24
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
25
|
+
// Overrides exist for the test; the shipped layout needs neither.
|
|
26
|
+
const cliJs = process.env.TESSERACT_CLI_JS || join(here, 'cli.js');
|
|
27
|
+
const appRoot = process.env.TESSERACT_APP_ROOT || join(dirname(cliJs), '..', 'app.asar');
|
|
28
|
+
|
|
29
|
+
if (typeof registerHooks === 'function' && existsSync(appRoot)) {
|
|
30
|
+
// A file inside the app's node_modules: resolution only uses its location, it need not exist.
|
|
31
|
+
const anchor = join(appRoot, 'node_modules', '.tesseract-cli-anchor.js');
|
|
32
|
+
const appRequire = createRequire(anchor);
|
|
33
|
+
const isBare = (s) => !s.startsWith('.') && !s.startsWith('/') && !/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(s) && !/^[a-zA-Z]:[\\/]/.test(s);
|
|
34
|
+
const missing = (e) => e && (e.code === 'ERR_MODULE_NOT_FOUND' || e.code === 'MODULE_NOT_FOUND');
|
|
35
|
+
// createRequire().resolve() RUNS the registered hooks, this one included. Without this guard the
|
|
36
|
+
// CommonJS retry re-enters itself (measured in the patch channel's module overlay).
|
|
37
|
+
let nested = false;
|
|
38
|
+
registerHooks({
|
|
39
|
+
resolve(specifier, context, next) {
|
|
40
|
+
if (nested) return next(specifier, context);
|
|
41
|
+
try {
|
|
42
|
+
return next(specifier, context);
|
|
43
|
+
} catch (e) {
|
|
44
|
+
if (!isBare(specifier) || !missing(e)) throw e;
|
|
45
|
+
const c = context.conditions;
|
|
46
|
+
const cjs = Array.isArray(c) ? c.includes('require') : !!(c && c.has && c.has('require'));
|
|
47
|
+
if (cjs) {
|
|
48
|
+
nested = true;
|
|
49
|
+
try { return { url: pathToFileURL(appRequire.resolve(specifier)).href, shortCircuit: true }; } finally { nested = false; }
|
|
50
|
+
}
|
|
51
|
+
return next(specifier, { ...context, parentURL: pathToFileURL(anchor).href });
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
await import(pathToFileURL(cliJs).href);
|
|
@@ -150,6 +150,17 @@ if (existsSync(netdOut) && statSync(netdOut).size > 0) {
|
|
|
150
150
|
// permission error naming the binary, which reads as a corrupt download.
|
|
151
151
|
if (process.platform !== 'win32') chmodSync(netdOut, 0o755);
|
|
152
152
|
console.log(`[mesh-core] fetched ${what}`);
|
|
153
|
+
// ITS UPDATE SIGNATURE, beside it. An installed helper replaces itself only with a build whose
|
|
154
|
+
// .sig verifies (crates/tsmesh-netd/src/update.rs), so without this a CLI upgrade leaves the
|
|
155
|
+
// installed helper where it was. Optional: a release older than signing has none, and the
|
|
156
|
+
// helper then updates the old way — reinstalled, with a prompt. Not checked against a .sha256:
|
|
157
|
+
// the signature IS the integrity check, made by the helper that trusts nothing else.
|
|
158
|
+
try {
|
|
159
|
+
await fetchTo(`${base}/${netdAsset}.sig`, `${netdOut}.sig`);
|
|
160
|
+
console.log(`[mesh-core] fetched ${netdAsset}.sig`);
|
|
161
|
+
} catch {
|
|
162
|
+
rmSync(`${netdOut}.sig`, { force: true });
|
|
163
|
+
}
|
|
153
164
|
// WINTUN, and only on Windows. `tun-rs` does not link it — it LoadLibrary's `wintun.dll`
|
|
154
165
|
// from the helper's OWN directory at runtime — so a netd.exe without it fails with
|
|
155
166
|
// `open tun: LoadLibraryExW failed` and the machine carries no packets. It is fetched
|
|
@@ -161,6 +172,7 @@ if (existsSync(netdOut) && statSync(netdOut).size > 0) {
|
|
|
161
172
|
}
|
|
162
173
|
} catch (e) {
|
|
163
174
|
rmSync(netdOut, { force: true });
|
|
175
|
+
rmSync(`${netdOut}.sig`, { force: true });
|
|
164
176
|
// Remove the DLL too. Half a helper on disk is worse than none: `netdBinaryPath()` would
|
|
165
177
|
// find the exe and the installer would register a service that cannot open a device.
|
|
166
178
|
rmSync(join(outDir, 'netd', 'wintun.dll'), { force: true });
|