@openagents-org/agent-launcher 0.2.210 → 0.2.211
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/icons/mimo-code.svg +1 -0
- package/icons/qoder-cn.svg +1 -0
- package/icons/qoder.svg +1 -0
- package/icons/qwen-code.svg +1 -0
- package/package.json +1 -1
- package/registry.json +374 -2
- package/src/adapters/base.js +25 -4
- package/src/adapters/deepseek.js +21 -3
- package/src/adapters/index.js +13 -1
- package/src/adapters/kimi-stream.js +6 -5
- package/src/adapters/mimo-code-runtime.js +266 -0
- package/src/adapters/mimo-code.js +581 -0
- package/src/adapters/opencode.js +21 -16
- package/src/adapters/pi.js +91 -8
- package/src/adapters/qoder-cn.js +24 -0
- package/src/adapters/qoder-runtime.js +611 -0
- package/src/adapters/qoder.js +946 -0
- package/src/adapters/qwen-code-stream.js +735 -0
- package/src/adapters/qwen-code.js +1125 -0
- package/src/agent-login.js +93 -0
- package/src/cli-models.js +45 -2
- package/src/cli.js +94 -0
- package/src/daemon.js +80 -4
- package/src/env.js +3 -0
- package/src/installer.js +49 -17
- package/src/paths.js +21 -0
- package/src/probe.js +44 -1
- package/src/workspace-client.js +12 -1
package/src/adapters/pi.js
CHANGED
|
@@ -129,6 +129,56 @@ class PiCancelledError extends Error {
|
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
+
/**
|
|
133
|
+
* Inline `--append-system-prompt` text longer than this is written to a
|
|
134
|
+
* session file. A single argv entry past ~980 characters is SIGKILL'd on some
|
|
135
|
+
* macOS hosts, and the workspace prompt carries the workspace token.
|
|
136
|
+
*/
|
|
137
|
+
const APPEND_PROMPT_INLINE_MAX = 512;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Return `prompt` unchanged when it is short enough to stay on argv, otherwise
|
|
141
|
+
* write it into `sessionDir` and return that path.
|
|
142
|
+
*
|
|
143
|
+
* The filename is `system-prompt-<sessionId>.md` when `sessionId` is a UUID,
|
|
144
|
+
* and `system-prompt-default.md` otherwise, so a non-UUID id cannot leave
|
|
145
|
+
* `sessionDir`. The write is atomic (temp sibling, mode 0600, rename) and the
|
|
146
|
+
* file stays while the process runs (Pi re-reads it mid-session) and is
|
|
147
|
+
* removed when that process exits or the session is cleared. A write, chmod,
|
|
148
|
+
* or rename failure throws; the long text is never put back on argv.
|
|
149
|
+
*
|
|
150
|
+
* @param {string} prompt
|
|
151
|
+
* @param {string} sessionDir OpenAgents session directory, never the working dir
|
|
152
|
+
* @param {string} [sessionId]
|
|
153
|
+
* @returns {string}
|
|
154
|
+
*/
|
|
155
|
+
/** Where stagePiAppendSystemPrompt writes the prompt for this session. */
|
|
156
|
+
function stagedPromptPath(sessionDir, sessionId) {
|
|
157
|
+
const id = isValidSessionId(sessionId) ? sessionId : 'default';
|
|
158
|
+
return path.join(sessionDir, `system-prompt-${id}.md`);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function stagePiAppendSystemPrompt(prompt, sessionDir, sessionId) {
|
|
162
|
+
if (typeof prompt !== 'string' || prompt.length <= APPEND_PROMPT_INLINE_MAX
|
|
163
|
+
|| typeof sessionDir !== 'string' || !sessionDir) {
|
|
164
|
+
return prompt;
|
|
165
|
+
}
|
|
166
|
+
const dest = stagedPromptPath(sessionDir, sessionId);
|
|
167
|
+
const tmp = `${dest}.${process.pid}.tmp`;
|
|
168
|
+
try {
|
|
169
|
+
fs.mkdirSync(sessionDir, { recursive: true });
|
|
170
|
+
fs.writeFileSync(tmp, prompt, { encoding: 'utf-8', mode: 0o600 });
|
|
171
|
+
fs.chmodSync(tmp, 0o600);
|
|
172
|
+
fs.renameSync(tmp, dest);
|
|
173
|
+
} catch (err) {
|
|
174
|
+
try { fs.unlinkSync(tmp); } catch { /* temp file may not exist */ }
|
|
175
|
+
let detail = (err && err.message) ? String(err.message) : 'unknown error';
|
|
176
|
+
if (detail.includes(prompt)) detail = (err && err.code) ? String(err.code) : 'write failed';
|
|
177
|
+
throw new Error(`Failed to stage the Pi system prompt in ${sessionDir}: ${detail}`);
|
|
178
|
+
}
|
|
179
|
+
return dest;
|
|
180
|
+
}
|
|
181
|
+
|
|
132
182
|
class PiAdapter extends BaseAdapter {
|
|
133
183
|
/**
|
|
134
184
|
* @param {object} opts - BaseAdapter opts plus:
|
|
@@ -239,12 +289,36 @@ class PiAdapter extends BaseAdapter {
|
|
|
239
289
|
}
|
|
240
290
|
|
|
241
291
|
_clearSession(channel) {
|
|
242
|
-
|
|
292
|
+
const sessionId = this._channelSessions[channel];
|
|
293
|
+
if (sessionId) {
|
|
243
294
|
delete this._channelSessions[channel];
|
|
244
295
|
this._saveSessions();
|
|
296
|
+
// The staged prompt holds the workspace token; a cleared session never
|
|
297
|
+
// reads it again. Left alone while a process for this channel runs.
|
|
298
|
+
if (!this._persistentProcs[channel]) {
|
|
299
|
+
this._unlinkStagedPrompt(stagedPromptPath(this._sessionDir, sessionId));
|
|
300
|
+
}
|
|
245
301
|
}
|
|
246
302
|
}
|
|
247
303
|
|
|
304
|
+
_unlinkStagedPrompt(file) {
|
|
305
|
+
if (!file) return;
|
|
306
|
+
try { fs.unlinkSync(file); } catch { /* already gone */ }
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Remove the prompt file a process was started with, once it exits. Skipped
|
|
311
|
+
* when a newer process already owns the channel: a respawn rewrites the
|
|
312
|
+
* same per-session path, and Pi re-reads it during the session.
|
|
313
|
+
*/
|
|
314
|
+
_releaseStagedPrompt(channel, pp) {
|
|
315
|
+
if (!pp || !pp.stagedPrompt) return;
|
|
316
|
+
const current = this._persistentProcs[channel];
|
|
317
|
+
if (current && current !== pp) return;
|
|
318
|
+
this._unlinkStagedPrompt(pp.stagedPrompt);
|
|
319
|
+
pp.stagedPrompt = null;
|
|
320
|
+
}
|
|
321
|
+
|
|
248
322
|
// ------------------------------------------------------------------
|
|
249
323
|
// Binary resolution (mirrors the Claude/Cline adapters tier-for-tier)
|
|
250
324
|
// ------------------------------------------------------------------
|
|
@@ -265,9 +339,8 @@ class PiAdapter extends BaseAdapter {
|
|
|
265
339
|
|
|
266
340
|
/**
|
|
267
341
|
* Resolve a shim/symlink to [nodeBin, jsEntry] so we spawn the JS entry point
|
|
268
|
-
* under a Node we control. On Windows this also
|
|
269
|
-
* `cmd.exe /c
|
|
270
|
-
* --append-system-prompt. Returns null when the target is a native binary.
|
|
342
|
+
* under a Node we control. On Windows this also keeps a `.cmd` launch off
|
|
343
|
+
* `cmd.exe /c`. Returns null when the target is a native binary.
|
|
271
344
|
*/
|
|
272
345
|
_resolveToNodeCmd(binPath) {
|
|
273
346
|
const nodeBin = this._findNodeBin();
|
|
@@ -276,8 +349,9 @@ class PiAdapter extends BaseAdapter {
|
|
|
276
349
|
const cmdDir = path.dirname(path.resolve(binPath));
|
|
277
350
|
// Both npm shim dialects (`%dp0%` and `%~dp0`) are parsed — see
|
|
278
351
|
// parseWindowsCmdShim. A shim we fail to parse falls back to
|
|
279
|
-
// `cmd.exe /c
|
|
280
|
-
//
|
|
352
|
+
// `cmd.exe /c`. Parsing still keeps the `.cmd` launch off cmd.exe.
|
|
353
|
+
// A prompt over 512 characters is a 0600 file under the session dir,
|
|
354
|
+
// and that path is what `--append-system-prompt` receives.
|
|
281
355
|
const shim = parseWindowsCmdShim(fs.readFileSync(binPath, 'utf-8'), cmdDir);
|
|
282
356
|
if (shim && shim.kind === 'script') return [nodeBin, shim.target];
|
|
283
357
|
if (shim && shim.kind === 'exe') return [shim.target];
|
|
@@ -856,6 +930,7 @@ class PiAdapter extends BaseAdapter {
|
|
|
856
930
|
}
|
|
857
931
|
pp.exitCode = code;
|
|
858
932
|
this._teardownProcState(pp, why);
|
|
933
|
+
this._releaseStagedPrompt(channel, pp);
|
|
859
934
|
this._unregisterProc(channel, pp, proc);
|
|
860
935
|
});
|
|
861
936
|
|
|
@@ -1302,10 +1377,13 @@ class PiAdapter extends BaseAdapter {
|
|
|
1302
1377
|
const sessionId = this._sessionIdFor(channel, workingDir);
|
|
1303
1378
|
try { fs.mkdirSync(this._sessionDir, { recursive: true }); } catch {}
|
|
1304
1379
|
|
|
1380
|
+
// A long prompt is a 0600 file in the session dir. The flag receives that
|
|
1381
|
+
// path; short text stays inline. There is no argv fallback on failure.
|
|
1382
|
+
const appendSystemPrompt = stagePiAppendSystemPrompt(systemPrompt, this._sessionDir, sessionId);
|
|
1305
1383
|
const args = buildPiArgs({
|
|
1306
1384
|
sessionDir: this._sessionDir,
|
|
1307
1385
|
sessionId,
|
|
1308
|
-
appendSystemPrompt
|
|
1386
|
+
appendSystemPrompt,
|
|
1309
1387
|
provider: cfg.provider,
|
|
1310
1388
|
model: cfg.model,
|
|
1311
1389
|
thinking: cfg.thinking,
|
|
@@ -1325,7 +1403,11 @@ class PiAdapter extends BaseAdapter {
|
|
|
1325
1403
|
env: this._buildEnv(),
|
|
1326
1404
|
sessionId,
|
|
1327
1405
|
});
|
|
1328
|
-
|
|
1406
|
+
pp.stagedPrompt = appendSystemPrompt !== systemPrompt ? appendSystemPrompt : null;
|
|
1407
|
+
if (pp.spawnError) {
|
|
1408
|
+
this._releaseStagedPrompt(channel, pp);
|
|
1409
|
+
throw new Error(pp.spawnError);
|
|
1410
|
+
}
|
|
1329
1411
|
return pp;
|
|
1330
1412
|
}
|
|
1331
1413
|
|
|
@@ -1508,3 +1590,4 @@ class PiAdapter extends BaseAdapter {
|
|
|
1508
1590
|
|
|
1509
1591
|
module.exports = PiAdapter;
|
|
1510
1592
|
module.exports.PiCancelledError = PiCancelledError;
|
|
1593
|
+
module.exports.stagePiAppendSystemPrompt = stagePiAppendSystemPrompt;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Qoder CLI CN adapter — the China edition of Qoder (qoder.com.cn).
|
|
3
|
+
*
|
|
4
|
+
* The same CLI as QoderAdapter, built under another brand: its own binary
|
|
5
|
+
* (`qoderclicn`), install script, config root (~/.qoder-cn), env prefix
|
|
6
|
+
* (QODERCN_) and account. Flags and the stream-json contract are identical
|
|
7
|
+
* (verified on 1.1.72), so only the edition table changes. It is a separate
|
|
8
|
+
* agent type rather than a region option because install, detection and the
|
|
9
|
+
* sign-in probe all key off the binary, and the two binaries are not
|
|
10
|
+
* interchangeable — each talks only to its own service.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
15
|
+
const QoderAdapter = require('./qoder');
|
|
16
|
+
const { EDITIONS } = require('./qoder-runtime');
|
|
17
|
+
|
|
18
|
+
class QoderCnAdapter extends QoderAdapter {
|
|
19
|
+
static get edition() {
|
|
20
|
+
return EDITIONS.cn;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = QoderCnAdapter;
|