@kweaver-ai/kweaver-sdk 0.4.14 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/conversations.d.ts +6 -0
- package/dist/api/conversations.js +21 -0
- package/dist/api/vega.d.ts +76 -3
- package/dist/api/vega.js +145 -10
- package/dist/cli.js +1 -1
- package/dist/commands/agent.d.ts +5 -0
- package/dist/commands/agent.js +74 -2
- package/dist/commands/vega.js +640 -21
- package/dist/resources/vega.d.ts +17 -3
- package/dist/resources/vega.js +44 -4
- package/package.json +1 -1
|
@@ -12,11 +12,17 @@ export interface ListMessagesOptions {
|
|
|
12
12
|
businessDomain?: string;
|
|
13
13
|
limit?: number;
|
|
14
14
|
}
|
|
15
|
+
export interface GetTracesOptions {
|
|
16
|
+
baseUrl: string;
|
|
17
|
+
accessToken: string;
|
|
18
|
+
conversationId: string;
|
|
19
|
+
}
|
|
15
20
|
/**
|
|
16
21
|
* List conversations for an agent.
|
|
17
22
|
* Returns empty array on 404 (endpoint may not be available in all deployments).
|
|
18
23
|
*/
|
|
19
24
|
export declare function listConversations(opts: ListConversationsOptions): Promise<string>;
|
|
25
|
+
export declare function getTracesByConversation(opts: GetTracesOptions): Promise<string>;
|
|
20
26
|
/**
|
|
21
27
|
* List messages for a conversation.
|
|
22
28
|
* Returns empty array on 404 (endpoint may not be available in all deployments).
|
|
@@ -34,6 +34,27 @@ export async function listConversations(opts) {
|
|
|
34
34
|
}
|
|
35
35
|
return body || "[]";
|
|
36
36
|
}
|
|
37
|
+
function buildTracesUrl(baseUrl, conversationId) {
|
|
38
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
39
|
+
return `${base}/api/agent-observability/v1/traces/by-conversation?conversation_id=${conversationId}`;
|
|
40
|
+
}
|
|
41
|
+
export async function getTracesByConversation(opts) {
|
|
42
|
+
const { baseUrl, accessToken, conversationId } = opts;
|
|
43
|
+
const url = buildTracesUrl(baseUrl, conversationId);
|
|
44
|
+
const response = await fetch(url, {
|
|
45
|
+
method: "GET",
|
|
46
|
+
headers: {
|
|
47
|
+
accept: "application/json",
|
|
48
|
+
authorization: `Bearer ${accessToken}`,
|
|
49
|
+
token: accessToken,
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
const body = await response.text();
|
|
53
|
+
if (!response.ok) {
|
|
54
|
+
throw new Error(`getTracesByConversation failed: HTTP ${response.status} ${response.statusText} — ${body.slice(0, 200)}`);
|
|
55
|
+
}
|
|
56
|
+
return body || "{}";
|
|
57
|
+
}
|
|
37
58
|
/**
|
|
38
59
|
* List messages for a conversation.
|
|
39
60
|
* Returns empty array on 404 (endpoint may not be available in all deployments).
|
package/dist/api/vega.d.ts
CHANGED
|
@@ -20,6 +20,28 @@ export interface GetVegaCatalogOptions {
|
|
|
20
20
|
businessDomain?: string;
|
|
21
21
|
}
|
|
22
22
|
export declare function getVegaCatalog(options: GetVegaCatalogOptions): Promise<string>;
|
|
23
|
+
export interface CreateVegaCatalogOptions {
|
|
24
|
+
baseUrl: string;
|
|
25
|
+
accessToken: string;
|
|
26
|
+
body: string;
|
|
27
|
+
businessDomain?: string;
|
|
28
|
+
}
|
|
29
|
+
export declare function createVegaCatalog(options: CreateVegaCatalogOptions): Promise<string>;
|
|
30
|
+
export interface UpdateVegaCatalogOptions {
|
|
31
|
+
baseUrl: string;
|
|
32
|
+
accessToken: string;
|
|
33
|
+
id: string;
|
|
34
|
+
body: string;
|
|
35
|
+
businessDomain?: string;
|
|
36
|
+
}
|
|
37
|
+
export declare function updateVegaCatalog(options: UpdateVegaCatalogOptions): Promise<string>;
|
|
38
|
+
export interface DeleteVegaCatalogsOptions {
|
|
39
|
+
baseUrl: string;
|
|
40
|
+
accessToken: string;
|
|
41
|
+
ids: string;
|
|
42
|
+
businessDomain?: string;
|
|
43
|
+
}
|
|
44
|
+
export declare function deleteVegaCatalogs(options: DeleteVegaCatalogsOptions): Promise<string>;
|
|
23
45
|
export interface VegaCatalogHealthStatusOptions {
|
|
24
46
|
baseUrl: string;
|
|
25
47
|
accessToken: string;
|
|
@@ -78,14 +100,28 @@ export interface QueryVegaResourceDataOptions {
|
|
|
78
100
|
businessDomain?: string;
|
|
79
101
|
}
|
|
80
102
|
export declare function queryVegaResourceData(options: QueryVegaResourceDataOptions): Promise<string>;
|
|
81
|
-
export interface
|
|
103
|
+
export interface CreateVegaResourceOptions {
|
|
104
|
+
baseUrl: string;
|
|
105
|
+
accessToken: string;
|
|
106
|
+
body: string;
|
|
107
|
+
businessDomain?: string;
|
|
108
|
+
}
|
|
109
|
+
export declare function createVegaResource(options: CreateVegaResourceOptions): Promise<string>;
|
|
110
|
+
export interface UpdateVegaResourceOptions {
|
|
82
111
|
baseUrl: string;
|
|
83
112
|
accessToken: string;
|
|
84
113
|
id: string;
|
|
85
|
-
|
|
114
|
+
body: string;
|
|
115
|
+
businessDomain?: string;
|
|
116
|
+
}
|
|
117
|
+
export declare function updateVegaResource(options: UpdateVegaResourceOptions): Promise<string>;
|
|
118
|
+
export interface DeleteVegaResourcesOptions {
|
|
119
|
+
baseUrl: string;
|
|
120
|
+
accessToken: string;
|
|
121
|
+
ids: string;
|
|
86
122
|
businessDomain?: string;
|
|
87
123
|
}
|
|
88
|
-
export declare function
|
|
124
|
+
export declare function deleteVegaResources(options: DeleteVegaResourcesOptions): Promise<string>;
|
|
89
125
|
export interface ListVegaConnectorTypesOptions {
|
|
90
126
|
baseUrl: string;
|
|
91
127
|
accessToken: string;
|
|
@@ -99,6 +135,36 @@ export interface GetVegaConnectorTypeOptions {
|
|
|
99
135
|
businessDomain?: string;
|
|
100
136
|
}
|
|
101
137
|
export declare function getVegaConnectorType(options: GetVegaConnectorTypeOptions): Promise<string>;
|
|
138
|
+
export interface RegisterVegaConnectorTypeOptions {
|
|
139
|
+
baseUrl: string;
|
|
140
|
+
accessToken: string;
|
|
141
|
+
body: string;
|
|
142
|
+
businessDomain?: string;
|
|
143
|
+
}
|
|
144
|
+
export declare function registerVegaConnectorType(options: RegisterVegaConnectorTypeOptions): Promise<string>;
|
|
145
|
+
export interface UpdateVegaConnectorTypeOptions {
|
|
146
|
+
baseUrl: string;
|
|
147
|
+
accessToken: string;
|
|
148
|
+
type: string;
|
|
149
|
+
body: string;
|
|
150
|
+
businessDomain?: string;
|
|
151
|
+
}
|
|
152
|
+
export declare function updateVegaConnectorType(options: UpdateVegaConnectorTypeOptions): Promise<string>;
|
|
153
|
+
export interface DeleteVegaConnectorTypeOptions {
|
|
154
|
+
baseUrl: string;
|
|
155
|
+
accessToken: string;
|
|
156
|
+
type: string;
|
|
157
|
+
businessDomain?: string;
|
|
158
|
+
}
|
|
159
|
+
export declare function deleteVegaConnectorType(options: DeleteVegaConnectorTypeOptions): Promise<string>;
|
|
160
|
+
export interface SetVegaConnectorTypeEnabledOptions {
|
|
161
|
+
baseUrl: string;
|
|
162
|
+
accessToken: string;
|
|
163
|
+
type: string;
|
|
164
|
+
enabled: boolean;
|
|
165
|
+
businessDomain?: string;
|
|
166
|
+
}
|
|
167
|
+
export declare function setVegaConnectorTypeEnabled(options: SetVegaConnectorTypeEnabledOptions): Promise<string>;
|
|
102
168
|
export interface ListVegaDiscoverTasksOptions {
|
|
103
169
|
baseUrl: string;
|
|
104
170
|
accessToken: string;
|
|
@@ -108,3 +174,10 @@ export interface ListVegaDiscoverTasksOptions {
|
|
|
108
174
|
businessDomain?: string;
|
|
109
175
|
}
|
|
110
176
|
export declare function listVegaDiscoverTasks(options: ListVegaDiscoverTasksOptions): Promise<string>;
|
|
177
|
+
export interface GetVegaDiscoverTaskOptions {
|
|
178
|
+
baseUrl: string;
|
|
179
|
+
accessToken: string;
|
|
180
|
+
id: string;
|
|
181
|
+
businessDomain?: string;
|
|
182
|
+
}
|
|
183
|
+
export declare function getVegaDiscoverTask(options: GetVegaDiscoverTaskOptions): Promise<string>;
|
package/dist/api/vega.js
CHANGED
|
@@ -61,11 +61,52 @@ export async function getVegaCatalog(options) {
|
|
|
61
61
|
}
|
|
62
62
|
return body;
|
|
63
63
|
}
|
|
64
|
+
export async function createVegaCatalog(options) {
|
|
65
|
+
const { baseUrl, accessToken, body: requestBody, businessDomain = "bd_public" } = options;
|
|
66
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
67
|
+
const url = `${base}${VEGA_BASE}/catalogs`;
|
|
68
|
+
const response = await fetch(url, {
|
|
69
|
+
method: "POST",
|
|
70
|
+
headers: { ...buildHeaders(accessToken, businessDomain), "content-type": "application/json" },
|
|
71
|
+
body: requestBody,
|
|
72
|
+
});
|
|
73
|
+
const body = await response.text();
|
|
74
|
+
if (!response.ok)
|
|
75
|
+
throw new HttpError(response.status, response.statusText, body);
|
|
76
|
+
return body;
|
|
77
|
+
}
|
|
78
|
+
export async function updateVegaCatalog(options) {
|
|
79
|
+
const { baseUrl, accessToken, id, body: requestBody, businessDomain = "bd_public" } = options;
|
|
80
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
81
|
+
const url = `${base}${VEGA_BASE}/catalogs/${encodeURIComponent(id)}`;
|
|
82
|
+
const response = await fetch(url, {
|
|
83
|
+
method: "PUT",
|
|
84
|
+
headers: { ...buildHeaders(accessToken, businessDomain), "content-type": "application/json" },
|
|
85
|
+
body: requestBody,
|
|
86
|
+
});
|
|
87
|
+
const body = await response.text();
|
|
88
|
+
if (!response.ok)
|
|
89
|
+
throw new HttpError(response.status, response.statusText, body);
|
|
90
|
+
return body;
|
|
91
|
+
}
|
|
92
|
+
export async function deleteVegaCatalogs(options) {
|
|
93
|
+
const { baseUrl, accessToken, ids, businessDomain = "bd_public" } = options;
|
|
94
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
95
|
+
const url = `${base}${VEGA_BASE}/catalogs/${ids}`;
|
|
96
|
+
const response = await fetch(url, {
|
|
97
|
+
method: "DELETE",
|
|
98
|
+
headers: buildHeaders(accessToken, businessDomain),
|
|
99
|
+
});
|
|
100
|
+
const body = await response.text();
|
|
101
|
+
if (!response.ok)
|
|
102
|
+
throw new HttpError(response.status, response.statusText, body);
|
|
103
|
+
return body;
|
|
104
|
+
}
|
|
64
105
|
export async function vegaCatalogHealthStatus(options) {
|
|
65
106
|
const { baseUrl, accessToken, ids, businessDomain = "bd_public", } = options;
|
|
66
107
|
const base = baseUrl.replace(/\/+$/, "");
|
|
67
|
-
|
|
68
|
-
url
|
|
108
|
+
// ids go in the path segment: GET /catalogs/{ids}/health-status
|
|
109
|
+
const url = new URL(`${base}${VEGA_BASE}/catalogs/${ids}/health-status`);
|
|
69
110
|
const response = await fetch(url.toString(), {
|
|
70
111
|
method: "GET",
|
|
71
112
|
headers: buildHeaders(accessToken, businessDomain),
|
|
@@ -189,19 +230,45 @@ export async function queryVegaResourceData(options) {
|
|
|
189
230
|
}
|
|
190
231
|
return body;
|
|
191
232
|
}
|
|
192
|
-
export async function
|
|
193
|
-
const { baseUrl, accessToken,
|
|
233
|
+
export async function createVegaResource(options) {
|
|
234
|
+
const { baseUrl, accessToken, body: requestBody, businessDomain = "bd_public" } = options;
|
|
194
235
|
const base = baseUrl.replace(/\/+$/, "");
|
|
195
|
-
const url =
|
|
196
|
-
url
|
|
197
|
-
|
|
198
|
-
|
|
236
|
+
const url = `${base}${VEGA_BASE}/resources`;
|
|
237
|
+
const response = await fetch(url, {
|
|
238
|
+
method: "POST",
|
|
239
|
+
headers: { ...buildHeaders(accessToken, businessDomain), "content-type": "application/json" },
|
|
240
|
+
body: requestBody,
|
|
241
|
+
});
|
|
242
|
+
const body = await response.text();
|
|
243
|
+
if (!response.ok)
|
|
244
|
+
throw new HttpError(response.status, response.statusText, body);
|
|
245
|
+
return body;
|
|
246
|
+
}
|
|
247
|
+
export async function updateVegaResource(options) {
|
|
248
|
+
const { baseUrl, accessToken, id, body: requestBody, businessDomain = "bd_public" } = options;
|
|
249
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
250
|
+
const url = `${base}${VEGA_BASE}/resources/${encodeURIComponent(id)}`;
|
|
251
|
+
const response = await fetch(url, {
|
|
252
|
+
method: "PUT",
|
|
253
|
+
headers: { ...buildHeaders(accessToken, businessDomain), "content-type": "application/json" },
|
|
254
|
+
body: requestBody,
|
|
255
|
+
});
|
|
256
|
+
const body = await response.text();
|
|
257
|
+
if (!response.ok)
|
|
258
|
+
throw new HttpError(response.status, response.statusText, body);
|
|
259
|
+
return body;
|
|
260
|
+
}
|
|
261
|
+
export async function deleteVegaResources(options) {
|
|
262
|
+
const { baseUrl, accessToken, ids, businessDomain = "bd_public" } = options;
|
|
263
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
264
|
+
const url = `${base}${VEGA_BASE}/resources/${ids}`;
|
|
265
|
+
const response = await fetch(url, {
|
|
266
|
+
method: "DELETE",
|
|
199
267
|
headers: buildHeaders(accessToken, businessDomain),
|
|
200
268
|
});
|
|
201
269
|
const body = await response.text();
|
|
202
|
-
if (!response.ok)
|
|
270
|
+
if (!response.ok)
|
|
203
271
|
throw new HttpError(response.status, response.statusText, body);
|
|
204
|
-
}
|
|
205
272
|
return body;
|
|
206
273
|
}
|
|
207
274
|
export async function listVegaConnectorTypes(options) {
|
|
@@ -232,6 +299,61 @@ export async function getVegaConnectorType(options) {
|
|
|
232
299
|
}
|
|
233
300
|
return body;
|
|
234
301
|
}
|
|
302
|
+
export async function registerVegaConnectorType(options) {
|
|
303
|
+
const { baseUrl, accessToken, body: requestBody, businessDomain = "bd_public" } = options;
|
|
304
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
305
|
+
const url = `${base}${VEGA_BASE}/connector-types`;
|
|
306
|
+
const response = await fetch(url, {
|
|
307
|
+
method: "POST",
|
|
308
|
+
headers: { ...buildHeaders(accessToken, businessDomain), "content-type": "application/json" },
|
|
309
|
+
body: requestBody,
|
|
310
|
+
});
|
|
311
|
+
const body = await response.text();
|
|
312
|
+
if (!response.ok)
|
|
313
|
+
throw new HttpError(response.status, response.statusText, body);
|
|
314
|
+
return body;
|
|
315
|
+
}
|
|
316
|
+
export async function updateVegaConnectorType(options) {
|
|
317
|
+
const { baseUrl, accessToken, type, body: requestBody, businessDomain = "bd_public" } = options;
|
|
318
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
319
|
+
const url = `${base}${VEGA_BASE}/connector-types/${encodeURIComponent(type)}`;
|
|
320
|
+
const response = await fetch(url, {
|
|
321
|
+
method: "PUT",
|
|
322
|
+
headers: { ...buildHeaders(accessToken, businessDomain), "content-type": "application/json" },
|
|
323
|
+
body: requestBody,
|
|
324
|
+
});
|
|
325
|
+
const body = await response.text();
|
|
326
|
+
if (!response.ok)
|
|
327
|
+
throw new HttpError(response.status, response.statusText, body);
|
|
328
|
+
return body;
|
|
329
|
+
}
|
|
330
|
+
export async function deleteVegaConnectorType(options) {
|
|
331
|
+
const { baseUrl, accessToken, type, businessDomain = "bd_public" } = options;
|
|
332
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
333
|
+
const url = `${base}${VEGA_BASE}/connector-types/${encodeURIComponent(type)}`;
|
|
334
|
+
const response = await fetch(url, {
|
|
335
|
+
method: "DELETE",
|
|
336
|
+
headers: buildHeaders(accessToken, businessDomain),
|
|
337
|
+
});
|
|
338
|
+
const body = await response.text();
|
|
339
|
+
if (!response.ok)
|
|
340
|
+
throw new HttpError(response.status, response.statusText, body);
|
|
341
|
+
return body;
|
|
342
|
+
}
|
|
343
|
+
export async function setVegaConnectorTypeEnabled(options) {
|
|
344
|
+
const { baseUrl, accessToken, type, enabled, businessDomain = "bd_public" } = options;
|
|
345
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
346
|
+
const url = `${base}${VEGA_BASE}/connector-types/${encodeURIComponent(type)}/enabled`;
|
|
347
|
+
const response = await fetch(url, {
|
|
348
|
+
method: "POST",
|
|
349
|
+
headers: { ...buildHeaders(accessToken, businessDomain), "content-type": "application/json" },
|
|
350
|
+
body: JSON.stringify({ enabled }),
|
|
351
|
+
});
|
|
352
|
+
const body = await response.text();
|
|
353
|
+
if (!response.ok)
|
|
354
|
+
throw new HttpError(response.status, response.statusText, body);
|
|
355
|
+
return body;
|
|
356
|
+
}
|
|
235
357
|
export async function listVegaDiscoverTasks(options) {
|
|
236
358
|
const { baseUrl, accessToken, status, limit, offset, businessDomain = "bd_public", } = options;
|
|
237
359
|
const base = baseUrl.replace(/\/+$/, "");
|
|
@@ -252,3 +374,16 @@ export async function listVegaDiscoverTasks(options) {
|
|
|
252
374
|
}
|
|
253
375
|
return body;
|
|
254
376
|
}
|
|
377
|
+
export async function getVegaDiscoverTask(options) {
|
|
378
|
+
const { baseUrl, accessToken, id, businessDomain = "bd_public" } = options;
|
|
379
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
380
|
+
const url = `${base}${VEGA_BASE}/discover-tasks/${encodeURIComponent(id)}`;
|
|
381
|
+
const response = await fetch(url, {
|
|
382
|
+
method: "GET",
|
|
383
|
+
headers: buildHeaders(accessToken, businessDomain),
|
|
384
|
+
});
|
|
385
|
+
const body = await response.text();
|
|
386
|
+
if (!response.ok)
|
|
387
|
+
throw new HttpError(response.status, response.statusText, body);
|
|
388
|
+
return body;
|
|
389
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -82,7 +82,7 @@ Usage:
|
|
|
82
82
|
|
|
83
83
|
kweaver vega health|stats|inspect
|
|
84
84
|
kweaver vega catalog list|get|health|test-connection|discover|resources [options]
|
|
85
|
-
kweaver vega resource list|get|query
|
|
85
|
+
kweaver vega resource list|get|query [options]
|
|
86
86
|
kweaver vega connector-type list|get [options]
|
|
87
87
|
|
|
88
88
|
kweaver context-loader config set|use|list|remove|show [options]
|
package/dist/commands/agent.d.ts
CHANGED
|
@@ -25,6 +25,11 @@ export interface AgentHistoryOptions {
|
|
|
25
25
|
pretty: boolean;
|
|
26
26
|
}
|
|
27
27
|
export declare function parseAgentHistoryArgs(args: string[]): AgentHistoryOptions;
|
|
28
|
+
export interface AgentTraceOptions {
|
|
29
|
+
conversationId: string;
|
|
30
|
+
pretty: boolean;
|
|
31
|
+
}
|
|
32
|
+
export declare function parseAgentTraceArgs(args: string[]): AgentTraceOptions;
|
|
28
33
|
export declare function runAgentCommand(args: string[]): Promise<number>;
|
|
29
34
|
export interface AgentGetOptions {
|
|
30
35
|
agentId: string;
|
package/dist/commands/agent.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ensureValidToken, formatHttpError, with401RefreshRetry } from "../auth/oauth.js";
|
|
2
2
|
import { runAgentChatCommand } from "./agent-chat.js";
|
|
3
3
|
import { listAgents, getAgent, getAgentByKey, createAgent, updateAgent, deleteAgent, publishAgent, unpublishAgent, } from "../api/agent-list.js";
|
|
4
|
-
import { listConversations, listMessages } from "../api/conversations.js";
|
|
4
|
+
import { listConversations, listMessages, getTracesByConversation } from "../api/conversations.js";
|
|
5
5
|
import { formatCallOutput } from "./call.js";
|
|
6
6
|
import { resolveBusinessDomain } from "../config/store.js";
|
|
7
7
|
function readStringField(value, ...keys) {
|
|
@@ -212,6 +212,29 @@ export function parseAgentHistoryArgs(args) {
|
|
|
212
212
|
businessDomain = resolveBusinessDomain();
|
|
213
213
|
return { conversationId, businessDomain, limit, pretty };
|
|
214
214
|
}
|
|
215
|
+
export function parseAgentTraceArgs(args) {
|
|
216
|
+
const conversationId = args[0];
|
|
217
|
+
if (!conversationId || conversationId.startsWith("-")) {
|
|
218
|
+
throw new Error("Missing conversation_id");
|
|
219
|
+
}
|
|
220
|
+
let pretty = true;
|
|
221
|
+
for (let i = 1; i < args.length; i += 1) {
|
|
222
|
+
const arg = args[i];
|
|
223
|
+
if (arg === "--help" || arg === "-h") {
|
|
224
|
+
throw new Error("help");
|
|
225
|
+
}
|
|
226
|
+
if (arg === "--pretty") {
|
|
227
|
+
pretty = true;
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
if (arg === "--compact") {
|
|
231
|
+
pretty = false;
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
throw new Error(`Unsupported agent trace argument: ${arg}`);
|
|
235
|
+
}
|
|
236
|
+
return { conversationId, pretty };
|
|
237
|
+
}
|
|
215
238
|
export async function runAgentCommand(args) {
|
|
216
239
|
const [subcommand, ...rest] = args;
|
|
217
240
|
if (!subcommand || subcommand === "--help" || subcommand === "-h") {
|
|
@@ -231,7 +254,8 @@ Subcommands:
|
|
|
231
254
|
chat <agent_id> Start interactive chat with an agent
|
|
232
255
|
chat <agent_id> -m "message" Send a single message (non-interactive)
|
|
233
256
|
sessions <agent_id> List all conversations for an agent
|
|
234
|
-
history <conversation_id> Show message history for a conversation
|
|
257
|
+
history <conversation_id> Show message history for a conversation
|
|
258
|
+
trace <conversation_id> Get trace data for a conversation`);
|
|
235
259
|
return Promise.resolve(0);
|
|
236
260
|
}
|
|
237
261
|
const dispatch = async () => {
|
|
@@ -245,6 +269,8 @@ Subcommands:
|
|
|
245
269
|
return runAgentSessionsCommand(rest);
|
|
246
270
|
if (subcommand === "history")
|
|
247
271
|
return runAgentHistoryCommand(rest);
|
|
272
|
+
if (subcommand === "trace")
|
|
273
|
+
return runAgentTraceCommand(rest);
|
|
248
274
|
if (subcommand === "get-by-key")
|
|
249
275
|
return runAgentGetByKeyCommand(rest);
|
|
250
276
|
if (subcommand === "create")
|
|
@@ -345,6 +371,18 @@ Options:
|
|
|
345
371
|
return 0;
|
|
346
372
|
}
|
|
347
373
|
}
|
|
374
|
+
if (subcommand === "trace") {
|
|
375
|
+
if (rest.length === 1 && (rest[0] === "--help" || rest[0] === "-h")) {
|
|
376
|
+
console.log(`kweaver agent trace <conversation_id> [options]
|
|
377
|
+
|
|
378
|
+
Get trace data for a conversation.
|
|
379
|
+
|
|
380
|
+
Options:
|
|
381
|
+
--pretty Pretty-print JSON output (default)
|
|
382
|
+
--compact Compact JSON output`);
|
|
383
|
+
return 0;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
348
386
|
try {
|
|
349
387
|
return await with401RefreshRetry(async () => {
|
|
350
388
|
const code = await dispatch();
|
|
@@ -571,6 +609,40 @@ Options:
|
|
|
571
609
|
return 1;
|
|
572
610
|
}
|
|
573
611
|
}
|
|
612
|
+
async function runAgentTraceCommand(args) {
|
|
613
|
+
let options;
|
|
614
|
+
try {
|
|
615
|
+
options = parseAgentTraceArgs(args);
|
|
616
|
+
}
|
|
617
|
+
catch (error) {
|
|
618
|
+
if (error instanceof Error && error.message === "help") {
|
|
619
|
+
console.log(`kweaver agent trace <conversation_id> [options]
|
|
620
|
+
|
|
621
|
+
Get trace data for a conversation.
|
|
622
|
+
|
|
623
|
+
Options:
|
|
624
|
+
--pretty Pretty-print JSON output (default)
|
|
625
|
+
--compact Compact JSON output`);
|
|
626
|
+
return 0;
|
|
627
|
+
}
|
|
628
|
+
console.error(formatHttpError(error));
|
|
629
|
+
return 1;
|
|
630
|
+
}
|
|
631
|
+
try {
|
|
632
|
+
const token = await ensureValidToken();
|
|
633
|
+
const body = await getTracesByConversation({
|
|
634
|
+
baseUrl: token.baseUrl,
|
|
635
|
+
accessToken: token.accessToken,
|
|
636
|
+
conversationId: options.conversationId,
|
|
637
|
+
});
|
|
638
|
+
console.log(formatCallOutput(body, options.pretty));
|
|
639
|
+
return 0;
|
|
640
|
+
}
|
|
641
|
+
catch (error) {
|
|
642
|
+
console.error(formatHttpError(error));
|
|
643
|
+
return 1;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
574
646
|
// ── Get by key ───────────────────────────────────────────────────────────────
|
|
575
647
|
async function runAgentGetByKeyCommand(args) {
|
|
576
648
|
const key = args[0];
|