@ouro.bot/cli 0.1.0-alpha.9 → 0.1.0-alpha.91
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/AdoptionSpecialist.ouro/agent.json +70 -9
- package/AdoptionSpecialist.ouro/psyche/SOUL.md +5 -2
- package/AdoptionSpecialist.ouro/psyche/identities/monty.md +2 -2
- package/README.md +147 -205
- package/assets/ouroboros.png +0 -0
- package/changelog.json +536 -0
- package/dist/heart/active-work.js +251 -0
- package/dist/heart/bridges/manager.js +358 -0
- package/dist/heart/bridges/state-machine.js +135 -0
- package/dist/heart/bridges/store.js +123 -0
- package/dist/heart/commitments.js +109 -0
- package/dist/heart/config.js +68 -23
- package/dist/heart/core.js +452 -93
- package/dist/heart/cross-chat-delivery.js +146 -0
- package/dist/heart/daemon/agent-discovery.js +81 -0
- package/dist/heart/daemon/auth-flow.js +430 -0
- package/dist/heart/daemon/daemon-cli.js +1738 -269
- package/dist/heart/daemon/daemon-entry.js +55 -6
- package/dist/heart/daemon/daemon-runtime-sync.js +212 -0
- package/dist/heart/daemon/daemon.js +216 -10
- package/dist/heart/daemon/hatch-animation.js +10 -3
- package/dist/heart/daemon/hatch-flow.js +7 -82
- package/dist/heart/daemon/hooks/bundle-meta.js +92 -0
- package/dist/heart/daemon/launchd.js +159 -0
- package/dist/heart/daemon/log-tailer.js +4 -3
- package/dist/heart/daemon/message-router.js +17 -8
- package/dist/heart/daemon/ouro-bot-entry.js +0 -0
- package/dist/heart/daemon/ouro-bot-global-installer.js +128 -0
- package/dist/heart/daemon/ouro-entry.js +0 -0
- package/dist/heart/daemon/ouro-path-installer.js +260 -0
- package/dist/heart/daemon/ouro-uti.js +11 -2
- package/dist/heart/daemon/ouro-version-manager.js +171 -0
- package/dist/heart/daemon/process-manager.js +14 -1
- package/dist/heart/daemon/run-hooks.js +37 -0
- package/dist/heart/daemon/runtime-logging.js +58 -15
- package/dist/heart/daemon/runtime-metadata.js +219 -0
- package/dist/heart/daemon/runtime-mode.js +67 -0
- package/dist/heart/daemon/sense-manager.js +307 -0
- package/dist/heart/daemon/skill-management-installer.js +94 -0
- package/dist/heart/daemon/socket-client.js +202 -0
- package/dist/heart/daemon/specialist-orchestrator.js +53 -84
- package/dist/heart/daemon/specialist-prompt.js +63 -11
- package/dist/heart/daemon/specialist-tools.js +211 -60
- package/dist/heart/daemon/staged-restart.js +114 -0
- package/dist/heart/daemon/thoughts.js +507 -0
- package/dist/heart/daemon/update-checker.js +111 -0
- package/dist/heart/daemon/update-hooks.js +138 -0
- package/dist/heart/daemon/wrapper-publish-guard.js +86 -0
- package/dist/heart/delegation.js +62 -0
- package/dist/heart/identity.js +126 -21
- package/dist/heart/kicks.js +1 -19
- package/dist/heart/model-capabilities.js +48 -0
- package/dist/heart/obligations.js +191 -0
- package/dist/heart/progress-story.js +42 -0
- package/dist/heart/providers/anthropic.js +74 -9
- package/dist/heart/providers/azure.js +86 -7
- package/dist/heart/providers/github-copilot.js +149 -0
- package/dist/heart/providers/minimax.js +4 -0
- package/dist/heart/providers/openai-codex.js +12 -3
- package/dist/heart/safe-workspace.js +362 -0
- package/dist/heart/sense-truth.js +61 -0
- package/dist/heart/session-activity.js +169 -0
- package/dist/heart/session-recall.js +116 -0
- package/dist/heart/streaming.js +100 -22
- package/dist/heart/target-resolution.js +123 -0
- package/dist/heart/turn-coordinator.js +28 -0
- package/dist/mind/associative-recall.js +14 -2
- package/dist/mind/bundle-manifest.js +70 -0
- package/dist/mind/context.js +57 -11
- package/dist/mind/first-impressions.js +16 -2
- package/dist/mind/friends/channel.js +35 -0
- package/dist/mind/friends/group-context.js +144 -0
- package/dist/mind/friends/store-file.js +19 -0
- package/dist/mind/friends/trust-explanation.js +74 -0
- package/dist/mind/friends/types.js +8 -0
- package/dist/mind/memory.js +27 -26
- package/dist/mind/obligation-steering.js +31 -0
- package/dist/mind/pending.js +76 -9
- package/dist/mind/phrases.js +1 -0
- package/dist/mind/prompt.js +467 -77
- package/dist/mind/token-estimate.js +8 -12
- package/dist/nerves/cli-logging.js +15 -2
- package/dist/nerves/coverage/run-artifacts.js +1 -1
- package/dist/nerves/index.js +12 -0
- package/dist/repertoire/ado-client.js +4 -2
- package/dist/repertoire/coding/feedback.js +180 -0
- package/dist/repertoire/coding/index.js +4 -1
- package/dist/repertoire/coding/manager.js +69 -4
- package/dist/repertoire/coding/spawner.js +21 -3
- package/dist/repertoire/coding/tools.js +105 -2
- package/dist/repertoire/data/ado-endpoints.json +188 -0
- package/dist/repertoire/guardrails.js +290 -0
- package/dist/repertoire/mcp-client.js +254 -0
- package/dist/repertoire/mcp-manager.js +195 -0
- package/dist/repertoire/skills.js +3 -26
- package/dist/repertoire/tasks/board.js +12 -0
- package/dist/repertoire/tasks/index.js +23 -9
- package/dist/repertoire/tasks/transitions.js +1 -2
- package/dist/repertoire/tools-base.js +714 -249
- package/dist/repertoire/tools-bluebubbles.js +93 -0
- package/dist/repertoire/tools-teams.js +58 -25
- package/dist/repertoire/tools.js +106 -53
- package/dist/senses/bluebubbles-client.js +210 -5
- package/dist/senses/bluebubbles-entry.js +2 -0
- package/dist/senses/bluebubbles-inbound-log.js +109 -0
- package/dist/senses/bluebubbles-media.js +339 -0
- package/dist/senses/bluebubbles-model.js +12 -4
- package/dist/senses/bluebubbles-mutation-log.js +45 -5
- package/dist/senses/bluebubbles-runtime-state.js +109 -0
- package/dist/senses/bluebubbles-session-cleanup.js +72 -0
- package/dist/senses/bluebubbles.js +894 -45
- package/dist/senses/cli-layout.js +187 -0
- package/dist/senses/cli.js +400 -164
- package/dist/senses/continuity.js +94 -0
- package/dist/senses/debug-activity.js +154 -0
- package/dist/senses/inner-dialog-worker.js +47 -18
- package/dist/senses/inner-dialog.js +377 -83
- package/dist/senses/pipeline.js +307 -0
- package/dist/senses/teams.js +573 -129
- package/dist/senses/trust-gate.js +112 -2
- package/package.json +14 -3
- package/subagents/README.md +4 -70
- package/dist/heart/daemon/specialist-session.js +0 -142
- package/dist/heart/daemon/subagent-installer.js +0 -125
- package/dist/inner-worker-entry.js +0 -4
- package/subagents/work-doer.md +0 -233
- package/subagents/work-merger.md +0 -624
- package/subagents/work-planner.md +0 -373
|
@@ -0,0 +1,219 @@
|
|
|
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.getRuntimeMetadata = getRuntimeMetadata;
|
|
37
|
+
const crypto_1 = require("crypto");
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const os = __importStar(require("os"));
|
|
40
|
+
const path = __importStar(require("path"));
|
|
41
|
+
const childProcess = __importStar(require("child_process"));
|
|
42
|
+
const identity_1 = require("../identity");
|
|
43
|
+
const runtime_1 = require("../../nerves/runtime");
|
|
44
|
+
const UNKNOWN_METADATA = "unknown";
|
|
45
|
+
function optionalFunction(target, key) {
|
|
46
|
+
try {
|
|
47
|
+
const candidate = target[key];
|
|
48
|
+
return typeof candidate === "function" ? candidate : null;
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function readVersion(packageJsonPath, readFileSyncImpl) {
|
|
55
|
+
try {
|
|
56
|
+
const parsed = JSON.parse(readFileSyncImpl(packageJsonPath, "utf-8"));
|
|
57
|
+
return typeof parsed.version === "string" && parsed.version.trim().length > 0
|
|
58
|
+
? parsed.version.trim()
|
|
59
|
+
: UNKNOWN_METADATA;
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return UNKNOWN_METADATA;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function readLastUpdated(repoRoot, packageJsonPath, statSyncImpl, execFileSyncImpl) {
|
|
66
|
+
try {
|
|
67
|
+
const raw = execFileSyncImpl("git", ["log", "-1", "--format=%cI"], {
|
|
68
|
+
cwd: repoRoot,
|
|
69
|
+
encoding: "utf-8",
|
|
70
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
71
|
+
}).trim();
|
|
72
|
+
if (raw.length > 0) {
|
|
73
|
+
return { value: raw, source: "git" };
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
// fall through to mtime fallback
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
const stats = statSyncImpl(packageJsonPath);
|
|
81
|
+
return {
|
|
82
|
+
value: stats.mtime.toISOString(),
|
|
83
|
+
source: "package-json-mtime",
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return { value: UNKNOWN_METADATA, source: "unknown" };
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function readHomeDir() {
|
|
91
|
+
const homedirImpl = optionalFunction(os, "homedir");
|
|
92
|
+
if (!homedirImpl) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
return homedirImpl.call(os);
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function listConfigTargets(bundlesRoot, secretsRoot, daemonLoggingPath, readdirSyncImpl) {
|
|
103
|
+
if (!readdirSyncImpl)
|
|
104
|
+
return [];
|
|
105
|
+
const targets = new Set();
|
|
106
|
+
if (daemonLoggingPath) {
|
|
107
|
+
targets.add(daemonLoggingPath);
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
const bundleEntries = readdirSyncImpl(bundlesRoot, { withFileTypes: true });
|
|
111
|
+
for (const entry of bundleEntries) {
|
|
112
|
+
if (!entry.isDirectory() || !entry.name.endsWith(".ouro"))
|
|
113
|
+
continue;
|
|
114
|
+
targets.add(path.join(bundlesRoot, entry.name, "agent.json"));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
// ignore unreadable bundle roots
|
|
119
|
+
}
|
|
120
|
+
if (secretsRoot) {
|
|
121
|
+
try {
|
|
122
|
+
const secretEntries = readdirSyncImpl(secretsRoot, { withFileTypes: true });
|
|
123
|
+
for (const entry of secretEntries) {
|
|
124
|
+
if (!entry.isDirectory())
|
|
125
|
+
continue;
|
|
126
|
+
targets.add(path.join(secretsRoot, entry.name, "secrets.json"));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
// ignore unreadable secrets roots
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return [...targets].sort();
|
|
134
|
+
}
|
|
135
|
+
function readConfigFingerprint(targets, readFileSyncImpl, existsSyncImpl) {
|
|
136
|
+
if (!readFileSyncImpl || !existsSyncImpl) {
|
|
137
|
+
return {
|
|
138
|
+
value: UNKNOWN_METADATA,
|
|
139
|
+
source: "unknown",
|
|
140
|
+
trackedFiles: targets.length,
|
|
141
|
+
presentFiles: 0,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
const hash = (0, crypto_1.createHash)("sha256");
|
|
145
|
+
let presentFiles = 0;
|
|
146
|
+
for (const target of targets) {
|
|
147
|
+
hash.update(target);
|
|
148
|
+
hash.update("\0");
|
|
149
|
+
if (!existsSyncImpl(target)) {
|
|
150
|
+
hash.update("missing");
|
|
151
|
+
hash.update("\0");
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
presentFiles += 1;
|
|
155
|
+
hash.update("present");
|
|
156
|
+
hash.update("\0");
|
|
157
|
+
try {
|
|
158
|
+
hash.update(readFileSyncImpl(target, "utf-8"));
|
|
159
|
+
}
|
|
160
|
+
catch {
|
|
161
|
+
hash.update("unreadable");
|
|
162
|
+
}
|
|
163
|
+
hash.update("\0");
|
|
164
|
+
}
|
|
165
|
+
return {
|
|
166
|
+
value: hash.digest("hex"),
|
|
167
|
+
source: "content-hash",
|
|
168
|
+
trackedFiles: targets.length,
|
|
169
|
+
presentFiles,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function getRuntimeMetadata(deps = {}) {
|
|
173
|
+
const repoRoot = deps.repoRoot ?? (0, identity_1.getRepoRoot)();
|
|
174
|
+
const bundlesRoot = deps.bundlesRoot ?? (0, identity_1.getAgentBundlesRoot)();
|
|
175
|
+
const homeDir = readHomeDir();
|
|
176
|
+
const secretsRoot = deps.secretsRoot ?? (homeDir ? path.join(homeDir, ".agentsecrets") : null);
|
|
177
|
+
const daemonLoggingPath = deps.daemonLoggingPath ?? (0, identity_1.getAgentDaemonLoggingConfigPath)();
|
|
178
|
+
const readFileSyncImpl = deps.readFileSync ?? optionalFunction(fs, "readFileSync")?.bind(fs) ?? null;
|
|
179
|
+
const statSyncImpl = deps.statSync ?? optionalFunction(fs, "statSync")?.bind(fs) ?? null;
|
|
180
|
+
const readdirSyncImpl = deps.readdirSync ?? optionalFunction(fs, "readdirSync")?.bind(fs) ?? null;
|
|
181
|
+
const existsSyncImpl = deps.existsSync ?? optionalFunction(fs, "existsSync")?.bind(fs) ?? null;
|
|
182
|
+
const execFileSyncImpl = deps.execFileSync
|
|
183
|
+
?? optionalFunction(childProcess, "execFileSync")?.bind(childProcess)
|
|
184
|
+
?? null;
|
|
185
|
+
const packageJsonPath = path.join(repoRoot, "package.json");
|
|
186
|
+
const version = readFileSyncImpl
|
|
187
|
+
? readVersion(packageJsonPath, readFileSyncImpl)
|
|
188
|
+
: UNKNOWN_METADATA;
|
|
189
|
+
const lastUpdated = statSyncImpl
|
|
190
|
+
? readLastUpdated(repoRoot, packageJsonPath, statSyncImpl, execFileSyncImpl ?? (() => {
|
|
191
|
+
throw new Error("git unavailable");
|
|
192
|
+
}))
|
|
193
|
+
: { value: UNKNOWN_METADATA, source: "unknown" };
|
|
194
|
+
const configTargets = listConfigTargets(bundlesRoot, secretsRoot, daemonLoggingPath, readdirSyncImpl);
|
|
195
|
+
const configFingerprint = readConfigFingerprint(configTargets, readFileSyncImpl, existsSyncImpl);
|
|
196
|
+
(0, runtime_1.emitNervesEvent)({
|
|
197
|
+
component: "daemon",
|
|
198
|
+
event: "daemon.runtime_metadata_read",
|
|
199
|
+
message: "read runtime metadata",
|
|
200
|
+
meta: {
|
|
201
|
+
version,
|
|
202
|
+
lastUpdated: lastUpdated.value,
|
|
203
|
+
lastUpdatedSource: lastUpdated.source,
|
|
204
|
+
repoRoot,
|
|
205
|
+
configFingerprint: configFingerprint.value === UNKNOWN_METADATA
|
|
206
|
+
? UNKNOWN_METADATA
|
|
207
|
+
: configFingerprint.value.slice(0, 12),
|
|
208
|
+
configFingerprintSource: configFingerprint.source,
|
|
209
|
+
configTrackedFiles: configFingerprint.trackedFiles,
|
|
210
|
+
configPresentFiles: configFingerprint.presentFiles,
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
return {
|
|
214
|
+
version,
|
|
215
|
+
lastUpdated: lastUpdated.value,
|
|
216
|
+
repoRoot,
|
|
217
|
+
configFingerprint: configFingerprint.value,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
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.detectRuntimeMode = detectRuntimeMode;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const runtime_1 = require("../../nerves/runtime");
|
|
40
|
+
function detectRuntimeMode(rootPath, deps = {}) {
|
|
41
|
+
const checkExists = deps.existsSync ?? fs.existsSync;
|
|
42
|
+
// 1. Production: installed via npm
|
|
43
|
+
if (rootPath.includes("node_modules/@ouro.bot/cli") ||
|
|
44
|
+
rootPath.includes("node_modules/ouro.bot")) {
|
|
45
|
+
(0, runtime_1.emitNervesEvent)({
|
|
46
|
+
component: "daemon",
|
|
47
|
+
event: "daemon.runtime_mode_detected",
|
|
48
|
+
message: "detected runtime mode",
|
|
49
|
+
meta: { rootPath, mode: "production" },
|
|
50
|
+
});
|
|
51
|
+
return "production";
|
|
52
|
+
}
|
|
53
|
+
// 2-4. Everything else is dev: worktrees, git repos, unknown paths
|
|
54
|
+
// (conservative default: assume dev unless proven production)
|
|
55
|
+
const reason = rootPath.includes(".claude/worktrees/")
|
|
56
|
+
? "worktree"
|
|
57
|
+
: checkExists(path.join(rootPath, ".git"))
|
|
58
|
+
? "git-repo"
|
|
59
|
+
: "unknown";
|
|
60
|
+
(0, runtime_1.emitNervesEvent)({
|
|
61
|
+
component: "daemon",
|
|
62
|
+
event: "daemon.runtime_mode_detected",
|
|
63
|
+
message: "detected runtime mode",
|
|
64
|
+
meta: { rootPath, mode: "dev", reason },
|
|
65
|
+
});
|
|
66
|
+
return "dev";
|
|
67
|
+
}
|
|
@@ -0,0 +1,307 @@
|
|
|
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.DaemonSenseManager = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const os = __importStar(require("os"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
const runtime_1 = require("../../nerves/runtime");
|
|
41
|
+
const bluebubbles_runtime_state_1 = require("../../senses/bluebubbles-runtime-state");
|
|
42
|
+
const identity_1 = require("../identity");
|
|
43
|
+
const sense_truth_1 = require("../sense-truth");
|
|
44
|
+
const process_manager_1 = require("./process-manager");
|
|
45
|
+
const DEFAULT_TEAMS_PORT = 3978;
|
|
46
|
+
const DEFAULT_BLUEBUBBLES_PORT = 18790;
|
|
47
|
+
const DEFAULT_BLUEBUBBLES_WEBHOOK_PATH = "/bluebubbles-webhook";
|
|
48
|
+
const BLUEBUBBLES_RUNTIME_FRESHNESS_WINDOW_MS = 90_000;
|
|
49
|
+
function defaultSenses() {
|
|
50
|
+
return {
|
|
51
|
+
cli: { ...identity_1.DEFAULT_AGENT_SENSES.cli },
|
|
52
|
+
teams: { ...identity_1.DEFAULT_AGENT_SENSES.teams },
|
|
53
|
+
bluebubbles: { ...identity_1.DEFAULT_AGENT_SENSES.bluebubbles },
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function readAgentSenses(agentJsonPath) {
|
|
57
|
+
const defaults = defaultSenses();
|
|
58
|
+
let parsed;
|
|
59
|
+
try {
|
|
60
|
+
parsed = JSON.parse(fs.readFileSync(agentJsonPath, "utf-8"));
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
(0, runtime_1.emitNervesEvent)({
|
|
64
|
+
level: "warn",
|
|
65
|
+
component: "channels",
|
|
66
|
+
event: "channel.daemon_sense_agent_config_fallback",
|
|
67
|
+
message: "using default senses because agent config could not be read",
|
|
68
|
+
meta: {
|
|
69
|
+
path: agentJsonPath,
|
|
70
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
return defaults;
|
|
74
|
+
}
|
|
75
|
+
const rawSenses = parsed.senses;
|
|
76
|
+
if (!rawSenses || typeof rawSenses !== "object" || Array.isArray(rawSenses)) {
|
|
77
|
+
return defaults;
|
|
78
|
+
}
|
|
79
|
+
for (const sense of ["cli", "teams", "bluebubbles"]) {
|
|
80
|
+
const rawSense = rawSenses[sense];
|
|
81
|
+
if (!rawSense || typeof rawSense !== "object" || Array.isArray(rawSense)) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
const enabled = rawSense.enabled;
|
|
85
|
+
if (typeof enabled === "boolean") {
|
|
86
|
+
defaults[sense] = { enabled };
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return defaults;
|
|
90
|
+
}
|
|
91
|
+
function readSecretsPayload(secretsPath) {
|
|
92
|
+
try {
|
|
93
|
+
const raw = fs.readFileSync(secretsPath, "utf-8");
|
|
94
|
+
const parsed = JSON.parse(raw);
|
|
95
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
96
|
+
return { payload: {}, error: "invalid secrets.json object" };
|
|
97
|
+
}
|
|
98
|
+
return { payload: parsed, error: null };
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
return {
|
|
102
|
+
payload: {},
|
|
103
|
+
error: error instanceof Error ? error.message : String(error),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function textField(record, key) {
|
|
108
|
+
const value = record?.[key];
|
|
109
|
+
return typeof value === "string" ? value.trim() : "";
|
|
110
|
+
}
|
|
111
|
+
function numberField(record, key, fallback) {
|
|
112
|
+
const value = record?.[key];
|
|
113
|
+
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
114
|
+
}
|
|
115
|
+
function senseFactsFromSecrets(agent, senses, secretsPath) {
|
|
116
|
+
const base = {
|
|
117
|
+
cli: { configured: true, detail: "local interactive terminal" },
|
|
118
|
+
teams: { configured: false, detail: "not enabled in agent.json" },
|
|
119
|
+
bluebubbles: { configured: false, detail: "not enabled in agent.json" },
|
|
120
|
+
};
|
|
121
|
+
const { payload, error } = readSecretsPayload(secretsPath);
|
|
122
|
+
const teams = payload.teams;
|
|
123
|
+
const teamsChannel = payload.teamsChannel;
|
|
124
|
+
const bluebubbles = payload.bluebubbles;
|
|
125
|
+
const bluebubblesChannel = payload.bluebubblesChannel;
|
|
126
|
+
if (senses.teams.enabled) {
|
|
127
|
+
const missing = [];
|
|
128
|
+
if (!textField(teams, "clientId"))
|
|
129
|
+
missing.push("teams.clientId");
|
|
130
|
+
if (!textField(teams, "clientSecret"))
|
|
131
|
+
missing.push("teams.clientSecret");
|
|
132
|
+
if (!textField(teams, "tenantId"))
|
|
133
|
+
missing.push("teams.tenantId");
|
|
134
|
+
base.teams = missing.length === 0
|
|
135
|
+
? {
|
|
136
|
+
configured: true,
|
|
137
|
+
detail: `:${numberField(teamsChannel, "port", DEFAULT_TEAMS_PORT)}`,
|
|
138
|
+
}
|
|
139
|
+
: {
|
|
140
|
+
configured: false,
|
|
141
|
+
detail: error && !fs.existsSync(secretsPath)
|
|
142
|
+
? `missing secrets.json (${agent})`
|
|
143
|
+
: `missing ${missing.join("/")}`,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
if (senses.bluebubbles.enabled) {
|
|
147
|
+
const missing = [];
|
|
148
|
+
if (!textField(bluebubbles, "serverUrl"))
|
|
149
|
+
missing.push("bluebubbles.serverUrl");
|
|
150
|
+
if (!textField(bluebubbles, "password"))
|
|
151
|
+
missing.push("bluebubbles.password");
|
|
152
|
+
base.bluebubbles = missing.length === 0
|
|
153
|
+
? {
|
|
154
|
+
configured: true,
|
|
155
|
+
detail: `:${numberField(bluebubblesChannel, "port", DEFAULT_BLUEBUBBLES_PORT)} ${textField(bluebubblesChannel, "webhookPath") || DEFAULT_BLUEBUBBLES_WEBHOOK_PATH}`,
|
|
156
|
+
}
|
|
157
|
+
: {
|
|
158
|
+
configured: false,
|
|
159
|
+
detail: error && !fs.existsSync(secretsPath)
|
|
160
|
+
? `missing secrets.json (${agent})`
|
|
161
|
+
: `missing ${missing.join("/")}`,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
return base;
|
|
165
|
+
}
|
|
166
|
+
function parseSenseSnapshotName(name) {
|
|
167
|
+
const parts = name.split(":");
|
|
168
|
+
if (parts.length !== 2)
|
|
169
|
+
return null;
|
|
170
|
+
const [agent, sense] = parts;
|
|
171
|
+
if (sense !== "teams" && sense !== "bluebubbles")
|
|
172
|
+
return null;
|
|
173
|
+
return { agent, sense };
|
|
174
|
+
}
|
|
175
|
+
function runtimeInfoFor(status) {
|
|
176
|
+
if (status === "running")
|
|
177
|
+
return { runtime: "running" };
|
|
178
|
+
return { runtime: "error" };
|
|
179
|
+
}
|
|
180
|
+
function blueBubblesRuntimeStateIsFresh(lastCheckedAt, now = Date.now()) {
|
|
181
|
+
if (!lastCheckedAt) {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
const checkedAt = Date.parse(lastCheckedAt);
|
|
185
|
+
if (!Number.isFinite(checkedAt)) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
return checkedAt >= now - BLUEBUBBLES_RUNTIME_FRESHNESS_WINDOW_MS;
|
|
189
|
+
}
|
|
190
|
+
function readBlueBubblesRuntimeFacts(agent, bundlesRoot, snapshot) {
|
|
191
|
+
const agentRoot = path.join(bundlesRoot, `${agent}.ouro`);
|
|
192
|
+
const runtimePath = path.join(agentRoot, "state", "senses", "bluebubbles", "runtime.json");
|
|
193
|
+
if (!fs.existsSync(runtimePath)) {
|
|
194
|
+
return { runtime: snapshot?.runtime };
|
|
195
|
+
}
|
|
196
|
+
const state = (0, bluebubbles_runtime_state_1.readBlueBubblesRuntimeState)(agent, agentRoot);
|
|
197
|
+
if (!blueBubblesRuntimeStateIsFresh(state.lastCheckedAt)) {
|
|
198
|
+
return { runtime: snapshot?.runtime };
|
|
199
|
+
}
|
|
200
|
+
if (state.upstreamStatus === "error") {
|
|
201
|
+
return {
|
|
202
|
+
runtime: "error",
|
|
203
|
+
detail: state.detail,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
if (state.upstreamStatus === "ok") {
|
|
207
|
+
return { runtime: "running" };
|
|
208
|
+
}
|
|
209
|
+
return { runtime: snapshot?.runtime };
|
|
210
|
+
}
|
|
211
|
+
class DaemonSenseManager {
|
|
212
|
+
processManager;
|
|
213
|
+
contexts;
|
|
214
|
+
bundlesRoot;
|
|
215
|
+
constructor(options) {
|
|
216
|
+
const bundlesRoot = options.bundlesRoot ?? path.join(os.homedir(), "AgentBundles");
|
|
217
|
+
const secretsRoot = options.secretsRoot ?? path.join(os.homedir(), ".agentsecrets");
|
|
218
|
+
this.bundlesRoot = bundlesRoot;
|
|
219
|
+
this.contexts = new Map(options.agents.map((agent) => {
|
|
220
|
+
const senses = readAgentSenses(path.join(bundlesRoot, `${agent}.ouro`, "agent.json"));
|
|
221
|
+
const facts = senseFactsFromSecrets(agent, senses, path.join(secretsRoot, agent, "secrets.json"));
|
|
222
|
+
return [agent, { senses, facts }];
|
|
223
|
+
}));
|
|
224
|
+
const managedSenseAgents = [...this.contexts.entries()].flatMap(([agent, context]) => {
|
|
225
|
+
return ["teams", "bluebubbles"]
|
|
226
|
+
.filter((sense) => context.senses[sense].enabled && context.facts[sense].configured)
|
|
227
|
+
.map((sense) => ({
|
|
228
|
+
name: `${agent}:${sense}`,
|
|
229
|
+
agentArg: agent,
|
|
230
|
+
entry: sense === "teams" ? "senses/teams-entry.js" : "senses/bluebubbles-entry.js",
|
|
231
|
+
channel: sense,
|
|
232
|
+
autoStart: true,
|
|
233
|
+
}));
|
|
234
|
+
});
|
|
235
|
+
this.processManager = options.processManager ?? new process_manager_1.DaemonProcessManager({
|
|
236
|
+
agents: managedSenseAgents,
|
|
237
|
+
});
|
|
238
|
+
(0, runtime_1.emitNervesEvent)({
|
|
239
|
+
component: "channels",
|
|
240
|
+
event: "channel.daemon_sense_manager_init",
|
|
241
|
+
message: "initialized daemon sense manager",
|
|
242
|
+
meta: {
|
|
243
|
+
agents: options.agents,
|
|
244
|
+
managedSenseProcesses: managedSenseAgents.map((entry) => entry.name),
|
|
245
|
+
},
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
async startAutoStartSenses() {
|
|
249
|
+
await this.processManager.startAutoStartAgents();
|
|
250
|
+
}
|
|
251
|
+
async stopAll() {
|
|
252
|
+
await this.processManager.stopAll();
|
|
253
|
+
}
|
|
254
|
+
listSenseRows() {
|
|
255
|
+
const runtime = new Map();
|
|
256
|
+
for (const snapshot of this.processManager.listAgentSnapshots()) {
|
|
257
|
+
const parsed = parseSenseSnapshotName(snapshot.name);
|
|
258
|
+
if (!parsed)
|
|
259
|
+
continue;
|
|
260
|
+
const current = runtime.get(parsed.agent) ?? {};
|
|
261
|
+
current[parsed.sense] = runtimeInfoFor(snapshot.status);
|
|
262
|
+
runtime.set(parsed.agent, current);
|
|
263
|
+
}
|
|
264
|
+
const rows = [...this.contexts.entries()].flatMap(([agent, context]) => {
|
|
265
|
+
const blueBubblesRuntimeFacts = readBlueBubblesRuntimeFacts(agent, this.bundlesRoot, runtime.get(agent)?.bluebubbles);
|
|
266
|
+
const runtimeInfo = {
|
|
267
|
+
cli: { configured: true },
|
|
268
|
+
teams: {
|
|
269
|
+
configured: context.facts.teams.configured,
|
|
270
|
+
...(runtime.get(agent)?.teams ?? {}),
|
|
271
|
+
},
|
|
272
|
+
bluebubbles: {
|
|
273
|
+
configured: context.facts.bluebubbles.configured,
|
|
274
|
+
...blueBubblesRuntimeFacts,
|
|
275
|
+
},
|
|
276
|
+
};
|
|
277
|
+
const inventory = (0, sense_truth_1.getSenseInventory)({ senses: context.senses }, runtimeInfo);
|
|
278
|
+
return inventory.map((entry) => ({
|
|
279
|
+
agent,
|
|
280
|
+
sense: entry.sense,
|
|
281
|
+
label: entry.label,
|
|
282
|
+
enabled: entry.enabled,
|
|
283
|
+
status: entry.status,
|
|
284
|
+
detail: entry.enabled
|
|
285
|
+
? entry.sense === "bluebubbles"
|
|
286
|
+
? blueBubblesRuntimeFacts.detail
|
|
287
|
+
?? context.facts[entry.sense].detail
|
|
288
|
+
: context.facts[entry.sense].detail
|
|
289
|
+
: "not enabled in agent.json",
|
|
290
|
+
}));
|
|
291
|
+
});
|
|
292
|
+
(0, runtime_1.emitNervesEvent)({
|
|
293
|
+
component: "channels",
|
|
294
|
+
event: "channel.daemon_sense_rows_built",
|
|
295
|
+
message: "built daemon sense status rows",
|
|
296
|
+
meta: {
|
|
297
|
+
rows: rows.map((row) => ({
|
|
298
|
+
agent: row.agent,
|
|
299
|
+
sense: row.sense,
|
|
300
|
+
status: row.status,
|
|
301
|
+
})),
|
|
302
|
+
},
|
|
303
|
+
});
|
|
304
|
+
return rows;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
exports.DaemonSenseManager = DaemonSenseManager;
|
|
@@ -0,0 +1,94 @@
|
|
|
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.ensureSkillManagement = ensureSkillManagement;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const runtime_1 = require("../../nerves/runtime");
|
|
40
|
+
const identity_1 = require("../identity");
|
|
41
|
+
const SKILL_MANAGEMENT_URL = "https://raw.githubusercontent.com/ouroborosbot/ouroboros-skills/main/skills/skill-management/SKILL.md";
|
|
42
|
+
async function ensureSkillManagement() {
|
|
43
|
+
const bundlesRoot = (0, identity_1.getAgentBundlesRoot)();
|
|
44
|
+
if (!fs.existsSync(bundlesRoot))
|
|
45
|
+
return;
|
|
46
|
+
// Find all agent bundles
|
|
47
|
+
const entries = fs.readdirSync(bundlesRoot).filter(e => e.endsWith(".ouro"));
|
|
48
|
+
if (entries.length === 0)
|
|
49
|
+
return;
|
|
50
|
+
// Check if ANY bundle is missing the skill
|
|
51
|
+
const missing = entries.filter(e => {
|
|
52
|
+
const targetPath = path.join(bundlesRoot, e, "skills", "skill-management.md");
|
|
53
|
+
return !fs.existsSync(targetPath);
|
|
54
|
+
});
|
|
55
|
+
if (missing.length === 0)
|
|
56
|
+
return;
|
|
57
|
+
// eslint-disable-next-line no-console -- terminal UX: visible install status
|
|
58
|
+
console.log("installing skill-management from ouroboros-skills...");
|
|
59
|
+
try {
|
|
60
|
+
const response = await fetch(SKILL_MANAGEMENT_URL);
|
|
61
|
+
if (!response.ok) {
|
|
62
|
+
// eslint-disable-next-line no-console -- terminal UX: visible install status
|
|
63
|
+
console.error(`✗ failed to fetch skill-management (HTTP ${response.status})`);
|
|
64
|
+
(0, runtime_1.emitNervesEvent)({
|
|
65
|
+
level: "warn",
|
|
66
|
+
component: "daemon",
|
|
67
|
+
event: "daemon.skill_management_install_error",
|
|
68
|
+
message: "failed to fetch skill-management from GitHub",
|
|
69
|
+
meta: { status: response.status, url: SKILL_MANAGEMENT_URL },
|
|
70
|
+
});
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const content = await response.text();
|
|
74
|
+
for (const bundle of missing) {
|
|
75
|
+
const skillsDir = path.join(bundlesRoot, bundle, "skills");
|
|
76
|
+
const targetPath = path.join(skillsDir, "skill-management.md");
|
|
77
|
+
fs.mkdirSync(skillsDir, { recursive: true });
|
|
78
|
+
fs.writeFileSync(targetPath, content, "utf-8");
|
|
79
|
+
}
|
|
80
|
+
// eslint-disable-next-line no-console -- terminal UX: visible install status
|
|
81
|
+
console.log(`✓ installed skill-management (${missing.length} agent${missing.length > 1 ? "s" : ""})`);
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
// eslint-disable-next-line no-console -- terminal UX: visible install status
|
|
85
|
+
console.error(`✗ failed to install skill-management: ${error instanceof Error ? error.message : String(error)}`);
|
|
86
|
+
(0, runtime_1.emitNervesEvent)({
|
|
87
|
+
level: "warn",
|
|
88
|
+
component: "daemon",
|
|
89
|
+
event: "daemon.skill_management_install_error",
|
|
90
|
+
message: "failed to install skill-management skill",
|
|
91
|
+
meta: { error: error instanceof Error ? error.message : String(error) },
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|