@jungjaehoon/mama-os 0.48.4 → 0.49.1

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 (166) hide show
  1. package/dist/agent/agent-loop.d.ts +6 -7
  2. package/dist/agent/agent-loop.d.ts.map +1 -1
  3. package/dist/agent/agent-loop.js +106 -80
  4. package/dist/agent/agent-loop.js.map +1 -1
  5. package/dist/agent/code-act/host-bridge.d.ts.map +1 -1
  6. package/dist/agent/code-act/host-bridge.js +7 -9
  7. package/dist/agent/code-act/host-bridge.js.map +1 -1
  8. package/dist/agent/codex-home.d.ts.map +1 -1
  9. package/dist/agent/codex-home.js +3 -1
  10. package/dist/agent/codex-home.js.map +1 -1
  11. package/dist/agent/gateway-tool-executor.d.ts +0 -16
  12. package/dist/agent/gateway-tool-executor.d.ts.map +1 -1
  13. package/dist/agent/gateway-tool-executor.js +0 -51
  14. package/dist/agent/gateway-tool-executor.js.map +1 -1
  15. package/dist/agent/gateway-tools.md +1 -2
  16. package/dist/agent/os-agent-capabilities.md +14 -34
  17. package/dist/agent/role-manager.d.ts.map +1 -1
  18. package/dist/agent/role-manager.js +6 -3
  19. package/dist/agent/role-manager.js.map +1 -1
  20. package/dist/agent/tool-registry.d.ts.map +1 -1
  21. package/dist/agent/tool-registry.js +27 -8
  22. package/dist/agent/tool-registry.js.map +1 -1
  23. package/dist/agent/types.d.ts +20 -6
  24. package/dist/agent/types.d.ts.map +1 -1
  25. package/dist/agent/types.js.map +1 -1
  26. package/dist/api/graph-api-types.d.ts +0 -18
  27. package/dist/api/graph-api-types.d.ts.map +1 -1
  28. package/dist/api/graph-api.d.ts.map +1 -1
  29. package/dist/api/graph-api.js +9 -81
  30. package/dist/api/graph-api.js.map +1 -1
  31. package/dist/cli/commands/start.d.ts +7 -16
  32. package/dist/cli/commands/start.d.ts.map +1 -1
  33. package/dist/cli/commands/start.js +188 -189
  34. package/dist/cli/commands/start.js.map +1 -1
  35. package/dist/cli/config/types.d.ts.map +1 -1
  36. package/dist/cli/config/types.js +11 -4
  37. package/dist/cli/config/types.js.map +1 -1
  38. package/dist/cli/runtime/agent-loop-init.d.ts.map +1 -1
  39. package/dist/cli/runtime/agent-loop-init.js +31 -11
  40. package/dist/cli/runtime/agent-loop-init.js.map +1 -1
  41. package/dist/cli/runtime/api-routes-init.d.ts +0 -2
  42. package/dist/cli/runtime/api-routes-init.d.ts.map +1 -1
  43. package/dist/cli/runtime/api-routes-init.js +9 -95
  44. package/dist/cli/runtime/api-routes-init.js.map +1 -1
  45. package/dist/cli/runtime/api-server-init.d.ts +2 -2
  46. package/dist/cli/runtime/api-server-init.d.ts.map +1 -1
  47. package/dist/cli/runtime/api-server-init.js +2 -2
  48. package/dist/cli/runtime/api-server-init.js.map +1 -1
  49. package/dist/cli/runtime/scheduler-init.d.ts +3 -4
  50. package/dist/cli/runtime/scheduler-init.d.ts.map +1 -1
  51. package/dist/cli/runtime/scheduler-init.js +6 -16
  52. package/dist/cli/runtime/scheduler-init.js.map +1 -1
  53. package/dist/cli/runtime/shutdown.d.ts +0 -1
  54. package/dist/cli/runtime/shutdown.d.ts.map +1 -1
  55. package/dist/cli/runtime/shutdown.js +1 -1
  56. package/dist/cli/runtime/shutdown.js.map +1 -1
  57. package/dist/cli/runtime/types.d.ts +0 -5
  58. package/dist/cli/runtime/types.d.ts.map +1 -1
  59. package/dist/concurrency/lane-manager.d.ts +1 -1
  60. package/dist/concurrency/lane-manager.d.ts.map +1 -1
  61. package/dist/concurrency/lane-manager.js +4 -2
  62. package/dist/concurrency/lane-manager.js.map +1 -1
  63. package/dist/concurrency/types.d.ts +4 -0
  64. package/dist/concurrency/types.d.ts.map +1 -1
  65. package/dist/concurrency/types.js.map +1 -1
  66. package/dist/envelope/types.d.ts +1 -1
  67. package/dist/envelope/types.d.ts.map +1 -1
  68. package/dist/envelope/types.js.map +1 -1
  69. package/dist/gateways/message-router.d.ts +15 -71
  70. package/dist/gateways/message-router.d.ts.map +1 -1
  71. package/dist/gateways/message-router.js +124 -493
  72. package/dist/gateways/message-router.js.map +1 -1
  73. package/dist/gateways/session-store.d.ts +3 -23
  74. package/dist/gateways/session-store.d.ts.map +1 -1
  75. package/dist/gateways/session-store.js +2 -64
  76. package/dist/gateways/session-store.js.map +1 -1
  77. package/dist/gateways/telegram-report-context-store.d.ts +4 -66
  78. package/dist/gateways/telegram-report-context-store.d.ts.map +1 -1
  79. package/dist/gateways/telegram-report-context-store.js +11 -235
  80. package/dist/gateways/telegram-report-context-store.js.map +1 -1
  81. package/dist/gateways/turn-contract.d.ts +7 -3
  82. package/dist/gateways/turn-contract.d.ts.map +1 -1
  83. package/dist/operator/operator-trigger-loop.d.ts +1 -12
  84. package/dist/operator/operator-trigger-loop.d.ts.map +1 -1
  85. package/dist/operator/operator-trigger-loop.js +6 -40
  86. package/dist/operator/operator-trigger-loop.js.map +1 -1
  87. package/dist/operator/owner-event-loop.d.ts +9 -8
  88. package/dist/operator/owner-event-loop.d.ts.map +1 -1
  89. package/dist/operator/owner-event-loop.js +8 -22
  90. package/dist/operator/owner-event-loop.js.map +1 -1
  91. package/dist/operator/owner-event-policy.d.ts.map +1 -1
  92. package/dist/operator/owner-event-policy.js +0 -2
  93. package/dist/operator/owner-event-policy.js.map +1 -1
  94. package/dist/operator/owner-event-prompt.d.ts +0 -2
  95. package/dist/operator/owner-event-prompt.d.ts.map +1 -1
  96. package/dist/operator/owner-event-prompt.js +1 -8
  97. package/dist/operator/owner-event-prompt.js.map +1 -1
  98. package/dist/operator/owner-runtime-journal.d.ts +21 -0
  99. package/dist/operator/owner-runtime-journal.d.ts.map +1 -0
  100. package/dist/operator/owner-runtime-journal.js +131 -0
  101. package/dist/operator/owner-runtime-journal.js.map +1 -0
  102. package/dist/operator/owner-runtime.d.ts +32 -0
  103. package/dist/operator/owner-runtime.d.ts.map +1 -0
  104. package/dist/operator/owner-runtime.js +31 -0
  105. package/dist/operator/owner-runtime.js.map +1 -0
  106. package/dist/operator/pending-report-store.d.ts +2 -2
  107. package/dist/operator/pending-report-store.d.ts.map +1 -1
  108. package/dist/operator/pending-report-store.js +4 -1
  109. package/dist/operator/pending-report-store.js.map +1 -1
  110. package/dist/operator/report-run.d.ts +7 -10
  111. package/dist/operator/report-run.d.ts.map +1 -1
  112. package/dist/operator/report-run.js +5 -26
  113. package/dist/operator/report-run.js.map +1 -1
  114. package/dist/operator/situation-report.d.ts +25 -6
  115. package/dist/operator/situation-report.d.ts.map +1 -1
  116. package/dist/operator/situation-report.js +28 -37
  117. package/dist/operator/situation-report.js.map +1 -1
  118. package/dist/operator/task-ledger.d.ts +8 -1
  119. package/dist/operator/task-ledger.d.ts.map +1 -1
  120. package/dist/operator/task-ledger.js +51 -16
  121. package/dist/operator/task-ledger.js.map +1 -1
  122. package/dist/operator/task-list-views.d.ts.map +1 -1
  123. package/dist/operator/task-list-views.js +45 -24
  124. package/dist/operator/task-list-views.js.map +1 -1
  125. package/dist/operator/task-temporal.d.ts +3 -0
  126. package/dist/operator/task-temporal.d.ts.map +1 -1
  127. package/dist/operator/task-temporal.js +12 -0
  128. package/dist/operator/task-temporal.js.map +1 -1
  129. package/dist/operator/trigger-author.d.ts +0 -45
  130. package/dist/operator/trigger-author.d.ts.map +1 -1
  131. package/dist/operator/trigger-author.js +0 -122
  132. package/dist/operator/trigger-author.js.map +1 -1
  133. package/dist/operator/worker-run.d.ts +9 -23
  134. package/dist/operator/worker-run.d.ts.map +1 -1
  135. package/dist/operator/worker-run.js +18 -74
  136. package/dist/operator/worker-run.js.map +1 -1
  137. package/dist/operator/workorder-consumer.d.ts.map +1 -1
  138. package/dist/operator/workorder-consumer.js +7 -0
  139. package/dist/operator/workorder-consumer.js.map +1 -1
  140. package/dist/scheduler/cron-worker.d.ts +0 -3
  141. package/dist/scheduler/cron-worker.d.ts.map +1 -1
  142. package/dist/scheduler/cron-worker.js +2 -13
  143. package/dist/scheduler/cron-worker.js.map +1 -1
  144. package/dist/scheduler/heartbeat.d.ts +3 -1
  145. package/dist/scheduler/heartbeat.d.ts.map +1 -1
  146. package/dist/scheduler/heartbeat.js +13 -4
  147. package/dist/scheduler/heartbeat.js.map +1 -1
  148. package/dist/validation/types.d.ts +1 -1
  149. package/dist/validation/types.js +1 -1
  150. package/package.json +1 -1
  151. package/dist/cli/runtime/memory-agent-init.d.ts +0 -37
  152. package/dist/cli/runtime/memory-agent-init.d.ts.map +0 -1
  153. package/dist/cli/runtime/memory-agent-init.js +0 -202
  154. package/dist/cli/runtime/memory-agent-init.js.map +0 -1
  155. package/dist/gateways/owner-report-inbox.d.ts +0 -40
  156. package/dist/gateways/owner-report-inbox.d.ts.map +0 -1
  157. package/dist/gateways/owner-report-inbox.js +0 -128
  158. package/dist/gateways/owner-report-inbox.js.map +0 -1
  159. package/dist/multi-agent/memory-agent-persona.d.ts +0 -11
  160. package/dist/multi-agent/memory-agent-persona.d.ts.map +0 -1
  161. package/dist/multi-agent/memory-agent-persona.js +0 -175
  162. package/dist/multi-agent/memory-agent-persona.js.map +0 -1
  163. package/dist/operator/report-context.d.ts +0 -184
  164. package/dist/operator/report-context.d.ts.map +0 -1
  165. package/dist/operator/report-context.js +0 -1052
  166. package/dist/operator/report-context.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"heartbeat.js","sourceRoot":"","sources":["../../src/scheduler/heartbeat.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,2BAA8C;AAC9C,+BAA4B;AAE5B,iEAA6D;AAC7D,+DAA2D;AAa3D,MAAM,cAAc,GAAoB;IACtC,QAAQ,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,aAAa;IACvC,UAAU,EAAE,EAAE;IACd,QAAQ,EAAE,CAAC;CACZ,CAAC;AAEF,MAAa,kBAAkB;IACrB,MAAM,CAAkB;IACxB,SAAS,CAAY;IACrB,KAAK,GAA0B,IAAI,CAAC;IACpC,YAAY,GAA0B,IAAI,CAAC;IAC3C,OAAO,GAAG,KAAK,CAAC;IAChB,gBAAgB,CAAyD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C,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;YACxE,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;YAC3C,YAAY,CAAC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU;QACd,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;QAC1C,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,OAAO,qBAAqB,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,SAAS,CAAC,MAAgC;QACxC,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;QAE5C,uCAAuC;QACvC,IAAI,IAAI,CAAC,OAAO,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YACpC,IAAI,CAAC,IAAI,EAAE,CAAC;YACZ,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,CAAC;IACH,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAC5B,CAAC;CACF;AArMD,gDAqMC"}
@@ -2,7 +2,7 @@
2
2
  * Validation Session Domain Types + Metric Profiles
3
3
  *
4
4
  * Shared observable validation model for agent execution.
5
- * Every run path (delegate, agent_test, system_run, audit) feeds the same model.
5
+ * Every validation run path feeds the same model.
6
6
  */
7
7
  export type ExecutionStatus = 'started' | 'completed' | 'failed' | 'timeout';
8
8
  export type ValidationOutcome = 'healthy' | 'improved' | 'regressed' | 'inconclusive';
@@ -3,7 +3,7 @@
3
3
  * Validation Session Domain Types + Metric Profiles
4
4
  *
5
5
  * Shared observable validation model for agent execution.
6
- * Every run path (delegate, agent_test, system_run, audit) feeds the same model.
6
+ * Every validation run path feeds the same model.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.SCHEMA_VERSION = void 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jungjaehoon/mama-os",
3
- "version": "0.48.4",
3
+ "version": "0.49.1",
4
4
  "description": "MAMA OS - The local work agent behind your messenger.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -1,37 +0,0 @@
1
- /**
2
- * Memory Agent initialization.
3
- *
4
- * Extracted from cli/commands/start.ts to keep the orchestrator thin.
5
- * All logic and function signatures are unchanged.
6
- *
7
- * Responsibilities:
8
- * 1. Loads memory agent persona via ensureMemoryPersona()
9
- * 2. Creates memoryAgentContext (AgentContext)
10
- * 3. Constructs a new AgentLoop for the memory agent (model: claude-sonnet-4-6, maxTurns: 3, tools: mama_search/mama_save)
11
- * 4. Creates memoryProcessManager with getSharedProcess().sendMessage() implementation:
12
- * - Bootstrap delivery (first-time only, with lock)
13
- * - Decision count tracking (before/after)
14
- * - buildMemoryAuditAckFromAgentResult for ack classification
15
- * 5. Wires to messageRouter.setMemoryAgent()
16
- */
17
- import type { MAMAConfig } from '../config/types.js';
18
- import type { OAuthManager } from '../../auth/index.js';
19
- import { AgentLoop } from '../../agent/index.js';
20
- import type { GatewayToolExecutor } from '../../agent/gateway-tool-executor.js';
21
- import type { MessageRouter } from '../../gateways/message-router.js';
22
- import type { MAMAApiShape } from './types.js';
23
- import type { MamaApiClient } from '../../gateways/context-injector.js';
24
- /**
25
- * Result returned by initMemoryAgent.
26
- */
27
- export interface MemoryAgentInitResult {
28
- memoryAgentLoop: AgentLoop | null;
29
- }
30
- /**
31
- * Initialize the memory agent (persistent process for fact extraction).
32
- *
33
- * On success, wires memoryProcessManager into messageRouter via setMemoryAgent().
34
- * On failure, logs a non-fatal warning and returns { memoryAgentLoop: null }.
35
- */
36
- export declare function initMemoryAgent(oauthManager: OAuthManager, config: MAMAConfig, _mamaApi: MAMAApiShape, mamaApiClient: MamaApiClient, messageRouter: MessageRouter, runtimeBackend: string, toolExecutor: GatewayToolExecutor): Promise<MemoryAgentInitResult>;
37
- //# sourceMappingURL=memory-agent-init.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"memory-agent-init.d.ts","sourceRoot":"","sources":["../../../src/cli/runtime/memory-agent-init.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAOhF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAQtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAExE;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,eAAe,EAAE,SAAS,GAAG,IAAI,CAAC;CACnC;AAmBD;;;;;GAKG;AACH,wBAAsB,eAAe,CACnC,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,UAAU,EAKlB,QAAQ,EAAE,YAAY,EACtB,aAAa,EAAE,aAAa,EAC5B,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,MAAM,EACtB,YAAY,EAAE,mBAAmB,GAChC,OAAO,CAAC,qBAAqB,CAAC,CAmLhC"}
@@ -1,202 +0,0 @@
1
- "use strict";
2
- /**
3
- * Memory Agent initialization.
4
- *
5
- * Extracted from cli/commands/start.ts to keep the orchestrator thin.
6
- * All logic and function signatures are unchanged.
7
- *
8
- * Responsibilities:
9
- * 1. Loads memory agent persona via ensureMemoryPersona()
10
- * 2. Creates memoryAgentContext (AgentContext)
11
- * 3. Constructs a new AgentLoop for the memory agent (model: claude-sonnet-4-6, maxTurns: 3, tools: mama_search/mama_save)
12
- * 4. Creates memoryProcessManager with getSharedProcess().sendMessage() implementation:
13
- * - Bootstrap delivery (first-time only, with lock)
14
- * - Decision count tracking (before/after)
15
- * - buildMemoryAuditAckFromAgentResult for ack classification
16
- * 5. Wires to messageRouter.setMemoryAgent()
17
- */
18
- Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.initMemoryAgent = initMemoryAgent;
20
- const node_fs_1 = require("node:fs");
21
- const node_os_1 = require("node:os");
22
- const config_manager_js_1 = require("../config/config-manager.js");
23
- const index_js_1 = require("../../agent/index.js");
24
- const backend_model_policy_js_1 = require("../../agent/backend-model-policy.js");
25
- const bootstrap_context_js_1 = require("../../memory/bootstrap-context.js");
26
- const memory_agent_ack_js_1 = require("../../memory/memory-agent-ack.js");
27
- const scope_context_js_1 = require("../../memory/scope-context.js");
28
- function isBackendType(value) {
29
- return value === 'claude' || value === 'codex' || value === 'cline';
30
- }
31
- function resolveMemoryBackend(configuredBackend, runtimeBackend) {
32
- if (isBackendType(configuredBackend)) {
33
- return configuredBackend;
34
- }
35
- if (isBackendType(runtimeBackend)) {
36
- return runtimeBackend;
37
- }
38
- return 'claude';
39
- }
40
- /**
41
- * Initialize the memory agent (persistent process for fact extraction).
42
- *
43
- * On success, wires memoryProcessManager into messageRouter via setMemoryAgent().
44
- * On failure, logs a non-fatal warning and returns { memoryAgentLoop: null }.
45
- */
46
- async function initMemoryAgent(oauthManager, config,
47
- // Task 7: the memory agent no longer carries a private executor built around
48
- // this mamaApi - it shares the boot executor (already wired via setMamaApi),
49
- // so the positional arg is retained for the call signature but unused here.
50
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
51
- _mamaApi, mamaApiClient, messageRouter, runtimeBackend, toolExecutor) {
52
- // getAdapter is used directly for DB queries after initDB has run
53
- // eslint-disable-next-line @typescript-eslint/no-require-imports
54
- const { getAdapter } = require('@jungjaehoon/mama-core/db-manager');
55
- let memoryAgentLoop = null;
56
- // Initialize memory agent (persistent process for fact extraction)
57
- try {
58
- const { ensureMemoryPersona } = await import('../../multi-agent/memory-agent-persona.js');
59
- const personaPath = ensureMemoryPersona();
60
- const memoryPersona = (0, node_fs_1.readFileSync)(personaPath, 'utf-8');
61
- const memoryAgentConfig = config.multi_agent?.agents?.memory;
62
- const memoryBackend = resolveMemoryBackend(memoryAgentConfig?.backend, runtimeBackend);
63
- const memoryAgentContext = {
64
- source: 'memory-agent',
65
- platform: 'cli',
66
- roleName: 'memory_agent',
67
- role: {
68
- allowedTools: memoryBackend === 'cline'
69
- ? ['code_act', 'mama_search', 'mama_save']
70
- : ['mama_search', 'mama_save'],
71
- blockedTools: ['Read', 'Write', 'Bash', 'Grep', 'Glob', 'Edit'],
72
- systemControl: false,
73
- sensitiveAccess: false,
74
- },
75
- session: {
76
- sessionId: 'memory-agent:shared',
77
- channelId: 'shared',
78
- startedAt: new Date(),
79
- },
80
- capabilities: memoryBackend === 'cline'
81
- ? ['code_act', 'mama_search', 'mama_save']
82
- : ['mama_search', 'mama_save'],
83
- limitations: ['No file or shell access'],
84
- tier: 2,
85
- backend: memoryBackend,
86
- };
87
- const memoryModel = (0, backend_model_policy_js_1.resolveBackendScopedModel)({
88
- backend: memoryBackend,
89
- model: memoryAgentConfig?.model,
90
- inheritedBackend: isBackendType(runtimeBackend) ? runtimeBackend : config.agent.backend,
91
- inheritedModel: config.agent.model,
92
- });
93
- memoryAgentLoop = new index_js_1.AgentLoop(oauthManager, {
94
- systemPrompt: memoryPersona,
95
- model: memoryModel,
96
- maxTurns: 3,
97
- backend: memoryBackend,
98
- useCodeAct: memoryBackend === 'cline',
99
- // A codex memory agent writes the shared managed config like every other
100
- // Codex process, so it has to agree on the effort or it flips theirs.
101
- codexEffort: (0, backend_model_policy_js_1.codexEffortForBackend)(memoryBackend, config.agent.effort),
102
- clineCommand: process.env.MAMA_CLINE_COMMAND ?? config.agent.cline_command,
103
- clineProvider: config.agent.cline_provider,
104
- clineDataDir: config.agent.cline_data_dir,
105
- toolsConfig: {
106
- gateway: ['mama_search', 'mama_save'],
107
- mcp: [],
108
- },
109
- // Fold into the boot-wired shared executor (Task 7): the private twin
110
- // existed ONLY to carry the initMamaCore mamaApi (now on the shared
111
- // executor via setMamaApi), while the shared executor otherwise lazily
112
- // built a second API/adapter stack against the same DB. The memory
113
- // agent's tool restriction lives in toolsConfig + per-call context, not
114
- // executor instance state, so sharing is safe (Task 1 per-call model).
115
- executor: toolExecutor,
116
- });
117
- memoryAgentLoop.setSessionKey('memory-agent:shared');
118
- let memoryBootstrapDelivered = false;
119
- let memoryBootstrapLock = null;
120
- const memoryWorkspaceProjectId = process.env.MAMA_WORKSPACE ||
121
- (0, config_manager_js_1.expandPath)(config.workspace?.path || `${(0, node_os_1.homedir)()}/.mama/workspace`);
122
- const memoryProcessManager = {
123
- async getSharedProcess() {
124
- return {
125
- async sendMessage(content, options) {
126
- if (!memoryAgentLoop) {
127
- throw new Error('Memory agent loop is not initialized');
128
- }
129
- if (!memoryBootstrapDelivered && memoryBootstrapLock) {
130
- await memoryBootstrapLock;
131
- }
132
- // Safe: initDB() completed before memoryProcessManager is created.
133
- const adapter = getAdapter();
134
- const beforeDecisionCount = Number(adapter.prepare('SELECT COUNT(*) AS count FROM decisions').get().count);
135
- let prompt = content;
136
- let shouldDeliverBootstrap = false;
137
- let resolveBootstrapLock;
138
- let rejectBootstrapLock;
139
- if (!memoryBootstrapDelivered) {
140
- shouldDeliverBootstrap = true;
141
- memoryBootstrapLock = new Promise((resolve, reject) => {
142
- resolveBootstrapLock = resolve;
143
- rejectBootstrapLock = reject;
144
- });
145
- const bootstrap = await (0, bootstrap_context_js_1.buildStandaloneMemoryBootstrap)({
146
- mamaApi: mamaApiClient,
147
- scopes: (0, scope_context_js_1.deriveMemoryScopes)({
148
- source: 'memory-agent',
149
- channelId: 'shared',
150
- projectId: memoryWorkspaceProjectId,
151
- }),
152
- currentGoal: 'Maintain current memory truth and audit ongoing conversations',
153
- mainAgentState: {
154
- active_goal: 'Maintain current memory truth and audit ongoing conversations',
155
- active_channel: 'shared',
156
- },
157
- });
158
- prompt = `${(0, bootstrap_context_js_1.formatMemoryBootstrap)(bootstrap)}\n\n---\n\n${content}`;
159
- }
160
- try {
161
- const result = await memoryAgentLoop.run(prompt, {
162
- source: 'memory-agent',
163
- channelId: 'shared',
164
- agentContext: memoryAgentContext,
165
- stopAfterSuccessfulTools: ['mama_save'],
166
- sourceTurnId: options?.sourceTurnId,
167
- sourceMessageRef: options?.sourceMessageRef,
168
- parentModelRunId: options?.parentModelRunId,
169
- });
170
- const afterDecisionCount = Number(adapter.prepare('SELECT COUNT(*) AS count FROM decisions').get().count);
171
- const ack = (0, memory_agent_ack_js_1.buildMemoryAuditAckFromAgentResult)(result, beforeDecisionCount, afterDecisionCount);
172
- if (shouldDeliverBootstrap) {
173
- memoryBootstrapDelivered = true;
174
- if (resolveBootstrapLock) {
175
- resolveBootstrapLock();
176
- }
177
- memoryBootstrapLock = null;
178
- }
179
- return { response: result.response, ack };
180
- }
181
- catch (error) {
182
- if (shouldDeliverBootstrap) {
183
- if (rejectBootstrapLock) {
184
- rejectBootstrapLock(error);
185
- }
186
- memoryBootstrapLock = null;
187
- }
188
- throw error;
189
- }
190
- },
191
- };
192
- },
193
- };
194
- messageRouter.setMemoryAgent(memoryProcessManager);
195
- console.log('✓ Memory agent initialized');
196
- }
197
- catch (err) {
198
- console.warn(`[memory-agent] Init failed (non-fatal): ${err instanceof Error ? err.message : String(err)}`);
199
- }
200
- return { memoryAgentLoop };
201
- }
202
- //# sourceMappingURL=memory-agent-init.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"memory-agent-init.js","sourceRoot":"","sources":["../../../src/cli/runtime/memory-agent-init.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;AAyDH,0CA+LC;AAtPD,qCAAuC;AACvC,qCAAkC;AAGlC,mEAAyD;AAEzD,mDAAiD;AAGjD,iFAG6C;AAI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AO,CAAC,yCAAyC,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,CACvE,CAAC;4BACF,MAAM,GAAG,GAAG,IAAA,wDAAkC,EAC5C,MAAM,EACN,mBAAmB,EACnB,kBAAkB,CACnB,CAAC;4BAEF,IAAI,sBAAsB,EAAE,CAAC;gCAC3B,wBAAwB,GAAG,IAAI,CAAC;gCAChC,IAAI,oBAAoB,EAAE,CAAC;oCACzB,oBAAoB,EAAE,CAAC;gCACzB,CAAC;gCACD,mBAAmB,GAAG,IAAI,CAAC;4BAC7B,CAAC;4BAED,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC;wBAC5C,CAAC;wBAAC,OAAO,KAAK,EAAE,CAAC;4BACf,IAAI,sBAAsB,EAAE,CAAC;gCAC3B,IAAI,mBAAmB,EAAE,CAAC;oCACxB,mBAAmB,CAAC,KAAK,CAAC,CAAC;gCAC7B,CAAC;gCACD,mBAAmB,GAAG,IAAI,CAAC;4BAC7B,CAAC;4BACD,MAAM,KAAK,CAAC;wBACd,CAAC;oBACH,CAAC;iBACF,CAAC;YACJ,CAAC;SACF,CAAC;QAEF,aAAa,CAAC,cAAc,CAAC,oBAAqD,CAAC,CAAC;QACpF,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;IAC5C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CACV,2CAA2C,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAC9F,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,eAAe,EAAE,CAAC;AAC7B,CAAC"}
@@ -1,40 +0,0 @@
1
- /**
2
- * TG-05/TG-06: owner-report inbox - the read surface a verified owner turn
3
- * uses to consume delivered-pending reports as bounded model context
4
- * (docs/development/telegram-outbound-context-inbox-design.md, Decision 5-6).
5
- *
6
- * Lookup must happen only after the Telegram owner-console trust check; the
7
- * caller (MessageRouter) gates on the resolved role, and the store scopes
8
- * every read to one exact target.
9
- */
10
- import type { ReportContextTarget, TelegramReportContextStore } from './telegram-report-context-store.js';
11
- import type { ConversationTurn } from './types.js';
12
- export interface OwnerReportSnapshot {
13
- version: 'v1';
14
- /** The exact complete Projection V1 block. */
15
- text: string;
16
- /** Lowercase hex SHA-256 over the exact UTF-8 bytes of `text`. */
17
- projectionHash: string;
18
- /** Ordered delivery IDs rendered in the block - the only consumable set. */
19
- deliveryIds: string[];
20
- }
21
- export interface OwnerReportInboxPort {
22
- snapshot(target: ReportContextTarget): OwnerReportSnapshot | null;
23
- /** Committed-projection history for an actual new backend conversation. */
24
- historyBlock(target: ReportContextTarget, turns: ConversationTurn[], nowIso?: string): string;
25
- }
26
- export declare class OwnerReportInbox implements OwnerReportInboxPort {
27
- private readonly store;
28
- constructor(store: TelegramReportContextStore);
29
- snapshot(target: ReportContextTarget): OwnerReportSnapshot | null;
30
- /**
31
- * Startup restoration for an actual new backend conversation (design
32
- * Decision 7): emit the already-committed Projection V1 text of the
33
- * restored final turns' receipts, grouped in messenger-turn order. Bounded
34
- * by 48,000 code points, 64 events, and five normal receipts; the newest
35
- * complete receipt suffix that fits is taken and a receipt projection is
36
- * never sliced. Returns '' when nothing restores.
37
- */
38
- historyBlock(target: ReportContextTarget, turns: ConversationTurn[], nowIso?: string): string;
39
- }
40
- //# sourceMappingURL=owner-report-inbox.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"owner-report-inbox.d.ts","sourceRoot":"","sources":["../../src/gateways/owner-report-inbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EACV,mBAAmB,EACnB,0BAA0B,EAC3B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAsBnD,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,IAAI,CAAC;IACd,8CAA8C;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,cAAc,EAAE,MAAM,CAAC;IACvB,4EAA4E;IAC5E,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,MAAM,EAAE,mBAAmB,GAAG,mBAAmB,GAAG,IAAI,CAAC;IAClE,2EAA2E;IAC3E,YAAY,CAAC,MAAM,EAAE,mBAAmB,EAAE,KAAK,EAAE,gBAAgB,EAAE,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC/F;AAED,qBAAa,gBAAiB,YAAW,oBAAoB;IAC/C,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAAL,KAAK,EAAE,0BAA0B;IAE9D,QAAQ,CAAC,MAAM,EAAE,mBAAmB,GAAG,mBAAmB,GAAG,IAAI;IAiBjE;;;;;;;OAOG;IACH,YAAY,CAAC,MAAM,EAAE,mBAAmB,EAAE,KAAK,EAAE,gBAAgB,EAAE,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM;CAsE9F"}
@@ -1,128 +0,0 @@
1
- "use strict";
2
- /**
3
- * TG-05/TG-06: owner-report inbox - the read surface a verified owner turn
4
- * uses to consume delivered-pending reports as bounded model context
5
- * (docs/development/telegram-outbound-context-inbox-design.md, Decision 5-6).
6
- *
7
- * Lookup must happen only after the Telegram owner-console trust check; the
8
- * caller (MessageRouter) gates on the resolved role, and the store scopes
9
- * every read to one exact target.
10
- */
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.OwnerReportInbox = void 0;
13
- const node_crypto_1 = require("node:crypto");
14
- const report_projection_v1_js_1 = require("./report-projection-v1.js");
15
- /** Design Decision 7 startup-history caps. */
16
- const HISTORY_CAP_CP = 48_000;
17
- const HISTORY_MAX_EVENTS = 64;
18
- const HISTORY_MAX_RECEIPTS = 5;
19
- const HISTORY_OPEN_TAG = '<recent_owner_report_history projection="v1">';
20
- const HISTORY_CLOSE_TAG = '</recent_owner_report_history>';
21
- function countCodePoints(text) {
22
- let count = 0;
23
- let index = 0;
24
- while (index < text.length) {
25
- const codePoint = text.codePointAt(index);
26
- count += 1;
27
- index += codePoint > 0xffff ? 2 : 1;
28
- }
29
- return count;
30
- }
31
- class OwnerReportInbox {
32
- store;
33
- constructor(store) {
34
- this.store = store;
35
- }
36
- snapshot(target) {
37
- const pending = this.store.listDeliveredPending(target);
38
- if (pending.length === 0) {
39
- return null;
40
- }
41
- const projection = (0, report_projection_v1_js_1.buildOwnerReportProjectionV1)(pending);
42
- if (projection.text === '' || projection.selectedDeliveryIds.length === 0) {
43
- return null;
44
- }
45
- return {
46
- version: 'v1',
47
- text: projection.text,
48
- projectionHash: projection.projectionHash,
49
- deliveryIds: projection.selectedDeliveryIds,
50
- };
51
- }
52
- /**
53
- * Startup restoration for an actual new backend conversation (design
54
- * Decision 7): emit the already-committed Projection V1 text of the
55
- * restored final turns' receipts, grouped in messenger-turn order. Bounded
56
- * by 48,000 code points, 64 events, and five normal receipts; the newest
57
- * complete receipt suffix that fits is taken and a receipt projection is
58
- * never sliced. Returns '' when nothing restores.
59
- */
60
- historyBlock(target, turns, nowIso) {
61
- const now = nowIso ?? new Date().toISOString();
62
- const refs = turns
63
- .filter((turn) => turn.state !== 'provisional' && turn.sourceMessageRef)
64
- .map((turn) => turn.sourceMessageRef);
65
- const receipts = refs.length > 0 ? this.store.listReceiptsByRefs(refs) : [];
66
- const legacy = this.store.listLegacyRestorations(target, now);
67
- if (receipts.length === 0 && legacy.length === 0) {
68
- return '';
69
- }
70
- const groups = [
71
- ...legacy.map((entry) => ({
72
- kind: 'legacy',
73
- time: entry.consumedAtIso ?? entry.deliveredAtIso,
74
- tieBreak: entry.deliveryId,
75
- eventCount: 1,
76
- render: `[legacy_v2_consumed delivery_sha256=${sha256Hex(entry.deliveryId)} consumed_at=${entry.consumedAtIso}]\n${entry.restorationText}`,
77
- })),
78
- ...receipts.map((receipt) => ({
79
- kind: 'receipt',
80
- time: receipt.committedAtIso,
81
- tieBreak: receipt.sourceMessageRef,
82
- eventCount: receipt.deliveryIds.length,
83
- render: `[before_turn source_message_ref_sha256=${sha256Hex(receipt.sourceMessageRef)}]\n${receipt.projectionText}`,
84
- })),
85
- ].sort((a, b) => {
86
- if (a.time !== b.time)
87
- return a.time < b.time ? -1 : 1;
88
- if (a.kind !== b.kind)
89
- return a.kind === 'legacy' ? -1 : 1;
90
- return a.tieBreak < b.tieBreak ? -1 : 1;
91
- });
92
- // Newest complete suffix under the caps: 48k code points and 64 events in
93
- // aggregate, at most five NORMAL receipts. A group is never sliced.
94
- const selected = [];
95
- let eventCount = 0;
96
- let receiptCount = 0;
97
- for (let index = groups.length - 1; index >= 0; index -= 1) {
98
- const group = groups[index];
99
- if (group.kind === 'receipt' && receiptCount + 1 > HISTORY_MAX_RECEIPTS) {
100
- break;
101
- }
102
- if (eventCount + group.eventCount > HISTORY_MAX_EVENTS) {
103
- break;
104
- }
105
- const candidate = [group, ...selected];
106
- if (countCodePoints(renderHistoryBlock(candidate)) > HISTORY_CAP_CP) {
107
- break;
108
- }
109
- selected.unshift(group);
110
- eventCount += group.eventCount;
111
- if (group.kind === 'receipt') {
112
- receiptCount += 1;
113
- }
114
- }
115
- if (selected.length === 0) {
116
- return '';
117
- }
118
- return renderHistoryBlock(selected);
119
- }
120
- }
121
- exports.OwnerReportInbox = OwnerReportInbox;
122
- function sha256Hex(text) {
123
- return (0, node_crypto_1.createHash)('sha256').update(text, 'utf8').digest('hex');
124
- }
125
- function renderHistoryBlock(groups) {
126
- return `${HISTORY_OPEN_TAG}\n${groups.map((group) => group.render).join('\n\n')}\n${HISTORY_CLOSE_TAG}`;
127
- }
128
- //# sourceMappingURL=owner-report-inbox.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"owner-report-inbox.js","sourceRoot":"","sources":["../../src/gateways/owner-report-inbox.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAEH,6CAAyC;AAM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E,MAAM;YACR,CAAC;YACD,IAAI,UAAU,GAAG,KAAK,CAAC,UAAU,GAAG,kBAAkB,EAAE,CAAC;gBACvD,MAAM;YACR,CAAC;YACD,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,GAAG,QAAQ,CAAC,CAAC;YACvC,IAAI,eAAe,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,GAAG,cAAc,EAAE,CAAC;gBACpE,MAAM;YACR,CAAC;YACD,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YACxB,UAAU,IAAI,KAAK,CAAC,UAAU,CAAC;YAC/B,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;gBAC7B,YAAY,IAAI,CAAC,CAAC;YACpB,CAAC;QACH,CAAC;QACD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,OAAO,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IACtC,CAAC;CACF;AAlGD,4CAkGC;AAED,SAAS,SAAS,CAAC,IAAY;IAC7B,OAAO,IAAA,wBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACjE,CAAC;AAED,SAAS,kBAAkB,CAAC,MAAiC;IAC3D,OAAO,GAAG,gBAAgB,KAAK,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,iBAAiB,EAAE,CAAC;AAC1G,CAAC"}
@@ -1,11 +0,0 @@
1
- /**
2
- * Default persona for the memory agent.
3
- * Written to ~/.mama/personas/memory.md on first use if not present.
4
- */
5
- export declare const MEMORY_AGENT_PERSONA = "<!-- MAMA managed memory persona v6 -->\n\nYou are MAMA's memory auditor and curator \u2014 an internal agent that watches conversations, maintains current truth, and advises the main agent when memory matters.\n\n## Your Role\n- Observe every conversation turn between users and the main agent\n- Distinguish time-ordered memory history from current truth\n- Use memory tools directly to inspect, evolve, and save memory\n- Notify the main agent only when evidence-backed memory findings are relevant\n- Never rely on the caller to parse JSON and save for you\n\n## Topic Rules\n- MUST reuse existing topic if same subject (provided in context)\n- Use lowercase snake_case: auth_strategy, database_choice\n- Same topic = evolution chain (supersedes)\n- Related topic = builds_on or synthesizes\n\n## Mandatory Tool Workflow\nKeep the workflow minimal and terminate quickly.\n\n**Step 1 \u2014 ALWAYS call `mama_search` first.**\nSearch for existing memories related to the conversation topic. This is mandatory even if you believe nothing is worth saving \u2014 you need context to make that judgment.\n\n**Step 2 \u2014 Decide: save or no-op.**\nBased on search results and the conversation, decide whether to save or skip.\n\n**Step 3 \u2014 Call `mama_save` when the conversation contains ANY of these:**\n- A decision, preference, or technical choice\n- A constraint, requirement, or lesson learned\n- A fact about architecture, tooling, or workflow\n- A change that supersedes a prior memory\n\nWhen calling `mama_save`, always include the `scopes` field from the Memory scopes listed at the top of the prompt. Parse the scope entries (e.g., \"project:/path, channel:telegram:123\") into `[{kind: \"project\", id: \"/path\"}, {kind: \"channel\", id: \"telegram:123\"}]`.\n\n**Step 4 \u2014 Only skip (no-op) when the conversation is ALL of these:**\n- Pure greeting, thanks, or confirmation (\"ok\", \"got it\", \"thanks\")\n- Contains zero decisions, preferences, facts, or choices\n- Even then, you must have called `mama_search` first before deciding to skip\n\n## Strict Limits\n- Call `mama_search` at most once per audit.\n- Call `mama_save` at most once per audit.\n- Do NOT call resource discovery tools such as `list_mcp_resources` or `list_mcp_resource_templates`.\n- Do NOT ask follow-up questions.\n- Do NOT continue reasoning after the required tool calls finish.\n- After finishing tool work, respond with exactly one token:\n - `DONE` if a save occurred\n - `SKIP` if nothing should be saved\n\n## Relationship Types\n- supersedes: replaces a previous decision on same topic\n- builds_on: adds information to existing topic without replacing\n- synthesizes: merges multiple decisions or infers connections\n\n## Truth Model\n- Preserve history, but maintain current truth separately\n- Old memories may remain in history while becoming stale, contradicted, or superseded\n- When uncertain about relationship type, prefer builds_on over supersedes to avoid data loss\n\n## Temporal Marker Extraction\n\nWhen the conversation contains relative time expressions, extract an explicit event_date and include it in `mama_save` as the `event_date` field (ISO 8601: \"YYYY-MM-DD\").\n\n**Extract event_date when you see:**\n- Yesterday \u2192 today - 1 day\n- Last week / last month \u2192 approximate Monday or 1st of previous period\n- \"In March\", \"in January 2023\" \u2192 first day of that month (e.g., \"2023-03-01\")\n- \"A year ago\", \"3 months ago\" \u2192 today minus that duration\n- \"On Tuesday\", \"last Friday\" \u2192 nearest past occurrence of that weekday\n- An explicit date mentioned in the conversation (e.g., \"December 28th\")\n\n**How to apply:**\n1. Identify the most precise date derivable from context\n2. Pass `event_date: \"YYYY-MM-DD\"` in `mama_save` alongside the decision\n3. If no temporal marker is present, omit event_date (system defaults to created_at)\n\n## What to Save\n- Architecture decisions, technical choices, tooling preferences\n- User preferences and working style\n- Constraints, requirements, lessons learned\n- Decision changes that should supersede prior memory\n\n## What to Skip\n- Greetings, casual chat, thanks\n- Questions without answers\n- Temporary debugging steps\n- Code snippets\n\n## Response Rules\n- You MUST call at least `mama_search` before any text response.\n- Do not return JSON for the caller to parse\n- Do the memory work yourself with tools, then terminate immediately with `DONE` or `SKIP`\n- When in doubt, save \u2014 false negatives (missing a memory) are worse than false positives\n- You are an internal subagent, not the user-facing assistant\n\n## PROMOTION RUN mode\nWhen an incoming message begins with \"PROMOTION RUN\", it is a scheduled batch\npass over recent business data, NOT a turn audit. In this mode ONLY:\n- The per-audit limits above do not apply: you may call mama_search several\n times and mama_save up to 5 times, and you gather evidence yourself with\n the business-data tools projected for this run plus agent_notices as the run\n instructions describe.\n- Promote ONLY durable judgments: pricing/scope agreements, a client's standing\n preference or boundary, a process rule, a recurring risk pattern. Things that\n change how future work is done.\n- NEVER promote task lifecycle states (\"X was submitted\", \"Y is in progress\") --\n the task board owns those. Never promote greetings, scheduling chatter, or\n one-off logistics.\n- Every save needs scopes (parse from the run instructions or the source\n channel) and an event_date for when the judgment was actually made.\n- Reuse existing topics found via mama_search so evolution chains stay intact.\n- Finish with exactly one line: `PROMOTED <n>` (n = number of saves) or\n `NO_UPDATE` when nothing qualifies. When in doubt in THIS mode, do NOT save --\n promotion is curation, and a wrong policy in memory misleads every consumer.";
6
- /**
7
- * Ensure persona file exists at ~/.mama/personas/memory.md
8
- * Creates it from default if not present and upgrades legacy managed personas.
9
- */
10
- export declare function ensureMemoryPersona(mamaHomeDir?: string): string;
11
- //# sourceMappingURL=memory-agent-persona.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"memory-agent-persona.d.ts","sourceRoot":"","sources":["../../src/multi-agent/memory-agent-persona.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,eAAO,MAAM,oBAAoB,uyLAiH8C,CAAC;AA2BhF;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,GAAE,MAAiC,GAAG,MAAM,CA4B1F"}