Define the core contracts: domain model

Details (original message):
Define the core contracts: domain model, stream events, HITL, profiles, tools, plugins, UI vocabulary, ingest IR, retrieval and memory; golden-sample conformance tests; TS mirror.
This commit is contained in:
weichen
2026-09-29 17:34:58 +00:00
parent f2fcc2f62e
commit 9929d8f8ad
25 changed files with 1585 additions and 2 deletions
+49
View File
@@ -0,0 +1,49 @@
package core
import "encoding/json"
// 工具契约(4.8):内置、声明式 HTTP、插件工具统一走 ToolProvider 形态。
// Parameters 是 JSON Schema(draft-07 子集即可),调用参数按其校验。
type SourceKind string
const (
SourceBuiltin SourceKind = "builtin"
SourcePlugin SourceKind = "plugin"
SourceUser SourceKind = "user"
)
type ToolDesc struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters json.RawMessage `json:"parameters,omitempty"`
Source SourceKind `json:"source"`
PluginID string `json:"pluginId,omitempty"`
HTTP *HTTPToolSpec `json:"http,omitempty"` // 声明式 HTTP 工具(无代码)
}
// HTTPToolSpec:无代码自定义工具(4.8)。模板变量 {{param.x}} 从调用参数注入。
type HTTPToolSpec struct {
Method string `json:"method"`
URL string `json:"url"`
Headers map[string]string `json:"headers,omitempty"`
BodyTemplate string `json:"bodyTemplate,omitempty"` // JSON 模板
AuthRef string `json:"authRef,omitempty"` // 设置中的密钥引用(settings key)
TimeoutMs int `json:"timeoutMs,omitempty"`
// ResultPath 从响应 JSON 中裁剪(jq 点路径);空取整个响应。
ResultPath string `json:"resultPath,omitempty"`
}
type ToolCallRequest struct {
CallID string `json:"callId"`
Name string `json:"name"`
Arguments json.RawMessage `json:"arguments,omitempty"`
}
type ToolCallResult struct {
CallID string `json:"callId"`
Status string `json:"status"` // ok | error
Output string `json:"output,omitempty"`
Truncated bool `json:"truncated,omitempty"`
Artifact *Artifact `json:"artifact,omitempty"` // 超长转工件
}