@stevezhou/sisu 0.3.10 → 0.3.12
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/runtime/launch.js +30 -6
- package/dist/tui.js +6 -1
- package/package.json +1 -1
package/dist/runtime/launch.js
CHANGED
|
@@ -3,11 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.RuntimeUnavailable = void 0;
|
|
6
|
+
exports.MIN_PAGER_STAMP = exports.RuntimeUnavailable = void 0;
|
|
7
7
|
exports.assertRuntimeAvailable = assertRuntimeAvailable;
|
|
8
8
|
exports.grokBuildBinaryCandidates = grokBuildBinaryCandidates;
|
|
9
9
|
exports.findGrokBuildBinary = findGrokBuildBinary;
|
|
10
10
|
exports.sisuRuntimeApiBase = sisuRuntimeApiBase;
|
|
11
|
+
exports.purgeXaiEngineAuth = purgeXaiEngineAuth;
|
|
11
12
|
exports.writeSisuGrokConfig = writeSisuGrokConfig;
|
|
12
13
|
exports.migrateGrokScratchToEngine = migrateGrokScratchToEngine;
|
|
13
14
|
exports.purgeChangelogCache = purgeChangelogCache;
|
|
@@ -75,10 +76,27 @@ function findGrokBuildBinary() {
|
|
|
75
76
|
function sisuRuntimeApiBase(apiBase) {
|
|
76
77
|
return (0, adapter_1.openaiCompatUrl)(apiBase).replace(/\/chat\/completions$/, '');
|
|
77
78
|
}
|
|
79
|
+
/** Drop leftover grok.com / auth.x.ai sessions from the pager engine store. */
|
|
80
|
+
function purgeXaiEngineAuth(engine = (0, store_1.sisuEngineHome)()) {
|
|
81
|
+
const file = path_1.default.join(engine, 'auth.json');
|
|
82
|
+
if (!fs_1.default.existsSync(file))
|
|
83
|
+
return file;
|
|
84
|
+
try {
|
|
85
|
+
const raw = fs_1.default.readFileSync(file, 'utf8');
|
|
86
|
+
if (!/auth\.x\.ai|accounts\.x\.ai|grok\.com/i.test(raw))
|
|
87
|
+
return file;
|
|
88
|
+
fs_1.default.writeFileSync(file, '{}\n', { encoding: 'utf8', mode: 0o600 });
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
// missing / busy — next launch retries
|
|
92
|
+
}
|
|
93
|
+
return file;
|
|
94
|
+
}
|
|
78
95
|
function writeSisuGrokConfig() {
|
|
79
96
|
const auth = (0, store_1.readAuth)();
|
|
80
97
|
const engine = (0, store_1.sisuEngineHome)();
|
|
81
98
|
fs_1.default.mkdirSync(engine, { recursive: true, mode: 0o700 });
|
|
99
|
+
purgeXaiEngineAuth(engine);
|
|
82
100
|
const file = path_1.default.join(engine, 'config.toml');
|
|
83
101
|
const runtimeBase = sisuRuntimeApiBase(auth?.api_base || process.env.SISU_API_BASE || store_1.DEFAULT_API_BASE);
|
|
84
102
|
const body = [
|
|
@@ -167,15 +185,17 @@ function pagerStampMeetsRelease(stamped = installedPagerStamp(), release = clien
|
|
|
167
185
|
return false;
|
|
168
186
|
return comparePagerStamp(stamped, release) >= 0;
|
|
169
187
|
}
|
|
170
|
-
/**
|
|
188
|
+
/** First pager that speaks the access-point contract. Host patches may ship ahead of a rebuild. */
|
|
189
|
+
exports.MIN_PAGER_STAMP = '0.3.11';
|
|
190
|
+
/** B-full when the host env flag is on or the installed pager is at least MIN_PAGER_STAMP. */
|
|
171
191
|
function accessPointBfullEnabled() {
|
|
172
|
-
return process.env.SISU_ACCESS_POINT_BFULL === '1' || pagerStampMeetsRelease();
|
|
192
|
+
return process.env.SISU_ACCESS_POINT_BFULL === '1' || pagerStampMeetsRelease(installedPagerStamp(), exports.MIN_PAGER_STAMP);
|
|
173
193
|
}
|
|
174
|
-
/** Installed ~/.sisu/bin pager must be
|
|
194
|
+
/** Installed ~/.sisu/bin pager must be the access-point contract; other paths (SISU_GROK_BIN / cargo) are dev. */
|
|
175
195
|
function pagerStampAllowsSpawn(binary) {
|
|
176
196
|
if (path_1.default.resolve(binary) !== path_1.default.resolve(installedPagerPath()))
|
|
177
197
|
return true;
|
|
178
|
-
return pagerStampMeetsRelease(installedPagerStamp(binary));
|
|
198
|
+
return pagerStampMeetsRelease(installedPagerStamp(binary), exports.MIN_PAGER_STAMP);
|
|
179
199
|
}
|
|
180
200
|
function sisuGrokBuildEnv() {
|
|
181
201
|
const auth = (0, store_1.readAuth)();
|
|
@@ -187,6 +207,10 @@ function sisuGrokBuildEnv() {
|
|
|
187
207
|
delete env.GROK_CODE_XAI_API_KEY;
|
|
188
208
|
delete env.GROK_DEFAULT_MODEL;
|
|
189
209
|
delete env.SISU_TOKEN;
|
|
210
|
+
// Must not set GROK_DISABLE_API_KEY_AUTH: AuthManager.vet_cached hides
|
|
211
|
+
// auth_mode=api_key snapshots, so the pager thinks there is no session
|
|
212
|
+
// and exits 10 (host login) in a loop.
|
|
213
|
+
delete env.GROK_DISABLE_API_KEY_AUTH;
|
|
190
214
|
if (accessPointBfullEnabled()) {
|
|
191
215
|
delete env.XAI_API_KEY;
|
|
192
216
|
env.SISU_TOKEN = auth?.token || '';
|
|
@@ -207,6 +231,7 @@ function sisuGrokBuildEnv() {
|
|
|
207
231
|
email: auth.email || undefined,
|
|
208
232
|
});
|
|
209
233
|
}
|
|
234
|
+
purgeXaiEngineAuth(engine);
|
|
210
235
|
return {
|
|
211
236
|
...env,
|
|
212
237
|
SISU_ACCESS_POINT: '1',
|
|
@@ -227,7 +252,6 @@ function sisuGrokBuildEnv() {
|
|
|
227
252
|
GROK_DISABLE_CLI_CHAT_PROXY: '1',
|
|
228
253
|
GROK_TELEMETRY_ENABLED: '0',
|
|
229
254
|
GROK_CHANGELOG_OFFLINE: '1',
|
|
230
|
-
GROK_DISABLE_API_KEY_AUTH: '1',
|
|
231
255
|
};
|
|
232
256
|
}
|
|
233
257
|
function launchGrokBuildHeadless(prompt, cwd) {
|
package/dist/tui.js
CHANGED
|
@@ -257,7 +257,7 @@ async function runTui(io, deps = {}) {
|
|
|
257
257
|
io.write(`${(0, logo_1.sisuSplash)(columns, true)}\n`);
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
|
-
if (usePager && !deps.pager) {
|
|
260
|
+
if (usePager && (deps.spawnGrokPager || !deps.pager)) {
|
|
261
261
|
const spawnOnce = deps.spawnGrokPager ??
|
|
262
262
|
(() => {
|
|
263
263
|
const grokBin = (0, launch_1.findGrokBuildBinary)();
|
|
@@ -300,12 +300,17 @@ async function runTui(io, deps = {}) {
|
|
|
300
300
|
});
|
|
301
301
|
if (deps.spawnGrokPager || ((0, launch_1.findGrokBuildBinary)() && process.stdout.isTTY)) {
|
|
302
302
|
// Login handoff: pager exits 10 → host web login → respawn.
|
|
303
|
+
// If a session is already on disk, do not mint another device code.
|
|
303
304
|
while (true) {
|
|
304
305
|
const code = await spawnOnce();
|
|
305
306
|
if (code === null)
|
|
306
307
|
break;
|
|
307
308
|
if (code !== exports.SISU_LOGIN_EXIT_CODE)
|
|
308
309
|
return code;
|
|
310
|
+
if (auth()) {
|
|
311
|
+
io.write('sisu: session already saved; not opening another login page.\n');
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
309
314
|
try {
|
|
310
315
|
const email = await startWebLogin((line) => io.write(`${line}\n`));
|
|
311
316
|
io.write(`logged in as ${email}\n`);
|