@nkmc/gateway 0.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.
- package/dist/chunk-56RA53VS.js +37 -0
- package/dist/chunk-CZJ75YTV.js +969 -0
- package/dist/chunk-QGM4M3NI.js +37 -0
- package/dist/http.cjs +1772 -0
- package/dist/http.d.cts +49 -0
- package/dist/http.d.ts +49 -0
- package/dist/http.js +748 -0
- package/dist/index.cjs +2436 -0
- package/dist/index.d.cts +436 -0
- package/dist/index.d.ts +436 -0
- package/dist/index.js +1434 -0
- package/dist/proxy-ClPcDgsO.d.cts +283 -0
- package/dist/proxy-qpda1ANS.d.ts +283 -0
- package/dist/proxy.cjs +148 -0
- package/dist/proxy.d.cts +6 -0
- package/dist/proxy.d.ts +6 -0
- package/dist/proxy.js +90 -0
- package/dist/testing.cjs +865 -0
- package/dist/testing.d.cts +12 -0
- package/dist/testing.d.ts +12 -0
- package/dist/testing.js +831 -0
- package/dist/tunnels-BviBEaih.d.cts +12 -0
- package/dist/tunnels-DFHNgmN7.d.ts +12 -0
- package/dist/types-C6JC9oTm.d.cts +21 -0
- package/dist/types-C6JC9oTm.d.ts +21 -0
- package/package.json +47 -0
- package/src/__tests__/sqlite-integration.test.ts +384 -0
- package/src/credential/d1-vault.ts +134 -0
- package/src/credential/memory-vault.ts +50 -0
- package/src/credential/types.ts +16 -0
- package/src/d1/__tests__/sqlite-adapter.test.ts +75 -0
- package/src/d1/sqlite-adapter.ts +59 -0
- package/src/d1/types.ts +22 -0
- package/src/federation/__tests__/d1-peer-store.test.ts +218 -0
- package/src/federation/__tests__/peer-client.test.ts +205 -0
- package/src/federation/__tests__/peer-store.test.ts +114 -0
- package/src/federation/d1-peer-store.ts +164 -0
- package/src/federation/peer-backend.ts +60 -0
- package/src/federation/peer-client.ts +122 -0
- package/src/federation/peer-store.ts +45 -0
- package/src/federation/types.ts +39 -0
- package/src/http/app.ts +152 -0
- package/src/http/lib/dns.ts +30 -0
- package/src/http/middleware/admin-auth.ts +18 -0
- package/src/http/middleware/agent-auth.ts +27 -0
- package/src/http/middleware/publish-auth.ts +39 -0
- package/src/http/routes/__tests__/federation.test.ts +364 -0
- package/src/http/routes/__tests__/peers.test.ts +290 -0
- package/src/http/routes/__tests__/proxy.test.ts +159 -0
- package/src/http/routes/auth.ts +39 -0
- package/src/http/routes/byok.ts +62 -0
- package/src/http/routes/credentials.ts +40 -0
- package/src/http/routes/domains.ts +174 -0
- package/src/http/routes/federation.ts +170 -0
- package/src/http/routes/fs.ts +89 -0
- package/src/http/routes/peers.ts +103 -0
- package/src/http/routes/proxy.ts +57 -0
- package/src/http/routes/registry.ts +222 -0
- package/src/http/routes/tunnels.ts +124 -0
- package/src/http.ts +9 -0
- package/src/index.ts +63 -0
- package/src/metering/d1-store.ts +123 -0
- package/src/metering/memory-store.ts +29 -0
- package/src/metering/pricing-guard.ts +68 -0
- package/src/metering/types.ts +25 -0
- package/src/onboard/apis-guru.ts +64 -0
- package/src/onboard/index.ts +4 -0
- package/src/onboard/manifest.ts +362 -0
- package/src/onboard/pipeline.ts +214 -0
- package/src/onboard/types.ts +72 -0
- package/src/proxy/__tests__/tool-registry.test.ts +93 -0
- package/src/proxy/tool-registry.ts +122 -0
- package/src/proxy.ts +12 -0
- package/src/registry/context7-backend.ts +93 -0
- package/src/registry/context7.ts +54 -0
- package/src/registry/d1-store.ts +242 -0
- package/src/registry/memory-store.ts +101 -0
- package/src/registry/openapi-compiler.ts +284 -0
- package/src/registry/resolver.ts +196 -0
- package/src/registry/rpc-compiler.ts +142 -0
- package/src/registry/skill-parser.ts +119 -0
- package/src/registry/skill-to-config.ts +239 -0
- package/src/registry/source-refresher.ts +83 -0
- package/src/registry/types.ts +129 -0
- package/src/registry/virtual-files.ts +76 -0
- package/src/testing/sqlite-d1.ts +64 -0
- package/src/testing.ts +2 -0
- package/src/tunnel/__tests__/cloudflare-provider.test.ts +255 -0
- package/src/tunnel/__tests__/tunnel.test.ts +542 -0
- package/src/tunnel/cloudflare-provider.ts +121 -0
- package/src/tunnel/memory-store.ts +30 -0
- package/src/tunnel/types.ts +28 -0
- package/test/credential/d1-vault.test.ts +127 -0
- package/test/credential/injection.test.ts +67 -0
- package/test/credential/memory-vault.test.ts +63 -0
- package/test/http/app.test.ts +300 -0
- package/test/http/byok-e2e.test.ts +240 -0
- package/test/http/byok.test.ts +115 -0
- package/test/http/credentials.test.ts +57 -0
- package/test/http/e2e.test.ts +260 -0
- package/test/integration/authenticated-apis.test.ts +185 -0
- package/test/integration/free-apis-e2e.test.ts +222 -0
- package/test/metering/d1-store.test.ts +82 -0
- package/test/metering/memory-store.test.ts +76 -0
- package/test/metering/pricing-guard.test.ts +108 -0
- package/test/onboard/apis-guru.test.ts +57 -0
- package/test/onboard/e2e.test.ts +70 -0
- package/test/onboard/pipeline.test.ts +318 -0
- package/test/onboard/real-apis.test.ts +483 -0
- package/test/registry/compilation-correctness.test.ts +132 -0
- package/test/registry/context7-backend.test.ts +88 -0
- package/test/registry/context7-e2e.test.ts +92 -0
- package/test/registry/context7.test.ts +73 -0
- package/test/registry/d1-store.test.ts +184 -0
- package/test/registry/integration.test.ts +129 -0
- package/test/registry/lazy-mount.test.ts +138 -0
- package/test/registry/memory-store.test.ts +171 -0
- package/test/registry/openapi-compiler.test.ts +267 -0
- package/test/registry/openapi-e2e.test.ts +154 -0
- package/test/registry/passthrough-e2e.test.ts +109 -0
- package/test/registry/resolver-peer.test.ts +299 -0
- package/test/registry/resolver.test.ts +228 -0
- package/test/registry/rpc-compiler.test.ts +112 -0
- package/test/registry/skill-parser.test.ts +151 -0
- package/test/registry/skill-to-config.test.ts +151 -0
- package/test/registry/skill-to-rpc-config.test.ts +142 -0
- package/test/registry/source-refresher.test.ts +90 -0
- package/test/registry/virtual-files.test.ts +96 -0
- package/tsconfig.json +4 -0
- package/tsup.config.ts +8 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
import { R as RegistryStore, S as ServiceRecord, V as VersionSummary, b as ServiceSummary, d as SearchResult, e as RegistryStats, f as EndpointPricing, P as PeerGateway, g as EndpointRecord, C as CredentialVault, h as StoredCredential, E as Env, i as PeerStore, L as LendingRule, T as TunnelStore, j as TunnelRecord, a as TunnelProvider } from './proxy-qpda1ANS.js';
|
|
2
|
+
export { k as EndpointAnnotations, l as EndpointSummary, m as ServiceStatus, n as SourceConfig } from './proxy-qpda1ANS.js';
|
|
3
|
+
import { D as D1Database } from './types-C6JC9oTm.js';
|
|
4
|
+
export { a as D1PreparedStatement, b as D1Result, c as D1RunResult } from './types-C6JC9oTm.js';
|
|
5
|
+
import { HttpBackendConfig, Mount, AgentContext, HttpAuth, FsBackend } from '@nkmc/agent-fs';
|
|
6
|
+
import { JWK } from 'jose';
|
|
7
|
+
import * as hono_types from 'hono/types';
|
|
8
|
+
import { Hono } from 'hono';
|
|
9
|
+
import Database from 'better-sqlite3';
|
|
10
|
+
export { T as TunnelRouteOptions, t as tunnelRoutes } from './tunnels-DFHNgmN7.js';
|
|
11
|
+
|
|
12
|
+
declare class MemoryRegistryStore implements RegistryStore {
|
|
13
|
+
private records;
|
|
14
|
+
private key;
|
|
15
|
+
get(domain: string): Promise<ServiceRecord | null>;
|
|
16
|
+
getVersion(domain: string, version: string): Promise<ServiceRecord | null>;
|
|
17
|
+
listVersions(domain: string): Promise<VersionSummary[]>;
|
|
18
|
+
put(domain: string, record: ServiceRecord): Promise<void>;
|
|
19
|
+
delete(domain: string): Promise<void>;
|
|
20
|
+
list(): Promise<ServiceSummary[]>;
|
|
21
|
+
search(query: string): Promise<SearchResult[]>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare class D1RegistryStore implements RegistryStore {
|
|
25
|
+
private db;
|
|
26
|
+
constructor(db: D1Database);
|
|
27
|
+
initSchema(): Promise<void>;
|
|
28
|
+
get(domain: string): Promise<ServiceRecord | null>;
|
|
29
|
+
getVersion(domain: string, version: string): Promise<ServiceRecord | null>;
|
|
30
|
+
listVersions(domain: string): Promise<VersionSummary[]>;
|
|
31
|
+
/** Max endpoints JSON size before stripping verbose fields (parameters, requestBody, responses). */
|
|
32
|
+
static readonly ENDPOINTS_SIZE_LIMIT = 800000;
|
|
33
|
+
put(domain: string, record: ServiceRecord): Promise<void>;
|
|
34
|
+
delete(domain: string): Promise<void>;
|
|
35
|
+
list(): Promise<ServiceSummary[]>;
|
|
36
|
+
search(query: string): Promise<SearchResult[]>;
|
|
37
|
+
stats(): Promise<RegistryStats>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface ParseOptions {
|
|
41
|
+
isFirstParty?: boolean;
|
|
42
|
+
}
|
|
43
|
+
declare function parseSkillMd(domain: string, raw: string, options?: ParseOptions): ServiceRecord;
|
|
44
|
+
declare function parsePricingAnnotation(text: string): EndpointPricing | undefined;
|
|
45
|
+
|
|
46
|
+
declare function skillToHttpConfig(record: ServiceRecord): HttpBackendConfig;
|
|
47
|
+
|
|
48
|
+
interface PeerQueryResult {
|
|
49
|
+
available: boolean;
|
|
50
|
+
pricing?: {
|
|
51
|
+
mode: string;
|
|
52
|
+
amount?: number;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
interface PeerExecResult {
|
|
56
|
+
ok: boolean;
|
|
57
|
+
data?: unknown;
|
|
58
|
+
error?: string;
|
|
59
|
+
paymentRequired?: {
|
|
60
|
+
price: number;
|
|
61
|
+
currency: string;
|
|
62
|
+
payTo: string;
|
|
63
|
+
network: string;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Client for communicating with peer gateways in the federation.
|
|
68
|
+
* Each method sends authenticated HTTP requests to the peer's URL.
|
|
69
|
+
*/
|
|
70
|
+
declare class PeerClient {
|
|
71
|
+
private selfId;
|
|
72
|
+
constructor(selfId: string);
|
|
73
|
+
/**
|
|
74
|
+
* Query a peer to check if it has credentials for a domain
|
|
75
|
+
* and its lending rules allow access.
|
|
76
|
+
*/
|
|
77
|
+
query(peer: PeerGateway, domain: string): Promise<PeerQueryResult>;
|
|
78
|
+
/**
|
|
79
|
+
* Execute a command on a peer gateway on behalf of an agent.
|
|
80
|
+
* Handles 402 Payment Required responses with X-402-* headers.
|
|
81
|
+
*/
|
|
82
|
+
exec(peer: PeerGateway, request: {
|
|
83
|
+
command: string;
|
|
84
|
+
agentId: string;
|
|
85
|
+
}): Promise<PeerExecResult>;
|
|
86
|
+
/**
|
|
87
|
+
* Announce our available domains to a peer gateway.
|
|
88
|
+
*/
|
|
89
|
+
announce(peer: PeerGateway, domains: string[]): Promise<void>;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
interface RegistryResolverHooks {
|
|
93
|
+
onMiss: (path: string, addMount: (mount: Mount) => void, agent?: AgentContext) => Promise<boolean>;
|
|
94
|
+
listDomains: () => Promise<string[]>;
|
|
95
|
+
searchDomains: (query: string) => Promise<SearchResult[]>;
|
|
96
|
+
searchEndpoints: (domain: string, query: string) => Promise<Pick<EndpointRecord, "method" | "path" | "description">[]>;
|
|
97
|
+
}
|
|
98
|
+
interface RegistryResolverOptions {
|
|
99
|
+
store: RegistryStore;
|
|
100
|
+
vault?: {
|
|
101
|
+
get(domain: string, developerId?: string): Promise<{
|
|
102
|
+
auth: HttpAuth;
|
|
103
|
+
} | null>;
|
|
104
|
+
};
|
|
105
|
+
gatewayPrivateKey?: JWK;
|
|
106
|
+
wrapVirtualFiles?: boolean;
|
|
107
|
+
peerStore?: {
|
|
108
|
+
listPeers(): Promise<PeerGateway[]>;
|
|
109
|
+
};
|
|
110
|
+
peerClient?: PeerClient;
|
|
111
|
+
}
|
|
112
|
+
declare function createRegistryResolver(storeOrOptions: RegistryStore | RegistryResolverOptions): RegistryResolverHooks;
|
|
113
|
+
declare function extractDomainPath(path: string): {
|
|
114
|
+
domain: string | null;
|
|
115
|
+
version: string | null;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
interface MeterRecord {
|
|
119
|
+
id: string;
|
|
120
|
+
timestamp: number;
|
|
121
|
+
domain: string;
|
|
122
|
+
version: string;
|
|
123
|
+
endpoint: string;
|
|
124
|
+
agentId: string;
|
|
125
|
+
developerId?: string;
|
|
126
|
+
cost: number;
|
|
127
|
+
currency: string;
|
|
128
|
+
}
|
|
129
|
+
interface MeterQuery {
|
|
130
|
+
domain?: string;
|
|
131
|
+
agentId?: string;
|
|
132
|
+
developerId?: string;
|
|
133
|
+
from?: number;
|
|
134
|
+
to?: number;
|
|
135
|
+
}
|
|
136
|
+
interface MeterStore {
|
|
137
|
+
record(entry: MeterRecord): Promise<void>;
|
|
138
|
+
query(filter: MeterQuery): Promise<MeterRecord[]>;
|
|
139
|
+
sum(filter: MeterQuery): Promise<{
|
|
140
|
+
total: number;
|
|
141
|
+
currency: string;
|
|
142
|
+
}>;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
declare class MemoryMeterStore implements MeterStore {
|
|
146
|
+
private records;
|
|
147
|
+
record(entry: MeterRecord): Promise<void>;
|
|
148
|
+
query(filter: MeterQuery): Promise<MeterRecord[]>;
|
|
149
|
+
sum(filter: MeterQuery): Promise<{
|
|
150
|
+
total: number;
|
|
151
|
+
currency: string;
|
|
152
|
+
}>;
|
|
153
|
+
private matches;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
declare class D1MeterStore implements MeterStore {
|
|
157
|
+
private db;
|
|
158
|
+
constructor(db: D1Database);
|
|
159
|
+
initSchema(): Promise<void>;
|
|
160
|
+
record(entry: MeterRecord): Promise<void>;
|
|
161
|
+
query(filter: MeterQuery): Promise<MeterRecord[]>;
|
|
162
|
+
sum(filter: MeterQuery): Promise<{
|
|
163
|
+
total: number;
|
|
164
|
+
currency: string;
|
|
165
|
+
}>;
|
|
166
|
+
private buildQuery;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
declare function lookupPricing(record: ServiceRecord, method: string, path: string): EndpointPricing | null;
|
|
170
|
+
declare function checkAccess(record: ServiceRecord): {
|
|
171
|
+
allowed: boolean;
|
|
172
|
+
reason?: string;
|
|
173
|
+
};
|
|
174
|
+
declare function meter(store: MeterStore, opts: {
|
|
175
|
+
domain: string;
|
|
176
|
+
version: string;
|
|
177
|
+
endpoint: string;
|
|
178
|
+
agentId: string;
|
|
179
|
+
developerId?: string;
|
|
180
|
+
pricing: EndpointPricing;
|
|
181
|
+
}): Promise<MeterRecord>;
|
|
182
|
+
|
|
183
|
+
interface VirtualFileOptions {
|
|
184
|
+
inner: FsBackend;
|
|
185
|
+
domain: string;
|
|
186
|
+
store: RegistryStore;
|
|
187
|
+
}
|
|
188
|
+
declare class VirtualFileBackend implements FsBackend {
|
|
189
|
+
private inner;
|
|
190
|
+
private domain;
|
|
191
|
+
private store;
|
|
192
|
+
constructor(options: VirtualFileOptions);
|
|
193
|
+
list(path: string): Promise<string[]>;
|
|
194
|
+
read(path: string): Promise<unknown>;
|
|
195
|
+
write(path: string, data: unknown): Promise<{
|
|
196
|
+
id: string;
|
|
197
|
+
}>;
|
|
198
|
+
remove(path: string): Promise<void>;
|
|
199
|
+
search(path: string, pattern: string): Promise<unknown[]>;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
declare class MemoryCredentialVault implements CredentialVault {
|
|
203
|
+
private credentials;
|
|
204
|
+
private poolKey;
|
|
205
|
+
private byokKey;
|
|
206
|
+
get(domain: string, developerId?: string): Promise<StoredCredential | null>;
|
|
207
|
+
putPool(domain: string, auth: HttpAuth): Promise<void>;
|
|
208
|
+
putByok(domain: string, developerId: string, auth: HttpAuth): Promise<void>;
|
|
209
|
+
delete(domain: string, developerId?: string): Promise<void>;
|
|
210
|
+
listDomains(): Promise<string[]>;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
declare class D1CredentialVault implements CredentialVault {
|
|
214
|
+
private db;
|
|
215
|
+
private encryptionKey;
|
|
216
|
+
constructor(db: D1Database, encryptionKey: CryptoKey);
|
|
217
|
+
initSchema(): Promise<void>;
|
|
218
|
+
get(domain: string, developerId?: string): Promise<StoredCredential | null>;
|
|
219
|
+
putPool(domain: string, auth: HttpAuth): Promise<void>;
|
|
220
|
+
putByok(domain: string, developerId: string, auth: HttpAuth): Promise<void>;
|
|
221
|
+
delete(domain: string, developerId?: string): Promise<void>;
|
|
222
|
+
listDomains(): Promise<string[]>;
|
|
223
|
+
private rowToCredential;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
interface CredentialRouteOptions {
|
|
227
|
+
vault: CredentialVault;
|
|
228
|
+
}
|
|
229
|
+
declare function credentialRoutes(options: CredentialRouteOptions): Hono<Env, hono_types.BlankSchema, "/">;
|
|
230
|
+
|
|
231
|
+
declare function queryDnsTxt(domain: string): Promise<string[]>;
|
|
232
|
+
|
|
233
|
+
interface Context7Options {
|
|
234
|
+
apiKey?: string;
|
|
235
|
+
baseUrl?: string;
|
|
236
|
+
fetchFn?: typeof globalThis.fetch;
|
|
237
|
+
}
|
|
238
|
+
interface LibrarySearchResult {
|
|
239
|
+
id: string;
|
|
240
|
+
name: string;
|
|
241
|
+
description?: string;
|
|
242
|
+
totalSnippets?: number;
|
|
243
|
+
trustScore?: number;
|
|
244
|
+
}
|
|
245
|
+
declare class Context7Client {
|
|
246
|
+
private apiKey?;
|
|
247
|
+
private baseUrl;
|
|
248
|
+
private fetchFn;
|
|
249
|
+
constructor(options?: Context7Options);
|
|
250
|
+
/** Search for a library by name. Returns matching library entries. */
|
|
251
|
+
searchLibraries(libraryName: string, query?: string): Promise<LibrarySearchResult[]>;
|
|
252
|
+
/** Query documentation for a specific library. Returns documentation text. */
|
|
253
|
+
queryDocs(libraryId: string, query: string): Promise<string>;
|
|
254
|
+
private headers;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
interface Context7BackendOptions extends Context7Options {
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* FsBackend that maps filesystem operations to Context7 documentation queries.
|
|
261
|
+
*
|
|
262
|
+
* Filesystem mapping:
|
|
263
|
+
* grep "react" / → searchLibraries("react") — search for libraries
|
|
264
|
+
* cat /{owner}/{repo} → queryDocs("/{owner}/{repo}", repo) — library overview
|
|
265
|
+
* grep "hooks" /{o}/{r} → queryDocs("/{o}/{r}", "hooks") — query specific docs
|
|
266
|
+
* ls / → usage instructions
|
|
267
|
+
*/
|
|
268
|
+
declare class Context7Backend implements FsBackend {
|
|
269
|
+
private client;
|
|
270
|
+
constructor(options?: Context7BackendOptions);
|
|
271
|
+
list(path: string): Promise<string[]>;
|
|
272
|
+
read(path: string): Promise<unknown>;
|
|
273
|
+
write(_path: string, _data: unknown): Promise<{
|
|
274
|
+
id: string;
|
|
275
|
+
}>;
|
|
276
|
+
remove(_path: string): Promise<void>;
|
|
277
|
+
search(path: string, pattern: string): Promise<unknown[]>;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
interface RpcManifestDef {
|
|
281
|
+
url: string;
|
|
282
|
+
convention?: "crud" | "evm" | "raw";
|
|
283
|
+
methods: Array<{
|
|
284
|
+
rpcMethod: string;
|
|
285
|
+
description: string;
|
|
286
|
+
resource?: string;
|
|
287
|
+
fsOp?: "list" | "read" | "write" | "create" | "remove" | "search";
|
|
288
|
+
}>;
|
|
289
|
+
}
|
|
290
|
+
/** A single service to onboard */
|
|
291
|
+
interface ManifestEntry {
|
|
292
|
+
domain: string;
|
|
293
|
+
/** OpenAPI spec URL — triggers compilation */
|
|
294
|
+
specUrl?: string;
|
|
295
|
+
/** skill.md URL — fetched and registered directly */
|
|
296
|
+
skillMdUrl?: string;
|
|
297
|
+
/** Inline skill.md content */
|
|
298
|
+
skillMd?: string;
|
|
299
|
+
/** JSON-RPC definition — triggers RPC compilation */
|
|
300
|
+
rpcDef?: RpcManifestDef;
|
|
301
|
+
/** Pool credential — values can be "${ENV_VAR}" references */
|
|
302
|
+
auth?: ManifestAuth;
|
|
303
|
+
/** Tags for categorization */
|
|
304
|
+
tags?: string[];
|
|
305
|
+
/** Skip this entry (default false) */
|
|
306
|
+
disabled?: boolean;
|
|
307
|
+
}
|
|
308
|
+
interface ManifestAuth {
|
|
309
|
+
type: "bearer" | "api-key" | "basic" | "oauth2";
|
|
310
|
+
token?: string;
|
|
311
|
+
prefix?: string;
|
|
312
|
+
header?: string;
|
|
313
|
+
key?: string;
|
|
314
|
+
username?: string;
|
|
315
|
+
password?: string;
|
|
316
|
+
tokenUrl?: string;
|
|
317
|
+
clientId?: string;
|
|
318
|
+
clientSecret?: string;
|
|
319
|
+
scope?: string;
|
|
320
|
+
}
|
|
321
|
+
/** Result of onboarding one service */
|
|
322
|
+
interface OnboardResult {
|
|
323
|
+
domain: string;
|
|
324
|
+
status: "ok" | "failed" | "skipped";
|
|
325
|
+
error?: string;
|
|
326
|
+
source: "openapi" | "skillmd" | "wellknown" | "jsonrpc" | "none";
|
|
327
|
+
endpoints: number;
|
|
328
|
+
resources: number;
|
|
329
|
+
hasCredentials: boolean;
|
|
330
|
+
smokeTest?: {
|
|
331
|
+
ls: boolean;
|
|
332
|
+
cat: boolean;
|
|
333
|
+
catEndpoint?: string;
|
|
334
|
+
};
|
|
335
|
+
durationMs: number;
|
|
336
|
+
}
|
|
337
|
+
/** Summary of a batch onboard run */
|
|
338
|
+
interface OnboardReport {
|
|
339
|
+
total: number;
|
|
340
|
+
ok: number;
|
|
341
|
+
failed: number;
|
|
342
|
+
skipped: number;
|
|
343
|
+
results: OnboardResult[];
|
|
344
|
+
durationMs: number;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
interface PipelineOptions {
|
|
348
|
+
store: RegistryStore;
|
|
349
|
+
vault?: CredentialVault;
|
|
350
|
+
/** Run smoke tests after registration (default true) */
|
|
351
|
+
smokeTest?: boolean;
|
|
352
|
+
/** Concurrency limit for parallel onboarding (default 5) */
|
|
353
|
+
concurrency?: number;
|
|
354
|
+
/** Custom fetch function */
|
|
355
|
+
fetchFn?: typeof globalThis.fetch;
|
|
356
|
+
/** Progress callback */
|
|
357
|
+
onProgress?: (result: OnboardResult, index: number, total: number) => void;
|
|
358
|
+
}
|
|
359
|
+
declare class OnboardPipeline {
|
|
360
|
+
private store;
|
|
361
|
+
private vault?;
|
|
362
|
+
private smokeTest;
|
|
363
|
+
private concurrency;
|
|
364
|
+
private fetchFn;
|
|
365
|
+
private onProgress?;
|
|
366
|
+
constructor(options: PipelineOptions);
|
|
367
|
+
/** Onboard a single service */
|
|
368
|
+
onboardOne(entry: ManifestEntry): Promise<OnboardResult>;
|
|
369
|
+
/** Onboard many services with controlled concurrency */
|
|
370
|
+
onboardMany(entries: ManifestEntry[]): Promise<OnboardReport>;
|
|
371
|
+
private runSmokeTest;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
interface ApisGuruOptions {
|
|
375
|
+
/** Max number of APIs to return */
|
|
376
|
+
limit?: number;
|
|
377
|
+
/** Filter by keyword in API title/description */
|
|
378
|
+
filter?: string;
|
|
379
|
+
/** Custom fetch function */
|
|
380
|
+
fetchFn?: typeof globalThis.fetch;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Discover APIs from the apis.guru public directory.
|
|
384
|
+
* Returns ManifestEntry[] ready for the onboard pipeline.
|
|
385
|
+
*/
|
|
386
|
+
declare function discoverFromApisGuru(options?: ApisGuruOptions): Promise<ManifestEntry[]>;
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Wraps a better-sqlite3 Database instance to implement the D1Database interface.
|
|
390
|
+
* This allows all existing D1-based stores (RegistryStore, CredentialVault, MeterStore)
|
|
391
|
+
* to work with a local SQLite database for standalone deployments.
|
|
392
|
+
*/
|
|
393
|
+
declare function createSqliteD1(db: Database.Database): D1Database;
|
|
394
|
+
|
|
395
|
+
declare class D1PeerStore implements PeerStore {
|
|
396
|
+
private db;
|
|
397
|
+
constructor(db: D1Database);
|
|
398
|
+
initSchema(): Promise<void>;
|
|
399
|
+
getPeer(id: string): Promise<PeerGateway | null>;
|
|
400
|
+
putPeer(peer: PeerGateway): Promise<void>;
|
|
401
|
+
deletePeer(id: string): Promise<void>;
|
|
402
|
+
listPeers(): Promise<PeerGateway[]>;
|
|
403
|
+
updateLastSeen(id: string, timestamp: number): Promise<void>;
|
|
404
|
+
getRule(domain: string): Promise<LendingRule | null>;
|
|
405
|
+
putRule(rule: LendingRule): Promise<void>;
|
|
406
|
+
deleteRule(domain: string): Promise<void>;
|
|
407
|
+
listRules(): Promise<LendingRule[]>;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
declare class MemoryTunnelStore implements TunnelStore {
|
|
411
|
+
private records;
|
|
412
|
+
get(id: string): Promise<TunnelRecord | null>;
|
|
413
|
+
getByAgent(agentId: string): Promise<TunnelRecord | null>;
|
|
414
|
+
put(record: TunnelRecord): Promise<void>;
|
|
415
|
+
delete(id: string): Promise<void>;
|
|
416
|
+
list(): Promise<TunnelRecord[]>;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
declare class CloudflareTunnelProvider implements TunnelProvider {
|
|
420
|
+
private accountId;
|
|
421
|
+
private apiToken;
|
|
422
|
+
private tunnelDomain;
|
|
423
|
+
private zoneId;
|
|
424
|
+
constructor(accountId: string, apiToken: string, tunnelDomain: string, // e.g. "tunnel.example.com"
|
|
425
|
+
zoneId: string);
|
|
426
|
+
create(name: string, hostname: string): Promise<{
|
|
427
|
+
tunnelId: string;
|
|
428
|
+
tunnelToken: string;
|
|
429
|
+
}>;
|
|
430
|
+
delete(tunnelId: string): Promise<void>;
|
|
431
|
+
private cfFetch;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
declare const VERSION = "0.1.0";
|
|
435
|
+
|
|
436
|
+
export { type ApisGuruOptions, CloudflareTunnelProvider, Context7Backend, type Context7BackendOptions, Context7Client, type Context7Options, CredentialVault, D1CredentialVault, D1Database, D1MeterStore, D1PeerStore, D1RegistryStore, EndpointPricing, EndpointRecord, LendingRule, type LibrarySearchResult, type ManifestAuth, type ManifestEntry, MemoryCredentialVault, MemoryMeterStore, MemoryRegistryStore, MemoryTunnelStore, type MeterQuery, type MeterRecord, type MeterStore, OnboardPipeline, type OnboardReport, type OnboardResult, type ParseOptions, PeerGateway, PeerStore, type PipelineOptions, type RegistryResolverHooks, type RegistryResolverOptions, RegistryStore, SearchResult, ServiceRecord, ServiceSummary, StoredCredential, TunnelProvider, TunnelRecord, TunnelStore, VERSION, VersionSummary, VirtualFileBackend, checkAccess, createRegistryResolver, createSqliteD1, credentialRoutes, discoverFromApisGuru, extractDomainPath, lookupPricing, meter, parsePricingAnnotation, parseSkillMd, queryDnsTxt, skillToHttpConfig };
|