wtfai 1.8.8 → 1.8.9

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/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Workflow, WorkflowListResponse, DeviceInfo } from '@our-llm/shared/types';
1
+ import type { Workflow, WorkflowListResponse } from '@our-llm/shared/types';
2
2
  import type { ClientConfig, SessionOptions } from './types';
3
3
  import { WorkflowSession } from './session';
4
4
  import { UploadService } from './upload';
@@ -52,8 +52,4 @@ export declare class Wtfai {
52
52
  * 创建工作流会话
53
53
  */
54
54
  createSession(workflowId: string, options?: SessionOptions): WorkflowSession;
55
- /**
56
- * 获取当前详细的设备信息(本地计算)
57
- */
58
- getDeviceInfo(): Promise<DeviceInfo>;
59
55
  }
package/dist/client.js CHANGED
@@ -1,4 +1,3 @@
1
- import { getDeviceInfo } from "@our-llm/shared/fingerprint";
2
1
  import { WorkflowSession } from "./session.js";
3
2
  import { UploadService } from "./upload.js";
4
3
  import { RealtimeService } from "./realtime.js";
@@ -34,9 +33,6 @@ class Wtfai {
34
33
  createSession(workflowId, options) {
35
34
  return new WorkflowSession(workflowId, this.baseUrl, this.uploadService, this.headers, options);
36
35
  }
37
- async getDeviceInfo() {
38
- return getDeviceInfo();
39
- }
40
36
  constructor(config){
41
37
  _define_property(this, "baseUrl", void 0);
42
38
  _define_property(this, "uploadService", void 0);
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ export { WorkflowSession } from './session';
4
4
  export { UploadService } from './upload';
5
5
  export { RealtimeService } from './realtime';
6
6
  export type { ClientConfig, SessionOptions, SessionState, SessionEventListeners, SendInput, UploadParams, UploadImageParams, CompressOptions, WorkflowInfo, ContentPart, ContentAction, } from './types';
7
- export type { SimpleMessage, Workflow, WorkflowConfig, RealtimeEvent, RealtimePresence, RealtimePushDto, } from '@our-llm/shared/types';
7
+ export type { SimpleMessage, Workflow, WorkflowConfig, RealtimeEvent, RealtimePresence, RealtimePushDto, DeviceInfoDetail, DeviceInfoListRequest, UpdateDeviceNameRequest, } from '@our-llm/shared/types';
8
8
  export { Markdown, type MarkdownProps, WorkflowRegistry } from './ui/markdown';
9
9
  export type { WorkflowInfoMapping, WorkflowExportConfig } from './ui/context';
10
10
  export { exportMessages, createExportedMessagesBlob, createMermaidChartExportAdapter, type ChartImageExport, type ChartExportKind, type ChartExportAdapter, type ChartExportAdapterContext, type MessageExportInput, type MessageExportOptions, type ExportedMessage, type ExportedMessagePayload, } from './export';
package/dist/realtime.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { fetchEventSource } from "@microsoft/fetch-event-source";
2
- import { getFingerprint } from "@our-llm/shared/fingerprint";
2
+ import { getCachedDeviceId } from "@our-llm/shared/fingerprint";
3
3
  function _define_property(obj, key, value) {
4
4
  if (key in obj) Object.defineProperty(obj, key, {
5
5
  value: value,
@@ -13,7 +13,7 @@ function _define_property(obj, key, value) {
13
13
  const REALTIME_RECONNECT_INTERVAL = 1000;
14
14
  class RealtimeService {
15
15
  async subscribe(topic, onEvent) {
16
- const deviceId = await getFingerprint();
16
+ const deviceId = await getCachedDeviceId();
17
17
  const controller = new AbortController();
18
18
  const query = `?deviceId=${encodeURIComponent(deviceId)}`;
19
19
  const url = `${this.baseUrl}/workflows/realtime/streams/${topic}${query}`;
package/dist/session.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { SimpleMessage, DeviceInfo } from '@our-llm/shared/types';
1
+ import type { SimpleMessage, DeviceInfoDetail } from '@our-llm/shared/types';
2
2
  import type { SessionOptions, SessionState, SessionEventListeners, SendInput, ListRecordsOptions, ListRecordsResult } from './types';
3
3
  import { UploadService } from './upload';
4
4
  /**
@@ -144,9 +144,17 @@ export declare class WorkflowSession {
144
144
  success: boolean;
145
145
  }>;
146
146
  /**
147
- * 获取当前详细的设备信息(本地计算)
147
+ * 获取当前设备的服务端详情;服务端未上报时回退到本地设备信息。
148
148
  */
149
- getDeviceInfo(): Promise<DeviceInfo>;
149
+ getDeviceInfo(): Promise<DeviceInfoDetail>;
150
+ /**
151
+ * 根据设备 ID 列表获取设备详情
152
+ */
153
+ getDeviceInfos(deviceIds: string[]): Promise<DeviceInfoDetail[]>;
154
+ /**
155
+ * 修改单个设备名称
156
+ */
157
+ updateDeviceName(deviceId: string, name: string): Promise<DeviceInfoDetail>;
150
158
  /**
151
159
  * 发送消息执行工作流
152
160
  */
package/dist/session.js CHANGED
@@ -1,4 +1,4 @@
1
- import { getDeviceInfo, getFingerprint } from "@our-llm/shared/fingerprint";
1
+ import { getCachedDeviceId, getDeviceInfo } from "@our-llm/shared/fingerprint";
2
2
  import { executeWorkflowSSE } from "./sse.js";
3
3
  import { v7 } from "uuid";
4
4
  function _define_property(obj, key, value) {
@@ -374,14 +374,13 @@ class WorkflowSession {
374
374
  }
375
375
  async reportDeviceInfo() {
376
376
  this.assertNotDisposed();
377
- const deviceId = await getFingerprint();
378
- const userAgent = navigator.userAgent;
379
377
  const sessionId = this.state.threadId;
380
378
  if (!sessionId) throw new Error('No active session (missing threadId)');
379
+ const deviceId = await getCachedDeviceId(sessionId);
380
+ const userAgent = navigator.userAgent;
381
381
  const payload = {
382
382
  deviceId,
383
- userAgent,
384
- sessionId
383
+ userAgent
385
384
  };
386
385
  const response = await fetch(`${this.baseUrl}/workflows/device-info`, {
387
386
  method: 'POST',
@@ -396,7 +395,46 @@ class WorkflowSession {
396
395
  }
397
396
  async getDeviceInfo() {
398
397
  this.assertNotDisposed();
399
- return getDeviceInfo();
398
+ const localDeviceInfo = await getDeviceInfo(this.state.threadId);
399
+ const devices = await this.getDeviceInfos([
400
+ localDeviceInfo.deviceId
401
+ ]);
402
+ return devices[0] || {
403
+ deviceId: localDeviceInfo.deviceId,
404
+ userAgent: localDeviceInfo.userAgent,
405
+ createdAt: new Date().toISOString(),
406
+ updatedAt: new Date().toISOString()
407
+ };
408
+ }
409
+ async getDeviceInfos(deviceIds) {
410
+ this.assertNotDisposed();
411
+ const response = await fetch(`${this.baseUrl}/workflows/device-info/list`, {
412
+ method: 'POST',
413
+ headers: {
414
+ 'Content-Type': 'application/json',
415
+ ...this.headers
416
+ },
417
+ body: JSON.stringify({
418
+ deviceIds
419
+ })
420
+ });
421
+ if (!response.ok) throw new Error('Failed to get device info list');
422
+ return response.json();
423
+ }
424
+ async updateDeviceName(deviceId, name) {
425
+ this.assertNotDisposed();
426
+ const response = await fetch(`${this.baseUrl}/workflows/device-info/${encodeURIComponent(deviceId)}/name`, {
427
+ method: 'PUT',
428
+ headers: {
429
+ 'Content-Type': 'application/json',
430
+ ...this.headers
431
+ },
432
+ body: JSON.stringify({
433
+ name
434
+ })
435
+ });
436
+ if (!response.ok) throw new Error('Failed to update device name');
437
+ return response.json();
400
438
  }
401
439
  async send({ parts: inputParts, ...rest }) {
402
440
  this.assertNotDisposed();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wtfai",
3
- "version": "1.8.8",
3
+ "version": "1.8.9",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {