@graphen.ai/aiia-sdk 1.0.18 → 1.0.20

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 CHANGED
@@ -24,21 +24,23 @@ SOFTWARE.
24
24
 
25
25
  This project uses the following third-party packages and complies with their respective licenses:
26
26
 
27
+ - @mediapipe/tasks-vision (Apache License 2.0)
28
+ - @nut-tree-fork/nut-js (Apache License 2.0)
27
29
  - axios (MIT License)
28
- - lodash (MIT License)
30
+ - lodash-es (MIT License)
31
+ - mathjs (Apache License 2.0)
32
+ - moment (MIT License)
33
+ - node-osc (Apache License 2.0)
29
34
  - rxjs (Apache License 2.0)
30
35
  - socket.io (MIT License)
31
36
  - socket.io-client (MIT License)
37
+ - systeminformation (MIT License)
32
38
  - ws (MIT License)
33
- - moment (MIT License)
34
39
 
35
40
  Development dependencies:
36
- - @microsoft/api-extractor (MIT License)
37
- - @rollup/* (MIT License)
38
- - @types/* (MIT License)
39
- - rollup (MIT License)
40
- - rollup-plugin-javascript-obfuscator (MIT License)
41
- - tslib (MIT License)
41
+
42
+ - @types/lodash-es (MIT License)
43
+ - tsup (MIT License)
42
44
  - typescript (Apache License 2.0)
43
45
 
44
46
  Please refer to each package's official documentation for full license details.
package/NOTICE CHANGED
@@ -21,6 +21,62 @@ Licensed under the Apache License, Version 2.0 (the "License");
21
21
  you may not use this file except in compliance with the License.
22
22
  You may obtain a copy of the License at
23
23
 
24
+ [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
25
+ Unless required by applicable law or agreed to in writing, software
26
+ distributed under the License is distributed on an "AS IS" BASIS,
27
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28
+ See the License for the specific language governing permissions and
29
+ limitations under the License.
30
+
31
+ @mediapipe/tasks-vision
32
+ Copyright 2023 The MediaPipe Authors.
33
+
34
+ Licensed under the Apache License, Version 2.0 (the "License");
35
+ you may not use this file except in compliance with the License.
36
+ You may obtain a copy of the License at
37
+
38
+ [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
39
+ Unless required by applicable law or agreed to in writing, software
40
+ distributed under the License is distributed on an "AS IS" BASIS,
41
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
42
+ See the License for the specific language governing permissions and
43
+ limitations under the License.
44
+
45
+ @nut-tree-fork/nut-js
46
+ Copyright 2024 dry Software UG (haftungsbeschränkt)
47
+
48
+ Licensed under the Apache License, Version 2.0 (the "License");
49
+ you may not use this file except in compliance with the License.
50
+ You may obtain a copy of the License at
51
+
52
+ [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
53
+ Unless required by applicable law or agreed to in writing, software
54
+ distributed under the License is distributed on an "AS IS" BASIS,
55
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
56
+ See the License for the specific language governing permissions and
57
+ limitations under the License.
58
+
59
+ mathjs
60
+ Copyright (C) 2013-2024 Jos de Jong <wjosdejong@gmail.com>
61
+
62
+ Licensed under the Apache License, Version 2.0 (the "License");
63
+ you may not use this file except in compliance with the License.
64
+ You may obtain a copy of the License at
65
+
66
+ [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
67
+ Unless required by applicable law or agreed to in writing, software
68
+ distributed under the License is distributed on an "AS IS" BASIS,
69
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
70
+ See the License for the specific language governing permissions and
71
+ limitations under the License.
72
+
73
+ node-osc
74
+ Copyright (C) 2012-2024 Myles Borins
75
+
76
+ Licensed under the Apache License, Version 2.0 (the "License");
77
+ you may not use this file except in compliance with the License.
78
+ You may obtain a copy of the License at
79
+
24
80
  [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
25
81
  Unless required by applicable law or agreed to in writing, software
26
82
  distributed under the License is distributed on an "AS IS" BASIS,
package/README.md CHANGED
@@ -34,7 +34,7 @@ sdk.start()
34
34
  ```typescript
35
35
  import { aiiaCore } from '@graphen.ai/aiia-sdk/node';
36
36
 
37
- const core = aiiaCore({ license: "<Your Token>" });
37
+ const core = aiiaCore({ group_id: "<Your Token>" });
38
38
  ```
39
39
 
40
40
  ## 錯誤碼(Error Codes)
@@ -1,2 +1,26 @@
1
- /** @license AiiaVad Released: 2025-12-8 */
2
- !function(){"use strict";var t;!function(t){t[t.unknow=0]="unknow",t[t.allowed=1]="allowed",t[t.rejected=2]="rejected"}(t||(t={}));class e extends AudioWorkletProcessor{inputBuffer;inputBufferLength;processChunkSize;outputSampleRate;originalSampleRate;constructor(t){super(),this.inputBuffer=[],this.inputBufferLength=0;const{outputSampleRate:e,chunkTimeInSeconds:n}=Object.assign({outputSampleRate:16e3,chunkTimeInSeconds:1},t?.processorOptions);this.originalSampleRate=sampleRate,this.outputSampleRate=e,this.processChunkSize=function(t,e,n=1){const s=e*n,u=t/e;return Math.ceil(s*u)}(this.originalSampleRate,this.outputSampleRate,n)}process(t,e,n){const s=t[0][0];if(!s)return!0;const u=new Float32Array(s);if(this.inputBuffer.push(u),this.inputBufferLength+=s.length,this.inputBufferLength>=this.processChunkSize){const t=function(t){const e=t.reduce((t,e)=>t+e.length,0),n=new Float32Array(e);let s=0;for(const e of t)n.set(e,s),s+=e.length;return n}(this.inputBuffer);this.inputBuffer=[],this.inputBufferLength=0;const e=function(t,e,n){if(e===n)return t;const s=n/e,u=Math.ceil(t.length*s),i=new Float32Array(u);for(let e=0;e<u;e++){const n=e/s,u=Math.floor(n),o=n-u,r=t[u],a=t[Math.min(u+1,t.length-1)];i[e]=r+(a-r)*o}return i}(t,this.originalSampleRate,this.outputSampleRate);this.port.postMessage({float32:e,outputSampleRate:this.outputSampleRate},[e.buffer])}return!0}}registerProcessor("aiia-vad",e)}();
1
+ (function(){'use strict';/**
2
+ * MIT License
3
+ *
4
+ * Copyright (c) 2026 Graphen
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ *
24
+ * UPDATA DATE: 2026/2/11
25
+ */
26
+ var A=Object.defineProperty;var y=(e,r,t)=>r in e?A(e,r,{enumerable:true,configurable:true,writable:true,value:t}):e[r]=t;var u=(e,r,t)=>y(e,typeof r!="symbol"?r+"":r,t);function h(e,r,t){if(r===t)return e;let n=t/r,a=e.length,o=Math.ceil(a*n),s=new Float32Array(o),c=1/n,i=0;for(let f=0;f<o;f++){let l=i|0,g=i-l,p=e[l],d=l+1<a?e[l+1]:p;s[f]=p+(d-p)*g,i+=c;}return s}function x(e){let r=e.reduce((a,o)=>a+o.length,0),t=new Float32Array(r),n=0;for(let a of e)t.set(a,n),n+=a.length;return t}function M(e,r,t=1){let n=r*t,a=e/r;return Math.ceil(n*a)}var m=class extends AudioWorkletProcessor{constructor(t){super();u(this,"inputBuffer");u(this,"inputBufferLength");u(this,"processChunkSize");u(this,"outputSampleRate");u(this,"originalSampleRate");this.inputBuffer=[],this.inputBufferLength=0;let{outputSampleRate:n,chunkTimeInSeconds:a}=Object.assign({outputSampleRate:16e3,chunkTimeInSeconds:1},t==null?void 0:t.processorOptions);this.originalSampleRate=sampleRate,this.outputSampleRate=n,this.processChunkSize=M(this.originalSampleRate,this.outputSampleRate,a);}process(t,n,a){let o=t[0][0];if(!o)return true;let s=new Float32Array(o);if(this.inputBuffer.push(s),this.inputBufferLength+=o.length,this.inputBufferLength>=this.processChunkSize){let c=x(this.inputBuffer);this.inputBuffer=[],this.inputBufferLength=0;let i=h(c,this.originalSampleRate,this.outputSampleRate);this.port.postMessage({float32:i,outputSampleRate:this.outputSampleRate},[i.buffer]);}return true}};registerProcessor("aiia-vad",m);})();
@@ -0,0 +1,406 @@
1
+ import { BoundingBox, Landmark, Detection } from '@mediapipe/tasks-vision';
2
+ import { A as AiiaProjectItem, L as LoggerLevel, I as InitOptions } from '../type-RVXBPx7G.js';
3
+ import * as rxjs from 'rxjs';
4
+ import * as node_http2 from 'node:http2';
5
+ import * as node_https from 'node:https';
6
+ import * as node_http from 'node:http';
7
+ import 'http';
8
+ import 'https';
9
+ import 'http2';
10
+
11
+ interface Result extends BoundingBox {
12
+ area: number;
13
+ score: number;
14
+ clientWidth: number;
15
+ clientHeight: number;
16
+ }
17
+ type AnalysisResult = Result | null;
18
+
19
+ type LayoutID = string | number;
20
+ interface LAYOUT$1 {
21
+ signal: "layout";
22
+ content: {
23
+ type: "mount";
24
+ id: LayoutID;
25
+ panel: string;
26
+ props?: Record<string, unknown>;
27
+ zIndex?: number;
28
+ } | {
29
+ type: "update";
30
+ id: LayoutID;
31
+ props?: Record<string, unknown>;
32
+ zIndex?: number;
33
+ } | {
34
+ type: "unmount";
35
+ id: LayoutID;
36
+ };
37
+ }
38
+ interface SendMessage_MiniGame {
39
+ request: "minigame";
40
+ userCtrl?: boolean;
41
+ content: {
42
+ type: "start" | "open" | "next" | "answer" | "rank";
43
+ quizId?: string;
44
+ ansId?: string;
45
+ };
46
+ }
47
+ interface SendMessage_Layout {
48
+ request: "layout";
49
+ userCtrl?: boolean;
50
+ content: {
51
+ type: "duplicate_id" | "miss_panel_name" | "id_not_find" | "props_error";
52
+ } & Record<string, string | string[]>;
53
+ }
54
+ interface SendMessage_Audio_Init {
55
+ request: "audio";
56
+ userCtrl?: boolean;
57
+ command: "sampleRate";
58
+ content: number;
59
+ }
60
+ interface SendMessage_Audio_PCM {
61
+ request: "audio";
62
+ userCtrl?: boolean;
63
+ command: "pcm";
64
+ content: number[];
65
+ }
66
+ type SendMessage_Audio = SendMessage_Audio_Init | SendMessage_Audio_PCM;
67
+ interface SendMessage_Face {
68
+ request: "face_detect";
69
+ content: boolean;
70
+ }
71
+ type LandmarkResult = Landmark[][];
72
+ interface SendMessage_Pose {
73
+ request: "pose_detect";
74
+ content: LandmarkResult;
75
+ }
76
+ type SendMessage = {
77
+ request: "reset";
78
+ } | {
79
+ request: "skip";
80
+ } | SendMessage_Layout | SendMessage_MiniGame | SendMessage_Audio | SendMessage_Face | SendMessage_Pose;
81
+
82
+ interface AiiaProjectItemWithAvatar extends AiiaProjectItem {
83
+ avatar: {
84
+ name: string;
85
+ url: string;
86
+ };
87
+ }
88
+ declare enum MonitorDeviceState {
89
+ 未響應 = 1,// 瀏覽器未在時間內回應狀態
90
+ 等待授權 = 2,
91
+ 已被拒絕 = 3,
92
+ VAD模組載入失敗 = 4,
93
+ 可正常使用 = 5,
94
+ 缺失該裝置 = 6,
95
+ 沒有服務 = 7
96
+ }
97
+ interface MonitorResult {
98
+ mic: MonitorDeviceState;
99
+ camera: MonitorDeviceState;
100
+ }
101
+ interface MSG_TO_SERVER {
102
+ uuid: string;
103
+ cloud: SendMessage;
104
+ debug: null;
105
+ face: AnalysisResult;
106
+ monitor: MonitorResult;
107
+ }
108
+
109
+ declare class AiiaConfig {
110
+ private config;
111
+ get webserver(): node_http.Server<any, any> | node_https.Server<any, any> | node_http2.Http2SecureServer<any, any, any, any> | node_http2.Http2Server<any, any, any, any>;
112
+ get environment(): string;
113
+ get license(): string;
114
+ get note(): string;
115
+ get port(): number;
116
+ get ws_url(): string;
117
+ get worklet_url(): string;
118
+ get project(): {
119
+ specific: boolean;
120
+ } & Partial<AiiaProjectItem>;
121
+ get endPoint(): {
122
+ api: string;
123
+ socket: string;
124
+ };
125
+ get debug(): boolean | "all" | "none" | LoggerLevel[];
126
+ get mediaStream(): MediaStream;
127
+ get chunkTimeInSeconds(): number;
128
+ get llmSampleRate(): number;
129
+ get detection(): {
130
+ perSecond: number;
131
+ confidence: number;
132
+ };
133
+ get autoClearSubtitle(): {
134
+ userDelayTime: number;
135
+ aiiaDelayTime: number;
136
+ };
137
+ get eyeTrackEnable(): boolean;
138
+ get eyeTrackCorrection(): {
139
+ x_axis_px: number;
140
+ y_axis_px: number;
141
+ };
142
+ constructor(config: InitOptions);
143
+ private safeRead;
144
+ }
145
+
146
+ declare enum MediaStateEnum {
147
+ padding = 0,
148
+ rejected = 1,
149
+ loadfail = 2,
150
+ allowed = 3
151
+ }
152
+ declare class MediaManager {
153
+ stream?: MediaStream;
154
+ private _state;
155
+ private stateSub;
156
+ private audioCtx?;
157
+ private audioManager?;
158
+ private vadManager?;
159
+ private camManager?;
160
+ private destroy;
161
+ private pcmSub;
162
+ private detectionsSub;
163
+ private landmarksSub;
164
+ get sampleRate(): number;
165
+ get pcm(): rxjs.Observable<Float32Array<ArrayBufferLike>>;
166
+ get detections(): rxjs.Observable<{
167
+ detections: Detection[];
168
+ clientWidth: number;
169
+ clientHeight: number;
170
+ }>;
171
+ get landmarks(): rxjs.Observable<LandmarkResult>;
172
+ get state(): MediaStateEnum;
173
+ set state(v: MediaStateEnum);
174
+ get stateObs(): rxjs.Observable<MediaStateEnum>;
175
+ constructor(stream?: MediaStream);
176
+ init(workletUrl: string, config?: {
177
+ llmSampleRate?: AiiaConfig["llmSampleRate"];
178
+ chunkTimeInSeconds?: AiiaConfig["chunkTimeInSeconds"];
179
+ cameraDetection?: AiiaConfig["detection"];
180
+ }): Promise<void>;
181
+ addAudioQueue(input: {
182
+ buffer: AudioBuffer;
183
+ } | {
184
+ int16: Int16Array<ArrayBufferLike>;
185
+ numberOfChannels?: number;
186
+ } | {
187
+ float32: Float32Array<ArrayBufferLike>;
188
+ numberOfChannels?: number;
189
+ }): void;
190
+ playAudio(): void;
191
+ stopAudio(): void;
192
+ startRecord(): void;
193
+ stopRecord(): void;
194
+ setVolume(val: number): void;
195
+ getVolume(): number;
196
+ startCapture(): void;
197
+ stopCapture(): void;
198
+ getInfo(): MSG_TO_SERVER["monitor"];
199
+ onDestroy(): void;
200
+ }
201
+
202
+ type AiiaState = "NotStart" | "WaitingProjectID" | "ConnectingCloud" | "ReconnectingCloud" | "InService" | "InServiceNoMedia" | "NoPermissions" | "CloseService" | "Destroy";
203
+ type LAYOUT = LAYOUT$1["content"] | {
204
+ type: "resetLayout";
205
+ };
206
+ declare class AiiaSdk {
207
+ private config;
208
+ private media;
209
+ private chat;
210
+ private destroySub;
211
+ private projectsSub;
212
+ private layoutSub;
213
+ private aiiaSubtitleSub;
214
+ private userSubtitleSub;
215
+ private sampleRateOfWhisper;
216
+ private stateSub;
217
+ private _currentState;
218
+ private isMuteAiia;
219
+ private aiiaSubtitleClearSub;
220
+ private userSubtitleClearSub;
221
+ private _lastProjects;
222
+ private guestSub;
223
+ private _hasGuest;
224
+ private isStart;
225
+ /**
226
+ * [zh]
227
+ * 可訂閱,服務狀態
228
+ *
229
+ * [en]
230
+ * Subscribable, service status
231
+ */
232
+ get state(): rxjs.Observable<AiiaState>;
233
+ /**
234
+ * [zh]
235
+ * 服務狀態
236
+ *
237
+ * [en]
238
+ * service status
239
+ */
240
+ get currentState(): AiiaState;
241
+ /**
242
+ * [zh]
243
+ * 可訂閱,控制組件
244
+ *
245
+ * [en]
246
+ * Subscribable, Control layout
247
+ */
248
+ get layout(): rxjs.Observable<LAYOUT>;
249
+ /**
250
+ * [zh]
251
+ * 若沒有明確指定 Project ID 時,請訂閱此物件
252
+ *
253
+ * [en]
254
+ * If no Project ID is explicitly specified, please subscribe to this object
255
+ */
256
+ get projects(): rxjs.Observable<AiiaProjectItemWithAvatar[]>;
257
+ /**
258
+ * [zh]
259
+ * 可讀取最近一次收到的專案列表
260
+ *
261
+ * [en]
262
+ * You can read the list of projects received recently
263
+ */
264
+ get lastProjects(): AiiaProjectItemWithAvatar[];
265
+ /**
266
+ * [zh]
267
+ * 可訂閱,Aiia 的回應字幕
268
+ *
269
+ * [en]
270
+ * Subscribable, Aiia's subtitle of response
271
+ */
272
+ get aiiaSubtitle(): rxjs.Observable<string>;
273
+ /**
274
+ * [zh]
275
+ * 可訂閱,使用者語音輸入的字幕
276
+ *
277
+ * [en]
278
+ * Subscribable, User's subtitle of voice input
279
+ */
280
+ get userSubtitle(): rxjs.Observable<string>;
281
+ /**
282
+ * [zh]
283
+ * 可訂閱,是否有使用者
284
+ *
285
+ * [en]
286
+ * Subscribable, Is there a user
287
+ */
288
+ get guest(): rxjs.Observable<boolean>;
289
+ /**
290
+ * [zh]
291
+ * 是否有使用者
292
+ *
293
+ * [en]
294
+ * Is there a user
295
+ */
296
+ get hasGuest(): boolean;
297
+ /**
298
+ * [zh]
299
+ * 設定音量
300
+ *
301
+ * [en]
302
+ * Setting volume
303
+ *
304
+ * @example```js
305
+ * const sdk = new AiiaSdk()
306
+ * sdk.volume // retrun 0 to 100
307
+ * sdk.volume = 10 // setting voice volume
308
+ * ```
309
+ */
310
+ set volume(val: number);
311
+ get volume(): number;
312
+ constructor(config: AiiaConfig, media: MediaManager);
313
+ /**
314
+ * [zh]
315
+ * 啟動完整服務
316
+ *
317
+ * [en]
318
+ * Start the full service
319
+ */
320
+ start(): void;
321
+ /**
322
+ * Alias for `onDestroy`.
323
+ *
324
+ * [zh]
325
+ * 停止所有服務,釋放資源
326
+ *
327
+ * [en]
328
+ * Stop all services to release resources
329
+ */
330
+ close: () => void;
331
+ /**
332
+ * [zh]
333
+ * 中斷當前對話
334
+ *
335
+ * [en]
336
+ * Interrupt the current conversation
337
+ */
338
+ skip(): void;
339
+ /**
340
+ * [zh]
341
+ * 重置對話記憶
342
+ *
343
+ * [en]
344
+ * Reset conversation memory
345
+ */
346
+ reset(): void;
347
+ /**
348
+ * [zh]
349
+ * 若沒有明確指定 Project 時,請呼叫此方法
350
+ *
351
+ * [en]
352
+ * If no Project is explicitly specified, please execute this method.
353
+ * @param project_id
354
+ */
355
+ chooseProject(project_id: AiiaProjectItemWithAvatar["id"]): void;
356
+ /**
357
+ * [zh]
358
+ * 不同於`this.volume = 0`的調整輸出音量
359
+ *
360
+ * 此方法會暫停麥克風輸入及清除所有音訊資料
361
+ *
362
+ * [en]
363
+ * Unlike `this.volume = 0` which adjusts the output volume,
364
+ *
365
+ * This method will pause mic record and clear all audio data
366
+ */
367
+ mute(): void;
368
+ /**
369
+ * [zh]
370
+ * 恢復聲音訊號資料
371
+ *
372
+ * [en]
373
+ * Restore audio signal data
374
+ */
375
+ unmute(): void;
376
+ /**
377
+ * [zh]
378
+ * 切換畫面上是否顯示 Media Element
379
+ *
380
+ * @property options.camera 相機檢測的元素
381
+ * @property options.audio 聲音檢測的元素
382
+ */
383
+ switchMediaElement(options?: {
384
+ camera?: boolean;
385
+ audio?: boolean | {
386
+ open: boolean;
387
+ mode?: "waveform" | "siri";
388
+ color?: string;
389
+ };
390
+ }): void;
391
+ private behavior;
392
+ private proxyIsStable;
393
+ /**
394
+ * [zh]
395
+ * 停止所有服務,釋放資源
396
+ *
397
+ * [en]
398
+ * Stop all services to release resources
399
+ */
400
+ onDestroy(): void;
401
+ }
402
+
403
+ type BrowserInitOptions = Omit<InitOptions, "webserver" | "port" | "license" | "eyeTrackEnable" | "correction" | "note">;
404
+ declare function initSdk(options?: BrowserInitOptions): AiiaSdk;
405
+
406
+ export { type AiiaProjectItemWithAvatar, type AiiaState, type BrowserInitOptions, type LAYOUT, initSdk };