archgraph-argo-beta 0.30.0-beta.2 → 0.30.0-beta.3

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.
@@ -20,6 +20,7 @@ const readline = require('node:readline');
20
20
  const binding = require('./workspace-binding.js');
21
21
  const credentials = require('./cloud-credentials.js');
22
22
  const argoMode = require('./argo-mode.js');
23
+ const argoPaths = require('./argo-paths.js');
23
24
  const cloudClient = require('./cloud-client.js');
24
25
 
25
26
  const WRITE_TOOLS = new Set([
@@ -100,7 +101,8 @@ function unwrapHandleResult(response) {
100
101
 
101
102
  function createThinRouter({ mode, client, workspaceRoot, fullServer, projectId }) {
102
103
  async function localHandle(name, args) {
103
- const response = await fullServer.handleRequest({ jsonrpc: '2.0', id: 1, method: 'tools/call', params: { name, arguments: args || {} } });
104
+ const merged = { ...(args || {}), workspaceRoot };
105
+ const response = await fullServer.handleRequest({ jsonrpc: '2.0', id: 1, method: 'tools/call', params: { name, arguments: merged } });
104
106
  return unwrapHandleResult(response);
105
107
  }
106
108
  return async function handleToolCall(name, args) {
@@ -116,7 +118,7 @@ function createThinRouter({ mode, client, workspaceRoot, fullServer, projectId }
116
118
 
117
119
  function buildSession({ workspaceRoot, cfg, env }) {
118
120
  const projectId = cfg && typeof cfg.projectId === 'string' && cfg.projectId.trim() ? cfg.projectId.trim() : null;
119
- const mode = cfg && (cfg.mode === 'offline' || cfg.mode === 'online') ? cfg.mode : (env.ARGO_MODE === 'offline' ? 'offline' : 'online');
121
+ const mode = cfg && (cfg.mode === 'offline' || cfg.mode === 'online') ? cfg.mode : (env.ARGO_MODE === 'online' ? 'online' : 'offline');
120
122
  const cloudCfg = cfg && cfg.cloud && typeof cfg.cloud === 'object' ? cfg.cloud : {};
121
123
  const cloudUrl = cloudCfg.url || (cfg && cfg.cloudUrl) || env.ARGO_CLOUD_URL || null;
122
124
  const token = credentials.resolveToken({ projectId, env }).token || env.ARGO_CLOUD_TOKEN || null;
@@ -148,6 +150,28 @@ async function main() {
148
150
 
149
151
  let session = null; // { workspaceRoot, projectId, mode, cloudUrl, client }
150
152
 
153
+ // MCP roots handshake (parity with argo-mcp-server): the host advertises its
154
+ // workspace roots; we collect them and feed them to resolution so a roots-only
155
+ // host is addressed exactly like the full engine (ARGO_REPO_ROOT / cwd / marker
156
+ // still take precedence per workspace-binding's deterministic order).
157
+ let roots = [];
158
+ let rootsReqId = null;
159
+ let rootsTimer = null;
160
+ function requestRoots() {
161
+ if (argoPaths.hasStaticWorkspace() || rootsReqId) {
162
+ return;
163
+ }
164
+ rootsReqId = 'argo-roots';
165
+ process.stdout.write(`${JSON.stringify({ jsonrpc: '2.0', id: rootsReqId, method: 'roots/list', params: {} })}\n`);
166
+ rootsTimer = setTimeout(() => { rootsTimer = null; rootsReqId = null; }, 8000);
167
+ }
168
+ function setRoots(list) {
169
+ roots = Array.isArray(list) ? list : [];
170
+ argoPaths.setMcpWorkspaceRoots(roots);
171
+ if (rootsTimer) { clearTimeout(rootsTimer); rootsTimer = null; }
172
+ rootsReqId = null;
173
+ }
174
+
151
175
  function readCfg(workspaceRoot) {
152
176
  try {
153
177
  const loaded = argoMode.readWorkspaceConfig(workspaceRoot);
@@ -166,7 +190,7 @@ async function main() {
166
190
  return session;
167
191
  }
168
192
  try {
169
- const resolution = binding.resolveWorkspaceRoot({ args: {}, env, cwd: process.cwd(), roots: [] });
193
+ const resolution = binding.resolveWorkspaceRoot({ args: {}, env, cwd: process.cwd(), roots });
170
194
  session = bindFrom(resolution.workspaceRoot);
171
195
  return session;
172
196
  } catch {
@@ -182,6 +206,9 @@ async function main() {
182
206
  let request;
183
207
  try { request = JSON.parse(line); } catch { continue; }
184
208
  if (request.method === undefined && request.id !== undefined) {
209
+ if (request.id === rootsReqId) {
210
+ setRoots(request.result && request.result.roots);
211
+ }
185
212
  continue;
186
213
  }
187
214
  const { id, method, params } = request;
@@ -189,10 +216,16 @@ async function main() {
189
216
  try {
190
217
  if (method === 'initialize') {
191
218
  response = { jsonrpc: '2.0', id, result: { protocolVersion: '2024-11-05', capabilities: { tools: {} }, serverInfo: { name: 'argo-thin', version: '1.0.0' } } };
219
+ requestRoots();
192
220
  } else if (typeof method === 'string' && method.startsWith('notifications/')) {
221
+ if (method === 'notifications/initialized') {
222
+ requestRoots();
223
+ } else if (method === 'notifications/roots/list_changed') {
224
+ setRoots(params && params.roots);
225
+ }
193
226
  response = null;
194
227
  } else if (method === 'tools/list') {
195
- const useOnline = (session ? session.mode : (env.ARGO_MODE || 'online')) === 'online';
228
+ const useOnline = (session ? session.mode : (env.ARGO_MODE === 'online' ? 'online' : 'offline')) === 'online';
196
229
  const client = (session && session.client) || envClient;
197
230
  const tools = useOnline && client
198
231
  ? await client.listTools()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "archgraph-argo-beta",
3
- "version": "0.30.0-beta.2",
3
+ "version": "0.30.0-beta.3",
4
4
  "description": "Deploy the ArchGraph ARGO toolchain, skills, and rules (schema, scripts, argo-init skill, global rule) with one command.",
5
5
  "license": "MIT",
6
6
  "bin": {