wake-bridge 0.9.0-preview.8

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 (115) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +222 -0
  3. package/dist/src/adapters/botlingknows.d.ts +42 -0
  4. package/dist/src/adapters/botlingknows.js +141 -0
  5. package/dist/src/adapters/botlingknows.js.map +1 -0
  6. package/dist/src/adapters/group-chat.d.ts +43 -0
  7. package/dist/src/adapters/group-chat.js +120 -0
  8. package/dist/src/adapters/group-chat.js.map +1 -0
  9. package/dist/src/cli.d.ts +2 -0
  10. package/dist/src/cli.js +637 -0
  11. package/dist/src/cli.js.map +1 -0
  12. package/dist/src/connector-catalog.d.ts +17 -0
  13. package/dist/src/connector-catalog.js +43 -0
  14. package/dist/src/connector-catalog.js.map +1 -0
  15. package/dist/src/connectors/botlingknows-mcp.d.ts +15 -0
  16. package/dist/src/connectors/botlingknows-mcp.js +130 -0
  17. package/dist/src/connectors/botlingknows-mcp.js.map +1 -0
  18. package/dist/src/connectors/group-chat-http.d.ts +17 -0
  19. package/dist/src/connectors/group-chat-http.js +226 -0
  20. package/dist/src/connectors/group-chat-http.js.map +1 -0
  21. package/dist/src/connectors/mcp-http-client.d.ts +11 -0
  22. package/dist/src/connectors/mcp-http-client.js +108 -0
  23. package/dist/src/connectors/mcp-http-client.js.map +1 -0
  24. package/dist/src/core.d.ts +170 -0
  25. package/dist/src/core.js +1720 -0
  26. package/dist/src/core.js.map +1 -0
  27. package/dist/src/daemon.d.ts +31 -0
  28. package/dist/src/daemon.js +605 -0
  29. package/dist/src/daemon.js.map +1 -0
  30. package/dist/src/db.d.ts +31 -0
  31. package/dist/src/db.js +513 -0
  32. package/dist/src/db.js.map +1 -0
  33. package/dist/src/event-sdk.d.ts +43 -0
  34. package/dist/src/event-sdk.js +152 -0
  35. package/dist/src/event-sdk.js.map +1 -0
  36. package/dist/src/host-adapter-registry.d.ts +21 -0
  37. package/dist/src/host-adapter-registry.js +59 -0
  38. package/dist/src/host-adapter-registry.js.map +1 -0
  39. package/dist/src/index.d.ts +5 -0
  40. package/dist/src/index.js +6 -0
  41. package/dist/src/index.js.map +1 -0
  42. package/dist/src/instance-config.d.ts +46 -0
  43. package/dist/src/instance-config.js +176 -0
  44. package/dist/src/instance-config.js.map +1 -0
  45. package/dist/src/mcp.d.ts +51 -0
  46. package/dist/src/mcp.js +728 -0
  47. package/dist/src/mcp.js.map +1 -0
  48. package/dist/src/operator-control.d.ts +82 -0
  49. package/dist/src/operator-control.js +220 -0
  50. package/dist/src/operator-control.js.map +1 -0
  51. package/dist/src/out-of-process-host.d.ts +37 -0
  52. package/dist/src/out-of-process-host.js +196 -0
  53. package/dist/src/out-of-process-host.js.map +1 -0
  54. package/dist/src/policy-control.d.ts +3 -0
  55. package/dist/src/policy-control.js +120 -0
  56. package/dist/src/policy-control.js.map +1 -0
  57. package/dist/src/release-lifecycle.d.ts +98 -0
  58. package/dist/src/release-lifecycle.js +378 -0
  59. package/dist/src/release-lifecycle.js.map +1 -0
  60. package/dist/src/sdk-error.d.ts +6 -0
  61. package/dist/src/sdk-error.js +12 -0
  62. package/dist/src/sdk-error.js.map +1 -0
  63. package/dist/src/source-adapter.d.ts +32 -0
  64. package/dist/src/source-adapter.js +164 -0
  65. package/dist/src/source-adapter.js.map +1 -0
  66. package/dist/src/source-connector.d.ts +50 -0
  67. package/dist/src/source-connector.js +358 -0
  68. package/dist/src/source-connector.js.map +1 -0
  69. package/dist/src/source-control-client.d.ts +38 -0
  70. package/dist/src/source-control-client.js +61 -0
  71. package/dist/src/source-control-client.js.map +1 -0
  72. package/dist/src/source-ingress.d.ts +16 -0
  73. package/dist/src/source-ingress.js +47 -0
  74. package/dist/src/source-ingress.js.map +1 -0
  75. package/dist/src/source-sdk.d.ts +6 -0
  76. package/dist/src/source-sdk.js +53 -0
  77. package/dist/src/source-sdk.js.map +1 -0
  78. package/dist/src/transport-sdk.d.ts +102 -0
  79. package/dist/src/transport-sdk.js +222 -0
  80. package/dist/src/transport-sdk.js.map +1 -0
  81. package/dist/src/transport.d.ts +23 -0
  82. package/dist/src/transport.js +71 -0
  83. package/dist/src/transport.js.map +1 -0
  84. package/dist/src/types.d.ts +522 -0
  85. package/dist/src/types.js +2 -0
  86. package/dist/src/types.js.map +1 -0
  87. package/dist/src/util.d.ts +26 -0
  88. package/dist/src/util.js +136 -0
  89. package/dist/src/util.js.map +1 -0
  90. package/dist/src/version.d.ts +1 -0
  91. package/dist/src/version.js +2 -0
  92. package/dist/src/version.js.map +1 -0
  93. package/docs/adapters/botlingknows.md +40 -0
  94. package/docs/adapters/gmail-planned.md +16 -0
  95. package/docs/adapters/group-chat.md +126 -0
  96. package/docs/operations/connector-catalog.md +40 -0
  97. package/docs/operations/operator-control.md +83 -0
  98. package/docs/operations/out-of-process-host-adapter.md +150 -0
  99. package/docs/operations/policies.md +106 -0
  100. package/docs/operations/public-sdk.md +87 -0
  101. package/docs/operations/release-lifecycle.md +154 -0
  102. package/docs/operations/source-connectors.md +163 -0
  103. package/docs/operations/source-ingress.md +108 -0
  104. package/docs/operations/templates/botlingknows-connector.env.example +5 -0
  105. package/docs/operations/templates/sources.json.example +15 -0
  106. package/docs/quickstart.md +143 -0
  107. package/docs/releases/0.9.0-preview.8.md +44 -0
  108. package/docs/verification.md +19 -0
  109. package/examples/policies/botlingknows-conservative.json +44 -0
  110. package/examples/reference-host-adapter/README.md +41 -0
  111. package/examples/reference-host-adapter/adapter.mjs +173 -0
  112. package/examples/reference-host-adapter/host-adapters.json.example +26 -0
  113. package/package.json +94 -0
  114. package/schemas/event-v1.schema.json +26 -0
  115. package/schemas/policy-v1.schema.json +66 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,222 @@
1
+ # Wake Bridge
2
+
3
+ Wake Bridge 是一个 local-first 的 **agent attention scheduler and delivery core**。外部来源登记“发生了什么”,agent 用自己的 policy 决定是否、何时重新获得注意力;Wake Bridge 把结构化 wake envelope 可靠交给 agent 所在宿主明确登记的 Host Adapter。
4
+
5
+ 它不是 agent runtime、聊天前端或记忆系统,也不直接承诺唤醒某一种 CLI/Desktop 产品。真正启动、恢复或排队 agent session 的能力属于拥有该 session lifecycle 的 Host Adapter。
6
+
7
+ 当前 preview 已实现并验证:
8
+
9
+ - durable Event、Claim、Batch、outbox 与分层 receipt;
10
+ - immediate、scheduled、suppress、quiet hours 与 presence gate;
11
+ - agent 自主预约未来的 self-commitment;
12
+ - endpoint lease、attention-channel binding 与 generation fencing;
13
+ - source-scoped ingress、Source Connector checkpoint 与身份 fencing;
14
+ - versioned event/source/transport SDK;
15
+ - out-of-process loopback Host Adapter Contract;
16
+ - 单 Agent Principal / 单 Agent Space / 单 daemon 的本地部署。
17
+
18
+ 当前公开边界见 [架构与路由](docs/architecture.md) 和
19
+ [Out-of-process Host Adapter contract](docs/operations/out-of-process-host-adapter.md)。
20
+
21
+ ## 开始使用
22
+
23
+ 从 [First Wake Quickstart](docs/quickstart.md) 开始。它覆盖 clean install、Agent Space 初始化、仓库外 Host Adapter、第一条受控 wake、MCP、presence、self-commitment 与可选 Source Connector。完整公共文档见 [文档导航](docs/README.md)。
24
+
25
+ `0.9.0-preview.8` 是首个公开 pre-release,已通过 clean-artifact 首发演练并发布到 npm 的 `preview` channel。Wake Bridge 本身不内置任何具体 agent 产品 Host Adapter;使用者必须已有或实现一个能精确控制目标 session 的 adapter。
26
+
27
+ ## 为什么有 Wake Bridge
28
+
29
+ 项目最初来自小机知道上的一个公共产品问题:站方是否会做 Wake Bridge,让 agent 不必反复轮询通知,也能在模型回合之外发生事件时重新获得注意力。
30
+
31
+ 它解决的不是“怎样让 agent 永远记住某件事”,而是另一层问题:
32
+
33
+ - 不需要模型反复轮询邮件、论坛或群聊才能发现新事件;
34
+ - 调度与待处理事项不依赖某一个模型回合持续运行;
35
+ - agent 可以为未来的自己预约何时、为何重新醒来;
36
+ - agent 可以选择自己的 Source Connector 与个人唤醒策略;
37
+ - 可信 presence 表明用户正在交谈时,后台注意力可以让位;
38
+ - 事件、决定、投递和消费都有 durable、可审计的生命周期。
39
+
40
+ 完整背景见 [项目背景与目标](docs/background.md)。
41
+
42
+ ## 架构边界
43
+
44
+ ```text
45
+ External Source
46
+ └─ Source Connector / authenticated ingress
47
+ └─ WakeEvent reference
48
+
49
+ Wake Bridge Core
50
+ Event → Policy → Claim → Gates → Batch → Durable Outbox
51
+ ▲ │
52
+ Presence lease ▼
53
+ Host Adapter Contract
54
+
55
+
56
+ exact agent session/task
57
+ ```
58
+
59
+ ### Wake Bridge Core 负责
60
+
61
+ - 事件归一化、去重、checkpoint 与有限 metadata;
62
+ - durable Attention Claim 与 self-commitment;
63
+ - 个人 policy、quiet hours、presence 与 inactivity watch;
64
+ - endpoint/binding lease、generation fencing、batch/outbox 与重试;
65
+ - 生成固定的 wake envelope,并记录不高于真实证据的 receipt。
66
+
67
+ ### Host Adapter 负责
68
+
69
+ - 识别自己拥有的精确 agent session;
70
+ - 启动、恢复或排队该 session;
71
+ - 将 wake envelope 注入 agent 输入面;
72
+ - 报告自己真正观察到的 delivery/session 阶段;
73
+ - 在具备可信观察能力时维护 session lifecycle 与 presence。
74
+
75
+ ### Agent/harness 负责
76
+
77
+ - 醒来后读取 envelope 引用的权威来源;
78
+ - ack、consume、snooze 或 dismiss claim;
79
+ - 上下文、记忆、身份与换窗恢复;
80
+ - 决定是否安排下一次 self-commitment。
81
+
82
+ `transport_accepted`、`host_accepted`、宿主实际观察到的 turn start、`agent_seen` 与 `agent_consumed` 是不同证据层。
83
+ 当前公共 adapter HTTP 202 最多只产生 `transport_accepted` receipt,不能冒充 agent 已醒来。
84
+
85
+ ## Host Adapter Contract
86
+
87
+ 已有 backend、agent runner、bridge service 或自制 frontend 的宿主,应通过公开 Host Adapter Contract 接入。推荐使用
88
+ [`HostSessionClient`](docs/operations/out-of-process-host-adapter.md) 登记 opaque session id 与 credential-free loopback route;delivery credential 只属于该 adapter process,不与 owner/source credential 共用。
89
+
90
+ 实现协议只证明 compatibility,不自动获得“Wake Bridge 支持某宿主产品”的分类。具体集成维护方必须自己声明并验证:
91
+
92
+ - exact identity;
93
+ - cold start / warm resume / busy queue 行为;
94
+ - activity/presence 是否可观察;
95
+ - receipt 上界;
96
+ - restart、lease expiry 与 generation takeover;
97
+ - 端到端 wake 时延与失败语义。
98
+
99
+ 仓库提供一个不具名的 [reference Host Adapter](examples/reference-host-adapter/README.md),只演示公开 contract 与生命周期,不内建任何 agent runtime。
100
+
101
+ ## Source 与 Source Connector
102
+
103
+ - **Source**:发生事实的外部系统或 feed,例如论坛、邮件服务或群聊。
104
+ - **Source Connector**:从 Source 增量读取或接收事实,并转换为 `WakeEvent` 的独立程序。
105
+ - **Source binding/subscription**:某个 Agent Space 对具体 source identity 的配置与 checkpoint。
106
+
107
+ Source Connector 只报告事实,不能选择 endpoint、绕过 policy 或注入任意 prompt。Wake envelope 只携带 resource reference;正文仍由 agent 醒来后通过来源自己的 API/MCP 读取。
108
+
109
+ 上游 credential 由独立 connector 保管,不进入 Wake Bridge daemon、event、receipt 或模型上下文。Manifest 必须分别声明上游 credential breadth、credential custody、connector 实际暴露能力与读取副作用。
110
+
111
+ ### 首发 catalog
112
+
113
+ Connector 采用“可发现、可选配置、默认关闭”的模型。默认提供不表示默认登录、创建 checkpoint、轮询或唤醒。
114
+
115
+ | Connector | 状态 | 默认行为 |
116
+ | --- | --- | --- |
117
+ | 小机知道 | official optional | disabled;verify + from-now bootstrap 后才能 enable |
118
+ | Gmail | planned | 不可 enable;完成独立设计、provider 合规与真实 UAT 后再进入 available |
119
+ | Group Chat fixture | reference/conformance | disabled;用于证明通用 connector contract |
120
+
121
+ Source Connector 的本地协议、身份 fencing、cursor CAS 与错误处理见
122
+ [Source Connector 安装与本地协议](docs/operations/source-connectors.md)。
123
+
124
+ ## Preview 安装
125
+
126
+ 当前 package 名称为 `wake-bridge`,发布 channel 为 `preview`。已验收平台为 macOS arm64/x64、Node.js 20+ 与 SQLite CLI 3.33+;Linux/systemd 尚未进入支持矩阵。
127
+
128
+ 从 npm 安装当前 preview:
129
+
130
+ ```bash
131
+ npm install --global wake-bridge@preview
132
+ wakebridge release-preflight
133
+ ```
134
+
135
+ 从源码 checkout 生成并验证本地 tarball:
136
+
137
+ ```bash
138
+ npm pack --json
139
+ npm install --global ./wake-bridge-0.9.0-preview.8.tgz
140
+ wakebridge release-preflight
141
+ wakebridge init \
142
+ --data-dir /absolute/private/path \
143
+ --instance-id default \
144
+ --owner-id your-agent \
145
+ --timezone UTC
146
+ ```
147
+
148
+ 旧 schema 不会在普通 daemon/inspect 启动时隐式迁移。升级必须使用带 verified snapshot 和失败自动恢复的 `wakebridge upgrade`。完整流程见 [release lifecycle runbook](docs/operations/release-lifecycle.md)。
149
+
150
+ ### 公共扩展入口
151
+
152
+ 第三方集成只依赖这些版本化 subpath:
153
+
154
+ ```text
155
+ wake-bridge/event
156
+ wake-bridge/source
157
+ wake-bridge/transport
158
+ ```
159
+
160
+ Root import 只聚合公开 contract。Core、SQLite、daemon 与 owner control 不属于 package API。详见
161
+ [public SDK boundary](docs/operations/public-sdk.md)。
162
+
163
+ ### 无 Host Adapter 时
164
+
165
+ Wake Bridge 仍会可靠保存 Event、Claim 与 Batch,但 delivery 明确停在 `waiting_for_endpoint`。Core 不扫描窗口、不猜最近 session,也不悄悄降级到另一个宿主入口。
166
+
167
+ ## 安全原则
168
+
169
+ - 一个 preview daemon instance 固定服务一个 Agent Principal / Agent Space。
170
+ - 每个 Space 独享 SQLite、端口、owner/source/host credential、policy、connector 与 endpoint registry。
171
+ - source credential 只能在固定 source namespace 内登记 Event。
172
+ - Host Adapter 只能登记获授权的 host kind 与 route,不能获得 owner API 或读取其他 source secret。
173
+ - 通用 ingress 和 Source Connector 不能提交 wake prompt。
174
+ - 来源正文、provider token 与 connector bearer 不进入 durable event/receipt。
175
+ - broad/unknown provider credential 若直接注入 Wake Bridge process,默认 fail closed。
176
+
177
+ ## 当前非目标
178
+
179
+ - 内建 agent runtime、聊天 frontend、memory system 或 session manager;
180
+ - 保证任意 CLI/Desktop 产品能被外部进程及时唤醒;
181
+ - 通过进程、窗口焦点或“最近活动”猜 agent identity;
182
+ - 替 harness 保证换窗后的记忆、身份 bootstrap 或 loop 连续性;
183
+ - 将模型放进 scheduler 热路径自由决定优先级;
184
+ - 复制邮件、论坛、群聊等来源正文;
185
+ - 自动登录第三方服务或默认启用 connector;
186
+ - 把 `transport_accepted` 宣传成 agent 已读或已处理;
187
+ - 在首版中提供共享多 Agent Space daemon。
188
+
189
+ ## 主要文档
190
+
191
+ - [First Wake Quickstart](docs/quickstart.md)
192
+ - [文档导航](docs/README.md)
193
+ - [项目背景与目标](docs/background.md)
194
+ - [架构与路由](docs/architecture.md)
195
+ - [协议与数据模型](docs/protocol.md)
196
+ - [Out-of-process Host Adapter](docs/operations/out-of-process-host-adapter.md)
197
+ - [Source Connector](docs/operations/source-connectors.md)
198
+ - [Source-scoped ingress](docs/operations/source-ingress.md)
199
+ - [Personal policy](docs/operations/policies.md)
200
+ - [Explicit inactivity watch](docs/inactivity-watch.md)
201
+ - [Release lifecycle](docs/operations/release-lifecycle.md)
202
+ - [公开验证口径](docs/verification.md)
203
+ - [小机知道 Source Connector](docs/adapters/botlingknows.md)
204
+
205
+ ## 项目词汇
206
+
207
+ | 词 | 含义 |
208
+ | --- | --- |
209
+ | Agent Principal | Wake Bridge 中一个稳定、独立的 agent 身份 |
210
+ | Agent Space | 一个 Agent Principal 独享的状态、凭证与策略边界 |
211
+ | Source | 发生外部事实的系统或 feed |
212
+ | Source Connector | 把 Source 的增量事实转换为 WakeEvent 的独立程序 |
213
+ | Event | 已发生事实的不可变 reference,不等于模型唤醒 |
214
+ | Attention Claim | 一件事从某时起值得重新获得一次注意力的 durable 请求 |
215
+ | Policy | 从 Event 生成 Claim,并决定时间、静默、presence 与聚合的规则 |
216
+ | Presence lease | 可信 host observation 产生的短 TTL 调度门 |
217
+ | Inactivity watch | agent 显式登记的 session 失活条件,不等于记忆保证 |
218
+ | Wake batch | 一次 delivery 携带的一组 claim/event references |
219
+ | Attention channel | agent 自己定义的注意力槽,例如 `life` 或 `work` |
220
+ | Endpoint | Host Adapter 显式登记的 opaque delivery target |
221
+ | Binding | attention channel 当前使用的 primary endpoint |
222
+ | Generation | takeover 时递增、用于 fencing stale endpoint 的代际号 |
@@ -0,0 +1,42 @@
1
+ import type { JsonValue, PullSourceAdapter, SourceAdapterManifest, SourceCursor, SourcePollContext, SourcePollResult, WakeEventInput } from "../types.js";
2
+ export interface BotlingKnowsNotification {
3
+ id: number;
4
+ notif_type: string;
5
+ category: "direct" | "activity" | "invitation" | "system" | string;
6
+ created_at: string;
7
+ question_id?: number | null;
8
+ content_id?: number | null;
9
+ actor_id?: number | null;
10
+ next_action?: JsonValue;
11
+ }
12
+ export interface BotlingKnowsNotificationPage {
13
+ notifications: BotlingKnowsNotification[];
14
+ next_cursor?: string | null;
15
+ }
16
+ export interface BotlingKnowsNotificationClient {
17
+ notifications(input: {
18
+ view: "full";
19
+ mark_read: false;
20
+ limit: number;
21
+ cursor?: string;
22
+ }): Promise<BotlingKnowsNotificationPage> | BotlingKnowsNotificationPage;
23
+ }
24
+ /** Botling Knows currently accepts at most 50 notifications per request. */
25
+ export declare const BOTLING_KNOWS_MAX_PAGE_SIZE = 50;
26
+ export declare function mapBotlingKnowsNotification(notification: BotlingKnowsNotification): WakeEventInput;
27
+ /**
28
+ * Read-only notification adapter. The stored cursor is a stable notification
29
+ * id high-watermark plus an optional pagination continuation; a source API's
30
+ * opaque page cursor is never mistaken for a durable incremental cursor.
31
+ */
32
+ export declare class BotlingKnowsSourceAdapter implements PullSourceAdapter {
33
+ readonly client: BotlingKnowsNotificationClient;
34
+ readonly manifest: SourceAdapterManifest;
35
+ constructor(client: BotlingKnowsNotificationClient, identity?: {
36
+ subject_ref: string;
37
+ binding_fingerprint: string;
38
+ });
39
+ poll(context: SourcePollContext): Promise<SourcePollResult>;
40
+ }
41
+ /** Explicit operator bootstrap for a future production install. */
42
+ export declare function botlingKnowsCursorFromNow(client: BotlingKnowsNotificationClient, limit?: number): Promise<SourceCursor>;
@@ -0,0 +1,141 @@
1
+ import { BridgeError } from "../core.js";
2
+ /** Botling Knows currently accepts at most 50 notifications per request. */
3
+ export const BOTLING_KNOWS_MAX_PAGE_SIZE = 50;
4
+ const BASE_MANIFEST = {
5
+ contract_version: 1,
6
+ id: "botlingknows",
7
+ version: "0.1.0",
8
+ read_side_effects: "none",
9
+ credential_custody: "connector",
10
+ upstream_credential_breadth: "unknown",
11
+ upstream_credential_scopes: [],
12
+ connector_capabilities: ["notifications.read"],
13
+ };
14
+ const TEST_IDENTITY = {
15
+ subject_ref: "botlingknows:test",
16
+ binding_fingerprint: `sha256:${"0".repeat(64)}`,
17
+ };
18
+ function normalizeCursor(cursor) {
19
+ if (cursor === null)
20
+ return { v: 1, high_watermark: 0, page_cursor: null, pending_max_id: 0 };
21
+ if (!cursor || typeof cursor !== "object" || Array.isArray(cursor)) {
22
+ throw new BridgeError("botlingknows cursor is invalid", "invalid_source_cursor", 400);
23
+ }
24
+ const value = cursor;
25
+ const high = Number(value.high_watermark);
26
+ const pending = Number(value.pending_max_id);
27
+ const page = value.page_cursor;
28
+ if (value.v !== 1 || !Number.isSafeInteger(high) || high < 0 || !Number.isSafeInteger(pending) || pending < high
29
+ || (page !== null && typeof page !== "string")) {
30
+ throw new BridgeError("botlingknows cursor is invalid", "invalid_source_cursor", 400);
31
+ }
32
+ return { v: 1, high_watermark: high, page_cursor: page, pending_max_id: pending };
33
+ }
34
+ function absoluteTimestamp(value) {
35
+ const date = new Date(value);
36
+ if (!value || Number.isNaN(date.getTime())) {
37
+ throw new BridgeError("botlingknows notification timestamp is invalid", "invalid_source_page", 502);
38
+ }
39
+ return date.toISOString();
40
+ }
41
+ function resourceFor(notification) {
42
+ if (Number.isSafeInteger(notification.content_id) && Number(notification.content_id) > 0) {
43
+ return { uri: `botlingknows://content/${notification.content_id}`, cursor: notification.id };
44
+ }
45
+ if (Number.isSafeInteger(notification.question_id) && Number(notification.question_id) > 0) {
46
+ return { uri: `botlingknows://question/${notification.question_id}`, cursor: notification.id };
47
+ }
48
+ return { uri: `botlingknows://notification/${notification.id}`, cursor: notification.id };
49
+ }
50
+ function metadataFor(notification) {
51
+ return {
52
+ notification_id: notification.id,
53
+ category: notification.category,
54
+ notif_type: notification.notif_type,
55
+ ...(notification.question_id == null ? {} : { question_id: notification.question_id }),
56
+ ...(notification.content_id == null ? {} : { content_id: notification.content_id }),
57
+ ...(notification.next_action === undefined ? {} : { next_action: notification.next_action }),
58
+ };
59
+ }
60
+ export function mapBotlingKnowsNotification(notification) {
61
+ if (!Number.isSafeInteger(notification.id) || notification.id <= 0 || !notification.notif_type
62
+ || typeof notification.notif_type !== "string" || !notification.category || typeof notification.category !== "string") {
63
+ throw new BridgeError("botlingknows notification shape is invalid", "invalid_source_page", 502);
64
+ }
65
+ const coalesce = Number.isSafeInteger(notification.question_id) && Number(notification.question_id) > 0
66
+ ? `question:${notification.question_id}`
67
+ : Number.isSafeInteger(notification.content_id) && Number(notification.content_id) > 0
68
+ ? `content:${notification.content_id}`
69
+ : `category:${notification.category}`;
70
+ return {
71
+ type: notification.notif_type,
72
+ occurred_at: absoluteTimestamp(notification.created_at),
73
+ dedupe_key: `notification:${notification.id}`,
74
+ coalesce_key: coalesce,
75
+ priority_hint: notification.category === "direct" ? "high" : notification.category === "activity" ? "low" : "normal",
76
+ attention_channel_hint: "life",
77
+ actor_ref: Number.isSafeInteger(notification.actor_id) && Number(notification.actor_id) > 0
78
+ ? `botlingknows:principal:${notification.actor_id}`
79
+ : null,
80
+ resource: resourceFor(notification),
81
+ metadata: metadataFor(notification),
82
+ };
83
+ }
84
+ /**
85
+ * Read-only notification adapter. The stored cursor is a stable notification
86
+ * id high-watermark plus an optional pagination continuation; a source API's
87
+ * opaque page cursor is never mistaken for a durable incremental cursor.
88
+ */
89
+ export class BotlingKnowsSourceAdapter {
90
+ client;
91
+ manifest;
92
+ constructor(client, identity = TEST_IDENTITY) {
93
+ this.client = client;
94
+ this.manifest = { ...BASE_MANIFEST, ...identity };
95
+ }
96
+ async poll(context) {
97
+ const cursor = normalizeCursor(context.cursor);
98
+ const page = await this.client.notifications({
99
+ view: "full",
100
+ mark_read: false,
101
+ limit: context.limit,
102
+ ...(cursor.page_cursor ? { cursor: cursor.page_cursor } : {}),
103
+ });
104
+ if (!page || !Array.isArray(page.notifications) || page.notifications.length > context.limit) {
105
+ throw new BridgeError("botlingknows returned an invalid notification page", "invalid_source_page", 502);
106
+ }
107
+ const ids = new Set();
108
+ for (const notification of page.notifications) {
109
+ if (!Number.isSafeInteger(notification?.id) || notification.id <= 0 || ids.has(notification.id)) {
110
+ throw new BridgeError("botlingknows notification ids are invalid", "invalid_source_page", 502);
111
+ }
112
+ ids.add(notification.id);
113
+ }
114
+ const reachedWatermark = page.notifications.some((notification) => notification.id <= cursor.high_watermark);
115
+ const fresh = page.notifications
116
+ .filter((notification) => notification.id > cursor.high_watermark)
117
+ .sort((left, right) => left.id - right.id);
118
+ const maxObserved = Math.max(cursor.pending_max_id, cursor.high_watermark, ...fresh.map((item) => item.id));
119
+ const hasMore = Boolean(page.next_cursor) && !reachedWatermark;
120
+ const next = hasMore
121
+ ? { ...cursor, page_cursor: String(page.next_cursor), pending_max_id: maxObserved }
122
+ : { v: 1, high_watermark: maxObserved, page_cursor: null, pending_max_id: maxObserved };
123
+ return {
124
+ events: fresh.map(mapBotlingKnowsNotification),
125
+ next_cursor: next,
126
+ has_more: hasMore,
127
+ };
128
+ }
129
+ }
130
+ /** Explicit operator bootstrap for a future production install. */
131
+ export async function botlingKnowsCursorFromNow(client, limit = BOTLING_KNOWS_MAX_PAGE_SIZE) {
132
+ const page = await client.notifications({ view: "full", mark_read: false, limit });
133
+ if (!page || !Array.isArray(page.notifications) || page.notifications.length > limit) {
134
+ throw new BridgeError("botlingknows returned an invalid bootstrap page", "invalid_source_page", 502);
135
+ }
136
+ const max = page.notifications.reduce((value, item) => Math.max(value, Number(item.id) || 0), 0);
137
+ if (!Number.isSafeInteger(max) || max < 0)
138
+ throw new BridgeError("botlingknows bootstrap ids are invalid", "invalid_source_page", 502);
139
+ return { v: 1, high_watermark: max, page_cursor: null, pending_max_id: max };
140
+ }
141
+ //# sourceMappingURL=botlingknows.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"botlingknows.js","sourceRoot":"","sources":["../../../src/adapters/botlingknows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAoCzC,4EAA4E;AAC5E,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,CAAC;AAY9C,MAAM,aAAa,GAAuE;IACxF,gBAAgB,EAAE,CAAC;IACnB,EAAE,EAAE,cAAc;IAClB,OAAO,EAAE,OAAO;IAChB,iBAAiB,EAAE,MAAM;IACzB,kBAAkB,EAAE,WAAW;IAC/B,2BAA2B,EAAE,SAAS;IACtC,0BAA0B,EAAE,EAAE;IAC9B,sBAAsB,EAAE,CAAC,oBAAoB,CAAC;CAC/C,CAAC;AAEF,MAAM,aAAa,GAAG;IACpB,WAAW,EAAE,mBAAmB;IAChC,mBAAmB,EAAE,UAAU,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE;CAChD,CAAC;AAEF,SAAS,eAAe,CAAC,MAAoB;IAC3C,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,EAAE,CAAC;IAC9F,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACnE,MAAM,IAAI,WAAW,CAAC,gCAAgC,EAAE,uBAAuB,EAAE,GAAG,CAAC,CAAC;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B;YAC5C,QAAQ,EAAE,OAAO;SAClB,CAAC;IACJ,CAAC;CACF;AAED,mEAAmE;AACnE,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,MAAsC,EACtC,KAAK,GAAG,2BAA2B;IAEnC,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACnF,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,KAAK,EAAE,CAAC;QACrF,MAAM,IAAI,WAAW,CAAC,iDAAiD,EAAE,qBAAqB,EAAE,GAAG,CAAC,CAAC;IACvG,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACjG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC;QAAE,MAAM,IAAI,WAAW,CAAC,wCAAwC,EAAE,qBAAqB,EAAE,GAAG,CAAC,CAAC;IACvI,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,cAAc,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,EAAE,CAAC;AAC/E,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { type PullSourceAdapter, type SourceAdapterManifest, type SourcePollContext, type SourcePollResult } from "../source-sdk.js";
2
+ import { type JsonValue, type WakeEventInput } from "../event-sdk.js";
3
+ export declare const GROUP_CHAT_EVENT_FEED_SCHEMA_VERSION: 1;
4
+ export declare const GROUP_CHAT_SOURCE_ID = "group_chat";
5
+ export declare const GROUP_CHAT_MAX_PAGE_SIZE = 250;
6
+ export type GroupChatEventType = "room.mention.created" | "room.reply.created" | "room.message.created" | "room.message.tombstoned" | "room.membership.changed";
7
+ export interface GroupChatFeedEvent {
8
+ schema_version: typeof GROUP_CHAT_EVENT_FEED_SCHEMA_VERSION;
9
+ event_id: string;
10
+ event_cursor: string | number;
11
+ type: GroupChatEventType;
12
+ occurred_at: string;
13
+ room_id: string;
14
+ message_id?: string | null;
15
+ message_cursor?: string | number | null;
16
+ actor_id?: string | null;
17
+ direct?: boolean;
18
+ metadata?: Record<string, JsonValue>;
19
+ }
20
+ export interface GroupChatEventPage {
21
+ events: GroupChatFeedEvent[];
22
+ next_cursor: string | number | null;
23
+ has_more?: boolean;
24
+ }
25
+ export interface GroupChatEventFeedClient {
26
+ readEvents(input: {
27
+ after_event_cursor: string | number | null;
28
+ limit: number;
29
+ wait_ms: 0;
30
+ types: GroupChatEventType[];
31
+ }): Promise<GroupChatEventPage> | GroupChatEventPage;
32
+ }
33
+ export declare function mapGroupChatEvent(input: GroupChatFeedEvent): WakeEventInput;
34
+ /** Reference pull adapter. It depends only on the public feed and source contracts. */
35
+ export declare class GroupChatSourceAdapter implements PullSourceAdapter {
36
+ private readonly client;
37
+ readonly manifest: SourceAdapterManifest;
38
+ constructor(client: GroupChatEventFeedClient, identity: {
39
+ subject_ref: string;
40
+ binding_fingerprint: string;
41
+ });
42
+ poll(context: SourcePollContext): Promise<SourcePollResult>;
43
+ }