@ouro.bot/cli 0.1.0-alpha.134 → 0.1.0-alpha.136
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 +6 -2
- package/changelog.json +16 -0
- package/dist/heart/core.js +63 -39
- package/dist/heart/daemon/daemon-cli.js +161 -0
- package/dist/heart/daemon/daemon-entry.js +11 -0
- package/dist/heart/daemon/daemon.js +44 -31
- package/dist/heart/tool-loop.js +5 -1
- package/dist/mind/context.js +62 -0
- package/dist/mind/prompt.js +9 -4
- package/dist/repertoire/ado-semantic.js +6 -0
- package/dist/repertoire/coding/tools.js +5 -0
- package/dist/repertoire/tools-base.js +24 -31
- package/dist/repertoire/tools-bluebubbles.js +1 -0
- package/dist/repertoire/tools-github.js +1 -6
- package/dist/repertoire/tools-teams.js +9 -36
- package/dist/repertoire/tools.js +15 -69
- package/dist/senses/cli-entry.js +1 -1
- package/package.json +3 -2
- package/dist/heart/safe-workspace.js +0 -381
package/README.md
CHANGED
|
@@ -8,7 +8,8 @@ Ouroboros is a TypeScript harness for daemon-managed agents that live in externa
|
|
|
8
8
|
|
|
9
9
|
- `npx ouro.bot` is the bootstrap path.
|
|
10
10
|
- `ouro` is the installed day-to-day command.
|
|
11
|
-
- `ouro up` starts
|
|
11
|
+
- `ouro up` starts the daemon from the installed production version, syncs the launcher, installs workflow helpers, and reconciles stale runtime state.
|
|
12
|
+
- `ouro dev` starts the daemon from a local repo build (skips update checker, writes plist to repo path).
|
|
12
13
|
- Agent bundles live outside the repo at `~/AgentBundles/<agent>.ouro/`.
|
|
13
14
|
- Secrets live outside the repo at `~/.agentsecrets/<agent>/secrets.json`.
|
|
14
15
|
- Machine-scoped test and runtime spillover lives under `~/.agentstate/...`.
|
|
@@ -141,7 +142,10 @@ If you are changing runtime code, keep all three green.
|
|
|
141
142
|
## Common Commands
|
|
142
143
|
|
|
143
144
|
```bash
|
|
144
|
-
ouro up
|
|
145
|
+
ouro up # start daemon from installed production version
|
|
146
|
+
ouro dev # start daemon from local repo build
|
|
147
|
+
ouro dev --repo-path /path # start from a specific repo checkout
|
|
148
|
+
ouro dev --clone # clone repo to ~/Projects/ouroboros, build, start
|
|
145
149
|
ouro status
|
|
146
150
|
ouro logs
|
|
147
151
|
ouro stop
|
package/changelog.json
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_note": "This changelog is maintained as part of the PR/version-bump workflow. Agent-curated, not auto-generated. Agents read this file directly via read_file to understand what changed between versions.",
|
|
3
3
|
"versions": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.1.0-alpha.136",
|
|
6
|
+
"changes": [
|
|
7
|
+
"Dev mode DX: ouro dev starts daemon from local repo build, skips update checker, prints dev mode indicator.",
|
|
8
|
+
"ouro up from dev context delegates to installed production binary or errors with install guidance.",
|
|
9
|
+
"Daemon accepts mode option; update checker suppressed in dev mode with daemon.update_checker_skip event.",
|
|
10
|
+
"Daemon entry emits daemon.dev_mode_indicator nerves event when running from a dev repo."
|
|
11
|
+
]
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"version": "0.1.0-alpha.135",
|
|
15
|
+
"changes": [
|
|
16
|
+
"Metacognitive tool vocabulary complete: go_inward renamed to descend. RunAgentOutcome value is now 'descended', event is 'engine.descended'.",
|
|
17
|
+
"summarizeArgs rewritten: reads summaryKeys from ToolDefinition instead of per-tool switch branches. summarizeTeamsArgs and summarizeGithubArgs eliminated."
|
|
18
|
+
]
|
|
19
|
+
},
|
|
4
20
|
{
|
|
5
21
|
"version": "0.1.0-alpha.134",
|
|
6
22
|
"changes": [
|
package/dist/heart/core.js
CHANGED
|
@@ -176,7 +176,7 @@ Object.defineProperty(exports, "buildSystem", { enumerable: true, get: function
|
|
|
176
176
|
const SOLE_CALL_REJECTION = {
|
|
177
177
|
settle: "rejected: settle must be the only tool call. finish your work first, then call settle alone.",
|
|
178
178
|
observe: "rejected: observe must be the only tool call. call observe alone when you want to stay silent.",
|
|
179
|
-
|
|
179
|
+
descend: "rejected: descend must be the only tool call. finish your other work first, then call descend alone.",
|
|
180
180
|
};
|
|
181
181
|
const DELEGATION_REASON_PROSE_HANDOFF = {
|
|
182
182
|
explicit_reflection: "something in the conversation called for reflection",
|
|
@@ -186,7 +186,7 @@ const DELEGATION_REASON_PROSE_HANDOFF = {
|
|
|
186
186
|
non_fast_path_tool: "this needs tools beyond a simple reply",
|
|
187
187
|
unresolved_obligation: "there's an unresolved commitment from an earlier conversation",
|
|
188
188
|
};
|
|
189
|
-
function
|
|
189
|
+
function buildDescendHandoffPacket(params) {
|
|
190
190
|
const reasons = params.delegationDecision?.reasons ?? [];
|
|
191
191
|
const reasonProse = reasons.length > 0
|
|
192
192
|
? reasons.map((r) => DELEGATION_REASON_PROSE_HANDOFF[r]).join("; ")
|
|
@@ -245,14 +245,14 @@ function isExternalStateQuery(toolName, args) {
|
|
|
245
245
|
const cmd = String(args.command ?? "");
|
|
246
246
|
return /\bgh\s+(pr|run|api|issue)\b/.test(cmd) || /\bnpm\s+(view|info|show)\b/.test(cmd);
|
|
247
247
|
}
|
|
248
|
-
function getSettleRetryError(mustResolveBeforeHandoff, intent, sawSteeringFollowUp, _delegationDecision, sawSendMessageSelf,
|
|
248
|
+
function getSettleRetryError(mustResolveBeforeHandoff, intent, sawSteeringFollowUp, _delegationDecision, sawSendMessageSelf, sawDescend, _sawQuerySession, currentObligation, innerJob, sawExternalStateQuery) {
|
|
249
249
|
// Delegation adherence removed: the delegation decision is surfaced in the
|
|
250
250
|
// system prompt as a suggestion. Hard-gating settle caused infinite
|
|
251
251
|
// rejection loops where the agent couldn't respond to the user at all.
|
|
252
252
|
// The agent is free to follow or ignore the delegation hint.
|
|
253
253
|
// 2. Pending obligation not addressed
|
|
254
|
-
if (innerJob?.obligationStatus === "pending" && !sawSendMessageSelf && !
|
|
255
|
-
return "you're still holding something from an earlier conversation -- someone is waiting for your answer. finish the thought first, or
|
|
254
|
+
if (innerJob?.obligationStatus === "pending" && !sawSendMessageSelf && !sawDescend) {
|
|
255
|
+
return "you're still holding something from an earlier conversation -- someone is waiting for your answer. finish the thought first, or descend to keep working on it privately.";
|
|
256
256
|
}
|
|
257
257
|
// 3. mustResolveBeforeHandoff + missing intent
|
|
258
258
|
if (mustResolveBeforeHandoff && !intent) {
|
|
@@ -496,7 +496,7 @@ async function runAgent(messages, callbacks, channel, signal, options) {
|
|
|
496
496
|
let mustResolveBeforeHandoffActive = options?.mustResolveBeforeHandoff === true;
|
|
497
497
|
let currentReasoningEffort = "medium";
|
|
498
498
|
let sawSendMessageSelf = false;
|
|
499
|
-
let
|
|
499
|
+
let sawDescend = false;
|
|
500
500
|
let sawQuerySession = false;
|
|
501
501
|
let sawBridgeManage = false;
|
|
502
502
|
let sawExternalStateQuery = false;
|
|
@@ -522,11 +522,11 @@ async function runAgent(messages, callbacks, channel, signal, options) {
|
|
|
522
522
|
providerRuntime.resetTurnState(messages);
|
|
523
523
|
while (!done) {
|
|
524
524
|
// Channel-based tool filtering:
|
|
525
|
-
// - Inner dialog: exclude
|
|
525
|
+
// - Inner dialog: exclude descend (already inward), send_message (delivery via surface), observe (no one to observe)
|
|
526
526
|
// - 1:1 sessions: exclude observe (can't ignore someone talking directly to you)
|
|
527
527
|
// - Group chats: observe available
|
|
528
528
|
//
|
|
529
|
-
//
|
|
529
|
+
// descend, settle, surface, and observe are always assembled based on channel context.
|
|
530
530
|
// toolChoiceRequired only controls whether tool_choice: "required" is set in the API call.
|
|
531
531
|
const isInnerDialog = channel === "inner";
|
|
532
532
|
const filteredBaseTools = isInnerDialog
|
|
@@ -534,7 +534,7 @@ async function runAgent(messages, callbacks, channel, signal, options) {
|
|
|
534
534
|
: baseTools;
|
|
535
535
|
const activeTools = [
|
|
536
536
|
...filteredBaseTools,
|
|
537
|
-
...(!isInnerDialog ? [tools_1.
|
|
537
|
+
...(!isInnerDialog ? [tools_1.descendTool] : []),
|
|
538
538
|
...(isInnerDialog ? [surface_tool_1.surfaceToolDef] : []),
|
|
539
539
|
...(currentContext?.isGroupChat && !isInnerDialog ? [tools_1.observeTool] : []),
|
|
540
540
|
tools_1.settleTool,
|
|
@@ -619,9 +619,18 @@ async function runAgent(messages, callbacks, channel, signal, options) {
|
|
|
619
619
|
else {
|
|
620
620
|
// Check for settle sole call: intercept before tool execution
|
|
621
621
|
if (isSoleSettle) {
|
|
622
|
+
/* v8 ignore next -- defensive: JSON.parse catch for malformed settle args @preserve */
|
|
623
|
+
const settleArgs = (() => { try {
|
|
624
|
+
return JSON.parse(result.toolCalls[0].arguments);
|
|
625
|
+
}
|
|
626
|
+
catch {
|
|
627
|
+
return {};
|
|
628
|
+
} })();
|
|
629
|
+
callbacks.onToolStart("settle", settleArgs);
|
|
622
630
|
// Inner dialog attention queue gate: reject settle if items remain
|
|
623
631
|
const attentionQueue = (augmentedToolContext ?? options?.toolContext)?.delegatedOrigins;
|
|
624
632
|
if (isInnerDialog && attentionQueue && attentionQueue.length > 0) {
|
|
633
|
+
callbacks.onToolEnd("settle", (0, tools_1.summarizeArgs)("settle", settleArgs), false);
|
|
625
634
|
callbacks.onClearText?.();
|
|
626
635
|
messages.push(msg);
|
|
627
636
|
const gateMessage = "you're holding thoughts someone is waiting for — surface them before you settle.";
|
|
@@ -634,6 +643,7 @@ async function runAgent(messages, callbacks, channel, signal, options) {
|
|
|
634
643
|
const { answer, intent } = parseSettlePayload(result.toolCalls[0].arguments);
|
|
635
644
|
// Inner dialog settle: no CompletionMetadata, "(settled)" ack
|
|
636
645
|
if (isInnerDialog) {
|
|
646
|
+
callbacks.onToolEnd("settle", (0, tools_1.summarizeArgs)("settle", settleArgs), true);
|
|
637
647
|
messages.push(msg);
|
|
638
648
|
const settled = "(settled)";
|
|
639
649
|
messages.push({ role: "tool", tool_call_id: result.toolCalls[0].id, content: settled });
|
|
@@ -642,7 +652,7 @@ async function runAgent(messages, callbacks, channel, signal, options) {
|
|
|
642
652
|
done = true;
|
|
643
653
|
continue;
|
|
644
654
|
}
|
|
645
|
-
const retryError = getSettleRetryError(mustResolveBeforeHandoffActive, intent, sawSteeringFollowUp, options?.delegationDecision, sawSendMessageSelf,
|
|
655
|
+
const retryError = getSettleRetryError(mustResolveBeforeHandoffActive, intent, sawSteeringFollowUp, options?.delegationDecision, sawSendMessageSelf, sawDescend, sawQuerySession, options?.currentObligation ?? null, options?.activeWorkFrame?.inner?.job, sawExternalStateQuery);
|
|
646
656
|
const deliveredAnswer = answer;
|
|
647
657
|
const validDirectReply = mustResolveBeforeHandoffActive && intent === "direct_reply" && sawSteeringFollowUp;
|
|
648
658
|
const validTerminalIntent = intent === "complete" || intent === "blocked";
|
|
@@ -650,6 +660,7 @@ async function runAgent(messages, callbacks, channel, signal, options) {
|
|
|
650
660
|
&& !retryError
|
|
651
661
|
&& (!mustResolveBeforeHandoffActive || validDirectReply || validTerminalIntent);
|
|
652
662
|
if (validClosure) {
|
|
663
|
+
callbacks.onToolEnd("settle", (0, tools_1.summarizeArgs)("settle", settleArgs), true);
|
|
653
664
|
completion = {
|
|
654
665
|
answer: deliveredAnswer,
|
|
655
666
|
intent: validDirectReply ? "direct_reply" : intent === "blocked" ? "blocked" : "complete",
|
|
@@ -684,6 +695,7 @@ async function runAgent(messages, callbacks, channel, signal, options) {
|
|
|
684
695
|
// Answer is undefined -- the model's settle was incomplete or
|
|
685
696
|
// malformed. Clear any partial streamed text or noise, then push the
|
|
686
697
|
// assistant msg + error tool result and let the model try again.
|
|
698
|
+
callbacks.onToolEnd("settle", (0, tools_1.summarizeArgs)("settle", settleArgs), false);
|
|
687
699
|
callbacks.onClearText?.();
|
|
688
700
|
messages.push(msg);
|
|
689
701
|
const toolRetryMessage = retryError
|
|
@@ -696,19 +708,24 @@ async function runAgent(messages, callbacks, channel, signal, options) {
|
|
|
696
708
|
// Check for observe sole call: intercept before tool execution
|
|
697
709
|
const isSoleObserve = result.toolCalls.length === 1 && result.toolCalls[0].name === "observe";
|
|
698
710
|
if (isSoleObserve) {
|
|
699
|
-
|
|
700
|
-
try {
|
|
701
|
-
|
|
702
|
-
if (typeof parsed?.reason === "string")
|
|
703
|
-
reason = parsed.reason;
|
|
711
|
+
/* v8 ignore next -- defensive: JSON.parse catch for malformed observe args @preserve */
|
|
712
|
+
const observeArgs = (() => { try {
|
|
713
|
+
return JSON.parse(result.toolCalls[0].arguments);
|
|
704
714
|
}
|
|
705
|
-
catch {
|
|
715
|
+
catch {
|
|
716
|
+
return {};
|
|
717
|
+
} })();
|
|
718
|
+
let reason;
|
|
719
|
+
if (typeof observeArgs?.reason === "string")
|
|
720
|
+
reason = observeArgs.reason;
|
|
721
|
+
callbacks.onToolStart("observe", observeArgs);
|
|
706
722
|
(0, runtime_1.emitNervesEvent)({
|
|
707
723
|
component: "engine",
|
|
708
724
|
event: "engine.observe",
|
|
709
725
|
message: "agent declined to respond in group chat",
|
|
710
726
|
meta: { ...(reason ? { reason } : {}) },
|
|
711
727
|
});
|
|
728
|
+
callbacks.onToolEnd("observe", (0, tools_1.summarizeArgs)("observe", observeArgs), true);
|
|
712
729
|
messages.push(msg);
|
|
713
730
|
const silenced = "(silenced)";
|
|
714
731
|
messages.push({ role: "tool", tool_call_id: result.toolCalls[0].id, content: silenced });
|
|
@@ -717,14 +734,15 @@ async function runAgent(messages, callbacks, channel, signal, options) {
|
|
|
717
734
|
done = true;
|
|
718
735
|
continue;
|
|
719
736
|
}
|
|
720
|
-
// Check for
|
|
721
|
-
const
|
|
722
|
-
if (
|
|
737
|
+
// Check for descend sole call: intercept before tool execution
|
|
738
|
+
const isSoleDescend = result.toolCalls.length === 1 && result.toolCalls[0].name === "descend";
|
|
739
|
+
if (isSoleDescend) {
|
|
723
740
|
let parsedArgs = {};
|
|
724
741
|
try {
|
|
725
742
|
parsedArgs = JSON.parse(result.toolCalls[0].arguments);
|
|
726
743
|
}
|
|
727
744
|
catch { /* ignore */ }
|
|
745
|
+
callbacks.onToolStart("descend", parsedArgs);
|
|
728
746
|
/* v8 ignore next -- defensive: topic always string from model @preserve */
|
|
729
747
|
const topic = typeof parsedArgs.topic === "string" ? parsedArgs.topic : "";
|
|
730
748
|
const answer = typeof parsedArgs.answer === "string" ? parsedArgs.answer : undefined;
|
|
@@ -738,7 +756,7 @@ async function runAgent(messages, callbacks, channel, signal, options) {
|
|
|
738
756
|
callbacks.onTextChunk(answer);
|
|
739
757
|
}
|
|
740
758
|
// Build handoff packet and enqueue
|
|
741
|
-
const handoffContent =
|
|
759
|
+
const handoffContent = buildDescendHandoffPacket({
|
|
742
760
|
topic,
|
|
743
761
|
mode,
|
|
744
762
|
delegationDecision: options?.delegationDecision,
|
|
@@ -749,6 +767,24 @@ async function runAgent(messages, callbacks, channel, signal, options) {
|
|
|
749
767
|
const pendingDir = (0, pending_1.getInnerDialogPendingDir)((0, identity_2.getAgentName)());
|
|
750
768
|
const currentSession = options?.toolContext?.currentSession;
|
|
751
769
|
const isInnerChannel = currentSession?.friendId === "self" && currentSession?.channel === "inner";
|
|
770
|
+
// Create obligation FIRST so we can attach its ID to the pending message
|
|
771
|
+
let createdObligationId;
|
|
772
|
+
if (currentSession && !isInnerChannel) {
|
|
773
|
+
try {
|
|
774
|
+
const obligation = (0, obligations_1.createObligation)((0, identity_2.getAgentRoot)(), {
|
|
775
|
+
origin: {
|
|
776
|
+
friendId: currentSession.friendId,
|
|
777
|
+
channel: currentSession.channel,
|
|
778
|
+
key: currentSession.key,
|
|
779
|
+
},
|
|
780
|
+
content: topic,
|
|
781
|
+
});
|
|
782
|
+
createdObligationId = obligation.id;
|
|
783
|
+
}
|
|
784
|
+
catch {
|
|
785
|
+
/* v8 ignore next -- defensive: obligation store write failure should not break descend @preserve */
|
|
786
|
+
}
|
|
787
|
+
}
|
|
752
788
|
const envelope = {
|
|
753
789
|
from: (0, identity_2.getAgentName)(),
|
|
754
790
|
friendId: "self",
|
|
@@ -764,40 +800,28 @@ async function runAgent(messages, callbacks, channel, signal, options) {
|
|
|
764
800
|
key: currentSession.key,
|
|
765
801
|
},
|
|
766
802
|
obligationStatus: "pending",
|
|
803
|
+
/* v8 ignore next -- defensive: createdObligationId is undefined only when obligation store write fails @preserve */
|
|
804
|
+
...(createdObligationId ? { obligationId: createdObligationId } : {}),
|
|
767
805
|
} : {}),
|
|
768
806
|
};
|
|
769
807
|
(0, pending_1.queuePendingMessage)(pendingDir, envelope);
|
|
770
|
-
if (currentSession && !isInnerChannel) {
|
|
771
|
-
try {
|
|
772
|
-
(0, obligations_1.createObligation)((0, identity_2.getAgentRoot)(), {
|
|
773
|
-
origin: {
|
|
774
|
-
friendId: currentSession.friendId,
|
|
775
|
-
channel: currentSession.channel,
|
|
776
|
-
key: currentSession.key,
|
|
777
|
-
},
|
|
778
|
-
content: topic,
|
|
779
|
-
});
|
|
780
|
-
}
|
|
781
|
-
catch {
|
|
782
|
-
/* v8 ignore next -- defensive: obligation store write failure should not break go_inward @preserve */
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
808
|
try {
|
|
786
809
|
await (0, socket_client_1.requestInnerWake)((0, identity_2.getAgentName)());
|
|
787
810
|
}
|
|
788
811
|
catch { /* daemon may not be running */ }
|
|
789
|
-
|
|
812
|
+
callbacks.onToolEnd("descend", (0, tools_1.summarizeArgs)("descend", parsedArgs), true);
|
|
813
|
+
sawDescend = true;
|
|
790
814
|
messages.push(msg);
|
|
791
815
|
const ack = "(going inward)";
|
|
792
816
|
messages.push({ role: "tool", tool_call_id: result.toolCalls[0].id, content: ack });
|
|
793
817
|
providerRuntime.appendToolOutput(result.toolCalls[0].id, ack);
|
|
794
818
|
(0, runtime_1.emitNervesEvent)({
|
|
795
819
|
component: "engine",
|
|
796
|
-
event: "engine.
|
|
820
|
+
event: "engine.descended",
|
|
797
821
|
message: "taking thread inward",
|
|
798
822
|
meta: { mode, hasAnswer: answer !== undefined, contentSnippet: topic.slice(0, 80) },
|
|
799
823
|
});
|
|
800
|
-
outcome = "
|
|
824
|
+
outcome = "descended";
|
|
801
825
|
done = true;
|
|
802
826
|
continue;
|
|
803
827
|
}
|
|
@@ -957,7 +981,7 @@ async function runAgent(messages, callbacks, channel, signal, options) {
|
|
|
957
981
|
trace_id: traceId,
|
|
958
982
|
component: "engine",
|
|
959
983
|
message: "runAgent turn completed",
|
|
960
|
-
meta: { done,
|
|
984
|
+
meta: { done, sawDescend, sawQuerySession, sawBridgeManage },
|
|
961
985
|
});
|
|
962
986
|
return {
|
|
963
987
|
usage: lastUsage,
|
|
@@ -272,6 +272,7 @@ function usage() {
|
|
|
272
272
|
return [
|
|
273
273
|
"Usage:",
|
|
274
274
|
" ouro [up]",
|
|
275
|
+
" ouro dev [--repo-path <path>] [--clone [--clone-path <path>]]",
|
|
275
276
|
" ouro stop|down|status|logs|hatch",
|
|
276
277
|
" ouro -v|--version",
|
|
277
278
|
" ouro config model --agent <name> <model-name>",
|
|
@@ -899,6 +900,27 @@ function parseOuroCommand(args) {
|
|
|
899
900
|
}
|
|
900
901
|
if (head === "up")
|
|
901
902
|
return { kind: "daemon.up" };
|
|
903
|
+
if (head === "dev") {
|
|
904
|
+
const devArgs = args.slice(1);
|
|
905
|
+
let repoPath;
|
|
906
|
+
let clone = false;
|
|
907
|
+
let clonePath;
|
|
908
|
+
for (let i = 0; i < devArgs.length; i++) {
|
|
909
|
+
if (devArgs[i] === "--repo-path" && devArgs[i + 1]) {
|
|
910
|
+
repoPath = devArgs[++i];
|
|
911
|
+
continue;
|
|
912
|
+
}
|
|
913
|
+
if (devArgs[i] === "--clone") {
|
|
914
|
+
clone = true;
|
|
915
|
+
continue;
|
|
916
|
+
}
|
|
917
|
+
if (devArgs[i] === "--clone-path" && devArgs[i + 1]) {
|
|
918
|
+
clonePath = devArgs[++i];
|
|
919
|
+
continue;
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
return { kind: "daemon.dev", repoPath, clone, clonePath };
|
|
923
|
+
}
|
|
902
924
|
if (head === "rollback")
|
|
903
925
|
return { kind: "rollback", ...(second ? { version: second } : {}) };
|
|
904
926
|
if (head === "versions")
|
|
@@ -1383,6 +1405,19 @@ function createDefaultOuroCliDeps(socketPath = socket_client_1.DEFAULT_DAEMON_SO
|
|
|
1383
1405
|
syncGlobalOuroBotWrapper: ouro_bot_global_installer_1.syncGlobalOuroBotWrapper,
|
|
1384
1406
|
ensureSkillManagement: skill_management_installer_1.ensureSkillManagement,
|
|
1385
1407
|
ensureDaemonBootPersistence: defaultEnsureDaemonBootPersistence,
|
|
1408
|
+
/* v8 ignore start -- dev-mode defaults: tests inject mocks for mode detection and binary resolution @preserve */
|
|
1409
|
+
detectMode: () => (0, runtime_mode_1.detectRuntimeMode)((0, identity_1.getRepoRoot)()),
|
|
1410
|
+
getInstalledBinaryPath: () => {
|
|
1411
|
+
const cliHome = (0, ouro_version_manager_1.getOuroCliHome)();
|
|
1412
|
+
const binaryPath = path.join(cliHome, "bin", "ouro");
|
|
1413
|
+
return fs.existsSync(binaryPath) ? binaryPath : null;
|
|
1414
|
+
},
|
|
1415
|
+
execInstalledBinary: (binaryPath, binArgs) => {
|
|
1416
|
+
const { execFileSync } = require("child_process");
|
|
1417
|
+
execFileSync(binaryPath, binArgs, { stdio: "inherit" });
|
|
1418
|
+
process.exit(0);
|
|
1419
|
+
},
|
|
1420
|
+
/* v8 ignore stop */
|
|
1386
1421
|
/* v8 ignore next 3 -- integration: launches interactive CLI session @preserve */
|
|
1387
1422
|
startChat: async (agentName) => {
|
|
1388
1423
|
const { main } = await Promise.resolve().then(() => __importStar(require("../../senses/cli")));
|
|
@@ -1726,6 +1761,48 @@ function executeReminderCommand(command, taskMod) {
|
|
|
1726
1761
|
return `error: ${error instanceof Error ? error.message : /* v8 ignore next -- defensive: non-Error catch branch @preserve */ String(error)}`;
|
|
1727
1762
|
}
|
|
1728
1763
|
}
|
|
1764
|
+
/* v8 ignore start -- repo resolution for ouro dev: repoPath branch tested via daemon-cli-dev; clone requires real git/npm @preserve */
|
|
1765
|
+
function resolveDevRepoCwd(command, checkExists, deps) {
|
|
1766
|
+
if (command.repoPath)
|
|
1767
|
+
return path.resolve(command.repoPath);
|
|
1768
|
+
if (command.clone)
|
|
1769
|
+
return resolveClonePath(command, checkExists, deps);
|
|
1770
|
+
return deps.getRepoCwd ? deps.getRepoCwd() : (0, identity_1.getRepoRoot)();
|
|
1771
|
+
}
|
|
1772
|
+
/* v8 ignore stop */
|
|
1773
|
+
/* v8 ignore start -- clone/build: requires real git clone + npm install on disk @preserve */
|
|
1774
|
+
function resolveClonePath(command, checkExists, deps) {
|
|
1775
|
+
const cloneTarget = command.clonePath
|
|
1776
|
+
? path.resolve(command.clonePath)
|
|
1777
|
+
: path.join(os.homedir(), "Projects", "ouroboros");
|
|
1778
|
+
if (!checkExists(path.join(cloneTarget, ".git"))) {
|
|
1779
|
+
deps.writeStdout(`cloning ouroboros to ${cloneTarget}...`);
|
|
1780
|
+
try {
|
|
1781
|
+
(0, child_process_1.execSync)(`git clone ${identity_1.HARNESS_CANONICAL_REPO_URL} "${cloneTarget}"`, { stdio: "inherit" });
|
|
1782
|
+
}
|
|
1783
|
+
catch {
|
|
1784
|
+
throw new Error(`clone failed. check your network and try again, or clone manually and use --repo-path.`);
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
else {
|
|
1788
|
+
deps.writeStdout(`repo already exists at ${cloneTarget}, pulling latest...`);
|
|
1789
|
+
try {
|
|
1790
|
+
(0, child_process_1.execSync)("git pull --ff-only", { cwd: cloneTarget, stdio: "inherit" });
|
|
1791
|
+
}
|
|
1792
|
+
catch {
|
|
1793
|
+
deps.writeStdout("pull failed (may have local changes). continuing with existing code.");
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
deps.writeStdout("building...");
|
|
1797
|
+
try {
|
|
1798
|
+
(0, child_process_1.execSync)("npm install && npm run build", { cwd: cloneTarget, stdio: "inherit" });
|
|
1799
|
+
}
|
|
1800
|
+
catch {
|
|
1801
|
+
throw new Error(`build failed in ${cloneTarget}. check the output above.`);
|
|
1802
|
+
}
|
|
1803
|
+
return cloneTarget;
|
|
1804
|
+
}
|
|
1805
|
+
/* v8 ignore stop */
|
|
1729
1806
|
async function runOuroCli(args, deps = createDefaultOuroCliDeps()) {
|
|
1730
1807
|
if (args.length === 1 && (args[0] === "--help" || args[0] === "-h")) {
|
|
1731
1808
|
const text = usage();
|
|
@@ -1807,6 +1884,27 @@ async function runOuroCli(args, deps = createDefaultOuroCliDeps()) {
|
|
|
1807
1884
|
meta: { kind: command.kind },
|
|
1808
1885
|
});
|
|
1809
1886
|
if (command.kind === "daemon.up") {
|
|
1887
|
+
// ── dev mode delegation: ouro up from a dev repo delegates to installed binary ──
|
|
1888
|
+
// Only runs when detectMode is explicitly injected (via createDefaultOuroCliDeps or tests)
|
|
1889
|
+
if (deps.detectMode) {
|
|
1890
|
+
const runtimeMode = deps.detectMode();
|
|
1891
|
+
if (runtimeMode === "dev") {
|
|
1892
|
+
/* v8 ignore next -- defensive: getInstalledBinaryPath always injected in tests @preserve */
|
|
1893
|
+
const installedBinary = deps.getInstalledBinaryPath ? deps.getInstalledBinaryPath() : null;
|
|
1894
|
+
if (installedBinary) {
|
|
1895
|
+
deps.writeStdout("delegating to installed ouro...");
|
|
1896
|
+
/* v8 ignore next 3 -- defensive: execInstalledBinary always injected; missing branch unreachable @preserve */
|
|
1897
|
+
if (deps.execInstalledBinary) {
|
|
1898
|
+
deps.execInstalledBinary(installedBinary, args);
|
|
1899
|
+
}
|
|
1900
|
+
/* v8 ignore next 2 -- unreachable after exec replaces process @preserve */
|
|
1901
|
+
return "";
|
|
1902
|
+
}
|
|
1903
|
+
const message = "no installed version found. run: npx @ouro.bot/cli@alpha";
|
|
1904
|
+
deps.writeStdout(message);
|
|
1905
|
+
return message;
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1810
1908
|
const linkedVersionBeforeUp = deps.getCurrentCliVersion?.() ?? null;
|
|
1811
1909
|
// ── versioned CLI update check ──
|
|
1812
1910
|
if (deps.checkForCliUpdate) {
|
|
@@ -1900,6 +1998,69 @@ async function runOuroCli(args, deps = createDefaultOuroCliDeps()) {
|
|
|
1900
1998
|
deps.writeStdout(daemonResult.message);
|
|
1901
1999
|
return daemonResult.message;
|
|
1902
2000
|
}
|
|
2001
|
+
if (command.kind === "daemon.dev") {
|
|
2002
|
+
/* v8 ignore next -- defensive: existsSync always injected in tests @preserve */
|
|
2003
|
+
const checkExists = deps.existsSync ?? fs.existsSync;
|
|
2004
|
+
/* v8 ignore next -- repo resolution dispatched to v8-ignored helper @preserve */
|
|
2005
|
+
const repoCwd = resolveDevRepoCwd(command, checkExists, deps);
|
|
2006
|
+
const entryPath = path.join(repoCwd, "dist", "heart", "daemon", "daemon-entry.js");
|
|
2007
|
+
if (!checkExists(entryPath) || !checkExists(path.join(repoCwd, ".git"))) {
|
|
2008
|
+
const lines = [
|
|
2009
|
+
"no harness repo found at " + repoCwd,
|
|
2010
|
+
"",
|
|
2011
|
+
"options:",
|
|
2012
|
+
" ouro dev --repo-path /path/to/ouroboros use an existing checkout",
|
|
2013
|
+
" ouro dev --clone fresh clone to ~/Projects/ouroboros",
|
|
2014
|
+
" ouro dev --clone --clone-path /somewhere fresh clone to a custom path",
|
|
2015
|
+
"",
|
|
2016
|
+
"if you have the repo, cd into it and run: npm run build && ouro dev",
|
|
2017
|
+
];
|
|
2018
|
+
const message = lines.join("\n");
|
|
2019
|
+
deps.writeStdout(message);
|
|
2020
|
+
return message;
|
|
2021
|
+
}
|
|
2022
|
+
/* v8 ignore start -- defensive: ensureDaemonBootPersistence always injected in tests @preserve */
|
|
2023
|
+
if (deps.ensureDaemonBootPersistence) {
|
|
2024
|
+
try {
|
|
2025
|
+
await Promise.resolve(deps.ensureDaemonBootPersistence(deps.socketPath));
|
|
2026
|
+
/* v8 ignore next -- defensive: boot persistence error should not block dev mode @preserve */
|
|
2027
|
+
}
|
|
2028
|
+
catch (error) {
|
|
2029
|
+
(0, runtime_1.emitNervesEvent)({
|
|
2030
|
+
level: "warn",
|
|
2031
|
+
component: "daemon",
|
|
2032
|
+
event: "daemon.dev_boot_persistence_error",
|
|
2033
|
+
message: "failed to persist daemon boot startup in dev mode",
|
|
2034
|
+
meta: { error: error instanceof Error ? error.message : String(error), socketPath: deps.socketPath },
|
|
2035
|
+
});
|
|
2036
|
+
}
|
|
2037
|
+
/* v8 ignore stop */
|
|
2038
|
+
}
|
|
2039
|
+
// Always force-restart in dev mode — you rebuilt, you want this code running
|
|
2040
|
+
/* v8 ignore start -- dev force-restart: socket alive/stop/spawn tested via integration; tests inject mocks @preserve */
|
|
2041
|
+
const alive = await deps.checkSocketAlive(deps.socketPath);
|
|
2042
|
+
if (alive) {
|
|
2043
|
+
try {
|
|
2044
|
+
await deps.sendCommand(deps.socketPath, { kind: "daemon.stop" });
|
|
2045
|
+
}
|
|
2046
|
+
catch { /* already stopping */ }
|
|
2047
|
+
}
|
|
2048
|
+
deps.cleanupStaleSocket(deps.socketPath);
|
|
2049
|
+
const devEntry = path.join(repoCwd, "dist", "heart", "daemon", "daemon-entry.js");
|
|
2050
|
+
const startDevDaemon = deps.startDaemonProcess === defaultStartDaemonProcess
|
|
2051
|
+
? async (sp) => {
|
|
2052
|
+
const child = (0, child_process_1.spawn)("node", [devEntry, "--socket", sp], { detached: true, stdio: "ignore" });
|
|
2053
|
+
child.unref();
|
|
2054
|
+
return { pid: child.pid ?? null };
|
|
2055
|
+
}
|
|
2056
|
+
: deps.startDaemonProcess;
|
|
2057
|
+
/* v8 ignore stop */
|
|
2058
|
+
const started = await startDevDaemon(deps.socketPath);
|
|
2059
|
+
/* v8 ignore next -- defensive: pid is null only when spawn fails silently @preserve */
|
|
2060
|
+
const message = `daemon running in dev mode from ${repoCwd} (pid ${started.pid ?? "unknown"})`;
|
|
2061
|
+
deps.writeStdout(message);
|
|
2062
|
+
return message;
|
|
2063
|
+
}
|
|
1903
2064
|
// ── rollback command (local, no daemon socket needed for symlinks) ──
|
|
1904
2065
|
/* v8 ignore start -- rollback/versions: tested via daemon-cli-rollback/versions tests @preserve */
|
|
1905
2066
|
if (command.kind === "rollback") {
|
|
@@ -66,6 +66,16 @@ const mode = (0, runtime_mode_1.detectRuntimeMode)((0, identity_1.getRepoRoot)()
|
|
|
66
66
|
message: "starting daemon entrypoint",
|
|
67
67
|
meta: { socketPath, entryPath, mode },
|
|
68
68
|
});
|
|
69
|
+
/* v8 ignore next -- dev-mode indicator: false branch (production) tested in daemon-boot-updates.test.ts @preserve */
|
|
70
|
+
if (mode === "dev") {
|
|
71
|
+
const repoRoot = (0, identity_1.getRepoRoot)();
|
|
72
|
+
(0, runtime_1.emitNervesEvent)({
|
|
73
|
+
component: "daemon",
|
|
74
|
+
event: "daemon.dev_mode_indicator",
|
|
75
|
+
message: `[dev] running from ${repoRoot}`,
|
|
76
|
+
meta: { repoRoot },
|
|
77
|
+
});
|
|
78
|
+
}
|
|
69
79
|
const managedAgents = (0, agent_discovery_1.listEnabledBundleAgents)();
|
|
70
80
|
const processManager = new process_manager_1.DaemonProcessManager({
|
|
71
81
|
agents: managedAgents.map((agent) => ({
|
|
@@ -103,6 +113,7 @@ const daemon = new daemon_1.OuroDaemon({
|
|
|
103
113
|
scheduler,
|
|
104
114
|
healthMonitor,
|
|
105
115
|
router,
|
|
116
|
+
mode,
|
|
106
117
|
});
|
|
107
118
|
void daemon.start().catch(async () => {
|
|
108
119
|
(0, runtime_1.emitNervesEvent)({
|
|
@@ -174,6 +174,7 @@ class OuroDaemon {
|
|
|
174
174
|
router;
|
|
175
175
|
senseManager;
|
|
176
176
|
bundlesRoot;
|
|
177
|
+
mode;
|
|
177
178
|
server = null;
|
|
178
179
|
constructor(options) {
|
|
179
180
|
this.socketPath = options.socketPath;
|
|
@@ -183,6 +184,7 @@ class OuroDaemon {
|
|
|
183
184
|
this.router = options.router;
|
|
184
185
|
this.senseManager = options.senseManager ?? null;
|
|
185
186
|
this.bundlesRoot = options.bundlesRoot ?? (0, identity_1.getAgentBundlesRoot)();
|
|
187
|
+
this.mode = options.mode ?? "production";
|
|
186
188
|
}
|
|
187
189
|
async start() {
|
|
188
190
|
if (this.server)
|
|
@@ -198,39 +200,50 @@ class OuroDaemon {
|
|
|
198
200
|
const currentVersion = (0, bundle_manifest_1.getPackageVersion)();
|
|
199
201
|
await (0, update_hooks_1.applyPendingUpdates)(this.bundlesRoot, currentVersion);
|
|
200
202
|
// Start periodic update checker (polls npm registry every 30 minutes)
|
|
203
|
+
// Skip in dev mode — dev builds should not auto-update from npm
|
|
201
204
|
const bundlesRoot = this.bundlesRoot;
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
try {
|
|
220
|
-
const resolved = (0, child_process_1.execSync)(`node -e "console.log(require.resolve('@ouro.bot/cli/package.json'))"`, { encoding: "utf-8" }).trim();
|
|
221
|
-
return resolved ? path.dirname(resolved) : null;
|
|
222
|
-
}
|
|
223
|
-
catch {
|
|
224
|
-
return null;
|
|
225
|
-
}
|
|
205
|
+
if (this.mode === "dev") {
|
|
206
|
+
(0, runtime_1.emitNervesEvent)({
|
|
207
|
+
component: "daemon",
|
|
208
|
+
event: "daemon.update_checker_skip",
|
|
209
|
+
message: "skipping update checker in dev mode",
|
|
210
|
+
meta: { reason: "dev mode" },
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
const daemon = this;
|
|
215
|
+
(0, update_checker_1.startUpdateChecker)({
|
|
216
|
+
currentVersion,
|
|
217
|
+
deps: {
|
|
218
|
+
distTag: "alpha",
|
|
219
|
+
fetchRegistryJson: /* v8 ignore next -- integration: real HTTP fetch @preserve */ async () => {
|
|
220
|
+
const res = await fetch("https://registry.npmjs.org/@ouro.bot/cli");
|
|
221
|
+
return res.json();
|
|
226
222
|
},
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
223
|
+
},
|
|
224
|
+
onUpdate: /* v8 ignore start -- integration: real npm install + process spawn @preserve */ async (result) => {
|
|
225
|
+
if (!result.latestVersion)
|
|
226
|
+
return;
|
|
227
|
+
await (0, staged_restart_1.performStagedRestart)(result.latestVersion, {
|
|
228
|
+
execSync: (cmd) => (0, child_process_1.execSync)(cmd, { stdio: "inherit" }),
|
|
229
|
+
spawnSync: child_process_1.spawnSync,
|
|
230
|
+
resolveNewCodePath: (_version) => {
|
|
231
|
+
try {
|
|
232
|
+
const resolved = (0, child_process_1.execSync)(`node -e "console.log(require.resolve('@ouro.bot/cli/package.json'))"`, { encoding: "utf-8" }).trim();
|
|
233
|
+
return resolved ? path.dirname(resolved) : null;
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
gracefulShutdown: () => daemon.stop(),
|
|
240
|
+
nodePath: process.execPath,
|
|
241
|
+
bundlesRoot,
|
|
242
|
+
});
|
|
243
|
+
},
|
|
244
|
+
/* v8 ignore stop */
|
|
245
|
+
});
|
|
246
|
+
}
|
|
234
247
|
// Pre-initialize MCP connections so they're ready for the first command (non-blocking)
|
|
235
248
|
/* v8 ignore next -- catch callback: getSharedMcpManager logs errors internally @preserve */
|
|
236
249
|
(0, mcp_manager_1.getSharedMcpManager)().catch(() => { });
|
package/dist/heart/tool-loop.js
CHANGED
|
@@ -178,8 +178,12 @@ function recordToolOutcome(state, toolName, args, result, success) {
|
|
|
178
178
|
state.history.splice(0, state.history.length - exports.TOOL_LOOP_HISTORY_LIMIT);
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
|
+
// Tools that must never be blocked by the circuit breaker.
|
|
182
|
+
// settle = end the turn, surface = deliver results outward.
|
|
183
|
+
// Blocking these traps the agent: it can think all it wants but can never speak.
|
|
184
|
+
const CIRCUIT_BREAKER_EXEMPT = new Set(["settle", "surface"]);
|
|
181
185
|
function detectToolLoop(state, toolName, args) {
|
|
182
|
-
if (state.history.length >= exports.GLOBAL_CIRCUIT_BREAKER_LIMIT) {
|
|
186
|
+
if (state.history.length >= exports.GLOBAL_CIRCUIT_BREAKER_LIMIT && !CIRCUIT_BREAKER_EXEMPT.has(toolName)) {
|
|
183
187
|
return emitDetection("global_circuit_breaker", toolName, state.history.length, `this turn has already made ${state.history.length} tool calls. stop thrashing, use the current evidence, and either change approach or answer truthfully with the best grounded status.`);
|
|
184
188
|
}
|
|
185
189
|
const callHash = digest(normalizeArgs(toolName, args));
|