@ouro.bot/cli 0.1.0-alpha.1167 → 0.1.0-alpha.1168
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/changelog.json +6 -0
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/dist/heart/config.js +2 -1
- package/dist/heart/core.js +3 -0
- package/dist/heart/model-limits.js +49 -0
- package/dist/heart/providers/github-copilot.js +19 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/changelog.json
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_note": "This changelog is maintained as part of the PR/version-bump workflow. Agent-curated, not auto-generated. Agents read this file directly via read_file to understand what changed between versions.",
|
|
3
3
|
"versions": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.1.0-alpha.1168",
|
|
6
|
+
"changes": [
|
|
7
|
+
"An agent's context window is read from the provider's own model listing (GitHub Copilot's capabilities.limits.max_context_window_tokens) once per model and cached. The built-in 200k/400k estimates apply only when that read fails, and the log says so (engine.context_window_fallback)."
|
|
8
|
+
]
|
|
9
|
+
},
|
|
4
10
|
{
|
|
5
11
|
"version": "0.1.0-alpha.1167",
|
|
6
12
|
"changes": [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<?xml version="1.0"?>
|
|
2
2
|
<Container version="2">
|
|
3
3
|
<Name>ouro-butler</Name>
|
|
4
|
-
<Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.
|
|
4
|
+
<Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1168</Repository>
|
|
5
5
|
<Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
|
|
6
6
|
<Network>host</Network>
|
|
7
7
|
<Shell>sh</Shell>
|
package/dist/heart/config.js
CHANGED
|
@@ -66,6 +66,7 @@ exports.sessionPath = sessionPath;
|
|
|
66
66
|
exports.logPath = logPath;
|
|
67
67
|
const fs = __importStar(require("fs"));
|
|
68
68
|
const path = __importStar(require("path"));
|
|
69
|
+
const model_limits_1 = require("./model-limits");
|
|
69
70
|
const model_capabilities_1 = require("./model-capabilities");
|
|
70
71
|
const identity_1 = require("./identity");
|
|
71
72
|
const provider_credentials_1 = require("./provider-credentials");
|
|
@@ -288,7 +289,7 @@ function getContextConfig(model) {
|
|
|
288
289
|
: undefined;
|
|
289
290
|
const modelId = model ?? agentConfig.humanFacing?.model;
|
|
290
291
|
return {
|
|
291
|
-
maxTokens: override ?? (modelId ? (0, model_capabilities_1.getModelCapabilities)(modelId).contextWindowTokens : undefined) ?? defaults.maxTokens,
|
|
292
|
+
maxTokens: override ?? (modelId ? (0, model_limits_1.getLearnedContextWindow)(modelId) ?? (0, model_capabilities_1.getModelCapabilities)(modelId).contextWindowTokens : undefined) ?? defaults.maxTokens,
|
|
292
293
|
contextMargin: typeof agentContext?.contextMargin === "number" ? agentContext.contextMargin : defaults.contextMargin,
|
|
293
294
|
};
|
|
294
295
|
}
|
package/dist/heart/core.js
CHANGED
|
@@ -23,6 +23,7 @@ exports.dropReplayedReasoning = dropReplayedReasoning;
|
|
|
23
23
|
exports.runAgent = runAgent;
|
|
24
24
|
const config_1 = require("./config");
|
|
25
25
|
const identity_1 = require("./identity");
|
|
26
|
+
const model_limits_1 = require("./model-limits");
|
|
26
27
|
const source_grounding_1 = require("./source-grounding");
|
|
27
28
|
const shelf_claims_1 = require("./shelf-claims");
|
|
28
29
|
const reply_style_1 = require("./reply-style");
|
|
@@ -188,6 +189,7 @@ async function getProviderRuntime(facing = "human", owner) {
|
|
|
188
189
|
console.error(`\n[fatal] ${msg}\n`);
|
|
189
190
|
throw new Error(msg);
|
|
190
191
|
}
|
|
192
|
+
await (0, model_limits_1.learnContextWindow)(runtime);
|
|
191
193
|
// The shared tool loop supplies approval continuation to every provider adapter.
|
|
192
194
|
return { ...runtime, capabilities: new Set([...runtime.capabilities, "approval-continuation"]) };
|
|
193
195
|
}
|
|
@@ -202,6 +204,7 @@ async function getChainEntryRuntime(entry, owner) {
|
|
|
202
204
|
/* v8 ignore next -- defensive: the registry resolves every provider id @preserve */
|
|
203
205
|
if (!runtime)
|
|
204
206
|
throw new Error(`${entry.provider} (${entry.model}) runtime could not be initialized.`);
|
|
207
|
+
await (0, model_limits_1.learnContextWindow)(runtime);
|
|
205
208
|
return { ...runtime, capabilities: new Set([...runtime.capabilities, "approval-continuation"]) };
|
|
206
209
|
}
|
|
207
210
|
// Called after getProviderRuntime has loaded the same agent.json, so a bad config has already failed the turn.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLearnedContextWindow = getLearnedContextWindow;
|
|
4
|
+
exports.learnContextWindow = learnContextWindow;
|
|
5
|
+
exports.resetLearnedContextWindowsForTests = resetLearnedContextWindowsForTests;
|
|
6
|
+
const runtime_1 = require("../nerves/runtime");
|
|
7
|
+
const learned = new Map();
|
|
8
|
+
const attempted = new Set();
|
|
9
|
+
/** The context window a provider reported for this model, once learned. */
|
|
10
|
+
function getLearnedContextWindow(model) {
|
|
11
|
+
return learned.get(model);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Ask the provider once per model for its real context window and remember it. A provider that cannot say, or a failed
|
|
15
|
+
* read, leaves the static table in model-capabilities.ts as the fallback, and says so in the log.
|
|
16
|
+
*/
|
|
17
|
+
async function learnContextWindow(runtime) {
|
|
18
|
+
const key = runtime.model;
|
|
19
|
+
if (learned.has(key) || attempted.has(key))
|
|
20
|
+
return;
|
|
21
|
+
attempted.add(key);
|
|
22
|
+
if (!runtime.fetchContextWindow)
|
|
23
|
+
return;
|
|
24
|
+
try {
|
|
25
|
+
const tokens = await runtime.fetchContextWindow(AbortSignal.timeout(5000));
|
|
26
|
+
if (tokens === undefined)
|
|
27
|
+
throw new Error("the provider's model list has no context window for this model");
|
|
28
|
+
learned.set(key, tokens);
|
|
29
|
+
(0, runtime_1.emitNervesEvent)({
|
|
30
|
+
component: "engine",
|
|
31
|
+
event: "engine.context_window_learned",
|
|
32
|
+
message: "context window read from the provider",
|
|
33
|
+
meta: { provider: runtime.id, model: key, tokens },
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
(0, runtime_1.emitNervesEvent)({
|
|
38
|
+
level: "warn",
|
|
39
|
+
component: "engine",
|
|
40
|
+
event: "engine.context_window_fallback",
|
|
41
|
+
message: "context window read failed; using the built-in estimate for this model",
|
|
42
|
+
meta: { provider: runtime.id, model: key, reason: error instanceof Error ? error.message : String(error) },
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function resetLearnedContextWindowsForTests() {
|
|
47
|
+
learned.clear();
|
|
48
|
+
attempted.clear();
|
|
49
|
+
}
|
|
@@ -38,6 +38,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.classifyGithubCopilotError = classifyGithubCopilotError;
|
|
40
40
|
exports.withCopilotVisionHeader = withCopilotVisionHeader;
|
|
41
|
+
exports.contextWindowFromModels = contextWindowFromModels;
|
|
41
42
|
exports.createGithubCopilotPooledCaller = createGithubCopilotPooledCaller;
|
|
42
43
|
exports.createGithubCopilotProviderRuntime = createGithubCopilotProviderRuntime;
|
|
43
44
|
const openai_1 = __importDefault(require("openai"));
|
|
@@ -67,6 +68,12 @@ function withCopilotVisionHeader(fetchImpl) {
|
|
|
67
68
|
return send(input, { ...init, headers });
|
|
68
69
|
};
|
|
69
70
|
}
|
|
71
|
+
/** Pull one model's context window out of Copilot's /models listing (`capabilities.limits.max_context_window_tokens`). */
|
|
72
|
+
function contextWindowFromModels(models, modelId) {
|
|
73
|
+
const entry = models.find((m) => m?.id === modelId);
|
|
74
|
+
const tokens = entry?.capabilities?.limits?.max_context_window_tokens;
|
|
75
|
+
return typeof tokens === "number" && Number.isFinite(tokens) && tokens > 0 ? Math.floor(tokens) : undefined;
|
|
76
|
+
}
|
|
70
77
|
/**
|
|
71
78
|
* The agent's account pool for this turn, when `ouro auth` discovered one; null for a single account.
|
|
72
79
|
* Without an owning agent (a daemon-side ping, provider discovery) the pool still switches on a 402 or 429,
|
|
@@ -161,6 +168,12 @@ function createGithubCopilotProviderRuntime(model, config = (0, config_1.getGith
|
|
|
161
168
|
}
|
|
162
169
|
},
|
|
163
170
|
/* v8 ignore stop */
|
|
171
|
+
/* v8 ignore start -- network read: the parsing is tested via contextWindowFromModels @preserve */
|
|
172
|
+
async fetchContextWindow(signal) {
|
|
173
|
+
const page = await callModel(this.client, (turnClient) => turnClient.models.list({ signal }));
|
|
174
|
+
return contextWindowFromModels(page.data, this.model);
|
|
175
|
+
},
|
|
176
|
+
/* v8 ignore stop */
|
|
164
177
|
/* v8 ignore start -- ping: tested via provider-ping.test.ts @preserve */
|
|
165
178
|
async ping(signal) {
|
|
166
179
|
await callModel(this.client, (turnClient) => turnClient.chat.completions.create({ model: this.model, max_tokens: 1, messages: [{ role: "user", content: "ping" }] }, { signal }));
|
|
@@ -220,6 +233,12 @@ function createGithubCopilotProviderRuntime(model, config = (0, config_1.getGith
|
|
|
220
233
|
}
|
|
221
234
|
},
|
|
222
235
|
/* v8 ignore stop */
|
|
236
|
+
/* v8 ignore start -- network read: the parsing is tested via contextWindowFromModels @preserve */
|
|
237
|
+
async fetchContextWindow(signal) {
|
|
238
|
+
const page = await callModel(this.client, (turnClient) => turnClient.models.list({ signal }));
|
|
239
|
+
return contextWindowFromModels(page.data, this.model);
|
|
240
|
+
},
|
|
241
|
+
/* v8 ignore stop */
|
|
223
242
|
/* v8 ignore start -- ping: tested via provider-ping.test.ts @preserve */
|
|
224
243
|
async ping(signal) {
|
|
225
244
|
await callModel(this.client, (turnClient) => turnClient.responses.create({ model: this.model, input: "ping", max_output_tokens: 16 }, { signal }));
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ouro.bot/cli",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.1168",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@ouro.bot/cli",
|
|
9
|
-
"version": "0.1.0-alpha.
|
|
9
|
+
"version": "0.1.0-alpha.1168",
|
|
10
10
|
"bundleDependencies": [
|
|
11
11
|
"@ouro.bot/friends"
|
|
12
12
|
],
|