@ouro.bot/cli 0.1.0-alpha.5 → 0.1.0-alpha.51

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.
Files changed (106) hide show
  1. package/AdoptionSpecialist.ouro/agent.json +70 -9
  2. package/AdoptionSpecialist.ouro/psyche/SOUL.md +5 -2
  3. package/AdoptionSpecialist.ouro/psyche/identities/monty.md +2 -2
  4. package/README.md +117 -188
  5. package/assets/ouroboros.png +0 -0
  6. package/changelog.json +252 -0
  7. package/dist/heart/active-work.js +157 -0
  8. package/dist/heart/bridges/manager.js +358 -0
  9. package/dist/heart/bridges/state-machine.js +135 -0
  10. package/dist/heart/bridges/store.js +123 -0
  11. package/dist/heart/config.js +81 -8
  12. package/dist/heart/core.js +172 -52
  13. package/dist/heart/daemon/agent-discovery.js +81 -0
  14. package/dist/heart/daemon/daemon-cli.js +1099 -164
  15. package/dist/heart/daemon/daemon-entry.js +14 -5
  16. package/dist/heart/daemon/daemon-runtime-sync.js +90 -0
  17. package/dist/heart/daemon/daemon.js +184 -9
  18. package/dist/heart/daemon/hatch-animation.js +10 -3
  19. package/dist/heart/daemon/hatch-flow.js +3 -20
  20. package/dist/heart/daemon/hooks/bundle-meta.js +92 -0
  21. package/dist/heart/daemon/launchd.js +151 -0
  22. package/dist/heart/daemon/message-router.js +15 -6
  23. package/dist/heart/daemon/ouro-bot-entry.js +0 -0
  24. package/dist/heart/daemon/ouro-bot-global-installer.js +128 -0
  25. package/dist/heart/daemon/ouro-entry.js +0 -0
  26. package/dist/heart/daemon/ouro-path-installer.js +178 -0
  27. package/dist/heart/daemon/ouro-uti.js +11 -2
  28. package/dist/heart/daemon/process-manager.js +1 -1
  29. package/dist/heart/daemon/run-hooks.js +37 -0
  30. package/dist/heart/daemon/runtime-metadata.js +118 -0
  31. package/dist/heart/daemon/sense-manager.js +290 -0
  32. package/dist/heart/daemon/socket-client.js +202 -0
  33. package/dist/heart/daemon/specialist-orchestrator.js +53 -84
  34. package/dist/heart/daemon/specialist-prompt.js +64 -5
  35. package/dist/heart/daemon/specialist-tools.js +213 -58
  36. package/dist/heart/daemon/staged-restart.js +114 -0
  37. package/dist/heart/daemon/subagent-installer.js +48 -7
  38. package/dist/heart/daemon/thoughts.js +379 -0
  39. package/dist/heart/daemon/update-checker.js +111 -0
  40. package/dist/heart/daemon/update-hooks.js +138 -0
  41. package/dist/heart/daemon/wrapper-publish-guard.js +86 -0
  42. package/dist/heart/delegation.js +62 -0
  43. package/dist/heart/identity.js +82 -4
  44. package/dist/heart/kicks.js +1 -19
  45. package/dist/heart/model-capabilities.js +40 -0
  46. package/dist/heart/progress-story.js +42 -0
  47. package/dist/heart/providers/anthropic.js +72 -7
  48. package/dist/heart/providers/azure.js +8 -1
  49. package/dist/heart/providers/minimax.js +4 -0
  50. package/dist/heart/providers/openai-codex.js +10 -1
  51. package/dist/heart/sense-truth.js +61 -0
  52. package/dist/heart/session-activity.js +169 -0
  53. package/dist/heart/session-recall.js +116 -0
  54. package/dist/heart/streaming.js +100 -22
  55. package/dist/heart/turn-coordinator.js +28 -0
  56. package/dist/mind/associative-recall.js +14 -2
  57. package/dist/mind/bundle-manifest.js +70 -0
  58. package/dist/mind/context.js +27 -11
  59. package/dist/mind/first-impressions.js +16 -2
  60. package/dist/mind/friends/channel.js +43 -0
  61. package/dist/mind/friends/store-file.js +19 -0
  62. package/dist/mind/friends/types.js +9 -1
  63. package/dist/mind/memory.js +10 -3
  64. package/dist/mind/pending.js +72 -9
  65. package/dist/mind/phrases.js +1 -0
  66. package/dist/mind/prompt.js +275 -77
  67. package/dist/mind/token-estimate.js +8 -12
  68. package/dist/nerves/cli-logging.js +15 -2
  69. package/dist/repertoire/ado-client.js +4 -2
  70. package/dist/repertoire/coding/feedback.js +134 -0
  71. package/dist/repertoire/coding/index.js +4 -1
  72. package/dist/repertoire/coding/manager.js +62 -4
  73. package/dist/repertoire/coding/spawner.js +3 -3
  74. package/dist/repertoire/coding/tools.js +41 -2
  75. package/dist/repertoire/data/ado-endpoints.json +188 -0
  76. package/dist/repertoire/tasks/board.js +12 -0
  77. package/dist/repertoire/tasks/index.js +23 -9
  78. package/dist/repertoire/tasks/transitions.js +1 -2
  79. package/dist/repertoire/tools-base.js +496 -245
  80. package/dist/repertoire/tools-bluebubbles.js +93 -0
  81. package/dist/repertoire/tools-teams.js +58 -25
  82. package/dist/repertoire/tools.js +93 -49
  83. package/dist/senses/bluebubbles-client.js +484 -0
  84. package/dist/senses/bluebubbles-entry.js +13 -0
  85. package/dist/senses/bluebubbles-inbound-log.js +109 -0
  86. package/dist/senses/bluebubbles-media.js +338 -0
  87. package/dist/senses/bluebubbles-model.js +261 -0
  88. package/dist/senses/bluebubbles-mutation-log.js +116 -0
  89. package/dist/senses/bluebubbles-runtime-state.js +109 -0
  90. package/dist/senses/bluebubbles-session-cleanup.js +72 -0
  91. package/dist/senses/bluebubbles.js +1142 -0
  92. package/dist/senses/cli.js +340 -138
  93. package/dist/senses/continuity.js +94 -0
  94. package/dist/senses/debug-activity.js +148 -0
  95. package/dist/senses/inner-dialog-worker.js +47 -18
  96. package/dist/senses/inner-dialog.js +330 -84
  97. package/dist/senses/pipeline.js +256 -0
  98. package/dist/senses/teams.js +541 -129
  99. package/dist/senses/trust-gate.js +112 -2
  100. package/package.json +14 -3
  101. package/subagents/README.md +46 -33
  102. package/subagents/work-doer.md +28 -24
  103. package/subagents/work-merger.md +24 -30
  104. package/subagents/work-planner.md +44 -27
  105. package/dist/heart/daemon/specialist-session.js +0 -142
  106. package/dist/inner-worker-entry.js +0 -4
@@ -0,0 +1,256 @@
1
+ "use strict";
2
+ // Shared per-turn pipeline for all senses.
3
+ // Senses are thin transport adapters; this module owns the common lifecycle:
4
+ // resolve friend -> trust gate -> load session -> drain pending -> runAgent -> postTurn -> token accumulation.
5
+ //
6
+ // Transport-level concerns (BB API calls, Teams cards, readline) stay in sense adapters.
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.handleInboundTurn = handleInboundTurn;
9
+ const runtime_1 = require("../nerves/runtime");
10
+ const continuity_1 = require("./continuity");
11
+ const manager_1 = require("../heart/bridges/manager");
12
+ const identity_1 = require("../heart/identity");
13
+ const tasks_1 = require("../repertoire/tasks");
14
+ const session_activity_1 = require("../heart/session-activity");
15
+ const active_work_1 = require("../heart/active-work");
16
+ const delegation_1 = require("../heart/delegation");
17
+ const thoughts_1 = require("../heart/daemon/thoughts");
18
+ const pending_1 = require("../mind/pending");
19
+ function emptyTaskBoard() {
20
+ return {
21
+ compact: "",
22
+ full: "",
23
+ byStatus: {
24
+ drafting: [],
25
+ processing: [],
26
+ validating: [],
27
+ collaborating: [],
28
+ paused: [],
29
+ blocked: [],
30
+ done: [],
31
+ },
32
+ actionRequired: [],
33
+ unresolvedDependencies: [],
34
+ activeSessions: [],
35
+ activeBridges: [],
36
+ };
37
+ }
38
+ function readInnerWorkState() {
39
+ try {
40
+ const agentRoot = (0, identity_1.getAgentRoot)();
41
+ const pendingDir = (0, pending_1.getInnerDialogPendingDir)((0, identity_1.getAgentName)());
42
+ const sessionPath = (0, thoughts_1.getInnerDialogSessionPath)(agentRoot);
43
+ const status = (0, thoughts_1.readInnerDialogStatus)(sessionPath, pendingDir);
44
+ return {
45
+ status: status.processing === "started" ? "running" : "idle",
46
+ hasPending: status.queue !== "clear",
47
+ };
48
+ }
49
+ catch {
50
+ return {
51
+ status: "idle",
52
+ hasPending: false,
53
+ };
54
+ }
55
+ }
56
+ // ── Pipeline ──────────────────────────────────────────────────────
57
+ async function handleInboundTurn(input) {
58
+ // Step 1: Resolve friend
59
+ const resolvedContext = await input.friendResolver.resolve();
60
+ (0, runtime_1.emitNervesEvent)({
61
+ component: "senses",
62
+ event: "senses.pipeline_start",
63
+ message: "inbound turn pipeline started",
64
+ meta: {
65
+ channel: input.channel,
66
+ friendId: resolvedContext.friend.id,
67
+ senseType: input.capabilities.senseType,
68
+ },
69
+ });
70
+ // Step 2: Trust gate
71
+ const gateInput = {
72
+ friend: resolvedContext.friend,
73
+ provider: input.provider ?? "local",
74
+ externalId: input.externalId ?? "",
75
+ tenantId: input.tenantId,
76
+ channel: input.channel,
77
+ senseType: input.capabilities.senseType,
78
+ isGroupChat: input.isGroupChat ?? false,
79
+ groupHasFamilyMember: input.groupHasFamilyMember ?? false,
80
+ hasExistingGroupWithFamily: input.hasExistingGroupWithFamily ?? false,
81
+ };
82
+ const gateResult = input.enforceTrustGate(gateInput);
83
+ // Gate rejection: return early, no agent turn
84
+ if (!gateResult.allowed) {
85
+ (0, runtime_1.emitNervesEvent)({
86
+ component: "senses",
87
+ event: "senses.pipeline_gate_reject",
88
+ message: "trust gate rejected inbound turn",
89
+ meta: {
90
+ channel: input.channel,
91
+ friendId: resolvedContext.friend.id,
92
+ reason: gateResult.reason,
93
+ },
94
+ });
95
+ return {
96
+ resolvedContext,
97
+ gateResult,
98
+ };
99
+ }
100
+ // Step 3: Load/create session
101
+ const session = await input.sessionLoader.loadOrCreate();
102
+ const sessionMessages = session.messages;
103
+ let mustResolveBeforeHandoff = (0, continuity_1.resolveMustResolveBeforeHandoff)(session.state?.mustResolveBeforeHandoff === true, input.continuityIngressTexts);
104
+ const lastFriendActivityAt = input.channel === "inner"
105
+ ? session.state?.lastFriendActivityAt
106
+ : new Date().toISOString();
107
+ const currentObligation = input.continuityIngressTexts
108
+ ?.map((text) => text.trim())
109
+ .filter((text) => text.length > 0)
110
+ .at(-1);
111
+ const currentSession = {
112
+ friendId: resolvedContext.friend.id,
113
+ channel: input.channel,
114
+ key: input.sessionKey ?? "session",
115
+ sessionPath: session.sessionPath,
116
+ };
117
+ const activeBridges = (0, manager_1.createBridgeManager)().findBridgesForSession({
118
+ friendId: currentSession.friendId,
119
+ channel: currentSession.channel,
120
+ key: currentSession.key,
121
+ });
122
+ const bridgeContext = (0, manager_1.formatBridgeContext)(activeBridges) || undefined;
123
+ let sessionActivity = [];
124
+ try {
125
+ const agentRoot = (0, identity_1.getAgentRoot)();
126
+ sessionActivity = (0, session_activity_1.listSessionActivity)({
127
+ sessionsDir: `${agentRoot}/state/sessions`,
128
+ friendsDir: `${agentRoot}/friends`,
129
+ agentName: (0, identity_1.getAgentName)(),
130
+ currentSession: {
131
+ friendId: currentSession.friendId,
132
+ channel: currentSession.channel,
133
+ key: currentSession.key,
134
+ },
135
+ });
136
+ }
137
+ catch {
138
+ sessionActivity = [];
139
+ }
140
+ const activeWorkFrame = (0, active_work_1.buildActiveWorkFrame)({
141
+ currentSession,
142
+ currentObligation,
143
+ mustResolveBeforeHandoff,
144
+ inner: readInnerWorkState(),
145
+ bridges: activeBridges,
146
+ taskBoard: (() => {
147
+ try {
148
+ return (0, tasks_1.getTaskModule)().getBoard();
149
+ }
150
+ catch {
151
+ return emptyTaskBoard();
152
+ }
153
+ })(),
154
+ friendActivity: sessionActivity,
155
+ });
156
+ const delegationDecision = (0, delegation_1.decideDelegation)({
157
+ channel: input.channel,
158
+ ingressTexts: input.continuityIngressTexts ?? [],
159
+ activeWork: activeWorkFrame,
160
+ mustResolveBeforeHandoff,
161
+ });
162
+ // Step 4: Drain deferred friend returns, then ordinary per-session pending.
163
+ const deferredReturns = input.channel === "inner"
164
+ ? []
165
+ : (input.drainDeferredReturns?.(resolvedContext.friend.id) ?? []);
166
+ const sessionPending = input.drainPending(input.pendingDir);
167
+ const pending = [...deferredReturns, ...sessionPending];
168
+ // Assemble messages: session messages + pending (formatted) + inbound user messages
169
+ if (pending.length > 0) {
170
+ // Format pending messages and prepend to the user content
171
+ const pendingSection = pending
172
+ .map((msg) => `[pending from ${msg.from}]: ${msg.content}`)
173
+ .join("\n");
174
+ // If there are inbound user messages, prepend pending to the first one
175
+ if (input.messages.length > 0) {
176
+ const firstMsg = input.messages[0];
177
+ if (firstMsg.role === "user") {
178
+ if (typeof firstMsg.content === "string") {
179
+ input.messages[0] = {
180
+ ...firstMsg,
181
+ content: `## pending messages\n${pendingSection}\n\n${firstMsg.content}`,
182
+ };
183
+ }
184
+ else {
185
+ input.messages[0] = {
186
+ ...firstMsg,
187
+ content: [
188
+ { type: "text", text: `## pending messages\n${pendingSection}\n\n` },
189
+ ...firstMsg.content,
190
+ ],
191
+ };
192
+ }
193
+ }
194
+ }
195
+ }
196
+ // Append user messages from the inbound turn
197
+ for (const msg of input.messages) {
198
+ sessionMessages.push(msg);
199
+ }
200
+ // Step 5: runAgent
201
+ const existingToolContext = input.runAgentOptions?.toolContext;
202
+ const runAgentOptions = {
203
+ ...input.runAgentOptions,
204
+ bridgeContext,
205
+ activeWorkFrame,
206
+ delegationDecision,
207
+ currentSessionKey: currentSession.key,
208
+ currentObligation,
209
+ mustResolveBeforeHandoff,
210
+ setMustResolveBeforeHandoff: (value) => {
211
+ mustResolveBeforeHandoff = value;
212
+ },
213
+ toolContext: {
214
+ /* v8 ignore next -- default no-op signin satisfies interface; real signin injected by sense adapter @preserve */
215
+ signin: async () => undefined,
216
+ ...existingToolContext,
217
+ context: resolvedContext,
218
+ friendStore: input.friendStore,
219
+ currentSession,
220
+ activeBridges,
221
+ },
222
+ };
223
+ const result = await input.runAgent(sessionMessages, input.callbacks, input.channel, input.signal, runAgentOptions);
224
+ // Step 6: postTurn
225
+ const continuingState = {
226
+ ...(mustResolveBeforeHandoff ? { mustResolveBeforeHandoff: true } : {}),
227
+ ...(typeof lastFriendActivityAt === "string" ? { lastFriendActivityAt } : {}),
228
+ };
229
+ const nextState = result.outcome === "complete" || result.outcome === "blocked" || result.outcome === "superseded"
230
+ ? (typeof lastFriendActivityAt === "string"
231
+ ? { lastFriendActivityAt }
232
+ : undefined)
233
+ : (Object.keys(continuingState).length > 0 ? continuingState : undefined);
234
+ input.postTurn(sessionMessages, session.sessionPath, result.usage, undefined, nextState);
235
+ // Step 7: Token accumulation
236
+ await input.accumulateFriendTokens(input.friendStore, resolvedContext.friend.id, result.usage);
237
+ (0, runtime_1.emitNervesEvent)({
238
+ component: "senses",
239
+ event: "senses.pipeline_end",
240
+ message: "inbound turn pipeline completed",
241
+ meta: {
242
+ channel: input.channel,
243
+ friendId: resolvedContext.friend.id,
244
+ },
245
+ });
246
+ return {
247
+ resolvedContext,
248
+ gateResult,
249
+ usage: result.usage,
250
+ turnOutcome: result.outcome,
251
+ completion: result.completion,
252
+ sessionPath: session.sessionPath,
253
+ messages: sessionMessages,
254
+ drainedPending: pending,
255
+ };
256
+ }