sarvam-agents-client 0.3.0 → 0.3.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.
- package/README.md +98 -1
- package/dist/apis/FunctionToolsApi.d.ts +33 -0
- package/dist/apis/FunctionToolsApi.js +65 -0
- package/dist/apis/index.d.ts +1 -0
- package/dist/apis/index.js +1 -0
- package/dist/compose/agent.d.ts +20 -3
- package/dist/compose/agent.js +84 -7
- package/dist/compose/errors.d.ts +5 -1
- package/dist/compose/errors.js +4 -1
- package/dist/compose/events.d.ts +4 -0
- package/dist/compose/events.js +34 -0
- package/dist/compose/functionTool.d.ts +101 -0
- package/dist/compose/functionTool.js +420 -0
- package/dist/compose/index.d.ts +6 -2
- package/dist/compose/index.js +3 -1
- package/dist/compose/output.d.ts +11 -0
- package/dist/compose/output.js +32 -7
- package/dist/compose/run.d.ts +5 -1
- package/dist/compose/run.js +118 -25
- package/dist/compose/runState.d.ts +26 -1
- package/dist/compose/runState.js +30 -0
- package/dist/compose/settingsTransport.d.ts +28 -1
- package/dist/compose/settingsTransport.js +389 -7
- package/dist/compose/transport.d.ts +18 -1
- package/dist/compose/webhook.d.ts +19 -0
- package/dist/compose/webhook.js +184 -0
- package/dist/esm/apis/FunctionToolsApi.d.ts +33 -0
- package/dist/esm/apis/FunctionToolsApi.js +61 -0
- package/dist/esm/apis/index.d.ts +1 -0
- package/dist/esm/apis/index.js +1 -0
- package/dist/esm/compose/agent.d.ts +20 -3
- package/dist/esm/compose/agent.js +84 -7
- package/dist/esm/compose/errors.d.ts +5 -1
- package/dist/esm/compose/errors.js +4 -1
- package/dist/esm/compose/events.d.ts +4 -0
- package/dist/esm/compose/events.js +33 -0
- package/dist/esm/compose/functionTool.d.ts +101 -0
- package/dist/esm/compose/functionTool.js +406 -0
- package/dist/esm/compose/index.d.ts +6 -2
- package/dist/esm/compose/index.js +1 -0
- package/dist/esm/compose/output.d.ts +11 -0
- package/dist/esm/compose/output.js +30 -9
- package/dist/esm/compose/run.d.ts +5 -1
- package/dist/esm/compose/run.js +118 -25
- package/dist/esm/compose/runState.d.ts +26 -1
- package/dist/esm/compose/runState.js +31 -1
- package/dist/esm/compose/settingsTransport.d.ts +28 -1
- package/dist/esm/compose/settingsTransport.js +392 -11
- package/dist/esm/compose/transport.d.ts +18 -1
- package/dist/esm/compose/webhook.d.ts +19 -0
- package/dist/esm/compose/webhook.js +177 -0
- package/dist/esm/models/AgentConversationDetail.d.ts +7 -0
- package/dist/esm/models/AgentConversationDetail.js +3 -0
- package/dist/esm/models/ClarifyBody.d.ts +6 -0
- package/dist/esm/models/ClarifyBody.js +2 -0
- package/dist/esm/models/ConversationDetail.d.ts +7 -0
- package/dist/esm/models/ConversationDetail.js +3 -0
- package/dist/esm/models/ErrorDetail.d.ts +1 -0
- package/dist/esm/models/ErrorDetail.js +2 -1
- package/dist/esm/models/FunctionResultBody.d.ts +44 -0
- package/dist/esm/models/FunctionResultBody.js +49 -0
- package/dist/esm/models/QueueMessageInput.d.ts +23 -0
- package/dist/esm/models/QueueMessageInput.js +14 -0
- package/dist/esm/models/RequiredAction.d.ts +77 -0
- package/dist/esm/models/RequiredAction.js +69 -0
- package/dist/esm/models/ResponseDetail.d.ts +8 -0
- package/dist/esm/models/ResponseDetail.js +2 -0
- package/dist/esm/models/ResponseInput.d.ts +23 -0
- package/dist/esm/models/ResponseInput.js +14 -0
- package/dist/esm/models/ToolResults200Response.d.ts +38 -0
- package/dist/esm/models/ToolResults200Response.js +47 -0
- package/dist/esm/models/ToolResultsBody.d.ts +39 -0
- package/dist/esm/models/ToolResultsBody.js +48 -0
- package/dist/esm/models/index.d.ts +4 -0
- package/dist/esm/models/index.js +4 -0
- package/dist/esm/streaming.d.ts +14 -2
- package/dist/esm/streaming.js +26 -4
- package/dist/esm/webhooks.d.ts +203 -0
- package/dist/esm/webhooks.js +215 -0
- package/dist/models/AgentConversationDetail.d.ts +7 -0
- package/dist/models/AgentConversationDetail.js +3 -0
- package/dist/models/ClarifyBody.d.ts +6 -0
- package/dist/models/ClarifyBody.js +2 -0
- package/dist/models/ConversationDetail.d.ts +7 -0
- package/dist/models/ConversationDetail.js +3 -0
- package/dist/models/ErrorDetail.d.ts +1 -0
- package/dist/models/ErrorDetail.js +2 -1
- package/dist/models/FunctionResultBody.d.ts +44 -0
- package/dist/models/FunctionResultBody.js +56 -0
- package/dist/models/QueueMessageInput.d.ts +23 -0
- package/dist/models/QueueMessageInput.js +15 -1
- package/dist/models/RequiredAction.d.ts +77 -0
- package/dist/models/RequiredAction.js +77 -0
- package/dist/models/ResponseDetail.d.ts +8 -0
- package/dist/models/ResponseDetail.js +2 -0
- package/dist/models/ResponseInput.d.ts +23 -0
- package/dist/models/ResponseInput.js +15 -0
- package/dist/models/ToolResults200Response.d.ts +38 -0
- package/dist/models/ToolResults200Response.js +54 -0
- package/dist/models/ToolResultsBody.d.ts +39 -0
- package/dist/models/ToolResultsBody.js +55 -0
- package/dist/models/index.d.ts +4 -0
- package/dist/models/index.js +4 -0
- package/dist/streaming.d.ts +14 -2
- package/dist/streaming.js +27 -4
- package/dist/webhooks.d.ts +203 -0
- package/dist/webhooks.js +224 -0
- package/package.json +9 -1
- package/src/apis/FunctionToolsApi.ts +102 -0
- package/src/apis/index.ts +1 -0
- package/src/compose/agent.ts +96 -9
- package/src/compose/errors.ts +7 -1
- package/src/compose/events.ts +30 -0
- package/src/compose/functionTool.ts +441 -0
- package/src/compose/index.ts +6 -2
- package/src/compose/output.ts +30 -9
- package/src/compose/run.ts +115 -18
- package/src/compose/runState.ts +44 -5
- package/src/compose/settingsTransport.ts +379 -8
- package/src/compose/transport.ts +24 -1
- package/src/compose/webhook.ts +181 -0
- package/src/models/AgentConversationDetail.ts +15 -0
- package/src/models/ClarifyBody.ts +8 -0
- package/src/models/ConversationDetail.ts +15 -0
- package/src/models/ErrorDetail.ts +2 -1
- package/src/models/FunctionResultBody.ts +83 -0
- package/src/models/QueueMessageInput.ts +28 -0
- package/src/models/RequiredAction.ts +128 -0
- package/src/models/ResponseDetail.ts +8 -0
- package/src/models/ResponseInput.ts +30 -0
- package/src/models/ToolResults200Response.ts +75 -0
- package/src/models/ToolResultsBody.ts +83 -0
- package/src/models/index.ts +4 -0
- package/src/streaming.ts +39 -3
- package/src/webhooks.ts +390 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Receive the agent's outbound webhooks: verify the signature, then parse the event.
|
|
3
|
+
*
|
|
4
|
+
* Panja signs every delivery in the Standard Webhooks format. Verify against the raw body bytes before parsing:
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { verify, parseEvent } from "sarvam-agents-client/webhooks";
|
|
8
|
+
* verify(rawBody, req.headers, "whsec_..."); // throws WebhookVerificationError
|
|
9
|
+
* const event = parseEvent(rawBody); // TurnCompletedEvent | TurnFailedEvent | ...
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* `verify` behaves exactly like the server's reference verifier (`claw_common/webhooks/signing.py`) and the Python
|
|
13
|
+
* SDK's, and is tested against the server's vectors (`shared/webhooks/vectors.json`). Nothing here logs, and no error
|
|
14
|
+
* carries a secret or a signature: errors carry only a closed `reason` token. Uses `node:crypto` only.
|
|
15
|
+
*/
|
|
16
|
+
import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
|
|
17
|
+
/**
|
|
18
|
+
* Every event an `agent.json` webhook may subscribe to. `approval.requested` is reserved: the server accepts it
|
|
19
|
+
* (with the save warning `event_reserved`) but never sends it yet.
|
|
20
|
+
*/
|
|
21
|
+
export const WEBHOOK_EVENTS = ["turn.completed", "turn.failed", "turn.requires_action", "approval.requested"];
|
|
22
|
+
const SECRET_PREFIX = "whsec_";
|
|
23
|
+
const SECRET_MIN_BYTES = 24;
|
|
24
|
+
const SECRET_MAX_BYTES = 64;
|
|
25
|
+
const SIGNATURE_PREFIX = "v1,";
|
|
26
|
+
export const DEFAULT_TOLERANCE_S = 300;
|
|
27
|
+
/** `verify` examines at most this many space-separated signature entries; the rest are ignored. */
|
|
28
|
+
export const MAX_SIGNATURES_EXAMINED = 10;
|
|
29
|
+
/**
|
|
30
|
+
* A longer `webhook-timestamp` is refused as `bad_timestamp`, as on the server (where `int()` caps out at 4300
|
|
31
|
+
* digits); no real time needs more than 20.
|
|
32
|
+
*/
|
|
33
|
+
export const MAX_TIMESTAMP_DIGITS = 20;
|
|
34
|
+
/** A secret is not `whsec_` + base64 of 24 to 64 bytes. The message is the reason alone, never the secret. */
|
|
35
|
+
export class SecretFormatError extends Error {
|
|
36
|
+
constructor(reason) {
|
|
37
|
+
super(reason);
|
|
38
|
+
this.name = "SecretFormatError";
|
|
39
|
+
this.reason = reason;
|
|
40
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** A delivery failed verification. The message is the reason alone. */
|
|
44
|
+
export class WebhookVerificationError extends Error {
|
|
45
|
+
constructor(reason) {
|
|
46
|
+
super(reason);
|
|
47
|
+
this.name = "WebhookVerificationError";
|
|
48
|
+
this.reason = reason;
|
|
49
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const B64 = /^[A-Za-z0-9+/]*={0,2}$/;
|
|
53
|
+
/**
|
|
54
|
+
* Python 3.12's `base64.b64decode(s, validate=True)`: the standard alphabet, padding only at the end and only where
|
|
55
|
+
* it completes the last group; leftover bits in the last character are ignored. Returns null when it would refuse.
|
|
56
|
+
*/
|
|
57
|
+
function b64decodeStrict(text) {
|
|
58
|
+
if (!B64.test(text))
|
|
59
|
+
return null;
|
|
60
|
+
const data = text.replace(/=+$/, "");
|
|
61
|
+
const pads = text.length - data.length;
|
|
62
|
+
const rem = data.length % 4;
|
|
63
|
+
if (!((rem === 0 && pads === 0) || (rem === 2 && pads === 2) || (rem === 3 && pads === 1)))
|
|
64
|
+
return null;
|
|
65
|
+
return Buffer.from(text, "base64");
|
|
66
|
+
}
|
|
67
|
+
function parseSecret(secret) {
|
|
68
|
+
if (typeof secret !== "string" || !secret.startsWith(SECRET_PREFIX))
|
|
69
|
+
throw new SecretFormatError("prefix");
|
|
70
|
+
const key = b64decodeStrict(secret.slice(SECRET_PREFIX.length));
|
|
71
|
+
if (key === null)
|
|
72
|
+
throw new SecretFormatError("base64");
|
|
73
|
+
if (key.length < SECRET_MIN_BYTES || key.length > SECRET_MAX_BYTES)
|
|
74
|
+
throw new SecretFormatError("length");
|
|
75
|
+
return key;
|
|
76
|
+
}
|
|
77
|
+
function bodyBytes(payload) {
|
|
78
|
+
if (typeof payload === "string")
|
|
79
|
+
return Buffer.from(payload, "utf8");
|
|
80
|
+
return Buffer.from(payload.buffer, payload.byteOffset, payload.byteLength);
|
|
81
|
+
}
|
|
82
|
+
function mac(key, msgId, timestamp, body) {
|
|
83
|
+
// The exact bytes received; the timestamp is the header string as received (never re-stringified).
|
|
84
|
+
return createHmac("sha256", key).update(Buffer.from(`${msgId}.${timestamp}.`, "utf8")).update(body).digest();
|
|
85
|
+
}
|
|
86
|
+
/** Lowercased name -> value; for a plain object the last spelling of a name wins, as in the Python verifier. */
|
|
87
|
+
function lowerHeaders(headers) {
|
|
88
|
+
const out = new Map();
|
|
89
|
+
if (typeof headers.forEach === "function" &&
|
|
90
|
+
typeof headers.get === "function") {
|
|
91
|
+
headers
|
|
92
|
+
.forEach((value, key) => out.set(key.toLowerCase(), value));
|
|
93
|
+
return out;
|
|
94
|
+
}
|
|
95
|
+
for (const key of Object.keys(headers))
|
|
96
|
+
out.set(key.toLowerCase(), headers[key]);
|
|
97
|
+
return out;
|
|
98
|
+
}
|
|
99
|
+
function header(headers, name) {
|
|
100
|
+
const value = headers.get(name);
|
|
101
|
+
return typeof value === "string" ? value : "";
|
|
102
|
+
}
|
|
103
|
+
// Python's str.split() with no argument: runs of str.isspace() characters (not JavaScript's \s, which adds U+FEFF
|
|
104
|
+
// and lacks U+001C..U+001F and U+0085).
|
|
105
|
+
const PY_WHITESPACE = /[\t\n\v\f\r\x1c-\x20\x85\xa0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000]+/;
|
|
106
|
+
function splitWhitespace(text) {
|
|
107
|
+
return text.split(PY_WHITESPACE).filter((part) => part.length > 0);
|
|
108
|
+
}
|
|
109
|
+
/** A fresh `whsec_` secret of `nbytes` (24 to 64) random bytes, to store as the webhook's vault credential. */
|
|
110
|
+
export function generateSecret(nbytes = 32) {
|
|
111
|
+
if (!Number.isInteger(nbytes) || nbytes < SECRET_MIN_BYTES || nbytes > SECRET_MAX_BYTES) {
|
|
112
|
+
throw new SecretFormatError("length");
|
|
113
|
+
}
|
|
114
|
+
return SECRET_PREFIX + randomBytes(nbytes).toString("base64");
|
|
115
|
+
}
|
|
116
|
+
/** `"v1,<base64 HMAC-SHA256>"` over `{msgId}.{timestamp}.{body}`, as the server signs (for tests). */
|
|
117
|
+
export function sign(secret, msg) {
|
|
118
|
+
return SIGNATURE_PREFIX + mac(parseSecret(secret), msg.msgId, String(msg.timestamp), bodyBytes(msg.body))
|
|
119
|
+
.toString("base64");
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Verify a delivery; throws `WebhookVerificationError` (or `SecretFormatError`) if it fails.
|
|
123
|
+
*
|
|
124
|
+
* `payload` is the raw request body (a `Buffer` from `express.raw()`, or the exact text), before any JSON parsing.
|
|
125
|
+
* `secret` is one `whsec_` secret, or several while you rotate. The `webhook-timestamp` must be 1 to 20 ASCII digits
|
|
126
|
+
* within `tolerance` seconds of `now`; it is checked before any HMAC work. Only the first 10 `webhook-signature`
|
|
127
|
+
* entries are examined and entries not starting `v1,` are skipped. Comparisons are constant time. A header given as
|
|
128
|
+
* an array counts as missing. Throws `TypeError` when `now` or `tolerance` is not a finite number, or `tolerance` is
|
|
129
|
+
* negative: `Number(process.env.UNSET)` is NaN, which would quietly turn off the timestamp check. An empty list of
|
|
130
|
+
* secrets throws `TypeError` too: a receiver missing its secret would otherwise refuse every delivery as forged.
|
|
131
|
+
*/
|
|
132
|
+
export function verify(payload, headers, secret, opts = {}) {
|
|
133
|
+
var _a, _b;
|
|
134
|
+
const now = (_a = opts.now) !== null && _a !== void 0 ? _a : Math.floor(Date.now() / 1000);
|
|
135
|
+
const tolerance = (_b = opts.tolerance) !== null && _b !== void 0 ? _b : DEFAULT_TOLERANCE_S;
|
|
136
|
+
if (!Number.isFinite(now) || !Number.isFinite(tolerance) || tolerance < 0) {
|
|
137
|
+
throw new TypeError("verify: now and tolerance must be finite numbers, and tolerance not negative");
|
|
138
|
+
}
|
|
139
|
+
const secrets = typeof secret === "string" ? [secret] : [...secret];
|
|
140
|
+
// A configuration error: as no_matching_signature it would refuse every genuine delivery.
|
|
141
|
+
if (secrets.length === 0)
|
|
142
|
+
throw new TypeError("verify: no secrets; pass at least one whsec_ secret");
|
|
143
|
+
const body = bodyBytes(payload);
|
|
144
|
+
const lowered = lowerHeaders(headers);
|
|
145
|
+
const msgId = header(lowered, "webhook-id");
|
|
146
|
+
const rawTs = header(lowered, "webhook-timestamp");
|
|
147
|
+
const rawSigs = header(lowered, "webhook-signature");
|
|
148
|
+
if (!msgId || !rawTs || !rawSigs)
|
|
149
|
+
throw new WebhookVerificationError("missing_header");
|
|
150
|
+
if (!/^[0-9]+$/.test(rawTs) || rawTs.length > MAX_TIMESTAMP_DIGITS) {
|
|
151
|
+
throw new WebhookVerificationError("bad_timestamp");
|
|
152
|
+
}
|
|
153
|
+
// Exact for every value near the clock; a larger one is far outside the tolerance either way.
|
|
154
|
+
const timestamp = Number(rawTs);
|
|
155
|
+
if (timestamp < now - tolerance)
|
|
156
|
+
throw new WebhookVerificationError("timestamp_too_old");
|
|
157
|
+
if (timestamp > now + tolerance)
|
|
158
|
+
throw new WebhookVerificationError("timestamp_too_new");
|
|
159
|
+
const received = [];
|
|
160
|
+
for (const entry of splitWhitespace(rawSigs).slice(0, MAX_SIGNATURES_EXAMINED)) {
|
|
161
|
+
if (!entry.startsWith(SIGNATURE_PREFIX))
|
|
162
|
+
continue;
|
|
163
|
+
const decoded = b64decodeStrict(entry.slice(SIGNATURE_PREFIX.length));
|
|
164
|
+
if (decoded !== null)
|
|
165
|
+
received.push(decoded);
|
|
166
|
+
}
|
|
167
|
+
let matched = false;
|
|
168
|
+
for (const s of secrets) {
|
|
169
|
+
const expected = mac(parseSecret(s), msgId, rawTs, body);
|
|
170
|
+
for (const candidate of received) {
|
|
171
|
+
// no early exit inside the loops: the work does not depend on which entry matches
|
|
172
|
+
if (candidate.length === expected.length && timingSafeEqual(candidate, expected))
|
|
173
|
+
matched = true;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (!matched)
|
|
177
|
+
throw new WebhookVerificationError("no_matching_signature");
|
|
178
|
+
return { msgId, timestamp };
|
|
179
|
+
}
|
|
180
|
+
const STATUS = new Map([
|
|
181
|
+
["turn.completed", "completed"],
|
|
182
|
+
["turn.failed", "failed"],
|
|
183
|
+
["turn.requires_action", "requires_action"],
|
|
184
|
+
]);
|
|
185
|
+
function isObject(value) {
|
|
186
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* The typed event of a verified body (raw bytes, text or an already-parsed object).
|
|
190
|
+
*
|
|
191
|
+
* Returns `undefined` for an event type this SDK release doesn't know (reply 2xx and skip it). Throws `TypeError`
|
|
192
|
+
* when the body is not a webhook event or its `data.status` doesn't match its type. Only the envelope is checked;
|
|
193
|
+
* the fields are typed as the server documents them.
|
|
194
|
+
*/
|
|
195
|
+
export function parseEvent(payload) {
|
|
196
|
+
let raw = payload;
|
|
197
|
+
if (typeof payload === "string" || payload instanceof Uint8Array) {
|
|
198
|
+
try {
|
|
199
|
+
raw = JSON.parse(typeof payload === "string" ? payload : bodyBytes(payload).toString("utf8"));
|
|
200
|
+
}
|
|
201
|
+
catch (_a) {
|
|
202
|
+
throw new TypeError("webhook body is not JSON");
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (!isObject(raw) || typeof raw.type !== "string")
|
|
206
|
+
throw new TypeError("webhook body is not an event: no string 'type'");
|
|
207
|
+
const status = STATUS.get(raw.type);
|
|
208
|
+
if (status === undefined)
|
|
209
|
+
return undefined;
|
|
210
|
+
if (typeof raw.id !== "string" || typeof raw.timestamp !== "string" || !isObject(raw.data) ||
|
|
211
|
+
raw.data.status !== status) {
|
|
212
|
+
throw new TypeError(`webhook body is not a ${raw.type} event`);
|
|
213
|
+
}
|
|
214
|
+
return raw;
|
|
215
|
+
}
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import type { UIMessage } from './UIMessage.js';
|
|
13
13
|
import type { FieldHighlight } from './FieldHighlight.js';
|
|
14
|
+
import type { RequiredAction } from './RequiredAction.js';
|
|
14
15
|
import type { QueuedTurnView } from './QueuedTurnView.js';
|
|
15
16
|
/**
|
|
16
17
|
*
|
|
@@ -134,6 +135,12 @@ export interface AgentConversationDetail {
|
|
|
134
135
|
* @memberof AgentConversationDetail
|
|
135
136
|
*/
|
|
136
137
|
queuedTurns?: Array<QueuedTurnView>;
|
|
138
|
+
/**
|
|
139
|
+
*
|
|
140
|
+
* @type {Array<RequiredAction>}
|
|
141
|
+
* @memberof AgentConversationDetail
|
|
142
|
+
*/
|
|
143
|
+
requiredActions?: Array<RequiredAction>;
|
|
137
144
|
/**
|
|
138
145
|
*
|
|
139
146
|
* @type {boolean}
|
|
@@ -20,6 +20,7 @@ exports.AgentConversationDetailToJSON = AgentConversationDetailToJSON;
|
|
|
20
20
|
exports.AgentConversationDetailToJSONTyped = AgentConversationDetailToJSONTyped;
|
|
21
21
|
const UIMessage_js_1 = require("./UIMessage.js");
|
|
22
22
|
const FieldHighlight_js_1 = require("./FieldHighlight.js");
|
|
23
|
+
const RequiredAction_js_1 = require("./RequiredAction.js");
|
|
23
24
|
const QueuedTurnView_js_1 = require("./QueuedTurnView.js");
|
|
24
25
|
/**
|
|
25
26
|
* Check if a given object implements the AgentConversationDetail interface.
|
|
@@ -86,6 +87,7 @@ function AgentConversationDetailFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
86
87
|
'hasMore': json['hasMore'] == null ? undefined : json['hasMore'],
|
|
87
88
|
'nextBeforeCursor': json['nextBeforeCursor'] == null ? undefined : json['nextBeforeCursor'],
|
|
88
89
|
'queuedTurns': json['queuedTurns'] == null ? undefined : (json['queuedTurns'].map(QueuedTurnView_js_1.QueuedTurnViewFromJSON)),
|
|
90
|
+
'requiredActions': json['requiredActions'] == null ? undefined : (json['requiredActions'].map(RequiredAction_js_1.RequiredActionFromJSON)),
|
|
89
91
|
'isMine': json['isMine'] == null ? undefined : json['isMine'],
|
|
90
92
|
'panjaWsId': json['panjaWsId'],
|
|
91
93
|
'readOnly': json['readOnly'] == null ? undefined : json['readOnly'],
|
|
@@ -119,6 +121,7 @@ function AgentConversationDetailToJSONTyped(value, ignoreDiscriminator = false)
|
|
|
119
121
|
'hasMore': value['hasMore'],
|
|
120
122
|
'nextBeforeCursor': value['nextBeforeCursor'],
|
|
121
123
|
'queuedTurns': value['queuedTurns'] == null ? undefined : (value['queuedTurns'].map(QueuedTurnView_js_1.QueuedTurnViewToJSON)),
|
|
124
|
+
'requiredActions': value['requiredActions'] == null ? undefined : (value['requiredActions'].map(RequiredAction_js_1.RequiredActionToJSON)),
|
|
122
125
|
'isMine': value['isMine'],
|
|
123
126
|
'panjaWsId': value['panjaWsId'],
|
|
124
127
|
'readOnly': value['readOnly'],
|
|
@@ -37,6 +37,7 @@ function ClarifyBodyFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
37
37
|
'requestId': json['requestId'],
|
|
38
38
|
'action': json['action'] == null ? undefined : json['action'],
|
|
39
39
|
'answers': json['answers'] == null ? undefined : json['answers'],
|
|
40
|
+
'endUserId': json['endUserId'] == null ? undefined : json['endUserId'],
|
|
40
41
|
};
|
|
41
42
|
}
|
|
42
43
|
function ClarifyBodyToJSON(json) {
|
|
@@ -50,5 +51,6 @@ function ClarifyBodyToJSONTyped(value, ignoreDiscriminator = false) {
|
|
|
50
51
|
'requestId': value['requestId'],
|
|
51
52
|
'action': value['action'],
|
|
52
53
|
'answers': value['answers'],
|
|
54
|
+
'endUserId': value['endUserId'],
|
|
53
55
|
};
|
|
54
56
|
}
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import type { UIMessage } from './UIMessage.js';
|
|
13
13
|
import type { FieldHighlight } from './FieldHighlight.js';
|
|
14
|
+
import type { RequiredAction } from './RequiredAction.js';
|
|
14
15
|
import type { QueuedTurnView } from './QueuedTurnView.js';
|
|
15
16
|
/**
|
|
16
17
|
* GET /conversations/{id} — the list view plus the projected history and
|
|
@@ -135,6 +136,12 @@ export interface ConversationDetail {
|
|
|
135
136
|
* @memberof ConversationDetail
|
|
136
137
|
*/
|
|
137
138
|
queuedTurns?: Array<QueuedTurnView>;
|
|
139
|
+
/**
|
|
140
|
+
*
|
|
141
|
+
* @type {Array<RequiredAction>}
|
|
142
|
+
* @memberof ConversationDetail
|
|
143
|
+
*/
|
|
144
|
+
requiredActions?: Array<RequiredAction>;
|
|
138
145
|
}
|
|
139
146
|
/**
|
|
140
147
|
* Check if a given object implements the ConversationDetail interface.
|
|
@@ -20,6 +20,7 @@ exports.ConversationDetailToJSON = ConversationDetailToJSON;
|
|
|
20
20
|
exports.ConversationDetailToJSONTyped = ConversationDetailToJSONTyped;
|
|
21
21
|
const UIMessage_js_1 = require("./UIMessage.js");
|
|
22
22
|
const FieldHighlight_js_1 = require("./FieldHighlight.js");
|
|
23
|
+
const RequiredAction_js_1 = require("./RequiredAction.js");
|
|
23
24
|
const QueuedTurnView_js_1 = require("./QueuedTurnView.js");
|
|
24
25
|
/**
|
|
25
26
|
* Check if a given object implements the ConversationDetail interface.
|
|
@@ -84,6 +85,7 @@ function ConversationDetailFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
84
85
|
'hasMore': json['hasMore'] == null ? undefined : json['hasMore'],
|
|
85
86
|
'nextBeforeCursor': json['nextBeforeCursor'] == null ? undefined : json['nextBeforeCursor'],
|
|
86
87
|
'queuedTurns': json['queuedTurns'] == null ? undefined : (json['queuedTurns'].map(QueuedTurnView_js_1.QueuedTurnViewFromJSON)),
|
|
88
|
+
'requiredActions': json['requiredActions'] == null ? undefined : (json['requiredActions'].map(RequiredAction_js_1.RequiredActionFromJSON)),
|
|
87
89
|
};
|
|
88
90
|
}
|
|
89
91
|
function ConversationDetailToJSON(json) {
|
|
@@ -113,5 +115,6 @@ function ConversationDetailToJSONTyped(value, ignoreDiscriminator = false) {
|
|
|
113
115
|
'hasMore': value['hasMore'],
|
|
114
116
|
'nextBeforeCursor': value['nextBeforeCursor'],
|
|
115
117
|
'queuedTurns': value['queuedTurns'] == null ? undefined : (value['queuedTurns'].map(QueuedTurnView_js_1.QueuedTurnViewToJSON)),
|
|
118
|
+
'requiredActions': value['requiredActions'] == null ? undefined : (value['requiredActions'].map(RequiredAction_js_1.RequiredActionToJSON)),
|
|
116
119
|
};
|
|
117
120
|
}
|
|
@@ -58,6 +58,7 @@ export declare const ErrorDetailCodeEnum: {
|
|
|
58
58
|
readonly Unavailable: "CHAT_UNAVAILABLE";
|
|
59
59
|
readonly Upstream: "CHAT_UPSTREAM";
|
|
60
60
|
readonly Internal: "CHAT_INTERNAL";
|
|
61
|
+
readonly BalanceExhausted: "CHAT_BALANCE_EXHAUSTED";
|
|
61
62
|
};
|
|
62
63
|
export type ErrorDetailCodeEnum = typeof ErrorDetailCodeEnum[keyof typeof ErrorDetailCodeEnum];
|
|
63
64
|
/**
|
|
@@ -33,7 +33,8 @@ exports.ErrorDetailCodeEnum = {
|
|
|
33
33
|
RateLimit: 'CHAT_RATE_LIMIT',
|
|
34
34
|
Unavailable: 'CHAT_UNAVAILABLE',
|
|
35
35
|
Upstream: 'CHAT_UPSTREAM',
|
|
36
|
-
Internal: 'CHAT_INTERNAL'
|
|
36
|
+
Internal: 'CHAT_INTERNAL',
|
|
37
|
+
BalanceExhausted: 'CHAT_BALANCE_EXHAUSTED'
|
|
37
38
|
};
|
|
38
39
|
/**
|
|
39
40
|
* Check if a given object implements the ErrorDetail interface.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sarvam Agents API
|
|
3
|
+
* Chat with a Sarvam agent, exchange files with it, and set it up (instructions, skills, knowledge bases, connectors, deploy) from your own code. Authenticate with a service token sent as a Bearer token, and send the header X-Panja-Origin: managed_agents on every request.
|
|
4
|
+
*
|
|
5
|
+
* The version of the OpenAPI document: 0.1.0
|
|
6
|
+
* Contact: support@sarvam.ai
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
9
|
+
* https://openapi-generator.tech
|
|
10
|
+
* Do not edit the class manually.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* One call's result, as the app ran it.
|
|
14
|
+
* @export
|
|
15
|
+
* @interface FunctionResultBody
|
|
16
|
+
*/
|
|
17
|
+
export interface FunctionResultBody {
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @type {string}
|
|
21
|
+
* @memberof FunctionResultBody
|
|
22
|
+
*/
|
|
23
|
+
toolCallId: string;
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @type {string}
|
|
27
|
+
* @memberof FunctionResultBody
|
|
28
|
+
*/
|
|
29
|
+
output: string;
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @type {boolean}
|
|
33
|
+
* @memberof FunctionResultBody
|
|
34
|
+
*/
|
|
35
|
+
isError?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Check if a given object implements the FunctionResultBody interface.
|
|
39
|
+
*/
|
|
40
|
+
export declare function instanceOfFunctionResultBody(value: object): value is FunctionResultBody;
|
|
41
|
+
export declare function FunctionResultBodyFromJSON(json: any): FunctionResultBody;
|
|
42
|
+
export declare function FunctionResultBodyFromJSONTyped(json: any, ignoreDiscriminator: boolean): FunctionResultBody;
|
|
43
|
+
export declare function FunctionResultBodyToJSON(json: any): FunctionResultBody;
|
|
44
|
+
export declare function FunctionResultBodyToJSONTyped(value?: FunctionResultBody | null, ignoreDiscriminator?: boolean): any;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
/**
|
|
5
|
+
* Sarvam Agents API
|
|
6
|
+
* Chat with a Sarvam agent, exchange files with it, and set it up (instructions, skills, knowledge bases, connectors, deploy) from your own code. Authenticate with a service token sent as a Bearer token, and send the header X-Panja-Origin: managed_agents on every request.
|
|
7
|
+
*
|
|
8
|
+
* The version of the OpenAPI document: 0.1.0
|
|
9
|
+
* Contact: support@sarvam.ai
|
|
10
|
+
*
|
|
11
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
12
|
+
* https://openapi-generator.tech
|
|
13
|
+
* Do not edit the class manually.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.instanceOfFunctionResultBody = instanceOfFunctionResultBody;
|
|
17
|
+
exports.FunctionResultBodyFromJSON = FunctionResultBodyFromJSON;
|
|
18
|
+
exports.FunctionResultBodyFromJSONTyped = FunctionResultBodyFromJSONTyped;
|
|
19
|
+
exports.FunctionResultBodyToJSON = FunctionResultBodyToJSON;
|
|
20
|
+
exports.FunctionResultBodyToJSONTyped = FunctionResultBodyToJSONTyped;
|
|
21
|
+
/**
|
|
22
|
+
* Check if a given object implements the FunctionResultBody interface.
|
|
23
|
+
*/
|
|
24
|
+
function instanceOfFunctionResultBody(value) {
|
|
25
|
+
if (!('toolCallId' in value) || value['toolCallId'] === undefined)
|
|
26
|
+
return false;
|
|
27
|
+
if (!('output' in value) || value['output'] === undefined)
|
|
28
|
+
return false;
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
function FunctionResultBodyFromJSON(json) {
|
|
32
|
+
return FunctionResultBodyFromJSONTyped(json, false);
|
|
33
|
+
}
|
|
34
|
+
function FunctionResultBodyFromJSONTyped(json, ignoreDiscriminator) {
|
|
35
|
+
if (json == null) {
|
|
36
|
+
return json;
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
'toolCallId': json['toolCallId'],
|
|
40
|
+
'output': json['output'],
|
|
41
|
+
'isError': json['isError'] == null ? undefined : json['isError'],
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function FunctionResultBodyToJSON(json) {
|
|
45
|
+
return FunctionResultBodyToJSONTyped(json, false);
|
|
46
|
+
}
|
|
47
|
+
function FunctionResultBodyToJSONTyped(value, ignoreDiscriminator = false) {
|
|
48
|
+
if (value == null) {
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
'toolCallId': value['toolCallId'],
|
|
53
|
+
'output': value['output'],
|
|
54
|
+
'isError': value['isError'],
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -40,6 +40,18 @@ export interface QueueMessageInput {
|
|
|
40
40
|
* @memberof QueueMessageInput
|
|
41
41
|
*/
|
|
42
42
|
retryOf?: string | null;
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* @type {string}
|
|
46
|
+
* @memberof QueueMessageInput
|
|
47
|
+
*/
|
|
48
|
+
surface?: QueueMessageInputSurfaceEnum | null;
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* @type {string}
|
|
52
|
+
* @memberof QueueMessageInput
|
|
53
|
+
*/
|
|
54
|
+
endUserId?: string | null;
|
|
43
55
|
}
|
|
44
56
|
/**
|
|
45
57
|
* @export
|
|
@@ -49,6 +61,17 @@ export declare const QueueMessageInputDeliveryEnum: {
|
|
|
49
61
|
readonly Now: "now";
|
|
50
62
|
};
|
|
51
63
|
export type QueueMessageInputDeliveryEnum = typeof QueueMessageInputDeliveryEnum[keyof typeof QueueMessageInputDeliveryEnum];
|
|
64
|
+
/**
|
|
65
|
+
* @export
|
|
66
|
+
*/
|
|
67
|
+
export declare const QueueMessageInputSurfaceEnum: {
|
|
68
|
+
readonly Builder: "builder";
|
|
69
|
+
readonly Playground: "playground";
|
|
70
|
+
readonly Tests: "tests";
|
|
71
|
+
readonly Evals: "evals";
|
|
72
|
+
readonly Cowork: "cowork";
|
|
73
|
+
};
|
|
74
|
+
export type QueueMessageInputSurfaceEnum = typeof QueueMessageInputSurfaceEnum[keyof typeof QueueMessageInputSurfaceEnum];
|
|
52
75
|
/**
|
|
53
76
|
* Check if a given object implements the QueueMessageInput interface.
|
|
54
77
|
*/
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* Do not edit the class manually.
|
|
14
14
|
*/
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.QueueMessageInputDeliveryEnum = void 0;
|
|
16
|
+
exports.QueueMessageInputSurfaceEnum = exports.QueueMessageInputDeliveryEnum = void 0;
|
|
17
17
|
exports.instanceOfQueueMessageInput = instanceOfQueueMessageInput;
|
|
18
18
|
exports.QueueMessageInputFromJSON = QueueMessageInputFromJSON;
|
|
19
19
|
exports.QueueMessageInputFromJSONTyped = QueueMessageInputFromJSONTyped;
|
|
@@ -27,6 +27,16 @@ exports.QueueMessageInputDeliveryEnum = {
|
|
|
27
27
|
Queue: 'queue',
|
|
28
28
|
Now: 'now'
|
|
29
29
|
};
|
|
30
|
+
/**
|
|
31
|
+
* @export
|
|
32
|
+
*/
|
|
33
|
+
exports.QueueMessageInputSurfaceEnum = {
|
|
34
|
+
Builder: 'builder',
|
|
35
|
+
Playground: 'playground',
|
|
36
|
+
Tests: 'tests',
|
|
37
|
+
Evals: 'evals',
|
|
38
|
+
Cowork: 'cowork'
|
|
39
|
+
};
|
|
30
40
|
/**
|
|
31
41
|
* Check if a given object implements the QueueMessageInput interface.
|
|
32
42
|
*/
|
|
@@ -47,6 +57,8 @@ function QueueMessageInputFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
47
57
|
'delivery': json['delivery'] == null ? undefined : json['delivery'],
|
|
48
58
|
'agentId': json['agentId'] == null ? undefined : json['agentId'],
|
|
49
59
|
'retryOf': json['retryOf'] == null ? undefined : json['retryOf'],
|
|
60
|
+
'surface': json['surface'] == null ? undefined : json['surface'],
|
|
61
|
+
'endUserId': json['endUserId'] == null ? undefined : json['endUserId'],
|
|
50
62
|
};
|
|
51
63
|
}
|
|
52
64
|
function QueueMessageInputToJSON(json) {
|
|
@@ -61,5 +73,7 @@ function QueueMessageInputToJSONTyped(value, ignoreDiscriminator = false) {
|
|
|
61
73
|
'delivery': value['delivery'],
|
|
62
74
|
'agentId': value['agentId'],
|
|
63
75
|
'retryOf': value['retryOf'],
|
|
76
|
+
'surface': value['surface'],
|
|
77
|
+
'endUserId': value['endUserId'],
|
|
64
78
|
};
|
|
65
79
|
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sarvam Agents API
|
|
3
|
+
* Chat with a Sarvam agent, exchange files with it, and set it up (instructions, skills, knowledge bases, connectors, deploy) from your own code. Authenticate with a service token sent as a Bearer token, and send the header X-Panja-Origin: managed_agents on every request.
|
|
4
|
+
*
|
|
5
|
+
* The version of the OpenAPI document: 0.1.0
|
|
6
|
+
* Contact: support@sarvam.ai
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
9
|
+
* https://openapi-generator.tech
|
|
10
|
+
* Do not edit the class manually.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* One function call the app must run before the turn can continue.
|
|
14
|
+
* @export
|
|
15
|
+
* @interface RequiredAction
|
|
16
|
+
*/
|
|
17
|
+
export interface RequiredAction {
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @type {string}
|
|
21
|
+
* @memberof RequiredAction
|
|
22
|
+
*/
|
|
23
|
+
type?: RequiredActionTypeEnum;
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @type {string}
|
|
27
|
+
* @memberof RequiredAction
|
|
28
|
+
*/
|
|
29
|
+
requestId: string;
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @type {string}
|
|
33
|
+
* @memberof RequiredAction
|
|
34
|
+
*/
|
|
35
|
+
toolCallId: string;
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* @type {string}
|
|
39
|
+
* @memberof RequiredAction
|
|
40
|
+
*/
|
|
41
|
+
name: string;
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* @type {{ [key: string]: any; }}
|
|
45
|
+
* @memberof RequiredAction
|
|
46
|
+
*/
|
|
47
|
+
arguments: {
|
|
48
|
+
[key: string]: any;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
* @type {Date}
|
|
53
|
+
* @memberof RequiredAction
|
|
54
|
+
*/
|
|
55
|
+
createdAt: Date;
|
|
56
|
+
/**
|
|
57
|
+
*
|
|
58
|
+
* @type {Date}
|
|
59
|
+
* @memberof RequiredAction
|
|
60
|
+
*/
|
|
61
|
+
expiresAt?: Date | null;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* @export
|
|
65
|
+
*/
|
|
66
|
+
export declare const RequiredActionTypeEnum: {
|
|
67
|
+
readonly FunctionCall: "function_call";
|
|
68
|
+
};
|
|
69
|
+
export type RequiredActionTypeEnum = typeof RequiredActionTypeEnum[keyof typeof RequiredActionTypeEnum];
|
|
70
|
+
/**
|
|
71
|
+
* Check if a given object implements the RequiredAction interface.
|
|
72
|
+
*/
|
|
73
|
+
export declare function instanceOfRequiredAction(value: object): value is RequiredAction;
|
|
74
|
+
export declare function RequiredActionFromJSON(json: any): RequiredAction;
|
|
75
|
+
export declare function RequiredActionFromJSONTyped(json: any, ignoreDiscriminator: boolean): RequiredAction;
|
|
76
|
+
export declare function RequiredActionToJSON(json: any): RequiredAction;
|
|
77
|
+
export declare function RequiredActionToJSONTyped(value?: RequiredAction | null, ignoreDiscriminator?: boolean): any;
|