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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** RunState: what a paused run needs to continue (conversation, pending interruptions and the caller's answers). */
|
|
2
2
|
import type { Agent } from "./agent.js";
|
|
3
|
+
import type { OutputType } from "./output.js";
|
|
3
4
|
import type { ClarifyQuestion } from "./events.js";
|
|
4
5
|
export interface Interruption {
|
|
5
6
|
kind: "clarify";
|
|
@@ -22,5 +23,5 @@ export declare class RunState {
|
|
|
22
23
|
/** JSON in the format Python's `RunState.to_json()` writes. */
|
|
23
24
|
toString(): string;
|
|
24
25
|
/** Read a state written by `toString()` (or by Python's `to_json()`). */
|
|
25
|
-
static fromString(agent: Agent
|
|
26
|
+
static fromString(agent: Agent<OutputType | undefined>, s: string): Promise<RunState>;
|
|
26
27
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Configuration } from "../runtime.js";
|
|
2
2
|
import type { Agent } from "./agent.js";
|
|
3
|
+
import type { OutputType } from "./output.js";
|
|
3
4
|
import type { RemoteAgent, Transport, TurnStream } from "./transport.js";
|
|
4
5
|
export declare class SettingsTransport implements Transport {
|
|
5
6
|
private readonly config;
|
|
@@ -10,8 +11,8 @@ export declare class SettingsTransport implements Transport {
|
|
|
10
11
|
constructor(config: Configuration);
|
|
11
12
|
findAgents(sdkName: string): Promise<RemoteAgent[]>;
|
|
12
13
|
readAgent(agentId: string): Promise<RemoteAgent>;
|
|
13
|
-
createAgent(agent: Agent): Promise<RemoteAgent>;
|
|
14
|
-
updateAgent(agentId: string, agent: Agent): Promise<RemoteAgent>;
|
|
14
|
+
createAgent(agent: Agent<OutputType | undefined>): Promise<RemoteAgent>;
|
|
15
|
+
updateAgent(agentId: string, agent: Agent<OutputType | undefined>): Promise<RemoteAgent>;
|
|
15
16
|
deleteAgent(agentId: string): Promise<void>;
|
|
16
17
|
startTurn(agentId: string, conversationId: string | null, text: string, signal?: AbortSignal): Promise<TurnStream>;
|
|
17
18
|
answerClarify(conversationId: string, requestId: string, answers: Record<string, unknown>, signal?: AbortSignal): Promise<TurnStream>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** Transport interface: the seam between the compose layer and the server. */
|
|
2
2
|
import type { Agent } from "./agent.js";
|
|
3
|
+
import type { OutputType } from "./output.js";
|
|
3
4
|
import type { Event } from "./events.js";
|
|
4
5
|
export interface SettingsWarning {
|
|
5
6
|
code: string;
|
|
@@ -24,8 +25,8 @@ export interface Transport {
|
|
|
24
25
|
readonly kind: "settings";
|
|
25
26
|
findAgents(sdkName: string): Promise<RemoteAgent[]>;
|
|
26
27
|
readAgent(agentId: string): Promise<RemoteAgent>;
|
|
27
|
-
createAgent(agent: Agent): Promise<RemoteAgent>;
|
|
28
|
-
updateAgent(agentId: string, agent: Agent): Promise<RemoteAgent>;
|
|
28
|
+
createAgent(agent: Agent<OutputType | undefined>): Promise<RemoteAgent>;
|
|
29
|
+
updateAgent(agentId: string, agent: Agent<OutputType | undefined>): Promise<RemoteAgent>;
|
|
29
30
|
deleteAgent(agentId: string): Promise<void>;
|
|
30
31
|
startTurn(agentId: string, conversationId: string | null, text: string, signal?: AbortSignal): Promise<TurnStream>;
|
|
31
32
|
answerClarify(conversationId: string, requestId: string, answers: Record<string, unknown>, signal?: AbortSignal): Promise<TurnStream>;
|
|
@@ -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>;
|
|
@@ -98,7 +98,7 @@ export class AgentsApi extends runtime.BaseAPI {
|
|
|
98
98
|
return await response.value();
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
101
|
-
* Owner-only soft delete.
|
|
101
|
+
* Owner-only soft delete. The managed state lives on the agent row, so a deleted agent stops being a managed agent with it.
|
|
102
102
|
* Delete Agent
|
|
103
103
|
*/
|
|
104
104
|
async deleteAgentRaw(requestParameters, initOverrides) {
|
|
@@ -123,7 +123,7 @@ export class AgentsApi extends runtime.BaseAPI {
|
|
|
123
123
|
return new runtime.VoidApiResponse(response);
|
|
124
124
|
}
|
|
125
125
|
/**
|
|
126
|
-
* Owner-only soft delete.
|
|
126
|
+
* Owner-only soft delete. The managed state lives on the agent row, so a deleted agent stops being a managed agent with it.
|
|
127
127
|
* Delete Agent
|
|
128
128
|
*/
|
|
129
129
|
async deleteAgent(requestParameters, initOverrides) {
|
|
@@ -474,7 +474,7 @@ export class AgentsApi extends runtime.BaseAPI {
|
|
|
474
474
|
return await response.value();
|
|
475
475
|
}
|
|
476
476
|
/**
|
|
477
|
-
* 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
|
|
477
|
+
* 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.
|
|
478
478
|
* List Agents
|
|
479
479
|
*/
|
|
480
480
|
async listAgentsRaw(requestParameters, initOverrides) {
|
|
@@ -532,7 +532,7 @@ export class AgentsApi extends runtime.BaseAPI {
|
|
|
532
532
|
return new runtime.JSONApiResponse(response, (jsonValue) => EntityListAgentResourceFromJSON(jsonValue));
|
|
533
533
|
}
|
|
534
534
|
/**
|
|
535
|
-
* 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
|
|
535
|
+
* 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.
|
|
536
536
|
* List Agents
|
|
537
537
|
*/
|
|
538
538
|
async listAgents(requestParameters = {}, initOverrides) {
|
package/dist/esm/apis/AppsApi.js
CHANGED
|
@@ -350,6 +350,9 @@ export class AppsApi extends runtime.BaseAPI {
|
|
|
350
350
|
if (requestParameters['includeFilterOptions'] != null) {
|
|
351
351
|
queryParameters['includeFilterOptions'] = requestParameters['includeFilterOptions'];
|
|
352
352
|
}
|
|
353
|
+
if (requestParameters['custom'] != null) {
|
|
354
|
+
queryParameters['custom'] = requestParameters['custom'];
|
|
355
|
+
}
|
|
353
356
|
const headerParameters = {};
|
|
354
357
|
if (this.configuration && this.configuration.accessToken) {
|
|
355
358
|
const token = this.configuration.accessToken;
|
|
@@ -78,6 +78,9 @@ export class QueueApi extends runtime.BaseAPI {
|
|
|
78
78
|
if (requestParameters['xClientVersion'] != null) {
|
|
79
79
|
headerParameters['X-Client-Version'] = String(requestParameters['xClientVersion']);
|
|
80
80
|
}
|
|
81
|
+
if (requestParameters['xLoginId'] != null) {
|
|
82
|
+
headerParameters['X-Login-Id'] = String(requestParameters['xLoginId']);
|
|
83
|
+
}
|
|
81
84
|
if (this.configuration && this.configuration.accessToken) {
|
|
82
85
|
const token = this.configuration.accessToken;
|
|
83
86
|
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
|
*
|
|
@@ -36,6 +36,9 @@ export class ResponsesApi extends runtime.BaseAPI {
|
|
|
36
36
|
if (requestParameters['xClientVersion'] != null) {
|
|
37
37
|
headerParameters['X-Client-Version'] = String(requestParameters['xClientVersion']);
|
|
38
38
|
}
|
|
39
|
+
if (requestParameters['xLoginId'] != null) {
|
|
40
|
+
headerParameters['X-Login-Id'] = String(requestParameters['xLoginId']);
|
|
41
|
+
}
|
|
39
42
|
if (this.configuration && this.configuration.accessToken) {
|
|
40
43
|
const token = this.configuration.accessToken;
|
|
41
44
|
const tokenString = await token("bearerAuth", []);
|
|
@@ -138,6 +141,9 @@ export class ResponsesApi extends runtime.BaseAPI {
|
|
|
138
141
|
if (requestParameters['xClientVersion'] != null) {
|
|
139
142
|
headerParameters['X-Client-Version'] = String(requestParameters['xClientVersion']);
|
|
140
143
|
}
|
|
144
|
+
if (requestParameters['xLoginId'] != null) {
|
|
145
|
+
headerParameters['X-Login-Id'] = String(requestParameters['xLoginId']);
|
|
146
|
+
}
|
|
141
147
|
if (this.configuration && this.configuration.accessToken) {
|
|
142
148
|
const token = this.configuration.accessToken;
|
|
143
149
|
const tokenString = await token("bearerAuth", []);
|
|
@@ -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;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NotSupportedError, UserError } from "./errors.js";
|
|
2
2
|
import { settingsFingerprint } from "./fingerprint.js";
|
|
3
3
|
import { BUILTIN_NAMES, checkWebSearchOptions } from "./builtins.js";
|
|
4
|
+
import { checkOutputType, outputSchema } from "./output.js";
|
|
4
5
|
const SLUG = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
5
6
|
const REASONING = ["off", "none", "low", "medium", "high", "xhigh", "max"];
|
|
6
7
|
const TOOL_CHOICES = ["auto", "none"];
|
|
@@ -89,6 +90,7 @@ export class Agent {
|
|
|
89
90
|
this.tools = clone(opts.tools);
|
|
90
91
|
this.limits = clone(opts.limits);
|
|
91
92
|
this.metadata = clone(opts.metadata);
|
|
93
|
+
Object.defineProperty(this, "outputType", { value: opts.outputType, enumerable: false, writable: false });
|
|
92
94
|
this.check();
|
|
93
95
|
deepFreeze(this);
|
|
94
96
|
}
|
|
@@ -97,6 +99,10 @@ export class Agent {
|
|
|
97
99
|
if (typeof this.name !== "string" || !SLUG.test(this.name)) {
|
|
98
100
|
throw new UserError(`name: ${JSON.stringify(this.name)} must match ${SLUG.source}`);
|
|
99
101
|
}
|
|
102
|
+
if (this.outputType !== undefined) {
|
|
103
|
+
checkOutputType(this.outputType);
|
|
104
|
+
outputSchema(this.outputType); // refuse what the server would, before anything is sent
|
|
105
|
+
}
|
|
100
106
|
for (const [key, value] of [["model", this.model], ["endpoint", this.endpoint]]) {
|
|
101
107
|
if (value !== undefined && (typeof value !== "string" || value === "")) {
|
|
102
108
|
throw new UserError(`${key}: must be a non-empty string`);
|
|
@@ -200,6 +206,8 @@ export class Agent {
|
|
|
200
206
|
}
|
|
201
207
|
out["builtin_tools"] = tools;
|
|
202
208
|
}
|
|
209
|
+
if (this.outputType !== undefined)
|
|
210
|
+
out["output_schema"] = outputSchema(this.outputType);
|
|
203
211
|
return out;
|
|
204
212
|
}
|
|
205
213
|
specHash() {
|
|
@@ -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>;
|
|
@@ -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
|
}
|
|
@@ -13,7 +13,24 @@ export class UserError extends AgentsError {
|
|
|
13
13
|
this.issues = issues;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* The agent's answer didn't match its `outputType`. `source` says where: `"server"` (no answer matched the schema
|
|
18
|
+
* after the server's retry; `rawText` is the model's last attempt) or `"local_parse"` (the server accepted the answer
|
|
19
|
+
* but the `outputType`'s `parse` refused it, for example a zod refinement; `rawText` is the server's JSON,
|
|
20
|
+
* re-serialised).
|
|
21
|
+
*/
|
|
16
22
|
export class ModelBehaviorError extends AgentsError {
|
|
23
|
+
constructor(rawText = "", errors = [], note, source = "server") {
|
|
24
|
+
const prefix = source === "server" ? "model output rejected" : "model output rejected by outputType";
|
|
25
|
+
super(errors.length ? `${prefix}: ` + errors.join("; ") : rawText);
|
|
26
|
+
/** The run's conversation, set when a run rejects with this, so the caller can continue it (`conversationId`) or
|
|
27
|
+
* fetch its `ResponseDetail`. */
|
|
28
|
+
this.conversationId = undefined;
|
|
29
|
+
this.rawText = rawText;
|
|
30
|
+
this.errors = errors.slice();
|
|
31
|
+
this.note = note;
|
|
32
|
+
this.source = source;
|
|
33
|
+
}
|
|
17
34
|
}
|
|
18
35
|
export class MaxTurnsExceededError extends AgentsError {
|
|
19
36
|
}
|
|
@@ -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
|
|
@@ -24,7 +24,7 @@ export function fromUiChunk(chunk) {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
function map(chunk) {
|
|
27
|
-
var _a, _b;
|
|
27
|
+
var _a, _b, _c;
|
|
28
28
|
const type = chunk["type"];
|
|
29
29
|
const data = isObject(chunk["data"]) ? chunk["data"] : {};
|
|
30
30
|
if (typeof type === "string" && IGNORED.indexOf(type) !== -1)
|
|
@@ -97,8 +97,31 @@ function map(chunk) {
|
|
|
97
97
|
return { kind: "turn_failed", code: str(chunk["code"], "turn_failed"), message: text(chunk["errorText"]) };
|
|
98
98
|
case "finish":
|
|
99
99
|
return { kind: "turn_finished", reason: str(chunk["finishReason"], "stop") };
|
|
100
|
+
case "data-output": {
|
|
101
|
+
const ev = { kind: "output", output: (_c = data["output"]) !== null && _c !== void 0 ? _c : null };
|
|
102
|
+
if (typeof data["skipped"] === "string" && data["skipped"])
|
|
103
|
+
ev.skipped = data["skipped"];
|
|
104
|
+
if (typeof data["mode"] === "string" && data["mode"])
|
|
105
|
+
ev.mode = data["mode"];
|
|
106
|
+
const citations = Array.isArray(data["citations"]) ? data["citations"].filter(isObject) : [];
|
|
107
|
+
if (citations.length)
|
|
108
|
+
ev.citations = citations;
|
|
109
|
+
if (typeof data["note"] === "string" && data["note"])
|
|
110
|
+
ev.note = data["note"];
|
|
111
|
+
return ev;
|
|
112
|
+
}
|
|
113
|
+
case "data-output-error": {
|
|
114
|
+
const errors = data["errors"];
|
|
115
|
+
const ev = {
|
|
116
|
+
kind: "output_error",
|
|
117
|
+
errors: Array.isArray(errors) ? errors.map(String) : typeof errors === "string" ? [errors] : [],
|
|
118
|
+
rawText: text(data["rawText"]),
|
|
119
|
+
};
|
|
120
|
+
if (typeof data["note"] === "string" && data["note"])
|
|
121
|
+
ev.note = data["note"];
|
|
122
|
+
return ev;
|
|
123
|
+
}
|
|
100
124
|
default:
|
|
101
|
-
// data-output and data-output-error are unknown until structured output lands.
|
|
102
125
|
return { kind: "unknown", chunk };
|
|
103
126
|
}
|
|
104
127
|
}
|
|
@@ -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;
|