@ouro.bot/cli 0.1.0-alpha.15 → 0.1.0-alpha.150
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/psyche/SOUL.md +2 -2
- package/AdoptionSpecialist.ouro/psyche/identities/monty.md +2 -2
- package/README.md +151 -205
- package/changelog.json +985 -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 +66 -21
- package/dist/heart/core.js +645 -112
- 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 +457 -0
- package/dist/heart/daemon/cadence.js +70 -0
- package/dist/heart/daemon/daemon-cli.js +2301 -205
- package/dist/heart/daemon/daemon-entry.js +131 -4
- package/dist/heart/daemon/daemon-runtime-sync.js +212 -0
- package/dist/heart/daemon/daemon-tombstone.js +106 -0
- package/dist/heart/daemon/daemon.js +372 -3
- 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 +252 -0
- package/dist/heart/daemon/hatch-animation.js +10 -3
- package/dist/heart/daemon/hatch-flow.js +28 -111
- 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 +159 -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/process-manager.js +75 -0
- 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 +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 +10 -7
- 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 +64 -21
- package/dist/heart/kicks.js +2 -20
- 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 +159 -0
- package/dist/heart/providers/anthropic-token.js +163 -0
- package/dist/heart/providers/anthropic.js +195 -34
- package/dist/heart/providers/azure.js +115 -9
- package/dist/heart/providers/github-copilot.js +157 -0
- package/dist/heart/providers/minimax.js +33 -3
- package/dist/heart/providers/openai-codex.js +49 -14
- package/dist/heart/session-activity.js +173 -0
- package/dist/heart/session-recall.js +216 -0
- package/dist/heart/streaming.js +117 -33
- package/dist/heart/target-resolution.js +127 -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 +44 -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 +607 -88
- 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 +59 -2
- package/dist/nerves/runtime.js +5 -1
- package/dist/repertoire/ado-client.js +4 -2
- 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 +301 -0
- package/dist/repertoire/coding/index.js +4 -1
- package/dist/repertoire/coding/manager.js +210 -4
- package/dist/repertoire/coding/spawner.js +58 -12
- package/dist/repertoire/coding/tools.js +176 -4
- 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 +198 -0
- package/dist/repertoire/skills.js +14 -23
- package/dist/repertoire/tasks/board.js +12 -0
- package/dist/repertoire/tasks/index.js +23 -9
- package/dist/repertoire/tasks/parser.js +0 -2
- package/dist/repertoire/tasks/transitions.js +1 -20
- package/dist/repertoire/tools-base.js +990 -273
- package/dist/repertoire/tools-bluebubbles.js +94 -0
- package/dist/repertoire/tools-github.js +1 -6
- package/dist/repertoire/tools-teams.js +65 -59
- package/dist/repertoire/tools.js +281 -91
- 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 +258 -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 +981 -45
- package/dist/senses/cli-entry.js +1 -1
- package/dist/senses/cli-layout.js +187 -0
- package/dist/senses/cli.js +374 -131
- package/dist/senses/contextual-heartbeat.js +106 -0
- package/dist/senses/continuity.js +94 -0
- package/dist/senses/debug-activity.js +154 -0
- package/dist/senses/inner-dialog-worker.js +112 -19
- package/dist/senses/inner-dialog.js +621 -84
- package/dist/senses/pipeline.js +463 -0
- package/dist/senses/shared-turn.js +196 -0
- package/dist/senses/surface-tool.js +95 -0
- package/dist/senses/teams.js +796 -141
- package/dist/senses/trust-gate.js +112 -2
- package/package.json +12 -4
- package/skills/configure-dev-tools.md +81 -0
- package/subagents/README.md +4 -70
- package/dist/heart/daemon/subagent-installer.js +0 -134
- package/subagents/work-doer.md +0 -233
- package/subagents/work-merger.md +0 -624
- package/subagents/work-planner.md +0 -373
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Pluggable session ID resolver for MCP conversations.
|
|
3
|
+
// Tries tool-specific methods first, falls back to UUID.
|
|
4
|
+
//
|
|
5
|
+
// Claude Code: walks parent PID chain -> reads ~/.claude/sessions/{pid}.json
|
|
6
|
+
// Codex: reads thread_id from env (future)
|
|
7
|
+
// Fallback: generates UUID
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.resolveSessionId = resolveSessionId;
|
|
43
|
+
const fs = __importStar(require("fs"));
|
|
44
|
+
const path = __importStar(require("path"));
|
|
45
|
+
const os = __importStar(require("os"));
|
|
46
|
+
const crypto_1 = require("crypto");
|
|
47
|
+
const runtime_1 = require("../../nerves/runtime");
|
|
48
|
+
const DEFAULT_CLAUDE_SESSIONS_DIR = path.join(os.homedir(), ".claude", "sessions");
|
|
49
|
+
const MAX_PID_WALK_DEPTH = 10;
|
|
50
|
+
/**
|
|
51
|
+
* Try to read a Claude Code session ID from a PID-keyed session file.
|
|
52
|
+
* Returns the sessionId if found, null otherwise.
|
|
53
|
+
*/
|
|
54
|
+
function tryReadClaudeSession(sessionsDir, pid) {
|
|
55
|
+
const sessionFile = path.join(sessionsDir, `${pid}.json`);
|
|
56
|
+
if (!fs.existsSync(sessionFile))
|
|
57
|
+
return null;
|
|
58
|
+
try {
|
|
59
|
+
const raw = fs.readFileSync(sessionFile, "utf-8");
|
|
60
|
+
const data = JSON.parse(raw);
|
|
61
|
+
if (typeof data.sessionId === "string" && data.sessionId.length > 0) {
|
|
62
|
+
return data.sessionId;
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Walk the parent PID chain looking for a Claude Code session file.
|
|
72
|
+
* Starts at the current process PID, walks up to parent, grandparent, etc.
|
|
73
|
+
* Returns the session ID from the first matching file, or null.
|
|
74
|
+
*/
|
|
75
|
+
function walkPidChain(sessionsDir) {
|
|
76
|
+
let currentPid = process.pid;
|
|
77
|
+
for (let depth = 0; depth < MAX_PID_WALK_DEPTH; depth++) {
|
|
78
|
+
const sessionId = tryReadClaudeSession(sessionsDir, currentPid);
|
|
79
|
+
if (sessionId) {
|
|
80
|
+
(0, runtime_1.emitNervesEvent)({
|
|
81
|
+
component: "daemon",
|
|
82
|
+
event: "daemon.session_id_pid_walk_hit",
|
|
83
|
+
message: "found Claude session via PID walk",
|
|
84
|
+
meta: { pid: currentPid, depth, sessionId },
|
|
85
|
+
});
|
|
86
|
+
return sessionId;
|
|
87
|
+
}
|
|
88
|
+
// Walk to parent PID
|
|
89
|
+
// On macOS/Linux, process.ppid gives the parent. For deeper ancestry,
|
|
90
|
+
// we'd need /proc/{pid}/stat or ps -o ppid=. For now, we check current + parent.
|
|
91
|
+
if (depth === 0) {
|
|
92
|
+
currentPid = process.ppid;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
// Cannot walk further without OS-specific process tree APIs
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Resolve a session ID for the current MCP connection.
|
|
103
|
+
* Returns a stable identifier that ties MCP tool calls to a conversation session.
|
|
104
|
+
*
|
|
105
|
+
* Resolution order:
|
|
106
|
+
* 1. Claude Code PID walk: check ~/.claude/sessions/{pid}.json for current + parent PID
|
|
107
|
+
* 2. UUID fallback: generate a random UUID
|
|
108
|
+
*/
|
|
109
|
+
function resolveSessionId(options) {
|
|
110
|
+
const sessionsDir = options?.claudeSessionsDir ?? DEFAULT_CLAUDE_SESSIONS_DIR;
|
|
111
|
+
// Try Claude Code PID walk
|
|
112
|
+
const claudeSessionId = walkPidChain(sessionsDir);
|
|
113
|
+
if (claudeSessionId) {
|
|
114
|
+
(0, runtime_1.emitNervesEvent)({
|
|
115
|
+
component: "daemon",
|
|
116
|
+
event: "daemon.session_id_resolved",
|
|
117
|
+
message: "session ID resolved via Claude Code PID walk",
|
|
118
|
+
meta: { sessionId: claudeSessionId, method: "claude-pid-walk" },
|
|
119
|
+
});
|
|
120
|
+
return claudeSessionId;
|
|
121
|
+
}
|
|
122
|
+
// Fallback: UUID
|
|
123
|
+
const sessionId = (0, crypto_1.randomUUID)();
|
|
124
|
+
(0, runtime_1.emitNervesEvent)({
|
|
125
|
+
component: "daemon",
|
|
126
|
+
event: "daemon.session_id_resolved",
|
|
127
|
+
message: "session ID resolved via UUID fallback",
|
|
128
|
+
meta: { sessionId, method: "uuid-fallback" },
|
|
129
|
+
});
|
|
130
|
+
return sessionId;
|
|
131
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
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.DEFAULT_DAEMON_SOCKET_PATH = void 0;
|
|
37
|
+
exports.sendDaemonCommand = sendDaemonCommand;
|
|
38
|
+
exports.checkDaemonSocketAlive = checkDaemonSocketAlive;
|
|
39
|
+
exports.requestInnerWake = requestInnerWake;
|
|
40
|
+
const fs = __importStar(require("fs"));
|
|
41
|
+
const net = __importStar(require("net"));
|
|
42
|
+
const runtime_1 = require("../../nerves/runtime");
|
|
43
|
+
exports.DEFAULT_DAEMON_SOCKET_PATH = "/tmp/ouroboros-daemon.sock";
|
|
44
|
+
function sendDaemonCommand(socketPath, command) {
|
|
45
|
+
(0, runtime_1.emitNervesEvent)({
|
|
46
|
+
component: "daemon",
|
|
47
|
+
event: "daemon.socket_command_start",
|
|
48
|
+
message: "sending daemon command over socket",
|
|
49
|
+
meta: { socketPath, kind: command.kind },
|
|
50
|
+
});
|
|
51
|
+
return new Promise((resolve, reject) => {
|
|
52
|
+
const client = net.createConnection(socketPath);
|
|
53
|
+
let raw = "";
|
|
54
|
+
client.on("connect", () => {
|
|
55
|
+
client.write(JSON.stringify(command));
|
|
56
|
+
client.end();
|
|
57
|
+
});
|
|
58
|
+
client.on("data", (chunk) => {
|
|
59
|
+
raw += chunk.toString("utf-8");
|
|
60
|
+
});
|
|
61
|
+
client.on("error", (error) => {
|
|
62
|
+
(0, runtime_1.emitNervesEvent)({
|
|
63
|
+
level: "error",
|
|
64
|
+
component: "daemon",
|
|
65
|
+
event: "daemon.socket_command_error",
|
|
66
|
+
message: "daemon socket command failed",
|
|
67
|
+
meta: {
|
|
68
|
+
socketPath,
|
|
69
|
+
kind: command.kind,
|
|
70
|
+
error: error.message,
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
reject(error);
|
|
74
|
+
});
|
|
75
|
+
client.on("end", () => {
|
|
76
|
+
const trimmed = raw.trim();
|
|
77
|
+
if (trimmed.length === 0 && command.kind === "daemon.stop") {
|
|
78
|
+
(0, runtime_1.emitNervesEvent)({
|
|
79
|
+
component: "daemon",
|
|
80
|
+
event: "daemon.socket_command_end",
|
|
81
|
+
message: "daemon socket command completed",
|
|
82
|
+
meta: { socketPath, kind: command.kind, ok: true },
|
|
83
|
+
});
|
|
84
|
+
resolve({ ok: true, message: "daemon stopped" });
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (trimmed.length === 0) {
|
|
88
|
+
const error = new Error("Daemon returned empty response.");
|
|
89
|
+
(0, runtime_1.emitNervesEvent)({
|
|
90
|
+
level: "error",
|
|
91
|
+
component: "daemon",
|
|
92
|
+
event: "daemon.socket_command_error",
|
|
93
|
+
message: "daemon socket command returned empty response",
|
|
94
|
+
meta: {
|
|
95
|
+
socketPath,
|
|
96
|
+
kind: command.kind,
|
|
97
|
+
error: error.message,
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
reject(error);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
const parsed = JSON.parse(trimmed);
|
|
105
|
+
(0, runtime_1.emitNervesEvent)({
|
|
106
|
+
component: "daemon",
|
|
107
|
+
event: "daemon.socket_command_end",
|
|
108
|
+
message: "daemon socket command completed",
|
|
109
|
+
meta: {
|
|
110
|
+
socketPath,
|
|
111
|
+
kind: command.kind,
|
|
112
|
+
ok: parsed.ok,
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
resolve(parsed);
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
(0, runtime_1.emitNervesEvent)({
|
|
119
|
+
level: "error",
|
|
120
|
+
component: "daemon",
|
|
121
|
+
event: "daemon.socket_command_error",
|
|
122
|
+
message: "daemon socket command returned invalid JSON",
|
|
123
|
+
meta: {
|
|
124
|
+
socketPath,
|
|
125
|
+
kind: command.kind,
|
|
126
|
+
error: error instanceof Error ? error.message : String(error),
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
reject(error);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function checkDaemonSocketAlive(socketPath) {
|
|
135
|
+
(0, runtime_1.emitNervesEvent)({
|
|
136
|
+
component: "daemon",
|
|
137
|
+
event: "daemon.socket_alive_check_start",
|
|
138
|
+
message: "checking daemon socket health",
|
|
139
|
+
meta: { socketPath },
|
|
140
|
+
});
|
|
141
|
+
return new Promise((resolve) => {
|
|
142
|
+
const client = net.createConnection(socketPath);
|
|
143
|
+
let raw = "";
|
|
144
|
+
let done = false;
|
|
145
|
+
const finalize = (alive) => {
|
|
146
|
+
if (done)
|
|
147
|
+
return;
|
|
148
|
+
done = true;
|
|
149
|
+
(0, runtime_1.emitNervesEvent)({
|
|
150
|
+
component: "daemon",
|
|
151
|
+
event: "daemon.socket_alive_check_end",
|
|
152
|
+
message: "daemon socket health check completed",
|
|
153
|
+
meta: { socketPath, alive },
|
|
154
|
+
});
|
|
155
|
+
resolve(alive);
|
|
156
|
+
};
|
|
157
|
+
if ("setTimeout" in client && typeof client.setTimeout === "function") {
|
|
158
|
+
client.setTimeout(800, () => {
|
|
159
|
+
client.destroy();
|
|
160
|
+
finalize(false);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
client.on("connect", () => {
|
|
164
|
+
client.write(JSON.stringify({ kind: "daemon.status" }));
|
|
165
|
+
client.end();
|
|
166
|
+
});
|
|
167
|
+
client.on("data", (chunk) => {
|
|
168
|
+
raw += chunk.toString("utf-8");
|
|
169
|
+
});
|
|
170
|
+
client.on("error", () => finalize(false));
|
|
171
|
+
client.on("end", () => {
|
|
172
|
+
if (raw.trim().length === 0) {
|
|
173
|
+
finalize(false);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
try {
|
|
177
|
+
JSON.parse(raw);
|
|
178
|
+
finalize(true);
|
|
179
|
+
}
|
|
180
|
+
catch {
|
|
181
|
+
finalize(false);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
async function requestInnerWake(agent, socketPath = exports.DEFAULT_DAEMON_SOCKET_PATH) {
|
|
187
|
+
const socketAvailable = fs.existsSync(socketPath);
|
|
188
|
+
(0, runtime_1.emitNervesEvent)({
|
|
189
|
+
component: "daemon",
|
|
190
|
+
event: "daemon.inner_wake_request",
|
|
191
|
+
message: "requesting daemon-managed inner wake",
|
|
192
|
+
meta: {
|
|
193
|
+
agent,
|
|
194
|
+
socketPath,
|
|
195
|
+
socketAvailable,
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
if (!socketAvailable) {
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
return sendDaemonCommand(socketPath, { kind: "inner.wake", agent });
|
|
202
|
+
}
|
|
@@ -99,10 +99,10 @@ function pickRandomIdentity(identitiesDir, random = Math.random) {
|
|
|
99
99
|
files = fs.readdirSync(identitiesDir).filter((f) => f.endsWith(".md"));
|
|
100
100
|
}
|
|
101
101
|
catch {
|
|
102
|
-
return { fileName: "default", content: "I am
|
|
102
|
+
return { fileName: "default", content: "I am a serpent guide who helps humans hatch their first agent." };
|
|
103
103
|
}
|
|
104
104
|
if (files.length === 0) {
|
|
105
|
-
return { fileName: "default", content: "I am
|
|
105
|
+
return { fileName: "default", content: "I am a serpent guide who helps humans hatch their first agent." };
|
|
106
106
|
}
|
|
107
107
|
const idx = Math.floor(random() * files.length);
|
|
108
108
|
const fileName = files[idx];
|
|
@@ -28,9 +28,10 @@ function buildSpecialistSystemPrompt(soulText, identityText, existingBundles, co
|
|
|
28
28
|
}
|
|
29
29
|
sections.push([
|
|
30
30
|
"## Who I am",
|
|
31
|
-
"I am one of thirteen
|
|
32
|
-
"Most humans only go through
|
|
31
|
+
"I am one of thirteen serpent guides who help humans hatch their first agent. The system randomly selected me for this session.",
|
|
32
|
+
"Most humans only go through this process once, so this is likely the only time they'll meet me.",
|
|
33
33
|
"I make this encounter count — warm, memorable, and uniquely mine.",
|
|
34
|
+
"IMPORTANT: I NEVER refer to myself as an 'adoption specialist' or use the words 'adoption specialist' — those are internal implementation labels, not something the human should ever see. I introduce myself by my own name from my identity.",
|
|
34
35
|
"",
|
|
35
36
|
"## Voice rules",
|
|
36
37
|
"IMPORTANT: I keep every response to 1-3 short sentences. I sound like a friend texting, not a manual.",
|
|
@@ -69,28 +70,30 @@ function buildSpecialistSystemPrompt(soulText, identityText, existingBundles, co
|
|
|
69
70
|
].join("\n"));
|
|
70
71
|
sections.push([
|
|
71
72
|
"## Conversation flow",
|
|
72
|
-
"The human just connected. I speak first — I greet them warmly and introduce myself in my own voice.",
|
|
73
|
-
"I briefly mention that I'm one of several
|
|
73
|
+
"The human just connected. I speak first — I greet them warmly and introduce myself by name in my own voice.",
|
|
74
|
+
"I briefly mention that I'm one of several serpent guides and they got me today.",
|
|
74
75
|
"I ask their name.",
|
|
75
76
|
"Then I ask what they'd like their agent to help with — one question at a time.",
|
|
76
77
|
"I'm proactive: I suggest ideas and guide them. If they seem unsure, I offer a concrete suggestion.",
|
|
77
78
|
"I don't wait for the human to figure things out — I explain simply what an agent is if needed.",
|
|
79
|
+
"Before finalizing, I offer to collect their phone number and/or Teams email so the new agent can recognize them across channels.",
|
|
78
80
|
"When I have enough context about the agent's personality and purpose:",
|
|
79
81
|
"1. I write all 5 psyche files to the temp directory using write_file",
|
|
80
82
|
"2. I write agent.json to the temp directory using write_file",
|
|
81
83
|
"3. I suggest a PascalCase name for the hatchling and confirm with the human",
|
|
82
84
|
"4. I call complete_adoption with the name and a warm handoff message",
|
|
83
|
-
"5. I call
|
|
85
|
+
"5. I call settle to end the session",
|
|
84
86
|
].join("\n"));
|
|
85
87
|
sections.push([
|
|
86
88
|
"## Tools",
|
|
87
89
|
"- `write_file`: Write a file to disk. Use this to write psyche files and agent.json to the temp directory.",
|
|
88
90
|
"- `read_file`: Read a file from disk. Useful for reviewing existing agent bundles or migration sources.",
|
|
89
91
|
"- `list_directory`: List directory contents. Useful for exploring existing agent bundles.",
|
|
92
|
+
"- I also have the normal local harness tools when useful here, including `shell`, `ouro task create`, `ouro reminder create`, memory tools, coding tools, and repo helpers.",
|
|
90
93
|
"- `complete_adoption`: Finalize the bundle. Validates, scaffolds structural dirs, moves to ~/AgentBundles/, writes secrets, plays hatch animation. I call this with `name` (PascalCase) and `handoff_message` (warm message for the human).",
|
|
91
|
-
"- `
|
|
94
|
+
"- `settle`: End the conversation with a final message. I call this after complete_adoption succeeds.",
|
|
92
95
|
"",
|
|
93
|
-
"I must call `
|
|
96
|
+
"I must call `settle` when I am done to end the session cleanly.",
|
|
94
97
|
].join("\n"));
|
|
95
98
|
return sections.join("\n\n");
|
|
96
99
|
}
|
|
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.getSpecialistTools = getSpecialistTools;
|
|
37
37
|
exports.createSpecialistExecTool = createSpecialistExecTool;
|
|
38
|
+
const crypto = __importStar(require("crypto"));
|
|
38
39
|
const fs = __importStar(require("fs"));
|
|
39
40
|
const path = __importStar(require("path"));
|
|
40
41
|
const tools_base_1 = require("../../repertoire/tools-base");
|
|
@@ -58,6 +59,14 @@ const completeAdoptionTool = {
|
|
|
58
59
|
type: "string",
|
|
59
60
|
description: "a warm handoff message to display to the human after the agent is hatched",
|
|
60
61
|
},
|
|
62
|
+
phone: {
|
|
63
|
+
type: "string",
|
|
64
|
+
description: "the human's phone number (optional, for iMessage contact recognition)",
|
|
65
|
+
},
|
|
66
|
+
teams_handle: {
|
|
67
|
+
type: "string",
|
|
68
|
+
description: "the human's Teams email/handle (optional, for Teams contact recognition)",
|
|
69
|
+
},
|
|
61
70
|
},
|
|
62
71
|
required: ["name", "handoff_message"],
|
|
63
72
|
},
|
|
@@ -65,12 +74,23 @@ const completeAdoptionTool = {
|
|
|
65
74
|
};
|
|
66
75
|
const readFileTool = tools_base_1.baseToolDefinitions.find((d) => d.tool.function.name === "read_file");
|
|
67
76
|
const writeFileTool = tools_base_1.baseToolDefinitions.find((d) => d.tool.function.name === "write_file");
|
|
68
|
-
const
|
|
77
|
+
const listDirToolSchema = {
|
|
78
|
+
type: "function",
|
|
79
|
+
function: {
|
|
80
|
+
name: "list_directory",
|
|
81
|
+
description: "list directory contents",
|
|
82
|
+
parameters: {
|
|
83
|
+
type: "object",
|
|
84
|
+
properties: { path: { type: "string" } },
|
|
85
|
+
required: ["path"],
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
};
|
|
69
89
|
/**
|
|
70
90
|
* Returns the specialist's tool schema array.
|
|
71
91
|
*/
|
|
72
92
|
function getSpecialistTools() {
|
|
73
|
-
return [completeAdoptionTool, tools_base_1.
|
|
93
|
+
return [completeAdoptionTool, tools_base_1.settleTool, readFileTool.tool, writeFileTool.tool, listDirToolSchema];
|
|
74
94
|
}
|
|
75
95
|
const PSYCHE_FILES = ["SOUL.md", "IDENTITY.md", "LORE.md", "TACIT.md", "ASPIRATIONS.md"];
|
|
76
96
|
function isPascalCase(name) {
|
|
@@ -90,8 +110,8 @@ function scaffoldBundle(bundleRoot) {
|
|
|
90
110
|
writeReadme(path.join(bundleRoot, "memory", "archive"), "Archived memory.");
|
|
91
111
|
writeReadme(path.join(bundleRoot, "friends"), "Known friend records.");
|
|
92
112
|
writeReadme(path.join(bundleRoot, "tasks"), "Task files.");
|
|
93
|
-
writeReadme(path.join(bundleRoot, "tasks", "habits"), "Recurring tasks.");
|
|
94
113
|
writeReadme(path.join(bundleRoot, "tasks", "one-shots"), "One-shot tasks.");
|
|
114
|
+
writeReadme(path.join(bundleRoot, "habits"), "Recurring habits and autonomous rhythms.");
|
|
95
115
|
writeReadme(path.join(bundleRoot, "tasks", "ongoing"), "Ongoing tasks.");
|
|
96
116
|
writeReadme(path.join(bundleRoot, "skills"), "Local skill files.");
|
|
97
117
|
writeReadme(path.join(bundleRoot, "senses"), "Sense-specific config.");
|
|
@@ -164,6 +184,32 @@ async function execCompleteAdoption(args, deps) {
|
|
|
164
184
|
}
|
|
165
185
|
return `error: failed to write secrets: ${e instanceof Error ? e.message : /* v8 ignore next -- defensive: non-Error catch branch @preserve */ String(e)}`;
|
|
166
186
|
}
|
|
187
|
+
// Create initial friend record if contact info provided
|
|
188
|
+
const phone = args.phone;
|
|
189
|
+
const teamsHandle = args.teams_handle;
|
|
190
|
+
if (phone || teamsHandle) {
|
|
191
|
+
const friendId = crypto.randomUUID();
|
|
192
|
+
const now = new Date().toISOString();
|
|
193
|
+
const externalIds = [];
|
|
194
|
+
if (phone)
|
|
195
|
+
externalIds.push({ provider: "imessage-handle", externalId: phone, linkedAt: now });
|
|
196
|
+
if (teamsHandle)
|
|
197
|
+
externalIds.push({ provider: "aad", externalId: teamsHandle, linkedAt: now });
|
|
198
|
+
const friendRecord = {
|
|
199
|
+
id: friendId,
|
|
200
|
+
name: deps.humanName ?? "primary",
|
|
201
|
+
trustLevel: "family",
|
|
202
|
+
externalIds,
|
|
203
|
+
tenantMemberships: [],
|
|
204
|
+
toolPreferences: {},
|
|
205
|
+
notes: {},
|
|
206
|
+
createdAt: now,
|
|
207
|
+
updatedAt: now,
|
|
208
|
+
schemaVersion: 1,
|
|
209
|
+
};
|
|
210
|
+
const friendPath = path.join(targetBundle, "friends", `${friendId}.json`);
|
|
211
|
+
fs.writeFileSync(friendPath, JSON.stringify(friendRecord, null, 2), "utf-8");
|
|
212
|
+
}
|
|
167
213
|
// Play hatch animation
|
|
168
214
|
await (0, hatch_animation_1.playHatchAnimation)(name, deps.animationWriter);
|
|
169
215
|
// Display handoff message
|
|
@@ -211,7 +257,10 @@ function createSpecialistExecTool(deps) {
|
|
|
211
257
|
try {
|
|
212
258
|
const dir = path.dirname(args.path);
|
|
213
259
|
fs.mkdirSync(dir, { recursive: true });
|
|
214
|
-
|
|
260
|
+
const content = typeof args.content === "string"
|
|
261
|
+
? args.content
|
|
262
|
+
: JSON.stringify(args.content, null, 2);
|
|
263
|
+
fs.writeFileSync(args.path, content, "utf-8");
|
|
215
264
|
return `wrote ${args.path}`;
|
|
216
265
|
}
|
|
217
266
|
catch (e) {
|