@ouro.bot/cli 0.1.0-alpha.1507 → 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,14 @@
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
+ },
4
12
  {
5
13
  "version": "0.1.0-alpha.1507",
6
14
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1507",
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.1507</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>
@@ -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.1507",
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.1507",
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.1507",
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": {