@stevezhou/sisu 0.3.9 → 0.3.11
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 +23 -0
- package/package.json +1 -1
package/dist/runtime/launch.js
CHANGED
|
@@ -8,6 +8,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 = [
|
|
@@ -86,6 +104,9 @@ function writeSisuGrokConfig() {
|
|
|
86
104
|
'[endpoints]',
|
|
87
105
|
`xai_api_base_url = "${runtimeBase}"`,
|
|
88
106
|
'',
|
|
107
|
+
'[agent]',
|
|
108
|
+
'system_prompt_label = "SiSu"',
|
|
109
|
+
'',
|
|
89
110
|
].join('\n');
|
|
90
111
|
const existing = fs_1.default.existsSync(file) ? fs_1.default.readFileSync(file, 'utf8') : '';
|
|
91
112
|
if (!existing || existing.includes('sisu-managed grok-build')) {
|
|
@@ -204,6 +225,7 @@ function sisuGrokBuildEnv() {
|
|
|
204
225
|
email: auth.email || undefined,
|
|
205
226
|
});
|
|
206
227
|
}
|
|
228
|
+
purgeXaiEngineAuth(engine);
|
|
207
229
|
return {
|
|
208
230
|
...env,
|
|
209
231
|
SISU_ACCESS_POINT: '1',
|
|
@@ -214,6 +236,7 @@ function sisuGrokBuildEnv() {
|
|
|
214
236
|
SISU_ACCOUNT_PLAN: auth?.plan_code || '',
|
|
215
237
|
SISU_API_BASE: apiBase,
|
|
216
238
|
SISU_CLIENT_VERSION: client_1.SISU_CLIENT_VERSION,
|
|
239
|
+
GROK_SYSTEM_PROMPT_LABEL: 'SiSu',
|
|
217
240
|
SISU_CONVERSATION_ID: (0, store_1.ensureConversationId)(),
|
|
218
241
|
GROK_XAI_API_BASE_URL: runtime,
|
|
219
242
|
XAI_API_BASE_URL: runtime,
|