@agentprojectcontext/apx 1.77.2 → 1.78.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.
Files changed (294) hide show
  1. package/README.md +23 -9
  2. package/package.json +12 -12
  3. package/src/core/agent/build-agent-system.js +3 -2
  4. package/src/core/agent/constants.js +3 -2
  5. package/src/core/agent/loop/greeting-guard.js +55 -0
  6. package/src/core/agent/loop/side-effects.js +52 -0
  7. package/src/core/agent/prompt-builder.js +49 -8
  8. package/src/core/agent/run-agent.js +13 -48
  9. package/src/core/agent/security.js +1 -1
  10. package/src/core/agent/self-memory.js +4 -2
  11. package/src/core/agent/skills/index-store.js +2 -2
  12. package/src/core/agent/skills/loader.js +3 -22
  13. package/src/core/agent/super-agent.js +0 -2
  14. package/src/core/agent/tools/handlers/call-runtime.js +4 -4
  15. package/src/core/agent/tools/handlers/search-sessions.js +1 -1
  16. package/src/core/agent/tools/handlers/set-permission-mode.js +11 -4
  17. package/src/core/agent/tools/names.js +58 -0
  18. package/src/core/apc/context-copy.js +1 -1
  19. package/src/core/apc/frontmatter.js +85 -0
  20. package/src/core/apc/parser.js +9 -21
  21. package/src/core/apc/paths.js +8 -8
  22. package/src/core/apc/scaffold.js +5 -4
  23. package/src/core/channels/telegram/config.js +201 -0
  24. package/src/core/config/index.js +25 -183
  25. package/src/core/config/paths.js +54 -1
  26. package/src/core/confirmation/adapters/web.js +1 -1
  27. package/src/core/deck/manifest.js +12 -12
  28. package/src/core/desktop/autostart.js +3 -2
  29. package/src/core/desktop/process.js +4 -4
  30. package/src/core/engines/presets.js +2 -2
  31. package/src/core/http-tools/browser.js +1 -1
  32. package/src/core/http-tools/catalog.js +551 -0
  33. package/src/core/http-tools/fetch.js +1 -1
  34. package/src/core/http-tools/glob.js +3 -3
  35. package/src/core/http-tools/grep.js +2 -9
  36. package/src/core/http-tools/inline-handlers.js +59 -0
  37. package/src/core/http-tools/registry.js +31 -615
  38. package/src/core/http-tools/search.js +2 -2
  39. package/src/core/identity/self.js +6 -7
  40. package/src/core/identity/telegram.js +3 -3
  41. package/src/core/logging.js +6 -5
  42. package/src/core/mcp/sources.js +12 -16
  43. package/src/core/memory/indexer.js +2 -5
  44. package/src/core/profiles/lifecycle.js +0 -2
  45. package/src/core/profiles/store.js +2 -7
  46. package/src/core/routines/runner.js +1 -1
  47. package/src/core/runtime-skills/apx-agency-agents/SKILL.md +2 -2
  48. package/src/core/runtime-skills/apx-profile/SKILL.md +3 -3
  49. package/src/core/runtime-skills/apx-project/SKILL.md +1 -1
  50. package/src/core/runtime-skills/apx-task/SKILL.md +8 -8
  51. package/src/core/runtime-skills/apx-telegram/SKILL.md +4 -4
  52. package/src/core/runtime-skills/apx-voice/SKILL.md +4 -4
  53. package/src/core/runtimes/detect.js +2 -2
  54. package/src/core/sessions/index.js +800 -0
  55. package/src/core/stores/code-sessions.js +3 -14
  56. package/src/core/stores/engine-sessions.js +0 -4
  57. package/src/core/stores/messages.js +0 -5
  58. package/src/core/stores/organization.js +9 -11
  59. package/src/core/stores/routines.js +6 -11
  60. package/src/core/stores/runtime-callbacks.js +2 -1
  61. package/src/core/util/json-file.js +128 -0
  62. package/src/core/vars/sources.js +14 -21
  63. package/src/core/voice/stt-models.js +1 -1
  64. package/src/core/voice/tts.js +5 -4
  65. package/src/host/daemon/api/admin-config.js +5 -5
  66. package/src/host/daemon/api/admin.js +8 -7
  67. package/src/host/daemon/api/agents.js +16 -16
  68. package/src/host/daemon/api/artifact-preview.js +8 -8
  69. package/src/host/daemon/api/artifacts.js +7 -7
  70. package/src/host/daemon/api/code.js +8 -8
  71. package/src/host/daemon/api/config.js +6 -6
  72. package/src/host/daemon/api/confirm.js +2 -2
  73. package/src/host/daemon/api/connections.js +2 -2
  74. package/src/host/daemon/api/conversations.js +12 -12
  75. package/src/host/daemon/api/deck.js +6 -6
  76. package/src/host/daemon/api/desktop.js +8 -8
  77. package/src/host/daemon/api/embeddings.js +4 -4
  78. package/src/host/daemon/api/engines.js +8 -7
  79. package/src/host/daemon/api/exec.js +5 -4
  80. package/src/host/daemon/api/files-project.js +6 -6
  81. package/src/host/daemon/api/health.js +2 -2
  82. package/src/host/daemon/api/identity.js +3 -3
  83. package/src/host/daemon/api/inbox.js +2 -2
  84. package/src/host/daemon/api/integrations.js +23 -19
  85. package/src/host/daemon/api/mcps.js +16 -12
  86. package/src/host/daemon/api/messages.js +5 -5
  87. package/src/host/daemon/api/organization.js +8 -8
  88. package/src/host/daemon/api/pairing.js +10 -7
  89. package/src/host/daemon/api/plugins.js +3 -3
  90. package/src/host/daemon/api/prefix.js +20 -0
  91. package/src/host/daemon/api/profiles.js +9 -9
  92. package/src/host/daemon/api/projects.js +5 -5
  93. package/src/host/daemon/api/routines.js +8 -8
  94. package/src/host/daemon/api/run.js +2 -2
  95. package/src/host/daemon/api/runtimes.js +6 -6
  96. package/src/host/daemon/api/sessions-search.js +18 -11
  97. package/src/host/daemon/api/sessions.js +6 -6
  98. package/src/host/daemon/api/shared.js +59 -13
  99. package/src/host/daemon/api/skills.js +12 -12
  100. package/src/host/daemon/api/super-agent.js +4 -4
  101. package/src/host/daemon/api/tasks.js +11 -11
  102. package/src/host/daemon/api/telegram.js +19 -20
  103. package/src/host/daemon/api/tools.js +7 -7
  104. package/src/host/daemon/api/top-level.js +7 -7
  105. package/src/host/daemon/api/transcribe.js +6 -6
  106. package/src/host/daemon/api/tts.js +3 -3
  107. package/src/host/daemon/api/vars.js +11 -8
  108. package/src/host/daemon/api/voice.js +6 -6
  109. package/src/host/daemon/api/web.js +28 -32
  110. package/src/host/daemon/api.js +77 -48
  111. package/src/host/daemon/db.js +1 -1
  112. package/src/host/daemon/desktop-ws.js +7 -3
  113. package/src/host/daemon/index.js +11 -5
  114. package/src/host/daemon/plugins/desktop/index.js +1 -1
  115. package/src/host/daemon/plugins/telegram/index.js +1 -1
  116. package/src/host/daemon/stt-venv.js +20 -81
  117. package/src/host/daemon/wakeup.js +1 -1
  118. package/src/interfaces/acp/index.js +3 -3
  119. package/src/interfaces/acp/session.js +2 -2
  120. package/src/interfaces/cli/commands/a2a.js +2 -2
  121. package/src/interfaces/cli/commands/agent.js +3 -3
  122. package/src/interfaces/cli/commands/artifact.js +13 -13
  123. package/src/interfaces/cli/commands/chat.js +3 -3
  124. package/src/interfaces/cli/commands/command.js +2 -2
  125. package/src/interfaces/cli/commands/config.js +4 -4
  126. package/src/interfaces/cli/commands/daemon.js +17 -18
  127. package/src/interfaces/cli/commands/desktop.js +7 -14
  128. package/src/interfaces/cli/commands/exec.js +2 -2
  129. package/src/interfaces/cli/commands/log.js +3 -4
  130. package/src/interfaces/cli/commands/mcp.js +9 -9
  131. package/src/interfaces/cli/commands/memory.js +2 -2
  132. package/src/interfaces/cli/commands/messages.js +5 -5
  133. package/src/interfaces/cli/commands/model.js +0 -18
  134. package/src/interfaces/cli/commands/obsidian.js +5 -5
  135. package/src/interfaces/cli/commands/org.js +5 -5
  136. package/src/interfaces/cli/commands/pair.js +6 -6
  137. package/src/interfaces/cli/commands/plugins.js +2 -2
  138. package/src/interfaces/cli/commands/profile.js +10 -10
  139. package/src/interfaces/cli/commands/project-config.js +6 -6
  140. package/src/interfaces/cli/commands/project.js +10 -10
  141. package/src/interfaces/cli/commands/routine.js +8 -9
  142. package/src/interfaces/cli/commands/runtime.js +2 -2
  143. package/src/interfaces/cli/commands/search.js +0 -1
  144. package/src/interfaces/cli/commands/session.js +12 -40
  145. package/src/interfaces/cli/commands/sessions.js +21 -798
  146. package/src/interfaces/cli/commands/setup.js +16 -6
  147. package/src/interfaces/cli/commands/skills.js +1 -2
  148. package/src/interfaces/cli/commands/status.js +3 -3
  149. package/src/interfaces/cli/commands/task.js +8 -8
  150. package/src/interfaces/cli/commands/telegram.js +21 -21
  151. package/src/interfaces/cli/commands/voice.js +6 -6
  152. package/src/interfaces/cli/help/index.js +2245 -0
  153. package/src/interfaces/cli/http.js +9 -4
  154. package/src/interfaces/cli/index.js +14 -2857
  155. package/src/interfaces/cli/routes/acp.js +13 -0
  156. package/src/interfaces/cli/routes/agent.js +27 -0
  157. package/src/interfaces/cli/routes/artifact.js +28 -0
  158. package/src/interfaces/cli/routes/chat.js +11 -0
  159. package/src/interfaces/cli/routes/code.js +11 -0
  160. package/src/interfaces/cli/routes/command.js +21 -0
  161. package/src/interfaces/cli/routes/config.js +16 -0
  162. package/src/interfaces/cli/routes/connections.js +11 -0
  163. package/src/interfaces/cli/routes/conversations.js +21 -0
  164. package/src/interfaces/cli/routes/daemon.js +19 -0
  165. package/src/interfaces/cli/routes/desktop.js +20 -0
  166. package/src/interfaces/cli/routes/env.js +13 -0
  167. package/src/interfaces/cli/routes/exec.js +11 -0
  168. package/src/interfaces/cli/routes/identity.js +11 -0
  169. package/src/interfaces/cli/routes/index.js +71 -0
  170. package/src/interfaces/cli/routes/init.js +11 -0
  171. package/src/interfaces/cli/routes/log.js +20 -0
  172. package/src/interfaces/cli/routes/mcp.js +22 -0
  173. package/src/interfaces/cli/routes/memory.js +11 -0
  174. package/src/interfaces/cli/routes/messages.js +16 -0
  175. package/src/interfaces/cli/routes/model.js +11 -0
  176. package/src/interfaces/cli/routes/obsidian.js +17 -0
  177. package/src/interfaces/cli/routes/org.js +34 -0
  178. package/src/interfaces/cli/routes/overlay.js +10 -0
  179. package/src/interfaces/cli/routes/pair.js +17 -0
  180. package/src/interfaces/cli/routes/panel.js +16 -0
  181. package/src/interfaces/cli/routes/permission.js +11 -0
  182. package/src/interfaces/cli/routes/plugins.js +21 -0
  183. package/src/interfaces/cli/routes/profile.js +27 -0
  184. package/src/interfaces/cli/routes/project.js +41 -0
  185. package/src/interfaces/cli/routes/restart.js +15 -0
  186. package/src/interfaces/cli/routes/routine.js +28 -0
  187. package/src/interfaces/cli/routes/run.js +11 -0
  188. package/src/interfaces/cli/routes/search.js +11 -0
  189. package/src/interfaces/cli/routes/send.js +11 -0
  190. package/src/interfaces/cli/routes/session.js +26 -0
  191. package/src/interfaces/cli/routes/sessions.js +15 -0
  192. package/src/interfaces/cli/routes/setup.js +18 -0
  193. package/src/interfaces/cli/routes/skills.js +20 -0
  194. package/src/interfaces/cli/routes/status.js +12 -0
  195. package/src/interfaces/cli/routes/task.js +26 -0
  196. package/src/interfaces/cli/routes/telegram.js +39 -0
  197. package/src/interfaces/cli/routes/update.js +24 -0
  198. package/src/interfaces/cli/routes/voice.js +17 -0
  199. package/src/interfaces/desktop/main.js +6 -7
  200. package/src/interfaces/desktop/renderer.js +0 -5
  201. package/src/interfaces/mcp-server/index.js +15 -14
  202. package/src/interfaces/tui/_shims/globals.d.ts +8 -0
  203. package/src/interfaces/tui/tsconfig.json +4 -1
  204. package/src/interfaces/web/README.md +6 -6
  205. package/src/interfaces/web/dist/assets/index-CBR_-QyA.js +824 -0
  206. package/src/interfaces/web/dist/assets/index-CBR_-QyA.js.map +1 -0
  207. package/src/interfaces/web/dist/index.html +1 -1
  208. package/src/interfaces/web/src/components/AddProjectDialog.tsx +1 -1
  209. package/src/interfaces/web/src/components/agents/AgentFormFields.tsx +1 -1
  210. package/src/interfaces/web/src/components/chat/ChatList.tsx +2 -2
  211. package/src/interfaces/web/src/components/chat/SkillPicker.tsx +1 -1
  212. package/src/interfaces/web/src/components/code/CodeFileTree.tsx +1 -1
  213. package/src/interfaces/web/src/components/code/CodeTerminal.tsx +1 -1
  214. package/src/interfaces/web/src/components/desktop/DesktopStatusCard.tsx +1 -1
  215. package/src/interfaces/web/src/components/files/FileBrowser.tsx +2 -2
  216. package/src/interfaces/web/src/components/memory/MemoryBrowser.tsx +2 -2
  217. package/src/interfaces/web/src/components/routines/ExecutionsList.tsx +1 -1
  218. package/src/interfaces/web/src/components/routines/RoutineEditor.tsx +2 -2
  219. package/src/interfaces/web/src/components/settings/DesktopSettingsPanel.tsx +1 -1
  220. package/src/interfaces/web/src/components/settings/MemoryPanel.tsx +1 -1
  221. package/src/interfaces/web/src/components/settings/SkillsInspectorPanel.tsx +1 -1
  222. package/src/interfaces/web/src/components/settings/SkillsManager.tsx +2 -2
  223. package/src/interfaces/web/src/components/tasks/TaskDetailPanel.tsx +1 -1
  224. package/src/interfaces/web/src/hooks/useDaemonStatus.ts +1 -1
  225. package/src/interfaces/web/src/hooks/useDevices.ts +1 -1
  226. package/src/interfaces/web/src/hooks/useEngines.ts +1 -1
  227. package/src/interfaces/web/src/hooks/useGlobalConfig.ts +2 -2
  228. package/src/interfaces/web/src/hooks/useIdentity.ts +1 -1
  229. package/src/interfaces/web/src/hooks/useInbox.ts +1 -1
  230. package/src/interfaces/web/src/hooks/useProfiles.ts +3 -3
  231. package/src/interfaces/web/src/hooks/useProjects.ts +1 -1
  232. package/src/interfaces/web/src/hooks/useTelegram.ts +3 -3
  233. package/src/interfaces/web/src/hooks/useTokenBootstrap.ts +30 -7
  234. package/src/interfaces/web/src/lib/api/admin.ts +11 -11
  235. package/src/interfaces/web/src/lib/api/agents.ts +14 -14
  236. package/src/interfaces/web/src/lib/api/artifacts.ts +11 -11
  237. package/src/interfaces/web/src/lib/api/code.ts +1 -1
  238. package/src/interfaces/web/src/lib/api/conversations.ts +8 -8
  239. package/src/interfaces/web/src/lib/api/deck.ts +3 -3
  240. package/src/interfaces/web/src/lib/api/desktop.ts +8 -8
  241. package/src/interfaces/web/src/lib/api/embeddings.ts +3 -3
  242. package/src/interfaces/web/src/lib/api/engines.ts +3 -3
  243. package/src/interfaces/web/src/lib/api/filesystem.ts +2 -2
  244. package/src/interfaces/web/src/lib/api/health.ts +1 -1
  245. package/src/interfaces/web/src/lib/api/identity.ts +2 -2
  246. package/src/interfaces/web/src/lib/api/inbox.ts +1 -1
  247. package/src/interfaces/web/src/lib/api/integrations.ts +8 -8
  248. package/src/interfaces/web/src/lib/api/mcps.ts +6 -6
  249. package/src/interfaces/web/src/lib/api/messages.ts +3 -3
  250. package/src/interfaces/web/src/lib/api/organization.ts +7 -7
  251. package/src/interfaces/web/src/lib/api/profiles.ts +8 -8
  252. package/src/interfaces/web/src/lib/api/projectFiles.ts +5 -5
  253. package/src/interfaces/web/src/lib/api/projects.ts +12 -12
  254. package/src/interfaces/web/src/lib/api/routines.ts +7 -7
  255. package/src/interfaces/web/src/lib/api/sessions.ts +2 -2
  256. package/src/interfaces/web/src/lib/api/skills.ts +11 -11
  257. package/src/interfaces/web/src/lib/api/super_agent.ts +3 -3
  258. package/src/interfaces/web/src/lib/api/tasks.ts +12 -12
  259. package/src/interfaces/web/src/lib/api/telegram.ts +14 -14
  260. package/src/interfaces/web/src/lib/api/tools.ts +1 -1
  261. package/src/interfaces/web/src/lib/api/vars.ts +4 -4
  262. package/src/interfaces/web/src/lib/api/voice.ts +6 -6
  263. package/src/interfaces/web/src/screens/base/AgentDefaultsTab.tsx +1 -1
  264. package/src/interfaces/web/src/screens/base/GlobalTasksTab.tsx +1 -1
  265. package/src/interfaces/web/src/screens/base/LogsTab.tsx +3 -3
  266. package/src/interfaces/web/src/screens/base/SessionsTab.tsx +1 -1
  267. package/src/interfaces/web/src/screens/modules/CodeScreen.tsx +1 -1
  268. package/src/interfaces/web/src/screens/modules/DeckScreen.tsx +1 -1
  269. package/src/interfaces/web/src/screens/modules/DesktopScreen.tsx +1 -1
  270. package/src/interfaces/web/src/screens/modules/VoiceScreen.tsx +1 -1
  271. package/src/interfaces/web/src/screens/project/AgentDetailScreen.tsx +8 -8
  272. package/src/interfaces/web/src/screens/project/AgentsTab.tsx +2 -2
  273. package/src/interfaces/web/src/screens/project/ChatTab.tsx +3 -3
  274. package/src/interfaces/web/src/screens/project/ConfigTab.tsx +1 -1
  275. package/src/interfaces/web/src/screens/project/McpsTab.tsx +3 -3
  276. package/src/interfaces/web/src/screens/project/Overview.tsx +6 -6
  277. package/src/interfaces/web/src/screens/project/RoutinesTab.tsx +2 -2
  278. package/src/interfaces/web/src/screens/project/StructureTab.tsx +1 -1
  279. package/src/interfaces/web/src/screens/project/TasksTab.tsx +1 -1
  280. package/src/interfaces/web/src/screens/project/VarsTab.tsx +1 -1
  281. package/src/interfaces/web/vite.config.ts +13 -18
  282. package/src/interfaces/web/dist/assets/index-BWWpTTSd.js +0 -824
  283. package/src/interfaces/web/dist/assets/index-BWWpTTSd.js.map +0 -1
  284. package/src/skills/apc-context/SKILL.md +0 -159
  285. /package/src/{host/daemon → core}/runtimes/_spawn.js +0 -0
  286. /package/src/{host/daemon → core}/runtimes/aider.js +0 -0
  287. /package/src/{host/daemon → core}/runtimes/antigravity.js +0 -0
  288. /package/src/{host/daemon → core}/runtimes/claude-code.js +0 -0
  289. /package/src/{host/daemon → core}/runtimes/codex.js +0 -0
  290. /package/src/{host/daemon → core}/runtimes/cursor-agent.js +0 -0
  291. /package/src/{host/daemon → core}/runtimes/gemini-cli.js +0 -0
  292. /package/src/{host/daemon → core}/runtimes/index.js +0 -0
  293. /package/src/{host/daemon → core}/runtimes/opencode.js +0 -0
  294. /package/src/{host/daemon → core}/runtimes/qwen-code.js +0 -0
@@ -1,564 +1,15 @@
1
- // Tool Registry on-demand for APX.
1
+ // Tool registry lookup and HTTP surface.
2
2
  //
3
- // Endpoints registered by api.js:
4
- // GET /tools → lightweight list [{name, description, category, schema_url}]
5
- // GET /tools/:name → full schema + examples
6
- // POST /tools/:name/call → execute the tool (proxy to internal handler)
3
+ // Endpoints registered by api.js (mounted under /api):
4
+ // GET /api/tools → lightweight list [{name, description, category, schema_url}]
5
+ // GET /api/tools/:name → full schema + examples
6
+ // POST /api/tools/:name/call → execute the tool (proxy to internal handler)
7
7
  //
8
- // Tools that already exist as HTTP endpoints are listed here with their
9
- // endpoint targets no code duplication.
8
+ // The catalog itself lives in ./catalog.js and the in-process executors in
9
+ // ./inline-handlers.js. This module only indexes and serves them.
10
+ import { TOOL_DEFINITIONS } from "./catalog.js";
11
+ import { makeInlineHandlers } from "./inline-handlers.js";
10
12
 
11
- // ---------------------------------------------------------------------------
12
- // Tool definitions
13
- // ---------------------------------------------------------------------------
14
-
15
- const TOOL_DEFINITIONS = [
16
- // ── file ──────────────────────────────────────────────────────────────────
17
- {
18
- name: "read_file",
19
- category: "file",
20
- description: "Read the contents of a file inside the project.",
21
- endpoint: { method: "GET", path: "/files", query: ["path", "project"] },
22
- parameters: {
23
- type: "object",
24
- properties: {
25
- path: { type: "string", description: "Relative path inside the project" },
26
- project: { type: "string", description: "Project ID or path (optional)" },
27
- },
28
- required: ["path"],
29
- },
30
- examples: [{ path: "src/index.js" }],
31
- },
32
- {
33
- name: "write_file",
34
- category: "file",
35
- description: "Write or overwrite a file inside the project.",
36
- endpoint: { method: "POST", path: "/files" },
37
- parameters: {
38
- type: "object",
39
- properties: {
40
- path: { type: "string" },
41
- content: { type: "string" },
42
- project: { type: "string" },
43
- },
44
- required: ["path", "content"],
45
- },
46
- examples: [{ path: "notes.md", content: "# Hello" }],
47
- },
48
- {
49
- name: "list_files",
50
- category: "file",
51
- description: "List files and directories inside a project path.",
52
- endpoint: { method: "GET", path: "/files" },
53
- parameters: {
54
- type: "object",
55
- properties: {
56
- path: { type: "string", description: "Sub-path to list (optional)" },
57
- project: { type: "string" },
58
- },
59
- },
60
- examples: [{ path: "src" }],
61
- },
62
- {
63
- name: "search_files",
64
- category: "file",
65
- description: "Search for files by name glob or content pattern in the project.",
66
- endpoint: { method: "GET", path: "/files/search" },
67
- parameters: {
68
- type: "object",
69
- properties: {
70
- q: { type: "string", description: "Search query (filename or content)" },
71
- project: { type: "string" },
72
- },
73
- required: ["q"],
74
- },
75
- examples: [{ q: "*.config.js" }],
76
- },
77
-
78
- // ── shell ─────────────────────────────────────────────────────────────────
79
- {
80
- name: "run_command",
81
- category: "shell",
82
- description: "Execute a shell command in the project directory. Returns stdout, stderr, exit_code.",
83
- endpoint: { method: "POST", path: "/run" },
84
- parameters: {
85
- type: "object",
86
- properties: {
87
- cmd: { type: "string", description: "Shell command to run" },
88
- cwd: { type: "string", description: "Working directory override" },
89
- project: { type: "string" },
90
- timeout_ms: { type: "integer", default: 30000 },
91
- },
92
- required: ["cmd"],
93
- },
94
- examples: [{ cmd: "ls -la" }, { cmd: "git log --oneline -5" }],
95
- },
96
-
97
- // ── memory ────────────────────────────────────────────────────────────────
98
- {
99
- name: "memory_get",
100
- category: "memory",
101
- description: "Read the memory.md of the default agent in a project.",
102
- endpoint: { method: "GET", path: "/memory" },
103
- parameters: {
104
- type: "object",
105
- properties: {
106
- project: { type: "string" },
107
- },
108
- },
109
- examples: [{}],
110
- },
111
- {
112
- name: "memory_set",
113
- category: "memory",
114
- description: "Overwrite the memory.md of the default agent in a project.",
115
- endpoint: { method: "POST", path: "/memory" },
116
- parameters: {
117
- type: "object",
118
- properties: {
119
- body: { type: "string", description: "Full content to write" },
120
- project: { type: "string" },
121
- },
122
- required: ["body"],
123
- },
124
- examples: [{ body: "# Agent Memory\n\n- Remember to greet the user." }],
125
- },
126
- {
127
- name: "memory_append",
128
- category: "memory",
129
- description: "Append text to the agent memory.md (read-modify-write).",
130
- endpoint: null, // implemented inline in the call handler
131
- parameters: {
132
- type: "object",
133
- properties: {
134
- text: { type: "string" },
135
- project: { type: "string" },
136
- },
137
- required: ["text"],
138
- },
139
- examples: [{ text: "\n- New fact to remember." }],
140
- },
141
- {
142
- name: "memory_list",
143
- category: "memory",
144
- description: "List all agents that have memory files in a project.",
145
- endpoint: null,
146
- parameters: {
147
- type: "object",
148
- properties: { project: { type: "string" } },
149
- },
150
- examples: [{}],
151
- },
152
-
153
- // ── session ───────────────────────────────────────────────────────────────
154
- {
155
- name: "session_list",
156
- category: "session",
157
- description: "List sessions for an agent in a project.",
158
- endpoint: { method: "GET", path: "/projects/:pid/agents/:slug/sessions" },
159
- parameters: {
160
- type: "object",
161
- properties: {
162
- project: { type: "string", description: "Project ID" },
163
- agent: { type: "string", description: "Agent slug" },
164
- },
165
- required: ["project", "agent"],
166
- },
167
- examples: [{ project: "1", agent: "sofia" }],
168
- },
169
- {
170
- name: "session_get",
171
- category: "session",
172
- description: "Get a session by filename.",
173
- endpoint: { method: "GET", path: "/projects/:pid/sessions/:sid" },
174
- parameters: {
175
- type: "object",
176
- properties: {
177
- project: { type: "string" },
178
- session_id: { type: "string" },
179
- },
180
- required: ["project", "session_id"],
181
- },
182
- examples: [{ project: "1", session_id: "2026-05-01-planning.md" }],
183
- },
184
- {
185
- name: "session_search",
186
- category: "session",
187
- description: "Search session content by text query across all agents in a project.",
188
- endpoint: { method: "GET", path: "/sessions/search" },
189
- parameters: {
190
- type: "object",
191
- properties: {
192
- q: { type: "string", description: "Search query" },
193
- project: { type: "string" },
194
- limit: { type: "integer", default: 20 },
195
- },
196
- required: ["q"],
197
- },
198
- examples: [{ q: "authentication bug" }],
199
- },
200
- {
201
- name: "session_compact",
202
- category: "session",
203
- description: "Compact (summarise and compress) a session conversation.",
204
- endpoint: { method: "POST", path: "/sessions/:id/compact" },
205
- parameters: {
206
- type: "object",
207
- properties: {
208
- session_id: { type: "string" },
209
- project: { type: "string" },
210
- agent: { type: "string" },
211
- model: { type: "string" },
212
- },
213
- required: ["project", "agent", "session_id"],
214
- },
215
- examples: [{ project: "1", agent: "sofia", session_id: "2026-05-01-planning.md" }],
216
- },
217
-
218
- // ── mcp ───────────────────────────────────────────────────────────────────
219
- {
220
- name: "mcp_list",
221
- category: "mcp",
222
- description: "List all MCP servers registered in a project.",
223
- endpoint: { method: "GET", path: "/mcp" },
224
- parameters: {
225
- type: "object",
226
- properties: { project: { type: "string" } },
227
- },
228
- examples: [{}],
229
- },
230
- {
231
- name: "mcp_run",
232
- category: "mcp",
233
- description: "Call a tool on an MCP server.",
234
- endpoint: { method: "POST", path: "/mcp/run" },
235
- parameters: {
236
- type: "object",
237
- properties: {
238
- name: { type: "string", description: "MCP server name" },
239
- tool: { type: "string", description: "Tool name on that server" },
240
- params: { type: "object" },
241
- project: { type: "string" },
242
- },
243
- required: ["name", "tool"],
244
- },
245
- examples: [{ name: "filesystem", tool: "list_directory", params: { path: "/tmp" } }],
246
- },
247
-
248
- // ── glob / grep ───────────────────────────────────────────────────────────
249
- {
250
- name: "glob",
251
- category: "file",
252
- description: "List files matching a glob pattern (e.g. **/*.js). Uses native Node.js glob.",
253
- endpoint: { method: "POST", path: "/tools/glob" },
254
- parameters: {
255
- type: "object",
256
- properties: {
257
- pattern: { type: "string", description: "Glob pattern, e.g. src/**/*.ts" },
258
- cwd: { type: "string", description: "Base directory (absolute path)" },
259
- dot: { type: "boolean", default: false, description: "Include dotfiles" },
260
- absolute: { type: "boolean", default: false },
261
- limit: { type: "integer", default: 500 },
262
- },
263
- required: ["pattern"],
264
- },
265
- examples: [
266
- { pattern: "**/*.js", cwd: "/my/project" },
267
- { pattern: "src/**/*.ts", cwd: "/my/project", limit: 100 },
268
- ],
269
- },
270
- {
271
- name: "grep",
272
- category: "file",
273
- description: "Search file contents by regex pattern. Uses ripgrep when available, pure Node.js fallback.",
274
- endpoint: { method: "POST", path: "/tools/grep" },
275
- parameters: {
276
- type: "object",
277
- properties: {
278
- pattern: { type: "string", description: "Regex to search for" },
279
- path: { type: "string", description: "Directory or file to search in" },
280
- glob: { type: "string", description: "Glob filter for files, e.g. *.ts" },
281
- case_sensitive: { type: "boolean", default: false },
282
- context: { type: "integer", default: 0, description: "Lines of context around matches" },
283
- limit: { type: "integer", default: 100 },
284
- },
285
- required: ["pattern"],
286
- },
287
- examples: [
288
- { pattern: "export default", path: "/my/project/src", glob: "*.js" },
289
- { pattern: "TODO|FIXME", path: "/my/project", context: 2 },
290
- ],
291
- },
292
-
293
- // ── fetch (native HTTP, no browser) ───────────────────────────────────────
294
- {
295
- name: "http_get",
296
- category: "fetch",
297
- description: "Native HTTP GET — fast, no headless browser. Use for REST APIs, raw HTML, JSON endpoints.",
298
- endpoint: { method: "POST", path: "/tools/fetch/get" },
299
- parameters: {
300
- type: "object",
301
- properties: {
302
- url: { type: "string" },
303
- headers: { type: "object" },
304
- timeout_ms: { type: "number", default: 30000 },
305
- },
306
- required: ["url"],
307
- },
308
- examples: [{ url: "https://api.github.com/repos/anthropics/anthropic-sdk-typescript" }],
309
- },
310
- {
311
- name: "http_post",
312
- category: "fetch",
313
- description: "Native HTTP POST — sends body as JSON when body is an object. Use for REST APIs.",
314
- endpoint: { method: "POST", path: "/tools/fetch/post" },
315
- parameters: {
316
- type: "object",
317
- properties: {
318
- url: { type: "string" },
319
- body: { description: "Object → JSON-stringified. String → sent as-is." },
320
- headers: { type: "object" },
321
- timeout_ms: { type: "number", default: 30000 },
322
- json: { type: "boolean", description: "Force JSON parsing of response body." },
323
- },
324
- required: ["url"],
325
- },
326
- examples: [{ url: "https://api.example.com/items", body: { name: "foo" } }],
327
- },
328
- {
329
- name: "http_request",
330
- category: "fetch",
331
- description: "Generic HTTP request with full control over method, headers, body, timeout.",
332
- endpoint: { method: "POST", path: "/tools/fetch/request" },
333
- parameters: {
334
- type: "object",
335
- properties: {
336
- url: { type: "string" },
337
- method: { type: "string", default: "GET" },
338
- headers: { type: "object" },
339
- body: {},
340
- timeout_ms: { type: "number", default: 30000 },
341
- json: { type: "boolean" },
342
- },
343
- required: ["url"],
344
- },
345
- examples: [{ url: "https://api.example.com/x", method: "DELETE" }],
346
- },
347
-
348
- // ── browser (Puppeteer-backed — heavier, launches Chromium lazily) ────────
349
- {
350
- name: "browser_navigate",
351
- category: "browser",
352
- description: "Navigate the headless browser to a URL. Launches Chromium lazily on first call. Auto-retries and falls back to a more permissive wait strategy on redirect-heavy sites.",
353
- endpoint: { method: "POST", path: "/tools/browser/navigate" },
354
- parameters: {
355
- type: "object",
356
- properties: {
357
- url: { type: "string" },
358
- wait_until: {
359
- type: "string",
360
- enum: ["load", "domcontentloaded", "networkidle0", "networkidle2"],
361
- description: "Puppeteer wait strategy (default networkidle2). Use 'domcontentloaded' for slow/redirect-heavy sites; navigate auto-falls back to it on failure anyway.",
362
- },
363
- launch_options: { type: "object", description: "Puppeteer launch overrides (headless, args, defaultViewport, etc.)." },
364
- allow_dangerous: { type: "boolean", description: "Allow dangerous launch args (--no-sandbox, --single-process, etc.)." },
365
- },
366
- required: ["url"],
367
- },
368
- examples: [{ url: "https://example.com" }],
369
- },
370
- {
371
- name: "browser_screenshot",
372
- category: "browser",
373
- description: "Take a screenshot of the current browser page (or an element via selector). Returns { base64, path?, bytes, url }. To send via Telegram, prefer `save_to_tmp: true` and pass the returned `path` to send_telegram({photo_path}); otherwise pass `base64` straight to send_telegram({photo_base64}). NEVER include the base64 in any text field — Telegram does not render it.",
374
- endpoint: { method: "POST", path: "/tools/browser/screenshot" },
375
- parameters: {
376
- type: "object",
377
- properties: {
378
- selector: { type: "string", description: "CSS selector of element to capture. Omit for full viewport/page." },
379
- full_page: { type: "boolean", default: false },
380
- width: { type: "number", description: "Viewport width (capped at 1920)." },
381
- height: { type: "number", description: "Viewport height (capped at 1080)." },
382
- encoded: { type: "boolean", description: "Also return a data:image/png;base64 URI in response." },
383
- save_path: { type: "string", description: "Absolute path to write the PNG. Returns it in `path`." },
384
- save_to_tmp: { type: "boolean", description: "Auto-write to <os.tmpdir>/apx-screenshots/screenshot-<ts>.png. Returns the path." },
385
- },
386
- },
387
- examples: [{}, { selector: "#hero" }, { save_to_tmp: true }],
388
- },
389
- {
390
- name: "browser_click",
391
- category: "browser",
392
- description: "Click a CSS selector on the current browser page.",
393
- endpoint: { method: "POST", path: "/tools/browser/click" },
394
- parameters: {
395
- type: "object",
396
- properties: { selector: { type: "string" } },
397
- required: ["selector"],
398
- },
399
- examples: [{ selector: "button#submit" }],
400
- },
401
- {
402
- name: "browser_type",
403
- category: "browser",
404
- description: "Type text into a CSS selector. Uses focus + Ctrl+A + Backspace to clear, then types with realistic delay.",
405
- endpoint: { method: "POST", path: "/tools/browser/type" },
406
- parameters: {
407
- type: "object",
408
- properties: {
409
- selector: { type: "string" },
410
- text: { type: "string" },
411
- clear: { type: "boolean", default: true },
412
- },
413
- required: ["selector", "text"],
414
- },
415
- examples: [{ selector: "input#search", text: "hello world" }],
416
- },
417
- {
418
- name: "browser_select",
419
- category: "browser",
420
- description: "Choose an option in a <select> element by its value.",
421
- endpoint: { method: "POST", path: "/tools/browser/select" },
422
- parameters: {
423
- type: "object",
424
- properties: {
425
- selector: { type: "string" },
426
- value: { type: "string" },
427
- },
428
- required: ["selector", "value"],
429
- },
430
- examples: [{ selector: "select#country", value: "AR" }],
431
- },
432
- {
433
- name: "browser_hover",
434
- category: "browser",
435
- description: "Hover the cursor over an element (triggers tooltips, dropdowns, hover states).",
436
- endpoint: { method: "POST", path: "/tools/browser/hover" },
437
- parameters: {
438
- type: "object",
439
- properties: { selector: { type: "string" } },
440
- required: ["selector"],
441
- },
442
- examples: [{ selector: "nav .menu-item" }],
443
- },
444
- {
445
- name: "browser_evaluate",
446
- category: "browser",
447
- description: "Execute JavaScript in the page context. Captures the script's console.log/info/warn/error output and returns it alongside the result.",
448
- endpoint: { method: "POST", path: "/tools/browser/evaluate" },
449
- parameters: {
450
- type: "object",
451
- properties: { code: { type: "string", description: "JS code to eval (function body)." } },
452
- required: ["code"],
453
- },
454
- examples: [{ code: "return document.title;" }],
455
- },
456
- {
457
- name: "browser_get_text",
458
- category: "browser",
459
- description: "Extract readable text from the current page (or a single element). Strips script/style/nav/header/footer.",
460
- endpoint: { method: "POST", path: "/tools/browser/get_text" },
461
- parameters: {
462
- type: "object",
463
- properties: { selector: { type: "string", description: "Optional CSS selector." } },
464
- },
465
- examples: [{}, { selector: "article" }],
466
- },
467
- {
468
- name: "browser_get_content",
469
- category: "browser",
470
- description: "Return raw innerHTML of the page or a single element (truncated at 1MB).",
471
- endpoint: { method: "POST", path: "/tools/browser/get_content" },
472
- parameters: {
473
- type: "object",
474
- properties: { selector: { type: "string" } },
475
- },
476
- examples: [{}, { selector: "main" }],
477
- },
478
- {
479
- name: "browser_wait_for_selector",
480
- category: "browser",
481
- description: "Wait until a CSS selector appears on the page.",
482
- endpoint: { method: "POST", path: "/tools/browser/wait_for_selector" },
483
- parameters: {
484
- type: "object",
485
- properties: {
486
- selector: { type: "string" },
487
- timeout: { type: "number", default: 30000 },
488
- },
489
- required: ["selector"],
490
- },
491
- examples: [{ selector: ".results-loaded" }],
492
- },
493
- {
494
- name: "browser_close",
495
- category: "browser",
496
- description: "Close the headless browser and free resources.",
497
- endpoint: { method: "POST", path: "/tools/browser/close" },
498
- parameters: { type: "object", properties: {} },
499
- examples: [{}],
500
- },
501
-
502
- // ── search ────────────────────────────────────────────────────────────────
503
- {
504
- name: "web_search",
505
- category: "search",
506
- description: "Search the web. Modes: auto (tries DDG → Brave → Browser), ddg, brave, browser.",
507
- endpoint: { method: "POST", path: "/tools/search" },
508
- parameters: {
509
- type: "object",
510
- properties: {
511
- query: { type: "string" },
512
- mode: { type: "string", enum: ["auto", "ddg", "brave", "browser"], default: "auto" },
513
- limit: { type: "integer", default: 5 },
514
- },
515
- required: ["query"],
516
- },
517
- examples: [
518
- { query: "APC agent project context standard" },
519
- { query: "site:github.com puppeteer examples", mode: "ddg" },
520
- ],
521
- },
522
-
523
- // ── agents ────────────────────────────────────────────────────────────────
524
- {
525
- name: "agent_list",
526
- category: "agents",
527
- description: "List all agents in a project.",
528
- endpoint: { method: "GET", path: "/projects/:pid/agents" },
529
- parameters: {
530
- type: "object",
531
- properties: { project: { type: "string" } },
532
- required: ["project"],
533
- },
534
- examples: [{ project: "1" }],
535
- },
536
- {
537
- name: "agent_get",
538
- category: "agents",
539
- description: "Get details + memory for a specific agent.",
540
- endpoint: { method: "GET", path: "/projects/:pid/agents/:slug" },
541
- parameters: {
542
- type: "object",
543
- properties: {
544
- project: { type: "string" },
545
- agent: { type: "string" },
546
- },
547
- required: ["project", "agent"],
548
- },
549
- examples: [{ project: "1", agent: "sofia" }],
550
- },
551
-
552
- // ── project ───────────────────────────────────────────────────────────────
553
- {
554
- name: "project_info",
555
- category: "project",
556
- description: "List all registered projects and their metadata.",
557
- endpoint: { method: "GET", path: "/projects" },
558
- parameters: { type: "object", properties: {} },
559
- examples: [{}],
560
- },
561
- ];
562
13
 
563
14
  // ---------------------------------------------------------------------------
564
15
  // Index for fast lookup
@@ -571,7 +22,7 @@ function listTools() {
571
22
  name,
572
23
  description,
573
24
  category,
574
- schema_url: `/tools/${name}`,
25
+ schema_url: `/api/tools/${name}`,
575
26
  endpoint_method: endpoint?.method || "inline",
576
27
  endpoint_path: endpoint?.path || null,
577
28
  }));
@@ -587,60 +38,10 @@ function getTool(name) {
587
38
  parameters: t.parameters,
588
39
  examples: t.examples || [],
589
40
  endpoint: t.endpoint || null,
590
- schema_url: `/tools/${name}`,
41
+ schema_url: `/api/tools/${name}`,
591
42
  };
592
43
  }
593
44
 
594
- // ---------------------------------------------------------------------------
595
- // Inline call handlers for tools without a dedicated HTTP endpoint
596
- // ---------------------------------------------------------------------------
597
-
598
- function makeInlineHandlers({ projects, registries }) {
599
- return {
600
- memory_append: async (body) => {
601
- const { default: fetch } = await import("node-fetch");
602
- const base = `http://localhost:${process.env.APX_PORT || 7430}`;
603
- // GET current
604
- const getRes = await fetch(`${base}/memory${body.project ? `?project=${body.project}` : ""}`);
605
- if (!getRes.ok) throw new Error(`memory_get failed: ${getRes.status}`);
606
- const { body: current } = await getRes.json();
607
- // POST updated
608
- const text = body.text || "";
609
- const postRes = await fetch(`${base}/memory${body.project ? `?project=${body.project}` : ""}`, {
610
- method: "POST",
611
- headers: { "content-type": "application/json" },
612
- body: JSON.stringify({ body: current + text }),
613
- });
614
- if (!postRes.ok) throw new Error(`memory_set failed: ${postRes.status}`);
615
- return { ok: true, appended_chars: text.length };
616
- },
617
-
618
- memory_list: async (body) => {
619
- const { default: fs } = await import("node:fs");
620
- const { default: path } = await import("node:path");
621
- const { readAgents } = await import("../parser.js");
622
- const { agentMemoryPath } = await import("../agent-memory.js");
623
- // Find the project
624
- const all = projects.list();
625
- let p = null;
626
- if (body.project) {
627
- const ref = String(body.project);
628
- const found = all.find((x) => String(x.id) === ref || x.path === ref);
629
- p = found ? projects.get(found.id) : null;
630
- }
631
- if (!p) p = projects.get(all.filter((x) => x.id !== 0)[0]?.id) || projects.get(0);
632
- if (!p) throw new Error("no project registered");
633
- const result = readAgents(p.path).map((agent) => {
634
- const slug = agent.slug;
635
- const memPath = agentMemoryPath(p, slug);
636
- if (!fs.existsSync(memPath)) return null;
637
- const stat = fs.statSync(memPath);
638
- return { agent: slug, path: memPath, size: stat.size, mtime: stat.mtime };
639
- }).filter(Boolean);
640
- return { project: p.path, agents_with_memory: result };
641
- },
642
- };
643
- }
644
45
 
645
46
  // ---------------------------------------------------------------------------
646
47
  // Express router factory
@@ -651,19 +52,19 @@ export function buildRegistryRouter(express, ctx) {
651
52
  const router = express.Router();
652
53
  const inlineHandlers = makeInlineHandlers({ projects, registries });
653
54
 
654
- // GET /tools — lightweight list
55
+ // GET /api/tools — lightweight list
655
56
  router.get("/", (_req, res) => {
656
57
  res.json(listTools());
657
58
  });
658
59
 
659
- // GET /tools/:name — full schema
60
+ // GET /api/tools/:name — full schema
660
61
  router.get("/:name", (req, res) => {
661
62
  const tool = getTool(req.params.name);
662
63
  if (!tool) return res.status(404).json({ error: `tool "${req.params.name}" not found` });
663
64
  res.json(tool);
664
65
  });
665
66
 
666
- // POST /tools/:name/call — execute tool
67
+ // POST /api/tools/:name/call — execute tool
667
68
  router.post("/:name/call", async (req, res) => {
668
69
  const { name } = req.params;
669
70
  const toolDef = TOOL_MAP.get(name);
@@ -703,7 +104,19 @@ export function buildRegistryRouter(express, ctx) {
703
104
  const method = toolDef.endpoint.method || "GET";
704
105
  let fetchUrl = `${base}${urlPath}`;
705
106
 
706
- let fetchOpts = { method, headers: { "content-type": "application/json" } };
107
+ // Forward the caller's bearer. Every /api route is authenticated, and
108
+ // this proxy never sent one — so all 33 endpoint-backed tools answered
109
+ // 401 and only the 2 inline handlers worked. The tool call is made on
110
+ // behalf of an already-authenticated caller, so its credential carries.
111
+ const fetchOpts = {
112
+ method,
113
+ headers: {
114
+ "content-type": "application/json",
115
+ ...(req.get("authorization")
116
+ ? { authorization: req.get("authorization") }
117
+ : {}),
118
+ },
119
+ };
707
120
 
708
121
  if (method === "GET") {
709
122
  // Append body fields as query params
@@ -732,4 +145,7 @@ export function buildRegistryRouter(express, ctx) {
732
145
  return router;
733
146
  }
734
147
 
735
- export { listTools, getTool, TOOL_DEFINITIONS };
148
+ // TOOL_DEFINITIONS is re-exported so the agent-side bridge
149
+ // (core/agent/tools/registry-bridge.js) keeps its existing import path.
150
+ export { listTools, getTool };
151
+ export { TOOL_DEFINITIONS } from "./catalog.js";