@ouro.bot/cli 0.1.0-alpha.6 → 0.1.0-alpha.61

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