@astrale-os/kernel-client 1.0.0-beta.5 → 1.0.0-beta.50

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 (206) hide show
  1. package/dist/auth/authorization.d.ts +10 -5
  2. package/dist/auth/authorization.js +14 -1
  3. package/dist/auth/index.d.ts +1 -0
  4. package/dist/client/admission.js +3 -1
  5. package/dist/client/client.d.ts +70 -4
  6. package/dist/client/client.js +209 -32
  7. package/dist/client/index.d.ts +3 -3
  8. package/dist/client/index.js +2 -2
  9. package/dist/client/level.d.ts +58 -0
  10. package/dist/client/level.js +159 -0
  11. package/dist/client/request.d.ts +7 -2
  12. package/dist/client/request.js +11 -7
  13. package/dist/client/result.d.ts +14 -1
  14. package/dist/client/result.js +19 -8
  15. package/dist/client/routing-control.d.ts +11 -15
  16. package/dist/client/routing-control.js +21 -29
  17. package/dist/errors/index.d.ts +3 -0
  18. package/dist/errors/index.js +3 -0
  19. package/dist/errors/inexpressible-error.d.ts +23 -0
  20. package/dist/errors/inexpressible-error.js +26 -0
  21. package/dist/errors/query-input.d.ts +47 -0
  22. package/dist/errors/query-input.js +85 -0
  23. package/dist/errors/refusal.d.ts +12 -0
  24. package/dist/errors/refusal.js +44 -6
  25. package/dist/errors/response-too-large-error.d.ts +11 -0
  26. package/dist/errors/response-too-large-error.js +15 -0
  27. package/dist/errors/stale-route-error.d.ts +1 -1
  28. package/dist/errors/stale-route-error.js +1 -1
  29. package/dist/{schema → execution}/admission.d.ts +2 -2
  30. package/dist/{schema → execution}/admission.js +2 -2
  31. package/dist/{session/execution.d.ts → execution/contracts.d.ts} +22 -34
  32. package/dist/execution/contracts.js +1 -0
  33. package/dist/execution/deadline.d.ts +18 -0
  34. package/dist/execution/deadline.js +25 -0
  35. package/dist/execution/execution.d.ts +61 -0
  36. package/dist/execution/execution.js +132 -0
  37. package/dist/execution/index.d.ts +4 -0
  38. package/dist/execution/index.js +3 -0
  39. package/dist/graph/domain/binding.d.ts +2 -2
  40. package/dist/graph/domain/binding.js +20 -17
  41. package/dist/graph/domain/conformance.d.ts +12 -0
  42. package/dist/graph/domain/conformance.js +18 -0
  43. package/dist/graph/domain/index.d.ts +1 -0
  44. package/dist/graph/domain/index.js +1 -1
  45. package/dist/graph/domain/provenance.d.ts +0 -2
  46. package/dist/graph/domain/provenance.js +0 -4
  47. package/dist/graph/graph.d.ts +17 -3
  48. package/dist/graph/graph.js +4 -1
  49. package/dist/graph/index.d.ts +3 -3
  50. package/dist/graph/index.js +1 -1
  51. package/dist/graph/page-contract.d.ts +66 -1
  52. package/dist/graph/provenance.d.ts +4 -5
  53. package/dist/graph/provenance.js +5 -6
  54. package/dist/graph/query.d.ts +10 -4
  55. package/dist/graph/query.js +144 -5
  56. package/dist/graph/query.typecheck.d.ts +81 -0
  57. package/dist/graph/query.typecheck.js +34 -0
  58. package/dist/index.d.ts +1 -1
  59. package/dist/index.js +1 -1
  60. package/dist/schema/contracts.d.ts +54 -79
  61. package/dist/schema/index.d.ts +2 -2
  62. package/dist/schema/index.js +1 -1
  63. package/dist/schema/installation.d.ts +36 -64
  64. package/dist/schema/installation.js +67 -131
  65. package/dist/schema/schema.d.ts +10 -16
  66. package/dist/schema/schema.js +57 -34
  67. package/dist/session/admission.js +10 -3
  68. package/dist/session/bound.d.ts +12 -3
  69. package/dist/session/bound.js +36 -32
  70. package/dist/session/content/api.d.ts +20 -2
  71. package/dist/session/content/api.js +17 -7
  72. package/dist/session/content/files.d.ts +12 -0
  73. package/dist/session/content/files.js +47 -0
  74. package/dist/session/content/index.d.ts +1 -1
  75. package/dist/session/content/input.d.ts +13 -2
  76. package/dist/session/content/input.js +25 -4
  77. package/dist/session/content/retry.d.ts +5 -1
  78. package/dist/session/content/retry.js +21 -31
  79. package/dist/session/context/index.d.ts +2 -2
  80. package/dist/session/context/index.js +2 -2
  81. package/dist/session/context/operation.d.ts +2 -0
  82. package/dist/session/context/operation.js +5 -0
  83. package/dist/session/context/policy.d.ts +2 -0
  84. package/dist/session/context/policy.js +6 -3
  85. package/dist/session/credential/credentials.d.ts +2 -1
  86. package/dist/session/credential/credentials.js +62 -29
  87. package/dist/session/discovery/bundle.d.ts +13 -4
  88. package/dist/session/discovery/bundle.js +85 -36
  89. package/dist/session/discovery/discovery.d.ts +1 -1
  90. package/dist/session/discovery/discovery.js +8 -11
  91. package/dist/session/discovery/index.d.ts +1 -0
  92. package/dist/session/discovery/index.js +5 -1
  93. package/dist/session/discovery/release.d.ts +2 -0
  94. package/dist/session/discovery/release.js +34 -31
  95. package/dist/session/discovery/response.d.ts +4 -0
  96. package/dist/session/discovery/response.js +10 -6
  97. package/dist/session/discovery/snapshot.d.ts +5 -1
  98. package/dist/session/discovery/transport.d.ts +37 -3
  99. package/dist/session/discovery/transport.js +62 -1
  100. package/dist/session/durable.d.ts +13 -0
  101. package/dist/session/durable.js +39 -0
  102. package/dist/session/exchange/exchange.d.ts +3 -2
  103. package/dist/session/exchange/exchange.js +10 -7
  104. package/dist/session/exchange/index.d.ts +1 -1
  105. package/dist/session/exchange/index.js +1 -1
  106. package/dist/session/exchange/presentation.js +28 -10
  107. package/dist/session/exchange/source.d.ts +7 -7
  108. package/dist/session/exchange/source.js +26 -27
  109. package/dist/session/index.d.ts +5 -4
  110. package/dist/session/index.js +0 -1
  111. package/dist/session/options.d.ts +4 -2
  112. package/dist/session/options.js +3 -3
  113. package/dist/session/reference.d.ts +27 -6
  114. package/dist/session/reference.js +18 -3
  115. package/dist/session/retry.d.ts +12 -0
  116. package/dist/session/retry.js +23 -0
  117. package/dist/session/routing/auth.d.ts +9 -3
  118. package/dist/session/routing/auth.js +4 -3
  119. package/dist/session/routing/cache.d.ts +12 -5
  120. package/dist/session/routing/cache.js +56 -48
  121. package/dist/session/routing/dispatch.d.ts +26 -3
  122. package/dist/session/routing/dispatch.js +112 -69
  123. package/dist/session/routing/envelope.d.ts +3 -3
  124. package/dist/session/routing/index.d.ts +1 -1
  125. package/dist/session/routing/legacy/release-route.d.ts +12 -0
  126. package/dist/session/routing/legacy/release-route.js +6 -0
  127. package/dist/session/routing/recovery.d.ts +3 -6
  128. package/dist/session/routing/recovery.js +3 -14
  129. package/dist/session/routing/request.d.ts +2 -1
  130. package/dist/session/routing/request.js +2 -1
  131. package/dist/session/routing/result.d.ts +1 -1
  132. package/dist/session/routing/result.js +5 -1
  133. package/dist/session/routing/store.js +4 -5
  134. package/dist/session/session.d.ts +31 -5
  135. package/dist/session/session.js +70 -22
  136. package/dist/session/session.typecheck.js +20 -6
  137. package/dist/session/views/index.d.ts +2 -2
  138. package/dist/session/views/index.js +2 -2
  139. package/dist/session/views/kernel.d.ts +31 -0
  140. package/dist/session/views/kernel.js +30 -0
  141. package/dist/session/views/legacy/catalog.d.ts +21 -0
  142. package/dist/session/views/{catalog.js → legacy/catalog.js} +7 -31
  143. package/dist/session/views/legacy/index.d.ts +14 -0
  144. package/dist/session/views/legacy/index.js +14 -0
  145. package/dist/session/views/legacy/resolve.d.ts +46 -0
  146. package/dist/session/views/legacy/resolve.js +83 -0
  147. package/dist/session/views/legacy/unplaced.d.ts +22 -0
  148. package/dist/session/views/legacy/unplaced.js +26 -0
  149. package/dist/session/views/read.d.ts +49 -0
  150. package/dist/session/views/read.js +148 -0
  151. package/dist/session/views/view.d.ts +48 -0
  152. package/dist/session/views/view.js +74 -0
  153. package/dist/store/memory.d.ts +1 -3
  154. package/dist/store/memory.js +61 -112
  155. package/dist/store/shape.d.ts +33 -12
  156. package/dist/store/shape.js +125 -16
  157. package/dist/store/store.d.ts +6 -6
  158. package/dist/store/store.js +1 -1
  159. package/dist/transport/auto/decision.d.ts +28 -14
  160. package/dist/transport/auto/decision.js +39 -32
  161. package/dist/transport/auto/fallback.d.ts +1 -1
  162. package/dist/transport/auto/fallback.js +5 -10
  163. package/dist/transport/auto/transport.d.ts +10 -3
  164. package/dist/transport/auto/transport.js +41 -32
  165. package/dist/transport/deadline.d.ts +2 -0
  166. package/dist/transport/deadline.js +18 -0
  167. package/dist/transport/failure.d.ts +28 -1
  168. package/dist/transport/failure.js +63 -1
  169. package/dist/transport/http/admission.js +8 -35
  170. package/dist/transport/http/binary-request.d.ts +44 -0
  171. package/dist/transport/http/binary-request.js +110 -0
  172. package/dist/transport/http/binary.js +3 -3
  173. package/dist/transport/http/byte-stream.d.ts +2 -1
  174. package/dist/transport/http/byte-stream.js +12 -8
  175. package/dist/transport/http/configuration.d.ts +7 -0
  176. package/dist/transport/http/configuration.js +2 -0
  177. package/dist/transport/http/index.d.ts +1 -1
  178. package/dist/transport/http/index.js +1 -1
  179. package/dist/transport/http/response.d.ts +13 -1
  180. package/dist/transport/http/response.js +22 -9
  181. package/dist/transport/http/stream.d.ts +8 -13
  182. package/dist/transport/http/stream.js +34 -81
  183. package/dist/transport/http/transport.d.ts +14 -1
  184. package/dist/transport/http/transport.js +110 -35
  185. package/dist/transport/http/unprocessed.d.ts +5 -0
  186. package/dist/transport/http/unprocessed.js +28 -0
  187. package/dist/transport/index.d.ts +2 -1
  188. package/dist/transport/index.js +2 -1
  189. package/dist/transport/level.d.ts +42 -0
  190. package/dist/transport/level.js +58 -0
  191. package/dist/transport/stream.d.ts +52 -0
  192. package/dist/transport/stream.js +101 -0
  193. package/dist/transport/transport.d.ts +33 -0
  194. package/dist/transport/unary.d.ts +9 -0
  195. package/dist/transport/unary.js +36 -0
  196. package/dist/transport/websocket/connection.d.ts +13 -4
  197. package/dist/transport/websocket/connection.js +123 -96
  198. package/dist/transport/websocket/exchange.d.ts +15 -19
  199. package/dist/transport/websocket/exchange.js +87 -183
  200. package/dist/transport/websocket/transport.d.ts +19 -1
  201. package/dist/transport/websocket/transport.js +50 -21
  202. package/package.json +9 -7
  203. package/dist/session/execution.js +0 -34
  204. package/dist/session/views/catalog.d.ts +0 -19
  205. package/dist/session/views/resolve.d.ts +0 -13
  206. package/dist/session/views/resolve.js +0 -21
@@ -3,23 +3,29 @@ import { callableFingerprint } from '@astrale-os/kernel-dsl/v1/schema/fingerprin
3
3
  import { createAuth } from '../auth/auth.js';
4
4
  import { acceptCall } from '../client/index.js';
5
5
  import { SessionError } from '../errors/index.js';
6
+ import { createExecution } from '../execution/index.js';
6
7
  import { createDomainBinding } from '../graph/domain/binding.js';
7
8
  import { createGraph } from '../graph/index.js';
8
9
  import { createSchema } from '../schema/index.js';
9
10
  import { admitFunction } from './admission.js';
11
+ import { uploadFiles } from './content/files.js';
10
12
  import { createContentApi } from './content/index.js';
11
- import { admitControlOptions, allowEndpoint, createSessionOperation } from './context/index.js';
13
+ import { admitControlOptions, allowEndpoint, createSessionOperation, sessionTransportOptions, } from './context/index.js';
12
14
  import { createSessionDiscovery } from './discovery/index.js';
15
+ import { attemptDurable, durableOptions } from './durable.js';
13
16
  import { acquireDomainCredential, admitExchangeRequest, createSessionExchange, } from './exchange/index.js';
14
17
  import { acceptSessionOptions } from './options.js';
15
- import { admitReference } from './reference.js';
18
+ import { admitReference, filesOf, outputModeOf } from './reference.js';
16
19
  import { admitInvocationOptions, requireResultKind, SessionDispatcher } from './routing/index.js';
17
- import { domainViewCatalog, resolveViewsFor } from './views/index.js';
20
+ import { admitView } from './views/index.js';
21
+ import { readDomainViewsOrResolved, readViewOrResolved, resolvedViewSource, } from './views/legacy/index.js';
18
22
  const DEFAULT_SESSION_POLICY = Object.freeze({ maximumRouteAgeMs: 60_000 });
19
23
  /** Caller-owned discovery and redirect-following conversation with one exact source Kernel. */
20
24
  export class ClientSession {
21
25
  kernel;
22
26
  schema;
27
+ /** The `K.Execution` Methods of any Execution, a durable call's or an install's. */
28
+ execution;
23
29
  graph;
24
30
  auth;
25
31
  content;
@@ -31,7 +37,9 @@ export class ClientSession {
31
37
  routes;
32
38
  exchangeDependencies;
33
39
  callExchange;
34
- admitDomainViews;
40
+ viewReader;
41
+ /** The deprecated View.resolve reads: `viewsFor`, and the Views of a Kernel that places none. */
42
+ resolvedViews;
35
43
  closed = false;
36
44
  constructor(options) {
37
45
  const settled = acceptSessionOptions(options);
@@ -41,13 +49,19 @@ export class ClientSession {
41
49
  this.timeoutMs = settled.timeoutMs;
42
50
  this.ownedPool = settled.ownedPool;
43
51
  this.routes = settled.routes;
44
- this.admitDomainViews = (input, domain) => domainViewCatalog(input, domain, policy);
52
+ this.viewReader = Object.freeze({
53
+ query: (ast, page, operation) => this.graph.query(ast, { ...sessionTransportOptions(operation), page }),
54
+ read: (target, operation) => this.graph.getOrThrow(target, sessionTransportOptions(operation)),
55
+ admit: (node, declaration) => admitView(node, declaration, kernel, policy),
56
+ });
57
+ this.resolvedViews = resolvedViewSource(async (call, operation) => requireResultKind('value', await this.dispatcher.dispatch(call, {}, operation)).value, policy);
45
58
  this.discovery = createSessionDiscovery({
46
59
  kernel,
47
60
  fetch,
48
61
  policy,
49
62
  maximumReleaseBytes,
50
63
  maximumBundleBytes,
64
+ maximumLogicalBundleBytes: settled.maximumLogicalBundleBytes,
51
65
  requireOpen: () => this.requireOpen(),
52
66
  acquisitionOperation: () => this.operation(undefined),
53
67
  });
@@ -60,7 +74,7 @@ export class ClientSession {
60
74
  ...(auth === undefined ? {} : { auth }),
61
75
  fetch,
62
76
  policy,
63
- limits: { maximumReleaseBytes, maximumBundleBytes },
77
+ limits: { maximumReleaseBytes, maximumBundleBytes: settled.maximumLogicalBundleBytes },
64
78
  maximumResponseBytes,
65
79
  operation: (signal) => this.operation(signal === undefined ? undefined : { signal }),
66
80
  });
@@ -91,9 +105,9 @@ export class ClientSession {
91
105
  });
92
106
  this.schema = createSchema((request, options) => this.dispatch(request, options), {
93
107
  maximumReleaseBytes,
94
- maximumBundleBytes,
95
- lifecycleTimeoutMs: settled.schemaLifecycleTimeoutMs,
108
+ maximumBundleBytes: settled.maximumLogicalBundleBytes,
96
109
  });
110
+ this.execution = createExecution((request, options) => this.dispatch(request, options));
97
111
  this.graph = createGraph((call, options) => this.call(call, options));
98
112
  this.auth = createAuth((target, input, options) => this.call({ target, input }, options), (call, options) => {
99
113
  const operation = this.operation(admitControlOptions(options));
@@ -122,13 +136,22 @@ export class ClientSession {
122
136
  snapshot(options) {
123
137
  return this.discovery.snapshot(this.operation(admitControlOptions(options)));
124
138
  }
139
+ view(input, options) {
140
+ this.requireOpen();
141
+ const operation = this.operation(admitControlOptions(options));
142
+ return isViewsOf(input)
143
+ ? readDomainViewsOrResolved(this.viewReader, this.resolvedViews.views, input.domain, operation)
144
+ : readViewOrResolved(this.viewReader, this.resolvedViews.views, input, operation);
145
+ }
125
146
  /**
126
- * Resolve the View catalog of one installed Domain. Only an exact Domain Path `/:<origin>` is
127
- * accepted; any other Path rejects with a TypeError before the call.
147
+ * @deprecated Read a Domain's Views with `view({ domain })`, or one View with `view(path)`. This
148
+ * lists them through the deprecated View.resolve, each with the Release digest that owns it, and
149
+ * never names the entrypoint. Only an exact Domain Path `/:<origin>` is accepted; any other Path
150
+ * rejects with a TypeError before the call.
128
151
  */
129
152
  viewsFor(domain, options) {
130
153
  this.requireOpen();
131
- return resolveViewsFor(async (call, operation) => requireResultKind('value', await this.dispatcher.dispatch(call, {}, operation)).value, this.admitDomainViews, domain, this.operation(admitControlOptions(options)));
154
+ return this.resolvedViews.catalog(domain, this.operation(admitControlOptions(options)));
132
155
  }
133
156
  dispatch(call, options) {
134
157
  return this.dispatchWith(call, options);
@@ -140,6 +163,10 @@ export class ClientSession {
140
163
  async invoke(reference, input, options) {
141
164
  const admittedReference = admitReference(reference);
142
165
  const admitted = admitInvocationOptions(options);
166
+ // A file field may hold the Blob itself: it is uploaded, and its receipt is sent.
167
+ const sent = admittedReference.files === undefined
168
+ ? input
169
+ : await uploadFiles(admittedReference.files, input, (source, uploadOptions) => this.content.upload(source, uploadOptions), admitted.options.signal === undefined ? {} : { signal: admitted.options.signal });
143
170
  const { anchor, steps } = admittedReference.target.ast;
144
171
  const last = steps.at(-1);
145
172
  const instance = last?.kind === 'method' && last.dispatch === 'instance'
@@ -155,18 +182,31 @@ export class ClientSession {
155
182
  : { fingerprint: admittedReference.fingerprint }),
156
183
  ...(instance === undefined ? {} : { instance }),
157
184
  }),
158
- input,
185
+ input: sent,
159
186
  };
160
- const operation = this.operation(admitted.options);
161
- const result = await (admitted.body === undefined && admittedReference.outputMode !== 'binary'
162
- ? this.dispatcher.dispatch(call, admitted.options, operation)
163
- : this.dispatcher.dispatchHttp(call, admitted.options, operation, admitted.body));
187
+ // A durable call is keyed, so an attempt whose outcome is unknown can be sent again.
188
+ const durable = admittedReference.outputMode === 'execution';
189
+ const requested = durable ? durableOptions(admitted.options) : admitted.options;
190
+ const operation = this.operation(requested);
191
+ const streaming = admitted.body === undefined && admittedReference.outputMode !== 'binary'
192
+ ? undefined
193
+ : { body: admitted.body };
194
+ // Resolved once: every attempt presents the principal and caller its key names an Execution with.
195
+ const resolved = await this.dispatcher.resolve(call, operation);
196
+ const attempt = () => this.dispatcher.dispatchResolved(resolved, requested, operation, streaming);
197
+ const result = await (durable ? attemptDurable(operation, attempt) : attempt());
164
198
  const narrowed = requireResultKind(admittedReference.outputMode, result);
165
- return narrowed.kind === 'value'
166
- ? narrowed.value
167
- : narrowed.kind === 'stream'
168
- ? narrowed.stream
169
- : narrowed.value;
199
+ switch (narrowed.kind) {
200
+ case 'stream':
201
+ return narrowed.stream;
202
+ case 'execution':
203
+ return Object.freeze({
204
+ id: narrowed.execution,
205
+ ...(narrowed.replayed === undefined ? {} : { replayed: narrowed.replayed }),
206
+ });
207
+ default:
208
+ return narrowed.value;
209
+ }
170
210
  }
171
211
  dispatchWith(call, options, requireHttp = false) {
172
212
  const admitted = admitInvocationOptions(options);
@@ -209,7 +249,8 @@ export class ClientSession {
209
249
  fingerprint: callableFingerprint(method),
210
250
  callable: method.key,
211
251
  target: Path.instanceMethod(Path.id(node.id), method.key),
212
- outputMode: method.output.mode,
252
+ outputMode: outputModeOf(method),
253
+ files: filesOf(method),
213
254
  }, input);
214
255
  }
215
256
  operation(options) {
@@ -217,6 +258,13 @@ export class ClientSession {
217
258
  return createSessionOperation(this.lifecycle.signal, options, this.timeoutMs);
218
259
  }
219
260
  }
261
+ /**
262
+ * Whether `view` reads a Domain's Views: its input is then a plain `{ domain }` object, while one
263
+ * View is read by a NodeId, a Path value or string, or a DefinitionRef.
264
+ */
265
+ function isViewsOf(input) {
266
+ return typeof input === 'object' && !(input instanceof Path) && 'domain' in input;
267
+ }
220
268
  /** Open a Kernel conversation with secure defaults and automatic Domain exchange when authenticated. */
221
269
  export function connect(options) {
222
270
  if (options === null || typeof options !== 'object') {
@@ -4,7 +4,7 @@ import { K, KernelSchema } from '@astrale-os/kernel-core/schema';
4
4
  import { defineSchema, func, method, nodeClass, schema, valueSchema, } from '@astrale-os/kernel-dsl/v1';
5
5
  import { isBinaryInput } from '@astrale-os/kernel-dsl/v1/language';
6
6
  import { call } from '../client/index.js';
7
- import { ClientSession, credentials, execution, reference } from './index.js';
7
+ import { ClientSession, credentials, reference } from './index.js';
8
8
  void new ClientSession(options);
9
9
  void auth;
10
10
  void control;
@@ -110,6 +110,10 @@ const boundBlobReceipt = boundSession.content
110
110
  .then(({ receipt }) => receipt);
111
111
  void blobReceipt;
112
112
  void boundBlobReceipt;
113
+ void session.content.upload(received, { mediaType: 'image/png' });
114
+ void boundSession.content.upload({ body: new ReadableStream(), length: 0 }, { mediaType: 'image/png' });
115
+ // @ts-expect-error A stream upload declares its exact length.
116
+ void session.content.upload({ body: new ReadableStream() }, { mediaType: 'image/png' });
113
117
  void session.invoke(registerReference, registration);
114
118
  void boundSession.invoke(staticRegisterReference, registration);
115
119
  void session.invoke(renameReference, renameRequest);
@@ -121,6 +125,12 @@ void client.dispatch(rawBinaryCall, { body: new Blob() });
121
125
  void client.as('credential').call(rawBinaryCall, { body: new Blob() });
122
126
  // @ts-expect-error Binary Functions require a byte source.
123
127
  void session.invoke(binaryUploadReference, { mediaType: 'image/png' });
128
+ // @ts-expect-error A Session invocation sends a re-readable Blob: it may follow a Redirect.
129
+ void session.invoke(binaryUploadReference, { mediaType: 'image/png' }, { body: received });
130
+ // @ts-expect-error A raw Client sends a re-readable Blob: it cannot resend a stream a Redirect answers.
131
+ void client.dispatch(rawBinaryCall, { body: received });
132
+ // @ts-expect-error The public HTTP transport sends a re-readable Blob too.
133
+ void httpTransport.dispatchBinary(rawEnvelope, received);
124
134
  // @ts-expect-error Value Functions reject binary bodies.
125
135
  void session.invoke(registerReference, registration, { body: new Blob() });
126
136
  // @ts-expect-error Bound binary Functions require a byte source.
@@ -189,12 +199,13 @@ const durableDomain = schema.resolve(defineSchema('client.durable.typecheck', {
189
199
  }));
190
200
  const remindReference = reference(durableDomain, durableDomain.classes.Invoice.methods.remind)(Path.id(NodeId('invoice-1')));
191
201
  const durableReturnsExecution = true;
202
+ const outcome = session.execution.result(run, { waitMs: 1_000 });
192
203
  const outcomeIsTyped = true;
204
+ const status = session.execution.status(run);
193
205
  const statusIsTyped = true;
194
- void session.invoke(execution.result(run), { waitMs: 1_000 });
195
- void session.invoke(execution.signal(run), { name: 'approval', value: { by: 'billing' } });
206
+ void session.execution.signal(run, { name: 'approval', value: { by: 'billing' } });
196
207
  // @ts-expect-error Force is the only cancellation option.
197
- void session.invoke(execution.cancel(run), { waitMs: 1_000 });
208
+ void session.execution.cancel(run, { waitMs: 1_000 });
198
209
  void durableReturnsExecution;
199
210
  void outcomeIsTyped;
200
211
  void statusIsTyped;
@@ -206,5 +217,8 @@ void session.invoke(dynamicReference, dynamicInput, { expect: undefined });
206
217
  const unsupportedClientOptions = { expect: undefined };
207
218
  void unsupportedClientOptions;
208
219
  // @ts-expect-error Internal metadata dispatch is absent from the public package facade.
209
- import { dispatchTrace } from '../index.js';
210
- void dispatchTrace;
220
+ import { dispatchInternal } from '../index.js';
221
+ void dispatchInternal;
222
+ // @ts-expect-error The stream-capable HTTP binary path is absent from the public package facade.
223
+ import { dispatchBinaryBody } from '../index.js';
224
+ void dispatchBinaryBody;
@@ -1,2 +1,2 @@
1
- export { catalogFromKeys, domainViewCatalog, rootViewCatalog, type ResolvedView, type ViewCatalog, } from './catalog.js';
2
- export { resolveViewsFor, type ViewCatalogAdmission, type ViewInvoker } from './resolve.js';
1
+ export { admitView, admitViewPlacement, declaredView, type Declaration, type View } from './view.js';
2
+ export { readDomainViews, readView, type ViewAnswer, type ViewReader, type ViewsOf, type ViewsQuery, } from './read.js';
@@ -1,2 +1,2 @@
1
- export { catalogFromKeys, domainViewCatalog, rootViewCatalog, } from './catalog.js';
2
- export { resolveViewsFor } from './resolve.js';
1
+ export { admitView, admitViewPlacement, declaredView } from './view.js';
2
+ export { readDomainViews, readView, } from './read.js';
@@ -0,0 +1,31 @@
1
+ /** The Kernel `View` Class. */
2
+ export declare const VIEW_CLASS: Readonly<{
3
+ origin: 'kernel.astrale.ai';
4
+ kind: 'class';
5
+ name: "View";
6
+ }>;
7
+ /** The Kernel `of_domain` Edge Class, which only projection writes. */
8
+ export declare const OF_DOMAIN_CLASS: Readonly<{
9
+ origin: 'kernel.astrale.ai';
10
+ kind: 'class';
11
+ name: "of_domain";
12
+ }>;
13
+ /** The Kernel `Domain` Class. */
14
+ export declare const DOMAIN_CLASS: Readonly<{
15
+ origin: 'kernel.astrale.ai';
16
+ kind: 'class';
17
+ name: "Domain";
18
+ }>;
19
+ export declare const VIEW: "kernel.astrale.ai:class.View";
20
+ export declare const OF_DOMAIN: "kernel.astrale.ai:class.of_domain";
21
+ export declare const DOMAIN: "kernel.astrale.ai:class.Domain";
22
+ /** `View.placement`: where and how a Shell mounts the View. */
23
+ export declare const PLACEMENT: "kernel.astrale.ai:class.View.property.placement";
24
+ /** `of_domain.member`: the member name under which a Domain declares the Node. */
25
+ export declare const MEMBER: "kernel.astrale.ai:class.of_domain.property.member";
26
+ /** `Domain.origin`. */
27
+ export declare const ORIGIN: "kernel.astrale.ai:class.Domain.property.origin";
28
+ /** `Descriptable.description`. */
29
+ export declare const DESCRIPTION: "kernel.astrale.ai:class.Descriptable.property.description";
30
+ /** `Identity.iss`. */
31
+ export declare const ISSUER: "kernel.astrale.ai:class.Identity.property.iss";
@@ -0,0 +1,30 @@
1
+ import { ClassKey, PropertyKey } from '@astrale-os/kernel-dsl/v1/addressing';
2
+ // The Kernel Classes a View read names, by their coordinates. `K` is built by the DSL builder when
3
+ // its module loads, and the Session must not resolve the Kernel Schema on loading, so these are
4
+ // written out here and the tests hold them equal to `K`.
5
+ function kernelClass(name) {
6
+ return Object.freeze({
7
+ origin: 'kernel.astrale.ai',
8
+ kind: 'class',
9
+ name,
10
+ });
11
+ }
12
+ /** The Kernel `View` Class. */
13
+ export const VIEW_CLASS = kernelClass('View');
14
+ /** The Kernel `of_domain` Edge Class, which only projection writes. */
15
+ export const OF_DOMAIN_CLASS = kernelClass('of_domain');
16
+ /** The Kernel `Domain` Class. */
17
+ export const DOMAIN_CLASS = kernelClass('Domain');
18
+ export const VIEW = ClassKey.of(VIEW_CLASS);
19
+ export const OF_DOMAIN = ClassKey.of(OF_DOMAIN_CLASS);
20
+ export const DOMAIN = ClassKey.of(DOMAIN_CLASS);
21
+ /** `View.placement`: where and how a Shell mounts the View. */
22
+ export const PLACEMENT = PropertyKey.of(VIEW_CLASS, 'placement');
23
+ /** `of_domain.member`: the member name under which a Domain declares the Node. */
24
+ export const MEMBER = PropertyKey.of(OF_DOMAIN_CLASS, 'member');
25
+ /** `Domain.origin`. */
26
+ export const ORIGIN = PropertyKey.of(DOMAIN_CLASS, 'origin');
27
+ /** `Descriptable.description`. */
28
+ export const DESCRIPTION = PropertyKey.of(kernelClass('Descriptable'), 'description');
29
+ /** `Identity.iss`. */
30
+ export const ISSUER = PropertyKey.of(kernelClass('Identity'), 'iss');
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The View catalog before Views carried their placement: `ResolvedView`, keyed by declaration and
3
+ * carrying the Release digest that owns it. `viewsFor` lists it through View.resolve
4
+ * (`resolve.ts`), and `SessionSnapshot.views` joins the source Kernel's Release to its root Schema.
5
+ * A client reads a View from its Node instead, as a `View` (`../view.ts`).
6
+ */
7
+ import type { ResolvedView } from '@astrale-os/kernel-core/schema/kernel/syscalls/view-resolution';
8
+ import type { bundle } from '@astrale-os/kernel-dsl/v1';
9
+ import type { DomainRelease } from '@astrale-os/kernel-protocol/release';
10
+ import type { SessionPolicy } from '../../context/index.js';
11
+ /** @deprecated One View as View.resolve lists it, with its Release digest; read it as a `View`. */
12
+ export type { ResolvedView };
13
+ /** @deprecated Immutable canonical-key-ordered inventory of Views; read them with `view`. */
14
+ export interface ViewCatalog {
15
+ readonly entrypoint?: ResolvedView;
16
+ readonly views: readonly ResolvedView[];
17
+ }
18
+ /** @deprecated The `viewsFor` of a bound Session whose source serves none: it throws. */
19
+ export declare function unavailableViewCatalog(): never;
20
+ /** @deprecated Join each root Domain View to its exact release binding. */
21
+ export declare function rootViewCatalog(release: DomainRelease, artifact: bundle.Bundle, policy: Readonly<SessionPolicy>): ViewCatalog;
@@ -1,8 +1,11 @@
1
- import { acceptViewResolution, } from '@astrale-os/kernel-core/schema/kernel/syscalls/view-resolution';
2
1
  import { Key as ViewKey } from '@astrale-os/kernel-dsl/v1/addressing';
3
- import { ClientError } from '../../errors/index.js';
4
- import { allowEndpoint } from '../context/index.js';
5
- /** Join each root Domain View to its exact release binding. */
2
+ import { ClientError } from '../../../errors/index.js';
3
+ import { allowEndpoint } from '../../context/index.js';
4
+ /** @deprecated The `viewsFor` of a bound Session whose source serves none: it throws. */
5
+ export function unavailableViewCatalog() {
6
+ throw new TypeError('The View catalog is unavailable from this bound Session source.');
7
+ }
8
+ /** @deprecated Join each root Domain View to its exact release binding. */
6
9
  export function rootViewCatalog(release, artifact, policy) {
7
10
  const views = release.bindings.views
8
11
  .flatMap((binding) => {
@@ -38,33 +41,6 @@ export function rootViewCatalog(release, artifact, policy) {
38
41
  views: catalogViews,
39
42
  });
40
43
  }
41
- export function catalogFromKeys(root, keys) {
42
- const selected = new Set(keys);
43
- const views = Object.freeze(root.views.filter(({ key }) => selected.has(key)));
44
- return Object.freeze({
45
- ...(root.entrypoint !== undefined && selected.has(root.entrypoint.key)
46
- ? { entrypoint: root.entrypoint }
47
- : {}),
48
- views,
49
- });
50
- }
51
- /**
52
- * Re-admit one Runtime-resolved Domain View catalog at the Client trust boundary. Only Views that
53
- * the requested Domain declares for itself are kept.
54
- */
55
- export function domainViewCatalog(input, domain, policy) {
56
- let resolution;
57
- try {
58
- resolution = acceptViewResolution(input);
59
- }
60
- catch (cause) {
61
- throw new ClientError('Resolved View catalog is invalid.', { cause });
62
- }
63
- const views = resolution.views.filter((view) => ViewKey.origin(view.key) === domain);
64
- for (const view of views)
65
- allowEndpoint(view.href, policy);
66
- return Object.freeze({ views: Object.freeze(views) });
67
- }
68
44
  function compareKeys(left, right) {
69
45
  return left < right ? -1 : left > right ? 1 : 0;
70
46
  }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * What a client keeps only to stay compatible. Every export is deprecated, the Session composes
3
+ * them, and no durable View code imports them.
4
+ *
5
+ * - `unplaced.ts` answers `view` from View.resolve when the Kernel that answers places no View.
6
+ * Delete it, with the `unplaced` answer of `../read.ts` and `ResolvedViewSource.views`, when every
7
+ * Kernel a client may reach places Views.
8
+ * - `catalog.ts` and `resolve.ts` serve `viewsFor` and `SessionSnapshot.views`: the View catalog
9
+ * keyed by declaration, with the Release digest that owns each View. Delete them with those two
10
+ * members, and `resolve.ts` only once `unplaced.ts` is gone too, since it lists through it.
11
+ */
12
+ export { rootViewCatalog, unavailableViewCatalog, type ResolvedView, type ViewCatalog, } from './catalog.js';
13
+ export { domainViewCatalog, resolvedViews, resolvedViewSource, resolveViewsFor, type ResolvedViews, type ResolvedViewSource, type ViewCatalogAdmission, type ViewInvoker, } from './resolve.js';
14
+ export { readDomainViewsOrResolved, readViewOrResolved } from './unplaced.js';
@@ -0,0 +1,14 @@
1
+ /**
2
+ * What a client keeps only to stay compatible. Every export is deprecated, the Session composes
3
+ * them, and no durable View code imports them.
4
+ *
5
+ * - `unplaced.ts` answers `view` from View.resolve when the Kernel that answers places no View.
6
+ * Delete it, with the `unplaced` answer of `../read.ts` and `ResolvedViewSource.views`, when every
7
+ * Kernel a client may reach places Views.
8
+ * - `catalog.ts` and `resolve.ts` serve `viewsFor` and `SessionSnapshot.views`: the View catalog
9
+ * keyed by declaration, with the Release digest that owns each View. Delete them with those two
10
+ * members, and `resolve.ts` only once `unplaced.ts` is gone too, since it lists through it.
11
+ */
12
+ export { rootViewCatalog, unavailableViewCatalog, } from './catalog.js';
13
+ export { domainViewCatalog, resolvedViews, resolvedViewSource, resolveViewsFor, } from './resolve.js';
14
+ export { readDomainViewsOrResolved, readViewOrResolved } from './unplaced.js';
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Every read through View.resolve, the one source of a Domain's Views before they carried their
3
+ * placement: the deprecated `viewsFor`, exactly as it listed them, each with the Release digest that
4
+ * owns it, and the same listing as Views for `unplaced.ts`. A Session composes both through
5
+ * `resolvedViewSource`.
6
+ */
7
+ import type { PathLike } from '@astrale-os/kernel-core/path';
8
+ import type { Key } from '@astrale-os/kernel-dsl/v1';
9
+ import type { Call, Input } from '../../../client/index.js';
10
+ import type { SessionOperation, SessionPolicy } from '../../context/index.js';
11
+ import type { View } from '../view.js';
12
+ import type { ViewCatalog } from './catalog.js';
13
+ /** @deprecated How `viewsFor` sends its View.resolve call. */
14
+ export type ViewInvoker = (call: Call, operation: SessionOperation) => Promise<Input>;
15
+ /** @deprecated How `viewsFor` admits the catalog View.resolve answers for one Domain. */
16
+ export type ViewCatalogAdmission = (input: unknown, domain: Key.Origin) => ViewCatalog;
17
+ /** @deprecated The Views of one Domain as its Kernel's View.resolve lists them. */
18
+ export type ResolvedViews = (domain: Key.Origin, operation: SessionOperation) => Promise<readonly View[]>;
19
+ /** @deprecated What one Session reads through View.resolve. */
20
+ export interface ResolvedViewSource {
21
+ /** The catalog `viewsFor` answers for one exact Domain Path. */
22
+ readonly catalog: (domain: PathLike, operation: SessionOperation) => Promise<ViewCatalog>;
23
+ /** The Views of one Domain, for a Kernel that places none (`unplaced.ts`). */
24
+ readonly views: ResolvedViews;
25
+ }
26
+ /**
27
+ * @deprecated The View.resolve reads of one Session: each Call sent by `invoke`, each answer admitted
28
+ * under the Session endpoint policy.
29
+ */
30
+ export declare function resolvedViewSource(invoke: ViewInvoker, policy: Readonly<SessionPolicy>): ResolvedViewSource;
31
+ /**
32
+ * @deprecated Resolve the per-Domain View catalog through the canonical source Kernel call, then
33
+ * admit the Release evidence it answers with. Every View targets its owning Domain, so only an exact
34
+ * Domain Path `/:<origin>` is meaningful; any other Path is refused before the call.
35
+ */
36
+ export declare function resolveViewsFor(invoke: ViewInvoker, admitCatalog: ViewCatalogAdmission, domain: PathLike, operation: SessionOperation): Promise<ViewCatalog>;
37
+ /**
38
+ * @deprecated Re-admit one Runtime-resolved Domain View catalog at the Client trust boundary. Only
39
+ * Views that the requested Domain declares for itself are kept.
40
+ */
41
+ export declare function domainViewCatalog(input: unknown, domain: Key.Origin, policy: Readonly<SessionPolicy>): ViewCatalog;
42
+ /**
43
+ * @deprecated The Views View.resolve lists for one Domain, each named by its declaration and
44
+ * answered for by the issuer of the Release that binds it, its Domain's.
45
+ */
46
+ export declare function resolvedViews(invoke: ViewInvoker, admitCatalog: ViewCatalogAdmission): ResolvedViews;
@@ -0,0 +1,83 @@
1
+ import { Path } from '@astrale-os/kernel-core/path';
2
+ import { view } from '@astrale-os/kernel-core/schema/kernel/syscalls/references';
3
+ import { acceptViewResolution, } from '@astrale-os/kernel-core/schema/kernel/syscalls/view-resolution';
4
+ import { Key as ViewKey } from '@astrale-os/kernel-dsl/v1/addressing';
5
+ import { call } from '../../../client/index.js';
6
+ import { ClientError } from '../../../errors/index.js';
7
+ import { allowEndpoint } from '../../context/index.js';
8
+ /**
9
+ * @deprecated The View.resolve reads of one Session: each Call sent by `invoke`, each answer admitted
10
+ * under the Session endpoint policy.
11
+ */
12
+ export function resolvedViewSource(invoke, policy) {
13
+ const admit = (input, domain) => domainViewCatalog(input, domain, policy);
14
+ return Object.freeze({
15
+ catalog: (domain, operation) => resolveViewsFor(invoke, admit, domain, operation),
16
+ views: resolvedViews(invoke, admit),
17
+ });
18
+ }
19
+ /**
20
+ * @deprecated Resolve the per-Domain View catalog through the canonical source Kernel call, then
21
+ * admit the Release evidence it answers with. Every View targets its owning Domain, so only an exact
22
+ * Domain Path `/:<origin>` is meaningful; any other Path is refused before the call.
23
+ */
24
+ export async function resolveViewsFor(invoke, admitCatalog, domain, operation) {
25
+ const origin = domainOrigin(domain);
26
+ const owner = Path.project(view.resolve.owner);
27
+ const resolve = Path.staticMethod(owner, view.resolve.name);
28
+ return admitCatalog(await invoke(call(resolve, { target: Path.domain(origin).raw }), operation), origin);
29
+ }
30
+ /**
31
+ * @deprecated Re-admit one Runtime-resolved Domain View catalog at the Client trust boundary. Only
32
+ * Views that the requested Domain declares for itself are kept.
33
+ */
34
+ export function domainViewCatalog(input, domain, policy) {
35
+ let resolution;
36
+ try {
37
+ resolution = acceptViewResolution(input);
38
+ }
39
+ catch (cause) {
40
+ throw new ClientError('Resolved View catalog is invalid.', { cause });
41
+ }
42
+ const views = resolution.views.filter((view) => ViewKey.origin(view.key) === domain);
43
+ for (const view of views)
44
+ allowEndpoint(view.href, policy);
45
+ return Object.freeze({ views: Object.freeze(views) });
46
+ }
47
+ /**
48
+ * @deprecated The Views View.resolve lists for one Domain, each named by its declaration and
49
+ * answered for by the issuer of the Release that binds it, its Domain's.
50
+ */
51
+ export function resolvedViews(invoke, admitCatalog) {
52
+ return async (domain, operation) => {
53
+ const { views } = await resolveViewsFor(invoke, admitCatalog, Path.domain(domain), operation);
54
+ return Object.freeze(views.map(viewOf));
55
+ };
56
+ }
57
+ /**
58
+ * One View View.resolve listed, as the graph places it. Its Release digest and revision name what
59
+ * owns the View, not where it is mounted, and a View carries neither.
60
+ */
61
+ function viewOf(resolved) {
62
+ const domain = ViewKey.origin(resolved.key);
63
+ const name = resolved.key.slice(resolved.key.indexOf(':') + 1).slice('view.'.length);
64
+ const { description } = resolved.declaration;
65
+ return Object.freeze({
66
+ path: Path.project({ origin: domain, kind: 'view', name }).raw,
67
+ domain,
68
+ ...(description === undefined ? {} : { description }),
69
+ placement: Object.freeze({
70
+ href: resolved.href,
71
+ handshake: resolved.handshake,
72
+ ...(resolved.host === undefined ? {} : { host: resolved.host }),
73
+ }),
74
+ issuer: resolved.issuer,
75
+ });
76
+ }
77
+ function domainOrigin(input) {
78
+ const { anchor, steps } = Path.from(input).ast;
79
+ if (anchor.kind !== 'domain' || steps.length !== 0) {
80
+ throw new TypeError('View catalog requires a Domain Path /:<origin>; Views never target a Node.');
81
+ }
82
+ return anchor.origin;
83
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * A Kernel released before placement keeps no placement on its View Nodes and lists a Domain's
3
+ * Views only through View.resolve. A Release binds every View its Domain declares
4
+ * (`RELEASE_VIEW_INVALID`) and projection places each binding, so a read `../read.ts` answers
5
+ * `unplaced` comes from such a Kernel: these reads answer it from that Kernel's View.resolve, so a
6
+ * Shell built on this client keeps working against a Host not yet upgraded.
7
+ */
8
+ import type { NodeTarget } from '@astrale-os/kernel-core/path';
9
+ import type { SessionOperation } from '../../context/index.js';
10
+ import type { ViewReader, ViewsOf } from '../read.js';
11
+ import type { View } from '../view.js';
12
+ import type { ResolvedViews } from './resolve.js';
13
+ /**
14
+ * @deprecated Read one View from the graph, or, when the graph declares it without a placement, as
15
+ * View.resolve lists it; a View it does not list is refused.
16
+ */
17
+ export declare function readViewOrResolved(reader: ViewReader, resolved: ResolvedViews, target: NodeTarget, operation: SessionOperation): Promise<View>;
18
+ /**
19
+ * @deprecated Read the Views one Domain declares from the graph, or, when the graph places none of
20
+ * them, as View.resolve lists them: in canonical key order, which is their Path order.
21
+ */
22
+ export declare function readDomainViewsOrResolved(reader: ViewReader, resolved: ResolvedViews, domain: ViewsOf['domain'], operation: SessionOperation): Promise<readonly View[]>;
@@ -0,0 +1,26 @@
1
+ import { ClientError } from '../../../errors/index.js';
2
+ import { readDomainViews, readView } from '../read.js';
3
+ /**
4
+ * @deprecated Read one View from the graph, or, when the graph declares it without a placement, as
5
+ * View.resolve lists it; a View it does not list is refused.
6
+ */
7
+ export async function readViewOrResolved(reader, resolved, target, operation) {
8
+ const answer = await readView(reader, target, operation);
9
+ if ('placed' in answer)
10
+ return answer.placed;
11
+ const { path, domain } = answer.unplaced;
12
+ const listed = (await resolved(domain, operation)).find((view) => view.path === path);
13
+ if (listed === undefined)
14
+ throw new ClientError('Node is not a placed View.');
15
+ return listed;
16
+ }
17
+ /**
18
+ * @deprecated Read the Views one Domain declares from the graph, or, when the graph places none of
19
+ * them, as View.resolve lists them: in canonical key order, which is their Path order.
20
+ */
21
+ export async function readDomainViewsOrResolved(reader, resolved, domain, operation) {
22
+ const answer = await readDomainViews(reader, domain, operation);
23
+ if ('placed' in answer)
24
+ return answer.placed;
25
+ return resolved(answer.unplaced, operation);
26
+ }