@astrale-os/shell 0.1.1 → 0.3.0

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 (284) hide show
  1. package/LICENSE +202 -0
  2. package/dist/application/apps.d.ts +18 -0
  3. package/dist/application/apps.d.ts.map +1 -0
  4. package/dist/application/apps.js +35 -0
  5. package/dist/application/namespaces.d.ts +21 -0
  6. package/dist/application/namespaces.d.ts.map +1 -0
  7. package/dist/application/namespaces.js +12 -0
  8. package/dist/application/session/open.d.ts +19 -0
  9. package/dist/application/session/open.d.ts.map +1 -0
  10. package/dist/application/session/open.js +46 -0
  11. package/dist/application/session/session.d.ts +41 -0
  12. package/dist/application/session/session.d.ts.map +1 -0
  13. package/dist/application/session/session.js +9 -0
  14. package/dist/application/session/token.d.ts +24 -0
  15. package/dist/application/session/token.d.ts.map +1 -0
  16. package/dist/application/session/token.js +51 -0
  17. package/dist/application/spaces.d.ts +17 -0
  18. package/dist/application/spaces.d.ts.map +1 -0
  19. package/dist/application/spaces.js +30 -0
  20. package/dist/application/user.d.ts +20 -0
  21. package/dist/application/user.d.ts.map +1 -0
  22. package/dist/application/user.js +26 -0
  23. package/dist/application/view.d.ts +20 -0
  24. package/dist/application/view.d.ts.map +1 -0
  25. package/dist/application/view.js +18 -0
  26. package/dist/{application/channels/children-channel.d.ts → channel/children.d.ts} +4 -4
  27. package/dist/channel/children.d.ts.map +1 -0
  28. package/dist/channel/listeners.d.ts +8 -0
  29. package/dist/channel/listeners.d.ts.map +1 -0
  30. package/dist/{adapters/message-port.transport.d.ts → channel/message-port.d.ts} +2 -2
  31. package/dist/channel/message-port.d.ts.map +1 -0
  32. package/dist/{application/channels → channel}/observer.d.ts +2 -1
  33. package/dist/channel/observer.d.ts.map +1 -0
  34. package/dist/{application/channels/parent-channel.d.ts → channel/parent.d.ts} +4 -4
  35. package/dist/channel/parent.d.ts.map +1 -0
  36. package/dist/{application/channels/parent-channel.js → channel/parent.js} +1 -1
  37. package/dist/channel/transport.d.ts +8 -0
  38. package/dist/channel/transport.d.ts.map +1 -0
  39. package/dist/index.d.ts +56 -41
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +23 -20
  42. package/dist/{domain/intent → intent}/middleware/capabilities.d.ts +2 -2
  43. package/dist/intent/middleware/capabilities.d.ts.map +1 -0
  44. package/dist/intent/middleware/logging.d.ts.map +1 -0
  45. package/dist/{domain/intent → intent}/middleware/rate-limit.d.ts +1 -1
  46. package/dist/intent/middleware/rate-limit.d.ts.map +1 -0
  47. package/dist/{application/intent/pipeline-runner.d.ts → intent/pipeline.d.ts} +3 -3
  48. package/dist/intent/pipeline.d.ts.map +1 -0
  49. package/dist/intent/policy.d.ts +40 -0
  50. package/dist/intent/policy.d.ts.map +1 -0
  51. package/dist/intent/policy.js +15 -0
  52. package/dist/{application/intent → intent}/request.d.ts +5 -14
  53. package/dist/intent/request.d.ts.map +1 -0
  54. package/dist/{application/intent → intent}/request.js +6 -20
  55. package/dist/intent/router.d.ts +31 -0
  56. package/dist/intent/router.d.ts.map +1 -0
  57. package/dist/{application/intent → intent}/router.js +1 -15
  58. package/dist/kernel/client.d.ts +33 -0
  59. package/dist/kernel/client.d.ts.map +1 -0
  60. package/dist/kernel/credential.d.ts +35 -0
  61. package/dist/kernel/credential.d.ts.map +1 -0
  62. package/dist/kernel/credential.js +43 -0
  63. package/dist/kernel/delegated.d.ts +17 -0
  64. package/dist/kernel/delegated.d.ts.map +1 -0
  65. package/dist/kernel/delegated.js +29 -0
  66. package/dist/{application/windowing/token-refresh.d.ts → kernel/delegation/refresh.d.ts} +2 -2
  67. package/dist/kernel/delegation/refresh.d.ts.map +1 -0
  68. package/dist/{application/windowing/token-refresh.js → kernel/delegation/refresh.js} +1 -1
  69. package/dist/{domain/identity/delegation.d.ts → kernel/delegation/token.d.ts} +1 -1
  70. package/dist/kernel/delegation/token.d.ts.map +1 -0
  71. package/dist/{adapters/kernel-client.adapter.d.ts → kernel/session.d.ts} +15 -12
  72. package/dist/kernel/session.d.ts.map +1 -0
  73. package/dist/{adapters/kernel-client.adapter.js → kernel/session.js} +10 -15
  74. package/dist/message/ctrl.d.ts +34 -0
  75. package/dist/message/ctrl.d.ts.map +1 -0
  76. package/dist/message/error.d.ts +9 -0
  77. package/dist/message/error.d.ts.map +1 -0
  78. package/dist/{application/windowing/protocol.d.ts → message/init.d.ts} +1 -1
  79. package/dist/message/init.d.ts.map +1 -0
  80. package/dist/{domain/message/registries.d.ts → message/intent.d.ts} +45 -37
  81. package/dist/message/intent.d.ts.map +1 -0
  82. package/dist/message/message.d.ts +10 -0
  83. package/dist/message/message.d.ts.map +1 -0
  84. package/dist/shell/access.d.ts +10 -0
  85. package/dist/shell/access.d.ts.map +1 -0
  86. package/dist/shell/access.js +19 -0
  87. package/dist/shell/build.d.ts +28 -0
  88. package/dist/shell/build.d.ts.map +1 -0
  89. package/dist/shell/build.js +58 -0
  90. package/dist/shell/config.d.ts +29 -0
  91. package/dist/shell/config.d.ts.map +1 -0
  92. package/dist/shell/create.d.ts +4 -0
  93. package/dist/shell/create.d.ts.map +1 -0
  94. package/dist/shell/create.js +5 -0
  95. package/dist/{application/windowing/child-init.d.ts → shell/sandboxed/boot.d.ts} +5 -5
  96. package/dist/shell/sandboxed/boot.d.ts.map +1 -0
  97. package/dist/{application/windowing/child-init.js → shell/sandboxed/boot.js} +5 -6
  98. package/dist/shell/sandboxed/guarded.d.ts +13 -0
  99. package/dist/shell/sandboxed/guarded.d.ts.map +1 -0
  100. package/dist/shell/sandboxed/guarded.js +28 -0
  101. package/dist/shell/sandboxed/pending.d.ts +14 -0
  102. package/dist/shell/sandboxed/pending.d.ts.map +1 -0
  103. package/dist/shell/sandboxed/pending.js +30 -0
  104. package/dist/shell/sandboxed/sandboxed.d.ts +4 -0
  105. package/dist/shell/sandboxed/sandboxed.d.ts.map +1 -0
  106. package/dist/shell/sandboxed/sandboxed.js +100 -0
  107. package/dist/shell/shell.d.ts +36 -0
  108. package/dist/shell/shell.d.ts.map +1 -0
  109. package/dist/shell/standalone.d.ts +4 -0
  110. package/dist/shell/standalone.d.ts.map +1 -0
  111. package/dist/shell/standalone.js +85 -0
  112. package/dist/{domain/window/config.d.ts → window/capabilities.d.ts} +3 -3
  113. package/dist/window/capabilities.d.ts.map +1 -0
  114. package/dist/{ports/shell-adapter.d.ts → window/embed/adapter.d.ts} +3 -2
  115. package/dist/window/embed/adapter.d.ts.map +1 -0
  116. package/dist/{adapters/iframe.shell-adapter.d.ts → window/embed/iframe.d.ts} +2 -2
  117. package/dist/window/embed/iframe.d.ts.map +1 -0
  118. package/dist/{application/windowing/lifecycle-controller.d.ts → window/lifecycle/states.d.ts} +4 -3
  119. package/dist/window/lifecycle/states.d.ts.map +1 -0
  120. package/dist/{application/windowing/lifecycle-controller.js → window/lifecycle/states.js} +1 -1
  121. package/dist/{domain/window/lifecycle.d.ts → window/lifecycle/transition.d.ts} +3 -3
  122. package/dist/window/lifecycle/transition.d.ts.map +1 -0
  123. package/dist/{domain/window/lifecycle.js → window/lifecycle/transition.js} +1 -1
  124. package/dist/window/mount/close.d.ts +27 -0
  125. package/dist/window/mount/close.d.ts.map +1 -0
  126. package/dist/window/mount/close.js +74 -0
  127. package/dist/window/mount/credential.d.ts +41 -0
  128. package/dist/window/mount/credential.d.ts.map +1 -0
  129. package/dist/window/mount/credential.js +74 -0
  130. package/dist/window/mount/handshake.d.ts.map +1 -0
  131. package/dist/{application/windowing → window/mount}/handshake.js +1 -1
  132. package/dist/{application/windowing/mount-controller.d.ts → window/mount/mount.d.ts} +7 -7
  133. package/dist/window/mount/mount.d.ts.map +1 -0
  134. package/dist/window/mount/mount.js +143 -0
  135. package/dist/window/mount/params.d.ts +73 -0
  136. package/dist/window/mount/params.d.ts.map +1 -0
  137. package/dist/window/mount/params.js +1 -0
  138. package/dist/window/mount/plain.d.ts +20 -0
  139. package/dist/window/mount/plain.d.ts.map +1 -0
  140. package/dist/window/mount/plain.js +46 -0
  141. package/dist/{domain/window → window}/window.d.ts +1 -1
  142. package/dist/window/window.d.ts.map +1 -0
  143. package/dist/window/window.js +1 -0
  144. package/package.json +15 -7
  145. package/src/application/apps.ts +60 -0
  146. package/src/application/namespaces.ts +38 -0
  147. package/src/application/session/open.ts +73 -0
  148. package/src/application/session/session.ts +46 -0
  149. package/src/application/session/token.ts +87 -0
  150. package/src/application/spaces.ts +52 -0
  151. package/src/application/user.ts +54 -0
  152. package/src/application/view.ts +42 -0
  153. package/src/{application/channels/children-channel.ts → channel/children.ts} +3 -3
  154. package/src/{application/channels/types.ts → channel/listeners.ts} +2 -7
  155. package/src/{adapters/message-port.transport.ts → channel/message-port.ts} +2 -2
  156. package/src/{application/channels → channel}/observer.ts +2 -1
  157. package/src/{application/channels/parent-channel.ts → channel/parent.ts} +4 -4
  158. package/src/{ports → channel}/transport.ts +2 -1
  159. package/src/index.ts +80 -88
  160. package/src/{domain/intent → intent}/middleware/capabilities.ts +2 -3
  161. package/src/{domain/intent → intent}/middleware/logging.ts +1 -1
  162. package/src/{domain/intent → intent}/middleware/rate-limit.ts +1 -1
  163. package/src/{application/intent/pipeline-runner.ts → intent/pipeline.ts} +3 -2
  164. package/src/intent/policy.ts +46 -0
  165. package/src/{application/intent → intent}/request.ts +14 -34
  166. package/src/{application/intent → intent}/router.ts +12 -49
  167. package/src/kernel/client.ts +33 -0
  168. package/src/kernel/credential.ts +78 -0
  169. package/src/kernel/delegated.ts +49 -0
  170. package/src/{application/windowing/token-refresh.ts → kernel/delegation/refresh.ts} +2 -2
  171. package/src/{adapters/kernel-client.adapter.ts → kernel/session.ts} +26 -33
  172. package/src/message/ctrl.ts +25 -0
  173. package/src/{domain/message/errors.ts → message/error.ts} +8 -0
  174. package/src/message/intent.ts +98 -0
  175. package/src/message/message.ts +11 -0
  176. package/src/shell/access.ts +26 -0
  177. package/src/shell/build.ts +95 -0
  178. package/src/shell/config.ts +32 -0
  179. package/src/shell/create.ts +9 -0
  180. package/src/{application/windowing/child-init.ts → shell/sandboxed/boot.ts} +10 -11
  181. package/src/shell/sandboxed/guarded.ts +32 -0
  182. package/src/shell/sandboxed/pending.ts +52 -0
  183. package/src/shell/sandboxed/sandboxed.ts +131 -0
  184. package/src/shell/shell.ts +37 -0
  185. package/src/shell/standalone.ts +97 -0
  186. package/src/{domain/window/config.ts → window/capabilities.ts} +2 -2
  187. package/src/{ports/shell-adapter.ts → window/embed/adapter.ts} +2 -1
  188. package/src/{adapters/iframe.shell-adapter.ts → window/embed/iframe.ts} +2 -2
  189. package/src/{application/windowing/lifecycle-controller.ts → window/lifecycle/states.ts} +3 -2
  190. package/src/{domain/window/lifecycle.ts → window/lifecycle/transition.ts} +2 -2
  191. package/src/window/mount/close.ts +111 -0
  192. package/src/window/mount/credential.ts +101 -0
  193. package/src/{application/windowing → window/mount}/handshake.ts +3 -2
  194. package/src/window/mount/mount.ts +185 -0
  195. package/src/window/mount/params.ts +64 -0
  196. package/src/window/mount/plain.ts +68 -0
  197. package/src/{domain/window → window}/window.ts +1 -1
  198. package/dist/adapters/iframe.shell-adapter.d.ts.map +0 -1
  199. package/dist/adapters/kernel-client.adapter.d.ts.map +0 -1
  200. package/dist/adapters/message-port.transport.d.ts.map +0 -1
  201. package/dist/application/channels/children-channel.d.ts.map +0 -1
  202. package/dist/application/channels/observer.d.ts.map +0 -1
  203. package/dist/application/channels/parent-channel.d.ts.map +0 -1
  204. package/dist/application/channels/types.d.ts +0 -12
  205. package/dist/application/channels/types.d.ts.map +0 -1
  206. package/dist/application/intent/pipeline-runner.d.ts.map +0 -1
  207. package/dist/application/intent/request.d.ts.map +0 -1
  208. package/dist/application/intent/router.d.ts +0 -56
  209. package/dist/application/intent/router.d.ts.map +0 -1
  210. package/dist/application/kernel-facade.d.ts +0 -33
  211. package/dist/application/kernel-facade.d.ts.map +0 -1
  212. package/dist/application/kernel-facade.js +0 -77
  213. package/dist/application/shell.d.ts +0 -100
  214. package/dist/application/shell.d.ts.map +0 -1
  215. package/dist/application/shell.js +0 -256
  216. package/dist/application/windowing/child-init.d.ts.map +0 -1
  217. package/dist/application/windowing/handshake.d.ts.map +0 -1
  218. package/dist/application/windowing/lifecycle-controller.d.ts.map +0 -1
  219. package/dist/application/windowing/mount-controller.d.ts.map +0 -1
  220. package/dist/application/windowing/mount-controller.js +0 -277
  221. package/dist/application/windowing/protocol.d.ts.map +0 -1
  222. package/dist/application/windowing/token-refresh.d.ts.map +0 -1
  223. package/dist/domain/identity/delegation.d.ts.map +0 -1
  224. package/dist/domain/identity/path.d.ts +0 -11
  225. package/dist/domain/identity/path.d.ts.map +0 -1
  226. package/dist/domain/identity/path.js +0 -13
  227. package/dist/domain/identity/resolve-self.d.ts +0 -21
  228. package/dist/domain/identity/resolve-self.d.ts.map +0 -1
  229. package/dist/domain/identity/resolve-self.js +0 -36
  230. package/dist/domain/intent/middleware/capabilities.d.ts.map +0 -1
  231. package/dist/domain/intent/middleware/logging.d.ts.map +0 -1
  232. package/dist/domain/intent/middleware/rate-limit.d.ts.map +0 -1
  233. package/dist/domain/intent/pipeline.d.ts +0 -3
  234. package/dist/domain/intent/pipeline.d.ts.map +0 -1
  235. package/dist/domain/intent/router.d.ts +0 -6
  236. package/dist/domain/intent/router.d.ts.map +0 -1
  237. package/dist/domain/message/errors.d.ts +0 -2
  238. package/dist/domain/message/errors.d.ts.map +0 -1
  239. package/dist/domain/message/registries.d.ts.map +0 -1
  240. package/dist/domain/message/types.d.ts +0 -30
  241. package/dist/domain/message/types.d.ts.map +0 -1
  242. package/dist/domain/window/config.d.ts.map +0 -1
  243. package/dist/domain/window/lifecycle.d.ts.map +0 -1
  244. package/dist/domain/window/window.d.ts.map +0 -1
  245. package/dist/ports/kernel-client.d.ts +0 -33
  246. package/dist/ports/kernel-client.d.ts.map +0 -1
  247. package/dist/ports/shell-adapter.d.ts.map +0 -1
  248. package/dist/ports/transport.d.ts +0 -7
  249. package/dist/ports/transport.d.ts.map +0 -1
  250. package/src/application/kernel-facade.ts +0 -143
  251. package/src/application/shell.ts +0 -433
  252. package/src/application/windowing/mount-controller.ts +0 -335
  253. package/src/domain/identity/path.ts +0 -14
  254. package/src/domain/identity/resolve-self.ts +0 -38
  255. package/src/domain/intent/pipeline.ts +0 -3
  256. package/src/domain/intent/router.ts +0 -6
  257. package/src/domain/message/registries.ts +0 -76
  258. package/src/domain/message/types.ts +0 -32
  259. package/src/ports/kernel-client.ts +0 -32
  260. /package/dist/{application/channels/children-channel.js → channel/children.js} +0 -0
  261. /package/dist/{application/channels/types.js → channel/listeners.js} +0 -0
  262. /package/dist/{adapters/message-port.transport.js → channel/message-port.js} +0 -0
  263. /package/dist/{application/channels → channel}/observer.js +0 -0
  264. /package/dist/{ports → channel}/transport.js +0 -0
  265. /package/dist/{domain/intent → intent}/middleware/capabilities.js +0 -0
  266. /package/dist/{domain/intent → intent}/middleware/logging.d.ts +0 -0
  267. /package/dist/{domain/intent → intent}/middleware/logging.js +0 -0
  268. /package/dist/{domain/intent → intent}/middleware/rate-limit.js +0 -0
  269. /package/dist/{application/intent/pipeline-runner.js → intent/pipeline.js} +0 -0
  270. /package/dist/{domain/intent/pipeline.js → kernel/client.js} +0 -0
  271. /package/dist/{domain/identity/delegation.js → kernel/delegation/token.js} +0 -0
  272. /package/dist/{domain/intent/router.js → message/ctrl.js} +0 -0
  273. /package/dist/{domain/message/errors.js → message/error.js} +0 -0
  274. /package/dist/{application/windowing/protocol.js → message/init.js} +0 -0
  275. /package/dist/{domain/message/registries.js → message/intent.js} +0 -0
  276. /package/dist/{domain/message/types.js → message/message.js} +0 -0
  277. /package/dist/{domain/window → shell}/config.js +0 -0
  278. /package/dist/{domain/window/window.js → shell/shell.js} +0 -0
  279. /package/dist/{ports/kernel-client.js → window/capabilities.js} +0 -0
  280. /package/dist/{ports/shell-adapter.js → window/embed/adapter.js} +0 -0
  281. /package/dist/{adapters/iframe.shell-adapter.js → window/embed/iframe.js} +0 -0
  282. /package/dist/{application/windowing → window/mount}/handshake.d.ts +0 -0
  283. /package/src/{domain/identity/delegation.ts → kernel/delegation/token.ts} +0 -0
  284. /package/src/{application/windowing/protocol.ts → message/init.ts} +0 -0
package/src/index.ts CHANGED
@@ -1,103 +1,95 @@
1
- // ─── domain/message ─────────────────────────────────────────────────────────
2
- export type { ErrorCode } from './domain/message/errors'
3
- export type { IntentRegistry, CtrlRegistry, ViewRef } from './domain/message/registries'
1
+ // ─── message ────────────────────────────────────────────────────────────────
4
2
  export type {
5
- ShellMessage,
6
- IntentMessage,
3
+ IntentRegistry,
4
+ ViewRef,
5
+ PayloadOf,
6
+ ReplyOf,
7
7
  IntentEnvelope,
8
- CtrlMessage,
9
- ErrorMessage,
10
- } from './domain/message/types'
11
-
12
- // ─── domain/window ──────────────────────────────────────────────────────────
13
- export type { WindowConfig, WindowCapabilities, SandboxProfile } from './domain/window/config'
14
- export type { Window, WindowState } from './domain/window/window'
15
- export { transition as lifecycleTransition } from './domain/window/lifecycle'
16
- export type { LifecycleEvent, TransitionResult } from './domain/window/lifecycle'
17
-
18
- // ─── domain/intent ──────────────────────────────────────────────────────────
19
- export type { IntentMiddleware } from './domain/intent/pipeline'
20
- export type { IntentRouter } from './domain/intent/router'
21
- export { loggingMiddleware } from './domain/intent/middleware/logging'
22
- export type { LoggingConfig, LoggingEntry, LoggingSink } from './domain/intent/middleware/logging'
23
- export { capabilitiesMiddleware } from './domain/intent/middleware/capabilities'
24
- export type {
25
- CapabilitiesConfig,
26
- CapabilityLookup,
27
- CapabilityViolation,
28
- } from './domain/intent/middleware/capabilities'
29
- export { rateLimitMiddleware } from './domain/intent/middleware/rate-limit'
30
- export type { RateLimitConfig, RateLimitViolation } from './domain/intent/middleware/rate-limit'
8
+ IntentMessage,
9
+ } from './message/intent'
10
+ export type { CtrlRegistry, CtrlMessage } from './message/ctrl'
11
+ export type { ErrorCode, ErrorMessage } from './message/error'
12
+ export type { ShellMessage, MessageHandler } from './message/message'
13
+ export {
14
+ INIT_REQUEST_TYPE,
15
+ INIT_RESPONSE_TYPE,
16
+ isInitRequest,
17
+ isInitResponse,
18
+ } from './message/init'
19
+ export type { InitRequestMessage, InitResponseMessage } from './message/init'
31
20
 
32
- // ─── domain/identity ────────────────────────────────────────────────────────
33
- export type { DelegationScope, DelegationToken, TokenState } from './domain/identity/delegation'
34
- export { stateOf, isExpired } from './domain/identity/delegation'
21
+ // ─── kernel ─────────────────────────────────────────────────────────────────
22
+ export type { KernelClient } from './kernel/client'
23
+ export { createKernelClientAdapter } from './kernel/session'
24
+ export type { KernelClientAdapter, CreateKernelClientAdapterOpts } from './kernel/session'
25
+ export type { DelegationScope, DelegationToken, TokenState } from './kernel/delegation/token'
26
+ export { stateOf, isExpired } from './kernel/delegation/token'
27
+ export { createTokenRefresher } from './kernel/delegation/refresh'
28
+ export type { TokenRefreshConfig, TokenRefresher } from './kernel/delegation/refresh'
35
29
 
36
- // ─── ports ──────────────────────────────────────────────────────────────────
37
- export type { Transport } from './ports/transport'
38
- export type { ShellAdapter, WindowHandle } from './ports/shell-adapter'
39
- export type { KernelClient } from './ports/kernel-client'
30
+ // ─── channel ────────────────────────────────────────────────────────────────
31
+ export type { Transport } from './channel/transport'
32
+ export { createMessagePortTransport } from './channel/message-port'
33
+ export type { MessagePortTransportConfig } from './channel/message-port'
34
+ export type { ParentChannel } from './channel/parent'
35
+ export type { ChildrenChannel } from './channel/children'
36
+ export type { MessageDirection, ObserverHandler } from './channel/observer'
40
37
 
41
- // ─── adapters ───────────────────────────────────────────────────────────────
42
- export { createKernelClientAdapter } from './adapters/kernel-client.adapter'
38
+ // ─── window ─────────────────────────────────────────────────────────────────
39
+ export type { Window, WindowState } from './window/window'
40
+ export type { WindowConfig, WindowCapabilities, SandboxProfile } from './window/capabilities'
41
+ export { transition as lifecycleTransition } from './window/lifecycle/transition'
42
+ export type { LifecycleEvent, TransitionResult } from './window/lifecycle/transition'
43
+ export type { ShellAdapter, WindowHandle } from './window/embed/adapter'
44
+ export { createIframeShellAdapter } from './window/embed/iframe'
45
+ export type { IframeShellAdapterConfig } from './window/embed/iframe'
43
46
  export type {
44
- KernelClientAdapter,
45
- CreateKernelClientAdapterOpts,
46
- } from './adapters/kernel-client.adapter'
47
- export { createMessagePortTransport } from './adapters/message-port.transport'
48
- export type { MessagePortTransportConfig } from './adapters/message-port.transport'
49
- export { createIframeShellAdapter } from './adapters/iframe.shell-adapter'
50
- export type { IframeShellAdapterConfig } from './adapters/iframe.shell-adapter'
51
-
52
- // ─── application ────────────────────────────────────────────────────────────
53
- export type {
54
- Shell,
55
- ShellConfig,
56
- StandaloneConfig,
57
- SandboxedConfig,
58
47
  MountParams,
48
+ MountCredential,
59
49
  MountedWindow,
60
50
  CloseResult,
61
- ParentChannel,
62
- ChildrenChannel,
63
- MessageDirection,
64
- MessageHandler,
65
- ObserverHandler,
66
- } from './application/shell'
67
- export { createShell } from './application/shell'
68
-
69
- // ─── application/windowing (advanced / testing) ─────────────────────────────
70
- export { runParentHandshake } from './application/windowing/handshake'
71
- export type {
72
- HandshakeParams,
73
- HandshakeError,
74
- HandshakeResult,
75
- } from './application/windowing/handshake'
76
- export { performChildInit } from './application/windowing/child-init'
77
- export type { ChildInitParams, ChildInitResult } from './application/windowing/child-init'
78
- export { createTokenRefresher } from './application/windowing/token-refresh'
79
- export type { TokenRefreshConfig, TokenRefresher } from './application/windowing/token-refresh'
51
+ } from './window/mount/params'
52
+ export { runParentHandshake } from './window/mount/handshake'
53
+ export type { HandshakeParams, HandshakeError, HandshakeResult } from './window/mount/handshake'
80
54
 
81
- // ─── application/intent (advanced / testing) ────────────────────────────────
82
- export { createIntentPipeline } from './application/intent/pipeline-runner'
83
- export type { IntentPipeline } from './application/intent/pipeline-runner'
84
- export { createIntentRouter } from './application/intent/router'
55
+ // ─── intent ─────────────────────────────────────────────────────────────────
56
+ export { createIntentPipeline } from './intent/pipeline'
57
+ export type { IntentMiddleware, IntentPipeline } from './intent/pipeline'
58
+ export type { IntentDecision, IntentOrigin, IntentPolicy, IntentContext } from './intent/policy'
59
+ export { createIntentRouter } from './intent/router'
85
60
  export type {
61
+ IntentRouter,
86
62
  IntentRouterController,
87
63
  IntentRouterConfig,
88
- IntentDecision,
89
- IntentOrigin,
90
- IntentPolicy,
91
- IntentContext,
92
64
  LocalIntentHandler,
93
- } from './application/intent/router'
94
- export { requestIntent, replyToIntent, requestAccess } from './application/intent/request'
65
+ } from './intent/router'
66
+ export { requestIntent, replyToIntent } from './intent/request'
67
+ export { loggingMiddleware } from './intent/middleware/logging'
68
+ export type { LoggingConfig, LoggingEntry, LoggingSink } from './intent/middleware/logging'
69
+ export { capabilitiesMiddleware } from './intent/middleware/capabilities'
70
+ export type {
71
+ CapabilitiesConfig,
72
+ CapabilityLookup,
73
+ CapabilityViolation,
74
+ } from './intent/middleware/capabilities'
75
+ export { rateLimitMiddleware } from './intent/middleware/rate-limit'
76
+ export type { RateLimitConfig, RateLimitViolation } from './intent/middleware/rate-limit'
95
77
 
96
- // ─── Init-request protocol (shared with host pages) ─────────────────────────
97
- export {
98
- INIT_REQUEST_TYPE,
99
- INIT_RESPONSE_TYPE,
100
- isInitRequest,
101
- isInitResponse,
102
- } from './application/windowing/protocol'
103
- export type { InitRequestMessage, InitResponseMessage } from './application/windowing/protocol'
78
+ // ─── application (OS plane: shell.user / .spaces / .apps) ───────────────────
79
+ export { createOsNamespaces } from './application/namespaces'
80
+ export type { OsNamespaces, CreateOsNamespacesDeps } from './application/namespaces'
81
+ export type { UserNamespace, UserNode, RoleNode } from './application/user'
82
+ export type { SpacesNamespace, SpaceNode } from './application/spaces'
83
+ export type { AppsNamespace, ApplicationNode } from './application/apps'
84
+ export { openAppSession } from './application/session/open'
85
+ export type { OpenAppSessionDeps } from './application/session/open'
86
+ export { AppSessionRefreshError } from './application/session/session'
87
+ export type { AppSession, AppView, RefreshStep } from './application/session/session'
88
+
89
+ // ─── shell ──────────────────────────────────────────────────────────────────
90
+ export { createShell } from './shell/create'
91
+ export type { Shell } from './shell/shell'
92
+ export type { ShellConfig, StandaloneConfig, SandboxedConfig } from './shell/config'
93
+ export { requestAccess } from './shell/access'
94
+ export { performChildInit } from './shell/sandboxed/boot'
95
+ export type { ChildInitParams, ChildInitResult } from './shell/sandboxed/boot'
@@ -1,6 +1,5 @@
1
- import type { IntentRegistry } from '../../message/registries'
2
- import type { IntentMessage } from '../../message/types'
3
- import type { WindowCapabilities } from '../../window/config'
1
+ import type { IntentMessage, IntentRegistry } from '../../message/intent'
2
+ import type { WindowCapabilities } from '../../window/capabilities'
4
3
  import type { IntentMiddleware } from '../pipeline'
5
4
 
6
5
  export type CapabilityLookup = (sender: string) => WindowCapabilities | undefined
@@ -1,4 +1,4 @@
1
- import type { IntentMessage } from '../../message/types'
1
+ import type { IntentMessage } from '../../message/intent'
2
2
  import type { IntentMiddleware } from '../pipeline'
3
3
 
4
4
  export type LoggingSink = (entry: LoggingEntry) => void
@@ -1,4 +1,4 @@
1
- import type { IntentMessage } from '../../message/types'
1
+ import type { IntentMessage } from '../../message/intent'
2
2
  import type { IntentMiddleware } from '../pipeline'
3
3
 
4
4
  export type RateLimitKey = (message: IntentMessage) => string
@@ -1,5 +1,6 @@
1
- import type { IntentMiddleware } from '../../domain/intent/pipeline'
2
- import type { IntentMessage } from '../../domain/message/types'
1
+ import type { IntentMessage } from '../message/intent'
2
+
3
+ export type IntentMiddleware = (message: IntentMessage, next: () => Promise<void>) => Promise<void>
3
4
 
4
5
  export interface IntentPipeline {
5
6
  use(middleware: IntentMiddleware): void
@@ -0,0 +1,46 @@
1
+ import type { IntentMessage, IntentRegistry } from '../message/intent'
2
+ import type { Window } from '../window/window'
3
+
4
+ /**
5
+ * Decision produced by a routing policy: where an inbound intent should go.
6
+ *
7
+ * - `local`: the shell (entry point or sandboxed parent) handles it itself.
8
+ * - `parent`: forward upstream (only valid for sandboxed children).
9
+ * - `child`: forward to a specific child window.
10
+ * - `drop`: discard silently (e.g., handled fully by a middleware).
11
+ */
12
+ export type IntentDecision<K extends keyof IntentRegistry = keyof IntentRegistry> =
13
+ | { kind: 'local'; message: IntentMessage<K> }
14
+ | { kind: 'parent'; message: IntentMessage<K> }
15
+ | { kind: 'child'; windowId: string; message: IntentMessage<K> }
16
+ | { kind: 'drop' }
17
+
18
+ export type IntentOrigin = 'parent' | 'child' | 'self'
19
+
20
+ export type IntentPolicy = (
21
+ message: IntentMessage,
22
+ ctx: IntentContext,
23
+ ) => IntentDecision | Promise<IntentDecision>
24
+
25
+ export interface IntentContext {
26
+ readonly selfWindowId: string
27
+ readonly origin: IntentOrigin
28
+ readonly windows: ReadonlyMap<string, Window>
29
+ readonly hasParent: boolean
30
+ }
31
+
32
+ /**
33
+ * Default policy:
34
+ * - intent arrives from a child → handle locally
35
+ * - intent arrives from the parent → handle locally
36
+ * - intent initiated locally (self) → send up to parent if we have one,
37
+ * otherwise keep it local
38
+ */
39
+ export function defaultPolicy(): IntentPolicy {
40
+ return (message, ctx) => {
41
+ if (ctx.origin === 'self') {
42
+ return ctx.hasParent ? { kind: 'parent', message } : { kind: 'local', message }
43
+ }
44
+ return { kind: 'local', message }
45
+ }
46
+ }
@@ -1,10 +1,6 @@
1
- import { NO_PERMS } from '@astrale-os/kernel-core/permissions'
2
-
3
- import type { IntentRegistry } from '../../domain/message/registries'
4
- import type { IntentMessage } from '../../domain/message/types'
5
- import type { ChildrenChannel } from '../channels/children-channel'
6
- import type { ParentChannel } from '../channels/parent-channel'
7
- import type { Shell } from '../shell'
1
+ import type { ChildrenChannel } from '../channel/children'
2
+ import type { ParentChannel } from '../channel/parent'
3
+ import type { IntentMessage, IntentRegistry, PayloadOf, ReplyOf } from '../message/intent'
8
4
 
9
5
  /**
10
6
  * Request/reply over the otherwise fire-and-forget intent transport.
@@ -22,22 +18,26 @@ import type { Shell } from '../shell'
22
18
  export function requestIntent<K extends keyof IntentRegistry>(
23
19
  parent: ParentChannel,
24
20
  name: K,
25
- payload: IntentRegistry[K]['payload'],
26
- ): Promise<IntentRegistry[K]['response']> {
21
+ payload: PayloadOf<K>,
22
+ ): Promise<ReplyOf<K>> {
27
23
  const correlationId = crypto.randomUUID()
28
24
  return new Promise((resolve) => {
29
25
  const off = parent.on('intent', (message) => {
30
26
  if (message.envelope.name !== 'intentReply') return
31
- const reply = message.envelope.payload as IntentRegistry['intentReply']['payload']
27
+ const reply = message.envelope.payload as PayloadOf<'intentReply'>
32
28
  if (reply.correlationId !== correlationId) return
33
29
  off()
34
- resolve(reply.result as IntentRegistry[K]['response'])
30
+ resolve(reply.result as ReplyOf<K>)
35
31
  })
36
- parent.send({
32
+ // `PayloadOf<K>` is a deferred conditional TS can't reconcile with the
33
+ // `ShellMessage` union across a generic `K`; the payload is exact, so assert
34
+ // the concrete message shape.
35
+ const message: IntentMessage<K> = {
37
36
  type: 'intent',
38
37
  version: 1,
39
38
  envelope: { name, payload, sender: { windowId: 'self' }, correlationId },
40
- })
39
+ }
40
+ parent.send(message as IntentMessage)
41
41
  })
42
42
  }
43
43
 
@@ -51,7 +51,7 @@ export function replyToIntent<K extends keyof IntentRegistry>(
51
51
  children: ChildrenChannel,
52
52
  windowId: string,
53
53
  request: IntentMessage<K>,
54
- result: IntentRegistry[K]['response'],
54
+ result: ReplyOf<K>,
55
55
  ): void {
56
56
  const correlationId = request.envelope.correlationId
57
57
  if (!correlationId) return
@@ -65,23 +65,3 @@ export function replyToIntent<K extends keyof IntentRegistry>(
65
65
  },
66
66
  })
67
67
  }
68
-
69
- /**
70
- * View SDK convenience: ask the user (via the root shell) to grant `perms` on
71
- * `node` to `identity`. Resolves with the bitmask actually granted (0 if the
72
- * user declined or there was no parent to ask). The view typically passes its
73
- * own identity (from `whoami`) as `identity`.
74
- */
75
- export function requestAccess(
76
- shell: Shell,
77
- opts: IntentRegistry['requestAccess']['payload'],
78
- ): Promise<IntentRegistry['requestAccess']['response']> {
79
- if (!shell.parent) return Promise.resolve({ granted: false, perms: NO_PERMS })
80
- // A sandboxed shell's `parent` is a proxy that throws until `init()` resolves;
81
- // honour the documented "no parent to ask" fallback instead of surfacing that
82
- // opaque rejection to the caller.
83
- return requestIntent(shell.parent, 'requestAccess', opts).catch(() => ({
84
- granted: false,
85
- perms: NO_PERMS,
86
- }))
87
- }
@@ -1,36 +1,15 @@
1
- import type { IntentRegistry } from '../../domain/message/registries'
2
- import type { IntentMessage } from '../../domain/message/types'
3
- import type { Window } from '../../domain/window/window'
4
- import type { ChildrenChannelController } from '../channels/children-channel'
5
- import type { ParentChannel } from '../channels/parent-channel'
6
- import type { IntentPipeline } from './pipeline-runner'
7
-
8
- /**
9
- * Decision produced by a routing policy: where an inbound intent should go.
10
- *
11
- * - `local`: the shell (entry point or sandboxed parent) handles it itself.
12
- * - `parent`: forward upstream (only valid for sandboxed children).
13
- * - `child`: forward to a specific child window.
14
- * - `drop`: discard silently (e.g., handled fully by a middleware).
15
- */
16
- export type IntentDecision<K extends keyof IntentRegistry = keyof IntentRegistry> =
17
- | { kind: 'local'; message: IntentMessage<K> }
18
- | { kind: 'parent'; message: IntentMessage<K> }
19
- | { kind: 'child'; windowId: string; message: IntentMessage<K> }
20
- | { kind: 'drop' }
21
-
22
- export type IntentOrigin = 'parent' | 'child' | 'self'
23
-
24
- export type IntentPolicy = (
25
- message: IntentMessage,
26
- ctx: IntentContext,
27
- ) => IntentDecision | Promise<IntentDecision>
28
-
29
- export interface IntentContext {
30
- readonly selfWindowId: string
31
- readonly origin: IntentOrigin
32
- readonly windows: ReadonlyMap<string, Window>
33
- readonly hasParent: boolean
1
+ import type { ChildrenChannelController } from '../channel/children'
2
+ import type { ParentChannel } from '../channel/parent'
3
+ import type { IntentMessage, IntentRegistry } from '../message/intent'
4
+ import type { Window } from '../window/window'
5
+ import type { IntentPipeline } from './pipeline'
6
+ import type { IntentDecision, IntentOrigin, IntentPolicy } from './policy'
7
+
8
+ import { defaultPolicy } from './policy'
9
+
10
+ /** Minimal dispatch-only router surface (no current in-package implementer). */
11
+ export interface IntentRouter {
12
+ dispatch<K extends keyof IntentRegistry>(message: IntentMessage<K>): Promise<void>
34
13
  }
35
14
 
36
15
  export type LocalIntentHandler<K extends keyof IntentRegistry = keyof IntentRegistry> = (
@@ -61,22 +40,6 @@ export type IntentRouterConfig = {
61
40
  windows: ReadonlyMap<string, Window>
62
41
  }
63
42
 
64
- /**
65
- * Default policy:
66
- * - intent arrives from a child → handle locally
67
- * - intent arrives from the parent → handle locally
68
- * - intent initiated locally (self) → send up to parent if we have one,
69
- * otherwise keep it local
70
- */
71
- function defaultPolicy(): IntentPolicy {
72
- return (message, ctx) => {
73
- if (ctx.origin === 'self') {
74
- return ctx.hasParent ? { kind: 'parent', message } : { kind: 'local', message }
75
- }
76
- return { kind: 'local', message }
77
- }
78
- }
79
-
80
43
  /** Return a copy of `message` with a trusted `sender.windowId`. */
81
44
  function withSender(message: IntentMessage, windowId: string): IntentMessage {
82
45
  return { ...message, envelope: { ...message.envelope, sender: { windowId } } }
@@ -0,0 +1,33 @@
1
+ import type { FnMap } from '@astrale-os/kernel-client'
2
+ import type { BoundClientSessionView } from '@astrale-os/kernel-client/session'
3
+
4
+ /**
5
+ * The shell's kernel handle — the kernel-client `BoundClientSessionView` bound
6
+ * to this shell's credential. The bound view IS the surface: the graph sugar
7
+ * (`.get/.node/.children/.query/.mutate/…` over the two kernel doors), dispatch
8
+ * (`.call/.stream/.as/…`) and the `auth` control plane
9
+ * (`.auth.mint/.credential/.whoami/…`). The extras below are the deprecated
10
+ * iframe ABI, kept working until Views adopt `.auth.*`.
11
+ */
12
+ export type KernelClient = BoundClientSessionView<FnMap> & {
13
+ /**
14
+ * @deprecated iframe ABI — use `shell.kernel.auth.mint()`. Despite the name,
15
+ * mints an *identity* credential for the current principal (v1 misnomer).
16
+ */
17
+ mintDelegation(): Promise<string>
18
+ /**
19
+ * @deprecated iframe ABI — use `shell.kernel.auth.credential()`. The current
20
+ * JWT for a raw `fetch()`; auto-refreshed, so read fresh per request.
21
+ */
22
+ authToken(): string
23
+ /**
24
+ * Kernel envelope endpoint this shell talks to. In same-origin GUI shells this
25
+ * may be the resolved `/api/` route; direct instance/dev shells usually pass a
26
+ * full instance endpoint such as `https://example.eu.astrale.ai/api/`.
27
+ *
28
+ * Worker REST routes are different audiences. Do not assume `url` is the right
29
+ * target for a raw stream just because the source credential came from the
30
+ * kernel.
31
+ */
32
+ readonly url: string
33
+ }
@@ -0,0 +1,78 @@
1
+ import type { KernelClient } from './client'
2
+ import type { KernelClientAdapter } from './session'
3
+
4
+ export type KernelFacadeConfig = {
5
+ adapter: KernelClientAdapter
6
+ credential?: string
7
+ getCredential?: () => string
8
+ /** Kernel URL — exposed to consumers via `KernelClient.url`. */
9
+ url: string
10
+ /**
11
+ * Explicit identity node to use as the mint subject. When omitted, the mint
12
+ * resolves the AUTHENTICATED caller via `whoami` (so a cookie-fronted GUI mints
13
+ * as the logged-in user, not the kernel root). Set this only to pin a subject.
14
+ */
15
+ mintIdentity?: string
16
+ }
17
+
18
+ export interface KernelFacadeController extends KernelClient {
19
+ dispose(): void
20
+ }
21
+
22
+ export function createKernelFacade(config: KernelFacadeConfig): KernelFacadeController {
23
+ const getCredential =
24
+ config.getCredential ??
25
+ (() => {
26
+ if (config.credential === undefined) {
27
+ throw new Error('KernelFacade requires credential or getCredential')
28
+ }
29
+ return config.credential
30
+ })
31
+ return buildCredentialFacade({
32
+ adapter: config.adapter,
33
+ getCredential,
34
+ url: config.url,
35
+ mintIdentity: config.mintIdentity,
36
+ })
37
+ }
38
+
39
+ export type FacadeParams = {
40
+ adapter: KernelClientAdapter
41
+ getCredential: () => string
42
+ url: string
43
+ /** Explicit mint subject. When omitted, the authenticated caller is resolved via `whoami`. */
44
+ mintIdentity?: string
45
+ }
46
+
47
+ /**
48
+ * Bind the unified kernel surface to a credential thunk and attach the shell
49
+ * extras. The bound view IS the kernel surface (`.get/.node/.query/.mutate/
50
+ * .call/…` plus the `auth` control plane), credential-bound via `getCredential`
51
+ * (invoked per dispatch); `mintDelegation`/`authToken`/`url` layer on top as
52
+ * the deprecated iframe-ABI aliases over the view's `auth` namespace.
53
+ */
54
+ export function buildCredentialFacade(params: FacadeParams): KernelFacadeController {
55
+ const { adapter, getCredential, mintIdentity, url } = params
56
+ const view = adapter.boundView(getCredential)
57
+
58
+ // @deprecated iframe ABI — use `shell.kernel.auth.mint()`. Mints an identity
59
+ // credential for the pinned `mintIdentity`, else the whoami-resolved caller.
60
+ // No implicit `__system__` fallback — an unresolved principal throws rather
61
+ // than silently minting a child credential as kernel root.
62
+ async function mintDelegation(): Promise<string> {
63
+ return view.auth.mint(mintIdentity !== undefined ? { subject: mintIdentity } : undefined)
64
+ }
65
+
66
+ // @deprecated iframe ABI — use `shell.kernel.auth.credential()`. Shell
67
+ // credentials are JWT strings; decode the `Uint8Array` arm defensively.
68
+ function authToken(): string {
69
+ const credential = view.auth.credential()
70
+ return typeof credential === 'string' ? credential : new TextDecoder().decode(credential)
71
+ }
72
+
73
+ function dispose() {
74
+ // adapter lifetime is owned by the caller
75
+ }
76
+
77
+ return Object.assign(view, { mintDelegation, authToken, url, dispose })
78
+ }
@@ -0,0 +1,49 @@
1
+ import type { KernelFacadeController } from './credential'
2
+ import type { DelegationToken } from './delegation/token'
3
+ import type { KernelClientAdapter } from './session'
4
+
5
+ import { buildCredentialFacade } from './credential'
6
+
7
+ export type DelegationKernelFacadeConfig = {
8
+ adapter: KernelClientAdapter
9
+ initialToken: DelegationToken
10
+ url: string
11
+ onTokenChange?: (token: DelegationToken) => void
12
+ mintIdentity?: string
13
+ }
14
+
15
+ export interface DelegationKernelFacadeController extends KernelFacadeController {
16
+ token(): DelegationToken
17
+ setToken(next: DelegationToken): void
18
+ }
19
+
20
+ /** The sandboxed-mode kernel: bound to a delegation token the parent refreshes. */
21
+ export function createDelegationKernelFacade(
22
+ config: DelegationKernelFacadeConfig,
23
+ ): DelegationKernelFacadeController {
24
+ let token = config.initialToken
25
+ const base = buildCredentialFacade({
26
+ adapter: config.adapter,
27
+ getCredential: () => token.credential,
28
+ url: config.url,
29
+ mintIdentity: config.mintIdentity,
30
+ })
31
+
32
+ return {
33
+ ...base,
34
+ token() {
35
+ return token
36
+ },
37
+ setToken(next) {
38
+ if (next.credential === token.credential && next.expiresAt === token.expiresAt) return
39
+ token = next
40
+ config.onTokenChange?.(next)
41
+ },
42
+ // The delegation facade owns its adapter exclusively (created per child in
43
+ // `performChildInit`), so disposing it must tear the adapter down — unlike
44
+ // the standalone facade, where the caller owns the adapter's lifetime.
45
+ dispose() {
46
+ config.adapter.disconnect()
47
+ },
48
+ }
49
+ }
@@ -1,6 +1,6 @@
1
- import type { DelegationToken } from '../../domain/identity/delegation'
1
+ import type { DelegationToken } from './token'
2
2
 
3
- import { REFRESH_WINDOW_MS } from '../../domain/identity/delegation'
3
+ import { REFRESH_WINDOW_MS } from './token'
4
4
 
5
5
  export type TokenRefreshConfig = {
6
6
  readonly token: () => DelegationToken