@1presence/bridge 0.76.0 → 0.78.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/dist/claude.js +0 -1
- package/dist/config.js +41 -46
- package/dist/index.js +2 -1
- package/dist/update.js +49 -0
- package/package.json +2 -2
package/dist/claude.js
CHANGED
package/dist/config.js
CHANGED
|
@@ -1,60 +1,55 @@
|
|
|
1
1
|
import { emitKeypressEvents } from 'readline';
|
|
2
|
-
import {
|
|
2
|
+
import { query } from '@anthropic-ai/claude-agent-sdk';
|
|
3
3
|
let selectedModel = null;
|
|
4
4
|
function detectClaudeDefaultModel() {
|
|
5
5
|
return new Promise((resolve) => {
|
|
6
6
|
let settled = false;
|
|
7
|
-
const
|
|
7
|
+
const abort = new AbortController();
|
|
8
|
+
const finish = (v) => {
|
|
9
|
+
if (settled)
|
|
10
|
+
return;
|
|
8
11
|
settled = true;
|
|
12
|
+
clearTimeout(timer);
|
|
13
|
+
try {
|
|
14
|
+
abort.abort();
|
|
15
|
+
}
|
|
16
|
+
catch { }
|
|
9
17
|
resolve(v);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
buf = lines.pop() ?? '';
|
|
37
|
-
for (const line of lines) {
|
|
38
|
-
const trimmed = line.trim();
|
|
39
|
-
if (!trimmed)
|
|
40
|
-
continue;
|
|
41
|
-
try {
|
|
42
|
-
const ev = JSON.parse(trimmed);
|
|
43
|
-
if (ev['type'] === 'system' && ev['subtype'] === 'init') {
|
|
44
|
-
const model = ev['model'];
|
|
45
|
-
clearTimeout(timer);
|
|
46
|
-
try {
|
|
47
|
-
proc.kill('SIGKILL');
|
|
48
|
-
}
|
|
49
|
-
catch { }
|
|
50
|
-
finish(typeof model === 'string' ? model : null);
|
|
18
|
+
};
|
|
19
|
+
const timer = setTimeout(() => finish(null), 5000);
|
|
20
|
+
const { ANTHROPIC_API_KEY: _stripped, ...safeEnv } = process.env;
|
|
21
|
+
void (async () => {
|
|
22
|
+
try {
|
|
23
|
+
const stream = query({
|
|
24
|
+
prompt: (async function* () {
|
|
25
|
+
yield {
|
|
26
|
+
type: 'user',
|
|
27
|
+
message: { role: 'user', content: '' },
|
|
28
|
+
parent_tool_use_id: null,
|
|
29
|
+
};
|
|
30
|
+
})(),
|
|
31
|
+
options: {
|
|
32
|
+
systemPrompt: '',
|
|
33
|
+
settingSources: [],
|
|
34
|
+
tools: [],
|
|
35
|
+
permissionMode: 'default',
|
|
36
|
+
env: safeEnv,
|
|
37
|
+
abortController: abort,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
for await (const msg of stream) {
|
|
41
|
+
const ev = msg;
|
|
42
|
+
if (ev.type === 'system' && ev.subtype === 'init') {
|
|
43
|
+
finish(typeof ev.model === 'string' ? ev.model : null);
|
|
51
44
|
return;
|
|
52
45
|
}
|
|
53
46
|
}
|
|
54
|
-
|
|
47
|
+
finish(null);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
finish(null);
|
|
55
51
|
}
|
|
56
|
-
});
|
|
57
|
-
proc.stdin?.end('{"type":"user","message":{"role":"user","content":""}}\n');
|
|
52
|
+
})();
|
|
58
53
|
});
|
|
59
54
|
}
|
|
60
55
|
const MODEL_OPTIONS = [
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { getValidAuth, ensureFreshToken, forceRefreshToken, isTokenValid, AuthCa
|
|
|
10
10
|
import { spawnClaude, killAll, cancelConversation, setVerbose, setDebug, paint, SECTION_COLORS, getCliVersion, getRateLimitWindow } from './claude.js';
|
|
11
11
|
import { ensureModelChoice } from './config.js';
|
|
12
12
|
import { probeClaudeAuth, launchClaudeLogin, waitForClaudeLogin, promptYesNo } from './claudeAuth.js';
|
|
13
|
-
import { checkAndUpdate } from './update.js';
|
|
13
|
+
import { checkAndUpdate, warnIfRuntimeStale } from './update.js';
|
|
14
14
|
import { makeBridgeAccumulator, postSaveTurn } from './accumulator.js';
|
|
15
15
|
import { writeSpool, deleteSpool, listSpool } from './outbox.js';
|
|
16
16
|
import { startTurnTimer, stopTurnTimer, formatElapsed } from './timer.js';
|
|
@@ -673,6 +673,7 @@ async function main() {
|
|
|
673
673
|
return;
|
|
674
674
|
const auth = await getValidAuth(GATEWAY_HTTP, PWA_URL);
|
|
675
675
|
currentAuth = auth;
|
|
676
|
+
await warnIfRuntimeStale();
|
|
676
677
|
await ensureModelChoice();
|
|
677
678
|
await ensureClaudeCodeLogin();
|
|
678
679
|
process.stdout.write('Setting up…');
|
package/dist/update.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { spawn } from 'child_process';
|
|
2
2
|
import { createRequire } from 'module';
|
|
3
|
+
import { readFileSync } from 'fs';
|
|
4
|
+
import { dirname, join } from 'path';
|
|
3
5
|
const { version } = createRequire(import.meta.url)('../package.json');
|
|
4
6
|
function isNewer(a, b) {
|
|
5
7
|
const pa = a.split('.').map(Number);
|
|
@@ -35,3 +37,50 @@ export async function checkAndUpdate() {
|
|
|
35
37
|
return false;
|
|
36
38
|
}
|
|
37
39
|
}
|
|
40
|
+
function bundledSdkVersion() {
|
|
41
|
+
try {
|
|
42
|
+
const req = createRequire(import.meta.url);
|
|
43
|
+
let dir = dirname(req.resolve('@anthropic-ai/claude-agent-sdk'));
|
|
44
|
+
for (let i = 0; i < 5; i++) {
|
|
45
|
+
try {
|
|
46
|
+
const pkg = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf-8'));
|
|
47
|
+
if (pkg.name === '@anthropic-ai/claude-agent-sdk' && typeof pkg.version === 'string')
|
|
48
|
+
return pkg.version;
|
|
49
|
+
}
|
|
50
|
+
catch { }
|
|
51
|
+
const parent = dirname(dir);
|
|
52
|
+
if (parent === dir)
|
|
53
|
+
break;
|
|
54
|
+
dir = parent;
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export async function warnIfRuntimeStale() {
|
|
63
|
+
const installed = bundledSdkVersion();
|
|
64
|
+
if (!installed)
|
|
65
|
+
return null;
|
|
66
|
+
try {
|
|
67
|
+
const res = await fetch('https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk/latest', {
|
|
68
|
+
signal: AbortSignal.timeout(3000),
|
|
69
|
+
});
|
|
70
|
+
if (!res.ok)
|
|
71
|
+
return null;
|
|
72
|
+
const { version: latest } = await res.json();
|
|
73
|
+
if (!latest || !isNewer(latest, installed))
|
|
74
|
+
return null;
|
|
75
|
+
console.log(`\n⚠ The Claude Code runtime bundled with this bridge is out of date (${installed} → ${latest} available).`);
|
|
76
|
+
console.log(' It runs your turns and it decides what "Use Claude Code default" resolves to, so that');
|
|
77
|
+
console.log(' default may be an older model than your account can serve. Pin a model in the next');
|
|
78
|
+
console.log(' prompt to be certain. The runtime ships with the bridge — updating your local `claude`');
|
|
79
|
+
console.log(' will NOT change it. Restart the bridge to pick up a newer release; if this warning');
|
|
80
|
+
console.log(' persists, the newest published bridge itself needs updating — please report it.');
|
|
81
|
+
return { installed, latest };
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1presence/bridge",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.78.0",
|
|
4
4
|
"description": "Run 1Presence on your Mac and use your Claude.ai Pro subscription from any device",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"start": "node dist/index.js"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@anthropic-ai/claude-agent-sdk": "^0.3.
|
|
24
|
+
"@anthropic-ai/claude-agent-sdk": "^0.3.234",
|
|
25
25
|
"ws": "^8.20.0",
|
|
26
26
|
"zod": "^4.0.0"
|
|
27
27
|
},
|