pyric 0.1.0-alpha.11 → 0.1.0-alpha.13

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 (370) hide show
  1. package/README.md.orig +0 -1
  2. package/dist/{firestore-values/index.d.ts → firestore/internal/value-codec.d.ts} +2 -2
  3. package/dist/firestore/internal/value-codec.d.ts.map +1 -0
  4. package/dist/{firestore-values/index.js → firestore/internal/value-codec.js} +10 -10
  5. package/dist/firestore/internal/value-codec.js.map +1 -0
  6. package/dist/sandbox/admin-firestore/remote/value-codec.d.ts +2 -1
  7. package/dist/sandbox/admin-firestore/remote/value-codec.d.ts.map +1 -1
  8. package/dist/sandbox/admin-firestore/remote/value-codec.js +3 -2
  9. package/dist/sandbox/admin-firestore/remote/value-codec.js.map +1 -1
  10. package/dist/sandbox/persistence/chunk-format.js +1 -1
  11. package/dist/sandbox/persistence/chunk-format.js.map +1 -1
  12. package/dist/sandbox/persistence/serialize.d.ts +1 -1
  13. package/dist/sandbox/persistence/serialize.d.ts.map +1 -1
  14. package/dist/sandbox/persistence/serialize.js +6 -6
  15. package/dist/sandbox/persistence/serialize.js.map +1 -1
  16. package/package.json +6 -5
  17. package/src/ai/backend.ts +49 -0
  18. package/src/ai/broker/broker.ts +254 -0
  19. package/src/ai/broker/index.ts +59 -0
  20. package/src/ai/broker/openai-engine.ts +646 -0
  21. package/src/ai/broker/scripted-engine.ts +277 -0
  22. package/src/ai/broker/synthesizer.ts +340 -0
  23. package/src/ai/broker/types.ts +194 -0
  24. package/src/ai/enums.ts +193 -0
  25. package/src/ai/errors.ts +125 -0
  26. package/src/ai/index.ts +139 -0
  27. package/src/ai/instances.ts +136 -0
  28. package/src/ai/internal.ts +57 -0
  29. package/src/ai/models.ts +344 -0
  30. package/src/ai/request-helpers.ts +214 -0
  31. package/src/ai/response-helpers.ts +230 -0
  32. package/src/ai/sandbox-plane.ts +219 -0
  33. package/src/ai/schema.ts +247 -0
  34. package/src/ai/scripting.ts +114 -0
  35. package/src/ai/target.ts +36 -0
  36. package/src/ai/types.ts +491 -0
  37. package/src/app/diagnostics.test.ts +44 -0
  38. package/src/app/diagnostics.ts +105 -0
  39. package/src/app/dispatch.test.ts +142 -0
  40. package/src/app/index.ts +15 -0
  41. package/src/app/internal.ts +34 -0
  42. package/src/app/options.ts +18 -0
  43. package/src/app/package-resolution.test.ts +14 -0
  44. package/src/app/register.test.ts +31 -0
  45. package/src/app/register.ts +45 -0
  46. package/src/app/registry.ts +193 -0
  47. package/src/app/runtime.ts +148 -0
  48. package/src/app/types.ts +22 -0
  49. package/src/auth/action-code-url.ts +133 -0
  50. package/src/auth/action-codes.ts +465 -0
  51. package/src/auth/auth-errors.ts +24 -0
  52. package/src/auth/config-tokens.ts +101 -0
  53. package/src/auth/credentials.ts +228 -0
  54. package/src/auth/email-link.ts +207 -0
  55. package/src/auth/enums.ts +214 -0
  56. package/src/auth/index.ts +2 -0
  57. package/src/auth/instances.ts +127 -0
  58. package/src/auth/linking.ts +224 -0
  59. package/src/auth/modular.ts +118 -0
  60. package/src/auth/password-policy.ts +102 -0
  61. package/src/auth/providers.ts +250 -0
  62. package/src/auth/reauth.ts +194 -0
  63. package/src/auth/sandbox/driver.ts +142 -0
  64. package/src/auth/sandbox/persistence.ts +156 -0
  65. package/src/auth/sandbox/project-store.ts +31 -0
  66. package/src/auth/sandbox-auth-flow.ts +255 -0
  67. package/src/auth/sandbox-backend-types.ts +200 -0
  68. package/src/auth/sandbox-backend.ts +2259 -0
  69. package/src/auth/sandbox-credential-validators.ts +52 -0
  70. package/src/auth/sandbox-token.ts +32 -0
  71. package/src/auth/sign-in.ts +194 -0
  72. package/src/auth/target.ts +43 -0
  73. package/src/auth/tokens.ts +155 -0
  74. package/src/auth/types.ts +298 -0
  75. package/src/auth/user-lifecycle.ts +93 -0
  76. package/src/database/index.ts +8 -0
  77. package/src/database/listener-registry.ts +89 -0
  78. package/src/database/modular.ts +1483 -0
  79. package/src/database/replay.ts +213 -0
  80. package/src/database/sandbox/backend-for.ts +36 -0
  81. package/src/database/sandbox/backend.ts +1805 -0
  82. package/src/database/sandbox/data-tree.ts +322 -0
  83. package/src/database/sandbox/normalize.ts +207 -0
  84. package/src/database/sandbox/push-id.ts +86 -0
  85. package/src/database/sandbox/query.ts +383 -0
  86. package/src/database/sandbox/rules-eval.ts +202 -0
  87. package/src/database/sandbox/sentinels.ts +114 -0
  88. package/src/database/sandbox-controls.ts +33 -0
  89. package/src/firestore/aggregates.ts +104 -0
  90. package/src/firestore/equality.ts +32 -0
  91. package/src/firestore/field-values.ts +203 -0
  92. package/src/firestore/index.ts +60 -0
  93. package/src/firestore/instances.ts +292 -0
  94. package/src/firestore/internal/index.ts +14 -0
  95. package/src/firestore/internal/listener-routing.ts +3 -0
  96. package/src/firestore/internal/value-codec.ts +175 -0
  97. package/src/firestore/listeners.ts +280 -0
  98. package/src/firestore/persistence.ts +381 -0
  99. package/src/firestore/query-constraints.ts +283 -0
  100. package/src/firestore/reads.ts +67 -0
  101. package/src/firestore/refs.ts +190 -0
  102. package/src/firestore/sandbox/activity-bounded.ts +12 -0
  103. package/src/firestore/sandbox/activity-contract.ts +60 -0
  104. package/src/firestore/sandbox/activity-listener-retention.ts +21 -0
  105. package/src/firestore/sandbox/activity-monitor.ts +547 -0
  106. package/src/firestore/sandbox/activity-public-identity.ts +90 -0
  107. package/src/firestore/sandbox/activity-query-value.ts +60 -0
  108. package/src/firestore/sandbox/activity-structural-identity.ts +11 -0
  109. package/src/firestore/sandbox/activity-value-registry.ts +126 -0
  110. package/src/firestore/sandbox/admin-compat/batch.ts +86 -0
  111. package/src/firestore/sandbox/admin-compat/doc-ref.ts +184 -0
  112. package/src/firestore/sandbox/admin-compat/firestore.ts +154 -0
  113. package/src/firestore/sandbox/admin-compat/index.ts +96 -0
  114. package/src/firestore/sandbox/admin-compat/paths.ts +53 -0
  115. package/src/firestore/sandbox/admin-compat/query.ts +983 -0
  116. package/src/firestore/sandbox/admin-compat/read-translation.ts +66 -0
  117. package/src/firestore/sandbox/admin-compat/snapshots.ts +60 -0
  118. package/src/firestore/sandbox/admin-compat/transaction.ts +102 -0
  119. package/src/firestore/sandbox/admin-compat/types.ts +404 -0
  120. package/src/firestore/sandbox/admin-compat/value-order.ts +186 -0
  121. package/src/firestore/sandbox/auto-id.ts +40 -0
  122. package/src/firestore/sandbox/converters/bytes-geopoint.ts +100 -0
  123. package/src/firestore/sandbox/converters/fieldvalue.ts +172 -0
  124. package/src/firestore/sandbox/converters/reference.ts +59 -0
  125. package/src/firestore/sandbox/converters/timestamp.ts +65 -0
  126. package/src/firestore/sandbox/converters/user-timestamp.ts +72 -0
  127. package/src/firestore/sandbox/converters/vector.ts +51 -0
  128. package/src/firestore/sandbox/errors.ts +137 -0
  129. package/src/firestore/sandbox/event-bus.ts +117 -0
  130. package/src/firestore/sandbox/event-log.ts +134 -0
  131. package/src/firestore/sandbox/field-merge.ts +245 -0
  132. package/src/firestore/sandbox/history-controls.ts +98 -0
  133. package/src/firestore/sandbox/list-query-proof.ts +221 -0
  134. package/src/firestore/sandbox/listener-delivery.ts +38 -0
  135. package/src/firestore/sandbox/listener-dispatch.ts +914 -0
  136. package/src/firestore/sandbox/local-environment.ts +2012 -0
  137. package/src/firestore/sandbox/local-state.ts +538 -0
  138. package/src/firestore/sandbox/overlay-backing.ts +103 -0
  139. package/src/firestore/sandbox/reads.ts +18 -0
  140. package/src/firestore/sandbox/request-events.ts +119 -0
  141. package/src/firestore/sandbox/rules-evaluation.ts +95 -0
  142. package/src/firestore/sandbox/rules-read-engine.ts +499 -0
  143. package/src/firestore/sandbox/rules-state.ts +61 -0
  144. package/src/firestore/sandbox/sentinel-capture.ts +63 -0
  145. package/src/firestore/sandbox/snapshot-listeners.ts +482 -0
  146. package/src/firestore/sandbox/topk.ts +38 -0
  147. package/src/firestore/sandbox/transaction-merge.ts +157 -0
  148. package/src/firestore/sandbox/transaction-types.ts +160 -0
  149. package/src/firestore/sandbox/transaction.ts +143 -0
  150. package/src/firestore/sandbox/trigger-scope.ts +52 -0
  151. package/src/firestore/sandbox/value-equality.ts +34 -0
  152. package/src/firestore/sandbox/value-resolver.ts +289 -0
  153. package/src/firestore/sandbox/wire-encoder.ts +136 -0
  154. package/src/firestore/sandbox/writes.ts +91 -0
  155. package/src/firestore/sandbox-controls.ts +143 -0
  156. package/src/firestore/snapshots.ts +188 -0
  157. package/src/firestore/state.ts +341 -0
  158. package/src/firestore/tools.ts +386 -0
  159. package/src/firestore/transactions.ts +32 -0
  160. package/src/firestore/types.ts +119 -0
  161. package/src/firestore/writes.ts +106 -0
  162. package/src/messaging/broker/broker.test.ts +260 -0
  163. package/src/messaging/broker/broker.ts +482 -0
  164. package/src/messaging/broker/envelopes.ts +177 -0
  165. package/src/messaging/broker/index.ts +72 -0
  166. package/src/messaging/broker/tokens.ts +39 -0
  167. package/src/messaging/broker/types.ts +104 -0
  168. package/src/messaging/broker/validate.ts +206 -0
  169. package/src/messaging/client.ts +160 -0
  170. package/src/messaging/index.ts +2 -0
  171. package/src/messaging/instance.ts +199 -0
  172. package/src/messaging/internal.ts +20 -0
  173. package/src/messaging/sw.ts +110 -0
  174. package/src/project-scope.ts +4 -0
  175. package/src/rules/api/assert.ts +130 -0
  176. package/src/rules/api/case-types.ts +158 -0
  177. package/src/rules/api/errors.ts +51 -0
  178. package/src/rules/api/firestore.ts +173 -0
  179. package/src/rules/api/issue.ts +101 -0
  180. package/src/rules/api/lint.ts +69 -0
  181. package/src/rules/api/rtdb.ts +213 -0
  182. package/src/rules/api/values.ts +73 -0
  183. package/src/rules/generators/assembler.ts +325 -0
  184. package/src/rules/generators/expressions.ts +125 -0
  185. package/src/rules/generators/grid.ts +63 -0
  186. package/src/rules/grammar/FirestoreAST.ts +93 -0
  187. package/src/rules/grammar/FirestoreAssembler.ts +200 -0
  188. package/src/rules/grammar/FirestoreParser.ts +431 -0
  189. package/src/rules/grammar/FirestoreRules.ohm +236 -0
  190. package/src/rules/grammar/FirestoreRules.ohm.generated.ts +241 -0
  191. package/src/rules/grammar/FirestoreValidator.ts +502 -0
  192. package/src/rules/index.ts +151 -0
  193. package/src/rules/indexes/extract/annotation-collect.ts +90 -0
  194. package/src/rules/indexes/extract/annotations.ts +177 -0
  195. package/src/rules/indexes/extract/ast.ts +118 -0
  196. package/src/rules/indexes/extract/classify.ts +163 -0
  197. package/src/rules/indexes/extract/composite.ts +112 -0
  198. package/src/rules/indexes/extract/dataflow.ts +258 -0
  199. package/src/rules/indexes/extract/enumerate.ts +194 -0
  200. package/src/rules/indexes/extract/extractor.ts +311 -0
  201. package/src/rules/indexes/extract/types.ts +222 -0
  202. package/src/rules/indexes/extractHandler.ts +110 -0
  203. package/src/rules/indexes/extractTool.ts +73 -0
  204. package/src/rules/indexes/types.ts +83 -0
  205. package/src/rules/inspect/handler.ts +174 -0
  206. package/src/rules/inspect/spec.ts +35 -0
  207. package/src/rules/inspect/tools.ts +42 -0
  208. package/src/rules/internal/extract.ts +51 -0
  209. package/src/rules/internal/index.ts +239 -0
  210. package/src/rules/internal/node.ts +44 -0
  211. package/src/rules/internal/rtdb.ts +108 -0
  212. package/src/rules/linter/ast-utils.ts +401 -0
  213. package/src/rules/linter/hallucinations.ts +373 -0
  214. package/src/rules/linter/linter.ts +904 -0
  215. package/src/rules/modules/resolver-browser.ts +71 -0
  216. package/src/rules/modules/resolver-core.ts +382 -0
  217. package/src/rules/modules/resolver.ts +62 -0
  218. package/src/rules/modules/stdlib/STDLIB.md +271 -0
  219. package/src/rules/modules/stdlib/atomic.rules +52 -0
  220. package/src/rules/modules/stdlib/atomic.test.json +152 -0
  221. package/src/rules/modules/stdlib/auth.rules +7 -0
  222. package/src/rules/modules/stdlib/auth.test.json +53 -0
  223. package/src/rules/modules/stdlib/content.rules +50 -0
  224. package/src/rules/modules/stdlib/content.test.json +238 -0
  225. package/src/rules/modules/stdlib/counters.rules +41 -0
  226. package/src/rules/modules/stdlib/counters.test.json +254 -0
  227. package/src/rules/modules/stdlib/geometry.rules +43 -0
  228. package/src/rules/modules/stdlib/geometry.test.json +200 -0
  229. package/src/rules/modules/stdlib/joining.rules +49 -0
  230. package/src/rules/modules/stdlib/joining.test.json +287 -0
  231. package/src/rules/modules/stdlib/lifecycle.rules +51 -0
  232. package/src/rules/modules/stdlib/lifecycle.test.json +288 -0
  233. package/src/rules/modules/stdlib/lobby.rules +44 -0
  234. package/src/rules/modules/stdlib/lobby.test.json +32 -0
  235. package/src/rules/modules/stdlib/membership.rules +40 -0
  236. package/src/rules/modules/stdlib/membership.test.json +107 -0
  237. package/src/rules/modules/stdlib/spaces.rules +46 -0
  238. package/src/rules/modules/stdlib/spaces.test.json +392 -0
  239. package/src/rules/modules/stdlib/state.rules +28 -0
  240. package/src/rules/modules/stdlib/state.test.json +55 -0
  241. package/src/rules/modules/stdlib/timing.rules +20 -0
  242. package/src/rules/modules/stdlib/timing.test.json +106 -0
  243. package/src/rules/modules/stdlib/transitions.rules +34 -0
  244. package/src/rules/modules/stdlib/transitions.test.json +86 -0
  245. package/src/rules/modules/stdlib/turns.rules +27 -0
  246. package/src/rules/modules/stdlib/turns.test.json +64 -0
  247. package/src/rules/modules/stdlib/validation.rules +31 -0
  248. package/src/rules/modules/stdlib/validation.test.json +184 -0
  249. package/src/rules/modules/stdlib-content.ts +590 -0
  250. package/src/rules/rtdb/compiled-rules.ts +121 -0
  251. package/src/rules/rtdb/constraints/atoms.spec.ts +47 -0
  252. package/src/rules/rtdb/constraints/atoms.ts +69 -0
  253. package/src/rules/rtdb/constraints/compose.ts +24 -0
  254. package/src/rules/rtdb/constraints/data.ts +79 -0
  255. package/src/rules/rtdb/constraints/document.ts +162 -0
  256. package/src/rules/rtdb/constraints/game.spec.ts +32 -0
  257. package/src/rules/rtdb/constraints/game.ts +70 -0
  258. package/src/rules/rtdb/constraints/index.ts +32 -0
  259. package/src/rules/rtdb/constraints/policies.spec.ts +34 -0
  260. package/src/rules/rtdb/constraints/policies.ts +36 -0
  261. package/src/rules/rtdb/constraints/ruleset.ts +151 -0
  262. package/src/rules/rtdb/constraints/schema.ts +89 -0
  263. package/src/rules/rtdb/constraints/types.ts +23 -0
  264. package/src/rules/rtdb/constraints/write-rules-file.ts +35 -0
  265. package/src/rules/rtdb/expression-engine.ts +24 -0
  266. package/src/rules/rtdb/grammar/RtdbExpr.ohm +98 -0
  267. package/src/rules/rtdb/grammar/RtdbExpr.ohm.generated.ts +103 -0
  268. package/src/rules/rtdb/grammar/RtdbExprParser.ts +65 -0
  269. package/src/rules/rtdb/grammar/linter.ts +90 -0
  270. package/src/rules/rtdb/grammar/simulator.ts +340 -0
  271. package/src/rules/rtdb/grammar/validator.ts +113 -0
  272. package/src/rules/rtdb/simulation/handler.ts +430 -0
  273. package/src/rules/rtdb/simulation/spec.ts +48 -0
  274. package/src/rules/rtdb/types.ts +39 -0
  275. package/src/rules/simulator/evaluator.ts +1461 -0
  276. package/src/rules/simulator/expression/eval-errors.ts +136 -0
  277. package/src/rules/simulator/expression/evaluator.ts +425 -0
  278. package/src/rules/simulator/expression/lexer.ts +395 -0
  279. package/src/rules/simulator/expression/parser.ts +375 -0
  280. package/src/rules/simulator/expression/types.ts +252 -0
  281. package/src/rules/simulator/expression/walk-data.ts +216 -0
  282. package/src/rules/simulator/firestore-set.ts +90 -0
  283. package/src/rules/simulator/handler.ts +739 -0
  284. package/src/rules/simulator/mapdiff.ts +78 -0
  285. package/src/rules/simulator/project-after-state.ts +125 -0
  286. package/src/rules/simulator/query-proof.ts +513 -0
  287. package/src/rules/simulator/value-equality.ts +33 -0
  288. package/src/rules/simulator/wrappers/base.ts +143 -0
  289. package/src/rules/simulator/wrappers/bytes.ts +142 -0
  290. package/src/rules/simulator/wrappers/duration.ts +191 -0
  291. package/src/rules/simulator/wrappers/float.ts +92 -0
  292. package/src/rules/simulator/wrappers/latlng.ts +116 -0
  293. package/src/rules/simulator/wrappers/path.ts +166 -0
  294. package/src/rules/simulator/wrappers/reference.ts +161 -0
  295. package/src/rules/simulator/wrappers/timestamp.ts +228 -0
  296. package/src/rules/simulator/wrappers/vector.ts +88 -0
  297. package/src/rules/simulator-tools-impl.ts +544 -0
  298. package/src/rules/simulator.ts +36 -0
  299. package/src/rules/stdlib-modules.ts +1023 -0
  300. package/src/rules/stdlib-tools.ts +206 -0
  301. package/src/rules/test/handler.ts +272 -0
  302. package/src/rules/test/spec.ts +681 -0
  303. package/src/rules/tools.ts +159 -0
  304. package/src/rules/write/handler.ts +140 -0
  305. package/src/rules/write/spec.ts +7 -0
  306. package/src/sandbox/admin-compat.ts +39 -0
  307. package/src/sandbox/admin-firestore/error-translation.ts +254 -0
  308. package/src/sandbox/admin-firestore/get-admin-firestore.ts +104 -0
  309. package/src/sandbox/admin-firestore/get-firestore.ts +73 -0
  310. package/src/sandbox/admin-firestore/index.ts +96 -0
  311. package/src/sandbox/admin-firestore/listeners.ts +400 -0
  312. package/src/sandbox/admin-firestore/local-handle.ts +98 -0
  313. package/src/sandbox/admin-firestore/remote/batch.ts +41 -0
  314. package/src/sandbox/admin-firestore/remote/channel.ts +34 -0
  315. package/src/sandbox/admin-firestore/remote/doc-ref.ts +112 -0
  316. package/src/sandbox/admin-firestore/remote/errors.ts +38 -0
  317. package/src/sandbox/admin-firestore/remote/listeners.ts +130 -0
  318. package/src/sandbox/admin-firestore/remote/query.ts +245 -0
  319. package/src/sandbox/admin-firestore/remote/remote-firestore.ts +148 -0
  320. package/src/sandbox/admin-firestore/remote/snapshots.ts +50 -0
  321. package/src/sandbox/admin-firestore/remote/transaction.ts +128 -0
  322. package/src/sandbox/admin-firestore/remote/value-codec.ts +134 -0
  323. package/src/sandbox/admin-firestore/remote/wire-types.ts +65 -0
  324. package/src/sandbox/admin-firestore/types.ts +62 -0
  325. package/src/sandbox/branches/index.ts +378 -0
  326. package/src/sandbox/index.ts +141 -0
  327. package/src/sandbox/internal/client-app.ts +49 -0
  328. package/src/sandbox/internal/firebase-error.ts +23 -0
  329. package/src/sandbox/internal/index.ts +96 -0
  330. package/src/sandbox/internal/local-brand.ts +2 -0
  331. package/src/sandbox/internal/provenance.ts +176 -0
  332. package/src/sandbox/internal/sandbox-impl.ts +837 -0
  333. package/src/sandbox/operation-record.ts +194 -0
  334. package/src/sandbox/persistence/backends.ts +229 -0
  335. package/src/sandbox/persistence/chunk-format.ts +195 -0
  336. package/src/sandbox/persistence/controller.ts +537 -0
  337. package/src/sandbox/persistence/index.ts +12 -0
  338. package/src/sandbox/persistence/serialize.ts +131 -0
  339. package/src/sandbox/persistence/types.ts +118 -0
  340. package/src/sandbox/remote.ts +137 -0
  341. package/src/sandbox/replay/index.ts +326 -0
  342. package/src/sandbox/sandbox-context.ts +117 -0
  343. package/src/sandbox/tab-sync/index.ts +371 -0
  344. package/src/sandbox/types/auth-state.ts +22 -0
  345. package/src/sandbox/types/context.ts +34 -0
  346. package/src/sandbox/types/errors.ts +160 -0
  347. package/src/sandbox/types/events.ts +570 -0
  348. package/src/sandbox/types/index.ts +61 -0
  349. package/src/sandbox/types/operation.ts +64 -0
  350. package/src/sandbox/types/persistence.ts +150 -0
  351. package/src/sandbox/types/service.ts +392 -0
  352. package/src/storage/admin/api.ts +601 -0
  353. package/src/storage/admin/handler.ts +125 -0
  354. package/src/storage/admin/spec.ts +73 -0
  355. package/src/storage/admin/tools.ts +115 -0
  356. package/src/storage/download.ts +162 -0
  357. package/src/storage/enforce.ts +174 -0
  358. package/src/storage/errors.ts +95 -0
  359. package/src/storage/index.ts +95 -0
  360. package/src/storage/instances.ts +42 -0
  361. package/src/storage/internal.ts +21 -0
  362. package/src/storage/list.ts +96 -0
  363. package/src/storage/metadata.ts +224 -0
  364. package/src/storage/persistence.ts +282 -0
  365. package/src/storage/reference.ts +134 -0
  366. package/src/storage/rules.ts +1544 -0
  367. package/src/storage/service.ts +389 -0
  368. package/src/storage/upload.ts +291 -0
  369. package/dist/firestore-values/index.d.ts.map +0 -1
  370. package/dist/firestore-values/index.js.map +0 -1
package/README.md.orig CHANGED
@@ -17,7 +17,6 @@ Rules tooling and explicit sandbox controls.
17
17
  | `pyric/database` | Realtime Database modular mirror |
18
18
  | `pyric/storage` | Storage modular mirror and rules-aware sandbox tools |
19
19
  | `pyric/rules` | Firestore and RTDB rules lint, simulation, explanation, constraints, and standard library |
20
- | `pyric/firestore-values` | Firestore value helpers |
21
20
  | `pyric/sandbox` | Sandbox lifecycle, identity, events, persistence, and replay |
22
21
 
23
22
  The package manifest is the authority for public exports, including the
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Firestore value codec — the marker-based serialize/rehydrate of
2
+ * Internal Firestore value codec — the marker-based serialize/rehydrate of
3
3
  * Firestore special scalar types (Timestamp, Bytes, LatLng/GeoPoint,
4
4
  * Duration, Reference, Path, Vector).
5
5
  *
@@ -60,4 +60,4 @@
60
60
  * MessagePort wire format are guaranteed identical.
61
61
  */
62
62
  export declare function rehydrateDocValue(value: unknown): unknown;
63
- //# sourceMappingURL=index.d.ts.map
63
+ //# sourceMappingURL=value-codec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"value-codec.d.ts","sourceRoot":"","sources":["../../../src/firestore/internal/value-codec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AA6CH;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEzD"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Firestore value codec — the marker-based serialize/rehydrate of
2
+ * Internal Firestore value codec — the marker-based serialize/rehydrate of
3
3
  * Firestore special scalar types (Timestamp, Bytes, LatLng/GeoPoint,
4
4
  * Duration, Reference, Path, Vector).
5
5
  *
@@ -52,18 +52,18 @@
52
52
  */
53
53
  // Direct leaf imports — NOT the `pyric/rules` barrel. Each of these modules
54
54
  // depends only on `./base.js` (no imports), so this stays engine-free.
55
- import { Bytes } from '../rules/simulator/wrappers/bytes.js';
56
- import { Duration } from '../rules/simulator/wrappers/duration.js';
57
- import { LatLng } from '../rules/simulator/wrappers/latlng.js';
58
- import { Path } from '../rules/simulator/wrappers/path.js';
59
- import { Reference } from '../rules/simulator/wrappers/reference.js';
60
- import { Timestamp } from '../rules/simulator/wrappers/timestamp.js';
61
- import { Vector } from '../rules/simulator/wrappers/vector.js';
55
+ import { Bytes } from '../../rules/simulator/wrappers/bytes.js';
56
+ import { Duration } from '../../rules/simulator/wrappers/duration.js';
57
+ import { LatLng } from '../../rules/simulator/wrappers/latlng.js';
58
+ import { Path } from '../../rules/simulator/wrappers/path.js';
59
+ import { Reference } from '../../rules/simulator/wrappers/reference.js';
60
+ import { Timestamp } from '../../rules/simulator/wrappers/timestamp.js';
61
+ import { Vector } from '../../rules/simulator/wrappers/vector.js';
62
62
  // Sideways leaf import into the firestore surface (same character as the
63
63
  // wrapper imports above): the activity value registry is a zero-dependency
64
64
  // leaf owned by `firestore/sandbox/`, consumed here only to stamp trusted
65
65
  // wire identities on rehydrated values. It pulls no backend code.
66
- import { registerActivityValue, trustedWireActivityValue, } from '../firestore/sandbox/activity-value-registry.js';
66
+ import { registerActivityValue, trustedWireActivityValue, } from '../sandbox/activity-value-registry.js';
67
67
  /**
68
68
  * Decode a base64url string (`-`/`_` alphabet, no padding) back into a
69
69
  * Uint8Array. Mirrors the encode path in `Bytes.toBase64` (RFC 4648 section 5).
@@ -164,4 +164,4 @@ function rehydrateValue(value, registerRootIdentity) {
164
164
  out[k] = rehydrateValue(v, false);
165
165
  return withActivityIdentity(out);
166
166
  }
167
- //# sourceMappingURL=index.js.map
167
+ //# sourceMappingURL=value-codec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"value-codec.js","sourceRoot":"","sources":["../../../src/firestore/internal/value-codec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAEH,4EAA4E;AAC5E,uEAAuE;AACvE,OAAO,EAAE,KAAK,EAAE,MAAM,yCAAyC,CAAC;AAChE,OAAO,EAA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AoB,CAAC,IAAI,SAAS,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC;YACnE,CAAC;YACD,KAAK,qBAAqB,CAAC,CAAC,CAAC;gBAC3B,0EAA0E;gBAC1E,OAAO,oBAAoB,CAAC,IAAI,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,KAAe,CAAC,CAAC,CAAC,CAAC;YAC/E,CAAC;YACD,KAAK,wBAAwB,CAAC,CAAC,CAAC;gBAC9B,4DAA4D;gBAC5D,OAAO,oBAAoB,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,QAAkB,EAAE,GAAG,CAAC,SAAmB,CAAC,CAAC,CAAC;YAC3F,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,GAAG,GAA4B,EAAE,CAAC;IACxC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC;QAAE,GAAG,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAC5E,OAAO,oBAAoB,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC"}
@@ -10,7 +10,8 @@
10
10
  * the worker STORES real typed values (rules comparisons and `orderBy`
11
11
  * see a Timestamp, not a map). Read payloads arrive as the
12
12
  * `SerializedDocData` JSON envelope and are rehydrated with the ONE shared
13
- * codec (`pyric/firestore-values`' `rehydrateDocValue`) then translated to
13
+ * codec (`pyric/firestore/internal/value-codec`'s `rehydrateDocValue`) then
14
+ * translated to
14
15
  * the compat field shapes (`translateReadData`) — the same shapes the
15
16
  * local arm's read path yields.
16
17
  *
@@ -1 +1 @@
1
- {"version":3,"file":"value-codec.d.ts","sourceRoot":"","sources":["../../../../src/sandbox/admin-firestore/remote/value-codec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EAEL,KAAK,YAAY,EAElB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAsCnD;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CA0B/C;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAE3D;AAID;;iEAEiE;AACjE,wBAAgB,cAAc,CAAC,UAAU,EAAE,WAAW,GAAG,YAAY,CAEpE;AAED;;iEAEiE;AACjE,wBAAgB,aAAa,CAAC,UAAU,EAAE,WAAW,GAAG,YAAY,CAEnE"}
1
+ {"version":3,"file":"value-codec.d.ts","sourceRoot":"","sources":["../../../../src/sandbox/admin-firestore/remote/value-codec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,EAEL,KAAK,YAAY,EAElB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAsCnD;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CA0B/C;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAE3D;AAID;;iEAEiE;AACjE,wBAAgB,cAAc,CAAC,UAAU,EAAE,WAAW,GAAG,YAAY,CAEpE;AAED;;iEAEiE;AACjE,wBAAgB,aAAa,CAAC,UAAU,EAAE,WAAW,GAAG,YAAY,CAEnE"}
@@ -10,7 +10,8 @@
10
10
  * the worker STORES real typed values (rules comparisons and `orderBy`
11
11
  * see a Timestamp, not a map). Read payloads arrive as the
12
12
  * `SerializedDocData` JSON envelope and are rehydrated with the ONE shared
13
- * codec (`pyric/firestore-values`' `rehydrateDocValue`) then translated to
13
+ * codec (`pyric/firestore/internal/value-codec`'s `rehydrateDocValue`) then
14
+ * translated to
14
15
  * the compat field shapes (`translateReadData`) — the same shapes the
15
16
  * local arm's read path yields.
16
17
  *
@@ -26,7 +27,7 @@
26
27
  * the in-page live path — marker-shaped user data is already reserved
27
28
  * vocabulary in this system.
28
29
  */
29
- import { rehydrateDocValue } from 'pyric/firestore-values';
30
+ import { rehydrateDocValue } from 'pyric/firestore/internal/value-codec';
30
31
  import { Timestamp as CompatTimestamp, } from 'pyric/sandbox/admin-compat';
31
32
  import { translateReadData } from '../../../firestore/sandbox/admin-compat/read-translation.js';
32
33
  import { invalidArgument } from './errors.js';
@@ -1 +1 @@
1
- {"version":3,"file":"value-codec.js","sourceRoot":"","sources":["../../../../src/sandbox/admin-firestore/remote/value-codec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACL,SAAS,IAAI,eAAe,GAG7B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6DAA6D,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG9C,6EAA6E;AAE7E,MAAM,cAAc,GAAwB,IAAI,GAAG,CAAC;IAClD,iBAAiB;IACjB,WAAW;IACX,YAAY;IACZ,aAAa;IACb,aAAa;CACd,CAAC,CAAC;AAEH,SAAS,oBAAoB,CAAC,CAAU;IACtC,OAAO,CACL,CAAC,KAAK,IAAI;QACV,OAAO,CAAC,KAAK,QAAQ;QACrB,OAAQ,CAA0B,CAAC,MAAM,KAAK,QAAQ;QACtD,cAAc,CAAC,GAAG,CAAE,CAAwB,CAAC,MAAM,CAAC,CACrD,CAAC;AACJ,CAAC;AAED;sEACsE;AACtE,SAAS,cAAc,CAAC,CAAqB;IAC3C,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAC;QACjB,KAAK,iBAAiB;YACpB,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAC;QAC3C,KAAK,WAAW;YACd,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC,EAAE,CA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,CAAC;QAC3C,CAAC;QACD,MAAM,eAAe,CACnB,wCAAwC,KAAK,CAAC,WAAW,EAAE,IAAI,IAAI,OAAO,GAAG;YAC3E,mFAAmF,CACtF,CAAC;IACJ,CAAC;IACD,MAAM,GAAG,GAA4B,EAAE,CAAC;IACxC,KAAK,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAA4B,CAAC,EAAE,CAAC;QACpE,GAAG,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAkB;IAChD,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED,8EAA8E;AAE9E;;iEAEiE;AACjE,MAAM,UAAU,cAAc,CAAC,UAAuB;IACpD,OAAO,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAiB,CAAC;AACxE,CAAC;AAED;;iEAEiE;AACjE,MAAM,UAAU,aAAa,CAAC,UAAuB;IACnD,OAAO,iBAAiB,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC;AACvD,CAAC"}
1
+ {"version":3,"file":"value-codec.js","sourceRoot":"","sources":["../../../../src/sandbox/admin-firestore/remote/value-codec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EACL,SAAS,IAAI,eAAe,GAG7B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6DAA6D,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG9C,6EAA6E;AAE7E,MAAM,cAAc,GAAwB,IAAI,GAAG,CAAC;IAClD,iBAAiB;IACjB,WAAW;IACX,YAAY;IAC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C,UAAU,CAAC,CAAC,CAAC;AACvD,CAAC"}
@@ -17,7 +17,7 @@
17
17
  * (Float32Array vector encoding is a later, backward-compatible refinement on the
18
18
  * per-bucket record shape.)
19
19
  */
20
- import { rehydrateDocValue } from '../../firestore-values/index.js';
20
+ import { rehydrateDocValue } from '../../firestore/internal/value-codec.js';
21
21
  import { deserializeSnapshot } from './serialize.js';
22
22
  export const CHUNK_FORMAT_VERSION = 3;
23
23
  export const BUCKET_COUNT = 256;
@@ -1 +1 @@
1
- {"version":3,"file":"chunk-format.js","sourceRoot":"","sources":["../../../src/sandbox/persistence/chunk-format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAU,CAAC;AAC/C,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAC;AAChC,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC;AAErC;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,IAAI,CAAC,GAAG,UAAU,CAAC;IACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACxB,2DAA2D;QAC3D,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC1E,CAAC;IACD,OAAO,CAAC,CAAC,GA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QAAQ;YACnC,YAAY,CAAC,MAAM,CAAC,IAA+C,CAAC,KAAK,MAAM,CAAC,QAAQ,EACxF,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,uDAAuD,EAAE,4BAA4B,CAAC,CAAC;YACpG,SAAS;QACX,CAAC;QACD,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;YACvD,SAAS,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,IAAI,CAA4B,CAAC;QACvE,CAAC;IACH,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;AACjC,CAAC"}
@@ -18,7 +18,7 @@
18
18
  * Schema version is captured in the blob so future format changes can
19
19
  * be detected and reported (rather than corrupting silently).
20
20
  */
21
- import { rehydrateDocValue } from '../../firestore-values/index.js';
21
+ import { rehydrateDocValue } from '../../firestore/internal/value-codec.js';
22
22
  export { rehydrateDocValue };
23
23
  export declare class PersistenceSchemaError extends Error {
24
24
  constructor(message: string);
@@ -1 +1 @@
1
- {"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../../src/sandbox/persistence/serialize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAOH,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAKpE,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAqB7B,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,OAAO,EAAE,MAAM;CAI5B;AAED,uEAAuE;AACvE,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAClD,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACrC,MAAM,CAQR;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,oBAAoB,CAgCrE"}
1
+ {"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../../src/sandbox/persistence/serialize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAOH,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAK5E,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAqB7B,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,OAAO,EAAE,MAAM;CAI5B;AAED,uEAAuE;AACvE,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAClD,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACrC,MAAM,CAQR;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,oBAAoB,CAgCrE"}
@@ -18,12 +18,12 @@
18
18
  * Schema version is captured in the blob so future format changes can
19
19
  * be detected and reported (rather than corrupting silently).
20
20
  */
21
- // The marker-based value codec lives in a STANDALONE leaf module
22
- // (`firestore-values`) so the SharedWorker client can rehydrate doc values
23
- // WITHOUT pulling the rules engine. `serialize.ts` re-uses that same codec so
24
- // there is exactly one rehydrate implementation — the IDB persistence format
25
- // and the MessagePort wire format can't drift.
26
- import { rehydrateDocValue } from '../../firestore-values/index.js';
21
+ // The marker-based value codec lives behind Firestore's leaf internal seam so
22
+ // the SharedWorker client can rehydrate doc values WITHOUT pulling the rules
23
+ // engine. `serialize.ts` re-uses that same codec so there is exactly one
24
+ // rehydrate implementation — the IDB persistence format and the MessagePort
25
+ // wire format can't drift.
26
+ import { rehydrateDocValue } from '../../firestore/internal/value-codec.js';
27
27
  // Re-exported so existing consumers (`sandbox/persistence/index.ts` →
28
28
  // `pyric/sandbox`) keep their import path; the implementation now lives in the
29
29
  // leaf codec.
@@ -1 +1 @@
1
- {"version":3,"file":"serialize.js","sourceRoot":"","sources":["../../../src/sandbox/persistence/serialize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,iEAAiE;AACjE,2EAA2E;AAC3E,8EAA8E;AAC9E,6EAA6E;AAC7E,+CAA+C;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpE,sEAAsE;AACtE,+EAA+E;AAC/E,cAAc;AACd,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAE7B;;;;;;;;GAQG;AACH,MAAM,cAAc,GAAG,CAAU,CAAC;AAUlC,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC/C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAED,uEAAuE;AACvE,MAAM,UAAU,iBAAiB,CAC/B,SAAkD,EAClD,WAAoC,EAAE;IAEtC,MAAM,OAAO,GAAmB;QAC9B,OAAO,EAAE,cAAc;QACvB,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE;QACnB,SAAS;QACT,QAAQ;KACT,CAAC;IACF,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC;AAgBD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBA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QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QAClD,MAAM,IAAI,sBAAsB,CAAC,iCAAiC,CAAC,CAAC;IACtE,CAAC;IACD,oEAAoE;IACpE,sEAAsE;IACtE,IAAI,MAAM,CAAC,OAAO,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,KAAK,CAAC,EAAE,CAAC;QACjD,MAAM,IAAI,sBAAsB,CAC9B,8BAA8B,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,mBAAmB,CACxE,CAAC;IACJ,CAAC;IACD,IAAI,OAAO,MAAM,CAAC,SAAS,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,KAAK,IAAI,EAAE,CAAC;QACtE,MAAM,IAAI,sBAAsB,CAAC,uCAAuC,CAAC,CAAC;IAC5E,CAAC;IACD,MAAM,SAAS,GAA4C,EAAE,CAAC;IAC9D,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;QAC5D,SAAS,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,IAAI,CAA4B,CAAC;IACvE,CAAC;IACD,+DAA+D;IAC/D,uEAAuE;IACvE,MAAM,QAAQ,GAAG,CAAC,MAAM,CAAC,QAAQ,KAAK,SAAS,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,KAAK,IAAI,CAAC;QACjH,CAAC,CAAE,MAAM,CAAC,QAAoC;QAC9C,CAAC,CAAC,EAAE,CAAC;IACP,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;AACjC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pyric",
3
- "version": "0.1.0-alpha.11",
3
+ "version": "0.1.0-alpha.13",
4
4
  "license": "Apache-2.0",
5
5
  "homepage": "https://pyric.dev",
6
6
  "repository": {
@@ -34,6 +34,10 @@
34
34
  "types": "./dist/firestore/internal/index.d.ts",
35
35
  "import": "./dist/firestore/internal/index.js"
36
36
  },
37
+ "./firestore/internal/value-codec": {
38
+ "types": "./dist/firestore/internal/value-codec.d.ts",
39
+ "import": "./dist/firestore/internal/value-codec.js"
40
+ },
37
41
  "./auth": {
38
42
  "types": "./dist/auth/index.d.ts",
39
43
  "import": "./dist/auth/index.js"
@@ -78,10 +82,6 @@
78
82
  "types": "./dist/rules/index.d.ts",
79
83
  "import": "./dist/rules/index.js"
80
84
  },
81
- "./firestore-values": {
82
- "types": "./dist/firestore-values/index.d.ts",
83
- "import": "./dist/firestore-values/index.js"
84
- },
85
85
  "./rules/internal": {
86
86
  "types": "./dist/rules/internal/index.d.ts",
87
87
  "import": "./dist/rules/internal/index.js"
@@ -125,6 +125,7 @@
125
125
  },
126
126
  "files": [
127
127
  "dist",
128
+ "src",
128
129
  "README.md",
129
130
  "LICENSE"
130
131
  ],
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Backend configuration classes for `pyric/ai`, mirroring the installed
3
+ * `@firebase/ai@2.12.0`: an abstract {@link Backend} carrying
4
+ * `backendType`, with {@link GoogleAIBackend} (the default) and
5
+ * {@link VertexAIBackend} (location defaults to `us-central1`).
6
+ *
7
+ * In the sandbox mirror the backend is a pure configuration marker; the
8
+ * broker answers in-process either way. Production imports load Firebase's
9
+ * own backend classes before this package enters the graph.
10
+ */
11
+
12
+ const DEFAULT_LOCATION = 'us-central1';
13
+
14
+ /** Identifies which backend service the SDK communicates with. */
15
+ export const BackendType = {
16
+ VERTEX_AI: 'VERTEX_AI',
17
+ GOOGLE_AI: 'GOOGLE_AI',
18
+ } as const;
19
+ export type BackendType = (typeof BackendType)[keyof typeof BackendType];
20
+
21
+ /**
22
+ * Abstract base class representing the configuration for an AI service
23
+ * backend. Do not instantiate directly — use {@link GoogleAIBackend} or
24
+ * {@link VertexAIBackend}.
25
+ */
26
+ export abstract class Backend {
27
+ readonly backendType: BackendType;
28
+
29
+ protected constructor(type: BackendType) {
30
+ this.backendType = type;
31
+ }
32
+ }
33
+
34
+ /** Configuration class for the Gemini Developer API backend (the default). */
35
+ export class GoogleAIBackend extends Backend {
36
+ constructor() {
37
+ super(BackendType.GOOGLE_AI);
38
+ }
39
+ }
40
+
41
+ /** Configuration class for the Vertex AI Gemini API backend. */
42
+ export class VertexAIBackend extends Backend {
43
+ readonly location: string;
44
+
45
+ constructor(location: string = DEFAULT_LOCATION) {
46
+ super(BackendType.VERTEX_AI);
47
+ this.location = location || DEFAULT_LOCATION;
48
+ }
49
+ }
@@ -0,0 +1,254 @@
1
+ /**
2
+ * The sandbox AI broker — the ONE in-process Gemini-wire model every plane
3
+ * consumes (house pattern: the messaging broker):
4
+ *
5
+ * - the client mirror (`pyric/ai`, next stage) calls generateContent /
6
+ * streamGenerateContent / countTokens exactly like `rtdb.*` / `auth.*`
7
+ * will over the worker protocol (cdd-deltas #98.3);
8
+ * - Pyric Studio & tracing consume the typed `service_mutation` events the
9
+ * broker emits onto the sandbox's unified `onEvent` stream;
10
+ * - answering is delegated through ONE seam ({@link AnswerEngine},
11
+ * cdd-deltas #97): `scripted` (default, zero-I/O) or `openai`.
12
+ *
13
+ * The broker validates requests LIKE PRODUCTION does — before any engine
14
+ * runs — throwing {@link AiBrokerError} carrying the exact captured error
15
+ * envelope:
16
+ * - empty/missing `contents` → `ai-error-empty-contents`
17
+ * - a role outside the captured list → `ai-error-bad-role`
18
+ * - a model-turn functionCall part with no thoughtSignature
19
+ * → `ai-error-fncall-missing-thought-signature`
20
+ *
21
+ * Event emission is best-effort behind one small choke-point ({@link emit}):
22
+ * a throw from the emit path (or any event consumer downstream) must never
23
+ * poison the AI operation the caller just completed — handler errors are the
24
+ * consumer's problem, never the broker's (the sandbox's emit fan-out already
25
+ * isolates listener throws; this guard covers the emit path itself).
26
+ */
27
+
28
+ import type { Sandbox } from 'pyric/sandbox';
29
+ import { emitSandboxEvent, makeServiceMutationEvent } from 'pyric/sandbox/internal';
30
+
31
+ import { AiBrokerError, Synthesizer, badRole, emptyContents, missingThoughtSignature } from './synthesizer.js';
32
+ import { ScriptedEngine } from './scripted-engine.js';
33
+ import { OpenAiEngine } from './openai-engine.js';
34
+ import type {
35
+ AnswerEngine,
36
+ CountTokensRequest,
37
+ CountTokensResponse,
38
+ EngineConfig,
39
+ GenerateContentRequest,
40
+ RawEnvelope,
41
+ WireChunk,
42
+ WireResponse,
43
+ } from './types.js';
44
+
45
+ /**
46
+ * Roles production accepts, from the captured rejection text
47
+ * (`ai-error-bad-role`): "Please use a valid role: SYSTEM, SYSTEM_1, USER,
48
+ * ASSISTANT, DEVELOPER, CONTEXT, USER_CONTEXT, MODEL, USER." — compared
49
+ * case-insensitively (the SDK sends lowercase `user`/`model`). `FUNCTION` is
50
+ * additionally accepted: the captured message omits it, yet production
51
+ * accepted the SDK's function-response turn (`ai-function-response-round`),
52
+ * and the installed SDK threads those turns with role `function`.
53
+ */
54
+ const ACCEPTED_ROLES = new Set([
55
+ 'SYSTEM',
56
+ 'SYSTEM_1',
57
+ 'USER',
58
+ 'ASSISTANT',
59
+ 'DEVELOPER',
60
+ 'CONTEXT',
61
+ 'USER_CONTEXT',
62
+ 'MODEL',
63
+ 'FUNCTION',
64
+ ]);
65
+
66
+ export interface AiBrokerOptions {
67
+ /** Engine config, or a fully custom engine. Default: zero-config scripted. */
68
+ engine?: EngineConfig | AnswerEngine;
69
+ /** When present, ops land on the sandbox's unified event stream. */
70
+ sandbox?: Sandbox;
71
+ }
72
+
73
+ function isAnswerEngine(value: EngineConfig | AnswerEngine): value is AnswerEngine {
74
+ return typeof (value as AnswerEngine).generateContent === 'function';
75
+ }
76
+
77
+ /** What Studio's stream (and the construction log line) name the engine. */
78
+ type EngineKind = 'scripted' | 'openai' | 'custom';
79
+
80
+ export class AiBroker {
81
+ readonly engine: AnswerEngine;
82
+ private readonly sandbox: Sandbox | undefined;
83
+ private readonly engineKind: EngineKind;
84
+ private readonly engineModel: string | undefined;
85
+ private readonly engineBaseUrl: string | undefined;
86
+
87
+ constructor(options: AiBrokerOptions = {}) {
88
+ this.sandbox = options.sandbox;
89
+ const engine = options.engine ?? { kind: 'scripted' as const };
90
+ if (isAnswerEngine(engine)) {
91
+ this.engine = engine;
92
+ this.engineKind = 'custom';
93
+ } else if (engine.kind === 'scripted') {
94
+ this.engine = new ScriptedEngine(engine.script ?? [], new Synthesizer());
95
+ this.engineKind = 'scripted';
96
+ } else {
97
+ this.engine = new OpenAiEngine(engine);
98
+ this.engineKind = 'openai';
99
+ this.engineModel = engine.model;
100
+ this.engineBaseUrl = engine.baseUrl;
101
+ }
102
+ console.info(this.describeEngine());
103
+ }
104
+
105
+ /** One-line construction-time summary of what this broker resolved to. */
106
+ private describeEngine(): string {
107
+ if (this.engineKind === 'openai') {
108
+ return `[pyric/ai] engine resolved: openai (model=${this.engineModel ?? 'passthrough'}, upstream=${this.engineBaseUrl})`;
109
+ }
110
+ if (this.engineKind === 'custom') {
111
+ return '[pyric/ai] engine resolved: custom AnswerEngine';
112
+ }
113
+ return '[pyric/ai] engine resolved: scripted (zero-config unless a script is queued)';
114
+ }
115
+
116
+ /** Additive detail fields every emitted event carries so Studio can show the engine. */
117
+ private engineDetail(): Record<string, unknown> {
118
+ return {
119
+ engine: this.engineKind,
120
+ ...(this.engineKind === 'openai'
121
+ ? { model: this.engineModel, baseUrl: this.engineBaseUrl }
122
+ : {}),
123
+ };
124
+ }
125
+
126
+ async generateContent(req: GenerateContentRequest, model: string): Promise<WireResponse> {
127
+ this.validate(req, model);
128
+ const response = await this.engine.generateContent(req, model);
129
+ this.emit('generate_content', model, {
130
+ contentCount: req.contents.length,
131
+ finishReason: response.candidates?.[0]?.finishReason,
132
+ totalTokenCount: response.usageMetadata?.totalTokenCount,
133
+ responseId: response.responseId,
134
+ });
135
+ return response;
136
+ }
137
+
138
+ /**
139
+ * Chunk objects with the captured framing SEMANTICS (finishReason last
140
+ * chunk only, usageMetadata every chunk). Validation runs EAGERLY — a bad
141
+ * request throws here, before iteration, the way production answers with
142
+ * an HTTP error instead of a stream.
143
+ */
144
+ streamGenerateContent(req: GenerateContentRequest, model: string): AsyncIterable<WireChunk> {
145
+ this.validate(req, model);
146
+ const inner = this.engine.streamGenerateContent(req, model);
147
+ const emit = (chunkCount: number) =>
148
+ this.emit('stream_generate_content', model, {
149
+ contentCount: req.contents.length,
150
+ chunkCount,
151
+ });
152
+ return (async function* wrapped(): AsyncGenerator<WireChunk> {
153
+ let chunkCount = 0;
154
+ for await (const chunk of inner) {
155
+ chunkCount++;
156
+ yield chunk;
157
+ }
158
+ emit(chunkCount);
159
+ })();
160
+ }
161
+
162
+ async countTokens(req: CountTokensRequest, model: string): Promise<CountTokensResponse> {
163
+ this.validateContents(req, model);
164
+ const response = await this.engine.countTokens(req, model);
165
+ this.emit('count_tokens', model, { totalTokens: response.totalTokens });
166
+ return response;
167
+ }
168
+
169
+ // ── Production-shaped validation ──────────────────────────────────────────
170
+
171
+ private validate(req: GenerateContentRequest, model: string): void {
172
+ this.validateContents(req, model);
173
+ // Model turns threading a functionCall back in MUST carry the
174
+ // thoughtSignature production minted (`ai-error-fncall-missing-thought-signature`).
175
+ for (let i = 0; i < req.contents.length; i++) {
176
+ const content = req.contents[i]!;
177
+ if ((content.role ?? '').toUpperCase() !== 'MODEL') continue;
178
+ for (const part of content.parts ?? []) {
179
+ if (part.functionCall && part.thoughtSignature === undefined) {
180
+ // `position` is the 1-based index of the offending content turn.
181
+ this.reject(model, missingThoughtSignature(part.functionCall.name, i + 1));
182
+ }
183
+ }
184
+ }
185
+ }
186
+
187
+ private validateContents(req: { contents: unknown }, model: string): void {
188
+ const contents = req.contents;
189
+ if (!Array.isArray(contents) || contents.length === 0) {
190
+ this.reject(model, emptyContents());
191
+ }
192
+ for (const content of contents as GenerateContentRequest['contents']) {
193
+ const role = content.role ?? '';
194
+ if (!ACCEPTED_ROLES.has(role.toUpperCase())) {
195
+ this.reject(model, badRole(role));
196
+ }
197
+ }
198
+ }
199
+
200
+ /** Emit the rejection onto the event stream, then throw the wire envelope. */
201
+ private reject(model: string, envelope: AiBrokerError['envelope']): never {
202
+ this.emit('request_rejected', model, {
203
+ code: envelope.error.code,
204
+ status: envelope.error.status,
205
+ message: envelope.error.message,
206
+ });
207
+ throw new AiBrokerError(envelope);
208
+ }
209
+
210
+ // ── Event emission (Studio stream consumer seam) ──────────────────────────
211
+
212
+ /**
213
+ * Land a broker operation on the sandbox's unified event stream.
214
+ * Best-effort, storage-precedent: a throw from the emit path must never
215
+ * fail the AI operation the caller just completed.
216
+ */
217
+ private emit(op: string, model: string, detail: Record<string, unknown>): void {
218
+ if (this.sandbox === undefined) return;
219
+ try {
220
+ emitSandboxEvent(
221
+ this.sandbox,
222
+ makeServiceMutationEvent({
223
+ service: 'ai',
224
+ op,
225
+ path: model,
226
+ auth: null,
227
+ detail: { ...detail, ...this.engineDetail() },
228
+ }),
229
+ { service: 'ai' },
230
+ );
231
+ } catch {
232
+ // Observational — never let event emission break an AI op.
233
+ }
234
+ }
235
+ }
236
+
237
+ /**
238
+ * Fixture helper: extract `behavior.raw` from a parsed oracle observation
239
+ * JSON so a capture pastes straight into a script entry
240
+ * (`{ respond: loadObservationEnvelope(obs) }`). Captures are the corpus.
241
+ */
242
+ export function loadObservationEnvelope(obsJson: unknown): RawEnvelope {
243
+ const raw = (obsJson as { behavior?: { raw?: unknown } })?.behavior?.raw;
244
+ if (
245
+ raw === null ||
246
+ typeof raw !== 'object' ||
247
+ !Array.isArray((raw as RawEnvelope).candidates)
248
+ ) {
249
+ throw new Error(
250
+ 'loadObservationEnvelope: observation has no behavior.raw response envelope (expected a capture with candidates)',
251
+ );
252
+ }
253
+ return structuredClone(raw) as RawEnvelope;
254
+ }
@@ -0,0 +1,59 @@
1
+ /**
2
+ * AI broker barrel — the in-process Gemini-wire model for the sandbox's ai
3
+ * surface (CDD map #92; rulings in packages/conformance/docs/ai/cdd-deltas.md).
4
+ * NOT wired into package exports yet: the `pyric/ai` mirror layer (next
5
+ * stage) owns the public surface.
6
+ */
7
+
8
+ export { AiBroker, loadObservationEnvelope, type AiBrokerOptions } from './broker.js';
9
+ export { ScriptedEngine, lastUserText, promptTextOf } from './scripted-engine.js';
10
+ export {
11
+ OpenAiEngine,
12
+ ToolCallBuffer,
13
+ SseParser,
14
+ DONE_SENTINEL,
15
+ geminiToOpenAIRequest,
16
+ normalizeSchema,
17
+ mapFinishReason,
18
+ openAIToGeminiResponse,
19
+ openAIChunkToParts,
20
+ type OpenAiEngineOptions,
21
+ type OpenAIRequest,
22
+ type OpenAIResponse,
23
+ type OpenAIStreamChunk,
24
+ type OpenAIMessage,
25
+ type OpenAIToolCall,
26
+ } from './openai-engine.js';
27
+ export {
28
+ AiBrokerError,
29
+ Synthesizer,
30
+ errorEnvelope,
31
+ unknownModel,
32
+ badRole,
33
+ emptyContents,
34
+ missingThoughtSignature,
35
+ resolveModelVersion,
36
+ estimateTokens,
37
+ mintThoughtSignature,
38
+ mintFunctionCallId,
39
+ type SynthesizeOptions,
40
+ } from './synthesizer.js';
41
+ export type {
42
+ AnswerEngine,
43
+ CountTokensRequest,
44
+ CountTokensResponse,
45
+ EngineConfig,
46
+ GenerateContentRequest,
47
+ RawEnvelope,
48
+ ScriptEntry,
49
+ ScriptMatcher,
50
+ ScriptRespond,
51
+ ScriptShorthand,
52
+ WireCandidate,
53
+ WireChunk,
54
+ WireContent,
55
+ WireErrorEnvelope,
56
+ WirePart,
57
+ WireResponse,
58
+ WireUsageMetadata,
59
+ } from './types.js';