@agent-os-sdk/client 0.9.25 → 0.9.27
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/generated/openapi.d.ts +82 -0
- package/dist/generated/openapi.d.ts.map +1 -1
- package/dist/modules/runs.d.ts.map +1 -1
- package/dist/modules/templates.d.ts +23 -0
- package/dist/modules/templates.d.ts.map +1 -1
- package/dist/modules/templates.js +7 -0
- package/package.json +2 -2
- package/src/client/AgentOsClient.ts +0 -294
- package/src/client/HttpRequestBuilder.ts +0 -115
- package/src/client/OperationContext.ts +0 -22
- package/src/client/OperationContextProvider.ts +0 -89
- package/src/client/auth.ts +0 -136
- package/src/client/config.ts +0 -100
- package/src/client/helpers.ts +0 -98
- package/src/client/pagination.ts +0 -218
- package/src/client/raw.ts +0 -609
- package/src/client/retry.ts +0 -150
- package/src/client/sanitize.ts +0 -31
- package/src/client/timeout.ts +0 -59
- package/src/errors/factory.ts +0 -140
- package/src/errors/index.ts +0 -365
- package/src/generated/client.ts +0 -32
- package/src/generated/index.ts +0 -2
- package/src/generated/openapi.ts +0 -12302
- package/src/generated/swagger.json +0 -16851
- package/src/index.ts +0 -131
- package/src/modules/a2a.ts +0 -64
- package/src/modules/agents.ts +0 -604
- package/src/modules/apiTokens.ts +0 -101
- package/src/modules/approvals.ts +0 -151
- package/src/modules/audit.ts +0 -145
- package/src/modules/auth.ts +0 -33
- package/src/modules/catalog.ts +0 -241
- package/src/modules/chatwoot.ts +0 -242
- package/src/modules/checkpoints.ts +0 -87
- package/src/modules/contracts.ts +0 -80
- package/src/modules/credentials.ts +0 -216
- package/src/modules/crons.ts +0 -115
- package/src/modules/datasets.ts +0 -142
- package/src/modules/evaluation.ts +0 -269
- package/src/modules/files.ts +0 -208
- package/src/modules/improvements.ts +0 -71
- package/src/modules/info.ts +0 -143
- package/src/modules/me.ts +0 -74
- package/src/modules/members.ts +0 -199
- package/src/modules/memberships.ts +0 -42
- package/src/modules/metaAgent.ts +0 -131
- package/src/modules/metrics.ts +0 -34
- package/src/modules/observability.ts +0 -28
- package/src/modules/playground.ts +0 -68
- package/src/modules/presets.ts +0 -246
- package/src/modules/prompts.ts +0 -147
- package/src/modules/roles.ts +0 -112
- package/src/modules/runs.ts +0 -878
- package/src/modules/store.ts +0 -65
- package/src/modules/templates.ts +0 -40
- package/src/modules/tenants.ts +0 -79
- package/src/modules/threads.ts +0 -343
- package/src/modules/tools.ts +0 -91
- package/src/modules/traces.ts +0 -133
- package/src/modules/triggers.ts +0 -357
- package/src/modules/usage.ts +0 -117
- package/src/modules/vectorStores.ts +0 -257
- package/src/modules/workspaces.ts +0 -216
- package/src/sse/client.ts +0 -179
package/src/client/raw.ts
DELETED
|
@@ -1,609 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent OS SDK - Raw HTTP Client
|
|
3
|
-
*
|
|
4
|
-
* Fully typed HTTP client using openapi-fetch with generated OpenAPI types.
|
|
5
|
-
* All types are automatically inferred from the backend Swagger specification.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import createClient, { type Client } from "openapi-fetch";
|
|
9
|
-
import type { components, paths } from "../generated/openapi.js";
|
|
10
|
-
import { createErrorFromResponse } from "../errors/factory.js";
|
|
11
|
-
import { AgentOsError, NetworkError, TimeoutError } from "../errors/index.js";
|
|
12
|
-
import { httpRequestBuilder, sanitizeValidCorrelationId } from "./HttpRequestBuilder.js";
|
|
13
|
-
import type { OperationContext } from "./OperationContext.js";
|
|
14
|
-
import type { OperationContextProvider } from "./OperationContextProvider.js";
|
|
15
|
-
import { mergeNetworkConfig, type NetworkConfig } from "./config.js";
|
|
16
|
-
import { withRetry } from "./retry.js";
|
|
17
|
-
import { withTimeout } from "./timeout.js";
|
|
18
|
-
|
|
19
|
-
// Re-export types for external use
|
|
20
|
-
export type { components, paths };
|
|
21
|
-
|
|
22
|
-
export type ClientOptions = {
|
|
23
|
-
baseUrl: string;
|
|
24
|
-
headers?: Record<string, string>;
|
|
25
|
-
headerProvider?: () => Promise<Record<string, string>>;
|
|
26
|
-
/** Optional flow context provider (ALS/manual). */
|
|
27
|
-
contextProvider?: OperationContextProvider;
|
|
28
|
-
/** Network behavior (timeouts/retries). Defaults to DEFAULT_NETWORK_CONFIG. */
|
|
29
|
-
network?: Partial<NetworkConfig>;
|
|
30
|
-
/** Hooks for observability (OTEL, Sentry, etc.) */
|
|
31
|
-
hooks?: SDKHooks;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* SDK hooks for external observability tools.
|
|
36
|
-
* These are called during the request lifecycle for instrumentation.
|
|
37
|
-
*/
|
|
38
|
-
export interface SDKHooks {
|
|
39
|
-
/** Called before each request. Return modified request context or void. */
|
|
40
|
-
onRequest?: (context: HookRequestContext) => void | Promise<void>;
|
|
41
|
-
/** Called after each successful response */
|
|
42
|
-
onResponse?: (context: HookResponseContext) => void | Promise<void>;
|
|
43
|
-
/** Called on any error (network, timeout, HTTP error) */
|
|
44
|
-
onError?: (context: HookErrorContext) => void | Promise<void>;
|
|
45
|
-
/** Optional logger bridge used by SDK internal warnings. */
|
|
46
|
-
logger?: { warn?: (message: string) => void };
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface HookRequestContext {
|
|
50
|
-
method: string;
|
|
51
|
-
url: string;
|
|
52
|
-
headers: Record<string, string>;
|
|
53
|
-
body?: unknown;
|
|
54
|
-
requestId?: string;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface HookResponseContext {
|
|
58
|
-
method: string;
|
|
59
|
-
url: string;
|
|
60
|
-
status: number;
|
|
61
|
-
durationMs: number;
|
|
62
|
-
requestId?: string;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export interface HookErrorContext {
|
|
66
|
-
method: string;
|
|
67
|
-
url: string;
|
|
68
|
-
error: Error;
|
|
69
|
-
durationMs: number;
|
|
70
|
-
requestId?: string;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Standard API response wrapper.
|
|
75
|
-
* This matches the pattern used by openapi-fetch.
|
|
76
|
-
*/
|
|
77
|
-
export interface APIResponse<T> {
|
|
78
|
-
data?: T;
|
|
79
|
-
error?: {
|
|
80
|
-
code: string;
|
|
81
|
-
message: string;
|
|
82
|
-
details?: unknown;
|
|
83
|
-
};
|
|
84
|
-
response: Response;
|
|
85
|
-
/** Metadata for observability */
|
|
86
|
-
meta?: {
|
|
87
|
-
/** Request ID from x-request-id header */
|
|
88
|
-
requestId?: string;
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Typed API client using openapi-fetch.
|
|
94
|
-
* All paths and responses are fully typed from OpenAPI spec.
|
|
95
|
-
*/
|
|
96
|
-
export type TypedClient = Client<paths>;
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Creates a typed HTTP client with openapi-fetch.
|
|
100
|
-
* This provides full type inference for all API endpoints.
|
|
101
|
-
*/
|
|
102
|
-
export function createTypedClient(options: ClientOptions): TypedClient {
|
|
103
|
-
return createClient<paths>({
|
|
104
|
-
baseUrl: options.baseUrl,
|
|
105
|
-
headers: options.headers,
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Legacy raw client interface (for backward compatibility).
|
|
111
|
-
* Wraps openapi-fetch to provide the old interface while maintaining types.
|
|
112
|
-
*/
|
|
113
|
-
export function createRawClient(options: ClientOptions) {
|
|
114
|
-
const { baseUrl, headers: defaultHeaders = {}, headerProvider, contextProvider } = options;
|
|
115
|
-
const networkConfig = mergeNetworkConfig(options.network);
|
|
116
|
-
const warn = (message: string): void => {
|
|
117
|
-
const hookWarn = options.hooks?.logger?.warn;
|
|
118
|
-
if (typeof hookWarn === "function") {
|
|
119
|
-
hookWarn(message);
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
if (typeof console !== "undefined" && typeof console.warn === "function") {
|
|
123
|
-
console.warn(message);
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
// Sticky fallback context for clients that don't provide per-operation context.
|
|
127
|
-
const fallbackContext: OperationContext = Object.freeze({
|
|
128
|
-
correlationId: crypto.randomUUID(),
|
|
129
|
-
});
|
|
130
|
-
let warnedStickyFallbackContext = false;
|
|
131
|
-
let warnedInvalidContextCorrelation = false;
|
|
132
|
-
const resolveEffectiveContext = (optsContext?: OperationContext): OperationContext => {
|
|
133
|
-
const providerContext = contextProvider?.get();
|
|
134
|
-
const usingStickyFallback = !optsContext && !providerContext;
|
|
135
|
-
if (usingStickyFallback && !contextProvider && !warnedStickyFallbackContext) {
|
|
136
|
-
warnedStickyFallbackContext = true;
|
|
137
|
-
warn(
|
|
138
|
-
"[AgentOS SDK] Using sticky fallback correlation context per client instance. " +
|
|
139
|
-
"For long-lived server clients, configure contextProvider (ALS/manual) to scope correlation per request."
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const effectiveContext = optsContext ?? providerContext ?? fallbackContext;
|
|
144
|
-
const correlationProvidedByCaller =
|
|
145
|
-
effectiveContext !== fallbackContext
|
|
146
|
-
&& typeof effectiveContext?.correlationId === "string";
|
|
147
|
-
|
|
148
|
-
if (correlationProvidedByCaller) {
|
|
149
|
-
const validCorrelation = sanitizeValidCorrelationId(effectiveContext.correlationId);
|
|
150
|
-
if (!validCorrelation) {
|
|
151
|
-
if (!warnedInvalidContextCorrelation) {
|
|
152
|
-
warnedInvalidContextCorrelation = true;
|
|
153
|
-
warn(
|
|
154
|
-
"[AgentOS SDK] Invalid correlationId in operation context ignored; generated fallback correlation id. " +
|
|
155
|
-
"Provide a valid correlationId (8-128 chars: A-Za-z0-9._:-)."
|
|
156
|
-
);
|
|
157
|
-
}
|
|
158
|
-
// Caller provided invalid flow id: use per-request fallback (not sticky fallback context).
|
|
159
|
-
return {
|
|
160
|
-
...effectiveContext,
|
|
161
|
-
correlationId: crypto.randomUUID(),
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if (validCorrelation !== effectiveContext.correlationId) {
|
|
166
|
-
return {
|
|
167
|
-
...effectiveContext,
|
|
168
|
-
correlationId: validCorrelation,
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
return effectiveContext;
|
|
174
|
-
};
|
|
175
|
-
type ErrorPayload = { code?: string; message?: string; details?: unknown } & Record<string, unknown>;
|
|
176
|
-
type HttpAgentOsError = AgentOsError & {
|
|
177
|
-
response?: Response;
|
|
178
|
-
payload?: ErrorPayload;
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
async function request<T>(
|
|
182
|
-
method: string,
|
|
183
|
-
path: string,
|
|
184
|
-
opts?: {
|
|
185
|
-
params?: { path?: Record<string, string>; query?: Record<string, unknown> };
|
|
186
|
-
body?: unknown;
|
|
187
|
-
headers?: Record<string, string>;
|
|
188
|
-
signal?: AbortSignal;
|
|
189
|
-
/** Set to false to disable retry for this request */
|
|
190
|
-
retry?: boolean;
|
|
191
|
-
/** Override timeout for this request */
|
|
192
|
-
timeoutMs?: number;
|
|
193
|
-
/** Operation context for flow tracing */
|
|
194
|
-
context?: OperationContext;
|
|
195
|
-
/** Idempotency key for POST requests */
|
|
196
|
-
idempotencyKey?: string;
|
|
197
|
-
/** Require correlation ID (throws if missing) */
|
|
198
|
-
requireFlow?: boolean;
|
|
199
|
-
}
|
|
200
|
-
): Promise<APIResponse<T>> {
|
|
201
|
-
// Replace path params
|
|
202
|
-
let url = path;
|
|
203
|
-
if (opts?.params?.path) {
|
|
204
|
-
for (const [key, value] of Object.entries(opts.params.path)) {
|
|
205
|
-
url = url.replace(`{${key}}`, encodeURIComponent(value));
|
|
206
|
-
// Also handle {id} pattern common in our API
|
|
207
|
-
url = url.replace(`{id}`, encodeURIComponent(value));
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
// Build query string
|
|
212
|
-
if (opts?.params?.query) {
|
|
213
|
-
const query = new URLSearchParams();
|
|
214
|
-
for (const [key, value] of Object.entries(opts.params.query)) {
|
|
215
|
-
if (value !== undefined && value !== null) {
|
|
216
|
-
query.append(key, String(value));
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
const queryStr = query.toString();
|
|
220
|
-
if (queryStr) {
|
|
221
|
-
url += `?${queryStr}`;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
const fullUrl = `${baseUrl}${url}`;
|
|
226
|
-
|
|
227
|
-
// Resolve dynamic headers (e.g. auth)
|
|
228
|
-
const dynamicHeaders = headerProvider ? await headerProvider() : {};
|
|
229
|
-
|
|
230
|
-
const headers: Record<string, string> = {
|
|
231
|
-
...defaultHeaders,
|
|
232
|
-
...dynamicHeaders,
|
|
233
|
-
...opts?.headers,
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
if (opts?.body) {
|
|
237
|
-
headers["Content-Type"] = "application/json";
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
const effectiveContext = resolveEffectiveContext(opts?.context);
|
|
241
|
-
|
|
242
|
-
// Build standard headers via HttpRequestBuilder (single source of truth)
|
|
243
|
-
const builderHeaders = httpRequestBuilder.build({
|
|
244
|
-
context: effectiveContext,
|
|
245
|
-
idempotencyKey: opts?.idempotencyKey,
|
|
246
|
-
requireFlow: opts?.requireFlow,
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
// Merge builder headers (X-Request-Id, X-Correlation-Id, X-Idempotency-Key, User-Agent)
|
|
250
|
-
Object.assign(headers, builderHeaders);
|
|
251
|
-
|
|
252
|
-
// Use X-Request-Id from builder as client request ID
|
|
253
|
-
const clientRequestId = headers["X-Request-Id"];
|
|
254
|
-
|
|
255
|
-
// Call onRequest hook
|
|
256
|
-
const startTime = Date.now();
|
|
257
|
-
await options.hooks?.onRequest?.({
|
|
258
|
-
method,
|
|
259
|
-
url: fullUrl,
|
|
260
|
-
headers,
|
|
261
|
-
body: opts?.body,
|
|
262
|
-
requestId: clientRequestId,
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
// Execute the actual fetch
|
|
266
|
-
const doFetch = async (signal?: AbortSignal): Promise<Response> => {
|
|
267
|
-
return fetch(fullUrl, {
|
|
268
|
-
method,
|
|
269
|
-
headers,
|
|
270
|
-
body: opts?.body ? JSON.stringify(opts.body) : undefined,
|
|
271
|
-
signal,
|
|
272
|
-
});
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
let response: Response;
|
|
276
|
-
try {
|
|
277
|
-
const hasIdempotencyKey = Boolean(
|
|
278
|
-
opts?.idempotencyKey ||
|
|
279
|
-
headers["X-Idempotency-Key"] ||
|
|
280
|
-
headers["Idempotency-Key"]
|
|
281
|
-
);
|
|
282
|
-
|
|
283
|
-
const executeAttempt = async (signal?: AbortSignal): Promise<Response> => {
|
|
284
|
-
const attemptResponse = await withTimeout(async (timeoutSignal) => {
|
|
285
|
-
try {
|
|
286
|
-
return await doFetch(timeoutSignal);
|
|
287
|
-
} catch (fetchError) {
|
|
288
|
-
// Preserve AbortError semantics for caller-provided cancellation.
|
|
289
|
-
if (fetchError instanceof Error && fetchError.name === "AbortError") {
|
|
290
|
-
throw fetchError;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
throw new NetworkError(
|
|
294
|
-
fetchError instanceof Error ? fetchError.message : "Network request failed",
|
|
295
|
-
fetchError instanceof Error ? fetchError : undefined
|
|
296
|
-
);
|
|
297
|
-
}
|
|
298
|
-
}, opts?.timeoutMs ?? networkConfig.timeoutMs, signal);
|
|
299
|
-
|
|
300
|
-
if (!attemptResponse.ok) {
|
|
301
|
-
let errorBody: ErrorPayload | undefined;
|
|
302
|
-
try {
|
|
303
|
-
errorBody = await attemptResponse.json() as ErrorPayload;
|
|
304
|
-
} catch {
|
|
305
|
-
// Ignore JSON parse errors and fallback to status text.
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
const typedError = createErrorFromResponse(attemptResponse, errorBody, path) as HttpAgentOsError;
|
|
309
|
-
typedError.response = attemptResponse;
|
|
310
|
-
typedError.payload = errorBody;
|
|
311
|
-
throw typedError;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
return attemptResponse;
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
if (opts?.retry === false) {
|
|
318
|
-
response = await executeAttempt(opts?.signal);
|
|
319
|
-
} else {
|
|
320
|
-
response = await withRetry(
|
|
321
|
-
(signal) => executeAttempt(signal),
|
|
322
|
-
networkConfig.retry,
|
|
323
|
-
{ method, hasIdempotencyKey },
|
|
324
|
-
opts?.signal
|
|
325
|
-
);
|
|
326
|
-
}
|
|
327
|
-
} catch (requestError) {
|
|
328
|
-
const durationMs = Date.now() - startTime;
|
|
329
|
-
const error = requestError instanceof Error ? requestError : new Error(String(requestError));
|
|
330
|
-
const typedError = requestError instanceof AgentOsError ? requestError as HttpAgentOsError : undefined;
|
|
331
|
-
const errorResponse = typedError?.response;
|
|
332
|
-
const requestId = errorResponse?.headers.get("x-request-id")
|
|
333
|
-
?? typedError?.requestId
|
|
334
|
-
?? clientRequestId;
|
|
335
|
-
|
|
336
|
-
// Call onError hook
|
|
337
|
-
await options.hooks?.onError?.({
|
|
338
|
-
method,
|
|
339
|
-
url: fullUrl,
|
|
340
|
-
error,
|
|
341
|
-
durationMs,
|
|
342
|
-
requestId,
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
if (typedError && errorResponse) {
|
|
346
|
-
return {
|
|
347
|
-
error: {
|
|
348
|
-
code: typedError.backendCode || typedError.code,
|
|
349
|
-
message: typedError.message,
|
|
350
|
-
details: typedError.details,
|
|
351
|
-
// Include full payload for validation hints and backend-specific fields.
|
|
352
|
-
...typedError.payload,
|
|
353
|
-
},
|
|
354
|
-
response: errorResponse,
|
|
355
|
-
meta: { requestId },
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
if (error instanceof TimeoutError) {
|
|
360
|
-
return {
|
|
361
|
-
error: {
|
|
362
|
-
code: error.code,
|
|
363
|
-
message: error.message,
|
|
364
|
-
},
|
|
365
|
-
response: new Response(null, { status: 408, statusText: "Request Timeout" }),
|
|
366
|
-
meta: { requestId },
|
|
367
|
-
};
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
// Network/abort/unexpected errors - return as standardized transport error.
|
|
371
|
-
return {
|
|
372
|
-
error: {
|
|
373
|
-
code: "NETWORK_ERROR",
|
|
374
|
-
message: error.message || "Network request failed"
|
|
375
|
-
},
|
|
376
|
-
response: new Response(null, { status: 503, statusText: "Network Error" }),
|
|
377
|
-
meta: { requestId },
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
const durationMs = Date.now() - startTime;
|
|
382
|
-
|
|
383
|
-
// Extract requestId for tracing (prefer server requestId if available)
|
|
384
|
-
const requestId = response.headers.get("x-request-id") ?? clientRequestId;
|
|
385
|
-
|
|
386
|
-
// Call onResponse hook
|
|
387
|
-
await options.hooks?.onResponse?.({
|
|
388
|
-
method,
|
|
389
|
-
url: fullUrl,
|
|
390
|
-
status: response.status,
|
|
391
|
-
durationMs,
|
|
392
|
-
requestId,
|
|
393
|
-
});
|
|
394
|
-
|
|
395
|
-
// Handle no-content responses
|
|
396
|
-
if (response.status === 204) {
|
|
397
|
-
return { data: undefined as T, response, meta: { requestId } };
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
try {
|
|
401
|
-
const data = await response.json();
|
|
402
|
-
return { data: data as T, response, meta: { requestId } };
|
|
403
|
-
} catch {
|
|
404
|
-
return { data: undefined as T, response, meta: { requestId } };
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
return {
|
|
409
|
-
GET: <T>(path: string, opts?: Parameters<typeof request>[2]) =>
|
|
410
|
-
request<T>("GET", path, opts),
|
|
411
|
-
POST: <T>(path: string, opts?: Parameters<typeof request>[2]) =>
|
|
412
|
-
request<T>("POST", path, opts),
|
|
413
|
-
PUT: <T>(path: string, opts?: Parameters<typeof request>[2]) =>
|
|
414
|
-
request<T>("PUT", path, opts),
|
|
415
|
-
PATCH: <T>(path: string, opts?: Parameters<typeof request>[2]) =>
|
|
416
|
-
request<T>("PATCH", path, opts),
|
|
417
|
-
DELETE: <T>(path: string, opts?: Parameters<typeof request>[2]) =>
|
|
418
|
-
request<T>("DELETE", path, opts),
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* Stream GET request - returns raw Response for SSE consumption.
|
|
422
|
-
* Headers are resolved asynchronously (includes Auth + Workspace).
|
|
423
|
-
*/
|
|
424
|
-
streamGet: async (
|
|
425
|
-
path: string,
|
|
426
|
-
opts?: {
|
|
427
|
-
params?: { path?: Record<string, string>; query?: Record<string, unknown> };
|
|
428
|
-
headers?: Record<string, string>;
|
|
429
|
-
context?: OperationContext;
|
|
430
|
-
requireFlow?: boolean;
|
|
431
|
-
signal?: AbortSignal;
|
|
432
|
-
}
|
|
433
|
-
): Promise<Response> => {
|
|
434
|
-
let url = path;
|
|
435
|
-
if (opts?.params?.path) {
|
|
436
|
-
for (const [key, value] of Object.entries(opts.params.path)) {
|
|
437
|
-
url = url.replace(`{${key}}`, encodeURIComponent(value));
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
if (opts?.params?.query) {
|
|
441
|
-
const query = new URLSearchParams();
|
|
442
|
-
for (const [key, value] of Object.entries(opts.params.query)) {
|
|
443
|
-
if (value !== undefined && value !== null) {
|
|
444
|
-
query.append(key, String(value));
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
const queryStr = query.toString();
|
|
448
|
-
if (queryStr) url += `?${queryStr}`;
|
|
449
|
-
}
|
|
450
|
-
const fullUrl = `${baseUrl}${url}`;
|
|
451
|
-
const dynamicHeaders = headerProvider ? await headerProvider() : {};
|
|
452
|
-
const effectiveContext = resolveEffectiveContext(opts?.context);
|
|
453
|
-
const builderHeaders = httpRequestBuilder.build({
|
|
454
|
-
context: effectiveContext,
|
|
455
|
-
requireFlow: opts?.requireFlow,
|
|
456
|
-
});
|
|
457
|
-
const headers: Record<string, string> = {
|
|
458
|
-
...defaultHeaders,
|
|
459
|
-
...dynamicHeaders,
|
|
460
|
-
...builderHeaders,
|
|
461
|
-
Accept: "text/event-stream",
|
|
462
|
-
...opts?.headers,
|
|
463
|
-
};
|
|
464
|
-
return fetch(fullUrl, { method: "GET", headers, signal: opts?.signal });
|
|
465
|
-
},
|
|
466
|
-
|
|
467
|
-
/**
|
|
468
|
-
* Stream POST request - returns raw Response for SSE consumption.
|
|
469
|
-
* Headers are resolved asynchronously (includes Auth + Workspace).
|
|
470
|
-
*/
|
|
471
|
-
streamPost: async (
|
|
472
|
-
path: string,
|
|
473
|
-
opts?: {
|
|
474
|
-
params?: { path?: Record<string, string> };
|
|
475
|
-
body?: unknown;
|
|
476
|
-
headers?: Record<string, string>;
|
|
477
|
-
signal?: AbortSignal;
|
|
478
|
-
context?: OperationContext;
|
|
479
|
-
idempotencyKey?: string;
|
|
480
|
-
requireFlow?: boolean;
|
|
481
|
-
}
|
|
482
|
-
): Promise<Response> => {
|
|
483
|
-
let url = path;
|
|
484
|
-
if (opts?.params?.path) {
|
|
485
|
-
for (const [key, value] of Object.entries(opts.params.path)) {
|
|
486
|
-
url = url.replace(`{${key}}`, encodeURIComponent(value));
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
const fullUrl = `${baseUrl}${url}`;
|
|
490
|
-
const dynamicHeaders = headerProvider ? await headerProvider() : {};
|
|
491
|
-
const effectiveContext = resolveEffectiveContext(opts?.context);
|
|
492
|
-
const builderHeaders = httpRequestBuilder.build({
|
|
493
|
-
context: effectiveContext,
|
|
494
|
-
idempotencyKey: opts?.idempotencyKey,
|
|
495
|
-
requireFlow: opts?.requireFlow,
|
|
496
|
-
});
|
|
497
|
-
const headers: Record<string, string> = {
|
|
498
|
-
...defaultHeaders,
|
|
499
|
-
...dynamicHeaders,
|
|
500
|
-
...builderHeaders,
|
|
501
|
-
"Content-Type": "application/json",
|
|
502
|
-
Accept: "text/event-stream",
|
|
503
|
-
...opts?.headers,
|
|
504
|
-
};
|
|
505
|
-
return fetch(fullUrl, {
|
|
506
|
-
method: "POST",
|
|
507
|
-
headers,
|
|
508
|
-
body: opts?.body ? JSON.stringify(opts.body) : undefined,
|
|
509
|
-
signal: opts?.signal,
|
|
510
|
-
});
|
|
511
|
-
},
|
|
512
|
-
|
|
513
|
-
/** Base URL for constructing full URLs when needed */
|
|
514
|
-
baseUrl,
|
|
515
|
-
};
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
export type RawClient = ReturnType<typeof createRawClient>;
|
|
519
|
-
|
|
520
|
-
// ============================================================================
|
|
521
|
-
// Convenience type exports from OpenAPI schemas
|
|
522
|
-
// ============================================================================
|
|
523
|
-
|
|
524
|
-
// Agent types
|
|
525
|
-
export type Agent = components["schemas"]["AgentExportAgent"];
|
|
526
|
-
export type CreateAgentRequest = components["schemas"]["CreateAgentRequest"];
|
|
527
|
-
export type UpdateAgentRequest = components["schemas"]["UpdateAgentRequest"];
|
|
528
|
-
export type AgentBundle = components["schemas"]["AgentExportBundle"];
|
|
529
|
-
export type AgentBundleItem = components["schemas"]["AgentBundleItem"];
|
|
530
|
-
|
|
531
|
-
// Run types
|
|
532
|
-
export type RunResponse = components["schemas"]["RunResponse"];
|
|
533
|
-
export type RunDetailResponse = components["schemas"]["RunDetailResponse"];
|
|
534
|
-
export type CreateRunRequest = components["schemas"]["CreateRunRequest"];
|
|
535
|
-
export type WaitRunRequest = components["schemas"]["WaitRunRequest"];
|
|
536
|
-
export type WaitRunResponse = components["schemas"]["WaitRunResponse"];
|
|
537
|
-
export type BatchRunRequest = components["schemas"]["BatchRunRequest"];
|
|
538
|
-
export type BatchRunResponse = components["schemas"]["BatchRunResponse"];
|
|
539
|
-
export type ReplayRequest = components["schemas"]["ReplayRequest"];
|
|
540
|
-
export type RunReplayRequest = components["schemas"]["RunReplayRequest"];
|
|
541
|
-
export type RunReplayResponse = components["schemas"]["RunReplayResponse"];
|
|
542
|
-
export type CancelRequest = components["schemas"]["CancelRequest"];
|
|
543
|
-
export type CancelRunResponse = components["schemas"]["CancelRunResponse"];
|
|
544
|
-
|
|
545
|
-
// Thread types
|
|
546
|
-
export type ThreadRequest = components["schemas"]["ThreadRequest"];
|
|
547
|
-
export type ThreadSearchRequest = components["schemas"]["ThreadSearchRequest"];
|
|
548
|
-
export type ThreadCopyRequest = components["schemas"]["ThreadCopyRequest"];
|
|
549
|
-
export type ThreadPruneRequest = components["schemas"]["ThreadPruneRequest"];
|
|
550
|
-
export type AddMessageRequest = components["schemas"]["AddMessageRequest"];
|
|
551
|
-
|
|
552
|
-
// Checkpoint types
|
|
553
|
-
export type CheckpointDetail = components["schemas"]["CheckpointDetail"];
|
|
554
|
-
export type CheckpointNode = components["schemas"]["CheckpointNode"];
|
|
555
|
-
export type CheckpointListResponse = components["schemas"]["CheckpointListResponse"];
|
|
556
|
-
export type CheckpointIndexResponse = components["schemas"]["CheckpointIndexResponse"];
|
|
557
|
-
export type CreateCheckpointRequest = components["schemas"]["CreateCheckpointRequest"];
|
|
558
|
-
|
|
559
|
-
// Credential types
|
|
560
|
-
export type CreateCredentialRequest = components["schemas"]["CreateCredentialRequest"];
|
|
561
|
-
export type UpdateCredentialRequest = components["schemas"]["UpdateCredentialRequest"];
|
|
562
|
-
|
|
563
|
-
// Evaluation types
|
|
564
|
-
export type CreateDatasetRequest = components["schemas"]["CreateDatasetRequest"];
|
|
565
|
-
export type CreateExperimentRequest = components["schemas"]["CreateExperimentRequest"];
|
|
566
|
-
export type ExampleData = components["schemas"]["ExampleData"];
|
|
567
|
-
export type AddExamplesRequest = components["schemas"]["AddExamplesRequest"];
|
|
568
|
-
|
|
569
|
-
// Vector Store types
|
|
570
|
-
export type VectorStoreResponse = components["schemas"]["VectorStoreResponse"];
|
|
571
|
-
export type VectorQueryRequest = components["schemas"]["VectorQueryRequest"];
|
|
572
|
-
export type VectorQueryResponse = components["schemas"]["VectorQueryResponse"];
|
|
573
|
-
export type VectorSearchResult = components["schemas"]["VectorSearchResult"];
|
|
574
|
-
export type VectorStoreFileResponse = components["schemas"]["VectorStoreFileResponse"];
|
|
575
|
-
|
|
576
|
-
// Cron types
|
|
577
|
-
export type CreateCronJobRequest = components["schemas"]["CreateCronJobRequest"];
|
|
578
|
-
export type UpdateCronJobRequest = components["schemas"]["UpdateCronJobRequest"];
|
|
579
|
-
|
|
580
|
-
// Member types
|
|
581
|
-
export type InviteMemberRequest = components["schemas"]["InviteMemberRequest"];
|
|
582
|
-
export type UpdateMemberRequest = components["schemas"]["UpdateMemberRequest"];
|
|
583
|
-
|
|
584
|
-
// Tenant/Workspace types
|
|
585
|
-
export type UpdateTenantRequest = components["schemas"]["UpdateTenantRequest"];
|
|
586
|
-
export type UpdateWorkspaceRequest = components["schemas"]["UpdateWorkspaceRequest"];
|
|
587
|
-
|
|
588
|
-
// Prompt types
|
|
589
|
-
export type CreatePromptRequest = components["schemas"]["CreatePromptRequest"];
|
|
590
|
-
export type CreatePromptVersionRequest = components["schemas"]["CreatePromptVersionRequest"];
|
|
591
|
-
|
|
592
|
-
// File types
|
|
593
|
-
export type CreatePresignedUploadRequest = components["schemas"]["CreatePresignedUploadRequest"];
|
|
594
|
-
export type PresignedUploadResponse = components["schemas"]["PresignedUploadResponse"];
|
|
595
|
-
export type ConfirmUploadRequest = components["schemas"]["ConfirmUploadRequest"];
|
|
596
|
-
|
|
597
|
-
// Trace types
|
|
598
|
-
export type SpanData = components["schemas"]["SpanData"];
|
|
599
|
-
export type BatchIngestRequest = components["schemas"]["BatchIngestRequest"];
|
|
600
|
-
export type AddFeedbackRequest = components["schemas"]["AddFeedbackRequest"];
|
|
601
|
-
|
|
602
|
-
// Trigger types
|
|
603
|
-
export type UpdateTriggerRequest = components["schemas"]["UpdateTriggerRequest"];
|
|
604
|
-
|
|
605
|
-
// Store types
|
|
606
|
-
export type StoreValueRequest = components["schemas"]["StoreValueRequest"];
|
|
607
|
-
|
|
608
|
-
// Problem details (errors)
|
|
609
|
-
export type ProblemDetails = components["schemas"]["ProblemDetails"];
|