@agentuity/server 0.0.48 → 0.0.50
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/api.d.ts.map +1 -1
- package/dist/api/api.js +5 -0
- package/dist/api/api.js.map +1 -1
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +1 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/project/deploy.d.ts +10 -0
- package/dist/api/project/deploy.d.ts.map +1 -1
- package/dist/api/project/deploy.js +6 -1
- package/dist/api/project/deploy.js.map +1 -1
- package/dist/api/project/deployment.d.ts.map +1 -1
- package/dist/api/project/deployment.js +18 -10
- package/dist/api/project/deployment.js.map +1 -1
- package/dist/api/session/get.d.ts +33 -0
- package/dist/api/session/get.d.ts.map +1 -0
- package/dist/api/session/get.js +33 -0
- package/dist/api/session/get.js.map +1 -0
- package/dist/api/session/index.d.ts +7 -0
- package/dist/api/session/index.d.ts.map +1 -0
- package/dist/api/session/index.js +4 -0
- package/dist/api/session/index.js.map +1 -0
- package/dist/api/session/list.d.ts +127 -0
- package/dist/api/session/list.d.ts.map +1 -0
- package/dist/api/session/list.js +73 -0
- package/dist/api/session/list.js.map +1 -0
- package/dist/api/session/logs.d.ts +23 -0
- package/dist/api/session/logs.d.ts.map +1 -0
- package/dist/api/session/logs.js +27 -0
- package/dist/api/session/logs.js.map +1 -0
- package/dist/server.d.ts +13 -3
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +46 -6
- package/dist/server.js.map +1 -1
- package/package.json +4 -2
- package/src/api/api.ts +7 -0
- package/src/api/index.ts +1 -0
- package/src/api/project/deploy.ts +6 -1
- package/src/api/project/deployment.ts +55 -26
- package/src/api/session/get.ts +62 -0
- package/src/api/session/index.ts +6 -0
- package/src/api/session/list.ts +107 -0
- package/src/api/session/logs.ts +46 -0
- package/src/server.ts +57 -7
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { APIClient } from '../api';
|
|
3
|
+
declare const _SessionLogsRequestSchema: z.ZodObject<{
|
|
4
|
+
id: z.ZodString;
|
|
5
|
+
}, z.core.$strip>;
|
|
6
|
+
declare const LogSchema: z.ZodObject<{
|
|
7
|
+
body: z.ZodString;
|
|
8
|
+
severity: z.ZodString;
|
|
9
|
+
timestamp: z.ZodString;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
type SessionLogsRequest = z.infer<typeof _SessionLogsRequestSchema>;
|
|
12
|
+
export type SessionLog = z.infer<typeof LogSchema>;
|
|
13
|
+
export type SessionLogs = SessionLog[];
|
|
14
|
+
/**
|
|
15
|
+
* Get logs for a session from the App API
|
|
16
|
+
*
|
|
17
|
+
* @param client APIClient configured for the App API base URL
|
|
18
|
+
* @param request
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
export declare function sessionLogs(client: APIClient, request: SessionLogsRequest): Promise<SessionLogs>;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=logs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../../src/api/session/logs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAqB,MAAM,QAAQ,CAAC;AAEtD,QAAA,MAAM,yBAAyB;;iBAE7B,CAAC;AAEH,QAAA,MAAM,SAAS;;;;iBAIb,CAAC;AAMH,KAAK,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAGpE,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AACnD,MAAM,MAAM,WAAW,GAAG,UAAU,EAAE,CAAC;AAEvC;;;;;;GAMG;AACH,wBAAsB,WAAW,CAChC,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,kBAAkB,GACzB,OAAO,CAAC,WAAW,CAAC,CAYtB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { APIResponseSchema } from '../api';
|
|
3
|
+
const _SessionLogsRequestSchema = z.object({
|
|
4
|
+
id: z.string().describe('the session id'),
|
|
5
|
+
});
|
|
6
|
+
const LogSchema = z.object({
|
|
7
|
+
body: z.string().describe('the log body'),
|
|
8
|
+
severity: z.string().describe('the log severity'),
|
|
9
|
+
timestamp: z.string().describe('the log timestamp'),
|
|
10
|
+
});
|
|
11
|
+
const SessionLogsResponse = z.array(LogSchema);
|
|
12
|
+
const SessionLogsResponseSchema = APIResponseSchema(SessionLogsResponse);
|
|
13
|
+
/**
|
|
14
|
+
* Get logs for a session from the App API
|
|
15
|
+
*
|
|
16
|
+
* @param client APIClient configured for the App API base URL
|
|
17
|
+
* @param request
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
export async function sessionLogs(client, request) {
|
|
21
|
+
const resp = await client.request('GET', `/cli/session/${request.id}/logs`, SessionLogsResponseSchema);
|
|
22
|
+
if (resp.success) {
|
|
23
|
+
return resp.data;
|
|
24
|
+
}
|
|
25
|
+
throw new Error(resp.message);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=logs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs.js","sourceRoot":"","sources":["../../../src/api/session/logs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAa,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAEtD,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,gBAAgB,CAAC;CACzC,CAAC,CAAC;AAEH,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC;IACzC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;IACjD,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC;CACnD,CAAC,CAAC;AAEH,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AAE/C,MAAM,yBAAyB,GAAG,iBAAiB,CAAC,mBAAmB,CAAC,CAAC;AAQzE;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAChC,MAAiB,EACjB,OAA2B;IAE3B,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAChC,KAAK,EACL,gBAAgB,OAAO,CAAC,EAAE,OAAO,EACjC,yBAAyB,CACzB,CAAC;IAEF,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC/B,CAAC"}
|
package/dist/server.d.ts
CHANGED
|
@@ -1,13 +1,23 @@
|
|
|
1
|
-
import type { FetchRequest, FetchResponse, FetchAdapter } from '@agentuity/core';
|
|
1
|
+
import type { FetchRequest, FetchResponse, FetchAdapter, Logger } from '@agentuity/core';
|
|
2
2
|
import { ServiceException } from '@agentuity/core';
|
|
3
3
|
interface ServiceAdapterConfig {
|
|
4
4
|
headers: Record<string, string>;
|
|
5
5
|
onBefore?: (url: string, options: FetchRequest, invoke: () => Promise<void>) => Promise<void>;
|
|
6
6
|
onAfter?: <T>(url: string, options: FetchRequest, response: FetchResponse<T>, err?: ServiceException) => Promise<void>;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* Redacts the middle of a string while keeping a prefix and suffix visible.
|
|
10
|
+
* Ensures that if the string is too short, everything is redacted.
|
|
11
|
+
*
|
|
12
|
+
* @param input The string to redact
|
|
13
|
+
* @param prefix Number of chars to keep at the start
|
|
14
|
+
* @param suffix Number of chars to keep at the end
|
|
15
|
+
* @param mask Character used for redaction
|
|
16
|
+
*/
|
|
17
|
+
export declare function redact(input: string, prefix?: number, suffix?: number, mask?: string): string;
|
|
8
18
|
declare class ServerFetchAdapter implements FetchAdapter {
|
|
9
19
|
#private;
|
|
10
|
-
constructor(config: ServiceAdapterConfig);
|
|
20
|
+
constructor(config: ServiceAdapterConfig, logger: Logger);
|
|
11
21
|
private _invoke;
|
|
12
22
|
invoke<T>(url: string, options?: FetchRequest): Promise<FetchResponse<T>>;
|
|
13
23
|
}
|
|
@@ -17,6 +27,6 @@ declare class ServerFetchAdapter implements FetchAdapter {
|
|
|
17
27
|
* @param config the service config
|
|
18
28
|
* @returns
|
|
19
29
|
*/
|
|
20
|
-
export declare function createServerFetchAdapter(config: ServiceAdapterConfig): ServerFetchAdapter;
|
|
30
|
+
export declare function createServerFetchAdapter(config: ServiceAdapterConfig, logger: Logger): ServerFetchAdapter;
|
|
21
31
|
export {};
|
|
22
32
|
//# sourceMappingURL=server.d.ts.map
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,YAAY,EAEZ,aAAa,EACb,YAAY,EACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAoC,MAAM,iBAAiB,CAAC;AAErF,UAAU,oBAAoB;IAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9F,OAAO,CAA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;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,sBAEpF"}
|
package/dist/server.js
CHANGED
|
@@ -1,8 +1,46 @@
|
|
|
1
1
|
import { toServiceException, fromResponse } from '@agentuity/core';
|
|
2
|
+
const sensitiveHeaders = new Set(['authorization', 'x-api-key']);
|
|
3
|
+
/**
|
|
4
|
+
* Redacts the middle of a string while keeping a prefix and suffix visible.
|
|
5
|
+
* Ensures that if the string is too short, everything is redacted.
|
|
6
|
+
*
|
|
7
|
+
* @param input The string to redact
|
|
8
|
+
* @param prefix Number of chars to keep at the start
|
|
9
|
+
* @param suffix Number of chars to keep at the end
|
|
10
|
+
* @param mask Character used for redaction
|
|
11
|
+
*/
|
|
12
|
+
export function redact(input, prefix = 4, suffix = 4, mask = '*') {
|
|
13
|
+
if (!input)
|
|
14
|
+
return '';
|
|
15
|
+
// If revealing prefix+suffix would leak too much, fully mask
|
|
16
|
+
if (input.length <= prefix + suffix) {
|
|
17
|
+
return mask.repeat(input.length);
|
|
18
|
+
}
|
|
19
|
+
const start = input.slice(0, prefix);
|
|
20
|
+
const end = input.slice(-suffix);
|
|
21
|
+
const hiddenLength = input.length - prefix - suffix;
|
|
22
|
+
return start + mask.repeat(hiddenLength) + end;
|
|
23
|
+
}
|
|
24
|
+
const redactHeaders = (kv) => {
|
|
25
|
+
const values = [];
|
|
26
|
+
for (const k of Object.keys(kv)) {
|
|
27
|
+
const _k = k.toLowerCase();
|
|
28
|
+
const v = kv[k];
|
|
29
|
+
if (sensitiveHeaders.has(_k)) {
|
|
30
|
+
values.push(`${_k}=${redact(v)}`);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
values.push(`${_k}=${v}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return '[' + values.join(',') + ']';
|
|
37
|
+
};
|
|
2
38
|
class ServerFetchAdapter {
|
|
3
39
|
#config;
|
|
4
|
-
|
|
40
|
+
#logger;
|
|
41
|
+
constructor(config, logger) {
|
|
5
42
|
this.#config = config;
|
|
43
|
+
this.#logger = logger;
|
|
6
44
|
}
|
|
7
45
|
async _invoke(url, options) {
|
|
8
46
|
const headers = {
|
|
@@ -17,8 +55,10 @@ class ServerFetchAdapter {
|
|
|
17
55
|
options.body instanceof ArrayBuffer) {
|
|
18
56
|
headers['Content-Type'] = 'application/octet-stream';
|
|
19
57
|
}
|
|
58
|
+
const method = options.method ?? 'POST';
|
|
59
|
+
this.#logger.trace('sending %s to %s with headers: %s', method, url, redactHeaders(headers));
|
|
20
60
|
const res = await fetch(url, {
|
|
21
|
-
method
|
|
61
|
+
method,
|
|
22
62
|
body: options.body,
|
|
23
63
|
headers,
|
|
24
64
|
signal: options.signal,
|
|
@@ -46,7 +86,7 @@ class ServerFetchAdapter {
|
|
|
46
86
|
response: res,
|
|
47
87
|
};
|
|
48
88
|
}
|
|
49
|
-
const data = await fromResponse(url, res);
|
|
89
|
+
const data = await fromResponse(method, url, res);
|
|
50
90
|
return {
|
|
51
91
|
ok: true,
|
|
52
92
|
data,
|
|
@@ -59,7 +99,7 @@ class ServerFetchAdapter {
|
|
|
59
99
|
response: res,
|
|
60
100
|
};
|
|
61
101
|
}
|
|
62
|
-
const err = await toServiceException(url, res);
|
|
102
|
+
const err = await toServiceException(method, url, res);
|
|
63
103
|
throw err;
|
|
64
104
|
}
|
|
65
105
|
async invoke(url, options = { method: 'POST' }) {
|
|
@@ -101,7 +141,7 @@ class ServerFetchAdapter {
|
|
|
101
141
|
* @param config the service config
|
|
102
142
|
* @returns
|
|
103
143
|
*/
|
|
104
|
-
export function createServerFetchAdapter(config) {
|
|
105
|
-
return new ServerFetchAdapter(config);
|
|
144
|
+
export function createServerFetchAdapter(config, logger) {
|
|
145
|
+
return new ServerFetchAdapter(config, logger);
|
|
106
146
|
}
|
|
107
147
|
//# sourceMappingURL=server.js.map
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAOA,OAAO,EAAoB,kBAAkB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAarF,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC,CAAC;AAEjE;;;;;;;;GAQG;AACH,MAAM,UAAU,MAAM,CACrB,KAAa,EACb,SAAiB,CAAC,EAClB,SAAiB,CAAC,EAClB,OAAe,GAAG;IAElB,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC;IAEtB,6DAA6D;IAC7D,IAAI,KAAK,CAAC,MAAM,IAAI,MAAM,GAAG,MAAM,EAAE,CAAC;QACrC,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IAED,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACrC,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC;IACjC,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAEpD,OAAO,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,GAAG,CAAC;AAChD,CAAC;AAED,MAAM,aAAa,GAAG,CAAC,EAA0B,EAAU,EAAE;IAC5D,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;QACjC,MAAM,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;QAC3B,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QAChB,IAAI,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC,EA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AAE,MAAM,CAAC,CAAC;AAC/C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentuity/server",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.50",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"author": "Agentuity employees and contributors",
|
|
6
6
|
"type": "module",
|
|
@@ -25,11 +25,13 @@
|
|
|
25
25
|
"prepublishOnly": "bun run clean && bun run build"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@agentuity/core": "0.0.
|
|
28
|
+
"@agentuity/core": "0.0.50",
|
|
29
29
|
"zod": "^4.1.12"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
+
"@types/bun": "latest",
|
|
32
33
|
"@types/node": "^22.0.0",
|
|
34
|
+
"bun-types": "latest",
|
|
33
35
|
"typescript": "^5.9.0"
|
|
34
36
|
},
|
|
35
37
|
"publishConfig": {
|
package/src/api/api.ts
CHANGED
|
@@ -147,6 +147,8 @@ export class APIClient {
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
async #makeRequest(method: string, endpoint: string, body?: unknown): Promise<Response> {
|
|
150
|
+
this.#logger.trace('sending %s to %s', method, endpoint);
|
|
151
|
+
|
|
150
152
|
const maxRetries = this.#config?.maxRetries ?? 3;
|
|
151
153
|
const baseDelayMs = this.#config?.retryDelayMs ?? 100;
|
|
152
154
|
|
|
@@ -165,6 +167,11 @@ export class APIClient {
|
|
|
165
167
|
headers['Authorization'] = `Bearer ${this.#apiKey}`;
|
|
166
168
|
}
|
|
167
169
|
|
|
170
|
+
// Log request body for debugging deployment issues
|
|
171
|
+
if (body !== undefined && endpoint.includes('/deploy/')) {
|
|
172
|
+
this.#logger.debug('Request body: %s', JSON.stringify(body, null, 2));
|
|
173
|
+
}
|
|
174
|
+
|
|
168
175
|
const response = await fetch(url, {
|
|
169
176
|
method,
|
|
170
177
|
headers,
|
package/src/api/index.ts
CHANGED
|
@@ -35,13 +35,18 @@ const BaseFileFields = {
|
|
|
35
35
|
const EvalSchema = z.object({
|
|
36
36
|
...BaseFileFields,
|
|
37
37
|
id: z.string().describe('the unique calculated id for the eval'),
|
|
38
|
+
evalId: z.string().describe('the unique id for eval for the project across deployments'),
|
|
38
39
|
name: z.string().describe('the name of the eval'),
|
|
39
40
|
description: z.string().optional().describe('the eval description'),
|
|
41
|
+
agentIdentifier: z.string().describe('the identifier of the agent'),
|
|
42
|
+
projectId: z.string().describe('the project id'),
|
|
40
43
|
});
|
|
41
44
|
|
|
42
45
|
const BaseAgentFields = {
|
|
43
46
|
...BaseFileFields,
|
|
44
47
|
id: z.string().describe('the unique calculated id for the agent'),
|
|
48
|
+
agentId: z.string().describe('the unique id for agent for the project across deployments'),
|
|
49
|
+
projectId: z.string().describe('the project id'),
|
|
45
50
|
name: z.string().describe('the name of the agent'),
|
|
46
51
|
description: z.string().optional().describe('the agent description'),
|
|
47
52
|
evals: z.array(EvalSchema).optional().describe('the evals for the agent'),
|
|
@@ -138,7 +143,7 @@ export async function projectDeploymentCreate(
|
|
|
138
143
|
'POST',
|
|
139
144
|
`/cli/deploy/1/start/${projectId}`,
|
|
140
145
|
CreateProjectDeploymentSchema,
|
|
141
|
-
deploymentConfig
|
|
146
|
+
deploymentConfig ?? {}
|
|
142
147
|
);
|
|
143
148
|
if (resp.success) {
|
|
144
149
|
return resp.data;
|
|
@@ -1,27 +1,35 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { type APIClient, APIResponseSchema } from '../api';
|
|
2
|
+
import { type APIClient, APIResponseSchema, APIResponseSchemaOptionalData } from '../api';
|
|
3
3
|
|
|
4
4
|
// Simplified metadata schema for the client
|
|
5
5
|
const DeploymentMetadataSchema = z.object({
|
|
6
|
-
origin: z
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
6
|
+
origin: z
|
|
7
|
+
.object({
|
|
8
|
+
trigger: z.string().optional(),
|
|
9
|
+
provider: z.string().optional(),
|
|
10
|
+
event: z.string().optional(),
|
|
11
|
+
branch: z.string().optional(),
|
|
12
|
+
commit: z
|
|
13
|
+
.object({
|
|
14
|
+
hash: z.string(),
|
|
15
|
+
message: z.string(),
|
|
16
|
+
url: z.string().optional(),
|
|
17
|
+
author: z
|
|
18
|
+
.object({
|
|
19
|
+
name: z.string().optional(),
|
|
20
|
+
email: z.string().optional(),
|
|
21
|
+
})
|
|
22
|
+
.optional(),
|
|
23
|
+
})
|
|
24
|
+
.optional(),
|
|
25
|
+
pr: z
|
|
26
|
+
.object({
|
|
27
|
+
number: z.number(),
|
|
28
|
+
url: z.string().optional(),
|
|
29
|
+
})
|
|
30
|
+
.optional(),
|
|
31
|
+
})
|
|
32
|
+
.optional(),
|
|
25
33
|
});
|
|
26
34
|
|
|
27
35
|
const DeploymentSchema = z.object({
|
|
@@ -39,11 +47,17 @@ const DeploymentSchema = z.object({
|
|
|
39
47
|
|
|
40
48
|
const DeploymentListResponseSchema = APIResponseSchema(z.array(DeploymentSchema));
|
|
41
49
|
const DeploymentGetResponseSchema = APIResponseSchema(DeploymentSchema);
|
|
42
|
-
const DeploymentActionResponseSchema =
|
|
50
|
+
const DeploymentActionResponseSchema = APIResponseSchemaOptionalData(
|
|
51
|
+
z.object({ activeDeploymentId: z.string().optional() })
|
|
52
|
+
);
|
|
43
53
|
|
|
44
54
|
export type DeploymentInfo = z.infer<typeof DeploymentSchema>;
|
|
45
55
|
|
|
46
|
-
export async function projectDeploymentList(
|
|
56
|
+
export async function projectDeploymentList(
|
|
57
|
+
client: APIClient,
|
|
58
|
+
projectId: string,
|
|
59
|
+
limit = 10
|
|
60
|
+
): Promise<DeploymentInfo[]> {
|
|
47
61
|
const resp = await client.request(
|
|
48
62
|
'GET',
|
|
49
63
|
`/cli/project/${projectId}/deployments?limit=${limit}`,
|
|
@@ -55,7 +69,11 @@ export async function projectDeploymentList(client: APIClient, projectId: string
|
|
|
55
69
|
throw new Error(resp.message);
|
|
56
70
|
}
|
|
57
71
|
|
|
58
|
-
export async function projectDeploymentGet(
|
|
72
|
+
export async function projectDeploymentGet(
|
|
73
|
+
client: APIClient,
|
|
74
|
+
projectId: string,
|
|
75
|
+
deploymentId: string
|
|
76
|
+
): Promise<DeploymentInfo> {
|
|
59
77
|
const resp = await client.request(
|
|
60
78
|
'GET',
|
|
61
79
|
`/cli/project/${projectId}/deployments/${deploymentId}`,
|
|
@@ -67,7 +85,11 @@ export async function projectDeploymentGet(client: APIClient, projectId: string,
|
|
|
67
85
|
throw new Error(resp.message);
|
|
68
86
|
}
|
|
69
87
|
|
|
70
|
-
export async function projectDeploymentDelete(
|
|
88
|
+
export async function projectDeploymentDelete(
|
|
89
|
+
client: APIClient,
|
|
90
|
+
projectId: string,
|
|
91
|
+
deploymentId: string
|
|
92
|
+
): Promise<void> {
|
|
71
93
|
const resp = await client.request(
|
|
72
94
|
'DELETE',
|
|
73
95
|
`/cli/project/${projectId}/deployments/${deploymentId}`,
|
|
@@ -78,7 +100,11 @@ export async function projectDeploymentDelete(client: APIClient, projectId: stri
|
|
|
78
100
|
}
|
|
79
101
|
}
|
|
80
102
|
|
|
81
|
-
export async function projectDeploymentRollback(
|
|
103
|
+
export async function projectDeploymentRollback(
|
|
104
|
+
client: APIClient,
|
|
105
|
+
projectId: string,
|
|
106
|
+
deploymentId: string
|
|
107
|
+
): Promise<void> {
|
|
82
108
|
const resp = await client.request(
|
|
83
109
|
'POST',
|
|
84
110
|
`/cli/project/${projectId}/deployments/${deploymentId}/rollback`,
|
|
@@ -89,7 +115,10 @@ export async function projectDeploymentRollback(client: APIClient, projectId: st
|
|
|
89
115
|
}
|
|
90
116
|
}
|
|
91
117
|
|
|
92
|
-
export async function projectDeploymentUndeploy(
|
|
118
|
+
export async function projectDeploymentUndeploy(
|
|
119
|
+
client: APIClient,
|
|
120
|
+
projectId: string
|
|
121
|
+
): Promise<void> {
|
|
93
122
|
const resp = await client.request(
|
|
94
123
|
'POST',
|
|
95
124
|
`/cli/project/${projectId}/deployments/undeploy`,
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { APIClient, APIResponseSchema } from '../api';
|
|
3
|
+
import { SessionSchema } from './list';
|
|
4
|
+
|
|
5
|
+
const _SessionGetRequestSchema = z.object({
|
|
6
|
+
id: z.string().describe('the session id'),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
const EvalRunSchema = z.object({
|
|
10
|
+
id: z.string().describe('eval run id'),
|
|
11
|
+
created_at: z.string().describe('creation timestamp'),
|
|
12
|
+
eval_id: z.string().describe('evaluation id'),
|
|
13
|
+
pending: z.boolean().describe('pending status'),
|
|
14
|
+
success: z.boolean().describe('success status'),
|
|
15
|
+
error: z.string().nullable().describe('error message'),
|
|
16
|
+
result: z.string().nullable().describe('result JSON'),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const EnrichedSessionDataSchema = z.object({
|
|
20
|
+
session: SessionSchema,
|
|
21
|
+
agent_names: z.array(z.string()).describe('resolved agent names'),
|
|
22
|
+
eval_runs: z.array(EvalRunSchema).describe('eval runs for this session'),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const SessionGetResponseSchema = APIResponseSchema(EnrichedSessionDataSchema);
|
|
26
|
+
|
|
27
|
+
type SessionGetRequest = z.infer<typeof _SessionGetRequestSchema>;
|
|
28
|
+
type SessionGetResponse = z.infer<typeof SessionGetResponseSchema>;
|
|
29
|
+
|
|
30
|
+
export type Session = z.infer<typeof SessionSchema>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Get a single session by id
|
|
34
|
+
*
|
|
35
|
+
* @param client
|
|
36
|
+
* @param request
|
|
37
|
+
* @returns
|
|
38
|
+
*/
|
|
39
|
+
export type EvalRun = z.infer<typeof EvalRunSchema>;
|
|
40
|
+
export type EnrichedSession = {
|
|
41
|
+
session: Session;
|
|
42
|
+
agentNames: string[];
|
|
43
|
+
evalRuns: EvalRun[];
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export async function sessionGet(client: APIClient, request: SessionGetRequest): Promise<EnrichedSession> {
|
|
47
|
+
const resp = await client.request<SessionGetResponse>(
|
|
48
|
+
'GET',
|
|
49
|
+
`/session/2025-03-17/${request.id}`,
|
|
50
|
+
SessionGetResponseSchema
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
if (resp.success) {
|
|
54
|
+
return {
|
|
55
|
+
session: resp.data.session,
|
|
56
|
+
agentNames: resp.data.agent_names,
|
|
57
|
+
evalRuns: resp.data.eval_runs,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
throw new Error(resp.message);
|
|
62
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { sessionGet } from './get';
|
|
2
|
+
export type { Session, EnrichedSession, EvalRun } from './get';
|
|
3
|
+
export { sessionList, SessionSchema } from './list';
|
|
4
|
+
export type { SessionList, SessionListResponse, SessionListOptions } from './list';
|
|
5
|
+
export { sessionLogs } from './logs';
|
|
6
|
+
export type { SessionLog } from './logs';
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { APIClient, APIResponseSchema } from '../api';
|
|
3
|
+
|
|
4
|
+
const SessionSchema = z.object({
|
|
5
|
+
id: z.string().describe('the session id'),
|
|
6
|
+
created_at: z.string().describe('the creation timestamp'),
|
|
7
|
+
updated_at: z.string().describe('the last update timestamp'),
|
|
8
|
+
deleted: z.boolean().describe('whether the session is deleted'),
|
|
9
|
+
deleted_at: z.string().nullable().describe('the deletion timestamp'),
|
|
10
|
+
deleted_by: z.string().nullable().describe('who deleted the session'),
|
|
11
|
+
start_time: z.string().describe('the session start time'),
|
|
12
|
+
end_time: z.string().nullable().describe('the session end time'),
|
|
13
|
+
duration: z.number().nullable().describe('the session duration in nanoseconds'),
|
|
14
|
+
org_id: z.string().describe('the organization id'),
|
|
15
|
+
project_id: z.string().describe('the project id'),
|
|
16
|
+
deployment_id: z.string().describe('the deployment id'),
|
|
17
|
+
agent_ids: z.array(z.string()).describe('the agent ids involved'),
|
|
18
|
+
trigger: z.string().describe('how the session was triggered'),
|
|
19
|
+
env: z.string().describe('the environment'),
|
|
20
|
+
devmode: z.boolean().describe('whether dev mode was enabled'),
|
|
21
|
+
pending: z.boolean().describe('whether the session is pending'),
|
|
22
|
+
success: z.boolean().describe('whether the session succeeded'),
|
|
23
|
+
error: z.string().nullable().describe('the error message if failed'),
|
|
24
|
+
metadata: z.string().nullable().describe('additional metadata'),
|
|
25
|
+
cpu_time: z.number().nullable().describe('the CPU time in nanoseconds'),
|
|
26
|
+
llm_cost: z.string().nullable().describe('the LLM cost'),
|
|
27
|
+
llm_prompt_token_count: z.number().nullable().describe('the LLM prompt token count'),
|
|
28
|
+
llm_completion_token_count: z.number().nullable().describe('the LLM completion token count'),
|
|
29
|
+
total_cost: z.string().nullable().describe('the total cost'),
|
|
30
|
+
method: z.string().describe('the HTTP method'),
|
|
31
|
+
url: z.string().describe('the request URL'),
|
|
32
|
+
route_id: z.string().describe('the route id'),
|
|
33
|
+
thread_id: z.string().describe('the thread id'),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export { SessionSchema };
|
|
37
|
+
|
|
38
|
+
const SessionListResponse = z.array(SessionSchema);
|
|
39
|
+
|
|
40
|
+
const SessionListResponseSchema = APIResponseSchema(SessionListResponse);
|
|
41
|
+
|
|
42
|
+
export type SessionListResponse = z.infer<typeof SessionListResponseSchema>;
|
|
43
|
+
export type SessionList = z.infer<typeof SessionListResponse>;
|
|
44
|
+
export type Session = z.infer<typeof SessionSchema>;
|
|
45
|
+
|
|
46
|
+
export interface SessionListOptions {
|
|
47
|
+
count?: number;
|
|
48
|
+
projectId?: string;
|
|
49
|
+
deploymentId?: string;
|
|
50
|
+
trigger?: string;
|
|
51
|
+
env?: string;
|
|
52
|
+
devmode?: boolean;
|
|
53
|
+
success?: boolean;
|
|
54
|
+
threadId?: string;
|
|
55
|
+
agentIdentifier?: string;
|
|
56
|
+
startAfter?: string;
|
|
57
|
+
startBefore?: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* List sessions
|
|
62
|
+
*
|
|
63
|
+
* @param client
|
|
64
|
+
* @param options filtering and pagination options
|
|
65
|
+
* @returns
|
|
66
|
+
*/
|
|
67
|
+
export async function sessionList(
|
|
68
|
+
client: APIClient,
|
|
69
|
+
options: SessionListOptions = {}
|
|
70
|
+
): Promise<SessionList> {
|
|
71
|
+
const {
|
|
72
|
+
count = 10,
|
|
73
|
+
projectId,
|
|
74
|
+
deploymentId,
|
|
75
|
+
trigger,
|
|
76
|
+
env,
|
|
77
|
+
devmode,
|
|
78
|
+
success,
|
|
79
|
+
threadId,
|
|
80
|
+
agentIdentifier,
|
|
81
|
+
startAfter,
|
|
82
|
+
startBefore,
|
|
83
|
+
} = options;
|
|
84
|
+
const params = new URLSearchParams({ count: count.toString() });
|
|
85
|
+
if (projectId) params.set('projectId', projectId);
|
|
86
|
+
if (deploymentId) params.set('deploymentId', deploymentId);
|
|
87
|
+
if (trigger) params.set('trigger', trigger);
|
|
88
|
+
if (env) params.set('env', env);
|
|
89
|
+
if (devmode !== undefined) params.set('devmode', devmode.toString());
|
|
90
|
+
if (success !== undefined) params.set('success', success.toString());
|
|
91
|
+
if (threadId) params.set('threadId', threadId);
|
|
92
|
+
if (agentIdentifier) params.set('agentIdentifier', agentIdentifier);
|
|
93
|
+
if (startAfter) params.set('startAfter', startAfter);
|
|
94
|
+
if (startBefore) params.set('startBefore', startBefore);
|
|
95
|
+
|
|
96
|
+
const resp = await client.request<SessionListResponse>(
|
|
97
|
+
'GET',
|
|
98
|
+
`/session/2025-03-17?${params.toString()}`,
|
|
99
|
+
SessionListResponseSchema
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
if (resp.success) {
|
|
103
|
+
return resp.data;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
throw new Error(resp.message);
|
|
107
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { APIClient, APIResponseSchema } from '../api';
|
|
3
|
+
|
|
4
|
+
const _SessionLogsRequestSchema = z.object({
|
|
5
|
+
id: z.string().describe('the session id'),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
const LogSchema = z.object({
|
|
9
|
+
body: z.string().describe('the log body'),
|
|
10
|
+
severity: z.string().describe('the log severity'),
|
|
11
|
+
timestamp: z.string().describe('the log timestamp'),
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const SessionLogsResponse = z.array(LogSchema);
|
|
15
|
+
|
|
16
|
+
const SessionLogsResponseSchema = APIResponseSchema(SessionLogsResponse);
|
|
17
|
+
|
|
18
|
+
type SessionLogsRequest = z.infer<typeof _SessionLogsRequestSchema>;
|
|
19
|
+
type SessionLogsResponse = z.infer<typeof SessionLogsResponseSchema>;
|
|
20
|
+
|
|
21
|
+
export type SessionLog = z.infer<typeof LogSchema>;
|
|
22
|
+
export type SessionLogs = SessionLog[];
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Get logs for a session from the App API
|
|
26
|
+
*
|
|
27
|
+
* @param client APIClient configured for the App API base URL
|
|
28
|
+
* @param request
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
export async function sessionLogs(
|
|
32
|
+
client: APIClient,
|
|
33
|
+
request: SessionLogsRequest
|
|
34
|
+
): Promise<SessionLogs> {
|
|
35
|
+
const resp = await client.request<SessionLogsResponse>(
|
|
36
|
+
'GET',
|
|
37
|
+
`/cli/session/${request.id}/logs`,
|
|
38
|
+
SessionLogsResponseSchema
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
if (resp.success) {
|
|
42
|
+
return resp.data;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
throw new Error(resp.message);
|
|
46
|
+
}
|