@datagrout/conduit 0.3.0 → 0.5.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.
- package/README.md +52 -2
- package/dist/{chunk-RED5DKGI.mjs → chunk-26DYCD4G.mjs} +4 -30
- package/dist/chunk-CIESM3BP.mjs +33 -0
- package/dist/chunk-SWH5Y2U7.mjs +69 -0
- package/dist/index.d.mts +294 -10
- package/dist/index.d.ts +294 -10
- package/dist/index.js +478 -5
- package/dist/index.mjs +410 -11
- package/dist/{oauth-OMPWCI2X.mjs → oauth-NSDC2G7W.mjs} +2 -1
- package/dist/onramp-743RJTNI.mjs +13 -0
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ Production-ready MCP client with mTLS identity, OAuth 2.1, semantic discovery, a
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install @datagrout/conduit
|
|
8
|
+
npm install @datagrout/conduit@0.5.0
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Quick Start
|
|
@@ -158,8 +158,58 @@ const client = new Client({ url });
|
|
|
158
158
|
|
|
159
159
|
// JSONRPC — lightweight, stateless, same tools and auth
|
|
160
160
|
const client = new Client({ url, transport: 'jsonrpc' });
|
|
161
|
+
|
|
162
|
+
// WebSocket — bidirectional push
|
|
163
|
+
const client = new Client({
|
|
164
|
+
url: 'wss://gateway.datagrout.ai/servers/{uuid}/ws',
|
|
165
|
+
transport: 'websocket',
|
|
166
|
+
});
|
|
161
167
|
```
|
|
162
168
|
|
|
169
|
+
### WebSocket transport
|
|
170
|
+
|
|
171
|
+
The WebSocket transport uses the `datagrout-jsonrpc.v1` subprotocol over a single persistent `wss://` connection. Concurrent requests are multiplexed; responses correlated by JSON-RPC `id` via `Map<string, { resolve, reject }>`.
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
import { Client } from '@datagrout/conduit';
|
|
175
|
+
|
|
176
|
+
const client = new Client({
|
|
177
|
+
url: 'wss://gateway.datagrout.ai/servers/{uuid}/ws',
|
|
178
|
+
auth: { bearer: 'your-token' },
|
|
179
|
+
transport: 'websocket',
|
|
180
|
+
});
|
|
181
|
+
await client.connect();
|
|
182
|
+
|
|
183
|
+
// Subscribe to server-pushed events
|
|
184
|
+
const sub = await client.subscribe('agents.my-agent-id.events');
|
|
185
|
+
|
|
186
|
+
for await (const event of sub) {
|
|
187
|
+
console.log(event.event, event.data);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
await client.unsubscribe(sub.id);
|
|
191
|
+
await client.disconnect();
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
You can also call `await sub.recv()` for one-event-at-a-time consumption:
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
const event = await sub.recv();
|
|
198
|
+
console.log(event.event, event.data);
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Supported topics:
|
|
202
|
+
|
|
203
|
+
| Topic | Fires when |
|
|
204
|
+
|-------|-----------|
|
|
205
|
+
| `agents.<agent_id>.events` | Agent lifecycle events (plan started, IC completed, grounding failed, …) |
|
|
206
|
+
| `tools.<tool_name>.results` | A specific tool call completes |
|
|
207
|
+
| `tasks.<task_id>.*` | Long-running background task transitions |
|
|
208
|
+
| `flows.<flow_id>.*` | `flow.into` progress and completion |
|
|
209
|
+
| `governor.<server_uuid>` | Governor percept events (file change, schedule, webhook) |
|
|
210
|
+
|
|
211
|
+
**Reconnection**: after a disconnect, calls raise `NotInitializedError`. Re-call `connect()` and re-subscribe — subscriptions do not survive reconnects in v0.4.
|
|
212
|
+
|
|
163
213
|
## API Reference
|
|
164
214
|
|
|
165
215
|
### Client Options
|
|
@@ -168,7 +218,7 @@ const client = new Client({ url, transport: 'jsonrpc' });
|
|
|
168
218
|
new Client(options: {
|
|
169
219
|
url: string;
|
|
170
220
|
auth?: { bearer?: string; apiKey?: string; clientCredentials?: {...} };
|
|
171
|
-
transport?: 'mcp' | 'jsonrpc';
|
|
221
|
+
transport?: 'mcp' | 'jsonrpc' | 'websocket';
|
|
172
222
|
useIntelligentInterface?: boolean;
|
|
173
223
|
identity?: ConduitIdentity;
|
|
174
224
|
identityAuto?: boolean;
|
|
@@ -1,29 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
6
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
7
|
-
}) : x)(function(x) {
|
|
8
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
9
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
10
|
-
});
|
|
11
|
-
var __esm = (fn, res) => function __init() {
|
|
12
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
13
|
-
};
|
|
14
|
-
var __export = (target, all) => {
|
|
15
|
-
for (var name in all)
|
|
16
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
-
};
|
|
18
|
-
var __copyProps = (to, from, except, desc) => {
|
|
19
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
-
for (let key of __getOwnPropNames(from))
|
|
21
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
-
}
|
|
24
|
-
return to;
|
|
25
|
-
};
|
|
26
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
import {
|
|
2
|
+
__esm,
|
|
3
|
+
__export
|
|
4
|
+
} from "./chunk-CIESM3BP.mjs";
|
|
27
5
|
|
|
28
6
|
// src/oauth.ts
|
|
29
7
|
var oauth_exports = {};
|
|
@@ -111,10 +89,6 @@ var init_oauth = __esm({
|
|
|
111
89
|
});
|
|
112
90
|
|
|
113
91
|
export {
|
|
114
|
-
__require,
|
|
115
|
-
__esm,
|
|
116
|
-
__export,
|
|
117
|
-
__toCommonJS,
|
|
118
92
|
deriveTokenEndpoint,
|
|
119
93
|
OAuthTokenProvider,
|
|
120
94
|
oauth_exports,
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
6
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
7
|
+
}) : x)(function(x) {
|
|
8
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
9
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
10
|
+
});
|
|
11
|
+
var __esm = (fn, res) => function __init() {
|
|
12
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
13
|
+
};
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
__require,
|
|
30
|
+
__esm,
|
|
31
|
+
__export,
|
|
32
|
+
__toCommonJS
|
|
33
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// src/onramp.ts
|
|
2
|
+
async function _doRegister(opts) {
|
|
3
|
+
const base = opts.gateway.replace(/\/$/, "");
|
|
4
|
+
const body = { agent_name: opts.agentName };
|
|
5
|
+
if (opts.agentType) body["agent_type"] = opts.agentType;
|
|
6
|
+
if (opts.intendedUse) body["intended_use"] = opts.intendedUse;
|
|
7
|
+
if (opts.accessCode) body["access_code"] = opts.accessCode;
|
|
8
|
+
const initResp = await fetch(`${base}/onramp`, {
|
|
9
|
+
method: "POST",
|
|
10
|
+
headers: { "Content-Type": "application/json" },
|
|
11
|
+
body: JSON.stringify(body)
|
|
12
|
+
});
|
|
13
|
+
if (!initResp.ok) {
|
|
14
|
+
const text = await initResp.text();
|
|
15
|
+
throw new Error(`onramp init rejected (HTTP ${initResp.status}): ${text}`);
|
|
16
|
+
}
|
|
17
|
+
const initData = await initResp.json();
|
|
18
|
+
const sessionToken = initData.session_token;
|
|
19
|
+
const completeResp = await fetch(`${base}/onramp/complete`, {
|
|
20
|
+
method: "POST",
|
|
21
|
+
headers: { Authorization: `Bearer ${sessionToken}` }
|
|
22
|
+
});
|
|
23
|
+
if (!completeResp.ok) {
|
|
24
|
+
const text = await completeResp.text();
|
|
25
|
+
throw new Error(`onramp complete rejected (HTTP ${completeResp.status}): ${text}`);
|
|
26
|
+
}
|
|
27
|
+
const data = await completeResp.json();
|
|
28
|
+
return {
|
|
29
|
+
clientId: data["client_id"],
|
|
30
|
+
clientSecret: data["client_secret"],
|
|
31
|
+
tokenUrl: data["token_url"],
|
|
32
|
+
scopes: data["scopes"] ?? [],
|
|
33
|
+
expiresIn: data["expires_in"] ?? 0,
|
|
34
|
+
rpcUrl: data["rpc_url"],
|
|
35
|
+
mcpUrl: data["mcp_url"]
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
async function _exchangeToken(creds) {
|
|
39
|
+
const body = new URLSearchParams({
|
|
40
|
+
grant_type: "client_credentials",
|
|
41
|
+
client_id: creds.clientId,
|
|
42
|
+
client_secret: creds.clientSecret
|
|
43
|
+
});
|
|
44
|
+
const resp = await fetch(creds.tokenUrl, {
|
|
45
|
+
method: "POST",
|
|
46
|
+
body
|
|
47
|
+
});
|
|
48
|
+
if (!resp.ok) {
|
|
49
|
+
const text = await resp.text();
|
|
50
|
+
throw new Error(`token exchange failed (HTTP ${resp.status}): ${text}`);
|
|
51
|
+
}
|
|
52
|
+
const data = await resp.json();
|
|
53
|
+
return data.access_token;
|
|
54
|
+
}
|
|
55
|
+
async function registerOnly(opts) {
|
|
56
|
+
return _doRegister(opts);
|
|
57
|
+
}
|
|
58
|
+
async function registerAndExchange(opts) {
|
|
59
|
+
const creds = await _doRegister(opts);
|
|
60
|
+
const token = await _exchangeToken(creds);
|
|
61
|
+
return [creds, token];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export {
|
|
65
|
+
_doRegister,
|
|
66
|
+
_exchangeToken,
|
|
67
|
+
registerOnly,
|
|
68
|
+
registerAndExchange
|
|
69
|
+
};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Autonomous agent self-registration (onramp) for DataGrout.
|
|
3
|
+
*
|
|
4
|
+
* The onramp flow lets a machine intelligence register itself with DG
|
|
5
|
+
* without a human in the loop, using only plain HTTP JSON — no MCP client
|
|
6
|
+
* required. This matters because many agent harnesses gate or restrict MCP
|
|
7
|
+
* connections but allow arbitrary HTTP requests.
|
|
8
|
+
*
|
|
9
|
+
* Flow
|
|
10
|
+
* ----
|
|
11
|
+
* 1. POST to `/onramp` with agent identity metadata (no auth).
|
|
12
|
+
* 2. DG returns a short-lived `session_token` (5 minutes).
|
|
13
|
+
* 3. POST to `/onramp/complete` with `Authorization: Bearer <session_token>`.
|
|
14
|
+
* 4. DG issues provisional `client_id` + `client_secret` (restricted scopes).
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { Client } from './client';
|
|
19
|
+
* import { OnrampOptions } from './onramp';
|
|
20
|
+
*
|
|
21
|
+
* // One-shot: autonomous registration + mTLS bootstrap.
|
|
22
|
+
* const client = await Client.bootstrapOnramp({
|
|
23
|
+
* opts: {
|
|
24
|
+
* gateway: 'https://app.datagrout.ai',
|
|
25
|
+
* agentName: 'my-research-agent',
|
|
26
|
+
* agentType: 'claude-sonnet-4-6',
|
|
27
|
+
* intendedUse: 'Summarise documents and extract entities.',
|
|
28
|
+
* },
|
|
29
|
+
* });
|
|
30
|
+
* await client.connect();
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
/** Options for the autonomous agent onramp flow. */
|
|
34
|
+
interface OnrampOptions {
|
|
35
|
+
/** DataGrout gateway base URL (e.g. `"https://app.datagrout.ai"`). */
|
|
36
|
+
gateway: string;
|
|
37
|
+
/** Human-readable name for this agent instance. */
|
|
38
|
+
agentName: string;
|
|
39
|
+
/** Model or framework identifier (e.g. `"claude-sonnet-4-6"`, `"gpt-4o"`). */
|
|
40
|
+
agentType?: string;
|
|
41
|
+
/** Plain-language description of what the agent intends to do. */
|
|
42
|
+
intendedUse?: string;
|
|
43
|
+
/** Optional access code from the server owner — reserved for scope elevation. */
|
|
44
|
+
accessCode?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Provisional credentials returned by the DG onramp complete endpoint.
|
|
48
|
+
*
|
|
49
|
+
* Store `clientId` and `clientSecret` securely — the secret is shown exactly
|
|
50
|
+
* once and cannot be recovered after this point.
|
|
51
|
+
*
|
|
52
|
+
* `mcpUrl` and `rpcUrl` are provisioned as part of the identity registration
|
|
53
|
+
* step and may be absent from the initial onramp response. Use
|
|
54
|
+
* `Client.bootstrapOnramp` for the all-in-one flow that handles this
|
|
55
|
+
* transparently.
|
|
56
|
+
*/
|
|
57
|
+
interface OnrampCredentials {
|
|
58
|
+
/** OAuth client ID. */
|
|
59
|
+
clientId: string;
|
|
60
|
+
/** OAuth client secret. Store this securely — shown once. */
|
|
61
|
+
clientSecret: string;
|
|
62
|
+
/** Token endpoint for the `client_credentials` grant. */
|
|
63
|
+
tokenUrl: string;
|
|
64
|
+
/** Granted OAuth scopes. */
|
|
65
|
+
scopes: string[];
|
|
66
|
+
/** Provisional credential TTL in seconds. */
|
|
67
|
+
expiresIn: number;
|
|
68
|
+
/** JSON-RPC endpoint. Absent until identity is registered. */
|
|
69
|
+
rpcUrl?: string;
|
|
70
|
+
/** MCP endpoint. Absent until identity is registered. */
|
|
71
|
+
mcpUrl?: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Perform the onramp handshake and return provisional OAuth credentials.
|
|
75
|
+
*
|
|
76
|
+
* This is the low-level entry point. Most callers should use
|
|
77
|
+
* `Client.bootstrapOnramp` instead, which chains onramp → token exchange →
|
|
78
|
+
* mTLS identity bootstrap in a single call.
|
|
79
|
+
*
|
|
80
|
+
* @param opts Onramp registration options.
|
|
81
|
+
* @returns `OnrampCredentials` containing `clientId` and `clientSecret`.
|
|
82
|
+
*/
|
|
83
|
+
declare function registerOnly(opts: OnrampOptions): Promise<OnrampCredentials>;
|
|
84
|
+
/**
|
|
85
|
+
* Perform the full onramp handshake and OAuth token exchange.
|
|
86
|
+
*
|
|
87
|
+
* Returns the provisional credentials alongside a short-lived access token
|
|
88
|
+
* ready for use with `Client.bootstrapIdentity`.
|
|
89
|
+
*
|
|
90
|
+
* @param opts Onramp registration options.
|
|
91
|
+
* @returns Tuple of `[OnrampCredentials, accessToken]`.
|
|
92
|
+
*/
|
|
93
|
+
declare function registerAndExchange(opts: OnrampOptions): Promise<[OnrampCredentials, string]>;
|
|
94
|
+
|
|
1
95
|
/**
|
|
2
96
|
* Identity and mTLS support for Conduit connections.
|
|
3
97
|
*
|
|
@@ -256,6 +350,7 @@ interface GuideState {
|
|
|
256
350
|
}
|
|
257
351
|
interface AuthConfig {
|
|
258
352
|
bearer?: string;
|
|
353
|
+
apiKey?: string;
|
|
259
354
|
basic?: {
|
|
260
355
|
username: string;
|
|
261
356
|
password: string;
|
|
@@ -294,6 +389,9 @@ interface ClientOptions {
|
|
|
294
389
|
* `~/.conduit/` before falling back to token auth. Equivalent to
|
|
295
390
|
* calling `ConduitIdentity.tryDefault()` and passing the result as
|
|
296
391
|
* `identity`.
|
|
392
|
+
*
|
|
393
|
+
* mTLS auto-discovery is **opt-in** — this flag must be set to enable it.
|
|
394
|
+
* DataGrout URLs do not auto-discover an identity by default.
|
|
297
395
|
*/
|
|
298
396
|
identityAuto?: boolean;
|
|
299
397
|
/**
|
|
@@ -312,16 +410,11 @@ interface ClientOptions {
|
|
|
312
410
|
*/
|
|
313
411
|
useIntelligentInterface?: boolean;
|
|
314
412
|
/**
|
|
315
|
-
*
|
|
316
|
-
*
|
|
317
|
-
* By default, DG URLs (`*.datagrout.ai`) silently attempt to discover an
|
|
318
|
-
* mTLS identity from env vars or `~/.conduit/`. Set to `true` to opt out
|
|
319
|
-
* and use token-only auth.
|
|
320
|
-
*
|
|
321
|
-
* @default false
|
|
413
|
+
* @deprecated No-op. mTLS auto-discovery is now opt-in via `identityAuto`.
|
|
414
|
+
* This option is kept for backward compatibility and has no effect.
|
|
322
415
|
*/
|
|
323
416
|
disableMtls?: boolean;
|
|
324
|
-
transport?: 'mcp' | 'jsonrpc';
|
|
417
|
+
transport?: 'mcp' | 'jsonrpc' | 'websocket';
|
|
325
418
|
timeout?: number;
|
|
326
419
|
/**
|
|
327
420
|
* Maximum number of automatic retries on "server not initialized" errors.
|
|
@@ -461,6 +554,136 @@ interface MCPPrompt {
|
|
|
461
554
|
}>;
|
|
462
555
|
}
|
|
463
556
|
|
|
557
|
+
/**
|
|
558
|
+
* Base transport interface
|
|
559
|
+
*/
|
|
560
|
+
|
|
561
|
+
declare abstract class Transport {
|
|
562
|
+
abstract connect(): Promise<void>;
|
|
563
|
+
abstract disconnect(): Promise<void>;
|
|
564
|
+
abstract listTools(options?: any): Promise<MCPTool[]>;
|
|
565
|
+
abstract callTool(name: string, args: Record<string, any>, options?: any): Promise<any>;
|
|
566
|
+
abstract listResources(options?: any): Promise<MCPResource[]>;
|
|
567
|
+
abstract readResource(uri: string, options?: any): Promise<any>;
|
|
568
|
+
abstract listPrompts(options?: any): Promise<MCPPrompt[]>;
|
|
569
|
+
abstract getPrompt(name: string, args?: Record<string, any>, options?: any): Promise<any>;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* WebSocket transport for `datagrout-jsonrpc.v1`.
|
|
574
|
+
*
|
|
575
|
+
* Recommended for any client that needs bidirectional push (server-initiated
|
|
576
|
+
* notifications) without a polling loop. A single `wss://` connection is
|
|
577
|
+
* multiplexed for all in-flight requests; concurrent calls are correlated by
|
|
578
|
+
* JSON-RPC `id` with no head-of-line blocking.
|
|
579
|
+
*
|
|
580
|
+
* @example
|
|
581
|
+
* ```ts
|
|
582
|
+
* const client = new Client({
|
|
583
|
+
* url: 'wss://gateway.datagrout.ai/servers/<uuid>/ws',
|
|
584
|
+
* transport: 'websocket',
|
|
585
|
+
* auth: { bearer: 'your-token' },
|
|
586
|
+
* });
|
|
587
|
+
* await client.connect();
|
|
588
|
+
*
|
|
589
|
+
* // Push subscription
|
|
590
|
+
* const sub = await client.subscribe('agents.my-agent-id.events');
|
|
591
|
+
* for await (const event of sub) {
|
|
592
|
+
* console.log(event.event, event.data);
|
|
593
|
+
* }
|
|
594
|
+
* await client.unsubscribe(sub.id);
|
|
595
|
+
* ```
|
|
596
|
+
*
|
|
597
|
+
* @module
|
|
598
|
+
*/
|
|
599
|
+
|
|
600
|
+
declare const SUBPROTOCOL = "datagrout-jsonrpc.v1";
|
|
601
|
+
/** A single server-pushed notification. */
|
|
602
|
+
interface SubscriptionEvent {
|
|
603
|
+
/** The subscription id this event belongs to. */
|
|
604
|
+
subscription: string;
|
|
605
|
+
/** Server-named event slug (e.g. `"agent.thought"`). */
|
|
606
|
+
event: string;
|
|
607
|
+
/** Free-form payload from the server. */
|
|
608
|
+
data: unknown;
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Handle for an active server-push subscription.
|
|
612
|
+
*
|
|
613
|
+
* Consume events with {@link Subscription.recv} or an async-for loop:
|
|
614
|
+
* ```ts
|
|
615
|
+
* for await (const event of sub) {
|
|
616
|
+
* handle(event);
|
|
617
|
+
* }
|
|
618
|
+
* ```
|
|
619
|
+
*/
|
|
620
|
+
declare class Subscription {
|
|
621
|
+
readonly id: string;
|
|
622
|
+
readonly topic: string;
|
|
623
|
+
private _queue;
|
|
624
|
+
private _waiters;
|
|
625
|
+
private _rejecters;
|
|
626
|
+
private _closed;
|
|
627
|
+
constructor(id: string, topic: string);
|
|
628
|
+
/**
|
|
629
|
+
* Wait for the next event from this subscription.
|
|
630
|
+
*
|
|
631
|
+
* @throws When the subscription has been closed.
|
|
632
|
+
*/
|
|
633
|
+
recv(): Promise<SubscriptionEvent>;
|
|
634
|
+
[Symbol.asyncIterator](): AsyncGenerator<SubscriptionEvent>;
|
|
635
|
+
_enqueue(event: SubscriptionEvent): void;
|
|
636
|
+
_close(): void;
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* JSON-RPC 2.0 over WebSocket transport (`datagrout-jsonrpc.v1`).
|
|
640
|
+
*
|
|
641
|
+
* Multiplexes any number of in-flight requests on one socket and routes
|
|
642
|
+
* server-pushed notifications back to {@link Subscription} queues.
|
|
643
|
+
*/
|
|
644
|
+
declare class WsTransport extends Transport {
|
|
645
|
+
private readonly _url;
|
|
646
|
+
private readonly _auth?;
|
|
647
|
+
private _ws;
|
|
648
|
+
private _nextId;
|
|
649
|
+
private readonly _pending;
|
|
650
|
+
private readonly _pendingSubscribe;
|
|
651
|
+
private readonly _subscriptions;
|
|
652
|
+
constructor(url: string, auth?: AuthConfig, _timeout?: number, _identity?: ConduitIdentity);
|
|
653
|
+
connect(): Promise<void>;
|
|
654
|
+
disconnect(): Promise<void>;
|
|
655
|
+
/**
|
|
656
|
+
* Open a server-side push subscription for `topic`.
|
|
657
|
+
*
|
|
658
|
+
* @param topic - Dotted namespace topic, e.g.
|
|
659
|
+
* `"agents.my-agent-id.events"` or `"tasks.task-123.*"`.
|
|
660
|
+
* @returns A {@link Subscription} handle whose async-for loop delivers events.
|
|
661
|
+
*/
|
|
662
|
+
subscribe(topic: string): Promise<Subscription>;
|
|
663
|
+
/**
|
|
664
|
+
* Cancel a server-side subscription.
|
|
665
|
+
*
|
|
666
|
+
* The local {@link Subscription} queue is closed immediately.
|
|
667
|
+
*
|
|
668
|
+
* @param subscriptionId - The `id` field from the {@link Subscription}
|
|
669
|
+
* returned by {@link subscribe}.
|
|
670
|
+
*/
|
|
671
|
+
unsubscribe(subscriptionId: string): Promise<void>;
|
|
672
|
+
listTools(options?: any): Promise<MCPTool[]>;
|
|
673
|
+
callTool(name: string, args: Record<string, any>, _options?: any): Promise<any>;
|
|
674
|
+
listResources(_options?: any): Promise<MCPResource[]>;
|
|
675
|
+
readResource(uri: string, _options?: any): Promise<any>;
|
|
676
|
+
listPrompts(_options?: any): Promise<MCPPrompt[]>;
|
|
677
|
+
getPrompt(name: string, args?: Record<string, any>, _options?: any): Promise<any>;
|
|
678
|
+
private _mintId;
|
|
679
|
+
private _requireConnected;
|
|
680
|
+
private _send;
|
|
681
|
+
private _request;
|
|
682
|
+
private _handleMessage;
|
|
683
|
+
private _routeNotification;
|
|
684
|
+
private _failAll;
|
|
685
|
+
}
|
|
686
|
+
|
|
464
687
|
/**
|
|
465
688
|
* Prism namespace — data transformation, charting, rendering, and export.
|
|
466
689
|
*/
|
|
@@ -759,6 +982,40 @@ declare class Client {
|
|
|
759
982
|
identityDir?: string;
|
|
760
983
|
substrateEndpoint?: string;
|
|
761
984
|
}): Promise<Client>;
|
|
985
|
+
/**
|
|
986
|
+
* Register autonomously with DG and bootstrap an mTLS identity.
|
|
987
|
+
*
|
|
988
|
+
* The all-in-one flow: onramp (no prior credentials required) →
|
|
989
|
+
* OAuth token exchange → mTLS identity registration and persistence.
|
|
990
|
+
*
|
|
991
|
+
* On subsequent runs the saved mTLS identity is auto-discovered and
|
|
992
|
+
* no credentials are needed.
|
|
993
|
+
*
|
|
994
|
+
* @param options.opts - Onramp registration options.
|
|
995
|
+
* @param options.url - MCP server URL. Required if the onramp
|
|
996
|
+
* response does not include `mcpUrl`.
|
|
997
|
+
* @param options.identityDir - Custom identity storage directory.
|
|
998
|
+
*
|
|
999
|
+
* @example
|
|
1000
|
+
* ```ts
|
|
1001
|
+
* import { Client } from './client';
|
|
1002
|
+
* import type { OnrampOptions } from './onramp';
|
|
1003
|
+
*
|
|
1004
|
+
* const client = await Client.bootstrapOnramp({
|
|
1005
|
+
* opts: {
|
|
1006
|
+
* gateway: 'https://app.datagrout.ai',
|
|
1007
|
+
* agentName: 'my-research-agent',
|
|
1008
|
+
* agentType: 'claude-sonnet-4-6',
|
|
1009
|
+
* },
|
|
1010
|
+
* });
|
|
1011
|
+
* await client.connect();
|
|
1012
|
+
* ```
|
|
1013
|
+
*/
|
|
1014
|
+
static bootstrapOnramp(options: {
|
|
1015
|
+
opts: OnrampOptions;
|
|
1016
|
+
url?: string;
|
|
1017
|
+
identityDir?: string;
|
|
1018
|
+
}): Promise<Client>;
|
|
762
1019
|
/**
|
|
763
1020
|
* Establish the underlying transport connection.
|
|
764
1021
|
*
|
|
@@ -842,6 +1099,33 @@ declare class Client {
|
|
|
842
1099
|
* @param args - Template argument values.
|
|
843
1100
|
*/
|
|
844
1101
|
getPrompt(name: string, args?: Record<string, any>, options?: any): Promise<any>;
|
|
1102
|
+
/**
|
|
1103
|
+
* Subscribe to a server-push topic (WebSocket transport only).
|
|
1104
|
+
*
|
|
1105
|
+
* Requires `transport: 'websocket'` when constructing the client.
|
|
1106
|
+
*
|
|
1107
|
+
* @param topic - Dotted namespace topic, e.g.
|
|
1108
|
+
* `"agents.my-agent-id.events"` or `"tasks.task-123.*"`.
|
|
1109
|
+
* @returns A {@link Subscription} handle. Consume events with
|
|
1110
|
+
* {@link Subscription.recv} or an `for await` loop.
|
|
1111
|
+
*
|
|
1112
|
+
* @example
|
|
1113
|
+
* ```ts
|
|
1114
|
+
* const sub = await client.subscribe('agents.my-agent-id.events');
|
|
1115
|
+
* for await (const event of sub) {
|
|
1116
|
+
* console.log(event.event, event.data);
|
|
1117
|
+
* }
|
|
1118
|
+
* await client.unsubscribe(sub.id);
|
|
1119
|
+
* ```
|
|
1120
|
+
*/
|
|
1121
|
+
subscribe(topic: string): Promise<Subscription>;
|
|
1122
|
+
/**
|
|
1123
|
+
* Cancel a server-side push subscription.
|
|
1124
|
+
*
|
|
1125
|
+
* @param subscriptionId - The `id` from the {@link Subscription} returned
|
|
1126
|
+
* by {@link subscribe}.
|
|
1127
|
+
*/
|
|
1128
|
+
unsubscribe(subscriptionId: string): Promise<void>;
|
|
845
1129
|
private warnIfNotDg;
|
|
846
1130
|
/**
|
|
847
1131
|
* Semantically discover tools relevant to a goal or query.
|
|
@@ -1223,6 +1507,6 @@ declare class InvalidConfigError extends ConduitError {
|
|
|
1223
1507
|
* DataGrout Conduit SDK for TypeScript/JavaScript
|
|
1224
1508
|
*/
|
|
1225
1509
|
|
|
1226
|
-
declare const version = "0.
|
|
1510
|
+
declare const version = "0.5.0";
|
|
1227
1511
|
|
|
1228
|
-
export { type AuthConfig, AuthError, type Byok, type ChartOptions, Client, type ClientOptions, ConduitError, ConduitIdentity, type ConstrainOptions, type CreditEstimate, DEFAULT_IDENTITY_DIR, DG_CA_URL, DG_SUBSTRATE_ENDPOINT, type DiscoverOptions, type DiscoverResult, type FlowOptions, type ForgetOptions, type GuideOptions, type GuideRequestOptions, type GuideState, GuidedSession, InvalidConfigError, type Keypair, type MCPPrompt, type MCPResource, type MCPTool, type MtlsConfig, NetworkError, NotInitializedError, OAuthTokenProvider, type PerformOptions, type PerformResult, type PlanOptions, type PrismFocusOptions, type QueryCellOptions, type RateLimit, RateLimitError, type RateLimitStatus, type Receipt, type ReflectOptions, type RefractOptions, type RegisteredIdentity, type RegistrationOptions, type RememberOptions, type RenewalOptions, type RotationOptions, type SavedPaths, ServerError, type ToolInfo, type ToolMeta, deriveTokenEndpoint, extractMeta, fetchDgCaCert, fetchWithIdentity, generateKeypair, isDgUrl, refreshCaCert, registerIdentity, rotateIdentity, saveIdentity, version };
|
|
1512
|
+
export { type AuthConfig, AuthError, type Byok, type ChartOptions, Client, type ClientOptions, ConduitError, ConduitIdentity, type ConstrainOptions, type CreditEstimate, DEFAULT_IDENTITY_DIR, DG_CA_URL, DG_SUBSTRATE_ENDPOINT, type DiscoverOptions, type DiscoverResult, type FlowOptions, type ForgetOptions, type GuideOptions, type GuideRequestOptions, type GuideState, GuidedSession, InvalidConfigError, type Keypair, type MCPPrompt, type MCPResource, type MCPTool, type MtlsConfig, NetworkError, NotInitializedError, OAuthTokenProvider, type OnrampCredentials, type OnrampOptions, type PerformOptions, type PerformResult, type PlanOptions, type PrismFocusOptions, type QueryCellOptions, type RateLimit, RateLimitError, type RateLimitStatus, type Receipt, type ReflectOptions, type RefractOptions, type RegisteredIdentity, type RegistrationOptions, type RememberOptions, type RenewalOptions, type RotationOptions, type SavedPaths, ServerError, Subscription, type SubscriptionEvent, type ToolInfo, type ToolMeta, SUBPROTOCOL as WS_SUBPROTOCOL, WsTransport, deriveTokenEndpoint, extractMeta, fetchDgCaCert, fetchWithIdentity, generateKeypair, isDgUrl, refreshCaCert, registerAndExchange, registerIdentity, registerOnly, rotateIdentity, saveIdentity, version };
|