amalgm 0.0.0 → 0.0.32
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/README.md +41 -1
- package/bin/amalgm.js +8 -2
- package/lib/auth-store.js +223 -0
- package/lib/cli.js +1132 -0
- package/lib/paths.js +30 -0
- package/lib/supervisor.js +476 -0
- package/lib/tunnel-chat.js +328 -0
- package/lib/tunnel-events.js +499 -0
- package/package.json +30 -3
- package/runtime/README.md +4 -0
- package/runtime/lib/chatInput.js +315 -0
- package/runtime/lib/harnesses.js +988 -0
- package/runtime/lib/local/amalgmStore.js +136 -0
- package/runtime/lib/local/credentialResolver.js +425 -0
- package/runtime/lib/mcpApps/registry.js +619 -0
- package/runtime/package.json +5 -0
- package/runtime/scripts/amalgm-mcp/agents/rest.js +144 -0
- package/runtime/scripts/amalgm-mcp/agents/store.js +684 -0
- package/runtime/scripts/amalgm-mcp/agents/talk.js +1162 -0
- package/runtime/scripts/amalgm-mcp/agents/tools.js +221 -0
- package/runtime/scripts/amalgm-mcp/artifacts/advertise.js +132 -0
- package/runtime/scripts/amalgm-mcp/artifacts/rest.js +103 -0
- package/runtime/scripts/amalgm-mcp/artifacts/store.js +157 -0
- package/runtime/scripts/amalgm-mcp/artifacts/supervisor.js +402 -0
- package/runtime/scripts/amalgm-mcp/artifacts/tools.js +176 -0
- package/runtime/scripts/amalgm-mcp/browser/page.js +637 -0
- package/runtime/scripts/amalgm-mcp/browser/tools.js +688 -0
- package/runtime/scripts/amalgm-mcp/config.js +140 -0
- package/runtime/scripts/amalgm-mcp/credentials/rest.js +45 -0
- package/runtime/scripts/amalgm-mcp/deps.js +40 -0
- package/runtime/scripts/amalgm-mcp/email/inbound.js +215 -0
- package/runtime/scripts/amalgm-mcp/events/executor.js +179 -0
- package/runtime/scripts/amalgm-mcp/events/ingress.js +113 -0
- package/runtime/scripts/amalgm-mcp/events/matcher.js +125 -0
- package/runtime/scripts/amalgm-mcp/events/rest.js +200 -0
- package/runtime/scripts/amalgm-mcp/events/ring-buffer.js +19 -0
- package/runtime/scripts/amalgm-mcp/events/store.js +113 -0
- package/runtime/scripts/amalgm-mcp/events/tools.js +306 -0
- package/runtime/scripts/amalgm-mcp/events/webhook-url.js +28 -0
- package/runtime/scripts/amalgm-mcp/fs/rest.js +293 -0
- package/runtime/scripts/amalgm-mcp/index.js +100 -0
- package/runtime/scripts/amalgm-mcp/lib/chat-runner.js +167 -0
- package/runtime/scripts/amalgm-mcp/lib/email-md.js +288 -0
- package/runtime/scripts/amalgm-mcp/lib/mcp-resolver.js +63 -0
- package/runtime/scripts/amalgm-mcp/lib/prefs.js +441 -0
- package/runtime/scripts/amalgm-mcp/lib/storage.js +92 -0
- package/runtime/scripts/amalgm-mcp/lib/supabase.js +118 -0
- package/runtime/scripts/amalgm-mcp/lib/tool-result.js +177 -0
- package/runtime/scripts/amalgm-mcp/local/rest.js +87 -0
- package/runtime/scripts/amalgm-mcp/mcp-connections/rest.js +234 -0
- package/runtime/scripts/amalgm-mcp/notify/index.js +107 -0
- package/runtime/scripts/amalgm-mcp/server/core-tools.js +20 -0
- package/runtime/scripts/amalgm-mcp/server/http.js +377 -0
- package/runtime/scripts/amalgm-mcp/server/mcp.js +127 -0
- package/runtime/scripts/amalgm-mcp/slack/inbound.js +200 -0
- package/runtime/scripts/amalgm-mcp/state/db.js +194 -0
- package/runtime/scripts/amalgm-mcp/state/events.js +113 -0
- package/runtime/scripts/amalgm-mcp/state/rest.js +64 -0
- package/runtime/scripts/amalgm-mcp/state/snapshot.js +76 -0
- package/runtime/scripts/amalgm-mcp/tasks/executor.js +225 -0
- package/runtime/scripts/amalgm-mcp/tasks/rest.js +110 -0
- package/runtime/scripts/amalgm-mcp/tasks/schedule-normalization.js +85 -0
- package/runtime/scripts/amalgm-mcp/tasks/scheduler.js +105 -0
- package/runtime/scripts/amalgm-mcp/tasks/store.js +154 -0
- package/runtime/scripts/amalgm-mcp/tasks/tools.js +391 -0
- package/runtime/scripts/amalgm-mcp/toolbox/rest.js +75 -0
- package/runtime/scripts/amalgm-mcp/toolbox/runner.js +257 -0
- package/runtime/scripts/amalgm-mcp/toolbox/store.js +933 -0
- package/runtime/scripts/amalgm-mcp/toolbox/tools.js +269 -0
- package/runtime/scripts/amalgm-mcp/user-api-keys/rest.js +105 -0
- package/runtime/scripts/amalgm-mcp/workspace/rest.js +497 -0
- package/runtime/scripts/chat-core/adapters/claude.js +165 -0
- package/runtime/scripts/chat-core/adapters/codex.js +313 -0
- package/runtime/scripts/chat-core/adapters/opencode.js +412 -0
- package/runtime/scripts/chat-core/auth.js +177 -0
- package/runtime/scripts/chat-core/contract.js +328 -0
- package/runtime/scripts/chat-core/credentials/store.js +212 -0
- package/runtime/scripts/chat-core/egress.js +87 -0
- package/runtime/scripts/chat-core/engine.js +253 -0
- package/runtime/scripts/chat-core/event-schema.js +231 -0
- package/runtime/scripts/chat-core/events.js +190 -0
- package/runtime/scripts/chat-core/index.js +11 -0
- package/runtime/scripts/chat-core/input.js +50 -0
- package/runtime/scripts/chat-core/normalizers/claude.js +450 -0
- package/runtime/scripts/chat-core/normalizers/codex.js +380 -0
- package/runtime/scripts/chat-core/normalizers/normalizer_spec.md +259 -0
- package/runtime/scripts/chat-core/normalizers/opencode.js +552 -0
- package/runtime/scripts/chat-core/normalizers/tool_contract.md +123 -0
- package/runtime/scripts/chat-core/normalizers/usage_contract.md +304 -0
- package/runtime/scripts/chat-core/parts.js +253 -0
- package/runtime/scripts/chat-core/recorder.js +65 -0
- package/runtime/scripts/chat-core/runtime.js +86 -0
- package/runtime/scripts/chat-core/server.js +163 -0
- package/runtime/scripts/chat-core/sse.js +196 -0
- package/runtime/scripts/chat-core/stores.js +100 -0
- package/runtime/scripts/chat-core/tool-display.js +149 -0
- package/runtime/scripts/chat-core/tool-shape.js +143 -0
- package/runtime/scripts/chat-core/tooling/mcp-bundle.js +161 -0
- package/runtime/scripts/chat-core/tooling/mcp-relay.js +97 -0
- package/runtime/scripts/chat-core/tooling/native-binaries.js +608 -0
- package/runtime/scripts/chat-core/tooling/system-prompt.js +20 -0
- package/runtime/scripts/chat-core/usage.js +343 -0
- package/runtime/scripts/chat-server/config.js +110 -0
- package/runtime/scripts/chat-server/db.js +529 -0
- package/runtime/scripts/chat-server/index.js +33 -0
- package/runtime/scripts/chat-server/model-catalog.js +327 -0
- package/runtime/scripts/chat-server.js +75 -0
- package/runtime/scripts/credential-adapter.js +131 -0
- package/runtime/scripts/fs-watcher.js +888 -0
- package/runtime/scripts/local-gateway.js +854 -0
- package/runtime/scripts/platform-context.txt +246 -0
- package/runtime/scripts/port-monitor.js +175 -0
- package/runtime/scripts/proxy-token-store.js +162 -0
- package/runtime/scripts/runtime-auth.js +163 -0
- package/runtime/scripts/test-claude-code-models.js +87 -0
- package/runtime/tsconfig.json +15 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* /agents/* REST routes (UI-only, not MCP tools).
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
createAgent,
|
|
7
|
+
deleteAgent,
|
|
8
|
+
getAllAgentsWithBuiltins,
|
|
9
|
+
resolveAgent,
|
|
10
|
+
updateAgent,
|
|
11
|
+
} = require('./store');
|
|
12
|
+
const credentialAdapter = require('../../credential-adapter');
|
|
13
|
+
|
|
14
|
+
function coerceAuthMethodForHarness(harnessId, authMethod) {
|
|
15
|
+
const supported = credentialAdapter.SUPPORTED_AUTH_BY_HARNESS?.[harnessId] || ['amalgm'];
|
|
16
|
+
return supported.includes(authMethod) ? authMethod : supported[0] || 'amalgm';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function normalizeStringList(values) {
|
|
20
|
+
if (!Array.isArray(values)) return [];
|
|
21
|
+
return [...new Set(values
|
|
22
|
+
.filter((value) => typeof value === 'string')
|
|
23
|
+
.map((value) => value.trim())
|
|
24
|
+
.filter(Boolean))];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function normalizeMcpConfig(mcp, mcpAppIds, nativeMcps) {
|
|
28
|
+
return {
|
|
29
|
+
inheritAll: mcp?.inheritAll !== false,
|
|
30
|
+
customServers: Array.isArray(mcp?.customServers) ? mcp.customServers : [],
|
|
31
|
+
appIds: normalizeStringList(mcp?.appIds ?? mcpAppIds),
|
|
32
|
+
nativeMcps: normalizeStringList(mcp?.nativeMcps ?? nativeMcps),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function normalizeToolConfig(tools, legacyMcp) {
|
|
37
|
+
const raw = tools && typeof tools === 'object' && !Array.isArray(tools) ? tools : null;
|
|
38
|
+
const selectedToolIds = normalizeStringList(
|
|
39
|
+
raw?.selectedToolIds
|
|
40
|
+
?? raw?.selected
|
|
41
|
+
?? [
|
|
42
|
+
...normalizeStringList(legacyMcp?.appIds),
|
|
43
|
+
...normalizeStringList(legacyMcp?.nativeMcps),
|
|
44
|
+
],
|
|
45
|
+
);
|
|
46
|
+
return {
|
|
47
|
+
mode: raw?.mode === 'selected' || (!raw && legacyMcp?.inheritAll === false) ? 'selected' : 'all',
|
|
48
|
+
selectedToolIds,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async function handleList(sendJson) {
|
|
53
|
+
sendJson(200, { agents: getAllAgentsWithBuiltins() });
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async function handleGet(body, sendJson) {
|
|
57
|
+
const { agent_id } = body;
|
|
58
|
+
const agent = resolveAgent(agent_id);
|
|
59
|
+
if (!agent) return sendJson(404, { error: `Agent not found: ${agent_id}` });
|
|
60
|
+
sendJson(200, { agent });
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function handleCreate(body, sendJson) {
|
|
64
|
+
const {
|
|
65
|
+
name,
|
|
66
|
+
description,
|
|
67
|
+
baseHarnessId,
|
|
68
|
+
baseModelId,
|
|
69
|
+
systemPrompt,
|
|
70
|
+
files,
|
|
71
|
+
skills,
|
|
72
|
+
mcpAppIds,
|
|
73
|
+
nativeMcps,
|
|
74
|
+
mcp,
|
|
75
|
+
tools,
|
|
76
|
+
authMethod,
|
|
77
|
+
} = body;
|
|
78
|
+
if (!name || !name.trim()) return sendJson(400, { error: 'name is required' });
|
|
79
|
+
if (!baseHarnessId) return sendJson(400, { error: 'baseHarnessId is required' });
|
|
80
|
+
|
|
81
|
+
const mcpConfig = normalizeMcpConfig(mcp, mcpAppIds, nativeMcps);
|
|
82
|
+
const toolConfig = normalizeToolConfig(tools, mcpConfig);
|
|
83
|
+
let agent;
|
|
84
|
+
try {
|
|
85
|
+
agent = createAgent({
|
|
86
|
+
name: name.trim(),
|
|
87
|
+
description: description || '',
|
|
88
|
+
baseHarnessId,
|
|
89
|
+
baseModelId: baseModelId || '',
|
|
90
|
+
systemPrompt: systemPrompt || '',
|
|
91
|
+
files: normalizeStringList(files),
|
|
92
|
+
skills: normalizeStringList(skills),
|
|
93
|
+
mcpAppIds: normalizeStringList(mcpConfig.appIds),
|
|
94
|
+
nativeMcps: normalizeStringList(mcpConfig.nativeMcps),
|
|
95
|
+
tools: toolConfig,
|
|
96
|
+
mcp: {
|
|
97
|
+
...mcpConfig,
|
|
98
|
+
inheritAll: toolConfig.mode !== 'selected',
|
|
99
|
+
},
|
|
100
|
+
authMethod: coerceAuthMethodForHarness(baseHarnessId, authMethod),
|
|
101
|
+
});
|
|
102
|
+
} catch (error) {
|
|
103
|
+
return sendJson(400, { error: error.message || 'Failed to create agent' });
|
|
104
|
+
}
|
|
105
|
+
console.log(`[AmalgmMCP] Created agent: ${agent.id} (${agent.name})`);
|
|
106
|
+
sendJson(200, { ok: true, agent });
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async function handleUpdate(body, sendJson) {
|
|
110
|
+
const { agent_id, ...updates } = body;
|
|
111
|
+
if (!agent_id) return sendJson(400, { error: 'agent_id is required' });
|
|
112
|
+
const existing = resolveAgent(agent_id);
|
|
113
|
+
if (!existing) return sendJson(404, { error: `Agent not found: ${agent_id}` });
|
|
114
|
+
|
|
115
|
+
if (updates.authMethod !== undefined) {
|
|
116
|
+
updates.authMethod = coerceAuthMethodForHarness(existing.baseHarnessId, updates.authMethod);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
let agent;
|
|
120
|
+
try {
|
|
121
|
+
agent = updateAgent(agent_id, updates);
|
|
122
|
+
} catch (error) {
|
|
123
|
+
const message = error.message || 'Failed to update agent';
|
|
124
|
+
return sendJson(message.includes('not found') ? 404 : 400, { error: message });
|
|
125
|
+
}
|
|
126
|
+
console.log(`[AmalgmMCP] Updated agent: ${agent.id} (${agent.name})`);
|
|
127
|
+
sendJson(200, { ok: true, agent });
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async function handleDelete(body, sendJson) {
|
|
131
|
+
const { agent_id } = body;
|
|
132
|
+
if (!agent_id) return sendJson(400, { error: 'agent_id is required' });
|
|
133
|
+
let deleted;
|
|
134
|
+
try {
|
|
135
|
+
deleted = deleteAgent(agent_id);
|
|
136
|
+
} catch (error) {
|
|
137
|
+
const message = error.message || 'Failed to delete agent';
|
|
138
|
+
return sendJson(message.includes('not found') ? 404 : 400, { error: message });
|
|
139
|
+
}
|
|
140
|
+
console.log(`[AmalgmMCP] Deleted agent: ${agent_id} (${deleted.name})`);
|
|
141
|
+
sendJson(200, { ok: true, deleted });
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
module.exports = { handleList, handleGet, handleCreate, handleUpdate, handleDelete };
|