@astrale-os/kernel-client 0.2.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 (257) hide show
  1. package/dist/client/batch.d.ts +26 -0
  2. package/dist/client/batch.d.ts.map +1 -0
  3. package/dist/client/batch.js +8 -0
  4. package/dist/client/batch.js.map +1 -0
  5. package/dist/client/bound.d.ts +27 -0
  6. package/dist/client/bound.d.ts.map +1 -0
  7. package/dist/client/bound.js +14 -0
  8. package/dist/client/bound.js.map +1 -0
  9. package/dist/client/client.d.ts +93 -0
  10. package/dist/client/client.d.ts.map +1 -0
  11. package/dist/client/client.js +393 -0
  12. package/dist/client/client.js.map +1 -0
  13. package/dist/client/config.d.ts +112 -0
  14. package/dist/client/config.d.ts.map +1 -0
  15. package/dist/client/config.js +10 -0
  16. package/dist/client/config.js.map +1 -0
  17. package/dist/client/fn-map.d.ts +61 -0
  18. package/dist/client/fn-map.d.ts.map +1 -0
  19. package/dist/client/fn-map.js +2 -0
  20. package/dist/client/fn-map.js.map +1 -0
  21. package/dist/client/freeze.d.ts +32 -0
  22. package/dist/client/freeze.d.ts.map +1 -0
  23. package/dist/client/freeze.js +42 -0
  24. package/dist/client/freeze.js.map +1 -0
  25. package/dist/client/hooks.d.ts +49 -0
  26. package/dist/client/hooks.d.ts.map +1 -0
  27. package/dist/client/hooks.js +2 -0
  28. package/dist/client/hooks.js.map +1 -0
  29. package/dist/client/index.d.ts +7 -0
  30. package/dist/client/index.d.ts.map +1 -0
  31. package/dist/client/index.js +2 -0
  32. package/dist/client/index.js.map +1 -0
  33. package/dist/delegation/cache.d.ts +133 -0
  34. package/dist/delegation/cache.d.ts.map +1 -0
  35. package/dist/delegation/cache.js +258 -0
  36. package/dist/delegation/cache.js.map +1 -0
  37. package/dist/delegation/errors.d.ts +44 -0
  38. package/dist/delegation/errors.d.ts.map +1 -0
  39. package/dist/delegation/errors.js +62 -0
  40. package/dist/delegation/errors.js.map +1 -0
  41. package/dist/delegation/index.d.ts +6 -0
  42. package/dist/delegation/index.d.ts.map +1 -0
  43. package/dist/delegation/index.js +4 -0
  44. package/dist/delegation/index.js.map +1 -0
  45. package/dist/delegation/policy.d.ts +175 -0
  46. package/dist/delegation/policy.d.ts.map +1 -0
  47. package/dist/delegation/policy.js +109 -0
  48. package/dist/delegation/policy.js.map +1 -0
  49. package/dist/errors/errors.d.ts +103 -0
  50. package/dist/errors/errors.d.ts.map +1 -0
  51. package/dist/errors/errors.js +170 -0
  52. package/dist/errors/errors.js.map +1 -0
  53. package/dist/errors/index.d.ts +4 -0
  54. package/dist/errors/index.d.ts.map +1 -0
  55. package/dist/errors/index.js +3 -0
  56. package/dist/errors/index.js.map +1 -0
  57. package/dist/errors/session-error.d.ts +21 -0
  58. package/dist/errors/session-error.d.ts.map +1 -0
  59. package/dist/errors/session-error.js +25 -0
  60. package/dist/errors/session-error.js.map +1 -0
  61. package/dist/index.d.ts +17 -0
  62. package/dist/index.d.ts.map +1 -0
  63. package/dist/index.js +10 -0
  64. package/dist/index.js.map +1 -0
  65. package/dist/pacer/batcher.d.ts +11 -0
  66. package/dist/pacer/batcher.d.ts.map +1 -0
  67. package/dist/pacer/batcher.js +15 -0
  68. package/dist/pacer/batcher.js.map +1 -0
  69. package/dist/pacer/defaults.d.ts +18 -0
  70. package/dist/pacer/defaults.d.ts.map +1 -0
  71. package/dist/pacer/defaults.js +18 -0
  72. package/dist/pacer/defaults.js.map +1 -0
  73. package/dist/pacer/index.d.ts +10 -0
  74. package/dist/pacer/index.d.ts.map +1 -0
  75. package/dist/pacer/index.js +11 -0
  76. package/dist/pacer/index.js.map +1 -0
  77. package/dist/pacer/queue.d.ts +11 -0
  78. package/dist/pacer/queue.d.ts.map +1 -0
  79. package/dist/pacer/queue.js +15 -0
  80. package/dist/pacer/queue.js.map +1 -0
  81. package/dist/pacer/rate-limiter.d.ts +11 -0
  82. package/dist/pacer/rate-limiter.d.ts.map +1 -0
  83. package/dist/pacer/rate-limiter.js +15 -0
  84. package/dist/pacer/rate-limiter.js.map +1 -0
  85. package/dist/pacer/retry.d.ts +14 -0
  86. package/dist/pacer/retry.d.ts.map +1 -0
  87. package/dist/pacer/retry.js +50 -0
  88. package/dist/pacer/retry.js.map +1 -0
  89. package/dist/persistence/index.d.ts +3 -0
  90. package/dist/persistence/index.d.ts.map +1 -0
  91. package/dist/persistence/index.js +2 -0
  92. package/dist/persistence/index.js.map +1 -0
  93. package/dist/persistence/persistence.d.ts +52 -0
  94. package/dist/persistence/persistence.d.ts.map +1 -0
  95. package/dist/persistence/persistence.js +32 -0
  96. package/dist/persistence/persistence.js.map +1 -0
  97. package/dist/pool/errors.d.ts +13 -0
  98. package/dist/pool/errors.d.ts.map +1 -0
  99. package/dist/pool/errors.js +16 -0
  100. package/dist/pool/errors.js.map +1 -0
  101. package/dist/pool/index.d.ts +4 -0
  102. package/dist/pool/index.d.ts.map +1 -0
  103. package/dist/pool/index.js +3 -0
  104. package/dist/pool/index.js.map +1 -0
  105. package/dist/pool/pool.d.ts +63 -0
  106. package/dist/pool/pool.d.ts.map +1 -0
  107. package/dist/pool/pool.js +87 -0
  108. package/dist/pool/pool.js.map +1 -0
  109. package/dist/redirect/errors.d.ts +45 -0
  110. package/dist/redirect/errors.d.ts.map +1 -0
  111. package/dist/redirect/errors.js +52 -0
  112. package/dist/redirect/errors.js.map +1 -0
  113. package/dist/redirect/index.d.ts +4 -0
  114. package/dist/redirect/index.d.ts.map +1 -0
  115. package/dist/redirect/index.js +3 -0
  116. package/dist/redirect/index.js.map +1 -0
  117. package/dist/redirect/policy.d.ts +79 -0
  118. package/dist/redirect/policy.d.ts.map +1 -0
  119. package/dist/redirect/policy.js +69 -0
  120. package/dist/redirect/policy.js.map +1 -0
  121. package/dist/schema/call-args.d.ts +6 -0
  122. package/dist/schema/call-args.d.ts.map +1 -0
  123. package/dist/schema/call-args.js +21 -0
  124. package/dist/schema/call-args.js.map +1 -0
  125. package/dist/schema/class-proxy.d.ts +8 -0
  126. package/dist/schema/class-proxy.d.ts.map +1 -0
  127. package/dist/schema/class-proxy.js +38 -0
  128. package/dist/schema/class-proxy.js.map +1 -0
  129. package/dist/schema/extract.d.ts +9 -0
  130. package/dist/schema/extract.d.ts.map +1 -0
  131. package/dist/schema/extract.js +16 -0
  132. package/dist/schema/extract.js.map +1 -0
  133. package/dist/schema/from-entries.d.ts +12 -0
  134. package/dist/schema/from-entries.d.ts.map +1 -0
  135. package/dist/schema/from-entries.js +39 -0
  136. package/dist/schema/from-entries.js.map +1 -0
  137. package/dist/schema/index.d.ts +11 -0
  138. package/dist/schema/index.d.ts.map +1 -0
  139. package/dist/schema/index.js +9 -0
  140. package/dist/schema/index.js.map +1 -0
  141. package/dist/schema/node-proxy.d.ts +9 -0
  142. package/dist/schema/node-proxy.d.ts.map +1 -0
  143. package/dist/schema/node-proxy.js +32 -0
  144. package/dist/schema/node-proxy.js.map +1 -0
  145. package/dist/schema/proxy-types.d.ts +112 -0
  146. package/dist/schema/proxy-types.d.ts.map +1 -0
  147. package/dist/schema/proxy-types.js +2 -0
  148. package/dist/schema/proxy-types.js.map +1 -0
  149. package/dist/schema/registry.d.ts +51 -0
  150. package/dist/schema/registry.d.ts.map +1 -0
  151. package/dist/schema/registry.js +111 -0
  152. package/dist/schema/registry.js.map +1 -0
  153. package/dist/schema/resolve.d.ts +26 -0
  154. package/dist/schema/resolve.d.ts.map +1 -0
  155. package/dist/schema/resolve.js +27 -0
  156. package/dist/schema/resolve.js.map +1 -0
  157. package/dist/schema/typed-client.d.ts +10 -0
  158. package/dist/schema/typed-client.d.ts.map +1 -0
  159. package/dist/schema/typed-client.js +26 -0
  160. package/dist/schema/typed-client.js.map +1 -0
  161. package/dist/schema/types.d.ts +9 -0
  162. package/dist/schema/types.d.ts.map +1 -0
  163. package/dist/schema/types.js +2 -0
  164. package/dist/schema/types.js.map +1 -0
  165. package/dist/session/bound.d.ts +11 -0
  166. package/dist/session/bound.d.ts.map +1 -0
  167. package/dist/session/bound.js +24 -0
  168. package/dist/session/bound.js.map +1 -0
  169. package/dist/session/client-session.d.ts +61 -0
  170. package/dist/session/client-session.d.ts.map +1 -0
  171. package/dist/session/client-session.js +635 -0
  172. package/dist/session/client-session.js.map +1 -0
  173. package/dist/session/config.d.ts +157 -0
  174. package/dist/session/config.d.ts.map +1 -0
  175. package/dist/session/config.js +2 -0
  176. package/dist/session/config.js.map +1 -0
  177. package/dist/session/errors/index.d.ts +6 -0
  178. package/dist/session/errors/index.d.ts.map +1 -0
  179. package/dist/session/errors/index.js +8 -0
  180. package/dist/session/errors/index.js.map +1 -0
  181. package/dist/session/errors/session-errors.d.ts +52 -0
  182. package/dist/session/errors/session-errors.d.ts.map +1 -0
  183. package/dist/session/errors/session-errors.js +70 -0
  184. package/dist/session/errors/session-errors.js.map +1 -0
  185. package/dist/session/forward.d.ts +14 -0
  186. package/dist/session/forward.d.ts.map +1 -0
  187. package/dist/session/forward.js +44 -0
  188. package/dist/session/forward.js.map +1 -0
  189. package/dist/session/helpers.d.ts +23 -0
  190. package/dist/session/helpers.d.ts.map +1 -0
  191. package/dist/session/helpers.js +56 -0
  192. package/dist/session/helpers.js.map +1 -0
  193. package/dist/session/hooks.d.ts +140 -0
  194. package/dist/session/hooks.d.ts.map +1 -0
  195. package/dist/session/hooks.js +2 -0
  196. package/dist/session/hooks.js.map +1 -0
  197. package/dist/session/index.d.ts +6 -0
  198. package/dist/session/index.d.ts.map +1 -0
  199. package/dist/session/index.js +3 -0
  200. package/dist/session/index.js.map +1 -0
  201. package/dist/session/types.d.ts +38 -0
  202. package/dist/session/types.d.ts.map +1 -0
  203. package/dist/session/types.js +2 -0
  204. package/dist/session/types.js.map +1 -0
  205. package/dist/transport/binary.d.ts +15 -0
  206. package/dist/transport/binary.d.ts.map +1 -0
  207. package/dist/transport/binary.js +2 -0
  208. package/dist/transport/binary.js.map +1 -0
  209. package/dist/transport/contract.d.ts +58 -0
  210. package/dist/transport/contract.d.ts.map +1 -0
  211. package/dist/transport/contract.js +11 -0
  212. package/dist/transport/contract.js.map +1 -0
  213. package/dist/transport/fetch.d.ts +28 -0
  214. package/dist/transport/fetch.d.ts.map +1 -0
  215. package/dist/transport/fetch.js +74 -0
  216. package/dist/transport/fetch.js.map +1 -0
  217. package/dist/transport/http-envelope.d.ts +49 -0
  218. package/dist/transport/http-envelope.d.ts.map +1 -0
  219. package/dist/transport/http-envelope.js +405 -0
  220. package/dist/transport/http-envelope.js.map +1 -0
  221. package/dist/transport/http-routed.d.ts +61 -0
  222. package/dist/transport/http-routed.d.ts.map +1 -0
  223. package/dist/transport/http-routed.js +409 -0
  224. package/dist/transport/http-routed.js.map +1 -0
  225. package/dist/transport/index.d.ts +8 -0
  226. package/dist/transport/index.d.ts.map +1 -0
  227. package/dist/transport/index.js +6 -0
  228. package/dist/transport/index.js.map +1 -0
  229. package/dist/transport/request-id.d.ts +9 -0
  230. package/dist/transport/request-id.d.ts.map +1 -0
  231. package/dist/transport/request-id.js +12 -0
  232. package/dist/transport/request-id.js.map +1 -0
  233. package/dist/transport/ws-envelope.d.ts +74 -0
  234. package/dist/transport/ws-envelope.d.ts.map +1 -0
  235. package/dist/transport/ws-envelope.js +560 -0
  236. package/dist/transport/ws-envelope.js.map +1 -0
  237. package/dist/util/race-signal.d.ts +12 -0
  238. package/dist/util/race-signal.d.ts.map +1 -0
  239. package/dist/util/race-signal.js +34 -0
  240. package/dist/util/race-signal.js.map +1 -0
  241. package/dist/wire/controller.d.ts +38 -0
  242. package/dist/wire/controller.d.ts.map +1 -0
  243. package/dist/wire/controller.js +38 -0
  244. package/dist/wire/controller.js.map +1 -0
  245. package/dist/wire/index.d.ts +7 -0
  246. package/dist/wire/index.d.ts.map +1 -0
  247. package/dist/wire/index.js +4 -0
  248. package/dist/wire/index.js.map +1 -0
  249. package/dist/wire/meta.d.ts +81 -0
  250. package/dist/wire/meta.d.ts.map +1 -0
  251. package/dist/wire/meta.js +44 -0
  252. package/dist/wire/meta.js.map +1 -0
  253. package/dist/wire/sse.d.ts +67 -0
  254. package/dist/wire/sse.d.ts.map +1 -0
  255. package/dist/wire/sse.js +170 -0
  256. package/dist/wire/sse.js.map +1 -0
  257. package/package.json +104 -0
@@ -0,0 +1,157 @@
1
+ import type { CredentialInput } from '@astrale-os/kernel-core';
2
+ import type { SelfIdentityExpr, UnresolvedIdentityExpr } from '@astrale-os/kernel-core/expression';
3
+ import type { ClientLogger, Protocol, CallTransport } from '../client/config';
4
+ import type { FnMap } from '../client/fn-map';
5
+ import type { DelegationCache, DelegationCacheConfig } from '../delegation/cache';
6
+ import type { DelegationPolicy } from '../delegation/policy';
7
+ import type { SchemaPersistence } from '../persistence/persistence';
8
+ import type { ClientPool, ClientPoolConfig } from '../pool/pool';
9
+ import type { RedirectPolicy } from '../redirect/policy';
10
+ import type { SchemaRegistry } from '../schema/registry';
11
+ import type { FunctionSchema } from '../schema/types';
12
+ import type { ClientSessionHooks } from './hooks';
13
+ /**
14
+ * Picker shape — either a static credential, a sync function, or an
15
+ * async function. `typeof identity === 'function'` is the discriminator.
16
+ * ClientSession calls the function on every `session.call` that doesn't override
17
+ * via `opts.credential`.
18
+ */
19
+ export type IdentityInput = CredentialInput | (() => CredentialInput | Promise<CredentialInput>) | (() => undefined | Promise<undefined>);
20
+ export type ClientSessionConfig<M extends FnMap = FnMap> = {
21
+ /** Default kernel URL used when `ClientSessionCallOptions.url` is absent — mandatory (§4.3). */
22
+ default: string;
23
+ /**
24
+ * Identity picker. Accepts a function (sync or async), a static
25
+ * credential value (for per-invocation tools), or `undefined`
26
+ * (callers must supply `opts.credential` on every call).
27
+ */
28
+ identity?: IdentityInput;
29
+ /**
30
+ * Redirect policy. If `undefined`, every redirect is followed
31
+ * (equivalent to `allowAllPolicy()`). Consumers who want to gate
32
+ * redirects pass `allowlistPolicy` / `promptPolicy` / `strictPolicy`.
33
+ */
34
+ redirect?: RedirectPolicy;
35
+ /**
36
+ * Maximum redirect hops (default 3). The (maxHops+1)-th hop throws
37
+ * `HopLimitExceededError`. Per-call override via `ClientSessionCallOptions.maxHops`.
38
+ */
39
+ maxHops?: number;
40
+ /**
41
+ * Delegation cache. If `undefined`, cross-audience dispatches (direct-dial
42
+ * to non-default, redirect to non-default) dispatch with the base credential —
43
+ * the kernel likely rejects, and a plain `AuthenticationError` surfaces.
44
+ */
45
+ delegation?: DelegationCacheConfig | DelegationCache;
46
+ /**
47
+ * Delegation policy — audience + scope derivation + consent. When
48
+ * `undefined`, ClientSession uses `allowAllDelegations({ default: config.default })`
49
+ * which returns `origin` for any target whose origin differs from the
50
+ * default's origin, and implicitly allows all mints.
51
+ */
52
+ delegationPolicy?: DelegationPolicy;
53
+ /**
54
+ * Client pool. Always present internally (§4.4). If `undefined`, ClientSession
55
+ * constructs a default `ClientPool` with `maxSize: 32` and a default
56
+ * `clientFactory` that constructs `KernelClient` bound to the shared
57
+ * `SchemaRegistry`.
58
+ */
59
+ pool?: ClientPoolConfig<M> | ClientPool<M>;
60
+ /**
61
+ * Custom `fetch` forwarded to the default `clientFactory`'s `KernelClient`s
62
+ * — the wire-layer shim seam. Use it to wrap requests (e.g. a same-origin
63
+ * wrapper that adds `credentials:'include'` and refresh-on-401 for a
64
+ * cookie-fronted SPA). Ignored when a custom `pool`/`clientFactory` is
65
+ * supplied (those own their own wiring). Default: global fetch.
66
+ */
67
+ fetch?: typeof fetch;
68
+ /**
69
+ * Schema persistence adapter. If `undefined`, the registry lives
70
+ * in-memory for the ClientSession's lifetime.
71
+ */
72
+ schemaStore?: SchemaPersistence;
73
+ /**
74
+ * Preloaded schemas OR an external `SchemaRegistry`. Precedence with
75
+ * `schemaStore` pinned in §7.3.
76
+ */
77
+ schema?: FunctionSchema[] | SchemaRegistry;
78
+ /** Orchestration-level hooks, composed with but not wrapping ClientHooks (§12.1). */
79
+ hooks?: ClientSessionHooks;
80
+ /** Logger for hook-failure diagnostics and orchestration-internal warnings. */
81
+ logger?: ClientLogger;
82
+ };
83
+ export type ClientSessionCallOptions = {
84
+ /** Per-call timeout override (ms). Applies to every hop independently. */
85
+ timeout?: number;
86
+ /** Abort signal — propagates to every hop of a redirect follow chain. */
87
+ signal?: AbortSignal;
88
+ /** Class context for instance-method schema resolution (same as client). */
89
+ class?: string;
90
+ /**
91
+ * Per-call URL override. Redirect follow-ups use the redirection's
92
+ * URL, NOT this override.
93
+ */
94
+ url?: string;
95
+ /**
96
+ * Per-call transport override (`'http' | 'ws'`). Hop-1 only; subsequent
97
+ * hops pick their transport from the schema of the new target.
98
+ */
99
+ transport?: CallTransport;
100
+ /**
101
+ * Per-call protocol override (`'envelope' | 'auto'`). `'auto'` uses
102
+ * the schema's `RouteBinding` when present and the transport is HTTP,
103
+ * else envelope. Hop-1 only.
104
+ */
105
+ protocol?: Protocol;
106
+ /**
107
+ * Caller-provided correlation id. If absent, ClientSession generates one and
108
+ * threads it through every hop, hook ctx, and thrown error.
109
+ */
110
+ correlationId?: string;
111
+ /**
112
+ * Per-call credential override. Skips the picker for this call only.
113
+ */
114
+ credential?: CredentialInput;
115
+ /**
116
+ * Per-call delegation-expression override. When the call's target
117
+ * requires a delegation (§11.4), this `UnresolvedIdentityExpr` is passed
118
+ * to the mint instead of `DelegationPolicy.delegationFor`'s output.
119
+ * `undefined` = defer to policy; the kernel-core builder exports
120
+ * `scopedSelf(scopes)` for the common "narrow self-delegation" case.
121
+ */
122
+ delegation?: UnresolvedIdentityExpr;
123
+ /**
124
+ * Per-call attestation override. Carried into the mint's outer envelope
125
+ * unchanged. `undefined` = defer to `DelegationPolicy.attestationFor`;
126
+ * if that is also absent, the mint omits the attestation param and the
127
+ * kernel adapter defaults it to `{ kind: 'identity', self: true }`.
128
+ */
129
+ attestation?: SelfIdentityExpr;
130
+ /**
131
+ * Per-call delegation bypass. When `true`, ClientSession skips the entire
132
+ * pre-dispatch delegation block (§8.1 step ④) — `audienceFor` is NOT
133
+ * called, no mint fires, no policy consent runs. The base credential
134
+ * (`opts.credential` or the picker) dispatches as-is on every hop.
135
+ *
136
+ * Use when the host holds a credential it knows is valid for the target
137
+ * audience (external bearer, pre-minted delegation, test fixture)
138
+ * without the policy wrapping it in another delegation. `opts.delegation`
139
+ * / `opts.attestation` are ignored when this is `true` — the bypass is
140
+ * total.
141
+ */
142
+ skipDelegation?: boolean;
143
+ /**
144
+ * Per-call hop cap override. `0` = refuse any redirect. `N >= 1` =
145
+ * follow up to N. `undefined` = use `ClientSessionConfig.maxHops`.
146
+ */
147
+ maxHops?: number;
148
+ /**
149
+ * Target-of-call ref for instance-method dispatch (e.g. `@<nodeId>`
150
+ * or `/path/to/node`). Forwarded as `KernelRequest.self` on the
151
+ * outbound envelope — sibling of params, never merged into them.
152
+ * Set by the CLI when rewriting `@<id>::method` and propagated
153
+ * across redirect hops via `CallRedirection.self`.
154
+ */
155
+ self?: string;
156
+ };
157
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/session/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAA;AAElG,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAC7E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AACjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAC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;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;;OAGG;IACH,SAAS,CAAC,EAAE,aAAa,CAAA;IACzB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,UAAU,CAAC,EAAE,eAAe,CAAA;IAC5B;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,sBAAsB,CAAA;IACnC;;;;;OAKG;IACH,WAAW,CAAC,EAAE,gBAAgB,CAAA;IAC9B;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/session/config.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ export { IdentityPickerError, PersistenceLoadFailedError, RegistryWriteFailedError, SchemaOwnershipConflictError, UnresolvedIdentityError, } from './session-errors';
2
+ export { ClientSessionError } from '../../errors/session-error';
3
+ export { DelegationMintError, DelegationPolicyError, DelegationRefusedError, } from '../../delegation/errors';
4
+ export { PoolClosedError } from '../../pool/errors';
5
+ export { HopLimitExceededError, RedirectPolicyError, RedirectRefusedError, } from '../../redirect/errors';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/session/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,wBAAwB,EACxB,4BAA4B,EAC5B,uBAAuB,GACxB,MAAM,kBAAkB,CAAA;AAIzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,uBAAuB,CAAA"}
@@ -0,0 +1,8 @@
1
+ export { IdentityPickerError, PersistenceLoadFailedError, RegistryWriteFailedError, SchemaOwnershipConflictError, UnresolvedIdentityError, } from './session-errors';
2
+ // Re-exports so consumers catching every ClientSession-thrown shape have one
3
+ // import surface — each still ships from its owning subpath.
4
+ export { ClientSessionError } from '../../errors/session-error';
5
+ export { DelegationMintError, DelegationPolicyError, DelegationRefusedError, } from '../../delegation/errors';
6
+ export { PoolClosedError } from '../../pool/errors';
7
+ export { HopLimitExceededError, RedirectPolicyError, RedirectRefusedError, } from '../../redirect/errors';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/session/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,wBAAwB,EACxB,4BAA4B,EAC5B,uBAAuB,GACxB,MAAM,kBAAkB,CAAA;AAEzB,6EAA6E;AAC7E,6DAA6D;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,uBAAuB,CAAA"}
@@ -0,0 +1,52 @@
1
+ import { ClientSessionError } from '../../errors/session-error';
2
+ /**
3
+ * No credential could be resolved for a call.
4
+ *
5
+ * Thrown when `ClientSessionCallOptions.credential` is absent, the identity
6
+ * picker returned `undefined`, or the bound-view captured credential is
7
+ * unresolvable.
8
+ */
9
+ export declare class UnresolvedIdentityError extends ClientSessionError {
10
+ constructor(message?: string);
11
+ }
12
+ /**
13
+ * The identity picker function threw.
14
+ *
15
+ * Wraps the original error as `cause`. Consumers that want to surface
16
+ * a sign-in prompt typically switch on `UnresolvedIdentityError` and
17
+ * this class together.
18
+ */
19
+ export declare class IdentityPickerError extends ClientSessionError {
20
+ constructor(options?: ErrorOptions);
21
+ }
22
+ /**
23
+ * A schema learned on redirect was rejected by the registry's
24
+ * contract-drift check.
25
+ *
26
+ * Wraps the registry's error as `cause`. The current hop's schema
27
+ * disagrees with a previously-registered shape for the same ref —
28
+ * either a misconfigured kernel or an incompatible version.
29
+ */
30
+ export declare class RegistryWriteFailedError extends ClientSessionError {
31
+ readonly ref: string;
32
+ constructor(ref: string, options?: ErrorOptions);
33
+ }
34
+ /**
35
+ * Caller passed both a pre-built `SchemaRegistry` and a `SchemaPersistence`
36
+ * adapter. ClientSession refuses to wire persistence onto a caller-owned registry
37
+ * to avoid double-writes or ordering corruption — wire persistence yourself
38
+ * or let ClientSession construct the registry.
39
+ */
40
+ export declare class SchemaOwnershipConflictError extends ClientSessionError {
41
+ constructor();
42
+ }
43
+ /**
44
+ * `SchemaPersistence.load()` threw during ClientSession construction.
45
+ *
46
+ * Wraps the adapter's error as `cause`. ClientSession aborts construction
47
+ * rather than proceed with a half-loaded registry.
48
+ */
49
+ export declare class PersistenceLoadFailedError extends ClientSessionError {
50
+ constructor(options?: ErrorOptions);
51
+ }
52
+ //# sourceMappingURL=session-errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-errors.d.ts","sourceRoot":"","sources":["../../../src/session/errors/session-errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAE/D;;;;;;GAMG;AACH,qBAAa,uBAAwB,SAAQ,kBAAkB;IAC7D,YAAY,OAAO,SAAyC,EAG3D;CACF;AAED;;;;;;GAMG;AACH,qBAAa,mBAAoB,SAAQ,kBAAkB;IACzD,YAAY,OAAO,CAAC,EAAE,YAAY,EAGjC;CACF;AAED;;;;;;;GAOG;AACH,qBAAa,wBAAyB,SAAQ,kBAAkB;aAE5C,GAAG,EAAE,MAAM;IAD7B,YACkB,GAAG,EAAE,MAAM,EAC3B,OAAO,CAAC,EAAE,YAAY,EAIvB;CACF;AAED;;;;;GAKG;AACH,qBAAa,4BAA6B,SAAQ,kBAAkB;IAClE,cAQC;CACF;AAED;;;;;GAKG;AACH,qBAAa,0BAA2B,SAAQ,kBAAkB;IAChE,YAAY,OAAO,CAAC,EAAE,YAAY,EAGjC;CACF"}
@@ -0,0 +1,70 @@
1
+ import { ClientSessionError } from '../../errors/session-error';
2
+ /**
3
+ * No credential could be resolved for a call.
4
+ *
5
+ * Thrown when `ClientSessionCallOptions.credential` is absent, the identity
6
+ * picker returned `undefined`, or the bound-view captured credential is
7
+ * unresolvable.
8
+ */
9
+ export class UnresolvedIdentityError extends ClientSessionError {
10
+ constructor(message = 'No credential resolved for this call') {
11
+ super(message, 'IDENTITY_UNRESOLVED');
12
+ this.name = 'UnresolvedIdentityError';
13
+ }
14
+ }
15
+ /**
16
+ * The identity picker function threw.
17
+ *
18
+ * Wraps the original error as `cause`. Consumers that want to surface
19
+ * a sign-in prompt typically switch on `UnresolvedIdentityError` and
20
+ * this class together.
21
+ */
22
+ export class IdentityPickerError extends ClientSessionError {
23
+ constructor(options) {
24
+ super('Identity picker threw', 'IDENTITY_PICKER_THREW', options);
25
+ this.name = 'IdentityPickerError';
26
+ }
27
+ }
28
+ /**
29
+ * A schema learned on redirect was rejected by the registry's
30
+ * contract-drift check.
31
+ *
32
+ * Wraps the registry's error as `cause`. The current hop's schema
33
+ * disagrees with a previously-registered shape for the same ref —
34
+ * either a misconfigured kernel or an incompatible version.
35
+ */
36
+ export class RegistryWriteFailedError extends ClientSessionError {
37
+ ref;
38
+ constructor(ref, options) {
39
+ super(`Registry write failed for "${ref}"`, 'REGISTRY_WRITE_FAILED', options);
40
+ this.ref = ref;
41
+ this.name = 'RegistryWriteFailedError';
42
+ }
43
+ }
44
+ /**
45
+ * Caller passed both a pre-built `SchemaRegistry` and a `SchemaPersistence`
46
+ * adapter. ClientSession refuses to wire persistence onto a caller-owned registry
47
+ * to avoid double-writes or ordering corruption — wire persistence yourself
48
+ * or let ClientSession construct the registry.
49
+ */
50
+ export class SchemaOwnershipConflictError extends ClientSessionError {
51
+ constructor() {
52
+ super('ClientSessionConfig.schema (SchemaRegistry) is incompatible with ClientSessionConfig.schemaStore. ' +
53
+ 'Pass only the registry and wire persistence yourself, or pass only schemaStore + ' +
54
+ 'let ClientSession construct the registry.', 'SCHEMA_OWNERSHIP_CONFLICT');
55
+ this.name = 'SchemaOwnershipConflictError';
56
+ }
57
+ }
58
+ /**
59
+ * `SchemaPersistence.load()` threw during ClientSession construction.
60
+ *
61
+ * Wraps the adapter's error as `cause`. ClientSession aborts construction
62
+ * rather than proceed with a half-loaded registry.
63
+ */
64
+ export class PersistenceLoadFailedError extends ClientSessionError {
65
+ constructor(options) {
66
+ super('SchemaPersistence.load() threw', 'PERSISTENCE_LOAD_FAILED', options);
67
+ this.name = 'PersistenceLoadFailedError';
68
+ }
69
+ }
70
+ //# sourceMappingURL=session-errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-errors.js","sourceRoot":"","sources":["../../../src/session/errors/session-errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAE/D;;;;;;GAMG;AACH,MAAM,OAAO,uBAAwB,SAAQ,kBAAkB;IAC7D,YAAY,OAAO,GAAG,sCAAsC;QAC1D,KAAK,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAA;QACrC,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAA;IACvC,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,OAAO,mBAAoB,SAAQ,kBAAkB;IACzD,YAAY,OAAsB;QAChC,KAAK,CAAC,uBAAuB,EAAE,uBAAuB,EAAE,OAAO,CAAC,CAAA;QAChE,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAA;IACnC,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,OAAO,wBAAyB,SAAQ,kBAAkB;IAE5C,GAAG;IADrB,YACkB,GAAW,EAC3B,OAAsB;QAEtB,KAAK,CAAC,8BAA8B,GAAG,GAAG,EAAE,uBAAuB,EAAE,OAAO,CAAC,CAAA;mBAH7D,GAAG;QAInB,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAA;IACxC,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,4BAA6B,SAAQ,kBAAkB;IAClE;QACE,KAAK,CACH,oGAAoG;YAClG,mFAAmF;YACnF,2CAA2C,EAC7C,2BAA2B,CAC5B,CAAA;QACD,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAA;IAC5C,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,0BAA2B,SAAQ,kBAAkB;IAChE,YAAY,OAAsB;QAChC,KAAK,CAAC,gCAAgC,EAAE,yBAAyB,EAAE,OAAO,CAAC,CAAA;QAC3E,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAA;IAC1C,CAAC;CACF"}
@@ -0,0 +1,14 @@
1
+ import type { CallOptions } from '../client/config';
2
+ import type { ClientSessionCallOptions } from './config';
3
+ /**
4
+ * Assemble the `CallOptions` forwarded to `client.send` for one hop.
5
+ * Per-hop fields (timeout/signal/class/self) forward every hop. The `url` is
6
+ * hop-specific: hop 0 uses the caller's `opts.url`; redirect follow-ups use
7
+ * `redirectTarget` (the URL the kernel redirected to), so the per-request URL
8
+ * builder retargets verbatim instead of falling back to the schema binding.
9
+ * transport/protocol stay hop-0-only — follow-ups pick them from the new
10
+ * target's schema. `credential`, `maxHops`, `correlationId` are consumed by
11
+ * ClientSession itself and not forwarded here.
12
+ */
13
+ export declare function forwardedFor(opts: ClientSessionCallOptions | undefined, hopIndex: number, redirectTarget?: string): CallOptions;
14
+ //# sourceMappingURL=forward.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forward.d.ts","sourceRoot":"","sources":["../../src/session/forward.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAA;AAExD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,wBAAwB,GAAG,SAAS,EAC1C,QAAQ,EAAE,MAAM,EAChB,cAAc,CAAC,EAAE,MAAM,GACtB,WAAW,CA0Bb"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Assemble the `CallOptions` forwarded to `client.send` for one hop.
3
+ * Per-hop fields (timeout/signal/class/self) forward every hop. The `url` is
4
+ * hop-specific: hop 0 uses the caller's `opts.url`; redirect follow-ups use
5
+ * `redirectTarget` (the URL the kernel redirected to), so the per-request URL
6
+ * builder retargets verbatim instead of falling back to the schema binding.
7
+ * transport/protocol stay hop-0-only — follow-ups pick them from the new
8
+ * target's schema. `credential`, `maxHops`, `correlationId` are consumed by
9
+ * ClientSession itself and not forwarded here.
10
+ */
11
+ export function forwardedFor(opts, hopIndex, redirectTarget) {
12
+ const out = {};
13
+ if (!opts) {
14
+ // No caller opts, but a redirect follow-up still needs its target on the wire.
15
+ if (hopIndex > 0 && redirectTarget !== undefined)
16
+ out.url = redirectTarget;
17
+ return out;
18
+ }
19
+ if (opts.timeout !== undefined)
20
+ out.timeout = opts.timeout;
21
+ if (opts.signal !== undefined)
22
+ out.signal = opts.signal;
23
+ if (opts.class !== undefined)
24
+ out.class = opts.class;
25
+ // `self` forwards every hop; `redirection.self` replaces it on follow.
26
+ if (opts.self !== undefined)
27
+ out.self = opts.self;
28
+ if (hopIndex === 0) {
29
+ if (opts.url !== undefined)
30
+ out.url = opts.url;
31
+ if (opts.transport !== undefined)
32
+ out.transport = opts.transport;
33
+ if (opts.protocol !== undefined)
34
+ out.protocol = opts.protocol;
35
+ }
36
+ else if (redirectTarget !== undefined) {
37
+ // Redirect-resolved endpoint (path + placeholders intact) → dial verbatim.
38
+ // http-envelope `targetFor` only appends a trailing slash to a server root
39
+ // (the kernel envelope, hop 0); a worker route URL must be dialed as-is.
40
+ out.url = redirectTarget;
41
+ }
42
+ return out;
43
+ }
44
+ //# sourceMappingURL=forward.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forward.js","sourceRoot":"","sources":["../../src/session/forward.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,MAAM,UAAU,YAAY,CAC1B,IAA0C,EAC1C,QAAgB,EAChB,cAAuB;IAEvB,MAAM,GAAG,GAAgB,EAAE,CAAA;IAC3B,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,+EAA+E;QAC/E,IAAI,QAAQ,GAAG,CAAC,IAAI,cAAc,KAAK,SAAS;YAAE,GAAG,CAAC,GAAG,GAAG,cAAc,CAAA;QAC1E,OAAO,GAAG,CAAA;IACZ,CAAC;IAED,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS;QAAE,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;IAC1D,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS;QAAE,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;IACvD,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS;QAAE,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;IACpD,uEAAuE;IACvE,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS;QAAE,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;IAEjD,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;QACnB,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS;YAAE,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAA;QAC9C,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS;YAAE,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAA;QAChE,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS;YAAE,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;IAC/D,CAAC;SAAM,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;QACxC,2EAA2E;QAC3E,2EAA2E;QAC3E,yEAAyE;QACzE,GAAG,CAAC,GAAG,GAAG,cAAc,CAAA;IAC1B,CAAC;IAED,OAAO,GAAG,CAAA;AACZ,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { CallRedirection } from '@astrale-os/kernel-api';
2
+ import type { ClientSessionErrorCtx } from './hooks';
3
+ /**
4
+ * Unwrap a successful `SendResult` / `SendStreamResult` / `SendBinaryResult`
5
+ * to the post-orchestration shape ClientSession hands back to the caller. Redirect
6
+ * results are handled on the dispatch loop; passing one here is a bug.
7
+ */
8
+ export declare function unwrapResult(result: {
9
+ kind: 'value' | 'stream' | 'binary' | 'redirect';
10
+ value?: unknown;
11
+ chunks?: unknown;
12
+ response?: unknown;
13
+ redirection?: CallRedirection;
14
+ }): unknown;
15
+ export declare function freezeHops<T>(arr: readonly T[]): ReadonlyArray<T>;
16
+ /** Non-cryptographic correlation id; `sh-` prefix disambiguates from caller-supplied cids. */
17
+ export declare function generateCid(): string;
18
+ /**
19
+ * Map an error to a `ClientSessionErrorCtx.context`. Specific subclasses first,
20
+ * `ClientSessionError` catch-all next, wire `'transport'` last.
21
+ */
22
+ export declare function classifyError(err: unknown): ClientSessionErrorCtx['context'];
23
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/session/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAE7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAiBpD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE;IACnC,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAA;IAChD,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,CAAC,EAAE,eAAe,CAAA;CAC9B,GAAG,OAAO,CAWV;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC,CAEjE;AAED,8FAA8F;AAC9F,wBAAgB,WAAW,IAAI,MAAM,CAGpC;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAY5E"}
@@ -0,0 +1,56 @@
1
+ import { DelegationMintError, DelegationPolicyError, DelegationRefusedError, } from '../delegation/errors';
2
+ import { ClientSessionError } from '../errors/session-error';
3
+ import { PoolClosedError } from '../pool/errors';
4
+ import { RedirectPolicyError } from '../redirect/errors';
5
+ import { IdentityPickerError, PersistenceLoadFailedError, RegistryWriteFailedError, UnresolvedIdentityError, } from './errors/session-errors';
6
+ /**
7
+ * Unwrap a successful `SendResult` / `SendStreamResult` / `SendBinaryResult`
8
+ * to the post-orchestration shape ClientSession hands back to the caller. Redirect
9
+ * results are handled on the dispatch loop; passing one here is a bug.
10
+ */
11
+ export function unwrapResult(result) {
12
+ switch (result.kind) {
13
+ case 'value':
14
+ return result.value;
15
+ case 'stream':
16
+ return result.chunks;
17
+ case 'binary':
18
+ return result.response;
19
+ case 'redirect':
20
+ throw new Error('Unreachable: redirect passed to unwrapResult');
21
+ }
22
+ }
23
+ export function freezeHops(arr) {
24
+ return Object.freeze([...arr]);
25
+ }
26
+ /** Non-cryptographic correlation id; `sh-` prefix disambiguates from caller-supplied cids. */
27
+ export function generateCid() {
28
+ const r = Math.random().toString(36).slice(2, 10);
29
+ return `sh-${Date.now().toString(36)}-${r}`;
30
+ }
31
+ /**
32
+ * Map an error to a `ClientSessionErrorCtx.context`. Specific subclasses first,
33
+ * `ClientSessionError` catch-all next, wire `'transport'` last.
34
+ */
35
+ export function classifyError(err) {
36
+ if (err instanceof RegistryWriteFailedError)
37
+ return 'registry';
38
+ if (err instanceof PersistenceLoadFailedError)
39
+ return 'persistence.load';
40
+ if (err instanceof RedirectPolicyError)
41
+ return 'redirect.policy';
42
+ if (err instanceof DelegationPolicyError)
43
+ return 'delegation.policy';
44
+ if (err instanceof DelegationMintError)
45
+ return 'delegation.mint';
46
+ if (err instanceof DelegationRefusedError)
47
+ return 'delegation.refused';
48
+ if (err instanceof UnresolvedIdentityError || err instanceof IdentityPickerError)
49
+ return 'identity';
50
+ if (err instanceof PoolClosedError)
51
+ return 'session';
52
+ if (err instanceof ClientSessionError)
53
+ return 'session';
54
+ return 'transport';
55
+ }
56
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/session/helpers.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,yBAAyB,CAAA;AAEhC;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,MAM5B;IACC,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,OAAO;YACV,O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O,WAAW,CAAA;AACpB,CAAC"}
@@ -0,0 +1,140 @@
1
+ import type { CallRedirection } from '@astrale-os/kernel-api';
2
+ import type { CredentialInput } from '@astrale-os/kernel-core';
3
+ import type { SelfIdentityExpr, UnresolvedIdentityExpr } from '@astrale-os/kernel-core/expression';
4
+ import type { FunctionSchema } from '../schema/types';
5
+ /** Hop record ClientSession threads through every ctx type. */
6
+ export type ClientSessionHop = {
7
+ url: string;
8
+ at: number;
9
+ };
10
+ /**
11
+ * Ctx for the entry of a top-level `session.call`. Fields are captured
12
+ * *before* any wire I/O — `credential` is the baseCred resolved from
13
+ * the picker or `opts.credential`, not the per-hop delegation.
14
+ */
15
+ export type BeforeCallCtx = {
16
+ method: string;
17
+ params: unknown;
18
+ credential: CredentialInput;
19
+ /** Initial target — may not equal default if `opts.url` was used. */
20
+ url: string;
21
+ correlationId: string;
22
+ maxHops: number;
23
+ };
24
+ /**
25
+ * Ctx for a successful `session.call`. `result` is the unwrapped value
26
+ * the caller received; `hops` is the full chain.
27
+ */
28
+ export type AfterCallCtx = BeforeCallCtx & {
29
+ result: unknown;
30
+ hops: ReadonlyArray<ClientSessionHop>;
31
+ /** Wall-clock ms from `onBeforeCall` firing to this hook firing. */
32
+ durationMs: number;
33
+ };
34
+ /** Ctx for a followed redirect hop transition. */
35
+ export type RedirectFollowCtx = BeforeCallCtx & {
36
+ /** 0-based hop index being departed. */
37
+ fromHop: number;
38
+ fromUrl: string;
39
+ toUrl: string;
40
+ redirection: CallRedirection;
41
+ /** Present if `redirection.schema` was saved to the registry. */
42
+ schemaLearned?: FunctionSchema;
43
+ /** True if a fresh mint happened for this hop (cache miss). */
44
+ delegationMinted: boolean;
45
+ };
46
+ /** Ctx for a refused redirect — symmetric with `RedirectFollowCtx`. */
47
+ export type RedirectRefusedCtx = BeforeCallCtx & {
48
+ fromUrl: string;
49
+ redirection: CallRedirection;
50
+ /** From `RedirectPolicy.decide({ follow: false, reason })`. */
51
+ reason: string;
52
+ };
53
+ /** Ctx for a refused delegation (policy.decide returned `{ allow: false }`). */
54
+ export type DelegationRefusedCtx = BeforeCallCtx & {
55
+ /** URL the delegation would have targeted. */
56
+ target: string;
57
+ /** Audience derived by `DelegationPolicy.audienceFor`. */
58
+ audience: string;
59
+ /** Expression the mint would have carried (pre-refine per §9.3.1). */
60
+ delegation: UnresolvedIdentityExpr;
61
+ /** Outer-envelope attestation the mint would have carried, if any. */
62
+ attestation?: SelfIdentityExpr;
63
+ /** From `DelegationPolicy.decide({ allow: false, reason })`. */
64
+ reason: string;
65
+ };
66
+ /**
67
+ * Ctx for a fresh delegation mint. Does NOT extend `BeforeCallCtx` —
68
+ * a mint can coalesce across N triggering calls, so single-cid fields
69
+ * would lie; see `triggeringCorrelationIds`.
70
+ *
71
+ * `delegation` / `attestation` are post-refine (what was actually minted
72
+ * and keyed in the cache), not the originals from `delegationFor`.
73
+ */
74
+ export type DelegationMintCtx = {
75
+ audience: string;
76
+ /** The `UnresolvedIdentityExpr` the mint actually carried. */
77
+ delegation: UnresolvedIdentityExpr;
78
+ /** The `SelfIdentityExpr` the mint actually carried, if any. */
79
+ attestation?: SelfIdentityExpr;
80
+ /**
81
+ * Correlation id(s) of the call(s) waiting on this mint. When
82
+ * multiple concurrent callers share one mint, every waiter's id
83
+ * appears. First element is the triggering call; remaining elements
84
+ * are callers that joined before resolution.
85
+ *
86
+ * Cross-session limitation: when two ClientSessions share one
87
+ * `DelegationCache` and one of them drives the mint while the other
88
+ * joins the in-flight promise, only the driving ClientSession's waiters
89
+ * appear here. The joining ClientSession's `triggeringCorrelationIds` is
90
+ * empty for that mint. Callers needing mint-correlation across
91
+ * shared caches observe it through the owning ClientSession's hook.
92
+ */
93
+ triggeringCorrelationIds: readonly string[];
94
+ /**
95
+ * Method name of the triggering call — quick filtering helper;
96
+ * per-correlationId methods can be tracked separately.
97
+ */
98
+ triggeringMethod: string;
99
+ /** Wall-clock ms the mint took. */
100
+ durationMs: number;
101
+ /** TTL (seconds) of the minted credential. */
102
+ ttl: number;
103
+ };
104
+ /**
105
+ * Ctx for any error thrown from ClientSession. `context` triages the error
106
+ * source without stack parsing.
107
+ */
108
+ export type ClientSessionErrorCtx = BeforeCallCtx & {
109
+ error: Error;
110
+ hops: ReadonlyArray<ClientSessionHop>;
111
+ context: 'transport' | 'redirect.policy' | 'delegation.policy' | 'delegation.mint' | 'delegation.refused' | 'identity' | 'registry' | 'persistence.load' | 'persistence.save' | 'session';
112
+ };
113
+ /** Ctx for `session.signal` dispatch — fire-and-forget, no result. */
114
+ export type AfterSignalCtx = {
115
+ method: string;
116
+ params: unknown;
117
+ url: string;
118
+ correlationId: string;
119
+ dispatchedAt: number;
120
+ };
121
+ /** Orchestration-layer hook surface. `ClientHooks` still fires per hop. */
122
+ export type ClientSessionHooks = {
123
+ /** Fires once per top-level `session.call`/`stream`/`binary` (NOT per hop). */
124
+ onBeforeCall?: (ctx: BeforeCallCtx) => void | Promise<void>;
125
+ /** Fires once per successful top-level call, after final-hop unwrap. */
126
+ onAfterCall?: (ctx: AfterCallCtx) => void | Promise<void>;
127
+ /** Fires once per redirect actually followed. */
128
+ onRedirectFollow?: (ctx: RedirectFollowCtx) => void | Promise<void>;
129
+ /** Fires once per refused redirect (before the throw). */
130
+ onRedirectRefused?: (ctx: RedirectRefusedCtx) => void | Promise<void>;
131
+ /** Fires once per delegation mint (cache miss). */
132
+ onDelegationMint?: (ctx: DelegationMintCtx) => void | Promise<void>;
133
+ /** Fires once per refused delegation (before the throw). */
134
+ onDelegationRefused?: (ctx: DelegationRefusedCtx) => void | Promise<void>;
135
+ /** Fires on every error thrown from ClientSession. */
136
+ onError?: (ctx: ClientSessionErrorCtx) => void | Promise<void>;
137
+ /** Fires on `session.signal` dispatch. */
138
+ onAfterSignal?: (ctx: AfterSignalCtx) => void | Promise<void>;
139
+ };
140
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/session/hooks.ts"],"names":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