@ouro.bot/cli 0.1.0-alpha.1011 → 0.1.0-alpha.1014
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 +12 -0
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/dist/heart/auth/auth-flow.js +60 -0
- package/dist/heart/core.js +5 -3
- package/dist/heart/optional-packages.js +71 -0
- package/dist/heart/provider-credentials.js +2 -2
- package/dist/heart/providers/account-pool.js +549 -0
- package/dist/heart/providers/azure.js +4 -1
- package/dist/heart/providers/github-copilot.js +71 -6
- package/dist/heart/quota/fleet-readings.js +222 -0
- package/dist/heart/quota/tranche.js +59 -0
- package/dist/mailroom/core.js +2 -1
- package/dist/repertoire/stripe-client.js +2 -1
- package/dist/senses/mail-entry.js +5 -3
- package/dist/senses/shepherd/owner-notice.js +2 -1
- package/dist/senses/teams-entry.js +5 -3
- package/npm-shrinkwrap.json +174 -34
- package/package.json +14 -12
package/changelog.json
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
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.1014",
|
|
6
|
+
"changes": [
|
|
7
|
+
"The Teams, Azure, Stripe and mail SDKs are optional packages. A small host can leave them out with npm config set omit optional (about 97 MB and 138 packages of the 220 MB install); the core harness, providers, vault and other senses run without them, and a feature that needs a missing one says which package and how to restore it. The edge benchmark now measures that install."
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"version": "0.1.0-alpha.1013",
|
|
12
|
+
"changes": [
|
|
13
|
+
"github-copilot can bill a discovered pool of Copilot accounts: with accountPool in agent.json, ouro auth discovers every eligible account signed in to the Copilot app (each checked on its own host), and the runtime fills them by quota tranche (30/60/90/100% used), moves to the next account at once on a 402 or 429 and retries that request once, logs every move to state/account-switches.jsonl, and publishes the agent's burn (summed across its processes) to the fleet gist."
|
|
14
|
+
]
|
|
15
|
+
},
|
|
4
16
|
{
|
|
5
17
|
"version": "0.1.0-alpha.1011",
|
|
6
18
|
"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.1014</Repository>
|
|
5
5
|
<Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
|
|
6
6
|
<Network>host</Network>
|
|
7
7
|
<Shell>sh</Shell>
|
|
@@ -37,6 +37,8 @@ exports.readAgentConfigForAgent = readAgentConfigForAgent;
|
|
|
37
37
|
exports.writeAgentProviderSelection = writeAgentProviderSelection;
|
|
38
38
|
exports.storeProviderCredentials = storeProviderCredentials;
|
|
39
39
|
exports.writeAgentModel = writeAgentModel;
|
|
40
|
+
exports.readAccountPoolSettings = readAccountPoolSettings;
|
|
41
|
+
exports.collectGithubCopilotPoolCredentials = collectGithubCopilotPoolCredentials;
|
|
40
42
|
exports.collectRuntimeAuthCredentials = collectRuntimeAuthCredentials;
|
|
41
43
|
exports.resolveHatchCredentials = resolveHatchCredentials;
|
|
42
44
|
exports.runRuntimeAuthFlow = runRuntimeAuthFlow;
|
|
@@ -50,6 +52,7 @@ const identity_1 = require("../identity");
|
|
|
50
52
|
const migrate_config_1 = require("../migrate-config");
|
|
51
53
|
const provider_models_1 = require("../provider-models");
|
|
52
54
|
const agent_presentation_1 = require("../../senses/shepherd/agent-presentation");
|
|
55
|
+
const account_pool_1 = require("../providers/account-pool");
|
|
53
56
|
const provider_credentials_1 = require("../provider-credentials");
|
|
54
57
|
const vault_unlock_1 = require("../../repertoire/vault-unlock");
|
|
55
58
|
const ANTHROPIC_SETUP_TOKEN_PREFIX = "sk-ant-oat01-";
|
|
@@ -274,6 +277,60 @@ function validateAnthropicToken(token) {
|
|
|
274
277
|
}
|
|
275
278
|
return trimmed;
|
|
276
279
|
}
|
|
280
|
+
/** The agent's `accountPool` settings, or null when it has none (or its bundle can't be read here). */
|
|
281
|
+
function readAccountPoolSettings(agentName, bundlesRoot) {
|
|
282
|
+
try {
|
|
283
|
+
const settings = readAgentConfigForAgent(agentName, bundlesRoot).config.accountPool;
|
|
284
|
+
return settings && typeof settings === "object" ? settings : null;
|
|
285
|
+
}
|
|
286
|
+
catch {
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Discover the agent's Copilot account pool: every eligible account signed in to the Copilot app, each
|
|
292
|
+
* checked on its own host. The first account is also the single-account credential, so older runtimes
|
|
293
|
+
* keep working.
|
|
294
|
+
*/
|
|
295
|
+
async function collectGithubCopilotPoolCredentials(input, settings, deps) {
|
|
296
|
+
/* v8 ignore next -- tests always inject spawnSync; the default is for production @preserve */
|
|
297
|
+
const spawnSync = deps.spawnSync ?? child_process_1.spawnSync;
|
|
298
|
+
writeAuthProgress(input, "discovering the Copilot accounts signed in on this machine...");
|
|
299
|
+
const discovery = await (0, account_pool_1.discoverAccountPool)(settings, { spawnSync, homeDir: deps.homeDir });
|
|
300
|
+
for (const skipped of discovery.skipped)
|
|
301
|
+
writeAuthProgress(input, `skipped ${skipped.key}: ${skipped.reason}`);
|
|
302
|
+
const [first] = discovery.accounts;
|
|
303
|
+
if (!first) {
|
|
304
|
+
throw new Error(`No eligible Copilot account is signed in on this machine for ${input.agentName}. Sign one in to the Copilot app and the GitHub CLI (\`gh auth login --hostname <host>\`), then retry.`);
|
|
305
|
+
}
|
|
306
|
+
const credentials = {
|
|
307
|
+
githubToken: first.githubToken,
|
|
308
|
+
baseUrl: first.baseUrl,
|
|
309
|
+
accountPool: (0, account_pool_1.serializeAccountPool)(discovery.accounts),
|
|
310
|
+
};
|
|
311
|
+
const fleet = settings.fleet;
|
|
312
|
+
if (fleet?.gistId) {
|
|
313
|
+
const result = spawnSync("gh", ["auth", "token", "--hostname", "github.com", ...(fleet.user ? ["--user", fleet.user] : [])], { encoding: "utf8" });
|
|
314
|
+
const token = result.status === 0 && result.stdout ? String(result.stdout).trim() : "";
|
|
315
|
+
if (token) {
|
|
316
|
+
credentials.fleetGistToken = token;
|
|
317
|
+
credentials.fleetGistId = fleet.gistId;
|
|
318
|
+
if (fleet.machine)
|
|
319
|
+
credentials.fleetMachine = fleet.machine;
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
writeAuthProgress(input, "no github.com token for the fleet gist; burn publishing stays off");
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
writeAuthProgress(input, `account pool: ${discovery.accounts.map(account_pool_1.accountKey).join(", ")}`);
|
|
326
|
+
(0, runtime_1.emitNervesEvent)({
|
|
327
|
+
component: "daemon",
|
|
328
|
+
event: "daemon.auth_account_pool",
|
|
329
|
+
message: "discovered the github-copilot account pool for runtime auth",
|
|
330
|
+
meta: { agentName: input.agentName, accounts: discovery.accounts.map(account_pool_1.accountKey), fleet: Boolean(credentials.fleetGistToken) },
|
|
331
|
+
});
|
|
332
|
+
return credentials;
|
|
333
|
+
}
|
|
277
334
|
async function collectRuntimeAuthCredentials(input, deps) {
|
|
278
335
|
const spawnSync = deps.spawnSync ?? child_process_1.spawnSync;
|
|
279
336
|
const homeDir = deps.homeDir ?? os.homedir();
|
|
@@ -292,6 +349,9 @@ async function collectRuntimeAuthCredentials(input, deps) {
|
|
|
292
349
|
};
|
|
293
350
|
}
|
|
294
351
|
if (input.provider === "github-copilot") {
|
|
352
|
+
const poolSettings = readAccountPoolSettings(input.agentName, deps.bundlesRoot);
|
|
353
|
+
if (poolSettings)
|
|
354
|
+
return collectGithubCopilotPoolCredentials(input, poolSettings, deps);
|
|
295
355
|
let token = process.env.GH_TOKEN?.trim() || process.env.GITHUB_TOKEN?.trim() || "";
|
|
296
356
|
let ghInstalled = true;
|
|
297
357
|
if (!token) {
|
package/dist/heart/core.js
CHANGED
|
@@ -121,7 +121,7 @@ async function getProviderRuntimeFingerprint(facing, owner) {
|
|
|
121
121
|
}
|
|
122
122
|
function createProviderRegistry() {
|
|
123
123
|
return {
|
|
124
|
-
resolve(provider, model, credential) {
|
|
124
|
+
resolve(provider, model, credential, owner) {
|
|
125
125
|
const providerConfig = { ...credential.config, ...credential.credentials };
|
|
126
126
|
switch (provider) {
|
|
127
127
|
case "azure":
|
|
@@ -133,7 +133,7 @@ function createProviderRegistry() {
|
|
|
133
133
|
case "openai-codex":
|
|
134
134
|
return (0, openai_codex_1.createOpenAICodexProviderRuntime)(model, providerConfig);
|
|
135
135
|
case "github-copilot":
|
|
136
|
-
return (0, github_copilot_1.createGithubCopilotProviderRuntime)(model, providerConfig);
|
|
136
|
+
return (0, github_copilot_1.createGithubCopilotProviderRuntime)(model, providerConfig, owner);
|
|
137
137
|
case "openai-compatible":
|
|
138
138
|
case "openai-compatible-gemini":
|
|
139
139
|
return (0, openai_compatible_1.createOpenAICompatibleProviderRuntime)(provider, model, providerConfig);
|
|
@@ -148,7 +148,9 @@ async function getProviderRuntime(facing = "human", owner) {
|
|
|
148
148
|
const { binding, fingerprint, credential } = await getProviderRuntimeFingerprint(facing, scope);
|
|
149
149
|
const cached = _providerRuntimeFactories[facing];
|
|
150
150
|
if (!cached || cached.fingerprint !== fingerprint) {
|
|
151
|
-
const
|
|
151
|
+
const agentName = scope?.agentName ?? (0, identity_2.getAgentName)();
|
|
152
|
+
const runtimeOwner = { agentName, agentRoot: scope?.agentRoot ?? (0, identity_2.getAgentRoot)(agentName) };
|
|
153
|
+
const create = () => createProviderRegistry().resolve(binding.provider, binding.model, credential, runtimeOwner);
|
|
152
154
|
runtime = create();
|
|
153
155
|
_providerRuntimeFactories[facing] = runtime ? { fingerprint, create } : null;
|
|
154
156
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OptionalPackageMissingError = exports.OPTIONAL_PACKAGES = void 0;
|
|
4
|
+
exports.missingOptionalPackage = missingOptionalPackage;
|
|
5
|
+
exports.importOptional = importOptional;
|
|
6
|
+
exports.describeStartupError = describeStartupError;
|
|
7
|
+
const runtime_1 = require("../nerves/runtime");
|
|
8
|
+
/**
|
|
9
|
+
* Product SDKs listed in package.json optionalDependencies. npm installs them by default; a small
|
|
10
|
+
* host can leave them out with `npm install --omit=optional` (about 97 MB and 138 packages), and
|
|
11
|
+
* only the feature that needs one stops working.
|
|
12
|
+
*/
|
|
13
|
+
exports.OPTIONAL_PACKAGES = [
|
|
14
|
+
"@azure/identity",
|
|
15
|
+
"@azure/storage-blob",
|
|
16
|
+
"@microsoft/teams.api",
|
|
17
|
+
"@microsoft/teams.apps",
|
|
18
|
+
"@microsoft/teams.cards",
|
|
19
|
+
"@microsoft/teams.common",
|
|
20
|
+
"@microsoft/teams.dev",
|
|
21
|
+
"@microsoft/teams.graph",
|
|
22
|
+
"mailparser",
|
|
23
|
+
"smtp-server",
|
|
24
|
+
"stripe",
|
|
25
|
+
];
|
|
26
|
+
class OptionalPackageMissingError extends Error {
|
|
27
|
+
packageName;
|
|
28
|
+
feature;
|
|
29
|
+
constructor(packageName, feature) {
|
|
30
|
+
super(`${feature} needs ${packageName}, an optional package this install left out (npm --omit=optional). ` +
|
|
31
|
+
"Reinstall @ouro.bot/cli without --omit=optional to use it.");
|
|
32
|
+
this.packageName = packageName;
|
|
33
|
+
this.feature = feature;
|
|
34
|
+
this.name = "OptionalPackageMissingError";
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.OptionalPackageMissingError = OptionalPackageMissingError;
|
|
38
|
+
/** The optional package an error says is missing, or null for any other error (including a missing file inside a package). */
|
|
39
|
+
function missingOptionalPackage(error) {
|
|
40
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
41
|
+
return exports.OPTIONAL_PACKAGES.find((name) => message.includes(`Cannot find module '${name}'`)) ?? null;
|
|
42
|
+
}
|
|
43
|
+
function reportMissing(packageName, feature) {
|
|
44
|
+
const missing = new OptionalPackageMissingError(packageName, feature);
|
|
45
|
+
(0, runtime_1.emitNervesEvent)({
|
|
46
|
+
level: "error",
|
|
47
|
+
component: "engine",
|
|
48
|
+
event: "engine.optional_package_missing",
|
|
49
|
+
message: missing.message,
|
|
50
|
+
meta: { package: packageName, feature },
|
|
51
|
+
});
|
|
52
|
+
return missing;
|
|
53
|
+
}
|
|
54
|
+
/** Load an optional package, turning its absence into an error that names the feature and the fix. */
|
|
55
|
+
async function importOptional(packageName, feature, load) {
|
|
56
|
+
try {
|
|
57
|
+
return await load();
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
if (missingOptionalPackage(error) !== packageName)
|
|
61
|
+
throw error;
|
|
62
|
+
throw reportMissing(packageName, feature);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** The message a sense entry point prints when it fails to start: the plain error, or what to do when an optional package is absent. */
|
|
66
|
+
function describeStartupError(error, feature) {
|
|
67
|
+
const packageName = missingOptionalPackage(error);
|
|
68
|
+
if (packageName)
|
|
69
|
+
return reportMissing(packageName, feature).message;
|
|
70
|
+
return error instanceof Error ? error.message : String(error);
|
|
71
|
+
}
|
|
@@ -75,8 +75,8 @@ const PROVIDER_FIELD_SPLITS = {
|
|
|
75
75
|
config: [],
|
|
76
76
|
},
|
|
77
77
|
"github-copilot": {
|
|
78
|
-
credentials: ["githubToken"],
|
|
79
|
-
config: ["baseUrl"],
|
|
78
|
+
credentials: ["githubToken", "accountPool", "fleetGistToken"],
|
|
79
|
+
config: ["baseUrl", "fleetGistId", "fleetMachine"],
|
|
80
80
|
},
|
|
81
81
|
"openai-compatible": {
|
|
82
82
|
credentials: ["apiKey"],
|