@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.
Files changed (65) hide show
  1. package/dist/generated/openapi.d.ts +82 -0
  2. package/dist/generated/openapi.d.ts.map +1 -1
  3. package/dist/modules/runs.d.ts.map +1 -1
  4. package/dist/modules/templates.d.ts +23 -0
  5. package/dist/modules/templates.d.ts.map +1 -1
  6. package/dist/modules/templates.js +7 -0
  7. package/package.json +2 -2
  8. package/src/client/AgentOsClient.ts +0 -294
  9. package/src/client/HttpRequestBuilder.ts +0 -115
  10. package/src/client/OperationContext.ts +0 -22
  11. package/src/client/OperationContextProvider.ts +0 -89
  12. package/src/client/auth.ts +0 -136
  13. package/src/client/config.ts +0 -100
  14. package/src/client/helpers.ts +0 -98
  15. package/src/client/pagination.ts +0 -218
  16. package/src/client/raw.ts +0 -609
  17. package/src/client/retry.ts +0 -150
  18. package/src/client/sanitize.ts +0 -31
  19. package/src/client/timeout.ts +0 -59
  20. package/src/errors/factory.ts +0 -140
  21. package/src/errors/index.ts +0 -365
  22. package/src/generated/client.ts +0 -32
  23. package/src/generated/index.ts +0 -2
  24. package/src/generated/openapi.ts +0 -12302
  25. package/src/generated/swagger.json +0 -16851
  26. package/src/index.ts +0 -131
  27. package/src/modules/a2a.ts +0 -64
  28. package/src/modules/agents.ts +0 -604
  29. package/src/modules/apiTokens.ts +0 -101
  30. package/src/modules/approvals.ts +0 -151
  31. package/src/modules/audit.ts +0 -145
  32. package/src/modules/auth.ts +0 -33
  33. package/src/modules/catalog.ts +0 -241
  34. package/src/modules/chatwoot.ts +0 -242
  35. package/src/modules/checkpoints.ts +0 -87
  36. package/src/modules/contracts.ts +0 -80
  37. package/src/modules/credentials.ts +0 -216
  38. package/src/modules/crons.ts +0 -115
  39. package/src/modules/datasets.ts +0 -142
  40. package/src/modules/evaluation.ts +0 -269
  41. package/src/modules/files.ts +0 -208
  42. package/src/modules/improvements.ts +0 -71
  43. package/src/modules/info.ts +0 -143
  44. package/src/modules/me.ts +0 -74
  45. package/src/modules/members.ts +0 -199
  46. package/src/modules/memberships.ts +0 -42
  47. package/src/modules/metaAgent.ts +0 -131
  48. package/src/modules/metrics.ts +0 -34
  49. package/src/modules/observability.ts +0 -28
  50. package/src/modules/playground.ts +0 -68
  51. package/src/modules/presets.ts +0 -246
  52. package/src/modules/prompts.ts +0 -147
  53. package/src/modules/roles.ts +0 -112
  54. package/src/modules/runs.ts +0 -878
  55. package/src/modules/store.ts +0 -65
  56. package/src/modules/templates.ts +0 -40
  57. package/src/modules/tenants.ts +0 -79
  58. package/src/modules/threads.ts +0 -343
  59. package/src/modules/tools.ts +0 -91
  60. package/src/modules/traces.ts +0 -133
  61. package/src/modules/triggers.ts +0 -357
  62. package/src/modules/usage.ts +0 -117
  63. package/src/modules/vectorStores.ts +0 -257
  64. package/src/modules/workspaces.ts +0 -216
  65. package/src/sse/client.ts +0 -179
@@ -1,242 +0,0 @@
1
- /**
2
- * Chatwoot Module
3
- */
4
-
5
- import type { APIResponse, RawClient } from "../client/raw.js";
6
-
7
- export interface ChatwootInboxUrlResponse {
8
- url: string;
9
- }
10
-
11
- export interface ChatwootConfig {
12
- baseUrl: string;
13
- accountId: string;
14
- apiAccessToken: string;
15
- }
16
-
17
- export class ChatwootModule {
18
- constructor(
19
- private client: RawClient,
20
- private headers: () => Record<string, string>
21
- ) { }
22
-
23
- /**
24
- * Internal helper to resolve Chatwoot configuration from AgentOS credentials
25
- */
26
- private async _getChatwootConfig(credentialId: string): Promise<{ data: ChatwootConfig | undefined; error: any; response?: Response }> {
27
- const { data: credential, error } = await this.client.GET<any>("/v1/api/credentials/{id}", {
28
- params: {
29
- path: { id: credentialId },
30
- query: { includeValues: true }
31
- },
32
- headers: this.headers(),
33
- });
34
-
35
- if (error || !credential) {
36
- return { error: error || { message: "Credential not found", code: "CREDENTIAL_NOT_FOUND" }, data: undefined };
37
- }
38
-
39
- // Backend now returns 'values' when includeValues=true
40
- const values = credential.values || credential.Values || {};
41
- const publicConfig = credential.publicConfig || credential.PublicConfig || {};
42
- const data = credential.data || {};
43
-
44
- const url = publicConfig.url || data.url || values.url || publicConfig.endpoint || data.endpoint || values.endpoint || values.base_url;
45
- let accountId = publicConfig.account_id || data.account_id || values.account_id || publicConfig.accountId || data.accountId || values.accountId;
46
- const apiAccessToken = values.api_access_token || data.api_access_token || values.api_key || data.api_key || values.apiKey || data.apiKey || values.api_token;
47
-
48
- if (!url || !apiAccessToken) {
49
- return { error: { message: "Invalid Chatwoot credential: missing URL/Endpoint or API Access Token/Key", code: "INVALID_CREDENTIAL" }, data: undefined };
50
- }
51
-
52
- const baseUrl = url.endsWith("/") ? url.slice(0, -1) : url;
53
-
54
- // Auto-discover accountId if missing
55
- if (!accountId) {
56
- try {
57
- const profileRes = await fetch(`${baseUrl}/api/v1/profile`, {
58
- headers: { "api_access_token": apiAccessToken }
59
- });
60
- if (profileRes.ok) {
61
- const profile = await profileRes.json();
62
- // Use the first available account
63
- if (profile.accounts && profile.accounts.length > 0) {
64
- accountId = profile.accounts[0].id;
65
- }
66
- }
67
- } catch (err) {
68
- console.warn("Failed to auto-discover Chatwoot account ID:", err);
69
- }
70
- }
71
-
72
- if (!accountId) {
73
- return { error: { message: "Invalid Chatwoot credential: missing Account ID and auto-discovery failed.", code: "ACCOUNT_ID_MISSING" }, data: undefined };
74
- }
75
-
76
- return {
77
- data: {
78
- baseUrl,
79
- accountId: String(accountId),
80
- apiAccessToken
81
- },
82
- error: null
83
- };
84
- }
85
-
86
- /**
87
- * Direct call to Chatwoot API
88
- */
89
- private async _chatwootRequest(config: ChatwootConfig, method: string, path: string, body?: any): Promise<APIResponse<any>> {
90
- const url = `${config.baseUrl}${path}`;
91
- const headers = {
92
- "api_access_token": config.apiAccessToken,
93
- "Content-Type": "application/json",
94
- };
95
-
96
- try {
97
- const response = await fetch(url, {
98
- method,
99
- headers,
100
- body: body ? JSON.stringify(body) : undefined,
101
- });
102
-
103
- let data = null;
104
- const contentType = response.headers.get("content-type");
105
- if (contentType && contentType.includes("application/json")) {
106
- try {
107
- const text = await response.text();
108
- if (text) data = JSON.parse(text);
109
- } catch (e) {
110
- // Ignore JSON parse errors for empty bodies
111
- }
112
- }
113
-
114
- if (!response.ok) {
115
- return { error: data || { message: `Chatwoot API error: ${response.statusText}`, code: "API_ERROR" }, data: undefined, response };
116
- }
117
-
118
- return { data, error: undefined, response };
119
- } catch (err) {
120
- return { error: { message: (err as Error).message, code: "UNKNOWN_ERROR" }, data: undefined, response: new Response() };
121
- }
122
- }
123
-
124
- /**
125
- * Get the inbox URL for a specific credential.
126
- * Use this to open the Chatwoot inbox directly.
127
- */
128
- async getInboxUrl(credentialId: string): Promise<APIResponse<ChatwootInboxUrlResponse>> {
129
- const { data: config, error } = await this._getChatwootConfig(credentialId);
130
-
131
- if (error || !config) {
132
- return { error: error || { message: "Config not found", code: "CONFIG_MISSING" }, data: undefined, response: new Response() };
133
- }
134
-
135
- const inboxUrl = `${config.baseUrl}/app/accounts/${config.accountId}/inbox`;
136
-
137
- return {
138
- data: { url: inboxUrl },
139
- error: undefined,
140
- response: new Response(),
141
- };
142
- }
143
-
144
- /**
145
- * List all inboxes
146
- */
147
- async listInboxes(credentialId: string): Promise<APIResponse<any[]>> {
148
- const { data: config, error } = await this._getChatwootConfig(credentialId);
149
- if (error || !config) return { error: error || { message: "Config not found", code: "CONFIG_MISSING" }, data: undefined, response: new Response() };
150
-
151
- const res = await this._chatwootRequest(config, "GET", `/api/v1/accounts/${config.accountId}/inboxes`);
152
-
153
- // Chatwoot API returns { payload: [...] }
154
- if (res.data && Array.isArray(res.data.payload)) {
155
- return { data: res.data.payload, error: undefined, response: res.response };
156
- }
157
-
158
- return res;
159
- }
160
-
161
- /**
162
- * Create a new inbox
163
- */
164
- async createInbox(credentialId: string, data: any): Promise<APIResponse<any>> {
165
- const { data: config, error } = await this._getChatwootConfig(credentialId);
166
- if (error || !config) return { error: error || { message: "Config not found", code: "CONFIG_MISSING" }, data: undefined, response: new Response() };
167
-
168
- return this._chatwootRequest(config, "POST", `/api/v1/accounts/${config.accountId}/inboxes`, data);
169
- }
170
-
171
- /**
172
- * Get a specific inbox
173
- */
174
- async getInbox(credentialId: string, inboxId: string | number): Promise<APIResponse<any>> {
175
- const { data: config, error } = await this._getChatwootConfig(credentialId);
176
- if (error || !config) return { error: error || { message: "Config not found", code: "CONFIG_MISSING" }, data: undefined, response: new Response() };
177
-
178
- return this._chatwootRequest(config, "GET", `/api/v1/accounts/${config.accountId}/inboxes/${inboxId}`);
179
- }
180
-
181
- /**
182
- * Update an inbox
183
- */
184
- async updateInbox(credentialId: string, inboxId: string | number, data: any): Promise<APIResponse<any>> {
185
- const { data: config, error } = await this._getChatwootConfig(credentialId);
186
- if (error || !config) return { error: error || { message: "Config not found", code: "CONFIG_MISSING" }, data: undefined, response: new Response() };
187
-
188
- return this._chatwootRequest(config, "PATCH", `/api/v1/accounts/${config.accountId}/inboxes/${inboxId}`, data);
189
- }
190
-
191
- /**
192
- * Delete an inbox
193
- */
194
- async deleteInbox(credentialId: string, inboxId: string | number): Promise<APIResponse<any>> {
195
- const { data: config, error } = await this._getChatwootConfig(credentialId);
196
- if (error || !config) return { error: error || { message: "Config not found", code: "CONFIG_MISSING" }, data: undefined, response: new Response() };
197
-
198
- return this._chatwootRequest(config, "DELETE", `/api/v1/accounts/${config.accountId}/inboxes/${inboxId}`);
199
- }
200
-
201
- /**
202
- * Get inbox metrics
203
- */
204
- async getInboxMetrics(credentialId: string, inboxId: string | number): Promise<APIResponse<any>> {
205
- const { data: config, error } = await this._getChatwootConfig(credentialId);
206
- if (error || !config) return { error: error || { message: "Config not found", code: "CONFIG_MISSING" }, data: undefined, response: new Response() };
207
-
208
- return this._chatwootRequest(config, "GET", `/api/v1/accounts/${config.accountId}/inboxes/${inboxId}/metrics`);
209
- }
210
-
211
- /**
212
- * Get the inbox URL for a specific agent.
213
- */
214
- async getAgentInboxUrl(agentId: string): Promise<APIResponse<ChatwootInboxUrlResponse>> {
215
- const { data: triggers, error: triggerError } = await this.client.GET<any>("/v1/api/triggers", {
216
- params: { query: { agent_id: agentId } },
217
- headers: this.headers(),
218
- });
219
-
220
- if (triggerError || !triggers) {
221
- return { error: triggerError || { message: "Failed to fetch triggers", code: "TRIGGER_FETCH_FAILED" }, data: undefined, response: new Response() };
222
- }
223
-
224
- const chatwootTrigger = triggers.items?.find((t: any) =>
225
- t.type === "chatwoot" ||
226
- (t.type === "evolution_whatsapp" && t.config?.chat_platform === "chatwoot") ||
227
- (t.config?.credential_id && (t.type === "chatwoot" || t.type.includes("whatsapp")))
228
- );
229
-
230
- if (!chatwootTrigger) {
231
- return { error: { message: "No compatible trigger found for this agent", code: "NO_TRIGGER" }, data: undefined, response: new Response() };
232
- }
233
-
234
- const credentialId = chatwootTrigger.config?.credential_id;
235
-
236
- if (!credentialId) {
237
- return { error: { message: "Trigger configuration missing credential_id", code: "MISSING_CREDENTIAL_ID" }, data: undefined, response: new Response() };
238
- }
239
-
240
- return this.getInboxUrl(credentialId);
241
- }
242
- }
@@ -1,87 +0,0 @@
1
- /**
2
- * Checkpoints Module - Fully Typed
3
- */
4
-
5
- import type { RawClient, APIResponse, components } from "../client/raw.js";
6
-
7
- type CheckpointDetail = components["schemas"]["CheckpointDetail"];
8
- type CheckpointListResponse = components["schemas"]["CheckpointListResponse"];
9
-
10
- export interface Checkpoint {
11
- id: string;
12
- run_id: string;
13
- thread_id: string;
14
- step_name: string;
15
- checkpoint_id: string;
16
- parent_checkpoint_id?: string;
17
- has_state_snapshot: boolean;
18
- created_at: string;
19
- }
20
-
21
- export interface CheckpointNode {
22
- id: string;
23
- step_name: string;
24
- checkpoint_id: string;
25
- parent_checkpoint_id?: string;
26
- created_at: string;
27
- children?: CheckpointNode[];
28
- }
29
-
30
- export interface CheckpointsResponse {
31
- run_id: string;
32
- total_checkpoints: number;
33
- checkpoints: CheckpointNode[];
34
- }
35
-
36
- export interface ReplayResponse {
37
- run_id: string;
38
- status: string;
39
- replayed_from_checkpoint_id: string;
40
- }
41
-
42
- export class CheckpointsModule {
43
- constructor(private client: RawClient, private headers: () => Record<string, string>) { }
44
-
45
- /**
46
- * List checkpoints for a run.
47
- * @param workspaceId - Workspace ID
48
- * @param runId - Run ID
49
- */
50
- async list(workspaceId: string, runId: string): Promise<APIResponse<CheckpointsResponse>> {
51
- return this.client.GET<CheckpointsResponse>("/v1/api/workspaces/{workspaceId}/runs/{runId}/checkpoints", {
52
- params: { path: { workspaceId, runId } },
53
- headers: this.headers(),
54
- });
55
- }
56
-
57
- /**
58
- * Get a specific checkpoint.
59
- * @param workspaceId - Workspace ID
60
- * @param runId - Run ID
61
- * @param checkpointId - Checkpoint ID
62
- */
63
- async get(workspaceId: string, runId: string, checkpointId: string): Promise<APIResponse<Checkpoint>> {
64
- return this.client.GET<Checkpoint>("/v1/api/workspaces/{workspaceId}/runs/{runId}/checkpoints/{checkpointId}", {
65
- params: { path: { workspaceId, runId, checkpointId } },
66
- headers: this.headers(),
67
- });
68
- }
69
-
70
- /**
71
- * Replay from a checkpoint.
72
- * @param workspaceId - Workspace ID
73
- * @param runId - Run ID
74
- * @param checkpointId - Checkpoint ID
75
- * @param options - Replay options
76
- */
77
- async replay(workspaceId: string, runId: string, checkpointId: string, options?: {
78
- create_new_thread?: boolean;
79
- modified_input?: string;
80
- }): Promise<APIResponse<ReplayResponse>> {
81
- return this.client.POST<ReplayResponse>("/v1/api/workspaces/{workspaceId}/runs/{runId}/checkpoints/{checkpointId}/replay", {
82
- params: { path: { workspaceId, runId, checkpointId } },
83
- body: options ?? {},
84
- headers: this.headers(),
85
- });
86
- }
87
- }
@@ -1,80 +0,0 @@
1
- import type { APIResponse, RawClient } from "../client/raw.js";
2
-
3
- export interface ContractsValidationIssue {
4
- code: string;
5
- message: string;
6
- path?: string;
7
- severity?: string;
8
- }
9
-
10
- export type ContractsErrorCode =
11
- | "CONTRACT_ID_INVALID"
12
- | "RUNTIME_PACKAGE_COMPILE_INVALID"
13
- | "INTERNAL_UNAUTHORIZED"
14
- | "KERNEL_UNAVAILABLE"
15
- | "KERNEL_ERROR"
16
- | "INTERNAL_ERROR"
17
- | "VALIDATION_ERROR";
18
-
19
- export interface ContractsErrorResponse {
20
- code: ContractsErrorCode;
21
- message: string;
22
- errors?: ContractsValidationIssue[];
23
- supported_contract_ids?: string[];
24
- }
25
-
26
- export interface ContractsSupportedResponse {
27
- contract_ids: string[];
28
- }
29
-
30
- export interface ContractsValidateRequest {
31
- contract_id: string;
32
- spec: unknown;
33
- }
34
-
35
- export interface ContractsValidateResponse {
36
- contract_id: string;
37
- valid: boolean;
38
- errors: ContractsValidationIssue[];
39
- warnings: ContractsValidationIssue[];
40
- }
41
-
42
- export interface ContractsCompileRuntimePackageRequest {
43
- ir_spec: unknown;
44
- capability_registry_spec: unknown;
45
- policy_refs?: Record<string, unknown>;
46
- runtime_config_refs?: Record<string, unknown>;
47
- package_id?: string;
48
- metadata?: Record<string, unknown>;
49
- compiled_at?: string;
50
- }
51
-
52
- export interface ContractsCompileRuntimePackageResponse {
53
- package_spec: Record<string, unknown>;
54
- }
55
-
56
- export class ContractsModule {
57
- constructor(private client: RawClient, private headers: () => Record<string, string>) {}
58
-
59
- async supported(): Promise<APIResponse<ContractsSupportedResponse>> {
60
- return this.client.GET<ContractsSupportedResponse>("/v1/api/contracts/supported", {
61
- headers: this.headers(),
62
- });
63
- }
64
-
65
- async validate(body: ContractsValidateRequest): Promise<APIResponse<ContractsValidateResponse>> {
66
- return this.client.POST<ContractsValidateResponse>("/v1/api/contracts/validate", {
67
- body,
68
- headers: this.headers(),
69
- });
70
- }
71
-
72
- async compileRuntimePackage(
73
- body: ContractsCompileRuntimePackageRequest,
74
- ): Promise<APIResponse<ContractsCompileRuntimePackageResponse>> {
75
- return this.client.POST<ContractsCompileRuntimePackageResponse>("/v1/api/contracts/compile/runtime-package", {
76
- body,
77
- headers: this.headers(),
78
- });
79
- }
80
- }
@@ -1,216 +0,0 @@
1
- /**
2
- * Credentials Module - Fully Typed
3
- */
4
-
5
- import type { APIResponse, components, RawClient } from "../client/raw.js";
6
-
7
- type CreateCredentialRequest = components["schemas"]["CreateCredentialRequest"];
8
- type UpdateCredentialRequest = components["schemas"]["UpdateCredentialRequest"];
9
-
10
- export interface Credential {
11
- id: string;
12
- credential_instance_ref?: string;
13
- name: string;
14
- scope: "workspace" | "tenant";
15
- type_id?: string;
16
- type?: string;
17
- credential_type_ref?: string;
18
- workspace_id?: string;
19
- tenant_id: string;
20
- sharing_mode: "private" | "shared";
21
- status: "active" | "disabled" | "expired";
22
- created_at: string;
23
- updated_at: string;
24
- }
25
-
26
- export interface CredentialListResponse {
27
- items: Credential[];
28
- total: number;
29
- }
30
-
31
- export interface CredentialType {
32
- id: string;
33
- name: string;
34
- credential_type_ref?: string;
35
- display_name?: string;
36
- description?: string;
37
- provider_family?: string;
38
- version?: string;
39
- status?: string;
40
- masking_policy?: string;
41
- materialization_policy?: string;
42
- schema_public_json?: Record<string, unknown> | null;
43
- schema_secret_json?: Record<string, unknown> | null;
44
- }
45
-
46
- export interface CredentialTypesResponse {
47
- items: CredentialType[];
48
- count?: number;
49
- }
50
-
51
- export interface ValidateCredentialResponse {
52
- valid: boolean;
53
- error?: string;
54
- }
55
-
56
- export class CredentialsModule {
57
- constructor(
58
- private client: RawClient,
59
- private getWorkspaceId: () => string,
60
- private headers: () => Record<string, string>
61
- ) { }
62
-
63
- /**
64
- * List all credentials.
65
- */
66
- async list(params?: {
67
- workspace_id?: string;
68
- scope?: string;
69
- type?: string;
70
- limit?: number;
71
- offset?: number;
72
- }): Promise<APIResponse<CredentialListResponse>> {
73
- return this.client.GET<CredentialListResponse>("/v1/api/credentials", {
74
- params: { query: params },
75
- headers: this.headers(),
76
- });
77
- }
78
-
79
- /**
80
- * Get a credential by ID.
81
- */
82
- async get(credentialId: string, includeValues: boolean = false): Promise<APIResponse<Credential>> {
83
- return this.client.GET<Credential>("/v1/api/credentials/{id}", {
84
- params: {
85
- path: { id: credentialId },
86
- query: { includeValues }
87
- },
88
- headers: this.headers(),
89
- });
90
- }
91
-
92
- /**
93
- * Create a new credential.
94
- */
95
- async create(body: {
96
- name: string;
97
- scope?: "workspace" | "tenant";
98
- type_id?: string;
99
- type?: string;
100
- workspace_id?: string;
101
- values?: Record<string, unknown>;
102
- data?: Record<string, unknown>;
103
- sharing_mode?: "private" | "shared";
104
- }): Promise<APIResponse<Credential>> {
105
- return this.client.POST<Credential>("/v1/api/credentials", {
106
- body: {
107
- ...body,
108
- workspace_id: body.workspace_id || (this.getWorkspaceId() ? this.getWorkspaceId() : undefined),
109
- },
110
- headers: this.headers(),
111
- });
112
- }
113
-
114
- /**
115
- * Update a credential.
116
- * Uses PATCH per backend CredentialsController.
117
- */
118
- async update(credentialId: string, body: {
119
- name?: string;
120
- values?: Record<string, unknown>;
121
- status?: string;
122
- sharing_mode?: string;
123
- }): Promise<APIResponse<Credential>> {
124
- return this.client.PATCH<Credential>("/v1/api/credentials/{id}", {
125
- params: { path: { id: credentialId } },
126
- body,
127
- headers: this.headers(),
128
- });
129
- }
130
-
131
- /**
132
- * Delete a credential.
133
- */
134
- async delete(credentialId: string): Promise<APIResponse<void>> {
135
- return this.client.DELETE<void>("/v1/api/credentials/{id}", {
136
- params: { path: { id: credentialId } },
137
- headers: this.headers(),
138
- });
139
- }
140
-
141
- /**
142
- * List available credential types.
143
- */
144
- async listTypes(): Promise<APIResponse<CredentialTypesResponse>> {
145
- const response = await this.client.GET<unknown>("/v1/api/credential-types", {
146
- headers: this.headers(),
147
- });
148
-
149
- if (!response.data || response.error) {
150
- return response as APIResponse<CredentialTypesResponse>;
151
- }
152
-
153
- const raw = response.data as Record<string, unknown>;
154
- const rawItems = Array.isArray(raw)
155
- ? raw
156
- : Array.isArray(raw.items)
157
- ? raw.items
158
- : [];
159
-
160
- const items: CredentialType[] = rawItems
161
- .filter((item): item is Record<string, unknown> => Boolean(item) && typeof item === "object")
162
- .map((item) => ({
163
- id: String(item.id ?? ""),
164
- name: String(item.name ?? item.key ?? ""),
165
- credential_type_ref: typeof item.credential_type_ref === "string"
166
- ? item.credential_type_ref
167
- : undefined,
168
- display_name: typeof item.display_name === "string"
169
- ? item.display_name
170
- : typeof item.displayName === "string"
171
- ? item.displayName
172
- : undefined,
173
- description: typeof item.description === "string" ? item.description : undefined,
174
- provider_family: typeof item.provider_family === "string" ? item.provider_family : undefined,
175
- version: typeof item.version === "string" ? item.version : undefined,
176
- status: typeof item.status === "string" ? item.status : undefined,
177
- masking_policy: typeof item.masking_policy === "string" ? item.masking_policy : undefined,
178
- materialization_policy: typeof item.materialization_policy === "string" ? item.materialization_policy : undefined,
179
- schema_public_json: item.schema_public_json && typeof item.schema_public_json === "object"
180
- ? item.schema_public_json as Record<string, unknown>
181
- : null,
182
- schema_secret_json: item.schema_secret_json && typeof item.schema_secret_json === "object"
183
- ? item.schema_secret_json as Record<string, unknown>
184
- : null,
185
- }))
186
- .filter((item) => item.id && item.name);
187
-
188
- return {
189
- ...response,
190
- data: {
191
- items,
192
- count: typeof raw.count === "number" ? raw.count : items.length,
193
- },
194
- };
195
- }
196
-
197
- /**
198
- * Validate a credential.
199
- */
200
- async validate(credentialId: string): Promise<APIResponse<ValidateCredentialResponse>> {
201
- return this.client.POST<ValidateCredentialResponse>("/v1/api/credentials/{id}/validate", {
202
- params: { path: { id: credentialId } },
203
- headers: this.headers(),
204
- });
205
- }
206
-
207
- /**
208
- * List available models for a credential provider.
209
- */
210
- async listModels(credentialId: string): Promise<APIResponse<string[]>> {
211
- return this.client.GET<string[]>("/v1/api/credentials/{id}/models", {
212
- params: { path: { id: credentialId } },
213
- headers: this.headers(),
214
- });
215
- }
216
- }