@aiassist-secure/core 1.0.0
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/LICENSE +21 -0
- package/README.md +327 -0
- package/dist/index.d.mts +223 -0
- package/dist/index.d.ts +223 -0
- package/dist/index.js +345 -0
- package/dist/index.mjs +314 -0
- package/package.json +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 Interchained LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
# @aiassist-secure/core
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@aiassist-secure/core)
|
|
4
|
+
[](https://www.typescriptlang.org/)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
**Framework-agnostic TypeScript SDK for AiAssist Secure** - The enterprise AI orchestration platform with shadow mode, human-in-the-loop, and real-time typing indicators.
|
|
8
|
+
|
|
9
|
+
Works in **Node.js 18+** and **modern browsers**.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- **OpenAI-Compatible API** - Drop-in replacement syntax
|
|
16
|
+
- **Shadow Mode** - AI drafts require human approval before sending
|
|
17
|
+
- **Human-in-the-Loop** - Seamless AI-to-human handoff detection
|
|
18
|
+
- **Typing Preview** - Real-time "AI is typing..." indicators
|
|
19
|
+
- **Streaming** - Server-sent events for token-by-token output
|
|
20
|
+
- **Managed Workspaces** - Persistent conversation threads with context
|
|
21
|
+
- **Full TypeScript** - Complete type definitions included
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install @aiassist-secure/core
|
|
29
|
+
# or
|
|
30
|
+
yarn add @aiassist-secure/core
|
|
31
|
+
# or
|
|
32
|
+
pnpm add @aiassist-secure/core
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Quick Start
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { AiAssistClient } from '@aiassist-secure/core';
|
|
41
|
+
|
|
42
|
+
const client = new AiAssistClient({ apiKey: 'aai_your_key' });
|
|
43
|
+
|
|
44
|
+
// Simple chat completion (OpenAI-compatible)
|
|
45
|
+
const response = await client.chat.completions.create({
|
|
46
|
+
messages: [{ role: 'user', content: 'Hello!' }]
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
console.log(response.choices[0].message.content);
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Streaming Responses
|
|
55
|
+
|
|
56
|
+
Get real-time token-by-token output:
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
const stream = await client.chat.completions.create({
|
|
60
|
+
messages: [{ role: 'user', content: 'Write a haiku about coding' }],
|
|
61
|
+
stream: true
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
for await (const chunk of stream) {
|
|
65
|
+
const content = chunk.choices[0]?.delta?.content;
|
|
66
|
+
if (content) {
|
|
67
|
+
process.stdout.write(content); // Print each token as it arrives
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Managed Workspaces
|
|
75
|
+
|
|
76
|
+
Create persistent conversation threads with full context:
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
// Create a workspace with system prompt and context
|
|
80
|
+
const { workspace, messages } = await client.workspaces.create({
|
|
81
|
+
clientId: 'user_123',
|
|
82
|
+
initial_message: 'Hello!',
|
|
83
|
+
system_prompt: 'You are a helpful customer support agent for Acme Inc.',
|
|
84
|
+
context: {
|
|
85
|
+
user_plan: 'enterprise',
|
|
86
|
+
previous_tickets: 3
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
console.log('Workspace ID:', workspace.id);
|
|
91
|
+
console.log('AI Response:', messages[0].content);
|
|
92
|
+
|
|
93
|
+
// Continue the conversation
|
|
94
|
+
const response = await client.workspaces.sendMessage(
|
|
95
|
+
workspace.id,
|
|
96
|
+
'I need help with my billing'
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
console.log('Mode:', response.mode); // 'ai' | 'shadow' | 'takeover'
|
|
100
|
+
console.log('Response:', response.responses[0].content);
|
|
101
|
+
|
|
102
|
+
// Get full conversation history
|
|
103
|
+
const history = await client.workspaces.getMessages(workspace.id);
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## Shadow Mode (Enterprise)
|
|
109
|
+
|
|
110
|
+
In shadow mode, AI drafts require manager approval before being sent to the client. Perfect for training, compliance, and quality assurance:
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
const response = await client.workspaces.sendMessage(workspace.id, 'Process my refund');
|
|
114
|
+
|
|
115
|
+
if (response.pending_approval) {
|
|
116
|
+
console.log('AI drafted a response - awaiting manager approval');
|
|
117
|
+
console.log('Draft:', response.responses[0].content);
|
|
118
|
+
|
|
119
|
+
// The message won't be visible to the end-user until approved
|
|
120
|
+
// Your manager dashboard can approve/reject/edit the draft
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Check workspace mode
|
|
124
|
+
console.log('Current mode:', response.mode);
|
|
125
|
+
// 'ai' - Fully autonomous
|
|
126
|
+
// 'shadow' - AI drafts, human approves
|
|
127
|
+
// 'takeover' - Human control only
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Human-in-the-Loop Detection
|
|
133
|
+
|
|
134
|
+
Detect when a human agent takes over the conversation:
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
const response = await client.workspaces.sendMessage(workspace.id, 'I want to speak to a human');
|
|
138
|
+
|
|
139
|
+
switch (response.mode) {
|
|
140
|
+
case 'ai':
|
|
141
|
+
console.log('AI is handling this conversation');
|
|
142
|
+
break;
|
|
143
|
+
case 'shadow':
|
|
144
|
+
console.log('AI is drafting, but a human will review');
|
|
145
|
+
break;
|
|
146
|
+
case 'takeover':
|
|
147
|
+
console.log('A human agent has taken control');
|
|
148
|
+
// Update your UI to show "Speaking with Support Agent"
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Typing Preview
|
|
156
|
+
|
|
157
|
+
Show real-time "AI is typing..." indicators in your UI:
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
// Poll for typing status (useful for chat UIs)
|
|
161
|
+
const status = await client.workspaces.getTypingStatus(workspace.id);
|
|
162
|
+
|
|
163
|
+
if (status.is_typing) {
|
|
164
|
+
showTypingIndicator();
|
|
165
|
+
console.log('AI is composing a response...');
|
|
166
|
+
} else {
|
|
167
|
+
hideTypingIndicator();
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## End Conversation
|
|
174
|
+
|
|
175
|
+
Gracefully close conversations with optional feedback:
|
|
176
|
+
|
|
177
|
+
```typescript
|
|
178
|
+
// End the conversation
|
|
179
|
+
await client.workspaces.endConversation(workspace.id);
|
|
180
|
+
|
|
181
|
+
// Or end with a reason/feedback
|
|
182
|
+
await client.workspaces.endConversation(workspace.id, {
|
|
183
|
+
reason: 'resolved',
|
|
184
|
+
feedback: 'Issue was resolved successfully'
|
|
185
|
+
});
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## Configuration Options
|
|
191
|
+
|
|
192
|
+
```typescript
|
|
193
|
+
const client = new AiAssistClient({
|
|
194
|
+
apiKey: 'aai_your_key', // Required: Your API key
|
|
195
|
+
baseURL: 'https://api.aiassist.net', // Custom endpoint
|
|
196
|
+
timeout: 30000, // Request timeout (ms)
|
|
197
|
+
maxRetries: 3, // Retry failed requests
|
|
198
|
+
defaultHeaders: { // Custom headers
|
|
199
|
+
'X-Custom-Header': 'value'
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## Error Handling
|
|
207
|
+
|
|
208
|
+
Typed errors for precise error handling:
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
import {
|
|
212
|
+
AiAssistClient,
|
|
213
|
+
AuthenticationError,
|
|
214
|
+
RateLimitError,
|
|
215
|
+
APIError
|
|
216
|
+
} from '@aiassist-secure/core';
|
|
217
|
+
|
|
218
|
+
try {
|
|
219
|
+
const response = await client.chat.completions.create({
|
|
220
|
+
messages: [{ role: 'user', content: 'Hello' }]
|
|
221
|
+
});
|
|
222
|
+
} catch (error) {
|
|
223
|
+
if (error instanceof AuthenticationError) {
|
|
224
|
+
console.error('Invalid API key - check your credentials');
|
|
225
|
+
} else if (error instanceof RateLimitError) {
|
|
226
|
+
console.error(`Rate limited. Retry after ${error.retryAfter} seconds`);
|
|
227
|
+
// Implement exponential backoff
|
|
228
|
+
} else if (error instanceof APIError) {
|
|
229
|
+
console.error(`API error ${error.status}: ${error.message}`);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## List Available Models
|
|
237
|
+
|
|
238
|
+
```typescript
|
|
239
|
+
const models = await client.models.list();
|
|
240
|
+
|
|
241
|
+
console.log('Available models:');
|
|
242
|
+
models.forEach(model => {
|
|
243
|
+
console.log(`- ${model.id}: ${model.context_length} tokens`);
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
// Example output:
|
|
247
|
+
// - llama-3.3-70b-versatile: 128000 tokens
|
|
248
|
+
// - llama-3.1-8b-instant: 131072 tokens
|
|
249
|
+
// - mixtral-8x7b-32768: 32768 tokens
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## TypeScript Types
|
|
255
|
+
|
|
256
|
+
Full type definitions included:
|
|
257
|
+
|
|
258
|
+
```typescript
|
|
259
|
+
import type {
|
|
260
|
+
// Core types
|
|
261
|
+
Message,
|
|
262
|
+
ChatCompletion,
|
|
263
|
+
ChatCompletionChunk,
|
|
264
|
+
ChatCompletionCreateParams,
|
|
265
|
+
|
|
266
|
+
// Workspace types
|
|
267
|
+
Workspace,
|
|
268
|
+
WorkspaceMessage,
|
|
269
|
+
WorkspaceCreateParams,
|
|
270
|
+
WorkspaceCreateResponse,
|
|
271
|
+
SendMessageResponse,
|
|
272
|
+
WorkspaceMode, // 'ai' | 'shadow' | 'takeover'
|
|
273
|
+
WorkspaceStatus, // 'active' | 'ended'
|
|
274
|
+
|
|
275
|
+
// Client types
|
|
276
|
+
AiAssistClientOptions,
|
|
277
|
+
} from '@aiassist-secure/core';
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## Browser Usage
|
|
283
|
+
|
|
284
|
+
Works directly in modern browsers via ESM:
|
|
285
|
+
|
|
286
|
+
```html
|
|
287
|
+
<script type="module">
|
|
288
|
+
import { AiAssistClient } from 'https://esm.sh/@aiassist-secure/core';
|
|
289
|
+
|
|
290
|
+
const client = new AiAssistClient({
|
|
291
|
+
apiKey: 'aai_pub_your_domain_scoped_key'
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
const response = await client.chat.completions.create({
|
|
295
|
+
messages: [{ role: 'user', content: 'Hello from the browser!' }]
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
document.getElementById('output').textContent =
|
|
299
|
+
response.choices[0].message.content;
|
|
300
|
+
</script>
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
**Note:** Use domain-scoped public keys (`aai_pub_*`) for browser environments.
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
## Related Packages
|
|
308
|
+
|
|
309
|
+
| Package | Description |
|
|
310
|
+
|---------|-------------|
|
|
311
|
+
| [@aiassist-secure/react](https://www.npmjs.com/package/@aiassist-secure/react) | React components with built-in UI |
|
|
312
|
+
| [@aiassist-secure/vanilla](https://www.npmjs.com/package/@aiassist-secure/vanilla) | Drop-in widget for any website |
|
|
313
|
+
|
|
314
|
+
---
|
|
315
|
+
|
|
316
|
+
## Links
|
|
317
|
+
|
|
318
|
+
- [Documentation](https://aiassist.net/developer-docs/typescript)
|
|
319
|
+
- [API Reference](https://aiassist.net/api-reference)
|
|
320
|
+
- [GitHub](https://github.com/aiassistsecure/aiassist-js)
|
|
321
|
+
- [Discord Community](https://discord.gg/aiassist)
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
## License
|
|
326
|
+
|
|
327
|
+
MIT License - [Interchained LLC](https://interchained.com)
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AiAssist SDK Types
|
|
3
|
+
*/
|
|
4
|
+
interface Message {
|
|
5
|
+
role: 'system' | 'user' | 'assistant';
|
|
6
|
+
content: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
}
|
|
9
|
+
interface ChatCompletionChoice {
|
|
10
|
+
index: number;
|
|
11
|
+
message: Message;
|
|
12
|
+
finish_reason: 'stop' | 'length' | 'content_filter' | null;
|
|
13
|
+
}
|
|
14
|
+
interface Usage {
|
|
15
|
+
prompt_tokens: number;
|
|
16
|
+
completion_tokens: number;
|
|
17
|
+
total_tokens: number;
|
|
18
|
+
}
|
|
19
|
+
interface ChatCompletion {
|
|
20
|
+
id: string;
|
|
21
|
+
object: 'chat.completion';
|
|
22
|
+
created: number;
|
|
23
|
+
model: string;
|
|
24
|
+
choices: ChatCompletionChoice[];
|
|
25
|
+
usage?: Usage;
|
|
26
|
+
}
|
|
27
|
+
interface ChatCompletionChunkDelta {
|
|
28
|
+
role?: 'assistant';
|
|
29
|
+
content?: string;
|
|
30
|
+
}
|
|
31
|
+
interface ChatCompletionChunkChoice {
|
|
32
|
+
index: number;
|
|
33
|
+
delta: ChatCompletionChunkDelta;
|
|
34
|
+
finish_reason: 'stop' | 'length' | 'content_filter' | null;
|
|
35
|
+
}
|
|
36
|
+
interface ChatCompletionChunk {
|
|
37
|
+
id: string;
|
|
38
|
+
object: 'chat.completion.chunk';
|
|
39
|
+
created: number;
|
|
40
|
+
model: string;
|
|
41
|
+
choices: ChatCompletionChunkChoice[];
|
|
42
|
+
}
|
|
43
|
+
interface ChatCompletionCreateParams {
|
|
44
|
+
messages: Message[];
|
|
45
|
+
model?: string;
|
|
46
|
+
temperature?: number;
|
|
47
|
+
max_tokens?: number;
|
|
48
|
+
top_p?: number;
|
|
49
|
+
stream?: boolean;
|
|
50
|
+
provider?: string;
|
|
51
|
+
}
|
|
52
|
+
type WorkspaceMode = 'ai' | 'shadow' | 'takeover';
|
|
53
|
+
type WorkspaceStatus = 'active' | 'archived' | 'deleted';
|
|
54
|
+
type MessageRole = 'user' | 'ai' | 'human' | 'system';
|
|
55
|
+
interface Workspace {
|
|
56
|
+
id: string;
|
|
57
|
+
mode: WorkspaceMode;
|
|
58
|
+
status: WorkspaceStatus;
|
|
59
|
+
metadata?: Record<string, unknown>;
|
|
60
|
+
created_at?: string;
|
|
61
|
+
updated_at?: string;
|
|
62
|
+
}
|
|
63
|
+
interface WorkspaceMessage {
|
|
64
|
+
id: string;
|
|
65
|
+
role: MessageRole;
|
|
66
|
+
content: string;
|
|
67
|
+
created_at?: string;
|
|
68
|
+
workspace_id?: string;
|
|
69
|
+
}
|
|
70
|
+
interface WorkspaceCreateParams {
|
|
71
|
+
initial_message?: string;
|
|
72
|
+
client_id?: string;
|
|
73
|
+
system_prompt?: string;
|
|
74
|
+
context?: Record<string, unknown>;
|
|
75
|
+
metadata?: Record<string, unknown>;
|
|
76
|
+
}
|
|
77
|
+
interface WorkspaceCreateResponse {
|
|
78
|
+
workspace: Workspace;
|
|
79
|
+
messages: WorkspaceMessage[];
|
|
80
|
+
}
|
|
81
|
+
interface SendMessageResponse {
|
|
82
|
+
user_message: WorkspaceMessage;
|
|
83
|
+
responses: WorkspaceMessage[];
|
|
84
|
+
mode: WorkspaceMode;
|
|
85
|
+
pending_approval?: boolean;
|
|
86
|
+
}
|
|
87
|
+
interface WorkspaceByClientResponse {
|
|
88
|
+
workspace: Workspace | null;
|
|
89
|
+
messages: WorkspaceMessage[];
|
|
90
|
+
exists: boolean;
|
|
91
|
+
}
|
|
92
|
+
interface Model {
|
|
93
|
+
id: string;
|
|
94
|
+
object: 'model';
|
|
95
|
+
owned_by: string;
|
|
96
|
+
created?: number;
|
|
97
|
+
}
|
|
98
|
+
interface ModelList {
|
|
99
|
+
object: 'list';
|
|
100
|
+
data: Model[];
|
|
101
|
+
}
|
|
102
|
+
interface LeadInfo {
|
|
103
|
+
leadId: string;
|
|
104
|
+
email: string;
|
|
105
|
+
}
|
|
106
|
+
interface AiAssistClientOptions {
|
|
107
|
+
apiKey: string;
|
|
108
|
+
baseURL?: string;
|
|
109
|
+
timeout?: number;
|
|
110
|
+
maxRetries?: number;
|
|
111
|
+
defaultHeaders?: Record<string, string>;
|
|
112
|
+
}
|
|
113
|
+
declare class AiAssistError extends Error {
|
|
114
|
+
status?: number;
|
|
115
|
+
code?: string;
|
|
116
|
+
constructor(message: string, status?: number, code?: string);
|
|
117
|
+
}
|
|
118
|
+
declare class AuthenticationError extends AiAssistError {
|
|
119
|
+
constructor(message?: string);
|
|
120
|
+
}
|
|
121
|
+
declare class RateLimitError extends AiAssistError {
|
|
122
|
+
retryAfter?: number;
|
|
123
|
+
constructor(message?: string, retryAfter?: number);
|
|
124
|
+
}
|
|
125
|
+
declare class APIError extends AiAssistError {
|
|
126
|
+
constructor(message: string, status?: number, code?: string);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* AiAssist API Client
|
|
131
|
+
*
|
|
132
|
+
* Framework-agnostic TypeScript client for the AiAssist API.
|
|
133
|
+
* Works in Node.js and browsers.
|
|
134
|
+
*
|
|
135
|
+
* Full feature parity with React and Vanilla SDKs including:
|
|
136
|
+
* - Shadow mode support (pending_approval)
|
|
137
|
+
* - Human-in-the-loop mode detection
|
|
138
|
+
* - Typing preview
|
|
139
|
+
* - Conversation management
|
|
140
|
+
*/
|
|
141
|
+
|
|
142
|
+
declare class AiAssistClient {
|
|
143
|
+
private apiKey;
|
|
144
|
+
private baseURL;
|
|
145
|
+
private timeout;
|
|
146
|
+
private maxRetries;
|
|
147
|
+
private defaultHeaders;
|
|
148
|
+
chat: ChatAPI;
|
|
149
|
+
models: ModelsAPI;
|
|
150
|
+
workspaces: WorkspacesAPI;
|
|
151
|
+
constructor(options: AiAssistClientOptions);
|
|
152
|
+
private getHeaders;
|
|
153
|
+
request<T>(method: string, path: string, options?: {
|
|
154
|
+
body?: unknown;
|
|
155
|
+
headers?: Record<string, string>;
|
|
156
|
+
}): Promise<T>;
|
|
157
|
+
requestSilent(method: string, path: string, options?: {
|
|
158
|
+
body?: unknown;
|
|
159
|
+
}): Promise<void>;
|
|
160
|
+
stream(method: string, path: string, body: unknown): AsyncGenerator<ChatCompletionChunk, void, unknown>;
|
|
161
|
+
private sleep;
|
|
162
|
+
}
|
|
163
|
+
declare class ChatAPI {
|
|
164
|
+
completions: ChatCompletionsAPI;
|
|
165
|
+
constructor(client: AiAssistClient);
|
|
166
|
+
}
|
|
167
|
+
declare class ChatCompletionsAPI {
|
|
168
|
+
private client;
|
|
169
|
+
constructor(client: AiAssistClient);
|
|
170
|
+
create(params: ChatCompletionCreateParams & {
|
|
171
|
+
stream?: false;
|
|
172
|
+
}): Promise<ChatCompletion>;
|
|
173
|
+
create(params: ChatCompletionCreateParams & {
|
|
174
|
+
stream: true;
|
|
175
|
+
}): Promise<AsyncGenerator<ChatCompletionChunk, void, unknown>>;
|
|
176
|
+
create(params: ChatCompletionCreateParams): Promise<ChatCompletion | AsyncGenerator<ChatCompletionChunk, void, unknown>>;
|
|
177
|
+
}
|
|
178
|
+
declare class ModelsAPI {
|
|
179
|
+
private client;
|
|
180
|
+
constructor(client: AiAssistClient);
|
|
181
|
+
list(): Promise<Model[]>;
|
|
182
|
+
}
|
|
183
|
+
declare class WorkspacesAPI {
|
|
184
|
+
private client;
|
|
185
|
+
constructor(client: AiAssistClient);
|
|
186
|
+
/**
|
|
187
|
+
* Create a new workspace with optional system prompt and context.
|
|
188
|
+
*
|
|
189
|
+
* @param params - Workspace creation options
|
|
190
|
+
* @returns Workspace and initial messages
|
|
191
|
+
*/
|
|
192
|
+
create(params?: WorkspaceCreateParams): Promise<WorkspaceCreateResponse>;
|
|
193
|
+
/**
|
|
194
|
+
* Get workspace by ID.
|
|
195
|
+
*/
|
|
196
|
+
get(workspaceId: string): Promise<Workspace>;
|
|
197
|
+
/**
|
|
198
|
+
* Get workspace by client ID.
|
|
199
|
+
* Returns null if not found.
|
|
200
|
+
*/
|
|
201
|
+
getByClientId(clientId: string): Promise<WorkspaceByClientResponse>;
|
|
202
|
+
/**
|
|
203
|
+
* Send a message to a workspace.
|
|
204
|
+
* Returns user message, AI/human responses, mode, and shadow mode approval status.
|
|
205
|
+
*/
|
|
206
|
+
sendMessage(workspaceId: string, content: string): Promise<SendMessageResponse>;
|
|
207
|
+
/**
|
|
208
|
+
* Get all messages in a workspace.
|
|
209
|
+
*/
|
|
210
|
+
getMessages(workspaceId: string): Promise<WorkspaceMessage[]>;
|
|
211
|
+
/**
|
|
212
|
+
* Send typing preview to workspace (for real-time typing indicators).
|
|
213
|
+
* Fails silently - non-critical operation.
|
|
214
|
+
*/
|
|
215
|
+
sendTypingPreview(workspaceId: string, text: string): Promise<void>;
|
|
216
|
+
/**
|
|
217
|
+
* End a conversation/workspace.
|
|
218
|
+
* Fails silently - non-critical operation.
|
|
219
|
+
*/
|
|
220
|
+
endConversation(workspaceId: string): Promise<void>;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export { APIError, AiAssistClient, type AiAssistClientOptions, AiAssistError, AuthenticationError, type ChatCompletion, type ChatCompletionChoice, type ChatCompletionChunk, type ChatCompletionChunkChoice, type ChatCompletionChunkDelta, type ChatCompletionCreateParams, type LeadInfo, type Message, type MessageRole, type Model, type ModelList, RateLimitError, type SendMessageResponse, type Usage, type Workspace, type WorkspaceByClientResponse, type WorkspaceCreateParams, type WorkspaceCreateResponse, type WorkspaceMessage, type WorkspaceMode, type WorkspaceStatus };
|