Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
38fe861bca | ||
|
|
fa9108e2d1 |
+13
-46
@@ -12,52 +12,19 @@ import "time"
|
||||
type ActivityCard struct {
|
||||
ID ID `json:"id"`
|
||||
// ProjectID/ConversationID 定位归属;ConversationID 为空表示项目级卡片(远期跨会话收件箱)。
|
||||
ProjectID ID `json:"projectId"`
|
||||
ConversationID ID `json:"conversationId,omitempty"`
|
||||
SourceRunID ID `json:"sourceRunId,omitempty"` // 溯源:产生卡片的 run
|
||||
AnchorMessageID ID `json:"anchorMessageId,omitempty"` // 互定位:出生消息(↙ 定位到对话)
|
||||
Kind CardKind `json:"kind"`
|
||||
Title string `json:"title"`
|
||||
Status CardStatus `json:"status"`
|
||||
Tone string `json:"tone,omitempty"` // ok | warn | danger | info
|
||||
Body []UINode `json:"body,omitempty"`
|
||||
Actions []UIAction `json:"actions,omitempty"` // 走命令总线;未绑定 command 降级为发消息
|
||||
Pinned bool `json:"pinned,omitempty"`
|
||||
Work *WorkCard `json:"work,omitempty"` // optional background-work snapshot; never a foreground approval
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
// WorkCard keeps the complete saved result and an optional, non-blocking next step
|
||||
// on the original task. Reading and answering do not change the result version.
|
||||
type WorkCard struct {
|
||||
Result string `json:"result,omitempty"`
|
||||
ResultVersion int `json:"resultVersion"`
|
||||
ReadVersion int `json:"readVersion"`
|
||||
CompletedAt *time.Time `json:"completedAt,omitempty"`
|
||||
Decision *WorkDecision `json:"decision,omitempty"`
|
||||
}
|
||||
|
||||
type WorkDecision struct {
|
||||
RunID ID `json:"runId,omitempty"` // reserved child identity; reconciles acceptance after restart without rerunning
|
||||
Mode string `json:"mode"` // single | multiple
|
||||
State string `json:"state"` // open | deferred | dispatching | submitted
|
||||
Options []WorkOption `json:"options,omitempty"`
|
||||
SelectedIDs []string `json:"selectedIds,omitempty"`
|
||||
FreeText string `json:"freeText,omitempty"`
|
||||
RespondedAt *time.Time `json:"respondedAt,omitempty"`
|
||||
}
|
||||
|
||||
type WorkOption struct {
|
||||
ID string `json:"id"`
|
||||
Label string `json:"label"`
|
||||
}
|
||||
|
||||
// WorkCardAction is version-fenced. Presentation-only opens never mark a result read.
|
||||
type WorkCardAction struct {
|
||||
ResultVersion int `json:"resultVersion"`
|
||||
SelectedIDs []string `json:"selectedIds,omitempty"`
|
||||
FreeText string `json:"freeText,omitempty"`
|
||||
ProjectID ID `json:"projectId"`
|
||||
ConversationID ID `json:"conversationId,omitempty"`
|
||||
SourceRunID ID `json:"sourceRunId,omitempty"` // 溯源:产生卡片的 run
|
||||
AnchorMessageID ID `json:"anchorMessageId,omitempty"` // 互定位:出生消息(↙ 定位到对话)
|
||||
Kind CardKind `json:"kind"`
|
||||
Title string `json:"title"`
|
||||
Status CardStatus `json:"status"`
|
||||
Tone string `json:"tone,omitempty"` // ok | warn | danger | info
|
||||
Body []UINode `json:"body,omitempty"`
|
||||
Actions []UIAction `json:"actions,omitempty"` // 走命令总线;未绑定 command 降级为发消息
|
||||
Pinned bool `json:"pinned,omitempty"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
type CardKind string
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestWorkCardSurvivesPersistedSnapshot(t *testing.T) {
|
||||
completed := time.Date(2026, 10, 15, 6, 0, 0, 0, time.UTC)
|
||||
card := ActivityCard{ID: "card_work", Status: CardDone, Work: &WorkCard{
|
||||
Result: strings.Repeat("完整结果\n", 200) + "最后一项依据",
|
||||
ResultVersion: 2, ReadVersion: 1, CompletedAt: &completed,
|
||||
Decision: &WorkDecision{Mode: "multiple", State: "submitted", Options: []WorkOption{{ID: "summary", Label: "生成摘要"}},
|
||||
SelectedIDs: []string{"summary"}, FreeText: "请突出关键限制", RespondedAt: &completed},
|
||||
}}
|
||||
data, err := json.Marshal(card)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var restored ActivityCard
|
||||
if err := json.Unmarshal(data, &restored); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if restored.Work == nil || restored.Work.Result != card.Work.Result || restored.Work.ReadVersion != 1 || restored.Work.ResultVersion != 2 {
|
||||
t.Fatalf("complete result or unread version lost: %+v", restored.Work)
|
||||
}
|
||||
if d := restored.Work.Decision; d.State != "submitted" || d.SelectedIDs[0] != "summary" || d.FreeText != "请突出关键限制" || !d.RespondedAt.Equal(completed) {
|
||||
t.Fatalf("decision history lost: %+v", d)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLegacyCardOmitsOptionalWork(t *testing.T) {
|
||||
var legacy ActivityCard
|
||||
if err := json.Unmarshal([]byte(`{"id":"old","status":"resolved","body":[{"type":"markdown","markdown":"保留历史"}]}`), &legacy); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
data, err := json.Marshal(legacy)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if legacy.Work != nil || strings.Contains(string(data), `"work"`) || legacy.Body[0].Markdown != "保留历史" {
|
||||
t.Fatalf("legacy payload changed: %s", data)
|
||||
}
|
||||
}
|
||||
+27
-21
@@ -7,42 +7,42 @@ import (
|
||||
|
||||
// 智能体画像(4.7):核心定制机制,全部数据化、可导入导出。
|
||||
type AgentProfile struct {
|
||||
ID string `json:"id"`
|
||||
Owner string `json:"owner,omitempty"` // 租户;空 = 共享(builtin)
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Builtin bool `json:"builtin,omitempty"`
|
||||
Source string `json:"source,omitempty"` // builtin | plugin | user
|
||||
SystemPrompt string `json:"systemPrompt"`
|
||||
ID string `json:"id"`
|
||||
Owner string `json:"owner,omitempty"` // 租户;空 = 共享(builtin)
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Builtin bool `json:"builtin,omitempty"`
|
||||
Source string `json:"source,omitempty"` // builtin | plugin | user
|
||||
SystemPrompt string `json:"systemPrompt"`
|
||||
// PromptModules 引用提示词库模块 ID(有序;空 = 组装默认基座全集)。
|
||||
// SystemPrompt 兼容保留:非空时作为附加段追加在模块组装结果之后。
|
||||
PromptModules []string `json:"promptModules,omitempty"`
|
||||
Model ModelRoute `json:"model"`
|
||||
Tools ToolPolicy `json:"tools"`
|
||||
Context ContextPolicy `json:"context"`
|
||||
HITL HITLPolicy `json:"hitl"`
|
||||
Budget RunBudget `json:"budget"`
|
||||
Model ModelRoute `json:"model"`
|
||||
Tools ToolPolicy `json:"tools"`
|
||||
Context ContextPolicy `json:"context"`
|
||||
HITL HITLPolicy `json:"hitl"`
|
||||
Budget RunBudget `json:"budget"`
|
||||
}
|
||||
|
||||
// ModelRoute 按用途选择模型(4.7 kind 路由):空串回落到 chat 默认。
|
||||
type ModelRoute struct {
|
||||
Chat string `json:"chat,omitempty"`
|
||||
Chat string `json:"chat,omitempty"`
|
||||
Lightweight string `json:"lightweight,omitempty"`
|
||||
Embedding string `json:"embedding,omitempty"`
|
||||
Rerank string `json:"rerank,omitempty"`
|
||||
Embedding string `json:"embedding,omitempty"`
|
||||
Rerank string `json:"rerank,omitempty"`
|
||||
}
|
||||
|
||||
// ToolPolicy 三清单:allow/deny 决定可见工具,confirm 强制执行前 HITL 确认。
|
||||
// 匹配语义:精确名或前缀通配("http.*" 表示 http 前缀);deny 优先于 allow。
|
||||
type ToolPolicy struct {
|
||||
Allow []string `json:"allow"` // ["*"] 全部
|
||||
Allow []string `json:"allow"` // ["*"] 全部
|
||||
Deny []string `json:"deny,omitempty"`
|
||||
Confirm []string `json:"confirm,omitempty"`
|
||||
}
|
||||
|
||||
// ContextPolicy(4.10):ctxasm 的输入;逐版本增加策略项不动组装器接口。
|
||||
type ContextPolicy struct {
|
||||
MaxHistoryMessages int `json:"maxHistoryMessages"` // 0 = 默认 40
|
||||
MaxHistoryMessages int `json:"maxHistoryMessages"` // 0 = 默认 40
|
||||
SummarizeBeyond bool `json:"summarizeBeyond,omitempty"` // 远期;先存标志
|
||||
MemoryBudgetPct int `json:"memoryBudgetPct,omitempty"` // 注入槽份额上限
|
||||
KnowledgeBudgetPct int `json:"knowledgeBudgetPct,omitempty"`
|
||||
@@ -105,19 +105,25 @@ const (
|
||||
type SettingEffect string
|
||||
|
||||
const (
|
||||
EffectHot SettingEffect = "hot" // 立即生效
|
||||
EffectNewRun SettingEffect = "new-run" // 仅影响新 run
|
||||
EffectHot SettingEffect = "hot" // 立即生效
|
||||
EffectNewRun SettingEffect = "new-run" // 仅影响新 run
|
||||
EffectRestart SettingEffect = "restart" // 需重启
|
||||
)
|
||||
|
||||
// SettingScope 声明设置项的写入归属(提案 2026-10-13-rdm-settings-members-duties-perms-increment P2)。
|
||||
// 空串 = 默认:user 与 project 层可写(向后兼容既有 schema)。
|
||||
// 空串保留旧个人配置兼容,不表示共享项目策略或系统管理资格。
|
||||
type SettingScope string
|
||||
|
||||
const (
|
||||
// SettingScopeSystem 受管项:仅系统管理面(admin)可写;user/project 写入被拒,
|
||||
// 生效链忽略这两层的存量覆盖值。
|
||||
SettingScopeSystem SettingScope = "system"
|
||||
// SettingScopeUser is a private account preference, never a shared project policy.
|
||||
SettingScopeUser SettingScope = "user"
|
||||
// SettingScopeProject is shared business configuration under project authority.
|
||||
SettingScopeProject SettingScope = "project"
|
||||
// SettingScopeProjectPersonal is a private preference within one project.
|
||||
SettingScopeProjectPersonal SettingScope = "project-personal"
|
||||
)
|
||||
|
||||
// SettingDesc 描述一个设置项;设置页按此渲染并标注生效时机(schema 驱动)。
|
||||
@@ -131,7 +137,7 @@ type SettingDesc struct {
|
||||
Options []string `json:"options,omitempty"` // enum
|
||||
Effect SettingEffect `json:"effect"`
|
||||
Secret bool `json:"secret,omitempty"`
|
||||
Scope SettingScope `json:"scope,omitempty"` // 空 = user/project 可写;system = 受管
|
||||
Scope SettingScope `json:"scope,omitempty"` // Empty is legacy personal compatibility; explicit scopes own their write surface.
|
||||
}
|
||||
|
||||
// ManagedPaths 返回 schema 中 scope=system 的键路径(点路径形式)。
|
||||
|
||||
+3
-17
@@ -150,21 +150,7 @@ export interface ActivityCard {
|
||||
sourceRunId?: ID; anchorMessageId?: ID;
|
||||
kind: CardKind; title: string; status: CardStatus; tone?: string;
|
||||
body?: UINode[]; actions?: { id: string; label: string; style?: 'primary' | 'default' | 'danger'; command?: string }[];
|
||||
pinned?: boolean; createdAt: string; updatedAt: string; work?: WorkCard;
|
||||
}
|
||||
|
||||
export interface WorkCard {
|
||||
result?: string; resultVersion: number; readVersion: number; completedAt?: string;
|
||||
decision?: WorkDecision;
|
||||
}
|
||||
export interface WorkDecision {
|
||||
runId?: ID;
|
||||
mode: 'single' | 'multiple'; state: 'open' | 'deferred' | 'dispatching' | 'submitted';
|
||||
options?: { id: string; label: string }[];
|
||||
selectedIds?: string[]; freeText?: string; respondedAt?: string;
|
||||
}
|
||||
export interface WorkCardAction {
|
||||
resultVersion: number; selectedIds?: string[]; freeText?: string;
|
||||
pinned?: boolean; createdAt: string; updatedAt: string;
|
||||
}
|
||||
|
||||
export interface CardPayload { card: ActivityCard }
|
||||
@@ -283,8 +269,8 @@ export interface SettingDesc {
|
||||
default?: unknown; options?: string[];
|
||||
effect: 'hot' | 'new-run' | 'restart';
|
||||
secret?: boolean;
|
||||
/** P2 受管:system = 系统受管项,仅系统管理面可写(用户/项目层拒绝)。 */
|
||||
scope?: 'system';
|
||||
/** Setting ownership; an omitted scope retains legacy personal compatibility. */
|
||||
scope?: 'system' | 'user' | 'project' | 'project-personal';
|
||||
}
|
||||
|
||||
// ---- 插件 ----
|
||||
|
||||
Reference in New Issue
Block a user