@melaya/runner 1.0.95 → 1.0.96
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/assistantHost.py +4 -1
- package/dist/connection.js +33 -2
- package/package.json +1 -1
package/dist/assistantHost.py
CHANGED
|
@@ -237,7 +237,10 @@ def _build_agent():
|
|
|
237
237
|
"phone_ask_user(question): it expands the Melaya tile ON THE PHONE into a reply "
|
|
238
238
|
"card and BLOCKS for the user's typed answer WITHOUT ending your turn, so the run "
|
|
239
239
|
"continues seamlessly the moment they reply. Use it SPARINGLY, for real decisions "
|
|
240
|
-
"only — not routine ones.
|
|
240
|
+
"only — not routine ones. Do NOT call phone_ask_user to cope with repeated tool "
|
|
241
|
+
"ERRORS or because you feel stuck/struggling — that is a failure to REPORT, not a "
|
|
242
|
+
"decision for the user; stop and report what failed instead. Only ask for a genuine "
|
|
243
|
+
"who/which fork. The EXACT-APP rule still holds (a missing app is a stop, "
|
|
241
244
|
"not a substitution). If a feed is algorithmic, use the app's own Search / Explore "
|
|
242
245
|
"to find the right content yourself. Keep going until the task is COMPLETE (e.g. "
|
|
243
246
|
"all N comments posted) or you are genuinely blocked; only then report what you "
|
package/dist/connection.js
CHANGED
|
@@ -77,11 +77,42 @@ export async function connect(opts) {
|
|
|
77
77
|
const localVersion = getLocalSharedVersion();
|
|
78
78
|
if (!localVersion)
|
|
79
79
|
return; // nothing cached yet — let assistant_start do it
|
|
80
|
-
const { ensurePythonEnv } = await import("./pythonEnv.js");
|
|
81
|
-
await ensurePythonEnv(opts.pythonPath, localVersion, (m) => { if (opts.verbose)
|
|
80
|
+
const { ensurePythonEnv, getCertBundlePath } = await import("./pythonEnv.js");
|
|
81
|
+
const envResult = await ensurePythonEnv(opts.pythonPath, localVersion, (m) => { if (opts.verbose)
|
|
82
82
|
console.log(chalk.gray(` [assistant prewarm] ${m}`)); });
|
|
83
83
|
if (opts.verbose)
|
|
84
84
|
console.log(chalk.gray(" [assistant prewarm] ready"));
|
|
85
|
+
// ALSO pre-import the heavy Python stack so the first real run/chat
|
|
86
|
+
// doesn't pay the ~6s cold `import shared.runtime.registry`. Spawn it
|
|
87
|
+
// detached + fire-and-forget with the SAME PYTHONPATH/env a real
|
|
88
|
+
// pipeline spawn uses (see the runner:run handler below) so `shared.*`
|
|
89
|
+
// resolves; this heats the OS file cache + bytecode. Never blocks
|
|
90
|
+
// connect, never throws — swallow everything. Only when a shared
|
|
91
|
+
// bundle exists locally (mirror the ensurePythonEnv guard above).
|
|
92
|
+
if (envResult.ok) {
|
|
93
|
+
try {
|
|
94
|
+
const sharedDir = getSharedDir();
|
|
95
|
+
if (existsSync(sharedDir)) {
|
|
96
|
+
const certBundle = getCertBundlePath();
|
|
97
|
+
const warmEnv = {
|
|
98
|
+
...process.env,
|
|
99
|
+
PYTHONPATH: sharedDir,
|
|
100
|
+
PYTHONIOENCODING: "utf-8",
|
|
101
|
+
PYTHONUTF8: "1",
|
|
102
|
+
...(certBundle ? { SSL_CERT_FILE: certBundle, REQUESTS_CA_BUNDLE: certBundle } : {}),
|
|
103
|
+
};
|
|
104
|
+
const warmChild = spawn(envResult.pythonPath, ["-c", "import shared.runtime.registry"], { env: warmEnv, stdio: "ignore" });
|
|
105
|
+
warmChild.on("error", () => { });
|
|
106
|
+
warmChild.on("exit", (code) => {
|
|
107
|
+
if (code === 0 && opts.verbose) {
|
|
108
|
+
console.log(chalk.gray(" [assistant prewarm] import-warmed"));
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
warmChild.unref();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
catch { /* fire-and-forget — never throw */ }
|
|
115
|
+
}
|
|
85
116
|
}
|
|
86
117
|
catch (e) {
|
|
87
118
|
if (opts.verbose)
|