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

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 (104) 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/index.d.ts +1 -1
  8. package/dist/graph/index.js +1 -1
  9. package/dist/schema/introspection.js +1 -5
  10. package/dist/schema/schema.js +4 -8
  11. package/dist/session/bound.d.ts +1 -1
  12. package/dist/session/bound.js +2 -1
  13. package/dist/session/content/api.d.ts +45 -0
  14. package/dist/session/content/api.js +28 -0
  15. package/dist/session/content/batch.d.ts +5 -0
  16. package/dist/session/content/batch.js +93 -0
  17. package/dist/session/content/index.d.ts +1 -0
  18. package/dist/session/content/index.js +1 -0
  19. package/dist/session/content/input.d.ts +9 -0
  20. package/dist/session/content/input.js +33 -0
  21. package/dist/session/content/parts.d.ts +36 -0
  22. package/dist/session/content/parts.js +154 -0
  23. package/dist/session/content/retry.d.ts +3 -0
  24. package/dist/session/content/retry.js +41 -0
  25. package/dist/session/content/wire.d.ts +12 -0
  26. package/dist/session/content/wire.js +60 -0
  27. package/dist/session/context/index.d.ts +1 -1
  28. package/dist/session/context/index.js +1 -1
  29. package/dist/session/context/limits.d.ts +0 -1
  30. package/dist/session/context/limits.js +0 -1
  31. package/dist/session/context/operation.d.ts +0 -1
  32. package/dist/session/context/operation.js +1 -1
  33. package/dist/session/context/policy.d.ts +0 -1
  34. package/dist/session/context/policy.js +0 -16
  35. package/dist/session/discovery/bundle.d.ts +4 -3
  36. package/dist/session/discovery/bundle.js +20 -21
  37. package/dist/session/discovery/discovery.d.ts +0 -3
  38. package/dist/session/discovery/discovery.js +6 -14
  39. package/dist/session/discovery/index.d.ts +0 -5
  40. package/dist/session/discovery/index.js +1 -2
  41. package/dist/session/discovery/release.d.ts +6 -5
  42. package/dist/session/discovery/release.js +3 -3
  43. package/dist/session/discovery/snapshot.d.ts +1 -8
  44. package/dist/session/discovery/snapshot.js +2 -2
  45. package/dist/session/exchange/domain.js +1 -1
  46. package/dist/session/exchange/source.d.ts +2 -1
  47. package/dist/session/index.d.ts +3 -2
  48. package/dist/session/index.js +1 -1
  49. package/dist/session/options.d.ts +65 -0
  50. package/dist/session/options.js +132 -0
  51. package/dist/session/routing/cache.d.ts +9 -14
  52. package/dist/session/routing/cache.js +17 -178
  53. package/dist/session/routing/dispatch.d.ts +4 -3
  54. package/dist/session/routing/dispatch.js +63 -113
  55. package/dist/session/routing/envelope.d.ts +3 -3
  56. package/dist/session/routing/expiry.d.ts +4 -0
  57. package/dist/session/routing/expiry.js +32 -0
  58. package/dist/session/routing/index.d.ts +4 -2
  59. package/dist/session/routing/index.js +4 -2
  60. package/dist/session/routing/integrity.d.ts +7 -0
  61. package/dist/session/routing/integrity.js +44 -0
  62. package/dist/session/routing/recovery.d.ts +16 -0
  63. package/dist/session/routing/recovery.js +41 -0
  64. package/dist/session/routing/result.d.ts +5 -0
  65. package/dist/session/routing/result.js +12 -0
  66. package/dist/session/routing/store.d.ts +23 -0
  67. package/dist/session/routing/store.js +99 -0
  68. package/dist/session/session.d.ts +6 -50
  69. package/dist/session/session.js +28 -134
  70. package/dist/session/session.typecheck.js +8 -3
  71. package/dist/session/views/catalog.d.ts +5 -9
  72. package/dist/session/views/catalog.js +12 -24
  73. package/dist/session/views/resolve.d.ts +1 -1
  74. package/dist/session/views/resolve.js +1 -1
  75. package/dist/store/entity-index.d.ts +1 -2
  76. package/dist/store/entity-index.js +0 -3
  77. package/dist/store/memory.js +2 -2
  78. package/dist/store/shape.d.ts +2 -1
  79. package/dist/transport/auto/decision.d.ts +3 -2
  80. package/dist/transport/http/admission.d.ts +5 -0
  81. package/dist/transport/http/admission.js +101 -0
  82. package/dist/transport/http/binary.d.ts +5 -0
  83. package/dist/transport/http/binary.js +70 -0
  84. package/dist/transport/http/configuration.d.ts +24 -0
  85. package/dist/transport/http/configuration.js +116 -0
  86. package/dist/transport/http/index.d.ts +2 -1
  87. package/dist/transport/http/response.d.ts +7 -0
  88. package/dist/transport/http/response.js +9 -0
  89. package/dist/transport/http/retired.d.ts +8 -0
  90. package/dist/transport/http/retired.js +28 -0
  91. package/dist/transport/http/transport.d.ts +1 -19
  92. package/dist/transport/http/transport.js +17 -299
  93. package/dist/transport/websocket/connection.d.ts +2 -1
  94. package/package.json +5 -5
  95. package/dist/session/content.d.ts +0 -27
  96. package/dist/session/content.js +0 -135
  97. package/dist/session/discovery/legacy/index.d.ts +0 -38
  98. package/dist/session/discovery/legacy/index.js +0 -38
  99. package/dist/session/discovery/legacy/intrinsic.d.ts +0 -33
  100. package/dist/session/discovery/legacy/intrinsic.js +0 -67
  101. package/dist/session/discovery/legacy/projection.d.ts +0 -8
  102. package/dist/session/discovery/legacy/projection.js +0 -17
  103. package/dist/session/discovery/legacy/publication.d.ts +0 -26
  104. package/dist/session/discovery/legacy/publication.js +0 -76
@@ -0,0 +1,101 @@
1
+ import * as protocol from '@astrale-os/kernel-protocol/invocation';
2
+ import * as retirement from '@astrale-os/kernel-protocol/routes';
3
+ import { ProtocolError, ResponseError } from '../../errors/index.js';
4
+ import { invocationFailure } from '../failure.js';
5
+ import { requireLive } from '../index.js';
6
+ import { decodeBinary } from './binary.js';
7
+ import { codecForResponse, decodeProtocol, readBoundedBody, requireId, requireNoStore, } from './response.js';
8
+ import { decodeDeploymentRetired } from './retired.js';
9
+ import { HttpStream } from './stream.js';
10
+ /** Admit exactly one response representation, preserving reserved-control precedence. */
11
+ export async function admitResponse(response, requestId, context) {
12
+ const { control, maximumBytes } = context;
13
+ if (response.status >= 300 && response.status < 400) {
14
+ throw new ProtocolError('server returned a network redirect.');
15
+ }
16
+ const streamFraming = response.headers.get(protocol.http.STREAM_FRAMING_FIELD);
17
+ const binaryId = response.headers.get(protocol.http.REQUEST_ID_FIELD);
18
+ const binaryManifest = response.headers.get(protocol.http.BINARY_HEADERS_FIELD);
19
+ const binaryDelivery = response.headers.get(protocol.http.BINARY_DELIVERY_FIELD);
20
+ const hasStreamSignal = streamFraming !== null;
21
+ const hasBinarySignal = binaryId !== null || binaryManifest !== null || binaryDelivery !== null;
22
+ const responseCodec = codecForResponse(response.headers.get('content-type'));
23
+ if (response.headers.has(retirement.HTTP_DEPLOYMENT_RETIRED)) {
24
+ if (hasStreamSignal || hasBinarySignal) {
25
+ throw new ProtocolError('server returned a deployment-retired control with a stream or binary signal.');
26
+ }
27
+ const retired = await decodeDeploymentRetired(response, responseCodec, context);
28
+ requireLive(control);
29
+ return retired;
30
+ }
31
+ if (!response.ok && responseCodec === undefined && !hasStreamSignal && !hasBinarySignal) {
32
+ throw invocationFailure(`server returned HTTP ${response.status} without an invocation response.`, 'receive', { delivery: 'unknown' });
33
+ }
34
+ requireNoStore(response);
35
+ if (hasStreamSignal && hasBinarySignal) {
36
+ throw new ProtocolError('server returned conflicting stream and binary response signals.');
37
+ }
38
+ if (hasBinarySignal) {
39
+ if (binaryId === null || binaryManifest === null) {
40
+ throw new ProtocolError('server returned an incomplete binary response signal.');
41
+ }
42
+ if (binaryDelivery !== null && binaryDelivery !== protocol.http.STREAMING_BINARY_DELIVERY) {
43
+ throw new ProtocolError('server returned an unsupported binary delivery signal.');
44
+ }
45
+ const binary = await decodeBinary(response, requestId, binaryId, binaryDelivery !== null, context);
46
+ return binary;
47
+ }
48
+ if (responseCodec === undefined) {
49
+ throw new ProtocolError(`server returned unsupported Content-Type ${JSON.stringify(response.headers.get('content-type'))}.`);
50
+ }
51
+ if (hasStreamSignal) {
52
+ if (streamFraming !== protocol.http.LENGTH_PREFIX_V1) {
53
+ throw new ProtocolError(`server returned unsupported stream framing ${JSON.stringify(streamFraming)}.`);
54
+ }
55
+ if (!response.ok) {
56
+ throw new ProtocolError('server returned a non-success stream response.');
57
+ }
58
+ const stream = await HttpStream.open(response, responseCodec, requestId, maximumBytes, control);
59
+ requireLive(control);
60
+ return { kind: 'stream', stream, invocation: stream.invocation };
61
+ }
62
+ const body = await readBoundedBody(response, maximumBytes, control.signal);
63
+ requireLive(control);
64
+ const decoded = decodeProtocol('response body', () => responseCodec.decode(body));
65
+ const envelope = decodeProtocol('response envelope', () => protocol.decodeResponse(decoded));
66
+ if (envelope.requestId === null && 'error' in envelope) {
67
+ throw new ResponseError(envelope.error.code, envelope.error.message, envelope.invocation, envelope.error.data);
68
+ }
69
+ requireId(requestId, envelope.requestId);
70
+ if ('kind' in envelope && envelope.kind === 'stale') {
71
+ const stale = decodeProtocol('stale response', () => protocol.decodeStale(envelope));
72
+ requireLive(control);
73
+ return Object.freeze({
74
+ kind: 'stale',
75
+ current: stale.current,
76
+ invocation: stale.invocation,
77
+ });
78
+ }
79
+ if ('kind' in envelope && envelope.kind === 'miss') {
80
+ decodeProtocol('miss response', () => protocol.decodeMiss(envelope));
81
+ requireLive(control);
82
+ return Object.freeze({ kind: 'miss', invocation: envelope.invocation });
83
+ }
84
+ if ('kind' in envelope && envelope.kind === 'redirect') {
85
+ const response = decodeProtocol('redirect response', () => protocol.decodeRedirectResponse(envelope));
86
+ requireLive(control);
87
+ return redirectResult(response);
88
+ }
89
+ if ('error' in envelope) {
90
+ throw new ResponseError(envelope.error.code, envelope.error.message, envelope.invocation, envelope.error.data);
91
+ }
92
+ requireLive(control);
93
+ return { kind: 'value', value: envelope.result, invocation: envelope.invocation };
94
+ }
95
+ function redirectResult(response) {
96
+ return Object.freeze({
97
+ kind: 'redirect',
98
+ invocation: response.invocation,
99
+ redirect: response.redirect,
100
+ });
101
+ }
@@ -0,0 +1,5 @@
1
+ import * as protocol from '@astrale-os/kernel-protocol/invocation';
2
+ import type { BinaryResponse } from '../../client/index.js';
3
+ import { type ResponseContext } from './response.js';
4
+ /** Admit buffered or streaming binary output within the invocation's lifetime. */
5
+ export declare function decodeBinary(response: Response, requestId: protocol.RequestId, binaryId: string, streaming: boolean, context: ResponseContext): Promise<BinaryResponse>;
@@ -0,0 +1,70 @@
1
+ import { canonicalMediaType } from '@astrale-os/kernel-protocol/artifact';
2
+ import * as protocol from '@astrale-os/kernel-protocol/invocation';
3
+ import { ProtocolError } from '../../errors/index.js';
4
+ import { requireLive } from '../index.js';
5
+ import { HttpByteStream } from './byte-stream.js';
6
+ import { binaryHeaders, decodeProtocol, readBoundedBody } from './response.js';
7
+ /** Admit buffered or streaming binary output within the invocation's lifetime. */
8
+ export async function decodeBinary(response, requestId, binaryId, streaming, context) {
9
+ const { control, maximumBytes } = context;
10
+ if (binaryId !== String(requestId)) {
11
+ throw new ProtocolError(`binary response requestId ${JSON.stringify(binaryId)} does not match request requestId ${requestId}.`);
12
+ }
13
+ const contentType = response.headers.get('content-type');
14
+ if (contentType === null) {
15
+ throw new ProtocolError('binary response has no media type.');
16
+ }
17
+ const mediaType = decodeProtocol('binary media type', () => canonicalMediaType(contentType));
18
+ const headerNames = decodeProtocol('binary application-header manifest', () => protocol.http.decodeBinaryHeaderNames(response.headers.get(protocol.http.BINARY_HEADERS_FIELD)));
19
+ const headers = binaryHeaders(response.headers, headerNames);
20
+ const invocation = decodeProtocol('binary InvocationId field', () => protocol.http.decodeInvocationId(response.headers.get(protocol.http.INVOCATION_FIELD)));
21
+ if (streaming) {
22
+ if (response.body === null)
23
+ throw new ProtocolError('streaming binary has no body.');
24
+ // An intermediary may rewrite Content-Length (for example when it compresses the body), so
25
+ // only the protocol length counts.
26
+ const length = response.headers.get(protocol.http.BINARY_LENGTH_FIELD);
27
+ const expectedBytes = length === null ? undefined : protocol.http.decodeBinaryLength(length);
28
+ if (length !== null && expectedBytes === undefined) {
29
+ throw new ProtocolError(`streaming binary has an invalid ${protocol.http.BINARY_LENGTH_FIELD}.`);
30
+ }
31
+ if (expectedBytes !== undefined && expectedBytes > maximumBytes) {
32
+ throw new ProtocolError(`streaming binary exceeds maximumResponseBytes (${maximumBytes}).`);
33
+ }
34
+ requireLive(control);
35
+ return {
36
+ kind: 'binary',
37
+ invocation,
38
+ value: {
39
+ body: new HttpByteStream(response.body, maximumBytes, control, expectedBytes),
40
+ // The byte stream enforces this exact count through its final read.
41
+ ...(expectedBytes === undefined ? {} : { length: expectedBytes }),
42
+ mediaType,
43
+ ...(response.status === 200 ? {} : { status: response.status }),
44
+ ...(Object.keys(headers).length === 0 ? {} : { headers }),
45
+ },
46
+ };
47
+ }
48
+ const body = await readBoundedBody(response, maximumBytes, control.signal);
49
+ requireLive(control);
50
+ const binary = decodeProtocol('binary response', () => protocol.decodeBinaryResponse({
51
+ kind: 'binary',
52
+ requestId,
53
+ invocation,
54
+ body,
55
+ mediaType,
56
+ status: response.status,
57
+ ...(Object.keys(headers).length === 0 ? {} : { headers }),
58
+ }));
59
+ requireLive(control);
60
+ return {
61
+ kind: 'binary',
62
+ invocation: binary.invocation,
63
+ value: {
64
+ body: binary.body,
65
+ mediaType: binary.mediaType,
66
+ ...(binary.status === 200 ? {} : { status: binary.status }),
67
+ ...(binary.headers === undefined ? {} : { headers: binary.headers }),
68
+ },
69
+ };
70
+ }
@@ -0,0 +1,24 @@
1
+ /** Web Fetch capability used by the built-in HTTP transport. */
2
+ export type Fetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
3
+ export interface HttpTransportOptions {
4
+ readonly url: string;
5
+ /** Inject this capability when the host does not provide global Fetch. */
6
+ readonly fetch?: Fetch;
7
+ readonly headers?: Readonly<Record<string, string>>;
8
+ readonly timeoutMs?: number;
9
+ /** Maximum bytes in one encoded request before Fetch handoff. */
10
+ readonly maximumRequestBytes?: number;
11
+ /** Maximum unary, binary, or individual stream-frame body size. */
12
+ readonly maximumResponseBytes?: number;
13
+ }
14
+ /** Captured transport configuration, admitted once before any invocation. */
15
+ export interface Configuration {
16
+ readonly url: string;
17
+ readonly fetch: Fetch;
18
+ readonly headers: Readonly<Record<string, string>>;
19
+ readonly timeoutMs: number;
20
+ readonly maximumRequestBytes: number;
21
+ readonly maximumResponseBytes: number;
22
+ }
23
+ /** Admit static options and detach the caller's request headers. */
24
+ export declare function capture(options: HttpTransportOptions): Configuration;
@@ -0,0 +1,116 @@
1
+ import * as protocol from '@astrale-os/kernel-protocol/invocation';
2
+ import { asError, positiveInteger } from '../index.js';
3
+ const DEFAULT_TIMEOUT_MS = 30_000;
4
+ const DEFAULT_MAXIMUM_REQUEST_BYTES = 16 * 1024 * 1024;
5
+ const DEFAULT_MAXIMUM_RESPONSE_BYTES = 16 * 1024 * 1024;
6
+ /** Admit static options and detach the caller's request headers. */
7
+ export function capture(options) {
8
+ if (options === null || typeof options !== 'object') {
9
+ throw new TypeError('HttpTransport options must be an object.');
10
+ }
11
+ return {
12
+ url: normalizeUrl(options.url),
13
+ fetch: admitFetch(options.fetch),
14
+ headers: admitHeaders(options.headers ?? {}),
15
+ timeoutMs: positiveInteger(options.timeoutMs ?? DEFAULT_TIMEOUT_MS, 'timeoutMs'),
16
+ maximumRequestBytes: positiveInteger(options.maximumRequestBytes ?? DEFAULT_MAXIMUM_REQUEST_BYTES, 'maximumRequestBytes'),
17
+ maximumResponseBytes: positiveInteger(options.maximumResponseBytes ?? DEFAULT_MAXIMUM_RESPONSE_BYTES, 'maximumResponseBytes'),
18
+ };
19
+ }
20
+ function normalizeUrl(input) {
21
+ if (typeof input !== 'string')
22
+ throw new TypeError('server URL must be a string.');
23
+ let parsed;
24
+ try {
25
+ parsed = new URL(input);
26
+ }
27
+ catch (error) {
28
+ throw new TypeError(`Invalid server URL ${JSON.stringify(input)}.`, { cause: asError(error) });
29
+ }
30
+ if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
31
+ throw new TypeError('server URL must use http or https.');
32
+ }
33
+ if (parsed.username !== '' || parsed.password !== '' || parsed.hash !== '') {
34
+ throw new TypeError('server URL cannot contain credentials or a fragment.');
35
+ }
36
+ return parsed.toString();
37
+ }
38
+ function admitHeaders(input) {
39
+ if (input === null || typeof input !== 'object' || Array.isArray(input)) {
40
+ throw new TypeError('HTTP headers must be an object.');
41
+ }
42
+ const output = {};
43
+ for (const [name, value] of Object.entries(input)) {
44
+ if (!HEADER_NAME.test(name)) {
45
+ throw new TypeError(`HTTP header name ${JSON.stringify(name)} is invalid.`);
46
+ }
47
+ const normalized = name.toLowerCase();
48
+ if (Object.hasOwn(output, normalized)) {
49
+ throw new TypeError(`HTTP header ${JSON.stringify(name)} occurs more than once.`);
50
+ }
51
+ if (isReservedRequestHeader(normalized)) {
52
+ throw new TypeError(`HTTP header ${JSON.stringify(name)} is owned by transport.`);
53
+ }
54
+ if (typeof value !== 'string') {
55
+ throw new TypeError(`HTTP header ${JSON.stringify(name)} must be a string.`);
56
+ }
57
+ if (hasControlCharacter(value)) {
58
+ throw new TypeError(`HTTP header ${JSON.stringify(name)} contains a control character.`);
59
+ }
60
+ output[normalized] = value;
61
+ }
62
+ return Object.freeze(output);
63
+ }
64
+ function admitFetch(input) {
65
+ const implementation = input ?? globalThis.fetch;
66
+ if (typeof implementation !== 'function') {
67
+ throw new TypeError('HttpTransport requires a Fetch implementation.');
68
+ }
69
+ return input === undefined ? implementation.bind(globalThis) : implementation;
70
+ }
71
+ const HEADER_NAME = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
72
+ const RESERVED_REQUEST_HEADERS = new Set([
73
+ 'accept',
74
+ 'accept-encoding',
75
+ 'authorization',
76
+ 'cache-control',
77
+ 'connection',
78
+ 'content-length',
79
+ 'content-type',
80
+ 'cookie',
81
+ 'forwarded',
82
+ 'host',
83
+ 'keep-alive',
84
+ 'origin',
85
+ 'pragma',
86
+ 'proxy-authenticate',
87
+ 'proxy-authorization',
88
+ 'referer',
89
+ 'referrer-policy',
90
+ 'set-cookie',
91
+ 'te',
92
+ protocol.http.TRACEPARENT_FIELD,
93
+ protocol.http.TRACESTATE_FIELD,
94
+ protocol.http.BAGGAGE_FIELD,
95
+ 'trailer',
96
+ 'transfer-encoding',
97
+ 'upgrade',
98
+ 'via',
99
+ ]);
100
+ function isReservedRequestHeader(name) {
101
+ return (RESERVED_REQUEST_HEADERS.has(name) ||
102
+ name.startsWith('access-control-') ||
103
+ name.startsWith('content-') ||
104
+ name.startsWith('proxy-') ||
105
+ name.startsWith('sec-websocket-') ||
106
+ name.startsWith('x-astrale-') ||
107
+ name.startsWith('x-forwarded-'));
108
+ }
109
+ function hasControlCharacter(input) {
110
+ for (let index = 0; index < input.length; index += 1) {
111
+ const code = input.charCodeAt(index);
112
+ if (code <= 0x1f || code === 0x7f)
113
+ return true;
114
+ }
115
+ return false;
116
+ }
@@ -1 +1,2 @@
1
- export { HttpTransport, type Fetch, type HttpTransportOptions } from './transport.js';
1
+ export { HttpTransport } from './transport.js';
2
+ export type { Fetch, HttpTransportOptions } from './configuration.js';
@@ -1,8 +1,15 @@
1
1
  import * as codecs from '@astrale-os/kernel-protocol/codecs';
2
2
  import * as protocol from '@astrale-os/kernel-protocol/invocation';
3
+ import { type ControlledSignal } from '../index.js';
4
+ /** The body budget and cancellation lifetime shared by all response representations. */
5
+ export interface ResponseContext {
6
+ readonly maximumBytes: number;
7
+ readonly control: ControlledSignal;
8
+ }
3
9
  export declare function codecForResponse(contentType: string | null): codecs.Codec | undefined;
4
10
  export declare function readBoundedBody(response: Response, maximumBytes: number, signal: AbortSignal): Promise<Uint8Array>;
5
11
  export declare function requireId(expected: protocol.RequestId, received: protocol.RequestId): void;
6
12
  export declare function decodeProtocol<T>(label: string, decode: () => T): T;
7
13
  export declare function normalizeMediaType(input: string | null): string | undefined;
8
14
  export declare function binaryHeaders(input: Headers, names: readonly string[]): Readonly<Record<string, string>>;
15
+ export declare function requireNoStore(response: Response): void;
@@ -73,3 +73,12 @@ export function binaryHeaders(input, names) {
73
73
  }
74
74
  return Object.freeze(output);
75
75
  }
76
+ export function requireNoStore(response) {
77
+ const directives = response.headers
78
+ .get('cache-control')
79
+ ?.split(',')
80
+ .map((directive) => directive.trim().toLowerCase()) ?? [];
81
+ if (!directives.includes('no-store')) {
82
+ throw new ProtocolError('server response is missing Cache-Control: no-store.');
83
+ }
84
+ }
@@ -0,0 +1,8 @@
1
+ import type * as codecs from '@astrale-os/kernel-protocol/codecs';
2
+ import type { DeploymentRetired } from '../index.js';
3
+ import { type ResponseContext } from './response.js';
4
+ /**
5
+ * Admit the reserved retirement control only as the exact 410, header and envelope triple; the
6
+ * header beside any other status, value or body is an invalid response, never an ordinary error.
7
+ */
8
+ export declare function decodeDeploymentRetired(response: Response, codec: codecs.Codec | undefined, context: ResponseContext): Promise<DeploymentRetired>;
@@ -0,0 +1,28 @@
1
+ import * as protocol from '@astrale-os/kernel-protocol/invocation';
2
+ import * as retirement from '@astrale-os/kernel-protocol/routes';
3
+ import { ProtocolError } from '../../errors/index.js';
4
+ import { decodeProtocol, readBoundedBody, requireNoStore, } from './response.js';
5
+ /**
6
+ * Admit the reserved retirement control only as the exact 410, header and envelope triple; the
7
+ * header beside any other status, value or body is an invalid response, never an ordinary error.
8
+ */
9
+ export async function decodeDeploymentRetired(response, codec, context) {
10
+ const { control, maximumBytes } = context;
11
+ if (codec === undefined) {
12
+ throw new ProtocolError('server returned a deployment-retired control without an envelope.');
13
+ }
14
+ requireNoStore(response);
15
+ const body = await readBoundedBody(response, maximumBytes, control.signal);
16
+ const decoded = decodeProtocol('deployment-retired body', () => codec.decode(body));
17
+ const retired = decodeProtocol('deployment-retired control', () => retirement.decodeDeploymentRetired(response.status, response.headers, decoded));
18
+ const envelope = decodeProtocol('deployment-retired envelope', () => protocol.decodeResponse(decoded));
19
+ if (retired === undefined || !('error' in envelope)) {
20
+ throw new ProtocolError('server returned an invalid deployment-retired control.');
21
+ }
22
+ return Object.freeze({
23
+ kind: 'deployment-retired',
24
+ reason: retired.reason,
25
+ message: envelope.error.message,
26
+ invocation: envelope.invocation,
27
+ });
28
+ }
@@ -1,17 +1,5 @@
1
1
  import type { RequestOptions, Transport, TransportRequest, TransportResult } from '../index.js';
2
- /** Web Fetch capability used by the built-in HTTP transport. */
3
- export type Fetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
4
- export interface HttpTransportOptions {
5
- readonly url: string;
6
- /** Inject this capability when the host does not provide global Fetch. */
7
- readonly fetch?: Fetch;
8
- readonly headers?: Readonly<Record<string, string>>;
9
- readonly timeoutMs?: number;
10
- /** Maximum bytes in one encoded request before Fetch handoff. */
11
- readonly maximumRequestBytes?: number;
12
- /** Maximum unary, binary, or individual stream-frame body size. */
13
- readonly maximumResponseBytes?: number;
14
- }
2
+ import type { HttpTransportOptions } from './configuration.js';
15
3
  /** HTTP implementation of the universal invocation protocol. */
16
4
  export declare class HttpTransport implements Transport {
17
5
  readonly url: string;
@@ -27,11 +15,5 @@ export declare class HttpTransport implements Transport {
27
15
  dispatchBinary(input: TransportRequest, body: Blob, options?: RequestOptions): Promise<TransportResult>;
28
16
  private dispatchWith;
29
17
  private fetchResponse;
30
- /**
31
- * Admit the reserved retirement control only as the exact 410, header and envelope triple; the
32
- * header beside any other status, value or body is an invalid response, never an ordinary error.
33
- */
34
- private decodeDeploymentRetired;
35
- private decodeBinary;
36
18
  private nextRequestId;
37
19
  }