@openagents-org/agent-launcher 0.2.218 → 0.2.220
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/node_modules/ws/LICENSE +20 -0
- package/node_modules/ws/README.md +548 -0
- package/node_modules/ws/browser.js +8 -0
- package/node_modules/ws/index.js +22 -0
- package/node_modules/ws/lib/buffer-util.js +131 -0
- package/node_modules/ws/lib/constants.js +19 -0
- package/node_modules/ws/lib/event-target.js +292 -0
- package/node_modules/ws/lib/extension.js +203 -0
- package/node_modules/ws/lib/limiter.js +55 -0
- package/node_modules/ws/lib/permessage-deflate.js +528 -0
- package/node_modules/ws/lib/receiver.js +706 -0
- package/node_modules/ws/lib/sender.js +602 -0
- package/node_modules/ws/lib/stream.js +161 -0
- package/node_modules/ws/lib/subprotocol.js +62 -0
- package/node_modules/ws/lib/validation.js +152 -0
- package/node_modules/ws/lib/websocket-server.js +554 -0
- package/node_modules/ws/lib/websocket.js +1393 -0
- package/node_modules/ws/package.json +70 -0
- package/node_modules/ws/wrapper.mjs +21 -0
- package/package.json +5 -2
- package/registry.json +12 -2
- package/src/adapters/claude.js +13 -9
- package/src/adapters/codearts.js +1 -0
- package/src/adapters/codex.js +49 -9
- package/src/adapters/deepseek-runtime.js +6 -2
- package/src/adapters/kimi-stream.js +78 -5
- package/src/adapters/kimi.js +114 -24
- package/src/adapters/mimo-code.js +1 -0
- package/src/adapters/openclaw.js +24 -19
- package/src/adapters/opencode.js +55 -2
- package/src/adapters/utils.js +11 -0
- package/src/daemon.js +4 -2
- package/src/installer.js +206 -36
- package/src/native-build.js +132 -0
- package/src/probe.js +88 -7
- package/src/utils.js +123 -12
package/src/utils.js
CHANGED
|
@@ -22,6 +22,7 @@ const VENDOR_HOSTS = /(^|\.)(openai\.com|moonshot\.ai|deepseek\.com|anthropic\.c
|
|
|
22
22
|
const MODEL_REJECTED =
|
|
23
23
|
/model.{0,60}?(is not available|does not exist|not found|unknown model|invalid model|no such model|not supported)|model_not_found/is;
|
|
24
24
|
|
|
25
|
+
const crypto = require('crypto');
|
|
25
26
|
const { networkErrorText } = require('./adapters/utils');
|
|
26
27
|
|
|
27
28
|
/** One HTTP request. Resolves { status, data } or { error }; never rejects. */
|
|
@@ -119,6 +120,100 @@ function completionResult(res, { isAnthropic, model }) {
|
|
|
119
120
|
}
|
|
120
121
|
}
|
|
121
122
|
|
|
123
|
+
/**
|
|
124
|
+
* The one field the Responses test adds that the Codex CLI does not send
|
|
125
|
+
* (codex-api's ResponsesApiRequest has no such field): it caps what the test
|
|
126
|
+
* costs. An endpoint refusing it says nothing about the agent, so the test
|
|
127
|
+
* asks again without it.
|
|
128
|
+
*/
|
|
129
|
+
const PROBE_ONLY_FIELD = 'max_output_tokens';
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* The Responses API test, sent the way the Codex CLI sends every turn:
|
|
133
|
+
* streamed, `store: false`, `client_metadata`, the input as message items. A
|
|
134
|
+
* relay that refuses one of those ("Unsupported Responses request
|
|
135
|
+
* parameter", param client_metadata) passed a plain chat/completions test
|
|
136
|
+
* and then failed every message; one that only streams failed a non-streamed
|
|
137
|
+
* test and then chatted fine.
|
|
138
|
+
*
|
|
139
|
+
* @returns {Promise<{ res: object, result: object }>} the last raw response and its reading
|
|
140
|
+
*/
|
|
141
|
+
async function requestResponses(url, headers, model) {
|
|
142
|
+
const body = {
|
|
143
|
+
model,
|
|
144
|
+
stream: true,
|
|
145
|
+
input: [{ type: 'message', role: 'user', content: [{ type: 'input_text', text: 'Say hi in 5 words.' }] }],
|
|
146
|
+
store: false,
|
|
147
|
+
client_metadata: { session_id: crypto.randomUUID() },
|
|
148
|
+
[PROBE_ONLY_FIELD]: 16,
|
|
149
|
+
};
|
|
150
|
+
const send = () => requestCompletion(url, {
|
|
151
|
+
headers: { ...headers, Accept: 'text/event-stream' },
|
|
152
|
+
body: JSON.stringify(body),
|
|
153
|
+
});
|
|
154
|
+
const res = await send();
|
|
155
|
+
const { result, refusal } = readResponses(res, model);
|
|
156
|
+
// The field the refusal names, or — when it names none — its text.
|
|
157
|
+
const refused = refusal && (refusal.param ? refusal.param === PROBE_ONLY_FIELD : refusal.text.includes(PROBE_ONLY_FIELD));
|
|
158
|
+
if (!refused) return { res, result };
|
|
159
|
+
delete body[PROBE_ONLY_FIELD];
|
|
160
|
+
const again = await send();
|
|
161
|
+
return { res: again, result: readResponses(again, model).result };
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Read a streamed Responses reply the way the Codex CLI reads it: good once
|
|
166
|
+
* `response.completed` arrives — or `response.incomplete`, the cap this test
|
|
167
|
+
* sets — bad on `response.failed` or an `error` event. A stream that ends
|
|
168
|
+
* before either fails the CLI's turn too ("stream closed before
|
|
169
|
+
* response.completed"), and so does a single JSON body in place of a stream.
|
|
170
|
+
*
|
|
171
|
+
* @returns {{ result: object, refusal: { param: string, text: string } | null }}
|
|
172
|
+
* the reading, and — only for an HTTP error or a failed/error event — what
|
|
173
|
+
* the endpoint refused, whole: the field it names (`param`, '' when it
|
|
174
|
+
* names none) and its full text. Never read off anything else: a stream's
|
|
175
|
+
* response.created event, and a JSON body, echo the request's own fields.
|
|
176
|
+
*/
|
|
177
|
+
function readResponses(res, model) {
|
|
178
|
+
if (res.error) return { result: { success: false, error: res.error }, refusal: null };
|
|
179
|
+
const data = String(res.data == null ? '' : res.data);
|
|
180
|
+
if (res.status >= 400) {
|
|
181
|
+
let param = '';
|
|
182
|
+
try {
|
|
183
|
+
const parsed = JSON.parse(data);
|
|
184
|
+
param = String((parsed.error && parsed.error.param) || parsed.param || '');
|
|
185
|
+
} catch {}
|
|
186
|
+
return { result: { success: false, error: `HTTP ${res.status}: ${data.slice(0, 200)}` }, refusal: { param, text: data } };
|
|
187
|
+
}
|
|
188
|
+
let text = '';
|
|
189
|
+
for (const line of data.split(/\r?\n/)) {
|
|
190
|
+
const m = /^data:\s?(.*)$/.exec(line);
|
|
191
|
+
if (!m) continue;
|
|
192
|
+
let evt;
|
|
193
|
+
try { evt = JSON.parse(m[1]); } catch { continue; }
|
|
194
|
+
const type = evt && evt.type;
|
|
195
|
+
if (type === 'response.output_text.delta' && typeof evt.delta === 'string') {
|
|
196
|
+
text += evt.delta;
|
|
197
|
+
} else if (type === 'response.completed' || type === 'response.incomplete') {
|
|
198
|
+
const result = { success: true, model: (evt.response && evt.response.model) || model || '?', response: text.slice(0, 80) };
|
|
199
|
+
return { result, refusal: null };
|
|
200
|
+
} else if (type === 'response.failed' || type === 'error') {
|
|
201
|
+
const err = (evt.response && evt.response.error) || evt.error || evt;
|
|
202
|
+
// param and code first, so a long message is what the cut drops: the
|
|
203
|
+
// probe reads the refused field off this text (probe.js refusedParam).
|
|
204
|
+
const shown = JSON.stringify({ param: err.param, code: err.code, ...err }).slice(0, 200);
|
|
205
|
+
return {
|
|
206
|
+
result: { success: false, error: `${type}: ${shown}` },
|
|
207
|
+
refusal: { param: String(err.param || ''), text: JSON.stringify(err) },
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if (/^\s*[{[]/.test(data)) {
|
|
212
|
+
return { result: { success: false, error: `Answered with a JSON body, not the event stream the Codex CLI reads: ${data.slice(0, 200)}` }, refusal: null };
|
|
213
|
+
}
|
|
214
|
+
return { result: { success: false, error: `Stream ended before response.completed: ${data.slice(0, 200)}` }, refusal: null };
|
|
215
|
+
}
|
|
216
|
+
|
|
122
217
|
/**
|
|
123
218
|
* Test an LLM connection by sending a minimal inference request.
|
|
124
219
|
*
|
|
@@ -131,8 +226,10 @@ function completionResult(res, { isAnthropic, model }) {
|
|
|
131
226
|
* ANTHROPIC_MODEL), which `env` alone does not say; see agent-model.js.
|
|
132
227
|
* @param {string} [opts.baseUrl] - The endpoint, when the caller knows it from
|
|
133
228
|
* a variable of the agent's own (DEEPSEEK_BASE_URL); see probe.js.
|
|
134
|
-
* @param {'anthropic'|'openai'} [opts.protocol] - The API to speak,
|
|
135
|
-
* agent's config names it (Pi's PI_API_FORMAT
|
|
229
|
+
* @param {'anthropic'|'openai'|'responses'} [opts.protocol] - The API to speak,
|
|
230
|
+
* when the agent's config names it (Pi's PI_API_FORMAT, Codex's
|
|
231
|
+
* CODEX_WIRE_API) rather than its env shape. 'responses' is OpenAI's
|
|
232
|
+
* Responses API, asked the way the Codex CLI asks it (see below).
|
|
136
233
|
* @returns {Promise<{success: boolean, model?: string, response?: string, error?: string}>}
|
|
137
234
|
*/
|
|
138
235
|
async function testLLMConnection(env, opts = {}) {
|
|
@@ -154,7 +251,12 @@ async function testLLMConnection(env, opts = {}) {
|
|
|
154
251
|
? opts.protocol === 'anthropic'
|
|
155
252
|
: hasAnthropicConfig || baseUrl.includes('anthropic');
|
|
156
253
|
|
|
157
|
-
|
|
254
|
+
const isResponses = opts.protocol === 'responses';
|
|
255
|
+
// The Codex CLI calls <base_url>/responses on the URL as configured
|
|
256
|
+
// (adapters/codex.js): an endpoint at /codex answered /codex/responses and
|
|
257
|
+
// 404'd the /codex/v1/responses this used to test.
|
|
258
|
+
if (isResponses) baseUrl = baseUrl.replace(/\/+$/, '');
|
|
259
|
+
else if (!isAnthropic && !baseUrl.endsWith('/v1')) {
|
|
158
260
|
baseUrl += '/v1';
|
|
159
261
|
}
|
|
160
262
|
|
|
@@ -181,7 +283,11 @@ async function testLLMConnection(env, opts = {}) {
|
|
|
181
283
|
}
|
|
182
284
|
} catch {}
|
|
183
285
|
const body = JSON.stringify({
|
|
184
|
-
|
|
286
|
+
// Only for an agent with no model set. claude-sonnet-4-20250514 was the
|
|
287
|
+
// default here and Anthropic retired it on 2026-06-15: the test then
|
|
288
|
+
// failed with a 404 "not_found_error" for a key that works. Any 200 is
|
|
289
|
+
// a pass, so a reply that is all thinking within 32 tokens still counts.
|
|
290
|
+
model: env.ANTHROPIC_MODEL || model || 'claude-sonnet-5-5',
|
|
185
291
|
max_tokens: 32,
|
|
186
292
|
messages: [{ role: 'user', content: 'Say hi in 5 words.' }],
|
|
187
293
|
});
|
|
@@ -208,14 +314,19 @@ async function testLLMConnection(env, opts = {}) {
|
|
|
208
314
|
|
|
209
315
|
let last = null;
|
|
210
316
|
for (const candidate of candidates) {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
317
|
+
let res;
|
|
318
|
+
if (isResponses) {
|
|
319
|
+
({ res, result: last } = await requestResponses(`${baseUrl}/responses`, headers, candidate));
|
|
320
|
+
} else {
|
|
321
|
+
const requestBody = {
|
|
322
|
+
model: candidate,
|
|
323
|
+
messages: [{ role: 'user', content: 'Say hi in 5 words.' }],
|
|
324
|
+
};
|
|
325
|
+
if (hasKimiConfig) requestBody.max_tokens = 32;
|
|
326
|
+
else requestBody.max_completion_tokens = 32;
|
|
327
|
+
res = await requestCompletion(`${baseUrl}/chat/completions`, { headers, body: JSON.stringify(requestBody) });
|
|
328
|
+
last = completionResult(res, { isAnthropic: false, model: candidate });
|
|
329
|
+
}
|
|
219
330
|
if (last.success) return last;
|
|
220
331
|
// Only a model WE picked moves on to the next one. A configured model is
|
|
221
332
|
// sent as configured and its rejection reported as-is.
|