@agentronics/sdk 0.6.0 → 0.7.1
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-4FLZQPCO.js +18 -0
- package/dist/chunk-4FLZQPCO.js.map +1 -0
- package/dist/{chunk-X7NFMFN6.js → chunk-6QQS26AP.js} +264 -69
- package/dist/chunk-6QQS26AP.js.map +1 -0
- package/dist/chunk-BPDWJCPY.js +2 -0
- package/dist/chunk-BPDWJCPY.js.map +1 -0
- package/dist/index.cjs +8 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +57 -8
- package/dist/index.d.ts +57 -8
- package/dist/index.global.js +8 -7
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{init-only-7f8_LQAI.d.ts → init-only-C80qhujz.d.ts} +227 -30
- package/dist/{init-only-Cwll8MGz.d.cts → init-only-s9E9bVC0.d.cts} +227 -30
- package/dist/init-only.cjs +8 -7
- package/dist/init-only.cjs.map +1 -1
- package/dist/init-only.d.cts +2 -2
- package/dist/init-only.d.ts +2 -2
- package/dist/init-only.global.js +8 -7
- package/dist/init-only.global.js.map +1 -1
- package/dist/init-only.js +1 -1
- package/dist/lite.cjs +1 -1
- package/dist/lite.cjs.map +1 -1
- package/dist/lite.d.cts +2 -2
- package/dist/lite.d.ts +2 -2
- package/dist/lite.global.js +1 -1
- package/dist/lite.global.js.map +1 -1
- package/dist/lite.js +1 -1
- package/dist/middleware-Dd2T772u.d.cts +429 -0
- package/dist/middleware-Dd2T772u.d.ts +429 -0
- package/dist/next.cjs +239 -64
- package/dist/next.cjs.map +1 -1
- package/dist/next.d.cts +2 -2
- package/dist/next.d.ts +2 -2
- package/dist/next.js +2 -2
- package/dist/server.cjs +361 -66
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +103 -308
- package/dist/server.d.ts +103 -308
- package/dist/server.js +93 -1
- package/dist/server.js.map +1 -1
- package/dist/webmcp-BgKzHeQ3.d.cts +97 -0
- package/dist/webmcp-BgKzHeQ3.d.ts +97 -0
- package/package.json +4 -4
- package/dist/chunk-LLD3Y2LZ.js +0 -2
- package/dist/chunk-LLD3Y2LZ.js.map +0 -1
- package/dist/chunk-X7NFMFN6.js.map +0 -1
- package/dist/chunk-Y7JYD5RA.js +0 -17
- package/dist/chunk-Y7JYD5RA.js.map +0 -1
- package/dist/webmcp-C4ikhM4g.d.cts +0 -12
- package/dist/webmcp-C4ikhM4g.d.ts +0 -12
package/dist/server.d.cts
CHANGED
|
@@ -1,336 +1,131 @@
|
|
|
1
|
-
|
|
1
|
+
export { A as AGENT_HEADERS, a as AgentAuthHandlerOptions, b as AgentAuthMethod, c as AgentAuthOptions, d as AgentAuthResult, e as ApiKeyIdentity, f as ApiKeyOptions, C as ClientIpSource, g as CrawlerOptions, D as DIRECTORY_PATH, H as HandlerOutcome, I as IpRangeOptions, O as OAuth2Options, h as OAuthAgent, P as PROTECTED_RESOURCE_PATH, i as PUBLISHED_IP_RANGES, j as ProtectedResourceOptions, k as PublicJwk, R as RDNS_DOMAINS, l as ReplayCache, S as SignatureAlgorithm, V as VerifiedAgent, W as WEB_BOT_AUTH_TAG, m as WebBotAuthOptions, n as WebBotAuthResult, o as classifyUserAgent, p as clientIp, q as createAgentAuth, r as createAgentAuthHandler, s as expressAgentAuth, t as generateAgentKey, u as hashAgentKey, v as ipInCidr, w as ipInRanges, x as jwkThumbprint, y as memoryReplayCache, z as oauthChallenge, B as protectedResourceMetadata, E as rangesFor, F as readAgentHeaders, G as signatureBase, J as staticKeyVerifier, K as toTraceEvent, L as verifyCrawler, M as verifyOAuthToken, N as verifyWebBotAuth, Q as withAgentHeaders } from './middleware-Dd2T772u.cjs';
|
|
2
|
+
import { PolicyRule, AgentIdentity } from '@agentronics/protocol';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Server-side crawler identification + verification.
|
|
14
|
-
*
|
|
15
|
-
* A User-Agent claim is trivially spoofable, so on its own it only makes a
|
|
16
|
-
* request "claimed". A claim becomes verified by forward-confirmed reverse DNS
|
|
17
|
-
* (the IP's PTR name sits under the vendor's documented domain AND resolves
|
|
18
|
-
* back to the same IP) — the method Google, Microsoft, Apple, Yandex, Baidu and
|
|
19
|
-
* Amazon document for their crawlers. Needs Node DNS; on edge runtimes the
|
|
20
|
-
* claim stays unverified (use Web Bot Auth, which works everywhere).
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/** Vendors that document reverse-DNS verification, keyed by signature name. */
|
|
24
|
-
declare const RDNS_DOMAINS: Record<string, string[]>;
|
|
25
|
-
interface CrawlerClaim {
|
|
26
|
-
name: string;
|
|
27
|
-
category: CrawlerSignature['category'];
|
|
28
|
-
}
|
|
29
|
-
declare function classifyUserAgent(ua: string | null, signatures?: CrawlerSignature[]): CrawlerClaim | null;
|
|
30
|
-
/**
|
|
31
|
-
* Where the real client IP comes from. Platform headers are set by the edge
|
|
32
|
-
* and can't be spoofed by the caller; the leftmost X-Forwarded-For entry CAN,
|
|
33
|
-
* so it's never used by default.
|
|
34
|
-
*/
|
|
35
|
-
type ClientIpSource = 'auto' | 'cloudflare' | 'vercel' | ((request: Request) => string | null);
|
|
36
|
-
declare function clientIp(request: Request, source?: ClientIpSource): string | null;
|
|
37
|
-
interface DnsResolver {
|
|
38
|
-
reverse(ip: string): Promise<string[]>;
|
|
39
|
-
lookup(host: string): Promise<string[]>;
|
|
40
|
-
}
|
|
41
|
-
type CrawlerVerification = {
|
|
42
|
-
status: 'verified';
|
|
43
|
-
name: string;
|
|
44
|
-
host: string;
|
|
45
|
-
ip: string;
|
|
46
|
-
} | {
|
|
47
|
-
status: 'unverified';
|
|
48
|
-
name: string;
|
|
49
|
-
reason: string;
|
|
50
|
-
};
|
|
51
|
-
declare function verifyCrawler(claim: CrawlerClaim, ip: string | null, resolver?: DnsResolver): Promise<CrawlerVerification>;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Structured Field Values for HTTP (RFC 9651) — the subset HTTP Message
|
|
55
|
-
* Signatures (RFC 9421) and Web Bot Auth need: Dictionaries, Inner Lists,
|
|
56
|
-
* Items, Parameters; bare items of type Integer, Decimal, String, Token,
|
|
57
|
-
* Byte Sequence and Boolean. Parsing is strict (invalid input throws), and
|
|
58
|
-
* serialization is canonical, which RFC 9421 relies on for `@signature-params`.
|
|
59
|
-
*/
|
|
60
|
-
declare class SfToken {
|
|
61
|
-
readonly value: string;
|
|
62
|
-
constructor(value: string);
|
|
63
|
-
}
|
|
64
|
-
declare class SfDecimal {
|
|
65
|
-
readonly value: number;
|
|
66
|
-
constructor(value: number);
|
|
67
|
-
}
|
|
68
|
-
type BareItem = string | number | boolean | Uint8Array | SfToken | SfDecimal;
|
|
69
|
-
type Params = Array<[string, BareItem]>;
|
|
70
|
-
interface Item {
|
|
71
|
-
value: BareItem;
|
|
72
|
-
params: Params;
|
|
73
|
-
}
|
|
74
|
-
interface InnerList {
|
|
75
|
-
items: Item[];
|
|
76
|
-
params: Params;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* HTTP Message Signatures (RFC 9421) — request verification only.
|
|
81
|
-
* Runtime-neutral: WebCrypto + Fetch `Request`, so it runs on Node ≥ 20,
|
|
82
|
-
* Vercel/Next edge middleware, Cloudflare Workers, Deno and Bun.
|
|
83
|
-
*/
|
|
84
|
-
|
|
85
|
-
interface ComponentContext {
|
|
86
|
-
request: Request;
|
|
87
|
-
url: URL;
|
|
88
|
-
/** Override for `@authority` (e.g. when a proxy rewrites Host). */
|
|
89
|
-
authority?: string;
|
|
90
|
-
}
|
|
91
|
-
/** Build the signature base (RFC 9421 §2.5) for one Signature-Input member. */
|
|
92
|
-
declare function signatureBase(input: InnerList, ctx: ComponentContext): string;
|
|
93
|
-
interface PublicJwk {
|
|
94
|
-
kty: string;
|
|
95
|
-
crv?: string;
|
|
96
|
-
x?: string;
|
|
97
|
-
y?: string;
|
|
98
|
-
n?: string;
|
|
99
|
-
e?: string;
|
|
100
|
-
kid?: string;
|
|
101
|
-
alg?: string;
|
|
102
|
-
use?: string;
|
|
103
|
-
nbf?: number;
|
|
104
|
-
exp?: number;
|
|
105
|
-
}
|
|
106
|
-
type SignatureAlgorithm = 'ed25519' | 'rsa-pss-sha512' | 'rsa-v1_5-sha256' | 'ecdsa-p256-sha256' | 'ecdsa-p384-sha384';
|
|
107
|
-
/** JWK SHA-256 thumbprint, base64url (RFC 7638; RFC 8037 §A.3 for OKP). */
|
|
108
|
-
declare function jwkThumbprint(jwk: PublicJwk): Promise<string>;
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Web Bot Auth verifier — draft-meunier-webbotauth-httpsig-protocol-02.
|
|
112
|
-
*
|
|
113
|
-
* A signed agent request carries:
|
|
114
|
-
* Signature-Agent: agent2="https://signer.example" (dictionary form)
|
|
115
|
-
* Signature-Input: sig2=("@authority" "signature-agent";key="agent2");
|
|
116
|
-
* created=…;expires=…;keyid="<JWK thumbprint>";tag="web-bot-auth"
|
|
117
|
-
* Signature: sig2=:<base64>:
|
|
118
|
-
* The verifier resolves the signer's key directory
|
|
119
|
-
* (<origin>/.well-known/http-message-signatures-directory by default), picks
|
|
120
|
-
* the key whose JWK thumbprint equals `keyid`, rebuilds the RFC 9421 signature
|
|
121
|
-
* base, and verifies it. Cheap checks run before any network call.
|
|
122
|
-
*/
|
|
123
|
-
|
|
124
|
-
declare const WEB_BOT_AUTH_TAG = "web-bot-auth";
|
|
125
|
-
declare const DIRECTORY_PATH = "/.well-known/http-message-signatures-directory";
|
|
126
|
-
interface ReplayCache {
|
|
127
|
-
has(key: string): boolean | Promise<boolean>;
|
|
128
|
-
add(key: string, ttlSeconds: number): void | Promise<void>;
|
|
129
|
-
}
|
|
130
|
-
/** Bounded in-memory replay cache. Use a shared store (Redis…) across instances. */
|
|
131
|
-
declare function memoryReplayCache(maxEntries?: number): ReplayCache;
|
|
132
|
-
interface WebBotAuthOptions {
|
|
4
|
+
interface TraceRelayOptions {
|
|
5
|
+
url: string;
|
|
6
|
+
ingestKey: string;
|
|
7
|
+
/** Events are re-labelled with this site id, whatever the browser sent. */
|
|
8
|
+
siteId: string;
|
|
9
|
+
/** Max events accepted per request. Default 100. */
|
|
10
|
+
maxEvents?: number;
|
|
133
11
|
/**
|
|
134
|
-
*
|
|
135
|
-
*
|
|
12
|
+
* Also hand every accepted batch to your own sink — a warehouse, a queue,
|
|
13
|
+
* a webhook. Runs alongside the console export; failures are ignored.
|
|
136
14
|
*/
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
clockSkewSec?: number;
|
|
140
|
-
/** Max `expires - created`, seconds. Default 86400 (spec: ≤ 24 h recommended). */
|
|
141
|
-
maxValiditySec?: number;
|
|
142
|
-
/** Reject signatures without a `nonce`. Default false. */
|
|
143
|
-
requireNonce?: boolean;
|
|
144
|
-
replayCache?: ReplayCache;
|
|
145
|
-
/** Override `@authority` when a proxy rewrites Host. */
|
|
146
|
-
authority?: (request: Request, url: URL) => string;
|
|
147
|
-
/** Node only: DNS-check directory hosts for private addresses. Default true. */
|
|
148
|
-
resolveDns?: boolean;
|
|
149
|
-
/** Test seams. */
|
|
150
|
-
fetch?: typeof fetch;
|
|
151
|
-
now?: () => number;
|
|
15
|
+
forward?: (events: Array<Record<string, unknown>>) => unknown;
|
|
16
|
+
fetcher?: typeof fetch;
|
|
152
17
|
}
|
|
153
|
-
|
|
154
|
-
status: 'absent';
|
|
155
|
-
} | {
|
|
156
|
-
status: 'verified';
|
|
157
|
-
/** Stable identity: the signer URL (directory origin or JWKS URL). */
|
|
158
|
-
agentUrl: string;
|
|
159
|
-
keyid: string;
|
|
160
|
-
label: string;
|
|
161
|
-
alg: SignatureAlgorithm;
|
|
162
|
-
created: number;
|
|
163
|
-
expires: number;
|
|
164
|
-
} | {
|
|
165
|
-
status: 'invalid';
|
|
166
|
-
reason: string;
|
|
167
|
-
agentUrl?: string;
|
|
168
|
-
keyid?: string;
|
|
169
|
-
};
|
|
170
|
-
declare function verifyWebBotAuth(request: Request, opts?: WebBotAuthOptions): Promise<WebBotAuthResult>;
|
|
18
|
+
declare function createTraceRelay(options: TraceRelayOptions): (request: Request) => Promise<Response>;
|
|
171
19
|
|
|
172
20
|
/**
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
* const auth = createAgentAuth({ apiKey: { verify } })
|
|
176
|
-
* const result = await auth.authenticate(request) // Fetch API Request
|
|
21
|
+
* The WebMCP `ModelContext` surface, per the W3C WebMCP draft (Oct 2026):
|
|
177
22
|
*
|
|
178
|
-
*
|
|
179
|
-
* routes can read; an unverified agent (or a human) browses exactly as before.
|
|
23
|
+
* await document.modelContext.registerTool(tool, { signal, exposedTo })
|
|
180
24
|
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
25
|
+
* - The getter lives on `document`. `navigator.modelContext` was the old name;
|
|
26
|
+
* Chrome 150 kept it as an alias and Chrome 152 removed it, so it's read
|
|
27
|
+
* only as a fallback.
|
|
28
|
+
* - `registerTool()` is async. There is no `unregisterTool()`; aborting the
|
|
29
|
+
* `signal` passed at registration unregisters the tool.
|
|
30
|
+
* - `toolactivated` / `toolcancel` events fire on the ModelContext when an
|
|
31
|
+
* agent starts or cancels a tool call — the only reliable "an agent is here"
|
|
32
|
+
* signal, because the API itself exists for every visitor of a WebMCP browser.
|
|
33
|
+
* - The declarative form API (`<form toolname>`) was removed from the spec
|
|
34
|
+
* (Oct 8, 2026) and lives on only as an explainer; the SDK registers every
|
|
35
|
+
* tool imperatively.
|
|
185
36
|
*/
|
|
37
|
+
interface ToolAnnotations {
|
|
38
|
+
/** The tool only reads; agents may call it without asking the user. */
|
|
39
|
+
readOnlyHint?: boolean;
|
|
40
|
+
/** The tool's output includes content the site didn't author (reviews, messages, …). */
|
|
41
|
+
untrustedContentHint?: boolean;
|
|
42
|
+
/** Payments, deletes, sends — the agent should confirm with the user first. */
|
|
43
|
+
consequentialHint?: boolean;
|
|
44
|
+
/** Exposed only to agent debugging tools. */
|
|
45
|
+
debugging?: boolean;
|
|
46
|
+
}
|
|
186
47
|
|
|
187
|
-
|
|
188
|
-
interface VerifiedAgent {
|
|
189
|
-
/** Stable id: signer URL, API-key agent id, OAuth client id, or crawler name. */
|
|
190
|
-
id: string;
|
|
48
|
+
interface GovernedTool<Input = unknown, Output = unknown> {
|
|
191
49
|
name: string;
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
50
|
+
/** Human-readable name agents and browsers may show (WebMCP `title`). */
|
|
51
|
+
title?: string;
|
|
52
|
+
version?: string;
|
|
53
|
+
group?: string;
|
|
54
|
+
description?: string;
|
|
55
|
+
/** WebMCP hints: readOnlyHint, consequentialHint, untrustedContentHint. */
|
|
56
|
+
annotations?: ToolAnnotations;
|
|
57
|
+
/** Other origins whose agents may see this tool (WebMCP `exposedTo`). */
|
|
58
|
+
exposedTo?: string[];
|
|
59
|
+
inputSchema?: Record<string, unknown>;
|
|
60
|
+
outputSchema?: Record<string, unknown>;
|
|
61
|
+
stage?: string;
|
|
62
|
+
authz?: Omit<PolicyRule, 'id' | 'tool'>;
|
|
63
|
+
rateLimit?: PolicyRule['rateLimit'];
|
|
64
|
+
execute: (input: Input, context: {
|
|
65
|
+
identity: AgentIdentity | null;
|
|
66
|
+
signal?: AbortSignal;
|
|
67
|
+
}) => Promise<Output> | Output;
|
|
195
68
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
agent: VerifiedAgent;
|
|
199
|
-
} | {
|
|
200
|
-
status: 'unverified';
|
|
201
|
-
reason: string;
|
|
202
|
-
claimedName?: string;
|
|
203
|
-
attempted: AgentAuthMethod[];
|
|
204
|
-
} | {
|
|
205
|
-
status: 'none';
|
|
206
|
-
};
|
|
69
|
+
|
|
70
|
+
/** Mirrors ApiKeyIdentity in @agentronics/sdk/server (kept structural to avoid a server import). */
|
|
207
71
|
interface ApiKeyIdentity {
|
|
208
72
|
agentId: string;
|
|
209
73
|
name?: string;
|
|
210
74
|
vendor?: string;
|
|
211
75
|
scopes?: string[];
|
|
212
76
|
}
|
|
213
|
-
interface ApiKeyOptions {
|
|
214
|
-
/** Key prefix that marks a bearer token as an agent key. Default `agk_`. */
|
|
215
|
-
prefix?: string;
|
|
216
|
-
/** Look the key up. Return null for unknown/revoked keys. */
|
|
217
|
-
verify: (key: string) => ApiKeyIdentity | null | Promise<ApiKeyIdentity | null>;
|
|
218
|
-
}
|
|
219
|
-
interface OAuth2Options {
|
|
220
|
-
issuer: string;
|
|
221
|
-
audience: string | string[];
|
|
222
|
-
/** Default `<issuer>/.well-known/jwks.json`. */
|
|
223
|
-
jwksUri?: string;
|
|
224
|
-
/** Static JWKS (tests / pinned keys) instead of fetching `jwksUri`. */
|
|
225
|
-
jwks?: {
|
|
226
|
-
keys: JsonWebKey[];
|
|
227
|
-
};
|
|
228
|
-
requiredScopes?: string[];
|
|
229
|
-
algorithms?: string[];
|
|
230
|
-
clockToleranceSec?: number;
|
|
231
|
-
}
|
|
232
|
-
interface CrawlerOptions {
|
|
233
|
-
/** Where to read the client IP. Default 'auto' (platform headers only). */
|
|
234
|
-
clientIp?: ClientIpSource;
|
|
235
|
-
/** Test seam / custom resolver. */
|
|
236
|
-
resolver?: DnsResolver;
|
|
237
|
-
}
|
|
238
|
-
interface AgentAuthOptions {
|
|
239
|
-
/** Web Bot Auth (on by default). `false` disables it. */
|
|
240
|
-
webBotAuth?: boolean | WebBotAuthOptions;
|
|
241
|
-
apiKey?: ApiKeyOptions;
|
|
242
|
-
oauth2?: OAuth2Options;
|
|
243
|
-
/** Verified crawlers (on by default). `false` disables it. */
|
|
244
|
-
crawlers?: boolean | CrawlerOptions;
|
|
245
|
-
}
|
|
246
|
-
declare function createAgentAuth(options?: AgentAuthOptions): {
|
|
247
|
-
authenticate: (request: Request) => Promise<AgentAuthResult>;
|
|
248
|
-
};
|
|
249
|
-
/** SHA-256 hex of an agent key — store this, never the key. */
|
|
250
|
-
declare function hashAgentKey(key: string): Promise<string>;
|
|
251
|
-
/** Verifier over a static map of `sha256(key) → identity` (e.g. from env/config). */
|
|
252
|
-
declare function staticKeyVerifier(hashedKeys: Record<string, ApiKeyIdentity>): ApiKeyOptions['verify'];
|
|
253
|
-
/** Mint a new agent key (`agk_` + 32 random bytes, base64url). Show it once; store its hash. */
|
|
254
|
-
declare function generateAgentKey(prefix?: string): string;
|
|
255
|
-
declare const AGENT_HEADERS: {
|
|
256
|
-
readonly status: "x-agentronics-agent-status";
|
|
257
|
-
readonly id: "x-agentronics-agent-id";
|
|
258
|
-
readonly name: "x-agentronics-agent-name";
|
|
259
|
-
readonly vendor: "x-agentronics-agent-vendor";
|
|
260
|
-
readonly method: "x-agentronics-auth-method";
|
|
261
|
-
};
|
|
262
77
|
/**
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
78
|
+
* Push the authoritative tool registry + site-memory snapshot to the
|
|
79
|
+
* Agentronics console — the full data the WebMCP Tools + Knaph pages need,
|
|
80
|
+
* which is too large for the lightweight trace stream. Call after `syncTools()`
|
|
81
|
+
* / `provideSiteMemory(...)`. Backend/server use only (the key is secret).
|
|
266
82
|
*/
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
})
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
83
|
+
interface IntelSync {
|
|
84
|
+
/** POST the registry to /v1/sdk/tools. Returns the number of tools sent. */
|
|
85
|
+
pushTools(tools: GovernedTool[]): Promise<number>;
|
|
86
|
+
/** POST the site-memory snapshot (+ optional quality score) to /v1/sdk/memory. */
|
|
87
|
+
pushMemory(snapshot: object, score?: number): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Fetch what the console manages for this site: authorization rules and the
|
|
90
|
+
* tool descriptions you approved in Procedural memory. Pass them to the
|
|
91
|
+
* browser SDK — `init({ policies, toolDescriptions })`.
|
|
92
|
+
*/
|
|
93
|
+
pullConfig(): Promise<DashboardConfig>;
|
|
94
|
+
/**
|
|
95
|
+
* An agent-API-key verifier for `createAgentAuth({ apiKey: { verify } })`
|
|
96
|
+
* that checks keys minted in the console, live — revoking a key in the
|
|
97
|
+
* console takes effect within `cacheSeconds` (default 60).
|
|
98
|
+
*/
|
|
99
|
+
keyVerifier(options?: {
|
|
100
|
+
cacheSeconds?: number;
|
|
101
|
+
}): (key: string) => Promise<ApiKeyIdentity | null>;
|
|
102
|
+
}
|
|
103
|
+
interface DashboardConfig {
|
|
104
|
+
policies: PolicyRule[];
|
|
105
|
+
/** tool name → approved description (replaces the code's description when published). */
|
|
106
|
+
toolDescriptions: Record<string, string>;
|
|
107
|
+
/** The site-memory snapshot last pushed for this site (null if none). */
|
|
108
|
+
siteMemory: Record<string, unknown> | null;
|
|
109
|
+
fetchedAt: string;
|
|
110
|
+
}
|
|
292
111
|
|
|
293
112
|
/**
|
|
294
|
-
*
|
|
113
|
+
* Serve `/.well-known/agent-context.json` — your site memory, for any agent,
|
|
114
|
+
* with no SDK on their side — from what you manage in the Agentronics console.
|
|
295
115
|
*
|
|
296
|
-
* -
|
|
297
|
-
*
|
|
298
|
-
* - agentronicsMiddleware(): Next.js middleware — see '@agentronics/sdk/next'
|
|
116
|
+
* // app/.well-known/agent-context.json/route.ts (Next.js)
|
|
117
|
+
* export const GET = createAgentContextHandler({ sync })
|
|
299
118
|
*
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
*
|
|
119
|
+
* The snapshot comes from `sync.pullConfig()` (the last `pushMemory()` for this
|
|
120
|
+
* site), cached in memory. If the console can't be reached, the last good
|
|
121
|
+
* snapshot keeps being served; with none, the route answers 404.
|
|
303
122
|
*/
|
|
304
123
|
|
|
305
|
-
interface
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
request: Request;
|
|
310
|
-
}) => void | Promise<void>;
|
|
311
|
-
/** Return false to skip a path (e.g. static assets). */
|
|
312
|
-
matcher?: (url: URL) => boolean;
|
|
313
|
-
}
|
|
314
|
-
interface HandlerOutcome {
|
|
315
|
-
result: AgentAuthResult;
|
|
316
|
-
/** Request headers to forward downstream (spoofed x-agentronics-* stripped). */
|
|
317
|
-
headers: Headers;
|
|
124
|
+
interface AgentContextHandlerOptions {
|
|
125
|
+
sync: Pick<IntelSync, 'pullConfig'>;
|
|
126
|
+
/** How long to reuse a snapshot. Default 300 s. */
|
|
127
|
+
cacheSeconds?: number;
|
|
318
128
|
}
|
|
319
|
-
declare function
|
|
320
|
-
interface NodeReq {
|
|
321
|
-
method?: string;
|
|
322
|
-
url?: string;
|
|
323
|
-
originalUrl?: string;
|
|
324
|
-
protocol?: string;
|
|
325
|
-
headers: Record<string, string | string[] | undefined>;
|
|
326
|
-
agent?: AgentAuthResult;
|
|
327
|
-
}
|
|
328
|
-
/**
|
|
329
|
-
* Express middleware. Sets `req.agent` to the auth result and the
|
|
330
|
-
* `x-agentronics-*` request headers for downstream handlers, then always
|
|
331
|
-
* calls next(). For correct `@authority`/client IP behind a proxy, set
|
|
332
|
-
* Express `trust proxy`.
|
|
333
|
-
*/
|
|
334
|
-
declare function expressAgentAuth(options?: AgentAuthHandlerOptions): (req: NodeReq, _res: unknown, next: (err?: unknown) => void) => void;
|
|
129
|
+
declare function createAgentContextHandler({ sync, cacheSeconds }: AgentContextHandlerOptions): () => Promise<Response>;
|
|
335
130
|
|
|
336
|
-
export {
|
|
131
|
+
export { type AgentContextHandlerOptions, type TraceRelayOptions, createAgentContextHandler, createTraceRelay };
|