amalgm 0.1.88 → 0.1.89

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.
Files changed (45) hide show
  1. package/lib/cli.js +16 -6
  2. package/lib/service.js +19 -0
  3. package/lib/supervisor.js +51 -0
  4. package/package.json +1 -1
  5. package/runtime/scripts/amalgm-mcp/apps/supervisor.js +0 -25
  6. package/runtime/scripts/amalgm-mcp/browser/auth-tools.js +179 -0
  7. package/runtime/scripts/amalgm-mcp/browser/cli.js +217 -0
  8. package/runtime/scripts/amalgm-mcp/browser/cua-tools.js +147 -0
  9. package/runtime/scripts/amalgm-mcp/browser/engine.js +454 -0
  10. package/runtime/scripts/amalgm-mcp/browser/recorder-tools.js +82 -0
  11. package/runtime/scripts/amalgm-mcp/browser/recorder.js +199 -0
  12. package/runtime/scripts/amalgm-mcp/browser/rest.js +5 -1
  13. package/runtime/scripts/amalgm-mcp/browser/tools.js +104 -731
  14. package/runtime/scripts/amalgm-mcp/fs/rest.js +5 -6
  15. package/runtime/scripts/amalgm-mcp/index.js +2 -0
  16. package/runtime/scripts/amalgm-mcp/lib/tool-result.js +32 -66
  17. package/runtime/scripts/amalgm-mcp/project-context/paths.js +266 -0
  18. package/runtime/scripts/amalgm-mcp/project-context/prompt.js +232 -0
  19. package/runtime/scripts/amalgm-mcp/project-context/rest.js +100 -0
  20. package/runtime/scripts/amalgm-mcp/project-context/store.js +671 -0
  21. package/runtime/scripts/amalgm-mcp/project-context/tools.js +146 -0
  22. package/runtime/scripts/amalgm-mcp/server/core-tools.js +35 -2
  23. package/runtime/scripts/amalgm-mcp/server/local-service-router.js +2 -0
  24. package/runtime/scripts/amalgm-mcp/server/routes/project-context.js +33 -0
  25. package/runtime/scripts/amalgm-mcp/state/db.js +11 -0
  26. package/runtime/scripts/amalgm-mcp/state/snapshot.js +3 -3
  27. package/runtime/scripts/amalgm-mcp/tests/core-tools.test.js +37 -4
  28. package/runtime/scripts/amalgm-mcp/tests/project-context.test.js +328 -0
  29. package/runtime/scripts/amalgm-mcp/tests/system-catalog.test.js +9 -9
  30. package/runtime/scripts/amalgm-mcp/tests/toolbox-service.test.js +2 -2
  31. package/runtime/scripts/amalgm-mcp/toolbox/loadout-context.js +1 -0
  32. package/runtime/scripts/amalgm-mcp/toolbox/store.js +0 -15
  33. package/runtime/scripts/amalgm-mcp/toolbox/system-catalog.js +2 -0
  34. package/runtime/scripts/amalgm-mcp/workspace/rest.js +11 -7
  35. package/runtime/scripts/chat-core/adapters/opencode.js +1 -1
  36. package/runtime/scripts/chat-core/engine.js +16 -2
  37. package/runtime/scripts/chat-core/input.js +19 -1
  38. package/runtime/scripts/chat-core/tool-shape.js +6 -4
  39. package/runtime/scripts/chat-core/tooling/system-instructions.js +51 -0
  40. package/runtime/scripts/chat-core/tooling/system-prompt.js +34 -8
  41. package/runtime/scripts/local-gateway.js +1 -0
  42. package/runtime/scripts/amalgm-mcp/browser/agent-browser.js +0 -569
  43. package/runtime/scripts/amalgm-mcp/browser/page.js +0 -25
  44. package/runtime/scripts/chat-core/tooling/active-memory.js +0 -574
  45. package/runtime/scripts/chat-core/tooling/passive-memory.js +0 -576
@@ -0,0 +1,100 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * /project-context/* REST routes — the canonical UI/API write path for
5
+ * project memory docs. Not part of the MCP tool surface.
6
+ */
7
+
8
+ const store = require('./store');
9
+
10
+ function cleanString(value) {
11
+ return typeof value === 'string' && value.trim() ? value.trim() : '';
12
+ }
13
+
14
+ async function handleGet(query, sendJson) {
15
+ const targetPath = cleanString(query?.path);
16
+ if (!targetPath) {
17
+ sendJson(400, { error: 'path is required' });
18
+ return;
19
+ }
20
+ try {
21
+ const context = store.getProjectContext(targetPath, { source: 'project-context:rest-read' });
22
+ if (!context) {
23
+ sendJson(404, { error: `No registered Amalgm project contains: ${targetPath}` });
24
+ return;
25
+ }
26
+ sendJson(200, { context });
27
+ } catch (error) {
28
+ sendJson(500, { error: error instanceof Error ? error.message : 'Failed to read project context' });
29
+ }
30
+ }
31
+
32
+ async function handleList(sendJson) {
33
+ try {
34
+ sendJson(200, { contexts: store.listProjectContexts() });
35
+ } catch (error) {
36
+ sendJson(500, { error: error instanceof Error ? error.message : 'Failed to list project contexts' });
37
+ }
38
+ }
39
+
40
+ async function handleAppendChangeLog(body, sendJson) {
41
+ const targetPath = cleanString(body?.path || body?.projectPath);
42
+ if (!targetPath) {
43
+ sendJson(400, { error: 'path is required' });
44
+ return;
45
+ }
46
+ if (!cleanString(body?.body)) {
47
+ sendJson(400, { error: 'body is required' });
48
+ return;
49
+ }
50
+ try {
51
+ const result = store.appendChangeLog(targetPath, body.body, {
52
+ source: cleanString(body?.source) || 'project-context:rest',
53
+ });
54
+ sendJson(200, {
55
+ success: true,
56
+ entry: result.entry,
57
+ timestamp: result.timestamp,
58
+ context: result.record,
59
+ });
60
+ } catch (error) {
61
+ const message = error instanceof Error ? error.message : 'Failed to append change log entry';
62
+ sendJson(message.startsWith('No registered Amalgm project') ? 404 : 500, { error: message });
63
+ }
64
+ }
65
+
66
+ function writeDocHandler(writeFn) {
67
+ return async (body, sendJson) => {
68
+ const targetPath = cleanString(body?.path || body?.projectPath);
69
+ if (!targetPath) {
70
+ sendJson(400, { error: 'path is required' });
71
+ return;
72
+ }
73
+ if (typeof body?.content !== 'string') {
74
+ sendJson(400, { error: 'content is required' });
75
+ return;
76
+ }
77
+ try {
78
+ const result = writeFn(targetPath, body.content, {
79
+ source: cleanString(body?.source) || 'project-context:rest',
80
+ });
81
+ sendJson(200, { success: true, context: result.record });
82
+ } catch (error) {
83
+ const message = error instanceof Error ? error.message : 'Failed to write document';
84
+ sendJson(message.startsWith('No registered Amalgm project') ? 404 : 500, { error: message });
85
+ }
86
+ };
87
+ }
88
+
89
+ const handleWriteProjectState = writeDocHandler(store.writeProjectState);
90
+ const handleWriteInstructions = writeDocHandler(store.writeInstructions);
91
+ const handleWriteChangeLog = writeDocHandler(store.writeChangeLog);
92
+
93
+ module.exports = {
94
+ handleAppendChangeLog,
95
+ handleGet,
96
+ handleList,
97
+ handleWriteChangeLog,
98
+ handleWriteInstructions,
99
+ handleWriteProjectState,
100
+ };