@ouro.bot/cli 0.1.0-alpha.1506 → 0.1.0-alpha.1508

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 CHANGED
@@ -1,6 +1,20 @@
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.1508",
6
+ "changes": [
7
+ "Bundle sync no longer fails with \"git: 'remote-https' is not a git command\" when the daemon runs under a PATH whose first `git` is the Copilot app's relocatable build without its `GIT_EXEC_PATH`: sync now picks a git that can reach a remote and drops a stale `GIT_EXEC_PATH`.",
8
+ "Peers whose presence record is more than 45 minutes old are marked STALE in \"where i am\" and `ouro presence status`, so a stale view of what runs on which machine is never read as current.",
9
+ "Forwarded Teams messages and pending proactive messages older than 6 hours are dropped (quarantined, for the forwarded outbox) instead of being sent late and repeated in the session."
10
+ ]
11
+ },
12
+ {
13
+ "version": "0.1.0-alpha.1507",
14
+ "changes": [
15
+ "The interview runner runs product H. Its kit runs every arm in the H guest on the books cases, codex and openhands each in its own agent image. A run refuses to start any session unless `--images` names every image the kit needs. Each arm has a replacement list in three tiers: what the arm's own prompt and tools say about the product, then the container's real home and bundle paths, then single brand words. The lists rewrite every arm's paths to /tmp/agent/AgentBundles/sanctuary.agent, and the ouro arm now links that path to its real bundle, as the other arms already did. A test runs each arm's captured first request through its list and the brand scan and finds nothing. codex's `exec_command` and openhands' `terminal` are read as the `shell` calls the books cases check. Every request's rewrites, counted by tier, go on its request-log line. Each arm's totals go in its record and in the printed summary."
16
+ ]
17
+ },
4
18
  {
5
19
  "version": "0.1.0-alpha.1506",
6
20
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1506",
2
+ "runtimeVersion": "0.1.0-alpha.1508",
3
3
  "bundleSchemaVersion": 3,
4
4
  "lastUpdated": "2026-09-03T00:00:00.000Z"
5
5
  }
@@ -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.1506</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1508</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -27,6 +27,7 @@ const remote_1 = require("./sandbox/remote");
27
27
  const targets_1 = require("./targets");
28
28
  const runner_1 = require("./interviews/runner");
29
29
  const kit_1 = require("./interviews/u/kit");
30
+ const kit_2 = require("./interviews/h/kit");
30
31
  const REPO = node_path_1.default.resolve(__dirname, "../..");
31
32
  function take(argv, flag) {
32
33
  const at = argv.indexOf(flag);
@@ -104,7 +105,8 @@ async function main() {
104
105
  lock = await (0, host_lock_1.holdHostLock)((0, remote_1.sshNode)(host, [`${root}/harness/deploy/unraid/ouro-host-lock.mjs`, "hold", "--holder", hostLock.value, "--ttl", String(host_lock_1.HOST_LOCK_TTL_S), "--wait", String(host_lock_1.HOST_LOCK_WAIT_S)]));
105
106
  }
106
107
  try {
107
- return await interviews(args, lock ? stopWhenLockLost(runCaseFor(ssh.value, bundle.value, seed.value, images, lock.token)) : { runCase: runCaseFor(ssh.value, bundle.value, seed.value, images, undefined), started: startedSessions() });
108
+ const agentImages = Object.keys(images?.named ?? {});
109
+ return await interviews(args, lock ? stopWhenLockLost(runCaseFor(ssh.value, bundle.value, seed.value, images, lock.token)) : { runCase: runCaseFor(ssh.value, bundle.value, seed.value, images, undefined), started: startedSessions() }, agentImages);
108
110
  }
109
111
  finally {
110
112
  await lock?.release();
@@ -140,13 +142,14 @@ function stopWhenLockLost(runCase) {
140
142
  },
141
143
  };
142
144
  }
143
- async function interviews(args, deps) {
145
+ async function interviews(args, deps, agentImages) {
144
146
  const { exitCode } = await (0, runner_1.runInterviews)(args, {
145
147
  readText: (file) => node_fs_1.default.readFileSync(file, "utf8"),
146
148
  loadCases: self_test_1.loadCases,
147
149
  resolveTarget: (spec, creds) => (0, targets_1.resolveTarget)(spec, creds),
148
150
  runCase: deps.runCase,
149
- kits: { X: runner_1.X_KIT, U: kit_1.U_KIT },
151
+ kits: { X: runner_1.X_KIT, U: kit_1.U_KIT, H: kit_2.H_KIT },
152
+ agentImages,
150
153
  outputExists: (file) => node_fs_1.default.existsSync(file),
151
154
  writeReport: report_1.writePrivateReport,
152
155
  openLog: openPrivateLog,
@@ -10,7 +10,9 @@ exports.H_OPENHANDS_FIDELITY = exports.H_CODEX_FIDELITY = exports.H_OURO_FIDELIT
10
10
  exports.H_OURO_FIDELITY = [
11
11
  "no provider retries, as in every arm: each error from the host's runtime is marked not retryable, so a retry is never a second metered call",
12
12
  "offers web_search and fetch_url, which fail in the sandbox (no route off the host); the other arms don't offer web search at all, since their hosted search tools can't reach the host's runtime",
13
- "the bundle sits at its production path, so the working folder the model sees differs from the other arms' neutral path",
13
+ "the bundle sits at its production path, where the turn reads it; the arm's list shows the model that path, and /home/ouro, as the other arms' neutral ones (/tmp/agent/AgentBundles/sanctuary.agent), which the guest links to the real ones",
14
+ "every arm's list rewrites the container's user name (ouro) and real paths in what the model sees, tool results included, so a rewritten name that is no path (the user agent, AGENT_HOME, ~/.agent) finds nothing when the model types it, nor does an id or file name with a brand word inside it; model names are in no list, so the host's scan voids a session that shows one",
15
+ "the neutral home is a real folder under /tmp in every arm, with the bundle linked at /tmp/agent/AgentBundles/sanctuary.agent; in the ouro arm, the real home's entries are linked into it when the arm starts, and one the turn makes later is not",
14
16
  "skills aren't listed in the prompt: a skill reaches the model only when the agent reads its file, while the other arms list each skill's name and when-line",
15
17
  ];
16
18
  exports.H_CODEX_FIDELITY = [
@@ -26,10 +28,11 @@ exports.H_CODEX_FIDELITY = [
26
28
  "the request's own settings (tool_choice, parallel_tool_calls, reasoning, include, store, prompt_cache_key and the like) are not passed on: the host's runtime sets the model's settings, as it does for the ouro arm",
27
29
  "codex's leading developer messages become one system message, joined with a blank line, and a message's text parts are joined with a newline, since the harness's messages carry one string each",
28
30
  "codex doesn't know the model's name, so it runs as for any unknown model: its generic base prompt, no apply_patch tool, and output of each tool call cut at 10,000 bytes",
29
- "the brand words in codex's base prompt are replaced before the call reaches the model",
30
- "the shell can still show the brand through the names of the variables codex sets (CODEX_HOME, CODEX_THREAD_ID, CODEX_SESSION_ID, CODEX_CI), none of which is in the prompt; codex adds no helper folder to PATH, since it refuses to create one under /tmp",
31
+ "codex's base prompt is rewritten before the call reaches the model: its first sentences say a coding agent running in a terminal-based coding assistant, and the line on what Codex refers to is removed",
32
+ "what the shell shows of the brand (the variables codex sets, CODEX_HOME, CODEX_THREAD_ID, CODEX_SESSION_ID and CODEX_CI, and codex's own name in output) is rewritten to AGENT_ and agent in tool results; codex adds no helper folder to PATH, since it refuses to create one under /tmp",
31
33
  "codex runs from a neutral home under /tmp (the agent container is read-only elsewhere), with the bundle linked at /tmp/agent/AgentBundles/sanctuary.agent",
32
34
  "codex is killed at 540 seconds, inside the host's 600-second guest deadline, and the turn reports that it exited 137; commands it started stop when the host removes the container at the guest's end",
35
+ "the books checks read each exec_command as a shell call in its workdir; a command typed into an open session through write_stdin is not read as one",
33
36
  "built from source at the pinned commit for x86_64 gnu (on the x86_64 sandbox host, which runs every session), not codex's released musl build, without the release's version stamp",
34
37
  ];
35
38
  exports.H_OPENHANDS_FIDELITY = [
@@ -42,10 +45,11 @@ exports.H_OPENHANDS_FIDELITY = [
42
45
  "the SDK doesn't know the model's name (openai/model), so it uses its defaults for an unknown model; LITELLM_LOCAL_MODEL_COST_MAP = True makes LiteLLM read the cost map it ships with instead of fetching one",
43
46
  "the Butler's persona and the label line are the system message's suffix, after the SDK's own system prompt",
44
47
  "the system prompt is the default preset's (system_prompt_kwargs cli_mode False), so its security-risk wording is the preset's, not the command line's",
45
- "the brand words in the SDK's system prompt and tool descriptions are replaced before the call reaches the model",
46
- "the shell can still show the brand: the tmux socket and session names in TMUX, the ~/.openhands folder, and the LITELLM_LOCAL_MODEL_COST_MAP variable; none is in the prompt. AI_AGENT is set to a neutral name, where the SDK would set its own",
48
+ "the SDK's system prompt and tool descriptions are rewritten before the call reaches the model: the self-documentation section, the previous-conversations and skills-docs lines and the security-risk note's origin are removed, the opening says a helpful AI assistant, and the git identity reads agent <agent@agent.dev>",
49
+ "what the shell shows of the brand (the tmux socket and session names in TMUX, the ~/.openhands folder) is rewritten to agent in tool results; the LITELLM_LOCAL_MODEL_COST_MAP variable has no brand word. AI_AGENT is set to a neutral name, where the SDK would set its own",
47
50
  "the SDK runs on the uv-managed Python 3.13 and uv 0.13.7 its own agent-server image uses, with bytecode compiled at build time because the image is read-only when the arm runs",
48
51
  "runs from a neutral home under /tmp (the agent container is read-only elsewhere), with the bundle linked at /tmp/agent/AgentBundles/sanctuary.agent",
52
+ "the books checks read each terminal call as a shell call in the folder the terminal reported after the call before (tmux keeps the folder between calls); the first starts in the workdir",
49
53
  "the supervisor process is killed at 540 seconds, inside the host's 600-second guest deadline; the terminal's tmux and anything it started stop when the host removes the container at the guest's end",
50
54
  "SHELL is /bin/bash: tmux runs its session through SHELL, and the image's user has no login shell to fall back on",
51
55
  "the supervisor's stdout carries only its status lines; anything the SDK or LiteLLM prints goes to stderr",
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.H_ARMS = void 0;
7
+ exports.linkNeutralPaths = linkNeutralPaths;
7
8
  exports.ouroArm = ouroArm;
8
9
  exports.runHGuest = runHGuest;
9
10
  /**
@@ -17,19 +18,55 @@ exports.runHGuest = runHGuest;
17
18
  * model calls, as every interview guest gives it; the first turn's reply and outcome are the job's.
18
19
  */
19
20
  const node_fs_1 = __importDefault(require("node:fs"));
21
+ const node_path_1 = __importDefault(require("node:path"));
20
22
  const runtime_1 = require("../../../../nerves/runtime");
21
23
  const provider_proxy_1 = require("../../../transport/provider-proxy");
22
24
  const telegram_turn_1 = require("../../../transport/telegram-turn");
23
25
  const codex_1 = require("./codex");
24
26
  const openhands_1 = require("./openhands");
25
- /** The ouro arm: the harness's own turn, unchanged but for the label line and the later message. */
26
- function ouroArm(runTurn = telegram_turn_1.runTelegramTurn) {
27
- return ({ turn, bundle, providerRuntime }) => runTurn({
28
- agentRoot: bundle, prefix: turn.prefix, userText: turn.userText, providerRuntime, systemLine: turn.labelLine, followUps: turn.followUps,
29
- });
27
+ /**
28
+ * The neutral paths the H kit's lists show the model, made to exist in the ouro arm as they do in the others: a real
29
+ * neutral home (`/tmp/agent`, on the container's writable /tmp) with the bundle linked at
30
+ * `AgentBundles/sanctuary.agent`, and a link for each other entry the real home has now. The bundles folder beside the
31
+ * real bundle is the mount point Docker made, which the container's user can't write, so no link goes there. Entries
32
+ * that are already there are kept.
33
+ */
34
+ function linkNeutralPaths(bundle, neutral) {
35
+ const bundles = node_path_1.default.dirname(bundle);
36
+ const home = node_path_1.default.dirname(bundles);
37
+ const exists = (file) => { try {
38
+ node_fs_1.default.lstatSync(file);
39
+ return true;
40
+ }
41
+ catch {
42
+ return false;
43
+ } };
44
+ const named = node_path_1.default.join(neutral, node_path_1.default.basename(bundles), node_path_1.default.basename(bundle).replace(/\.ouro$/, ".agent"));
45
+ node_fs_1.default.mkdirSync(node_path_1.default.dirname(named), { recursive: true });
46
+ if (!exists(named))
47
+ node_fs_1.default.symlinkSync(bundle, named);
48
+ let linked = 0;
49
+ for (const entry of node_fs_1.default.readdirSync(home)) {
50
+ if (entry === node_path_1.default.basename(bundles) || exists(node_path_1.default.join(neutral, entry)))
51
+ continue;
52
+ node_fs_1.default.symlinkSync(node_path_1.default.join(home, entry), node_path_1.default.join(neutral, entry));
53
+ linked += 1;
54
+ }
55
+ (0, runtime_1.emitNervesEvent)({ component: "eval", event: "eval.h_neutral_links", message: "linked the ouro arm's neutral paths", meta: { neutral, linked } });
56
+ }
57
+ /**
58
+ * The ouro arm: the harness's own turn, unchanged but for the label line and the later message. With `neutral`, the
59
+ * neutral paths are linked first; the turn still runs from the bundle at its production path, where it reads it.
60
+ */
61
+ function ouroArm(runTurn = telegram_turn_1.runTelegramTurn, neutral) {
62
+ return ({ turn, bundle, providerRuntime }) => {
63
+ if (neutral !== undefined)
64
+ linkNeutralPaths(bundle, neutral);
65
+ return runTurn({ agentRoot: bundle, prefix: turn.prefix, userText: turn.userText, providerRuntime, systemLine: turn.labelLine, followUps: turn.followUps });
66
+ };
30
67
  }
31
68
  /** The H arms this guest runs. */
32
- exports.H_ARMS = { ouro: ouroArm(), codex: (0, codex_1.codexArm)(), openhands: (0, openhands_1.openhandsArm)() };
69
+ exports.H_ARMS = { ouro: ouroArm(telegram_turn_1.runTelegramTurn, codex_1.CODEX_HOME_DIR), codex: (0, codex_1.codexArm)(), openhands: (0, openhands_1.openhandsArm)() };
33
70
  function readTurnFile(file) {
34
71
  const value = JSON.parse(node_fs_1.default.readFileSync(file, "utf8"));
35
72
  if (value.product !== "H" || typeof value.arm !== "string" || typeof value.labelLine !== "string" || !Array.isArray(value.prefix)
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.H_KIT = exports.H_REPLACEMENTS = exports.H_ARMS_IMAGES = void 0;
4
+ exports.canonicalH = canonicalH;
5
+ /**
6
+ * Product H, whole harnesses (pre-registration v2 section 2), as the runner's `ProductKit`. Every arm runs in the H
7
+ * guest (`h-guest-entry.js`) on the books cases: the ouro arm in the default agent image, codex and openhands each in
8
+ * its own image, which `--images` must name.
9
+ *
10
+ * Each arm's replacement list (section 3) runs in three tiers, in order:
11
+ * - sentences and sections: what the arm's own prompt and tools say about the product, replaced with a neutral
12
+ * sentence or removed where it is only about the product;
13
+ * - paths: the container's real home and bundle, shown to the model as the neutral ones every arm has
14
+ * (/tmp/agent/AgentBundles/sanctuary.agent), which are linked to the real ones, so a path the model copies works;
15
+ * - words: the user's name and the arm's own name, wherever a tool result shows them.
16
+ * Model names are in no list, so the host's scan still voids a session where one appears.
17
+ */
18
+ const runtime_1 = require("../../../nerves/runtime");
19
+ const fidelity_1 = require("../guest/h/fidelity");
20
+ const protocol_1 = require("../protocol");
21
+ /** The named agent images H needs, besides the default one the ouro arm runs in. */
22
+ exports.H_ARMS_IMAGES = ["codex", "openhands"];
23
+ const escape = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
24
+ const sentence = (text, by) => ({ pattern: new RegExp(escape(text), "g"), with: by, tier: "sentence" });
25
+ /** The container's real home and bundle, as every arm shows them; the H guest links both. */
26
+ const PATHS = [
27
+ { pattern: /\/home\/ouro(?![\w.-])/g, with: "/tmp/agent", tier: "path" },
28
+ { pattern: /\bsanctuary\.ouro\b/g, with: "sanctuary.agent", tier: "path" },
29
+ ];
30
+ /** The container's user, `ouro`, and the harness's own name, wherever a tool result shows them. */
31
+ const OURO_WORDS = [
32
+ { pattern: /ouroboros/gi, with: "agent", tier: "word" },
33
+ { pattern: /ouro/gi, with: "agent", tier: "word" },
34
+ ];
35
+ const CODEX = [
36
+ sentence("You are a coding agent running in the Codex CLI, a terminal-based coding assistant. Codex CLI is an open source project led by OpenAI.", "You are a coding agent running in a terminal-based coding assistant."),
37
+ sentence("Within this context, Codex refers to the open-source agentic coding interface (not the old Codex language model built by OpenAI).\n\n", ""),
38
+ ...PATHS,
39
+ // The variables codex puts in the shell (CODEX_HOME, CODEX_THREAD_ID, CODEX_SESSION_ID, CODEX_CI).
40
+ { pattern: /CODEX_/g, with: "AGENT_", tier: "word" },
41
+ { pattern: /codex/gi, with: "agent", tier: "word" },
42
+ ...OURO_WORDS,
43
+ ];
44
+ const OPENHANDS = [
45
+ sentence("You are OpenHands agent, a helpful AI assistant", "You are a helpful AI assistant"),
46
+ sentence("* When asked to find a previous local OpenHands conversation, search the workspace's `workspace/conversations/` directory for its event history.\n", ""),
47
+ sentence("* For more information about skills, see: https://docs.openhands.dev/overview/skills\n", ""),
48
+ { pattern: /<SELF_DOCUMENTATION>[\s\S]*?<\/SELF_DOCUMENTATION>\n\n/g, with: "", tier: "sentence" },
49
+ sentence("an AI agent (OpenHands) on behalf of", "an AI agent on behalf of"),
50
+ sentence("Based on OpenHands security risk levels but adapted for agent-sdk.\n", ""),
51
+ ...PATHS,
52
+ { pattern: /openhands/gi, with: "agent", tier: "word" },
53
+ { pattern: /open hands/gi, with: "agent", tier: "word" },
54
+ { pattern: /all-hands/gi, with: "agent", tier: "word" },
55
+ ...OURO_WORDS,
56
+ ];
57
+ exports.H_REPLACEMENTS = {
58
+ ouro: [...PATHS, ...OURO_WORDS],
59
+ codex: CODEX,
60
+ openhands: OPENHANDS,
61
+ };
62
+ /** The folder openhands' terminal reports after a command, the last such line in its result. */
63
+ const REPORTED_FOLDER = /\[Current working directory: ([^\]\n]+)\]/g;
64
+ const reportedFolder = (result) => [...result.matchAll(REPORTED_FOLDER)].at(-1)?.[1];
65
+ /** A shell call's command and folder, from the arm's own arguments; null when they aren't readable. */
66
+ function shellArgs(arm, name, args, folder) {
67
+ const tool = arm === "codex" ? "exec_command" : arm === "openhands" ? "terminal" : null;
68
+ if (name !== tool)
69
+ return null;
70
+ let value;
71
+ try {
72
+ value = JSON.parse(args);
73
+ }
74
+ catch {
75
+ return null;
76
+ }
77
+ if (typeof value !== "object" || value === null)
78
+ return null;
79
+ const fields = value;
80
+ const command = arm === "codex" ? fields.cmd : fields.command;
81
+ if (typeof command !== "string")
82
+ return null;
83
+ // codex names the call's folder. openhands' tmux keeps the folder between calls, so a call starts where the terminal
84
+ // reported it was after the call before; the first starts in the workdir, the bundle.
85
+ const cwd = arm === "codex" ? (typeof fields.workdir === "string" ? fields.workdir : undefined) : folder;
86
+ return cwd === undefined ? { command } : { command, cwd };
87
+ }
88
+ /** codex's exec_command and openhands' terminal as the `shell` calls the books cases' assertions read. */
89
+ function canonicalH(arm, obs) {
90
+ let mapped = 0;
91
+ let folder;
92
+ const timeline = obs.timeline.map((entry) => {
93
+ if (entry.kind !== "call")
94
+ return entry;
95
+ const shell = shellArgs(arm, entry.name, entry.args, folder);
96
+ if (!shell)
97
+ return entry;
98
+ if (arm === "openhands")
99
+ folder = reportedFolder(entry.result) ?? folder;
100
+ mapped += 1;
101
+ return { ...entry, name: "shell", args: JSON.stringify(shell) };
102
+ });
103
+ (0, runtime_1.emitNervesEvent)({ component: "eval", event: "eval.h_canonical", message: "read an H arm's calls as shell calls", meta: { arm, mapped } });
104
+ return { ...obs, timeline };
105
+ }
106
+ exports.H_KIT = {
107
+ guest: ({ session, arm, case: c, debrief }) => {
108
+ const last = c.prefix[c.prefix.length - 1];
109
+ return {
110
+ entry: "h-guest-entry.js",
111
+ turn: { product: session.product, arm: arm.arm, labelLine: (0, protocol_1.labelLine)(session.product, arm.label), prefix: c.prefix.slice(0, -1), userText: last.content, followUps: [debrief] },
112
+ ...(arm.arm === "ouro" ? {} : { image: arm.arm }),
113
+ };
114
+ },
115
+ canonical: canonicalH,
116
+ fidelity: { "H:ouro": [...fidelity_1.H_OURO_FIDELITY], "H:codex": [...fidelity_1.H_CODEX_FIDELITY], "H:openhands": [...fidelity_1.H_OPENHANDS_FIDELITY] },
117
+ replacements: (arm) => Object.hasOwn(exports.H_REPLACEMENTS, arm) ? exports.H_REPLACEMENTS[arm] : undefined,
118
+ images: exports.H_ARMS_IMAGES,
119
+ };
@@ -95,19 +95,23 @@ function guardedRuntime(input) {
95
95
  const rewritten = input.replacements ? (0, rewrite_1.rewriteRequest)(own, input.replacements) : undefined;
96
96
  const request = rewritten?.request ?? own;
97
97
  const body = requestText(request);
98
+ const counted = rewritten ? { rewrites: rewritten.rewrites } : {};
99
+ if (rewritten && input.rewrites)
100
+ for (const [tier, n] of Object.entries(rewritten.rewrites))
101
+ input.rewrites[tier] = (input.rewrites[tier] ?? 0) + n;
98
102
  const hits = (0, protocol_1.brandHits)(body);
99
103
  if (hits.length > 0) {
100
104
  latch._void(hits);
101
- input.log({ kind: gate.kind, sent: false, body });
105
+ input.log({ kind: gate.kind, sent: false, body, ...counted });
102
106
  latch._record({ kind: gate.kind, usage: null, credits: 0, sent: false });
103
107
  (0, runtime_1.emitNervesEvent)({ component: "eval", level: "warn", event: "eval.interview_request_void", message: "refused a request with brand words; its session is void", meta: { kind: gate.kind, count: hits.length } });
104
108
  throw new RefusedCall(`not sent: the request names ${[...new Set(hits.map((hit) => hit.toLowerCase()))].join(", ")}`, "brand");
105
109
  }
106
110
  if (!gate.take()) {
107
- input.log({ kind: gate.kind, sent: false, body });
111
+ input.log({ kind: gate.kind, sent: false, body, ...counted });
108
112
  throw new RefusedCall(`not sent: ${gate.refused()}`, "limit");
109
113
  }
110
- input.log({ kind: gate.kind, sent: true, body });
114
+ input.log({ kind: gate.kind, sent: true, body, ...counted });
111
115
  // The provider builds its body from the messages just scanned, never from items it kept from an earlier call (a
112
116
  // Responses-API runtime keeps reasoning and output items otherwise), so what is sent is what was scanned.
113
117
  input.inner.resetTurnState(request.messages);
@@ -3,22 +3,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.replace = replace;
4
4
  exports.rewriteRequest = rewriteRequest;
5
5
  const runtime_1 = require("../../nerves/runtime");
6
- /** Applies the list in order to one text. */
7
- function replace(text, list) {
8
- return list.reduce((out, { pattern, with: by }) => {
6
+ /** Applies the list in order to one text, adding each replacement's matches to `counts` when given. */
7
+ function replace(text, list, counts) {
8
+ return list.reduce((out, { pattern, with: by, tier = "list" }) => {
9
9
  if (!pattern.global)
10
10
  throw new Error(`replacement ${String(pattern)} must be global (the g flag)`);
11
+ if (counts) {
12
+ const matches = out.match(pattern)?.length ?? 0;
13
+ if (matches > 0)
14
+ counts[tier] = (counts[tier] ?? 0) + matches;
15
+ }
11
16
  return out.replace(pattern, by);
12
17
  }, text);
13
18
  }
14
19
  /** Every string in a plain value rewritten; anything else as it is. */
15
- function deep(value, list) {
20
+ function deep(value, list, counts) {
16
21
  if (typeof value === "string")
17
- return replace(value, list);
22
+ return replace(value, list, counts);
18
23
  if (Array.isArray(value))
19
- return value.map((item) => deep(item, list));
24
+ return value.map((item) => deep(item, list, counts));
20
25
  if (value !== null && typeof value === "object")
21
- return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, deep(item, list)]));
26
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, deep(item, list, counts)]));
22
27
  return value;
23
28
  }
24
29
  /**
@@ -26,13 +31,14 @@ function deep(value, list) {
26
31
  * name. The harness's own fields (callbacks, signal) are passed through untouched.
27
32
  */
28
33
  function rewriteRequest(request, list) {
34
+ const rewrites = {};
29
35
  const rewritten = {
30
36
  ...request,
31
- messages: deep(request.messages, list),
32
- activeTools: deep(request.activeTools, list),
33
- ...(request.deferredTools ? { deferredTools: deep(request.deferredTools, list) } : {}),
34
- ...(request.systemPrompt ? { systemPrompt: deep(request.systemPrompt, list) } : {}),
35
- ...(request.traceId !== undefined ? { traceId: replace(request.traceId, list) } : {}),
37
+ messages: deep(request.messages, list, rewrites),
38
+ activeTools: deep(request.activeTools, list, rewrites),
39
+ ...(request.deferredTools ? { deferredTools: deep(request.deferredTools, list, rewrites) } : {}),
40
+ ...(request.systemPrompt ? { systemPrompt: deep(request.systemPrompt, list, rewrites) } : {}),
41
+ ...(request.traceId !== undefined ? { traceId: replace(request.traceId, list, rewrites) } : {}),
36
42
  };
37
43
  const back = new Map();
38
44
  for (const tool of [...request.activeTools, ...request.deferredTools ?? []]) {
@@ -45,5 +51,5 @@ function rewriteRequest(request, list) {
45
51
  }
46
52
  back.set(sent, own);
47
53
  }
48
- return { request: rewritten, toolName: (name) => back.get(name) ?? name };
54
+ return { request: rewritten, toolName: (name) => back.get(name) ?? name, rewrites };
49
55
  }
@@ -87,7 +87,7 @@ function armRecord(input) {
87
87
  return {
88
88
  label: input.arm.label, arm: input.arm.arm, ...verdict, outcome: raw.outcome, checks: graded.checks, note, rating: (0, protocol_1.ratingOf)(note),
89
89
  debriefOutcome: debrief?.outcome ?? null, debriefToolCalls: debrief?.toolCalls ?? 0,
90
- jobCalls: input.job.calls(), debriefCalls: input.debrief.calls(), observation,
90
+ jobCalls: input.job.calls(), debriefCalls: input.debrief.calls(), rewrites: input.rewrites, observation,
91
91
  };
92
92
  }
93
93
  /** A kit's verdict, or a failed one when it throws: the guest's grade is untrusted input. */
@@ -124,8 +124,8 @@ async function runSession(input) {
124
124
  ouroFirst: false, voidedBy: null, calls: [], spent: ZERO,
125
125
  };
126
126
  const c = caseOf(input.kit, input.cases, session);
127
- const guard = (gateFor, replacements) => (0, latch_1.guardedRuntime)({
128
- inner: input.target.runtime, latch, ledger: input.ledger, pricing: input.pricing, gateFor, ...(replacements ? { replacements } : {}),
127
+ const guard = (gateFor, replacements, rewrites) => (0, latch_1.guardedRuntime)({
128
+ inner: input.target.runtime, latch, ledger: input.ledger, pricing: input.pricing, gateFor, ...(replacements ? { replacements, rewrites } : {}),
129
129
  log: (entry) => input.log(JSON.stringify({ session: session.id, preregistrationVersion: input.version, ...entry })),
130
130
  });
131
131
  const end = (status, why) => {
@@ -137,7 +137,8 @@ async function runSession(input) {
137
137
  const job = latch.gate("job");
138
138
  const debriefGate = latch.gate("debrief");
139
139
  // The gate reads the runner's own request, so the debrief is told apart before the arm's list rewrites it.
140
- const host = guard((request) => request.messages.some((m) => m.role === "user" && m.content === debrief) ? debriefGate : job, input.kit.replacements?.(arm.arm));
140
+ const rewrites = {};
141
+ const host = guard((request) => request.messages.some((m) => m.role === "user" && m.content === debrief) ? debriefGate : job, input.kit.replacements?.(arm.arm), rewrites);
141
142
  let obs;
142
143
  try {
143
144
  obs = await input.runCase({ case: c, host, budget: { take: () => true }, guest: input.kit.guest({ session, arm, case: c, debrief }) });
@@ -146,7 +147,7 @@ async function runSession(input) {
146
147
  end("crashed", `${arm.label}: ${(0, loop_1.messageOf)(error)}`);
147
148
  break;
148
149
  }
149
- const armResult = armRecord({ arm, c, obs, kit: input.kit, job, debrief: debriefGate });
150
+ const armResult = armRecord({ arm, c, obs, kit: input.kit, job, debrief: debriefGate, rewrites });
150
151
  record.arms.push(armResult);
151
152
  if (latch.voided()) {
152
153
  end("void", `${arm.label}: a request named ${named(latch.voided())}`);
@@ -189,7 +190,8 @@ function summarizeSessions(records, spent, stopped) {
189
190
  const lines = records.map((r) => {
190
191
  const passed = r.arms.filter((arm) => arm.passed).length;
191
192
  const usage = r.calls.reduce((sum, call) => ({ input: sum.input + (call.usage?.input_tokens ?? 0), output: sum.output + (call.usage?.output_tokens ?? 0) }), { input: 0, output: 0 });
192
- return `${r.id} ${r.status} ouro-first=${r.ouroFirst ? "yes" : "no"} jobs-passed=${passed}/${r.arms.length} calls=${r.calls.length} tokens-in=${usage.input} tokens-out=${usage.output} credits=${r.spent.credits.toFixed(3)} premium=${r.spent.premium}`;
193
+ const rewrites = r.arms.map((arm) => `${arm.arm}:${Object.entries(arm.rewrites).map(([tier, n]) => `${tier} ${n}`).join(",") || "none"}`).join(";");
194
+ return `${r.id} ${r.status} ouro-first=${r.ouroFirst ? "yes" : "no"} jobs-passed=${passed}/${r.arms.length} calls=${r.calls.length} tokens-in=${usage.input} tokens-out=${usage.output} credits=${r.spent.credits.toFixed(3)} premium=${r.spent.premium}${rewrites ? ` rewrites=${rewrites}` : ""}`;
193
195
  });
194
196
  return [...lines, `spent: ${spent.credits.toFixed(3)} credits, ${spent.premium} premium requests${stopped ? `; stopped: ${stopped}` : ""}`].join("\n");
195
197
  }
@@ -221,6 +223,11 @@ async function runInterviews(args, deps) {
221
223
  const missingKit = chosen.find((session) => !deps.kits[session.product]);
222
224
  if (missingKit)
223
225
  throw new Error(`session ${missingKit.id} is product ${missingKit.product}, which has no runner kit yet`);
226
+ for (const session of chosen) {
227
+ const missing = (deps.kits[session.product].images ?? []).find((name) => !(deps.agentImages ?? []).includes(name));
228
+ if (missing)
229
+ throw new Error(`session ${session.id} needs the agent image ${missing}; name it in --images as ${missing}=<image>`);
230
+ }
224
231
  const fidelity = fidelityOf(deps.kits, chosen);
225
232
  const cases = new Map(deps.loadCases(args.cases).map((c) => [c.id, c]));
226
233
  const missingCase = chosen.find((session) => !caseOf(deps.kits[session.product], cases, session));
@@ -238,7 +238,8 @@ 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 seen = record ? `${record.version}, seen ${ago(record.seenAt, now)}` : "no presence record yet";
241
+ const stale = record && (0, presence_1.isStaleSeenAt)(record.seenAt, now.getTime()) ? " [STALE: verify before routing work here]" : "";
242
+ const seen = record ? `${record.version}, seen ${ago(record.seenAt, now)}${stale}` : "no presence record yet";
242
243
  const legacy = presence.legacy.includes(machine.machineId) ? "; may run a home-only daemon" : "";
243
244
  lines.push(`- ${machine.name}${me}: ${machine.role}; ${seen}${legacy}`);
244
245
  }
@@ -58,7 +58,7 @@ var __importStar = (this && this.__importStar) || (function () {
58
58
  };
59
59
  })();
60
60
  Object.defineProperty(exports, "__esModule", { value: true });
61
- exports.SHARED_SENSES = exports.PRESENCE_FIRST_VERSION = exports.PRESENCE_SCHEMA = void 0;
61
+ exports.STALE_PEER_MS = exports.SHARED_SENSES = exports.PRESENCE_FIRST_VERSION = exports.PRESENCE_SCHEMA = void 0;
62
62
  exports.isSharedSense = isSharedSense;
63
63
  exports.parsePresenceBlock = parsePresenceBlock;
64
64
  exports.compareVersions = compareVersions;
@@ -90,6 +90,7 @@ exports.ownsSense = ownsSense;
90
90
  exports.ownedSharedSenses = ownedSharedSenses;
91
91
  exports.findRosterMachine = findRosterMachine;
92
92
  exports.emitOwnershipChange = emitOwnershipChange;
93
+ exports.isStaleSeenAt = isStaleSeenAt;
93
94
  const fs = __importStar(require("fs"));
94
95
  const os = __importStar(require("os"));
95
96
  const path = __importStar(require("path"));
@@ -460,3 +461,9 @@ function emitOwnershipChange(agent, sense, owns, owner) {
460
461
  meta: { agent, sense, owner },
461
462
  });
462
463
  }
464
+ /** Peers publish every 15 min; three missed cycles means the record can no longer be trusted. */
465
+ exports.STALE_PEER_MS = 45 * 60_000;
466
+ function isStaleSeenAt(seenAt, nowMs) {
467
+ const ms = nowMs - Date.parse(seenAt);
468
+ return !Number.isFinite(ms) || ms > exports.STALE_PEER_MS;
469
+ }
@@ -0,0 +1,115 @@
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.resetGitBinaryCache = resetGitBinaryCache;
37
+ exports.gitRuntimeEnv = gitRuntimeEnv;
38
+ exports.resolveGitBinary = resolveGitBinary;
39
+ const child_process_1 = require("child_process");
40
+ const fs = __importStar(require("fs"));
41
+ const path = __importStar(require("path"));
42
+ const runtime_1 = require("../nerves/runtime");
43
+ /**
44
+ * Which `git` the bundle sync runs. The `git` first on a daemon's PATH is not always one that can fetch: the Copilot
45
+ * app bundles a relocatable git that finds its helpers only through the `GIT_EXEC_PATH` the app sets, so a daemon
46
+ * (or a shim that execs the first non-shim `git`) without it computes `//libexec/git-core` and every fetch dies with
47
+ * "git: 'remote-https' is not a git command". Sync probes `git --exec-path` once per environment and, when the PATH
48
+ * git cannot serve the https/ssh helpers, uses the first candidate that can.
49
+ */
50
+ const FALLBACK_GITS = ["/usr/bin/git", "/opt/homebrew/bin/git", "/usr/local/bin/git"];
51
+ const resolved = new Map();
52
+ /** Forget probed results (tests). */
53
+ function resetGitBinaryCache() {
54
+ resolved.clear();
55
+ }
56
+ function execPathOf(binary, env) {
57
+ const run = (0, child_process_1.spawnSync)(binary, ["--exec-path"], { env, encoding: "utf-8", timeout: 5000, stdio: ["ignore", "pipe", "ignore"] });
58
+ return run.status === 0 && run.stdout.trim() ? run.stdout.trim() : null;
59
+ }
60
+ /** A git can serve the network when its exec path holds the transport helpers. */
61
+ function healthy(binary, env, exists) {
62
+ const execPath = execPathOf(binary, env);
63
+ return execPath !== null && exists(path.join(execPath, "git-remote-https"));
64
+ }
65
+ function candidates(env) {
66
+ const onPath = (env.PATH ?? "").split(path.delimiter).filter(Boolean).map((dir) => path.join(dir, "git"));
67
+ return [...new Set(["git", ...onPath, ...FALLBACK_GITS])];
68
+ }
69
+ /**
70
+ * The environment git runs under. A `GIT_EXEC_PATH` that points at a deleted cache is dropped so git's own
71
+ * (when it has one) applies.
72
+ */
73
+ function gitRuntimeEnv(env, exists = fs.existsSync) {
74
+ const kept = { ...env };
75
+ const execPath = kept.GIT_EXEC_PATH;
76
+ if (execPath !== undefined && !exists(path.join(execPath, "git-remote-https"))) {
77
+ delete kept.GIT_EXEC_PATH;
78
+ (0, runtime_1.emitNervesEvent)({
79
+ level: "warn",
80
+ component: "heart",
81
+ event: "heart.git_exec_path_dropped",
82
+ message: "git: ignored a GIT_EXEC_PATH that holds no transport helpers",
83
+ meta: { execPath },
84
+ });
85
+ }
86
+ for (const name of ["GIT_TEMPLATE_DIR", "GIT_CONFIG_SYSTEM"]) {
87
+ const value = kept[name];
88
+ if (value !== undefined && value !== "" && !exists(value))
89
+ delete kept[name];
90
+ }
91
+ return kept;
92
+ }
93
+ /** The git executable that can reach a remote under `env`; `git` itself when none can (the failure then names the cause). */
94
+ function resolveGitBinary(env, exists = fs.existsSync) {
95
+ const key = `${env.PATH ?? ""}\0${env.GIT_EXEC_PATH ?? ""}`;
96
+ const cached = resolved.get(key);
97
+ if (cached !== undefined)
98
+ return cached;
99
+ let chosen = "git";
100
+ for (const candidate of candidates(env)) {
101
+ if (healthy(candidate, env, exists)) {
102
+ chosen = candidate;
103
+ break;
104
+ }
105
+ }
106
+ resolved.set(key, chosen);
107
+ (0, runtime_1.emitNervesEvent)({
108
+ level: chosen === "git" ? "info" : "warn",
109
+ component: "heart",
110
+ event: "heart.git_binary_resolved",
111
+ message: chosen === "git" ? "git: the git on PATH can reach remotes" : "git: the git on PATH cannot reach remotes; using another",
112
+ meta: { chosen },
113
+ });
114
+ return chosen;
115
+ }
@@ -66,6 +66,7 @@ const crypto_1 = require("crypto");
66
66
  const fs = __importStar(require("fs"));
67
67
  const path = __importStar(require("path"));
68
68
  const runtime_1 = require("../nerves/runtime");
69
+ const git_binary_1 = require("./git-binary");
69
70
  const sync_health_1 = require("./sync-health");
70
71
  const sync_lock_1 = require("./sync-lock");
71
72
  /** What sync tells the owner, once, when it holds off a first push to an empty remote. */
@@ -170,7 +171,7 @@ function identityArgs(agentName) {
170
171
  }
171
172
  /** git's messages are matched in English, so the locale is pinned. */
172
173
  function gitEnv(extra = {}) {
173
- return { ...process.env, GIT_TERMINAL_PROMPT: "0", LC_ALL: "C", LANG: "C", ...extra };
174
+ return { ...(0, git_binary_1.gitRuntimeEnv)(process.env), GIT_TERMINAL_PROMPT: "0", LC_ALL: "C", LANG: "C", ...extra };
174
175
  }
175
176
  /**
176
177
  * The environment of a fetch or push. When the container has the key mount,
@@ -184,9 +185,10 @@ function syncNetworkEnv() {
184
185
  return gitEnv({ GIT_SSH_COMMAND: exports.SYNC_SSH_COMMAND, GIT_SSH_VARIANT: "ssh" });
185
186
  }
186
187
  function runGit(agentRoot, agentName, args, env, input) {
187
- const run = (0, child_process_1.spawnSync)("git", [...identityArgs(agentName), ...args], {
188
+ const runEnv = gitEnv(env);
189
+ const run = (0, child_process_1.spawnSync)((0, git_binary_1.resolveGitBinary)(runEnv), [...identityArgs(agentName), ...args], {
188
190
  cwd: agentRoot,
189
- env: gitEnv(env),
191
+ env: runEnv,
190
192
  input,
191
193
  stdio: [input === undefined ? "ignore" : "pipe", "pipe", "pipe"],
192
194
  timeout: exports.SYNC_GIT_TIMEOUT_MS,
@@ -222,9 +224,10 @@ function gitOnPaths(agentRoot, agentName, args, paths) {
222
224
  */
223
225
  function runGitAsync(agentRoot, agentName, args, timeoutMs, signal) {
224
226
  return new Promise((resolve) => {
225
- const child = (0, child_process_1.spawn)("git", [...identityArgs(agentName), ...args], {
227
+ const childEnv = syncNetworkEnv();
228
+ const child = (0, child_process_1.spawn)((0, git_binary_1.resolveGitBinary)(childEnv), [...identityArgs(agentName), ...args], {
226
229
  cwd: agentRoot,
227
- env: syncNetworkEnv(),
230
+ env: childEnv,
228
231
  stdio: ["ignore", "pipe", "pipe"],
229
232
  detached: true,
230
233
  });
@@ -58,6 +58,9 @@ function ago(seenAt, nowMs) {
58
58
  const hours = Math.round(minutes / 60);
59
59
  return hours < 48 ? `${hours} h ago` : `${Math.round(hours / 24)} days ago`;
60
60
  }
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; verify the machine is reachable and check bundle sync before routing work to it]" : "";
63
+ }
61
64
  function sessionCounts(record) {
62
65
  const counts = record?.appSessions?.counts;
63
66
  if (!counts)
@@ -86,7 +89,7 @@ function renderWhereAmI(presence, self, nowMs = Date.now()) {
86
89
  for (const peer of peers) {
87
90
  const record = presence.peers.find((candidate) => candidate.machineId === peer.machineId);
88
91
  const facts = [peer.role, record?.os, record?.location].filter(Boolean).join(", ");
89
- const seen = record ? `last seen ${ago(record.seenAt, nowMs)} on ${record.version}${sessionCounts(record)}` : "not seen yet (no presence record)";
92
+ const seen = record ? `last seen ${ago(record.seenAt, nowMs)} on ${record.version}${sessionCounts(record)}${staleNote(record.seenAt, nowMs)}` : "not seen yet (no presence record)";
90
93
  lines.push(`- ${peer.name} (${facts}): ${seen}`);
91
94
  }
92
95
  }
@@ -108,7 +111,7 @@ function renderWhereAmI(presence, self, nowMs = Date.now()) {
108
111
  lines.push(`shared senses that run on a peer, not here: ${elsewhere.map((sense) => {
109
112
  const owner = (0, presence_1.effectiveOwner)(presence, sense);
110
113
  const record = presence.peers.find((peer) => peer.machineId === owner);
111
- const shown = record?.owns?.includes(sense) ? `its record from ${ago(record.seenAt, nowMs)} says it runs it` : "its last record does not show it running";
114
+ const shown = record?.owns?.includes(sense) ? `its record from ${ago(record.seenAt, nowMs)} says it runs it${staleNote(record.seenAt, nowMs)}` : "its last record does not show it running";
112
115
  return `${sense} (${machineName(owner)}; ${shown})`;
113
116
  }).join(", ")}.`);
114
117
  }
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.TEAMS_OUTBOX_SETTLE_MS = exports.TEAMS_OUTBOX_DRAIN_INTERVAL_MS = exports.TEAMS_OUTBOX_MAX_PER_DRAIN = exports.TEAMS_OUTBOX_VERSION = void 0;
36
+ exports.TEAMS_OUTBOX_MAX_AGE_MS = exports.TEAMS_OUTBOX_SETTLE_MS = exports.TEAMS_OUTBOX_DRAIN_INTERVAL_MS = exports.TEAMS_OUTBOX_MAX_PER_DRAIN = exports.TEAMS_OUTBOX_VERSION = void 0;
37
37
  exports.teamsOutboxDir = teamsOutboxDir;
38
38
  exports.teamsOutboxFailedDir = teamsOutboxFailedDir;
39
39
  exports.writeTeamsOutboxEntry = writeTeamsOutboxEntry;
@@ -58,6 +58,8 @@ exports.TEAMS_OUTBOX_MAX_PER_DRAIN = 20;
58
58
  exports.TEAMS_OUTBOX_DRAIN_INTERVAL_MS = 30_000;
59
59
  /** A file that does not parse may still be arriving through a pull; it is quarantined only once it is this old. */
60
60
  exports.TEAMS_OUTBOX_SETTLE_MS = 60_000;
61
+ /** A forwarded message this old is no longer news; sending it would replay a dead proactive message into Teams and the session. */
62
+ exports.TEAMS_OUTBOX_MAX_AGE_MS = 6 * 60 * 60_000;
61
63
  function teamsOutboxDir(agentRoot) {
62
64
  return path.join(agentRoot, "presence", "outbox");
63
65
  }
@@ -157,6 +159,11 @@ async function drainOnce(agentRoot, send, options) {
157
159
  result.quarantined++;
158
160
  continue;
159
161
  }
162
+ if (now() - Date.parse(entry.createdAt) > exports.TEAMS_OUTBOX_MAX_AGE_MS) {
163
+ quarantine(agentRoot, name, "expired", entry.friendId);
164
+ result.quarantined++;
165
+ continue;
166
+ }
160
167
  let sent;
161
168
  try {
162
169
  sent = await send({
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.TYPING_KEEPALIVE_MS = exports.DEFAULT_FLUSH_INTERVAL_MS = void 0;
36
+ exports.TEAMS_PENDING_MAX_AGE_MS = exports.TYPING_KEEPALIVE_MS = exports.DEFAULT_FLUSH_INTERVAL_MS = void 0;
37
37
  exports.aiLabelEntities = aiLabelEntities;
38
38
  exports.stripMentions = stripMentions;
39
39
  exports.splitMessage = splitMessage;
@@ -2070,11 +2070,29 @@ function scanPendingTeamsFiles(pendingRoot) {
2070
2070
  }
2071
2071
  return results;
2072
2072
  }
2073
+ /** Matches the forwarded-outbox expiry in teams-outbox.ts. */
2074
+ exports.TEAMS_PENDING_MAX_AGE_MS = 6 * 60 * 60_000;
2073
2075
  async function drainAndSendPendingTeams(store, botApi, pendingRoot) {
2074
2076
  const root = pendingRoot ?? path.join((0, identity_1.getAgentRoot)(), "state", "pending");
2075
2077
  const pendingFiles = scanPendingTeamsFiles(root);
2076
2078
  const result = { sent: 0, skipped: 0, failed: 0 };
2077
2079
  for (const { friendId, key, filePath, content } of pendingFiles) {
2080
+ // A pending message that has failed to send for hours is dead news; sending it now would replay it into the session.
2081
+ if (Date.now() - fs.statSync(filePath).mtimeMs > exports.TEAMS_PENDING_MAX_AGE_MS) {
2082
+ result.skipped++;
2083
+ try {
2084
+ fs.unlinkSync(filePath);
2085
+ }
2086
+ catch { /* ignore */ }
2087
+ (0, runtime_1.emitNervesEvent)({
2088
+ level: "warn",
2089
+ component: "senses",
2090
+ event: "senses.teams_pending_expired",
2091
+ message: "dropped a pending Teams message too old to send",
2092
+ meta: { friendId },
2093
+ });
2094
+ continue;
2095
+ }
2078
2096
  let parsed;
2079
2097
  try {
2080
2098
  parsed = JSON.parse(content);
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1506",
3
+ "version": "0.1.0-alpha.1508",
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.1506",
9
+ "version": "0.1.0-alpha.1508",
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.1506",
3
+ "version": "0.1.0-alpha.1508",
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": {