@agent-os-sdk/client 0.9.9 → 0.9.11
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/client/AgentOsClient.d.ts +2 -0
- package/dist/client/AgentOsClient.d.ts.map +1 -1
- package/dist/client/AgentOsClient.js +4 -0
- package/dist/client/HttpRequestBuilder.d.ts +1 -0
- package/dist/client/HttpRequestBuilder.d.ts.map +1 -1
- package/dist/client/HttpRequestBuilder.js +6 -2
- package/dist/client/auth.d.ts +4 -0
- package/dist/client/auth.d.ts.map +1 -1
- package/dist/client/raw.d.ts +13 -0
- package/dist/client/raw.d.ts.map +1 -1
- package/dist/client/raw.js +68 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/modules/agents.d.ts +29 -0
- package/dist/modules/agents.d.ts.map +1 -1
- package/dist/modules/agents.js +23 -0
- package/dist/modules/builder.d.ts +0 -4
- package/dist/modules/builder.d.ts.map +1 -1
- package/dist/modules/files.d.ts +34 -13
- package/dist/modules/files.d.ts.map +1 -1
- package/dist/modules/files.js +86 -19
- package/dist/modules/graphs.d.ts +1 -1
- package/dist/modules/graphs.d.ts.map +1 -1
- package/dist/modules/members.d.ts +0 -6
- package/dist/modules/members.d.ts.map +1 -1
- package/dist/modules/members.js +0 -6
- package/dist/modules/observability.d.ts +19 -0
- package/dist/modules/observability.d.ts.map +1 -0
- package/dist/modules/observability.js +14 -0
- package/dist/modules/runs.d.ts +2 -0
- package/dist/modules/runs.d.ts.map +1 -1
- package/dist/modules/runs.js +2 -2
- package/dist/modules/threads.js +2 -2
- package/dist/modules/vectorStores.d.ts +6 -3
- package/dist/modules/vectorStores.d.ts.map +1 -1
- package/dist/modules/vectorStores.js +86 -14
- package/dist/modules/workspaces.d.ts +35 -0
- package/dist/modules/workspaces.d.ts.map +1 -1
- package/dist/modules/workspaces.js +41 -0
- package/package.json +50 -51
- package/src/client/AgentOsClient.ts +4 -0
- package/src/client/HttpRequestBuilder.ts +7 -2
- package/src/client/auth.ts +4 -0
- package/src/client/raw.ts +93 -5
- package/src/index.ts +1 -0
- package/src/modules/agents.ts +52 -0
- package/src/modules/builder.ts +0 -7
- package/src/modules/files.ts +125 -29
- package/src/modules/graphs.ts +1 -1
- package/src/modules/members.ts +0 -7
- package/src/modules/observability.ts +28 -0
- package/src/modules/runs.ts +4 -2
- package/src/modules/threads.ts +2 -2
- package/src/modules/vectorStores.ts +115 -18
- package/src/modules/workspaces.ts +64 -0
- package/dist/modules/dlq.d.ts +0 -81
- package/dist/modules/dlq.d.ts.map +0 -1
- package/dist/modules/dlq.js +0 -66
- package/dist/modules/mcp.d.ts +0 -39
- package/dist/modules/mcp.d.ts.map +0 -1
- package/dist/modules/mcp.js +0 -38
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Workspaces Module - Fully Typed
|
|
3
3
|
*/
|
|
4
|
+
import { parseSSE } from "../sse/client.js";
|
|
4
5
|
export class WorkspacesModule {
|
|
5
6
|
client;
|
|
6
7
|
getTenantId;
|
|
@@ -74,4 +75,44 @@ export class WorkspacesModule {
|
|
|
74
75
|
headers: this.headers(),
|
|
75
76
|
});
|
|
76
77
|
}
|
|
78
|
+
// ======================== FOLLOW (Workspace SSE) ========================
|
|
79
|
+
/**
|
|
80
|
+
* Stream events for a specific workspace via SSE.
|
|
81
|
+
* Server validates ACL: caller must have access to the workspace.
|
|
82
|
+
*
|
|
83
|
+
* @param workspaceId - Workspace to stream events for
|
|
84
|
+
* @param options - AbortSignal for cleanup (MUST be used to avoid leaking connections)
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* const controller = new AbortController();
|
|
89
|
+
* for await (const event of client.workspaces.followEvents(workspaceId, { signal: controller.signal })) {
|
|
90
|
+
* if (event.type === 'run_status_changed') {
|
|
91
|
+
* console.log(`Run ${event.run_id} → ${event.new_status}`);
|
|
92
|
+
* }
|
|
93
|
+
* }
|
|
94
|
+
* // On cleanup:
|
|
95
|
+
* controller.abort();
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
async *followEvents(workspaceId, options) {
|
|
99
|
+
const response = await this.client.streamGet("/v1/api/workspaces/{workspaceId}/events/stream", {
|
|
100
|
+
params: { path: { workspaceId } },
|
|
101
|
+
headers: this.headers(),
|
|
102
|
+
signal: options?.signal,
|
|
103
|
+
});
|
|
104
|
+
try {
|
|
105
|
+
for await (const rawEvent of parseSSE(response)) {
|
|
106
|
+
if (rawEvent.data != null) {
|
|
107
|
+
yield rawEvent.data;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
// Abort is normal cleanup — not an error worth surfacing.
|
|
113
|
+
if (options?.signal?.aborted)
|
|
114
|
+
return;
|
|
115
|
+
throw err;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
77
118
|
}
|
package/package.json
CHANGED
|
@@ -1,53 +1,52 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
]
|
|
2
|
+
"name": "@agent-os-sdk/client",
|
|
3
|
+
"version": "0.9.11",
|
|
4
|
+
"description": "Official TypeScript SDK for Agent OS platform",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"agent-os",
|
|
17
|
+
"sdk",
|
|
18
|
+
"ai",
|
|
19
|
+
"agents",
|
|
20
|
+
"typescript"
|
|
21
|
+
],
|
|
22
|
+
"author": "Agent OS Team",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/yuri12344/agent-os.git"
|
|
27
|
+
},
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"openapi-fetch": "^0.13.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/node": "^25.2.1",
|
|
36
|
+
"openapi-typescript": "^7.4.0",
|
|
37
|
+
"tsx": "^4.19.0",
|
|
38
|
+
"typescript": "^5.5.0",
|
|
39
|
+
"vitest": "^4.0.18"
|
|
40
|
+
},
|
|
41
|
+
"files": [
|
|
42
|
+
"dist",
|
|
43
|
+
"src"
|
|
44
|
+
],
|
|
45
|
+
"scripts": {
|
|
46
|
+
"generate": "tsx scripts/generate.ts",
|
|
47
|
+
"build": "tsc",
|
|
48
|
+
"dev": "tsc --watch",
|
|
49
|
+
"test": "vitest run",
|
|
50
|
+
"typecheck": "tsc --noEmit"
|
|
51
|
+
}
|
|
53
52
|
}
|
|
@@ -66,6 +66,7 @@ import { InfoModule } from "../modules/info.js";
|
|
|
66
66
|
import { MeModule } from "../modules/me.js";
|
|
67
67
|
import { MembershipsModule } from "../modules/memberships.js";
|
|
68
68
|
import { MetricsModule } from "../modules/metrics.js";
|
|
69
|
+
import { ObservabilityModule } from "../modules/observability.js";
|
|
69
70
|
import { PlaygroundModule } from "../modules/playground.js";
|
|
70
71
|
import { PresetsModule } from "../modules/presets.js";
|
|
71
72
|
import { PromptsModule } from "../modules/prompts.js";
|
|
@@ -119,6 +120,7 @@ export class AgentOsClient {
|
|
|
119
120
|
readonly catalog: CatalogModule;
|
|
120
121
|
readonly approvals: ApprovalsModule;
|
|
121
122
|
readonly auth: AuthModule;
|
|
123
|
+
readonly observability: ObservabilityModule;
|
|
122
124
|
|
|
123
125
|
// Convenience aliases
|
|
124
126
|
readonly experiments: {
|
|
@@ -145,6 +147,7 @@ export class AgentOsClient {
|
|
|
145
147
|
this._client = createRawClient({
|
|
146
148
|
baseUrl: options.baseUrl,
|
|
147
149
|
headerProvider: () => this._resolveHeaders(),
|
|
150
|
+
contextProvider: options.contextProvider,
|
|
148
151
|
network: options.network,
|
|
149
152
|
hooks: options.hooks,
|
|
150
153
|
});
|
|
@@ -189,6 +192,7 @@ export class AgentOsClient {
|
|
|
189
192
|
this.catalog = new CatalogModule(this._client);
|
|
190
193
|
this.approvals = new ApprovalsModule(this._client, getHeaders);
|
|
191
194
|
this.auth = new AuthModule(this._client, getHeaders);
|
|
195
|
+
this.observability = new ObservabilityModule(this._client, getHeaders);
|
|
192
196
|
|
|
193
197
|
// Initialize convenience aliases
|
|
194
198
|
this.experiments = {
|
|
@@ -23,6 +23,11 @@ declare const __SDK_VERSION__: string | undefined;
|
|
|
23
23
|
const SDK_VERSION = typeof __SDK_VERSION__ !== "undefined" ? __SDK_VERSION__ : "0.7.12-dev";
|
|
24
24
|
const CORRELATION_ID_PATTERN = /^[A-Za-z0-9._:-]{8,128}$/;
|
|
25
25
|
|
|
26
|
+
export function sanitizeValidCorrelationId(raw?: string): string | null {
|
|
27
|
+
const candidate = sanitizeHeader((raw ?? "").trim());
|
|
28
|
+
return CORRELATION_ID_PATTERN.test(candidate) ? candidate : null;
|
|
29
|
+
}
|
|
30
|
+
|
|
26
31
|
/**
|
|
27
32
|
* Options for building request headers
|
|
28
33
|
*/
|
|
@@ -81,8 +86,8 @@ export class HttpRequestBuilder {
|
|
|
81
86
|
}
|
|
82
87
|
|
|
83
88
|
private resolveCorrelationId(raw?: string): string {
|
|
84
|
-
const candidate =
|
|
85
|
-
if (
|
|
89
|
+
const candidate = sanitizeValidCorrelationId(raw);
|
|
90
|
+
if (candidate) {
|
|
86
91
|
return candidate;
|
|
87
92
|
}
|
|
88
93
|
|
package/src/client/auth.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import type { NetworkConfig } from "./config.js";
|
|
10
10
|
import type { SDKHooks } from "./raw.js";
|
|
11
|
+
import type { OperationContextProvider } from "./OperationContextProvider.js";
|
|
11
12
|
|
|
12
13
|
// ============================================================================
|
|
13
14
|
// Auth Provider Types
|
|
@@ -89,6 +90,9 @@ export type AgentOsClientOptions = {
|
|
|
89
90
|
network?: Partial<NetworkConfig>
|
|
90
91
|
/** Optional request lifecycle hooks for observability */
|
|
91
92
|
hooks?: SDKHooks
|
|
93
|
+
/** Optional flow context provider (ALS/manual) for sticky correlation per operation. */
|
|
94
|
+
/** Recommended for long-lived server clients to avoid process-wide sticky fallback correlation. */
|
|
95
|
+
contextProvider?: OperationContextProvider
|
|
92
96
|
/** Custom headers to add to all requests */
|
|
93
97
|
headers?: Record<string, string>
|
|
94
98
|
}
|
package/src/client/raw.ts
CHANGED
|
@@ -9,8 +9,9 @@ import createClient, { type Client } from "openapi-fetch";
|
|
|
9
9
|
import type { components, paths } from "../generated/openapi.js";
|
|
10
10
|
import { createErrorFromResponse } from "../errors/factory.js";
|
|
11
11
|
import { AgentOsError, NetworkError, TimeoutError } from "../errors/index.js";
|
|
12
|
-
import { httpRequestBuilder } from "./HttpRequestBuilder.js";
|
|
12
|
+
import { httpRequestBuilder, sanitizeValidCorrelationId } from "./HttpRequestBuilder.js";
|
|
13
13
|
import type { OperationContext } from "./OperationContext.js";
|
|
14
|
+
import type { OperationContextProvider } from "./OperationContextProvider.js";
|
|
14
15
|
import { mergeNetworkConfig, type NetworkConfig } from "./config.js";
|
|
15
16
|
import { withRetry } from "./retry.js";
|
|
16
17
|
import { withTimeout } from "./timeout.js";
|
|
@@ -22,6 +23,8 @@ export type ClientOptions = {
|
|
|
22
23
|
baseUrl: string;
|
|
23
24
|
headers?: Record<string, string>;
|
|
24
25
|
headerProvider?: () => Promise<Record<string, string>>;
|
|
26
|
+
/** Optional flow context provider (ALS/manual). */
|
|
27
|
+
contextProvider?: OperationContextProvider;
|
|
25
28
|
/** Network behavior (timeouts/retries). Defaults to DEFAULT_NETWORK_CONFIG. */
|
|
26
29
|
network?: Partial<NetworkConfig>;
|
|
27
30
|
/** Hooks for observability (OTEL, Sentry, etc.) */
|
|
@@ -39,6 +42,8 @@ export interface SDKHooks {
|
|
|
39
42
|
onResponse?: (context: HookResponseContext) => void | Promise<void>;
|
|
40
43
|
/** Called on any error (network, timeout, HTTP error) */
|
|
41
44
|
onError?: (context: HookErrorContext) => void | Promise<void>;
|
|
45
|
+
/** Optional logger bridge used by SDK internal warnings. */
|
|
46
|
+
logger?: { warn?: (message: string) => void };
|
|
42
47
|
}
|
|
43
48
|
|
|
44
49
|
export interface HookRequestContext {
|
|
@@ -106,8 +111,67 @@ export function createTypedClient(options: ClientOptions): TypedClient {
|
|
|
106
111
|
* Wraps openapi-fetch to provide the old interface while maintaining types.
|
|
107
112
|
*/
|
|
108
113
|
export function createRawClient(options: ClientOptions) {
|
|
109
|
-
const { baseUrl, headers: defaultHeaders = {}, headerProvider } = options;
|
|
114
|
+
const { baseUrl, headers: defaultHeaders = {}, headerProvider, contextProvider } = options;
|
|
110
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
|
+
};
|
|
111
175
|
type ErrorPayload = { code?: string; message?: string; details?: unknown } & Record<string, unknown>;
|
|
112
176
|
type HttpAgentOsError = AgentOsError & {
|
|
113
177
|
response?: Response;
|
|
@@ -173,9 +237,11 @@ export function createRawClient(options: ClientOptions) {
|
|
|
173
237
|
headers["Content-Type"] = "application/json";
|
|
174
238
|
}
|
|
175
239
|
|
|
240
|
+
const effectiveContext = resolveEffectiveContext(opts?.context);
|
|
241
|
+
|
|
176
242
|
// Build standard headers via HttpRequestBuilder (single source of truth)
|
|
177
243
|
const builderHeaders = httpRequestBuilder.build({
|
|
178
|
-
context:
|
|
244
|
+
context: effectiveContext,
|
|
179
245
|
idempotencyKey: opts?.idempotencyKey,
|
|
180
246
|
requireFlow: opts?.requireFlow,
|
|
181
247
|
});
|
|
@@ -357,7 +423,13 @@ export function createRawClient(options: ClientOptions) {
|
|
|
357
423
|
*/
|
|
358
424
|
streamGet: async (
|
|
359
425
|
path: string,
|
|
360
|
-
opts?: {
|
|
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
|
+
}
|
|
361
433
|
): Promise<Response> => {
|
|
362
434
|
let url = path;
|
|
363
435
|
if (opts?.params?.path) {
|
|
@@ -377,13 +449,19 @@ export function createRawClient(options: ClientOptions) {
|
|
|
377
449
|
}
|
|
378
450
|
const fullUrl = `${baseUrl}${url}`;
|
|
379
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
|
+
});
|
|
380
457
|
const headers: Record<string, string> = {
|
|
381
458
|
...defaultHeaders,
|
|
382
459
|
...dynamicHeaders,
|
|
460
|
+
...builderHeaders,
|
|
383
461
|
Accept: "text/event-stream",
|
|
384
462
|
...opts?.headers,
|
|
385
463
|
};
|
|
386
|
-
return fetch(fullUrl, { method: "GET", headers });
|
|
464
|
+
return fetch(fullUrl, { method: "GET", headers, signal: opts?.signal });
|
|
387
465
|
},
|
|
388
466
|
|
|
389
467
|
/**
|
|
@@ -397,6 +475,9 @@ export function createRawClient(options: ClientOptions) {
|
|
|
397
475
|
body?: unknown;
|
|
398
476
|
headers?: Record<string, string>;
|
|
399
477
|
signal?: AbortSignal;
|
|
478
|
+
context?: OperationContext;
|
|
479
|
+
idempotencyKey?: string;
|
|
480
|
+
requireFlow?: boolean;
|
|
400
481
|
}
|
|
401
482
|
): Promise<Response> => {
|
|
402
483
|
let url = path;
|
|
@@ -407,9 +488,16 @@ export function createRawClient(options: ClientOptions) {
|
|
|
407
488
|
}
|
|
408
489
|
const fullUrl = `${baseUrl}${url}`;
|
|
409
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
|
+
});
|
|
410
497
|
const headers: Record<string, string> = {
|
|
411
498
|
...defaultHeaders,
|
|
412
499
|
...dynamicHeaders,
|
|
500
|
+
...builderHeaders,
|
|
413
501
|
"Content-Type": "application/json",
|
|
414
502
|
Accept: "text/event-stream",
|
|
415
503
|
...opts?.headers,
|
package/src/index.ts
CHANGED
|
@@ -101,6 +101,7 @@ export * from "./modules/credentials.js";
|
|
|
101
101
|
export * from "./modules/datasets.js";
|
|
102
102
|
export * from "./modules/me.js";
|
|
103
103
|
export * from "./modules/members.js";
|
|
104
|
+
export * from "./modules/observability.js";
|
|
104
105
|
export * from "./modules/presets.js";
|
|
105
106
|
export * from "./modules/prompts.js";
|
|
106
107
|
export * from "./modules/roles.js";
|
package/src/modules/agents.ts
CHANGED
|
@@ -53,6 +53,21 @@ export interface GraphValidationResponse {
|
|
|
53
53
|
warnings?: string[];
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
export interface UpsertAgentCredentialBindingRequest {
|
|
57
|
+
credential_id: string;
|
|
58
|
+
alias: string;
|
|
59
|
+
priority?: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface AgentCredentialBindingUpsertResponse {
|
|
63
|
+
id: string;
|
|
64
|
+
updated: boolean;
|
|
65
|
+
agent_id: string;
|
|
66
|
+
credential_id: string;
|
|
67
|
+
alias: string;
|
|
68
|
+
priority: number;
|
|
69
|
+
}
|
|
70
|
+
|
|
56
71
|
export type AgentListResponse = PaginatedResponse<Agent>;
|
|
57
72
|
|
|
58
73
|
export class AgentsModule {
|
|
@@ -259,6 +274,34 @@ export class AgentsModule {
|
|
|
259
274
|
});
|
|
260
275
|
}
|
|
261
276
|
|
|
277
|
+
/**
|
|
278
|
+
* Get Mermaid diagram for a specific bundle graph.
|
|
279
|
+
*/
|
|
280
|
+
async getBundleMermaid(agentId: string, bundleId: string): Promise<APIResponse<BundleMermaidResponse>> {
|
|
281
|
+
return this.client.GET<BundleMermaidResponse>("/v1/api/agents/{agentId}/bundles/{bundleId}/graph/mermaid", {
|
|
282
|
+
params: { path: { agentId, bundleId } },
|
|
283
|
+
headers: this.headers(),
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Creates or updates an agent credential binding by alias.
|
|
289
|
+
*/
|
|
290
|
+
async upsertCredentialBinding(
|
|
291
|
+
agentId: string,
|
|
292
|
+
body: UpsertAgentCredentialBindingRequest
|
|
293
|
+
): Promise<APIResponse<AgentCredentialBindingUpsertResponse>> {
|
|
294
|
+
return this.client.POST<AgentCredentialBindingUpsertResponse>("/v1/api/agents/{id}/credential-bindings", {
|
|
295
|
+
params: { path: { id: agentId } },
|
|
296
|
+
body: {
|
|
297
|
+
credential_id: body.credential_id,
|
|
298
|
+
alias: body.alias,
|
|
299
|
+
priority: body.priority ?? 0,
|
|
300
|
+
},
|
|
301
|
+
headers: this.headers(),
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
|
|
262
305
|
}
|
|
263
306
|
|
|
264
307
|
// Bundle manifest response type
|
|
@@ -274,3 +317,12 @@ export interface BundleManifestResponse {
|
|
|
274
317
|
created_at?: string;
|
|
275
318
|
graph_spec?: Record<string, unknown>;
|
|
276
319
|
}
|
|
320
|
+
|
|
321
|
+
export interface BundleMermaidResponse {
|
|
322
|
+
bundle_id: string;
|
|
323
|
+
agent_id: string;
|
|
324
|
+
mermaid: string;
|
|
325
|
+
format?: string;
|
|
326
|
+
node_count?: number;
|
|
327
|
+
edge_count?: number;
|
|
328
|
+
}
|
package/src/modules/builder.ts
CHANGED
|
@@ -118,11 +118,6 @@ export type HintModel = {
|
|
|
118
118
|
};
|
|
119
119
|
|
|
120
120
|
export type GraphUpdateAction = {
|
|
121
|
-
// Legacy support
|
|
122
|
-
action: string;
|
|
123
|
-
// ... legacy fields omitted for brevity, keeping strict new protocol
|
|
124
|
-
} | {
|
|
125
|
-
// New protocol (WAVE-3)
|
|
126
121
|
graph_spec: Record<string, unknown>;
|
|
127
122
|
hints?: HintModel[];
|
|
128
123
|
has_errors?: boolean;
|
|
@@ -166,8 +161,6 @@ export type PatchOp = {
|
|
|
166
161
|
label?: string;
|
|
167
162
|
data?: Record<string, unknown>;
|
|
168
163
|
set?: Record<string, unknown>;
|
|
169
|
-
source?: string;
|
|
170
|
-
target?: string;
|
|
171
164
|
from?: string;
|
|
172
165
|
to?: string;
|
|
173
166
|
entrypoint?: string;
|