@ouro.bot/cli 0.1.0-alpha.19 → 0.1.0-alpha.190
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/README.md +187 -191
- package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/agent.json +3 -2
- package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/SOUL.md +1 -1
- package/changelog.json +1280 -0
- package/dist/heart/active-work.js +832 -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/cares.js +174 -0
- package/dist/heart/commitments.js +111 -0
- package/dist/heart/config.js +40 -30
- package/dist/heart/core.js +620 -124
- 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 +2470 -210
- package/dist/heart/daemon/daemon-entry.js +157 -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 +449 -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-flow.js +31 -112
- package/dist/heart/daemon/hatch-specialist.js +3 -3
- 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 +165 -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 +1331 -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-prompt.js +10 -7
- package/dist/heart/daemon/specialist-tools.js +49 -3
- 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/intentions.js +168 -0
- 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 +220 -0
- package/dist/heart/presence.js +185 -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 +187 -41
- 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 +36 -27
- package/dist/heart/target-resolution.js +127 -0
- package/dist/heart/tempo.js +93 -0
- package/dist/heart/temporal-view.js +41 -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/heart/wake-packet.js +226 -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/episodes.js +116 -0
- package/dist/mind/file-state.js +179 -0
- 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 +36 -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 +779 -102
- package/dist/mind/scrutiny.js +173 -0
- package/dist/mind/token-estimate.js +8 -12
- package/dist/nerves/coverage/audit.js +1 -1
- 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-DN6vVYPm.css +1 -0
- package/dist/outlook-ui/assets/index-M1l1tDTX.js +61 -0
- package/dist/outlook-ui/index.html +15 -0
- package/dist/repertoire/ado-semantic.js +11 -5
- package/dist/repertoire/coding/codex-jsonl.js +64 -0
- package/dist/repertoire/coding/context-pack.js +330 -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 +170 -7
- 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/shell-sessions.js +133 -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 +1345 -320
- 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 +318 -124
- 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/adapter.js +274 -0
- package/dist/senses/cli/ink-app.js +156 -0
- package/dist/senses/cli/inline-diff.js +64 -0
- package/dist/senses/cli/message-list.js +51 -0
- package/dist/senses/cli/ouro-tui.js +349 -0
- package/dist/senses/cli/spinner-imperative.js +135 -0
- package/dist/senses/cli/spinner.js +101 -0
- package/dist/senses/cli/status-line.js +60 -0
- package/dist/senses/cli/streaming-markdown.js +526 -0
- package/dist/senses/cli/tool-display.js +83 -0
- package/dist/senses/cli/tool-render.js +85 -0
- package/dist/senses/cli/tui-store.js +198 -0
- package/dist/senses/cli/virtual-list.js +35 -0
- package/dist/senses/cli-entry.js +1 -1
- package/dist/senses/cli-layout.js +187 -0
- package/dist/senses/cli.js +508 -243
- package/dist/senses/commands.js +65 -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 +633 -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 +16 -6
- 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
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/basilisk.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/jafar.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/jormungandr.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/kaa.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/medusa.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/monty.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/nagini.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/ouroboros.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/python.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/quetzalcoatl.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/sir-hiss.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/the-serpent.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/the-snake.md +0 -0
package/dist/repertoire/tools.js
CHANGED
|
@@ -1,49 +1,238 @@
|
|
|
1
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
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
36
|
+
exports.restTool = exports.ponderTool = exports.observeTool = exports.settleTool = exports.tools = void 0;
|
|
4
37
|
exports.getToolsForChannel = getToolsForChannel;
|
|
5
38
|
exports.isConfirmationRequired = isConfirmationRequired;
|
|
6
39
|
exports.execTool = execTool;
|
|
7
40
|
exports.summarizeArgs = summarizeArgs;
|
|
41
|
+
exports.buildToolResultSummary = buildToolResultSummary;
|
|
8
42
|
const tools_base_1 = require("./tools-base");
|
|
9
43
|
const tools_teams_1 = require("./tools-teams");
|
|
44
|
+
const tools_bluebubbles_1 = require("./tools-bluebubbles");
|
|
10
45
|
const ado_semantic_1 = require("./ado-semantic");
|
|
11
46
|
const tools_github_1 = require("./tools-github");
|
|
12
47
|
const runtime_1 = require("../nerves/runtime");
|
|
48
|
+
const guardrails_1 = require("./guardrails");
|
|
49
|
+
const identity_1 = require("../heart/identity");
|
|
50
|
+
const surface_tool_1 = require("../senses/surface-tool");
|
|
51
|
+
const obligations_1 = require("../mind/obligations");
|
|
52
|
+
const obligations_2 = require("../heart/obligations");
|
|
53
|
+
const session_activity_1 = require("../heart/session-activity");
|
|
54
|
+
const path = __importStar(require("path"));
|
|
55
|
+
function safeGetAgentRoot() {
|
|
56
|
+
try {
|
|
57
|
+
return (0, identity_1.getAgentRoot)();
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
13
63
|
// Re-export types and constants used by the rest of the codebase
|
|
14
64
|
var tools_base_2 = require("./tools-base");
|
|
15
65
|
Object.defineProperty(exports, "tools", { enumerable: true, get: function () { return tools_base_2.tools; } });
|
|
16
|
-
Object.defineProperty(exports, "
|
|
17
|
-
|
|
18
|
-
Object.defineProperty(exports, "
|
|
66
|
+
Object.defineProperty(exports, "settleTool", { enumerable: true, get: function () { return tools_base_2.settleTool; } });
|
|
67
|
+
Object.defineProperty(exports, "observeTool", { enumerable: true, get: function () { return tools_base_2.observeTool; } });
|
|
68
|
+
Object.defineProperty(exports, "ponderTool", { enumerable: true, get: function () { return tools_base_2.ponderTool; } });
|
|
69
|
+
Object.defineProperty(exports, "restTool", { enumerable: true, get: function () { return tools_base_2.restTool; } });
|
|
70
|
+
// Surface tool handler: routes content to friend's freshest session
|
|
71
|
+
/* v8 ignore start -- surface handler wiring: core logic tested via surface-tool.test.ts; this wires identity/routing deps @preserve */
|
|
72
|
+
const surfaceToolDefinition = {
|
|
73
|
+
tool: surface_tool_1.surfaceToolDef,
|
|
74
|
+
handler: async (args, ctx) => {
|
|
75
|
+
const queue = ctx?.delegatedOrigins ?? [];
|
|
76
|
+
const agentName = (() => { try {
|
|
77
|
+
return (0, identity_1.getAgentName)();
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return "unknown";
|
|
81
|
+
} })();
|
|
82
|
+
const routeToFriend = async (friendId, content, queueItem) => {
|
|
83
|
+
/* v8 ignore start -- routing: integration path tested via inner-dialog routing tests @preserve */
|
|
84
|
+
try {
|
|
85
|
+
const agentRoot = (0, identity_1.getAgentRoot)();
|
|
86
|
+
const sessionsDir = path.join(agentRoot, "state", "sessions");
|
|
87
|
+
const friendsDir = path.join(agentRoot, "friends");
|
|
88
|
+
// Priority 1: Bridge-preferred session (if queue item has a bridgeId)
|
|
89
|
+
if (queueItem?.bridgeId) {
|
|
90
|
+
const { createBridgeManager } = await Promise.resolve().then(() => __importStar(require("../heart/bridges/manager")));
|
|
91
|
+
const bridge = createBridgeManager().getBridge(queueItem.bridgeId);
|
|
92
|
+
if (bridge && bridge.lifecycle !== "completed" && bridge.lifecycle !== "cancelled") {
|
|
93
|
+
const allSessions = (0, session_activity_1.listSessionActivity)({ sessionsDir, friendsDir, agentName });
|
|
94
|
+
const bridgeTarget = allSessions.find((activity) => activity.friendId === friendId
|
|
95
|
+
&& activity.channel !== "inner"
|
|
96
|
+
&& bridge.attachedSessions.some((s) => s.friendId === activity.friendId && s.channel === activity.channel && s.key === activity.key));
|
|
97
|
+
if (bridgeTarget) {
|
|
98
|
+
// Attempt proactive BB delivery for bridge target
|
|
99
|
+
if (bridgeTarget.channel === "bluebubbles") {
|
|
100
|
+
const { sendProactiveBlueBubblesMessageToSession } = await Promise.resolve().then(() => __importStar(require("../senses/bluebubbles")));
|
|
101
|
+
const proactiveResult = await sendProactiveBlueBubblesMessageToSession({
|
|
102
|
+
friendId: bridgeTarget.friendId,
|
|
103
|
+
sessionKey: bridgeTarget.key,
|
|
104
|
+
text: content,
|
|
105
|
+
});
|
|
106
|
+
if (proactiveResult.delivered) {
|
|
107
|
+
// Inject surfaced content into the target session so it knows what was delivered
|
|
108
|
+
const { appendSyntheticAssistantMessage } = await Promise.resolve().then(() => __importStar(require("../mind/context")));
|
|
109
|
+
const sessionFilePath = path.join(sessionsDir, bridgeTarget.friendId, bridgeTarget.channel, `${bridgeTarget.key}.json`);
|
|
110
|
+
appendSyntheticAssistantMessage(sessionFilePath, `[surfaced from inner dialog] ${content}`);
|
|
111
|
+
return { status: "delivered", detail: "via iMessage" };
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// Fall back to pending queue for bridge target
|
|
115
|
+
const { queuePendingMessage, getPendingDir } = await Promise.resolve().then(() => __importStar(require("../mind/pending")));
|
|
116
|
+
const pendingDir = getPendingDir(agentName, bridgeTarget.friendId, bridgeTarget.channel, bridgeTarget.key);
|
|
117
|
+
queuePendingMessage(pendingDir, {
|
|
118
|
+
from: agentName,
|
|
119
|
+
friendId: bridgeTarget.friendId,
|
|
120
|
+
channel: bridgeTarget.channel,
|
|
121
|
+
key: bridgeTarget.key,
|
|
122
|
+
content,
|
|
123
|
+
timestamp: Date.now(),
|
|
124
|
+
});
|
|
125
|
+
return { status: "queued", detail: `for next interaction via ${bridgeTarget.channel}` };
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
// Priority 2: Freshest active friend session
|
|
130
|
+
const freshest = (0, session_activity_1.findFreshestFriendSession)({
|
|
131
|
+
sessionsDir,
|
|
132
|
+
friendsDir,
|
|
133
|
+
agentName,
|
|
134
|
+
friendId,
|
|
135
|
+
activeOnly: true,
|
|
136
|
+
});
|
|
137
|
+
if (freshest && freshest.channel !== "inner") {
|
|
138
|
+
// Attempt proactive BB delivery
|
|
139
|
+
if (freshest.channel === "bluebubbles") {
|
|
140
|
+
const { sendProactiveBlueBubblesMessageToSession } = await Promise.resolve().then(() => __importStar(require("../senses/bluebubbles")));
|
|
141
|
+
const proactiveResult = await sendProactiveBlueBubblesMessageToSession({
|
|
142
|
+
friendId: freshest.friendId,
|
|
143
|
+
sessionKey: freshest.key,
|
|
144
|
+
text: content,
|
|
145
|
+
});
|
|
146
|
+
if (proactiveResult.delivered) {
|
|
147
|
+
// Inject surfaced content into the target session so it knows what was delivered
|
|
148
|
+
const { appendSyntheticAssistantMessage } = await Promise.resolve().then(() => __importStar(require("../mind/context")));
|
|
149
|
+
const sessionFilePath = path.join(sessionsDir, freshest.friendId, freshest.channel, `${freshest.key}.json`);
|
|
150
|
+
appendSyntheticAssistantMessage(sessionFilePath, `[surfaced from inner dialog] ${content}`);
|
|
151
|
+
return { status: "delivered", detail: "via iMessage" };
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
// Queue as pending for next interaction
|
|
155
|
+
const { queuePendingMessage, getPendingDir } = await Promise.resolve().then(() => __importStar(require("../mind/pending")));
|
|
156
|
+
const pendingDir = getPendingDir(agentName, freshest.friendId, freshest.channel, freshest.key);
|
|
157
|
+
queuePendingMessage(pendingDir, {
|
|
158
|
+
from: agentName,
|
|
159
|
+
friendId: freshest.friendId,
|
|
160
|
+
channel: freshest.channel,
|
|
161
|
+
key: freshest.key,
|
|
162
|
+
content,
|
|
163
|
+
timestamp: Date.now(),
|
|
164
|
+
});
|
|
165
|
+
return { status: "queued", detail: `for next interaction via ${freshest.channel}` };
|
|
166
|
+
}
|
|
167
|
+
// Priority 3: Deferred — no active session found
|
|
168
|
+
const { getDeferredReturnDir } = await Promise.resolve().then(() => __importStar(require("../mind/pending")));
|
|
169
|
+
const { queuePendingMessage: queueDeferred } = await Promise.resolve().then(() => __importStar(require("../mind/pending")));
|
|
170
|
+
const deferredDir = getDeferredReturnDir(agentName, friendId);
|
|
171
|
+
queueDeferred(deferredDir, {
|
|
172
|
+
from: agentName,
|
|
173
|
+
friendId,
|
|
174
|
+
channel: "deferred",
|
|
175
|
+
key: "return",
|
|
176
|
+
content,
|
|
177
|
+
timestamp: Date.now(),
|
|
178
|
+
});
|
|
179
|
+
return { status: "deferred", detail: "they'll see it next time" };
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
return { status: "failed" };
|
|
183
|
+
}
|
|
184
|
+
/* v8 ignore stop */
|
|
185
|
+
};
|
|
186
|
+
return (0, surface_tool_1.handleSurface)({
|
|
187
|
+
content: args.content ?? "",
|
|
188
|
+
delegationId: args.delegationId,
|
|
189
|
+
friendId: args.friendId,
|
|
190
|
+
queue,
|
|
191
|
+
routeToFriend,
|
|
192
|
+
advanceObligation: (obligationId, update) => {
|
|
193
|
+
/* v8 ignore start -- obligation advance: tested via attention-queue tests @preserve */
|
|
194
|
+
try {
|
|
195
|
+
const name = (() => { try {
|
|
196
|
+
return (0, identity_1.getAgentName)();
|
|
197
|
+
}
|
|
198
|
+
catch {
|
|
199
|
+
return "unknown";
|
|
200
|
+
} })();
|
|
201
|
+
(0, obligations_1.advanceObligation)(name, obligationId, {
|
|
202
|
+
status: update.status,
|
|
203
|
+
...(update.returnedAt !== undefined ? { returnedAt: update.returnedAt } : {}),
|
|
204
|
+
...(update.returnTarget !== undefined ? { returnTarget: update.returnTarget } : {}),
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
catch {
|
|
208
|
+
// swallowed — obligation advance must never break surface delivery
|
|
209
|
+
}
|
|
210
|
+
/* v8 ignore stop */
|
|
211
|
+
},
|
|
212
|
+
fulfillHeartObligation: (origin) => {
|
|
213
|
+
/* v8 ignore start -- heart obligation fulfillment: tested via surface-tool.test.ts @preserve */
|
|
214
|
+
try {
|
|
215
|
+
const agentRoot = (0, identity_1.getAgentRoot)();
|
|
216
|
+
const heartObligation = (0, obligations_2.findPendingObligationForOrigin)(agentRoot, origin);
|
|
217
|
+
if (heartObligation) {
|
|
218
|
+
(0, obligations_2.fulfillObligation)(agentRoot, heartObligation.id);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
catch {
|
|
222
|
+
// swallowed — heart obligation fulfillment must never break surface delivery
|
|
223
|
+
}
|
|
224
|
+
/* v8 ignore stop */
|
|
225
|
+
},
|
|
226
|
+
});
|
|
227
|
+
},
|
|
228
|
+
summaryKeys: ["content", "delegationId"],
|
|
229
|
+
};
|
|
230
|
+
/* v8 ignore stop */
|
|
19
231
|
// All tool definitions in a single registry
|
|
20
|
-
const allDefinitions = [...tools_base_1.baseToolDefinitions, ...tools_teams_1.teamsToolDefinitions, ...ado_semantic_1.adoSemanticToolDefinitions, ...tools_github_1.githubToolDefinitions];
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return
|
|
24
|
-
}
|
|
25
|
-
function isSharedRemoteContext(friend) {
|
|
26
|
-
const externalIds = friend.externalIds ?? [];
|
|
27
|
-
return externalIds.some((externalId) => externalId.externalId.startsWith("group:") || externalId.provider === "teams-conversation");
|
|
28
|
-
}
|
|
29
|
-
function isTrustedRemoteContext(context) {
|
|
30
|
-
if (!context?.friend || !isRemoteChannel(context.channel))
|
|
31
|
-
return false;
|
|
32
|
-
const trustLevel = context.friend.trustLevel ?? "stranger";
|
|
33
|
-
return trustLevel !== "stranger" && !isSharedRemoteContext(context.friend);
|
|
34
|
-
}
|
|
35
|
-
function shouldBlockLocalTools(capabilities, context) {
|
|
36
|
-
if (!isRemoteChannel(capabilities))
|
|
37
|
-
return false;
|
|
38
|
-
return !isTrustedRemoteContext(context);
|
|
39
|
-
}
|
|
40
|
-
function blockedLocalToolMessage() {
|
|
41
|
-
return "I can't do that from here because I'm talking to multiple people in a shared remote channel, and local shell/file/git/gh operations could let conversations interfere with each other. Ask me for a remote-safe alternative (Graph/ADO/web), or run that operation from CLI.";
|
|
42
|
-
}
|
|
43
|
-
function baseToolsForCapabilities(capabilities, context) {
|
|
44
|
-
if (!shouldBlockLocalTools(capabilities, context))
|
|
45
|
-
return tools_base_1.tools;
|
|
46
|
-
return tools_base_1.tools.filter((tool) => !REMOTE_BLOCKED_LOCAL_TOOLS.has(tool.function.name));
|
|
232
|
+
const allDefinitions = [...tools_base_1.baseToolDefinitions, ...tools_bluebubbles_1.bluebubblesToolDefinitions, ...tools_teams_1.teamsToolDefinitions, ...ado_semantic_1.adoSemanticToolDefinitions, ...tools_github_1.githubToolDefinitions, surfaceToolDefinition];
|
|
233
|
+
function baseToolsForCapabilities() {
|
|
234
|
+
// Use baseToolDefinitions at call time so dynamically-added tools are included
|
|
235
|
+
return tools_base_1.baseToolDefinitions.map((d) => d.tool);
|
|
47
236
|
}
|
|
48
237
|
// Apply a single tool preference to a tool schema, returning a new object.
|
|
49
238
|
function applyPreference(tool, pref) {
|
|
@@ -55,34 +244,55 @@ function applyPreference(tool, pref) {
|
|
|
55
244
|
},
|
|
56
245
|
};
|
|
57
246
|
}
|
|
247
|
+
// Filter out tools whose requiredCapability is not in the provider's capability set.
|
|
248
|
+
// Uses baseToolDefinitions at call time so dynamically-added tools are included.
|
|
249
|
+
// Only base tools can have requiredCapability (integration tools do not).
|
|
250
|
+
function filterByCapability(toolList, providerCapabilities) {
|
|
251
|
+
return toolList.filter((tool) => {
|
|
252
|
+
const def = tools_base_1.baseToolDefinitions.find((d) => d.tool.function.name === tool.function.name);
|
|
253
|
+
if (!def?.requiredCapability)
|
|
254
|
+
return true;
|
|
255
|
+
return providerCapabilities?.has(def.requiredCapability) === true;
|
|
256
|
+
});
|
|
257
|
+
}
|
|
58
258
|
// Return the appropriate tools list based on channel capabilities.
|
|
59
259
|
// Base tools (no integration) are always included.
|
|
60
260
|
// Teams/integration tools are included only if their integration is in availableIntegrations.
|
|
61
261
|
// When toolPreferences is provided, matching preferences are appended to tool descriptions.
|
|
62
|
-
|
|
63
|
-
|
|
262
|
+
// When providerCapabilities is provided, tools with requiredCapability are filtered.
|
|
263
|
+
function getToolsForChannel(capabilities, toolPreferences, _context, providerCapabilities) {
|
|
264
|
+
const baseTools = baseToolsForCapabilities();
|
|
265
|
+
const bluebubblesTools = capabilities?.channel === "bluebubbles"
|
|
266
|
+
? tools_bluebubbles_1.bluebubblesToolDefinitions.map((d) => d.tool)
|
|
267
|
+
: [];
|
|
268
|
+
let result;
|
|
64
269
|
if (!capabilities || capabilities.availableIntegrations.length === 0) {
|
|
65
|
-
|
|
270
|
+
result = [...baseTools, ...bluebubblesTools];
|
|
66
271
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
272
|
+
else {
|
|
273
|
+
const available = new Set(capabilities.availableIntegrations);
|
|
274
|
+
const channelDefs = [...tools_teams_1.teamsToolDefinitions, ...ado_semantic_1.adoSemanticToolDefinitions, ...tools_github_1.githubToolDefinitions];
|
|
275
|
+
// Include tools whose integration is available, plus channel tools with no integration gate (e.g. teams_send_message)
|
|
276
|
+
const integrationDefs = channelDefs.filter((d) => d.integration ? available.has(d.integration) : capabilities.channel === "teams");
|
|
277
|
+
if (!toolPreferences || Object.keys(toolPreferences).length === 0) {
|
|
278
|
+
result = [...baseTools, ...bluebubblesTools, ...integrationDefs.map((d) => d.tool)];
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
// Build a map of integration -> preference text for fast lookup
|
|
282
|
+
const prefMap = new Map();
|
|
283
|
+
for (const [key, value] of Object.entries(toolPreferences)) {
|
|
284
|
+
prefMap.set(key, value);
|
|
285
|
+
}
|
|
286
|
+
// Apply preferences to matching integration tools (new objects, no mutation)
|
|
287
|
+
// d.integration is guaranteed truthy -- integrationDefs are pre-filtered above
|
|
288
|
+
const enrichedIntegrationTools = integrationDefs.map((d) => {
|
|
289
|
+
const pref = prefMap.get(d.integration);
|
|
290
|
+
return pref ? applyPreference(d.tool, pref) : d.tool;
|
|
291
|
+
});
|
|
292
|
+
result = [...baseTools, ...bluebubblesTools, ...enrichedIntegrationTools];
|
|
293
|
+
}
|
|
73
294
|
}
|
|
74
|
-
|
|
75
|
-
const prefMap = new Map();
|
|
76
|
-
for (const [key, value] of Object.entries(toolPreferences)) {
|
|
77
|
-
prefMap.set(key, value);
|
|
78
|
-
}
|
|
79
|
-
// Apply preferences to matching integration tools (new objects, no mutation)
|
|
80
|
-
// d.integration is guaranteed truthy -- integrationDefs are pre-filtered above
|
|
81
|
-
const enrichedIntegrationTools = integrationDefs.map((d) => {
|
|
82
|
-
const pref = prefMap.get(d.integration);
|
|
83
|
-
return pref ? applyPreference(d.tool, pref) : d.tool;
|
|
84
|
-
});
|
|
85
|
-
return [...baseTools, ...enrichedIntegrationTools];
|
|
295
|
+
return filterByCapability(result, providerCapabilities);
|
|
86
296
|
}
|
|
87
297
|
// Check whether a tool requires user confirmation before execution.
|
|
88
298
|
// Reads from ToolDefinition.confirmationRequired instead of a separate Set.
|
|
@@ -90,12 +300,15 @@ function isConfirmationRequired(toolName) {
|
|
|
90
300
|
const def = allDefinitions.find((d) => d.tool.function.name === toolName);
|
|
91
301
|
return def?.confirmationRequired === true;
|
|
92
302
|
}
|
|
303
|
+
function normalizeGuardArgs(_name, args) {
|
|
304
|
+
return args;
|
|
305
|
+
}
|
|
93
306
|
async function execTool(name, args, ctx) {
|
|
94
307
|
(0, runtime_1.emitNervesEvent)({
|
|
95
308
|
event: "tool.start",
|
|
96
309
|
component: "tools",
|
|
97
310
|
message: "tool execution started",
|
|
98
|
-
meta: { name },
|
|
311
|
+
meta: { name, ...(name === "shell" && args.command ? { command: args.command } : {}) },
|
|
99
312
|
});
|
|
100
313
|
// Look up from combined registry
|
|
101
314
|
const def = allDefinitions.find((d) => d.tool.function.name === name);
|
|
@@ -109,16 +322,23 @@ async function execTool(name, args, ctx) {
|
|
|
109
322
|
});
|
|
110
323
|
return `unknown: ${name}`;
|
|
111
324
|
}
|
|
112
|
-
|
|
113
|
-
|
|
325
|
+
// Guardrail check: structural + trust-level
|
|
326
|
+
const guardContext = {
|
|
327
|
+
readPaths: tools_base_1.editFileReadTracker,
|
|
328
|
+
trustLevel: ctx?.context?.friend?.trustLevel,
|
|
329
|
+
agentRoot: safeGetAgentRoot(),
|
|
330
|
+
};
|
|
331
|
+
const guardArgs = normalizeGuardArgs(name, args);
|
|
332
|
+
const guardResult = (0, guardrails_1.guardInvocation)(name, guardArgs, guardContext);
|
|
333
|
+
if (!guardResult.allowed) {
|
|
114
334
|
(0, runtime_1.emitNervesEvent)({
|
|
115
335
|
level: "warn",
|
|
116
|
-
event: "tool.
|
|
336
|
+
event: "tool.guardrail_block",
|
|
117
337
|
component: "tools",
|
|
118
|
-
message: "blocked
|
|
119
|
-
meta: { name,
|
|
338
|
+
message: "guardrail blocked tool execution",
|
|
339
|
+
meta: { name, reason: guardResult.reason },
|
|
120
340
|
});
|
|
121
|
-
return
|
|
341
|
+
return guardResult.reason;
|
|
122
342
|
}
|
|
123
343
|
try {
|
|
124
344
|
const result = await def.handler(args, ctx);
|
|
@@ -162,71 +382,45 @@ function summarizeUnknownArgs(args) {
|
|
|
162
382
|
return summarizeKeyValues(args, keys);
|
|
163
383
|
}
|
|
164
384
|
function summarizeArgs(name, args) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
return teamsSummary;
|
|
169
|
-
// Check github tools
|
|
170
|
-
const githubSummary = (0, tools_github_1.summarizeGithubArgs)(name, args);
|
|
171
|
-
if (githubSummary !== undefined)
|
|
172
|
-
return githubSummary;
|
|
173
|
-
// Base tools
|
|
174
|
-
if (name === "read_file" || name === "write_file")
|
|
175
|
-
return summarizeKeyValues(args, ["path"]);
|
|
176
|
-
if (name === "shell")
|
|
177
|
-
return summarizeKeyValues(args, ["command"]);
|
|
178
|
-
if (name === "list_directory")
|
|
179
|
-
return summarizeKeyValues(args, ["path"]);
|
|
180
|
-
if (name === "git_commit")
|
|
181
|
-
return summarizeKeyValues(args, ["message"]);
|
|
182
|
-
if (name === "gh_cli")
|
|
183
|
-
return summarizeKeyValues(args, ["command"]);
|
|
184
|
-
if (name === "load_skill")
|
|
185
|
-
return summarizeKeyValues(args, ["name"]);
|
|
186
|
-
if (name === "task_create")
|
|
187
|
-
return summarizeKeyValues(args, ["title", "type", "category", "scheduledAt", "cadence"]);
|
|
188
|
-
if (name === "schedule_reminder")
|
|
189
|
-
return summarizeKeyValues(args, ["title", "scheduledAt", "cadence"]);
|
|
190
|
-
if (name === "task_update_status")
|
|
191
|
-
return summarizeKeyValues(args, ["name", "status"]);
|
|
192
|
-
if (name === "task_board_status")
|
|
193
|
-
return summarizeKeyValues(args, ["status"]);
|
|
194
|
-
if (name === "task_board_action")
|
|
195
|
-
return summarizeKeyValues(args, ["scope"]);
|
|
196
|
-
if (name === "task_board" || name === "task_board_deps" || name === "task_board_sessions")
|
|
197
|
-
return "";
|
|
198
|
-
if (name === "coding_spawn")
|
|
199
|
-
return summarizeKeyValues(args, ["runner", "workdir", "taskRef"]);
|
|
200
|
-
if (name === "coding_status")
|
|
201
|
-
return summarizeKeyValues(args, ["sessionId"]);
|
|
202
|
-
if (name === "coding_tail")
|
|
203
|
-
return summarizeKeyValues(args, ["sessionId"]);
|
|
204
|
-
if (name === "coding_send_input")
|
|
205
|
-
return summarizeKeyValues(args, ["sessionId", "input"]);
|
|
206
|
-
if (name === "coding_kill")
|
|
207
|
-
return summarizeKeyValues(args, ["sessionId"]);
|
|
208
|
-
if (name === "claude")
|
|
209
|
-
return summarizeKeyValues(args, ["prompt"]);
|
|
210
|
-
if (name === "web_search")
|
|
211
|
-
return summarizeKeyValues(args, ["query"]);
|
|
212
|
-
if (name === "memory_search")
|
|
213
|
-
return summarizeKeyValues(args, ["query"]);
|
|
214
|
-
if (name === "memory_save")
|
|
215
|
-
return summarizeKeyValues(args, ["text", "about"]);
|
|
216
|
-
if (name === "get_friend_note")
|
|
217
|
-
return summarizeKeyValues(args, ["friendId"]);
|
|
218
|
-
if (name === "save_friend_note") {
|
|
219
|
-
return summarizeKeyValues(args, ["type", "key", "content"]);
|
|
385
|
+
const def = allDefinitions.find((d) => d.tool.function.name === name);
|
|
386
|
+
if (def && def.summaryKeys !== undefined) {
|
|
387
|
+
return summarizeKeyValues(args, def.summaryKeys);
|
|
220
388
|
}
|
|
221
|
-
if (name === "ado_backlog_list")
|
|
222
|
-
return summarizeKeyValues(args, ["organization", "project"]);
|
|
223
|
-
if (name === "ado_batch_update")
|
|
224
|
-
return summarizeKeyValues(args, ["organization", "project"]);
|
|
225
|
-
if (name === "ado_create_epic" || name === "ado_create_issue")
|
|
226
|
-
return summarizeKeyValues(args, ["organization", "project", "title"]);
|
|
227
|
-
if (name === "ado_move_items")
|
|
228
|
-
return summarizeKeyValues(args, ["organization", "project", "workItemIds"]);
|
|
229
|
-
if (name === "ado_restructure_backlog")
|
|
230
|
-
return summarizeKeyValues(args, ["organization", "project"]);
|
|
231
389
|
return summarizeUnknownArgs(args);
|
|
232
390
|
}
|
|
391
|
+
/**
|
|
392
|
+
* Build an enriched tool result summary for display on remote channels.
|
|
393
|
+
* For recognized tools, includes result-derived info (diff stats, exit codes, etc.).
|
|
394
|
+
* Falls back to arg-based summary for unrecognized tools.
|
|
395
|
+
*/
|
|
396
|
+
function buildToolResultSummary(name, args, _result, success) {
|
|
397
|
+
switch (name) {
|
|
398
|
+
case "edit_file": {
|
|
399
|
+
if (!success)
|
|
400
|
+
return summarizeArgs(name, args);
|
|
401
|
+
const addedLines = (args.new_string ?? "").split("\n").length;
|
|
402
|
+
const removedLines = (args.old_string ?? "").split("\n").length;
|
|
403
|
+
return `+${addedLines} -${removedLines} lines in ${args.path ?? "unknown"}`;
|
|
404
|
+
}
|
|
405
|
+
case "shell": {
|
|
406
|
+
const cmd = args.command ?? "?";
|
|
407
|
+
const exitCode = success ? 0 : 1;
|
|
408
|
+
return `$ ${cmd} (exit ${exitCode})`;
|
|
409
|
+
}
|
|
410
|
+
case "read_file":
|
|
411
|
+
return `path=${args.path ?? "unknown"}`;
|
|
412
|
+
case "write_file":
|
|
413
|
+
return `path=${args.path ?? "unknown"}`;
|
|
414
|
+
case "glob":
|
|
415
|
+
return `pattern=${args.pattern ?? "?"} ${args.cwd ? `cwd=${args.cwd}` : ""}`.trim();
|
|
416
|
+
case "grep":
|
|
417
|
+
return `pattern=${args.pattern ?? "?"} ${args.path ? `path=${args.path}` : ""}`.trim();
|
|
418
|
+
case "coding_spawn": {
|
|
419
|
+
const taskRef = args.taskRef ?? "unknown";
|
|
420
|
+
const status = success ? "spawned" : "failed";
|
|
421
|
+
return `${taskRef} -> ${status}`;
|
|
422
|
+
}
|
|
423
|
+
default:
|
|
424
|
+
return summarizeArgs(name, args);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Claude Code lifecycle hook handler.
|
|
3
|
+
// Receives events from Claude Code's hooks system (SessionStart, Stop, PostToolUse)
|
|
4
|
+
// and forwards them to the Ouroboros daemon for agent awareness.
|
|
5
|
+
//
|
|
6
|
+
// This module exports handleHookEvent for testability.
|
|
7
|
+
// The actual hook scripts (scripts/claude-code-hook.js) read stdin and call this.
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.handleHookEvent = handleHookEvent;
|
|
10
|
+
const socket_client_1 = require("../heart/daemon/socket-client");
|
|
11
|
+
const runtime_1 = require("../nerves/runtime");
|
|
12
|
+
/**
|
|
13
|
+
* Handle a Claude Code lifecycle hook event.
|
|
14
|
+
* Sends the event to the daemon and always exits 0 (hooks must not block the IDE).
|
|
15
|
+
*/
|
|
16
|
+
async function handleHookEvent(hookEvent) {
|
|
17
|
+
(0, runtime_1.emitNervesEvent)({
|
|
18
|
+
component: "daemon",
|
|
19
|
+
event: "daemon.hook_event_received",
|
|
20
|
+
message: "claude code hook event received",
|
|
21
|
+
meta: { hookEvent: hookEvent.event, sessionId: hookEvent.sessionId },
|
|
22
|
+
});
|
|
23
|
+
try {
|
|
24
|
+
await (0, socket_client_1.sendDaemonCommand)(socket_client_1.DEFAULT_DAEMON_SOCKET_PATH, {
|
|
25
|
+
kind: "hook.event",
|
|
26
|
+
event: hookEvent.event,
|
|
27
|
+
sessionId: hookEvent.sessionId,
|
|
28
|
+
toolName: hookEvent.toolName,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// Daemon unavailable — silently ignore. Hooks must not block.
|
|
33
|
+
(0, runtime_1.emitNervesEvent)({
|
|
34
|
+
component: "daemon",
|
|
35
|
+
event: "daemon.hook_event_daemon_unavailable",
|
|
36
|
+
message: "daemon unavailable for hook event",
|
|
37
|
+
meta: { hookEvent: hookEvent.event },
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return { exitCode: 0 };
|
|
41
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Claude Code stop hook — checks the agent's pending queue and returns
|
|
3
|
+
// any messages as additionalContext for injection into the next turn.
|
|
4
|
+
//
|
|
5
|
+
// This is how the agent can proactively communicate back to the dev tool user:
|
|
6
|
+
// the agent surfaces a message to the pending queue, and the stop hook picks
|
|
7
|
+
// it up and injects it as context in the Claude Code session.
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.handleStopHook = handleStopHook;
|
|
10
|
+
const pending_1 = require("../mind/pending");
|
|
11
|
+
const runtime_1 = require("../nerves/runtime");
|
|
12
|
+
/**
|
|
13
|
+
* Check the pending queue for messages from the agent to this dev tool session.
|
|
14
|
+
* Returns accumulated message text as additionalContext.
|
|
15
|
+
*/
|
|
16
|
+
async function handleStopHook(input) {
|
|
17
|
+
(0, runtime_1.emitNervesEvent)({
|
|
18
|
+
component: "daemon",
|
|
19
|
+
event: "daemon.stop_hook_check_start",
|
|
20
|
+
message: "checking pending queue for stop hook",
|
|
21
|
+
meta: { agentName: input.agentName, friendId: input.friendId, sessionId: input.sessionId },
|
|
22
|
+
});
|
|
23
|
+
try {
|
|
24
|
+
const pendingDir = (0, pending_1.getPendingDir)(input.agentName, input.friendId, "mcp", input.sessionId);
|
|
25
|
+
const pending = (0, pending_1.drainPending)(pendingDir);
|
|
26
|
+
if (pending.length === 0) {
|
|
27
|
+
return { additionalContext: "" };
|
|
28
|
+
}
|
|
29
|
+
const text = pending.map((m) => m.content).join("\n\n---\n\n");
|
|
30
|
+
(0, runtime_1.emitNervesEvent)({
|
|
31
|
+
component: "daemon",
|
|
32
|
+
event: "daemon.stop_hook_check_end",
|
|
33
|
+
message: "pending messages found for stop hook",
|
|
34
|
+
meta: { agentName: input.agentName, count: pending.length },
|
|
35
|
+
});
|
|
36
|
+
return { additionalContext: text };
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
(0, runtime_1.emitNervesEvent)({
|
|
40
|
+
component: "daemon",
|
|
41
|
+
event: "daemon.stop_hook_check_error",
|
|
42
|
+
message: "error checking pending queue in stop hook",
|
|
43
|
+
meta: { agentName: input.agentName },
|
|
44
|
+
});
|
|
45
|
+
return { additionalContext: "" };
|
|
46
|
+
}
|
|
47
|
+
}
|