@aui.io/aui-client 3.1.0 → 3.1.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/README.md +17 -4
- package/dist/cjs/ApolloClientWrapper.js +11 -1
- package/dist/cjs/Client.js +2 -2
- package/dist/cjs/api/resources/session/client/Socket.d.ts +4 -6
- package/dist/cjs/api/resources/session/client/Socket.js +2 -10
- package/dist/cjs/exports.d.ts +1 -0
- package/dist/cjs/exports.js +5 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/ApolloClientWrapper.mjs +11 -1
- package/dist/esm/Client.mjs +2 -2
- package/dist/esm/api/resources/session/client/Socket.d.mts +4 -6
- package/dist/esm/api/resources/session/client/Socket.mjs +2 -10
- package/dist/esm/exports.d.mts +1 -0
- package/dist/esm/exports.mjs +3 -0
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -80,7 +80,6 @@ import { ApolloEnvironment } from '@aui.io/aui-client';
|
|
|
80
80
|
ApolloEnvironment.Gcp = {
|
|
81
81
|
base: 'https://api-v3.aui.io/apollo-api-v2', // REST
|
|
82
82
|
production: 'wss://api-v3.aui.io/apollo-api-v2', // WebSocket
|
|
83
|
-
local: 'ws://localhost:8000', // WebSocket (local)
|
|
84
83
|
};
|
|
85
84
|
```
|
|
86
85
|
|
|
@@ -145,8 +144,9 @@ socket.on('message', (msg) => {
|
|
|
145
144
|
socket.on('error', (err) => console.error('WS error:', err));
|
|
146
145
|
socket.on('close', (event) => console.log('Closed:', event.code));
|
|
147
146
|
|
|
148
|
-
// Send a turn
|
|
147
|
+
// Send a turn (type is required on the WS submit frame)
|
|
149
148
|
socket.sendSubmitMessage({
|
|
149
|
+
type: 'message',
|
|
150
150
|
agent_id: agentId,
|
|
151
151
|
user_id: 'end-user-123',
|
|
152
152
|
text: 'Hello over WebSocket',
|
|
@@ -156,6 +156,14 @@ socket.sendSubmitMessage({
|
|
|
156
156
|
socket.close();
|
|
157
157
|
```
|
|
158
158
|
|
|
159
|
+
> **Notes**
|
|
160
|
+
> - `socket.on(event, handler)` registers a **single** handler per event — calling it
|
|
161
|
+
> again for the same event replaces the previous handler rather than adding one.
|
|
162
|
+
> - The socket type is exported as `SessionSocket` (`import { SessionSocket } from '@aui.io/aui-client'`).
|
|
163
|
+
> - Request timeouts are **per call** via `timeoutInSeconds` on a request's options; there
|
|
164
|
+
> is no client-wide default timeout. Pass it on slow calls, e.g.
|
|
165
|
+
> `client.threads.listThreads({ filters: {} }, { timeoutInSeconds: 120 })`.
|
|
166
|
+
|
|
159
167
|
## Key Context Helpers
|
|
160
168
|
|
|
161
169
|
After the first request (or an explicit `getContext()`), scope resolved from the key is available:
|
|
@@ -172,13 +180,17 @@ client.organizationId;
|
|
|
172
180
|
|
|
173
181
|
## Error Handling
|
|
174
182
|
|
|
183
|
+
`ApolloError` (the base API error) and `ApolloTimeoutError` are exported at the top
|
|
184
|
+
level. The per-status errors (e.g. `UnprocessableEntityError`) live under the `Apollo`
|
|
185
|
+
namespace.
|
|
186
|
+
|
|
175
187
|
```typescript
|
|
176
|
-
import { ApolloError,
|
|
188
|
+
import { ApolloError, Apollo } from '@aui.io/aui-client';
|
|
177
189
|
|
|
178
190
|
try {
|
|
179
191
|
await client.agents.getAgent('missing-id');
|
|
180
192
|
} catch (error) {
|
|
181
|
-
if (error instanceof UnprocessableEntityError) {
|
|
193
|
+
if (error instanceof Apollo.UnprocessableEntityError) {
|
|
182
194
|
console.error('Validation failed:', error.body);
|
|
183
195
|
} else if (error instanceof ApolloError) {
|
|
184
196
|
console.error('API error:', error.statusCode, error.body);
|
|
@@ -196,6 +208,7 @@ The SDK ships full type definitions. Models are namespaced under `Apollo`:
|
|
|
196
208
|
import { ApolloClient, Apollo } from '@aui.io/aui-client';
|
|
197
209
|
|
|
198
210
|
const req: Apollo.SubmitMessageRequest = {
|
|
211
|
+
type: 'message',
|
|
199
212
|
agent_id: 'agent-123',
|
|
200
213
|
user_id: 'end-user-123',
|
|
201
214
|
text: 'Typed request',
|
|
@@ -58,6 +58,16 @@ const SESSION_WS_PATH = "/messaging/v1/session";
|
|
|
58
58
|
// The v2 messaging server negotiates this subprotocol on the WS upgrade; the
|
|
59
59
|
// connection is rejected without it. Fern emits protocols: [], so we set it here.
|
|
60
60
|
const WS_SUBPROTOCOL = "aui-websocket";
|
|
61
|
+
// Fern injects SDK-telemetry headers (X-Fern-*) on every request. The API doesn't need
|
|
62
|
+
// them, and in the browser each custom header triggers a CORS preflight that fails unless
|
|
63
|
+
// the gateway allow-lists it. Passing null strips them (mergeHeaders deletes null values).
|
|
64
|
+
const STRIPPED_SDK_HEADERS = {
|
|
65
|
+
"X-Fern-Language": null,
|
|
66
|
+
"X-Fern-SDK-Name": null,
|
|
67
|
+
"X-Fern-SDK-Version": null,
|
|
68
|
+
"X-Fern-Runtime": null,
|
|
69
|
+
"X-Fern-Runtime-Version": null,
|
|
70
|
+
};
|
|
61
71
|
// Publishable-key exchange + token caching. Kept as a standalone object so the header
|
|
62
72
|
// suppliers can close over it — a subclass may not touch `this` before super() runs.
|
|
63
73
|
class Auth {
|
|
@@ -144,7 +154,7 @@ class ApolloClient extends Client_js_1.ApolloClient {
|
|
|
144
154
|
const auth = new Auth(env.base, options.publishableKey, options.organizationApiKey);
|
|
145
155
|
super({
|
|
146
156
|
environment: env,
|
|
147
|
-
headers: Object.assign({}, (auth.hasCredential ? { Authorization: () => __awaiter(this, void 0, void 0, function* () { return `Bearer ${yield auth.getToken()}`; }) } : {})),
|
|
157
|
+
headers: Object.assign(Object.assign({}, STRIPPED_SDK_HEADERS), (auth.hasCredential ? { Authorization: () => __awaiter(this, void 0, void 0, function* () { return `Bearer ${yield auth.getToken()}`; }) } : {})),
|
|
148
158
|
});
|
|
149
159
|
this._tokenAuth = auth;
|
|
150
160
|
this._env = env;
|
package/dist/cjs/Client.js
CHANGED
|
@@ -61,8 +61,8 @@ class ApolloClient {
|
|
|
61
61
|
this._options = Object.assign(Object.assign({}, _options), { logging: core.logging.createLogger(_options === null || _options === void 0 ? void 0 : _options.logging), headers: (0, headers_js_1.mergeHeaders)({
|
|
62
62
|
"X-Fern-Language": "JavaScript",
|
|
63
63
|
"X-Fern-SDK-Name": "@aui.io/aui-client",
|
|
64
|
-
"X-Fern-SDK-Version": "3.1.
|
|
65
|
-
"User-Agent": "@aui.io/aui-client/3.1.
|
|
64
|
+
"X-Fern-SDK-Version": "3.1.1",
|
|
65
|
+
"User-Agent": "@aui.io/aui-client/3.1.1",
|
|
66
66
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
67
67
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
68
68
|
}, _options === null || _options === void 0 ? void 0 : _options.headers) });
|
|
@@ -4,7 +4,7 @@ export declare namespace SessionSocket {
|
|
|
4
4
|
interface Args {
|
|
5
5
|
socket: core.ReconnectingWebSocket;
|
|
6
6
|
}
|
|
7
|
-
type Response = Apollo.
|
|
7
|
+
type Response = Apollo.ThreadEnvelope | Apollo.MessageEnvelope | Apollo.EventEnvelope | Apollo.ErrorEnvelope;
|
|
8
8
|
type EventHandlers = {
|
|
9
9
|
open?: () => void;
|
|
10
10
|
message?: (message: Response) => void;
|
|
@@ -33,10 +33,8 @@ export declare class SessionSocket {
|
|
|
33
33
|
* ```
|
|
34
34
|
*/
|
|
35
35
|
on<T extends keyof SessionSocket.EventHandlers>(event: T, callback: SessionSocket.EventHandlers[T]): void;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
sendForwardedEvent(message: Apollo.EventEnvelope): void;
|
|
39
|
-
sendErrorFrame(message: Apollo.ErrorEnvelope): void;
|
|
36
|
+
sendSubmitMessage(message: Apollo.SubmitMessageRequest): void;
|
|
37
|
+
sendResume(message: Apollo.ResumeRequest): void;
|
|
40
38
|
/** Connect to the websocket and register event handlers. */
|
|
41
39
|
connect(): SessionSocket;
|
|
42
40
|
/** Close the websocket and unregister event handlers. */
|
|
@@ -48,5 +46,5 @@ export declare class SessionSocket {
|
|
|
48
46
|
/** Send a binary payload to the websocket. */
|
|
49
47
|
protected sendBinary(payload: ArrayBufferLike | Blob | ArrayBufferView): void;
|
|
50
48
|
/** Send a JSON payload to the websocket. */
|
|
51
|
-
protected sendJson(payload: Apollo.
|
|
49
|
+
protected sendJson(payload: Apollo.SubmitMessageRequest | Apollo.ResumeRequest): void;
|
|
52
50
|
}
|
|
@@ -90,19 +90,11 @@ class SessionSocket {
|
|
|
90
90
|
on(event, callback) {
|
|
91
91
|
this.eventHandlers[event] = callback;
|
|
92
92
|
}
|
|
93
|
-
|
|
93
|
+
sendSubmitMessage(message) {
|
|
94
94
|
this.assertSocketIsOpen();
|
|
95
95
|
this.sendJson(message);
|
|
96
96
|
}
|
|
97
|
-
|
|
98
|
-
this.assertSocketIsOpen();
|
|
99
|
-
this.sendJson(message);
|
|
100
|
-
}
|
|
101
|
-
sendForwardedEvent(message) {
|
|
102
|
-
this.assertSocketIsOpen();
|
|
103
|
-
this.sendJson(message);
|
|
104
|
-
}
|
|
105
|
-
sendErrorFrame(message) {
|
|
97
|
+
sendResume(message) {
|
|
106
98
|
this.assertSocketIsOpen();
|
|
107
99
|
this.sendJson(message);
|
|
108
100
|
}
|
package/dist/cjs/exports.d.ts
CHANGED
package/dist/cjs/exports.js
CHANGED
|
@@ -21,4 +21,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
21
21
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
22
22
|
};
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.SessionSocket = void 0;
|
|
24
25
|
__exportStar(require("./core/exports.js"), exports);
|
|
26
|
+
// The generated session resource doesn't re-export its socket class, so consumers
|
|
27
|
+
// couldn't name the type returned by `client.connect()`. Surface it at the package root.
|
|
28
|
+
var Socket_js_1 = require("./api/resources/session/client/Socket.js");
|
|
29
|
+
Object.defineProperty(exports, "SessionSocket", { enumerable: true, get: function () { return Socket_js_1.SessionSocket; } });
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "3.1.
|
|
1
|
+
export declare const SDK_VERSION = "3.1.1";
|
package/dist/cjs/version.js
CHANGED
|
@@ -22,6 +22,16 @@ const SESSION_WS_PATH = "/messaging/v1/session";
|
|
|
22
22
|
// The v2 messaging server negotiates this subprotocol on the WS upgrade; the
|
|
23
23
|
// connection is rejected without it. Fern emits protocols: [], so we set it here.
|
|
24
24
|
const WS_SUBPROTOCOL = "aui-websocket";
|
|
25
|
+
// Fern injects SDK-telemetry headers (X-Fern-*) on every request. The API doesn't need
|
|
26
|
+
// them, and in the browser each custom header triggers a CORS preflight that fails unless
|
|
27
|
+
// the gateway allow-lists it. Passing null strips them (mergeHeaders deletes null values).
|
|
28
|
+
const STRIPPED_SDK_HEADERS = {
|
|
29
|
+
"X-Fern-Language": null,
|
|
30
|
+
"X-Fern-SDK-Name": null,
|
|
31
|
+
"X-Fern-SDK-Version": null,
|
|
32
|
+
"X-Fern-Runtime": null,
|
|
33
|
+
"X-Fern-Runtime-Version": null,
|
|
34
|
+
};
|
|
25
35
|
// Publishable-key exchange + token caching. Kept as a standalone object so the header
|
|
26
36
|
// suppliers can close over it — a subclass may not touch `this` before super() runs.
|
|
27
37
|
class Auth {
|
|
@@ -108,7 +118,7 @@ export class ApolloClient extends _GeneratedClient {
|
|
|
108
118
|
const auth = new Auth(env.base, options.publishableKey, options.organizationApiKey);
|
|
109
119
|
super({
|
|
110
120
|
environment: env,
|
|
111
|
-
headers: Object.assign({}, (auth.hasCredential ? { Authorization: () => __awaiter(this, void 0, void 0, function* () { return `Bearer ${yield auth.getToken()}`; }) } : {})),
|
|
121
|
+
headers: Object.assign(Object.assign({}, STRIPPED_SDK_HEADERS), (auth.hasCredential ? { Authorization: () => __awaiter(this, void 0, void 0, function* () { return `Bearer ${yield auth.getToken()}`; }) } : {})),
|
|
112
122
|
});
|
|
113
123
|
this._tokenAuth = auth;
|
|
114
124
|
this._env = env;
|
package/dist/esm/Client.mjs
CHANGED
|
@@ -25,8 +25,8 @@ export class ApolloClient {
|
|
|
25
25
|
this._options = Object.assign(Object.assign({}, _options), { logging: core.logging.createLogger(_options === null || _options === void 0 ? void 0 : _options.logging), headers: mergeHeaders({
|
|
26
26
|
"X-Fern-Language": "JavaScript",
|
|
27
27
|
"X-Fern-SDK-Name": "@aui.io/aui-client",
|
|
28
|
-
"X-Fern-SDK-Version": "3.1.
|
|
29
|
-
"User-Agent": "@aui.io/aui-client/3.1.
|
|
28
|
+
"X-Fern-SDK-Version": "3.1.1",
|
|
29
|
+
"User-Agent": "@aui.io/aui-client/3.1.1",
|
|
30
30
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
31
31
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
32
32
|
}, _options === null || _options === void 0 ? void 0 : _options.headers) });
|
|
@@ -4,7 +4,7 @@ export declare namespace SessionSocket {
|
|
|
4
4
|
interface Args {
|
|
5
5
|
socket: core.ReconnectingWebSocket;
|
|
6
6
|
}
|
|
7
|
-
type Response = Apollo.
|
|
7
|
+
type Response = Apollo.ThreadEnvelope | Apollo.MessageEnvelope | Apollo.EventEnvelope | Apollo.ErrorEnvelope;
|
|
8
8
|
type EventHandlers = {
|
|
9
9
|
open?: () => void;
|
|
10
10
|
message?: (message: Response) => void;
|
|
@@ -33,10 +33,8 @@ export declare class SessionSocket {
|
|
|
33
33
|
* ```
|
|
34
34
|
*/
|
|
35
35
|
on<T extends keyof SessionSocket.EventHandlers>(event: T, callback: SessionSocket.EventHandlers[T]): void;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
sendForwardedEvent(message: Apollo.EventEnvelope): void;
|
|
39
|
-
sendErrorFrame(message: Apollo.ErrorEnvelope): void;
|
|
36
|
+
sendSubmitMessage(message: Apollo.SubmitMessageRequest): void;
|
|
37
|
+
sendResume(message: Apollo.ResumeRequest): void;
|
|
40
38
|
/** Connect to the websocket and register event handlers. */
|
|
41
39
|
connect(): SessionSocket;
|
|
42
40
|
/** Close the websocket and unregister event handlers. */
|
|
@@ -48,5 +46,5 @@ export declare class SessionSocket {
|
|
|
48
46
|
/** Send a binary payload to the websocket. */
|
|
49
47
|
protected sendBinary(payload: ArrayBufferLike | Blob | ArrayBufferView): void;
|
|
50
48
|
/** Send a JSON payload to the websocket. */
|
|
51
|
-
protected sendJson(payload: Apollo.
|
|
49
|
+
protected sendJson(payload: Apollo.SubmitMessageRequest | Apollo.ResumeRequest): void;
|
|
52
50
|
}
|
|
@@ -54,19 +54,11 @@ export class SessionSocket {
|
|
|
54
54
|
on(event, callback) {
|
|
55
55
|
this.eventHandlers[event] = callback;
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
sendSubmitMessage(message) {
|
|
58
58
|
this.assertSocketIsOpen();
|
|
59
59
|
this.sendJson(message);
|
|
60
60
|
}
|
|
61
|
-
|
|
62
|
-
this.assertSocketIsOpen();
|
|
63
|
-
this.sendJson(message);
|
|
64
|
-
}
|
|
65
|
-
sendForwardedEvent(message) {
|
|
66
|
-
this.assertSocketIsOpen();
|
|
67
|
-
this.sendJson(message);
|
|
68
|
-
}
|
|
69
|
-
sendErrorFrame(message) {
|
|
61
|
+
sendResume(message) {
|
|
70
62
|
this.assertSocketIsOpen();
|
|
71
63
|
this.sendJson(message);
|
|
72
64
|
}
|
package/dist/esm/exports.d.mts
CHANGED
package/dist/esm/exports.mjs
CHANGED
|
@@ -6,3 +6,6 @@
|
|
|
6
6
|
* `export * from "./exports.mjs"`.
|
|
7
7
|
*/
|
|
8
8
|
export * from "./core/exports.mjs";
|
|
9
|
+
// The generated session resource doesn't re-export its socket class, so consumers
|
|
10
|
+
// couldn't name the type returned by `client.connect()`. Surface it at the package root.
|
|
11
|
+
export { SessionSocket } from "./api/resources/session/client/Socket.mjs";
|
package/dist/esm/version.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "3.1.
|
|
1
|
+
export declare const SDK_VERSION = "3.1.1";
|
package/dist/esm/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "3.1.
|
|
1
|
+
export const SDK_VERSION = "3.1.1";
|