@ouro.bot/cli 0.1.0-alpha.1510 → 0.1.0-alpha.1512
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 +16 -0
- package/deploy/unraid/README.txt +1 -1
- package/deploy/unraid/ouro-host-lock.mjs +40 -2
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/dist/eval/billing-guard.js +23 -0
- package/dist/eval/budget.js +10 -3
- package/dist/eval/interview-entry.js +4 -2
- package/dist/eval/interviews/runner.js +8 -1
- package/dist/eval/kill-switch.js +33 -0
- package/dist/eval/month-ledger.js +95 -0
- package/dist/eval/run-command.js +31 -4
- package/dist/eval/run-entry.js +4 -0
- package/dist/eval/stop-command.js +71 -0
- package/dist/eval/stop-entry.js +46 -0
- package/dist/eval/watch/cli.js +9 -1
- package/dist/eval/watch-entry.js +2 -2
- package/dist/heart/daemon/app-sessions-record.js +69 -0
- package/dist/heart/daemon/cli-commands/entry-points.js +7 -1
- package/dist/heart/daemon/daemon-entry.js +2 -11
- package/dist/heart/daemon/presence-roster.js +1 -1
- package/dist/heart/session-events.js +10 -3
- package/dist/mind/where-am-i.js +12 -1
- package/dist/senses/teams.js +3 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -1
package/changelog.json
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_note": "Each pull request writes its own change note under changes/; the release job on main gives each landed change its version and adds the notes here (scripts/release-version.cjs). On main this file stops at the last version set by hand; the published package has every release. Agents read this file directly via read_file to understand what changed between versions.",
|
|
3
3
|
"versions": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.1.0-alpha.1512",
|
|
6
|
+
"changes": [
|
|
7
|
+
"Evals now have a stop button and money guards. While `~/.ouro-eval/STOP` exists, eval and interview batches refuse every new run and stop a running one at its next model call, and Watch exits before reading. `npm run eval:stop -- --sandbox-ssh <host>:<folder>` removes every eval container, network and image on that Docker host, frees an eval's host lock (never the Butler's) and checks that nothing is left. Each eval run is also refused when it could pass this month's cap of $40 in credits or 600 premium requests (`~/.ouro-eval/ledger-month.json`), or when its Copilot account reads under 20% of its quota left or gives no reading. Interview sessions add their spend to that month's total, so eval runs make way for the study, but the month cap never blocks or stops an interview, whose pre-registered caps still govern it. The host lock holder for `--host-lock` must now start with `eval`."
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"version": "0.1.0-alpha.1511",
|
|
12
|
+
"changes": [
|
|
13
|
+
"A pending Teams message that is sent again (a file that reappears) is now recorded in the conversation once, so the same old proactive message no longer piles up in the agent's context.",
|
|
14
|
+
"The STALE marker on a peer's presence now names where that data comes from (the bundle's presence record, delivered only by git sync) and which commands to check.",
|
|
15
|
+
"\"where i am\" now lists the Copilot app sessions each peer machine published, so what runs on the other machine is visible from the bundle alone.",
|
|
16
|
+
"Proactive notices older than 6 hours stay in the conversation history but are no longer replayed to the model.",
|
|
17
|
+
"Each machine's published app sessions now carry their desk card (track, slug, status), shown by \"where i am\"."
|
|
18
|
+
]
|
|
19
|
+
},
|
|
4
20
|
{
|
|
5
21
|
"version": "0.1.0-alpha.1510",
|
|
6
22
|
"changes": [
|
package/deploy/unraid/README.txt
CHANGED
|
@@ -3029,6 +3029,6 @@ Shipping a Butler release (one command)
|
|
|
3029
3029
|
|
|
3030
3030
|
It resolves the release merge commit, waits for that commit's coverage-gate and for the GHCR image to resolve on the host, backs up the host's /tmp/butler-upgrade.mjs and /tmp/sanctuary-replay-gate.mjs to .bak-<previous>, stages the release's own copies, runs preflight, runs the release's gate against the live version (the baseline, log at /var/log/ouro-baseline-<version>.log), starts the gated upgrade detached with its log at /var/log/ouro-upgrade-<version>.log and OURO_REPLAY_BASELINE pointing at the baseline log, follows the case lines to a terminal line and runs verify. A candidate failure blocks the release only when that case did not fail on the live baseline; a case that fails on both is reported as failing-on-live-too and does not block. The safety checks (window-trusted, no-telegram, owner-policy-untouched) and a planted case always block. --no-baseline skips the live run, so every failure blocks. The last stdout line is one JSON result: {version, result: kept|rolled_back|refused|failed, running_image, cases, summary, baseline, comparison, verify, log}; comparison lists each case's live and candidate status and its verdict, and is also printed as a table above it. Exit 0 only when the result is kept and verify is green. --dry-run runs only the read-only steps. BUTLER_HOST overrides the default host alias.
|
|
3031
3031
|
|
|
3032
|
-
Host lock: before it changes anything, butler:ship copies deploy/unraid/ouro-host-lock.mjs to /tmp/ouro-host-lock.mjs and takes the host lock (/var/lock/ouro-host.d, with owner.json naming the holder, pid, host and expiry). While someone else holds it, the ship waits up to 30 minutes, then stops saying nothing was changed. The ship passes its token to the upgrade as OURO_HOST_LOCK_TOKEN, and the upgrade takes the lock over with its own pid and a fresh 4-hour expiry, so the lock lasts as long as the upgrade does; when the upgrade exits it hands the lock back to the ship (30-minute expiry), which frees it at the end. Run by hand without a token, the upgrade takes a lock of its own and frees it when it exits. The upgrade waits up to OURO_HOST_LOCK_WAIT_S seconds (default 1800) while anyone else holds the lock, and never starts past it. Each rollback checks the lock again; one that could not run prints ROLLBACK FAILED, and as with any failed rollback the keeper's authority boot retries it about 30 minutes later (that retry does not check the lock). A lock whose expiry has passed, whose process on this host is gone, or that has had no readable owner for a minute is stale and is broken by the next taker. To see who holds it: cat /var/lock/ouro-host.d/owner.json. Eval runs take it with `npm run eval -- ... --sandbox-ssh <host>:<folder> --host-lock <holder>` and hold it for the whole command (#1760).
|
|
3032
|
+
Host lock: before it changes anything, butler:ship copies deploy/unraid/ouro-host-lock.mjs to /tmp/ouro-host-lock.mjs and takes the host lock (/var/lock/ouro-host.d, with owner.json naming the holder, pid, host and expiry). While someone else holds it, the ship waits up to 30 minutes, then stops saying nothing was changed. The ship passes its token to the upgrade as OURO_HOST_LOCK_TOKEN, and the upgrade takes the lock over with its own pid and a fresh 4-hour expiry, so the lock lasts as long as the upgrade does; when the upgrade exits it hands the lock back to the ship (30-minute expiry), which frees it at the end. Run by hand without a token, the upgrade takes a lock of its own and frees it when it exits. The upgrade waits up to OURO_HOST_LOCK_WAIT_S seconds (default 1800) while anyone else holds the lock, and never starts past it. Each rollback checks the lock again; one that could not run prints ROLLBACK FAILED, and as with any failed rollback the keeper's authority boot retries it about 30 minutes later (that retry does not check the lock). A lock whose expiry has passed, whose process on this host is gone, or that has had no readable owner for a minute is stale and is broken by the next taker. To see who holds it: cat /var/lock/ouro-host.d/owner.json. Eval runs take it with `npm run eval -- ... --sandbox-ssh <host>:<folder> --host-lock <holder>` and hold it for the whole command (#1760); their holder always starts with "eval", and `npm run eval:stop` frees only such a lock (`free-eval`), never the ship's or a manual one.
|
|
3033
3033
|
|
|
3034
3034
|
Manual fallback (the script automates exactly these): wait for coverage-gate and `docker manifest inspect ghcr.io/ourostack/ouroboros-butler:<version>` on the host; copy deploy/unraid/sanctuary-butler-upgrade.mjs to /tmp/butler-upgrade.mjs, deploy/unraid/sanctuary-replay-gate.mjs to /tmp/sanctuary-replay-gate.mjs and deploy/unraid/ouro-host-lock.mjs to /tmp/ouro-host-lock.mjs; take the lock with `node /tmp/ouro-host-lock.mjs acquire --holder "<you>" --ttl 14400 --wait 1800` and pass the printed token to the upgrade as OURO_HOST_LOCK_TOKEN; run `node /tmp/butler-upgrade.mjs preflight <version>`; start `setsid nohup /usr/local/bin/node /tmp/butler-upgrade.mjs upgrade <version> > /var/log/ouro-upgrade-<version>.log 2>&1 < /dev/null &`; read the log for GATE PASS, GATE FAIL (rolled back), UPGRADE done, REFUSING or FAILED; then run `node /tmp/butler-upgrade.mjs verify` and free the lock with `node /tmp/ouro-host-lock.mjs release --token <token>`. Check for a live upgrade with pgrep -f "[b]utler-upgrade.mjs upgrade" so the check does not match its own shell.
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
// ouro-host-lock.mjs hold --holder <name> --ttl <seconds> [--wait <seconds>]
|
|
18
18
|
// ouro-host-lock.mjs release --token <token>
|
|
19
19
|
// ouro-host-lock.mjs check --token <token> (exit 0 only while that token holds a live lock)
|
|
20
|
+
// ouro-host-lock.mjs free-eval (eval:stop: frees a lock whose holder starts with "eval")
|
|
21
|
+
// ouro-host-lock.mjs status (@@LOCK free, eval <owner> or other <owner>)
|
|
20
22
|
// Output lines start with @@LOCK. Exit 3: the lock stayed held for all of --wait. Exit 2: bad usage.
|
|
21
23
|
import { randomBytes } from "node:crypto"
|
|
22
24
|
import { mkdirSync, readFileSync, realpathSync, renameSync, rmSync, rmdirSync, statSync, writeFileSync } from "node:fs"
|
|
@@ -145,6 +147,32 @@ export function release(dir, token, io) {
|
|
|
145
147
|
})
|
|
146
148
|
}
|
|
147
149
|
|
|
150
|
+
// Eval runs and interview batches take the lock only under a holder starting with "eval" (their --host-lock checks it).
|
|
151
|
+
const isEval = (owner) => !owner.unreadable && typeof owner.holder === "string" && owner.holder.startsWith("eval")
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Where the lock stands for `npm run eval:stop`: "free", "eval" (an eval run or interview batch holds it), or "other"
|
|
155
|
+
* (a Butler upgrade or rollback, a person's manual hold, or an owner not written yet). A stale lock counts as free.
|
|
156
|
+
*/
|
|
157
|
+
export function stopStatus(dir, io) {
|
|
158
|
+
const current = readOwner(dir, io)
|
|
159
|
+
if (!current || staleReason(current, io)) return { state: "free" }
|
|
160
|
+
return { state: isEval(current) ? "eval" : "other", owner: current }
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Frees the lock for `npm run eval:stop` when an eval holds it, whatever its token; never anyone else's, such as a
|
|
165
|
+
* Butler upgrade's or a person's manual hold. { freed, owner? }.
|
|
166
|
+
*/
|
|
167
|
+
export function freeEval(dir, io) {
|
|
168
|
+
return withGuard(dir, io, () => {
|
|
169
|
+
const current = readOwner(dir, io)
|
|
170
|
+
if (!current || !isEval(current)) return { freed: false, ...(current ? { owner: current } : {}) }
|
|
171
|
+
rmSync(dir, { recursive: true, force: true })
|
|
172
|
+
return { freed: true, owner: current }
|
|
173
|
+
})
|
|
174
|
+
}
|
|
175
|
+
|
|
148
176
|
/** True while this token holds a lock that is not stale. */
|
|
149
177
|
export function heldBy(dir, token, io) {
|
|
150
178
|
const current = readOwner(dir, io)
|
|
@@ -162,7 +190,7 @@ function parse(argv) {
|
|
|
162
190
|
const [command, ...rest] = argv
|
|
163
191
|
const opts = {}
|
|
164
192
|
for (let i = 0; i < rest.length; i += 2) opts[String(rest[i]).replace(/^--/, "")] = rest[i + 1]
|
|
165
|
-
const needs = { acquire: ["holder", "ttl"], hold: ["holder", "ttl"], release: ["token"], check: ["token"] }[command]
|
|
193
|
+
const needs = { acquire: ["holder", "ttl"], hold: ["holder", "ttl"], release: ["token"], check: ["token"], "free-eval": [], status: [] }[command]
|
|
166
194
|
if (!needs || needs.some((key) => !opts[key])) return null
|
|
167
195
|
return { command, ...opts }
|
|
168
196
|
}
|
|
@@ -186,8 +214,18 @@ async function takeWaiting(dir, args, pid, over = () => false) {
|
|
|
186
214
|
|
|
187
215
|
export async function main(argv, dir = process.env.OURO_HOST_LOCK_DIR || LOCK_DIR) {
|
|
188
216
|
const args = parse(argv)
|
|
189
|
-
if (!args) { console.error("usage: ouro-host-lock.mjs acquire|hold --holder <name> --ttl <seconds> [--wait <seconds>] | release|check --token <token>"); return 2 }
|
|
217
|
+
if (!args) { console.error("usage: ouro-host-lock.mjs acquire|hold --holder <name> --ttl <seconds> [--wait <seconds>] | release|check --token <token> | free-eval | status"); return 2 }
|
|
190
218
|
if (args.command === "check") return heldBy(dir, args.token) ? 0 : 1
|
|
219
|
+
if (args.command === "status") {
|
|
220
|
+
const { state, owner } = stopStatus(dir)
|
|
221
|
+
console.log(`@@LOCK ${state}${owner ? ` ${describeOwner(owner)}` : ""}`)
|
|
222
|
+
return 0
|
|
223
|
+
}
|
|
224
|
+
if (args.command === "free-eval") {
|
|
225
|
+
const { freed, owner } = freeEval(dir)
|
|
226
|
+
console.log(freed ? `@@LOCK freed ${describeOwner(owner)}` : owner ? `@@LOCK kept ${describeOwner(owner)}` : "@@LOCK free")
|
|
227
|
+
return 0
|
|
228
|
+
}
|
|
191
229
|
if (args.command === "release") { console.log(release(dir, args.token) ? "@@LOCK released" : "@@LOCK not-held"); return 0 }
|
|
192
230
|
if (args.command === "acquire") return (await takeWaiting(dir, args, null)) ? 0 : 3
|
|
193
231
|
// hold: keep it until the session that asked for it ends. Listen before taking it, so an early signal still releases.
|
|
@@ -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.1512</Repository>
|
|
5
5
|
<Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
|
|
6
6
|
<Network>host</Network>
|
|
7
7
|
<Shell>sh</Shell>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MIN_LEFT_PCT = void 0;
|
|
4
|
+
exports.billingRefusal = billingRefusal;
|
|
5
|
+
/**
|
|
6
|
+
* The billing guard. Shadow, the blind interviews and live Slugger all bill and rate-limit on one Copilot login, so
|
|
7
|
+
* before each eval run (`npm run eval`; the interviews keep their own pre-registered caps and don't consult it) the
|
|
8
|
+
* eval reads that account's quota and refuses unless at least `MIN_LEFT_PCT` of it is left. A
|
|
9
|
+
* token-billed account with unlimited premium interactions reads as 100% left. A missing reading refuses, since an
|
|
10
|
+
* account the eval can't read could be one Slugger is about to run dry (design finding 9).
|
|
11
|
+
*/
|
|
12
|
+
const runtime_1 = require("../nerves/runtime");
|
|
13
|
+
exports.MIN_LEFT_PCT = 20;
|
|
14
|
+
/** Why the account must not take another run, or undefined when it may. */
|
|
15
|
+
function billingRefusal(account, snapshot) {
|
|
16
|
+
const left = snapshot.reading?.leftPct ?? undefined;
|
|
17
|
+
const why = left === undefined
|
|
18
|
+
? `no quota reading for ${account}`
|
|
19
|
+
: left < exports.MIN_LEFT_PCT ? `${account} has ${left}% of its quota left, under ${exports.MIN_LEFT_PCT}%` : undefined;
|
|
20
|
+
if (why !== undefined)
|
|
21
|
+
(0, runtime_1.emitNervesEvent)({ component: "eval", level: "warn", event: "eval.billing_guard_refused", message: "the billing guard refused a run", meta: { leftPct: left ?? null, tokenBased: snapshot.tokenBased } });
|
|
22
|
+
return why;
|
|
23
|
+
}
|
package/dist/eval/budget.js
CHANGED
|
@@ -11,7 +11,7 @@ const finite = (value) => Number.isFinite(value) && value >= 0;
|
|
|
11
11
|
function creditsOf(usage, pricing) {
|
|
12
12
|
return round((usage.input_tokens * pricing.creditsPerMillionInput + usage.output_tokens * pricing.creditsPerMillionOutput) / 1_000_000);
|
|
13
13
|
}
|
|
14
|
-
function createBudgetLedger(caps) {
|
|
14
|
+
function createBudgetLedger(caps, options = {}) {
|
|
15
15
|
for (const meter of METERS) {
|
|
16
16
|
const cap = caps[meter];
|
|
17
17
|
if (cap !== undefined && !finite(cap))
|
|
@@ -33,6 +33,13 @@ function createBudgetLedger(caps) {
|
|
|
33
33
|
if (cap !== undefined && spent[meter] > cap)
|
|
34
34
|
stop(`${meter} cap ${cap} passed: ${spent[meter]} spent`);
|
|
35
35
|
};
|
|
36
|
+
/** Stops the ledger when the kill switch is set; true when it is stopped, for whatever reason. */
|
|
37
|
+
const halted = () => {
|
|
38
|
+
const killed = stopReason === undefined ? options.killSwitch?.() : undefined;
|
|
39
|
+
if (killed !== undefined)
|
|
40
|
+
stop(killed);
|
|
41
|
+
return stopReason !== undefined;
|
|
42
|
+
};
|
|
36
43
|
return {
|
|
37
44
|
stop,
|
|
38
45
|
stopped: () => stopReason,
|
|
@@ -42,7 +49,7 @@ function createBudgetLedger(caps) {
|
|
|
42
49
|
throw new Error("a reservation needs at least 1 call");
|
|
43
50
|
if (!METERS.every((meter) => finite(worst.perCall[meter])))
|
|
44
51
|
throw new Error("a reservation's per-call cost must be numbers of at least 0");
|
|
45
|
-
if (
|
|
52
|
+
if (halted())
|
|
46
53
|
return { refused: `stopped: ${stopReason}` };
|
|
47
54
|
const total = { premium: round(worst.calls * worst.perCall.premium), credits: round(worst.calls * worst.perCall.credits) };
|
|
48
55
|
for (const meter of METERS) {
|
|
@@ -69,7 +76,7 @@ function createBudgetLedger(caps) {
|
|
|
69
76
|
(0, runtime_1.emitNervesEvent)({ component: "eval", event: "eval.budget_reserved", message: "reserved a session's worst-case model spend", meta: { label, ...total } });
|
|
70
77
|
return {
|
|
71
78
|
take() {
|
|
72
|
-
if (!open ||
|
|
79
|
+
if (!open || taken >= worst.calls || halted())
|
|
73
80
|
return false;
|
|
74
81
|
if (worst.perCall.credits > 0 && round(mine.credits + worst.perCall.credits) > total.credits) {
|
|
75
82
|
cut = true;
|
|
@@ -28,6 +28,7 @@ const targets_1 = require("./targets");
|
|
|
28
28
|
const runner_1 = require("./interviews/runner");
|
|
29
29
|
const kit_1 = require("./interviews/u/kit");
|
|
30
30
|
const kit_2 = require("./interviews/h/kit");
|
|
31
|
+
const month_ledger_1 = require("./month-ledger");
|
|
31
32
|
const REPO = node_path_1.default.resolve(__dirname, "../..");
|
|
32
33
|
function take(argv, flag) {
|
|
33
34
|
const at = argv.indexOf(flag);
|
|
@@ -92,8 +93,8 @@ async function main() {
|
|
|
92
93
|
if (!hostLock.value || hostLock.value.startsWith("--"))
|
|
93
94
|
throw new Error("--host-lock needs a holder, such as eval:<your run>");
|
|
94
95
|
// The holder goes to the host through ssh's remote shell, as in `run-command`.
|
|
95
|
-
if (!/^[\w.:@+-]
|
|
96
|
-
throw new Error("--host-lock takes one word of letters, digits and . : @ + - _ (it is sent over ssh)");
|
|
96
|
+
if (!/^eval[\w.:@+-]*$/.test(hostLock.value))
|
|
97
|
+
throw new Error("--host-lock takes one word starting with eval, of letters, digits and . : @ + - _ (it is sent over ssh, and eval:stop frees only eval holders)");
|
|
97
98
|
if (!ssh.value)
|
|
98
99
|
throw new Error("--host-lock needs --sandbox-ssh");
|
|
99
100
|
}
|
|
@@ -155,6 +156,7 @@ async function interviews(args, deps, agentImages) {
|
|
|
155
156
|
openLog: openPrivateLog,
|
|
156
157
|
started: deps.started,
|
|
157
158
|
print: (text) => { process.stdout.write(`${text}\n`); },
|
|
159
|
+
monthLedger: (0, month_ledger_1.monthLedger)(),
|
|
158
160
|
});
|
|
159
161
|
return exitCode;
|
|
160
162
|
}
|
|
@@ -9,6 +9,7 @@ exports.parseInterviewArgs = parseInterviewArgs;
|
|
|
9
9
|
const runtime_1 = require("../../nerves/runtime");
|
|
10
10
|
const assertions_1 = require("../assertions");
|
|
11
11
|
const budget_1 = require("../budget");
|
|
12
|
+
const kill_switch_1 = require("../kill-switch");
|
|
12
13
|
const report_1 = require("../report");
|
|
13
14
|
const allocation_1 = require("./allocation");
|
|
14
15
|
const final_1 = require("./final");
|
|
@@ -250,7 +251,7 @@ async function runInterviews(args, deps) {
|
|
|
250
251
|
if (args.budgetCredits === undefined && (target.account === null || before.tokenBased !== false)) {
|
|
251
252
|
throw new Error(`${args.target} is billed by the token (or not known not to be); pass --budget-credits with --price-in, --price-out and --reserve-credits-per-call`);
|
|
252
253
|
}
|
|
253
|
-
const ledger = (0, budget_1.createBudgetLedger)({ premium: args.budgetPremium, ...(args.budgetCredits !== undefined ? { credits: args.budgetCredits } : {}) });
|
|
254
|
+
const ledger = (0, budget_1.createBudgetLedger)({ premium: args.budgetPremium, ...(args.budgetCredits !== undefined ? { credits: args.budgetCredits } : {}) }, { killSwitch: deps.killSwitch ?? (() => (0, kill_switch_1.stopRequested)()) });
|
|
254
255
|
const pricing = { premiumPerCall: target.unitCost, creditsPerMillionInput: args.priceIn ?? 0, creditsPerMillionOutput: args.priceOut ?? 0 };
|
|
255
256
|
let perCallCredits = args.reserveCreditsPerCall ?? 0;
|
|
256
257
|
const interviewLatch = (0, latch_1.createInterviewLatch)({ ledger, pricing, perCall: () => ({ premium: target.unitCost, credits: perCallCredits }) });
|
|
@@ -294,6 +295,12 @@ async function runInterviews(args, deps) {
|
|
|
294
295
|
record = { ...notRun((0, loop_1.messageOf)(error)), status: "crashed", voidedBy: latch.voided(), calls: latch.calls(), spent: latch.release() };
|
|
295
296
|
}
|
|
296
297
|
records.push(record);
|
|
298
|
+
// The month ledger only hears what the session spent: it never blocks or stops the study, whose pre-registered
|
|
299
|
+
// caps govern it, and a ledger that fails costs the study nothing.
|
|
300
|
+
await deps.monthLedger?.add(record.spent, "interviews").catch((error) => {
|
|
301
|
+
(0, runtime_1.emitNervesEvent)({ component: "eval", level: "warn", event: "eval.interview_month_ledger_failed", message: "couldn't add an interview session's spend to the month ledger", meta: { session: session.id, error: (0, loop_1.messageOf)(error) } });
|
|
302
|
+
deps.print(`month ledger: couldn't add ${session.id}'s spend (${(0, loop_1.messageOf)(error)})`);
|
|
303
|
+
});
|
|
297
304
|
perCallCredits = Math.max(perCallCredits, latch.hold.maxCall());
|
|
298
305
|
if (ledger.stopped())
|
|
299
306
|
stopped = ledger.stopped();
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.evalHome = evalHome;
|
|
7
|
+
exports.stopFile = stopFile;
|
|
8
|
+
exports.stopRequested = stopRequested;
|
|
9
|
+
/**
|
|
10
|
+
* The eval kill switch: while the file `~/.ouro-eval/STOP` exists, the budget ledger refuses every reservation and
|
|
11
|
+
* every later model call, so a running batch stops at its next call, and Watch exits before it reads anything. Make
|
|
12
|
+
* it with `mkdir -p ~/.ouro-eval && touch ~/.ouro-eval/STOP`, and delete it to allow runs again. Any kind of entry at
|
|
13
|
+
* that path counts, a broken link included.
|
|
14
|
+
*/
|
|
15
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
16
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
17
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
18
|
+
const runtime_1 = require("../nerves/runtime");
|
|
19
|
+
/** The eval's private folder on this machine. */
|
|
20
|
+
function evalHome(home = node_os_1.default.homedir()) {
|
|
21
|
+
return node_path_1.default.join(home, ".ouro-eval");
|
|
22
|
+
}
|
|
23
|
+
function stopFile(home = node_os_1.default.homedir()) {
|
|
24
|
+
return node_path_1.default.join(evalHome(home), "STOP");
|
|
25
|
+
}
|
|
26
|
+
/** Why evals must stop now, or undefined while they may run. */
|
|
27
|
+
function stopRequested(file = stopFile()) {
|
|
28
|
+
if (!node_fs_1.default.lstatSync(file, { throwIfNoEntry: false }))
|
|
29
|
+
return undefined;
|
|
30
|
+
(0, runtime_1.emitNervesEvent)({ component: "eval", level: "warn", event: "eval.kill_switch_set", message: "the eval kill switch is set", meta: {} });
|
|
31
|
+
// The reason reaches stdout and the report, so it names the switch, not the home folder.
|
|
32
|
+
return "the kill switch ~/.ouro-eval/STOP is set";
|
|
33
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.MONTH_CAPS = void 0;
|
|
7
|
+
exports.monthLedger = monthLedger;
|
|
8
|
+
/**
|
|
9
|
+
* The month ledger: what every eval run and interview session on this machine spent in each calendar month (UTC), in
|
|
10
|
+
* `~/.ouro-eval/ledger-month.json`, read and written only under a file lock. Both draw on one Copilot subscription,
|
|
11
|
+
* so the month's totals hold both, and each month also keeps them apart by source. Before an eval run, `refusal`
|
|
12
|
+
* answers why its worst case would pass the month cap, counting the interviews' spend, so evals yield to the study.
|
|
13
|
+
* After a run or session, `add` records what it spent. Interviews only add: their pre-registered caps govern them,
|
|
14
|
+
* and the month cap never blocks or stops one (changing a registered cap mid-study would break the registration).
|
|
15
|
+
* Past the cap, eval runs refuse until the next month; spending more is a money decision for Ari.
|
|
16
|
+
*
|
|
17
|
+
* A file it can't read or understand refuses every run rather than starting the month again from nothing. Two eval
|
|
18
|
+
* commands running at once can each pass the check before the other adds, so the cap holds to within one run per
|
|
19
|
+
* command; batches run one at a time under the host lock.
|
|
20
|
+
*/
|
|
21
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
22
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
23
|
+
const atomic_file_1 = require("../heart/atomic-file");
|
|
24
|
+
const file_lock_1 = require("../heart/file-lock");
|
|
25
|
+
const runtime_1 = require("../nerves/runtime");
|
|
26
|
+
const kill_switch_1 = require("./kill-switch");
|
|
27
|
+
/** $40 a month in credits (1 credit is $0.01), and 600 premium requests (design section 7). */
|
|
28
|
+
exports.MONTH_CAPS = { premium: 600, credits: 4000 };
|
|
29
|
+
const METERS = ["premium", "credits"];
|
|
30
|
+
const round = (value) => Math.round(value * 1e6) / 1e6;
|
|
31
|
+
const isCount = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
32
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
33
|
+
const isSpend = (value) => isRecord(value) && isCount(value.premium) && isCount(value.credits) && isCount(value.runs);
|
|
34
|
+
const SOURCES = ["eval", "interviews"];
|
|
35
|
+
const ZERO = { premium: 0, credits: 0, runs: 0 };
|
|
36
|
+
const plus = (before, spent) => ({ premium: round(before.premium + spent.premium), credits: round(before.credits + spent.credits), runs: before.runs + 1 });
|
|
37
|
+
function read(file) {
|
|
38
|
+
let raw;
|
|
39
|
+
try {
|
|
40
|
+
raw = node_fs_1.default.readFileSync(file, "utf8");
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
if (error.code === "ENOENT")
|
|
44
|
+
return { schemaVersion: 1, months: {} };
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
let parsed;
|
|
48
|
+
try {
|
|
49
|
+
parsed = JSON.parse(raw);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
parsed = undefined;
|
|
53
|
+
}
|
|
54
|
+
const months = parsed?.months;
|
|
55
|
+
const valid = parsed?.schemaVersion === 1 && isRecord(months)
|
|
56
|
+
&& Object.values(months).every((m) => isSpend(m) && (m.sources === undefined || (isRecord(m.sources) && Object.entries(m.sources).every(([source, s]) => SOURCES.includes(source) && isSpend(s)))));
|
|
57
|
+
if (!valid) {
|
|
58
|
+
(0, runtime_1.emitNervesEvent)({ component: "eval", level: "error", event: "eval.month_ledger_unreadable", message: "the month ledger can't be understood", meta: { file: node_path_1.default.basename(file) } });
|
|
59
|
+
throw new Error(`the month ledger ${node_path_1.default.basename(file)} can't be understood; fix or move it before running more evals`);
|
|
60
|
+
}
|
|
61
|
+
return parsed;
|
|
62
|
+
}
|
|
63
|
+
function monthLedger(options = {}) {
|
|
64
|
+
const file = options.file ?? node_path_1.default.join((0, kill_switch_1.evalHome)(), "ledger-month.json");
|
|
65
|
+
const caps = options.caps ?? exports.MONTH_CAPS;
|
|
66
|
+
const now = options.now ?? (() => new Date());
|
|
67
|
+
const locked = (fn) => (0, file_lock_1.withFileLock)(node_path_1.default.dirname(file), node_path_1.default.basename(file), fn);
|
|
68
|
+
const monthOf = () => now().toISOString().slice(0, 7);
|
|
69
|
+
const spentIn = (data, month) => data.months[month] ?? ZERO;
|
|
70
|
+
return {
|
|
71
|
+
refusal: (label, worst) => locked(() => {
|
|
72
|
+
const month = monthOf();
|
|
73
|
+
const spent = spentIn(read(file), month);
|
|
74
|
+
const meter = METERS.find((m) => round(spent[m] + worst[m]) > caps[m]);
|
|
75
|
+
if (meter === undefined)
|
|
76
|
+
return undefined;
|
|
77
|
+
(0, runtime_1.emitNervesEvent)({ component: "eval", event: "eval.month_cap_refused", message: "refused a run that could pass the month cap", meta: { label, meter, month } });
|
|
78
|
+
const interviews = spent.sources?.interviews?.[meter] ?? 0;
|
|
79
|
+
return `${label} could pass the ${month} ${meter} cap ${caps[meter]}: ${spent[meter]} spent this month (${interviews} by interviews), ${worst[meter]} more at worst`;
|
|
80
|
+
}),
|
|
81
|
+
add: (spent, source = "eval") => locked(() => {
|
|
82
|
+
const data = read(file);
|
|
83
|
+
const month = monthOf();
|
|
84
|
+
const before = spentIn(data, month);
|
|
85
|
+
const { sources = {}, ...total } = before;
|
|
86
|
+
data.months[month] = { ...plus(total, spent), sources: { ...sources, [source]: plus(sources[source] ?? ZERO, spent) } };
|
|
87
|
+
(0, atomic_file_1.writeFileAtomicSync)(file, `${JSON.stringify(data, null, 2)}\n`);
|
|
88
|
+
(0, runtime_1.emitNervesEvent)({ component: "eval", event: "eval.month_ledger_added", message: "added a run's spend to the month ledger", meta: { month, source, ...plus(total, spent) } });
|
|
89
|
+
}),
|
|
90
|
+
current: () => locked(() => {
|
|
91
|
+
const month = monthOf();
|
|
92
|
+
return { month, spent: spentIn(read(file), month) };
|
|
93
|
+
}),
|
|
94
|
+
};
|
|
95
|
+
}
|
package/dist/eval/run-command.js
CHANGED
|
@@ -16,6 +16,10 @@ exports.runEvalCommand = runEvalCommand;
|
|
|
16
16
|
* calls outgrow its own credit reservation is cut short and not scored (it counts as not run), and the next run
|
|
17
17
|
* reserves more. The first 402 or 429 also stops the command. Either way the report keeps every finished run, and the
|
|
18
18
|
* run the provider cut short counts as failed. The command exits 2 when it stopped early.
|
|
19
|
+
*
|
|
20
|
+
* Three more stops come before each run: the kill switch (`~/.ouro-eval/STOP`, which also stops a run at its next
|
|
21
|
+
* call), the billing guard (an account with a login must read at least 20% of its quota left) and the month ledger
|
|
22
|
+
* (the run's worst case must fit this month's cap, and its spend is added once it ends).
|
|
19
23
|
*/
|
|
20
24
|
const core_1 = require("../heart/core");
|
|
21
25
|
const runtime_1 = require("../nerves/runtime");
|
|
@@ -23,6 +27,7 @@ const assertions_1 = require("./assertions");
|
|
|
23
27
|
const budget_1 = require("./budget");
|
|
24
28
|
const report_1 = require("./report");
|
|
25
29
|
const self_test_1 = require("./self-test");
|
|
30
|
+
const kill_switch_1 = require("./kill-switch");
|
|
26
31
|
/** The most model calls one turn can make: the step-budget ceiling, plus the report call it asks for when used up. */
|
|
27
32
|
exports.CALLS_PER_RUN = core_1.MAX_PROVIDER_ITERATIONS_CEILING + 1;
|
|
28
33
|
const STRING_FLAGS = {
|
|
@@ -68,8 +73,8 @@ function parseEvalArgs(argv) {
|
|
|
68
73
|
}
|
|
69
74
|
if (out.hostLock !== undefined && out.sandboxSsh === undefined)
|
|
70
75
|
throw new Error("--host-lock needs --sandbox-ssh: it locks that host");
|
|
71
|
-
if (out.hostLock !== undefined && !/^[\w.:@+-]
|
|
72
|
-
throw new Error("--host-lock takes one word of letters, digits and . : @ + - _ (it is sent over ssh)");
|
|
76
|
+
if (out.hostLock !== undefined && !/^eval[\w.:@+-]*$/.test(String(out.hostLock)))
|
|
77
|
+
throw new Error("--host-lock takes one word starting with eval, of letters, digits and . : @ + - _ (it is sent over ssh, and eval:stop frees only eval holders)");
|
|
73
78
|
const missing = REQUIRED.find((flag) => !seen.has(flag));
|
|
74
79
|
if (missing)
|
|
75
80
|
throw new Error(`${missing} is required`);
|
|
@@ -103,7 +108,7 @@ async function runEvalCommand(args, deps) {
|
|
|
103
108
|
throw new Error("a credits cap needs --price-in, --price-out and --reserve-credits-per-call (credits per million tokens, and per call)");
|
|
104
109
|
}
|
|
105
110
|
(0, runtime_1.emitNervesEvent)({ component: "eval", event: "eval.run_command_start", message: "starting an eval model run", meta: { target: args.target, bundleRef: args.bundleRef, runs: args.runs, cases: cases.length } });
|
|
106
|
-
const ledger = (0, budget_1.createBudgetLedger)({ premium: args.budgetPremium, ...(args.budgetCredits !== undefined ? { credits: args.budgetCredits } : {}) });
|
|
111
|
+
const ledger = (0, budget_1.createBudgetLedger)({ premium: args.budgetPremium, ...(args.budgetCredits !== undefined ? { credits: args.budgetCredits } : {}) }, { killSwitch: deps.killSwitch ?? (() => (0, kill_switch_1.stopRequested)()) });
|
|
107
112
|
const pricing = { premiumPerCall: target.unitCost, creditsPerMillionInput: args.priceIn ?? 0, creditsPerMillionOutput: args.priceOut ?? 0 };
|
|
108
113
|
let perCallCredits = args.reserveCreditsPerCall ?? 0;
|
|
109
114
|
const runCase = deps.runCase(args);
|
|
@@ -112,7 +117,24 @@ async function runEvalCommand(args, deps) {
|
|
|
112
117
|
outer: for (const c of cases) {
|
|
113
118
|
for (let run = 1; run <= args.runs; run += 1) {
|
|
114
119
|
const reserved = { premium: target.unitCost, credits: perCallCredits };
|
|
115
|
-
const
|
|
120
|
+
const label = `${c.id} run ${run}`;
|
|
121
|
+
if (deps.billingGuard && target.account !== null) {
|
|
122
|
+
const refused = deps.billingGuard(target.account, await target.quota());
|
|
123
|
+
if (refused !== undefined) {
|
|
124
|
+
stopped = `the billing guard refused ${label}: ${refused}`;
|
|
125
|
+
break outer;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (deps.monthLedger) {
|
|
129
|
+
// A month ledger that can't be read or locked stops the batch, and the report still keeps the finished runs.
|
|
130
|
+
const refused = await deps.monthLedger.refusal(label, { premium: exports.CALLS_PER_RUN * reserved.premium, credits: exports.CALLS_PER_RUN * reserved.credits })
|
|
131
|
+
.catch((error) => `the month ledger failed: ${error.message}`);
|
|
132
|
+
if (refused !== undefined) {
|
|
133
|
+
stopped = refused;
|
|
134
|
+
break outer;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
const hold = ledger.reserve(label, { calls: exports.CALLS_PER_RUN, perCall: reserved, pricing });
|
|
116
138
|
if ("refused" in hold) {
|
|
117
139
|
stopped = hold.refused;
|
|
118
140
|
break outer;
|
|
@@ -127,6 +149,7 @@ async function runEvalCommand(args, deps) {
|
|
|
127
149
|
obs = failedRun(`sandbox-error: ${sandboxError}`);
|
|
128
150
|
}
|
|
129
151
|
const spent = hold.release();
|
|
152
|
+
const monthError = await deps.monthLedger?.add(spent).then(() => undefined, (error) => `the month ledger failed to add ${label}'s spend: ${error.message}`);
|
|
130
153
|
const budgetCut = hold.cutShort();
|
|
131
154
|
const graded = (0, assertions_1.evaluate)(c, obs);
|
|
132
155
|
const verdict = budgetCut ? { passed: false, reason: "cut short by its credit reservation" } : (0, report_1.gradeRun)(obs, graded);
|
|
@@ -136,6 +159,10 @@ async function runEvalCommand(args, deps) {
|
|
|
136
159
|
viaShellFallback: verdict.passed && (0, report_1.withoutBooksRemove)(obs), observation,
|
|
137
160
|
});
|
|
138
161
|
perCallCredits = Math.max(perCallCredits, hold.maxCall());
|
|
162
|
+
if (monthError !== undefined) {
|
|
163
|
+
stopped = monthError;
|
|
164
|
+
break outer;
|
|
165
|
+
}
|
|
139
166
|
if (ledger.stopped()) {
|
|
140
167
|
stopped = ledger.stopped();
|
|
141
168
|
break outer;
|
package/dist/eval/run-entry.js
CHANGED
|
@@ -17,6 +17,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
18
18
|
const node_path_1 = __importDefault(require("node:path"));
|
|
19
19
|
const runtime_1 = require("../nerves/runtime");
|
|
20
|
+
const billing_guard_1 = require("./billing-guard");
|
|
21
|
+
const month_ledger_1 = require("./month-ledger");
|
|
20
22
|
const run_command_1 = require("./run-command");
|
|
21
23
|
const report_1 = require("./report");
|
|
22
24
|
const docker_1 = require("./sandbox/docker");
|
|
@@ -66,6 +68,8 @@ async function main() {
|
|
|
66
68
|
outputExists: (file) => node_fs_1.default.existsSync(file),
|
|
67
69
|
writeReport: report_1.writePrivateReport,
|
|
68
70
|
print: (text) => { process.stdout.write(`${text}\n`); },
|
|
71
|
+
monthLedger: (0, month_ledger_1.monthLedger)(),
|
|
72
|
+
billingGuard: billing_guard_1.billingRefusal,
|
|
69
73
|
});
|
|
70
74
|
return exitCode;
|
|
71
75
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseStopArgs = parseStopArgs;
|
|
4
|
+
exports.runStopCommand = runStopCommand;
|
|
5
|
+
/**
|
|
6
|
+
* `npm run eval:stop -- --sandbox-ssh <host>:<folder>`: the eval's stop button for a Docker host. Over ssh it removes
|
|
7
|
+
* every container, network and image labelled `ouro.eval=1` (both eval images carry the label from
|
|
8
|
+
* deploy/eval/Dockerfile), frees the host lock when an eval or interview batch holds it (a holder starting with
|
|
9
|
+
* "eval"; never a Butler's or a person's, see `free-eval` in deploy/unraid/ouro-host-lock.mjs, run from
|
|
10
|
+
* `<folder>/harness`), then reads back that no labelled container, network or image remains and that no eval holds
|
|
11
|
+
* the lock ("other" holders may). It prints counts only.
|
|
12
|
+
*
|
|
13
|
+
* It doesn't stop a batch on this machine; `~/.ouro-eval/STOP` does that (`kill-switch.ts`). A batch whose sandbox
|
|
14
|
+
* disappears stops on its own with "the sandbox failed".
|
|
15
|
+
*/
|
|
16
|
+
const runtime_1 = require("../nerves/runtime");
|
|
17
|
+
const docker_1 = require("./sandbox/docker");
|
|
18
|
+
const USAGE = "usage: npm run eval:stop -- --sandbox-ssh <host>:<folder>";
|
|
19
|
+
const KINDS = [
|
|
20
|
+
{ name: "containers", list: ["docker", "ps", "-aq"], remove: ["docker", "rm", "-f"] },
|
|
21
|
+
{ name: "networks", list: ["docker", "network", "ls", "-q"], remove: ["docker", "network", "rm"] },
|
|
22
|
+
{ name: "images", list: ["docker", "images", "-q"], remove: ["docker", "rmi", "-f"] },
|
|
23
|
+
];
|
|
24
|
+
/** Reads `--sandbox-ssh <host>:<folder>`; both are sent over ssh, so only plain names and absolute paths pass. */
|
|
25
|
+
function parseStopArgs(argv) {
|
|
26
|
+
if (argv.length !== 2 || argv[0] !== "--sandbox-ssh")
|
|
27
|
+
throw new Error(USAGE);
|
|
28
|
+
const spec = argv[1];
|
|
29
|
+
const split = spec.indexOf(":");
|
|
30
|
+
const host = spec.slice(0, Math.max(split, 0));
|
|
31
|
+
const root = spec.slice(split + 1);
|
|
32
|
+
if (!/^\w[\w.@-]*$/.test(host) || !/^\/[\w./-]*$/.test(root) || root.split("/").includes(".."))
|
|
33
|
+
throw new Error(`${USAGE} (a plain host name and an absolute folder)`);
|
|
34
|
+
return { host, root };
|
|
35
|
+
}
|
|
36
|
+
async function must(run, argv) {
|
|
37
|
+
const { code, stdout } = await run(argv);
|
|
38
|
+
if (code !== 0)
|
|
39
|
+
throw new Error(`${argv[0] === "node" ? `host lock ${argv[2]}` : argv.slice(0, 3).join(" ")} exited ${code}`);
|
|
40
|
+
return stdout;
|
|
41
|
+
}
|
|
42
|
+
const ids = (stdout) => [...new Set(stdout.split("\n").map((line) => line.trim()).filter(Boolean))];
|
|
43
|
+
async function labelled(run) {
|
|
44
|
+
const found = {};
|
|
45
|
+
for (const kind of KINDS)
|
|
46
|
+
found[kind.name] = ids(await must(run, [...kind.list, "--filter", `label=${docker_1.EVAL_LABEL}`]));
|
|
47
|
+
return found;
|
|
48
|
+
}
|
|
49
|
+
async function runStopCommand(target, run, print) {
|
|
50
|
+
const lockScript = `${target.root}/harness/deploy/unraid/ouro-host-lock.mjs`;
|
|
51
|
+
const found = await labelled(run);
|
|
52
|
+
const removed = {};
|
|
53
|
+
for (const kind of KINDS) {
|
|
54
|
+
const list = found[kind.name];
|
|
55
|
+
if (list.length > 0)
|
|
56
|
+
await must(run, [...kind.remove, ...list]);
|
|
57
|
+
removed[kind.name] = list.length;
|
|
58
|
+
}
|
|
59
|
+
const freed = (await must(run, ["node", lockScript, "free-eval"])).trim();
|
|
60
|
+
const left = await labelled(run);
|
|
61
|
+
const remaining = Object.fromEntries(KINDS.map((kind) => [kind.name, left[kind.name].length]));
|
|
62
|
+
const status = (await must(run, ["node", lockScript, "status"])).trim();
|
|
63
|
+
const lockState = /^@@LOCK (free|eval|other)\b/.exec(status)?.[1] ?? "unknown";
|
|
64
|
+
const lock = freed.startsWith("@@LOCK freed") ? `freed, now ${lockState}` : lockState;
|
|
65
|
+
const clean = Object.values(remaining).every((n) => n === 0) && (lockState === "free" || lockState === "other");
|
|
66
|
+
print(`removed ${removed.containers} containers, ${removed.networks} networks and ${removed.images} images labelled ${docker_1.EVAL_LABEL} on ${target.host}`);
|
|
67
|
+
print(`host lock: ${lock}`);
|
|
68
|
+
print(clean ? "read back: none remain" : `read back: ${remaining.containers} containers, ${remaining.networks} networks and ${remaining.images} images remain; host lock ${lockState}`);
|
|
69
|
+
(0, runtime_1.emitNervesEvent)({ component: "eval", level: clean ? "info" : "error", event: "eval.stop_command", message: "eval:stop ran on a Docker host", meta: { removed, remaining, lock: lockState } });
|
|
70
|
+
return { exitCode: clean ? 0 : 1, removed, lock, remaining };
|
|
71
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* `npm run eval:stop -- --sandbox-ssh <host>:<folder>` (see `stop-command.ts`): removes the eval's containers,
|
|
5
|
+
* networks and images on that Docker host, frees an eval's host lock and reads back that none remain. Exits 0 when
|
|
6
|
+
* the read-back is clean, 1 when something remains or a step failed, 2 for bad arguments.
|
|
7
|
+
*/
|
|
8
|
+
const node_child_process_1 = require("node:child_process");
|
|
9
|
+
const runtime_1 = require("../nerves/runtime");
|
|
10
|
+
const stop_command_1 = require("./stop-command");
|
|
11
|
+
/** One command over ssh, with no terminal and no password prompt; stderr passes through. */
|
|
12
|
+
function sshRun(host) {
|
|
13
|
+
return (argv) => new Promise((resolve) => {
|
|
14
|
+
const child = (0, node_child_process_1.spawn)("ssh", ["-T", "-o", "BatchMode=yes", host, ...argv], { stdio: ["ignore", "pipe", "inherit"] });
|
|
15
|
+
let stdout = "";
|
|
16
|
+
child.stdout.setEncoding("utf8").on("data", (chunk) => { stdout += chunk; });
|
|
17
|
+
child.on("error", () => resolve({ code: -1, stdout }));
|
|
18
|
+
child.on("close", (code) => resolve({ code: code ?? -1, stdout }));
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
// stderr's last line names the failure its Ouro AX card lists (cli-commands/entry-points.ts).
|
|
22
|
+
const USAGE = "usage";
|
|
23
|
+
const INCOMPLETE = "stop-incomplete";
|
|
24
|
+
const FAILED = "stop-failed";
|
|
25
|
+
async function main() {
|
|
26
|
+
let target;
|
|
27
|
+
try {
|
|
28
|
+
target = (0, stop_command_1.parseStopArgs)(process.argv.slice(2));
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
process.stderr.write(`${error.message}\ncode: ${USAGE}\n`);
|
|
32
|
+
return 2;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
const { exitCode } = await (0, stop_command_1.runStopCommand)(target, sshRun(target.host), (text) => { process.stdout.write(`${text}\n`); });
|
|
36
|
+
if (exitCode !== 0)
|
|
37
|
+
process.stderr.write(`code: ${INCOMPLETE}\n`);
|
|
38
|
+
return exitCode;
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
(0, runtime_1.emitNervesEvent)({ component: "eval", level: "error", event: "eval.stop_entry_error", message: "eval:stop failed", meta: { error: error.message } });
|
|
42
|
+
process.stderr.write(`eval:stop: ${error.message}\ncode: ${FAILED}\n`);
|
|
43
|
+
return 1;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
void main().then((code) => { process.exitCode = code; });
|
package/dist/eval/watch/cli.js
CHANGED
|
@@ -13,6 +13,7 @@ exports.lowerPriority = lowerPriority;
|
|
|
13
13
|
const node_os_1 = __importDefault(require("node:os"));
|
|
14
14
|
const node_path_1 = __importDefault(require("node:path"));
|
|
15
15
|
const runtime_1 = require("../../nerves/runtime");
|
|
16
|
+
const kill_switch_1 = require("../kill-switch");
|
|
16
17
|
const guarded_fs_1 = require("./guarded-fs");
|
|
17
18
|
const run_watch_1 = require("./run-watch");
|
|
18
19
|
const USAGE = "usage: npm run eval:watch -- --agent-root <path> [--out <folder>]\n";
|
|
@@ -20,8 +21,15 @@ function argument(args, name) {
|
|
|
20
21
|
const index = args.indexOf(name);
|
|
21
22
|
return index >= 0 ? args[index + 1] : undefined;
|
|
22
23
|
}
|
|
23
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Runs Watch once and returns the exit code: 0 on success, 2 for bad arguments, 3 when the kill switch
|
|
26
|
+
* (`~/.ouro-eval/STOP`) is set, which it checks before reading anything, and 1 for any other failure.
|
|
27
|
+
*/
|
|
24
28
|
function watchCli(args, io, extra = {}) {
|
|
29
|
+
if ((0, kill_switch_1.stopRequested)((0, kill_switch_1.stopFile)(io.homedir)) !== undefined) {
|
|
30
|
+
io.stderr("Watch stopped: the eval kill switch ~/.ouro-eval/STOP is set, so nothing was read.\n");
|
|
31
|
+
return 3;
|
|
32
|
+
}
|
|
25
33
|
const agentRootArg = argument(args, "--agent-root");
|
|
26
34
|
if (!agentRootArg) {
|
|
27
35
|
io.stderr(USAGE);
|
package/dist/eval/watch-entry.js
CHANGED
|
@@ -19,8 +19,8 @@ const code = (0, cli_1.watchCli)(process.argv.slice(2), {
|
|
|
19
19
|
stderr: (text) => process.stderr.write(text),
|
|
20
20
|
homedir: node_os_1.default.homedir(),
|
|
21
21
|
});
|
|
22
|
-
// stderr's last line names the failure for a script: 2 bad arguments, 1 a run
|
|
22
|
+
// stderr's last line names the failure for a script: 2 bad arguments, 3 the kill switch, 1 a run refused or failed.
|
|
23
23
|
if (code !== 0)
|
|
24
|
-
process.stderr.write(`code: ${code === 2 ? "usage" : "watch-failed"}\n`);
|
|
24
|
+
process.stderr.write(`code: ${code === 2 ? "usage" : code === 3 ? "stopped" : "watch-failed"}\n`);
|
|
25
25
|
(0, runtime_1.emitNervesEvent)({ component: "eval", event: "eval.watch_entry_exit", message: "Watch's command finished", meta: { code } });
|
|
26
26
|
process.exitCode = code;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.appSessionsRecord = appSessionsRecord;
|
|
37
|
+
const fs = __importStar(require("node:fs"));
|
|
38
|
+
const runtime_1 = require("../../nerves/runtime");
|
|
39
|
+
const store_1 = require("../../senses/app-sessions/store");
|
|
40
|
+
const path = __importStar(require("node:path"));
|
|
41
|
+
const SNAPSHOT_MAX_AGE_MS = 10 * 60_000;
|
|
42
|
+
const DIGEST_MAX_AGE_MS = 60 * 60_000;
|
|
43
|
+
function readJson(file) {
|
|
44
|
+
try {
|
|
45
|
+
return JSON.parse(fs.readFileSync(file, "utf-8"));
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* This machine's Copilot app sessions for its peer record, from the app-sessions sense's last snapshot. Each session
|
|
53
|
+
* the digest tied to a desk card carries that card's track, slug and status, so a peer sees what work runs here and
|
|
54
|
+
* where its source of truth lives (the desk), without reaching this machine. Stale snapshots publish nothing.
|
|
55
|
+
*/
|
|
56
|
+
function appSessionsRecord(agentRoot, nowMs) {
|
|
57
|
+
const snap = readJson(path.join((0, store_1.appSessionsStateDir)(agentRoot), "snapshot.json"));
|
|
58
|
+
if (!snap?.at || !snap.counts || nowMs - Date.parse(snap.at) > SNAPSHOT_MAX_AGE_MS)
|
|
59
|
+
return {};
|
|
60
|
+
const digest = readJson(path.join((0, store_1.appSessionsStateDir)(agentRoot), "digest.json"));
|
|
61
|
+
const digestFresh = !!digest?.at && nowMs - Date.parse(digest.at) <= DIGEST_MAX_AGE_MS;
|
|
62
|
+
const cards = new Map((digestFresh ? digest?.sessions ?? [] : []).filter((s) => s.card).map((s) => [s.id, s.card]));
|
|
63
|
+
const sessions = (snap.sessions ?? []).map(({ id, name, state }) => {
|
|
64
|
+
const card = cards.get(id);
|
|
65
|
+
return { id, name, state, ...(card ? { desk: { track: card.track, slug: card.slug, status: card.status, via: "desk" } } : {}) };
|
|
66
|
+
});
|
|
67
|
+
(0, runtime_1.emitNervesEvent)({ component: "daemon", event: "daemon.app_sessions_record_built", message: "built the app sessions part of the peer record", meta: { sessions: sessions.length, withDeskCard: cards.size } });
|
|
68
|
+
return { appSessions: { at: snap.at, counts: snap.counts, sessions } };
|
|
69
|
+
}
|
|
@@ -148,15 +148,21 @@ exports.ENTRY_POINT_COMMANDS = [
|
|
|
148
148
|
{ name: `${PROBE} recover`, effect: "private", summary: "Restore state after a health probe.", ax: { id: `cli:${PROBE} recover`, group: "sanctuary-host", effect: "write", when: "After an interrupted probe: put the agent's health state back from the snapshot the run saved.", errors: [probeUsage("recover")] } },
|
|
149
149
|
{ name: `${PROBE} finalize`, effect: "private", summary: "Finish a health acceptance scenario.", ax: { id: `cli:${PROBE} finalize`, group: "sanctuary-host", effect: "write", when: "Close a scenario by proving the owner image and container after it, then clear the probe's workspace.", errors: [probeUsage("finalize")] } },
|
|
150
150
|
{ name: "node dist/eval/run-entry.js", effect: "private", summary: "Run the replay eval's cases on a model.", ax: { id: "cli:node dist/eval/run-entry.js", group: "diagnostics", effect: "consequential", confirm: "It spends model credits or premium requests on the account the flags name, up to the caps you pass.", when: "Measure a model on the replay eval's cases, writing a private report; every run reserves its worst-case spend first.", errors: [
|
|
151
|
-
{ code: "budget-stopped", means: "The eval stopped early: a run
|
|
151
|
+
{ code: "budget-stopped", means: "The eval stopped early: a run could pass its cap or the month's, the quota read under 20% or none, ~/.ouro-eval/STOP is set, or the provider sent 402 or 429.", fix: "Read the reason on stdout. Raise a cap only if approved, wait for quota or the next month, or delete ~/.ouro-eval/STOP; the report keeps finished runs, so a rerun adds runs." },
|
|
152
152
|
{ code: "eval-error", means: "The eval refused to start or failed: a bad or missing flag, a case that fails its self-test, a report file that exists already, a target without its prices or caps, or a run that threw.", fix: "Read the `eval:` line above it on stderr, fix that, and run again with a new --output path." },
|
|
153
153
|
] } },
|
|
154
154
|
{ name: "node dist/eval/interview-entry.js", effect: "private", summary: "Run blind-interview sessions on a model.", ax: { id: "cli:node dist/eval/interview-entry.js", group: "diagnostics", effect: "consequential", confirm: "It spends model credits or premium requests on the account the flags name, up to the caps you pass, and a session it starts can never run again.", when: "Run the pre-registered blind-interview sessions on one model, writing a private report and request log; each session reserves its worst case first.", errors: [
|
|
155
155
|
{ code: "budget-stopped", means: "The study stopped: a session's reservation would pass a cap, or the provider answered 402 or 429. Later sessions are recorded as not run.", fix: "Read the counts on stdout; the study stays stopped, since a session that didn't run counts as ouro not chosen first." },
|
|
156
156
|
{ code: "eval-error", means: "The interviews refused to start (a bad flag, sandbox or target, a host lock already held by another holder or lost mid-run, or a session not allowed or already started) or failed after starting.", fix: "Read the `interviews:` line on stderr; sessions it began are in the started file and can't run again, so name the others with --session." },
|
|
157
157
|
] } },
|
|
158
|
+
{ name: "node dist/eval/stop-entry.js", effect: "private", summary: "Remove the eval's sandboxes from a Docker host.", ax: { id: "cli:node dist/eval/stop-entry.js", group: "diagnostics", effect: "consequential", confirm: "It force-removes every container, network and image labelled ouro.eval=1 on that host, ending any eval or interview run there, and frees a host lock an eval holds.", when: "Stop every eval on a Docker host at once and prove nothing of it is left; set ~/.ouro-eval/STOP as well to keep batches on this machine from starting more runs.", errors: [
|
|
159
|
+
{ code: "usage", means: "eval:stop needs exactly --sandbox-ssh <host>:<folder>, a plain host name and an absolute folder.", fix: "Pass only --sandbox-ssh with the host and the absolute folder whose harness/ the eval runs use, such as box:/srv/ouro." },
|
|
160
|
+
{ code: "stop-incomplete", means: "The read-back found labelled containers, networks or images left, or an eval holder still on the host lock.", fix: "Read the counts on stdout and run it again; if something stays, inspect it on the host with docker ps -a --filter label=ouro.eval=1 or the lock script's status." },
|
|
161
|
+
{ code: "stop-failed", means: "A step exited with an error: ssh got no connection to the host, or a docker or lock command there returned nonzero.", fix: "Read the `eval:stop:` line on stderr, check ssh to the host and that its harness checkout has the lock script, then run it again." },
|
|
162
|
+
] } },
|
|
158
163
|
{ name: "node dist/eval/watch-entry.js", effect: "private", summary: "Count a live agent's turns from its logs.", ax: { id: "cli:node dist/eval/watch-entry.js", group: "diagnostics", effect: "write", when: "See how a running agent's turns went by day and channel; it reads only new log lines and keeps its private rows outside the bundle.", errors: [
|
|
159
164
|
{ code: "usage", means: "Watch was started without --agent-root.", fix: "Pass --agent-root with the agent's bundle folder, such as ~/AgentBundles/<agent>.ouro." },
|
|
165
|
+
{ code: "stopped", means: "The eval kill switch ~/.ouro-eval/STOP is set, so Watch exited before reading anything.", fix: "Leave it while evals must stay stopped; delete ~/.ouro-eval/STOP to let Watch and eval runs start again." },
|
|
160
166
|
{ code: "watch-failed", means: "Watch refused or failed: its --out folder is inside a bundle or holds other files, a private file is a link, or a private write failed. The line above names only an error code.", fix: "Point --out at an empty folder outside ~/AgentBundles, or remove the link from the private folder, and run again." },
|
|
161
167
|
] } },
|
|
162
168
|
{ name: "node dist/senses/shepherd/judge-evaluation-entry.js", effect: "private", summary: "Evaluate Shepherd's judge on its cases.", ax: { id: "cli:node dist/senses/shepherd/judge-evaluation-entry.js", group: "diagnostics", effect: "write", when: "Measure how Shepherd's judge classifies its evaluation cases, writing a report; it never qualifies v1 on its own.", errors: [
|
|
@@ -51,6 +51,7 @@ const sense_manager_1 = require("./sense-manager");
|
|
|
51
51
|
const agent_discovery_1 = require("./agent-discovery");
|
|
52
52
|
const agent_home_1 = require("./agent-home");
|
|
53
53
|
const identity_1 = require("../identity");
|
|
54
|
+
const app_sessions_record_1 = require("./app-sessions-record");
|
|
54
55
|
const runtime_mode_1 = require("./runtime-mode");
|
|
55
56
|
const habit_scheduler_1 = require("../habits/habit-scheduler");
|
|
56
57
|
const habit_migration_1 = require("../habits/habit-migration");
|
|
@@ -334,17 +335,7 @@ const presenceTicker = new presence_daemon_1.PresenceTicker({
|
|
|
334
335
|
},
|
|
335
336
|
schedulersRunning: (agent) => agentSchedulers.has(agent),
|
|
336
337
|
// This machine's Copilot app sessions, from the app-sessions sense's last snapshot, so peers see them too.
|
|
337
|
-
extraRecord: (agent) => {
|
|
338
|
-
try {
|
|
339
|
-
const snap = JSON.parse(fs.readFileSync(path.join((0, identity_1.getAgentBundlesRoot)(), `${agent}.ouro`, "state", "senses", "app-sessions", "snapshot.json"), "utf-8"));
|
|
340
|
-
if (!snap.at || !snap.counts || Date.now() - Date.parse(snap.at) > 10 * 60_000)
|
|
341
|
-
return {};
|
|
342
|
-
return { appSessions: { at: snap.at, counts: snap.counts, sessions: (snap.sessions ?? []).map(({ id, name, state }) => ({ id, name, state })) } };
|
|
343
|
-
}
|
|
344
|
-
catch {
|
|
345
|
-
return {};
|
|
346
|
-
}
|
|
347
|
-
},
|
|
338
|
+
extraRecord: (agent) => (0, app_sessions_record_1.appSessionsRecord)(path.join((0, identity_1.getAgentBundlesRoot)(), `${agent}.ouro`), Date.now()),
|
|
348
339
|
notify: async (agent, text) => {
|
|
349
340
|
await (0, socket_client_1.sendDaemonCommand)(socketPath, { kind: "message.send", from: "presence", to: agent, content: text });
|
|
350
341
|
await (0, socket_client_1.sendDaemonCommand)(socketPath, {
|
|
@@ -238,7 +238,7 @@ function renderPresenceStatus(options) {
|
|
|
238
238
|
for (const machine of presence.block.machines) {
|
|
239
239
|
const record = presence.peers.find((peer) => peer.machineId === machine.machineId);
|
|
240
240
|
const me = machine.machineId === machineId ? " (this machine)" : "";
|
|
241
|
-
const stale = record && (0, presence_1.isStaleSeenAt)(record.seenAt, now.getTime()) ? " [STALE:
|
|
241
|
+
const stale = record && (0, presence_1.isStaleSeenAt)(record.seenAt, now.getTime()) ? " [STALE: bundle sync has not delivered a newer presence record; check sync health before routing work here]" : "";
|
|
242
242
|
const seen = record ? `${record.version}, seen ${ago(record.seenAt, now)}${stale}` : "no presence record yet";
|
|
243
243
|
const legacy = presence.legacy.includes(machine.machineId) ? "; may run a home-only daemon" : "";
|
|
244
244
|
lines.push(`- ${machine.name}${me}: ${machine.role}; ${seen}${legacy}`);
|
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.EVENT_CONTENT_MAX_CHARS = exports.OUTBOUND_ORIGINS = void 0;
|
|
36
|
+
exports.PROACTIVE_REPLAY_MAX_AGE_MS = exports.EVENT_CONTENT_MAX_CHARS = exports.OUTBOUND_ORIGINS = void 0;
|
|
37
37
|
exports.materializeApprovalTerminal = materializeApprovalTerminal;
|
|
38
38
|
exports.attachApprovalSuspensionCheckpoint = attachApprovalSuspensionCheckpoint;
|
|
39
39
|
exports.listApprovalSuspensionCheckpoints = listApprovalSuspensionCheckpoints;
|
|
@@ -1021,8 +1021,15 @@ function buildEventFromMessage(message, sequence, recordedAt, captureKind, sourc
|
|
|
1021
1021
|
function projectedSessionEventIds(envelope) {
|
|
1022
1022
|
return providerProjectionEvents(envelope).map((event) => event.id);
|
|
1023
1023
|
}
|
|
1024
|
-
|
|
1025
|
-
|
|
1024
|
+
/** A proactive notice this old is no longer news. It stays in the durable history but is not replayed to the model. */
|
|
1025
|
+
exports.PROACTIVE_REPLAY_MAX_AGE_MS = 6 * 60 * 60_000;
|
|
1026
|
+
function isDeadProactiveNotice(event, nowMs) {
|
|
1027
|
+
if (event.provenance.outbound?.origin !== "proactive")
|
|
1028
|
+
return false;
|
|
1029
|
+
return nowMs - Date.parse(bestEventTimestamp(event)) > exports.PROACTIVE_REPLAY_MAX_AGE_MS;
|
|
1030
|
+
}
|
|
1031
|
+
function providerProjectionEvents(envelope, nowMs = Date.now()) {
|
|
1032
|
+
const events = selectEffectiveSessionEvents(envelope.events).filter((event) => !isDeadProactiveNotice(event, nowMs));
|
|
1026
1033
|
if (envelope.projection.eventIds.length === 0)
|
|
1027
1034
|
return envelope.projection.trimmed ? [] : events;
|
|
1028
1035
|
const byId = new Map(events.map((event) => [event.id, event]));
|
package/dist/mind/where-am-i.js
CHANGED
|
@@ -59,7 +59,7 @@ function ago(seenAt, nowMs) {
|
|
|
59
59
|
return hours < 48 ? `${hours} h ago` : `${Math.round(hours / 24)} days ago`;
|
|
60
60
|
}
|
|
61
61
|
function staleNote(seenAt, nowMs) {
|
|
62
|
-
return (0, presence_1.isStaleSeenAt)(seenAt, nowMs) ? " [STALE: this record is old, so its sessions, counts and ownership may be out of date;
|
|
62
|
+
return (0, presence_1.isStaleSeenAt)(seenAt, nowMs) ? " [STALE: this record is old, so its sessions, counts and ownership may be out of date; its newest data is the bundle's presence/<machineId>.json, which only arrives through git sync, so run `ouro presence status` and check `ouro status` sync health before routing work to it]" : "";
|
|
63
63
|
}
|
|
64
64
|
function sessionCounts(record) {
|
|
65
65
|
const counts = record?.appSessions?.counts;
|
|
@@ -68,6 +68,16 @@ function sessionCounts(record) {
|
|
|
68
68
|
const parts = Object.entries(counts).filter(([, count]) => typeof count === "number").map(([state, count]) => `${count} ${state}`);
|
|
69
69
|
return parts.length > 0 ? `; copilot app sessions: ${parts.join(", ")}` : "";
|
|
70
70
|
}
|
|
71
|
+
const PEER_SESSIONS_SHOWN = 8;
|
|
72
|
+
/** The Copilot app sessions a peer last published, so work running there is visible without reaching the machine. */
|
|
73
|
+
function peerSessionLines(record, nowMs) {
|
|
74
|
+
const sessions = record?.appSessions?.sessions ?? [];
|
|
75
|
+
if (!record?.appSessions || sessions.length === 0)
|
|
76
|
+
return [];
|
|
77
|
+
const shown = sessions.slice(0, PEER_SESSIONS_SHOWN).map((session) => ` - ${session.name ?? session.id}${session.state ? ` (${session.state})` : ""}${session.desk?.track ? `, desk card ${session.desk.track}/${session.desk.slug ?? "?"}${session.desk.status ? ` [${session.desk.status}]` : ""}` : ""}`);
|
|
78
|
+
const more = sessions.length > shown.length ? [` - and ${sessions.length - shown.length} more`] : [];
|
|
79
|
+
return [` its copilot app sessions as of ${ago(record.appSessions.at, nowMs)}:`, ...shown, ...more];
|
|
80
|
+
}
|
|
71
81
|
/** Senses every presence runs for its own machine. */
|
|
72
82
|
const MACHINE_SENSES = ["cli", "shepherd", "app-sessions"];
|
|
73
83
|
/** What a person calls a sense whose name is the integration's. */
|
|
@@ -91,6 +101,7 @@ function renderWhereAmI(presence, self, nowMs = Date.now()) {
|
|
|
91
101
|
const facts = [peer.role, record?.os, record?.location].filter(Boolean).join(", ");
|
|
92
102
|
const seen = record ? `last seen ${ago(record.seenAt, nowMs)} on ${record.version}${sessionCounts(record)}${staleNote(record.seenAt, nowMs)}` : "not seen yet (no presence record)";
|
|
93
103
|
lines.push(`- ${peer.name} (${facts}): ${seen}`);
|
|
104
|
+
lines.push(...peerSessionLines(record, nowMs));
|
|
94
105
|
}
|
|
95
106
|
}
|
|
96
107
|
// Only senses agent.json turns on: a disabled sense runs on no machine, whatever the roster's owners say.
|
package/dist/senses/teams.js
CHANGED
|
@@ -2133,6 +2133,9 @@ async function drainAndSendPendingTeams(store, botApi, pendingRoot) {
|
|
|
2133
2133
|
sessionKey: key,
|
|
2134
2134
|
text: messageText,
|
|
2135
2135
|
intent: "generic_outreach",
|
|
2136
|
+
// Stable per file: a pending file that reappears (a restored checkout, a failed unlink) is recognised by the
|
|
2137
|
+
// session and not recorded into the conversation a second time.
|
|
2138
|
+
deliveryId: `pending:${(0, node_crypto_1.createHash)("sha256").update(path.relative(root, filePath)).digest("hex").slice(0, 32)}`,
|
|
2136
2139
|
}, {
|
|
2137
2140
|
botApi,
|
|
2138
2141
|
store,
|
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.1512",
|
|
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.1512",
|
|
10
10
|
"bundleDependencies": [
|
|
11
11
|
"@ouro.bot/friends"
|
|
12
12
|
],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ouro.bot/cli",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.1512",
|
|
4
4
|
"description": "Ouroboros, the agent harness: agents with durable memory that live where you talk (terminal, Teams, iMessage, mail, voice) and use real tools. Start with npx ouro.bot@latest.",
|
|
5
5
|
"homepage": "https://ouroboros.bot/",
|
|
6
6
|
"engines": {
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"test": "vitest run",
|
|
42
42
|
"test:integration": "npm run build && vitest run --config vitest.integration.config.ts",
|
|
43
43
|
"eval": "npm run build && node dist/eval/run-entry.js",
|
|
44
|
+
"eval:stop": "npm run build && node dist/eval/stop-entry.js",
|
|
44
45
|
"eval:watch": "npm run build && node dist/eval/watch-entry.js",
|
|
45
46
|
"interviews": "npm run build && node dist/eval/interview-entry.js",
|
|
46
47
|
"test:eval-sandbox": "npm run build && vitest run --config vitest.eval.config.ts",
|