@agentuity/server 0.0.60 → 0.0.62
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 +87 -23
- package/dist/api/api.d.ts.map +1 -1
- package/dist/api/api.js +87 -47
- package/dist/api/api.js.map +1 -1
- package/dist/api/apikey/create.d.ts.map +1 -1
- package/dist/api/apikey/create.js +2 -1
- package/dist/api/apikey/create.js.map +1 -1
- package/dist/api/apikey/delete.d.ts.map +1 -1
- package/dist/api/apikey/delete.js +2 -1
- package/dist/api/apikey/delete.js.map +1 -1
- package/dist/api/apikey/get.d.ts.map +1 -1
- package/dist/api/apikey/get.js +2 -1
- package/dist/api/apikey/get.js.map +1 -1
- package/dist/api/apikey/list.d.ts.map +1 -1
- package/dist/api/apikey/list.js +2 -1
- package/dist/api/apikey/list.js.map +1 -1
- package/dist/api/apikey/util.d.ts +23 -0
- package/dist/api/apikey/util.d.ts.map +1 -0
- package/dist/api/apikey/util.js +3 -0
- package/dist/api/apikey/util.js.map +1 -0
- 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/org/list.d.ts.map +1 -1
- package/dist/api/org/list.js +2 -1
- package/dist/api/org/list.js.map +1 -1
- package/dist/api/org/util.d.ts +23 -0
- package/dist/api/org/util.d.ts.map +1 -0
- package/dist/api/org/util.js +3 -0
- package/dist/api/org/util.js.map +1 -0
- package/dist/api/project/agent.d.ts.map +1 -1
- package/dist/api/project/agent.js +4 -3
- package/dist/api/project/agent.js.map +1 -1
- package/dist/api/project/create.d.ts.map +1 -1
- package/dist/api/project/create.js +2 -1
- package/dist/api/project/create.js.map +1 -1
- package/dist/api/project/delete.d.ts.map +1 -1
- package/dist/api/project/delete.js +2 -1
- package/dist/api/project/delete.js.map +1 -1
- package/dist/api/project/deploy.d.ts.map +1 -1
- package/dist/api/project/deploy.js +4 -3
- 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 +7 -6
- package/dist/api/project/deployment.js.map +1 -1
- package/dist/api/project/env-delete.d.ts.map +1 -1
- package/dist/api/project/env-delete.js +2 -1
- package/dist/api/project/env-delete.js.map +1 -1
- package/dist/api/project/env-update.d.ts.map +1 -1
- package/dist/api/project/env-update.js +2 -1
- package/dist/api/project/env-update.js.map +1 -1
- package/dist/api/project/exists.d.ts.map +1 -1
- package/dist/api/project/exists.js +6 -5
- package/dist/api/project/exists.js.map +1 -1
- package/dist/api/project/get.d.ts.map +1 -1
- package/dist/api/project/get.js +2 -1
- package/dist/api/project/get.js.map +1 -1
- package/dist/api/project/list.d.ts.map +1 -1
- package/dist/api/project/list.js +2 -1
- package/dist/api/project/list.js.map +1 -1
- package/dist/api/project/util.d.ts +49 -0
- package/dist/api/project/util.d.ts.map +1 -0
- package/dist/api/project/util.js +5 -0
- package/dist/api/project/util.js.map +1 -0
- package/dist/api/region/create.d.ts.map +1 -1
- package/dist/api/region/create.js +4 -1
- package/dist/api/region/create.js.map +1 -1
- package/dist/api/region/delete.d.ts.map +1 -1
- package/dist/api/region/delete.js +2 -1
- package/dist/api/region/delete.js.map +1 -1
- package/dist/api/region/list.d.ts.map +1 -1
- package/dist/api/region/list.js +2 -1
- package/dist/api/region/list.js.map +1 -1
- package/dist/api/region/resources.d.ts.map +1 -1
- package/dist/api/region/resources.js +2 -1
- package/dist/api/region/resources.js.map +1 -1
- package/dist/api/region/util.d.ts +23 -0
- package/dist/api/region/util.d.ts.map +1 -0
- package/dist/api/region/util.js +3 -0
- package/dist/api/region/util.js.map +1 -0
- package/dist/api/session/get.d.ts +1 -0
- package/dist/api/session/get.d.ts.map +1 -1
- package/dist/api/session/get.js +3 -1
- package/dist/api/session/get.js.map +1 -1
- package/dist/api/session/list.d.ts +3 -0
- package/dist/api/session/list.d.ts.map +1 -1
- package/dist/api/session/list.js +3 -1
- package/dist/api/session/list.js.map +1 -1
- package/dist/api/session/logs.d.ts.map +1 -1
- package/dist/api/session/logs.js +2 -1
- package/dist/api/session/logs.js.map +1 -1
- package/dist/api/session/util.d.ts +23 -0
- package/dist/api/session/util.d.ts.map +1 -0
- package/dist/api/session/util.js +3 -0
- package/dist/api/session/util.js.map +1 -0
- package/dist/api/thread/delete.d.ts +16 -0
- package/dist/api/thread/delete.d.ts.map +1 -0
- package/dist/api/thread/delete.js +21 -0
- package/dist/api/thread/delete.js.map +1 -0
- package/dist/api/thread/get.d.ts +18 -0
- package/dist/api/thread/get.d.ts.map +1 -0
- package/dist/api/thread/get.js +23 -0
- package/dist/api/thread/get.js.map +1 -0
- package/dist/api/thread/index.d.ts +5 -0
- package/dist/api/thread/index.d.ts.map +1 -0
- package/dist/api/thread/index.js +5 -0
- package/dist/api/thread/index.js.map +1 -0
- package/dist/api/thread/list.d.ts +59 -0
- package/dist/api/thread/list.d.ts.map +1 -0
- package/dist/api/thread/list.js +38 -0
- package/dist/api/thread/list.js.map +1 -0
- package/dist/api/thread/util.d.ts +23 -0
- package/dist/api/thread/util.d.ts.map +1 -0
- package/dist/api/thread/util.js +3 -0
- package/dist/api/thread/util.js.map +1 -0
- package/dist/api/user/util.d.ts +23 -0
- package/dist/api/user/util.d.ts.map +1 -0
- package/dist/api/user/util.js +3 -0
- package/dist/api/user/util.js.map +1 -0
- package/dist/api/user/whoami.d.ts.map +1 -1
- package/dist/api/user/whoami.js +2 -1
- package/dist/api/user/whoami.js.map +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +4 -4
- package/dist/server.js.map +1 -1
- package/package.json +2 -2
- package/src/api/api.ts +127 -78
- package/src/api/apikey/create.ts +2 -1
- package/src/api/apikey/delete.ts +2 -1
- package/src/api/apikey/get.ts +2 -1
- package/src/api/apikey/list.ts +2 -1
- package/src/api/apikey/util.ts +3 -0
- package/src/api/index.ts +1 -0
- package/src/api/org/list.ts +2 -1
- package/src/api/org/util.ts +3 -0
- package/src/api/project/agent.ts +4 -3
- package/src/api/project/create.ts +2 -1
- package/src/api/project/delete.ts +2 -1
- package/src/api/project/deploy.ts +4 -3
- package/src/api/project/deployment.ts +7 -6
- package/src/api/project/env-delete.ts +2 -1
- package/src/api/project/env-update.ts +2 -1
- package/src/api/project/exists.ts +5 -4
- package/src/api/project/get.ts +2 -1
- package/src/api/project/list.ts +2 -1
- package/src/api/project/util.ts +5 -0
- package/src/api/region/create.ts +4 -1
- package/src/api/region/delete.ts +2 -1
- package/src/api/region/list.ts +2 -1
- package/src/api/region/resources.ts +2 -1
- package/src/api/region/util.ts +3 -0
- package/src/api/session/get.ts +4 -1
- package/src/api/session/list.ts +3 -1
- package/src/api/session/logs.ts +2 -1
- package/src/api/session/util.ts +3 -0
- package/src/api/thread/delete.ts +31 -0
- package/src/api/thread/get.ts +36 -0
- package/src/api/thread/index.ts +4 -0
- package/src/api/thread/list.ts +60 -0
- package/src/api/thread/util.ts +3 -0
- package/src/api/user/util.ts +3 -0
- package/src/api/user/whoami.ts +2 -1
- package/src/server.ts +5 -5
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const UserResponseError: {
|
|
2
|
+
new (args?: {
|
|
3
|
+
message?: string;
|
|
4
|
+
cause?: unknown;
|
|
5
|
+
} | undefined): import("@agentuity/core").RichError & {
|
|
6
|
+
readonly _tag: "UserResponseError";
|
|
7
|
+
} & Readonly<Record<string, never>>;
|
|
8
|
+
readonly defaultMessage?: string;
|
|
9
|
+
} & (<Shape extends {
|
|
10
|
+
[x: string]: any;
|
|
11
|
+
} = Record<string, never>>() => {
|
|
12
|
+
new (args?: (Shape extends Record<string, never> ? {
|
|
13
|
+
message?: string;
|
|
14
|
+
cause?: unknown;
|
|
15
|
+
} : Shape & {
|
|
16
|
+
message?: string;
|
|
17
|
+
cause?: unknown;
|
|
18
|
+
}) | undefined): import("@agentuity/core").RichError & {
|
|
19
|
+
readonly _tag: "UserResponseError";
|
|
20
|
+
} & Readonly<Shape>;
|
|
21
|
+
readonly defaultMessage?: string;
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/api/user/util.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;EAAuC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../../src/api/user/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAC,mBAAmB,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whoami.d.ts","sourceRoot":"","sources":["../../../src/api/user/whoami.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAqB,SAAS,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"whoami.d.ts","sourceRoot":"","sources":["../../../src/api/user/whoami.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAqB,SAAS,EAAE,MAAM,QAAQ,CAAC;AAQtD,QAAA,MAAM,cAAc;;;;;;;iBAIlB,CAAC;AACH,QAAA,MAAM,oBAAoB;;;;;;;;;;;;;8BAAoC,CAAC;AAE/D,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAElD;;;;;GAKG;AACH,wBAAsB,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAM7D"}
|
package/dist/api/user/whoami.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { APIResponseSchema } from '../api';
|
|
3
|
+
import { UserResponseError } from './util';
|
|
3
4
|
const OrganizationSchema = z.object({
|
|
4
5
|
id: z.string().describe('the unique id for the organization'),
|
|
5
6
|
name: z.string().describe('the name of the organization'),
|
|
@@ -21,6 +22,6 @@ export async function whoami(client) {
|
|
|
21
22
|
if (resp.success) {
|
|
22
23
|
return resp.data;
|
|
23
24
|
}
|
|
24
|
-
throw new
|
|
25
|
+
throw new UserResponseError({ message: resp.message });
|
|
25
26
|
}
|
|
26
27
|
//# sourceMappingURL=whoami.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../../src/api/user/whoami.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAa,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../../src/api/user/whoami.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAa,MAAM,QAAQ,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAE3C,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oCAAoC,CAAC;IAC7D,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8BAA8B,CAAC;CACzD,CAAC,CAAC;AAEH,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4BAA4B,CAAC;IAC5D,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,2BAA2B,CAAC;IAC1D,aAAa,EAAE,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,QAAQ,CAAC,2CAA2C,CAAC;CAChG,CAAC,CAAC;AACH,MAAM,oBAAoB,GAAG,iBAAiB,CAAC,cAAc,CAAC,CAAC;AAK/D;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,MAAiB;IAC7C,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAiB,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,CAAC,CAAC;IACjG,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IACD,MAAM,IAAI,iBAAiB,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;AACxD,CAAC"}
|
package/dist/server.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ 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
|
-
onAfter?: <T>(url: string, options: FetchRequest, response: FetchResponse<T>, err?: ServiceException) => Promise<void>;
|
|
6
|
+
onAfter?: <T>(url: string, options: FetchRequest, response: FetchResponse<T>, err?: InstanceType<typeof ServiceException>) => Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Redacts the middle of a string while keeping a prefix and suffix visible.
|
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,EAEN,MAAM,iBAAiB,CAAC;AACzB,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AE,MAAU,EAClB,IAAI,GAAE,MAAY,GAChB,MAAM,CAaR;AAgBD,cAAM,kBAAmB,YAAW,YAAY;;gBAInC,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM;YAI1C,OAAO;IA6Df,MAAM,CAAC,CAAC,EACb,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,YAAiC,GACxC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;CAmC5B;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,sBAEpF"}
|
package/dist/server.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toServiceException, fromResponse } from '@agentuity/core';
|
|
1
|
+
import { ServiceException, toServiceException, fromResponse } from '@agentuity/core';
|
|
2
2
|
const sensitiveHeaders = new Set(['authorization', 'x-api-key']);
|
|
3
3
|
/**
|
|
4
4
|
* Redacts the middle of a string while keeping a prefix and suffix visible.
|
|
@@ -115,11 +115,11 @@ class ServerFetchAdapter {
|
|
|
115
115
|
}
|
|
116
116
|
catch (ex) {
|
|
117
117
|
err = ex;
|
|
118
|
-
if (this.#config.onAfter) {
|
|
118
|
+
if (this.#config.onAfter && err instanceof ServiceException) {
|
|
119
119
|
await this.#config.onAfter(url, options, {
|
|
120
120
|
ok: false,
|
|
121
|
-
response: new Response(err.message
|
|
122
|
-
status: err.statusCode
|
|
121
|
+
response: new Response(err.message, {
|
|
122
|
+
status: err.statusCode,
|
|
123
123
|
}),
|
|
124
124
|
}, err);
|
|
125
125
|
}
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAQA,OAAO,
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,YAA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
4
|
"license": "Apache-2.0",
|
|
5
5
|
"author": "Agentuity employees and contributors",
|
|
6
6
|
"type": "module",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"prepublishOnly": "bun run clean && bun run build"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@agentuity/core": "0.0.
|
|
28
|
+
"@agentuity/core": "0.0.62",
|
|
29
29
|
"zod": "^4.1.12"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
package/src/api/api.ts
CHANGED
|
@@ -10,17 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
import { z } from 'zod';
|
|
12
12
|
import type { Logger } from '@agentuity/core';
|
|
13
|
-
|
|
14
|
-
export interface APIErrorResponse {
|
|
15
|
-
success: boolean;
|
|
16
|
-
code?: string;
|
|
17
|
-
message?: string;
|
|
18
|
-
error?: {
|
|
19
|
-
name?: string;
|
|
20
|
-
issues?: z.ZodIssue[];
|
|
21
|
-
};
|
|
22
|
-
details?: Record<string, unknown>;
|
|
23
|
-
}
|
|
13
|
+
import { StructuredError } from '@agentuity/core';
|
|
24
14
|
|
|
25
15
|
export interface APIClientConfig {
|
|
26
16
|
skipVersionCheck?: boolean;
|
|
@@ -29,36 +19,75 @@ export interface APIClientConfig {
|
|
|
29
19
|
retryDelayMs?: number;
|
|
30
20
|
}
|
|
31
21
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
22
|
+
const ZodIssuesSchema = z.array(
|
|
23
|
+
z.object({
|
|
24
|
+
code: z.string(),
|
|
25
|
+
input: z.unknown().optional(),
|
|
26
|
+
path: z.array(z.union([z.string(), z.number()])),
|
|
27
|
+
message: z.string(),
|
|
28
|
+
})
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
export type IssuesType = z.infer<typeof ZodIssuesSchema>;
|
|
32
|
+
|
|
33
|
+
const toIssues = (issues: z.core.$ZodIssue[]): IssuesType => {
|
|
34
|
+
return issues.map((issue) => ({
|
|
35
|
+
code: issue.code,
|
|
36
|
+
input: issue.input,
|
|
37
|
+
path: issue.path.map((x) => (typeof x === 'number' ? x : String(x))),
|
|
38
|
+
message: issue.message,
|
|
39
|
+
}));
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const APIErrorSchema = z.object({
|
|
43
|
+
success: z.boolean(),
|
|
44
|
+
code: z.string().optional(),
|
|
45
|
+
message: z.string().optional(),
|
|
46
|
+
error: z.object({
|
|
47
|
+
name: z.string().optional(),
|
|
48
|
+
issues: ZodIssuesSchema.optional(),
|
|
49
|
+
}),
|
|
50
|
+
details: z.record(z.string(), z.unknown()).optional(),
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export const APIError = StructuredError(
|
|
54
|
+
'APIErrorResponse',
|
|
55
|
+
'The API encountered an unexpected error attempting to reach the service.'
|
|
56
|
+
)<{
|
|
57
|
+
url: string;
|
|
58
|
+
error?: string;
|
|
59
|
+
status: number;
|
|
60
|
+
sessionId?: string | null;
|
|
61
|
+
}>();
|
|
62
|
+
|
|
63
|
+
export const ValidationInputError = StructuredError(
|
|
64
|
+
'ValidationInputError',
|
|
65
|
+
'There was an error validating the API input data.'
|
|
66
|
+
)<{
|
|
67
|
+
url: string;
|
|
68
|
+
issues: IssuesType;
|
|
69
|
+
}>();
|
|
70
|
+
|
|
71
|
+
export const ValidationOutputError = StructuredError(
|
|
72
|
+
'ValidationOutputError',
|
|
73
|
+
'There was an unexpected error validating the API response data.'
|
|
74
|
+
)<{
|
|
75
|
+
url: string;
|
|
76
|
+
issues: IssuesType;
|
|
77
|
+
sessionId?: string | null;
|
|
78
|
+
}>();
|
|
79
|
+
|
|
80
|
+
export const UpgradeRequiredError = StructuredError(
|
|
81
|
+
'UpgradeRequiredError',
|
|
82
|
+
'Upgrade required to continue. Please see https://agentuity.dev/CLI/installation to download the latest version of the SDK.'
|
|
83
|
+
)<{
|
|
84
|
+
sessionId?: string | null;
|
|
85
|
+
}>();
|
|
86
|
+
|
|
87
|
+
export const MaxRetriesError = StructuredError(
|
|
88
|
+
'MaxRetriesError',
|
|
89
|
+
'Max Retries attempted and continued failures exhausted.'
|
|
90
|
+
);
|
|
62
91
|
|
|
63
92
|
export class APIClient {
|
|
64
93
|
#baseUrl: string;
|
|
@@ -101,11 +130,10 @@ export class APIClient {
|
|
|
101
130
|
if (body !== undefined && bodySchema) {
|
|
102
131
|
const validationResult = bodySchema.safeParse(body);
|
|
103
132
|
if (!validationResult.success) {
|
|
104
|
-
throw new
|
|
105
|
-
endpoint,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
);
|
|
133
|
+
throw new ValidationInputError({
|
|
134
|
+
url: endpoint,
|
|
135
|
+
issues: toIssues(validationResult.error.issues),
|
|
136
|
+
});
|
|
109
137
|
}
|
|
110
138
|
}
|
|
111
139
|
|
|
@@ -133,11 +161,11 @@ export class APIClient {
|
|
|
133
161
|
// Validate response
|
|
134
162
|
const validationResult = responseSchema.safeParse(data);
|
|
135
163
|
if (!validationResult.success) {
|
|
136
|
-
throw new
|
|
137
|
-
endpoint,
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
);
|
|
164
|
+
throw new ValidationOutputError({
|
|
165
|
+
url: endpoint,
|
|
166
|
+
issues: toIssues(validationResult.error.issues),
|
|
167
|
+
sessionId: response.headers.get('x-session-id'),
|
|
168
|
+
});
|
|
141
169
|
}
|
|
142
170
|
|
|
143
171
|
return validationResult.data;
|
|
@@ -167,17 +195,35 @@ export class APIClient {
|
|
|
167
195
|
headers['Authorization'] = `Bearer ${this.#apiKey}`;
|
|
168
196
|
}
|
|
169
197
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
198
|
+
let response: Response;
|
|
199
|
+
|
|
200
|
+
try {
|
|
201
|
+
response = await fetch(url, {
|
|
202
|
+
method,
|
|
203
|
+
headers,
|
|
204
|
+
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
205
|
+
});
|
|
206
|
+
} catch (ex) {
|
|
207
|
+
const _ex = ex as { code?: string; name: string };
|
|
208
|
+
let retryable = false;
|
|
209
|
+
// Check for retryable network errors
|
|
210
|
+
if (_ex.code === 'ConnectionRefused' || _ex.code === 'ECONNREFUSED') {
|
|
211
|
+
retryable = true;
|
|
212
|
+
} else if (_ex.name === 'TypeError' || ex instanceof TypeError) {
|
|
213
|
+
// TypeError from fetch typically indicates network issues
|
|
214
|
+
retryable = true;
|
|
215
|
+
}
|
|
216
|
+
if (retryable) {
|
|
217
|
+
response = new Response(null, { status: 503 });
|
|
218
|
+
} else {
|
|
219
|
+
throw new APIError({
|
|
220
|
+
url,
|
|
221
|
+
status: 0,
|
|
222
|
+
cause: ex,
|
|
223
|
+
});
|
|
224
|
+
}
|
|
173
225
|
}
|
|
174
226
|
|
|
175
|
-
const response = await fetch(url, {
|
|
176
|
-
method,
|
|
177
|
-
headers,
|
|
178
|
-
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
179
|
-
});
|
|
180
|
-
|
|
181
227
|
// Check if we should retry on specific status codes (409, 501, 503)
|
|
182
228
|
const retryableStatuses = [409, 501, 503];
|
|
183
229
|
if (retryableStatuses.includes(response.status) && attempt < maxRetries) {
|
|
@@ -206,16 +252,18 @@ export class APIClient {
|
|
|
206
252
|
continue;
|
|
207
253
|
}
|
|
208
254
|
|
|
255
|
+
const sessionId = response.headers.get('x-session-id');
|
|
256
|
+
|
|
209
257
|
// Handle error responses
|
|
210
258
|
if (!response.ok) {
|
|
211
259
|
const responseBody = await response.text();
|
|
212
260
|
|
|
213
|
-
|
|
214
|
-
|
|
261
|
+
let errorData: z.infer<typeof APIErrorSchema> | undefined;
|
|
262
|
+
|
|
215
263
|
try {
|
|
216
|
-
errorData =
|
|
264
|
+
errorData = APIErrorSchema.parse(responseBody);
|
|
217
265
|
} catch {
|
|
218
|
-
|
|
266
|
+
/** ignore */
|
|
219
267
|
}
|
|
220
268
|
|
|
221
269
|
// Sanitize headers to avoid leaking API keys
|
|
@@ -240,31 +288,32 @@ export class APIClient {
|
|
|
240
288
|
this.#logger.debug('Skipping version check (configured to skip)');
|
|
241
289
|
// Request is still rejected, but throw UpgradeRequiredError so callers
|
|
242
290
|
// can detect it and handle UI behavior (e.g., suppress banner) based on skip flag
|
|
243
|
-
throw new UpgradeRequiredError(
|
|
244
|
-
errorData.message ||
|
|
245
|
-
'Version check skipped, but request failed. Try upgrading the client.'
|
|
246
|
-
);
|
|
291
|
+
throw new UpgradeRequiredError({ sessionId });
|
|
247
292
|
}
|
|
248
293
|
|
|
249
|
-
throw new UpgradeRequiredError(
|
|
250
|
-
errorData.message || 'Please upgrade to the latest version'
|
|
251
|
-
);
|
|
294
|
+
throw new UpgradeRequiredError({ sessionId });
|
|
252
295
|
}
|
|
253
296
|
|
|
254
297
|
// Handle Zod validation errors from the API
|
|
255
298
|
if (errorData?.error?.name === 'ZodError' && errorData.error.issues) {
|
|
256
|
-
throw new
|
|
299
|
+
throw new ValidationOutputError({
|
|
300
|
+
url,
|
|
301
|
+
issues: errorData.error.issues,
|
|
302
|
+
sessionId,
|
|
303
|
+
});
|
|
257
304
|
}
|
|
258
305
|
|
|
259
306
|
// Throw with message from API if available
|
|
260
307
|
if (errorData?.message) {
|
|
261
|
-
throw new APIError(
|
|
308
|
+
throw new APIError({
|
|
309
|
+
url,
|
|
310
|
+
status: response.status,
|
|
311
|
+
error: errorData.message,
|
|
312
|
+
sessionId,
|
|
313
|
+
});
|
|
262
314
|
}
|
|
263
315
|
|
|
264
|
-
throw new APIError(
|
|
265
|
-
`API error: ${response.status} ${response.statusText}`,
|
|
266
|
-
response.status
|
|
267
|
-
);
|
|
316
|
+
throw new APIError({ url: url, status: response.status, sessionId });
|
|
268
317
|
}
|
|
269
318
|
|
|
270
319
|
// Successful response; handle empty bodies (e.g., 204 No Content)
|
|
@@ -290,7 +339,7 @@ export class APIClient {
|
|
|
290
339
|
}
|
|
291
340
|
}
|
|
292
341
|
|
|
293
|
-
throw new
|
|
342
|
+
throw new MaxRetriesError();
|
|
294
343
|
}
|
|
295
344
|
|
|
296
345
|
#isRetryableError(error: unknown): boolean {
|
package/src/api/apikey/create.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { APIClient, APIResponseSchema } from '../api';
|
|
3
|
+
import { APIKeyResponseError } from './util';
|
|
3
4
|
|
|
4
5
|
const APIKeyCreateResponseSchema = z.object({
|
|
5
6
|
id: z.string().describe('the API key id'),
|
|
@@ -41,5 +42,5 @@ export async function apikeyCreate(
|
|
|
41
42
|
return resp.data;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
throw new
|
|
45
|
+
throw new APIKeyResponseError({ message: resp.message });
|
|
45
46
|
}
|
package/src/api/apikey/delete.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { APIClient, APIResponseSchema } from '../api';
|
|
3
|
+
import { APIKeyResponseError } from './util';
|
|
3
4
|
|
|
4
5
|
const APIKeyDeleteResponseSchema = APIResponseSchema(
|
|
5
6
|
z.number().describe('number of rows affected')
|
|
@@ -25,5 +26,5 @@ export async function apikeyDelete(client: APIClient, id: string): Promise<numbe
|
|
|
25
26
|
return resp.data;
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
throw new
|
|
29
|
+
throw new APIKeyResponseError({ message: resp.message });
|
|
29
30
|
}
|
package/src/api/apikey/get.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { APIClient, APIResponseSchema } from '../api';
|
|
3
|
+
import { APIKeyResponseError } from './util';
|
|
3
4
|
|
|
4
5
|
const APIKeyDetailSchema = z.object({
|
|
5
6
|
id: z.string().describe('the API key id'),
|
|
@@ -43,5 +44,5 @@ export async function apikeyGet(client: APIClient, id: string): Promise<APIKeyDe
|
|
|
43
44
|
return resp.data;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
throw new
|
|
47
|
+
throw new APIKeyResponseError({ message: resp.message });
|
|
47
48
|
}
|
package/src/api/apikey/list.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { APIClient, APIResponseSchema } from '../api';
|
|
3
|
+
import { APIKeyResponseError } from './util';
|
|
3
4
|
|
|
4
5
|
export const APIKeySchema = z.object({
|
|
5
6
|
id: z.string().describe('the API key id'),
|
|
@@ -59,5 +60,5 @@ export async function apikeyList(
|
|
|
59
60
|
return resp.data;
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
throw new
|
|
63
|
+
throw new APIKeyResponseError({ message: resp.message });
|
|
63
64
|
}
|
package/src/api/index.ts
CHANGED
package/src/api/org/list.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { APIResponseSchema, APIClient } from '../api';
|
|
3
|
+
import { OrgResponseError } from './util';
|
|
3
4
|
|
|
4
5
|
const ListOrganizationsResponse = z.array(
|
|
5
6
|
z.object({
|
|
@@ -27,5 +28,5 @@ export async function listOrganizations(client: APIClient): Promise<Organization
|
|
|
27
28
|
if (resp.success) {
|
|
28
29
|
return resp.data;
|
|
29
30
|
}
|
|
30
|
-
throw new
|
|
31
|
+
throw new OrgResponseError({ message: resp.message });
|
|
31
32
|
}
|
package/src/api/project/agent.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import type { APIClient } from '../api';
|
|
3
3
|
import { APIResponseSchema } from '../api';
|
|
4
|
+
import { AgentNotFoundError, ProjectResponseError } from './util';
|
|
4
5
|
|
|
5
6
|
const AgentSchema = z.object({
|
|
6
7
|
id: z.string().describe('Agent ID (same as identifier)'),
|
|
@@ -54,7 +55,7 @@ export async function projectAgentList(
|
|
|
54
55
|
if (resp.success) {
|
|
55
56
|
return resp.data;
|
|
56
57
|
}
|
|
57
|
-
throw new
|
|
58
|
+
throw new ProjectResponseError({ message: resp.message });
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
/**
|
|
@@ -73,9 +74,9 @@ export async function projectAgentGet(
|
|
|
73
74
|
|
|
74
75
|
if (resp.success) {
|
|
75
76
|
if (resp.data.length === 0) {
|
|
76
|
-
throw new
|
|
77
|
+
throw new AgentNotFoundError({ id: agentId, message: `Agent not found: ${agentId}` });
|
|
77
78
|
}
|
|
78
79
|
return resp.data[0];
|
|
79
80
|
}
|
|
80
|
-
throw new
|
|
81
|
+
throw new ProjectResponseError({ message: resp.message });
|
|
81
82
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { APIClient, APIResponseSchema } from '../api';
|
|
3
|
+
import { ProjectResponseError } from './util';
|
|
3
4
|
|
|
4
5
|
const CreateProjectRequestSchema = z.object({
|
|
5
6
|
name: z.string().max(255).min(1).describe('the name of the new project'),
|
|
@@ -39,5 +40,5 @@ export async function projectCreate(
|
|
|
39
40
|
if (resp.success) {
|
|
40
41
|
return resp.data;
|
|
41
42
|
}
|
|
42
|
-
throw new
|
|
43
|
+
throw new ProjectResponseError({ message: resp.message });
|
|
43
44
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { APIClient, APIResponseSchema } from '../api';
|
|
3
|
+
import { ProjectResponseError } from './util';
|
|
3
4
|
|
|
4
5
|
const ProjectDeleteRequestSchema = z.object({ ids: z.array(z.string()) });
|
|
5
6
|
const ProjectDeleteResponseSchema = APIResponseSchema(z.array(z.string()));
|
|
@@ -20,5 +21,5 @@ export async function projectDelete(client: APIClient, ...ids: string[]): Promis
|
|
|
20
21
|
return resp.data;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
throw new
|
|
24
|
+
throw new ProjectResponseError({ message: resp.message ?? 'failed to delete project' });
|
|
24
25
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { type APIClient, APIResponseSchema } from '../api';
|
|
3
|
+
import { ProjectResponseError } from './util';
|
|
3
4
|
|
|
4
5
|
export const Resources = z.object({
|
|
5
6
|
memory: z.string().default('500Mi').describe('The memory requirements'),
|
|
@@ -177,7 +178,7 @@ export async function projectDeploymentCreate(
|
|
|
177
178
|
if (resp.success) {
|
|
178
179
|
return resp.data;
|
|
179
180
|
}
|
|
180
|
-
throw new
|
|
181
|
+
throw new ProjectResponseError({ message: resp.message });
|
|
181
182
|
}
|
|
182
183
|
|
|
183
184
|
const DeploymentInstructionsObject = z.object({
|
|
@@ -217,7 +218,7 @@ export async function projectDeploymentUpdate(
|
|
|
217
218
|
if (resp.success) {
|
|
218
219
|
return resp.data;
|
|
219
220
|
}
|
|
220
|
-
throw new
|
|
221
|
+
throw new ProjectResponseError({ message: resp.message });
|
|
221
222
|
}
|
|
222
223
|
|
|
223
224
|
const DeploymentCompleteObject = z.object({
|
|
@@ -254,5 +255,5 @@ export async function projectDeploymentComplete(
|
|
|
254
255
|
if (resp.success) {
|
|
255
256
|
return resp.data;
|
|
256
257
|
}
|
|
257
|
-
throw new
|
|
258
|
+
throw new ProjectResponseError({ message: resp.message });
|
|
258
259
|
}
|