@astrale-os/shell-react 0.2.9 → 0.2.10-beta.3

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 (335) hide show
  1. package/dist/application/apps/app-host.d.ts +4 -15
  2. package/dist/application/apps/app-host.d.ts.map +1 -1
  3. package/dist/application/apps/app-host.js +1 -1
  4. package/dist/application/apps/apps.hook.d.ts +7 -4
  5. package/dist/application/apps/apps.hook.d.ts.map +1 -1
  6. package/dist/application/apps/apps.hook.js +10 -2
  7. package/dist/application/apps/domains.hook.d.ts +1 -1
  8. package/dist/application/apps/domains.hook.d.ts.map +1 -1
  9. package/dist/application/apps/domains.hook.js +1 -1
  10. package/dist/application/apps/open-app.hook.d.ts +2 -3
  11. package/dist/application/apps/open-app.hook.d.ts.map +1 -1
  12. package/dist/application/index.d.ts +2 -4
  13. package/dist/application/index.d.ts.map +1 -1
  14. package/dist/application/index.js +2 -3
  15. package/dist/application/spaces/space.hook.d.ts +2 -2
  16. package/dist/application/spaces/space.hook.d.ts.map +1 -1
  17. package/dist/application/spaces/space.hook.js +2 -2
  18. package/dist/application/spaces/spaces.hook.d.ts +2 -3
  19. package/dist/application/spaces/spaces.hook.d.ts.map +1 -1
  20. package/dist/application/spaces/spaces.hook.js +10 -3
  21. package/dist/auth/act-as.context.d.ts +15 -32
  22. package/dist/auth/act-as.context.d.ts.map +1 -1
  23. package/dist/auth/act-as.context.js +22 -66
  24. package/dist/auth/auth.hook.d.ts +1 -0
  25. package/dist/auth/auth.hook.d.ts.map +1 -1
  26. package/dist/auth/auth.hook.js +2 -22
  27. package/dist/auth/can.hook.d.ts +10 -38
  28. package/dist/auth/can.hook.d.ts.map +1 -1
  29. package/dist/auth/can.hook.js +35 -110
  30. package/dist/auth/index.d.ts +1 -0
  31. package/dist/auth/index.d.ts.map +1 -1
  32. package/dist/auth/self.hook.d.ts +2 -2
  33. package/dist/auth/self.hook.d.ts.map +1 -1
  34. package/dist/auth/self.hook.js +0 -7
  35. package/dist/auth/session-kernel.d.ts +2 -3
  36. package/dist/auth/session-kernel.d.ts.map +1 -1
  37. package/dist/auth/session-kernel.js +4 -13
  38. package/dist/components/astrale.d.ts +14 -0
  39. package/dist/components/astrale.d.ts.map +1 -0
  40. package/dist/components/astrale.js +12 -0
  41. package/dist/components/boundaries.d.ts +47 -0
  42. package/dist/components/boundaries.d.ts.map +1 -0
  43. package/dist/components/boundaries.js +55 -0
  44. package/dist/components/can.d.ts +11 -0
  45. package/dist/components/can.d.ts.map +1 -0
  46. package/dist/components/can.js +5 -0
  47. package/dist/components/index.d.ts +6 -0
  48. package/dist/components/index.d.ts.map +1 -0
  49. package/dist/components/index.js +3 -0
  50. package/dist/graph/call/call.hook.d.ts +8 -18
  51. package/dist/graph/call/call.hook.d.ts.map +1 -1
  52. package/dist/graph/call/call.hook.js +7 -13
  53. package/dist/graph/call/stream.hook.d.ts +12 -20
  54. package/dist/graph/call/stream.hook.d.ts.map +1 -1
  55. package/dist/graph/call/stream.hook.js +55 -111
  56. package/dist/graph/graph.context.d.ts +4 -3
  57. package/dist/graph/graph.context.d.ts.map +1 -1
  58. package/dist/graph/graph.context.js +2 -8
  59. package/dist/graph/guards.error.d.ts +7 -8
  60. package/dist/graph/guards.error.d.ts.map +1 -1
  61. package/dist/graph/guards.error.js +11 -7
  62. package/dist/graph/index.d.ts +8 -16
  63. package/dist/graph/index.d.ts.map +1 -1
  64. package/dist/graph/index.js +3 -7
  65. package/dist/graph/memory/read/envelope.d.ts +22 -54
  66. package/dist/graph/memory/read/envelope.d.ts.map +1 -1
  67. package/dist/graph/memory/read/envelope.js +26 -20
  68. package/dist/graph/memory/read/idle.d.ts +1 -15
  69. package/dist/graph/memory/read/idle.d.ts.map +1 -1
  70. package/dist/graph/memory/read/idle.js +4 -13
  71. package/dist/graph/query-definition.hook.d.ts +11 -0
  72. package/dist/graph/query-definition.hook.d.ts.map +1 -0
  73. package/dist/graph/query-definition.hook.js +205 -0
  74. package/dist/graph/resource.d.ts +34 -0
  75. package/dist/graph/resource.d.ts.map +1 -0
  76. package/dist/graph/resource.js +244 -0
  77. package/dist/graph/store.d.ts +25 -0
  78. package/dist/graph/store.d.ts.map +1 -0
  79. package/dist/graph/store.js +69 -0
  80. package/dist/host/actions.hook.d.ts +34 -0
  81. package/dist/host/actions.hook.d.ts.map +1 -0
  82. package/dist/host/actions.hook.js +125 -0
  83. package/dist/host/components.d.ts +15 -0
  84. package/dist/host/components.d.ts.map +1 -0
  85. package/dist/host/components.js +14 -0
  86. package/dist/host/index.d.ts +5 -0
  87. package/dist/host/index.d.ts.map +1 -0
  88. package/dist/host/index.js +3 -0
  89. package/dist/index.d.ts +26 -37
  90. package/dist/index.d.ts.map +1 -1
  91. package/dist/index.js +20 -31
  92. package/dist/intents/envelope.d.ts +7 -19
  93. package/dist/intents/envelope.d.ts.map +1 -1
  94. package/dist/intents/envelope.js +2 -3
  95. package/dist/intents/send-intent.hook.d.ts +5 -7
  96. package/dist/intents/send-intent.hook.d.ts.map +1 -1
  97. package/dist/intents/send-intent.hook.js +17 -75
  98. package/dist/navigation/adapters/adapter.d.ts +5 -0
  99. package/dist/navigation/adapters/adapter.d.ts.map +1 -1
  100. package/dist/navigation/adapters/memory.adapter.d.ts.map +1 -1
  101. package/dist/navigation/adapters/memory.adapter.js +4 -0
  102. package/dist/navigation/adapters/url.adapter.d.ts.map +1 -1
  103. package/dist/navigation/adapters/url.adapter.js +57 -10
  104. package/dist/navigation/codec.d.ts +60 -0
  105. package/dist/navigation/codec.d.ts.map +1 -0
  106. package/dist/navigation/codec.js +121 -0
  107. package/dist/navigation/history.d.ts +11 -9
  108. package/dist/navigation/history.d.ts.map +1 -1
  109. package/dist/navigation/history.js +6 -8
  110. package/dist/navigation/hooks/ancestors.hook.d.ts +5 -7
  111. package/dist/navigation/hooks/ancestors.hook.d.ts.map +1 -1
  112. package/dist/navigation/hooks/ancestors.hook.js +7 -51
  113. package/dist/navigation/hooks/location.hook.d.ts.map +1 -1
  114. package/dist/navigation/hooks/location.hook.js +4 -6
  115. package/dist/navigation/hooks/scope.hook.d.ts.map +1 -1
  116. package/dist/navigation/hooks/scope.hook.js +4 -6
  117. package/dist/navigation/index.d.ts +4 -2
  118. package/dist/navigation/index.d.ts.map +1 -1
  119. package/dist/navigation/index.js +2 -1
  120. package/dist/navigation/link.d.ts +12 -0
  121. package/dist/navigation/link.d.ts.map +1 -1
  122. package/dist/navigation/link.js +13 -2
  123. package/dist/navigation/location.d.ts +13 -40
  124. package/dist/navigation/location.d.ts.map +1 -1
  125. package/dist/navigation/location.js +14 -76
  126. package/dist/navigation/scope.context.d.ts +17 -26
  127. package/dist/navigation/scope.context.d.ts.map +1 -1
  128. package/dist/navigation/scope.context.js +140 -108
  129. package/dist/navigation/snapshot.d.ts +14 -19
  130. package/dist/navigation/snapshot.d.ts.map +1 -1
  131. package/dist/navigation/snapshot.js +48 -44
  132. package/dist/schema/action.hook.d.ts +44 -0
  133. package/dist/schema/action.hook.d.ts.map +1 -0
  134. package/dist/schema/action.hook.js +72 -0
  135. package/dist/schema/domain.hook.d.ts +12 -7
  136. package/dist/schema/domain.hook.d.ts.map +1 -1
  137. package/dist/schema/domain.hook.js +101 -4
  138. package/dist/schema/index.d.ts +9 -8
  139. package/dist/schema/index.d.ts.map +1 -1
  140. package/dist/schema/index.js +5 -7
  141. package/dist/schema/kernel.hook.d.ts +4 -9
  142. package/dist/schema/kernel.hook.d.ts.map +1 -1
  143. package/dist/schema/kernel.hook.js +4 -6
  144. package/dist/schema/mutation.hook.d.ts +9 -0
  145. package/dist/schema/mutation.hook.d.ts.map +1 -0
  146. package/dist/schema/mutation.hook.js +41 -0
  147. package/dist/schema/object.hook.d.ts +16 -0
  148. package/dist/schema/object.hook.d.ts.map +1 -0
  149. package/dist/schema/object.hook.js +46 -0
  150. package/dist/schema/relation.hook.d.ts +46 -0
  151. package/dist/schema/relation.hook.d.ts.map +1 -0
  152. package/dist/schema/relation.hook.js +136 -0
  153. package/dist/selection/live.d.ts +9 -17
  154. package/dist/selection/live.d.ts.map +1 -1
  155. package/dist/selection/live.js +65 -112
  156. package/dist/selection/scope.context.js +5 -4
  157. package/dist/session/boot/boot.d.ts +1 -13
  158. package/dist/session/boot/boot.d.ts.map +1 -1
  159. package/dist/session/boot/boot.js +9 -27
  160. package/dist/session/index.d.ts +1 -0
  161. package/dist/session/index.d.ts.map +1 -1
  162. package/dist/session/kernel-instance.hook.d.ts +1 -4
  163. package/dist/session/kernel-instance.hook.d.ts.map +1 -1
  164. package/dist/session/kernel-instance.hook.js +1 -5
  165. package/dist/session/provider.d.ts +9 -23
  166. package/dist/session/provider.d.ts.map +1 -1
  167. package/dist/session/provider.js +29 -75
  168. package/dist/session/session.context.d.ts +5 -0
  169. package/dist/session/session.context.d.ts.map +1 -1
  170. package/dist/window/adopt.d.ts +0 -1
  171. package/dist/window/adopt.d.ts.map +1 -1
  172. package/dist/window/hooks/target-node.hook.d.ts +10 -6
  173. package/dist/window/hooks/target-node.hook.d.ts.map +1 -1
  174. package/dist/window/hooks/target-node.hook.js +14 -72
  175. package/dist/window/hooks/views-for.hook.d.ts +4 -3
  176. package/dist/window/hooks/views-for.hook.d.ts.map +1 -1
  177. package/dist/window/hooks/views-for.hook.js +6 -22
  178. package/dist/window/hooks/windows.hook.d.ts.map +1 -1
  179. package/dist/window/hooks/windows.hook.js +3 -4
  180. package/dist/window/host.d.ts +9 -11
  181. package/dist/window/host.d.ts.map +1 -1
  182. package/dist/window/host.js +26 -62
  183. package/dist/window/hub.d.ts +2 -0
  184. package/dist/window/hub.d.ts.map +1 -1
  185. package/dist/window/hub.js +33 -0
  186. package/dist/window/index.d.ts +2 -2
  187. package/dist/window/index.d.ts.map +1 -1
  188. package/dist/window/index.js +2 -2
  189. package/dist/window/lifecycle/mount.d.ts +5 -44
  190. package/dist/window/lifecycle/mount.d.ts.map +1 -1
  191. package/dist/window/lifecycle/mount.js +14 -120
  192. package/dist/window/lifecycle/states.d.ts +0 -5
  193. package/dist/window/lifecycle/states.d.ts.map +1 -1
  194. package/package.json +20 -8
  195. package/src/application/apps/app-host.tsx +11 -15
  196. package/src/application/apps/apps.hook.ts +13 -6
  197. package/src/application/apps/domains.hook.ts +1 -1
  198. package/src/application/apps/open-app.hook.ts +3 -4
  199. package/src/application/index.ts +4 -6
  200. package/src/application/spaces/space.hook.ts +5 -6
  201. package/src/application/spaces/spaces.hook.ts +14 -9
  202. package/src/auth/act-as.context.tsx +37 -91
  203. package/src/auth/auth.hook.ts +2 -30
  204. package/src/auth/can.hook.ts +44 -135
  205. package/src/auth/index.ts +1 -0
  206. package/src/auth/self.hook.ts +2 -9
  207. package/src/auth/session-kernel.ts +6 -16
  208. package/src/components/astrale.tsx +40 -0
  209. package/src/components/boundaries.tsx +113 -0
  210. package/src/components/can.tsx +16 -0
  211. package/src/components/index.ts +13 -0
  212. package/src/graph/call/call.hook.ts +22 -27
  213. package/src/graph/call/stream.hook.ts +66 -143
  214. package/src/graph/graph.context.ts +6 -11
  215. package/src/graph/guards.error.ts +17 -55
  216. package/src/graph/index.ts +23 -17
  217. package/src/graph/memory/read/envelope.ts +40 -65
  218. package/src/graph/memory/read/idle.ts +5 -18
  219. package/src/graph/query-definition.hook.ts +270 -0
  220. package/src/graph/resource.ts +358 -0
  221. package/src/graph/store.ts +97 -0
  222. package/src/host/actions.hook.ts +165 -0
  223. package/src/host/components.tsx +29 -0
  224. package/src/host/index.ts +17 -0
  225. package/src/index.ts +131 -124
  226. package/src/intents/envelope.ts +7 -23
  227. package/src/intents/send-intent.hook.ts +24 -79
  228. package/src/navigation/adapters/adapter.ts +3 -0
  229. package/src/navigation/adapters/memory.adapter.ts +4 -0
  230. package/src/navigation/adapters/url.adapter.ts +48 -8
  231. package/src/navigation/codec.ts +190 -0
  232. package/src/navigation/history.ts +20 -11
  233. package/src/navigation/hooks/ancestors.hook.ts +10 -60
  234. package/src/navigation/hooks/location.hook.ts +4 -6
  235. package/src/navigation/hooks/scope.hook.ts +4 -6
  236. package/src/navigation/index.ts +18 -2
  237. package/src/navigation/link.tsx +27 -2
  238. package/src/navigation/location.ts +26 -93
  239. package/src/navigation/scope.context.tsx +151 -136
  240. package/src/navigation/snapshot.ts +69 -50
  241. package/src/schema/action.hook.ts +146 -0
  242. package/src/schema/domain.hook.ts +127 -11
  243. package/src/schema/index.ts +9 -30
  244. package/src/schema/kernel.hook.ts +6 -13
  245. package/src/schema/mutation.hook.ts +63 -0
  246. package/src/schema/object.hook.ts +85 -0
  247. package/src/schema/relation.hook.ts +253 -0
  248. package/src/selection/live.ts +75 -125
  249. package/src/selection/scope.context.tsx +4 -4
  250. package/src/session/boot/boot.ts +8 -33
  251. package/src/session/index.ts +1 -0
  252. package/src/session/kernel-instance.hook.ts +2 -11
  253. package/src/session/provider.tsx +34 -103
  254. package/src/session/session.context.ts +6 -0
  255. package/src/window/adopt.ts +0 -1
  256. package/src/window/hooks/target-node.hook.ts +20 -85
  257. package/src/window/hooks/views-for.hook.ts +12 -25
  258. package/src/window/hooks/windows.hook.ts +3 -4
  259. package/src/window/host.tsx +35 -77
  260. package/src/window/hub.ts +33 -0
  261. package/src/window/index.ts +3 -3
  262. package/src/window/lifecycle/mount.ts +15 -160
  263. package/src/window/lifecycle/states.ts +1 -5
  264. package/dist/application/roles.hook.d.ts +0 -7
  265. package/dist/application/roles.hook.d.ts.map +0 -1
  266. package/dist/application/roles.hook.js +0 -23
  267. package/dist/graph/memory/base.d.ts +0 -21
  268. package/dist/graph/memory/base.d.ts.map +0 -1
  269. package/dist/graph/memory/base.js +0 -33
  270. package/dist/graph/memory/read/read.d.ts +0 -9
  271. package/dist/graph/memory/read/read.d.ts.map +0 -1
  272. package/dist/graph/memory/read/read.js +0 -87
  273. package/dist/graph/memory/scope.d.ts +0 -7
  274. package/dist/graph/memory/scope.d.ts.map +0 -1
  275. package/dist/graph/memory/scope.js +0 -25
  276. package/dist/graph/mutate/move.hook.d.ts +0 -7
  277. package/dist/graph/mutate/move.hook.d.ts.map +0 -1
  278. package/dist/graph/mutate/move.hook.js +0 -49
  279. package/dist/graph/mutate/mutate.hook.d.ts +0 -17
  280. package/dist/graph/mutate/mutate.hook.d.ts.map +0 -1
  281. package/dist/graph/mutate/mutate.hook.js +0 -45
  282. package/dist/graph/query/children.hook.d.ts +0 -29
  283. package/dist/graph/query/children.hook.d.ts.map +0 -1
  284. package/dist/graph/query/children.hook.js +0 -64
  285. package/dist/graph/query/graph.hook.d.ts +0 -9
  286. package/dist/graph/query/graph.hook.d.ts.map +0 -1
  287. package/dist/graph/query/graph.hook.js +0 -5
  288. package/dist/graph/query/neighbors.hook.d.ts +0 -7
  289. package/dist/graph/query/neighbors.hook.d.ts.map +0 -1
  290. package/dist/graph/query/neighbors.hook.js +0 -104
  291. package/dist/graph/query/node.hook.d.ts +0 -14
  292. package/dist/graph/query/node.hook.d.ts.map +0 -1
  293. package/dist/graph/query/node.hook.js +0 -43
  294. package/dist/graph/query/query.hook.d.ts +0 -14
  295. package/dist/graph/query/query.hook.d.ts.map +0 -1
  296. package/dist/graph/query/query.hook.js +0 -23
  297. package/dist/schema/bind-read.d.ts +0 -37
  298. package/dist/schema/bind-read.d.ts.map +0 -1
  299. package/dist/schema/bind-read.js +0 -205
  300. package/dist/schema/binding.d.ts +0 -21
  301. package/dist/schema/binding.d.ts.map +0 -1
  302. package/dist/schema/binding.js +0 -99
  303. package/dist/schema/function.hook.d.ts +0 -9
  304. package/dist/schema/function.hook.d.ts.map +0 -1
  305. package/dist/schema/function.hook.js +0 -40
  306. package/dist/schema/method.hook.d.ts +0 -14
  307. package/dist/schema/method.hook.d.ts.map +0 -1
  308. package/dist/schema/method.hook.js +0 -49
  309. package/dist/schema/tag.d.ts +0 -11
  310. package/dist/schema/tag.d.ts.map +0 -1
  311. package/dist/schema/tag.js +0 -11
  312. package/dist/schema/types.d.ts +0 -73
  313. package/dist/schema/types.d.ts.map +0 -1
  314. package/dist/schema/types.js +0 -1
  315. package/dist/schema/write.d.ts +0 -16
  316. package/dist/schema/write.d.ts.map +0 -1
  317. package/dist/schema/write.js +0 -56
  318. package/src/application/roles.hook.ts +0 -41
  319. package/src/graph/memory/base.ts +0 -50
  320. package/src/graph/memory/read/read.ts +0 -103
  321. package/src/graph/memory/scope.ts +0 -29
  322. package/src/graph/mutate/move.hook.ts +0 -70
  323. package/src/graph/mutate/mutate.hook.ts +0 -69
  324. package/src/graph/query/children.hook.ts +0 -136
  325. package/src/graph/query/graph.hook.ts +0 -13
  326. package/src/graph/query/neighbors.hook.ts +0 -159
  327. package/src/graph/query/node.hook.ts +0 -83
  328. package/src/graph/query/query.hook.ts +0 -42
  329. package/src/schema/bind-read.ts +0 -319
  330. package/src/schema/binding.ts +0 -146
  331. package/src/schema/function.hook.ts +0 -68
  332. package/src/schema/method.hook.ts +0 -103
  333. package/src/schema/tag.ts +0 -19
  334. package/src/schema/types.ts +0 -150
  335. package/src/schema/write.ts +0 -96
@@ -1,119 +1,44 @@
1
- import { rawOf } from '@astrale-os/kernel-client/graph';
1
+ import { Path } from '@astrale-os/sdk/graph/path';
2
+ import { useEffect, useState } from 'react';
3
+ import { useIdentityBinding } from './act-as.context.js';
2
4
  /**
3
- * useCan (API §4) — deduped standing-grant permission checks. `auth.check`-backed:
4
- * `undefined` while the first check is in flight (or `on` is idle), then a boolean.
5
- * Deduped per (principal, perms, nodeId) across the whole tree via the principal's
6
- * check ledger (folded in here as the dedup substrate). Standing-grant semantics:
7
- * the dispatched call remains the gatekeeper — this is a UI affordance, not the
8
- * enforcement point (SPEC §6.2). A local grant/revoke invalidates the ledger.
5
+ * Evaluate one declared Kernel policy for one exact graph object. This is a UI affordance; the
6
+ * invoked callable remains the authorization enforcement point.
9
7
  */
10
- import { useCallback, useMemo, useSyncExternalStore } from 'react';
11
- import { isIdleInput } from '../graph/memory/read/idle.js';
12
- import { useIdentityBinding } from './act-as.context.js';
13
- const NOOP_UNSUB = () => undefined;
14
- /** A node value carries the id/class/path triple (mirrors the memory's `isNodeValue`). */
15
- export function isNodeValue(x) {
16
- return typeof x === 'object' && x !== null && 'id' in x && 'class' in x && 'path' in x;
17
- }
18
- /** Normalize a `useCan` subject to a dispatchable `Ref` plus a stable dedup key. */
19
- export function toRef(on) {
20
- if (isNodeValue(on))
21
- return { ref: on.path, key: `@${on.id}` };
22
- return { ref: on, key: rawOf(on) };
23
- }
24
- // ── check ledger (the dedup substrate) ───────────────────────────────────────
25
- /** One deduped check — its last-known value plus the subscribers watching it. */
26
- class CheckCell {
27
- auth;
28
- perms;
29
- on;
30
- value = undefined;
31
- inFlight = false;
32
- listeners = new Set();
33
- constructor(auth, perms, on) {
34
- this.auth = auth;
35
- this.perms = perms;
36
- this.on = on;
37
- }
38
- subscribe = (onChange) => {
39
- this.listeners.add(onChange);
40
- this.ensure();
41
- return () => this.listeners.delete(onChange);
42
- };
43
- getSnapshot = () => this.value;
44
- /** Run the check once when the value is unknown and nothing is in flight. */
45
- ensure() {
46
- if (this.value !== undefined || this.inFlight)
47
- return;
48
- this.run();
49
- }
50
- /** Force a re-check (local grant/revoke on this principal). */
51
- invalidate() {
52
- if (this.listeners.size === 0) {
53
- this.value = undefined; // recompute lazily on the next subscribe
8
+ export function useCan(policy, object) {
9
+ const { kernel } = useIdentityBinding();
10
+ const objectId = objectIdOf(object);
11
+ const policyTarget = policyPath(policy);
12
+ const [decision, setDecision] = useState(undefined);
13
+ useEffect(() => {
14
+ if (policyTarget === null || objectId === null) {
15
+ setDecision(undefined);
54
16
  return;
55
17
  }
56
- this.run();
57
- }
58
- run() {
59
- this.inFlight = true;
60
- void this.auth
61
- .check({ on: this.on, perms: this.perms })
62
- .then((ok) => {
63
- this.value = ok;
18
+ let active = true;
19
+ setDecision(undefined);
20
+ void kernel.auth.can({ policy: policyTarget, object: objectId }).then((allowed) => {
21
+ if (active)
22
+ setDecision(allowed);
64
23
  }, () => {
65
- // A failed check leaves the value unknown (undefined) — never a false grant.
66
- this.value = undefined;
67
- })
68
- .finally(() => {
69
- this.inFlight = false;
70
- for (const l of this.listeners)
71
- l();
24
+ if (active)
25
+ setDecision(undefined);
72
26
  });
73
- }
74
- }
75
- /** Per-principal cell registry — dedup across the whole tree for one kernel handle. */
76
- export class CheckLedger {
77
- auth;
78
- cells = new Map();
79
- constructor(auth) {
80
- this.auth = auth;
81
- }
82
- cell(key, perms, on) {
83
- let cell = this.cells.get(key);
84
- if (cell === undefined) {
85
- cell = new CheckCell(this.auth, perms, on);
86
- this.cells.set(key, cell);
87
- }
88
- return cell;
89
- }
90
- /** Re-check every observed cell — conservative Tier-0 sweep after a local grant/revoke. */
91
- invalidateAll() {
92
- for (const cell of this.cells.values())
93
- cell.invalidate();
94
- }
27
+ return () => {
28
+ active = false;
29
+ };
30
+ }, [kernel, policyTarget, objectId]);
31
+ return decision;
95
32
  }
96
- // One ledger per bound kernel object → per principal. `session.as(cred)` mints a
97
- // fresh view per ActAs, so acted-as principals never share a ledger with the root.
98
- const ledgers = new WeakMap();
99
- export function ledgerFor(kernel) {
100
- let ledger = ledgers.get(kernel);
101
- if (ledger === undefined) {
102
- ledger = new CheckLedger(kernel.auth);
103
- ledgers.set(kernel, ledger);
104
- }
105
- return ledger;
33
+ function policyPath(policy) {
34
+ if (policy === null || policy === undefined)
35
+ return null;
36
+ return policy instanceof Path || typeof policy === 'string'
37
+ ? Path.from(policy).raw
38
+ : Path.project(policy).raw;
106
39
  }
107
- // ── useCan ────────────────────────────────────────────────────────────────────
108
- export function useCan(perms, on) {
109
- const binding = useIdentityBinding();
110
- const ref = isIdleInput(on) ? null : toRef(on);
111
- // The shared cell for (principal, perms, nodeId): identical to every other
112
- // useCan reading the same triple, so one check serves the whole tree.
113
- const cell = useMemo(() => ref === null ? null : ledgerFor(binding.kernel).cell(`${perms}\0${ref.key}`, perms, ref.ref),
114
- // ref is rebuilt per render; its `key` string is the stable identity.
115
- [binding.kernel, perms, ref?.key]);
116
- const subscribe = useCallback((onChange) => (cell === null ? NOOP_UNSUB : cell.subscribe(onChange)), [cell]);
117
- const getSnapshot = useCallback(() => cell?.getSnapshot(), [cell]);
118
- return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
40
+ function objectIdOf(value) {
41
+ if (value === null || value === undefined)
42
+ return null;
43
+ return typeof value === 'object' ? value.id : value;
119
44
  }
@@ -2,5 +2,6 @@ export { ActAs } from './act-as.context.js';
2
2
  export type { ActAsProps } from './act-as.context.js';
3
3
  export { useAuth } from './auth.hook.js';
4
4
  export { useCan } from './can.hook.js';
5
+ export type { PolicyObject } from './can.hook.js';
5
6
  export { useSelf } from './self.hook.js';
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA"}
@@ -1,3 +1,3 @@
1
- import type { NodeValue } from './act-as.context.js';
2
- export declare function useSelf(): NodeValue;
1
+ import type { Identity } from '@astrale-os/kernel-client/auth';
2
+ export declare function useSelf(): Identity;
3
3
  //# sourceMappingURL=self.hook.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"self.hook.d.ts","sourceRoot":"","sources":["../../src/auth/self.hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAWpD,wBAAgB,OAAO,IAAI,SAAS,CAEnC"}
1
+ {"version":3,"file":"self.hook.d.ts","sourceRoot":"","sources":["../../src/auth/self.hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAA;AAI9D,wBAAgB,OAAO,IAAI,QAAQ,CAElC"}
@@ -1,10 +1,3 @@
1
- /**
2
- * useSelf (API §4) — the caller's identity node, resolved at boot and read
3
- * synchronously (never suspends). An <ActAs> subtree returns the acted-as
4
- * identity. FLAG: today this is the boot-resolved whoami snapshot; it becomes a
5
- * live memory shape once the graph plane subscribes the self node — no signature
6
- * change.
7
- */
8
1
  import { useIdentityBinding } from './act-as.context.js';
9
2
  export function useSelf() {
10
3
  return useIdentityBinding().self;
@@ -1,4 +1,3 @@
1
- import type { SessionView } from './act-as.context.js';
2
- /** The EFFECTIVE dispatch kernel for this subtree. Throws outside a provider. */
3
- export declare function useSessionKernel(): SessionView;
1
+ import type { KernelClient } from '@astrale-os/shell';
2
+ export declare function useSessionKernel(): KernelClient;
4
3
  //# sourceMappingURL=session-kernel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"session-kernel.d.ts","sourceRoot":"","sources":["../../src/auth/session-kernel.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAKtD,iFAAiF;AACjF,wBAAgB,gBAAgB,IAAI,WAAW,CAQ9C"}
1
+ {"version":3,"file":"session-kernel.d.ts","sourceRoot":"","sources":["../../src/auth/session-kernel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAOrD,wBAAgB,gBAAgB,IAAI,YAAY,CAM/C"}
@@ -1,21 +1,12 @@
1
- /**
2
- * useSessionKernel (API §4) — the dispatch-floor resolver. Inside an `<ActAs>` it
3
- * is the acted-as principal's bound session view; otherwise the root
4
- * `shell.kernel`. Every dispatch floor (schema bindings, useCall/useStream, useMove,
5
- * typed method dispatch) routes through this so a call runs as the subtree's
6
- * principal — not the root — and its scoped memory.
7
- */
8
1
  import { useContext } from 'react';
9
2
  import { ShellContext } from '../session/session.context.js';
10
3
  import { IdentityContext } from './act-as.context.js';
11
- /** The EFFECTIVE dispatch kernel for this subtree. Throws outside a provider. */
12
4
  export function useSessionKernel() {
13
- const binding = useContext(IdentityContext);
5
+ const identity = useContext(IdentityContext);
14
6
  const runtime = useContext(ShellContext);
15
- if (binding !== null)
16
- return binding.kernel;
17
- if (runtime === null) {
7
+ if (identity !== null)
8
+ return identity.kernel;
9
+ if (runtime === null)
18
10
  throw new Error('session hooks must be used within a <ShellProvider>');
19
- }
20
11
  return runtime.shell.kernel;
21
12
  }
@@ -0,0 +1,14 @@
1
+ import type { Shell, ShellConfig } from '@astrale-os/shell';
2
+ import type { ReactElement, ReactNode } from 'react';
3
+ import type { ShellProviderProps } from '../session/provider.js';
4
+ export interface AstraleProps {
5
+ /** Defaults to the child-side sandbox handshake; pass a Shell for an embedded host or test. */
6
+ readonly config?: ShellConfig | Shell;
7
+ readonly fallback?: ReactNode;
8
+ readonly errorFallback?: ShellProviderProps['errorFallback'];
9
+ readonly onError?: (error: unknown) => void;
10
+ readonly children: ReactNode;
11
+ }
12
+ /** Complete Astrale runtime root without taking ownership of application routing. */
13
+ export declare function Astrale(props: AstraleProps): ReactElement;
14
+ //# sourceMappingURL=astrale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"astrale.d.ts","sourceRoot":"","sources":["../../src/components/astrale.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAIpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAQhE,MAAM,WAAW,YAAY;IAC3B,+FAA+F;IAC/F,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,KAAK,CAAA;IACrC,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;IAC7B,QAAQ,CAAC,aAAa,CAAC,EAAE,kBAAkB,CAAC,eAAe,CAAC,CAAA;IAC5D,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IAC3C,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAA;CAC7B;AAED,qFAAqF;AACrF,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,YAAY,CAgBzD"}
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Suspense } from 'react';
3
+ import { ShellProvider } from '../session/provider.js';
4
+ import { ViewStage } from '../window/stage.js';
5
+ import { defaultViewError, defaultViewLoading, ViewErrorBoundary } from './boundaries.js';
6
+ const SANDBOXED_SHELL = Object.freeze({ mode: 'sandboxed' });
7
+ /** Complete Astrale runtime root without taking ownership of application routing. */
8
+ export function Astrale(props) {
9
+ const loading = props.fallback ?? defaultViewLoading();
10
+ const errorFallback = props.errorFallback ?? defaultViewError;
11
+ return (_jsxs(ShellProvider, { config: props.config ?? SANDBOXED_SHELL, fallback: loading, errorFallback: errorFallback, onError: ({ error }) => props.onError?.(error), children: [_jsx(ViewErrorBoundary, { fallback: errorFallback, onError: props.onError, children: _jsx(Suspense, { fallback: loading, children: props.children }) }), _jsx(ViewStage, {})] }));
12
+ }
@@ -0,0 +1,47 @@
1
+ import type { CredentialSnapshot } from '@astrale-os/shell';
2
+ import type { ReactElement, ReactNode } from 'react';
3
+ import { Component } from 'react';
4
+ import type { GraphResource } from '../graph/resource.js';
5
+ import { useConnection } from '../session/connection/connection.hook.js';
6
+ export declare function ViewBoundary<T>(props: {
7
+ readonly resource: GraphResource<T>;
8
+ readonly children: (value: T) => ReactNode;
9
+ readonly loading?: ReactNode;
10
+ readonly empty?: ReactNode;
11
+ readonly error?: (error: unknown) => ReactNode;
12
+ }): ReactElement;
13
+ export declare const GraphBoundary: typeof ViewBoundary;
14
+ export interface ViewErrorBoundaryProps {
15
+ /** A render function receives the retry generation and can recreate rejected lazy resources. */
16
+ readonly children: ReactNode | ((generation: number) => ReactNode);
17
+ readonly fallback?: (error: unknown, retry: () => void) => ReactNode;
18
+ readonly onError?: (error: unknown) => void;
19
+ }
20
+ /** Catch Shell View render/lazy failures and remount the failed subtree on explicit retry. */
21
+ export declare class ViewErrorBoundary extends Component<ViewErrorBoundaryProps, {
22
+ readonly error: unknown;
23
+ readonly generation: number;
24
+ }> {
25
+ state: {
26
+ error: unknown;
27
+ generation: number;
28
+ };
29
+ static getDerivedStateFromError(error: unknown): {
30
+ error: unknown;
31
+ };
32
+ componentDidCatch(error: unknown): void;
33
+ private readonly retry;
34
+ render(): ReactNode;
35
+ }
36
+ export declare function defaultViewLoading(): ReactElement;
37
+ export declare function defaultViewError(_error: unknown, retry: () => void): ReactElement;
38
+ export declare function ConnectionBoundary(props: {
39
+ readonly children: ReactNode;
40
+ readonly fallback?: (status: ReturnType<typeof useConnection>) => ReactNode;
41
+ }): ReactElement;
42
+ export declare function CredentialBoundary(props: {
43
+ readonly credential: CredentialSnapshot;
44
+ readonly children: ReactNode;
45
+ readonly fallback?: (credential: CredentialSnapshot) => ReactNode;
46
+ }): ReactElement;
47
+ //# sourceMappingURL=boundaries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boundaries.d.ts","sourceRoot":"","sources":["../../src/components/boundaries.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,C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AC,KAAK,EAAE,OAAO,GAAG,IAAI,CAE/C;IAED,OAAO,CAAC,QAAQ,CAAC,KAAK,CAErB;IAEQ,MAAM,IAAI,SAAS,CAY3B;CACF;AAED,wBAAgB,kBAAkB,IAAI,YAAY,CAMjD;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,IAAI,GAAG,YAAY,CASjF;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IACxC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAA;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,KAAK,SAAS,CAAA;CAC5E,GAAG,YAAY,CAOf;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IACxC,QAAQ,CAAC,UAAU,EAAE,kBAAkB,CAAA;IACvC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAA;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,UAAU,EAAE,kBAAkB,KAAK,SAAS,CAAA;CAClE,GAAG,YAAY,CAQf"}
@@ -0,0 +1,55 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Component, Fragment } from 'react';
3
+ import { useConnection } from '../session/connection/connection.hook.js';
4
+ export function ViewBoundary(props) {
5
+ const { resource } = props;
6
+ if (resource.state === 'failed') {
7
+ if (props.error !== undefined)
8
+ return _jsx(_Fragment, { children: props.error(resource.error) });
9
+ throw resource.error;
10
+ }
11
+ if (resource.data === undefined)
12
+ return _jsx(_Fragment, { children: props.loading ?? null });
13
+ if (resource.data === null)
14
+ return _jsx(_Fragment, { children: props.empty ?? null });
15
+ return _jsx(_Fragment, { children: props.children(resource.data) });
16
+ }
17
+ export const GraphBoundary = ViewBoundary;
18
+ /** Catch Shell View render/lazy failures and remount the failed subtree on explicit retry. */
19
+ export class ViewErrorBoundary extends Component {
20
+ state = { error: undefined, generation: 0 };
21
+ static getDerivedStateFromError(error) {
22
+ return { error };
23
+ }
24
+ componentDidCatch(error) {
25
+ this.props.onError?.(error);
26
+ }
27
+ retry = () => {
28
+ this.setState((state) => ({ error: undefined, generation: state.generation + 1 }));
29
+ };
30
+ render() {
31
+ if (this.state.error !== undefined) {
32
+ return (this.props.fallback?.(this.state.error, this.retry) ??
33
+ defaultViewError(this.state.error, this.retry));
34
+ }
35
+ const content = typeof this.props.children === 'function'
36
+ ? this.props.children(this.state.generation)
37
+ : this.props.children;
38
+ return _jsx(Fragment, { children: content }, this.state.generation);
39
+ }
40
+ }
41
+ export function defaultViewLoading() {
42
+ return (_jsx("div", { role: "status", "aria-live": "polite", children: "Loading view\u2026" }));
43
+ }
44
+ export function defaultViewError(_error, retry) {
45
+ return (_jsxs("section", { role: "alert", children: [_jsx("p", { children: "View could not load." }), _jsx("button", { type: "button", onClick: retry, children: "Retry" })] }));
46
+ }
47
+ export function ConnectionBoundary(props) {
48
+ const connection = useConnection();
49
+ return connection.status === 'ready' ? (_jsx(_Fragment, { children: props.children })) : (_jsx(_Fragment, { children: props.fallback?.(connection) ?? null }));
50
+ }
51
+ export function CredentialBoundary(props) {
52
+ return props.credential.state === 'valid' ||
53
+ props.credential.state === 'refreshing' ||
54
+ props.credential.state === 'degraded' ? (_jsx(_Fragment, { children: props.children })) : (_jsx(_Fragment, { children: props.fallback?.(props.credential) ?? null }));
55
+ }
@@ -0,0 +1,11 @@
1
+ import type { PathLike } from '@astrale-os/sdk/graph/path';
2
+ import type { schema } from '@astrale-os/sdk/schema';
3
+ import type { ReactElement, ReactNode } from 'react';
4
+ import type { PolicyObject } from '../auth/can.hook.js';
5
+ export declare function Can(props: {
6
+ readonly policy: PathLike | schema.PolicyRef;
7
+ readonly object: PolicyObject;
8
+ readonly children: ReactNode;
9
+ readonly fallback?: ReactNode;
10
+ }): ReactElement;
11
+ //# sourceMappingURL=can.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"can.d.ts","sourceRoot":"","sources":["../../src/components/can.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAIvD,wBAAgB,GAAG,CAAC,KAAK,EAAE;IACzB,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAA;IAC5C,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAA;IAC7B,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAA;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAC9B,GAAG,YAAY,CAEf"}
@@ -0,0 +1,5 @@
1
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
+ import { useCan } from '../auth/can.hook.js';
3
+ export function Can(props) {
4
+ return _jsx(_Fragment, { children: useCan(props.policy, props.object) === true ? props.children : props.fallback });
5
+ }
@@ -0,0 +1,6 @@
1
+ export { Can } from './can.js';
2
+ export { ConnectionBoundary, CredentialBoundary, defaultViewError, defaultViewLoading, GraphBoundary, ViewErrorBoundary, ViewBoundary, } from './boundaries.js';
3
+ export type { ViewErrorBoundaryProps } from './boundaries.js';
4
+ export { Astrale } from './astrale.js';
5
+ export type { AstraleProps } from './astrale.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,YAAY,GACb,MAAM,iBAAiB,CAAA;AACxB,YAAY,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA"}
@@ -0,0 +1,3 @@
1
+ export { Can } from './can.js';
2
+ export { ConnectionBoundary, CredentialBoundary, defaultViewError, defaultViewLoading, GraphBoundary, ViewErrorBoundary, ViewBoundary, } from './boundaries.js';
3
+ export { Astrale } from './astrale.js';
@@ -1,21 +1,11 @@
1
- /**
2
- * useCall (API §7) — unary domain-function dispatch over `kernel.call`, in the
3
- * Action envelope. No result caching, no liveness — domain function reads are not
4
- * structurally invalidatable (FRONTEND §5.7); a consumer that needs freshness
5
- * owns its own refetch policy. Dispatch is a graph operation (rule 2).
6
- */
7
- import type { CallFns, FnMap } from '@astrale-os/kernel-client';
1
+ import type { Call } from '@astrale-os/kernel-client';
2
+ import type { SessionRequestOptions } from '@astrale-os/kernel-client/session';
3
+ import type { Value } from '@astrale-os/sdk/value';
8
4
  import type { Action } from '../action.js';
9
- export interface CallOptions {
10
- /** Per-call timeout (ms), forwarded to the kernel dispatch. */
11
- timeout?: number;
12
- /** Side-channel notified on rejection (the Action also records `.error`). */
13
- onError?(error: unknown): void;
5
+ export interface CallOptions extends SessionRequestOptions {
6
+ readonly onError?: (error: unknown) => void;
14
7
  }
15
- /**
16
- * Unary domain-function dispatch as an {@link Action}. `method` is a typed FnMap
17
- * `call` path or any string (the untyped floor); `null` yields an idle action
18
- * that rejects if invoked. Params/result are typed from the FnMap entry.
19
- */
20
- export declare function useCall<K extends CallFns<FnMap>>(method: K | null, opts?: CallOptions): Action<[FnMap[K]['params']], FnMap[K]['result']>;
8
+ export type CallResult = Value;
9
+ export declare function useCall(call: Call | null, options?: CallOptions): Action<[], CallResult>;
10
+ export declare function useCall<A extends unknown[]>(author: ((...args: A) => Call) | null, options?: CallOptions): Action<A, CallResult>;
21
11
  //# sourceMappingURL=call.hook.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"call.hook.d.ts","sourceRoot":"","sources":["../../../src/graph/call/call.hook.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAA;AAE/D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAK1C,MAAM,WAAW,WAAW;IAC1B,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,6EAA6E;IAC7E,OAAO,CAAC,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAA;CAC/B;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,OAAO,CAAC,KAAK,CAAC,EAC9C,MAAM,EAAE,CAAC,GAAG,IAAI,EAChB,IAAI,CAAC,EAAE,WAAW,GACjB,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAalD"}
1
+ {"version":3,"file":"call.hook.d.ts","sourceRoot":"","sources":["../../../src/graph/call/call.hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAA;AAC9E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAElD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAK1C,MAAM,WAAW,WAAY,SAAQ,qBAAqB;IACxD,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;CAC5C;AAED,MAAM,MAAM,UAAU,GAAG,KAAK,CAAA;AAG9B,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC,EAAE,EAAE,UAAU,CAAC,CAAA;AACzF,wBAAgB,OAAO,CAAC,CAAC,SAAS,OAAO,EAAE,EACzC,MAAM,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC,GAAG,IAAI,EACrC,OAAO,CAAC,EAAE,WAAW,GACpB,MAAM,CAAC,CAAC,EAAE,UAAU,CAAC,CAAA"}
@@ -1,22 +1,16 @@
1
1
  import { useSessionKernel } from '../../auth/session-kernel.js';
2
2
  import { useAction } from '../action.js';
3
- /**
4
- * Unary domain-function dispatch as an {@link Action}. `method` is a typed FnMap
5
- * `call` path or any string (the untyped floor); `null` yields an idle action
6
- * that rejects if invoked. Params/result are typed from the FnMap entry.
7
- */
8
- export function useCall(method, opts) {
3
+ export function useCall(author, options) {
9
4
  const kernel = useSessionKernel();
10
- // A fresh closure per render captures the current method/opts; `useAction`
11
- // keeps ONE stable callable and always dispatches this latest closure.
12
- return useAction(async (params) => {
13
- if (method === null)
14
- throw new Error('useCall: method is null (idle action invoked)');
5
+ return useAction(async (...args) => {
6
+ if (author === null)
7
+ throw new Error('useCall: idle action invoked');
8
+ const call = typeof author === 'function' ? author(...args) : author;
15
9
  try {
16
- return await kernel.call(method, params, { timeout: opts?.timeout });
10
+ return await kernel.call(call, options);
17
11
  }
18
12
  catch (error) {
19
- opts?.onError?.(error);
13
+ options?.onError?.(error);
20
14
  throw error;
21
15
  }
22
16
  });
@@ -1,28 +1,20 @@
1
- import type { FnMap, StreamFns } from '@astrale-os/kernel-client';
2
- export interface StreamOptions<T> {
3
- /** Notified per chunk as it arrives (in addition to `chunks` accumulation). */
4
- onChunk?(chunk: T): void;
1
+ import type { Call } from '@astrale-os/kernel-client';
2
+ import type { SessionRequestOptions } from '@astrale-os/kernel-client/session';
3
+ import type { Value } from '@astrale-os/sdk/value';
4
+ import type { KernelClient } from '@astrale-os/shell';
5
+ export type KernelStream = Awaited<ReturnType<KernelClient['stream']>>;
6
+ export type StreamItem = Value;
7
+ export type CallAuthor<A extends unknown[]> = Call | ((...args: A) => Call);
8
+ export interface StreamOptions<T = StreamItem> extends SessionRequestOptions {
9
+ readonly onChunk?: (chunk: T) => void;
5
10
  }
6
- export interface StreamHandle<T> {
7
- /** Begin a run: resets chunks, then resolves when the stream ends / rejects on failure. */
8
- start(params: unknown): Promise<void>;
9
- /** Chunks accumulated in the current run; reset on the next `start`. */
11
+ export interface StreamHandle<A extends unknown[] = unknown[], T = StreamItem> {
12
+ start(...args: A): Promise<void>;
10
13
  readonly chunks: readonly T[];
11
- /** The most recent chunk, or null before the first. */
12
14
  readonly last: T | null;
13
- /** A run is in flight. */
14
15
  readonly streaming: boolean;
15
- /** Last run failure; retained until the next `start`. */
16
16
  readonly error: unknown;
17
- /** Close the stream (returns the iterator); a later `start` begins fresh. */
18
17
  cancel(): void;
19
18
  }
20
- /**
21
- * Streaming domain-function dispatch. `start(params)` opens a run over
22
- * `kernel.stream`; chunks accumulate on `chunks`; `cancel()` closes the iterator
23
- * and a later `start` begins fresh. A superseding `start` (or unmount) closes the
24
- * prior run and discards its late chunks/errors — only the current run drives
25
- * state. Never live; the handle keeps one identity for the hook's lifetime.
26
- */
27
- export declare function useStream<K extends StreamFns<FnMap>>(method: K | null, opts?: StreamOptions<FnMap[K]['result']>): StreamHandle<FnMap[K]['result']>;
19
+ export declare function useStream<A extends unknown[] = []>(author: CallAuthor<A> | null, options?: StreamOptions): StreamHandle<A, StreamItem>;
28
20
  //# sourceMappingURL=stream.hook.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stream.hook.d.ts","sourceRoot":"","sources":["../../../src/graph/call/stream.hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAYjE,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,+EAA+E;IAC/E,OAAO,CAAC,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