@agent-os-sdk/client 0.3.15 → 0.4.1

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.
Files changed (66) hide show
  1. package/dist/client/config.d.ts +49 -0
  2. package/dist/client/config.d.ts.map +1 -0
  3. package/dist/client/config.js +62 -0
  4. package/dist/client/pagination.d.ts +105 -0
  5. package/dist/client/pagination.d.ts.map +1 -0
  6. package/dist/client/pagination.js +117 -0
  7. package/dist/client/raw.d.ts +67 -2
  8. package/dist/client/raw.d.ts.map +1 -1
  9. package/dist/client/raw.js +78 -17
  10. package/dist/client/retry.d.ts +37 -0
  11. package/dist/client/retry.d.ts.map +1 -0
  12. package/dist/client/retry.js +108 -0
  13. package/dist/client/timeout.d.ts +26 -0
  14. package/dist/client/timeout.d.ts.map +1 -0
  15. package/dist/client/timeout.js +51 -0
  16. package/dist/errors/factory.d.ts +20 -0
  17. package/dist/errors/factory.d.ts.map +1 -0
  18. package/dist/errors/factory.js +97 -0
  19. package/dist/errors/index.d.ts +210 -0
  20. package/dist/errors/index.d.ts.map +1 -0
  21. package/dist/errors/index.js +283 -0
  22. package/dist/index.d.ts +37 -29
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +48 -22
  25. package/dist/modules/audit.d.ts +27 -4
  26. package/dist/modules/audit.d.ts.map +1 -1
  27. package/dist/modules/audit.js +58 -2
  28. package/dist/modules/builder.d.ts +6 -0
  29. package/dist/modules/builder.d.ts.map +1 -1
  30. package/dist/modules/checkpoints.d.ts +1 -1
  31. package/dist/modules/checkpoints.d.ts.map +1 -1
  32. package/dist/modules/info.d.ts +49 -0
  33. package/dist/modules/info.d.ts.map +1 -1
  34. package/dist/modules/info.js +66 -0
  35. package/dist/modules/members.d.ts +50 -2
  36. package/dist/modules/members.d.ts.map +1 -1
  37. package/dist/modules/members.js +61 -0
  38. package/dist/modules/runs.d.ts +103 -0
  39. package/dist/modules/runs.d.ts.map +1 -1
  40. package/dist/modules/runs.js +258 -0
  41. package/dist/modules/tenants.d.ts +4 -1
  42. package/dist/modules/tenants.d.ts.map +1 -1
  43. package/dist/modules/tenants.js +3 -0
  44. package/dist/modules/threads.d.ts +24 -0
  45. package/dist/modules/threads.d.ts.map +1 -1
  46. package/dist/modules/threads.js +48 -1
  47. package/dist/sse/client.d.ts.map +1 -1
  48. package/dist/sse/client.js +17 -5
  49. package/package.json +49 -50
  50. package/src/client/config.ts +100 -0
  51. package/src/client/pagination.ts +218 -0
  52. package/src/client/raw.ts +141 -20
  53. package/src/client/retry.ts +150 -0
  54. package/src/client/timeout.ts +59 -0
  55. package/src/errors/factory.ts +135 -0
  56. package/src/errors/index.ts +365 -0
  57. package/src/index.ts +97 -76
  58. package/src/modules/audit.ts +77 -6
  59. package/src/modules/builder.ts +7 -0
  60. package/src/modules/checkpoints.ts +1 -1
  61. package/src/modules/info.ts +108 -0
  62. package/src/modules/members.ts +80 -2
  63. package/src/modules/runs.ts +333 -0
  64. package/src/modules/tenants.ts +5 -2
  65. package/src/modules/threads.ts +57 -1
  66. package/src/sse/client.ts +21 -5
package/src/index.ts CHANGED
@@ -42,135 +42,156 @@ export { AgentOsClient, type AgentOsClientOptions, type AuthProvider } from "./c
42
42
 
43
43
  // Auth Provider Types
44
44
  export {
45
- type ApiTokenAuth,
46
- type JwtAuth,
47
- isApiTokenAuth,
48
- isJwtAuth,
49
- isBrowser,
50
- isApiToken,
51
- isJwtToken,
45
+ isApiToken, isApiTokenAuth, isBrowser, isJwtAuth, isJwtToken, type ApiTokenAuth,
46
+ type JwtAuth
52
47
  } from "./client/auth.js";
53
48
 
54
49
  // ============================================================================
55
50
  // Helpers & Utilities
56
51
  // ============================================================================
57
52
  export {
58
- unwrap,
59
- toResult,
60
- SDKError,
61
- type PaginationParams,
62
- type PaginatedResponse,
63
- type Result,
64
- type Unwrapped,
53
+ SDKError, toResult, unwrap, type PaginatedResponse, type PaginationParams, type Result,
54
+ type Unwrapped
65
55
  } from "./client/helpers.js";
66
56
 
57
+ // ============================================================================
58
+ // Typed Errors (Enterprise)
59
+ // ============================================================================
60
+ export {
61
+ // Base class
62
+ AgentOsError, ConflictError, ForbiddenError, NetworkError, NotFoundError, RateLimitError,
63
+ ServerError, TimeoutError,
64
+ // Error classes
65
+ UnauthorizedError, ValidationError,
66
+ // Type guards
67
+ isAgentOsError, isAuthError,
68
+ isClientError, isRetryableError, isServerError, type ErrorOptions,
69
+ // Field errors
70
+ type FieldError
71
+ } from "./errors/index.js";
72
+
73
+ export { createErrorFromResponse } from "./errors/factory.js";
74
+
75
+ // ============================================================================
76
+ // Network Configuration
77
+ // ============================================================================
78
+ export {
79
+ BACKGROUND_NETWORK_CONFIG, DEFAULT_NETWORK_CONFIG,
80
+ INTERACTIVE_NETWORK_CONFIG, mergeNetworkConfig, type NetworkConfig, type RetryConfig
81
+ } from "./client/config.js";
82
+
83
+ // ============================================================================
84
+ // Retry & Timeout Utilities
85
+ // ============================================================================
86
+ export { sleep, withRetry, type RetryContext } from "./client/retry.js";
87
+ export { createTimeoutController, withTimeout } from "./client/timeout.js";
88
+
89
+ // ============================================================================
90
+ // Pagination Utilities
91
+ // ============================================================================
92
+ export {
93
+ collectAll,
94
+ getFirst, paginate, type CursorPaginatedResponse, type CursorParams, type OffsetPaginatedResponse, type OffsetParams, type PaginateOptions
95
+ } from "./client/pagination.js";
96
+
97
+
67
98
  // ============================================================================
68
99
  // Raw Client & Core Types
69
100
  // ============================================================================
70
101
  export {
71
102
  createRawClient,
72
- createTypedClient,
73
- type RawClient,
74
- type TypedClient,
75
- type ClientOptions,
76
- type APIResponse,
103
+ createTypedClient, type APIResponse, type ClientOptions, type HookErrorContext, type HookRequestContext,
104
+ type HookResponseContext, type RawClient,
105
+ // SDK Hooks for observability (OTEL, Sentry, etc.)
106
+ type SDKHooks, type TypedClient
77
107
  } from "./client/raw.js";
78
108
 
79
109
  // Export OpenAPI types
80
- export type { paths, components } from "./client/raw.js";
110
+ export type { components, paths } from "./client/raw.js";
81
111
 
82
112
  // ============================================================================
83
113
  // Module Classes
84
114
  // ============================================================================
85
115
 
86
116
  // Core modules
87
- export { AgentsModule, type Agent, type AgentVersion, type AgentListResponse, type AgentGraphResponse } from "./modules/agents.js";
88
- export { RunsModule, type Run, type RunStatus, type RunEvent, type RunListResponse, type RunEventsResponse, type CreateRunResponse, type RunEventsPollResponse, type RunEventDto } from "./modules/runs.js";
89
- export { ThreadsModule, type Thread, type ThreadState, type ThreadMessage, type ThreadRun, type ThreadListResponse, type ThreadMessagesResponse } from "./modules/threads.js";
90
- export { ToolsModule, type Tool, type ToolListResponse } from "./modules/tools.js";
91
- export { KnowledgeModule, type KnowledgeDataset, type KnowledgeSearchResponse } from "./modules/knowledge.js";
92
- export { TriggersModule, type Trigger, type TriggerListResponse } from "./modules/triggers.js";
93
- export { CredentialsModule, type Credential, type CredentialListResponse, type CredentialType } from "./modules/credentials.js";
117
+ export { AgentsModule, type Agent, type AgentGraphResponse, type AgentListResponse, type AgentVersion } from "./modules/agents.js";
94
118
  export { BuilderModule, type BuilderChatRequest, type BuilderChatResponse, type BuilderStreamEvent, type GraphUpdateAction } from "./modules/builder.js";
95
- export { MembersModule, type Member, type MemberListResponse } from "./modules/members.js";
119
+ export { CredentialsModule, type Credential, type CredentialListResponse, type CredentialType } from "./modules/credentials.js";
120
+ export { KnowledgeModule, type KnowledgeDataset, type KnowledgeSearchResponse } from "./modules/knowledge.js";
121
+ export { MembersModule, type Member, type MemberListResponse, type Role } from "./modules/members.js";
122
+ export { RunsModule, type CreateRunResponse, type FollowEvent, type FollowOptions, type Run, type RunEvent, type RunEventDto, type RunEventsPollResponse, type RunEventsResponse, type RunListResponse, type RunStatus } from "./modules/runs.js";
96
123
  export { TenantsModule, type Tenant } from "./modules/tenants.js";
124
+ export { ThreadsModule, type Thread, type ThreadListResponse, type ThreadMessage, type ThreadMessagesResponse, type ThreadRun, type ThreadState } from "./modules/threads.js";
125
+ export { ToolsModule, type Tool, type ToolListResponse } from "./modules/tools.js";
126
+ export { TriggersModule, type Trigger, type TriggerListResponse } from "./modules/triggers.js";
97
127
  export { WorkspacesModule, type Workspace, type WorkspaceListResponse } from "./modules/workspaces.js";
98
128
 
99
129
  // Platform modules
100
- export { PromptsModule, type Prompt, type PromptVersion, type PromptListResponse } from "./modules/prompts.js";
101
- export { TracesModule, type Trace, type Span, type TraceListResponse, type SpanData, type FeedbackRequest } from "./modules/traces.js";
102
- export { FilesModule, type StoredFile, type FileListResponse, type PresignedUpload } from "./modules/files.js";
103
- export { VectorStoresModule, type VectorStore, type VectorStoreListResponse, type VectorQueryResult } from "./modules/vectorStores.js";
104
- export { EvaluationModule, type EvalDataset, type Experiment, type ExampleData } from "./modules/evaluation.js";
130
+ export { A2aModule, type A2aAgentCard, type JsonRpcRequest, type JsonRpcResponse } from "./modules/a2a.js";
131
+ export { AuditModule, type AuditListResponse, type AuditLogEntry } from "./modules/audit.js";
132
+ export { CatalogModule, type CatalogVersions, type NodeCatalogResponse, type NodeDefinition, type ToolCatalogResponse, type ToolDefinition, type TriggerCatalogResponse, type TriggerTemplate } from "./modules/catalog.js";
105
133
  export { CheckpointsModule, type Checkpoint, type CheckpointsResponse } from "./modules/checkpoints.js";
106
- export { PlaygroundModule, type PlaygroundSession } from "./modules/playground.js";
107
134
  export { CronsModule, type CronJob, type CronJobListResponse } from "./modules/crons.js";
108
- export { DlqModule, type DlqMessage, type DlqListResponse } from "./modules/dlq.js";
109
- export { StoreModule, type StoreValue } from "./modules/store.js";
110
- export { AuditModule, type AuditLogEntry, type AuditListResponse } from "./modules/audit.js";
111
- export { UsageModule, type UsageResponse, type UsageQuota } from "./modules/usage.js";
135
+ export { DlqModule, type DlqListResponse, type DlqMessage } from "./modules/dlq.js";
136
+ export { EvaluationModule, type EvalDataset, type ExampleData, type Experiment } from "./modules/evaluation.js";
137
+ export { FilesModule, type FileListResponse, type PresignedUpload, type StoredFile } from "./modules/files.js";
138
+ export { GraphsModule, type GraphIntrospectionResult, type GraphValidationResult } from "./modules/graphs.js";
139
+ export { InfoModule, type ServerCapabilities, type ServerInfo } from "./modules/info.js";
112
140
  export { McpModule, type McpServer } from "./modules/mcp.js";
113
- export { A2aModule, type JsonRpcRequest, type JsonRpcResponse, type A2aAgentCard } from "./modules/a2a.js";
114
141
  export { MeModule, type MeResponse } from "./modules/me.js";
115
- export { InfoModule, type ServerInfo } from "./modules/info.js";
116
142
  export { MetricsModule, type MetricsResponse } from "./modules/metrics.js";
117
- export { GraphsModule, type GraphValidationResult, type GraphIntrospectionResult } from "./modules/graphs.js";
118
- export { CatalogModule, type CatalogVersions, type NodeCatalogResponse, type ToolCatalogResponse, type TriggerCatalogResponse, type NodeDefinition, type ToolDefinition, type TriggerTemplate } from "./modules/catalog.js";
143
+ export { PlaygroundModule, type PlaygroundSession } from "./modules/playground.js";
144
+ export { PromptsModule, type Prompt, type PromptListResponse, type PromptVersion } from "./modules/prompts.js";
145
+ export { StoreModule, type StoreValue } from "./modules/store.js";
146
+ export { TracesModule, type FeedbackRequest, type Span, type SpanData, type Trace, type TraceListResponse } from "./modules/traces.js";
147
+ export { UsageModule, type UsageQuota, type UsageResponse } from "./modules/usage.js";
148
+ export { VectorStoresModule, type VectorQueryResult, type VectorStore, type VectorStoreListResponse } from "./modules/vectorStores.js";
119
149
 
120
150
  // Approvals is real (has backend implementation)
121
- export { ApprovalsModule, type Approval, type ApprovalStatus, type ApprovalDecision, type ApprovalListResponse, type ApprovalStatusResponse } from "./modules/approvals.js";
151
+ export { ApprovalsModule, type Approval, type ApprovalDecision, type ApprovalListResponse, type ApprovalStatus, type ApprovalStatusResponse } from "./modules/approvals.js";
152
+
153
+ export { ApiTokensModule, type ApiToken, type ApiTokenSecret, type CreateTokenRequest, type RotateTokenResponse } from "./modules/apiTokens.js";
154
+ export { MembershipsModule, type EnsureMembershipRequest, type MembershipResponse } from "./modules/memberships.js";
122
155
 
123
156
  // ============================================================================
124
157
  // SSE Streaming
125
158
  // ============================================================================
126
- export { streamSSE, parseSSE, type SSEEvent, type SSEOptions, type RunStreamEvent, type RunSSEEvent, type RunEventDto as SSERunEventDto } from "./sse/client.js";
159
+ export { parseSSE, streamSSE, type RunSSEEvent, type RunStreamEvent, type SSEEvent, type SSEOptions, type RunEventDto as SSERunEventDto } from "./sse/client.js";
127
160
 
128
161
  // ============================================================================
129
162
  // Convenience Type Re-exports
130
163
  // ============================================================================
131
164
  export type {
165
+ AddMessageRequest, AgentBundle,
132
166
  // Agent types
133
- Agent as AgentSchema,
134
- CreateAgentRequest,
135
- UpdateAgentRequest,
136
- AgentBundle,
137
- CreateAgentVersionRequest,
138
- // Run types
139
- RunResponse,
140
- RunDetailResponse,
141
- WaitRunResponse,
142
- BatchRunResponse,
167
+ Agent as AgentSchema, BatchRunResponse,
143
168
  CancelRunResponse,
144
- ReplayRequest,
145
- // Thread types
146
- ThreadRequest,
147
- ThreadSearchRequest,
148
- AddMessageRequest,
149
169
  // Checkpoint types
150
170
  CheckpointDetail,
151
- CheckpointListResponse,
171
+ CheckpointListResponse, CreateAgentRequest, CreateAgentVersionRequest,
152
172
  // Credential types
153
173
  CreateCredentialRequest,
154
- UpdateCredentialRequest,
155
174
  // Cron types
156
175
  CreateCronJobRequest,
157
- UpdateCronJobRequest,
158
- // Member types
159
- InviteMemberRequest,
160
- UpdateMemberRequest,
161
- // Prompt types
162
- CreatePromptRequest,
163
- CreatePromptVersionRequest,
164
- // File types
165
- CreatePresignedUploadRequest,
166
- PresignedUploadResponse,
167
- // Vector Store types
168
- VectorStoreResponse,
169
- VectorQueryRequest,
170
- VectorQueryResponse,
171
176
  // Evaluation types
172
177
  CreateDatasetRequest,
173
178
  CreateExperimentRequest,
179
+ // File types
180
+ CreatePresignedUploadRequest,
181
+ // Prompt types
182
+ CreatePromptRequest,
183
+ CreatePromptVersionRequest,
184
+ // Member types
185
+ InviteMemberRequest, PresignedUploadResponse,
174
186
  // Error types
175
- ProblemDetails,
187
+ ProblemDetails, ReplayRequest, RunDetailResponse,
188
+ // Run types
189
+ RunResponse,
190
+ // Thread types
191
+ ThreadRequest,
192
+ ThreadSearchRequest, UpdateAgentRequest, UpdateCredentialRequest, UpdateCronJobRequest, UpdateMemberRequest, VectorQueryRequest,
193
+ VectorQueryResponse,
194
+ // Vector Store types
195
+ VectorStoreResponse, WaitRunResponse
176
196
  } from "./client/raw.js";
197
+
@@ -37,11 +37,21 @@ export class AuditModule {
37
37
  workspace_id?: string;
38
38
  from?: string;
39
39
  to?: string;
40
- skip?: number;
41
- take?: number;
40
+ limit?: number;
41
+ offset?: number;
42
42
  }): Promise<APIResponse<AuditListResponse>> {
43
+ const queryParams: any = { ...params };
44
+ if (params?.limit !== undefined) {
45
+ queryParams.take = params.limit;
46
+ delete queryParams.limit;
47
+ }
48
+ if (params?.offset !== undefined) {
49
+ queryParams.skip = params.offset;
50
+ delete queryParams.offset;
51
+ }
52
+
43
53
  return this.client.GET<AuditListResponse>("/v1/api/audit", {
44
- params: { query: params },
54
+ params: { query: queryParams },
45
55
  headers: this.headers(),
46
56
  });
47
57
  }
@@ -63,12 +73,73 @@ export class AuditModule {
63
73
  query?: string;
64
74
  from?: string;
65
75
  to?: string;
66
- skip?: number;
67
- take?: number;
76
+ limit?: number;
77
+ offset?: number;
68
78
  }): Promise<APIResponse<AuditListResponse>> {
79
+ const queryParams: any = { ...params };
80
+ if (params?.limit !== undefined) {
81
+ queryParams.take = params.limit;
82
+ delete queryParams.limit;
83
+ }
84
+ if (params?.offset !== undefined) {
85
+ queryParams.skip = params.offset;
86
+ delete queryParams.offset;
87
+ }
88
+
69
89
  return this.client.GET<AuditListResponse>("/v1/api/audit/search", {
70
- params: { query: params },
90
+ params: { query: queryParams },
71
91
  headers: this.headers(),
72
92
  });
73
93
  }
94
+
95
+ /**
96
+ * Iterate through all audit logs with automatic pagination.
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * // Get all audit logs for a specific action
101
+ * for await (const entry of client.audit.iterate({ action: "agent.created" })) {
102
+ * console.log(entry.actor, entry.action);
103
+ * }
104
+ * ```
105
+ */
106
+ async *iterate(
107
+ filters?: {
108
+ actor?: string;
109
+ action?: string;
110
+ resource?: string;
111
+ workspace_id?: string;
112
+ from?: string;
113
+ to?: string;
114
+ },
115
+ options?: { pageSize?: number; maxItems?: number; signal?: AbortSignal }
116
+ ): AsyncGenerator<AuditLogEntry, void, unknown> {
117
+ const pageSize = options?.pageSize ?? 100;
118
+ const maxItems = options?.maxItems ?? Infinity;
119
+ let offset = 0;
120
+ let yielded = 0;
121
+ let hasMore = true;
122
+
123
+ while (hasMore && yielded < maxItems) {
124
+ if (options?.signal?.aborted) return;
125
+
126
+ const response = await this.list({
127
+ ...filters,
128
+ limit: Math.min(pageSize, maxItems - yielded),
129
+ offset,
130
+ });
131
+
132
+ if (response.error) throw response.error;
133
+ const data = response.data!;
134
+
135
+ for (const entry of data.items) {
136
+ if (yielded >= maxItems) return;
137
+ yield entry;
138
+ yielded++;
139
+ }
140
+
141
+ offset += data.items.length;
142
+ hasMore = offset < data.total && data.items.length > 0;
143
+ }
144
+ }
74
145
  }
@@ -36,10 +36,17 @@ export type CatalogVersions = {
36
36
  triggers: string;
37
37
  };
38
38
 
39
+ export type ChatHistoryMessage = {
40
+ role: 'user' | 'assistant';
41
+ content: string;
42
+ };
43
+
39
44
  export type BuilderChatRequest = {
40
45
  message: string;
41
46
  current_graph_spec?: Record<string, unknown>;
42
47
  thread_id?: string;
48
+ /** Previous conversation history for context */
49
+ history?: ChatHistoryMessage[];
43
50
  /** Catalog versions to use for validation */
44
51
  catalog_versions?: CatalogVersions;
45
52
  /** Combined hash of all catalogs for integrity */
@@ -66,7 +66,7 @@ export class CheckpointsModule {
66
66
  * Replay from a checkpoint.
67
67
  */
68
68
  async replay(checkpointId: string, options?: {
69
- mode?: "best_effort" | "deterministic";
69
+ mode?: "best_effort" | "strict";
70
70
  modified_state?: unknown;
71
71
  }): Promise<APIResponse<ReplayResponse>> {
72
72
  return this.client.POST<ReplayResponse>("/v1/api/checkpoints/{id}/replay", {
@@ -10,8 +10,44 @@ export interface ServerInfo {
10
10
  environment: string;
11
11
  features?: string[];
12
12
  uptime_seconds?: number;
13
+ commit_hash?: string;
14
+ api_version?: string;
13
15
  }
14
16
 
17
+ /** Normalized server capabilities (camelCase, with defaults) */
18
+ export interface ServerCapabilities {
19
+ /** Server version */
20
+ version?: string;
21
+ /** Git commit hash */
22
+ commitHash?: string;
23
+ /** API version */
24
+ apiVersion?: string;
25
+ /** Environment (production, staging, development) */
26
+ environment?: string;
27
+ /** Feature flags - all default to false if not present */
28
+ features: {
29
+ sseResume: boolean;
30
+ cronTriggers: boolean;
31
+ batchRuns: boolean;
32
+ hitl: boolean;
33
+ traces: boolean;
34
+ vectorStores: boolean;
35
+ evaluations: boolean;
36
+ [key: string]: boolean;
37
+ };
38
+ /** Server limits */
39
+ limits?: {
40
+ maxBatchSize?: number;
41
+ maxFileSize?: number;
42
+ [key: string]: number | undefined;
43
+ };
44
+ /** SDK version that fetched this (useful for support) */
45
+ sdkVersion: string;
46
+ }
47
+
48
+ // SDK version from package (will be replaced at build time or use constant)
49
+ const SDK_VERSION = "0.4.0";
50
+
15
51
  export class InfoModule {
16
52
  constructor(private client: RawClient, private headers: () => Record<string, string>) { }
17
53
 
@@ -32,4 +68,76 @@ export class InfoModule {
32
68
  headers: this.headers(),
33
69
  });
34
70
  }
71
+
72
+ /**
73
+ * Get normalized server capabilities for feature detection.
74
+ *
75
+ * This method never assumes feature availability - all features
76
+ * default to false unless explicitly enabled by the server.
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * const caps = await client.info.capabilities();
81
+ * if (caps.data?.features.sseResume) {
82
+ * // Use follow() with resume
83
+ * } else {
84
+ * // Fall back to polling
85
+ * }
86
+ * ```
87
+ */
88
+ async capabilities(): Promise<APIResponse<ServerCapabilities>> {
89
+ const response = await this.get();
90
+
91
+ if (response.error || !response.data) {
92
+ // Pass through error - construct proper response without data
93
+ return {
94
+ error: response.error,
95
+ response: response.response,
96
+ meta: response.meta,
97
+ };
98
+ }
99
+
100
+ const info = response.data;
101
+
102
+ // Transform snake_case features array to camelCase object
103
+ // CRITICAL: Never assume true - default everything to false
104
+ const featureArray = info.features ?? [];
105
+ const features: ServerCapabilities["features"] = {
106
+ sseResume: featureArray.includes("sse_resume"),
107
+ cronTriggers: featureArray.includes("cron_triggers"),
108
+ batchRuns: featureArray.includes("batch_runs"),
109
+ hitl: featureArray.includes("hitl"),
110
+ traces: featureArray.includes("traces"),
111
+ vectorStores: featureArray.includes("vector_stores"),
112
+ evaluations: featureArray.includes("evaluations"),
113
+ };
114
+
115
+ // Add any other features from array as snake_case → camelCase
116
+ for (const feature of featureArray) {
117
+ const camelCase = snakeToCamel(feature);
118
+ if (!(camelCase in features)) {
119
+ features[camelCase] = true;
120
+ }
121
+ }
122
+
123
+ const capabilities: ServerCapabilities = {
124
+ version: info.version,
125
+ commitHash: info.commit_hash,
126
+ apiVersion: info.api_version,
127
+ environment: info.environment,
128
+ features,
129
+ sdkVersion: SDK_VERSION,
130
+ };
131
+
132
+ return {
133
+ data: capabilities,
134
+ response: response.response,
135
+ meta: response.meta,
136
+ };
137
+ }
138
+ }
139
+
140
+ /** Convert snake_case to camelCase */
141
+ function snakeToCamel(str: string): string {
142
+ return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
35
143
  }
@@ -7,8 +7,8 @@
7
7
  * - create*, update*, delete* for mutations (NOT remove!)
8
8
  */
9
9
 
10
- import type { RawClient, APIResponse } from "../client/raw.js";
11
- import type { PaginationParams, PaginatedResponse } from "../client/helpers.js";
10
+ import type { PaginatedResponse, PaginationParams } from "../client/helpers.js";
11
+ import type { APIResponse, RawClient } from "../client/raw.js";
12
12
 
13
13
  export interface Member {
14
14
  id: string;
@@ -25,6 +25,15 @@ export interface Member {
25
25
  updated_at: string;
26
26
  }
27
27
 
28
+ export interface Role {
29
+ id: string;
30
+ name: string;
31
+ is_system: boolean;
32
+ permissions?: string[];
33
+ created_at?: string;
34
+ members_count?: number;
35
+ }
36
+
28
37
  export interface MemberInviteResponse {
29
38
  member_id: string;
30
39
  invite_token?: string;
@@ -60,6 +69,66 @@ export class MembersModule {
60
69
  });
61
70
  }
62
71
 
72
+
73
+ /**
74
+ * List all roles in the tenant.
75
+ */
76
+ async listRoles(): Promise<APIResponse<{ items: Role[] }>> {
77
+ return this.client.GET<{ items: Role[] }>("/v1/api/roles", {
78
+ headers: this.headers(),
79
+ });
80
+ }
81
+
82
+ /**
83
+ * Get a role by ID.
84
+ */
85
+ async getRole(roleId: string): Promise<APIResponse<Role>> {
86
+ return this.client.GET<Role>("/v1/api/roles/{id}", {
87
+ params: { path: { id: roleId } },
88
+ headers: this.headers(),
89
+ });
90
+ }
91
+
92
+ /**
93
+ * Create a new custom role.
94
+ */
95
+ async createRole(body: { name: string; permissions?: string[] }): Promise<APIResponse<Role>> {
96
+ return this.client.POST<Role>("/v1/api/roles", {
97
+ body,
98
+ headers: this.headers(),
99
+ });
100
+ }
101
+
102
+ /**
103
+ * Update a custom role.
104
+ */
105
+ async updateRole(roleId: string, body: { name?: string; permissions?: string[] }): Promise<APIResponse<Role>> {
106
+ return this.client.PUT<Role>("/v1/api/roles/{id}", {
107
+ params: { path: { id: roleId } },
108
+ body,
109
+ headers: this.headers(),
110
+ });
111
+ }
112
+
113
+ /**
114
+ * Delete a custom role.
115
+ */
116
+ async deleteRole(roleId: string): Promise<APIResponse<void>> {
117
+ return this.client.DELETE<void>("/v1/api/roles/{id}", {
118
+ params: { path: { id: roleId } },
119
+ headers: this.headers(),
120
+ });
121
+ }
122
+
123
+ /**
124
+ * List all available system permissions.
125
+ */
126
+ async listPermissions(): Promise<APIResponse<{ items: string[] }>> {
127
+ return this.client.GET<{ items: string[] }>("/v1/api/roles/permissions", {
128
+ headers: this.headers(),
129
+ });
130
+ }
131
+
63
132
  /**
64
133
  * Invite a new member.
65
134
  */
@@ -125,4 +194,13 @@ export class MembersModule {
125
194
  headers: this.headers(),
126
195
  });
127
196
  }
197
+
198
+ /**
199
+ * Seed default permissions (Dev only)
200
+ */
201
+ async seedDefaults(): Promise<APIResponse<{ message: string }>> {
202
+ return this.client.POST<{ message: string }>("/v1/api/roles/seed-defaults", {
203
+ headers: this.headers(),
204
+ });
205
+ }
128
206
  }