refactor flows into canonical runtime architecture
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# 步骤与Flow节点化重构开发方案
|
||||
# 步骤与Flow节点化重构开发方案
|
||||
|
||||
## 1. 文档目标
|
||||
|
||||
@@ -19,17 +19,17 @@
|
||||
| --- | --- | --- |
|
||||
| 状态 | `background.js` 里仍有 `currentStep`、`stepStatuses` | 数字步骤同时承担状态、顺序和恢复锚点 |
|
||||
| 协议 | `EXECUTE_STEP`、`STEP_COMPLETE`、`STEP_ERROR`、`SKIP_STEP` | 消息协议仍以数字 step 为核心 |
|
||||
| 定义 | `data/step-definitions.js`、`background/steps/registry.js` | 只有 OpenAI 真正注册,且执行仍按数字 id |
|
||||
| 定义 | `data/step-definitions.js`、`core/flow-kernel/step-registry.js` | 只有 OpenAI 真正注册,且执行仍按数字 id |
|
||||
| UI | `sidepanel/sidepanel.js` 按 step 渲染、发送、跳过 | 侧边栏本质上还是数字步骤面板 |
|
||||
| 内容脚本 | `content/signup-page.js` 按 `message.step` 分支 | 页面驱动逻辑被 step number 绑死 |
|
||||
| 运行态 | `background/runtime-state.js` 已有 `currentNodeId`、`nodeStatuses` | 但仍通过 legacy step 视图回写,双模型并存 |
|
||||
| 外围能力 | `shared/source-registry.js`、`shared/flow-capabilities.js`、`background/mail-rule-registry.js` | 已有抽象,但都还没成为唯一事实来源 |
|
||||
| 内容脚本 | `flows/openai/content/openai-auth.js` 按 `message.step` 分支 | 页面驱动逻辑被 step number 绑死 |
|
||||
| 运行态 | `core/flow-kernel/runtime-state.js` 已有 `currentNodeId`、`nodeStatuses` | 但仍通过 legacy step 视图回写,双模型并存 |
|
||||
| 外围能力 | `core/flow-kernel/source-registry.js`、`core/flow-kernel/flow-capabilities.js`、`background/mail-rule-registry.js` | 已有抽象,但都还没成为唯一事实来源 |
|
||||
|
||||
重点文件里最能说明问题的几个点:
|
||||
|
||||
- `background.js`:`DEFAULT_STATE`、`setStepStatus()`、`skipStep()`、`runAutoSequenceFromStep()`、`getStepRegistryForState()` 仍把数字 step 当主流程。
|
||||
- `background/message-router.js`:`STEP_COMPLETE` / `STEP_ERROR` / `EXECUTE_STEP` / `SKIP_STEP` 还在消息层面锁死 step。
|
||||
- `background/runtime-state.js`:已经有 node 相关字段,但还在做 step 兼容派生。
|
||||
- `core/flow-kernel/runtime-state.js`:已经有 node 相关字段,但还在做 step 兼容派生。
|
||||
- `sidepanel/sidepanel.js`:步骤列表、状态展示、手动执行、跳过、自动运行都还围着 step。
|
||||
- `flows/openai/mail-rules.js`、`background/mail-rule-registry.js`:已经说明“规则可以 flow 化”,但目前只有 OpenAI 在用。
|
||||
|
||||
@@ -164,7 +164,7 @@ node = {
|
||||
type: 'task',
|
||||
order: 20, // 仅用于展示,不参与身份
|
||||
sourceId: 'openai-auth',
|
||||
driverId: 'content/signup-page',
|
||||
driverId: 'flows/openai/content/openai-auth',
|
||||
next: ['fill-password'],
|
||||
retryPolicy: { maxAttempts: 3 },
|
||||
recoveryPolicy: { onFailure: 'restart-node' },
|
||||
@@ -241,11 +241,11 @@ flows/<flowId>/
|
||||
|
||||
### 6.3 content scripts
|
||||
|
||||
`content/signup-page.js` 这类脚本要从“按 step 分支”改成“按 node action / command 分支”。
|
||||
`flows/openai/content/openai-auth.js` 这类脚本要从“按 step 分支”改成“按 node action / command 分支”。
|
||||
|
||||
### 6.4 source / driver
|
||||
|
||||
`shared/source-registry.js` 只负责页面来源、标签页生命周期和注入范围。
|
||||
`core/flow-kernel/source-registry.js` 只负责页面来源、标签页生命周期和注入范围。
|
||||
|
||||
`driverRegistry` 只负责“这个 source 能接什么命令”。
|
||||
|
||||
@@ -378,3 +378,4 @@ flows/<flowId>/
|
||||
- 邮件规则是否只从当前 flow definition 派生。
|
||||
- sidepanel 是否能仅通过 workflow nodes 渲染,不新增全局步骤 switch。
|
||||
- 自动运行、历史和日志是否都能用 `flowId/runId/nodeId` 定位。
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -94,9 +94,9 @@
|
||||
|
||||
文件:
|
||||
|
||||
1. `background/kiro/state.js`
|
||||
2. `background/kiro/desktop-authorize-runner.js`
|
||||
3. `background/kiro/publisher-kiro-rs.js`
|
||||
1. `flows/kiro/background/state.js`
|
||||
2. `flows/kiro/background/desktop-authorize-runner.js`
|
||||
3. `flows/kiro/background/publisher-kiro-rs.js`
|
||||
4. `data/step-definitions.js`
|
||||
|
||||
当前事实:
|
||||
@@ -434,7 +434,7 @@ const FLOW_CONTRIBUTION_ADAPTERS = {
|
||||
};
|
||||
```
|
||||
|
||||
### 4.2 修改 `shared/flow-registry.js`
|
||||
### 4.2 修改 `core/flow-kernel/flow-registry.js`
|
||||
|
||||
新增 capability:
|
||||
|
||||
@@ -449,7 +449,7 @@ supportsAccountContribution: true
|
||||
3. `supportsContributionMode` 仅作为迁移字段映射到 `supportsAccountContribution`。
|
||||
4. 新增 flow 只有在注册 adapter 后才能设置 `supportsAccountContribution: true`。
|
||||
|
||||
### 4.3 修改 `shared/flow-capabilities.js`
|
||||
### 4.3 修改 `core/flow-kernel/flow-capabilities.js`
|
||||
|
||||
处理规则:
|
||||
|
||||
@@ -499,7 +499,7 @@ flowContributionRuntime: {
|
||||
新增文件:
|
||||
|
||||
```text
|
||||
background/kiro/credential-artifact.js
|
||||
flows/kiro/background/credential-artifact.js
|
||||
```
|
||||
|
||||
职责:
|
||||
@@ -515,8 +515,8 @@ background/kiro/credential-artifact.js
|
||||
|
||||
修改位置:
|
||||
|
||||
1. `background/kiro/desktop-authorize-runner.js`
|
||||
2. `background/kiro/publisher-kiro-rs.js`
|
||||
1. `flows/kiro/background/desktop-authorize-runner.js`
|
||||
2. `flows/kiro/background/publisher-kiro-rs.js`
|
||||
3. Kiro runner 调度处
|
||||
|
||||
处理规则:
|
||||
@@ -782,7 +782,7 @@ POLL_FLOW_CONTRIBUTION_STATUS
|
||||
|
||||
开发内容:
|
||||
|
||||
1. 新增 `background/kiro/credential-artifact.js`。
|
||||
1. 新增 `flows/kiro/background/credential-artifact.js`。
|
||||
2. 新增 `background/contribution/adapters/kiro-builder-id.js`。
|
||||
3. 复用 Kiro runtime 产物构建 artifact。
|
||||
4. 增加本地校验。
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# 多注册流程来源与驱动注册设计
|
||||
# 多注册流程来源与驱动注册设计
|
||||
|
||||
本文解决的是另一个会在第二个 flow 接入时立刻爆炸的问题:当前项目虽然有 `tab-runtime`,但“来源 source 是谁、该注入什么脚本、URL family 怎么判定、localhost callback 应该清谁”仍然带着明显的 OpenAI 单流程假设。
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
- `content/utils.js` 的 `detectScriptSource()`
|
||||
- `background/navigation-utils.js` 的 `matchesSourceUrlFamily()`
|
||||
- `background/tab-runtime.js` 的注册表、冲突清理、callback 清理
|
||||
- `core/flow-kernel/tab-runtime.js` 的注册表、冲突清理、callback 清理
|
||||
|
||||
这说明当前的 source 体系不是“可扩展的来源注册表”,而是“OpenAI 时代遗留的 source 命名”。
|
||||
|
||||
@@ -58,10 +58,10 @@ sourceRegistry = {
|
||||
'content/activation-utils.js',
|
||||
'content/utils.js',
|
||||
'content/operation-delay.js',
|
||||
'content/auth-page-recovery.js',
|
||||
'content/phone-country-utils.js',
|
||||
'content/phone-auth.js',
|
||||
'content/signup-page.js',
|
||||
'flows/openai/content/auth-page-recovery.js',
|
||||
'flows/openai/content/phone-country-utils.js',
|
||||
'flows/openai/content/phone-auth.js',
|
||||
'flows/openai/content/openai-auth.js',
|
||||
],
|
||||
cleanupScopes: ['oauth-localhost-callback'],
|
||||
},
|
||||
@@ -81,7 +81,7 @@ sourceRegistry = {
|
||||
label: 'SUB2API 后台',
|
||||
dynamicOnly: true,
|
||||
familyMatcher: 'sub2api-panel-family',
|
||||
injectFiles: ['content/utils.js', 'content/sub2api-panel.js'],
|
||||
injectFiles: ['content/utils.js', 'flows/openai/content/sub2api-panel.js'],
|
||||
},
|
||||
};
|
||||
```
|
||||
@@ -125,7 +125,7 @@ sourceRegistry = {
|
||||
driverRegistry = {
|
||||
'openai-auth': {
|
||||
sourceId: 'openai-auth',
|
||||
driverId: 'content/signup-page',
|
||||
driverId: 'flows/openai/content/openai-auth',
|
||||
commands: [
|
||||
'OPEN_SIGNUP',
|
||||
'SUBMIT_SIGNUP_IDENTIFIER',
|
||||
@@ -244,3 +244,4 @@ callbackRegistry = {
|
||||
- manifest 与动态注入没有统一入口
|
||||
- `content/utils.js` 的默认 source 回退会污染未来 flow
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -77,8 +77,8 @@ flows/
|
||||
- `phone-sms/providers/hero-sms.js`
|
||||
- `phone-sms/providers/five-sim.js`
|
||||
- `phone-sms/providers/registry.js`
|
||||
- `content/phone-auth.js`
|
||||
- `content/phone-country-utils.js`
|
||||
- `flows/openai/content/phone-auth.js`
|
||||
- `flows/openai/content/phone-country-utils.js`
|
||||
- sidepanel 中的接码配置区
|
||||
- 相关测试:`tests/phone-verification-flow.test.js`、`tests/five-sim-provider.test.js`、`tests/sidepanel-phone-verification-settings.test.js`
|
||||
|
||||
|
||||
+2
-2
@@ -7,8 +7,8 @@
|
||||
定义:不离开当前步骤,在当前页面链路内恢复或替换资源。
|
||||
|
||||
典型位置:
|
||||
- `background/steps/fetch-signup-code.js`(步骤 4 页面恢复)
|
||||
- `background/steps/fetch-login-code.js` + `background/verification-flow.js`(步骤 8 邮箱轮询与重发)
|
||||
- `flows/openai/background/steps/fetch-signup-code.js`(步骤 4 页面恢复)
|
||||
- `flows/openai/background/steps/fetch-login-code.js` + `background/verification-flow.js`(步骤 8 邮箱轮询与重发)
|
||||
- `background/phone-verification-flow.js`(步骤 9 号码轮换、重发、回到 add-phone)
|
||||
|
||||
常见动作:
|
||||
|
||||
Reference in New Issue
Block a user