@datagrout/conduit 0.4.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 +1 -1
- 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 +135 -9
- package/dist/index.d.ts +135 -9
- package/dist/index.js +136 -5
- package/dist/index.mjs +70 -11
- package/dist/{oauth-OMPWCI2X.mjs → oauth-NSDC2G7W.mjs} +2 -1
- package/dist/onramp-743RJTNI.mjs +13 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -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
|
*
|
|
@@ -295,6 +389,9 @@ interface ClientOptions {
|
|
|
295
389
|
* `~/.conduit/` before falling back to token auth. Equivalent to
|
|
296
390
|
* calling `ConduitIdentity.tryDefault()` and passing the result as
|
|
297
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.
|
|
298
395
|
*/
|
|
299
396
|
identityAuto?: boolean;
|
|
300
397
|
/**
|
|
@@ -313,13 +410,8 @@ interface ClientOptions {
|
|
|
313
410
|
*/
|
|
314
411
|
useIntelligentInterface?: boolean;
|
|
315
412
|
/**
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
* By default, DG URLs (`*.datagrout.ai`) silently attempt to discover an
|
|
319
|
-
* mTLS identity from env vars or `~/.conduit/`. Set to `true` to opt out
|
|
320
|
-
* and use token-only auth.
|
|
321
|
-
*
|
|
322
|
-
* @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.
|
|
323
415
|
*/
|
|
324
416
|
disableMtls?: boolean;
|
|
325
417
|
transport?: 'mcp' | 'jsonrpc' | 'websocket';
|
|
@@ -890,6 +982,40 @@ declare class Client {
|
|
|
890
982
|
identityDir?: string;
|
|
891
983
|
substrateEndpoint?: string;
|
|
892
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>;
|
|
893
1019
|
/**
|
|
894
1020
|
* Establish the underlying transport connection.
|
|
895
1021
|
*
|
|
@@ -1381,6 +1507,6 @@ declare class InvalidConfigError extends ConduitError {
|
|
|
1381
1507
|
* DataGrout Conduit SDK for TypeScript/JavaScript
|
|
1382
1508
|
*/
|
|
1383
1509
|
|
|
1384
|
-
declare const version = "0.
|
|
1510
|
+
declare const version = "0.5.0";
|
|
1385
1511
|
|
|
1386
|
-
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, Subscription, type SubscriptionEvent, type ToolInfo, type ToolMeta, SUBPROTOCOL as WS_SUBPROTOCOL, WsTransport, 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 };
|
package/dist/index.d.ts
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
|
*
|
|
@@ -295,6 +389,9 @@ interface ClientOptions {
|
|
|
295
389
|
* `~/.conduit/` before falling back to token auth. Equivalent to
|
|
296
390
|
* calling `ConduitIdentity.tryDefault()` and passing the result as
|
|
297
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.
|
|
298
395
|
*/
|
|
299
396
|
identityAuto?: boolean;
|
|
300
397
|
/**
|
|
@@ -313,13 +410,8 @@ interface ClientOptions {
|
|
|
313
410
|
*/
|
|
314
411
|
useIntelligentInterface?: boolean;
|
|
315
412
|
/**
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
* By default, DG URLs (`*.datagrout.ai`) silently attempt to discover an
|
|
319
|
-
* mTLS identity from env vars or `~/.conduit/`. Set to `true` to opt out
|
|
320
|
-
* and use token-only auth.
|
|
321
|
-
*
|
|
322
|
-
* @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.
|
|
323
415
|
*/
|
|
324
416
|
disableMtls?: boolean;
|
|
325
417
|
transport?: 'mcp' | 'jsonrpc' | 'websocket';
|
|
@@ -890,6 +982,40 @@ declare class Client {
|
|
|
890
982
|
identityDir?: string;
|
|
891
983
|
substrateEndpoint?: string;
|
|
892
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>;
|
|
893
1019
|
/**
|
|
894
1020
|
* Establish the underlying transport connection.
|
|
895
1021
|
*
|
|
@@ -1381,6 +1507,6 @@ declare class InvalidConfigError extends ConduitError {
|
|
|
1381
1507
|
* DataGrout Conduit SDK for TypeScript/JavaScript
|
|
1382
1508
|
*/
|
|
1383
1509
|
|
|
1384
|
-
declare const version = "0.
|
|
1510
|
+
declare const version = "0.5.0";
|
|
1385
1511
|
|
|
1386
|
-
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, Subscription, type SubscriptionEvent, type ToolInfo, type ToolMeta, SUBPROTOCOL as WS_SUBPROTOCOL, WsTransport, 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 };
|
package/dist/index.js
CHANGED
|
@@ -343,6 +343,81 @@ var init_identity = __esm({
|
|
|
343
343
|
}
|
|
344
344
|
});
|
|
345
345
|
|
|
346
|
+
// src/onramp.ts
|
|
347
|
+
var onramp_exports = {};
|
|
348
|
+
__export(onramp_exports, {
|
|
349
|
+
_doRegister: () => _doRegister,
|
|
350
|
+
_exchangeToken: () => _exchangeToken,
|
|
351
|
+
registerAndExchange: () => registerAndExchange,
|
|
352
|
+
registerOnly: () => registerOnly
|
|
353
|
+
});
|
|
354
|
+
async function _doRegister(opts) {
|
|
355
|
+
const base = opts.gateway.replace(/\/$/, "");
|
|
356
|
+
const body = { agent_name: opts.agentName };
|
|
357
|
+
if (opts.agentType) body["agent_type"] = opts.agentType;
|
|
358
|
+
if (opts.intendedUse) body["intended_use"] = opts.intendedUse;
|
|
359
|
+
if (opts.accessCode) body["access_code"] = opts.accessCode;
|
|
360
|
+
const initResp = await fetch(`${base}/onramp`, {
|
|
361
|
+
method: "POST",
|
|
362
|
+
headers: { "Content-Type": "application/json" },
|
|
363
|
+
body: JSON.stringify(body)
|
|
364
|
+
});
|
|
365
|
+
if (!initResp.ok) {
|
|
366
|
+
const text = await initResp.text();
|
|
367
|
+
throw new Error(`onramp init rejected (HTTP ${initResp.status}): ${text}`);
|
|
368
|
+
}
|
|
369
|
+
const initData = await initResp.json();
|
|
370
|
+
const sessionToken = initData.session_token;
|
|
371
|
+
const completeResp = await fetch(`${base}/onramp/complete`, {
|
|
372
|
+
method: "POST",
|
|
373
|
+
headers: { Authorization: `Bearer ${sessionToken}` }
|
|
374
|
+
});
|
|
375
|
+
if (!completeResp.ok) {
|
|
376
|
+
const text = await completeResp.text();
|
|
377
|
+
throw new Error(`onramp complete rejected (HTTP ${completeResp.status}): ${text}`);
|
|
378
|
+
}
|
|
379
|
+
const data = await completeResp.json();
|
|
380
|
+
return {
|
|
381
|
+
clientId: data["client_id"],
|
|
382
|
+
clientSecret: data["client_secret"],
|
|
383
|
+
tokenUrl: data["token_url"],
|
|
384
|
+
scopes: data["scopes"] ?? [],
|
|
385
|
+
expiresIn: data["expires_in"] ?? 0,
|
|
386
|
+
rpcUrl: data["rpc_url"],
|
|
387
|
+
mcpUrl: data["mcp_url"]
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
async function _exchangeToken(creds) {
|
|
391
|
+
const body = new URLSearchParams({
|
|
392
|
+
grant_type: "client_credentials",
|
|
393
|
+
client_id: creds.clientId,
|
|
394
|
+
client_secret: creds.clientSecret
|
|
395
|
+
});
|
|
396
|
+
const resp = await fetch(creds.tokenUrl, {
|
|
397
|
+
method: "POST",
|
|
398
|
+
body
|
|
399
|
+
});
|
|
400
|
+
if (!resp.ok) {
|
|
401
|
+
const text = await resp.text();
|
|
402
|
+
throw new Error(`token exchange failed (HTTP ${resp.status}): ${text}`);
|
|
403
|
+
}
|
|
404
|
+
const data = await resp.json();
|
|
405
|
+
return data.access_token;
|
|
406
|
+
}
|
|
407
|
+
async function registerOnly(opts) {
|
|
408
|
+
return _doRegister(opts);
|
|
409
|
+
}
|
|
410
|
+
async function registerAndExchange(opts) {
|
|
411
|
+
const creds = await _doRegister(opts);
|
|
412
|
+
const token = await _exchangeToken(creds);
|
|
413
|
+
return [creds, token];
|
|
414
|
+
}
|
|
415
|
+
var init_onramp = __esm({
|
|
416
|
+
"src/onramp.ts"() {
|
|
417
|
+
"use strict";
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
|
|
346
421
|
// src/index.ts
|
|
347
422
|
var index_exports = {};
|
|
348
423
|
__export(index_exports, {
|
|
@@ -369,7 +444,9 @@ __export(index_exports, {
|
|
|
369
444
|
generateKeypair: () => generateKeypair,
|
|
370
445
|
isDgUrl: () => isDgUrl,
|
|
371
446
|
refreshCaCert: () => refreshCaCert,
|
|
447
|
+
registerAndExchange: () => registerAndExchange,
|
|
372
448
|
registerIdentity: () => registerIdentity,
|
|
449
|
+
registerOnly: () => registerOnly,
|
|
373
450
|
rotateIdentity: () => rotateIdentity,
|
|
374
451
|
saveIdentity: () => saveIdentity,
|
|
375
452
|
version: () => version
|
|
@@ -1538,10 +1615,7 @@ var Client2 = class _Client {
|
|
|
1538
1615
|
this.isDg = isDgUrl(this.url);
|
|
1539
1616
|
this.useIntelligentInterface = options.useIntelligentInterface ?? this.isDg;
|
|
1540
1617
|
this.maxRetries = options.maxRetries ?? 3;
|
|
1541
|
-
|
|
1542
|
-
if (identity === void 0 && this.isDg && !options.disableMtls) {
|
|
1543
|
-
identity = ConduitIdentity.tryDiscover(options.identityDir) ?? void 0;
|
|
1544
|
-
}
|
|
1618
|
+
const identity = options.identity ?? (options.identityAuto ? ConduitIdentity.tryDiscover(options.identityDir) ?? void 0 : void 0);
|
|
1545
1619
|
const transportType = options.transport || "mcp";
|
|
1546
1620
|
if (transportType === "mcp") {
|
|
1547
1621
|
this.transport = new MCPTransport(this.url, this.auth, identity);
|
|
@@ -1626,6 +1700,60 @@ var Client2 = class _Client {
|
|
|
1626
1700
|
substrateEndpoint: options.substrateEndpoint
|
|
1627
1701
|
});
|
|
1628
1702
|
}
|
|
1703
|
+
/**
|
|
1704
|
+
* Register autonomously with DG and bootstrap an mTLS identity.
|
|
1705
|
+
*
|
|
1706
|
+
* The all-in-one flow: onramp (no prior credentials required) →
|
|
1707
|
+
* OAuth token exchange → mTLS identity registration and persistence.
|
|
1708
|
+
*
|
|
1709
|
+
* On subsequent runs the saved mTLS identity is auto-discovered and
|
|
1710
|
+
* no credentials are needed.
|
|
1711
|
+
*
|
|
1712
|
+
* @param options.opts - Onramp registration options.
|
|
1713
|
+
* @param options.url - MCP server URL. Required if the onramp
|
|
1714
|
+
* response does not include `mcpUrl`.
|
|
1715
|
+
* @param options.identityDir - Custom identity storage directory.
|
|
1716
|
+
*
|
|
1717
|
+
* @example
|
|
1718
|
+
* ```ts
|
|
1719
|
+
* import { Client } from './client';
|
|
1720
|
+
* import type { OnrampOptions } from './onramp';
|
|
1721
|
+
*
|
|
1722
|
+
* const client = await Client.bootstrapOnramp({
|
|
1723
|
+
* opts: {
|
|
1724
|
+
* gateway: 'https://app.datagrout.ai',
|
|
1725
|
+
* agentName: 'my-research-agent',
|
|
1726
|
+
* agentType: 'claude-sonnet-4-6',
|
|
1727
|
+
* },
|
|
1728
|
+
* });
|
|
1729
|
+
* await client.connect();
|
|
1730
|
+
* ```
|
|
1731
|
+
*/
|
|
1732
|
+
static async bootstrapOnramp(options) {
|
|
1733
|
+
const { _doRegister: _doRegister2, _exchangeToken: _exchangeToken2 } = await Promise.resolve().then(() => (init_onramp(), onramp_exports));
|
|
1734
|
+
const dir = options.identityDir || DEFAULT_IDENTITY_DIR;
|
|
1735
|
+
const existing = ConduitIdentity.tryDiscover(dir);
|
|
1736
|
+
if (existing && !existing.needsRotation(7)) {
|
|
1737
|
+
if (!options.url) {
|
|
1738
|
+
throw new Error("'url' must be provided when an existing identity is reused");
|
|
1739
|
+
}
|
|
1740
|
+
return new _Client({ url: options.url, identity: existing, identityDir: dir });
|
|
1741
|
+
}
|
|
1742
|
+
const creds = await _doRegister2(options.opts);
|
|
1743
|
+
const token = await _exchangeToken2(creds);
|
|
1744
|
+
const url = creds.mcpUrl ?? options.url;
|
|
1745
|
+
if (!url) {
|
|
1746
|
+
throw new Error(
|
|
1747
|
+
"'url' must be provided when mcpUrl is absent from the onramp response"
|
|
1748
|
+
);
|
|
1749
|
+
}
|
|
1750
|
+
return _Client.bootstrapIdentity({
|
|
1751
|
+
url,
|
|
1752
|
+
authToken: token,
|
|
1753
|
+
name: options.opts.agentName,
|
|
1754
|
+
identityDir: options.identityDir
|
|
1755
|
+
});
|
|
1756
|
+
}
|
|
1629
1757
|
// ===== Lifecycle =====
|
|
1630
1758
|
/**
|
|
1631
1759
|
* Establish the underlying transport connection.
|
|
@@ -2118,7 +2246,8 @@ function buildToolMeta(raw) {
|
|
|
2118
2246
|
}
|
|
2119
2247
|
|
|
2120
2248
|
// src/index.ts
|
|
2121
|
-
|
|
2249
|
+
init_onramp();
|
|
2250
|
+
var version = "0.5.0";
|
|
2122
2251
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2123
2252
|
0 && (module.exports = {
|
|
2124
2253
|
AuthError,
|
|
@@ -2144,7 +2273,9 @@ var version = "0.4.0";
|
|
|
2144
2273
|
generateKeypair,
|
|
2145
2274
|
isDgUrl,
|
|
2146
2275
|
refreshCaCert,
|
|
2276
|
+
registerAndExchange,
|
|
2147
2277
|
registerIdentity,
|
|
2278
|
+
registerOnly,
|
|
2148
2279
|
rotateIdentity,
|
|
2149
2280
|
saveIdentity,
|
|
2150
2281
|
version
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
OAuthTokenProvider,
|
|
3
|
-
__esm,
|
|
4
|
-
__export,
|
|
5
|
-
__require,
|
|
6
|
-
__toCommonJS,
|
|
7
3
|
deriveTokenEndpoint,
|
|
8
4
|
init_oauth,
|
|
9
5
|
oauth_exports
|
|
10
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-26DYCD4G.mjs";
|
|
7
|
+
import {
|
|
8
|
+
registerAndExchange,
|
|
9
|
+
registerOnly
|
|
10
|
+
} from "./chunk-SWH5Y2U7.mjs";
|
|
11
|
+
import {
|
|
12
|
+
__esm,
|
|
13
|
+
__export,
|
|
14
|
+
__require,
|
|
15
|
+
__toCommonJS
|
|
16
|
+
} from "./chunk-CIESM3BP.mjs";
|
|
11
17
|
|
|
12
18
|
// src/identity.ts
|
|
13
19
|
var identity_exports = {};
|
|
@@ -1398,10 +1404,7 @@ var Client2 = class _Client {
|
|
|
1398
1404
|
this.isDg = isDgUrl(this.url);
|
|
1399
1405
|
this.useIntelligentInterface = options.useIntelligentInterface ?? this.isDg;
|
|
1400
1406
|
this.maxRetries = options.maxRetries ?? 3;
|
|
1401
|
-
|
|
1402
|
-
if (identity === void 0 && this.isDg && !options.disableMtls) {
|
|
1403
|
-
identity = ConduitIdentity.tryDiscover(options.identityDir) ?? void 0;
|
|
1404
|
-
}
|
|
1407
|
+
const identity = options.identity ?? (options.identityAuto ? ConduitIdentity.tryDiscover(options.identityDir) ?? void 0 : void 0);
|
|
1405
1408
|
const transportType = options.transport || "mcp";
|
|
1406
1409
|
if (transportType === "mcp") {
|
|
1407
1410
|
this.transport = new MCPTransport(this.url, this.auth, identity);
|
|
@@ -1470,7 +1473,7 @@ var Client2 = class _Client {
|
|
|
1470
1473
|
* @param options.substrateEndpoint - Override the DG Substrate endpoint.
|
|
1471
1474
|
*/
|
|
1472
1475
|
static async bootstrapIdentityOAuth(options) {
|
|
1473
|
-
const { OAuthTokenProvider: OAuthTokenProvider2, deriveTokenEndpoint: deriveTokenEndpoint2 } = await import("./oauth-
|
|
1476
|
+
const { OAuthTokenProvider: OAuthTokenProvider2, deriveTokenEndpoint: deriveTokenEndpoint2 } = await import("./oauth-NSDC2G7W.mjs");
|
|
1474
1477
|
const tokenEndpoint = deriveTokenEndpoint2(options.url);
|
|
1475
1478
|
const provider = new OAuthTokenProvider2({
|
|
1476
1479
|
clientId: options.clientId,
|
|
@@ -1486,6 +1489,60 @@ var Client2 = class _Client {
|
|
|
1486
1489
|
substrateEndpoint: options.substrateEndpoint
|
|
1487
1490
|
});
|
|
1488
1491
|
}
|
|
1492
|
+
/**
|
|
1493
|
+
* Register autonomously with DG and bootstrap an mTLS identity.
|
|
1494
|
+
*
|
|
1495
|
+
* The all-in-one flow: onramp (no prior credentials required) →
|
|
1496
|
+
* OAuth token exchange → mTLS identity registration and persistence.
|
|
1497
|
+
*
|
|
1498
|
+
* On subsequent runs the saved mTLS identity is auto-discovered and
|
|
1499
|
+
* no credentials are needed.
|
|
1500
|
+
*
|
|
1501
|
+
* @param options.opts - Onramp registration options.
|
|
1502
|
+
* @param options.url - MCP server URL. Required if the onramp
|
|
1503
|
+
* response does not include `mcpUrl`.
|
|
1504
|
+
* @param options.identityDir - Custom identity storage directory.
|
|
1505
|
+
*
|
|
1506
|
+
* @example
|
|
1507
|
+
* ```ts
|
|
1508
|
+
* import { Client } from './client';
|
|
1509
|
+
* import type { OnrampOptions } from './onramp';
|
|
1510
|
+
*
|
|
1511
|
+
* const client = await Client.bootstrapOnramp({
|
|
1512
|
+
* opts: {
|
|
1513
|
+
* gateway: 'https://app.datagrout.ai',
|
|
1514
|
+
* agentName: 'my-research-agent',
|
|
1515
|
+
* agentType: 'claude-sonnet-4-6',
|
|
1516
|
+
* },
|
|
1517
|
+
* });
|
|
1518
|
+
* await client.connect();
|
|
1519
|
+
* ```
|
|
1520
|
+
*/
|
|
1521
|
+
static async bootstrapOnramp(options) {
|
|
1522
|
+
const { _doRegister, _exchangeToken } = await import("./onramp-743RJTNI.mjs");
|
|
1523
|
+
const dir = options.identityDir || DEFAULT_IDENTITY_DIR;
|
|
1524
|
+
const existing = ConduitIdentity.tryDiscover(dir);
|
|
1525
|
+
if (existing && !existing.needsRotation(7)) {
|
|
1526
|
+
if (!options.url) {
|
|
1527
|
+
throw new Error("'url' must be provided when an existing identity is reused");
|
|
1528
|
+
}
|
|
1529
|
+
return new _Client({ url: options.url, identity: existing, identityDir: dir });
|
|
1530
|
+
}
|
|
1531
|
+
const creds = await _doRegister(options.opts);
|
|
1532
|
+
const token = await _exchangeToken(creds);
|
|
1533
|
+
const url = creds.mcpUrl ?? options.url;
|
|
1534
|
+
if (!url) {
|
|
1535
|
+
throw new Error(
|
|
1536
|
+
"'url' must be provided when mcpUrl is absent from the onramp response"
|
|
1537
|
+
);
|
|
1538
|
+
}
|
|
1539
|
+
return _Client.bootstrapIdentity({
|
|
1540
|
+
url,
|
|
1541
|
+
authToken: token,
|
|
1542
|
+
name: options.opts.agentName,
|
|
1543
|
+
identityDir: options.identityDir
|
|
1544
|
+
});
|
|
1545
|
+
}
|
|
1489
1546
|
// ===== Lifecycle =====
|
|
1490
1547
|
/**
|
|
1491
1548
|
* Establish the underlying transport connection.
|
|
@@ -1978,7 +2035,7 @@ function buildToolMeta(raw) {
|
|
|
1978
2035
|
}
|
|
1979
2036
|
|
|
1980
2037
|
// src/index.ts
|
|
1981
|
-
var version = "0.
|
|
2038
|
+
var version = "0.5.0";
|
|
1982
2039
|
export {
|
|
1983
2040
|
AuthError,
|
|
1984
2041
|
Client2 as Client,
|
|
@@ -2003,7 +2060,9 @@ export {
|
|
|
2003
2060
|
generateKeypair,
|
|
2004
2061
|
isDgUrl,
|
|
2005
2062
|
refreshCaCert,
|
|
2063
|
+
registerAndExchange,
|
|
2006
2064
|
registerIdentity,
|
|
2065
|
+
registerOnly,
|
|
2007
2066
|
rotateIdentity,
|
|
2008
2067
|
saveIdentity,
|
|
2009
2068
|
version
|