first commit

This commit is contained in:
zyl
2026-03-06 03:36:12 +08:00
commit 4e32b3193f
64 changed files with 42394 additions and 0 deletions

View File

@@ -0,0 +1,176 @@
<mxfile host="Electron" modified="2024-03-05T10:00:00.000Z" agent="Mozilla/5.0" version="24.0.0" type="device">
<diagram id="sgclaw_arch" name="sgClaw Architecture">
<mxGraphModel dx="1400" dy="900" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1600" pageHeight="900" background="#F4F7F9" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<!-- Swimlanes (Subgraphs) -->
<mxCell id="browser_bg" value="🌐 浏览器侧 (P4+P2)" style="swimlane;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#cbd5e1;strokeWidth=2;fontStyle=1;startSize=36;rounded=1;shadow=1;" vertex="1" parent="1">
<mxGeometry x="160" y="40" width="280" height="460" as="geometry" />
</mxCell>
<mxCell id="sgclaw_bg" value="⚙️ sgClaw AI 引擎进程 (P1a+P1b)" style="swimlane;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#cbd5e1;strokeWidth=2;fontStyle=1;startSize=36;rounded=1;shadow=1;" vertex="1" parent="1">
<mxGeometry x="580" y="40" width="280" height="560" as="geometry" />
</mxCell>
<mxCell id="ext_bg" value="☁️ 远端服务与库 (P3)" style="swimlane;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#cbd5e1;strokeWidth=2;fontStyle=1;startSize=36;dashed=1;rounded=1;shadow=1;" vertex="1" parent="1">
<mxGeometry x="980" y="40" width="280" height="560" as="geometry" />
</mxCell>
<!-- Node: User -->
<mxCell id="user" value="👤 用户操作" style="ellipse;whiteSpace=wrap;html=1;fillColor=#fef9c3;strokeColor=#eab308;strokeWidth=2;fontStyle=1;shadow=1;" vertex="1" parent="1">
<mxGeometry x="20" y="100" width="100" height="60" as="geometry" />
</mxCell>
<!-- Nodes in BROWSER -->
<mxCell id="sidepanel" value="UI: AI 面板 (Vue)" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#eff6ff;strokeColor=#2563eb;strokeWidth=2;fontStyle=1;" vertex="1" parent="browser_bg">
<mxGeometry x="40" y="60" width="200" height="60" as="geometry" />
</mxCell>
<mxCell id="processhost" value="Host: 进程守护" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#eff6ff;strokeColor=#2563eb;strokeWidth=2;fontStyle=1;" vertex="1" parent="browser_bg">
<mxGeometry x="40" y="160" width="200" height="60" as="geometry" />
</mxCell>
<mxCell id="pipelistener" value="IPC: Pipe 监听" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#eff6ff;strokeColor=#2563eb;strokeWidth=2;fontStyle=1;" vertex="1" parent="browser_bg">
<mxGeometry x="40" y="260" width="200" height="60" as="geometry" />
</mxCell>
<mxCell id="cmd" value="Action: CDP 操纵指令" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#eff6ff;strokeColor=#2563eb;strokeWidth=2;fontStyle=1;" vertex="1" parent="browser_bg">
<mxGeometry x="40" y="360" width="200" height="60" as="geometry" />
</mxCell>
<!-- Nodes in SGCLAW -->
<mxCell id="runtime" value="Brain: ReAct 核心循环" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff7ed;strokeColor=#ea580c;strokeWidth=2;fontStyle=1;" vertex="1" parent="sgclaw_bg">
<mxGeometry x="40" y="60" width="200" height="60" as="geometry" />
</mxCell>
<mxCell id="browsertool" value="Tool: Action 封装" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff7ed;strokeColor=#ea580c;strokeWidth=2;fontStyle=1;" vertex="1" parent="sgclaw_bg">
<mxGeometry x="40" y="160" width="200" height="60" as="geometry" />
</mxCell>
<mxCell id="piperw" value="Core: Pipe 双向读写" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff7ed;strokeColor=#ea580c;strokeWidth=2;fontStyle=1;" vertex="1" parent="sgclaw_bg">
<mxGeometry x="40" y="260" width="200" height="60" as="geometry" />
</mxCell>
<mxCell id="memory" value="Mem: 记忆层 (SQLite)" style="shape=cylinder3;boundedLbl=1;backgroundOutline=1;size=10;whiteSpace=wrap;html=1;fillColor=#fff7ed;strokeColor=#ea580c;strokeWidth=2;fontStyle=1;" vertex="1" parent="sgclaw_bg">
<mxGeometry x="40" y="360" width="200" height="60" as="geometry" />
</mxCell>
<mxCell id="skillloader" value="Sandbox: 沙箱加载验签" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff7ed;strokeColor=#ea580c;strokeWidth=2;fontStyle=1;" vertex="1" parent="sgclaw_bg">
<mxGeometry x="40" y="460" width="200" height="60" as="geometry" />
</mxCell>
<!-- Nodes in EXT -->
<mxCell id="llm1" value="LLM: Minimax-M2.5 API" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f0fdf4;strokeColor=#16a34a;strokeWidth=2;fontStyle=1;" vertex="1" parent="ext_bg">
<mxGeometry x="40" y="60" width="200" height="60" as="geometry" />
</mxCell>
<mxCell id="skilldb" value="Skill: 黄金/泛化技能库" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;fillColor=#f0fdf4;strokeColor=#16a34a;strokeWidth=2;fontStyle=1;size=15;" vertex="1" parent="ext_bg">
<mxGeometry x="30" y="460" width="220" height="60" as="geometry" />
</mxCell>
<!-- Edges -->
<!-- User -> SidePanel -->
<mxCell id="e_user_ui" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#64748b;strokeWidth=2;" edge="1" parent="1" source="user" target="sidepanel">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<!-- SidePanel <-> ProcessHost -->
<mxCell id="e_ui_host" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;startArrow=classic;endArrow=classic;strokeColor=#64748b;strokeWidth=2;" edge="1" parent="1" source="sidepanel" target="processhost">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e_ui_host_l" value="Window IPC" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];fillColor=#ffffff;fontStyle=1;fontColor=#475569;" vertex="1" connectable="0" parent="e_ui_host">
<mxGeometry x="-0.1" y="0" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<!-- ProcessHost -> PipeListener -->
<mxCell id="e_host_listener" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#64748b;strokeWidth=2;" edge="1" parent="1" source="processhost" target="pipelistener">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<!-- PipeListener -.-> Cmd -->
<mxCell id="e_listener_cmd" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;dashed=1;strokeColor=#64748b;strokeWidth=2;" edge="1" parent="1" source="pipelistener" target="cmd">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e_listener_cmd_l" value="复用" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];fillColor=#ffffff;fontStyle=1;fontColor=#475569;" vertex="1" connectable="0" parent="e_listener_cmd">
<mxGeometry x="-0.1" y="0" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<!-- Internal SGCLAW Edges -->
<!-- PipeRW <-> BrowserTool -->
<mxCell id="e_piperw_tool" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;startArrow=classic;endArrow=classic;strokeColor=#64748b;strokeWidth=2;" edge="1" parent="1" source="piperw" target="browsertool">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<!-- BrowserTool <-> Runtime -->
<mxCell id="e_tool_runtime" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;startArrow=classic;endArrow=classic;strokeColor=#64748b;strokeWidth=2;" edge="1" parent="1" source="browsertool" target="runtime">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<!-- Runtime -> Memory (Routed around left side) -->
<mxCell id="e_runtime_mem" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#64748b;strokeWidth=2;exitX=0;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="runtime" target="memory">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="600" y="130" />
<mxPoint x="600" y="430" />
</Array>
</mxGeometry>
</mxCell>
<!-- Runtime -> SkillLoader (Routed around right side) -->
<mxCell id="e_runtime_skill" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#64748b;strokeWidth=2;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="runtime" target="skillloader">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="840" y="130" />
<mxPoint x="840" y="530" />
</Array>
</mxGeometry>
</mxCell>
<!-- Cross-Boundary Edges -->
<!-- PipeListener == PipeRW (Critical Path) -->
<mxCell id="e_critical" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;startArrow=none;endArrow=none;strokeColor=#ef4444;strokeWidth=4;" edge="1" parent="1" source="pipelistener" target="piperw">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e_critical_l" value="⚡ 高风险卡点 (STDIO 双工流)" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];fillColor=#fef2f2;strokeColor=#fca5a5;fontColor=#991b1b;fontStyle=1;spacing=4;rounded=1;" vertex="1" connectable="0" parent="e_critical">
<mxGeometry x="0" y="0" relative="1" as="geometry">
<mxPoint y="-15" as="offset" />
</mxGeometry>
</mxCell>
<!-- Runtime <-> LLM1 -->
<mxCell id="e_runtime_llm" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;startArrow=classic;endArrow=classic;strokeColor=#64748b;strokeWidth=2;" edge="1" parent="1" source="runtime" target="llm1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e_runtime_llm_l" value="提示词组装" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];fillColor=#ffffff;fontStyle=1;fontColor=#475569;" vertex="1" connectable="0" parent="e_runtime_llm">
<mxGeometry x="0" y="0" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<!-- SkillLoader -> SkillDB -->
<mxCell id="e_skill_db" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#64748b;strokeWidth=2;" edge="1" parent="1" source="skillloader" target="skilldb">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="e_skill_db_l" value="签名挂载调用" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];fillColor=#ffffff;fontStyle=1;fontColor=#475569;" vertex="1" connectable="0" parent="e_skill_db">
<mxGeometry x="0" y="0" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<!-- BrowserTool -.-> PipeListener (Callback) -->
<mxCell id="e_tool_cb" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;dashed=1;strokeColor=#2563eb;strokeWidth=2;exitX=0;exitY=0.5;exitDx=0;exitDy=0;entryX=1;entryY=0.25;entryDx=0;entryDy=0;" edge="1" parent="1" source="browsertool" target="pipelistener">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="540" y="230" />
<mxPoint x="540" y="315" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="e_tool_cb_l" value="执行结果回调" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];fillColor=#eff6ff;fontColor=#1e3a8a;fontStyle=1;" vertex="1" connectable="0" parent="e_tool_cb">
<mxGeometry x="-0.15" y="0" relative="1" as="geometry">
<mxPoint x="10" y="-12" as="offset" />
</mxGeometry>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>

View File

@@ -0,0 +1,48 @@
graph LR
User(["👤 用户操作"])
subgraph BROWSER["🌐 浏览器侧 (P4+P2)"]
direction TB
SidePanel("UI: AI 面板 (Vue)")
ProcessHost("Host: 进程守护")
PipeListener("IPC: Pipe 监听")
Cmd["Action: CDP 操纵指令"]
SidePanel <-->|"Window IPC"| ProcessHost
ProcessHost --> PipeListener
PipeListener -.->|"复用"| Cmd
end
subgraph SGCLAW["⚙️ sgClaw AI 引擎进程 (P1a+P1b)"]
direction TB
PipeRW("Core: Pipe 双向读写")
BrowserTool("Tool: Action 封装")
Runtime("Brain: ReAct 核心循环")
Memory[("Mem: 记忆层 (SQLite)")]
SkillLoader("Sandbox: 沙箱加载验签")
PipeRW <--> BrowserTool
BrowserTool <--> Runtime
Runtime --> Memory
Runtime --> SkillLoader
end
subgraph EXT["☁️ 远端服务与库 (P3)"]
direction TB
LLM1("LLM: Minimax-M2.5 API")
SkillDB[/"Skill: 黄金/泛化技能库"/]
end
User --> SidePanel
PipeListener == "⚡ 高风险卡点 (STDIO 双工流)" === PipeRW
Runtime <-->|"提示词组装"| LLM1
SkillLoader -->|"签名挂载调用"| SkillDB
BrowserTool -.->|"执行结果回调"| PipeListener
classDef p1 fill:#fff7ed,stroke:#ea580c,stroke-width:2px
classDef p2 fill:#eff6ff,stroke:#2563eb,stroke-width:2px
classDef p3 fill:#f0fdf4,stroke:#16a34a,stroke-width:2px
class PipeRW,BrowserTool,Runtime,Memory,SkillLoader p1
class SidePanel,ProcessHost,PipeListener,Cmd p2
class LLM1,SkillDB p3

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 342 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 37 KiB

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,32 @@
graph TB
subgraph W1["📌 W1 独立开发期 (Day 1-3)"]
direction LR
P1a["P1a 协议层构建"]
P2["P2 内核扩展开发"]
P1b["P1b ReAct框架"]
P3["P3 核心用例设计"]
P4["P4 面板UI开发"]
P1a ~~~ P2 ~~~ P1b ~~~ P3 ~~~ P4
end
CRIT{{"⚠️ W1 末期关键联调 (Day 4-5)\n=====================\nP1a 🤝 P2 联合打通 STDIO Pipe\n(如果阻塞,整个后续测试将无法进行)"}}
subgraph W2["🚀 W2 集成与验收期 (Day 6-10)"]
direction TB
INT1["P1b 🤝 P3\n沙箱能力与用例装载测试"]
INT2["P1a 🤝 P1b\n引擎接入浏览器动作测试"]
INT3["P2 🤝 P4\n前后端 IPC 接口贯通测试"]
TEST["🎯 全链路 E2E 测试\n跑通首批 6 个核心业务场景"]
SHIP["📦 P4 打包发版"]
INT1 --> TEST
INT2 --> TEST
INT3 --> TEST
TEST --> SHIP
end
W1 --> CRIT
CRIT -->|打通后| W2
classDef crit fill:#fef2f2,stroke:#ef4444,stroke-width:2px,color:#991b1b
class CRIT crit

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 23 KiB

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,13 @@
flowchart LR
Input(["💬 用户指令"])
Router{"🔍 引擎意图分析\n语义匹配技能库"}
Simple["⚡ 简单路径\nSingle-Skill Direct\n无 LLM 调用"]
Complex["🧠 复杂路径\nReAct Planning Loop\n动态拆解 + 多轮 LLM"]
Input --> Router
Router -->|"Skill 命中率高\n单一、明确意图"| Simple
Router -->|"无匹配 Skill\n模糊或组合目标"| Complex
style Simple fill:#eff6ff,stroke:#3b82f6,stroke-width:2px,color:#1e3a8a
style Complex fill:#fff7ed,stroke:#f97316,stroke-width:2px,color:#7c2d12
style Router fill:#faf5ff,stroke:#a855f7,stroke-width:2px,color:#6b21a8

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 53 KiB

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,23 @@
sequenceDiagram
autonumber
actor U as 用户
participant UI as UI面板(P4)
participant Core as 引擎(P1a+P1b)
participant Sandbox as Skill沙箱(Deno)
participant Browser as 浏览器内核(P2)
U->>UI: "提取当前页面表格"
UI->>Core: 发送执行请求(含页面上下文)
rect rgb(239, 246, 255)
Note over Core,Sandbox: 语义匹配:命中 TableExtract_Skill跳过大模型
Core->>Sandbox: 加载并 Ed25519 验签 TableExtract_Skill
Sandbox-->>Core: 验签通过JS 沙箱就绪
end
Sandbox->>Browser: 下发 BrowserActionCDP 获取 DOM 结构
Browser-->>Sandbox: 返回页面 HTML / 表格节点
Sandbox-->>Core: Skill 执行完毕,返回结构化数据
Core-->>UI: 格式化结果JSON → 可读表格)
UI-->>U: 界面展示提取结果

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 25 KiB

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,37 @@
sequenceDiagram
autonumber
actor U as 用户
participant UI as UI面板(P4)
participant Core as 引擎(P1a+P1b)
participant LLM as 大模型底座
participant Memory as 记忆系统(L0/L1/L2)
participant Sandbox as Skill沙箱(Deno)
participant Browser as 浏览器内核(P2)
U->>UI: "对比 A 和 B 公司最新财报"
UI->>Core: 发送复杂任务请求
rect rgb(255, 247, 237)
Note over Core,LLM: Think 阶段:大模型拆解目标
Core->>LLM: 意图分析 + 生成执行计划 (Plan)
LLM-->>Core: 返回步骤列表:① 搜 A 财报 → ② 搜 B 财报 → ③ 对比汇总
end
rect rgb(254, 242, 242)
Note over Core,Browser: ReAct 循环:逐步执行,每步评估
loop 针对每个拆解步骤Step 1..N
Core->>Sandbox: Act加载当前步骤对应的 Skill
Sandbox->>Browser: 执行 BrowserAction操作页面
Browser-->>Sandbox: 返回页面反馈Observation
Sandbox-->>Core: Skill 执行结果
Core->>Memory: 写入 L1 短期记忆RingBuffer
Core->>LLM: Critic 评估:当前步骤是否成功?
LLM-->>Core: 决断:继续下一步 / 纠错重试
end
end
Core->>LLM: 汇总所有步骤结果,生成最终报告
LLM-->>Core: 输出多维度财报对比分析
Core->>Memory: 将成功路径写入 L2 长期记忆SQLite
Core-->>UI: 返回完整分析报告
UI-->>U: 界面展示多维度对比结果

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 31 KiB

View File

@@ -0,0 +1,26 @@
{
"theme": "base",
"themeVariables": {
"fontFamily": "PingFang SC, Microsoft YaHei, Arial, sans-serif",
"fontSize": "15px",
"primaryColor": "#ffffff",
"primaryTextColor": "#1e293b",
"primaryBorderColor": "#cbd5e1",
"lineColor": "#64748b",
"secondaryColor": "#f1f5f9",
"tertiaryColor": "#f8fafc"
},
"flowchart": {
"useMaxWidth": false,
"htmlLabels": true,
"curve": "basis",
"nodeSpacing": 50,
"rankSpacing": 50
},
"sequence": {
"useMaxWidth": false,
"actorMargin": 50,
"messageMargin": 30,
"mirrorActors": false
}
}

View File

@@ -0,0 +1,3 @@
{
"args": ["--no-sandbox", "--disable-setuid-sandbox"]
}