@ouro.bot/cli 0.1.0-alpha.2 → 0.1.0-alpha.200
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/SerpentGuide.ouro/agent.json +82 -0
- package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/SOUL.md +6 -3
- package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/monty.md +2 -2
- package/assets/ouroboros.png +0 -0
- package/changelog.json +1248 -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 +179 -0
- package/dist/heart/commitments.js +111 -0
- package/dist/heart/config.js +114 -28
- package/dist/heart/core.js +689 -120
- package/dist/heart/cross-chat-delivery.js +146 -0
- package/dist/heart/daemon/agent-config-check.js +149 -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 +2897 -193
- package/dist/heart/daemon/daemon-entry.js +194 -8
- package/dist/heart/daemon/daemon-health.js +136 -0
- package/dist/heart/daemon/daemon-runtime-sync.js +231 -0
- package/dist/heart/daemon/daemon-tombstone.js +123 -0
- package/dist/heart/daemon/daemon.js +488 -13
- 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 +35 -0
- package/dist/heart/daemon/hatch-flow.js +32 -122
- package/dist/heart/daemon/hatch-specialist.js +7 -2
- package/dist/heart/daemon/hooks/agent-config-v2.js +33 -0
- package/dist/heart/daemon/hooks/bundle-meta.js +206 -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-bot-wrapper.js +4 -3
- package/dist/heart/daemon/ouro-path-installer.js +221 -0
- package/dist/heart/daemon/ouro-uti.js +11 -2
- package/dist/heart/daemon/ouro-version-manager.js +171 -0
- package/dist/heart/daemon/outlook-http.js +439 -0
- package/dist/heart/daemon/outlook-read.js +1618 -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 +94 -1
- package/dist/heart/daemon/run-hooks.js +39 -0
- package/dist/heart/daemon/runtime-logging.js +61 -14
- 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 +314 -0
- 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 +129 -0
- package/dist/heart/daemon/specialist-prompt.js +101 -0
- package/dist/heart/daemon/specialist-tools.js +283 -0
- package/dist/heart/daemon/staged-restart.js +138 -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 +220 -52
- package/dist/heart/intentions.js +173 -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 +225 -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 +178 -0
- package/dist/heart/providers/anthropic-token.js +163 -0
- package/dist/heart/providers/anthropic.js +199 -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/sense-truth.js +61 -0
- package/dist/heart/session-activity.js +172 -0
- package/dist/heart/session-recall.js +216 -0
- package/dist/heart/start-of-turn-packet.js +232 -0
- package/dist/heart/streaming.js +120 -33
- package/dist/heart/sync.js +217 -0
- 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/mind/associative-recall.js +122 -32
- package/dist/mind/bundle-manifest.js +77 -1
- package/dist/mind/context.js +125 -14
- package/dist/mind/{memory.js → diary.js} +69 -56
- package/dist/mind/episodes.js +119 -0
- package/dist/mind/file-state.js +179 -0
- package/dist/mind/first-impressions.js +16 -2
- package/dist/mind/friends/channel.js +64 -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 +9 -1
- package/dist/mind/journal-index.js +161 -0
- package/dist/mind/obligation-steering.js +221 -0
- package/dist/mind/obligations.js +138 -0
- package/dist/mind/pending.js +76 -9
- package/dist/mind/phrases.js +1 -0
- package/dist/mind/prompt.js +861 -105
- package/dist/mind/scrutiny.js +173 -0
- package/dist/mind/token-estimate.js +8 -12
- package/dist/nerves/cli-logging.js +15 -2
- 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-Ck8agNeO.js +61 -0
- package/dist/outlook-ui/assets/index-LwChZTgL.css +1 -0
- package/dist/outlook-ui/index.html +15 -0
- package/dist/repertoire/ado-client.js +4 -2
- 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 +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 +209 -7
- package/dist/repertoire/data/ado-endpoints.json +188 -0
- package/dist/repertoire/guardrails.js +291 -0
- package/dist/repertoire/mcp-client.js +254 -0
- package/dist/repertoire/mcp-manager.js +251 -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 +1360 -271
- 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 +318 -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 +532 -0
- package/dist/senses/bluebubbles-entry.js +13 -0
- package/dist/senses/bluebubbles-inbound-log.js +109 -0
- package/dist/senses/bluebubbles-media.js +339 -0
- package/dist/senses/bluebubbles-model.js +261 -0
- package/dist/senses/bluebubbles-mutation-log.js +116 -0
- package/dist/senses/bluebubbles-runtime-state.js +109 -0
- package/dist/senses/bluebubbles-session-cleanup.js +72 -0
- package/dist/senses/bluebubbles.js +1327 -0
- 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 +687 -262
- 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 +693 -0
- package/dist/senses/shared-turn.js +196 -0
- package/dist/senses/surface-tool.js +95 -0
- package/dist/senses/teams.js +817 -151
- package/dist/senses/trust-gate.js +112 -2
- package/package.json +24 -7
- package/skills/configure-dev-tools.md +81 -0
- package/subagents/README.md +4 -70
- package/AdoptionSpecialist.ouro/agent.json +0 -20
- package/dist/heart/daemon/subagent-installer.js +0 -125
- package/dist/inner-worker-entry.js +0 -4
- package/subagents/work-doer.md +0 -233
- package/subagents/work-merger.md +0 -624
- package/subagents/work-planner.md +0 -373
- /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/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
|
@@ -0,0 +1,138 @@
|
|
|
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.registerUpdateHook = registerUpdateHook;
|
|
37
|
+
exports.getRegisteredHooks = getRegisteredHooks;
|
|
38
|
+
exports.clearRegisteredHooks = clearRegisteredHooks;
|
|
39
|
+
exports.applyPendingUpdates = applyPendingUpdates;
|
|
40
|
+
const fs = __importStar(require("fs"));
|
|
41
|
+
const path = __importStar(require("path"));
|
|
42
|
+
const semver = __importStar(require("semver"));
|
|
43
|
+
const runtime_1 = require("../../nerves/runtime");
|
|
44
|
+
const _hooks = [];
|
|
45
|
+
function registerUpdateHook(hook) {
|
|
46
|
+
_hooks.push(hook);
|
|
47
|
+
(0, runtime_1.emitNervesEvent)({
|
|
48
|
+
component: "daemon",
|
|
49
|
+
event: "daemon.update_hook_registered",
|
|
50
|
+
message: "registered update hook",
|
|
51
|
+
meta: {},
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function getRegisteredHooks() {
|
|
55
|
+
return _hooks;
|
|
56
|
+
}
|
|
57
|
+
function clearRegisteredHooks() {
|
|
58
|
+
_hooks.length = 0;
|
|
59
|
+
}
|
|
60
|
+
async function applyPendingUpdates(bundlesRoot, currentVersion) {
|
|
61
|
+
const summary = { updated: [] };
|
|
62
|
+
(0, runtime_1.emitNervesEvent)({
|
|
63
|
+
component: "daemon",
|
|
64
|
+
event: "daemon.apply_pending_updates_start",
|
|
65
|
+
message: "applying pending updates",
|
|
66
|
+
meta: { bundlesRoot, currentVersion },
|
|
67
|
+
});
|
|
68
|
+
if (!fs.existsSync(bundlesRoot)) {
|
|
69
|
+
return summary;
|
|
70
|
+
}
|
|
71
|
+
let entries;
|
|
72
|
+
try {
|
|
73
|
+
entries = fs.readdirSync(bundlesRoot, { withFileTypes: true });
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return summary;
|
|
77
|
+
}
|
|
78
|
+
for (const entry of entries) {
|
|
79
|
+
if (!entry.isDirectory() || !entry.name.endsWith(".ouro"))
|
|
80
|
+
continue;
|
|
81
|
+
const agentRoot = path.join(bundlesRoot, entry.name);
|
|
82
|
+
let previousVersion;
|
|
83
|
+
const metaPath = path.join(agentRoot, "bundle-meta.json");
|
|
84
|
+
try {
|
|
85
|
+
if (fs.existsSync(metaPath)) {
|
|
86
|
+
const raw = fs.readFileSync(metaPath, "utf-8");
|
|
87
|
+
const meta = JSON.parse(raw);
|
|
88
|
+
previousVersion = meta.runtimeVersion;
|
|
89
|
+
if (previousVersion === currentVersion) {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
// Skip downgrades — only update forward
|
|
93
|
+
if (semver.valid(previousVersion) && semver.valid(currentVersion) && semver.gte(previousVersion, currentVersion)) {
|
|
94
|
+
(0, runtime_1.emitNervesEvent)({
|
|
95
|
+
component: "daemon",
|
|
96
|
+
event: "daemon.update_hook_skip_downgrade",
|
|
97
|
+
message: "skipping downgrade",
|
|
98
|
+
meta: { agentRoot, previousVersion, currentVersion },
|
|
99
|
+
});
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
// Malformed or unreadable bundle-meta.json -- treat as needing update
|
|
106
|
+
previousVersion = undefined;
|
|
107
|
+
}
|
|
108
|
+
const ctx = { agentRoot, currentVersion, previousVersion };
|
|
109
|
+
for (const hook of _hooks) {
|
|
110
|
+
try {
|
|
111
|
+
await hook(ctx);
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
(0, runtime_1.emitNervesEvent)({
|
|
115
|
+
component: "daemon",
|
|
116
|
+
event: "daemon.update_hook_error",
|
|
117
|
+
message: "update hook threw",
|
|
118
|
+
meta: {
|
|
119
|
+
agentRoot,
|
|
120
|
+
error: err instanceof Error ? err.message : /* v8 ignore next -- defensive: non-Error catch branch @preserve */ String(err),
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
summary.updated.push({
|
|
126
|
+
agent: entry.name.replace(/\.ouro$/, ""),
|
|
127
|
+
from: previousVersion,
|
|
128
|
+
to: currentVersion,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
(0, runtime_1.emitNervesEvent)({
|
|
132
|
+
component: "daemon",
|
|
133
|
+
event: "daemon.apply_pending_updates_end",
|
|
134
|
+
message: "pending updates applied",
|
|
135
|
+
meta: { bundlesRoot },
|
|
136
|
+
});
|
|
137
|
+
return summary;
|
|
138
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assessWrapperPublishSync = assessWrapperPublishSync;
|
|
4
|
+
const runtime_1 = require("../../nerves/runtime");
|
|
5
|
+
function wrapperPackageChanged(changedFiles) {
|
|
6
|
+
return changedFiles.some((file) => file.startsWith("packages/ouro.bot/"));
|
|
7
|
+
}
|
|
8
|
+
function assessWrapperPublishSync(input) {
|
|
9
|
+
let result;
|
|
10
|
+
if (input.localVersion !== input.cliVersion) {
|
|
11
|
+
result = {
|
|
12
|
+
ok: false,
|
|
13
|
+
message: `ouro.bot wrapper version ${input.localVersion} must match @ouro.bot/cli version ${input.cliVersion}`,
|
|
14
|
+
};
|
|
15
|
+
(0, runtime_1.emitNervesEvent)({
|
|
16
|
+
level: "warn",
|
|
17
|
+
component: "daemon",
|
|
18
|
+
event: "daemon.wrapper_publish_guard_checked",
|
|
19
|
+
message: "evaluated wrapper publish sync",
|
|
20
|
+
meta: {
|
|
21
|
+
changed: wrapperPackageChanged(input.changedFiles),
|
|
22
|
+
localVersion: input.localVersion,
|
|
23
|
+
cliVersion: input.cliVersion,
|
|
24
|
+
publishedVersion: input.publishedVersion,
|
|
25
|
+
ok: result.ok,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
if (!wrapperPackageChanged(input.changedFiles)) {
|
|
31
|
+
result = {
|
|
32
|
+
ok: true,
|
|
33
|
+
message: "wrapper package unchanged",
|
|
34
|
+
};
|
|
35
|
+
(0, runtime_1.emitNervesEvent)({
|
|
36
|
+
component: "daemon",
|
|
37
|
+
event: "daemon.wrapper_publish_guard_checked",
|
|
38
|
+
message: "evaluated wrapper publish sync",
|
|
39
|
+
meta: {
|
|
40
|
+
changed: false,
|
|
41
|
+
localVersion: input.localVersion,
|
|
42
|
+
cliVersion: input.cliVersion,
|
|
43
|
+
publishedVersion: input.publishedVersion,
|
|
44
|
+
ok: result.ok,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
if (input.publishedVersion === input.localVersion) {
|
|
50
|
+
result = {
|
|
51
|
+
ok: false,
|
|
52
|
+
message: `ouro.bot wrapper changed but ouro.bot@${input.localVersion} is already published; bump packages/ouro.bot/package.json before merging`,
|
|
53
|
+
};
|
|
54
|
+
(0, runtime_1.emitNervesEvent)({
|
|
55
|
+
level: "warn",
|
|
56
|
+
component: "daemon",
|
|
57
|
+
event: "daemon.wrapper_publish_guard_checked",
|
|
58
|
+
message: "evaluated wrapper publish sync",
|
|
59
|
+
meta: {
|
|
60
|
+
changed: true,
|
|
61
|
+
localVersion: input.localVersion,
|
|
62
|
+
cliVersion: input.cliVersion,
|
|
63
|
+
publishedVersion: input.publishedVersion,
|
|
64
|
+
ok: result.ok,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
result = {
|
|
70
|
+
ok: true,
|
|
71
|
+
message: "wrapper package changed and local wrapper version is unpublished",
|
|
72
|
+
};
|
|
73
|
+
(0, runtime_1.emitNervesEvent)({
|
|
74
|
+
component: "daemon",
|
|
75
|
+
event: "daemon.wrapper_publish_guard_checked",
|
|
76
|
+
message: "evaluated wrapper publish sync",
|
|
77
|
+
meta: {
|
|
78
|
+
changed: true,
|
|
79
|
+
localVersion: input.localVersion,
|
|
80
|
+
cliVersion: input.cliVersion,
|
|
81
|
+
publishedVersion: input.publishedVersion,
|
|
82
|
+
ok: result.ok,
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decideDelegation = decideDelegation;
|
|
4
|
+
const runtime_1 = require("../nerves/runtime");
|
|
5
|
+
const CROSS_SESSION_TOOLS = new Set(["query_session", "send_message", "bridge_manage"]);
|
|
6
|
+
const FAST_PATH_TOOLS = new Set(["settle"]);
|
|
7
|
+
const REFLECTION_PATTERN = /\b(think|reflect|ponder|surface|surfaces|surfaced|sit with|metaboli[sz]e)\b/i;
|
|
8
|
+
const CROSS_SESSION_PATTERN = /\b(other chat|other session|across chats?|across sessions?|keep .* aligned|relay|carry .* across)\b/i;
|
|
9
|
+
function hasExplicitReflection(ingressTexts) {
|
|
10
|
+
return ingressTexts.some((text) => REFLECTION_PATTERN.test(text));
|
|
11
|
+
}
|
|
12
|
+
function hasCrossSessionPressure(ingressTexts, requestedToolNames) {
|
|
13
|
+
if (requestedToolNames.some((name) => CROSS_SESSION_TOOLS.has(name))) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
return ingressTexts.some((text) => CROSS_SESSION_PATTERN.test(text));
|
|
17
|
+
}
|
|
18
|
+
function hasNonFastPathToolRequest(requestedToolNames) {
|
|
19
|
+
return requestedToolNames.some((name) => !FAST_PATH_TOOLS.has(name));
|
|
20
|
+
}
|
|
21
|
+
function decideDelegation(input) {
|
|
22
|
+
const requestedToolNames = (input.requestedToolNames ?? [])
|
|
23
|
+
.map((name) => name.trim())
|
|
24
|
+
.filter((name) => name.length > 0);
|
|
25
|
+
const reasons = [];
|
|
26
|
+
if (hasExplicitReflection(input.ingressTexts)) {
|
|
27
|
+
reasons.push("explicit_reflection");
|
|
28
|
+
}
|
|
29
|
+
if (hasCrossSessionPressure(input.ingressTexts, requestedToolNames)) {
|
|
30
|
+
reasons.push("cross_session");
|
|
31
|
+
}
|
|
32
|
+
if (input.activeWork.centerOfGravity === "shared-work" || input.activeWork.bridges.some((bridge) => bridge.lifecycle === "active")) {
|
|
33
|
+
reasons.push("bridge_state");
|
|
34
|
+
}
|
|
35
|
+
if (input.activeWork.taskPressure.liveTaskNames.length > 0) {
|
|
36
|
+
reasons.push("task_state");
|
|
37
|
+
}
|
|
38
|
+
if (hasNonFastPathToolRequest(requestedToolNames)) {
|
|
39
|
+
reasons.push("non_fast_path_tool");
|
|
40
|
+
}
|
|
41
|
+
if (input.mustResolveBeforeHandoff || input.activeWork.mustResolveBeforeHandoff) {
|
|
42
|
+
reasons.push("unresolved_obligation");
|
|
43
|
+
}
|
|
44
|
+
const target = reasons.length === 0 ? "fast-path" : "delegate-inward";
|
|
45
|
+
const decision = {
|
|
46
|
+
target,
|
|
47
|
+
reasons,
|
|
48
|
+
outwardClosureRequired: target === "delegate-inward" && input.channel !== "inner",
|
|
49
|
+
};
|
|
50
|
+
(0, runtime_1.emitNervesEvent)({
|
|
51
|
+
component: "engine",
|
|
52
|
+
event: "engine.delegation_decide",
|
|
53
|
+
message: "computed delegation hint",
|
|
54
|
+
meta: {
|
|
55
|
+
channel: input.channel,
|
|
56
|
+
target: decision.target,
|
|
57
|
+
reasons: decision.reasons,
|
|
58
|
+
outwardClosureRequired: decision.outwardClosureRequired,
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
return decision;
|
|
62
|
+
}
|
package/dist/heart/identity.js
CHANGED
|
@@ -33,20 +33,30 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.DEFAULT_AGENT_PHRASES = exports.DEFAULT_AGENT_CONTEXT = void 0;
|
|
36
|
+
exports.HARNESS_CANONICAL_REPO_URL = exports.PROVIDER_CREDENTIALS = exports.DEFAULT_AGENT_SENSES = exports.DEFAULT_AGENT_PHRASES = exports.DEFAULT_AGENT_CONTEXT = void 0;
|
|
37
37
|
exports.buildDefaultAgentTemplate = buildDefaultAgentTemplate;
|
|
38
38
|
exports.getAgentName = getAgentName;
|
|
39
39
|
exports.getRepoRoot = getRepoRoot;
|
|
40
40
|
exports.getAgentBundlesRoot = getAgentBundlesRoot;
|
|
41
41
|
exports.getAgentRoot = getAgentRoot;
|
|
42
|
+
exports.getAgentStateRoot = getAgentStateRoot;
|
|
43
|
+
exports.getAgentRepoWorkspacesRoot = getAgentRepoWorkspacesRoot;
|
|
44
|
+
exports.getAgentDaemonStateRoot = getAgentDaemonStateRoot;
|
|
45
|
+
exports.getAgentDaemonLogsDir = getAgentDaemonLogsDir;
|
|
46
|
+
exports.getAgentDaemonLoggingConfigPath = getAgentDaemonLoggingConfigPath;
|
|
47
|
+
exports.getAgentMessagesRoot = getAgentMessagesRoot;
|
|
48
|
+
exports.getAgentToolsRoot = getAgentToolsRoot;
|
|
42
49
|
exports.getAgentSecretsPath = getAgentSecretsPath;
|
|
43
50
|
exports.loadAgentConfig = loadAgentConfig;
|
|
44
51
|
exports.setAgentName = setAgentName;
|
|
52
|
+
exports.setAgentConfigOverride = setAgentConfigOverride;
|
|
53
|
+
exports.resetAgentConfigCache = resetAgentConfigCache;
|
|
45
54
|
exports.resetIdentity = resetIdentity;
|
|
46
55
|
const fs = __importStar(require("fs"));
|
|
47
56
|
const os = __importStar(require("os"));
|
|
48
57
|
const path = __importStar(require("path"));
|
|
49
58
|
const runtime_1 = require("../nerves/runtime");
|
|
59
|
+
const migrate_config_1 = require("./migrate-config");
|
|
50
60
|
exports.DEFAULT_AGENT_CONTEXT = {
|
|
51
61
|
maxTokens: 80000,
|
|
52
62
|
contextMargin: 20,
|
|
@@ -56,12 +66,74 @@ exports.DEFAULT_AGENT_PHRASES = {
|
|
|
56
66
|
tool: ["running tool"],
|
|
57
67
|
followup: ["processing"],
|
|
58
68
|
};
|
|
69
|
+
exports.DEFAULT_AGENT_SENSES = {
|
|
70
|
+
cli: { enabled: true },
|
|
71
|
+
teams: { enabled: false },
|
|
72
|
+
bluebubbles: { enabled: false },
|
|
73
|
+
};
|
|
74
|
+
function normalizeSenses(value, configFile) {
|
|
75
|
+
const defaults = {
|
|
76
|
+
cli: { ...exports.DEFAULT_AGENT_SENSES.cli },
|
|
77
|
+
teams: { ...exports.DEFAULT_AGENT_SENSES.teams },
|
|
78
|
+
bluebubbles: { ...exports.DEFAULT_AGENT_SENSES.bluebubbles },
|
|
79
|
+
};
|
|
80
|
+
if (value === undefined) {
|
|
81
|
+
return defaults;
|
|
82
|
+
}
|
|
83
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
84
|
+
(0, runtime_1.emitNervesEvent)({
|
|
85
|
+
level: "error",
|
|
86
|
+
event: "config_identity.error",
|
|
87
|
+
component: "config/identity",
|
|
88
|
+
message: "agent config has invalid senses block",
|
|
89
|
+
meta: { path: configFile },
|
|
90
|
+
});
|
|
91
|
+
throw new Error(`agent.json at ${configFile} must include senses as an object when present.`);
|
|
92
|
+
}
|
|
93
|
+
const raw = value;
|
|
94
|
+
const senseNames = ["cli", "teams", "bluebubbles"];
|
|
95
|
+
for (const senseName of senseNames) {
|
|
96
|
+
const rawSense = raw[senseName];
|
|
97
|
+
if (rawSense === undefined) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (!rawSense || typeof rawSense !== "object" || Array.isArray(rawSense)) {
|
|
101
|
+
(0, runtime_1.emitNervesEvent)({
|
|
102
|
+
level: "error",
|
|
103
|
+
event: "config_identity.error",
|
|
104
|
+
component: "config/identity",
|
|
105
|
+
message: "agent config has invalid sense config",
|
|
106
|
+
meta: { path: configFile, sense: senseName },
|
|
107
|
+
});
|
|
108
|
+
throw new Error(`agent.json at ${configFile} has invalid senses.${senseName} config.`);
|
|
109
|
+
}
|
|
110
|
+
const enabled = rawSense.enabled;
|
|
111
|
+
if (typeof enabled !== "boolean") {
|
|
112
|
+
(0, runtime_1.emitNervesEvent)({
|
|
113
|
+
level: "error",
|
|
114
|
+
event: "config_identity.error",
|
|
115
|
+
component: "config/identity",
|
|
116
|
+
message: "agent config has invalid sense enabled flag",
|
|
117
|
+
meta: { path: configFile, sense: senseName, enabled: enabled ?? null },
|
|
118
|
+
});
|
|
119
|
+
throw new Error(`agent.json at ${configFile} must include senses.${senseName}.enabled as boolean.`);
|
|
120
|
+
}
|
|
121
|
+
defaults[senseName] = { enabled };
|
|
122
|
+
}
|
|
123
|
+
return defaults;
|
|
124
|
+
}
|
|
59
125
|
function buildDefaultAgentTemplate(_agentName) {
|
|
60
126
|
return {
|
|
61
|
-
version:
|
|
127
|
+
version: 2,
|
|
62
128
|
enabled: true,
|
|
63
|
-
provider: "anthropic",
|
|
129
|
+
humanFacing: { provider: "anthropic", model: "claude-opus-4-6" },
|
|
130
|
+
agentFacing: { provider: "anthropic", model: "claude-opus-4-6" },
|
|
64
131
|
context: { ...exports.DEFAULT_AGENT_CONTEXT },
|
|
132
|
+
senses: {
|
|
133
|
+
cli: { ...exports.DEFAULT_AGENT_SENSES.cli },
|
|
134
|
+
teams: { ...exports.DEFAULT_AGENT_SENSES.teams },
|
|
135
|
+
bluebubbles: { ...exports.DEFAULT_AGENT_SENSES.bluebubbles },
|
|
136
|
+
},
|
|
65
137
|
phrases: {
|
|
66
138
|
thinking: [...exports.DEFAULT_AGENT_PHRASES.thinking],
|
|
67
139
|
tool: [...exports.DEFAULT_AGENT_PHRASES.tool],
|
|
@@ -70,7 +142,7 @@ function buildDefaultAgentTemplate(_agentName) {
|
|
|
70
142
|
};
|
|
71
143
|
}
|
|
72
144
|
let _cachedAgentName = null;
|
|
73
|
-
let
|
|
145
|
+
let _agentConfigOverride = null;
|
|
74
146
|
/**
|
|
75
147
|
* Parse `--agent <name>` from process.argv.
|
|
76
148
|
* Caches the result after first parse.
|
|
@@ -111,13 +183,60 @@ function getRepoRoot() {
|
|
|
111
183
|
* Returns the shared bundle root directory: `~/AgentBundles/`
|
|
112
184
|
*/
|
|
113
185
|
function getAgentBundlesRoot() {
|
|
114
|
-
|
|
186
|
+
const homeBase = process.env.WEBSITE_SITE_NAME ? "/home" : os.homedir();
|
|
187
|
+
return path.join(homeBase, "AgentBundles");
|
|
115
188
|
}
|
|
116
189
|
/**
|
|
117
190
|
* Returns the agent-specific bundle directory: `~/AgentBundles/<agentName>.ouro/`
|
|
118
191
|
*/
|
|
119
|
-
function getAgentRoot() {
|
|
120
|
-
return path.join(getAgentBundlesRoot(), `${
|
|
192
|
+
function getAgentRoot(agentName = getAgentName()) {
|
|
193
|
+
return path.join(getAgentBundlesRoot(), `${agentName}.ouro`);
|
|
194
|
+
}
|
|
195
|
+
function resolveOptionalAgentName(agentName) {
|
|
196
|
+
if (agentName && agentName.trim().length > 0)
|
|
197
|
+
return agentName.trim();
|
|
198
|
+
try {
|
|
199
|
+
return getAgentName();
|
|
200
|
+
}
|
|
201
|
+
catch {
|
|
202
|
+
return "slugger";
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Returns the bundle-local runtime state directory: `~/AgentBundles/<agentName>.ouro/state/`
|
|
207
|
+
*/
|
|
208
|
+
function getAgentStateRoot(agentName) {
|
|
209
|
+
return path.join(getAgentRoot(resolveOptionalAgentName(agentName)), "state");
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Required credential fields per provider.
|
|
213
|
+
* Used by daemon config-check to validate secrets before spawning an agent.
|
|
214
|
+
*/
|
|
215
|
+
exports.PROVIDER_CREDENTIALS = {
|
|
216
|
+
azure: ["apiKey", "endpoint", "deployment"],
|
|
217
|
+
minimax: ["apiKey"],
|
|
218
|
+
anthropic: ["setupToken"],
|
|
219
|
+
"openai-codex": ["oauthAccessToken"],
|
|
220
|
+
"github-copilot": ["githubToken", "baseUrl"],
|
|
221
|
+
};
|
|
222
|
+
exports.HARNESS_CANONICAL_REPO_URL = "https://github.com/ouroborosbot/ouroboros.git";
|
|
223
|
+
function getAgentRepoWorkspacesRoot(agentName) {
|
|
224
|
+
return path.join(getAgentStateRoot(resolveOptionalAgentName(agentName)), "workspaces");
|
|
225
|
+
}
|
|
226
|
+
function getAgentDaemonStateRoot(agentName) {
|
|
227
|
+
return path.join(getAgentStateRoot(resolveOptionalAgentName(agentName)), "daemon");
|
|
228
|
+
}
|
|
229
|
+
function getAgentDaemonLogsDir(agentName) {
|
|
230
|
+
return path.join(getAgentDaemonStateRoot(resolveOptionalAgentName(agentName)), "logs");
|
|
231
|
+
}
|
|
232
|
+
function getAgentDaemonLoggingConfigPath(agentName) {
|
|
233
|
+
return path.join(getAgentDaemonStateRoot(resolveOptionalAgentName(agentName)), "logging.json");
|
|
234
|
+
}
|
|
235
|
+
function getAgentMessagesRoot(agentName) {
|
|
236
|
+
return path.join(getAgentStateRoot(resolveOptionalAgentName(agentName)), "messages");
|
|
237
|
+
}
|
|
238
|
+
function getAgentToolsRoot(agentName) {
|
|
239
|
+
return path.join(getAgentStateRoot(resolveOptionalAgentName(agentName)), "tools");
|
|
121
240
|
}
|
|
122
241
|
/**
|
|
123
242
|
* Returns the conventional secrets path: `~/.agentsecrets/<agentName>/secrets.json`
|
|
@@ -125,23 +244,11 @@ function getAgentRoot() {
|
|
|
125
244
|
function getAgentSecretsPath(agentName = getAgentName()) {
|
|
126
245
|
return path.join(os.homedir(), ".agentsecrets", agentName, "secrets.json");
|
|
127
246
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
function loadAgentConfig() {
|
|
134
|
-
if (_cachedAgentConfig) {
|
|
135
|
-
(0, runtime_1.emitNervesEvent)({
|
|
136
|
-
event: "identity.resolve",
|
|
137
|
-
component: "config/identity",
|
|
138
|
-
message: "loaded agent config from cache",
|
|
139
|
-
meta: { source: "cache" },
|
|
140
|
-
});
|
|
141
|
-
return _cachedAgentConfig;
|
|
142
|
-
}
|
|
143
|
-
const agentRoot = getAgentRoot();
|
|
144
|
-
const configFile = path.join(agentRoot, "agent.json");
|
|
247
|
+
const VALID_PROVIDERS = ["azure", "minimax", "anthropic", "openai-codex", "github-copilot"];
|
|
248
|
+
function isValidProvider(value) {
|
|
249
|
+
return typeof value === "string" && VALID_PROVIDERS.includes(value);
|
|
250
|
+
}
|
|
251
|
+
function readAndParseAgentJson(configFile) {
|
|
145
252
|
let raw;
|
|
146
253
|
try {
|
|
147
254
|
raw = fs.readFileSync(configFile, "utf-8");
|
|
@@ -159,9 +266,8 @@ function loadAgentConfig() {
|
|
|
159
266
|
});
|
|
160
267
|
throw new Error(`Cannot read agent.json at ${configFile}. Does the agent directory exist?`);
|
|
161
268
|
}
|
|
162
|
-
let parsed;
|
|
163
269
|
try {
|
|
164
|
-
|
|
270
|
+
return JSON.parse(raw);
|
|
165
271
|
}
|
|
166
272
|
catch (error) {
|
|
167
273
|
(0, runtime_1.emitNervesEvent)({
|
|
@@ -176,6 +282,62 @@ function loadAgentConfig() {
|
|
|
176
282
|
});
|
|
177
283
|
throw new Error(`Invalid JSON in agent.json at ${configFile}. Check syntax.`);
|
|
178
284
|
}
|
|
285
|
+
}
|
|
286
|
+
function validateFacingConfig(parsed, facingName, configFile) {
|
|
287
|
+
const raw = parsed[facingName];
|
|
288
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
289
|
+
(0, runtime_1.emitNervesEvent)({
|
|
290
|
+
level: "error",
|
|
291
|
+
event: "config_identity.error",
|
|
292
|
+
component: "config/identity",
|
|
293
|
+
message: `agent config missing or invalid ${facingName}`,
|
|
294
|
+
meta: { path: configFile, [facingName]: raw ?? null },
|
|
295
|
+
});
|
|
296
|
+
throw new Error(`agent.json at ${configFile} must include ${facingName} as { provider, model }.`);
|
|
297
|
+
}
|
|
298
|
+
const facing = raw;
|
|
299
|
+
if (!isValidProvider(facing.provider)) {
|
|
300
|
+
(0, runtime_1.emitNervesEvent)({
|
|
301
|
+
level: "error",
|
|
302
|
+
event: "config_identity.error",
|
|
303
|
+
component: "config/identity",
|
|
304
|
+
message: `agent config has invalid provider in ${facingName}`,
|
|
305
|
+
meta: { path: configFile, provider: facing.provider ?? null },
|
|
306
|
+
});
|
|
307
|
+
throw new Error(`agent.json at ${configFile} ${facingName}.provider must be one of: ${VALID_PROVIDERS.join(", ")}.`);
|
|
308
|
+
}
|
|
309
|
+
if (typeof facing.model !== "string") {
|
|
310
|
+
(0, runtime_1.emitNervesEvent)({
|
|
311
|
+
level: "error",
|
|
312
|
+
event: "config_identity.error",
|
|
313
|
+
component: "config/identity",
|
|
314
|
+
message: `agent config has invalid model in ${facingName}`,
|
|
315
|
+
meta: { path: configFile, model: facing.model ?? null },
|
|
316
|
+
});
|
|
317
|
+
throw new Error(`agent.json at ${configFile} ${facingName}.model must be a string.`);
|
|
318
|
+
}
|
|
319
|
+
return { provider: facing.provider, model: facing.model };
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Load and parse `<agentRoot>/agent.json`.
|
|
323
|
+
* Reads the file fresh on each call unless an override is set.
|
|
324
|
+
* If the config is v1, auto-migrates to v2 via migrateAgentConfigV1ToV2 and re-reads.
|
|
325
|
+
* Throws descriptive error if file is missing or contains invalid JSON.
|
|
326
|
+
*/
|
|
327
|
+
function loadAgentConfig() {
|
|
328
|
+
if (_agentConfigOverride) {
|
|
329
|
+
return _agentConfigOverride;
|
|
330
|
+
}
|
|
331
|
+
const agentRoot = getAgentRoot();
|
|
332
|
+
const configFile = path.join(agentRoot, "agent.json");
|
|
333
|
+
let parsed = readAndParseAgentJson(configFile);
|
|
334
|
+
// Inline migration: v1 -> v2
|
|
335
|
+
const rawVersion = parsed.version;
|
|
336
|
+
const initialVersion = typeof rawVersion === "number" ? rawVersion : 1;
|
|
337
|
+
if (initialVersion < 2) {
|
|
338
|
+
(0, migrate_config_1.migrateAgentConfigV1ToV2)(agentRoot);
|
|
339
|
+
parsed = readAndParseAgentJson(configFile);
|
|
340
|
+
}
|
|
179
341
|
const existingPhrases = parsed.phrases;
|
|
180
342
|
const needsFill = !existingPhrases ||
|
|
181
343
|
!existingPhrases.thinking ||
|
|
@@ -197,27 +359,11 @@ function loadAgentConfig() {
|
|
|
197
359
|
});
|
|
198
360
|
fs.writeFileSync(configFile, JSON.stringify(parsed, null, 2) + "\n", "utf-8");
|
|
199
361
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
(0, runtime_1.emitNervesEvent)({
|
|
206
|
-
level: "error",
|
|
207
|
-
event: "config_identity.error",
|
|
208
|
-
component: "config/identity",
|
|
209
|
-
message: "agent config missing or invalid provider",
|
|
210
|
-
meta: {
|
|
211
|
-
path: configFile,
|
|
212
|
-
provider: rawProvider,
|
|
213
|
-
},
|
|
214
|
-
});
|
|
215
|
-
throw new Error(`agent.json at ${configFile} must include provider: "azure", "minimax", "anthropic", or "openai-codex".`);
|
|
216
|
-
}
|
|
217
|
-
const rawVersion = parsed.version;
|
|
218
|
-
const version = rawVersion === undefined ? 1 : rawVersion;
|
|
219
|
-
if (typeof version !== "number" ||
|
|
220
|
-
!Number.isInteger(version) ||
|
|
362
|
+
// Validate v2 facing configs
|
|
363
|
+
const humanFacing = validateFacingConfig(parsed, "humanFacing", configFile);
|
|
364
|
+
const agentFacing = validateFacingConfig(parsed, "agentFacing", configFile);
|
|
365
|
+
const version = typeof parsed.version === "number" ? parsed.version : 1;
|
|
366
|
+
if (!Number.isInteger(version) ||
|
|
221
367
|
version < 1) {
|
|
222
368
|
(0, runtime_1.emitNervesEvent)({
|
|
223
369
|
level: "error",
|
|
@@ -226,7 +372,7 @@ function loadAgentConfig() {
|
|
|
226
372
|
message: "agent config missing or invalid version",
|
|
227
373
|
meta: {
|
|
228
374
|
path: configFile,
|
|
229
|
-
version:
|
|
375
|
+
version: parsed.version,
|
|
230
376
|
},
|
|
231
377
|
});
|
|
232
378
|
throw new Error(`agent.json at ${configFile} must include version as integer >= 1.`);
|
|
@@ -246,12 +392,19 @@ function loadAgentConfig() {
|
|
|
246
392
|
});
|
|
247
393
|
throw new Error(`agent.json at ${configFile} must include enabled as boolean.`);
|
|
248
394
|
}
|
|
249
|
-
|
|
395
|
+
// Tolerate deprecated provider field for backward compatibility
|
|
396
|
+
const rawProvider = parsed.provider;
|
|
397
|
+
const provider = isValidProvider(rawProvider) ? rawProvider : undefined;
|
|
398
|
+
const config = {
|
|
250
399
|
version,
|
|
251
400
|
enabled,
|
|
252
|
-
provider:
|
|
401
|
+
...(provider !== undefined ? { provider } : {}),
|
|
402
|
+
humanFacing,
|
|
403
|
+
agentFacing,
|
|
253
404
|
context: parsed.context,
|
|
254
405
|
logging: parsed.logging,
|
|
406
|
+
senses: normalizeSenses(parsed.senses, configFile),
|
|
407
|
+
mcpServers: parsed.mcpServers,
|
|
255
408
|
phrases: parsed.phrases,
|
|
256
409
|
};
|
|
257
410
|
(0, runtime_1.emitNervesEvent)({
|
|
@@ -260,7 +413,7 @@ function loadAgentConfig() {
|
|
|
260
413
|
message: "loaded agent config from disk",
|
|
261
414
|
meta: { source: "disk" },
|
|
262
415
|
});
|
|
263
|
-
return
|
|
416
|
+
return config;
|
|
264
417
|
}
|
|
265
418
|
/**
|
|
266
419
|
* Prime the agent name cache explicitly.
|
|
@@ -271,11 +424,26 @@ function loadAgentConfig() {
|
|
|
271
424
|
function setAgentName(name) {
|
|
272
425
|
_cachedAgentName = name;
|
|
273
426
|
}
|
|
427
|
+
/**
|
|
428
|
+
* Override the agent config returned by loadAgentConfig().
|
|
429
|
+
* When set to a non-null AgentConfig, loadAgentConfig() returns the override
|
|
430
|
+
* instead of reading from disk. When set to null, normal disk-based loading resumes.
|
|
431
|
+
*/
|
|
432
|
+
function setAgentConfigOverride(config) {
|
|
433
|
+
_agentConfigOverride = config;
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Preserve the compatibility hook for callers that previously cleared cached
|
|
437
|
+
* disk-backed agent config. Agent config is now read fresh on every call.
|
|
438
|
+
*/
|
|
439
|
+
function resetAgentConfigCache() {
|
|
440
|
+
// No-op: disk-backed agent config is no longer memoized in-process.
|
|
441
|
+
}
|
|
274
442
|
/**
|
|
275
443
|
* Clear all cached identity state.
|
|
276
444
|
* Used in tests and when switching agent context.
|
|
277
445
|
*/
|
|
278
446
|
function resetIdentity() {
|
|
279
447
|
_cachedAgentName = null;
|
|
280
|
-
|
|
448
|
+
_agentConfigOverride = null;
|
|
281
449
|
}
|