@aexhq/sdk 0.55.0 → 0.55.1
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/index.js +1 -1
- package/dist/session.js +6 -6
- package/dist/transport.js +5 -5
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ export class Aex {
|
|
|
7
7
|
sessions;
|
|
8
8
|
constructor(options) {
|
|
9
9
|
if (options.apiKey.trim() === "")
|
|
10
|
-
throw new TypeError("
|
|
10
|
+
throw new TypeError("Aex apiKey cannot be empty");
|
|
11
11
|
const fetchImplementation = options.fetch ?? globalThis.fetch?.bind(globalThis);
|
|
12
12
|
if (fetchImplementation === undefined) {
|
|
13
13
|
throw new TypeError("This runtime does not provide fetch; pass a fetch implementation to Aex");
|
package/dist/session.js
CHANGED
|
@@ -120,7 +120,7 @@ export class Session {
|
|
|
120
120
|
throw abortError(error);
|
|
121
121
|
throw error;
|
|
122
122
|
}
|
|
123
|
-
throw new SessionError("The
|
|
123
|
+
throw new SessionError("The Aex event stream ended before the session finished its work");
|
|
124
124
|
}
|
|
125
125
|
async output(schema, input, options = {}) {
|
|
126
126
|
let jsonSchema;
|
|
@@ -153,20 +153,20 @@ export class Session {
|
|
|
153
153
|
retry: true,
|
|
154
154
|
});
|
|
155
155
|
if (accepted.session_id !== this.id || accepted.schema_hash !== schemaHash) {
|
|
156
|
-
throw new SessionError("
|
|
156
|
+
throw new SessionError("Aex returned an inconsistent output admission");
|
|
157
157
|
}
|
|
158
158
|
try {
|
|
159
159
|
for await (const event of this.events({ after: Math.max(0, accepted.seq - 1), signal: options.signal })) {
|
|
160
160
|
if (event.type === "output.failed" && event.output_id === accepted.output_id) {
|
|
161
161
|
if (event.schema_hash !== schemaHash) {
|
|
162
|
-
throw new SessionError("
|
|
162
|
+
throw new SessionError("Aex returned an output failure for a different schema");
|
|
163
163
|
}
|
|
164
164
|
this.markIdle();
|
|
165
165
|
throw outputEventError(event.error, event.issues);
|
|
166
166
|
}
|
|
167
167
|
if (event.type === "output.completed" && event.output_id === accepted.output_id) {
|
|
168
168
|
if (event.output.schema_hash !== schemaHash) {
|
|
169
|
-
throw new SessionError("
|
|
169
|
+
throw new SessionError("Aex returned an output value for a different schema");
|
|
170
170
|
}
|
|
171
171
|
this.markIdle();
|
|
172
172
|
const parsed = await schema.safeParseAsync(event.output.value);
|
|
@@ -188,7 +188,7 @@ export class Session {
|
|
|
188
188
|
}
|
|
189
189
|
throw error;
|
|
190
190
|
}
|
|
191
|
-
throw new SessionError("The
|
|
191
|
+
throw new SessionError("The Aex event stream ended before the typed output completed");
|
|
192
192
|
}
|
|
193
193
|
events(options = {}) {
|
|
194
194
|
return this.#transport.events(this.id, options);
|
|
@@ -238,7 +238,7 @@ function assertPortableOutputSchema(schema) {
|
|
|
238
238
|
definition.type === "file" ||
|
|
239
239
|
definition.check === "overwrite";
|
|
240
240
|
if (unsupported) {
|
|
241
|
-
throw new OutputSchemaError(`This Zod schema contains ${String(definition.type ?? definition.check)} behavior that cannot be enforced by the
|
|
241
|
+
throw new OutputSchemaError(`This Zod schema contains ${String(definition.type ?? definition.check)} behavior that cannot be enforced by the Aex output service`);
|
|
242
242
|
}
|
|
243
243
|
visit(definition);
|
|
244
244
|
return;
|
package/dist/transport.js
CHANGED
|
@@ -41,7 +41,7 @@ export class Transport {
|
|
|
41
41
|
lastError = error;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
throw new SessionError("Could not reach the
|
|
44
|
+
throw new SessionError("Could not reach the Aex API", { cause: lastError });
|
|
45
45
|
}
|
|
46
46
|
async *events(sessionId, options = {}) {
|
|
47
47
|
let cursor = options.after ?? 0;
|
|
@@ -62,7 +62,7 @@ export class Transport {
|
|
|
62
62
|
if (!response.ok)
|
|
63
63
|
throw await this.responseError(response);
|
|
64
64
|
if (response.body === null)
|
|
65
|
-
throw new SessionError("The
|
|
65
|
+
throw new SessionError("The Aex event stream had no body");
|
|
66
66
|
let received = false;
|
|
67
67
|
for await (const event of parseEventStream(response.body)) {
|
|
68
68
|
if (event.seq <= cursor)
|
|
@@ -86,7 +86,7 @@ export class Transport {
|
|
|
86
86
|
if (consecutiveFailures > 5) {
|
|
87
87
|
if (error instanceof AexError)
|
|
88
88
|
throw error;
|
|
89
|
-
throw new SessionError("The
|
|
89
|
+
throw new SessionError("The Aex event stream disconnected", { cause: error });
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
await delay(Math.min(2_000, 100 * 2 ** (consecutiveFailures - 1)), options.signal);
|
|
@@ -102,7 +102,7 @@ export class Transport {
|
|
|
102
102
|
}
|
|
103
103
|
if (envelope?.error !== undefined)
|
|
104
104
|
return errorFromApi(envelope.error, response.status);
|
|
105
|
-
return new SessionError(`
|
|
105
|
+
return new SessionError(`Aex API request failed with HTTP ${response.status}`, {
|
|
106
106
|
status: response.status,
|
|
107
107
|
requestId: response.headers.get("x-request-id") ?? undefined,
|
|
108
108
|
});
|
|
@@ -124,7 +124,7 @@ async function* parseEventStream(stream) {
|
|
|
124
124
|
return JSON.parse(data);
|
|
125
125
|
}
|
|
126
126
|
catch (cause) {
|
|
127
|
-
throw new SessionError("
|
|
127
|
+
throw new SessionError("Aex sent an invalid event", { cause });
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
130
|
const line = (raw) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aexhq/sdk",
|
|
3
|
-
"version": "0.55.
|
|
4
|
-
"description": "TypeScript SDK for
|
|
3
|
+
"version": "0.55.1",
|
|
4
|
+
"description": "TypeScript SDK for Aex sessions",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://aex.dev",
|
|
7
7
|
"repository": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"test": "tsc -p tsconfig.json && node --test"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@aexhq/contracts": "0.26.
|
|
36
|
+
"@aexhq/contracts": "0.26.1"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"zod": "^4.0.0"
|