sarvam-agents-client 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apis/AgentsApi.d.ts +4 -4
- package/dist/apis/AgentsApi.js +4 -4
- package/dist/apis/AppsApi.d.ts +1 -0
- package/dist/apis/AppsApi.js +3 -0
- package/dist/apis/QueueApi.d.ts +1 -0
- package/dist/apis/QueueApi.js +3 -0
- package/dist/apis/ResponsesApi.d.ts +2 -0
- package/dist/apis/ResponsesApi.js +6 -0
- package/dist/compose/agent.d.ts +10 -3
- package/dist/compose/agent.js +8 -0
- package/dist/compose/deploy.d.ts +3 -2
- package/dist/compose/errors.d.ts +17 -0
- package/dist/compose/errors.js +17 -0
- package/dist/compose/events.d.ts +34 -0
- package/dist/compose/events.js +25 -2
- package/dist/compose/index.d.ts +2 -1
- package/dist/compose/output.d.ts +29 -0
- package/dist/compose/output.js +451 -0
- package/dist/compose/run.d.ts +39 -14
- package/dist/compose/run.js +53 -3
- package/dist/compose/runState.d.ts +2 -1
- package/dist/compose/settingsTransport.d.ts +3 -2
- package/dist/compose/transport.d.ts +3 -2
- package/dist/esm/apis/AgentsApi.d.ts +4 -4
- package/dist/esm/apis/AgentsApi.js +4 -4
- package/dist/esm/apis/AppsApi.d.ts +1 -0
- package/dist/esm/apis/AppsApi.js +3 -0
- package/dist/esm/apis/QueueApi.d.ts +1 -0
- package/dist/esm/apis/QueueApi.js +3 -0
- package/dist/esm/apis/ResponsesApi.d.ts +2 -0
- package/dist/esm/apis/ResponsesApi.js +6 -0
- package/dist/esm/compose/agent.d.ts +10 -3
- package/dist/esm/compose/agent.js +8 -0
- package/dist/esm/compose/deploy.d.ts +3 -2
- package/dist/esm/compose/errors.d.ts +17 -0
- package/dist/esm/compose/errors.js +17 -0
- package/dist/esm/compose/events.d.ts +34 -0
- package/dist/esm/compose/events.js +25 -2
- package/dist/esm/compose/index.d.ts +2 -1
- package/dist/esm/compose/output.d.ts +29 -0
- package/dist/esm/compose/output.js +445 -0
- package/dist/esm/compose/run.d.ts +39 -14
- package/dist/esm/compose/run.js +54 -4
- package/dist/esm/compose/runState.d.ts +2 -1
- package/dist/esm/compose/settingsTransport.d.ts +3 -2
- package/dist/esm/compose/transport.d.ts +3 -2
- package/dist/esm/models/AppResource.d.ts +29 -0
- package/dist/esm/models/AppResource.js +16 -0
- package/dist/esm/models/AppToolsResponse.d.ts +3 -4
- package/dist/esm/models/AppToolsResponse.js +3 -2
- package/dist/esm/models/AppView.d.ts +48 -0
- package/dist/esm/models/AppView.js +23 -0
- package/dist/esm/models/McpSecurityAppealView.d.ts +50 -0
- package/dist/esm/models/McpSecurityAppealView.js +47 -0
- package/dist/esm/models/McpSecurityView.d.ts +105 -0
- package/dist/esm/models/McpSecurityView.js +66 -0
- package/dist/esm/models/MessagesResponse.d.ts +6 -0
- package/dist/esm/models/MessagesResponse.js +2 -0
- package/dist/esm/models/ResponseDetail.d.ts +32 -0
- package/dist/esm/models/ResponseDetail.js +10 -0
- package/dist/esm/models/index.d.ts +2 -0
- package/dist/esm/models/index.js +2 -0
- package/dist/models/AppResource.d.ts +29 -0
- package/dist/models/AppResource.js +17 -1
- package/dist/models/AppToolsResponse.d.ts +3 -4
- package/dist/models/AppToolsResponse.js +3 -2
- package/dist/models/AppView.d.ts +48 -0
- package/dist/models/AppView.js +24 -1
- package/dist/models/McpSecurityAppealView.d.ts +50 -0
- package/dist/models/McpSecurityAppealView.js +54 -0
- package/dist/models/McpSecurityView.d.ts +105 -0
- package/dist/models/McpSecurityView.js +73 -0
- package/dist/models/MessagesResponse.d.ts +6 -0
- package/dist/models/MessagesResponse.js +2 -0
- package/dist/models/ResponseDetail.d.ts +32 -0
- package/dist/models/ResponseDetail.js +10 -0
- package/dist/models/index.d.ts +2 -0
- package/dist/models/index.js +2 -0
- package/package.json +4 -3
- package/src/apis/AgentsApi.ts +4 -4
- package/src/apis/AppsApi.ts +5 -0
- package/src/apis/QueueApi.ts +5 -0
- package/src/apis/ResponsesApi.ts +10 -0
- package/src/compose/agent.ts +21 -6
- package/src/compose/deploy.ts +6 -5
- package/src/compose/errors.ts +28 -1
- package/src/compose/events.ts +49 -1
- package/src/compose/index.ts +2 -1
- package/src/compose/output.ts +415 -0
- package/src/compose/run.ts +93 -21
- package/src/compose/runState.ts +2 -1
- package/src/compose/settingsTransport.ts +4 -3
- package/src/compose/transport.ts +3 -2
- package/src/models/AppResource.ts +42 -0
- package/src/models/AppToolsResponse.ts +11 -4
- package/src/models/AppView.ts +73 -0
- package/src/models/McpSecurityAppealView.ts +89 -0
- package/src/models/McpSecurityView.ts +169 -0
- package/src/models/MessagesResponse.ts +8 -0
- package/src/models/ResponseDetail.ts +40 -0
- package/src/models/index.ts +2 -0
package/dist/apis/AgentsApi.d.ts
CHANGED
|
@@ -133,12 +133,12 @@ export declare class AgentsApi extends runtime.BaseAPI {
|
|
|
133
133
|
*/
|
|
134
134
|
createAgent(requestParameters: CreateAgentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<AgentResource>;
|
|
135
135
|
/**
|
|
136
|
-
* Owner-only soft delete.
|
|
136
|
+
* Owner-only soft delete. The managed state lives on the agent row, so a deleted agent stops being a managed agent with it.
|
|
137
137
|
* Delete Agent
|
|
138
138
|
*/
|
|
139
139
|
deleteAgentRaw(requestParameters: DeleteAgentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>>;
|
|
140
140
|
/**
|
|
141
|
-
* Owner-only soft delete.
|
|
141
|
+
* Owner-only soft delete. The managed state lives on the agent row, so a deleted agent stops being a managed agent with it.
|
|
142
142
|
* Delete Agent
|
|
143
143
|
*/
|
|
144
144
|
deleteAgent(requestParameters: DeleteAgentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void>;
|
|
@@ -237,12 +237,12 @@ export declare class AgentsApi extends runtime.BaseAPI {
|
|
|
237
237
|
*/
|
|
238
238
|
listAgentTemplates(requestParameters?: ListAgentTemplatesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<EntityListAgentTemplateResource>;
|
|
239
239
|
/**
|
|
240
|
-
* Flat, scope-filterable agent catalog (contract replaces v1\'s grouped ``GET /v1/agents``; the FE re-groups client-side from each row\'s ``scope``). One gateway call returns the caller\'s full visible set (the triple powers the gateway\'s ``visibility_scope`` clause). We then drop the operator-seeded editor agents, re-apply the visibility predicate (defence in depth — the gateway is identity-agnostic), and apply the ``?scope=``/``q`` filters before counting, so ``total`` is authoritative for the returned set. ``origin=managed_agents`` keeps only managed agents the caller owns (:func:`is_owner`). A teammate\'s published managed agent is visible to the caller but its sessions are owner-only, so listing it would only lead to a 403 on the session log. It always takes the fetch-all path below: the SQL catalog pages at the gateway, which
|
|
240
|
+
* Flat, scope-filterable agent catalog (contract replaces v1\'s grouped ``GET /v1/agents``; the FE re-groups client-side from each row\'s ``scope``). One gateway call returns the caller\'s full visible set (the triple powers the gateway\'s ``visibility_scope`` clause). We then drop the operator-seeded editor agents, re-apply the visibility predicate (defence in depth — the gateway is identity-agnostic), and apply the ``?scope=``/``q`` filters before counting, so ``total`` is authoritative for the returned set. ``origin=managed_agents`` keeps only managed agents the caller owns (:func:`is_owner`). A teammate\'s published managed agent is visible to the caller but its sessions are owner-only, so listing it would only lead to a 403 on the session log. It always takes the fetch-all path below: the SQL catalog pages at the gateway, which has no managed filter, so filtering its page here would return short pages and a wrong ``total``. Catalog-only filters are therefore a 400 with ``origin`` rather than silently ignored.
|
|
241
241
|
* List Agents
|
|
242
242
|
*/
|
|
243
243
|
listAgentsRaw(requestParameters: ListAgentsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<EntityListAgentResource>>;
|
|
244
244
|
/**
|
|
245
|
-
* Flat, scope-filterable agent catalog (contract replaces v1\'s grouped ``GET /v1/agents``; the FE re-groups client-side from each row\'s ``scope``). One gateway call returns the caller\'s full visible set (the triple powers the gateway\'s ``visibility_scope`` clause). We then drop the operator-seeded editor agents, re-apply the visibility predicate (defence in depth — the gateway is identity-agnostic), and apply the ``?scope=``/``q`` filters before counting, so ``total`` is authoritative for the returned set. ``origin=managed_agents`` keeps only managed agents the caller owns (:func:`is_owner`). A teammate\'s published managed agent is visible to the caller but its sessions are owner-only, so listing it would only lead to a 403 on the session log. It always takes the fetch-all path below: the SQL catalog pages at the gateway, which
|
|
245
|
+
* Flat, scope-filterable agent catalog (contract replaces v1\'s grouped ``GET /v1/agents``; the FE re-groups client-side from each row\'s ``scope``). One gateway call returns the caller\'s full visible set (the triple powers the gateway\'s ``visibility_scope`` clause). We then drop the operator-seeded editor agents, re-apply the visibility predicate (defence in depth — the gateway is identity-agnostic), and apply the ``?scope=``/``q`` filters before counting, so ``total`` is authoritative for the returned set. ``origin=managed_agents`` keeps only managed agents the caller owns (:func:`is_owner`). A teammate\'s published managed agent is visible to the caller but its sessions are owner-only, so listing it would only lead to a 403 on the session log. It always takes the fetch-all path below: the SQL catalog pages at the gateway, which has no managed filter, so filtering its page here would return short pages and a wrong ``total``. Catalog-only filters are therefore a 400 with ``origin`` rather than silently ignored.
|
|
246
246
|
* List Agents
|
|
247
247
|
*/
|
|
248
248
|
listAgents(requestParameters?: ListAgentsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<EntityListAgentResource>;
|
package/dist/apis/AgentsApi.js
CHANGED
|
@@ -101,7 +101,7 @@ class AgentsApi extends runtime.BaseAPI {
|
|
|
101
101
|
return await response.value();
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
|
-
* Owner-only soft delete.
|
|
104
|
+
* Owner-only soft delete. The managed state lives on the agent row, so a deleted agent stops being a managed agent with it.
|
|
105
105
|
* Delete Agent
|
|
106
106
|
*/
|
|
107
107
|
async deleteAgentRaw(requestParameters, initOverrides) {
|
|
@@ -126,7 +126,7 @@ class AgentsApi extends runtime.BaseAPI {
|
|
|
126
126
|
return new runtime.VoidApiResponse(response);
|
|
127
127
|
}
|
|
128
128
|
/**
|
|
129
|
-
* Owner-only soft delete.
|
|
129
|
+
* Owner-only soft delete. The managed state lives on the agent row, so a deleted agent stops being a managed agent with it.
|
|
130
130
|
* Delete Agent
|
|
131
131
|
*/
|
|
132
132
|
async deleteAgent(requestParameters, initOverrides) {
|
|
@@ -477,7 +477,7 @@ class AgentsApi extends runtime.BaseAPI {
|
|
|
477
477
|
return await response.value();
|
|
478
478
|
}
|
|
479
479
|
/**
|
|
480
|
-
* Flat, scope-filterable agent catalog (contract replaces v1\'s grouped ``GET /v1/agents``; the FE re-groups client-side from each row\'s ``scope``). One gateway call returns the caller\'s full visible set (the triple powers the gateway\'s ``visibility_scope`` clause). We then drop the operator-seeded editor agents, re-apply the visibility predicate (defence in depth — the gateway is identity-agnostic), and apply the ``?scope=``/``q`` filters before counting, so ``total`` is authoritative for the returned set. ``origin=managed_agents`` keeps only managed agents the caller owns (:func:`is_owner`). A teammate\'s published managed agent is visible to the caller but its sessions are owner-only, so listing it would only lead to a 403 on the session log. It always takes the fetch-all path below: the SQL catalog pages at the gateway, which
|
|
480
|
+
* Flat, scope-filterable agent catalog (contract replaces v1\'s grouped ``GET /v1/agents``; the FE re-groups client-side from each row\'s ``scope``). One gateway call returns the caller\'s full visible set (the triple powers the gateway\'s ``visibility_scope`` clause). We then drop the operator-seeded editor agents, re-apply the visibility predicate (defence in depth — the gateway is identity-agnostic), and apply the ``?scope=``/``q`` filters before counting, so ``total`` is authoritative for the returned set. ``origin=managed_agents`` keeps only managed agents the caller owns (:func:`is_owner`). A teammate\'s published managed agent is visible to the caller but its sessions are owner-only, so listing it would only lead to a 403 on the session log. It always takes the fetch-all path below: the SQL catalog pages at the gateway, which has no managed filter, so filtering its page here would return short pages and a wrong ``total``. Catalog-only filters are therefore a 400 with ``origin`` rather than silently ignored.
|
|
481
481
|
* List Agents
|
|
482
482
|
*/
|
|
483
483
|
async listAgentsRaw(requestParameters, initOverrides) {
|
|
@@ -535,7 +535,7 @@ class AgentsApi extends runtime.BaseAPI {
|
|
|
535
535
|
return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_js_1.EntityListAgentResourceFromJSON)(jsonValue));
|
|
536
536
|
}
|
|
537
537
|
/**
|
|
538
|
-
* Flat, scope-filterable agent catalog (contract replaces v1\'s grouped ``GET /v1/agents``; the FE re-groups client-side from each row\'s ``scope``). One gateway call returns the caller\'s full visible set (the triple powers the gateway\'s ``visibility_scope`` clause). We then drop the operator-seeded editor agents, re-apply the visibility predicate (defence in depth — the gateway is identity-agnostic), and apply the ``?scope=``/``q`` filters before counting, so ``total`` is authoritative for the returned set. ``origin=managed_agents`` keeps only managed agents the caller owns (:func:`is_owner`). A teammate\'s published managed agent is visible to the caller but its sessions are owner-only, so listing it would only lead to a 403 on the session log. It always takes the fetch-all path below: the SQL catalog pages at the gateway, which
|
|
538
|
+
* Flat, scope-filterable agent catalog (contract replaces v1\'s grouped ``GET /v1/agents``; the FE re-groups client-side from each row\'s ``scope``). One gateway call returns the caller\'s full visible set (the triple powers the gateway\'s ``visibility_scope`` clause). We then drop the operator-seeded editor agents, re-apply the visibility predicate (defence in depth — the gateway is identity-agnostic), and apply the ``?scope=``/``q`` filters before counting, so ``total`` is authoritative for the returned set. ``origin=managed_agents`` keeps only managed agents the caller owns (:func:`is_owner`). A teammate\'s published managed agent is visible to the caller but its sessions are owner-only, so listing it would only lead to a 403 on the session log. It always takes the fetch-all path below: the SQL catalog pages at the gateway, which has no managed filter, so filtering its page here would return short pages and a wrong ``total``. Catalog-only filters are therefore a 400 with ``origin`` rather than silently ignored.
|
|
539
539
|
* List Agents
|
|
540
540
|
*/
|
|
541
541
|
async listAgents(requestParameters = {}, initOverrides) {
|
package/dist/apis/AppsApi.d.ts
CHANGED
package/dist/apis/AppsApi.js
CHANGED
|
@@ -353,6 +353,9 @@ class AppsApi extends runtime.BaseAPI {
|
|
|
353
353
|
if (requestParameters['includeFilterOptions'] != null) {
|
|
354
354
|
queryParameters['includeFilterOptions'] = requestParameters['includeFilterOptions'];
|
|
355
355
|
}
|
|
356
|
+
if (requestParameters['custom'] != null) {
|
|
357
|
+
queryParameters['custom'] = requestParameters['custom'];
|
|
358
|
+
}
|
|
356
359
|
const headerParameters = {};
|
|
357
360
|
if (this.configuration && this.configuration.accessToken) {
|
|
358
361
|
const token = this.configuration.accessToken;
|
package/dist/apis/QueueApi.d.ts
CHANGED
package/dist/apis/QueueApi.js
CHANGED
|
@@ -81,6 +81,9 @@ class QueueApi extends runtime.BaseAPI {
|
|
|
81
81
|
if (requestParameters['xClientVersion'] != null) {
|
|
82
82
|
headerParameters['X-Client-Version'] = String(requestParameters['xClientVersion']);
|
|
83
83
|
}
|
|
84
|
+
if (requestParameters['xLoginId'] != null) {
|
|
85
|
+
headerParameters['X-Login-Id'] = String(requestParameters['xLoginId']);
|
|
86
|
+
}
|
|
84
87
|
if (this.configuration && this.configuration.accessToken) {
|
|
85
88
|
const token = this.configuration.accessToken;
|
|
86
89
|
const tokenString = await token("bearerAuth", []);
|
|
@@ -16,6 +16,7 @@ export interface CreateResponseRequest {
|
|
|
16
16
|
xClientFeatures?: string | null;
|
|
17
17
|
xClientPlatform?: string | null;
|
|
18
18
|
xClientVersion?: string | null;
|
|
19
|
+
xLoginId?: string | null;
|
|
19
20
|
}
|
|
20
21
|
export interface ReconnectStreamRequest {
|
|
21
22
|
conversationId: string;
|
|
@@ -30,6 +31,7 @@ export interface StopResponseRequest {
|
|
|
30
31
|
conversationId: string;
|
|
31
32
|
xClientPlatform?: string | null;
|
|
32
33
|
xClientVersion?: string | null;
|
|
34
|
+
xLoginId?: string | null;
|
|
33
35
|
}
|
|
34
36
|
/**
|
|
35
37
|
*
|
|
@@ -39,6 +39,9 @@ class ResponsesApi extends runtime.BaseAPI {
|
|
|
39
39
|
if (requestParameters['xClientVersion'] != null) {
|
|
40
40
|
headerParameters['X-Client-Version'] = String(requestParameters['xClientVersion']);
|
|
41
41
|
}
|
|
42
|
+
if (requestParameters['xLoginId'] != null) {
|
|
43
|
+
headerParameters['X-Login-Id'] = String(requestParameters['xLoginId']);
|
|
44
|
+
}
|
|
42
45
|
if (this.configuration && this.configuration.accessToken) {
|
|
43
46
|
const token = this.configuration.accessToken;
|
|
44
47
|
const tokenString = await token("bearerAuth", []);
|
|
@@ -141,6 +144,9 @@ class ResponsesApi extends runtime.BaseAPI {
|
|
|
141
144
|
if (requestParameters['xClientVersion'] != null) {
|
|
142
145
|
headerParameters['X-Client-Version'] = String(requestParameters['xClientVersion']);
|
|
143
146
|
}
|
|
147
|
+
if (requestParameters['xLoginId'] != null) {
|
|
148
|
+
headerParameters['X-Login-Id'] = String(requestParameters['xLoginId']);
|
|
149
|
+
}
|
|
144
150
|
if (this.configuration && this.configuration.accessToken) {
|
|
145
151
|
const token = this.configuration.accessToken;
|
|
146
152
|
const tokenString = await token("bearerAuth", []);
|
package/dist/compose/agent.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BuiltinTool } from "./tools.js";
|
|
2
|
+
import type { OutputType } from "./output.js";
|
|
2
3
|
export interface ModelSettings {
|
|
3
4
|
temperature?: number;
|
|
4
5
|
topP?: number;
|
|
@@ -13,7 +14,7 @@ export interface Limits {
|
|
|
13
14
|
maxToolCallsPerTurn?: number;
|
|
14
15
|
maxTokensPerTurn?: number;
|
|
15
16
|
}
|
|
16
|
-
export interface AgentOptions {
|
|
17
|
+
export interface AgentOptions<TOutput extends OutputType | undefined = undefined> {
|
|
17
18
|
name: string;
|
|
18
19
|
instructions?: string;
|
|
19
20
|
model?: string;
|
|
@@ -25,8 +26,12 @@ export interface AgentOptions {
|
|
|
25
26
|
tools?: BuiltinTool[];
|
|
26
27
|
limits?: Limits;
|
|
27
28
|
metadata?: Record<string, string>;
|
|
29
|
+
/** The shape of the final answer: `{ type: "json_schema", schema }` or a zod schema. `finalOutput` follows it. */
|
|
30
|
+
outputType?: TOutput;
|
|
28
31
|
}
|
|
29
|
-
|
|
32
|
+
/** An agent with any output type: use it for helpers that accept every agent (plain `Agent` means a text agent). */
|
|
33
|
+
export type AnyAgent = Agent<OutputType | undefined>;
|
|
34
|
+
export declare class Agent<TOutput extends OutputType | undefined = undefined> {
|
|
30
35
|
readonly name: string;
|
|
31
36
|
readonly instructions: string;
|
|
32
37
|
readonly model?: string;
|
|
@@ -36,7 +41,9 @@ export declare class Agent {
|
|
|
36
41
|
readonly tools?: readonly BuiltinTool[];
|
|
37
42
|
readonly limits?: Limits;
|
|
38
43
|
readonly metadata?: Record<string, string>;
|
|
39
|
-
|
|
44
|
+
/** Kept by reference and not frozen: a zod schema must stay usable. Non-enumerable, so deepFreeze skips it. */
|
|
45
|
+
readonly outputType: TOutput;
|
|
46
|
+
constructor(rawOpts: AgentOptions<TOutput>);
|
|
40
47
|
private check;
|
|
41
48
|
private baseSettings;
|
|
42
49
|
specHash(): string;
|
package/dist/compose/agent.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.Agent = void 0;
|
|
|
4
4
|
const errors_js_1 = require("./errors.js");
|
|
5
5
|
const fingerprint_js_1 = require("./fingerprint.js");
|
|
6
6
|
const builtins_js_1 = require("./builtins.js");
|
|
7
|
+
const output_js_1 = require("./output.js");
|
|
7
8
|
const SLUG = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
8
9
|
const REASONING = ["off", "none", "low", "medium", "high", "xhigh", "max"];
|
|
9
10
|
const TOOL_CHOICES = ["auto", "none"];
|
|
@@ -92,6 +93,7 @@ class Agent {
|
|
|
92
93
|
this.tools = clone(opts.tools);
|
|
93
94
|
this.limits = clone(opts.limits);
|
|
94
95
|
this.metadata = clone(opts.metadata);
|
|
96
|
+
Object.defineProperty(this, "outputType", { value: opts.outputType, enumerable: false, writable: false });
|
|
95
97
|
this.check();
|
|
96
98
|
deepFreeze(this);
|
|
97
99
|
}
|
|
@@ -100,6 +102,10 @@ class Agent {
|
|
|
100
102
|
if (typeof this.name !== "string" || !SLUG.test(this.name)) {
|
|
101
103
|
throw new errors_js_1.UserError(`name: ${JSON.stringify(this.name)} must match ${SLUG.source}`);
|
|
102
104
|
}
|
|
105
|
+
if (this.outputType !== undefined) {
|
|
106
|
+
(0, output_js_1.checkOutputType)(this.outputType);
|
|
107
|
+
(0, output_js_1.outputSchema)(this.outputType); // refuse what the server would, before anything is sent
|
|
108
|
+
}
|
|
103
109
|
for (const [key, value] of [["model", this.model], ["endpoint", this.endpoint]]) {
|
|
104
110
|
if (value !== undefined && (typeof value !== "string" || value === "")) {
|
|
105
111
|
throw new errors_js_1.UserError(`${key}: must be a non-empty string`);
|
|
@@ -203,6 +209,8 @@ class Agent {
|
|
|
203
209
|
}
|
|
204
210
|
out["builtin_tools"] = tools;
|
|
205
211
|
}
|
|
212
|
+
if (this.outputType !== undefined)
|
|
213
|
+
out["output_schema"] = (0, output_js_1.outputSchema)(this.outputType);
|
|
206
214
|
return out;
|
|
207
215
|
}
|
|
208
216
|
specHash() {
|
package/dist/compose/deploy.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** deploy()/undeploy(): upsert a hosted agent by name, with fingerprint-based drift detection, and the deploy cache. */
|
|
2
2
|
import type { Configuration } from "../runtime.js";
|
|
3
3
|
import type { Agent } from "./agent.js";
|
|
4
|
+
import type { OutputType } from "./output.js";
|
|
4
5
|
import type { Transport } from "./transport.js";
|
|
5
6
|
export interface Deployment {
|
|
6
7
|
agentId: string;
|
|
@@ -10,7 +11,7 @@ export interface Deployment {
|
|
|
10
11
|
export declare function setDefaultClient(config: Configuration | null): void;
|
|
11
12
|
export declare function getDefaultClient(): Configuration | null;
|
|
12
13
|
export declare function resolveTransport(client?: Configuration, transport?: Transport): Transport;
|
|
13
|
-
export declare function deploy(agent: Agent
|
|
14
|
+
export declare function deploy(agent: Agent<OutputType | undefined>, opts?: {
|
|
14
15
|
client?: Configuration;
|
|
15
16
|
transport?: Transport;
|
|
16
17
|
strict?: boolean;
|
|
@@ -27,4 +28,4 @@ export declare function forget(name: string): void;
|
|
|
27
28
|
* Keyed by name, as the server is: a variant with the same name redeploys, chained after any in-flight deploy so
|
|
28
29
|
* deploys of one name never overlap.
|
|
29
30
|
*/
|
|
30
|
-
export declare function agentIdFor(agent: Agent
|
|
31
|
+
export declare function agentIdFor(agent: Agent<OutputType | undefined>, transport: Transport, owner: object): Promise<string>;
|
package/dist/compose/errors.d.ts
CHANGED
|
@@ -16,7 +16,24 @@ export declare class UserError extends AgentsError {
|
|
|
16
16
|
message?: string;
|
|
17
17
|
}>);
|
|
18
18
|
}
|
|
19
|
+
/** Where a `ModelBehaviorError` came from: the server's check, or the `outputType`'s own `parse`. */
|
|
20
|
+
export type ModelBehaviorErrorSource = "server" | "local_parse";
|
|
21
|
+
/**
|
|
22
|
+
* The agent's answer didn't match its `outputType`. `source` says where: `"server"` (no answer matched the schema
|
|
23
|
+
* after the server's retry; `rawText` is the model's last attempt) or `"local_parse"` (the server accepted the answer
|
|
24
|
+
* but the `outputType`'s `parse` refused it, for example a zod refinement; `rawText` is the server's JSON,
|
|
25
|
+
* re-serialised).
|
|
26
|
+
*/
|
|
19
27
|
export declare class ModelBehaviorError extends AgentsError {
|
|
28
|
+
readonly rawText: string;
|
|
29
|
+
readonly errors: string[];
|
|
30
|
+
/** The server's `outputNote`: the turn's size-refused `final_answer` was not the answer. */
|
|
31
|
+
readonly note: string | undefined;
|
|
32
|
+
readonly source: ModelBehaviorErrorSource;
|
|
33
|
+
/** The run's conversation, set when a run rejects with this, so the caller can continue it (`conversationId`) or
|
|
34
|
+
* fetch its `ResponseDetail`. */
|
|
35
|
+
conversationId: string | undefined;
|
|
36
|
+
constructor(rawText?: string, errors?: string[], note?: string, source?: ModelBehaviorErrorSource);
|
|
20
37
|
}
|
|
21
38
|
export declare class MaxTurnsExceededError extends AgentsError {
|
|
22
39
|
}
|
package/dist/compose/errors.js
CHANGED
|
@@ -18,7 +18,24 @@ class UserError extends AgentsError {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
exports.UserError = UserError;
|
|
21
|
+
/**
|
|
22
|
+
* The agent's answer didn't match its `outputType`. `source` says where: `"server"` (no answer matched the schema
|
|
23
|
+
* after the server's retry; `rawText` is the model's last attempt) or `"local_parse"` (the server accepted the answer
|
|
24
|
+
* but the `outputType`'s `parse` refused it, for example a zod refinement; `rawText` is the server's JSON,
|
|
25
|
+
* re-serialised).
|
|
26
|
+
*/
|
|
21
27
|
class ModelBehaviorError extends AgentsError {
|
|
28
|
+
constructor(rawText = "", errors = [], note, source = "server") {
|
|
29
|
+
const prefix = source === "server" ? "model output rejected" : "model output rejected by outputType";
|
|
30
|
+
super(errors.length ? `${prefix}: ` + errors.join("; ") : rawText);
|
|
31
|
+
/** The run's conversation, set when a run rejects with this, so the caller can continue it (`conversationId`) or
|
|
32
|
+
* fetch its `ResponseDetail`. */
|
|
33
|
+
this.conversationId = undefined;
|
|
34
|
+
this.rawText = rawText;
|
|
35
|
+
this.errors = errors.slice();
|
|
36
|
+
this.note = note;
|
|
37
|
+
this.source = source;
|
|
38
|
+
}
|
|
22
39
|
}
|
|
23
40
|
exports.ModelBehaviorError = ModelBehaviorError;
|
|
24
41
|
class MaxTurnsExceededError extends AgentsError {
|
package/dist/compose/events.d.ts
CHANGED
|
@@ -11,6 +11,14 @@ export interface FunctionCallRequest {
|
|
|
11
11
|
name: string;
|
|
12
12
|
arguments: Record<string, unknown>;
|
|
13
13
|
}
|
|
14
|
+
/** A source the structured output cited: the server's citation-manifest entry, passed through as sent. */
|
|
15
|
+
export interface OutputCitation {
|
|
16
|
+
cite_id: string;
|
|
17
|
+
type?: string;
|
|
18
|
+
url?: string;
|
|
19
|
+
title?: string;
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
}
|
|
14
22
|
export type Event = {
|
|
15
23
|
kind: "text_start";
|
|
16
24
|
id: string;
|
|
@@ -46,6 +54,32 @@ export type Event = {
|
|
|
46
54
|
kind: "stopped";
|
|
47
55
|
reason: string;
|
|
48
56
|
}
|
|
57
|
+
/** The turn's structured output (`data-output`); `output` is null and `skipped` says why when the turn ended
|
|
58
|
+
* without one: `limit`, `budget`, `paused` or `suppressed` (a cron turn that ended `[SILENT]`), passed through as
|
|
59
|
+
* sent, so a newer server's value arrives unchanged. */
|
|
60
|
+
| {
|
|
61
|
+
kind: "output";
|
|
62
|
+
output: unknown;
|
|
63
|
+
skipped?: string;
|
|
64
|
+
/** How the server produced it (`tool_in_loop`, `tool_oversize`, `forced_tool`, `native`, `prompted`), passed
|
|
65
|
+
* through as sent. `tool_oversize`: the model's `final_answer` was too large for the tool loop and the server
|
|
66
|
+
* validated it afterwards. */
|
|
67
|
+
mode?: string;
|
|
68
|
+
/** The sources `output` cited, first citation first; absent when it cited none. `output` itself carries no
|
|
69
|
+
* `[cite:...]` markers. */
|
|
70
|
+
citations?: OutputCitation[];
|
|
71
|
+
/** Set when the turn's `final_answer` was refused for size and was not the answer: `oversize_answer_invalid`
|
|
72
|
+
* (it did not validate) or `oversize_answer_dropped` (too large to check), so `output` came from the model's
|
|
73
|
+
* later text. */
|
|
74
|
+
note?: string;
|
|
75
|
+
}
|
|
76
|
+
/** No answer matched the agent's output schema (`data-output-error`); `note` as on `output`. */
|
|
77
|
+
| {
|
|
78
|
+
kind: "output_error";
|
|
79
|
+
errors: string[];
|
|
80
|
+
rawText: string;
|
|
81
|
+
note?: string;
|
|
82
|
+
}
|
|
49
83
|
/** An agent.json limit ended the turn (`data-turn-limit`); the wrap-up answer still follows. `capKind` is the
|
|
50
84
|
* server's cap name: `max_turns`, `tool_calls` or `tokens`. `limit` is the agent.json `limits` key that set it
|
|
51
85
|
* (`max_turns`, `max_tool_calls_per_turn` or `max_tokens_per_turn`) and `value` the configured number; both are
|
package/dist/compose/events.js
CHANGED
|
@@ -27,7 +27,7 @@ function fromUiChunk(chunk) {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
function map(chunk) {
|
|
30
|
-
var _a, _b;
|
|
30
|
+
var _a, _b, _c;
|
|
31
31
|
const type = chunk["type"];
|
|
32
32
|
const data = isObject(chunk["data"]) ? chunk["data"] : {};
|
|
33
33
|
if (typeof type === "string" && IGNORED.indexOf(type) !== -1)
|
|
@@ -100,8 +100,31 @@ function map(chunk) {
|
|
|
100
100
|
return { kind: "turn_failed", code: str(chunk["code"], "turn_failed"), message: text(chunk["errorText"]) };
|
|
101
101
|
case "finish":
|
|
102
102
|
return { kind: "turn_finished", reason: str(chunk["finishReason"], "stop") };
|
|
103
|
+
case "data-output": {
|
|
104
|
+
const ev = { kind: "output", output: (_c = data["output"]) !== null && _c !== void 0 ? _c : null };
|
|
105
|
+
if (typeof data["skipped"] === "string" && data["skipped"])
|
|
106
|
+
ev.skipped = data["skipped"];
|
|
107
|
+
if (typeof data["mode"] === "string" && data["mode"])
|
|
108
|
+
ev.mode = data["mode"];
|
|
109
|
+
const citations = Array.isArray(data["citations"]) ? data["citations"].filter(isObject) : [];
|
|
110
|
+
if (citations.length)
|
|
111
|
+
ev.citations = citations;
|
|
112
|
+
if (typeof data["note"] === "string" && data["note"])
|
|
113
|
+
ev.note = data["note"];
|
|
114
|
+
return ev;
|
|
115
|
+
}
|
|
116
|
+
case "data-output-error": {
|
|
117
|
+
const errors = data["errors"];
|
|
118
|
+
const ev = {
|
|
119
|
+
kind: "output_error",
|
|
120
|
+
errors: Array.isArray(errors) ? errors.map(String) : typeof errors === "string" ? [errors] : [],
|
|
121
|
+
rawText: text(data["rawText"]),
|
|
122
|
+
};
|
|
123
|
+
if (typeof data["note"] === "string" && data["note"])
|
|
124
|
+
ev.note = data["note"];
|
|
125
|
+
return ev;
|
|
126
|
+
}
|
|
103
127
|
default:
|
|
104
|
-
// data-output and data-output-error are unknown until structured output lands.
|
|
105
128
|
return { kind: "unknown", chunk };
|
|
106
129
|
}
|
|
107
130
|
}
|
package/dist/compose/index.d.ts
CHANGED
|
@@ -2,12 +2,13 @@ export * from "./errors.js";
|
|
|
2
2
|
export * from "./fingerprint.js";
|
|
3
3
|
export * from "./tools.js";
|
|
4
4
|
export * from "./agent.js";
|
|
5
|
-
export type { Event, ClarifyQuestion, FunctionCallRequest } from "./events.js";
|
|
5
|
+
export type { Event, ClarifyQuestion, FunctionCallRequest, OutputCitation } from "./events.js";
|
|
6
6
|
export { SettingsTransport } from "./settingsTransport.js";
|
|
7
7
|
export type { RemoteAgent, SettingsWarning, TurnStream, Transport } from "./transport.js";
|
|
8
8
|
export { deploy, undeploy, setDefaultClient } from "./deploy.js";
|
|
9
9
|
export type { Deployment } from "./deploy.js";
|
|
10
10
|
export { run, RunResult, StreamedRunResult } from "./run.js";
|
|
11
11
|
export type { RunOptions, RunStreamEvent, ClarifyHandler, StopReason } from "./run.js";
|
|
12
|
+
export type { JsonSchemaOutputType, OutputType, ResolvedOutput, SchemaLikeOutputType } from "./output.js";
|
|
12
13
|
export { RunState } from "./runState.js";
|
|
13
14
|
export type { Interruption } from "./runState.js";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** A JSON Schema output type, as in `@openai/agents`. `finalOutput` is the parsed JSON (typed `unknown`). */
|
|
2
|
+
export interface JsonSchemaOutputType {
|
|
3
|
+
type: "json_schema";
|
|
4
|
+
name?: string;
|
|
5
|
+
strict?: boolean;
|
|
6
|
+
schema: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
/** A zod (v4) schema, or anything with the same two methods. `finalOutput` is what `parse` returns. */
|
|
9
|
+
export interface SchemaLikeOutputType<T = unknown> {
|
|
10
|
+
parse(value: unknown): T;
|
|
11
|
+
toJSONSchema(): Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
export type OutputType = JsonSchemaOutputType | SchemaLikeOutputType<unknown>;
|
|
14
|
+
/** The type of `finalOutput` for an agent's output type: text without one. */
|
|
15
|
+
export type ResolvedOutput<T> = [T] extends [undefined] ? string : T extends {
|
|
16
|
+
parse(value: unknown): infer R;
|
|
17
|
+
} ? R : unknown;
|
|
18
|
+
export declare function checkOutputType(v: unknown): void;
|
|
19
|
+
/** Nesting depth of a JSON value, counted like the server: the root is 1. */
|
|
20
|
+
export declare function schemaDepth(node: unknown): number;
|
|
21
|
+
/** The output type's JSON Schema with definitions inlined, an OpenAPI `discriminator` and a no-op
|
|
22
|
+
* `propertyNames: {type: "string"}` dropped, and a root `$schema` naming 2020-12 (what zod writes, and the server's
|
|
23
|
+
* default) dropped; throws UserError on what the server refuses. Another `$schema` is kept, so the server reads the
|
|
24
|
+
* schema in the dialect it names, and must be draft-04 to 2020-12. A zod `.regex()`, `z.email()`, `z.uuid()`,
|
|
25
|
+
* `z.url()` or `z.iso.datetime()` becomes a `pattern`, which it refuses. */
|
|
26
|
+
export declare function outputSchema(outputType: OutputType): Record<string, unknown>;
|
|
27
|
+
/** `data-output`'s JSON as the output type's value; a schema-like type's `parse` must accept it, or this throws
|
|
28
|
+
* `ModelBehaviorError` with `source: "local_parse"` and the server's `note`. */
|
|
29
|
+
export declare function parseOutput(outputType: OutputType, output: unknown, note?: string): unknown;
|