sarvam-agents-client 0.5.3 → 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/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/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/package.json +1 -1
- 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
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/** Sarvam-specific helper namespace (client.sarvam.customApis). */
|
|
2
|
+
import {
|
|
3
|
+
CustomApis,
|
|
4
|
+
type CustomApiAgentEntry,
|
|
5
|
+
type CustomApiCreateParams,
|
|
6
|
+
type CustomApiInfo,
|
|
7
|
+
type CustomApiUpdateParams,
|
|
8
|
+
} from "../../core/customApis.js";
|
|
9
|
+
import { Http, type PerCallRequestOptions } from "../../core/http.js";
|
|
10
|
+
import { wrapCoreErrors } from "../errors.js";
|
|
11
|
+
import type { RequestOptions } from "../types.js";
|
|
12
|
+
|
|
13
|
+
function toPerCallOpts(options?: RequestOptions): PerCallRequestOptions {
|
|
14
|
+
if (!options) return {};
|
|
15
|
+
return {
|
|
16
|
+
timeout: options.timeout,
|
|
17
|
+
maxRetries: options.maxRetries,
|
|
18
|
+
headers: options.headers,
|
|
19
|
+
query: options.query,
|
|
20
|
+
signal: options.signal,
|
|
21
|
+
idempotencyKey: options.idempotencyKey,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export class CustomApisResource {
|
|
26
|
+
constructor(
|
|
27
|
+
private readonly http: Http,
|
|
28
|
+
private readonly core: CustomApis,
|
|
29
|
+
) {}
|
|
30
|
+
|
|
31
|
+
async list(opts: { q?: string } = {}, options?: RequestOptions): Promise<CustomApiInfo[]> {
|
|
32
|
+
return wrapCoreErrors(() =>
|
|
33
|
+
this.http.withRequestOptions(toPerCallOpts(options), () => this.core.list(opts)),
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async get(customApiId: string, options?: RequestOptions): Promise<CustomApiInfo> {
|
|
38
|
+
return wrapCoreErrors(() =>
|
|
39
|
+
this.http.withRequestOptions(toPerCallOpts(options), () => this.core.get(customApiId)),
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async retrieve(customApiId: string, options?: RequestOptions): Promise<CustomApiInfo> {
|
|
44
|
+
return this.get(customApiId, options);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async create(params: CustomApiCreateParams, options?: RequestOptions): Promise<CustomApiInfo> {
|
|
48
|
+
return wrapCoreErrors(() =>
|
|
49
|
+
this.http.withRequestOptions(toPerCallOpts(options), () => this.core.create(params)),
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async update(
|
|
54
|
+
customApiId: string,
|
|
55
|
+
params: CustomApiUpdateParams,
|
|
56
|
+
options?: RequestOptions,
|
|
57
|
+
): Promise<CustomApiInfo> {
|
|
58
|
+
return wrapCoreErrors(() =>
|
|
59
|
+
this.http.withRequestOptions(toPerCallOpts(options), () => this.core.update(customApiId, params)),
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async delete(customApiId: string, opts: { force?: boolean } = {}, options?: RequestOptions): Promise<void> {
|
|
64
|
+
await wrapCoreErrors(() =>
|
|
65
|
+
this.http.withRequestOptions(toPerCallOpts(options), () => this.core.delete(customApiId, opts)),
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async listForAgent(agentId: string, options?: RequestOptions): Promise<CustomApiAgentEntry[]> {
|
|
70
|
+
return wrapCoreErrors(() =>
|
|
71
|
+
this.http.withRequestOptions(toPerCallOpts(options), () => this.core.listForAgent(agentId)),
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async bind(agentId: string, customApiId: string, options?: RequestOptions): Promise<void> {
|
|
76
|
+
await wrapCoreErrors(() =>
|
|
77
|
+
this.http.withRequestOptions(toPerCallOpts(options), () => this.core.bind(agentId, customApiId)),
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async unbind(agentId: string, customApiId: string, options?: RequestOptions): Promise<void> {
|
|
82
|
+
await wrapCoreErrors(() =>
|
|
83
|
+
this.http.withRequestOptions(toPerCallOpts(options), () => this.core.unbind(agentId, customApiId)),
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export class SarvamResource {
|
|
89
|
+
readonly customApis: CustomApisResource;
|
|
90
|
+
|
|
91
|
+
constructor(http: Http, customApis: CustomApis) {
|
|
92
|
+
this.customApis = new CustomApisResource(http, customApis);
|
|
93
|
+
}
|
|
94
|
+
}
|