open-agents-ai 0.103.41 → 0.103.43
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/index.js +51 -34
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12297,9 +12297,9 @@ async function handleCmd(cmd) {
|
|
|
12297
12297
|
if (!peerId) { writeResp(id, { ok: false, output: 'target_peer is required' }); return; }
|
|
12298
12298
|
dlog('invoke_capability: peer=' + peerId.slice(0, 20) + ' cap=' + capability);
|
|
12299
12299
|
try {
|
|
12300
|
-
// Wrap in a
|
|
12301
|
-
const INVOKE_TIMEOUT =
|
|
12302
|
-
const invokePromise = nexus.invokeCapability(peerId, capability, typeof input === 'string' ? { prompt: input } : input, { stream: false, maxDurationMs:
|
|
12300
|
+
// Wrap in a 300s timeout \u2014 remote API inference (Chutes, etc.) can take 60-180s for large models
|
|
12301
|
+
const INVOKE_TIMEOUT = 300_000;
|
|
12302
|
+
const invokePromise = nexus.invokeCapability(peerId, capability, typeof input === 'string' ? { prompt: input } : input, { stream: false, maxDurationMs: 240000 });
|
|
12303
12303
|
const timeoutPromise = new Promise((_, reject) => setTimeout(() => reject(new Error('invoke_capability timed out after ' + (INVOKE_TIMEOUT / 1000) + 's (client-side timeout)')), INVOKE_TIMEOUT));
|
|
12304
12304
|
const result = await Promise.race([invokePromise, timeoutPromise]);
|
|
12305
12305
|
dlog('invoke_capability: SUCCESS');
|
|
@@ -12349,8 +12349,8 @@ async function handleCmd(cmd) {
|
|
|
12349
12349
|
// Direct invoke on specified peer
|
|
12350
12350
|
dlog('remote_infer: invoking ' + riCapName + ' on explicit peer ' + riTargetPeer.slice(0, 20));
|
|
12351
12351
|
try {
|
|
12352
|
-
var RI_TIMEOUT =
|
|
12353
|
-
var riInvokeP = nexus.invokeCapability(riTargetPeer, riCapName, riData, { stream: false, maxDurationMs:
|
|
12352
|
+
var RI_TIMEOUT = 300000; // 5 min \u2014 remote APIs (Chutes, etc.) can be slow for large models
|
|
12353
|
+
var riInvokeP = nexus.invokeCapability(riTargetPeer, riCapName, riData, { stream: false, maxDurationMs: 240000 });
|
|
12354
12354
|
var riTimeoutP = new Promise(function(_, reject) { setTimeout(function() { reject(new Error('remote_infer timed out after ' + (RI_TIMEOUT / 1000) + 's')); }, RI_TIMEOUT); });
|
|
12355
12355
|
var riResult = await Promise.race([riInvokeP, riTimeoutP]);
|
|
12356
12356
|
dlog('remote_infer: SUCCESS (explicit peer)');
|
|
@@ -12378,8 +12378,8 @@ async function handleCmd(cmd) {
|
|
|
12378
12378
|
var rPid = riCandidates[ri];
|
|
12379
12379
|
dlog('remote_infer: trying peer ' + rPid.slice(0, 20) + '...');
|
|
12380
12380
|
try {
|
|
12381
|
-
var PEER_INVOKE_TIMEOUT =
|
|
12382
|
-
var specInvoke = nexus.invokeCapability(rPid, riCapName, riData, { stream: false, maxDurationMs:
|
|
12381
|
+
var PEER_INVOKE_TIMEOUT = 180000; // 3 min per peer \u2014 remote API inference can be slow
|
|
12382
|
+
var specInvoke = nexus.invokeCapability(rPid, riCapName, riData, { stream: false, maxDurationMs: 150000 });
|
|
12383
12383
|
var specTimeout = new Promise(function(_, reject) {
|
|
12384
12384
|
setTimeout(function() { reject(new Error('peer invoke timeout')); }, PEER_INVOKE_TIMEOUT);
|
|
12385
12385
|
});
|
|
@@ -12698,7 +12698,7 @@ async function handleCmd(cmd) {
|
|
|
12698
12698
|
} catch { /* offline \u2014 use zero rates */ }
|
|
12699
12699
|
|
|
12700
12700
|
// Build pricing menu \u2014 match local models to market rates
|
|
12701
|
-
const margin = parseFloat(args.margin || '0
|
|
12701
|
+
const margin = parseFloat(args.margin || '0'); // default free \u2014 set margin > 0 to enable x402 pricing
|
|
12702
12702
|
const pricingMenu = [];
|
|
12703
12703
|
|
|
12704
12704
|
for (const model of models) {
|
|
@@ -12837,6 +12837,7 @@ async function handleCmd(cmd) {
|
|
|
12837
12837
|
method: 'POST',
|
|
12838
12838
|
headers: chatHeaders,
|
|
12839
12839
|
body: JSON.stringify(chatBody),
|
|
12840
|
+
signal: AbortSignal.timeout(210000), // 3.5 min \u2014 upstream API may be slow
|
|
12840
12841
|
});
|
|
12841
12842
|
genData = await genResp.json();
|
|
12842
12843
|
dlog('expose: ollama response keys=' + Object.keys(genData).join(',') + ' choices=' + (genData.choices ? genData.choices.length : 0));
|
|
@@ -12879,6 +12880,7 @@ async function handleCmd(cmd) {
|
|
|
12879
12880
|
messages: [{ role: 'user', content: flatPrompt }],
|
|
12880
12881
|
stream: false,
|
|
12881
12882
|
}),
|
|
12883
|
+
signal: AbortSignal.timeout(210000), // 3.5 min
|
|
12882
12884
|
});
|
|
12883
12885
|
genData = await genResp.json();
|
|
12884
12886
|
var ptChoices = genData.choices || [];
|
|
@@ -12905,6 +12907,7 @@ async function handleCmd(cmd) {
|
|
|
12905
12907
|
prompt: flatPrompt,
|
|
12906
12908
|
stream: false,
|
|
12907
12909
|
}),
|
|
12910
|
+
signal: AbortSignal.timeout(210000), // 3.5 min
|
|
12908
12911
|
});
|
|
12909
12912
|
genData = await genResp.json();
|
|
12910
12913
|
output = genData.response || '';
|
|
@@ -27783,6 +27786,9 @@ var init_expose = __esm({
|
|
|
27783
27786
|
super();
|
|
27784
27787
|
this.options = options;
|
|
27785
27788
|
this._kind = options.kind;
|
|
27789
|
+
if (options.kind === "custom" && !options.targetUrl) {
|
|
27790
|
+
throw new Error('ExposeGateway: targetUrl is required when kind is "custom"');
|
|
27791
|
+
}
|
|
27786
27792
|
this._targetUrl = options.targetUrl ?? DEFAULT_TARGETS[options.kind];
|
|
27787
27793
|
this._stateDir = options.stateDir ?? null;
|
|
27788
27794
|
this._fullAccess = options.fullAccess ?? false;
|
|
@@ -28476,9 +28482,12 @@ ${this.formatConnectionInfo()}`);
|
|
|
28476
28482
|
super();
|
|
28477
28483
|
this._nexusTool = nexusTool;
|
|
28478
28484
|
this._kind = options.kind;
|
|
28485
|
+
if (options.kind === "custom" && !options.targetUrl) {
|
|
28486
|
+
throw new Error('ExposeP2PGateway: targetUrl is required when kind is "custom"');
|
|
28487
|
+
}
|
|
28479
28488
|
this._targetUrl = options.targetUrl ?? DEFAULT_TARGETS[options.kind];
|
|
28480
28489
|
this._stateDir = options.stateDir ?? null;
|
|
28481
|
-
this._margin = options.margin ?? 0
|
|
28490
|
+
this._margin = options.margin ?? 0;
|
|
28482
28491
|
this._passthrough = options.passthrough ?? false;
|
|
28483
28492
|
this._loadbalance = options.loadbalance ?? false;
|
|
28484
28493
|
this._endpointAuth = options.endpointAuth;
|
|
@@ -34564,18 +34573,17 @@ async function handleEndpoint(arg, ctx, local = false) {
|
|
|
34564
34573
|
if (ctx.hasActiveTask?.()) {
|
|
34565
34574
|
ctx.abortActiveTask?.();
|
|
34566
34575
|
}
|
|
34567
|
-
|
|
34568
|
-
|
|
34569
|
-
const defaultSettings = { backendUrl: defaultUrl, backendType: "ollama", apiKey: void 0 };
|
|
34576
|
+
ctx.setEndpoint(DEFAULT_CONFIG.backendUrl, DEFAULT_CONFIG.backendType, void 0);
|
|
34577
|
+
const defaultSettings = { backendUrl: DEFAULT_CONFIG.backendUrl, backendType: DEFAULT_CONFIG.backendType, apiKey: void 0 };
|
|
34570
34578
|
if (local) {
|
|
34571
34579
|
ctx.saveLocalSettings(defaultSettings);
|
|
34572
34580
|
} else {
|
|
34573
|
-
setConfigValue("backendUrl",
|
|
34574
|
-
setConfigValue("backendType",
|
|
34581
|
+
setConfigValue("backendUrl", DEFAULT_CONFIG.backendUrl);
|
|
34582
|
+
setConfigValue("backendType", DEFAULT_CONFIG.backendType);
|
|
34575
34583
|
ctx.saveSettings(defaultSettings);
|
|
34576
34584
|
}
|
|
34577
34585
|
process.stdout.write(`
|
|
34578
|
-
${c2.green("\u2714")} Endpoint reset to local Ollama (${
|
|
34586
|
+
${c2.green("\u2714")} Endpoint reset to local Ollama (${DEFAULT_CONFIG.backendUrl})
|
|
34579
34587
|
`);
|
|
34580
34588
|
if (ctx.hasActiveTask?.()) {
|
|
34581
34589
|
renderWarning("Active task aborted \u2014 send a new prompt to continue.");
|
|
@@ -45959,11 +45967,11 @@ async function startInteractive(config, repoPath) {
|
|
|
45959
45967
|
let dreamEngine = null;
|
|
45960
45968
|
let blessEngine = null;
|
|
45961
45969
|
let dmnEngine = null;
|
|
45962
|
-
const snrEngine = new SNREngine(
|
|
45970
|
+
const snrEngine = new SNREngine(currentConfig, repoRoot);
|
|
45963
45971
|
const emotionEngine = new EmotionEngine({
|
|
45964
|
-
backendUrl:
|
|
45965
|
-
model:
|
|
45966
|
-
apiKey:
|
|
45972
|
+
backendUrl: currentConfig.backendUrl,
|
|
45973
|
+
model: currentConfig.model,
|
|
45974
|
+
apiKey: currentConfig.apiKey,
|
|
45967
45975
|
onEmotionUpdate: (state) => {
|
|
45968
45976
|
statusBar.setEmotion(state.emoji, state.label);
|
|
45969
45977
|
}
|
|
@@ -46121,7 +46129,7 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
46121
46129
|
const allCompletions = [.../* @__PURE__ */ new Set([...BUILTIN_COMMANDS, ...discoveredSkillNames])].sort();
|
|
46122
46130
|
let cachedModelNames = [];
|
|
46123
46131
|
function refreshModelCache() {
|
|
46124
|
-
fetchModels(
|
|
46132
|
+
fetchModels(currentConfig.backendUrl, currentConfig.apiKey).then((models) => {
|
|
46125
46133
|
cachedModelNames = models.map((m) => m.name);
|
|
46126
46134
|
}).catch(() => {
|
|
46127
46135
|
});
|
|
@@ -46232,24 +46240,24 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
46232
46240
|
(async () => {
|
|
46233
46241
|
if (!isResumed && !isFirstRun()) {
|
|
46234
46242
|
try {
|
|
46235
|
-
const available = await isModelAvailable(
|
|
46236
|
-
if (!available &&
|
|
46243
|
+
const available = await isModelAvailable(currentConfig);
|
|
46244
|
+
if (!available && currentConfig.backendType === "ollama") {
|
|
46237
46245
|
writeContent(() => {
|
|
46238
|
-
renderWarning(`Model "${
|
|
46246
|
+
renderWarning(`Model "${currentConfig.model}" not available. Use /model to pick one.`);
|
|
46239
46247
|
});
|
|
46240
46248
|
}
|
|
46241
46249
|
} catch {
|
|
46242
46250
|
}
|
|
46243
46251
|
}
|
|
46244
|
-
if (
|
|
46252
|
+
if (currentConfig.backendType === "ollama" && !currentConfig.model.startsWith("open-agents-")) {
|
|
46245
46253
|
try {
|
|
46246
|
-
const expandResult = await ensureExpandedContext(
|
|
46254
|
+
const expandResult = await ensureExpandedContext(currentConfig.model, currentConfig.backendUrl);
|
|
46247
46255
|
if (expandResult.created) {
|
|
46248
46256
|
config = { ...config, model: expandResult.model };
|
|
46249
46257
|
currentConfig = { ...currentConfig, model: expandResult.model };
|
|
46250
46258
|
statusBar.setModelName(expandResult.model);
|
|
46251
46259
|
writeContent(() => renderInfo(`Created expanded context model: ${expandResult.model} (${expandResult.contextLabel}, ${expandResult.numCtx} tokens)`));
|
|
46252
|
-
} else if (expandResult.model !==
|
|
46260
|
+
} else if (expandResult.model !== currentConfig.model) {
|
|
46253
46261
|
config = { ...config, model: expandResult.model };
|
|
46254
46262
|
currentConfig = { ...currentConfig, model: expandResult.model };
|
|
46255
46263
|
statusBar.setModelName(expandResult.model);
|
|
@@ -46260,19 +46268,19 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
46260
46268
|
}
|
|
46261
46269
|
if (!isResumed) {
|
|
46262
46270
|
try {
|
|
46263
|
-
const baseUrl = normalizeBaseUrl(
|
|
46264
|
-
const prov = detectProvider(
|
|
46271
|
+
const baseUrl = normalizeBaseUrl(currentConfig.backendUrl);
|
|
46272
|
+
const prov = detectProvider(currentConfig.backendUrl);
|
|
46265
46273
|
const healthUrl = `${baseUrl}${prov.modelsPath}`;
|
|
46266
46274
|
const headers = {};
|
|
46267
|
-
if (
|
|
46268
|
-
headers["Authorization"] = `Bearer ${
|
|
46275
|
+
if (currentConfig.apiKey)
|
|
46276
|
+
headers["Authorization"] = `Bearer ${currentConfig.apiKey}`;
|
|
46269
46277
|
const resp = await fetch(healthUrl, { headers, signal: AbortSignal.timeout(1e4) });
|
|
46270
46278
|
if (!resp.ok)
|
|
46271
46279
|
throw new Error(`HTTP ${resp.status}`);
|
|
46272
46280
|
} catch {
|
|
46273
|
-
const prov = detectProvider(
|
|
46281
|
+
const prov = detectProvider(currentConfig.backendUrl);
|
|
46274
46282
|
writeContent(() => {
|
|
46275
|
-
renderWarning(`Cannot reach ${prov.label} at ${
|
|
46283
|
+
renderWarning(`Cannot reach ${prov.label} at ${currentConfig.backendUrl}`);
|
|
46276
46284
|
if (prov.id === "ollama") {
|
|
46277
46285
|
renderInfo("Use /endpoint http://127.0.0.1:11434 to auto-install & start Ollama.");
|
|
46278
46286
|
}
|
|
@@ -47132,9 +47140,18 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
47132
47140
|
throw new Error("P2P mesh is already running");
|
|
47133
47141
|
let models = [];
|
|
47134
47142
|
try {
|
|
47135
|
-
const
|
|
47143
|
+
const meshProvider = detectProvider(commandCtx.config.backendUrl);
|
|
47144
|
+
const meshBaseUrl = normalizeBaseUrl(commandCtx.config.backendUrl);
|
|
47145
|
+
const meshHeaders = {};
|
|
47146
|
+
if (commandCtx.config.apiKey)
|
|
47147
|
+
meshHeaders["Authorization"] = `Bearer ${commandCtx.config.apiKey}`;
|
|
47148
|
+
const resp = await fetch(`${meshBaseUrl}${meshProvider.modelsPath}`, { headers: meshHeaders });
|
|
47136
47149
|
const data = await resp.json();
|
|
47137
|
-
|
|
47150
|
+
if (data.models) {
|
|
47151
|
+
models = data.models.map((m) => m.name);
|
|
47152
|
+
} else if (data.data) {
|
|
47153
|
+
models = data.data.map((m) => m.id ?? m.name ?? "unknown");
|
|
47154
|
+
}
|
|
47138
47155
|
} catch {
|
|
47139
47156
|
}
|
|
47140
47157
|
peerMesh = new PeerMesh({
|
package/package.json
CHANGED