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,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `webhooks` entries of `agent.json`, checked locally with the server's cheap rules (as the Python SDK does).
|
|
3
|
+
*
|
|
4
|
+
* The server (`claw_common/agent_settings/webhooks.py`) also checks that the host resolves to a public address and
|
|
5
|
+
* that `secret_credential` names a vault credential bound to the agent whose allowed hosts cover the URL; those need
|
|
6
|
+
* I/O and stay on the server, which refuses the save with a 422 that `deploy` throws as `UserError`. A new agent has
|
|
7
|
+
* no credentials bound yet, so the deploy that creates it binds the caller's Custom API of each named credential first
|
|
8
|
+
* (`SettingsTransport.createAgent`).
|
|
9
|
+
*/
|
|
10
|
+
import { UserError } from "./errors.js";
|
|
11
|
+
import { WEBHOOK_EVENTS } from "../webhooks.js";
|
|
12
|
+
export const WEBHOOKS_MAX = 5;
|
|
13
|
+
const WEBHOOK_URL_MAX = 2048;
|
|
14
|
+
const SECRET_CREDENTIAL_MAX = 256;
|
|
15
|
+
const LABEL = /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
16
|
+
// A last label that is a number (decimal, or 0x hex) makes resolvers read the whole host as an IPv4 address.
|
|
17
|
+
const NUMERIC_LABEL = /^(?:[0-9]+|0x[0-9a-f]*)$/;
|
|
18
|
+
const SCHEME = /^[A-Za-z][A-Za-z0-9+\-.]*$/;
|
|
19
|
+
/** Length in code points, as Python's `len`. */
|
|
20
|
+
function codePoints(text) {
|
|
21
|
+
return Array.from(text).length;
|
|
22
|
+
}
|
|
23
|
+
/** `[scheme, netloc, path, query]` as Python 3.12's `urlsplit` splits a URL without a fragment. */
|
|
24
|
+
function split(url) {
|
|
25
|
+
let rest = url;
|
|
26
|
+
let scheme = "";
|
|
27
|
+
const i = rest.indexOf(":");
|
|
28
|
+
if (i > 0 && SCHEME.test(rest.slice(0, i))) {
|
|
29
|
+
scheme = rest.slice(0, i).toLowerCase();
|
|
30
|
+
rest = rest.slice(i + 1);
|
|
31
|
+
}
|
|
32
|
+
let netloc = "";
|
|
33
|
+
if (rest.slice(0, 2) === "//") {
|
|
34
|
+
let end = rest.length;
|
|
35
|
+
for (const c of "/?#") {
|
|
36
|
+
const at = rest.indexOf(c, 2);
|
|
37
|
+
if (at >= 0)
|
|
38
|
+
end = Math.min(end, at);
|
|
39
|
+
}
|
|
40
|
+
netloc = rest.slice(2, end);
|
|
41
|
+
rest = rest.slice(end);
|
|
42
|
+
}
|
|
43
|
+
let query = "";
|
|
44
|
+
const q = rest.indexOf("?");
|
|
45
|
+
if (q >= 0) {
|
|
46
|
+
query = rest.slice(q + 1);
|
|
47
|
+
rest = rest.slice(0, q);
|
|
48
|
+
}
|
|
49
|
+
return [scheme, netloc, rest, query];
|
|
50
|
+
}
|
|
51
|
+
/** Python's `str.partition`. */
|
|
52
|
+
function partition(text, sep) {
|
|
53
|
+
const at = text.indexOf(sep);
|
|
54
|
+
return at < 0 ? [text, "", ""] : [text.slice(0, at), sep, text.slice(at + sep.length)];
|
|
55
|
+
}
|
|
56
|
+
/** `urlsplit`'s host (lowercased) and raw port (`null` when absent or empty). */
|
|
57
|
+
function hostPort(netloc) {
|
|
58
|
+
const hostinfo = netloc.slice(netloc.lastIndexOf("@") + 1);
|
|
59
|
+
const [, bracket, bracketed] = partition(hostinfo, "[");
|
|
60
|
+
let host;
|
|
61
|
+
let port;
|
|
62
|
+
if (bracket) {
|
|
63
|
+
const [inner, , after] = partition(bracketed, "]");
|
|
64
|
+
host = inner;
|
|
65
|
+
port = partition(after, ":")[2];
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
[host, , port] = partition(hostinfo, ":");
|
|
69
|
+
}
|
|
70
|
+
return [host.toLowerCase(), port || null];
|
|
71
|
+
}
|
|
72
|
+
function stripTrailingDots(host) {
|
|
73
|
+
return host.replace(/\.+$/, "");
|
|
74
|
+
}
|
|
75
|
+
/** Why `url` is not an allowed webhook URL, or null. Every URL the server refuses is refused, with the server's
|
|
76
|
+
* sentence for every URL Python's `urlsplit` parses; for a netloc its NFKC check refuses, the sentence may differ. */
|
|
77
|
+
export function urlProblem(url) {
|
|
78
|
+
if (codePoints(url) > WEBHOOK_URL_MAX)
|
|
79
|
+
return `url must be at most ${WEBHOOK_URL_MAX} characters.`;
|
|
80
|
+
for (let i = 0; i < url.length; i++) {
|
|
81
|
+
const code = url.charCodeAt(i);
|
|
82
|
+
if (code <= 0x20 || code === 0x7f)
|
|
83
|
+
return "url must not contain spaces or control characters.";
|
|
84
|
+
}
|
|
85
|
+
if (url.indexOf("#") !== -1)
|
|
86
|
+
return "url must not have a fragment.";
|
|
87
|
+
const [scheme, netloc, path] = split(url);
|
|
88
|
+
if (scheme !== "https")
|
|
89
|
+
return "url must start with https://.";
|
|
90
|
+
if (netloc.indexOf("@") !== -1)
|
|
91
|
+
return "url must not contain a user name or password.";
|
|
92
|
+
// urlsplit refuses unbalanced brackets outright
|
|
93
|
+
if ((netloc.indexOf("[") !== -1) !== (netloc.indexOf("]") !== -1)) {
|
|
94
|
+
return "url host must be a DNS name, not an IP address.";
|
|
95
|
+
}
|
|
96
|
+
const [rawHost, port] = hostPort(netloc);
|
|
97
|
+
if (port !== null) {
|
|
98
|
+
if (!/^[0-9]+$/.test(port) || Number(port) > 65535) {
|
|
99
|
+
return "url has an invalid port; leave the port out (443 is used).";
|
|
100
|
+
}
|
|
101
|
+
if (Number(port) !== 443)
|
|
102
|
+
return "url must use port 443; leave the port out.";
|
|
103
|
+
}
|
|
104
|
+
const host = stripTrailingDots(rawHost);
|
|
105
|
+
if (!host)
|
|
106
|
+
return "url must name a host, like https://hooks.example.com/panja.";
|
|
107
|
+
if (netloc.indexOf("[") !== -1)
|
|
108
|
+
return "url host must be a DNS name, not an IP address.";
|
|
109
|
+
const labels = host.split(".");
|
|
110
|
+
if (!labels.every((label) => LABEL.test(label)))
|
|
111
|
+
return "url host must be a DNS name, like hooks.example.com.";
|
|
112
|
+
if (NUMERIC_LABEL.test(labels[labels.length - 1]))
|
|
113
|
+
return "url host must be a DNS name, not an IP address.";
|
|
114
|
+
if (path.split("/").some((seg) => seg === "." || seg === ".."))
|
|
115
|
+
return "url path must not contain . or .. segments.";
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
/** Host (lowercased, no trailing dot, no port), path and query: two URLs with one key are one endpoint. */
|
|
119
|
+
function urlKey(url) {
|
|
120
|
+
const [, netloc, path, query] = split(url);
|
|
121
|
+
return `${stripTrailingDots(hostPort(netloc)[0])}${path}?${query}`;
|
|
122
|
+
}
|
|
123
|
+
/** The server's pure `webhooks` rules (types first); throws `UserError` naming the agent.json path. */
|
|
124
|
+
export function checkWebhooks(webhooks) {
|
|
125
|
+
if (!Array.isArray(webhooks))
|
|
126
|
+
throw new UserError("webhooks: must be a list of webhooks");
|
|
127
|
+
if (webhooks.length > WEBHOOKS_MAX) {
|
|
128
|
+
throw new UserError(`webhooks: webhooks may hold at most ${WEBHOOKS_MAX} endpoints.`);
|
|
129
|
+
}
|
|
130
|
+
const seen = new Set();
|
|
131
|
+
webhooks.forEach((hook, i) => {
|
|
132
|
+
const where = `webhooks.${i}.`;
|
|
133
|
+
if (typeof hook !== "object" || hook === null || Array.isArray(hook)) {
|
|
134
|
+
throw new UserError(`webhooks.${i}: must be an object with url, events and secretCredential`);
|
|
135
|
+
}
|
|
136
|
+
const { url, events, secretCredential } = hook;
|
|
137
|
+
if (typeof url !== "string")
|
|
138
|
+
throw new UserError(where + "url: must be a string");
|
|
139
|
+
if (!Array.isArray(events) || !events.every((e) => typeof e === "string")) {
|
|
140
|
+
throw new UserError(where + "events: must be a list of event names");
|
|
141
|
+
}
|
|
142
|
+
if (typeof secretCredential !== "string")
|
|
143
|
+
throw new UserError(where + "secretCredential: must be a string");
|
|
144
|
+
// Python's Webhook is extra="forbid": a key dropped silently (a misplaced secret) would never verify.
|
|
145
|
+
const extra = Object.keys(hook).find((k) => k !== "url" && k !== "events" && k !== "secretCredential");
|
|
146
|
+
if (extra !== undefined)
|
|
147
|
+
throw new UserError(where + extra + ": Extra inputs are not permitted");
|
|
148
|
+
const problem = urlProblem(url);
|
|
149
|
+
if (problem !== null)
|
|
150
|
+
throw new UserError(where + "url: " + problem);
|
|
151
|
+
if (events.length < 1 || events.length > WEBHOOK_EVENTS.length) {
|
|
152
|
+
throw new UserError(where + `events: events must list 1 to ${WEBHOOK_EVENTS.length} events.`);
|
|
153
|
+
}
|
|
154
|
+
if (events.some((e) => WEBHOOK_EVENTS.indexOf(e) === -1)) {
|
|
155
|
+
throw new UserError(where + `events: events must be from: ${WEBHOOK_EVENTS.join(", ")}.`);
|
|
156
|
+
}
|
|
157
|
+
if (new Set(events).size !== events.length)
|
|
158
|
+
throw new UserError(where + "events: events must not repeat an event.");
|
|
159
|
+
const n = codePoints(secretCredential);
|
|
160
|
+
if (n < 1 || n > SECRET_CREDENTIAL_MAX) {
|
|
161
|
+
throw new UserError(where + "secret_credential: secret_credential must be the name of a vault credential " +
|
|
162
|
+
`(1 to ${SECRET_CREDENTIAL_MAX} characters).`);
|
|
163
|
+
}
|
|
164
|
+
const key = urlKey(url);
|
|
165
|
+
if (seen.has(key)) {
|
|
166
|
+
throw new UserError(where + "url: webhooks must not list the same url twice; put all its events on one entry.");
|
|
167
|
+
}
|
|
168
|
+
seen.add(key);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
/** Only the three fields, in agent.json's names (a copy). */
|
|
172
|
+
export function copyWebhooks(webhooks) {
|
|
173
|
+
return webhooks.map((h) => ({ url: h.url, events: [...h.events], secretCredential: h.secretCredential }));
|
|
174
|
+
}
|
|
175
|
+
export function webhooksJson(webhooks) {
|
|
176
|
+
return webhooks.map((h) => ({ url: h.url, events: [...h.events], secret_credential: h.secretCredential }));
|
|
177
|
+
}
|
|
@@ -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}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { UIMessageFromJSON, UIMessageToJSON, } from './UIMessage.js';
|
|
15
15
|
import { FieldHighlightFromJSON, FieldHighlightToJSON, } from './FieldHighlight.js';
|
|
16
|
+
import { RequiredActionFromJSON, RequiredActionToJSON, } from './RequiredAction.js';
|
|
16
17
|
import { QueuedTurnViewFromJSON, QueuedTurnViewToJSON, } from './QueuedTurnView.js';
|
|
17
18
|
/**
|
|
18
19
|
* Check if a given object implements the AgentConversationDetail interface.
|
|
@@ -79,6 +80,7 @@ export function AgentConversationDetailFromJSONTyped(json, ignoreDiscriminator)
|
|
|
79
80
|
'hasMore': json['hasMore'] == null ? undefined : json['hasMore'],
|
|
80
81
|
'nextBeforeCursor': json['nextBeforeCursor'] == null ? undefined : json['nextBeforeCursor'],
|
|
81
82
|
'queuedTurns': json['queuedTurns'] == null ? undefined : (json['queuedTurns'].map(QueuedTurnViewFromJSON)),
|
|
83
|
+
'requiredActions': json['requiredActions'] == null ? undefined : (json['requiredActions'].map(RequiredActionFromJSON)),
|
|
82
84
|
'isMine': json['isMine'] == null ? undefined : json['isMine'],
|
|
83
85
|
'panjaWsId': json['panjaWsId'],
|
|
84
86
|
'readOnly': json['readOnly'] == null ? undefined : json['readOnly'],
|
|
@@ -112,6 +114,7 @@ export function AgentConversationDetailToJSONTyped(value, ignoreDiscriminator =
|
|
|
112
114
|
'hasMore': value['hasMore'],
|
|
113
115
|
'nextBeforeCursor': value['nextBeforeCursor'],
|
|
114
116
|
'queuedTurns': value['queuedTurns'] == null ? undefined : (value['queuedTurns'].map(QueuedTurnViewToJSON)),
|
|
117
|
+
'requiredActions': value['requiredActions'] == null ? undefined : (value['requiredActions'].map(RequiredActionToJSON)),
|
|
115
118
|
'isMine': value['isMine'],
|
|
116
119
|
'panjaWsId': value['panjaWsId'],
|
|
117
120
|
'readOnly': value['readOnly'],
|
|
@@ -30,6 +30,7 @@ export function ClarifyBodyFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
30
30
|
'requestId': json['requestId'],
|
|
31
31
|
'action': json['action'] == null ? undefined : json['action'],
|
|
32
32
|
'answers': json['answers'] == null ? undefined : json['answers'],
|
|
33
|
+
'endUserId': json['endUserId'] == null ? undefined : json['endUserId'],
|
|
33
34
|
};
|
|
34
35
|
}
|
|
35
36
|
export function ClarifyBodyToJSON(json) {
|
|
@@ -43,5 +44,6 @@ export function ClarifyBodyToJSONTyped(value, ignoreDiscriminator = false) {
|
|
|
43
44
|
'requestId': value['requestId'],
|
|
44
45
|
'action': value['action'],
|
|
45
46
|
'answers': value['answers'],
|
|
47
|
+
'endUserId': value['endUserId'],
|
|
46
48
|
};
|
|
47
49
|
}
|
|
@@ -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.
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { UIMessageFromJSON, UIMessageToJSON, } from './UIMessage.js';
|
|
15
15
|
import { FieldHighlightFromJSON, FieldHighlightToJSON, } from './FieldHighlight.js';
|
|
16
|
+
import { RequiredActionFromJSON, RequiredActionToJSON, } from './RequiredAction.js';
|
|
16
17
|
import { QueuedTurnViewFromJSON, QueuedTurnViewToJSON, } from './QueuedTurnView.js';
|
|
17
18
|
/**
|
|
18
19
|
* Check if a given object implements the ConversationDetail interface.
|
|
@@ -77,6 +78,7 @@ export function ConversationDetailFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
77
78
|
'hasMore': json['hasMore'] == null ? undefined : json['hasMore'],
|
|
78
79
|
'nextBeforeCursor': json['nextBeforeCursor'] == null ? undefined : json['nextBeforeCursor'],
|
|
79
80
|
'queuedTurns': json['queuedTurns'] == null ? undefined : (json['queuedTurns'].map(QueuedTurnViewFromJSON)),
|
|
81
|
+
'requiredActions': json['requiredActions'] == null ? undefined : (json['requiredActions'].map(RequiredActionFromJSON)),
|
|
80
82
|
};
|
|
81
83
|
}
|
|
82
84
|
export function ConversationDetailToJSON(json) {
|
|
@@ -106,5 +108,6 @@ export function ConversationDetailToJSONTyped(value, ignoreDiscriminator = false
|
|
|
106
108
|
'hasMore': value['hasMore'],
|
|
107
109
|
'nextBeforeCursor': value['nextBeforeCursor'],
|
|
108
110
|
'queuedTurns': value['queuedTurns'] == null ? undefined : (value['queuedTurns'].map(QueuedTurnViewToJSON)),
|
|
111
|
+
'requiredActions': value['requiredActions'] == null ? undefined : (value['requiredActions'].map(RequiredActionToJSON)),
|
|
109
112
|
};
|
|
110
113
|
}
|
|
@@ -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
|
/**
|
|
@@ -25,7 +25,8 @@ export const ErrorDetailCodeEnum = {
|
|
|
25
25
|
RateLimit: 'CHAT_RATE_LIMIT',
|
|
26
26
|
Unavailable: 'CHAT_UNAVAILABLE',
|
|
27
27
|
Upstream: 'CHAT_UPSTREAM',
|
|
28
|
-
Internal: 'CHAT_INTERNAL'
|
|
28
|
+
Internal: 'CHAT_INTERNAL',
|
|
29
|
+
BalanceExhausted: 'CHAT_BALANCE_EXHAUSTED'
|
|
29
30
|
};
|
|
30
31
|
/**
|
|
31
32
|
* 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,49 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Sarvam Agents API
|
|
5
|
+
* 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.
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: 0.1.0
|
|
8
|
+
* Contact: support@sarvam.ai
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Check if a given object implements the FunctionResultBody interface.
|
|
16
|
+
*/
|
|
17
|
+
export function instanceOfFunctionResultBody(value) {
|
|
18
|
+
if (!('toolCallId' in value) || value['toolCallId'] === undefined)
|
|
19
|
+
return false;
|
|
20
|
+
if (!('output' in value) || value['output'] === undefined)
|
|
21
|
+
return false;
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
export function FunctionResultBodyFromJSON(json) {
|
|
25
|
+
return FunctionResultBodyFromJSONTyped(json, false);
|
|
26
|
+
}
|
|
27
|
+
export function FunctionResultBodyFromJSONTyped(json, ignoreDiscriminator) {
|
|
28
|
+
if (json == null) {
|
|
29
|
+
return json;
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
'toolCallId': json['toolCallId'],
|
|
33
|
+
'output': json['output'],
|
|
34
|
+
'isError': json['isError'] == null ? undefined : json['isError'],
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export function FunctionResultBodyToJSON(json) {
|
|
38
|
+
return FunctionResultBodyToJSONTyped(json, false);
|
|
39
|
+
}
|
|
40
|
+
export function FunctionResultBodyToJSONTyped(value, ignoreDiscriminator = false) {
|
|
41
|
+
if (value == null) {
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
'toolCallId': value['toolCallId'],
|
|
46
|
+
'output': value['output'],
|
|
47
|
+
'isError': value['isError'],
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -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
|
*/
|
|
@@ -19,6 +19,16 @@ export const QueueMessageInputDeliveryEnum = {
|
|
|
19
19
|
Queue: 'queue',
|
|
20
20
|
Now: 'now'
|
|
21
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* @export
|
|
24
|
+
*/
|
|
25
|
+
export const QueueMessageInputSurfaceEnum = {
|
|
26
|
+
Builder: 'builder',
|
|
27
|
+
Playground: 'playground',
|
|
28
|
+
Tests: 'tests',
|
|
29
|
+
Evals: 'evals',
|
|
30
|
+
Cowork: 'cowork'
|
|
31
|
+
};
|
|
22
32
|
/**
|
|
23
33
|
* Check if a given object implements the QueueMessageInput interface.
|
|
24
34
|
*/
|
|
@@ -39,6 +49,8 @@ export function QueueMessageInputFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
39
49
|
'delivery': json['delivery'] == null ? undefined : json['delivery'],
|
|
40
50
|
'agentId': json['agentId'] == null ? undefined : json['agentId'],
|
|
41
51
|
'retryOf': json['retryOf'] == null ? undefined : json['retryOf'],
|
|
52
|
+
'surface': json['surface'] == null ? undefined : json['surface'],
|
|
53
|
+
'endUserId': json['endUserId'] == null ? undefined : json['endUserId'],
|
|
42
54
|
};
|
|
43
55
|
}
|
|
44
56
|
export function QueueMessageInputToJSON(json) {
|
|
@@ -53,5 +65,7 @@ export function QueueMessageInputToJSONTyped(value, ignoreDiscriminator = false)
|
|
|
53
65
|
'delivery': value['delivery'],
|
|
54
66
|
'agentId': value['agentId'],
|
|
55
67
|
'retryOf': value['retryOf'],
|
|
68
|
+
'surface': value['surface'],
|
|
69
|
+
'endUserId': value['endUserId'],
|
|
56
70
|
};
|
|
57
71
|
}
|
|
@@ -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;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Sarvam Agents API
|
|
5
|
+
* 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.
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: 0.1.0
|
|
8
|
+
* Contact: support@sarvam.ai
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* @export
|
|
16
|
+
*/
|
|
17
|
+
export const RequiredActionTypeEnum = {
|
|
18
|
+
FunctionCall: 'function_call'
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Check if a given object implements the RequiredAction interface.
|
|
22
|
+
*/
|
|
23
|
+
export function instanceOfRequiredAction(value) {
|
|
24
|
+
if (!('requestId' in value) || value['requestId'] === undefined)
|
|
25
|
+
return false;
|
|
26
|
+
if (!('toolCallId' in value) || value['toolCallId'] === undefined)
|
|
27
|
+
return false;
|
|
28
|
+
if (!('name' in value) || value['name'] === undefined)
|
|
29
|
+
return false;
|
|
30
|
+
if (!('arguments' in value) || value['arguments'] === undefined)
|
|
31
|
+
return false;
|
|
32
|
+
if (!('createdAt' in value) || value['createdAt'] === undefined)
|
|
33
|
+
return false;
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
export function RequiredActionFromJSON(json) {
|
|
37
|
+
return RequiredActionFromJSONTyped(json, false);
|
|
38
|
+
}
|
|
39
|
+
export function RequiredActionFromJSONTyped(json, ignoreDiscriminator) {
|
|
40
|
+
if (json == null) {
|
|
41
|
+
return json;
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
'type': json['type'] == null ? undefined : json['type'],
|
|
45
|
+
'requestId': json['requestId'],
|
|
46
|
+
'toolCallId': json['toolCallId'],
|
|
47
|
+
'name': json['name'],
|
|
48
|
+
'arguments': json['arguments'],
|
|
49
|
+
'createdAt': (new Date(json['createdAt'])),
|
|
50
|
+
'expiresAt': json['expiresAt'] == null ? undefined : (new Date(json['expiresAt'])),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export function RequiredActionToJSON(json) {
|
|
54
|
+
return RequiredActionToJSONTyped(json, false);
|
|
55
|
+
}
|
|
56
|
+
export function RequiredActionToJSONTyped(value, ignoreDiscriminator = false) {
|
|
57
|
+
if (value == null) {
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
'type': value['type'],
|
|
62
|
+
'requestId': value['requestId'],
|
|
63
|
+
'toolCallId': value['toolCallId'],
|
|
64
|
+
'name': value['name'],
|
|
65
|
+
'arguments': value['arguments'],
|
|
66
|
+
'createdAt': ((value['createdAt']).toISOString()),
|
|
67
|
+
'expiresAt': value['expiresAt'] == null ? undefined : (value['expiresAt'].toISOString()),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
@@ -34,6 +34,14 @@ export interface ResponseDetail {
|
|
|
34
34
|
* @memberof ResponseDetail
|
|
35
35
|
*/
|
|
36
36
|
output: Array<UIMessage>;
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
* @type {{ [key: string]: any; }}
|
|
40
|
+
* @memberof ResponseDetail
|
|
41
|
+
*/
|
|
42
|
+
usage?: {
|
|
43
|
+
[key: string]: any;
|
|
44
|
+
} | null;
|
|
37
45
|
/**
|
|
38
46
|
*
|
|
39
47
|
* @type {any}
|
|
@@ -44,6 +44,7 @@ export function ResponseDetailFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
44
44
|
'responseId': json['responseId'],
|
|
45
45
|
'status': json['status'],
|
|
46
46
|
'output': (json['output'].map(UIMessageFromJSON)),
|
|
47
|
+
'usage': json['usage'] == null ? undefined : json['usage'],
|
|
47
48
|
'structuredOutput': json['structuredOutput'] == null ? undefined : json['structuredOutput'],
|
|
48
49
|
'outputErrors': json['outputErrors'] == null ? undefined : json['outputErrors'],
|
|
49
50
|
'outputCitations': json['outputCitations'] == null ? undefined : json['outputCitations'],
|
|
@@ -62,6 +63,7 @@ export function ResponseDetailToJSONTyped(value, ignoreDiscriminator = false) {
|
|
|
62
63
|
'responseId': value['responseId'],
|
|
63
64
|
'status': value['status'],
|
|
64
65
|
'output': (value['output'].map(UIMessageToJSON)),
|
|
66
|
+
'usage': value['usage'],
|
|
65
67
|
'structuredOutput': value['structuredOutput'],
|
|
66
68
|
'outputErrors': value['outputErrors'],
|
|
67
69
|
'outputCitations': value['outputCitations'],
|