sarvam-agents-client 0.5.0 → 0.5.2

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 (151) hide show
  1. package/dist/compat/core/agents.d.ts +53 -0
  2. package/dist/compat/core/agents.js +338 -0
  3. package/dist/compat/core/data.d.ts +10 -0
  4. package/dist/compat/core/data.js +275 -0
  5. package/dist/compat/core/errors.d.ts +37 -0
  6. package/dist/compat/core/errors.js +155 -0
  7. package/dist/compat/core/events.d.ts +107 -0
  8. package/dist/compat/core/events.js +160 -0
  9. package/dist/compat/core/files.d.ts +65 -0
  10. package/dist/compat/core/files.js +851 -0
  11. package/dist/compat/core/history.d.ts +9 -0
  12. package/dist/compat/core/history.js +112 -0
  13. package/dist/compat/core/http.d.ts +112 -0
  14. package/dist/compat/core/http.js +753 -0
  15. package/dist/compat/core/ids.d.ts +4 -0
  16. package/dist/compat/core/ids.js +36 -0
  17. package/dist/compat/core/index.d.ts +14 -0
  18. package/dist/compat/core/index.js +30 -0
  19. package/dist/compat/core/models.d.ts +20 -0
  20. package/dist/compat/core/models.js +75 -0
  21. package/dist/compat/core/paging.d.ts +14 -0
  22. package/dist/compat/core/paging.js +124 -0
  23. package/dist/compat/core/refusals.d.ts +9 -0
  24. package/dist/compat/core/refusals.js +25 -0
  25. package/dist/compat/core/sessions.d.ts +65 -0
  26. package/dist/compat/core/sessions.js +317 -0
  27. package/dist/compat/core/toolResults.d.ts +43 -0
  28. package/dist/compat/core/toolResults.js +208 -0
  29. package/dist/compat/core/turns.d.ts +104 -0
  30. package/dist/compat/core/turns.js +504 -0
  31. package/dist/compat/core/warnings.d.ts +6 -0
  32. package/dist/compat/core/warnings.js +26 -0
  33. package/dist/compat/index.d.ts +3 -0
  34. package/dist/compat/index.js +9 -0
  35. package/dist/compat/openai/client.d.ts +62 -0
  36. package/dist/compat/openai/client.js +108 -0
  37. package/dist/compat/openai/errors.d.ts +72 -0
  38. package/dist/compat/openai/errors.js +150 -0
  39. package/dist/compat/openai/index.d.ts +14 -0
  40. package/dist/compat/openai/index.js +42 -0
  41. package/dist/compat/openai/pages.d.ts +19 -0
  42. package/dist/compat/openai/pages.js +39 -0
  43. package/dist/compat/openai/resources/agents.d.ts +36 -0
  44. package/dist/compat/openai/resources/agents.js +549 -0
  45. package/dist/compat/openai/resources/events.d.ts +23 -0
  46. package/dist/compat/openai/resources/events.js +485 -0
  47. package/dist/compat/openai/resources/sessions.d.ts +33 -0
  48. package/dist/compat/openai/resources/sessions.js +283 -0
  49. package/dist/compat/openai/stream.d.ts +40 -0
  50. package/dist/compat/openai/stream.js +585 -0
  51. package/dist/compat/openai/types.d.ts +125 -0
  52. package/dist/compat/openai/types.js +98 -0
  53. package/dist/compose/agent.d.ts +2 -0
  54. package/dist/compose/agent.js +27 -0
  55. package/dist/compose/functionTool.d.ts +2 -0
  56. package/dist/compose/functionTool.js +46 -0
  57. package/dist/compose/output.d.ts +2 -0
  58. package/dist/compose/output.js +15 -7
  59. package/dist/esm/compat/core/agents.d.ts +53 -0
  60. package/dist/esm/compat/core/agents.js +334 -0
  61. package/dist/esm/compat/core/data.d.ts +10 -0
  62. package/dist/esm/compat/core/data.js +272 -0
  63. package/dist/esm/compat/core/errors.d.ts +37 -0
  64. package/dist/esm/compat/core/errors.js +146 -0
  65. package/dist/esm/compat/core/events.d.ts +107 -0
  66. package/dist/esm/compat/core/events.js +156 -0
  67. package/dist/esm/compat/core/files.d.ts +65 -0
  68. package/dist/esm/compat/core/files.js +829 -0
  69. package/dist/esm/compat/core/history.d.ts +9 -0
  70. package/dist/esm/compat/core/history.js +109 -0
  71. package/dist/esm/compat/core/http.d.ts +112 -0
  72. package/dist/esm/compat/core/http.js +746 -0
  73. package/dist/esm/compat/core/ids.d.ts +4 -0
  74. package/dist/esm/compat/core/ids.js +30 -0
  75. package/dist/esm/compat/core/index.d.ts +14 -0
  76. package/dist/esm/compat/core/index.js +14 -0
  77. package/dist/esm/compat/core/models.d.ts +20 -0
  78. package/dist/esm/compat/core/models.js +71 -0
  79. package/dist/esm/compat/core/paging.d.ts +14 -0
  80. package/dist/esm/compat/core/paging.js +118 -0
  81. package/dist/esm/compat/core/refusals.d.ts +9 -0
  82. package/dist/esm/compat/core/refusals.js +21 -0
  83. package/dist/esm/compat/core/sessions.d.ts +65 -0
  84. package/dist/esm/compat/core/sessions.js +312 -0
  85. package/dist/esm/compat/core/toolResults.d.ts +43 -0
  86. package/dist/esm/compat/core/toolResults.js +203 -0
  87. package/dist/esm/compat/core/turns.d.ts +104 -0
  88. package/dist/esm/compat/core/turns.js +497 -0
  89. package/dist/esm/compat/core/warnings.d.ts +6 -0
  90. package/dist/esm/compat/core/warnings.js +20 -0
  91. package/dist/esm/compat/index.d.ts +3 -0
  92. package/dist/esm/compat/index.js +3 -0
  93. package/dist/esm/compat/openai/client.d.ts +62 -0
  94. package/dist/esm/compat/openai/client.js +104 -0
  95. package/dist/esm/compat/openai/errors.d.ts +72 -0
  96. package/dist/esm/compat/openai/errors.js +130 -0
  97. package/dist/esm/compat/openai/index.d.ts +14 -0
  98. package/dist/esm/compat/openai/index.js +17 -0
  99. package/dist/esm/compat/openai/pages.d.ts +19 -0
  100. package/dist/esm/compat/openai/pages.js +35 -0
  101. package/dist/esm/compat/openai/resources/agents.d.ts +36 -0
  102. package/dist/esm/compat/openai/resources/agents.js +540 -0
  103. package/dist/esm/compat/openai/resources/events.d.ts +23 -0
  104. package/dist/esm/compat/openai/resources/events.js +479 -0
  105. package/dist/esm/compat/openai/resources/sessions.d.ts +33 -0
  106. package/dist/esm/compat/openai/resources/sessions.js +278 -0
  107. package/dist/esm/compat/openai/stream.d.ts +40 -0
  108. package/dist/esm/compat/openai/stream.js +579 -0
  109. package/dist/esm/compat/openai/types.d.ts +125 -0
  110. package/dist/esm/compat/openai/types.js +91 -0
  111. package/dist/esm/compose/agent.d.ts +2 -0
  112. package/dist/esm/compose/agent.js +28 -2
  113. package/dist/esm/compose/functionTool.d.ts +2 -0
  114. package/dist/esm/compose/functionTool.js +45 -0
  115. package/dist/esm/compose/output.d.ts +2 -0
  116. package/dist/esm/compose/output.js +14 -7
  117. package/dist/esm/index.d.ts +2 -0
  118. package/dist/esm/index.js +2 -0
  119. package/dist/index.d.ts +2 -0
  120. package/dist/index.js +5 -1
  121. package/package.json +53 -11
  122. package/src/compat/core/agents.ts +437 -0
  123. package/src/compat/core/data.ts +283 -0
  124. package/src/compat/core/errors.ts +162 -0
  125. package/src/compat/core/events.ts +198 -0
  126. package/src/compat/core/files.ts +913 -0
  127. package/src/compat/core/history.ts +116 -0
  128. package/src/compat/core/http.ts +827 -0
  129. package/src/compat/core/ids.ts +35 -0
  130. package/src/compat/core/index.ts +14 -0
  131. package/src/compat/core/models.ts +85 -0
  132. package/src/compat/core/paging.ts +119 -0
  133. package/src/compat/core/refusals.ts +31 -0
  134. package/src/compat/core/sessions.ts +358 -0
  135. package/src/compat/core/toolResults.ts +235 -0
  136. package/src/compat/core/turns.ts +622 -0
  137. package/src/compat/core/warnings.ts +23 -0
  138. package/src/compat/index.ts +3 -0
  139. package/src/compat/openai/client.ts +177 -0
  140. package/src/compat/openai/errors.ts +165 -0
  141. package/src/compat/openai/index.ts +65 -0
  142. package/src/compat/openai/pages.ts +55 -0
  143. package/src/compat/openai/resources/agents.ts +603 -0
  144. package/src/compat/openai/resources/events.ts +523 -0
  145. package/src/compat/openai/resources/sessions.ts +369 -0
  146. package/src/compat/openai/stream.ts +599 -0
  147. package/src/compat/openai/types.ts +217 -0
  148. package/src/compose/agent.ts +30 -3
  149. package/src/compose/functionTool.ts +44 -0
  150. package/src/compose/output.ts +14 -8
  151. package/src/index.ts +3 -0
@@ -0,0 +1,91 @@
1
+ /** OpenAI-shaped types, RequestOptions, and validation helpers for compat/openai. */
2
+ import { CoreAPIError } from "../core/errors.js";
3
+ import { refuse } from "../core/refusals.js";
4
+ import { toOpenAIError } from "./errors.js";
5
+ export class NotGiven {
6
+ constructor() {
7
+ this._notGiven = true;
8
+ }
9
+ }
10
+ export const NOT_GIVEN = new NotGiven();
11
+ export function isoToEpoch(isoStr) {
12
+ if (!isoStr)
13
+ return null;
14
+ const ms = Date.parse(isoStr);
15
+ return Number.isNaN(ms) ? null : Math.floor(ms / 1000);
16
+ }
17
+ export function refuseOpenAI(path, opts) {
18
+ try {
19
+ refuse("openai", path, opts);
20
+ }
21
+ catch (err) {
22
+ if (err instanceof CoreAPIError)
23
+ throw toOpenAIError(err);
24
+ throw err;
25
+ }
26
+ }
27
+ export function checkExtraParams(params, known, options, prefix = "") {
28
+ var _a, _b;
29
+ let sarvamConfig = {};
30
+ const headers = { ...((_a = options === null || options === void 0 ? void 0 : options.headers) !== null && _a !== void 0 ? _a : {}) };
31
+ const query = { ...((_b = options === null || options === void 0 ? void 0 : options.query) !== null && _b !== void 0 ? _b : {}) };
32
+ let timeout = options === null || options === void 0 ? void 0 : options.timeout;
33
+ for (const [key, val] of Object.entries(params)) {
34
+ if (val === undefined || val instanceof NotGiven)
35
+ continue;
36
+ if (known.has(key))
37
+ continue;
38
+ if (key === "extra_headers") {
39
+ if (val !== null && typeof val === "object" && !Array.isArray(val)) {
40
+ for (const [hk, hv] of Object.entries(val))
41
+ headers[hk] = String(hv);
42
+ }
43
+ continue;
44
+ }
45
+ if (key === "extra_query") {
46
+ if (val !== null && typeof val === "object" && !Array.isArray(val)) {
47
+ for (const [qk, qv] of Object.entries(val)) {
48
+ if (qv !== undefined && qv !== null)
49
+ query[qk] = String(qv);
50
+ }
51
+ }
52
+ continue;
53
+ }
54
+ if (key === "timeout") {
55
+ if (typeof val === "number")
56
+ timeout = val;
57
+ continue;
58
+ }
59
+ if (key === "extra_body") {
60
+ if (val === null)
61
+ continue;
62
+ if (typeof val !== "object" || Array.isArray(val)) {
63
+ refuseOpenAI("extra_body", { param: "extra_body" });
64
+ }
65
+ for (const [bk, bv] of Object.entries(val)) {
66
+ if (bk === "sarvam_config") {
67
+ if (bv !== null && typeof bv === "object" && !Array.isArray(bv)) {
68
+ sarvamConfig = { ...sarvamConfig, ...bv };
69
+ }
70
+ }
71
+ else {
72
+ refuseOpenAI("extra_body", { param: `extra_body.${bk}` });
73
+ }
74
+ }
75
+ continue;
76
+ }
77
+ const path = prefix ? `${prefix}.${key}` : key;
78
+ refuseOpenAI(path, { reason: "unknown or unsupported parameter", param: path });
79
+ }
80
+ return {
81
+ sarvamConfig,
82
+ reqOpts: {
83
+ timeout,
84
+ maxRetries: options === null || options === void 0 ? void 0 : options.maxRetries,
85
+ headers: Object.keys(headers).length > 0 ? headers : undefined,
86
+ query: Object.keys(query).length > 0 ? query : undefined,
87
+ signal: options === null || options === void 0 ? void 0 : options.signal,
88
+ idempotencyKey: options === null || options === void 0 ? void 0 : options.idempotencyKey,
89
+ },
90
+ };
91
+ }
@@ -70,3 +70,5 @@ export declare class Agent<TOutput extends OutputType | undefined = undefined> {
70
70
  specHash(): string;
71
71
  toSettings(): Record<string, unknown>;
72
72
  }
73
+ /** Internal Agent builder for compat layers carrying raw `agent.json` settings (not re-exported from compose/index.ts). */
74
+ export declare function rawAgent(name: string, instructions: string, settings: Record<string, unknown>): Agent;
@@ -1,8 +1,8 @@
1
1
  import { NotSupportedError, UserError } from "./errors.js";
2
2
  import { settingsFingerprint } from "./fingerprint.js";
3
3
  import { BUILTIN_NAMES, checkWebSearchOptions } from "./builtins.js";
4
- import { DEFAULT_FUNCTION_TIMEOUT_SECONDS, FUNCTION_TIMEOUT_RANGE, FUNCTIONS_MAX, FUNCTIONS_TOTAL_MAX_BYTES, compactBytes, functionToolSettings, isBuiltFunctionTool, isFunctionTool, tool, } from "./functionTool.js";
5
- import { checkOutputType, outputSchema } from "./output.js";
4
+ import { DEFAULT_FUNCTION_TIMEOUT_SECONDS, FUNCTION_TIMEOUT_RANGE, FUNCTIONS_MAX, FUNCTIONS_TOTAL_MAX_BYTES, checkFunctionSpecs, compactBytes, functionToolSettings, isBuiltFunctionTool, isFunctionTool, tool, } from "./functionTool.js";
5
+ import { checkOutputSchema, checkOutputType, outputSchema } from "./output.js";
6
6
  import { checkWebhooks, copyWebhooks, webhooksJson } from "./webhook.js";
7
7
  import { checkTriggers, triggersJson } from "./trigger.js";
8
8
  const SLUG = /^[a-z0-9][a-z0-9-]{0,63}$/;
@@ -310,3 +310,29 @@ export class Agent {
310
310
  return out;
311
311
  }
312
312
  }
313
+ /** Internal Agent builder for compat layers carrying raw `agent.json` settings (not re-exported from compose/index.ts). */
314
+ export function rawAgent(name, instructions, settings) {
315
+ const checked = JSON.parse(JSON.stringify(settings));
316
+ if (checked["output_schema"] !== undefined && checked["output_schema"] !== null) {
317
+ checked["output_schema"] = checkOutputSchema(checked["output_schema"]);
318
+ }
319
+ if (Array.isArray(checked["functions"]) && checked["functions"].length > 0) {
320
+ checkFunctionSpecs(checked["functions"]);
321
+ }
322
+ const instance = Object.create(Agent.prototype);
323
+ Object.defineProperty(instance, "name", { value: name, enumerable: true, writable: false });
324
+ Object.defineProperty(instance, "instructions", { value: instructions, enumerable: true, writable: false });
325
+ Object.defineProperty(instance, "outputType", { value: undefined, enumerable: false, writable: false });
326
+ instance["specHash"] = () => settingsFingerprint(instructions, checked);
327
+ instance["toSettings"] = () => {
328
+ const out = JSON.parse(JSON.stringify(checked));
329
+ const meta = (out["metadata"] && typeof out["metadata"] === "object" && !Array.isArray(out["metadata"]))
330
+ ? { ...out["metadata"] } : {};
331
+ if (meta["sdk_name"] === undefined)
332
+ meta["sdk_name"] = name;
333
+ meta["sdk_hash"] = settingsFingerprint(instructions, checked);
334
+ out["metadata"] = meta;
335
+ return out;
336
+ };
337
+ return instance;
338
+ }
@@ -74,6 +74,8 @@ export declare function isFunctionTool(value: unknown): value is FunctionTool;
74
74
  export declare function isBuiltFunctionTool(value: unknown): value is FunctionTool;
75
75
  /** One `functions` entry of agent.json. */
76
76
  export declare function functionToolSettings(t: FunctionTool): Record<string, unknown>;
77
+ /** Validate raw `agent.json` `functions` entries under the server's rules (used by compat layers). */
78
+ export declare function checkFunctionSpecs(specs: Record<string, unknown>[]): void;
77
79
  /** One call's result, as posted to the server. */
78
80
  export interface FunctionResult {
79
81
  callId: string;
@@ -182,6 +182,51 @@ export function isBuiltFunctionTool(value) {
182
182
  export function functionToolSettings(t) {
183
183
  return { name: t.name, description: t.description, parameters: JSON.parse(JSON.stringify(t.parameters)) };
184
184
  }
185
+ /** Validate raw `agent.json` `functions` entries under the server's rules (used by compat layers). */
186
+ export function checkFunctionSpecs(specs) {
187
+ if (specs.length > FUNCTIONS_MAX) {
188
+ throw new UserError(`tools: at most ${FUNCTIONS_MAX} function tools (got ${specs.length})`);
189
+ }
190
+ const seen = new Set();
191
+ for (let i = 0; i < specs.length; i++) {
192
+ const spec = specs[i];
193
+ if (!isObject(spec))
194
+ throw new UserError(`tools[${i}]: function tool must be an object`);
195
+ const name = spec["name"];
196
+ if (typeof name !== "string" || !NAME_PATTERN.test(name)) {
197
+ throw new UserError(`tools[${i}].name: ${JSON.stringify(name)} must be letters, digits, _ or -, start with a letter or _, and be at most 64 characters`);
198
+ }
199
+ if (RESERVED_FUNCTION_NAMES.has(name)) {
200
+ throw new UserError(`tools[${i}].name: ${JSON.stringify(name)} is reserved: a built-in or platform tool has that name`);
201
+ }
202
+ if (seen.has(name))
203
+ throw new UserError(`tools[${i}].name: duplicate function tool ${JSON.stringify(name)}`);
204
+ seen.add(name);
205
+ const desc = spec["description"];
206
+ if (typeof desc !== "string" || chars(desc) < 1 || chars(desc) > DESCRIPTION_MAX_CHARS) {
207
+ throw new UserError(`tools[${i}].description: description must be 1 to ${DESCRIPTION_MAX_CHARS} characters.`);
208
+ }
209
+ const params = spec["parameters"];
210
+ if (!isObject(params) || params["type"] !== "object") {
211
+ throw new UserError(`tools[${i}].parameters: parameters must be a JSON schema with "type": "object".`);
212
+ }
213
+ if (containerDepth(params) > PARAMETERS_MAX_DEPTH) {
214
+ throw new UserError(`tools[${i}].parameters: parameters is nested more than ${PARAMETERS_MAX_DEPTH} levels.`);
215
+ }
216
+ const size = compactBytes(params);
217
+ if (size > PARAMETERS_MAX_BYTES) {
218
+ throw new UserError(`tools[${i}].parameters: parameters are ${size} bytes; the server allows at most 16 KB.`);
219
+ }
220
+ const problem = schemaProblem(params);
221
+ if (problem !== undefined) {
222
+ throw new UserError(`tools[${i}].parameters: parameters is not a valid JSON Schema: ${problem}`);
223
+ }
224
+ }
225
+ const total = specs.reduce((sum, s) => sum + compactBytes(s), 0);
226
+ if (total > FUNCTIONS_TOTAL_MAX_BYTES) {
227
+ throw new UserError(`tools: function tools are ${Math.ceil(total / 1024)} KB together; the server allows 64 KB`);
228
+ }
229
+ }
185
230
  /** Thrown by `runCalls` when its signal aborts. */
186
231
  export class CallsCancelled extends Error {
187
232
  }
@@ -29,6 +29,8 @@ export declare function sameKey(v: unknown): string;
29
29
  /** Why `schema` is not a valid JSON Schema for its `$schema` dialect (2020-12 when absent or unknown, as the server's
30
30
  * `validator_for` picks), or undefined. Checks the keywords the output-schema allowlist knows; others pass. */
31
31
  export declare function schemaProblem(schema: Record<string, unknown>): string | undefined;
32
+ /** Validate and inline a raw JSON Schema object under the server's `output_schema` rules. */
33
+ export declare function checkOutputSchema(rawInput: Record<string, unknown>): Record<string, unknown>;
32
34
  /** The output type's JSON Schema with definitions inlined, an OpenAPI `discriminator` and a no-op
33
35
  * `propertyNames: {type: "string"}` dropped, and a root `$schema` naming 2020-12 (what zod writes, and the server's
34
36
  * default) dropped; throws UserError on what the server refuses. Another `$schema` is kept, so the server reads the
@@ -405,13 +405,11 @@ function nodeProblem(node, draft, stack, path) {
405
405
  }
406
406
  return undefined;
407
407
  }
408
- /** The output type's JSON Schema with definitions inlined, an OpenAPI `discriminator` and a no-op
409
- * `propertyNames: {type: "string"}` dropped, and a root `$schema` naming 2020-12 (what zod writes, and the server's
410
- * default) dropped; throws UserError on what the server refuses. Another `$schema` is kept, so the server reads the
411
- * schema in the dialect it names, and must be draft-04 to 2020-12. A zod `.regex()`, `z.email()`, `z.uuid()`,
412
- * `z.url()` or `z.iso.datetime()` becomes a `pattern`, which it refuses. */
413
- export function outputSchema(outputType) {
414
- const raw = JSON.parse(JSON.stringify(isSchemaLike(outputType) ? outputType.toJSONSchema() : outputType.schema));
408
+ /** Validate and inline a raw JSON Schema object under the server's `output_schema` rules. */
409
+ export function checkOutputSchema(rawInput) {
410
+ if (!isObject(rawInput))
411
+ throw new UserError("outputType: the schema must be a JSON object");
412
+ const raw = JSON.parse(JSON.stringify(rawInput));
415
413
  const defs = { ...(isObject(raw["$defs"]) ? raw["$defs"] : {}), ...(isObject(raw["definitions"]) ? raw["definitions"] : {}) };
416
414
  delete raw["$defs"];
417
415
  delete raw["definitions"];
@@ -447,6 +445,15 @@ export function outputSchema(outputType) {
447
445
  }
448
446
  return schema;
449
447
  }
448
+ /** The output type's JSON Schema with definitions inlined, an OpenAPI `discriminator` and a no-op
449
+ * `propertyNames: {type: "string"}` dropped, and a root `$schema` naming 2020-12 (what zod writes, and the server's
450
+ * default) dropped; throws UserError on what the server refuses. Another `$schema` is kept, so the server reads the
451
+ * schema in the dialect it names, and must be draft-04 to 2020-12. A zod `.regex()`, `z.email()`, `z.uuid()`,
452
+ * `z.url()` or `z.iso.datetime()` becomes a `pattern`, which it refuses. */
453
+ export function outputSchema(outputType) {
454
+ const raw = isSchemaLike(outputType) ? outputType.toJSONSchema() : outputType.schema;
455
+ return checkOutputSchema(raw);
456
+ }
450
457
  /** `data-output`'s JSON as the output type's value; a schema-like type's `parse` must accept it, or this throws
451
458
  * `ModelBehaviorError` with `source: "local_parse"` and the server's `note`. */
452
459
  export function parseOutput(outputType, output, note) {
@@ -7,3 +7,5 @@ export { WebhookSecrets } from './compose/webhookSecrets.js';
7
7
  export type { SecretStatus } from './compose/webhookSecrets.js';
8
8
  export { Triggers, EVENT_WINDOW_DAYS, EVENTS_PAGE_DEFAULT, EVENTS_PAGE_MAX, GRACE_SECONDS_MAX, PROVIDER_OUTAGE_ERROR, SECRET_MAX_CHARS, } from './compose/triggers.js';
9
9
  export type { TriggerRef, TriggerSecretStatus } from './compose/triggers.js';
10
+ export { OpenAI, SarvamAgents } from './compat/index.js';
11
+ export type { OpenAIOptions, SarvamAgentsOptions } from './compat/index.js';
package/dist/esm/index.js CHANGED
@@ -9,3 +9,5 @@ export * from './streaming.js';
9
9
  export { Client } from './client.js';
10
10
  export { WebhookSecrets } from './compose/webhookSecrets.js';
11
11
  export { Triggers, EVENT_WINDOW_DAYS, EVENTS_PAGE_DEFAULT, EVENTS_PAGE_MAX, GRACE_SECONDS_MAX, PROVIDER_OUTAGE_ERROR, SECRET_MAX_CHARS, } from './compose/triggers.js';
12
+ // Hand-written: drop-in compatibility clients.
13
+ export { OpenAI, SarvamAgents } from './compat/index.js';
package/dist/index.d.ts CHANGED
@@ -7,3 +7,5 @@ export { WebhookSecrets } from './compose/webhookSecrets.js';
7
7
  export type { SecretStatus } from './compose/webhookSecrets.js';
8
8
  export { Triggers, EVENT_WINDOW_DAYS, EVENTS_PAGE_DEFAULT, EVENTS_PAGE_MAX, GRACE_SECONDS_MAX, PROVIDER_OUTAGE_ERROR, SECRET_MAX_CHARS, } from './compose/triggers.js';
9
9
  export type { TriggerRef, TriggerSecretStatus } from './compose/triggers.js';
10
+ export { OpenAI, SarvamAgents } from './compat/index.js';
11
+ export type { OpenAIOptions, SarvamAgentsOptions } from './compat/index.js';
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.SECRET_MAX_CHARS = exports.PROVIDER_OUTAGE_ERROR = exports.GRACE_SECONDS_MAX = exports.EVENTS_PAGE_MAX = exports.EVENTS_PAGE_DEFAULT = exports.EVENT_WINDOW_DAYS = exports.Triggers = exports.WebhookSecrets = exports.Client = void 0;
17
+ exports.SarvamAgents = exports.OpenAI = exports.SECRET_MAX_CHARS = exports.PROVIDER_OUTAGE_ERROR = exports.GRACE_SECONDS_MAX = exports.EVENTS_PAGE_MAX = exports.EVENTS_PAGE_DEFAULT = exports.EVENT_WINDOW_DAYS = exports.Triggers = exports.WebhookSecrets = exports.Client = void 0;
18
18
  /* tslint:disable */
19
19
  /* eslint-disable */
20
20
  // Hand-maintained entry point (listed in .openapi-generator-ignore): the generated exports plus the streaming helpers.
@@ -35,3 +35,7 @@ Object.defineProperty(exports, "EVENTS_PAGE_MAX", { enumerable: true, get: funct
35
35
  Object.defineProperty(exports, "GRACE_SECONDS_MAX", { enumerable: true, get: function () { return triggers_js_1.GRACE_SECONDS_MAX; } });
36
36
  Object.defineProperty(exports, "PROVIDER_OUTAGE_ERROR", { enumerable: true, get: function () { return triggers_js_1.PROVIDER_OUTAGE_ERROR; } });
37
37
  Object.defineProperty(exports, "SECRET_MAX_CHARS", { enumerable: true, get: function () { return triggers_js_1.SECRET_MAX_CHARS; } });
38
+ // Hand-written: drop-in compatibility clients.
39
+ var index_js_1 = require("./compat/index.js");
40
+ Object.defineProperty(exports, "OpenAI", { enumerable: true, get: function () { return index_js_1.OpenAI; } });
41
+ Object.defineProperty(exports, "SarvamAgents", { enumerable: true, get: function () { return index_js_1.SarvamAgents; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sarvam-agents-client",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "Client for the Sarvam Agents API: chat with an agent, exchange files with it, and set it up from your own code.",
5
5
  "author": "Sarvam AI <support@sarvam.ai>",
6
6
  "license": "MIT",
@@ -21,19 +21,54 @@
21
21
  "types": "./dist/index.d.ts",
22
22
  "exports": {
23
23
  ".": {
24
- "types": "./dist/index.d.ts",
25
- "import": "./dist/esm/index.js",
26
- "require": "./dist/index.js"
24
+ "import": {
25
+ "types": "./dist/esm/index.d.ts",
26
+ "default": "./dist/esm/index.js"
27
+ },
28
+ "require": {
29
+ "types": "./dist/index.d.ts",
30
+ "default": "./dist/index.js"
31
+ }
27
32
  },
28
33
  "./compose": {
29
- "types": "./dist/compose/index.d.ts",
30
- "import": "./dist/esm/compose/index.js",
31
- "require": "./dist/compose/index.js"
34
+ "import": {
35
+ "types": "./dist/esm/compose/index.d.ts",
36
+ "default": "./dist/esm/compose/index.js"
37
+ },
38
+ "require": {
39
+ "types": "./dist/compose/index.d.ts",
40
+ "default": "./dist/compose/index.js"
41
+ }
32
42
  },
33
43
  "./webhooks": {
34
- "types": "./dist/webhooks.d.ts",
35
- "import": "./dist/esm/webhooks.js",
36
- "require": "./dist/webhooks.js"
44
+ "import": {
45
+ "types": "./dist/esm/webhooks.d.ts",
46
+ "default": "./dist/esm/webhooks.js"
47
+ },
48
+ "require": {
49
+ "types": "./dist/webhooks.d.ts",
50
+ "default": "./dist/webhooks.js"
51
+ }
52
+ },
53
+ "./compat": {
54
+ "import": {
55
+ "types": "./dist/esm/compat/index.d.ts",
56
+ "default": "./dist/esm/compat/index.js"
57
+ },
58
+ "require": {
59
+ "types": "./dist/compat/index.d.ts",
60
+ "default": "./dist/compat/index.js"
61
+ }
62
+ },
63
+ "./compat/openai": {
64
+ "import": {
65
+ "types": "./dist/esm/compat/openai/index.d.ts",
66
+ "default": "./dist/esm/compat/openai/index.js"
67
+ },
68
+ "require": {
69
+ "types": "./dist/compat/openai/index.d.ts",
70
+ "default": "./dist/compat/openai/index.js"
71
+ }
37
72
  },
38
73
  "./package.json": "./package.json"
39
74
  },
@@ -48,7 +83,8 @@
48
83
  },
49
84
  "scripts": {
50
85
  "build": "tsc && tsc -p tsconfig.esm.json && node -e \"require('fs').writeFileSync('dist/esm/package.json', '{\\\"type\\\": \\\"module\\\"}')\"",
51
- "test": "tsc -p test/types/tsconfig.json && node --test test/*.test.mjs test/compose/*.test.mjs test/live/*.test.mjs",
86
+ "sync:compat": "node scripts/syncCompatData.mjs",
87
+ "test": "tsc -p test/types/tsconfig.json && tsc -p test/types/tsconfig.esm.json && node --test test/*.test.mjs test/compose/*.test.mjs test/compat/*.test.mjs test/live/*.test.mjs",
52
88
  "prepublishOnly": "npm run build && npm test"
53
89
  },
54
90
  "devDependencies": {
@@ -63,6 +99,12 @@
63
99
  ],
64
100
  "webhooks": [
65
101
  "./dist/webhooks.d.ts"
102
+ ],
103
+ "compat": [
104
+ "./dist/compat/index.d.ts"
105
+ ],
106
+ "compat/openai": [
107
+ "./dist/compat/openai/index.d.ts"
66
108
  ]
67
109
  }
68
110
  }