@jungjaehoon/mama-os 0.51.2 → 0.52.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.
- package/dist/agent/agent-loop.d.ts +58 -0
- package/dist/agent/agent-loop.d.ts.map +1 -1
- package/dist/agent/agent-loop.js +503 -142
- package/dist/agent/agent-loop.js.map +1 -1
- package/dist/agent/claude-cli-wrapper.d.ts.map +1 -1
- package/dist/agent/claude-cli-wrapper.js +3 -2
- package/dist/agent/claude-cli-wrapper.js.map +1 -1
- package/dist/agent/cline-cli-adapter.d.ts +2 -0
- package/dist/agent/cline-cli-adapter.d.ts.map +1 -1
- package/dist/agent/cline-cli-adapter.js +2 -0
- package/dist/agent/cline-cli-adapter.js.map +1 -1
- package/dist/agent/code-act/constants.d.ts +1 -1
- package/dist/agent/code-act/constants.d.ts.map +1 -1
- package/dist/agent/code-act/constants.js +5 -2
- package/dist/agent/code-act/constants.js.map +1 -1
- package/dist/agent/code-act/host-bridge.d.ts.map +1 -1
- package/dist/agent/code-act/host-bridge.js +102 -4
- package/dist/agent/code-act/host-bridge.js.map +1 -1
- package/dist/agent/code-act/tool-catalog.d.ts +2 -0
- package/dist/agent/code-act/tool-catalog.d.ts.map +1 -1
- package/dist/agent/code-act/tool-catalog.js +20 -7
- package/dist/agent/code-act/tool-catalog.js.map +1 -1
- package/dist/agent/codex-app-server-process.d.ts +112 -0
- package/dist/agent/codex-app-server-process.d.ts.map +1 -1
- package/dist/agent/codex-app-server-process.js +518 -1
- package/dist/agent/codex-app-server-process.js.map +1 -1
- package/dist/agent/gateway-tool-executor.d.ts +17 -0
- package/dist/agent/gateway-tool-executor.d.ts.map +1 -1
- package/dist/agent/gateway-tool-executor.js +236 -53
- package/dist/agent/gateway-tool-executor.js.map +1 -1
- package/dist/agent/gateway-tools.md +9 -3
- package/dist/agent/model-runner.d.ts +16 -0
- package/dist/agent/model-runner.d.ts.map +1 -1
- package/dist/agent/model-runner.js.map +1 -1
- package/dist/agent/persistent-cli-adapter.d.ts +5 -0
- package/dist/agent/persistent-cli-adapter.d.ts.map +1 -1
- package/dist/agent/persistent-cli-adapter.js +7 -0
- package/dist/agent/persistent-cli-adapter.js.map +1 -1
- package/dist/agent/persistent-cli-process.d.ts.map +1 -1
- package/dist/agent/persistent-cli-process.js +27 -2
- package/dist/agent/persistent-cli-process.js.map +1 -1
- package/dist/agent/skill-loader.d.ts +7 -2
- package/dist/agent/skill-loader.d.ts.map +1 -1
- package/dist/agent/skill-loader.js +29 -8
- package/dist/agent/skill-loader.js.map +1 -1
- package/dist/agent/subagent-run-reconcile.d.ts +23 -0
- package/dist/agent/subagent-run-reconcile.d.ts.map +1 -0
- package/dist/agent/subagent-run-reconcile.js +56 -0
- package/dist/agent/subagent-run-reconcile.js.map +1 -0
- package/dist/agent/tool-registry.d.ts.map +1 -1
- package/dist/agent/tool-registry.js +126 -3
- package/dist/agent/tool-registry.js.map +1 -1
- package/dist/agent/types.d.ts +52 -2
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/api/graph-api.d.ts.map +1 -1
- package/dist/api/graph-api.js +0 -22
- package/dist/api/graph-api.js.map +1 -1
- package/dist/cli/commands/start.d.ts +8 -7
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +154 -74
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/config/types.d.ts.map +1 -1
- package/dist/cli/config/types.js +2 -1
- package/dist/cli/config/types.js.map +1 -1
- package/dist/cli/runtime/agent-loop-init.d.ts.map +1 -1
- package/dist/cli/runtime/agent-loop-init.js +1 -0
- package/dist/cli/runtime/agent-loop-init.js.map +1 -1
- package/dist/cli/runtime/api-routes-init.d.ts +1 -0
- package/dist/cli/runtime/api-routes-init.d.ts.map +1 -1
- package/dist/cli/runtime/api-routes-init.js +82 -58
- package/dist/cli/runtime/api-routes-init.js.map +1 -1
- package/dist/db/migrations/operator-procedures.d.ts +4 -0
- package/dist/db/migrations/operator-procedures.d.ts.map +1 -0
- package/dist/db/migrations/operator-procedures.js +63 -0
- package/dist/db/migrations/operator-procedures.js.map +1 -0
- package/dist/gateways/message-router.d.ts +6 -3
- package/dist/gateways/message-router.d.ts.map +1 -1
- package/dist/gateways/message-router.js +43 -131
- package/dist/gateways/message-router.js.map +1 -1
- package/dist/gateways/telegram-format.d.ts.map +1 -1
- package/dist/gateways/telegram-format.js +2 -0
- package/dist/gateways/telegram-format.js.map +1 -1
- package/dist/gateways/telegram-response-presenter.d.ts.map +1 -1
- package/dist/gateways/telegram-response-presenter.js +4 -0
- package/dist/gateways/telegram-response-presenter.js.map +1 -1
- package/dist/mcp/code-act-mcp-config.d.ts +49 -0
- package/dist/mcp/code-act-mcp-config.d.ts.map +1 -0
- package/dist/mcp/code-act-mcp-config.js +124 -0
- package/dist/mcp/code-act-mcp-config.js.map +1 -0
- package/dist/multi-agent/runtime-process.d.ts +10 -0
- package/dist/multi-agent/runtime-process.d.ts.map +1 -1
- package/dist/multi-agent/runtime-process.js +8 -0
- package/dist/multi-agent/runtime-process.js.map +1 -1
- package/dist/operator/board-delta-gate.d.ts +34 -10
- package/dist/operator/board-delta-gate.d.ts.map +1 -1
- package/dist/operator/board-delta-gate.js +68 -24
- package/dist/operator/board-delta-gate.js.map +1 -1
- package/dist/operator/board-refresh-gate.d.ts +11 -6
- package/dist/operator/board-refresh-gate.d.ts.map +1 -1
- package/dist/operator/board-refresh-gate.js +12 -11
- package/dist/operator/board-refresh-gate.js.map +1 -1
- package/dist/operator/board-slot-instructions.d.ts +30 -0
- package/dist/operator/board-slot-instructions.d.ts.map +1 -1
- package/dist/operator/board-slot-instructions.js +110 -6
- package/dist/operator/board-slot-instructions.js.map +1 -1
- package/dist/operator/console-brief.d.ts +26 -13
- package/dist/operator/console-brief.d.ts.map +1 -1
- package/dist/operator/console-brief.js +159 -83
- package/dist/operator/console-brief.js.map +1 -1
- package/dist/operator/experience-evidence.d.ts +18 -0
- package/dist/operator/experience-evidence.d.ts.map +1 -0
- package/dist/operator/experience-evidence.js +82 -0
- package/dist/operator/experience-evidence.js.map +1 -0
- package/dist/operator/experience-hints.d.ts +44 -0
- package/dist/operator/experience-hints.d.ts.map +1 -0
- package/dist/operator/experience-hints.js +98 -0
- package/dist/operator/experience-hints.js.map +1 -0
- package/dist/operator/mama-memory-port.js +1 -3
- package/dist/operator/mama-memory-port.js.map +1 -1
- package/dist/operator/operator-trigger-loop.d.ts.map +1 -1
- package/dist/operator/operator-trigger-loop.js +3 -2
- package/dist/operator/operator-trigger-loop.js.map +1 -1
- package/dist/operator/owner-action-effects.d.ts +13 -1
- package/dist/operator/owner-action-effects.d.ts.map +1 -1
- package/dist/operator/owner-action-effects.js +17 -4
- package/dist/operator/owner-action-effects.js.map +1 -1
- package/dist/operator/owner-event-inbox.d.ts +7 -1
- package/dist/operator/owner-event-inbox.d.ts.map +1 -1
- package/dist/operator/owner-event-inbox.js +8 -0
- package/dist/operator/owner-event-inbox.js.map +1 -1
- package/dist/operator/owner-event-loop.d.ts +28 -2
- package/dist/operator/owner-event-loop.d.ts.map +1 -1
- package/dist/operator/owner-event-loop.js +60 -2
- package/dist/operator/owner-event-loop.js.map +1 -1
- package/dist/operator/owner-event-policy.d.ts +20 -0
- package/dist/operator/owner-event-policy.d.ts.map +1 -1
- package/dist/operator/owner-event-policy.js +34 -5
- package/dist/operator/owner-event-policy.js.map +1 -1
- package/dist/operator/owner-event-prompt.d.ts +13 -4
- package/dist/operator/owner-event-prompt.d.ts.map +1 -1
- package/dist/operator/owner-event-prompt.js +31 -38
- package/dist/operator/owner-event-prompt.js.map +1 -1
- package/dist/operator/owner-runtime-journal.d.ts.map +1 -1
- package/dist/operator/owner-runtime-journal.js +7 -3
- package/dist/operator/owner-runtime-journal.js.map +1 -1
- package/dist/operator/owner-runtime.d.ts +6 -0
- package/dist/operator/owner-runtime.d.ts.map +1 -1
- package/dist/operator/owner-runtime.js +48 -5
- package/dist/operator/owner-runtime.js.map +1 -1
- package/dist/operator/procedure-activation.d.ts +7 -0
- package/dist/operator/procedure-activation.d.ts.map +1 -0
- package/dist/operator/procedure-activation.js +132 -0
- package/dist/operator/procedure-activation.js.map +1 -0
- package/dist/operator/procedure-projection.d.ts +25 -0
- package/dist/operator/procedure-projection.d.ts.map +1 -0
- package/dist/operator/procedure-projection.js +80 -0
- package/dist/operator/procedure-projection.js.map +1 -0
- package/dist/operator/procedure-runtime.d.ts +45 -0
- package/dist/operator/procedure-runtime.d.ts.map +1 -0
- package/dist/operator/procedure-runtime.js +496 -0
- package/dist/operator/procedure-runtime.js.map +1 -0
- package/dist/operator/procedure-store.d.ts +97 -0
- package/dist/operator/procedure-store.d.ts.map +1 -0
- package/dist/operator/procedure-store.js +368 -0
- package/dist/operator/procedure-store.js.map +1 -0
- package/dist/operator/subagent-stimulus.d.ts +34 -0
- package/dist/operator/subagent-stimulus.d.ts.map +1 -0
- package/dist/operator/subagent-stimulus.js +145 -0
- package/dist/operator/subagent-stimulus.js.map +1 -0
- package/dist/operator/task-ledger.d.ts +40 -3
- package/dist/operator/task-ledger.d.ts.map +1 -1
- package/dist/operator/task-ledger.js +63 -10
- package/dist/operator/task-ledger.js.map +1 -1
- package/dist/operator/thread-brief-memory.d.ts +29 -0
- package/dist/operator/thread-brief-memory.d.ts.map +1 -0
- package/dist/operator/thread-brief-memory.js +61 -0
- package/dist/operator/thread-brief-memory.js.map +1 -0
- package/dist/operator/trigger-author.d.ts +2 -1
- package/dist/operator/trigger-author.d.ts.map +1 -1
- package/dist/operator/trigger-author.js +23 -0
- package/dist/operator/trigger-author.js.map +1 -1
- package/dist/operator/trigger-matcher.js +1 -0
- package/dist/operator/trigger-matcher.js.map +1 -1
- package/dist/operator/trigger-registry.d.ts +5 -4
- package/dist/operator/trigger-registry.d.ts.map +1 -1
- package/dist/operator/trigger-registry.js +78 -24
- package/dist/operator/trigger-registry.js.map +1 -1
- package/dist/operator/trigger-review.d.ts +1 -1
- package/dist/operator/trigger-review.d.ts.map +1 -1
- package/dist/operator/trigger-review.js +24 -4
- package/dist/operator/trigger-review.js.map +1 -1
- package/dist/operator/trigger-types.d.ts +10 -1
- package/dist/operator/trigger-types.d.ts.map +1 -1
- package/dist/operator/worker-run.d.ts +13 -1
- package/dist/operator/worker-run.d.ts.map +1 -1
- package/dist/operator/worker-run.js +5 -2
- package/dist/operator/worker-run.js.map +1 -1
- package/dist/operator/workorder-consumer.d.ts +106 -14
- package/dist/operator/workorder-consumer.d.ts.map +1 -1
- package/dist/operator/workorder-consumer.js +295 -93
- package/dist/operator/workorder-consumer.js.map +1 -1
- package/dist/operator/workorder-hooks.d.ts +42 -9
- package/dist/operator/workorder-hooks.d.ts.map +1 -1
- package/dist/operator/workorder-hooks.js +52 -13
- package/dist/operator/workorder-hooks.js.map +1 -1
- package/dist/operator/workorder-publishers.d.ts +9 -1
- package/dist/operator/workorder-publishers.d.ts.map +1 -1
- package/dist/operator/workorder-publishers.js +21 -2
- package/dist/operator/workorder-publishers.js.map +1 -1
- package/package.json +2 -2
- package/dist/operator/learning-context.d.ts +0 -49
- package/dist/operator/learning-context.d.ts.map +0 -1
- package/dist/operator/learning-context.js +0 -129
- package/dist/operator/learning-context.js.map +0 -1
- package/dist/operator/learning-markers.d.ts +0 -19
- package/dist/operator/learning-markers.d.ts.map +0 -1
- package/dist/operator/learning-markers.js +0 -147
- package/dist/operator/learning-markers.js.map +0 -1
- package/dist/operator/learning-read.d.ts +0 -16
- package/dist/operator/learning-read.d.ts.map +0 -1
- package/dist/operator/learning-read.js +0 -18
- package/dist/operator/learning-read.js.map +0 -1
- package/dist/operator/turn-observer.d.ts +0 -34
- package/dist/operator/turn-observer.d.ts.map +0 -1
- package/dist/operator/turn-observer.js +0 -79
- package/dist/operator/turn-observer.js.map +0 -1
- package/templates/skills/heartbeat-report.md +0 -75
|
@@ -14,6 +14,7 @@ import { SessionStore } from './session-store.js';
|
|
|
14
14
|
import { type MamaApiClient } from './context-injector.js';
|
|
15
15
|
import type { NormalizedMessage, MessageRouterConfig, Session, ContentBlock } from './types.js';
|
|
16
16
|
import { type MemberEffectiveScope, type MemberEffectiveScopeInput } from './member-effective-scope.js';
|
|
17
|
+
import type { ProcedureStore } from '../operator/procedure-store.js';
|
|
17
18
|
import type { AgentLoopOptions, ModelRunProvenance } from '../agent/types.js';
|
|
18
19
|
import type { RoleConfig } from '../cli/config/types.js';
|
|
19
20
|
import type { ProcessingResult, ProcessOptions, TurnProcessor } from './turn-contract.js';
|
|
@@ -68,6 +69,8 @@ export interface AgentLoopClient {
|
|
|
68
69
|
readonly probesDurableSession?: boolean;
|
|
69
70
|
/** AgentLoop owns one bounded cross-channel recovery journal. */
|
|
70
71
|
readonly ownerRecoveryJournalEnabled?: boolean;
|
|
72
|
+
/** True when the ACTIVE model runner can spawn a native subagent the host observes. */
|
|
73
|
+
readonly supportsNativeSubagents?: boolean;
|
|
71
74
|
/**
|
|
72
75
|
* Run the agent loop with a prompt
|
|
73
76
|
*/
|
|
@@ -105,6 +108,9 @@ export declare function agentSavedInTurn(response: string | null | undefined): b
|
|
|
105
108
|
* Central hub for processing messages from all messenger platforms.
|
|
106
109
|
*/
|
|
107
110
|
export declare class MessageRouter implements TurnProcessor {
|
|
111
|
+
private procedureStore?;
|
|
112
|
+
setProcedureStore(store: ProcedureStore): void;
|
|
113
|
+
private readOwnerConsoleBrief;
|
|
108
114
|
private sessionStore;
|
|
109
115
|
private contextInjector;
|
|
110
116
|
private mamaApi;
|
|
@@ -221,9 +227,6 @@ export declare class MessageRouter implements TurnProcessor {
|
|
|
221
227
|
*/
|
|
222
228
|
updateChannelName(source: NormalizedMessage['source'], channelId: string, channelName: string): boolean;
|
|
223
229
|
private getRuntimeProjectId;
|
|
224
|
-
private observeOwnerLearning;
|
|
225
|
-
/** <policy>/<lessons> for an owner chat turn, or '' (learning-context.ts). */
|
|
226
|
-
private buildLearningPrefix;
|
|
227
230
|
private getPerTurnMemoryPrefix;
|
|
228
231
|
private resolveFrontdoorAgentId;
|
|
229
232
|
private logFrontdoorActivity;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-router.d.ts","sourceRoot":"","sources":["../../src/gateways/message-router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAyC,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAClG,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAChG,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC/B,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"message-router.d.ts","sourceRoot":"","sources":["../../src/gateways/message-router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAyC,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAClG,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAChG,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC/B,MAAM,6BAA6B,CAAC;AAQrC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AASrE,OAAO,KAAK,EAAgB,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAc1F,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,gCAAgC,CAAC;AAExC,OAAO,KAAK,EAEV,sBAA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S,EAAE,MAAM,GAAG,OAAO;IAIzC;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,mBAAmB,CAAC,GAAG,IAAI;IAiCrD;;OAEG;IACH,SAAS,IAAI,QAAQ,CAAC,mBAAmB,CAAC;IAI1C;;OAEG;IACH,iBAAiB,CACf,MAAM,EAAE,iBAAiB,CAAC,QAAQ,CAAC,EACnC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,GAClB,OAAO;IAIV,OAAO,CAAC,mBAAmB;YAIb,sBAAsB;IAoCpC,OAAO,CAAC,uBAAuB;IAI/B,OAAO,CAAC,oBAAoB;IAe5B,OAAO,CAAC,gBAAgB;CA0BzB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,iBAAiB,GAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAA8B,GACpE,eAAe,CAUjB"}
|
|
@@ -72,10 +72,6 @@ const principal_js_1 = require("./principal.js");
|
|
|
72
72
|
const debugLogger = __importStar(require("@jungjaehoon/mama-core/debug-logger"));
|
|
73
73
|
const agent_notice_queue_js_1 = require("../memory/agent-notice-queue.js");
|
|
74
74
|
const scope_context_js_1 = require("../memory/scope-context.js");
|
|
75
|
-
const learning_context_js_1 = require("../operator/learning-context.js");
|
|
76
|
-
const learning_read_js_1 = require("../operator/learning-read.js");
|
|
77
|
-
const turn_observer_js_1 = require("../operator/turn-observer.js");
|
|
78
|
-
const learning_markers_js_1 = require("../operator/learning-markers.js");
|
|
79
75
|
const recall_bundle_formatter_js_1 = require("../memory/recall-bundle-formatter.js");
|
|
80
76
|
const untrusted_content_js_1 = require("../utils/untrusted-content.js");
|
|
81
77
|
const telegram_text_entities_js_1 = require("./telegram-text-entities.js");
|
|
@@ -179,11 +175,10 @@ const TRELLO_READ_TOOLS = [
|
|
|
179
175
|
'trello_card',
|
|
180
176
|
'context_compile',
|
|
181
177
|
];
|
|
182
|
-
function buildStableRolePolicyInstructions(agentContext, roleManager, trelloAvailable, privateConnectorPolicy
|
|
178
|
+
function buildStableRolePolicyInstructions(agentContext, roleManager, trelloAvailable, privateConnectorPolicy) {
|
|
183
179
|
if (agentContext.roleName !== 'owner_console') {
|
|
184
180
|
return '';
|
|
185
181
|
}
|
|
186
|
-
const { includeOperatingDiscipline = true } = options;
|
|
187
182
|
// TG-04: name the Trello read primitives the role actually holds. The former text said
|
|
188
183
|
// Trello was reachable "only through context_compile" while the owner role also held
|
|
189
184
|
// trello_search/trello_card/trello_kanban, and forbade the lifecycle judgment the owner
|
|
@@ -201,34 +196,10 @@ function buildStableRolePolicyInstructions(agentContext, roleManager, trelloAvai
|
|
|
201
196
|
const privateStoreBoundary = privateConnectorPolicy.enabledPrivateConnectors.length > 0
|
|
202
197
|
? '\n- Private connector task tools are read-only evidence. Keep their lifecycle state separate from the native task board.'
|
|
203
198
|
: '';
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
return
|
|
207
|
-
? `${evidencePolicy}\n\n${OWNER_CONSOLE_OPERATING_DISCIPLINE}`
|
|
208
|
-
: evidencePolicy;
|
|
199
|
+
// Trust boundaries only: which store is the owner's own tracker and which are external
|
|
200
|
+
// evidence. How to investigate and how to answer are learned, not restated per turn.
|
|
201
|
+
return `- Task-store canonicity: the task board (task_list/task_create/task_update/task_reclassify) is the tracker YOU maintain for the owner. Every external store remains separate evidence: name the store a fact came from, and decide the board's lifecycle from what the evidence shows rather than copying an external status. Create a task only when the owner is asking for finite work and supply a concrete completion_criteria. Lessons, memories, principles, aspirations, observations and open-ended management questions remain records/memory/decisions.${privateStoreBoundary}${trelloBoundary}`;
|
|
209
202
|
}
|
|
210
|
-
/**
|
|
211
|
-
* Owner-console operating posture, restated on every owner turn.
|
|
212
|
-
*
|
|
213
|
-
* Without it the only behavioural instruction the chat persona carries is "Be concise", which
|
|
214
|
-
* reliably yields a cautious advisor ("you may want to check X") instead of an operator that
|
|
215
|
-
* checks X and reports the result. The scheduled operator report already carries an equivalent
|
|
216
|
-
* SOP (situation-report.ts buildPrompt); this is the interactive half of the same contract.
|
|
217
|
-
*
|
|
218
|
-
* English default, mechanism only - no personal, business, or channel strings (locale overrides
|
|
219
|
-
* belong in ~/.mama/operator/*.json, as with the other operator prompts).
|
|
220
|
-
*/
|
|
221
|
-
const OWNER_CONSOLE_OPERATING_DISCIPLINE = `## Owner console operating discipline (applies to every reply)
|
|
222
|
-
- You are the owner's operator, not an advisor. Report what you found and what you did; do not hand back work you could have done yourself.
|
|
223
|
-
- Gather before answering. Any question about status, work, or what happened is answered by CALLING your gateway tools first. Never reply "please check X" when a gateway tool can check X - check it, then report.
|
|
224
|
-
- Never claim a check you did not run. If a tool errored or was denied, name the tool and the error; a missing answer is reported as missing, never smoothed over.
|
|
225
|
-
- Act by default; ask only before the irreversible. Reversible work is yours to do and then report: reading, analysing, ranking, drafting, and writes whose only audience is this console (mama_save, task_create/task_update on your task board). Ask first only when the effect leaves this conversation and cannot be taken back - sending to another channel (telegram_send), uploading or overwriting shared files (drive_upload), storing credentials, or delegating a run you cannot cancel.
|
|
226
|
-
- A status or full-report request is YOUR judgment task in THIS conversation. Use compact descriptors and overview reads first, deepen only the material uncertainties through bounded pages, take authorized reversible actions, and answer the owner directly. Never hand it to another report agent and never reply with only an acknowledgement.
|
|
227
|
-
- Do not close by offering work you could have done. "Shall I rank these?" or "want it broken down by person?" is work, not a question - if you can do it now it belongs in this reply. End with what you did and what the OWNER has to decide, never with a menu of things you are willing to do next.
|
|
228
|
-
- Multi-step requests: decide the steps, carry out the reversible ones, then report the outcome. Do not return the plan as a suggestion and stop.
|
|
229
|
-
- Synthesize, do not dump. A raw tool result is evidence, not an answer - say what it means for the owner and cite which source answered.
|
|
230
|
-
- Before saying something is done, verify it (re-read the artifact or re-run the query) and say what you verified.
|
|
231
|
-
- Reply in the language the owner writes in.`;
|
|
232
203
|
function projectOwnerConversationAgency(roleName, role) {
|
|
233
204
|
if (roleName !== 'owner_console') {
|
|
234
205
|
return role;
|
|
@@ -258,6 +229,8 @@ const SENSITIVE_PATTERNS = [
|
|
|
258
229
|
const KOREAN_TARGETS = new Set(['korean', '한국어']);
|
|
259
230
|
const VIEWER_CONTEXT_AGENT_LIST_LIMIT = 5;
|
|
260
231
|
const VIEWER_CONTEXT_ALERT_LIMIT = 3;
|
|
232
|
+
/** Wall for a native child's own grant: long delegated work must not expire mid-run. */
|
|
233
|
+
const SUBAGENT_ENVELOPE_WALL_SECONDS = 1800;
|
|
261
234
|
const REACTIVE_ENVELOPE_EXPIRY_MULTIPLIER = 4;
|
|
262
235
|
const HOST_MESSAGE_SOURCES = new Set(['viewer', 'mobile', 'system']);
|
|
263
236
|
exports.PUBLIC_LANE_SYSTEM_PROMPT = "You are MAMA's public chat assistant. Answer directly and concisely using only the public conversation. You have no tools.";
|
|
@@ -295,8 +268,11 @@ const EMPTY_ENHANCED_PROMPT_CONTEXT = Object.freeze({
|
|
|
295
268
|
agentsContent: '',
|
|
296
269
|
rulesContent: '',
|
|
297
270
|
});
|
|
298
|
-
function buildReactiveEnvelopeInput(message, config, surface, privateConnectorPolicy, memberEffectiveScope) {
|
|
271
|
+
function buildReactiveEnvelopeInput(message, config, surface, privateConnectorPolicy, memberEffectiveScope, wallSecondsOverride) {
|
|
299
272
|
const policy = (0, reactive_config_js_1.getReactiveRoutePolicy)(message, config);
|
|
273
|
+
// A native child outlives the chat turn, so its own grant gets its own wall. Same scope,
|
|
274
|
+
// longer clock - never the parent's snapshot, which the child cannot renew.
|
|
275
|
+
const wallSeconds = wallSecondsOverride ?? policy.reactiveBudgetSeconds;
|
|
300
276
|
const memberMemoryScopes = memberEffectiveScope?.memoryScopes.map((scope) => ({ ...scope }));
|
|
301
277
|
const memberRawConnectors = memberEffectiveScope
|
|
302
278
|
? Object.entries(memberEffectiveScope.channelGrant)
|
|
@@ -326,9 +302,9 @@ function buildReactiveEnvelopeInput(message, config, surface, privateConnectorPo
|
|
|
326
302
|
allowed_destinations: policy.allowedDestinations,
|
|
327
303
|
},
|
|
328
304
|
tier: memberEffectiveScope ? 2 : 1,
|
|
329
|
-
budget: { wall_seconds:
|
|
305
|
+
budget: { wall_seconds: wallSeconds },
|
|
330
306
|
// Wall budget limits agent work; envelope validity gets slack for tool finalization.
|
|
331
|
-
expires_at: new Date(Date.now() +
|
|
307
|
+
expires_at: new Date(Date.now() + wallSeconds * 1000 * REACTIVE_ENVELOPE_EXPIRY_MULTIPLIER).toISOString(),
|
|
332
308
|
};
|
|
333
309
|
}
|
|
334
310
|
function memberReadOnlyRole(publicRole) {
|
|
@@ -402,6 +378,20 @@ function normalizeTranslationTargetLanguage(value, fallback) {
|
|
|
402
378
|
* Central hub for processing messages from all messenger platforms.
|
|
403
379
|
*/
|
|
404
380
|
class MessageRouter {
|
|
381
|
+
procedureStore;
|
|
382
|
+
setProcedureStore(store) {
|
|
383
|
+
this.procedureStore = store;
|
|
384
|
+
}
|
|
385
|
+
readOwnerConsoleBrief() {
|
|
386
|
+
const projectId = this.getRuntimeProjectId();
|
|
387
|
+
const text = (projectId
|
|
388
|
+
? this.procedureStore?.read('owner-console-brief', {
|
|
389
|
+
ownerScope: 'owner:runtime',
|
|
390
|
+
projectId,
|
|
391
|
+
})?.body
|
|
392
|
+
: undefined) ?? (0, console_brief_js_1.loadConsoleBrief)();
|
|
393
|
+
return this.procedureStore ? (0, console_brief_js_1.modernizeLegacyBriefMechanism)(text) : text;
|
|
394
|
+
}
|
|
405
395
|
sessionStore;
|
|
406
396
|
contextInjector;
|
|
407
397
|
mamaApi;
|
|
@@ -568,14 +558,14 @@ class MessageRouter {
|
|
|
568
558
|
maxDecisions: this.config.maxDecisions,
|
|
569
559
|
});
|
|
570
560
|
}
|
|
571
|
-
buildReactiveEnvelope(message, agentContext, memberEffectiveScope) {
|
|
561
|
+
buildReactiveEnvelope(message, agentContext, memberEffectiveScope, wallSecondsOverride) {
|
|
572
562
|
const config = this.envelopeConfig;
|
|
573
563
|
const authority = this.envelopeAuthority;
|
|
574
564
|
if (!config || !authority) {
|
|
575
565
|
return undefined;
|
|
576
566
|
}
|
|
577
567
|
const surface = (0, private_connector_policy_js_1.resolvePrivatePrincipalSurface)({ agentContext });
|
|
578
|
-
return authority.buildAndPersist(buildReactiveEnvelopeInput(message, config, surface, this.privateConnectorPolicy, memberEffectiveScope));
|
|
568
|
+
return authority.buildAndPersist(buildReactiveEnvelopeInput(message, config, surface, this.privateConnectorPolicy, memberEffectiveScope, wallSecondsOverride));
|
|
579
569
|
}
|
|
580
570
|
/**
|
|
581
571
|
* Create AgentContext for a message
|
|
@@ -1003,19 +993,9 @@ This protects your credentials from being exposed in chat logs.`;
|
|
|
1003
993
|
}
|
|
1004
994
|
}, streamFlushIntervalMs);
|
|
1005
995
|
}
|
|
1006
|
-
// Skill
|
|
1007
|
-
//
|
|
1008
|
-
const skillPrefix =
|
|
1009
|
-
? `<system-reminder>\n${enhanced.skillContent.replace(/<\/system-reminder>/gi, '')}\n</system-reminder>\n\n`
|
|
1010
|
-
: '';
|
|
1011
|
-
// Owner policy and lessons ride the user message for the same reason skills do:
|
|
1012
|
-
// a persistent CLI session cannot change its system prompt after creation.
|
|
1013
|
-
const learningPrefix = !isPublicLane && agentContext.roleName === 'owner_console'
|
|
1014
|
-
? await this.buildLearningPrefix(message)
|
|
1015
|
-
: '';
|
|
1016
|
-
if (!isPublicLane && enhanced.skillContent) {
|
|
1017
|
-
logger.info(`[SkillMatch] Injecting skill into user message: ${enhanced.skillContent.length} chars`);
|
|
1018
|
-
}
|
|
996
|
+
// Skill descriptions and source paths come from the common admission catalog.
|
|
997
|
+
// Keyword coincidence must not promote a whole unrelated skill into an instruction.
|
|
998
|
+
const skillPrefix = '';
|
|
1019
999
|
// NEW sessions may receive implicit memory/context prefixes. CONTINUE turns
|
|
1020
1000
|
// keep using CLI conversation state and only prepend queued audit notices.
|
|
1021
1001
|
let memoryPrefix = '';
|
|
@@ -1056,6 +1036,13 @@ This protects your credentials from being exposed in chat logs.`;
|
|
|
1056
1036
|
prepareEnvelope: () => this.buildReactiveEnvelope(message, agentContext, memberEffectiveScope),
|
|
1057
1037
|
}
|
|
1058
1038
|
: {}),
|
|
1039
|
+
// The owner's chat turn may delegate to a native child that keeps working after
|
|
1040
|
+
// the turn ends; that child gets its OWN grant on its own wall.
|
|
1041
|
+
...(runtimeSessionKey === owner_runtime_js_1.OWNER_RUNTIME_SESSION_KEY
|
|
1042
|
+
? {
|
|
1043
|
+
prepareSubagentEnvelope: async () => this.buildReactiveEnvelope(message, agentContext, memberEffectiveScope, SUBAGENT_ENVELOPE_WALL_SECONDS),
|
|
1044
|
+
}
|
|
1045
|
+
: {}),
|
|
1059
1046
|
sourceTurnId,
|
|
1060
1047
|
sourceMessageRef,
|
|
1061
1048
|
...(runtimeSessionKey === owner_runtime_js_1.OWNER_RUNTIME_SESSION_KEY
|
|
@@ -1178,7 +1165,7 @@ This protects your credentials from being exposed in chat logs.`;
|
|
|
1178
1165
|
}
|
|
1179
1166
|
// Add text content (with memory context, skill context, and page context)
|
|
1180
1167
|
const pageCtx = isPublicLane ? '' : this.getPageContextPrefix(message);
|
|
1181
|
-
const effectiveMessageText = `${pageCtx}${memoryPrefix}${
|
|
1168
|
+
const effectiveMessageText = `${pageCtx}${memoryPrefix}${skillPrefix}${messageText || ''}${formattingSuffix}`;
|
|
1182
1169
|
if (effectiveMessageText) {
|
|
1183
1170
|
contentBlocks.push({ type: 'text', text: effectiveMessageText });
|
|
1184
1171
|
}
|
|
@@ -1222,7 +1209,7 @@ This protects your credentials from being exposed in chat logs.`;
|
|
|
1222
1209
|
}
|
|
1223
1210
|
else {
|
|
1224
1211
|
const pageCtx = isPublicLane ? '' : this.getPageContextPrefix(message);
|
|
1225
|
-
const effectiveText = `${pageCtx}${memoryPrefix}${
|
|
1212
|
+
const effectiveText = `${pageCtx}${memoryPrefix}${skillPrefix}${message.text}${formattingSuffix}`;
|
|
1226
1213
|
const turnStart = Date.now();
|
|
1227
1214
|
const result = await this.agentLoop.run(effectiveText, options);
|
|
1228
1215
|
response = result.response;
|
|
@@ -1312,17 +1299,6 @@ This protects your credentials from being exposed in chat logs.`;
|
|
|
1312
1299
|
if (!persisted) {
|
|
1313
1300
|
throw new Error('Unable to persist final assistant response');
|
|
1314
1301
|
}
|
|
1315
|
-
if ((message.principal?.lane ?? 'owner') !== 'public' &&
|
|
1316
|
-
response &&
|
|
1317
|
-
message.text &&
|
|
1318
|
-
agentContext.roleName === 'owner_console') {
|
|
1319
|
-
// Owner corrections and rules become lesson:/policy: rows (turn-observer.ts).
|
|
1320
|
-
// Only AFTER the reply persisted (a failed persist throws above): a turn that did
|
|
1321
|
-
// not commit must not leave standing instructions for later prompts.
|
|
1322
|
-
void this.observeOwnerLearning(message).catch((error) => {
|
|
1323
|
-
logger.warn(`[learning] observer failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
1324
|
-
});
|
|
1325
|
-
}
|
|
1326
1302
|
// Release session lock AFTER final persistence to prevent out-of-order turns
|
|
1327
1303
|
releaseCliSessionLock();
|
|
1328
1304
|
// 6. Return result. Run identity rides out with it: the router already generated
|
|
@@ -1449,9 +1425,8 @@ ${historyContext}
|
|
|
1449
1425
|
if (injectedContext) {
|
|
1450
1426
|
prompt += injectedContext;
|
|
1451
1427
|
}
|
|
1452
|
-
prompt += `\n## Instructions\n- Be concise. Save important decisions.${hasHistory ? '' : ' Greet naturally.'}`;
|
|
1453
1428
|
if (agentContext?.platform === 'viewer') {
|
|
1454
|
-
prompt += `\n- Image display: cp to ~/.mama/workspace/media/outbound/ then write bare path in response.`;
|
|
1429
|
+
prompt += `\n## Instructions\n- Image display: cp to ~/.mama/workspace/media/outbound/ then write bare path in response.`;
|
|
1455
1430
|
}
|
|
1456
1431
|
if (agentContext) {
|
|
1457
1432
|
// Store canonicity and external-evidence trust are stable owner policy.
|
|
@@ -1463,7 +1438,7 @@ ${historyContext}
|
|
|
1463
1438
|
// manual layered ABOVE the code-owned discipline floor. Loaded per build so
|
|
1464
1439
|
// a self-update reaches the very next NEW session.
|
|
1465
1440
|
if (agentContext.roleName === 'owner_console') {
|
|
1466
|
-
const consoleBrief =
|
|
1441
|
+
const consoleBrief = this.readOwnerConsoleBrief();
|
|
1467
1442
|
if (consoleBrief.trim()) {
|
|
1468
1443
|
const projectedBrief = (0, console_brief_js_1.projectConsoleBriefForPrompt)(consoleBrief, this.privateConnectorPolicy);
|
|
1469
1444
|
prompt += `\n\n${((gatewayCatalog && !durableNativeBackend) || privatePolicyPrompt
|
|
@@ -1508,7 +1483,7 @@ ${historyContext}
|
|
|
1508
1483
|
// Brief edits must rotate the durable-session policy (re-anchor carries
|
|
1509
1484
|
// the new manual); non-owner roles contribute an empty string.
|
|
1510
1485
|
(agentContext.roleName === 'owner_console'
|
|
1511
|
-
? `\n${(0, console_brief_js_1.projectConsoleBriefForPrompt)(
|
|
1486
|
+
? `\n${(0, console_brief_js_1.projectConsoleBriefForPrompt)(this.readOwnerConsoleBrief(), this.privateConnectorPolicy)}`
|
|
1512
1487
|
: '') +
|
|
1513
1488
|
`\n${gatewayCatalog.cacheKey}`,
|
|
1514
1489
|
});
|
|
@@ -1666,69 +1641,6 @@ ${historyContext}
|
|
|
1666
1641
|
getRuntimeProjectId() {
|
|
1667
1642
|
return process.env.MAMA_WORKSPACE || process.cwd();
|
|
1668
1643
|
}
|
|
1669
|
-
async observeOwnerLearning(message) {
|
|
1670
|
-
if (!this.mamaApi.saveMemory || !this.mamaApi.queryRelevantTruth) {
|
|
1671
|
-
return;
|
|
1672
|
-
}
|
|
1673
|
-
const scopes = (0, scope_context_js_1.deriveMemoryScopes)({
|
|
1674
|
-
source: message.source,
|
|
1675
|
-
channelId: message.channelId,
|
|
1676
|
-
projectId: this.getRuntimeProjectId(),
|
|
1677
|
-
});
|
|
1678
|
-
const result = await (0, turn_observer_js_1.observeOwnerTurn)({
|
|
1679
|
-
userMessage: message.text,
|
|
1680
|
-
scopes,
|
|
1681
|
-
source: {
|
|
1682
|
-
package: 'standalone',
|
|
1683
|
-
source_type: message.source,
|
|
1684
|
-
channel_id: message.channelId,
|
|
1685
|
-
project_id: this.getRuntimeProjectId(),
|
|
1686
|
-
},
|
|
1687
|
-
markers: (0, learning_markers_js_1.loadLearningMarkers)(),
|
|
1688
|
-
turnCommitted: true,
|
|
1689
|
-
save: async (input) => {
|
|
1690
|
-
const saved = await this.mamaApi.saveMemory(input);
|
|
1691
|
-
return { memoryId: saved.id };
|
|
1692
|
-
},
|
|
1693
|
-
// Exact-topic lookup over the active rows in scope. Not capped: a cap keeps the newest
|
|
1694
|
-
// rows and could drop an older exact match, turning a dedupe into a duplicate.
|
|
1695
|
-
findExisting: async (topic) => {
|
|
1696
|
-
const rows = await this.mamaApi.queryRelevantTruth({ query: '', scopes });
|
|
1697
|
-
const hit = rows.find((row) => row.topic === topic);
|
|
1698
|
-
return hit ? { memory_id: hit.memory_id } : null;
|
|
1699
|
-
},
|
|
1700
|
-
// A repeat carries the same normalized text (that is what the topic hash pins), so the
|
|
1701
|
-
// existing row already says it; dedupe needs no rewrite.
|
|
1702
|
-
});
|
|
1703
|
-
if (result.kind !== 'none') {
|
|
1704
|
-
logger.info(`[learning] observed kind=${result.kind} topic=${result.topic} deduped=${result.deduped === true} (${result.reason})`);
|
|
1705
|
-
}
|
|
1706
|
-
}
|
|
1707
|
-
/** <policy>/<lessons> for an owner chat turn, or '' (learning-context.ts). */
|
|
1708
|
-
async buildLearningPrefix(message) {
|
|
1709
|
-
if (!this.mamaApi.queryRelevantTruth) {
|
|
1710
|
-
return '';
|
|
1711
|
-
}
|
|
1712
|
-
try {
|
|
1713
|
-
const scopes = (0, scope_context_js_1.deriveMemoryScopes)({
|
|
1714
|
-
source: message.source,
|
|
1715
|
-
channelId: message.channelId,
|
|
1716
|
-
projectId: this.getRuntimeProjectId(),
|
|
1717
|
-
});
|
|
1718
|
-
const context = await (0, learning_context_js_1.buildLearningContext)({
|
|
1719
|
-
scopes,
|
|
1720
|
-
query: message.text.slice(0, 500),
|
|
1721
|
-
readClaims: (0, learning_read_js_1.cappedLearningReader)((params) => this.mamaApi.queryRelevantTruth(params), (line) => logger.info(line)),
|
|
1722
|
-
});
|
|
1723
|
-
const channelScopeId = scopes.find((scope) => scope.kind === 'channel')?.id ?? null;
|
|
1724
|
-
logger.info((0, learning_context_js_1.formatLearningAuditLine)('chat', channelScopeId, context));
|
|
1725
|
-
return context.promptBlock ? `${context.promptBlock}\n\n` : '';
|
|
1726
|
-
}
|
|
1727
|
-
catch (error) {
|
|
1728
|
-
logger.warn(`[learning] chat prefix failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
1729
|
-
return '';
|
|
1730
|
-
}
|
|
1731
|
-
}
|
|
1732
1644
|
async getPerTurnMemoryPrefix(message) {
|
|
1733
1645
|
if (this.config.implicitMemoryRecall && this.mamaApi.recallMemory) {
|
|
1734
1646
|
try {
|