super-agent-sdk 1.0.10 → 1.0.11

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/widget.d.ts CHANGED
@@ -81,6 +81,15 @@ export declare interface CapabilityItem {
81
81
  desc?: string;
82
82
  }
83
83
 
84
+ /** 附件描述:前端直传 NOS(如 @netease-ehr/ui Upload 的 nosUpload onSuccess 结果)提取。 */
85
+ export declare interface ChatAttachment {
86
+ nosKey: string;
87
+ filename: string;
88
+ size?: number;
89
+ mime?: string;
90
+ url?: string;
91
+ }
92
+
84
93
  declare interface ChatEvent {
85
94
  type: "user" | "thinking" | "ai" | "tool_call" | "tool_result" | "done" | "stop" | "error" | "interrupt";
86
95
  content: string;
@@ -98,6 +107,8 @@ declare interface ChatEvent {
98
107
  declare interface ChatOptions {
99
108
  sessionId: string;
100
109
  message: string;
110
+ /** 附件(仅沙箱模式 Agent 支持,其他模式后端返回 400)。需先经直传组件传到 NOS 拿到 nosKey。 */
111
+ attachments?: ChatAttachment[];
101
112
  stream?: boolean;
102
113
  onMessage?: (event: ChatEvent) => void;
103
114
  onError?: (error: Error) => void;
@@ -109,11 +120,15 @@ declare interface ChatOptions {
109
120
  signal?: AbortSignal;
110
121
  }
111
122
 
112
- export declare function ChatProvider({ sdk, hooks, children }: ChatProviderProps): default_2.JSX.Element;
123
+ export declare function ChatProvider({ sdk, hooks, attachmentUploader, nosUpload, children }: ChatProviderProps): default_2.JSX.Element;
113
124
 
114
125
  declare interface ChatProviderProps {
115
126
  sdk: SuperAgentSDK;
116
127
  hooks?: EventHooks;
128
+ /** 附件上传器(mount 配置注入;未配置 = 附件功能关闭) */
129
+ attachmentUploader?: (file: File) => Promise<ChatAttachment>;
130
+ /** 内置直传配置(attachmentUploader 优先) */
131
+ nosUpload?: NosUploadConfig;
117
132
  children: default_2.ReactNode;
118
133
  }
119
134
 
@@ -133,7 +148,11 @@ export declare interface ChatState {
133
148
  hasMore: boolean;
134
149
  conversationsLoading: boolean;
135
150
  messagesLoading: boolean;
136
- sendMessage: (content: string) => void;
151
+ sendMessage: (content: string, attachments?: ChatAttachment[]) => void;
152
+ /** 附件上传器(attachmentUploader 直传 or nosUpload 桥解析后的统一入口;null = 未启用) */
153
+ attachmentUploader: ((file: File) => Promise<ChatAttachment>) | null;
154
+ /** 内置直传配置(@netease-ehr/ui 桥;attachmentUploader 优先) */
155
+ nosUpload: NosUploadConfig | null;
137
156
  stop: () => void;
138
157
  regenerate: () => void;
139
158
  switchConversation: (sessionId: string) => void;
@@ -169,13 +188,19 @@ declare interface ChatWidgetProps extends MountOptions {
169
188
 
170
189
  /**
171
190
  * 底部输入区(样式对齐 hr-for-help inputArea):
172
- * 渐变描边输入框(聚焦/有内容时渐变点亮)+ 发送/停止按钮 + 底部 AI 提示文案。
191
+ * 渐变描边输入框(聚焦/有内容时渐变点亮)+ 附件按钮 + 发送/停止按钮 + 底部 AI 提示文案。
192
+ *
193
+ * 附件(两种启用方式,attachmentUploader 优先):
194
+ * 1. mount({ attachmentUploader }):完全自定义上传函数;
195
+ * 2. mount({ nosUpload: { baseURL } }):SDK 内置 NOS 直传(协议对齐 @netease-ehr/ui,
196
+ * 零依赖该私有包)——nosKey 生成 → /nos/token → 分片直传 → /nos/url。
197
+ * 上传完成的 chip 随消息发送,上传中禁止发送。
173
198
  */
174
199
  export declare function Composer(): default_2.JSX.Element;
175
200
 
176
201
  export declare interface ComposerProps {
177
202
  status: ChatStatus;
178
- onSend: (content: string) => void;
203
+ onSend: (content: string, attachments?: ChatAttachment[]) => void;
179
204
  onStop: () => void;
180
205
  }
181
206
 
@@ -375,6 +400,9 @@ declare type MessagePart = {
375
400
  } | {
376
401
  type: "error";
377
402
  content: string;
403
+ } | {
404
+ type: "attachment";
405
+ attachment: ChatAttachment;
378
406
  } | {
379
407
  type: "interrupt";
380
408
  interrupt: InterruptEvent;
@@ -419,6 +447,26 @@ export declare interface MountOptions {
419
447
  triggerLogo?: string;
420
448
  /** 显示消息时间戳,默认 false(对齐 hr-for-help,不显示时间) */
421
449
  showTimestamp?: boolean;
450
+ /**
451
+ * 附件上传器(完全自定义,优先于 nosUpload):把 File 直传 NOS 并返回 ChatAttachment。
452
+ * 不配置则输入区不显示附件按钮(功能关闭,零影响)。
453
+ */
454
+ attachmentUploader?: (file: File) => Promise<ChatAttachment>;
455
+ /**
456
+ * 内置 NOS 直传(零依赖 @netease-ehr/ui):SDK 内置协议实现
457
+ * (nosKey 生成 → /nos/token → nos-js-sdk 分片直传 → /nos/url),配置即用。
458
+ */
459
+ nosUpload?: NosUploadConfig;
460
+ }
461
+
462
+ /** 内置 NOS 直传配置(协议对齐 @netease-ehr/ui Upload 的 nosUpload 路径) */
463
+ export declare interface NosUploadConfig {
464
+ /** 业务网关(通常与业务系统接口网关一致,如 "/api/e5s",token/url 相对同源请求) */
465
+ baseURL: string;
466
+ /** 网关自定义请求头(鉴权等) */
467
+ headers?: Record<string, string>;
468
+ /** 分片大小(默认 4MB) */
469
+ trunkSize?: number;
422
470
  }
423
471
 
424
472
  /**
@@ -651,7 +699,7 @@ declare interface UseChatReturn {
651
699
  messages: UIMessage[];
652
700
  status: ChatStatus;
653
701
  error: Error | null;
654
- sendMessage: (content: string) => void;
702
+ sendMessage: (content: string, attachments?: ChatAttachment[]) => void;
655
703
  stop: () => void;
656
704
  regenerate: () => void;
657
705
  setMessages: (messages: UIMessage[]) => void;