@agent-os-sdk/client 0.9.26 → 0.9.28
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 +141 -0
- package/dist/client/AgentOsClient.d.ts.map +1 -0
- package/{src/client/AgentOsClient.ts → dist/client/AgentOsClient.js} +61 -105
- package/dist/client/HttpRequestBuilder.d.ts +50 -0
- package/dist/client/HttpRequestBuilder.d.ts.map +1 -0
- package/{src/client/HttpRequestBuilder.ts → dist/client/HttpRequestBuilder.js} +9 -41
- package/{src/client/OperationContext.ts → dist/client/OperationContext.d.ts} +6 -9
- package/dist/client/OperationContext.d.ts.map +1 -0
- package/dist/client/OperationContext.js +13 -0
- package/dist/client/OperationContextProvider.d.ts +54 -0
- package/dist/client/OperationContextProvider.d.ts.map +1 -0
- package/{src/client/OperationContextProvider.ts → dist/client/OperationContextProvider.js} +17 -35
- package/{src/client/auth.ts → dist/client/auth.d.ts} +29 -65
- package/dist/client/auth.d.ts.map +1 -0
- package/dist/client/auth.js +38 -0
- package/dist/client/config.d.ts +49 -0
- package/dist/client/config.d.ts.map +1 -0
- package/{src/client/config.ts → dist/client/config.js} +5 -43
- package/dist/client/helpers.d.ts +63 -0
- package/dist/client/helpers.d.ts.map +1 -0
- package/{src/client/helpers.ts → dist/client/helpers.js} +9 -52
- package/dist/client/pagination.d.ts +105 -0
- package/dist/client/pagination.d.ts.map +1 -0
- package/{src/client/pagination.ts → dist/client/pagination.js} +15 -116
- package/dist/client/raw.d.ts +277 -0
- package/dist/client/raw.d.ts.map +1 -0
- package/dist/client/raw.js +337 -0
- package/dist/client/retry.d.ts +37 -0
- package/dist/client/retry.d.ts.map +1 -0
- package/{src/client/retry.ts → dist/client/retry.js} +13 -55
- package/dist/client/sanitize.d.ts +19 -0
- package/dist/client/sanitize.d.ts.map +1 -0
- package/{src/client/sanitize.ts → dist/client/sanitize.js} +4 -7
- package/dist/client/timeout.d.ts +26 -0
- package/dist/client/timeout.d.ts.map +1 -0
- package/{src/client/timeout.ts → dist/client/timeout.js} +10 -18
- package/dist/errors/factory.d.ts +22 -0
- package/dist/errors/factory.d.ts.map +1 -0
- package/{src/errors/factory.ts → dist/errors/factory.js} +18 -57
- package/dist/errors/index.d.ts +210 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/{src/errors/index.ts → dist/errors/index.js} +74 -156
- package/{src/generated/client.ts → dist/generated/client.d.ts} +5 -17
- package/dist/generated/client.d.ts.map +1 -0
- package/dist/generated/client.js +15 -0
- package/{src/generated/index.ts → dist/generated/index.d.ts} +1 -1
- package/dist/generated/index.d.ts.map +1 -0
- package/dist/generated/index.js +1 -0
- package/{src/generated/openapi.ts → dist/generated/openapi.d.ts} +1 -1
- package/dist/generated/openapi.d.ts.map +1 -0
- package/dist/generated/openapi.js +5 -0
- package/dist/index.d.ts +69 -0
- package/dist/index.d.ts.map +1 -0
- package/{src/index.ts → dist/index.js} +13 -63
- package/dist/modules/a2a.d.ts +48 -0
- package/dist/modules/a2a.d.ts.map +1 -0
- package/dist/modules/a2a.js +37 -0
- package/dist/modules/agents.d.ts +346 -0
- package/dist/modules/agents.d.ts.map +1 -0
- package/dist/modules/agents.js +296 -0
- package/dist/modules/apiTokens.d.ts +62 -0
- package/dist/modules/apiTokens.d.ts.map +1 -0
- package/dist/modules/apiTokens.js +56 -0
- package/dist/modules/approvals.d.ts +77 -0
- package/dist/modules/approvals.d.ts.map +1 -0
- package/dist/modules/approvals.js +91 -0
- package/dist/modules/audit.d.ts +78 -0
- package/dist/modules/audit.d.ts.map +1 -0
- package/{src/modules/audit.ts → dist/modules/audit.js} +23 -74
- package/{src/modules/auth.ts → dist/modules/auth.d.ts} +6 -11
- package/dist/modules/auth.d.ts.map +1 -0
- package/dist/modules/auth.js +22 -0
- package/dist/modules/builder.d.ts +242 -0
- package/dist/modules/builder.d.ts.map +1 -0
- package/dist/modules/builder.js +248 -0
- package/dist/modules/catalog.d.ts +142 -0
- package/dist/modules/catalog.d.ts.map +1 -0
- package/dist/modules/catalog.js +136 -0
- package/dist/modules/chatwoot.d.ts +59 -0
- package/dist/modules/chatwoot.d.ts.map +1 -0
- package/dist/modules/chatwoot.js +200 -0
- package/dist/modules/checkpoints.d.ts +62 -0
- package/dist/modules/checkpoints.d.ts.map +1 -0
- package/dist/modules/checkpoints.js +48 -0
- package/dist/modules/contracts.d.ts +48 -0
- package/dist/modules/contracts.d.ts.map +1 -0
- package/dist/modules/contracts.js +25 -0
- package/dist/modules/credentials.d.ts +105 -0
- package/dist/modules/credentials.d.ts.map +1 -0
- package/dist/modules/credentials.js +135 -0
- package/dist/modules/crons.d.ts +73 -0
- package/dist/modules/crons.d.ts.map +1 -0
- package/dist/modules/crons.js +67 -0
- package/dist/modules/datasets.d.ts +80 -0
- package/dist/modules/datasets.d.ts.map +1 -0
- package/dist/modules/datasets.js +91 -0
- package/{src/modules/evaluation.ts → dist/modules/evaluation.d.ts} +23 -109
- package/dist/modules/evaluation.d.ts.map +1 -0
- package/dist/modules/evaluation.js +108 -0
- package/dist/modules/files.d.ts +89 -0
- package/dist/modules/files.d.ts.map +1 -0
- package/dist/modules/files.js +133 -0
- package/dist/modules/graphs.d.ts +120 -0
- package/dist/modules/graphs.d.ts.map +1 -0
- package/dist/modules/graphs.js +69 -0
- package/{src/modules/improvements.ts → dist/modules/improvements.d.ts} +8 -27
- package/dist/modules/improvements.d.ts.map +1 -0
- package/dist/modules/improvements.js +27 -0
- package/dist/modules/info.d.ts +76 -0
- package/dist/modules/info.d.ts.map +1 -0
- package/{src/modules/info.ts → dist/modules/info.js} +16 -66
- package/dist/modules/knowledge.d.ts +91 -0
- package/dist/modules/knowledge.d.ts.map +1 -0
- package/dist/modules/knowledge.js +80 -0
- package/{src/modules/me.ts → dist/modules/me.d.ts} +7 -23
- package/dist/modules/me.d.ts.map +1 -0
- package/dist/modules/me.js +28 -0
- package/dist/modules/members.d.ts +124 -0
- package/dist/modules/members.d.ts.map +1 -0
- package/dist/modules/members.js +142 -0
- package/dist/modules/memberships.d.ts +25 -0
- package/dist/modules/memberships.d.ts.map +1 -0
- package/dist/modules/memberships.js +20 -0
- package/{src/modules/metaAgent.ts → dist/modules/metaAgent.d.ts} +8 -44
- package/dist/modules/metaAgent.d.ts.map +1 -0
- package/dist/modules/metaAgent.js +32 -0
- package/dist/modules/metrics.d.ts +20 -0
- package/dist/modules/metrics.d.ts.map +1 -0
- package/{src/modules/metrics.ts → dist/modules/metrics.js} +7 -14
- 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/playground.d.ts +42 -0
- package/dist/modules/playground.d.ts.map +1 -0
- package/dist/modules/playground.js +48 -0
- package/dist/modules/presets.d.ts +32 -0
- package/dist/modules/presets.d.ts.map +1 -0
- package/dist/modules/presets.js +199 -0
- package/dist/modules/prompts.d.ts +87 -0
- package/dist/modules/prompts.d.ts.map +1 -0
- package/dist/modules/prompts.js +87 -0
- package/dist/modules/roles.d.ts +64 -0
- package/dist/modules/roles.d.ts.map +1 -0
- package/dist/modules/roles.js +79 -0
- package/dist/modules/runs.d.ts +451 -0
- package/dist/modules/runs.d.ts.map +1 -0
- package/{src/modules/runs.ts → dist/modules/runs.js} +96 -438
- package/dist/modules/store.d.ts +37 -0
- package/dist/modules/store.d.ts.map +1 -0
- package/dist/modules/store.js +48 -0
- package/{src/modules/templates.ts → dist/modules/templates.d.ts} +8 -32
- package/dist/modules/templates.d.ts.map +1 -0
- package/dist/modules/templates.js +26 -0
- package/dist/modules/tenants.d.ts +49 -0
- package/dist/modules/tenants.d.ts.map +1 -0
- package/dist/modules/tenants.js +56 -0
- package/dist/modules/threads.d.ts +205 -0
- package/dist/modules/threads.d.ts.map +1 -0
- package/dist/modules/threads.js +225 -0
- package/dist/modules/tools.d.ts +62 -0
- package/dist/modules/tools.d.ts.map +1 -0
- package/dist/modules/tools.js +45 -0
- package/dist/modules/traces.d.ts +89 -0
- package/dist/modules/traces.d.ts.map +1 -0
- package/dist/modules/traces.js +65 -0
- package/{src/modules/triggers.ts → dist/modules/triggers.d.ts} +24 -153
- package/dist/modules/triggers.d.ts.map +1 -0
- package/dist/modules/triggers.js +176 -0
- package/{src/modules/usage.ts → dist/modules/usage.d.ts} +14 -46
- package/dist/modules/usage.d.ts.map +1 -0
- package/dist/modules/usage.js +43 -0
- package/dist/modules/vectorStores.d.ts +100 -0
- package/dist/modules/vectorStores.d.ts.map +1 -0
- package/dist/modules/vectorStores.js +159 -0
- package/dist/modules/workspaces.d.ts +138 -0
- package/dist/modules/workspaces.d.ts.map +1 -0
- package/dist/modules/workspaces.js +121 -0
- package/dist/sse/client.d.ts +140 -0
- package/dist/sse/client.d.ts.map +1 -0
- package/{src/sse/client.ts → dist/sse/client.js} +24 -100
- package/package.json +8 -15
- package/src/client/raw.ts +0 -609
- package/src/generated/swagger.json +0 -17014
- 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/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/files.ts +0 -208
- package/src/modules/members.ts +0 -199
- package/src/modules/memberships.ts +0 -42
- 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/store.ts +0 -65
- 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/vectorStores.ts +0 -257
- package/src/modules/workspaces.ts +0 -216
package/src/modules/chatwoot.ts
DELETED
|
@@ -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
|
-
}
|
package/src/modules/contracts.ts
DELETED
|
@@ -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
|
-
}
|