@jungjaehoon/mama-os 0.22.1 → 0.24.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.
- package/CHANGELOG.md +22 -0
- package/README.md +3 -1
- package/dist/agent/agent-loop.d.ts +3 -9
- package/dist/agent/agent-loop.d.ts.map +1 -1
- package/dist/agent/agent-loop.js +419 -216
- package/dist/agent/agent-loop.js.map +1 -1
- package/dist/agent/code-act/constants.d.ts +2 -2
- package/dist/agent/code-act/constants.d.ts.map +1 -1
- package/dist/agent/code-act/constants.js +16 -9
- package/dist/agent/code-act/constants.js.map +1 -1
- package/dist/agent/code-act/host-bridge.d.ts +12 -11
- package/dist/agent/code-act/host-bridge.d.ts.map +1 -1
- package/dist/agent/code-act/host-bridge.js +92 -15
- package/dist/agent/code-act/host-bridge.js.map +1 -1
- package/dist/agent/code-act/index.d.ts +2 -0
- package/dist/agent/code-act/index.d.ts.map +1 -1
- package/dist/agent/code-act/index.js +5 -1
- package/dist/agent/code-act/index.js.map +1 -1
- package/dist/agent/code-act/tool-policy.d.ts +42 -0
- package/dist/agent/code-act/tool-policy.d.ts.map +1 -0
- package/dist/agent/code-act/tool-policy.js +122 -0
- package/dist/agent/code-act/tool-policy.js.map +1 -0
- package/dist/agent/code-act/type-definition-generator.d.ts +4 -3
- package/dist/agent/code-act/type-definition-generator.d.ts.map +1 -1
- package/dist/agent/code-act/type-definition-generator.js +26 -48
- package/dist/agent/code-act/type-definition-generator.js.map +1 -1
- package/dist/agent/codex-app-server-process.d.ts +116 -0
- package/dist/agent/codex-app-server-process.d.ts.map +1 -0
- package/dist/agent/codex-app-server-process.js +1382 -0
- package/dist/agent/codex-app-server-process.js.map +1 -0
- package/dist/agent/codex-home.d.ts +9 -0
- package/dist/agent/codex-home.d.ts.map +1 -1
- package/dist/agent/codex-home.js +626 -4
- package/dist/agent/codex-home.js.map +1 -1
- package/dist/agent/codex-thread-registry.d.ts +63 -0
- package/dist/agent/codex-thread-registry.d.ts.map +1 -0
- package/dist/agent/codex-thread-registry.js +433 -0
- package/dist/agent/codex-thread-registry.js.map +1 -0
- package/dist/agent/gateway-tool-executor.d.ts +20 -7
- package/dist/agent/gateway-tool-executor.d.ts.map +1 -1
- package/dist/agent/gateway-tool-executor.js +254 -90
- package/dist/agent/gateway-tool-executor.js.map +1 -1
- package/dist/agent/gateway-tools.md +10 -5
- package/dist/agent/managed-agent-runtime-sync.d.ts.map +1 -1
- package/dist/agent/managed-agent-runtime-sync.js +0 -3
- package/dist/agent/managed-agent-runtime-sync.js.map +1 -1
- package/dist/agent/managed-agent-validation.js +1 -1
- package/dist/agent/managed-agent-validation.js.map +1 -1
- package/dist/agent/model-runner.d.ts +51 -3
- package/dist/agent/model-runner.d.ts.map +1 -1
- package/dist/agent/model-runner.js +1 -1
- package/dist/agent/model-runner.js.map +1 -1
- package/dist/agent/persistent-cli-adapter.d.ts +1 -0
- package/dist/agent/persistent-cli-adapter.d.ts.map +1 -1
- package/dist/agent/persistent-cli-adapter.js +3 -0
- package/dist/agent/persistent-cli-adapter.js.map +1 -1
- package/dist/agent/role-manager.d.ts +22 -1
- package/dist/agent/role-manager.d.ts.map +1 -1
- package/dist/agent/role-manager.js +39 -2
- package/dist/agent/role-manager.js.map +1 -1
- package/dist/agent/session-pool.d.ts +2 -2
- package/dist/agent/session-pool.d.ts.map +1 -1
- package/dist/agent/session-pool.js +6 -6
- package/dist/agent/session-pool.js.map +1 -1
- package/dist/agent/tool-registry.d.ts +14 -0
- package/dist/agent/tool-registry.d.ts.map +1 -1
- package/dist/agent/tool-registry.js +81 -12
- package/dist/agent/tool-registry.js.map +1 -1
- package/dist/agent/types.d.ts +49 -7
- 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 +62 -40
- package/dist/api/graph-api.js.map +1 -1
- package/dist/api/operator-tasks-handler.d.ts.map +1 -1
- package/dist/api/operator-tasks-handler.js +6 -2
- package/dist/api/operator-tasks-handler.js.map +1 -1
- package/dist/cli/commands/init.d.ts +1 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +22 -14
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/run.d.ts.map +1 -1
- package/dist/cli/commands/run.js +7 -4
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/commands/start.d.ts +2 -0
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +259 -23
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/commands/status.js +2 -2
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/config/config-manager.d.ts +0 -5
- package/dist/cli/config/config-manager.d.ts.map +1 -1
- package/dist/cli/config/config-manager.js +78 -6
- package/dist/cli/config/config-manager.js.map +1 -1
- package/dist/cli/config/types.d.ts +4 -4
- package/dist/cli/config/types.d.ts.map +1 -1
- package/dist/cli/config/types.js +36 -0
- package/dist/cli/config/types.js.map +1 -1
- package/dist/cli/index.js +2 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/runtime/agent-loop-init.d.ts +1 -1
- package/dist/cli/runtime/agent-loop-init.d.ts.map +1 -1
- package/dist/cli/runtime/agent-loop-init.js +106 -60
- package/dist/cli/runtime/agent-loop-init.js.map +1 -1
- package/dist/cli/runtime/api-routes-init.d.ts +3 -0
- package/dist/cli/runtime/api-routes-init.d.ts.map +1 -1
- package/dist/cli/runtime/api-routes-init.js +226 -51
- package/dist/cli/runtime/api-routes-init.js.map +1 -1
- package/dist/cli/runtime/connector-init.d.ts.map +1 -1
- package/dist/cli/runtime/connector-init.js +13 -17
- package/dist/cli/runtime/connector-init.js.map +1 -1
- package/dist/cli/runtime/envelope-bootstrap.d.ts.map +1 -1
- package/dist/cli/runtime/envelope-bootstrap.js +13 -1
- package/dist/cli/runtime/envelope-bootstrap.js.map +1 -1
- package/dist/cli/runtime/gateway-init.d.ts +1 -1
- package/dist/cli/runtime/gateway-init.d.ts.map +1 -1
- package/dist/cli/runtime/gateway-init.js +5 -0
- package/dist/cli/runtime/gateway-init.js.map +1 -1
- package/dist/cli/runtime/mama-core-init.d.ts +2 -2
- package/dist/cli/runtime/mama-core-init.d.ts.map +1 -1
- package/dist/cli/runtime/mama-core-init.js +17 -0
- package/dist/cli/runtime/mama-core-init.js.map +1 -1
- package/dist/cli/runtime/memory-agent-init.d.ts +1 -1
- package/dist/cli/runtime/memory-agent-init.d.ts.map +1 -1
- package/dist/cli/runtime/memory-agent-init.js +16 -6
- package/dist/cli/runtime/memory-agent-init.js.map +1 -1
- package/dist/cli/runtime/types.d.ts +4 -26
- package/dist/cli/runtime/types.d.ts.map +1 -1
- package/dist/cli/runtime/utilities.js +2 -2
- package/dist/cli/runtime/utilities.js.map +1 -1
- package/dist/connectors/config-loader.d.ts +24 -0
- package/dist/connectors/config-loader.d.ts.map +1 -0
- package/dist/connectors/config-loader.js +205 -0
- package/dist/connectors/config-loader.js.map +1 -0
- package/dist/connectors/framework/types.d.ts +2 -0
- package/dist/connectors/framework/types.d.ts.map +1 -1
- package/dist/connectors/kagemusha/query-tools.js +2 -2
- package/dist/connectors/kagemusha/query-tools.js.map +1 -1
- package/dist/envelope/reactive-config.d.ts +2 -2
- package/dist/envelope/reactive-config.d.ts.map +1 -1
- package/dist/envelope/reactive-config.js +36 -4
- package/dist/envelope/reactive-config.js.map +1 -1
- package/dist/gateways/context-injector.d.ts +2 -1
- package/dist/gateways/context-injector.d.ts.map +1 -1
- package/dist/gateways/context-injector.js.map +1 -1
- package/dist/gateways/message-router.d.ts +19 -1
- package/dist/gateways/message-router.d.ts.map +1 -1
- package/dist/gateways/message-router.js +179 -24
- package/dist/gateways/message-router.js.map +1 -1
- package/dist/gateways/telegram.d.ts.map +1 -1
- package/dist/gateways/telegram.js +13 -0
- package/dist/gateways/telegram.js.map +1 -1
- package/dist/gateways/types.d.ts +4 -1
- package/dist/gateways/types.d.ts.map +1 -1
- package/dist/memory/history-extractor.d.ts +0 -24
- package/dist/memory/history-extractor.d.ts.map +1 -1
- package/dist/memory/history-extractor.js +0 -132
- package/dist/memory/history-extractor.js.map +1 -1
- package/dist/memory/save-candidate-extractor.d.ts +3 -0
- package/dist/memory/save-candidate-extractor.d.ts.map +1 -1
- package/dist/memory/save-candidate-extractor.js +12 -1
- package/dist/memory/save-candidate-extractor.js.map +1 -1
- package/dist/memory/secret-filter.d.ts +22 -0
- package/dist/memory/secret-filter.d.ts.map +1 -0
- package/dist/memory/secret-filter.js +77 -0
- package/dist/memory/secret-filter.js.map +1 -0
- package/dist/multi-agent/agent-process-manager.d.ts +9 -1
- package/dist/multi-agent/agent-process-manager.d.ts.map +1 -1
- package/dist/multi-agent/agent-process-manager.js +197 -49
- package/dist/multi-agent/agent-process-manager.js.map +1 -1
- package/dist/multi-agent/multi-agent-base.d.ts.map +1 -1
- package/dist/multi-agent/multi-agent-base.js +2 -1
- package/dist/multi-agent/multi-agent-base.js.map +1 -1
- package/dist/multi-agent/runtime-process.d.ts +18 -15
- package/dist/multi-agent/runtime-process.d.ts.map +1 -1
- package/dist/multi-agent/runtime-process.js +63 -59
- package/dist/multi-agent/runtime-process.js.map +1 -1
- package/dist/multi-agent/types.d.ts +13 -7
- package/dist/multi-agent/types.d.ts.map +1 -1
- package/dist/multi-agent/types.js.map +1 -1
- package/dist/multi-agent/workflow-engine.js +3 -3
- package/dist/multi-agent/workflow-engine.js.map +1 -1
- package/dist/multi-agent/workflow-types.d.ts +2 -2
- package/dist/multi-agent/workflow-types.d.ts.map +1 -1
- package/dist/observability/code-audit.d.ts +4 -0
- package/dist/observability/code-audit.d.ts.map +1 -1
- package/dist/observability/code-audit.js +69 -0
- package/dist/observability/code-audit.js.map +1 -1
- package/dist/operator/briefs.d.ts +26 -0
- package/dist/operator/briefs.d.ts.map +1 -0
- package/dist/operator/briefs.js +128 -0
- package/dist/operator/briefs.js.map +1 -0
- package/dist/operator/operator-trigger-loop.d.ts +27 -0
- package/dist/operator/operator-trigger-loop.d.ts.map +1 -1
- package/dist/operator/operator-trigger-loop.js +72 -12
- package/dist/operator/operator-trigger-loop.js.map +1 -1
- package/dist/operator/report-carry.d.ts +29 -0
- package/dist/operator/report-carry.d.ts.map +1 -0
- package/dist/operator/report-carry.js +81 -0
- package/dist/operator/report-carry.js.map +1 -0
- package/dist/operator/report-run.d.ts +4 -4
- package/dist/operator/shadow-capture.d.ts +20 -0
- package/dist/operator/shadow-capture.d.ts.map +1 -0
- package/dist/operator/shadow-capture.js +34 -0
- package/dist/operator/shadow-capture.js.map +1 -0
- package/dist/operator/situation-report.d.ts +9 -0
- package/dist/operator/situation-report.d.ts.map +1 -1
- package/dist/operator/situation-report.js +56 -26
- package/dist/operator/situation-report.js.map +1 -1
- package/dist/operator/task-ledger.d.ts +90 -2
- package/dist/operator/task-ledger.d.ts.map +1 -1
- package/dist/operator/task-ledger.js +359 -23
- package/dist/operator/task-ledger.js.map +1 -1
- package/dist/operator/trigger-author.d.ts +35 -1
- package/dist/operator/trigger-author.d.ts.map +1 -1
- package/dist/operator/trigger-author.js +73 -10
- package/dist/operator/trigger-author.js.map +1 -1
- package/dist/operator/worker-run.d.ts +89 -0
- package/dist/operator/worker-run.d.ts.map +1 -0
- package/dist/operator/worker-run.js +127 -0
- package/dist/operator/worker-run.js.map +1 -0
- package/dist/operator/workorder-consumer.d.ts +121 -0
- package/dist/operator/workorder-consumer.d.ts.map +1 -0
- package/dist/operator/workorder-consumer.js +253 -0
- package/dist/operator/workorder-consumer.js.map +1 -0
- package/dist/operator/workorder-hooks.d.ts +30 -0
- package/dist/operator/workorder-hooks.d.ts.map +1 -0
- package/dist/operator/workorder-hooks.js +70 -0
- package/dist/operator/workorder-hooks.js.map +1 -0
- package/dist/operator/workorder-publishers.d.ts +68 -0
- package/dist/operator/workorder-publishers.d.ts.map +1 -0
- package/dist/operator/workorder-publishers.js +150 -0
- package/dist/operator/workorder-publishers.js.map +1 -0
- package/dist/security/security-monitor.d.ts +7 -0
- package/dist/security/security-monitor.d.ts.map +1 -1
- package/dist/security/security-monitor.js +17 -0
- package/dist/security/security-monitor.js.map +1 -1
- package/dist/setup/setup-prompt.d.ts +1 -1
- package/dist/setup/setup-prompt.d.ts.map +1 -1
- package/dist/setup/setup-prompt.js +4 -5
- package/dist/setup/setup-prompt.js.map +1 -1
- package/dist/utils/untrusted-content.d.ts +13 -0
- package/dist/utils/untrusted-content.d.ts.map +1 -1
- package/dist/utils/untrusted-content.js +43 -0
- package/dist/utils/untrusted-content.js.map +1 -1
- package/package.json +2 -2
- package/public/viewer/js/modules/agents.js +13 -9
- package/public/viewer/js/modules/settings.js +15 -10
- package/public/viewer/src/modules/agents.ts +12 -10
- package/public/viewer/src/modules/settings.ts +17 -12
- package/public/viewer/src/utils/api.ts +2 -2
- package/templates/AGENTS.codex.md +2 -23
- package/templates/personas/conductor.md +1 -1
- package/dist/agent/codex-mcp-process.d.ts +0 -105
- package/dist/agent/codex-mcp-process.d.ts.map +0 -1
- package/dist/agent/codex-mcp-process.js +0 -748
- package/dist/agent/codex-mcp-process.js.map +0 -1
|
@@ -67,6 +67,27 @@ function getStaticRoute(message) {
|
|
|
67
67
|
}
|
|
68
68
|
return route;
|
|
69
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Owner-console trust at the ENVELOPE layer (plan v6 S1-T2b): same condition
|
|
72
|
+
* as RoleManager's escalation (telegram + allowed_chats locked + 1:1 DM from
|
|
73
|
+
* an allowlisted chat), derived independently from config so the envelope
|
|
74
|
+
* never depends on RoleManager singleton state. Both layers fail closed;
|
|
75
|
+
* kagemusha_* tools pass only when BOTH agree.
|
|
76
|
+
*/
|
|
77
|
+
function isOwnerConsoleMessage(message, config) {
|
|
78
|
+
if (message.source !== 'telegram') {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
if (!config.roles?.definitions?.owner_console) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
const allowed = config.telegram?.allowed_chats;
|
|
85
|
+
if (!Array.isArray(allowed) || allowed.length === 0) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
const chatType = typeof message.metadata?.chatType === 'string' ? message.metadata.chatType : undefined;
|
|
89
|
+
return (chatType === 'private' && allowed.map((id) => String(id).trim()).includes(message.channelId));
|
|
90
|
+
}
|
|
70
91
|
function homeFromEnv(env) {
|
|
71
92
|
const home = env.HOME;
|
|
72
93
|
return home && home.trim() ? home : (0, node_os_1.homedir)();
|
|
@@ -100,7 +121,7 @@ function reactiveBudgetSeconds(config) {
|
|
|
100
121
|
const seconds = Number(config.timeouts?.agent_ms) / 1000;
|
|
101
122
|
return Number.isFinite(seconds) && seconds > 0 ? seconds : 300;
|
|
102
123
|
}
|
|
103
|
-
function getReactiveRoutePolicy(message, config, env = process.env) {
|
|
124
|
+
function getReactiveRoutePolicy(message, config, env = process.env, enabledConnectorNames = []) {
|
|
104
125
|
const route = getStaticRoute(message);
|
|
105
126
|
if (isReactiveEnvelopeConfig(config)) {
|
|
106
127
|
return {
|
|
@@ -120,17 +141,28 @@ function getReactiveRoutePolicy(message, config, env = process.env) {
|
|
|
120
141
|
userId: message.userId,
|
|
121
142
|
projectId,
|
|
122
143
|
});
|
|
144
|
+
// Owner console reads business state through the kagemusha bridge; the
|
|
145
|
+
// reactive telegram envelope must widen its raw-connector scope for the
|
|
146
|
+
// verified-owner DM or the enforcer denies kagemusha_messages even after
|
|
147
|
+
// the role layer allows it (connector_out_of_scope).
|
|
148
|
+
const isOwnerConsole = isOwnerConsoleMessage(message, config);
|
|
149
|
+
const rawConnectors = Array.from(new Set([
|
|
150
|
+
...route.rawConnectors,
|
|
151
|
+
...(isOwnerConsole ? ['kagemusha'] : []),
|
|
152
|
+
...(isOwnerConsole && enabledConnectorNames.includes('trello') ? ['trello'] : []),
|
|
153
|
+
]));
|
|
123
154
|
return {
|
|
124
155
|
source,
|
|
125
156
|
projectRefs: [{ kind: 'project', id: projectId }],
|
|
126
|
-
rawConnectors
|
|
157
|
+
rawConnectors,
|
|
127
158
|
memoryScopes,
|
|
128
159
|
allowedDestinations: route.allowedDestinations(message),
|
|
129
160
|
reactiveBudgetSeconds: reactiveBudgetSeconds(config),
|
|
130
161
|
};
|
|
131
162
|
}
|
|
132
|
-
function createDefaultReactiveEnvelopeConfig(config, env = process.env) {
|
|
163
|
+
function createDefaultReactiveEnvelopeConfig(config, env = process.env, enabledConnectorNames = []) {
|
|
133
164
|
const budgetSeconds = reactiveBudgetSeconds(config);
|
|
165
|
+
const connectorSnapshot = Object.freeze([...enabledConnectorNames]);
|
|
134
166
|
resolveReactiveProjectRoot(config, env);
|
|
135
167
|
const policyCache = new WeakMap();
|
|
136
168
|
const policyFor = (message) => {
|
|
@@ -138,7 +170,7 @@ function createDefaultReactiveEnvelopeConfig(config, env = process.env) {
|
|
|
138
170
|
if (cached) {
|
|
139
171
|
return cached;
|
|
140
172
|
}
|
|
141
|
-
const policy = getReactiveRoutePolicy(message, config, env);
|
|
173
|
+
const policy = getReactiveRoutePolicy(message, config, env, connectorSnapshot);
|
|
142
174
|
policyCache.set(message, policy);
|
|
143
175
|
return policy;
|
|
144
176
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactive-config.js","sourceRoot":"","sources":["../../src/envelope/reactive-config.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"reactive-config.js","sourceRoot":"","sources":["../../src/envelope/reactive-config.ts"],"names":[],"mappings":";;AAoJA,gEAWC;AAOD,wDAkDC;AAED,kFA2BC;AArPD,qCAAkC;AAClC,yCAAsD;AAGtD,iEAAgE;AA6BhE,MAAM,oBAAoB,GAAG;IAC3B,QAAQ,EAAE;QACR,MAAM,EAAE,UAAU;QAClB,aAAa,EAAE,CAAC,UAAU,CAAC;QAC3B,mBAAmB,EAAE,CAAC,OAA0B,EAAE,EAAE,CAAC;YACnD,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,OAAO,CAAC,SAAS,EAAE;SAC5C;KACF;IACD,K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CAAC,CAAC;IACxC,MAAM,WAAW,GAAG,IAAI,OAAO,EAA0C,CAAC;IAC1E,MAAM,SAAS,GAAG,CAAC,OAA0B,EAAuB,EAAE;QACpE,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACxC,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,MAAM,MAAM,GAAG,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,iBAAiB,CAAC,CAAC;QAC/E,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACjC,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IAEF,OAAO;QACL,cAAc,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC;QAChE,gBAAgB,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC;QACpE,eAAe,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC;QAClE,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,MAAM;QACjD,sBAAsB,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,mBAAmB,CAAC;QAChF,qBAAqB,EAAE,aAAa;KACrC,CAAC;AACJ,CAAC"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* and formats it for injection into system prompts.
|
|
6
6
|
*/
|
|
7
7
|
import type { RelatedDecision, MessageRouterConfig } from './types.js';
|
|
8
|
+
import type { SaveDecisionPayload } from '../agent/types.js';
|
|
8
9
|
/**
|
|
9
10
|
* Checkpoint data from MAMA
|
|
10
11
|
*/
|
|
@@ -51,7 +52,7 @@ export interface MamaApiClient {
|
|
|
51
52
|
/**
|
|
52
53
|
* Save a new decision or fact
|
|
53
54
|
*/
|
|
54
|
-
save?(input:
|
|
55
|
+
save?(input: SaveDecisionPayload): Promise<unknown>;
|
|
55
56
|
/**
|
|
56
57
|
* Recall memory v2 bundle
|
|
57
58
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-injector.d.ts","sourceRoot":"","sources":["../../src/gateways/context-injector.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"context-injector.d.ts","sourceRoot":"","sources":["../../src/gateways/context-injector.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAA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MAAM,CAAC;QACxB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,6CAA6C;IAC7C,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;;;GAKG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,mBAAmB,CAAS;IACpC,OAAO,CAAC,YAAY,CAAS;gBAG3B,OAAO,EAAE,aAAa,EACtB,MAAM,GAAE,IAAI,CAAC,mBAAmB,EAAE,qBAAqB,GAAG,cAAc,CAAM;IAOhF;;OAEG;IACG,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAwDjE;;OAEG;IACH,OAAO,CAAC,YAAY;IAUpB;;OAEG;IACH,OAAO,CAAC,YAAY;IAUpB;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,mBAAmB,EAAE,qBAAqB,GAAG,cAAc,CAAC,GAAG,IAAI;IAS1F;;;OAGG;IACG,wBAAwB,CAAC,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAoE9F;;OAEG;IACH,OAAO,CAAC,aAAa;IAYrB;;OAEG;IACH,OAAO,CAAC,QAAQ;CAKjB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,GAAE,YAAY,EAAO,GAAG,aAAa,CAyE/E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-injector.js","sourceRoot":"","sources":["../../src/gateways/context-injector.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;
|
|
1
|
+
{"version":3,"file":"context-injector.js","sourceRoot":"","sources":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E,QAAQ,CAAC,QAAQ,IAAI,EAAE;oBAChC,WAAW,EAAE,QAAQ,CAAC,UAAU;iBACjC,CAAC,CAAC;gBACH,mBAAmB,EAAE,EAAE;gBACvB,oBAAoB,EAAE,EAAE;gBACxB,gBAAgB,EAAE;oBAChB,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,wBAAwB,EAAE,CAAC;oBAC/D,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,wBAAwB,EAAE,CAAC;iBAClE;gBACD,gBAAgB,EAAE,KAAK,CAAC,cAAc;aACvC,CAAC;QACJ,CAAC;QACD,KAAK,CAAC,iBAAiB,CAAC,UAAkB;YACxC,OAAO;gBACL,WAAW,EAAE,UAAU;gBACvB,gBAAgB,EAAE,wDAAwD;gBAC1E,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;aACvB,CAAC;QACJ,CAAC;QACD,KAAK,CAAC,oBAAoB;YACxB,OAAO;QACT,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -19,6 +19,9 @@ import { EnvelopeAuthority } from '../envelope/index.js';
|
|
|
19
19
|
import { type ReactiveEnvelopeConfig } from '../envelope/reactive-config.js';
|
|
20
20
|
export type { AgentLoopOptions } from '../agent/types.js';
|
|
21
21
|
export type { ReactiveEnvelopeConfig } from '../envelope/reactive-config.js';
|
|
22
|
+
/** Channel-less host alarms (workorder failures) park here; every resumed
|
|
23
|
+
* owner turn reads this key in addition to its own channel key. */
|
|
24
|
+
export declare const OPERATOR_BROADCAST_NOTICE_KEY = "operator:broadcast";
|
|
22
25
|
/**
|
|
23
26
|
* Agent Loop interface for message processing
|
|
24
27
|
*/
|
|
@@ -69,6 +72,12 @@ export interface ProcessingResult {
|
|
|
69
72
|
/** Processing duration in milliseconds */
|
|
70
73
|
duration: number;
|
|
71
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* True when the agent persisted memory during THIS turn (gateway mama_save in
|
|
77
|
+
* the reasoning header) - the extractor safety net then skips to avoid the
|
|
78
|
+
* dual-save duplicate proven live on 2026-07-17.
|
|
79
|
+
*/
|
|
80
|
+
export declare function agentSavedInTurn(response: string | null | undefined): boolean;
|
|
72
81
|
/**
|
|
73
82
|
* Message Router class
|
|
74
83
|
*
|
|
@@ -84,7 +93,6 @@ export declare class MessageRouter {
|
|
|
84
93
|
private envelopeAuthority?;
|
|
85
94
|
private roleManager;
|
|
86
95
|
private promptEnhancer;
|
|
87
|
-
private cachedGatewayToolsPrompt;
|
|
88
96
|
private gatewayRegistry;
|
|
89
97
|
private memoryAgentProcessManager?;
|
|
90
98
|
private memoryAuditQueue?;
|
|
@@ -116,6 +124,15 @@ export declare class MessageRouter {
|
|
|
116
124
|
status: "applied" | "skipped" | "failed";
|
|
117
125
|
}>;
|
|
118
126
|
};
|
|
127
|
+
/**
|
|
128
|
+
* Host-code enqueue into the owner notice surface (Stage-2 workorder
|
|
129
|
+
* failures). The queue stays router-owned; this is the accessor plan C5
|
|
130
|
+
* requires - the consumer lives in start.ts host code and cannot reach the
|
|
131
|
+
* private field. Keyed under the operator BROADCAST key: host alarms have
|
|
132
|
+
* no conversation channel, and per-channel keys would dead-letter (review
|
|
133
|
+
* M1). Delivered on the owner's next resumed chat turn on ANY channel.
|
|
134
|
+
*/
|
|
135
|
+
enqueueOperatorNotice(summary: string): void;
|
|
119
136
|
/**
|
|
120
137
|
* Public API for auditing a conversation via the memory agent.
|
|
121
138
|
* Used by the /api/mama/audit-conversation endpoint for benchmarking.
|
|
@@ -162,6 +179,7 @@ export declare class MessageRouter {
|
|
|
162
179
|
* because CLI doesn't persist sessions between calls.
|
|
163
180
|
*/
|
|
164
181
|
private buildSystemPrompt;
|
|
182
|
+
private buildSessionPolicyFingerprint;
|
|
165
183
|
/**
|
|
166
184
|
* Build minimal prompt for resumed CLI sessions.
|
|
167
185
|
* CLI already has full system prompt from initial request.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-router.d.ts","sourceRoot":"","sources":["../../src/gateways/message-router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,KAAK,EACV,iBAAiB,EACjB,mBAAmB,EACnB,OAAO,EACP,eAAe,EACf,YAAY,EACb,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"message-router.d.ts","sourceRoot":"","sources":["../../src/gateways/message-router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,KAAK,EACV,iBAAiB,EACjB,mBAAmB,EACnB,OAAO,EACP,eAAe,EACf,YAAY,EACb,MAAM,YAAY,CAAC;AAUpB,OAAO,KAAK,EAAgB,gBAAgB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzF,OAAO,EAEL,KAAK,kBAAkB,EAExB,MAAM,+BAA+B,CAAC;AASvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,gCAAgC,CAAC;AAGxC,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,YAAY,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAY7E;oEACoE;AACpE,eAAO,MAAM,6BAA6B,uBAAuB,CAAC;AAElE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,GAAG,CACD,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,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,CAAC,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI;IAKlF;;OAEG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAIxC;;OAEG;IACH,aAAa,CAAC,SAAS,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;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAU;IACrD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAO;IACjD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAU;IAEpD,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,sBAAsB;IA0B9B,OAAO,CAAC,2BAA2B;IAqDnC,OAAO,CAAC,oBAAoB;YAwEd,sBAAsB;YAkCtB,kBAAkB;IAyJhC,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,CASjB"}
|
|
@@ -45,7 +45,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
45
45
|
};
|
|
46
46
|
})();
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports.MessageRouter = void 0;
|
|
48
|
+
exports.MessageRouter = exports.OPERATOR_BROADCAST_NOTICE_KEY = void 0;
|
|
49
|
+
exports.agentSavedInTurn = agentSavedInTurn;
|
|
49
50
|
exports.createMockAgentLoop = createMockAgentLoop;
|
|
50
51
|
const node_fs_1 = require("node:fs");
|
|
51
52
|
const node_path_1 = require("node:path");
|
|
@@ -57,6 +58,7 @@ const complete_autonomous_prompt_js_1 = require("../onboarding/complete-autonomo
|
|
|
57
58
|
const session_pool_js_1 = require("../agent/session-pool.js");
|
|
58
59
|
const agent_loop_js_1 = require("../agent/agent-loop.js");
|
|
59
60
|
const role_manager_js_1 = require("../agent/role-manager.js");
|
|
61
|
+
const tool_registry_js_1 = require("../agent/tool-registry.js");
|
|
60
62
|
const context_prompt_builder_js_1 = require("../agent/context-prompt-builder.js");
|
|
61
63
|
const prompt_enhancer_js_1 = require("../agent/prompt-enhancer.js");
|
|
62
64
|
const debugLogger = __importStar(require("@jungjaehoon/mama-core/debug-logger"));
|
|
@@ -65,10 +67,16 @@ const agent_notice_queue_js_1 = require("../memory/agent-notice-queue.js");
|
|
|
65
67
|
const scope_context_js_1 = require("../memory/scope-context.js");
|
|
66
68
|
const recall_bundle_formatter_js_1 = require("../memory/recall-bundle-formatter.js");
|
|
67
69
|
const save_candidate_extractor_js_1 = require("../memory/save-candidate-extractor.js");
|
|
70
|
+
const untrusted_content_js_1 = require("../utils/untrusted-content.js");
|
|
71
|
+
const security_monitor_js_1 = require("../security/security-monitor.js");
|
|
72
|
+
const report_carry_js_1 = require("../operator/report-carry.js");
|
|
68
73
|
const agent_store_js_1 = require("../db/agent-store.js");
|
|
69
74
|
const reactive_config_js_1 = require("../envelope/reactive-config.js");
|
|
70
75
|
const { DebugLogger } = debugLogger;
|
|
71
76
|
const logger = new DebugLogger('MessageRouter');
|
|
77
|
+
/** Channel-less host alarms (workorder failures) park here; every resumed
|
|
78
|
+
* owner turn reads this key in addition to its own channel key. */
|
|
79
|
+
exports.OPERATOR_BROADCAST_NOTICE_KEY = 'operator:broadcast';
|
|
72
80
|
/**
|
|
73
81
|
* Sensitive patterns that should only be configured via MAMA OS Viewer
|
|
74
82
|
*/
|
|
@@ -131,6 +139,24 @@ function sanitizeForPrompt(text) {
|
|
|
131
139
|
function stripGatewayDecorations(text) {
|
|
132
140
|
return text.replace(/^(?:\s*\|\|[\s\S]*?\|\|\s*)+/u, '').trim();
|
|
133
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* True when the agent persisted memory during THIS turn (gateway mama_save in
|
|
144
|
+
* the reasoning header) - the extractor safety net then skips to avoid the
|
|
145
|
+
* dual-save duplicate proven live on 2026-07-17.
|
|
146
|
+
*/
|
|
147
|
+
function agentSavedInTurn(response) {
|
|
148
|
+
if (!response) {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
// Only the reasoning header (first '||...||' line) counts - a prose mention
|
|
152
|
+
// of the marker in the body must not suppress the extractor safety net.
|
|
153
|
+
const newline = response.indexOf('\n');
|
|
154
|
+
const headerLine = newline === -1 ? response : response.slice(0, newline);
|
|
155
|
+
if (!headerLine.startsWith('||')) {
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
return /\u{1F527} mama_save\b/u.test(headerLine);
|
|
159
|
+
}
|
|
134
160
|
/**
|
|
135
161
|
* Check if message contains sensitive configuration request
|
|
136
162
|
*/
|
|
@@ -159,7 +185,6 @@ class MessageRouter {
|
|
|
159
185
|
envelopeAuthority;
|
|
160
186
|
roleManager;
|
|
161
187
|
promptEnhancer;
|
|
162
|
-
cachedGatewayToolsPrompt = null;
|
|
163
188
|
gatewayRegistry = null;
|
|
164
189
|
memoryAgentProcessManager;
|
|
165
190
|
memoryAuditQueue;
|
|
@@ -291,6 +316,24 @@ class MessageRouter {
|
|
|
291
316
|
getMemoryAgentStats() {
|
|
292
317
|
return { ...this.memoryAgentStats };
|
|
293
318
|
}
|
|
319
|
+
/**
|
|
320
|
+
* Host-code enqueue into the owner notice surface (Stage-2 workorder
|
|
321
|
+
* failures). The queue stays router-owned; this is the accessor plan C5
|
|
322
|
+
* requires - the consumer lives in start.ts host code and cannot reach the
|
|
323
|
+
* private field. Keyed under the operator BROADCAST key: host alarms have
|
|
324
|
+
* no conversation channel, and per-channel keys would dead-letter (review
|
|
325
|
+
* M1). Delivered on the owner's next resumed chat turn on ANY channel.
|
|
326
|
+
*/
|
|
327
|
+
enqueueOperatorNotice(summary) {
|
|
328
|
+
this.memoryNoticeQueue.enqueue(exports.OPERATOR_BROADCAST_NOTICE_KEY, {
|
|
329
|
+
type: 'memory_warning',
|
|
330
|
+
severity: 'high',
|
|
331
|
+
summary,
|
|
332
|
+
evidence: [],
|
|
333
|
+
recommended_action: 'recheck',
|
|
334
|
+
relevant_memories: [],
|
|
335
|
+
});
|
|
336
|
+
}
|
|
294
337
|
/**
|
|
295
338
|
* Public API for auditing a conversation via the memory agent.
|
|
296
339
|
* Used by the /api/mama/audit-conversation endpoint for benchmarking.
|
|
@@ -366,7 +409,12 @@ class MessageRouter {
|
|
|
366
409
|
* Determines role based on message source and builds context
|
|
367
410
|
*/
|
|
368
411
|
createAgentContext(message, sessionId) {
|
|
369
|
-
|
|
412
|
+
// Per-message trust context: chatType is runtime state (a locked allowlist
|
|
413
|
+
// alone cannot prove owner - allowlisted groups contain third parties).
|
|
414
|
+
const { roleName, role } = this.roleManager.getRoleForSource(message.source, {
|
|
415
|
+
channelId: message.channelId,
|
|
416
|
+
chatType: typeof message.metadata?.chatType === 'string' ? message.metadata.chatType : undefined,
|
|
417
|
+
});
|
|
370
418
|
const capabilities = this.roleManager.getCapabilities(role);
|
|
371
419
|
const limitations = this.roleManager.getLimitations(role);
|
|
372
420
|
const ctx = (0, context_prompt_builder_js_1.createAgentContext)(message.source, roleName, role, {
|
|
@@ -402,8 +450,40 @@ class MessageRouter {
|
|
|
402
450
|
*/
|
|
403
451
|
async process(message, processOptions) {
|
|
404
452
|
const startTime = Date.now();
|
|
405
|
-
// Security: Block sensitive configuration requests from non-viewer sources
|
|
406
|
-
|
|
453
|
+
// Security: Block sensitive configuration requests from non-viewer sources.
|
|
454
|
+
// The wall applies to OWNER-authored text only: untrusted-wrapped blocks
|
|
455
|
+
// (forwarded third-party content) are stripped first - the owner forwarding
|
|
456
|
+
// a phishing message that merely mentions "api key" must reach the persona
|
|
457
|
+
// (as labeled data), not trip the wall. Sensitive patterns INSIDE wrapped
|
|
458
|
+
// content are tripwire-logged instead (S1-T7).
|
|
459
|
+
// Strip wrapped blocks ONLY when trusted gateway metadata says the gateway
|
|
460
|
+
// itself wrapped them (forwarded content). Sender-typed markers are
|
|
461
|
+
// forgeable in-band data and never a security boundary: without the flag
|
|
462
|
+
// the wall sees the FULL text ('keep' handles unterminated spoofs too).
|
|
463
|
+
const gatewayWrapped = message.metadata?.untrustedWrapped === true;
|
|
464
|
+
const ownerAuthoredText = gatewayWrapped
|
|
465
|
+
? (0, untrusted_content_js_1.stripUntrustedBlocks)(message.text, { unterminated: 'keep' })
|
|
466
|
+
: message.text;
|
|
467
|
+
const hasWrappedBlocks = gatewayWrapped && ownerAuthoredText !== message.text;
|
|
468
|
+
// Tripwire (record-only, never blocks): sensitive patterns INSIDE wrapped
|
|
469
|
+
// third-party content are observability signals, not walls.
|
|
470
|
+
if (hasWrappedBlocks &&
|
|
471
|
+
containsSensitiveRequest(message.text) &&
|
|
472
|
+
!containsSensitiveRequest(ownerAuthoredText)) {
|
|
473
|
+
(0, security_monitor_js_1.logSecurityEventOnly)({
|
|
474
|
+
type: 'sensitive_content_in_forward',
|
|
475
|
+
severity: 'warn',
|
|
476
|
+
message: 'Sensitive pattern inside forwarded/wrapped content (tripwire, not blocked)',
|
|
477
|
+
details: { source: message.source, channelId: message.channelId },
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
if (message.source !== 'viewer' && containsSensitiveRequest(ownerAuthoredText)) {
|
|
481
|
+
(0, security_monitor_js_1.logSecurityEventOnly)({
|
|
482
|
+
type: 'sensitive_request_blocked',
|
|
483
|
+
severity: 'warn',
|
|
484
|
+
message: 'Sensitive configuration request blocked in chat',
|
|
485
|
+
details: { source: message.source, channelId: message.channelId },
|
|
486
|
+
});
|
|
407
487
|
const securityResponse = `🔒 **Security Notice**
|
|
408
488
|
|
|
409
489
|
For security reasons, token and API key configuration must be done through MAMA OS.
|
|
@@ -518,14 +598,20 @@ This protects your credentials from being exposed in chat logs.`;
|
|
|
518
598
|
'.model: claude-sonnet-4-6\n' +
|
|
519
599
|
' Codex: codex login → roles.definitions.' +
|
|
520
600
|
agentContext.roleName +
|
|
521
|
-
'.model: gpt-5.
|
|
601
|
+
'.model: gpt-5.4\n\n' +
|
|
522
602
|
'Or run: mama init --reconfigure');
|
|
523
603
|
}
|
|
524
604
|
const roleMaxTurns = agentContext.role.maxTurns;
|
|
605
|
+
const sessionPolicyFingerprint = this.buildSessionPolicyFingerprint(agentContext, enhanced, roleModel);
|
|
525
606
|
// Determine if we should resume an existing CLI session
|
|
526
607
|
// - New CLI session: start with --session-id (inject full system prompt)
|
|
527
608
|
// - Continuing CLI session: use --resume flag (minimal injection - CLI has context)
|
|
528
609
|
const shouldResume = !isNewCliSession;
|
|
610
|
+
// Codex persists thread IDs independently from the in-memory SessionPool.
|
|
611
|
+
// After a daemon restart the pool is new, but the durable Codex thread may
|
|
612
|
+
// still exist and should be resumed. Keep prompt/context freshness separate
|
|
613
|
+
// from backend conversation continuity.
|
|
614
|
+
const shouldResumeBackend = this.config.backend === 'codex' ? true : shouldResume;
|
|
529
615
|
// For resumed sessions: inject minimal context only
|
|
530
616
|
// Persistent CLI keeps the process alive with full system prompt from initial request
|
|
531
617
|
// Only inject per-message context (related decisions) to avoid context overflow
|
|
@@ -567,18 +653,20 @@ This protects your credentials from being exposed in chat logs.`;
|
|
|
567
653
|
// keep using CLI conversation state and only prepend queued audit notices.
|
|
568
654
|
let memoryPrefix = '';
|
|
569
655
|
let pendingNotices = false;
|
|
570
|
-
let
|
|
656
|
+
let pendingChannelNoticeCount = 0;
|
|
657
|
+
let pendingBroadcastNoticeCount = 0;
|
|
571
658
|
try {
|
|
572
659
|
const envelope = this.buildReactiveEnvelope(message);
|
|
573
660
|
const options = {
|
|
574
661
|
systemPrompt: effectivePrompt,
|
|
662
|
+
sessionPolicyFingerprint,
|
|
575
663
|
userId: message.userId,
|
|
576
664
|
model: roleModel, // Role-specific model override
|
|
577
665
|
maxTurns: roleMaxTurns, // Role-specific max turns
|
|
578
666
|
source: message.source,
|
|
579
667
|
channelId: message.channelId,
|
|
580
668
|
agentContext,
|
|
581
|
-
resumeSession:
|
|
669
|
+
resumeSession: shouldResumeBackend,
|
|
582
670
|
cliSessionId, // Pass CLI session ID to avoid double-locking
|
|
583
671
|
streamCallbacks: wrappedOnStream || processOptions?.onStream,
|
|
584
672
|
envelope,
|
|
@@ -591,11 +679,29 @@ This protects your credentials from being exposed in chat logs.`;
|
|
|
591
679
|
else {
|
|
592
680
|
logger.info(`New CLI session (full: ${systemPrompt.length} chars)`);
|
|
593
681
|
}
|
|
682
|
+
// Context carry (plan v6 S1-T4): owner console turns reference the last
|
|
683
|
+
// DELIVERED full report. User-message prefix is the only channel that
|
|
684
|
+
// reaches the model on EVERY turn including CONTINUE (per-call system
|
|
685
|
+
// prompts never reach a pooled CLI process).
|
|
686
|
+
const carryPrefix = agentContext?.roleName === 'owner_console' ? (0, report_carry_js_1.buildReportCarryPrefix)() : '';
|
|
594
687
|
try {
|
|
595
688
|
if (shouldResume) {
|
|
596
|
-
|
|
689
|
+
// Per-channel notices PLUS the operator broadcast key: host-code
|
|
690
|
+
// alarms (workorder failures) have no conversation channel at
|
|
691
|
+
// enqueue time - without the broadcast read they dead-letter
|
|
692
|
+
// (Stage-2 review M1). Broadcast is OWNER-ONLY (review N3: a
|
|
693
|
+
// non-owner/group turn must neither see internal ops state nor
|
|
694
|
+
// drain the queue away from the owner), and the two queues are
|
|
695
|
+
// peeked/drained by their OWN counts (review N2: a combined count
|
|
696
|
+
// over-drained one queue, dropping mid-turn notices undisplayed).
|
|
697
|
+
const channelNotices = this.memoryNoticeQueue.peek(channelKey);
|
|
698
|
+
const broadcastNotices = agentContext?.roleName === 'owner_console'
|
|
699
|
+
? this.memoryNoticeQueue.peek(exports.OPERATOR_BROADCAST_NOTICE_KEY)
|
|
700
|
+
: [];
|
|
701
|
+
const notices = [...channelNotices, ...broadcastNotices];
|
|
597
702
|
pendingNotices = notices.length > 0;
|
|
598
|
-
|
|
703
|
+
pendingChannelNoticeCount = channelNotices.length;
|
|
704
|
+
pendingBroadcastNoticeCount = broadcastNotices.length;
|
|
599
705
|
memoryPrefix = notices.map((notice) => (0, recall_bundle_formatter_js_1.formatAuditNotice)(notice)).join('\n\n');
|
|
600
706
|
if (memoryPrefix) {
|
|
601
707
|
memoryPrefix = `${memoryPrefix}\n\n`;
|
|
@@ -646,7 +752,7 @@ This protects your credentials from being exposed in chat logs.`;
|
|
|
646
752
|
}
|
|
647
753
|
// Add text content (with memory context, skill context, and page context)
|
|
648
754
|
const pageCtx = this.getPageContextPrefix(message);
|
|
649
|
-
const effectiveMessageText = `${pageCtx}${memoryPrefix}${skillPrefix}${messageText || ''}`;
|
|
755
|
+
const effectiveMessageText = `${pageCtx}${carryPrefix}${memoryPrefix}${skillPrefix}${messageText || ''}`;
|
|
650
756
|
if (effectiveMessageText) {
|
|
651
757
|
contentBlocks.push({ type: 'text', text: effectiveMessageText });
|
|
652
758
|
}
|
|
@@ -675,15 +781,24 @@ This protects your credentials from being exposed in chat logs.`;
|
|
|
675
781
|
}
|
|
676
782
|
else {
|
|
677
783
|
const pageCtx = this.getPageContextPrefix(message);
|
|
678
|
-
const effectiveText = `${pageCtx}${memoryPrefix}${skillPrefix}${message.text}`;
|
|
784
|
+
const effectiveText = `${pageCtx}${carryPrefix}${memoryPrefix}${skillPrefix}${message.text}`;
|
|
679
785
|
const conductorStart = Date.now();
|
|
680
786
|
const result = await this.agentLoop.run(effectiveText, options);
|
|
681
787
|
response = result.response;
|
|
682
788
|
parentModelRunId = result.modelRunId ?? undefined;
|
|
683
789
|
this.logFrontdoorActivity(message, message.text, response, Date.now() - conductorStart);
|
|
684
790
|
}
|
|
685
|
-
// Auto-extract facts from conversation (fire-and-forget, non-blocking)
|
|
686
|
-
|
|
791
|
+
// Auto-extract facts from conversation (fire-and-forget, non-blocking).
|
|
792
|
+
// Dual-save dedup: when the agent ALREADY persisted memory during this
|
|
793
|
+
// turn (gateway mama_save in the reasoning header), the extractor safety
|
|
794
|
+
// net would save the same instruction twice (proven live 2026-07-17:
|
|
795
|
+
// decision_* + mem_* duplicates for one directive). The in-turn save is
|
|
796
|
+
// the agent's judgment; the net exists for turns where it did not act.
|
|
797
|
+
const agentSavedThisTurn = agentSavedInTurn(response);
|
|
798
|
+
if (agentSavedThisTurn) {
|
|
799
|
+
logger.info('[memory-agent] extraction skipped - agent saved in-turn (dual-save dedup)');
|
|
800
|
+
}
|
|
801
|
+
if (response && message.text && !agentSavedThisTurn) {
|
|
687
802
|
const rawAssistantText = stripGatewayDecorations(response);
|
|
688
803
|
void (async () => {
|
|
689
804
|
try {
|
|
@@ -695,7 +810,14 @@ This protects your credentials from being exposed in chat logs.`;
|
|
|
695
810
|
})();
|
|
696
811
|
}
|
|
697
812
|
if (shouldResume && pendingNotices) {
|
|
698
|
-
|
|
813
|
+
// Drain each queue by ITS OWN peeked count - notices enqueued while
|
|
814
|
+
// the agent run was in flight stay for the next turn (review N2).
|
|
815
|
+
if (pendingChannelNoticeCount > 0) {
|
|
816
|
+
this.memoryNoticeQueue.drain(channelKey, pendingChannelNoticeCount);
|
|
817
|
+
}
|
|
818
|
+
if (pendingBroadcastNoticeCount > 0) {
|
|
819
|
+
this.memoryNoticeQueue.drain(exports.OPERATOR_BROADCAST_NOTICE_KEY, pendingBroadcastNoticeCount);
|
|
820
|
+
}
|
|
699
821
|
}
|
|
700
822
|
}
|
|
701
823
|
catch (error) {
|
|
@@ -899,6 +1021,13 @@ ${historyContext}
|
|
|
899
1021
|
if (agentContext?.platform === 'viewer') {
|
|
900
1022
|
prompt += `\n- Image display: cp to ~/.mama/workspace/media/outbound/ then write bare path in response.`;
|
|
901
1023
|
}
|
|
1024
|
+
if (agentContext?.roleName === 'owner_console') {
|
|
1025
|
+
// Store canonicity (Stage-2 S2-T7): two task stores exist with different
|
|
1026
|
+
// vocabularies - the agent must never present their mismatch as data.
|
|
1027
|
+
prompt += `
|
|
1028
|
+
- Task-store canonicity: kagemusha_* is the READ-ONLY project-task truth; the native ledger (task_list/task_create/task_update) holds owner-console tasks. Their status vocabularies DIFFER (e.g. kagemusha has no 'blocked') - when a status query returns nothing, say the vocabulary difference instead of inferring the work is gone.
|
|
1029
|
+
- Answer status questions from artifacts first (board_read, workorder_status, audit_findings_read), then live queries; memory recall is the LAST resort and may be stale - cite which source answered.`;
|
|
1030
|
+
}
|
|
902
1031
|
prompt += '\n';
|
|
903
1032
|
if (enhanced?.keywordInstructions) {
|
|
904
1033
|
prompt += `\n${enhanced.keywordInstructions}\n`;
|
|
@@ -907,17 +1036,38 @@ ${historyContext}
|
|
|
907
1036
|
// because PersistentCLI sessions can't update system prompt after creation.
|
|
908
1037
|
// See process() method for user-message injection.
|
|
909
1038
|
// Include gateway tools directly in system prompt (priority 1 protection)
|
|
910
|
-
// so they don't get truncated by PromptSizeMonitor as a separate layer
|
|
911
|
-
//
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
1039
|
+
// so they don't get truncated by PromptSizeMonitor as a separate layer.
|
|
1040
|
+
// Prompt-permission coherence: advertise ONLY the tools this role can
|
|
1041
|
+
// execute - the previous role-agnostic single cache advertised the full
|
|
1042
|
+
// catalog, teaching the model to call tools the executor then denied.
|
|
1043
|
+
// getGatewayToolsPrompt keeps its own per-disallowed-key cache, and its
|
|
1044
|
+
// per-bullet filter preserves the '## Gateway Tools' marker - AgentLoop
|
|
1045
|
+
// must keep seeing that marker or it double-injects an UNFILTERED catalog
|
|
1046
|
+
// (agent-loop alreadyHasTools check).
|
|
1047
|
+
const disallowedForRole = agentContext
|
|
1048
|
+
? tool_registry_js_1.ToolRegistry.getValidToolNames().filter((name) => !this.roleManager.isToolAllowed(agentContext.role, name))
|
|
1049
|
+
: undefined;
|
|
1050
|
+
const gatewayToolsPrompt = this.config.backend === 'codex' ? '' : (0, agent_loop_js_1.getGatewayToolsPrompt)(disallowedForRole) || '';
|
|
1051
|
+
if (gatewayToolsPrompt) {
|
|
1052
|
+
prompt += `\n---\n\n${gatewayToolsPrompt}\n`;
|
|
918
1053
|
}
|
|
919
1054
|
return prompt;
|
|
920
1055
|
}
|
|
1056
|
+
buildSessionPolicyFingerprint(agentContext, enhanced, model) {
|
|
1057
|
+
const soulPath = (0, node_path_1.join)((0, node_os_1.homedir)(), '.mama', 'SOUL.md');
|
|
1058
|
+
const baseInstructions = (0, node_fs_1.existsSync)(soulPath)
|
|
1059
|
+
? (0, agent_loop_js_1.loadComposedSystemPrompt)(false, agentContext)
|
|
1060
|
+
: complete_autonomous_prompt_js_1.COMPLETE_AUTONOMOUS_PROMPT;
|
|
1061
|
+
return (0, node_crypto_1.createHash)('sha256')
|
|
1062
|
+
.update(baseInstructions)
|
|
1063
|
+
.update('\0')
|
|
1064
|
+
.update(enhanced.agentsContent ?? '')
|
|
1065
|
+
.update('\0')
|
|
1066
|
+
.update(enhanced.rulesContent ?? '')
|
|
1067
|
+
.update('\0')
|
|
1068
|
+
.update(model)
|
|
1069
|
+
.digest('hex');
|
|
1070
|
+
}
|
|
921
1071
|
/**
|
|
922
1072
|
* Build minimal prompt for resumed CLI sessions.
|
|
923
1073
|
* CLI already has full system prompt from initial request.
|
|
@@ -1239,6 +1389,7 @@ INSTRUCTION:
|
|
|
1239
1389
|
const userId = message?.userId;
|
|
1240
1390
|
const candidates = (0, save_candidate_extractor_js_1.extractSaveCandidates)({
|
|
1241
1391
|
userText,
|
|
1392
|
+
gatewayWrapped: message?.metadata?.untrustedWrapped === true,
|
|
1242
1393
|
botResponse,
|
|
1243
1394
|
channelKey,
|
|
1244
1395
|
source,
|
|
@@ -1249,7 +1400,11 @@ INSTRUCTION:
|
|
|
1249
1400
|
});
|
|
1250
1401
|
const cooldownKey = `${source}:${channelId}:${userId ?? 'anonymous'}`;
|
|
1251
1402
|
const lastExtractTime = this.memoryAuditCooldowns.get(cooldownKey) ?? 0;
|
|
1252
|
-
|
|
1403
|
+
// The cooldown rate-limits memory-agent invocations for ORDINARY chatter.
|
|
1404
|
+
// Candidate-bearing turns are owner directives/decisions - discarding one
|
|
1405
|
+
// because another arrived within 30s loses real instructions, so they
|
|
1406
|
+
// bypass the cooldown (bounded by how fast an owner can type directives).
|
|
1407
|
+
if (candidates.length === 0 && now - lastExtractTime < MessageRouter.EXTRACT_COOLDOWN_MS) {
|
|
1253
1408
|
return;
|
|
1254
1409
|
}
|
|
1255
1410
|
let content = `User: ${userText}\nAssistant: ${botResponse}`;
|