stable-harness 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/docs/0.1.0-p0-runtime-control-plane-plan.zh.md +171 -0
- package/docs/0.1.0-retry-policy.zh.md +87 -0
- package/docs/0.1.0-stable-runtime-development-roadmap.zh.md +393 -0
- package/docs/0.1.0-tool-guard-benchmark.zh.md +42 -0
- package/docs/adapter-contract.md +199 -0
- package/docs/architecture/backend-comparison.md +41 -0
- package/docs/architecture/runtime-events.md +263 -0
- package/docs/architecture/runtime-events.zh.md +248 -0
- package/docs/architecture/system-architecture.zh.md +435 -0
- package/docs/compatibility-matrix.md +139 -0
- package/docs/engineering-rules.md +111 -0
- package/docs/evaluation/0.1.0-bfcl-targeted-model-matrix.zh.md +1632 -0
- package/docs/evaluation/0.1.0-bfcl-targeted-review-matrix.zh.md +1952 -0
- package/docs/evaluation/0.1.0-bfcl-tool-guard.zh.md +1427 -0
- package/docs/granite-tool-calling-comparison.zh.md +206 -0
- package/docs/guides/getting-started.md +126 -0
- package/docs/guides/index.md +40 -0
- package/docs/guides/integration-guide.md +126 -0
- package/docs/guides/operator-runbook.md +153 -0
- package/docs/guides/workspace-authoring.md +212 -0
- package/docs/implementation-blueprint.md +233 -0
- package/docs/memory/0.1.0-memory-design.zh.md +719 -0
- package/docs/memory/0.1.0-step-09-deepagents-native-memory.zh.md +146 -0
- package/docs/memory/0.1.0-step-09-langmem-shaped-provider.zh.md +169 -0
- package/docs/memory/0.1.0-step-09-memory-adapter-projection.zh.md +123 -0
- package/docs/memory/0.1.0-step-09-memory-contract.zh.md +169 -0
- package/docs/memory/0.1.0-step-09-memory-governance-approval.zh.md +143 -0
- package/docs/memory/0.1.0-step-09-memory-lifecycle-hooks.zh.md +150 -0
- package/docs/memory/0.1.0-step-09-memory-maintenance-boundary.zh.md +118 -0
- package/docs/memory/0.1.0-step-09-memory-persistence-boundary.zh.md +118 -0
- package/docs/product/adoption-playbook.md +145 -0
- package/docs/product/market-positioning.md +137 -0
- package/docs/product-boundary.md +258 -0
- package/docs/protocols/http-runtime.md +37 -0
- package/docs/protocols/langgraph-compatible.md +107 -0
- package/docs/protocols/openai-compatible.md +121 -0
- package/docs/tooling/0.1.0-bettercall-tool-quality.zh.md +231 -0
- package/package.json +2 -1
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
# Runtime Event Model 运行时事件模型
|
|
2
|
+
|
|
3
|
+
本文档定义 stable-harness 的事件分层模型。这里列出的名称就是当前物理事件
|
|
4
|
+
schema;不再保留旧事件名兼容层。
|
|
5
|
+
|
|
6
|
+
章节结构:
|
|
7
|
+
|
|
8
|
+
- 大分类:Owner,从 `agent` 开始。
|
|
9
|
+
- 中分类:Category,例如 Signal、Fact、Envelope、View。
|
|
10
|
+
- 小分类:具体 event group,例如 `agent.tool.*`、`runtime.request.*`。
|
|
11
|
+
|
|
12
|
+
本文档里的 `runtime.*` / `agent.*` 是稳定命名空间。`event type` 表示顶层
|
|
13
|
+
runtime event;`payload phase` 表示 `runtime.adapter.event.event.phase`。
|
|
14
|
+
|
|
15
|
+
代码 source of truth:
|
|
16
|
+
|
|
17
|
+
- 顶层 runtime events:`packages/core/src/runtime/events.ts`
|
|
18
|
+
- Trace projection:`packages/core/src/trace.ts`
|
|
19
|
+
- OpenAI-compatible SSE projection:`packages/protocols/src/openai-stream.ts`
|
|
20
|
+
|
|
21
|
+
## 1. Owner: Agent Runtime / Backend Adapter
|
|
22
|
+
|
|
23
|
+
Agent owner 指 upstream agent runtime 或 backend adapter,例如 DeepAgents、
|
|
24
|
+
LangGraph workflow adapter 或未来的 OpenAI Agents SDK / Gemini SDK adapter。
|
|
25
|
+
|
|
26
|
+
stable-harness 不拥有这层的执行语义,只通过 `runtime.adapter.event` envelope
|
|
27
|
+
观察、记录、持久化和投影这些信号。
|
|
28
|
+
|
|
29
|
+
### 1.1 Category: Agent Signals
|
|
30
|
+
|
|
31
|
+
Agent signals 是 upstream/backend 执行过程中的可观察信号。
|
|
32
|
+
|
|
33
|
+
#### 1.1.1 Event Group: `agent.lifecycle.*`
|
|
34
|
+
|
|
35
|
+
| 事件 | payload phase | Owner | 常见字段 | 含义 |
|
|
36
|
+
| --- | --- | --- | --- | --- |
|
|
37
|
+
| `agent.handoff` | `agent.handoff` | backend adapter | `adapter`, `phase`, `modelRef`, `tools`, `subagents` | adapter 接管执行。 |
|
|
38
|
+
|
|
39
|
+
#### 1.1.2 Event Group: `agent.output.*`
|
|
40
|
+
|
|
41
|
+
| 事件 | payload phase | Owner | 常见字段 | 含义 |
|
|
42
|
+
| --- | --- | --- | --- | --- |
|
|
43
|
+
| `agent.output.delta` | `agent.output.delta` | upstream agent runtime | `adapter`, `phase`, `text` | assistant stream delta。 |
|
|
44
|
+
|
|
45
|
+
#### 1.1.3 Event Group: `agent.tool.*`
|
|
46
|
+
|
|
47
|
+
| 事件 | payload phase | Owner | 常见字段 | 含义 |
|
|
48
|
+
| --- | --- | --- | --- | --- |
|
|
49
|
+
| `agent.tool.start` | `agent.tool.start` | upstream / adapter | `adapter`, `phase`, `toolId`, `args` | upstream/adapter 工具调用开始。 |
|
|
50
|
+
| `agent.tool.result` | `agent.tool.result` | upstream / adapter | `adapter`, `phase`, `toolId`, `output`, `error` | upstream/adapter 工具调用完成或失败。 |
|
|
51
|
+
|
|
52
|
+
#### 1.1.4 Event Group: `agent.workflow.*`
|
|
53
|
+
|
|
54
|
+
| 事件 | payload phase | Owner | 常见字段 | 含义 |
|
|
55
|
+
| --- | --- | --- | --- | --- |
|
|
56
|
+
| `agent.langgraph.invoke` | `agent.langgraph.invoke` | upstream workflow runtime | `adapter`, `phase`, `workflowId` | LangGraph workflow invocation 开始。 |
|
|
57
|
+
| `agent.node.completed` | `agent.node.completed` | upstream workflow runtime | `adapter`, `phase`, `workflowId`, `nodeId` | workflow node 完成。 |
|
|
58
|
+
|
|
59
|
+
## 2. Owner: Stable Harness Runtime / Control Plane
|
|
60
|
+
|
|
61
|
+
Stable Harness runtime/control-plane owner 指 stable-harness 自己拥有的事实事件、
|
|
62
|
+
运行契约、memory lifecycle、artifact、tool gateway 和 adapter envelope。
|
|
63
|
+
|
|
64
|
+
这些事件是 store、audit、replay、test 的 source of truth。
|
|
65
|
+
|
|
66
|
+
### 2.1 Category: Runtime Facts
|
|
67
|
+
|
|
68
|
+
Runtime facts 是稳定、类型化、可审计、会写入 run record 的事实事件。
|
|
69
|
+
|
|
70
|
+
#### 2.1.1 Event Group: `runtime.request.*`
|
|
71
|
+
|
|
72
|
+
| 事件 | event type | 必填字段 | 可选字段 | 含义 |
|
|
73
|
+
| --- | --- | --- | --- | --- |
|
|
74
|
+
| `runtime.request.started` | `runtime.request.started` | `requestId`, `sessionId`, `agentId` | | request 开始。 |
|
|
75
|
+
| `runtime.request.completed` | `runtime.request.completed` | `requestId`, `sessionId`, `agentId`, `output` | | request 成功完成。 |
|
|
76
|
+
| `runtime.request.failed` | `runtime.request.failed` | `requestId`, `sessionId`, `agentId`, `error` | | request 失败。 |
|
|
77
|
+
| `runtime.request.cancelled` | `runtime.request.cancelled` | `requestId`, `sessionId`, `agentId` | `reason` | request 被取消。 |
|
|
78
|
+
|
|
79
|
+
#### 2.1.2 Event Group: `runtime.execution.*`
|
|
80
|
+
|
|
81
|
+
| 事件 | event type | 必填字段 | 可选字段 | 含义 |
|
|
82
|
+
| --- | --- | --- | --- | --- |
|
|
83
|
+
| `runtime.execution.contract.failed` | `runtime.execution.contract.failed` | `requestId`, `sessionId`, `agentId`, `reason` | `missingEvidenceTools` | 执行证据契约失败。 |
|
|
84
|
+
|
|
85
|
+
#### 2.1.3 Event Group: `runtime.tool.direct.*`
|
|
86
|
+
|
|
87
|
+
这些事件只表示 stable-harness direct tool request 通过 runtime tool gateway
|
|
88
|
+
执行。它们不表示 agent/upstream 在执行过程中选择了 tool;agent 内部 tool call
|
|
89
|
+
属于 `agent.tool.*` signal。
|
|
90
|
+
|
|
91
|
+
| 事件 | event type | 必填字段 | 可选字段 | 含义 |
|
|
92
|
+
| --- | --- | --- | --- | --- |
|
|
93
|
+
| `runtime.tool.direct.started` | `runtime.tool.direct.started` | `requestId`, `sessionId`, `agentId`, `toolId` | | direct tool request 开始执行。 |
|
|
94
|
+
| `runtime.tool.direct.completed` | `runtime.tool.direct.completed` | `requestId`, `sessionId`, `agentId`, `toolId`, `output` | | direct tool request 执行完成。 |
|
|
95
|
+
|
|
96
|
+
#### 2.1.4 Event Group: `runtime.workflow.*`
|
|
97
|
+
|
|
98
|
+
这些事件的 owner 是 stable-harness workflow runtime。它们作为顶层
|
|
99
|
+
`runtime.workflow.*` fact 发出,不再通过 adapter payload 表达;adapter payload
|
|
100
|
+
只保留 upstream/backend 拥有的 workflow signal,例如 `agent.langgraph.invoke`。
|
|
101
|
+
|
|
102
|
+
| 事件 | event type | 必填字段 | 可选字段 | 含义 |
|
|
103
|
+
| --- | --- | --- | --- | --- |
|
|
104
|
+
| `runtime.workflow.started` | `runtime.workflow.started` | `requestId`, `sessionId`, `agentId`, `workflowId`, `adapter` | | stable-harness workflow execution 开始。 |
|
|
105
|
+
| `runtime.workflow.completed` | `runtime.workflow.completed` | `requestId`, `sessionId`, `agentId`, `workflowId`, `adapter` | | stable-harness workflow execution 完成。 |
|
|
106
|
+
|
|
107
|
+
#### 2.1.5 Event Group: `runtime.artifact.*`
|
|
108
|
+
|
|
109
|
+
| 事件 | event type | 必填字段 | 可选字段 | 含义 |
|
|
110
|
+
| --- | --- | --- | --- | --- |
|
|
111
|
+
| `runtime.artifact.created` | `runtime.artifact.created` | `requestId`, `sessionId`, `agentId`, `artifact` | | artifact 被创建。 |
|
|
112
|
+
|
|
113
|
+
#### 2.1.6 Event Group: `runtime.specDriven.*`
|
|
114
|
+
|
|
115
|
+
这些事件属于 stable-harness 的 spec-driven workflow runtime capability。它们记录
|
|
116
|
+
control-plane 阶段事实和产物,不替代 backend agent execution semantics。
|
|
117
|
+
|
|
118
|
+
| 事件 | event type | 必填字段 | 可选字段 | 含义 |
|
|
119
|
+
| --- | --- | --- | --- | --- |
|
|
120
|
+
| `runtime.specDriven.phase.started` | `runtime.specDriven.phase.started` | `requestId`, `sessionId`, `agentId`, `phaseId` | `workflowId` | spec-driven 阶段开始。 |
|
|
121
|
+
| `runtime.specDriven.phase.blocked` | `runtime.specDriven.phase.blocked` | `requestId`, `sessionId`, `agentId`, `phaseId`, `reason` | `workflowId` | spec-driven 阶段被 gate 或 policy 阻塞。 |
|
|
122
|
+
| `runtime.specDriven.phase.completed` | `runtime.specDriven.phase.completed` | `requestId`, `sessionId`, `agentId`, `phaseId` | `workflowId`, `artifact` | spec-driven 阶段完成。 |
|
|
123
|
+
| `runtime.specDriven.phase.verified` | `runtime.specDriven.phase.verified` | `requestId`, `sessionId`, `agentId`, `phaseId` | `workflowId`, `artifact` | spec-driven 阶段完成验证。 |
|
|
124
|
+
|
|
125
|
+
#### 2.1.7 Event Group: `runtime.skill.*`
|
|
126
|
+
|
|
127
|
+
| 事件 | event type | 必填字段 | 可选字段 | 含义 |
|
|
128
|
+
| --- | --- | --- | --- | --- |
|
|
129
|
+
| `runtime.skill.candidate.created` | `runtime.skill.candidate.created` | `requestId`, `sessionId`, `agentId`, `candidateId`, `name`, `confidence`, `evidenceCount`, `status` | `proposedPath` | skill candidate 被发现。 |
|
|
130
|
+
|
|
131
|
+
### 2.2 Category: Runtime Memory Facts
|
|
132
|
+
|
|
133
|
+
Memory 是 stable-harness runtime/control-plane 能力,所以归入 `runtime.memory.*`。
|
|
134
|
+
|
|
135
|
+
#### 2.2.1 Event Group: `runtime.memory.lifecycle`
|
|
136
|
+
|
|
137
|
+
| 事件 | event type | 必填字段 | 可选字段 | 含义 |
|
|
138
|
+
| --- | --- | --- | --- | --- |
|
|
139
|
+
| `runtime.memory.lifecycle` | `runtime.memory.lifecycle` | `requestId`, `sessionId`, `agentId`, `hook` | | memory lifecycle hook 被触发。 |
|
|
140
|
+
|
|
141
|
+
当前 hook:
|
|
142
|
+
|
|
143
|
+
| Hook | 含义 |
|
|
144
|
+
| --- | --- |
|
|
145
|
+
| `read-before-plan` | planning 前读取 memory。 |
|
|
146
|
+
| `read-before-finalize` | final output 定稿前读取 memory。 |
|
|
147
|
+
| `write-after-run` | run 结束后写入 memory。 |
|
|
148
|
+
|
|
149
|
+
#### 2.2.2 Event Group: `runtime.memory.recall.*`
|
|
150
|
+
|
|
151
|
+
| 事件 | event type | 必填字段 | 可选字段 | 含义 |
|
|
152
|
+
| --- | --- | --- | --- | --- |
|
|
153
|
+
| `runtime.memory.recall.completed` | `runtime.memory.recall.completed` | `requestId`, `sessionId`, `agentId`, `namespace`, `recordIds`, `context` | | memory recall 完成。 |
|
|
154
|
+
|
|
155
|
+
#### 2.2.3 Event Group: `runtime.memory.write.*`
|
|
156
|
+
|
|
157
|
+
| 事件 | event type | 必填字段 | 可选字段 | 含义 |
|
|
158
|
+
| --- | --- | --- | --- | --- |
|
|
159
|
+
| `runtime.memory.candidate.submitted` | `runtime.memory.candidate.submitted` | `requestId`, `sessionId`, `agentId`, `candidate`, `decision` | `record` | memory 写入候选被提交。 |
|
|
160
|
+
| `runtime.memory.approval.requested` | `runtime.memory.approval.requested` | `requestId`, `sessionId`, `agentId`, `approval` | | memory 操作需要 approval。 |
|
|
161
|
+
|
|
162
|
+
#### 2.2.4 Event Group: `runtime.memory.plugin.*`
|
|
163
|
+
|
|
164
|
+
| 事件 | event type | 必填字段 | 可选字段 | 含义 |
|
|
165
|
+
| --- | --- | --- | --- | --- |
|
|
166
|
+
| `runtime.memory.plugin.started` | `runtime.memory.plugin.started` | `requestId`, `sessionId`, `agentId`, `memoryId`, `provider`, `namespace` | | memory plugin 开始。 |
|
|
167
|
+
| `runtime.memory.plugin.completed` | `runtime.memory.plugin.completed` | `requestId`, `sessionId`, `agentId`, `memoryId`, `provider`, `namespace`, `candidateCount` | | memory plugin 完成。 |
|
|
168
|
+
| `runtime.memory.plugin.failed` | `runtime.memory.plugin.failed` | `requestId`, `sessionId`, `agentId`, `memoryId`, `provider`, `namespace`, `error` | | memory plugin 失败。 |
|
|
169
|
+
|
|
170
|
+
#### 2.2.5 Event Group: `runtime.memory.maintenance.*`
|
|
171
|
+
|
|
172
|
+
| 事件 | event type | 必填字段 | 可选字段 | 含义 |
|
|
173
|
+
| --- | --- | --- | --- | --- |
|
|
174
|
+
| `runtime.memory.maintenance.started` | `runtime.memory.maintenance.started` | `requestId`, `sessionId`, `agentId`, `target` | | memory maintenance 开始。 |
|
|
175
|
+
| `runtime.memory.maintenance.completed` | `runtime.memory.maintenance.completed` | `requestId`, `sessionId`, `agentId`, `target`, `operationCount` | | memory maintenance 完成。 |
|
|
176
|
+
| `runtime.memory.maintenance.failed` | `runtime.memory.maintenance.failed` | `requestId`, `sessionId`, `agentId`, `target`, `error` | | memory maintenance 失败。 |
|
|
177
|
+
|
|
178
|
+
### 2.3 Category: Runtime Envelope
|
|
179
|
+
|
|
180
|
+
Envelope 是 stable-harness 拥有的稳定容器;nested payload 由 agent/backend 拥有。
|
|
181
|
+
|
|
182
|
+
#### 2.3.1 Event Group: `runtime.adapter.*`
|
|
183
|
+
|
|
184
|
+
| 事件 | event type | 必填字段 | 可选字段 | 含义 |
|
|
185
|
+
| --- | --- | --- | --- | --- |
|
|
186
|
+
| `runtime.adapter.event` | `runtime.adapter.event` | `requestId`, `sessionId`, `agentId`, `event` | | backend/agent signal 的稳定 envelope。 |
|
|
187
|
+
|
|
188
|
+
## 3. Owner: Stable Harness Views / Protocol
|
|
189
|
+
|
|
190
|
+
Views/protocol owner 指 stable-harness 对 facts 和 signals 做的展示、投影、传输、
|
|
191
|
+
叙事层。它们不替代原始事实,也不创造执行语义。
|
|
192
|
+
|
|
193
|
+
### 3.1 Category: Runtime Trace Views
|
|
194
|
+
|
|
195
|
+
#### 3.1.1 Event Group: `runtime.trace.*`
|
|
196
|
+
|
|
197
|
+
| 逻辑 view | 当前实现 | 来源 | 用途 |
|
|
198
|
+
| --- | --- | --- | --- |
|
|
199
|
+
| `runtime.trace.request` | trace category `request` | `runtime.request.*`, `runtime.execution.contract.failed` | request timeline。 |
|
|
200
|
+
| `runtime.trace.tool.direct` | trace category `tool` | `runtime.tool.direct.started`, `runtime.tool.direct.completed` | direct/gateway tool timeline。 |
|
|
201
|
+
| `runtime.trace.agent.tool` | trace category `adapter` | `runtime.adapter.event` payload `agent.tool.start` / `agent.tool.result` | agent/upstream tool timeline。 |
|
|
202
|
+
| `runtime.trace.adapter` | trace category `adapter` | `runtime.adapter.event` | backend signal timeline。 |
|
|
203
|
+
| `runtime.trace.memory` | trace category `memory` | `runtime.memory.*` | memory timeline。 |
|
|
204
|
+
| `runtime.trace.artifact` | trace category `artifact` | `runtime.artifact.created` | artifact timeline。 |
|
|
205
|
+
| `runtime.trace.spec` | trace category `spec` | `runtime.specDriven.phase.*` | spec-driven phase timeline。 |
|
|
206
|
+
| `runtime.trace.plan` | trace category `plan` | `runtime.adapter.event.traceType: "plan"` | plan/TODO 展示。 |
|
|
207
|
+
| `runtime.trace.delegation` | trace category `delegation` | `runtime.adapter.event.traceType: "delegation"` | delegation 展示。 |
|
|
208
|
+
|
|
209
|
+
### 3.2 Category: Runtime Stream Views
|
|
210
|
+
|
|
211
|
+
#### 3.2.1 Event Group: `runtime.stream.*`
|
|
212
|
+
|
|
213
|
+
| 逻辑 view | 当前实现 | 来源 | 用途 |
|
|
214
|
+
| --- | --- | --- | --- |
|
|
215
|
+
| `runtime.stream.tool.progress` | SSE `stable_harness.tool.progress` | `runtime.tool.direct.*` 或 `agent.tool.*` signal | OpenAI-compatible tool progress stream。 |
|
|
216
|
+
| `runtime.stream.progress.narration` | SSE `stable_harness.progress.narration` | `runtime.progress.narration` | OpenAI-compatible narration stream。 |
|
|
217
|
+
|
|
218
|
+
### 3.3 Category: Runtime Progress Views
|
|
219
|
+
|
|
220
|
+
#### 3.3.1 Event Group: `runtime.progress.*`
|
|
221
|
+
|
|
222
|
+
| 逻辑事件 | 当前实现 | 必填字段 | 可选字段 | 含义 |
|
|
223
|
+
| --- | --- | --- | --- | --- |
|
|
224
|
+
| `runtime.progress.narration` | runtime event | `requestId`, `sessionId`, `agentId`, `message`, `provider`, `sourceEventTypes` | `sourceEventIds`, `model`, `style` | 基于 runtime facts 和 agent signals 生成的人类可读进度说明。 |
|
|
225
|
+
|
|
226
|
+
约束:
|
|
227
|
+
|
|
228
|
+
- narrator 只消费事件,不修改 execution、runtime state、tool result、approval 或 memory decision。
|
|
229
|
+
- narrator 输出必须能追溯到 source events。
|
|
230
|
+
- narrator provider 是可插拔 runtime view provider,支持同步或异步实现;内置 `template` provider。
|
|
231
|
+
- 可通过 `createStableHarnessRuntime({ progressNarration })` 或 workspace `runtime.progress.narration.enabled` 启用。
|
|
232
|
+
- CLI 展示策略是独立 runtime 设置:`runtime.cli.events`。它只控制 CLI 显示,不控制 runtime 是否产生事件。
|
|
233
|
+
- CLI 默认只显示 `runtime.progress.narration`;可用 `include: ["*"]` 打开全部事件。
|
|
234
|
+
|
|
235
|
+
Workspace YAML:
|
|
236
|
+
|
|
237
|
+
```yaml
|
|
238
|
+
spec:
|
|
239
|
+
progress:
|
|
240
|
+
narration:
|
|
241
|
+
enabled: true
|
|
242
|
+
style: concise
|
|
243
|
+
cli:
|
|
244
|
+
events:
|
|
245
|
+
include:
|
|
246
|
+
- runtime.progress.narration
|
|
247
|
+
- runtime.tool.direct.*
|
|
248
|
+
```
|
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
# stable-harness 系统架构
|
|
2
|
+
|
|
3
|
+
`stable-harness` 是 agent 应用的产品运行时和 operator control plane。它不重新发明 agent 执行框架,而是把 YAML workspace 装配成可运行应用,将执行交给 DeepAgents、LangGraph、OpenAI Agents SDK、Gemini SDK 或客户自有框架等上游后端,并在执行外围提供稳定的请求生命周期、事件、审批、治理、记忆、工具网关、协议入口和运维检查能力。
|
|
4
|
+
|
|
5
|
+
## 设计边界
|
|
6
|
+
|
|
7
|
+
核心原则:
|
|
8
|
+
|
|
9
|
+
- 上游框架拥有 agent 执行语义,例如模型调用、subagent 行为、任务工具、workflow engine、backend-native memory 和 sandbox primitive。
|
|
10
|
+
- `stable-harness` 拥有运行时和控制面语义,例如 workspace 装配、request/session/run、event trace、approval、policy、tool gateway、memory lifecycle、artifact、recovery、replay 和 protocol access。
|
|
11
|
+
- 下游 workspace 拥有业务逻辑,例如金融、新闻、Kubernetes、QA、秘书、发布流程等应用域能力。
|
|
12
|
+
- compat 代码只用于迁移,不能成为 native runtime 的设计目标。
|
|
13
|
+
|
|
14
|
+
任何 native 能力都必须来自 typed config、metadata、runtime state、events、policy 或 adapter contract,不能来自 prompt 文本、关键词、测试 fixture 或某个下游 workspace 的失败样例。
|
|
15
|
+
|
|
16
|
+
## 总体构造图
|
|
17
|
+
|
|
18
|
+
```mermaid
|
|
19
|
+
flowchart TB
|
|
20
|
+
subgraph Clients["Client and Operator Surfaces"]
|
|
21
|
+
CLI["CLI: stable-harness start/run"]
|
|
22
|
+
SDK["In-process SDK"]
|
|
23
|
+
HTTP["HTTP Runtime API"]
|
|
24
|
+
OAI["OpenAI-compatible /v1 facade"]
|
|
25
|
+
Future["Future protocols: MCP, ACP, A2A, AG-UI"]
|
|
26
|
+
Operator["Operator Console / Admin API"]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
subgraph Runtime["Stable Runtime Core"]
|
|
30
|
+
Factory["Runtime Factory"]
|
|
31
|
+
Workspace["Compiled Workspace Inventory"]
|
|
32
|
+
Request["Request / Session / Run Lifecycle"]
|
|
33
|
+
Events["Normalized Event Stream"]
|
|
34
|
+
Store["Runtime Store"]
|
|
35
|
+
Inspector["Inspection APIs"]
|
|
36
|
+
Governance["Governance Policy and Approvals"]
|
|
37
|
+
Memory["Memory Lifecycle"]
|
|
38
|
+
Gateway["Tool Gateway"]
|
|
39
|
+
Artifacts["Artifact Store"]
|
|
40
|
+
Recovery["Recovery / Retry / Replay Hooks"]
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
subgraph Adapters["Pluggable Backend Adapters"]
|
|
44
|
+
DeepAgents["DeepAgents Adapter"]
|
|
45
|
+
LangGraph["LangGraph Agent/Graph Adapter"]
|
|
46
|
+
OpenAI["OpenAI Agents SDK Adapter"]
|
|
47
|
+
Gemini["Gemini SDK Adapter"]
|
|
48
|
+
Custom["Customer-owned Adapter"]
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
subgraph WorkspaceFiles["Workspace Files"]
|
|
52
|
+
RuntimeYaml["config/runtime/workspace.yaml"]
|
|
53
|
+
AgentsYaml["config/agents/*.yaml including optional edges"]
|
|
54
|
+
ModelsYaml["config/catalogs/models.yaml"]
|
|
55
|
+
ToolsYaml["config/catalogs/tools.yaml"]
|
|
56
|
+
WorkflowsYaml["config/workflows/*.yaml for explicit control-plane graphs"]
|
|
57
|
+
Resources["resources/tools, skills, files"]
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
CLI --> Factory
|
|
61
|
+
SDK --> Factory
|
|
62
|
+
HTTP --> Request
|
|
63
|
+
OAI --> Request
|
|
64
|
+
Future --> Request
|
|
65
|
+
Operator --> Inspector
|
|
66
|
+
|
|
67
|
+
Factory --> Workspace
|
|
68
|
+
WorkspaceFiles --> Factory
|
|
69
|
+
Request --> Store
|
|
70
|
+
Request --> Events
|
|
71
|
+
Request --> Governance
|
|
72
|
+
Request --> Memory
|
|
73
|
+
Request --> Gateway
|
|
74
|
+
Request --> Recovery
|
|
75
|
+
Request --> Adapters
|
|
76
|
+
Adapters --> Events
|
|
77
|
+
Adapters --> Artifacts
|
|
78
|
+
Gateway --> Resources
|
|
79
|
+
Inspector --> Store
|
|
80
|
+
Inspector --> Events
|
|
81
|
+
Inspector --> Governance
|
|
82
|
+
Inspector --> Memory
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Workspace 装配
|
|
86
|
+
|
|
87
|
+
Workspace 是产品的主要配置面。应用通过 Kubernetes-style YAML 定义 agent、model、tool、skill、memory、adapter、protocol 和 policy。对 LangGraph 这类图后端,用户仍然定义 `Agent`,只在现有 inventory 上追加 `edges`。显式 Workflow 文档保留为控制面图 inventory、检查和迁移入口,不是默认产品概念。运行时启动时只做装配和校验,不把业务意图写进核心代码。
|
|
88
|
+
|
|
89
|
+
```mermaid
|
|
90
|
+
flowchart LR
|
|
91
|
+
Files["Workspace YAML and resources"] --> Loader["workspace-yaml loader"]
|
|
92
|
+
Loader --> Inventory["CompiledWorkspace"]
|
|
93
|
+
Inventory --> Factory["createStableHarnessRuntime(workspaceRoot)"]
|
|
94
|
+
Factory --> ToolGateway["Module Tool Gateway"]
|
|
95
|
+
Factory --> AdapterPolicy["Runtime.spec.adapters"]
|
|
96
|
+
AdapterPolicy --> AdapterFactory["Adapter factories"]
|
|
97
|
+
AdapterFactory --> Runtime["StableHarnessRuntime"]
|
|
98
|
+
ToolGateway --> Runtime
|
|
99
|
+
Inventory --> Runtime
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
装配职责:
|
|
103
|
+
|
|
104
|
+
- `workspace-yaml` 读取 YAML,编译成 `CompiledWorkspace`。
|
|
105
|
+
- root runtime factory 根据 `Runtime.spec.adapters` 或 agent backend 自动选择 adapter。
|
|
106
|
+
- tool gateway 从 workspace tools/resources 中装载工具。
|
|
107
|
+
- protocol 配置保持在 runtime YAML 中,例如 OpenAI-compatible bearer token。
|
|
108
|
+
- unknown adapter 通过显式 factory 注入,避免把客户后端硬编码进核心。
|
|
109
|
+
|
|
110
|
+
## 运行时核心模块
|
|
111
|
+
|
|
112
|
+
```mermaid
|
|
113
|
+
flowchart TB
|
|
114
|
+
Runtime["StableHarnessRuntime"]
|
|
115
|
+
Runtime --> Client["RuntimeClient.request"]
|
|
116
|
+
Runtime --> EventSource["RuntimeEventSource.subscribe"]
|
|
117
|
+
Runtime --> Inspector["RuntimeInspector"]
|
|
118
|
+
Runtime --> Lifecycle["RuntimeLifecycle.cancel/stop"]
|
|
119
|
+
|
|
120
|
+
Client --> RunRecord["RuntimeRunRecord"]
|
|
121
|
+
RunRecord --> States["queued/running/completed/failed/cancelled"]
|
|
122
|
+
RunRecord --> EventList["RuntimeEvent[]"]
|
|
123
|
+
RunRecord --> Output["RuntimeOutput"]
|
|
124
|
+
RunRecord --> ArtifactRecords["RuntimeArtifact[]"]
|
|
125
|
+
|
|
126
|
+
Inspector --> ListRequests["listRequests"]
|
|
127
|
+
Inspector --> ListSessions["listSessions"]
|
|
128
|
+
Inspector --> InspectRequest["inspectRequest"]
|
|
129
|
+
Inspector --> GetRun["getRun"]
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
核心运行时只稳定这些产品概念:
|
|
133
|
+
|
|
134
|
+
- request:一次用户或协议入口提交的工作。
|
|
135
|
+
- session:跨 request 的会话边界。
|
|
136
|
+
- run:请求执行记录,包含状态、输出、错误、事件和 artifact。
|
|
137
|
+
- event:可订阅、可存储、可检查的运行时事件。
|
|
138
|
+
- artifact:运行中产生的稳定产物记录。
|
|
139
|
+
- policy:审批、恢复、重试、记忆、协议等运行时策略。
|
|
140
|
+
|
|
141
|
+
## 请求执行流程
|
|
142
|
+
|
|
143
|
+
```mermaid
|
|
144
|
+
flowchart TD
|
|
145
|
+
Start["runtime.request(input)"] --> Resolve["Resolve agent and backend adapter"]
|
|
146
|
+
Resolve --> CreateRun["Create RuntimeRunRecord"]
|
|
147
|
+
CreateRun --> EmitStart["Emit runtime.request.started"]
|
|
148
|
+
EmitStart --> Kind{"Request kind"}
|
|
149
|
+
|
|
150
|
+
Kind -->|"explicit workflow request"| Workflow["Dispatch to workflow adapter"]
|
|
151
|
+
Kind -->|"direct toolCall"| ToolCall["Invoke tool gateway"]
|
|
152
|
+
Kind -->|"agent request"| MemoryRecall["Run memory recall"]
|
|
153
|
+
|
|
154
|
+
MemoryRecall --> AdapterRun["Call backend adapter"]
|
|
155
|
+
AdapterRun --> Recoverable{"Recoverable adapter error?"}
|
|
156
|
+
Recoverable -->|"yes"| RecoveryPrompt["Build typed recovery request"]
|
|
157
|
+
RecoveryPrompt --> AdapterRun
|
|
158
|
+
Recoverable -->|"no"| ResultCheck["Check result recovery policy"]
|
|
159
|
+
ResultCheck --> NeedsFollowup{"Need follow-up recovery?"}
|
|
160
|
+
NeedsFollowup -->|"yes"| Followup["Call adapter with recovery request"]
|
|
161
|
+
NeedsFollowup -->|"no"| MemoryFinalize["Memory candidate approval / plugin lifecycle"]
|
|
162
|
+
Followup --> MemoryFinalize
|
|
163
|
+
|
|
164
|
+
Workflow --> Complete["Complete run"]
|
|
165
|
+
ToolCall --> Complete
|
|
166
|
+
MemoryFinalize --> Contract["Assert execution contract"]
|
|
167
|
+
Contract --> Complete
|
|
168
|
+
Complete --> EmitComplete["Emit runtime.request.completed"]
|
|
169
|
+
EmitComplete --> Response["Return RuntimeResponse"]
|
|
170
|
+
|
|
171
|
+
AdapterRun --> Failure["Non-recoverable failure"]
|
|
172
|
+
Failure --> EmitFailure["Emit runtime.request.failed"]
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
这个流程的关键限制是:runtime 可以做生命周期、可观测性、恢复策略和最终 contract 检查,但不能用自然语言关键词决定工具、agent 或业务路由。
|
|
176
|
+
|
|
177
|
+
## 请求 Sequence Diagram
|
|
178
|
+
|
|
179
|
+
```mermaid
|
|
180
|
+
sequenceDiagram
|
|
181
|
+
autonumber
|
|
182
|
+
participant Client
|
|
183
|
+
participant Runtime as StableHarnessRuntime
|
|
184
|
+
participant Store as RuntimeStore
|
|
185
|
+
participant Memory as Memory Providers
|
|
186
|
+
participant Adapter as Backend Adapter
|
|
187
|
+
participant Gateway as Tool Gateway
|
|
188
|
+
participant Upstream as Upstream Framework
|
|
189
|
+
|
|
190
|
+
Client->>Runtime: request(input, agentId?, sessionId?)
|
|
191
|
+
Runtime->>Store: createRun(requestId, sessionId, agentId)
|
|
192
|
+
Runtime-->>Client: runtime.request.started event via subscription
|
|
193
|
+
Runtime->>Memory: recall(request, agent, workspace)
|
|
194
|
+
Memory-->>Runtime: runtime memory context
|
|
195
|
+
Runtime->>Adapter: run(workspace, agent, request, memory, toolGateway, emit)
|
|
196
|
+
Adapter->>Upstream: invoke upstream-native agent/workflow
|
|
197
|
+
Upstream->>Gateway: tool call through adapter-provided gateway
|
|
198
|
+
Gateway-->>Runtime: runtime.tool.direct.started / runtime.tool.direct.completed events
|
|
199
|
+
Upstream-->>Adapter: backend result
|
|
200
|
+
Adapter-->>Runtime: RuntimeOutput
|
|
201
|
+
Runtime->>Memory: submit candidates / run lifecycle hooks
|
|
202
|
+
Runtime->>Store: updateRun(completed, output, artifacts)
|
|
203
|
+
Runtime-->>Client: RuntimeResponse
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## Tool Gateway 和治理流程
|
|
207
|
+
|
|
208
|
+
Tool gateway 是稳定运行时的工具执行边界。它负责工具 inventory、参数防护、执行上下文、事件和可插拔实现,但不负责业务路由。
|
|
209
|
+
|
|
210
|
+
```mermaid
|
|
211
|
+
flowchart TD
|
|
212
|
+
Adapter["Backend adapter selected a tool"] --> Gateway["RuntimeToolGateway.invoke"]
|
|
213
|
+
Gateway --> Guard["Argument guard / schema check"]
|
|
214
|
+
Guard --> Policy["Governance policy"]
|
|
215
|
+
Policy --> Approval{"Approval required?"}
|
|
216
|
+
Approval -->|"yes"| Queue["ApprovalQueue"]
|
|
217
|
+
Queue --> Decision{"approve or deny"}
|
|
218
|
+
Decision -->|"deny"| Denied["Emit tool.denied"]
|
|
219
|
+
Decision -->|"approve"| Execute["Execute module/MCP/remote tool"]
|
|
220
|
+
Approval -->|"no"| Execute
|
|
221
|
+
Execute --> Result["ToolGatewayInvokeResult"]
|
|
222
|
+
Result --> Event["Emit runtime.tool.direct.completed or runtime.request.failed"]
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
治理输入只能来自 typed policy、tool metadata、runtime context、approval state 和 request metadata。不能用工具名所属业务域、prompt 关键词或测试期望来改变 native runtime 行为。
|
|
226
|
+
|
|
227
|
+
## Protocol Surfaces
|
|
228
|
+
|
|
229
|
+
协议层是 runtime contract 的外壳,不是 backend adapter。
|
|
230
|
+
|
|
231
|
+
```mermaid
|
|
232
|
+
flowchart LR
|
|
233
|
+
OpenAIClient["OpenAI-compatible client"] --> V1["/v1/models, /v1/capabilities, /v1/chat/completions"]
|
|
234
|
+
V1 --> Map["Map model to workspace agentId"]
|
|
235
|
+
Map --> RuntimeReq["runtime.request(metadata.protocol=openai-compatible)"]
|
|
236
|
+
RuntimeReq --> Runtime["Stable Runtime"]
|
|
237
|
+
|
|
238
|
+
OperatorClient["Operator client"] --> OperatorAPI["Operator API"]
|
|
239
|
+
OperatorAPI --> Inspect["listRequests/listSessions/inspectRequest/getRun"]
|
|
240
|
+
OperatorAPI --> Control["cancel/retry/approve/deny/maintenance"]
|
|
241
|
+
Inspect --> Runtime
|
|
242
|
+
Control --> Runtime
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
OpenAI-compatible `/v1` facade 面向客户端兼容,只暴露小而稳定的 chat-completions 子集。request/session/cancel/approval/run inspection 属于 operator control plane,不应该塞进 `/v1` 兼容协议里。
|
|
246
|
+
|
|
247
|
+
## OpenAI-Compatible Chat Sequence
|
|
248
|
+
|
|
249
|
+
```mermaid
|
|
250
|
+
sequenceDiagram
|
|
251
|
+
autonumber
|
|
252
|
+
participant App as OpenAI-compatible Client
|
|
253
|
+
participant Facade as /v1 Facade
|
|
254
|
+
participant Runtime as Stable Runtime
|
|
255
|
+
participant Adapter as Backend Adapter
|
|
256
|
+
participant ClientStream as SSE Stream
|
|
257
|
+
|
|
258
|
+
App->>Facade: POST /v1/chat/completions
|
|
259
|
+
Facade->>Facade: validate messages and model
|
|
260
|
+
Facade->>Runtime: request(input transcript, agentId=model)
|
|
261
|
+
Runtime->>Adapter: run selected workspace agent
|
|
262
|
+
Adapter-->>Runtime: runtime events and final output
|
|
263
|
+
Runtime-->>Facade: RuntimeResponse
|
|
264
|
+
Facade-->>ClientStream: chat.completion.chunk
|
|
265
|
+
Facade-->>ClientStream: stable_harness.tool.progress events
|
|
266
|
+
Facade-->>ClientStream: data: [DONE]
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
客户端传入的 `tools` 和 `tool_choice` 不应绕过 workspace inventory、governance policy 或 tool gateway。runtime 工具仍由 workspace 和后端 adapter 共同约束。
|
|
270
|
+
|
|
271
|
+
## Adapter 分层
|
|
272
|
+
|
|
273
|
+
```mermaid
|
|
274
|
+
flowchart TB
|
|
275
|
+
StableRequest["Stable RuntimeRequest"] --> Adapter["RuntimeAdapter.run"]
|
|
276
|
+
Adapter --> Translate["Translate to upstream call"]
|
|
277
|
+
Translate --> UpstreamConfig["Pass through backend-native config"]
|
|
278
|
+
UpstreamConfig --> Framework["Upstream framework"]
|
|
279
|
+
Framework --> BackendEvents["Backend progress"]
|
|
280
|
+
BackendEvents --> Normalize["Normalize into RuntimeEvent"]
|
|
281
|
+
Framework --> BackendOutput["Backend output"]
|
|
282
|
+
BackendOutput --> StableOutput["RuntimeOutput"]
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
adapter 可以做:
|
|
286
|
+
|
|
287
|
+
- 将稳定 request 转成上游调用。
|
|
288
|
+
- 传递 upstream-native config。
|
|
289
|
+
- 把上游进度投影成 runtime events。
|
|
290
|
+
- 返回稳定的 `RuntimeOutput` 和 artifacts。
|
|
291
|
+
|
|
292
|
+
adapter 不能做:
|
|
293
|
+
|
|
294
|
+
- 用自然语言关键词路由。
|
|
295
|
+
- 为单个下游应用硬编码工具、领域或 agent。
|
|
296
|
+
- 重新实现上游已有的 planning、delegation、memory、sandbox、workflow engine。
|
|
297
|
+
- 解析 TODO 文本并制造工具调用。
|
|
298
|
+
- 本地 replay upstream custom tool calls。
|
|
299
|
+
|
|
300
|
+
## Agent Graph and Workflow Adapter
|
|
301
|
+
|
|
302
|
+
Agent 是默认用户定义面。DeepAgents Agent 的字段保持不变;LangGraph Agent 只在现有 tools、skills、subagents inventory 上追加 `edges`,由 LangGraph adapter 编译到上游 `StateGraph`。
|
|
303
|
+
|
|
304
|
+
Workflow 是显式控制面 graph inventory,用于检查、迁移或协议需要直接指定 graph 的场景。它引用已有 workspace inventory,不重新定义 agent、tool 或 skill,也不是新的主用户概念。
|
|
305
|
+
|
|
306
|
+
```mermaid
|
|
307
|
+
flowchart TD
|
|
308
|
+
Agent["Agent backend: langgraph + edges"] --> RuntimeAdapter["LangGraph RuntimeAdapter"]
|
|
309
|
+
Request["Explicit RuntimeRequest.workflow"] --> Resolve["Resolve workflowId or typed routeId"]
|
|
310
|
+
Resolve --> Validate["Validate workflow exists in inventory"]
|
|
311
|
+
Validate --> WorkflowAdapter["RuntimeWorkflowAdapter"]
|
|
312
|
+
RuntimeAdapter --> Compile["Compile inventory nodes + edges"]
|
|
313
|
+
WorkflowAdapter --> Compile
|
|
314
|
+
Compile --> LangGraph["LangGraph StateGraph or future backend"]
|
|
315
|
+
LangGraph --> NodeHandler["Injected node handlers/resolvers"]
|
|
316
|
+
NodeHandler --> Result["RuntimeOutput"]
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
Core runtime 只负责 Agent/Workflow inventory、显式 route 表、request lifecycle 和 events。具体 graph 执行语义属于 LangGraph、Microsoft Agent Framework 或其他 workflow backend。
|
|
320
|
+
|
|
321
|
+
## Memory Lifecycle
|
|
322
|
+
|
|
323
|
+
```mermaid
|
|
324
|
+
flowchart LR
|
|
325
|
+
Request["Runtime request"] --> RecallPolicy["Memory recall policy"]
|
|
326
|
+
RecallPolicy --> Provider["Memory provider"]
|
|
327
|
+
Provider --> Context["RuntimeMemoryContext"]
|
|
328
|
+
Context --> Adapter["Backend adapter"]
|
|
329
|
+
Adapter --> Output["RuntimeOutput"]
|
|
330
|
+
Output --> Candidates["Memory candidates"]
|
|
331
|
+
Candidates --> Approval["Governance approval"]
|
|
332
|
+
Approval --> Persist["Memory store / LangMem service"]
|
|
333
|
+
Persist --> Maintenance["Maintenance: compact, backup, export"]
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
`stable-harness` owns memory namespace、persistence policy、recall coordination、approval、maintenance 和 observability。DeepAgents-native memory 或其他 backend-native memory 应通过 adapter passthrough 使用,不在 core 中导出 backend 命名的语义。
|
|
337
|
+
|
|
338
|
+
## Operator Control Plane
|
|
339
|
+
|
|
340
|
+
```mermaid
|
|
341
|
+
flowchart TB
|
|
342
|
+
Operator["Operator"] --> Dashboard["Control Plane Surface"]
|
|
343
|
+
Dashboard --> Requests["Requests and runs"]
|
|
344
|
+
Dashboard --> Sessions["Sessions"]
|
|
345
|
+
Dashboard --> Events["Events and traces"]
|
|
346
|
+
Dashboard --> Approvals["Approval queue"]
|
|
347
|
+
Dashboard --> Memory["Memory records"]
|
|
348
|
+
Dashboard --> Artifacts["Artifacts"]
|
|
349
|
+
Dashboard --> Health["Backend and workspace health"]
|
|
350
|
+
Dashboard --> Maintenance["Maintenance jobs"]
|
|
351
|
+
|
|
352
|
+
Requests --> Actions["cancel / retry / inspect"]
|
|
353
|
+
Approvals --> Review["approve / deny"]
|
|
354
|
+
Maintenance --> Jobs["compact / replay / export / cleanup"]
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
Operator control plane 的目标是让运维视角看到稳定的产品对象:request、session、run、event、approval、artifact、memory 和 health,而不是直接暴露上游 checkpoint 内部结构。
|
|
358
|
+
|
|
359
|
+
## Deployment Shapes
|
|
360
|
+
|
|
361
|
+
```mermaid
|
|
362
|
+
flowchart LR
|
|
363
|
+
subgraph Embedded["Embedded application"]
|
|
364
|
+
App["Customer app"] --> SDK["createStableHarnessRuntime(workspaceRoot)"]
|
|
365
|
+
SDK --> RuntimeA["In-process runtime"]
|
|
366
|
+
end
|
|
367
|
+
|
|
368
|
+
subgraph Service["Standalone service"]
|
|
369
|
+
CLI["stable-harness start -w workspace --port 8642"] --> Server["HTTP / OpenAI-compatible server"]
|
|
370
|
+
Server --> RuntimeB["Runtime instance"]
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
subgraph Future["Managed surfaces"]
|
|
374
|
+
MCP["MCP server"]
|
|
375
|
+
ACP["ACP/A2A"]
|
|
376
|
+
AGUI["AG-UI"]
|
|
377
|
+
MCP --> RuntimeC["Runtime instance"]
|
|
378
|
+
ACP --> RuntimeC
|
|
379
|
+
AGUI --> RuntimeC
|
|
380
|
+
end
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
推荐启动路径:
|
|
384
|
+
|
|
385
|
+
- 嵌入式应用:`createStableHarnessRuntime(workspaceRoot)`,由 workspace YAML 决定 adapter、protocol 和 policy 默认值。
|
|
386
|
+
- 本地或服务化入口:`stable-harness start -w "$PWD" --port 8642 --api-key ...`。
|
|
387
|
+
- OpenAI-compatible 客户端:连接 `http://host:port/v1`,把 `model` 映射为 workspace agent id。
|
|
388
|
+
|
|
389
|
+
## 扩展点
|
|
390
|
+
|
|
391
|
+
| 扩展点 | Owner | 说明 |
|
|
392
|
+
| --- | --- | --- |
|
|
393
|
+
| Runtime adapter | Backend adapter | 接入 DeepAgents、OpenAI Agents SDK、Gemini SDK 或客户框架 |
|
|
394
|
+
| Graph/workflow adapter | Backend adapter | 让 `backend: langgraph` Agent 的 edges 或显式 Workflow 编译到上游图后端 |
|
|
395
|
+
| Tool gateway | Runtime capability | 替换本地 module tool、MCP、remote tool 或参数防护实现 |
|
|
396
|
+
| Memory provider | Runtime capability | 替换 LangMem service、嵌入式 store 或企业记忆服务 |
|
|
397
|
+
| Approval queue | Governance capability | 接入人工审批、企业工单或策略引擎 |
|
|
398
|
+
| Event sink | Runtime capability | 接入日志、trace、SIEM、dashboard |
|
|
399
|
+
| Protocol adapter | Protocol surface | 暴露 CLI、SDK、HTTP、OpenAI-compatible、MCP、ACP/A2A/AG-UI |
|
|
400
|
+
| Artifact store | Runtime capability | 接入本地文件、对象存储、数据库或审计仓库 |
|
|
401
|
+
|
|
402
|
+
## 典型端到端路径
|
|
403
|
+
|
|
404
|
+
```mermaid
|
|
405
|
+
flowchart TD
|
|
406
|
+
User["User or client"] --> Protocol["Protocol surface"]
|
|
407
|
+
Protocol --> Runtime["Stable runtime"]
|
|
408
|
+
Runtime --> Workspace["Workspace inventory"]
|
|
409
|
+
Workspace --> Agent["Selected agent"]
|
|
410
|
+
Agent --> Adapter["Backend adapter"]
|
|
411
|
+
Adapter --> Upstream["Upstream agent framework"]
|
|
412
|
+
Upstream --> ToolNeed{"Tool needed?"}
|
|
413
|
+
ToolNeed -->|"yes"| Gateway["Tool gateway + governance"]
|
|
414
|
+
Gateway --> Tool["Workspace tool / MCP / remote tool"]
|
|
415
|
+
Tool --> Upstream
|
|
416
|
+
ToolNeed -->|"no"| Final["Final backend output"]
|
|
417
|
+
Upstream --> Final
|
|
418
|
+
Final --> Runtime
|
|
419
|
+
Runtime --> Store["Persist run, events, artifacts, memory hooks"]
|
|
420
|
+
Store --> Protocol
|
|
421
|
+
Protocol --> User
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
## 架构守则
|
|
425
|
+
|
|
426
|
+
实现新能力前先分类:
|
|
427
|
+
|
|
428
|
+
- 上游执行语义:adapter passthrough。
|
|
429
|
+
- 产品运行时语义:typed stable capability。
|
|
430
|
+
- 协议兼容需求:protocol adapter。
|
|
431
|
+
- 运营治理需求:governance/control-plane capability。
|
|
432
|
+
- 下游业务逻辑:workspace config、prompt、tool 或 app test。
|
|
433
|
+
- 历史迁移行为:compat,且必须有删除或上移路径。
|
|
434
|
+
|
|
435
|
+
如果一个行为只能解释为“某个 prompt、某个模型、某个业务域、某个测试用例需要”,它不应该进入 native runtime。
|