@celestea/core 2.7.1

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 (80) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +95 -0
  3. package/contracts/data-files/checkpoint.schema.json +111 -0
  4. package/contracts/data-files/cli-main-jsonl-precompact.schema.json +27 -0
  5. package/contracts/data-files/cli-main-jsonl.schema.json +22 -0
  6. package/contracts/data-files/fallbacks.schema.json +71 -0
  7. package/contracts/data-files/index.json +124 -0
  8. package/contracts/data-files/pricing.schema.json +65 -0
  9. package/contracts/data-files/prompts.schema.json +130 -0
  10. package/contracts/data-files/providers.schema.json +177 -0
  11. package/contracts/data-files/registry-tsv.schema.json +74 -0
  12. package/contracts/data-files/session.schema.json +51 -0
  13. package/contracts/data-files/usage-ledger.schema.json +112 -0
  14. package/contracts/data-files/workspaces.schema.json +63 -0
  15. package/contracts/endpoints.json +4390 -0
  16. package/contracts/probe-evidence.json +219 -0
  17. package/contracts/route-table.snapshot.json +377 -0
  18. package/contracts/scope-hash-vectors.json +273 -0
  19. package/contracts/session-event.schema.json +441 -0
  20. package/contracts/sse-events.json +202 -0
  21. package/contracts/tools.json +730 -0
  22. package/dist/agent.d.ts +65 -0
  23. package/dist/agent.js +36 -0
  24. package/dist/celestea-home.d.ts +63 -0
  25. package/dist/celestea-home.js +96 -0
  26. package/dist/celestea-sources.d.ts +53 -0
  27. package/dist/celestea-sources.js +61 -0
  28. package/dist/context.d.ts +33 -0
  29. package/dist/context.js +55 -0
  30. package/dist/contracts/index.d.ts +234 -0
  31. package/dist/contracts/index.js +159 -0
  32. package/dist/errors.d.ts +16 -0
  33. package/dist/errors.js +22 -0
  34. package/dist/event-bus.d.ts +60 -0
  35. package/dist/event-bus.js +100 -0
  36. package/dist/index.d.ts +66 -0
  37. package/dist/index.js +66 -0
  38. package/dist/injection.d.ts +61 -0
  39. package/dist/injection.js +27 -0
  40. package/dist/json.d.ts +34 -0
  41. package/dist/json.js +127 -0
  42. package/dist/llm.d.ts +34 -0
  43. package/dist/llm.js +41 -0
  44. package/dist/memory.d.ts +72 -0
  45. package/dist/memory.js +123 -0
  46. package/dist/message.d.ts +189 -0
  47. package/dist/message.js +252 -0
  48. package/dist/plugin.d.ts +38 -0
  49. package/dist/plugin.js +49 -0
  50. package/dist/projection.d.ts +67 -0
  51. package/dist/projection.js +168 -0
  52. package/dist/question.d.ts +154 -0
  53. package/dist/question.js +82 -0
  54. package/dist/redact.d.ts +40 -0
  55. package/dist/redact.js +185 -0
  56. package/dist/repo.d.ts +14 -0
  57. package/dist/repo.js +87 -0
  58. package/dist/sandbox.d.ts +182 -0
  59. package/dist/sandbox.js +78 -0
  60. package/dist/session-event.d.ts +57 -0
  61. package/dist/session-event.js +425 -0
  62. package/dist/session-log.d.ts +71 -0
  63. package/dist/session-log.js +66 -0
  64. package/dist/skill-catalog.d.ts +29 -0
  65. package/dist/skill-catalog.js +52 -0
  66. package/dist/skills.d.ts +116 -0
  67. package/dist/skills.js +273 -0
  68. package/dist/sse-bus.d.ts +40 -0
  69. package/dist/sse-bus.js +105 -0
  70. package/dist/stream.d.ts +115 -0
  71. package/dist/stream.js +52 -0
  72. package/dist/tool-surface.d.ts +45 -0
  73. package/dist/tool-surface.js +98 -0
  74. package/dist/tool.d.ts +77 -0
  75. package/dist/tool.js +15 -0
  76. package/dist/turn-id.d.ts +37 -0
  77. package/dist/turn-id.js +76 -0
  78. package/dist/types.d.ts +396 -0
  79. package/dist/types.js +58 -0
  80. package/package.json +27 -0
@@ -0,0 +1,273 @@
1
+ {
2
+ "$comment": "冻结向量:前端 security/scope-hash.ts 与服务端 apps/studio/src/store/grants.ts 必须对本文件的每一条逐字给出同一个 canonical_json 与 sha256。任一端偏离即门禁失败(前端 frontend/tools/check-scope-hash.mjs / 服务端 tests/scope-hash-vectors.test.ts)。",
3
+ "schema": 1,
4
+ "kind": "scope-hash-frozen-vectors",
5
+ "contract": "提权范围的规范序列化 + SHA-256(= 线上 scope_hash,设计 §6.4 / W516;前端 security/scope-hash.ts)",
6
+ "source_of_truth": "apps/studio/src/store/grants.ts 的 canonicalScopeJson / canonicalScopeHash(本文件的 canonical_json / sha256 由该实现产出)",
7
+ "must_match_verbatim": "两侧必须逐字一致:前端把摘要放进一次性令牌,服务端拿到提交体后按自己的公式重算再比对;任何一个字节不同 ⇒ 每次授予都被判 403(历史事故 commit 692f19c 就是这个原因)。",
8
+ "shape": "{\"cap\":\"<cap>\",\"scope\":{\"<roots|hosts|tools>\":[\"…\"]}};布尔类 cap(network/unsandboxed)恒为 {\"cap\":\"<cap>\",\"scope\":{}}。",
9
+ "pipeline": {
10
+ "frontend": "canonicalScopeJson(cap, scope) → sha256(utf8(json)),见 frontend/src/security/scope-hash.ts(scopeHashOf 优先 WebCrypto,非安全上下文回落自带实现 sha256Hex)",
11
+ "server": "validateScope(cap, scope, knownSecrets) → canonicalScopeHash(cap, validatedScope)"
12
+ },
13
+ "shared_domain": [
14
+ "向量的 scope 取『两侧都能接受』的交集;服务端 validateScope 会拒绝的输入不进本文件(如空数组、>32 项、含首尾空白或换行的值——looksLikeCredential 把首尾空白直接判为凭据形状、非本 cap 的键、非字符串项)",
15
+ "规范化的等价性:前端 normList 与服务端 validateScope 都做去重(首现序无关,因为随后都排序);值一律按 JS 默认 sort(UTF-16 码元序,字典序,不是数值序)排序",
16
+ "cap 白名单:read_roots/write_roots→roots、net_hosts→hosts、tool_extra→tools、network/unsandboxed→无范围(scope 里出现任何键都被丢成 {})"
17
+ ],
18
+ "guards": {
19
+ "frontend": "frontend/tools/check-scope-hash.mjs(已接进 frontend package.json 的 check/check:scope-hash)",
20
+ "server": "/src/celestea_studio-ts/tests/scope-hash-vectors.test.ts(vitest,含直接导入前端纯函数逐字对拍)",
21
+ "vectors": "本文件(单一真源)"
22
+ },
23
+ "regenerate": "改了两侧任意一处的形状/算法后,必须同时更新本文件:用服务端 pipeline 重算 canonical_json/sha256(临时脚本 import apps/studio/src/store/grants.ts + frontend/src/security/scope-hash.ts,断言两者一致后再落盘);只改一侧会立即被两侧门禁拦住。",
24
+ "vectors": [
25
+ {
26
+ "name": "read_roots-single",
27
+ "why": "单目录:最基本的授予形状",
28
+ "cap": "read_roots",
29
+ "scope": {
30
+ "roots": [
31
+ "/srv/data"
32
+ ]
33
+ },
34
+ "canonical_json": "{\"cap\":\"read_roots\",\"scope\":{\"roots\":[\"/srv/data\"]}}",
35
+ "sha256": "61f9ab6ed6d996c998a695d5a307a6388ad3ef94bf5ea9524cbc8bc8b247873d"
36
+ },
37
+ {
38
+ "name": "read_roots-normalize",
39
+ "why": "去重 + 排序(首现序无关)",
40
+ "cap": "read_roots",
41
+ "scope": {
42
+ "roots": [
43
+ "/srv/b",
44
+ "/srv/a",
45
+ "/srv/a"
46
+ ]
47
+ },
48
+ "canonical_json": "{\"cap\":\"read_roots\",\"scope\":{\"roots\":[\"/srv/a\",\"/srv/b\"]}}",
49
+ "sha256": "ddd19aba92b7f8ff34fc52187b14a2ce63636bd13214840f5d032e1ddfdfb876"
50
+ },
51
+ {
52
+ "name": "read_roots-lexicographic-sort",
53
+ "why": "JS 默认 sort 是字典序:/p1 < /p10 < /p2",
54
+ "cap": "read_roots",
55
+ "scope": {
56
+ "roots": [
57
+ "/p10",
58
+ "/p2",
59
+ "/p1"
60
+ ]
61
+ },
62
+ "canonical_json": "{\"cap\":\"read_roots\",\"scope\":{\"roots\":[\"/p1\",\"/p10\",\"/p2\"]}}",
63
+ "sha256": "70ea4de26410cb393304f973bc3889c9b62def9fec512ae267566035d2d60b3b"
64
+ },
65
+ {
66
+ "name": "read_roots-unicode-and-space",
67
+ "why": "非 ASCII 与内嵌空格按 UTF-16 码元排序",
68
+ "cap": "read_roots",
69
+ "scope": {
70
+ "roots": [
71
+ "/srv/数据 目录",
72
+ "/srv/aber"
73
+ ]
74
+ },
75
+ "canonical_json": "{\"cap\":\"read_roots\",\"scope\":{\"roots\":[\"/srv/aber\",\"/srv/数据 目录\"]}}",
76
+ "sha256": "3c0be2e08adaf88350024514e69540fba5201287e34149ad3e2707521444ae83"
77
+ },
78
+ {
79
+ "name": "read_roots-max-32-entries",
80
+ "why": "MAX_SCOPE_ENTRIES=32 上边界(倒序输入)",
81
+ "cap": "read_roots",
82
+ "scope": {
83
+ "roots": [
84
+ "/srv/p32",
85
+ "/srv/p31",
86
+ "/srv/p30",
87
+ "/srv/p29",
88
+ "/srv/p28",
89
+ "/srv/p27",
90
+ "/srv/p26",
91
+ "/srv/p25",
92
+ "/srv/p24",
93
+ "/srv/p23",
94
+ "/srv/p22",
95
+ "/srv/p21",
96
+ "/srv/p20",
97
+ "/srv/p19",
98
+ "/srv/p18",
99
+ "/srv/p17",
100
+ "/srv/p16",
101
+ "/srv/p15",
102
+ "/srv/p14",
103
+ "/srv/p13",
104
+ "/srv/p12",
105
+ "/srv/p11",
106
+ "/srv/p10",
107
+ "/srv/p09",
108
+ "/srv/p08",
109
+ "/srv/p07",
110
+ "/srv/p06",
111
+ "/srv/p05",
112
+ "/srv/p04",
113
+ "/srv/p03",
114
+ "/srv/p02",
115
+ "/srv/p01"
116
+ ]
117
+ },
118
+ "canonical_json": "{\"cap\":\"read_roots\",\"scope\":{\"roots\":[\"/srv/p01\",\"/srv/p02\",\"/srv/p03\",\"/srv/p04\",\"/srv/p05\",\"/srv/p06\",\"/srv/p07\",\"/srv/p08\",\"/srv/p09\",\"/srv/p10\",\"/srv/p11\",\"/srv/p12\",\"/srv/p13\",\"/srv/p14\",\"/srv/p15\",\"/srv/p16\",\"/srv/p17\",\"/srv/p18\",\"/srv/p19\",\"/srv/p20\",\"/srv/p21\",\"/srv/p22\",\"/srv/p23\",\"/srv/p24\",\"/srv/p25\",\"/srv/p26\",\"/srv/p27\",\"/srv/p28\",\"/srv/p29\",\"/srv/p30\",\"/srv/p31\",\"/srv/p32\"]}}",
119
+ "sha256": "d2fc3f17fb04097be500271a2806f0bf49d3d6cda9fdeac35ad02a693ed70611"
120
+ },
121
+ {
122
+ "name": "write_roots-multi-normalize",
123
+ "why": "多目录 + 重复项去重",
124
+ "cap": "write_roots",
125
+ "scope": {
126
+ "roots": [
127
+ "/var/log",
128
+ "/var/log",
129
+ "/tmp",
130
+ "/etc"
131
+ ]
132
+ },
133
+ "canonical_json": "{\"cap\":\"write_roots\",\"scope\":{\"roots\":[\"/etc\",\"/tmp\",\"/var/log\"]}}",
134
+ "sha256": "9ffce184793f9cc38f7718372180272240ad001f5e2c9b489813156b7ac9c496"
135
+ },
136
+ {
137
+ "name": "write_roots-deep",
138
+ "why": "深路径逐字保留",
139
+ "cap": "write_roots",
140
+ "scope": {
141
+ "roots": [
142
+ "/srv/app/config"
143
+ ]
144
+ },
145
+ "canonical_json": "{\"cap\":\"write_roots\",\"scope\":{\"roots\":[\"/srv/app/config\"]}}",
146
+ "sha256": "54e43f84a191b4ec7e76708ec6f722dca8a653e07042daa4d8cee681daad3a62"
147
+ },
148
+ {
149
+ "name": "net_hosts-single",
150
+ "why": "单站点",
151
+ "cap": "net_hosts",
152
+ "scope": {
153
+ "hosts": [
154
+ "example.com"
155
+ ]
156
+ },
157
+ "canonical_json": "{\"cap\":\"net_hosts\",\"scope\":{\"hosts\":[\"example.com\"]}}",
158
+ "sha256": "ae80bd277d0ae244ee4ac80b770f64df5c23fd87b33ded3344e457cd80710025"
159
+ },
160
+ {
161
+ "name": "net_hosts-mixed-case-port",
162
+ "why": "大小写与端口逐字保留(大写先于小写)",
163
+ "cap": "net_hosts",
164
+ "scope": {
165
+ "hosts": [
166
+ "api.example.com:443",
167
+ "API.example.com",
168
+ "localhost:8080",
169
+ "10.0.0.5"
170
+ ]
171
+ },
172
+ "canonical_json": "{\"cap\":\"net_hosts\",\"scope\":{\"hosts\":[\"10.0.0.5\",\"API.example.com\",\"api.example.com:443\",\"localhost:8080\"]}}",
173
+ "sha256": "8af30986ffefc490dc05ff9c459ab06dda8cdecd4d775b694a14a4df37aa5892"
174
+ },
175
+ {
176
+ "name": "net_hosts-normalize",
177
+ "why": "站点列表去重",
178
+ "cap": "net_hosts",
179
+ "scope": {
180
+ "hosts": [
181
+ "b.example.com",
182
+ "a.example.com",
183
+ "a.example.com"
184
+ ]
185
+ },
186
+ "canonical_json": "{\"cap\":\"net_hosts\",\"scope\":{\"hosts\":[\"a.example.com\",\"b.example.com\"]}}",
187
+ "sha256": "80716d8bfe1026c82a1ea1972784b5e0247980d8d323cc668847f702a935af86"
188
+ },
189
+ {
190
+ "name": "tool_extra-single",
191
+ "why": "单工具",
192
+ "cap": "tool_extra",
193
+ "scope": {
194
+ "tools": [
195
+ "Bash"
196
+ ]
197
+ },
198
+ "canonical_json": "{\"cap\":\"tool_extra\",\"scope\":{\"tools\":[\"Bash\"]}}",
199
+ "sha256": "7604f8e69fbd0c16c8a45414d469f37b380c9f9d75f9ff0e5e17ec53f833c5c2"
200
+ },
201
+ {
202
+ "name": "tool_extra-normalize",
203
+ "why": "工具名去重 + 排序",
204
+ "cap": "tool_extra",
205
+ "scope": {
206
+ "tools": [
207
+ "Read",
208
+ "Bash",
209
+ "Read",
210
+ "write"
211
+ ]
212
+ },
213
+ "canonical_json": "{\"cap\":\"tool_extra\",\"scope\":{\"tools\":[\"Bash\",\"Read\",\"write\"]}}",
214
+ "sha256": "e84c5ca42efc23fa9dc9b6b6a8f55f0a31e1f157a6c5f53af2b2f45d16fd1e74"
215
+ },
216
+ {
217
+ "name": "tool_extra-namespaced",
218
+ "why": "命名空间工具名逐字保留",
219
+ "cap": "tool_extra",
220
+ "scope": {
221
+ "tools": [
222
+ "mcp__server.tool:v1",
223
+ "fs.read_file"
224
+ ]
225
+ },
226
+ "canonical_json": "{\"cap\":\"tool_extra\",\"scope\":{\"tools\":[\"fs.read_file\",\"mcp__server.tool:v1\"]}}",
227
+ "sha256": "8b85802ec676aaad53bd6c68821e509fbdd118de97c63b5c09e019ebac36a66b"
228
+ },
229
+ {
230
+ "name": "network-bool-empty",
231
+ "why": "布尔类 cap:scope 必为空对象",
232
+ "cap": "network",
233
+ "scope": {},
234
+ "canonical_json": "{\"cap\":\"network\",\"scope\":{}}",
235
+ "sha256": "8993f5882b79ca21aecdd81928ee47aec19e1501c1326154d72f19a2af8c672b"
236
+ },
237
+ {
238
+ "name": "unsandboxed-bool-empty",
239
+ "why": "布尔类 cap:scope 必为空对象",
240
+ "cap": "unsandboxed",
241
+ "scope": {},
242
+ "canonical_json": "{\"cap\":\"unsandboxed\",\"scope\":{}}",
243
+ "sha256": "2767086b3cd03168816cf5effbb1fe4598301c0607767b951871bbf2432b3376"
244
+ },
245
+ {
246
+ "name": "network-bool-stray-scope-keys",
247
+ "why": "布尔类 cap 收到无关 scope 键 ⇒ 两侧都丢成 {}",
248
+ "cap": "network",
249
+ "scope": {
250
+ "roots": [
251
+ "/ignored"
252
+ ]
253
+ },
254
+ "canonical_json": "{\"cap\":\"network\",\"scope\":{}}",
255
+ "sha256": "8993f5882b79ca21aecdd81928ee47aec19e1501c1326154d72f19a2af8c672b"
256
+ },
257
+ {
258
+ "name": "read_roots-stray-extra-key",
259
+ "why": "非本 cap 的 scope 键被白名单丢弃(两侧一致)",
260
+ "cap": "read_roots",
261
+ "scope": {
262
+ "roots": [
263
+ "/a"
264
+ ],
265
+ "hosts": [
266
+ "evil.example.com"
267
+ ]
268
+ },
269
+ "canonical_json": "{\"cap\":\"read_roots\",\"scope\":{\"roots\":[\"/a\"]}}",
270
+ "sha256": "881fcf621667c541723bc833b34cc96efa6961e566f2c4488eccce62e687487a"
271
+ }
272
+ ]
273
+ }