@jungjaehoon/mama-os 0.48.3 → 0.49.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/dist/agent/agent-loop.d.ts +6 -7
- package/dist/agent/agent-loop.d.ts.map +1 -1
- package/dist/agent/agent-loop.js +93 -79
- package/dist/agent/agent-loop.js.map +1 -1
- package/dist/agent/code-act/host-bridge.d.ts.map +1 -1
- package/dist/agent/code-act/host-bridge.js +2 -10
- package/dist/agent/code-act/host-bridge.js.map +1 -1
- package/dist/agent/codex-home.d.ts.map +1 -1
- package/dist/agent/codex-home.js +3 -1
- package/dist/agent/codex-home.js.map +1 -1
- package/dist/agent/gateway-tool-executor.d.ts +0 -16
- package/dist/agent/gateway-tool-executor.d.ts.map +1 -1
- package/dist/agent/gateway-tool-executor.js +0 -51
- package/dist/agent/gateway-tool-executor.js.map +1 -1
- package/dist/agent/gateway-tools.md +1 -2
- package/dist/agent/os-agent-capabilities.md +14 -34
- package/dist/agent/role-manager.d.ts.map +1 -1
- package/dist/agent/role-manager.js +6 -3
- package/dist/agent/role-manager.js.map +1 -1
- package/dist/agent/tool-registry.d.ts.map +1 -1
- package/dist/agent/tool-registry.js +2 -8
- package/dist/agent/tool-registry.js.map +1 -1
- package/dist/agent/types.d.ts +18 -6
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/api/graph-api-types.d.ts +0 -18
- package/dist/api/graph-api-types.d.ts.map +1 -1
- package/dist/api/graph-api.d.ts.map +1 -1
- package/dist/api/graph-api.js +9 -81
- package/dist/api/graph-api.js.map +1 -1
- package/dist/cli/commands/start.d.ts +7 -16
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +181 -188
- 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 +11 -4
- 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 +28 -11
- package/dist/cli/runtime/agent-loop-init.js.map +1 -1
- package/dist/cli/runtime/api-routes-init.d.ts +0 -2
- package/dist/cli/runtime/api-routes-init.d.ts.map +1 -1
- package/dist/cli/runtime/api-routes-init.js +9 -95
- package/dist/cli/runtime/api-routes-init.js.map +1 -1
- package/dist/cli/runtime/api-server-init.d.ts +2 -2
- package/dist/cli/runtime/api-server-init.d.ts.map +1 -1
- package/dist/cli/runtime/api-server-init.js +2 -2
- package/dist/cli/runtime/api-server-init.js.map +1 -1
- package/dist/cli/runtime/scheduler-init.d.ts +3 -4
- package/dist/cli/runtime/scheduler-init.d.ts.map +1 -1
- package/dist/cli/runtime/scheduler-init.js +6 -16
- package/dist/cli/runtime/scheduler-init.js.map +1 -1
- package/dist/cli/runtime/shutdown.d.ts +0 -1
- package/dist/cli/runtime/shutdown.d.ts.map +1 -1
- package/dist/cli/runtime/shutdown.js +1 -1
- package/dist/cli/runtime/shutdown.js.map +1 -1
- package/dist/cli/runtime/types.d.ts +0 -5
- package/dist/cli/runtime/types.d.ts.map +1 -1
- package/dist/concurrency/lane-manager.d.ts +1 -1
- package/dist/concurrency/lane-manager.d.ts.map +1 -1
- package/dist/concurrency/lane-manager.js +4 -2
- package/dist/concurrency/lane-manager.js.map +1 -1
- package/dist/concurrency/types.d.ts +4 -0
- package/dist/concurrency/types.d.ts.map +1 -1
- package/dist/concurrency/types.js.map +1 -1
- package/dist/envelope/types.d.ts +1 -1
- package/dist/envelope/types.d.ts.map +1 -1
- package/dist/envelope/types.js.map +1 -1
- package/dist/gateways/message-router.d.ts +13 -71
- package/dist/gateways/message-router.d.ts.map +1 -1
- package/dist/gateways/message-router.js +99 -489
- package/dist/gateways/message-router.js.map +1 -1
- package/dist/gateways/session-store.d.ts +3 -23
- package/dist/gateways/session-store.d.ts.map +1 -1
- package/dist/gateways/session-store.js +2 -64
- package/dist/gateways/session-store.js.map +1 -1
- package/dist/gateways/telegram-report-context-store.d.ts +4 -66
- package/dist/gateways/telegram-report-context-store.d.ts.map +1 -1
- package/dist/gateways/telegram-report-context-store.js +11 -235
- package/dist/gateways/telegram-report-context-store.js.map +1 -1
- package/dist/gateways/turn-contract.d.ts +7 -3
- package/dist/gateways/turn-contract.d.ts.map +1 -1
- package/dist/operator/operator-trigger-loop.d.ts +1 -12
- package/dist/operator/operator-trigger-loop.d.ts.map +1 -1
- package/dist/operator/operator-trigger-loop.js +6 -40
- package/dist/operator/operator-trigger-loop.js.map +1 -1
- package/dist/operator/owner-event-loop.d.ts +8 -7
- package/dist/operator/owner-event-loop.d.ts.map +1 -1
- package/dist/operator/owner-event-loop.js +7 -20
- package/dist/operator/owner-event-loop.js.map +1 -1
- package/dist/operator/owner-event-policy.d.ts.map +1 -1
- package/dist/operator/owner-event-policy.js +0 -2
- package/dist/operator/owner-event-policy.js.map +1 -1
- package/dist/operator/owner-event-prompt.d.ts +0 -2
- package/dist/operator/owner-event-prompt.d.ts.map +1 -1
- package/dist/operator/owner-event-prompt.js +1 -8
- package/dist/operator/owner-event-prompt.js.map +1 -1
- package/dist/operator/owner-runtime-journal.d.ts +21 -0
- package/dist/operator/owner-runtime-journal.d.ts.map +1 -0
- package/dist/operator/owner-runtime-journal.js +131 -0
- package/dist/operator/owner-runtime-journal.js.map +1 -0
- package/dist/operator/owner-runtime.d.ts +32 -0
- package/dist/operator/owner-runtime.d.ts.map +1 -0
- package/dist/operator/owner-runtime.js +31 -0
- package/dist/operator/owner-runtime.js.map +1 -0
- package/dist/operator/pending-report-store.d.ts +2 -2
- package/dist/operator/pending-report-store.d.ts.map +1 -1
- package/dist/operator/pending-report-store.js +4 -1
- package/dist/operator/pending-report-store.js.map +1 -1
- package/dist/operator/report-run.d.ts +7 -10
- package/dist/operator/report-run.d.ts.map +1 -1
- package/dist/operator/report-run.js +5 -26
- package/dist/operator/report-run.js.map +1 -1
- package/dist/operator/situation-report.d.ts +25 -6
- package/dist/operator/situation-report.d.ts.map +1 -1
- package/dist/operator/situation-report.js +25 -37
- package/dist/operator/situation-report.js.map +1 -1
- package/dist/operator/trigger-author.d.ts +0 -45
- package/dist/operator/trigger-author.d.ts.map +1 -1
- package/dist/operator/trigger-author.js +0 -122
- package/dist/operator/trigger-author.js.map +1 -1
- package/dist/operator/worker-run.d.ts +9 -23
- package/dist/operator/worker-run.d.ts.map +1 -1
- package/dist/operator/worker-run.js +18 -74
- package/dist/operator/worker-run.js.map +1 -1
- package/dist/operator/workorder-consumer.d.ts.map +1 -1
- package/dist/operator/workorder-consumer.js +7 -0
- package/dist/operator/workorder-consumer.js.map +1 -1
- package/dist/scheduler/cron-worker.d.ts +0 -3
- package/dist/scheduler/cron-worker.d.ts.map +1 -1
- package/dist/scheduler/cron-worker.js +2 -13
- package/dist/scheduler/cron-worker.js.map +1 -1
- package/dist/scheduler/heartbeat.d.ts +3 -1
- package/dist/scheduler/heartbeat.d.ts.map +1 -1
- package/dist/scheduler/heartbeat.js +13 -4
- package/dist/scheduler/heartbeat.js.map +1 -1
- package/dist/validation/types.d.ts +1 -1
- package/dist/validation/types.js +1 -1
- package/dist/wiki/wiki-turn-contract.d.ts.map +1 -1
- package/dist/wiki/wiki-turn-contract.js +1 -0
- package/dist/wiki/wiki-turn-contract.js.map +1 -1
- package/dist/wiki-artifacts/wiki-publish-adapter.d.ts.map +1 -1
- package/dist/wiki-artifacts/wiki-publish-adapter.js +11 -1
- package/dist/wiki-artifacts/wiki-publish-adapter.js.map +1 -1
- package/package.json +1 -1
- package/dist/cli/runtime/memory-agent-init.d.ts +0 -37
- package/dist/cli/runtime/memory-agent-init.d.ts.map +0 -1
- package/dist/cli/runtime/memory-agent-init.js +0 -202
- package/dist/cli/runtime/memory-agent-init.js.map +0 -1
- package/dist/gateways/owner-report-inbox.d.ts +0 -40
- package/dist/gateways/owner-report-inbox.d.ts.map +0 -1
- package/dist/gateways/owner-report-inbox.js +0 -128
- package/dist/gateways/owner-report-inbox.js.map +0 -1
- package/dist/multi-agent/memory-agent-persona.d.ts +0 -11
- package/dist/multi-agent/memory-agent-persona.d.ts.map +0 -1
- package/dist/multi-agent/memory-agent-persona.js +0 -175
- package/dist/multi-agent/memory-agent-persona.js.map +0 -1
- package/dist/operator/report-context.d.ts +0 -184
- package/dist/operator/report-context.d.ts.map +0 -1
- package/dist/operator/report-context.js +0 -1052
- package/dist/operator/report-context.js.map +0 -1
|
@@ -65,7 +65,6 @@ exports.buildTurnAgentPolicy = buildTurnAgentPolicy;
|
|
|
65
65
|
exports.bindCodeActParentModelRun = bindCodeActParentModelRun;
|
|
66
66
|
exports.finalizeCodeActParentModelRun = finalizeCodeActParentModelRun;
|
|
67
67
|
exports.failCodeActParentModelRun = failCodeActParentModelRun;
|
|
68
|
-
exports.buildSystemAgentProcessDefaults = buildSystemAgentProcessDefaults;
|
|
69
68
|
exports.resolveOwnerEventTerminalReceipt = resolveOwnerEventTerminalReceipt;
|
|
70
69
|
exports.startCommand = startCommand;
|
|
71
70
|
exports.buildStartOnboardingOutput = buildStartOnboardingOutput;
|
|
@@ -85,7 +84,6 @@ const run_context_registry_js_1 = require("../../agent/code-act/run-context-regi
|
|
|
85
84
|
const index_js_2 = require("../../gateways/index.js");
|
|
86
85
|
const member_effective_scope_js_1 = require("../../gateways/member-effective-scope.js");
|
|
87
86
|
const telegram_report_context_store_js_1 = require("../../gateways/telegram-report-context-store.js");
|
|
88
|
-
const owner_report_inbox_js_1 = require("../../gateways/owner-report-inbox.js");
|
|
89
87
|
const report_delivery_coordinator_js_1 = require("../../operator/report-delivery-coordinator.js");
|
|
90
88
|
const graph_api_js_1 = require("../../api/graph-api.js");
|
|
91
89
|
const sqlite_js_1 = __importDefault(require("../../sqlite.js"));
|
|
@@ -104,7 +102,6 @@ const daemon_js_1 = require("../runtime/daemon.js");
|
|
|
104
102
|
const metrics_init_js_1 = require("../runtime/metrics-init.js");
|
|
105
103
|
const mama_core_init_js_1 = require("../runtime/mama-core-init.js");
|
|
106
104
|
const agent_loop_init_js_1 = require("../runtime/agent-loop-init.js");
|
|
107
|
-
const memory_agent_init_js_1 = require("../runtime/memory-agent-init.js");
|
|
108
105
|
const gateway_init_js_1 = require("../runtime/gateway-init.js");
|
|
109
106
|
const gateway_wiring_js_1 = require("../runtime/gateway-wiring.js");
|
|
110
107
|
const scheduler_init_js_1 = require("../runtime/scheduler-init.js");
|
|
@@ -127,12 +124,7 @@ const node_crypto_1 = require("node:crypto");
|
|
|
127
124
|
const debugLogger = __importStar(require("@jungjaehoon/mama-core/debug-logger"));
|
|
128
125
|
const mama_core_1 = require("@jungjaehoon/mama-core");
|
|
129
126
|
const mamaCore = __importStar(require("@jungjaehoon/mama-core"));
|
|
130
|
-
const
|
|
131
|
-
const report_context_js_1 = require("../../operator/report-context.js");
|
|
132
|
-
const changes_projection_js_1 = require("../../operator/changes-projection.js");
|
|
133
|
-
const external_correlation_js_1 = require("../../operator/external-correlation.js");
|
|
134
|
-
const provenance_lookup_js_1 = require("../../operator/provenance-lookup.js");
|
|
135
|
-
const query_tools_js_1 = require("../../connectors/trello/query-tools.js");
|
|
127
|
+
const owner_runtime_js_1 = require("../../operator/owner-runtime.js");
|
|
136
128
|
const console_brief_js_1 = require("../../operator/console-brief.js");
|
|
137
129
|
const task_ledger_js_1 = require("../../operator/task-ledger.js");
|
|
138
130
|
const board_refresh_gate_js_1 = require("../../operator/board-refresh-gate.js");
|
|
@@ -488,7 +480,6 @@ exports.ADMINISTRATION_TOOLS = new Set([
|
|
|
488
480
|
'member_scope_grant',
|
|
489
481
|
'member_scope_revoke',
|
|
490
482
|
'console_brief_update',
|
|
491
|
-
'report_request',
|
|
492
483
|
]);
|
|
493
484
|
/**
|
|
494
485
|
* Per-turn-kind artifact tools, projected by the HOST. These exist only for scheduled
|
|
@@ -613,15 +604,23 @@ exports.TURN_KIND_BLOCKED_TOOLS = {
|
|
|
613
604
|
'obsidian',
|
|
614
605
|
]),
|
|
615
606
|
};
|
|
616
|
-
/**
|
|
617
|
-
* Packet-only reports receive no gateway tools. The host compiles current bounded authorities
|
|
618
|
-
* before model admission; the model spends one turn judging and narrating that packet.
|
|
619
|
-
*/
|
|
607
|
+
/** Progressive evidence primitives for a scheduled owner-runtime report turn. */
|
|
620
608
|
exports.OPERATOR_REPORT_TOOL_POLICY = {
|
|
621
|
-
roleName: '
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
609
|
+
roleName: 'owner_console',
|
|
610
|
+
allowedTools: [
|
|
611
|
+
'code_act',
|
|
612
|
+
'task_list',
|
|
613
|
+
'changes_read',
|
|
614
|
+
'board_read',
|
|
615
|
+
'audit_findings_read',
|
|
616
|
+
'schedule_upcoming',
|
|
617
|
+
'context_compile',
|
|
618
|
+
'mama_recall',
|
|
619
|
+
'mama_provenance',
|
|
620
|
+
'trello_search',
|
|
621
|
+
'trello_card',
|
|
622
|
+
'trello_kanban',
|
|
623
|
+
],
|
|
625
624
|
};
|
|
626
625
|
function requirePrivateConnectorPolicy(privateConnectorPolicy) {
|
|
627
626
|
if (!privateConnectorPolicy) {
|
|
@@ -646,26 +645,36 @@ function buildProjectedLanePrompt(innerTools, surface, privateConnectorPolicy) {
|
|
|
646
645
|
}).prompt;
|
|
647
646
|
}
|
|
648
647
|
/**
|
|
649
|
-
* Build the
|
|
648
|
+
* Build the execution role for one progressive report stimulus. The durable
|
|
649
|
+
* session catalog comes from the full owner role; this role narrows effects.
|
|
650
650
|
*/
|
|
651
|
-
function buildOperatorReportAgentPolicy(model, backend, privateConnectorPolicy) {
|
|
651
|
+
function buildOperatorReportAgentPolicy(model, backend, privateConnectorPolicy, ownerRole = types_js_1.DEFAULT_ROLES.definitions.owner_console) {
|
|
652
652
|
const requiredPrivatePolicy = requirePrivateConnectorPolicy(privateConnectorPolicy);
|
|
653
|
-
const
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
653
|
+
const blockedSet = new Set([
|
|
654
|
+
...exports.ADMINISTRATION_TOOLS,
|
|
655
|
+
...exports.SCHEDULED_TURN_BLOCKED_TOOLS,
|
|
656
|
+
...(ownerRole.blockedTools ?? []),
|
|
657
|
+
]);
|
|
658
|
+
const projectedRole = requiredPrivatePolicy.projectRole('owner_console', {
|
|
659
|
+
...ownerRole,
|
|
660
|
+
model,
|
|
661
|
+
allowedTools: uniqueToolList([
|
|
662
|
+
...ownerRole.allowedTools,
|
|
663
|
+
...exports.OPERATOR_REPORT_TOOL_POLICY.allowedTools,
|
|
664
|
+
]).filter((tool) => !blockedSet.has(tool)),
|
|
665
|
+
blockedTools: [...blockedSet],
|
|
666
|
+
allowedPaths: [...(ownerRole.allowedPaths ?? [])],
|
|
667
|
+
});
|
|
668
|
+
const blockedTools = [...new Set([...(projectedRole.blockedTools ?? []), ...blockedSet])];
|
|
669
|
+
const innerTools = uniqueToolList(projectedRole.allowedTools).filter((tool) => tool !== 'code_act' && !blockedSet.has(tool));
|
|
670
|
+
const allowedTools = uniqueToolList(['code_act', ...innerTools]);
|
|
662
671
|
const agentContext = {
|
|
663
672
|
source: 'operator',
|
|
664
673
|
platform: 'cli',
|
|
665
|
-
roleName: exports.
|
|
674
|
+
roleName: exports.ONE_AGENT_TURN_POLICY.roleName,
|
|
666
675
|
role: { ...projectedRole, allowedTools, blockedTools, model },
|
|
667
676
|
session: {
|
|
668
|
-
sessionId:
|
|
677
|
+
sessionId: owner_runtime_js_1.OWNER_RUNTIME_SESSION_KEY,
|
|
669
678
|
channelId: 'report',
|
|
670
679
|
startedAt: new Date(),
|
|
671
680
|
},
|
|
@@ -676,7 +685,7 @@ function buildOperatorReportAgentPolicy(model, backend, privateConnectorPolicy)
|
|
|
676
685
|
};
|
|
677
686
|
return {
|
|
678
687
|
agentContext,
|
|
679
|
-
gatewayToolsPrompt: '',
|
|
688
|
+
gatewayToolsPrompt: buildProjectedLanePrompt(innerTools, 'owner_console', requiredPrivatePolicy),
|
|
680
689
|
briefProjectionPolicy: requiredPrivatePolicy,
|
|
681
690
|
};
|
|
682
691
|
}
|
|
@@ -718,7 +727,7 @@ function buildTurnAgentPolicy(kind, model, backend, privateConnectorPolicy, rawC
|
|
|
718
727
|
roleName: exports.ONE_AGENT_TURN_POLICY.roleName,
|
|
719
728
|
role: { ...projectedRole, allowedTools, blockedTools, model },
|
|
720
729
|
session: {
|
|
721
|
-
sessionId:
|
|
730
|
+
sessionId: owner_runtime_js_1.OWNER_RUNTIME_SESSION_KEY,
|
|
722
731
|
channelId: `worker:${kind}`,
|
|
723
732
|
startedAt: new Date(),
|
|
724
733
|
},
|
|
@@ -782,11 +791,6 @@ function failCodeActParentModelRun(adapter, modelRunId, error) {
|
|
|
782
791
|
}
|
|
783
792
|
(0, mama_core_1.failModelRunInAdapter)(adapter, modelRunId, codeActErrorSummary(error));
|
|
784
793
|
}
|
|
785
|
-
function buildSystemAgentProcessDefaults(config) {
|
|
786
|
-
return {
|
|
787
|
-
dangerouslySkipPermissions: config.multi_agent?.dangerouslySkipPermissions ?? true,
|
|
788
|
-
};
|
|
789
|
-
}
|
|
790
794
|
function resolveOwnerEventTerminalReceipt(batch, deps) {
|
|
791
795
|
// Crash-recovery mirror of classifyOwnerEventOutcome. A ledger write that
|
|
792
796
|
// named this batch's events as its cause (evidence_effects) or a confirmed
|
|
@@ -903,7 +907,7 @@ async function printStartOnboardingStatus() {
|
|
|
903
907
|
* Phase 1: Foundation (config, db, oauth, metrics)
|
|
904
908
|
* Phase 2: Session + Tool + Agent Loop
|
|
905
909
|
* Phase 3: MAMA Core API
|
|
906
|
-
* Phase 4:
|
|
910
|
+
* Phase 4: MessageRouter
|
|
907
911
|
* Phase 5: Graph Handler + Embedding
|
|
908
912
|
* Phase 6: Cron Scheduler
|
|
909
913
|
* Phase 7: Gateways
|
|
@@ -920,7 +924,7 @@ async function runAgentLoop(config, options = {}) {
|
|
|
920
924
|
const runtimeBackend = requireRuntimeBackend(config.agent.backend);
|
|
921
925
|
const { connectorConfigLoadResult, privateConnectorPolicy } = (0, connector_bootstrap_js_1.resolveRuntimeConnectorBootstrap)((0, config_loader_js_1.loadConnectorConfig)());
|
|
922
926
|
// ONE owner role for every model turn: chat, event, and scheduled.
|
|
923
|
-
const ownerRole = config.roles?.definitions.owner_console ?? types_js_1.DEFAULT_ROLES.definitions.owner_console;
|
|
927
|
+
const ownerRole = (0, owner_runtime_js_1.projectOwnerRuntimeRole)(config.roles?.definitions.owner_console ?? types_js_1.DEFAULT_ROLES.definitions.owner_console);
|
|
924
928
|
const temporalPolicy = temporalStartup.temporalFlag === 'on'
|
|
925
929
|
? buildTurnAgentPolicy('temporal', config.agent.model, runtimeBackend, privateConnectorPolicy, [], ownerRole)
|
|
926
930
|
: null;
|
|
@@ -967,15 +971,9 @@ async function runAgentLoop(config, options = {}) {
|
|
|
967
971
|
const { metricsStore, metricsCleanup, healthService, healthCheckService, metricsInterval } = await (0, metrics_init_js_1.initMetrics)(config, db, utilities_js_1.EMBEDDING_PORT);
|
|
968
972
|
// ── Phase 2: Session + Tool + Agent Loop ──────────────────────────────────
|
|
969
973
|
const sessionStore = new index_js_2.SessionStore(db);
|
|
970
|
-
// TG-05/TG-06:
|
|
971
|
-
//
|
|
972
|
-
|
|
973
|
-
// transaction (design Decision 4/6).
|
|
974
|
-
const reportContextStore = new telegram_report_context_store_js_1.TelegramReportContextStore(db, {
|
|
975
|
-
// TG-05 Slice K: one-time V2 carry migration; the file is renamed
|
|
976
|
-
// `.migrated` after commit and no component reads or writes V2 afterward.
|
|
977
|
-
legacyCarryPath: (0, config_manager_js_1.expandPath)('~/.mama/operator/last-full-report.json'),
|
|
978
|
-
});
|
|
974
|
+
// TG-05/TG-06: durable report delivery ledger. Conversation continuity is
|
|
975
|
+
// owned by the standing owner runtime, so this store never injects reports.
|
|
976
|
+
const reportContextStore = new telegram_report_context_store_js_1.TelegramReportContextStore(db);
|
|
979
977
|
// Establish one canonical private workspace for gateway files, OCR, Drive,
|
|
980
978
|
// Telegram media, and the persona runtime. An explicit environment override
|
|
981
979
|
// remains authoritative; otherwise honor config.workspace.path.
|
|
@@ -1040,16 +1038,15 @@ async function runAgentLoop(config, options = {}) {
|
|
|
1040
1038
|
memberGrantReader: principalRegistry,
|
|
1041
1039
|
dependencies: {
|
|
1042
1040
|
privateConnectorPolicy,
|
|
1043
|
-
//
|
|
1044
|
-
//
|
|
1045
|
-
// reads or writes V2 afterward. Wiring FileReportCarryStore here would
|
|
1046
|
-
// couple two owners to one file behind an implicit construction order.
|
|
1047
|
-
ownerReportInbox: new owner_report_inbox_js_1.OwnerReportInbox(reportContextStore),
|
|
1041
|
+
// Report delivery is receipted by the delivery ledger. Conversation
|
|
1042
|
+
// recovery belongs only to the owner-runtime journal.
|
|
1048
1043
|
},
|
|
1049
1044
|
});
|
|
1050
1045
|
messageRouter.setSessionsDb(db);
|
|
1051
1046
|
// validationService wired after creation (Phase 5 below)
|
|
1052
|
-
|
|
1047
|
+
// One MAMA: memory judgment stays in the owner turn through mama_save and
|
|
1048
|
+
// deterministic owner-policy observation. Do not boot a second model identity
|
|
1049
|
+
// that re-reads every conversation after the owner agent has answered.
|
|
1053
1050
|
// ── Phase 5: Graph Handler + Embedding ────────────────────────────────────
|
|
1054
1051
|
// Create singleton UI command queue for Agent↔Viewer communication
|
|
1055
1052
|
const uiCommandQueue = new ui_command_handler_js_1.UICommandQueue();
|
|
@@ -1057,7 +1054,6 @@ async function runAgentLoop(config, options = {}) {
|
|
|
1057
1054
|
const graphHandlerOptions = {
|
|
1058
1055
|
healthService: healthService ?? undefined,
|
|
1059
1056
|
healthCheckService,
|
|
1060
|
-
auditConversation: (job) => messageRouter.auditConversation(job),
|
|
1061
1057
|
sessionsDb: db,
|
|
1062
1058
|
uiCommandQueue,
|
|
1063
1059
|
};
|
|
@@ -1291,7 +1287,72 @@ async function runAgentLoop(config, options = {}) {
|
|
|
1291
1287
|
console.log(`✓ Agent versions seeded (${Object.keys(agents).length} agents)`);
|
|
1292
1288
|
await (0, utilities_js_1.startEmbeddingServerIfAvailable)(messageRouter, sessionStore, graphHandler);
|
|
1293
1289
|
// ── Phase 6: Cron Scheduler ───────────────────────────────────────────────
|
|
1294
|
-
const
|
|
1290
|
+
const backgroundOwnerContext = (0, owner_event_policy_js_1.buildOwnerEventAgentContext)({
|
|
1291
|
+
backend: runtimeBackend,
|
|
1292
|
+
model: config.agent.model,
|
|
1293
|
+
ownerRole,
|
|
1294
|
+
privateConnectorPolicy,
|
|
1295
|
+
});
|
|
1296
|
+
const issueOwnerRuntimeEnvelope = async (channelId, wallSeconds) => {
|
|
1297
|
+
if (!envelopeBootstrap.envelopeAuthority || envelopeBootstrap.metadata.issuance === 'off') {
|
|
1298
|
+
return undefined;
|
|
1299
|
+
}
|
|
1300
|
+
const projectId = (0, reactive_config_js_1.resolveReactiveProjectRoot)(config, process.env);
|
|
1301
|
+
return envelopeBootstrap.envelopeAuthority.buildAndPersist({
|
|
1302
|
+
agent_id: 'mama-owner',
|
|
1303
|
+
instance_id: (0, node_crypto_1.randomUUID)(),
|
|
1304
|
+
source: 'cron',
|
|
1305
|
+
channel_id: channelId,
|
|
1306
|
+
trigger_context: { user_text: `<owner runtime ${channelId} stimulus>` },
|
|
1307
|
+
scope: {
|
|
1308
|
+
project_refs: [{ kind: 'project', id: projectId }],
|
|
1309
|
+
raw_connectors: [
|
|
1310
|
+
...privateConnectorPolicy.projectRawConnectors('owner_console', codeActRawConnectors),
|
|
1311
|
+
],
|
|
1312
|
+
memory_scopes: uniqueMemoryScopes((0, scope_context_js_1.deriveMemoryScopes)({ source: 'operator', channelId, projectId })),
|
|
1313
|
+
allowed_destinations: [],
|
|
1314
|
+
},
|
|
1315
|
+
tier: 1,
|
|
1316
|
+
budget: { wall_seconds: wallSeconds },
|
|
1317
|
+
expires_at: new Date(Date.now() + wallSeconds * 1000 + 30_000).toISOString(),
|
|
1318
|
+
});
|
|
1319
|
+
};
|
|
1320
|
+
const runOwnerStimulus = async (content, channelId) => {
|
|
1321
|
+
const envelope = await issueOwnerRuntimeEnvelope(channelId, 600);
|
|
1322
|
+
if (!envelope)
|
|
1323
|
+
throw new Error(`Owner runtime stimulus ${channelId} requires envelope authority`);
|
|
1324
|
+
return await agentLoop.run(content, {
|
|
1325
|
+
sessionKey: owner_runtime_js_1.OWNER_RUNTIME_SESSION_KEY,
|
|
1326
|
+
source: 'operator',
|
|
1327
|
+
channelId,
|
|
1328
|
+
agentContext: backgroundOwnerContext,
|
|
1329
|
+
sessionPolicyRole: ownerRole,
|
|
1330
|
+
envelope,
|
|
1331
|
+
requestTimeoutMs: 600_000,
|
|
1332
|
+
});
|
|
1333
|
+
};
|
|
1334
|
+
const cronOwnerRunner = {
|
|
1335
|
+
backendType: runtimeBackend,
|
|
1336
|
+
prompt: async (content) => {
|
|
1337
|
+
const result = await runOwnerStimulus(content, 'cron');
|
|
1338
|
+
return {
|
|
1339
|
+
response: result.response,
|
|
1340
|
+
usage: result.totalUsage,
|
|
1341
|
+
session_id: owner_runtime_js_1.OWNER_RUNTIME_SESSION_KEY,
|
|
1342
|
+
};
|
|
1343
|
+
},
|
|
1344
|
+
setSessionId: () => { },
|
|
1345
|
+
setSystemPrompt: () => { },
|
|
1346
|
+
isHealthy: () => true,
|
|
1347
|
+
getMetrics: () => ({
|
|
1348
|
+
requestCount: 0,
|
|
1349
|
+
failureCount: 0,
|
|
1350
|
+
avgLatencyMs: 0,
|
|
1351
|
+
lastRequestAt: null,
|
|
1352
|
+
}),
|
|
1353
|
+
stop: () => { },
|
|
1354
|
+
};
|
|
1355
|
+
const { scheduler, cronWorker, cronEmitter } = (0, scheduler_init_js_1.initCronScheduler)(config, () => cronOwnerRunner);
|
|
1295
1356
|
// ── Phase 7: Gateways ────────────────────────────────────────────────────
|
|
1296
1357
|
const gatewayInit = await (0, gateway_init_js_1.initGateways)(config, messageRouter, toolExecutor, agentLoop, runtimeBackend, db, principalResolver);
|
|
1297
1358
|
const { discordGateway, slackGateway, telegramGateway, gateways } = gatewayInit;
|
|
@@ -1309,44 +1370,15 @@ async function runAgentLoop(config, options = {}) {
|
|
|
1309
1370
|
agentLoop,
|
|
1310
1371
|
cronEmitter,
|
|
1311
1372
|
});
|
|
1312
|
-
// ── Phase 8.5: Delegate tool fallback wiring ─────────────────────────────
|
|
1313
|
-
// If no Discord/Slack handler wired the delegate tool, create standalone
|
|
1314
|
-
// DelegationManager + AgentProcessManager so delegate() works from any path
|
|
1315
|
-
// (Viewer, Telegram, iMessage, Terminal).
|
|
1316
|
-
const fallbackMultiAgentConfig = config.multi_agent;
|
|
1317
|
-
const hasSystemRunAgents = Boolean(fallbackMultiAgentConfig?.agents?.['dashboard-agent'] ||
|
|
1318
|
-
fallbackMultiAgentConfig?.agents?.['wiki-agent']);
|
|
1319
|
-
if (fallbackMultiAgentConfig &&
|
|
1320
|
-
!toolExecutor.getAgentProcessManager() &&
|
|
1321
|
-
(fallbackMultiAgentConfig.enabled || hasSystemRunAgents)) {
|
|
1322
|
-
const { AgentProcessManager } = await import('../../multi-agent/agent-process-manager.js');
|
|
1323
|
-
const pm = new AgentProcessManager(fallbackMultiAgentConfig, buildSystemAgentProcessDefaults(config), {
|
|
1324
|
-
backend: runtimeBackend,
|
|
1325
|
-
model: config.agent.model,
|
|
1326
|
-
effort: config.agent.effort,
|
|
1327
|
-
clineCwd: workspaceRoot,
|
|
1328
|
-
clineCommand: process.env.MAMA_CLINE_COMMAND ?? config.agent.cline_command,
|
|
1329
|
-
clineProvider: config.agent.cline_provider,
|
|
1330
|
-
clineDataDir: config.agent.cline_data_dir,
|
|
1331
|
-
privateConnectorPolicy,
|
|
1332
|
-
});
|
|
1333
|
-
toolExecutor.setAgentProcessManager(pm);
|
|
1334
|
-
agentLoop.setAgentProcessManager(pm);
|
|
1335
|
-
graphHandlerOptions.applyMultiAgentConfig = async (rawConfig) => {
|
|
1336
|
-
const nextConfig = rawConfig;
|
|
1337
|
-
pm.updateConfig(nextConfig);
|
|
1338
|
-
};
|
|
1339
|
-
graphHandlerOptions.restartMultiAgentAgent = async (agentId) => {
|
|
1340
|
-
pm.reloadPersona(agentId);
|
|
1341
|
-
};
|
|
1342
|
-
// The delegate wiring was here. Over the full log history it was wired ZERO times and
|
|
1343
|
-
// its only runtime trace was one call refused by role permission. The process manager
|
|
1344
|
-
// above stays: that one IS wired on every boot (113 so far) and runs the dashboard and
|
|
1345
|
-
// wiki agents.
|
|
1346
|
-
console.log('[start] ✓ System agent process manager wired');
|
|
1347
|
-
}
|
|
1348
1373
|
// ── Phase 9: Heartbeat + Connectors ──────────────────────────────────────
|
|
1349
|
-
const { heartbeatScheduler, tokenKeepAlive, healthWarningInterval } = (0, scheduler_init_js_1.initHeartbeat)(config, agentLoop, discordGateway, scheduler, healthCheckService)
|
|
1374
|
+
const { heartbeatScheduler, tokenKeepAlive, healthWarningInterval } = (0, scheduler_init_js_1.initHeartbeat)(config, agentLoop, discordGateway, scheduler, healthCheckService, async () => {
|
|
1375
|
+
const envelope = await issueOwnerRuntimeEnvelope('heartbeat', 300);
|
|
1376
|
+
return {
|
|
1377
|
+
agentContext: backgroundOwnerContext,
|
|
1378
|
+
sessionPolicyRole: ownerRole,
|
|
1379
|
+
...(envelope ? { envelope } : {}),
|
|
1380
|
+
};
|
|
1381
|
+
});
|
|
1350
1382
|
// M2.4 freshness: the connector sink nudges the trigger loop when a poll indexes new rows. The
|
|
1351
1383
|
// loop is constructed AFTER initConnectors (below), so hand initConnectors a stable forwarder now
|
|
1352
1384
|
// and point it at the loop once it exists. Null until then -> nudge no-ops (no loop = nothing to
|
|
@@ -1668,15 +1700,11 @@ async function runAgentLoop(config, options = {}) {
|
|
|
1668
1700
|
reconcileChannelKey,
|
|
1669
1701
|
privateConnectorPolicy,
|
|
1670
1702
|
});
|
|
1671
|
-
// Worker prompt selects the provider's supported tool path: Claude's
|
|
1672
|
-
// text gateway or Codex's injected native host tools. Both avoid the
|
|
1673
|
-
// spawn-default code-act path, where per-run envelope/capture overrides
|
|
1674
|
-
// cannot reach (shadow-gate §8.2).
|
|
1675
|
-
const { buildWorkerSystemPrompt } = await import('../../operator/worker-run.js');
|
|
1676
1703
|
const workOrderPolicy = buildTurnAgentPolicy(wo.workKind, config.agent.model, runtimeBackend, privateConnectorPolicy, workOrderScope.raw_connectors, ownerRole);
|
|
1677
1704
|
const runOptions = attachWorkOrderAttemptContext({
|
|
1678
|
-
|
|
1705
|
+
gatewayToolsPrompt: workOrderPolicy.gatewayToolsPrompt,
|
|
1679
1706
|
agentContext: workOrderPolicy.agentContext,
|
|
1707
|
+
sessionPolicyRole: ownerRole,
|
|
1680
1708
|
workOrderBriefProjectionPolicy: workOrderPolicy.briefProjectionPolicy,
|
|
1681
1709
|
}, wo.id);
|
|
1682
1710
|
// A temporal run is bound to ONE task on ONE channel, and the packet check
|
|
@@ -1824,7 +1852,6 @@ async function runAgentLoop(config, options = {}) {
|
|
|
1824
1852
|
// connector_event_index) and after mama-core initDB. Read-only: recall/surface/log.
|
|
1825
1853
|
const { isOperatorTriggerLoopEnabled, resolveOperatorReportChatId } = await import('../../operator/runtime-config.js');
|
|
1826
1854
|
if (isOperatorTriggerLoopEnabled(process.env)) {
|
|
1827
|
-
let stopTriggerAgentRuntime;
|
|
1828
1855
|
// Component isolation (PR #119 review): a trigger-loop bootstrap failure (bad import,
|
|
1829
1856
|
// DB permission, registry constructor) must not abort the whole daemon before Phase
|
|
1830
1857
|
// 10/11 - the gateways/viewer/agent serve independently of this optional leg. The
|
|
@@ -1834,7 +1861,6 @@ async function runAgentLoop(config, options = {}) {
|
|
|
1834
1861
|
const { ConnectorDeltaRepo } = await import('../../operator/connector-delta-repo.js');
|
|
1835
1862
|
const { TriggerRegistry } = await import('../../operator/trigger-registry.js');
|
|
1836
1863
|
const { createMamaMemoryPort } = await import('../../operator/mama-memory-port.js');
|
|
1837
|
-
const { createTriggerAgentRuntime } = await import('../../operator/trigger-author.js');
|
|
1838
1864
|
const { reviewTriggerCLI } = await import('../../operator/trigger-review.js');
|
|
1839
1865
|
const { ReportScheduler, FileReportScheduleStore, parseReportHours } = await import('../../operator/report-scheduler.js');
|
|
1840
1866
|
// Set when a report is composed, read when that same report is delivered. Safe
|
|
@@ -1851,10 +1877,9 @@ async function runAgentLoop(config, options = {}) {
|
|
|
1851
1877
|
// Owner-report leg (M1.5): destination chat comes from env (~/.mama/start.sh),
|
|
1852
1878
|
// never source. No chat configured or no telegram gateway -> loop stays read-only.
|
|
1853
1879
|
const reportChatId = resolveOperatorReportChatId(process.env, config.telegram?.allowed_chats);
|
|
1854
|
-
// TG-05/TG-06
|
|
1855
|
-
//
|
|
1856
|
-
//
|
|
1857
|
-
// the coordinator owns every Telegram send.
|
|
1880
|
+
// TG-05/TG-06: one durable production boundary for every report mode.
|
|
1881
|
+
// The delivery ledger reserves exact output and the coordinator owns
|
|
1882
|
+
// every Telegram send; no report text is copied into another model.
|
|
1858
1883
|
let reportDelivery;
|
|
1859
1884
|
const reportTarget = reportChatId && telegramGateway
|
|
1860
1885
|
? { source: 'telegram', channelId: reportChatId }
|
|
@@ -1888,49 +1913,30 @@ async function runAgentLoop(config, options = {}) {
|
|
|
1888
1913
|
const fullReportHours = parseReportHours(process.env.MAMA_TRIGGER_LOOP_FULL_REPORT_HOURS || '');
|
|
1889
1914
|
// Constructed whenever the report SINK exists, even with no scheduled
|
|
1890
1915
|
// hours (empty hours -> shouldFire never fires): on-demand reports
|
|
1891
|
-
//
|
|
1892
|
-
//
|
|
1916
|
+
// API-triggered reports need the persistent anchor state regardless of
|
|
1917
|
+
// whether scheduled hours are configured.
|
|
1893
1918
|
const reportScheduler = reportDelivery
|
|
1894
1919
|
? new ReportScheduler(fullReportHours, new FileReportScheduleStore((0, config_manager_js_1.expandPath)('~/.mama/operator/report-schedule-state.json')))
|
|
1895
1920
|
: undefined;
|
|
1896
|
-
const triggerAgentRuntime = createTriggerAgentRuntime(runtimeBackend, {
|
|
1897
|
-
model: config.agent.model,
|
|
1898
|
-
cwd: workspaceRoot,
|
|
1899
|
-
command: runtimeBackend === 'cline'
|
|
1900
|
-
? (process.env.MAMA_CLINE_COMMAND ?? config.agent.cline_command)
|
|
1901
|
-
: process.env.MAMA_CODEX_COMMAND,
|
|
1902
|
-
provider: config.agent.cline_provider,
|
|
1903
|
-
dataDir: config.agent.cline_data_dir,
|
|
1904
|
-
effort: config.agent.effort,
|
|
1905
|
-
});
|
|
1906
|
-
stopTriggerAgentRuntime = () => triggerAgentRuntime.stop();
|
|
1907
1921
|
const ownerEventEnvelopeAuthority = envelopeBootstrap.envelopeAuthority;
|
|
1908
1922
|
const ownerEventExecution = (0, owner_event_policy_js_1.resolveOwnerEventExecution)({
|
|
1909
1923
|
issuance: envelopeBootstrap.metadata.issuance,
|
|
1910
1924
|
hasAuthority: ownerEventEnvelopeAuthority !== undefined,
|
|
1911
1925
|
});
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
throw new Error('Trello is outside the owner-report read scope');
|
|
1927
|
-
}
|
|
1928
|
-
return (0, query_tools_js_1.getTrelloKanban)({ maxCardsPerList: 100 });
|
|
1929
|
-
},
|
|
1930
|
-
buildProvenanceLookup: provenance_lookup_js_1.buildProvenanceLookup,
|
|
1931
|
-
correlate: external_correlation_js_1.correlateTasksWithExternalItems,
|
|
1932
|
-
readChanges: (_scope, input, nowMs) => (0, changes_projection_js_1.readChanges)(taskLedger, input, nowMs),
|
|
1933
|
-
now: Date.now,
|
|
1926
|
+
const ownerMaintenanceAsk = async (prompt) => {
|
|
1927
|
+
const envelope = await issueOwnerRuntimeEnvelope('trigger-maintenance', 600);
|
|
1928
|
+
if (!envelope)
|
|
1929
|
+
throw new Error('Owner maintenance requires envelope authority');
|
|
1930
|
+
const result = await agentLoop.run(prompt, {
|
|
1931
|
+
sessionKey: owner_runtime_js_1.OWNER_RUNTIME_SESSION_KEY,
|
|
1932
|
+
source: 'operator',
|
|
1933
|
+
channelId: 'trigger-maintenance',
|
|
1934
|
+
agentContext: backgroundOwnerContext,
|
|
1935
|
+
sessionPolicyRole: ownerRole,
|
|
1936
|
+
envelope,
|
|
1937
|
+
requestTimeoutMs: 600_000,
|
|
1938
|
+
});
|
|
1939
|
+
return result.response;
|
|
1934
1940
|
};
|
|
1935
1941
|
const triggerLoop = new OperatorTriggerLoop({
|
|
1936
1942
|
backend: runtimeBackend,
|
|
@@ -1938,31 +1944,30 @@ async function runAgentLoop(config, options = {}) {
|
|
|
1938
1944
|
memory: createMamaMemoryPort(),
|
|
1939
1945
|
registry: triggerRegistry,
|
|
1940
1946
|
...(ownerEventExecution.enabled ? { ownerEventInbox } : {}),
|
|
1941
|
-
askAgent:
|
|
1942
|
-
//
|
|
1943
|
-
//
|
|
1944
|
-
//
|
|
1945
|
-
// Full reports run in one fresh, tool-free persona turn. Current state is compiled and
|
|
1946
|
-
// persisted by the host before this call; digest composition remains on the same persona.
|
|
1947
|
+
askAgent: ownerMaintenanceAsk,
|
|
1948
|
+
// TG-03/TG-04/TG-05: a report is another stimulus for the standing
|
|
1949
|
+
// owner subject. It keeps the same backend thread and progressive tool
|
|
1950
|
+
// catalog while the current envelope narrows effects for this delivery.
|
|
1947
1951
|
reportAsk: createPersonaReportAsk({
|
|
1948
1952
|
run: async (prompt, sourceMessageRef) => {
|
|
1949
|
-
const reportAgentPolicy = buildOperatorReportAgentPolicy(config.agent.model, runtimeBackend, privateConnectorPolicy);
|
|
1953
|
+
const reportAgentPolicy = buildOperatorReportAgentPolicy(config.agent.model, runtimeBackend, privateConnectorPolicy, ownerRole);
|
|
1954
|
+
const envelope = await issueOwnerRuntimeEnvelope('report', 600);
|
|
1955
|
+
if (!envelope)
|
|
1956
|
+
throw new Error('Owner report requires envelope authority');
|
|
1950
1957
|
const result = await agentLoop.runWithContent([{ type: 'text', text: prompt }], {
|
|
1951
|
-
sessionKey:
|
|
1958
|
+
sessionKey: owner_runtime_js_1.OWNER_RUNTIME_SESSION_KEY,
|
|
1952
1959
|
source: 'operator',
|
|
1953
1960
|
channelId: 'report',
|
|
1954
|
-
//
|
|
1955
|
-
//
|
|
1956
|
-
// gather no matter what the prompt instructs (roleAllowsOuterCodeAct
|
|
1957
|
-
// fails closed on an absent role - agent-loop.ts). Same built-in
|
|
1958
|
-
// least-privilege treatment the Stage-2 workers get.
|
|
1961
|
+
// The current report role narrows effect authority; the stable
|
|
1962
|
+
// sessionPolicyRole keeps the owner thread compatible.
|
|
1959
1963
|
agentContext: reportAgentPolicy.agentContext,
|
|
1964
|
+
sessionPolicyRole: ownerRole,
|
|
1960
1965
|
gatewayToolsPrompt: reportAgentPolicy.gatewayToolsPrompt,
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
+
envelope,
|
|
1967
|
+
requestTimeoutMs: 600_000,
|
|
1968
|
+
ownerJournalPrompt: sourceMessageRef
|
|
1969
|
+
? `Report stimulus: ${sourceMessageRef}`
|
|
1970
|
+
: prompt,
|
|
1966
1971
|
...(sourceMessageRef ? { sourceMessageRef } : {}),
|
|
1967
1972
|
});
|
|
1968
1973
|
return {
|
|
@@ -1976,28 +1981,28 @@ async function runAgentLoop(config, options = {}) {
|
|
|
1976
1981
|
...(result.modelRunProvenance === undefined
|
|
1977
1982
|
? {}
|
|
1978
1983
|
: { modelRunProvenance: result.modelRunProvenance }),
|
|
1984
|
+
...(result.ownerJournalProvenance === undefined
|
|
1985
|
+
? {}
|
|
1986
|
+
: { ownerJournalProvenance: result.ownerJournalProvenance }),
|
|
1979
1987
|
};
|
|
1980
1988
|
},
|
|
1981
1989
|
log: (line) => console.log(line),
|
|
1982
1990
|
onRunProvenance: (provenance) => {
|
|
1983
1991
|
lastReportProvenance = provenance;
|
|
1984
1992
|
},
|
|
1993
|
+
onRecoveryFailure: () => {
|
|
1994
|
+
recordIssue({
|
|
1995
|
+
surface: 'delivery',
|
|
1996
|
+
signature: 'journal_commit_failed',
|
|
1997
|
+
severity: 'error',
|
|
1998
|
+
error: 'Report completed but owner runtime recovery journal did not persist',
|
|
1999
|
+
});
|
|
2000
|
+
},
|
|
1985
2001
|
}),
|
|
1986
|
-
review: (trigger, context) => reviewTriggerCLI(trigger, context,
|
|
2002
|
+
review: (trigger, context) => reviewTriggerCLI(trigger, context, ownerMaintenanceAsk),
|
|
1987
2003
|
reportDelivery,
|
|
1988
2004
|
reportTarget,
|
|
1989
2005
|
reportScheduler,
|
|
1990
|
-
fullReportReadScope: (() => {
|
|
1991
|
-
const projectId = (0, reactive_config_js_1.resolveReactiveProjectRoot)(config, process.env);
|
|
1992
|
-
return {
|
|
1993
|
-
projectRefs: [{ kind: 'project', id: projectId }],
|
|
1994
|
-
memoryScopes: uniqueMemoryScopes((0, scope_context_js_1.deriveMemoryScopes)({ source: 'operator', channelId: 'report', projectId })),
|
|
1995
|
-
rawConnectors: [
|
|
1996
|
-
...privateConnectorPolicy.projectRawConnectors('operator-report', codeActRawConnectors),
|
|
1997
|
-
],
|
|
1998
|
-
};
|
|
1999
|
-
})(),
|
|
2000
|
-
compileFullReportContext: async ({ readScope, windowEvidence, since }) => (0, report_context_js_1.compileOwnerReportContext)({ readScope, windowEvidence, since }, reportContextDeps),
|
|
2001
2006
|
// TG-06: composition supplies provenance immediately to the prepared
|
|
2002
2007
|
// delivery; this callback receives that durable artifact only after send success.
|
|
2003
2008
|
fullReportProvenance: () => lastReportProvenance,
|
|
@@ -2038,14 +2043,11 @@ async function runAgentLoop(config, options = {}) {
|
|
|
2038
2043
|
}
|
|
2039
2044
|
const stopTriggerLoop = triggerLoop.start();
|
|
2040
2045
|
stopOwnerEventRuntime = async () => {
|
|
2041
|
-
await
|
|
2046
|
+
await stopTriggerLoop();
|
|
2042
2047
|
};
|
|
2043
2048
|
// M2.4: point the connector sink's forwarder at this loop now that it exists.
|
|
2044
2049
|
triggerLoopNudge.current = () => triggerLoop.nudge();
|
|
2045
2050
|
triggerLoopFullReport.current = () => triggerLoop.startFullReport();
|
|
2046
|
-
// S1-T3: owner-intent forwarder - report_request routes to the SAME
|
|
2047
|
-
// report machinery (fresh session, delta anchor, consume semantics).
|
|
2048
|
-
toolExecutor.setReportRequestHandler(() => triggerLoop.startFullReport());
|
|
2049
2051
|
if (ownerEventExecution.enabled && ownerEventEnvelopeAuthority) {
|
|
2050
2052
|
// MAMA itself owns connector events. This is the same AgentLoop and
|
|
2051
2053
|
// owner operating policy as the owner console, on a durable per-channel
|
|
@@ -2099,17 +2101,11 @@ async function runAgentLoop(config, options = {}) {
|
|
|
2099
2101
|
inbox: ownerEventInbox,
|
|
2100
2102
|
runner: agentLoop,
|
|
2101
2103
|
agentContext: ownerEventContext,
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
channelKey: batch.channelKey,
|
|
2105
|
-
eventIds: batch.eventIds,
|
|
2106
|
-
since: new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString(),
|
|
2107
|
-
}, reportContextDeps)),
|
|
2108
|
-
buildPrompt: async (batch, packet) => {
|
|
2104
|
+
ownerRuntimeRole: ownerRole,
|
|
2105
|
+
buildPrompt: async (batch) => {
|
|
2109
2106
|
const readScope = ownerEventReadScope(batch);
|
|
2110
2107
|
return (0, owner_event_prompt_js_1.buildOwnerEventPrompt)({
|
|
2111
2108
|
batch,
|
|
2112
|
-
packet,
|
|
2113
2109
|
learning: await buildLearningBlockFor('event', readScope.memoryScopes, batch.lines.join('\n').slice(0, 500)),
|
|
2114
2110
|
ownerBrief: (0, console_brief_js_1.projectConsoleBriefForPrompt)((0, console_brief_js_1.loadConsoleBrief)(), privateConnectorPolicy),
|
|
2115
2111
|
skillContent: await ownerEventPromptEnhancer.detectSkillMatch(batch.lines.join('\n')),
|
|
@@ -2166,7 +2162,7 @@ async function runAgentLoop(config, options = {}) {
|
|
|
2166
2162
|
// operator DB closes.
|
|
2167
2163
|
if (ownerEventTickPromise)
|
|
2168
2164
|
await ownerEventTickPromise;
|
|
2169
|
-
await
|
|
2165
|
+
await stopTriggerLoop();
|
|
2170
2166
|
};
|
|
2171
2167
|
}
|
|
2172
2168
|
else {
|
|
@@ -2180,7 +2176,6 @@ async function runAgentLoop(config, options = {}) {
|
|
|
2180
2176
|
catch (error) {
|
|
2181
2177
|
await stopOwnerEventRuntime?.().catch(() => { });
|
|
2182
2178
|
stopOwnerEventRuntime = null;
|
|
2183
|
-
await stopTriggerAgentRuntime?.().catch(() => { });
|
|
2184
2179
|
console.error('[trigger-loop] FAILED to start - daemon continues WITHOUT the trigger loop. Fix and restart:', error);
|
|
2185
2180
|
}
|
|
2186
2181
|
}
|
|
@@ -2193,13 +2188,13 @@ async function runAgentLoop(config, options = {}) {
|
|
|
2193
2188
|
healthCheckService,
|
|
2194
2189
|
rawStore: rawStoreForApi,
|
|
2195
2190
|
enabledConnectors: enabledConnectorNames,
|
|
2196
|
-
agentLoop,
|
|
2197
2191
|
getAdapter,
|
|
2198
2192
|
envelopeMetadata: envelopeBootstrap.metadata,
|
|
2199
2193
|
envelopeAuthority: envelopeBootstrap.envelopeAuthority,
|
|
2200
2194
|
contextCompileService,
|
|
2201
2195
|
connectorConfigLoadResult,
|
|
2202
2196
|
privateConnectorPolicy,
|
|
2197
|
+
runOwnerStimulus,
|
|
2203
2198
|
});
|
|
2204
2199
|
const apiRoutesHandle = await (0, api_routes_init_js_1.registerApiRoutes)({
|
|
2205
2200
|
config,
|
|
@@ -2209,7 +2204,6 @@ async function runAgentLoop(config, options = {}) {
|
|
|
2209
2204
|
mamaApi,
|
|
2210
2205
|
messageRouter,
|
|
2211
2206
|
reportContextStore,
|
|
2212
|
-
agentLoop,
|
|
2213
2207
|
toolExecutor,
|
|
2214
2208
|
discordGateway,
|
|
2215
2209
|
slackGateway,
|
|
@@ -2251,7 +2245,6 @@ async function runAgentLoop(config, options = {}) {
|
|
|
2251
2245
|
gateways,
|
|
2252
2246
|
pluginLoader,
|
|
2253
2247
|
agentLoop,
|
|
2254
|
-
memoryAgentLoop,
|
|
2255
2248
|
stopExtraction,
|
|
2256
2249
|
sessionStore,
|
|
2257
2250
|
db,
|