@zero-library/chat-copilot 3.1.10 → 3.1.12

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/index.d.mts CHANGED
@@ -55,7 +55,7 @@ interface FileUploadConfig {
55
55
  }
56
56
  interface AgentSpec {
57
57
  model?: ModelConfig;
58
- knowledge?: {
58
+ knowledges?: {
59
59
  items: {
60
60
  id: string;
61
61
  name: string;
@@ -370,6 +370,64 @@ interface ConversationNewTitleEvent {
370
370
  type: 'conversationNewTitle';
371
371
  title: string;
372
372
  }
373
+ interface DisplayMeta {
374
+ label: string;
375
+ value: string;
376
+ }
377
+ interface DisplayKvItem {
378
+ label: string;
379
+ value: string;
380
+ }
381
+ interface DisplayLinkItem {
382
+ title: string;
383
+ url: string;
384
+ summary?: string;
385
+ }
386
+ type DisplayStatusLevel = 'info' | 'success' | 'warning' | 'error';
387
+ type DisplayBlock = {
388
+ kind: 'markdown';
389
+ title?: string;
390
+ content: string;
391
+ } | {
392
+ kind: 'code';
393
+ title?: string;
394
+ content: string;
395
+ lang: string;
396
+ } | {
397
+ kind: 'key_value';
398
+ title?: string;
399
+ items: DisplayKvItem[];
400
+ } | {
401
+ kind: 'links';
402
+ title?: string;
403
+ items: DisplayLinkItem[];
404
+ } | {
405
+ kind: 'status';
406
+ level: DisplayStatusLevel;
407
+ text: string;
408
+ };
409
+ /** 完整展示视图 — ToolCall/ToolResult 事件携带,全量替换语义 */
410
+ interface DisplayView {
411
+ /** 简短标题(文件路径、命令首行等) */
412
+ title: string;
413
+ /** 标题下的一句话摘要 */
414
+ summary?: string;
415
+ /** 通用展示块 */
416
+ blocks?: DisplayBlock[];
417
+ /** 简短元信息 */
418
+ meta?: DisplayMeta[];
419
+ }
420
+ /** 流式展示增量 — ToolCallDelta 事件携带,增量追加语义 */
421
+ interface DisplayDelta {
422
+ /** 标题变更(首次设置或变化时发送,前端直接替换) */
423
+ title?: string;
424
+ /** 内容追加片段(节流后发送,前端追加到末尾) */
425
+ contentAppend?: string;
426
+ /** 流式内容类型 */
427
+ kind?: 'markdown' | 'code' | 'text';
428
+ /** code 类型语言 */
429
+ lang?: string;
430
+ }
373
431
  interface ToolCallEvent {
374
432
  type: 'toolCall';
375
433
  toolCallId?: string;
@@ -382,6 +440,29 @@ interface ToolCallEvent {
382
440
  content?: string;
383
441
  /** 工具调用参数 */
384
442
  arguments?: any;
443
+ /** 完整展示视图(全量替换语义,未实现 display 方法的工具为 null) */
444
+ display?: DisplayView | null;
445
+ /** 执行状态 */
446
+ status?: 'pending' | 'running' | 'success' | 'error';
447
+ /** 该工具是否触发了子智能体(前端动态判断:有 toolCallId 的子消息到达时标记) */
448
+ hasSubAgent?: boolean;
449
+ /** 前端内部标记:是否使用 display 协议渲染 */
450
+ displayProtocol?: boolean;
451
+ }
452
+ interface ToolCallDeltaEvent {
453
+ type: 'toolCallDelta';
454
+ toolCallId?: string;
455
+ toolName?: string | null;
456
+ /** 工具图标 */
457
+ toolIcon?: string;
458
+ /** 工具调用标题 */
459
+ title?: string;
460
+ /** 同一消息中多个工具调用的序号 */
461
+ index?: number;
462
+ /** 增量参数字符串,需追加拼接 */
463
+ argumentsDelta?: string;
464
+ /** 流式展示增量(增量追加语义,无变化时不出现此字段) */
465
+ displayDelta?: DisplayDelta;
385
466
  /** 执行状态 */
386
467
  status?: 'pending' | 'running' | 'success' | 'error';
387
468
  }
@@ -397,10 +478,16 @@ interface ToolResultEvent {
397
478
  content?: string;
398
479
  /** 工具执行结果 */
399
480
  result?: any;
481
+ /** 完整展示视图(结果阶段全量替换语义) */
482
+ display?: DisplayView | null;
400
483
  /** 执行状态 */
401
484
  status?: 'pending' | 'running' | 'success' | 'error';
485
+ /** 是否出错(与 status='error' 始终一致,推荐使用此字段) */
486
+ isError?: boolean;
402
487
  errorMessage?: string;
403
488
  /** 耗时(ms) */
489
+ durationMs?: number;
490
+ /** 兼容旧字段名 */
404
491
  duration?: number;
405
492
  }
406
493
  interface A2uiCommandEvent {
@@ -428,7 +515,7 @@ interface CitationEvent {
428
515
  type: 'citation';
429
516
  citations?: Citation[];
430
517
  }
431
- type MessageEvent = RunStartedEvent | TextEvent | FilesEvent | StepStartedEvent | StepFinishedEvent | StepErrorEvent | RunFinishedEvent | RunStoppedEvent | ConversationNewTitleEvent | ToolCallEvent | ToolResultEvent | RunFailedEvent | A2uiCommandEvent | A2uiSchemaEvent | PlanEvent | CitationEvent;
518
+ type MessageEvent = RunStartedEvent | TextEvent | FilesEvent | StepStartedEvent | StepFinishedEvent | StepErrorEvent | RunFinishedEvent | RunStoppedEvent | ConversationNewTitleEvent | ToolCallEvent | ToolCallDeltaEvent | ToolResultEvent | RunFailedEvent | A2uiCommandEvent | A2uiSchemaEvent | PlanEvent | CitationEvent;
432
519
  /**
433
520
  * 消息类型
434
521
  * 定义智能体和用户之间的消息结构
@@ -460,6 +547,14 @@ interface ConversationMessage {
460
547
  stopFlag?: boolean;
461
548
  /** 是否正在生成中 */
462
549
  generating?: boolean;
550
+ /** 子智能体名称,前端展示用 */
551
+ subAgentName?: string;
552
+ /** 父执行 ID,用于关联到主智能体的执行 */
553
+ parentExecutionId?: string;
554
+ /** 嵌套深度(0=顶层,1=一级子智能体) */
555
+ subAgentDepth?: number;
556
+ /** 父 agent_spawn 工具调用 ID,前端通过此字段将子智能体消息归属到对应工具块 */
557
+ toolCallId?: string;
463
558
  }
464
559
 
465
560
  /**
package/dist/index.d.ts CHANGED
@@ -55,7 +55,7 @@ interface FileUploadConfig {
55
55
  }
56
56
  interface AgentSpec {
57
57
  model?: ModelConfig;
58
- knowledge?: {
58
+ knowledges?: {
59
59
  items: {
60
60
  id: string;
61
61
  name: string;
@@ -370,6 +370,64 @@ interface ConversationNewTitleEvent {
370
370
  type: 'conversationNewTitle';
371
371
  title: string;
372
372
  }
373
+ interface DisplayMeta {
374
+ label: string;
375
+ value: string;
376
+ }
377
+ interface DisplayKvItem {
378
+ label: string;
379
+ value: string;
380
+ }
381
+ interface DisplayLinkItem {
382
+ title: string;
383
+ url: string;
384
+ summary?: string;
385
+ }
386
+ type DisplayStatusLevel = 'info' | 'success' | 'warning' | 'error';
387
+ type DisplayBlock = {
388
+ kind: 'markdown';
389
+ title?: string;
390
+ content: string;
391
+ } | {
392
+ kind: 'code';
393
+ title?: string;
394
+ content: string;
395
+ lang: string;
396
+ } | {
397
+ kind: 'key_value';
398
+ title?: string;
399
+ items: DisplayKvItem[];
400
+ } | {
401
+ kind: 'links';
402
+ title?: string;
403
+ items: DisplayLinkItem[];
404
+ } | {
405
+ kind: 'status';
406
+ level: DisplayStatusLevel;
407
+ text: string;
408
+ };
409
+ /** 完整展示视图 — ToolCall/ToolResult 事件携带,全量替换语义 */
410
+ interface DisplayView {
411
+ /** 简短标题(文件路径、命令首行等) */
412
+ title: string;
413
+ /** 标题下的一句话摘要 */
414
+ summary?: string;
415
+ /** 通用展示块 */
416
+ blocks?: DisplayBlock[];
417
+ /** 简短元信息 */
418
+ meta?: DisplayMeta[];
419
+ }
420
+ /** 流式展示增量 — ToolCallDelta 事件携带,增量追加语义 */
421
+ interface DisplayDelta {
422
+ /** 标题变更(首次设置或变化时发送,前端直接替换) */
423
+ title?: string;
424
+ /** 内容追加片段(节流后发送,前端追加到末尾) */
425
+ contentAppend?: string;
426
+ /** 流式内容类型 */
427
+ kind?: 'markdown' | 'code' | 'text';
428
+ /** code 类型语言 */
429
+ lang?: string;
430
+ }
373
431
  interface ToolCallEvent {
374
432
  type: 'toolCall';
375
433
  toolCallId?: string;
@@ -382,6 +440,29 @@ interface ToolCallEvent {
382
440
  content?: string;
383
441
  /** 工具调用参数 */
384
442
  arguments?: any;
443
+ /** 完整展示视图(全量替换语义,未实现 display 方法的工具为 null) */
444
+ display?: DisplayView | null;
445
+ /** 执行状态 */
446
+ status?: 'pending' | 'running' | 'success' | 'error';
447
+ /** 该工具是否触发了子智能体(前端动态判断:有 toolCallId 的子消息到达时标记) */
448
+ hasSubAgent?: boolean;
449
+ /** 前端内部标记:是否使用 display 协议渲染 */
450
+ displayProtocol?: boolean;
451
+ }
452
+ interface ToolCallDeltaEvent {
453
+ type: 'toolCallDelta';
454
+ toolCallId?: string;
455
+ toolName?: string | null;
456
+ /** 工具图标 */
457
+ toolIcon?: string;
458
+ /** 工具调用标题 */
459
+ title?: string;
460
+ /** 同一消息中多个工具调用的序号 */
461
+ index?: number;
462
+ /** 增量参数字符串,需追加拼接 */
463
+ argumentsDelta?: string;
464
+ /** 流式展示增量(增量追加语义,无变化时不出现此字段) */
465
+ displayDelta?: DisplayDelta;
385
466
  /** 执行状态 */
386
467
  status?: 'pending' | 'running' | 'success' | 'error';
387
468
  }
@@ -397,10 +478,16 @@ interface ToolResultEvent {
397
478
  content?: string;
398
479
  /** 工具执行结果 */
399
480
  result?: any;
481
+ /** 完整展示视图(结果阶段全量替换语义) */
482
+ display?: DisplayView | null;
400
483
  /** 执行状态 */
401
484
  status?: 'pending' | 'running' | 'success' | 'error';
485
+ /** 是否出错(与 status='error' 始终一致,推荐使用此字段) */
486
+ isError?: boolean;
402
487
  errorMessage?: string;
403
488
  /** 耗时(ms) */
489
+ durationMs?: number;
490
+ /** 兼容旧字段名 */
404
491
  duration?: number;
405
492
  }
406
493
  interface A2uiCommandEvent {
@@ -428,7 +515,7 @@ interface CitationEvent {
428
515
  type: 'citation';
429
516
  citations?: Citation[];
430
517
  }
431
- type MessageEvent = RunStartedEvent | TextEvent | FilesEvent | StepStartedEvent | StepFinishedEvent | StepErrorEvent | RunFinishedEvent | RunStoppedEvent | ConversationNewTitleEvent | ToolCallEvent | ToolResultEvent | RunFailedEvent | A2uiCommandEvent | A2uiSchemaEvent | PlanEvent | CitationEvent;
518
+ type MessageEvent = RunStartedEvent | TextEvent | FilesEvent | StepStartedEvent | StepFinishedEvent | StepErrorEvent | RunFinishedEvent | RunStoppedEvent | ConversationNewTitleEvent | ToolCallEvent | ToolCallDeltaEvent | ToolResultEvent | RunFailedEvent | A2uiCommandEvent | A2uiSchemaEvent | PlanEvent | CitationEvent;
432
519
  /**
433
520
  * 消息类型
434
521
  * 定义智能体和用户之间的消息结构
@@ -460,6 +547,14 @@ interface ConversationMessage {
460
547
  stopFlag?: boolean;
461
548
  /** 是否正在生成中 */
462
549
  generating?: boolean;
550
+ /** 子智能体名称,前端展示用 */
551
+ subAgentName?: string;
552
+ /** 父执行 ID,用于关联到主智能体的执行 */
553
+ parentExecutionId?: string;
554
+ /** 嵌套深度(0=顶层,1=一级子智能体) */
555
+ subAgentDepth?: number;
556
+ /** 父 agent_spawn 工具调用 ID,前端通过此字段将子智能体消息归属到对应工具块 */
557
+ toolCallId?: string;
463
558
  }
464
559
 
465
560
  /**