@ouro.bot/cli 0.1.0-alpha.17 → 0.1.0-alpha.170
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 +3 -2
- package/AdoptionSpecialist.ouro/psyche/SOUL.md +3 -3
- package/AdoptionSpecialist.ouro/psyche/identities/monty.md +2 -2
- package/README.md +187 -191
- package/changelog.json +1145 -0
- package/dist/heart/active-work.js +633 -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 +105 -0
- package/dist/heart/config.js +40 -30
- package/dist/heart/core.js +608 -123
- package/dist/heart/cross-chat-delivery.js +146 -0
- package/dist/heart/daemon/agent-discovery.js +81 -0
- package/dist/heart/daemon/agent-service.js +360 -0
- package/dist/heart/daemon/auth-flow.js +477 -0
- package/dist/heart/daemon/cadence.js +70 -0
- package/dist/heart/daemon/daemon-cli.js +2473 -206
- package/dist/heart/daemon/daemon-entry.js +140 -4
- package/dist/heart/daemon/daemon-health.js +136 -0
- package/dist/heart/daemon/daemon-runtime-sync.js +212 -0
- package/dist/heart/daemon/daemon-tombstone.js +123 -0
- package/dist/heart/daemon/daemon.js +446 -17
- package/dist/heart/daemon/habit-migration.js +181 -0
- package/dist/heart/daemon/habit-parser.js +119 -0
- package/dist/heart/daemon/habit-scheduler.js +369 -0
- package/dist/heart/daemon/hatch-animation.js +10 -3
- package/dist/heart/daemon/hatch-flow.js +30 -111
- package/dist/heart/daemon/hooks/agent-config-v2.js +33 -0
- package/dist/heart/daemon/hooks/bundle-meta.js +92 -0
- package/dist/heart/daemon/inner-status.js +89 -0
- package/dist/heart/daemon/launchd.js +161 -0
- package/dist/heart/daemon/log-tailer.js +4 -3
- package/dist/heart/daemon/mcp-server.js +591 -0
- package/dist/heart/daemon/message-router.js +17 -8
- package/dist/heart/daemon/os-cron-deps.js +134 -0
- package/dist/heart/daemon/ouro-bot-global-installer.js +128 -0
- package/dist/heart/daemon/ouro-path-installer.js +78 -34
- package/dist/heart/daemon/ouro-version-manager.js +171 -0
- package/dist/heart/daemon/outlook-http.js +399 -0
- package/dist/heart/daemon/outlook-read.js +1291 -0
- package/dist/heart/daemon/outlook-render.js +1032 -0
- package/dist/heart/daemon/outlook-types.js +7 -0
- package/dist/heart/daemon/outlook-view.js +194 -0
- package/dist/heart/daemon/process-manager.js +75 -0
- package/dist/heart/daemon/run-hooks.js +39 -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/safe-mode.js +161 -0
- package/dist/heart/daemon/sense-manager.js +50 -2
- package/dist/heart/daemon/session-id-resolver.js +131 -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 +2 -2
- package/dist/heart/daemon/specialist-prompt.js +13 -8
- package/dist/heart/daemon/specialist-tools.js +53 -4
- package/dist/heart/daemon/staged-restart.js +114 -0
- package/dist/heart/daemon/task-scheduler.js +3 -25
- 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 +136 -55
- package/dist/heart/kicks.js +2 -20
- package/dist/heart/migrate-config.js +127 -0
- package/dist/heart/model-capabilities.js +48 -0
- package/dist/heart/obligations.js +197 -0
- package/dist/heart/progress-story.js +42 -0
- package/dist/heart/provider-failover.js +88 -0
- package/dist/heart/provider-ping.js +172 -0
- package/dist/heart/providers/anthropic-token.js +163 -0
- package/dist/heart/providers/anthropic.js +196 -36
- package/dist/heart/providers/azure.js +116 -10
- package/dist/heart/providers/github-copilot.js +157 -0
- package/dist/heart/providers/minimax.js +33 -3
- package/dist/heart/providers/openai-codex.js +51 -16
- package/dist/heart/session-activity.js +172 -0
- package/dist/heart/session-recall.js +216 -0
- package/dist/heart/streaming.js +62 -32
- package/dist/heart/target-resolution.js +127 -0
- package/dist/heart/tool-activity-callbacks.js +36 -0
- package/dist/heart/tool-description.js +135 -0
- package/dist/heart/tool-loop.js +200 -0
- package/dist/heart/turn-coordinator.js +28 -0
- package/dist/mind/associative-recall.js +122 -32
- package/dist/mind/bundle-manifest.js +14 -0
- package/dist/mind/context.js +125 -14
- package/dist/mind/{memory.js → diary.js} +70 -56
- package/dist/mind/first-impressions.js +16 -2
- package/dist/mind/friends/channel.js +56 -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/journal-index.js +161 -0
- package/dist/mind/obligation-steering.js +221 -0
- package/dist/mind/obligations.js +134 -0
- package/dist/mind/pending.js +76 -9
- package/dist/mind/phrases.js +1 -0
- package/dist/mind/prompt.js +649 -89
- 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/event-buffer.js +111 -0
- package/dist/nerves/index.js +63 -3
- package/dist/nerves/observation.js +20 -0
- package/dist/nerves/runtime.js +5 -1
- package/dist/outlook-ui/assets/index-CBueh0d3.css +1 -0
- package/dist/outlook-ui/assets/index-GtHoFpRM.js +61 -0
- package/dist/outlook-ui/index.html +15 -0
- package/dist/repertoire/ado-semantic.js +6 -0
- package/dist/repertoire/coding/codex-jsonl.js +64 -0
- package/dist/repertoire/coding/context-pack.js +254 -0
- package/dist/repertoire/coding/feedback.js +197 -30
- package/dist/repertoire/coding/manager.js +149 -2
- package/dist/repertoire/coding/spawner.js +55 -9
- package/dist/repertoire/coding/tools.js +135 -2
- package/dist/repertoire/guardrails.js +291 -0
- package/dist/repertoire/mcp-client.js +254 -0
- package/dist/repertoire/mcp-manager.js +198 -0
- package/dist/repertoire/skills.js +14 -23
- package/dist/repertoire/tasks/board.js +43 -5
- package/dist/repertoire/tasks/fix.js +182 -0
- package/dist/repertoire/tasks/index.js +28 -10
- package/dist/repertoire/tasks/lifecycle.js +2 -2
- package/dist/repertoire/tasks/parser.js +3 -2
- package/dist/repertoire/tasks/scanner.js +194 -37
- package/dist/repertoire/tasks/transitions.js +11 -28
- package/dist/repertoire/tools-base.js +991 -272
- package/dist/repertoire/tools-bluebubbles.js +94 -0
- package/dist/repertoire/tools-github.js +1 -6
- package/dist/repertoire/tools-teams.js +12 -59
- package/dist/repertoire/tools.js +281 -122
- package/dist/scripts/claude-code-hook.js +41 -0
- package/dist/scripts/claude-code-stop-hook.js +47 -0
- package/dist/senses/attention-queue.js +97 -0
- package/dist/senses/bluebubbles-client.js +102 -3
- package/dist/senses/bluebubbles-entry.js +2 -0
- package/dist/senses/bluebubbles-inbound-log.js +109 -0
- package/dist/senses/bluebubbles-media.js +118 -23
- 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 +1008 -102
- package/dist/senses/cli-entry.js +1 -1
- package/dist/senses/cli-layout.js +187 -0
- package/dist/senses/cli.js +419 -152
- package/dist/senses/commands.js +38 -1
- package/dist/senses/continuity.js +94 -0
- package/dist/senses/habit-turn-message.js +108 -0
- package/dist/senses/inner-dialog-worker.js +112 -19
- package/dist/senses/inner-dialog.js +592 -84
- package/dist/senses/pipeline.js +502 -0
- package/dist/senses/shared-turn.js +196 -0
- package/dist/senses/surface-tool.js +95 -0
- package/dist/senses/teams.js +667 -120
- package/dist/senses/trust-gate.js +112 -2
- package/package.json +13 -5
- package/skills/configure-dev-tools.md +81 -0
- package/subagents/README.md +4 -70
- package/dist/heart/daemon/subagent-installer.js +0 -134
- package/dist/senses/debug-activity.js +0 -107
- package/subagents/work-doer.md +0 -235
- package/subagents/work-merger.md +0 -618
- package/subagents/work-planner.md +0 -382
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deliverCrossChatMessage = deliverCrossChatMessage;
|
|
4
|
+
const types_1 = require("../mind/friends/types");
|
|
5
|
+
const runtime_1 = require("../nerves/runtime");
|
|
6
|
+
function buildPendingEnvelope(request, agentName, now) {
|
|
7
|
+
return {
|
|
8
|
+
from: agentName,
|
|
9
|
+
friendId: request.friendId,
|
|
10
|
+
channel: request.channel,
|
|
11
|
+
key: request.key,
|
|
12
|
+
content: request.content,
|
|
13
|
+
timestamp: now,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function queueForLater(request, deps, detail) {
|
|
17
|
+
deps.queuePending(buildPendingEnvelope(request, deps.agentName, (deps.now ?? Date.now)()));
|
|
18
|
+
return {
|
|
19
|
+
status: "queued_for_later",
|
|
20
|
+
detail,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function isExplicitlyAuthorized(request) {
|
|
24
|
+
return request.intent === "explicit_cross_chat"
|
|
25
|
+
&& Boolean(request.authorizingSession)
|
|
26
|
+
&& (0, types_1.isTrustedLevel)(request.authorizingSession?.trustLevel);
|
|
27
|
+
}
|
|
28
|
+
async function deliverCrossChatMessage(request, deps) {
|
|
29
|
+
(0, runtime_1.emitNervesEvent)({
|
|
30
|
+
component: "engine",
|
|
31
|
+
event: "engine.cross_chat_delivery_start",
|
|
32
|
+
message: "resolving cross-chat delivery",
|
|
33
|
+
meta: {
|
|
34
|
+
friendId: request.friendId,
|
|
35
|
+
channel: request.channel,
|
|
36
|
+
key: request.key,
|
|
37
|
+
intent: request.intent,
|
|
38
|
+
authorizingTrustLevel: request.authorizingSession?.trustLevel ?? null,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
if (request.intent === "generic_outreach") {
|
|
42
|
+
const result = queueForLater(request, deps, "generic outreach stays queued until the target session is next active");
|
|
43
|
+
(0, runtime_1.emitNervesEvent)({
|
|
44
|
+
component: "engine",
|
|
45
|
+
event: "engine.cross_chat_delivery_end",
|
|
46
|
+
message: "queued generic outreach for later delivery",
|
|
47
|
+
meta: {
|
|
48
|
+
friendId: request.friendId,
|
|
49
|
+
channel: request.channel,
|
|
50
|
+
key: request.key,
|
|
51
|
+
status: result.status,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
if (!isExplicitlyAuthorized(request)) {
|
|
57
|
+
const result = {
|
|
58
|
+
status: "blocked",
|
|
59
|
+
detail: "explicit cross-chat delivery requires a trusted asking session",
|
|
60
|
+
};
|
|
61
|
+
(0, runtime_1.emitNervesEvent)({
|
|
62
|
+
level: "warn",
|
|
63
|
+
component: "engine",
|
|
64
|
+
event: "engine.cross_chat_delivery_end",
|
|
65
|
+
message: "blocked explicit cross-chat delivery",
|
|
66
|
+
meta: {
|
|
67
|
+
friendId: request.friendId,
|
|
68
|
+
channel: request.channel,
|
|
69
|
+
key: request.key,
|
|
70
|
+
status: result.status,
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
const deliverer = deps.deliverers?.[request.channel];
|
|
76
|
+
if (!deliverer) {
|
|
77
|
+
const result = queueForLater(request, deps, "live delivery unavailable right now; queued for the next active turn");
|
|
78
|
+
(0, runtime_1.emitNervesEvent)({
|
|
79
|
+
component: "engine",
|
|
80
|
+
event: "engine.cross_chat_delivery_end",
|
|
81
|
+
message: "queued explicit cross-chat delivery because no live deliverer was available",
|
|
82
|
+
meta: {
|
|
83
|
+
friendId: request.friendId,
|
|
84
|
+
channel: request.channel,
|
|
85
|
+
key: request.key,
|
|
86
|
+
status: result.status,
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
const direct = await deliverer(request);
|
|
93
|
+
if (direct.status === "delivered_now" || direct.status === "blocked" || direct.status === "failed") {
|
|
94
|
+
const result = {
|
|
95
|
+
status: direct.status,
|
|
96
|
+
detail: direct.detail,
|
|
97
|
+
};
|
|
98
|
+
(0, runtime_1.emitNervesEvent)({
|
|
99
|
+
level: result.status === "failed" ? "error" : result.status === "blocked" ? "warn" : "info",
|
|
100
|
+
component: "engine",
|
|
101
|
+
event: "engine.cross_chat_delivery_end",
|
|
102
|
+
message: "completed direct cross-chat delivery resolution",
|
|
103
|
+
meta: {
|
|
104
|
+
friendId: request.friendId,
|
|
105
|
+
channel: request.channel,
|
|
106
|
+
key: request.key,
|
|
107
|
+
status: result.status,
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
return result;
|
|
111
|
+
}
|
|
112
|
+
const result = queueForLater(request, deps, direct.detail.trim() || "live delivery unavailable right now; queued for the next active turn");
|
|
113
|
+
(0, runtime_1.emitNervesEvent)({
|
|
114
|
+
component: "engine",
|
|
115
|
+
event: "engine.cross_chat_delivery_end",
|
|
116
|
+
message: "queued explicit cross-chat delivery after adapter reported unavailability",
|
|
117
|
+
meta: {
|
|
118
|
+
friendId: request.friendId,
|
|
119
|
+
channel: request.channel,
|
|
120
|
+
key: request.key,
|
|
121
|
+
status: result.status,
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
return result;
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
const result = {
|
|
128
|
+
status: "failed",
|
|
129
|
+
detail: error instanceof Error ? error.message : String(error),
|
|
130
|
+
};
|
|
131
|
+
(0, runtime_1.emitNervesEvent)({
|
|
132
|
+
level: "error",
|
|
133
|
+
component: "engine",
|
|
134
|
+
event: "engine.cross_chat_delivery_end",
|
|
135
|
+
message: "cross-chat delivery threw unexpectedly",
|
|
136
|
+
meta: {
|
|
137
|
+
friendId: request.friendId,
|
|
138
|
+
channel: request.channel,
|
|
139
|
+
key: request.key,
|
|
140
|
+
status: result.status,
|
|
141
|
+
reason: result.detail,
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
return result;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
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.listEnabledBundleAgents = listEnabledBundleAgents;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const identity_1 = require("../identity");
|
|
40
|
+
const runtime_1 = require("../../nerves/runtime");
|
|
41
|
+
function listEnabledBundleAgents(options = {}) {
|
|
42
|
+
const bundlesRoot = options.bundlesRoot ?? (0, identity_1.getAgentBundlesRoot)();
|
|
43
|
+
const readdirSync = options.readdirSync ?? fs.readdirSync;
|
|
44
|
+
const readFileSync = options.readFileSync ?? fs.readFileSync;
|
|
45
|
+
let entries;
|
|
46
|
+
try {
|
|
47
|
+
entries = readdirSync(bundlesRoot, { withFileTypes: true });
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
(0, runtime_1.emitNervesEvent)({
|
|
51
|
+
level: "warn",
|
|
52
|
+
component: "daemon",
|
|
53
|
+
event: "daemon.agent_discovery_failed",
|
|
54
|
+
message: "failed to read bundle root for daemon agent discovery",
|
|
55
|
+
meta: { bundlesRoot },
|
|
56
|
+
});
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
const discovered = [];
|
|
60
|
+
for (const entry of entries) {
|
|
61
|
+
if (!entry.isDirectory() || !entry.name.endsWith(".ouro"))
|
|
62
|
+
continue;
|
|
63
|
+
const agentName = entry.name.slice(0, -5);
|
|
64
|
+
const configPath = path.join(bundlesRoot, entry.name, "agent.json");
|
|
65
|
+
let enabled = true;
|
|
66
|
+
try {
|
|
67
|
+
const raw = readFileSync(configPath, "utf-8");
|
|
68
|
+
const parsed = JSON.parse(raw);
|
|
69
|
+
if (typeof parsed.enabled === "boolean") {
|
|
70
|
+
enabled = parsed.enabled;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if (enabled) {
|
|
77
|
+
discovered.push(agentName);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return discovered.sort((left, right) => left.localeCompare(right));
|
|
81
|
+
}
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Agent service layer — handles MCP-facing daemon commands.
|
|
4
|
+
* Each handler receives { agent, friendId, ...params } and returns DaemonResponse.
|
|
5
|
+
*
|
|
6
|
+
* DRY: uses the same shared functions the agent's own tools use (diary, session-recall).
|
|
7
|
+
* This file is a thin adapter — no reimplemented search, parsing, or state reading.
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
26
|
+
var ownKeys = function(o) {
|
|
27
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
+
var ar = [];
|
|
29
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
return ownKeys(o);
|
|
33
|
+
};
|
|
34
|
+
return function (mod) {
|
|
35
|
+
if (mod && mod.__esModule) return mod;
|
|
36
|
+
var result = {};
|
|
37
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.handleAgentStatus = handleAgentStatus;
|
|
44
|
+
exports.handleAgentAsk = handleAgentAsk;
|
|
45
|
+
exports.handleAgentCatchup = handleAgentCatchup;
|
|
46
|
+
exports.handleAgentDelegate = handleAgentDelegate;
|
|
47
|
+
exports.handleAgentGetContext = handleAgentGetContext;
|
|
48
|
+
exports.handleAgentSearchMemory = handleAgentSearchMemory;
|
|
49
|
+
exports.handleAgentGetTask = handleAgentGetTask;
|
|
50
|
+
exports.handleAgentCheckScope = handleAgentCheckScope;
|
|
51
|
+
exports.handleAgentRequestDecision = handleAgentRequestDecision;
|
|
52
|
+
exports.handleAgentCheckGuidance = handleAgentCheckGuidance;
|
|
53
|
+
exports.handleAgentReportProgress = handleAgentReportProgress;
|
|
54
|
+
exports.handleAgentReportBlocker = handleAgentReportBlocker;
|
|
55
|
+
exports.handleAgentReportComplete = handleAgentReportComplete;
|
|
56
|
+
const fs = __importStar(require("fs"));
|
|
57
|
+
const path = __importStar(require("path"));
|
|
58
|
+
const identity_1 = require("../identity");
|
|
59
|
+
const diary_1 = require("../../mind/diary");
|
|
60
|
+
const runtime_1 = require("../../nerves/runtime");
|
|
61
|
+
/** Format diary hits the same way the recall tool does. */
|
|
62
|
+
function formatDiaryHits(hits) {
|
|
63
|
+
return hits.map((f) => `[diary] ${f.text} (source=${f.source}, createdAt=${f.createdAt})`);
|
|
64
|
+
}
|
|
65
|
+
/** Read a file from the agent root, returning null if it doesn't exist. */
|
|
66
|
+
function readAgentFile(agent, ...segments) {
|
|
67
|
+
const filePath = path.join((0, identity_1.getAgentRoot)(agent), ...segments);
|
|
68
|
+
if (!fs.existsSync(filePath))
|
|
69
|
+
return null;
|
|
70
|
+
return fs.readFileSync(filePath, "utf-8");
|
|
71
|
+
}
|
|
72
|
+
/** Resolve the diary root for a specific agent. */
|
|
73
|
+
function agentDiaryRoot(agent) {
|
|
74
|
+
return (0, diary_1.resolveDiaryRoot)(path.join((0, identity_1.getAgentRoot)(agent), "psyche", "memory"));
|
|
75
|
+
}
|
|
76
|
+
/** Read inner dialog runtime status. */
|
|
77
|
+
function readInnerDialogStatus(agent) {
|
|
78
|
+
const content = readAgentFile(agent, "state", "sessions", "self", "inner", "runtime.json");
|
|
79
|
+
if (!content)
|
|
80
|
+
return null;
|
|
81
|
+
try {
|
|
82
|
+
const data = JSON.parse(content);
|
|
83
|
+
return { status: data.status ?? "unknown", lastCompletedAt: data.lastCompletedAt ?? "" };
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function safeReaddir(dirPath) {
|
|
90
|
+
try {
|
|
91
|
+
return fs.readdirSync(dirPath).map(String);
|
|
92
|
+
/* v8 ignore start — catch is defensive; tested paths don't trigger fs errors */
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
/* v8 ignore stop */
|
|
98
|
+
}
|
|
99
|
+
function safeIsDir(dirPath) {
|
|
100
|
+
try {
|
|
101
|
+
return fs.statSync(dirPath).isDirectory();
|
|
102
|
+
/* v8 ignore start — catch is defensive; tested paths don't trigger fs errors */
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
/* v8 ignore stop */
|
|
108
|
+
}
|
|
109
|
+
/** Enumerate sessions from state/sessions/, reading session.json files. */
|
|
110
|
+
function enumerateSessions(agent) {
|
|
111
|
+
const sessionsDir = path.join((0, identity_1.getAgentRoot)(agent), "state", "sessions");
|
|
112
|
+
if (!fs.existsSync(sessionsDir))
|
|
113
|
+
return [];
|
|
114
|
+
const sessions = [];
|
|
115
|
+
for (const friendId of safeReaddir(sessionsDir)) {
|
|
116
|
+
const friendPath = path.join(sessionsDir, friendId);
|
|
117
|
+
if (!safeIsDir(friendPath))
|
|
118
|
+
continue;
|
|
119
|
+
for (const channel of safeReaddir(friendPath)) {
|
|
120
|
+
const channelPath = path.join(friendPath, channel);
|
|
121
|
+
if (!safeIsDir(channelPath))
|
|
122
|
+
continue;
|
|
123
|
+
for (const key of safeReaddir(channelPath)) {
|
|
124
|
+
const sessionFile = path.join(channelPath, key, "session.json");
|
|
125
|
+
if (!fs.existsSync(sessionFile))
|
|
126
|
+
continue;
|
|
127
|
+
try {
|
|
128
|
+
const data = JSON.parse(fs.readFileSync(sessionFile, "utf-8"));
|
|
129
|
+
sessions.push({ friendId, channel, key, lastUsage: data.lastUsage ?? "" });
|
|
130
|
+
}
|
|
131
|
+
catch { /* skip malformed */ }
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return sessions;
|
|
136
|
+
}
|
|
137
|
+
/** List markdown files in {agentRoot}/tasks/. */
|
|
138
|
+
function listTaskFiles(agent) {
|
|
139
|
+
const tasksDir = path.join((0, identity_1.getAgentRoot)(agent), "tasks");
|
|
140
|
+
if (!fs.existsSync(tasksDir))
|
|
141
|
+
return [];
|
|
142
|
+
try {
|
|
143
|
+
return fs.readdirSync(tasksDir).map(String).filter((f) => f.endsWith(".md"));
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
return [];
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function emit(event, message, meta) {
|
|
150
|
+
(0, runtime_1.emitNervesEvent)({ component: "daemon", event, message, meta });
|
|
151
|
+
}
|
|
152
|
+
// ─── Handlers ────────────────────────────────────────────────────────────────
|
|
153
|
+
async function handleAgentStatus(params) {
|
|
154
|
+
(0, runtime_1.emitNervesEvent)({ component: "daemon", event: "daemon.agent_service_start", message: "handling agent.status", meta: { agent: params.agent } });
|
|
155
|
+
const diaryRoot = agentDiaryRoot(params.agent);
|
|
156
|
+
const facts = (0, diary_1.readDiaryEntries)(diaryRoot);
|
|
157
|
+
const innerStatus = readInnerDialogStatus(params.agent);
|
|
158
|
+
const sessions = enumerateSessions(params.agent);
|
|
159
|
+
emit("daemon.agent_service_end", "completed agent.status", { agent: params.agent });
|
|
160
|
+
return {
|
|
161
|
+
ok: true,
|
|
162
|
+
message: `Agent ${params.agent} status`,
|
|
163
|
+
data: {
|
|
164
|
+
agent: params.agent,
|
|
165
|
+
innerStatus: innerStatus?.status ?? "unknown",
|
|
166
|
+
lastThoughtAt: innerStatus?.lastCompletedAt ?? null,
|
|
167
|
+
sessionCount: sessions.length,
|
|
168
|
+
hasMemory: facts.length > 0,
|
|
169
|
+
factCount: facts.length,
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
async function handleAgentAsk(params) {
|
|
174
|
+
emit("daemon.agent_service_start", "handling agent.ask", { agent: params.agent });
|
|
175
|
+
const question = params.question;
|
|
176
|
+
if (!question) {
|
|
177
|
+
emit("daemon.agent_service_error", "agent.ask missing question", { agent: params.agent });
|
|
178
|
+
return { ok: false, error: "Missing required parameter: question" };
|
|
179
|
+
}
|
|
180
|
+
// Use the same searchDiaryEntries the recall tool uses (substring fallback — no embedding provider in shim)
|
|
181
|
+
const diaryRoot = agentDiaryRoot(params.agent);
|
|
182
|
+
const hits = await (0, diary_1.searchDiaryEntries)(question, (0, diary_1.readDiaryEntries)(diaryRoot));
|
|
183
|
+
const context = hits.length > 0
|
|
184
|
+
? hits.slice(0, 10).map((f) => f.text).join("\n")
|
|
185
|
+
: `No relevant memories found for: ${question}`;
|
|
186
|
+
emit("daemon.agent_service_end", "completed agent.ask", { agent: params.agent });
|
|
187
|
+
return { ok: true, message: context };
|
|
188
|
+
}
|
|
189
|
+
async function handleAgentCatchup(params) {
|
|
190
|
+
emit("daemon.agent_service_start", "handling agent.catchup", { agent: params.agent });
|
|
191
|
+
const sessions = enumerateSessions(params.agent);
|
|
192
|
+
const sorted = sessions.sort((a, b) => (b.lastUsage || "").localeCompare(a.lastUsage || ""));
|
|
193
|
+
const recentSessions = sorted.slice(0, 5);
|
|
194
|
+
const innerStatus = readInnerDialogStatus(params.agent);
|
|
195
|
+
const parts = [];
|
|
196
|
+
if (innerStatus) {
|
|
197
|
+
parts.push(`Inner dialog: ${innerStatus.status} (last completed: ${innerStatus.lastCompletedAt || "never"})`);
|
|
198
|
+
}
|
|
199
|
+
if (recentSessions.length > 0) {
|
|
200
|
+
parts.push(`Recent sessions (${recentSessions.length}):`);
|
|
201
|
+
for (const s of recentSessions) {
|
|
202
|
+
parts.push(` - ${s.friendId}/${s.channel}/${s.key} (${s.lastUsage || "unknown"})`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
parts.push("No recent sessions");
|
|
207
|
+
}
|
|
208
|
+
emit("daemon.agent_service_end", "completed agent.catchup", { agent: params.agent });
|
|
209
|
+
return {
|
|
210
|
+
ok: true,
|
|
211
|
+
/* v8 ignore next — parts always has at least one element (either sessions or "No recent sessions") */
|
|
212
|
+
message: parts.length > 0 ? parts.join("\n") : `No recent activity for ${params.agent}`,
|
|
213
|
+
data: { recentSessions, innerStatus },
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
async function handleAgentDelegate(params) {
|
|
217
|
+
emit("daemon.agent_service_start", "handling agent.delegate", { agent: params.agent });
|
|
218
|
+
const task = params.task;
|
|
219
|
+
if (!task) {
|
|
220
|
+
emit("daemon.agent_service_error", "agent.delegate missing task", { agent: params.agent });
|
|
221
|
+
return { ok: false, error: "Missing required parameter: task" };
|
|
222
|
+
}
|
|
223
|
+
emit("daemon.agent_service_end", "completed agent.delegate", { agent: params.agent });
|
|
224
|
+
return { ok: true, message: `Task queued: ${task}`, data: { task, context: params.context ?? null, queuedAt: new Date().toISOString() } };
|
|
225
|
+
}
|
|
226
|
+
async function handleAgentGetContext(params) {
|
|
227
|
+
emit("daemon.agent_service_start", "handling agent.getContext", { agent: params.agent });
|
|
228
|
+
const query = (params.question ?? params.query ?? params.topic);
|
|
229
|
+
const diaryRoot = agentDiaryRoot(params.agent);
|
|
230
|
+
const facts = (0, diary_1.readDiaryEntries)(diaryRoot);
|
|
231
|
+
const innerStatus = readInnerDialogStatus(params.agent);
|
|
232
|
+
const sessions = enumerateSessions(params.agent);
|
|
233
|
+
const taskFiles = listTaskFiles(params.agent);
|
|
234
|
+
let memorySummary = null;
|
|
235
|
+
if (query) {
|
|
236
|
+
const hits = await (0, diary_1.searchDiaryEntries)(query, facts);
|
|
237
|
+
memorySummary = hits.length > 0
|
|
238
|
+
? hits.slice(0, 10).map((f) => f.text).join("\n")
|
|
239
|
+
: `No relevant memories for: ${query}`;
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
const recent = facts.slice(-10);
|
|
243
|
+
if (recent.length > 0)
|
|
244
|
+
memorySummary = recent.map((f) => f.text).join("\n");
|
|
245
|
+
}
|
|
246
|
+
emit("daemon.agent_service_end", "completed agent.getContext", { agent: params.agent });
|
|
247
|
+
return {
|
|
248
|
+
ok: true,
|
|
249
|
+
data: {
|
|
250
|
+
agent: params.agent,
|
|
251
|
+
hasMemory: facts.length > 0,
|
|
252
|
+
factCount: facts.length,
|
|
253
|
+
memorySummary,
|
|
254
|
+
taskCount: taskFiles.length,
|
|
255
|
+
sessionCount: sessions.length,
|
|
256
|
+
innerStatus: innerStatus?.status ?? null,
|
|
257
|
+
},
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
async function handleAgentSearchMemory(params) {
|
|
261
|
+
emit("daemon.agent_service_start", "handling agent.searchMemory", { agent: params.agent });
|
|
262
|
+
const query = params.query;
|
|
263
|
+
if (!query) {
|
|
264
|
+
emit("daemon.agent_service_error", "agent.searchMemory missing query", { agent: params.agent });
|
|
265
|
+
return { ok: false, error: "Missing required parameter: query" };
|
|
266
|
+
}
|
|
267
|
+
// Same searchDiaryEntries as the recall tool
|
|
268
|
+
const diaryRoot = agentDiaryRoot(params.agent);
|
|
269
|
+
const hits = await (0, diary_1.searchDiaryEntries)(query, (0, diary_1.readDiaryEntries)(diaryRoot));
|
|
270
|
+
const formatted = formatDiaryHits(hits.slice(0, 20));
|
|
271
|
+
emit("daemon.agent_service_end", "completed agent.searchMemory", { agent: params.agent, matchCount: hits.length });
|
|
272
|
+
return {
|
|
273
|
+
ok: true,
|
|
274
|
+
message: hits.length > 0 ? `Found ${hits.length} matches` : "No matches found",
|
|
275
|
+
data: { query, matches: formatted },
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
async function handleAgentGetTask(params) {
|
|
279
|
+
emit("daemon.agent_service_start", "handling agent.getTask", { agent: params.agent });
|
|
280
|
+
const taskFiles = listTaskFiles(params.agent);
|
|
281
|
+
const activeTasks = taskFiles.filter((f) => f.toLowerCase().includes("doing") && !f.toLowerCase().includes("done"));
|
|
282
|
+
const taskNames = activeTasks.length > 0 ? activeTasks : taskFiles;
|
|
283
|
+
const tasks = taskNames.map((name) => {
|
|
284
|
+
const content = readAgentFile(params.agent, "tasks", name);
|
|
285
|
+
const firstLine = content?.split("\n").find((l) => l.trim().length > 0)?.trim() ?? "";
|
|
286
|
+
return { name, statusLine: firstLine };
|
|
287
|
+
});
|
|
288
|
+
emit("daemon.agent_service_end", "completed agent.getTask", { agent: params.agent });
|
|
289
|
+
return {
|
|
290
|
+
ok: true,
|
|
291
|
+
message: tasks.length > 0 ? `Tasks (${tasks.length}): ${tasks.map((t) => t.name).join(", ")}` : `No active tasks for ${params.agent}`,
|
|
292
|
+
data: { tasks, activeCount: activeTasks.length, totalCount: taskFiles.length },
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
async function handleAgentCheckScope(params) {
|
|
296
|
+
emit("daemon.agent_service_start", "handling agent.checkScope", { agent: params.agent });
|
|
297
|
+
const item = params.item;
|
|
298
|
+
if (!item) {
|
|
299
|
+
emit("daemon.agent_service_error", "agent.checkScope missing item", { agent: params.agent });
|
|
300
|
+
return { ok: false, error: "Missing required parameter: item" };
|
|
301
|
+
}
|
|
302
|
+
emit("daemon.agent_service_end", "completed agent.checkScope", { agent: params.agent });
|
|
303
|
+
return { ok: true, message: `Scope check for: ${item}`, data: { item, inScope: true, reason: "MVP: scope check requires inference — defaulting to in-scope" } };
|
|
304
|
+
}
|
|
305
|
+
async function handleAgentRequestDecision(params) {
|
|
306
|
+
emit("daemon.agent_service_start", "handling agent.requestDecision", { agent: params.agent });
|
|
307
|
+
const topic = params.topic;
|
|
308
|
+
if (!topic) {
|
|
309
|
+
emit("daemon.agent_service_error", "agent.requestDecision missing topic", { agent: params.agent });
|
|
310
|
+
return { ok: false, error: "Missing required parameter: topic" };
|
|
311
|
+
}
|
|
312
|
+
emit("daemon.agent_service_end", "completed agent.requestDecision", { agent: params.agent });
|
|
313
|
+
return { ok: true, message: `Decision request queued: ${topic}`, data: { topic, options: params.options ?? null, status: "pending" } };
|
|
314
|
+
}
|
|
315
|
+
async function handleAgentCheckGuidance(params) {
|
|
316
|
+
emit("daemon.agent_service_start", "handling agent.checkGuidance", { agent: params.agent });
|
|
317
|
+
const topic = params.topic;
|
|
318
|
+
if (!topic) {
|
|
319
|
+
emit("daemon.agent_service_error", "agent.checkGuidance missing topic", { agent: params.agent });
|
|
320
|
+
return { ok: false, error: "Missing required parameter: topic" };
|
|
321
|
+
}
|
|
322
|
+
// Same searchDiaryEntries as the recall tool
|
|
323
|
+
const diaryRoot = agentDiaryRoot(params.agent);
|
|
324
|
+
const hits = await (0, diary_1.searchDiaryEntries)(topic, (0, diary_1.readDiaryEntries)(diaryRoot));
|
|
325
|
+
const guidance = hits.length > 0
|
|
326
|
+
? `Relevant guidance:\n${hits.slice(0, 10).map((f) => f.text).join("\n")}`
|
|
327
|
+
: `No specific guidance found for: ${topic}`;
|
|
328
|
+
emit("daemon.agent_service_end", "completed agent.checkGuidance", { agent: params.agent });
|
|
329
|
+
return { ok: true, message: guidance };
|
|
330
|
+
}
|
|
331
|
+
async function handleAgentReportProgress(params) {
|
|
332
|
+
emit("daemon.agent_service_start", "handling agent.reportProgress", { agent: params.agent });
|
|
333
|
+
const summary = params.summary;
|
|
334
|
+
if (!summary) {
|
|
335
|
+
emit("daemon.agent_service_error", "agent.reportProgress missing summary", { agent: params.agent });
|
|
336
|
+
return { ok: false, error: "Missing required parameter: summary" };
|
|
337
|
+
}
|
|
338
|
+
emit("daemon.agent_service_end", "completed agent.reportProgress", { agent: params.agent });
|
|
339
|
+
return { ok: true, message: `Progress noted: ${summary}`, data: { summary, receivedAt: new Date().toISOString() } };
|
|
340
|
+
}
|
|
341
|
+
async function handleAgentReportBlocker(params) {
|
|
342
|
+
emit("daemon.agent_service_start", "handling agent.reportBlocker", { agent: params.agent });
|
|
343
|
+
const blocker = params.blocker;
|
|
344
|
+
if (!blocker) {
|
|
345
|
+
emit("daemon.agent_service_error", "agent.reportBlocker missing blocker", { agent: params.agent });
|
|
346
|
+
return { ok: false, error: "Missing required parameter: blocker" };
|
|
347
|
+
}
|
|
348
|
+
emit("daemon.agent_service_end", "completed agent.reportBlocker", { agent: params.agent });
|
|
349
|
+
return { ok: true, message: `Blocker reported: ${blocker}`, data: { blocker, receivedAt: new Date().toISOString() } };
|
|
350
|
+
}
|
|
351
|
+
async function handleAgentReportComplete(params) {
|
|
352
|
+
emit("daemon.agent_service_start", "handling agent.reportComplete", { agent: params.agent });
|
|
353
|
+
const summary = params.summary;
|
|
354
|
+
if (!summary) {
|
|
355
|
+
emit("daemon.agent_service_error", "agent.reportComplete missing summary", { agent: params.agent });
|
|
356
|
+
return { ok: false, error: "Missing required parameter: summary" };
|
|
357
|
+
}
|
|
358
|
+
emit("daemon.agent_service_end", "completed agent.reportComplete", { agent: params.agent });
|
|
359
|
+
return { ok: true, message: `Completion reported: ${summary}`, data: { summary, receivedAt: new Date().toISOString() } };
|
|
360
|
+
}
|