perceptkit 0.2.2__py3-none-any.whl
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.
- perceptkit/__init__.py +85 -0
- perceptkit/algorithms/__init__.py +40 -0
- perceptkit/algorithms/attribution.py +147 -0
- perceptkit/algorithms/glance.py +236 -0
- perceptkit/algorithms/history.py +663 -0
- perceptkit/algorithms/identity.py +43 -0
- perceptkit/algorithms/observation.py +44 -0
- perceptkit/algorithms/streaks.py +111 -0
- perceptkit/algorithms/trend_models.py +184 -0
- perceptkit/algorithms/wake.py +149 -0
- perceptkit/catalog.py +252 -0
- perceptkit/conformance/__init__.py +28 -0
- perceptkit/conformance/memory.py +364 -0
- perceptkit/conformance/report.py +170 -0
- perceptkit/conformance/suite.py +419 -0
- perceptkit/conformance/wake.py +151 -0
- perceptkit/contracts/__init__.py +97 -0
- perceptkit/contracts/_time.py +89 -0
- perceptkit/contracts/availability.py +77 -0
- perceptkit/contracts/context.py +50 -0
- perceptkit/contracts/delivery.py +167 -0
- perceptkit/contracts/errors.py +22 -0
- perceptkit/contracts/event.py +137 -0
- perceptkit/contracts/observation.py +172 -0
- perceptkit/contracts/receipt.py +129 -0
- perceptkit/contracts/records.py +367 -0
- perceptkit/contracts/report.py +127 -0
- perceptkit/contracts/versioning.py +63 -0
- perceptkit/fields.py +184 -0
- perceptkit/kit.py +223 -0
- perceptkit/manifest/__init__.py +57 -0
- perceptkit/manifest/checks.py +323 -0
- perceptkit/manifest/mapping.py +96 -0
- perceptkit/manifest/minimal.py +1282 -0
- perceptkit/manifest/types.py +211 -0
- perceptkit/manifest/units.py +84 -0
- perceptkit/ports/__init__.py +19 -0
- perceptkit/ports/storage.py +288 -0
- perceptkit/ports/wake.py +43 -0
- perceptkit/processing/__init__.py +49 -0
- perceptkit/processing/aggregate.py +80 -0
- perceptkit/processing/dispatch.py +356 -0
- perceptkit/processing/normalize.py +458 -0
- perceptkit/processing/pipeline.py +406 -0
- perceptkit/processing/recompute.py +170 -0
- perceptkit/processing/recurrence.py +166 -0
- perceptkit/processing/scheduled.py +233 -0
- perceptkit/prompts.py +75 -0
- perceptkit/queries/__init__.py +32 -0
- perceptkit/queries/api.py +457 -0
- perceptkit/retention.py +84 -0
- perceptkit/rules/__init__.py +19 -0
- perceptkit/rules/engine.py +112 -0
- perceptkit/rules/evaluators.py +228 -0
- perceptkit/rules/types.py +236 -0
- perceptkit-0.2.2.dist-info/METADATA +439 -0
- perceptkit-0.2.2.dist-info/RECORD +59 -0
- perceptkit-0.2.2.dist-info/WHEEL +4 -0
- perceptkit-0.2.2.dist-info/licenses/LICENSE +202 -0
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: perceptkit
|
|
3
|
+
Version: 0.2.2
|
|
4
|
+
Summary: 从设备信号判断:有没有发生值得留意的事、值不值得叫醒一次 agent、以及该怎么把此刻的状况讲给它听。不采集数据、不碰存储、不调模型。
|
|
5
|
+
License:
|
|
6
|
+
Apache License
|
|
7
|
+
Version 2.0, January 2004
|
|
8
|
+
http://www.apache.org/licenses/
|
|
9
|
+
|
|
10
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
11
|
+
|
|
12
|
+
1. Definitions.
|
|
13
|
+
|
|
14
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
15
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
16
|
+
|
|
17
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
18
|
+
the copyright owner that is granting the License.
|
|
19
|
+
|
|
20
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
21
|
+
other entities that control, are controlled by, or are under common
|
|
22
|
+
control with that entity. For the purposes of this definition,
|
|
23
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
24
|
+
direction or management of such entity, whether by contract or
|
|
25
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
26
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
27
|
+
|
|
28
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
29
|
+
exercising permissions granted by this License.
|
|
30
|
+
|
|
31
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
32
|
+
including but not limited to software source code, documentation
|
|
33
|
+
source, and configuration files.
|
|
34
|
+
|
|
35
|
+
"Object" form shall mean any form resulting from mechanical
|
|
36
|
+
transformation or translation of a Source form, including but
|
|
37
|
+
not limited to compiled object code, generated documentation,
|
|
38
|
+
and conversions to other media types.
|
|
39
|
+
|
|
40
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
41
|
+
Object form, made available under the License, as indicated by a
|
|
42
|
+
copyright notice that is included in or attached to the work
|
|
43
|
+
(an example is provided in the Appendix below).
|
|
44
|
+
|
|
45
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
46
|
+
form, that is based on (or derived from) the Work and for which the
|
|
47
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
48
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
49
|
+
of this License, Derivative Works shall not include works that remain
|
|
50
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
51
|
+
the Work and Derivative Works thereof.
|
|
52
|
+
|
|
53
|
+
"Contribution" shall mean any work of authorship, including
|
|
54
|
+
the original version of the Work and any modifications or additions
|
|
55
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
56
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
57
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
58
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
59
|
+
means any form of electronic, verbal, or written communication sent
|
|
60
|
+
to the Licensor or its representatives, including but not limited to
|
|
61
|
+
communication on electronic mailing lists, source code control systems,
|
|
62
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
63
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
64
|
+
excluding communication that is conspicuously marked or otherwise
|
|
65
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
66
|
+
|
|
67
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
68
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
69
|
+
subsequently incorporated within the Work.
|
|
70
|
+
|
|
71
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
72
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
73
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
74
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
75
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
76
|
+
Work and such Derivative Works in Source or Object form.
|
|
77
|
+
|
|
78
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
79
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
80
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
81
|
+
(except as stated in this section) patent license to make, have made,
|
|
82
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
83
|
+
where such license applies only to those patent claims licensable
|
|
84
|
+
by such Contributor that are necessarily infringed by their
|
|
85
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
86
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
87
|
+
institute patent litigation against any entity (including a
|
|
88
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
89
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
90
|
+
or contributory patent infringement, then any patent licenses
|
|
91
|
+
granted to You under this License for that Work shall terminate
|
|
92
|
+
as of the date such litigation is filed.
|
|
93
|
+
|
|
94
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
95
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
96
|
+
modifications, and in Source or Object form, provided that You
|
|
97
|
+
meet the following conditions:
|
|
98
|
+
|
|
99
|
+
(a) You must give any other recipients of the Work or
|
|
100
|
+
Derivative Works a copy of this License; and
|
|
101
|
+
|
|
102
|
+
(b) You must cause any modified files to carry prominent notices
|
|
103
|
+
stating that You changed the files; and
|
|
104
|
+
|
|
105
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
106
|
+
that You distribute, all copyright, patent, trademark, and
|
|
107
|
+
attribution notices from the Source form of the Work,
|
|
108
|
+
excluding those notices that do not pertain to any part of
|
|
109
|
+
the Derivative Works; and
|
|
110
|
+
|
|
111
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
112
|
+
distribution, then any Derivative Works that You distribute must
|
|
113
|
+
include a readable copy of the attribution notices contained
|
|
114
|
+
within such NOTICE file, excluding those notices that do not
|
|
115
|
+
pertain to any part of the Derivative Works, in at least one
|
|
116
|
+
of the following places: within a NOTICE text file distributed
|
|
117
|
+
as part of the Derivative Works; within the Source form or
|
|
118
|
+
documentation, if provided along with the Derivative Works; or,
|
|
119
|
+
within a display generated by the Derivative Works, if and
|
|
120
|
+
wherever such third-party notices normally appear. The contents
|
|
121
|
+
of the NOTICE file are for informational purposes only and
|
|
122
|
+
do not modify the License. You may add Your own attribution
|
|
123
|
+
notices within Derivative Works that You distribute, alongside
|
|
124
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
125
|
+
that such additional attribution notices cannot be construed
|
|
126
|
+
as modifying the License.
|
|
127
|
+
|
|
128
|
+
You may add Your own copyright statement to Your modifications and
|
|
129
|
+
may provide additional or different license terms and conditions
|
|
130
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
131
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
132
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
133
|
+
the conditions stated in this License.
|
|
134
|
+
|
|
135
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
136
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
137
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
138
|
+
this License, without any additional terms or conditions.
|
|
139
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
140
|
+
the terms of any separate license agreement you may have executed
|
|
141
|
+
with Licensor regarding such Contributions.
|
|
142
|
+
|
|
143
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
144
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
145
|
+
except as required for reasonable and customary use in describing the
|
|
146
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
147
|
+
|
|
148
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
149
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
150
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
151
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
152
|
+
implied, including, without limitation, any warranties or conditions
|
|
153
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
154
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
155
|
+
appropriateness of using or redistributing the Work and assume any
|
|
156
|
+
risks associated with Your exercise of permissions under this License.
|
|
157
|
+
|
|
158
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
159
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
160
|
+
unless required by applicable law (such as deliberate and grossly
|
|
161
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
162
|
+
liable to You for damages, including any direct, indirect, special,
|
|
163
|
+
incidental, or consequential damages of any character arising as a
|
|
164
|
+
result of this License or out of the use or inability to use the
|
|
165
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
166
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
167
|
+
other commercial damages or losses), even if such Contributor
|
|
168
|
+
has been advised of the possibility of such damages.
|
|
169
|
+
|
|
170
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
171
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
172
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
173
|
+
or other liability obligations and/or rights consistent with this
|
|
174
|
+
License. However, in accepting such obligations, You may act only
|
|
175
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
176
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
177
|
+
defend, and hold each Contributor harmless for any liability
|
|
178
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
179
|
+
of your accepting any such warranty or additional liability.
|
|
180
|
+
|
|
181
|
+
END OF TERMS AND CONDITIONS
|
|
182
|
+
|
|
183
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
184
|
+
|
|
185
|
+
To apply the Apache License to your work, attach the following
|
|
186
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
187
|
+
replaced with your own identifying information. (Don't include
|
|
188
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
189
|
+
comment syntax for the file format. We also recommend that a
|
|
190
|
+
file or class name and description of purpose be included on the
|
|
191
|
+
same "printed page" as the copyright notice for easier
|
|
192
|
+
identification within third-party archives.
|
|
193
|
+
|
|
194
|
+
Copyright [yyyy] [name of copyright owner]
|
|
195
|
+
|
|
196
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
197
|
+
you may not use this file except in compliance with the License.
|
|
198
|
+
You may obtain a copy of the License at
|
|
199
|
+
|
|
200
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
201
|
+
|
|
202
|
+
Unless required by applicable law or agreed to in writing, software
|
|
203
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
204
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
205
|
+
See the License for the specific language governing permissions and
|
|
206
|
+
limitations under the License.
|
|
207
|
+
License-File: LICENSE
|
|
208
|
+
Keywords: agent,context,perception,proactive,wake
|
|
209
|
+
Requires-Python: >=3.10
|
|
210
|
+
Provides-Extra: dev
|
|
211
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
212
|
+
Description-Content-Type: text/markdown
|
|
213
|
+
|
|
214
|
+
# perceptkit
|
|
215
|
+
|
|
216
|
+
**一套可插拔的主动感知:从设备上报,到"该戳一下 agent 了"。**
|
|
217
|
+
|
|
218
|
+
设备把采到的东西按标准格式交给它,它负责校验、标准化、去重、落库编排、
|
|
219
|
+
按你配的规则判断"这算不算一件事"、生成事件、可靠地送到你的 agent runtime。
|
|
220
|
+
|
|
221
|
+
你要写的只有两个接口:**数据存哪儿**(`StoragePort`)和**事件交给谁**(`WakePort`)。
|
|
222
|
+
|
|
223
|
+
```python
|
|
224
|
+
from perceptkit import PerceptionKit, IngestContext
|
|
225
|
+
|
|
226
|
+
kit = PerceptionKit(storage=my_storage, wake=my_runtime, definitions=my_rules)
|
|
227
|
+
|
|
228
|
+
result = kit.ingest(report, context=IngestContext(
|
|
229
|
+
subject_id=user_id, # 从已认证连接来,绝不信客户端自报
|
|
230
|
+
received_at=now, # 你的钟
|
|
231
|
+
))
|
|
232
|
+
# 事件已经落地了。投递由你自己的 worker 驱动:
|
|
233
|
+
kit.dispatch_pending(worker_id="w1", now=now)
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
它**不采集数据、不实现数据库、不做加解密、不调模型、不读时钟** —— 那些是宿主的事。
|
|
237
|
+
零第三方依赖(有 AST 测试盯着这条)。
|
|
238
|
+
|
|
239
|
+
**顺序不在你手里,这是有意的。** "先落地再投递""迟到的数据不覆盖当前值"
|
|
240
|
+
"同一件事崩溃重投也只提醒一次" —— 这些是正确性问题,留给每个宿主自己发挥的结果是
|
|
241
|
+
同一个包装到四个宿主上、四种可靠性。所以顺序在包里定死,你只填被调用的方法体。
|
|
242
|
+
就像你写 React 组件但不决定什么时候渲染。
|
|
243
|
+
|
|
244
|
+
**现状:还没发布到 PyPI**,`pip install perceptkit` 现在装不到东西。
|
|
245
|
+
能确认好用的两条路:
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
git clone git@github.com:teleport-computer/perceptkit.git
|
|
249
|
+
cd perceptkit
|
|
250
|
+
uv run pytest # 283 条测试
|
|
251
|
+
uv run python3 examples/quickstart.py # 一分钟看它怎么判断
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
想在别的项目里依赖它:
|
|
255
|
+
|
|
256
|
+
```toml
|
|
257
|
+
# 另一个项目的 pyproject.toml
|
|
258
|
+
perceptkit = { git = "ssh://git@github.com/teleport-computer/perceptkit.git" }
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
或者本地路径依赖(两个仓库在同一台机器上时):
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
uv add --editable ../perceptkit
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
## 〇、包里有什么
|
|
270
|
+
|
|
271
|
+
```
|
|
272
|
+
contracts/ 四个信封(上报 / 观测 / 事件 / 回执) + 三态 + 可信上下文
|
|
273
|
+
+ 八个逻辑存储对象 + 投递状态机
|
|
274
|
+
manifest/ 每个字段的单一声明处(类型/单位/TTL/保留期/聚合/趋势/隐私)
|
|
275
|
+
+ 四条自动检查,让"忘了声明"变成一条红色的测试
|
|
276
|
+
ports/ StoragePort / WakePort —— 你要实现的两个接口
|
|
277
|
+
processing/ 校验 → 标准化 → 去重 → 落库 → 当前值 → 聚合 → 求值 → 发件箱
|
|
278
|
+
rules/ 九种内置规则 + 生命周期 + 自定义 evaluator 接口
|
|
279
|
+
queries/ 读取侧八个函数(带 TTL 判定、趋势模型选择、缺数据显式化、隐私投影)
|
|
280
|
+
conformance/ 十条一致性保证的检查套件 + 内存版存储(测试工具)
|
|
281
|
+
algorithms 归属日期 / 连续天数 / 趋势模型 / 日聚合 / 去重键 …(原有纯函数)
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
**一句话分工**:宿主决定怎么存、怎么投、说不说话;这个包规定存哪些事实、
|
|
285
|
+
按什么顺序、满足什么保证。
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
## 一、它跟这几类东西不是一回事
|
|
290
|
+
|
|
291
|
+
```
|
|
292
|
+
地理围栏 / 系统事件检测 SDK 它们负责"测到了什么"(到没到某个地点、
|
|
293
|
+
(Radar、CoreLocation region 解没解锁、屏幕有没有变化);这个包接手
|
|
294
|
+
monitoring、系统健康/屏幕时间框架) 的是下一步——"测到的这个变化,够不够
|
|
295
|
+
资格戳一下 agent",它自己不做检测。
|
|
296
|
+
|
|
297
|
+
推送时机优化 / 用户参与度引擎 它们的目标函数是"提高打开率/参与度";
|
|
298
|
+
(send-time optimization、 这个包没有目标函数,只回答一道是非题:
|
|
299
|
+
engagement 引擎) 值不值得,不掺杂"怎么让人多点开"。
|
|
300
|
+
|
|
301
|
+
健康看板 / Quantified-Self App 它们的核心产品就是把数字摆给你看
|
|
302
|
+
(Apple 健康、Oura、WHOOP 这类) (心率曲线、睡眠时长);这个包的 glance
|
|
303
|
+
刻意反过来——从不吐出一个数字。
|
|
304
|
+
|
|
305
|
+
主动性 agent 运行时 / 编排框架 "戳醒之后该不该开口、开口说什么",这些
|
|
306
|
+
是宿主运行时的职责;这个包只回答到
|
|
307
|
+
"值不值得戳"为止,一步都不往前多走。
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
它是**要不要打扰的判断力**,不是感知系统、不是增长引擎、不是健康 App、
|
|
311
|
+
也不是对话运行时。
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
## 二、一分钟跑通
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
uv run python3 examples/quickstart.py
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
不联网、不需要 API key、不碰任何存储。走一个具体场景:老王最近几晚睡得
|
|
322
|
+
不好,此刻手机检测到他到了常去的"公司"——从一条原始测量,一路走到
|
|
323
|
+
"该怎么把此刻讲给模型听"。
|
|
324
|
+
|
|
325
|
+
> 注意:直接 `python3 examples/quickstart.py`(不经过 `uv run`)会报
|
|
326
|
+
> `ModuleNotFoundError: No module named 'perceptkit'`——这是预期的,本包
|
|
327
|
+
> 是 src-layout,没有发布安装包时只能通过 `uv run`(或先 `uv sync`/
|
|
328
|
+
> `pip install -e .`)让解释器找到它。
|
|
329
|
+
|
|
330
|
+
最小代码:
|
|
331
|
+
|
|
332
|
+
```python
|
|
333
|
+
from perceptkit.observation import classify
|
|
334
|
+
from perceptkit.wake import should_wake
|
|
335
|
+
from perceptkit.glance import build_perception_glance
|
|
336
|
+
|
|
337
|
+
# 一条测量:有值、有观测到零值、没测到、还是不可用?四态分开判断,
|
|
338
|
+
# 不能拿"没测到"直接当"测到是 0",两者会喂出截然不同的错误结论。
|
|
339
|
+
state = classify(180.0) # -> "observed"
|
|
340
|
+
|
|
341
|
+
# 这次到达值不值得戳一下 agent(30 秒内的第二次到达会被防抖拦下)
|
|
342
|
+
ok, reason = should_wake(
|
|
343
|
+
"arrival", enabled_sources=("arrival",),
|
|
344
|
+
last_wake_ts=1000.0, now=1030.0, debounce_sec=60.0,
|
|
345
|
+
)
|
|
346
|
+
|
|
347
|
+
# 此刻的状况压成一份摘要——只有 True/False,没有一个具体数字
|
|
348
|
+
glance = build_perception_glance({"location": {"place_label": "公司"}})
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
## 三、两个真正的关键判断
|
|
354
|
+
|
|
355
|
+
### 1. 戳醒 ≠ 该开口了
|
|
356
|
+
|
|
357
|
+
戳醒之后,agent 继续睡 / 只看一眼 / 开口说话,是三个平行且同等合法的
|
|
358
|
+
结局。这个包只回答"值不值得戳一下",不参与"戳完之后该怎么办",
|
|
359
|
+
也不产出任何"该说话了"式的措辞。
|
|
360
|
+
|
|
361
|
+
```
|
|
362
|
+
之前(如果 wake 直接等于开口)
|
|
363
|
+
用户到公司 → 库判定"该说话" → agent 不管场合硬接一句"你到公司啦"
|
|
364
|
+
→ 用户在开会,手机弹了句废话
|
|
365
|
+
|
|
366
|
+
之后(这个包的实际语义)
|
|
367
|
+
用户到公司 → should_wake() 只回答"这次到达值得关注"
|
|
368
|
+
→ 具体开不开口、说不说话,完全交给宿主运行时按当下场合自己判断
|
|
369
|
+
(库的返回值里连"建议怎么说"这种字段都没有——不是没写全,是故意不给)
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### 2. 摘要只出布尔值,从不出数字
|
|
373
|
+
|
|
374
|
+
```
|
|
375
|
+
之前(把数字直接喂给模型)
|
|
376
|
+
"你昨晚睡了 5 小时 12 分钟"
|
|
377
|
+
→ 模型像念体检报告一样把这句话复述给用户,而不是自己判断要不要在意
|
|
378
|
+
|
|
379
|
+
之后(build_perception_glance 的实际产出)
|
|
380
|
+
{"health": {"available": True, "notable_change": True}}
|
|
381
|
+
→ 模型自己决定"睡眠有显著变化"值不值得多看一眼;
|
|
382
|
+
值得的话,它主动去查工具拿具体数字——这时候数字才是"被用",
|
|
383
|
+
而不是"被念出来"
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
四个信号态(`observation.classify`)、防抖与开关(`wake.should_wake`)、
|
|
387
|
+
连续偏离的迟滞判断(`streaks.should_trigger`)、按指标类型选对趋势读法
|
|
388
|
+
(`trend_models.model_for`)——都是在为这份摘要和这次判断兜底,细节见
|
|
389
|
+
下面目录里对应模块的模块级文档字符串。
|
|
390
|
+
|
|
391
|
+
---
|
|
392
|
+
|
|
393
|
+
## 四、库替你做的判断,与不替你做的判断
|
|
394
|
+
|
|
395
|
+
```
|
|
396
|
+
在库里 这个信号有哪些字段、多久算新鲜(catalog) · agent 能看哪些字段、
|
|
397
|
+
该不该给(fields) · 此刻是否有事发生,只出 bool(glance) ·
|
|
398
|
+
按天汇总、看出什么趋势变化(history) · 该怎么把这些讲给模型(prompts) ·
|
|
399
|
+
这次变化值不值得叫醒一次 agent(wake) · 一条测量到底是"有观测到零值"
|
|
400
|
+
还是"压根没测到"(observation) · 一条测量该记在本地日历的哪一天
|
|
401
|
+
(attribution) · "连续 N 天"怎么断续、怎么只在跨入异常时触发一次
|
|
402
|
+
(streaks) · 三种趋势判读方式:波动/漂移/周期性(trend_models) ·
|
|
403
|
+
每类信号的历史该留多久(retention) · 一条测量的去重键怎么造
|
|
404
|
+
(identity)
|
|
405
|
+
|
|
406
|
+
不在库里 采集数据 · 存储 · 加解密 · 账号身份与鉴权 · 定时器/调度 ·
|
|
407
|
+
真正调模型 · 叫醒之后该说什么话
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
---
|
|
411
|
+
|
|
412
|
+
## 五、目录
|
|
413
|
+
|
|
414
|
+
```
|
|
415
|
+
src/perceptkit/
|
|
416
|
+
catalog.py 信号有哪些字段、多久算新鲜
|
|
417
|
+
fields.py agent 能看哪些字段 + 权限判断
|
|
418
|
+
glance.py 此刻的纯 bool 摘要
|
|
419
|
+
history.py 按天汇总、显著变化
|
|
420
|
+
prompts.py 该怎么把这些讲给模型
|
|
421
|
+
wake.py 值不值得叫醒一次 agent
|
|
422
|
+
observation.py 四态:observed / observed-zero / not-observed / unavailable
|
|
423
|
+
attribution.py 一条测量归本地日历的哪一天
|
|
424
|
+
streaks.py "连续 N 天"的可执行定义
|
|
425
|
+
trend_models.py 三种趋势判读方式:波动/漂移/周期性
|
|
426
|
+
retention.py 每类信号的历史留多久
|
|
427
|
+
identity.py 一条测量的去重键
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
## 六、现状
|
|
431
|
+
|
|
432
|
+
107 条测试全绿(含 `test_purity.py` 的 AST 扫描:本包只依赖标准库,
|
|
433
|
+
以及 `test_no_host_leakage.py`:不带宿主内部痕迹)。`examples/quickstart.py`
|
|
434
|
+
本身也有一条测试盯着(`tests/test_examples.py`)——它必须一直能跑,
|
|
435
|
+
不能悄悄烂掉。
|
|
436
|
+
|
|
437
|
+
## 许可
|
|
438
|
+
|
|
439
|
+
Apache-2.0
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
perceptkit/__init__.py,sha256=Ulryo2oK6bxFnMpPA_tfblwgL2DkBD72vUy_HJsH3ZA,3306
|
|
2
|
+
perceptkit/catalog.py,sha256=x1MFN549tZBid6sWo0nNCdyGoWcOzRkPdA5T5yGYKhM,13562
|
|
3
|
+
perceptkit/fields.py,sha256=wOY60o2Xkyzt8wA3mccOy0cg9VIWIlWwayPpbcZsxr0,8051
|
|
4
|
+
perceptkit/kit.py,sha256=e0kig5XWf71YQxLAuoNnbl4CpnIHolzxxePd2pcsgIY,10125
|
|
5
|
+
perceptkit/prompts.py,sha256=qWQl7-a4KIk7ikFgNzbJTc2vUcLpznCCGzlZTysV6lA,4451
|
|
6
|
+
perceptkit/retention.py,sha256=OLgsDBfYMziQpQQ3nR5OilMBH_3_yWFuQ83imccwRCA,3913
|
|
7
|
+
perceptkit/algorithms/__init__.py,sha256=ovAn8IyUmcpH3HwQI1qL6qRXsChUQNqCcYF3jm9JBbc,1707
|
|
8
|
+
perceptkit/algorithms/attribution.py,sha256=kNsBA8wnYaZZuGjFYRrilMPKBgtPa5l2DxaXu0rQk7A,7535
|
|
9
|
+
perceptkit/algorithms/glance.py,sha256=aesDjsQ_OlQi2dj0dvKd1RDG9k_gwHhiBp6BeUtZ68M,9989
|
|
10
|
+
perceptkit/algorithms/history.py,sha256=Y0O1bawFukTslVeGKAocNPyKNs-Rudw059lF6LrWzRA,25565
|
|
11
|
+
perceptkit/algorithms/identity.py,sha256=FL8gzaBIaq2pK4bS1GgBH_BvoPP_0gzvauPL9uAWlcg,2158
|
|
12
|
+
perceptkit/algorithms/observation.py,sha256=RMek50gW1R6ofJeJieELbjHUVGFj99TNlyBJA4BVlzg,2005
|
|
13
|
+
perceptkit/algorithms/streaks.py,sha256=mU6x2h86r23emLFzeaSsN7aNO1JCd8DVS3Ou7GVVDhQ,5152
|
|
14
|
+
perceptkit/algorithms/trend_models.py,sha256=bgeHtCFL3diffa9LkzjUF0Lw1cyhpZDEmjsi3jgrs5o,7110
|
|
15
|
+
perceptkit/algorithms/wake.py,sha256=MwDAqC9GMTeRB_PYkPdPlk4-MR_2X5-E3wkJ-qhlR54,7622
|
|
16
|
+
perceptkit/conformance/__init__.py,sha256=k2aBvbR9iu6BlzIw-2C5Zy7eQ70nTe0RO4O6byTikr4,1242
|
|
17
|
+
perceptkit/conformance/memory.py,sha256=KaUIaG6TAH2ECmMabgSDnReFBBY_VrGChrEOhvwDieU,16138
|
|
18
|
+
perceptkit/conformance/report.py,sha256=53PFa6QIAgyM0pVZE29WoDV4b8vO-XNLKveGHGfAy54,8150
|
|
19
|
+
perceptkit/conformance/suite.py,sha256=wug93jf7B1bi8hqCrasXxvQ5MzOqa6pEA4w3TX5H4E0,19151
|
|
20
|
+
perceptkit/conformance/wake.py,sha256=r5TK8I9IQRzKiOZKYtUCbibGxNZhDEkYFgObsvfsGtw,6971
|
|
21
|
+
perceptkit/contracts/__init__.py,sha256=UFABM9Xe3C80MM-fC0O8lAo5RTmNdcohDFSkE8OSmcA,3018
|
|
22
|
+
perceptkit/contracts/_time.py,sha256=wflRerHUpnCEndWvL5FYmkoqMyqDd2F_0fyOnCqcz9I,3255
|
|
23
|
+
perceptkit/contracts/availability.py,sha256=_uOeZd0D-_kRoey6PyXUDl0jf5p0ECBA58tIR6kOI80,3226
|
|
24
|
+
perceptkit/contracts/context.py,sha256=4h3nvW5uEQG_bGEI8GNnryS4gcqymzcMfOYaRQ92lho,2426
|
|
25
|
+
perceptkit/contracts/delivery.py,sha256=GODAXnAZzTOmMale6RKu9TaKRMNduicegr17d9fno2s,7046
|
|
26
|
+
perceptkit/contracts/errors.py,sha256=Ago3Bwbox_zkZAs-R1rEavLitVZ_dEosMaEQfFEzdu4,611
|
|
27
|
+
perceptkit/contracts/event.py,sha256=SV8a6PDAuw1NuHzsYFTz822gLLe73SRYegsCmHBqSEo,5411
|
|
28
|
+
perceptkit/contracts/observation.py,sha256=swd3nAeOhTjeI2OsoimpMtzcDk5a71-dsk-wHZcXd1s,8088
|
|
29
|
+
perceptkit/contracts/receipt.py,sha256=uMhYPWzBJdjpkrqTLPAf05XiwSIRQj3JReB4t6ohOD8,5151
|
|
30
|
+
perceptkit/contracts/records.py,sha256=ZGPMToaTbOnXzz_jnmuwnRgBzE75m4_yijy3eFgVg64,14744
|
|
31
|
+
perceptkit/contracts/report.py,sha256=WysgcgPomy1GUSDNqP1aZdm97PIFxC_NookwMNBBE_s,5245
|
|
32
|
+
perceptkit/contracts/versioning.py,sha256=sAi6l0-q_tnrjyx9B44ZT_pOG0rKHuBy9P5pPHjNxac,2828
|
|
33
|
+
perceptkit/manifest/__init__.py,sha256=3lB6GLD4333-yicoQgaXskUKPUv56x944vlP0Nti3NA,2054
|
|
34
|
+
perceptkit/manifest/checks.py,sha256=gxTJHaTQdjROZ4OwjiWTNEd5AMDnFxdotY72TXaKt0w,14796
|
|
35
|
+
perceptkit/manifest/mapping.py,sha256=ZV4QQZ-K0KxTkWrREi_4Q-KBzbRmkHsN9DCLkiYmCoU,3806
|
|
36
|
+
perceptkit/manifest/minimal.py,sha256=Q7jnAvraHv5PXcCIkKNbYeewpwKA-bHx-ZA11_n8Nbc,55657
|
|
37
|
+
perceptkit/manifest/types.py,sha256=kBHjn_5ZjQ36LXGVdiN3dPUPi9t6ONRtxa6SpMu4Nvk,9836
|
|
38
|
+
perceptkit/manifest/units.py,sha256=7vwDI2t2vf43rPjiNbIEzsiQD1htB-dyxooG3ljSSPk,3325
|
|
39
|
+
perceptkit/ports/__init__.py,sha256=unBgR6gLGa3Cepqxxd-Q495s_FZvCcry1uloUlOn5iw,813
|
|
40
|
+
perceptkit/ports/storage.py,sha256=nJOfDnLB4FazHQMbh_dw6-t5hTLwNWaRLZAdmlFP41Q,11777
|
|
41
|
+
perceptkit/ports/wake.py,sha256=YyezruKvBth9KWN0ufQBw6c_6mCS_rCmCfh3GOllA58,1892
|
|
42
|
+
perceptkit/processing/__init__.py,sha256=EoLAWNlJhlt40DjyIFeNaAsbD7DyZyD0uV8TI96V-oU,1531
|
|
43
|
+
perceptkit/processing/aggregate.py,sha256=igmJCVakfj4Fjw6OE-zZ6xTdhPxkxQ5vSIFhMBalTc0,3656
|
|
44
|
+
perceptkit/processing/dispatch.py,sha256=JVRO154rf1aygc3j97rrZEVcgmKCW3iiJkgWZto7lDA,14541
|
|
45
|
+
perceptkit/processing/normalize.py,sha256=JyVG-3omaU8aTzeByzeV2NDHA7sfwoHKZhSb3toLI_E,19740
|
|
46
|
+
perceptkit/processing/pipeline.py,sha256=8E7otARTf15j0p_tx1spRUpJPGDPksm0cke8uaHh4_Y,17149
|
|
47
|
+
perceptkit/processing/recompute.py,sha256=ajE6Pl7T4dvPU_6HLLaHS6P5B9CZj3XUvQM2s-8xW0s,6360
|
|
48
|
+
perceptkit/processing/recurrence.py,sha256=xHX1MoTDFa5YqbkJR1qVA6eonMZg1Vrjy8nZ1_VzcSQ,6871
|
|
49
|
+
perceptkit/processing/scheduled.py,sha256=4znoK6HeQQe5xgTw_ut_UsEohVOLfvWnGFAZFlmWElw,9059
|
|
50
|
+
perceptkit/queries/__init__.py,sha256=gB7zds_4aNM9bkoa5Pi21CQB0BrrNIIUFzIF4dq_urE,947
|
|
51
|
+
perceptkit/queries/api.py,sha256=y3j7AvHKScu9tuAaZU69GgrD6MBqXhh65F9HS5qnRY0,19602
|
|
52
|
+
perceptkit/rules/__init__.py,sha256=rfM3LOVPcWhIMAi36QzmjhYTuaYIKh2ZxMqTcDfqJTk,730
|
|
53
|
+
perceptkit/rules/engine.py,sha256=FrS54q4Hc13WxE3xnKo_MZB4fsm7z1FKi8vezMzmVEk,4447
|
|
54
|
+
perceptkit/rules/evaluators.py,sha256=yrA6heDKqV6pysheeGaC7nw_8RQZsubPf10B8T3sjD4,10029
|
|
55
|
+
perceptkit/rules/types.py,sha256=w2cS02a5h7Truj29xCxkxbQn-0gfa_v4OMCnhCnTqz0,10045
|
|
56
|
+
perceptkit-0.2.2.dist-info/METADATA,sha256=v3SxSv5heo2jANwIEJgvjZqDD7Seaf5HUQVJodQ8ADU,23118
|
|
57
|
+
perceptkit-0.2.2.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
|
|
58
|
+
perceptkit-0.2.2.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
59
|
+
perceptkit-0.2.2.dist-info/RECORD,,
|