@wenathlan/devthink 1.1.16 → 2.0.2
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/CHANGELOG.md +1288 -0
- package/README.md +6 -0
- package/bridge.d.ts +698 -0
- package/bridge.d.ts.map +1 -0
- package/bridge.js +1877 -0
- package/bun.d.ts +8 -0
- package/bun.d.ts.map +1 -0
- package/bun.js +52329 -0
- package/caps/background.json +712 -0
- package/caps/cli.json +360 -0
- package/caps/library.json +3611 -0
- package/caps/mcp.json +126 -0
- package/caps/pagebridge.json +377 -0
- package/caps/popup.json +51 -0
- package/caps/sidepanel.json +522 -0
- package/checksums.txt +142 -0
- package/cli.d.ts +187 -0
- package/cli.d.ts.map +1 -0
- package/cli.js +18197 -0
- package/companion.d.ts +19 -0
- package/companion.d.ts.map +1 -0
- package/companion.js +389 -0
- package/crossbrowser.d.ts +277 -0
- package/crossbrowser.d.ts.map +1 -0
- package/crossbrowser.js +1191 -0
- package/dashdone.d.ts +273 -0
- package/dashdone.d.ts.map +1 -0
- package/dashdone.js +368 -0
- package/deno.d.ts +11 -0
- package/deno.d.ts.map +1 -0
- package/deno.js +52325 -0
- package/devthink.umd.js +52346 -0
- package/fixtures/bun.ts +7 -0
- package/fixtures/cjs.js +6 -0
- package/fixtures/deno.ts +6 -0
- package/fixtures/example-org-pagestate.json +22 -0
- package/fixtures/importers/automa-workflow.json +18 -0
- package/fixtures/importers/selenium-side.json +20 -0
- package/fixtures/importers/tabular-plan.csv +7 -0
- package/fixtures/importers/uivision-macro.json +10 -0
- package/fixtures/importers/v1-plan.json +13 -0
- package/fixtures/mcp-client.mjs +14 -0
- package/fixtures/pages/checkout.html +192 -0
- package/fixtures/pages/dashboard.html +110 -0
- package/fixtures/pages/feed.html +113 -0
- package/fixtures/pages/product-grid.html +150 -0
- package/fixtures/plans/form-inventory-plan.json +11 -0
- package/fixtures/plans/release-notes-plan.json +11 -0
- package/fixtures/recipes/agentscompete.json +11 -0
- package/fixtures/recipes/agentsforms.json +11 -0
- package/fixtures/recipes/agentsmonitor.json +11 -0
- package/fixtures/recipes/agentsreview.json +29 -0
- package/fixtures/recipes/agentswarm.json +11 -0
- package/fixtures/recipes/fillcalendar.json +12 -0
- package/fixtures/recipes/fillcheckout.json +13 -0
- package/fixtures/recipes/filldependentdropdowns.json +12 -0
- package/fixtures/recipes/fillfromcsv.json +13 -0
- package/fixtures/recipes/fillloginform.json +12 -0
- package/fixtures/recipes/fillmultistepwizard.json +13 -0
- package/fixtures/recipes/fillregistration.json +12 -0
- package/fixtures/recipes/fillsearchfilters.json +12 -0
- package/fixtures/recipes/filltypeahead.json +11 -0
- package/fixtures/recipes/monitoralerts.json +12 -0
- package/fixtures/recipes/monitoravailability.json +11 -0
- package/fixtures/recipes/monitornetworkquiet.json +12 -0
- package/fixtures/recipes/monitorpagechanges.json +11 -0
- package/fixtures/recipes/monitorpricechange.json +11 -0
- package/fixtures/recipes/monitorschedule.json +12 -0
- package/fixtures/recipes/scrapedynamicprices.json +13 -0
- package/fixtures/recipes/scrapeimagegallery.json +12 -0
- package/fixtures/recipes/scrapeinfinitefeed.json +13 -0
- package/fixtures/recipes/scrapenestedlists.json +12 -0
- package/fixtures/recipes/scrapeproductgrid.json +12 -0
- package/fixtures/recipes/scrapereviews.json +12 -0
- package/fixtures/recipes/scrapesearchresults.json +12 -0
- package/fixtures/recipes/scrapetablepagination.json +12 -0
- package/fixtures/recipes/testaccessibility.json +34 -0
- package/fixtures/recipes/testconsoleerrors.json +12 -0
- package/fixtures/recipes/testdeeplinks.json +12 -0
- package/fixtures/recipes/testformvalidation.json +13 -0
- package/fixtures/recipes/testlayoutshift.json +12 -0
- package/fixtures/recipes/testlinkcheck.json +12 -0
- package/fixtures/recipes/testloadtiming.json +12 -0
- package/fixtures/recipes/testvisualdiff.json +12 -0
- package/fixtures/workflows/changelog-digest-workflow.json +13 -0
- package/fixtures/workflows/form-survey-workflow.json +13 -0
- package/gallery.json +706 -0
- package/hardening.d.ts +81 -0
- package/hardening.d.ts.map +1 -0
- package/hardening.js +188 -0
- package/headless.d.ts +114 -0
- package/headless.d.ts.map +1 -0
- package/headless.js +11522 -0
- package/http.d.ts +636 -0
- package/http.d.ts.map +1 -0
- package/http.js +2165 -0
- package/index.cjs +54682 -0
- package/index.d.ts +40 -0
- package/index.d.ts.map +1 -0
- package/index.js +52310 -0
- package/index.neutral.js +46343 -0
- package/manifest.json +199 -0
- package/mcp.d.ts +501 -0
- package/mcp.d.ts.map +1 -0
- package/mcp.js +20515 -0
- package/memory.d.ts +2397 -0
- package/memory.d.ts.map +1 -0
- package/memory.js +5782 -0
- package/nativehost.template.json +10 -0
- package/node.cjs +54686 -0
- package/node.d.ts +8 -0
- package/node.d.ts.map +1 -0
- package/pack.d.ts +211 -0
- package/pack.d.ts.map +1 -0
- package/pack.js +805 -0
- package/package.json +101 -51
- package/policy.d.ts +1854 -0
- package/policy.d.ts.map +1 -0
- package/policy.js +12580 -0
- package/progress.d.ts +390 -0
- package/progress.d.ts.map +1 -0
- package/progress.js +645 -0
- package/protocol.d.ts +2336 -0
- package/protocol.d.ts.map +1 -0
- package/protocol.js +8334 -0
- package/schemas/audit.schema.json +226 -0
- package/schemas/capability.schema.json +113 -0
- package/schemas/envelope.schema.json +162 -0
- package/schemas/memory.schema.json +51 -0
- package/schemas/observation.schema.json +113 -0
- package/schemas/plan.schema.json +208 -0
- package/schemas/progress.schema.json +126 -0
- package/schemas/proposal.schema.json +68 -0
- package/schemas/session.schema.json +82 -0
- package/schemas/tool.schema.json +94 -0
- package/server.d.ts +435 -0
- package/server.d.ts.map +1 -0
- package/server.js +28872 -0
- package/umd-example.html +18 -0
- package/umd.d.ts +6 -0
- package/umd.d.ts.map +1 -0
- package/build.ts +0 -41
- package/check-secrets.ts +0 -52
- package/compatibility.ts +0 -37
- package/config.ts +0 -246
- package/devthink.ts +0 -397
- package/identity.ts +0 -156
- package/ids.ts +0 -22
- package/memory.ts +0 -95
- package/modes.ts +0 -43
- package/plugin.ts +0 -68
- package/providers.ts +0 -179
- package/server.ts +0 -264
- package/session.ts +0 -155
- package/storage.ts +0 -82
- package/stream.ts +0 -130
- package/sync.ts +0 -27
- package/terminal-ui.tsx +0 -155
- package/ui.ts +0 -143
- package/workspace.ts +0 -20
package/http.d.ts
ADDED
|
@@ -0,0 +1,636 @@
|
|
|
1
|
+
/** The http module of the 1.1.88 consolidation: every correlated variation of the http logic interned in this one file, so the module family carries one surface without duplicate variations. */
|
|
2
|
+
import type { endpointrecord, fetchrequest, fetchoptions, graphqlrequest, htmlquery, jsonpathrule, parsedfield, payloadschema, streamwindow, jsonrpcframe, mcpserverconfig, sessiontoken, tlsconfig, transportkind, allowlistentry, clientrecord, httpstreamconfig, rpcerror, streamchannel, relayserverstate, relayserversession, serverenvelope } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Network observation part one logics for the 1.1.42 family.
|
|
5
|
+
* Every correlated rule for the outbound fetch with timeout, retries, backoff and the redirect follow limit, the streamed reading of large bodies inside a byte budget, the dotted json path extraction, the html query evaluation over a parse seam, the typed rest call with payload schemas and url templating and the graphql envelope wrapping and unwrapping lives in this file.
|
|
6
|
+
* Header values and body bytes never enter any audit summary built from these results.
|
|
7
|
+
*/
|
|
8
|
+
/** The network observation kinds, listed among the available capabilities of every proposal request. */
|
|
9
|
+
export declare const httpkinds: string[];
|
|
10
|
+
/** One transport response as the seam reports it: status, response headers, body text and redirect facts. */
|
|
11
|
+
export interface transportresponse {
|
|
12
|
+
status: number;
|
|
13
|
+
headers: Record<string, string>;
|
|
14
|
+
body: string;
|
|
15
|
+
/** Location of a readable redirect response, when the transport exposes one. */
|
|
16
|
+
location?: string;
|
|
17
|
+
redirected?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** Transport seam signature: one reviewed request against one url; the extension executor wires the browser fetch, tests wire plain fixtures. */
|
|
20
|
+
export type fetchtransport = (url: string, init: {
|
|
21
|
+
method: string;
|
|
22
|
+
headers: Record<string, string>;
|
|
23
|
+
body?: string;
|
|
24
|
+
mode?: string;
|
|
25
|
+
redirect: "follow" | "error";
|
|
26
|
+
}) => Promise<transportresponse>;
|
|
27
|
+
/** Transport facts of one completed outbound request: status, response header names, body, byte size, duration, retries and redirect hops. */
|
|
28
|
+
export interface calltransport {
|
|
29
|
+
url: string;
|
|
30
|
+
status: number;
|
|
31
|
+
statusclass: string;
|
|
32
|
+
headernames: string[];
|
|
33
|
+
body: string;
|
|
34
|
+
bytes: number;
|
|
35
|
+
duration: number;
|
|
36
|
+
retries: number;
|
|
37
|
+
redirects: number;
|
|
38
|
+
}
|
|
39
|
+
/** Maps one response status to its reviewed status class: informational, success, redirect, clienterror, servererror or unknown. */
|
|
40
|
+
export declare function statusclassof(status: number): "informational" | "success" | "redirect" | "clienterror" | "servererror" | "unknown";
|
|
41
|
+
/** Interpolates a reviewed url template by replacing every {variable} with the reviewed payload value of that name. */
|
|
42
|
+
export declare function templateurl(template: string, values: Record<string, unknown>): string;
|
|
43
|
+
/** Normalizes a reviewed fetch request value: url, method, custom header allowlist, body and mode; unknown fields stay ignored. */
|
|
44
|
+
export declare function fetchrequestof(value: unknown): fetchrequest | undefined;
|
|
45
|
+
/** Normalizes reviewed fetch policy options: timeout, retries, backoff base and redirect follow limit stay user choices with no code ceiling. */
|
|
46
|
+
export declare function fetchoptionsof(value: unknown): fetchoptions;
|
|
47
|
+
/** Normalizes a reviewed stream window: the byte budget ceiling stays a user choice. */
|
|
48
|
+
export declare function streamwindowof(value: unknown): streamwindow;
|
|
49
|
+
/** Normalizes reviewed json path rules: every rule needs a field name and a dotted path; kind and default stay optional. */
|
|
50
|
+
export declare function jsonpathrulesof(value: unknown): jsonpathrule[];
|
|
51
|
+
/** Normalizes reviewed html queries: selector, optional attribute and the multi flag for all matches versus the first. */
|
|
52
|
+
export declare function htmlqueriesof(value: unknown): htmlquery[];
|
|
53
|
+
/** Normalizes a reviewed graphql request: operation text, operation kind, variables and operation name. */
|
|
54
|
+
export declare function graphqlrequestof(value: unknown): graphqlrequest | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Sends one reviewed outbound request through the transport seam with the reviewed timeout, retries, backoff and redirect follow limit.
|
|
57
|
+
* Every bound stays a reviewed choice: the timeout races each attempt, failed attempts wait backoff times the attempt number before the retry, and redirect hops beyond the follow limit refuse instead of following.
|
|
58
|
+
*/
|
|
59
|
+
export declare function sendfetch(input: {
|
|
60
|
+
request: fetchrequest;
|
|
61
|
+
options?: fetchoptions;
|
|
62
|
+
transport: fetchtransport;
|
|
63
|
+
sleep?: (milliseconds: number) => Promise<void>;
|
|
64
|
+
onretry?: (attempt: number, wait: number, reason: string) => void;
|
|
65
|
+
now?: () => number;
|
|
66
|
+
}): Promise<calltransport>;
|
|
67
|
+
/**
|
|
68
|
+
* Consumes a large response body in chunks inside the reviewed stream window: every chunk passes the reviewed handler path, the byte budget aborts past the ceiling and the abort flag stops the stream cleanly between chunks.
|
|
69
|
+
*/
|
|
70
|
+
export declare function readstream(input: {
|
|
71
|
+
chunks: string[] | (() => Promise<string | undefined>);
|
|
72
|
+
window: streamwindow;
|
|
73
|
+
}): Promise<{
|
|
74
|
+
chunks: number;
|
|
75
|
+
bytes: number;
|
|
76
|
+
aborted: boolean;
|
|
77
|
+
reason?: string;
|
|
78
|
+
}>;
|
|
79
|
+
/**
|
|
80
|
+
* Extracts named fields from one parsed json body by dotted paths: array indexes use numeric segments, a miss fills the reviewed default and reports the miss instead of crashing, and every value carries its reviewed kind.
|
|
81
|
+
*/
|
|
82
|
+
export declare function readpath(parsed: unknown, rules: jsonpathrule[]): parsedfield[];
|
|
83
|
+
/** One element match of an html query as the parse seam reports it: text content plus attribute values. */
|
|
84
|
+
export interface htmlmatch {
|
|
85
|
+
text: string;
|
|
86
|
+
attributes: Record<string, string>;
|
|
87
|
+
}
|
|
88
|
+
/** The parsed document seam: one query function over fetched markup; the page bridge supplies the real domparser. */
|
|
89
|
+
export interface parseddocument {
|
|
90
|
+
query(selector: string): htmlmatch[];
|
|
91
|
+
}
|
|
92
|
+
/** Parse seam signature: turns fetched markup into a queryable document. */
|
|
93
|
+
export type domparse = (markup: string) => parseddocument;
|
|
94
|
+
/** Result of one reviewed html query: attribute values or text, the element count and the multi flag. */
|
|
95
|
+
export interface htmlqueryresult {
|
|
96
|
+
selector: string;
|
|
97
|
+
attribute?: string;
|
|
98
|
+
multi: boolean;
|
|
99
|
+
count: number;
|
|
100
|
+
values: string[];
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Parses fetched markup through the parse seam and runs the reviewed html queries: every query returns attribute values or text plus the element count, and the multi flag widens the first match to every match.
|
|
104
|
+
*/
|
|
105
|
+
export declare function parsehtmlbody(input: {
|
|
106
|
+
body: string;
|
|
107
|
+
queries: htmlquery[];
|
|
108
|
+
parse?: domparse;
|
|
109
|
+
}): htmlqueryresult[];
|
|
110
|
+
/** Validates one reviewed payload against an endpoint payload schema: every required field must be present with its kind; extra fields pass through as reviewed values. */
|
|
111
|
+
export declare function payloadvalid(payload: Record<string, unknown>, schema: payloadschema | undefined): {
|
|
112
|
+
ok: boolean;
|
|
113
|
+
errors: string[];
|
|
114
|
+
};
|
|
115
|
+
/** Applies the schema defaults to one reviewed payload: missing optional fields gain their reviewed default values. */
|
|
116
|
+
export declare function payloadwithdefaults(payload: Record<string, unknown>, schema: payloadschema | undefined): Record<string, unknown>;
|
|
117
|
+
/**
|
|
118
|
+
* Executes one typed rest endpoint call: the payload validates against the endpoint payload schema, the url templates its variables from the reviewed values, the reviewed success status list (or the two hundred class by default) maps the response code to the step outcome and json error bodies parse into structured errors.
|
|
119
|
+
*/
|
|
120
|
+
export declare function callrest(input: {
|
|
121
|
+
endpoint: endpointrecord;
|
|
122
|
+
payload: Record<string, unknown>;
|
|
123
|
+
options?: fetchoptions;
|
|
124
|
+
transport: fetchtransport;
|
|
125
|
+
success?: number[];
|
|
126
|
+
sleep?: (milliseconds: number) => Promise<void>;
|
|
127
|
+
onretry?: (attempt: number, wait: number, reason: string) => void;
|
|
128
|
+
now?: () => number;
|
|
129
|
+
}): Promise<{
|
|
130
|
+
transport: calltransport;
|
|
131
|
+
url: string;
|
|
132
|
+
payload: Record<string, unknown>;
|
|
133
|
+
ok: boolean;
|
|
134
|
+
errors: string[];
|
|
135
|
+
}>;
|
|
136
|
+
/** Wraps one reviewed graphql request into the request body envelope with the operation text, the variables and the operation name. */
|
|
137
|
+
export declare function graphqlopenvelope(request: graphqlrequest): string;
|
|
138
|
+
/** Unwraps a graphql response into its data block and every returned error mapped to a plain string. */
|
|
139
|
+
export declare function unwrapgraphql(value: unknown): {
|
|
140
|
+
data?: unknown;
|
|
141
|
+
errors: string[];
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Executes one reviewed graphql query or mutation against a typed endpoint: the operation wraps with its variables and operation name, and the response unwraps its data block while every returned error maps into the step result details.
|
|
145
|
+
*/
|
|
146
|
+
export declare function callgraphql(input: {
|
|
147
|
+
endpoint: endpointrecord;
|
|
148
|
+
request: graphqlrequest;
|
|
149
|
+
options?: fetchoptions;
|
|
150
|
+
transport: fetchtransport;
|
|
151
|
+
sleep?: (milliseconds: number) => Promise<void>;
|
|
152
|
+
onretry?: (attempt: number, wait: number, reason: string) => void;
|
|
153
|
+
now?: () => number;
|
|
154
|
+
}): Promise<{
|
|
155
|
+
transport: calltransport;
|
|
156
|
+
data?: unknown;
|
|
157
|
+
errors: string[];
|
|
158
|
+
}>;
|
|
159
|
+
/**
|
|
160
|
+
* Http transport of the 1.1.84 mcp server mode.
|
|
161
|
+
* Every streamable http concern lives in this file: the localhost bind with its documented default and the reviewed remote bind behind the explicit review, the posted envelope intake that parses one posted json rpc message — a bare frame or a batch — through the same frame pipeline the remote family owns, the server sent event frames of the stream channel with their event ids so a client resumes after a reconnect, the tls decision that turns on exactly when the user provides a certificate while an unverified peer refuses under the required mode, and the auth handshake requirement that keeps every non localhost connection behind the token exchange while localhost stays direct.
|
|
162
|
+
* The transport stays pure: the node listener reaches it through injected seams only, the bind, the port, the endpoint path and the tls material stay user choices with no code default beyond the documented localhost bind, and no certificate, endpoint or provider is ever hardcoded.
|
|
163
|
+
*/
|
|
164
|
+
/** Builds the http transport endpoint record of one server config: the bind with its port, the localhost state and the posted endpoint path the streamable transport serves. */
|
|
165
|
+
export declare function httpendpoint(config: mcpserverconfig): {
|
|
166
|
+
kind: transportkind;
|
|
167
|
+
endpoint: string;
|
|
168
|
+
bind: string;
|
|
169
|
+
port: number;
|
|
170
|
+
localhost: boolean;
|
|
171
|
+
path: string;
|
|
172
|
+
};
|
|
173
|
+
/** Decides the tls termination of one http transport: the transport speaks tls exactly when the user provides a certificate, the presented fingerprint must match the reviewed one under the required mode and an unverified peer refuses while the off mode keeps the plain localhost listener. */
|
|
174
|
+
export declare function tlsdecision(input: {
|
|
175
|
+
config: tlsconfig;
|
|
176
|
+
presented?: {
|
|
177
|
+
fingerprint?: string;
|
|
178
|
+
};
|
|
179
|
+
now: number;
|
|
180
|
+
}): {
|
|
181
|
+
tls: boolean;
|
|
182
|
+
verified: boolean;
|
|
183
|
+
reason?: string;
|
|
184
|
+
};
|
|
185
|
+
/** Requires the auth handshake of one posted frame: a localhost connection stays direct while any non localhost connection must present a verified session token through the same pipeline the remote family owns — the pipeline answers the refusal error the listener returns. */
|
|
186
|
+
export declare function postauth(input: {
|
|
187
|
+
config: mcpserverconfig;
|
|
188
|
+
local: boolean;
|
|
189
|
+
tokens: sessiontoken[];
|
|
190
|
+
rawtoken?: string;
|
|
191
|
+
fingerprint?: string;
|
|
192
|
+
toolname?: string;
|
|
193
|
+
now: number;
|
|
194
|
+
}): Promise<{
|
|
195
|
+
error?: {
|
|
196
|
+
code: string;
|
|
197
|
+
message: string;
|
|
198
|
+
retryhint: "retry" | "wait" | "none";
|
|
199
|
+
};
|
|
200
|
+
token?: sessiontoken;
|
|
201
|
+
}>;
|
|
202
|
+
/** Parses one posted body into its wire message: a bare frame parses as itself, an array parses as a batch and anything else refuses with the parse error the listener answers. */
|
|
203
|
+
export declare function parsepost(body: string): {
|
|
204
|
+
message?: jsonrpcframe | jsonrpcframe[];
|
|
205
|
+
error?: {
|
|
206
|
+
code: string;
|
|
207
|
+
message: string;
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
/** Encodes the http answer of one handled frame: the json body the post returns with its newline terminator so a line reader consumes it too. */
|
|
211
|
+
export declare function httpanswer(frame: jsonrpcframe): string;
|
|
212
|
+
/** Formats one server sent event of the stream channel: the event id the client resumes after, the event name and the json data line pair; the id advances with every event the channel emits. */
|
|
213
|
+
export declare function sseframe(input: {
|
|
214
|
+
id: number;
|
|
215
|
+
event: string;
|
|
216
|
+
frame: jsonrpcframe;
|
|
217
|
+
}): string;
|
|
218
|
+
/** Builds the stream channel endpoint record of one server config: the stream path beside the posted endpoint, on the same localhost bind and port while the channel rides its own path. */
|
|
219
|
+
export declare function streampathof(config: mcpserverconfig): {
|
|
220
|
+
path: string;
|
|
221
|
+
bind: string;
|
|
222
|
+
port: number;
|
|
223
|
+
localhost: boolean;
|
|
224
|
+
};
|
|
225
|
+
/** Answers whether one requested path is the posted endpoint or the stream channel of the configured transport; any other path refuses with the method error. */
|
|
226
|
+
export declare function routepath(config: mcpserverconfig, path: string): "endpoint" | "stream" | undefined;
|
|
227
|
+
/** The documented bind of the http listener: localhost only, kept beside the transport so the serve state and the docs share one name. */
|
|
228
|
+
export declare const documentedbind = "127.0.0.1";
|
|
229
|
+
/**
|
|
230
|
+
* Http stream transport of the 1.1.55 agent protocol part two.
|
|
231
|
+
* Every remote transport concern lives in this file: the http stream config with the posted json rpc endpoint and the server sent event channel paths, the stream channels the server keeps open for client streams, the heartbeat rhythm that keeps idle channels alive and closes dead ones, the tls termination that requires valid certificates before any remote traffic, the user configured client ceiling, the remote status report of endpoint, tls and client counts, and the ordered frame pipeline that terminates tls first, verifies the session token on every frame, checks the allowlist and runs the namespace scope check before any consent gate — auth failures answer with one fixed json rpc error so the pairing state never leaks.
|
|
232
|
+
* The transport stays honest: the browser runtime exposes no listening socket, so the frame intake rides the same seam as the stdio bridge while the endpoint, tls mode, heartbeat and ceiling all stay user configured with no code ceiling and no hardcoded endpoint or certificate.
|
|
233
|
+
*/
|
|
234
|
+
/** The documented default heartbeat interval of the event channels; any user configured rhythm wins. */
|
|
235
|
+
export declare const defaultheartbeatms = 30000;
|
|
236
|
+
/** The documented default idle window after which a silent channel counts as dead; any user configured window wins. */
|
|
237
|
+
export declare const defaultidlewindowms = 90000;
|
|
238
|
+
/** The documented default http stream config: the posted json rpc endpoint path, the server sent event channel path, tls off for the localhost default and the documented heartbeat rhythm. */
|
|
239
|
+
export declare function defaulthttpstream(): httpstreamconfig;
|
|
240
|
+
/** Opens one server sent event channel for a remote client stream: the open and first heartbeat times ride the record. */
|
|
241
|
+
export declare function openstreamchannel(input: {
|
|
242
|
+
clientid: string;
|
|
243
|
+
now: number;
|
|
244
|
+
id?: string;
|
|
245
|
+
}): streamchannel;
|
|
246
|
+
/** Stamps one heartbeat on every open channel of a client so idle channels stay alive. */
|
|
247
|
+
export declare function heartbeat(input: {
|
|
248
|
+
channels: streamchannel[];
|
|
249
|
+
clientid: string;
|
|
250
|
+
now: number;
|
|
251
|
+
}): streamchannel[];
|
|
252
|
+
/** Reports whether one channel stays live: an open channel inside its idle window counts as alive while closed channels and silent ones past the window count as dead. */
|
|
253
|
+
export declare function channellive(channel: streamchannel, now: number, idlewindow?: number): boolean;
|
|
254
|
+
/** Closes every dead channel: silent channels past the user configured idle window close while live channels stay open. */
|
|
255
|
+
export declare function closeidlechannels(input: {
|
|
256
|
+
channels: streamchannel[];
|
|
257
|
+
now: number;
|
|
258
|
+
idlewindow?: number;
|
|
259
|
+
}): streamchannel[];
|
|
260
|
+
/** Terminates tls before any remote traffic: the off mode keeps the documented localhost default, the on mode negotiates while the required mode refuses any peer without a valid certificate that matches the user configured fingerprint. */
|
|
261
|
+
export declare function starttls(input: {
|
|
262
|
+
config: tlsconfig;
|
|
263
|
+
presented?: {
|
|
264
|
+
fingerprint?: string;
|
|
265
|
+
};
|
|
266
|
+
now: number;
|
|
267
|
+
}): {
|
|
268
|
+
tls: boolean;
|
|
269
|
+
verified: boolean;
|
|
270
|
+
reason?: string;
|
|
271
|
+
};
|
|
272
|
+
/** Enforces the user configured client ceiling: a configured maximum refuses connections past it while an absent value keeps the client count unbounded. */
|
|
273
|
+
export declare function enforcemaxclients(input: {
|
|
274
|
+
clients: clientrecord[];
|
|
275
|
+
maxclients?: number;
|
|
276
|
+
}): {
|
|
277
|
+
allowed: boolean;
|
|
278
|
+
reason?: string;
|
|
279
|
+
};
|
|
280
|
+
/** Reports the remote transport status: the advertised endpoint, the tls state, the client counts, the open and dead stream channels and the live token count. */
|
|
281
|
+
export declare function listremotestatus(input: {
|
|
282
|
+
config: mcpserverconfig;
|
|
283
|
+
channels: streamchannel[];
|
|
284
|
+
clients: clientrecord[];
|
|
285
|
+
tokens: sessiontoken[];
|
|
286
|
+
now: number;
|
|
287
|
+
}): {
|
|
288
|
+
endpoint: string;
|
|
289
|
+
tls: {
|
|
290
|
+
mode: string;
|
|
291
|
+
certificaterequired: boolean;
|
|
292
|
+
verified: boolean;
|
|
293
|
+
};
|
|
294
|
+
clients: number;
|
|
295
|
+
paired: number;
|
|
296
|
+
channelsopen: number;
|
|
297
|
+
channelsdead: number;
|
|
298
|
+
tokenslive: number;
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* Runs the ordered intake pipeline of one remote frame: tls terminates first, the session token verifies on every frame, the allowlist refuses unknown fingerprints and the namespace scope check runs before any consent gate so unknown tools fail fast.
|
|
302
|
+
* A clean frame returns the verified token; every failure returns its json rpc error while auth failures answer with the fixed message that leaks no pairing state.
|
|
303
|
+
*/
|
|
304
|
+
export declare function httpframepipeline(input: {
|
|
305
|
+
config: mcpserverconfig;
|
|
306
|
+
presented?: {
|
|
307
|
+
fingerprint?: string;
|
|
308
|
+
};
|
|
309
|
+
tokens: sessiontoken[];
|
|
310
|
+
rawtoken?: string;
|
|
311
|
+
allowlist: allowlistentry[];
|
|
312
|
+
fingerprint: string;
|
|
313
|
+
toolname?: string;
|
|
314
|
+
now: number;
|
|
315
|
+
}): Promise<{
|
|
316
|
+
error?: rpcerror;
|
|
317
|
+
token?: sessiontoken;
|
|
318
|
+
}>;
|
|
319
|
+
/**
|
|
320
|
+
* Relayserve of the 1.1.87 self hosting family.
|
|
321
|
+
* Every server side relay concern of the publishing pipeline lives in this one pure module: the session state machine a self hosted relay drives for the extension and the site members, the pairing code exchange the extension side registers and the site side redeems, the per frame token authentication (the relay issues one token per member, keeps the hash in the session records and rotates the token on every rejoin — the raw token lives only in the memory-only issuance map so the routed frames address their member and no log or record ever carries it), the event routing between the two members of a session over the four servercontract operations, the idle sweep that closes a quiet connection inside the window the operator chose, and the deterministic reply list the runner writes back onto its sockets. The module stays pure: the wire frames reach it as text through injected seams, the ids and the token hashes come from injected seams (the container runner injects crypto randomness, tests inject counters), the relay never names an endpoint of its own because the operator hosts it at the address they choose, and no pairing code, token or page content ever enters an error message it builds.
|
|
322
|
+
* Example: `const outcome = relayserverframe({ state, connectionid: "conn-1", frame: text, now }); const routed = outcome.routed;`
|
|
323
|
+
*/
|
|
324
|
+
/** The id seam signature: one call resolves the next opaque id (a session id, a token or a pairing code); the container runner injects crypto randomness while the tests inject deterministic counters. */
|
|
325
|
+
export type relayidseam = () => string;
|
|
326
|
+
/** The hash seam signature: the relay hashes every token it issues so the session records keep the hash only; the container runner injects the sha256 digest, the tests inject the plain identity. */
|
|
327
|
+
export type relayhashseam = (token: string) => string;
|
|
328
|
+
/** Creates the empty relay server state: no session, no pairing, no connection and no token — the runner registers connections as its sockets open. */
|
|
329
|
+
export declare function newrelayserverstate(): relayserverstate;
|
|
330
|
+
/** Registers one connection the relay accepted: the connection starts with no role, no session and no token; the frame handler fills them as the servercontract handshake proceeds. */
|
|
331
|
+
export declare function relayconnectionopen(state: relayserverstate, connectionid: string, now: number): relayserverstate;
|
|
332
|
+
/** Removes one connection the relay lost: the session keeps its event log, the member slot frees for a rejoin, the memory-only token record of the connection drops with it and the pairing codes stay pending until they expire. */
|
|
333
|
+
export declare function relayconnectionclose(state: relayserverstate, connectionid: string): relayserverstate;
|
|
334
|
+
/** Reads the live token hashes of one session: the hashes the session issued minus the revoked ones — the frame authentication checks every incoming token against this list. */
|
|
335
|
+
export declare function relaylivetokens(session: relayserversession): string[];
|
|
336
|
+
/** Encodes one envelope as the wire frame text the runner writes onto the socket: the plain json text of the servercontract codec. */
|
|
337
|
+
export declare function relayframeof(envelope: Omit<serverenvelope, "version"> & {
|
|
338
|
+
version?: number;
|
|
339
|
+
}): string;
|
|
340
|
+
/** Handles one wire frame of one connection: the frame parses through the servercontract codec, the sessioncreate operation opens a session for the extension member (issuing its token and registering the pairing code when the frame carries one), the sessionjoin operation redeems a pairing code for the site member or rotates the token of a returning member, the eventpost operation routes the event to the other member of the session, and the eventstream operation acks the subscription — every other frame answers the outside the contract error and a failed token authentication answers the refusal without touching the session state. */
|
|
341
|
+
export declare function relayserverframe(input: {
|
|
342
|
+
state: relayserverstate;
|
|
343
|
+
connectionid: string;
|
|
344
|
+
frame: string;
|
|
345
|
+
now: number;
|
|
346
|
+
idof?: relayidseam;
|
|
347
|
+
hashof?: relayhashseam;
|
|
348
|
+
}): {
|
|
349
|
+
state: relayserverstate;
|
|
350
|
+
replies: string[];
|
|
351
|
+
routed: Array<{
|
|
352
|
+
connectionid: string;
|
|
353
|
+
frame: string;
|
|
354
|
+
}>;
|
|
355
|
+
};
|
|
356
|
+
/** Lists the connection ids the idle sweep closes: a connection quiet past the window the operator chose leaves, while an absent window never expires a connection because the bound stays the operator's choice. */
|
|
357
|
+
export declare function relayidleconnections(state: relayserverstate, now: number, idlewindow?: number): string[];
|
|
358
|
+
/** Reads the pairing codes pending redemption: the codes the extension side registered, still unused and still inside their lifetime — the list the self hosting walkthrough prints so the operator pairs the site side. */
|
|
359
|
+
export declare function relaypendingpairings(state: relayserverstate, now: number): string[];
|
|
360
|
+
/**
|
|
361
|
+
* Stdio transport of the 1.1.84 mcp server mode.
|
|
362
|
+
* Every stdio wire concern lives in this file: the frame boundary handling that splits the raw stdin bytes into newline delimited json lines while a partial tail stays buffered until its newline arrives, the line pump a local client rides — every decoded message routes through the injected handler seam and every response frame encodes back to stdout through the injected write seam while notifications stay unanswered — the transport counters that mirror the frames both directions, and the transport record the serve state reports.
|
|
363
|
+
* The transport stays pure: the process pipes reach it through the injected read and write seams only, the handler seam carries the serve frame router, and no client process, host name or endpoint is ever hardcoded — the user launches the local client and its stdio wires the two together.
|
|
364
|
+
*/
|
|
365
|
+
/** One stdio transport record of the serve mode: the pipe channel it rides, the frame counters of both directions and the lifecycle times. */
|
|
366
|
+
export interface stdiotransportrecord {
|
|
367
|
+
kind: "stdio";
|
|
368
|
+
endpoint: string;
|
|
369
|
+
startedat: number;
|
|
370
|
+
received: number;
|
|
371
|
+
sent: number;
|
|
372
|
+
lastframeat?: number;
|
|
373
|
+
closedat?: number;
|
|
374
|
+
}
|
|
375
|
+
/** Splits one raw stdin chunk into its complete newline delimited lines: every complete line parses while a trailing fragment without its newline stays buffered for the next chunk; a buffer without a newline yields no line. */
|
|
376
|
+
export declare function splitlines(buffer: string): {
|
|
377
|
+
lines: string[];
|
|
378
|
+
rest: string;
|
|
379
|
+
};
|
|
380
|
+
/** Creates one stdio transport record for the serve state: the pipe channel of the spawned serve process with its frame counters at zero. */
|
|
381
|
+
export declare function stdiotransport(now: number): stdiotransportrecord;
|
|
382
|
+
/** Creates the line pump of one stdio session: raw stdin chunks feed the pump, complete lines decode through the message codec, every frame of the decoded message routes through the handler seam and every response frame encodes newline delimited back through the write seam — notifications carry no id and stay unanswered while a handler that throws answers the internal error frame so a failing frame never kills the transport. */
|
|
383
|
+
export declare function createlinepump(input: {
|
|
384
|
+
write: (line: string) => void;
|
|
385
|
+
handle: (frame: jsonrpcframe) => Promise<jsonrpcframe | undefined>;
|
|
386
|
+
now: number;
|
|
387
|
+
}): {
|
|
388
|
+
feed: (chunk: string) => Promise<void>;
|
|
389
|
+
record: () => stdiotransportrecord;
|
|
390
|
+
close: (now: number) => stdiotransportrecord;
|
|
391
|
+
};
|
|
392
|
+
import type { apicallrecord, cacheentry, correlationcontext, eventsubscription, formpayload, graphqlsubscription, longpollrequest, multipartfield, multipartpayload, pollcursor, ratelimitdirective } from "./types.js";
|
|
393
|
+
/**
|
|
394
|
+
* Web api transport logics of the 1.1.76 family.
|
|
395
|
+
* Every correlated rule for the widened transport surface lives in this one module: the server sent events subscription lifecycle with field parsing, last event id resume, clean cancellation and channel error surfacing; the long poll request loop that waits on the response cursor, retries on the configured timeout backoff and stops on cancellation or plan expiry; the graphql subscription message mapping of next, error and complete frames into step results; the urlencoded form post and the streamed multipart upload with their part encodings and upload progress; the per run correlation id assignment that joins request and response pairs and exports one request map to the audit trail; the rate limit directive parsing that delays the next request until the reset window and honors the retry after wait of 429 and 503 answers; and the per run response cache that keys by url, method and body hash, serves repeated read only calls inside one run, expires entries by the response headers and the user policy and never caches a response that follows a mutation.
|
|
396
|
+
* The module reuses the socketbus parsing of the 1.1.43 family for the event stream grammar and the poll cursor decisions, and the netauth encodings of the 1.1.44 family for the urlencoded and multipart wire shapes, so the transport widening extends the reviewed families instead of duplicating them.
|
|
397
|
+
* Message payloads and field values are opaque reviewed text; no payload value enters any audit summary built from these results, and every timeout, backoff, retention and bound stays a user choice with no code default — an absent value never hides a hardcoded ceiling.
|
|
398
|
+
*/
|
|
399
|
+
import { type sseevent } from "./net.js";
|
|
400
|
+
/** Stream open seam: one reviewed url with its request headers resolves to a reader of text chunks or an error class; the extension executor wires the fetch stream, tests wire plain fixtures. */
|
|
401
|
+
export type streamopen = (url: string, headers: Record<string, string>) => Promise<{
|
|
402
|
+
ok: boolean;
|
|
403
|
+
status: number;
|
|
404
|
+
read: () => Promise<{
|
|
405
|
+
done: boolean;
|
|
406
|
+
text?: string;
|
|
407
|
+
}>;
|
|
408
|
+
error?: string;
|
|
409
|
+
}>;
|
|
410
|
+
/** Poll fetch seam: one poll url with its optional request body resolves to the response status, headers and text; the extension executor wires fetch, tests wire plain fixtures. */
|
|
411
|
+
export type pollfetch = (url: string, body?: string) => Promise<{
|
|
412
|
+
status: number;
|
|
413
|
+
headers: Record<string, string>;
|
|
414
|
+
body: string;
|
|
415
|
+
timeout?: boolean;
|
|
416
|
+
}>;
|
|
417
|
+
/**
|
|
418
|
+
* Runs one server sent events subscription through the stream open seam: the channel reads chunk by chunk, every complete block parses into its event, data, id and retry fields, the last event id persists so a reconnect resumes exactly where the stream stopped, a cancelled step or an elapsed lifetime closes the channel cleanly, and a channel error surfaces to the run state machine instead of dying silently.
|
|
419
|
+
*/
|
|
420
|
+
export declare function subevents(input: {
|
|
421
|
+
record: eventsubscription;
|
|
422
|
+
open: streamopen;
|
|
423
|
+
cancelled?: () => boolean;
|
|
424
|
+
now?: () => number;
|
|
425
|
+
}): Promise<{
|
|
426
|
+
record: eventsubscription;
|
|
427
|
+
events: sseevent[];
|
|
428
|
+
error?: string;
|
|
429
|
+
}>;
|
|
430
|
+
/** Normalizes one reviewed long poll request from step options: the url the poll drives, the user chosen timeout of one request and the resume cursor; an absent timeout never aborts a poll because the bound stays a user choice with no code default. */
|
|
431
|
+
export declare function longpollrequestof(value: unknown): longpollrequest | undefined;
|
|
432
|
+
/**
|
|
433
|
+
* Runs one long poll loop through the poll fetch seam: each iteration issues the request the reviewed cursor builds, waits on the response cursor, retries a timed out request under the configured backoff and stops on the reviewed stop condition, the cancellation flag, the plan expiry or the reviewed poll ceiling; the loop never invents a bound of its own.
|
|
434
|
+
*/
|
|
435
|
+
export declare function longpoll(input: {
|
|
436
|
+
request: longpollrequest;
|
|
437
|
+
cursor: pollcursor;
|
|
438
|
+
fetchpoll: pollfetch;
|
|
439
|
+
cancelled?: () => boolean;
|
|
440
|
+
expiresat?: number;
|
|
441
|
+
backoff?: number;
|
|
442
|
+
now?: () => number;
|
|
443
|
+
sleep?: (milliseconds: number) => Promise<void>;
|
|
444
|
+
}): Promise<{
|
|
445
|
+
polls: number;
|
|
446
|
+
retries: number;
|
|
447
|
+
reason: string;
|
|
448
|
+
cursor?: string;
|
|
449
|
+
exchanges: Array<{
|
|
450
|
+
url: string;
|
|
451
|
+
status: number;
|
|
452
|
+
body: string;
|
|
453
|
+
timeout: boolean;
|
|
454
|
+
}>;
|
|
455
|
+
error?: string;
|
|
456
|
+
}>;
|
|
457
|
+
/** One parsed graphql subscription message of the graphql-ws grammar: the next payload, the error list or the complete marker with its operation id. */
|
|
458
|
+
export interface graphqlmessage {
|
|
459
|
+
kind: "next" | "error" | "complete";
|
|
460
|
+
id?: string;
|
|
461
|
+
/** The payload of a next message, kept opaque for the step results. */
|
|
462
|
+
payload?: unknown;
|
|
463
|
+
/** The error messages of an error message. */
|
|
464
|
+
errors?: string[];
|
|
465
|
+
}
|
|
466
|
+
/** Normalizes one reviewed graphql subscription from step options: the query, its variables and the websocket channel the subscription rides. */
|
|
467
|
+
export declare function graphqlsubscriptionof(value: unknown): graphqlsubscription | undefined;
|
|
468
|
+
/** Parses one inbound graphql subscription message of the graphql-ws grammar into its next, error or complete kind; an unparseable frame reports itself as an error instead of dying silently. */
|
|
469
|
+
export declare function parsegraphqlmessage(payload: string): graphqlmessage;
|
|
470
|
+
/** Builds the graphql-ws subscribe frame of one reviewed subscription: the operation id, the query and its variables ride one json frame the channel publishes. */
|
|
471
|
+
export declare function graphqlsubscribeframe(subscription: graphqlsubscription, operationid: string): string;
|
|
472
|
+
/** Maps the inbound graphql subscription messages into step results: every next payload becomes one result with its operation id, the errors collect for the step outcome and the complete marker closes the mapping. */
|
|
473
|
+
export declare function graphqlsub(input: {
|
|
474
|
+
subscription: graphqlsubscription;
|
|
475
|
+
messages: string[];
|
|
476
|
+
}): {
|
|
477
|
+
results: Array<{
|
|
478
|
+
id?: string;
|
|
479
|
+
data: unknown;
|
|
480
|
+
}>;
|
|
481
|
+
errors: string[];
|
|
482
|
+
completed: boolean;
|
|
483
|
+
};
|
|
484
|
+
/** Builds one reviewed urlencoded form post for a granted origin: the fields encode with the urlencoded grammar under the application/x-www-form-urlencoded content type, and an origin outside the grants refuses before any byte moves. */
|
|
485
|
+
export declare function formpost(input: {
|
|
486
|
+
payload: formpayload;
|
|
487
|
+
grants: string[];
|
|
488
|
+
}): {
|
|
489
|
+
ok: true;
|
|
490
|
+
url: string;
|
|
491
|
+
method: "POST";
|
|
492
|
+
headers: Record<string, string>;
|
|
493
|
+
body: string;
|
|
494
|
+
} | {
|
|
495
|
+
ok: false;
|
|
496
|
+
refusal: string;
|
|
497
|
+
};
|
|
498
|
+
/** Builds the part headers of one multipart file field: the content disposition names the field and the filename while the content type carries the reviewed mime of the part. */
|
|
499
|
+
export declare function multipartfieldheader(field: multipartfield): string;
|
|
500
|
+
/** Encodes one reviewed multipart upload for a granted origin: the fields and the files encode into ordered chunks under one boundary, the progress callback reports each streamed chunk with its sent and total bytes without ever buffering the whole payload, and an origin outside the grants or an unreviewed file refuses before any byte moves. */
|
|
501
|
+
export declare function multipartpost(input: {
|
|
502
|
+
payload: multipartpayload;
|
|
503
|
+
grants: string[];
|
|
504
|
+
onprogress?: (progress: {
|
|
505
|
+
chunk: number;
|
|
506
|
+
chunks: number;
|
|
507
|
+
sent: number;
|
|
508
|
+
total: number;
|
|
509
|
+
}) => void;
|
|
510
|
+
}): {
|
|
511
|
+
ok: true;
|
|
512
|
+
url: string;
|
|
513
|
+
method: "POST";
|
|
514
|
+
headers: Record<string, string>;
|
|
515
|
+
chunks: string[];
|
|
516
|
+
boundary: string;
|
|
517
|
+
bytes: number;
|
|
518
|
+
} | {
|
|
519
|
+
ok: false;
|
|
520
|
+
refusal: string;
|
|
521
|
+
};
|
|
522
|
+
/** Assigns one request id per outbound request of the run: the correlation context grows by the request, the correlation id derives from the run and the request order, and the mapping stays read only inside the run. */
|
|
523
|
+
export declare function correlateids(input: {
|
|
524
|
+
context: correlationcontext;
|
|
525
|
+
stepid: string;
|
|
526
|
+
url: string;
|
|
527
|
+
method: string;
|
|
528
|
+
now: number;
|
|
529
|
+
}): {
|
|
530
|
+
context: correlationcontext;
|
|
531
|
+
requestid: string;
|
|
532
|
+
};
|
|
533
|
+
/** Joins one response onto its request through the shared correlation id: the request gains its response id and status, and a request id the map does not carry refuses instead of pairing the wrong pair. */
|
|
534
|
+
export declare function joincorrelation(input: {
|
|
535
|
+
context: correlationcontext;
|
|
536
|
+
requestid: string;
|
|
537
|
+
responseid?: string;
|
|
538
|
+
status: number;
|
|
539
|
+
now: number;
|
|
540
|
+
}): correlationcontext;
|
|
541
|
+
/** Exports the per run request map for the audit trail: every request with its correlation id, its pair state and the paired share, read only beside the run it belongs to. */
|
|
542
|
+
export declare function correlationexport(context: correlationcontext): {
|
|
543
|
+
runid: string;
|
|
544
|
+
requests: number;
|
|
545
|
+
pairs: number;
|
|
546
|
+
map: Array<{
|
|
547
|
+
requestid: string;
|
|
548
|
+
correlationid: string;
|
|
549
|
+
stepid: string;
|
|
550
|
+
url: string;
|
|
551
|
+
origin: string;
|
|
552
|
+
method: string;
|
|
553
|
+
paired: boolean;
|
|
554
|
+
status?: number;
|
|
555
|
+
at: number;
|
|
556
|
+
}>;
|
|
557
|
+
};
|
|
558
|
+
/** Parses one rate limit directive from the response headers: the remaining count and the reset window of the x-ratelimit family and the retry after wait of a 429 or 503 answer compose into one directive scoped to the origin; headers without any rate limit fact parse to nothing. */
|
|
559
|
+
export declare function ratelimitdirectiveof(headers: Record<string, string>, origin: string, status: number, now: number): ratelimitdirective | undefined;
|
|
560
|
+
/** Resolves the wait the next request of one origin owes: the newest directive of the origin names the milliseconds until its reset window passes, an absent or passed directive waits nothing, and the wait itself stays a user respected value with no code ceiling. */
|
|
561
|
+
export declare function ratelimitwaitof(directives: ratelimitdirective[], origin: string, now: number): {
|
|
562
|
+
waitms: number;
|
|
563
|
+
directive?: ratelimitdirective;
|
|
564
|
+
};
|
|
565
|
+
/** Applies the rate limit respect before one transport call: the wait sleeps until the reset window of the origin passes so the call never crosses a limit the endpoint published, and the resolved wait reports itself for the audit trail. */
|
|
566
|
+
export declare function ratelimitrespect(input: {
|
|
567
|
+
directives: ratelimitdirective[];
|
|
568
|
+
origin: string;
|
|
569
|
+
now?: () => number;
|
|
570
|
+
sleep?: (milliseconds: number) => Promise<void>;
|
|
571
|
+
}): Promise<{
|
|
572
|
+
waitms: number;
|
|
573
|
+
directive?: ratelimitdirective;
|
|
574
|
+
}>;
|
|
575
|
+
/** Hashes one request body for the cache key with a stable rolling digest; the hash never carries the body values anywhere, only their shape identity. */
|
|
576
|
+
export declare function bodyhashof(body: string): string;
|
|
577
|
+
/** Builds the cache key of one call: the run namespace, the method, the url and the body hash compose into one key so a repeated read of the same run serves from its own entry only. */
|
|
578
|
+
export declare function cachekeyof(input: {
|
|
579
|
+
runid: string;
|
|
580
|
+
url: string;
|
|
581
|
+
method: string;
|
|
582
|
+
body: string;
|
|
583
|
+
}): string;
|
|
584
|
+
/** Resolves the expiry timestamp of one stored response from its headers and the user policy: the cache-control max-age and the expires date cap the entry while the user configured retention bounds the entries per run, and an absent fact keeps the entry until the run ends. */
|
|
585
|
+
export declare function cacheexpiryof(headers: Record<string, string>, now: number, retention?: number): number | undefined;
|
|
586
|
+
/** True when the method reads only: GET and HEAD carry no mutation, every other verb mutates and its responses never cache. */
|
|
587
|
+
export declare function readmethod(method: string): boolean;
|
|
588
|
+
/** Stores one response in the per run cache: the entry keys by the run namespace, the url, the method and the body hash, only a read only method stores, a response that carries credentials refuses through the cache gate of the caller, and a response that follows a mutation on its origin never stores because the mutation invalidated the read it would answer. */
|
|
589
|
+
export declare function cacheresponse(input: {
|
|
590
|
+
entries: cacheentry[];
|
|
591
|
+
url: string;
|
|
592
|
+
method: string;
|
|
593
|
+
body: string;
|
|
594
|
+
headers: Record<string, string>;
|
|
595
|
+
status: number;
|
|
596
|
+
runid: string;
|
|
597
|
+
now: number;
|
|
598
|
+
retention?: number;
|
|
599
|
+
credentials?: boolean;
|
|
600
|
+
mutatedat?: number;
|
|
601
|
+
}): {
|
|
602
|
+
entries: cacheentry[];
|
|
603
|
+
entry?: cacheentry;
|
|
604
|
+
refusal?: string;
|
|
605
|
+
};
|
|
606
|
+
/** Serves one repeated read only call from the per run cache: the entry with the matching key serves while its expiry has not passed, a hit bumps its counter, an entry whose origin saw a mutation stops serving, and an expired entry drops with its expiry reported. */
|
|
607
|
+
export declare function cacheserv(input: {
|
|
608
|
+
entries: cacheentry[];
|
|
609
|
+
url: string;
|
|
610
|
+
method: string;
|
|
611
|
+
body: string;
|
|
612
|
+
runid: string;
|
|
613
|
+
now: number;
|
|
614
|
+
mutatedat?: number;
|
|
615
|
+
}): {
|
|
616
|
+
entries: cacheentry[];
|
|
617
|
+
entry?: cacheentry;
|
|
618
|
+
expired?: cacheentry;
|
|
619
|
+
};
|
|
620
|
+
/** Runs the cache expiry cleanup pass: every entry whose expiry passed drops while its metadata survives through the caller, and the pass reports exactly what it expired. */
|
|
621
|
+
export declare function cachecleanup(entries: cacheentry[], now: number): {
|
|
622
|
+
kept: cacheentry[];
|
|
623
|
+
expired: cacheentry[];
|
|
624
|
+
};
|
|
625
|
+
/** Builds one observed page api call record from a captured exchange fact: the url, its origin, the endpoint path, the method, the status and the mime compose into one read only observation beside the discovered api map. */
|
|
626
|
+
export declare function apicallrecordof(input: {
|
|
627
|
+
id: string;
|
|
628
|
+
runid: string;
|
|
629
|
+
stepid: string;
|
|
630
|
+
url: string;
|
|
631
|
+
method: string;
|
|
632
|
+
status: number;
|
|
633
|
+
mime?: string;
|
|
634
|
+
at: number;
|
|
635
|
+
}): apicallrecord;
|
|
636
|
+
//# sourceMappingURL=http.d.ts.map
|