borgmcp 0.9.56 → 0.9.58
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/README.md +104 -176
- package/dist/assimilate-cmd.d.ts +2 -5
- package/dist/assimilate-cmd.d.ts.map +1 -1
- package/dist/assimilate-cmd.js +12 -0
- package/dist/assimilate-cmd.js.map +1 -1
- package/dist/assimilate-deps.d.ts.map +1 -1
- package/dist/assimilate-deps.js +2 -9
- package/dist/assimilate-deps.js.map +1 -1
- package/dist/auth-env.d.ts +52 -0
- package/dist/auth-env.d.ts.map +1 -0
- package/dist/auth-env.js +107 -0
- package/dist/auth-env.js.map +1 -0
- package/dist/auth.d.ts +33 -13
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +100 -4
- package/dist/auth.js.map +1 -1
- package/dist/claude.js +28 -6
- package/dist/claude.js.map +1 -1
- package/dist/cli-help.d.ts +16 -0
- package/dist/cli-help.d.ts.map +1 -0
- package/dist/cli-help.js +27 -0
- package/dist/cli-help.js.map +1 -0
- package/dist/cli-platform.js +1 -1
- package/dist/cli-platform.js.map +1 -1
- package/dist/codex-remote.d.ts +60 -12
- package/dist/codex-remote.d.ts.map +1 -1
- package/dist/codex-remote.js +173 -80
- package/dist/codex-remote.js.map +1 -1
- package/dist/config.d.ts +13 -10
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +105 -60
- package/dist/config.js.map +1 -1
- package/dist/device-auth.d.ts +75 -0
- package/dist/device-auth.d.ts.map +1 -0
- package/dist/device-auth.js +167 -0
- package/dist/device-auth.js.map +1 -0
- package/dist/inbox-monitor.d.ts.map +1 -1
- package/dist/inbox-monitor.js +15 -0
- package/dist/inbox-monitor.js.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/setup.js +25 -7
- package/dist/setup.js.map +1 -1
- package/dist/subscription-retry.d.ts +40 -0
- package/dist/subscription-retry.d.ts.map +1 -0
- package/dist/subscription-retry.js +23 -0
- package/dist/subscription-retry.js.map +1 -0
- package/dist/templates.d.ts +1 -0
- package/dist/templates.d.ts.map +1 -1
- package/dist/templates.js +59 -11
- package/dist/templates.js.map +1 -1
- package/dist/token-crypto.d.ts +50 -0
- package/dist/token-crypto.d.ts.map +1 -0
- package/dist/token-crypto.js +91 -0
- package/dist/token-crypto.js.map +1 -0
- package/dist/token-store.d.ts +98 -0
- package/dist/token-store.d.ts.map +1 -0
- package/dist/token-store.js +136 -0
- package/dist/token-store.js.map +1 -0
- package/package.json +1 -9
package/dist/codex-remote.d.ts
CHANGED
|
@@ -1,21 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* gh#528 — npm-managed Codex remote-wake.
|
|
3
|
+
*
|
|
4
|
+
* borg owns a per-launch DIRECT Codex app-server (`codex app-server --listen
|
|
5
|
+
* unix://<socket>`) as the primary wake path, instead of the standalone
|
|
6
|
+
* `codex app-server daemon start` (which only exists for standalone-installer
|
|
7
|
+
* Codex — npm-managed Codex has no daemon, so those sessions had NO push-wake
|
|
8
|
+
* and silently fell back to the ~30min /loop heartbeat). Per-launch direct
|
|
9
|
+
* app-server works for both install kinds and starts fresh each launch (so it
|
|
10
|
+
* always loads the current borgmcp MCP — no daemon-restart version refresh
|
|
11
|
+
* needed). The TUI is then launched with `codex --remote unix://<socket>` and
|
|
12
|
+
* Borg delivers wakes by connecting to that socket (see codex-app-wake.ts).
|
|
13
|
+
*/
|
|
14
|
+
export interface CodexAppServerHandle {
|
|
15
|
+
pid: number | undefined;
|
|
16
|
+
socketPath: string;
|
|
17
|
+
/** Kill the owned app-server + remove its socket/pidfile. Wire to TUI exit. */
|
|
18
|
+
cleanup: () => void;
|
|
19
|
+
}
|
|
1
20
|
export interface CodexRemoteLaunch {
|
|
2
21
|
args: string[];
|
|
3
22
|
env: Record<string, string>;
|
|
4
23
|
warning?: string;
|
|
24
|
+
/** Present when borg owns a per-launch app-server that must be cleaned up on TUI exit. */
|
|
25
|
+
server?: CodexAppServerHandle;
|
|
5
26
|
}
|
|
6
|
-
export interface
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
stderr: string;
|
|
27
|
+
export interface CodexChild {
|
|
28
|
+
pid: number | undefined;
|
|
29
|
+
kill: () => void;
|
|
10
30
|
}
|
|
11
|
-
export interface
|
|
12
|
-
|
|
13
|
-
|
|
31
|
+
export interface PrepareCodexRemoteDeps {
|
|
32
|
+
/** Spawn the long-lived `codex app-server --listen unix://<socketPath>` child. */
|
|
33
|
+
spawnAppServer: (socketPath: string) => CodexChild;
|
|
34
|
+
/** Readiness probe: a real CodexAppServerClient connect + thread/loaded/list round-trip. */
|
|
35
|
+
probeReady: (socketPath: string) => Promise<boolean>;
|
|
36
|
+
/** Delay between readiness polls (injected so tests don't actually wait). */
|
|
37
|
+
sleep: (ms: number) => Promise<void>;
|
|
38
|
+
/** 0700 runtime dir (default ~/.config/borgmcp/codex-remote). */
|
|
39
|
+
runtimeDir?: string;
|
|
40
|
+
/** Unique socket id generator (default 32-hex). Injected for deterministic tests. */
|
|
41
|
+
socketId?: () => string;
|
|
42
|
+
/** Readiness timeout (default 8000ms) + poll interval (default 250ms). */
|
|
43
|
+
readyTimeoutMs?: number;
|
|
44
|
+
pollIntervalMs?: number;
|
|
45
|
+
/** Whether a pid is alive (default process.kill(pid, 0)). Injected for tests. */
|
|
46
|
+
isAlive?: (pid: number) => boolean;
|
|
14
47
|
}
|
|
15
|
-
export declare
|
|
48
|
+
export declare const DEFAULT_CODEX_REMOTE_DIR: string;
|
|
16
49
|
export declare function withCodexCwdArg(args: string[], cwd: string): string[];
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Start a borg-owned per-launch Codex app-server, probe it for readiness, and
|
|
52
|
+
* return the `--remote` launch args + an owned handle (or a fail-loud warning).
|
|
53
|
+
* Async + lifecycle-owning: the caller MUST call `result.server?.cleanup()` on
|
|
54
|
+
* TUI exit.
|
|
55
|
+
*/
|
|
56
|
+
export declare function prepareCodexRemoteLaunch(deps: PrepareCodexRemoteDeps): Promise<CodexRemoteLaunch>;
|
|
57
|
+
/**
|
|
58
|
+
* Production deps for prepareCodexRemoteLaunch — spawn the real `codex
|
|
59
|
+
* app-server` child + probe it with the real CodexAppServerClient. Shared by
|
|
60
|
+
* claude.ts and assimilate-deps.ts so there's ONE wiring.
|
|
61
|
+
*
|
|
62
|
+
* The readiness probe uses Codex app-server RPCs ONLY (connect + thread/loaded/
|
|
63
|
+
* list) — it never calls a borg /api/drone/* endpoint — so it can never advance
|
|
64
|
+
* last_seen/last_regen_at and mask a deaf Codex (the gh#46/gh#406 signal-truth
|
|
65
|
+
* invariant; the app-server socket is the wake-DELIVERY wire, not a liveness
|
|
66
|
+
* signal).
|
|
67
|
+
*/
|
|
68
|
+
export declare function defaultCodexRemoteDeps(): Pick<PrepareCodexRemoteDeps, 'spawnAppServer' | 'probeReady' | 'sleep'>;
|
|
21
69
|
//# sourceMappingURL=codex-remote.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex-remote.d.ts","sourceRoot":"","sources":["../src/codex-remote.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"codex-remote.d.ts","sourceRoot":"","sources":["../src/codex-remote.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,+EAA+E;IAC/E,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0FAA0F;IAC1F,MAAM,CAAC,EAAE,oBAAoB,CAAC;CAC/B;AAED,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB;AAED,MAAM,WAAW,sBAAsB;IACrC,kFAAkF;IAClF,cAAc,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,UAAU,CAAC;IACnD,4FAA4F;IAC5F,UAAU,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACrD,6EAA6E;IAC7E,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,iEAAiE;IACjE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qFAAqF;IACrF,QAAQ,CAAC,EAAE,MAAM,MAAM,CAAC;IACxB,0EAA0E;IAC1E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iFAAiF;IACjF,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;CACpC;AAED,eAAO,MAAM,wBAAwB,QAAwD,CAAC;AAE9F,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAGrE;AA0DD;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,sBAAsB,GAC3B,OAAO,CAAC,iBAAiB,CAAC,CA+E5B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAC5C,sBAAsB,EACtB,gBAAgB,GAAG,YAAY,GAAG,OAAO,CAC1C,CAoCA"}
|
package/dist/codex-remote.js
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { mkdirSync, chmodSync, readdirSync, rmSync, writeFileSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { homedir } from 'node:os';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const daemon = withRefreshWarning(parseCodexRemoteResult(daemonResult, 'Codex app-server daemon start'), refresh.warning);
|
|
9
|
-
if (daemon.args.length > 0)
|
|
10
|
-
return daemon;
|
|
11
|
-
return {
|
|
12
|
-
args: [],
|
|
13
|
-
env: {},
|
|
14
|
-
warning: daemon.warning,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { randomBytes } from 'node:crypto';
|
|
5
|
+
import { spawn } from 'node:child_process';
|
|
6
|
+
import { CodexAppServerClient } from './codex-app-server.js';
|
|
7
|
+
export const DEFAULT_CODEX_REMOTE_DIR = join(homedir(), '.config', 'borgmcp', 'codex-remote');
|
|
17
8
|
export function withCodexCwdArg(args, cwd) {
|
|
18
9
|
if (hasCodexCwdArg(args))
|
|
19
10
|
return args;
|
|
@@ -22,86 +13,188 @@ export function withCodexCwdArg(args, cwd) {
|
|
|
22
13
|
function hasCodexCwdArg(args) {
|
|
23
14
|
return args.some((arg) => arg === '--cd' || arg.startsWith('--cd=') || arg === '-C');
|
|
24
15
|
}
|
|
25
|
-
function
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
16
|
+
function defaultIsAlive(pid) {
|
|
17
|
+
try {
|
|
18
|
+
process.kill(pid, 0);
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
// EPERM ⇒ the process exists but we can't signal it (still alive).
|
|
23
|
+
return err?.code === 'EPERM';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function safeRm(p) {
|
|
27
|
+
try {
|
|
28
|
+
rmSync(p, { force: true });
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
// best-effort
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Remove sockets in the owned dir whose owning app-server pid is no longer
|
|
36
|
+
* alive (crashed prior launches), leaving live concurrent sessions' sockets
|
|
37
|
+
* untouched. Operates ONLY inside the borg-owned runtime dir.
|
|
38
|
+
*/
|
|
39
|
+
function pruneStaleSockets(runtimeDir, isAlive) {
|
|
40
|
+
let entries;
|
|
34
41
|
try {
|
|
35
|
-
|
|
42
|
+
entries = readdirSync(runtimeDir);
|
|
36
43
|
}
|
|
37
44
|
catch {
|
|
38
|
-
return
|
|
39
|
-
args: [],
|
|
40
|
-
env: {},
|
|
41
|
-
warning: `${commandLabel} returned invalid JSON; automatic Borg wakeups disabled.`,
|
|
42
|
-
};
|
|
45
|
+
return;
|
|
43
46
|
}
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
for (const name of entries) {
|
|
48
|
+
if (!name.endsWith('.pid'))
|
|
49
|
+
continue;
|
|
50
|
+
const pidPath = join(runtimeDir, name);
|
|
51
|
+
const sockPath = join(runtimeDir, name.replace(/\.pid$/, '.sock'));
|
|
52
|
+
let pid;
|
|
53
|
+
try {
|
|
54
|
+
pid = Number.parseInt(readFileSync(pidPath, 'utf-8').trim(), 10);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
safeRm(pidPath);
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (Number.isNaN(pid) || !isAlive(pid)) {
|
|
61
|
+
safeRm(sockPath);
|
|
62
|
+
safeRm(pidPath);
|
|
63
|
+
}
|
|
51
64
|
}
|
|
52
|
-
return {
|
|
53
|
-
args: ['--remote', `unix://${socketPath}`],
|
|
54
|
-
env: { BORG_CODEX_REMOTE_WAKE: '1' },
|
|
55
|
-
};
|
|
56
65
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
function failLoud(reason) {
|
|
67
|
+
return { args: [], env: {}, warning: reason };
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Start a borg-owned per-launch Codex app-server, probe it for readiness, and
|
|
71
|
+
* return the `--remote` launch args + an owned handle (or a fail-loud warning).
|
|
72
|
+
* Async + lifecycle-owning: the caller MUST call `result.server?.cleanup()` on
|
|
73
|
+
* TUI exit.
|
|
74
|
+
*/
|
|
75
|
+
export async function prepareCodexRemoteLaunch(deps) {
|
|
76
|
+
const runtimeDir = deps.runtimeDir ?? DEFAULT_CODEX_REMOTE_DIR;
|
|
77
|
+
const isAlive = deps.isAlive ?? defaultIsAlive;
|
|
78
|
+
const readyTimeoutMs = deps.readyTimeoutMs ?? 8000;
|
|
79
|
+
const pollIntervalMs = deps.pollIntervalMs ?? 250;
|
|
80
|
+
// 1. 0700 owned dir + prune crashed prior sockets (concurrent-safe via pid liveness).
|
|
81
|
+
try {
|
|
82
|
+
mkdirSync(runtimeDir, { recursive: true, mode: 0o700 });
|
|
83
|
+
chmodSync(runtimeDir, 0o700); // enforce 0700 even if it pre-existed with looser perms
|
|
84
|
+
pruneStaleSockets(runtimeDir, isAlive);
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
return failLoud(`Codex remote-wake disabled: could not prepare ${runtimeDir} (${err?.message ?? err}); run borg:regen manually.`);
|
|
72
88
|
}
|
|
89
|
+
// 2. unique, non-predictable socket path inside the owned dir.
|
|
90
|
+
const id = (deps.socketId ?? (() => randomBytes(16).toString('hex')))();
|
|
91
|
+
const socketPath = join(runtimeDir, `${id}.sock`);
|
|
92
|
+
const pidPath = join(runtimeDir, `${id}.pid`);
|
|
93
|
+
// 3. spawn the long-lived app-server.
|
|
94
|
+
let child;
|
|
73
95
|
try {
|
|
74
|
-
|
|
96
|
+
child = deps.spawnAppServer(socketPath);
|
|
75
97
|
}
|
|
76
98
|
catch (err) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
99
|
+
safeRm(socketPath);
|
|
100
|
+
return failLoud(`Codex remote-wake disabled: could not start \`codex app-server\` (${err?.message ?? err}) — ` +
|
|
101
|
+
`is Codex installed + up to date? This session only wakes on the ~30min /loop fallback; ` +
|
|
102
|
+
`run borg:regen manually.`);
|
|
81
103
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
104
|
+
if (child.pid != null) {
|
|
105
|
+
try {
|
|
106
|
+
writeFileSync(pidPath, String(child.pid));
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
// pidfile is only for stale-prune; launch still proceeds.
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const cleanup = () => {
|
|
113
|
+
try {
|
|
114
|
+
child.kill();
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
// best-effort
|
|
118
|
+
}
|
|
119
|
+
safeRm(socketPath);
|
|
120
|
+
safeRm(pidPath);
|
|
90
121
|
};
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
122
|
+
// 4. readiness via a real protocol round-trip — bounded attempts (no clock dep).
|
|
123
|
+
const attempts = Math.max(1, Math.ceil(readyTimeoutMs / pollIntervalMs));
|
|
124
|
+
let ready = false;
|
|
125
|
+
for (let i = 0; i < attempts && !ready; i++) {
|
|
126
|
+
try {
|
|
127
|
+
ready = await deps.probeReady(socketPath);
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
ready = false;
|
|
131
|
+
}
|
|
132
|
+
if (!ready && i < attempts - 1)
|
|
133
|
+
await deps.sleep(pollIntervalMs);
|
|
98
134
|
}
|
|
99
|
-
|
|
100
|
-
|
|
135
|
+
if (!ready) {
|
|
136
|
+
cleanup();
|
|
137
|
+
return failLoud(`Codex remote-wake disabled: could not reach a Codex app-server at ${socketPath} within ` +
|
|
138
|
+
`${readyTimeoutMs}ms (is Codex up to date? \`codex app-server --listen\` is required). ` +
|
|
139
|
+
`This session only wakes on the ~30min /loop fallback — run borg:regen manually when you return.`);
|
|
101
140
|
}
|
|
141
|
+
// 5. ready → owned remote launch.
|
|
142
|
+
return {
|
|
143
|
+
args: ['--remote', `unix://${socketPath}`],
|
|
144
|
+
env: { BORG_CODEX_REMOTE_WAKE: '1' },
|
|
145
|
+
server: { pid: child.pid, socketPath, cleanup },
|
|
146
|
+
};
|
|
102
147
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
148
|
+
/**
|
|
149
|
+
* Production deps for prepareCodexRemoteLaunch — spawn the real `codex
|
|
150
|
+
* app-server` child + probe it with the real CodexAppServerClient. Shared by
|
|
151
|
+
* claude.ts and assimilate-deps.ts so there's ONE wiring.
|
|
152
|
+
*
|
|
153
|
+
* The readiness probe uses Codex app-server RPCs ONLY (connect + thread/loaded/
|
|
154
|
+
* list) — it never calls a borg /api/drone/* endpoint — so it can never advance
|
|
155
|
+
* last_seen/last_regen_at and mask a deaf Codex (the gh#46/gh#406 signal-truth
|
|
156
|
+
* invariant; the app-server socket is the wake-DELIVERY wire, not a liveness
|
|
157
|
+
* signal).
|
|
158
|
+
*/
|
|
159
|
+
export function defaultCodexRemoteDeps() {
|
|
160
|
+
return {
|
|
161
|
+
spawnAppServer: (socketPath) => {
|
|
162
|
+
const child = spawn('codex', ['app-server', '--listen', `unix://${socketPath}`], {
|
|
163
|
+
stdio: 'ignore',
|
|
164
|
+
shell: false,
|
|
165
|
+
});
|
|
166
|
+
return {
|
|
167
|
+
pid: child.pid,
|
|
168
|
+
kill: () => {
|
|
169
|
+
try {
|
|
170
|
+
child.kill();
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
// best-effort
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
},
|
|
178
|
+
probeReady: async (socketPath) => {
|
|
179
|
+
const probe = new CodexAppServerClient(socketPath);
|
|
180
|
+
try {
|
|
181
|
+
await probe.connect();
|
|
182
|
+
await probe.loadedThreadIds();
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
finally {
|
|
189
|
+
try {
|
|
190
|
+
probe.close();
|
|
191
|
+
}
|
|
192
|
+
catch {
|
|
193
|
+
// best-effort
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
|
|
198
|
+
};
|
|
106
199
|
}
|
|
107
200
|
//# sourceMappingURL=codex-remote.js.map
|
package/dist/codex-remote.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex-remote.js","sourceRoot":"","sources":["../src/codex-remote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"codex-remote.js","sourceRoot":"","sources":["../src/codex-remote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACjG,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAsD7D,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC;AAE9F,MAAM,UAAU,eAAe,CAAC,IAAc,EAAE,GAAW;IACzD,IAAI,cAAc,CAAC,IAAI,CAAC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AAC,GAAG;gBACd,IAAI,EAAE,GAAG,EAAE;oBACT,IAAI,CAAC;wBACH,KAAK,CAAC,IAAI,EAAE,CAAC;oBACf,CAAC;oBAAC,MAAM,CAAC;wBACP,cAAc;oBAChB,CAAC;gBACH,CAAC;aACF,CAAC;QACJ,CAAC;QACD,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE;YAC/B,MAAM,KAAK,GAAG,IAAI,oBAAoB,CAAC,UAAU,CAAC,CAAC;YACnD,IAAI,CAAC;gBACH,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;gBACtB,MAAM,KAAK,CAAC,eAAe,EAAE,CAAC;gBAC9B,OAAO,IAAI,CAAC;YACd,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,KAAK,CAAC;YACf,CAAC;oBAAS,CAAC;gBACT,IAAI,CAAC;oBACH,KAAK,CAAC,KAAK,EAAE,CAAC;gBAChB,CAAC;gBAAC,MAAM,CAAC;oBACP,cAAc;gBAChB,CAAC;YACH,CAAC;QACH,CAAC;QACD,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;KACjE,CAAC;AACJ,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Store Google OAuth ID token securely in the
|
|
2
|
+
* Store Google OAuth ID token securely in the selected backend.
|
|
3
3
|
*/
|
|
4
4
|
export declare function storeIdToken(idToken: string, expiresAt: number): Promise<void>;
|
|
5
5
|
/**
|
|
6
|
-
* Store Google OAuth refresh token securely in the
|
|
6
|
+
* Store Google OAuth refresh token securely in the selected backend.
|
|
7
7
|
*/
|
|
8
8
|
export declare function storeRefreshToken(refreshToken: string): Promise<void>;
|
|
9
9
|
/**
|
|
10
|
-
* Retrieve the Google OAuth ID token
|
|
11
|
-
* Returns null if not stored or expired (5-minute buffer).
|
|
10
|
+
* Retrieve the Google OAuth ID token.
|
|
12
11
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
12
|
+
* A caller-managed token (BORG_TOKEN / BORG_TOKEN_FILE) takes precedence and
|
|
13
|
+
* is returned verbatim — the caller owns its freshness, so the expiry buffer
|
|
14
|
+
* does not apply. Otherwise reads the persistent backend and returns null if
|
|
15
|
+
* not stored or within the 5-minute expiry buffer.
|
|
16
16
|
*/
|
|
17
17
|
export declare function getIdToken(): Promise<string | null>;
|
|
18
18
|
/**
|
|
19
|
-
* Retrieve the Google OAuth refresh token
|
|
19
|
+
* Retrieve the Google OAuth refresh token. There is no refresh_token in
|
|
20
|
+
* caller-managed mode (the externally-supplied id_token has no refresh
|
|
21
|
+
* counterpart), so this returns null whenever a caller-managed token is set.
|
|
20
22
|
*/
|
|
21
23
|
export declare function getRefreshToken(): Promise<string | null>;
|
|
22
24
|
/**
|
|
23
|
-
* Clear all stored tokens from the
|
|
24
|
-
*
|
|
25
|
+
* Clear all stored tokens from the selected backend. Idempotent — clearing
|
|
26
|
+
* an already-empty store is a no-op. Does not touch caller-managed env vars
|
|
27
|
+
* (those are the caller's to manage).
|
|
25
28
|
*/
|
|
26
29
|
export declare function clearTokens(): Promise<void>;
|
|
27
30
|
/**
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAkGA;;GAEG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAIpF;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG3E;AAED;;;;;;;GAOG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAqBzD;AAED;;;;GAIG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAI9D;AAED;;;;GAIG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAKjD;AAED;;GAEG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC,CAGxD"}
|