@agentuity/adapter 3.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +92 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +388 -0
- package/dist/index.js.map +1 -0
- package/package.json +40 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
export type { Logger } from '@agentuity/core';
|
|
2
|
+
/**
|
|
3
|
+
* HTTP client adapter for Agentuity service clients.
|
|
4
|
+
*
|
|
5
|
+
* This package provides a minimal HTTP adapter that service clients (keyvalue, queue, etc.)
|
|
6
|
+
* use to communicate with Agentuity cloud services. It handles authentication headers,
|
|
7
|
+
* request/response processing, and debug logging.
|
|
8
|
+
*
|
|
9
|
+
* @module @agentuity/adapter
|
|
10
|
+
*/
|
|
11
|
+
import type { FetchRequest, FetchResponse, FetchAdapter, Logger } from '@agentuity/core';
|
|
12
|
+
import { ServiceException } from '@agentuity/core';
|
|
13
|
+
/**
|
|
14
|
+
* Configuration for the service fetch adapter.
|
|
15
|
+
*/
|
|
16
|
+
export interface ServiceAdapterConfig {
|
|
17
|
+
/** Headers to include in all requests */
|
|
18
|
+
headers: Record<string, string>;
|
|
19
|
+
/** Query parameters to append to all requests */
|
|
20
|
+
queryParams?: Record<string, string>;
|
|
21
|
+
/** Hook called before each request */
|
|
22
|
+
onBefore?: (url: string, options: FetchRequest, invoke: () => Promise<void>) => Promise<void>;
|
|
23
|
+
/** Hook called after each request */
|
|
24
|
+
onAfter?: <T>(url: string, options: FetchRequest, response: FetchResponse<T>, err?: InstanceType<typeof ServiceException>) => Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Options for building client request headers.
|
|
28
|
+
*/
|
|
29
|
+
export interface BuildClientHeadersOptions {
|
|
30
|
+
/** API key for authentication (Bearer token) */
|
|
31
|
+
apiKey?: string;
|
|
32
|
+
/** Organization ID for multi-tenant requests */
|
|
33
|
+
orgId?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Builds standard headers for Agentuity service clients.
|
|
37
|
+
*
|
|
38
|
+
* This helper creates the header object needed by `createServerFetchAdapter`,
|
|
39
|
+
* handling authentication and multi-tenant scoping consistently across all clients.
|
|
40
|
+
*
|
|
41
|
+
* @param options - Options containing apiKey and/or orgId
|
|
42
|
+
* @returns Headers object ready to pass to createServerFetchAdapter
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* import { buildClientHeaders, createServerFetchAdapter } from '@agentuity/adapter';
|
|
47
|
+
*
|
|
48
|
+
* const headers = buildClientHeaders({ apiKey: 'sk_xxx', orgId: 'org_xxx' });
|
|
49
|
+
* const adapter = createServerFetchAdapter({ headers }, logger);
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function buildClientHeaders(options: BuildClientHeadersOptions): Record<string, string>;
|
|
53
|
+
/**
|
|
54
|
+
* Redacts the middle of a string while keeping a prefix and suffix visible.
|
|
55
|
+
* Ensures that if the string is too short, everything is redacted.
|
|
56
|
+
*
|
|
57
|
+
* @param input The string to redact
|
|
58
|
+
* @param prefix Number of chars to keep at the start
|
|
59
|
+
* @param suffix Number of chars to keep at the end
|
|
60
|
+
* @param mask Character used for redaction
|
|
61
|
+
*/
|
|
62
|
+
export declare function redact(input: string, prefix?: number, suffix?: number, mask?: string): string;
|
|
63
|
+
declare class ServerFetchAdapter implements FetchAdapter {
|
|
64
|
+
#private;
|
|
65
|
+
constructor(config: ServiceAdapterConfig, logger: Logger);
|
|
66
|
+
private _invoke;
|
|
67
|
+
invoke<T>(url: string, options?: FetchRequest): Promise<FetchResponse<T>>;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Create a Server Side Fetch Adapter to allow the server to add headers and track outgoing requests.
|
|
71
|
+
*
|
|
72
|
+
* This adapter is used by all Agentuity service clients (KeyValueClient, QueueClient, etc.)
|
|
73
|
+
* to communicate with Agentuity cloud services.
|
|
74
|
+
*
|
|
75
|
+
* @param config - Configuration containing headers and optional hooks
|
|
76
|
+
* @param logger - Logger instance for debug output
|
|
77
|
+
* @returns A FetchAdapter instance
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* import { createServerFetchAdapter, buildClientHeaders } from '@agentuity/adapter';
|
|
82
|
+
* import { createMinimalLogger } from '@agentuity/core';
|
|
83
|
+
*
|
|
84
|
+
* const headers = buildClientHeaders({ apiKey: 'sk_xxx' });
|
|
85
|
+
* const adapter = createServerFetchAdapter({ headers }, createMinimalLogger());
|
|
86
|
+
*
|
|
87
|
+
* // Use with a service
|
|
88
|
+
* const service = new KeyValueStorageService('https://api.agentuity.sh', adapter);
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export declare function createServerFetchAdapter(config: ServiceAdapterConfig, logger: Logger): ServerFetchAdapter;
|
|
92
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACX,YAAY,EAEZ,aAAa,EACb,YAAY,EACZ,MAAM,EAEN,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAoC,MAAM,iBAAiB,CAAC;AAOrF;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC,yCAAyC;IACzC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,iDAAiD;IACjD,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,sCAAsC;IACtC,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9F,qCAAqC;IACrC,OAAO,CAAC,EAAE,CAAC,CAAC,EACX,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,YAAY,EACrB,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,EAC1B,GAAG,CAAC,EAAE,YAAY,CAAC,OAAO,gBAAgB,CAAC,KACvC,OAAO,CAAC,IAAI,CAAC,CAAC;CACnB;AAMD;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACzC,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAa7F;AAkBD;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CACrB,KAAK,EAAE,MAAM,EACb,MAAM,GAAE,MAAU,EAClB,MAAM,GAAE,MAAU,EAClB,IAAI,GAAE,MAAY,GAChB,MAAM,CAaR;AAkLD,cAAM,kBAAmB,YAAW,YAAY;;gBAInC,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM;YAoB1C,OAAO;IA2Ef,MAAM,CAAC,CAAC,EACb,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,YAAiC,GACxC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;CAsC5B;AAMD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,sBAEpF"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import { ServiceException, toServiceException, fromResponse } from '@agentuity/core';
|
|
2
|
+
import { appendFileSync } from 'node:fs';
|
|
3
|
+
/**
|
|
4
|
+
* Builds standard headers for Agentuity service clients.
|
|
5
|
+
*
|
|
6
|
+
* This helper creates the header object needed by `createServerFetchAdapter`,
|
|
7
|
+
* handling authentication and multi-tenant scoping consistently across all clients.
|
|
8
|
+
*
|
|
9
|
+
* @param options - Options containing apiKey and/or orgId
|
|
10
|
+
* @returns Headers object ready to pass to createServerFetchAdapter
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { buildClientHeaders, createServerFetchAdapter } from '@agentuity/adapter';
|
|
15
|
+
*
|
|
16
|
+
* const headers = buildClientHeaders({ apiKey: 'sk_xxx', orgId: 'org_xxx' });
|
|
17
|
+
* const adapter = createServerFetchAdapter({ headers }, logger);
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export function buildClientHeaders(options) {
|
|
21
|
+
const headers = options.apiKey
|
|
22
|
+
? {
|
|
23
|
+
Authorization: `Bearer ${options.apiKey}`,
|
|
24
|
+
'Content-Type': 'application/json',
|
|
25
|
+
}
|
|
26
|
+
: { 'Content-Type': 'application/json' };
|
|
27
|
+
if (options.orgId) {
|
|
28
|
+
headers['x-agentuity-orgid'] = options.orgId;
|
|
29
|
+
}
|
|
30
|
+
return headers;
|
|
31
|
+
}
|
|
32
|
+
// =============================================================================
|
|
33
|
+
// Redaction Utilities
|
|
34
|
+
// =============================================================================
|
|
35
|
+
/**
|
|
36
|
+
* Headers that contain sensitive information and should be redacted in debug logs.
|
|
37
|
+
* Includes authentication tokens, API keys, cookies, and proxy credentials.
|
|
38
|
+
*/
|
|
39
|
+
const sensitiveHeaders = new Set([
|
|
40
|
+
'authorization',
|
|
41
|
+
'x-api-key',
|
|
42
|
+
'cookie',
|
|
43
|
+
'set-cookie',
|
|
44
|
+
'proxy-authorization',
|
|
45
|
+
]);
|
|
46
|
+
/**
|
|
47
|
+
* Redacts the middle of a string while keeping a prefix and suffix visible.
|
|
48
|
+
* Ensures that if the string is too short, everything is redacted.
|
|
49
|
+
*
|
|
50
|
+
* @param input The string to redact
|
|
51
|
+
* @param prefix Number of chars to keep at the start
|
|
52
|
+
* @param suffix Number of chars to keep at the end
|
|
53
|
+
* @param mask Character used for redaction
|
|
54
|
+
*/
|
|
55
|
+
export function redact(input, prefix = 4, suffix = 4, mask = '*') {
|
|
56
|
+
if (!input)
|
|
57
|
+
return '';
|
|
58
|
+
// If revealing prefix+suffix would leak too much, fully mask
|
|
59
|
+
if (input.length <= prefix + suffix) {
|
|
60
|
+
return mask.repeat(input.length);
|
|
61
|
+
}
|
|
62
|
+
const start = input.slice(0, prefix);
|
|
63
|
+
const end = input.slice(-suffix);
|
|
64
|
+
const hiddenLength = input.length - prefix - suffix;
|
|
65
|
+
return start + mask.repeat(hiddenLength) + end;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Format a sensitive header value, preserving Bearer prefix if present.
|
|
69
|
+
*/
|
|
70
|
+
function redactSensitiveHeader(key, value) {
|
|
71
|
+
const _k = key.toLowerCase();
|
|
72
|
+
// Handle Bearer tokens in authorization and proxy-authorization headers
|
|
73
|
+
if ((_k === 'authorization' || _k === 'proxy-authorization') && value.startsWith('Bearer ')) {
|
|
74
|
+
return `Bearer ${redact(value.substring(7))}`;
|
|
75
|
+
}
|
|
76
|
+
return redact(value);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Format headers as a readable string for debug logging.
|
|
80
|
+
* Sensitive headers (auth tokens, cookies, API keys) are redacted.
|
|
81
|
+
*/
|
|
82
|
+
function formatHeaders(headers) {
|
|
83
|
+
const entries = [];
|
|
84
|
+
if (headers instanceof Headers) {
|
|
85
|
+
headers.forEach((value, key) => {
|
|
86
|
+
const _k = key.toLowerCase();
|
|
87
|
+
if (sensitiveHeaders.has(_k)) {
|
|
88
|
+
entries.push(` ${key}: ${redactSensitiveHeader(key, value)}`);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
entries.push(` ${key}: ${value}`);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
97
|
+
const _k = key.toLowerCase();
|
|
98
|
+
if (sensitiveHeaders.has(_k)) {
|
|
99
|
+
entries.push(` ${key}: ${redactSensitiveHeader(key, value)}`);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
entries.push(` ${key}: ${value}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return entries.join('\n');
|
|
107
|
+
}
|
|
108
|
+
const redactHeaders = (kv) => {
|
|
109
|
+
const values = [];
|
|
110
|
+
for (const k of Object.keys(kv)) {
|
|
111
|
+
const _k = k.toLowerCase();
|
|
112
|
+
const v = kv[k];
|
|
113
|
+
if (v === undefined) {
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
if (sensitiveHeaders.has(_k)) {
|
|
117
|
+
values.push(`${_k}=${redactSensitiveHeader(k, v)}`);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
values.push(`${_k}=${v}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return '[' + values.join(',') + ']';
|
|
124
|
+
};
|
|
125
|
+
// =============================================================================
|
|
126
|
+
// Debug Logging
|
|
127
|
+
// =============================================================================
|
|
128
|
+
/**
|
|
129
|
+
* Check if API debug logging is enabled and return the output destination.
|
|
130
|
+
* Returns:
|
|
131
|
+
* - 'console' if CI=1/true or AGENTUITY_API_DEBUG=1/true
|
|
132
|
+
* - file path string if AGENTUITY_API_DEBUG is set to a path
|
|
133
|
+
* - null if debug logging is disabled (including AGENTUITY_API_DEBUG=0/false)
|
|
134
|
+
*/
|
|
135
|
+
function getDebugOutput() {
|
|
136
|
+
const apiDebug = process.env.AGENTUITY_API_DEBUG?.trim();
|
|
137
|
+
if (apiDebug) {
|
|
138
|
+
const normalized = apiDebug.toLowerCase();
|
|
139
|
+
// Check if explicitly disabled
|
|
140
|
+
if (normalized === '0' || normalized === 'false') {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
// Check if it's a truthy value (console output)
|
|
144
|
+
if (normalized === '1' || normalized === 'true') {
|
|
145
|
+
return 'console';
|
|
146
|
+
}
|
|
147
|
+
// Treat any other non-empty value as a file path
|
|
148
|
+
return apiDebug;
|
|
149
|
+
}
|
|
150
|
+
// Fall back to CI environment check
|
|
151
|
+
if (process.env.CI === '1' || process.env.CI === 'true') {
|
|
152
|
+
return 'console';
|
|
153
|
+
}
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Format request body for CI debug logging
|
|
158
|
+
*/
|
|
159
|
+
function formatRequestBody(body) {
|
|
160
|
+
if (body === undefined || body === null) {
|
|
161
|
+
return '[no body]';
|
|
162
|
+
}
|
|
163
|
+
if (typeof body === 'string') {
|
|
164
|
+
return body;
|
|
165
|
+
}
|
|
166
|
+
if (body instanceof Uint8Array) {
|
|
167
|
+
return `[binary data: ${body.length} bytes]`;
|
|
168
|
+
}
|
|
169
|
+
if (body instanceof ArrayBuffer) {
|
|
170
|
+
return `[binary data: ${body.byteLength} bytes]`;
|
|
171
|
+
}
|
|
172
|
+
if (body instanceof ReadableStream) {
|
|
173
|
+
return '[stream]';
|
|
174
|
+
}
|
|
175
|
+
return String(body);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Log detailed debug information when API requests fail.
|
|
179
|
+
* Output destination is determined by AGENTUITY_API_DEBUG or CI environment variables.
|
|
180
|
+
*/
|
|
181
|
+
function logAPIDebug(url, method, requestHeaders, requestBody, response, responseBody) {
|
|
182
|
+
const output = getDebugOutput();
|
|
183
|
+
if (!output) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
const separator = '='.repeat(60);
|
|
187
|
+
const timestamp = new Date().toISOString();
|
|
188
|
+
const lines = [
|
|
189
|
+
'',
|
|
190
|
+
separator,
|
|
191
|
+
`API DEBUG: Request Failed [${timestamp}]`,
|
|
192
|
+
separator,
|
|
193
|
+
'',
|
|
194
|
+
'>>> REQUEST',
|
|
195
|
+
`URL: ${url}`,
|
|
196
|
+
`Method: ${method}`,
|
|
197
|
+
'Headers:',
|
|
198
|
+
formatHeaders(requestHeaders),
|
|
199
|
+
'Body:',
|
|
200
|
+
` ${formatRequestBody(requestBody)}`,
|
|
201
|
+
'',
|
|
202
|
+
'<<< RESPONSE',
|
|
203
|
+
`Status: ${response.status} ${response.statusText}`,
|
|
204
|
+
'Headers:',
|
|
205
|
+
formatHeaders(response.headers),
|
|
206
|
+
'Body:',
|
|
207
|
+
` ${responseBody || '[empty]'}`,
|
|
208
|
+
'',
|
|
209
|
+
separator,
|
|
210
|
+
'',
|
|
211
|
+
];
|
|
212
|
+
const content = lines.join('\n');
|
|
213
|
+
if (output === 'console') {
|
|
214
|
+
console.error(content);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
// Append to file
|
|
218
|
+
try {
|
|
219
|
+
appendFileSync(output, content + '\n');
|
|
220
|
+
}
|
|
221
|
+
catch {
|
|
222
|
+
// If file write fails, fall back to console.error
|
|
223
|
+
console.error(`[API DEBUG] Failed to write to ${output}, falling back to console`);
|
|
224
|
+
console.error(content);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
// =============================================================================
|
|
229
|
+
// Server Fetch Adapter
|
|
230
|
+
// =============================================================================
|
|
231
|
+
class ServerFetchAdapter {
|
|
232
|
+
#config;
|
|
233
|
+
#logger;
|
|
234
|
+
constructor(config, logger) {
|
|
235
|
+
this.#config = config;
|
|
236
|
+
this.#logger = logger;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Build the final URL with query params appended.
|
|
240
|
+
* This is extracted so both invoke() and _invoke() use the same URL.
|
|
241
|
+
*/
|
|
242
|
+
#buildUrl(url) {
|
|
243
|
+
if (this.#config.queryParams && Object.keys(this.#config.queryParams).length > 0) {
|
|
244
|
+
const urlObj = new URL(url);
|
|
245
|
+
for (const [key, value] of Object.entries(this.#config.queryParams)) {
|
|
246
|
+
urlObj.searchParams.set(key, value);
|
|
247
|
+
}
|
|
248
|
+
return urlObj.toString();
|
|
249
|
+
}
|
|
250
|
+
return url;
|
|
251
|
+
}
|
|
252
|
+
async _invoke(url, options) {
|
|
253
|
+
// URL already has query params appended by invoke() or direct caller
|
|
254
|
+
const headers = {
|
|
255
|
+
...options.headers,
|
|
256
|
+
...this.#config.headers,
|
|
257
|
+
};
|
|
258
|
+
if (options.contentType) {
|
|
259
|
+
headers['Content-Type'] = options.contentType;
|
|
260
|
+
}
|
|
261
|
+
else if (typeof options.body === 'string' ||
|
|
262
|
+
options.body instanceof Uint8Array ||
|
|
263
|
+
options.body instanceof ArrayBuffer) {
|
|
264
|
+
headers['Content-Type'] = 'application/octet-stream';
|
|
265
|
+
}
|
|
266
|
+
// Ensure we request JSON responses for proper error handling
|
|
267
|
+
if (!headers['Accept'] && !headers['accept']) {
|
|
268
|
+
headers['Accept'] = 'application/json';
|
|
269
|
+
}
|
|
270
|
+
const method = options.method ?? 'POST';
|
|
271
|
+
this.#logger.trace('sending %s to %s with headers: %s', method, url, redactHeaders(headers));
|
|
272
|
+
const res = await fetch(url, {
|
|
273
|
+
method,
|
|
274
|
+
body: options.body,
|
|
275
|
+
headers,
|
|
276
|
+
signal: options.signal,
|
|
277
|
+
...(options.duplex ? { duplex: options.duplex } : {}),
|
|
278
|
+
});
|
|
279
|
+
if (res.ok) {
|
|
280
|
+
switch (res.status) {
|
|
281
|
+
case 100:
|
|
282
|
+
case 101:
|
|
283
|
+
case 102:
|
|
284
|
+
case 204:
|
|
285
|
+
case 304:
|
|
286
|
+
return {
|
|
287
|
+
ok: true,
|
|
288
|
+
data: undefined,
|
|
289
|
+
response: res,
|
|
290
|
+
};
|
|
291
|
+
default:
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
if (options?.binary) {
|
|
295
|
+
return {
|
|
296
|
+
ok: true,
|
|
297
|
+
data: undefined,
|
|
298
|
+
response: res,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
const data = await fromResponse(res);
|
|
302
|
+
return {
|
|
303
|
+
ok: true,
|
|
304
|
+
data,
|
|
305
|
+
response: res,
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
if (res.status === 404) {
|
|
309
|
+
// Log debug info for 404 errors if debugging is enabled
|
|
310
|
+
if (getDebugOutput()) {
|
|
311
|
+
const responseBody = await res.clone().text();
|
|
312
|
+
logAPIDebug(url, method, headers, options.body, res, responseBody);
|
|
313
|
+
}
|
|
314
|
+
return {
|
|
315
|
+
ok: false,
|
|
316
|
+
response: res,
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
// Clone response to read body for debug logging before toServiceException consumes it
|
|
320
|
+
const responseBody = getDebugOutput() ? await res.clone().text() : '';
|
|
321
|
+
logAPIDebug(url, method, headers, options.body, res, responseBody);
|
|
322
|
+
const err = await toServiceException(method, url, res);
|
|
323
|
+
throw err;
|
|
324
|
+
}
|
|
325
|
+
async invoke(url, options = { method: 'POST' }) {
|
|
326
|
+
// Build final URL with query params BEFORE hooks, so hooks receive the actual URL
|
|
327
|
+
const finalUrl = this.#buildUrl(url);
|
|
328
|
+
if (this.#config.onBefore) {
|
|
329
|
+
let result = undefined;
|
|
330
|
+
let err = undefined;
|
|
331
|
+
await this.#config.onBefore(finalUrl, options, async () => {
|
|
332
|
+
try {
|
|
333
|
+
result = await this._invoke(finalUrl, options);
|
|
334
|
+
if (this.#config.onAfter) {
|
|
335
|
+
await this.#config.onAfter(finalUrl, options, result);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
catch (ex) {
|
|
339
|
+
err = ex;
|
|
340
|
+
if (this.#config.onAfter && err instanceof ServiceException) {
|
|
341
|
+
await this.#config.onAfter(finalUrl, options, {
|
|
342
|
+
ok: false,
|
|
343
|
+
response: new Response(err.message, {
|
|
344
|
+
status: err.statusCode,
|
|
345
|
+
}),
|
|
346
|
+
}, err);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
if (err) {
|
|
351
|
+
throw err;
|
|
352
|
+
}
|
|
353
|
+
return result;
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
return await this._invoke(finalUrl, options);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
// =============================================================================
|
|
361
|
+
// Factory Function
|
|
362
|
+
// =============================================================================
|
|
363
|
+
/**
|
|
364
|
+
* Create a Server Side Fetch Adapter to allow the server to add headers and track outgoing requests.
|
|
365
|
+
*
|
|
366
|
+
* This adapter is used by all Agentuity service clients (KeyValueClient, QueueClient, etc.)
|
|
367
|
+
* to communicate with Agentuity cloud services.
|
|
368
|
+
*
|
|
369
|
+
* @param config - Configuration containing headers and optional hooks
|
|
370
|
+
* @param logger - Logger instance for debug output
|
|
371
|
+
* @returns A FetchAdapter instance
|
|
372
|
+
*
|
|
373
|
+
* @example
|
|
374
|
+
* ```typescript
|
|
375
|
+
* import { createServerFetchAdapter, buildClientHeaders } from '@agentuity/adapter';
|
|
376
|
+
* import { createMinimalLogger } from '@agentuity/core';
|
|
377
|
+
*
|
|
378
|
+
* const headers = buildClientHeaders({ apiKey: 'sk_xxx' });
|
|
379
|
+
* const adapter = createServerFetchAdapter({ headers }, createMinimalLogger());
|
|
380
|
+
*
|
|
381
|
+
* // Use with a service
|
|
382
|
+
* const service = new KeyValueStorageService('https://api.agentuity.sh', adapter);
|
|
383
|
+
* ```
|
|
384
|
+
*/
|
|
385
|
+
export function createServerFetchAdapter(config, logger) {
|
|
386
|
+
return new ServerFetchAdapter(config, logger);
|
|
387
|
+
}
|
|
388
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,i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AO,CAAC,CAAC;oBAC/C,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;wBAC1B,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;oBACvD,CAAC;gBACF,CAAC;gBAAC,OAAO,EAAE,EAAE,CAAC;oBACb,GAAG,GAAG,EAAW,CAAC;oBAClB,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,GAAG,YAAY,gBAAgB,EAAE,CAAC;wBAC7D,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CACzB,QAAQ,EACR,OAAO,EACP;4BACC,EAAE,EAAE,KAAK;4BACT,QAAQ,EAAE,IAAI,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE;gCACnC,MAAM,EAAE,GAAG,CAAC,UAAU;6BACtB,CAAC;yBACoB,EACvB,GAAG,CACH,CAAC;oBACH,CAAC;gBACF,CAAC;YACF,CAAC,CAAC,CAAC;YACH,IAAI,GAAG,EAAE,CAAC;gBACT,MAAM,GAAG,CAAC;YACX,CAAC;YACD,OAAO,MAAqC,CAAC;QAC9C,CAAC;aAAM,CAAC;YACP,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC9C,CAAC;IACF,CAAC;CACD;AAED,gFAAgF;AAChF,mBAAmB;AACnB,gFAAgF;AAEhF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,wBAAwB,CAAC,MAA4B,EAAE,MAAc;IACpF,OAAO,IAAI,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC/C,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agentuity/adapter",
|
|
3
|
+
"version": "3.0.0-alpha.0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"author": "Agentuity employees and contributors",
|
|
6
|
+
"description": "HTTP client adapter for Agentuity service clients",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsgo --build --force",
|
|
22
|
+
"typecheck": "tsgo --noEmit",
|
|
23
|
+
"clean": "rm -rf dist *.tsbuildinfo"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@agentuity/core": "3.0.0-alpha.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/bun": "latest",
|
|
30
|
+
"typescript": "^6.0.2"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "https://github.com/agentuity/sdk.git",
|
|
38
|
+
"directory": "packages/adapter"
|
|
39
|
+
}
|
|
40
|
+
}
|