realontext 0.7.0 → 0.8.1
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/.claude-plugin/plugin.json +1 -1
- package/README.md +13 -0
- package/bin/realontext.js +19 -9
- package/lib/binary.js +58 -6
- package/lib/mcp.js +153 -0
- package/lib/tui.mjs +1 -2
- package/lib/update.js +139 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -58,6 +58,19 @@ Without a Token nothing leaves the machine: the results come back in lexical
|
|
|
58
58
|
order, with a notice saying so. `REALONTEXT_TOKEN` overrides the saved Token;
|
|
59
59
|
set to an empty string, it turns jev off for that process.
|
|
60
60
|
|
|
61
|
+
## Updates
|
|
62
|
+
|
|
63
|
+
The binary keeps itself at the version the Relay names. In the background, at
|
|
64
|
+
most once an hour, `realontext` asks the Relay for it; a newer one is
|
|
65
|
+
downloaded from the npm registry (`npm_config_registry` if set), checked
|
|
66
|
+
against the registry's integrity, and kept in `~/.local/share/realontext`
|
|
67
|
+
(`%LOCALAPPDATA%\realontext` on Windows). The next start runs it. An agent's
|
|
68
|
+
`realontext mcp` asks when it starts and every hour, and switches to the new
|
|
69
|
+
binary between two requests, without the agent seeing it; a query the Relay
|
|
70
|
+
refuses as too old waits for the new binary and goes again. A newer
|
|
71
|
+
`npm install -g realontext` runs in its place. `REALONTEXT_NO_AUTO_UPDATE=1`
|
|
72
|
+
turns this off.
|
|
73
|
+
|
|
61
74
|
## From the shell
|
|
62
75
|
|
|
63
76
|
```bash
|
package/bin/realontext.js
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
// The `realontext` command npm installs: runs the binary of this platform with
|
|
3
3
|
// this process's arguments, stdio and exit status (D39). What is written here
|
|
4
4
|
// instead is what Node does better: `setup` edits agents' configs (D74), and
|
|
5
|
-
// with no command, in a terminal, a menu of everything (D75).
|
|
5
|
+
// with no command, in a terminal, a menu of everything (D75). Each start may
|
|
6
|
+
// update the binary in the background (D94); `mcp` passes the session through
|
|
7
|
+
// and switches to a newer binary in its middle (D95).
|
|
6
8
|
"use strict";
|
|
7
9
|
|
|
8
10
|
const { spawnSync } = require("child_process");
|
|
@@ -10,6 +12,13 @@ const { spawnSync } = require("child_process");
|
|
|
10
12
|
const [command, ...rest] = process.argv.slice(2);
|
|
11
13
|
const terminal = process.stdin.isTTY && process.stdout.isTTY;
|
|
12
14
|
|
|
15
|
+
if (command !== "mcp") require("../lib/update.js").start();
|
|
16
|
+
|
|
17
|
+
function exit(status) {
|
|
18
|
+
if (typeof status === "string") process.kill(process.pid, status);
|
|
19
|
+
process.exit(status);
|
|
20
|
+
}
|
|
21
|
+
|
|
13
22
|
if (terminal && (command === undefined || (command === "setup" && rest.length === 0))) {
|
|
14
23
|
import("../lib/tui.mjs")
|
|
15
24
|
.then((tui) => tui.default(command === "setup" ? "setup" : "home"))
|
|
@@ -24,13 +33,14 @@ if (terminal && (command === undefined || (command === "setup" && rest.length ==
|
|
|
24
33
|
console.error(`realontext: ${e.message}`);
|
|
25
34
|
process.exit(1);
|
|
26
35
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
process.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
if (command === "mcp") {
|
|
37
|
+
require("../lib/mcp.js")(path, rest).then(exit);
|
|
38
|
+
} else {
|
|
39
|
+
const run = spawnSync(path, process.argv.slice(2), { stdio: "inherit" });
|
|
40
|
+
if (run.error) {
|
|
41
|
+
console.error(`realontext: ${run.error.message}`);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
exit(run.signal ?? run.status);
|
|
34
45
|
}
|
|
35
|
-
process.exit(run.status);
|
|
36
46
|
}
|
package/lib/binary.js
CHANGED
|
@@ -1,15 +1,62 @@
|
|
|
1
|
-
// The binary
|
|
2
|
-
// (D39)
|
|
1
|
+
// The binary this machine runs: the one the platform package npm picked
|
|
2
|
+
// through optionalDependencies (D39), or the newer one the updater put in
|
|
3
|
+
// versions/ (D94). Throws when there is neither.
|
|
3
4
|
"use strict";
|
|
4
5
|
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const os = require("os");
|
|
8
|
+
const path = require("path");
|
|
9
|
+
const { version } = require("../package.json");
|
|
10
|
+
|
|
5
11
|
const packages = {
|
|
6
12
|
"darwin arm64": "@realontext/darwin-arm64",
|
|
7
13
|
"linux x64": "@realontext/linux-x64",
|
|
8
14
|
"win32 x64": "@realontext/win32-x64",
|
|
9
15
|
};
|
|
10
16
|
|
|
11
|
-
|
|
12
|
-
|
|
17
|
+
const exe = process.platform === "win32" ? "realontext.exe" : "realontext";
|
|
18
|
+
|
|
19
|
+
function packageName() {
|
|
20
|
+
return packages[`${process.platform} ${process.arch}`];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Where the updater keeps versions/<version>/ and `current`, the version that runs.
|
|
24
|
+
function home() {
|
|
25
|
+
if (process.platform === "win32") {
|
|
26
|
+
return path.join(process.env.LOCALAPPDATA || path.join(os.homedir(), "AppData", "Local"), "realontext");
|
|
27
|
+
}
|
|
28
|
+
return path.join(os.homedir(), ".local", "share", "realontext");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function parse(v) {
|
|
32
|
+
const m = /^(\d+)\.(\d+)\.(\d+)$/.exec(v || "");
|
|
33
|
+
return m && m.slice(1).map(Number);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Whether version `a` is later than `b`; false when either is not a version.
|
|
37
|
+
function newer(a, b) {
|
|
38
|
+
const x = parse(a);
|
|
39
|
+
const y = parse(b);
|
|
40
|
+
if (!x || !y) return false;
|
|
41
|
+
const i = x.findIndex((n, k) => n !== y[k]);
|
|
42
|
+
return i >= 0 && x[i] > y[i];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// The updater's version, when it is newer than npm's: {version, path}.
|
|
46
|
+
function installed() {
|
|
47
|
+
try {
|
|
48
|
+
const v = fs.readFileSync(path.join(home(), "current"), "utf8").trim();
|
|
49
|
+
const p = path.join(home(), "versions", v, exe);
|
|
50
|
+
return newer(v, version) && fs.existsSync(p) ? { version: v, path: p } : null;
|
|
51
|
+
} catch {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function binary() {
|
|
57
|
+
const ours = installed();
|
|
58
|
+
if (ours) return ours.path;
|
|
59
|
+
const name = packageName();
|
|
13
60
|
if (!name) {
|
|
14
61
|
throw new Error(
|
|
15
62
|
`no build for ${process.platform}-${process.arch}; ` +
|
|
@@ -17,11 +64,16 @@ module.exports = function binary() {
|
|
|
17
64
|
);
|
|
18
65
|
}
|
|
19
66
|
try {
|
|
20
|
-
return require.resolve(`${name}/bin
|
|
67
|
+
return require.resolve(`${name}/bin/${exe}`);
|
|
21
68
|
} catch {
|
|
22
69
|
throw new Error(
|
|
23
70
|
`${name} is not installed. It is an optional dependency of realontext; ` +
|
|
24
71
|
`reinstall without --no-optional / --omit=optional.`
|
|
25
72
|
);
|
|
26
73
|
}
|
|
27
|
-
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// The version `binary()` runs.
|
|
77
|
+
binary.version = () => installed()?.version ?? version;
|
|
78
|
+
|
|
79
|
+
module.exports = Object.assign(binary, { packageName, home, exe, newer });
|
package/lib/mcp.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// `realontext mcp` through the wrapper (D95): the agent's JSON-RPC lines go to
|
|
2
|
+
// the binary and its lines come back, so the binary can be switched for a
|
|
3
|
+
// newer one in the middle of a session. The version is asked for when the
|
|
4
|
+
// session starts, every hour, and when a query comes back 426; a tools/call
|
|
5
|
+
// waits up to 15 s for an ask in progress. The switch happens between
|
|
6
|
+
// requests, when the binary owes no answer: the new one is started, the
|
|
7
|
+
// session's initialize is replayed to it and its answer dropped, and the old
|
|
8
|
+
// one is closed. A call refused with 426 goes again once, after an ask.
|
|
9
|
+
"use strict";
|
|
10
|
+
|
|
11
|
+
const readline = require("readline");
|
|
12
|
+
const { spawn } = require("child_process");
|
|
13
|
+
const update = require("./update.js");
|
|
14
|
+
|
|
15
|
+
const hour = 60 * 60 * 1000;
|
|
16
|
+
const wait = 15 * 1000;
|
|
17
|
+
const replay = "realontext-switch"; // the id of the replayed initialize
|
|
18
|
+
|
|
19
|
+
function parse(line) {
|
|
20
|
+
try {
|
|
21
|
+
const m = JSON.parse(line);
|
|
22
|
+
return m && typeof m === "object" ? m : null;
|
|
23
|
+
} catch {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const key = (id) => JSON.stringify(id);
|
|
29
|
+
|
|
30
|
+
function tooOld(m) {
|
|
31
|
+
return m.result?.isError === true && JSON.stringify(m.result.content ?? "").includes("HTTP 426");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Resolves to the exit status once the binary has exited.
|
|
35
|
+
module.exports = function mcp(path, args) {
|
|
36
|
+
return new Promise((resolve) => {
|
|
37
|
+
let child;
|
|
38
|
+
let next = null; // a binary to switch to
|
|
39
|
+
let asking = null; // the ask in progress
|
|
40
|
+
let waiting = false; // a tools/call waits for `asking`
|
|
41
|
+
let switching = false; // the replayed initialize is not answered yet
|
|
42
|
+
let closed = false; // the agent closed stdin
|
|
43
|
+
let initialize = null;
|
|
44
|
+
const held = []; // the agent's lines not sent yet
|
|
45
|
+
const owed = new Map(); // key(id) → the request line the binary has not answered
|
|
46
|
+
const retried = new Set();
|
|
47
|
+
|
|
48
|
+
function ask() {
|
|
49
|
+
if (asking) return;
|
|
50
|
+
asking = update
|
|
51
|
+
.latest()
|
|
52
|
+
.then((p) => {
|
|
53
|
+
if (p && p !== path) next = p;
|
|
54
|
+
})
|
|
55
|
+
.finally(() => {
|
|
56
|
+
asking = null;
|
|
57
|
+
pump();
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function start() {
|
|
62
|
+
const c = spawn(path, ["mcp", ...args], { stdio: ["pipe", "pipe", "inherit"], windowsHide: true });
|
|
63
|
+
child = c;
|
|
64
|
+
c.stdin.on("error", () => {});
|
|
65
|
+
readline.createInterface({ input: c.stdout, crlfDelay: Infinity }).on("line", answer);
|
|
66
|
+
c.on("error", (e) => {
|
|
67
|
+
if (c !== child) return;
|
|
68
|
+
console.error(`realontext: ${e.message}`);
|
|
69
|
+
resolve(1);
|
|
70
|
+
});
|
|
71
|
+
c.on("exit", (code, signal) => {
|
|
72
|
+
if (c !== child) return;
|
|
73
|
+
// Every answer is out before the status goes back.
|
|
74
|
+
process.stdout.write("", () => resolve(signal ? signal : (code ?? 1)));
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function change() {
|
|
79
|
+
const old = child;
|
|
80
|
+
path = next;
|
|
81
|
+
next = null;
|
|
82
|
+
start();
|
|
83
|
+
if (initialize) {
|
|
84
|
+
child.stdin.write(JSON.stringify({ ...parse(initialize), id: replay }) + "\n");
|
|
85
|
+
switching = true;
|
|
86
|
+
}
|
|
87
|
+
old.stdin.end();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function send(line, m) {
|
|
91
|
+
if (m?.method === "initialize") initialize = line;
|
|
92
|
+
if (m?.method && "id" in m) owed.set(key(m.id), line);
|
|
93
|
+
child.stdin.write(line + "\n");
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function pump() {
|
|
97
|
+
while (held.length && !switching && !waiting) {
|
|
98
|
+
const m = parse(held[0]);
|
|
99
|
+
if (m?.method === "tools/call" && asking) {
|
|
100
|
+
waiting = true;
|
|
101
|
+
Promise.race([asking, new Promise((r) => setTimeout(r, wait).unref())]).then(() => {
|
|
102
|
+
waiting = false;
|
|
103
|
+
pump();
|
|
104
|
+
});
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
// Nothing more goes to a binary being left: it answers what it owes first.
|
|
108
|
+
if (next) {
|
|
109
|
+
if (owed.size) return;
|
|
110
|
+
change();
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
send(held.shift(), m);
|
|
114
|
+
}
|
|
115
|
+
if (closed && !held.length && !switching && !waiting) child.stdin.end();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function answer(line) {
|
|
119
|
+
const m = parse(line);
|
|
120
|
+
if (m && m.id === replay && !m.method) {
|
|
121
|
+
switching = false;
|
|
122
|
+
return pump();
|
|
123
|
+
}
|
|
124
|
+
const k = m && "id" in m && !m.method ? key(m.id) : null;
|
|
125
|
+
if (k && owed.has(k)) {
|
|
126
|
+
const request = owed.get(k);
|
|
127
|
+
owed.delete(k);
|
|
128
|
+
if (tooOld(m) && !retried.has(k)) {
|
|
129
|
+
retried.add(k);
|
|
130
|
+
held.unshift(request);
|
|
131
|
+
ask();
|
|
132
|
+
return pump();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
process.stdout.write(line + "\n");
|
|
136
|
+
pump();
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
start();
|
|
140
|
+
ask();
|
|
141
|
+
setInterval(ask, hour).unref();
|
|
142
|
+
readline
|
|
143
|
+
.createInterface({ input: process.stdin, crlfDelay: Infinity })
|
|
144
|
+
.on("line", (line) => {
|
|
145
|
+
held.push(line);
|
|
146
|
+
pump();
|
|
147
|
+
})
|
|
148
|
+
.on("close", () => {
|
|
149
|
+
closed = true;
|
|
150
|
+
pump();
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
};
|
package/lib/tui.mjs
CHANGED
|
@@ -13,7 +13,6 @@ import { Box, Text, render, useApp, useInput } from "ink";
|
|
|
13
13
|
const require = createRequire(import.meta.url);
|
|
14
14
|
const { agents, setup } = require("./setup.js");
|
|
15
15
|
const binary = require("./binary.js");
|
|
16
|
-
const { version } = require("../package.json");
|
|
17
16
|
const h = React.createElement;
|
|
18
17
|
|
|
19
18
|
// `realontext usage`: {account, queries}, or {error} with what went wrong.
|
|
@@ -144,7 +143,7 @@ function App({ start, onDone }) {
|
|
|
144
143
|
h(
|
|
145
144
|
Box,
|
|
146
145
|
{ flexDirection: "column" },
|
|
147
|
-
h(Text, { bold: true }, `realontext ${version} `, h(Text, { dimColor: true }, process.cwd())),
|
|
146
|
+
h(Text, { bold: true }, `realontext ${binary.version()} `, h(Text, { dimColor: true }, process.cwd())),
|
|
148
147
|
h(Account, { account })
|
|
149
148
|
),
|
|
150
149
|
h(SCREENS[screen], { account, go, done })
|
package/lib/update.js
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// Keeps the binary at the version the Relay names (D94). The Relay's GET
|
|
2
|
+
// /v1/client names the version; when it is newer than npm's, that version's
|
|
3
|
+
// platform package comes from the registry, checked against the registry's
|
|
4
|
+
// integrity, into versions/<version>/, and `current` names it. A version no
|
|
5
|
+
// newer than npm's lets npm's run. Nothing is printed; the last failure is
|
|
6
|
+
// left in update.log.
|
|
7
|
+
//
|
|
8
|
+
// `start()` runs this file as a detached process, at most once an hour: the
|
|
9
|
+
// command it was started for does not wait, the next start runs the new
|
|
10
|
+
// version. `latest()` does the same in this process, for `mcp` (D95), which
|
|
11
|
+
// switches to what it returns.
|
|
12
|
+
"use strict";
|
|
13
|
+
|
|
14
|
+
const crypto = require("crypto");
|
|
15
|
+
const fs = require("fs");
|
|
16
|
+
const path = require("path");
|
|
17
|
+
const zlib = require("zlib");
|
|
18
|
+
const { spawn } = require("child_process");
|
|
19
|
+
const binary = require("./binary.js");
|
|
20
|
+
const { version } = require("../package.json");
|
|
21
|
+
|
|
22
|
+
const relay = "https://api.context.revlm.com";
|
|
23
|
+
const registry = (process.env.npm_config_registry || "https://registry.npmjs.org").replace(/\/+$/, "");
|
|
24
|
+
const hour = 60 * 60 * 1000;
|
|
25
|
+
|
|
26
|
+
const off = () => Boolean(process.env.REALONTEXT_NO_AUTO_UPDATE) || !binary.packageName();
|
|
27
|
+
|
|
28
|
+
function start() {
|
|
29
|
+
if (off()) return;
|
|
30
|
+
const checked = path.join(binary.home(), "checked");
|
|
31
|
+
try {
|
|
32
|
+
if (Date.now() - fs.statSync(checked).mtimeMs < hour) return;
|
|
33
|
+
} catch {}
|
|
34
|
+
try {
|
|
35
|
+
fs.mkdirSync(binary.home(), { recursive: true });
|
|
36
|
+
fs.writeFileSync(checked, "");
|
|
37
|
+
spawn(process.execPath, [__filename], { detached: true, stdio: "ignore", windowsHide: true }).unref();
|
|
38
|
+
} catch {}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function get(url) {
|
|
42
|
+
const res = await fetch(url, {
|
|
43
|
+
headers: { "User-Agent": `realontext/${version}` },
|
|
44
|
+
signal: AbortSignal.timeout(60000),
|
|
45
|
+
});
|
|
46
|
+
if (!res.ok) throw new Error(`${url}: HTTP ${res.status}`);
|
|
47
|
+
return res;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// The file `want` in a tar archive.
|
|
51
|
+
function untar(tar, want) {
|
|
52
|
+
for (let at = 0; at + 512 <= tar.length && tar[at] !== 0; ) {
|
|
53
|
+
const field = (from, to) => tar.toString("utf8", at + from, at + to).replace(/\0[\s\S]*$/, "");
|
|
54
|
+
const prefix = field(345, 500);
|
|
55
|
+
const name = (prefix ? prefix + "/" : "") + field(0, 100);
|
|
56
|
+
const size = parseInt(field(124, 136).trim(), 8);
|
|
57
|
+
if (name === want) return tar.subarray(at + 512, at + 512 + size);
|
|
58
|
+
at += 512 + Math.ceil(size / 512) * 512;
|
|
59
|
+
}
|
|
60
|
+
throw new Error(`${want} is not in the package`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Puts `v`'s binary in versions/<v>/.
|
|
64
|
+
async function install(v) {
|
|
65
|
+
const dir = path.join(binary.home(), "versions", v);
|
|
66
|
+
if (fs.existsSync(path.join(dir, binary.exe))) return;
|
|
67
|
+
const name = binary.packageName();
|
|
68
|
+
const meta = await (await get(`${registry}/${name.replace("/", "%2f")}/${v}`)).json();
|
|
69
|
+
const tgz = Buffer.from(await (await get(meta.dist.tarball)).arrayBuffer());
|
|
70
|
+
const [algorithm, digest] = meta.dist.integrity.split(/-(.*)/s);
|
|
71
|
+
if (crypto.createHash(algorithm).update(tgz).digest("base64") !== digest) {
|
|
72
|
+
throw new Error(`${name}@${v}: the download does not match the registry's integrity`);
|
|
73
|
+
}
|
|
74
|
+
const file = untar(zlib.gunzipSync(tgz), `package/bin/${binary.exe}`);
|
|
75
|
+
// Written beside, then renamed: a start never finds half a binary.
|
|
76
|
+
const tmp = `${dir}.${process.pid}`;
|
|
77
|
+
fs.mkdirSync(tmp, { recursive: true });
|
|
78
|
+
fs.writeFileSync(path.join(tmp, binary.exe), file, { mode: 0o755 });
|
|
79
|
+
try {
|
|
80
|
+
fs.renameSync(tmp, dir);
|
|
81
|
+
} catch (e) {
|
|
82
|
+
fs.rmSync(tmp, { recursive: true, force: true });
|
|
83
|
+
if (!fs.existsSync(path.join(dir, binary.exe))) throw e;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Points `current` at `v`, or at nothing; versions/ keeps it and the one before.
|
|
88
|
+
function choose(v) {
|
|
89
|
+
const current = path.join(binary.home(), "current");
|
|
90
|
+
let was = null;
|
|
91
|
+
try {
|
|
92
|
+
was = fs.readFileSync(current, "utf8").trim();
|
|
93
|
+
} catch {}
|
|
94
|
+
if (v) {
|
|
95
|
+
fs.writeFileSync(`${current}.${process.pid}`, v);
|
|
96
|
+
fs.renameSync(`${current}.${process.pid}`, current);
|
|
97
|
+
} else {
|
|
98
|
+
fs.rmSync(current, { force: true });
|
|
99
|
+
}
|
|
100
|
+
const versions = path.join(binary.home(), "versions");
|
|
101
|
+
for (const d of fs.existsSync(versions) ? fs.readdirSync(versions) : []) {
|
|
102
|
+
if (d === v || d === was) continue;
|
|
103
|
+
// A version still running on Windows cannot go: it goes next time.
|
|
104
|
+
try {
|
|
105
|
+
fs.rmSync(path.join(versions, d), { recursive: true, force: true });
|
|
106
|
+
} catch {}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function run() {
|
|
111
|
+
const want = (await (await get(`${relay}/v1/client`)).json()).version;
|
|
112
|
+
if (!want) return;
|
|
113
|
+
if (!binary.newer(want, version)) return choose(null);
|
|
114
|
+
await install(want);
|
|
115
|
+
choose(want);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function log(e) {
|
|
119
|
+
try {
|
|
120
|
+
fs.mkdirSync(binary.home(), { recursive: true });
|
|
121
|
+
fs.writeFileSync(path.join(binary.home(), "update.log"), `${new Date().toISOString()} ${e.message}\n`);
|
|
122
|
+
} catch {}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// The binary to run once versions/ is where the Relay says; null when updates
|
|
126
|
+
// are off or there is no binary.
|
|
127
|
+
async function latest() {
|
|
128
|
+
if (off()) return null;
|
|
129
|
+
await run().catch(log);
|
|
130
|
+
try {
|
|
131
|
+
return binary();
|
|
132
|
+
} catch {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (require.main === module) run().catch(log);
|
|
138
|
+
|
|
139
|
+
module.exports = { start, latest };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "realontext",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "Code search for coding agents, over the directory you are in. CLI and MCP server.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"repository": {
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"react": "^18.3.1"
|
|
25
25
|
},
|
|
26
26
|
"optionalDependencies": {
|
|
27
|
-
"@realontext/darwin-arm64": "0.
|
|
28
|
-
"@realontext/linux-x64": "0.
|
|
29
|
-
"@realontext/win32-x64": "0.
|
|
27
|
+
"@realontext/darwin-arm64": "0.8.1",
|
|
28
|
+
"@realontext/linux-x64": "0.8.1",
|
|
29
|
+
"@realontext/win32-x64": "0.8.1"
|
|
30
30
|
}
|
|
31
31
|
}
|