sarvam-agents-client 0.1.2 → 0.2.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/README.md +15 -0
- package/dist/apis/AgentConversationsApi.d.ts +44 -1
- package/dist/apis/AgentConversationsApi.js +104 -1
- package/dist/apis/AgentsApi.d.ts +77 -5
- package/dist/apis/AgentsApi.js +163 -5
- package/dist/apis/AppsApi.d.ts +43 -1
- package/dist/apis/AppsApi.js +108 -0
- package/dist/apis/ArtifactsApi.d.ts +31 -1
- package/dist/apis/ArtifactsApi.js +82 -0
- package/dist/apis/CustomAPIsApi.d.ts +124 -0
- package/dist/apis/CustomAPIsApi.js +305 -0
- package/dist/apis/ModelsApi.d.ts +26 -0
- package/dist/apis/ModelsApi.js +52 -0
- package/dist/apis/index.d.ts +2 -0
- package/dist/apis/index.js +2 -0
- package/dist/compose/agent.d.ts +40 -0
- package/dist/compose/agent.js +191 -0
- package/dist/compose/deploy.d.ts +30 -0
- package/dist/compose/deploy.js +146 -0
- package/dist/compose/errors.d.ts +48 -0
- package/dist/compose/errors.js +68 -0
- package/dist/compose/events.d.ts +63 -0
- package/dist/compose/events.js +100 -0
- package/dist/compose/fingerprint.d.ts +6 -0
- package/dist/compose/fingerprint.js +83 -0
- package/dist/compose/index.d.ts +13 -0
- package/dist/compose/index.js +33 -0
- package/dist/compose/run.d.ts +100 -0
- package/dist/compose/run.js +536 -0
- package/dist/compose/runState.d.ts +26 -0
- package/dist/compose/runState.js +79 -0
- package/dist/compose/settingsTransport.d.ts +24 -0
- package/dist/compose/settingsTransport.js +280 -0
- package/dist/compose/tools.d.ts +17 -0
- package/dist/compose/tools.js +29 -0
- package/dist/compose/transport.d.ts +34 -0
- package/dist/compose/transport.js +2 -0
- package/dist/esm/apis/AgentConversationsApi.d.ts +44 -1
- package/dist/esm/apis/AgentConversationsApi.js +104 -1
- package/dist/esm/apis/AgentsApi.d.ts +77 -5
- package/dist/esm/apis/AgentsApi.js +163 -5
- package/dist/esm/apis/AppsApi.d.ts +43 -1
- package/dist/esm/apis/AppsApi.js +109 -1
- package/dist/esm/apis/ArtifactsApi.d.ts +31 -1
- package/dist/esm/apis/ArtifactsApi.js +83 -1
- package/dist/esm/apis/CustomAPIsApi.d.ts +124 -0
- package/dist/esm/apis/CustomAPIsApi.js +301 -0
- package/dist/esm/apis/ModelsApi.d.ts +26 -0
- package/dist/esm/apis/ModelsApi.js +48 -0
- package/dist/esm/apis/index.d.ts +2 -0
- package/dist/esm/apis/index.js +2 -0
- package/dist/esm/compose/agent.d.ts +40 -0
- package/dist/esm/compose/agent.js +187 -0
- package/dist/esm/compose/deploy.d.ts +30 -0
- package/dist/esm/compose/deploy.js +137 -0
- package/dist/esm/compose/errors.d.ts +48 -0
- package/dist/esm/compose/errors.js +53 -0
- package/dist/esm/compose/events.d.ts +63 -0
- package/dist/esm/compose/events.js +97 -0
- package/dist/esm/compose/fingerprint.d.ts +6 -0
- package/dist/esm/compose/fingerprint.js +78 -0
- package/dist/esm/compose/index.d.ts +13 -0
- package/dist/esm/compose/index.js +8 -0
- package/dist/esm/compose/run.d.ts +100 -0
- package/dist/esm/compose/run.js +530 -0
- package/dist/esm/compose/runState.d.ts +26 -0
- package/dist/esm/compose/runState.js +75 -0
- package/dist/esm/compose/settingsTransport.d.ts +24 -0
- package/dist/esm/compose/settingsTransport.js +276 -0
- package/dist/esm/compose/tools.d.ts +17 -0
- package/dist/esm/compose/tools.js +19 -0
- package/dist/esm/compose/transport.d.ts +34 -0
- package/dist/esm/compose/transport.js +1 -0
- package/dist/esm/models/AgentChannelRef.d.ts +1 -0
- package/dist/esm/models/AgentChannelRef.js +2 -1
- package/dist/esm/models/AgentConversationDetail.d.ts +15 -2
- package/dist/esm/models/AgentConversationDetail.js +6 -4
- package/dist/esm/models/AgentConversationView.d.ts +11 -5
- package/dist/esm/models/AgentConversationView.js +4 -4
- package/dist/esm/models/AgentCreate.d.ts +8 -0
- package/dist/esm/models/AgentCreate.js +2 -0
- package/dist/esm/models/AgentCustomApiList.d.ts +33 -0
- package/dist/esm/models/AgentCustomApiList.js +44 -0
- package/dist/esm/models/AgentResource.d.ts +14 -0
- package/dist/esm/models/AgentResource.js +4 -0
- package/dist/esm/models/AgentSettingsResponse.d.ts +53 -0
- package/dist/esm/models/AgentSettingsResponse.js +52 -0
- package/dist/esm/models/AgentUpdate.d.ts +8 -0
- package/dist/esm/models/AgentUpdate.js +2 -0
- package/dist/esm/models/AppAccountView.d.ts +88 -0
- package/dist/esm/models/AppAccountView.js +79 -0
- package/dist/esm/models/AppAccountsView.d.ts +66 -0
- package/dist/esm/models/AppAccountsView.js +60 -0
- package/dist/esm/models/AppResource.d.ts +36 -0
- package/dist/esm/models/AppResource.js +12 -0
- package/dist/esm/models/AppResourceCheckView.d.ts +74 -0
- package/dist/esm/models/AppResourceCheckView.js +63 -0
- package/dist/esm/models/AppResourceView.d.ts +68 -0
- package/dist/esm/models/AppResourceView.js +67 -0
- package/dist/esm/models/AppResourcesView.d.ts +54 -0
- package/dist/esm/models/AppResourcesView.js +56 -0
- package/dist/esm/models/AppToolsResponse.d.ts +14 -0
- package/dist/esm/models/AppToolsResponse.js +4 -0
- package/dist/esm/models/AppView.d.ts +42 -0
- package/dist/esm/models/AppView.js +14 -0
- package/dist/esm/models/ArtifactVersionResponse.d.ts +94 -0
- package/dist/esm/models/ArtifactVersionResponse.js +80 -0
- package/dist/esm/models/AttachedAgent.d.ts +44 -0
- package/dist/esm/models/AttachedAgent.js +49 -0
- package/dist/esm/models/Auth.d.ts +30 -0
- package/dist/esm/models/Auth.js +52 -0
- package/dist/esm/models/BindCustomApiBody.d.ts +32 -0
- package/dist/esm/models/BindCustomApiBody.js +43 -0
- package/dist/esm/models/ConversationArtifact.d.ts +14 -0
- package/dist/esm/models/ConversationArtifact.js +9 -0
- package/dist/esm/models/CustomApi.d.ts +102 -0
- package/dist/esm/models/CustomApi.js +90 -0
- package/dist/esm/models/CustomApiBasicAuth.d.ts +51 -0
- package/dist/esm/models/CustomApiBasicAuth.js +57 -0
- package/dist/esm/models/CustomApiBearerAuth.d.ts +45 -0
- package/dist/esm/models/CustomApiBearerAuth.js +53 -0
- package/dist/esm/models/CustomApiCreate.d.ts +57 -0
- package/dist/esm/models/CustomApiCreate.js +56 -0
- package/dist/esm/models/CustomApiHeader.d.ts +44 -0
- package/dist/esm/models/CustomApiHeader.js +47 -0
- package/dist/esm/models/CustomApiHeadersAuth.d.ts +46 -0
- package/dist/esm/models/CustomApiHeadersAuth.js +54 -0
- package/dist/esm/models/CustomApiList.d.ts +64 -0
- package/dist/esm/models/CustomApiList.js +64 -0
- package/dist/esm/models/CustomApiName.d.ts +44 -0
- package/dist/esm/models/CustomApiName.js +49 -0
- package/dist/esm/models/CustomApiUpdate.d.ts +58 -0
- package/dist/esm/models/CustomApiUpdate.js +50 -0
- package/dist/esm/models/CustomApiUpdateAuth.d.ts +30 -0
- package/dist/esm/models/CustomApiUpdateAuth.js +52 -0
- package/dist/esm/models/ErrorDetailItem.d.ts +5 -0
- package/dist/esm/models/ListModels403Response.d.ts +23 -0
- package/dist/esm/models/ListModels403Response.js +45 -0
- package/dist/esm/models/ModelEndpointView.d.ts +38 -0
- package/dist/esm/models/ModelEndpointView.js +45 -0
- package/dist/esm/models/ModelView.d.ts +69 -0
- package/dist/esm/models/ModelView.js +56 -0
- package/dist/esm/models/ModelsResponse.d.ts +33 -0
- package/dist/esm/models/ModelsResponse.js +44 -0
- package/dist/esm/models/SettingsIssueView.d.ts +44 -0
- package/dist/esm/models/SettingsIssueView.js +51 -0
- package/dist/esm/models/VersionCommitBody.d.ts +44 -0
- package/dist/esm/models/VersionCommitBody.js +51 -0
- package/dist/esm/models/VersionUploadUrlBody.d.ts +32 -0
- package/dist/esm/models/VersionUploadUrlBody.js +43 -0
- package/dist/esm/models/index.d.ts +28 -0
- package/dist/esm/models/index.js +28 -0
- package/dist/models/AgentChannelRef.d.ts +1 -0
- package/dist/models/AgentChannelRef.js +2 -1
- package/dist/models/AgentConversationDetail.d.ts +15 -2
- package/dist/models/AgentConversationDetail.js +6 -4
- package/dist/models/AgentConversationView.d.ts +11 -5
- package/dist/models/AgentConversationView.js +4 -4
- package/dist/models/AgentCreate.d.ts +8 -0
- package/dist/models/AgentCreate.js +2 -0
- package/dist/models/AgentCustomApiList.d.ts +33 -0
- package/dist/models/AgentCustomApiList.js +51 -0
- package/dist/models/AgentResource.d.ts +14 -0
- package/dist/models/AgentResource.js +4 -0
- package/dist/models/AgentSettingsResponse.d.ts +53 -0
- package/dist/models/AgentSettingsResponse.js +59 -0
- package/dist/models/AgentUpdate.d.ts +8 -0
- package/dist/models/AgentUpdate.js +2 -0
- package/dist/models/AppAccountView.d.ts +88 -0
- package/dist/models/AppAccountView.js +87 -0
- package/dist/models/AppAccountsView.d.ts +66 -0
- package/dist/models/AppAccountsView.js +68 -0
- package/dist/models/AppResource.d.ts +36 -0
- package/dist/models/AppResource.js +12 -0
- package/dist/models/AppResourceCheckView.d.ts +74 -0
- package/dist/models/AppResourceCheckView.js +71 -0
- package/dist/models/AppResourceView.d.ts +68 -0
- package/dist/models/AppResourceView.js +74 -0
- package/dist/models/AppResourcesView.d.ts +54 -0
- package/dist/models/AppResourcesView.js +64 -0
- package/dist/models/AppToolsResponse.d.ts +14 -0
- package/dist/models/AppToolsResponse.js +4 -0
- package/dist/models/AppView.d.ts +42 -0
- package/dist/models/AppView.js +14 -0
- package/dist/models/ArtifactVersionResponse.d.ts +94 -0
- package/dist/models/ArtifactVersionResponse.js +88 -0
- package/dist/models/AttachedAgent.d.ts +44 -0
- package/dist/models/AttachedAgent.js +56 -0
- package/dist/models/Auth.d.ts +30 -0
- package/dist/models/Auth.js +58 -0
- package/dist/models/BindCustomApiBody.d.ts +32 -0
- package/dist/models/BindCustomApiBody.js +50 -0
- package/dist/models/ConversationArtifact.d.ts +14 -0
- package/dist/models/ConversationArtifact.js +10 -0
- package/dist/models/CustomApi.d.ts +102 -0
- package/dist/models/CustomApi.js +98 -0
- package/dist/models/CustomApiBasicAuth.d.ts +51 -0
- package/dist/models/CustomApiBasicAuth.js +65 -0
- package/dist/models/CustomApiBearerAuth.d.ts +45 -0
- package/dist/models/CustomApiBearerAuth.js +61 -0
- package/dist/models/CustomApiCreate.d.ts +57 -0
- package/dist/models/CustomApiCreate.js +63 -0
- package/dist/models/CustomApiHeader.d.ts +44 -0
- package/dist/models/CustomApiHeader.js +54 -0
- package/dist/models/CustomApiHeadersAuth.d.ts +46 -0
- package/dist/models/CustomApiHeadersAuth.js +62 -0
- package/dist/models/CustomApiList.d.ts +64 -0
- package/dist/models/CustomApiList.js +71 -0
- package/dist/models/CustomApiName.d.ts +44 -0
- package/dist/models/CustomApiName.js +56 -0
- package/dist/models/CustomApiUpdate.d.ts +58 -0
- package/dist/models/CustomApiUpdate.js +57 -0
- package/dist/models/CustomApiUpdateAuth.d.ts +30 -0
- package/dist/models/CustomApiUpdateAuth.js +58 -0
- package/dist/models/ErrorDetailItem.d.ts +5 -0
- package/dist/models/ListModels403Response.d.ts +23 -0
- package/dist/models/ListModels403Response.js +51 -0
- package/dist/models/ModelEndpointView.d.ts +38 -0
- package/dist/models/ModelEndpointView.js +52 -0
- package/dist/models/ModelView.d.ts +69 -0
- package/dist/models/ModelView.js +63 -0
- package/dist/models/ModelsResponse.d.ts +33 -0
- package/dist/models/ModelsResponse.js +51 -0
- package/dist/models/SettingsIssueView.d.ts +44 -0
- package/dist/models/SettingsIssueView.js +58 -0
- package/dist/models/VersionCommitBody.d.ts +44 -0
- package/dist/models/VersionCommitBody.js +58 -0
- package/dist/models/VersionUploadUrlBody.d.ts +32 -0
- package/dist/models/VersionUploadUrlBody.js +50 -0
- package/dist/models/index.d.ts +28 -0
- package/dist/models/index.js +28 -0
- package/package.json +15 -2
- package/src/apis/AgentConversationsApi.ts +172 -3
- package/src/apis/AgentsApi.ts +242 -7
- package/src/apis/AppsApi.ts +174 -3
- package/src/apis/ArtifactsApi.ts +144 -0
- package/src/apis/ClarifyApi.ts +3 -3
- package/src/apis/CollectionsApi.ts +3 -3
- package/src/apis/ConversationsApi.ts +3 -3
- package/src/apis/CronsApi.ts +3 -3
- package/src/apis/CustomAPIsApi.ts +471 -0
- package/src/apis/MessagesApi.ts +3 -3
- package/src/apis/ModelsApi.ts +70 -0
- package/src/apis/QueueApi.ts +3 -3
- package/src/apis/ResponsesApi.ts +3 -3
- package/src/apis/SkillsApi.ts +3 -3
- package/src/apis/index.ts +2 -0
- package/src/compose/agent.ts +223 -0
- package/src/compose/deploy.ts +168 -0
- package/src/compose/errors.ts +66 -0
- package/src/compose/events.ts +122 -0
- package/src/compose/fingerprint.ts +74 -0
- package/src/compose/index.ts +13 -0
- package/src/compose/run.ts +601 -0
- package/src/compose/runState.ts +95 -0
- package/src/compose/settingsTransport.ts +299 -0
- package/src/compose/tools.ts +27 -0
- package/src/compose/transport.ts +48 -0
- package/src/models/AgentChannelRef.ts +2 -1
- package/src/models/AgentConversationDetail.ts +21 -5
- package/src/models/AgentConversationView.ts +15 -8
- package/src/models/AgentCreate.ts +8 -0
- package/src/models/AgentCustomApiList.ts +74 -0
- package/src/models/AgentResource.ts +16 -0
- package/src/models/AgentSettingsResponse.ts +99 -0
- package/src/models/AgentUpdate.ts +8 -0
- package/src/models/AppAccountView.ts +143 -0
- package/src/models/AppAccountsView.ts +118 -0
- package/src/models/AppResource.ts +48 -0
- package/src/models/AppResourceCheckView.ts +117 -0
- package/src/models/AppResourceView.ts +120 -0
- package/src/models/AppResourcesView.ts +102 -0
- package/src/models/AppToolsResponse.ts +16 -0
- package/src/models/AppView.ts +56 -0
- package/src/models/ArtifactVersionResponse.ts +155 -0
- package/src/models/AttachedAgent.ts +83 -0
- package/src/models/Auth.ts +84 -0
- package/src/models/BindCustomApiBody.ts +66 -0
- package/src/models/ConversationArtifact.ts +19 -0
- package/src/models/CustomApi.ts +175 -0
- package/src/models/CustomApiBasicAuth.ts +94 -0
- package/src/models/CustomApiBearerAuth.ts +85 -0
- package/src/models/CustomApiCreate.ts +108 -0
- package/src/models/CustomApiHeader.ts +82 -0
- package/src/models/CustomApiHeadersAuth.ts +93 -0
- package/src/models/CustomApiList.ts +120 -0
- package/src/models/CustomApiName.ts +83 -0
- package/src/models/CustomApiUpdate.ts +106 -0
- package/src/models/CustomApiUpdateAuth.ts +84 -0
- package/src/models/ErrorDetailItem.ts +5 -0
- package/src/models/ListModels403Response.ts +73 -0
- package/src/models/ModelEndpointView.ts +74 -0
- package/src/models/ModelView.ts +122 -0
- package/src/models/ModelsResponse.ts +74 -0
- package/src/models/SettingsIssueView.ts +84 -0
- package/src/models/VersionCommitBody.ts +84 -0
- package/src/models/VersionUploadUrlBody.ts +66 -0
- package/src/models/index.ts +28 -0
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
/** SettingsTransport: the compose transport on the generated API (agent settings file + responses stream). */
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { AgentsApi } from "../apis/AgentsApi.js";
|
|
4
|
+
import { ConversationsApi } from "../apis/ConversationsApi.js";
|
|
5
|
+
import { ResponsesApi } from "../apis/ResponsesApi.js";
|
|
6
|
+
import { ResponseError } from "../runtime.js";
|
|
7
|
+
import type { Configuration } from "../runtime.js";
|
|
8
|
+
import { answerClarify, reconnect, streamResponse } from "../streaming.js";
|
|
9
|
+
import type { ResponseStream } from "../streaming.js";
|
|
10
|
+
import type { Agent } from "./agent.js";
|
|
11
|
+
import { NotSupportedByServerError, UserError } from "./errors.js";
|
|
12
|
+
import { fromUiChunk } from "./events.js";
|
|
13
|
+
import type { Event } from "./events.js";
|
|
14
|
+
import type { RemoteAgent, SettingsWarning, Transport, TurnStream } from "./transport.js";
|
|
15
|
+
|
|
16
|
+
const PAGE = 100;
|
|
17
|
+
|
|
18
|
+
interface Envelope {
|
|
19
|
+
settings?: { [key: string]: any } | null;
|
|
20
|
+
warnings?: SettingsWarning[] | null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function isNotFound(err: unknown): boolean {
|
|
24
|
+
return err instanceof ResponseError && err.response.status === 404;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** TurnStream over a streaming ResponseStream; ids are read live from the underlying stream. */
|
|
28
|
+
class Stream implements TurnStream {
|
|
29
|
+
constructor(
|
|
30
|
+
private readonly inner: ResponseStream,
|
|
31
|
+
readonly conversationId: string | null,
|
|
32
|
+
) {}
|
|
33
|
+
|
|
34
|
+
get responseId(): string | null {
|
|
35
|
+
return this.inner.responseId;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
get lastEventId(): string | null {
|
|
39
|
+
return this.inner.lastEventId;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async *[Symbol.asyncIterator](): AsyncGenerator<Event> {
|
|
43
|
+
for await (const chunk of this.inner) {
|
|
44
|
+
const event = fromUiChunk(chunk);
|
|
45
|
+
if (event !== null) yield event;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
close(): void {
|
|
50
|
+
this.inner.close();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export class SettingsTransport implements Transport {
|
|
55
|
+
readonly kind = "settings" as const;
|
|
56
|
+
private readonly agents: AgentsApi;
|
|
57
|
+
private readonly conversations: ConversationsApi;
|
|
58
|
+
private readonly responses: ResponsesApi;
|
|
59
|
+
|
|
60
|
+
constructor(private readonly config: Configuration) {
|
|
61
|
+
this.agents = new AgentsApi(config);
|
|
62
|
+
this.conversations = new ConversationsApi(config);
|
|
63
|
+
this.responses = new ResponsesApi(config);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// -- agents ---------------------------------------------------------------------------------------------
|
|
67
|
+
|
|
68
|
+
async findAgents(sdkName: string): Promise<RemoteAgent[]> {
|
|
69
|
+
const found: RemoteAgent[] = [];
|
|
70
|
+
let offset = 0;
|
|
71
|
+
for (;;) {
|
|
72
|
+
const result = await this.agents.listAgents({ q: sdkName, limit: PAGE, offset });
|
|
73
|
+
const items = result.data;
|
|
74
|
+
for (const item of items) {
|
|
75
|
+
if (item.name !== sdkName) continue;
|
|
76
|
+
const resource = await this.agents.getAgent({ agentId: item.id });
|
|
77
|
+
const metadata = (resource.settings ?? {})["metadata"];
|
|
78
|
+
if (metadata && metadata["sdk_name"] === sdkName) {
|
|
79
|
+
found.push(this.remote(resource, await this.instructions(item.id)));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
offset += items.length;
|
|
83
|
+
if (items.length === 0 || !result.hasMore) return found;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async readAgent(agentId: string): Promise<RemoteAgent> {
|
|
88
|
+
const resource = await this.agents.getAgent({ agentId });
|
|
89
|
+
return this.remote(resource, await this.instructions(agentId));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async createAgent(agent: Agent): Promise<RemoteAgent> {
|
|
93
|
+
const settings = agent.toSettings();
|
|
94
|
+
let resource;
|
|
95
|
+
try {
|
|
96
|
+
resource = await this.agents.createAgent({
|
|
97
|
+
agentCreate: { name: agent.name, instructions: agent.instructions, settings },
|
|
98
|
+
});
|
|
99
|
+
} catch (err) {
|
|
100
|
+
// A 422 stored nothing, so there is no agent to delete.
|
|
101
|
+
throw (await invalidSettings(err)) ?? err;
|
|
102
|
+
}
|
|
103
|
+
let envelope: Envelope;
|
|
104
|
+
let warnings: SettingsWarning[];
|
|
105
|
+
// The create response never echoes settings, so support is read back from the settings route, which 404s
|
|
106
|
+
// when the server has settings switched off (create then silently drops them).
|
|
107
|
+
try {
|
|
108
|
+
try {
|
|
109
|
+
envelope = await this.agents.getAgentSettings({ agentId: resource.id });
|
|
110
|
+
} catch (err) {
|
|
111
|
+
if (isNotFound(err)) throw new NotSupportedByServerError(["settings"]);
|
|
112
|
+
throw err;
|
|
113
|
+
}
|
|
114
|
+
warnings = checkWarnings(envelope, settings);
|
|
115
|
+
checkMetadata(envelope, agent);
|
|
116
|
+
await this.agents.deployAgent({ agentId: resource.id });
|
|
117
|
+
} catch (err) {
|
|
118
|
+
// Don't leave an orphan agent behind; a failing cleanup must not mask the original error.
|
|
119
|
+
try {
|
|
120
|
+
await this.agents.deleteAgent({ agentId: resource.id });
|
|
121
|
+
} catch (cleanup) {
|
|
122
|
+
console.warn(`could not delete agent ${resource.id} after failed create: ${cleanup}`);
|
|
123
|
+
}
|
|
124
|
+
throw err;
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
agentId: resource.id,
|
|
128
|
+
name: agent.name,
|
|
129
|
+
instructions: agent.instructions,
|
|
130
|
+
settings: { ...(envelope.settings ?? {}) },
|
|
131
|
+
warnings,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async updateAgent(agentId: string, agent: Agent): Promise<RemoteAgent> {
|
|
136
|
+
const settings = agent.toSettings();
|
|
137
|
+
// findAgents searches by display name, so an adopted (or dashboard-renamed) agent must carry sdk_name.
|
|
138
|
+
if ((await this.agents.getAgent({ agentId })).name !== agent.name) {
|
|
139
|
+
await this.agents.updateAgent({ agentId, agentUpdate: { name: agent.name } });
|
|
140
|
+
}
|
|
141
|
+
// Rejections are only visible after the server stored the settings, so keep what was there to put it back.
|
|
142
|
+
const previousInstructions = await this.instructions(agentId);
|
|
143
|
+
let previousSettings: { [key: string]: any };
|
|
144
|
+
try {
|
|
145
|
+
previousSettings = { ...((await this.agents.getAgentSettings({ agentId })).settings ?? {}) };
|
|
146
|
+
} catch (err) {
|
|
147
|
+
if (isNotFound(err)) throw new NotSupportedByServerError(["settings"]);
|
|
148
|
+
throw err;
|
|
149
|
+
}
|
|
150
|
+
// Instructions first: the settings carry the new sdk_hash, and a hash written ahead of the instructions it
|
|
151
|
+
// covers would read as an edit made outside the SDK if the instructions write then failed.
|
|
152
|
+
const instructionsChanged = previousInstructions !== agent.instructions;
|
|
153
|
+
if (instructionsChanged) {
|
|
154
|
+
await this.agents.putInstructions({ agentId, instructionsBody: { data: agent.instructions } });
|
|
155
|
+
}
|
|
156
|
+
let envelope: Envelope;
|
|
157
|
+
try {
|
|
158
|
+
envelope = await this.agents.putAgentSettings({ agentId, body: settings });
|
|
159
|
+
} catch (err) {
|
|
160
|
+
if (isNotFound(err)) throw new NotSupportedByServerError(["settings"]);
|
|
161
|
+
const invalid = await invalidSettings(err);
|
|
162
|
+
if (invalid === null) throw err;
|
|
163
|
+
// The failed PUT stored nothing; only the instructions need putting back.
|
|
164
|
+
if (instructionsChanged) await this.restore(agentId, null, previousInstructions);
|
|
165
|
+
throw invalid;
|
|
166
|
+
}
|
|
167
|
+
let warnings: SettingsWarning[];
|
|
168
|
+
try {
|
|
169
|
+
warnings = checkWarnings(envelope, settings);
|
|
170
|
+
} catch (err) {
|
|
171
|
+
if (err instanceof NotSupportedByServerError || err instanceof UserError) {
|
|
172
|
+
await this.restore(agentId, previousSettings, instructionsChanged ? previousInstructions : null);
|
|
173
|
+
}
|
|
174
|
+
throw err;
|
|
175
|
+
}
|
|
176
|
+
checkMetadata(envelope, agent);
|
|
177
|
+
await this.agents.deployAgent({ agentId }); // idempotent; moves an adopted draft to deployed
|
|
178
|
+
return {
|
|
179
|
+
agentId,
|
|
180
|
+
name: agent.name,
|
|
181
|
+
instructions: agent.instructions,
|
|
182
|
+
settings: { ...(envelope.settings ?? {}) },
|
|
183
|
+
warnings,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
async deleteAgent(agentId: string): Promise<void> {
|
|
188
|
+
await this.agents.deleteAgent({ agentId });
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// -- turns ----------------------------------------------------------------------------------------------
|
|
192
|
+
|
|
193
|
+
async startTurn(
|
|
194
|
+
agentId: string,
|
|
195
|
+
conversationId: string | null,
|
|
196
|
+
text: string,
|
|
197
|
+
signal?: AbortSignal,
|
|
198
|
+
): Promise<TurnStream> {
|
|
199
|
+
if (conversationId === null) {
|
|
200
|
+
conversationId = (await this.conversations.createConversation({ createConversationBody: { agentId } })).id;
|
|
201
|
+
}
|
|
202
|
+
const body = {
|
|
203
|
+
id: conversationId,
|
|
204
|
+
agentId,
|
|
205
|
+
message: { id: randomUUID(), role: "user", parts: [{ type: "text", text }] },
|
|
206
|
+
};
|
|
207
|
+
return new Stream(await streamResponse(this.config, body, { signal }), conversationId);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
async answerClarify(
|
|
211
|
+
conversationId: string,
|
|
212
|
+
requestId: string,
|
|
213
|
+
answers: Record<string, unknown>,
|
|
214
|
+
signal?: AbortSignal,
|
|
215
|
+
): Promise<TurnStream> {
|
|
216
|
+
const inner = await answerClarify(this.config, conversationId, { requestId, answers }, { signal });
|
|
217
|
+
return new Stream(inner, conversationId);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
async resume(
|
|
221
|
+
conversationId: string,
|
|
222
|
+
responseId: string,
|
|
223
|
+
lastEventId: string | null,
|
|
224
|
+
signal?: AbortSignal,
|
|
225
|
+
): Promise<TurnStream> {
|
|
226
|
+
const inner = await reconnect(this.config, conversationId, responseId, lastEventId, { signal });
|
|
227
|
+
return new Stream(inner, conversationId);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
async stop(conversationId: string): Promise<void> {
|
|
231
|
+
await this.responses.stopResponse({ conversationId });
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// -- helpers --------------------------------------------------------------------------------------------
|
|
235
|
+
|
|
236
|
+
/** Put back what updateAgent overwrote; a failing restore must not mask the original error. */
|
|
237
|
+
private async restore(agentId: string, settings: { [key: string]: any } | null, instructions: string | null): Promise<void> {
|
|
238
|
+
try {
|
|
239
|
+
if (instructions !== null) {
|
|
240
|
+
await this.agents.putInstructions({ agentId, instructionsBody: { data: instructions } });
|
|
241
|
+
}
|
|
242
|
+
if (settings !== null) await this.agents.putAgentSettings({ agentId, body: settings });
|
|
243
|
+
} catch (err) {
|
|
244
|
+
console.warn(`could not restore agent ${agentId} after rejected settings: ${err}`);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
private async instructions(agentId: string): Promise<string> {
|
|
249
|
+
return (await this.agents.getInstructions({ agentId })).data;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
private remote(resource: { id: string; name: string; settings?: { [key: string]: any } | null }, instructions: string): RemoteAgent {
|
|
253
|
+
return { agentId: resource.id, name: resource.name, instructions, settings: { ...(resource.settings ?? {}) }, warnings: [] };
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** The server's 422 CHAT_VALIDATION / invalid_agent_settings rejection as a UserError, else null. */
|
|
258
|
+
async function invalidSettings(err: unknown): Promise<UserError | null> {
|
|
259
|
+
if (!(err instanceof ResponseError) || err.response.status !== 422) return null;
|
|
260
|
+
try {
|
|
261
|
+
const error = (await err.response.clone().json()).error;
|
|
262
|
+
const details = (error.details as any[]).filter((d) => d && d.code === "invalid_agent_settings");
|
|
263
|
+
if (details.length === 0) return null;
|
|
264
|
+
const issues = details.flatMap((d) => (d.issues ?? []) as any[]).map((i) => ({
|
|
265
|
+
code: i.code, path: i.path, message: i.message,
|
|
266
|
+
}));
|
|
267
|
+
return new UserError(String(error.message || "the server rejected the agent settings"), issues);
|
|
268
|
+
} catch {
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/** findAgents() matches on metadata.sdk_name; a server that drops it would get a new agent per deploy. */
|
|
274
|
+
function checkMetadata(envelope: Envelope, agent: Agent): void {
|
|
275
|
+
const metadata = (envelope.settings ?? {})["metadata"];
|
|
276
|
+
if (typeof metadata !== "object" || metadata === null || Array.isArray(metadata) || metadata["sdk_name"] !== agent.name) {
|
|
277
|
+
throw new NotSupportedByServerError(["metadata"]);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function checkWarnings(envelope: Envelope, sent: Record<string, unknown>): SettingsWarning[] {
|
|
282
|
+
const warnings: SettingsWarning[] = [];
|
|
283
|
+
const rejected: string[] = [];
|
|
284
|
+
const unsupported: string[] = [];
|
|
285
|
+
for (const w of envelope.warnings ?? []) {
|
|
286
|
+
const item = { code: w.code, path: w.path, message: w.message };
|
|
287
|
+
warnings.push(item);
|
|
288
|
+
if (item.code === "unknown_key" && Object.prototype.hasOwnProperty.call(sent, item.path) && item.path !== "metadata") {
|
|
289
|
+
if (rejected.indexOf(item.path) === -1) rejected.push(item.path);
|
|
290
|
+
} else if (item.code === "reasoning_unsupported") {
|
|
291
|
+
unsupported.push(String(item.message || "reasoning is not supported by the model"));
|
|
292
|
+
} else if (!(item.code === "unknown_key" && item.path === "metadata")) {
|
|
293
|
+
console.warn(`agent settings warning ${item.code} at ${item.path}: ${item.message}`);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
if (rejected.length) throw new NotSupportedByServerError(rejected.sort());
|
|
297
|
+
if (unsupported.length) throw new UserError(unsupported.join("; "));
|
|
298
|
+
return warnings;
|
|
299
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Built-in (server-side) tools. Listing a tool enables it; unlisted tools keep the server default. */
|
|
2
|
+
|
|
3
|
+
export interface BuiltinTool {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly options?: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function webSearchTool(opts: {
|
|
9
|
+
filters?: { allowedDomains?: string[] | null };
|
|
10
|
+
blockedDomains?: string[];
|
|
11
|
+
} = {}): BuiltinTool {
|
|
12
|
+
const options: Record<string, unknown> = {};
|
|
13
|
+
const allowed = opts.filters?.allowedDomains;
|
|
14
|
+
if (allowed !== undefined && allowed !== null) options["allowed_domains"] = allowed.slice();
|
|
15
|
+
if (opts.blockedDomains !== undefined) options["blocked_domains"] = opts.blockedDomains.slice();
|
|
16
|
+
const tool: BuiltinTool = Object.keys(options).length > 0 ? { name: "web_search", options } : { name: "web_search" };
|
|
17
|
+
return tool;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const simple = (name: string): BuiltinTool => ({ name });
|
|
21
|
+
|
|
22
|
+
export const sandbox = (): BuiltinTool => simple("sandbox");
|
|
23
|
+
export const codeMode = (): BuiltinTool => simple("code_mode");
|
|
24
|
+
export const todo = (): BuiltinTool => simple("todo");
|
|
25
|
+
export const schedules = (): BuiltinTool => simple("schedules");
|
|
26
|
+
export const clarify = (): BuiltinTool => simple("clarify");
|
|
27
|
+
export const subagents = (): BuiltinTool => simple("subagents");
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** Transport interface: the seam between the compose layer and the server. */
|
|
2
|
+
import type { Agent } from "./agent.js";
|
|
3
|
+
import type { Event } from "./events.js";
|
|
4
|
+
|
|
5
|
+
export interface SettingsWarning {
|
|
6
|
+
code: string;
|
|
7
|
+
path: string;
|
|
8
|
+
message: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface RemoteAgent {
|
|
12
|
+
agentId: string;
|
|
13
|
+
name: string;
|
|
14
|
+
instructions: string;
|
|
15
|
+
settings: Record<string, unknown>;
|
|
16
|
+
warnings: SettingsWarning[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Async iterable of Events; the ids are filled in as the stream progresses. */
|
|
20
|
+
export interface TurnStream extends AsyncIterable<Event> {
|
|
21
|
+
readonly conversationId: string | null;
|
|
22
|
+
readonly responseId: string | null;
|
|
23
|
+
readonly lastEventId: string | null;
|
|
24
|
+
close(): void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface Transport {
|
|
28
|
+
readonly kind: "settings";
|
|
29
|
+
findAgents(sdkName: string): Promise<RemoteAgent[]>;
|
|
30
|
+
readAgent(agentId: string): Promise<RemoteAgent>;
|
|
31
|
+
createAgent(agent: Agent): Promise<RemoteAgent>;
|
|
32
|
+
updateAgent(agentId: string, agent: Agent): Promise<RemoteAgent>;
|
|
33
|
+
deleteAgent(agentId: string): Promise<void>;
|
|
34
|
+
startTurn(agentId: string, conversationId: string | null, text: string, signal?: AbortSignal): Promise<TurnStream>;
|
|
35
|
+
answerClarify(
|
|
36
|
+
conversationId: string,
|
|
37
|
+
requestId: string,
|
|
38
|
+
answers: Record<string, unknown>,
|
|
39
|
+
signal?: AbortSignal,
|
|
40
|
+
): Promise<TurnStream>;
|
|
41
|
+
resume(
|
|
42
|
+
conversationId: string,
|
|
43
|
+
responseId: string,
|
|
44
|
+
lastEventId: string | null,
|
|
45
|
+
signal?: AbortSignal,
|
|
46
|
+
): Promise<TurnStream>;
|
|
47
|
+
stop(conversationId: string): Promise<void>;
|
|
48
|
+
}
|
|
@@ -54,7 +54,8 @@ export const AgentChannelRefTypeEnum = {
|
|
|
54
54
|
Web: 'web',
|
|
55
55
|
Slack: 'slack',
|
|
56
56
|
Whatsapp: 'whatsapp',
|
|
57
|
-
Cli: 'cli'
|
|
57
|
+
Cli: 'cli',
|
|
58
|
+
Teams: 'teams'
|
|
58
59
|
} as const;
|
|
59
60
|
export type AgentChannelRefTypeEnum = typeof AgentChannelRefTypeEnum[keyof typeof AgentChannelRefTypeEnum];
|
|
60
61
|
|
|
@@ -157,16 +157,29 @@ export interface AgentConversationDetail {
|
|
|
157
157
|
queuedTurns?: Array<QueuedTurnView>;
|
|
158
158
|
/**
|
|
159
159
|
*
|
|
160
|
-
* @type {
|
|
160
|
+
* @type {boolean}
|
|
161
161
|
* @memberof AgentConversationDetail
|
|
162
162
|
*/
|
|
163
|
-
|
|
163
|
+
isMine?: boolean;
|
|
164
164
|
/**
|
|
165
165
|
*
|
|
166
166
|
* @type {string}
|
|
167
167
|
* @memberof AgentConversationDetail
|
|
168
168
|
*/
|
|
169
169
|
panjaWsId: string | null;
|
|
170
|
+
/**
|
|
171
|
+
*
|
|
172
|
+
* @type {boolean}
|
|
173
|
+
* @memberof AgentConversationDetail
|
|
174
|
+
*/
|
|
175
|
+
readOnly?: boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Deprecated: the server no longer sends this field, so it is always undefined. Use isMine.
|
|
178
|
+
* @type {string}
|
|
179
|
+
* @memberof AgentConversationDetail
|
|
180
|
+
* @deprecated
|
|
181
|
+
*/
|
|
182
|
+
panjaUserId?: string;
|
|
170
183
|
}
|
|
171
184
|
|
|
172
185
|
/**
|
|
@@ -188,7 +201,6 @@ export function instanceOfAgentConversationDetail(value: object): value is Agent
|
|
|
188
201
|
if (!('createdAt' in value) || value['createdAt'] === undefined) return false;
|
|
189
202
|
if (!('messages' in value) || value['messages'] === undefined) return false;
|
|
190
203
|
if (!('lastEventId' in value) || value['lastEventId'] === undefined) return false;
|
|
191
|
-
if (!('panjaUserId' in value) || value['panjaUserId'] === undefined) return false;
|
|
192
204
|
if (!('panjaWsId' in value) || value['panjaWsId'] === undefined) return false;
|
|
193
205
|
return true;
|
|
194
206
|
}
|
|
@@ -222,8 +234,10 @@ export function AgentConversationDetailFromJSONTyped(json: any, ignoreDiscrimina
|
|
|
222
234
|
'hasMore': json['hasMore'] == null ? undefined : json['hasMore'],
|
|
223
235
|
'nextBeforeCursor': json['nextBeforeCursor'] == null ? undefined : json['nextBeforeCursor'],
|
|
224
236
|
'queuedTurns': json['queuedTurns'] == null ? undefined : ((json['queuedTurns'] as Array<any>).map(QueuedTurnViewFromJSON)),
|
|
225
|
-
'
|
|
237
|
+
'isMine': json['isMine'] == null ? undefined : json['isMine'],
|
|
226
238
|
'panjaWsId': json['panjaWsId'],
|
|
239
|
+
'readOnly': json['readOnly'] == null ? undefined : json['readOnly'],
|
|
240
|
+
'panjaUserId': json['panjaUserId'] == null ? undefined : json['panjaUserId'],
|
|
227
241
|
};
|
|
228
242
|
}
|
|
229
243
|
|
|
@@ -257,8 +271,10 @@ export function AgentConversationDetailToJSONTyped(value?: AgentConversationDeta
|
|
|
257
271
|
'hasMore': value['hasMore'],
|
|
258
272
|
'nextBeforeCursor': value['nextBeforeCursor'],
|
|
259
273
|
'queuedTurns': value['queuedTurns'] == null ? undefined : ((value['queuedTurns'] as Array<any>).map(QueuedTurnViewToJSON)),
|
|
260
|
-
'
|
|
274
|
+
'isMine': value['isMine'],
|
|
261
275
|
'panjaWsId': value['panjaWsId'],
|
|
276
|
+
'readOnly': value['readOnly'],
|
|
277
|
+
'panjaUserId': value['panjaUserId'],
|
|
262
278
|
};
|
|
263
279
|
}
|
|
264
280
|
|
|
@@ -22,9 +22,8 @@ import {
|
|
|
22
22
|
} from './FieldHighlight.js';
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
* One session-log row: the inbox view
|
|
26
|
-
*
|
|
27
|
-
* table ever needs them.
|
|
25
|
+
* One session-log row: the inbox view, anonymised (see module doc), plus
|
|
26
|
+
* whether it is the caller's own and which workspace it lives in.
|
|
28
27
|
* @export
|
|
29
28
|
* @interface AgentConversationView
|
|
30
29
|
*/
|
|
@@ -115,16 +114,23 @@ export interface AgentConversationView {
|
|
|
115
114
|
highlight?: Array<FieldHighlight>;
|
|
116
115
|
/**
|
|
117
116
|
*
|
|
118
|
-
* @type {
|
|
117
|
+
* @type {boolean}
|
|
119
118
|
* @memberof AgentConversationView
|
|
120
119
|
*/
|
|
121
|
-
|
|
120
|
+
isMine?: boolean;
|
|
122
121
|
/**
|
|
123
122
|
*
|
|
124
123
|
* @type {string}
|
|
125
124
|
* @memberof AgentConversationView
|
|
126
125
|
*/
|
|
127
126
|
panjaWsId: string | null;
|
|
127
|
+
/**
|
|
128
|
+
* Deprecated: the server no longer sends this field, so it is always undefined. Use isMine.
|
|
129
|
+
* @type {string}
|
|
130
|
+
* @memberof AgentConversationView
|
|
131
|
+
* @deprecated
|
|
132
|
+
*/
|
|
133
|
+
panjaUserId?: string;
|
|
128
134
|
}
|
|
129
135
|
|
|
130
136
|
/**
|
|
@@ -144,7 +150,6 @@ export function instanceOfAgentConversationView(value: object): value is AgentCo
|
|
|
144
150
|
if (!('lastActiveAt' in value) || value['lastActiveAt'] === undefined) return false;
|
|
145
151
|
if (!('lastReadAt' in value) || value['lastReadAt'] === undefined) return false;
|
|
146
152
|
if (!('createdAt' in value) || value['createdAt'] === undefined) return false;
|
|
147
|
-
if (!('panjaUserId' in value) || value['panjaUserId'] === undefined) return false;
|
|
148
153
|
if (!('panjaWsId' in value) || value['panjaWsId'] === undefined) return false;
|
|
149
154
|
return true;
|
|
150
155
|
}
|
|
@@ -173,8 +178,9 @@ export function AgentConversationViewFromJSONTyped(json: any, ignoreDiscriminato
|
|
|
173
178
|
'lastReadAt': (json['lastReadAt'] == null ? null : new Date(json['lastReadAt'])),
|
|
174
179
|
'createdAt': (new Date(json['createdAt'])),
|
|
175
180
|
'highlight': json['highlight'] == null ? undefined : ((json['highlight'] as Array<any>).map(FieldHighlightFromJSON)),
|
|
176
|
-
'
|
|
181
|
+
'isMine': json['isMine'] == null ? undefined : json['isMine'],
|
|
177
182
|
'panjaWsId': json['panjaWsId'],
|
|
183
|
+
'panjaUserId': json['panjaUserId'] == null ? undefined : json['panjaUserId'],
|
|
178
184
|
};
|
|
179
185
|
}
|
|
180
186
|
|
|
@@ -203,8 +209,9 @@ export function AgentConversationViewToJSONTyped(value?: AgentConversationView |
|
|
|
203
209
|
'lastReadAt': (value['lastReadAt'] == null ? null : (value['lastReadAt'] as any).toISOString()),
|
|
204
210
|
'createdAt': ((value['createdAt']).toISOString()),
|
|
205
211
|
'highlight': value['highlight'] == null ? undefined : ((value['highlight'] as Array<any>).map(FieldHighlightToJSON)),
|
|
206
|
-
'
|
|
212
|
+
'isMine': value['isMine'],
|
|
207
213
|
'panjaWsId': value['panjaWsId'],
|
|
214
|
+
'panjaUserId': value['panjaUserId'],
|
|
208
215
|
};
|
|
209
216
|
}
|
|
210
217
|
|
|
@@ -49,6 +49,12 @@ export interface AgentCreate {
|
|
|
49
49
|
* @memberof AgentCreate
|
|
50
50
|
*/
|
|
51
51
|
llmConfig?: { [key: string]: any; } | null;
|
|
52
|
+
/**
|
|
53
|
+
*
|
|
54
|
+
* @type {{ [key: string]: any; }}
|
|
55
|
+
* @memberof AgentCreate
|
|
56
|
+
*/
|
|
57
|
+
settings?: { [key: string]: any; } | null;
|
|
52
58
|
}
|
|
53
59
|
|
|
54
60
|
/**
|
|
@@ -73,6 +79,7 @@ export function AgentCreateFromJSONTyped(json: any, ignoreDiscriminator: boolean
|
|
|
73
79
|
'instructions': json['instructions'] == null ? undefined : json['instructions'],
|
|
74
80
|
'appearance': json['appearance'] == null ? undefined : json['appearance'],
|
|
75
81
|
'llmConfig': json['llmConfig'] == null ? undefined : json['llmConfig'],
|
|
82
|
+
'settings': json['settings'] == null ? undefined : json['settings'],
|
|
76
83
|
};
|
|
77
84
|
}
|
|
78
85
|
|
|
@@ -92,6 +99,7 @@ export function AgentCreateToJSONTyped(value?: AgentCreate | null, ignoreDiscrim
|
|
|
92
99
|
'instructions': value['instructions'],
|
|
93
100
|
'appearance': value['appearance'],
|
|
94
101
|
'llmConfig': value['llmConfig'],
|
|
102
|
+
'settings': value['settings'],
|
|
95
103
|
};
|
|
96
104
|
}
|
|
97
105
|
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
import { mapValues } from '../runtime.js';
|
|
16
|
+
import type { CustomApiName } from './CustomApiName.js';
|
|
17
|
+
import {
|
|
18
|
+
CustomApiNameFromJSON,
|
|
19
|
+
CustomApiNameFromJSONTyped,
|
|
20
|
+
CustomApiNameToJSON,
|
|
21
|
+
CustomApiNameToJSONTyped,
|
|
22
|
+
} from './CustomApiName.js';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @export
|
|
27
|
+
* @interface AgentCustomApiList
|
|
28
|
+
*/
|
|
29
|
+
export interface AgentCustomApiList {
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @type {Array<CustomApiName>}
|
|
33
|
+
* @memberof AgentCustomApiList
|
|
34
|
+
*/
|
|
35
|
+
data: Array<CustomApiName>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Check if a given object implements the AgentCustomApiList interface.
|
|
40
|
+
*/
|
|
41
|
+
export function instanceOfAgentCustomApiList(value: object): value is AgentCustomApiList {
|
|
42
|
+
if (!('data' in value) || value['data'] === undefined) return false;
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function AgentCustomApiListFromJSON(json: any): AgentCustomApiList {
|
|
47
|
+
return AgentCustomApiListFromJSONTyped(json, false);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function AgentCustomApiListFromJSONTyped(json: any, ignoreDiscriminator: boolean): AgentCustomApiList {
|
|
51
|
+
if (json == null) {
|
|
52
|
+
return json;
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
|
|
56
|
+
'data': ((json['data'] as Array<any>).map(CustomApiNameFromJSON)),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function AgentCustomApiListToJSON(json: any): AgentCustomApiList {
|
|
61
|
+
return AgentCustomApiListToJSONTyped(json, false);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function AgentCustomApiListToJSONTyped(value?: AgentCustomApiList | null, ignoreDiscriminator: boolean = false): any {
|
|
65
|
+
if (value == null) {
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
|
|
71
|
+
'data': ((value['data'] as Array<any>).map(CustomApiNameToJSON)),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
@@ -146,6 +146,12 @@ export interface AgentResource {
|
|
|
146
146
|
* @memberof AgentResource
|
|
147
147
|
*/
|
|
148
148
|
deployState?: AgentResourceDeployStateEnum | null;
|
|
149
|
+
/**
|
|
150
|
+
*
|
|
151
|
+
* @type {Date}
|
|
152
|
+
* @memberof AgentResource
|
|
153
|
+
*/
|
|
154
|
+
deployedAt?: Date | null;
|
|
149
155
|
/**
|
|
150
156
|
*
|
|
151
157
|
* @type {string}
|
|
@@ -158,6 +164,12 @@ export interface AgentResource {
|
|
|
158
164
|
* @memberof AgentResource
|
|
159
165
|
*/
|
|
160
166
|
isDefault?: boolean;
|
|
167
|
+
/**
|
|
168
|
+
*
|
|
169
|
+
* @type {{ [key: string]: any; }}
|
|
170
|
+
* @memberof AgentResource
|
|
171
|
+
*/
|
|
172
|
+
settings?: { [key: string]: any; } | null;
|
|
161
173
|
/**
|
|
162
174
|
*
|
|
163
175
|
* @type {number}
|
|
@@ -274,8 +286,10 @@ export function AgentResourceFromJSONTyped(json: any, ignoreDiscriminator: boole
|
|
|
274
286
|
'highlight': json['highlight'] == null ? undefined : ((json['highlight'] as Array<any>).map(FieldHighlightFromJSON)),
|
|
275
287
|
'agentTypes': json['agentTypes'] == null ? undefined : json['agentTypes'],
|
|
276
288
|
'deployState': json['deployState'] == null ? undefined : json['deployState'],
|
|
289
|
+
'deployedAt': json['deployedAt'] == null ? undefined : (new Date(json['deployedAt'])),
|
|
277
290
|
'clonedFromAgentId': json['clonedFromAgentId'] == null ? undefined : json['clonedFromAgentId'],
|
|
278
291
|
'isDefault': json['isDefault'] == null ? undefined : json['isDefault'],
|
|
292
|
+
'settings': json['settings'] == null ? undefined : json['settings'],
|
|
279
293
|
'interactionCount': json['interactionCount'] == null ? undefined : json['interactionCount'],
|
|
280
294
|
'slackChannelName': json['slackChannelName'] == null ? undefined : json['slackChannelName'],
|
|
281
295
|
'slackUrl': json['slackUrl'] == null ? undefined : json['slackUrl'],
|
|
@@ -312,8 +326,10 @@ export function AgentResourceToJSONTyped(value?: AgentResource | null, ignoreDis
|
|
|
312
326
|
'highlight': value['highlight'] == null ? undefined : ((value['highlight'] as Array<any>).map(FieldHighlightToJSON)),
|
|
313
327
|
'agentTypes': value['agentTypes'],
|
|
314
328
|
'deployState': value['deployState'],
|
|
329
|
+
'deployedAt': value['deployedAt'] == null ? undefined : ((value['deployedAt'] as any).toISOString()),
|
|
315
330
|
'clonedFromAgentId': value['clonedFromAgentId'],
|
|
316
331
|
'isDefault': value['isDefault'],
|
|
332
|
+
'settings': value['settings'],
|
|
317
333
|
'interactionCount': value['interactionCount'],
|
|
318
334
|
'slackChannelName': value['slackChannelName'],
|
|
319
335
|
'slackUrl': value['slackUrl'],
|