qlogicagent 2.18.5 → 2.18.7

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 (151) hide show
  1. package/README.md +382 -382
  2. package/dist/agent.js +30 -30
  3. package/dist/cli.js +1 -1
  4. package/dist/default-project-knowledge/INSTRUCTIONS.md +7 -7
  5. package/dist/default-project-knowledge/rules/project-workflow.md +6 -6
  6. package/dist/host-contract.js +1 -0
  7. package/dist/index.js +536 -525
  8. package/dist/orchestration.js +4 -4
  9. package/dist/permissions.js +1 -1
  10. package/dist/plugin-marketplace-compute.js +1 -0
  11. package/dist/protocol.js +1 -1
  12. package/dist/runtime/infra/mcp-bridge-server.js +275 -275
  13. package/dist/skills/builtin/desktop-screenshot/SKILL.md +62 -62
  14. package/dist/skills/builtin/office-doc-reading/SKILL.md +19 -19
  15. package/dist/skills/mcp/astraclaw-native-mcp-server.js +4 -4
  16. package/dist/tunables.js +1 -0
  17. package/dist/types/agent/runtime-vars.d.ts +1 -2
  18. package/dist/types/agent/tool-loop.d.ts +13 -0
  19. package/dist/types/agent/tool-loop.test-harness.d.ts +20 -0
  20. package/dist/types/agent/types.d.ts +8 -0
  21. package/dist/types/cli/acp-extended-handlers.d.ts +7 -0
  22. package/dist/types/cli/acp-extended-host-adapter.d.ts +2 -0
  23. package/dist/types/cli/acp-session-host.d.ts +15 -2
  24. package/dist/types/cli/base-tool-bootstrap.d.ts +1 -0
  25. package/dist/types/cli/community-skill-installer.d.ts +2 -0
  26. package/dist/types/cli/core-tool-coordinator.d.ts +4 -0
  27. package/dist/types/cli/core-tools/config-tool-bootstrap.d.ts +3 -1
  28. package/dist/types/cli/core-tools/config-tool-service.d.ts +7 -5
  29. package/dist/types/cli/default-project-bootstrap.d.ts +1 -0
  30. package/dist/types/cli/dream-host-adapter.d.ts +1 -0
  31. package/dist/types/cli/handlers/agents-handler.d.ts +4 -1
  32. package/dist/types/cli/handlers/community-handler.d.ts +2 -0
  33. package/dist/types/cli/handlers/config-handler.d.ts +2 -15
  34. package/dist/types/cli/handlers/dream-handler.d.ts +4 -0
  35. package/dist/types/cli/handlers/pet-handler.d.ts +3 -2
  36. package/dist/types/cli/handlers/session-handler.d.ts +1 -1
  37. package/dist/types/cli/handlers/skills-handler.d.ts +12 -10
  38. package/dist/types/cli/handlers/solo-handler.d.ts +3 -0
  39. package/dist/types/cli/handlers/turn-handler.d.ts +46 -32
  40. package/dist/types/cli/handlers/workflow-handler.d.ts +6 -0
  41. package/dist/types/cli/mcp-bootstrap.d.ts +0 -2
  42. package/dist/types/cli/media-inline.d.ts +31 -0
  43. package/dist/types/cli/media-understanding.d.ts +65 -8
  44. package/dist/types/cli/memory-coordinator.d.ts +8 -0
  45. package/dist/types/cli/multi-agent-handler-host.d.ts +2 -0
  46. package/dist/types/cli/permission-bootstrap.d.ts +2 -0
  47. package/dist/types/cli/pet-runtime.d.ts +0 -1
  48. package/dist/types/cli/plugin-bootstrap.d.ts +2 -1
  49. package/dist/types/cli/product-coordinator.d.ts +4 -1
  50. package/dist/types/cli/rpc-registry.d.ts +1 -3
  51. package/dist/types/cli/runtime-watcher-bootstrap.d.ts +0 -2
  52. package/dist/types/cli/session-context.d.ts +4 -2
  53. package/dist/types/cli/skill-invocation-service.d.ts +2 -0
  54. package/dist/types/cli/skill-tools-bootstrap.d.ts +2 -0
  55. package/dist/types/cli/skills-query-service.d.ts +2 -1
  56. package/dist/types/cli/stdio-acp-protocol-coordinator.d.ts +9 -0
  57. package/dist/types/cli/stdio-acp-request-host.d.ts +11 -2
  58. package/dist/types/cli/stdio-rpc-handler-hosts.d.ts +1 -1
  59. package/dist/types/cli/stdio-runtime-bootstrap.d.ts +6 -0
  60. package/dist/types/cli/stdio-runtime-services.d.ts +6 -1
  61. package/dist/types/cli/stdio-server.d.ts +33 -4
  62. package/dist/types/cli/task-distillation-coordinator.d.ts +9 -4
  63. package/dist/types/cli/tool-bootstrap-core-registration.d.ts +3 -0
  64. package/dist/types/cli/tool-bootstrap-media-registration.d.ts +10 -0
  65. package/dist/types/cli/tool-bootstrap-web-registration.d.ts +1 -0
  66. package/dist/types/cli/tool-bootstrap.d.ts +9 -0
  67. package/dist/types/cli/turn-core.d.ts +4 -0
  68. package/dist/types/cli/turn-preview-browser-setup.d.ts +15 -0
  69. package/dist/types/cli/turn-project-router.d.ts +1 -1
  70. package/dist/types/cli/workflow-host-adapter.d.ts +2 -0
  71. package/dist/types/host-contract/index.d.ts +1475 -0
  72. package/dist/types/host-contract/project-id.d.ts +5 -0
  73. package/dist/types/host-contract/provider-profile.d.ts +46 -0
  74. package/dist/types/orchestration/agent-instance.d.ts +6 -0
  75. package/dist/types/orchestration/delegation-coordinator.d.ts +40 -0
  76. package/dist/types/orchestration/goal-mode-adapters.d.ts +3 -0
  77. package/dist/types/orchestration/product-planner.d.ts +3 -0
  78. package/dist/types/orchestration/solo-evaluator.d.ts +18 -3
  79. package/dist/types/orchestration/solo-persistence.d.ts +2 -0
  80. package/dist/types/orchestration/testing/delegate-test-bridge.d.ts +4 -0
  81. package/dist/types/permissions.d.ts +2 -0
  82. package/dist/types/protocol/methods.d.ts +0 -199
  83. package/dist/types/protocol/wire/acp-protocol.d.ts +16 -1
  84. package/dist/types/protocol/wire/agent-methods.d.ts +1 -173
  85. package/dist/types/protocol/wire/chat-types.d.ts +6 -0
  86. package/dist/types/runtime/config/tunable-defaults.d.ts +13 -3
  87. package/dist/types/runtime/execution/dream-agent.d.ts +9 -8
  88. package/dist/types/runtime/infra/agent-paths.d.ts +3 -3
  89. package/dist/types/runtime/infra/astraclaw-capabilities.d.ts +1 -1
  90. package/dist/types/runtime/infra/clixml-sanitize.d.ts +16 -0
  91. package/dist/types/runtime/infra/external-agent-approvals.d.ts +18 -0
  92. package/dist/types/runtime/infra/feedback-distillation.d.ts +3 -1
  93. package/dist/types/runtime/infra/feedback-host-authority.d.ts +4 -0
  94. package/dist/types/runtime/infra/llmrouter-catalog.d.ts +2 -13
  95. package/dist/types/runtime/infra/model-registry.d.ts +3 -1
  96. package/dist/types/runtime/infra/project-authority-facade.d.ts +11 -0
  97. package/dist/types/runtime/infra/project-host-authority.d.ts +10 -0
  98. package/dist/types/runtime/ports/memory-provider.d.ts +11 -7
  99. package/dist/types/runtime/ports/tool-contracts.d.ts +2 -0
  100. package/dist/types/runtime/prompt/fresh-workspace-evidence.d.ts +2 -2
  101. package/dist/types/runtime/session/session-catalog.d.ts +12 -0
  102. package/dist/types/runtime/session/session-persistence.d.ts +30 -11
  103. package/dist/types/runtime/session/session-recovery.d.ts +4 -0
  104. package/dist/types/runtime/session/session-summary.d.ts +3 -1
  105. package/dist/types/runtime/session/session-transcript-store.d.ts +7 -0
  106. package/dist/types/skills/memory/host-memory-provider.d.ts +148 -0
  107. package/dist/types/skills/memory/local-memory-provider.d.ts +20 -11
  108. package/dist/types/skills/memory/local-store.d.ts +5 -2
  109. package/dist/types/skills/memory/task-distillation.d.ts +6 -0
  110. package/dist/types/skills/plugins/plugin-marketplace.d.ts +23 -57
  111. package/dist/types/skills/tools/media-understand-tool.d.ts +28 -0
  112. package/dist/types/skills/tools/preview-browser-tool.d.ts +136 -0
  113. package/dist/types/skills/tools/shell/task-output.d.ts +10 -1
  114. package/dist/types/skills/tools/skill-tool.d.ts +1 -1
  115. package/dist/types/skills/web-search/brave-source.d.ts +2 -1
  116. package/dist/types/skills/web-search/crawl4ai-extractor.d.ts +3 -2
  117. package/dist/types/skills/web-search/exa-source.d.ts +2 -1
  118. package/dist/types/skills/web-search/search-svc-source.d.ts +4 -3
  119. package/dist/types/skills/web-search/searxng-source.d.ts +3 -1
  120. package/dist/types/skills/web-search/serper-source.d.ts +2 -1
  121. package/dist/types/skills/web-search/source-factory.d.ts +2 -1
  122. package/dist/types/skills/web-search/web-tunable-resolver.d.ts +16 -0
  123. package/dist/types/test-support/global-home-setup.d.ts +2 -0
  124. package/dist/types/transport/acp-server.d.ts +29 -0
  125. package/dist/types/transport/delegate-client.d.ts +82 -0
  126. package/dist/types/transport/host-capability-client.d.ts +21 -0
  127. package/dist/types/transport/host-feedback-client.d.ts +25 -0
  128. package/dist/types/transport/host-profile-client.d.ts +19 -0
  129. package/dist/types/transport/host-project-client.d.ts +16 -0
  130. package/dist/types/transport/host-request-client.d.ts +38 -0
  131. package/dist/types/transport/host-session-client.d.ts +29 -0
  132. package/dist/types/tunables.d.ts +2 -0
  133. package/dist/vendor/hatch-pet/LICENSE.txt +201 -201
  134. package/dist/vendor/hatch-pet/NOTICE.md +25 -25
  135. package/dist/vendor/hatch-pet/references/animation-rows.md +29 -29
  136. package/dist/vendor/hatch-pet/references/codex-pet-contract.md +35 -35
  137. package/dist/vendor/hatch-pet/references/qa-rubric.md +66 -66
  138. package/dist/vendor/hatch-pet/scripts/compose_atlas.py +169 -169
  139. package/dist/vendor/hatch-pet/scripts/derive_running_left_from_running_right.py +150 -150
  140. package/dist/vendor/hatch-pet/scripts/extract_strip_frames.py +408 -408
  141. package/dist/vendor/hatch-pet/scripts/inspect_frames.py +256 -256
  142. package/dist/vendor/hatch-pet/scripts/make_contact_sheet.py +96 -96
  143. package/dist/vendor/hatch-pet/scripts/prepare_pet_run.py +834 -834
  144. package/dist/vendor/hatch-pet/scripts/render_animation_previews.py +78 -78
  145. package/dist/vendor/hatch-pet/scripts/validate_atlas.py +157 -157
  146. package/package.json +25 -2
  147. package/dist/types/cli/handlers/settings-handler.d.ts +0 -19
  148. package/dist/types/cli/permission-rule-persistence.d.ts +0 -16
  149. package/dist/types/cli/tunable-store.d.ts +0 -26
  150. package/dist/types/skills/permissions/settings-watcher.d.ts +0 -26
  151. /package/dist/types/{skills/memory → host-contract}/fts-segment.d.ts +0 -0
@@ -1,23 +1,23 @@
1
- #!/usr/bin/env node
2
- /**
3
- * MCP Bridge Server — stdio MCP server for external ACP agents.
4
- *
5
- * Spawned by qlogicagent as a child of the external agent process.
6
- * Receives MCP requests (tools/list, tools/call) from the external agent
7
- * and proxies tool calls back to qlogicagent's parent RPC.
8
- *
9
- * Environment:
10
- * QLOGICAGENT_PARENT_RPC — IPC/pipe path to parent qlogicagent
11
- * QLOGICAGENT_SESSION_ID — session scope for tool calls
12
- *
13
- * Protocol: JSON-RPC 2.0 over stdio (newline-delimited)
14
- */
15
-
1
+ #!/usr/bin/env node
2
+ /**
3
+ * MCP Bridge Server — stdio MCP server for external ACP agents.
4
+ *
5
+ * Spawned by qlogicagent as a child of the external agent process.
6
+ * Receives MCP requests (tools/list, tools/call) from the external agent
7
+ * and proxies tool calls back to qlogicagent's parent RPC.
8
+ *
9
+ * Environment:
10
+ * QLOGICAGENT_PARENT_RPC — IPC/pipe path to parent qlogicagent
11
+ * QLOGICAGENT_SESSION_ID — session scope for tool calls
12
+ *
13
+ * Protocol: JSON-RPC 2.0 over stdio (newline-delimited)
14
+ */
15
+
16
16
  import readline from "node:readline";
17
17
  import net from "node:net";
18
-
19
- // ── Tool Manifest (must match MCP_BRIDGE_TOOLS in mcp-bridge.ts) ────
20
-
18
+
19
+ // ── Tool Manifest (must match MCP_BRIDGE_TOOLS in mcp-bridge.ts) ────
20
+
21
21
  const TOOLS = [
22
22
  {
23
23
  name: "skills_list",
@@ -61,161 +61,161 @@ const TOOLS = [
61
61
  {
62
62
  name: "media_generate",
63
63
  description: "Generate images or videos using AI models.",
64
- inputSchema: {
65
- type: "object",
66
- properties: {
67
- prompt: { type: "string", description: "Generation prompt" },
68
- type: { type: "string", enum: ["image", "video"], description: "Media type" },
69
- },
70
- required: ["prompt"],
71
- },
72
- },
73
- {
74
- name: "media_status",
75
- description: "Check status of an async media generation job.",
76
- inputSchema: {
77
- type: "object",
78
- properties: {
79
- jobId: { type: "string", description: "Job ID to check" },
80
- },
81
- required: ["jobId"],
82
- },
83
- },
84
- {
85
- name: "memory_read",
86
- description: "Read from persistent memory.",
87
- inputSchema: {
88
- type: "object",
89
- properties: {
90
- key: { type: "string", description: "Memory key to read" },
91
- },
92
- required: ["key"],
93
- },
94
- },
95
- {
96
- name: "memory_write",
97
- description: "Write to persistent memory.",
98
- inputSchema: {
99
- type: "object",
100
- properties: {
101
- key: { type: "string", description: "Memory key" },
102
- value: { type: "string", description: "Value to store" },
103
- },
104
- required: ["key", "value"],
105
- },
106
- },
107
- {
108
- name: "memory_search",
109
- description: "Search persistent memory by query.",
110
- inputSchema: {
111
- type: "object",
112
- properties: {
113
- query: { type: "string", description: "Search query" },
114
- },
115
- required: ["query"],
116
- },
117
- },
118
- {
119
- name: "web_search",
120
- description: "Search the web for information.",
121
- inputSchema: {
122
- type: "object",
123
- properties: {
124
- query: { type: "string", description: "Search query" },
125
- },
126
- required: ["query"],
127
- },
128
- },
129
- {
130
- name: "web_fetch",
131
- description: "Fetch content from a URL.",
132
- inputSchema: {
133
- type: "object",
134
- properties: {
135
- url: { type: "string", description: "URL to fetch" },
136
- },
137
- required: ["url"],
138
- },
139
- },
140
- {
141
- name: "team_status",
142
- description: "Get status of all agent team members.",
143
- inputSchema: {
144
- type: "object",
145
- properties: {},
146
- },
147
- },
148
- {
149
- name: "team_message",
150
- description: "Send a message to another team member agent.",
151
- inputSchema: {
152
- type: "object",
153
- properties: {
154
- targetAgentId: { type: "string", description: "Target agent ID" },
155
- message: { type: "string", description: "Message to send" },
156
- },
157
- required: ["targetAgentId", "message"],
158
- },
159
- },
160
- ];
161
-
162
- // ── Parent RPC Connection ───────────────────────────────────
163
-
164
- const PARENT_RPC = process.env.QLOGICAGENT_PARENT_RPC;
165
- const SESSION_ID = process.env.QLOGICAGENT_SESSION_ID || "unknown";
166
-
167
- let parentSocket = null;
168
- let rpcId = 1;
169
- const pendingRpc = new Map();
170
-
171
- function connectParent() {
172
- if (!PARENT_RPC) return;
173
-
64
+ inputSchema: {
65
+ type: "object",
66
+ properties: {
67
+ prompt: { type: "string", description: "Generation prompt" },
68
+ type: { type: "string", enum: ["image", "video"], description: "Media type" },
69
+ },
70
+ required: ["prompt"],
71
+ },
72
+ },
73
+ {
74
+ name: "media_status",
75
+ description: "Check status of an async media generation job.",
76
+ inputSchema: {
77
+ type: "object",
78
+ properties: {
79
+ jobId: { type: "string", description: "Job ID to check" },
80
+ },
81
+ required: ["jobId"],
82
+ },
83
+ },
84
+ {
85
+ name: "memory_read",
86
+ description: "Read from persistent memory.",
87
+ inputSchema: {
88
+ type: "object",
89
+ properties: {
90
+ key: { type: "string", description: "Memory key to read" },
91
+ },
92
+ required: ["key"],
93
+ },
94
+ },
95
+ {
96
+ name: "memory_write",
97
+ description: "Write to persistent memory.",
98
+ inputSchema: {
99
+ type: "object",
100
+ properties: {
101
+ key: { type: "string", description: "Memory key" },
102
+ value: { type: "string", description: "Value to store" },
103
+ },
104
+ required: ["key", "value"],
105
+ },
106
+ },
107
+ {
108
+ name: "memory_search",
109
+ description: "Search persistent memory by query.",
110
+ inputSchema: {
111
+ type: "object",
112
+ properties: {
113
+ query: { type: "string", description: "Search query" },
114
+ },
115
+ required: ["query"],
116
+ },
117
+ },
118
+ {
119
+ name: "web_search",
120
+ description: "Search the web for information.",
121
+ inputSchema: {
122
+ type: "object",
123
+ properties: {
124
+ query: { type: "string", description: "Search query" },
125
+ },
126
+ required: ["query"],
127
+ },
128
+ },
129
+ {
130
+ name: "web_fetch",
131
+ description: "Fetch content from a URL.",
132
+ inputSchema: {
133
+ type: "object",
134
+ properties: {
135
+ url: { type: "string", description: "URL to fetch" },
136
+ },
137
+ required: ["url"],
138
+ },
139
+ },
140
+ {
141
+ name: "team_status",
142
+ description: "Get status of all agent team members.",
143
+ inputSchema: {
144
+ type: "object",
145
+ properties: {},
146
+ },
147
+ },
148
+ {
149
+ name: "team_message",
150
+ description: "Send a message to another team member agent.",
151
+ inputSchema: {
152
+ type: "object",
153
+ properties: {
154
+ targetAgentId: { type: "string", description: "Target agent ID" },
155
+ message: { type: "string", description: "Message to send" },
156
+ },
157
+ required: ["targetAgentId", "message"],
158
+ },
159
+ },
160
+ ];
161
+
162
+ // ── Parent RPC Connection ───────────────────────────────────
163
+
164
+ const PARENT_RPC = process.env.QLOGICAGENT_PARENT_RPC;
165
+ const SESSION_ID = process.env.QLOGICAGENT_SESSION_ID || "unknown";
166
+
167
+ let parentSocket = null;
168
+ let rpcId = 1;
169
+ const pendingRpc = new Map();
170
+
171
+ function connectParent() {
172
+ if (!PARENT_RPC) return;
173
+
174
174
  parentSocket = net.createConnection(PARENT_RPC, () => {
175
- process.stderr.write(`[mcp-bridge] connected to parent: ${PARENT_RPC}\n`);
176
- });
177
-
178
- let buffer = "";
179
- parentSocket.on("data", (chunk) => {
180
- buffer += chunk.toString();
181
- let nl;
182
- while ((nl = buffer.indexOf("\n")) !== -1) {
183
- const line = buffer.slice(0, nl).trim();
184
- buffer = buffer.slice(nl + 1);
185
- if (!line) continue;
186
- try {
187
- const msg = JSON.parse(line);
188
- if (msg.id !== undefined && pendingRpc.has(msg.id)) {
189
- const resolve = pendingRpc.get(msg.id);
190
- pendingRpc.delete(msg.id);
191
- resolve(msg);
192
- }
193
- } catch {
194
- // ignore parse errors
195
- }
196
- }
197
- });
198
-
199
- parentSocket.on("error", (err) => {
200
- process.stderr.write(`[mcp-bridge] parent connection error: ${err.message}\n`);
201
- });
202
-
203
- parentSocket.on("close", () => {
204
- parentSocket = null;
205
- });
206
- }
207
-
208
- function callParent(method, params) {
209
- return new Promise((resolve, reject) => {
210
- if (!parentSocket) {
211
- reject(new Error("Not connected to parent"));
212
- return;
213
- }
214
- const id = rpcId++;
215
- const msg = JSON.stringify({ jsonrpc: "2.0", id, method, params }) + "\n";
216
- pendingRpc.set(id, resolve);
217
- parentSocket.write(msg);
218
-
175
+ process.stderr.write(`[mcp-bridge] connected to parent: ${PARENT_RPC}\n`);
176
+ });
177
+
178
+ let buffer = "";
179
+ parentSocket.on("data", (chunk) => {
180
+ buffer += chunk.toString();
181
+ let nl;
182
+ while ((nl = buffer.indexOf("\n")) !== -1) {
183
+ const line = buffer.slice(0, nl).trim();
184
+ buffer = buffer.slice(nl + 1);
185
+ if (!line) continue;
186
+ try {
187
+ const msg = JSON.parse(line);
188
+ if (msg.id !== undefined && pendingRpc.has(msg.id)) {
189
+ const resolve = pendingRpc.get(msg.id);
190
+ pendingRpc.delete(msg.id);
191
+ resolve(msg);
192
+ }
193
+ } catch {
194
+ // ignore parse errors
195
+ }
196
+ }
197
+ });
198
+
199
+ parentSocket.on("error", (err) => {
200
+ process.stderr.write(`[mcp-bridge] parent connection error: ${err.message}\n`);
201
+ });
202
+
203
+ parentSocket.on("close", () => {
204
+ parentSocket = null;
205
+ });
206
+ }
207
+
208
+ function callParent(method, params) {
209
+ return new Promise((resolve, reject) => {
210
+ if (!parentSocket) {
211
+ reject(new Error("Not connected to parent"));
212
+ return;
213
+ }
214
+ const id = rpcId++;
215
+ const msg = JSON.stringify({ jsonrpc: "2.0", id, method, params }) + "\n";
216
+ pendingRpc.set(id, resolve);
217
+ parentSocket.write(msg);
218
+
219
219
  // Connector calls can legitimately run longer than a simple capability lookup.
220
220
  setTimeout(() => {
221
221
  if (pendingRpc.has(id)) {
@@ -225,19 +225,19 @@ function callParent(method, params) {
225
225
  }, 120_000);
226
226
  });
227
227
  }
228
-
229
- // ── MCP Stdio Protocol ──────────────────────────────────────
230
-
231
- function sendResponse(id, result, error) {
232
- const msg = { jsonrpc: "2.0", id };
233
- if (error) msg.error = error;
234
- else msg.result = result;
235
- process.stdout.write(JSON.stringify(msg) + "\n");
236
- }
237
-
238
- async function handleRequest(msg) {
239
- const { id, method, params } = msg;
240
-
228
+
229
+ // ── MCP Stdio Protocol ──────────────────────────────────────
230
+
231
+ function sendResponse(id, result, error) {
232
+ const msg = { jsonrpc: "2.0", id };
233
+ if (error) msg.error = error;
234
+ else msg.result = result;
235
+ process.stdout.write(JSON.stringify(msg) + "\n");
236
+ }
237
+
238
+ async function handleRequest(msg) {
239
+ const { id, method, params } = msg;
240
+
241
241
  if (method === "initialize") {
242
242
  sendResponse(id, {
243
243
  protocolVersion: "2024-11-05",
@@ -246,93 +246,93 @@ async function handleRequest(msg) {
246
246
  });
247
247
  return;
248
248
  }
249
-
250
- if (method === "tools/list") {
251
- sendResponse(id, { tools: TOOLS });
252
- return;
253
- }
254
-
255
- if (method === "tools/call") {
256
- const toolName = params?.name;
257
- const toolArgs = params?.arguments || {};
258
-
259
- if (!toolName) {
260
- sendResponse(id, null, { code: -32602, message: "Missing tool name" });
261
- return;
262
- }
263
-
264
- const knownTool = TOOLS.find((t) => t.name === toolName);
265
- if (!knownTool) {
266
- sendResponse(id, null, { code: -32602, message: `Unknown tool: ${toolName}` });
267
- return;
268
- }
269
-
270
- // Proxy to parent qlogicagent
271
- if (!parentSocket) {
272
- sendResponse(id, {
273
- content: [{ type: "text", text: `Error: MCP bridge not connected to parent` }],
274
- isError: true,
275
- });
276
- return;
277
- }
278
-
279
- try {
280
- const result = await callParent("mcp.toolCall", {
281
- sessionId: SESSION_ID,
282
- tool: toolName,
283
- arguments: toolArgs,
284
- });
285
-
286
- if (result.error) {
287
- sendResponse(id, {
288
- content: [{ type: "text", text: `Error: ${result.error.message}` }],
289
- isError: true,
290
- });
291
- } else {
292
- const text = typeof result.result === "string"
293
- ? result.result
294
- : JSON.stringify(result.result);
295
- sendResponse(id, {
296
- content: [{ type: "text", text }],
297
- });
298
- }
299
- } catch (err) {
300
- sendResponse(id, {
301
- content: [{ type: "text", text: `Error: ${err.message}` }],
302
- isError: true,
303
- });
304
- }
305
- return;
306
- }
307
-
308
- // Notification — no response needed
309
- if (id === undefined) return;
310
-
311
- sendResponse(id, null, { code: -32601, message: `Unknown method: ${method}` });
312
- }
313
-
314
- // ── Main ────────────────────────────────────────────────────
315
-
316
- connectParent();
317
-
318
- const rl = readline.createInterface({ input: process.stdin, terminal: false });
319
-
320
- rl.on("line", (line) => {
321
- const trimmed = line.trim();
322
- if (!trimmed) return;
323
- try {
324
- const msg = JSON.parse(trimmed);
325
- handleRequest(msg).catch((err) => {
326
- if (msg.id !== undefined) {
327
- sendResponse(msg.id, null, { code: -32603, message: err.message });
328
- }
329
- });
330
- } catch {
331
- // Malformed JSON — ignore
332
- }
333
- });
334
-
335
- rl.on("close", () => {
336
- if (parentSocket) parentSocket.destroy();
337
- process.exit(0);
338
- });
249
+
250
+ if (method === "tools/list") {
251
+ sendResponse(id, { tools: TOOLS });
252
+ return;
253
+ }
254
+
255
+ if (method === "tools/call") {
256
+ const toolName = params?.name;
257
+ const toolArgs = params?.arguments || {};
258
+
259
+ if (!toolName) {
260
+ sendResponse(id, null, { code: -32602, message: "Missing tool name" });
261
+ return;
262
+ }
263
+
264
+ const knownTool = TOOLS.find((t) => t.name === toolName);
265
+ if (!knownTool) {
266
+ sendResponse(id, null, { code: -32602, message: `Unknown tool: ${toolName}` });
267
+ return;
268
+ }
269
+
270
+ // Proxy to parent qlogicagent
271
+ if (!parentSocket) {
272
+ sendResponse(id, {
273
+ content: [{ type: "text", text: `Error: MCP bridge not connected to parent` }],
274
+ isError: true,
275
+ });
276
+ return;
277
+ }
278
+
279
+ try {
280
+ const result = await callParent("mcp.toolCall", {
281
+ sessionId: SESSION_ID,
282
+ tool: toolName,
283
+ arguments: toolArgs,
284
+ });
285
+
286
+ if (result.error) {
287
+ sendResponse(id, {
288
+ content: [{ type: "text", text: `Error: ${result.error.message}` }],
289
+ isError: true,
290
+ });
291
+ } else {
292
+ const text = typeof result.result === "string"
293
+ ? result.result
294
+ : JSON.stringify(result.result);
295
+ sendResponse(id, {
296
+ content: [{ type: "text", text }],
297
+ });
298
+ }
299
+ } catch (err) {
300
+ sendResponse(id, {
301
+ content: [{ type: "text", text: `Error: ${err.message}` }],
302
+ isError: true,
303
+ });
304
+ }
305
+ return;
306
+ }
307
+
308
+ // Notification — no response needed
309
+ if (id === undefined) return;
310
+
311
+ sendResponse(id, null, { code: -32601, message: `Unknown method: ${method}` });
312
+ }
313
+
314
+ // ── Main ────────────────────────────────────────────────────
315
+
316
+ connectParent();
317
+
318
+ const rl = readline.createInterface({ input: process.stdin, terminal: false });
319
+
320
+ rl.on("line", (line) => {
321
+ const trimmed = line.trim();
322
+ if (!trimmed) return;
323
+ try {
324
+ const msg = JSON.parse(trimmed);
325
+ handleRequest(msg).catch((err) => {
326
+ if (msg.id !== undefined) {
327
+ sendResponse(msg.id, null, { code: -32603, message: err.message });
328
+ }
329
+ });
330
+ } catch {
331
+ // Malformed JSON — ignore
332
+ }
333
+ });
334
+
335
+ rl.on("close", () => {
336
+ if (parentSocket) parentSocket.destroy();
337
+ process.exit(0);
338
+ });