@jungjaehoon/mama-os 0.20.0 → 0.21.0

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 (296) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/dist/agent/agent-loop.d.ts +2 -1
  3. package/dist/agent/agent-loop.d.ts.map +1 -1
  4. package/dist/agent/agent-loop.js +65 -19
  5. package/dist/agent/agent-loop.js.map +1 -1
  6. package/dist/agent/claude-cli-wrapper.d.ts.map +1 -1
  7. package/dist/agent/claude-cli-wrapper.js +6 -2
  8. package/dist/agent/claude-cli-wrapper.js.map +1 -1
  9. package/dist/agent/cli-arg-redaction.d.ts +2 -0
  10. package/dist/agent/cli-arg-redaction.d.ts.map +1 -0
  11. package/dist/agent/cli-arg-redaction.js +18 -0
  12. package/dist/agent/cli-arg-redaction.js.map +1 -0
  13. package/dist/agent/code-act/constants.d.ts +1 -1
  14. package/dist/agent/code-act/constants.d.ts.map +1 -1
  15. package/dist/agent/code-act/constants.js +24 -3
  16. package/dist/agent/code-act/constants.js.map +1 -1
  17. package/dist/agent/code-act/host-bridge.d.ts +2 -0
  18. package/dist/agent/code-act/host-bridge.d.ts.map +1 -1
  19. package/dist/agent/code-act/host-bridge.js +43 -7
  20. package/dist/agent/code-act/host-bridge.js.map +1 -1
  21. package/dist/agent/code-act/type-definition-generator.d.ts +2 -2
  22. package/dist/agent/code-act/type-definition-generator.d.ts.map +1 -1
  23. package/dist/agent/code-act/type-definition-generator.js +29 -4
  24. package/dist/agent/code-act/type-definition-generator.js.map +1 -1
  25. package/dist/agent/codex-home.d.ts +1 -1
  26. package/dist/agent/codex-home.d.ts.map +1 -1
  27. package/dist/agent/codex-home.js +43 -1
  28. package/dist/agent/codex-home.js.map +1 -1
  29. package/dist/agent/codex-mcp-process.d.ts +2 -0
  30. package/dist/agent/codex-mcp-process.d.ts.map +1 -1
  31. package/dist/agent/codex-mcp-process.js +1 -1
  32. package/dist/agent/codex-mcp-process.js.map +1 -1
  33. package/dist/agent/context-compile-service.d.ts +47 -0
  34. package/dist/agent/context-compile-service.d.ts.map +1 -0
  35. package/dist/agent/context-compile-service.js +435 -0
  36. package/dist/agent/context-compile-service.js.map +1 -0
  37. package/dist/agent/gateway-tool-executor.d.ts +16 -11
  38. package/dist/agent/gateway-tool-executor.d.ts.map +1 -1
  39. package/dist/agent/gateway-tool-executor.js +539 -109
  40. package/dist/agent/gateway-tool-executor.js.map +1 -1
  41. package/dist/agent/gateway-tools.md +4 -3
  42. package/dist/agent/mama-tool-handlers.d.ts.map +1 -1
  43. package/dist/agent/mama-tool-handlers.js +37 -1
  44. package/dist/agent/mama-tool-handlers.js.map +1 -1
  45. package/dist/agent/managed-agent-runtime-sync.d.ts.map +1 -1
  46. package/dist/agent/managed-agent-runtime-sync.js +2 -4
  47. package/dist/agent/managed-agent-runtime-sync.js.map +1 -1
  48. package/dist/agent/managed-agent-validation.d.ts.map +1 -1
  49. package/dist/agent/managed-agent-validation.js +2 -1
  50. package/dist/agent/managed-agent-validation.js.map +1 -1
  51. package/dist/agent/os-agent-capabilities.md +13 -12
  52. package/dist/agent/persistent-cli-process.d.ts +1 -0
  53. package/dist/agent/persistent-cli-process.d.ts.map +1 -1
  54. package/dist/agent/persistent-cli-process.js +6 -1
  55. package/dist/agent/persistent-cli-process.js.map +1 -1
  56. package/dist/agent/tool-registry.d.ts.map +1 -1
  57. package/dist/agent/tool-registry.js +10 -2
  58. package/dist/agent/tool-registry.js.map +1 -1
  59. package/dist/agent/types.d.ts +30 -5
  60. package/dist/agent/types.d.ts.map +1 -1
  61. package/dist/agent/types.js.map +1 -1
  62. package/dist/api/agent-context-handler.d.ts +10 -0
  63. package/dist/api/agent-context-handler.d.ts.map +1 -0
  64. package/dist/api/agent-context-handler.js +216 -0
  65. package/dist/api/agent-context-handler.js.map +1 -0
  66. package/dist/api/agent-handler.d.ts +2 -0
  67. package/dist/api/agent-handler.d.ts.map +1 -1
  68. package/dist/api/agent-handler.js +14 -7
  69. package/dist/api/agent-handler.js.map +1 -1
  70. package/dist/api/graph-api-types.d.ts +6 -1
  71. package/dist/api/graph-api-types.d.ts.map +1 -1
  72. package/dist/api/graph-api.d.ts +2 -1
  73. package/dist/api/graph-api.d.ts.map +1 -1
  74. package/dist/api/graph-api.js +193 -11
  75. package/dist/api/graph-api.js.map +1 -1
  76. package/dist/api/index.d.ts +11 -1
  77. package/dist/api/index.d.ts.map +1 -1
  78. package/dist/api/index.js +13 -2
  79. package/dist/api/index.js.map +1 -1
  80. package/dist/api/intelligence-handler.d.ts +17 -6
  81. package/dist/api/intelligence-handler.d.ts.map +1 -1
  82. package/dist/api/intelligence-handler.js +59 -1
  83. package/dist/api/intelligence-handler.js.map +1 -1
  84. package/dist/api/operator-handler.d.ts +17 -0
  85. package/dist/api/operator-handler.d.ts.map +1 -0
  86. package/dist/api/operator-handler.js +88 -0
  87. package/dist/api/operator-handler.js.map +1 -0
  88. package/dist/api/report-handler.d.ts +7 -0
  89. package/dist/api/report-handler.d.ts.map +1 -1
  90. package/dist/api/report-handler.js +30 -0
  91. package/dist/api/report-handler.js.map +1 -1
  92. package/dist/api/report-persistence.d.ts +17 -0
  93. package/dist/api/report-persistence.d.ts.map +1 -0
  94. package/dist/api/report-persistence.js +91 -0
  95. package/dist/api/report-persistence.js.map +1 -0
  96. package/dist/cli/commands/start.d.ts +45 -0
  97. package/dist/cli/commands/start.d.ts.map +1 -1
  98. package/dist/cli/commands/start.js +610 -197
  99. package/dist/cli/commands/start.js.map +1 -1
  100. package/dist/cli/config/config-manager.d.ts.map +1 -1
  101. package/dist/cli/config/config-manager.js +171 -4
  102. package/dist/cli/config/config-manager.js.map +1 -1
  103. package/dist/cli/config/types.d.ts +25 -5
  104. package/dist/cli/config/types.d.ts.map +1 -1
  105. package/dist/cli/config/types.js +5 -0
  106. package/dist/cli/config/types.js.map +1 -1
  107. package/dist/cli/runtime/agent-loop-init.d.ts +3 -0
  108. package/dist/cli/runtime/agent-loop-init.d.ts.map +1 -1
  109. package/dist/cli/runtime/agent-loop-init.js +2 -0
  110. package/dist/cli/runtime/agent-loop-init.js.map +1 -1
  111. package/dist/cli/runtime/api-routes-init.d.ts.map +1 -1
  112. package/dist/cli/runtime/api-routes-init.js +396 -259
  113. package/dist/cli/runtime/api-routes-init.js.map +1 -1
  114. package/dist/cli/runtime/api-server-init.d.ts +2 -0
  115. package/dist/cli/runtime/api-server-init.d.ts.map +1 -1
  116. package/dist/cli/runtime/api-server-init.js +19 -8
  117. package/dist/cli/runtime/api-server-init.js.map +1 -1
  118. package/dist/cli/runtime/connector-init.d.ts +26 -7
  119. package/dist/cli/runtime/connector-init.d.ts.map +1 -1
  120. package/dist/cli/runtime/connector-init.js +79 -16
  121. package/dist/cli/runtime/connector-init.js.map +1 -1
  122. package/dist/cli/runtime/envelope-bootstrap.d.ts.map +1 -1
  123. package/dist/cli/runtime/envelope-bootstrap.js +8 -2
  124. package/dist/cli/runtime/envelope-bootstrap.js.map +1 -1
  125. package/dist/cli/runtime/gateway-init.d.ts +1 -1
  126. package/dist/cli/runtime/gateway-init.d.ts.map +1 -1
  127. package/dist/cli/runtime/gateway-init.js.map +1 -1
  128. package/dist/cli/runtime/message-router-config.d.ts +4 -0
  129. package/dist/cli/runtime/message-router-config.d.ts.map +1 -0
  130. package/dist/cli/runtime/message-router-config.js +11 -0
  131. package/dist/cli/runtime/message-router-config.js.map +1 -0
  132. package/dist/cli/runtime/scheduler-init.d.ts.map +1 -1
  133. package/dist/cli/runtime/scheduler-init.js +12 -12
  134. package/dist/cli/runtime/scheduler-init.js.map +1 -1
  135. package/dist/cli/runtime/utilities.js +2 -2
  136. package/dist/cli/runtime/utilities.js.map +1 -1
  137. package/dist/connectors/framework/polling-scheduler.d.ts.map +1 -1
  138. package/dist/connectors/framework/polling-scheduler.js +101 -5
  139. package/dist/connectors/framework/polling-scheduler.js.map +1 -1
  140. package/dist/connectors/kagemusha/query-tools.d.ts.map +1 -1
  141. package/dist/connectors/kagemusha/query-tools.js +14 -3
  142. package/dist/connectors/kagemusha/query-tools.js.map +1 -1
  143. package/dist/db/agent-store.d.ts.map +1 -1
  144. package/dist/db/agent-store.js +10 -3
  145. package/dist/db/agent-store.js.map +1 -1
  146. package/dist/db/migrations/wiki-artifacts.d.ts +3 -0
  147. package/dist/db/migrations/wiki-artifacts.d.ts.map +1 -0
  148. package/dist/db/migrations/wiki-artifacts.js +24 -0
  149. package/dist/db/migrations/wiki-artifacts.js.map +1 -0
  150. package/dist/envelope/enforcer.d.ts.map +1 -1
  151. package/dist/envelope/enforcer.js +48 -4
  152. package/dist/envelope/enforcer.js.map +1 -1
  153. package/dist/envelope/key-provider.d.ts +1 -0
  154. package/dist/envelope/key-provider.d.ts.map +1 -1
  155. package/dist/envelope/key-provider.js +86 -0
  156. package/dist/envelope/key-provider.js.map +1 -1
  157. package/dist/gateways/message-router.d.ts.map +1 -1
  158. package/dist/gateways/message-router.js +15 -3
  159. package/dist/gateways/message-router.js.map +1 -1
  160. package/dist/gateways/types.d.ts +5 -1
  161. package/dist/gateways/types.d.ts.map +1 -1
  162. package/dist/mcp/code-act-server.js +50 -7
  163. package/dist/mcp/code-act-server.js.map +1 -1
  164. package/dist/memory/raw-backed-memory-ingest.d.ts +26 -0
  165. package/dist/memory/raw-backed-memory-ingest.d.ts.map +1 -0
  166. package/dist/memory/raw-backed-memory-ingest.js +214 -0
  167. package/dist/memory/raw-backed-memory-ingest.js.map +1 -0
  168. package/dist/memory/scope-context.js +1 -1
  169. package/dist/multi-agent/agent-event-bus.d.ts +10 -0
  170. package/dist/multi-agent/agent-event-bus.d.ts.map +1 -1
  171. package/dist/multi-agent/agent-event-bus.js +34 -0
  172. package/dist/multi-agent/agent-event-bus.js.map +1 -1
  173. package/dist/multi-agent/agent-process-manager.d.ts +3 -0
  174. package/dist/multi-agent/agent-process-manager.d.ts.map +1 -1
  175. package/dist/multi-agent/agent-process-manager.js +118 -13
  176. package/dist/multi-agent/agent-process-manager.js.map +1 -1
  177. package/dist/multi-agent/conductor-persona.js +2 -2
  178. package/dist/multi-agent/dashboard-agent-persona.d.ts +6 -2
  179. package/dist/multi-agent/dashboard-agent-persona.d.ts.map +1 -1
  180. package/dist/multi-agent/dashboard-agent-persona.js +57 -30
  181. package/dist/multi-agent/dashboard-agent-persona.js.map +1 -1
  182. package/dist/multi-agent/memory-agent-persona.d.ts +1 -1
  183. package/dist/multi-agent/memory-agent-persona.d.ts.map +1 -1
  184. package/dist/multi-agent/memory-agent-persona.js +25 -4
  185. package/dist/multi-agent/memory-agent-persona.js.map +1 -1
  186. package/dist/multi-agent/runtime-process.d.ts +1 -0
  187. package/dist/multi-agent/runtime-process.d.ts.map +1 -1
  188. package/dist/multi-agent/runtime-process.js +1 -0
  189. package/dist/multi-agent/runtime-process.js.map +1 -1
  190. package/dist/multi-agent/types.d.ts +14 -4
  191. package/dist/multi-agent/types.d.ts.map +1 -1
  192. package/dist/multi-agent/types.js.map +1 -1
  193. package/dist/multi-agent/wiki-agent-persona.d.ts +7 -1
  194. package/dist/multi-agent/wiki-agent-persona.d.ts.map +1 -1
  195. package/dist/multi-agent/wiki-agent-persona.js +83 -61
  196. package/dist/multi-agent/wiki-agent-persona.js.map +1 -1
  197. package/dist/multi-agent/workflow-types.d.ts +1 -1
  198. package/dist/multi-agent/workflow-types.d.ts.map +1 -1
  199. package/dist/operator/board-slot-instructions.d.ts +18 -0
  200. package/dist/operator/board-slot-instructions.d.ts.map +1 -0
  201. package/dist/operator/board-slot-instructions.js +52 -0
  202. package/dist/operator/board-slot-instructions.js.map +1 -0
  203. package/dist/operator/connector-delta-repo.d.ts +33 -0
  204. package/dist/operator/connector-delta-repo.d.ts.map +1 -0
  205. package/dist/operator/connector-delta-repo.js +0 -0
  206. package/dist/operator/connector-delta-repo.js.map +1 -0
  207. package/dist/operator/mama-memory-port.d.ts +13 -0
  208. package/dist/operator/mama-memory-port.d.ts.map +1 -0
  209. package/dist/operator/mama-memory-port.js +35 -0
  210. package/dist/operator/mama-memory-port.js.map +1 -0
  211. package/dist/operator/operator-interfaces.d.ts +136 -0
  212. package/dist/operator/operator-interfaces.d.ts.map +1 -0
  213. package/dist/operator/operator-interfaces.js +15 -0
  214. package/dist/operator/operator-interfaces.js.map +1 -0
  215. package/dist/operator/operator-trigger-loop.d.ts +106 -0
  216. package/dist/operator/operator-trigger-loop.d.ts.map +1 -0
  217. package/dist/operator/operator-trigger-loop.js +228 -0
  218. package/dist/operator/operator-trigger-loop.js.map +1 -0
  219. package/dist/operator/report-run.d.ts +78 -0
  220. package/dist/operator/report-run.d.ts.map +1 -0
  221. package/dist/operator/report-run.js +141 -0
  222. package/dist/operator/report-run.js.map +1 -0
  223. package/dist/operator/report-scheduler.d.ts +43 -0
  224. package/dist/operator/report-scheduler.d.ts.map +1 -0
  225. package/dist/operator/report-scheduler.js +87 -0
  226. package/dist/operator/report-scheduler.js.map +1 -0
  227. package/dist/operator/situation-report.d.ts +86 -0
  228. package/dist/operator/situation-report.d.ts.map +1 -0
  229. package/dist/operator/situation-report.js +211 -0
  230. package/dist/operator/situation-report.js.map +1 -0
  231. package/dist/operator/trigger-author.d.ts +45 -0
  232. package/dist/operator/trigger-author.d.ts.map +1 -0
  233. package/dist/operator/trigger-author.js +217 -0
  234. package/dist/operator/trigger-author.js.map +1 -0
  235. package/dist/operator/trigger-evolve.d.ts +31 -0
  236. package/dist/operator/trigger-evolve.d.ts.map +1 -0
  237. package/dist/operator/trigger-evolve.js +51 -0
  238. package/dist/operator/trigger-evolve.js.map +1 -0
  239. package/dist/operator/trigger-fire.d.ts +29 -0
  240. package/dist/operator/trigger-fire.d.ts.map +1 -0
  241. package/dist/operator/trigger-fire.js +41 -0
  242. package/dist/operator/trigger-fire.js.map +1 -0
  243. package/dist/operator/trigger-matcher.d.ts +19 -0
  244. package/dist/operator/trigger-matcher.d.ts.map +1 -0
  245. package/dist/operator/trigger-matcher.js +61 -0
  246. package/dist/operator/trigger-matcher.js.map +1 -0
  247. package/dist/operator/trigger-registry.d.ts +36 -0
  248. package/dist/operator/trigger-registry.d.ts.map +1 -0
  249. package/dist/operator/trigger-registry.js +135 -0
  250. package/dist/operator/trigger-registry.js.map +1 -0
  251. package/dist/operator/trigger-review.d.ts +23 -0
  252. package/dist/operator/trigger-review.d.ts.map +1 -0
  253. package/dist/operator/trigger-review.js +127 -0
  254. package/dist/operator/trigger-review.js.map +1 -0
  255. package/dist/operator/trigger-types.d.ts +84 -0
  256. package/dist/operator/trigger-types.d.ts.map +1 -0
  257. package/dist/operator/trigger-types.js +14 -0
  258. package/dist/operator/trigger-types.js.map +1 -0
  259. package/dist/scheduler/cron-worker.d.ts.map +1 -1
  260. package/dist/scheduler/cron-worker.js +3 -1
  261. package/dist/scheduler/cron-worker.js.map +1 -1
  262. package/dist/security/security-monitor.d.ts.map +1 -1
  263. package/dist/security/security-monitor.js +1 -0
  264. package/dist/security/security-monitor.js.map +1 -1
  265. package/dist/wiki/obsidian-writer.d.ts +1 -1
  266. package/dist/wiki/obsidian-writer.d.ts.map +1 -1
  267. package/dist/wiki/obsidian-writer.js +67 -27
  268. package/dist/wiki/obsidian-writer.js.map +1 -1
  269. package/dist/wiki/path-safety.d.ts +2 -0
  270. package/dist/wiki/path-safety.d.ts.map +1 -0
  271. package/dist/wiki/path-safety.js +40 -0
  272. package/dist/wiki/path-safety.js.map +1 -0
  273. package/dist/wiki/types.d.ts +4 -2
  274. package/dist/wiki/types.d.ts.map +1 -1
  275. package/dist/wiki/types.js +1 -1
  276. package/dist/wiki/types.js.map +1 -1
  277. package/dist/wiki-artifacts/normalization.d.ts +8 -0
  278. package/dist/wiki-artifacts/normalization.d.ts.map +1 -0
  279. package/dist/wiki-artifacts/normalization.js +41 -0
  280. package/dist/wiki-artifacts/normalization.js.map +1 -0
  281. package/dist/wiki-artifacts/types.d.ts +52 -0
  282. package/dist/wiki-artifacts/types.d.ts.map +1 -0
  283. package/dist/wiki-artifacts/types.js +3 -0
  284. package/dist/wiki-artifacts/types.js.map +1 -0
  285. package/dist/wiki-artifacts/wiki-publish-adapter.d.ts +14 -0
  286. package/dist/wiki-artifacts/wiki-publish-adapter.d.ts.map +1 -0
  287. package/dist/wiki-artifacts/wiki-publish-adapter.js +71 -0
  288. package/dist/wiki-artifacts/wiki-publish-adapter.js.map +1 -0
  289. package/package.json +6 -4
  290. package/public/ui/assets/index-BDsaQNGd.js +62 -0
  291. package/public/ui/assets/index-C4URnm_X.css +1 -0
  292. package/public/ui/index.html +13 -0
  293. package/public/viewer/js/utils/api.js +2 -2
  294. package/public/viewer/src/utils/api.ts +9 -2
  295. package/public/viewer/sw.js +1 -1
  296. package/public/viewer/viewer.html +6 -0
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OPERATOR_REPORT_SESSION_KEY = void 0;
4
+ exports.summarizeReportToolUse = summarizeReportToolUse;
5
+ exports.formatReportToolAudit = formatReportToolAudit;
6
+ exports.createPersonaReportAsk = createPersonaReportAsk;
7
+ /** Dedicated persona session lane for operator reports; isolates the multi-turn gather loop from
8
+ * chat. runWithContent honors options.sessionKey (agent-loop.ts:879). */
9
+ exports.OPERATOR_REPORT_SESSION_KEY = 'operator:report';
10
+ /** Gateway READ tools the full report is instructed to gather with (gateway-tools.md:12,14,22-25). */
11
+ const GATHER_TOOLS = new Set([
12
+ 'kagemusha_overview',
13
+ 'kagemusha_entities',
14
+ 'kagemusha_tasks',
15
+ 'kagemusha_messages',
16
+ 'mama_recall',
17
+ 'mama_search',
18
+ 'context_compile',
19
+ ]);
20
+ /** Gateway WRITE tools. mama_save is the M3 hand; the rest are classified only for honest
21
+ * observability if they ever appear (report_publish/wiki_publish are NOT instructed in M3 -
22
+ * see plan finding F6). (gateway-tools.md:11,17,18,65,66) */
23
+ const WRITE_TOOLS = new Set([
24
+ 'mama_save',
25
+ 'mama_add',
26
+ 'mama_ingest',
27
+ 'report_publish',
28
+ 'wiki_publish',
29
+ ]);
30
+ /** True when a tool_result proves the call did NOT execute: errored, or denied by the envelope
31
+ * layer with {"success":false,...,"code":"envelope_missing"} (gateway-tool-executor.ts:1090-1142).
32
+ * The gateway loop serializes the tool-result OBJECT as the content (JSON.stringify in
33
+ * executeTools), so parse and inspect the ROOT properties first - a substring regex alone
34
+ * false-positives on a SUCCESSFUL result whose nested payload merely mentions
35
+ * '"success":false' (PR #119 review). The substring heuristic remains only as the
36
+ * conservative fallback for unparseable content. */
37
+ function isErroredOrDenied(block) {
38
+ if (block.is_error === true) {
39
+ return true;
40
+ }
41
+ const body = typeof block.content === 'string' ? block.content : JSON.stringify(block.content ?? '');
42
+ try {
43
+ const parsed = JSON.parse(body);
44
+ if (typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed)) {
45
+ const root = parsed;
46
+ return root.success === false || root.code === 'envelope_missing';
47
+ }
48
+ }
49
+ catch {
50
+ // Not JSON - fall through to the conservative substring heuristic.
51
+ }
52
+ return /"success"\s*:\s*false/.test(body) || body.includes('envelope_missing');
53
+ }
54
+ /** Pair assistant tool_use blocks with their tool_result and classify EXECUTIONS as gather vs
55
+ * write. `all` inventories every emission (executed or not) for honest logging. */
56
+ function summarizeReportToolUse(history) {
57
+ // Pass 1: index result health by tool_use_id (results live in the user messages the agent loop
58
+ // pushes after each tool batch - agent-loop.ts:1408-1411).
59
+ const resultOkById = new Map();
60
+ for (const msg of history) {
61
+ if (!msg || msg.role !== 'user' || !Array.isArray(msg.content))
62
+ continue;
63
+ for (const block of msg.content) {
64
+ if (!block || block.type !== 'tool_result' || typeof block.tool_use_id !== 'string')
65
+ continue;
66
+ resultOkById.set(block.tool_use_id, !isErroredOrDenied(block));
67
+ }
68
+ }
69
+ // Pass 2: classify assistant tool_use blocks; only a paired healthy result counts as executed.
70
+ const gatherTools = [];
71
+ const writeTools = [];
72
+ const all = [];
73
+ for (const msg of history) {
74
+ if (!msg || msg.role !== 'assistant' || !Array.isArray(msg.content))
75
+ continue;
76
+ for (const block of msg.content) {
77
+ if (!block || block.type !== 'tool_use' || typeof block.name !== 'string')
78
+ continue;
79
+ all.push(block.name);
80
+ const executed = typeof block.id === 'string' && resultOkById.get(block.id) === true;
81
+ if (!executed)
82
+ continue;
83
+ if (GATHER_TOOLS.has(block.name))
84
+ gatherTools.push(block.name);
85
+ else if (WRITE_TOOLS.has(block.name))
86
+ writeTools.push(block.name);
87
+ }
88
+ }
89
+ return { gatherTools, writeTools, all };
90
+ }
91
+ function uniq(names) {
92
+ return [...new Set(names)];
93
+ }
94
+ /**
95
+ * Build the operator-log lines for one report.
96
+ * isFullReport gates the no-fallback gather WARNING (only the FULL report is instructed to gather;
97
+ * the digest is intentionally tool-free, so absence of gather tools there is normal).
98
+ */
99
+ function formatReportToolAudit(audit, isFullReport) {
100
+ const lines = [];
101
+ if (audit.writeTools.length > 0) {
102
+ lines.push(`[trigger-loop] full report: agent wrote via ${uniq(audit.writeTools).join(', ')}`);
103
+ }
104
+ if (isFullReport) {
105
+ if (audit.gatherTools.length === 0) {
106
+ lines.push('[trigger-loop] full report WARNING: agent executed NO gateway gather tools ' +
107
+ '(none called, or every call errored/denied) - task-board substance NOT verified; ' +
108
+ 'the report may reflect native-tool, denied, or window-only gathering');
109
+ }
110
+ else {
111
+ lines.push(`[trigger-loop] full report: agent gathered via ${uniq(audit.gatherTools).join(', ')}`);
112
+ }
113
+ }
114
+ return lines;
115
+ }
116
+ /**
117
+ * Build the report-composition AskAgent (M3). Envelope-first: gateway 'model_tool' executions are
118
+ * envelope-gated (gateway-tool-executor.ts:252-256), so issue the per-report scoped envelope
119
+ * BEFORE running - without one every call is denied with code 'envelope_missing' (:1090-1142),
120
+ * the enforcement that killed the ancestor scheduled-report path. Issuance failure propagates
121
+ * loudly (no-fallback; the buffer is kept and the next cadence retries). Then run the persona
122
+ * agent (injected runner isolates the report into its own session lane and carries the envelope),
123
+ * audit + log the gateway tools it actually EXECUTED (no-fallback WARNING when a full report
124
+ * executed none; observability line for every write), and enforce the empty-report guard
125
+ * (M2 semantics).
126
+ */
127
+ function createPersonaReportAsk(deps) {
128
+ return async (prompt) => {
129
+ const envelope = deps.issueEnvelope ? await deps.issueEnvelope() : undefined;
130
+ const { response, history } = await deps.run(prompt, envelope);
131
+ const isFull = prompt.includes(deps.fullReportTag);
132
+ for (const line of formatReportToolAudit(summarizeReportToolUse(history), isFull)) {
133
+ deps.log(line);
134
+ }
135
+ if (!response || response.trim() === '') {
136
+ throw new Error('persona agent returned an empty report response');
137
+ }
138
+ return response;
139
+ };
140
+ }
141
+ //# sourceMappingURL=report-run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report-run.js","sourceRoot":"","sources":["../../src/operator/report-run.ts"],"names":[],"mappings":";;;AAuFA,wDAkCC;AAWD,sDAmBC;AAoCD,wDAaC;AAnLD;0EAC0E;AAC7D,QAAA,2BAA2B,GAAG,iBAAiB,CAAC;AAE7D,sGAAsG;AACtG,MAAM,YAAY,GAAG,IAAI,GAAG,CAAS;IACnC,oBAAoB;IACpB,oBAAoB;IACpB,iBAAiB;IACjB,oBAAoB;IACpB,aAAa;IACb,aAAa;IACb,iBAAiB;CAClB,CAAC,CAAC;AAEH;;8DAE8D;AAC9D,MAAM,WAAW,GAAG,IAAI,GAAG,CAAS;IAClC,WAAW;IACX,UAAU;IACV,aAAa;IACb,gBAAgB;IAChB,cAAc;CACf,CAAC,CAAC;AAeH;;;;;;qDAMqD;AACrD,SAAS,iBAAiB,CAAC,KAAgD;IACzE,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,IAAI,GACR,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;IAC1F,IAAI,CAAC;QACH,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,OAAO,MAAM,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ability). */
2
+ export interface ReportSchedule {
3
+ shouldFire(now: Date): {
4
+ fire: boolean;
5
+ hourKey: string;
6
+ };
7
+ markFired(hourKey: string): void;
8
+ }
9
+ /** Persist/restore the last-fired hour key (so a restart within the same hour does not re-send). */
10
+ export interface ReportScheduleStore {
11
+ load(): string | null;
12
+ save(hourKey: string): void;
13
+ }
14
+ /** Local-time "YYYY-MM-DD:HH" bucket. Two ticks in the same local hour share a key. */
15
+ export declare function hourKeyLocal(now: Date): string;
16
+ /**
17
+ * Parse an env string like "8,13,18" into sorted, deduped LOCAL hours in [0,23].
18
+ * Empty/garbage -> [] (feature off). Ports Kagemusha normalizeFullReportHours
19
+ * (~/project/mama-suite/apps/kagemusha/src/config/ai-config.ts:203) but generic + ASCII, no
20
+ * personal defaults.
21
+ */
22
+ export declare function parseReportHours(raw: string): number[];
23
+ export declare class ReportScheduler implements ReportSchedule {
24
+ private hours;
25
+ private store;
26
+ private lastFiredHourKey;
27
+ constructor(hours: number[], store: ReportScheduleStore);
28
+ /** Pure: does a full report fire at now? Robust to ticks not landing on the hour boundary. */
29
+ shouldFire(now: Date): {
30
+ fire: boolean;
31
+ hourKey: string;
32
+ };
33
+ /** Mark this hour delivered (persist) so we fire once per configured hour, restart-safe. */
34
+ markFired(hourKey: string): void;
35
+ }
36
+ /** File-backed store under ~/.mama - mirrors ConnectorDeltaRepo's atomic cursor file. */
37
+ export declare class FileReportScheduleStore implements ReportScheduleStore {
38
+ private path;
39
+ constructor(path: string);
40
+ load(): string | null;
41
+ save(hourKey: string): void;
42
+ }
43
+ //# sourceMappingURL=report-scheduler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report-scheduler.d.ts","sourceRoot":"","sources":["../../src/operator/report-scheduler.ts"],"names":[],"mappings":"AAeA,sGAAsG;AACtG,MAAM,WAAW,cAAc;IAC7B,UAAU,CAAC,GAAG,EAAE,IAAI,GAAG;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1D,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAED,oGAAoG;AACpG,MAAM,WAAW,mBAAmB;IAClC,IAAI,IAAI,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,uFAAuF;AACvF,wBAAgB,YAAY,CAAC,GAAG,EAAE,IAAI,GAAG,MAAM,CAG9C;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAQtD;AAED,qBAAa,eAAgB,YAAW,cAAc;IACpD,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,KAAK,CAAsB;IACnC,OAAO,CAAC,gBAAgB,CAAgB;gBAE5B,KAAK,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,mBAAmB;IAMvD,8FAA8F;IAC9F,UAAU,CAAC,GAAG,EAAE,IAAI,GAAG;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;IAMzD,4FAA4F;IAC5F,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;CAIjC;AAED,yFAAyF;AACzF,qBAAa,uBAAwB,YAAW,mBAAmB;IACjE,OAAO,CAAC,IAAI,CAAS;gBAET,IAAI,EAAE,MAAM;IAIxB,IAAI,IAAI,MAAM,GAAG,IAAI;IAYrB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;CAM5B"}
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FileReportScheduleStore = exports.ReportScheduler = void 0;
4
+ exports.hourKeyLocal = hourKeyLocal;
5
+ exports.parseReportHours = parseReportHours;
6
+ /**
7
+ * ReportScheduler - the scheduled full-report cadence (M2-T0).
8
+ *
9
+ * Ports the schedule-firing MECHANISM from Kagemusha AgentAwareness.tickScheduledReports
10
+ * (~/project/mama-suite/apps/kagemusha/src/runtime/agent-awareness.ts:1371 + buildHourKey:1483):
11
+ * fire once when the current hour is one of the configured hours and this hour has not been fired
12
+ * yet. Kagemusha keys on Asia/Seoul; MAMA uses LOCAL hours (Date.getHours) per the M2 brief - the
13
+ * owner timezone stays a runtime property, never a source constant.
14
+ *
15
+ * Pure decision (shouldFire) + a persisted last-fired hour key (survives restart -> no
16
+ * double-send). NO personal data: the hours are injected from env/config, never hardcoded here.
17
+ */
18
+ const node_fs_1 = require("node:fs");
19
+ const node_path_1 = require("node:path");
20
+ /** Local-time "YYYY-MM-DD:HH" bucket. Two ticks in the same local hour share a key. */
21
+ function hourKeyLocal(now) {
22
+ const pad = (n) => String(n).padStart(2, '0');
23
+ return `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}:${pad(now.getHours())}`;
24
+ }
25
+ /**
26
+ * Parse an env string like "8,13,18" into sorted, deduped LOCAL hours in [0,23].
27
+ * Empty/garbage -> [] (feature off). Ports Kagemusha normalizeFullReportHours
28
+ * (~/project/mama-suite/apps/kagemusha/src/config/ai-config.ts:203) but generic + ASCII, no
29
+ * personal defaults.
30
+ */
31
+ function parseReportHours(raw) {
32
+ const hours = raw
33
+ .split(',')
34
+ .map((part) => part.trim())
35
+ .filter((part) => part !== '') // drop empty tokens BEFORE Number(): Number('') === 0 would sneak in hour 0
36
+ .map(Number)
37
+ .filter((n) => Number.isInteger(n) && n >= 0 && n <= 23);
38
+ return [...new Set(hours)].sort((a, b) => a - b);
39
+ }
40
+ class ReportScheduler {
41
+ hours;
42
+ store;
43
+ lastFiredHourKey;
44
+ constructor(hours, store) {
45
+ this.hours = hours;
46
+ this.store = store;
47
+ this.lastFiredHourKey = store.load(); // restore across restart
48
+ }
49
+ /** Pure: does a full report fire at now? Robust to ticks not landing on the hour boundary. */
50
+ shouldFire(now) {
51
+ const hourKey = hourKeyLocal(now);
52
+ const fire = this.hours.includes(now.getHours()) && this.lastFiredHourKey !== hourKey;
53
+ return { fire, hourKey };
54
+ }
55
+ /** Mark this hour delivered (persist) so we fire once per configured hour, restart-safe. */
56
+ markFired(hourKey) {
57
+ this.lastFiredHourKey = hourKey;
58
+ this.store.save(hourKey);
59
+ }
60
+ }
61
+ exports.ReportScheduler = ReportScheduler;
62
+ /** File-backed store under ~/.mama - mirrors ConnectorDeltaRepo's atomic cursor file. */
63
+ class FileReportScheduleStore {
64
+ path;
65
+ constructor(path) {
66
+ this.path = path;
67
+ }
68
+ load() {
69
+ if (!(0, node_fs_1.existsSync)(this.path)) {
70
+ return null;
71
+ }
72
+ const parsed = JSON.parse((0, node_fs_1.readFileSync)(this.path, 'utf8')); // throws on corrupt (no-fallback)
73
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
74
+ throw new Error(`corrupt report-schedule state (not an object): ${this.path}`);
75
+ }
76
+ const key = parsed.lastFiredHourKey;
77
+ return typeof key === 'string' ? key : null;
78
+ }
79
+ save(hourKey) {
80
+ (0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(this.path), { recursive: true });
81
+ const tmp = (0, node_path_1.join)((0, node_path_1.dirname)(this.path), `.report-schedule.${process.pid}.tmp`);
82
+ (0, node_fs_1.writeFileSync)(tmp, JSON.stringify({ lastFiredHourKey: hourKey }), 'utf8');
83
+ (0, node_fs_1.renameSync)(tmp, this.path); // atomic replace
84
+ }
85
+ }
86
+ exports.FileReportScheduleStore = FileReportScheduleStore;
87
+ //# sourceMappingURL=report-scheduler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report-scheduler.js","sourceRoot":"","sources":["../../src/operator/report-scheduler.ts"],"names":[],"mappings":";;;AA4BA,oCAGC;AAQD,4CAQC;AA/CD;;;;;;;;;;;GAWG;AACH,qCAAyF;AACzF,yCAA0C;AAc1C,uFAAuF;AACvF,SAAgB,YAAY,CAAC,GAAS;IACpC,MAAM,GAAG,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,MAAM,CAAC,CAAC,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,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACnD,MAAM,GAAG,GAAG,IAAA,gBAAI,EAAC,IAAA,mBAAO,EAAC,IAAI,CAAC,IAAI,CAAC,EAAE,oBAAoB,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC;QAC5E,IAAA,uBAAa,EAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,gBAAgB,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;QAC1E,IAAA,oBAAU,EAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAiB;IAC/C,CAAC;CACF;AAzBD,0DAyBC"}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * SituationReporter - the OUTPUT leg of the trigger loop (M2), superseding TriggerReporter (M1.5).
3
+ *
4
+ * Accumulates a BOUNDED window of drained events (per-channel counts + last-K excerpts), plus
5
+ * fire/author activity and the memory those fires recalled (agent-authored memoryQuery drove the
6
+ * recall - trigger-fire.ts:33-34). On a report cadence the AGENT composes an owner situation
7
+ * report from the AGGREGATE (agent-first: the agent judges content and may reply NOTHING to
8
+ * suppress); the system only windows/schedules/sends.
9
+ *
10
+ * Two framings share one accumulator + send machinery:
11
+ * - 'digest': the short periodic update (the M1.5 fire digest, now window-aware).
12
+ * - 'full' : the fuller scheduled report covering the whole window since the last full report.
13
+ *
14
+ * No activity -> no agent call, no send (no spam). Send failure propagates loudly (no-fallback)
15
+ * and keeps the buffer so the next cadence retries. English default; the agent is told to answer
16
+ * in the owner's language if inferable. NO personal strings in this source.
17
+ */
18
+ import type { OperatorChannelEvent, OutputSink } from './operator-interfaces.js';
19
+ import type { AskAgent } from './trigger-author.js';
20
+ /**
21
+ * Machine frame tag prepended to the FULL report prompt so the report-run wiring can tell a full
22
+ * report from a digest for tool-use auditing (report-run.ts). Kagemusha frames its scheduled full
23
+ * report with the same bracketed-tag convention (report-prompts.ts buildFullReportPrompt).
24
+ */
25
+ export declare const OPERATOR_FULL_REPORT_TAG = "[operator_full_report]";
26
+ export interface FireActivity {
27
+ triggerId: string;
28
+ kind: string;
29
+ channelId: string;
30
+ recalled: {
31
+ topic: string;
32
+ content: string;
33
+ }[];
34
+ }
35
+ export type ReportMode = 'digest' | 'full';
36
+ export interface SituationReporterOptions {
37
+ /**
38
+ * M2.3: tool-call instructions injected into the FULL report framing so the agent
39
+ * ACTIVELY gathers current context (channels, tasks, memory) before writing - the
40
+ * lesson from Kagemusha, whose report prompt instructs its agent to call its tools
41
+ * (and which deleted its deterministic report builder for low quality). The lines
42
+ * are injected from the runtime wiring (which knows the daemon's toolset); this
43
+ * module stays generic. Digest mode never uses them (frequent + must stay light).
44
+ */
45
+ selfGatherLines?: string[];
46
+ /**
47
+ * Kagemusha dual-output mechanism: lines instructing the FULL report run to also
48
+ * publish the operator board slots (report_publish) before writing the text
49
+ * report. Injected from runtime wiring (board-slot-instructions.ts); digest mode
50
+ * never publishes the board.
51
+ */
52
+ boardPublishLines?: string[];
53
+ /**
54
+ * G2 success signal: called with the trigger ids the agent says it actually
55
+ * drew on for the sent report (parsed from the stripped USED_TRIGGERS
56
+ * trailer, validated against this window's fires). The wiring records
57
+ * 'succeeded' outcomes so evolution finally gets a positive signal instead
58
+ * of being elimination-only. Uncited fires stay NEUTRAL - not failures.
59
+ */
60
+ recordTriggerUse?: (triggerIds: string[]) => void;
61
+ }
62
+ export declare class SituationReporter {
63
+ private windowByChannel;
64
+ private windowTotal;
65
+ private fireAgg;
66
+ private authored;
67
+ private recalled;
68
+ private opts;
69
+ constructor(opts?: SituationReporterOptions);
70
+ /** Fold a batch of drained events into the bounded per-channel window. */
71
+ recordWindow(events: OperatorChannelEvent[]): void;
72
+ /** Fold one fire into the aggregate; merge the memory it recalled (agent-query-driven). */
73
+ recordFire(activity: FireActivity): void;
74
+ recordAuthored(count: number): void;
75
+ /** Any window events, fires, or authored triggers accumulated since the last reset. */
76
+ hasActivity(): boolean;
77
+ /**
78
+ * Agent composes the report from the aggregate; sink delivers it. Returns true if a report was
79
+ * sent, false if there was nothing to say or the agent suppressed it (NOTHING).
80
+ */
81
+ report(askAgent: AskAgent, output: Pick<OutputSink, 'send'>, mode: ReportMode): Promise<boolean>;
82
+ private reset;
83
+ /** Public for testability. Aggregate window + fire activity + recalled memory -> agent prompt. */
84
+ buildPrompt(mode: ReportMode): string;
85
+ }
86
+ //# sourceMappingURL=situation-report.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"situation-report.d.ts","sourceRoot":"","sources":["../../src/operator/situation-report.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACjF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,2BAA2B,CAAC;AAEjE,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAChD;AAED,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,MAAM,CAAC;AAqB3C,MAAM,WAAW,wBAAwB;IACvC;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CACnD;AAKD,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,eAAe,CAAoC;IAC3D,OAAO,CAAC,WAAW,CAAK;IACxB,OAAO,CAAC,OAAO,CAA8B;IAC7C,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,QAAQ,CAA6B;IAC7C,OAAO,CAAC,IAAI,CAA2B;gBAE3B,IAAI,GAAE,wBAA6B;IAI/C,0EAA0E;IAC1E,YAAY,CAAC,MAAM,EAAE,oBAAoB,EAAE,GAAG,IAAI;IAgBlD,2FAA2F;IAC3F,UAAU,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI;IAmBxC,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAInC,uFAAuF;IACvF,WAAW,IAAI,OAAO;IAItB;;;OAGG;IACG,MAAM,CACV,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,EAChC,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,OAAO,CAAC;IA2CnB,OAAO,CAAC,KAAK;IAQb,kGAAkG;IAClG,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM;CAwGtC"}
@@ -0,0 +1,211 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SituationReporter = exports.OPERATOR_FULL_REPORT_TAG = void 0;
4
+ /**
5
+ * Machine frame tag prepended to the FULL report prompt so the report-run wiring can tell a full
6
+ * report from a digest for tool-use auditing (report-run.ts). Kagemusha frames its scheduled full
7
+ * report with the same bracketed-tag convention (report-prompts.ts buildFullReportPrompt).
8
+ */
9
+ exports.OPERATOR_FULL_REPORT_TAG = '[operator_full_report]';
10
+ /** Deterministic prompt-size bounds (mind memory + prompt length; see plan design decision 4). */
11
+ const MAX_EXCERPTS_PER_CHANNEL = 5;
12
+ const MAX_EXCERPT_CHARS = 160;
13
+ const MAX_CHANNELS_IN_PROMPT = 12;
14
+ const MAX_RECALLED = 20;
15
+ /** Machine trailer the agent appends; stripped before the owner sees the report. */
16
+ const USED_TRIGGERS_PATTERN = /\n?^USED_TRIGGERS:\s*(.*)\s*$/im;
17
+ class SituationReporter {
18
+ windowByChannel = new Map();
19
+ windowTotal = 0;
20
+ fireAgg = new Map();
21
+ authored = 0;
22
+ recalled = new Map(); // topic -> content (deduped, bounded)
23
+ opts;
24
+ constructor(opts = {}) {
25
+ this.opts = opts;
26
+ }
27
+ /** Fold a batch of drained events into the bounded per-channel window. */
28
+ recordWindow(events) {
29
+ for (const e of events) {
30
+ const w = this.windowByChannel.get(e.channelId) ?? { count: 0, excerpts: [] };
31
+ w.count += 1;
32
+ const text = e.content.trim();
33
+ if (text) {
34
+ w.excerpts.push(text.slice(0, MAX_EXCERPT_CHARS));
35
+ if (w.excerpts.length > MAX_EXCERPTS_PER_CHANNEL) {
36
+ w.excerpts.shift();
37
+ }
38
+ }
39
+ this.windowByChannel.set(e.channelId, w);
40
+ this.windowTotal += 1;
41
+ }
42
+ }
43
+ /** Fold one fire into the aggregate; merge the memory it recalled (agent-query-driven). */
44
+ recordFire(activity) {
45
+ const key = `${activity.triggerId}|${activity.channelId}`;
46
+ const agg = this.fireAgg.get(key) ?? {
47
+ triggerId: activity.triggerId,
48
+ kind: activity.kind,
49
+ channelId: activity.channelId,
50
+ count: 0,
51
+ topics: new Set(),
52
+ };
53
+ agg.count += 1;
54
+ for (const r of activity.recalled) {
55
+ agg.topics.add(r.topic);
56
+ if (!this.recalled.has(r.topic) && this.recalled.size < MAX_RECALLED) {
57
+ this.recalled.set(r.topic, r.content.slice(0, MAX_EXCERPT_CHARS));
58
+ }
59
+ }
60
+ this.fireAgg.set(key, agg);
61
+ }
62
+ recordAuthored(count) {
63
+ this.authored += count;
64
+ }
65
+ /** Any window events, fires, or authored triggers accumulated since the last reset. */
66
+ hasActivity() {
67
+ return this.windowTotal > 0 || this.fireAgg.size > 0 || this.authored > 0;
68
+ }
69
+ /**
70
+ * Agent composes the report from the aggregate; sink delivers it. Returns true if a report was
71
+ * sent, false if there was nothing to say or the agent suppressed it (NOTHING).
72
+ */
73
+ async report(askAgent, output, mode) {
74
+ // M2.1: the scheduled FULL report is a duty report - it composes even on an empty window
75
+ // (the owner relies on it arriving; a quiet window is itself the news). Digests stay gated.
76
+ if (mode !== 'full' && !this.hasActivity())
77
+ return false;
78
+ const raw = (await askAgent(this.buildPrompt(mode))).trim();
79
+ if (raw === '' || /^NOTHING\b/i.test(raw)) {
80
+ this.reset(); // agent judged nothing worth reporting - drop the buffer quietly
81
+ return false;
82
+ }
83
+ // Parse + strip the USED_TRIGGERS machine trailer (the owner never sees it)
84
+ // and validate the ids against THIS window's fires (no hallucinated credit).
85
+ const match = raw.match(USED_TRIGGERS_PATTERN);
86
+ const text = raw.replace(USED_TRIGGERS_PATTERN, '').trim();
87
+ let cited = [];
88
+ if (match) {
89
+ const windowIds = new Set([...this.fireAgg.values()].map((f) => f.triggerId));
90
+ cited = [
91
+ ...new Set(match[1]
92
+ .split(',')
93
+ .map((id) => id.trim())
94
+ .filter((id) => id.length > 0 && id.toLowerCase() !== 'none' && windowIds.has(id))),
95
+ ];
96
+ }
97
+ if (text === '') {
98
+ this.reset(); // trailer-only reply: nothing was delivered, so no credit either
99
+ return false;
100
+ }
101
+ await output.send(text); // throws loudly on failure; buffer kept for retry (no-fallback)
102
+ // Credit only AFTER a successful send: success means "cited in a DELIVERED
103
+ // report". Crediting before send would double-count on the retry path
104
+ // (send throws -> buffer kept -> next cadence re-cites the same fires).
105
+ if (cited.length > 0) {
106
+ this.opts.recordTriggerUse?.(cited);
107
+ }
108
+ this.reset();
109
+ return true;
110
+ }
111
+ reset() {
112
+ this.windowByChannel.clear();
113
+ this.windowTotal = 0;
114
+ this.fireAgg.clear();
115
+ this.authored = 0;
116
+ this.recalled.clear();
117
+ }
118
+ /** Public for testability. Aggregate window + fire activity + recalled memory -> agent prompt. */
119
+ buildPrompt(mode) {
120
+ const channels = [...this.windowByChannel.entries()].sort((a, b) => b[1].count - a[1].count);
121
+ const shown = channels.slice(0, MAX_CHANNELS_IN_PROMPT);
122
+ const windowLines = shown.map(([channelId, w]) => `- ${channelId}: ${w.count} msg(s); recent: ${w.excerpts.join(' | ') || '(none)'}`);
123
+ if (channels.length > shown.length) {
124
+ const restCount = channels.slice(shown.length).reduce((n, [, w]) => n + w.count, 0);
125
+ windowLines.push(`- (+${channels.length - shown.length} more channel(s), ${restCount} msg(s))`);
126
+ }
127
+ const fireLines = [...this.fireAgg.values()].map((f) => `- trigger "${f.kind}" [id: ${f.triggerId}] fired ${f.count}x on ${f.channelId}; recalled: ${[...f.topics].join(', ') || '(none)'}`);
128
+ const memoryLines = [...this.recalled.entries()].map(([topic, content]) => `- ${topic}: ${content}`);
129
+ // M2.1 posture: the full report is a DUTY report (always arrives - a quiet window is
130
+ // reported as quiet, the aliveness signal owners rely on); the digest defaults to briefing
131
+ // and keeps NOTHING only for pure noise.
132
+ const framing = mode === 'full'
133
+ ? [
134
+ exports.OPERATOR_FULL_REPORT_TAG,
135
+ 'You are the operator agent. Write your scheduled FULLER situation report for your owner',
136
+ 'covering the whole window below (multiple channels, since the last full report). Group',
137
+ "what recurred, what is new, and what needs the owner's attention. Plain language, no",
138
+ 'markdown tables. This scheduled report must ALWAYS arrive: if the window was quiet,',
139
+ 'say so in one or two lines instead of skipping.',
140
+ "Structure the report with these sections (render the headings in the owner's language;",
141
+ 'omit a section only when it is truly empty):',
142
+ '1) Key situation 2) Action required 3) Decisions needed 4) Pipeline 5) Next actions',
143
+ ...(this.opts.selfGatherLines && this.opts.selfGatherLines.length > 0
144
+ ? [
145
+ '',
146
+ 'Before writing, ACTIVELY gather current context by CALLING your gateway tools.',
147
+ 'Emit each call as a fenced tool_call JSON block and wait for the result before',
148
+ 'the next call. The block format is exactly:',
149
+ '```tool_call',
150
+ '{"name": "kagemusha_tasks", "input": {"status": "in_progress"}}',
151
+ '```',
152
+ 'Gather with these gateway tool calls:',
153
+ ...this.opts.selfGatherLines.map((line) => `- ${line}`),
154
+ 'These gateway tools are NOT native or deferred CLI tools: ToolSearch cannot',
155
+ 'load them and will find nothing. Invoke them ONLY as fenced tool_call JSON',
156
+ 'blocks in your reply text - do not search for them, and do not fall back to',
157
+ 'Bash or curl against any API.',
158
+ 'Use ONLY these gateway tool_call blocks to gather. Do NOT read log files,',
159
+ 'databases, or the filesystem with Bash, Read, or other native tools - those are',
160
+ 'not the task board and will make the report wrong. Your gateway tool findings',
161
+ 'are the primary source; the window summary below is only a hint.',
162
+ '',
163
+ 'After gathering, if the window contains a durable decision or lesson worth',
164
+ 'keeping, persist exactly ONE with a gateway tool_call to mama_save (type',
165
+ '"decision", with topic, decision, reasoning). Only save when it is genuinely',
166
+ 'durable; skip the save otherwise. This is your judgement, not a requirement.',
167
+ ]
168
+ : []),
169
+ ...(this.opts.boardPublishLines && this.opts.boardPublishLines.length > 0
170
+ ? ['', ...this.opts.boardPublishLines]
171
+ : []),
172
+ ]
173
+ : [
174
+ 'You are the operator agent. Write a SHORT proactive digest for your owner about the',
175
+ 'situation below - what happened, what recurred, and what the owner may want to look at.',
176
+ '2-6 lines, plain language, no markdown tables. Default to sending the brief when there',
177
+ 'is meaningful activity; reply exactly NOTHING only if this window is pure noise',
178
+ '(duplicates, bot chatter) with nothing the owner could act on.',
179
+ ];
180
+ return [
181
+ ...framing,
182
+ // Attribution discipline (owner feedback: the only quality complaint on day-1
183
+ // reports was merged sender/room identities).
184
+ 'Attribute people and rooms EXACTLY as they appear in the source lines: a channel/room',
185
+ 'name is never a person, and a sender is never a room. If you cannot tell who said',
186
+ 'something, write "(sender unclear)" instead of guessing or merging names.',
187
+ // G2 success signal: machine trailer, stripped before delivery.
188
+ 'After the report body, add ONE final line exactly in this form:',
189
+ 'USED_TRIGGERS: <comma-separated ids of the fired triggers (from [id: ...] in the fire',
190
+ 'activity below) whose fire or recalled memory you actually drew on>, or',
191
+ 'USED_TRIGGERS: none if you drew on none. This line is machine-read and stripped',
192
+ 'before the owner sees the report.',
193
+ 'Reply in the language the owner uses on these channels if you can tell; otherwise English.',
194
+ // Local wall-clock, not UTC: the first live report stamped itself in UTC because the
195
+ // agent had no local time reference (Kagemusha injects local time the same way).
196
+ `Current local time: ${new Date().toLocaleString()}. Use LOCAL time in the report, never UTC.`,
197
+ '',
198
+ 'Window (per channel; excerpts truncated):',
199
+ ...(windowLines.length > 0 ? windowLines : ['- (no channel messages this window)']),
200
+ '',
201
+ `Triggers newly authored this window: ${this.authored}`,
202
+ 'Fire activity:',
203
+ ...(fireLines.length > 0 ? fireLines : ['- (no triggers fired this window)']),
204
+ '',
205
+ 'Memory your triggers surfaced this window:',
206
+ ...(memoryLines.length > 0 ? memoryLines : ['- (none)']),
207
+ ].join('\n');
208
+ }
209
+ }
210
+ exports.SituationReporter = SituationReporter;
211
+ //# sourceMappingURL=situation-report.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"situation-report.js","sourceRoot":"","sources":["../../src/operator/situation-report.ts"],"names":[],"mappings":";;;AAoBA;;;;GAIG;AACU,QAAA,wBAAwB,GAAG,wBAAwB,CAAC;AAWjE,kGAAkG;AAClG,MAAM,wBAAwB,GAAG,CAAC,CAAC;AACnC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC,MAAM,YAAY,GAAG,EAAE,CAAC;AA0CxB,oFAAoF;AACpF,MAAM,qBAAqB,GAAG,iCAAiC,CAAC;AAEhE,MAAa,iBAAiB;IACpB,eAAe,GAAG,IAAI,GAAG,EAAyB,CAAC;IACnD,WAAW,GAAG,CAAC,CAAC;IAChB,OAAO,GAAG,IAAI,GAAG,EAAmB,CAAC;IACrC,QAAQ,GAAG,CAAC,CAAC;IACb,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC,CAAC,sCAAsC;IAC5E,IAAI,CAA2B;IAEvC,YAAY,OAAiC,EAAE;QAC7C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,0EAA0E;IAC1E,YAAY,CAAC,MAA8B;QACzC,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;YACvB,MAAM,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,C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