126 lines
2.6 KiB
TypeScript
126 lines
2.6 KiB
TypeScript
// ============================================================
|
|
// Prompt Envelope Protocol — Type Definitions
|
|
// ============================================================
|
|
|
|
// --- 顶层信封 ---
|
|
export interface PromptEnvelope {
|
|
version: '1.0'
|
|
model?: string // 导出时使用的 model 名称,如 'gpt-4-turbo'
|
|
messages: Message[]
|
|
}
|
|
|
|
// --- 单条消息 ---
|
|
export interface Message {
|
|
id: string
|
|
role: 'system' | 'user' | 'assistant'
|
|
segments: Segment[]
|
|
timestamp: number
|
|
}
|
|
|
|
// --- Segment 联合类型 ---
|
|
export type Segment =
|
|
| TextSegment
|
|
| StaticVarSegment
|
|
| SystemPromptSegment
|
|
| MemorySegment
|
|
| SkillSegment
|
|
| ToolOverviewSegment
|
|
| ToolCallRequestSegment
|
|
| ToolCallResultSegment
|
|
| DocumentSegment
|
|
| LongTextSegment
|
|
| MediaSegment
|
|
|
|
// --- 各 Segment 类型 ---
|
|
|
|
export interface TextSegment {
|
|
kind: 'text'
|
|
content: string
|
|
}
|
|
|
|
export interface StaticVarSegment {
|
|
kind: 'static_var'
|
|
name: string // e.g. "user_name"
|
|
value: string // e.g. "张三"
|
|
}
|
|
|
|
export interface SystemPromptSegment {
|
|
kind: 'system_prompt'
|
|
content: string
|
|
collapsed: boolean // default: true
|
|
}
|
|
|
|
export interface MemorySegment {
|
|
kind: 'memory'
|
|
description?: string // 简短解释 memory 的作用
|
|
items: MemoryItem[]
|
|
collapsed: boolean
|
|
}
|
|
|
|
export interface MemoryItem {
|
|
title: string
|
|
content: string
|
|
}
|
|
|
|
export interface SkillSegment {
|
|
kind: 'skills'
|
|
description?: string // 简短解释 skills 是什么
|
|
items: SkillItem[]
|
|
collapsed: boolean
|
|
}
|
|
|
|
export interface SkillItem {
|
|
name: string
|
|
description: string
|
|
}
|
|
|
|
export interface ToolOverviewSegment {
|
|
kind: 'tool_overview'
|
|
items: ToolItem[]
|
|
collapsed: boolean
|
|
}
|
|
|
|
export interface ToolItem {
|
|
name: string
|
|
description: string
|
|
parameters: string // 人类可读的参数摘要
|
|
schema?: Record<string, unknown> // JSON Schema — 导出时作为 tools[].function.parameters
|
|
}
|
|
|
|
export interface ToolCallRequestSegment {
|
|
kind: 'tool_call_request'
|
|
toolName: string
|
|
arguments: Record<string, unknown>
|
|
collapsed: boolean // default: false
|
|
}
|
|
|
|
export interface ToolCallResultSegment {
|
|
kind: 'tool_call_result'
|
|
toolName: string
|
|
result: string // 摘要文本
|
|
success: boolean
|
|
collapsed: boolean // default: true
|
|
}
|
|
|
|
export interface DocumentSegment {
|
|
kind: 'document'
|
|
fileName: string
|
|
mimeType: string
|
|
snippet: string // 前 200 字符预览
|
|
sizeBytes: number
|
|
}
|
|
|
|
export interface LongTextSegment {
|
|
kind: 'long_text'
|
|
content: string
|
|
charCount: number
|
|
collapsed: boolean // default: true
|
|
}
|
|
|
|
export interface MediaSegment {
|
|
kind: 'media'
|
|
mediaType: 'image' | 'audio' | 'video'
|
|
url: string
|
|
altText?: string
|
|
}
|