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,280 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SettingsTransport = void 0;
|
|
4
|
+
/** SettingsTransport: the compose transport on the generated API (agent settings file + responses stream). */
|
|
5
|
+
const node_crypto_1 = require("node:crypto");
|
|
6
|
+
const AgentsApi_js_1 = require("../apis/AgentsApi.js");
|
|
7
|
+
const ConversationsApi_js_1 = require("../apis/ConversationsApi.js");
|
|
8
|
+
const ResponsesApi_js_1 = require("../apis/ResponsesApi.js");
|
|
9
|
+
const runtime_js_1 = require("../runtime.js");
|
|
10
|
+
const streaming_js_1 = require("../streaming.js");
|
|
11
|
+
const errors_js_1 = require("./errors.js");
|
|
12
|
+
const events_js_1 = require("./events.js");
|
|
13
|
+
const PAGE = 100;
|
|
14
|
+
function isNotFound(err) {
|
|
15
|
+
return err instanceof runtime_js_1.ResponseError && err.response.status === 404;
|
|
16
|
+
}
|
|
17
|
+
/** TurnStream over a streaming ResponseStream; ids are read live from the underlying stream. */
|
|
18
|
+
class Stream {
|
|
19
|
+
constructor(inner, conversationId) {
|
|
20
|
+
this.inner = inner;
|
|
21
|
+
this.conversationId = conversationId;
|
|
22
|
+
}
|
|
23
|
+
get responseId() {
|
|
24
|
+
return this.inner.responseId;
|
|
25
|
+
}
|
|
26
|
+
get lastEventId() {
|
|
27
|
+
return this.inner.lastEventId;
|
|
28
|
+
}
|
|
29
|
+
async *[Symbol.asyncIterator]() {
|
|
30
|
+
for await (const chunk of this.inner) {
|
|
31
|
+
const event = (0, events_js_1.fromUiChunk)(chunk);
|
|
32
|
+
if (event !== null)
|
|
33
|
+
yield event;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
close() {
|
|
37
|
+
this.inner.close();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
class SettingsTransport {
|
|
41
|
+
constructor(config) {
|
|
42
|
+
this.config = config;
|
|
43
|
+
this.kind = "settings";
|
|
44
|
+
this.agents = new AgentsApi_js_1.AgentsApi(config);
|
|
45
|
+
this.conversations = new ConversationsApi_js_1.ConversationsApi(config);
|
|
46
|
+
this.responses = new ResponsesApi_js_1.ResponsesApi(config);
|
|
47
|
+
}
|
|
48
|
+
// -- agents ---------------------------------------------------------------------------------------------
|
|
49
|
+
async findAgents(sdkName) {
|
|
50
|
+
var _a;
|
|
51
|
+
const found = [];
|
|
52
|
+
let offset = 0;
|
|
53
|
+
for (;;) {
|
|
54
|
+
const result = await this.agents.listAgents({ q: sdkName, limit: PAGE, offset });
|
|
55
|
+
const items = result.data;
|
|
56
|
+
for (const item of items) {
|
|
57
|
+
if (item.name !== sdkName)
|
|
58
|
+
continue;
|
|
59
|
+
const resource = await this.agents.getAgent({ agentId: item.id });
|
|
60
|
+
const metadata = ((_a = resource.settings) !== null && _a !== void 0 ? _a : {})["metadata"];
|
|
61
|
+
if (metadata && metadata["sdk_name"] === sdkName) {
|
|
62
|
+
found.push(this.remote(resource, await this.instructions(item.id)));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
offset += items.length;
|
|
66
|
+
if (items.length === 0 || !result.hasMore)
|
|
67
|
+
return found;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async readAgent(agentId) {
|
|
71
|
+
const resource = await this.agents.getAgent({ agentId });
|
|
72
|
+
return this.remote(resource, await this.instructions(agentId));
|
|
73
|
+
}
|
|
74
|
+
async createAgent(agent) {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
const settings = agent.toSettings();
|
|
77
|
+
let resource;
|
|
78
|
+
try {
|
|
79
|
+
resource = await this.agents.createAgent({
|
|
80
|
+
agentCreate: { name: agent.name, instructions: agent.instructions, settings },
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
// A 422 stored nothing, so there is no agent to delete.
|
|
85
|
+
throw (_a = (await invalidSettings(err))) !== null && _a !== void 0 ? _a : err;
|
|
86
|
+
}
|
|
87
|
+
let envelope;
|
|
88
|
+
let warnings;
|
|
89
|
+
// The create response never echoes settings, so support is read back from the settings route, which 404s
|
|
90
|
+
// when the server has settings switched off (create then silently drops them).
|
|
91
|
+
try {
|
|
92
|
+
try {
|
|
93
|
+
envelope = await this.agents.getAgentSettings({ agentId: resource.id });
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
if (isNotFound(err))
|
|
97
|
+
throw new errors_js_1.NotSupportedByServerError(["settings"]);
|
|
98
|
+
throw err;
|
|
99
|
+
}
|
|
100
|
+
warnings = checkWarnings(envelope, settings);
|
|
101
|
+
checkMetadata(envelope, agent);
|
|
102
|
+
await this.agents.deployAgent({ agentId: resource.id });
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
// Don't leave an orphan agent behind; a failing cleanup must not mask the original error.
|
|
106
|
+
try {
|
|
107
|
+
await this.agents.deleteAgent({ agentId: resource.id });
|
|
108
|
+
}
|
|
109
|
+
catch (cleanup) {
|
|
110
|
+
console.warn(`could not delete agent ${resource.id} after failed create: ${cleanup}`);
|
|
111
|
+
}
|
|
112
|
+
throw err;
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
agentId: resource.id,
|
|
116
|
+
name: agent.name,
|
|
117
|
+
instructions: agent.instructions,
|
|
118
|
+
settings: { ...((_b = envelope.settings) !== null && _b !== void 0 ? _b : {}) },
|
|
119
|
+
warnings,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
async updateAgent(agentId, agent) {
|
|
123
|
+
var _a, _b;
|
|
124
|
+
const settings = agent.toSettings();
|
|
125
|
+
// findAgents searches by display name, so an adopted (or dashboard-renamed) agent must carry sdk_name.
|
|
126
|
+
if ((await this.agents.getAgent({ agentId })).name !== agent.name) {
|
|
127
|
+
await this.agents.updateAgent({ agentId, agentUpdate: { name: agent.name } });
|
|
128
|
+
}
|
|
129
|
+
// Rejections are only visible after the server stored the settings, so keep what was there to put it back.
|
|
130
|
+
const previousInstructions = await this.instructions(agentId);
|
|
131
|
+
let previousSettings;
|
|
132
|
+
try {
|
|
133
|
+
previousSettings = { ...((_a = (await this.agents.getAgentSettings({ agentId })).settings) !== null && _a !== void 0 ? _a : {}) };
|
|
134
|
+
}
|
|
135
|
+
catch (err) {
|
|
136
|
+
if (isNotFound(err))
|
|
137
|
+
throw new errors_js_1.NotSupportedByServerError(["settings"]);
|
|
138
|
+
throw err;
|
|
139
|
+
}
|
|
140
|
+
// Instructions first: the settings carry the new sdk_hash, and a hash written ahead of the instructions it
|
|
141
|
+
// covers would read as an edit made outside the SDK if the instructions write then failed.
|
|
142
|
+
const instructionsChanged = previousInstructions !== agent.instructions;
|
|
143
|
+
if (instructionsChanged) {
|
|
144
|
+
await this.agents.putInstructions({ agentId, instructionsBody: { data: agent.instructions } });
|
|
145
|
+
}
|
|
146
|
+
let envelope;
|
|
147
|
+
try {
|
|
148
|
+
envelope = await this.agents.putAgentSettings({ agentId, body: settings });
|
|
149
|
+
}
|
|
150
|
+
catch (err) {
|
|
151
|
+
if (isNotFound(err))
|
|
152
|
+
throw new errors_js_1.NotSupportedByServerError(["settings"]);
|
|
153
|
+
const invalid = await invalidSettings(err);
|
|
154
|
+
if (invalid === null)
|
|
155
|
+
throw err;
|
|
156
|
+
// The failed PUT stored nothing; only the instructions need putting back.
|
|
157
|
+
if (instructionsChanged)
|
|
158
|
+
await this.restore(agentId, null, previousInstructions);
|
|
159
|
+
throw invalid;
|
|
160
|
+
}
|
|
161
|
+
let warnings;
|
|
162
|
+
try {
|
|
163
|
+
warnings = checkWarnings(envelope, settings);
|
|
164
|
+
}
|
|
165
|
+
catch (err) {
|
|
166
|
+
if (err instanceof errors_js_1.NotSupportedByServerError || err instanceof errors_js_1.UserError) {
|
|
167
|
+
await this.restore(agentId, previousSettings, instructionsChanged ? previousInstructions : null);
|
|
168
|
+
}
|
|
169
|
+
throw err;
|
|
170
|
+
}
|
|
171
|
+
checkMetadata(envelope, agent);
|
|
172
|
+
await this.agents.deployAgent({ agentId }); // idempotent; moves an adopted draft to deployed
|
|
173
|
+
return {
|
|
174
|
+
agentId,
|
|
175
|
+
name: agent.name,
|
|
176
|
+
instructions: agent.instructions,
|
|
177
|
+
settings: { ...((_b = envelope.settings) !== null && _b !== void 0 ? _b : {}) },
|
|
178
|
+
warnings,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
async deleteAgent(agentId) {
|
|
182
|
+
await this.agents.deleteAgent({ agentId });
|
|
183
|
+
}
|
|
184
|
+
// -- turns ----------------------------------------------------------------------------------------------
|
|
185
|
+
async startTurn(agentId, conversationId, text, signal) {
|
|
186
|
+
if (conversationId === null) {
|
|
187
|
+
conversationId = (await this.conversations.createConversation({ createConversationBody: { agentId } })).id;
|
|
188
|
+
}
|
|
189
|
+
const body = {
|
|
190
|
+
id: conversationId,
|
|
191
|
+
agentId,
|
|
192
|
+
message: { id: (0, node_crypto_1.randomUUID)(), role: "user", parts: [{ type: "text", text }] },
|
|
193
|
+
};
|
|
194
|
+
return new Stream(await (0, streaming_js_1.streamResponse)(this.config, body, { signal }), conversationId);
|
|
195
|
+
}
|
|
196
|
+
async answerClarify(conversationId, requestId, answers, signal) {
|
|
197
|
+
const inner = await (0, streaming_js_1.answerClarify)(this.config, conversationId, { requestId, answers }, { signal });
|
|
198
|
+
return new Stream(inner, conversationId);
|
|
199
|
+
}
|
|
200
|
+
async resume(conversationId, responseId, lastEventId, signal) {
|
|
201
|
+
const inner = await (0, streaming_js_1.reconnect)(this.config, conversationId, responseId, lastEventId, { signal });
|
|
202
|
+
return new Stream(inner, conversationId);
|
|
203
|
+
}
|
|
204
|
+
async stop(conversationId) {
|
|
205
|
+
await this.responses.stopResponse({ conversationId });
|
|
206
|
+
}
|
|
207
|
+
// -- helpers --------------------------------------------------------------------------------------------
|
|
208
|
+
/** Put back what updateAgent overwrote; a failing restore must not mask the original error. */
|
|
209
|
+
async restore(agentId, settings, instructions) {
|
|
210
|
+
try {
|
|
211
|
+
if (instructions !== null) {
|
|
212
|
+
await this.agents.putInstructions({ agentId, instructionsBody: { data: instructions } });
|
|
213
|
+
}
|
|
214
|
+
if (settings !== null)
|
|
215
|
+
await this.agents.putAgentSettings({ agentId, body: settings });
|
|
216
|
+
}
|
|
217
|
+
catch (err) {
|
|
218
|
+
console.warn(`could not restore agent ${agentId} after rejected settings: ${err}`);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
async instructions(agentId) {
|
|
222
|
+
return (await this.agents.getInstructions({ agentId })).data;
|
|
223
|
+
}
|
|
224
|
+
remote(resource, instructions) {
|
|
225
|
+
var _a;
|
|
226
|
+
return { agentId: resource.id, name: resource.name, instructions, settings: { ...((_a = resource.settings) !== null && _a !== void 0 ? _a : {}) }, warnings: [] };
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
exports.SettingsTransport = SettingsTransport;
|
|
230
|
+
/** The server's 422 CHAT_VALIDATION / invalid_agent_settings rejection as a UserError, else null. */
|
|
231
|
+
async function invalidSettings(err) {
|
|
232
|
+
if (!(err instanceof runtime_js_1.ResponseError) || err.response.status !== 422)
|
|
233
|
+
return null;
|
|
234
|
+
try {
|
|
235
|
+
const error = (await err.response.clone().json()).error;
|
|
236
|
+
const details = error.details.filter((d) => d && d.code === "invalid_agent_settings");
|
|
237
|
+
if (details.length === 0)
|
|
238
|
+
return null;
|
|
239
|
+
const issues = details.flatMap((d) => { var _a; return ((_a = d.issues) !== null && _a !== void 0 ? _a : []); }).map((i) => ({
|
|
240
|
+
code: i.code, path: i.path, message: i.message,
|
|
241
|
+
}));
|
|
242
|
+
return new errors_js_1.UserError(String(error.message || "the server rejected the agent settings"), issues);
|
|
243
|
+
}
|
|
244
|
+
catch (_a) {
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/** findAgents() matches on metadata.sdk_name; a server that drops it would get a new agent per deploy. */
|
|
249
|
+
function checkMetadata(envelope, agent) {
|
|
250
|
+
var _a;
|
|
251
|
+
const metadata = ((_a = envelope.settings) !== null && _a !== void 0 ? _a : {})["metadata"];
|
|
252
|
+
if (typeof metadata !== "object" || metadata === null || Array.isArray(metadata) || metadata["sdk_name"] !== agent.name) {
|
|
253
|
+
throw new errors_js_1.NotSupportedByServerError(["metadata"]);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
function checkWarnings(envelope, sent) {
|
|
257
|
+
var _a;
|
|
258
|
+
const warnings = [];
|
|
259
|
+
const rejected = [];
|
|
260
|
+
const unsupported = [];
|
|
261
|
+
for (const w of (_a = envelope.warnings) !== null && _a !== void 0 ? _a : []) {
|
|
262
|
+
const item = { code: w.code, path: w.path, message: w.message };
|
|
263
|
+
warnings.push(item);
|
|
264
|
+
if (item.code === "unknown_key" && Object.prototype.hasOwnProperty.call(sent, item.path) && item.path !== "metadata") {
|
|
265
|
+
if (rejected.indexOf(item.path) === -1)
|
|
266
|
+
rejected.push(item.path);
|
|
267
|
+
}
|
|
268
|
+
else if (item.code === "reasoning_unsupported") {
|
|
269
|
+
unsupported.push(String(item.message || "reasoning is not supported by the model"));
|
|
270
|
+
}
|
|
271
|
+
else if (!(item.code === "unknown_key" && item.path === "metadata")) {
|
|
272
|
+
console.warn(`agent settings warning ${item.code} at ${item.path}: ${item.message}`);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
if (rejected.length)
|
|
276
|
+
throw new errors_js_1.NotSupportedByServerError(rejected.sort());
|
|
277
|
+
if (unsupported.length)
|
|
278
|
+
throw new errors_js_1.UserError(unsupported.join("; "));
|
|
279
|
+
return warnings;
|
|
280
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Built-in (server-side) tools. Listing a tool enables it; unlisted tools keep the server default. */
|
|
2
|
+
export interface BuiltinTool {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly options?: Record<string, unknown>;
|
|
5
|
+
}
|
|
6
|
+
export declare function webSearchTool(opts?: {
|
|
7
|
+
filters?: {
|
|
8
|
+
allowedDomains?: string[] | null;
|
|
9
|
+
};
|
|
10
|
+
blockedDomains?: string[];
|
|
11
|
+
}): BuiltinTool;
|
|
12
|
+
export declare const sandbox: () => BuiltinTool;
|
|
13
|
+
export declare const codeMode: () => BuiltinTool;
|
|
14
|
+
export declare const todo: () => BuiltinTool;
|
|
15
|
+
export declare const schedules: () => BuiltinTool;
|
|
16
|
+
export declare const clarify: () => BuiltinTool;
|
|
17
|
+
export declare const subagents: () => BuiltinTool;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** Built-in (server-side) tools. Listing a tool enables it; unlisted tools keep the server default. */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.subagents = exports.clarify = exports.schedules = exports.todo = exports.codeMode = exports.sandbox = void 0;
|
|
5
|
+
exports.webSearchTool = webSearchTool;
|
|
6
|
+
function webSearchTool(opts = {}) {
|
|
7
|
+
var _a;
|
|
8
|
+
const options = {};
|
|
9
|
+
const allowed = (_a = opts.filters) === null || _a === void 0 ? void 0 : _a.allowedDomains;
|
|
10
|
+
if (allowed !== undefined && allowed !== null)
|
|
11
|
+
options["allowed_domains"] = allowed.slice();
|
|
12
|
+
if (opts.blockedDomains !== undefined)
|
|
13
|
+
options["blocked_domains"] = opts.blockedDomains.slice();
|
|
14
|
+
const tool = Object.keys(options).length > 0 ? { name: "web_search", options } : { name: "web_search" };
|
|
15
|
+
return tool;
|
|
16
|
+
}
|
|
17
|
+
const simple = (name) => ({ name });
|
|
18
|
+
const sandbox = () => simple("sandbox");
|
|
19
|
+
exports.sandbox = sandbox;
|
|
20
|
+
const codeMode = () => simple("code_mode");
|
|
21
|
+
exports.codeMode = codeMode;
|
|
22
|
+
const todo = () => simple("todo");
|
|
23
|
+
exports.todo = todo;
|
|
24
|
+
const schedules = () => simple("schedules");
|
|
25
|
+
exports.schedules = schedules;
|
|
26
|
+
const clarify = () => simple("clarify");
|
|
27
|
+
exports.clarify = clarify;
|
|
28
|
+
const subagents = () => simple("subagents");
|
|
29
|
+
exports.subagents = subagents;
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
export interface SettingsWarning {
|
|
5
|
+
code: string;
|
|
6
|
+
path: string;
|
|
7
|
+
message: string;
|
|
8
|
+
}
|
|
9
|
+
export interface RemoteAgent {
|
|
10
|
+
agentId: string;
|
|
11
|
+
name: string;
|
|
12
|
+
instructions: string;
|
|
13
|
+
settings: Record<string, unknown>;
|
|
14
|
+
warnings: SettingsWarning[];
|
|
15
|
+
}
|
|
16
|
+
/** Async iterable of Events; the ids are filled in as the stream progresses. */
|
|
17
|
+
export interface TurnStream extends AsyncIterable<Event> {
|
|
18
|
+
readonly conversationId: string | null;
|
|
19
|
+
readonly responseId: string | null;
|
|
20
|
+
readonly lastEventId: string | null;
|
|
21
|
+
close(): void;
|
|
22
|
+
}
|
|
23
|
+
export interface Transport {
|
|
24
|
+
readonly kind: "settings";
|
|
25
|
+
findAgents(sdkName: string): Promise<RemoteAgent[]>;
|
|
26
|
+
readAgent(agentId: string): Promise<RemoteAgent>;
|
|
27
|
+
createAgent(agent: Agent): Promise<RemoteAgent>;
|
|
28
|
+
updateAgent(agentId: string, agent: Agent): Promise<RemoteAgent>;
|
|
29
|
+
deleteAgent(agentId: string): Promise<void>;
|
|
30
|
+
startTurn(agentId: string, conversationId: string | null, text: string, signal?: AbortSignal): Promise<TurnStream>;
|
|
31
|
+
answerClarify(conversationId: string, requestId: string, answers: Record<string, unknown>, signal?: AbortSignal): Promise<TurnStream>;
|
|
32
|
+
resume(conversationId: string, responseId: string, lastEventId: string | null, signal?: AbortSignal): Promise<TurnStream>;
|
|
33
|
+
stop(conversationId: string): Promise<void>;
|
|
34
|
+
}
|
|
@@ -10,21 +10,46 @@
|
|
|
10
10
|
* Do not edit the class manually.
|
|
11
11
|
*/
|
|
12
12
|
import * as runtime from '../runtime.js';
|
|
13
|
-
import type { AgentConversationDetail, PageAgentConversationView } from '../models/index.js';
|
|
13
|
+
import type { AgentConversationDetail, DownloadUrlResponse, MessagesResponse, PageAgentConversationView } from '../models/index.js';
|
|
14
|
+
export interface AgentConversationArtifactDownloadUrlRequest {
|
|
15
|
+
agentId: string;
|
|
16
|
+
conversationId: string;
|
|
17
|
+
artifactId: string;
|
|
18
|
+
expires?: number;
|
|
19
|
+
disposition?: AgentConversationArtifactDownloadUrlDispositionEnum;
|
|
20
|
+
}
|
|
14
21
|
export interface GetAgentConversationRequest {
|
|
15
22
|
agentId: string;
|
|
16
23
|
conversationId: string;
|
|
17
24
|
}
|
|
25
|
+
export interface ListAgentConversationMessagesRequest {
|
|
26
|
+
agentId: string;
|
|
27
|
+
conversationId: string;
|
|
28
|
+
before: string;
|
|
29
|
+
turnLimit?: number | null;
|
|
30
|
+
}
|
|
18
31
|
export interface ListAgentConversationsRequest {
|
|
19
32
|
agentId: string;
|
|
20
33
|
limit?: number;
|
|
21
34
|
cursor?: string | null;
|
|
22
35
|
sessionType?: ListAgentConversationsSessionTypeEnum;
|
|
36
|
+
workspaceId?: Array<string>;
|
|
37
|
+
mine?: boolean | null;
|
|
23
38
|
}
|
|
24
39
|
/**
|
|
25
40
|
*
|
|
26
41
|
*/
|
|
27
42
|
export declare class AgentConversationsApi extends runtime.BaseAPI {
|
|
43
|
+
/**
|
|
44
|
+
* Presign one file of a session from the log, signed on each click. The file belongs to the session\'s user, not to the caller, so the in-app presign (scoped to the caller) would 404. Instead: 1. List the session\'s artifacts as its owner and require ``artifact_id`` among them. Without this check, an agent owner could presign any file of that user by guessing an id, not just this session\'s. 2. Presign through the owner-identity route the share links use. The gateway still checks the ids against the artifact\'s real owner.
|
|
45
|
+
* Agent Conversation Artifact Download Url Route
|
|
46
|
+
*/
|
|
47
|
+
agentConversationArtifactDownloadUrlRaw(requestParameters: AgentConversationArtifactDownloadUrlRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<DownloadUrlResponse>>;
|
|
48
|
+
/**
|
|
49
|
+
* Presign one file of a session from the log, signed on each click. The file belongs to the session\'s user, not to the caller, so the in-app presign (scoped to the caller) would 404. Instead: 1. List the session\'s artifacts as its owner and require ``artifact_id`` among them. Without this check, an agent owner could presign any file of that user by guessing an id, not just this session\'s. 2. Presign through the owner-identity route the share links use. The gateway still checks the ids against the artifact\'s real owner.
|
|
50
|
+
* Agent Conversation Artifact Download Url Route
|
|
51
|
+
*/
|
|
52
|
+
agentConversationArtifactDownloadUrl(requestParameters: AgentConversationArtifactDownloadUrlRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<DownloadUrlResponse>;
|
|
28
53
|
/**
|
|
29
54
|
* One session from the log, with its projected history and tool calls. Read-only: unlike the self route this never marks the row read, because ``last_read_at`` is the owning user\'s unread state, not the agent owner\'s.
|
|
30
55
|
* Get Agent Conversation Route
|
|
@@ -35,6 +60,16 @@ export declare class AgentConversationsApi extends runtime.BaseAPI {
|
|
|
35
60
|
* Get Agent Conversation Route
|
|
36
61
|
*/
|
|
37
62
|
getAgentConversation(requestParameters: GetAgentConversationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<AgentConversationDetail>;
|
|
63
|
+
/**
|
|
64
|
+
* Older history of one session from the log: the backward page of the self route ``GET /v1/conversations/{id}/messages?before=``. Only the backward path is offered, because the detail already returns the newest window and there is no live stream to catch up with.
|
|
65
|
+
* List Agent Conversation Messages Route
|
|
66
|
+
*/
|
|
67
|
+
listAgentConversationMessagesRaw(requestParameters: ListAgentConversationMessagesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<MessagesResponse>>;
|
|
68
|
+
/**
|
|
69
|
+
* Older history of one session from the log: the backward page of the self route ``GET /v1/conversations/{id}/messages?before=``. Only the backward path is offered, because the detail already returns the newest window and there is no live stream to catch up with.
|
|
70
|
+
* List Agent Conversation Messages Route
|
|
71
|
+
*/
|
|
72
|
+
listAgentConversationMessages(requestParameters: ListAgentConversationMessagesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<MessagesResponse>;
|
|
38
73
|
/**
|
|
39
74
|
* The agent owner\'s session log: conversations every user in the tenant has had with this agent on the selected surface, newest-active first.
|
|
40
75
|
* List Agent Conversations Route
|
|
@@ -46,6 +81,14 @@ export declare class AgentConversationsApi extends runtime.BaseAPI {
|
|
|
46
81
|
*/
|
|
47
82
|
listAgentConversations(requestParameters: ListAgentConversationsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<PageAgentConversationView>;
|
|
48
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* @export
|
|
86
|
+
*/
|
|
87
|
+
export declare const AgentConversationArtifactDownloadUrlDispositionEnum: {
|
|
88
|
+
readonly Inline: "inline";
|
|
89
|
+
readonly Attachment: "attachment";
|
|
90
|
+
};
|
|
91
|
+
export type AgentConversationArtifactDownloadUrlDispositionEnum = typeof AgentConversationArtifactDownloadUrlDispositionEnum[keyof typeof AgentConversationArtifactDownloadUrlDispositionEnum];
|
|
49
92
|
/**
|
|
50
93
|
* @export
|
|
51
94
|
*/
|
|
@@ -12,11 +12,56 @@
|
|
|
12
12
|
* Do not edit the class manually.
|
|
13
13
|
*/
|
|
14
14
|
import * as runtime from '../runtime.js';
|
|
15
|
-
import { AgentConversationDetailFromJSON, PageAgentConversationViewFromJSON, } from '../models/index.js';
|
|
15
|
+
import { AgentConversationDetailFromJSON, DownloadUrlResponseFromJSON, MessagesResponseFromJSON, PageAgentConversationViewFromJSON, } from '../models/index.js';
|
|
16
16
|
/**
|
|
17
17
|
*
|
|
18
18
|
*/
|
|
19
19
|
export class AgentConversationsApi extends runtime.BaseAPI {
|
|
20
|
+
/**
|
|
21
|
+
* Presign one file of a session from the log, signed on each click. The file belongs to the session\'s user, not to the caller, so the in-app presign (scoped to the caller) would 404. Instead: 1. List the session\'s artifacts as its owner and require ``artifact_id`` among them. Without this check, an agent owner could presign any file of that user by guessing an id, not just this session\'s. 2. Presign through the owner-identity route the share links use. The gateway still checks the ids against the artifact\'s real owner.
|
|
22
|
+
* Agent Conversation Artifact Download Url Route
|
|
23
|
+
*/
|
|
24
|
+
async agentConversationArtifactDownloadUrlRaw(requestParameters, initOverrides) {
|
|
25
|
+
if (requestParameters['agentId'] == null) {
|
|
26
|
+
throw new runtime.RequiredError('agentId', 'Required parameter "agentId" was null or undefined when calling agentConversationArtifactDownloadUrl().');
|
|
27
|
+
}
|
|
28
|
+
if (requestParameters['conversationId'] == null) {
|
|
29
|
+
throw new runtime.RequiredError('conversationId', 'Required parameter "conversationId" was null or undefined when calling agentConversationArtifactDownloadUrl().');
|
|
30
|
+
}
|
|
31
|
+
if (requestParameters['artifactId'] == null) {
|
|
32
|
+
throw new runtime.RequiredError('artifactId', 'Required parameter "artifactId" was null or undefined when calling agentConversationArtifactDownloadUrl().');
|
|
33
|
+
}
|
|
34
|
+
const queryParameters = {};
|
|
35
|
+
if (requestParameters['expires'] != null) {
|
|
36
|
+
queryParameters['expires'] = requestParameters['expires'];
|
|
37
|
+
}
|
|
38
|
+
if (requestParameters['disposition'] != null) {
|
|
39
|
+
queryParameters['disposition'] = requestParameters['disposition'];
|
|
40
|
+
}
|
|
41
|
+
const headerParameters = {};
|
|
42
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
43
|
+
const token = this.configuration.accessToken;
|
|
44
|
+
const tokenString = await token("bearerAuth", []);
|
|
45
|
+
if (tokenString) {
|
|
46
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const response = await this.request({
|
|
50
|
+
path: `/v1/agents/{agentId}/conversations/{conversationId}/artifacts/{artifactId}/download-url`.replace(`{${"agentId"}}`, runtime.encodePathParam('agentId', requestParameters['agentId'])).replace(`{${"conversationId"}}`, runtime.encodePathParam('conversationId', requestParameters['conversationId'])).replace(`{${"artifactId"}}`, runtime.encodePathParam('artifactId', requestParameters['artifactId'])),
|
|
51
|
+
method: 'GET',
|
|
52
|
+
headers: headerParameters,
|
|
53
|
+
query: queryParameters,
|
|
54
|
+
}, initOverrides);
|
|
55
|
+
return new runtime.JSONApiResponse(response, (jsonValue) => DownloadUrlResponseFromJSON(jsonValue));
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Presign one file of a session from the log, signed on each click. The file belongs to the session\'s user, not to the caller, so the in-app presign (scoped to the caller) would 404. Instead: 1. List the session\'s artifacts as its owner and require ``artifact_id`` among them. Without this check, an agent owner could presign any file of that user by guessing an id, not just this session\'s. 2. Presign through the owner-identity route the share links use. The gateway still checks the ids against the artifact\'s real owner.
|
|
59
|
+
* Agent Conversation Artifact Download Url Route
|
|
60
|
+
*/
|
|
61
|
+
async agentConversationArtifactDownloadUrl(requestParameters, initOverrides) {
|
|
62
|
+
const response = await this.agentConversationArtifactDownloadUrlRaw(requestParameters, initOverrides);
|
|
63
|
+
return await response.value();
|
|
64
|
+
}
|
|
20
65
|
/**
|
|
21
66
|
* One session from the log, with its projected history and tool calls. Read-only: unlike the self route this never marks the row read, because ``last_read_at`` is the owning user\'s unread state, not the agent owner\'s.
|
|
22
67
|
* Get Agent Conversation Route
|
|
@@ -53,6 +98,51 @@ export class AgentConversationsApi extends runtime.BaseAPI {
|
|
|
53
98
|
const response = await this.getAgentConversationRaw(requestParameters, initOverrides);
|
|
54
99
|
return await response.value();
|
|
55
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Older history of one session from the log: the backward page of the self route ``GET /v1/conversations/{id}/messages?before=``. Only the backward path is offered, because the detail already returns the newest window and there is no live stream to catch up with.
|
|
103
|
+
* List Agent Conversation Messages Route
|
|
104
|
+
*/
|
|
105
|
+
async listAgentConversationMessagesRaw(requestParameters, initOverrides) {
|
|
106
|
+
if (requestParameters['agentId'] == null) {
|
|
107
|
+
throw new runtime.RequiredError('agentId', 'Required parameter "agentId" was null or undefined when calling listAgentConversationMessages().');
|
|
108
|
+
}
|
|
109
|
+
if (requestParameters['conversationId'] == null) {
|
|
110
|
+
throw new runtime.RequiredError('conversationId', 'Required parameter "conversationId" was null or undefined when calling listAgentConversationMessages().');
|
|
111
|
+
}
|
|
112
|
+
if (requestParameters['before'] == null) {
|
|
113
|
+
throw new runtime.RequiredError('before', 'Required parameter "before" was null or undefined when calling listAgentConversationMessages().');
|
|
114
|
+
}
|
|
115
|
+
const queryParameters = {};
|
|
116
|
+
if (requestParameters['before'] != null) {
|
|
117
|
+
queryParameters['before'] = requestParameters['before'];
|
|
118
|
+
}
|
|
119
|
+
if (requestParameters['turnLimit'] != null) {
|
|
120
|
+
queryParameters['turnLimit'] = requestParameters['turnLimit'];
|
|
121
|
+
}
|
|
122
|
+
const headerParameters = {};
|
|
123
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
124
|
+
const token = this.configuration.accessToken;
|
|
125
|
+
const tokenString = await token("bearerAuth", []);
|
|
126
|
+
if (tokenString) {
|
|
127
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const response = await this.request({
|
|
131
|
+
path: `/v1/agents/{agentId}/conversations/{conversationId}/messages`.replace(`{${"agentId"}}`, runtime.encodePathParam('agentId', requestParameters['agentId'])).replace(`{${"conversationId"}}`, runtime.encodePathParam('conversationId', requestParameters['conversationId'])),
|
|
132
|
+
method: 'GET',
|
|
133
|
+
headers: headerParameters,
|
|
134
|
+
query: queryParameters,
|
|
135
|
+
}, initOverrides);
|
|
136
|
+
return new runtime.JSONApiResponse(response, (jsonValue) => MessagesResponseFromJSON(jsonValue));
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Older history of one session from the log: the backward page of the self route ``GET /v1/conversations/{id}/messages?before=``. Only the backward path is offered, because the detail already returns the newest window and there is no live stream to catch up with.
|
|
140
|
+
* List Agent Conversation Messages Route
|
|
141
|
+
*/
|
|
142
|
+
async listAgentConversationMessages(requestParameters, initOverrides) {
|
|
143
|
+
const response = await this.listAgentConversationMessagesRaw(requestParameters, initOverrides);
|
|
144
|
+
return await response.value();
|
|
145
|
+
}
|
|
56
146
|
/**
|
|
57
147
|
* The agent owner\'s session log: conversations every user in the tenant has had with this agent on the selected surface, newest-active first.
|
|
58
148
|
* List Agent Conversations Route
|
|
@@ -71,6 +161,12 @@ export class AgentConversationsApi extends runtime.BaseAPI {
|
|
|
71
161
|
if (requestParameters['sessionType'] != null) {
|
|
72
162
|
queryParameters['sessionType'] = requestParameters['sessionType'];
|
|
73
163
|
}
|
|
164
|
+
if (requestParameters['workspaceId'] != null) {
|
|
165
|
+
queryParameters['workspaceId'] = requestParameters['workspaceId'];
|
|
166
|
+
}
|
|
167
|
+
if (requestParameters['mine'] != null) {
|
|
168
|
+
queryParameters['mine'] = requestParameters['mine'];
|
|
169
|
+
}
|
|
74
170
|
const headerParameters = {};
|
|
75
171
|
if (this.configuration && this.configuration.accessToken) {
|
|
76
172
|
const token = this.configuration.accessToken;
|
|
@@ -96,6 +192,13 @@ export class AgentConversationsApi extends runtime.BaseAPI {
|
|
|
96
192
|
return await response.value();
|
|
97
193
|
}
|
|
98
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* @export
|
|
197
|
+
*/
|
|
198
|
+
export const AgentConversationArtifactDownloadUrlDispositionEnum = {
|
|
199
|
+
Inline: 'inline',
|
|
200
|
+
Attachment: 'attachment'
|
|
201
|
+
};
|
|
99
202
|
/**
|
|
100
203
|
* @export
|
|
101
204
|
*/
|