@devframes/agentic 1.0.0 → 1.1.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.
@@ -4,9 +4,18 @@ export interface ConnectServerOptions {
4
4
  /**
5
5
  * Explicit ports to probe besides the registry, for instances started
6
6
  * before the registry existed, or reachable only by convention. Each port
7
- * is probed at `/` (`http://localhost:<port>/__connection.json`).
7
+ * is probed at {@link ConnectServerOptions.base} (default `/`, i.e.
8
+ * `http://localhost:<port>/__connection.json`).
8
9
  */
9
10
  ports?: number[];
11
+ /**
12
+ * Base path the explicit {@link ConnectServerOptions.ports} probes look for
13
+ * `__connection.json` under, for a devframe or hub mounted below the root
14
+ * of its host (e.g. `/__devtools/` for Vite DevTools). The advertised MCP
15
+ * path is resolved against it. Default `/`. Registry records carry their
16
+ * own base and ignore this.
17
+ */
18
+ base?: string;
10
19
  /** Override the registry directory (`DEVFRAME_INSTANCES_DIR` also applies). */
11
20
  instancesDir?: string;
12
21
  /** Probe timeout per instance, ms. Default 1000. */
@@ -55,4 +64,12 @@ export interface ConnectServerHandle {
55
64
  * Streamable-HTTP endpoint), and holds no domain knowledge of its own.
56
65
  */
57
66
  export declare function startConnectServer(options?: ConnectServerOptions): Promise<ConnectServerHandle>;
67
+ /**
68
+ * Probe an explicit port for a devframe serving `__connection.json` under
69
+ * `base` (default `/`), reusing the registry's origin-candidate probe (a
70
+ * `localhost`-bound server may listen on either address family). The
71
+ * advertised MCP path is relative to that base, as in the registry records
72
+ * the instance shell writes. Exported for focused tests.
73
+ */
74
+ export declare function probePort(port: number, base?: string, timeoutMs?: number): Promise<DevframeInstanceRecord | null>;
58
75
  //#endregion
@@ -4,7 +4,7 @@ import { toAgentToolName } from "devframe/utils/agent-tool-name";
4
4
  import { Client, StreamableHTTPClientTransport } from "@modelcontextprotocol/client";
5
5
  import { StdioServerTransport } from "@modelcontextprotocol/server/stdio";
6
6
  import { Diagnostic } from "devframe/utils/nostics";
7
- import { joinURL } from "devframe/utils/url";
7
+ import { joinURL, withLeadingSlash, withTrailingSlash } from "devframe/utils/url";
8
8
  //#region src/connect/index.ts
9
9
  /**
10
10
  * Resolve the per-record bearer from the {@link ConnectServerOptions.authToken}
@@ -108,7 +108,7 @@ async function index(options) {
108
108
  const records = [...live];
109
109
  for (const port of options.ports ?? []) {
110
110
  if (records.some((r) => r.port === port)) continue;
111
- const probed = await probePort(port, options.timeoutMs);
111
+ const probed = await probePort(port, options.base, options.timeoutMs);
112
112
  if (probed) records.push(probed);
113
113
  }
114
114
  const instances = await Promise.all(records.map(async (record) => {
@@ -137,23 +137,26 @@ async function index(options) {
137
137
  }));
138
138
  return {
139
139
  instances,
140
- ...instances.length === 0 ? { hint: "No running devframe instances found. Start a devframe dev server (with --mcp for tools), or pass --port <n> to devframe connect if the instance predates the registry." } : {}
140
+ ...instances.length === 0 ? { hint: "No running devframe instances found. Start a devframe dev server (with --mcp for tools), or pass --port <n> to devframe connect if the instance predates the registry (plus --base <path> when it is mounted below the root, e.g. --base /__devtools/)." } : {}
141
141
  };
142
142
  }
143
143
  /**
144
- * Probe an explicit port for a devframe serving `__connection.json` at `/`,
145
- * reusing the registry's origin-candidate probe (a `localhost`-bound server
146
- * may listen on either address family).
144
+ * Probe an explicit port for a devframe serving `__connection.json` under
145
+ * `base` (default `/`), reusing the registry's origin-candidate probe (a
146
+ * `localhost`-bound server may listen on either address family). The
147
+ * advertised MCP path is relative to that base, as in the registry records
148
+ * the instance shell writes. Exported for focused tests.
147
149
  */
148
- async function probePort(port, timeoutMs) {
149
- const probed = await probeDevframeOrigin(`http://localhost:${port}`, "/", timeoutMs);
150
+ async function probePort(port, base = "/", timeoutMs) {
151
+ const basePath = withTrailingSlash(withLeadingSlash(base));
152
+ const probed = await probeDevframeOrigin(`http://localhost:${port}`, basePath, timeoutMs);
150
153
  if (!probed) return null;
151
- const mcpPath = probed.meta.mcp ? joinURL("/", probed.meta.mcp.path) : null;
154
+ const mcpPath = probed.meta.mcp ? joinURL(basePath, probed.meta.mcp.path) : null;
152
155
  return {
153
156
  pid: -1,
154
157
  port,
155
158
  origin: probed.origin,
156
- basePath: "/",
159
+ basePath,
157
160
  id: `port-${port}`,
158
161
  rootDir: "",
159
162
  mcp: mcpPath ? { path: mcpPath } : null,
@@ -169,7 +172,7 @@ async function call(options, args) {
169
172
  instancesDir: options.instancesDir,
170
173
  timeoutMs: options.timeoutMs
171
174
  });
172
- const record = live.find((record) => record.port === args.port && record.mcp) ?? await probePort(args.port, options.timeoutMs);
175
+ const record = live.find((record) => record.port === args.port && record.mcp) ?? await probePort(args.port, options.base, options.timeoutMs);
173
176
  if (!record) throw diagnostics.DF0050({ port: args.port });
174
177
  if (!record.mcp) throw diagnostics.DF0051({ port: args.port });
175
178
  return withInstanceClient(`${record.origin}${record.mcp.path}`, resolveAuthToken(options.authToken, record), async (client) => {
@@ -235,4 +238,4 @@ function errorResult(error) {
235
238
  };
236
239
  }
237
240
  //#endregion
238
- export { buildInstanceRequestHeaders, resolveAuthToken, startConnectServer };
241
+ export { buildInstanceRequestHeaders, probePort, resolveAuthToken, startConnectServer };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@devframes/agentic",
3
3
  "type": "module",
4
- "version": "1.0.0",
4
+ "version": "1.1.0",
5
5
  "description": "Agent-surface implementation for devframe: installing it next to devframe enables the MCP adapter (devframe/adapters/mcp) and the devframe connect gateway.",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -30,18 +30,18 @@
30
30
  "dist"
31
31
  ],
32
32
  "peerDependencies": {
33
- "devframe": "1.0.0"
33
+ "devframe": "1.1.0"
34
34
  },
35
35
  "dependencies": {
36
- "@modelcontextprotocol/client": "^2.0.0",
37
- "@modelcontextprotocol/server": "^2.0.0",
38
- "h3": "^2.0.1-rc.31",
36
+ "@modelcontextprotocol/client": "^2.1.0",
37
+ "@modelcontextprotocol/server": "^2.1.0",
38
+ "h3": "^2.0.1-rc.32",
39
39
  "pathe": "^2.0.3"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@standard-schema/spec": "^1.1.0",
43
- "@types/node": "^26.5.1",
44
- "devframe": "1.0.0",
43
+ "@types/node": "^26.6.2",
44
+ "devframe": "1.1.0",
45
45
  "tsdown": "^0.23.0",
46
46
  "valibot": "^1.5.0"
47
47
  },