@adcp/sdk 15.4.0 → 15.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/dist/lib/advanced.d.mts +2 -2
- package/dist/lib/advanced.d.ts +2 -2
- package/dist/lib/advanced.js +8 -2
- package/dist/lib/advanced.mjs +8 -2
- package/dist/lib/auth/oauth/index.d.mts +1 -0
- package/dist/lib/auth/oauth/index.d.ts +1 -0
- package/dist/lib/auth/oauth/index.js +5 -0
- package/dist/lib/auth/oauth/index.mjs +3 -0
- package/dist/lib/auth/oauth/pending-web-flow.d.mts +16 -0
- package/dist/lib/auth/oauth/pending-web-flow.d.ts +16 -0
- package/dist/lib/auth/oauth/pending-web-flow.js +66 -0
- package/dist/lib/auth/oauth/pending-web-flow.mjs +41 -0
- package/dist/lib/auth/oauth/web-flow.js +3 -3
- package/dist/lib/auth/oauth/web-flow.mjs +3 -3
- package/dist/lib/core/AgentClient.d.mts +4 -0
- package/dist/lib/core/AgentClient.d.ts +4 -0
- package/dist/lib/core/AgentClient.js +8 -0
- package/dist/lib/core/AgentClient.mjs +8 -0
- package/dist/lib/core/SingleAgentClient.d.mts +154 -0
- package/dist/lib/core/SingleAgentClient.d.ts +154 -0
- package/dist/lib/core/SingleAgentClient.js +661 -23
- package/dist/lib/core/SingleAgentClient.mjs +666 -23
- package/dist/lib/core/agent-discovery-cache.d.mts +103 -0
- package/dist/lib/core/agent-discovery-cache.d.ts +103 -0
- package/dist/lib/core/agent-discovery-cache.js +121 -0
- package/dist/lib/core/agent-discovery-cache.mjs +92 -0
- package/dist/lib/index.d.mts +5 -3
- package/dist/lib/index.d.ts +5 -3
- package/dist/lib/index.js +7 -0
- package/dist/lib/index.mjs +6 -0
- package/dist/lib/protocols/index.d.mts +2 -2
- package/dist/lib/protocols/index.d.ts +2 -2
- package/dist/lib/protocols/index.js +1 -1
- package/dist/lib/protocols/index.mjs +1 -1
- package/dist/lib/protocols/mcp-call-context.d.mts +109 -0
- package/dist/lib/protocols/mcp-call-context.d.ts +109 -0
- package/dist/lib/protocols/mcp-call-context.js +221 -0
- package/dist/lib/protocols/mcp-call-context.mjs +186 -0
- package/dist/lib/protocols/mcp-modern.d.mts +9 -1
- package/dist/lib/protocols/mcp-modern.d.ts +9 -1
- package/dist/lib/protocols/mcp-modern.js +180 -104
- package/dist/lib/protocols/mcp-modern.mjs +193 -104
- package/dist/lib/protocols/mcp-scope.d.mts +15 -0
- package/dist/lib/protocols/mcp-scope.d.ts +15 -0
- package/dist/lib/protocols/mcp.d.mts +4 -2
- package/dist/lib/protocols/mcp.d.ts +4 -2
- package/dist/lib/protocols/mcp.js +178 -154
- package/dist/lib/protocols/mcp.mjs +189 -153
- package/dist/lib/protocols/transportDiagnostics.d.mts +33 -1
- package/dist/lib/protocols/transportDiagnostics.d.ts +33 -1
- package/dist/lib/protocols/transportDiagnostics.js +128 -12
- package/dist/lib/protocols/transportDiagnostics.mjs +128 -12
- package/dist/lib/registry/types.generated.d.mts +63 -1
- package/dist/lib/registry/types.generated.d.ts +63 -1
- package/dist/lib/reporting/azure/index.d.mts +26 -0
- package/dist/lib/reporting/azure/index.d.ts +26 -0
- package/dist/lib/reporting/azure/index.js +247 -0
- package/dist/lib/reporting/azure/index.mjs +230 -0
- package/dist/lib/reporting/bigquery/index.d.mts +127 -0
- package/dist/lib/reporting/bigquery/index.d.ts +127 -0
- package/dist/lib/reporting/bigquery/index.js +379 -0
- package/dist/lib/reporting/bigquery/index.mjs +341 -0
- package/dist/lib/reporting/gcs/index.d.mts +2 -0
- package/dist/lib/reporting/gcs/index.d.ts +2 -0
- package/dist/lib/reporting/gcs/index.js +3 -0
- package/dist/lib/reporting/gcs/index.mjs +2 -0
- package/dist/lib/reporting/gcs/row-provider.d.mts +32 -0
- package/dist/lib/reporting/gcs/row-provider.d.ts +32 -0
- package/dist/lib/reporting/gcs/row-provider.js +205 -0
- package/dist/lib/reporting/gcs/row-provider.mjs +188 -0
- package/dist/lib/reporting/ledger/change-feed.d.mts +41 -0
- package/dist/lib/reporting/ledger/change-feed.d.ts +41 -0
- package/dist/lib/reporting/ledger/change-feed.js +101 -0
- package/dist/lib/reporting/ledger/change-feed.mjs +74 -0
- package/dist/lib/reporting/ledger/handler.js +22 -8
- package/dist/lib/reporting/ledger/handler.mjs +22 -8
- package/dist/lib/reporting/ledger/index.d.mts +4 -0
- package/dist/lib/reporting/ledger/index.d.ts +4 -0
- package/dist/lib/reporting/ledger/index.js +9 -1
- package/dist/lib/reporting/ledger/index.mjs +4 -0
- package/dist/lib/reporting/ledger/managed-postgres.d.mts +2 -0
- package/dist/lib/reporting/ledger/managed-postgres.d.ts +2 -0
- package/dist/lib/reporting/ledger/managed-postgres.js +21 -1
- package/dist/lib/reporting/ledger/managed-postgres.mjs +21 -1
- package/dist/lib/reporting/ledger/managed.d.mts +9 -0
- package/dist/lib/reporting/ledger/managed.d.ts +9 -0
- package/dist/lib/reporting/ledger/managed.js +18 -0
- package/dist/lib/reporting/ledger/managed.mjs +18 -0
- package/dist/lib/reporting/ledger/postgres.d.mts +185 -0
- package/dist/lib/reporting/ledger/postgres.d.ts +185 -0
- package/dist/lib/reporting/ledger/postgres.js +872 -26
- package/dist/lib/reporting/ledger/postgres.mjs +880 -26
- package/dist/lib/reporting/ledger/producer.js +10 -1
- package/dist/lib/reporting/ledger/producer.mjs +10 -1
- package/dist/lib/reporting/ledger/row-storage-errors.d.mts +7 -0
- package/dist/lib/reporting/ledger/row-storage-errors.d.ts +7 -0
- package/dist/lib/reporting/ledger/row-storage-errors.js +41 -0
- package/dist/lib/reporting/ledger/row-storage-errors.mjs +16 -0
- package/dist/lib/reporting/ledger/row-storage-migration.d.mts +41 -0
- package/dist/lib/reporting/ledger/row-storage-migration.d.ts +41 -0
- package/dist/lib/reporting/ledger/row-storage-migration.js +234 -0
- package/dist/lib/reporting/ledger/row-storage-migration.mjs +208 -0
- package/dist/lib/reporting/ledger/row-storage-object.d.mts +112 -0
- package/dist/lib/reporting/ledger/row-storage-object.d.ts +112 -0
- package/dist/lib/reporting/ledger/row-storage-object.js +304 -0
- package/dist/lib/reporting/ledger/row-storage-object.mjs +262 -0
- package/dist/lib/reporting/ledger/row-storage-provider-io.d.mts +44 -0
- package/dist/lib/reporting/ledger/row-storage-provider-io.d.ts +44 -0
- package/dist/lib/reporting/ledger/row-storage-provider-io.js +142 -0
- package/dist/lib/reporting/ledger/row-storage-provider-io.mjs +111 -0
- package/dist/lib/reporting/ledger/row-storage.d.mts +224 -0
- package/dist/lib/reporting/ledger/row-storage.d.ts +224 -0
- package/dist/lib/reporting/ledger/row-storage.js +692 -0
- package/dist/lib/reporting/ledger/row-storage.mjs +680 -0
- package/dist/lib/reporting/ledger/types.d.mts +8 -0
- package/dist/lib/reporting/ledger/types.d.ts +8 -0
- package/dist/lib/reporting/s3/index.d.mts +29 -0
- package/dist/lib/reporting/s3/index.d.ts +29 -0
- package/dist/lib/reporting/s3/index.js +324 -0
- package/dist/lib/reporting/s3/index.mjs +317 -0
- package/dist/lib/reporting/service/index.d.mts +43 -1
- package/dist/lib/reporting/service/index.d.ts +43 -1
- package/dist/lib/reporting/service/index.js +69 -1
- package/dist/lib/reporting/service/index.mjs +71 -1
- package/dist/lib/schemas/browser.d.mts +14 -0
- package/dist/lib/schemas/browser.d.ts +14 -0
- package/dist/lib/schemas/browser.js +48 -0
- package/dist/lib/schemas/browser.mjs +20 -0
- package/dist/lib/schemas/index.d.mts +2 -120
- package/dist/lib/schemas/index.d.ts +2 -120
- package/dist/lib/schemas/index.js +3 -11
- package/dist/lib/schemas/index.mjs +1 -9
- package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
- package/dist/lib/testing/index.d.mts +1 -0
- package/dist/lib/testing/index.d.ts +1 -0
- package/dist/lib/testing/index.js +3 -0
- package/dist/lib/testing/index.mjs +2 -0
- package/dist/lib/testing/pending-web-flow-store.d.mts +20 -0
- package/dist/lib/testing/pending-web-flow-store.d.ts +20 -0
- package/dist/lib/testing/pending-web-flow-store.js +132 -0
- package/dist/lib/testing/pending-web-flow-store.mjs +98 -0
- package/dist/lib/testing/storyboard/validations.d.mts +1 -1
- package/dist/lib/testing/storyboard/validations.d.ts +1 -1
- package/dist/lib/validation/get-products-request.d.mts +122 -0
- package/dist/lib/validation/get-products-request.d.ts +122 -0
- package/dist/lib/validation/get-products-request.js +39 -0
- package/dist/lib/validation/get-products-request.mjs +14 -0
- package/dist/lib/version.d.mts +3 -3
- package/dist/lib/version.d.ts +3 -3
- package/dist/lib/version.js +3 -3
- package/dist/lib/version.mjs +3 -3
- package/docs/README.md +1 -1
- package/docs/TYPE-SUMMARY.md +35 -2
- package/docs/ZOD-SCHEMAS.md +13 -1
- package/docs/guides/DISCOVERY-CACHE-AND-SESSION-REUSE.md +142 -0
- package/docs/guides/EXISTING-PLATFORM.md +43 -12
- package/docs/guides/OAUTH-ISSUER-BINDING.md +6 -0
- package/docs/guides/REPORTING-LEDGER.md +374 -0
- package/docs/guides/REPORTING-OPERATIONS.md +76 -1
- package/docs/guides/WEB-OAUTH.md +48 -1
- package/docs/llms.txt +4 -2
- package/docs/migration-14.x-rc-worksheet.md +6 -4
- package/package.json +64 -1
|
@@ -30,6 +30,7 @@ __export(transportDiagnostics_exports, {
|
|
|
30
30
|
module.exports = __toCommonJS(transportDiagnostics_exports);
|
|
31
31
|
var import_global_async_local_storage = require('../utils/global-async-local-storage.js');
|
|
32
32
|
var import_node_crypto = require("node:crypto");
|
|
33
|
+
var import_mcp_call_context = require('./mcp-call-context.js');
|
|
33
34
|
const BODY_SNIPPET_LIMIT = 64 * 1024;
|
|
34
35
|
const BODY_SNIPPET_TIMEOUT_MS = 1e3;
|
|
35
36
|
const OBSERVER_FLUSH_TIMEOUT_MS = 5e3;
|
|
@@ -110,7 +111,7 @@ function wrapFetchWithTransportDiagnostics(upstream) {
|
|
|
110
111
|
const url = sanitizeTransportUrl(getUrl(input));
|
|
111
112
|
const requestHeaders = sanitizeTransportHeaders(mergeRequestHeaders(input, init));
|
|
112
113
|
const requestBody = bodySnippet(init?.body);
|
|
113
|
-
const
|
|
114
|
+
const correlation = {
|
|
114
115
|
agentId: slot.agentId,
|
|
115
116
|
protocol: slot.protocol,
|
|
116
117
|
transportRequestId,
|
|
@@ -122,11 +123,15 @@ function wrapFetchWithTransportDiagnostics(upstream) {
|
|
|
122
123
|
method,
|
|
123
124
|
url,
|
|
124
125
|
requestHeaders,
|
|
126
|
+
startedAt
|
|
127
|
+
};
|
|
128
|
+
const signal = getSignal(input, init);
|
|
129
|
+
const baseEvent = {
|
|
130
|
+
...correlation,
|
|
125
131
|
...requestBody && {
|
|
126
132
|
requestBody: requestBody.body,
|
|
127
133
|
requestBodyTruncated: requestBody.truncated
|
|
128
|
-
}
|
|
129
|
-
startedAt
|
|
134
|
+
}
|
|
130
135
|
};
|
|
131
136
|
emitTransportActivity(handler, {
|
|
132
137
|
type: "request_started",
|
|
@@ -148,13 +153,18 @@ function wrapFetchWithTransportDiagnostics(upstream) {
|
|
|
148
153
|
};
|
|
149
154
|
const responseBody = responseBodySnippet(response);
|
|
150
155
|
if (!responseBody) {
|
|
151
|
-
|
|
152
|
-
handler,
|
|
153
|
-
response
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
if (!response.body) {
|
|
157
|
+
emitTransportActivity(handler, responseEvent);
|
|
158
|
+
return response;
|
|
159
|
+
}
|
|
160
|
+
const observer = observeResponseBody(response, handler, correlation, startedAtMs, signal);
|
|
161
|
+
emitTransportActivity(handler, {
|
|
162
|
+
...responseEvent,
|
|
163
|
+
responseBodyTruncated: true,
|
|
164
|
+
...observer && { streaming: true }
|
|
165
|
+
});
|
|
166
|
+
observer?.start();
|
|
167
|
+
return observer?.response ?? response;
|
|
158
168
|
} else {
|
|
159
169
|
void responseBody.then(
|
|
160
170
|
(captured) => {
|
|
@@ -188,8 +198,13 @@ function wrapFetchWithTransportDiagnostics(upstream) {
|
|
|
188
198
|
return wrapped;
|
|
189
199
|
}
|
|
190
200
|
function emitTransportActivity(handler, event) {
|
|
201
|
+
return dispatchTransportActivity(handler, event, true);
|
|
202
|
+
}
|
|
203
|
+
function emitUntrackedTransportActivity(handler, event) {
|
|
204
|
+
void dispatchTransportActivity(handler, event, false);
|
|
205
|
+
}
|
|
206
|
+
function dispatchTransportActivity(handler, event, track) {
|
|
191
207
|
try {
|
|
192
|
-
const slot = transportDiagnosticsStorage.getStore();
|
|
193
208
|
const frozen = Object.freeze(structuredClone(event));
|
|
194
209
|
const pending = Promise.resolve().then(() => handler(frozen)).then(
|
|
195
210
|
() => {
|
|
@@ -197,12 +212,113 @@ function emitTransportActivity(handler, event) {
|
|
|
197
212
|
() => {
|
|
198
213
|
}
|
|
199
214
|
);
|
|
200
|
-
|
|
215
|
+
if (track) transportDiagnosticsStorage.getStore()?.pending.push(pending);
|
|
201
216
|
return pending;
|
|
202
217
|
} catch {
|
|
203
218
|
return void 0;
|
|
204
219
|
}
|
|
205
220
|
}
|
|
221
|
+
function observeResponseBody(response, handler, correlation, startedAtMs, signal) {
|
|
222
|
+
const source = response.body;
|
|
223
|
+
if (!source) return void 0;
|
|
224
|
+
let reader;
|
|
225
|
+
try {
|
|
226
|
+
reader = source.getReader();
|
|
227
|
+
} catch {
|
|
228
|
+
return void 0;
|
|
229
|
+
}
|
|
230
|
+
const { status: httpStatus, statusText } = response;
|
|
231
|
+
let bytes = 0;
|
|
232
|
+
let finished = false;
|
|
233
|
+
const release = () => {
|
|
234
|
+
try {
|
|
235
|
+
reader.releaseLock();
|
|
236
|
+
} catch {
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
const onAbort = () => finish((0, import_mcp_call_context.isMCPCallCompleted)(signal?.reason) ? "cancelled" : "aborted", signal?.reason);
|
|
240
|
+
const finish = (outcome, error) => {
|
|
241
|
+
if (finished) return;
|
|
242
|
+
finished = true;
|
|
243
|
+
signal?.removeEventListener("abort", onAbort);
|
|
244
|
+
try {
|
|
245
|
+
const resolved = outcome !== "ended" && signal?.aborted ? (0, import_mcp_call_context.isMCPCallCompleted)(signal.reason) ? "cancelled" : "aborted" : outcome;
|
|
246
|
+
const event = {
|
|
247
|
+
...correlation,
|
|
248
|
+
type: "response_completed",
|
|
249
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
250
|
+
durationMs: Date.now() - startedAtMs,
|
|
251
|
+
httpStatus,
|
|
252
|
+
statusText,
|
|
253
|
+
outcome: resolved,
|
|
254
|
+
bytes
|
|
255
|
+
};
|
|
256
|
+
if (error !== void 0 && (resolved === "errored" || resolved === "aborted")) {
|
|
257
|
+
event.errorName = error instanceof Error ? error.name : typeof error;
|
|
258
|
+
event.errorMessage = sanitizeDiagnosticText(error instanceof Error ? error.message : String(error));
|
|
259
|
+
}
|
|
260
|
+
emitUntrackedTransportActivity(handler, event);
|
|
261
|
+
} catch {
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
const classify = (error) => error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError") ? "aborted" : "errored";
|
|
265
|
+
const stream = new ReadableStream(
|
|
266
|
+
{
|
|
267
|
+
async pull(controller) {
|
|
268
|
+
try {
|
|
269
|
+
const { done, value } = await reader.read();
|
|
270
|
+
if (done) {
|
|
271
|
+
finish("ended");
|
|
272
|
+
release();
|
|
273
|
+
controller.close();
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
if (typeof value?.byteLength === "number") bytes += value.byteLength;
|
|
277
|
+
controller.enqueue(value);
|
|
278
|
+
} catch (error) {
|
|
279
|
+
finish(classify(error), error);
|
|
280
|
+
release();
|
|
281
|
+
throw error;
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
cancel(reason) {
|
|
285
|
+
finish("cancelled", reason);
|
|
286
|
+
return reader.cancel(reason).finally(release);
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
{ highWaterMark: 0 }
|
|
290
|
+
);
|
|
291
|
+
let rebuilt;
|
|
292
|
+
try {
|
|
293
|
+
rebuilt = new Response(stream, {
|
|
294
|
+
status: response.status,
|
|
295
|
+
statusText: response.statusText,
|
|
296
|
+
headers: response.headers
|
|
297
|
+
});
|
|
298
|
+
} catch {
|
|
299
|
+
reader.releaseLock();
|
|
300
|
+
return void 0;
|
|
301
|
+
}
|
|
302
|
+
preserveResponseMetadata(response, rebuilt);
|
|
303
|
+
const start = () => {
|
|
304
|
+
reader.closed.catch((error) => finish(classify(error), error));
|
|
305
|
+
if (signal?.aborted) onAbort();
|
|
306
|
+
else signal?.addEventListener("abort", onAbort, { once: true });
|
|
307
|
+
};
|
|
308
|
+
return { response: rebuilt, start };
|
|
309
|
+
}
|
|
310
|
+
function preserveResponseMetadata(from, to) {
|
|
311
|
+
for (const key of ["url", "redirected", "type"]) {
|
|
312
|
+
try {
|
|
313
|
+
Object.defineProperty(to, key, { value: from[key], enumerable: true, configurable: true });
|
|
314
|
+
} catch {
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
function getSignal(input, init) {
|
|
319
|
+
if (init?.signal) return init.signal;
|
|
320
|
+
return input instanceof Request ? input.signal : void 0;
|
|
321
|
+
}
|
|
206
322
|
function getUrl(input) {
|
|
207
323
|
return typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
|
208
324
|
}
|
|
@@ -5,6 +5,7 @@ const __dirname = __adcpDirname(__adcpFileURLToPath(import.meta.url));
|
|
|
5
5
|
const require2 = __adcpCreateRequire(import.meta.url);
|
|
6
6
|
import { globalAsyncLocalStorage } from "../utils/global-async-local-storage.mjs";
|
|
7
7
|
import { createHmac, randomUUID } from "node:crypto";
|
|
8
|
+
import { isMCPCallCompleted } from "./mcp-call-context.mjs";
|
|
8
9
|
const BODY_SNIPPET_LIMIT = 64 * 1024;
|
|
9
10
|
const BODY_SNIPPET_TIMEOUT_MS = 1e3;
|
|
10
11
|
const OBSERVER_FLUSH_TIMEOUT_MS = 5e3;
|
|
@@ -85,7 +86,7 @@ function wrapFetchWithTransportDiagnostics(upstream) {
|
|
|
85
86
|
const url = sanitizeTransportUrl(getUrl(input));
|
|
86
87
|
const requestHeaders = sanitizeTransportHeaders(mergeRequestHeaders(input, init));
|
|
87
88
|
const requestBody = bodySnippet(init?.body);
|
|
88
|
-
const
|
|
89
|
+
const correlation = {
|
|
89
90
|
agentId: slot.agentId,
|
|
90
91
|
protocol: slot.protocol,
|
|
91
92
|
transportRequestId,
|
|
@@ -97,11 +98,15 @@ function wrapFetchWithTransportDiagnostics(upstream) {
|
|
|
97
98
|
method,
|
|
98
99
|
url,
|
|
99
100
|
requestHeaders,
|
|
101
|
+
startedAt
|
|
102
|
+
};
|
|
103
|
+
const signal = getSignal(input, init);
|
|
104
|
+
const baseEvent = {
|
|
105
|
+
...correlation,
|
|
100
106
|
...requestBody && {
|
|
101
107
|
requestBody: requestBody.body,
|
|
102
108
|
requestBodyTruncated: requestBody.truncated
|
|
103
|
-
}
|
|
104
|
-
startedAt
|
|
109
|
+
}
|
|
105
110
|
};
|
|
106
111
|
emitTransportActivity(handler, {
|
|
107
112
|
type: "request_started",
|
|
@@ -123,13 +128,18 @@ function wrapFetchWithTransportDiagnostics(upstream) {
|
|
|
123
128
|
};
|
|
124
129
|
const responseBody = responseBodySnippet(response);
|
|
125
130
|
if (!responseBody) {
|
|
126
|
-
|
|
127
|
-
handler,
|
|
128
|
-
response
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
if (!response.body) {
|
|
132
|
+
emitTransportActivity(handler, responseEvent);
|
|
133
|
+
return response;
|
|
134
|
+
}
|
|
135
|
+
const observer = observeResponseBody(response, handler, correlation, startedAtMs, signal);
|
|
136
|
+
emitTransportActivity(handler, {
|
|
137
|
+
...responseEvent,
|
|
138
|
+
responseBodyTruncated: true,
|
|
139
|
+
...observer && { streaming: true }
|
|
140
|
+
});
|
|
141
|
+
observer?.start();
|
|
142
|
+
return observer?.response ?? response;
|
|
133
143
|
} else {
|
|
134
144
|
void responseBody.then(
|
|
135
145
|
(captured) => {
|
|
@@ -163,8 +173,13 @@ function wrapFetchWithTransportDiagnostics(upstream) {
|
|
|
163
173
|
return wrapped;
|
|
164
174
|
}
|
|
165
175
|
function emitTransportActivity(handler, event) {
|
|
176
|
+
return dispatchTransportActivity(handler, event, true);
|
|
177
|
+
}
|
|
178
|
+
function emitUntrackedTransportActivity(handler, event) {
|
|
179
|
+
void dispatchTransportActivity(handler, event, false);
|
|
180
|
+
}
|
|
181
|
+
function dispatchTransportActivity(handler, event, track) {
|
|
166
182
|
try {
|
|
167
|
-
const slot = transportDiagnosticsStorage.getStore();
|
|
168
183
|
const frozen = Object.freeze(structuredClone(event));
|
|
169
184
|
const pending = Promise.resolve().then(() => handler(frozen)).then(
|
|
170
185
|
() => {
|
|
@@ -172,12 +187,113 @@ function emitTransportActivity(handler, event) {
|
|
|
172
187
|
() => {
|
|
173
188
|
}
|
|
174
189
|
);
|
|
175
|
-
|
|
190
|
+
if (track) transportDiagnosticsStorage.getStore()?.pending.push(pending);
|
|
176
191
|
return pending;
|
|
177
192
|
} catch {
|
|
178
193
|
return void 0;
|
|
179
194
|
}
|
|
180
195
|
}
|
|
196
|
+
function observeResponseBody(response, handler, correlation, startedAtMs, signal) {
|
|
197
|
+
const source = response.body;
|
|
198
|
+
if (!source) return void 0;
|
|
199
|
+
let reader;
|
|
200
|
+
try {
|
|
201
|
+
reader = source.getReader();
|
|
202
|
+
} catch {
|
|
203
|
+
return void 0;
|
|
204
|
+
}
|
|
205
|
+
const { status: httpStatus, statusText } = response;
|
|
206
|
+
let bytes = 0;
|
|
207
|
+
let finished = false;
|
|
208
|
+
const release = () => {
|
|
209
|
+
try {
|
|
210
|
+
reader.releaseLock();
|
|
211
|
+
} catch {
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
const onAbort = () => finish(isMCPCallCompleted(signal?.reason) ? "cancelled" : "aborted", signal?.reason);
|
|
215
|
+
const finish = (outcome, error) => {
|
|
216
|
+
if (finished) return;
|
|
217
|
+
finished = true;
|
|
218
|
+
signal?.removeEventListener("abort", onAbort);
|
|
219
|
+
try {
|
|
220
|
+
const resolved = outcome !== "ended" && signal?.aborted ? isMCPCallCompleted(signal.reason) ? "cancelled" : "aborted" : outcome;
|
|
221
|
+
const event = {
|
|
222
|
+
...correlation,
|
|
223
|
+
type: "response_completed",
|
|
224
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
225
|
+
durationMs: Date.now() - startedAtMs,
|
|
226
|
+
httpStatus,
|
|
227
|
+
statusText,
|
|
228
|
+
outcome: resolved,
|
|
229
|
+
bytes
|
|
230
|
+
};
|
|
231
|
+
if (error !== void 0 && (resolved === "errored" || resolved === "aborted")) {
|
|
232
|
+
event.errorName = error instanceof Error ? error.name : typeof error;
|
|
233
|
+
event.errorMessage = sanitizeDiagnosticText(error instanceof Error ? error.message : String(error));
|
|
234
|
+
}
|
|
235
|
+
emitUntrackedTransportActivity(handler, event);
|
|
236
|
+
} catch {
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
const classify = (error) => error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError") ? "aborted" : "errored";
|
|
240
|
+
const stream = new ReadableStream(
|
|
241
|
+
{
|
|
242
|
+
async pull(controller) {
|
|
243
|
+
try {
|
|
244
|
+
const { done, value } = await reader.read();
|
|
245
|
+
if (done) {
|
|
246
|
+
finish("ended");
|
|
247
|
+
release();
|
|
248
|
+
controller.close();
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
if (typeof value?.byteLength === "number") bytes += value.byteLength;
|
|
252
|
+
controller.enqueue(value);
|
|
253
|
+
} catch (error) {
|
|
254
|
+
finish(classify(error), error);
|
|
255
|
+
release();
|
|
256
|
+
throw error;
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
cancel(reason) {
|
|
260
|
+
finish("cancelled", reason);
|
|
261
|
+
return reader.cancel(reason).finally(release);
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
{ highWaterMark: 0 }
|
|
265
|
+
);
|
|
266
|
+
let rebuilt;
|
|
267
|
+
try {
|
|
268
|
+
rebuilt = new Response(stream, {
|
|
269
|
+
status: response.status,
|
|
270
|
+
statusText: response.statusText,
|
|
271
|
+
headers: response.headers
|
|
272
|
+
});
|
|
273
|
+
} catch {
|
|
274
|
+
reader.releaseLock();
|
|
275
|
+
return void 0;
|
|
276
|
+
}
|
|
277
|
+
preserveResponseMetadata(response, rebuilt);
|
|
278
|
+
const start = () => {
|
|
279
|
+
reader.closed.catch((error) => finish(classify(error), error));
|
|
280
|
+
if (signal?.aborted) onAbort();
|
|
281
|
+
else signal?.addEventListener("abort", onAbort, { once: true });
|
|
282
|
+
};
|
|
283
|
+
return { response: rebuilt, start };
|
|
284
|
+
}
|
|
285
|
+
function preserveResponseMetadata(from, to) {
|
|
286
|
+
for (const key of ["url", "redirected", "type"]) {
|
|
287
|
+
try {
|
|
288
|
+
Object.defineProperty(to, key, { value: from[key], enumerable: true, configurable: true });
|
|
289
|
+
} catch {
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
function getSignal(input, init) {
|
|
294
|
+
if (init?.signal) return init.signal;
|
|
295
|
+
return input instanceof Request ? input.signal : void 0;
|
|
296
|
+
}
|
|
181
297
|
function getUrl(input) {
|
|
182
298
|
return typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
|
183
299
|
}
|
|
@@ -1825,7 +1825,11 @@ export interface paths {
|
|
|
1825
1825
|
*/
|
|
1826
1826
|
put: operations["connectAgent"];
|
|
1827
1827
|
post?: never;
|
|
1828
|
-
|
|
1828
|
+
/**
|
|
1829
|
+
* Clear saved bearer or basic credentials
|
|
1830
|
+
* @description Clear the selected organization's static credential while retaining OAuth configuration and compliance history. Requires authentication and ownership.
|
|
1831
|
+
*/
|
|
1832
|
+
delete: operations["removeAgentAuthToken"];
|
|
1829
1833
|
options?: never;
|
|
1830
1834
|
head?: never;
|
|
1831
1835
|
patch?: never;
|
|
@@ -10662,6 +10666,64 @@ export interface operations {
|
|
|
10662
10666
|
};
|
|
10663
10667
|
};
|
|
10664
10668
|
};
|
|
10669
|
+
removeAgentAuthToken: {
|
|
10670
|
+
parameters: {
|
|
10671
|
+
query?: {
|
|
10672
|
+
org?: string;
|
|
10673
|
+
};
|
|
10674
|
+
header?: never;
|
|
10675
|
+
path: {
|
|
10676
|
+
encodedUrl: string;
|
|
10677
|
+
};
|
|
10678
|
+
cookie?: never;
|
|
10679
|
+
};
|
|
10680
|
+
requestBody?: never;
|
|
10681
|
+
responses: {
|
|
10682
|
+
/** @description Static credential cleared */
|
|
10683
|
+
204: {
|
|
10684
|
+
headers: {
|
|
10685
|
+
[name: string]: unknown;
|
|
10686
|
+
};
|
|
10687
|
+
content?: never;
|
|
10688
|
+
};
|
|
10689
|
+
/** @description Invalid parameters */
|
|
10690
|
+
400: {
|
|
10691
|
+
headers: {
|
|
10692
|
+
[name: string]: unknown;
|
|
10693
|
+
};
|
|
10694
|
+
content: {
|
|
10695
|
+
"application/json": components["schemas"]["Error"];
|
|
10696
|
+
};
|
|
10697
|
+
};
|
|
10698
|
+
/** @description Authentication required */
|
|
10699
|
+
401: {
|
|
10700
|
+
headers: {
|
|
10701
|
+
[name: string]: unknown;
|
|
10702
|
+
};
|
|
10703
|
+
content: {
|
|
10704
|
+
"application/json": components["schemas"]["Error"];
|
|
10705
|
+
};
|
|
10706
|
+
};
|
|
10707
|
+
/** @description Not authorized */
|
|
10708
|
+
403: {
|
|
10709
|
+
headers: {
|
|
10710
|
+
[name: string]: unknown;
|
|
10711
|
+
};
|
|
10712
|
+
content: {
|
|
10713
|
+
"application/json": components["schemas"]["Error"];
|
|
10714
|
+
};
|
|
10715
|
+
};
|
|
10716
|
+
/** @description Server error */
|
|
10717
|
+
500: {
|
|
10718
|
+
headers: {
|
|
10719
|
+
[name: string]: unknown;
|
|
10720
|
+
};
|
|
10721
|
+
content: {
|
|
10722
|
+
"application/json": components["schemas"]["Error"];
|
|
10723
|
+
};
|
|
10724
|
+
};
|
|
10725
|
+
};
|
|
10726
|
+
};
|
|
10665
10727
|
saveAgentOAuthClientCredentials: {
|
|
10666
10728
|
parameters: {
|
|
10667
10729
|
query?: never;
|
|
@@ -1825,7 +1825,11 @@ export interface paths {
|
|
|
1825
1825
|
*/
|
|
1826
1826
|
put: operations["connectAgent"];
|
|
1827
1827
|
post?: never;
|
|
1828
|
-
|
|
1828
|
+
/**
|
|
1829
|
+
* Clear saved bearer or basic credentials
|
|
1830
|
+
* @description Clear the selected organization's static credential while retaining OAuth configuration and compliance history. Requires authentication and ownership.
|
|
1831
|
+
*/
|
|
1832
|
+
delete: operations["removeAgentAuthToken"];
|
|
1829
1833
|
options?: never;
|
|
1830
1834
|
head?: never;
|
|
1831
1835
|
patch?: never;
|
|
@@ -10662,6 +10666,64 @@ export interface operations {
|
|
|
10662
10666
|
};
|
|
10663
10667
|
};
|
|
10664
10668
|
};
|
|
10669
|
+
removeAgentAuthToken: {
|
|
10670
|
+
parameters: {
|
|
10671
|
+
query?: {
|
|
10672
|
+
org?: string;
|
|
10673
|
+
};
|
|
10674
|
+
header?: never;
|
|
10675
|
+
path: {
|
|
10676
|
+
encodedUrl: string;
|
|
10677
|
+
};
|
|
10678
|
+
cookie?: never;
|
|
10679
|
+
};
|
|
10680
|
+
requestBody?: never;
|
|
10681
|
+
responses: {
|
|
10682
|
+
/** @description Static credential cleared */
|
|
10683
|
+
204: {
|
|
10684
|
+
headers: {
|
|
10685
|
+
[name: string]: unknown;
|
|
10686
|
+
};
|
|
10687
|
+
content?: never;
|
|
10688
|
+
};
|
|
10689
|
+
/** @description Invalid parameters */
|
|
10690
|
+
400: {
|
|
10691
|
+
headers: {
|
|
10692
|
+
[name: string]: unknown;
|
|
10693
|
+
};
|
|
10694
|
+
content: {
|
|
10695
|
+
"application/json": components["schemas"]["Error"];
|
|
10696
|
+
};
|
|
10697
|
+
};
|
|
10698
|
+
/** @description Authentication required */
|
|
10699
|
+
401: {
|
|
10700
|
+
headers: {
|
|
10701
|
+
[name: string]: unknown;
|
|
10702
|
+
};
|
|
10703
|
+
content: {
|
|
10704
|
+
"application/json": components["schemas"]["Error"];
|
|
10705
|
+
};
|
|
10706
|
+
};
|
|
10707
|
+
/** @description Not authorized */
|
|
10708
|
+
403: {
|
|
10709
|
+
headers: {
|
|
10710
|
+
[name: string]: unknown;
|
|
10711
|
+
};
|
|
10712
|
+
content: {
|
|
10713
|
+
"application/json": components["schemas"]["Error"];
|
|
10714
|
+
};
|
|
10715
|
+
};
|
|
10716
|
+
/** @description Server error */
|
|
10717
|
+
500: {
|
|
10718
|
+
headers: {
|
|
10719
|
+
[name: string]: unknown;
|
|
10720
|
+
};
|
|
10721
|
+
content: {
|
|
10722
|
+
"application/json": components["schemas"]["Error"];
|
|
10723
|
+
};
|
|
10724
|
+
};
|
|
10725
|
+
};
|
|
10726
|
+
};
|
|
10665
10727
|
saveAgentOAuthClientCredentials: {
|
|
10666
10728
|
parameters: {
|
|
10667
10729
|
query?: never;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { BlobServiceClient } from '@azure/storage-blob';
|
|
2
|
+
import type { ReportingRowObjectProviderV1 } from '../ledger/row-storage-object.mjs';
|
|
3
|
+
export interface CreateAzureBlobReportingRowObjectProviderOptionsV1 {
|
|
4
|
+
/** Official client used by bindings without a `credentialRef`. */
|
|
5
|
+
client?: BlobServiceClient;
|
|
6
|
+
/**
|
|
7
|
+
* Official clients keyed by `credentialRef`. This map is the closed set of
|
|
8
|
+
* references a binding may name; an unknown reference fails `UNSAFE_BINDING`.
|
|
9
|
+
* Endpoint and credentials come only from these clients.
|
|
10
|
+
*/
|
|
11
|
+
clients?: Readonly<Record<string, BlobServiceClient>>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Azure Blob Storage row-object provider (`@adcp/sdk/reporting/azure`).
|
|
15
|
+
*
|
|
16
|
+
* Inject official `BlobServiceClient`s with host-owned credentials (managed
|
|
17
|
+
* identity, workload identity). Bindings use `location: { account, container }`;
|
|
18
|
+
* the selected client must belong to `account`. Writes are block-blob uploads
|
|
19
|
+
* with `If-None-Match: *`. Blob versioning must be enabled on the storage account:
|
|
20
|
+
* the recorded native version is the write-unique `versionId` and pins every read
|
|
21
|
+
* and delete, so a delayed delete can never remove a later write that re-created
|
|
22
|
+
* identical bytes at the same key (ETags are content-derived and cannot fence that).
|
|
23
|
+
* The probe refuses accounts without versioning and proves create-only behaviour
|
|
24
|
+
* empirically.
|
|
25
|
+
*/
|
|
26
|
+
export declare function createAzureBlobReportingRowObjectProviderV1(options: CreateAzureBlobReportingRowObjectProviderOptionsV1): ReportingRowObjectProviderV1;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { BlobServiceClient } from '@azure/storage-blob';
|
|
2
|
+
import type { ReportingRowObjectProviderV1 } from '../ledger/row-storage-object';
|
|
3
|
+
export interface CreateAzureBlobReportingRowObjectProviderOptionsV1 {
|
|
4
|
+
/** Official client used by bindings without a `credentialRef`. */
|
|
5
|
+
client?: BlobServiceClient;
|
|
6
|
+
/**
|
|
7
|
+
* Official clients keyed by `credentialRef`. This map is the closed set of
|
|
8
|
+
* references a binding may name; an unknown reference fails `UNSAFE_BINDING`.
|
|
9
|
+
* Endpoint and credentials come only from these clients.
|
|
10
|
+
*/
|
|
11
|
+
clients?: Readonly<Record<string, BlobServiceClient>>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Azure Blob Storage row-object provider (`@adcp/sdk/reporting/azure`).
|
|
15
|
+
*
|
|
16
|
+
* Inject official `BlobServiceClient`s with host-owned credentials (managed
|
|
17
|
+
* identity, workload identity). Bindings use `location: { account, container }`;
|
|
18
|
+
* the selected client must belong to `account`. Writes are block-blob uploads
|
|
19
|
+
* with `If-None-Match: *`. Blob versioning must be enabled on the storage account:
|
|
20
|
+
* the recorded native version is the write-unique `versionId` and pins every read
|
|
21
|
+
* and delete, so a delayed delete can never remove a later write that re-created
|
|
22
|
+
* identical bytes at the same key (ETags are content-derived and cannot fence that).
|
|
23
|
+
* The probe refuses accounts without versioning and proves create-only behaviour
|
|
24
|
+
* empirically.
|
|
25
|
+
*/
|
|
26
|
+
export declare function createAzureBlobReportingRowObjectProviderV1(options: CreateAzureBlobReportingRowObjectProviderOptionsV1): ReportingRowObjectProviderV1;
|