sarvam-agents-client 0.5.1 → 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 (36) hide show
  1. package/dist/compat/core/data.js +5 -14
  2. package/dist/compat/core/events.d.ts +6 -0
  3. package/dist/compat/core/files.d.ts +65 -0
  4. package/dist/compat/core/files.js +851 -0
  5. package/dist/compat/core/history.js +32 -7
  6. package/dist/compat/core/http.d.ts +52 -0
  7. package/dist/compat/core/http.js +309 -0
  8. package/dist/compat/core/turns.d.ts +29 -0
  9. package/dist/compat/core/turns.js +163 -12
  10. package/dist/compat/openai/client.d.ts +5 -0
  11. package/dist/compat/openai/client.js +10 -2
  12. package/dist/compat/openai/resources/events.js +218 -21
  13. package/dist/compat/openai/resources/sessions.js +33 -4
  14. package/dist/esm/compat/core/data.js +5 -14
  15. package/dist/esm/compat/core/events.d.ts +6 -0
  16. package/dist/esm/compat/core/files.d.ts +65 -0
  17. package/dist/esm/compat/core/files.js +829 -0
  18. package/dist/esm/compat/core/history.js +32 -7
  19. package/dist/esm/compat/core/http.d.ts +52 -0
  20. package/dist/esm/compat/core/http.js +307 -0
  21. package/dist/esm/compat/core/turns.d.ts +29 -0
  22. package/dist/esm/compat/core/turns.js +162 -12
  23. package/dist/esm/compat/openai/client.d.ts +5 -0
  24. package/dist/esm/compat/openai/client.js +10 -2
  25. package/dist/esm/compat/openai/resources/events.js +209 -12
  26. package/dist/esm/compat/openai/resources/sessions.js +33 -4
  27. package/package.json +1 -1
  28. package/src/compat/core/data.ts +5 -14
  29. package/src/compat/core/events.ts +7 -1
  30. package/src/compat/core/files.ts +913 -0
  31. package/src/compat/core/history.ts +32 -7
  32. package/src/compat/core/http.ts +338 -1
  33. package/src/compat/core/turns.ts +214 -13
  34. package/src/compat/openai/client.ts +13 -1
  35. package/src/compat/openai/resources/events.ts +239 -12
  36. package/src/compat/openai/resources/sessions.ts +39 -4
@@ -202,21 +202,12 @@ exports.REFUSALS = [
202
202
  },
203
203
  {
204
204
  "provider": "openai",
205
- "path": "input.input_image",
205
+ "path": "input.input_image.detail",
206
206
  "param": "input",
207
- "reason": "image input parts are not supported yet in 0.6.0",
208
- "hint": "Planned for 0.6.2 once provider fixtures are confirmed.",
209
- "needs": "sdk: 0.6.2 image/file input",
210
- "feature": "openai.input.image"
211
- },
212
- {
213
- "provider": "openai",
214
- "path": "input.input_file",
215
- "param": "input",
216
- "reason": "file input parts are not supported yet in 0.6.0",
217
- "hint": "Planned for 0.6.2 once provider fixtures are confirmed.",
218
- "needs": "sdk: 0.6.2 image/file input",
219
- "feature": "openai.input.file"
207
+ "reason": "input_image.detail is not supported on agent sessions",
208
+ "hint": "Omit detail on input_image blocks; Sarvam ignores image detail tiers.",
209
+ "needs": null,
210
+ "feature": "openai.input.image.detail"
220
211
  },
221
212
  {
222
213
  "provider": "openai",
@@ -7,6 +7,11 @@ export interface Usage {
7
7
  reasoningTokens: number;
8
8
  totalTokens: number;
9
9
  }
10
+ export interface AttachmentRef {
11
+ fileId: string;
12
+ filename: string;
13
+ mediaType: string;
14
+ }
10
15
  export type TurnEvent = {
11
16
  kind: "turn_started";
12
17
  responseId: string;
@@ -21,6 +26,7 @@ export type TurnEvent = {
21
26
  kind: "text_done";
22
27
  itemId: string;
23
28
  text: string;
29
+ attachments?: AttachmentRef[];
24
30
  } | {
25
31
  kind: "reasoning_started";
26
32
  itemId: string;
@@ -0,0 +1,65 @@
1
+ import type { MessagePart } from "../../models/MessagePart.js";
2
+ import { Http } from "./http.js";
3
+ /** Matches Panja's artifact_contract.limits.MAX_UPLOAD_BYTES (20 MiB). */
4
+ export declare const MAX_UPLOAD_BYTES: number;
5
+ /** Maximum number of file/image attachments in a single message (below Panja's 32-attachment cap). */
6
+ export declare const MAX_ATTACHMENTS_PER_MESSAGE = 20;
7
+ /** Maximum combined size of all attachments in a single message (50 MiB). */
8
+ export declare const MAX_TOTAL_ATTACHMENT_BYTES: number;
9
+ export declare const MAX_REDIRECTS = 5;
10
+ export declare const DEFAULT_REMOTE_FETCH_TIMEOUT_MS = 30000;
11
+ export declare const ARTIFACT_URI_PREFIX = "artifact://";
12
+ export declare const ACCEPTED_IMAGE_MIMES: Set<string>;
13
+ export interface UploadedArtifact {
14
+ artifactId: string;
15
+ filename: string;
16
+ mediaType: string;
17
+ }
18
+ export declare class AttachmentUploadCache {
19
+ private readonly max;
20
+ private readonly store;
21
+ constructor(maxEntries?: number);
22
+ private keyOf;
23
+ get(sessionId: string, idempotencyKey: string, partIndex: number, sha256Hex: string): UploadedArtifact | undefined;
24
+ put(sessionId: string, idempotencyKey: string, partIndex: number, sha256Hex: string, artifact: UploadedArtifact): void;
25
+ evict(sessionId: string, idempotencyKey: string, partIndex: number, sha256Hex: string): void;
26
+ }
27
+ export declare function isOpenAIFileId(fileId: string): boolean;
28
+ export declare function normalizeMime(raw?: string | null): string | null;
29
+ export declare function inferMimeFromFilename(filename?: string | null): string | null;
30
+ export declare function sanitizeFilename(name: string | null | undefined, defaultStem: string, mediaType: string): string;
31
+ export declare function sniffImageMime(data: Uint8Array): string | null;
32
+ export declare function verifyImageBytes(data: Uint8Array, declaredMime: string | null | undefined, param?: string | null): string;
33
+ export declare function validateImageMime(mime: string | null | undefined, param?: string | null): string;
34
+ export declare function validateFileMime(mime: string | null | undefined, param?: string | null): string;
35
+ export declare function decodeBase64Bytes(raw: string, param?: string | null): Uint8Array;
36
+ export declare function parseDataUri(raw: string, param?: string | null): {
37
+ mime: string;
38
+ data: Uint8Array;
39
+ };
40
+ export declare function validateRemoteUrl(url: string, param?: string | null): string;
41
+ export declare function isBlockedIp(rawIp: string): boolean;
42
+ /**
43
+ * Validate that ``rawUrl`` does not target a private, loopback, link-local, or reserved address,
44
+ * and return the validated IP address to pin the socket connection to (closing the DNS rebinding
45
+ * TOCTOU gap), or ``null`` when ``allowPrivateRemoteUrls`` is enabled.
46
+ */
47
+ export declare function checkRemoteHostAllowed(http: Http, rawUrl: string, param?: string | null): Promise<string | null>;
48
+ export declare function fetchRemoteFile(http: Http, url: string, opts: {
49
+ kind: "image" | "file";
50
+ filename?: string | null;
51
+ mediaType?: string | null;
52
+ param?: string | null;
53
+ maxBytes?: number;
54
+ }): Promise<{
55
+ data: Uint8Array;
56
+ mediaType: string;
57
+ filename: string;
58
+ }>;
59
+ export declare function deleteArtifactBestEffort(http: Http, sessionId: string, artifactId: string): Promise<void>;
60
+ export declare function uploadArtifact(http: Http, sessionId: string, data: Uint8Array, opts: {
61
+ filename: string;
62
+ mediaType: string;
63
+ }): Promise<UploadedArtifact>;
64
+ export declare function listSessionArtifacts(http: Http, sessionId: string): Promise<Map<string, UploadedArtifact>>;
65
+ export declare function makeFileMessagePart(artifactId: string, filename: string, mediaType: string): MessagePart;