u-foo 3.1.6 → 4.0.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 (193) hide show
  1. package/README.md +172 -13
  2. package/README.zh-CN.md +108 -13
  3. package/SKILLS/ufoo/SKILL.md +15 -3
  4. package/SKILLS/ufoo-bus/SKILL.md +21 -1
  5. package/bin/uclaude.js +4 -0
  6. package/bin/ucodex.js +4 -0
  7. package/bin/ufoo.js +3 -1
  8. package/dist/tui/darwin-arm64/ufoo-tui +0 -0
  9. package/dist/tui/darwin-x64/ufoo-tui +0 -0
  10. package/dist/tui/linux-arm64/ufoo-tui +0 -0
  11. package/dist/tui/linux-x64/ufoo-tui +0 -0
  12. package/package.json +10 -3
  13. package/scripts/postinstall-skills.js +53 -0
  14. package/scripts/postinstall.js +11 -16
  15. package/scripts/smoke-native-messages.js +214 -0
  16. package/src/agents/activity/activityStateWriter.js +37 -38
  17. package/src/agents/capabilities/agentManagement/index.js +4 -0
  18. package/src/agents/capabilities/agentManagement/service.js +113 -0
  19. package/src/agents/capabilities/agentRouting/index.js +4 -0
  20. package/src/agents/capabilities/coding/index.js +32 -0
  21. package/src/agents/capabilities/coordination/index.js +37 -0
  22. package/src/agents/capabilities/globalRouting/index.js +5 -0
  23. package/src/agents/capabilities/groups/index.js +3 -0
  24. package/src/agents/capabilities/index.js +25 -0
  25. package/src/agents/capabilities/planning/index.js +123 -0
  26. package/src/agents/capabilities/planning/main.js +28 -0
  27. package/src/agents/capabilities/projectDiscovery/index.js +3 -0
  28. package/src/agents/capabilities/scheduling/index.js +3 -0
  29. package/src/agents/capabilities/sharedMemory/index.js +4 -0
  30. package/src/agents/capabilities/skills/index.js +12 -0
  31. package/src/agents/capabilities/taskExecution/index.js +3 -0
  32. package/src/agents/capabilities/taskReports/index.js +6 -0
  33. package/src/agents/controller/controllerToolExecutor.js +6 -4
  34. package/src/agents/controller/loopRuntime.js +85 -221
  35. package/src/agents/controller/ufooAgent.js +1 -0
  36. package/src/agents/internal/internalRunner.js +103 -32
  37. package/src/agents/launch/launcher.js +88 -6
  38. package/src/agents/launch/nativeCapabilities.js +40 -0
  39. package/src/agents/launch/nativeMessages.js +362 -0
  40. package/src/agents/launch/notifier.js +13 -18
  41. package/src/agents/launch/readyDetector.js +26 -12
  42. package/src/agents/profiles/coding.js +6 -0
  43. package/src/agents/profiles/globalRouter.js +2 -0
  44. package/src/agents/profiles/main.js +5 -0
  45. package/src/agents/prompts/groupBootstrap.js +10 -0
  46. package/src/agents/prompts/mainAgent.js +39 -0
  47. package/src/agents/prompts/native/tasks.js +2 -2
  48. package/src/agents/prompts/native/ufoo.js +3 -0
  49. package/src/agents/providers/claudeEventTranslator.js +6 -1
  50. package/src/agents/providers/claudeThreadProvider.js +44 -2
  51. package/src/agents/providers/codexEventTranslator.js +47 -7
  52. package/src/agents/providers/codexThreadProvider.js +3 -2
  53. package/src/agents/providers/controllerJsonTransport.js +28 -0
  54. package/src/agents/providers/credentials/claude.js +10 -3
  55. package/src/agents/providers/nativeTransport.js +1135 -0
  56. package/src/agents/providers/runtimeConfig.js +186 -0
  57. package/src/agents/providers/thinkingLevels.js +132 -0
  58. package/src/agents/providers/transports/anthropicMessagesTransport.js +121 -0
  59. package/src/agents/providers/transports/index.js +10 -0
  60. package/src/agents/providers/transports/openaiChatTransport.js +117 -0
  61. package/src/agents/providers/transports/openaiResponsesTransport.js +120 -0
  62. package/src/agents/providers/transports/responsesProtocol.js +499 -0
  63. package/src/agents/providers/transports/systemBlocks.js +16 -0
  64. package/src/agents/providers/transports/transportContract.js +50 -0
  65. package/src/agents/providers/transports/visionBlocks.js +151 -0
  66. package/src/agents/providers/upstreamTransport.js +13 -4
  67. package/src/agents/runtime/composeCapabilities.js +89 -0
  68. package/src/agents/runtime/context/commandStore.js +43 -0
  69. package/src/agents/runtime/context/contextWindow.js +119 -0
  70. package/src/agents/runtime/context/fileLock.js +36 -0
  71. package/src/agents/runtime/context/runtimeStore.js +126 -0
  72. package/src/agents/runtime/context/sessionJournal.js +360 -0
  73. package/src/agents/runtime/context/sessionStore.js +57 -0
  74. package/src/agents/runtime/core/agentLoop.js +270 -0
  75. package/src/agents/runtime/core/stableJson.js +29 -0
  76. package/src/agents/runtime/core/toolLoopGuard.js +55 -0
  77. package/src/agents/runtime/createAgentRuntime.js +247 -0
  78. package/src/agents/runtime/index.js +14 -0
  79. package/src/agents/runtime/protocol/faultHarness.js +90 -0
  80. package/src/agents/runtime/protocol/materialize.js +107 -0
  81. package/src/agents/runtime/protocol/toolCallLedger.js +221 -0
  82. package/src/agents/runtime/tasks/resourceLease.js +66 -0
  83. package/src/agents/runtime/tasks/scheduler.js +73 -0
  84. package/src/agents/runtime/tools/registry.js +57 -0
  85. package/src/app/chat/ChatController.js +14 -3
  86. package/src/app/chat/agentDirectory.js +8 -2
  87. package/src/app/chat/commandExecutor.js +36 -46
  88. package/src/app/chat/commands.js +14 -7
  89. package/src/app/chat/daemonConnection.js +58 -5
  90. package/src/app/chat/daemonMessageRouter.js +61 -3
  91. package/src/app/chat/inputSubmitHandler.js +14 -2
  92. package/src/app/chat/launchRequestContext.js +42 -0
  93. package/src/app/chat/multiWindow/paneManager.js +85 -165
  94. package/src/app/chat/streamState.js +3 -3
  95. package/src/app/chat/transport.js +1 -1
  96. package/src/app/cli/busCoreCommands.js +9 -0
  97. package/src/app/cli/features/doctor.js +33 -0
  98. package/src/app/cli/features/skills.js +16 -4
  99. package/src/app/cli/reportCoreCommands.js +37 -0
  100. package/src/app/cli/run.js +40 -39
  101. package/src/code/agent.js +16 -4
  102. package/src/code/context/artifacts.js +12 -11
  103. package/src/code/context/assembler.js +2 -1
  104. package/src/code/context/promptLayers.js +1 -13
  105. package/src/code/context/stableJson.js +2 -27
  106. package/src/code/contextWindow.js +2 -117
  107. package/src/code/conversation/sessionJournal.js +3 -349
  108. package/src/code/internalThread.js +100 -0
  109. package/src/code/nativeRunner.js +36 -2668
  110. package/src/code/protocol/faultHarness.js +2 -88
  111. package/src/code/protocol/materialize.js +2 -105
  112. package/src/code/protocol/toolCallLedger.js +5 -215
  113. package/src/code/providers/anthropicMessagesTransport.js +2 -118
  114. package/src/code/providers/openaiChatTransport.js +2 -114
  115. package/src/code/providers/openaiResponsesTransport.js +2 -117
  116. package/src/code/providers/responsesProtocol.js +2 -497
  117. package/src/code/providers/transportContract.js +2 -48
  118. package/src/code/providers/visionBlocks.js +2 -149
  119. package/src/code/sessionStore.js +24 -96
  120. package/src/code/thinkingLevels.js +1 -130
  121. package/src/code/toolLoopGuard.js +3 -49
  122. package/src/code/tools/artifactRead.js +1 -1
  123. package/src/code/tools/executor.js +373 -0
  124. package/src/code/tools/specs.js +312 -0
  125. package/src/config.js +81 -67
  126. package/src/coordination/bus/deliveryQueue.js +16 -2
  127. package/src/coordination/bus/index.js +2 -6
  128. package/src/coordination/bus/inject.js +13 -5
  129. package/src/coordination/bus/nativeReceipts.js +100 -0
  130. package/src/coordination/bus/queue.js +1 -3
  131. package/src/coordination/bus/utils.js +7 -3
  132. package/src/coordination/history/agentSurface.js +142 -0
  133. package/src/coordination/history/controllerSummary.js +23 -0
  134. package/src/coordination/memory/index.js +5 -21
  135. package/src/coordination/report/store.js +103 -83
  136. package/src/coordination/state/agentsStore.js +57 -3
  137. package/src/coordination/state/fileLock.js +2 -0
  138. package/src/coordination/state/workspaceAccess.js +36 -0
  139. package/src/runtime/contracts/agentMode.js +17 -0
  140. package/src/runtime/contracts/eventContract.js +3 -0
  141. package/src/runtime/contracts/uiProtocol.js +4 -0
  142. package/src/runtime/daemon/agentHost.js +375 -0
  143. package/src/runtime/daemon/busBridge.js +396 -0
  144. package/src/runtime/daemon/claudeChannel.js +159 -0
  145. package/src/runtime/daemon/controlPlaneService.js +27 -17
  146. package/src/runtime/daemon/cronOps.js +25 -17
  147. package/src/runtime/daemon/deliveryScheduler.js +32 -5
  148. package/src/runtime/daemon/executionPaths.js +30 -0
  149. package/src/runtime/daemon/globalDaemon.js +28 -1
  150. package/src/runtime/daemon/groupOrchestrator.js +1 -0
  151. package/src/runtime/daemon/index.js +114 -344
  152. package/src/runtime/daemon/ipcServer.js +32 -10
  153. package/src/runtime/daemon/mcpConfigure.js +113 -20
  154. package/src/runtime/daemon/mcpHttpServer.js +27 -5
  155. package/src/runtime/daemon/mcpServer.js +7 -4
  156. package/src/runtime/daemon/mcpStdioProxy.js +127 -10
  157. package/src/runtime/daemon/ops.js +22 -17
  158. package/src/runtime/daemon/promptRequest.js +23 -4
  159. package/src/runtime/daemon/providerSessions.js +67 -33
  160. package/src/runtime/daemon/reportControlBus.js +59 -25
  161. package/src/runtime/daemon/status.js +4 -0
  162. package/src/runtime/privacy/redactor.js +2 -2
  163. package/src/runtime/projects/identity.js +2 -1
  164. package/src/runtime/projects/registry.js +98 -38
  165. package/src/tools/controllerSchemas.js +24 -0
  166. package/src/tools/handlers/dispatchMessage.js +5 -2
  167. package/src/tools/handlers/listAgents.js +3 -1
  168. package/src/tools/handlers/readBusSummary.js +3 -1
  169. package/src/tools/handlers/readProjectRegistry.js +29 -2
  170. package/src/tools/handlers/routeAgent.js +35 -0
  171. package/src/tools/index.js +1 -0
  172. package/src/tools/registry.js +2 -0
  173. package/src/tools/schemaFixtures.js +16 -3
  174. package/src/tools/tier1/routeAgent.js +2 -2
  175. package/src/tools/tier2/runtimeCoordination.js +38 -0
  176. package/src/tools/types.js +2 -0
  177. package/src/ui/agentPresentation.js +109 -0
  178. package/src/ui/agentSurface.js +270 -0
  179. package/src/ui/format/banner.js +8 -11
  180. package/src/ui/format/startupBanner.js +50 -0
  181. package/src/ui/multiPaneBusMirror.js +29 -3
  182. package/src/ui/rustChatHost.js +170 -438
  183. package/src/ui/rustMultiSession.js +225 -51
  184. package/src/ui/rustUcodeHost.js +20 -87
  185. package/src/ui/settingsBridge.js +7 -4
  186. package/src/app/chat/agentEnter.js +0 -70
  187. package/src/app/chat/multiWindow/index.js +0 -310
  188. package/src/app/chat/multiWindow/paneLayout.js +0 -84
  189. package/src/app/chat/multiWindow/renderer.js +0 -420
  190. package/src/app/chat/multiWindow/virtualTerminal.js +0 -327
  191. package/src/app/chat/multiWindow/vtFrame.js +0 -93
  192. package/src/ui/multiWindowHandoff.js +0 -232
  193. package/src/ui/ptyHandoff.js +0 -23
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "u-foo",
3
- "version": "3.1.6",
3
+ "version": "4.0.0",
4
4
  "description": "Multi-Agent Workspace Protocol. Just add u. claude → uclaude, codex → ucodex.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "homepage": "https://ufoo.dev",
@@ -56,8 +56,8 @@
56
56
  "test:coverage": "jest --coverage"
57
57
  },
58
58
  "dependencies": {
59
- "@anthropic-ai/claude-agent-sdk": "^0.2.138",
60
- "@modelcontextprotocol/sdk": "^1.30.0",
59
+ "@anthropic-ai/claude-agent-sdk": "^0.2.141",
60
+ "@modelcontextprotocol/sdk": "^1.32.1",
61
61
  "@openai/codex-sdk": "^0.145.0",
62
62
  "@xterm/addon-serialize": "^0.14.0",
63
63
  "@xterm/headless": "^6.0.0",
@@ -65,10 +65,17 @@
65
65
  "commander": "^13.1.0",
66
66
  "gray-matter": "^4.0.3",
67
67
  "node-pty": "^1.1.0",
68
+ "proper-lockfile": "^4.1.2",
68
69
  "undici": "^6.28.0",
69
70
  "ws": "^8.19.0"
70
71
  },
71
72
  "devDependencies": {
72
73
  "jest": "^30.2.0"
74
+ },
75
+ "overrides": {
76
+ "js-yaml": {
77
+ "argparse": "^2.0.1"
78
+ },
79
+ "@hono/node-server": "^1.19.15"
73
80
  }
74
81
  }
@@ -13,6 +13,37 @@ const LEGACY_COMMAND_NAMES = Object.freeze([
13
13
  "ustatus",
14
14
  ]);
15
15
 
16
+ // A matching name is not ownership evidence: user-authored skills must survive
17
+ // npm install. Only links into this package (or another verified u-foo install)
18
+ // may be refreshed automatically.
19
+ function isManagedSkillLink(linkPath, source) {
20
+ try {
21
+ if (!fs.lstatSync(linkPath).isSymbolicLink()) return false;
22
+ const target = path.resolve(path.dirname(linkPath), fs.readlinkSync(linkPath));
23
+ if (target === path.resolve(source)) return true;
24
+ if (path.basename(target) !== path.basename(source)) return false;
25
+ const collection = path.basename(path.dirname(target));
26
+ if (!["SKILLS", "OPTIONAL_SKILLS"].includes(collection)) return false;
27
+ const manifest = JSON.parse(fs.readFileSync(path.join(target, "..", "..", "package.json"), "utf8"));
28
+ return manifest.name === "u-foo";
29
+ } catch { return false; }
30
+ }
31
+
32
+ function installManagedSkillLink(source, target) {
33
+ try {
34
+ fs.lstatSync(target);
35
+ if (!isManagedSkillLink(target, source)) return "conflict";
36
+ const current = path.resolve(path.dirname(target), fs.readlinkSync(target));
37
+ if (current === path.resolve(source)) return "unchanged";
38
+ fs.unlinkSync(target);
39
+ } catch (error) {
40
+ if (error.code !== "ENOENT") throw error;
41
+ }
42
+ fs.mkdirSync(path.dirname(target), { recursive: true });
43
+ fs.symlinkSync(source, target);
44
+ return "installed";
45
+ }
46
+
16
47
  function removeManagedSymlink(linkPath, expectedTarget) {
17
48
  try {
18
49
  const stat = fs.lstatSync(linkPath);
@@ -73,9 +104,31 @@ function removeLegacySkillAndCommandLinks({ pkgRoot, home, codexHome } = {}) {
73
104
  return removed;
74
105
  }
75
106
 
107
+ function refreshInstalledOptionalSkills({ pkgRoot, targetDirs = [] } = {}) {
108
+ const optionalRoot = path.join(pkgRoot, "OPTIONAL_SKILLS");
109
+ if (!fs.existsSync(optionalRoot)) return [];
110
+ const refreshed = [];
111
+ for (const entry of fs.readdirSync(optionalRoot, { withFileTypes: true })) {
112
+ const source = path.join(optionalRoot, entry.name);
113
+ if (!entry.isDirectory() || !fs.existsSync(path.join(source, "SKILL.md"))) continue;
114
+ for (const targetDir of new Set(targetDirs)) {
115
+ const target = path.join(targetDir, entry.name);
116
+ try { fs.lstatSync(target); } catch { continue; }
117
+ // Do not install new opt-in skills, and do not remove a skill when this
118
+ // checkout is already its source.
119
+ try { if (fs.realpathSync(target) === fs.realpathSync(source)) continue; } catch { /* stale link */ }
120
+ if (installManagedSkillLink(source, target) === "installed") refreshed.push(target);
121
+ }
122
+ }
123
+ return refreshed;
124
+ }
125
+
76
126
  module.exports = {
77
127
  RETIRED_DEFAULT_SKILLS,
78
128
  LEGACY_COMMAND_NAMES,
79
129
  removeManagedSymlink,
80
130
  removeLegacySkillAndCommandLinks,
131
+ refreshInstalledOptionalSkills,
132
+ installManagedSkillLink,
133
+ isManagedSkillLink,
81
134
  };
@@ -2,7 +2,7 @@
2
2
  const path = require("path");
3
3
  const fs = require("fs");
4
4
  const os = require("os");
5
- const { removeLegacySkillAndCommandLinks } = require("./postinstall-skills");
5
+ const { removeLegacySkillAndCommandLinks, refreshInstalledOptionalSkills, installManagedSkillLink } = require("./postinstall-skills");
6
6
 
7
7
  // Fix node-pty spawn-helper permissions on macOS (both arm64 and x64)
8
8
  const platforms = ["darwin-arm64", "darwin-x64"];
@@ -59,26 +59,16 @@ function collectSkillSources(pkgRoot) {
59
59
  return sources;
60
60
  }
61
61
 
62
- function forceSymlink(target, linkPath) {
63
- try {
64
- const existing = fs.lstatSync(linkPath);
65
- if (existing.isSymbolicLink() || existing.isFile() || existing.isDirectory()) {
66
- fs.rmSync(linkPath, { recursive: true, force: true });
67
- }
68
- } catch {
69
- // doesn't exist - fine
70
- }
71
- fs.symlinkSync(target, linkPath);
72
- }
73
-
74
62
  function installSkillDirs(targetDir, sources, label) {
75
63
  fs.mkdirSync(targetDir, { recursive: true });
76
-
64
+ let available = 0;
77
65
  for (const { name, dir } of sources) {
78
- forceSymlink(dir, path.join(targetDir, name));
66
+ if (installManagedSkillLink(dir, path.join(targetDir, name)) === "conflict") {
67
+ console.log(`[postinstall] Preserved existing user skill: ${path.join(targetDir, name)}`);
68
+ } else available += 1;
79
69
  }
80
70
 
81
- console.log(`[postinstall] Installed ${sources.length} ufoo skill(s) to ${label}`);
71
+ console.log(`[postinstall] ${available} ufoo skill(s) available in ${label}`);
82
72
  }
83
73
 
84
74
  // Install ufoo skills for Claude and Codex at npm install time.
@@ -100,6 +90,11 @@ try {
100
90
 
101
91
  installSkillDirs(path.join(codexHome, "skills"), sources, `${codexHome}/skills`);
102
92
  }
93
+ const refreshed = refreshInstalledOptionalSkills({
94
+ pkgRoot,
95
+ targetDirs: [path.join(home, ".claude", "skills"), path.join(codexHome, "skills"), path.join(home, ".agents", "skills")],
96
+ });
97
+ if (refreshed.length) console.log(`[postinstall] Refreshed ${refreshed.length} installed optional ufoo skill(s)`);
103
98
  } catch (err) {
104
99
  // Non-fatal - skills can be installed manually via `ufoo skills install`
105
100
  console.log(`[postinstall] Skipped skills install: ${err.message}`);
@@ -0,0 +1,214 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ // Optional local smoke test using installed vendor CLIs and an isolated fake
5
+ // model endpoint. No user settings, credentials or real inference are used.
6
+ const fs = require("fs");
7
+ const os = require("os");
8
+ const path = require("path");
9
+ const http = require("http");
10
+ const pty = require("node-pty");
11
+ const EventBus = require("../src/coordination/bus");
12
+ const { registerAgentFull } = require("../src/runtime/daemon/controlPlaneService");
13
+ const { resolveNativeMessageMode, setNativeMetadata } = require("../src/agents/launch/nativeMessages");
14
+ const Injector = require("../src/coordination/bus/inject");
15
+ const { getUfooPaths } = require("../src/coordination/state/paths");
16
+ const { loadAgentsData } = require("../src/coordination/state/agentsStore");
17
+
18
+ async function until(predicate, timeout = 20000) {
19
+ const deadline = Date.now() + timeout;
20
+ while (!predicate()) {
21
+ if (Date.now() > deadline) throw new Error("Native smoke condition timed out");
22
+ await new Promise((resolve) => setTimeout(resolve, 25));
23
+ }
24
+ }
25
+
26
+ function anthropicResponse(response, block) {
27
+ const messageId = "msg_ufoo_fixture";
28
+ const isTool = block.type === "tool_use";
29
+ response.writeHead(200, { "content-type": "text/event-stream", "cache-control": "no-cache" });
30
+ const send = (type, data) => response.write(`event: ${type}\ndata: ${JSON.stringify({ type, ...data })}\n\n`);
31
+ send("message_start", { message: { id: messageId, type: "message", role: "assistant", content: [], model: "fixture", stop_reason: null, stop_sequence: null, usage: { input_tokens: 1, output_tokens: 0 } } });
32
+ send("content_block_start", { index: 0, content_block: isTool ? { ...block, input: {} } : { type: "text", text: "" } });
33
+ send("content_block_delta", { index: 0, delta: isTool ? { type: "input_json_delta", partial_json: JSON.stringify(block.input) } : { type: "text_delta", text: block.text } });
34
+ send("content_block_stop", { index: 0 });
35
+ send("message_delta", { delta: { stop_reason: isTool ? "tool_use" : "end_turn", stop_sequence: null }, usage: { output_tokens: 1 } });
36
+ send("message_stop", {});
37
+ response.end();
38
+ }
39
+
40
+ async function main() {
41
+ const selected = process.argv[2] || "claude";
42
+ const legacyOptOut = process.argv.includes("--legacy");
43
+ // macOS's per-user temp path can exceed the Unix socket length limit once
44
+ // the wrapper's project-local bus socket suffix is appended.
45
+ const fixtureParent = process.platform === "darwin" ? "/private/tmp" : process.env.RUNNER_TEMP || os.tmpdir();
46
+ const root = fs.mkdtempSync(path.join(fixtureParent, "uf-smoke-"));
47
+ const ptyGroupsFile = path.join(root, "fixture-pty-groups");
48
+ const received = [];
49
+ let probeCalled = false;
50
+ const api = http.createServer((request, response) => {
51
+ let raw = "";
52
+ request.on("data", (chunk) => { raw += chunk; });
53
+ request.on("end", () => {
54
+ let body = {};
55
+ try { body = JSON.parse(raw || "{}"); } catch { /* non-model request */ }
56
+ if (request.url.includes("count_tokens")) {
57
+ response.writeHead(200, { "content-type": "application/json" }); response.end('{"input_tokens":1}'); return;
58
+ }
59
+ if (request.url.includes("messages")) {
60
+ const messages = JSON.stringify(body.messages || []);
61
+ const nonce = messages.match(/nonce ([0-9a-f]{48})/)?.[1];
62
+ const tool = body.tools?.find((item) => item.name.endsWith("__channel_ready"));
63
+ if (nonce && tool && !probeCalled) {
64
+ probeCalled = true;
65
+ anthropicResponse(response, { type: "tool_use", id: "tool_probe", name: tool.name, input: { nonce } });
66
+ } else {
67
+ for (const marker of ["ufoo_native_first", "ufoo_native_second"]) {
68
+ if (messages.includes(marker) && !received.includes(marker)) received.push(marker);
69
+ }
70
+ setTimeout(() => anthropicResponse(response, { type: "text", text: "Fixture message received." }), messages.includes("ufoo_native_first") ? 300 : 0);
71
+ }
72
+ return;
73
+ }
74
+ if (request.url.includes("responses")) {
75
+ const input = JSON.stringify(body.input || []);
76
+ for (const marker of ["ufoo_native_first", "ufoo_native_second"]) if (input.includes(marker) && !received.includes(marker)) received.push(marker);
77
+ response.writeHead(200, { "content-type": "text/event-stream" });
78
+ const item = { id: "msg_fixture", type: "message", role: "assistant", status: "completed", content: [{ type: "output_text", text: "Fixture message received.", annotations: [] }] };
79
+ const send = (data) => response.write(`data: ${JSON.stringify(data)}\n\n`);
80
+ send({ type: "response.created", response: { id: "resp_fixture", object: "response", status: "in_progress", output: [] } });
81
+ send({ type: "response.output_item.added", output_index: 0, item: { ...item, status: "in_progress", content: [] } });
82
+ send({ type: "response.output_text.delta", item_id: item.id, output_index: 0, content_index: 0, delta: "Fixture message received." });
83
+ send({ type: "response.output_item.done", output_index: 0, item });
84
+ setTimeout(() => {
85
+ send({ type: "response.completed", response: { id: "resp_fixture", object: "response", status: "completed", output: [item], usage: { input_tokens: 1, output_tokens: 1, total_tokens: 2, input_tokens_details: { cached_tokens: 0 }, output_tokens_details: { reasoning_tokens: 0 } } } });
86
+ response.end();
87
+ }, 300);
88
+ return;
89
+ }
90
+ response.writeHead(200, { "content-type": "application/json" }); response.end("{}");
91
+ });
92
+ });
93
+ await new Promise((resolve) => api.listen(0, "127.0.0.1", resolve));
94
+ const baseUrl = `http://127.0.0.1:${api.address().port}`;
95
+ const home = path.join(root, "home"); fs.mkdirSync(home);
96
+ const env = { PATH: process.env.PATH, LANG: process.env.LANG || "en_US.UTF-8", TERM: "xterm-256color", SHELL: process.env.SHELL || "/bin/sh", HOME: home, CODEX_HOME: path.join(home, "codex"), CLAUDE_CONFIG_DIR: path.join(home, "claude"), ANTHROPIC_API_KEY: "ufoo-local-fixture", ANTHROPIC_BASE_URL: baseUrl, DISABLE_UPDATES: "1" };
97
+ if (legacyOptOut) env.UFOO_NATIVE_MESSAGES = "0";
98
+ fs.mkdirSync(env.CODEX_HOME, { recursive: true });
99
+ fs.mkdirSync(env.CLAUDE_CONFIG_DIR, { recursive: true });
100
+ fs.writeFileSync(path.join(env.CLAUDE_CONFIG_DIR, ".claude.json"), JSON.stringify({ hasCompletedOnboarding: true, theme: "dark", customApiKeyResponses: { approved: [env.ANTHROPIC_API_KEY.slice(-20)], rejected: [] } }));
101
+ fs.writeFileSync(path.join(env.CODEX_HOME, "config.toml"), `model = "fixture"\nmodel_provider = "fixture"\n[model_providers.fixture]\nname = "fixture"\nbase_url = "${baseUrl}/v1"\nwire_api = "responses"\nrequires_openai_auth = false\nsupports_websockets = false\n`);
102
+ let terminal;
103
+ let output = "";
104
+ let exited = false;
105
+ try {
106
+ await new EventBus(root).init();
107
+ const agentType = selected === "codex" ? "codex" : "claude-code";
108
+ if (resolveNativeMessageMode({ agentType, env, stdinIsTTY: true, stdoutIsTTY: true }) === legacyOptOut) throw new Error("Interactive native delivery selection is incorrect");
109
+ const identity = await registerAgentFull(root, { agentType, sessionId: "smoke001", parentPid: process.pid, launchMode: "terminal", tty: "", skipSessionResolve: true }, { validateParentPid: true, notifyDaemon: false });
110
+ Object.assign(env, { UFOO_SUBSCRIBER_ID: identity.subscriber, UFOO_AGENT_HANDLE: identity.agent_handle });
111
+ if (legacyOptOut) setNativeMetadata(root, identity.subscriber, { native_delivery: "stale_receiver", native_delivery_ready: true, native_delivery_instance: "stale_socket" });
112
+ const args = selected === "codex" ? [] : ["--model", "fixture", "--allowedTools", "mcp__ufoo_channel__channel_ready", "--debug-file", path.join(root, "claude-debug.log")];
113
+ // Exercise the full shared launcher and its inject socket. Only daemon
114
+ // setup/registration use this fixture's already registered local identity.
115
+ const launcherScript = `
116
+ // Each Unix PTY owns a separate session. Record only this fixture's
117
+ // groups so cleanup can stop vendor descendants after wrapper exit.
118
+ const pty = require(${JSON.stringify(require.resolve("node-pty"))});
119
+ const spawnPty = pty.spawn;
120
+ pty.spawn = (...args) => {
121
+ const child = spawnPty(...args);
122
+ require("fs").appendFileSync(${JSON.stringify(ptyGroupsFile)}, String(child.pid) + "\\n");
123
+ return child;
124
+ };
125
+ const Launcher = require(${JSON.stringify(path.resolve(__dirname, "../src/agents/launch/launcher"))});
126
+ const launcher = new Launcher(${JSON.stringify(agentType)}, ${JSON.stringify(selected === "codex" ? "codex" : "claude")});
127
+ launcher.ensureInit = async () => {};
128
+ launcher.ensureDaemon = async () => "fixture";
129
+ launcher.getPreRegistered = async () => ({ subscriberId: process.env.UFOO_SUBSCRIBER_ID, sessionId: "smoke001", agentHandle: process.env.UFOO_AGENT_HANDLE });
130
+ launcher.launch(${JSON.stringify(args)});
131
+ `;
132
+ terminal = pty.spawn(process.execPath, ["-e", launcherScript], { cwd: root, env: { ...env, UFOO_SUPPRESS_LAUNCHER_BANNER: "1" }, name: "xterm-256color", cols: 120, rows: 40 });
133
+ const answered = new Set();
134
+ terminal.onExit(() => { exited = true; });
135
+ terminal.onData((data) => {
136
+ output = (output + data).slice(-24000);
137
+ const text = output.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, "");
138
+ // Answer only setup dialogs in this isolated fixture session.
139
+ if (/want\s*to\s*use\s*this\s*API\s*key/i.test(text) && !answered.has("fixture-key")) {
140
+ answered.add("fixture-key"); setTimeout(() => terminal.write("\x1b[A\r"), 100);
141
+ }
142
+ if (/local\s*development/i.test(text) && !answered.has("development-channel")) {
143
+ answered.add("development-channel"); setTimeout(() => terminal.write("\r"), 100);
144
+ }
145
+ if (/(?:trust.*(?:folder|directory)|Yes,?\s*I\s*trust)/i.test(text) && !answered.has("workspace-trust")) {
146
+ answered.add("workspace-trust");
147
+ // Newer Claude versions default to "No, exit". This fixture creates
148
+ // its own disposable workspace; select its trust option explicitly.
149
+ const declineSelected = /[❯>]\s*No,?\s*exit/i.test(text);
150
+ if (declineSelected) {
151
+ setTimeout(() => terminal.write("\x1b[B"), 100);
152
+ setTimeout(() => terminal.write("\r"), 400);
153
+ } else {
154
+ setTimeout(() => terminal.write("\r"), 100);
155
+ }
156
+ }
157
+ for (const pattern of [/text\s*style.*terminal/i, /Press\s*Ente?r?\s*to\s*continue/i, /Use\s*this\s*MCP\s*server/i]) {
158
+ if (pattern.test(text) && !answered.has(pattern.source)) {
159
+ answered.add(pattern.source); setTimeout(() => terminal.write("\r"), 100);
160
+ }
161
+ }
162
+ });
163
+ if (legacyOptOut) {
164
+ await until(() => loadAgentsData(getUfooPaths(root).agentsFile).agents[identity.subscriber]?.native_delivery === null
165
+ && fs.existsSync(path.join(getUfooPaths(root).busQueuesDir, identity.subscriber.replace(/:/g, "_"), "inject.sock")));
166
+ console.log(JSON.stringify({ host: selected, ok: true, legacy_opt_out: true, stale_receiver_cleared: true }));
167
+ return;
168
+ }
169
+ await until(() => {
170
+ if (exited) throw new Error(`${selected} exited before channel readiness`);
171
+ return loadAgentsData(getUfooPaths(root).agentsFile).agents[identity.subscriber]?.native_delivery_ready === true;
172
+ });
173
+ const injector = new Injector(getUfooPaths(root).busDir, getUfooPaths(root).agentsFile);
174
+ await injector.inject(identity.subscriber, "ufoo_native_first", { deliveryId: "smoke:1" });
175
+ await until(() => received.includes("ufoo_native_first"));
176
+ await injector.inject(identity.subscriber, "ufoo_native_second", { deliveryId: "smoke:2" });
177
+ await until(() => received.includes("ufoo_native_second"));
178
+ console.log(JSON.stringify({ host: selected, ok: true, received, native_channel_probe: selected === "codex" ? null : probeCalled }));
179
+ } catch (err) {
180
+ const debugFile = path.join(root, "claude-debug.log");
181
+ const channelDiagnostics = fs.existsSync(debugFile) ? fs.readFileSync(debugFile, "utf8").split("\n").filter((line) => /channel|ufoo_channel|growthbook/i.test(line)).slice(-20) : [];
182
+ console.error(JSON.stringify({ host: selected, ok: false, error: err.message, probe_called: probeCalled, channel_diagnostics: channelDiagnostics, fixture_ui: output.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, "").slice(-1800) }));
183
+ process.exitCode = 1;
184
+ } finally {
185
+ const groups = new Set(terminal ? [terminal.pid] : []);
186
+ try {
187
+ for (const value of fs.readFileSync(ptyGroupsFile, "utf8").split("\n")) {
188
+ const pid = Number(value);
189
+ if (Number.isInteger(pid) && pid > 1) groups.add(pid);
190
+ }
191
+ } catch { /* The launcher may have failed before starting its PTY. */ }
192
+ const signalGroups = (signal) => {
193
+ for (const pid of groups) {
194
+ try { process.kill(-pid, signal); }
195
+ catch (err) { if (err.code !== "ESRCH") throw err; }
196
+ }
197
+ };
198
+ signalGroups("SIGTERM");
199
+ if (terminal && !exited) {
200
+ terminal.kill("SIGTERM");
201
+ try { await until(() => exited, 2500); }
202
+ catch { terminal.kill("SIGKILL"); }
203
+ }
204
+ await new Promise((resolve) => setTimeout(resolve, 250));
205
+ signalGroups("SIGKILL");
206
+ api.closeAllConnections();
207
+ await new Promise((resolve) => api.close(resolve));
208
+ await new Promise((resolve) => setTimeout(resolve, 200));
209
+ // Vendor processes can finish writing state just after the wrapper exits.
210
+ fs.rmSync(root, { recursive: true, force: true, maxRetries: 10, retryDelay: 200 });
211
+ }
212
+ }
213
+
214
+ main().catch((err) => { console.error(err.message); process.exitCode = 1; });
@@ -1,5 +1,5 @@
1
1
  const fs = require("fs");
2
- const { readJSON, writeJSON } = require("../../coordination/bus/utils");
2
+ const { updateAgentsData } = require("../../coordination/state/agentsStore");
3
3
  const { appendAgentRegistryDiagnostic } = require("../../coordination/state/agentRegistryDiagnostics");
4
4
 
5
5
  /**
@@ -18,47 +18,46 @@ function writeActivityState(agentsFilePath, subscriber, state, options = {}) {
18
18
  const detail = typeof options.detail === "string" ? options.detail : "";
19
19
  try {
20
20
  if (!agentsFilePath || !fs.existsSync(agentsFilePath)) return false;
21
- const data = readJSON(agentsFilePath, null);
22
- if (!data) return false;
23
- if (!data.agents || !data.agents[subscriber]) {
24
- appendAgentRegistryDiagnostic(agentsFilePath, "activity_state_subscriber_missing", {
25
- source: "agent.activityStateWriter.writeActivityState",
26
- subscriber,
27
- state,
28
- known_ids: Object.keys(data.agents || {}).sort(),
29
- });
30
- return false;
31
- }
21
+ return updateAgentsData(agentsFilePath, (data) => {
22
+ if (!data.agents || !data.agents[subscriber]) {
23
+ appendAgentRegistryDiagnostic(agentsFilePath, "activity_state_subscriber_missing", {
24
+ source: "agent.activityStateWriter.writeActivityState",
25
+ subscriber,
26
+ state,
27
+ known_ids: Object.keys(data.agents || {}).sort(),
28
+ });
29
+ return false;
30
+ }
32
31
 
33
- const agent = data.agents[subscriber];
34
- const currentState = agent.activity_state;
35
- const currentDetail = typeof agent.activity_detail === "string" ? agent.activity_detail : "";
32
+ const agent = data.agents[subscriber];
33
+ const currentState = agent.activity_state;
34
+ const currentDetail = typeof agent.activity_detail === "string" ? agent.activity_detail : "";
36
35
 
37
- if (currentState === state && currentDetail === detail) return false;
36
+ if (currentState === state && currentDetail === detail) return false;
38
37
 
39
- if (
40
- currentState !== state
41
- && !force
42
- && (currentState === "working" || currentState === "waiting_input" || currentState === "blocked")
43
- ) {
44
- if (state === "idle" || state === "ready") return false;
45
- }
38
+ if (
39
+ currentState !== state
40
+ && !force
41
+ && (currentState === "working" || currentState === "waiting_input" || currentState === "blocked")
42
+ ) {
43
+ if (state === "idle" || state === "ready") return false;
44
+ }
46
45
 
47
- agent.activity_state = state;
48
- if (detail) {
49
- agent.activity_detail = detail;
50
- } else {
51
- delete agent.activity_detail;
52
- }
53
- if (currentState !== state) {
54
- agent.activity_since = since
55
- ? new Date(since).toISOString()
56
- : new Date().toISOString();
57
- } else if (!agent.activity_since) {
58
- agent.activity_since = new Date().toISOString();
59
- }
60
- writeJSON(agentsFilePath, data);
61
- return true;
46
+ agent.activity_state = state;
47
+ if (detail) {
48
+ agent.activity_detail = detail;
49
+ } else {
50
+ delete agent.activity_detail;
51
+ }
52
+ if (currentState !== state) {
53
+ agent.activity_since = since
54
+ ? new Date(since).toISOString()
55
+ : new Date().toISOString();
56
+ } else if (!agent.activity_since) {
57
+ agent.activity_since = new Date().toISOString();
58
+ }
59
+ return true;
60
+ });
62
61
  } catch {
63
62
  return false;
64
63
  }
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ const { createCoordinationCapability } = require("../coordination");
3
+ module.exports = { createAgentManagementCapability: (host) => createCoordinationCapability({ host, id: "agent-management",
4
+ toolNames: ["list_agents", "launch_agent", "rename_agent", "close_agent", "delegate_task", "resume_agents"] }) };
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+
3
+ const { createHash } = require("crypto");
4
+ const { createCommandStore } = require("../../runtime");
5
+ const { stableStringify } = require("../../runtime/core/stableJson");
6
+
7
+ const digest = (value) => createHash("sha256").update(value).digest("hex").slice(0, 24);
8
+ const empty = () => ({ tasks: {} });
9
+
10
+ /** Project host ports own launching/delivery; this adapter records business associations. */
11
+ function createAgentManagementService({ store, launch, dispatch, wake = async () => {}, emit = () => {}, validateEvidence = null, resolveTarget = (target) => target } = {}) {
12
+ const commands = createCommandStore(store);
13
+ const read = () => store.read().capabilityState["agent-management"]?.value || empty();
14
+ function update(mutator) {
15
+ return store.transaction((snapshot) => {
16
+ const state = snapshot.capabilityState["agent-management"]?.value || empty();
17
+ mutator(state);
18
+ return [{ type: "capability.state_committed", capabilityId: "agent-management", version: 1, value: state }];
19
+ });
20
+ }
21
+ async function flushWakes() {
22
+ for (const task of Object.values(read().tasks)) {
23
+ if (!task.pendingWake) continue;
24
+ await wake({ requestId: task.pendingWake, text: `Review delegated task ${task.taskId}. Worker reports ${task.report.phase}. Validate the acceptance criteria and evidence before accepting.`,
25
+ taskId: task.taskId, parentTaskRunId: task.parentTaskRunId, report: task.report, acceptanceCriteria: task.acceptanceCriteria });
26
+ update((state) => { if (state.tasks[task.taskId].pendingWake === task.pendingWake) state.tasks[task.taskId].pendingWake = ""; });
27
+ }
28
+ }
29
+ return Object.freeze({
30
+ commands,
31
+ snapshot: read,
32
+ flushWakes,
33
+ delivery({ subscriber, event, status, errorCode }) {
34
+ const matched = Object.values(read().tasks).find((task) => task.workerId === subscriber && task.dispatchReceipt?.receipt?.seq === event?.seq);
35
+ if (!matched || !["queued", "delivery_uncertain"].includes(matched.status)) return { matched: false };
36
+ const next = status === "ok" ? "delivered" : errorCode === "native_outcome_unknown" ? "delivery_uncertain" : "queued";
37
+ update((state) => { state.tasks[matched.taskId].status = next; });
38
+ emit({ type: next === "delivery_uncertain" ? "delivery.uncertain" : "dispatch.delivered", taskId: matched.taskId, workerId: subscriber, deliveryStatus: next });
39
+ return { matched: true, status: next };
40
+ },
41
+ async delegate(args, context = {}) {
42
+ const id = String(args.command_id || "");
43
+ if (!/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,100}$/.test(id)) throw new Error("delegate_task requires safe command_id");
44
+ if (!String(args.objective || "").trim()) throw new Error("delegate_task requires objective");
45
+ if (!args.target && !args.agent) throw new Error("delegate_task requires target or agent");
46
+ const scope = context.requestId ? `${context.requestId}:${id}` : id;
47
+ const commandId = `delegate-${digest(scope)}`;
48
+ const taskId = `delegated-${digest(scope)}`;
49
+ const fingerprint = digest(stableStringify(args));
50
+ const target = args.target ? resolveTarget(args.target) : "";
51
+ if (args.target && !target) throw new Error("delegation target is not an active project worker");
52
+ update((state) => {
53
+ const existing = state.tasks[taskId];
54
+ if (existing && existing.fingerprint !== fingerprint) throw Object.assign(new Error("delegation command conflicts"), { code: "command_conflict" });
55
+ if (!existing) state.tasks[taskId] = { taskId, fingerprint, objective: args.objective,
56
+ acceptanceCriteria: args.acceptance_criteria || [], parentTaskRunId: context.taskRunId || "",
57
+ parentSessionId: context.sessionId || "", status: "planning", workerId: String(target), reportIds: [] };
58
+ });
59
+ let task = read().tasks[taskId];
60
+ if (task.status !== "planning") return { ok: true, task: { ...task } };
61
+ if (!task.workerId) {
62
+ const nickname = args.nickname || `worker-${digest(scope).slice(0, 12)}`;
63
+ const result = await commands.execute({ commandId: `${commandId}:launch`, kind: "launch_agent", args: { agent: args.agent, nickname } }, () => launch({ agent: args.agent, nickname, count: 1 }));
64
+ if (!result || result.ok === false) return { ...result, ok: false, taskId };
65
+ const rows = Array.isArray(result.ops_results) ? result.ops_results : [result];
66
+ const workerId = rows.map((row) => row.agent_id || row.subscriber_ids?.[0] || "").find(Boolean);
67
+ if (!workerId) return { ok: false, code: "awaiting_registration", taskId, error: "Launch receipt has no concrete worker identity; reconcile before dispatch." };
68
+ update((state) => { state.tasks[taskId].workerId = workerId; });
69
+ task = read().tasks[taskId];
70
+ }
71
+ const message = [args.objective, `Task ID: ${taskId}`, "Controller: ufoo-agent. Report start/progress/done/error with this exact task ID and private scope.",
72
+ "Use ufoo report --task <id> --scope private --controller ufoo-agent, or MCP report_agent_status with task_id, scope=private, controller_id=ufoo-agent.",
73
+ `Acceptance criteria: ${JSON.stringify(task.acceptanceCriteria)}`].join("\n\n");
74
+ const receipt = await commands.execute({ commandId: `${commandId}:dispatch`, kind: "dispatch_message", args: { target: task.workerId, message } },
75
+ () => dispatch({ target: task.workerId, message, taskId }));
76
+ if (!receipt || receipt.ok === false) return { ...receipt, ok: false, taskId };
77
+ update((state) => { const entry = state.tasks[taskId]; entry.status = "queued"; entry.dispatchReceipt = receipt; });
78
+ emit({ type: "delegation.queued", taskId, workerId: task.workerId, parentTaskRunId: task.parentTaskRunId });
79
+ return { ok: true, task: read().tasks[taskId], deliveryStatus: "queued" };
80
+ },
81
+ async report(entry) {
82
+ const task = read().tasks[entry.task_id];
83
+ if (!task || task.workerId !== entry.agent_id) return { matched: false };
84
+ const reportId = entry.entry_id || digest(JSON.stringify(entry));
85
+ if (task.reportIds.includes(reportId)) { await flushWakes(); return { matched: true, duplicate: true }; }
86
+ update((state) => {
87
+ const current = state.tasks[entry.task_id];
88
+ current.reportIds.push(reportId);
89
+ if (current.status === "accepted") return;
90
+ if (current.report && ["done", "error"].includes(current.report.phase) && ["start", "progress"].includes(entry.phase)) return;
91
+ current.report = entry;
92
+ current.status = ["done", "error"].includes(entry.phase) ? "reported" : "running";
93
+ if (current.status === "reported") current.pendingWake = `report-${digest(`${current.taskId}:${reportId}`)}`;
94
+ });
95
+ await flushWakes();
96
+ return { matched: true, task: read().tasks[entry.task_id] };
97
+ },
98
+ accept({ task_id: taskId, outcome, reason, evidence = [] }, context = {}) {
99
+ if (!["accepted", "rejected"].includes(outcome)) throw new Error("accept_task requires accepted or rejected outcome");
100
+ update((state) => {
101
+ const task = state.tasks[taskId];
102
+ if (!task || task.status !== "reported") throw new Error("task has no unreviewed terminal report");
103
+ if (outcome === "accepted" && (!String(reason || "").trim() || !evidence.length || task.report.phase !== "done")) throw new Error("acceptance requires a completed worker report, reason, and validation evidence");
104
+ if (outcome === "accepted" && (!validateEvidence || validateEvidence(evidence, task, context) !== true)) throw new Error("host did not verify the acceptance evidence");
105
+ task.status = outcome;
106
+ task.acceptance = { outcome, reason, evidence };
107
+ });
108
+ return { ok: true, task: read().tasks[taskId] };
109
+ },
110
+ });
111
+ }
112
+
113
+ module.exports = { createAgentManagementService };
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ const { createCoordinationCapability } = require("../coordination");
3
+ module.exports = { createAgentRoutingCapability: (host) => createCoordinationCapability({ host, id: "agent-routing",
4
+ toolNames: ["route_agent", "dispatch_message", "read_bus_summary", "read_prompt_history", "read_open_decisions"] }) };
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ const { buildCoreToolSpecs } = require("../../../code/tools/specs");
4
+ const { runCoreToolAsync } = require("../../../code/tools/executor");
5
+
6
+ const CODING_TOOLS = new Set(["read", "read_image", "write", "edit", "bash", "artifact_read"]);
7
+
8
+ function toolFromSpec(spec) {
9
+ const { name, description, parameters } = spec.function;
10
+ return {
11
+ name, description, inputSchema: parameters,
12
+ permissions: [name === "bash" ? "workspace.execute" : ["write", "edit"].includes(name) ? "workspace.write" : "workspace.read"],
13
+ tight: ["read", "read_image", "artifact_read"].includes(name),
14
+ handler: (args, context) => runCoreToolAsync({ ...context, tool: name, args }),
15
+ };
16
+ }
17
+
18
+ function createCodingCapability({ workspaceAccess = null } = {}) {
19
+ return {
20
+ id: "coding", version: "1.0",
21
+ requires: { providerFeatures: ["tool_calls", "vision"] },
22
+ tools: buildCoreToolSpecs().filter((spec) => CODING_TOOLS.has(spec.function.name)).map((spec) => {
23
+ const tool = toolFromSpec(spec);
24
+ return workspaceAccess ? { ...tool, async handler(args, context) {
25
+ const result = await workspaceAccess.run({ ...context, tool: tool.name, args }, () => tool.handler(args, context));
26
+ return { ...result, toolCallId: context.toolCallId };
27
+ } } : tool;
28
+ }),
29
+ };
30
+ }
31
+
32
+ module.exports = { createCodingCapability, toolFromSpec };