@astrale-os/kernel-client 0.6.0-beta.86 → 0.6.0-beta.88

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 (106) hide show
  1. package/dist/auth/identity.d.ts +2 -1
  2. package/dist/client/credential.d.ts +2 -1
  3. package/dist/errors/stale-route-error.d.ts +4 -14
  4. package/dist/errors/stale-route-error.js +2 -13
  5. package/dist/errors/transport-error.d.ts +1 -1
  6. package/dist/graph/domain/domain.typecheck.js +1 -0
  7. package/dist/graph/graph.d.ts +1 -0
  8. package/dist/graph/index.d.ts +1 -1
  9. package/dist/graph/index.js +1 -1
  10. package/dist/graph/mutation.js +3 -1
  11. package/dist/schema/introspection.js +1 -5
  12. package/dist/schema/schema.js +4 -8
  13. package/dist/session/bound.d.ts +1 -1
  14. package/dist/session/bound.js +2 -1
  15. package/dist/session/content/api.d.ts +45 -0
  16. package/dist/session/content/api.js +28 -0
  17. package/dist/session/content/batch.d.ts +5 -0
  18. package/dist/session/content/batch.js +93 -0
  19. package/dist/session/content/index.d.ts +1 -0
  20. package/dist/session/content/index.js +1 -0
  21. package/dist/session/content/input.d.ts +9 -0
  22. package/dist/session/content/input.js +33 -0
  23. package/dist/session/content/parts.d.ts +36 -0
  24. package/dist/session/content/parts.js +154 -0
  25. package/dist/session/content/retry.d.ts +3 -0
  26. package/dist/session/content/retry.js +41 -0
  27. package/dist/session/content/wire.d.ts +12 -0
  28. package/dist/session/content/wire.js +60 -0
  29. package/dist/session/context/index.d.ts +1 -1
  30. package/dist/session/context/index.js +1 -1
  31. package/dist/session/context/limits.d.ts +0 -1
  32. package/dist/session/context/limits.js +0 -1
  33. package/dist/session/context/operation.d.ts +0 -1
  34. package/dist/session/context/operation.js +1 -1
  35. package/dist/session/context/policy.d.ts +0 -1
  36. package/dist/session/context/policy.js +0 -16
  37. package/dist/session/discovery/bundle.d.ts +4 -3
  38. package/dist/session/discovery/bundle.js +20 -21
  39. package/dist/session/discovery/discovery.d.ts +0 -3
  40. package/dist/session/discovery/discovery.js +6 -14
  41. package/dist/session/discovery/index.d.ts +0 -5
  42. package/dist/session/discovery/index.js +1 -2
  43. package/dist/session/discovery/release.d.ts +6 -5
  44. package/dist/session/discovery/release.js +3 -3
  45. package/dist/session/discovery/snapshot.d.ts +1 -8
  46. package/dist/session/discovery/snapshot.js +2 -2
  47. package/dist/session/exchange/domain.js +1 -1
  48. package/dist/session/exchange/source.d.ts +2 -1
  49. package/dist/session/index.d.ts +3 -2
  50. package/dist/session/index.js +1 -1
  51. package/dist/session/options.d.ts +65 -0
  52. package/dist/session/options.js +132 -0
  53. package/dist/session/routing/cache.d.ts +9 -14
  54. package/dist/session/routing/cache.js +17 -178
  55. package/dist/session/routing/dispatch.d.ts +4 -3
  56. package/dist/session/routing/dispatch.js +63 -113
  57. package/dist/session/routing/envelope.d.ts +3 -3
  58. package/dist/session/routing/expiry.d.ts +4 -0
  59. package/dist/session/routing/expiry.js +32 -0
  60. package/dist/session/routing/index.d.ts +4 -2
  61. package/dist/session/routing/index.js +4 -2
  62. package/dist/session/routing/integrity.d.ts +7 -0
  63. package/dist/session/routing/integrity.js +44 -0
  64. package/dist/session/routing/recovery.d.ts +16 -0
  65. package/dist/session/routing/recovery.js +41 -0
  66. package/dist/session/routing/result.d.ts +5 -0
  67. package/dist/session/routing/result.js +12 -0
  68. package/dist/session/routing/store.d.ts +23 -0
  69. package/dist/session/routing/store.js +99 -0
  70. package/dist/session/session.d.ts +6 -50
  71. package/dist/session/session.js +28 -134
  72. package/dist/session/session.typecheck.js +8 -3
  73. package/dist/session/views/catalog.d.ts +5 -9
  74. package/dist/session/views/catalog.js +12 -24
  75. package/dist/session/views/resolve.d.ts +1 -1
  76. package/dist/session/views/resolve.js +1 -1
  77. package/dist/store/entity-index.d.ts +1 -2
  78. package/dist/store/entity-index.js +0 -3
  79. package/dist/store/memory.js +2 -2
  80. package/dist/store/shape.d.ts +2 -1
  81. package/dist/transport/auto/decision.d.ts +3 -2
  82. package/dist/transport/http/admission.d.ts +5 -0
  83. package/dist/transport/http/admission.js +101 -0
  84. package/dist/transport/http/binary.d.ts +5 -0
  85. package/dist/transport/http/binary.js +70 -0
  86. package/dist/transport/http/configuration.d.ts +24 -0
  87. package/dist/transport/http/configuration.js +116 -0
  88. package/dist/transport/http/index.d.ts +2 -1
  89. package/dist/transport/http/response.d.ts +7 -0
  90. package/dist/transport/http/response.js +9 -0
  91. package/dist/transport/http/retired.d.ts +8 -0
  92. package/dist/transport/http/retired.js +28 -0
  93. package/dist/transport/http/transport.d.ts +1 -19
  94. package/dist/transport/http/transport.js +17 -299
  95. package/dist/transport/websocket/connection.d.ts +2 -1
  96. package/package.json +5 -5
  97. package/dist/session/content.d.ts +0 -27
  98. package/dist/session/content.js +0 -135
  99. package/dist/session/discovery/legacy/index.d.ts +0 -38
  100. package/dist/session/discovery/legacy/index.js +0 -38
  101. package/dist/session/discovery/legacy/intrinsic.d.ts +0 -33
  102. package/dist/session/discovery/legacy/intrinsic.js +0 -67
  103. package/dist/session/discovery/legacy/projection.d.ts +0 -8
  104. package/dist/session/discovery/legacy/projection.js +0 -17
  105. package/dist/session/discovery/legacy/publication.d.ts +0 -26
  106. package/dist/session/discovery/legacy/publication.js +0 -76
@@ -0,0 +1,41 @@
1
+ import { CODES } from '@astrale-os/kernel-protocol/errors';
2
+ import { ResponseError, TransportError } from '../../errors/index.js';
3
+ import { runSessionOperation } from '../context/index.js';
4
+ const MAXIMUM_ATTEMPTS = 3;
5
+ /** Repeat one content request that failed before any of its result was delivered. */
6
+ export async function retry(operation, request) {
7
+ for (let attempt = 0;; attempt++) {
8
+ try {
9
+ return await request();
10
+ }
11
+ catch (cause) {
12
+ if (!retryable(cause) || attempt + 1 === MAXIMUM_ATTEMPTS || operation.signal.aborted) {
13
+ throw cause;
14
+ }
15
+ await runSessionOperation(operation, (signal) => delay(200 * 2 ** attempt, signal));
16
+ }
17
+ }
18
+ }
19
+ function retryable(cause) {
20
+ return ((cause instanceof TransportError && cause.context.kind === 'invocation') ||
21
+ (cause instanceof ResponseError &&
22
+ (cause.reason?.code === 'BLOB_UNAVAILABLE' ||
23
+ cause.code === CODES.CANCELLED ||
24
+ cause.code === CODES.DEADLINE_EXCEEDED ||
25
+ cause.code === CODES.OUTCOME_UNKNOWN)));
26
+ }
27
+ function delay(ms, signal) {
28
+ return new Promise((resolve, reject) => {
29
+ if (signal.aborted)
30
+ return reject(signal.reason);
31
+ const timer = setTimeout(() => {
32
+ signal.removeEventListener('abort', abort);
33
+ resolve();
34
+ }, ms);
35
+ const abort = () => {
36
+ clearTimeout(timer);
37
+ reject(signal.reason);
38
+ };
39
+ signal.addEventListener('abort', abort, { once: true });
40
+ });
41
+ }
@@ -0,0 +1,12 @@
1
+ import { Path } from '@astrale-os/kernel-core/path';
2
+ import type { Binary } from '../../client/index.js';
3
+ import type { ContentRejection, ContentUploadResult } from './api.js';
4
+ export declare const UPLOAD: Path.Projection;
5
+ export declare const DOWNLOAD: Path.Projection;
6
+ export declare function decodeUploadResult(input: unknown): ContentUploadResult;
7
+ /** The rejection a code names, or `undefined` when it names none. */
8
+ export declare function decodeRejection(code: unknown): ContentRejection | undefined;
9
+ /** A download whose exact size is declared; anything else is closed and refused. */
10
+ export declare function decodeDownload(input: Binary): Promise<Binary>;
11
+ /** Close a streamed body nobody will read. */
12
+ export declare function cancelBinary(input: Binary): Promise<void>;
@@ -0,0 +1,60 @@
1
+ import { Path } from '@astrale-os/kernel-core/path';
2
+ import { download, upload } from '@astrale-os/kernel-core/schema/kernel/syscalls/references';
3
+ import * as artifact from '@astrale-os/kernel-protocol/artifact';
4
+ import { ClientError, ProtocolError } from '../../errors/index.js';
5
+ export const UPLOAD = Path.project(upload);
6
+ export const DOWNLOAD = Path.project(download);
7
+ const REJECTIONS = [
8
+ 'BLOB_NOT_FOUND',
9
+ 'BLOB_UNAVAILABLE',
10
+ 'BLOB_INTEGRITY',
11
+ ];
12
+ export function decodeUploadResult(input) {
13
+ if (input === null || typeof input !== 'object' || Array.isArray(input)) {
14
+ throw new ClientError('Content upload returned an invalid receipt.');
15
+ }
16
+ const value = input;
17
+ if (typeof value.receipt !== 'string' ||
18
+ value.receipt.length === 0 ||
19
+ typeof value.expiresAt !== 'string' ||
20
+ !Number.isFinite(Date.parse(value.expiresAt))) {
21
+ throw new ClientError('Content upload returned an invalid receipt.');
22
+ }
23
+ let ref;
24
+ try {
25
+ ref = artifact.accept(value.ref);
26
+ }
27
+ catch (cause) {
28
+ throw new ClientError('Content upload returned an invalid Ref.', { cause });
29
+ }
30
+ return Object.freeze({
31
+ receipt: value.receipt,
32
+ ref,
33
+ expiresAt: value.expiresAt,
34
+ });
35
+ }
36
+ /** The rejection a code names, or `undefined` when it names none. */
37
+ export function decodeRejection(code) {
38
+ return REJECTIONS.find((candidate) => candidate === code);
39
+ }
40
+ /** A download whose exact size is declared; anything else is closed and refused. */
41
+ export async function decodeDownload(input) {
42
+ // The HTTP transport sets `length` only from an admitted declared length, and its byte stream
43
+ // enforces that exact count through the final read.
44
+ if (input.body instanceof Uint8Array || !('length' in input) || input.length === undefined) {
45
+ await cancelBinary(input);
46
+ throw new ProtocolError('Content download omitted its exact content size.');
47
+ }
48
+ return input;
49
+ }
50
+ /** Close a streamed body nobody will read. */
51
+ export async function cancelBinary(input) {
52
+ if (input.body instanceof Uint8Array)
53
+ return;
54
+ try {
55
+ await input.body[Symbol.asyncIterator]().return?.();
56
+ }
57
+ catch {
58
+ // Preserve the admission error after the response stream has been closed.
59
+ }
60
+ }
@@ -1,4 +1,4 @@
1
1
  export { admitControlOptions, type SessionControlOptions } from './control.js';
2
- export { DEFAULT_MAXIMUM_BUNDLE_BYTES, DEFAULT_MAXIMUM_PUBLICATION_BYTES, DEFAULT_MAXIMUM_RELEASE_BYTES, DEFAULT_MAXIMUM_RESPONSE_BYTES, DEFAULT_MAXIMUM_ROUTES, DEFAULT_TIMEOUT_MS, platformDuration, positive, } from './limits.js';
2
+ export { DEFAULT_MAXIMUM_BUNDLE_BYTES, DEFAULT_MAXIMUM_RELEASE_BYTES, DEFAULT_MAXIMUM_RESPONSE_BYTES, DEFAULT_MAXIMUM_ROUTES, DEFAULT_TIMEOUT_MS, platformDuration, positive, } from './limits.js';
3
3
  export { createSessionOperation, remainingSessionTime, runSessionOperation, sessionTransportOptions, type SessionOperation, } from './operation.js';
4
4
  export { admitKernel, admitPolicy, allowEndpoint, kernelInvocationEndpoint, type SessionPolicy, } from './policy.js';
@@ -1,4 +1,4 @@
1
1
  export { admitControlOptions } from './control.js';
2
- export { DEFAULT_MAXIMUM_BUNDLE_BYTES, DEFAULT_MAXIMUM_PUBLICATION_BYTES, DEFAULT_MAXIMUM_RELEASE_BYTES, DEFAULT_MAXIMUM_RESPONSE_BYTES, DEFAULT_MAXIMUM_ROUTES, DEFAULT_TIMEOUT_MS, platformDuration, positive, } from './limits.js';
2
+ export { DEFAULT_MAXIMUM_BUNDLE_BYTES, DEFAULT_MAXIMUM_RELEASE_BYTES, DEFAULT_MAXIMUM_RESPONSE_BYTES, DEFAULT_MAXIMUM_ROUTES, DEFAULT_TIMEOUT_MS, platformDuration, positive, } from './limits.js';
3
3
  export { createSessionOperation, remainingSessionTime, runSessionOperation, sessionTransportOptions, } from './operation.js';
4
4
  export { admitKernel, admitPolicy, allowEndpoint, kernelInvocationEndpoint, } from './policy.js';
@@ -1,5 +1,4 @@
1
1
  export declare const DEFAULT_MAXIMUM_RELEASE_BYTES: number;
2
- export declare const DEFAULT_MAXIMUM_PUBLICATION_BYTES: number;
3
2
  export declare const DEFAULT_MAXIMUM_BUNDLE_BYTES: number;
4
3
  export declare const DEFAULT_MAXIMUM_RESPONSE_BYTES: number;
5
4
  export declare const DEFAULT_TIMEOUT_MS = 30000;
@@ -1,5 +1,4 @@
1
1
  export const DEFAULT_MAXIMUM_RELEASE_BYTES = 1024 * 1024;
2
- export const DEFAULT_MAXIMUM_PUBLICATION_BYTES = 1024 * 1024;
3
2
  export const DEFAULT_MAXIMUM_BUNDLE_BYTES = 16 * 1024 * 1024;
4
3
  export const DEFAULT_MAXIMUM_RESPONSE_BYTES = 16 * 1024 * 1024;
5
4
  export const DEFAULT_TIMEOUT_MS = 30_000;
@@ -20,4 +20,3 @@ export declare function sessionTransportOptions(operation: SessionOperation): {
20
20
  export declare function sessionTransportOptions(operation: SessionOperation, idempotencyKey: RequestOptions['idempotencyKey']): RequestOptions;
21
21
  /** Settle independently of a caller capability that ignores its supplied AbortSignal. */
22
22
  export declare function runSessionOperation<Result>(operation: SessionOperation, task: (signal: AbortSignal) => Result | PromiseLike<Result>): Promise<Result>;
23
- export declare function requireSessionOperation(operation: SessionOperation): void;
@@ -54,7 +54,7 @@ export async function runSessionOperation(operation, task) {
54
54
  operation.signal.removeEventListener('abort', abort);
55
55
  });
56
56
  }
57
- export function requireSessionOperation(operation) {
57
+ function requireSessionOperation(operation) {
58
58
  if (!operation.signal.aborted)
59
59
  return;
60
60
  throw sessionInterruption(operation.signal.reason);
@@ -7,5 +7,4 @@ export interface SessionPolicy {
7
7
  export declare function admitPolicy(input: SessionPolicy): Readonly<SessionPolicy>;
8
8
  export declare function admitKernel(input: string, insecure: boolean): IssuerId;
9
9
  export declare function kernelInvocationEndpoint(input: IssuerId): string;
10
- export declare function websocketEndpoint(input: string, insecure: boolean): string;
11
10
  export declare function allowEndpoint(url: string, policy: Readonly<SessionPolicy>): void;
@@ -39,22 +39,6 @@ export function admitKernel(input, insecure) {
39
39
  export function kernelInvocationEndpoint(input) {
40
40
  return `${input}/invoke`;
41
41
  }
42
- export function websocketEndpoint(input, insecure) {
43
- let url;
44
- try {
45
- url = new URL(input);
46
- }
47
- catch (cause) {
48
- throw new TypeError('Session WebSocket endpoint is invalid.', { cause });
49
- }
50
- if (url.username !== '' ||
51
- url.password !== '' ||
52
- url.hash !== '' ||
53
- (url.protocol !== 'wss:' && !(insecure && url.protocol === 'ws:'))) {
54
- throw new TypeError('Session WebSocket endpoint is invalid.');
55
- }
56
- return url.toString();
57
- }
58
42
  export function allowEndpoint(url, policy) {
59
43
  const parsed = new URL(url);
60
44
  if (parsed.protocol !== 'https:' && parsed.protocol !== 'wss:') {
@@ -1,9 +1,9 @@
1
1
  import type { bundle } from '@astrale-os/kernel-dsl/v1';
2
- import type { publication } from '@astrale-os/kernel-protocol';
2
+ import type { DomainRelease } from '@astrale-os/kernel-protocol/release';
3
3
  import type { Fetch } from '../../transport/http/index.js';
4
4
  import type { SessionOperation, SessionPolicy } from '../context/index.js';
5
5
  import { ClientError } from '../../errors/index.js';
6
- export interface BundleDiscoveryOptions {
6
+ interface BundleDiscoveryOptions {
7
7
  readonly fetch: Fetch;
8
8
  readonly policy: Readonly<SessionPolicy>;
9
9
  readonly maximumBytes: number;
@@ -15,7 +15,8 @@ export declare class BundleDiscovery {
15
15
  private readonly options;
16
16
  private retained?;
17
17
  constructor(options: BundleDiscoveryOptions);
18
- get(publication: publication.Publication, operation: SessionOperation): Promise<bundle.Bundle>;
18
+ get(release: DomainRelease, operation: SessionOperation): Promise<bundle.Bundle>;
19
19
  clear(): void;
20
20
  private fetch;
21
21
  }
22
+ export {};
@@ -1,5 +1,4 @@
1
- import { bundleUrl } from '@astrale-os/kernel-protocol/publication';
2
- import { decodeBundleValue } from '@astrale-os/kernel-protocol/publication/bundle';
1
+ import { bundleUrl, decodeBundle } from '@astrale-os/kernel-protocol/release';
3
2
  import { ClientError } from '../../errors/index.js';
4
3
  import { allowEndpoint } from '../context/index.js';
5
4
  import { boundedResponse, requireExactResponse } from './response.js';
@@ -13,26 +12,26 @@ export class BundleDiscovery {
13
12
  constructor(options) {
14
13
  this.options = options;
15
14
  }
16
- async get(publication, operation) {
17
- const key = bundleKey(publication);
18
- allowEndpoint(publication.schema.bundle.href, this.options.policy);
15
+ async get(release, operation) {
16
+ const key = bundleKey(release);
17
+ allowEndpoint(release.schema.bundle.href, this.options.policy);
19
18
  if (this.retained?.key === key)
20
19
  return this.retained.value;
21
- const value = await this.fetch(publication, operation);
20
+ const value = await this.fetch(release, operation);
22
21
  this.retained = { key, value };
23
22
  return value;
24
23
  }
25
24
  clear() {
26
25
  this.retained = undefined;
27
26
  }
28
- async fetch(publication, operation) {
29
- if (publication.schema.bundle.ref.size > this.options.maximumBytes) {
27
+ async fetch(release, operation) {
28
+ if (release.schema.bundle.ref.size > this.options.maximumBytes) {
30
29
  throw new ClientError('Bundle artifact exceeds its byte limit.');
31
30
  }
32
- const href = publication.schema.bundle.href;
33
- const immutable = href === bundleUrl(publication.identity.issuer, publication.schema.bundle.ref);
31
+ const href = release.schema.bundle.href;
32
+ const immutable = href === bundleUrl(release.identity.issuer, release.schema.bundle.ref);
34
33
  const response = await runAcquisition(operation, 'bundle', 'unknown', 'Kernel bundle could not be retrieved.', (signal) => this.options.fetch(href, {
35
- headers: { accept: publication.schema.bundle.ref.mediaType },
34
+ headers: { accept: release.schema.bundle.ref.mediaType },
36
35
  // Omitting `cache` is the browser default; Workers reject the DOM-only 'default' mode.
37
36
  cache: immutable ? undefined : 'no-cache',
38
37
  redirect: 'manual',
@@ -46,27 +45,27 @@ export class BundleDiscovery {
46
45
  }
47
46
  if (!response.ok)
48
47
  throw new ClientError(`Bundle retrieval returned HTTP ${response.status}.`);
49
- if (response.headers.get('content-type') !== publication.schema.bundle.ref.mediaType) {
48
+ if (response.headers.get('content-type') !== release.schema.bundle.ref.mediaType) {
50
49
  throw new ClientError('Bundle artifact media type differs from its descriptor.');
51
50
  }
52
51
  const etag = response.headers.get('etag');
53
- if (etag !== null && etag !== `"${publication.schema.bundle.ref.digest}"`) {
52
+ if (etag !== null && etag !== `"${release.schema.bundle.ref.digest}"`) {
54
53
  throw new ClientError('Bundle response ETag differs from its descriptor.');
55
54
  }
56
- const bytes = await runAcquisition(operation, 'bundle', 'receive', 'Kernel bundle response could not be read.', (signal) => boundedResponse(response, publication.schema.bundle.ref.size, signal));
57
- if (bytes.byteLength !== publication.schema.bundle.ref.size) {
55
+ const bytes = await runAcquisition(operation, 'bundle', 'receive', 'Kernel bundle response could not be read.', (signal) => boundedResponse(response, release.schema.bundle.ref.size, signal));
56
+ if (bytes.byteLength !== release.schema.bundle.ref.size) {
58
57
  throw new ClientError('Bundle artifact size differs from its descriptor.');
59
58
  }
60
- return decodeBundleValue(publication, bytes);
59
+ return decodeBundle(release, bytes);
61
60
  }
62
61
  }
63
- function bundleKey(publication) {
64
- const { href, ref } = publication.schema.bundle;
62
+ function bundleKey(release) {
63
+ const { href, ref } = release.schema.bundle;
65
64
  return JSON.stringify([
66
- publication.identity.issuer,
65
+ release.identity.issuer,
67
66
  new URL(href).origin,
68
- publication.origin,
69
- publication.schema.revision,
67
+ release.origin,
68
+ release.schema.revision,
70
69
  ref.digest,
71
70
  ref.mediaType,
72
71
  ref.size,
@@ -1,5 +1,4 @@
1
1
  import type { IssuerId } from '@astrale-os/kernel-core/auth/issuer';
2
- import type { publication } from '@astrale-os/kernel-protocol';
3
2
  import type { SessionOperation, SessionPolicy } from '../context/index.js';
4
3
  import type { IntrinsicRelease } from './release.js';
5
4
  import type { SessionSnapshot } from './snapshot.js';
@@ -21,8 +20,6 @@ export declare class SessionDiscovery {
21
20
  private releaseFlight?;
22
21
  constructor(kernel: IssuerId, policy: Readonly<SessionPolicy>, releases: IntrinsicReleases, bundles: BundleDiscovery, requireOpen: () => void, acquisitionOperation: () => SessionOperation);
23
22
  release(operation: SessionOperation): Promise<IntrinsicRelease>;
24
- /** @deprecated Successor: `release`. The v3 document of the current release. */
25
- publication(operation: SessionOperation): Promise<publication.Publication>;
26
23
  snapshot(operation: SessionOperation): Promise<SessionSnapshot>;
27
24
  clear(): void;
28
25
  private acquireSnapshot;
@@ -1,7 +1,6 @@
1
1
  import { runSessionOperation } from '../context/index.js';
2
2
  import { rootViewCatalog } from '../views/index.js';
3
3
  import { BundleUnavailableError } from './bundle.js';
4
- import { designation, publicationOf } from './legacy/index.js';
5
4
  import { createSessionSnapshot } from './snapshot.js';
6
5
  export class SessionDiscovery {
7
6
  kernel;
@@ -39,10 +38,6 @@ export class SessionDiscovery {
39
38
  .catch(() => undefined);
40
39
  return runSessionOperation(operation, () => flight);
41
40
  }
42
- /** @deprecated Successor: `release`. The v3 document of the current release. */
43
- async publication(operation) {
44
- return publicationOf(await this.release(operation));
45
- }
46
41
  snapshot(operation) {
47
42
  this.requireOpen();
48
43
  const current = this.flight;
@@ -67,26 +62,23 @@ export class SessionDiscovery {
67
62
  let release = await this.release(operation);
68
63
  let artifact;
69
64
  try {
70
- artifact = await this.bundles.get(publicationOf(release), operation);
65
+ artifact = await this.bundles.get(release, operation);
71
66
  }
72
67
  catch (cause) {
73
68
  if (!(cause instanceof BundleUnavailableError))
74
69
  throw cause;
75
70
  const current = await this.release(operation);
76
- if (designation(current) === designation(release))
71
+ if (current.digest === release.digest)
77
72
  throw cause;
78
73
  release = current;
79
- artifact = await this.bundles.get(publicationOf(release), operation);
74
+ artifact = await this.bundles.get(release, operation);
80
75
  }
81
76
  this.requireOpen();
82
- if (this.retained !== undefined &&
83
- designation(this.retained.release) === designation(release)) {
77
+ if (this.retained !== undefined && this.retained.release.digest === release.digest) {
84
78
  return this.retained;
85
79
  }
86
- // Bundle and root Views come from the v3 document until View provenance names the release.
87
- const publication = publicationOf(release);
88
- const views = rootViewCatalog(publication, artifact, this.policy);
89
- const snapshot = createSessionSnapshot(this.kernel, release, publication, artifact, views);
80
+ const views = rootViewCatalog(release, artifact, this.policy);
81
+ const snapshot = createSessionSnapshot(this.kernel, release, artifact, views);
90
82
  this.retained = snapshot;
91
83
  return snapshot;
92
84
  }
@@ -1,5 +1,4 @@
1
1
  import type { IssuerId } from '@astrale-os/kernel-core/auth/issuer';
2
- import type { publication } from '@astrale-os/kernel-protocol';
3
2
  import type { Fetch } from '../../transport/http/index.js';
4
3
  import type { SessionOperation, SessionPolicy } from '../context/index.js';
5
4
  import type { IntrinsicRelease } from './release.js';
@@ -10,8 +9,6 @@ export { boundedResponse, requireExactResponse } from './response.js';
10
9
  export interface SessionDiscovery {
11
10
  readonly kernel: IssuerId;
12
11
  release(operation: SessionOperation): Promise<IntrinsicRelease>;
13
- /** @deprecated Successor: `release`. */
14
- publication(operation: SessionOperation): Promise<publication.Publication>;
15
12
  snapshot(operation: SessionOperation): Promise<SessionSnapshot>;
16
13
  clear(): void;
17
14
  }
@@ -21,8 +18,6 @@ export interface SessionDiscoveryOptions {
21
18
  readonly policy: Readonly<SessionPolicy>;
22
19
  /** Bounds the source Kernel's own `release.json`. */
23
20
  readonly maximumReleaseBytes: number;
24
- /** Bounds the version 3 Publication a Host that predates `release.json` serves at `domain.json`. */
25
- readonly maximumPublicationBytes: number;
26
21
  readonly maximumBundleBytes: number;
27
22
  readonly requireOpen: () => void;
28
23
  readonly acquisitionOperation: () => SessionOperation;
@@ -1,11 +1,10 @@
1
1
  import { BundleDiscovery } from './bundle.js';
2
2
  import { SessionDiscovery as SessionDiscoveryImplementation } from './discovery.js';
3
- import { IntrinsicReleaseDiscovery, PublicationDiscovery } from './legacy/index.js';
4
3
  import { ReleaseDiscovery } from './release.js';
5
4
  export { boundedResponse, requireExactResponse } from './response.js';
6
5
  export function createSessionDiscovery(options) {
7
6
  const source = { kernel: options.kernel, fetch: options.fetch, policy: options.policy };
8
- return new SessionDiscoveryImplementation(options.kernel, options.policy, new IntrinsicReleaseDiscovery(new ReleaseDiscovery({ ...source, maximumBytes: options.maximumReleaseBytes }), new PublicationDiscovery({ ...source, maximumBytes: options.maximumPublicationBytes })), new BundleDiscovery({
7
+ return new SessionDiscoveryImplementation(options.kernel, options.policy, new ReleaseDiscovery({ ...source, maximumBytes: options.maximumReleaseBytes }), new BundleDiscovery({
9
8
  fetch: options.fetch,
10
9
  policy: options.policy,
11
10
  maximumBytes: options.maximumBundleBytes,
@@ -3,9 +3,9 @@ import type { release } from '@astrale-os/kernel-protocol';
3
3
  import type { Fetch } from '../../transport/http/index.js';
4
4
  import type { SessionOperation } from '../context/index.js';
5
5
  import { type SessionPolicy } from '../context/index.js';
6
- /** The source Kernel's release, or its version 3 Publication when `release.json` is unavailable. */
7
- export type IntrinsicRelease = release.DomainRelease | release.legacy.Publication;
8
- export interface ReleaseDiscoveryOptions {
6
+ /** The source Kernel's exact intrinsic DomainRelease. */
7
+ export type IntrinsicRelease = release.DomainRelease;
8
+ interface ReleaseDiscoveryOptions {
9
9
  readonly kernel: IssuerId;
10
10
  readonly fetch: Fetch;
11
11
  readonly policy: Readonly<SessionPolicy>;
@@ -22,8 +22,9 @@ export declare class ReleaseDiscovery {
22
22
  constructor(options: ReleaseDiscoveryOptions);
23
23
  /** The release admitted since construction, the last `invalidate()` or the last 404, if any. */
24
24
  current(): release.DomainRelease | undefined;
25
- /** The admitted release, or undefined when the Host answers `release.json` with its exact 404. */
26
- revalidate(operation: SessionOperation): Promise<release.DomainRelease | undefined>;
25
+ /** Revalidate the intrinsic release; an absent release is a discovery error. */
26
+ revalidate(operation: SessionOperation): Promise<release.DomainRelease>;
27
27
  invalidate(): void;
28
28
  private fetch;
29
29
  }
30
+ export {};
@@ -19,14 +19,14 @@ export class ReleaseDiscovery {
19
19
  current() {
20
20
  return this.release;
21
21
  }
22
- /** The admitted release, or undefined when the Host answers `release.json` with its exact 404. */
22
+ /** Revalidate the intrinsic release; an absent release is a discovery error. */
23
23
  async revalidate(operation) {
24
24
  const revision = this.revision;
25
25
  const previous = this.release;
26
26
  const discovered = await this.fetch(operation, previous);
27
27
  if (revision !== this.revision)
28
28
  return this.revalidate(operation);
29
- const retained = discovered !== undefined && previous?.digest === discovered.digest ? previous : discovered;
29
+ const retained = previous?.digest === discovered.digest ? previous : discovered;
30
30
  this.release = retained;
31
31
  return retained;
32
32
  }
@@ -49,7 +49,7 @@ export class ReleaseDiscovery {
49
49
  if (response.status === 404) {
50
50
  // Cleanup must not hold discovery open on an injected body cancellation.
51
51
  void response.body?.cancel().catch(() => undefined);
52
- return undefined;
52
+ throw new ClientError('Release discovery returned HTTP 404.');
53
53
  }
54
54
  if (response.status === 304) {
55
55
  if (previous === undefined) {
@@ -1,19 +1,12 @@
1
1
  import type { IssuerId } from '@astrale-os/kernel-core/auth/issuer';
2
2
  import type { bundle } from '@astrale-os/kernel-dsl/v1';
3
- import type { publication } from '@astrale-os/kernel-protocol';
4
3
  import type { ViewCatalog } from '../views/index.js';
5
4
  import type { IntrinsicRelease } from './release.js';
6
5
  /** Coherent public observation acquired through one Client Session at one intrinsic release. */
7
6
  export interface SessionSnapshot {
8
7
  readonly kernel: IssuerId;
9
8
  readonly release: IntrinsicRelease;
10
- /**
11
- * Bundle and root View provenance use this v3 document's ETag.
12
- *
13
- * @deprecated Use `release`.
14
- */
15
- readonly publication: publication.Publication;
16
9
  readonly bundle: bundle.Bundle;
17
10
  readonly views: ViewCatalog;
18
11
  }
19
- export declare function createSessionSnapshot(kernel: IssuerId, release: IntrinsicRelease, publication: publication.Publication, artifact: bundle.Bundle, views: ViewCatalog): SessionSnapshot;
12
+ export declare function createSessionSnapshot(kernel: IssuerId, release: IntrinsicRelease, artifact: bundle.Bundle, views: ViewCatalog): SessionSnapshot;
@@ -1,3 +1,3 @@
1
- export function createSessionSnapshot(kernel, release, publication, artifact, views) {
2
- return Object.freeze({ kernel, release, publication, bundle: artifact, views });
1
+ export function createSessionSnapshot(kernel, release, artifact, views) {
2
+ return Object.freeze({ kernel, release, bundle: artifact, views });
3
3
  }
@@ -26,7 +26,7 @@ export function isKernelOrigin(origin) {
26
26
  export async function installedIssuer(dependencies, origin, source, operation) {
27
27
  const caller = sourceCaller(dependencies, source, operation);
28
28
  const domain = await createSchema(caller.dispatch, dependencies.limits).inspect(origin);
29
- const remote = domain.publication;
29
+ const remote = domain.release;
30
30
  return remote === null || remote.identity.issuer === dependencies.kernel
31
31
  ? undefined
32
32
  : remote.identity.issuer;
@@ -8,7 +8,7 @@ import { ExchangeError } from '../../errors/index.js';
8
8
  /** A resolved source that carries both a credential and its delegation. */
9
9
  export type SourceAuthority = Required<EffectiveAuth>;
10
10
  /** Source Kernel syscalls issued as exactly one admitted source caller within one operation. */
11
- export interface SourceCaller {
11
+ interface SourceCaller {
12
12
  dispatch(call: Call): Promise<Result>;
13
13
  readonly call: AuthCall;
14
14
  }
@@ -30,3 +30,4 @@ export declare function delegationTtl(credential: string | undefined, ttlSeconds
30
30
  * concurrent Calls share one renewal; an auth that cannot refresh keeps the failure.
31
31
  */
32
32
  export declare function renewing<T>(auth: SessionAuth, call: invocation.Call, source: SourceAuthority, operation: SessionOperation, attempt: (source: SourceAuthority) => Promise<T>): Promise<T>;
33
+ export {};
@@ -1,11 +1,12 @@
1
1
  export type { SessionControlOptions, SessionPolicy } from './context/index.js';
2
- export type { ContentApi, ContentLocation, ContentUploadOptions, ContentUploadResult, } from './content.js';
2
+ export type { ContentApi, ContentDownload, ContentLocation, ContentRejection, ContentUploadOptions, ContentUploadResult, } from './content/index.js';
3
3
  export { bindSession, type BoundClientSession, type BoundSessionControls, type BoundSessionSource, } from './bound.js';
4
4
  export { createSessionCredentialProvider, type SessionCredential, type SessionCredentialProvider, type SessionCredentialProviderOptions, type SessionCredentialState, } from './credential/index.js';
5
5
  export type { IntrinsicRelease, SessionSnapshot } from './discovery/index.js';
6
6
  export type { SessionExchangeOptions, SessionExchangeRequest } from './exchange/index.js';
7
7
  export type { Auth, PersistedRoute, SessionRouteArtifact, SessionRouteStore, SessionAuth, SessionEnvelopeTransport, SessionRequestOptions, SessionRequestOptionsWithBody, } from './routing/index.js';
8
- export { ClientSession, connect, type ClientSessionOptions, type ConnectOptions, } from './session.js';
8
+ export type { ClientSessionOptions } from './options.js';
9
+ export { ClientSession, connect, type ConnectOptions } from './session.js';
9
10
  export type { CallableReference, InputOfReference, InputModeOfReference, InstanceCallableReference, OutputOfReference, } from './reference.js';
10
11
  export { reference } from './reference.js';
11
12
  export { execution, type ExecutionOutcome, type ExecutionRef, type ExecutionState, type ExecutionStatus, } from './execution.js';
@@ -1,5 +1,5 @@
1
1
  export { bindSession, } from './bound.js';
2
2
  export { createSessionCredentialProvider, } from './credential/index.js';
3
- export { ClientSession, connect, } from './session.js';
3
+ export { ClientSession, connect } from './session.js';
4
4
  export { reference } from './reference.js';
5
5
  export { execution, } from './execution.js';
@@ -0,0 +1,65 @@
1
+ import type { IssuerId } from '@astrale-os/kernel-core/auth/issuer';
2
+ import type { ClientFactory, ClientPool as ClientPoolType } from '../pool/index.js';
3
+ import type { ClientWarning } from '../transport/auto/index.js';
4
+ import type { Fetch } from '../transport/http/index.js';
5
+ import type { WebSocketConstructor } from '../transport/websocket/index.js';
6
+ import type { SessionPolicy } from './context/index.js';
7
+ import type { SessionExchangeOptions } from './exchange/index.js';
8
+ import type { ClientPoolCapability, SessionAuth, SessionEnvelopeTransport, SessionRouteStore } from './routing/index.js';
9
+ import { ClientPool } from '../pool/index.js';
10
+ import { RouteCache } from './routing/index.js';
11
+ export interface ClientSessionOptions {
12
+ /** Exact canonical source Kernel identity; its invocation and discovery endpoints are derived. */
13
+ readonly kernel: string;
14
+ readonly fetch?: Fetch;
15
+ readonly client?: ClientFactory;
16
+ readonly pool?: Pick<ClientPoolType, 'clientFor'>;
17
+ readonly websocket?: WebSocketConstructor;
18
+ readonly auth?: SessionAuth;
19
+ /**
20
+ * Present each Domain callable with a credential its declaring Domain exchanges for the `auth`
21
+ * caller, so the Domain is the principal and the caller is `auth`. Kernel and local callables keep
22
+ * the `auth` credential. `connect` defaults to `auto` when `auth` is present; `new ClientSession`
23
+ * keeps source authority when this option is omitted. `{ mode: 'source' }` keeps it for every Call.
24
+ */
25
+ readonly exchange?: SessionExchangeOptions;
26
+ /** Optional caller-owned persistence for bounded confidential route artifacts. */
27
+ readonly routeStore?: SessionRouteStore;
28
+ readonly policy: SessionPolicy;
29
+ readonly envelopeTransport?: SessionEnvelopeTransport;
30
+ readonly onWarning?: (warning: ClientWarning) => void;
31
+ /** Bounds the source Kernel's own `release.json`. */
32
+ readonly maximumReleaseBytes?: number;
33
+ readonly maximumBundleBytes?: number;
34
+ readonly maximumResponseBytes?: number;
35
+ readonly timeoutMs?: number;
36
+ readonly schemaLifecycleTimeoutMs?: number;
37
+ }
38
+ /** The caller's options once admitted, defaulted and captured, ready for the Session to wire. */
39
+ export interface SessionConfiguration {
40
+ readonly kernel: IssuerId;
41
+ readonly sourceEndpoint: string;
42
+ readonly policy: Readonly<SessionPolicy>;
43
+ readonly fetch: Fetch;
44
+ readonly maximumReleaseBytes: number;
45
+ readonly maximumBundleBytes: number;
46
+ readonly maximumResponseBytes: number;
47
+ readonly timeoutMs: number;
48
+ readonly schemaLifecycleTimeoutMs: number;
49
+ readonly websocketAvailable: boolean;
50
+ /** Present when the Session created, and therefore closes, its own pool. */
51
+ readonly ownedPool?: ClientPool;
52
+ readonly pool: ClientPoolCapability;
53
+ readonly routes: RouteCache;
54
+ readonly auth: SessionAuth | undefined;
55
+ readonly exchange: Readonly<{
56
+ ttlSeconds: number;
57
+ }> | undefined;
58
+ readonly envelopeTransport: SessionEnvelopeTransport;
59
+ }
60
+ /**
61
+ * Settle the caller's options in their public rejection order: the options object, policy, Kernel,
62
+ * Fetch, client/pool exclusivity, byte limits, durations, pool, route store, auth, exchange and
63
+ * envelope transport.
64
+ */
65
+ export declare function acceptSessionOptions(options: ClientSessionOptions): SessionConfiguration;