sarvam-agents-client 0.5.2 → 0.5.4
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/README.md +52 -29
- package/dist/apis/AgentsApi.d.ts +96 -11
- package/dist/apis/AgentsApi.js +229 -9
- package/dist/apis/ConversationsApi.d.ts +5 -2
- package/dist/apis/ConversationsApi.js +7 -2
- package/dist/client.d.ts +3 -2
- package/dist/client.js +2 -1
- package/dist/compat/core/agents.d.ts +6 -1
- package/dist/compat/core/agents.js +237 -27
- package/dist/compat/core/customApis.d.ts +76 -0
- package/dist/compat/core/customApis.js +424 -0
- package/dist/compat/core/data.js +1 -1
- package/dist/compat/openai/client.d.ts +3 -0
- package/dist/compat/openai/client.js +5 -1
- package/dist/compat/openai/index.d.ts +1 -0
- package/dist/compat/openai/index.js +0 -1
- package/dist/compat/openai/resources/agents.js +8 -1
- package/dist/compat/openai/resources/sarvam.d.ts +26 -0
- package/dist/compat/openai/resources/sarvam.js +56 -0
- package/dist/compose/deploy.d.ts +14 -3
- package/dist/compose/deploy.js +60 -7
- package/dist/compose/errors.d.ts +4 -0
- package/dist/compose/errors.js +6 -1
- package/dist/compose/settingsTransport.d.ts +18 -13
- package/dist/compose/settingsTransport.js +78 -130
- package/dist/compose/transport.d.ts +12 -2
- package/dist/compose/webhook.d.ts +10 -13
- package/dist/compose/webhook.js +48 -45
- package/dist/compose/webhookSecrets.d.ts +79 -49
- package/dist/compose/webhookSecrets.js +244 -195
- package/dist/esm/apis/AgentsApi.d.ts +96 -11
- package/dist/esm/apis/AgentsApi.js +230 -10
- package/dist/esm/apis/ConversationsApi.d.ts +5 -2
- package/dist/esm/apis/ConversationsApi.js +7 -2
- package/dist/esm/client.d.ts +3 -2
- package/dist/esm/client.js +2 -1
- package/dist/esm/compat/core/agents.d.ts +6 -1
- package/dist/esm/compat/core/agents.js +237 -27
- package/dist/esm/compat/core/customApis.d.ts +76 -0
- package/dist/esm/compat/core/customApis.js +419 -0
- package/dist/esm/compat/core/data.js +1 -1
- package/dist/esm/compat/openai/client.d.ts +3 -0
- package/dist/esm/compat/openai/client.js +5 -1
- package/dist/esm/compat/openai/index.d.ts +1 -0
- package/dist/esm/compat/openai/index.js +0 -1
- package/dist/esm/compat/openai/resources/agents.js +8 -1
- package/dist/esm/compat/openai/resources/sarvam.d.ts +26 -0
- package/dist/esm/compat/openai/resources/sarvam.js +51 -0
- package/dist/esm/compose/deploy.d.ts +14 -3
- package/dist/esm/compose/deploy.js +60 -7
- package/dist/esm/compose/errors.d.ts +4 -0
- package/dist/esm/compose/errors.js +4 -0
- package/dist/esm/compose/settingsTransport.d.ts +18 -13
- package/dist/esm/compose/settingsTransport.js +80 -132
- package/dist/esm/compose/transport.d.ts +12 -2
- package/dist/esm/compose/webhook.d.ts +10 -13
- package/dist/esm/compose/webhook.js +45 -42
- package/dist/esm/compose/webhookSecrets.d.ts +79 -49
- package/dist/esm/compose/webhookSecrets.js +241 -193
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/models/AgentConversationDetail.d.ts +12 -0
- package/dist/esm/models/AgentConversationDetail.js +4 -0
- package/dist/esm/models/AgentConversationView.d.ts +12 -0
- package/dist/esm/models/AgentConversationView.js +4 -0
- package/dist/esm/models/AgentResource.d.ts +7 -0
- package/dist/esm/models/AgentResource.js +3 -0
- package/dist/esm/models/AgentVersionSavedResource.d.ts +65 -0
- package/dist/esm/models/AgentVersionSavedResource.js +60 -0
- package/dist/esm/models/AgentWebhookList.d.ts +33 -0
- package/dist/esm/models/AgentWebhookList.js +44 -0
- package/dist/esm/models/AgentWebhookView.d.ts +76 -0
- package/dist/esm/models/AgentWebhookView.js +70 -0
- package/dist/esm/models/ConversationDetail.d.ts +6 -0
- package/dist/esm/models/ConversationDetail.js +2 -0
- package/dist/esm/models/ConversationView.d.ts +6 -0
- package/dist/esm/models/ConversationView.js +2 -0
- package/dist/esm/models/ErrorDetailItem.d.ts +3 -0
- package/dist/esm/models/FileNodeView.d.ts +7 -0
- package/dist/esm/models/FileNodeView.js +3 -0
- package/dist/esm/models/QueueMessageInput.d.ts +6 -0
- package/dist/esm/models/QueueMessageInput.js +2 -0
- package/dist/esm/models/RotatedWebhookSecretView.d.ts +58 -0
- package/dist/esm/models/RotatedWebhookSecretView.js +61 -0
- package/dist/esm/models/SaveWarningView.d.ts +44 -0
- package/dist/esm/models/SaveWarningView.js +51 -0
- package/dist/esm/models/ShareSkippedResource.d.ts +41 -0
- package/dist/esm/models/ShareSkippedResource.js +47 -0
- package/dist/esm/models/WebhookSecretPutBody.d.ts +32 -0
- package/dist/esm/models/WebhookSecretPutBody.js +43 -0
- package/dist/esm/models/WebhookSecretStateView.d.ts +52 -0
- package/dist/esm/models/WebhookSecretStateView.js +56 -0
- package/dist/esm/models/WebhookSecretValueView.d.ts +32 -0
- package/dist/esm/models/WebhookSecretValueView.js +44 -0
- package/dist/esm/models/WebhookWarning.d.ts +44 -0
- package/dist/esm/models/WebhookWarning.js +51 -0
- package/dist/esm/models/index.d.ts +10 -0
- package/dist/esm/models/index.js +10 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -1
- package/dist/models/AgentConversationDetail.d.ts +12 -0
- package/dist/models/AgentConversationDetail.js +4 -0
- package/dist/models/AgentConversationView.d.ts +12 -0
- package/dist/models/AgentConversationView.js +4 -0
- package/dist/models/AgentResource.d.ts +7 -0
- package/dist/models/AgentResource.js +3 -0
- package/dist/models/AgentVersionSavedResource.d.ts +65 -0
- package/dist/models/AgentVersionSavedResource.js +67 -0
- package/dist/models/AgentWebhookList.d.ts +33 -0
- package/dist/models/AgentWebhookList.js +51 -0
- package/dist/models/AgentWebhookView.d.ts +76 -0
- package/dist/models/AgentWebhookView.js +78 -0
- package/dist/models/ConversationDetail.d.ts +6 -0
- package/dist/models/ConversationDetail.js +2 -0
- package/dist/models/ConversationView.d.ts +6 -0
- package/dist/models/ConversationView.js +2 -0
- package/dist/models/ErrorDetailItem.d.ts +3 -0
- package/dist/models/FileNodeView.d.ts +7 -0
- package/dist/models/FileNodeView.js +3 -0
- package/dist/models/QueueMessageInput.d.ts +6 -0
- package/dist/models/QueueMessageInput.js +2 -0
- package/dist/models/RotatedWebhookSecretView.d.ts +58 -0
- package/dist/models/RotatedWebhookSecretView.js +69 -0
- package/dist/models/SaveWarningView.d.ts +44 -0
- package/dist/models/SaveWarningView.js +58 -0
- package/dist/models/ShareSkippedResource.d.ts +41 -0
- package/dist/models/ShareSkippedResource.js +54 -0
- package/dist/models/WebhookSecretPutBody.d.ts +32 -0
- package/dist/models/WebhookSecretPutBody.js +50 -0
- package/dist/models/WebhookSecretStateView.d.ts +52 -0
- package/dist/models/WebhookSecretStateView.js +64 -0
- package/dist/models/WebhookSecretValueView.d.ts +32 -0
- package/dist/models/WebhookSecretValueView.js +51 -0
- package/dist/models/WebhookWarning.d.ts +44 -0
- package/dist/models/WebhookWarning.js +58 -0
- package/dist/models/index.d.ts +10 -0
- package/dist/models/index.js +10 -0
- package/package.json +1 -1
- package/src/apis/AgentsApi.ts +366 -11
- package/src/apis/ConversationsApi.ts +9 -2
- package/src/client.ts +3 -2
- package/src/compat/core/agents.ts +265 -36
- package/src/compat/core/customApis.ts +506 -0
- package/src/compat/core/data.ts +1 -1
- package/src/compat/openai/client.ts +7 -1
- package/src/compat/openai/index.ts +9 -0
- package/src/compat/openai/resources/agents.ts +9 -1
- package/src/compat/openai/resources/sarvam.ts +94 -0
- package/src/compose/deploy.ts +71 -10
- package/src/compose/errors.ts +4 -0
- package/src/compose/settingsTransport.ts +78 -131
- package/src/compose/transport.ts +10 -2
- package/src/compose/webhook.ts +49 -45
- package/src/compose/webhookSecrets.ts +227 -179
- package/src/index.ts +2 -1
- package/src/models/AgentConversationDetail.ts +16 -0
- package/src/models/AgentConversationView.ts +16 -0
- package/src/models/AgentResource.ts +15 -0
- package/src/models/AgentVersionSavedResource.ts +119 -0
- package/src/models/AgentWebhookList.ts +74 -0
- package/src/models/AgentWebhookView.ts +129 -0
- package/src/models/ConversationDetail.ts +8 -0
- package/src/models/ConversationView.ts +8 -0
- package/src/models/ErrorDetailItem.ts +3 -0
- package/src/models/FileNodeView.ts +16 -0
- package/src/models/QueueMessageInput.ts +8 -0
- package/src/models/RotatedWebhookSecretView.ts +103 -0
- package/src/models/SaveWarningView.ts +84 -0
- package/src/models/ShareSkippedResource.ts +78 -0
- package/src/models/WebhookSecretPutBody.ts +66 -0
- package/src/models/WebhookSecretStateView.ts +94 -0
- package/src/models/WebhookSecretValueView.ts +66 -0
- package/src/models/WebhookWarning.ts +84 -0
- package/src/models/index.ts +10 -0
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CustomApis = void 0;
|
|
4
|
+
exports.validateCustomApiRefs = validateCustomApiRefs;
|
|
5
|
+
/** Core Custom APIs service: CRUD, validation, resolution, and agent bindings. */
|
|
6
|
+
const CustomAPIsApi_js_1 = require("../../apis/CustomAPIsApi.js");
|
|
7
|
+
const errors_js_1 = require("./errors.js");
|
|
8
|
+
const PAGE_LIMIT = 100;
|
|
9
|
+
const MAX_PAGES = 50;
|
|
10
|
+
const MAX_NAME_LEN = 256;
|
|
11
|
+
const MAX_DESC_LEN = 200;
|
|
12
|
+
const MAX_HOST_LEN = 253;
|
|
13
|
+
const MAX_SECRET_LEN = 8192;
|
|
14
|
+
const MAX_HEADERS = 16;
|
|
15
|
+
function isObj(v) {
|
|
16
|
+
return v !== null && typeof v === "object" && !Array.isArray(v);
|
|
17
|
+
}
|
|
18
|
+
function asRecord(v) {
|
|
19
|
+
return isObj(v) ? v : {};
|
|
20
|
+
}
|
|
21
|
+
function isoStr(v) {
|
|
22
|
+
if (v instanceof Date)
|
|
23
|
+
return v.toISOString();
|
|
24
|
+
if (typeof v === "string")
|
|
25
|
+
return v;
|
|
26
|
+
return "";
|
|
27
|
+
}
|
|
28
|
+
function badReq(message, param, code = "invalid_request_error") {
|
|
29
|
+
return new errors_js_1.CoreAPIError(message, { status: 400, code, param: param !== null && param !== void 0 ? param : null });
|
|
30
|
+
}
|
|
31
|
+
function infoFromModel(raw) {
|
|
32
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
33
|
+
const d = asRecord(raw);
|
|
34
|
+
const agentsRaw = Array.isArray(d["agents"]) ? d["agents"] : [];
|
|
35
|
+
const agents = agentsRaw.map((a) => {
|
|
36
|
+
var _a, _b;
|
|
37
|
+
const ar = asRecord(a);
|
|
38
|
+
return Object.freeze({ id: String((_a = ar["id"]) !== null && _a !== void 0 ? _a : ""), name: String((_b = ar["name"]) !== null && _b !== void 0 ? _b : "") });
|
|
39
|
+
});
|
|
40
|
+
const headerNamesRaw = Array.isArray(d["headerNames"])
|
|
41
|
+
? d["headerNames"]
|
|
42
|
+
: (Array.isArray(d["header_names"]) ? d["header_names"] : []);
|
|
43
|
+
const enabledRaw = "enabledForChats" in d
|
|
44
|
+
? d["enabledForChats"]
|
|
45
|
+
: ("enabled_for_chats" in d ? d["enabled_for_chats"] : true);
|
|
46
|
+
const errRaw = (_a = d["enabledForChatsError"]) !== null && _a !== void 0 ? _a : d["enabled_for_chats_error"];
|
|
47
|
+
return Object.freeze({
|
|
48
|
+
id: String((_b = d["id"]) !== null && _b !== void 0 ? _b : ""),
|
|
49
|
+
name: String((_c = d["name"]) !== null && _c !== void 0 ? _c : ""),
|
|
50
|
+
description: String((_d = d["description"]) !== null && _d !== void 0 ? _d : ""),
|
|
51
|
+
host: String((_e = d["host"]) !== null && _e !== void 0 ? _e : ""),
|
|
52
|
+
authType: String((_g = (_f = d["authType"]) !== null && _f !== void 0 ? _f : d["auth_type"]) !== null && _g !== void 0 ? _g : ""),
|
|
53
|
+
headerNames: Object.freeze(headerNamesRaw.map((h) => String(h))),
|
|
54
|
+
enabledForChats: Boolean(enabledRaw),
|
|
55
|
+
agents: Object.freeze(agents),
|
|
56
|
+
createdAt: isoStr((_h = d["createdAt"]) !== null && _h !== void 0 ? _h : d["created_at"]),
|
|
57
|
+
credentialsUpdatedAt: isoStr((_j = d["credentialsUpdatedAt"]) !== null && _j !== void 0 ? _j : d["credentials_updated_at"]),
|
|
58
|
+
enabledForChatsError: errRaw !== undefined && errRaw !== null ? String(errRaw) : null,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function validateName(name, param = "name") {
|
|
62
|
+
if (typeof name !== "string" || !name.trim()) {
|
|
63
|
+
throw badReq("name must be a non-empty string.", param);
|
|
64
|
+
}
|
|
65
|
+
if (name.length > MAX_NAME_LEN) {
|
|
66
|
+
throw badReq(`name must be at most ${MAX_NAME_LEN} characters.`, param);
|
|
67
|
+
}
|
|
68
|
+
return name;
|
|
69
|
+
}
|
|
70
|
+
function validateDescription(description, param = "description") {
|
|
71
|
+
if (description === undefined || description === null)
|
|
72
|
+
return null;
|
|
73
|
+
if (typeof description !== "string") {
|
|
74
|
+
throw badReq("description must be a string or null.", param);
|
|
75
|
+
}
|
|
76
|
+
if (description.length > MAX_DESC_LEN) {
|
|
77
|
+
throw badReq(`description must be at most ${MAX_DESC_LEN} characters.`, param);
|
|
78
|
+
}
|
|
79
|
+
return description;
|
|
80
|
+
}
|
|
81
|
+
function validateHost(host, param = "host") {
|
|
82
|
+
if (typeof host !== "string" || !host.trim()) {
|
|
83
|
+
throw badReq("host must be a non-empty hostname (for example 'api.acme.com').", param);
|
|
84
|
+
}
|
|
85
|
+
const trimmed = host.trim();
|
|
86
|
+
if (trimmed.length > MAX_HOST_LEN) {
|
|
87
|
+
throw badReq(`host must be at most ${MAX_HOST_LEN} characters.`, param);
|
|
88
|
+
}
|
|
89
|
+
if (trimmed.includes("://")) {
|
|
90
|
+
throw badReq("host must be a bare hostname without scheme (for example 'api.acme.com', not a full URL).", param);
|
|
91
|
+
}
|
|
92
|
+
if (/\s/.test(trimmed) || trimmed.includes("/") || trimmed.includes("?") || trimmed.includes("#")) {
|
|
93
|
+
throw badReq("host must be a bare hostname without path, query, or whitespace.", param);
|
|
94
|
+
}
|
|
95
|
+
return trimmed;
|
|
96
|
+
}
|
|
97
|
+
function buildAuth(auth, forUpdate, param = "auth") {
|
|
98
|
+
if (!isObj(auth)) {
|
|
99
|
+
throw badReq("auth must be an object with type 'bearer', 'basic', or 'headers'.", param);
|
|
100
|
+
}
|
|
101
|
+
const atype = auth["type"];
|
|
102
|
+
if (atype === "bearer") {
|
|
103
|
+
const extra = Object.keys(auth).filter((k) => k !== "type" && k !== "token");
|
|
104
|
+
if (extra.length > 0) {
|
|
105
|
+
throw badReq(`Unknown bearer auth key ${JSON.stringify(extra[0])}.`, `${param}.${extra[0]}`);
|
|
106
|
+
}
|
|
107
|
+
const token = auth["token"];
|
|
108
|
+
if (typeof token !== "string" || !token) {
|
|
109
|
+
throw badReq("bearer auth requires a non-empty token string.", `${param}.token`);
|
|
110
|
+
}
|
|
111
|
+
if (token.length > MAX_SECRET_LEN) {
|
|
112
|
+
throw badReq(`bearer token exceeds maximum length of ${MAX_SECRET_LEN}.`, `${param}.token`);
|
|
113
|
+
}
|
|
114
|
+
return { type: "bearer", token };
|
|
115
|
+
}
|
|
116
|
+
if (atype === "basic") {
|
|
117
|
+
const extra = Object.keys(auth).filter((k) => k !== "type" && k !== "username" && k !== "password");
|
|
118
|
+
if (extra.length > 0) {
|
|
119
|
+
throw badReq(`Unknown basic auth key ${JSON.stringify(extra[0])}.`, `${param}.${extra[0]}`);
|
|
120
|
+
}
|
|
121
|
+
const username = auth["username"];
|
|
122
|
+
const password = auth["password"];
|
|
123
|
+
if (typeof username !== "string" || !username) {
|
|
124
|
+
throw badReq("basic auth requires a non-empty username string.", `${param}.username`);
|
|
125
|
+
}
|
|
126
|
+
if (typeof password !== "string" || !password) {
|
|
127
|
+
throw badReq("basic auth requires a non-empty password string.", `${param}.password`);
|
|
128
|
+
}
|
|
129
|
+
if (password.length > MAX_SECRET_LEN) {
|
|
130
|
+
throw badReq(`basic password exceeds maximum length of ${MAX_SECRET_LEN}.`, `${param}.password`);
|
|
131
|
+
}
|
|
132
|
+
return { type: "basic", username, password };
|
|
133
|
+
}
|
|
134
|
+
if (atype === "headers") {
|
|
135
|
+
const extra = Object.keys(auth).filter((k) => k !== "type" && k !== "headers");
|
|
136
|
+
if (extra.length > 0) {
|
|
137
|
+
throw badReq(`Unknown headers auth key ${JSON.stringify(extra[0])}.`, `${param}.${extra[0]}`);
|
|
138
|
+
}
|
|
139
|
+
const rawHeaders = auth["headers"];
|
|
140
|
+
const parsed = [];
|
|
141
|
+
if (isObj(rawHeaders)) {
|
|
142
|
+
for (const [k, v] of Object.entries(rawHeaders)) {
|
|
143
|
+
if (typeof k !== "string" || !k.trim()) {
|
|
144
|
+
throw badReq("Header name must be a non-empty string.", `${param}.headers`);
|
|
145
|
+
}
|
|
146
|
+
if (v === null || v === undefined) {
|
|
147
|
+
if (!forUpdate) {
|
|
148
|
+
throw badReq(`Header ${JSON.stringify(k)} requires a non-empty value on create.`, `${param}.headers`);
|
|
149
|
+
}
|
|
150
|
+
parsed.push({ name: k });
|
|
151
|
+
}
|
|
152
|
+
else if (typeof v !== "string" || !v) {
|
|
153
|
+
throw badReq(`Header ${JSON.stringify(k)} value must be a non-empty string.`, `${param}.headers`);
|
|
154
|
+
}
|
|
155
|
+
else if (v.length > MAX_SECRET_LEN) {
|
|
156
|
+
throw badReq(`Header ${JSON.stringify(k)} value exceeds maximum length of ${MAX_SECRET_LEN}.`, `${param}.headers`);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
parsed.push({ name: k, value: v });
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
else if (Array.isArray(rawHeaders)) {
|
|
164
|
+
for (let i = 0; i < rawHeaders.length; i++) {
|
|
165
|
+
const item = rawHeaders[i];
|
|
166
|
+
const itemParam = `${param}.headers[${i}]`;
|
|
167
|
+
if (!isObj(item)) {
|
|
168
|
+
throw badReq("Each header entry must be an object with 'name' and 'value'.", itemParam);
|
|
169
|
+
}
|
|
170
|
+
const badKeys = Object.keys(item).filter((k) => k !== "name" && k !== "value" && k !== "previousName" && k !== "previous_name");
|
|
171
|
+
if (badKeys.length > 0) {
|
|
172
|
+
throw badReq(`Unknown header key ${JSON.stringify(badKeys[0])}.`, `${itemParam}.${badKeys[0]}`);
|
|
173
|
+
}
|
|
174
|
+
const hname = item["name"];
|
|
175
|
+
if (typeof hname !== "string" || !hname.trim()) {
|
|
176
|
+
throw badReq("Header name must be a non-empty string.", `${itemParam}.name`);
|
|
177
|
+
}
|
|
178
|
+
const hval = item["value"];
|
|
179
|
+
const prevName = "previousName" in item ? item["previousName"] : item["previous_name"];
|
|
180
|
+
if (prevName !== undefined && prevName !== null && (typeof prevName !== "string" || !prevName.trim())) {
|
|
181
|
+
throw badReq("previousName must be a non-empty string or null.", `${itemParam}.previousName`);
|
|
182
|
+
}
|
|
183
|
+
if (hval === undefined || hval === null) {
|
|
184
|
+
if (!forUpdate) {
|
|
185
|
+
throw badReq(`Header ${JSON.stringify(hname)} requires a non-empty value on create.`, `${itemParam}.value`);
|
|
186
|
+
}
|
|
187
|
+
const entry = { name: hname };
|
|
188
|
+
if (typeof prevName === "string")
|
|
189
|
+
entry.previousName = prevName;
|
|
190
|
+
parsed.push(entry);
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
if (typeof hval !== "string" || !hval) {
|
|
194
|
+
throw badReq(`Header ${JSON.stringify(hname)} value must be a non-empty string.`, `${itemParam}.value`);
|
|
195
|
+
}
|
|
196
|
+
if (hval.length > MAX_SECRET_LEN) {
|
|
197
|
+
throw badReq(`Header ${JSON.stringify(hname)} value exceeds maximum length of ${MAX_SECRET_LEN}.`, `${itemParam}.value`);
|
|
198
|
+
}
|
|
199
|
+
const entry = { name: hname, value: hval };
|
|
200
|
+
if (typeof prevName === "string")
|
|
201
|
+
entry.previousName = prevName;
|
|
202
|
+
parsed.push(entry);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
throw badReq("headers auth requires 'headers' as a non-empty list or name->value mapping.", `${param}.headers`);
|
|
208
|
+
}
|
|
209
|
+
if (parsed.length === 0 || parsed.length > MAX_HEADERS) {
|
|
210
|
+
throw badReq(`headers auth requires between 1 and ${MAX_HEADERS} headers.`, `${param}.headers`);
|
|
211
|
+
}
|
|
212
|
+
return { type: "headers", headers: parsed };
|
|
213
|
+
}
|
|
214
|
+
throw badReq("auth.type must be 'bearer', 'basic', or 'headers'.", `${param}.type`);
|
|
215
|
+
}
|
|
216
|
+
function validateCustomApiRefs(refs, param = "sarvam_config.custom_apis") {
|
|
217
|
+
if (!Array.isArray(refs)) {
|
|
218
|
+
throw badReq("sarvam_config.custom_apis must be a list of custom API IDs or names.", param);
|
|
219
|
+
}
|
|
220
|
+
const out = [];
|
|
221
|
+
for (let i = 0; i < refs.length; i++) {
|
|
222
|
+
const ref = refs[i];
|
|
223
|
+
if (typeof ref !== "string" || !ref.trim()) {
|
|
224
|
+
throw badReq("Each entry in sarvam_config.custom_apis must be a non-empty string.", `${param}[${i}]`);
|
|
225
|
+
}
|
|
226
|
+
out.push(ref.trim());
|
|
227
|
+
}
|
|
228
|
+
return out;
|
|
229
|
+
}
|
|
230
|
+
class CustomApis {
|
|
231
|
+
constructor(http) {
|
|
232
|
+
this.http = http;
|
|
233
|
+
this.api = new CustomAPIsApi_js_1.CustomAPIsApi(http.sdkConfig);
|
|
234
|
+
}
|
|
235
|
+
async list(opts = {}) {
|
|
236
|
+
const rows = [];
|
|
237
|
+
const seenIds = new Set();
|
|
238
|
+
let offset = 0;
|
|
239
|
+
for (let pages = 0; pages < MAX_PAGES; pages += 1) {
|
|
240
|
+
const off = offset;
|
|
241
|
+
const page = await this.http.call(() => this.api.listCustomApis({
|
|
242
|
+
...(opts.q !== undefined ? { q: opts.q } : {}),
|
|
243
|
+
limit: PAGE_LIMIT,
|
|
244
|
+
offset: off,
|
|
245
|
+
}), { idempotent: true });
|
|
246
|
+
const d = asRecord(page);
|
|
247
|
+
const items = Array.isArray(d["data"]) ? d["data"] : [];
|
|
248
|
+
for (const item of items) {
|
|
249
|
+
const info = infoFromModel(item);
|
|
250
|
+
if (info.id && seenIds.has(info.id))
|
|
251
|
+
continue;
|
|
252
|
+
if (info.id)
|
|
253
|
+
seenIds.add(info.id);
|
|
254
|
+
rows.push(info);
|
|
255
|
+
}
|
|
256
|
+
const hasMore = Boolean(d["hasMore"]);
|
|
257
|
+
if (items.length === 0 || !hasMore)
|
|
258
|
+
break;
|
|
259
|
+
offset += items.length;
|
|
260
|
+
}
|
|
261
|
+
return rows;
|
|
262
|
+
}
|
|
263
|
+
async get(customApiId) {
|
|
264
|
+
if (typeof customApiId !== "string" || !customApiId.trim()) {
|
|
265
|
+
throw badReq("customApiId must be a non-empty string.", "custom_api_id");
|
|
266
|
+
}
|
|
267
|
+
const raw = await this.http.call(() => this.api.getCustomApi({ customApiId }), { idempotent: true });
|
|
268
|
+
return infoFromModel(raw);
|
|
269
|
+
}
|
|
270
|
+
async retrieve(customApiId) {
|
|
271
|
+
return this.get(customApiId);
|
|
272
|
+
}
|
|
273
|
+
async create(params) {
|
|
274
|
+
if (!isObj(params)) {
|
|
275
|
+
throw badReq("create params must be an object.");
|
|
276
|
+
}
|
|
277
|
+
const name = validateName(params.name);
|
|
278
|
+
const host = validateHost(params.host);
|
|
279
|
+
const description = validateDescription(params.description);
|
|
280
|
+
const auth = buildAuth(params.auth, false);
|
|
281
|
+
const enabledRaw = params.enabledForChats !== undefined ? params.enabledForChats : params.enabled_for_chats;
|
|
282
|
+
const enabledForChats = enabledRaw === undefined ? true : enabledRaw;
|
|
283
|
+
if (typeof enabledForChats !== "boolean") {
|
|
284
|
+
throw badReq("enabledForChats must be a boolean.", "enabled_for_chats");
|
|
285
|
+
}
|
|
286
|
+
const body = {
|
|
287
|
+
name,
|
|
288
|
+
host,
|
|
289
|
+
auth,
|
|
290
|
+
enabledForChats,
|
|
291
|
+
...(description !== null ? { description } : {}),
|
|
292
|
+
};
|
|
293
|
+
const raw = await this.http.call(() => this.api.createCustomApi({ customApiCreate: body }), { idempotent: false });
|
|
294
|
+
return infoFromModel(raw);
|
|
295
|
+
}
|
|
296
|
+
async update(customApiId, params) {
|
|
297
|
+
if (typeof customApiId !== "string" || !customApiId.trim()) {
|
|
298
|
+
throw badReq("customApiId must be a non-empty string.", "custom_api_id");
|
|
299
|
+
}
|
|
300
|
+
if (!isObj(params)) {
|
|
301
|
+
throw badReq("update params must be an object.");
|
|
302
|
+
}
|
|
303
|
+
const body = {};
|
|
304
|
+
let hasField = false;
|
|
305
|
+
if (params.name !== undefined) {
|
|
306
|
+
body.name = validateName(params.name);
|
|
307
|
+
hasField = true;
|
|
308
|
+
}
|
|
309
|
+
if (params.description !== undefined) {
|
|
310
|
+
body.description = validateDescription(params.description);
|
|
311
|
+
hasField = true;
|
|
312
|
+
}
|
|
313
|
+
if (params.host !== undefined) {
|
|
314
|
+
body.host = validateHost(params.host);
|
|
315
|
+
hasField = true;
|
|
316
|
+
}
|
|
317
|
+
if (params.auth !== undefined) {
|
|
318
|
+
body.auth = buildAuth(params.auth, true);
|
|
319
|
+
hasField = true;
|
|
320
|
+
}
|
|
321
|
+
const enabledRaw = params.enabledForChats !== undefined ? params.enabledForChats : params.enabled_for_chats;
|
|
322
|
+
if (enabledRaw !== undefined) {
|
|
323
|
+
if (typeof enabledRaw !== "boolean") {
|
|
324
|
+
throw badReq("enabledForChats must be a boolean.", "enabled_for_chats");
|
|
325
|
+
}
|
|
326
|
+
body.enabledForChats = enabledRaw;
|
|
327
|
+
hasField = true;
|
|
328
|
+
}
|
|
329
|
+
if (!hasField) {
|
|
330
|
+
throw badReq("At least one field must be provided to update a custom API.");
|
|
331
|
+
}
|
|
332
|
+
const raw = await this.http.call(() => this.api.updateCustomApi({ customApiId, customApiUpdate: body }), { idempotent: false });
|
|
333
|
+
return infoFromModel(raw);
|
|
334
|
+
}
|
|
335
|
+
async delete(customApiId, opts = {}) {
|
|
336
|
+
if (typeof customApiId !== "string" || !customApiId.trim()) {
|
|
337
|
+
throw badReq("customApiId must be a non-empty string.", "custom_api_id");
|
|
338
|
+
}
|
|
339
|
+
if (!opts.force) {
|
|
340
|
+
const info = await this.get(customApiId);
|
|
341
|
+
if (info.agents.length > 0) {
|
|
342
|
+
const ids = info.agents.map((a) => a.id).filter(Boolean).join(", ");
|
|
343
|
+
throw new errors_js_1.CoreAPIError(`Custom API ${JSON.stringify(info.name)} (${info.id}) is attached to ${info.agents.length} agent(s)${ids ? ` (${ids})` : ""}; unbind it first or pass { force: true }.`, { status: 409, code: "custom_api_in_use", param: "custom_api_id" });
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
await this.http.call(() => this.api.deleteCustomApi({ customApiId }), { idempotent: true });
|
|
347
|
+
}
|
|
348
|
+
async listForAgent(agentId) {
|
|
349
|
+
if (typeof agentId !== "string" || !agentId.trim()) {
|
|
350
|
+
throw badReq("agentId must be a non-empty string.", "agent_id");
|
|
351
|
+
}
|
|
352
|
+
const resp = await this.http.call(() => this.api.listAgentCustomApis({ agentId }), { idempotent: true });
|
|
353
|
+
const d = asRecord(resp);
|
|
354
|
+
const items = Array.isArray(d["data"]) ? d["data"] : [];
|
|
355
|
+
return items.map((item) => {
|
|
356
|
+
var _a, _b;
|
|
357
|
+
const r = asRecord(item);
|
|
358
|
+
return {
|
|
359
|
+
id: String((_a = r["id"]) !== null && _a !== void 0 ? _a : ""),
|
|
360
|
+
name: String((_b = r["name"]) !== null && _b !== void 0 ? _b : ""),
|
|
361
|
+
host: r["host"] !== undefined && r["host"] !== null ? String(r["host"]) : null,
|
|
362
|
+
};
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
async bind(agentId, customApiId) {
|
|
366
|
+
if (typeof agentId !== "string" || !agentId.trim()) {
|
|
367
|
+
throw badReq("agentId must be a non-empty string.", "agent_id");
|
|
368
|
+
}
|
|
369
|
+
if (typeof customApiId !== "string" || !customApiId.trim()) {
|
|
370
|
+
throw badReq("customApiId must be a non-empty string.", "custom_api_id");
|
|
371
|
+
}
|
|
372
|
+
await this.http.call(() => this.api.bindCustomApi({ agentId, bindCustomApiBody: { customApiId } }), { idempotent: true });
|
|
373
|
+
}
|
|
374
|
+
async unbind(agentId, customApiId) {
|
|
375
|
+
if (typeof agentId !== "string" || !agentId.trim()) {
|
|
376
|
+
throw badReq("agentId must be a non-empty string.", "agent_id");
|
|
377
|
+
}
|
|
378
|
+
if (typeof customApiId !== "string" || !customApiId.trim()) {
|
|
379
|
+
throw badReq("customApiId must be a non-empty string.", "custom_api_id");
|
|
380
|
+
}
|
|
381
|
+
await this.http.call(() => this.api.unbindCustomApi({ agentId, customApiId }), { idempotent: true });
|
|
382
|
+
}
|
|
383
|
+
async resolveRefs(refs, paramPrefix = "sarvam_config.custom_apis") {
|
|
384
|
+
var _a, _b;
|
|
385
|
+
const validated = validateCustomApiRefs([...refs], paramPrefix);
|
|
386
|
+
if (validated.length === 0)
|
|
387
|
+
return [];
|
|
388
|
+
const catalog = await this.list();
|
|
389
|
+
const byId = new Map();
|
|
390
|
+
const byName = new Map();
|
|
391
|
+
for (const c of catalog) {
|
|
392
|
+
byId.set(c.id, c);
|
|
393
|
+
const list = (_a = byName.get(c.name)) !== null && _a !== void 0 ? _a : [];
|
|
394
|
+
list.push(c);
|
|
395
|
+
byName.set(c.name, list);
|
|
396
|
+
}
|
|
397
|
+
const resolved = [];
|
|
398
|
+
const seen = new Set();
|
|
399
|
+
for (let idx = 0; idx < validated.length; idx++) {
|
|
400
|
+
const ref = validated[idx];
|
|
401
|
+
const param = `${paramPrefix}[${idx}]`;
|
|
402
|
+
let match = byId.get(ref);
|
|
403
|
+
if (!match) {
|
|
404
|
+
const nameMatches = (_b = byName.get(ref)) !== null && _b !== void 0 ? _b : [];
|
|
405
|
+
if (nameMatches.length === 1) {
|
|
406
|
+
match = nameMatches[0];
|
|
407
|
+
}
|
|
408
|
+
else if (nameMatches.length > 1) {
|
|
409
|
+
const ids = nameMatches.map((m) => m.id).join(", ");
|
|
410
|
+
throw new errors_js_1.CoreAPIError(`Custom API name ${JSON.stringify(ref)} matches multiple custom APIs (${ids}); pass the custom API ID instead.`, { status: 409, code: "ambiguous_custom_api", param });
|
|
411
|
+
}
|
|
412
|
+
else {
|
|
413
|
+
throw new errors_js_1.CoreAPIError(`Custom API ${JSON.stringify(ref)} was not found. Create it with client.sarvam.customApis.create(...) or check client.sarvam.customApis.list().`, { status: 404, code: "custom_api_not_found", param });
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
if (!seen.has(match.id)) {
|
|
417
|
+
seen.add(match.id);
|
|
418
|
+
resolved.push(match);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
return resolved;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
exports.CustomApis = CustomApis;
|
package/dist/compat/core/data.js
CHANGED
|
@@ -16,7 +16,7 @@ exports.REFUSALS = [
|
|
|
16
16
|
"path": "environment.vault_ids",
|
|
17
17
|
"param": "environment.vault_ids",
|
|
18
18
|
"reason": "OpenAI vaults are not supported",
|
|
19
|
-
"hint": "Configure agent apps or custom APIs via sarvam_config={'
|
|
19
|
+
"hint": "Configure agent apps via sarvam_config={'apps': [...]} or custom APIs via sarvam_config={'custom_apis': [...]}.",
|
|
20
20
|
"needs": null,
|
|
21
21
|
"feature": "openai.environment.vault_ids"
|
|
22
22
|
},
|
|
@@ -3,6 +3,7 @@ import { SessionUpdateQueue } from "../core/sessions.js";
|
|
|
3
3
|
import { ToolResultStore } from "../core/toolResults.js";
|
|
4
4
|
import { ListenerRegistry } from "../core/turns.js";
|
|
5
5
|
import { AgentsResource } from "./resources/agents.js";
|
|
6
|
+
import { SarvamResource } from "./resources/sarvam.js";
|
|
6
7
|
import { SessionsResource } from "./resources/sessions.js";
|
|
7
8
|
import type { AgentSessionEventStream } from "./stream.js";
|
|
8
9
|
import type { AgentSession, RawResponse, RequestOptions } from "./types.js";
|
|
@@ -44,11 +45,13 @@ export interface RawResponseClient {
|
|
|
44
45
|
readonly beta: {
|
|
45
46
|
readonly agents: RawResponseAgentsResource;
|
|
46
47
|
};
|
|
48
|
+
readonly sarvam: RawResponseProxy<SarvamResource>;
|
|
47
49
|
}
|
|
48
50
|
export declare class OpenAI {
|
|
49
51
|
readonly beta: {
|
|
50
52
|
readonly agents: AgentsResource;
|
|
51
53
|
};
|
|
54
|
+
readonly sarvam: SarvamResource;
|
|
52
55
|
private readonly initOpts;
|
|
53
56
|
private readonly http;
|
|
54
57
|
private readonly listenerRegistry;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.OpenAI = void 0;
|
|
4
4
|
/** OpenAI drop-in client (client.beta.agents...) backed by compat/core. */
|
|
5
5
|
const agents_js_1 = require("../core/agents.js");
|
|
6
|
+
const customApis_js_1 = require("../core/customApis.js");
|
|
6
7
|
const errors_js_1 = require("../core/errors.js");
|
|
7
8
|
const files_js_1 = require("../core/files.js");
|
|
8
9
|
const http_js_1 = require("../core/http.js");
|
|
@@ -13,6 +14,7 @@ const turns_js_1 = require("../core/turns.js");
|
|
|
13
14
|
const errors_js_2 = require("./errors.js");
|
|
14
15
|
const agents_js_2 = require("./resources/agents.js");
|
|
15
16
|
const events_js_1 = require("./resources/events.js");
|
|
17
|
+
const sarvam_js_1 = require("./resources/sarvam.js");
|
|
16
18
|
const sessions_js_2 = require("./resources/sessions.js");
|
|
17
19
|
function makeRawProxy(target, http) {
|
|
18
20
|
return new Proxy(target, {
|
|
@@ -66,7 +68,8 @@ class OpenAI {
|
|
|
66
68
|
strict: opts.strictModels,
|
|
67
69
|
provider: "openai",
|
|
68
70
|
});
|
|
69
|
-
const
|
|
71
|
+
const customApisCore = new customApis_js_1.CustomApis(this.http);
|
|
72
|
+
const agentsCore = new agents_js_1.Agents(this.http, models, customApisCore);
|
|
70
73
|
this.sessionUpdateQueue = (_c = opts._sharedSessionQueue) !== null && _c !== void 0 ? _c : new sessions_js_1.SessionUpdateQueue();
|
|
71
74
|
const sessionsCore = new sessions_js_1.Sessions(this.http, { provider: "openai", updateQueue: this.sessionUpdateQueue });
|
|
72
75
|
this.listenerRegistry = (_d = opts._sharedRegistry) !== null && _d !== void 0 ? _d : new turns_js_1.ListenerRegistry();
|
|
@@ -86,6 +89,7 @@ class OpenAI {
|
|
|
86
89
|
const sessionsRes = new sessions_js_2.SessionsResource(this.http, agentsCore, sessionsCore, turnsCore, eventsRes, itemsRes);
|
|
87
90
|
const agentsRes = new agents_js_2.AgentsResource(this.http, agentsCore, sessionsRes);
|
|
88
91
|
this.beta = { agents: agentsRes };
|
|
92
|
+
this.sarvam = new sarvam_js_1.SarvamResource(this.http, customApisCore);
|
|
89
93
|
}
|
|
90
94
|
get withRawResponse() {
|
|
91
95
|
return makeRawProxy(this, this.http);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** OpenAI Hosted Agents API drop-in compatibility module. */
|
|
2
|
+
export type { CustomApiInfo, CustomApiAttachedAgent, CustomApiAgentEntry, CustomApiAuthInput, CustomApiHeaderInput, CustomApiCreateParams, CustomApiUpdateParams, } from "../core/customApis.js";
|
|
2
3
|
export { SarvamCompatWarning } from "../core/warnings.js";
|
|
3
4
|
export { OpenAIError, APIError, APIConnectionError, APITimeoutError, APIUserAbortError, APIStatusError, BadRequestError, UnsupportedFeatureError, AuthenticationError, PermissionDeniedError, NotFoundError, ConflictError, UnprocessableEntityError, RateLimitError, InternalServerError, } from "./errors.js";
|
|
4
5
|
export { NOT_GIVEN, NotGiven } from "./types.js";
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OpenAI = exports.AgentSessionEventStream = exports.SyncCursorPage = exports.NotGiven = exports.NOT_GIVEN = exports.InternalServerError = exports.RateLimitError = exports.UnprocessableEntityError = exports.ConflictError = exports.NotFoundError = exports.PermissionDeniedError = exports.AuthenticationError = exports.UnsupportedFeatureError = exports.BadRequestError = exports.APIStatusError = exports.APIUserAbortError = exports.APITimeoutError = exports.APIConnectionError = exports.APIError = exports.OpenAIError = exports.SarvamCompatWarning = void 0;
|
|
4
4
|
exports.SarvamAgents = SarvamAgents;
|
|
5
|
-
/** OpenAI Hosted Agents API drop-in compatibility module. */
|
|
6
5
|
var warnings_js_1 = require("../core/warnings.js");
|
|
7
6
|
Object.defineProperty(exports, "SarvamCompatWarning", { enumerable: true, get: function () { return warnings_js_1.SarvamCompatWarning; } });
|
|
8
7
|
var errors_js_1 = require("./errors.js");
|
|
@@ -374,6 +374,13 @@ function recordToAgent(rec) {
|
|
|
374
374
|
const multiAgent = spec.multiAgentEnabled !== null && spec.multiAgentEnabled !== undefined
|
|
375
375
|
? { enabled: spec.multiAgentEnabled }
|
|
376
376
|
: null;
|
|
377
|
+
const sarvamInfo = { model: rec.sarvamModel, version: rec.version };
|
|
378
|
+
if (rec.customApis.length > 0) {
|
|
379
|
+
sarvamInfo["custom_apis"] = rec.customApis.map((c) => ({ ...c }));
|
|
380
|
+
}
|
|
381
|
+
if (rec.unmanagedCustomApis.length > 0) {
|
|
382
|
+
sarvamInfo["unmanaged_custom_apis"] = rec.unmanagedCustomApis.map((c) => ({ ...c }));
|
|
383
|
+
}
|
|
377
384
|
return {
|
|
378
385
|
id: rec.id,
|
|
379
386
|
object: "agent",
|
|
@@ -387,7 +394,7 @@ function recordToAgent(rec) {
|
|
|
387
394
|
tool_choice: (_f = spec.toolChoice) !== null && _f !== void 0 ? _f : null,
|
|
388
395
|
multi_agent: multiAgent,
|
|
389
396
|
metadata: { ...spec.metadata },
|
|
390
|
-
sarvam:
|
|
397
|
+
sarvam: sarvamInfo,
|
|
391
398
|
};
|
|
392
399
|
}
|
|
393
400
|
class RefusedResource {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Sarvam-specific helper namespace (client.sarvam.customApis). */
|
|
2
|
+
import { CustomApis, type CustomApiAgentEntry, type CustomApiCreateParams, type CustomApiInfo, type CustomApiUpdateParams } from "../../core/customApis.js";
|
|
3
|
+
import { Http } from "../../core/http.js";
|
|
4
|
+
import type { RequestOptions } from "../types.js";
|
|
5
|
+
export declare class CustomApisResource {
|
|
6
|
+
private readonly http;
|
|
7
|
+
private readonly core;
|
|
8
|
+
constructor(http: Http, core: CustomApis);
|
|
9
|
+
list(opts?: {
|
|
10
|
+
q?: string;
|
|
11
|
+
}, options?: RequestOptions): Promise<CustomApiInfo[]>;
|
|
12
|
+
get(customApiId: string, options?: RequestOptions): Promise<CustomApiInfo>;
|
|
13
|
+
retrieve(customApiId: string, options?: RequestOptions): Promise<CustomApiInfo>;
|
|
14
|
+
create(params: CustomApiCreateParams, options?: RequestOptions): Promise<CustomApiInfo>;
|
|
15
|
+
update(customApiId: string, params: CustomApiUpdateParams, options?: RequestOptions): Promise<CustomApiInfo>;
|
|
16
|
+
delete(customApiId: string, opts?: {
|
|
17
|
+
force?: boolean;
|
|
18
|
+
}, options?: RequestOptions): Promise<void>;
|
|
19
|
+
listForAgent(agentId: string, options?: RequestOptions): Promise<CustomApiAgentEntry[]>;
|
|
20
|
+
bind(agentId: string, customApiId: string, options?: RequestOptions): Promise<void>;
|
|
21
|
+
unbind(agentId: string, customApiId: string, options?: RequestOptions): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
export declare class SarvamResource {
|
|
24
|
+
readonly customApis: CustomApisResource;
|
|
25
|
+
constructor(http: Http, customApis: CustomApis);
|
|
26
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SarvamResource = exports.CustomApisResource = void 0;
|
|
4
|
+
const errors_js_1 = require("../errors.js");
|
|
5
|
+
function toPerCallOpts(options) {
|
|
6
|
+
if (!options)
|
|
7
|
+
return {};
|
|
8
|
+
return {
|
|
9
|
+
timeout: options.timeout,
|
|
10
|
+
maxRetries: options.maxRetries,
|
|
11
|
+
headers: options.headers,
|
|
12
|
+
query: options.query,
|
|
13
|
+
signal: options.signal,
|
|
14
|
+
idempotencyKey: options.idempotencyKey,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
class CustomApisResource {
|
|
18
|
+
constructor(http, core) {
|
|
19
|
+
this.http = http;
|
|
20
|
+
this.core = core;
|
|
21
|
+
}
|
|
22
|
+
async list(opts = {}, options) {
|
|
23
|
+
return (0, errors_js_1.wrapCoreErrors)(() => this.http.withRequestOptions(toPerCallOpts(options), () => this.core.list(opts)));
|
|
24
|
+
}
|
|
25
|
+
async get(customApiId, options) {
|
|
26
|
+
return (0, errors_js_1.wrapCoreErrors)(() => this.http.withRequestOptions(toPerCallOpts(options), () => this.core.get(customApiId)));
|
|
27
|
+
}
|
|
28
|
+
async retrieve(customApiId, options) {
|
|
29
|
+
return this.get(customApiId, options);
|
|
30
|
+
}
|
|
31
|
+
async create(params, options) {
|
|
32
|
+
return (0, errors_js_1.wrapCoreErrors)(() => this.http.withRequestOptions(toPerCallOpts(options), () => this.core.create(params)));
|
|
33
|
+
}
|
|
34
|
+
async update(customApiId, params, options) {
|
|
35
|
+
return (0, errors_js_1.wrapCoreErrors)(() => this.http.withRequestOptions(toPerCallOpts(options), () => this.core.update(customApiId, params)));
|
|
36
|
+
}
|
|
37
|
+
async delete(customApiId, opts = {}, options) {
|
|
38
|
+
await (0, errors_js_1.wrapCoreErrors)(() => this.http.withRequestOptions(toPerCallOpts(options), () => this.core.delete(customApiId, opts)));
|
|
39
|
+
}
|
|
40
|
+
async listForAgent(agentId, options) {
|
|
41
|
+
return (0, errors_js_1.wrapCoreErrors)(() => this.http.withRequestOptions(toPerCallOpts(options), () => this.core.listForAgent(agentId)));
|
|
42
|
+
}
|
|
43
|
+
async bind(agentId, customApiId, options) {
|
|
44
|
+
await (0, errors_js_1.wrapCoreErrors)(() => this.http.withRequestOptions(toPerCallOpts(options), () => this.core.bind(agentId, customApiId)));
|
|
45
|
+
}
|
|
46
|
+
async unbind(agentId, customApiId, options) {
|
|
47
|
+
await (0, errors_js_1.wrapCoreErrors)(() => this.http.withRequestOptions(toPerCallOpts(options), () => this.core.unbind(agentId, customApiId)));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.CustomApisResource = CustomApisResource;
|
|
51
|
+
class SarvamResource {
|
|
52
|
+
constructor(http, customApis) {
|
|
53
|
+
this.customApis = new CustomApisResource(http, customApis);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.SarvamResource = SarvamResource;
|
package/dist/compose/deploy.d.ts
CHANGED
|
@@ -10,13 +10,19 @@ export interface Deployment {
|
|
|
10
10
|
/** The live version, or while the agent is paused, the paused version (what `resumeAgent` brings back); undefined
|
|
11
11
|
* from a server without versions, or when no version was ever live. */
|
|
12
12
|
version?: number;
|
|
13
|
-
/** URLs of the webhooks that
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
/** URLs of the agent's webhooks that have no signing secret after this deploy: one it added whose secret it could
|
|
14
|
+
* not create (it warned why), or one deployed before whose secret is missing (deleted, perhaps on purpose; deploy
|
|
15
|
+
* never recreates it). Nothing is delivered to them: `client.webhooks.createSecret(agentId, url)` gives one. Left
|
|
16
|
+
* out when there are none. */
|
|
16
17
|
webhooksMissingSecret?: string[];
|
|
17
18
|
/** The token (and fire URL) of each bearer trigger this deploy created. The server shows a token only once: keep
|
|
18
19
|
* it now. Left out when nothing was minted; `client.triggers.list(agentId)` lists every trigger's URL. */
|
|
19
20
|
triggerTokens?: MintedTriggerToken[];
|
|
21
|
+
/** The signing secret this deploy created for each webhook it added (every webhook on a first deploy), by URL. Give each to its receiver
|
|
22
|
+
* now (`client.webhooks.getSecret` shows it again). A webhook that already had a secret keeps it and is not listed.
|
|
23
|
+
* The property is non-enumerable, so logging or serialising the deployment leaves it out. Left out when deploy
|
|
24
|
+
* created none. */
|
|
25
|
+
readonly webhookSecrets?: Readonly<Record<string, string>>;
|
|
20
26
|
}
|
|
21
27
|
/** Set (or clear, with null) the client used when deploy/remove/run get no client. */
|
|
22
28
|
export declare function setDefaultClient(config: Configuration | null): void;
|
|
@@ -30,6 +36,11 @@ export declare function resolveTransport(client?: Configuration, transport?: Tra
|
|
|
30
36
|
* saves any edits the owner left in the draft, so check the draft first. `strict: true` throws `DriftError` instead of
|
|
31
37
|
* overwriting fields edited outside the SDK. `adopt: agentId` takes over an agent made elsewhere. `version` is the live
|
|
32
38
|
* version (the paused one while paused).
|
|
39
|
+
*
|
|
40
|
+
* The deploy then creates the signing secret of each webhook it added (a URL not in the agent.json last deployed;
|
|
41
|
+
* every webhook on a first deploy) and returns it once in `webhookSecrets` (by URL). An existing secret is never
|
|
42
|
+
* rotated or overwritten, and a missing one on a webhook deployed before is never recreated: it is listed in
|
|
43
|
+
* `webhooksMissingSecret`.
|
|
33
44
|
*/
|
|
34
45
|
export declare function deploy(agent: Agent<OutputType | undefined>, opts?: {
|
|
35
46
|
client?: Configuration;
|