@aui.io/aui-client 3.2.0 → 3.2.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 +195 -239
- package/dist/cjs/ApolloClientWrapper.d.ts +3 -3
- package/dist/cjs/ApolloClientWrapper.js +2 -6
- package/dist/cjs/Client.js +2 -2
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/ApolloClientWrapper.d.mts +3 -3
- package/dist/esm/ApolloClientWrapper.mjs +2 -6
- package/dist/esm/Client.mjs +2 -2
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# @aui.io/aui-client
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@aui.io/aui-client)
|
|
4
|
-
[](https://buildwithfern.com)
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
Official TypeScript/JavaScript SDK for the AUI Apollo API. Provides REST access to
|
|
6
|
+
messaging, projects, agents, and threads, plus a real-time WebSocket messaging session.
|
|
7
7
|
|
|
8
8
|
## Installation
|
|
9
9
|
|
|
@@ -11,347 +11,303 @@
|
|
|
11
11
|
npm install @aui.io/aui-client
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
##
|
|
14
|
+
## Clients
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
The package exposes two clients, one per credential. Import and use the one that
|
|
17
|
+
matches your environment.
|
|
17
18
|
|
|
18
|
-
| Client | Credential |
|
|
19
|
+
| Client | Credential | Browser | Purpose |
|
|
19
20
|
| --- | --- | --- | --- |
|
|
20
|
-
| `ApolloMessagingClient` | Publishable key (`pk_network_
|
|
21
|
-
| `ApolloManagementClient` | Organization API key |
|
|
21
|
+
| `ApolloMessagingClient` | Publishable key (`pk_network_...`) | Yes | End-user messaging and channels |
|
|
22
|
+
| `ApolloManagementClient` | Organization API key | No — server only | Managing projects, agents, versions, and threads |
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
- **`ApolloManagementClient`** sends the organization API key on every request as the `x-organization-api-key` header — there is no token exchange, caching, or refresh.
|
|
24
|
+
---
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
import { ApolloMessagingClient, ApolloManagementClient } from '@aui.io/aui-client';
|
|
26
|
+
## Messaging
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
`ApolloMessagingClient` authenticates with a publishable key. It exchanges the key
|
|
29
|
+
for a short-lived access token and refreshes it as needed, so you never handle tokens
|
|
30
|
+
directly. The agent is derived from the key and is not passed in request bodies. The
|
|
31
|
+
client is safe to use in the browser.
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { ApolloMessagingClient } from '@aui.io/aui-client';
|
|
33
35
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
organizationApiKey: 'YOUR_ORG_API_KEY',
|
|
36
|
+
const client = new ApolloMessagingClient({
|
|
37
|
+
publishableKey: 'pk_network_xxxxxxxxxxxxxxxxxxxxxxxx',
|
|
37
38
|
});
|
|
38
39
|
```
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
### Send a message
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
```typescript
|
|
45
|
-
import { ApolloMessagingClient } from '@aui.io/aui-client';
|
|
46
|
-
|
|
47
|
-
const messaging = new ApolloMessagingClient({
|
|
48
|
-
publishableKey: 'pk_network_xxxxxxxxxxxxxxxxxxxxxxxx',
|
|
49
|
-
});
|
|
43
|
+
Omit `thread_id` to start a new thread, or pass it to continue one.
|
|
50
44
|
|
|
51
|
-
|
|
52
|
-
const response = await
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
```ts
|
|
46
|
+
const response = await client.messaging.sendMessage({
|
|
47
|
+
user_id: 'end-user-123',
|
|
48
|
+
text: 'What can you help me with?',
|
|
49
|
+
// thread_id: existingThreadId,
|
|
55
50
|
});
|
|
56
51
|
|
|
57
|
-
console.log(
|
|
52
|
+
console.log(response.thread_id);
|
|
58
53
|
```
|
|
59
54
|
|
|
60
|
-
|
|
55
|
+
You can pass optional per-message values for the agent's configured context variables:
|
|
61
56
|
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
57
|
+
```ts
|
|
58
|
+
await client.messaging.sendMessage({
|
|
59
|
+
user_id: 'end-user-123',
|
|
60
|
+
text: 'Where is my order?',
|
|
61
|
+
agent_variables: {
|
|
62
|
+
static: { customer_name: 'Ada' },
|
|
63
|
+
dynamic: { order_id: 'ORD-1042' },
|
|
64
|
+
},
|
|
67
65
|
});
|
|
68
|
-
|
|
69
|
-
const projects = await management.projects.listProjects();
|
|
70
|
-
const projectId = projects.results[0].id;
|
|
71
|
-
|
|
72
|
-
const agents = await management.agents.listAgents(projectId, { filters: {} });
|
|
73
66
|
```
|
|
74
67
|
|
|
75
|
-
|
|
68
|
+
### Stream a message
|
|
76
69
|
|
|
77
|
-
|
|
70
|
+
`streamMessage` returns the reply as Server-Sent Events.
|
|
78
71
|
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
72
|
+
```ts
|
|
73
|
+
const stream = await client.messaging.streamMessage({
|
|
74
|
+
user_id: 'end-user-123',
|
|
75
|
+
text: 'Tell me about my account',
|
|
76
|
+
});
|
|
83
77
|
|
|
84
|
-
|
|
85
|
-
|
|
78
|
+
for await (const event of stream) {
|
|
79
|
+
console.log(event);
|
|
86
80
|
}
|
|
87
81
|
```
|
|
88
82
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
Resources are split by surface: messaging resources live on `ApolloMessagingClient`, management resources on `ApolloManagementClient`. All list endpoints are paginated and return `{ results, meta }`, where `meta.has_more` indicates further pages.
|
|
83
|
+
### Welcome message and follow-up suggestions
|
|
92
84
|
|
|
93
|
-
|
|
85
|
+
```ts
|
|
86
|
+
const { welcome_message } = await client.messaging.getWelcomeMessage();
|
|
94
87
|
|
|
95
|
-
|
|
88
|
+
const { suggestions } = await client.messaging.generateFollowupSuggestions({
|
|
89
|
+
context: { topic: 'order tracking' },
|
|
90
|
+
});
|
|
91
|
+
```
|
|
96
92
|
|
|
97
|
-
|
|
93
|
+
### Other messaging methods
|
|
98
94
|
|
|
99
95
|
| Method | Description |
|
|
100
96
|
| --- | --- |
|
|
101
|
-
| `sendMessage(request)` | Send a message and
|
|
102
|
-
| `streamMessage(request)` |
|
|
97
|
+
| `sendMessage(request)` | Send a message and return the reply. |
|
|
98
|
+
| `streamMessage(request)` | Send a message and stream the reply (SSE). |
|
|
103
99
|
| `rerun(threadId, request)` | Re-run the latest turn of a thread. |
|
|
104
|
-
| `listMessages(threadId)` |
|
|
105
|
-
| `threadTrace(threadId)` |
|
|
106
|
-
| `interactionTrace(interactionId)` |
|
|
107
|
-
| `getWelcomeMessage()` |
|
|
108
|
-
| `generateFollowupSuggestions(request)` |
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
100
|
+
| `listMessages(threadId)` | Return the messages in a thread. |
|
|
101
|
+
| `threadTrace(threadId)` | Return the reasoning trace for each interaction in a thread. |
|
|
102
|
+
| `interactionTrace(interactionId)` | Return the reasoning trace for a single interaction. |
|
|
103
|
+
| `getWelcomeMessage()` | Return the agent's welcome message. |
|
|
104
|
+
| `generateFollowupSuggestions(request)` | Generate follow-up prompts from a context. |
|
|
105
|
+
|
|
106
|
+
### Channels (SMS and WhatsApp)
|
|
107
|
+
|
|
108
|
+
Start an outbound thread on a channel with `channels.initiateThread`. Pass `'sms'`
|
|
109
|
+
or `'whatsapp'` as the channel.
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
const thread = await client.channels.initiateThread('sms', {
|
|
113
|
+
phone_number: '+14155551234',
|
|
114
|
+
user_id: 'end-user-123',
|
|
115
|
+
text: 'Hi! Your order has shipped.',
|
|
116
|
+
// thread_id: existingThreadId,
|
|
119
117
|
});
|
|
120
|
-
console.log('Thread:', res.thread_id);
|
|
121
118
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
119
|
+
console.log(thread.thread_id);
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### WebSocket sessions
|
|
127
123
|
|
|
128
|
-
|
|
129
|
-
|
|
124
|
+
`connect()` opens a real-time messaging session. Authentication is handled for you,
|
|
125
|
+
and it works in both Node and the browser.
|
|
130
126
|
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
const one = await messaging.messaging.interactionTrace(interactionId);
|
|
127
|
+
```ts
|
|
128
|
+
const socket = await client.connect();
|
|
129
|
+
await socket.waitForOpen();
|
|
135
130
|
|
|
136
|
-
|
|
137
|
-
|
|
131
|
+
socket.on('message', (message) => console.log(message));
|
|
132
|
+
socket.on('error', (error) => console.error(error));
|
|
133
|
+
socket.on('close', (event) => console.log('closed', event.code));
|
|
138
134
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
135
|
+
socket.sendSubmitMessage({
|
|
136
|
+
type: 'message',
|
|
137
|
+
agent_id: agentId,
|
|
138
|
+
user_id: 'end-user-123',
|
|
139
|
+
text: 'Hello over WebSocket',
|
|
142
140
|
});
|
|
141
|
+
|
|
142
|
+
socket.close();
|
|
143
143
|
```
|
|
144
144
|
|
|
145
|
-
|
|
145
|
+
The socket exposes `waitForOpen()`, `on(event, handler)` (events: `open`, `message`,
|
|
146
|
+
`error`, `close`), `sendSubmitMessage(request)`, `sendResume(request)`, and `close()`.
|
|
147
|
+
Note that `on()` registers a single handler per event; calling it again for the same
|
|
148
|
+
event replaces the previous handler. The socket type is exported as `SessionSocket`.
|
|
146
149
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
// thread_id: existingThreadId, // omit to start a new thread
|
|
159
|
-
});
|
|
160
|
-
console.log('Thread:', sms.thread_id);
|
|
150
|
+
### Resolved key context
|
|
151
|
+
|
|
152
|
+
After the first request, or after calling `getContext()`, the scope resolved from the
|
|
153
|
+
publishable key is available.
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
const context = await client.getContext();
|
|
157
|
+
console.log(context.agentId, context.organizationId);
|
|
158
|
+
|
|
159
|
+
client.agentId; // set after the first token exchange
|
|
160
|
+
client.organizationId;
|
|
161
161
|
```
|
|
162
162
|
|
|
163
|
-
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Management
|
|
166
|
+
|
|
167
|
+
`ApolloManagementClient` authenticates with an organization API key, sent as the
|
|
168
|
+
`x-organization-api-key` header on every request. It is intended for backend services
|
|
169
|
+
and CI. Do not expose the organization API key in the browser.
|
|
170
|
+
|
|
171
|
+
```ts
|
|
172
|
+
import { ApolloManagementClient } from '@aui.io/aui-client';
|
|
173
|
+
|
|
174
|
+
const client = new ApolloManagementClient({
|
|
175
|
+
organizationApiKey: process.env.AUI_ORG_API_KEY,
|
|
176
|
+
});
|
|
177
|
+
```
|
|
164
178
|
|
|
165
|
-
|
|
179
|
+
### Projects
|
|
166
180
|
|
|
167
181
|
| Method | Description |
|
|
168
182
|
| --- | --- |
|
|
169
|
-
| `listProjects()` | List the
|
|
183
|
+
| `listProjects()` | List the organization's projects. |
|
|
170
184
|
| `createProject(request)` | Create a project. |
|
|
171
185
|
| `getProject(projectId)` | Fetch one project. |
|
|
172
186
|
| `deleteProject(projectId)` | Delete a project. |
|
|
173
187
|
| `getProjectUsage(projectId)` | Usage metrics aggregated across the project. |
|
|
174
188
|
|
|
175
|
-
```
|
|
176
|
-
const page = await
|
|
177
|
-
const project = await
|
|
178
|
-
const
|
|
179
|
-
const usage = await management.projects.getProjectUsage(project.id);
|
|
180
|
-
await management.projects.deleteProject(project.id);
|
|
189
|
+
```ts
|
|
190
|
+
const page = await client.projects.listProjects();
|
|
191
|
+
const project = await client.projects.createProject({ name: 'My project' });
|
|
192
|
+
const usage = await client.projects.getProjectUsage(project.id);
|
|
181
193
|
```
|
|
182
194
|
|
|
183
|
-
|
|
195
|
+
### Agents
|
|
184
196
|
|
|
185
197
|
| Method | Description |
|
|
186
198
|
| --- | --- |
|
|
187
|
-
| `listAgents(projectId, { filters })` | List a project's agents
|
|
188
|
-
| `createAgent(projectId, request)` | Create an agent
|
|
189
|
-
| `getAgent(agentId)` | Fetch one agent
|
|
199
|
+
| `listAgents(projectId, { filters })` | List a project's agents. |
|
|
200
|
+
| `createAgent(projectId, request)` | Create an agent. |
|
|
201
|
+
| `getAgent(agentId)` | Fetch one agent. |
|
|
190
202
|
| `updateAgent(agentId, request)` | Rename an agent. |
|
|
191
|
-
| `deleteAgent(agentId)` | Delete an agent and
|
|
203
|
+
| `deleteAgent(agentId)` | Delete an agent and its versions. |
|
|
192
204
|
| `getAgentUsage(agentId)` | Usage metrics for one agent. |
|
|
193
205
|
|
|
194
|
-
```
|
|
195
|
-
const page = await
|
|
196
|
-
const agent = await
|
|
197
|
-
const
|
|
198
|
-
await management.agents.updateAgent(agent.id, { name: 'Support bot v2' });
|
|
199
|
-
const usage = await management.agents.getAgentUsage(agent.id);
|
|
200
|
-
await management.agents.deleteAgent(agent.id);
|
|
206
|
+
```ts
|
|
207
|
+
const page = await client.agents.listAgents(projectId, { filters: {} });
|
|
208
|
+
const agent = await client.agents.createAgent(projectId, { name: 'Support bot' });
|
|
209
|
+
const usage = await client.agents.getAgentUsage(agent.id);
|
|
201
210
|
```
|
|
202
211
|
|
|
203
|
-
|
|
212
|
+
### Agent versions
|
|
204
213
|
|
|
205
214
|
| Method | Description |
|
|
206
215
|
| --- | --- |
|
|
207
216
|
| `listVersions(agentId, { filters })` | List an agent's versions, newest first. |
|
|
208
|
-
| `createVersion(agentId, request)` | Create a draft version
|
|
209
|
-
| `updateVersion(agentId, versionId, request)` | Update a version's metadata
|
|
210
|
-
| `pushVersion(agentId, versionId, request)` | Push a
|
|
211
|
-
| `pullVersion(agentId, versionId, request?)` | Download a version's
|
|
217
|
+
| `createVersion(agentId, request)` | Create a draft version. |
|
|
218
|
+
| `updateVersion(agentId, versionId, request)` | Update a version's metadata. |
|
|
219
|
+
| `pushVersion(agentId, versionId, request)` | Push a configuration bundle. |
|
|
220
|
+
| `pullVersion(agentId, versionId, request?)` | Download a version's configuration bundle. |
|
|
212
221
|
| `publishVersion(agentId, versionId)` | Make a version the agent's live version. |
|
|
213
|
-
| `archiveVersion(agentId, versionId)` | Archive
|
|
214
|
-
|
|
215
|
-
```
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
await
|
|
219
|
-
await management.agentVersions.pushVersion(agentId, draft.id, { /* config bundle */ });
|
|
220
|
-
const bundle = await management.agentVersions.pullVersion(agentId, draft.id);
|
|
221
|
-
await management.agentVersions.publishVersion(agentId, draft.id);
|
|
222
|
-
await management.agentVersions.archiveVersion(agentId, draft.id);
|
|
222
|
+
| `archiveVersion(agentId, versionId)` | Archive a version. |
|
|
223
|
+
|
|
224
|
+
```ts
|
|
225
|
+
const draft = await client.agentVersions.createVersion(agentId, {});
|
|
226
|
+
await client.agentVersions.pushVersion(agentId, draft.id, { /* config bundle */ });
|
|
227
|
+
await client.agentVersions.publishVersion(agentId, draft.id);
|
|
223
228
|
```
|
|
224
229
|
|
|
225
|
-
|
|
230
|
+
### Threads
|
|
226
231
|
|
|
227
232
|
| Method | Description |
|
|
228
233
|
| --- | --- |
|
|
229
|
-
| `listThreads({ filters })` | List the
|
|
234
|
+
| `listThreads({ filters })` | List the organization's threads, newest first. |
|
|
230
235
|
| `getThread(threadId)` | Fetch one thread. |
|
|
231
236
|
| `updateThread(threadId, request)` | Update a thread (currently `title`). |
|
|
232
|
-
| `getThreadMessages(threadId)` |
|
|
233
|
-
| `getThreadTrace(threadId)` |
|
|
234
|
-
| `getInteractionTrace(interactionId)` |
|
|
235
|
-
|
|
236
|
-
`filters` supports `project_id`, `agent_id`, `user_id`, `external_id`, `created`
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
237
|
+
| `getThreadMessages(threadId)` | Return the thread's transcript. |
|
|
238
|
+
| `getThreadTrace(threadId)` | Return the reasoning trace for each interaction. |
|
|
239
|
+
| `getInteractionTrace(interactionId)` | Return the reasoning trace for a single interaction. |
|
|
240
|
+
|
|
241
|
+
`filters` supports `project_id`, `agent_id`, `user_id`, `external_id`, `created`
|
|
242
|
+
(range), `tool`, `rule`, and `param`. Prefer a filter such as `project_id` over an
|
|
243
|
+
empty object; the unfiltered list sorts every thread in the organization and can be slow.
|
|
244
|
+
|
|
245
|
+
```ts
|
|
246
|
+
const page = await client.threads.listThreads(
|
|
247
|
+
{ filters: { project_id: projectId } },
|
|
248
|
+
{ timeoutInSeconds: 120 },
|
|
242
249
|
);
|
|
243
|
-
const thread = await
|
|
244
|
-
|
|
245
|
-
const messages = await management.threads.getThreadMessages(threadId);
|
|
246
|
-
const trace = await management.threads.getThreadTrace(threadId);
|
|
247
|
-
const one = await management.threads.getInteractionTrace(interactionId);
|
|
250
|
+
const thread = await client.threads.getThread(threadId);
|
|
251
|
+
await client.threads.updateThread(threadId, { title: 'Renamed conversation' });
|
|
248
252
|
```
|
|
249
253
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
`connect()` opens a real-time session and is available on **`ApolloMessagingClient`** only (WebSocket messaging is publishable-key territory). The bearer token is attached to the upgrade automatically — it's passed as the first WebSocket subprotocol, which is the one credential channel browsers allow, so this works in the browser as well as in Node.
|
|
253
|
-
|
|
254
|
-
```typescript
|
|
255
|
-
const messaging = new ApolloMessagingClient({ publishableKey: 'pk_network_…' });
|
|
256
|
-
const socket = await messaging.connect();
|
|
257
|
-
await socket.waitForOpen();
|
|
258
|
-
|
|
259
|
-
socket.on('message', (msg) => {
|
|
260
|
-
console.log('Agent:', msg);
|
|
261
|
-
});
|
|
262
|
-
socket.on('error', (err) => console.error('WS error:', err));
|
|
263
|
-
socket.on('close', (event) => console.log('Closed:', event.code));
|
|
264
|
-
|
|
265
|
-
// Send a turn (type is required on the WS submit frame)
|
|
266
|
-
socket.sendSubmitMessage({
|
|
267
|
-
type: 'message',
|
|
268
|
-
agent_id: agentId,
|
|
269
|
-
user_id: 'end-user-123',
|
|
270
|
-
text: 'Hello over WebSocket',
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
// Resume a dropped stream
|
|
274
|
-
socket.sendResume({ /* ResumeRequest */ });
|
|
275
|
-
|
|
276
|
-
// When done
|
|
277
|
-
socket.close();
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
The socket (`SessionSocket`) exposes: `waitForOpen()`, `on(event, handler)` (events: `open`, `message`, `error`, `close`), `sendSubmitMessage(request)`, `sendResume(request)`, and `close()`.
|
|
281
|
-
|
|
282
|
-
> **Notes**
|
|
283
|
-
> - `socket.on(event, handler)` registers a **single** handler per event — calling it
|
|
284
|
-
> again for the same event replaces the previous handler rather than adding one.
|
|
285
|
-
> - The socket type is exported as `SessionSocket` (`import { SessionSocket } from '@aui.io/aui-client'`).
|
|
286
|
-
> - Request timeouts are **per call** via `timeoutInSeconds` on a request's options; there
|
|
287
|
-
> is no client-wide default timeout. Pass it on slow calls, e.g.
|
|
288
|
-
> `management.threads.listThreads({ filters: {} }, { timeoutInSeconds: 120 })`.
|
|
289
|
-
|
|
290
|
-
## Key Context Helpers
|
|
254
|
+
---
|
|
291
255
|
|
|
292
|
-
|
|
256
|
+
## Pagination
|
|
293
257
|
|
|
294
|
-
|
|
295
|
-
const messaging = new ApolloMessagingClient({ publishableKey: 'pk_network_…' });
|
|
258
|
+
List endpoints return `{ results, meta }`. Use `meta.has_more` to detect further pages.
|
|
296
259
|
|
|
297
|
-
|
|
260
|
+
## Timeouts
|
|
298
261
|
|
|
299
|
-
|
|
300
|
-
console.log(ctx.agentId, ctx.organizationId, ctx.keyType);
|
|
262
|
+
There is no client-wide timeout. Set `timeoutInSeconds` per call when needed:
|
|
301
263
|
|
|
302
|
-
|
|
303
|
-
|
|
264
|
+
```ts
|
|
265
|
+
await client.threads.listThreads({ filters: {} }, { timeoutInSeconds: 120 });
|
|
304
266
|
```
|
|
305
267
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
## Error Handling
|
|
268
|
+
## Error handling
|
|
309
269
|
|
|
310
|
-
`ApolloError`
|
|
311
|
-
|
|
312
|
-
namespace.
|
|
270
|
+
`ApolloError` and `ApolloTimeoutError` are exported at the top level. Per-status errors,
|
|
271
|
+
such as `UnprocessableEntityError`, are available under the `Apollo` namespace.
|
|
313
272
|
|
|
314
|
-
```
|
|
273
|
+
```ts
|
|
315
274
|
import { ApolloError, Apollo } from '@aui.io/aui-client';
|
|
316
275
|
|
|
317
276
|
try {
|
|
318
|
-
|
|
277
|
+
await client.agents.getAgent('missing-id');
|
|
319
278
|
} catch (error) {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
279
|
+
if (error instanceof Apollo.UnprocessableEntityError) {
|
|
280
|
+
console.error(error.body);
|
|
281
|
+
} else if (error instanceof ApolloError) {
|
|
282
|
+
console.error(error.statusCode, error.body);
|
|
283
|
+
} else {
|
|
284
|
+
throw error;
|
|
285
|
+
}
|
|
327
286
|
}
|
|
328
287
|
```
|
|
329
288
|
|
|
330
|
-
## TypeScript
|
|
289
|
+
## TypeScript
|
|
331
290
|
|
|
332
|
-
The
|
|
291
|
+
The package ships type definitions. Request and response models are available under the
|
|
292
|
+
`Apollo` namespace.
|
|
333
293
|
|
|
334
|
-
```
|
|
294
|
+
```ts
|
|
335
295
|
import { Apollo } from '@aui.io/aui-client';
|
|
336
296
|
|
|
337
|
-
const
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
297
|
+
const request: Apollo.SubmitMessageRequest = {
|
|
298
|
+
type: 'message',
|
|
299
|
+
agent_id: 'agent-123',
|
|
300
|
+
user_id: 'end-user-123',
|
|
301
|
+
text: 'Typed request',
|
|
342
302
|
};
|
|
343
303
|
```
|
|
344
304
|
|
|
345
305
|
## Resources
|
|
346
306
|
|
|
347
|
-
-
|
|
348
|
-
-
|
|
349
|
-
-
|
|
307
|
+
- npm: [@aui.io/aui-client](https://www.npmjs.com/package/@aui.io/aui-client)
|
|
308
|
+
- GitHub: [aui-io/aui-client-typescript](https://github.com/aui-io/aui-client-typescript)
|
|
309
|
+
- Issues: [GitHub Issues](https://github.com/aui-io/aui-client-typescript/issues)
|
|
350
310
|
|
|
351
311
|
## License
|
|
352
312
|
|
|
353
|
-
Proprietary
|
|
354
|
-
|
|
355
|
-
---
|
|
356
|
-
|
|
357
|
-
**Built by the AUI team**
|
|
313
|
+
Proprietary. Unauthorized copying or distribution is prohibited.
|
|
@@ -9,7 +9,7 @@ import type { Agents } from "./api/resources/agents/client/Client.js";
|
|
|
9
9
|
import type { AgentVersions } from "./api/resources/agentVersions/client/Client.js";
|
|
10
10
|
import type { Threads } from "./api/resources/threads/client/Client.js";
|
|
11
11
|
/** Publishable-key family, inferred from the key prefix. */
|
|
12
|
-
export type PublishableKeyType = "agent" | "
|
|
12
|
+
export type PublishableKeyType = "agent" | "unknown";
|
|
13
13
|
type AuthHeaders = Record<string, string | (() => Promise<string>) | null>;
|
|
14
14
|
declare class BaseApolloClient {
|
|
15
15
|
protected readonly _client: _GeneratedClient;
|
|
@@ -18,7 +18,7 @@ declare class BaseApolloClient {
|
|
|
18
18
|
}
|
|
19
19
|
export declare namespace ApolloMessagingClient {
|
|
20
20
|
interface Options {
|
|
21
|
-
/** Publishable key (pk_network_
|
|
21
|
+
/** Publishable key (pk_network_...). */
|
|
22
22
|
publishableKey: string;
|
|
23
23
|
/** Internal: override the API host. Defaults to production. */
|
|
24
24
|
baseUrl?: string;
|
|
@@ -37,7 +37,7 @@ export declare class ApolloMessagingClient extends BaseApolloClient {
|
|
|
37
37
|
get messaging(): Messaging;
|
|
38
38
|
/** Initiate channel-scoped threads (e.g. SMS). */
|
|
39
39
|
get channels(): Channels;
|
|
40
|
-
/** Publishable-key family (agent /
|
|
40
|
+
/** Publishable-key family (agent / unknown). */
|
|
41
41
|
get keyType(): PublishableKeyType;
|
|
42
42
|
/** Agent resolved from an agent-scoped key. Populated after the first exchange. */
|
|
43
43
|
get agentId(): string | undefined;
|
|
@@ -159,7 +159,7 @@ class ApolloMessagingClient extends BaseApolloClient {
|
|
|
159
159
|
get channels() {
|
|
160
160
|
return this._client.channels;
|
|
161
161
|
}
|
|
162
|
-
/** Publishable-key family (agent /
|
|
162
|
+
/** Publishable-key family (agent / unknown). */
|
|
163
163
|
get keyType() {
|
|
164
164
|
return this._pkAuth.keyType;
|
|
165
165
|
}
|
|
@@ -238,11 +238,7 @@ function resolveEnv(baseUrl) {
|
|
|
238
238
|
return { base, production: base.replace(/^http/i, "ws") };
|
|
239
239
|
}
|
|
240
240
|
function detectKeyType(publishableKey) {
|
|
241
|
-
if (
|
|
242
|
-
return "unknown";
|
|
243
|
-
if (publishableKey.startsWith("pk_network_"))
|
|
241
|
+
if (publishableKey === null || publishableKey === void 0 ? void 0 : publishableKey.startsWith("pk_network_"))
|
|
244
242
|
return "agent";
|
|
245
|
-
if (publishableKey.startsWith("pk_org_"))
|
|
246
|
-
return "org";
|
|
247
243
|
return "unknown";
|
|
248
244
|
}
|
package/dist/cjs/Client.js
CHANGED
|
@@ -62,8 +62,8 @@ class ApolloClient {
|
|
|
62
62
|
"x-organization-api-key": _options === null || _options === void 0 ? void 0 : _options.organizationApiKey,
|
|
63
63
|
"X-Fern-Language": "JavaScript",
|
|
64
64
|
"X-Fern-SDK-Name": "@aui.io/aui-client",
|
|
65
|
-
"X-Fern-SDK-Version": "3.2.
|
|
66
|
-
"User-Agent": "@aui.io/aui-client/3.2.
|
|
65
|
+
"X-Fern-SDK-Version": "3.2.1",
|
|
66
|
+
"User-Agent": "@aui.io/aui-client/3.2.1",
|
|
67
67
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
68
68
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
69
69
|
}, _options === null || _options === void 0 ? void 0 : _options.headers) });
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "3.2.
|
|
1
|
+
export declare const SDK_VERSION = "3.2.1";
|
package/dist/cjs/version.js
CHANGED
|
@@ -9,7 +9,7 @@ import type { Agents } from "./api/resources/agents/client/Client.mjs";
|
|
|
9
9
|
import type { AgentVersions } from "./api/resources/agentVersions/client/Client.mjs";
|
|
10
10
|
import type { Threads } from "./api/resources/threads/client/Client.mjs";
|
|
11
11
|
/** Publishable-key family, inferred from the key prefix. */
|
|
12
|
-
export type PublishableKeyType = "agent" | "
|
|
12
|
+
export type PublishableKeyType = "agent" | "unknown";
|
|
13
13
|
type AuthHeaders = Record<string, string | (() => Promise<string>) | null>;
|
|
14
14
|
declare class BaseApolloClient {
|
|
15
15
|
protected readonly _client: _GeneratedClient;
|
|
@@ -18,7 +18,7 @@ declare class BaseApolloClient {
|
|
|
18
18
|
}
|
|
19
19
|
export declare namespace ApolloMessagingClient {
|
|
20
20
|
interface Options {
|
|
21
|
-
/** Publishable key (pk_network_
|
|
21
|
+
/** Publishable key (pk_network_...). */
|
|
22
22
|
publishableKey: string;
|
|
23
23
|
/** Internal: override the API host. Defaults to production. */
|
|
24
24
|
baseUrl?: string;
|
|
@@ -37,7 +37,7 @@ export declare class ApolloMessagingClient extends BaseApolloClient {
|
|
|
37
37
|
get messaging(): Messaging;
|
|
38
38
|
/** Initiate channel-scoped threads (e.g. SMS). */
|
|
39
39
|
get channels(): Channels;
|
|
40
|
-
/** Publishable-key family (agent /
|
|
40
|
+
/** Publishable-key family (agent / unknown). */
|
|
41
41
|
get keyType(): PublishableKeyType;
|
|
42
42
|
/** Agent resolved from an agent-scoped key. Populated after the first exchange. */
|
|
43
43
|
get agentId(): string | undefined;
|
|
@@ -123,7 +123,7 @@ export class ApolloMessagingClient extends BaseApolloClient {
|
|
|
123
123
|
get channels() {
|
|
124
124
|
return this._client.channels;
|
|
125
125
|
}
|
|
126
|
-
/** Publishable-key family (agent /
|
|
126
|
+
/** Publishable-key family (agent / unknown). */
|
|
127
127
|
get keyType() {
|
|
128
128
|
return this._pkAuth.keyType;
|
|
129
129
|
}
|
|
@@ -200,11 +200,7 @@ function resolveEnv(baseUrl) {
|
|
|
200
200
|
return { base, production: base.replace(/^http/i, "ws") };
|
|
201
201
|
}
|
|
202
202
|
function detectKeyType(publishableKey) {
|
|
203
|
-
if (
|
|
204
|
-
return "unknown";
|
|
205
|
-
if (publishableKey.startsWith("pk_network_"))
|
|
203
|
+
if (publishableKey === null || publishableKey === void 0 ? void 0 : publishableKey.startsWith("pk_network_"))
|
|
206
204
|
return "agent";
|
|
207
|
-
if (publishableKey.startsWith("pk_org_"))
|
|
208
|
-
return "org";
|
|
209
205
|
return "unknown";
|
|
210
206
|
}
|
package/dist/esm/Client.mjs
CHANGED
|
@@ -26,8 +26,8 @@ export class ApolloClient {
|
|
|
26
26
|
"x-organization-api-key": _options === null || _options === void 0 ? void 0 : _options.organizationApiKey,
|
|
27
27
|
"X-Fern-Language": "JavaScript",
|
|
28
28
|
"X-Fern-SDK-Name": "@aui.io/aui-client",
|
|
29
|
-
"X-Fern-SDK-Version": "3.2.
|
|
30
|
-
"User-Agent": "@aui.io/aui-client/3.2.
|
|
29
|
+
"X-Fern-SDK-Version": "3.2.1",
|
|
30
|
+
"User-Agent": "@aui.io/aui-client/3.2.1",
|
|
31
31
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
32
32
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
33
33
|
}, _options === null || _options === void 0 ? void 0 : _options.headers) });
|
package/dist/esm/version.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "3.2.
|
|
1
|
+
export declare const SDK_VERSION = "3.2.1";
|
package/dist/esm/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "3.2.
|
|
1
|
+
export const SDK_VERSION = "3.2.1";
|