@jungjaehoon/mama-os 0.20.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/dist/agent/agent-loop.d.ts +2 -1
- package/dist/agent/agent-loop.d.ts.map +1 -1
- package/dist/agent/agent-loop.js +65 -19
- package/dist/agent/agent-loop.js.map +1 -1
- package/dist/agent/claude-cli-wrapper.d.ts.map +1 -1
- package/dist/agent/claude-cli-wrapper.js +6 -2
- package/dist/agent/claude-cli-wrapper.js.map +1 -1
- package/dist/agent/cli-arg-redaction.d.ts +2 -0
- package/dist/agent/cli-arg-redaction.d.ts.map +1 -0
- package/dist/agent/cli-arg-redaction.js +18 -0
- package/dist/agent/cli-arg-redaction.js.map +1 -0
- package/dist/agent/code-act/constants.d.ts +1 -1
- package/dist/agent/code-act/constants.d.ts.map +1 -1
- package/dist/agent/code-act/constants.js +24 -3
- package/dist/agent/code-act/constants.js.map +1 -1
- package/dist/agent/code-act/host-bridge.d.ts +2 -0
- package/dist/agent/code-act/host-bridge.d.ts.map +1 -1
- package/dist/agent/code-act/host-bridge.js +43 -7
- package/dist/agent/code-act/host-bridge.js.map +1 -1
- package/dist/agent/code-act/type-definition-generator.d.ts +2 -2
- package/dist/agent/code-act/type-definition-generator.d.ts.map +1 -1
- package/dist/agent/code-act/type-definition-generator.js +29 -4
- package/dist/agent/code-act/type-definition-generator.js.map +1 -1
- package/dist/agent/codex-home.d.ts +1 -1
- package/dist/agent/codex-home.d.ts.map +1 -1
- package/dist/agent/codex-home.js +43 -1
- package/dist/agent/codex-home.js.map +1 -1
- package/dist/agent/codex-mcp-process.d.ts +2 -0
- package/dist/agent/codex-mcp-process.d.ts.map +1 -1
- package/dist/agent/codex-mcp-process.js +1 -1
- package/dist/agent/codex-mcp-process.js.map +1 -1
- package/dist/agent/context-compile-service.d.ts +47 -0
- package/dist/agent/context-compile-service.d.ts.map +1 -0
- package/dist/agent/context-compile-service.js +435 -0
- package/dist/agent/context-compile-service.js.map +1 -0
- package/dist/agent/gateway-tool-executor.d.ts +16 -11
- package/dist/agent/gateway-tool-executor.d.ts.map +1 -1
- package/dist/agent/gateway-tool-executor.js +539 -109
- package/dist/agent/gateway-tool-executor.js.map +1 -1
- package/dist/agent/gateway-tools.md +4 -3
- package/dist/agent/mama-tool-handlers.d.ts.map +1 -1
- package/dist/agent/mama-tool-handlers.js +37 -1
- package/dist/agent/mama-tool-handlers.js.map +1 -1
- package/dist/agent/managed-agent-runtime-sync.d.ts.map +1 -1
- package/dist/agent/managed-agent-runtime-sync.js +2 -4
- package/dist/agent/managed-agent-runtime-sync.js.map +1 -1
- package/dist/agent/managed-agent-validation.d.ts.map +1 -1
- package/dist/agent/managed-agent-validation.js +2 -1
- package/dist/agent/managed-agent-validation.js.map +1 -1
- package/dist/agent/os-agent-capabilities.md +13 -12
- package/dist/agent/persistent-cli-process.d.ts +1 -0
- package/dist/agent/persistent-cli-process.d.ts.map +1 -1
- package/dist/agent/persistent-cli-process.js +6 -1
- package/dist/agent/persistent-cli-process.js.map +1 -1
- package/dist/agent/tool-registry.d.ts.map +1 -1
- package/dist/agent/tool-registry.js +10 -2
- package/dist/agent/tool-registry.js.map +1 -1
- package/dist/agent/types.d.ts +30 -5
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/api/agent-context-handler.d.ts +10 -0
- package/dist/api/agent-context-handler.d.ts.map +1 -0
- package/dist/api/agent-context-handler.js +216 -0
- package/dist/api/agent-context-handler.js.map +1 -0
- package/dist/api/agent-handler.d.ts +2 -0
- package/dist/api/agent-handler.d.ts.map +1 -1
- package/dist/api/agent-handler.js +14 -7
- package/dist/api/agent-handler.js.map +1 -1
- package/dist/api/graph-api-types.d.ts +6 -1
- package/dist/api/graph-api-types.d.ts.map +1 -1
- package/dist/api/graph-api.d.ts +2 -1
- package/dist/api/graph-api.d.ts.map +1 -1
- package/dist/api/graph-api.js +193 -11
- package/dist/api/graph-api.js.map +1 -1
- package/dist/api/index.d.ts +11 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +13 -2
- package/dist/api/index.js.map +1 -1
- package/dist/api/intelligence-handler.d.ts +17 -6
- package/dist/api/intelligence-handler.d.ts.map +1 -1
- package/dist/api/intelligence-handler.js +59 -1
- package/dist/api/intelligence-handler.js.map +1 -1
- package/dist/api/operator-handler.d.ts +17 -0
- package/dist/api/operator-handler.d.ts.map +1 -0
- package/dist/api/operator-handler.js +88 -0
- package/dist/api/operator-handler.js.map +1 -0
- package/dist/api/report-handler.d.ts +7 -0
- package/dist/api/report-handler.d.ts.map +1 -1
- package/dist/api/report-handler.js +30 -0
- package/dist/api/report-handler.js.map +1 -1
- package/dist/api/report-persistence.d.ts +17 -0
- package/dist/api/report-persistence.d.ts.map +1 -0
- package/dist/api/report-persistence.js +91 -0
- package/dist/api/report-persistence.js.map +1 -0
- package/dist/cli/commands/start.d.ts +45 -0
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +610 -197
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/config/config-manager.d.ts.map +1 -1
- package/dist/cli/config/config-manager.js +171 -4
- package/dist/cli/config/config-manager.js.map +1 -1
- package/dist/cli/config/types.d.ts +25 -5
- package/dist/cli/config/types.d.ts.map +1 -1
- package/dist/cli/config/types.js +5 -0
- package/dist/cli/config/types.js.map +1 -1
- package/dist/cli/runtime/agent-loop-init.d.ts +3 -0
- package/dist/cli/runtime/agent-loop-init.d.ts.map +1 -1
- package/dist/cli/runtime/agent-loop-init.js +2 -0
- package/dist/cli/runtime/agent-loop-init.js.map +1 -1
- package/dist/cli/runtime/api-routes-init.d.ts.map +1 -1
- package/dist/cli/runtime/api-routes-init.js +396 -259
- package/dist/cli/runtime/api-routes-init.js.map +1 -1
- package/dist/cli/runtime/api-server-init.d.ts +2 -0
- package/dist/cli/runtime/api-server-init.d.ts.map +1 -1
- package/dist/cli/runtime/api-server-init.js +19 -8
- package/dist/cli/runtime/api-server-init.js.map +1 -1
- package/dist/cli/runtime/connector-init.d.ts +26 -7
- package/dist/cli/runtime/connector-init.d.ts.map +1 -1
- package/dist/cli/runtime/connector-init.js +79 -16
- 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 +8 -2
- 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.map +1 -1
- package/dist/cli/runtime/message-router-config.d.ts +4 -0
- package/dist/cli/runtime/message-router-config.d.ts.map +1 -0
- package/dist/cli/runtime/message-router-config.js +11 -0
- package/dist/cli/runtime/message-router-config.js.map +1 -0
- package/dist/cli/runtime/scheduler-init.d.ts.map +1 -1
- package/dist/cli/runtime/scheduler-init.js +12 -12
- package/dist/cli/runtime/scheduler-init.js.map +1 -1
- package/dist/cli/runtime/utilities.js +2 -2
- package/dist/cli/runtime/utilities.js.map +1 -1
- package/dist/connectors/framework/polling-scheduler.d.ts.map +1 -1
- package/dist/connectors/framework/polling-scheduler.js +101 -5
- package/dist/connectors/framework/polling-scheduler.js.map +1 -1
- package/dist/connectors/kagemusha/query-tools.d.ts.map +1 -1
- package/dist/connectors/kagemusha/query-tools.js +14 -3
- package/dist/connectors/kagemusha/query-tools.js.map +1 -1
- package/dist/db/agent-store.d.ts.map +1 -1
- package/dist/db/agent-store.js +10 -3
- package/dist/db/agent-store.js.map +1 -1
- package/dist/db/migrations/wiki-artifacts.d.ts +3 -0
- package/dist/db/migrations/wiki-artifacts.d.ts.map +1 -0
- package/dist/db/migrations/wiki-artifacts.js +24 -0
- package/dist/db/migrations/wiki-artifacts.js.map +1 -0
- package/dist/envelope/enforcer.d.ts.map +1 -1
- package/dist/envelope/enforcer.js +48 -4
- package/dist/envelope/enforcer.js.map +1 -1
- package/dist/envelope/key-provider.d.ts +1 -0
- package/dist/envelope/key-provider.d.ts.map +1 -1
- package/dist/envelope/key-provider.js +86 -0
- package/dist/envelope/key-provider.js.map +1 -1
- package/dist/gateways/message-router.d.ts.map +1 -1
- package/dist/gateways/message-router.js +15 -3
- package/dist/gateways/message-router.js.map +1 -1
- package/dist/gateways/types.d.ts +5 -1
- package/dist/gateways/types.d.ts.map +1 -1
- package/dist/mcp/code-act-server.js +50 -7
- package/dist/mcp/code-act-server.js.map +1 -1
- package/dist/memory/raw-backed-memory-ingest.d.ts +26 -0
- package/dist/memory/raw-backed-memory-ingest.d.ts.map +1 -0
- package/dist/memory/raw-backed-memory-ingest.js +214 -0
- package/dist/memory/raw-backed-memory-ingest.js.map +1 -0
- package/dist/memory/scope-context.js +1 -1
- package/dist/multi-agent/agent-event-bus.d.ts +10 -0
- package/dist/multi-agent/agent-event-bus.d.ts.map +1 -1
- package/dist/multi-agent/agent-event-bus.js +34 -0
- package/dist/multi-agent/agent-event-bus.js.map +1 -1
- package/dist/multi-agent/agent-process-manager.d.ts +3 -0
- package/dist/multi-agent/agent-process-manager.d.ts.map +1 -1
- package/dist/multi-agent/agent-process-manager.js +118 -13
- package/dist/multi-agent/agent-process-manager.js.map +1 -1
- package/dist/multi-agent/conductor-persona.js +2 -2
- package/dist/multi-agent/dashboard-agent-persona.d.ts +6 -2
- package/dist/multi-agent/dashboard-agent-persona.d.ts.map +1 -1
- package/dist/multi-agent/dashboard-agent-persona.js +57 -30
- package/dist/multi-agent/dashboard-agent-persona.js.map +1 -1
- package/dist/multi-agent/memory-agent-persona.d.ts +1 -1
- package/dist/multi-agent/memory-agent-persona.d.ts.map +1 -1
- package/dist/multi-agent/memory-agent-persona.js +25 -4
- package/dist/multi-agent/memory-agent-persona.js.map +1 -1
- package/dist/multi-agent/runtime-process.d.ts +1 -0
- package/dist/multi-agent/runtime-process.d.ts.map +1 -1
- package/dist/multi-agent/runtime-process.js +1 -0
- package/dist/multi-agent/runtime-process.js.map +1 -1
- package/dist/multi-agent/types.d.ts +14 -4
- package/dist/multi-agent/types.d.ts.map +1 -1
- package/dist/multi-agent/types.js.map +1 -1
- package/dist/multi-agent/wiki-agent-persona.d.ts +7 -1
- package/dist/multi-agent/wiki-agent-persona.d.ts.map +1 -1
- package/dist/multi-agent/wiki-agent-persona.js +83 -61
- package/dist/multi-agent/wiki-agent-persona.js.map +1 -1
- package/dist/multi-agent/workflow-types.d.ts +1 -1
- package/dist/multi-agent/workflow-types.d.ts.map +1 -1
- package/dist/operator/board-slot-instructions.d.ts +18 -0
- package/dist/operator/board-slot-instructions.d.ts.map +1 -0
- package/dist/operator/board-slot-instructions.js +52 -0
- package/dist/operator/board-slot-instructions.js.map +1 -0
- package/dist/operator/connector-delta-repo.d.ts +33 -0
- package/dist/operator/connector-delta-repo.d.ts.map +1 -0
- package/dist/operator/connector-delta-repo.js +0 -0
- package/dist/operator/connector-delta-repo.js.map +1 -0
- package/dist/operator/mama-memory-port.d.ts +13 -0
- package/dist/operator/mama-memory-port.d.ts.map +1 -0
- package/dist/operator/mama-memory-port.js +35 -0
- package/dist/operator/mama-memory-port.js.map +1 -0
- package/dist/operator/operator-interfaces.d.ts +136 -0
- package/dist/operator/operator-interfaces.d.ts.map +1 -0
- package/dist/operator/operator-interfaces.js +15 -0
- package/dist/operator/operator-interfaces.js.map +1 -0
- package/dist/operator/operator-trigger-loop.d.ts +106 -0
- package/dist/operator/operator-trigger-loop.d.ts.map +1 -0
- package/dist/operator/operator-trigger-loop.js +228 -0
- package/dist/operator/operator-trigger-loop.js.map +1 -0
- package/dist/operator/report-run.d.ts +78 -0
- package/dist/operator/report-run.d.ts.map +1 -0
- package/dist/operator/report-run.js +141 -0
- package/dist/operator/report-run.js.map +1 -0
- package/dist/operator/report-scheduler.d.ts +43 -0
- package/dist/operator/report-scheduler.d.ts.map +1 -0
- package/dist/operator/report-scheduler.js +87 -0
- package/dist/operator/report-scheduler.js.map +1 -0
- package/dist/operator/situation-report.d.ts +86 -0
- package/dist/operator/situation-report.d.ts.map +1 -0
- package/dist/operator/situation-report.js +211 -0
- package/dist/operator/situation-report.js.map +1 -0
- package/dist/operator/trigger-author.d.ts +45 -0
- package/dist/operator/trigger-author.d.ts.map +1 -0
- package/dist/operator/trigger-author.js +217 -0
- package/dist/operator/trigger-author.js.map +1 -0
- package/dist/operator/trigger-evolve.d.ts +31 -0
- package/dist/operator/trigger-evolve.d.ts.map +1 -0
- package/dist/operator/trigger-evolve.js +51 -0
- package/dist/operator/trigger-evolve.js.map +1 -0
- package/dist/operator/trigger-fire.d.ts +29 -0
- package/dist/operator/trigger-fire.d.ts.map +1 -0
- package/dist/operator/trigger-fire.js +41 -0
- package/dist/operator/trigger-fire.js.map +1 -0
- package/dist/operator/trigger-matcher.d.ts +19 -0
- package/dist/operator/trigger-matcher.d.ts.map +1 -0
- package/dist/operator/trigger-matcher.js +61 -0
- package/dist/operator/trigger-matcher.js.map +1 -0
- package/dist/operator/trigger-registry.d.ts +36 -0
- package/dist/operator/trigger-registry.d.ts.map +1 -0
- package/dist/operator/trigger-registry.js +135 -0
- package/dist/operator/trigger-registry.js.map +1 -0
- package/dist/operator/trigger-review.d.ts +23 -0
- package/dist/operator/trigger-review.d.ts.map +1 -0
- package/dist/operator/trigger-review.js +127 -0
- package/dist/operator/trigger-review.js.map +1 -0
- package/dist/operator/trigger-types.d.ts +84 -0
- package/dist/operator/trigger-types.d.ts.map +1 -0
- package/dist/operator/trigger-types.js +14 -0
- package/dist/operator/trigger-types.js.map +1 -0
- package/dist/scheduler/cron-worker.d.ts.map +1 -1
- package/dist/scheduler/cron-worker.js +3 -1
- package/dist/scheduler/cron-worker.js.map +1 -1
- package/dist/security/security-monitor.d.ts.map +1 -1
- package/dist/security/security-monitor.js +1 -0
- package/dist/security/security-monitor.js.map +1 -1
- package/dist/wiki/obsidian-writer.d.ts +1 -1
- package/dist/wiki/obsidian-writer.d.ts.map +1 -1
- package/dist/wiki/obsidian-writer.js +67 -27
- package/dist/wiki/obsidian-writer.js.map +1 -1
- package/dist/wiki/path-safety.d.ts +2 -0
- package/dist/wiki/path-safety.d.ts.map +1 -0
- package/dist/wiki/path-safety.js +40 -0
- package/dist/wiki/path-safety.js.map +1 -0
- package/dist/wiki/types.d.ts +4 -2
- package/dist/wiki/types.d.ts.map +1 -1
- package/dist/wiki/types.js +1 -1
- package/dist/wiki/types.js.map +1 -1
- package/dist/wiki-artifacts/normalization.d.ts +8 -0
- package/dist/wiki-artifacts/normalization.d.ts.map +1 -0
- package/dist/wiki-artifacts/normalization.js +41 -0
- package/dist/wiki-artifacts/normalization.js.map +1 -0
- package/dist/wiki-artifacts/types.d.ts +52 -0
- package/dist/wiki-artifacts/types.d.ts.map +1 -0
- package/dist/wiki-artifacts/types.js +3 -0
- package/dist/wiki-artifacts/types.js.map +1 -0
- package/dist/wiki-artifacts/wiki-publish-adapter.d.ts +14 -0
- package/dist/wiki-artifacts/wiki-publish-adapter.d.ts.map +1 -0
- package/dist/wiki-artifacts/wiki-publish-adapter.js +71 -0
- package/dist/wiki-artifacts/wiki-publish-adapter.js.map +1 -0
- package/package.json +6 -4
- package/public/ui/assets/index-BDsaQNGd.js +62 -0
- package/public/ui/assets/index-C4URnm_X.css +1 -0
- package/public/ui/index.html +13 -0
- package/public/viewer/js/utils/api.js +2 -2
- package/public/viewer/src/utils/api.ts +9 -2
- package/public/viewer/sw.js +1 -1
- package/public/viewer/viewer.html +6 -0
package/dist/api/graph-api.js
CHANGED
|
@@ -16,6 +16,7 @@ exports.mapDecisionRowToGraphNode = mapDecisionRowToGraphNode;
|
|
|
16
16
|
exports.parseGraphLimit = parseGraphLimit;
|
|
17
17
|
exports.buildGraphMeta = buildGraphMeta;
|
|
18
18
|
exports.validateConfigUpdate = validateConfigUpdate;
|
|
19
|
+
exports.migrateLegacyManagedBackends = migrateLegacyManagedBackends;
|
|
19
20
|
exports.getAllNodes = getAllNodes;
|
|
20
21
|
exports.getAllEdges = getAllEdges;
|
|
21
22
|
exports.getAllCheckpoints = getAllCheckpoints;
|
|
@@ -75,6 +76,43 @@ const SW_JS_PATH = path_1.default.join(VIEWER_DIR, 'sw.js');
|
|
|
75
76
|
const MANIFEST_JSON_PATH = path_1.default.join(VIEWER_DIR, 'manifest.json');
|
|
76
77
|
const VIEWER_ICON_DIR = path_1.default.join(VIEWER_DIR, 'icons');
|
|
77
78
|
const VIEWER_FAVICON_PATH = path_1.default.join(VIEWER_DIR, '..', 'favicon.ico');
|
|
79
|
+
// Operator viewer SPA (built from ui/ into public/ui/). Resolved per request so
|
|
80
|
+
// the MAMA_UI_DIR override works for tests without module-load ordering games.
|
|
81
|
+
function getUiDirectory() {
|
|
82
|
+
if (process.env.MAMA_UI_DIR) {
|
|
83
|
+
// resolve() drops trailing slashes; without it the `uiRoot + path.sep`
|
|
84
|
+
// traversal guard below would 404 every request for '/foo/bar/'-style values.
|
|
85
|
+
return path_1.default.resolve(process.env.MAMA_UI_DIR);
|
|
86
|
+
}
|
|
87
|
+
const candidateDirs = [
|
|
88
|
+
path_1.default.join(process.cwd(), 'public', 'ui'),
|
|
89
|
+
path_1.default.join(PACKAGE_ROOT_DIR, 'public', 'ui'),
|
|
90
|
+
path_1.default.join(__dirname, '../../public/ui'),
|
|
91
|
+
path_1.default.join(__dirname, '../../../public/ui'),
|
|
92
|
+
path_1.default.join(process.cwd(), 'packages', 'standalone', 'public', 'ui'),
|
|
93
|
+
];
|
|
94
|
+
for (const candidate of candidateDirs) {
|
|
95
|
+
if (fs_1.default.existsSync(candidate) && fs_1.default.statSync(candidate).isDirectory()) {
|
|
96
|
+
return candidate;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return path_1.default.join(process.cwd(), 'public', 'ui');
|
|
100
|
+
}
|
|
101
|
+
// serveStaticFile requires an explicit content type and only reads bytes (not
|
|
102
|
+
// utf-8) for image/* or octet-stream -- fonts map to octet-stream for integrity.
|
|
103
|
+
const UI_STATIC_MIME = {
|
|
104
|
+
'.html': 'text/html',
|
|
105
|
+
'.js': 'text/javascript',
|
|
106
|
+
'.css': 'text/css',
|
|
107
|
+
'.json': 'application/json',
|
|
108
|
+
'.svg': 'image/svg+xml',
|
|
109
|
+
'.png': 'image/png',
|
|
110
|
+
'.ico': 'image/x-icon',
|
|
111
|
+
'.woff2': 'application/octet-stream',
|
|
112
|
+
};
|
|
113
|
+
// Agent-authored slot HTML renders inside this SPA. Two independent XSS layers:
|
|
114
|
+
// DOMPurify at render (ui/src/api/report.ts) + this CSP on the document.
|
|
115
|
+
const UI_CSP = "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self'";
|
|
78
116
|
const DEFAULT_GRAPH_LIMIT = 300;
|
|
79
117
|
exports.DEFAULT_GRAPH_LIMIT = DEFAULT_GRAPH_LIMIT;
|
|
80
118
|
const MAX_GRAPH_LIMIT = 2000;
|
|
@@ -87,7 +125,7 @@ const codeActRateBuckets = new Map();
|
|
|
87
125
|
// Model pattern helpers (used in multiple validation functions)
|
|
88
126
|
const isClaudeModel = (model) => /^claude-/i.test(model);
|
|
89
127
|
const isCodexModel = (model) => /^(gpt-|o\d|codex)/i.test(model);
|
|
90
|
-
const supportedManagedBackends = ['claude', 'codex', 'codex-mcp'
|
|
128
|
+
const supportedManagedBackends = ['claude', 'codex', 'codex-mcp'];
|
|
91
129
|
const isCodexFamilyBackend = (backend) => backend === 'codex' || backend === 'codex-mcp';
|
|
92
130
|
const VALIDATION_TRIGGER_TYPES = new Set([
|
|
93
131
|
'agent_test',
|
|
@@ -97,6 +135,80 @@ const VALIDATION_TRIGGER_TYPES = new Set([
|
|
|
97
135
|
]);
|
|
98
136
|
const isOpus46Model = (model) => /^claude-opus-4-6(?:$|-)/i.test(model) || model.toLowerCase() === 'claude-opus-4-latest';
|
|
99
137
|
const VALID_EFFORT_LEVELS = new Set(['low', 'medium', 'high', 'max']);
|
|
138
|
+
function normalizeLegacyManagedBackend(backend, configPath) {
|
|
139
|
+
if (typeof backend === 'string' && backend.toLowerCase() === 'gemini') {
|
|
140
|
+
console.warn(`[GraphAPI] Deprecated backend "gemini" at ${configPath}; using "claude" for compatibility.`);
|
|
141
|
+
return 'claude';
|
|
142
|
+
}
|
|
143
|
+
return backend;
|
|
144
|
+
}
|
|
145
|
+
function normalizeLegacyManagedModel(agent, configPath) {
|
|
146
|
+
if (typeof agent.model === 'string' && !isClaudeModel(agent.model)) {
|
|
147
|
+
console.warn(`[GraphAPI] Deprecated Gemini model at ${configPath}; using "claude-sonnet-4-6" for compatibility.`);
|
|
148
|
+
agent.model = 'claude-sonnet-4-6';
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
function isRecord(value) {
|
|
154
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
155
|
+
}
|
|
156
|
+
function migrateLegacyManagedBackends(config) {
|
|
157
|
+
let migrated = false;
|
|
158
|
+
const next = { ...config };
|
|
159
|
+
const originalAgent = isRecord(config.agent) ? config.agent : undefined;
|
|
160
|
+
const originalAgentBackend = originalAgent?.backend;
|
|
161
|
+
if (isRecord(next.agent)) {
|
|
162
|
+
const agent = { ...next.agent };
|
|
163
|
+
const backend = normalizeLegacyManagedBackend(agent.backend, 'agent.backend');
|
|
164
|
+
if (backend !== agent.backend) {
|
|
165
|
+
agent.backend = backend;
|
|
166
|
+
normalizeLegacyManagedModel(agent, 'agent.model');
|
|
167
|
+
next.agent = agent;
|
|
168
|
+
migrated = true;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (isRecord(next.multi_agent)) {
|
|
172
|
+
const multiAgent = { ...next.multi_agent };
|
|
173
|
+
const originalMultiAgent = isRecord(config.multi_agent) ? config.multi_agent : {};
|
|
174
|
+
const originalMultiAgentBackend = originalMultiAgent.backend;
|
|
175
|
+
const normalizedMultiAgentBackend = normalizeLegacyManagedBackend(originalMultiAgentBackend, 'multi_agent.backend');
|
|
176
|
+
if (normalizedMultiAgentBackend !== originalMultiAgentBackend) {
|
|
177
|
+
multiAgent.backend = normalizedMultiAgentBackend;
|
|
178
|
+
migrated = true;
|
|
179
|
+
}
|
|
180
|
+
const inheritedBackend = originalMultiAgentBackend ?? originalAgentBackend;
|
|
181
|
+
const normalizedInheritedBackend = normalizeLegacyManagedBackend(inheritedBackend, originalMultiAgentBackend !== undefined ? 'multi_agent.backend' : 'agent.backend');
|
|
182
|
+
if (isRecord(multiAgent.agents)) {
|
|
183
|
+
const agents = { ...multiAgent.agents };
|
|
184
|
+
let agentsMigrated = false;
|
|
185
|
+
for (const [agentId, agentConfig] of Object.entries(agents)) {
|
|
186
|
+
if (!isRecord(agentConfig)) {
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
const agent = { ...agentConfig };
|
|
190
|
+
const hasExplicitBackend = Object.prototype.hasOwnProperty.call(agent, 'backend');
|
|
191
|
+
const priorEffectiveBackend = hasExplicitBackend ? agent.backend : inheritedBackend;
|
|
192
|
+
const normalizedBackend = normalizeLegacyManagedBackend(priorEffectiveBackend, `multi_agent.agents.${agentId}.backend`);
|
|
193
|
+
const inheritedBackendWasNormalized = !hasExplicitBackend && normalizedInheritedBackend !== inheritedBackend;
|
|
194
|
+
if (normalizedBackend !== priorEffectiveBackend || inheritedBackendWasNormalized) {
|
|
195
|
+
agent.backend = normalizedBackend;
|
|
196
|
+
normalizeLegacyManagedModel(agent, `multi_agent.agents.${agentId}.model`);
|
|
197
|
+
agents[agentId] = agent;
|
|
198
|
+
agentsMigrated = true;
|
|
199
|
+
migrated = true;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
if (agentsMigrated) {
|
|
203
|
+
multiAgent.agents = agents;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (migrated) {
|
|
207
|
+
next.multi_agent = multiAgent;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return (migrated ? next : config);
|
|
211
|
+
}
|
|
100
212
|
function getCodeActRateLimitMax() {
|
|
101
213
|
const raw = process.env.MAMA_CODE_ACT_RATE_LIMIT_PER_MINUTE;
|
|
102
214
|
if (!raw) {
|
|
@@ -333,7 +445,7 @@ function filterEdgesByNodes(edges, nodes) {
|
|
|
333
445
|
const nodeIds = new Set(nodes.map((n) => n.id));
|
|
334
446
|
return edges.filter((e) => nodeIds.has(e.from) || nodeIds.has(e.to));
|
|
335
447
|
}
|
|
336
|
-
function serveStaticFile(res, filePath, contentType) {
|
|
448
|
+
function serveStaticFile(res, filePath, contentType, extraHeaders = {}) {
|
|
337
449
|
try {
|
|
338
450
|
const stats = fs_1.default.statSync(filePath);
|
|
339
451
|
if (!stats.isFile()) {
|
|
@@ -349,6 +461,7 @@ function serveStaticFile(res, filePath, contentType) {
|
|
|
349
461
|
Pragma: 'no-cache',
|
|
350
462
|
Expires: '0',
|
|
351
463
|
ETag: etag,
|
|
464
|
+
...extraHeaders,
|
|
352
465
|
});
|
|
353
466
|
res.end(content);
|
|
354
467
|
}
|
|
@@ -578,7 +691,7 @@ async function getSimilarityEdges() {
|
|
|
578
691
|
for (const decision of decisions.slice(0, 50)) {
|
|
579
692
|
try {
|
|
580
693
|
const query = `${decision.topic} ${decision.decision}`;
|
|
581
|
-
const embedding = await generateEmbedding(query);
|
|
694
|
+
const embedding = await generateEmbedding(query, 'query');
|
|
582
695
|
const similar = (await vectorSearch(embedding, 3, 0.7));
|
|
583
696
|
for (const s of similar) {
|
|
584
697
|
if (s.id !== decision.id && s.similarity > 0.7) {
|
|
@@ -919,10 +1032,11 @@ function createGraphHandler(options = {}) {
|
|
|
919
1032
|
res.end();
|
|
920
1033
|
return true;
|
|
921
1034
|
}
|
|
922
|
-
// Route: GET / - redirect to /
|
|
1035
|
+
// Route: GET / - redirect to the operator board (M7 phase 2: /ui is the
|
|
1036
|
+
// default face; the legacy viewer stays reachable at /viewer)
|
|
923
1037
|
if (pathname === '/' && req.method === 'GET') {
|
|
924
|
-
console.log('[GraphHandler] Redirecting / to /
|
|
925
|
-
res.writeHead(302, { Location: '/
|
|
1038
|
+
console.log('[GraphHandler] Redirecting / to /ui');
|
|
1039
|
+
res.writeHead(302, { Location: '/ui' });
|
|
926
1040
|
res.end();
|
|
927
1041
|
return true;
|
|
928
1042
|
}
|
|
@@ -958,6 +1072,29 @@ function createGraphHandler(options = {}) {
|
|
|
958
1072
|
serveStaticFile(res, VIEWER_FAVICON_PATH, 'image/x-icon');
|
|
959
1073
|
return true;
|
|
960
1074
|
}
|
|
1075
|
+
// Route: GET/HEAD /ui/* - operator viewer SPA (public/ui, Vite build)
|
|
1076
|
+
if ((pathname === '/ui' || pathname.startsWith('/ui/')) &&
|
|
1077
|
+
(req.method === 'GET' || req.method === 'HEAD')) {
|
|
1078
|
+
const uiRoot = getUiDirectory();
|
|
1079
|
+
// '/ui' and '/ui/' both mean the SPA shell; slicing '/ui/' yields '' which
|
|
1080
|
+
// resolves to uiRoot itself and would fail the traversal guard below.
|
|
1081
|
+
const rel = pathname === '/ui' || pathname === '/ui/' ? 'index.html' : pathname.slice('/ui/'.length);
|
|
1082
|
+
const resolved = path_1.default.resolve(uiRoot, rel);
|
|
1083
|
+
if (!resolved.startsWith(uiRoot + path_1.default.sep)) {
|
|
1084
|
+
res.writeHead(404, { 'Content-Type': 'text/plain' });
|
|
1085
|
+
res.end('Not found');
|
|
1086
|
+
return true;
|
|
1087
|
+
}
|
|
1088
|
+
const isAsset = rel.startsWith('assets/');
|
|
1089
|
+
const exists = fs_1.default.existsSync(resolved) && fs_1.default.statSync(resolved).isFile();
|
|
1090
|
+
// Missing hashed assets must 404 (via serveStaticFile's ENOENT path) -- an
|
|
1091
|
+
// index.html fallback would mask them as 200 text/html.
|
|
1092
|
+
const target = exists || isAsset ? resolved : path_1.default.join(uiRoot, 'index.html');
|
|
1093
|
+
const contentType = UI_STATIC_MIME[path_1.default.extname(target)] ?? 'application/octet-stream';
|
|
1094
|
+
const extraHeaders = contentType === 'text/html' ? { 'Content-Security-Policy': UI_CSP } : {};
|
|
1095
|
+
serveStaticFile(res, target, contentType, extraHeaders);
|
|
1096
|
+
return true;
|
|
1097
|
+
}
|
|
961
1098
|
// Route: GET/HEAD /viewer/icons/*.png - serve PWA icons
|
|
962
1099
|
if (pathname.startsWith('/viewer/icons/') &&
|
|
963
1100
|
pathname.endsWith('.png') &&
|
|
@@ -985,6 +1122,17 @@ function createGraphHandler(options = {}) {
|
|
|
985
1122
|
serveStaticFile(res, filePath, 'application/javascript');
|
|
986
1123
|
return true;
|
|
987
1124
|
}
|
|
1125
|
+
// Route: GET/HEAD /viewer/js/*.js - serve first-party viewer entry modules
|
|
1126
|
+
if (pathname.startsWith('/viewer/js/') &&
|
|
1127
|
+
!pathname.includes('/modules/') &&
|
|
1128
|
+
!pathname.includes('/utils/') &&
|
|
1129
|
+
pathname.endsWith('.js') &&
|
|
1130
|
+
(req.method === 'GET' || req.method === 'HEAD')) {
|
|
1131
|
+
const fileName = pathname.split('/').pop();
|
|
1132
|
+
const filePath = path_1.default.join(VIEWER_DIR, 'js', fileName);
|
|
1133
|
+
serveStaticFile(res, filePath, 'application/javascript');
|
|
1134
|
+
return true;
|
|
1135
|
+
}
|
|
988
1136
|
// Route: GET/HEAD /viewer/js/modules/*.js - serve feature modules
|
|
989
1137
|
if (pathname.startsWith('/viewer/js/modules/') &&
|
|
990
1138
|
pathname.endsWith('.js') &&
|
|
@@ -2058,7 +2206,8 @@ function loadMAMAConfig() {
|
|
|
2058
2206
|
return {};
|
|
2059
2207
|
}
|
|
2060
2208
|
const content = fs_1.default.readFileSync(MAMA_CONFIG_PATH, 'utf8');
|
|
2061
|
-
|
|
2209
|
+
const config = js_yaml_1.default.load(content) || {};
|
|
2210
|
+
return migrateLegacyManagedBackends(config);
|
|
2062
2211
|
}
|
|
2063
2212
|
catch (error) {
|
|
2064
2213
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -2250,6 +2399,7 @@ async function handleGetConfigRequest(_req, res) {
|
|
|
2250
2399
|
allowedTools: [
|
|
2251
2400
|
'mama_search',
|
|
2252
2401
|
'mama_recall',
|
|
2402
|
+
'context_compile',
|
|
2253
2403
|
'mama_load_checkpoint',
|
|
2254
2404
|
'Read',
|
|
2255
2405
|
'discord_send',
|
|
@@ -2590,7 +2740,7 @@ function validateConfigUpdate(config) {
|
|
|
2590
2740
|
}
|
|
2591
2741
|
if (config.agent.backend &&
|
|
2592
2742
|
!supportedManagedBackends.includes(String(config.agent.backend).toLowerCase())) {
|
|
2593
|
-
errors.push('agent.backend must be "claude", "codex", "codex-mcp"
|
|
2743
|
+
errors.push('agent.backend must be "claude", "codex", or "codex-mcp"');
|
|
2594
2744
|
}
|
|
2595
2745
|
if (config.agent.backend && config.agent.model && typeof config.agent.model === 'string') {
|
|
2596
2746
|
const backend = String(config.agent.backend).toLowerCase();
|
|
@@ -2624,7 +2774,7 @@ function validateConfigUpdate(config) {
|
|
|
2624
2774
|
if (backendRaw !== undefined) {
|
|
2625
2775
|
const backend = String(backendRaw).toLowerCase();
|
|
2626
2776
|
if (!supportedManagedBackends.includes(backend)) {
|
|
2627
|
-
errors.push(`multi_agent.agents.${agentId}.backend must be "claude", "codex", "codex-mcp"
|
|
2777
|
+
errors.push(`multi_agent.agents.${agentId}.backend must be "claude", "codex", or "codex-mcp"`);
|
|
2628
2778
|
continue;
|
|
2629
2779
|
}
|
|
2630
2780
|
if (typeof modelRaw === 'string' && modelRaw.trim()) {
|
|
@@ -2940,7 +3090,7 @@ async function handleMultiAgentUpdateAgentRequest(req, res, pathname, options =
|
|
|
2940
3090
|
if (body.backend !== undefined &&
|
|
2941
3091
|
(typeof body.backend !== 'string' ||
|
|
2942
3092
|
!supportedManagedBackends.includes(String(body.backend).toLowerCase()))) {
|
|
2943
|
-
validationErrors.push('backend must be "claude", "codex", "codex-mcp"
|
|
3093
|
+
validationErrors.push('backend must be "claude", "codex", or "codex-mcp"');
|
|
2944
3094
|
}
|
|
2945
3095
|
const nextBackend = (body.backend !== undefined ? String(body.backend).toLowerCase() : currentAgent.backend);
|
|
2946
3096
|
const nextModel = (body.model !== undefined ? body.model : currentAgent.model);
|
|
@@ -3310,7 +3460,28 @@ async function handleCodeActRequest(req, res, options = {}) {
|
|
|
3310
3460
|
res.end(JSON.stringify({ error: true, message: 'Missing required field: code (string)' }));
|
|
3311
3461
|
return;
|
|
3312
3462
|
}
|
|
3313
|
-
|
|
3463
|
+
let agentId;
|
|
3464
|
+
if (body.agent_id !== undefined) {
|
|
3465
|
+
if (typeof body.agent_id !== 'string' || body.agent_id.trim().length === 0) {
|
|
3466
|
+
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
3467
|
+
res.end(JSON.stringify({ error: true, message: 'agent_id must be a non-empty string.' }));
|
|
3468
|
+
return;
|
|
3469
|
+
}
|
|
3470
|
+
agentId = body.agent_id.trim();
|
|
3471
|
+
}
|
|
3472
|
+
const allowedTools = normalizeCodeActToolList(body.allowed_tools, 'allowed_tools', res);
|
|
3473
|
+
if (allowedTools === false) {
|
|
3474
|
+
return;
|
|
3475
|
+
}
|
|
3476
|
+
const blockedTools = normalizeCodeActToolList(body.blocked_tools, 'blocked_tools', res);
|
|
3477
|
+
if (blockedTools === false) {
|
|
3478
|
+
return;
|
|
3479
|
+
}
|
|
3480
|
+
const result = await options.executeCodeAct(code, {
|
|
3481
|
+
...(agentId ? { agentId } : {}),
|
|
3482
|
+
...(allowedTools ? { allowedTools } : {}),
|
|
3483
|
+
...(blockedTools ? { blockedTools } : {}),
|
|
3484
|
+
});
|
|
3314
3485
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
3315
3486
|
res.end(JSON.stringify(result));
|
|
3316
3487
|
}
|
|
@@ -3321,4 +3492,15 @@ async function handleCodeActRequest(req, res, options = {}) {
|
|
|
3321
3492
|
res.end(JSON.stringify({ error: true, message }));
|
|
3322
3493
|
}
|
|
3323
3494
|
}
|
|
3495
|
+
function normalizeCodeActToolList(value, field, res) {
|
|
3496
|
+
if (value === undefined) {
|
|
3497
|
+
return undefined;
|
|
3498
|
+
}
|
|
3499
|
+
if (!Array.isArray(value) || value.some((item) => typeof item !== 'string')) {
|
|
3500
|
+
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
3501
|
+
res.end(JSON.stringify({ error: true, message: `${field} must be an array of strings.` }));
|
|
3502
|
+
return false;
|
|
3503
|
+
}
|
|
3504
|
+
return value.map((item) => item.trim()).filter((item) => item.length > 0);
|
|
3505
|
+
}
|
|
3324
3506
|
//# sourceMappingURL=graph-api.js.map
|