@loom-framework/core 0.1.0-alpha.180 → 0.1.0-alpha.181

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.
Files changed (105) hide show
  1. package/builtin-skills/app-skill/SKILL.md +4 -5
  2. package/builtin-skills/app-skill/references/auth.md +79 -79
  3. package/builtin-skills/app-skill/references/events.md +237 -19
  4. package/builtin-skills/app-skill/references/evolution.md +59 -59
  5. package/builtin-skills/app-skill/references/model.md +48 -48
  6. package/builtin-skills/app-skill/references/notification.md +47 -47
  7. package/builtin-skills/app-skill/references/process-builder.md +173 -197
  8. package/builtin-skills/app-skill/references/process.md +274 -163
  9. package/builtin-skills/loom/SKILL.md +17 -10
  10. package/builtin-skills/loom/references/data-model.md +19 -3
  11. package/dist/backend/auth/rbac.js +1 -1
  12. package/dist/backend/auth/rbac.js.map +1 -1
  13. package/dist/backend/events/subscription-service.d.ts +46 -0
  14. package/dist/backend/events/subscription-service.d.ts.map +1 -0
  15. package/dist/backend/events/subscription-service.js +209 -0
  16. package/dist/backend/events/subscription-service.js.map +1 -0
  17. package/dist/backend/index.d.ts +1 -0
  18. package/dist/backend/index.d.ts.map +1 -1
  19. package/dist/backend/index.js +27 -13
  20. package/dist/backend/index.js.map +1 -1
  21. package/dist/backend/lifecycle/manager.d.ts +4 -2
  22. package/dist/backend/lifecycle/manager.d.ts.map +1 -1
  23. package/dist/backend/lifecycle/manager.js +9 -3
  24. package/dist/backend/lifecycle/manager.js.map +1 -1
  25. package/dist/backend/loom-paths.d.ts +3 -1
  26. package/dist/backend/loom-paths.d.ts.map +1 -1
  27. package/dist/backend/loom-paths.js +5 -1
  28. package/dist/backend/loom-paths.js.map +1 -1
  29. package/dist/backend/process/engine.d.ts +15 -1
  30. package/dist/backend/process/engine.d.ts.map +1 -1
  31. package/dist/backend/process/engine.js +79 -23
  32. package/dist/backend/process/engine.js.map +1 -1
  33. package/dist/backend/process/registry.d.ts +44 -9
  34. package/dist/backend/process/registry.d.ts.map +1 -1
  35. package/dist/backend/process/registry.js +208 -40
  36. package/dist/backend/process/registry.js.map +1 -1
  37. package/dist/backend/process/trigger.d.ts +18 -8
  38. package/dist/backend/process/trigger.d.ts.map +1 -1
  39. package/dist/backend/process/trigger.js +86 -32
  40. package/dist/backend/process/trigger.js.map +1 -1
  41. package/dist/backend/routes/ai-config.d.ts.map +1 -1
  42. package/dist/backend/routes/ai-config.js +1 -69
  43. package/dist/backend/routes/ai-config.js.map +1 -1
  44. package/dist/backend/routes/config-writer.d.ts +94 -0
  45. package/dist/backend/routes/config-writer.d.ts.map +1 -0
  46. package/dist/backend/routes/config-writer.js +522 -0
  47. package/dist/backend/routes/config-writer.js.map +1 -0
  48. package/dist/backend/routes/event-routes.d.ts +9 -2
  49. package/dist/backend/routes/event-routes.d.ts.map +1 -1
  50. package/dist/backend/routes/event-routes.js +101 -7
  51. package/dist/backend/routes/event-routes.js.map +1 -1
  52. package/dist/backend/routes/process-routes.d.ts +3 -0
  53. package/dist/backend/routes/process-routes.d.ts.map +1 -1
  54. package/dist/backend/routes/process-routes.js +120 -49
  55. package/dist/backend/routes/process-routes.js.map +1 -1
  56. package/dist/cli/commands/event.d.ts +12 -0
  57. package/dist/cli/commands/event.d.ts.map +1 -0
  58. package/dist/cli/commands/event.js +332 -0
  59. package/dist/cli/commands/event.js.map +1 -0
  60. package/dist/cli/commands/process.d.ts.map +1 -1
  61. package/dist/cli/commands/process.js +82 -44
  62. package/dist/cli/commands/process.js.map +1 -1
  63. package/dist/cli/generators/capability-generator.d.ts.map +1 -1
  64. package/dist/cli/generators/capability-generator.js +28 -32
  65. package/dist/cli/generators/capability-generator.js.map +1 -1
  66. package/dist/cli/helpers/system-page-config.d.ts +1 -1
  67. package/dist/cli/helpers/system-page-config.d.ts.map +1 -1
  68. package/dist/cli/helpers/system-page-config.js +9 -0
  69. package/dist/cli/helpers/system-page-config.js.map +1 -1
  70. package/dist/cli/index.d.ts.map +1 -1
  71. package/dist/cli/index.js +2 -0
  72. package/dist/cli/index.js.map +1 -1
  73. package/dist/cli/templates/event-management-page.d.ts +8 -0
  74. package/dist/cli/templates/event-management-page.d.ts.map +1 -0
  75. package/dist/cli/templates/event-management-page.js +598 -0
  76. package/dist/cli/templates/event-management-page.js.map +1 -0
  77. package/dist/cli/templates/login-page.d.ts +1 -1
  78. package/dist/cli/templates/login-page.js +1 -1
  79. package/dist/cli/templates/model-management-page.d.ts +1 -1
  80. package/dist/cli/templates/model-management-page.js +1 -1
  81. package/dist/cli/templates/notification-center-page.d.ts +1 -1
  82. package/dist/cli/templates/notification-center-page.js +1 -1
  83. package/dist/cli/templates/notification-detail-page.d.ts +1 -1
  84. package/dist/cli/templates/notification-detail-page.js +1 -1
  85. package/dist/cli/templates/process-management-page.d.ts +1 -1
  86. package/dist/cli/templates/process-management-page.js +1 -1
  87. package/dist/cli/templates/skill-management-page.d.ts +1 -1
  88. package/dist/cli/templates/skill-management-page.js +1 -1
  89. package/dist/cli/templates/user-management-page.d.ts +1 -1
  90. package/dist/cli/templates/user-management-page.js +1 -1
  91. package/dist/config.d.ts +327 -11
  92. package/dist/config.d.ts.map +1 -1
  93. package/dist/config.js +26 -7
  94. package/dist/config.js.map +1 -1
  95. package/dist/index.d.ts +1 -0
  96. package/dist/index.d.ts.map +1 -1
  97. package/dist/index.js.map +1 -1
  98. package/dist/types/event.d.ts +6 -0
  99. package/dist/types/event.d.ts.map +1 -1
  100. package/dist/types/index.d.ts +1 -1
  101. package/dist/types/index.d.ts.map +1 -1
  102. package/dist/types/process.d.ts +45 -7
  103. package/dist/types/process.d.ts.map +1 -1
  104. package/package.json +1 -1
  105. package/builtin-skills/app-skill/references/process-metrics.md +0 -93
@@ -1,90 +1,90 @@
1
- # Process Evolution Guide
1
+ # Process 演化指南
2
2
 
3
- ## Overview
3
+ ## 概述
4
4
 
5
- Process Evolution is the practice of iteratively improving automated processes based on execution results. Loom provides the tooling (logs, metrics) for AI to analyze and optimize processes over time.
5
+ Process 演化是基于执行结果持续改进自动化流程的实践。Loom 提供工具(日志、指标)供 AI 随时间分析和优化流程。
6
6
 
7
- ## How Evolution Works
7
+ ## 演化工作流程
8
8
 
9
- 1. **Monitor**: Review execution logs and metrics
10
- 2. **Analyze**: Identify patterns, failures, and optimization opportunities
11
- 3. **Decide**: Determine what to change (prompt, trigger, references)
12
- 4. **Apply**: Update the process definition or PROCESS.md
13
- 5. **Verify**: Monitor subsequent runs for improvement
9
+ 1. **监控**:查看执行日志和指标
10
+ 2. **分析**:识别模式、失败原因和优化机会
11
+ 3. **决策**:确定需要变更的内容(prompttriggerreferences
12
+ 4. **执行**:更新流程定义或 PROCESS.md
13
+ 5. **验证**:监控后续运行以确认改进效果
14
14
 
15
- ## Reading Metrics
15
+ ## 读取指标
16
16
 
17
17
  ```bash
18
- # Check recent logs
18
+ # 查看最近日志
19
19
  loom process logs <name> --limit 20
20
20
 
21
- # View process status
21
+ # 查看 process 状态
22
22
  loom process status <name>
23
23
  ```
24
24
 
25
- ### Key Indicators
25
+ ### 关键指标
26
26
 
27
- | Metric | Good | Needs Improvement |
28
- |--------|------|-------------------|
29
- | Success rate | > 95% | < 80% |
30
- | Avg duration | Stable or decreasing | Increasing trend |
31
- | Timeout rate | 0% | > 5% |
32
- | Error patterns | Unique errors | Repeated same error |
27
+ | 指标 | 良好 | 需要改进 |
28
+ |------|------|----------|
29
+ | 成功率 | > 95% | < 80% |
30
+ | 平均耗时 | 稳定或下降 | 上升趋势 |
31
+ | 超时率 | 0% | > 5% |
32
+ | 错误模式 | 错误各不相同 | 同一错误反复出现 |
33
33
 
34
- ## Evolution Strategies
34
+ ## 演化策略
35
35
 
36
- ### Prompt Optimization
36
+ ### Prompt 优化
37
37
 
38
- If a process frequently fails or produces low-quality results:
38
+ 如果流程频繁失败或产生低质量结果:
39
39
 
40
- 1. Read the current prompt: `loom process export <name>`
41
- 2. Analyze failure patterns in logs
42
- 3. Make the prompt more specific:
43
- - Add constraints ("Output must be JSON")
44
- - Add examples ("Here's a good output: ...")
45
- - Add error handling instructions
46
- 4. Update: `loom process export <name>` → edit → API update
40
+ 1. 读取当前 prompt:`loom process export <name>`
41
+ 2. 分析日志中的失败模式
42
+ 3. prompt 更具体:
43
+ - 添加约束("输出必须为 JSON"
44
+ - 添加示例("好的输出示例:..."
45
+ - 添加错误处理指令
46
+ 4. 更新:`loom process export <name>` → 编辑 → API 更新
47
47
 
48
- ### Trigger Adjustment
48
+ ### Trigger 调整
49
49
 
50
- If a process runs too often or too rarely:
50
+ 如果流程运行过于频繁或过少:
51
51
 
52
- - Adjust cron frequency
53
- - Add `--event-debounce` for bursty events
54
- - Add `--event-filter` for selective triggering
52
+ - 调整 cron 频率
53
+ - 通过 `loom event subscribe/unsubscribe` 管理事件订阅
54
+ - 通过 `loom event subscribe --debounce --filter` 添加防抖或过滤
55
55
 
56
56
  ```bash
57
- # Increase debounce for bursty events
58
- loom process update <name> --event-debounce 5000
57
+ # 对突发事件添加防抖订阅
58
+ loom event subscribe "data:update:*" --handler process --process <name> --debounce 5000
59
59
 
60
- # Add filter to only trigger on specific conditions
61
- loom process update <name> --event-filter '{"status":"urgent"}'
60
+ # 添加过滤条件,仅在特定条件下触发
61
+ loom event subscribe "data:update:tasks" --handler process --process <name> --filter '{"status":"urgent"}'
62
62
  ```
63
63
 
64
- ### Reference Updates
64
+ ### Reference 更新
65
65
 
66
- For full processes, update reference files:
67
- - Outdated API docsreplace with current
68
- - Missing context add new reference files
69
- - Unnecessary references remove to reduce prompt size
66
+ 对于完整流程,更新引用文件:
67
+ - 过时的 API 文档替换为最新版本
68
+ - 缺少上下文添加新的 reference 文件
69
+ - 不必要的引用移除以减少 prompt 大小
70
70
 
71
- ## Safety Constraints
71
+ ## 安全约束
72
72
 
73
- Evolution is limited to these safe operations:
74
- - **Notify**: Send alerts via events
75
- - **Data write**: Create/update records via `loom data` CLI
76
- - **Process update**: Modify process definitions via CLI
73
+ 演化仅限于以下安全操作:
74
+ - **通知**:通过事件发送告警
75
+ - **数据写入**:通过 `loom data` CLI 创建/更新记录
76
+ - **Process 更新**:通过 CLI 修改流程定义
77
77
 
78
- Evolution MUST NOT:
79
- - Delete data without explicit user approval
80
- - Modify other processes without user consent
81
- - Change authentication or authorization settings
82
- - Execute shell commands outside the sandbox
78
+ 演化严禁:
79
+ - 未经用户明确批准删除数据
80
+ - 未经用户同意修改其他流程
81
+ - 更改认证或授权设置
82
+ - 在沙箱外执行 shell 命令
83
83
 
84
- ## Monitoring Checklist
84
+ ## 监控清单
85
85
 
86
- After applying evolution changes:
87
- 1. Run manually: `loom process run <name>`
88
- 2. Check result: `loom process logs <name> --limit 1`
89
- 3. Verify metrics improve over next 5-10 scheduled runs
90
- 4. Revert if worse: restore previous definition
86
+ 应用演化变更后:
87
+ 1. 手动运行:`loom process run <name>`
88
+ 2. 检查结果:`loom process logs <name> --limit 1`
89
+ 3. 验证后续 5-10 次定时运行的指标是否改善
90
+ 4. 情况恶化时回滚:恢复之前的定义
@@ -1,24 +1,24 @@
1
- # Model CLI Reference
1
+ # Model CLI 参考
2
2
 
3
- ## Overview
3
+ ## 概述
4
4
 
5
- Model management commands configure AI models used by the Loom platform — for chat, Process execution, and AI-assisted features.
5
+ 模型管理命令用于配置 Loom 平台使用的 AI 模型——包括聊天、Process 执行和 AI 辅助功能。
6
6
 
7
- ## Commands
7
+ ## 命令
8
8
 
9
9
  ### `loom model list`
10
10
 
11
- List all configured AI models with their capability tier, tags, and default status.
11
+ 列出所有已配置的 AI 模型及其能力层级、标签和默认状态。
12
12
 
13
13
  ```bash
14
14
  loom model list
15
15
  ```
16
16
 
17
- Output shows each model's name, capability tier (`[fast]`, `[standard]`, `[max]`), default marker, base URL, auth status, and tags.
17
+ 输出显示每个模型的名称、能力层级(`[fast]`、`[standard]`、`[max]`)、默认标记、基础 URL、认证状态和标签。
18
18
 
19
19
  ### `loom model add <name>`
20
20
 
21
- Add a new AI model configuration.
21
+ 添加新的 AI 模型配置。
22
22
 
23
23
  ```bash
24
24
  loom model add "claude-sonnet-4-6" \
@@ -29,82 +29,82 @@ loom model add "claude-sonnet-4-6" \
29
29
  --tags "创作模型,多模态"
30
30
  ```
31
31
 
32
- **Options:**
33
- | Flag | Required | Description |
34
- |------|----------|-------------|
35
- | `--base-url` | Yes | API base URL |
36
- | `--auth-token` | No | Authentication token |
37
- | `--default` | No | Set as default model (first model is auto-default) |
38
- | `--tier` | No | Capability tier: `fast`, `standard`, or `max` |
39
- | `--tags` | No | Comma-separated classification tags |
40
- | `--token` | No | Auth token (or set LOOM_TOKEN) |
41
- | `--server` | No | Server URL (or set LOOM_SERVER, default: http://localhost:3000) |
32
+ **选项:**
33
+ | Flag | 必填 | Description |
34
+ |------|------|-------------|
35
+ | `--base-url` | | API 基础 URL |
36
+ | `--auth-token` | | 认证令牌 |
37
+ | `--default` | | 设为默认模型(第一个添加的模型自动成为默认) |
38
+ | `--tier` | | 能力层级:`fast`、`standard` `max` |
39
+ | `--tags` | | 逗号分隔的分类标签 |
40
+ | `--token` | | 认证令牌(或设置 LOOM_TOKEN |
41
+ | `--server` | | 服务器 URL(或设置 LOOM_SERVER,默认:http://localhost:3000 |
42
42
 
43
43
  ### `loom model update <name>`
44
44
 
45
- Update an existing model configuration.
45
+ 更新已有的模型配置。
46
46
 
47
47
  ```bash
48
- # Change capability tier
48
+ # 更改能力层级
49
49
  loom model update "claude-sonnet-4-6" --tier fast
50
50
 
51
- # Set as default
51
+ # 设为默认模型
52
52
  loom model update "claude-opus-4-7" --default
53
53
 
54
- # Update tags
54
+ # 更新标签
55
55
  loom model update "claude-sonnet-4-6" --tags "创作模型,多模态,代码"
56
56
 
57
- # Clear capability tier
57
+ # 清除能力层级
58
58
  loom model update "claude-sonnet-4-6" --tier none
59
59
 
60
- # Clear tags
60
+ # 清除标签
61
61
  loom model update "claude-sonnet-4-6" --tags ""
62
62
  ```
63
63
 
64
- **Options:**
65
- | Flag | Required | Description |
66
- |------|----------|-------------|
67
- | `--base-url` | No | Update API base URL |
68
- | `--auth-token` | No | Update authentication token |
69
- | `--default` | No | Set as default model |
70
- | `--tier` | No | Update capability tier (`fast`/`standard`/`max`, or `none` to clear) |
71
- | `--tags` | No | Update tags (comma-separated, or `""` to clear) |
72
- | `--token` | No | Auth token (or set LOOM_TOKEN) |
73
- | `--server` | No | Server URL (or set LOOM_SERVER, default: http://localhost:3000) |
64
+ **选项:**
65
+ | Flag | 必填 | Description |
66
+ |------|------|-------------|
67
+ | `--base-url` | | 更新 API 基础 URL |
68
+ | `--auth-token` | | 更新认证令牌 |
69
+ | `--default` | | 设为默认模型 |
70
+ | `--tier` | | 更新能力层级(`fast`/`standard`/`max`,或 `none` 清除) |
71
+ | `--tags` | | 更新标签(逗号分隔,或 `""` 清除) |
72
+ | `--token` | | 认证令牌(或设置 LOOM_TOKEN |
73
+ | `--server` | | 服务器 URL(或设置 LOOM_SERVER,默认:http://localhost:3000 |
74
74
 
75
75
  ### `loom model remove <name>`
76
76
 
77
- Remove a model configuration. If the removed model was the default, the first remaining model becomes the new default.
77
+ 移除模型配置。如果移除的模型是默认模型,剩余模型中的第一个将成为新的默认模型。
78
78
 
79
79
  ```bash
80
80
  loom model remove "old-model"
81
81
  ```
82
82
 
83
- ## Capability Tiers
83
+ ## 能力层级
84
84
 
85
- Capability tiers are informational labels for model capability:
85
+ 能力层级是模型能力的信息标签:
86
86
 
87
87
  | Tier | Meaning | Use Case |
88
88
  |------|---------|----------|
89
- | `fast` | Lightweight, quick responses | Simple data aggregation, formatting |
90
- | `standard` | Balanced performance | General-purpose tasks |
91
- | `max` | Strongest reasoning | Complex analysis, multi-step reasoning |
89
+ | `fast` | 轻量级,响应快速 | 简单数据聚合、格式化 |
90
+ | `standard` | 性能均衡 | 通用任务 |
91
+ | `max` | 最强推理能力 | 复杂分析、多步推理 |
92
92
 
93
- Capability tiers appear as colored tags in the AI Sidecar and ChatDrawer model selectors, and in Process overview when a model is bound.
93
+ 能力层级在 AI Sidecar ChatDrawer 的模型选择器中以彩色标签显示,绑定模型的 Process 概览页也会显示。
94
94
 
95
- ## Process Model Binding
95
+ ## Process 模型绑定
96
96
 
97
- When creating a Process, you can specify which model it uses:
97
+ 创建 Process 时,可以指定其使用的模型:
98
98
 
99
99
  ```bash
100
- # Use a specific model for complex reasoning
100
+ # 使用指定模型进行复杂推理
101
101
  loom process add --name "daily-analysis" \
102
102
  --cron "0 2 * * *" \
103
103
  --prompt "Analyze daily data and generate insights" \
104
104
  --owner admin \
105
105
  --model "claude-opus-4-7"
106
106
 
107
- # Use a fast model for simple aggregation
107
+ # 使用快速模型进行简单聚合
108
108
  loom process add --name "quick-summary" \
109
109
  --cron "*/30 * * * *" \
110
110
  --prompt "Summarize key metrics" \
@@ -112,12 +112,12 @@ loom process add --name "quick-summary" \
112
112
  --model "claude-sonnet-4-6"
113
113
  ```
114
114
 
115
- If `--model` is omitted, the Process uses the global default model.
115
+ 如果省略 `--model`,Process 将使用全局默认模型。
116
116
 
117
- ## HTTP API Equivalents
117
+ ## HTTP API 对应关系
118
118
 
119
- | CLI Command | HTTP Endpoint |
120
- |------------|---------------|
119
+ | CLI 命令 | HTTP 端点 |
120
+ |----------|-----------|
121
121
  | `loom model list` | `GET /api/v1/ai/models` |
122
122
  | `loom model add` | `POST /api/v1/ai/models` |
123
123
  | `loom model update` | `PUT /api/v1/ai/models/:name` |
@@ -1,37 +1,37 @@
1
- # Notification Commands Reference
1
+ # 通知命令参考
2
2
 
3
- ## Overview
3
+ ## 概述
4
4
 
5
- Loom provides a built-in notification system for persistent server-side notifications. Notifications are user-scoped and support CRUD operations via both HTTP API and CLI.
5
+ Loom 提供内置通知系统,用于持久化的服务端通知。通知按用户作用域隔离,支持通过 HTTP API CLI 进行 CRUD 操作。
6
6
 
7
- ## CLI Commands
7
+ ## CLI 命令
8
8
 
9
- ### List notifications
9
+ ### 列出通知
10
10
  ```bash
11
11
  loom notification list [--unread] [--limit 20] [--offset 0] --token <TOKEN>
12
12
  ```
13
13
 
14
- ### Mark as read
14
+ ### 标记为已读
15
15
  ```bash
16
16
  loom notification read <id> --token <TOKEN>
17
17
  ```
18
18
 
19
- ### Mark all as read
19
+ ### 全部标记为已读
20
20
  ```bash
21
21
  loom notification read-all --token <TOKEN>
22
22
  ```
23
23
 
24
- ### Delete notification
24
+ ### 删除通知
25
25
  ```bash
26
26
  loom notification delete <id> --token <TOKEN>
27
27
  ```
28
28
 
29
- ### Clear all notifications
29
+ ### 清空所有通知
30
30
  ```bash
31
31
  loom notification clear --token <TOKEN>
32
32
  ```
33
33
 
34
- ### Send notification (admin only)
34
+ ### 发送通知(仅管理员)
35
35
  ```bash
36
36
  loom notification send --userId <userId> --type <type> --title <title> [--description DESC] --token <TOKEN>
37
37
  ```
@@ -40,30 +40,30 @@ loom notification send --userId <userId> --type <type> --title <title> [--descri
40
40
 
41
41
  | Method | Path | Auth | Permission | Description |
42
42
  |--------|------|------|------------|-------------|
43
- | GET | `/api/v1/notifications` | Required | Own only | List (paginated) |
44
- | GET | `/api/v1/notifications/unread-count` | Required | Own only | Unread count |
45
- | PUT | `/api/v1/notifications/:id/read` | Required | Own only | Mark read |
46
- | PUT | `/api/v1/notifications/read-all` | Required | Own only | Mark all read |
47
- | DELETE | `/api/v1/notifications/:id` | Required | Own only | Delete single |
48
- | DELETE | `/api/v1/notifications` | Required | Own only | Clear all |
49
- | POST | `/api/v1/notifications` | Required | Admin | Create notification |
43
+ | GET | `/api/v1/notifications` | Required | Own only | 分页查询通知列表 |
44
+ | GET | `/api/v1/notifications/unread-count` | Required | Own only | 获取未读数量 |
45
+ | PUT | `/api/v1/notifications/:id/read` | Required | Own only | 标记为已读 |
46
+ | PUT | `/api/v1/notifications/read-all` | Required | Own only | 全部标记为已读 |
47
+ | DELETE | `/api/v1/notifications/:id` | Required | Own only | 删除单条通知 |
48
+ | DELETE | `/api/v1/notifications` | Required | Own only | 清空所有通知 |
49
+ | POST | `/api/v1/notifications` | Required | Admin | 创建通知 |
50
50
 
51
- ## Notification Types
51
+ ## 通知类型
52
52
 
53
- - `success` — Green, operation completed successfully
54
- - `error` — Red, operation failed
55
- - `warning` — Orange, attention needed
56
- - `info` — Blue, informational
53
+ - `success` — 绿色,操作成功完成
54
+ - `error` — 红色,操作失败
55
+ - `warning` — 橙色,需要关注
56
+ - `info` — 蓝色,信息提示
57
57
 
58
- ## Source Types
58
+ ## 来源类型
59
59
 
60
- - `system` — Generated by Loom framework
61
- - `event` — Generated by EventBus subscription
62
- - `cli` — Created via CLI command
60
+ - `system` — Loom 框架生成
61
+ - `event` — EventBus 订阅生成
62
+ - `cli` — 通过 CLI 命令创建
63
63
 
64
- ## EventBus notify Handler
64
+ ## EventBus notify 处理器
65
65
 
66
- Configure automatic notification generation from events in `loom.config.ts`:
66
+ `loom.config.ts` 中配置事件自动生成通知:
67
67
 
68
68
  ```typescript
69
69
  export default defineConfig({
@@ -92,32 +92,32 @@ export default defineConfig({
92
92
  });
93
93
  ```
94
94
 
95
- ### Config Options
95
+ ### 配置选项
96
96
 
97
97
  | Field | Type | Required | Description |
98
98
  |-------|------|----------|-------------|
99
- | `type` | `'success' \| 'error' \| 'warning' \| 'info'` | Yes | Notification severity |
100
- | `title` | `string` | Yes | Notification title (supports `{{var}}` interpolation) |
101
- | `description` | `string` | No | Notification body (supports `{{var}}` interpolation) |
102
- | `broadcastAll` | `boolean` | No | Broadcast to all users when event has no userId (default: false) |
99
+ | `type` | `'success' \| 'error' \| 'warning' \| 'info'` | Yes | 通知严重级别 |
100
+ | `title` | `string` | Yes | 通知标题(支持 `{{var}}` 插值) |
101
+ | `description` | `string` | No | 通知正文(支持 `{{var}}` 插值) |
102
+ | `broadcastAll` | `boolean` | No | 当事件无 userId 时广播给所有用户(默认:false |
103
103
 
104
- ### Interpolation
104
+ ### 插值
105
105
 
106
- Title and description support `{{var}}` interpolation from event payload:
107
- - `{{id}}` — Record ID
108
- - `{{model}}` — Model name
109
- - Any field from the event payload
106
+ 标题和描述支持从事件载荷中提取 `{{var}}` 插值:
107
+ - `{{id}}` — 记录 ID
108
+ - `{{model}}` — 模型名称
109
+ - 事件载荷中的任意字段
110
110
 
111
- Missing variables are replaced with empty string.
111
+ 缺失的变量将被替换为空字符串。
112
112
 
113
- ### Behavior
113
+ ### 行为规则
114
114
 
115
- - If event has `userId`: notification sent to that user only
116
- - If event has no `userId` and `broadcastAll: true`: sent to all users (capped at 100)
117
- - If event has no `userId` and `broadcastAll: false` (default): notification is skipped
115
+ - 若事件包含 `userId`:仅发送给该用户
116
+ - 若事件无 `userId` `broadcastAll: true`:发送给所有用户(上限 100
117
+ - 若事件无 `userId` `broadcastAll: false`(默认):跳过该通知
118
118
 
119
- ## Permissions
119
+ ## 权限
120
120
 
121
- - Users can only read/modify their own notifications
122
- - Only admin users can create notifications for other users via POST API or `loom notification send`
123
- - Notifications are auto-pruned after 30 days or when exceeding 500 items
121
+ - 用户只能读取/修改自己的通知
122
+ - 仅管理员可通过 POST API `loom notification send` 为其他用户创建通知
123
+ - 通知在 30 天后或超过 500 条时自动清理