{ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://hci-demo.local/prompt-envelope.schema.json", "title": "Prompt Envelope Protocol", "description": "Prompt Envelope 协议格式 — 消息由若干带类型的 Segment 组成,每种 Segment 有独立的视觉呈现。", "type": "object", "required": ["version", "messages"], "properties": { "version": { "type": "string", "const": "1.0", "description": "协议版本号" }, "model": { "type": "string", "description": "导出时使用的模型名称" }, "messages": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/Message" } } }, "$defs": { "Message": { "type": "object", "required": ["id", "role", "segments", "timestamp"], "properties": { "id": { "type": "string" }, "role": { "type": "string", "enum": ["system", "user", "assistant", "tool"] }, "segments": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/Segment" } }, "timestamp": { "type": "number", "description": "Unix epoch 毫秒" } } }, "Segment": { "oneOf": [ { "$ref": "#/$defs/TextSegment" }, { "$ref": "#/$defs/StaticVarSegment" }, { "$ref": "#/$defs/SystemPromptSegment" }, { "$ref": "#/$defs/MemorySegment" }, { "$ref": "#/$defs/SkillsSegment" }, { "$ref": "#/$defs/ToolOverviewSegment" }, { "$ref": "#/$defs/ToolCallRequestSegment" }, { "$ref": "#/$defs/ToolCallResultSegment" }, { "$ref": "#/$defs/DocumentSegment" }, { "$ref": "#/$defs/LongTextSegment" }, { "$ref": "#/$defs/MediaSegment" } ] }, "TextSegment": { "type": "object", "required": ["kind", "content"], "properties": { "kind": { "type": "string", "const": "text" }, "content": { "type": "string" } } }, "StaticVarSegment": { "type": "object", "required": ["kind", "name", "value"], "properties": { "kind": { "type": "string", "const": "static_var" }, "name": { "type": "string", "description": "模板变量名" }, "value": { "type": "string", "description": "展开后的值" }, "description": { "type": "string", "description": "简短说明" } } }, "SystemPromptSegment": { "type": "object", "required": ["kind", "content", "collapsed"], "properties": { "kind": { "type": "string", "const": "system_prompt" }, "content": { "type": "string" }, "collapsed": { "type": "boolean" } } }, "MemorySegment": { "type": "object", "required": ["kind", "items", "collapsed"], "properties": { "kind": { "type": "string", "const": "memory" }, "description": { "type": "string" }, "items": { "type": "array", "minItems": 1, "items": { "type": "object", "required": ["title", "content"], "properties": { "title": { "type": "string" }, "content": { "type": "string" } } } }, "collapsed": { "type": "boolean" } } }, "SkillsSegment": { "type": "object", "required": ["kind", "items", "collapsed"], "properties": { "kind": { "type": "string", "const": "skills" }, "description": { "type": "string" }, "items": { "type": "array", "minItems": 1, "items": { "type": "object", "required": ["name", "description"], "properties": { "name": { "type": "string" }, "description": { "type": "string" } } } }, "collapsed": { "type": "boolean" } } }, "ToolOverviewSegment": { "type": "object", "required": ["kind", "items", "collapsed"], "properties": { "kind": { "type": "string", "const": "tool_overview" }, "items": { "type": "array", "minItems": 1, "items": { "type": "object", "required": ["name", "description", "parameters"], "properties": { "name": { "type": "string" }, "description": { "type": "string" }, "parameters": { "type": "string" }, "schema": { "type": "object" } } } }, "collapsed": { "type": "boolean" } } }, "ToolCallRequestSegment": { "type": "object", "required": ["kind", "toolName", "arguments", "collapsed"], "properties": { "kind": { "type": "string", "const": "tool_call_request" }, "toolName": { "type": "string" }, "arguments": { "type": "object" }, "collapsed": { "type": "boolean" } } }, "ToolCallResultSegment": { "type": "object", "required": ["kind", "toolName", "result", "success", "collapsed"], "properties": { "kind": { "type": "string", "const": "tool_call_result" }, "toolName": { "type": "string" }, "result": { "type": "string" }, "success": { "type": "boolean" }, "collapsed": { "type": "boolean" } } }, "DocumentSegment": { "type": "object", "required": ["kind", "fileName", "mimeType", "snippet", "sizeBytes"], "properties": { "kind": { "type": "string", "const": "document" }, "fileName": { "type": "string" }, "mimeType": { "type": "string" }, "snippet": { "type": "string" }, "sizeBytes": { "type": "number" }, "parsedContent": { "type": "string" } } }, "LongTextSegment": { "type": "object", "required": ["kind", "content", "charCount", "collapsed"], "properties": { "kind": { "type": "string", "const": "long_text" }, "content": { "type": "string" }, "charCount": { "type": "number" }, "collapsed": { "type": "boolean" } } }, "MediaSegment": { "type": "object", "required": ["kind", "mediaType", "url"], "properties": { "kind": { "type": "string", "const": "media" }, "mediaType": { "type": "string", "enum": ["image", "audio", "video"] }, "url": { "type": "string" }, "altText": { "type": "string" } } } } }