@callimacus/thamyr 4.3.4
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/CHANGELOG.core.md +1747 -0
- package/CHANGELOG.md +2301 -0
- package/LICENSE.md +73 -0
- package/MIGRATION.md +271 -0
- package/README.md +514 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/types/index.d.ts +203 -0
- package/package.json +45 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright © 2025–2026 Solomei AI SRL. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Proprietary software, licensed for use by Callimacus customers only.
|
|
5
|
+
* See LICENSE.md for the full terms.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import { ThamyrResponse, ErrorMessage, ClientInfo, UiObserverConfig, UserInteractionType, InteractionPayloadMap, CallimacusApi } from '@callimacus/thamyr-core';
|
|
9
|
+
export * from '@callimacus/thamyr-core';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
Configuration options for WebsocketManager
|
|
13
|
+
*/
|
|
14
|
+
type CallimacusManagerOptions = {
|
|
15
|
+
/**
|
|
16
|
+
Whether to automatically connect to the server when initialized
|
|
17
|
+
@default true
|
|
18
|
+
*/
|
|
19
|
+
autoConnect?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
URL to connect to the Callimacus server
|
|
22
|
+
@default wss://localhost:4000
|
|
23
|
+
*/
|
|
24
|
+
url?: string;
|
|
25
|
+
/**
|
|
26
|
+
Authentication token for connecting to the server
|
|
27
|
+
*/
|
|
28
|
+
token?: string;
|
|
29
|
+
/**
|
|
30
|
+
Callbacks for different events
|
|
31
|
+
*/
|
|
32
|
+
callbacks?: {
|
|
33
|
+
/**
|
|
34
|
+
Called when the connection status changes
|
|
35
|
+
*/
|
|
36
|
+
onConnectionStatusChange?: (isConnected: boolean) => void;
|
|
37
|
+
/**
|
|
38
|
+
Called when a response is received from the server
|
|
39
|
+
*/
|
|
40
|
+
onResponse?: (response: ThamyrResponse) => void;
|
|
41
|
+
/**
|
|
42
|
+
Called when an error is received from the server
|
|
43
|
+
*/
|
|
44
|
+
onError?: (error: ErrorMessage) => void;
|
|
45
|
+
/**
|
|
46
|
+
Called when client information is gathered
|
|
47
|
+
*/
|
|
48
|
+
onClientInfo?: (clientInfo: ClientInfo) => void;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
Optional autonomous UI observer configuration.
|
|
52
|
+
When enabled, context snapshots are attached automatically on `sendUserInteraction`.
|
|
53
|
+
*/
|
|
54
|
+
uiObserver?: UiObserverConfig;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
Manages Callimacus service interactions for vanilla JavaScript applications.
|
|
58
|
+
|
|
59
|
+
Provides a lightweight wrapper around the core Callimacus service with
|
|
60
|
+
a more convenient API for vanilla JS usage.
|
|
61
|
+
|
|
62
|
+
@example
|
|
63
|
+
```js
|
|
64
|
+
// Initialize (connects automatically by default)
|
|
65
|
+
const manager = new WebsocketManager({
|
|
66
|
+
url: "wss://my-callimacus-server.example.com",
|
|
67
|
+
token: "your-auth-token",
|
|
68
|
+
callbacks: {
|
|
69
|
+
onConnectionStatusChange: (isConnected) => {
|
|
70
|
+
console.log(`Connection status: ${isConnected ? 'connected' : 'disconnected'}`);
|
|
71
|
+
},
|
|
72
|
+
onResponse: (response) => {
|
|
73
|
+
console.log('Received response:', response);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// Or connect manually (pass autoConnect: false above)
|
|
79
|
+
manager.connect("wss://server.example.com", "your-auth-token");
|
|
80
|
+
|
|
81
|
+
// Send an interaction: (type, payload)
|
|
82
|
+
manager.sendUserInteraction("create-round", { inputEvent });
|
|
83
|
+
|
|
84
|
+
// Disconnect when done
|
|
85
|
+
manager.disconnect();
|
|
86
|
+
```
|
|
87
|
+
*/
|
|
88
|
+
declare class WebsocketManager {
|
|
89
|
+
private onConnectionStatusChangeCallback?;
|
|
90
|
+
private onResponseCallback?;
|
|
91
|
+
private onErrorCallback?;
|
|
92
|
+
private readonly onClientInfoCallback?;
|
|
93
|
+
/**
|
|
94
|
+
Creates a new WebsocketManager instance
|
|
95
|
+
|
|
96
|
+
@param options - Configuration options
|
|
97
|
+
*/
|
|
98
|
+
constructor(options?: CallimacusManagerOptions);
|
|
99
|
+
/**
|
|
100
|
+
Sets up event listeners for the Callimacus service
|
|
101
|
+
*/
|
|
102
|
+
private setupEventListeners;
|
|
103
|
+
/**
|
|
104
|
+
Connects to the Callimacus server
|
|
105
|
+
|
|
106
|
+
@param url - The URL of the server to connect to
|
|
107
|
+
@param token - Authentication token to pass with the connection
|
|
108
|
+
*/
|
|
109
|
+
connect(url?: string, token?: string): void;
|
|
110
|
+
/**
|
|
111
|
+
Disconnects from the Callimacus server
|
|
112
|
+
*/
|
|
113
|
+
disconnect(): void;
|
|
114
|
+
/**
|
|
115
|
+
Sends a typed user interaction to the server with full type assistance.
|
|
116
|
+
|
|
117
|
+
@template T - The specific interaction type
|
|
118
|
+
@param type - Which user interaction to send (e.g. `CREATE_ROUND`)
|
|
119
|
+
@param payload - The properly typed payload for this interaction type
|
|
120
|
+
*/
|
|
121
|
+
sendUserInteraction<T extends UserInteractionType>(type: T, payload: InteractionPayloadMap[T]): void;
|
|
122
|
+
/**
|
|
123
|
+
Gathers client information
|
|
124
|
+
*/
|
|
125
|
+
gatherClientInfo(): void;
|
|
126
|
+
/**
|
|
127
|
+
Sets a callback to be called when the connection status changes
|
|
128
|
+
|
|
129
|
+
@param callback - Function to call when connection status changes
|
|
130
|
+
@returns A function to remove the callback
|
|
131
|
+
*/
|
|
132
|
+
onConnectionStatusChange(callback: (isConnected: boolean) => void): () => void;
|
|
133
|
+
/**
|
|
134
|
+
Sets a callback to be called when a response is received
|
|
135
|
+
|
|
136
|
+
@param callback - Function to call when a response is received
|
|
137
|
+
@returns A function to remove the callback
|
|
138
|
+
*/
|
|
139
|
+
onResponse(callback: (response: ThamyrResponse) => void): () => void;
|
|
140
|
+
/**
|
|
141
|
+
Sets a callback to be called when an error is received
|
|
142
|
+
|
|
143
|
+
@param callback - Function to call when an error is received
|
|
144
|
+
@returns A function to remove the callback
|
|
145
|
+
*/
|
|
146
|
+
onError(callback: (error: ErrorMessage) => void): () => void;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
The one read outside the generated contract: `sitemap.xml` is a token-less,
|
|
151
|
+
domain-resolved route the public document cannot describe. Same fetch client as
|
|
152
|
+
every other namespace; the classic direct-value promise is kept.
|
|
153
|
+
*/
|
|
154
|
+
declare class SitemapAPI {
|
|
155
|
+
readonly config: {
|
|
156
|
+
accessToken: string;
|
|
157
|
+
endpoint: string;
|
|
158
|
+
};
|
|
159
|
+
private readonly client;
|
|
160
|
+
constructor(config: {
|
|
161
|
+
accessToken: string;
|
|
162
|
+
endpoint: string;
|
|
163
|
+
});
|
|
164
|
+
/**
|
|
165
|
+
The site map as XML text (an empty body resolves `''`). Rejects with an `Error`
|
|
166
|
+
carrying `status` (the HTTP status, or `undefined` when no response arrived) on
|
|
167
|
+
anything but a 2xx.
|
|
168
|
+
*/
|
|
169
|
+
getSitemap(): Promise<string>;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
Extends the generated {@link CallimacusApi}: the contracted namespaces (content,
|
|
174
|
+
stories, products, whisper, analytics, cart, skesis) live on the instance and
|
|
175
|
+
grow with the contract. Their methods resolve `{data, error, response}` by default.
|
|
176
|
+
*/
|
|
177
|
+
declare class Thamyr extends CallimacusApi {
|
|
178
|
+
readonly config: {
|
|
179
|
+
endpoint?: string;
|
|
180
|
+
/**
|
|
181
|
+
Your Callimacus public client ID (`cal-pk-…`).
|
|
182
|
+
*/
|
|
183
|
+
clientId?: string;
|
|
184
|
+
uiObserver?: UiObserverConfig;
|
|
185
|
+
};
|
|
186
|
+
private readonly websocketManager;
|
|
187
|
+
readonly sitemap: SitemapAPI;
|
|
188
|
+
constructor(config: {
|
|
189
|
+
endpoint?: string;
|
|
190
|
+
/**
|
|
191
|
+
Your Callimacus public client ID (`cal-pk-…`).
|
|
192
|
+
*/
|
|
193
|
+
clientId?: string;
|
|
194
|
+
uiObserver?: UiObserverConfig;
|
|
195
|
+
});
|
|
196
|
+
sendAudio(audio: Blob, query?: string): void;
|
|
197
|
+
sendUserInteraction<T extends UserInteractionType>(type: T, payload: InteractionPayloadMap[T]): void;
|
|
198
|
+
onResponse(callback: (response: ThamyrResponse) => void): void;
|
|
199
|
+
onError(callback: (error: ErrorMessage) => void): void;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export { SitemapAPI, Thamyr, WebsocketManager };
|
|
203
|
+
export type { CallimacusManagerOptions };
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@callimacus/thamyr",
|
|
3
|
+
"version": "4.3.4",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "JavaScript package for Thamyr",
|
|
6
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
7
|
+
"homepage": "https://docs.callimacus.ai/thamyr-sdk/typescript/1-overview",
|
|
8
|
+
"main": "dist/esm/index.js",
|
|
9
|
+
"module": "dist/esm/index.js",
|
|
10
|
+
"types": "dist/types/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/esm/index.js",
|
|
14
|
+
"types": "./dist/types/index.d.ts"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"type": "module",
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"CHANGELOG.md",
|
|
21
|
+
"CHANGELOG.core.md",
|
|
22
|
+
"MIGRATION.md"
|
|
23
|
+
],
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public",
|
|
26
|
+
"registry": "https://registry.npmjs.org",
|
|
27
|
+
"@callimacus:registry": "https://registry.npmjs.org"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"prepack": "cp ../../MIGRATION.md ./MIGRATION.md && cp ../core/CHANGELOG.md ./CHANGELOG.core.md",
|
|
31
|
+
"build": "rollup -c",
|
|
32
|
+
"dev": "rollup -c -w",
|
|
33
|
+
"clean": "rm -rf dist",
|
|
34
|
+
"lint": "eslint src",
|
|
35
|
+
"test": "vitest run"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@callimacus/thamyr-core": "^4.3.4"
|
|
39
|
+
},
|
|
40
|
+
"gitHead": "fafba2c8ca0586f95b1d03c5eede356a53b00886",
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"eslint-config-xo": "^4.0.1",
|
|
43
|
+
"vitest": "^5.0.2"
|
|
44
|
+
}
|
|
45
|
+
}
|